# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['pydivkit', 'pydivkit.core', 'pydivkit.core.types', 'pydivkit.div']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'pydivkit',
    'version': '13.0.0b0',
    'description': 'DivKit python library',
    'long_description': 'PyDIVKit examples\n=================\n\nThis library is for working with DivKit with python.\n\nFeatures:\n* Declarative and imperative DivKit blocks definition\n* Native Type-hints support\n* Complete object-oriented API\n* IDE type checks and suggestions\n\nObject construction\n-------------------\n\nThe main idea is a provides ability to construct blocks by python objects.\n\n```python\nimport json\nimport pydivkit as dk\n\ncontainer = dk.DivContainer(\n    items=[\n        dk.DivGallery(\n            items=[\n                dk.DivText(text="Hello from pydivkit")\n            ]\n        )\n    ]\n)\n\nprint(json.dumps(container.dict(), indent=1))\n# {\n#  "type": "container",\n#  "items": [\n#   {\n#    "type": "gallery",\n#    "items": [\n#     {\n#      "type": "text",\n#      "text": "Hello from pydivkit"\n#     }\n#    ]\n#   }\n#  ]\n# }\n```\n\nSlider example\n--------------\n\nFollowing code is a rewritten slider example using pydivkit.\n\n```python\nimport pydivkit as dk\n\n\nslider = dk.DivData(\n    log_id="sample_card",\n    states=[\n        dk.DivDataState(\n            state_id=0,\n            div=dk.DivSlider(\n                width=dk.DivMatchParentSize(),\n                max_value=10,\n                min_value=1,\n                thumb_style=dk.DivShapeDrawable(\n                    color="#00b300",\n                    stroke=dk.DivStroke(\n                        color="#ffffff",\n                        width=3,\n                    ),\n                    shape=dk.DivRoundedRectangleShape(\n                        item_width=dk.DivFixedSize(value=32),\n                        item_height=dk.DivFixedSize(value=32),\n                        corner_radius=dk.DivFixedSize(value=100)\n                    ),\n                ),\n                track_active_style=dk.DivShapeDrawable(\n                    color="#00b300",\n                    shape=dk.DivRoundedRectangleShape(\n                        item_height=dk.DivFixedSize(value=6)\n                    )\n                ),\n                track_inactive_style=dk.DivShapeDrawable(\n                    color="#20000000",\n                    shape=dk.DivRoundedRectangleShape(\n                        item_height=dk.DivFixedSize(value=6)\n                    )\n                )\n            )\n        )\n    ]\n)\n\n```\n\nThis example might be serialised like this:\n\n```python\nimport json\n\nprint(json.dumps(slider.dict(), indent=1))\n# {\n#  "log_id": "sample_card",\n#  "states": [\n#   {\n#    "div": {\n#     "type": "slider",\n#     "max_value": 10,\n#     "min_value": 1,\n#     "thumb_style": {\n#      "type": "shape_drawable",\n#      "color": "#00b300",\n#      "shape": {\n#       "type": "rounded_rectangle",\n#       "corner_radius": {\n#        "type": "fixed",\n#        "value": 100\n#       },\n#       "item_height": {\n#        "type": "fixed",\n#        "value": 32\n#       },\n#       "item_width": {\n#        "type": "fixed",\n#        "value": 32\n#       }\n#      },\n#      "stroke": {\n#       "color": "#ffffff",\n#       "width": 3\n#      }\n#     },\n#     "track_active_style": {\n#      "type": "shape_drawable",\n#      "color": "#00b300",\n#      "shape": {\n#       "type": "rounded_rectangle",\n#       "item_height": {\n#        "type": "fixed",\n#        "value": 6\n#       }\n#      }\n#     },\n#     "track_inactive_style": {\n#      "type": "shape_drawable",\n#      "color": "#20000000",\n#      "shape": {\n#       "type": "rounded_rectangle",\n#       "item_height": {\n#        "type": "fixed",\n#        "value": 6\n#       }\n#      }\n#     },\n#     "width": {\n#      "type": "match_parent"\n#     }\n#    },\n#    "state_id": 0\n#   }\n#  ]\n# }\n```\n\nTemplating and DRY\n------------------\n\nOf course building blocks from your code every time manually it\'s\na very boring. So the first idea it\'s a move initialization of the \nDivKit objects to the functions.\n\n```python\n# Naive DRY example which strictly non-recommended\nimport pydivkit as dk\n\n\ndef get_size(value: int = 32) -> dk.DivFixedSize:\n    return dk.DivFixedSize(value=value)\n\n\ndef get_shape() -> dk.DivShape:\n    return dk.DivShape(\n        item_width=get_size(),\n        item_height=get_size(),\n        corner_radius=get_size(100)\n    )\n\n    \nslider_shape = get_shape()\n\nslider = dk.DivData(\n    log_id="sample_card",\n    states=[\n        dk.DivDataState(\n            # other arguments\n            div=dk.DivSlider(\n                thumb_style=dk.DivShapeDrawable(\n                    shape=slider_shape,\n                    # other arguments\n                ),\n                # other arguments\n            )\n        )\n    ]\n)\n```\n\nLooks a little better, but this approach doesn\'t scale well. To simplify layout \nand save traffic, DivKit has templates. This is a way to layout similar elements\nwithout having to declare the complete json, but just declare a template and use\nthis many times in similar items.\n\n**PyDivKit supports defining templates through the inheritance.**\n\nLet\'s define an example card.\n\n```python\nimport json\n\nimport pydivkit as dk\n\n\nclass CategoriesItem(dk.DivContainer):\n    """\n    Class inherited from dk.DivContainer will have a template\n    """\n\n    # Special object for mark this fields a DivKit field in template\n    icon_url: str = dk.Field()\n    text: str = dk.Field()\n\n    # Set defaults layout for in the template\n    width = dk.DivWrapContentSize()\n    background = [dk.DivSolidBackground(color="#f0f0f0")]\n    content_alignment_vertical = dk.DivAlignmentVertical.CENTER\n    orientation = dk.DivContainerOrientation.HORIZONTAL\n    paddings = dk.DivEdgeInsets(left=12, right=12, top=10, bottom=10)\n    border = dk.DivBorder(corner_radius=12)\n    items = [\n        dk.DivImage(\n            width=dk.DivFixedSize(value=20),\n            height=dk.DivFixedSize(value=20),\n            margins=dk.DivEdgeInsets(right=6),\n\n            # Special object Ref it\'s a reference for Field property\n            image_url=dk.Ref(icon_url),\n        ),\n        dk.DivText(\n            width=dk.DivWrapContentSize(),\n            max_lines=1,\n\n            # Special object Ref it\'s a reference for Field property\n            text=dk.Ref(text),\n        ),\n    ]\n\n\nBASE_URL = "https://leonardo.edadeal.io/dyn/re/segments/level1/96"\n\n\n# So after class definition you might use all the `Field` marked property\n# names as an argument.\n\ngallery = dk.DivGallery(\n    items=[\n        CategoriesItem(\n            text="Food", icon_url=f"{BASE_URL}/food.png",\n        ),\n        CategoriesItem(\n            text="Alcohol", icon_url=f"{BASE_URL}/alcohol.png",\n        ),\n        CategoriesItem(\n            text="Household", icon_url=f"{BASE_URL}/household.png",\n        ),\n    ]\n)\n\nprint(json.dumps(dk.make_div(gallery), indent=1, ensure_ascii=False))\n# {\n#  "templates": {\n#   "__main__.CategoriesItem": {\n#    "type": "container",\n#    "background": [\n#     {\n#      "type": "solid",\n#      "color": "#f0f0f0"\n#     }\n#    ],\n#    "border": {\n#     "corner_radius": 12\n#    },\n#    "content_alignment_vertical": "center",\n#    "items": [\n#     {\n#      "type": "image",\n#      "height": {\n#       "type": "fixed",\n#       "value": 20\n#      },\n#      "$image_url": "icon_url",\n#      "margins": {\n#       "right": 6\n#      },\n#      "width": {\n#       "type": "fixed",\n#       "value": 20\n#      }\n#     },\n#     {\n#      "type": "text",\n#      "max_lines": 1,\n#      "$text": "text",\n#      "width": {\n#       "type": "wrap_content"\n#      }\n#     }\n#    ],\n#    "orientation": "horizontal",\n#    "paddings": {\n#     "bottom": 10,\n#     "left": 12,\n#     "right": 12,\n#     "top": 10\n#    },\n#    "width": {\n#     "type": "wrap_content"\n#    }\n#   }\n#  },\n#  "card": {\n#   "log_id": "card",\n#   "states": [\n#    {\n#     "div": {\n#      "type": "gallery",\n#      "items": [\n#       {\n#        "type": "__main__.CategoriesItem",\n#        "icon_url": "https://leonardo.edadeal.io/dyn/re/segments/level1/96/food.png",\n#        "text": "Food"\n#       },\n#       {\n#        "type": "__main__.CategoriesItem",\n#        "icon_url": "https://leonardo.edadeal.io/dyn/re/segments/level1/96/alcohol.png",\n#        "text": "Alcohol"\n#       },\n#       {\n#        "type": "__main__.CategoriesItem",\n#        "icon_url": "https://leonardo.edadeal.io/dyn/re/segments/level1/96/household.png",\n#        "text": "Household"\n#       }\n#      ]\n#     },\n#     "state_id": 0\n#    }\n#   ]\n#  }\n# }\n```\n\nTemplate names\n--------------\n\nBy default, templates are collecting by the metaclass into shared storage when \nthe class is declaring at import time, and have the \nformat `{module_name}.{class_name}`.\n\nThe following example, which I am sure will not occur in the wild, shows a \nwarning if suddenly the names of the classes, and hence the templates, conflict.\n\n```python\nimport pydivkit as dk\n\n\nclass MyTemplate(dk.DivContainer):\n    width = dk.DivWrapContentSize()\n\n\nclass MyTemplate(dk.DivContainer):\n    pass\n\n# RuntimeWarning: Template \'test.MyTemplate\' already defined in \n# <class \'test.MyTemplate\'> and will be replaced to <class \'test.MyTemplate\'>\n```\n\nAlso, if you do not want to show the structure of your project to the outside, \nor for some reason you need to make the example above clean, you can rename the\ntemplate by declaring a special attribute `__template_name__`\n\n```python\nimport pydivkit as dk\n\n\nclass MyTemplate(dk.DivContainer):\n    width = dk.DivWrapContentSize()\n\nprint(MyTemplate.template_name)\n# >>> test.MyTemplate\n\nclass MyTemplate(dk.DivContainer):\n    __template_name__ = "MyTemplate2"\n\nprint(MyTemplate.template_name)\n# >>> MyTemplate2\n```\n',
    'author': 'Vladislav Bakaev',
    'author_email': 'bakaev-vlad@yandex-team.ru',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/divkit/divkit/tree/main/json-builder/python',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
