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