@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
|
@@ -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))
|
|
@@ -31,26 +31,26 @@ function h(e) {
|
|
|
31
31
|
let n = Number(t);
|
|
32
32
|
return Number.isFinite(n) ? n : null;
|
|
33
33
|
}
|
|
34
|
-
var g = t(function({ value: t, defaultValue: r, onValueChange: g,
|
|
34
|
+
var g = t(function({ value: t, defaultValue: r, onValueChange: g, min: _, max: v, step: y = 1, precision: b, formatOptions: x, label: S, hint: C, error: w, size: T = "md", disabled: E, incrementLabel: D, decrementLabel: O, className: k, id: A, onFocus: j, onBlur: M, onKeyDown: N, ariaLabel: P, ...F }, I) {
|
|
35
35
|
o();
|
|
36
|
-
let L =
|
|
37
|
-
V || (H.value = e), U.value = e == null ? "" : String(e), e !== W &&
|
|
36
|
+
let L = D ?? c(s.numberInput.increment), R = O ?? c(s.numberInput.decrement), [z, B] = i(d), V = t !== void 0, H = a(r ?? null), U = a(""), W = V ? t : H.value, G = A ?? (S ? `cascade-number-input-${S.toLowerCase().replace(/\s+/g, "-")}` : void 0), K = (e) => {
|
|
37
|
+
V || (H.value = e), U.value = e == null ? "" : String(e), e !== W && g?.(e);
|
|
38
38
|
}, q = () => {
|
|
39
39
|
let e = h(U.value);
|
|
40
|
-
e != null && (e = f(e,
|
|
40
|
+
e != null && (e = f(e, _, v), b !== void 0 && (e = m(e, b))), K(e);
|
|
41
41
|
}, J = (e) => {
|
|
42
|
-
let t = (z.value === "focused" ? h(U.value) : W) ?? 0, n =
|
|
43
|
-
K(f(m(t + e *
|
|
44
|
-
}, Y = z.value === "focused" ? U.value : ((e) => e == null ? "" :
|
|
42
|
+
let t = (z.value === "focused" ? h(U.value) : W) ?? 0, n = b ?? Math.max(p(y), p(t));
|
|
43
|
+
K(f(m(t + e * y, n), _, v));
|
|
44
|
+
}, Y = z.value === "focused" ? U.value : ((e) => e == null ? "" : x ? new Intl.NumberFormat(void 0, x).format(e) : String(e))(W), X = W != null && v !== void 0 && W >= v, Z = W != null && _ !== void 0 && W <= _;
|
|
45
45
|
return /* @__PURE__ */ u("div", {
|
|
46
|
-
className: n(e.wrapper,
|
|
47
|
-
"data-state":
|
|
48
|
-
"data-size":
|
|
46
|
+
className: n(e.wrapper, k),
|
|
47
|
+
"data-state": w ? "error" : z.value,
|
|
48
|
+
"data-size": T,
|
|
49
49
|
children: [
|
|
50
|
-
|
|
50
|
+
S && /* @__PURE__ */ l("label", {
|
|
51
51
|
className: e.label,
|
|
52
52
|
htmlFor: G,
|
|
53
|
-
children:
|
|
53
|
+
children: S
|
|
54
54
|
}),
|
|
55
55
|
/* @__PURE__ */ u("div", {
|
|
56
56
|
className: e.field,
|
|
@@ -62,26 +62,27 @@ var g = t(function({ value: t, defaultValue: r, onValueChange: g, onChange: _, m
|
|
|
62
62
|
role: "spinbutton",
|
|
63
63
|
className: e.input,
|
|
64
64
|
value: Y,
|
|
65
|
-
disabled:
|
|
65
|
+
disabled: E,
|
|
66
66
|
"aria-valuenow": W ?? void 0,
|
|
67
|
-
"aria-valuemin":
|
|
68
|
-
"aria-valuemax":
|
|
69
|
-
"aria-invalid":
|
|
70
|
-
"aria-describedby":
|
|
67
|
+
"aria-valuemin": _,
|
|
68
|
+
"aria-valuemax": v,
|
|
69
|
+
"aria-invalid": w ? !0 : void 0,
|
|
70
|
+
"aria-describedby": w ? `${G}-error` : C ? `${G}-hint` : void 0,
|
|
71
71
|
onChange: (e) => {
|
|
72
72
|
U.value = e.target.value;
|
|
73
73
|
},
|
|
74
74
|
onFocus: (e) => {
|
|
75
|
-
U.value = W == null ? "" : String(W), B("FOCUS"),
|
|
75
|
+
U.value = W == null ? "" : String(W), B("FOCUS"), j?.(e);
|
|
76
76
|
},
|
|
77
77
|
onBlur: (e) => {
|
|
78
|
-
q(), B("BLUR"),
|
|
78
|
+
q(), B("BLUR"), M?.(e);
|
|
79
79
|
},
|
|
80
80
|
onKeyDown: (e) => {
|
|
81
|
-
e.key === "ArrowUp" ? (e.preventDefault(), J(1)) : e.key === "ArrowDown" ? (e.preventDefault(), J(-1)) : e.key === "Enter" && q(),
|
|
81
|
+
e.key === "ArrowUp" ? (e.preventDefault(), J(1)) : e.key === "ArrowDown" ? (e.preventDefault(), J(-1)) : e.key === "Enter" && q(), N?.(e);
|
|
82
82
|
},
|
|
83
83
|
ref: I,
|
|
84
|
-
...F
|
|
84
|
+
...F,
|
|
85
|
+
"aria-label": F["aria-label"] ?? P
|
|
85
86
|
}), /* @__PURE__ */ u("div", {
|
|
86
87
|
className: e.steppers,
|
|
87
88
|
children: [/* @__PURE__ */ l("button", {
|
|
@@ -89,7 +90,7 @@ var g = t(function({ value: t, defaultValue: r, onValueChange: g, onChange: _, m
|
|
|
89
90
|
className: e.stepper,
|
|
90
91
|
"aria-label": L,
|
|
91
92
|
tabIndex: -1,
|
|
92
|
-
disabled:
|
|
93
|
+
disabled: E || X,
|
|
93
94
|
onMouseDown: (e) => e.preventDefault(),
|
|
94
95
|
onClick: () => J(1),
|
|
95
96
|
children: /* @__PURE__ */ l("svg", {
|
|
@@ -110,7 +111,7 @@ var g = t(function({ value: t, defaultValue: r, onValueChange: g, onChange: _, m
|
|
|
110
111
|
className: e.stepper,
|
|
111
112
|
"aria-label": R,
|
|
112
113
|
tabIndex: -1,
|
|
113
|
-
disabled:
|
|
114
|
+
disabled: E || Z,
|
|
114
115
|
onMouseDown: (e) => e.preventDefault(),
|
|
115
116
|
onClick: () => J(-1),
|
|
116
117
|
children: /* @__PURE__ */ l("svg", {
|
|
@@ -129,16 +130,16 @@ var g = t(function({ value: t, defaultValue: r, onValueChange: g, onChange: _, m
|
|
|
129
130
|
})]
|
|
130
131
|
})]
|
|
131
132
|
}),
|
|
132
|
-
|
|
133
|
+
w && /* @__PURE__ */ l("span", {
|
|
133
134
|
id: `${G}-error`,
|
|
134
135
|
className: e.error,
|
|
135
136
|
role: "alert",
|
|
136
|
-
children:
|
|
137
|
+
children: w
|
|
137
138
|
}),
|
|
138
|
-
!
|
|
139
|
+
!w && C && /* @__PURE__ */ l("span", {
|
|
139
140
|
id: `${G}-hint`,
|
|
140
141
|
className: e.hint,
|
|
141
|
-
children:
|
|
142
|
+
children: C
|
|
142
143
|
})
|
|
143
144
|
]
|
|
144
145
|
});
|
|
@@ -37,9 +37,9 @@ function u() {
|
|
|
37
37
|
]
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function d({ items: d, onSelect: f, placement: p = "bottom-end", ariaLabel: m,
|
|
40
|
+
function d({ items: d, onSelect: f, placement: p = "bottom-end", ariaLabel: m, label: h, size: g = "md", disabled: _ = !1, className: v }) {
|
|
41
41
|
r();
|
|
42
|
-
let
|
|
42
|
+
let y = m ?? h ?? a(i.overflowMenu.trigger), b = d.map((e) => {
|
|
43
43
|
let n = {
|
|
44
44
|
label: e.label,
|
|
45
45
|
value: l(e)
|
|
@@ -50,17 +50,17 @@ function d({ items: d, onSelect: f, placement: p = "bottom-end", ariaLabel: m, s
|
|
|
50
50
|
})] }) : e.icon !== void 0 && (n.icon = e.icon), n;
|
|
51
51
|
});
|
|
52
52
|
return /* @__PURE__ */ s("div", {
|
|
53
|
-
className: n(t.root,
|
|
53
|
+
className: n(t.root, v),
|
|
54
54
|
children: /* @__PURE__ */ s(e, {
|
|
55
|
-
items:
|
|
55
|
+
items: b,
|
|
56
56
|
onSelect: (e) => f?.(e),
|
|
57
57
|
placement: p,
|
|
58
58
|
trigger: /* @__PURE__ */ s("button", {
|
|
59
59
|
type: "button",
|
|
60
60
|
className: t.trigger,
|
|
61
|
-
"data-size":
|
|
62
|
-
disabled:
|
|
63
|
-
"aria-label":
|
|
61
|
+
"data-size": g,
|
|
62
|
+
disabled: _,
|
|
63
|
+
"aria-label": y,
|
|
64
64
|
children: /* @__PURE__ */ s(u, {})
|
|
65
65
|
})
|
|
66
66
|
})
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import e from "./progress.module.js";
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
3
|
//#region ../components/src/progress/progress.tsx
|
|
4
|
-
function n({ value: n, variant: r = "primary", size: i = "md", className: a, ariaLabel: o,
|
|
4
|
+
function n({ value: n, variant: r = "primary", size: i = "md", className: a, ariaLabel: o, label: s, ...c }) {
|
|
5
5
|
return /* @__PURE__ */ t("progress", {
|
|
6
|
-
"aria-label":
|
|
6
|
+
"aria-label": c["aria-label"] ?? o ?? s,
|
|
7
7
|
className: [e.progress, a].filter(Boolean).join(" "),
|
|
8
8
|
"data-variant": r,
|
|
9
9
|
"data-size": i,
|
|
10
10
|
value: n,
|
|
11
11
|
max: n === void 0 ? void 0 : 100,
|
|
12
|
-
...
|
|
12
|
+
...c
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
@@ -3,17 +3,17 @@ import { cn as t } from "@cascivo/core/pure";
|
|
|
3
3
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
4
|
//#region ../components/src/progress-circle/progress-circle.tsx
|
|
5
5
|
var i = 20, a = 2 * Math.PI * i;
|
|
6
|
-
function o({ value: o, max: s = 100, size: c = "md", showValue: l = !1, label: u,
|
|
7
|
-
let
|
|
6
|
+
function o({ value: o, max: s = 100, size: c = "md", showValue: l = !1, label: u, ariaLabel: d, className: f, ...p }) {
|
|
7
|
+
let m = Math.min(Math.max(o, 0), s), h = s > 0 ? m / s * 100 : 0, g = a * (1 - h / 100);
|
|
8
8
|
return /* @__PURE__ */ r("div", {
|
|
9
9
|
role: "progressbar",
|
|
10
10
|
"aria-valuemin": 0,
|
|
11
11
|
"aria-valuemax": s,
|
|
12
|
-
"aria-valuenow":
|
|
13
|
-
"aria-label": u,
|
|
12
|
+
"aria-valuenow": m,
|
|
13
|
+
"aria-label": d ?? u,
|
|
14
14
|
"data-size": c,
|
|
15
|
-
className: t(e.progressCircle,
|
|
16
|
-
...
|
|
15
|
+
className: t(e.progressCircle, f),
|
|
16
|
+
...p,
|
|
17
17
|
children: [/* @__PURE__ */ r("svg", {
|
|
18
18
|
viewBox: "0 0 48 48",
|
|
19
19
|
"aria-hidden": "true",
|
|
@@ -34,11 +34,11 @@ function o({ value: o, max: s = 100, size: c = "md", showValue: l = !1, label: u
|
|
|
34
34
|
strokeWidth: "4",
|
|
35
35
|
strokeLinecap: "round",
|
|
36
36
|
strokeDasharray: a,
|
|
37
|
-
strokeDashoffset:
|
|
37
|
+
strokeDashoffset: g
|
|
38
38
|
})]
|
|
39
39
|
}), l && /* @__PURE__ */ r("span", {
|
|
40
40
|
className: e.value,
|
|
41
|
-
children: [Math.round(
|
|
41
|
+
children: [Math.round(h), "%"]
|
|
42
42
|
})]
|
|
43
43
|
});
|
|
44
44
|
}
|
package/dist/qr-code/qr-code.js
CHANGED
|
@@ -7,31 +7,31 @@ import { builtin as i, t as a } from "@cascivo/i18n";
|
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
8
|
//#region ../components/src/qr-code/qr-code.tsx
|
|
9
9
|
var c = 4;
|
|
10
|
-
function l({ value: l, size: u = 128, errorCorrection: d = "M", radius: f, fill: p = "currentColor", background: m = "transparent", label: h,
|
|
10
|
+
function l({ value: l, size: u = 128, errorCorrection: d = "M", radius: f, fill: p = "currentColor", background: m = "transparent", label: h, ariaLabel: g, className: _, style: v, ...y }) {
|
|
11
11
|
if (r(), !l) return null;
|
|
12
|
-
let
|
|
13
|
-
for (let e = 0; e <
|
|
12
|
+
let b = e(l, d), x = b.length + c * 2, S = "";
|
|
13
|
+
for (let e = 0; e < b.length; e++) for (let t = 0; t < b.length; t++) b[e][t] && (S += `M${t + c},${e + c}h1v1h-1z`);
|
|
14
14
|
return /* @__PURE__ */ o("div", {
|
|
15
|
-
className: n(t.qrCode,
|
|
15
|
+
className: n(t.qrCode, _),
|
|
16
16
|
style: {
|
|
17
17
|
inlineSize: u,
|
|
18
18
|
blockSize: u,
|
|
19
19
|
borderRadius: f,
|
|
20
|
-
...
|
|
20
|
+
...v
|
|
21
21
|
},
|
|
22
|
-
...
|
|
22
|
+
...y,
|
|
23
23
|
children: /* @__PURE__ */ s("svg", {
|
|
24
24
|
className: t.svg,
|
|
25
25
|
role: "img",
|
|
26
|
-
"aria-label": h ?? a(i.qrCode.label),
|
|
27
|
-
viewBox: `0 0 ${
|
|
26
|
+
"aria-label": g ?? h ?? a(i.qrCode.label),
|
|
27
|
+
viewBox: `0 0 ${x} ${x}`,
|
|
28
28
|
shapeRendering: "crispEdges",
|
|
29
29
|
children: [/* @__PURE__ */ o("rect", {
|
|
30
|
-
width:
|
|
31
|
-
height:
|
|
30
|
+
width: x,
|
|
31
|
+
height: x,
|
|
32
32
|
fill: m
|
|
33
33
|
}), /* @__PURE__ */ o("path", {
|
|
34
|
-
d:
|
|
34
|
+
d: S,
|
|
35
35
|
fill: p
|
|
36
36
|
})]
|
|
37
37
|
})
|
|
@@ -2,24 +2,24 @@ import e from "./radial-progress.module.js";
|
|
|
2
2
|
import { useId as t } from "react";
|
|
3
3
|
import { jsx as n } from "react/jsx-runtime";
|
|
4
4
|
//#region ../components/src/radial-progress/radial-progress.tsx
|
|
5
|
-
function r({ value: r, size: i = "md", variant: a = "primary", children: o, className: s, ariaLabel: c,
|
|
6
|
-
let
|
|
5
|
+
function r({ value: r, size: i = "md", variant: a = "primary", children: o, className: s, ariaLabel: c, label: l, ...u }) {
|
|
6
|
+
let d = Math.min(100, Math.max(0, r)), f = t(), p = c ?? l;
|
|
7
7
|
return /* @__PURE__ */ n("div", {
|
|
8
8
|
role: "progressbar",
|
|
9
|
-
"aria-valuenow":
|
|
9
|
+
"aria-valuenow": d,
|
|
10
10
|
"aria-valuemin": 0,
|
|
11
11
|
"aria-valuemax": 100,
|
|
12
|
-
"aria-labelledby":
|
|
12
|
+
"aria-labelledby": p ?? u["aria-label"] ? void 0 : f,
|
|
13
13
|
className: [e.radialProgress, s].filter(Boolean).join(" "),
|
|
14
14
|
"data-size": i,
|
|
15
15
|
"data-variant": a,
|
|
16
|
-
style: { "--cascivo-radial-progress":
|
|
17
|
-
...
|
|
18
|
-
...
|
|
16
|
+
style: { "--cascivo-radial-progress": d },
|
|
17
|
+
...u,
|
|
18
|
+
...p === void 0 ? {} : { "aria-label": p },
|
|
19
19
|
children: /* @__PURE__ */ n("span", {
|
|
20
|
-
id:
|
|
20
|
+
id: f,
|
|
21
21
|
className: e.label,
|
|
22
|
-
children: o ?? `${
|
|
22
|
+
children: o ?? `${d}%`
|
|
23
23
|
})
|
|
24
24
|
});
|
|
25
25
|
}
|