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
|
@@ -4,41 +4,46 @@ import { useWimTranslation as n } from "../../../i18n/useWimTranslation.js";
|
|
|
4
4
|
import { Transition as r } from "../../layout/Transition/Transition.js";
|
|
5
5
|
import { BaseListItem as i } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
6
6
|
import { InputBase as a } from "../InputBase/InputBase.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import l from "
|
|
7
|
+
import { useInlineFloating as o } from "../../_internal/useInlineFloating.js";
|
|
8
|
+
import { formNs as s } from "../../../i18n/generated/form.js";
|
|
9
|
+
import { FieldTemplate as c } from "../FieldTemplate/FieldTemplate.js";
|
|
10
|
+
import { mergeRefs as l } from "../../_internal/mergeRefs.js";
|
|
11
|
+
import u from "./select.module.js";
|
|
11
12
|
import { useSelect as ee } from "./useSelect.js";
|
|
12
|
-
import te, { forwardRef as
|
|
13
|
-
import
|
|
14
|
-
import { jsx as
|
|
13
|
+
import te, { forwardRef as d, useId as f, useMemo as ne } from "react";
|
|
14
|
+
import p from "classnames";
|
|
15
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
15
16
|
//#region src/components/form/Select/Select.tsx
|
|
16
|
-
var
|
|
17
|
-
let { t:
|
|
18
|
-
options:
|
|
19
|
-
value:
|
|
20
|
-
onChange:
|
|
21
|
-
defaultValue:
|
|
22
|
-
searchable:
|
|
23
|
-
grouped:
|
|
24
|
-
disabled:
|
|
25
|
-
filterOption:
|
|
26
|
-
}),
|
|
17
|
+
var g = d(({ options: d = [], value: g, onChange: re, placeholder: _, label: v, error: y, required: b, layout: ie, className: ae, disabled: x = !1, defaultValue: oe, searchable: S = !1, searchPlaceholder: C, filterOption: w, grouped: T = !1, allowClear: E = !1, fullWidth: D = !1, intent: se = "default", id: ce, noOptionsFoundLabel: O, width: k, styles: A, asChild: le = !1, children: ue, ...de }, j) => {
|
|
18
|
+
let { t: fe } = n(s), pe = f(), M = ce || `wim-select-${pe}`, N = v ? `${M}-label` : void 0, P = y ? `${M}-error` : void 0, F = `${M}-list`, I = `${M}-trigger`, L = y ? "danger" : se, { isOpen: R, searchValue: z, setSearchValue: me, focusedIndex: B, setFocusedIndex: V, isKeyboardNavigating: he, setIsKeyboardNavigating: ge, containerRef: H, triggerRef: _e, searchInputRef: ve, listItemsRef: U, currentValue: W, filteredOptions: G, selectedOption: K, focusedOption: q, handleToggle: ye, handleSelect: J, handleClear: be, handleKeyDown: Y } = ee({
|
|
19
|
+
options: d,
|
|
20
|
+
value: g,
|
|
21
|
+
onChange: re,
|
|
22
|
+
defaultValue: oe,
|
|
23
|
+
searchable: S,
|
|
24
|
+
grouped: T,
|
|
25
|
+
disabled: x,
|
|
26
|
+
filterOption: w
|
|
27
|
+
}), { setReference: X, setFloating: xe, floatingProps: Se } = o({ open: R && !x }), Ce = ne(() => l(H, j, X), [
|
|
28
|
+
H,
|
|
29
|
+
j,
|
|
30
|
+
X
|
|
31
|
+
]), we = () => {
|
|
27
32
|
let e = 0;
|
|
28
|
-
return
|
|
29
|
-
let r = t.options.filter((e) => e.type === "separator" || !z || (
|
|
30
|
-
return r.length === 0 ? null : /* @__PURE__ */
|
|
31
|
-
className:
|
|
33
|
+
return T && d.length > 0 && "options" in d[0] ? d.map((t, n) => {
|
|
34
|
+
let r = t.options.filter((e) => e.type === "separator" || !z || (w || ((e, t) => (typeof e.label == "string" ? e.label : "").toLowerCase().includes(t.toLowerCase())))(e, z));
|
|
35
|
+
return r.length === 0 ? null : /* @__PURE__ */ h(te.Fragment, { children: [/* @__PURE__ */ m("li", {
|
|
36
|
+
className: p(u.groupLabel, A?.groupLabel),
|
|
32
37
|
role: "presentation",
|
|
33
38
|
children: t.label
|
|
34
39
|
}), r.map((t, r) => {
|
|
35
40
|
let a = e++;
|
|
36
|
-
if (t.type === "separator") return /* @__PURE__ */
|
|
37
|
-
className:
|
|
41
|
+
if (t.type === "separator") return /* @__PURE__ */ m("li", {
|
|
42
|
+
className: p(u.separator, A?.separator),
|
|
38
43
|
role: "presentation"
|
|
39
44
|
}, `sep-${n}-${r}`);
|
|
40
|
-
let o = a ===
|
|
41
|
-
return /* @__PURE__ */
|
|
45
|
+
let o = a === B, s = W === t.value, c = `wim-select-option-${M}-${t.value}`;
|
|
46
|
+
return /* @__PURE__ */ m(i, {
|
|
42
47
|
asChild: !0,
|
|
43
48
|
id: c,
|
|
44
49
|
ref: (e) => {
|
|
@@ -46,24 +51,24 @@ var m = u(({ options: u = [], value: m, onChange: h, placeholder: g, label: _, e
|
|
|
46
51
|
},
|
|
47
52
|
active: o,
|
|
48
53
|
disabled: t.disabled,
|
|
49
|
-
className:
|
|
54
|
+
className: p(u.option, s && u.selected, A?.option),
|
|
50
55
|
onClick: (e) => {
|
|
51
56
|
e.stopPropagation(), J(t);
|
|
52
57
|
},
|
|
53
|
-
onMouseEnter: () =>
|
|
58
|
+
onMouseEnter: () => V(a),
|
|
54
59
|
role: "option",
|
|
55
60
|
"aria-selected": s,
|
|
56
|
-
children: /* @__PURE__ */
|
|
61
|
+
children: /* @__PURE__ */ m("li", { children: t.label })
|
|
57
62
|
}, t.value);
|
|
58
63
|
})] }, n);
|
|
59
64
|
}) : G.map((t, n) => {
|
|
60
65
|
let r = e++;
|
|
61
|
-
if (t.type === "separator") return /* @__PURE__ */
|
|
62
|
-
className:
|
|
66
|
+
if (t.type === "separator") return /* @__PURE__ */ m("li", {
|
|
67
|
+
className: p(u.separator, A?.separator),
|
|
63
68
|
role: "presentation"
|
|
64
69
|
}, `sep-${n}`);
|
|
65
|
-
let a = r ===
|
|
66
|
-
return /* @__PURE__ */
|
|
70
|
+
let a = r === B, o = W === t.value, s = `wim-select-option-${M}-${t.value}`;
|
|
71
|
+
return /* @__PURE__ */ m(i, {
|
|
67
72
|
asChild: !0,
|
|
68
73
|
id: s,
|
|
69
74
|
ref: (e) => {
|
|
@@ -71,109 +76,111 @@ var m = u(({ options: u = [], value: m, onChange: h, placeholder: g, label: _, e
|
|
|
71
76
|
},
|
|
72
77
|
active: a,
|
|
73
78
|
disabled: t.disabled,
|
|
74
|
-
className:
|
|
79
|
+
className: p(u.option, o && u.selected, A?.option),
|
|
75
80
|
onClick: (e) => {
|
|
76
81
|
e.stopPropagation(), J(t);
|
|
77
82
|
},
|
|
78
|
-
onMouseEnter: () =>
|
|
83
|
+
onMouseEnter: () => V(r),
|
|
79
84
|
role: "option",
|
|
80
85
|
"aria-selected": o,
|
|
81
|
-
children: /* @__PURE__ */
|
|
86
|
+
children: /* @__PURE__ */ m("li", { children: t.label })
|
|
82
87
|
}, t.value);
|
|
83
88
|
});
|
|
84
|
-
}, Z = q && q.type !== "separator" ? `wim-select-option-${M}-${q.value}` : void 0, { "aria-label": Q, "aria-labelledby": $, "aria-describedby":
|
|
85
|
-
return /* @__PURE__ */
|
|
86
|
-
label:
|
|
87
|
-
error:
|
|
88
|
-
required:
|
|
89
|
-
layout:
|
|
89
|
+
}, Z = q && q.type !== "separator" ? `wim-select-option-${M}-${q.value}` : void 0, { "aria-label": Q, "aria-labelledby": $, "aria-describedby": Te, ...Ee } = de;
|
|
90
|
+
return /* @__PURE__ */ m(c, {
|
|
91
|
+
label: v,
|
|
92
|
+
error: y,
|
|
93
|
+
required: b,
|
|
94
|
+
layout: ie,
|
|
90
95
|
labelId: N,
|
|
91
96
|
htmlFor: I,
|
|
92
97
|
errorId: P,
|
|
93
|
-
className:
|
|
94
|
-
children: /* @__PURE__ */
|
|
95
|
-
className:
|
|
96
|
-
ref:
|
|
97
|
-
onMouseMove: () =>
|
|
98
|
-
"data-keyboard-nav":
|
|
99
|
-
...
|
|
98
|
+
className: ae,
|
|
99
|
+
children: /* @__PURE__ */ h(le ? e : "div", {
|
|
100
|
+
className: p("wim-select", u.root, D && u.fullWidth, A?.root),
|
|
101
|
+
ref: Ce,
|
|
102
|
+
onMouseMove: () => ge(!1),
|
|
103
|
+
"data-keyboard-nav": he,
|
|
104
|
+
...Ee,
|
|
100
105
|
children: [
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
disabled:
|
|
103
|
-
allowClear:
|
|
106
|
+
/* @__PURE__ */ m(a, {
|
|
107
|
+
disabled: x,
|
|
108
|
+
allowClear: E,
|
|
104
109
|
hasValue: !!W,
|
|
105
|
-
onClear:
|
|
110
|
+
onClear: be,
|
|
106
111
|
intent: L,
|
|
107
112
|
rightIcons: [{
|
|
108
113
|
name: "ChevronDownIcon",
|
|
109
114
|
rotated: R
|
|
110
115
|
}],
|
|
111
|
-
width:
|
|
112
|
-
fullWidth:
|
|
113
|
-
styles:
|
|
114
|
-
children: /* @__PURE__ */
|
|
116
|
+
width: k,
|
|
117
|
+
fullWidth: D,
|
|
118
|
+
styles: A?.inputBase,
|
|
119
|
+
children: /* @__PURE__ */ m("div", {
|
|
115
120
|
id: I,
|
|
116
|
-
className:
|
|
117
|
-
onClick:
|
|
121
|
+
className: p(u.trigger, R && u.open, x && u.disabled, A?.trigger),
|
|
122
|
+
onClick: ye,
|
|
118
123
|
onKeyDown: Y,
|
|
119
|
-
tabIndex:
|
|
124
|
+
tabIndex: x ? -1 : 0,
|
|
120
125
|
role: "combobox",
|
|
121
126
|
"aria-expanded": R,
|
|
122
127
|
"aria-haspopup": "listbox",
|
|
123
128
|
"aria-controls": R ? F : void 0,
|
|
124
|
-
"aria-disabled":
|
|
129
|
+
"aria-disabled": x,
|
|
125
130
|
"aria-labelledby": N || $,
|
|
126
|
-
"aria-label":
|
|
127
|
-
"aria-describedby": P ||
|
|
128
|
-
"aria-required":
|
|
131
|
+
"aria-label": v ? void 0 : typeof Q == "string" ? Q : typeof _ == "string" ? _ : void 0,
|
|
132
|
+
"aria-describedby": P || Te,
|
|
133
|
+
"aria-required": b ? "true" : void 0,
|
|
129
134
|
"aria-invalid": L === "danger" ? "true" : "false",
|
|
130
135
|
"aria-activedescendant": R ? Z : void 0,
|
|
131
|
-
ref:
|
|
132
|
-
children: /* @__PURE__ */
|
|
133
|
-
className:
|
|
134
|
-
children: K ? K.label :
|
|
136
|
+
ref: _e,
|
|
137
|
+
children: /* @__PURE__ */ m("div", {
|
|
138
|
+
className: p(u.value, !K && u.placeholder, A?.value),
|
|
139
|
+
children: K ? K.label : _
|
|
135
140
|
})
|
|
136
141
|
})
|
|
137
142
|
}),
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
show: R && !
|
|
143
|
+
/* @__PURE__ */ h(r, {
|
|
144
|
+
show: R && !x,
|
|
140
145
|
preset: "fade",
|
|
141
|
-
className:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
className: p(u.dropdown, A?.dropdown),
|
|
147
|
+
ref: xe,
|
|
148
|
+
...Se,
|
|
149
|
+
children: [S && /* @__PURE__ */ m("div", {
|
|
150
|
+
className: p(u.search, A?.search),
|
|
151
|
+
children: /* @__PURE__ */ m("input", {
|
|
152
|
+
ref: ve,
|
|
146
153
|
type: "text",
|
|
147
|
-
className:
|
|
148
|
-
placeholder:
|
|
154
|
+
className: p(u.searchInput, A?.searchInput),
|
|
155
|
+
placeholder: C,
|
|
149
156
|
value: z,
|
|
150
157
|
onChange: (e) => {
|
|
151
|
-
|
|
158
|
+
me(e.target.value), V(-1);
|
|
152
159
|
},
|
|
153
160
|
onClick: (e) => e.stopPropagation(),
|
|
154
161
|
onKeyDown: Y,
|
|
155
|
-
"aria-label":
|
|
162
|
+
"aria-label": C,
|
|
156
163
|
"aria-controls": F,
|
|
157
164
|
"aria-activedescendant": Z
|
|
158
165
|
})
|
|
159
|
-
}), /* @__PURE__ */
|
|
166
|
+
}), /* @__PURE__ */ m("ul", {
|
|
160
167
|
id: F,
|
|
161
|
-
className:
|
|
168
|
+
className: p(u.list, A?.list),
|
|
162
169
|
role: "listbox",
|
|
163
|
-
"aria-labelledby":
|
|
164
|
-
children: G.length === 0 ? /* @__PURE__ */
|
|
165
|
-
className:
|
|
170
|
+
"aria-labelledby": v ? N : $ || void 0,
|
|
171
|
+
children: G.length === 0 ? /* @__PURE__ */ m("li", {
|
|
172
|
+
className: p(u.empty, A?.empty),
|
|
166
173
|
role: "option",
|
|
167
174
|
"aria-selected": "false",
|
|
168
|
-
children:
|
|
169
|
-
}) :
|
|
175
|
+
children: O ?? fe("select.no_options")
|
|
176
|
+
}) : we()
|
|
170
177
|
})]
|
|
171
178
|
}),
|
|
172
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ m(t, { children: ue })
|
|
173
180
|
]
|
|
174
181
|
})
|
|
175
182
|
});
|
|
176
183
|
});
|
|
177
|
-
|
|
184
|
+
g.displayName = "Select";
|
|
178
185
|
//#endregion
|
|
179
|
-
export {
|
|
186
|
+
export { g as Select, g as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_wjf5o_23`,t=`_fullWidth_wjf5o_37`,n=`_trigger_wjf5o_41`,r=`_disabled_wjf5o_61`,i=`_open_wjf5o_83`,a=`_value_wjf5o_91`,o=`_placeholder_wjf5o_92`,s=`_icon_wjf5o_95`,c=`_icons_wjf5o_108`,l=`_clear_wjf5o_120`,u=`_dropdown_wjf5o_136`,d=`_search_wjf5o_156`,f=`_searchInput_wjf5o_160`,p=`_list_wjf5o_189`,m=`_groupLabel_wjf5o_196`,h=`_option_wjf5o_214`,g=`_selected_wjf5o_214`,_=`_empty_wjf5o_223`,v=`_separator_wjf5o_230`,y=`_native_wjf5o_238`,b=`_nativeWrapper_wjf5o_238`,x=`_select_wjf5o_214`,S={root:e,fullWidth:t,trigger:n,disabled:r,open:i,value:a,placeholder:o,icon:s,icons:c,clear:l,dropdown:u,search:d,searchInput:f,list:p,groupLabel:m,option:h,selected:g,empty:_,separator:v,native:y,nativeWrapper:b,select:x};exports.clear=l,exports.default=S,exports.disabled=r,exports.dropdown=u,exports.empty=_,exports.fullWidth=t,exports.groupLabel=m,exports.icon=s,exports.icons=c,exports.list=p,exports.native=y,exports.nativeWrapper=b,exports.open=i,exports.option=h,exports.placeholder=o,exports.root=e,exports.search=d,exports.searchInput=f,exports.select=x,exports.selected=g,exports.separator=v,exports.trigger=n,exports.value=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/Select/select.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_wjf5o_23", t = "_fullWidth_wjf5o_37", n = "_trigger_wjf5o_41", r = "_disabled_wjf5o_61", i = "_open_wjf5o_83", a = "_value_wjf5o_91", o = "_placeholder_wjf5o_92", s = "_icon_wjf5o_95", c = "_icons_wjf5o_108", l = "_clear_wjf5o_120", u = "_dropdown_wjf5o_136", d = "_search_wjf5o_156", f = "_searchInput_wjf5o_160", p = "_list_wjf5o_189", m = "_groupLabel_wjf5o_196", h = "_option_wjf5o_214", g = "_selected_wjf5o_214", _ = "_empty_wjf5o_223", v = "_separator_wjf5o_230", y = "_native_wjf5o_238", b = "_nativeWrapper_wjf5o_238", x = "_select_wjf5o_214", S = {
|
|
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("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../hooks/useMergedRef.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),ee=require("../InputBase/InputBase.cjs"),a=require("../../_internal/useInlineFloating.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("../../data-display/TreeView/TreeView.cjs"),c=require("./tree-select.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");function f(e){return e.map(e=>({value:e.value,label:e.label,disabled:e.disabled,icon:e.icon,children:e.children?f(e.children):void 0}))}var p=(0,l.forwardRef)(({treeData:e=[],value:p,onChange:m,placeholder:h,label:g,error:_,required:v,layout:y,className:b,disabled:x=!1,multiple:S=!1,searchable:C=!1,defaultExpandedKeys:w=[],allowClear:T=!1,checkStrategy:E=`cascade`,id:D,width:O,fullWidth:k=!1,asChild:A=!1,children:te,...ne},re)=>{let ie=(0,l.useId)(),j=D||`wim-tree-select-${ie}`,M=g?`${j}-label`:void 0,N=_?`${j}-error`:void 0,P=`${j}-trigger`,F=`${j}-dropdown`,[I,L]=(0,l.useState)(!1),[R,z]=(0,l.useState)(S?[]:``),B=(0,l.useRef)(null),V=(0,l.useRef)(null),H=p!==void 0,U=H?p:R;(0,l.useEffect)(()=>{let e=e=>{B.current&&!B.current.contains(e.target)&&L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,l.useEffect)(()=>{if(I){let e=setTimeout(()=>{let e=B.current?.querySelector(`[data-testid="tree-view-search-input"]`);e?e.focus():(B.current?.querySelector(`[data-testid="tree-view-root"]`))?.focus()},100);return()=>clearTimeout(e)}},[I]);let W=()=>{if(!x){let e=!I;L(e),e||V.current?.focus()}},G=e=>{if(!x){if(!I){(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),L(!0));return}e.key===`Escape`&&(e.preventDefault(),L(!1),V.current?.focus())}},K=(0,l.useMemo)(()=>{let t={},n=e=>{e.forEach(e=>{t[e.value]=e,e.children&&n(e.children)})};return n(e),t},[e]),q=()=>{if(S){let e=Array.isArray(U)?U:[];return e.length===0?null:e.map(e=>K[e]?K[e].label:e).reduce((e,t)=>[e,`, `,t])}{let e=U;return e?K[e]?K[e].label:e:null}},J=e=>{let t;S?t=e:(t=e[0]||``,L(!1),V.current?.focus()),H||z(t),m&&m(t)},ae=()=>{if(x)return;let e=S?[]:``;H||z(e),m&&m(e)},oe=(0,l.useMemo)(()=>f(e),[e]),Y=(0,l.useMemo)(()=>S?Array.isArray(U)?U:[]:U?[U]:[],[U,S]),X=q(),{"aria-label":Z,"aria-labelledby":Q,"aria-describedby":se,...ce}=ne,$=typeof h==`string`?h:`Select`,le=A?t.Root:`div`,{setReference:ue,setFloating:de,floatingProps:fe}=a.useInlineFloating({open:I&&!x}),pe=n.useMergedRef(B,re,ue);return(0,d.jsx)(o.FieldTemplate,{label:g,error:_,required:v,layout:y,labelId:M,errorId:N,className:(0,u.default)(c.default.container,b),children:(0,d.jsxs)(le,{className:(0,u.default)(`wim-tree-select`,c.default.root,k&&c.default.fullWidth),ref:pe,...ce,children:[(0,d.jsx)(t.Slottable,{children:te}),(0,d.jsx)(ee.InputBase,{disabled:x,allowClear:T,hasValue:!!X,onClear:ae,intent:_?`danger`:`default`,width:O,fullWidth:k,rightIcons:[{name:`ChevronDownIcon`,rotated:I,onClick:W,decorative:!0}],className:(0,u.default)(I&&c.default.open),children:(0,d.jsx)(`div`,{id:P,className:(0,u.default)(c.default.trigger,x&&c.default.disabled),onClick:W,onKeyDown:G,tabIndex:x?-1:0,role:`combobox`,"aria-expanded":I,"aria-haspopup":`tree`,"aria-controls":I?F:void 0,"aria-disabled":x,"aria-labelledby":M||Q,"aria-label":g?void 0:Z||$,"aria-describedby":N||se,"aria-required":v,"aria-invalid":!!_,ref:V,children:(0,d.jsx)(`div`,{className:(0,u.default)(c.default.value,!X&&c.default.placeholder),children:X||h})})}),(0,d.jsx)(r.Transition,{show:I&&!x,preset:`fade`,className:c.default.dropdown,ref:de,...fe,children:(0,d.jsx)(`div`,{id:F,children:(0,d.jsx)(i.FocusTrap,{active:I,initialFocus:!1,children:(0,d.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":M||Q,"aria-label":g?void 0:Z||$,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),L(!1),V.current?.focus())},children:(0,d.jsx)(s.TreeView,{multiSelect:S,defaultSelectedValues:Y,defaultCheckedValues:S?Y:[],nodes:oe,onCheckedChange:J,onSelectedChange:J,checkable:S,checkStrategy:E,searchable:C,defaultExpandedValues:w,styles:{root:c.default.treeView,item:c.default.treeViewItem,search:c.default.treeViewSearch}})})})})})]})})});p.displayName=`TreeSelect`,exports.TreeSelect=p;
|
|
@@ -1,166 +1,169 @@
|
|
|
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 { useMergedRef as n } from "../../../hooks/useMergedRef.js";
|
|
4
|
-
import { Transition as
|
|
5
|
-
import { FocusTrap as
|
|
6
|
-
import { InputBase as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import p from "
|
|
12
|
-
import
|
|
4
|
+
import { Transition as r } from "../../layout/Transition/Transition.js";
|
|
5
|
+
import { FocusTrap as i } from "../../overlay/FocusTrap/FocusTrap.js";
|
|
6
|
+
import { InputBase as a } from "../InputBase/InputBase.js";
|
|
7
|
+
import { useInlineFloating as o } from "../../_internal/useInlineFloating.js";
|
|
8
|
+
import { FieldTemplate as s } from "../FieldTemplate/FieldTemplate.js";
|
|
9
|
+
import { TreeView as c } from "../../data-display/TreeView/TreeView.js";
|
|
10
|
+
import l from "./tree-select.module.js";
|
|
11
|
+
import { forwardRef as u, useEffect as d, useId as ee, useMemo as f, useRef as p, useState as m } from "react";
|
|
12
|
+
import h from "classnames";
|
|
13
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
14
|
//#region src/components/form/TreeSelect/TreeSelect.tsx
|
|
14
|
-
function
|
|
15
|
+
function v(e) {
|
|
15
16
|
return e.map((e) => ({
|
|
16
17
|
value: e.value,
|
|
17
18
|
label: e.label,
|
|
18
19
|
disabled: e.disabled,
|
|
19
20
|
icon: e.icon,
|
|
20
|
-
children: e.children ?
|
|
21
|
+
children: e.children ? v(e.children) : void 0
|
|
21
22
|
}));
|
|
22
23
|
}
|
|
23
|
-
var
|
|
24
|
-
let
|
|
25
|
-
|
|
24
|
+
var y = u(({ treeData: u = [], value: y, onChange: b, placeholder: x, label: S, error: C, required: w, layout: T, className: E, disabled: D = !1, multiple: O = !1, searchable: k = !1, defaultExpandedKeys: A = [], allowClear: te = !1, checkStrategy: ne = "cascade", id: re, width: ie, fullWidth: j = !1, asChild: ae = !1, children: oe, ...se }, ce) => {
|
|
25
|
+
let le = ee(), M = re || `wim-tree-select-${le}`, N = S ? `${M}-label` : void 0, P = C ? `${M}-error` : void 0, F = `${M}-trigger`, I = `${M}-dropdown`, [L, R] = m(!1), [z, B] = m(O ? [] : ""), V = p(null), H = p(null), U = y !== void 0, W = U ? y : z;
|
|
26
|
+
d(() => {
|
|
26
27
|
let e = (e) => {
|
|
27
|
-
|
|
28
|
+
V.current && !V.current.contains(e.target) && R(!1);
|
|
28
29
|
};
|
|
29
30
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30
|
-
}, []),
|
|
31
|
-
if (
|
|
31
|
+
}, []), d(() => {
|
|
32
|
+
if (L) {
|
|
32
33
|
let e = setTimeout(() => {
|
|
33
|
-
let e =
|
|
34
|
-
e ? e.focus() : (
|
|
34
|
+
let e = V.current?.querySelector("[data-testid=\"tree-view-search-input\"]");
|
|
35
|
+
e ? e.focus() : (V.current?.querySelector("[data-testid=\"tree-view-root\"]"))?.focus();
|
|
35
36
|
}, 100);
|
|
36
37
|
return () => clearTimeout(e);
|
|
37
38
|
}
|
|
38
|
-
}, [
|
|
39
|
-
let
|
|
40
|
-
if (!
|
|
41
|
-
let e = !
|
|
42
|
-
|
|
39
|
+
}, [L]);
|
|
40
|
+
let G = () => {
|
|
41
|
+
if (!D) {
|
|
42
|
+
let e = !L;
|
|
43
|
+
R(e), e || H.current?.focus();
|
|
43
44
|
}
|
|
44
|
-
},
|
|
45
|
-
if (!
|
|
46
|
-
if (!
|
|
47
|
-
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(),
|
|
45
|
+
}, ue = (e) => {
|
|
46
|
+
if (!D) {
|
|
47
|
+
if (!L) {
|
|
48
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), R(!0));
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
|
-
e.key === "Escape" && (e.preventDefault(),
|
|
51
|
+
e.key === "Escape" && (e.preventDefault(), R(!1), H.current?.focus());
|
|
51
52
|
}
|
|
52
|
-
},
|
|
53
|
+
}, K = f(() => {
|
|
53
54
|
let e = {}, t = (n) => {
|
|
54
55
|
n.forEach((n) => {
|
|
55
56
|
e[n.value] = n, n.children && t(n.children);
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
|
-
return t(
|
|
59
|
-
}, [
|
|
60
|
-
if (
|
|
61
|
-
let e = Array.isArray(
|
|
62
|
-
return e.length === 0 ? null : e.map((e) =>
|
|
59
|
+
return t(u), e;
|
|
60
|
+
}, [u]), de = () => {
|
|
61
|
+
if (O) {
|
|
62
|
+
let e = Array.isArray(W) ? W : [];
|
|
63
|
+
return e.length === 0 ? null : e.map((e) => K[e] ? K[e].label : e).reduce((e, t) => [
|
|
63
64
|
e,
|
|
64
65
|
", ",
|
|
65
66
|
t
|
|
66
67
|
]);
|
|
67
68
|
}
|
|
68
69
|
{
|
|
69
|
-
let e =
|
|
70
|
-
return e ?
|
|
70
|
+
let e = W;
|
|
71
|
+
return e ? K[e] ? K[e].label : e : null;
|
|
71
72
|
}
|
|
72
|
-
},
|
|
73
|
+
}, q = (e) => {
|
|
73
74
|
let t;
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
if (
|
|
77
|
-
let e =
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
label:
|
|
82
|
-
error:
|
|
83
|
-
required:
|
|
84
|
-
layout:
|
|
85
|
-
labelId:
|
|
86
|
-
errorId:
|
|
87
|
-
className:
|
|
88
|
-
children: /* @__PURE__ */
|
|
89
|
-
className:
|
|
90
|
-
ref:
|
|
91
|
-
...
|
|
75
|
+
O ? t = e : (t = e[0] || "", R(!1), H.current?.focus()), U || B(t), b && b(t);
|
|
76
|
+
}, fe = () => {
|
|
77
|
+
if (D) return;
|
|
78
|
+
let e = O ? [] : "";
|
|
79
|
+
U || B(e), b && b(e);
|
|
80
|
+
}, pe = f(() => v(u), [u]), J = f(() => O ? Array.isArray(W) ? W : [] : W ? [W] : [], [W, O]), Y = de(), { "aria-label": X, "aria-labelledby": Z, "aria-describedby": me, ...he } = se, Q = typeof x == "string" ? x : "Select", ge = ae ? e : "div", { setReference: $, setFloating: _e, floatingProps: ve } = o({ open: L && !D }), ye = n(V, ce, $);
|
|
81
|
+
return /* @__PURE__ */ g(s, {
|
|
82
|
+
label: S,
|
|
83
|
+
error: C,
|
|
84
|
+
required: w,
|
|
85
|
+
layout: T,
|
|
86
|
+
labelId: N,
|
|
87
|
+
errorId: P,
|
|
88
|
+
className: h(l.container, E),
|
|
89
|
+
children: /* @__PURE__ */ _(ge, {
|
|
90
|
+
className: h("wim-tree-select", l.root, j && l.fullWidth),
|
|
91
|
+
ref: ye,
|
|
92
|
+
...he,
|
|
92
93
|
children: [
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
disabled:
|
|
96
|
-
allowClear:
|
|
97
|
-
hasValue: !!
|
|
98
|
-
onClear:
|
|
99
|
-
intent:
|
|
100
|
-
width:
|
|
94
|
+
/* @__PURE__ */ g(t, { children: oe }),
|
|
95
|
+
/* @__PURE__ */ g(a, {
|
|
96
|
+
disabled: D,
|
|
97
|
+
allowClear: te,
|
|
98
|
+
hasValue: !!Y,
|
|
99
|
+
onClear: fe,
|
|
100
|
+
intent: C ? "danger" : "default",
|
|
101
|
+
width: ie,
|
|
101
102
|
fullWidth: j,
|
|
102
103
|
rightIcons: [{
|
|
103
104
|
name: "ChevronDownIcon",
|
|
104
|
-
rotated:
|
|
105
|
-
onClick:
|
|
105
|
+
rotated: L,
|
|
106
|
+
onClick: G,
|
|
106
107
|
decorative: !0
|
|
107
108
|
}],
|
|
108
|
-
className:
|
|
109
|
-
children: /* @__PURE__ */
|
|
110
|
-
id:
|
|
111
|
-
className:
|
|
112
|
-
onClick:
|
|
113
|
-
onKeyDown:
|
|
114
|
-
tabIndex:
|
|
109
|
+
className: h(L && l.open),
|
|
110
|
+
children: /* @__PURE__ */ g("div", {
|
|
111
|
+
id: F,
|
|
112
|
+
className: h(l.trigger, D && l.disabled),
|
|
113
|
+
onClick: G,
|
|
114
|
+
onKeyDown: ue,
|
|
115
|
+
tabIndex: D ? -1 : 0,
|
|
115
116
|
role: "combobox",
|
|
116
|
-
"aria-expanded":
|
|
117
|
+
"aria-expanded": L,
|
|
117
118
|
"aria-haspopup": "tree",
|
|
118
|
-
"aria-controls":
|
|
119
|
-
"aria-disabled":
|
|
120
|
-
"aria-labelledby":
|
|
121
|
-
"aria-label":
|
|
122
|
-
"aria-describedby":
|
|
123
|
-
"aria-required":
|
|
124
|
-
"aria-invalid": !!
|
|
125
|
-
ref:
|
|
126
|
-
children: /* @__PURE__ */
|
|
127
|
-
className:
|
|
128
|
-
children:
|
|
119
|
+
"aria-controls": L ? I : void 0,
|
|
120
|
+
"aria-disabled": D,
|
|
121
|
+
"aria-labelledby": N || Z,
|
|
122
|
+
"aria-label": S ? void 0 : X || Q,
|
|
123
|
+
"aria-describedby": P || me,
|
|
124
|
+
"aria-required": w,
|
|
125
|
+
"aria-invalid": !!C,
|
|
126
|
+
ref: H,
|
|
127
|
+
children: /* @__PURE__ */ g("div", {
|
|
128
|
+
className: h(l.value, !Y && l.placeholder),
|
|
129
|
+
children: Y || x
|
|
129
130
|
})
|
|
130
131
|
})
|
|
131
132
|
}),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
show:
|
|
133
|
+
/* @__PURE__ */ g(r, {
|
|
134
|
+
show: L && !D,
|
|
134
135
|
preset: "fade",
|
|
135
|
-
className:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
className: l.dropdown,
|
|
137
|
+
ref: _e,
|
|
138
|
+
...ve,
|
|
139
|
+
children: /* @__PURE__ */ g("div", {
|
|
140
|
+
id: I,
|
|
141
|
+
children: /* @__PURE__ */ g(i, {
|
|
142
|
+
active: L,
|
|
140
143
|
initialFocus: !1,
|
|
141
|
-
children: /* @__PURE__ */
|
|
144
|
+
children: /* @__PURE__ */ g("div", {
|
|
142
145
|
role: "dialog",
|
|
143
146
|
"aria-modal": "true",
|
|
144
|
-
"aria-labelledby":
|
|
145
|
-
"aria-label":
|
|
147
|
+
"aria-labelledby": N || Z,
|
|
148
|
+
"aria-label": S ? void 0 : X || Q,
|
|
146
149
|
onKeyDown: (e) => {
|
|
147
|
-
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(),
|
|
150
|
+
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), R(!1), H.current?.focus());
|
|
148
151
|
},
|
|
149
|
-
children: /* @__PURE__ */
|
|
150
|
-
multiSelect:
|
|
151
|
-
defaultSelectedValues:
|
|
152
|
-
defaultCheckedValues:
|
|
153
|
-
nodes:
|
|
154
|
-
onCheckedChange:
|
|
155
|
-
onSelectedChange:
|
|
156
|
-
checkable:
|
|
157
|
-
checkStrategy:
|
|
158
|
-
searchable:
|
|
159
|
-
defaultExpandedValues:
|
|
152
|
+
children: /* @__PURE__ */ g(c, {
|
|
153
|
+
multiSelect: O,
|
|
154
|
+
defaultSelectedValues: J,
|
|
155
|
+
defaultCheckedValues: O ? J : [],
|
|
156
|
+
nodes: pe,
|
|
157
|
+
onCheckedChange: q,
|
|
158
|
+
onSelectedChange: q,
|
|
159
|
+
checkable: O,
|
|
160
|
+
checkStrategy: ne,
|
|
161
|
+
searchable: k,
|
|
162
|
+
defaultExpandedValues: A,
|
|
160
163
|
styles: {
|
|
161
|
-
root:
|
|
162
|
-
item:
|
|
163
|
-
search:
|
|
164
|
+
root: l.treeView,
|
|
165
|
+
item: l.treeViewItem,
|
|
166
|
+
search: l.treeViewSearch
|
|
164
167
|
}
|
|
165
168
|
})
|
|
166
169
|
})
|
|
@@ -171,6 +174,6 @@ var _ = s(({ treeData: s = [], value: _, onChange: v, placeholder: y, label: b,
|
|
|
171
174
|
})
|
|
172
175
|
});
|
|
173
176
|
});
|
|
174
|
-
|
|
177
|
+
y.displayName = "TreeSelect";
|
|
175
178
|
//#endregion
|
|
176
|
-
export {
|
|
179
|
+
export { y as TreeSelect };
|