wimui 0.60.0 → 0.60.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/_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 +88 -84
- 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/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/llms-full.txt +1 -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,128 +1,133 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { useWimTranslation as n } from "../../../i18n/useWimTranslation.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import h from "
|
|
15
|
-
import
|
|
4
|
+
import { useMergedRef as r } from "../../../hooks/useMergedRef.js";
|
|
5
|
+
import { Transition as i } from "../../layout/Transition/Transition.js";
|
|
6
|
+
import { FocusTrap as a } from "../../overlay/FocusTrap/FocusTrap.js";
|
|
7
|
+
import { componentsNs as o } from "../../../i18n/generated/components.js";
|
|
8
|
+
import { InputBase as ee } from "../InputBase/InputBase.js";
|
|
9
|
+
import { useInlineFloating as s } from "../../_internal/useInlineFloating.js";
|
|
10
|
+
import { FieldTemplate as c } from "../FieldTemplate/FieldTemplate.js";
|
|
11
|
+
import l from "../Input/input.module.js";
|
|
12
|
+
import { Calendar as u } from "../../data-display/Calendar/Calendar.js";
|
|
13
|
+
import d from "./date-picker.module.js";
|
|
14
|
+
import { forwardRef as f, useEffect as p, useId as te, useRef as m, useState as h } from "react";
|
|
15
|
+
import g from "classnames";
|
|
16
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
16
17
|
//#region src/components/form/DatePicker/DatePicker.tsx
|
|
17
|
-
var
|
|
18
|
-
let [
|
|
19
|
-
|
|
18
|
+
var y = f(({ intent: f = "default", variant: y = "outline", fullWidth: b = !1, className: x, disabled: S, value: C, defaultValue: w, onChange: T, format: ne = "YYYY-MM-DD", clearable: re = !0, placeholder: ie, minDate: ae, maxDate: oe, disabledDates: se, label: E, error: D, required: O, layout: k, id: A, labels: j, width: M, asChild: N = !1, children: P, ...F }, I) => {
|
|
19
|
+
let [L, R] = h(!1), [z, B] = h(w || null), V = m(null), H = m(null), { t: ce } = n(o), U = te(), W = A || `wim-datepicker-${U}`, G = `${W}-dropdown`, K = E ? `${W}-label` : void 0, q = D ? `${W}-error` : void 0, J = C !== void 0, Y = J ? C : z, le = ie ?? j?.placeholder, X = S, Z = D ? "danger" : f;
|
|
20
|
+
p(() => {
|
|
20
21
|
let e = (e) => {
|
|
21
|
-
|
|
22
|
+
V.current && !V.current.contains(e.target) && R(!1);
|
|
22
23
|
};
|
|
23
24
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
24
|
-
}, []),
|
|
25
|
+
}, []), p(() => {
|
|
25
26
|
let e = (e) => {
|
|
26
|
-
e.key === "Escape" &&
|
|
27
|
+
e.key === "Escape" && L && (R(!1), H.current?.focus());
|
|
27
28
|
};
|
|
28
|
-
return
|
|
29
|
-
}, [
|
|
30
|
-
let
|
|
29
|
+
return L && document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
30
|
+
}, [L]);
|
|
31
|
+
let ue = (e) => {
|
|
31
32
|
if (!e) return "";
|
|
32
33
|
let t = e.getFullYear(), n = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
|
|
33
34
|
return ne.replace("YYYY", String(t)).replace("MM", n).replace("DD", r);
|
|
34
|
-
}, ue = (e) => {
|
|
35
|
-
Y || z(e), w?.(e), L(!1), V.current?.focus();
|
|
36
35
|
}, de = (e) => {
|
|
37
|
-
e?.
|
|
38
|
-
},
|
|
39
|
-
|
|
36
|
+
J || B(e), T?.(e), R(!1), H.current?.focus();
|
|
37
|
+
}, fe = (e) => {
|
|
38
|
+
e?.stopPropagation(), X || (J || B(null), T?.(null));
|
|
39
|
+
}, Q = () => {
|
|
40
|
+
X || R(!L);
|
|
41
|
+
}, pe = (e) => {
|
|
42
|
+
X || (e.key === "Escape" ? (R(!1), H.current?.focus()) : (e.key === "Enter" || e.key === " " || e.key === "ArrowDown" && (e.altKey || !L)) && (e.preventDefault(), R(!L)));
|
|
40
43
|
};
|
|
41
|
-
|
|
42
|
-
if (
|
|
44
|
+
p(() => {
|
|
45
|
+
if (L) {
|
|
43
46
|
let e = setTimeout(() => {
|
|
44
|
-
let e =
|
|
45
|
-
e ? e.focus() :
|
|
47
|
+
let e = V.current?.querySelector("[data-calendar-day][tabindex=\"0\"]:not(:disabled), [data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus");
|
|
48
|
+
e ? e.focus() : V.current?.querySelector("[data-calendar-day]:not([data-other-month]):not(:disabled)")?.focus();
|
|
46
49
|
}, 50);
|
|
47
50
|
return () => clearTimeout(e);
|
|
48
51
|
}
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
}, [L]);
|
|
53
|
+
let $ = N ? e : "div", { setReference: me, setFloating: he, floatingProps: ge } = s({ open: L && !S }), _e = r(V, I, me);
|
|
54
|
+
return /* @__PURE__ */ _(c, {
|
|
55
|
+
label: E,
|
|
56
|
+
error: D,
|
|
57
|
+
required: O,
|
|
58
|
+
layout: k,
|
|
59
|
+
labelId: K,
|
|
60
|
+
htmlFor: W,
|
|
61
|
+
errorId: q,
|
|
62
|
+
className: x,
|
|
63
|
+
children: /* @__PURE__ */ v($, {
|
|
64
|
+
ref: _e,
|
|
65
|
+
className: g("wim-date-picker", d.root, b && d.fullWidth),
|
|
61
66
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
intent:
|
|
64
|
-
variant:
|
|
65
|
-
width:
|
|
66
|
-
fullWidth:
|
|
67
|
-
disabled:
|
|
67
|
+
/* @__PURE__ */ _(ee, {
|
|
68
|
+
intent: Z,
|
|
69
|
+
variant: y,
|
|
70
|
+
width: M,
|
|
71
|
+
fullWidth: b,
|
|
72
|
+
disabled: X,
|
|
68
73
|
allowClear: re,
|
|
69
|
-
hasValue: !!
|
|
70
|
-
onClear:
|
|
74
|
+
hasValue: !!Y,
|
|
75
|
+
onClear: fe,
|
|
71
76
|
rightIcons: [{
|
|
72
77
|
name: "ChevronDownIcon",
|
|
73
|
-
rotated:
|
|
74
|
-
onClick:
|
|
78
|
+
rotated: L,
|
|
79
|
+
onClick: Q,
|
|
75
80
|
decorative: !0
|
|
76
81
|
}],
|
|
77
|
-
children: /* @__PURE__ */
|
|
78
|
-
id:
|
|
79
|
-
ref:
|
|
82
|
+
children: /* @__PURE__ */ _("input", {
|
|
83
|
+
id: W,
|
|
84
|
+
ref: H,
|
|
80
85
|
type: "text",
|
|
81
86
|
readOnly: !0,
|
|
82
87
|
role: "combobox",
|
|
83
|
-
className:
|
|
84
|
-
value:
|
|
85
|
-
placeholder:
|
|
86
|
-
disabled:
|
|
87
|
-
onClick:
|
|
88
|
-
onKeyDown:
|
|
89
|
-
Z || (e.key === "Escape" ? (L(!1), V.current?.focus()) : (e.key === "Enter" || e.key === " " || e.key === "ArrowDown" && (e.altKey || !I)) && (e.preventDefault(), L(!I)));
|
|
90
|
-
},
|
|
88
|
+
className: g(l.root, d.input),
|
|
89
|
+
value: ue(Y),
|
|
90
|
+
placeholder: le,
|
|
91
|
+
disabled: X,
|
|
92
|
+
onClick: Q,
|
|
93
|
+
onKeyDown: pe,
|
|
91
94
|
"aria-haspopup": "dialog",
|
|
92
|
-
"aria-expanded":
|
|
93
|
-
"aria-controls":
|
|
94
|
-
"aria-invalid":
|
|
95
|
-
"aria-describedby":
|
|
96
|
-
"aria-labelledby":
|
|
97
|
-
"aria-required":
|
|
98
|
-
...
|
|
95
|
+
"aria-expanded": L,
|
|
96
|
+
"aria-controls": L ? G : void 0,
|
|
97
|
+
"aria-invalid": Z === "danger",
|
|
98
|
+
"aria-describedby": q,
|
|
99
|
+
"aria-labelledby": K,
|
|
100
|
+
"aria-required": O,
|
|
101
|
+
...F
|
|
99
102
|
})
|
|
100
103
|
}),
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
show:
|
|
104
|
+
/* @__PURE__ */ _(i, {
|
|
105
|
+
show: L && !S,
|
|
103
106
|
preset: "fade",
|
|
104
|
-
id:
|
|
105
|
-
className:
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
id: G,
|
|
108
|
+
className: d.dropdown,
|
|
109
|
+
ref: he,
|
|
110
|
+
...ge,
|
|
111
|
+
children: /* @__PURE__ */ _(a, {
|
|
112
|
+
active: L,
|
|
108
113
|
initialFocus: !1,
|
|
109
|
-
children: /* @__PURE__ */
|
|
114
|
+
children: /* @__PURE__ */ _("div", {
|
|
110
115
|
role: "dialog",
|
|
111
116
|
"aria-modal": "true",
|
|
112
|
-
"aria-labelledby":
|
|
113
|
-
"aria-label":
|
|
114
|
-
children: /* @__PURE__ */
|
|
115
|
-
value:
|
|
116
|
-
onChange:
|
|
117
|
+
"aria-labelledby": K,
|
|
118
|
+
"aria-label": K ? void 0 : F["aria-label"] ?? ce("datepicker.dialog"),
|
|
119
|
+
children: /* @__PURE__ */ _(u, {
|
|
120
|
+
value: Y ?? void 0,
|
|
121
|
+
onChange: de
|
|
117
122
|
})
|
|
118
123
|
})
|
|
119
124
|
})
|
|
120
125
|
}),
|
|
121
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ _(t, { children: P })
|
|
122
127
|
]
|
|
123
128
|
})
|
|
124
129
|
});
|
|
125
130
|
});
|
|
126
|
-
|
|
131
|
+
y.displayName = "DatePicker";
|
|
127
132
|
//#endregion
|
|
128
|
-
export {
|
|
133
|
+
export { y as DatePicker, y as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_1gx5z_4`,t=`_fullWidth_1gx5z_9`,n=`_input_1gx5z_13`,r=`_dropdown_1gx5z_17`,i={root:e,fullWidth:t,input:n,dropdown:r};exports.default=i,exports.dropdown=r,exports.fullWidth=t,exports.input=n,exports.root=e;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/DatePicker/date-picker.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_1gx5z_4", t = "_fullWidth_1gx5z_9", n = "_input_1gx5z_13", r = "_dropdown_1gx5z_17", i = {
|
|
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("../../_internal/BaseListItem/BaseListItem.cjs"),r=require("
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/BaseListItem/BaseListItem.cjs"),r=require("../Textarea/Textarea.cjs"),i=require("../../_internal/mergeRefs.cjs"),a=require("./mentions.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,o.forwardRef)(({options:e,trigger:c=`@`,value:l,defaultValue:u,onChange:d,onSelect:f,asChild:p=!1,children:m,intent:h,variant:g,fullWidth:_,fieldSizing:v,label:y,error:ee,required:b,layout:x,width:S,placeholder:C,rows:w,cols:T,onCopy:E,onCut:D,onPaste:O,...k},A)=>{let j=(0,o.useId)(),M=k.id||`wim-mentions-${j}`,[N,P]=(0,o.useState)(u||``),F=l!==void 0,I=F?l:N,[L,R]=(0,o.useState)(!1),[z,B]=(0,o.useState)(``),[V,H]=(0,o.useState)(0),[U,W]=(0,o.useState)(-1),[G,K]=(0,o.useState)(0),q=(0,o.useRef)(null),J=(0,o.useRef)(null),Y=i.mergeRefs(J,A),X=e.filter(e=>e.display.toLowerCase().includes(z.toLowerCase())),Z=e=>{let t=e.target.value,n=e.target.selectionStart;H(n),F||P(t),d&&d(e);let r=t.slice(0,n),i=r.lastIndexOf(c);if(i!==-1){let e=r.slice(i+c.length);if(!e.includes(` `)){W(i),B(e),R(!0),K(0);return}}R(!1),W(-1)},Q=e=>{let t=I.slice(0,U),n=I.slice(V),r=`${t}${c}${e.display} ${n}`;F||P(r),d&&d({target:{value:r}}),f&&f(e),R(!1),W(-1),setTimeout(()=>{if(q.current){q.current.focus();let n=t.length+c.length+e.display.length+1;q.current.setSelectionRange(n,n)}},0)},te=e=>{L&&X.length>0&&(e.key===`ArrowDown`?(e.preventDefault(),K(e=>e>=X.length-1?0:e+1)):e.key===`ArrowUp`?(e.preventDefault(),K(e=>e<=0?X.length-1:e-1)):e.key===`Enter`||e.key===`Tab`?G>=0&&X[G]&&(e.preventDefault(),Q(X[G])):e.key===`Escape`&&R(!1))},ne=p?t.Root:`div`,re={intent:h,variant:g,fullWidth:_,fieldSizing:v,label:y,error:ee,required:b,layout:x,width:S,placeholder:C,rows:w,cols:T,onCopy:E,onCut:D,onPaste:O},$={...k};delete $[`aria-label`],delete $[`aria-labelledby`],delete $[`aria-describedby`],delete $.id;let ie=$;return(0,s.jsxs)(ne,{className:`wim-mentions ${a.default.container}`,ref:Y,...ie,children:[(0,s.jsx)(r.Textarea,{...k,...re,ref:q,value:I,onChange:Z,onKeyDown:te,"aria-autocomplete":`list`,"aria-controls":L?`${M}-list`:void 0,onBlur:e=>{J.current?.contains(e.relatedTarget)||R(!1)}}),L&&X.length>0&&(0,s.jsx)(`div`,{id:`${M}-list`,className:a.default.list,role:`listbox`,children:X.map((e,t)=>(0,s.jsx)(n.BaseListItem,{active:t===G,onMouseDown:e=>e.preventDefault(),onClick:()=>Q(e),onMouseEnter:()=>K(t),role:`option`,"aria-selected":t===G,tabIndex:-1,children:e.display},e.id))}),p?(0,s.jsx)(t.Slottable,{children:m}):null]})});c.displayName=`Mentions`,exports.Mentions=c,exports.default=c;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { BaseListItem as n } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Textarea as r } from "../Textarea/Textarea.js";
|
|
5
|
+
import { mergeRefs as i } from "../../_internal/mergeRefs.js";
|
|
6
6
|
import a from "./mentions.module.js";
|
|
7
7
|
import { forwardRef as o, useId as s, useRef as c, useState as l } from "react";
|
|
8
8
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/form/Mentions/Mentions.tsx
|
|
10
10
|
var f = o(({ options: o, trigger: f = "@", value: p, defaultValue: ee, onChange: m, onSelect: h, asChild: g = !1, children: _, intent: v, variant: y, fullWidth: b, fieldSizing: x, label: S, error: C, required: w, layout: T, width: E, placeholder: D, rows: te, cols: ne, onCopy: O, onCut: k, onPaste: A, ...j }, M) => {
|
|
11
|
-
let N = s(), P = j.id || `wim-mentions-${N}`, [F, I] = l(ee || ""), L = p !== void 0, R = L ? p : F, [z, B] = l(!1), [V, H] = l(""), [U, W] = l(0), [G, K] = l(-1), [q, J] = l(0), Y = c(null), X = c(null), re =
|
|
11
|
+
let N = s(), P = j.id || `wim-mentions-${N}`, [F, I] = l(ee || ""), L = p !== void 0, R = L ? p : F, [z, B] = l(!1), [V, H] = l(""), [U, W] = l(0), [G, K] = l(-1), [q, J] = l(0), Y = c(null), X = c(null), re = i(X, M), Z = o.filter((e) => e.display.toLowerCase().includes(V.toLowerCase())), ie = (e) => {
|
|
12
12
|
let t = e.target.value, n = e.target.selectionStart;
|
|
13
13
|
W(n), L || I(t), m && m(e);
|
|
14
14
|
let r = t.slice(0, n), i = r.lastIndexOf(f);
|
|
@@ -55,7 +55,7 @@ var f = o(({ options: o, trigger: f = "@", value: p, defaultValue: ee, onChange:
|
|
|
55
55
|
ref: re,
|
|
56
56
|
...ce,
|
|
57
57
|
children: [
|
|
58
|
-
/* @__PURE__ */ u(
|
|
58
|
+
/* @__PURE__ */ u(r, {
|
|
59
59
|
...j,
|
|
60
60
|
...se,
|
|
61
61
|
ref: Y,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../icon/check.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../../icon/check.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("../../_internal/useInlineFloating.cjs"),s=require("../FieldTemplate/FieldTemplate.cjs"),ee=require("../../data-display/Chip/Chip.cjs"),c=require("./multiselect.module.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("classnames");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=({options:e=[],value:f,onChange:p,placeholder:m,label:h,error:g,required:_,layout:v,className:y,disabled:b=!1,defaultValue:x=[],allowClear:S=!1,id:C,width:w,fullWidth:T=!1,...E})=>{let[D,O]=(0,l.useState)(!1),[k,A]=(0,l.useState)(x),[j,M]=(0,l.useState)(-1),[N,P]=(0,l.useState)(!1),F=(0,l.useRef)(null),I=(0,l.useRef)(null),L=(0,l.useRef)(null),R=(0,l.useId)(),z=C||`wim-multiselect-${R}`,B=`${z}-list`,V=h?`${z}-label`:void 0,H=g?`${z}-error`:void 0,U=`${z}-trigger`,W=f!==void 0,G=W?f:k;(0,l.useEffect)(()=>{let e=e=>{F.current&&!F.current.contains(e.target)&&O(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let K=e=>{if(b||e&&e.target.closest(`[data-chip-delete]`))return;let t=!D;O(t),M(t?0:-1)},q=e=>{if(b)return;let t;t=G?.includes(e)?G.filter(t=>t!==e):[...G||[],e],W||A(t),p&&p(t)},J=(e,t)=>{if(e.stopPropagation(),b)return;let n=(G||[]).filter(e=>e!==t);W||A(n),p&&p(n)},Y=e=>{e?.stopPropagation(),!b&&(W||A([]),p&&p([]))},X=e.filter(e=>G?.includes(e.value)),Z=t=>{if(P(!0),!b)switch(t.key){case`ArrowDown`:t.preventDefault(),D?M(t=>t<e.length-1?t+1:0):(O(!0),M(0));break;case`ArrowUp`:t.preventDefault(),D&&M(t=>t>0?t-1:e.length-1);break;case`Enter`:case` `:t.preventDefault(),D?j>=0&&q(e[j].value):(O(!0),M(0));break;case`Escape`:D&&(t.preventDefault(),O(!1),M(-1),L.current?.focus());break;case`Home`:D&&(t.preventDefault(),M(0));break;case`End`:D&&(t.preventDefault(),M(e.length-1));break;case`Tab`:D&&(O(!1),M(-1))}};(0,l.useEffect)(()=>{D&&j>=0&&I.current&&I.current.children[j]?.scrollIntoView({block:`nearest`})},[j,D]);let{"aria-label":Q,"aria-labelledby":$,"aria-describedby":te,...ne}=E,{setReference:re,setFloating:ie,floatingProps:ae}=o.useInlineFloating({open:D&&!b}),oe=t.useMergedRef(F,re),se=t.useMergedRef(I,ie);return(0,d.jsx)(s.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:V,htmlFor:U,errorId:H,className:y,children:(0,d.jsxs)(`div`,{className:(0,u.default)(`wim-multi-select`,c.default.root,T&&c.default.fullWidth),ref:oe,onMouseMove:()=>P(!1),"data-keyboard-nav":N,...ne,children:[(0,d.jsx)(a.InputBase,{disabled:b,allowClear:S,hasValue:G&&G.length>0,onClear:Y,intent:g?`danger`:`default`,width:w,fullWidth:T,rightIcons:[{name:`ChevronDownIcon`,rotated:D}],className:(0,u.default)(D&&c.default.open),children:(0,d.jsx)(`div`,{id:U,"data-testid":`multiselect-trigger`,className:(0,u.default)(c.default.trigger,b&&c.default.disabled),onClick:K,tabIndex:b?-1:0,role:`combobox`,"aria-expanded":D,"aria-haspopup":`listbox`,"aria-controls":D?B:void 0,"aria-disabled":b,"aria-labelledby":V||$,"aria-describedby":H||te,"aria-required":_,"aria-invalid":!!g,"aria-label":h?void 0:Q||m,onKeyDown:Z,ref:L,"aria-activedescendant":D&&j>=0?`${z}-option-${j}`:void 0,children:(0,d.jsx)(`div`,{className:(0,u.default)(c.default.value,X.length===0&&c.default.placeholder),children:X.length>0?X.map(e=>(0,d.jsx)(ee.Chip,{"data-testid":`multiselect-chip`,size:`sm`,intent:`neutral`,variant:`solid`,disabled:b,onDelete:b?void 0:t=>J(t,e.value),children:e.label},e.value)):m})})}),D&&!b&&(0,d.jsx)(`ul`,{id:B,ref:se,className:c.default.list,...ae,role:`listbox`,"aria-multiselectable":`true`,"aria-labelledby":V||$||void 0,children:e.map((e,t)=>{let a=G?.includes(e.value),o=t===j;return(0,d.jsx)(i.BaseListItem,{asChild:!0,id:`${z}-option-${t}`,className:(0,u.default)(c.default.option,a&&c.default.selected),active:o,disabled:e.disabled,onClick:()=>!e.disabled&&q(e.value),onMouseEnter:()=>M(t),rightSection:a?(0,d.jsx)(r.Icon,{component:n.default,size:`sm`}):void 0,role:`option`,"aria-selected":a,tabIndex:-1,children:(0,d.jsx)(`li`,{children:e.label})},e.value)})})]})})};f.displayName=`MultiSelect`,exports.MultiSelect=f;
|
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import e from "../../../
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import o from "
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
2
|
+
import { useMergedRef as e } from "../../../hooks/useMergedRef.js";
|
|
3
|
+
import t from "../../../icon/check.js";
|
|
4
|
+
import { Icon as n } from "../../media/Icon/Icon.js";
|
|
5
|
+
import { BaseListItem as r } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
6
|
+
import { InputBase as i } from "../InputBase/InputBase.js";
|
|
7
|
+
import { useInlineFloating as a } from "../../_internal/useInlineFloating.js";
|
|
8
|
+
import { FieldTemplate as o } from "../FieldTemplate/FieldTemplate.js";
|
|
9
|
+
import { Chip as s } from "../../data-display/Chip/Chip.js";
|
|
10
|
+
import c from "./multiselect.module.js";
|
|
11
|
+
import { useEffect as l, useId as u, useRef as d, useState as f } from "react";
|
|
12
|
+
import p from "classnames";
|
|
13
|
+
import { jsx as m, jsxs as ee } from "react/jsx-runtime";
|
|
12
14
|
//#region src/components/form/MultiSelect/MultiSelect.tsx
|
|
13
|
-
var
|
|
14
|
-
let [k, A] =
|
|
15
|
-
|
|
15
|
+
var h = ({ options: h = [], value: g, onChange: _, placeholder: v, label: y, error: b, required: x, layout: S, className: C, disabled: w = !1, defaultValue: T = [], allowClear: te = !1, id: ne, width: E, fullWidth: D = !1, ...O }) => {
|
|
16
|
+
let [k, A] = f(!1), [j, M] = f(T), [N, P] = f(-1), [F, I] = f(!1), L = d(null), R = d(null), z = d(null), B = u(), V = ne || `wim-multiselect-${B}`, H = `${V}-list`, U = y ? `${V}-label` : void 0, W = b ? `${V}-error` : void 0, G = `${V}-trigger`, K = g !== void 0, q = K ? g : j;
|
|
17
|
+
l(() => {
|
|
16
18
|
let e = (e) => {
|
|
17
19
|
L.current && !L.current.contains(e.target) && A(!1);
|
|
18
20
|
};
|
|
19
21
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
20
22
|
}, []);
|
|
21
23
|
let J = (e) => {
|
|
22
|
-
if (
|
|
24
|
+
if (w || e && e.target.closest("[data-chip-delete]")) return;
|
|
23
25
|
let t = !k;
|
|
24
26
|
A(t), P(t ? 0 : -1);
|
|
25
27
|
}, Y = (e) => {
|
|
26
|
-
if (
|
|
28
|
+
if (w) return;
|
|
27
29
|
let t;
|
|
28
|
-
t = q?.includes(e) ? q.filter((t) => t !== e) : [...q || [], e], K || M(t),
|
|
30
|
+
t = q?.includes(e) ? q.filter((t) => t !== e) : [...q || [], e], K || M(t), _ && _(t);
|
|
29
31
|
}, X = (e, t) => {
|
|
30
|
-
if (e.stopPropagation(),
|
|
32
|
+
if (e.stopPropagation(), w) return;
|
|
31
33
|
let n = (q || []).filter((e) => e !== t);
|
|
32
|
-
K || M(n),
|
|
33
|
-
},
|
|
34
|
-
e?.stopPropagation(), !
|
|
35
|
-
},
|
|
36
|
-
if (I(!0), !
|
|
34
|
+
K || M(n), _ && _(n);
|
|
35
|
+
}, re = (e) => {
|
|
36
|
+
e?.stopPropagation(), !w && (K || M([]), _ && _([]));
|
|
37
|
+
}, Z = h.filter((e) => q?.includes(e.value)), ie = (e) => {
|
|
38
|
+
if (I(!0), !w) switch (e.key) {
|
|
37
39
|
case "ArrowDown":
|
|
38
|
-
e.preventDefault(), k ? P((e) => e <
|
|
40
|
+
e.preventDefault(), k ? P((e) => e < h.length - 1 ? e + 1 : 0) : (A(!0), P(0));
|
|
39
41
|
break;
|
|
40
42
|
case "ArrowUp":
|
|
41
|
-
e.preventDefault(), k && P((e) => e > 0 ? e - 1 :
|
|
43
|
+
e.preventDefault(), k && P((e) => e > 0 ? e - 1 : h.length - 1);
|
|
42
44
|
break;
|
|
43
45
|
case "Enter":
|
|
44
46
|
case " ":
|
|
45
|
-
e.preventDefault(), k ? N >= 0 && Y(
|
|
47
|
+
e.preventDefault(), k ? N >= 0 && Y(h[N].value) : (A(!0), P(0));
|
|
46
48
|
break;
|
|
47
49
|
case "Escape":
|
|
48
50
|
k && (e.preventDefault(), A(!1), P(-1), z.current?.focus());
|
|
@@ -51,106 +53,107 @@ var m = ({ options: m = [], value: h, onChange: g, placeholder: _, label: v, err
|
|
|
51
53
|
k && (e.preventDefault(), P(0));
|
|
52
54
|
break;
|
|
53
55
|
case "End":
|
|
54
|
-
k && (e.preventDefault(), P(
|
|
56
|
+
k && (e.preventDefault(), P(h.length - 1));
|
|
55
57
|
break;
|
|
56
58
|
case "Tab": k && (A(!1), P(-1));
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
|
-
|
|
61
|
+
l(() => {
|
|
60
62
|
k && N >= 0 && R.current && R.current.children[N]?.scrollIntoView({ block: "nearest" });
|
|
61
63
|
}, [N, k]);
|
|
62
|
-
let { "aria-label":
|
|
63
|
-
return /* @__PURE__ */
|
|
64
|
-
label:
|
|
65
|
-
error:
|
|
66
|
-
required:
|
|
67
|
-
layout:
|
|
64
|
+
let { "aria-label": Q, "aria-labelledby": $, "aria-describedby": ae, ...oe } = O, { setReference: se, setFloating: ce, floatingProps: le } = a({ open: k && !w }), ue = e(L, se), de = e(R, ce);
|
|
65
|
+
return /* @__PURE__ */ m(o, {
|
|
66
|
+
label: y,
|
|
67
|
+
error: b,
|
|
68
|
+
required: x,
|
|
69
|
+
layout: S,
|
|
68
70
|
labelId: U,
|
|
69
71
|
htmlFor: G,
|
|
70
72
|
errorId: W,
|
|
71
|
-
className:
|
|
72
|
-
children: /* @__PURE__ */
|
|
73
|
-
className:
|
|
74
|
-
ref:
|
|
73
|
+
className: C,
|
|
74
|
+
children: /* @__PURE__ */ ee("div", {
|
|
75
|
+
className: p("wim-multi-select", c.root, D && c.fullWidth),
|
|
76
|
+
ref: ue,
|
|
75
77
|
onMouseMove: () => I(!1),
|
|
76
78
|
"data-keyboard-nav": F,
|
|
77
|
-
...
|
|
78
|
-
children: [/* @__PURE__ */
|
|
79
|
-
disabled:
|
|
80
|
-
allowClear:
|
|
79
|
+
...oe,
|
|
80
|
+
children: [/* @__PURE__ */ m(i, {
|
|
81
|
+
disabled: w,
|
|
82
|
+
allowClear: te,
|
|
81
83
|
hasValue: q && q.length > 0,
|
|
82
|
-
onClear:
|
|
83
|
-
intent:
|
|
84
|
-
width:
|
|
85
|
-
fullWidth:
|
|
84
|
+
onClear: re,
|
|
85
|
+
intent: b ? "danger" : "default",
|
|
86
|
+
width: E,
|
|
87
|
+
fullWidth: D,
|
|
86
88
|
rightIcons: [{
|
|
87
89
|
name: "ChevronDownIcon",
|
|
88
90
|
rotated: k
|
|
89
91
|
}],
|
|
90
|
-
className:
|
|
91
|
-
children: /* @__PURE__ */
|
|
92
|
+
className: p(k && c.open),
|
|
93
|
+
children: /* @__PURE__ */ m("div", {
|
|
92
94
|
id: G,
|
|
93
95
|
"data-testid": "multiselect-trigger",
|
|
94
|
-
className:
|
|
96
|
+
className: p(c.trigger, w && c.disabled),
|
|
95
97
|
onClick: J,
|
|
96
|
-
tabIndex:
|
|
98
|
+
tabIndex: w ? -1 : 0,
|
|
97
99
|
role: "combobox",
|
|
98
100
|
"aria-expanded": k,
|
|
99
101
|
"aria-haspopup": "listbox",
|
|
100
102
|
"aria-controls": k ? H : void 0,
|
|
101
|
-
"aria-disabled":
|
|
103
|
+
"aria-disabled": w,
|
|
102
104
|
"aria-labelledby": U || $,
|
|
103
|
-
"aria-describedby": W ||
|
|
104
|
-
"aria-required":
|
|
105
|
-
"aria-invalid": !!
|
|
106
|
-
"aria-label":
|
|
107
|
-
onKeyDown:
|
|
105
|
+
"aria-describedby": W || ae,
|
|
106
|
+
"aria-required": x,
|
|
107
|
+
"aria-invalid": !!b,
|
|
108
|
+
"aria-label": y ? void 0 : Q || v,
|
|
109
|
+
onKeyDown: ie,
|
|
108
110
|
ref: z,
|
|
109
111
|
"aria-activedescendant": k && N >= 0 ? `${V}-option-${N}` : void 0,
|
|
110
|
-
children: /* @__PURE__ */
|
|
111
|
-
className:
|
|
112
|
-
children:
|
|
112
|
+
children: /* @__PURE__ */ m("div", {
|
|
113
|
+
className: p(c.value, Z.length === 0 && c.placeholder),
|
|
114
|
+
children: Z.length > 0 ? Z.map((e) => /* @__PURE__ */ m(s, {
|
|
113
115
|
"data-testid": "multiselect-chip",
|
|
114
116
|
size: "sm",
|
|
115
117
|
intent: "neutral",
|
|
116
118
|
variant: "solid",
|
|
117
|
-
disabled:
|
|
118
|
-
onDelete:
|
|
119
|
+
disabled: w,
|
|
120
|
+
onDelete: w ? void 0 : (t) => X(t, e.value),
|
|
119
121
|
children: e.label
|
|
120
|
-
}, e.value)) :
|
|
122
|
+
}, e.value)) : v
|
|
121
123
|
})
|
|
122
124
|
})
|
|
123
|
-
}), k && !
|
|
125
|
+
}), k && !w && /* @__PURE__ */ m("ul", {
|
|
124
126
|
id: H,
|
|
125
|
-
ref:
|
|
126
|
-
className:
|
|
127
|
+
ref: de,
|
|
128
|
+
className: c.list,
|
|
129
|
+
...le,
|
|
127
130
|
role: "listbox",
|
|
128
131
|
"aria-multiselectable": "true",
|
|
129
132
|
"aria-labelledby": U || $ || void 0,
|
|
130
|
-
children:
|
|
131
|
-
let a = q?.includes(
|
|
132
|
-
return /* @__PURE__ */
|
|
133
|
+
children: h.map((e, i) => {
|
|
134
|
+
let a = q?.includes(e.value), o = i === N;
|
|
135
|
+
return /* @__PURE__ */ m(r, {
|
|
133
136
|
asChild: !0,
|
|
134
137
|
id: `${V}-option-${i}`,
|
|
135
|
-
className:
|
|
136
|
-
active:
|
|
137
|
-
disabled:
|
|
138
|
-
onClick: () => !
|
|
138
|
+
className: p(c.option, a && c.selected),
|
|
139
|
+
active: o,
|
|
140
|
+
disabled: e.disabled,
|
|
141
|
+
onClick: () => !e.disabled && Y(e.value),
|
|
139
142
|
onMouseEnter: () => P(i),
|
|
140
|
-
rightSection: a ? /* @__PURE__ */
|
|
141
|
-
component:
|
|
143
|
+
rightSection: a ? /* @__PURE__ */ m(n, {
|
|
144
|
+
component: t,
|
|
142
145
|
size: "sm"
|
|
143
146
|
}) : void 0,
|
|
144
147
|
role: "option",
|
|
145
148
|
"aria-selected": a,
|
|
146
149
|
tabIndex: -1,
|
|
147
|
-
children: /* @__PURE__ */
|
|
148
|
-
},
|
|
150
|
+
children: /* @__PURE__ */ m("li", { children: e.label })
|
|
151
|
+
}, e.value);
|
|
149
152
|
})
|
|
150
153
|
})]
|
|
151
154
|
})
|
|
152
155
|
});
|
|
153
156
|
};
|
|
154
|
-
|
|
157
|
+
h.displayName = "MultiSelect";
|
|
155
158
|
//#endregion
|
|
156
|
-
export {
|
|
159
|
+
export { h as MultiSelect };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_58yea_23`,t=`_fullWidth_58yea_30`,n=`_trigger_58yea_34`,r=`_disabled_58yea_55`,i=`_open_58yea_76`,a=`_value_58yea_84`,o=`_placeholder_58yea_85`,s=`_icon_58yea_88`,c=`_list_58yea_108`,l=`_option_58yea_129`,u=`_active_58yea_129`,d=`_selected_58yea_133`,f=`_clear_58yea_144`,p={root:e,fullWidth:t,trigger:n,disabled:r,open:i,value:a,placeholder:o,icon:s,list:c,option:l,active:u,selected:d,clear:f};exports.active=u,exports.clear=f,exports.default=p,exports.disabled=r,exports.fullWidth=t,exports.icon=s,exports.list=c,exports.open=i,exports.option=l,exports.placeholder=o,exports.root=e,exports.selected=d,exports.trigger=n,exports.value=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/MultiSelect/multiselect.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_58yea_23", t = "_fullWidth_58yea_30", n = "_trigger_58yea_34", r = "_disabled_58yea_55", i = "_open_58yea_76", a = "_value_58yea_84", o = "_placeholder_58yea_85", s = "_icon_58yea_88", c = "_list_58yea_108", l = "_option_58yea_129", u = "_active_58yea_129", d = "_selected_58yea_133", f = "_clear_58yea_144", p = {
|
|
4
4
|
root: e,
|
|
5
5
|
fullWidth: t,
|
|
6
6
|
trigger: n,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/Transition/Transition.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../../icon/chevron-down.cjs"),a=require("../../media/Icon/Icon.cjs"),o=require("../../_internal/useInlineFloating.cjs"),s=require("../../../i18n/generated/form.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),l=require("./phone-input.module.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=[{code:`US`,dialCode:`1`,flag:`🇺🇸`},{code:`JP`,dialCode:`81`,flag:`🇯🇵`},{code:`GB`,dialCode:`44`,flag:`🇬🇧`},{code:`AU`,dialCode:`61`,flag:`🇦🇺`},{code:`DE`,dialCode:`49`,flag:`🇩🇪`},{code:`FR`,dialCode:`33`,flag:`🇫🇷`},{code:`CN`,dialCode:`86`,flag:`🇨🇳`},{code:`KR`,dialCode:`82`,flag:`🇰🇷`},{code:`IN`,dialCode:`91`,flag:`🇮🇳`},{code:`BR`,dialCode:`55`,flag:`🇧🇷`}],m=(0,u.forwardRef)(({value:e=``,onChange:m,countryCode:h=`US`,onCountryChange:g,placeholder:_=`000-0000-0000`,disabled:v=!1,error:y,required:b=!1,label:x,layout:S=`vertical`,className:C,fullWidth:w=!1,"aria-label":T,"aria-labelledby":E,"aria-describedby":D,...O},k)=>{let A=`wim-phone-input-${(0,u.useId)()}`,j=x?`${A}-label`:void 0,{t:M}=t.useWimTranslation(s.formNs),N=M(`phone.select_country`),P=`${A}-countries`,F=e=>`${A}-country-${e}`,I=y?`${A}-error`:void 0,[L,R]=(0,u.useState)(!1),[z,B]=(0,u.useState)(-1),V=(0,u.useRef)(null),H=(0,u.useRef)(null),U=(0,u.useRef)({text:``,timer:null});(0,u.useEffect)(()=>{let e=e=>{V.current&&!V.current.contains(e.target)&&R(!1)};return L&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[L]);let W=p.find(e=>e.code===h)??p[0],G=e=>{m?.(e.target.value)},K=p.length-1,q=e=>{let t=p.findIndex(e=>e.code===W.code);B(e??Math.max(t,0)),R(!0)},J=e=>{let t=p[e];t&&(g?.(t.code),R(!1))},Y=e=>M(`phone.countries.${e.code}`),X=e=>s.formNs.resources.en?.phone?.countries?.[e.code]??``,Z=(e,t)=>{let n=e.toLowerCase().replace(/^\+/,``);if(n===``)return-1;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]:[e=>Y(e).toLowerCase(),e=>X(e).toLowerCase(),e=>e.code.toLowerCase()];for(let e of s)for(let t=0;t<p.length;t++){let n=(Math.max(o,0)+t)%p.length;if(e(p[n]).startsWith(a))return n}return-1},Q=e=>{let t=U.current;t.timer&&clearTimeout(t.timer),t.text+=e,t.timer=setTimeout(()=>{t.text=``,t.timer=null},500);let n=Z(t.text,L?z:-1);n<0||(L?B(n):q(n))},$=e=>{if(!v)switch(e.key){case`ArrowDown`:case`ArrowUp`:if(e.preventDefault(),!L)q();else{let t=e.key===`ArrowDown`?1:-1;B(e=>(e+t+p.length)%p.length)}break;case`Home`:case`End`:e.preventDefault(),L?B(e.key===`Home`?0:K):q(e.key===`Home`?0:K);break;case`Enter`:case` `:e.preventDefault(),e.key===` `&&U.current.text!==``?Q(` `):L?J(z):q();break;case`Escape`:L&&(e.preventDefault(),R(!1));break;case`Tab`:R(!1);break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),Q(e.key))}};(0,u.useEffect)(()=>{let e=U.current;return()=>{e.timer&&clearTimeout(e.timer)}},[]),(0,u.useEffect)(()=>{L&&z>=0&&(H.current?.querySelectorAll(`[role="option"]`)?.[z])?.scrollIntoView?.({block:`nearest`})},[z,L]);let{setReference:ee,setFloating:te,floatingProps:ne}=o.useInlineFloating({open:L}),re=n.useMergedRef(V,ee);return(0,f.jsx)(c.FieldTemplate,{label:x,labelId:j,htmlFor:A,required:b,error:y,errorId:I,layout:S,className:C,children:(0,f.jsxs)(`div`,{ref:re,className:(0,d.default)(`wim-phone-input`,l.default.root,w&&l.default.fullWidth,v&&l.default.disabled,y&&l.default.danger),"data-testid":`phone-input-root`,...O,children:[(0,f.jsxs)(`div`,{className:l.default.countryWrapper,children:[(0,f.jsxs)(`button`,{type:`button`,role:`combobox`,className:l.default.countryTrigger,onClick:()=>{v||(L?R(!1):q())},onKeyDown:$,onKeyUp:e=>{e.key===` `&&e.preventDefault()},disabled:v,"aria-haspopup":`listbox`,"aria-expanded":L,"aria-controls":L?P:void 0,"aria-activedescendant":L&&z>=0?F(z):void 0,"aria-label":N,children:[(0,f.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`1.2em`},children:W.flag}),(0,f.jsxs)(`span`,{children:[`+`,W.dialCode]}),(0,f.jsx)(a.Icon,{component:i.default,size:`sm`,className:(0,d.default)(l.default.chevron,L&&l.default.chevronOpen)})]}),(0,f.jsx)(r.Transition,{show:L,preset:`fade`,className:l.default.dropdown,ref:te,...ne,children:(0,f.jsx)(`ul`,{ref:H,id:P,className:l.default.countryList,role:`listbox`,"aria-label":N,tabIndex:-1,onMouseDown:e=>e.preventDefault(),children:p.map((e,t)=>(0,f.jsxs)(`li`,{id:F(t),className:(0,d.default)(l.default.countryOption,t===z&&l.default.active,W.code===e.code&&l.default.selected),onMouseEnter:()=>B(t),onClick:()=>J(t),role:`option`,"aria-selected":W.code===e.code,children:[(0,f.jsx)(`span`,{"aria-hidden":`true`,children:e.flag}),(0,f.jsx)(`span`,{className:l.default.countryName,children:Y(e)}),` `,(0,f.jsxs)(`span`,{className:l.default.countryCode,children:[`+`,e.dialCode]})]},e.code))})})]}),(0,f.jsx)(`div`,{className:l.default.divider,"aria-hidden":`true`}),(0,f.jsx)(`input`,{id:A,ref:k,type:`tel`,value:e,onChange:G,placeholder:_,disabled:v,className:l.default.number,"aria-invalid":!!y,"aria-label":x?void 0:T,"aria-labelledby":x?void 0:E,"aria-describedby":[D,I].filter(Boolean).join(` `)||void 0})]})})});m.displayName=`PhoneInput`,exports.PHONE_COUNTRIES=p,exports.PhoneInput=m;
|