@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,164 +2,169 @@
2
2
 
3
3
  import e from "./combobox.module.js";
4
4
  import { useId as t, useRef as n } from "react";
5
- import { cn as r, createMachine as i, focusElement as a, useControllableSignal as o, useMachine as s, useSignal as c, useSignalEffect as l, useSignals as u } from "@cascivo/core";
6
- import { builtin as d, t as f } from "@cascivo/i18n";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
5
+ import { cn as r, createMachine as i, focusElement as ee, useControllableSignal as a, useMachine as o, useSignal as s, useSignalEffect as c, useSignals as te } from "@cascivo/core";
6
+ import { builtin as l, t as u } from "@cascivo/i18n";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
8
  //#region ../components/src/combobox/combobox.tsx
9
- var h = i({
9
+ var p = i({
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({ options: i, value: g, defaultValue: _, onValueChange: v, onChange: y, clearable: b = !1, searchable: x = !0, label: S, hint: C, error: w, size: T = "md", disabled: E = !1, labels: D, className: O, id: k }) {
17
- u();
18
- let [A, j] = s(h), M = t(), N = k ?? `cascade-combobox-${M}`, P = `${M}-listbox`, F = n(null), ee = D?.placeholder ?? f(d.combobox.placeholder), I = D?.empty ?? f(d.combobox.empty), L = D?.clear ?? f(d.combobox.clear), R = D?.search ?? f(d.combobox.search), [z] = o({
19
- value: g,
20
- defaultValue: _
21
- }), B = c(""), V = c(0), H = A.value === "open", U = i.filter((e) => !x || !B.value ? !0 : e.label.toLowerCase().includes(B.value.toLowerCase())), W = i.find((e) => e.value === z.value);
22
- l(() => {
23
- if (!H) return;
16
+ function m(...e) {
17
+ return e.filter(Boolean).join(" ") || void 0;
18
+ }
19
+ function h({ options: i, value: h, defaultValue: g, onValueChange: ne, clearable: _ = !1, searchable: v = !0, label: y, ariaLabel: b, hint: x, error: S, size: re = "md", disabled: C = !1, labels: w, className: T, id: E, "aria-labelledby": D, "aria-describedby": O, "aria-invalid": k }) {
20
+ te();
21
+ let [A, j] = o(p), M = t(), N = E ?? `cascade-combobox-${M}`, P = `${M}-listbox`, F = n(null), I = w?.placeholder ?? u(l.combobox.placeholder), L = w?.empty ?? u(l.combobox.empty), R = w?.clear ?? u(l.combobox.clear), z = w?.search ?? u(l.combobox.search), [B] = a({
22
+ value: h,
23
+ defaultValue: g
24
+ }), V = s(""), H = s(0), U = A.value === "open", W = i.filter((e) => !v || !V.value ? !0 : e.label.toLowerCase().includes(V.value.toLowerCase())), G = i.find((e) => e.value === B.value);
25
+ c(() => {
26
+ if (!U) return;
24
27
  let e = (e) => {
25
28
  let t = document.getElementById(`${M}-root`);
26
29
  t && !t.contains(e.target) && j("CLOSE");
27
30
  };
28
31
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
29
32
  });
30
- let G = () => {
31
- E || (B.value = "", V.value = 0, j("OPEN"), setTimeout(() => a(F.current), 0));
32
- }, K = () => {
33
- j("CLOSE"), B.value = "";
34
- }, q = v ?? y, J = (e) => {
35
- g === void 0 && (z.value = e), q?.(e), K();
36
- }, Y = () => {
37
- g === void 0 && (z.value = void 0), q?.(void 0);
38
- }, X = U.flatMap((e, t) => e.disabled ? [] : [t]), Z = (e) => {
39
- if (X.length === 0) return;
40
- let t = X[(X.indexOf(V.value) + e + X.length) % X.length];
41
- t !== void 0 && (V.value = t);
42
- }, Q = (e) => {
43
- (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), G());
44
- }, te = (e) => {
33
+ let K = () => {
34
+ C || (V.value = "", H.value = 0, j("OPEN"), setTimeout(() => ee(F.current), 0));
35
+ }, q = () => {
36
+ j("CLOSE"), V.value = "";
37
+ }, J = ne, Y = (e) => {
38
+ h === void 0 && (B.value = e), J?.(e), q();
39
+ }, X = () => {
40
+ h === void 0 && (B.value = void 0), J?.(void 0);
41
+ }, Z = W.flatMap((e, t) => e.disabled ? [] : [t]), Q = (e) => {
42
+ if (Z.length === 0) return;
43
+ let t = Z[(Z.indexOf(H.value) + e + Z.length) % Z.length];
44
+ t !== void 0 && (H.value = t);
45
+ }, ie = (e) => {
46
+ (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), K());
47
+ }, ae = (e) => {
45
48
  switch (e.key) {
46
49
  case "ArrowDown":
47
- e.preventDefault(), Z(1);
50
+ e.preventDefault(), Q(1);
48
51
  break;
49
52
  case "ArrowUp":
50
- e.preventDefault(), Z(-1);
53
+ e.preventDefault(), Q(-1);
51
54
  break;
52
55
  case "Enter": {
53
56
  e.preventDefault();
54
- let t = U[V.value];
55
- t && !t.disabled && J(t.value);
57
+ let t = W[H.value];
58
+ t && !t.disabled && Y(t.value);
56
59
  break;
57
60
  }
58
61
  case "Escape":
59
- e.preventDefault(), K();
62
+ e.preventDefault(), q();
60
63
  break;
61
64
  case "Tab":
62
- K();
65
+ q();
63
66
  break;
64
67
  }
65
68
  }, $ = (e) => `${M}-option-${e}`;
66
- return /* @__PURE__ */ m("div", {
69
+ return /* @__PURE__ */ f("div", {
67
70
  id: `${M}-root`,
68
- className: r(e.wrapper, O),
69
- "data-state": w ? "error" : A.value,
70
- "data-size": T,
71
+ className: r(e.wrapper, T),
72
+ "data-state": S ? "error" : A.value,
73
+ "data-size": re,
71
74
  children: [
72
- S && /* @__PURE__ */ p("label", {
75
+ y && /* @__PURE__ */ d("label", {
73
76
  className: e.label,
74
77
  htmlFor: N,
75
- children: S
78
+ children: y
76
79
  }),
77
- /* @__PURE__ */ m("div", {
80
+ /* @__PURE__ */ f("div", {
78
81
  className: e.field,
79
- children: [/* @__PURE__ */ m("button", {
82
+ children: [/* @__PURE__ */ f("button", {
80
83
  id: N,
81
84
  type: "button",
82
85
  role: "combobox",
83
- "aria-expanded": H,
86
+ "aria-expanded": U,
84
87
  "aria-controls": P,
85
88
  "aria-haspopup": "listbox",
86
- "aria-activedescendant": H && V.value >= 0 ? $(V.value) : void 0,
87
- "aria-invalid": w ? !0 : void 0,
88
- "aria-describedby": w ? `${M}-error` : C ? `${M}-hint` : void 0,
89
+ "aria-labelledby": D,
90
+ "aria-label": b,
91
+ "aria-activedescendant": U && H.value >= 0 ? $(H.value) : void 0,
92
+ "aria-invalid": S ? !0 : k,
93
+ "aria-describedby": m(S ? `${M}-error` : x ? `${M}-hint` : void 0, O),
89
94
  className: e.trigger,
90
- disabled: E,
91
- onKeyDown: Q,
92
- onClick: H ? K : G,
93
- children: [/* @__PURE__ */ p("span", {
94
- className: r(e.value, W ? void 0 : e.placeholder),
95
- children: W?.label ?? ee
96
- }), /* @__PURE__ */ p("span", {
95
+ disabled: C,
96
+ onKeyDown: ie,
97
+ onClick: U ? q : K,
98
+ children: [/* @__PURE__ */ d("span", {
99
+ className: r(e.value, G ? void 0 : e.placeholder),
100
+ children: G?.label ?? I
101
+ }), /* @__PURE__ */ d("span", {
97
102
  className: e.chevron,
98
103
  "aria-hidden": "true"
99
104
  })]
100
- }), b && z.value !== void 0 && /* @__PURE__ */ p("button", {
105
+ }), _ && B.value !== void 0 && /* @__PURE__ */ d("button", {
101
106
  type: "button",
102
107
  className: e.clear,
103
- "aria-label": L,
108
+ "aria-label": R,
104
109
  onClick: (e) => {
105
- e.stopPropagation(), Y();
110
+ e.stopPropagation(), X();
106
111
  },
107
112
  children: "✕"
108
113
  })]
109
114
  }),
110
- /* @__PURE__ */ m("div", {
115
+ /* @__PURE__ */ f("div", {
111
116
  role: "listbox",
112
117
  id: P,
113
118
  className: e.listbox,
114
- "data-state": H ? "open" : "closed",
115
- "aria-label": S,
116
- children: [x && H && /* @__PURE__ */ p("div", {
119
+ "data-state": U ? "open" : "closed",
120
+ "aria-label": y,
121
+ children: [v && U && /* @__PURE__ */ d("div", {
117
122
  className: e.searchWrapper,
118
- children: /* @__PURE__ */ p("input", {
123
+ children: /* @__PURE__ */ d("input", {
119
124
  ref: F,
120
125
  type: "text",
121
126
  className: e.search,
122
- value: B.value,
127
+ value: V.value,
123
128
  onChange: (e) => {
124
- B.value = e.target.value, V.value = 0;
129
+ V.value = e.target.value, H.value = 0;
125
130
  },
126
- onKeyDown: te,
127
- "aria-label": R,
131
+ onKeyDown: ae,
132
+ "aria-label": z,
128
133
  autoComplete: "off"
129
134
  })
130
- }), U.length === 0 ? /* @__PURE__ */ p("div", {
135
+ }), W.length === 0 ? /* @__PURE__ */ d("div", {
131
136
  className: e.empty,
132
- children: I
133
- }) : U.map((t, n) => /* @__PURE__ */ p("div", {
137
+ children: L
138
+ }) : W.map((t, n) => /* @__PURE__ */ d("div", {
134
139
  id: $(n),
135
140
  role: "option",
136
- "aria-selected": t.value === z.value,
141
+ "aria-selected": t.value === B.value,
137
142
  "aria-disabled": t.disabled || void 0,
138
- "data-state": n === V.value ? "active" : void 0,
143
+ "data-state": n === H.value ? "active" : void 0,
139
144
  "data-disabled": t.disabled || void 0,
140
145
  className: e.option,
141
146
  onMouseEnter: () => {
142
- t.disabled || (V.value = n);
147
+ t.disabled || (H.value = n);
143
148
  },
144
149
  onClick: () => {
145
- t.disabled || J(t.value);
150
+ t.disabled || Y(t.value);
146
151
  },
147
152
  children: t.label
148
153
  }, t.value))]
149
154
  }),
150
- w && /* @__PURE__ */ p("span", {
155
+ S && /* @__PURE__ */ d("span", {
151
156
  id: `${M}-error`,
152
157
  className: e.error,
153
158
  role: "alert",
154
- children: w
159
+ children: S
155
160
  }),
156
- !w && C && /* @__PURE__ */ p("span", {
161
+ !S && x && /* @__PURE__ */ d("span", {
157
162
  id: `${M}-hint`,
158
163
  className: e.hint,
159
- children: C
164
+ children: x
160
165
  })
161
166
  ]
162
167
  });
163
168
  }
164
169
  //#endregion
165
- export { g as Combobox };
170
+ export { h as Combobox };