@cascivo/react 0.17.1 → 1.0.0

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 (101) hide show
  1. package/README.md +4 -3
  2. package/dist/action-sheet/action-sheet.js +1 -1
  3. package/dist/breadcrumb/breadcrumb.js +7 -7
  4. package/dist/checkbox/checkbox.js +11 -10
  5. package/dist/color-picker/color-picker.js +81 -77
  6. package/dist/combobox/combobox.js +81 -76
  7. package/dist/command-menu/command-menu.js +104 -104
  8. package/dist/comparison/comparison.js +18 -18
  9. package/dist/data-table/data-table.css +1 -1
  10. package/dist/data-table/data-table.js +148 -121
  11. package/dist/data-table/data-table.module.js +29 -29
  12. package/dist/date-picker/date-picker.js +98 -93
  13. package/dist/date-range-picker/date-range-picker.js +1 -1
  14. package/dist/dock/dock.js +2 -2
  15. package/dist/dropdown/dropdown.js +43 -40
  16. package/dist/editable/editable.js +29 -20
  17. package/dist/fab/fab.js +37 -37
  18. package/dist/field/field.js +24 -17
  19. package/dist/file-uploader/file-uploader.js +24 -23
  20. package/dist/filter/filter.js +11 -11
  21. package/dist/index.d.ts +1302 -85
  22. package/dist/input/input.js +14 -13
  23. package/dist/navigation-menu/navigation-menu.js +9 -9
  24. package/dist/node/action-sheet/action-sheet.js +1 -1
  25. package/dist/node/breadcrumb/breadcrumb.js +7 -7
  26. package/dist/node/checkbox/checkbox.js +11 -10
  27. package/dist/node/color-picker/color-picker.js +81 -77
  28. package/dist/node/combobox/combobox.js +81 -76
  29. package/dist/node/command-menu/command-menu.js +104 -104
  30. package/dist/node/comparison/comparison.js +18 -18
  31. package/dist/node/data-table/data-table.js +148 -121
  32. package/dist/node/data-table/data-table.module.js +29 -29
  33. package/dist/node/date-picker/date-picker.js +98 -93
  34. package/dist/node/date-range-picker/date-range-picker.js +1 -1
  35. package/dist/node/dock/dock.js +2 -2
  36. package/dist/node/dropdown/dropdown.js +43 -40
  37. package/dist/node/editable/editable.js +29 -20
  38. package/dist/node/fab/fab.js +37 -37
  39. package/dist/node/field/field.js +24 -17
  40. package/dist/node/file-uploader/file-uploader.js +24 -23
  41. package/dist/node/filter/filter.js +11 -11
  42. package/dist/node/input/input.js +14 -13
  43. package/dist/node/navigation-menu/navigation-menu.js +9 -9
  44. package/dist/node/number-input/number-input.js +28 -27
  45. package/dist/node/overflow-menu/overflow-menu.js +7 -7
  46. package/dist/node/progress/progress.js +3 -3
  47. package/dist/node/progress-circle/progress-circle.js +8 -8
  48. package/dist/node/progress-indicator/progress-indicator.js +1 -1
  49. package/dist/node/qr-code/qr-code.js +11 -11
  50. package/dist/node/radial-progress/radial-progress.js +9 -9
  51. package/dist/node/radio/radio.js +10 -9
  52. package/dist/node/react/src/index.js +93 -93
  53. package/dist/node/resizable/resizable.js +24 -24
  54. package/dist/node/search/search.js +35 -31
  55. package/dist/node/select/select.js +15 -14
  56. package/dist/node/side-nav/side-nav.js +35 -35
  57. package/dist/node/side-nav/side-nav.module.js +27 -27
  58. package/dist/node/slider/slider.js +13 -12
  59. package/dist/node/spinner/spinner.js +4 -4
  60. package/dist/node/steps/steps.js +10 -10
  61. package/dist/node/structured-list/structured-list.js +14 -14
  62. package/dist/node/swap/swap.js +5 -5
  63. package/dist/node/switcher/switcher.js +5 -5
  64. package/dist/node/tags-input/tags-input.js +20 -16
  65. package/dist/node/textarea/textarea.js +14 -13
  66. package/dist/node/time-picker/time-picker.js +21 -20
  67. package/dist/node/toggle/toggle.js +8 -7
  68. package/dist/node/tree-view/tree-view.js +43 -43
  69. package/dist/node/virtual-list/virtual-list.js +10 -10
  70. package/dist/node/wheel-picker/wheel-picker.js +36 -36
  71. package/dist/number-input/number-input.js +28 -27
  72. package/dist/overflow-menu/overflow-menu.js +7 -7
  73. package/dist/progress/progress.js +3 -3
  74. package/dist/progress-circle/progress-circle.js +8 -8
  75. package/dist/progress-indicator/progress-indicator.js +1 -1
  76. package/dist/qr-code/qr-code.js +11 -11
  77. package/dist/radial-progress/radial-progress.js +9 -9
  78. package/dist/radio/radio.js +10 -9
  79. package/dist/react/src/index.js +93 -93
  80. package/dist/resizable/resizable.js +24 -24
  81. package/dist/search/search.js +35 -31
  82. package/dist/select/select.js +15 -14
  83. package/dist/side-nav/side-nav.css +1 -1
  84. package/dist/side-nav/side-nav.js +35 -35
  85. package/dist/side-nav/side-nav.module.js +27 -27
  86. package/dist/slider/slider.js +13 -12
  87. package/dist/spinner/spinner.js +4 -4
  88. package/dist/steps/steps.js +10 -10
  89. package/dist/structured-list/structured-list.js +14 -14
  90. package/dist/styles.css +2 -2
  91. package/dist/swap/swap.js +5 -5
  92. package/dist/switcher/switcher.js +5 -5
  93. package/dist/tags-input/tags-input.js +20 -16
  94. package/dist/textarea/textarea.js +14 -13
  95. package/dist/time-picker/time-picker.js +21 -20
  96. package/dist/toggle/toggle.js +8 -7
  97. package/dist/tree-view/tree-view.js +43 -43
  98. package/dist/virtual-list/virtual-list.js +10 -10
  99. package/dist/wheel-picker/wheel-picker.js +36 -36
  100. package/package.json +4 -4
  101. package/readme.body.md +4 -3
@@ -2,25 +2,25 @@
2
2
 
3
3
  import e from "./date-picker.module.js";
4
4
  import { useId as t, useRef as n } from "react";
5
- import { batch as r, cn as i, createMachine as a, useControllableSignal as o, useMachine as s, useSignal as c, useSignalEffect as l, useSignals as ee } from "@cascivo/core";
6
- import { builtin as u, currentLocale as d, t as f } from "@cascivo/i18n";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
5
+ import { batch as r, cn as i, createMachine as a, useControllableSignal as o, useMachine as s, useSignal as c, useSignalEffect as ee, useSignals as te } from "@cascivo/core";
6
+ import { builtin as l, currentLocale as u, t as d } from "@cascivo/i18n";
7
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
8
8
  //#region ../components/src/date-picker/date-picker.tsx
9
- var h = a({
9
+ var m = a({
10
10
  initial: "closed",
11
11
  states: {
12
12
  closed: { on: { OPEN: "open" } },
13
13
  open: { on: { CLOSE: "closed" } }
14
14
  }
15
15
  });
16
- function g(e) {
16
+ function ne(e) {
17
17
  try {
18
18
  let t = new Intl.Locale(e).weekInfo;
19
19
  if (t) return t.firstDay % 7;
20
20
  } catch {}
21
21
  return 1;
22
22
  }
23
- function te(e, t, n) {
23
+ function re(e, t, n) {
24
24
  let r = new Date(Date.UTC(e, t, 1)), i = new Date(Date.UTC(e, t + 1, 0)), a = (r.getUTCDay() - n + 7) % 7, o = [];
25
25
  for (let e = 0; e < a; e++) o.push(null);
26
26
  for (let n = 1; n <= i.getUTCDate(); n++) o.push(new Date(Date.UTC(e, t, n)));
@@ -29,53 +29,56 @@ function te(e, t, n) {
29
29
  for (let e = 0; e < o.length; e += 7) s.push(o.slice(e, e + 7));
30
30
  return s;
31
31
  }
32
- function _(e, t) {
32
+ function h(e, t) {
33
33
  return new Intl.DateTimeFormat(t).format(e);
34
34
  }
35
- function v(e) {
35
+ function g(e) {
36
36
  return e.toISOString().slice(0, 10);
37
37
  }
38
- function y(e) {
38
+ function _(e) {
39
39
  let [t, n, r] = e.split("-").map(Number);
40
40
  return new Date(Date.UTC(t, n - 1, r));
41
41
  }
42
- function b({ value: a, defaultValue: b, onValueChange: ne, onChange: x, min: S, max: C, clearable: w = !1, label: T, hint: E, error: D, size: re = "md", disabled: O = !1, labels: k, className: ie, id: ae }) {
43
- ee();
44
- let [A, j] = s(h), M = t(), N = ae ?? `cascade-date-picker-${M}`, P = `${M}-grid`, F = d(), I = k?.placeholder ?? f(u.datePicker.placeholder), L = k?.previousMonth ?? f(u.datePicker.previousMonth), R = k?.nextMonth ?? f(u.datePicker.nextMonth), z = k?.clear ?? f(u.datePicker.clear), B = /* @__PURE__ */ new Date(), V = v(B), [H] = o({
42
+ function ie(...e) {
43
+ return e.filter(Boolean).join(" ") || void 0;
44
+ }
45
+ function v({ value: a, defaultValue: v, onValueChange: y, min: b, max: x, clearable: ae = !1, label: S, ariaLabel: oe, hint: C, error: w, size: T = "md", disabled: E = !1, labels: D, className: O, id: k, "aria-labelledby": A, "aria-describedby": se, "aria-invalid": ce }) {
46
+ te();
47
+ let [j, M] = s(m), N = t(), P = k ?? `cascade-date-picker-${N}`, F = `${N}-grid`, I = u(), L = D?.placeholder ?? d(l.datePicker.placeholder), R = D?.previousMonth ?? d(l.datePicker.previousMonth), z = D?.nextMonth ?? d(l.datePicker.nextMonth), B = D?.clear ?? d(l.datePicker.clear), V = /* @__PURE__ */ new Date(), H = g(V), [U] = o({
45
48
  value: a,
46
- defaultValue: b
47
- }), U = c(H.value ? y(H.value).getUTCFullYear() : B.getUTCFullYear()), W = c(H.value ? y(H.value).getUTCMonth() : B.getUTCMonth()), G = c(H.value), K = n(null);
48
- l(() => {
49
- if (A.value !== "open") return;
49
+ defaultValue: v
50
+ }), W = c(U.value ? _(U.value).getUTCFullYear() : V.getUTCFullYear()), G = c(U.value ? _(U.value).getUTCMonth() : V.getUTCMonth()), K = c(U.value), q = n(null);
51
+ ee(() => {
52
+ if (j.value !== "open") return;
50
53
  let e = (e) => {
51
- K.current && !K.current.contains(e.target) && j("CLOSE");
54
+ q.current && !q.current.contains(e.target) && M("CLOSE");
52
55
  };
53
56
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
54
57
  });
55
- let q = () => {
56
- O || j("OPEN");
57
- }, J = () => j("CLOSE"), Y = ne ?? x, X = (e) => {
58
- S && e < S || C && e > C || (a === void 0 && (H.value = e), Y?.(e), J());
59
- }, oe = (e) => {
60
- e.stopPropagation(), a === void 0 && (H.value = void 0), Y?.(void 0);
61
- }, se = () => {
62
- W.value === 0 ? r(() => {
63
- U.value--, W.value = 11;
64
- }) : W.value--;
65
- }, ce = () => {
66
- W.value === 11 ? r(() => {
67
- U.value++, W.value = 0;
68
- }) : W.value++;
69
- }, Z = g(F), le = te(U.value, W.value, Z), ue = new Intl.DateTimeFormat(F, { weekday: "short" }), de = Array.from({ length: 7 }, (e, t) => {
58
+ let le = () => {
59
+ E || M("OPEN");
60
+ }, J = () => M("CLOSE"), Y = y, X = (e) => {
61
+ b && e < b || x && e > x || (a === void 0 && (U.value = e), Y?.(e), J());
62
+ }, ue = (e) => {
63
+ e.stopPropagation(), a === void 0 && (U.value = void 0), Y?.(void 0);
64
+ }, de = () => {
65
+ G.value === 0 ? r(() => {
66
+ W.value--, G.value = 11;
67
+ }) : G.value--;
68
+ }, fe = () => {
69
+ G.value === 11 ? r(() => {
70
+ W.value++, G.value = 0;
71
+ }) : G.value++;
72
+ }, Z = ne(I), pe = re(W.value, G.value, Z), me = new Intl.DateTimeFormat(I, { weekday: "short" }), he = Array.from({ length: 7 }, (e, t) => {
70
73
  let n = new Date(Date.UTC(2024, 0, 7 + Z + t));
71
- return ue.format(n);
72
- }), Q = new Intl.DateTimeFormat(F, {
74
+ return me.format(n);
75
+ }), Q = new Intl.DateTimeFormat(I, {
73
76
  month: "long",
74
77
  year: "numeric"
75
- }).format(new Date(Date.UTC(U.value, W.value, 1))), fe = (e) => {
76
- let t = G.value;
78
+ }).format(new Date(Date.UTC(W.value, G.value, 1))), ge = (e) => {
79
+ let t = K.value;
77
80
  if (!t) return;
78
- let n = y(t), i;
81
+ let n = _(t), i;
79
82
  if (e.key === "ArrowRight") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() + 1));
80
83
  else if (e.key === "ArrowLeft") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() - 1));
81
84
  else if (e.key === "ArrowDown") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() + 7));
@@ -88,103 +91,105 @@ function b({ value: a, defaultValue: b, onValueChange: ne, onChange: x, min: S,
88
91
  return;
89
92
  } else return;
90
93
  if (e.preventDefault(), i) {
91
- let e = v(i);
92
- if (S && e < S || C && e > C) return;
93
- G.value = e, r(() => {
94
- U.value = i.getUTCFullYear(), W.value = i.getUTCMonth();
94
+ let e = g(i);
95
+ if (b && e < b || x && e > x) return;
96
+ K.value = e, r(() => {
97
+ W.value = i.getUTCFullYear(), G.value = i.getUTCMonth();
95
98
  });
96
99
  }
97
- }, $ = H.value ? _(y(H.value), F) : "";
98
- return /* @__PURE__ */ m("div", {
99
- ref: K,
100
- className: i(e.wrapper, ie),
101
- "data-state": D ? "error" : A.value,
102
- "data-size": re,
100
+ }, $ = U.value ? h(_(U.value), I) : "";
101
+ return /* @__PURE__ */ p("div", {
102
+ ref: q,
103
+ className: i(e.wrapper, O),
104
+ "data-state": w ? "error" : j.value,
105
+ "data-size": T,
103
106
  children: [
104
- T && /* @__PURE__ */ p("label", {
107
+ S && /* @__PURE__ */ f("label", {
105
108
  className: e.label,
106
- htmlFor: N,
107
- children: T
109
+ htmlFor: P,
110
+ children: S
108
111
  }),
109
- /* @__PURE__ */ m("div", {
112
+ /* @__PURE__ */ p("div", {
110
113
  className: e.field,
111
- children: [/* @__PURE__ */ m("button", {
112
- id: N,
114
+ children: [/* @__PURE__ */ p("button", {
115
+ id: P,
113
116
  type: "button",
114
117
  role: "combobox",
115
- "aria-expanded": A.value === "open",
116
- "aria-controls": P,
118
+ "aria-expanded": j.value === "open",
119
+ "aria-controls": F,
117
120
  "aria-haspopup": "dialog",
118
- "aria-invalid": D ? !0 : void 0,
119
- "aria-describedby": D ? `${M}-error` : E ? `${M}-hint` : void 0,
121
+ "aria-labelledby": A,
122
+ "aria-label": oe,
123
+ "aria-invalid": w ? !0 : ce,
124
+ "aria-describedby": ie(w ? `${N}-error` : C ? `${N}-hint` : void 0, se),
120
125
  className: e.trigger,
121
- disabled: O,
122
- onClick: A.value === "open" ? J : q,
123
- children: [/* @__PURE__ */ p("span", {
126
+ disabled: E,
127
+ onClick: j.value === "open" ? J : le,
128
+ children: [/* @__PURE__ */ f("span", {
124
129
  className: i(e.value, $ ? void 0 : e.placeholder),
125
- children: $ || I
126
- }), /* @__PURE__ */ p("span", {
130
+ children: $ || L
131
+ }), /* @__PURE__ */ f("span", {
127
132
  className: e.icon,
128
133
  "aria-hidden": "true",
129
134
  children: "📅"
130
135
  })]
131
- }), w && H.value !== void 0 && /* @__PURE__ */ p("button", {
136
+ }), ae && U.value !== void 0 && /* @__PURE__ */ f("button", {
132
137
  type: "button",
133
138
  className: e.clear,
134
- "aria-label": z,
135
- onClick: oe,
139
+ "aria-label": B,
140
+ onClick: ue,
136
141
  children: "✕"
137
142
  })]
138
143
  }),
139
- /* @__PURE__ */ m("div", {
140
- id: P,
144
+ /* @__PURE__ */ p("div", {
145
+ id: F,
141
146
  role: "dialog",
142
147
  "aria-label": Q,
143
148
  className: e.calendar,
144
- "data-state": A.value,
145
- onKeyDown: fe,
146
- children: [/* @__PURE__ */ m("div", {
149
+ "data-state": j.value,
150
+ onKeyDown: ge,
151
+ children: [/* @__PURE__ */ p("div", {
147
152
  className: e.header,
148
153
  children: [
149
- /* @__PURE__ */ p("button", {
154
+ /* @__PURE__ */ f("button", {
150
155
  type: "button",
151
156
  className: e.navButton,
152
- "aria-label": L,
153
- onClick: se,
157
+ "aria-label": R,
158
+ onClick: de,
154
159
  children: "‹"
155
160
  }),
156
- /* @__PURE__ */ p("span", {
161
+ /* @__PURE__ */ f("span", {
157
162
  className: e.monthLabel,
158
163
  "aria-live": "polite",
159
164
  children: Q
160
165
  }),
161
- /* @__PURE__ */ p("button", {
166
+ /* @__PURE__ */ f("button", {
162
167
  type: "button",
163
168
  className: e.navButton,
164
- "aria-label": R,
165
- onClick: ce,
169
+ "aria-label": z,
170
+ onClick: fe,
166
171
  children: "›"
167
172
  })
168
173
  ]
169
- }), /* @__PURE__ */ m("table", {
174
+ }), /* @__PURE__ */ p("table", {
170
175
  role: "grid",
171
176
  className: e.grid,
172
- children: [/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { children: de.map((t) => /* @__PURE__ */ p("th", {
177
+ children: [/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ f("tr", { children: he.map((t) => /* @__PURE__ */ f("th", {
173
178
  className: e.weekday,
174
179
  abbr: t,
175
180
  scope: "col",
176
181
  children: t
177
- }, t)) }) }), /* @__PURE__ */ p("tbody", { children: le.map((t, n) => /* @__PURE__ */ p("tr", { children: t.map((t, n) => {
178
- if (!t) return /* @__PURE__ */ p("td", { className: e.empty }, n);
179
- let r = v(t), i = r === H.value, a = r === V, o = r === G.value, s = S !== void 0 && r < S || C !== void 0 && r > C;
180
- return /* @__PURE__ */ p("td", {
182
+ }, t)) }) }), /* @__PURE__ */ f("tbody", { children: pe.map((t, n) => /* @__PURE__ */ f("tr", { children: t.map((t, n) => {
183
+ if (!t) return /* @__PURE__ */ f("td", { className: e.empty }, n);
184
+ let r = g(t), i = r === U.value, a = r === H, o = r === K.value, s = b !== void 0 && r < b || x !== void 0 && r > x;
185
+ return /* @__PURE__ */ f("td", {
181
186
  className: e.cell,
182
- children: /* @__PURE__ */ p("button", {
187
+ children: /* @__PURE__ */ f("button", {
183
188
  type: "button",
184
189
  className: e.day,
185
190
  tabIndex: o ? 0 : -1,
186
191
  "aria-pressed": i,
187
- "aria-label": _(t, F),
192
+ "aria-label": h(t, I),
188
193
  "aria-current": a ? "date" : void 0,
189
194
  "aria-disabled": s || void 0,
190
195
  "data-selected": i || void 0,
@@ -193,7 +198,7 @@ function b({ value: a, defaultValue: b, onValueChange: ne, onChange: x, min: S,
193
198
  s || X(r);
194
199
  },
195
200
  onFocus: () => {
196
- G.value = r;
201
+ K.value = r;
197
202
  },
198
203
  children: t.getUTCDate()
199
204
  })
@@ -201,19 +206,19 @@ function b({ value: a, defaultValue: b, onValueChange: ne, onChange: x, min: S,
201
206
  }) }, n)) })]
202
207
  })]
203
208
  }),
204
- D && /* @__PURE__ */ p("span", {
205
- id: `${M}-error`,
209
+ w && /* @__PURE__ */ f("span", {
210
+ id: `${N}-error`,
206
211
  className: e.error,
207
212
  role: "alert",
208
- children: D
213
+ children: w
209
214
  }),
210
- !D && E && /* @__PURE__ */ p("span", {
211
- id: `${M}-hint`,
215
+ !w && C && /* @__PURE__ */ f("span", {
216
+ id: `${N}-hint`,
212
217
  className: e.hint,
213
- children: E
218
+ children: C
214
219
  })
215
220
  ]
216
221
  });
217
222
  }
218
223
  //#endregion
219
- export { b as DatePicker };
224
+ export { v as DatePicker };
@@ -137,7 +137,7 @@ function g({ value: g, defaultValue: _, onValueChange: v, min: y, max: b, disabl
137
137
  className: t.preset,
138
138
  onClick: () => W(e),
139
139
  children: e.label
140
- }, e.label))
140
+ }, e.id ?? e.label))
141
141
  }),
142
142
  /* @__PURE__ */ f("div", {
143
143
  className: t.calendars,
package/dist/dock/dock.js CHANGED
@@ -5,9 +5,9 @@ import { getLinkComponent as t, useSignals as n } from "@cascivo/core";
5
5
  import { builtin as r, t as i } from "@cascivo/i18n";
6
6
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
7
  //#region ../components/src/dock/dock.tsx
8
- function s({ items: s, activeIndex: c, className: l, ariaLabel: u }) {
8
+ function s({ items: s, activeIndex: c, className: l, ariaLabel: u, label: d }) {
9
9
  return n(), /* @__PURE__ */ a("nav", {
10
- "aria-label": u ?? i(r.dock.nav),
10
+ "aria-label": u ?? d ?? i(r.dock.nav),
11
11
  className: [e.dock, l].filter(Boolean).join(" "),
12
12
  children: s.map((n, r) => {
13
13
  let i = r === c;
@@ -12,96 +12,99 @@ var p = i({
12
12
  open: { on: { CLOSE: "closed" } }
13
13
  }
14
14
  });
15
- function m({ trigger: i, items: m, onSelect: h, placement: g = "bottom-start", open: _, onOpenChange: v }) {
15
+ function m(e) {
16
+ return !("kind" in e);
17
+ }
18
+ function h({ trigger: i, items: h, onSelect: g, placement: _ = "bottom-start", open: v, onOpenChange: y }) {
16
19
  u();
17
- let [y, b] = s(p), x = n(null), S = n(null), C = n(null), w = n([]), T = c(-1), E = _ !== void 0, D = E ? _ : y.value === "open", O = o(D), k = m.map((e, t) => ({
20
+ let [b, x] = s(p), S = n(null), C = n(null), w = n(null), T = n([]), E = c(-1), D = v !== void 0, O = D ? v : b.value === "open", k = o(O), A = h.map((e, t) => ({
18
21
  item: e,
19
22
  index: t
20
- })).filter(({ item: e }) => !e.separator && !e.disabled).map(({ index: e }) => e), A = (e) => {
21
- E || b(e ? "OPEN" : "CLOSE"), v?.(e);
23
+ })).filter(({ item: e }) => m(e) && !e.disabled).map(({ index: e }) => e), j = (e) => {
24
+ D || x(e ? "OPEN" : "CLOSE"), y?.(e);
22
25
  };
23
26
  l(() => {
24
- let e = T.value;
25
- O.value && e >= 0 && w.current[e]?.focus();
27
+ let e = E.value;
28
+ k.value && e >= 0 && T.current[e]?.focus();
26
29
  }), l(() => {
27
- O.value ? T.value = k[0] ?? -1 : T.value = -1;
30
+ k.value ? E.value = A[0] ?? -1 : E.value = -1;
28
31
  }), l(() => {
29
- O.value ? C.current?.showPopover() : C.current?.hidePopover();
32
+ k.value ? w.current?.showPopover() : w.current?.hidePopover();
30
33
  }), l(() => {
31
- let e = C.current;
34
+ let e = w.current;
32
35
  if (!e) return;
33
36
  let t = (e) => {
34
- e.newState === "closed" && A(!1);
37
+ e.newState === "closed" && j(!1);
35
38
  };
36
39
  return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
37
40
  });
38
- let j = (e) => {
39
- let t = m[e];
40
- !t || t.separator || t.disabled || (h?.(t.value), A(!1), a(S.current));
41
- }, M = (e) => {
42
- k.length !== 0 && (T.value = k[(k.indexOf(T.value) + e + k.length) % k.length] ?? -1);
41
+ let M = (e) => {
42
+ let t = h[e];
43
+ !t || !m(t) || t.disabled || (g?.(t.value), j(!1), a(C.current));
43
44
  }, N = (e) => {
45
+ A.length !== 0 && (E.value = A[(A.indexOf(E.value) + e + A.length) % A.length] ?? -1);
46
+ }, P = (e) => {
44
47
  switch (e.key) {
45
48
  case "ArrowDown":
46
- e.preventDefault(), M(1);
49
+ e.preventDefault(), N(1);
47
50
  break;
48
51
  case "ArrowUp":
49
- e.preventDefault(), M(-1);
52
+ e.preventDefault(), N(-1);
50
53
  break;
51
54
  case "Home":
52
- e.preventDefault(), T.value = k[0] ?? -1;
55
+ e.preventDefault(), E.value = A[0] ?? -1;
53
56
  break;
54
57
  case "End":
55
- e.preventDefault(), T.value = k[k.length - 1] ?? -1;
58
+ e.preventDefault(), E.value = A[A.length - 1] ?? -1;
56
59
  break;
57
60
  case "Escape":
58
- e.preventDefault(), A(!1), a(S.current);
61
+ e.preventDefault(), j(!1), a(C.current);
59
62
  break;
60
63
  case "Enter":
61
64
  case " ":
62
- e.preventDefault(), j(T.value);
65
+ e.preventDefault(), M(E.value);
63
66
  break;
64
67
  }
65
- }, P = i, F = t(P, {
66
- ref: r(S, P.props.ref),
68
+ }, F = i, I = t(F, {
69
+ ref: r(C, F.props.ref),
67
70
  onClick: (e) => {
68
- P.props.onClick?.(e), A(!D);
71
+ F.props.onClick?.(e), j(!O);
69
72
  },
70
73
  "aria-haspopup": "menu",
71
- "aria-expanded": D
74
+ "aria-expanded": O
72
75
  });
73
76
  return /* @__PURE__ */ f("div", {
74
- ref: x,
77
+ ref: S,
75
78
  className: e.root,
76
- children: [F, /* @__PURE__ */ d("div", {
77
- ref: C,
79
+ children: [I, /* @__PURE__ */ d("div", {
80
+ ref: w,
78
81
  popover: "auto",
79
82
  role: "menu",
80
- "data-placement": g,
81
- "data-state": D ? "open" : "closed",
83
+ "data-placement": _,
84
+ "data-state": O ? "open" : "closed",
82
85
  className: e.menu,
83
- onKeyDown: N,
84
- children: m.map((t, n) => t.separator ? /* @__PURE__ */ d("div", {
85
- role: "separator",
86
- className: e.separator
87
- }, `sep-${n}`) : /* @__PURE__ */ f("button", {
86
+ onKeyDown: P,
87
+ children: h.map((t, n) => m(t) ? /* @__PURE__ */ f("button", {
88
88
  type: "button",
89
89
  role: "menuitem",
90
90
  ref: (e) => {
91
- w.current[n] = e;
91
+ T.current[n] = e;
92
92
  },
93
- tabIndex: T.value === n ? 0 : -1,
93
+ tabIndex: E.value === n ? 0 : -1,
94
94
  disabled: t.disabled,
95
95
  className: e.item,
96
- onClick: () => j(n),
96
+ onClick: () => M(n),
97
97
  children: [t.icon && /* @__PURE__ */ d("span", {
98
98
  className: e.icon,
99
99
  "aria-hidden": "true",
100
100
  children: t.icon
101
101
  }), t.label]
102
- }, t.value))
102
+ }, t.value) : /* @__PURE__ */ d("div", {
103
+ role: "separator",
104
+ className: e.separator
105
+ }, `sep-${n}`))
103
106
  })]
104
107
  });
105
108
  }
106
109
  //#endregion
107
- export { m as Dropdown };
110
+ export { h as Dropdown };
@@ -5,50 +5,59 @@ import { useRef as t } from "react";
5
5
  import { cn as n, useSignal as r, useSignalEffect as i, useSignals as a } from "@cascivo/core";
6
6
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
7
  //#region ../components/src/editable/editable.tsx
8
- function c({ value: c, onValueChange: l, placeholder: u, disabled: d = !1, submitOnBlur: f = !0, onCancel: p, className: m, ...h }) {
8
+ function c({ value: c, onValueChange: l, placeholder: u, disabled: d = !1, submitOnBlur: f = !0, onCancel: p, className: m, id: h, "aria-labelledby": g, "aria-describedby": _, "aria-invalid": v, ...y }) {
9
9
  a();
10
- let g = r(!1), _ = r(c), v = t(null), y = t(p);
11
- y.current = p;
12
- let b = t(l);
13
- b.current = l, g.value || (_.value = c), i(() => {
14
- if (g.value) {
15
- let e = v.current;
10
+ let b = r(!1), x = r(c), S = t(null), C = t(p);
11
+ C.current = p;
12
+ let w = t(l);
13
+ w.current = l;
14
+ let T = {
15
+ id: h,
16
+ "aria-labelledby": g,
17
+ "aria-describedby": _,
18
+ "aria-invalid": v
19
+ };
20
+ b.value || (x.value = c), i(() => {
21
+ if (b.value) {
22
+ let e = S.current;
16
23
  e && (e.focus(), e.select());
17
24
  }
18
25
  });
19
- function x() {
20
- b.current(_.value), g.value = !1;
26
+ function E() {
27
+ w.current(x.value), b.value = !1;
21
28
  }
22
- function S() {
23
- _.value = c, g.value = !1, y.current?.();
29
+ function D() {
30
+ x.value = c, b.value = !1, C.current?.();
24
31
  }
25
- return g.value ? /* @__PURE__ */ o("div", {
32
+ return b.value ? /* @__PURE__ */ o("div", {
26
33
  className: n(e.wrapper, e.editing, m),
27
- ...h,
34
+ ...y,
28
35
  children: /* @__PURE__ */ o("input", {
29
- ref: v,
36
+ ref: S,
30
37
  className: e.input,
31
- value: _.value,
38
+ ...T,
39
+ value: x.value,
32
40
  onChange: (e) => {
33
- _.value = e.currentTarget.value;
41
+ x.value = e.currentTarget.value;
34
42
  },
35
43
  onKeyDown: (e) => {
36
- e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && (e.preventDefault(), S());
44
+ e.key === "Enter" ? (e.preventDefault(), E()) : e.key === "Escape" && (e.preventDefault(), D());
37
45
  },
38
46
  onBlur: () => {
39
- f ? x() : S();
47
+ f ? E() : D();
40
48
  }
41
49
  })
42
50
  }) : /* @__PURE__ */ o("div", {
43
51
  className: n(e.wrapper, m),
44
52
  "data-disabled": d ? "" : void 0,
45
- ...h,
53
+ ...y,
46
54
  children: /* @__PURE__ */ s("button", {
47
55
  type: "button",
48
56
  className: e.preview,
57
+ ...T,
49
58
  disabled: d,
50
59
  onClick: () => {
51
- d || (g.value = !0);
60
+ d || (b.value = !0);
52
61
  },
53
62
  children: [/* @__PURE__ */ o("span", {
54
63
  className: e["preview-text"],