@cascivo/react 0.16.0 → 0.17.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 (99) hide show
  1. package/README.md +6 -1
  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/badge/badge.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/combobox/combobox.js +55 -54
  16. package/dist/context-menu/context-menu.js +42 -38
  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/field/field.css +1 -1
  22. package/dist/field/field.module.js +3 -3
  23. package/dist/index.d.ts +307 -145
  24. package/dist/infinite-scroll/infinite-scroll.css +1 -0
  25. package/dist/infinite-scroll/infinite-scroll.js +49 -0
  26. package/dist/infinite-scroll/infinite-scroll.module.js +8 -0
  27. package/dist/large-title-header/large-title-header.css +1 -0
  28. package/dist/large-title-header/large-title-header.js +38 -0
  29. package/dist/large-title-header/large-title-header.module.js +13 -0
  30. package/dist/layouts/src/grid/grid.css +1 -1
  31. package/dist/layouts/src/grid/grid.module.js +3 -3
  32. package/dist/link/link.css +1 -1
  33. package/dist/link/link.module.js +1 -1
  34. package/dist/menu/menu.js +47 -43
  35. package/dist/node/accordion/accordion.js +5 -4
  36. package/dist/node/app-shell/app-shell.js +28 -26
  37. package/dist/node/app-shell/app-shell.module.js +8 -8
  38. package/dist/node/badge/badge.js +1 -1
  39. package/dist/node/button/button.js +4 -1
  40. package/dist/node/button/button.module.js +4 -1
  41. package/dist/node/calendar/calendar.js +67 -63
  42. package/dist/node/card/card.module.js +8 -8
  43. package/dist/node/checkbox/checkbox.module.js +4 -4
  44. package/dist/node/combobox/combobox.js +55 -54
  45. package/dist/node/context-menu/context-menu.js +42 -38
  46. package/dist/node/data-table/data-table.js +155 -160
  47. package/dist/node/data-table/data-table.module.js +29 -29
  48. package/dist/node/date-picker/date-picker.js +90 -89
  49. package/dist/node/field/field.module.js +3 -3
  50. package/dist/node/infinite-scroll/infinite-scroll.js +49 -0
  51. package/dist/node/infinite-scroll/infinite-scroll.module.js +7 -0
  52. package/dist/node/large-title-header/large-title-header.js +38 -0
  53. package/dist/node/large-title-header/large-title-header.module.js +12 -0
  54. package/dist/node/layouts/src/grid/grid.module.js +3 -3
  55. package/dist/node/link/link.module.js +1 -1
  56. package/dist/node/menu/menu.js +47 -43
  57. package/dist/node/react/src/index.js +27 -23
  58. package/dist/node/reorder-list/reorder-list.js +143 -0
  59. package/dist/node/reorder-list/reorder-list.module.js +11 -0
  60. package/dist/node/search/search.js +5 -4
  61. package/dist/node/side-nav/side-nav.js +90 -89
  62. package/dist/node/skip-nav/skip-nav.js +1 -0
  63. package/dist/node/swap/swap.js +2 -3
  64. package/dist/node/switcher/switcher.js +1 -1
  65. package/dist/node/tabs/tabs.js +41 -40
  66. package/dist/node/tag/tag.module.js +2 -2
  67. package/dist/node/toc/toc.js +5 -4
  68. package/dist/node/virtual-list/virtual-list.js +40 -0
  69. package/dist/node/virtual-list/virtual-list.module.js +7 -0
  70. package/dist/node/wheel-picker/wheel-picker.js +84 -0
  71. package/dist/node/wheel-picker/wheel-picker.module.js +8 -0
  72. package/dist/react/src/index.js +27 -23
  73. package/dist/reorder-list/reorder-list.css +1 -0
  74. package/dist/reorder-list/reorder-list.js +143 -0
  75. package/dist/reorder-list/reorder-list.module.js +12 -0
  76. package/dist/search/search.js +5 -4
  77. package/dist/side-nav/side-nav.js +90 -89
  78. package/dist/skip-nav/skip-nav.js +1 -0
  79. package/dist/styles.css +48 -11
  80. package/dist/swap/swap.js +2 -3
  81. package/dist/switcher/switcher.js +1 -1
  82. package/dist/tabs/tabs.js +41 -40
  83. package/dist/tag/tag.css +1 -1
  84. package/dist/tag/tag.module.js +2 -2
  85. package/dist/toc/toc.js +5 -4
  86. package/dist/virtual-list/virtual-list.css +1 -0
  87. package/dist/virtual-list/virtual-list.js +40 -0
  88. package/dist/virtual-list/virtual-list.module.js +8 -0
  89. package/dist/wheel-picker/wheel-picker.css +1 -0
  90. package/dist/wheel-picker/wheel-picker.js +84 -0
  91. package/dist/wheel-picker/wheel-picker.module.js +9 -0
  92. package/package.json +4 -4
  93. package/readme.body.md +6 -1
  94. package/dist/node/react/src/theme.js +0 -78
  95. package/dist/node/storage/src/drivers.js +0 -34
  96. package/dist/node/storage/src/persisted-signal.js +0 -41
  97. package/dist/react/src/theme.js +0 -78
  98. package/dist/storage/src/drivers.js +0 -34
  99. package/dist/storage/src/persisted-signal.js +0 -41
@@ -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, useMachine as o, useSignal as s, useSignalEffect as c, useSignals as ee } from "@cascivo/core";
6
- import { builtin as l, currentLocale as te, t as u } from "@cascivo/i18n";
7
- import { jsx as d, jsxs as f } 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 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";
8
8
  //#region ../components/src/date-picker/date-picker.tsx
9
- var p = a({
9
+ var h = 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 ne(e) {
16
+ function g(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 m(e, t, n) {
23
+ function te(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,170 +29,171 @@ function m(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 h(e, t) {
32
+ function _(e, t) {
33
33
  return new Intl.DateTimeFormat(t).format(e);
34
34
  }
35
- function g(e) {
35
+ function v(e) {
36
36
  return e.toISOString().slice(0, 10);
37
37
  }
38
- function _(e) {
38
+ function y(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 v({ value: a, defaultValue: v, onValueChange: y, onChange: b, min: x, max: S, clearable: C = !1, label: w, hint: T, error: E, size: D = "md", disabled: O = !1, labels: k, className: re, id: A }) {
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
43
  ee();
44
- let [j, M] = o(p), N = t(), P = A ?? `cascade-date-picker-${N}`, F = `${N}-grid`, I = te(), ie = k?.placeholder ?? u(l.datePicker.placeholder), ae = k?.previousMonth ?? u(l.datePicker.previousMonth), L = k?.nextMonth ?? u(l.datePicker.nextMonth), R = k?.clear ?? u(l.datePicker.clear), z = /* @__PURE__ */ new Date(), B = g(z), V = s(a ?? v);
45
- a !== void 0 && (V.value = a);
46
- let H = s(V.value ? _(V.value).getUTCFullYear() : z.getUTCFullYear()), U = s(V.value ? _(V.value).getUTCMonth() : z.getUTCMonth()), W = s(V.value), G = n(null);
47
- c(() => {
48
- if (j.value !== "open") return;
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({
45
+ 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
50
  let e = (e) => {
50
- G.current && !G.current.contains(e.target) && M("CLOSE");
51
+ K.current && !K.current.contains(e.target) && j("CLOSE");
51
52
  };
52
53
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
53
54
  });
54
- let K = () => {
55
- O || M("OPEN");
56
- }, q = () => M("CLOSE"), J = y ?? b, Y = (e) => {
57
- x && e < x || S && e > S || (a === void 0 && (V.value = e), J?.(e), q());
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());
58
59
  }, oe = (e) => {
59
- e.stopPropagation(), a === void 0 && (V.value = void 0), J?.(void 0);
60
+ e.stopPropagation(), a === void 0 && (H.value = void 0), Y?.(void 0);
60
61
  }, se = () => {
61
- U.value === 0 ? r(() => {
62
- H.value--, U.value = 11;
63
- }) : U.value--;
62
+ W.value === 0 ? r(() => {
63
+ U.value--, W.value = 11;
64
+ }) : W.value--;
64
65
  }, ce = () => {
65
- U.value === 11 ? r(() => {
66
- H.value++, U.value = 0;
67
- }) : U.value++;
68
- }, X = ne(I), Z = m(H.value, U.value, X), le = new Intl.DateTimeFormat(I, { weekday: "short" }), ue = Array.from({ length: 7 }, (e, t) => {
69
- let n = new Date(Date.UTC(2024, 0, 7 + X + t));
70
- return le.format(n);
71
- }), Q = new Intl.DateTimeFormat(I, {
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) => {
70
+ let n = new Date(Date.UTC(2024, 0, 7 + Z + t));
71
+ return ue.format(n);
72
+ }), Q = new Intl.DateTimeFormat(F, {
72
73
  month: "long",
73
74
  year: "numeric"
74
- }).format(new Date(Date.UTC(H.value, U.value, 1))), de = (e) => {
75
- let t = W.value;
75
+ }).format(new Date(Date.UTC(U.value, W.value, 1))), fe = (e) => {
76
+ let t = G.value;
76
77
  if (!t) return;
77
- let n = _(t), i;
78
+ let n = y(t), i;
78
79
  if (e.key === "ArrowRight") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() + 1));
79
80
  else if (e.key === "ArrowLeft") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() - 1));
80
81
  else if (e.key === "ArrowDown") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() + 7));
81
82
  else if (e.key === "ArrowUp") i = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate() - 7));
82
83
  else if (e.key === "Enter" || e.key === " ") {
83
- e.preventDefault(), Y(t);
84
+ e.preventDefault(), X(t);
84
85
  return;
85
86
  } else if (e.key === "Escape") {
86
- q();
87
+ J();
87
88
  return;
88
89
  } else return;
89
90
  if (e.preventDefault(), i) {
90
- let e = g(i);
91
- if (x && e < x || S && e > S) return;
92
- W.value = e, r(() => {
93
- H.value = i.getUTCFullYear(), U.value = i.getUTCMonth();
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
95
  });
95
96
  }
96
- }, $ = V.value ? h(_(V.value), I) : "";
97
- return /* @__PURE__ */ f("div", {
98
- ref: G,
99
- className: i(e.wrapper, re),
100
- "data-state": E ? "error" : j.value,
101
- "data-size": D,
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,
102
103
  children: [
103
- w && /* @__PURE__ */ d("label", {
104
+ T && /* @__PURE__ */ p("label", {
104
105
  className: e.label,
105
- htmlFor: P,
106
- children: w
106
+ htmlFor: N,
107
+ children: T
107
108
  }),
108
- /* @__PURE__ */ f("div", {
109
+ /* @__PURE__ */ m("div", {
109
110
  className: e.field,
110
- children: [/* @__PURE__ */ f("button", {
111
- id: P,
111
+ children: [/* @__PURE__ */ m("button", {
112
+ id: N,
112
113
  type: "button",
113
114
  role: "combobox",
114
- "aria-expanded": j.value === "open",
115
- "aria-controls": F,
115
+ "aria-expanded": A.value === "open",
116
+ "aria-controls": P,
116
117
  "aria-haspopup": "dialog",
117
- "aria-invalid": E ? !0 : void 0,
118
- "aria-describedby": E ? `${N}-error` : T ? `${N}-hint` : void 0,
118
+ "aria-invalid": D ? !0 : void 0,
119
+ "aria-describedby": D ? `${M}-error` : E ? `${M}-hint` : void 0,
119
120
  className: e.trigger,
120
121
  disabled: O,
121
- onClick: j.value === "open" ? q : K,
122
- children: [/* @__PURE__ */ d("span", {
122
+ onClick: A.value === "open" ? J : q,
123
+ children: [/* @__PURE__ */ p("span", {
123
124
  className: i(e.value, $ ? void 0 : e.placeholder),
124
- children: $ || ie
125
- }), /* @__PURE__ */ d("span", {
125
+ children: $ || I
126
+ }), /* @__PURE__ */ p("span", {
126
127
  className: e.icon,
127
128
  "aria-hidden": "true",
128
129
  children: "📅"
129
130
  })]
130
- }), C && V.value !== void 0 && /* @__PURE__ */ d("button", {
131
+ }), w && H.value !== void 0 && /* @__PURE__ */ p("button", {
131
132
  type: "button",
132
133
  className: e.clear,
133
- "aria-label": R,
134
+ "aria-label": z,
134
135
  onClick: oe,
135
136
  children: "✕"
136
137
  })]
137
138
  }),
138
- /* @__PURE__ */ f("div", {
139
- id: F,
139
+ /* @__PURE__ */ m("div", {
140
+ id: P,
140
141
  role: "dialog",
141
142
  "aria-label": Q,
142
143
  className: e.calendar,
143
- "data-state": j.value,
144
- onKeyDown: de,
145
- children: [/* @__PURE__ */ f("div", {
144
+ "data-state": A.value,
145
+ onKeyDown: fe,
146
+ children: [/* @__PURE__ */ m("div", {
146
147
  className: e.header,
147
148
  children: [
148
- /* @__PURE__ */ d("button", {
149
+ /* @__PURE__ */ p("button", {
149
150
  type: "button",
150
151
  className: e.navButton,
151
- "aria-label": ae,
152
+ "aria-label": L,
152
153
  onClick: se,
153
154
  children: "‹"
154
155
  }),
155
- /* @__PURE__ */ d("span", {
156
+ /* @__PURE__ */ p("span", {
156
157
  className: e.monthLabel,
157
158
  "aria-live": "polite",
158
159
  children: Q
159
160
  }),
160
- /* @__PURE__ */ d("button", {
161
+ /* @__PURE__ */ p("button", {
161
162
  type: "button",
162
163
  className: e.navButton,
163
- "aria-label": L,
164
+ "aria-label": R,
164
165
  onClick: ce,
165
166
  children: "›"
166
167
  })
167
168
  ]
168
- }), /* @__PURE__ */ f("table", {
169
+ }), /* @__PURE__ */ m("table", {
169
170
  role: "grid",
170
171
  className: e.grid,
171
- children: [/* @__PURE__ */ d("thead", { children: /* @__PURE__ */ d("tr", { children: ue.map((t) => /* @__PURE__ */ d("th", {
172
+ children: [/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { children: de.map((t) => /* @__PURE__ */ p("th", {
172
173
  className: e.weekday,
173
174
  abbr: t,
174
175
  scope: "col",
175
176
  children: t
176
- }, t)) }) }), /* @__PURE__ */ d("tbody", { children: Z.map((t, n) => /* @__PURE__ */ d("tr", { children: t.map((t, n) => {
177
- if (!t) return /* @__PURE__ */ d("td", { className: e.empty }, n);
178
- let r = g(t), i = r === V.value, a = r === B, o = r === W.value, s = x !== void 0 && r < x || S !== void 0 && r > S;
179
- return /* @__PURE__ */ d("td", {
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", {
180
181
  className: e.cell,
181
- children: /* @__PURE__ */ d("button", {
182
+ children: /* @__PURE__ */ p("button", {
182
183
  type: "button",
183
184
  className: e.day,
184
185
  tabIndex: o ? 0 : -1,
185
186
  "aria-pressed": i,
186
- "aria-label": h(t, I),
187
+ "aria-label": _(t, F),
187
188
  "aria-current": a ? "date" : void 0,
188
189
  "aria-disabled": s || void 0,
189
190
  "data-selected": i || void 0,
190
191
  "data-today": a || void 0,
191
192
  onClick: () => {
192
- s || Y(r);
193
+ s || X(r);
193
194
  },
194
195
  onFocus: () => {
195
- W.value = r;
196
+ G.value = r;
196
197
  },
197
198
  children: t.getUTCDate()
198
199
  })
@@ -200,19 +201,19 @@ function v({ value: a, defaultValue: v, onValueChange: y, onChange: b, min: x, m
200
201
  }) }, n)) })]
201
202
  })]
202
203
  }),
203
- E && /* @__PURE__ */ d("span", {
204
- id: `${N}-error`,
204
+ D && /* @__PURE__ */ p("span", {
205
+ id: `${M}-error`,
205
206
  className: e.error,
206
207
  role: "alert",
207
- children: E
208
+ children: D
208
209
  }),
209
- !E && T && /* @__PURE__ */ d("span", {
210
- id: `${N}-hint`,
210
+ !D && E && /* @__PURE__ */ p("span", {
211
+ id: `${M}-hint`,
211
212
  className: e.hint,
212
- children: T
213
+ children: E
213
214
  })
214
215
  ]
215
216
  });
216
217
  }
217
218
  //#endregion
218
- export { v as DatePicker };
219
+ export { b as DatePicker };
@@ -1 +1 @@
1
- @layer cascivo.component{._field_ws86v_2{gap:var(--cascivo-space-2);font-family:var(--cascivo-font-sans);display:grid}._field_ws86v_2[data-disabled]{opacity:.5}._description_ws86v_12{font-size:var(--cascivo-text-sm);line-height:var(--cascivo-leading-snug);color:var(--cascivo-color-text-muted);margin:0}._error_ws86v_19{font-size:var(--cascivo-text-sm);line-height:var(--cascivo-leading-snug);color:var(--cascivo-color-destructive);margin:0}}@media (forced-colors:active){._error_ws86v_19{color:buttontext}}
1
+ @layer cascivo.component{._field_1y14o_2{gap:var(--cascivo-space-2);font-family:var(--cascivo-font-sans);align-content:start;display:grid}._field_1y14o_2[data-disabled]{opacity:.5}._description_1y14o_20{font-size:var(--cascivo-text-sm);line-height:var(--cascivo-leading-snug);color:var(--cascivo-color-text-muted);margin:0}._error_1y14o_27{font-size:var(--cascivo-text-sm);line-height:var(--cascivo-leading-snug);color:var(--cascivo-color-destructive);margin:0}}@media (forced-colors:active){._error_1y14o_27{color:buttontext}}
@@ -1,8 +1,8 @@
1
1
  import './field.css';
2
2
  var e = {
3
- field: "_field_ws86v_2",
4
- description: "_description_ws86v_12",
5
- error: "_error_ws86v_19"
3
+ field: "_field_1y14o_2",
4
+ description: "_description_1y14o_20",
5
+ error: "_error_1y14o_27"
6
6
  };
7
7
  //#endregion
8
8
  export { e as default };