@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
package/dist/fab/fab.js CHANGED
@@ -5,57 +5,57 @@ import { useId as t, useRef as n } from "react";
5
5
  import { DismissableLayer as r, Presence as i, cn as a, focusElement as o, useControllableSignal as s, useRovingFocus as c, useSignalEffect as l, useSignals as u } from "@cascivo/core";
6
6
  import { jsx as d, jsxs as f } from "react/jsx-runtime";
7
7
  //#region ../components/src/fab/fab.tsx
8
- function p({ children: p, label: m, onClick: h, actions: g, position: _ = "bottom-end", open: v, defaultOpen: y, onOpenChange: b, className: x }) {
8
+ function p({ children: p, ariaLabel: m, label: h, onClick: g, actions: _, position: v = "bottom-end", open: y, defaultOpen: b, onOpenChange: x, className: S }) {
9
9
  u();
10
- let S = g != null && g.length > 0, [C, w] = s({
11
- value: v,
12
- defaultValue: y ?? !1,
13
- onChange: b
14
- }), T = c({
10
+ let C = _ != null && _.length > 0, [w, T] = s({
11
+ value: y,
12
+ defaultValue: b ?? !1,
13
+ onChange: x
14
+ }), E = c({
15
15
  orientation: "vertical",
16
16
  loop: !0
17
- }), E = n(null), D = n(null), O = t(), k = n(!1);
17
+ }), D = n(null), O = n(null), k = t(), A = n(!1);
18
18
  l(() => {
19
- let e = S && C.value;
20
- e && !k.current ? D.current?.querySelector("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")?.focus() : !e && k.current && o(E.current), k.current = e;
19
+ let e = C && w.value;
20
+ e && !A.current ? O.current?.querySelector("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")?.focus() : !e && A.current && o(D.current), A.current = e;
21
21
  });
22
- let A = (e) => {
23
- e.disabled || (e.onSelect(), w(!1));
24
- }, j = /* @__PURE__ */ d("button", {
25
- ref: E,
22
+ let j = (e) => {
23
+ e.disabled || (e.onSelect(), T(!1));
24
+ }, M = /* @__PURE__ */ d("button", {
25
+ ref: D,
26
26
  type: "button",
27
- "aria-label": m,
27
+ "aria-label": h ?? m,
28
28
  className: e.fab,
29
- ...S ? {
29
+ ...C ? {
30
30
  "aria-haspopup": "menu",
31
- "aria-expanded": C.value,
32
- "aria-controls": O,
33
- "data-state": C.value ? "open" : "closed",
34
- onClick: () => w(!C.value)
35
- } : { onClick: h },
31
+ "aria-expanded": w.value,
32
+ "aria-controls": k,
33
+ "data-state": w.value ? "open" : "closed",
34
+ onClick: () => T(!w.value)
35
+ } : { onClick: g },
36
36
  children: /* @__PURE__ */ d("span", {
37
37
  className: e.icon,
38
38
  "aria-hidden": "true",
39
39
  children: p
40
40
  })
41
41
  });
42
- return S ? /* @__PURE__ */ d(r, {
43
- onDismiss: () => w(!1),
44
- escapeDismisses: C.value,
45
- disableOutsidePointer: !C.value,
42
+ return C ? /* @__PURE__ */ d(r, {
43
+ onDismiss: () => T(!1),
44
+ escapeDismisses: w.value,
45
+ disableOutsidePointer: !w.value,
46
46
  children: /* @__PURE__ */ f("div", {
47
- className: a(e.root, x),
48
- "data-position": _,
47
+ className: a(e.root, S),
48
+ "data-position": v,
49
49
  children: [/* @__PURE__ */ d(i, {
50
- present: C,
50
+ present: w,
51
51
  children: /* @__PURE__ */ d("menu", {
52
- ref: D,
53
- id: O,
52
+ ref: O,
53
+ id: k,
54
54
  role: "menu",
55
- "aria-label": m,
55
+ "aria-label": h ?? m,
56
56
  className: e.dial,
57
- children: g.map((t, n) => {
58
- let r = T.getItemProps(n);
57
+ children: _.map((t, n) => {
58
+ let r = E.getItemProps(n);
59
59
  return /* @__PURE__ */ d("li", {
60
60
  role: "presentation",
61
61
  className: e.dialItem,
@@ -68,7 +68,7 @@ function p({ children: p, label: m, onClick: h, actions: g, position: _ = "botto
68
68
  className: e.action,
69
69
  onKeyDown: r.onKeyDown,
70
70
  onFocus: r.onFocus,
71
- onClick: () => A(t),
71
+ onClick: () => j(t),
72
72
  children: [/* @__PURE__ */ d("span", {
73
73
  className: e.actionLabel,
74
74
  children: t.label
@@ -81,12 +81,12 @@ function p({ children: p, label: m, onClick: h, actions: g, position: _ = "botto
81
81
  }, t.id ?? n);
82
82
  })
83
83
  })
84
- }), j]
84
+ }), M]
85
85
  })
86
86
  }) : /* @__PURE__ */ d("div", {
87
- className: a(e.root, x),
88
- "data-position": _,
89
- children: j
87
+ className: a(e.root, S),
88
+ "data-position": v,
89
+ children: M
90
90
  });
91
91
  }
92
92
  //#endregion
@@ -13,34 +13,41 @@ function d(e, t) {
13
13
  let n = String(e);
14
14
  l.has(n) || (l.add(n), console.warn(`cascivo Field: both the Field and its child control define a \`label\` (${n}). Omit the child's \`label\` inside a Field — it renders a second <label> for the same control. The Field owns the label.`));
15
15
  }
16
- function f({ label: l, description: u, error: f, required: p = !1, disabled: m = !1, id: h, children: g, className: _ }) {
17
- let v = r("cascade-field"), y = h ?? v, b = `${y}-description`, x = `${y}-error`, S = [u ? b : null, f ? x : null].filter(Boolean).join(" ") || void 0, C = { id: y };
18
- S && (C["aria-describedby"] = S), f && (C["aria-invalid"] = !0), (m || g.props.disabled) && (C.disabled = !0), o(g) && d(l, g);
19
- let w = o(g) ? a(i.only(g), C) : g;
16
+ var f = /* @__PURE__ */ new Set();
17
+ function p(e, t) {
18
+ if (!u() || e == null || t.props.hint == null) return;
19
+ let n = String(e);
20
+ f.has(n) || (f.add(n), console.warn(`cascivo Field: both the Field and its child control define supporting text (${n}). Omit the child's \`hint\` inside a Field — the Field owns it, and only the Field's is wired into aria-describedby.`));
21
+ }
22
+ function m({ label: l, description: u, hint: f, error: m, required: h = !1, disabled: g = !1, id: _, children: v, className: y }) {
23
+ let b = u ?? f, x = r("cascade-field"), S = _ ?? x, C = `${S}-description`, w = `${S}-error`, T = `${S}-label`, E = [b ? C : null, m ? w : null].filter(Boolean).join(" ") || void 0, D = { id: S };
24
+ l != null && (D["aria-labelledby"] = T), E && (D["aria-describedby"] = E), m && (D["aria-invalid"] = !0), (g || v.props.disabled) && (D.disabled = !0), o(v) && (d(l, v), p(b, v));
25
+ let O = o(v) ? a(i.only(v), D) : v;
20
26
  return /* @__PURE__ */ c("div", {
21
- className: n(t.field, _),
22
- "data-disabled": m ? "" : void 0,
27
+ className: n(t.field, y),
28
+ "data-disabled": g ? "" : void 0,
23
29
  children: [
24
30
  l && /* @__PURE__ */ s(e, {
25
- htmlFor: y,
26
- required: p,
27
- disabled: m,
31
+ id: T,
32
+ htmlFor: S,
33
+ required: h,
34
+ disabled: g,
28
35
  children: l
29
36
  }),
30
- w,
31
- u && /* @__PURE__ */ s("p", {
32
- id: b,
37
+ O,
38
+ b && /* @__PURE__ */ s("p", {
39
+ id: C,
33
40
  className: t.description,
34
- children: u
41
+ children: b
35
42
  }),
36
- f && /* @__PURE__ */ s("p", {
37
- id: x,
43
+ m && /* @__PURE__ */ s("p", {
44
+ id: w,
38
45
  role: "alert",
39
46
  className: t.error,
40
- children: f
47
+ children: m
41
48
  })
42
49
  ]
43
50
  });
44
51
  }
45
52
  //#endregion
46
- export { f as Field };
53
+ export { m as Field };
@@ -14,58 +14,59 @@ function u(e, t) {
14
14
  function d(e) {
15
15
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : e >= 1024 ? `${(e / 1024).toFixed(1)} KB` : `${e} B`;
16
16
  }
17
- function f({ files: f = [], onFilesAdded: p, onRemove: m, multiple: h = !1, accept: g, maxSize: _, onRejected: v, label: y, hint: b, labels: x, disabled: S = !1, className: C }) {
17
+ function f({ files: f = [], onFilesAdded: p, onRemove: m, multiple: h = !1, accept: g, maxSize: _, onRejected: v, label: y, ariaLabel: b, hint: x, labels: S, disabled: C = !1, className: w }) {
18
18
  a();
19
- let w = n(null), T = i(!1), E = y ?? x?.label ?? s(o.fileUploader.label), D = x?.drop ?? s(o.fileUploader.drop), O = x?.uploading ?? s(o.fileUploader.uploading), k = x?.complete ?? s(o.fileUploader.complete), A = x?.error ?? s(o.fileUploader.error), j = (e) => x?.remove ? x.remove.replace("{name}", e) : s(o.fileUploader.remove, { name: e }), M = `cascade-uploader-${E.toLowerCase().replace(/\s+/g, "-")}`, N = `${M}-label`, P = `${M}-hint`, F = (e) => {
19
+ let T = n(null), E = i(!1), D = y ?? S?.label ?? s(o.fileUploader.label), O = S?.drop ?? s(o.fileUploader.drop), k = S?.uploading ?? s(o.fileUploader.uploading), A = S?.complete ?? s(o.fileUploader.complete), j = S?.error ?? s(o.fileUploader.error), M = (e) => S?.remove ? S.remove.replace("{name}", e) : s(o.fileUploader.remove, { name: e }), N = `cascade-uploader-${D.toLowerCase().replace(/\s+/g, "-")}`, P = `${N}-label`, F = `${N}-hint`, I = (e) => {
20
20
  if (!e || e.length === 0) return;
21
21
  let t = h ? Array.from(e) : Array.from(e).slice(0, 1), n = [], r = [], i = [];
22
22
  for (let e of t) g && !u(e, g) ? r.push(e) : _ !== void 0 && e.size > _ ? i.push(e) : n.push(e);
23
23
  r.length > 0 && v?.(r, "type"), i.length > 0 && v?.(i, "size"), n.length > 0 && p?.(n);
24
24
  };
25
25
  return /* @__PURE__ */ l("div", {
26
- className: r(t.uploader, C),
26
+ className: r(t.uploader, w),
27
27
  children: [
28
28
  /* @__PURE__ */ c("span", {
29
- id: N,
29
+ id: P,
30
30
  className: t.label,
31
- children: E
31
+ children: D
32
32
  }),
33
33
  /* @__PURE__ */ c("input", {
34
- ref: w,
34
+ ref: T,
35
35
  type: "file",
36
36
  className: t.input,
37
37
  tabIndex: -1,
38
38
  "aria-hidden": "true",
39
39
  multiple: h,
40
40
  accept: g,
41
- disabled: S,
41
+ disabled: C,
42
42
  onChange: (e) => {
43
- F(e.target.files), e.target.value = "";
43
+ I(e.target.files), e.target.value = "";
44
44
  }
45
45
  }),
46
46
  /* @__PURE__ */ c("button", {
47
47
  type: "button",
48
48
  className: t.zone,
49
- "data-state": T.value ? "dragover" : "idle",
50
- disabled: S,
51
- "aria-describedby": b ? `${N} ${P}` : N,
52
- onClick: () => w.current?.click(),
49
+ "data-state": E.value ? "dragover" : "idle",
50
+ disabled: C,
51
+ "aria-label": b,
52
+ "aria-describedby": x ? `${P} ${F}` : P,
53
+ onClick: () => T.current?.click(),
53
54
  onDragEnter: (e) => {
54
- e.preventDefault(), S || (T.value = !0);
55
+ e.preventDefault(), C || (E.value = !0);
55
56
  },
56
57
  onDragOver: (e) => e.preventDefault(),
57
58
  onDragLeave: () => {
58
- T.value = !1;
59
+ E.value = !1;
59
60
  },
60
61
  onDrop: (e) => {
61
- e.preventDefault(), T.value = !1, !S && F(e.dataTransfer.files);
62
+ e.preventDefault(), E.value = !1, !C && I(e.dataTransfer.files);
62
63
  },
63
- children: D
64
+ children: O
64
65
  }),
65
- b && /* @__PURE__ */ c("span", {
66
- id: P,
66
+ x && /* @__PURE__ */ c("span", {
67
+ id: F,
67
68
  className: t.hint,
68
- children: b
69
+ children: x
69
70
  }),
70
71
  f.length > 0 && /* @__PURE__ */ c("ul", {
71
72
  className: t.list,
@@ -79,16 +80,16 @@ function f({ files: f = [], onFilesAdded: p, onRemove: m, multiple: h = !1, acce
79
80
  children: [
80
81
  n.status === "uploading" && /* @__PURE__ */ c(e, {
81
82
  size: "sm",
82
- label: O
83
+ label: k
83
84
  }),
84
85
  n.status === "complete" && /* @__PURE__ */ c("span", {
85
86
  className: t["glyph-complete"],
86
- "aria-label": k,
87
+ "aria-label": A,
87
88
  children: "✓"
88
89
  }),
89
90
  n.status === "error" && /* @__PURE__ */ c("span", {
90
91
  className: t["glyph-error"],
91
- "aria-label": A,
92
+ "aria-label": j,
92
93
  children: "✕"
93
94
  })
94
95
  ]
@@ -104,7 +105,7 @@ function f({ files: f = [], onFilesAdded: p, onRemove: m, multiple: h = !1, acce
104
105
  /* @__PURE__ */ c("button", {
105
106
  type: "button",
106
107
  className: t.remove,
107
- "aria-label": j(n.name),
108
+ "aria-label": M(n.name),
108
109
  onClick: () => m?.(n.id),
109
110
  children: "✕"
110
111
  }),
@@ -4,29 +4,29 @@ import e from "./filter.module.js";
4
4
  import { useControllableSignal as t, useSignals as n } from "@cascivo/core";
5
5
  import { jsx as r } from "react/jsx-runtime";
6
6
  //#region ../components/src/filter/filter.tsx
7
- function i({ options: i, value: a, defaultValue: o = [], onValueChange: s, onChange: c, multi: l = !1, variant: u = "pill", className: d, ariaLabel: f, ...p }) {
7
+ function i({ options: i, value: a, defaultValue: o = [], onValueChange: s, multi: c = !1, multiple: l, variant: u = "pill", className: d, ariaLabel: f, label: p, ...m }) {
8
8
  n();
9
- let [m, h] = t({
9
+ let h = l ?? c, [g, _] = t({
10
10
  value: a,
11
11
  defaultValue: o,
12
- onChange: s ?? c
12
+ onChange: s
13
13
  });
14
- function g(e) {
15
- let t = m.value, n;
16
- n = l ? t.includes(e) ? t.filter((t) => t !== e) : [...t, e] : t.includes(e) ? [] : [e], h(n);
14
+ function v(e) {
15
+ let t = g.value, n;
16
+ n = h ? t.includes(e) ? t.filter((t) => t !== e) : [...t, e] : t.includes(e) ? [] : [e], _(n);
17
17
  }
18
18
  return /* @__PURE__ */ r("div", {
19
19
  role: "group",
20
20
  className: [e.filter, d].filter(Boolean).join(" "),
21
21
  "data-variant": u,
22
- "aria-label": p["aria-label"] ?? f,
23
- ...p,
22
+ "aria-label": m["aria-label"] ?? f ?? p,
23
+ ...m,
24
24
  children: i.map((t) => /* @__PURE__ */ r("button", {
25
25
  type: "button",
26
26
  className: e.item,
27
- "data-selected": m.value.includes(t.value) || void 0,
28
- onClick: () => g(t.value),
29
- "aria-pressed": m.value.includes(t.value),
27
+ "data-selected": g.value.includes(t.value) || void 0,
28
+ onClick: () => v(t.value),
29
+ "aria-pressed": g.value.includes(t.value),
30
30
  children: t.label
31
31
  }, t.value))
32
32
  });