wimui 0.60.0 → 0.61.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/components/_internal/useInlineFloating.cjs +2 -0
- package/dist/components/_internal/useInlineFloating.d.ts +54 -0
- package/dist/components/_internal/useInlineFloating.js +61 -0
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +96 -89
- package/dist/components/ai/ModelSelector/model-selector.module.cjs +1 -1
- package/dist/components/ai/ModelSelector/model-selector.module.js +1 -1
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.js +89 -85
- package/dist/components/form/Cascader/cascader.module.cjs +1 -1
- package/dist/components/form/Cascader/cascader.module.js +6 -6
- package/dist/components/form/Combobox/Combobox.cjs +1 -1
- package/dist/components/form/Combobox/Combobox.js +108 -102
- package/dist/components/form/Combobox/combobox.module.cjs +1 -1
- package/dist/components/form/Combobox/combobox.module.js +1 -1
- package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/form/DatePicker/DatePicker.js +90 -85
- package/dist/components/form/DatePicker/date-picker.module.cjs +1 -1
- package/dist/components/form/DatePicker/date-picker.module.js +1 -1
- package/dist/components/form/Mentions/Mentions.cjs +1 -1
- package/dist/components/form/Mentions/Mentions.js +4 -4
- package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/form/MultiSelect/MultiSelect.js +80 -77
- package/dist/components/form/MultiSelect/multiselect.module.cjs +1 -1
- package/dist/components/form/MultiSelect/multiselect.module.js +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.js +117 -111
- package/dist/components/form/PhoneInput/phone-input.module.cjs +1 -1
- package/dist/components/form/PhoneInput/phone-input.module.js +1 -1
- package/dist/components/form/Select/Select.cjs +1 -1
- package/dist/components/form/Select/Select.js +96 -89
- package/dist/components/form/Select/select.module.cjs +1 -1
- package/dist/components/form/Select/select.module.js +1 -1
- package/dist/components/form/SplitButton/SplitButton.cjs +1 -1
- package/dist/components/form/SplitButton/SplitButton.js +35 -31
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.js +115 -112
- package/dist/components/form/TreeSelect/tree-select.module.cjs +1 -1
- package/dist/components/form/TreeSelect/tree-select.module.js +6 -6
- package/dist/components/navigation/Anchor/Anchor.cjs +1 -1
- package/dist/components/navigation/Anchor/Anchor.d.ts +5 -1
- package/dist/components/navigation/Anchor/Anchor.js +32 -29
- package/dist/components/navigation/Menubar/Menubar.cjs +1 -1
- package/dist/components/navigation/Menubar/Menubar.js +102 -92
- package/dist/components/navigation/Menubar/menubar.module.cjs +1 -1
- package/dist/components/navigation/Menubar/menubar.module.js +1 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.d.ts +7 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.js +7 -6
- package/dist/components/overlay/HoverCard/HoverCard.cjs +1 -1
- package/dist/components/overlay/HoverCard/HoverCard.js +49 -43
- package/dist/components/overlay/HoverCard/hover-card.module.cjs +1 -1
- package/dist/components/overlay/HoverCard/hover-card.module.js +1 -1
- package/dist/llms-full.txt +3 -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 +4 -4
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import t from "
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import a from "
|
|
8
|
-
import {
|
|
9
|
-
import s
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
2
|
+
import { useMergedRef as e } from "../../../hooks/useMergedRef.js";
|
|
3
|
+
import { Transition as t } from "../../layout/Transition/Transition.js";
|
|
4
|
+
import n from "../../../icon/chevron-right.js";
|
|
5
|
+
import { Icon as r } from "../../media/Icon/Icon.js";
|
|
6
|
+
import { BaseListItem as i } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
7
|
+
import { InputBase as a } from "../InputBase/InputBase.js";
|
|
8
|
+
import { useInlineFloating as o } from "../../_internal/useInlineFloating.js";
|
|
9
|
+
import s from "./cascader.module.js";
|
|
10
|
+
import { FieldTemplate as c } from "../FieldTemplate/FieldTemplate.js";
|
|
11
|
+
import l, { useEffect as u, useId as ee, useRef as d, useState as f } from "react";
|
|
12
|
+
import p from "classnames";
|
|
13
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
12
14
|
//#region src/components/form/Cascader/Cascader.tsx
|
|
13
|
-
function
|
|
15
|
+
function g(e) {
|
|
14
16
|
return typeof e == "string" ? e : typeof e == "number" ? String(e) : "";
|
|
15
17
|
}
|
|
16
|
-
var
|
|
17
|
-
let
|
|
18
|
-
|
|
18
|
+
var _ = ({ options: _ = [], value: v, onChange: y, placeholder: b, label: x, error: S, required: C, layout: te, className: ne, disabled: w = !1, defaultValue: T, id: re, expandTrigger: ie = "click", separator: E = " / ", allowClear: ae = !1, "aria-label": D, "aria-labelledby": oe, "aria-describedby": O, width: se, fullWidth: ce = !1, ...le }) => {
|
|
19
|
+
let ue = ee(), k = re || `wim-cascader-${ue}`, A = x ? `${k}-label` : void 0, j = S ? `${k}-error` : void 0, M = A ?? oe, de = `${k}-trigger`, N = `${k}-popup`, [P, F] = f(!1), [fe, I] = f(T || []), [L, R] = f([]), [z, B] = f(-1), [V, H] = f([]), [pe, U] = f(!1), W = d(null), G = d(null), K = v !== void 0, q = K ? v : fe;
|
|
20
|
+
u(() => {
|
|
19
21
|
let e = (e) => {
|
|
20
22
|
W.current && !W.current.contains(e.target) && F(!1);
|
|
21
23
|
};
|
|
22
24
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
23
|
-
}, []),
|
|
25
|
+
}, []), u(() => {
|
|
24
26
|
if (P && z >= 0) {
|
|
25
27
|
let e = V[z], t = `${k}-menu-${z}-option-${e}`, n = W.current?.querySelector(`#${t}`);
|
|
26
28
|
n && n.scrollIntoView({
|
|
@@ -35,44 +37,44 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
35
37
|
k
|
|
36
38
|
]);
|
|
37
39
|
let J = () => {
|
|
38
|
-
if (!
|
|
40
|
+
if (!w) {
|
|
39
41
|
let e = !P;
|
|
40
42
|
F(e), e ? (R(q || []), B(0), H([0])) : B(-1);
|
|
41
43
|
}
|
|
42
|
-
},
|
|
44
|
+
}, me = () => {
|
|
43
45
|
if (!q || q.length === 0) return null;
|
|
44
|
-
let e = [], t =
|
|
46
|
+
let e = [], t = _;
|
|
45
47
|
for (let n of q) {
|
|
46
48
|
let r = t.find((e) => e.value === n);
|
|
47
49
|
if (r) e.push(r.label), t = r.children || [];
|
|
48
50
|
else break;
|
|
49
51
|
}
|
|
50
|
-
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */
|
|
52
|
+
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ h(l.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ m("span", { children: E })] }, n));
|
|
51
53
|
}, Y = (e, t) => {
|
|
52
54
|
if (e.disabled) return;
|
|
53
55
|
let n = [...L.slice(0, t), e.value];
|
|
54
56
|
if (R(n), !e.children || e.children.length === 0) {
|
|
55
|
-
if (K || I(n),
|
|
56
|
-
let e = [], t =
|
|
57
|
+
if (K || I(n), y) {
|
|
58
|
+
let e = [], t = _;
|
|
57
59
|
for (let r of n) {
|
|
58
60
|
let n = t.find((e) => e.value === r);
|
|
59
61
|
n && (e.push(n), t = n.children || []);
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
y(n, e);
|
|
62
64
|
}
|
|
63
65
|
F(!1), G.current?.focus();
|
|
64
66
|
}
|
|
65
|
-
}, pe = (e) => {
|
|
66
|
-
e?.stopPropagation(), !C && (K || I([]), v && v([], []));
|
|
67
|
-
}, me = (e, t) => {
|
|
68
|
-
T === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
|
|
69
67
|
}, he = (e) => {
|
|
70
|
-
|
|
68
|
+
e?.stopPropagation(), !w && (K || I([]), y && y([], []));
|
|
69
|
+
}, ge = (e, t) => {
|
|
70
|
+
ie === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
|
|
71
|
+
}, _e = (e) => {
|
|
72
|
+
if (U(!0), w) return;
|
|
71
73
|
if (!P) {
|
|
72
74
|
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" || e.key === "ArrowDown" && e.altKey) && (e.preventDefault(), J());
|
|
73
75
|
return;
|
|
74
76
|
}
|
|
75
|
-
let t = [
|
|
77
|
+
let t = [_], n = _;
|
|
76
78
|
for (let e = 0; e < L.length; e++) {
|
|
77
79
|
let r = L[e], i = n.find((e) => e.value === r);
|
|
78
80
|
if (i && i.children && i.children.length > 0) t.push(i.children), n = i.children;
|
|
@@ -125,110 +127,112 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
125
127
|
break;
|
|
126
128
|
case "Tab": P && (F(!1), B(-1));
|
|
127
129
|
}
|
|
128
|
-
}, X = [
|
|
130
|
+
}, X = [_], Z = _;
|
|
129
131
|
for (let e = 0; e < L.length; e++) {
|
|
130
132
|
let t = L[e], n = Z.find((e) => e.value === t);
|
|
131
133
|
if (n && n.children && n.children.length > 0) X.push(n.children), Z = n.children;
|
|
132
134
|
else break;
|
|
133
135
|
}
|
|
134
|
-
let Q =
|
|
136
|
+
let Q = me(), $ = () => {
|
|
135
137
|
if (!q || q.length === 0) return "";
|
|
136
|
-
let e = [], t =
|
|
138
|
+
let e = [], t = _;
|
|
137
139
|
for (let n of q) {
|
|
138
140
|
let r = t.find((e) => e.value === n);
|
|
139
|
-
if (r) e.push(
|
|
141
|
+
if (r) e.push(g(r.label)), t = r.children || [];
|
|
140
142
|
else break;
|
|
141
143
|
}
|
|
142
144
|
return e.join(E);
|
|
143
|
-
};
|
|
144
|
-
return /* @__PURE__ */
|
|
145
|
-
label:
|
|
146
|
-
error:
|
|
147
|
-
required:
|
|
148
|
-
layout:
|
|
145
|
+
}, { setReference: ve, setFloating: ye, floatingProps: be } = o({ open: P && !w }), xe = e(W, ve);
|
|
146
|
+
return /* @__PURE__ */ m(c, {
|
|
147
|
+
label: x,
|
|
148
|
+
error: S,
|
|
149
|
+
required: C,
|
|
150
|
+
layout: te,
|
|
149
151
|
labelId: A,
|
|
150
152
|
errorId: j,
|
|
151
|
-
className:
|
|
152
|
-
children: /* @__PURE__ */
|
|
153
|
-
className:
|
|
154
|
-
ref:
|
|
153
|
+
className: p("wim-cascader", ne),
|
|
154
|
+
children: /* @__PURE__ */ h("div", {
|
|
155
|
+
className: s.root,
|
|
156
|
+
ref: xe,
|
|
155
157
|
onMouseMove: () => U(!1),
|
|
156
|
-
"data-keyboard-nav":
|
|
157
|
-
...
|
|
158
|
-
children: [/* @__PURE__ */
|
|
159
|
-
disabled:
|
|
160
|
-
allowClear:
|
|
158
|
+
"data-keyboard-nav": pe,
|
|
159
|
+
...le,
|
|
160
|
+
children: [/* @__PURE__ */ m(a, {
|
|
161
|
+
disabled: w,
|
|
162
|
+
allowClear: ae,
|
|
161
163
|
hasValue: !!Q,
|
|
162
|
-
onClear:
|
|
163
|
-
intent:
|
|
164
|
-
width:
|
|
165
|
-
fullWidth:
|
|
164
|
+
onClear: he,
|
|
165
|
+
intent: S ? "danger" : "default",
|
|
166
|
+
width: se,
|
|
167
|
+
fullWidth: ce,
|
|
166
168
|
rightIcons: [{
|
|
167
169
|
name: "ChevronDownIcon",
|
|
168
170
|
rotated: P
|
|
169
171
|
}],
|
|
170
|
-
className:
|
|
171
|
-
children: /* @__PURE__ */
|
|
172
|
-
id:
|
|
172
|
+
className: p(P && s.open),
|
|
173
|
+
children: /* @__PURE__ */ m("div", {
|
|
174
|
+
id: de,
|
|
173
175
|
ref: G,
|
|
174
|
-
className:
|
|
176
|
+
className: p(s.trigger, w && s.disabled),
|
|
175
177
|
onClick: J,
|
|
176
|
-
onKeyDown:
|
|
177
|
-
tabIndex:
|
|
178
|
+
onKeyDown: _e,
|
|
179
|
+
tabIndex: w ? -1 : 0,
|
|
178
180
|
role: "combobox",
|
|
179
181
|
"aria-expanded": P,
|
|
180
182
|
"aria-controls": P ? N : void 0,
|
|
181
183
|
"aria-haspopup": "listbox",
|
|
182
|
-
"aria-disabled":
|
|
184
|
+
"aria-disabled": w,
|
|
183
185
|
"aria-labelledby": M,
|
|
184
|
-
"aria-label": M ? void 0 : D || $() ||
|
|
185
|
-
"aria-describedby": [
|
|
186
|
-
"aria-required":
|
|
187
|
-
"aria-invalid": !!
|
|
186
|
+
"aria-label": M ? void 0 : D || $() || g(b),
|
|
187
|
+
"aria-describedby": [O, j].filter(Boolean).join(" ") || void 0,
|
|
188
|
+
"aria-required": C,
|
|
189
|
+
"aria-invalid": !!S,
|
|
188
190
|
"aria-activedescendant": P && z >= 0 ? `${k}-menu-${z}-option-${V[z]}` : void 0,
|
|
189
|
-
children: /* @__PURE__ */
|
|
190
|
-
className:
|
|
191
|
-
children: Q ||
|
|
191
|
+
children: /* @__PURE__ */ m("div", {
|
|
192
|
+
className: p(s.value, !Q && s.placeholder),
|
|
193
|
+
children: Q || b
|
|
192
194
|
})
|
|
193
195
|
})
|
|
194
|
-
}), /* @__PURE__ */
|
|
195
|
-
show: P && !
|
|
196
|
+
}), /* @__PURE__ */ m(t, {
|
|
197
|
+
show: P && !w,
|
|
196
198
|
preset: "fade",
|
|
197
199
|
id: N,
|
|
198
|
-
className:
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
className: s.dropdown,
|
|
201
|
+
ref: ye,
|
|
202
|
+
...be,
|
|
203
|
+
children: X.map((e, t) => /* @__PURE__ */ m("div", {
|
|
204
|
+
className: s.menu,
|
|
201
205
|
role: "listbox",
|
|
202
206
|
"aria-labelledby": M,
|
|
203
|
-
"aria-label": M ? void 0 : D || $() ||
|
|
204
|
-
children: e.map((e,
|
|
205
|
-
let
|
|
206
|
-
return /* @__PURE__ */
|
|
207
|
-
className:
|
|
208
|
-
active: c ||
|
|
207
|
+
"aria-label": M ? void 0 : D || $() || g(b),
|
|
208
|
+
children: e.map((e, a) => {
|
|
209
|
+
let o = L[t] === e.value, c = z === t && V[t] === a, l = q[t] === e.value, u = e.children && e.children.length > 0;
|
|
210
|
+
return /* @__PURE__ */ m(i, {
|
|
211
|
+
className: p(s.menuItem, l && s.selected),
|
|
212
|
+
active: c || o,
|
|
209
213
|
disabled: e.disabled,
|
|
210
|
-
onClick: (
|
|
211
|
-
|
|
214
|
+
onClick: (n) => {
|
|
215
|
+
n.stopPropagation(), Y(e, t);
|
|
212
216
|
},
|
|
213
217
|
onMouseEnter: () => {
|
|
214
|
-
|
|
218
|
+
ge(e, t), B(t), H((e) => [...e.slice(0, t), a]);
|
|
215
219
|
},
|
|
216
|
-
rightSection: u ? /* @__PURE__ */
|
|
217
|
-
component:
|
|
220
|
+
rightSection: u ? /* @__PURE__ */ m(r, {
|
|
221
|
+
component: n,
|
|
218
222
|
size: "sm"
|
|
219
223
|
}) : void 0,
|
|
220
224
|
role: "option",
|
|
221
|
-
id: `${k}-menu-${
|
|
225
|
+
id: `${k}-menu-${t}-option-${a}`,
|
|
222
226
|
"aria-selected": l,
|
|
223
227
|
tabIndex: -1,
|
|
224
228
|
children: e.label
|
|
225
229
|
}, e.value);
|
|
226
230
|
})
|
|
227
|
-
},
|
|
231
|
+
}, t))
|
|
228
232
|
})]
|
|
229
233
|
})
|
|
230
234
|
});
|
|
231
235
|
};
|
|
232
|
-
|
|
236
|
+
_.displayName = "Cascader";
|
|
233
237
|
//#endregion
|
|
234
|
-
export {
|
|
238
|
+
export { _ as Cascader };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_10y2r_323`,t=`_label_10y2r_328`,n=`_trigger_10y2r_335`,r=`_disabled_10y2r_348`,i=`_open_10y2r_354`,a=`_value_10y2r_362`,o=`_placeholder_10y2r_363`,s=`_icon_10y2r_366`,c=`_clear_10y2r_386`,l=`_dropdown_10y2r_398`,u=`_menu_10y2r_428`,d=`_menuItem_10y2r_457`,f=`_active_10y2r_457`,p=`_selected_10y2r_465`,m={"wim-docs-container":`_wim-docs-container_10y2r_87`,"wim-t":`_wim-t_10y2r_290`,"react-flow":`_react-flow_10y2r_313`,"react-flow__edges":`_react-flow__edges_10y2r_314`,"react-flow__connectionline":`_react-flow__connectionline_10y2r_315`,root:e,label:t,trigger:n,disabled:r,open:i,value:a,placeholder:o,icon:s,clear:c,dropdown:l,menu:u,menuItem:d,active:f,selected:p};exports.active=f,exports.clear=c,exports.default=m,exports.disabled=r,exports.dropdown=l,exports.icon=s,exports.label=t,exports.menu=u,exports.menuItem=d,exports.open=i,exports.placeholder=o,exports.root=e,exports.selected=p,exports.trigger=n,exports.value=a;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/Cascader/cascader.module.scss
|
|
3
|
-
var e = "
|
|
4
|
-
"wim-docs-container": "_wim-docs-
|
|
5
|
-
"wim-t": "_wim-
|
|
6
|
-
"react-flow": "_react-
|
|
7
|
-
"react-flow__edges": "_react-
|
|
8
|
-
"react-flow__connectionline": "_react-
|
|
3
|
+
var e = "_root_10y2r_323", t = "_label_10y2r_328", n = "_trigger_10y2r_335", r = "_disabled_10y2r_348", i = "_open_10y2r_354", a = "_value_10y2r_362", o = "_placeholder_10y2r_363", s = "_icon_10y2r_366", c = "_clear_10y2r_386", l = "_dropdown_10y2r_398", u = "_menu_10y2r_428", d = "_menuItem_10y2r_457", f = "_active_10y2r_457", p = "_selected_10y2r_465", m = {
|
|
4
|
+
"wim-docs-container": "_wim-docs-container_10y2r_87",
|
|
5
|
+
"wim-t": "_wim-t_10y2r_290",
|
|
6
|
+
"react-flow": "_react-flow_10y2r_313",
|
|
7
|
+
"react-flow__edges": "_react-flow__edges_10y2r_314",
|
|
8
|
+
"react-flow__connectionline": "_react-flow__connectionline_10y2r_315",
|
|
9
9
|
root: e,
|
|
10
10
|
label: t,
|
|
11
11
|
trigger: n,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../_internal/BaseListItem/BaseListItem.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../_internal/BaseListItem/BaseListItem.cjs"),r=require("../InputBase/InputBase.cjs"),i=require("../../_internal/useInlineFloating.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./combobox.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=({options:e=[],onChange:u,placeholder:d,showSearchIcon:f=!0,allowClear:p=!0,defaultValue:m=``,className:h,disabled:g=!1,label:_,error:v,required:y,layout:b,fullWidth:x=!1,id:S,labels:C={},...w})=>{let{noResults:T=`No results found`}=C,[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(m),[A,j]=(0,s.useState)(-1),[M,N]=(0,s.useState)(!1),P=(0,s.useRef)(null),F=(0,s.useId)(),I=S||`wim-combobox-${F}`,L=`${I}-list`,R=_?`${I}-label`:void 0,z=v?`${I}-error`:void 0,B=(0,s.useMemo)(()=>{let t=(O||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,O]);(0,s.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&D(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let V=e=>{let t=e.target.value;k(t),D(!0),j(-1)},H=e=>{k(e.label),D(!1),u&&u(e)},U=e=>{if(N(!0),!E&&e.key===`ArrowDown`){D(!0);return}switch(e.key){case`ArrowDown`:j(e=>e<B.length-1?e+1:0);break;case`ArrowUp`:j(e=>e<=0?B.length-1:e-1);break;case`Enter`:A>=0&&A<B.length&&H(B[A]);break;case`Escape`:D(!1);break;case`Tab`:D(!1)}},{setReference:W,setFloating:G,floatingProps:K}=i.useInlineFloating({open:E}),q=t.useMergedRef(P,W);return(0,l.jsx)(a.FieldTemplate,{label:_,error:v,required:y,layout:b,labelId:R,htmlFor:I,errorId:z,className:h,children:(0,l.jsxs)(`div`,{className:(0,c.default)(`wim-combobox`,o.default.root,x&&o.default.fullWidth),ref:q,onMouseMove:()=>N(!1),"data-keyboard-nav":M,children:[(0,l.jsx)(r.InputBase,{disabled:g,allowClear:p,hasValue:!!O,onClear:()=>k(``),intent:v?`danger`:`default`,leftIcon:f?`SearchIcon`:void 0,fullWidth:x,rightIcons:[{name:`ChevronDownIcon`,rotated:E,onClick:()=>D(!E),decorative:!0}],children:(0,l.jsx)(`input`,{id:I,className:o.default.input,placeholder:d,value:O,onChange:V,onKeyDown:U,onFocus:()=>D(!0),disabled:g,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":E,"aria-controls":E?L:void 0,"aria-labelledby":R,"aria-describedby":z,required:y,"aria-invalid":!!v,"aria-activedescendant":E&&A>=0?`${L}-option-${A}`:void 0,...w})}),E&&B.length>0&&(0,l.jsx)(`div`,{className:o.default.dropdown,ref:G,...K,children:(0,l.jsx)(`ul`,{id:L,className:o.default.list,role:`listbox`,"aria-labelledby":R,children:B.map((e,t)=>(0,l.jsx)(n.BaseListItem,{asChild:!0,id:`${L}-option-${t}`,className:(0,c.default)(o.default.option,t===A&&o.default.selected),active:t===A,onClick:()=>H(e),onMouseEnter:()=>j(t),role:`option`,"aria-selected":t===A,children:(0,l.jsx)(`li`,{children:e.label})},e.value))})}),E&&B.length===0&&(0,l.jsx)(`div`,{className:o.default.dropdown,ref:G,...K,children:(0,l.jsx)(`div`,{className:o.default.empty,role:`region`,"aria-live":`polite`,children:T})})]})})};u.displayName=`Combobox`,exports.Combobox=u;
|
|
@@ -1,133 +1,139 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import r from "
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
2
|
+
import { useMergedRef as e } from "../../../hooks/useMergedRef.js";
|
|
3
|
+
import { BaseListItem as t } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
4
|
+
import { InputBase as n } from "../InputBase/InputBase.js";
|
|
5
|
+
import { useInlineFloating as r } from "../../_internal/useInlineFloating.js";
|
|
6
|
+
import { FieldTemplate as i } from "../FieldTemplate/FieldTemplate.js";
|
|
7
|
+
import a from "./combobox.module.js";
|
|
8
|
+
import { useEffect as o, useId as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
9
|
+
import d from "classnames";
|
|
10
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
11
|
//#region src/components/form/Combobox/Combobox.tsx
|
|
10
|
-
var
|
|
11
|
-
let { noResults:
|
|
12
|
-
let e = (
|
|
13
|
-
return
|
|
14
|
-
}, [
|
|
15
|
-
|
|
12
|
+
var m = ({ options: m = [], onChange: h, placeholder: g, showSearchIcon: _ = !0, allowClear: v = !0, defaultValue: y = "", className: b, disabled: x = !1, label: S, error: C, required: w, layout: T, fullWidth: E = !1, id: D, labels: O = {}, ...k }) => {
|
|
13
|
+
let { noResults: A = "No results found" } = O, [j, M] = u(!1), [N, P] = u(y), [F, I] = u(-1), [L, R] = u(!1), z = l(null), B = s(), V = D || `wim-combobox-${B}`, H = `${V}-list`, U = S ? `${V}-label` : void 0, W = C ? `${V}-error` : void 0, G = c(() => {
|
|
14
|
+
let e = (N || "").toLowerCase();
|
|
15
|
+
return m.filter((t) => t.label.toLowerCase().includes(e));
|
|
16
|
+
}, [m, N]);
|
|
17
|
+
o(() => {
|
|
16
18
|
let e = (e) => {
|
|
17
|
-
|
|
19
|
+
z.current && !z.current.contains(e.target) && M(!1);
|
|
18
20
|
};
|
|
19
21
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
20
22
|
}, []);
|
|
21
|
-
let
|
|
23
|
+
let K = (e) => {
|
|
22
24
|
let t = e.target.value;
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
P(t), M(!0), I(-1);
|
|
26
|
+
}, q = (e) => {
|
|
27
|
+
P(e.label), M(!1), h && h(e);
|
|
28
|
+
}, J = (e) => {
|
|
29
|
+
if (R(!0), !j && e.key === "ArrowDown") {
|
|
30
|
+
M(!0);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
switch (e.key) {
|
|
34
|
+
case "ArrowDown":
|
|
35
|
+
I((e) => e < G.length - 1 ? e + 1 : 0);
|
|
36
|
+
break;
|
|
37
|
+
case "ArrowUp":
|
|
38
|
+
I((e) => e <= 0 ? G.length - 1 : e - 1);
|
|
39
|
+
break;
|
|
40
|
+
case "Enter":
|
|
41
|
+
F >= 0 && F < G.length && q(G[F]);
|
|
42
|
+
break;
|
|
43
|
+
case "Escape":
|
|
44
|
+
M(!1);
|
|
45
|
+
break;
|
|
46
|
+
case "Tab": M(!1);
|
|
47
|
+
}
|
|
48
|
+
}, { setReference: Y, setFloating: X, floatingProps: Z } = r({ open: j }), Q = e(z, Y);
|
|
49
|
+
return /* @__PURE__ */ f(i, {
|
|
50
|
+
label: S,
|
|
51
|
+
error: C,
|
|
52
|
+
required: w,
|
|
53
|
+
layout: T,
|
|
54
|
+
labelId: U,
|
|
55
|
+
htmlFor: V,
|
|
56
|
+
errorId: W,
|
|
57
|
+
className: b,
|
|
58
|
+
children: /* @__PURE__ */ p("div", {
|
|
59
|
+
className: d("wim-combobox", a.root, E && a.fullWidth),
|
|
60
|
+
ref: Q,
|
|
61
|
+
onMouseMove: () => R(!1),
|
|
62
|
+
"data-keyboard-nav": L,
|
|
41
63
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
disabled:
|
|
44
|
-
allowClear:
|
|
45
|
-
hasValue: !!
|
|
46
|
-
onClear: () =>
|
|
47
|
-
intent:
|
|
48
|
-
leftIcon:
|
|
49
|
-
fullWidth:
|
|
64
|
+
/* @__PURE__ */ f(n, {
|
|
65
|
+
disabled: x,
|
|
66
|
+
allowClear: v,
|
|
67
|
+
hasValue: !!N,
|
|
68
|
+
onClear: () => P(""),
|
|
69
|
+
intent: C ? "danger" : "default",
|
|
70
|
+
leftIcon: _ ? "SearchIcon" : void 0,
|
|
71
|
+
fullWidth: E,
|
|
50
72
|
rightIcons: [{
|
|
51
73
|
name: "ChevronDownIcon",
|
|
52
|
-
rotated:
|
|
53
|
-
onClick: () =>
|
|
74
|
+
rotated: j,
|
|
75
|
+
onClick: () => M(!j),
|
|
54
76
|
decorative: !0
|
|
55
77
|
}],
|
|
56
|
-
children: /* @__PURE__ */
|
|
57
|
-
id:
|
|
58
|
-
className:
|
|
59
|
-
placeholder:
|
|
60
|
-
value:
|
|
61
|
-
onChange:
|
|
62
|
-
onKeyDown:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
switch (e.key) {
|
|
68
|
-
case "ArrowDown":
|
|
69
|
-
P((e) => e < U.length - 1 ? e + 1 : 0);
|
|
70
|
-
break;
|
|
71
|
-
case "ArrowUp":
|
|
72
|
-
P((e) => e <= 0 ? U.length - 1 : e - 1);
|
|
73
|
-
break;
|
|
74
|
-
case "Enter":
|
|
75
|
-
N >= 0 && N < U.length && G(U[N]);
|
|
76
|
-
break;
|
|
77
|
-
case "Escape":
|
|
78
|
-
A(!1);
|
|
79
|
-
break;
|
|
80
|
-
case "Tab": A(!1);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
onFocus: () => A(!0),
|
|
84
|
-
disabled: y,
|
|
78
|
+
children: /* @__PURE__ */ f("input", {
|
|
79
|
+
id: V,
|
|
80
|
+
className: a.input,
|
|
81
|
+
placeholder: g,
|
|
82
|
+
value: N,
|
|
83
|
+
onChange: K,
|
|
84
|
+
onKeyDown: J,
|
|
85
|
+
onFocus: () => M(!0),
|
|
86
|
+
disabled: x,
|
|
85
87
|
autoComplete: "off",
|
|
86
88
|
role: "combobox",
|
|
87
89
|
"aria-autocomplete": "list",
|
|
88
|
-
"aria-expanded":
|
|
89
|
-
"aria-controls":
|
|
90
|
-
"aria-labelledby":
|
|
91
|
-
"aria-describedby":
|
|
92
|
-
required:
|
|
93
|
-
"aria-invalid": !!
|
|
94
|
-
"aria-activedescendant":
|
|
95
|
-
...
|
|
90
|
+
"aria-expanded": j,
|
|
91
|
+
"aria-controls": j ? H : void 0,
|
|
92
|
+
"aria-labelledby": U,
|
|
93
|
+
"aria-describedby": W,
|
|
94
|
+
required: w,
|
|
95
|
+
"aria-invalid": !!C,
|
|
96
|
+
"aria-activedescendant": j && F >= 0 ? `${H}-option-${F}` : void 0,
|
|
97
|
+
...k
|
|
96
98
|
})
|
|
97
99
|
}),
|
|
98
|
-
|
|
99
|
-
className:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
j && G.length > 0 && /* @__PURE__ */ f("div", {
|
|
101
|
+
className: a.dropdown,
|
|
102
|
+
ref: X,
|
|
103
|
+
...Z,
|
|
104
|
+
children: /* @__PURE__ */ f("ul", {
|
|
105
|
+
id: H,
|
|
106
|
+
className: a.list,
|
|
103
107
|
role: "listbox",
|
|
104
|
-
"aria-labelledby":
|
|
105
|
-
children:
|
|
108
|
+
"aria-labelledby": U,
|
|
109
|
+
children: G.map((e, n) => /* @__PURE__ */ f(t, {
|
|
106
110
|
asChild: !0,
|
|
107
|
-
id: `${
|
|
108
|
-
className:
|
|
109
|
-
active: n ===
|
|
110
|
-
onClick: () =>
|
|
111
|
-
onMouseEnter: () =>
|
|
111
|
+
id: `${H}-option-${n}`,
|
|
112
|
+
className: d(a.option, n === F && a.selected),
|
|
113
|
+
active: n === F,
|
|
114
|
+
onClick: () => q(e),
|
|
115
|
+
onMouseEnter: () => I(n),
|
|
112
116
|
role: "option",
|
|
113
|
-
"aria-selected": n ===
|
|
114
|
-
children: /* @__PURE__ */
|
|
115
|
-
},
|
|
117
|
+
"aria-selected": n === F,
|
|
118
|
+
children: /* @__PURE__ */ f("li", { children: e.label })
|
|
119
|
+
}, e.value))
|
|
116
120
|
})
|
|
117
121
|
}),
|
|
118
|
-
|
|
119
|
-
className:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
j && G.length === 0 && /* @__PURE__ */ f("div", {
|
|
123
|
+
className: a.dropdown,
|
|
124
|
+
ref: X,
|
|
125
|
+
...Z,
|
|
126
|
+
children: /* @__PURE__ */ f("div", {
|
|
127
|
+
className: a.empty,
|
|
122
128
|
role: "region",
|
|
123
129
|
"aria-live": "polite",
|
|
124
|
-
children:
|
|
130
|
+
children: A
|
|
125
131
|
})
|
|
126
132
|
})
|
|
127
133
|
]
|
|
128
134
|
})
|
|
129
135
|
});
|
|
130
136
|
};
|
|
131
|
-
|
|
137
|
+
m.displayName = "Combobox";
|
|
132
138
|
//#endregion
|
|
133
|
-
export {
|
|
139
|
+
export { m as Combobox };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_o8hc3_3`,t=`_fullWidth_o8hc3_8`,n=`_input_o8hc3_11`,r=`_dropdown_o8hc3_32`,i=`_list_o8hc3_37`,a=`_option_o8hc3_69`,o=`_selected_o8hc3_73`,s=`_empty_o8hc3_78`,c={root:e,fullWidth:t,input:n,dropdown:r,list:i,option:a,selected:o,empty:s};exports.default=c,exports.dropdown=r,exports.empty=s,exports.fullWidth=t,exports.input=n,exports.list=i,exports.option=a,exports.root=e,exports.selected=o;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/Combobox/combobox.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_o8hc3_3", t = "_fullWidth_o8hc3_8", n = "_input_o8hc3_11", r = "_dropdown_o8hc3_32", i = "_list_o8hc3_37", a = "_option_o8hc3_69", o = "_selected_o8hc3_73", s = "_empty_o8hc3_78", c = {
|
|
4
4
|
root: e,
|
|
5
5
|
fullWidth: t,
|
|
6
6
|
input: n,
|
|
@@ -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"),
|
|
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("../../../hooks/useMergedRef.cjs"),i=require("../../layout/Transition/Transition.cjs"),a=require("../../overlay/FocusTrap/FocusTrap.cjs"),o=require("../../../i18n/generated/components.cjs"),ee=require("../InputBase/InputBase.cjs"),s=require("../../_internal/useInlineFloating.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),l=require("../Input/input.module.cjs"),u=require("../../data-display/Calendar/Calendar.cjs"),d=require("./date-picker.module.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("classnames");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=(0,f.forwardRef)(({intent:e=`default`,variant:h=`outline`,fullWidth:g=!1,className:_,disabled:v,value:y,defaultValue:b,onChange:x,format:te=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:ne,maxDate:re,disabledDates:ie,label:w,error:T,required:E,layout:D,id:O,labels:k,width:A,asChild:j=!1,children:M,...N},P)=>{let[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(b||null),z=(0,f.useRef)(null),B=(0,f.useRef)(null),{t:V}=n.useWimTranslation(o.componentsNs),H=(0,f.useId)(),U=O||`wim-datepicker-${H}`,W=`${U}-dropdown`,G=w?`${U}-label`:void 0,K=T?`${U}-error`:void 0,q=y!==void 0,J=q?y:L,Y=C??k?.placeholder,X=v,Z=T?`danger`:e;(0,f.useEffect)(()=>{let e=e=>{z.current&&!z.current.contains(e.target)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,f.useEffect)(()=>{let e=e=>{e.key===`Escape`&&F&&(I(!1),B.current?.focus())};return F&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[F]);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 te.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},ae=e=>{q||R(e),x?.(e),I(!1),B.current?.focus()},oe=e=>{e?.stopPropagation(),X||(q||R(null),x?.(null))},$=()=>{X||I(!F)},se=e=>{X||(e.key===`Escape`?(I(!1),B.current?.focus()):(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`&&(e.altKey||!F))&&(e.preventDefault(),I(!F)))};(0,f.useEffect)(()=>{if(F){let e=setTimeout(()=>{let e=z.current?.querySelector(`[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():z.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[F]);let ce=j?t.Root:`div`,{setReference:le,setFloating:ue,floatingProps:de}=s.useInlineFloating({open:F&&!v}),fe=r.useMergedRef(z,P,le);return(0,m.jsx)(c.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:G,htmlFor:U,errorId:K,className:_,children:(0,m.jsxs)(ce,{ref:fe,className:(0,p.default)(`wim-date-picker`,d.default.root,g&&d.default.fullWidth),children:[(0,m.jsx)(ee.InputBase,{intent:Z,variant:h,width:A,fullWidth:g,disabled:X,allowClear:S,hasValue:!!J,onClear:oe,rightIcons:[{name:`ChevronDownIcon`,rotated:F,onClick:$,decorative:!0}],children:(0,m.jsx)(`input`,{id:U,ref:B,type:`text`,readOnly:!0,role:`combobox`,className:(0,p.default)(l.default.root,d.default.input),value:Q(J),placeholder:Y,disabled:X,onClick:$,onKeyDown:se,"aria-haspopup":`dialog`,"aria-expanded":F,"aria-controls":F?W:void 0,"aria-invalid":Z===`danger`,"aria-describedby":K,"aria-labelledby":G,"aria-required":E,...N})}),(0,m.jsx)(i.Transition,{show:F&&!v,preset:`fade`,id:W,className:d.default.dropdown,ref:ue,...de,children:(0,m.jsx)(a.FocusTrap,{active:F,initialFocus:!1,children:(0,m.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":G,"aria-label":G?void 0:N[`aria-label`]??V(`datepicker.dialog`),children:(0,m.jsx)(u.Calendar,{value:J??void 0,onChange:ae})})})}),(0,m.jsx)(t.Slottable,{children:M})]})})});h.displayName=`DatePicker`,exports.DatePicker=h,exports.default=h;
|