wimui 0.56.2 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ai/ThoughtProcess/ThoughtProcess.cjs +1 -1
- package/dist/components/ai/ThoughtProcess/ThoughtProcess.d.ts +10 -1
- package/dist/components/ai/ThoughtProcess/ThoughtProcess.js +12 -12
- package/dist/components/feedback/Toast/Toast.cjs +1 -1
- package/dist/components/feedback/Toast/Toast.js +1 -1
- package/dist/components/feedback/Toast/toast.module.cjs +1 -1
- package/dist/components/feedback/Toast/toast.module.js +8 -8
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.d.ts +1 -1
- package/dist/components/form/Cascader/Cascader.js +54 -54
- package/dist/components/form/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/form/DateRangePicker/DateRangePicker.d.ts +7 -1
- package/dist/components/form/DateRangePicker/DateRangePicker.js +9 -8
- package/dist/components/form/InlineEdit/InlineEdit.cjs +1 -1
- package/dist/components/form/InlineEdit/InlineEdit.js +33 -29
- package/dist/components/form/Mentions/Mentions.cjs +1 -1
- package/dist/components/form/Mentions/Mentions.js +62 -60
- package/dist/components/form/OtpInput/OtpInput.cjs +1 -1
- package/dist/components/form/OtpInput/OtpInput.js +36 -35
- package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.d.ts +6 -0
- package/dist/components/form/PhoneInput/PhoneInput.js +59 -57
- package/dist/components/form/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.d.ts +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.js +66 -64
- package/dist/components/form/SegmentedControl/SegmentedControl.cjs +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.d.ts +6 -0
- package/dist/components/form/SegmentedControl/SegmentedControl.js +18 -17
- package/dist/components/form/Slider/Slider.cjs +1 -1
- package/dist/components/form/Slider/Slider.js +44 -44
- package/dist/components/form/Transfer/Transfer.cjs +1 -1
- package/dist/components/form/Transfer/Transfer.d.ts +7 -1
- package/dist/components/form/Transfer/Transfer.js +50 -49
- package/dist/components/layout/Dashboard/Dashboard.cjs +1 -1
- package/dist/components/layout/Dashboard/Dashboard.d.ts +6 -1
- package/dist/components/layout/Dashboard/Dashboard.js +2 -2
- package/dist/llms-full.txt +21 -2
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +2 -2
- package/package.json +1 -1
|
@@ -61,33 +61,33 @@ var h = [
|
|
|
61
61
|
dialCode: "55",
|
|
62
62
|
flag: "🇧🇷"
|
|
63
63
|
}
|
|
64
|
-
], g = s(({ value: s = "", onChange: g, countryCode: _ = "US", onCountryChange: v, placeholder: y = "000-0000-0000", disabled: b = !1, error: x, required: S = !1, label: C, layout: w = "vertical", className: T, fullWidth: E = !1,
|
|
65
|
-
let
|
|
64
|
+
], g = s(({ value: s = "", onChange: g, countryCode: _ = "US", onCountryChange: v, placeholder: y = "000-0000-0000", disabled: b = !1, error: x, required: S = !1, label: C, layout: w = "vertical", className: T, fullWidth: E = !1, "aria-label": D, "aria-labelledby": ee, "aria-describedby": O, ...k }, A) => {
|
|
65
|
+
let j = `wim-phone-input-${l()}`, M = C ? `${j}-label` : void 0, { t: N } = e(i), P = N("phone.select_country"), F = `${j}-countries`, I = (e) => `${j}-country-${e}`, L = x ? `${j}-error` : void 0, [R, z] = d(!1), [B, V] = d(-1), H = u(null), U = u(null), W = u({
|
|
66
66
|
text: "",
|
|
67
67
|
timer: null
|
|
68
68
|
});
|
|
69
69
|
c(() => {
|
|
70
70
|
let e = (e) => {
|
|
71
|
-
|
|
71
|
+
H.current && !H.current.contains(e.target) && z(!1);
|
|
72
72
|
};
|
|
73
|
-
return
|
|
73
|
+
return R && document.addEventListener("mousedown", e), () => {
|
|
74
74
|
document.removeEventListener("mousedown", e);
|
|
75
75
|
};
|
|
76
|
-
}, [
|
|
77
|
-
let
|
|
76
|
+
}, [R]);
|
|
77
|
+
let G = h.find((e) => e.code === _) ?? h[0], K = (e) => {
|
|
78
78
|
g?.(e.target.value);
|
|
79
|
-
},
|
|
80
|
-
let t = h.findIndex((e) => e.code ===
|
|
81
|
-
|
|
82
|
-
},
|
|
79
|
+
}, q = h.length - 1, J = (e) => {
|
|
80
|
+
let t = h.findIndex((e) => e.code === G.code);
|
|
81
|
+
V(e ?? Math.max(t, 0)), z(!0);
|
|
82
|
+
}, Y = (e) => {
|
|
83
83
|
let t = h[e];
|
|
84
|
-
t && (v?.(t.code),
|
|
85
|
-
},
|
|
84
|
+
t && (v?.(t.code), z(!1));
|
|
85
|
+
}, X = (e) => N(`phone.countries.${e.code}`), Z = (e) => i.resources.en?.phone?.countries?.[e.code] ?? "", Q = (e, t) => {
|
|
86
86
|
let n = e.toLowerCase().replace(/^\+/, "");
|
|
87
87
|
if (n === "") return -1;
|
|
88
88
|
let r = /^[0-9]+$/.test(n), i = !r && n.length > 1 && n.split("").every((e) => e === n[0]), a = i ? n[0] : n, o = i || n.length === 1 ? t + 1 : t, s = r ? [(e) => e.dialCode] : [
|
|
89
|
-
(e) =>
|
|
90
|
-
(e) =>
|
|
89
|
+
(e) => X(e).toLowerCase(),
|
|
90
|
+
(e) => Z(e).toLowerCase(),
|
|
91
91
|
(e) => e.code.toLowerCase()
|
|
92
92
|
];
|
|
93
93
|
for (let e of s) for (let t = 0; t < h.length; t++) {
|
|
@@ -95,61 +95,61 @@ var h = [
|
|
|
95
95
|
if (e(h[n]).startsWith(a)) return n;
|
|
96
96
|
}
|
|
97
97
|
return -1;
|
|
98
|
-
},
|
|
99
|
-
let t =
|
|
98
|
+
}, $ = (e) => {
|
|
99
|
+
let t = W.current;
|
|
100
100
|
t.timer && clearTimeout(t.timer), t.text += e, t.timer = setTimeout(() => {
|
|
101
101
|
t.text = "", t.timer = null;
|
|
102
102
|
}, 500);
|
|
103
|
-
let n =
|
|
104
|
-
n < 0 || (
|
|
105
|
-
},
|
|
103
|
+
let n = Q(t.text, R ? B : -1);
|
|
104
|
+
n < 0 || (R ? V(n) : J(n));
|
|
105
|
+
}, te = (e) => {
|
|
106
106
|
if (!b) switch (e.key) {
|
|
107
107
|
case "ArrowDown":
|
|
108
108
|
case "ArrowUp":
|
|
109
|
-
if (e.preventDefault(), !
|
|
109
|
+
if (e.preventDefault(), !R) J();
|
|
110
110
|
else {
|
|
111
111
|
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
112
|
-
|
|
112
|
+
V((e) => (e + t + h.length) % h.length);
|
|
113
113
|
}
|
|
114
114
|
break;
|
|
115
115
|
case "Home":
|
|
116
116
|
case "End":
|
|
117
|
-
e.preventDefault(),
|
|
117
|
+
e.preventDefault(), R ? V(e.key === "Home" ? 0 : q) : J(e.key === "Home" ? 0 : q);
|
|
118
118
|
break;
|
|
119
119
|
case "Enter":
|
|
120
120
|
case " ":
|
|
121
|
-
e.preventDefault(), e.key === " " &&
|
|
121
|
+
e.preventDefault(), e.key === " " && W.current.text !== "" ? $(" ") : R ? Y(B) : J();
|
|
122
122
|
break;
|
|
123
123
|
case "Escape":
|
|
124
|
-
|
|
124
|
+
R && (e.preventDefault(), z(!1));
|
|
125
125
|
break;
|
|
126
126
|
case "Tab":
|
|
127
|
-
|
|
127
|
+
z(!1);
|
|
128
128
|
break;
|
|
129
|
-
default: e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(),
|
|
129
|
+
default: e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), $(e.key));
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
return c(() => {
|
|
133
|
-
let e =
|
|
133
|
+
let e = W.current;
|
|
134
134
|
return () => {
|
|
135
135
|
e.timer && clearTimeout(e.timer);
|
|
136
136
|
};
|
|
137
137
|
}, []), c(() => {
|
|
138
|
-
|
|
139
|
-
}, [
|
|
138
|
+
R && B >= 0 && (U.current?.querySelectorAll("[role=\"option\"]")?.[B])?.scrollIntoView?.({ block: "nearest" });
|
|
139
|
+
}, [B, R]), /* @__PURE__ */ p(a, {
|
|
140
140
|
label: C,
|
|
141
|
-
labelId:
|
|
142
|
-
htmlFor:
|
|
141
|
+
labelId: M,
|
|
142
|
+
htmlFor: j,
|
|
143
143
|
required: S,
|
|
144
144
|
error: x,
|
|
145
|
-
errorId:
|
|
145
|
+
errorId: L,
|
|
146
146
|
layout: w,
|
|
147
147
|
className: T,
|
|
148
148
|
children: /* @__PURE__ */ m("div", {
|
|
149
|
-
ref:
|
|
149
|
+
ref: H,
|
|
150
150
|
className: f("wim-phone-input", o.root, E && o.fullWidth, b && o.disabled, x && o.danger),
|
|
151
151
|
"data-testid": "phone-input-root",
|
|
152
|
-
...
|
|
152
|
+
...k,
|
|
153
153
|
children: [
|
|
154
154
|
/* @__PURE__ */ m("div", {
|
|
155
155
|
className: o.countryWrapper,
|
|
@@ -158,50 +158,50 @@ var h = [
|
|
|
158
158
|
role: "combobox",
|
|
159
159
|
className: o.countryTrigger,
|
|
160
160
|
onClick: () => {
|
|
161
|
-
b || (
|
|
161
|
+
b || (R ? z(!1) : J());
|
|
162
162
|
},
|
|
163
|
-
onKeyDown:
|
|
163
|
+
onKeyDown: te,
|
|
164
164
|
onKeyUp: (e) => {
|
|
165
165
|
e.key === " " && e.preventDefault();
|
|
166
166
|
},
|
|
167
167
|
disabled: b,
|
|
168
168
|
"aria-haspopup": "listbox",
|
|
169
|
-
"aria-expanded":
|
|
170
|
-
"aria-controls":
|
|
171
|
-
"aria-activedescendant":
|
|
172
|
-
"aria-label":
|
|
169
|
+
"aria-expanded": R,
|
|
170
|
+
"aria-controls": R ? F : void 0,
|
|
171
|
+
"aria-activedescendant": R && B >= 0 ? I(B) : void 0,
|
|
172
|
+
"aria-label": P,
|
|
173
173
|
children: [
|
|
174
174
|
/* @__PURE__ */ p("span", {
|
|
175
175
|
"aria-hidden": "true",
|
|
176
176
|
style: { fontSize: "1.2em" },
|
|
177
|
-
children:
|
|
177
|
+
children: G.flag
|
|
178
178
|
}),
|
|
179
|
-
/* @__PURE__ */ m("span", { children: ["+",
|
|
179
|
+
/* @__PURE__ */ m("span", { children: ["+", G.dialCode] }),
|
|
180
180
|
/* @__PURE__ */ p(r, {
|
|
181
181
|
component: n,
|
|
182
182
|
size: "sm",
|
|
183
|
-
className: f(o.chevron,
|
|
183
|
+
className: f(o.chevron, R && o.chevronOpen)
|
|
184
184
|
})
|
|
185
185
|
]
|
|
186
186
|
}), /* @__PURE__ */ p(t, {
|
|
187
|
-
show:
|
|
187
|
+
show: R,
|
|
188
188
|
preset: "fade",
|
|
189
189
|
className: o.dropdown,
|
|
190
190
|
children: /* @__PURE__ */ p("ul", {
|
|
191
|
-
ref:
|
|
192
|
-
id:
|
|
191
|
+
ref: U,
|
|
192
|
+
id: F,
|
|
193
193
|
className: o.countryList,
|
|
194
194
|
role: "listbox",
|
|
195
|
-
"aria-label":
|
|
195
|
+
"aria-label": P,
|
|
196
196
|
tabIndex: -1,
|
|
197
197
|
onMouseDown: (e) => e.preventDefault(),
|
|
198
198
|
children: h.map((e, t) => /* @__PURE__ */ m("li", {
|
|
199
|
-
id:
|
|
200
|
-
className: f(o.countryOption, t ===
|
|
201
|
-
onMouseEnter: () =>
|
|
202
|
-
onClick: () =>
|
|
199
|
+
id: I(t),
|
|
200
|
+
className: f(o.countryOption, t === B && o.active, G.code === e.code && o.selected),
|
|
201
|
+
onMouseEnter: () => V(t),
|
|
202
|
+
onClick: () => Y(t),
|
|
203
203
|
role: "option",
|
|
204
|
-
"aria-selected":
|
|
204
|
+
"aria-selected": G.code === e.code,
|
|
205
205
|
children: [
|
|
206
206
|
/* @__PURE__ */ p("span", {
|
|
207
207
|
"aria-hidden": "true",
|
|
@@ -209,7 +209,7 @@ var h = [
|
|
|
209
209
|
}),
|
|
210
210
|
/* @__PURE__ */ p("span", {
|
|
211
211
|
className: o.countryName,
|
|
212
|
-
children:
|
|
212
|
+
children: X(e)
|
|
213
213
|
}),
|
|
214
214
|
" ",
|
|
215
215
|
/* @__PURE__ */ m("span", {
|
|
@@ -226,16 +226,18 @@ var h = [
|
|
|
226
226
|
"aria-hidden": "true"
|
|
227
227
|
}),
|
|
228
228
|
/* @__PURE__ */ p("input", {
|
|
229
|
-
id:
|
|
230
|
-
ref:
|
|
229
|
+
id: j,
|
|
230
|
+
ref: A,
|
|
231
231
|
type: "tel",
|
|
232
232
|
value: s,
|
|
233
|
-
onChange:
|
|
233
|
+
onChange: K,
|
|
234
234
|
placeholder: y,
|
|
235
235
|
disabled: b,
|
|
236
236
|
className: o.number,
|
|
237
237
|
"aria-invalid": !!x,
|
|
238
|
-
"aria-
|
|
238
|
+
"aria-label": C ? void 0 : D,
|
|
239
|
+
"aria-labelledby": C ? void 0 : ee,
|
|
240
|
+
"aria-describedby": [O, L].filter(Boolean).join(" ") || void 0
|
|
239
241
|
})
|
|
240
242
|
]
|
|
241
243
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../i18n/generated/common.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../../utilities/slider-utils.cjs"),o=require("./range-slider.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=({value:e,defaultValue:u=[20,80],min:d=0,max:f=100,step:p=1,allowCross:m=!1,disabled:h=!1,onChange:g,onAfterChange:_,className:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../i18n/generated/common.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../../utilities/slider-utils.cjs"),o=require("./range-slider.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=({value:e,defaultValue:u=[20,80],min:d=0,max:f=100,step:p=1,allowCross:m=!1,disabled:h=!1,onChange:g,onAfterChange:_,className:ee,name:v,label:y,error:b,required:te,layout:ne=`vertical`,id:re,"aria-label":ie,"aria-labelledby":x,"aria-describedby":ae,asChild:oe=!1,children:se,...ce})=>{let{t:S}=n.useWimTranslation(r.commonNs),C=e!==void 0,le=(0,s.useId)(),w=re||le,ue=`wim-range-slider-label-${w}`,T=`wim-range-slider-error-${w}`,E=[ae,b?T:void 0].filter(Boolean).join(` `)||void 0,D=y||ie,O=`wim-range-slider-start-${w}`,k=`wim-range-slider-end-${w}`,A=e=>!D&&x?`${x} ${e}`:void 0,{clamp:j,calculateValue:M}=a.useSliderCommon(d,f,p),N=[j(u[0],d,f),j(u[1],d,f)];N[0]>N[1]&&N.sort((e,t)=>e-t);let[de,P]=(0,s.useState)(N),F=C?e:de,I=(0,s.useRef)(null),L=(0,s.useRef)(null),R=(0,s.useRef)(null),z=(0,s.useRef)(null),B=(0,s.useRef)(null),V=(0,s.useRef)(null),[H,U]=(0,s.useState)(null),W=(0,s.useRef)(null),G=(0,s.useRef)([...F]),K=(0,s.useCallback)(e=>(e-d)/(f-d)*100,[d,f]),q=(0,s.useCallback)(e=>{let t=K(e[0]),n=K(e[1]);L.current&&(L.current.style.left=`${t}%`,L.current.setAttribute(`aria-valuenow`,String(e[0])),L.current.setAttribute(`aria-valuemax`,String(e[1]))),R.current&&(R.current.style.left=`${n}%`,R.current.setAttribute(`aria-valuenow`,String(e[1])),R.current.setAttribute(`aria-valuemin`,String(e[0]))),z.current&&(z.current.style.left=`${t}%`,z.current.style.width=`${n-t}%`),B.current&&(B.current.value=String(e[0])),V.current&&(V.current.value=String(e[1]))},[K]);(0,s.useEffect)(()=>{H||q(F)},[F,H,q]);let J=(e,t)=>{h||(G.current=[...F],W.current=t,U(t),e.stopPropagation(),e.preventDefault())},Y=e=>{if(h)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=M(t,I.current),r=Math.abs(F[0]-n),i=Math.abs(F[1]-n),a;a=r<i?`min`:i<r?`max`:n<F[0]?`min`:`max`,W.current=a,U(a);let o=[...G.current];a===`min`?o[0]=Math.min(n,m?f:o[1]):o[1]=Math.max(n,m?d:o[0]),G.current=o,q(o),g?.(o)},X=(0,s.useCallback)(e=>{if(!W.current||h)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=M(t,I.current),r=[...G.current];W.current===`min`?r[0]=Math.min(n,m?f:r[1]):r[1]=Math.max(n,m?d:r[0]),G.current=r,q(r),g?.(r)},[h,g,m,M,d,f,q]),Z=(0,s.useCallback)(()=>{if(W.current){W.current=null,U(null);let e=G.current;C||P([...e]),_?.(e)}},[C,_]);(0,s.useEffect)(()=>(document.addEventListener(`mousemove`,X),document.addEventListener(`mouseup`,Z),document.addEventListener(`touchmove`,X,{passive:!1}),document.addEventListener(`touchend`,Z),()=>{document.removeEventListener(`mousemove`,X),document.removeEventListener(`mouseup`,Z),document.removeEventListener(`touchmove`,X),document.removeEventListener(`touchend`,Z)}),[X,Z]);let Q=(e,t)=>{if(h)return;let n=[...F],r=t===`min`?n[0]:n[1],i;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)i=Math.max(d,r-p);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)i=Math.min(f,r+p);else if(e.key===`Home`)i=d;else if(e.key===`End`)i=f;else return;if(t===`min`){let e=m?f:n[1];n[0]=Math.min(i,e)}else{let e=m?d:n[0];n[1]=Math.max(i,e)}C||P(n),g?.(n),e.preventDefault()},$=K(F[0]),fe=K(F[1]);return(0,l.jsx)(i.FieldTemplate,{label:y,error:b,required:te,layout:ne,labelId:ue,errorId:T,className:ee,children:(0,l.jsxs)(oe?t.Root:`div`,{role:`presentation`,"data-testid":`range-slider-root`,className:(0,c.default)(`wim-range-slider`,o.default.root,h&&o.default.disabled,b&&o.default.danger),onMouseDown:Y,onTouchStart:Y,...ce,children:[(0,l.jsxs)(`div`,{className:o.default.trackContainer,ref:I,children:[(0,l.jsx)(`div`,{ref:z,className:o.default.track,style:{left:`${$}%`,width:`${fe-$}%`}}),(0,l.jsx)(`div`,{ref:L,className:(0,c.default)(o.default.thumb,H===`min`&&o.default.active),style:{left:`${$}%`},role:`slider`,"aria-valuemin":d,"aria-valuemax":F[1],"aria-valuenow":F[0],"aria-disabled":h,id:O,"aria-labelledby":A(O),"aria-label":D?S(`rangeSlider.start_of`,{label:D}):S(`rangeSlider.start`),"aria-describedby":E,"aria-invalid":b?!0:void 0,tabIndex:h?-1:0,onMouseDown:e=>J(e,`min`),onTouchStart:e=>J(e,`min`),onKeyDown:e=>Q(e,`min`)}),(0,l.jsx)(`div`,{ref:R,className:(0,c.default)(o.default.thumb,H===`max`&&o.default.active),style:{left:`${fe}%`},role:`slider`,"aria-valuemin":F[0],"aria-valuemax":f,"aria-valuenow":F[1],"aria-disabled":h,id:k,"aria-labelledby":A(k),"aria-label":D?S(`rangeSlider.end_of`,{label:D}):S(`rangeSlider.end`),"aria-describedby":E,"aria-invalid":b?!0:void 0,tabIndex:h?-1:0,onMouseDown:e=>J(e,`max`),onTouchStart:e=>J(e,`max`),onKeyDown:e=>Q(e,`max`)})]}),(0,l.jsx)(`input`,{ref:B,type:`hidden`,name:v?`${v}-min`:``,value:F[0]}),(0,l.jsx)(`input`,{ref:V,type:`hidden`,name:v?`${v}-max`:``,value:F[1]}),(0,l.jsx)(t.Slottable,{children:se})]})})};u.displayName=`RangeSlider`,exports.RangeSlider=u;
|
|
@@ -43,7 +43,7 @@ type RangeSliderProps = Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" |
|
|
|
43
43
|
* Slider component for selecting a range (start and end).
|
|
44
44
|
*/
|
|
45
45
|
export declare const RangeSlider: {
|
|
46
|
-
({ value, defaultValue, min, max, step, allowCross, disabled, onChange, onAfterChange, className, name, label, error, required, layout, id: customId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, asChild, children, ...props }: RangeSliderProps): React.JSX.Element;
|
|
46
|
+
({ value, defaultValue, min, max, step, allowCross, disabled, onChange, onAfterChange, className, name, label, error, required, layout, id: customId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, asChild, children, ...props }: RangeSliderProps): React.JSX.Element;
|
|
47
47
|
displayName: string;
|
|
48
48
|
};
|
|
49
49
|
export {};
|
|
@@ -5,18 +5,18 @@ import { commonNs as r } from "../../../i18n/generated/common.js";
|
|
|
5
5
|
import { FieldTemplate as i } from "../FieldTemplate/FieldTemplate.js";
|
|
6
6
|
import { useSliderCommon as a } from "../../../utilities/slider-utils.js";
|
|
7
7
|
import o from "./range-slider.module.js";
|
|
8
|
-
import { useCallback as s, useEffect as
|
|
8
|
+
import { useCallback as s, useEffect as c, useId as ee, useRef as l, useState as te } from "react";
|
|
9
9
|
import u from "classnames";
|
|
10
10
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/RangeSlider/RangeSlider.tsx
|
|
12
|
-
var p = ({ value: p, defaultValue:
|
|
13
|
-
let { t:
|
|
12
|
+
var p = ({ value: p, defaultValue: ne = [20, 80], min: m = 0, max: h = 100, step: g = 1, allowCross: _ = !1, disabled: v = !1, onChange: y, onAfterChange: b, className: re, name: x, label: S, error: C, required: ie, layout: ae = "vertical", id: oe, "aria-label": se, "aria-labelledby": w, "aria-describedby": ce, asChild: le = !1, children: ue, ...de }) => {
|
|
13
|
+
let { t: T } = n(r), E = p !== void 0, fe = ee(), D = oe || fe, pe = `wim-range-slider-label-${D}`, me = `wim-range-slider-error-${D}`, he = [ce, C ? me : void 0].filter(Boolean).join(" ") || void 0, O = S || se, k = `wim-range-slider-start-${D}`, A = `wim-range-slider-end-${D}`, j = (e) => !O && w ? `${w} ${e}` : void 0, { clamp: M, calculateValue: N } = a(m, h, g), P = [M(ne[0], m, h), M(ne[1], m, h)];
|
|
14
14
|
P[0] > P[1] && P.sort((e, t) => e - t);
|
|
15
|
-
let [
|
|
15
|
+
let [ge, F] = te(P), I = E ? p : ge, L = l(null), R = l(null), z = l(null), B = l(null), V = l(null), H = l(null), [U, W] = te(null), G = l(null), K = l([...I]), q = s((e) => (e - m) / (h - m) * 100, [m, h]), J = s((e) => {
|
|
16
16
|
let t = q(e[0]), n = q(e[1]);
|
|
17
17
|
R.current && (R.current.style.left = `${t}%`, R.current.setAttribute("aria-valuenow", String(e[0])), R.current.setAttribute("aria-valuemax", String(e[1]))), z.current && (z.current.style.left = `${n}%`, z.current.setAttribute("aria-valuenow", String(e[1])), z.current.setAttribute("aria-valuemin", String(e[0]))), B.current && (B.current.style.left = `${t}%`, B.current.style.width = `${n - t}%`), V.current && (V.current.value = String(e[0])), H.current && (H.current.value = String(e[1]));
|
|
18
18
|
}, [q]);
|
|
19
|
-
|
|
19
|
+
c(() => {
|
|
20
20
|
U || J(I);
|
|
21
21
|
}, [
|
|
22
22
|
I,
|
|
@@ -24,67 +24,67 @@ var p = ({ value: p, defaultValue: m = [20, 80], min: h = 0, max: g = 100, step:
|
|
|
24
24
|
J
|
|
25
25
|
]);
|
|
26
26
|
let Y = (e, t) => {
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
if (
|
|
27
|
+
v || (K.current = [...I], G.current = t, W(t), e.stopPropagation(), e.preventDefault());
|
|
28
|
+
}, _e = (e) => {
|
|
29
|
+
if (v) return;
|
|
30
30
|
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = N(t, L.current), r = Math.abs(I[0] - n), i = Math.abs(I[1] - n), a;
|
|
31
31
|
a = r < i ? "min" : i < r ? "max" : n < I[0] ? "min" : "max", G.current = a, W(a);
|
|
32
32
|
let o = [...K.current];
|
|
33
|
-
a === "min" ? o[0] = Math.min(n,
|
|
34
|
-
},
|
|
35
|
-
if (!G.current ||
|
|
33
|
+
a === "min" ? o[0] = Math.min(n, _ ? h : o[1]) : o[1] = Math.max(n, _ ? m : o[0]), K.current = o, J(o), y?.(o);
|
|
34
|
+
}, X = s((e) => {
|
|
35
|
+
if (!G.current || v) return;
|
|
36
36
|
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = N(t, L.current), r = [...K.current];
|
|
37
|
-
G.current === "min" ? r[0] = Math.min(n,
|
|
37
|
+
G.current === "min" ? r[0] = Math.min(n, _ ? h : r[1]) : r[1] = Math.max(n, _ ? m : r[0]), K.current = r, J(r), y?.(r);
|
|
38
38
|
}, [
|
|
39
|
-
y,
|
|
40
|
-
b,
|
|
41
39
|
v,
|
|
40
|
+
y,
|
|
41
|
+
_,
|
|
42
42
|
N,
|
|
43
|
+
m,
|
|
43
44
|
h,
|
|
44
|
-
g,
|
|
45
45
|
J
|
|
46
|
-
]),
|
|
46
|
+
]), Z = s(() => {
|
|
47
47
|
if (G.current) {
|
|
48
48
|
G.current = null, W(null);
|
|
49
49
|
let e = K.current;
|
|
50
|
-
|
|
50
|
+
E || F([...e]), b?.(e);
|
|
51
51
|
}
|
|
52
|
-
}, [
|
|
53
|
-
|
|
54
|
-
document.removeEventListener("mousemove",
|
|
55
|
-
}), [
|
|
56
|
-
let
|
|
57
|
-
if (
|
|
52
|
+
}, [E, b]);
|
|
53
|
+
c(() => (document.addEventListener("mousemove", X), document.addEventListener("mouseup", Z), document.addEventListener("touchmove", X, { passive: !1 }), document.addEventListener("touchend", Z), () => {
|
|
54
|
+
document.removeEventListener("mousemove", X), document.removeEventListener("mouseup", Z), document.removeEventListener("touchmove", X), document.removeEventListener("touchend", Z);
|
|
55
|
+
}), [X, Z]);
|
|
56
|
+
let Q = (e, t) => {
|
|
57
|
+
if (v) return;
|
|
58
58
|
let n = [...I], r = t === "min" ? n[0] : n[1], i;
|
|
59
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowDown") i = Math.max(
|
|
60
|
-
else if (e.key === "ArrowRight" || e.key === "ArrowUp") i = Math.min(
|
|
61
|
-
else if (e.key === "Home") i =
|
|
62
|
-
else if (e.key === "End") i =
|
|
59
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") i = Math.max(m, r - g);
|
|
60
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") i = Math.min(h, r + g);
|
|
61
|
+
else if (e.key === "Home") i = m;
|
|
62
|
+
else if (e.key === "End") i = h;
|
|
63
63
|
else return;
|
|
64
64
|
if (t === "min") {
|
|
65
|
-
let e =
|
|
65
|
+
let e = _ ? h : n[1];
|
|
66
66
|
n[0] = Math.min(i, e);
|
|
67
67
|
} else {
|
|
68
|
-
let e =
|
|
68
|
+
let e = _ ? m : n[0];
|
|
69
69
|
n[1] = Math.max(i, e);
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
}, $ = q(I[0]),
|
|
71
|
+
E || F(n), y?.(n), e.preventDefault();
|
|
72
|
+
}, $ = q(I[0]), ve = q(I[1]);
|
|
73
73
|
return /* @__PURE__ */ d(i, {
|
|
74
|
-
label:
|
|
75
|
-
error:
|
|
76
|
-
required:
|
|
77
|
-
layout:
|
|
78
|
-
labelId:
|
|
79
|
-
errorId:
|
|
80
|
-
className:
|
|
81
|
-
children: /* @__PURE__ */ f(
|
|
74
|
+
label: S,
|
|
75
|
+
error: C,
|
|
76
|
+
required: ie,
|
|
77
|
+
layout: ae,
|
|
78
|
+
labelId: pe,
|
|
79
|
+
errorId: me,
|
|
80
|
+
className: re,
|
|
81
|
+
children: /* @__PURE__ */ f(le ? e : "div", {
|
|
82
82
|
role: "presentation",
|
|
83
83
|
"data-testid": "range-slider-root",
|
|
84
|
-
className: u("wim-range-slider", o.root,
|
|
85
|
-
onMouseDown:
|
|
86
|
-
onTouchStart:
|
|
87
|
-
...
|
|
84
|
+
className: u("wim-range-slider", o.root, v && o.disabled, C && o.danger),
|
|
85
|
+
onMouseDown: _e,
|
|
86
|
+
onTouchStart: _e,
|
|
87
|
+
...de,
|
|
88
88
|
children: [
|
|
89
89
|
/* @__PURE__ */ f("div", {
|
|
90
90
|
className: o.trackContainer,
|
|
@@ -95,7 +95,7 @@ var p = ({ value: p, defaultValue: m = [20, 80], min: h = 0, max: g = 100, step:
|
|
|
95
95
|
className: o.track,
|
|
96
96
|
style: {
|
|
97
97
|
left: `${$}%`,
|
|
98
|
-
width: `${
|
|
98
|
+
width: `${ve - $}%`
|
|
99
99
|
}
|
|
100
100
|
}),
|
|
101
101
|
/* @__PURE__ */ d("div", {
|
|
@@ -103,52 +103,54 @@ var p = ({ value: p, defaultValue: m = [20, 80], min: h = 0, max: g = 100, step:
|
|
|
103
103
|
className: u(o.thumb, U === "min" && o.active),
|
|
104
104
|
style: { left: `${$}%` },
|
|
105
105
|
role: "slider",
|
|
106
|
-
"aria-valuemin":
|
|
106
|
+
"aria-valuemin": m,
|
|
107
107
|
"aria-valuemax": I[1],
|
|
108
108
|
"aria-valuenow": I[0],
|
|
109
|
-
"aria-disabled":
|
|
110
|
-
|
|
111
|
-
"aria-
|
|
112
|
-
"aria-
|
|
113
|
-
"aria-
|
|
114
|
-
|
|
109
|
+
"aria-disabled": v,
|
|
110
|
+
id: k,
|
|
111
|
+
"aria-labelledby": j(k),
|
|
112
|
+
"aria-label": O ? T("rangeSlider.start_of", { label: O }) : T("rangeSlider.start"),
|
|
113
|
+
"aria-describedby": he,
|
|
114
|
+
"aria-invalid": C ? !0 : void 0,
|
|
115
|
+
tabIndex: v ? -1 : 0,
|
|
115
116
|
onMouseDown: (e) => Y(e, "min"),
|
|
116
117
|
onTouchStart: (e) => Y(e, "min"),
|
|
117
|
-
onKeyDown: (e) =>
|
|
118
|
+
onKeyDown: (e) => Q(e, "min")
|
|
118
119
|
}),
|
|
119
120
|
/* @__PURE__ */ d("div", {
|
|
120
121
|
ref: z,
|
|
121
122
|
className: u(o.thumb, U === "max" && o.active),
|
|
122
|
-
style: { left: `${
|
|
123
|
+
style: { left: `${ve}%` },
|
|
123
124
|
role: "slider",
|
|
124
125
|
"aria-valuemin": I[0],
|
|
125
|
-
"aria-valuemax":
|
|
126
|
+
"aria-valuemax": h,
|
|
126
127
|
"aria-valuenow": I[1],
|
|
127
|
-
"aria-disabled":
|
|
128
|
-
|
|
129
|
-
"aria-
|
|
130
|
-
"aria-
|
|
131
|
-
"aria-
|
|
132
|
-
|
|
128
|
+
"aria-disabled": v,
|
|
129
|
+
id: A,
|
|
130
|
+
"aria-labelledby": j(A),
|
|
131
|
+
"aria-label": O ? T("rangeSlider.end_of", { label: O }) : T("rangeSlider.end"),
|
|
132
|
+
"aria-describedby": he,
|
|
133
|
+
"aria-invalid": C ? !0 : void 0,
|
|
134
|
+
tabIndex: v ? -1 : 0,
|
|
133
135
|
onMouseDown: (e) => Y(e, "max"),
|
|
134
136
|
onTouchStart: (e) => Y(e, "max"),
|
|
135
|
-
onKeyDown: (e) =>
|
|
137
|
+
onKeyDown: (e) => Q(e, "max")
|
|
136
138
|
})
|
|
137
139
|
]
|
|
138
140
|
}),
|
|
139
141
|
/* @__PURE__ */ d("input", {
|
|
140
142
|
ref: V,
|
|
141
143
|
type: "hidden",
|
|
142
|
-
name:
|
|
144
|
+
name: x ? `${x}-min` : "",
|
|
143
145
|
value: I[0]
|
|
144
146
|
}),
|
|
145
147
|
/* @__PURE__ */ d("input", {
|
|
146
148
|
ref: H,
|
|
147
149
|
type: "hidden",
|
|
148
|
-
name:
|
|
150
|
+
name: x ? `${x}-max` : "",
|
|
149
151
|
value: I[1]
|
|
150
152
|
}),
|
|
151
|
-
/* @__PURE__ */ d(t, { children:
|
|
153
|
+
/* @__PURE__ */ d(t, { children: ue })
|
|
152
154
|
]
|
|
153
155
|
})
|
|
154
156
|
});
|
|
@@ -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"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./segmented-control.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=(0,s.forwardRef)(({options:e,value:u,onChange:d,size:f=`md`,fullWidth:p=!1,className:m,label:h,error:g,required:_,layout:v=`vertical`,disabled:y=!1,asChild:b=!1,children:x,id:S,styles:C},
|
|
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("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./segmented-control.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=(0,s.forwardRef)(({options:e,value:u,onChange:d,size:f=`md`,fullWidth:p=!1,className:m,label:h,error:g,required:_,layout:v=`vertical`,disabled:y=!1,asChild:b=!1,children:x,id:S,styles:C,"aria-label":w,"aria-labelledby":T,"aria-describedby":E},D)=>{let O=(0,s.useRef)([]),k=(0,s.useId)(),A=S||`wim-segmented-${k}`,j=`${A}-label`,M=`${A}-error`,{containerRef:N,sliderStyle:P,isReady:F}=a.useIndicator({activeSelector:`.${o.default.active}`,dependence:e.length}),I=e.findIndex(e=>e.value===u),L=(t,n)=>{let r;switch(t.key){case`ArrowLeft`:case`ArrowUp`:r=n-1,r<0&&(r=e.length-1);break;case`ArrowRight`:case`ArrowDown`:r=n+1,r>=e.length&&(r=0);break;case`Home`:r=0;break;case`End`:r=e.length-1;break;default:return}t.preventDefault(),d(e[r].value),O.current[r]?.focus()},R=`${A}-item-0`;return(0,l.jsx)(i.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:j,htmlFor:R,errorId:M,className:m,children:(0,l.jsxs)(b?t.Root:`div`,{ref:n.useMergedRef(N,D),id:A,className:(0,c.default)(`wim-segmented-control`,o.default.root,o.default[f],p&&o.default.fullWidth,F&&o.default.ready,g&&o.default.danger,C?.root),role:`radiogroup`,"aria-labelledby":h?j:T,"aria-label":h||T?void 0:w,"aria-required":_,"aria-invalid":g?!0:void 0,"aria-describedby":[E,g?M:void 0].filter(Boolean).join(` `)||void 0,children:[(0,l.jsx)(`div`,{className:(0,c.default)(o.default.slider,C?.slider),style:P,"aria-hidden":`true`}),e.map((e,t)=>{let n=e.value===u,i=n||I===-1&&t===0,a=`${A}-item-${t}`;return(0,l.jsxs)(`button`,{id:a,ref:e=>{O.current[t]=e},type:`button`,className:(0,c.default)(o.default.item,n&&o.default.active,!e.label&&e.iconName&&o.default.iconOnly,C?.item),onClick:()=>d(e.value),onKeyDown:e=>L(e,t),onFocus:()=>{},onBlur:()=>{},role:`radio`,"aria-checked":n,tabIndex:i?0:-1,"aria-label":e.label||e.value,disabled:y,children:[e.iconName&&(0,l.jsx)(r.Icon,{name:e.iconName,size:f,className:o.default.icon}),e.label&&(0,l.jsx)(`span`,{className:(0,c.default)(o.default.label,C?.label),children:e.label})]},e.value)}),(0,l.jsx)(t.Slottable,{children:x})]})})});u.displayName=`SegmentedControl`,exports.SegmentedControl=u;
|
|
@@ -34,6 +34,12 @@ type SegmentedControlProps = {
|
|
|
34
34
|
asChild?: boolean;
|
|
35
35
|
/** Optional children used when asChild is true */
|
|
36
36
|
children?: React.ReactNode;
|
|
37
|
+
/** Accessible name for the radio group when no visible `label` is provided. */
|
|
38
|
+
"aria-label"?: string;
|
|
39
|
+
/** ID of the element that labels the radio group when no visible `label` is provided. */
|
|
40
|
+
"aria-labelledby"?: string;
|
|
41
|
+
/** ID of the element that describes the radio group. Announced together with the error message. */
|
|
42
|
+
"aria-describedby"?: string;
|
|
37
43
|
/**
|
|
38
44
|
* Unique ID for the component
|
|
39
45
|
*/
|
|
@@ -9,11 +9,11 @@ import { forwardRef as s, useId as c, useRef as l } from "react";
|
|
|
9
9
|
import u from "classnames";
|
|
10
10
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/SegmentedControl/SegmentedControl.tsx
|
|
12
|
-
var p = s(({ options: s, value: p, onChange: m, size: h = "md", fullWidth: g = !1, className: _, label: v, error: y, required: b, layout: x = "vertical", disabled: S = !1, asChild: C = !1, children: w, id: T, styles: E },
|
|
13
|
-
let
|
|
12
|
+
var p = s(({ options: s, value: p, onChange: m, size: h = "md", fullWidth: g = !1, className: _, label: v, error: y, required: b, layout: x = "vertical", disabled: S = !1, asChild: C = !1, children: w, id: T, styles: E, "aria-label": D, "aria-labelledby": O, "aria-describedby": k }, A) => {
|
|
13
|
+
let j = l([]), M = c(), N = T || `wim-segmented-${M}`, P = `${N}-label`, F = `${N}-error`, { containerRef: I, sliderStyle: L, isReady: R } = a({
|
|
14
14
|
activeSelector: `.${o.active}`,
|
|
15
15
|
dependence: s.length
|
|
16
|
-
}),
|
|
16
|
+
}), z = s.findIndex((e) => e.value === p), B = (e, t) => {
|
|
17
17
|
let n;
|
|
18
18
|
switch (e.key) {
|
|
19
19
|
case "ArrowLeft":
|
|
@@ -32,43 +32,44 @@ var p = s(({ options: s, value: p, onChange: m, size: h = "md", fullWidth: g = !
|
|
|
32
32
|
break;
|
|
33
33
|
default: return;
|
|
34
34
|
}
|
|
35
|
-
e.preventDefault(), m(s[n].value),
|
|
36
|
-
},
|
|
35
|
+
e.preventDefault(), m(s[n].value), j.current[n]?.focus();
|
|
36
|
+
}, V = `${N}-item-0`;
|
|
37
37
|
return /* @__PURE__ */ d(i, {
|
|
38
38
|
label: v,
|
|
39
39
|
error: y,
|
|
40
40
|
required: b,
|
|
41
41
|
layout: x,
|
|
42
|
-
labelId:
|
|
43
|
-
htmlFor:
|
|
44
|
-
errorId:
|
|
42
|
+
labelId: P,
|
|
43
|
+
htmlFor: V,
|
|
44
|
+
errorId: F,
|
|
45
45
|
className: _,
|
|
46
46
|
children: /* @__PURE__ */ f(C ? e : "div", {
|
|
47
|
-
ref: n(
|
|
48
|
-
id:
|
|
49
|
-
className: u("wim-segmented-control", o.root, o[h], g && o.fullWidth,
|
|
47
|
+
ref: n(I, A),
|
|
48
|
+
id: N,
|
|
49
|
+
className: u("wim-segmented-control", o.root, o[h], g && o.fullWidth, R && o.ready, y && o.danger, E?.root),
|
|
50
50
|
role: "radiogroup",
|
|
51
|
-
"aria-labelledby": v ?
|
|
51
|
+
"aria-labelledby": v ? P : O,
|
|
52
|
+
"aria-label": v || O ? void 0 : D,
|
|
52
53
|
"aria-required": b,
|
|
53
54
|
"aria-invalid": y ? !0 : void 0,
|
|
54
|
-
"aria-describedby": y ?
|
|
55
|
+
"aria-describedby": [k, y ? F : void 0].filter(Boolean).join(" ") || void 0,
|
|
55
56
|
children: [
|
|
56
57
|
/* @__PURE__ */ d("div", {
|
|
57
58
|
className: u(o.slider, E?.slider),
|
|
58
|
-
style:
|
|
59
|
+
style: L,
|
|
59
60
|
"aria-hidden": "true"
|
|
60
61
|
}),
|
|
61
62
|
s.map((e, t) => {
|
|
62
|
-
let n = e.value === p, i = n ||
|
|
63
|
+
let n = e.value === p, i = n || z === -1 && t === 0, a = `${N}-item-${t}`;
|
|
63
64
|
return /* @__PURE__ */ f("button", {
|
|
64
65
|
id: a,
|
|
65
66
|
ref: (e) => {
|
|
66
|
-
|
|
67
|
+
j.current[t] = e;
|
|
67
68
|
},
|
|
68
69
|
type: "button",
|
|
69
70
|
className: u(o.item, n && o.active, !e.label && e.iconName && o.iconOnly, E?.item),
|
|
70
71
|
onClick: () => m(e.value),
|
|
71
|
-
onKeyDown: (e) =>
|
|
72
|
+
onKeyDown: (e) => B(e, t),
|
|
72
73
|
onFocus: () => {},
|
|
73
74
|
onBlur: () => {},
|
|
74
75
|
role: "radio",
|
|
@@ -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("../FieldTemplate/FieldTemplate.cjs"),r=require("../../../utilities/slider-utils.cjs"),i=require("./slider.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,a.forwardRef)(({value:e,defaultValue:c=0,min:l=0,max:u=100,step:d=1,disabled:f=!1,onChange:p,onAfterChange:m,className:h,name:g,label:_,error:v,required:y,layout:b=`vertical`,id:x,"aria-label":S,"aria-labelledby":C,asChild:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../FieldTemplate/FieldTemplate.cjs"),r=require("../../../utilities/slider-utils.cjs"),i=require("./slider.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,a.forwardRef)(({value:e,defaultValue:c=0,min:l=0,max:u=100,step:d=1,disabled:f=!1,onChange:p,onAfterChange:m,className:h,name:g,label:_,error:v,required:y,layout:b=`vertical`,id:x,"aria-label":S,"aria-labelledby":C,"aria-describedby":w,asChild:T=!1,styles:E,children:D,...O},k)=>{let A=e!==void 0,[j,M]=(0,a.useState)(c),N=A?e:j,P=(0,a.useRef)(null),F=(0,a.useRef)(null),I=(0,a.useRef)(null),L=(0,a.useRef)(null),R=(0,a.useRef)(!1),z=(0,a.useRef)(N),B=(0,a.useId)(),V=x||B,H=`wim-slider-label-${V}`,U=`wim-slider-error-${V}`,{calculateValue:W}=r.useSliderCommon(l,u,d),G=(0,a.useCallback)(e=>(e-l)/(u-l)*100,[l,u]),K=(0,a.useCallback)(e=>{let t=G(e);I.current&&(I.current.style.width=`${t}%`),F.current&&(F.current.style.left=`${t}%`,F.current.setAttribute(`aria-valuenow`,String(e))),L.current&&(L.current.value=String(e))},[G]);(0,a.useEffect)(()=>{R.current||K(N)},[N,K]);let q=e=>{if(f)return;R.current=!0;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=W(t,P.current);z.current=n,K(n),p?.(n),e.preventDefault()},J=(0,a.useCallback)(e=>{if(!R.current||f)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=W(t,P.current);z.current=n,K(n),p?.(n)},[f,W,p,K]),Y=(0,a.useCallback)(()=>{if(R.current){R.current=!1;let e=z.current;A||M(e),m?.(e)}},[A,m]);(0,a.useEffect)(()=>(document.addEventListener(`mousemove`,J),document.addEventListener(`mouseup`,Y),document.addEventListener(`touchmove`,J,{passive:!1}),document.addEventListener(`touchend`,Y),()=>{document.removeEventListener(`mousemove`,J),document.removeEventListener(`mouseup`,Y),document.removeEventListener(`touchmove`,J),document.removeEventListener(`touchend`,Y)}),[J,Y]);let X=e=>{if(f)return;let t;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)t=Math.max(l,N-d);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)t=Math.min(u,N+d);else if(e.key===`Home`)t=l;else if(e.key===`End`)t=u;else return;A||M(t),p?.(t),e.preventDefault()},Z=G(N);return(0,s.jsx)(n.FieldTemplate,{label:_,error:v,required:y,layout:b,labelId:H,errorId:U,className:h,styles:E,children:(0,s.jsxs)(T?t.Root:`div`,{role:`presentation`,className:(0,o.default)(`wim-slider`,i.default.root,f&&i.default.disabled,v&&i.default.danger),onMouseDown:q,onTouchStart:q,ref:k,...O,children:[(0,s.jsxs)(t.Slottable,{children:[(0,s.jsxs)(`div`,{className:i.default.trackContainer,ref:P,children:[(0,s.jsx)(`div`,{ref:I,className:i.default.track,style:{width:`${Z}%`}}),(0,s.jsx)(`div`,{ref:F,className:i.default.thumb,style:{left:`${Z}%`},role:`slider`,"aria-valuemin":l,"aria-valuemax":u,"aria-valuenow":N,"aria-disabled":f,"aria-labelledby":_?H:C,"aria-label":_?void 0:S,"aria-describedby":[w,v?U:void 0].filter(Boolean).join(` `)||void 0,"aria-invalid":v?!0:void 0,tabIndex:f?-1:0,onKeyDown:X})]}),(0,s.jsx)(`input`,{ref:L,type:`hidden`,name:g,value:N})]}),T?D:null]})})});c.displayName=`Slider`,exports.Slider=c,exports.default=c;
|