wimui 0.51.1 → 0.51.2
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/ChatUI/ChatUI.cjs +1 -1
- package/dist/components/ai/ChatUI/ChatUI.js +10 -10
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +121 -120
- package/dist/components/ai/ThreadList/ThreadList.cjs +1 -1
- package/dist/components/ai/ThreadList/ThreadList.js +63 -62
- package/dist/components/data-display/Accordion/accordion.module.cjs +1 -1
- package/dist/components/data-display/Accordion/accordion.module.js +1 -1
- package/dist/components/data-display/Carousel/Carousel.cjs +1 -1
- package/dist/components/data-display/Carousel/Carousel.js +46 -46
- package/dist/components/data-display/NodeGraph/NodeGraph.cjs +1 -1
- package/dist/components/data-display/NodeGraph/NodeGraph.js +48 -48
- package/dist/components/data-display/ScheduleView/ScheduleView.cjs +1 -1
- package/dist/components/data-display/ScheduleView/ScheduleView.js +49 -48
- package/dist/components/feedback/Tour/Tour.cjs +1 -1
- package/dist/components/feedback/Tour/Tour.js +125 -100
- package/dist/components/form/OtpInput/otp-input.module.cjs +1 -1
- package/dist/components/form/OtpInput/otp-input.module.js +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.js +116 -115
- package/dist/components/form/RangeSlider/range-slider.module.cjs +1 -1
- package/dist/components/form/RangeSlider/range-slider.module.js +1 -1
- package/dist/components/form/ThemeToggle/ThemeToggle.cjs +1 -1
- package/dist/components/form/ThemeToggle/ThemeToggle.js +66 -65
- package/dist/components/form/Transfer/Transfer.cjs +1 -1
- package/dist/components/form/Transfer/Transfer.d.ts +1 -1
- package/dist/components/form/Transfer/Transfer.js +104 -104
- package/dist/components/form/Transfer/transfer.module.cjs +1 -1
- package/dist/components/form/Transfer/transfer.module.js +6 -6
- package/dist/components/media/Audio/Audio.cjs +1 -1
- package/dist/components/media/Audio/Audio.js +45 -45
- package/dist/components/media/Audio/components/AudioCustomControls.cjs +1 -1
- package/dist/components/media/Audio/components/AudioCustomControls.js +113 -112
- package/dist/components/media/ImageCompare/ImageCompare.cjs +1 -1
- package/dist/components/media/ImageCompare/ImageCompare.js +73 -72
- package/dist/components/media/Video/Video.cjs +1 -1
- package/dist/components/media/Video/Video.js +36 -35
- package/dist/components/media/Video/components/VideoAdvancedMenu.cjs +1 -1
- package/dist/components/media/Video/components/VideoAdvancedMenu.js +138 -137
- package/dist/components/navigation/Tabs/tabs.module.cjs +1 -1
- package/dist/components/navigation/Tabs/tabs.module.js +1 -1
- package/dist/i18n/generated/keys.d.ts +1 -1
- package/dist/i18n/generated/resources.cjs +1 -1
- package/dist/i18n/generated/resources.js +192 -12
- package/dist/llms-full.txt +4 -4
- package/dist/llms.txt +1 -1
- package/dist/locales/en/common.json +53 -4
- package/dist/locales/en/components.json +3 -1
- package/dist/locales/ja/common.json +53 -4
- package/dist/locales/ja/components.json +3 -1
- package/dist/locales/pt/common.json +53 -4
- package/dist/locales/pt/components.json +3 -1
- package/dist/styles.css +2 -2
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +3 -3
- package/package.json +7 -7
|
@@ -1,145 +1,170 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
|
|
3
3
|
import { Portal as t } from "../../overlay/Portal/Portal.js";
|
|
4
|
-
import {
|
|
5
|
-
import r from "
|
|
6
|
-
import
|
|
7
|
-
import o from "
|
|
8
|
-
import
|
|
4
|
+
import { FocusTrap as n } from "../../overlay/FocusTrap/FocusTrap.js";
|
|
5
|
+
import { Button as r } from "../../form/Button/Button.js";
|
|
6
|
+
import i from "./tour.module.js";
|
|
7
|
+
import { useEffect as a, useId as o, useLayoutEffect as s, useRef as c, useState as l } from "react";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/feedback/Tour/Tour.tsx
|
|
10
|
-
var
|
|
11
|
-
function
|
|
11
|
+
var m = 16;
|
|
12
|
+
function h(e) {
|
|
12
13
|
let t = getComputedStyle(e);
|
|
13
14
|
return `${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;
|
|
14
15
|
}
|
|
15
|
-
async function
|
|
16
|
+
async function g(e) {
|
|
16
17
|
let t = document.fonts;
|
|
17
18
|
if (t && typeof t.load == "function") {
|
|
18
19
|
try {
|
|
19
|
-
await t.load(
|
|
20
|
+
await t.load(h(e));
|
|
20
21
|
} catch {}
|
|
21
22
|
for (; t.status === "loading";) await new Promise((e) => {
|
|
22
23
|
t.addEventListener("loadingdone", () => e(), { once: !0 });
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function _(e) {
|
|
27
28
|
let t = document.fonts;
|
|
28
|
-
return !t || typeof t.load != "function" ? !1 : t.status === "loading" || typeof t.check == "function" && !t.check(
|
|
29
|
+
return !t || typeof t.load != "function" ? !1 : t.status === "loading" || typeof t.check == "function" && !t.check(h(e));
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function v(e, t) {
|
|
31
32
|
return Math.round(e.top) === Math.round(t.top) && Math.round(e.left) === Math.round(t.left) && Math.round(e.width) === Math.round(t.width) && Math.round(e.height) === Math.round(t.height);
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
return e.top >=
|
|
34
|
+
function y(e) {
|
|
35
|
+
return e.top >= m && e.bottom <= window.innerHeight - m && e.left >= m && e.right <= window.innerWidth - m;
|
|
35
36
|
}
|
|
36
|
-
var
|
|
37
|
-
let { t:
|
|
38
|
-
|
|
39
|
-
if (!
|
|
40
|
-
|
|
37
|
+
var b = ({ steps: m, open: h, onClose: b, onFinish: x }) => {
|
|
38
|
+
let { t: S } = e("common"), [C, w] = l(0), [T, E] = l(null), D = m[C], O = D?.target;
|
|
39
|
+
s(() => {
|
|
40
|
+
if (!h || !O) {
|
|
41
|
+
E(null);
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
let e = !1, t = (t) => {
|
|
44
|
-
e ||
|
|
45
|
+
e || E((e) => t ? e && v(e, t) ? e : t : null);
|
|
45
46
|
}, n = () => {
|
|
46
|
-
let e = document.querySelector(
|
|
47
|
+
let e = document.querySelector(O);
|
|
47
48
|
if (!e) {
|
|
48
49
|
t(null);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
y(e.getBoundingClientRect()) || e.scrollIntoView({
|
|
52
53
|
block: "center",
|
|
53
54
|
inline: "nearest"
|
|
54
55
|
}), t(e.getBoundingClientRect());
|
|
55
56
|
}, r = () => {
|
|
56
|
-
let e = document.querySelector(
|
|
57
|
+
let e = document.querySelector(O);
|
|
57
58
|
t(e ? e.getBoundingClientRect() : null);
|
|
58
59
|
}, i = () => {
|
|
59
60
|
window.addEventListener("resize", r), window.addEventListener("scroll", r, !0);
|
|
60
61
|
}, a = async () => {
|
|
61
|
-
let t = document.querySelector(
|
|
62
|
-
t && await
|
|
63
|
-
}, o = document.querySelector(
|
|
64
|
-
return o &&
|
|
62
|
+
let t = document.querySelector(O);
|
|
63
|
+
t && await g(t), !e && (n(), i());
|
|
64
|
+
}, o = document.querySelector(O);
|
|
65
|
+
return o && _(o) ? a() : (n(), i()), () => {
|
|
65
66
|
e = !0, window.removeEventListener("resize", r), window.removeEventListener("scroll", r, !0);
|
|
66
67
|
};
|
|
67
68
|
}, [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
])
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
h,
|
|
70
|
+
C,
|
|
71
|
+
O
|
|
72
|
+
]);
|
|
73
|
+
let k = o(), A = c(null), j = c(null), M = h && !!D && !!T;
|
|
74
|
+
if (a(() => {
|
|
75
|
+
if (!M) return;
|
|
76
|
+
let e = A.current;
|
|
77
|
+
e && !e.contains(document.activeElement) && j.current?.focus();
|
|
78
|
+
}, [M, C]), a(() => {
|
|
79
|
+
if (!h) return;
|
|
80
|
+
let e = (e) => {
|
|
81
|
+
e.key === "Escape" && (e.preventDefault(), b());
|
|
82
|
+
};
|
|
83
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
84
|
+
}, [h, b]), !h || !D) return null;
|
|
85
|
+
let N = () => {
|
|
86
|
+
C < m.length - 1 ? w(C + 1) : (x ? x() : b(), w(0));
|
|
87
|
+
}, P = () => {
|
|
88
|
+
C > 0 && w(C - 1);
|
|
89
|
+
}, F = {}, I = D.placement || "bottom";
|
|
90
|
+
if (T) {
|
|
91
|
+
let e = window.innerWidth, t = Math.min(300, e - 32), n = I;
|
|
92
|
+
if (e < 640 && (n === "left" || n === "right") && (n = "bottom"), I = n, n === "top" || n === "bottom") {
|
|
93
|
+
let r = T.left + T.width / 2, i = t / 2 + 16, a = e - t / 2 - 16;
|
|
94
|
+
r = i > a ? e / 2 : Math.max(i, Math.min(a, r)), F.left = r, n === "top" ? (F.top = T.top - 12, F.transform = "translate(-50%, -100%)") : (F.top = T.bottom + 12, F.transform = "translateX(-50%)");
|
|
95
|
+
} else n === "left" ? (F.left = T.left - 12, F.top = T.top + T.height / 2, F.transform = "translate(-100%, -50%)") : n === "right" && (F.left = T.right + 12, F.top = T.top + T.height / 2, F.transform = "translateY(-50%)");
|
|
83
96
|
}
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
97
|
+
return /* @__PURE__ */ f(t, { children: /* @__PURE__ */ f(n, {
|
|
98
|
+
initialFocus: !1,
|
|
99
|
+
children: /* @__PURE__ */ p("div", {
|
|
100
|
+
role: "dialog",
|
|
101
|
+
"aria-modal": "true",
|
|
102
|
+
"aria-label": D.title,
|
|
103
|
+
"aria-describedby": T ? k : void 0,
|
|
104
|
+
children: [T && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
|
|
105
|
+
className: i.highlight,
|
|
106
|
+
style: {
|
|
107
|
+
top: T.top - 4,
|
|
108
|
+
left: T.left - 4,
|
|
109
|
+
width: T.width + 8,
|
|
110
|
+
height: T.height + 8
|
|
111
|
+
}
|
|
112
|
+
}), /* @__PURE__ */ f("div", {
|
|
113
|
+
ref: A,
|
|
114
|
+
className: u("wim-tour", i.bubble),
|
|
115
|
+
"data-placement": I,
|
|
116
|
+
style: F,
|
|
117
|
+
children: /* @__PURE__ */ p("div", {
|
|
118
|
+
className: i.inner,
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ f("h3", {
|
|
121
|
+
className: i.title,
|
|
122
|
+
children: D.title
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ f("p", {
|
|
125
|
+
id: k,
|
|
126
|
+
className: i.description,
|
|
127
|
+
children: D.description
|
|
128
|
+
}),
|
|
129
|
+
/* @__PURE__ */ p("div", {
|
|
130
|
+
className: i.footer,
|
|
131
|
+
children: [/* @__PURE__ */ p("span", {
|
|
132
|
+
className: i.progress,
|
|
133
|
+
children: [
|
|
134
|
+
C + 1,
|
|
135
|
+
" / ",
|
|
136
|
+
m.length
|
|
137
|
+
]
|
|
138
|
+
}), /* @__PURE__ */ p("div", {
|
|
139
|
+
className: i.buttons,
|
|
140
|
+
children: [C > 0 && /* @__PURE__ */ f(r, {
|
|
141
|
+
size: "sm",
|
|
142
|
+
variant: "outline",
|
|
143
|
+
onClick: P,
|
|
144
|
+
children: S("action.back")
|
|
145
|
+
}), /* @__PURE__ */ f(r, {
|
|
146
|
+
ref: j,
|
|
147
|
+
size: "sm",
|
|
148
|
+
variant: "solid",
|
|
149
|
+
onClick: N,
|
|
150
|
+
children: C === m.length - 1 ? S("action.finish") : S("action.next")
|
|
151
|
+
})]
|
|
152
|
+
})]
|
|
153
|
+
})
|
|
154
|
+
]
|
|
139
155
|
})
|
|
140
|
-
]
|
|
156
|
+
})] }), /* @__PURE__ */ f("div", {
|
|
157
|
+
className: i.mask,
|
|
158
|
+
onClick: b,
|
|
159
|
+
role: "button",
|
|
160
|
+
tabIndex: 0,
|
|
161
|
+
"aria-label": S("a11y.close_tour"),
|
|
162
|
+
onKeyDown: (e) => {
|
|
163
|
+
(e.key === "Enter" || e.key === " ") && b();
|
|
164
|
+
}
|
|
165
|
+
})]
|
|
141
166
|
})
|
|
142
|
-
})
|
|
167
|
+
}) });
|
|
143
168
|
};
|
|
144
169
|
//#endregion
|
|
145
|
-
export {
|
|
170
|
+
export { b as Tour };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_ssm81_37`,t=`_fullWidth_ssm81_51`,n=`_container_ssm81_54`,r=`_disabled_ssm81_64`,i=`_input_ssm81_67`,a=`_danger_ssm81_8`,o={root:e,fullWidth:t,container:n,disabled:r,input:i,danger:a};exports.container=n,exports.danger=a,exports.default=o,exports.disabled=r,exports.fullWidth=t,exports.input=i,exports.root=e;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/OtpInput/otp-input.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_ssm81_37", t = "_fullWidth_ssm81_51", n = "_container_ssm81_54", r = "_disabled_ssm81_64", i = "_input_ssm81_67", a = "_danger_ssm81_8", o = {
|
|
4
4
|
root: e,
|
|
5
5
|
fullWidth: t,
|
|
6
6
|
container: 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("../FieldTemplate/FieldTemplate.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("../../../utilities/slider-utils.cjs"),a=require("./range-slider.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=({value:e,defaultValue:l=[20,80],min:u=0,max:d=100,step:f=1,allowCross:p=!1,disabled:m=!1,onChange:h,onAfterChange:g,className:ee,name:_,label:v,error:y,required:te,layout:ne=`vertical`,id:re,"aria-label":b,"aria-labelledby":x,asChild:S=!1,children:C,...ie})=>{let{t:w}=n.useWimTranslation(`common`),T=e!==void 0,ae=(0,o.useId)(),E=re||ae,D=`wim-range-slider-label-${E}`,O=`wim-range-slider-error-${E}`,{clamp:k,calculateValue:A}=i.useSliderCommon(u,d,f),j=[k(l[0],u,d),k(l[1],u,d)];j[0]>j[1]&&j.sort((e,t)=>e-t);let[M,N]=(0,o.useState)(j),P=T?e:M,F=(0,o.useRef)(null),I=(0,o.useRef)(null),L=(0,o.useRef)(null),R=(0,o.useRef)(null),z=(0,o.useRef)(null),B=(0,o.useRef)(null),[V,H]=(0,o.useState)(null),U=(0,o.useRef)(null),W=(0,o.useRef)([...P]),G=(0,o.useCallback)(e=>(e-u)/(d-u)*100,[u,d]),K=(0,o.useCallback)(e=>{let t=G(e[0]),n=G(e[1]);I.current&&(I.current.style.left=`${t}%`,I.current.setAttribute(`aria-valuenow`,String(e[0])),I.current.setAttribute(`aria-valuemax`,String(e[1]))),L.current&&(L.current.style.left=`${n}%`,L.current.setAttribute(`aria-valuenow`,String(e[1])),L.current.setAttribute(`aria-valuemin`,String(e[0]))),R.current&&(R.current.style.left=`${t}%`,R.current.style.width=`${n-t}%`),z.current&&(z.current.value=String(e[0])),B.current&&(B.current.value=String(e[1]))},[G]);(0,o.useEffect)(()=>{V||K(P)},[P,V,K]);let q=(e,t)=>{m||(W.current=[...P],U.current=t,H(t),e.stopPropagation(),e.preventDefault())},J=e=>{if(m)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=A(t,F.current),r=Math.abs(P[0]-n),i=Math.abs(P[1]-n),a;a=r<i?`min`:i<r?`max`:n<P[0]?`min`:`max`,U.current=a,H(a);let o=[...W.current];a===`min`?o[0]=Math.min(n,p?d:o[1]):o[1]=Math.max(n,p?u:o[0]),W.current=o,K(o),h?.(o)},Y=(0,o.useCallback)(e=>{if(!U.current||m)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=A(t,F.current),r=[...W.current];U.current===`min`?r[0]=Math.min(n,p?d:r[1]):r[1]=Math.max(n,p?u:r[0]),W.current=r,K(r),h?.(r)},[m,h,p,A,u,d,K]),X=(0,o.useCallback)(()=>{if(U.current){U.current=null,H(null);let e=W.current;T||N([...e]),g?.(e)}},[T,g]);(0,o.useEffect)(()=>(document.addEventListener(`mousemove`,Y),document.addEventListener(`mouseup`,X),document.addEventListener(`touchmove`,Y,{passive:!1}),document.addEventListener(`touchend`,X),()=>{document.removeEventListener(`mousemove`,Y),document.removeEventListener(`mouseup`,X),document.removeEventListener(`touchmove`,Y),document.removeEventListener(`touchend`,X)}),[Y,X]);let Z=(e,t)=>{if(m)return;let n=[...P],r=t===`min`?n[0]:n[1],i;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)i=Math.max(u,r-f);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)i=Math.min(d,r+f);else if(e.key===`Home`)i=u;else if(e.key===`End`)i=d;else return;if(t===`min`){let e=p?d:n[1];n[0]=Math.min(i,e)}else{let e=p?u:n[0];n[1]=Math.max(i,e)}T||N(n),h?.(n),e.preventDefault()},Q=G(P[0]),$=G(P[1]);return(0,c.jsx)(r.FieldTemplate,{label:v,error:y,required:te,layout:ne,labelId:D,errorId:O,className:ee,children:(0,c.jsxs)(S?t.Root:`div`,{role:`presentation`,"data-testid":`range-slider-root`,className:(0,s.default)(`wim-range-slider`,a.default.root,m&&a.default.disabled,y&&a.default.danger),onMouseDown:J,onTouchStart:J,...ie,children:[(0,c.jsxs)(`div`,{className:a.default.trackContainer,ref:F,children:[(0,c.jsx)(`div`,{ref:R,className:a.default.track,style:{left:`${Q}%`,width:`${$-Q}%`}}),(0,c.jsx)(`div`,{ref:I,className:(0,s.default)(a.default.thumb,V===`min`&&a.default.active),style:{left:`${Q}%`},role:`slider`,"aria-valuemin":u,"aria-valuemax":P[1],"aria-valuenow":P[0],"aria-disabled":m,"aria-labelledby":v?D:x,"aria-label":v?w(`rangeSlider.start_of`,{label:v}):b||w(`rangeSlider.start`),"aria-describedby":y?O:void 0,"aria-invalid":y?!0:void 0,tabIndex:m?-1:0,onMouseDown:e=>q(e,`min`),onTouchStart:e=>q(e,`min`),onKeyDown:e=>Z(e,`min`)}),(0,c.jsx)(`div`,{ref:L,className:(0,s.default)(a.default.thumb,V===`max`&&a.default.active),style:{left:`${$}%`},role:`slider`,"aria-valuemin":P[0],"aria-valuemax":d,"aria-valuenow":P[1],"aria-disabled":m,"aria-labelledby":v?D:x,"aria-label":v?w(`rangeSlider.end_of`,{label:v}):b||w(`rangeSlider.end`),"aria-describedby":y?O:void 0,"aria-invalid":y?!0:void 0,tabIndex:m?-1:0,onMouseDown:e=>q(e,`max`),onTouchStart:e=>q(e,`max`),onKeyDown:e=>Z(e,`max`)})]}),(0,c.jsx)(`input`,{ref:z,type:`hidden`,name:_?`${_}-min`:``,value:P[0]}),(0,c.jsx)(`input`,{ref:B,type:`hidden`,name:_?`${_}-max`:``,value:P[1]}),(0,c.jsx)(t.Slottable,{children:C})]})})};l.displayName=`RangeSlider`,exports.RangeSlider=l;
|
|
@@ -1,156 +1,157 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import i from "
|
|
6
|
-
import
|
|
7
|
-
import l from "
|
|
8
|
-
import
|
|
3
|
+
import { useWimTranslation as n } from "../../../i18n/useWimTranslation.js";
|
|
4
|
+
import { FieldTemplate as r } from "../FieldTemplate/FieldTemplate.js";
|
|
5
|
+
import { useSliderCommon as i } from "../../../utilities/slider-utils.js";
|
|
6
|
+
import a from "./range-slider.module.js";
|
|
7
|
+
import { useCallback as o, useEffect as s, useId as ee, useRef as c, useState as l } from "react";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/form/RangeSlider/RangeSlider.tsx
|
|
10
|
-
var
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
let [le,
|
|
14
|
-
let t =
|
|
15
|
-
|
|
16
|
-
}, [
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
var p = ({ value: p, defaultValue: m = [20, 80], min: h = 0, max: g = 100, step: _ = 1, allowCross: v = !1, disabled: y = !1, onChange: b, onAfterChange: x, className: te, name: S, label: C, error: w, required: ne, layout: re = "vertical", id: ie, "aria-label": T, "aria-labelledby": E, asChild: ae = !1, children: oe, ...se }) => {
|
|
12
|
+
let { t: D } = n("common"), O = p !== void 0, ce = ee(), k = ie || ce, A = `wim-range-slider-label-${k}`, j = `wim-range-slider-error-${k}`, { clamp: M, calculateValue: N } = i(h, g, _), P = [M(m[0], h, g), M(m[1], h, g)];
|
|
13
|
+
P[0] > P[1] && P.sort((e, t) => e - t);
|
|
14
|
+
let [le, F] = l(P), I = O ? p : le, L = c(null), R = c(null), z = c(null), B = c(null), V = c(null), H = c(null), [U, W] = l(null), G = c(null), K = c([...I]), q = o((e) => (e - h) / (g - h) * 100, [h, g]), J = o((e) => {
|
|
15
|
+
let t = q(e[0]), n = q(e[1]);
|
|
16
|
+
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]));
|
|
17
|
+
}, [q]);
|
|
18
|
+
s(() => {
|
|
19
|
+
U || J(I);
|
|
19
20
|
}, [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
I,
|
|
22
|
+
U,
|
|
23
|
+
J
|
|
23
24
|
]);
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
if (
|
|
28
|
-
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n =
|
|
29
|
-
a = r < i ? "min" : i < r ? "max" : n <
|
|
30
|
-
let o = [...
|
|
31
|
-
a === "min" ? o[0] = Math.min(n,
|
|
32
|
-
},
|
|
33
|
-
if (!
|
|
34
|
-
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n =
|
|
35
|
-
|
|
25
|
+
let Y = (e, t) => {
|
|
26
|
+
y || (K.current = [...I], G.current = t, W(t), e.stopPropagation(), e.preventDefault());
|
|
27
|
+
}, X = (e) => {
|
|
28
|
+
if (y) return;
|
|
29
|
+
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;
|
|
30
|
+
a = r < i ? "min" : i < r ? "max" : n < I[0] ? "min" : "max", G.current = a, W(a);
|
|
31
|
+
let o = [...K.current];
|
|
32
|
+
a === "min" ? o[0] = Math.min(n, v ? g : o[1]) : o[1] = Math.max(n, v ? h : o[0]), K.current = o, J(o), b?.(o);
|
|
33
|
+
}, Z = o((e) => {
|
|
34
|
+
if (!G.current || y) return;
|
|
35
|
+
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = N(t, L.current), r = [...K.current];
|
|
36
|
+
G.current === "min" ? r[0] = Math.min(n, v ? g : r[1]) : r[1] = Math.max(n, v ? h : r[0]), K.current = r, J(r), b?.(r);
|
|
36
37
|
}, [
|
|
37
|
-
v,
|
|
38
38
|
y,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
b,
|
|
40
|
+
v,
|
|
41
|
+
N,
|
|
42
42
|
h,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
g,
|
|
44
|
+
J
|
|
45
|
+
]), Q = o(() => {
|
|
46
|
+
if (G.current) {
|
|
47
|
+
G.current = null, W(null);
|
|
48
|
+
let e = K.current;
|
|
49
|
+
O || F([...e]), x?.(e);
|
|
49
50
|
}
|
|
50
|
-
}, [
|
|
51
|
-
|
|
52
|
-
document.removeEventListener("mousemove",
|
|
53
|
-
}), [
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
56
|
-
let n = [...
|
|
57
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowDown") i = Math.max(
|
|
58
|
-
else if (e.key === "ArrowRight" || e.key === "ArrowUp") i = Math.min(
|
|
59
|
-
else if (e.key === "Home") i =
|
|
60
|
-
else if (e.key === "End") i =
|
|
51
|
+
}, [O, x]);
|
|
52
|
+
s(() => (document.addEventListener("mousemove", Z), document.addEventListener("mouseup", Q), document.addEventListener("touchmove", Z, { passive: !1 }), document.addEventListener("touchend", Q), () => {
|
|
53
|
+
document.removeEventListener("mousemove", Z), document.removeEventListener("mouseup", Q), document.removeEventListener("touchmove", Z), document.removeEventListener("touchend", Q);
|
|
54
|
+
}), [Z, Q]);
|
|
55
|
+
let ue = (e, t) => {
|
|
56
|
+
if (y) return;
|
|
57
|
+
let n = [...I], r = t === "min" ? n[0] : n[1], i;
|
|
58
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") i = Math.max(h, r - _);
|
|
59
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") i = Math.min(g, r + _);
|
|
60
|
+
else if (e.key === "Home") i = h;
|
|
61
|
+
else if (e.key === "End") i = g;
|
|
61
62
|
else return;
|
|
62
63
|
if (t === "min") {
|
|
63
|
-
let e =
|
|
64
|
+
let e = v ? g : n[1];
|
|
64
65
|
n[0] = Math.min(i, e);
|
|
65
66
|
} else {
|
|
66
|
-
let e =
|
|
67
|
+
let e = v ? h : n[0];
|
|
67
68
|
n[1] = Math.max(i, e);
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
label:
|
|
73
|
-
error:
|
|
70
|
+
O || F(n), b?.(n), e.preventDefault();
|
|
71
|
+
}, $ = q(I[0]), de = q(I[1]);
|
|
72
|
+
return /* @__PURE__ */ d(r, {
|
|
73
|
+
label: C,
|
|
74
|
+
error: w,
|
|
74
75
|
required: ne,
|
|
75
76
|
layout: re,
|
|
76
|
-
labelId:
|
|
77
|
-
errorId:
|
|
77
|
+
labelId: A,
|
|
78
|
+
errorId: j,
|
|
78
79
|
className: te,
|
|
79
|
-
children: /* @__PURE__ */
|
|
80
|
+
children: /* @__PURE__ */ f(ae ? e : "div", {
|
|
80
81
|
role: "presentation",
|
|
81
82
|
"data-testid": "range-slider-root",
|
|
82
|
-
className:
|
|
83
|
-
onMouseDown:
|
|
84
|
-
onTouchStart:
|
|
83
|
+
className: u("wim-range-slider", a.root, y && a.disabled, w && a.danger),
|
|
84
|
+
onMouseDown: X,
|
|
85
|
+
onTouchStart: X,
|
|
85
86
|
...se,
|
|
86
87
|
children: [
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
className:
|
|
89
|
-
ref:
|
|
88
|
+
/* @__PURE__ */ f("div", {
|
|
89
|
+
className: a.trackContainer,
|
|
90
|
+
ref: L,
|
|
90
91
|
children: [
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
ref:
|
|
93
|
-
className:
|
|
92
|
+
/* @__PURE__ */ d("div", {
|
|
93
|
+
ref: B,
|
|
94
|
+
className: a.track,
|
|
94
95
|
style: {
|
|
95
|
-
left: `${
|
|
96
|
-
width: `${
|
|
96
|
+
left: `${$}%`,
|
|
97
|
+
width: `${de - $}%`
|
|
97
98
|
}
|
|
98
99
|
}),
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
ref:
|
|
101
|
-
className:
|
|
102
|
-
style: { left: `${
|
|
100
|
+
/* @__PURE__ */ d("div", {
|
|
101
|
+
ref: R,
|
|
102
|
+
className: u(a.thumb, U === "min" && a.active),
|
|
103
|
+
style: { left: `${$}%` },
|
|
103
104
|
role: "slider",
|
|
104
|
-
"aria-valuemin":
|
|
105
|
-
"aria-valuemax":
|
|
106
|
-
"aria-valuenow":
|
|
107
|
-
"aria-disabled":
|
|
108
|
-
"aria-labelledby":
|
|
109
|
-
"aria-label":
|
|
110
|
-
"aria-describedby":
|
|
111
|
-
"aria-invalid":
|
|
112
|
-
tabIndex:
|
|
113
|
-
onMouseDown: (e) =>
|
|
114
|
-
onTouchStart: (e) =>
|
|
115
|
-
onKeyDown: (e) =>
|
|
105
|
+
"aria-valuemin": h,
|
|
106
|
+
"aria-valuemax": I[1],
|
|
107
|
+
"aria-valuenow": I[0],
|
|
108
|
+
"aria-disabled": y,
|
|
109
|
+
"aria-labelledby": C ? A : E,
|
|
110
|
+
"aria-label": C ? D("rangeSlider.start_of", { label: C }) : T || D("rangeSlider.start"),
|
|
111
|
+
"aria-describedby": w ? j : void 0,
|
|
112
|
+
"aria-invalid": w ? !0 : void 0,
|
|
113
|
+
tabIndex: y ? -1 : 0,
|
|
114
|
+
onMouseDown: (e) => Y(e, "min"),
|
|
115
|
+
onTouchStart: (e) => Y(e, "min"),
|
|
116
|
+
onKeyDown: (e) => ue(e, "min")
|
|
116
117
|
}),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
ref:
|
|
119
|
-
className:
|
|
120
|
-
style: { left: `${
|
|
118
|
+
/* @__PURE__ */ d("div", {
|
|
119
|
+
ref: z,
|
|
120
|
+
className: u(a.thumb, U === "max" && a.active),
|
|
121
|
+
style: { left: `${de}%` },
|
|
121
122
|
role: "slider",
|
|
122
|
-
"aria-valuemin":
|
|
123
|
-
"aria-valuemax":
|
|
124
|
-
"aria-valuenow":
|
|
125
|
-
"aria-disabled":
|
|
126
|
-
"aria-labelledby":
|
|
127
|
-
"aria-label":
|
|
128
|
-
"aria-describedby":
|
|
129
|
-
"aria-invalid":
|
|
130
|
-
tabIndex:
|
|
131
|
-
onMouseDown: (e) =>
|
|
132
|
-
onTouchStart: (e) =>
|
|
133
|
-
onKeyDown: (e) =>
|
|
123
|
+
"aria-valuemin": I[0],
|
|
124
|
+
"aria-valuemax": g,
|
|
125
|
+
"aria-valuenow": I[1],
|
|
126
|
+
"aria-disabled": y,
|
|
127
|
+
"aria-labelledby": C ? A : E,
|
|
128
|
+
"aria-label": C ? D("rangeSlider.end_of", { label: C }) : T || D("rangeSlider.end"),
|
|
129
|
+
"aria-describedby": w ? j : void 0,
|
|
130
|
+
"aria-invalid": w ? !0 : void 0,
|
|
131
|
+
tabIndex: y ? -1 : 0,
|
|
132
|
+
onMouseDown: (e) => Y(e, "max"),
|
|
133
|
+
onTouchStart: (e) => Y(e, "max"),
|
|
134
|
+
onKeyDown: (e) => ue(e, "max")
|
|
134
135
|
})
|
|
135
136
|
]
|
|
136
137
|
}),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
ref:
|
|
138
|
+
/* @__PURE__ */ d("input", {
|
|
139
|
+
ref: V,
|
|
139
140
|
type: "hidden",
|
|
140
|
-
name:
|
|
141
|
-
value:
|
|
141
|
+
name: S ? `${S}-min` : "",
|
|
142
|
+
value: I[0]
|
|
142
143
|
}),
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
ref:
|
|
144
|
+
/* @__PURE__ */ d("input", {
|
|
145
|
+
ref: H,
|
|
145
146
|
type: "hidden",
|
|
146
|
-
name:
|
|
147
|
-
value:
|
|
147
|
+
name: S ? `${S}-max` : "",
|
|
148
|
+
value: I[1]
|
|
148
149
|
}),
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ d(t, { children: oe })
|
|
150
151
|
]
|
|
151
152
|
})
|
|
152
153
|
});
|
|
153
154
|
};
|
|
154
|
-
|
|
155
|
+
p.displayName = "RangeSlider";
|
|
155
156
|
//#endregion
|
|
156
|
-
export {
|
|
157
|
+
export { p as RangeSlider };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_1brr1_23`,t=`_disabled_1brr1_32`,n=`_thumb_1brr1_36`,r=`_danger_1brr1_39`,i=`_track_1brr1_39`,a=`_trackContainer_1brr1_51`,o=`_active_1brr1_83`,s={root:e,disabled:t,thumb:n,danger:r,track:i,trackContainer:a,active:o};exports.active=o,exports.danger=r,exports.default=s,exports.disabled=t,exports.root=e,exports.thumb=n,exports.track=i,exports.trackContainer=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/RangeSlider/range-slider.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_1brr1_23", t = "_disabled_1brr1_32", n = "_thumb_1brr1_36", r = "_danger_1brr1_39", i = "_track_1brr1_39", a = "_trackContainer_1brr1_51", o = "_active_1brr1_83", s = {
|
|
4
4
|
root: e,
|
|
5
5
|
disabled: t,
|
|
6
6
|
thumb: n,
|