wimui 0.59.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/ai/SourceCitation/SourceCitation.cjs +1 -1
- package/dist/components/ai/SourceCitation/SourceCitation.d.ts +5 -1
- package/dist/components/ai/SourceCitation/SourceCitation.js +10 -8
- package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.d.ts +5 -1
- package/dist/components/data-display/DataGrid/DataGrid.js +54 -53
- package/dist/components/data-display/FAQSection/FAQSection.cjs +1 -1
- package/dist/components/data-display/FAQSection/FAQSection.d.ts +5 -1
- package/dist/components/data-display/FAQSection/FAQSection.js +5 -3
- package/dist/components/data-display/TreeView/TreeView.cjs +1 -1
- package/dist/components/data-display/TreeView/TreeView.d.ts +5 -1
- package/dist/components/data-display/TreeView/TreeView.js +87 -87
- package/dist/components/feedback/Notification/Notification.cjs +1 -1
- package/dist/components/feedback/Notification/Notification.d.ts +5 -1
- package/dist/components/feedback/Notification/Notification.js +10 -8
- package/dist/components/feedback/Toast/Toast.cjs +1 -1
- package/dist/components/feedback/Toast/Toast.d.ts +5 -1
- package/dist/components/feedback/Toast/Toast.js +11 -9
- 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/SignaturePad/SignaturePad.cjs +1 -1
- package/dist/components/form/SignaturePad/SignaturePad.d.ts +5 -1
- package/dist/components/form/SignaturePad/SignaturePad.js +47 -47
- 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/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.d.ts +5 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.js +11 -6
- package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination/Pagination.d.ts +5 -1
- package/dist/components/navigation/Pagination/Pagination.js +65 -63
- package/dist/components/overlay/Menu/Menu.cjs +1 -1
- package/dist/components/overlay/Menu/Menu.d.ts +4 -0
- package/dist/components/overlay/Menu/Menu.js +23 -21
- package/dist/llms-full.txt +19 -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("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../i18n/generated/components.cjs"),i=require("../Button/Button.cjs"),a=require("../../../i18n/generated/form.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("./signature-pad.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=({width:e=400,height:d=200,penColor:f=`var(--wim-color-text-primary)`,penWidth:p=2,onChange:m,clearLabel:h,disabled:g=!1,className:_,style:v,label:y,error:b,required:x,layout:S=`vertical`,canvasAriaLabel:C})=>{let{t:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../i18n/generated/components.cjs"),i=require("../Button/Button.cjs"),a=require("../../../i18n/generated/form.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("./signature-pad.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=({width:e=400,height:d=200,penColor:f=`var(--wim-color-text-primary)`,penWidth:p=2,onChange:m,clearLabel:h,disabled:g=!1,className:_,style:v,label:y,error:b,required:x,layout:S=`vertical`,canvasAriaLabel:C,"aria-label":w,"aria-labelledby":T})=>{let{t:E}=t.useWimTranslation([n.commonNs,r.componentsNs,a.formNs]),D=h??E(`signature.clear`,{ns:`components`,defaultValue:E(`button.clear`)}),O=C??E(`a11y.signature_canvas`),k=(0,c.useRef)(null),A=(0,c.useRef)(!1),[j,M]=(0,c.useState)(!0),N=`wim-signature-pad-${(0,c.useId)()}`,P=y?`${N}-label`:void 0,F=b?`${N}-error`:void 0,I=(0,c.useCallback)(e=>{if(e.startsWith(`var(`)&&k.current){let t=e.match(/var\((--[^)]+)\)/)?.[1];if(t)return getComputedStyle(k.current).getPropertyValue(t).trim()||`#000`}return e},[]);(0,c.useLayoutEffect)(()=>{if(!k.current)return;let t=k.current,n=t.getContext(`2d`);if(!n)return;let r=window.devicePixelRatio||1;t.width=e*r,t.height=d*r,n.scale(r,r),n.lineCap=`round`,n.lineJoin=`round`},[e,d]);let L=(0,c.useCallback)(t=>{if(!k.current)return null;let n=k.current.getBoundingClientRect(),r,i;if(`touches`in t){if(t.touches.length===0)return null;r=t.touches[0].clientX,i=t.touches[0].clientY}else r=t.clientX,i=t.clientY;let a=r-n.left,o=i-n.top,s=e/n.width,c=d/n.height;return{x:a*s,y:o*c}},[e,d]),R=e=>{if(g)return;let t=L(e);if(!t||!k.current)return;let n=k.current.getContext(`2d`);n&&(A.current=!0,n.beginPath(),n.moveTo(t.x,t.y),n.strokeStyle=I(f),n.lineWidth=p)},z=e=>{if(!A.current||g||!k.current)return;let t=L(e);if(!t)return;let n=k.current.getContext(`2d`);n&&(n.lineTo(t.x,t.y),n.stroke(),M(!1))},B=()=>{if(A.current&&(A.current=!1,m&&k.current)){let e=k.current,t=e.getContext(`2d`);m(!t||t.getImageData(0,0,e.width,e.height).data.every((e,t)=>t%4!=3||e===0)?null:e.toDataURL())}},V=(0,c.useRef)(B);(0,c.useLayoutEffect)(()=>{V.current=B}),(0,c.useEffect)(()=>{let e=()=>V.current();return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let H=(0,c.useRef)(!1);return(0,u.jsx)(o.FieldTemplate,{label:y,error:b,required:x,layout:S,labelId:P,errorId:F,className:_,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`wim-signature-pad`,s.default.root,g&&s.default.disabled,b&&s.default.danger),style:v,children:[(0,u.jsx)(`div`,{className:s.default.canvasContainer,style:{width:e,maxWidth:`100%`,aspectRatio:`${e} / ${d}`,height:`auto`},children:(0,u.jsx)(`canvas`,{ref:k,"data-testid":`signature-canvas`,className:s.default.canvas,style:{width:`100%`,height:`100%`,display:`block`},onMouseDown:R,onMouseMove:z,onMouseUp:B,onTouchStart:R,onTouchMove:z,onTouchEnd:B,"aria-labelledby":y?P:T,"aria-describedby":F,role:`img`,"aria-label":y||T?void 0:w??O})}),(0,u.jsx)(`div`,{className:s.default.footer,children:(0,u.jsx)(i.Button,{variant:`outline`,size:`sm`,"data-testid":`signature-clear`,onMouseDown:()=>{H.current=!0},onClick:()=>{if(!H.current||(H.current=!1,g||!k.current))return;let e=k.current,t=e.getContext(`2d`);t&&(t.clearRect(0,0,e.width,e.height),M(!0),m&&m(null))},disabled:g||j,children:D})})]})})};exports.SignaturePad=d;
|
|
@@ -28,8 +28,12 @@ export type SignaturePadProps = {
|
|
|
28
28
|
layout?: "vertical" | "horizontal";
|
|
29
29
|
/** Aria label for the canvas */
|
|
30
30
|
canvasAriaLabel?: string;
|
|
31
|
+
/** Accessible name for the canvas when no visible `label` is provided. Takes precedence over `canvasAriaLabel`. */
|
|
32
|
+
"aria-label"?: string;
|
|
33
|
+
/** ID of the element that labels the canvas when no visible `label` is provided. */
|
|
34
|
+
"aria-labelledby"?: string;
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
37
|
* Component for entering a handwritten signature with mouse or touch.
|
|
34
38
|
*/
|
|
35
|
-
export declare const SignaturePad: ({ width, height, penColor, penWidth, onChange, clearLabel, disabled, className, style, label, error, required, layout, canvasAriaLabel, }: SignaturePadProps) => React.JSX.Element;
|
|
39
|
+
export declare const SignaturePad: ({ width, height, penColor, penWidth, onChange, clearLabel, disabled, className, style, label, error, required, layout, canvasAriaLabel, "aria-label": ariaLabelAttr, "aria-labelledby": ariaLabelledBy, }: SignaturePadProps) => React.JSX.Element;
|
|
@@ -10,31 +10,31 @@ import { useCallback as s, useEffect as c, useId as l, useLayoutEffect as u, use
|
|
|
10
10
|
import p from "classnames";
|
|
11
11
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/form/SignaturePad/SignaturePad.tsx
|
|
13
|
-
var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-primary)", penWidth: y = 2, onChange: b, clearLabel: x, disabled: S = !1, className: C, style: w, label: T, error: E, required: D, layout: O = "vertical", canvasAriaLabel: k }) => {
|
|
14
|
-
let { t:
|
|
13
|
+
var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-primary)", penWidth: y = 2, onChange: b, clearLabel: x, disabled: S = !1, className: C, style: w, label: T, error: E, required: D, layout: O = "vertical", canvasAriaLabel: k, "aria-label": A, "aria-labelledby": j }) => {
|
|
14
|
+
let { t: M } = e([
|
|
15
15
|
t,
|
|
16
16
|
n,
|
|
17
17
|
i
|
|
18
|
-
]),
|
|
18
|
+
]), N = x ?? M("signature.clear", {
|
|
19
19
|
ns: "components",
|
|
20
|
-
defaultValue:
|
|
21
|
-
}),
|
|
22
|
-
if (e.startsWith("var(") &&
|
|
20
|
+
defaultValue: M("button.clear")
|
|
21
|
+
}), P = k ?? M("a11y.signature_canvas"), F = d(null), I = d(!1), [L, R] = f(!0), z = `wim-signature-pad-${l()}`, B = T ? `${z}-label` : void 0, V = E ? `${z}-error` : void 0, H = s((e) => {
|
|
22
|
+
if (e.startsWith("var(") && F.current) {
|
|
23
23
|
let t = e.match(/var\((--[^)]+)\)/)?.[1];
|
|
24
|
-
if (t) return getComputedStyle(
|
|
24
|
+
if (t) return getComputedStyle(F.current).getPropertyValue(t).trim() || "#000";
|
|
25
25
|
}
|
|
26
26
|
return e;
|
|
27
27
|
}, []);
|
|
28
28
|
u(() => {
|
|
29
|
-
if (!
|
|
30
|
-
let e =
|
|
29
|
+
if (!F.current) return;
|
|
30
|
+
let e = F.current, t = e.getContext("2d");
|
|
31
31
|
if (!t) return;
|
|
32
32
|
let n = window.devicePixelRatio || 1;
|
|
33
33
|
e.width = g * n, e.height = _ * n, t.scale(n, n), t.lineCap = "round", t.lineJoin = "round";
|
|
34
34
|
}, [g, _]);
|
|
35
|
-
let
|
|
36
|
-
if (!
|
|
37
|
-
let t =
|
|
35
|
+
let U = s((e) => {
|
|
36
|
+
if (!F.current) return null;
|
|
37
|
+
let t = F.current.getBoundingClientRect(), n, r;
|
|
38
38
|
if ("touches" in e) {
|
|
39
39
|
if (e.touches.length === 0) return null;
|
|
40
40
|
n = e.touches[0].clientX, r = e.touches[0].clientY;
|
|
@@ -44,38 +44,38 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
44
44
|
x: i * o,
|
|
45
45
|
y: a * s
|
|
46
46
|
};
|
|
47
|
-
}, [g, _]),
|
|
47
|
+
}, [g, _]), W = (e) => {
|
|
48
48
|
if (S) return;
|
|
49
|
-
let t =
|
|
50
|
-
if (!t || !
|
|
51
|
-
let n =
|
|
52
|
-
n && (
|
|
53
|
-
},
|
|
54
|
-
if (!
|
|
55
|
-
let t =
|
|
49
|
+
let t = U(e);
|
|
50
|
+
if (!t || !F.current) return;
|
|
51
|
+
let n = F.current.getContext("2d");
|
|
52
|
+
n && (I.current = !0, n.beginPath(), n.moveTo(t.x, t.y), n.strokeStyle = H(v), n.lineWidth = y);
|
|
53
|
+
}, G = (e) => {
|
|
54
|
+
if (!I.current || S || !F.current) return;
|
|
55
|
+
let t = U(e);
|
|
56
56
|
if (!t) return;
|
|
57
|
-
let n =
|
|
58
|
-
n && (n.lineTo(t.x, t.y), n.stroke(),
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
let e =
|
|
57
|
+
let n = F.current.getContext("2d");
|
|
58
|
+
n && (n.lineTo(t.x, t.y), n.stroke(), R(!1));
|
|
59
|
+
}, K = () => {
|
|
60
|
+
if (I.current && (I.current = !1, b && F.current)) {
|
|
61
|
+
let e = F.current, t = e.getContext("2d");
|
|
62
62
|
b(!t || t.getImageData(0, 0, e.width, e.height).data.every((e, t) => t % 4 != 3 || e === 0) ? null : e.toDataURL());
|
|
63
63
|
}
|
|
64
|
-
},
|
|
64
|
+
}, q = d(K);
|
|
65
65
|
u(() => {
|
|
66
|
-
|
|
66
|
+
q.current = K;
|
|
67
67
|
}), c(() => {
|
|
68
|
-
let e = () =>
|
|
68
|
+
let e = () => q.current();
|
|
69
69
|
return window.addEventListener("mouseup", e), () => window.removeEventListener("mouseup", e);
|
|
70
70
|
}, []);
|
|
71
|
-
let
|
|
71
|
+
let J = d(!1);
|
|
72
72
|
return /* @__PURE__ */ m(a, {
|
|
73
73
|
label: T,
|
|
74
74
|
error: E,
|
|
75
75
|
required: D,
|
|
76
76
|
layout: O,
|
|
77
|
-
labelId:
|
|
78
|
-
errorId:
|
|
77
|
+
labelId: B,
|
|
78
|
+
errorId: V,
|
|
79
79
|
className: C,
|
|
80
80
|
children: /* @__PURE__ */ h("div", {
|
|
81
81
|
className: p("wim-signature-pad", o.root, S && o.disabled, E && o.danger),
|
|
@@ -89,7 +89,7 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
89
89
|
height: "auto"
|
|
90
90
|
},
|
|
91
91
|
children: /* @__PURE__ */ m("canvas", {
|
|
92
|
-
ref:
|
|
92
|
+
ref: F,
|
|
93
93
|
"data-testid": "signature-canvas",
|
|
94
94
|
className: o.canvas,
|
|
95
95
|
style: {
|
|
@@ -97,16 +97,16 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
97
97
|
height: "100%",
|
|
98
98
|
display: "block"
|
|
99
99
|
},
|
|
100
|
-
onMouseDown:
|
|
101
|
-
onMouseMove:
|
|
102
|
-
onMouseUp:
|
|
103
|
-
onTouchStart:
|
|
104
|
-
onTouchMove:
|
|
105
|
-
onTouchEnd:
|
|
106
|
-
"aria-labelledby": T ?
|
|
107
|
-
"aria-describedby":
|
|
100
|
+
onMouseDown: W,
|
|
101
|
+
onMouseMove: G,
|
|
102
|
+
onMouseUp: K,
|
|
103
|
+
onTouchStart: W,
|
|
104
|
+
onTouchMove: G,
|
|
105
|
+
onTouchEnd: K,
|
|
106
|
+
"aria-labelledby": T ? B : j,
|
|
107
|
+
"aria-describedby": V,
|
|
108
108
|
role: "img",
|
|
109
|
-
"aria-label": T ? void 0 :
|
|
109
|
+
"aria-label": T || j ? void 0 : A ?? P
|
|
110
110
|
})
|
|
111
111
|
}), /* @__PURE__ */ m("div", {
|
|
112
112
|
className: o.footer,
|
|
@@ -115,15 +115,15 @@ var g = ({ width: g = 400, height: _ = 200, penColor: v = "var(--wim-color-text-
|
|
|
115
115
|
size: "sm",
|
|
116
116
|
"data-testid": "signature-clear",
|
|
117
117
|
onMouseDown: () => {
|
|
118
|
-
|
|
118
|
+
J.current = !0;
|
|
119
119
|
},
|
|
120
120
|
onClick: () => {
|
|
121
|
-
if (!
|
|
122
|
-
let e =
|
|
123
|
-
t && (t.clearRect(0, 0, e.width, e.height),
|
|
121
|
+
if (!J.current || (J.current = !1, S || !F.current)) return;
|
|
122
|
+
let e = F.current, t = e.getContext("2d");
|
|
123
|
+
t && (t.clearRect(0, 0, e.width, e.height), R(!0), b && b(null));
|
|
124
124
|
},
|
|
125
|
-
disabled: S ||
|
|
126
|
-
children:
|
|
125
|
+
disabled: S || L,
|
|
126
|
+
children: N
|
|
127
127
|
})
|
|
128
128
|
})]
|
|
129
129
|
})
|
|
@@ -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;
|