@cascivo/react 0.16.1 → 0.17.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 (62) hide show
  1. package/README.md +14 -13
  2. package/dist/accordion/accordion.js +5 -4
  3. package/dist/app-shell/app-shell.css +1 -1
  4. package/dist/app-shell/app-shell.js +28 -26
  5. package/dist/app-shell/app-shell.module.js +8 -8
  6. package/dist/breadcrumb/breadcrumb.js +1 -1
  7. package/dist/button/button.css +1 -1
  8. package/dist/button/button.js +4 -1
  9. package/dist/button/button.module.js +4 -1
  10. package/dist/calendar/calendar.js +67 -63
  11. package/dist/card/card.css +1 -1
  12. package/dist/card/card.module.js +8 -8
  13. package/dist/checkbox/checkbox.css +1 -1
  14. package/dist/checkbox/checkbox.module.js +4 -4
  15. package/dist/code-snippet/code-snippet.js +31 -26
  16. package/dist/combobox/combobox.js +55 -54
  17. package/dist/data-table/data-table.css +1 -1
  18. package/dist/data-table/data-table.js +155 -160
  19. package/dist/data-table/data-table.module.js +29 -29
  20. package/dist/date-picker/date-picker.js +90 -89
  21. package/dist/dock/dock.js +1 -1
  22. package/dist/field/field.css +1 -1
  23. package/dist/field/field.module.js +3 -3
  24. package/dist/index.d.ts +157 -10
  25. package/dist/large-title-header/large-title-header.js +1 -1
  26. package/dist/layouts/src/grid/grid.css +1 -1
  27. package/dist/layouts/src/grid/grid.module.js +3 -3
  28. package/dist/node/accordion/accordion.js +5 -4
  29. package/dist/node/app-shell/app-shell.js +28 -26
  30. package/dist/node/app-shell/app-shell.module.js +8 -8
  31. package/dist/node/breadcrumb/breadcrumb.js +1 -1
  32. package/dist/node/button/button.js +4 -1
  33. package/dist/node/button/button.module.js +4 -1
  34. package/dist/node/calendar/calendar.js +67 -63
  35. package/dist/node/card/card.module.js +8 -8
  36. package/dist/node/checkbox/checkbox.module.js +4 -4
  37. package/dist/node/code-snippet/code-snippet.js +31 -26
  38. package/dist/node/combobox/combobox.js +55 -54
  39. package/dist/node/data-table/data-table.js +155 -160
  40. package/dist/node/data-table/data-table.module.js +29 -29
  41. package/dist/node/date-picker/date-picker.js +90 -89
  42. package/dist/node/dock/dock.js +1 -1
  43. package/dist/node/field/field.module.js +3 -3
  44. package/dist/node/large-title-header/large-title-header.js +1 -1
  45. package/dist/node/layouts/src/grid/grid.module.js +3 -3
  46. package/dist/node/search/search.js +5 -4
  47. package/dist/node/side-nav/side-nav.js +90 -89
  48. package/dist/node/swap/swap.js +4 -3
  49. package/dist/node/switcher/switcher.js +1 -1
  50. package/dist/node/tabs/tabs.js +5 -4
  51. package/dist/node/toc/toc.js +5 -4
  52. package/dist/search/search.js +5 -4
  53. package/dist/side-nav/side-nav.js +90 -89
  54. package/dist/styles.css +7 -7
  55. package/dist/swap/swap.js +4 -3
  56. package/dist/switcher/switcher.js +1 -1
  57. package/dist/tabs/tabs.js +5 -4
  58. package/dist/toc/toc.js +5 -4
  59. package/dist/types.d.ts +21 -0
  60. package/dist/types.js +1 -0
  61. package/package.json +11 -4
  62. package/readme.body.md +14 -13
@@ -2,45 +2,46 @@
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, useMachine as o, useSignal as s, useSignalEffect as c, useSignals as l } from "@cascivo/core";
6
- import { builtin as u, t as d } from "@cascivo/i18n";
7
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
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";
8
8
  //#region ../components/src/combobox/combobox.tsx
9
- var m = i({
9
+ var h = 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 h({ options: i, 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
- l();
18
- let [k, A] = o(m), j = t(), M = O ?? `cascade-combobox-${j}`, N = `${j}-listbox`, P = n(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 = s(h ?? g);
19
- h !== void 0 && (z.value = h);
20
- let B = s(""), V = s(0), H = k.value === "open", U = i.filter((e) => !b || !B.value ? !0 : e.label.toLowerCase().includes(B.value.toLowerCase())), W = i.find((e) => e.value === z.value);
21
- c(() => {
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(() => {
22
23
  if (!H) return;
23
24
  let e = (e) => {
24
- let t = document.getElementById(`${j}-root`);
25
- t && !t.contains(e.target) && A("CLOSE");
25
+ let t = document.getElementById(`${M}-root`);
26
+ t && !t.contains(e.target) && j("CLOSE");
26
27
  };
27
28
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
28
29
  });
29
30
  let G = () => {
30
- T || (B.value = "", V.value = 0, A("OPEN"), setTimeout(() => a(P.current), 0));
31
+ E || (B.value = "", V.value = 0, j("OPEN"), setTimeout(() => a(F.current), 0));
31
32
  }, K = () => {
32
- A("CLOSE"), B.value = "";
33
- }, q = _ ?? v, J = (e) => {
34
- h === void 0 && (z.value = e), q?.(e), K();
33
+ j("CLOSE"), B.value = "";
34
+ }, q = v ?? y, J = (e) => {
35
+ g === void 0 && (z.value = e), q?.(e), K();
35
36
  }, Y = () => {
36
- h === void 0 && (z.value = void 0), q?.(void 0);
37
+ g === void 0 && (z.value = void 0), q?.(void 0);
37
38
  }, X = U.flatMap((e, t) => e.disabled ? [] : [t]), Z = (e) => {
38
39
  if (X.length === 0) return;
39
40
  let t = X[(X.indexOf(V.value) + e + X.length) % X.length];
40
41
  t !== void 0 && (V.value = t);
41
42
  }, Q = (e) => {
42
43
  (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), G());
43
- }, ee = (e) => {
44
+ }, te = (e) => {
44
45
  switch (e.key) {
45
46
  case "ArrowDown":
46
47
  e.preventDefault(), Z(1);
@@ -61,42 +62,42 @@ function h({ options: i, value: h, defaultValue: g, onValueChange: _, onChange:
61
62
  K();
62
63
  break;
63
64
  }
64
- }, $ = (e) => `${j}-option-${e}`;
65
- return /* @__PURE__ */ p("div", {
66
- id: `${j}-root`,
67
- className: r(e.wrapper, D),
68
- "data-state": C ? "error" : k.value,
69
- "data-size": w,
65
+ }, $ = (e) => `${M}-option-${e}`;
66
+ return /* @__PURE__ */ m("div", {
67
+ id: `${M}-root`,
68
+ className: r(e.wrapper, O),
69
+ "data-state": w ? "error" : A.value,
70
+ "data-size": T,
70
71
  children: [
71
- x && /* @__PURE__ */ f("label", {
72
+ S && /* @__PURE__ */ p("label", {
72
73
  className: e.label,
73
- htmlFor: M,
74
- children: x
74
+ htmlFor: N,
75
+ children: S
75
76
  }),
76
- /* @__PURE__ */ p("div", {
77
+ /* @__PURE__ */ m("div", {
77
78
  className: e.field,
78
- children: [/* @__PURE__ */ p("button", {
79
- id: M,
79
+ children: [/* @__PURE__ */ m("button", {
80
+ id: N,
80
81
  type: "button",
81
82
  role: "combobox",
82
83
  "aria-expanded": H,
83
- "aria-controls": N,
84
+ "aria-controls": P,
84
85
  "aria-haspopup": "listbox",
85
86
  "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,
87
+ "aria-invalid": w ? !0 : void 0,
88
+ "aria-describedby": w ? `${M}-error` : C ? `${M}-hint` : void 0,
88
89
  className: e.trigger,
89
- disabled: T,
90
+ disabled: E,
90
91
  onKeyDown: Q,
91
92
  onClick: H ? K : G,
92
- children: [/* @__PURE__ */ f("span", {
93
+ children: [/* @__PURE__ */ p("span", {
93
94
  className: r(e.value, W ? void 0 : e.placeholder),
94
- children: W?.label ?? F
95
- }), /* @__PURE__ */ f("span", {
95
+ children: W?.label ?? ee
96
+ }), /* @__PURE__ */ p("span", {
96
97
  className: e.chevron,
97
98
  "aria-hidden": "true"
98
99
  })]
99
- }), y && z.value !== void 0 && /* @__PURE__ */ f("button", {
100
+ }), b && z.value !== void 0 && /* @__PURE__ */ p("button", {
100
101
  type: "button",
101
102
  className: e.clear,
102
103
  "aria-label": L,
@@ -106,30 +107,30 @@ function h({ options: i, value: h, defaultValue: g, onValueChange: _, onChange:
106
107
  children: "✕"
107
108
  })]
108
109
  }),
109
- /* @__PURE__ */ p("div", {
110
+ /* @__PURE__ */ m("div", {
110
111
  role: "listbox",
111
- id: N,
112
+ id: P,
112
113
  className: e.listbox,
113
114
  "data-state": H ? "open" : "closed",
114
- "aria-label": x,
115
- children: [b && H && /* @__PURE__ */ f("div", {
115
+ "aria-label": S,
116
+ children: [x && H && /* @__PURE__ */ p("div", {
116
117
  className: e.searchWrapper,
117
- children: /* @__PURE__ */ f("input", {
118
- ref: P,
118
+ children: /* @__PURE__ */ p("input", {
119
+ ref: F,
119
120
  type: "text",
120
121
  className: e.search,
121
122
  value: B.value,
122
123
  onChange: (e) => {
123
124
  B.value = e.target.value, V.value = 0;
124
125
  },
125
- onKeyDown: ee,
126
+ onKeyDown: te,
126
127
  "aria-label": R,
127
128
  autoComplete: "off"
128
129
  })
129
- }), U.length === 0 ? /* @__PURE__ */ f("div", {
130
+ }), U.length === 0 ? /* @__PURE__ */ p("div", {
130
131
  className: e.empty,
131
132
  children: I
132
- }) : U.map((t, n) => /* @__PURE__ */ f("div", {
133
+ }) : U.map((t, n) => /* @__PURE__ */ p("div", {
133
134
  id: $(n),
134
135
  role: "option",
135
136
  "aria-selected": t.value === z.value,
@@ -146,19 +147,19 @@ function h({ options: i, value: h, defaultValue: g, onValueChange: _, onChange:
146
147
  children: t.label
147
148
  }, t.value))]
148
149
  }),
149
- C && /* @__PURE__ */ f("span", {
150
- id: `${j}-error`,
150
+ w && /* @__PURE__ */ p("span", {
151
+ id: `${M}-error`,
151
152
  className: e.error,
152
153
  role: "alert",
153
- children: C
154
+ children: w
154
155
  }),
155
- !C && S && /* @__PURE__ */ f("span", {
156
- id: `${j}-hint`,
156
+ !w && C && /* @__PURE__ */ p("span", {
157
+ id: `${M}-hint`,
157
158
  className: e.hint,
158
- children: S
159
+ children: C
159
160
  })
160
161
  ]
161
162
  });
162
163
  }
163
164
  //#endregion
164
- export { h as Combobox };
165
+ export { g as Combobox };