pydzn 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pydzn/base_component.py CHANGED
@@ -6,7 +6,6 @@ import json
6
6
  import inspect
7
7
  from pathlib import Path
8
8
  from jinja2 import Environment, FileSystemLoader, select_autoescape
9
- from .base_agent import BaseAssistant
10
9
  from .dzn import register_dzn_classes
11
10
 
12
11
 
@@ -0,0 +1,8 @@
1
+ from .button.component import Button
2
+ from .text.component import Text
3
+ from .drawer.component import Drawer
4
+ from .sidebar.component import Sidebar
5
+ from .nav_item.component import NavItem
6
+
7
+
8
+ __all__ = ["Button", "Text", "Drawer", "Sidebar", "NavItem"]
@@ -0,0 +1,15 @@
1
+ from pydzn.base_component import BaseComponent
2
+
3
+
4
+ class Card(BaseComponent):
5
+ """
6
+ Renders a card element.
7
+ Expects `template.html`
8
+ """
9
+
10
+ def __init__(self, children: str | None = None, tag: str = "div", **html_attrs):
11
+ super().__init__(children=children, tag=tag, **html_attrs)
12
+
13
+
14
+ def context(self) -> dict:
15
+ return {}
@@ -0,0 +1,3 @@
1
+ <{{ tag }}{% if attrs %} {{ attrs|safe }}{% endif %}>
2
+ {{ children|safe }}
3
+ </{{ tag }}>
@@ -0,0 +1,14 @@
1
+ from pydzn.base_component import BaseComponent
2
+
3
+
4
+ class Drawer(BaseComponent):
5
+ """
6
+ Renders a drawer element.
7
+ Expects `template.html`
8
+ """
9
+
10
+ def __init__(self, children: str | None = None, tag: str = "div", **html_attrs):
11
+ super().__init__(children=children, tag=tag, **html_attrs)
12
+
13
+ def context(self) -> dict:
14
+ return {}
@@ -0,0 +1,3 @@
1
+ <{{ tag }}{% if attrs %} {{ attrs|safe }}{% endif %}>
2
+ {{ children|safe }}
3
+ </{{ tag }}>
@@ -0,0 +1,56 @@
1
+ from pydzn.base_component import BaseComponent
2
+ from pydzn.dzn import register_dzn_classes
3
+
4
+
5
+ class NavItem(BaseComponent):
6
+ """
7
+ Minimal sidebar/nav item.
8
+ - No default styling; pass dzn yourself.
9
+ - Put label/content in `children` (e.g., render a Text component).
10
+ - Optional: `active=True` to start active; `group_toggle=True` to clear
11
+ siblings and apply `active_classes` on click (client-only).
12
+ """
13
+
14
+ def __init__(
15
+ self,
16
+ *,
17
+ children: str | None = None,
18
+ tag: str = "div",
19
+ dzn: str | None = None,
20
+ active: bool = False,
21
+ active_classes: list[str] | tuple[str, ...] | None = None,
22
+ group_toggle: bool = False,
23
+ **attrs,
24
+ ):
25
+ # No default design; just pass through what caller wants.
26
+ self._active_classes = list(active_classes or [])
27
+
28
+ # If we'll toggle classes at runtime, pre-register them so /_dzn.css emits rules.
29
+ if self._active_classes:
30
+ register_dzn_classes(self._active_classes)
31
+
32
+ # Start active = append active classes up front
33
+ effective_dzn = (dzn or "")
34
+ if active and self._active_classes:
35
+ effective_dzn = (effective_dzn + " " + " ".join(self._active_classes)).strip()
36
+
37
+ # Sensible a11y defaults (still “unstyled”)
38
+ attrs.setdefault("role", "button")
39
+ attrs.setdefault("tabindex", "0")
40
+
41
+ # Optional sibling-clearing active toggle, only if requested and not overridden
42
+ if group_toggle and "hx-on:click" not in attrs and self._active_classes:
43
+ # Build JS that removes active classes from siblings, adds to this.
44
+ rm = ",".join(f"'{c}'" for c in self._active_classes)
45
+ add = rm
46
+ attrs["hx-on:click"] = (
47
+ "var p=this.parentElement;"
48
+ f"for(const el of p.children){{el.classList.remove({rm});}}"
49
+ f"this.classList.add({add});"
50
+ )
51
+
52
+ super().__init__(children=children or "", tag=tag, dzn=effective_dzn, **attrs)
53
+
54
+ def context(self) -> dict:
55
+ # No label here; use children (e.g., a Text component) for content.
56
+ return {}
@@ -0,0 +1,3 @@
1
+ <{{ tag }} {{ attrs|safe }}>
2
+ {{ children|safe }}
3
+ </{{ tag }}>
@@ -0,0 +1,15 @@
1
+ from pydzn.base_component import BaseComponent
2
+
3
+
4
+ class Sidebar(BaseComponent):
5
+ """
6
+ Minimal sidebar container.
7
+ Spans parent height; default subtle panel bg.
8
+ The layout decides which side shows the divider.
9
+ """
10
+
11
+ def __init__(self, *, children: str | None = None, tag: str = "div", dzn: str | None = None, **attrs):
12
+ super().__init__(children=children or "", tag=tag, dzn=dzn, **attrs)
13
+
14
+ def context(self) -> dict:
15
+ return {}
@@ -0,0 +1,3 @@
1
+ <{{ tag }} {{ attrs|safe }}>
2
+ {{ children|safe }}
3
+ </{{ tag }}>
@@ -0,0 +1,15 @@
1
+ from pydzn.base_component import BaseComponent
2
+
3
+
4
+ class Text(BaseComponent):
5
+ """
6
+ Renders a text element.
7
+ Expects `template.html`
8
+ """
9
+
10
+ def __init__(self, text: str = "", children: str | None = None, tag: str = "div", **html_attrs):
11
+ super().__init__(children=children, tag=tag, **html_attrs)
12
+ self.text = text
13
+
14
+ def context(self) -> dict:
15
+ return {"text": self.text}
@@ -0,0 +1,3 @@
1
+ <{{ tag }}{% if attrs %} {{ attrs|safe }}{% endif %}>
2
+ {{ text }}{{ children|safe }}
3
+ </{{ tag }}>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydzn
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Tiny design-system utilities (Tailwind-like), composable HTML components, and a grid layout builder for Python/Jinja apps.
5
5
  Author-email: Ryan Kirkish <ryan@foo.com>
6
6
  License: Apache-2.0
@@ -0,0 +1,23 @@
1
+ pydzn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pydzn/base_component.py,sha256=YkfAF2AN87YioV0qK-XhJlGpUj0qfA201V0W0ituIOE,5304
3
+ pydzn/dzn.py,sha256=mdbDtI30smAjfjcnGrI2tyRVJlKZhrF0MbaPDqF1pqw,11776
4
+ pydzn/grid_builder.py,sha256=Qtxx8Si_vIqV7dwOgAs6jPUIJm0F_IvZtD2BrRWKnb8,9771
5
+ pydzn/components/__init__.py,sha256=VkSrv57Q7JaRJfc09dJwjn7gkYhEQ7Qb7ViSBepz5EU,249
6
+ pydzn/components/button/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ pydzn/components/button/component.py,sha256=KF9dDoIXZ4cQ_z_g2nDrzSjr0BEJ6skLF5ur0eqgxAw,1028
8
+ pydzn/components/button/template.html,sha256=RD0XPzHG0DlWgwlODNNs6PU4yp0arxEsajmGoB8k2vI,99
9
+ pydzn/components/card/component.py,sha256=9FV2k47mi6pqAbqo4C95QUmCaVAwRgqFPAlK_VzoCas,352
10
+ pydzn/components/card/template.html,sha256=xIHvf33q7nVPeNPgSn_wVo5dyNaRiX2quWyBVtk1IDw,89
11
+ pydzn/components/drawer/component.py,sha256=F3BeNaBbrYKa2X9D_FjfBXgwqe2Qo_YR8qMinrPHCag,355
12
+ pydzn/components/drawer/template.html,sha256=xIHvf33q7nVPeNPgSn_wVo5dyNaRiX2quWyBVtk1IDw,89
13
+ pydzn/components/nav_item/component.py,sha256=JTkjJ8i_Zk4-VSZt94Qzu8Cvodt_nfehDbAX5OJtNEs,2164
14
+ pydzn/components/nav_item/template.html,sha256=BpFjn70qDyRbeORBKBK3Uz1oJgVdZD7x7_w9tr9DPMw,64
15
+ pydzn/components/sidebar/component.py,sha256=dK5znbyE6zc90dlbSIwqE-8XKQ8rgHhpZUwpwVKnAoI,464
16
+ pydzn/components/sidebar/template.html,sha256=BpFjn70qDyRbeORBKBK3Uz1oJgVdZD7x7_w9tr9DPMw,64
17
+ pydzn/components/text/component.py,sha256=aAkhQXtUPLbApk6Cib-CVo-vQmsNvJnlHxs5QPv64pc,409
18
+ pydzn/components/text/template.html,sha256=RD0XPzHG0DlWgwlODNNs6PU4yp0arxEsajmGoB8k2vI,99
19
+ pydzn-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ pydzn-0.1.3.dist-info/METADATA,sha256=9dJyM_9-Juau6U8gr9Gtm4rJYNOlvyrLIEB4vREg7w0,1565
21
+ pydzn-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ pydzn-0.1.3.dist-info/top_level.txt,sha256=QPNKgtzCjxN7JSGId_GxBlQaq7X8yNEzCUrYbKAXudA,6
23
+ pydzn-0.1.3.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- pydzn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pydzn/base_component.py,sha256=iXjT12Pgqgbix9Ebm7KzimDpwrkOxSwzEzK12aP0qx4,5342
3
- pydzn/dzn.py,sha256=mdbDtI30smAjfjcnGrI2tyRVJlKZhrF0MbaPDqF1pqw,11776
4
- pydzn/grid_builder.py,sha256=Qtxx8Si_vIqV7dwOgAs6jPUIJm0F_IvZtD2BrRWKnb8,9771
5
- pydzn/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pydzn/components/button/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- pydzn/components/button/component.py,sha256=KF9dDoIXZ4cQ_z_g2nDrzSjr0BEJ6skLF5ur0eqgxAw,1028
8
- pydzn/components/button/template.html,sha256=RD0XPzHG0DlWgwlODNNs6PU4yp0arxEsajmGoB8k2vI,99
9
- pydzn-0.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
- pydzn-0.1.2.dist-info/METADATA,sha256=7Nnt_30H2g9nkza7we-Mcxpb1P7krEKXRQICsfSkFac,1565
11
- pydzn-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- pydzn-0.1.2.dist-info/top_level.txt,sha256=QPNKgtzCjxN7JSGId_GxBlQaq7X8yNEzCUrYbKAXudA,6
13
- pydzn-0.1.2.dist-info/RECORD,,
File without changes