@cascivo/react 0.13.0 → 0.13.1

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 (160) hide show
  1. package/dist/accordion/accordion.js +46 -44
  2. package/dist/action-sheet/action-sheet.js +16 -16
  3. package/dist/alert-dialog/alert-dialog.js +34 -34
  4. package/dist/app-shell/app-shell.css +1 -1
  5. package/dist/app-shell/app-shell.js +14 -12
  6. package/dist/app-shell/app-shell.module.js +8 -8
  7. package/dist/avatar-group/avatar-group.js +6 -6
  8. package/dist/bottom-sheet/bottom-sheet.js +18 -18
  9. package/dist/button/button.js +15 -12
  10. package/dist/button-group/button-group.js +8 -8
  11. package/dist/carousel/carousel.js +20 -20
  12. package/dist/checkbox/checkbox.js +21 -21
  13. package/dist/checkbox-card/checkbox-card.js +15 -13
  14. package/dist/collapsible/collapsible.js +7 -7
  15. package/dist/color-picker/color-picker.js +26 -26
  16. package/dist/combobox/combobox.js +86 -86
  17. package/dist/command-menu/command-menu.js +111 -111
  18. package/dist/comparison/comparison.js +10 -10
  19. package/dist/context-menu/context-menu.js +9 -9
  20. package/dist/copy-button/copy-button.js +18 -16
  21. package/dist/data-table/data-table.js +1 -1
  22. package/dist/date-picker/date-picker.js +25 -25
  23. package/dist/date-range-picker/date-range-picker.js +26 -26
  24. package/dist/drawer/drawer.css +1 -1
  25. package/dist/drawer/drawer.js +18 -17
  26. package/dist/drawer/drawer.module.js +9 -9
  27. package/dist/dropdown/dropdown.js +48 -48
  28. package/dist/editable/editable.js +11 -11
  29. package/dist/fab/fab.js +53 -53
  30. package/dist/field/field.js +8 -8
  31. package/dist/file-uploader/file-uploader.js +19 -19
  32. package/dist/header-panel/header-panel.js +31 -31
  33. package/dist/hover-card/hover-card.js +21 -21
  34. package/dist/icon-button/icon-button.js +5 -5
  35. package/dist/index.d.ts +202 -194
  36. package/dist/input/input.js +22 -21
  37. package/dist/link/link.js +8 -6
  38. package/dist/log-viewer/log-viewer.js +26 -26
  39. package/dist/menu/menu.js +20 -20
  40. package/dist/menu-button/menu-button.js +48 -48
  41. package/dist/menubar/menubar.js +42 -42
  42. package/dist/modal/modal.css +1 -1
  43. package/dist/modal/modal.js +41 -35
  44. package/dist/modal/modal.module.js +8 -7
  45. package/dist/multi-select/multi-select.css +1 -1
  46. package/dist/multi-select/multi-select.js +57 -57
  47. package/dist/multi-select/multi-select.module.js +11 -11
  48. package/dist/native-select/native-select.js +13 -11
  49. package/dist/navigation-menu/navigation-menu.js +46 -46
  50. package/dist/node/accordion/accordion.js +46 -44
  51. package/dist/node/action-sheet/action-sheet.js +16 -16
  52. package/dist/node/alert-dialog/alert-dialog.js +34 -34
  53. package/dist/node/app-shell/app-shell.js +14 -12
  54. package/dist/node/app-shell/app-shell.module.js +8 -8
  55. package/dist/node/avatar-group/avatar-group.js +6 -6
  56. package/dist/node/bottom-sheet/bottom-sheet.js +18 -18
  57. package/dist/node/button/button.js +15 -12
  58. package/dist/node/button-group/button-group.js +8 -8
  59. package/dist/node/carousel/carousel.js +20 -20
  60. package/dist/node/checkbox/checkbox.js +21 -21
  61. package/dist/node/checkbox-card/checkbox-card.js +15 -13
  62. package/dist/node/collapsible/collapsible.js +7 -7
  63. package/dist/node/color-picker/color-picker.js +26 -26
  64. package/dist/node/combobox/combobox.js +86 -86
  65. package/dist/node/command-menu/command-menu.js +111 -111
  66. package/dist/node/comparison/comparison.js +10 -10
  67. package/dist/node/context-menu/context-menu.js +9 -9
  68. package/dist/node/copy-button/copy-button.js +18 -16
  69. package/dist/node/data-table/data-table.js +1 -1
  70. package/dist/node/date-picker/date-picker.js +25 -25
  71. package/dist/node/date-range-picker/date-range-picker.js +26 -26
  72. package/dist/node/drawer/drawer.js +18 -17
  73. package/dist/node/drawer/drawer.module.js +9 -9
  74. package/dist/node/dropdown/dropdown.js +48 -48
  75. package/dist/node/editable/editable.js +11 -11
  76. package/dist/node/fab/fab.js +53 -53
  77. package/dist/node/field/field.js +8 -8
  78. package/dist/node/file-uploader/file-uploader.js +19 -19
  79. package/dist/node/header-panel/header-panel.js +31 -31
  80. package/dist/node/hover-card/hover-card.js +21 -21
  81. package/dist/node/icon-button/icon-button.js +5 -5
  82. package/dist/node/input/input.js +22 -21
  83. package/dist/node/link/link.js +8 -6
  84. package/dist/node/log-viewer/log-viewer.js +26 -26
  85. package/dist/node/menu/menu.js +20 -20
  86. package/dist/node/menu-button/menu-button.js +48 -48
  87. package/dist/node/menubar/menubar.js +42 -42
  88. package/dist/node/modal/modal.js +41 -35
  89. package/dist/node/modal/modal.module.js +8 -7
  90. package/dist/node/multi-select/multi-select.js +57 -57
  91. package/dist/node/multi-select/multi-select.module.js +11 -11
  92. package/dist/node/native-select/native-select.js +13 -11
  93. package/dist/node/navigation-menu/navigation-menu.js +46 -46
  94. package/dist/node/notification/notification.js +26 -26
  95. package/dist/node/number-input/number-input.js +52 -50
  96. package/dist/node/otp-input/otp-input.js +8 -8
  97. package/dist/node/password-input/password-input.js +28 -27
  98. package/dist/node/popover/popover.js +26 -24
  99. package/dist/node/pull-to-refresh/pull-to-refresh.js +13 -13
  100. package/dist/node/radial-progress/radial-progress.js +5 -5
  101. package/dist/node/radio/radio.js +23 -22
  102. package/dist/node/radio-card/radio-card.js +27 -26
  103. package/dist/node/react/src/index.js +3 -3
  104. package/dist/node/react/src/theme.js +30 -19
  105. package/dist/node/resizable/resizable.js +11 -11
  106. package/dist/node/scroll-area/scroll-area.js +4 -4
  107. package/dist/node/search/search.js +49 -49
  108. package/dist/node/select/select.js +27 -26
  109. package/dist/node/sheet/sheet.js +11 -10
  110. package/dist/node/sheet/sheet.module.js +5 -5
  111. package/dist/node/side-nav/side-nav.js +91 -91
  112. package/dist/node/skip-nav/skip-nav.js +12 -12
  113. package/dist/node/slider/slider.js +13 -11
  114. package/dist/node/structured-list/structured-list.js +23 -23
  115. package/dist/node/tabs/tabs.js +49 -47
  116. package/dist/node/tags-input/tags-input.js +35 -35
  117. package/dist/node/textarea/textarea.js +22 -21
  118. package/dist/node/time-picker/time-picker.js +22 -21
  119. package/dist/node/toast/toast.js +15 -15
  120. package/dist/node/toc/toc.js +8 -8
  121. package/dist/node/toggle/toggle.js +15 -13
  122. package/dist/node/toggle-group/toggle-group.js +10 -10
  123. package/dist/node/toggletip/toggletip.js +9 -9
  124. package/dist/node/tooltip/tooltip.js +5 -5
  125. package/dist/node/tree-view/tree-view.js +32 -32
  126. package/dist/notification/notification.js +26 -26
  127. package/dist/number-input/number-input.js +52 -50
  128. package/dist/otp-input/otp-input.js +8 -8
  129. package/dist/password-input/password-input.js +28 -27
  130. package/dist/popover/popover.js +26 -24
  131. package/dist/pull-to-refresh/pull-to-refresh.js +13 -13
  132. package/dist/radial-progress/radial-progress.js +5 -5
  133. package/dist/radio/radio.js +23 -22
  134. package/dist/radio-card/radio-card.js +27 -26
  135. package/dist/react/src/index.js +3 -3
  136. package/dist/react/src/theme.js +30 -19
  137. package/dist/resizable/resizable.js +11 -11
  138. package/dist/scroll-area/scroll-area.js +4 -4
  139. package/dist/search/search.js +49 -49
  140. package/dist/select/select.js +27 -26
  141. package/dist/sheet/sheet.css +1 -1
  142. package/dist/sheet/sheet.js +11 -10
  143. package/dist/sheet/sheet.module.js +5 -5
  144. package/dist/side-nav/side-nav.js +91 -91
  145. package/dist/skip-nav/skip-nav.js +12 -12
  146. package/dist/slider/slider.js +13 -11
  147. package/dist/structured-list/structured-list.js +23 -23
  148. package/dist/styles.css +55 -5
  149. package/dist/tabs/tabs.js +49 -47
  150. package/dist/tags-input/tags-input.js +35 -35
  151. package/dist/textarea/textarea.js +22 -21
  152. package/dist/time-picker/time-picker.js +22 -21
  153. package/dist/toast/toast.js +15 -15
  154. package/dist/toc/toc.js +8 -8
  155. package/dist/toggle/toggle.js +15 -13
  156. package/dist/toggle-group/toggle-group.js +10 -10
  157. package/dist/toggletip/toggletip.js +9 -9
  158. package/dist/tooltip/tooltip.js +5 -5
  159. package/dist/tree-view/tree-view.js +32 -32
  160. package/package.json +10 -4
@@ -1,164 +1,164 @@
1
1
  "use client";
2
2
 
3
3
  import e from "./combobox.module.js";
4
- import { cn as t, createMachine as n, useMachine as r, useSignal as i, useSignalEffect as a, useSignals as o } from "@cascivo/core";
5
- import { builtin as s, t as c } from "@cascivo/i18n";
6
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
- import { useId as d, useRef as f } from "react";
4
+ import { cn as t, createMachine as n, focusElement as r, useMachine as i, useSignal as a, useSignalEffect as o, useSignals as s } from "@cascivo/core";
5
+ import { useId as c, useRef as l } from "react";
6
+ import { builtin 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/combobox/combobox.tsx
9
- var p = n({
9
+ var m = n({
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 m({ options: n, value: m, defaultValue: h, onValueChange: g, onChange: _, clearable: v = !1, searchable: y = !0, label: b, hint: x, error: S, size: C = "md", disabled: w = !1, labels: T, className: E, id: D }) {
17
- o();
18
- let [O, k] = r(p), A = d(), j = D ?? `cascade-combobox-${A}`, M = `${A}-listbox`, N = f(null), P = T?.placeholder ?? c(s.combobox.placeholder), F = T?.empty ?? c(s.combobox.empty), I = T?.clear ?? c(s.combobox.clear), L = T?.search ?? c(s.combobox.search), R = i(m ?? h);
19
- m !== void 0 && (R.value = m);
20
- let z = i(""), B = i(0), V = O.value === "open", H = n.filter((e) => !y || !z.value ? !0 : e.label.toLowerCase().includes(z.value.toLowerCase())), U = n.find((e) => e.value === R.value);
21
- a(() => {
22
- if (!V) return;
16
+ function h({ options: n, value: h, defaultValue: g, onValueChange: _, onChange: v, clearable: y = !1, searchable: b = !0, label: x, hint: S, error: C, size: w = "md", disabled: T = !1, labels: E, className: D, id: O }) {
17
+ s();
18
+ let [k, A] = i(m), j = c(), M = O ?? `cascade-combobox-${j}`, N = `${j}-listbox`, P = l(null), F = E?.placeholder ?? d(u.combobox.placeholder), I = E?.empty ?? d(u.combobox.empty), L = E?.clear ?? d(u.combobox.clear), R = E?.search ?? d(u.combobox.search), z = a(h ?? g);
19
+ h !== void 0 && (z.value = h);
20
+ let B = a(""), V = a(0), H = k.value === "open", U = n.filter((e) => !b || !B.value ? !0 : e.label.toLowerCase().includes(B.value.toLowerCase())), W = n.find((e) => e.value === z.value);
21
+ o(() => {
22
+ if (!H) return;
23
23
  let e = (e) => {
24
- let t = document.getElementById(`${A}-root`);
25
- t && !t.contains(e.target) && k("CLOSE");
24
+ let t = document.getElementById(`${j}-root`);
25
+ t && !t.contains(e.target) && A("CLOSE");
26
26
  };
27
27
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
28
28
  });
29
- let W = () => {
30
- w || (z.value = "", B.value = 0, k("OPEN"), setTimeout(() => N.current?.focus(), 0));
31
- }, G = () => {
32
- k("CLOSE"), z.value = "";
33
- }, K = g ?? _, q = (e) => {
34
- m === void 0 && (R.value = e), K?.(e), G();
35
- }, J = () => {
36
- m === void 0 && (R.value = void 0), K?.(void 0);
37
- }, Y = H.flatMap((e, t) => e.disabled ? [] : [t]), X = (e) => {
38
- if (Y.length === 0) return;
39
- let t = Y[(Y.indexOf(B.value) + e + Y.length) % Y.length];
40
- t !== void 0 && (B.value = t);
41
- }, Z = (e) => {
42
- (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), W());
29
+ let G = () => {
30
+ T || (B.value = "", V.value = 0, A("OPEN"), setTimeout(() => r(P.current), 0));
31
+ }, K = () => {
32
+ A("CLOSE"), B.value = "";
33
+ }, q = _ ?? v, J = (e) => {
34
+ h === void 0 && (z.value = e), q?.(e), K();
35
+ }, Y = () => {
36
+ h === void 0 && (z.value = void 0), q?.(void 0);
37
+ }, X = U.flatMap((e, t) => e.disabled ? [] : [t]), Z = (e) => {
38
+ if (X.length === 0) return;
39
+ let t = X[(X.indexOf(V.value) + e + X.length) % X.length];
40
+ t !== void 0 && (V.value = t);
43
41
  }, Q = (e) => {
42
+ (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), G());
43
+ }, ee = (e) => {
44
44
  switch (e.key) {
45
45
  case "ArrowDown":
46
- e.preventDefault(), X(1);
46
+ e.preventDefault(), Z(1);
47
47
  break;
48
48
  case "ArrowUp":
49
- e.preventDefault(), X(-1);
49
+ e.preventDefault(), Z(-1);
50
50
  break;
51
51
  case "Enter": {
52
52
  e.preventDefault();
53
- let t = H[B.value];
54
- t && !t.disabled && q(t.value);
53
+ let t = U[V.value];
54
+ t && !t.disabled && J(t.value);
55
55
  break;
56
56
  }
57
57
  case "Escape":
58
- e.preventDefault(), G();
58
+ e.preventDefault(), K();
59
59
  break;
60
60
  case "Tab":
61
- G();
61
+ K();
62
62
  break;
63
63
  }
64
- }, $ = (e) => `${A}-option-${e}`;
65
- return /* @__PURE__ */ u("div", {
66
- id: `${A}-root`,
67
- className: t(e.wrapper, E),
68
- "data-state": S ? "error" : O.value,
69
- "data-size": C,
64
+ }, $ = (e) => `${j}-option-${e}`;
65
+ return /* @__PURE__ */ p("div", {
66
+ id: `${j}-root`,
67
+ className: t(e.wrapper, D),
68
+ "data-state": C ? "error" : k.value,
69
+ "data-size": w,
70
70
  children: [
71
- b && /* @__PURE__ */ l("label", {
71
+ x && /* @__PURE__ */ f("label", {
72
72
  className: e.label,
73
- htmlFor: j,
74
- children: b
73
+ htmlFor: M,
74
+ children: x
75
75
  }),
76
- /* @__PURE__ */ u("div", {
76
+ /* @__PURE__ */ p("div", {
77
77
  className: e.field,
78
- children: [/* @__PURE__ */ u("button", {
79
- id: j,
78
+ children: [/* @__PURE__ */ p("button", {
79
+ id: M,
80
80
  type: "button",
81
81
  role: "combobox",
82
- "aria-expanded": V,
83
- "aria-controls": M,
82
+ "aria-expanded": H,
83
+ "aria-controls": N,
84
84
  "aria-haspopup": "listbox",
85
- "aria-activedescendant": V && B.value >= 0 ? $(B.value) : void 0,
86
- "aria-invalid": S ? !0 : void 0,
87
- "aria-describedby": S ? `${A}-error` : x ? `${A}-hint` : void 0,
85
+ "aria-activedescendant": H && V.value >= 0 ? $(V.value) : void 0,
86
+ "aria-invalid": C ? !0 : void 0,
87
+ "aria-describedby": C ? `${j}-error` : S ? `${j}-hint` : void 0,
88
88
  className: e.trigger,
89
- disabled: w,
90
- onKeyDown: Z,
91
- onClick: V ? G : W,
92
- children: [/* @__PURE__ */ l("span", {
93
- className: t(e.value, U ? void 0 : e.placeholder),
94
- children: U?.label ?? P
95
- }), /* @__PURE__ */ l("span", {
89
+ disabled: T,
90
+ onKeyDown: Q,
91
+ onClick: H ? K : G,
92
+ children: [/* @__PURE__ */ f("span", {
93
+ className: t(e.value, W ? void 0 : e.placeholder),
94
+ children: W?.label ?? F
95
+ }), /* @__PURE__ */ f("span", {
96
96
  className: e.chevron,
97
97
  "aria-hidden": "true"
98
98
  })]
99
- }), v && R.value !== void 0 && /* @__PURE__ */ l("button", {
99
+ }), y && z.value !== void 0 && /* @__PURE__ */ f("button", {
100
100
  type: "button",
101
101
  className: e.clear,
102
- "aria-label": I,
102
+ "aria-label": L,
103
103
  onClick: (e) => {
104
- e.stopPropagation(), J();
104
+ e.stopPropagation(), Y();
105
105
  },
106
106
  children: "✕"
107
107
  })]
108
108
  }),
109
- /* @__PURE__ */ u("div", {
109
+ /* @__PURE__ */ p("div", {
110
110
  role: "listbox",
111
- id: M,
111
+ id: N,
112
112
  className: e.listbox,
113
- "data-state": V ? "open" : "closed",
114
- "aria-label": b,
115
- children: [y && V && /* @__PURE__ */ l("div", {
113
+ "data-state": H ? "open" : "closed",
114
+ "aria-label": x,
115
+ children: [b && H && /* @__PURE__ */ f("div", {
116
116
  className: e.searchWrapper,
117
- children: /* @__PURE__ */ l("input", {
118
- ref: N,
117
+ children: /* @__PURE__ */ f("input", {
118
+ ref: P,
119
119
  type: "text",
120
120
  className: e.search,
121
- value: z.value,
121
+ value: B.value,
122
122
  onChange: (e) => {
123
- z.value = e.target.value, B.value = 0;
123
+ B.value = e.target.value, V.value = 0;
124
124
  },
125
- onKeyDown: Q,
126
- "aria-label": L,
125
+ onKeyDown: ee,
126
+ "aria-label": R,
127
127
  autoComplete: "off"
128
128
  })
129
- }), H.length === 0 ? /* @__PURE__ */ l("div", {
129
+ }), U.length === 0 ? /* @__PURE__ */ f("div", {
130
130
  className: e.empty,
131
- children: F
132
- }) : H.map((t, n) => /* @__PURE__ */ l("div", {
131
+ children: I
132
+ }) : U.map((t, n) => /* @__PURE__ */ f("div", {
133
133
  id: $(n),
134
134
  role: "option",
135
- "aria-selected": t.value === R.value,
135
+ "aria-selected": t.value === z.value,
136
136
  "aria-disabled": t.disabled || void 0,
137
- "data-state": n === B.value ? "active" : void 0,
137
+ "data-state": n === V.value ? "active" : void 0,
138
138
  "data-disabled": t.disabled || void 0,
139
139
  className: e.option,
140
140
  onMouseEnter: () => {
141
- t.disabled || (B.value = n);
141
+ t.disabled || (V.value = n);
142
142
  },
143
143
  onClick: () => {
144
- t.disabled || q(t.value);
144
+ t.disabled || J(t.value);
145
145
  },
146
146
  children: t.label
147
147
  }, t.value))]
148
148
  }),
149
- S && /* @__PURE__ */ l("span", {
150
- id: `${A}-error`,
149
+ C && /* @__PURE__ */ f("span", {
150
+ id: `${j}-error`,
151
151
  className: e.error,
152
152
  role: "alert",
153
- children: S
153
+ children: C
154
154
  }),
155
- !S && x && /* @__PURE__ */ l("span", {
156
- id: `${A}-hint`,
155
+ !C && S && /* @__PURE__ */ f("span", {
156
+ id: `${j}-hint`,
157
157
  className: e.hint,
158
- children: x
158
+ children: S
159
159
  })
160
160
  ]
161
161
  });
162
162
  }
163
163
  //#endregion
164
- export { m as Combobox };
164
+ export { h as Combobox };