@cascivo/react 0.18.0 → 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.
- package/README.md +4 -3
- package/dist/action-sheet/action-sheet.js +1 -1
- package/dist/breadcrumb/breadcrumb.js +7 -7
- package/dist/checkbox/checkbox.js +11 -10
- package/dist/color-picker/color-picker.js +81 -77
- package/dist/combobox/combobox.js +81 -76
- package/dist/command-menu/command-menu.js +104 -104
- package/dist/comparison/comparison.js +18 -18
- package/dist/data-table/data-table.css +1 -1
- package/dist/data-table/data-table.js +148 -121
- package/dist/data-table/data-table.module.js +29 -29
- package/dist/date-picker/date-picker.js +98 -93
- package/dist/date-range-picker/date-range-picker.js +1 -1
- package/dist/dock/dock.js +2 -2
- package/dist/dropdown/dropdown.js +43 -40
- package/dist/editable/editable.js +29 -20
- package/dist/fab/fab.js +37 -37
- package/dist/field/field.js +24 -17
- package/dist/file-uploader/file-uploader.js +24 -23
- package/dist/filter/filter.js +11 -11
- package/dist/index.d.ts +1302 -85
- package/dist/input/input.js +14 -13
- package/dist/navigation-menu/navigation-menu.js +9 -9
- package/dist/node/action-sheet/action-sheet.js +1 -1
- package/dist/node/breadcrumb/breadcrumb.js +7 -7
- package/dist/node/checkbox/checkbox.js +11 -10
- package/dist/node/color-picker/color-picker.js +81 -77
- package/dist/node/combobox/combobox.js +81 -76
- package/dist/node/command-menu/command-menu.js +104 -104
- package/dist/node/comparison/comparison.js +18 -18
- package/dist/node/data-table/data-table.js +148 -121
- package/dist/node/data-table/data-table.module.js +29 -29
- package/dist/node/date-picker/date-picker.js +98 -93
- package/dist/node/date-range-picker/date-range-picker.js +1 -1
- package/dist/node/dock/dock.js +2 -2
- package/dist/node/dropdown/dropdown.js +43 -40
- package/dist/node/editable/editable.js +29 -20
- package/dist/node/fab/fab.js +37 -37
- package/dist/node/field/field.js +24 -17
- package/dist/node/file-uploader/file-uploader.js +24 -23
- package/dist/node/filter/filter.js +11 -11
- package/dist/node/input/input.js +14 -13
- package/dist/node/navigation-menu/navigation-menu.js +9 -9
- package/dist/node/number-input/number-input.js +28 -27
- package/dist/node/overflow-menu/overflow-menu.js +7 -7
- package/dist/node/progress/progress.js +3 -3
- package/dist/node/progress-circle/progress-circle.js +8 -8
- package/dist/node/progress-indicator/progress-indicator.js +1 -1
- package/dist/node/qr-code/qr-code.js +11 -11
- package/dist/node/radial-progress/radial-progress.js +9 -9
- package/dist/node/radio/radio.js +10 -9
- package/dist/node/react/src/index.js +93 -93
- package/dist/node/resizable/resizable.js +24 -24
- package/dist/node/search/search.js +35 -31
- package/dist/node/select/select.js +15 -14
- package/dist/node/side-nav/side-nav.js +35 -35
- package/dist/node/side-nav/side-nav.module.js +27 -27
- package/dist/node/slider/slider.js +13 -12
- package/dist/node/spinner/spinner.js +4 -4
- package/dist/node/steps/steps.js +10 -10
- package/dist/node/structured-list/structured-list.js +14 -14
- package/dist/node/swap/swap.js +5 -5
- package/dist/node/switcher/switcher.js +5 -5
- package/dist/node/tags-input/tags-input.js +20 -16
- package/dist/node/textarea/textarea.js +14 -13
- package/dist/node/time-picker/time-picker.js +21 -20
- package/dist/node/toggle/toggle.js +8 -7
- package/dist/node/tree-view/tree-view.js +43 -43
- package/dist/node/virtual-list/virtual-list.js +10 -10
- package/dist/node/wheel-picker/wheel-picker.js +36 -36
- package/dist/number-input/number-input.js +28 -27
- package/dist/overflow-menu/overflow-menu.js +7 -7
- package/dist/progress/progress.js +3 -3
- package/dist/progress-circle/progress-circle.js +8 -8
- package/dist/progress-indicator/progress-indicator.js +1 -1
- package/dist/qr-code/qr-code.js +11 -11
- package/dist/radial-progress/radial-progress.js +9 -9
- package/dist/radio/radio.js +10 -9
- package/dist/react/src/index.js +93 -93
- package/dist/resizable/resizable.js +24 -24
- package/dist/search/search.js +35 -31
- package/dist/select/select.js +15 -14
- package/dist/side-nav/side-nav.css +1 -1
- package/dist/side-nav/side-nav.js +35 -35
- package/dist/side-nav/side-nav.module.js +27 -27
- package/dist/slider/slider.js +13 -12
- package/dist/spinner/spinner.js +4 -4
- package/dist/steps/steps.js +10 -10
- package/dist/structured-list/structured-list.js +14 -14
- package/dist/styles.css +2 -2
- package/dist/swap/swap.js +5 -5
- package/dist/switcher/switcher.js +5 -5
- package/dist/tags-input/tags-input.js +20 -16
- package/dist/textarea/textarea.js +14 -13
- package/dist/time-picker/time-picker.js +21 -20
- package/dist/toggle/toggle.js +8 -7
- package/dist/tree-view/tree-view.js +43 -43
- package/dist/virtual-list/virtual-list.js +10 -10
- package/dist/wheel-picker/wheel-picker.js +36 -36
- package/package.json +4 -4
- package/readme.body.md +4 -3
|
@@ -6,22 +6,22 @@ import { cn as n, focusElement as r, useSignal as i, useSignals as a } from "@ca
|
|
|
6
6
|
import { builtin as o, t as s } from "@cascivo/i18n";
|
|
7
7
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
8
|
//#region ../components/src/tags-input/tags-input.tsx
|
|
9
|
-
function u({ value: u, onValueChange: d, placeholder: f, validate: p, max: m, disabled: h = !1, className: g,
|
|
9
|
+
function u({ value: u, onValueChange: d, placeholder: f, validate: p, max: m, disabled: h = !1, className: g, id: _, ariaLabel: v, label: y, "aria-labelledby": b, "aria-describedby": x, "aria-invalid": S, ...C }) {
|
|
10
10
|
a();
|
|
11
|
-
let
|
|
12
|
-
function
|
|
11
|
+
let w = i(""), T = t(null), E = v ?? y ?? (b === void 0 ? s(o.tagsInput.label) : void 0);
|
|
12
|
+
function D(e) {
|
|
13
13
|
let t = e.trim();
|
|
14
|
-
t && (m !== void 0 && u.length >= m || u.includes(t) || p && !p(t) || (d([...u, t]),
|
|
14
|
+
t && (m !== void 0 && u.length >= m || u.includes(t) || p && !p(t) || (d([...u, t]), w.value = ""));
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function O(e) {
|
|
17
17
|
d(u.filter((t, n) => n !== e));
|
|
18
18
|
}
|
|
19
|
-
let
|
|
19
|
+
let k = f ?? s(o.tagsInput.placeholder);
|
|
20
20
|
return /* @__PURE__ */ l("div", {
|
|
21
21
|
className: n(e.wrapper, g),
|
|
22
22
|
"data-disabled": h ? "" : void 0,
|
|
23
|
-
onClick: () => r(
|
|
24
|
-
...
|
|
23
|
+
onClick: () => r(T.current),
|
|
24
|
+
...C,
|
|
25
25
|
children: [u.map((t, n) => {
|
|
26
26
|
let r = p ? !p(t) : !1;
|
|
27
27
|
return /* @__PURE__ */ l("span", {
|
|
@@ -33,7 +33,7 @@ function u({ value: u, onValueChange: d, placeholder: f, validate: p, max: m, di
|
|
|
33
33
|
"aria-label": s(o.tagsInput.remove, { tag: t }),
|
|
34
34
|
disabled: h,
|
|
35
35
|
onClick: (e) => {
|
|
36
|
-
e.stopPropagation(),
|
|
36
|
+
e.stopPropagation(), O(n);
|
|
37
37
|
},
|
|
38
38
|
children: /* @__PURE__ */ c("span", {
|
|
39
39
|
"aria-hidden": "true",
|
|
@@ -42,20 +42,24 @@ function u({ value: u, onValueChange: d, placeholder: f, validate: p, max: m, di
|
|
|
42
42
|
})]
|
|
43
43
|
}, n);
|
|
44
44
|
}), /* @__PURE__ */ c("input", {
|
|
45
|
-
ref:
|
|
45
|
+
ref: T,
|
|
46
46
|
className: e.input,
|
|
47
|
-
value:
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
value: w.value,
|
|
48
|
+
id: _,
|
|
49
|
+
"aria-labelledby": b,
|
|
50
|
+
"aria-describedby": x,
|
|
51
|
+
"aria-invalid": S,
|
|
52
|
+
"aria-label": E,
|
|
53
|
+
placeholder: u.length === 0 ? k : void 0,
|
|
50
54
|
disabled: h,
|
|
51
55
|
onChange: (e) => {
|
|
52
|
-
|
|
56
|
+
w.value = e.currentTarget.value;
|
|
53
57
|
},
|
|
54
58
|
onKeyDown: (e) => {
|
|
55
|
-
e.key === "Enter" || e.key === "," ? (e.preventDefault(),
|
|
59
|
+
e.key === "Enter" || e.key === "," ? (e.preventDefault(), D(w.value)) : e.key === "Backspace" && !w.value && O(u.length - 1);
|
|
56
60
|
},
|
|
57
61
|
onBlur: () => {
|
|
58
|
-
|
|
62
|
+
w.value && D(w.value);
|
|
59
63
|
}
|
|
60
64
|
})]
|
|
61
65
|
});
|
|
@@ -11,42 +11,43 @@ var s = r({
|
|
|
11
11
|
idle: { on: { FOCUS: "focused" } },
|
|
12
12
|
focused: { on: { BLUR: "idle" } }
|
|
13
13
|
}
|
|
14
|
-
}), c = t(function({ label: t, hint: r, error: c, resize: l = "vertical", rows: u = 4,
|
|
15
|
-
let [
|
|
14
|
+
}), c = t(function({ label: t, hint: r, error: c, resize: l = "vertical", rows: u = 4, ariaLabel: d, className: f, id: p, onFocus: m, onBlur: h, ...g }, _) {
|
|
15
|
+
let [v, y] = i(s), b = p ?? (t ? `cascade-textarea-${t.toLowerCase().replace(/\s+/g, "-")}` : void 0);
|
|
16
16
|
return /* @__PURE__ */ o("div", {
|
|
17
|
-
className: n(e.wrapper,
|
|
18
|
-
"data-state": c ? "error" :
|
|
17
|
+
className: n(e.wrapper, f),
|
|
18
|
+
"data-state": c ? "error" : v.value,
|
|
19
19
|
"data-resize": l,
|
|
20
20
|
children: [
|
|
21
21
|
t && /* @__PURE__ */ a("label", {
|
|
22
22
|
className: e.label,
|
|
23
|
-
htmlFor:
|
|
23
|
+
htmlFor: b,
|
|
24
24
|
children: t
|
|
25
25
|
}),
|
|
26
26
|
/* @__PURE__ */ a("textarea", {
|
|
27
|
-
ref:
|
|
28
|
-
id:
|
|
27
|
+
ref: _,
|
|
28
|
+
id: b,
|
|
29
29
|
rows: u,
|
|
30
30
|
"aria-multiline": "true",
|
|
31
31
|
className: e.textarea,
|
|
32
32
|
"aria-invalid": c ? !0 : void 0,
|
|
33
|
-
"aria-describedby": c ? `${
|
|
33
|
+
"aria-describedby": c ? `${b}-error` : r ? `${b}-hint` : void 0,
|
|
34
34
|
onFocus: (e) => {
|
|
35
|
-
|
|
35
|
+
y("FOCUS"), m?.(e);
|
|
36
36
|
},
|
|
37
37
|
onBlur: (e) => {
|
|
38
|
-
|
|
38
|
+
y("BLUR"), h?.(e);
|
|
39
39
|
},
|
|
40
|
-
...
|
|
40
|
+
...g,
|
|
41
|
+
"aria-label": g["aria-label"] ?? d
|
|
41
42
|
}),
|
|
42
43
|
c && /* @__PURE__ */ a("span", {
|
|
43
|
-
id: `${
|
|
44
|
+
id: `${b}-error`,
|
|
44
45
|
className: e.error,
|
|
45
46
|
role: "alert",
|
|
46
47
|
children: c
|
|
47
48
|
}),
|
|
48
49
|
!c && r && /* @__PURE__ */ a("span", {
|
|
49
|
-
id: `${
|
|
50
|
+
id: `${b}-hint`,
|
|
50
51
|
className: e.hint,
|
|
51
52
|
children: r
|
|
52
53
|
})
|
|
@@ -11,18 +11,18 @@ var c = r({
|
|
|
11
11
|
idle: { on: { FOCUS: "focused" } },
|
|
12
12
|
focused: { on: { BLUR: "idle" } }
|
|
13
13
|
}
|
|
14
|
-
}), l = t(function({ value: t, defaultValue: r, onValueChange: l,
|
|
14
|
+
}), l = t(function({ value: t, defaultValue: r, onValueChange: l, min: u, max: d, step: f, label: p, hint: m, error: h, size: g = "md", className: _, id: v, onFocus: y, onBlur: b, ariaLabel: x, ...S }, C) {
|
|
15
15
|
a();
|
|
16
|
-
let [w, T] = i(c), E =
|
|
16
|
+
let [w, T] = i(c), E = v ?? (p ? `cascade-time-picker-${p.toLowerCase().replace(/\s+/g, "-")}` : void 0);
|
|
17
17
|
return /* @__PURE__ */ s("div", {
|
|
18
|
-
className: n(e.wrapper,
|
|
19
|
-
"data-state":
|
|
20
|
-
"data-size":
|
|
18
|
+
className: n(e.wrapper, _),
|
|
19
|
+
"data-state": h ? "error" : w.value,
|
|
20
|
+
"data-size": g,
|
|
21
21
|
children: [
|
|
22
|
-
|
|
22
|
+
p && /* @__PURE__ */ o("label", {
|
|
23
23
|
className: e.label,
|
|
24
24
|
htmlFor: E,
|
|
25
|
-
children:
|
|
25
|
+
children: p
|
|
26
26
|
}),
|
|
27
27
|
/* @__PURE__ */ o("input", {
|
|
28
28
|
id: E,
|
|
@@ -30,31 +30,32 @@ var c = r({
|
|
|
30
30
|
className: e.input,
|
|
31
31
|
value: t,
|
|
32
32
|
defaultValue: r,
|
|
33
|
-
min:
|
|
34
|
-
max:
|
|
35
|
-
step:
|
|
36
|
-
"aria-invalid":
|
|
37
|
-
"aria-describedby":
|
|
38
|
-
onChange: (e) =>
|
|
33
|
+
min: u,
|
|
34
|
+
max: d,
|
|
35
|
+
step: f,
|
|
36
|
+
"aria-invalid": h ? !0 : void 0,
|
|
37
|
+
"aria-describedby": h ? `${E}-error` : m ? `${E}-hint` : void 0,
|
|
38
|
+
onChange: (e) => l?.(e.target.value),
|
|
39
39
|
onFocus: (e) => {
|
|
40
|
-
T("FOCUS"),
|
|
40
|
+
T("FOCUS"), y?.(e);
|
|
41
41
|
},
|
|
42
42
|
onBlur: (e) => {
|
|
43
|
-
T("BLUR"),
|
|
43
|
+
T("BLUR"), b?.(e);
|
|
44
44
|
},
|
|
45
45
|
ref: C,
|
|
46
|
-
...S
|
|
46
|
+
...S,
|
|
47
|
+
"aria-label": S["aria-label"] ?? x
|
|
47
48
|
}),
|
|
48
|
-
|
|
49
|
+
h && /* @__PURE__ */ o("span", {
|
|
49
50
|
id: `${E}-error`,
|
|
50
51
|
className: e.error,
|
|
51
52
|
role: "alert",
|
|
52
|
-
children:
|
|
53
|
+
children: h
|
|
53
54
|
}),
|
|
54
|
-
!
|
|
55
|
+
!h && m && /* @__PURE__ */ o("span", {
|
|
55
56
|
id: `${E}-hint`,
|
|
56
57
|
className: e.hint,
|
|
57
|
-
children:
|
|
58
|
+
children: m
|
|
58
59
|
})
|
|
59
60
|
]
|
|
60
61
|
});
|
package/dist/toggle/toggle.js
CHANGED
|
@@ -5,7 +5,7 @@ import { forwardRef as t } from "react";
|
|
|
5
5
|
import { cn as n, createMachine as r, useMachine as i, useSignals as a } from "@cascivo/core";
|
|
6
6
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
7
|
//#region ../components/src/toggle/toggle.tsx
|
|
8
|
-
var c = t(function({ checked: t, defaultChecked: c = !1, onValueChange: l,
|
|
8
|
+
var c = t(function({ checked: t, defaultChecked: c = !1, onValueChange: l, label: u, size: d = "md", className: f, disabled: p, ariaLabel: m, ...h }, g) {
|
|
9
9
|
a();
|
|
10
10
|
let [_, v] = i(r({
|
|
11
11
|
initial: c ? "on" : "off",
|
|
@@ -19,21 +19,22 @@ var c = t(function({ checked: t, defaultChecked: c = !1, onValueChange: l, onCha
|
|
|
19
19
|
role: "switch",
|
|
20
20
|
"aria-checked": b,
|
|
21
21
|
"data-state": b ? "on" : "off",
|
|
22
|
-
"data-size":
|
|
23
|
-
disabled:
|
|
24
|
-
className: n(e.toggle,
|
|
22
|
+
"data-size": d,
|
|
23
|
+
disabled: p,
|
|
24
|
+
className: n(e.toggle, f),
|
|
25
25
|
onClick: () => {
|
|
26
|
-
y || v("TOGGLE"),
|
|
26
|
+
y || v("TOGGLE"), l?.(!b);
|
|
27
27
|
},
|
|
28
28
|
ref: g,
|
|
29
29
|
...h,
|
|
30
|
+
"aria-label": h["aria-label"] ?? m,
|
|
30
31
|
children: [/* @__PURE__ */ o("span", {
|
|
31
32
|
className: e.track,
|
|
32
33
|
"aria-hidden": "true",
|
|
33
34
|
children: /* @__PURE__ */ o("span", { className: e.thumb })
|
|
34
|
-
}),
|
|
35
|
+
}), u && /* @__PURE__ */ o("span", {
|
|
35
36
|
className: e.label,
|
|
36
|
-
children:
|
|
37
|
+
children: u
|
|
37
38
|
})]
|
|
38
39
|
});
|
|
39
40
|
});
|
|
@@ -24,88 +24,88 @@ function u(e, t) {
|
|
|
24
24
|
function d(e) {
|
|
25
25
|
return e === void 0 ? [] : Array.isArray(e) ? e : e === "" ? [] : [e];
|
|
26
26
|
}
|
|
27
|
-
function f({ items: o, selectionMode: s = "single", selected: l, defaultSelected: f, onSelectChange: h, expanded: g, defaultExpanded: _, onExpandedChange: v, className: y, "aria-label": b, ariaLabel: x }) {
|
|
27
|
+
function f({ items: o, selectionMode: s = "single", selected: l, defaultSelected: f, onSelectChange: h, expanded: g, defaultExpanded: _, onExpandedChange: v, className: y, "aria-label": b, ariaLabel: x, label: S }) {
|
|
28
28
|
a();
|
|
29
|
-
let [
|
|
29
|
+
let [C, w] = r({
|
|
30
30
|
value: g,
|
|
31
31
|
defaultValue: _ ?? [],
|
|
32
32
|
onChange: v
|
|
33
|
-
}), [
|
|
33
|
+
}), [T, E] = r({
|
|
34
34
|
value: l,
|
|
35
35
|
defaultValue: f ?? (s === "multi" ? [] : ""),
|
|
36
36
|
onChange: h
|
|
37
|
-
}),
|
|
38
|
-
if (
|
|
39
|
-
let t = new Set(
|
|
40
|
-
t.add(e),
|
|
41
|
-
}, I = (e) => {
|
|
42
|
-
if (!O.has(e)) return;
|
|
43
|
-
let t = new Set(O);
|
|
44
|
-
t.delete(e), P(t);
|
|
37
|
+
}), D = i(null), O = t(/* @__PURE__ */ new Map()), k = new Set(C.value), A = u(o, k), j = new Map(A.map((e, t) => [e.id, t])), M = d(T.value), N = new Set(M), P = D.value ?? M[0] ?? A[0]?.id ?? null, F = (e) => w([...e]), I = (e) => {
|
|
38
|
+
if (k.has(e)) return;
|
|
39
|
+
let t = new Set(k);
|
|
40
|
+
t.add(e), F(t);
|
|
45
41
|
}, L = (e) => {
|
|
46
|
-
|
|
42
|
+
if (!k.has(e)) return;
|
|
43
|
+
let t = new Set(k);
|
|
44
|
+
t.delete(e), F(t);
|
|
47
45
|
}, R = (e) => {
|
|
46
|
+
D.value = e, O.current.get(e)?.focus();
|
|
47
|
+
}, z = (e) => {
|
|
48
48
|
if (s === "multi") {
|
|
49
|
-
let t = new Set(
|
|
50
|
-
t.has(e) ? t.delete(e) : t.add(e),
|
|
51
|
-
} else
|
|
52
|
-
},
|
|
49
|
+
let t = new Set(N);
|
|
50
|
+
t.has(e) ? t.delete(e) : t.add(e), E([...t]);
|
|
51
|
+
} else E(e);
|
|
52
|
+
}, B = t({
|
|
53
53
|
buffer: "",
|
|
54
54
|
at: 0
|
|
55
|
-
}),
|
|
56
|
-
let n =
|
|
55
|
+
}), V = (e, t) => {
|
|
56
|
+
let n = j.get(t.id);
|
|
57
57
|
if (n === void 0) return;
|
|
58
|
-
let { hasChildren: r, level: i, parentId: a, expanded: s } =
|
|
58
|
+
let { hasChildren: r, level: i, parentId: a, expanded: s } = A[n];
|
|
59
59
|
switch (e.key) {
|
|
60
60
|
case "ArrowDown": {
|
|
61
61
|
e.preventDefault();
|
|
62
|
-
let t =
|
|
63
|
-
t &&
|
|
62
|
+
let t = A[n + 1];
|
|
63
|
+
t && R(t.id);
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
66
|
case "ArrowUp": {
|
|
67
67
|
e.preventDefault();
|
|
68
|
-
let t =
|
|
69
|
-
t &&
|
|
68
|
+
let t = A[n - 1];
|
|
69
|
+
t && R(t.id);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
case "ArrowRight":
|
|
73
|
-
if (e.preventDefault(), r && !s)
|
|
73
|
+
if (e.preventDefault(), r && !s) I(t.id);
|
|
74
74
|
else if (r && s) {
|
|
75
|
-
let e =
|
|
76
|
-
e && e.level > i &&
|
|
75
|
+
let e = A[n + 1];
|
|
76
|
+
e && e.level > i && R(e.id);
|
|
77
77
|
}
|
|
78
78
|
break;
|
|
79
79
|
case "ArrowLeft":
|
|
80
|
-
e.preventDefault(), r && s ?
|
|
80
|
+
e.preventDefault(), r && s ? L(t.id) : a && R(a);
|
|
81
81
|
break;
|
|
82
82
|
case "Home":
|
|
83
|
-
e.preventDefault(),
|
|
83
|
+
e.preventDefault(), A[0] && R(A[0].id);
|
|
84
84
|
break;
|
|
85
85
|
case "End": {
|
|
86
86
|
e.preventDefault();
|
|
87
|
-
let t =
|
|
88
|
-
t &&
|
|
87
|
+
let t = A[A.length - 1];
|
|
88
|
+
t && R(t.id);
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
91
|
case "Enter":
|
|
92
92
|
case " ":
|
|
93
|
-
e.preventDefault(),
|
|
93
|
+
e.preventDefault(), z(t.id);
|
|
94
94
|
break;
|
|
95
95
|
default:
|
|
96
96
|
if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
97
|
-
let t =
|
|
97
|
+
let t = B.current, r = Date.now();
|
|
98
98
|
t.buffer = r - t.at > 500 ? e.key : t.buffer + e.key, t.at = r;
|
|
99
|
-
let i = t.buffer.toLowerCase(), a = (e) => typeof e.label == "string" && e.label.toLowerCase().startsWith(i), s = p(o,
|
|
99
|
+
let i = t.buffer.toLowerCase(), a = (e) => typeof e.label == "string" && e.label.toLowerCase().startsWith(i), s = p(o, k), c = [...A.slice(n + 1), ...A.slice(0, n + 1)].find((e) => {
|
|
100
100
|
let t = s.get(e.id);
|
|
101
101
|
return t ? a(t) : !1;
|
|
102
102
|
});
|
|
103
|
-
c &&
|
|
103
|
+
c && R(c.id);
|
|
104
104
|
}
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
|
-
},
|
|
108
|
-
let i = !!e.children && e.children.length > 0, a =
|
|
107
|
+
}, H = (e, t, n, r) => {
|
|
108
|
+
let i = !!e.children && e.children.length > 0, a = k.has(e.id), o = N.has(e.id), s = P === e.id, l = e.children?.length ?? 0;
|
|
109
109
|
return /* @__PURE__ */ c(m, {
|
|
110
110
|
node: e,
|
|
111
111
|
level: t,
|
|
@@ -115,20 +115,20 @@ function f({ items: o, selectionMode: s = "single", selected: l, defaultSelected
|
|
|
115
115
|
isExpanded: a,
|
|
116
116
|
isSelected: o,
|
|
117
117
|
isTabbable: s,
|
|
118
|
-
itemRefs:
|
|
119
|
-
onFocusNode: () =>
|
|
120
|
-
onKeyDown: (t) =>
|
|
118
|
+
itemRefs: O,
|
|
119
|
+
onFocusNode: () => D.value = e.id,
|
|
120
|
+
onKeyDown: (t) => V(t, e),
|
|
121
121
|
onActivate: () => {
|
|
122
|
-
|
|
122
|
+
R(e.id), i && (a ? L : I)(e.id), z(e.id);
|
|
123
123
|
},
|
|
124
|
-
children: i && e.children.map((e, n) =>
|
|
124
|
+
children: i && e.children.map((e, n) => H(e, t + 1, n + 1, l))
|
|
125
125
|
}, e.id);
|
|
126
126
|
};
|
|
127
127
|
return /* @__PURE__ */ c("ul", {
|
|
128
128
|
role: "tree",
|
|
129
|
-
"aria-label": x ?? b,
|
|
129
|
+
"aria-label": x ?? b ?? S,
|
|
130
130
|
className: n(e.tree, y),
|
|
131
|
-
children: o.map((e, t) =>
|
|
131
|
+
children: o.map((e, t) => H(e, 1, t + 1, o.length))
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
function p(e, t) {
|
|
@@ -4,23 +4,23 @@ import e from "./virtual-list.module.js";
|
|
|
4
4
|
import { cn as t, useSignal as n, useSignals as r } from "@cascivo/core";
|
|
5
5
|
import { jsx as i } from "react/jsx-runtime";
|
|
6
6
|
//#region ../components/src/virtual-list/virtual-list.tsx
|
|
7
|
-
function a({ items: a, itemHeight: o, height: s, renderItem: c, overscan: l = 3, ariaLabel: u,
|
|
7
|
+
function a({ items: a, itemHeight: o, height: s, renderItem: c, overscan: l = 3, ariaLabel: u, label: d, className: f }) {
|
|
8
8
|
r();
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
},
|
|
9
|
+
let p = n(0), m = Math.ceil(s / o), h = Math.floor(p.value / o), g = Math.max(0, h - l), _ = Math.min(a.length, h + m + l), v = a.slice(g, _), y = (e) => {
|
|
10
|
+
p.value = e.currentTarget.scrollTop;
|
|
11
|
+
}, b = { blockSize: `${s}px` };
|
|
12
12
|
return /* @__PURE__ */ i("div", {
|
|
13
|
-
className: t(e.viewport,
|
|
14
|
-
style:
|
|
15
|
-
onScroll:
|
|
13
|
+
className: t(e.viewport, f),
|
|
14
|
+
style: b,
|
|
15
|
+
onScroll: y,
|
|
16
16
|
role: "list",
|
|
17
|
-
"aria-label": u,
|
|
17
|
+
"aria-label": u ?? d,
|
|
18
18
|
tabIndex: 0,
|
|
19
19
|
children: /* @__PURE__ */ i("div", {
|
|
20
20
|
className: e.canvas,
|
|
21
21
|
style: { blockSize: `${a.length * o}px` },
|
|
22
|
-
children:
|
|
23
|
-
let r =
|
|
22
|
+
children: v.map((t, n) => {
|
|
23
|
+
let r = g + n;
|
|
24
24
|
return /* @__PURE__ */ i("div", {
|
|
25
25
|
role: "listitem",
|
|
26
26
|
"aria-setsize": a.length,
|
|
@@ -6,71 +6,71 @@ import { cn as n, useEffectPropSignal as r, useId as i, useSignalEffect as a } f
|
|
|
6
6
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
7
|
//#region ../components/src/wheel-picker/wheel-picker.tsx
|
|
8
8
|
var c = 120;
|
|
9
|
-
function l({ options: l, value: u, onValueChange: d, visibleCount: f = 5, itemHeight: p = 36, ariaLabel: m,
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
let n =
|
|
9
|
+
function l({ options: l, value: u, onValueChange: d, visibleCount: f = 5, itemHeight: p = 36, ariaLabel: m, label: h, className: g }) {
|
|
10
|
+
let _ = t(null), v = i(), y = Math.max(0, l.findIndex((e) => e.value === u)), b = t(l);
|
|
11
|
+
b.current = l;
|
|
12
|
+
let x = t(d);
|
|
13
|
+
x.current = d;
|
|
14
|
+
let S = t(p);
|
|
15
|
+
S.current = p;
|
|
16
|
+
let C = t(u);
|
|
17
|
+
C.current = u;
|
|
18
|
+
let w = (e, t) => {
|
|
19
|
+
let n = _.current;
|
|
20
20
|
n && n.scrollTo({
|
|
21
|
-
top: e *
|
|
21
|
+
top: e * S.current,
|
|
22
22
|
behavior: t ? "smooth" : "instant"
|
|
23
23
|
});
|
|
24
|
-
},
|
|
24
|
+
}, T = r(u);
|
|
25
25
|
a(() => {
|
|
26
|
-
let e =
|
|
27
|
-
t >= 0 &&
|
|
26
|
+
let e = T.value, t = b.current.findIndex((t) => t.value === e);
|
|
27
|
+
t >= 0 && w(t, !1);
|
|
28
28
|
}), a(() => {
|
|
29
|
-
let e =
|
|
29
|
+
let e = _.current;
|
|
30
30
|
if (!e) return;
|
|
31
31
|
let t, n = () => {
|
|
32
32
|
clearTimeout(t), t = setTimeout(() => {
|
|
33
|
-
let t = Math.round(e.scrollTop /
|
|
34
|
-
n && n.value !==
|
|
33
|
+
let t = Math.round(e.scrollTop / S.current), n = b.current[t];
|
|
34
|
+
n && n.value !== C.current && x.current(n.value);
|
|
35
35
|
}, c);
|
|
36
36
|
};
|
|
37
37
|
return e.addEventListener("scroll", n, { passive: !0 }), () => {
|
|
38
38
|
clearTimeout(t), e.removeEventListener("scroll", n);
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
|
-
let
|
|
41
|
+
let E = (e) => {
|
|
42
42
|
let t = Math.max(0, Math.min(l.length - 1, e)), n = l[t];
|
|
43
|
-
!n || n.value === u || (d(n.value),
|
|
44
|
-
},
|
|
43
|
+
!n || n.value === u || (d(n.value), w(t, !0));
|
|
44
|
+
}, D = (e) => {
|
|
45
45
|
let t = {
|
|
46
|
-
ArrowDown:
|
|
47
|
-
ArrowUp:
|
|
46
|
+
ArrowDown: y + 1,
|
|
47
|
+
ArrowUp: y - 1,
|
|
48
48
|
Home: 0,
|
|
49
49
|
End: l.length - 1,
|
|
50
|
-
PageDown:
|
|
51
|
-
PageUp:
|
|
50
|
+
PageDown: y + f,
|
|
51
|
+
PageUp: y - f
|
|
52
52
|
}[e.key];
|
|
53
|
-
t !== void 0 && (e.preventDefault(),
|
|
54
|
-
},
|
|
53
|
+
t !== void 0 && (e.preventDefault(), E(t));
|
|
54
|
+
}, O = (f - 1) / 2 * p, k = {
|
|
55
55
|
"--_item-height": `${p}px`,
|
|
56
|
-
"--_pad": `${
|
|
56
|
+
"--_pad": `${O}px`,
|
|
57
57
|
"--_column-height": `${f * p}px`
|
|
58
58
|
};
|
|
59
59
|
return /* @__PURE__ */ s("div", {
|
|
60
|
-
className: n(e.root,
|
|
61
|
-
style:
|
|
60
|
+
className: n(e.root, g),
|
|
61
|
+
style: k,
|
|
62
62
|
children: [/* @__PURE__ */ o("div", {
|
|
63
|
-
ref:
|
|
63
|
+
ref: _,
|
|
64
64
|
role: "listbox",
|
|
65
65
|
tabIndex: 0,
|
|
66
|
-
"aria-label": m,
|
|
67
|
-
"aria-activedescendant": `${
|
|
66
|
+
"aria-label": m ?? h,
|
|
67
|
+
"aria-activedescendant": `${v}-${y}`,
|
|
68
68
|
className: e.column,
|
|
69
|
-
onKeyDown:
|
|
69
|
+
onKeyDown: D,
|
|
70
70
|
children: l.map((t, n) => /* @__PURE__ */ o("div", {
|
|
71
|
-
id: `${
|
|
71
|
+
id: `${v}-${n}`,
|
|
72
72
|
role: "option",
|
|
73
|
-
"aria-selected": n ===
|
|
73
|
+
"aria-selected": n === y,
|
|
74
74
|
className: e.option,
|
|
75
75
|
children: t.label
|
|
76
76
|
}, t.value))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cascivo/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Prebuilt cascivo design system components — use without copying source. @cascivo/themes installs with it; pair with @cascivo/charts (data-viz) and @cascivo/icons. Docs offline: npx @cascivo/docs",
|
|
6
6
|
"keywords": [
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"provenance": true
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@cascivo/core": "^0.
|
|
55
|
-
"@cascivo/i18n": "^0.
|
|
56
|
-
"@cascivo/themes": "^0.
|
|
54
|
+
"@cascivo/core": "^1.0.0",
|
|
55
|
+
"@cascivo/i18n": "^1.0.0",
|
|
56
|
+
"@cascivo/themes": "^1.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@testing-library/jest-dom": "^6.9.1",
|
package/readme.body.md
CHANGED
|
@@ -42,7 +42,7 @@ grayscale (`ThemeProvider` warns in dev when that happens).
|
|
|
42
42
|
In a Server Component file (e.g. `app/layout.tsx`), import the themes once:
|
|
43
43
|
|
|
44
44
|
```tsx
|
|
45
|
-
import '@cascivo/themes/
|
|
45
|
+
import '@cascivo/themes/light-dark.css'
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Component CSS ships **per component** and is pulled in automatically when you
|
|
@@ -85,7 +85,8 @@ RSC without any extra wrapper.
|
|
|
85
85
|
|
|
86
86
|
```tsx
|
|
87
87
|
// once, in your entry file — themes are the only global import
|
|
88
|
-
import '@cascivo/themes/
|
|
88
|
+
import '@cascivo/themes/light-dark.css' // tokens (once) + base typography + light & dark
|
|
89
|
+
// swap for '@cascivo/themes/all.css' only if you ship a theme picker (all twelve, ~2x)
|
|
89
90
|
|
|
90
91
|
// anywhere — each component brings its own CSS along
|
|
91
92
|
import { Button, Card, CardContent, Toggle } from '@cascivo/react'
|
|
@@ -378,7 +379,7 @@ routing break after adding one of these, check that the import resolves to
|
|
|
378
379
|
- **SideNav** — Collapsible sidebar navigation with optional icons and one level of grouping
|
|
379
380
|
- **SkipNav** — Skip link that jumps keyboard users past the navigation to the main content
|
|
380
381
|
- **Steps** — Visual progress indicator for multi-step flows with horizontal and vertical orientations
|
|
381
|
-
- **Switcher** —
|
|
382
|
+
- **Switcher** — Always-visible app/product switcher LIST — every entry is rendered at once, it does not collapse. Lives inside HeaderPanel; renders links with an active indicator and optional dividers. For a collapsed trigger with a menu, use Dropdown.
|
|
382
383
|
- **Tabs** — Switch between related panels of content
|
|
383
384
|
- **Toc** — Table of contents with scroll-spy highlighting of the active section
|
|
384
385
|
|