ex4nicegui 0.2.16__py3-none-any.whl → 0.2.18__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.
ex4nicegui/__init__.py CHANGED
@@ -16,4 +16,4 @@ from signe import batch
16
16
  from ex4nicegui.experimental_ import gridLayout as exp_ui
17
17
 
18
18
 
19
- __version__ = "0.2.16"
19
+ __version__ = "0.2.18"
@@ -1 +1 @@
1
- from .index import column, row, item
1
+ from .index import column, row, item, grid_flex
@@ -4,7 +4,39 @@ from nicegui import ui
4
4
  from typing_extensions import Literal
5
5
  from typing import Optional, Union
6
6
 
7
- TBreakpoint = Literal["xs[>0]", "sm[>600]", "md[>1024]", "lg[>1440]", "xl[>1920]"]
7
+ TBreakpoint = Literal[
8
+ "xs[0px]",
9
+ "sm[600px]",
10
+ "md[1024px]",
11
+ "lg[1440px]",
12
+ "xl[1920px]",
13
+ ">xs[0px]",
14
+ "<sm[600px]",
15
+ ">sm[600px]",
16
+ "<md[1024px]",
17
+ ">md[1024px]",
18
+ "<lg[1440px]",
19
+ ">lg[1440px]",
20
+ "<xl[1920px]",
21
+ ">xl[1920px]",
22
+ ]
23
+
24
+ Breakpoint_map = {
25
+ "xs[0px]": "xs",
26
+ "sm[600px]": "sm",
27
+ "md[1024px]": "md",
28
+ "lg[1440px]": "lg",
29
+ "xl[1920px]": "xl",
30
+ ">xs[0px]": "gt-xs",
31
+ "<sm[600px]": "lt-sm",
32
+ ">sm[600px]": "gt-sm",
33
+ "<md[1024px]": "lt-md",
34
+ ">md[1024px]": "gt-md",
35
+ "<lg[1440px]": "lt-lg",
36
+ ">lg[1440px]": "gt-lg",
37
+ "<xl[1920px]": "lt-xl",
38
+ ">xl[1920px]": "gt-xl",
39
+ }
8
40
 
9
41
 
10
42
  def _gap_value(value: Union[str, float, int]):
@@ -29,6 +61,79 @@ Vertical_map = {
29
61
  "stretch": "stretch",
30
62
  }
31
63
 
64
+ _TGrid_Type = Literal["row", "column"]
65
+
66
+
67
+ class GridFlex(ui.element):
68
+ def __init__(self) -> None:
69
+ """ """
70
+ super().__init__("div")
71
+ self._classes = ["grid"]
72
+
73
+ @staticmethod
74
+ def set_classes(
75
+ grid_flex: "GridFlex",
76
+ type: _TGrid_Type,
77
+ template: str,
78
+ horizontal: THorizontal = "stretch",
79
+ vertical: TVertical = "stretch",
80
+ gap: Union[str, float, int] = 1,
81
+ width_full=True,
82
+ break_point: Optional[TBreakpoint] = None,
83
+ ):
84
+ _template = template.strip().replace(" ", "_")
85
+ _type = f"{type}s"
86
+ _justify_items = f"justify-items-{Horizontal_map[horizontal]}"
87
+ _align_items = f"items-{Vertical_map[vertical]}"
88
+ _gap = f"gap-[{_gap_value(gap)}]"
89
+ _w_full = "w-full" if width_full else ""
90
+
91
+ class_names = [
92
+ f"grid-{_type}-[{_template}]",
93
+ _justify_items,
94
+ _align_items,
95
+ _gap,
96
+ _w_full,
97
+ ]
98
+
99
+ if break_point is not None:
100
+ class_names = [f"{Breakpoint_map[break_point]}-{n}" for n in class_names]
101
+
102
+ grid_flex.classes(" ".join(class_names))
103
+ return grid_flex
104
+
105
+ def grid_flex(
106
+ self,
107
+ type: _TGrid_Type,
108
+ template: str,
109
+ *,
110
+ horizontal: THorizontal = "stretch",
111
+ vertical: TVertical = "stretch",
112
+ gap: Union[str, float, int] = 1,
113
+ width_full=True,
114
+ break_point: Optional[TBreakpoint] = None,
115
+ ):
116
+ return GridFlex.set_classes(
117
+ self, type, template, horizontal, vertical, gap, width_full, break_point
118
+ )
119
+
120
+
121
+ def grid_flex(
122
+ type: _TGrid_Type,
123
+ template: str,
124
+ *,
125
+ horizontal: THorizontal = "stretch",
126
+ vertical: TVertical = "stretch",
127
+ gap: Union[str, float, int] = 1,
128
+ width_full=True,
129
+ break_point: Optional[TBreakpoint] = None,
130
+ ):
131
+ gf = GridFlex()
132
+
133
+ return GridFlex.set_classes(
134
+ gf, type, template, horizontal, vertical, gap, width_full, break_point
135
+ )
136
+
32
137
 
33
138
  def column(
34
139
  template: str,
@@ -1 +1,2 @@
1
- from .gridbox import grid_box
1
+ from .gridFlex import *
2
+ from .rxFlex import *
@@ -0,0 +1,156 @@
1
+ const M = Vue.getCurrentScope
2
+ const _ = Vue.onScopeDispose
3
+ const k = Vue.toRef
4
+ const q = Vue.readonly
5
+ const j = Vue.customRef
6
+ const d = Vue.ref
7
+ const m = Vue.computed
8
+ const B = Vue.watchEffect
9
+ const L = Vue.getCurrentInstance
10
+ const C = Vue.onMounted
11
+ const N = Vue.defineComponent
12
+ const R = Vue.openBlock
13
+ const G = Vue.createElementBlock
14
+ const W = Vue.normalizeStyle
15
+ const z = Vue.unref
16
+ const D = Vue.renderSlot
17
+ function F(n) {
18
+ return M() ? (_(n), !0) : !1;
19
+ }
20
+ const I = typeof window < "u", Q = () => {
21
+ };
22
+ function P(n, s) {
23
+ var r;
24
+ if (typeof n == "number")
25
+ return n + s;
26
+ const o = ((r = n.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : r[0]) || "", l = n.slice(o.length), t = Number.parseFloat(o) + s;
27
+ return Number.isNaN(t) ? n : t + l;
28
+ }
29
+ function U(...n) {
30
+ if (n.length !== 1)
31
+ return k(...n);
32
+ const s = n[0];
33
+ return typeof s == "function" ? q(j(() => ({ get: s, set: Q }))) : d(s);
34
+ }
35
+ const p = I ? window : void 0;
36
+ function V() {
37
+ const n = d(!1);
38
+ return L() && C(() => {
39
+ n.value = !0;
40
+ }), n;
41
+ }
42
+ function A(n) {
43
+ const s = V();
44
+ return m(() => (s.value, !!n()));
45
+ }
46
+ function c(n, s = {}) {
47
+ const { window: r = p } = s, o = A(() => r && "matchMedia" in r && typeof r.matchMedia == "function");
48
+ let l;
49
+ const t = d(!1), i = () => {
50
+ l && ("removeEventListener" in l ? l.removeEventListener("change", e) : l.removeListener(e));
51
+ }, e = () => {
52
+ o.value && (i(), l = r.matchMedia(U(n).value), t.value = !!(l != null && l.matches), l && ("addEventListener" in l ? l.addEventListener("change", e) : l.addListener(e)));
53
+ };
54
+ return B(e), F(() => i()), t;
55
+ }
56
+ function H(n, s = {}) {
57
+ function r(e, u) {
58
+ let a = n[e];
59
+ return u != null && (a = P(a, u)), typeof a == "number" && (a = `${a}px`), a;
60
+ }
61
+ const { window: o = p } = s;
62
+ function l(e) {
63
+ return o ? o.matchMedia(e).matches : !1;
64
+ }
65
+ const t = (e) => c(`(min-width: ${r(e)})`, s), i = Object.keys(n).reduce((e, u) => (Object.defineProperty(e, u, {
66
+ get: () => t(u),
67
+ enumerable: !0,
68
+ configurable: !0
69
+ }), e), {});
70
+ return Object.assign(i, {
71
+ greater(e) {
72
+ return c(`(min-width: ${r(e, 0.1)})`, s);
73
+ },
74
+ greaterOrEqual: t,
75
+ smaller(e) {
76
+ return c(`(max-width: ${r(e, -0.1)})`, s);
77
+ },
78
+ smallerOrEqual(e) {
79
+ return c(`(max-width: ${r(e)})`, s);
80
+ },
81
+ between(e, u) {
82
+ return c(`(min-width: ${r(e)}) and (max-width: ${r(u, -0.1)})`, s);
83
+ },
84
+ isGreater(e) {
85
+ return l(`(min-width: ${r(e, 0.1)})`);
86
+ },
87
+ isGreaterOrEqual(e) {
88
+ return l(`(min-width: ${r(e)})`);
89
+ },
90
+ isSmaller(e) {
91
+ return l(`(max-width: ${r(e, -0.1)})`);
92
+ },
93
+ isSmallerOrEqual(e) {
94
+ return l(`(max-width: ${r(e)})`);
95
+ },
96
+ isInBetween(e, u) {
97
+ return l(`(min-width: ${r(e)}) and (max-width: ${r(u, -0.1)})`);
98
+ },
99
+ current() {
100
+ const e = Object.keys(n).map((u) => [u, t(u)]);
101
+ return m(() => e.filter(([, u]) => u.value).map(([u]) => u));
102
+ }
103
+ });
104
+ }
105
+ const T = /* @__PURE__ */ N({
106
+ __name: "GridFlex",
107
+ props: {
108
+ normalStyles: null,
109
+ breakpointStyleMap: null
110
+ },
111
+ setup(n) {
112
+ const s = n, r = m(() => new Map(
113
+ Object.entries(s.breakpointStyleMap)
114
+ ));
115
+ function o() {
116
+ const t = H({
117
+ sm: 600,
118
+ md: 1024,
119
+ lg: 1440,
120
+ xl: 1920
121
+ }), i = t.smaller("sm"), e = t.between("sm", "md"), u = t.between("md", "lg"), a = t.between("lg", "xl"), g = t.greaterOrEqual("xl"), h = t.smaller("sm"), w = t.smaller("md"), v = t.smaller("lg"), y = t.smaller("xl"), x = t.greaterOrEqual("sm"), b = t.greaterOrEqual("md"), O = t.greaterOrEqual("lg"), S = t.greaterOrEqual("xl"), E = {
122
+ xs: i,
123
+ sm: e,
124
+ md: u,
125
+ lg: a,
126
+ xl: g,
127
+ "lt-sm": h,
128
+ "lt-md": w,
129
+ "lt-lg": v,
130
+ "lt-xl": y,
131
+ "gt-xs": x,
132
+ "gt-sm": b,
133
+ "gt-md": O,
134
+ "gt-lg": S
135
+ };
136
+ return m(() => {
137
+ if (r.value.size === 0)
138
+ return s.normalStyles;
139
+ for (const [f, $] of Object.entries(E))
140
+ if ($.value && r.value.has(f))
141
+ return r.value.get(f);
142
+ return s.normalStyles;
143
+ });
144
+ }
145
+ const l = o();
146
+ return (t, i) => (R(), G("div", {
147
+ class: "grid",
148
+ style: W(z(l))
149
+ }, [
150
+ D(t.$slots, "default")
151
+ ], 4));
152
+ }
153
+ });
154
+ export {
155
+ T as default
156
+ };
@@ -0,0 +1 @@
1
+ from .gridFlex import grid_flex, grid_box, mark_area, item_position, GridFlex
@@ -0,0 +1,276 @@
1
+ from typing import Any, Callable, Dict, Optional, cast
2
+ from dataclasses import dataclass
3
+ from nicegui.dataclasses import KWONLY_SLOTS
4
+ from nicegui import ui, app
5
+ from nicegui.element import Element
6
+ from signe import createSignal, effect, batch
7
+ from ex4nicegui.utils.signals import ref_from_signal
8
+
9
+ from typing_extensions import Literal
10
+ from typing import Optional, Union
11
+ from . import utils
12
+
13
+
14
+ TBreakpoint = Literal[
15
+ "xs[0px-599.99px]",
16
+ "sm[600px-1023.99px]",
17
+ "md[1024px-1439.99px]",
18
+ "lg[1440px-1919.99px]",
19
+ "xl[1920px-Infinity]",
20
+ ">xs[600px-Infinity]",
21
+ "<sm[0-599.99px]",
22
+ ">sm[1024px-Infinity]",
23
+ "<md[0-1023.99px]",
24
+ ">md[1440px-Infinity]",
25
+ "<lg[0-1439.99px]",
26
+ ">lg[1920px-Infinity]",
27
+ "<xl[0-1919.99px]",
28
+ ]
29
+
30
+ Breakpoint_map = {
31
+ "xs[0px-599.99px]": "xs",
32
+ "sm[600px-1023.99px]": "sm",
33
+ "md[1024px-1439.99px]": "md",
34
+ "lg[1440px-1919.99px]": "lg",
35
+ "xl[1920px-Infinity]": "xl",
36
+ ">xs[600px-Infinity]": "gt-xs",
37
+ "<sm[0-599.99px]": "lt-sm",
38
+ ">sm[1024px-Infinity]": "gt-sm",
39
+ "<md[0-1023.99px]": "lt-md",
40
+ ">md[1440px-Infinity]": "gt-md",
41
+ "<lg[0-1439.99px]": "lt-lg",
42
+ ">lg[1920px-Infinity]": "gt-lg",
43
+ "<xl[0-1919.99px]": "lt-xl",
44
+ }
45
+
46
+
47
+ def _gap_value(value: Optional[Union[str, float, int]]):
48
+ if value is None:
49
+ return value
50
+
51
+ if isinstance(value, (float, int)):
52
+ value = f"{value}rem"
53
+ return value
54
+
55
+
56
+ THorizontal = Literal["left", "center", "right", "stretch"]
57
+ Horizontal_map = {
58
+ "left": "start",
59
+ "center": "center",
60
+ "right": "end",
61
+ "stretch": "stretch",
62
+ }
63
+
64
+ TVertical = Literal["top", "center", "bottom", "stretch"]
65
+ Vertical_map = {
66
+ "top": "start",
67
+ "center": "center",
68
+ "bottom": "end",
69
+ "stretch": "stretch",
70
+ }
71
+
72
+ _TGrid_Type = Literal["row", "column"]
73
+ Grid_Type_map = {
74
+ "row": "columns",
75
+ "column": "rows",
76
+ }
77
+
78
+
79
+ class GridFlex(Element, component="GridFlex.js"):
80
+ def __init__(self) -> None:
81
+ super().__init__()
82
+
83
+ self._props["normalStyles"] = {}
84
+ self._props["breakpointStyleMap"] = {}
85
+
86
+ self.__breakpointStyleMap = {}
87
+
88
+ @staticmethod
89
+ def _cleanStyle(styles: Dict):
90
+ return {k: v for k, v in styles.items() if v is not None}
91
+
92
+ @staticmethod
93
+ def to_styles(
94
+ type: _TGrid_Type,
95
+ template: str,
96
+ horizontal: THorizontal = "stretch",
97
+ vertical: TVertical = "stretch",
98
+ gap: Union[str, float, int] = 1,
99
+ width_full=True,
100
+ ):
101
+ styles = {
102
+ f"grid-template-{Grid_Type_map[type]}": template,
103
+ "justify-items": Horizontal_map[horizontal],
104
+ "align-items": Vertical_map[vertical],
105
+ "gap": _gap_value(gap),
106
+ }
107
+
108
+ if width_full:
109
+ styles.update({"width": "100%"})
110
+
111
+ return styles
112
+
113
+ def grid_flex(
114
+ self,
115
+ type: _TGrid_Type,
116
+ template: str,
117
+ *,
118
+ horizontal: THorizontal = "stretch",
119
+ vertical: TVertical = "stretch",
120
+ gap: Union[str, float, int] = 1,
121
+ width_full=True,
122
+ break_point: Optional[TBreakpoint] = None,
123
+ ):
124
+ styles = GridFlex.to_styles(
125
+ type, template, horizontal, vertical, gap, width_full
126
+ )
127
+
128
+ if break_point is None:
129
+ self._props["normalStyles"] = styles
130
+ else:
131
+ self.__breakpointStyleMap[Breakpoint_map[break_point]] = styles
132
+ self._props["breakpointStyleMap"] = self.__breakpointStyleMap
133
+
134
+ self.update()
135
+ return self
136
+
137
+ def grid_box(
138
+ self,
139
+ area: Optional[str] = None,
140
+ *,
141
+ template_rows: Optional[str] = None,
142
+ template_columns: Optional[str] = None,
143
+ horizontal: THorizontal = "stretch",
144
+ vertical: TVertical = "stretch",
145
+ gap: Optional[Union[str, float, int]] = 1,
146
+ width_full=True,
147
+ break_point: Optional[TBreakpoint] = None,
148
+ **kws,
149
+ ):
150
+ if area is not None and area.strip() != "":
151
+ areas_list = utils.areas_str2array(area)
152
+ area = utils.areas_array2str(areas_list)
153
+ areas_cols_len = max(map(len, areas_list))
154
+ areas_rows_len = len(areas_list)
155
+
156
+ template_columns = template_columns or f"repeat({areas_cols_len}, 1fr)"
157
+ template_rows = template_rows or f"repeat({areas_rows_len}, 1fr)"
158
+
159
+ styles = {
160
+ "grid-template-areas": area,
161
+ "grid-template-rows": template_rows,
162
+ "grid-template-columns": template_columns,
163
+ "justify-items": Horizontal_map[horizontal],
164
+ "align-items": Vertical_map[vertical],
165
+ "gap": _gap_value(gap),
166
+ }
167
+ styles.update(kws)
168
+
169
+ if width_full:
170
+ styles.update({"width": "100%"})
171
+
172
+ styles = GridFlex._cleanStyle(styles)
173
+
174
+ if break_point is None:
175
+ self._props["normalStyles"] = styles
176
+ else:
177
+ self.__breakpointStyleMap[Breakpoint_map[break_point]] = styles
178
+ self._props["breakpointStyleMap"] = self.__breakpointStyleMap
179
+
180
+ self.update()
181
+ return self
182
+
183
+
184
+ def grid_box(
185
+ area: Optional[str] = None,
186
+ *,
187
+ template_rows: Optional[str] = None,
188
+ template_columns: Optional[str] = None,
189
+ horizontal: THorizontal = "stretch",
190
+ vertical: TVertical = "stretch",
191
+ gap: Union[str, float, int] = 1,
192
+ width_full=True,
193
+ break_point: Optional[TBreakpoint] = None,
194
+ **kws,
195
+ ):
196
+ gf = GridFlex()
197
+
198
+ gf.grid_box(
199
+ area,
200
+ template_rows=template_rows,
201
+ template_columns=template_columns,
202
+ horizontal=horizontal,
203
+ vertical=vertical,
204
+ gap=gap,
205
+ width_full=width_full,
206
+ break_point=break_point,
207
+ **kws,
208
+ )
209
+
210
+ return gf
211
+
212
+
213
+ def grid_flex(
214
+ type: _TGrid_Type,
215
+ template: str,
216
+ *,
217
+ horizontal: THorizontal = "stretch",
218
+ vertical: TVertical = "stretch",
219
+ gap: Union[str, float, int] = 1,
220
+ width_full=True,
221
+ break_point: Optional[TBreakpoint] = None,
222
+ ):
223
+ gf = GridFlex()
224
+
225
+ gf.grid_flex(
226
+ type,
227
+ template,
228
+ horizontal=horizontal,
229
+ vertical=vertical,
230
+ gap=gap,
231
+ width_full=width_full,
232
+ break_point=break_point,
233
+ )
234
+
235
+ return gf
236
+
237
+
238
+ class MarkArea:
239
+ def __init__(self, mark: str) -> None:
240
+ self.mark = mark
241
+
242
+ def __radd__(self, other: ui.element):
243
+ other.style(f"grid-area:{self.mark}")
244
+ return other
245
+
246
+
247
+ def mark_area(mark: str):
248
+ return MarkArea(mark)
249
+
250
+
251
+ class ItemPosition:
252
+ def __init__(
253
+ self,
254
+ horizontal: Optional[THorizontal] = None,
255
+ vertical: Optional[TVertical] = None,
256
+ ) -> None:
257
+ self.horizontal = horizontal
258
+ self.vertical = vertical
259
+
260
+ def __radd__(self, other: ui.element):
261
+ res = []
262
+ if self.horizontal is not None:
263
+ res.append(f"justify-self-{Horizontal_map[self.horizontal]}")
264
+
265
+ if self.vertical is not None:
266
+ res.append(f"self-{Vertical_map[self.vertical]}")
267
+
268
+ other.classes(" ".join(res))
269
+
270
+ return other
271
+
272
+
273
+ def item_position(
274
+ *, horizontal: Optional[THorizontal] = None, vertical: Optional[TVertical] = None
275
+ ):
276
+ return ItemPosition(horizontal, vertical)
@@ -0,0 +1,48 @@
1
+ from typing import List
2
+
3
+
4
+ def areas_str2array(areas: str) -> List[List[str]]:
5
+ """
6
+ >>> input='''
7
+ sc1 sc2
8
+ sc3
9
+ table table table table
10
+ '''
11
+ >>> areas_str2array(input)
12
+ >>> [
13
+ ["sc1", "sc2"],
14
+ ["sc3"],
15
+ ["table", "table", "table", "table"]
16
+ ]
17
+ """
18
+ pass
19
+
20
+ lines = (line.strip() for line in areas.splitlines())
21
+ remove_empty_rows = (line for line in lines if len(line) > 0)
22
+ splie_space = (line.split() for line in remove_empty_rows)
23
+ return list(splie_space)
24
+
25
+
26
+ def areas_array2str(areas_array: List[List[str]]):
27
+ """
28
+ >>> input = [
29
+ ["sc1", "sc2"],
30
+ ["sc3"],
31
+ ["table"] * 4
32
+ ]
33
+ >>> areas_array2str(input)
34
+ >>> '"sc1 sc2 . ." "sc3 . . ." "table table table table"'
35
+ """
36
+ max_len = max(map(len, areas_array))
37
+
38
+ fix_empty = (
39
+ [*line, *(["."] * (max_len - len(line)))] if len(line) < max_len else line
40
+ for line in areas_array
41
+ )
42
+
43
+ line2str = (f'"{" ".join(line)}"' for line in fix_empty)
44
+ return " ".join(line2str)
45
+
46
+
47
+ def best_grid_template_columns(min_column_size: str):
48
+ return f"repeat(auto-fit,minmax(min({min_column_size},100%),1fr))"
@@ -0,0 +1 @@
1
+ from .index import rx_column, rx_row
@@ -0,0 +1,121 @@
1
+ from typing import Callable, List, Optional, Union, TypeVar, Generic
2
+ from typing_extensions import Literal
3
+
4
+ from ex4nicegui.layout import grid_box, mark_area
5
+ from nicegui import ui, app
6
+ from .types import *
7
+
8
+ _T_itemWraper_add_var = TypeVar("_T_itemWraper_add_var")
9
+
10
+
11
+ class ItemWraper:
12
+ def __init__(self, fn: Callable[[ui.element], ui.element]):
13
+ self.fn = fn
14
+
15
+ def __radd__(self, other: _T_itemWraper_add_var) -> _T_itemWraper_add_var:
16
+ return self.fn(other) # type: ignore
17
+
18
+
19
+ class rx_flex_box(ui.element):
20
+ def space(self):
21
+ return ui.element("q-space")
22
+
23
+ def gap(self, value: Union[int, float, str]):
24
+ if isinstance(value, (int, float)):
25
+ value = f"{value}rem"
26
+ self._style["gap"] = str(value)
27
+ self.update()
28
+ return self
29
+
30
+ def all_items_grow(self):
31
+ self._props["ex4ng-rx-flex-auto-grow"] = ""
32
+ return self
33
+
34
+
35
+ def _q_space():
36
+ return ui.element("q-space")
37
+
38
+
39
+ class rx_column(ui.column, rx_flex_box):
40
+ def __init__(
41
+ self,
42
+ horizontal: TColumn_Horizontal = "left",
43
+ vertical: TColumn_Vertical = "top",
44
+ ) -> None:
45
+ super().__init__()
46
+ self.tailwind.align_items
47
+ self.horizontal(horizontal)
48
+ self.vertical(vertical)
49
+
50
+ self._props["ex4ng-rx-column"] = ""
51
+
52
+ def item_horizontal(self, value: TColumn_Item_Horizontal):
53
+ def fn(ele: ui.element):
54
+ ele._style["align-self"] = Column_Item_Horizontal_map.get(value, value)
55
+ # ele.update()
56
+ return ele
57
+
58
+ return ItemWraper(fn)
59
+
60
+ def horizontal(self, value: TColumn_Horizontal):
61
+ self._style["align-items"] = Column_Horizontal_map.get(value, value)
62
+ self.update()
63
+ return self
64
+
65
+ def vertical(self, value: TColumn_Vertical):
66
+ self._style["justify-content"] = Column_Vertical_map.get(value, value)
67
+ self.update()
68
+ return self
69
+
70
+ def space(self):
71
+ return _q_space()
72
+
73
+
74
+ class rx_row(ui.row, rx_flex_box):
75
+ def __init__(
76
+ self,
77
+ horizontal: TRow_Horizontal = "left",
78
+ vertical: TRow_Vertical = "top",
79
+ ) -> None:
80
+ super().__init__()
81
+ self.horizontal(horizontal)
82
+ self.vertical(vertical)
83
+ self._props["ex4ng-rx-row"] = ""
84
+
85
+ def item_vertical(self, value: TRow_Item_Vertical):
86
+ def fn(ele: ui.element):
87
+ ele._style["align-self"] = Row_Vertical_map.get(value, value)
88
+ return ele
89
+
90
+ return ItemWraper(fn)
91
+
92
+ def horizontal(self, value: TRow_Horizontal):
93
+ self._style["justify-content"] = Row_Horizontal_map.get(value, value)
94
+ self.update()
95
+ return self
96
+
97
+ def vertical(self, value: TRow_Vertical):
98
+ self._style["align-items"] = Row_Vertical_map.get(value, value)
99
+ self.update()
100
+ return
101
+
102
+ def space(self):
103
+ return _q_space()
104
+
105
+
106
+ class page_view(rx_column):
107
+ def __init__(
108
+ self,
109
+ horizontal: TColumn_Horizontal = "left",
110
+ vertical: TColumn_Vertical = "top",
111
+ ) -> None:
112
+ super().__init__(horizontal, vertical)
113
+ self.classes("w-full h-full no-wrap")
114
+ ui.query("main.q-page").classes("flex")
115
+ ui.query(".nicegui-content").classes("grow p-0")
116
+
117
+ def all_center(self):
118
+ return self.horizontal("center").vertical("center")
119
+
120
+ def full_screen(self):
121
+ return self.classes("fullscreen")
@@ -0,0 +1,80 @@
1
+ # region type
2
+
3
+ from typing_extensions import Literal
4
+
5
+
6
+ Space_map = {
7
+ "between": "space-between",
8
+ "around": "space-around",
9
+ "evenly": "space-evenly",
10
+ }
11
+
12
+ TColumn_Item_Horizontal = Literal[
13
+ "auto",
14
+ "left",
15
+ "right",
16
+ "center",
17
+ "stretch",
18
+ "baseline",
19
+ ]
20
+ Column_Item_Horizontal_map = {"left": "flex-start", "right": "flex-end"}
21
+
22
+
23
+ TColumn_Horizontal = Literal[
24
+ "left",
25
+ "right",
26
+ "center",
27
+ "baseline",
28
+ "stretch",
29
+ ]
30
+
31
+ Column_Horizontal_map = {"left": "flex-start", "right": "flex-end"}
32
+
33
+ TColumn_Vertical = Literal[
34
+ "normal",
35
+ "top",
36
+ "bottom",
37
+ "center",
38
+ "between",
39
+ "around",
40
+ "evenly",
41
+ "stretch",
42
+ ]
43
+
44
+ Column_Vertical_map = {"top": "flex-start", "bottom": "flex-end", **Space_map}
45
+
46
+
47
+ TRow_Horizontal = Literal[
48
+ "normal",
49
+ "left",
50
+ "right",
51
+ "center",
52
+ "between",
53
+ "around",
54
+ "evenly",
55
+ "stretch",
56
+ ]
57
+
58
+ Row_Horizontal_map = {"left": "flex-start", "right": "flex-end", **Space_map}
59
+
60
+ TRow_Vertical = Literal[
61
+ "top",
62
+ "bottom",
63
+ "center",
64
+ "baseline",
65
+ "stretch",
66
+ ]
67
+
68
+ Row_Vertical_map = {"top": "flex-start", "bottom": "flex-end"}
69
+
70
+
71
+ TRow_Item_Vertical = Literal[
72
+ "auto",
73
+ "top",
74
+ "bottom",
75
+ "center",
76
+ "stretch",
77
+ "baseline",
78
+ ]
79
+ TRow_Item_Vertical_map = {"top": "flex-start", "bottom": "flex-end"}
80
+ # endregion
@@ -43959,16 +43959,21 @@ const TX = { class: "echart-container relative" }, CX = /* @__PURE__ */ GL({
43959
43959
  });
43960
43960
  let i = null;
43961
43961
  Db(() => {
43962
- i = dV(n.value, a.theme), i.setOption(a.options), og(() => a.options, (s) => {
43963
- console.log(s), i == null || i.setOption(s);
43964
- }), i.on("click", (s) => {
43965
- t("chartClick", s);
43966
- }), i.getZr().on("click", function(s) {
43967
- s.target || t("chartClickBlank");
43968
- }), ZL("resize", () => {
43969
- i == null || i.resize();
43962
+ i = dV(n.value, a.theme), i.setOption(a.options), og(() => a.options, (l) => {
43963
+ i == null || i.setOption(l);
43964
+ }), i.on("click", (l) => {
43965
+ t("chartClick", l);
43966
+ }), i.getZr().on("click", function(l) {
43967
+ l.target || t("chartClickBlank");
43968
+ });
43969
+ function s() {
43970
+ const l = n.value.getBoundingClientRect();
43971
+ i == null || i.resize({ width: l.width - 5, height: l.height - 5 });
43972
+ }
43973
+ ZL("resize", () => {
43974
+ s();
43970
43975
  }), JL(n, () => {
43971
- i == null || i.resize();
43976
+ s();
43972
43977
  });
43973
43978
  });
43974
43979
  function o(s, l) {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ex4nicegui
3
- Version: 0.2.16
3
+ Version: 0.2.18
4
4
  Summary: ...
5
5
  Home-page:
6
6
  Author: carson_jia
@@ -1,9 +1,15 @@
1
- ex4nicegui/__init__.py,sha256=iH1dCSRqN6WObCWpEs1ZD4F8BGbIHV-gvHea9EiwZk0,397
1
+ ex4nicegui/__init__.py,sha256=_MbAAhRG7NTi391YxBHeqLpmetZrRQLlqtgHG8Nqebs,397
2
2
  ex4nicegui/experimental_/__init__.py,sha256=LSDd_U6eQ9g9St9kC4daau3MFGlVCRHGZJC4E0JRH34,36
3
- ex4nicegui/experimental_/gridLayout/__init__.py,sha256=XUIJ-uC9LTYjVosPQO9u6GCOen1xoEswa8G9uxemJls,38
4
- ex4nicegui/experimental_/gridLayout/index.py,sha256=2W1UStrShDPraBC27DuHSKqUEDSUKxE2ImBaL_qzMsg,2041
5
- ex4nicegui/layout/__init__.py,sha256=YoqBfyScFcWBw8EA77HygHMEc1O5AoQuOHLi6GcXtos,31
6
- ex4nicegui/layout/gridbox.py,sha256=yQuSFx4EpK_x6qRm1vIv6uHNOYa7XAZDTz5W_AMy7A8,2387
3
+ ex4nicegui/experimental_/gridLayout/__init__.py,sha256=48y_Pm0xxgC_PRnixQB5R_5rPL4FuyeoeOao_W7pm7A,49
4
+ ex4nicegui/experimental_/gridLayout/index.py,sha256=zFXuvFroo5EC1CFjt-b4hMiEy67hGP5J1GYTKH6kpUU,4737
5
+ ex4nicegui/layout/__init__.py,sha256=yYkdH0bC1nxIDr_OtvyTqR_yXkwnY5DmelaQOIwwjas,48
6
+ ex4nicegui/layout/gridFlex/GridFlex.js,sha256=ljkxGFucBUIPksMAT5w_35sxGogC7OzxzXnOw21Z3_k,4468
7
+ ex4nicegui/layout/gridFlex/__init__.py,sha256=98dcrOEROibl5fnzIj644CnELbUvYTid702IjhLdpfs,79
8
+ ex4nicegui/layout/gridFlex/gridFlex.py,sha256=8zMHKgh23wVr3TXVcvv8_KzyIZLk5zPUdgf7BWgy38k,7461
9
+ ex4nicegui/layout/gridFlex/utils.py,sha256=hBuusveBRaHSubIr2q38AP033-VtXDFE_fDzZtg4h44,1236
10
+ ex4nicegui/layout/rxFlex/__init__.py,sha256=dllXV6cri1oOZkOCGJpI9AlUjIZ3oB99ckLIYRW8faM,38
11
+ ex4nicegui/layout/rxFlex/index.py,sha256=XeAsxfy35RJBE2g2WGzKgskf43K4We0d2mBzWb0kbB8,3509
12
+ ex4nicegui/layout/rxFlex/types.py,sha256=OQBo3kkmtXhMo3BDI0GjX36HPJLDV1Cm67hPZGb1k2Q,1411
7
13
  ex4nicegui/reactive/__index.py,sha256=OaN_mD2TJORxqTzh2JeKAqaOhIBqM5cBnm21RqKt7PQ,451
8
14
  ex4nicegui/reactive/__init__.py,sha256=NZUgvItxqqgzHKrt4oGZnxxV9dlEudGiv4J3fhJdvdQ,24
9
15
  ex4nicegui/reactive/drawer.py,sha256=NWMq2gnalpYAU8tT0DwGN5l8n7fuMxTIWxOfr2QvFIA,1356
@@ -12,7 +18,7 @@ ex4nicegui/reactive/local_file_picker.py,sha256=DWNzm_IP02sY-nZWN6WEWJxlwpABW6tN
12
18
  ex4nicegui/reactive/q_pagination.py,sha256=ITXBrjLnI1a5bz3Rbn7j8lZs9UJaFuMHrM9_FW_V7NA,1217
13
19
  ex4nicegui/reactive/rxui.py,sha256=NZUgvItxqqgzHKrt4oGZnxxV9dlEudGiv4J3fhJdvdQ,24
14
20
  ex4nicegui/reactive/usePagination.py,sha256=IP1NeLxaH3413KTEjtbyuzq0FVdtnKQsTZqM-W7iEgY,2468
15
- ex4nicegui/reactive/EChartsComponent/ECharts.js,sha256=O4H4Mev9WN4DJqvr1PMI97ol5Yykx2ts2M8KInOtc5w,1581651
21
+ ex4nicegui/reactive/EChartsComponent/ECharts.js,sha256=zpB_m1dxK236_qZAiM8jzMkNCVTEPgeSV6tFpdgLZoo,1581763
16
22
  ex4nicegui/reactive/EChartsComponent/ECharts.py,sha256=LhThgTo7TSjaXIaWcG6eJojuPWyhUkDkw3tJIuCkJTw,2968
17
23
  ex4nicegui/reactive/EChartsComponent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
24
  ex4nicegui/reactive/UseDraggable/UseDraggable.js,sha256=D2_4c64qYwkqG_JzL1ZAwoNZDoz6qtHfPA_Z5RIvmIw,5235
@@ -57,8 +63,8 @@ ex4nicegui/tools/debug.py,sha256=HCKlVzhHx5av-983ADgwgMkScKwTreSluLA7uikGYa0,488
57
63
  ex4nicegui/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
64
  ex4nicegui/utils/common.py,sha256=5fsaOkoj-Ild1LGsInZXra66gJLVoVcZGAIG6YOeM6E,430
59
65
  ex4nicegui/utils/signals.py,sha256=Dwvb0Anansa0N1ZH2Ko0yCX9o-QHKbXOYEtvdrtde9g,4807
60
- ex4nicegui-0.2.16.dist-info/LICENSE,sha256=0KDDElS2dl-HIsWvbpy8ywbLzJMBFzXLev57LnMIZXs,1094
61
- ex4nicegui-0.2.16.dist-info/METADATA,sha256=obmzQBUSNjKvjsFKcNjJ3DpSicwNll3O2mGx7AmsaF0,515
62
- ex4nicegui-0.2.16.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
63
- ex4nicegui-0.2.16.dist-info/top_level.txt,sha256=VFwMiO9AFjj5rfLMJwN1ipLRASk9fJXB8tM6DNrpvPQ,11
64
- ex4nicegui-0.2.16.dist-info/RECORD,,
66
+ ex4nicegui-0.2.18.dist-info/LICENSE,sha256=0KDDElS2dl-HIsWvbpy8ywbLzJMBFzXLev57LnMIZXs,1094
67
+ ex4nicegui-0.2.18.dist-info/METADATA,sha256=wpiHNzH4hmeP__pwog5DyINiHtd99yQgHl48qj7DakI,515
68
+ ex4nicegui-0.2.18.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
69
+ ex4nicegui-0.2.18.dist-info/top_level.txt,sha256=VFwMiO9AFjj5rfLMJwN1ipLRASk9fJXB8tM6DNrpvPQ,11
70
+ ex4nicegui-0.2.18.dist-info/RECORD,,
@@ -1,85 +0,0 @@
1
- from typing import List, Optional, Union, cast
2
- from nicegui.client import Client
3
- from nicegui.element import Element
4
- from ex4nicegui.reactive.officials.base import BindableUi
5
-
6
-
7
- def _areas_str2array(areas: str) -> List[List[str]]:
8
- """
9
- >>> input='''
10
- sc1 sc2
11
- sc3
12
- table table table table
13
- '''
14
- >>> areas_str2array(input)
15
- >>> [
16
- ["sc1", "sc2"],
17
- ["sc3"],
18
- ["table", "table", "table", "table"]
19
- ]
20
- """
21
- pass
22
-
23
- lines = (line.strip() for line in areas.splitlines())
24
- remove_empty_rows = (line for line in lines if len(line) > 0)
25
- splie_space = (line.split() for line in remove_empty_rows)
26
- return list(splie_space)
27
-
28
-
29
- def _areas_array2str(areas_array: List[List[str]]):
30
- """
31
- >>> input = [
32
- ["sc1", "sc2"],
33
- ["sc3"],
34
- ["table"] * 4
35
- ]
36
- >>> areas_array2str(input)
37
- >>> '"sc1 sc2 . ." "sc3 . . ." "table table table table"'
38
- """
39
- max_len = max(map(len, areas_array))
40
-
41
- fix_empty = (
42
- [*line, *(["."] * (max_len - len(line)))] if len(line) < max_len else line
43
- for line in areas_array
44
- )
45
-
46
- line2str = (f'"{" ".join(line)}"' for line in fix_empty)
47
- return " ".join(line2str)
48
-
49
-
50
- class grid_box(Element):
51
- def __init__(
52
- self,
53
- areas_text: str,
54
- template_columns: Optional[str] = None,
55
- template_rows: Optional[str] = None,
56
- *,
57
- _client: Client | None = None,
58
- ) -> None:
59
- super().__init__("div", _client=_client)
60
-
61
- areas_list = _areas_str2array(areas_text)
62
-
63
- areas = _areas_array2str(areas_list)
64
-
65
- areas_cols_len = max(map(len, areas_list))
66
- areas_rows_len = len(areas_list)
67
-
68
- template_columns = template_columns or f"repeat({areas_cols_len}, 1fr)"
69
- template_rows = template_rows or f"repeat({areas_rows_len}, 1fr)"
70
-
71
- self.style(
72
- f"""
73
- width: 100%;
74
- grid-template-areas: {areas};
75
- display: grid;
76
- grid-template-columns: {template_columns};
77
- grid-template-rows:{template_rows};"""
78
- )
79
-
80
- def areas_mark(self, element: Union[Element, BindableUi], mark: str):
81
- if isinstance(element, BindableUi):
82
- element = element.element
83
- element = cast(Element, element)
84
- element.style(f"grid-area:{mark}")
85
- return element