@caspeco/casper-ui-library 4.0.0 → 4.0.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/dist/components/combobox/combobox-button.js +72 -73
- package/dist/components/combobox/combobox-menu.js +68 -69
- package/dist/components/combobox/combobox.js +104 -109
- package/dist/components/date-picker/base-date-picker.js +175 -176
- package/dist/components/date-picker/date-picker-header.js +10 -10
- package/dist/components/date-picker/helper.js +9 -9
- package/dist/components/image-upload/image-cropper.js +112 -113
- package/dist/components/image-upload/image-upload-dropzone.js +35 -36
- package/dist/components/menu/menu-group.js +44 -45
- package/dist/components/segmented-control/segmented-control.js +29 -29
- package/dist/components/table/table-cell.js +25 -26
- package/dist/components/table/table-header-dropdown.js +60 -60
- package/dist/components/table/table-header-row.js +19 -20
- package/dist/components/table/table-toolbar.js +63 -64
- package/dist/components/table/use-controllable-state.js +7 -7
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
- package/dist/node_modules/@tanstack/table-core/build/lib/index.js +41 -41
- package/dist/node_modules/date-fns/addDays.js +7 -7
- package/dist/node_modules/date-fns/addMonths.js +13 -13
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +11 -11
- package/dist/node_modules/date-fns/endOfDay.js +6 -6
- package/dist/node_modules/date-fns/endOfMonth.js +6 -6
- package/dist/node_modules/date-fns/format.js +46 -47
- package/dist/node_modules/date-fns/getDayOfYear.js +8 -8
- package/dist/node_modules/date-fns/getISOWeek.js +9 -9
- package/dist/node_modules/date-fns/getISOWeekYear.js +10 -10
- package/dist/node_modules/date-fns/getWeek.js +9 -9
- package/dist/node_modules/date-fns/getWeekYear.js +13 -14
- package/dist/node_modules/date-fns/isSameDay.js +9 -9
- package/dist/node_modules/date-fns/isSameMonth.js +9 -9
- package/dist/node_modules/date-fns/isSameWeek.js +8 -8
- package/dist/node_modules/date-fns/isSameYear.js +9 -9
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +12 -12
- package/dist/node_modules/date-fns/locale/da/_lib/formatDistance.js +4 -4
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +3 -3
- package/dist/node_modules/date-fns/locale/es/_lib/formatDistance.js +4 -4
- package/dist/node_modules/date-fns/locale/et/_lib/formatDistance.js +6 -6
- package/dist/node_modules/date-fns/locale/fi/_lib/formatDistance.js +17 -17
- package/dist/node_modules/date-fns/locale/lt/_lib/formatDistance.js +47 -47
- package/dist/node_modules/date-fns/locale/lv/_lib/formatDistance.js +11 -11
- package/dist/node_modules/date-fns/locale/nb/_lib/formatDistance.js +3 -3
- package/dist/node_modules/date-fns/locale/nl/_lib/formatDistance.js +4 -4
- package/dist/node_modules/date-fns/locale/sv/_lib/formatDistance.js +5 -5
- package/dist/node_modules/date-fns/startOfDay.js +6 -6
- package/dist/node_modules/date-fns/startOfMonth.js +6 -6
- package/dist/node_modules/date-fns/startOfWeek.js +7 -8
- package/dist/node_modules/date-fns/startOfWeekYear.js +9 -10
- package/dist/node_modules/date-fns/startOfYear.js +5 -5
- package/dist/theme/theme-config/components/modal-theme.js +13 -15
- package/dist/theme/theme-config/components/select-theme.js +15 -19
- package/package.json +2 -2
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { ComboboxButton as
|
|
5
|
-
import { ComboboxMenu as
|
|
6
|
-
import { translations as
|
|
7
|
-
const
|
|
8
|
-
const [n, e] =
|
|
9
|
-
var p;
|
|
1
|
+
import { jsxs as T, jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { Box as D } from "@chakra-ui/react";
|
|
3
|
+
import { useState as g, useRef as V, useEffect as M, useMemo as _ } from "react";
|
|
4
|
+
import { ComboboxButton as ee } from "./combobox-button.js";
|
|
5
|
+
import { ComboboxMenu as ne } from "./combobox-menu.js";
|
|
6
|
+
import { translations as te } from "./translations.js";
|
|
7
|
+
const re = (o, s) => {
|
|
8
|
+
const [n, e] = g(0), c = (l) => {
|
|
10
9
|
if (!s.current) return;
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const b = [...s.current.querySelectorAll("li")];
|
|
11
|
+
b[l] && (b[l]?.scrollIntoView({
|
|
13
12
|
behavior: "smooth",
|
|
14
13
|
block: "nearest"
|
|
15
14
|
}), e(l));
|
|
@@ -20,147 +19,143 @@ const ce = (o, s) => {
|
|
|
20
19
|
next: () => c((n + 1) % o.length),
|
|
21
20
|
previous: () => c((n - 1 + o.length) % o.length)
|
|
22
21
|
};
|
|
23
|
-
},
|
|
24
|
-
const [c,
|
|
25
|
-
return
|
|
26
|
-
e &&
|
|
27
|
-
}, [e,
|
|
28
|
-
s || n(""),
|
|
22
|
+
}, oe = (o, s, n, e) => {
|
|
23
|
+
const [c, t] = g(!1);
|
|
24
|
+
return M(() => {
|
|
25
|
+
e && t(!1);
|
|
26
|
+
}, [e, t]), { isOpen: c, close: () => {
|
|
27
|
+
s || n(""), t(!1);
|
|
29
28
|
}, open: () => {
|
|
30
|
-
c || e || (
|
|
29
|
+
c || e || (t(!0), o.set(0));
|
|
31
30
|
} };
|
|
32
|
-
},
|
|
33
|
-
const [n, e] =
|
|
31
|
+
}, le = (o, s) => {
|
|
32
|
+
const [n, e] = g([]), c = _(() => {
|
|
34
33
|
if (!n.length) return o;
|
|
35
|
-
const
|
|
34
|
+
const t = n[n.length - 1], h = {
|
|
36
35
|
id: "_back",
|
|
37
36
|
label: s.back
|
|
38
37
|
}, l = n[n.length - 1].children || [];
|
|
39
|
-
return
|
|
38
|
+
return t.isSelectableParent ? [h, t, ...l] : [h, ...l];
|
|
40
39
|
}, [n, o, s]);
|
|
41
40
|
return {
|
|
42
|
-
open: (
|
|
43
|
-
e((
|
|
41
|
+
open: (t) => {
|
|
42
|
+
e((h) => [...h, t]);
|
|
44
43
|
},
|
|
45
44
|
back: () => {
|
|
46
|
-
n.length && e((
|
|
45
|
+
n.length && e((t) => [...t.slice(0, n.length - 1)]);
|
|
47
46
|
},
|
|
48
47
|
opened: n,
|
|
49
48
|
current: c
|
|
50
49
|
};
|
|
51
|
-
},
|
|
50
|
+
}, ie = (o) => _(() => {
|
|
52
51
|
const s = {};
|
|
53
52
|
function n(e, c) {
|
|
54
|
-
s[e.id] = [...c], e.children && e.children.forEach((
|
|
53
|
+
s[e.id] = [...c], e.children && e.children.forEach((t) => n(t, [...c, e.label]));
|
|
55
54
|
}
|
|
56
55
|
return o.forEach((e) => n(e, [])), s;
|
|
57
56
|
}, [o]);
|
|
58
|
-
function
|
|
57
|
+
function pe({
|
|
59
58
|
id: o,
|
|
60
59
|
label: s = "",
|
|
61
60
|
isSingleSelect: n = !1,
|
|
62
61
|
selectedItems: e = [],
|
|
63
62
|
locale: c = "en-US",
|
|
64
|
-
size:
|
|
65
|
-
variant:
|
|
63
|
+
size: t = "md",
|
|
64
|
+
variant: h = "outline",
|
|
66
65
|
asPlainText: l = !1,
|
|
67
|
-
onSearch:
|
|
68
|
-
items:
|
|
69
|
-
maxVisibleItems:
|
|
70
|
-
onChange:
|
|
71
|
-
onBlur:
|
|
72
|
-
isDisabled:
|
|
73
|
-
isReadOnly:
|
|
74
|
-
isRequired:
|
|
75
|
-
placeholder:
|
|
76
|
-
isInvalid:
|
|
77
|
-
footerContent:
|
|
78
|
-
popoverWidth:
|
|
79
|
-
popoverPlacement:
|
|
80
|
-
collapsed:
|
|
81
|
-
...
|
|
66
|
+
onSearch: b,
|
|
67
|
+
items: I,
|
|
68
|
+
maxVisibleItems: L,
|
|
69
|
+
onChange: N,
|
|
70
|
+
onBlur: P,
|
|
71
|
+
isDisabled: S,
|
|
72
|
+
isReadOnly: x,
|
|
73
|
+
isRequired: m,
|
|
74
|
+
placeholder: U,
|
|
75
|
+
isInvalid: B,
|
|
76
|
+
footerContent: W,
|
|
77
|
+
popoverWidth: z,
|
|
78
|
+
popoverPlacement: G,
|
|
79
|
+
collapsed: J = !1,
|
|
80
|
+
...K
|
|
82
81
|
}) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
t.push(i), i.children && i.children.forEach(h);
|
|
82
|
+
const [v, p] = g(""), k = te[c], w = V(null), O = V(null), f = le(I, k), Q = v.toLowerCase() === e[0]?.label.toLowerCase(), C = v.length > 0 && !(l && Q);
|
|
83
|
+
let u = f.current;
|
|
84
|
+
if (C) {
|
|
85
|
+
const r = [], d = (i) => {
|
|
86
|
+
r.push(i), i.children && i.children.forEach(d);
|
|
89
87
|
};
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
return (!(i.children && i.children.length > 0) || i.isSelectableParent) &&
|
|
88
|
+
I.forEach(d), u = r.filter((i) => {
|
|
89
|
+
const A = i.label.toLowerCase().includes(v.toLowerCase());
|
|
90
|
+
return (!(i.children && i.children.length > 0) || i.isSelectableParent) && A;
|
|
93
91
|
});
|
|
94
92
|
}
|
|
95
|
-
const E =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
l && !a.isOpen && g(((t = e[0]) == null ? void 0 : t.label) || "");
|
|
93
|
+
const E = re(u, O), a = oe(E, l, p, S);
|
|
94
|
+
M(() => {
|
|
95
|
+
l && !a.isOpen && p(e[0]?.label || "");
|
|
99
96
|
}, [a.isOpen, e, l]);
|
|
100
|
-
const [q,
|
|
101
|
-
|
|
102
|
-
!a.isOpen || n ||
|
|
103
|
-
}, [a.isOpen]),
|
|
97
|
+
const [q, X] = g([]);
|
|
98
|
+
M(() => {
|
|
99
|
+
!a.isOpen || n || X(e);
|
|
100
|
+
}, [a.isOpen]), C || (u = [
|
|
104
101
|
...q,
|
|
105
|
-
...u.filter((
|
|
102
|
+
...u.filter((r) => !q.find((d) => d.label === r.label))
|
|
106
103
|
]);
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
if (v || x)
|
|
104
|
+
let j = !1;
|
|
105
|
+
x ? u = e : (j = u.length > (L ?? 1 / 0), u = u.slice(0, L));
|
|
106
|
+
const Y = ie(I), Z = (r) => {
|
|
107
|
+
if (x || S)
|
|
112
108
|
return;
|
|
113
|
-
if (
|
|
114
|
-
|
|
109
|
+
if (r.id === "_back") {
|
|
110
|
+
f.back();
|
|
115
111
|
return;
|
|
116
112
|
}
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
120
|
-
|
|
113
|
+
O.current?.parentNode?.querySelector("input")?.focus();
|
|
114
|
+
const d = f.opened.length > 0 && f.opened[f.opened.length - 1].id === r.id;
|
|
115
|
+
if (!C && !d && r.children && r.children.length > 0) {
|
|
116
|
+
f.open(r), requestAnimationFrame(() => E.set(1));
|
|
121
117
|
return;
|
|
122
118
|
}
|
|
123
|
-
let i = [
|
|
124
|
-
n || (e.some((
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}, V = {
|
|
119
|
+
let i = [r];
|
|
120
|
+
n || (e.some((H) => H.id === r.id) ? i = e.filter((H) => H.id !== r.id) : i = [...e, r]), p(l ? i[0]?.label : ""), n && (i.length === 0 ? a.open() : a.close()), N && N(i);
|
|
121
|
+
}, $ = e.length === 0 ? U ?? k.search : void 0, R = (r) => {
|
|
122
|
+
w.current?.contains(r.relatedTarget) || (a.close(), P && P(e));
|
|
123
|
+
}, y = {
|
|
129
124
|
id: o,
|
|
130
125
|
asPlainText: l,
|
|
131
|
-
inputValue:
|
|
126
|
+
inputValue: v,
|
|
132
127
|
selectedItems: e,
|
|
133
128
|
displayItems: u,
|
|
134
|
-
toggleItem:
|
|
129
|
+
toggleItem: Z,
|
|
135
130
|
highlightState: E,
|
|
136
131
|
openState: a,
|
|
137
|
-
parentStrings:
|
|
132
|
+
parentStrings: Y,
|
|
138
133
|
// Button
|
|
139
|
-
size:
|
|
140
|
-
variant:
|
|
134
|
+
size: t,
|
|
135
|
+
variant: h,
|
|
141
136
|
label: s,
|
|
142
|
-
placeHolderText:
|
|
143
|
-
isDisabled:
|
|
144
|
-
isReadOnly:
|
|
145
|
-
isInvalid:
|
|
146
|
-
collapsed:
|
|
147
|
-
setInputValue:
|
|
148
|
-
onSearch:
|
|
137
|
+
placeHolderText: $,
|
|
138
|
+
isDisabled: S,
|
|
139
|
+
isReadOnly: x,
|
|
140
|
+
isInvalid: B,
|
|
141
|
+
collapsed: J,
|
|
142
|
+
setInputValue: p,
|
|
143
|
+
onSearch: b,
|
|
149
144
|
// Menu
|
|
150
145
|
isSingleSelect: n,
|
|
151
|
-
isSearching:
|
|
152
|
-
isHidingItems:
|
|
153
|
-
popoverWidth:
|
|
154
|
-
popoverPlacement:
|
|
146
|
+
isSearching: C,
|
|
147
|
+
isHidingItems: j,
|
|
148
|
+
popoverWidth: z,
|
|
149
|
+
popoverPlacement: G,
|
|
155
150
|
previousSelectedItems: q,
|
|
156
151
|
parentRef: w,
|
|
157
152
|
popupRef: O,
|
|
158
|
-
footerContent:
|
|
159
|
-
subMenuState:
|
|
153
|
+
footerContent: W,
|
|
154
|
+
subMenuState: f,
|
|
160
155
|
translation: k
|
|
161
156
|
};
|
|
162
|
-
return /* @__PURE__ */
|
|
163
|
-
|
|
157
|
+
return /* @__PURE__ */ T(
|
|
158
|
+
D,
|
|
164
159
|
{
|
|
165
160
|
role: "combobox",
|
|
166
161
|
as: "label",
|
|
@@ -168,22 +163,22 @@ function xe({
|
|
|
168
163
|
className: "combobox",
|
|
169
164
|
ref: w,
|
|
170
165
|
onClick: a.open,
|
|
171
|
-
onBlur:
|
|
166
|
+
onBlur: R,
|
|
172
167
|
overflow: "visible",
|
|
173
168
|
width: "100%",
|
|
174
169
|
"aria-expanded": a.isOpen,
|
|
175
|
-
"aria-invalid":
|
|
176
|
-
"aria-required":
|
|
177
|
-
"aria-disabled":
|
|
178
|
-
"aria-readonly":
|
|
179
|
-
...
|
|
170
|
+
"aria-invalid": B,
|
|
171
|
+
"aria-required": m,
|
|
172
|
+
"aria-disabled": S,
|
|
173
|
+
"aria-readonly": x,
|
|
174
|
+
...K,
|
|
180
175
|
children: [
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
a.isOpen && /* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ F(ee, { ...y }),
|
|
177
|
+
a.isOpen && /* @__PURE__ */ F(ne, { ...y })
|
|
183
178
|
]
|
|
184
179
|
}
|
|
185
180
|
);
|
|
186
181
|
}
|
|
187
182
|
export {
|
|
188
|
-
|
|
183
|
+
pe as Combobox
|
|
189
184
|
};
|