@selectwin/kit 0.1.243 → 0.1.244

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.
@@ -4,38 +4,39 @@ import { FrameBody as r, useFrameKind as i } from "./internal/frame.js";
4
4
  import { SelectAvatar as a } from "./SelectAvatar.js";
5
5
  import { SelectListChrome as o, listChromeShape as s } from "./internal/listChrome.js";
6
6
  import { SelectTableEmpty as c } from "./SelectTableEmpty.js";
7
- import { Children as l, createContext as u, forwardRef as d, useCallback as f, useContext as p, useId as m, useLayoutEffect as h, useRef as g, useState as _ } from "react";
8
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
7
+ import { Children as l, createContext as u, forwardRef as d, useCallback as f, useContext as p, useId as ee, useLayoutEffect as m, useRef as h, useState as g } from "react";
8
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
9
9
  //#region src/SelectTable.tsx
10
- var x = 40, S = 1200, C = 8;
11
- function w(e) {
10
+ var b = 40, x = 1200, S = 8;
11
+ function C(e) {
12
12
  let t = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
13
13
  return `${Math.round(e / t * 1e3) / 1e3}rem`;
14
14
  }
15
- var T = u(0), E = d(function({ columns: t, children: a, empty: c, footer: u, title: d, help: p, description: v, action: E, filters: O, tools: k, onColumnResize: A, onColumnResizeReset: j, collapsible: M = !1, defaultOpen: N = !0, flush: P = !1, label: F, minWidth: I, sizing: L = "even", className: R, ...z }, B) {
16
- let V = F ?? (typeof d == "string" ? d : void 0), [H, U] = _(N), W = m(), G = M && d != null ? {
17
- open: H,
18
- onToggle: () => U((e) => !e),
19
- controls: W
20
- } : void 0, K = l.count(a) === 0, q = K && !!c, { hasFilters: J, hasTitleRow: Y } = s({
15
+ var w = u(0), T = d(function({ columns: t, children: a, empty: c, footer: u, title: d, help: p, description: _, action: T, filters: D, tools: O, onColumnResize: k, onColumnResizeReset: A, collapsible: j = !1, defaultOpen: te = !0, flush: M = !1, label: N, minWidth: P, sizing: ne = "even", className: F, ...I }, L) {
16
+ var R;
17
+ let re = N ?? (typeof d == "string" ? d : void 0), [z, B] = g(te), V = ee(), H = j && d != null ? {
18
+ open: z,
19
+ onToggle: () => B((e) => !e),
20
+ controls: V
21
+ } : void 0, U = l.count(a) === 0, W = U && !!c, { hasFilters: G, hasTitleRow: K } = s({
21
22
  title: d,
22
- description: v,
23
- action: E,
24
- filters: O,
25
- tools: k
26
- }), ee = q && !Y && !J, X = i(), te = X === "body", ne = X === "list", re = n({
23
+ description: _,
24
+ action: T,
25
+ filters: D,
26
+ tools: O
27
+ }), q = W && !K && !G, J = (R = t[t.length - 1]) == null ? void 0 : R.label, Y = J != null && J !== "" && J !== !1, X = i(), ie = X === "body", ae = X === "list", oe = n({
27
28
  selector: ".select-table__row",
28
29
  y: 8,
29
30
  duration: .45,
30
31
  stagger: .05,
31
32
  scroll: !0
32
- }), Z = t.length ? t.map((e) => e.width ?? `minmax(${e.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${e.grow ?? 1}fr)`).join(" ") : "1fr", Q = g(null), ie = f((e) => {
33
- Q.current = e, typeof B == "function" ? B(e) : B && (B.current = e);
34
- }, [B]);
35
- h(() => {
33
+ }), Z = t.length ? t.map((e) => e.width ?? `minmax(${e.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${e.grow ?? 1}fr)`).join(" ") : "1fr", Q = h(null), se = f((e) => {
34
+ Q.current = e, typeof L == "function" ? L(e) : L && (L.current = e);
35
+ }, [L]);
36
+ m(() => {
36
37
  let e = Q.current;
37
38
  if (!e) return;
38
- if (L !== "content" || !t.some((e) => e.width == null)) {
39
+ if (ne !== "content" || !t.some((e) => e.width == null)) {
39
40
  e.style.setProperty("--select-table-cols", Z);
40
41
  return;
41
42
  }
@@ -63,9 +64,9 @@ var T = u(0), E = d(function({ columns: t, children: a, empty: c, footer: u, tit
63
64
  if (!r) return;
64
65
  let i = t.map((t, r) => r === e ? `${n}px` : t.width ?? `minmax(${t.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${t.grow ?? 1}fr)`);
65
66
  r.style.setProperty("--select-table-cols", i.join(" "));
66
- }, ae = (e) => (t) => {
67
+ }, ce = (e) => (t) => {
67
68
  var n;
68
- if (!A || t.button !== 0) return;
69
+ if (!k || t.button !== 0) return;
69
70
  let r = (n = t.currentTarget.parentElement) == null ? void 0 : n.getBoundingClientRect();
70
71
  if (!r) return;
71
72
  let i = t.clientX, a = r.width;
@@ -73,86 +74,86 @@ var T = u(0), E = d(function({ columns: t, children: a, empty: c, footer: u, tit
73
74
  let o = Q.current;
74
75
  o == null || o.classList.add("select-table--resizing");
75
76
  let s = a, c = (t) => {
76
- s = Math.min(S, Math.max(x, a + (t.clientX - i))), $(e, s);
77
+ s = Math.min(x, Math.max(b, a + (t.clientX - i))), $(e, s);
77
78
  }, l = () => {
78
- window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l), o == null || o.classList.remove("select-table--resizing"), A(e, w(s));
79
+ window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l), o == null || o.classList.remove("select-table--resizing"), k(e, C(s));
79
80
  };
80
81
  window.addEventListener("pointermove", c), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", l);
81
- }, oe = (e) => (t) => {
82
+ }, le = (e) => (t) => {
82
83
  var n;
83
- if (!A) return;
84
+ if (!k) return;
84
85
  let r = t.key === "ArrowRight" ? 1 : t.key === "ArrowLeft" ? -1 : 0;
85
86
  if (r === 0) return;
86
87
  let i = (n = t.currentTarget.parentElement) == null ? void 0 : n.getBoundingClientRect();
87
88
  if (!i) return;
88
89
  t.preventDefault();
89
- let a = C * (t.shiftKey ? 10 : 1), o = Math.min(S, Math.max(x, i.width + r * a));
90
- $(e, o), A(e, w(o));
90
+ let a = S * (t.shiftKey ? 10 : 1), o = Math.min(x, Math.max(b, i.width + r * a));
91
+ $(e, o), k(e, C(o));
91
92
  };
92
- return /* @__PURE__ */ b("div", {
93
- ref: ie,
94
- ...z,
95
- className: `select-table${ee ? " select-table--empty" : ""}${te && !P ? " select-table--nested" : ""}${ne && !P ? " select-table--inlist" : ""}${P ? " select-table--flush" : ""}${G ? ` select-table--collapsible${H ? " is-open" : ""}` : ""}${R ? " " + R : ""}`,
93
+ return /* @__PURE__ */ y("div", {
94
+ ref: se,
95
+ ...I,
96
+ className: `select-table${q ? " select-table--empty" : ""}${ie && !M ? " select-table--nested" : ""}${ae && !M ? " select-table--inlist" : ""}${M ? " select-table--flush" : ""}${H ? ` select-table--collapsible${z ? " is-open" : ""}` : ""}${Y ? " select-table--free-last" : ""}${F ? " " + F : ""}`,
96
97
  style: {
97
98
  "--select-table-cols": Z,
98
- ...I ? { "--select-table-min": I } : {}
99
+ ...P ? { "--select-table-min": P } : {}
99
100
  },
100
- children: [/* @__PURE__ */ y(o, {
101
+ children: [/* @__PURE__ */ v(o, {
101
102
  title: d,
102
- help: G ? void 0 : p,
103
- description: v,
104
- action: E,
105
- filters: G ? void 0 : O,
106
- tools: G ? void 0 : k,
107
- toggle: G
108
- }), /* @__PURE__ */ b(D, {
109
- enabled: !!G,
110
- open: H,
111
- id: W,
103
+ help: H ? void 0 : p,
104
+ description: _,
105
+ action: T,
106
+ filters: H ? void 0 : D,
107
+ tools: H ? void 0 : O,
108
+ toggle: H
109
+ }), /* @__PURE__ */ y(E, {
110
+ enabled: !!H,
111
+ open: z,
112
+ id: V,
112
113
  children: [
113
- G && (O != null || k != null) ? /* @__PURE__ */ y(o, {
114
- filters: O,
115
- tools: k
114
+ H && (D != null || O != null) ? /* @__PURE__ */ v(o, {
115
+ filters: D,
116
+ tools: O
116
117
  }) : null,
117
- /* @__PURE__ */ y("div", {
118
- className: `select-table__scroll${q ? " select-table__scroll--empty" : ""}`,
119
- children: /* @__PURE__ */ b("div", {
118
+ /* @__PURE__ */ v("div", {
119
+ className: `select-table__scroll${W ? " select-table__scroll--empty" : ""}`,
120
+ children: /* @__PURE__ */ y("div", {
120
121
  className: "select-table__scrollinner",
121
- ...q ? {} : {
122
+ ...W ? {} : {
122
123
  role: "table",
123
- "aria-label": V
124
+ "aria-label": re
124
125
  },
125
- children: [!q && /* @__PURE__ */ y("div", {
126
+ children: [!W && /* @__PURE__ */ v("div", {
126
127
  className: "select-table__head",
127
128
  role: "row",
128
- children: t.map((n, r) => /* @__PURE__ */ b("div", {
129
+ children: t.map((n, r) => /* @__PURE__ */ y("div", {
129
130
  role: "columnheader",
130
131
  "aria-sort": n.sortable ? n.sortDir === "asc" ? "ascending" : n.sortDir === "desc" ? "descending" : "none" : void 0,
131
132
  className: `select-table__th select-table__cell--${n.align ?? "start"}${n.tone ? ` select-table__th--${n.tone}` : ""}`,
132
- children: [n.sortable ? /* @__PURE__ */ b("button", {
133
+ children: [n.sortable ? /* @__PURE__ */ y("button", {
133
134
  type: "button",
134
135
  className: `select-table__sortbtn${n.sortDir === "asc" ? " select-table__sortbtn--asc" : ""}${n.sortDir == null ? "" : " select-table__sortbtn--active"}`,
135
136
  onClick: n.onSort,
136
- children: [n.label, /* @__PURE__ */ y(e, {})]
137
- }) : n.label, A && n.resizable !== !1 && r < t.length - 1 && /* @__PURE__ */ y("span", {
137
+ children: [n.label, /* @__PURE__ */ v(e, {})]
138
+ }) : n.label, k && n.resizable !== !1 && r < t.length - 1 && /* @__PURE__ */ v("span", {
138
139
  role: "separator",
139
140
  "aria-orientation": "vertical",
140
141
  "aria-label": "Ajustar a largura da coluna",
141
142
  tabIndex: 0,
142
143
  className: "select-table__resizer",
143
- onPointerDown: ae(r),
144
- onKeyDown: oe(r),
145
- onDoubleClick: j ? () => j(r) : void 0
144
+ onPointerDown: ce(r),
145
+ onKeyDown: le(r),
146
+ onDoubleClick: A ? () => A(r) : void 0
146
147
  })]
147
148
  }, r))
148
- }), /* @__PURE__ */ y("div", {
149
+ }), /* @__PURE__ */ v("div", {
149
150
  className: "select-table__body",
150
- children: /* @__PURE__ */ y("div", {
151
+ children: /* @__PURE__ */ v("div", {
151
152
  className: "select-table__rows",
152
- ref: re,
153
- children: /* @__PURE__ */ y(T.Provider, {
153
+ ref: oe,
154
+ children: /* @__PURE__ */ v(w.Provider, {
154
155
  value: t.length,
155
- children: /* @__PURE__ */ y(r, { children: K && c ? /* @__PURE__ */ y("div", {
156
+ children: /* @__PURE__ */ v(r, { children: U && c ? /* @__PURE__ */ v("div", {
156
157
  className: "select-table__empty",
157
158
  children: c
158
159
  }) : a })
@@ -161,7 +162,7 @@ var T = u(0), E = d(function({ columns: t, children: a, empty: c, footer: u, tit
161
162
  })]
162
163
  })
163
164
  }),
164
- u && /* @__PURE__ */ y("div", {
165
+ u && /* @__PURE__ */ v("div", {
165
166
  className: "select-table__footer",
166
167
  children: u
167
168
  })
@@ -169,47 +170,47 @@ var T = u(0), E = d(function({ columns: t, children: a, empty: c, footer: u, tit
169
170
  })]
170
171
  });
171
172
  });
172
- function D({ enabled: e, open: t, id: n, children: r }) {
173
- return e ? /* @__PURE__ */ y("div", {
173
+ function E({ enabled: e, open: t, id: n, children: r }) {
174
+ return e ? /* @__PURE__ */ v("div", {
174
175
  className: "select-table__collapse",
175
176
  id: n,
176
177
  "data-open": t,
177
178
  "aria-hidden": !t,
178
- children: /* @__PURE__ */ y("div", {
179
+ children: /* @__PURE__ */ v("div", {
179
180
  className: "select-table__collapsewrap",
180
181
  children: r
181
182
  })
182
- }) : /* @__PURE__ */ y(v, { children: r });
183
+ }) : /* @__PURE__ */ v(_, { children: r });
183
184
  }
184
- var O = d(function({ name: e, secondary: t, src: n, badge: r, className: i, ...o }, s) {
185
- return /* @__PURE__ */ b("span", {
185
+ var D = d(function({ name: e, secondary: t, src: n, badge: r, className: i, ...o }, s) {
186
+ return /* @__PURE__ */ y("span", {
186
187
  ref: s,
187
188
  ...o,
188
189
  className: `select-usercell${i ? " " + i : ""}`,
189
- children: [/* @__PURE__ */ y(a, {
190
+ children: [/* @__PURE__ */ v(a, {
190
191
  name: typeof e == "string" ? e : void 0,
191
192
  src: n
192
- }), /* @__PURE__ */ b("span", {
193
+ }), /* @__PURE__ */ y("span", {
193
194
  className: "select-usercell__text",
194
- children: [r ? /* @__PURE__ */ b("span", {
195
+ children: [r ? /* @__PURE__ */ y("span", {
195
196
  className: "select-usercell__line",
196
- children: [/* @__PURE__ */ y("span", {
197
+ children: [/* @__PURE__ */ v("span", {
197
198
  className: "select-usercell__name",
198
199
  children: e
199
200
  }), r]
200
- }) : /* @__PURE__ */ y("span", {
201
+ }) : /* @__PURE__ */ v("span", {
201
202
  className: "select-usercell__name",
202
203
  children: e
203
- }), t && /* @__PURE__ */ y("span", {
204
+ }), t && /* @__PURE__ */ v("span", {
204
205
  className: "select-usercell__secondary",
205
206
  children: t
206
207
  })]
207
208
  })]
208
209
  });
209
210
  });
210
- function k({ children: e, onClick: t, expanded: n, nested: r = !1, current: i = !1, section: a = !1, muted: o = !1, className: s, ...c }) {
211
+ function O({ children: e, onClick: t, expanded: n, nested: r = !1, current: i = !1, section: a = !1, muted: o = !1, className: s, ...c }) {
211
212
  let l = `select-table__row${t ? " select-table__row--clickable" : ""}${r ? " select-table__row--nested" : ""}${a ? " select-table__row--section" : ""}${o ? " select-table__row--muted" : ""}${n ? " is-expanded" : ""}${i ? " is-current" : ""}${s ? " " + s : ""}`;
212
- return t ? /* @__PURE__ */ y("div", {
213
+ return t ? /* @__PURE__ */ v("div", {
213
214
  ...c,
214
215
  className: l,
215
216
  role: "row",
@@ -217,13 +218,13 @@ function k({ children: e, onClick: t, expanded: n, nested: r = !1, current: i =
217
218
  "aria-expanded": n,
218
219
  "aria-current": i || void 0,
219
220
  onClick: (e) => {
220
- j(e.target, e.currentTarget) || t();
221
+ A(e.target, e.currentTarget) || t();
221
222
  },
222
223
  onKeyDown: (e) => {
223
224
  e.target !== e.currentTarget || e.key !== "Enter" && e.key !== " " || (e.preventDefault(), t());
224
225
  },
225
226
  children: e
226
- }) : /* @__PURE__ */ y("div", {
227
+ }) : /* @__PURE__ */ v("div", {
227
228
  ...c,
228
229
  className: l,
229
230
  role: "row",
@@ -231,15 +232,15 @@ function k({ children: e, onClick: t, expanded: n, nested: r = !1, current: i =
231
232
  children: e
232
233
  });
233
234
  }
234
- var A = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [role=\"menuitem\"], [role=\"checkbox\"], [role=\"switch\"], [data-row-click=\"ignore\"]";
235
- function j(e, t) {
235
+ var k = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [role=\"menuitem\"], [role=\"checkbox\"], [role=\"switch\"], [data-row-click=\"ignore\"]";
236
+ function A(e, t) {
236
237
  if (!(e instanceof Element) || !t.contains(e)) return !0;
237
- let n = e.closest(A);
238
+ let n = e.closest(k);
238
239
  return n !== null && n !== t && t.contains(n);
239
240
  }
240
- var M = d(function({ children: e, align: n = "start", disclosure: r, header: i = !1, span: a, wrap: o = !1, className: s, style: c, ...l }, u) {
241
- let d = p(T), f = a === "all" ? d || void 0 : a;
242
- return /* @__PURE__ */ b("div", {
241
+ var j = d(function({ children: e, align: n = "start", disclosure: r, header: i = !1, span: a, wrap: o = !1, className: s, style: c, ...l }, u) {
242
+ let d = p(w), f = a === "all" ? d || void 0 : a;
243
+ return /* @__PURE__ */ y("div", {
243
244
  ref: u,
244
245
  ...l,
245
246
  role: i ? "rowheader" : "cell",
@@ -249,14 +250,14 @@ var M = d(function({ children: e, align: n = "start", disclosure: r, header: i =
249
250
  ...c
250
251
  } : c,
251
252
  className: `select-table__td select-table__cell--${n}${o ? " select-table__td--wrap" : ""}${s ? " " + s : ""}`,
252
- children: [r ? /* @__PURE__ */ y("span", {
253
+ children: [r ? /* @__PURE__ */ v("span", {
253
254
  className: `select-table__disclosure${r === "open" ? " is-open" : ""}`,
254
255
  "aria-hidden": "true",
255
- children: r !== "none" && /* @__PURE__ */ y(t, {})
256
+ children: r !== "none" && /* @__PURE__ */ v(t, {})
256
257
  }) : null, e]
257
258
  });
258
259
  });
259
260
  //#endregion
260
- export { E as SelectTable, M as SelectTableCell, c as SelectTableEmpty, k as SelectTableRow, O as SelectUserCell };
261
+ export { T as SelectTable, j as SelectTableCell, c as SelectTableEmpty, O as SelectTableRow, D as SelectUserCell };
261
262
 
262
263
  //# sourceMappingURL=SelectTable.js.map