@cascivo/react 0.16.1 → 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.
- 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/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/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/field/field.css +1 -1
- package/dist/field/field.module.js +3 -3
- package/dist/index.d.ts +72 -4
- 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/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/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/field/field.module.js +3 -3
- 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 +2 -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 +2 -3
- package/dist/switcher/switcher.js +1 -1
- package/dist/tabs/tabs.js +5 -4
- package/dist/toc/toc.js +5 -4
- package/package.json +3 -3
|
@@ -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,
|
|
6
|
-
import { builtin as
|
|
7
|
-
import { jsx as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
32
|
+
function _(e, t) {
|
|
33
33
|
return new Intl.DateTimeFormat(t).format(e);
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function v(e) {
|
|
36
36
|
return e.toISOString().slice(0, 10);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
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
|
|
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 [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
c(()
|
|
48
|
-
|
|
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
|
-
|
|
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
|
|
55
|
-
O ||
|
|
56
|
-
},
|
|
57
|
-
|
|
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 && (
|
|
60
|
+
e.stopPropagation(), a === void 0 && (H.value = void 0), Y?.(void 0);
|
|
60
61
|
}, se = () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}) :
|
|
62
|
+
W.value === 0 ? r(() => {
|
|
63
|
+
U.value--, W.value = 11;
|
|
64
|
+
}) : W.value--;
|
|
64
65
|
}, ce = () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}) :
|
|
68
|
-
},
|
|
69
|
-
let n = new Date(Date.UTC(2024, 0, 7 +
|
|
70
|
-
return
|
|
71
|
-
}), Q = new Intl.DateTimeFormat(
|
|
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(
|
|
75
|
-
let t =
|
|
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 =
|
|
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(),
|
|
84
|
+
e.preventDefault(), X(t);
|
|
84
85
|
return;
|
|
85
86
|
} else if (e.key === "Escape") {
|
|
86
|
-
|
|
87
|
+
J();
|
|
87
88
|
return;
|
|
88
89
|
} else return;
|
|
89
90
|
if (e.preventDefault(), i) {
|
|
90
|
-
let e =
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
}, $ =
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
ref:
|
|
99
|
-
className: i(e.wrapper,
|
|
100
|
-
"data-state":
|
|
101
|
-
"data-size":
|
|
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
|
-
|
|
104
|
+
T && /* @__PURE__ */ p("label", {
|
|
104
105
|
className: e.label,
|
|
105
|
-
htmlFor:
|
|
106
|
-
children:
|
|
106
|
+
htmlFor: N,
|
|
107
|
+
children: T
|
|
107
108
|
}),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ m("div", {
|
|
109
110
|
className: e.field,
|
|
110
|
-
children: [/* @__PURE__ */
|
|
111
|
-
id:
|
|
111
|
+
children: [/* @__PURE__ */ m("button", {
|
|
112
|
+
id: N,
|
|
112
113
|
type: "button",
|
|
113
114
|
role: "combobox",
|
|
114
|
-
"aria-expanded":
|
|
115
|
-
"aria-controls":
|
|
115
|
+
"aria-expanded": A.value === "open",
|
|
116
|
+
"aria-controls": P,
|
|
116
117
|
"aria-haspopup": "dialog",
|
|
117
|
-
"aria-invalid":
|
|
118
|
-
"aria-describedby":
|
|
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:
|
|
122
|
-
children: [/* @__PURE__ */
|
|
122
|
+
onClick: A.value === "open" ? J : q,
|
|
123
|
+
children: [/* @__PURE__ */ p("span", {
|
|
123
124
|
className: i(e.value, $ ? void 0 : e.placeholder),
|
|
124
|
-
children: $ ||
|
|
125
|
-
}), /* @__PURE__ */
|
|
125
|
+
children: $ || I
|
|
126
|
+
}), /* @__PURE__ */ p("span", {
|
|
126
127
|
className: e.icon,
|
|
127
128
|
"aria-hidden": "true",
|
|
128
129
|
children: "📅"
|
|
129
130
|
})]
|
|
130
|
-
}),
|
|
131
|
+
}), w && H.value !== void 0 && /* @__PURE__ */ p("button", {
|
|
131
132
|
type: "button",
|
|
132
133
|
className: e.clear,
|
|
133
|
-
"aria-label":
|
|
134
|
+
"aria-label": z,
|
|
134
135
|
onClick: oe,
|
|
135
136
|
children: "✕"
|
|
136
137
|
})]
|
|
137
138
|
}),
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
id:
|
|
139
|
+
/* @__PURE__ */ m("div", {
|
|
140
|
+
id: P,
|
|
140
141
|
role: "dialog",
|
|
141
142
|
"aria-label": Q,
|
|
142
143
|
className: e.calendar,
|
|
143
|
-
"data-state":
|
|
144
|
-
onKeyDown:
|
|
145
|
-
children: [/* @__PURE__ */
|
|
144
|
+
"data-state": A.value,
|
|
145
|
+
onKeyDown: fe,
|
|
146
|
+
children: [/* @__PURE__ */ m("div", {
|
|
146
147
|
className: e.header,
|
|
147
148
|
children: [
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ p("button", {
|
|
149
150
|
type: "button",
|
|
150
151
|
className: e.navButton,
|
|
151
|
-
"aria-label":
|
|
152
|
+
"aria-label": L,
|
|
152
153
|
onClick: se,
|
|
153
154
|
children: "‹"
|
|
154
155
|
}),
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ p("span", {
|
|
156
157
|
className: e.monthLabel,
|
|
157
158
|
"aria-live": "polite",
|
|
158
159
|
children: Q
|
|
159
160
|
}),
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ p("button", {
|
|
161
162
|
type: "button",
|
|
162
163
|
className: e.navButton,
|
|
163
|
-
"aria-label":
|
|
164
|
+
"aria-label": R,
|
|
164
165
|
onClick: ce,
|
|
165
166
|
children: "›"
|
|
166
167
|
})
|
|
167
168
|
]
|
|
168
|
-
}), /* @__PURE__ */
|
|
169
|
+
}), /* @__PURE__ */ m("table", {
|
|
169
170
|
role: "grid",
|
|
170
171
|
className: e.grid,
|
|
171
|
-
children: [/* @__PURE__ */
|
|
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__ */
|
|
177
|
-
if (!t) return /* @__PURE__ */
|
|
178
|
-
let r =
|
|
179
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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":
|
|
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 ||
|
|
193
|
+
s || X(r);
|
|
193
194
|
},
|
|
194
195
|
onFocus: () => {
|
|
195
|
-
|
|
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
|
-
|
|
204
|
-
id: `${
|
|
204
|
+
D && /* @__PURE__ */ p("span", {
|
|
205
|
+
id: `${M}-error`,
|
|
205
206
|
className: e.error,
|
|
206
207
|
role: "alert",
|
|
207
|
-
children:
|
|
208
|
+
children: D
|
|
208
209
|
}),
|
|
209
|
-
!
|
|
210
|
-
id: `${
|
|
210
|
+
!D && E && /* @__PURE__ */ p("span", {
|
|
211
|
+
id: `${M}-hint`,
|
|
211
212
|
className: e.hint,
|
|
212
|
-
children:
|
|
213
|
+
children: E
|
|
213
214
|
})
|
|
214
215
|
]
|
|
215
216
|
});
|
|
216
217
|
}
|
|
217
218
|
//#endregion
|
|
218
|
-
export {
|
|
219
|
+
export { b as DatePicker };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var e = {
|
|
2
|
-
"grid-container": "_grid-
|
|
3
|
-
grid: "
|
|
4
|
-
"grid-item": "_grid-
|
|
2
|
+
"grid-container": "_grid-container_1tchk_5",
|
|
3
|
+
grid: "_grid_1tchk_2",
|
|
4
|
+
"grid-item": "_grid-item_1tchk_55"
|
|
5
5
|
};
|
|
6
6
|
//#endregion
|
|
7
7
|
export { e as default };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import e from "./search.module.js";
|
|
4
4
|
import { useRef as t } from "react";
|
|
5
|
-
import { cn as n, focusElement as r,
|
|
5
|
+
import { cn as n, focusElement as r, useControllableSignal as i, useId as a, useSignalEffect as o, useSignals as s } from "@cascivo/core";
|
|
6
6
|
import { builtin as c, t as l } from "@cascivo/i18n";
|
|
7
7
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
8
|
//#region ../components/src/search/search.tsx
|
|
@@ -30,9 +30,10 @@ function f() {
|
|
|
30
30
|
}
|
|
31
31
|
function p({ value: p, defaultValue: m = "", onValueChange: h, onChange: g, onSearch: _, debounceMs: v = 300, placeholder: y, size: b = "md", label: x, disabled: S = !1, clearLabel: C, id: w, className: T }) {
|
|
32
32
|
s();
|
|
33
|
-
let E = y ?? l(c.search.placeholder), D = x ?? l(c.search.label), O = C ?? l(c.search.clear), k = t(null), A =
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let E = y ?? l(c.search.placeholder), D = x ?? l(c.search.label), O = C ?? l(c.search.clear), k = t(null), A = a("cascade-search"), j = w ?? A, M = p !== void 0, [N] = i({
|
|
34
|
+
value: p,
|
|
35
|
+
defaultValue: m
|
|
36
|
+
}), P = t(_);
|
|
36
37
|
P.current = _;
|
|
37
38
|
let F = t(null), I = () => {
|
|
38
39
|
F.current !== null && (clearTimeout(F.current), F.current = null);
|