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,16 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
|
|
3
|
-
import {
|
|
4
|
-
import n from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import o from "
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
3
|
+
import { useMergedRef as t } from "../../../hooks/useMergedRef.js";
|
|
4
|
+
import { Transition as n } from "../../layout/Transition/Transition.js";
|
|
5
|
+
import r from "../../../icon/chevron-down.js";
|
|
6
|
+
import { Icon as i } from "../../media/Icon/Icon.js";
|
|
7
|
+
import { useInlineFloating as a } from "../../_internal/useInlineFloating.js";
|
|
8
|
+
import { formNs as o } from "../../../i18n/generated/form.js";
|
|
9
|
+
import { FieldTemplate as s } from "../FieldTemplate/FieldTemplate.js";
|
|
10
|
+
import c from "./phone-input.module.js";
|
|
11
|
+
import { forwardRef as l, useEffect as u, useId as d, useRef as f, useState as p } from "react";
|
|
12
|
+
import m from "classnames";
|
|
13
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
12
14
|
//#region src/components/form/PhoneInput/PhoneInput.tsx
|
|
13
|
-
var
|
|
15
|
+
var _ = [
|
|
14
16
|
{
|
|
15
17
|
code: "US",
|
|
16
18
|
dialCode: "1",
|
|
@@ -61,159 +63,163 @@ var h = [
|
|
|
61
63
|
dialCode: "55",
|
|
62
64
|
flag: "🇧🇷"
|
|
63
65
|
}
|
|
64
|
-
],
|
|
65
|
-
let
|
|
66
|
+
], v = l(({ value: l = "", onChange: v, countryCode: y = "US", onCountryChange: b, placeholder: x = "000-0000-0000", disabled: S = !1, error: C, required: w = !1, label: T, layout: ee = "vertical", className: E, fullWidth: D = !1, "aria-label": O, "aria-labelledby": k, "aria-describedby": A, ...j }, M) => {
|
|
67
|
+
let N = `wim-phone-input-${d()}`, P = T ? `${N}-label` : void 0, { t: F } = e(o), I = F("phone.select_country"), L = `${N}-countries`, R = (e) => `${N}-country-${e}`, z = C ? `${N}-error` : void 0, [B, V] = p(!1), [H, U] = p(-1), W = f(null), G = f(null), K = f({
|
|
66
68
|
text: "",
|
|
67
69
|
timer: null
|
|
68
70
|
});
|
|
69
|
-
|
|
71
|
+
u(() => {
|
|
70
72
|
let e = (e) => {
|
|
71
|
-
|
|
73
|
+
W.current && !W.current.contains(e.target) && V(!1);
|
|
72
74
|
};
|
|
73
|
-
return
|
|
75
|
+
return B && document.addEventListener("mousedown", e), () => {
|
|
74
76
|
document.removeEventListener("mousedown", e);
|
|
75
77
|
};
|
|
76
|
-
}, [
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
let t =
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
let t =
|
|
84
|
-
t && (
|
|
85
|
-
},
|
|
78
|
+
}, [B]);
|
|
79
|
+
let q = _.find((e) => e.code === y) ?? _[0], J = (e) => {
|
|
80
|
+
v?.(e.target.value);
|
|
81
|
+
}, Y = _.length - 1, X = (e) => {
|
|
82
|
+
let t = _.findIndex((e) => e.code === q.code);
|
|
83
|
+
U(e ?? Math.max(t, 0)), V(!0);
|
|
84
|
+
}, Z = (e) => {
|
|
85
|
+
let t = _[e];
|
|
86
|
+
t && (b?.(t.code), V(!1));
|
|
87
|
+
}, Q = (e) => F(`phone.countries.${e.code}`), te = (e) => o.resources.en?.phone?.countries?.[e.code] ?? "", ne = (e, t) => {
|
|
86
88
|
let n = e.toLowerCase().replace(/^\+/, "");
|
|
87
89
|
if (n === "") return -1;
|
|
88
90
|
let r = /^[0-9]+$/.test(n), i = !r && n.length > 1 && n.split("").every((e) => e === n[0]), a = i ? n[0] : n, o = i || n.length === 1 ? t + 1 : t, s = r ? [(e) => e.dialCode] : [
|
|
89
|
-
(e) =>
|
|
90
|
-
(e) =>
|
|
91
|
+
(e) => Q(e).toLowerCase(),
|
|
92
|
+
(e) => te(e).toLowerCase(),
|
|
91
93
|
(e) => e.code.toLowerCase()
|
|
92
94
|
];
|
|
93
|
-
for (let e of s) for (let t = 0; t <
|
|
94
|
-
let n = (Math.max(o, 0) + t) %
|
|
95
|
-
if (e(
|
|
95
|
+
for (let e of s) for (let t = 0; t < _.length; t++) {
|
|
96
|
+
let n = (Math.max(o, 0) + t) % _.length;
|
|
97
|
+
if (e(_[n]).startsWith(a)) return n;
|
|
96
98
|
}
|
|
97
99
|
return -1;
|
|
98
100
|
}, $ = (e) => {
|
|
99
|
-
let t =
|
|
101
|
+
let t = K.current;
|
|
100
102
|
t.timer && clearTimeout(t.timer), t.text += e, t.timer = setTimeout(() => {
|
|
101
103
|
t.text = "", t.timer = null;
|
|
102
104
|
}, 500);
|
|
103
|
-
let n =
|
|
104
|
-
n < 0 || (
|
|
105
|
-
},
|
|
106
|
-
if (!
|
|
105
|
+
let n = ne(t.text, B ? H : -1);
|
|
106
|
+
n < 0 || (B ? U(n) : X(n));
|
|
107
|
+
}, re = (e) => {
|
|
108
|
+
if (!S) switch (e.key) {
|
|
107
109
|
case "ArrowDown":
|
|
108
110
|
case "ArrowUp":
|
|
109
|
-
if (e.preventDefault(), !
|
|
111
|
+
if (e.preventDefault(), !B) X();
|
|
110
112
|
else {
|
|
111
113
|
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
112
|
-
|
|
114
|
+
U((e) => (e + t + _.length) % _.length);
|
|
113
115
|
}
|
|
114
116
|
break;
|
|
115
117
|
case "Home":
|
|
116
118
|
case "End":
|
|
117
|
-
e.preventDefault(),
|
|
119
|
+
e.preventDefault(), B ? U(e.key === "Home" ? 0 : Y) : X(e.key === "Home" ? 0 : Y);
|
|
118
120
|
break;
|
|
119
121
|
case "Enter":
|
|
120
122
|
case " ":
|
|
121
|
-
e.preventDefault(), e.key === " " &&
|
|
123
|
+
e.preventDefault(), e.key === " " && K.current.text !== "" ? $(" ") : B ? Z(H) : X();
|
|
122
124
|
break;
|
|
123
125
|
case "Escape":
|
|
124
|
-
|
|
126
|
+
B && (e.preventDefault(), V(!1));
|
|
125
127
|
break;
|
|
126
128
|
case "Tab":
|
|
127
|
-
|
|
129
|
+
V(!1);
|
|
128
130
|
break;
|
|
129
131
|
default: e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), $(e.key));
|
|
130
132
|
}
|
|
131
133
|
};
|
|
132
|
-
|
|
133
|
-
let e =
|
|
134
|
+
u(() => {
|
|
135
|
+
let e = K.current;
|
|
134
136
|
return () => {
|
|
135
137
|
e.timer && clearTimeout(e.timer);
|
|
136
138
|
};
|
|
137
|
-
}, []),
|
|
138
|
-
|
|
139
|
-
}, [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
}, []), u(() => {
|
|
140
|
+
B && H >= 0 && (G.current?.querySelectorAll("[role=\"option\"]")?.[H])?.scrollIntoView?.({ block: "nearest" });
|
|
141
|
+
}, [H, B]);
|
|
142
|
+
let { setReference: ie, setFloating: ae, floatingProps: oe } = a({ open: B }), se = t(W, ie);
|
|
143
|
+
return /* @__PURE__ */ h(s, {
|
|
144
|
+
label: T,
|
|
145
|
+
labelId: P,
|
|
146
|
+
htmlFor: N,
|
|
147
|
+
required: w,
|
|
148
|
+
error: C,
|
|
149
|
+
errorId: z,
|
|
150
|
+
layout: ee,
|
|
151
|
+
className: E,
|
|
152
|
+
children: /* @__PURE__ */ g("div", {
|
|
153
|
+
ref: se,
|
|
154
|
+
className: m("wim-phone-input", c.root, D && c.fullWidth, S && c.disabled, C && c.danger),
|
|
151
155
|
"data-testid": "phone-input-root",
|
|
152
|
-
...
|
|
156
|
+
...j,
|
|
153
157
|
children: [
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
className:
|
|
156
|
-
children: [/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ g("div", {
|
|
159
|
+
className: c.countryWrapper,
|
|
160
|
+
children: [/* @__PURE__ */ g("button", {
|
|
157
161
|
type: "button",
|
|
158
162
|
role: "combobox",
|
|
159
|
-
className:
|
|
163
|
+
className: c.countryTrigger,
|
|
160
164
|
onClick: () => {
|
|
161
|
-
|
|
165
|
+
S || (B ? V(!1) : X());
|
|
162
166
|
},
|
|
163
|
-
onKeyDown:
|
|
167
|
+
onKeyDown: re,
|
|
164
168
|
onKeyUp: (e) => {
|
|
165
169
|
e.key === " " && e.preventDefault();
|
|
166
170
|
},
|
|
167
|
-
disabled:
|
|
171
|
+
disabled: S,
|
|
168
172
|
"aria-haspopup": "listbox",
|
|
169
|
-
"aria-expanded":
|
|
170
|
-
"aria-controls":
|
|
171
|
-
"aria-activedescendant":
|
|
172
|
-
"aria-label":
|
|
173
|
+
"aria-expanded": B,
|
|
174
|
+
"aria-controls": B ? L : void 0,
|
|
175
|
+
"aria-activedescendant": B && H >= 0 ? R(H) : void 0,
|
|
176
|
+
"aria-label": I,
|
|
173
177
|
children: [
|
|
174
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ h("span", {
|
|
175
179
|
"aria-hidden": "true",
|
|
176
180
|
style: { fontSize: "1.2em" },
|
|
177
|
-
children:
|
|
181
|
+
children: q.flag
|
|
178
182
|
}),
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
component:
|
|
183
|
+
/* @__PURE__ */ g("span", { children: ["+", q.dialCode] }),
|
|
184
|
+
/* @__PURE__ */ h(i, {
|
|
185
|
+
component: r,
|
|
182
186
|
size: "sm",
|
|
183
|
-
className:
|
|
187
|
+
className: m(c.chevron, B && c.chevronOpen)
|
|
184
188
|
})
|
|
185
189
|
]
|
|
186
|
-
}), /* @__PURE__ */
|
|
187
|
-
show:
|
|
190
|
+
}), /* @__PURE__ */ h(n, {
|
|
191
|
+
show: B,
|
|
188
192
|
preset: "fade",
|
|
189
|
-
className:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
className: c.dropdown,
|
|
194
|
+
ref: ae,
|
|
195
|
+
...oe,
|
|
196
|
+
children: /* @__PURE__ */ h("ul", {
|
|
197
|
+
ref: G,
|
|
198
|
+
id: L,
|
|
199
|
+
className: c.countryList,
|
|
194
200
|
role: "listbox",
|
|
195
|
-
"aria-label":
|
|
201
|
+
"aria-label": I,
|
|
196
202
|
tabIndex: -1,
|
|
197
203
|
onMouseDown: (e) => e.preventDefault(),
|
|
198
|
-
children:
|
|
199
|
-
id:
|
|
200
|
-
className:
|
|
201
|
-
onMouseEnter: () =>
|
|
202
|
-
onClick: () =>
|
|
204
|
+
children: _.map((e, t) => /* @__PURE__ */ g("li", {
|
|
205
|
+
id: R(t),
|
|
206
|
+
className: m(c.countryOption, t === H && c.active, q.code === e.code && c.selected),
|
|
207
|
+
onMouseEnter: () => U(t),
|
|
208
|
+
onClick: () => Z(t),
|
|
203
209
|
role: "option",
|
|
204
|
-
"aria-selected":
|
|
210
|
+
"aria-selected": q.code === e.code,
|
|
205
211
|
children: [
|
|
206
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ h("span", {
|
|
207
213
|
"aria-hidden": "true",
|
|
208
214
|
children: e.flag
|
|
209
215
|
}),
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
className:
|
|
212
|
-
children:
|
|
216
|
+
/* @__PURE__ */ h("span", {
|
|
217
|
+
className: c.countryName,
|
|
218
|
+
children: Q(e)
|
|
213
219
|
}),
|
|
214
220
|
" ",
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
className:
|
|
221
|
+
/* @__PURE__ */ g("span", {
|
|
222
|
+
className: c.countryCode,
|
|
217
223
|
children: ["+", e.dialCode]
|
|
218
224
|
})
|
|
219
225
|
]
|
|
@@ -221,28 +227,28 @@ var h = [
|
|
|
221
227
|
})
|
|
222
228
|
})]
|
|
223
229
|
}),
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
className:
|
|
230
|
+
/* @__PURE__ */ h("div", {
|
|
231
|
+
className: c.divider,
|
|
226
232
|
"aria-hidden": "true"
|
|
227
233
|
}),
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
-
id:
|
|
230
|
-
ref:
|
|
234
|
+
/* @__PURE__ */ h("input", {
|
|
235
|
+
id: N,
|
|
236
|
+
ref: M,
|
|
231
237
|
type: "tel",
|
|
232
|
-
value:
|
|
233
|
-
onChange:
|
|
234
|
-
placeholder:
|
|
235
|
-
disabled:
|
|
236
|
-
className:
|
|
237
|
-
"aria-invalid": !!
|
|
238
|
-
"aria-label":
|
|
239
|
-
"aria-labelledby":
|
|
240
|
-
"aria-describedby": [
|
|
238
|
+
value: l,
|
|
239
|
+
onChange: J,
|
|
240
|
+
placeholder: x,
|
|
241
|
+
disabled: S,
|
|
242
|
+
className: c.number,
|
|
243
|
+
"aria-invalid": !!C,
|
|
244
|
+
"aria-label": T ? void 0 : O,
|
|
245
|
+
"aria-labelledby": T ? void 0 : k,
|
|
246
|
+
"aria-describedby": [A, z].filter(Boolean).join(" ") || void 0
|
|
241
247
|
})
|
|
242
248
|
]
|
|
243
249
|
})
|
|
244
250
|
});
|
|
245
251
|
});
|
|
246
|
-
|
|
252
|
+
v.displayName = "PhoneInput";
|
|
247
253
|
//#endregion
|
|
248
|
-
export {
|
|
254
|
+
export { _ as PHONE_COUNTRIES, v as PhoneInput };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_1f5bd_37`,t=`_fullWidth_1f5bd_50`,n=`_disabled_1f5bd_53`,r=`_chevron_1f5bd_77`,i=`_countryCode_1f5bd_78`,a=`_number_1f5bd_79`,o=`_danger_1f5bd_8`,s=`_countryWrapper_1f5bd_91`,c=`_countryTrigger_1f5bd_98`,l=`_chevronOpen_1f5bd_140`,u=`_dropdown_1f5bd_143`,d=`_countryList_1f5bd_163`,f=`_countryOption_1f5bd_170`,p=`_active_1f5bd_180`,m=`_selected_1f5bd_186`,h=`_countryName_1f5bd_191`,g=`_divider_1f5bd_201`,_={root:e,fullWidth:t,disabled:n,chevron:r,countryCode:i,number:a,danger:o,countryWrapper:s,countryTrigger:c,chevronOpen:l,dropdown:u,countryList:d,countryOption:f,active:p,selected:m,countryName:h,divider:g};exports.active=p,exports.chevron=r,exports.chevronOpen=l,exports.countryCode=i,exports.countryList=d,exports.countryName=h,exports.countryOption=f,exports.countryTrigger=c,exports.countryWrapper=s,exports.danger=o,exports.default=_,exports.disabled=n,exports.divider=g,exports.dropdown=u,exports.fullWidth=t,exports.number=a,exports.root=e,exports.selected=m;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/PhoneInput/phone-input.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_1f5bd_37", t = "_fullWidth_1f5bd_50", n = "_disabled_1f5bd_53", r = "_chevron_1f5bd_77", i = "_countryCode_1f5bd_78", a = "_number_1f5bd_79", o = "_danger_1f5bd_8", s = "_countryWrapper_1f5bd_91", c = "_countryTrigger_1f5bd_98", l = "_chevronOpen_1f5bd_140", u = "_dropdown_1f5bd_143", d = "_countryList_1f5bd_163", f = "_countryOption_1f5bd_170", p = "_active_1f5bd_180", m = "_selected_1f5bd_186", h = "_countryName_1f5bd_191", g = "_divider_1f5bd_201", _ = {
|
|
4
4
|
root: e,
|
|
5
5
|
fullWidth: t,
|
|
6
6
|
disabled: 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"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("../../../i18n/generated/form.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("../../layout/Transition/Transition.cjs"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("../../_internal/useInlineFloating.cjs"),s=require("../../../i18n/generated/form.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),ee=require("../../_internal/mergeRefs.cjs"),l=require("./select.module.cjs"),te=require("./useSelect.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=(0,u.forwardRef)(({options:e=[],value:p,onChange:ne,placeholder:m,label:h,error:g,required:_,layout:re,className:ie,disabled:v=!1,defaultValue:y,searchable:b=!1,searchPlaceholder:x,filterOption:S,grouped:C=!1,allowClear:ae=!1,fullWidth:w=!1,intent:oe=`default`,id:se,noOptionsFoundLabel:T,width:E,styles:D,asChild:ce=!1,children:le,...ue},O)=>{let{t:de}=n.useWimTranslation(s.formNs),fe=(0,u.useId)(),k=se||`wim-select-${fe}`,A=h?`${k}-label`:void 0,j=g?`${k}-error`:void 0,M=`${k}-list`,N=`${k}-trigger`,P=g?`danger`:oe,{isOpen:F,searchValue:I,setSearchValue:L,focusedIndex:R,setFocusedIndex:z,isKeyboardNavigating:B,setIsKeyboardNavigating:pe,containerRef:V,triggerRef:me,searchInputRef:he,listItemsRef:H,currentValue:U,filteredOptions:W,selectedOption:G,focusedOption:K,handleToggle:ge,handleSelect:q,handleClear:_e,handleKeyDown:J}=te.useSelect({options:e,value:p,onChange:ne,defaultValue:y,searchable:b,grouped:C,disabled:v,filterOption:S}),{setReference:Y,setFloating:ve,floatingProps:ye}=o.useInlineFloating({open:F&&!v}),X=(0,u.useMemo)(()=>ee.mergeRefs(V,O,Y),[V,O,Y]),be=()=>{let t=0;return C&&e.length>0&&`options`in e[0]?e.map((e,n)=>{let r=e.options.filter(e=>e.type===`separator`||!I||(S||((e,t)=>(typeof e.label==`string`?e.label:``).toLowerCase().includes(t.toLowerCase())))(e,I));return r.length===0?null:(0,f.jsxs)(u.default.Fragment,{children:[(0,f.jsx)(`li`,{className:(0,d.default)(l.default.groupLabel,D?.groupLabel),role:`presentation`,children:e.label}),r.map((e,r)=>{let a=t++;if(e.type===`separator`)return(0,f.jsx)(`li`,{className:(0,d.default)(l.default.separator,D?.separator),role:`presentation`},`sep-${n}-${r}`);let o=a===R,s=U===e.value,c=`wim-select-option-${k}-${e.value}`;return(0,f.jsx)(i.BaseListItem,{asChild:!0,id:c,ref:e=>{H.current[a]=e},active:o,disabled:e.disabled,className:(0,d.default)(l.default.option,s&&l.default.selected,D?.option),onClick:t=>{t.stopPropagation(),q(e)},onMouseEnter:()=>z(a),role:`option`,"aria-selected":s,children:(0,f.jsx)(`li`,{children:e.label})},e.value)})]},n)}):W.map((e,n)=>{let r=t++;if(e.type===`separator`)return(0,f.jsx)(`li`,{className:(0,d.default)(l.default.separator,D?.separator),role:`presentation`},`sep-${n}`);let a=r===R,o=U===e.value,s=`wim-select-option-${k}-${e.value}`;return(0,f.jsx)(i.BaseListItem,{asChild:!0,id:s,ref:e=>{H.current[r]=e},active:a,disabled:e.disabled,className:(0,d.default)(l.default.option,o&&l.default.selected,D?.option),onClick:t=>{t.stopPropagation(),q(e)},onMouseEnter:()=>z(r),role:`option`,"aria-selected":o,children:(0,f.jsx)(`li`,{children:e.label})},e.value)})},Z=K&&K.type!==`separator`?`wim-select-option-${k}-${K.value}`:void 0,{"aria-label":Q,"aria-labelledby":$,"aria-describedby":xe,...Se}=ue;return(0,f.jsx)(c.FieldTemplate,{label:h,error:g,required:_,layout:re,labelId:A,htmlFor:N,errorId:j,className:ie,children:(0,f.jsxs)(ce?t.Root:`div`,{className:(0,d.default)(`wim-select`,l.default.root,w&&l.default.fullWidth,D?.root),ref:X,onMouseMove:()=>pe(!1),"data-keyboard-nav":B,...Se,children:[(0,f.jsx)(a.InputBase,{disabled:v,allowClear:ae,hasValue:!!U,onClear:_e,intent:P,rightIcons:[{name:`ChevronDownIcon`,rotated:F}],width:E,fullWidth:w,styles:D?.inputBase,children:(0,f.jsx)(`div`,{id:N,className:(0,d.default)(l.default.trigger,F&&l.default.open,v&&l.default.disabled,D?.trigger),onClick:ge,onKeyDown:J,tabIndex:v?-1:0,role:`combobox`,"aria-expanded":F,"aria-haspopup":`listbox`,"aria-controls":F?M:void 0,"aria-disabled":v,"aria-labelledby":A||$,"aria-label":h?void 0:typeof Q==`string`?Q:typeof m==`string`?m:void 0,"aria-describedby":j||xe,"aria-required":_?`true`:void 0,"aria-invalid":P===`danger`?`true`:`false`,"aria-activedescendant":F?Z:void 0,ref:me,children:(0,f.jsx)(`div`,{className:(0,d.default)(l.default.value,!G&&l.default.placeholder,D?.value),children:G?G.label:m})})}),(0,f.jsxs)(r.Transition,{show:F&&!v,preset:`fade`,className:(0,d.default)(l.default.dropdown,D?.dropdown),ref:ve,...ye,children:[b&&(0,f.jsx)(`div`,{className:(0,d.default)(l.default.search,D?.search),children:(0,f.jsx)(`input`,{ref:he,type:`text`,className:(0,d.default)(l.default.searchInput,D?.searchInput),placeholder:x,value:I,onChange:e=>{L(e.target.value),z(-1)},onClick:e=>e.stopPropagation(),onKeyDown:J,"aria-label":x,"aria-controls":M,"aria-activedescendant":Z})}),(0,f.jsx)(`ul`,{id:M,className:(0,d.default)(l.default.list,D?.list),role:`listbox`,"aria-labelledby":h?A:$||void 0,children:W.length===0?(0,f.jsx)(`li`,{className:(0,d.default)(l.default.empty,D?.empty),role:`option`,"aria-selected":`false`,children:T??de(`select.no_options`)}):be()})]}),(0,f.jsx)(t.Slottable,{children:le})]})})});p.displayName=`Select`,exports.Select=p,exports.default=p;
|