wimui 0.50.4 → 0.51.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/data-display/Calendar/Calendar.cjs +1 -1
- package/dist/components/data-display/Calendar/Calendar.js +116 -71
- package/dist/components/data-display/TreeView/TreeView.cjs +1 -1
- package/dist/components/data-display/TreeView/TreeView.js +194 -179
- package/dist/components/form/Combobox/Combobox.cjs +1 -1
- package/dist/components/form/Combobox/Combobox.js +2 -1
- package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/form/DatePicker/DatePicker.js +3 -2
- package/dist/components/form/Input/Input.cjs +1 -1
- package/dist/components/form/Input/Input.d.ts +7 -0
- package/dist/components/form/Input/Input.js +51 -50
- package/dist/components/form/InputBase/InputBase.cjs +1 -1
- package/dist/components/form/InputBase/InputBase.d.ts +7 -0
- package/dist/components/form/InputBase/InputBase.js +5 -1
- package/dist/components/form/InputBase/input-base.module.cjs +1 -1
- package/dist/components/form/InputBase/input-base.module.js +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.cjs +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.js +6 -0
- package/dist/components/form/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/form/TimePicker/TimePicker.js +1 -0
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.js +5 -1
- package/dist/llms-full.txt +33 -1
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -6,22 +6,22 @@ import { BaseListItem as r } from "../../_internal/BaseListItem/BaseListItem.js"
|
|
|
6
6
|
import { VirtualList as i } from "../VirtualList/VirtualList.js";
|
|
7
7
|
import a from "./tree-view.module.js";
|
|
8
8
|
import { useTreeViewItemExpansion as o } from "./useTreeViewItemExpansion.js";
|
|
9
|
-
import s, { createContext as c, useCallback as l, useContext as u,
|
|
10
|
-
import
|
|
11
|
-
import { jsx as
|
|
9
|
+
import s, { createContext as c, useCallback as l, useContext as u, useEffect as d, useMemo as f, useState as p } from "react";
|
|
10
|
+
import m from "classnames";
|
|
11
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/data-display/TreeView/TreeView.tsx
|
|
13
|
-
var
|
|
14
|
-
let e = u(
|
|
13
|
+
var _ = c(null), v = () => {
|
|
14
|
+
let e = u(_);
|
|
15
15
|
if (!e) throw Error("TreeView components must be used within a TreeView");
|
|
16
16
|
return e;
|
|
17
|
-
},
|
|
18
|
-
function
|
|
17
|
+
}, ee = 40, y = 100;
|
|
18
|
+
function b(e) {
|
|
19
19
|
return typeof e == "string" ? e : typeof e == "number" ? String(e) : "";
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function x(e, t, n, r = 0) {
|
|
22
22
|
let i = [];
|
|
23
23
|
for (let a of e) {
|
|
24
|
-
let e =
|
|
24
|
+
let e = b(a.label), o = !n || e.toLowerCase().includes(n.toLowerCase()), s = n && a.children ? S(a.children, n) : !1;
|
|
25
25
|
if (n && !o && !s) continue;
|
|
26
26
|
i.push({
|
|
27
27
|
...a,
|
|
@@ -29,14 +29,14 @@ function b(e, t, n, r = 0) {
|
|
|
29
29
|
hasChildren: !!(a.children && a.children.length > 0)
|
|
30
30
|
});
|
|
31
31
|
let c = t.includes(a.value) || !!n && s;
|
|
32
|
-
a.children && a.children.length > 0 && c && i.push(...
|
|
32
|
+
a.children && a.children.length > 0 && c && i.push(...x(a.children, t, n, r + 1));
|
|
33
33
|
}
|
|
34
34
|
return i;
|
|
35
35
|
}
|
|
36
|
-
function x(e, t) {
|
|
37
|
-
return e.some((e) => y(e.label).toLowerCase().includes(t.toLowerCase()) || (e.children ? x(e.children, t) : !1));
|
|
38
|
-
}
|
|
39
36
|
function S(e, t) {
|
|
37
|
+
return e.some((e) => b(e.label).toLowerCase().includes(t.toLowerCase()) || (e.children ? S(e.children, t) : !1));
|
|
38
|
+
}
|
|
39
|
+
function C(e, t) {
|
|
40
40
|
for (let n of e) {
|
|
41
41
|
if (n.value === t) {
|
|
42
42
|
let e = [], t = (n) => {
|
|
@@ -45,23 +45,23 @@ function S(e, t) {
|
|
|
45
45
|
return n.children && t(n.children), e;
|
|
46
46
|
}
|
|
47
47
|
if (n.children) {
|
|
48
|
-
let e =
|
|
48
|
+
let e = C(n.children, t);
|
|
49
49
|
if (e !== null) return e;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function w(e, t, n = []) {
|
|
55
55
|
for (let r of e) {
|
|
56
56
|
if (r.value === t) return n;
|
|
57
57
|
if (r.children) {
|
|
58
|
-
let e =
|
|
58
|
+
let e = w(r.children, t, [...n, r.value]);
|
|
59
59
|
if (e !== null) return e;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function T(e, t) {
|
|
65
65
|
let n = [], r = new Set(t);
|
|
66
66
|
function i(e) {
|
|
67
67
|
if (!e.children?.length) return r.has(e.value) ? "checked" : "unchecked";
|
|
@@ -74,181 +74,196 @@ function w(e, t) {
|
|
|
74
74
|
effectiveCheckedSet: r
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
var
|
|
78
|
-
let { t:
|
|
77
|
+
var E = ({ children: o, nodes: c, className: u, multiSelect: v = !1, checkable: S = !1, checkStrategy: E = "cascade", searchable: D = !1, defaultExpandedValues: O = [], defaultSelectedValues: k = [], defaultCheckedValues: A = [], onCheckedChange: j, onSelectedChange: M, width: te, virtualThreshold: ne = y, labels: N = {}, labelId: re, styles: P }) => {
|
|
78
|
+
let { t: F } = e("components"), { searchPlaceholder: I, searchAriaLabel: L = F("treeview.search_aria"), expandLabel: R = (e) => F("treeview.expand", { label: e }), collapseLabel: z = (e) => F("treeview.collapse", { label: e }) } = N, [B, V] = p(O), [H, ie] = p(k), [U, ae] = p(A), [W, oe] = p(""), [G, K] = p(k[0] || null), q = s.useRef(null), { indeterminateValues: J, effectiveCheckedSet: se } = f(() => !c || E !== "cascade" ? {
|
|
79
79
|
indeterminateValues: [],
|
|
80
|
-
effectiveCheckedSet: new Set(
|
|
81
|
-
} :
|
|
80
|
+
effectiveCheckedSet: new Set(U)
|
|
81
|
+
} : T(c, new Set(U)), [
|
|
82
82
|
c,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
]),
|
|
86
|
-
|
|
87
|
-
}, []),
|
|
88
|
-
if (
|
|
83
|
+
E,
|
|
84
|
+
U
|
|
85
|
+
]), Y = l((e) => {
|
|
86
|
+
V((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
87
|
+
}, []), X = l((e) => {
|
|
88
|
+
if (v) ie((t) => {
|
|
89
89
|
let n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
|
|
90
|
-
return
|
|
90
|
+
return M?.(n), n;
|
|
91
91
|
});
|
|
92
92
|
else {
|
|
93
93
|
let t = [e];
|
|
94
|
-
|
|
94
|
+
ie(t), M?.(t);
|
|
95
95
|
}
|
|
96
|
-
}, [
|
|
97
|
-
|
|
96
|
+
}, [v, M]), Z = l((e) => {
|
|
97
|
+
ae((t) => {
|
|
98
98
|
let n;
|
|
99
|
-
if (!c) return n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e],
|
|
100
|
-
if (
|
|
101
|
-
let { indeterminateValues: r } =
|
|
99
|
+
if (!c) return n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e], j?.(n), n;
|
|
100
|
+
if (E === "cascade") {
|
|
101
|
+
let { indeterminateValues: r } = T(c, new Set(t)), i = t.includes(e) && !r.includes(e), a = [e, ...C(c, e) ?? []];
|
|
102
102
|
n = i ? t.filter((e) => !a.includes(e)) : [...t, ...a.filter((e) => !t.includes(e))];
|
|
103
|
-
let { indeterminateValues: o, effectiveCheckedSet: s } =
|
|
104
|
-
|
|
103
|
+
let { indeterminateValues: o, effectiveCheckedSet: s } = T(c, new Set(n));
|
|
104
|
+
j?.([...s].filter((e) => !o.includes(e)));
|
|
105
105
|
} else {
|
|
106
106
|
if (t.includes(e)) n = t.filter((t) => t !== e);
|
|
107
107
|
else {
|
|
108
|
-
let r =
|
|
108
|
+
let r = w(c, e) ?? [], i = C(c, e) ?? [], a = /* @__PURE__ */ new Set([...r, ...i]);
|
|
109
109
|
n = [...t.filter((e) => !a.has(e)), e];
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
j?.(n);
|
|
112
112
|
}
|
|
113
113
|
return n;
|
|
114
114
|
});
|
|
115
115
|
}, [
|
|
116
|
-
|
|
116
|
+
E,
|
|
117
117
|
c,
|
|
118
|
-
|
|
119
|
-
]),
|
|
120
|
-
expandedValues:
|
|
121
|
-
selectedValues:
|
|
122
|
-
checkedValues:
|
|
123
|
-
indeterminateValues:
|
|
124
|
-
focusedValue:
|
|
125
|
-
toggleExpand:
|
|
126
|
-
select:
|
|
127
|
-
toggleCheck:
|
|
128
|
-
setFocusedValue:
|
|
129
|
-
containerRef:
|
|
130
|
-
multiSelect:
|
|
131
|
-
checkable:
|
|
132
|
-
checkStrategy:
|
|
133
|
-
searchQuery:
|
|
118
|
+
j
|
|
119
|
+
]), ce = f(() => ({
|
|
120
|
+
expandedValues: B,
|
|
121
|
+
selectedValues: H,
|
|
122
|
+
checkedValues: U,
|
|
123
|
+
indeterminateValues: J,
|
|
124
|
+
focusedValue: G,
|
|
125
|
+
toggleExpand: Y,
|
|
126
|
+
select: X,
|
|
127
|
+
toggleCheck: Z,
|
|
128
|
+
setFocusedValue: K,
|
|
129
|
+
containerRef: q,
|
|
130
|
+
multiSelect: v,
|
|
131
|
+
checkable: S,
|
|
132
|
+
checkStrategy: E,
|
|
133
|
+
searchQuery: W,
|
|
134
134
|
labels: {
|
|
135
|
-
expandLabel:
|
|
136
|
-
collapseLabel:
|
|
135
|
+
expandLabel: R,
|
|
136
|
+
collapseLabel: z
|
|
137
137
|
}
|
|
138
138
|
}), [
|
|
139
|
-
|
|
139
|
+
B,
|
|
140
|
+
H,
|
|
140
141
|
U,
|
|
141
|
-
|
|
142
|
+
J,
|
|
143
|
+
G,
|
|
142
144
|
Y,
|
|
143
|
-
K,
|
|
144
145
|
X,
|
|
145
146
|
Z,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
z
|
|
152
|
-
|
|
153
|
-
]), $ = d(() => c ? b(c, V, G) : [], [
|
|
147
|
+
v,
|
|
148
|
+
S,
|
|
149
|
+
E,
|
|
150
|
+
W,
|
|
151
|
+
R,
|
|
152
|
+
z
|
|
153
|
+
]), Q = f(() => c ? x(c, B, W) : [], [
|
|
154
154
|
c,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
]),
|
|
155
|
+
B,
|
|
156
|
+
W
|
|
157
|
+
]), le = !!c && Q.length >= ne, $ = l((e) => {
|
|
158
|
+
let t = q.current;
|
|
159
|
+
if (!t || !e) return;
|
|
160
|
+
let n = Array.from(t.querySelectorAll("[role=\"treeitem\"]")).find((t) => t.getAttribute("data-value") === e);
|
|
161
|
+
n && n !== document.activeElement && n.focus();
|
|
162
|
+
}, []);
|
|
163
|
+
d(() => {
|
|
164
|
+
if (!c || !G) return;
|
|
165
|
+
let e = q.current, t = document.activeElement;
|
|
166
|
+
e && t && e.contains(t) && (t instanceof HTMLInputElement || $(G));
|
|
167
|
+
}, [
|
|
168
|
+
c,
|
|
169
|
+
G,
|
|
170
|
+
$
|
|
171
|
+
]);
|
|
172
|
+
let ue = l((e, t, n) => {
|
|
158
173
|
switch (e.key) {
|
|
159
174
|
case "Enter":
|
|
160
175
|
case " ":
|
|
161
|
-
e.preventDefault(),
|
|
176
|
+
e.preventDefault(), X(t.value), S && Z(t.value);
|
|
162
177
|
break;
|
|
163
178
|
case "ArrowDown":
|
|
164
|
-
e.preventDefault(), n <
|
|
179
|
+
e.preventDefault(), n < Q.length - 1 && K(Q[n + 1].value);
|
|
165
180
|
break;
|
|
166
181
|
case "ArrowUp":
|
|
167
|
-
e.preventDefault(), n > 0 &&
|
|
182
|
+
e.preventDefault(), n > 0 && K(Q[n - 1].value);
|
|
168
183
|
break;
|
|
169
184
|
case "Home":
|
|
170
|
-
e.preventDefault(),
|
|
185
|
+
e.preventDefault(), Q.length > 0 && K(Q[0].value);
|
|
171
186
|
break;
|
|
172
187
|
case "End":
|
|
173
|
-
e.preventDefault(),
|
|
188
|
+
e.preventDefault(), Q.length > 0 && K(Q[Q.length - 1].value);
|
|
174
189
|
break;
|
|
175
190
|
case "ArrowRight":
|
|
176
|
-
e.preventDefault(), t.hasChildren && !
|
|
191
|
+
e.preventDefault(), t.hasChildren && !B.includes(t.value) ? Y(t.value) : t.hasChildren && n < Q.length - 1 && K(Q[n + 1].value);
|
|
177
192
|
break;
|
|
178
|
-
case "ArrowLeft": if (e.preventDefault(), t.hasChildren &&
|
|
179
|
-
else for (let e = n - 1; e >= 0; e--) if (
|
|
180
|
-
|
|
193
|
+
case "ArrowLeft": if (e.preventDefault(), t.hasChildren && B.includes(t.value)) Y(t.value);
|
|
194
|
+
else for (let e = n - 1; e >= 0; e--) if (Q[e].depth < t.depth) {
|
|
195
|
+
K(Q[e].value);
|
|
181
196
|
break;
|
|
182
197
|
}
|
|
183
198
|
}
|
|
184
199
|
}, [
|
|
185
|
-
$,
|
|
186
|
-
V,
|
|
187
|
-
Z,
|
|
188
|
-
x,
|
|
189
200
|
Q,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
B,
|
|
202
|
+
X,
|
|
203
|
+
S,
|
|
204
|
+
Z,
|
|
205
|
+
Y
|
|
206
|
+
]), de = l((e, i) => {
|
|
207
|
+
let o = H.includes(e.value), s = se.has(e.value), c = J.includes(e.value), l = B.includes(e.value), u = G === e.value, d = b(e.label);
|
|
208
|
+
return /* @__PURE__ */ h("div", {
|
|
209
|
+
className: m(a.item, o && a.selected, e.disabled && a.disabled, P?.item),
|
|
195
210
|
role: "treeitem",
|
|
196
211
|
"aria-expanded": e.hasChildren ? l : void 0,
|
|
197
212
|
"aria-selected": o,
|
|
198
213
|
"aria-disabled": e.disabled,
|
|
199
|
-
"aria-setsize":
|
|
214
|
+
"aria-setsize": Q.length,
|
|
200
215
|
"aria-posinset": i + 1,
|
|
201
216
|
"aria-level": e.depth + 1,
|
|
202
217
|
"data-value": e.value,
|
|
203
218
|
tabIndex: u ? 0 : -1,
|
|
204
219
|
onClick: (t) => {
|
|
205
|
-
t.stopPropagation(),
|
|
220
|
+
t.stopPropagation(), K(e.value), e.disabled || (v && S ? Z(e.value) : X(e.value));
|
|
206
221
|
},
|
|
207
222
|
onKeyDown: (t) => {
|
|
208
|
-
t.key !== "Tab" && t.stopPropagation(),
|
|
223
|
+
t.key !== "Tab" && t.key !== "Escape" && t.stopPropagation(), ue(t, e, i);
|
|
209
224
|
},
|
|
210
225
|
onFocus: (t) => {
|
|
211
|
-
t.stopPropagation(),
|
|
226
|
+
t.stopPropagation(), K(e.value);
|
|
212
227
|
},
|
|
213
228
|
style: { paddingLeft: e.depth * 20 },
|
|
214
|
-
children: /* @__PURE__ */
|
|
215
|
-
className:
|
|
229
|
+
children: /* @__PURE__ */ h(r, {
|
|
230
|
+
className: m(a.labelContainer, P?.labelContainer),
|
|
216
231
|
active: o,
|
|
217
232
|
disabled: e.disabled,
|
|
218
|
-
icon: /* @__PURE__ */
|
|
219
|
-
className:
|
|
233
|
+
icon: /* @__PURE__ */ g("div", {
|
|
234
|
+
className: m(a.iconWrapper, P?.iconWrapper),
|
|
220
235
|
children: [
|
|
221
|
-
e.hasChildren ? /* @__PURE__ */
|
|
236
|
+
e.hasChildren ? /* @__PURE__ */ h("button", {
|
|
222
237
|
type: "button",
|
|
223
|
-
className:
|
|
238
|
+
className: m(a.expandBtn, l && a.expanded, P?.expandBtn),
|
|
224
239
|
onClick: (t) => {
|
|
225
|
-
t.stopPropagation(), e.disabled ||
|
|
240
|
+
t.stopPropagation(), e.disabled || Y(e.value);
|
|
226
241
|
},
|
|
227
242
|
disabled: e.disabled,
|
|
228
|
-
"aria-label": l ?
|
|
243
|
+
"aria-label": l ? z(d) : R(d),
|
|
229
244
|
tabIndex: -1,
|
|
230
|
-
children: /* @__PURE__ */
|
|
245
|
+
children: /* @__PURE__ */ h(n, {
|
|
231
246
|
component: t,
|
|
232
247
|
size: "sm"
|
|
233
248
|
})
|
|
234
|
-
}) : /* @__PURE__ */
|
|
235
|
-
|
|
249
|
+
}) : /* @__PURE__ */ h("span", { className: a.spacer }),
|
|
250
|
+
S && /* @__PURE__ */ h("input", {
|
|
236
251
|
type: "checkbox",
|
|
237
|
-
className:
|
|
252
|
+
className: m(a.checkbox, P?.checkbox),
|
|
238
253
|
checked: s && !c,
|
|
239
254
|
ref: (e) => {
|
|
240
255
|
e && (e.indeterminate = c);
|
|
241
256
|
},
|
|
242
257
|
onChange: (t) => {
|
|
243
|
-
t.stopPropagation(), e.disabled ||
|
|
258
|
+
t.stopPropagation(), e.disabled || Z(e.value);
|
|
244
259
|
},
|
|
245
260
|
disabled: e.disabled,
|
|
246
261
|
onClick: (e) => e.stopPropagation(),
|
|
247
262
|
"aria-label": d,
|
|
248
263
|
tabIndex: -1
|
|
249
264
|
}),
|
|
250
|
-
e.icon && /* @__PURE__ */
|
|
251
|
-
className:
|
|
265
|
+
e.icon && /* @__PURE__ */ h("span", {
|
|
266
|
+
className: m(a.icon, P?.icon),
|
|
252
267
|
children: e.icon
|
|
253
268
|
})
|
|
254
269
|
]
|
|
@@ -257,83 +272,83 @@ var T = ({ children: o, nodes: c, className: u, multiSelect: _ = !1, checkable:
|
|
|
257
272
|
})
|
|
258
273
|
}, e.value);
|
|
259
274
|
}, [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
Z,
|
|
269
|
-
Q,
|
|
275
|
+
H,
|
|
276
|
+
se,
|
|
277
|
+
J,
|
|
278
|
+
B,
|
|
279
|
+
G,
|
|
280
|
+
Q.length,
|
|
281
|
+
v,
|
|
282
|
+
S,
|
|
270
283
|
X,
|
|
271
|
-
|
|
284
|
+
Z,
|
|
285
|
+
Y,
|
|
286
|
+
ue,
|
|
287
|
+
R,
|
|
272
288
|
z,
|
|
273
|
-
|
|
274
|
-
F
|
|
289
|
+
P
|
|
275
290
|
]);
|
|
276
|
-
return /* @__PURE__ */
|
|
277
|
-
value:
|
|
278
|
-
children: /* @__PURE__ */
|
|
279
|
-
ref:
|
|
291
|
+
return /* @__PURE__ */ h(_.Provider, {
|
|
292
|
+
value: ce,
|
|
293
|
+
children: /* @__PURE__ */ g("div", {
|
|
294
|
+
ref: q,
|
|
280
295
|
"data-testid": "tree-view-root",
|
|
281
|
-
className:
|
|
296
|
+
className: m("wim-tree-view", a.root, !!c && a.dataDriven, u, P?.root),
|
|
282
297
|
role: "tree",
|
|
283
298
|
"aria-label": N.treeAriaLabel,
|
|
284
|
-
"aria-labelledby": N.treeAriaLabel ? void 0 :
|
|
299
|
+
"aria-labelledby": N.treeAriaLabel ? void 0 : re,
|
|
285
300
|
style: {
|
|
286
|
-
width:
|
|
301
|
+
width: te,
|
|
287
302
|
maxWidth: "100%"
|
|
288
303
|
},
|
|
289
|
-
tabIndex:
|
|
304
|
+
tabIndex: G ? -1 : 0,
|
|
290
305
|
onFocus: (e) => {
|
|
291
|
-
e.target ===
|
|
306
|
+
e.target === q.current && (c ? G ? $(G) : Q.length > 0 && (K(Q[0].value), $(Q[0].value)) : G ? (q.current?.querySelector(`[role="treeitem"][data-value="${G}"]`))?.focus() : (q.current?.querySelector("[role=\"treeitem\"]"))?.focus());
|
|
292
307
|
},
|
|
293
|
-
children: [
|
|
294
|
-
className:
|
|
295
|
-
children: /* @__PURE__ */
|
|
308
|
+
children: [D && /* @__PURE__ */ h("div", {
|
|
309
|
+
className: m(a.search, P?.search),
|
|
310
|
+
children: /* @__PURE__ */ h("input", {
|
|
296
311
|
type: "text",
|
|
297
312
|
"data-testid": "tree-view-search-input",
|
|
298
|
-
className:
|
|
299
|
-
placeholder:
|
|
300
|
-
value:
|
|
301
|
-
onChange: (e) =>
|
|
302
|
-
"aria-label":
|
|
313
|
+
className: m(a.searchInput, P?.searchInput),
|
|
314
|
+
placeholder: I,
|
|
315
|
+
value: W,
|
|
316
|
+
onChange: (e) => oe(e.target.value),
|
|
317
|
+
"aria-label": L
|
|
303
318
|
})
|
|
304
|
-
}), c ?
|
|
305
|
-
items:
|
|
306
|
-
itemHeight:
|
|
319
|
+
}), c ? le ? /* @__PURE__ */ h(i, {
|
|
320
|
+
items: Q,
|
|
321
|
+
itemHeight: ee,
|
|
307
322
|
height: 400,
|
|
308
|
-
renderItem:
|
|
323
|
+
renderItem: de,
|
|
309
324
|
itemRole: "none",
|
|
310
325
|
role: "presentation"
|
|
311
|
-
}) :
|
|
326
|
+
}) : Q.map((e, t) => de(e, t)) : o]
|
|
312
327
|
})
|
|
313
328
|
});
|
|
314
|
-
},
|
|
315
|
-
let { expandedValues: f, selectedValues:
|
|
329
|
+
}, D = ({ value: e, label: i, icon: c, children: l, className: u, disabled: d = !1 }) => {
|
|
330
|
+
let { expandedValues: f, selectedValues: p, checkedValues: _, indeterminateValues: ee, focusedValue: y, toggleExpand: x, select: S, toggleCheck: C, setFocusedValue: w, containerRef: T, multiSelect: E, checkable: O, searchQuery: k } = v(), A = s.useId(), j = `wim-tree-view-item-checkbox-${A}`, M = `wim-tree-view-item-label-${A}`, te = b(i), ne = !k || te.toLowerCase().includes(k.toLowerCase()), N = s.useMemo(() => {
|
|
316
331
|
if (!k || !l) return !1;
|
|
317
332
|
let e = (t) => s.Children.toArray(t).some((t) => {
|
|
318
|
-
if (!s.isValidElement(t) || t.type !==
|
|
333
|
+
if (!s.isValidElement(t) || t.type !== D) return !1;
|
|
319
334
|
let n = t.props, r = n.label;
|
|
320
|
-
return
|
|
335
|
+
return b(r).toLowerCase().includes(k.toLowerCase()) ? !0 : n.children ? e(n.children) : !1;
|
|
321
336
|
});
|
|
322
337
|
return e(l);
|
|
323
|
-
}, [l, k]),
|
|
324
|
-
return k && !
|
|
325
|
-
className:
|
|
338
|
+
}, [l, k]), re = !!k && N, P = f.includes(e) || re, F = p.includes(e), I = _.includes(e), L = ee.includes(e), R = !!s.Children.count(l), { shouldRender: z, isVisualExpanded: B, handleTransitionEnd: V } = o(P);
|
|
339
|
+
return k && !ne && !N ? null : /* @__PURE__ */ g("div", {
|
|
340
|
+
className: m(a.item, F && a.selected, d && a.disabled, u),
|
|
326
341
|
role: "treeitem",
|
|
327
|
-
"aria-expanded":
|
|
328
|
-
"aria-selected":
|
|
342
|
+
"aria-expanded": R ? P : void 0,
|
|
343
|
+
"aria-selected": F,
|
|
329
344
|
"aria-disabled": d,
|
|
330
345
|
"data-value": e,
|
|
331
346
|
onClick: (t) => {
|
|
332
|
-
t.stopPropagation(), w(e), d || (
|
|
347
|
+
t.stopPropagation(), w(e), d || (E && O ? C(e) : S(e));
|
|
333
348
|
},
|
|
334
349
|
onKeyDown: (t) => {
|
|
335
350
|
if (d) return;
|
|
336
|
-
t.key !== "Tab" && t.stopPropagation();
|
|
351
|
+
t.key !== "Tab" && t.key !== "Escape" && t.stopPropagation();
|
|
337
352
|
let n = Array.from(T.current?.querySelectorAll("[role=\"treeitem\"]:not([aria-disabled=\"true\"])") || []), r = n.indexOf(t.currentTarget);
|
|
338
353
|
switch (t.key) {
|
|
339
354
|
case "Enter":
|
|
@@ -353,9 +368,9 @@ var T = ({ children: o, nodes: c, className: u, multiSelect: _ = !1, checkable:
|
|
|
353
368
|
t.preventDefault(), n.length > 0 && n[n.length - 1].focus();
|
|
354
369
|
break;
|
|
355
370
|
case "ArrowRight":
|
|
356
|
-
|
|
371
|
+
R && (P ? (t.preventDefault(), r < n.length - 1 && n[r + 1].focus()) : (t.preventDefault(), x(e)));
|
|
357
372
|
break;
|
|
358
|
-
case "ArrowLeft": if (
|
|
373
|
+
case "ArrowLeft": if (R && P) t.preventDefault(), x(e);
|
|
359
374
|
else {
|
|
360
375
|
t.preventDefault();
|
|
361
376
|
let e = t.currentTarget.parentElement?.closest("[role=\"treeitem\"]");
|
|
@@ -366,37 +381,37 @@ var T = ({ children: o, nodes: c, className: u, multiSelect: _ = !1, checkable:
|
|
|
366
381
|
onFocus: (t) => {
|
|
367
382
|
t.stopPropagation(), w(e);
|
|
368
383
|
},
|
|
369
|
-
tabIndex:
|
|
370
|
-
children: [/* @__PURE__ */
|
|
384
|
+
tabIndex: y === e ? 0 : -1,
|
|
385
|
+
children: [/* @__PURE__ */ h(r, {
|
|
371
386
|
id: M,
|
|
372
387
|
className: a.labelContainer,
|
|
373
|
-
active:
|
|
388
|
+
active: F,
|
|
374
389
|
disabled: d,
|
|
375
|
-
icon: /* @__PURE__ */
|
|
390
|
+
icon: /* @__PURE__ */ g("div", {
|
|
376
391
|
className: a.iconWrapper,
|
|
377
392
|
children: [
|
|
378
|
-
|
|
393
|
+
R && /* @__PURE__ */ h("button", {
|
|
379
394
|
type: "button",
|
|
380
|
-
className:
|
|
395
|
+
className: m(a.expandBtn, P && a.expanded),
|
|
381
396
|
onClick: (t) => {
|
|
382
|
-
t.stopPropagation(), !d &&
|
|
397
|
+
t.stopPropagation(), !d && R && x(e);
|
|
383
398
|
},
|
|
384
399
|
disabled: d,
|
|
385
|
-
"aria-label":
|
|
400
|
+
"aria-label": P ? `Collapse ${typeof i == "string" ? i : ""}` : `Expand ${typeof i == "string" ? i : ""}`,
|
|
386
401
|
tabIndex: -1,
|
|
387
|
-
children: /* @__PURE__ */
|
|
402
|
+
children: /* @__PURE__ */ h(n, {
|
|
388
403
|
component: t,
|
|
389
404
|
size: "sm"
|
|
390
405
|
})
|
|
391
406
|
}),
|
|
392
|
-
!
|
|
393
|
-
O && /* @__PURE__ */
|
|
407
|
+
!R && /* @__PURE__ */ h("span", { className: a.spacer }),
|
|
408
|
+
O && /* @__PURE__ */ h("input", {
|
|
394
409
|
id: j,
|
|
395
410
|
type: "checkbox",
|
|
396
411
|
className: a.checkbox,
|
|
397
|
-
checked:
|
|
412
|
+
checked: I && !L,
|
|
398
413
|
ref: (e) => {
|
|
399
|
-
e && (e.indeterminate =
|
|
414
|
+
e && (e.indeterminate = L);
|
|
400
415
|
},
|
|
401
416
|
onChange: (t) => {
|
|
402
417
|
t.stopPropagation(), d || C(e);
|
|
@@ -406,18 +421,18 @@ var T = ({ children: o, nodes: c, className: u, multiSelect: _ = !1, checkable:
|
|
|
406
421
|
"aria-labelledby": M,
|
|
407
422
|
tabIndex: -1
|
|
408
423
|
}),
|
|
409
|
-
c && /* @__PURE__ */
|
|
424
|
+
c && /* @__PURE__ */ h("span", {
|
|
410
425
|
className: a.icon,
|
|
411
426
|
children: c
|
|
412
427
|
})
|
|
413
428
|
]
|
|
414
429
|
}),
|
|
415
430
|
children: i
|
|
416
|
-
}),
|
|
417
|
-
className:
|
|
418
|
-
onTransitionEnd:
|
|
419
|
-
style: { gridTemplateRows:
|
|
420
|
-
children: /* @__PURE__ */
|
|
431
|
+
}), R && z && /* @__PURE__ */ h("div", {
|
|
432
|
+
className: m(a.children, B && a.expanded),
|
|
433
|
+
onTransitionEnd: V,
|
|
434
|
+
style: { gridTemplateRows: B ? "1fr" : "0fr" },
|
|
435
|
+
children: /* @__PURE__ */ h("div", {
|
|
421
436
|
className: a.childrenInner,
|
|
422
437
|
role: "group",
|
|
423
438
|
children: l
|
|
@@ -425,8 +440,8 @@ var T = ({ children: o, nodes: c, className: u, multiSelect: _ = !1, checkable:
|
|
|
425
440
|
})]
|
|
426
441
|
});
|
|
427
442
|
};
|
|
428
|
-
|
|
429
|
-
var
|
|
430
|
-
|
|
443
|
+
E.displayName = "TreeView", D.displayName = "TreeView.Item";
|
|
444
|
+
var O = E;
|
|
445
|
+
O.Item = D;
|
|
431
446
|
//#endregion
|
|
432
|
-
export {
|
|
447
|
+
export { O as TreeView, O as default, D as TreeViewItem };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../_internal/BaseListItem/BaseListItem.cjs"),n=require("../InputBase/InputBase.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("./combobox.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=({options:e=[],onChange:c,placeholder:l,showSearchIcon:u=!0,allowClear:d=!0,defaultValue:f=``,className:p,disabled:m=!1,label:h,error:g,required:_,layout:v,fullWidth:y=!1,id:b,labels:x={},...S})=>{let{noResults:C=`No results found`}=x,[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(f),[O,k]=(0,a.useState)(-1),[A,j]=(0,a.useState)(!1),M=(0,a.useRef)(null),N=(0,a.useId)(),P=b||`wim-combobox-${N}`,F=`${P}-list`,I=h?`${P}-label`:void 0,L=g?`${P}-error`:void 0,R=(0,a.useMemo)(()=>{let t=(E||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,E]);(0,a.useEffect)(()=>{let e=e=>{M.current&&!M.current.contains(e.target)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let z=e=>{let t=e.target.value;D(t),T(!0),k(-1)},B=e=>{D(e.label),T(!1),c&&c(e)};return(0,s.jsx)(r.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:I,htmlFor:P,errorId:L,className:p,children:(0,s.jsxs)(`div`,{className:(0,o.default)(`wim-combobox`,i.default.root,y&&i.default.fullWidth),ref:M,onMouseMove:()=>j(!1),"data-keyboard-nav":A,children:[(0,s.jsx)(n.InputBase,{disabled:m,allowClear:d,hasValue:!!E,onClear:()=>D(``),intent:g?`danger`:`default`,leftIcon:u?`SearchIcon`:void 0,fullWidth:y,rightIcons:[{name:`ChevronDownIcon`,rotated:w,onClick:()=>T(!w)}],children:(0,s.jsx)(`input`,{id:P,className:i.default.input,placeholder:l,value:E,onChange:z,onKeyDown:e=>{if(j(!0),!w&&e.key===`ArrowDown`){T(!0);return}switch(e.key){case`ArrowDown`:k(e=>e<R.length-1?e+1:0);break;case`ArrowUp`:k(e=>e<=0?R.length-1:e-1);break;case`Enter`:O>=0&&O<R.length&&B(R[O]);break;case`Escape`:T(!1);break;case`Tab`:T(!1)}},onFocus:()=>T(!0),disabled:m,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":w?F:void 0,"aria-labelledby":I,"aria-describedby":L,required:_,"aria-invalid":!!g,"aria-activedescendant":w&&O>=0?`${F}-option-${O}`:void 0,...S})}),w&&R.length>0&&(0,s.jsx)(`div`,{className:i.default.dropdown,children:(0,s.jsx)(`ul`,{id:F,className:i.default.list,role:`listbox`,"aria-labelledby":I,children:R.map((e,n)=>(0,s.jsx)(t.BaseListItem,{asChild:!0,id:`${F}-option-${n}`,className:(0,o.default)(i.default.option,n===O&&i.default.selected),active:n===O,onClick:()=>B(e),onMouseEnter:()=>k(n),role:`option`,"aria-selected":n===O,children:(0,s.jsx)(`li`,{children:e.label})},e.value))})}),w&&R.length===0&&(0,s.jsx)(`div`,{className:i.default.dropdown,children:(0,s.jsx)(`div`,{className:i.default.empty,role:`region`,"aria-live":`polite`,children:C})})]})})};c.displayName=`Combobox`,exports.Combobox=c;
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../_internal/BaseListItem/BaseListItem.cjs"),n=require("../InputBase/InputBase.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("./combobox.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=({options:e=[],onChange:c,placeholder:l,showSearchIcon:u=!0,allowClear:d=!0,defaultValue:f=``,className:p,disabled:m=!1,label:h,error:g,required:_,layout:v,fullWidth:y=!1,id:b,labels:x={},...S})=>{let{noResults:C=`No results found`}=x,[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(f),[O,k]=(0,a.useState)(-1),[A,j]=(0,a.useState)(!1),M=(0,a.useRef)(null),N=(0,a.useId)(),P=b||`wim-combobox-${N}`,F=`${P}-list`,I=h?`${P}-label`:void 0,L=g?`${P}-error`:void 0,R=(0,a.useMemo)(()=>{let t=(E||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,E]);(0,a.useEffect)(()=>{let e=e=>{M.current&&!M.current.contains(e.target)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let z=e=>{let t=e.target.value;D(t),T(!0),k(-1)},B=e=>{D(e.label),T(!1),c&&c(e)};return(0,s.jsx)(r.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:I,htmlFor:P,errorId:L,className:p,children:(0,s.jsxs)(`div`,{className:(0,o.default)(`wim-combobox`,i.default.root,y&&i.default.fullWidth),ref:M,onMouseMove:()=>j(!1),"data-keyboard-nav":A,children:[(0,s.jsx)(n.InputBase,{disabled:m,allowClear:d,hasValue:!!E,onClear:()=>D(``),intent:g?`danger`:`default`,leftIcon:u?`SearchIcon`:void 0,fullWidth:y,rightIcons:[{name:`ChevronDownIcon`,rotated:w,onClick:()=>T(!w),decorative:!0}],children:(0,s.jsx)(`input`,{id:P,className:i.default.input,placeholder:l,value:E,onChange:z,onKeyDown:e=>{if(j(!0),!w&&e.key===`ArrowDown`){T(!0);return}switch(e.key){case`ArrowDown`:k(e=>e<R.length-1?e+1:0);break;case`ArrowUp`:k(e=>e<=0?R.length-1:e-1);break;case`Enter`:O>=0&&O<R.length&&B(R[O]);break;case`Escape`:T(!1);break;case`Tab`:T(!1)}},onFocus:()=>T(!0),disabled:m,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":w?F:void 0,"aria-labelledby":I,"aria-describedby":L,required:_,"aria-invalid":!!g,"aria-activedescendant":w&&O>=0?`${F}-option-${O}`:void 0,...S})}),w&&R.length>0&&(0,s.jsx)(`div`,{className:i.default.dropdown,children:(0,s.jsx)(`ul`,{id:F,className:i.default.list,role:`listbox`,"aria-labelledby":I,children:R.map((e,n)=>(0,s.jsx)(t.BaseListItem,{asChild:!0,id:`${F}-option-${n}`,className:(0,o.default)(i.default.option,n===O&&i.default.selected),active:n===O,onClick:()=>B(e),onMouseEnter:()=>k(n),role:`option`,"aria-selected":n===O,children:(0,s.jsx)(`li`,{children:e.label})},e.value))})}),w&&R.length===0&&(0,s.jsx)(`div`,{className:i.default.dropdown,children:(0,s.jsx)(`div`,{className:i.default.empty,role:`region`,"aria-live":`polite`,children:C})})]})})};c.displayName=`Combobox`,exports.Combobox=c;
|
|
@@ -50,7 +50,8 @@ var f = ({ options: f = [], onChange: p, placeholder: m, showSearchIcon: h = !0,
|
|
|
50
50
|
rightIcons: [{
|
|
51
51
|
name: "ChevronDownIcon",
|
|
52
52
|
rotated: k,
|
|
53
|
-
onClick: () => A(!k)
|
|
53
|
+
onClick: () => A(!k),
|
|
54
|
+
decorative: !0
|
|
54
55
|
}],
|
|
55
56
|
children: /* @__PURE__ */ u("input", {
|
|
56
57
|
id: z,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("../Input/input.module.cjs"),c=require("../../data-display/Calendar/Calendar.cjs"),l=require("../../_internal/mergeRefs.cjs"),u=require("./date-picker.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=(0,d.forwardRef)(({intent:e=`default`,variant:m=`outline`,fullWidth:h=!1,className:g,disabled:_,value:v,defaultValue:y,onChange:b,format:x=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:ee,maxDate:te,disabledDates:ne,label:w,error:T,required:E,layout:D,id:re,labels:O,width:k,asChild:A=!1,children:j,...M},N)=>{let[P,F]=(0,d.useState)(!1),[I,L]=(0,d.useState)(y||null),R=(0,d.useRef)(null),z=(0,d.useRef)(null),B=l.mergeRefs(R,N),{t:V}=n.useWimTranslation(`components`),H=(0,d.useId)(),U=re||`wim-datepicker-${H}`,W=`${U}-dropdown`,G=w?`${U}-label`:void 0,K=T?`${U}-error`:void 0,q=v!==void 0,J=q?v:I,Y=C??O?.placeholder,X=_,Z=T?`danger`:e;(0,d.useEffect)(()=>{let e=e=>{R.current&&!R.current.contains(e.target)&&F(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&P&&(F(!1),z.current?.focus())};return P&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[P]);let Q=e=>{if(!e)return``;let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`);return x.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},ie=e=>{q||L(e),b?.(e),F(!1),z.current?.focus()},ae=e=>{e?.stopPropagation(),X||(q||L(null),b?.(null))},$=()=>{X||F(!P)};return(0,d.useEffect)(()=>{if(P){let e=setTimeout(()=>{let e=R.current?.querySelector(`[data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():R.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[P]),(0,p.jsx)(o.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:G,htmlFor:U,errorId:K,className:g,children:(0,p.jsxs)(A?t.Root:`div`,{ref:B,className:(0,f.default)(`wim-date-picker`,u.default.root,h&&u.default.fullWidth),children:[(0,p.jsxs)(t.Slottable,{children:[(0,p.jsx)(a.InputBase,{intent:Z,variant:m,width:k,fullWidth:h,disabled:X,allowClear:S,hasValue:!!J,onClear:ae,rightIcons:[{name:`ChevronDownIcon`,rotated:P,onClick
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("../Input/input.module.cjs"),c=require("../../data-display/Calendar/Calendar.cjs"),l=require("../../_internal/mergeRefs.cjs"),u=require("./date-picker.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=(0,d.forwardRef)(({intent:e=`default`,variant:m=`outline`,fullWidth:h=!1,className:g,disabled:_,value:v,defaultValue:y,onChange:b,format:x=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:ee,maxDate:te,disabledDates:ne,label:w,error:T,required:E,layout:D,id:re,labels:O,width:k,asChild:A=!1,children:j,...M},N)=>{let[P,F]=(0,d.useState)(!1),[I,L]=(0,d.useState)(y||null),R=(0,d.useRef)(null),z=(0,d.useRef)(null),B=l.mergeRefs(R,N),{t:V}=n.useWimTranslation(`components`),H=(0,d.useId)(),U=re||`wim-datepicker-${H}`,W=`${U}-dropdown`,G=w?`${U}-label`:void 0,K=T?`${U}-error`:void 0,q=v!==void 0,J=q?v:I,Y=C??O?.placeholder,X=_,Z=T?`danger`:e;(0,d.useEffect)(()=>{let e=e=>{R.current&&!R.current.contains(e.target)&&F(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&P&&(F(!1),z.current?.focus())};return P&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[P]);let Q=e=>{if(!e)return``;let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`);return x.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},ie=e=>{q||L(e),b?.(e),F(!1),z.current?.focus()},ae=e=>{e?.stopPropagation(),X||(q||L(null),b?.(null))},$=()=>{X||F(!P)};return(0,d.useEffect)(()=>{if(P){let e=setTimeout(()=>{let e=R.current?.querySelector(`[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():R.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[P]),(0,p.jsx)(o.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:G,htmlFor:U,errorId:K,className:g,children:(0,p.jsxs)(A?t.Root:`div`,{ref:B,className:(0,f.default)(`wim-date-picker`,u.default.root,h&&u.default.fullWidth),children:[(0,p.jsxs)(t.Slottable,{children:[(0,p.jsx)(a.InputBase,{intent:Z,variant:m,width:k,fullWidth:h,disabled:X,allowClear:S,hasValue:!!J,onClear:ae,rightIcons:[{name:`ChevronDownIcon`,rotated:P,onClick:$,decorative:!0}],children:(0,p.jsx)(`input`,{id:U,ref:z,type:`text`,readOnly:!0,role:`combobox`,className:(0,f.default)(s.default.root,u.default.input),value:Q(J),placeholder:Y,disabled:X,onClick:$,onKeyDown:e=>{X||(e.key===`Escape`?(F(!1),z.current?.focus()):(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`&&(e.altKey||!P))&&(e.preventDefault(),F(!P)))},"aria-haspopup":`dialog`,"aria-expanded":P,"aria-controls":P?W:void 0,"aria-invalid":Z===`danger`,"aria-describedby":K,"aria-labelledby":G,"aria-required":E,...M})}),(0,p.jsx)(r.Transition,{show:P&&!_,preset:`fade`,id:W,className:u.default.dropdown,children:(0,p.jsx)(i.FocusTrap,{active:P,initialFocus:!1,children:(0,p.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":G,"aria-label":G?void 0:M[`aria-label`]??V(`datepicker.dialog`),children:(0,p.jsx)(c.Calendar,{value:J??void 0,onChange:ie})})})})]}),j]})})});m.displayName=`DatePicker`,exports.DatePicker=m,exports.default=m;
|