nicegui-bootstrap-components 0.1.0__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.
Files changed (103) hide show
  1. nicegui_bootstrap_components/__init__.py +7 -0
  2. nicegui_bootstrap_components/_base.py +590 -0
  3. nicegui_bootstrap_components/_host.py +259 -0
  4. nicegui_bootstrap_components/assets.py +371 -0
  5. nicegui_bootstrap_components/bs/__init__.py +267 -0
  6. nicegui_bootstrap_components/bs/_actions.py +232 -0
  7. nicegui_bootstrap_components/bs/_alert_spinner.py +423 -0
  8. nicegui_bootstrap_components/bs/_carousel.py +312 -0
  9. nicegui_bootstrap_components/bs/_choices.py +779 -0
  10. nicegui_bootstrap_components/bs/_content.py +1343 -0
  11. nicegui_bootstrap_components/bs/_forms.py +378 -0
  12. nicegui_bootstrap_components/bs/_inputs.py +560 -0
  13. nicegui_bootstrap_components/bs/_layout.py +341 -0
  14. nicegui_bootstrap_components/bs/_nav.py +650 -0
  15. nicegui_bootstrap_components/bs/_navbar.py +445 -0
  16. nicegui_bootstrap_components/bs/_overlay_root.py +73 -0
  17. nicegui_bootstrap_components/bs/_overlays.py +2633 -0
  18. nicegui_bootstrap_components/bs/_scope.py +28 -0
  19. nicegui_bootstrap_components/bs/_tabs.py +605 -0
  20. nicegui_bootstrap_components/bs/_toast.py +137 -0
  21. nicegui_bootstrap_components/bs/_tooltip_popover.py +537 -0
  22. nicegui_bootstrap_components/contracts/dbc-2.0.4.json +16811 -0
  23. nicegui_bootstrap_components/dbc/__init__.py +108 -0
  24. nicegui_bootstrap_components/icons.py +29 -0
  25. nicegui_bootstrap_components/persist.py +201 -0
  26. nicegui_bootstrap_components/py.typed +0 -0
  27. nicegui_bootstrap_components/static/dist/fonts/bootstrap-icons.woff +0 -0
  28. nicegui_bootstrap_components/static/dist/fonts/bootstrap-icons.woff2 +0 -0
  29. nicegui_bootstrap_components/static/dist/ngbs-bootstrap-unscoped.css +12047 -0
  30. nicegui_bootstrap_components/static/dist/ngbs-bootstrap.css +12057 -0
  31. nicegui_bootstrap_components/static/dist/ngbs-cerulean-unscoped.css +12338 -0
  32. nicegui_bootstrap_components/static/dist/ngbs-cerulean.css +12348 -0
  33. nicegui_bootstrap_components/static/dist/ngbs-compat-unscoped.css +12 -0
  34. nicegui_bootstrap_components/static/dist/ngbs-compat.css +12 -0
  35. nicegui_bootstrap_components/static/dist/ngbs-cosmo-unscoped.css +11825 -0
  36. nicegui_bootstrap_components/static/dist/ngbs-cosmo.css +11835 -0
  37. nicegui_bootstrap_components/static/dist/ngbs-cyborg-unscoped.css +12213 -0
  38. nicegui_bootstrap_components/static/dist/ngbs-cyborg.css +12223 -0
  39. nicegui_bootstrap_components/static/dist/ngbs-darkly-unscoped.css +12143 -0
  40. nicegui_bootstrap_components/static/dist/ngbs-darkly.css +12153 -0
  41. nicegui_bootstrap_components/static/dist/ngbs-flatly-unscoped.css +12129 -0
  42. nicegui_bootstrap_components/static/dist/ngbs-flatly.css +12139 -0
  43. nicegui_bootstrap_components/static/dist/ngbs-grid-unscoped.css +4084 -0
  44. nicegui_bootstrap_components/static/dist/ngbs-grid.css +4094 -0
  45. nicegui_bootstrap_components/static/dist/ngbs-host-unscoped.css +9 -0
  46. nicegui_bootstrap_components/static/dist/ngbs-host.css +9 -0
  47. nicegui_bootstrap_components/static/dist/ngbs-icons-bootstrap.css +5 -0
  48. nicegui_bootstrap_components/static/dist/ngbs-icons-fontawesome.css +9 -0
  49. nicegui_bootstrap_components/static/dist/ngbs-journal-unscoped.css +12112 -0
  50. nicegui_bootstrap_components/static/dist/ngbs-journal.css +12122 -0
  51. nicegui_bootstrap_components/static/dist/ngbs-litera-unscoped.css +12214 -0
  52. nicegui_bootstrap_components/static/dist/ngbs-litera.css +12224 -0
  53. nicegui_bootstrap_components/static/dist/ngbs-lumen-unscoped.css +12377 -0
  54. nicegui_bootstrap_components/static/dist/ngbs-lumen.css +12387 -0
  55. nicegui_bootstrap_components/static/dist/ngbs-lux-unscoped.css +12048 -0
  56. nicegui_bootstrap_components/static/dist/ngbs-lux.css +12058 -0
  57. nicegui_bootstrap_components/static/dist/ngbs-materia-unscoped.css +13197 -0
  58. nicegui_bootstrap_components/static/dist/ngbs-materia.css +13207 -0
  59. nicegui_bootstrap_components/static/dist/ngbs-minty-unscoped.css +12184 -0
  60. nicegui_bootstrap_components/static/dist/ngbs-minty.css +12194 -0
  61. nicegui_bootstrap_components/static/dist/ngbs-morph-unscoped.css +12829 -0
  62. nicegui_bootstrap_components/static/dist/ngbs-morph.css +12839 -0
  63. nicegui_bootstrap_components/static/dist/ngbs-pulse-unscoped.css +11901 -0
  64. nicegui_bootstrap_components/static/dist/ngbs-pulse.css +11911 -0
  65. nicegui_bootstrap_components/static/dist/ngbs-quartz-unscoped.css +12625 -0
  66. nicegui_bootstrap_components/static/dist/ngbs-quartz.css +12635 -0
  67. nicegui_bootstrap_components/static/dist/ngbs-sandstone-unscoped.css +12214 -0
  68. nicegui_bootstrap_components/static/dist/ngbs-sandstone.css +12224 -0
  69. nicegui_bootstrap_components/static/dist/ngbs-simplex-unscoped.css +12199 -0
  70. nicegui_bootstrap_components/static/dist/ngbs-simplex.css +12209 -0
  71. nicegui_bootstrap_components/static/dist/ngbs-sketchy-unscoped.css +12518 -0
  72. nicegui_bootstrap_components/static/dist/ngbs-sketchy.css +12528 -0
  73. nicegui_bootstrap_components/static/dist/ngbs-slate-unscoped.css +12527 -0
  74. nicegui_bootstrap_components/static/dist/ngbs-slate.css +12537 -0
  75. nicegui_bootstrap_components/static/dist/ngbs-solar-unscoped.css +12152 -0
  76. nicegui_bootstrap_components/static/dist/ngbs-solar.css +12162 -0
  77. nicegui_bootstrap_components/static/dist/ngbs-spacelab-unscoped.css +12279 -0
  78. nicegui_bootstrap_components/static/dist/ngbs-spacelab.css +12289 -0
  79. nicegui_bootstrap_components/static/dist/ngbs-superhero-unscoped.css +12223 -0
  80. nicegui_bootstrap_components/static/dist/ngbs-superhero.css +12233 -0
  81. nicegui_bootstrap_components/static/dist/ngbs-united-unscoped.css +12090 -0
  82. nicegui_bootstrap_components/static/dist/ngbs-united.css +12100 -0
  83. nicegui_bootstrap_components/static/dist/ngbs-vapor-unscoped.css +12556 -0
  84. nicegui_bootstrap_components/static/dist/ngbs-vapor.css +12566 -0
  85. nicegui_bootstrap_components/static/dist/ngbs-yeti-unscoped.css +12333 -0
  86. nicegui_bootstrap_components/static/dist/ngbs-yeti.css +12343 -0
  87. nicegui_bootstrap_components/static/dist/ngbs-zephyr-unscoped.css +12296 -0
  88. nicegui_bootstrap_components/static/dist/ngbs-zephyr.css +12306 -0
  89. nicegui_bootstrap_components/static/prototype-ngbs.css +541 -0
  90. nicegui_bootstrap_components/static/webfonts/fa-brands-400.ttf +0 -0
  91. nicegui_bootstrap_components/static/webfonts/fa-brands-400.woff2 +0 -0
  92. nicegui_bootstrap_components/static/webfonts/fa-regular-400.ttf +0 -0
  93. nicegui_bootstrap_components/static/webfonts/fa-regular-400.woff2 +0 -0
  94. nicegui_bootstrap_components/static/webfonts/fa-solid-900.ttf +0 -0
  95. nicegui_bootstrap_components/static/webfonts/fa-solid-900.woff2 +0 -0
  96. nicegui_bootstrap_components/static/webfonts/fa-v4compatibility.ttf +0 -0
  97. nicegui_bootstrap_components/static/webfonts/fa-v4compatibility.woff2 +0 -0
  98. nicegui_bootstrap_components/theme.py +238 -0
  99. nicegui_bootstrap_components/themes.py +131 -0
  100. nicegui_bootstrap_components-0.1.0.dist-info/METADATA +234 -0
  101. nicegui_bootstrap_components-0.1.0.dist-info/RECORD +103 -0
  102. nicegui_bootstrap_components-0.1.0.dist-info/WHEEL +4 -0
  103. nicegui_bootstrap_components-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,341 @@
1
+ """Layout family: Container, Row, Col, Stack (native + compat sibling types)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from .._base import BootstrapElement, UnsupportedPropError, make_surface_classes
8
+
9
+ __all__ = [
10
+ "Col",
11
+ "Container",
12
+ "DbcCol",
13
+ "DbcContainer",
14
+ "DbcRow",
15
+ "DbcStack",
16
+ "Row",
17
+ "Stack",
18
+ "col",
19
+ "col_breakpoint_classes",
20
+ "container",
21
+ "container_class",
22
+ "row",
23
+ "row_classes",
24
+ "stack",
25
+ "stack_classes",
26
+ ]
27
+
28
+ _FLUID_BPS = frozenset({"sm", "md", "lg", "xl", "xxl"})
29
+ _ALIGN = frozenset({"start", "center", "end", "stretch", "baseline"})
30
+ _JUSTIFY = frozenset({"start", "center", "end", "around", "between", "evenly"})
31
+ _STACK_DIRECTIONS = frozenset({"vertical", "horizontal"})
32
+ _WIDTH_FRACTIONS = {
33
+ "1/12": 1,
34
+ "1/6": 2,
35
+ "1/4": 3,
36
+ "1/3": 4,
37
+ "5/12": 5,
38
+ "1/2": 6,
39
+ "7/12": 7,
40
+ "2/3": 8,
41
+ "3/4": 9,
42
+ "5/6": 10,
43
+ "11/12": 11,
44
+ "1/1": 12,
45
+ "12/12": 12,
46
+ }
47
+
48
+
49
+ def container_class(fluid: bool | str, *, surface: str) -> str:
50
+ """Map ``fluid`` to a Bootstrap container class."""
51
+ if fluid is False:
52
+ return "container"
53
+ if fluid is True:
54
+ return "container-fluid"
55
+ if isinstance(fluid, str):
56
+ if surface == "compat":
57
+ raise UnsupportedPropError("fluid")
58
+ if fluid not in _FLUID_BPS:
59
+ raise ValueError(f"Invalid container fluid breakpoint: {fluid!r}")
60
+ return f"container-{fluid}"
61
+ raise TypeError(f"fluid must be bool or breakpoint str, got {type(fluid)!r}")
62
+
63
+
64
+ def row_classes(
65
+ *,
66
+ align: str | None = None,
67
+ justify: str | None = None,
68
+ g: int | None = None,
69
+ gx: int | None = None,
70
+ gy: int | None = None,
71
+ ) -> list[str]:
72
+ """Return Bootstrap classes for a Row."""
73
+ classes = ["row"]
74
+ if align is not None:
75
+ if align not in _ALIGN:
76
+ raise ValueError(f"Invalid row align: {align!r}")
77
+ classes.append(f"align-items-{align}")
78
+ if justify is not None:
79
+ if justify not in _JUSTIFY:
80
+ raise ValueError(f"Invalid row justify: {justify!r}")
81
+ classes.append(f"justify-content-{justify}")
82
+ for name, val in (("g", g), ("gx", gx), ("gy", gy)):
83
+ if val is None:
84
+ continue
85
+ if isinstance(val, bool) or not isinstance(val, int) or val < 0 or val > 5:
86
+ raise ValueError(f"{name} must be an int 0-5, got {val!r}")
87
+ classes.append(f"{name}-{val}")
88
+ return classes
89
+
90
+
91
+ def _copied(value: object) -> object:
92
+ if isinstance(value, dict):
93
+ return dict(value)
94
+ return value
95
+
96
+
97
+ def _span_class(n: int, bp: str | None) -> str:
98
+ if bp is None or bp == "xs":
99
+ return f"col-{n}"
100
+ return f"col-{bp}-{n}"
101
+
102
+
103
+ def _check_span(n: int) -> None:
104
+ if n < 1 or n > 12:
105
+ raise ValueError(f"Column size must be 1-12, got {n}")
106
+
107
+
108
+ def _order_classes(order: object, *, bp: str | None) -> list[str]:
109
+ if isinstance(order, str):
110
+ if order not in ("first", "last"):
111
+ raise ValueError(f"order must be 0-12, 'first', or 'last', got {order!r}")
112
+ if bp is None or bp == "xs":
113
+ return [f"order-{order}"]
114
+ return [f"order-{bp}-{order}"]
115
+ if isinstance(order, float):
116
+ raise TypeError("order must not be a float")
117
+ if isinstance(order, bool) or not isinstance(order, int):
118
+ raise TypeError(f"order must be an int, got {type(order)!r}")
119
+ if order < 0 or order > 12:
120
+ raise ValueError(f"order must be 0-12, got {order}")
121
+ if bp is None or bp == "xs":
122
+ return [f"order-{order}"]
123
+ return [f"order-{bp}-{order}"]
124
+
125
+
126
+ def _offset_classes(offset: object, *, bp: str | None) -> list[str]:
127
+ if isinstance(offset, float):
128
+ raise TypeError("offset must not be a float")
129
+ if isinstance(offset, bool) or not isinstance(offset, int):
130
+ raise TypeError(f"offset must be an int, got {type(offset)!r}")
131
+ if offset < 0 or offset > 12:
132
+ raise ValueError(f"offset must be 0-12, got {offset}")
133
+ if bp is None or bp == "xs":
134
+ return [f"offset-{offset}"]
135
+ return [f"offset-{bp}-{offset}"]
136
+
137
+
138
+ def _col_value_to_classes(value: object, *, bp: str | None) -> list[str]:
139
+ if value is None or value is False:
140
+ return []
141
+ if value is True:
142
+ return ["col" if bp in (None, "xs") else f"col-{bp}"]
143
+ if isinstance(value, bool):
144
+ return []
145
+ if isinstance(value, float):
146
+ raise TypeError(
147
+ "Col width/breakpoint values must not be floats; use ints 1-12 or fraction strings"
148
+ )
149
+ if isinstance(value, int):
150
+ _check_span(value)
151
+ return [_span_class(value, bp)]
152
+ if isinstance(value, str):
153
+ if value == "auto":
154
+ return ["col-auto" if bp in (None, "xs") else f"col-{bp}-auto"]
155
+ if value in _WIDTH_FRACTIONS:
156
+ return [_span_class(_WIDTH_FRACTIONS[value], bp)]
157
+ if value.isdigit():
158
+ return _col_value_to_classes(int(value), bp=bp)
159
+ raise ValueError(f"Invalid column size: {value!r}")
160
+ if isinstance(value, dict):
161
+ data = dict(value)
162
+ out: list[str] = []
163
+ if "size" in data:
164
+ out.extend(_col_value_to_classes(data["size"], bp=bp))
165
+ if "order" in data:
166
+ out.extend(_order_classes(data["order"], bp=bp))
167
+ if "offset" in data:
168
+ out.extend(_offset_classes(data["offset"], bp=bp))
169
+ return out
170
+ raise TypeError(f"Unsupported column value type: {type(value)!r}")
171
+
172
+
173
+ def col_breakpoint_classes(
174
+ *,
175
+ width: object = None,
176
+ xs: object = None,
177
+ sm: object = None,
178
+ md: object = None,
179
+ lg: object = None,
180
+ xl: object = None,
181
+ xxl: object = None,
182
+ align: str | None = None,
183
+ order: object = None,
184
+ offset: object = None,
185
+ ) -> list[str]:
186
+ """Compute Col classes. Caller dicts are copied, not mutated. ``xs`` overrides ``width``."""
187
+ width_v = _copied(width)
188
+ xs_v = _copied(xs)
189
+ sm_v = _copied(sm)
190
+ md_v = _copied(md)
191
+ lg_v = _copied(lg)
192
+ xl_v = _copied(xl)
193
+ xxl_v = _copied(xxl)
194
+ base = xs_v if xs_v is not None else width_v
195
+ classes: list[str] = []
196
+ classes.extend(_col_value_to_classes(base, bp=None))
197
+ if order is not None and not isinstance(base, dict):
198
+ classes.extend(_order_classes(order, bp=None))
199
+ if offset is not None and not isinstance(base, dict):
200
+ classes.extend(_offset_classes(offset, bp=None))
201
+ for bp, val in (("sm", sm_v), ("md", md_v), ("lg", lg_v), ("xl", xl_v), ("xxl", xxl_v)):
202
+ if val is None:
203
+ continue
204
+ classes.extend(_col_value_to_classes(val, bp=bp))
205
+ if align is not None:
206
+ if align not in _ALIGN:
207
+ raise ValueError(f"Invalid col align: {align!r}")
208
+ classes.append(f"align-self-{align}")
209
+ if not classes:
210
+ classes.append("col")
211
+ return classes
212
+
213
+
214
+ def stack_classes(*, direction: str = "vertical", gap: int | None = None) -> list[str]:
215
+ """Return Bootstrap ``vstack``/``hstack`` classes."""
216
+ if direction not in _STACK_DIRECTIONS:
217
+ raise ValueError(f"Invalid stack direction: {direction!r}")
218
+ classes = ["vstack" if direction == "vertical" else "hstack"]
219
+ if gap is not None:
220
+ if isinstance(gap, bool) or not isinstance(gap, int) or gap < 0 or gap > 5:
221
+ raise ValueError(f"gap must be an int 0-5, got {gap!r}")
222
+ classes.append(f"gap-{gap}")
223
+ return classes
224
+
225
+
226
+ class _ContainerImpl(BootstrapElement):
227
+ """Private Container implementation."""
228
+
229
+ component_name = "Container"
230
+ children_kind = "auto"
231
+
232
+ def __init__(
233
+ self,
234
+ children: object = None,
235
+ *,
236
+ _surface: str,
237
+ fluid: bool | str = False,
238
+ tag: str = "div",
239
+ **kwargs: Any,
240
+ ) -> None:
241
+ self._surface = _surface
242
+ self._structural_classes = (container_class(fluid, surface=_surface),)
243
+ super().__init__(children, tag=tag, **kwargs)
244
+
245
+
246
+ class _RowImpl(BootstrapElement):
247
+ """Private Row implementation."""
248
+
249
+ component_name = "Row"
250
+ children_kind = "grouping"
251
+
252
+ def __init__(
253
+ self,
254
+ children: object = None,
255
+ *,
256
+ _surface: str,
257
+ align: str | None = None,
258
+ justify: str | None = None,
259
+ g: int | None = None,
260
+ gx: int | None = None,
261
+ gy: int | None = None,
262
+ tag: str = "div",
263
+ **kwargs: Any,
264
+ ) -> None:
265
+ self._surface = _surface
266
+ self._structural_classes = tuple(
267
+ row_classes(align=align, justify=justify, g=g, gx=gx, gy=gy)
268
+ )
269
+ super().__init__(children, tag=tag, **kwargs)
270
+
271
+
272
+ class _ColImpl(BootstrapElement):
273
+ """Private Col implementation."""
274
+
275
+ component_name = "Col"
276
+ children_kind = "auto"
277
+
278
+ def __init__(
279
+ self,
280
+ children: object = None,
281
+ *,
282
+ _surface: str,
283
+ width: object = None,
284
+ xs: object = None,
285
+ sm: object = None,
286
+ md: object = None,
287
+ lg: object = None,
288
+ xl: object = None,
289
+ xxl: object = None,
290
+ align: str | None = None,
291
+ order: object = None,
292
+ offset: object = None,
293
+ tag: str = "div",
294
+ **kwargs: Any,
295
+ ) -> None:
296
+ self._surface = _surface
297
+ self._structural_classes = tuple(
298
+ col_breakpoint_classes(
299
+ width=width,
300
+ xs=xs,
301
+ sm=sm,
302
+ md=md,
303
+ lg=lg,
304
+ xl=xl,
305
+ xxl=xxl,
306
+ align=align,
307
+ order=order,
308
+ offset=offset,
309
+ )
310
+ )
311
+ super().__init__(children, tag=tag, **kwargs)
312
+
313
+
314
+ class _StackImpl(BootstrapElement):
315
+ """Private Stack implementation."""
316
+
317
+ component_name = "Stack"
318
+ children_kind = "auto"
319
+
320
+ def __init__(
321
+ self,
322
+ children: object = None,
323
+ *,
324
+ _surface: str,
325
+ direction: str = "vertical",
326
+ gap: int | None = None,
327
+ **kwargs: Any,
328
+ ) -> None:
329
+ self._surface = _surface
330
+ self._structural_classes = tuple(stack_classes(direction=direction, gap=gap))
331
+ super().__init__(children, **kwargs)
332
+
333
+
334
+ Container, DbcContainer = make_surface_classes("Container", globals())
335
+ container = Container
336
+ Row, DbcRow = make_surface_classes("Row", globals())
337
+ row = Row
338
+ Col, DbcCol = make_surface_classes("Col", globals())
339
+ col = Col
340
+ Stack, DbcStack = make_surface_classes("Stack", globals())
341
+ stack = Stack