wimui 0.76.0 → 0.76.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/form/Combobox/Combobox.cjs +1 -1
- package/dist/components/form/Combobox/Combobox.js +1 -0
- package/dist/components/form/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.js +113 -111
- package/dist/components/form/Slider/Slider.cjs +1 -1
- package/dist/components/form/Slider/Slider.js +77 -75
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/utilities/slider-utils.cjs +1 -1
- package/dist/utilities/slider-utils.d.ts +5 -0
- package/dist/utilities/slider-utils.js +2 -2
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../_internal/useInlineFloating.cjs"),r=require("../../_internal/BaseListItem/BaseListItem.cjs"),i=require("../InputBase/InputBase.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("../../_internal/useAnnounce.cjs"),s=require("./combobox.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=({options:e=[],onChange:d,placeholder:f,showSearchIcon:p=!0,allowClear:m=!0,defaultValue:h=``,className:g,disabled:_=!1,label:v,error:y,required:b,layout:x,fullWidth:S=!1,id:C,labels:w={},...T})=>{let{noResults:E=`No results found`}=w,[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(h),[j,M]=(0,c.useState)(-1),[N,P]=(0,c.useState)(!1),F=(0,c.useRef)(null),I=(0,c.useId)(),L=C||`wim-combobox-${I}`,R=`${L}-list`,z=v?`${L}-label`:void 0,B=y?`${L}-error`:void 0,V=(0,c.useMemo)(()=>{let t=(k||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,k]);(0,c.useEffect)(()=>{let e=e=>{F.current&&!F.current.contains(e.target)&&O(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let H=e=>{let t=e.target.value;A(t),O(!0),M(-1)},U=e=>{A(e.label),O(!1),d&&d(e)},W=e=>{if(P(!0),!D&&e.key===`ArrowDown`)O(!0);else switch(e.key){case`ArrowDown`:M(e=>e<V.length-1?e+1:0);break;case`ArrowUp`:M(e=>e<=0?V.length-1:e-1);break;case`Enter`:j>=0&&j<V.length&&U(V[j]);break;case`Escape`:D&&e.preventDefault(),O(!1);break;case`Tab`:O(!1)}},{setReference:G,setFloating:K,floatingProps:q}=n.useInlineFloating({open:D}),J=t.useMergedRef(F,G),Y=D&&V.length===0,{ref:X,region:Z}=o.useAnnounceAppearance(Y);return(0,u.jsx)(a.FieldTemplate,{label:v,error:y,required:b,layout:x,labelId:z,htmlFor:L,errorId:B,className:g,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`wim-combobox`,s.default.root,S&&s.default.fullWidth),ref:J,onMouseMove:()=>P(!1),"data-keyboard-nav":N,children:[Z,(0,u.jsx)(i.InputBase,{disabled:_,allowClear:m,hasValue:!!k,onClear:()=>A(``),intent:y?`danger`:`default`,leftIcon:p?`SearchIcon`:void 0,fullWidth:S,rightIcons:[{name:`ChevronDownIcon`,rotated:D,onClick:()=>O(!D),decorative:!0}],children:(0,u.jsx)(`input`,{id:L,className:s.default.input,placeholder:f,value:k,onChange:H,onKeyDown:W,onFocus:()=>O(!0),disabled:_,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":D,"aria-controls":D?R:void 0,"aria-labelledby":z,"aria-describedby":B,required:b,"aria-invalid":!!y,"aria-activedescendant":D&&j>=0?`${R}-option-${j}`:void 0,...T})}),D&&V.length>0&&(0,u.jsx)(`div`,{className:s.default.dropdown,ref:K,...q,children:(0,u.jsx)(`ul`,{id:R,className:s.default.list,role:`listbox`,"aria-labelledby":z,children:V.map((e,t)=>(0,u.jsx)(r.BaseListItem,{asChild:!0,id:`${R}-option-${t}`,className:(0,l.default)(s.default.option,t===j&&s.default.selected),active:t===j,onClick:()=>U(e),onMouseEnter:()=>M(t),role:`option`,"aria-selected":t===j,children:(0,u.jsx)(`li`,{children:e.label})},e.value))})}),Y&&(0,u.jsx)(`div`,{className:s.default.dropdown,ref:K,...q,children:(0,u.jsx)(`div`,{className:s.default.empty,ref:X,children:E})})]})})};d.displayName=`Combobox`,exports.Combobox=d;
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../_internal/useInlineFloating.cjs"),r=require("../../_internal/BaseListItem/BaseListItem.cjs"),i=require("../InputBase/InputBase.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("../../_internal/useAnnounce.cjs"),s=require("./combobox.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=({options:e=[],onChange:d,placeholder:f,showSearchIcon:p=!0,allowClear:m=!0,defaultValue:h=``,className:g,disabled:_=!1,label:v,error:y,required:b,layout:x,fullWidth:S=!1,id:C,labels:w={},...T})=>{let{noResults:E=`No results found`}=w,[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(h),[j,M]=(0,c.useState)(-1),[N,P]=(0,c.useState)(!1),F=(0,c.useRef)(null),I=(0,c.useId)(),L=C||`wim-combobox-${I}`,R=`${L}-list`,z=v?`${L}-label`:void 0,B=y?`${L}-error`:void 0,V=(0,c.useMemo)(()=>{let t=(k||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,k]);(0,c.useEffect)(()=>{let e=e=>{F.current&&!F.current.contains(e.target)&&O(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let H=e=>{let t=e.target.value;A(t),O(!0),M(-1)},U=e=>{A(e.label),O(!1),d&&d(e)},W=e=>{if(P(!0),!D&&e.key===`ArrowDown`)O(!0);else switch(e.key){case`ArrowDown`:M(e=>e<V.length-1?e+1:0);break;case`ArrowUp`:M(e=>e<=0?V.length-1:e-1);break;case`Enter`:j>=0&&j<V.length&&U(V[j]);break;case`Escape`:D&&e.preventDefault(),O(!1);break;case`Tab`:O(!1)}},{setReference:G,setFloating:K,floatingProps:q}=n.useInlineFloating({open:D}),J=t.useMergedRef(F,G),Y=D&&V.length===0,{ref:X,region:Z}=o.useAnnounceAppearance(Y);return(0,u.jsx)(a.FieldTemplate,{label:v,error:y,required:b,layout:x,labelId:z,htmlFor:L,errorId:B,className:g,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`wim-combobox`,s.default.root,S&&s.default.fullWidth),ref:J,onMouseMove:()=>P(!1),"data-keyboard-nav":N,children:[Z,(0,u.jsx)(i.InputBase,{disabled:_,allowClear:m,hasValue:!!k,onClear:()=>A(``),intent:y?`danger`:`default`,leftIcon:p?`SearchIcon`:void 0,fullWidth:S,rightIcons:[{name:`ChevronDownIcon`,rotated:D,onClick:()=>O(!D),decorative:!0}],children:(0,u.jsx)(`input`,{id:L,className:s.default.input,placeholder:f,value:k,onChange:H,onKeyDown:W,onFocus:()=>O(!0),disabled:_,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":D,"aria-controls":D?R:void 0,"aria-labelledby":z,"aria-describedby":B,required:b,"aria-invalid":!!y,"aria-activedescendant":D&&j>=0?`${R}-option-${j}`:void 0,...T})}),D&&V.length>0&&(0,u.jsx)(`div`,{className:s.default.dropdown,ref:K,...q,children:(0,u.jsx)(`ul`,{id:R,className:s.default.list,role:`listbox`,"aria-labelledby":z,onMouseDown:e=>e.preventDefault(),children:V.map((e,t)=>(0,u.jsx)(r.BaseListItem,{asChild:!0,id:`${R}-option-${t}`,className:(0,l.default)(s.default.option,t===j&&s.default.selected),active:t===j,onClick:()=>U(e),onMouseEnter:()=>M(t),role:`option`,"aria-selected":t===j,children:(0,u.jsx)(`li`,{children:e.label})},e.value))})}),Y&&(0,u.jsx)(`div`,{className:s.default.dropdown,ref:K,...q,children:(0,u.jsx)(`div`,{className:s.default.empty,ref:X,children:E})})]})})};d.displayName=`Combobox`,exports.Combobox=d;
|
|
@@ -105,6 +105,7 @@ var h = ({ options: h = [], onChange: g, placeholder: _, showSearchIcon: v = !0,
|
|
|
105
105
|
className: o.list,
|
|
106
106
|
role: "listbox",
|
|
107
107
|
"aria-labelledby": U,
|
|
108
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
108
109
|
children: G.map((e, t) => /* @__PURE__ */ p(n, {
|
|
109
110
|
asChild: !0,
|
|
110
111
|
id: `${H}-option-${t}`,
|
|
@@ -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("../../_internal/composeEventHandlers.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("../../../utilities/slider-utils.cjs"),s=require("./range-slider.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=({value:e,defaultValue:d=[20,80],min:f=0,max:p=100,step:m=1,allowCross:h=!1,disabled:g=!1,onChange:_,onAfterChange:v,className:ee,name:y,label:b,error:x,required:te,layout:ne=`vertical`,id:re,"aria-label":ie,"aria-labelledby":ae,"aria-describedby":oe,asChild:se=!1,children:ce,...S})=>{let{t:C}=n.useWimTranslation(r.commonNs),w=e!==void 0,le=(0,c.useId)(),T=re||le,ue=`wim-range-slider-label-${T}`,E=`wim-range-slider-error-${T}`,D=[oe,x?E:void 0].filter(Boolean).join(` `)||void 0,O=b||ie,k=`wim-range-slider-start-${T}`,A=`wim-range-slider-end-${T}`,j=e=>!O&&ae?`${ae} ${e}`:void 0,{clamp:M,calculateValue:N}=o.useSliderCommon(f,p,m),P=[M(d[0],f,p),M(d[1],f,p)];P[0]>P[1]&&P.sort((e,t)=>e-t);let[de,F]=(0,c.useState)(P),I=w?e:de,L=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(null),B=(0,c.useRef)(null),V=(0,c.useRef)(null),H=(0,c.useRef)(null),[U,W]=(0,c.useState)(null),G=(0,c.useRef)(null),K=(0,c.useRef)([...I]),q=(0,c.useCallback)(e=>(e-f)/(p-f)*100,[f,p]),J=(0,c.useCallback)(e=>{let t=q(e[0]),n=q(e[1]);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]))},[q]);(0,c.useEffect)(()=>{U||J(I)},[I,U,J]);let Y=(e,t)=>{g||(K.current=[...I],G.current=t,W(t),e.stopPropagation(),e.preventDefault())},X=e=>{if(g)return;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;a=r<i?`min`:i<r?`max`:n<I[0]?`min`:`max`,G.current=a,W(a);let o=[...K.current];a===`min`?o[0]=Math.min(n,h?p:o[1]):o[1]=Math.max(n,h?f:o[0]),K.current=o,J(o),_?.(o)},Z=(0,c.useCallback)(e=>{if(!G.current||g)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=N(t,L.current),r=[...K.current];G.current===`min`?r[0]=Math.min(n,h?p:r[1]):r[1]=Math.max(n,h?f:r[0]),K.current=r,J(r),_?.(r)},[g,_,h,N,f,p,J]),Q=(0,c.useCallback)(()=>{if(G.current){G.current=null,W(null);let e=K.current;w||F([...e]),v?.(e)}},[w,v]);(0,c.useEffect)(()=>(document.addEventListener(`mousemove`,Z),document.addEventListener(`mouseup`,Q),document.addEventListener(`touchmove`,Z,{passive:!1}),document.addEventListener(`touchend`,Q),()=>{document.removeEventListener(`mousemove`,Z),document.removeEventListener(`mouseup`,Q),document.removeEventListener(`touchmove`,Z),document.removeEventListener(`touchend`,Q)}),[Z,Q]);let fe=(e,t)=>{if(g)return;let n=[...I],r=t===`min`?n[0]:n[1],i;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)i=Math.max(f,r-m);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)i=Math.min(p,r+m);else if(e.key===`Home`)i=f;else if(e.key===`End`)i=p;else return;if(t===`min`){let e=h?p:n[1];n[0]=Math.min(i,e)}else{let e=h?f:n[0];n[1]=Math.max(i,e)}w||F(n),_?.(n),e.preventDefault()},$=q(I[0]),pe=q(I[1]);return(0,u.jsx)(a.FieldTemplate,{label:b,error:x,required:te,layout:ne,labelId:ue,errorId:E,className:ee,children:(0,u.jsxs)(se?t.Root:`div`,{role:`presentation`,"data-testid":`range-slider-root`,className:(0,l.default)(`wim-range-slider`,s.default.root,g&&s.default.disabled,x&&s.default.danger),...S,onMouseDown:e=>i.composeEventHandlers(S.onMouseDown,X)(e),onTouchStart:e=>i.composeEventHandlers(S.onTouchStart,X)(e),children:[(0,u.jsxs)(`div`,{className:s.default.trackContainer,ref:L,children:[(0,u.jsx)(`div`,{ref:B,className:s.default.track,style:{left:`${$}%`,width:`${pe-$}%`}}),(0,u.jsx)(`div`,{ref:R,className:(0,l.default)(s.default.thumb,U===`min`&&s.default.active),style:{left:`${$}%`},role:`slider`,"aria-valuemin":f,"aria-valuemax":I[1],"aria-valuenow":I[0],"aria-disabled":g,id:k,"aria-labelledby":j(k),"aria-label":O?C(`rangeSlider.start_of`,{label:O}):C(`rangeSlider.start`),"aria-describedby":D,"aria-invalid":x?!0:void 0,tabIndex:g?-1:0,onMouseDown:e=>Y(e,`min`),onTouchStart:e=>Y(e,`min`),onKeyDown:e=>fe(e,`min`)}),(0,u.jsx)(`div`,{ref:z,className:(0,l.default)(s.default.thumb,U===`max`&&s.default.active),style:{left:`${pe}%`},role:`slider`,"aria-valuemin":I[0],"aria-valuemax":p,"aria-valuenow":I[1],"aria-disabled":g,id:A,"aria-labelledby":j(A),"aria-label":O?C(`rangeSlider.end_of`,{label:O}):C(`rangeSlider.end`),"aria-describedby":D,"aria-invalid":x?!0:void 0,tabIndex:g?-1:0,onMouseDown:e=>Y(e,`max`),onTouchStart:e=>Y(e,`max`),onKeyDown:e=>fe(e,`max`)})]}),(0,u.jsx)(`input`,{ref:V,type:`hidden`,name:y?`${y}-min`:``,value:I[0]}),(0,u.jsx)(`input`,{ref:H,type:`hidden`,name:y?`${y}-max`:``,value:I[1]}),(0,u.jsx)(t.Slottable,{children:ce})]})})};d.displayName=`RangeSlider`,exports.RangeSlider=d;
|
|
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("../../_internal/composeEventHandlers.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("../../../utilities/slider-utils.cjs"),s=require("./range-slider.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=({value:e,defaultValue:d=[20,80],min:f=0,max:p=100,step:m=1,allowCross:h=!1,disabled:g=!1,onChange:_,onAfterChange:v,className:ee,name:y,label:b,error:x,required:te,layout:ne=`vertical`,id:re,"aria-label":ie,"aria-labelledby":ae,"aria-describedby":oe,asChild:se=!1,children:ce,...S})=>{let{t:C}=n.useWimTranslation(r.commonNs),w=e!==void 0,le=(0,c.useId)(),T=re||le,ue=`wim-range-slider-label-${T}`,E=`wim-range-slider-error-${T}`,D=[oe,x?E:void 0].filter(Boolean).join(` `)||void 0,O=b||ie,k=`wim-range-slider-start-${T}`,A=`wim-range-slider-end-${T}`,j=e=>!O&&ae?`${ae} ${e}`:void 0,{clamp:M,calculateValue:N}=o.useSliderCommon(f,p,m),P=[M(d[0],f,p),M(d[1],f,p)];P[0]>P[1]&&P.sort((e,t)=>e-t);let[de,F]=(0,c.useState)(P),I=w?e:de,L=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(null),B=(0,c.useRef)(null),V=(0,c.useRef)(null),H=(0,c.useRef)(null),[U,W]=(0,c.useState)(null),G=(0,c.useRef)(null),K=(0,c.useRef)([...I]),q=(0,c.useCallback)(e=>(e-f)/(p-f)*100,[f,p]),J=(0,c.useCallback)(e=>{let t=q(e[0]),n=q(e[1]);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]))},[q]);(0,c.useEffect)(()=>{U||J(I)},[I,U,J]);let Y=(e,t)=>{g||(K.current=[...I],G.current=t,W(t),e.stopPropagation(),e.preventDefault())},X=e=>{if(g)return;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;a=r<i?`min`:i<r?`max`:n<I[0]?`min`:`max`,G.current=a,W(a);let o=[...K.current];a===`min`?o[0]=Math.min(n,h?p:o[1]):o[1]=Math.max(n,h?f:o[0]),K.current=o,J(o),_?.(o)},Z=(0,c.useCallback)(e=>{if(!G.current||g)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=N(t,L.current),r=[...K.current];G.current===`min`?r[0]=Math.min(n,h?p:r[1]):r[1]=Math.max(n,h?f:r[0]),K.current=r,J(r),_?.(r)},[g,_,h,N,f,p,J]),Q=(0,c.useCallback)(()=>{if(G.current){G.current=null,W(null);let e=K.current;w||F([...e]),v?.(e)}},[w,v]);(0,c.useEffect)(()=>(document.addEventListener(`mousemove`,Z),document.addEventListener(`mouseup`,Q),document.addEventListener(`touchmove`,Z,{passive:!1}),document.addEventListener(`touchend`,Q),()=>{document.removeEventListener(`mousemove`,Z),document.removeEventListener(`mouseup`,Q),document.removeEventListener(`touchmove`,Z),document.removeEventListener(`touchend`,Q)}),[Z,Q]);let fe=(e,t)=>{if(g)return;let n=[...I],r=t===`min`?n[0]:n[1],i;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)i=Math.max(f,r-m);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)i=Math.min(p,r+m);else if(e.key===`PageDown`)i=Math.max(f,r-o.largeStepOf(f,p,m));else if(e.key===`PageUp`)i=Math.min(p,r+o.largeStepOf(f,p,m));else if(e.key===`Home`)i=f;else if(e.key===`End`)i=p;else return;if(t===`min`){let e=h?p:n[1];n[0]=Math.min(i,e)}else{let e=h?f:n[0];n[1]=Math.max(i,e)}w||F(n),_?.(n),e.preventDefault()},$=q(I[0]),pe=q(I[1]);return(0,u.jsx)(a.FieldTemplate,{label:b,error:x,required:te,layout:ne,labelId:ue,errorId:E,className:ee,children:(0,u.jsxs)(se?t.Root:`div`,{role:`presentation`,"data-testid":`range-slider-root`,className:(0,l.default)(`wim-range-slider`,s.default.root,g&&s.default.disabled,x&&s.default.danger),...S,onMouseDown:e=>i.composeEventHandlers(S.onMouseDown,X)(e),onTouchStart:e=>i.composeEventHandlers(S.onTouchStart,X)(e),children:[(0,u.jsxs)(`div`,{className:s.default.trackContainer,ref:L,children:[(0,u.jsx)(`div`,{ref:B,className:s.default.track,style:{left:`${$}%`,width:`${pe-$}%`}}),(0,u.jsx)(`div`,{ref:R,className:(0,l.default)(s.default.thumb,U===`min`&&s.default.active),style:{left:`${$}%`},role:`slider`,"aria-valuemin":f,"aria-valuemax":I[1],"aria-valuenow":I[0],"aria-disabled":g,id:k,"aria-labelledby":j(k),"aria-label":O?C(`rangeSlider.start_of`,{label:O}):C(`rangeSlider.start`),"aria-describedby":D,"aria-invalid":x?!0:void 0,tabIndex:g?-1:0,onMouseDown:e=>Y(e,`min`),onTouchStart:e=>Y(e,`min`),onKeyDown:e=>fe(e,`min`)}),(0,u.jsx)(`div`,{ref:z,className:(0,l.default)(s.default.thumb,U===`max`&&s.default.active),style:{left:`${pe}%`},role:`slider`,"aria-valuemin":I[0],"aria-valuemax":p,"aria-valuenow":I[1],"aria-disabled":g,id:A,"aria-labelledby":j(A),"aria-label":O?C(`rangeSlider.end_of`,{label:O}):C(`rangeSlider.end`),"aria-describedby":D,"aria-invalid":x?!0:void 0,tabIndex:g?-1:0,onMouseDown:e=>Y(e,`max`),onTouchStart:e=>Y(e,`max`),onKeyDown:e=>fe(e,`max`)})]}),(0,u.jsx)(`input`,{ref:V,type:`hidden`,name:y?`${y}-min`:``,value:I[0]}),(0,u.jsx)(`input`,{ref:H,type:`hidden`,name:y?`${y}-max`:``,value:I[1]}),(0,u.jsx)(t.Slottable,{children:ce})]})})};d.displayName=`RangeSlider`,exports.RangeSlider=d;
|
|
@@ -4,158 +4,160 @@ import { useWimTranslation as n } from "../../../i18n/useWimTranslation.js";
|
|
|
4
4
|
import { commonNs as r } from "../../../i18n/generated/common.js";
|
|
5
5
|
import { composeEventHandlers as i } from "../../_internal/composeEventHandlers.js";
|
|
6
6
|
import { FieldTemplate as a } from "../FieldTemplate/FieldTemplate.js";
|
|
7
|
-
import {
|
|
7
|
+
import { largeStepOf as o, useSliderCommon as ee } from "../../../utilities/slider-utils.js";
|
|
8
8
|
import s from "./range-slider.module.js";
|
|
9
|
-
import { useCallback as c, useEffect as
|
|
10
|
-
import
|
|
11
|
-
import { jsx as
|
|
9
|
+
import { useCallback as c, useEffect as te, useId as ne, useRef as l, useState as u } from "react";
|
|
10
|
+
import d from "classnames";
|
|
11
|
+
import { jsx as f, jsxs as re } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/form/RangeSlider/RangeSlider.tsx
|
|
13
|
-
var
|
|
14
|
-
let { t:
|
|
15
|
-
|
|
16
|
-
let [
|
|
17
|
-
let t =
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
var p = ({ value: p, defaultValue: ie = [20, 80], min: m = 0, max: h = 100, step: g = 1, allowCross: _ = !1, disabled: v = !1, onChange: y, onAfterChange: ae, className: oe, name: b, label: x, error: S, required: se, layout: ce = "vertical", id: le, "aria-label": ue, "aria-labelledby": C, "aria-describedby": de, asChild: fe = !1, children: pe, ...w }) => {
|
|
14
|
+
let { t: T } = n(r), E = p !== void 0, me = ne(), D = le || me, he = `wim-range-slider-label-${D}`, ge = `wim-range-slider-error-${D}`, _e = [de, S ? ge : void 0].filter(Boolean).join(" ") || void 0, O = x || ue, k = `wim-range-slider-start-${D}`, A = `wim-range-slider-end-${D}`, j = (e) => !O && C ? `${C} ${e}` : void 0, { clamp: M, calculateValue: N } = ee(m, h, g), P = [M(ie[0], m, h), M(ie[1], m, h)];
|
|
15
|
+
P[0] > P[1] && P.sort((e, t) => e - t);
|
|
16
|
+
let [ve, F] = u(P), I = E ? p : ve, L = l(null), R = l(null), z = l(null), B = l(null), V = l(null), H = l(null), [U, W] = u(null), G = l(null), K = l([...I]), q = c((e) => (e - m) / (h - m) * 100, [m, h]), J = c((e) => {
|
|
17
|
+
let t = q(e[0]), n = q(e[1]);
|
|
18
|
+
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]));
|
|
19
|
+
}, [q]);
|
|
20
|
+
te(() => {
|
|
21
|
+
U || J(I);
|
|
22
22
|
}, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
I,
|
|
24
|
+
U,
|
|
25
|
+
J
|
|
26
26
|
]);
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
if (
|
|
31
|
-
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n =
|
|
32
|
-
a = r < i ? "min" : i < r ? "max" : n <
|
|
33
|
-
let o = [...
|
|
34
|
-
a === "min" ? o[0] = Math.min(n,
|
|
27
|
+
let Y = (e, t) => {
|
|
28
|
+
v || (K.current = [...I], G.current = t, W(t), e.stopPropagation(), e.preventDefault());
|
|
29
|
+
}, X = (e) => {
|
|
30
|
+
if (v) return;
|
|
31
|
+
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;
|
|
32
|
+
a = r < i ? "min" : i < r ? "max" : n < I[0] ? "min" : "max", G.current = a, W(a);
|
|
33
|
+
let o = [...K.current];
|
|
34
|
+
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);
|
|
35
35
|
}, Z = c((e) => {
|
|
36
|
-
if (!
|
|
37
|
-
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n =
|
|
38
|
-
|
|
36
|
+
if (!G.current || v) return;
|
|
37
|
+
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = N(t, L.current), r = [...K.current];
|
|
38
|
+
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);
|
|
39
39
|
}, [
|
|
40
|
-
y,
|
|
41
|
-
b,
|
|
42
40
|
v,
|
|
43
|
-
|
|
41
|
+
y,
|
|
42
|
+
_,
|
|
43
|
+
N,
|
|
44
|
+
m,
|
|
44
45
|
h,
|
|
45
|
-
|
|
46
|
-
Y
|
|
46
|
+
J
|
|
47
47
|
]), Q = c(() => {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
let e =
|
|
51
|
-
|
|
48
|
+
if (G.current) {
|
|
49
|
+
G.current = null, W(null);
|
|
50
|
+
let e = K.current;
|
|
51
|
+
E || F([...e]), ae?.(e);
|
|
52
52
|
}
|
|
53
|
-
}, [
|
|
54
|
-
|
|
53
|
+
}, [E, ae]);
|
|
54
|
+
te(() => (document.addEventListener("mousemove", Z), document.addEventListener("mouseup", Q), document.addEventListener("touchmove", Z, { passive: !1 }), document.addEventListener("touchend", Q), () => {
|
|
55
55
|
document.removeEventListener("mousemove", Z), document.removeEventListener("mouseup", Q), document.removeEventListener("touchmove", Z), document.removeEventListener("touchend", Q);
|
|
56
56
|
}), [Z, Q]);
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
59
|
-
let n = [...
|
|
60
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowDown") i = Math.max(
|
|
61
|
-
else if (e.key === "ArrowRight" || e.key === "ArrowUp") i = Math.min(
|
|
62
|
-
else if (e.key === "
|
|
63
|
-
else if (e.key === "
|
|
57
|
+
let ye = (e, t) => {
|
|
58
|
+
if (v) return;
|
|
59
|
+
let n = [...I], r = t === "min" ? n[0] : n[1], i;
|
|
60
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") i = Math.max(m, r - g);
|
|
61
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") i = Math.min(h, r + g);
|
|
62
|
+
else if (e.key === "PageDown") i = Math.max(m, r - o(m, h, g));
|
|
63
|
+
else if (e.key === "PageUp") i = Math.min(h, r + o(m, h, g));
|
|
64
|
+
else if (e.key === "Home") i = m;
|
|
65
|
+
else if (e.key === "End") i = h;
|
|
64
66
|
else return;
|
|
65
67
|
if (t === "min") {
|
|
66
|
-
let e =
|
|
68
|
+
let e = _ ? h : n[1];
|
|
67
69
|
n[0] = Math.min(i, e);
|
|
68
70
|
} else {
|
|
69
|
-
let e =
|
|
71
|
+
let e = _ ? m : n[0];
|
|
70
72
|
n[1] = Math.max(i, e);
|
|
71
73
|
}
|
|
72
|
-
|
|
73
|
-
}, $ =
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
-
label:
|
|
76
|
-
error:
|
|
77
|
-
required:
|
|
78
|
-
layout:
|
|
79
|
-
labelId:
|
|
80
|
-
errorId:
|
|
81
|
-
className:
|
|
82
|
-
children: /* @__PURE__ */
|
|
74
|
+
E || F(n), y?.(n), e.preventDefault();
|
|
75
|
+
}, $ = q(I[0]), be = q(I[1]);
|
|
76
|
+
return /* @__PURE__ */ f(a, {
|
|
77
|
+
label: x,
|
|
78
|
+
error: S,
|
|
79
|
+
required: se,
|
|
80
|
+
layout: ce,
|
|
81
|
+
labelId: he,
|
|
82
|
+
errorId: ge,
|
|
83
|
+
className: oe,
|
|
84
|
+
children: /* @__PURE__ */ re(fe ? e : "div", {
|
|
83
85
|
role: "presentation",
|
|
84
86
|
"data-testid": "range-slider-root",
|
|
85
|
-
className:
|
|
86
|
-
...
|
|
87
|
-
onMouseDown: (e) => i(
|
|
88
|
-
onTouchStart: (e) => i(
|
|
87
|
+
className: d("wim-range-slider", s.root, v && s.disabled, S && s.danger),
|
|
88
|
+
...w,
|
|
89
|
+
onMouseDown: (e) => i(w.onMouseDown, X)(e),
|
|
90
|
+
onTouchStart: (e) => i(w.onTouchStart, X)(e),
|
|
89
91
|
children: [
|
|
90
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ re("div", {
|
|
91
93
|
className: s.trackContainer,
|
|
92
|
-
ref:
|
|
94
|
+
ref: L,
|
|
93
95
|
children: [
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
ref:
|
|
96
|
+
/* @__PURE__ */ f("div", {
|
|
97
|
+
ref: B,
|
|
96
98
|
className: s.track,
|
|
97
99
|
style: {
|
|
98
100
|
left: `${$}%`,
|
|
99
|
-
width: `${
|
|
101
|
+
width: `${be - $}%`
|
|
100
102
|
}
|
|
101
103
|
}),
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
ref:
|
|
104
|
-
className:
|
|
104
|
+
/* @__PURE__ */ f("div", {
|
|
105
|
+
ref: R,
|
|
106
|
+
className: d(s.thumb, U === "min" && s.active),
|
|
105
107
|
style: { left: `${$}%` },
|
|
106
108
|
role: "slider",
|
|
107
|
-
"aria-valuemin":
|
|
108
|
-
"aria-valuemax":
|
|
109
|
-
"aria-valuenow":
|
|
110
|
-
"aria-disabled":
|
|
111
|
-
id:
|
|
112
|
-
"aria-labelledby":
|
|
113
|
-
"aria-label":
|
|
114
|
-
"aria-describedby":
|
|
115
|
-
"aria-invalid":
|
|
116
|
-
tabIndex:
|
|
117
|
-
onMouseDown: (e) =>
|
|
118
|
-
onTouchStart: (e) =>
|
|
119
|
-
onKeyDown: (e) =>
|
|
109
|
+
"aria-valuemin": m,
|
|
110
|
+
"aria-valuemax": I[1],
|
|
111
|
+
"aria-valuenow": I[0],
|
|
112
|
+
"aria-disabled": v,
|
|
113
|
+
id: k,
|
|
114
|
+
"aria-labelledby": j(k),
|
|
115
|
+
"aria-label": O ? T("rangeSlider.start_of", { label: O }) : T("rangeSlider.start"),
|
|
116
|
+
"aria-describedby": _e,
|
|
117
|
+
"aria-invalid": S ? !0 : void 0,
|
|
118
|
+
tabIndex: v ? -1 : 0,
|
|
119
|
+
onMouseDown: (e) => Y(e, "min"),
|
|
120
|
+
onTouchStart: (e) => Y(e, "min"),
|
|
121
|
+
onKeyDown: (e) => ye(e, "min")
|
|
120
122
|
}),
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
ref:
|
|
123
|
-
className:
|
|
124
|
-
style: { left: `${
|
|
123
|
+
/* @__PURE__ */ f("div", {
|
|
124
|
+
ref: z,
|
|
125
|
+
className: d(s.thumb, U === "max" && s.active),
|
|
126
|
+
style: { left: `${be}%` },
|
|
125
127
|
role: "slider",
|
|
126
|
-
"aria-valuemin":
|
|
127
|
-
"aria-valuemax":
|
|
128
|
-
"aria-valuenow":
|
|
129
|
-
"aria-disabled":
|
|
130
|
-
id:
|
|
131
|
-
"aria-labelledby":
|
|
132
|
-
"aria-label":
|
|
133
|
-
"aria-describedby":
|
|
134
|
-
"aria-invalid":
|
|
135
|
-
tabIndex:
|
|
136
|
-
onMouseDown: (e) =>
|
|
137
|
-
onTouchStart: (e) =>
|
|
138
|
-
onKeyDown: (e) =>
|
|
128
|
+
"aria-valuemin": I[0],
|
|
129
|
+
"aria-valuemax": h,
|
|
130
|
+
"aria-valuenow": I[1],
|
|
131
|
+
"aria-disabled": v,
|
|
132
|
+
id: A,
|
|
133
|
+
"aria-labelledby": j(A),
|
|
134
|
+
"aria-label": O ? T("rangeSlider.end_of", { label: O }) : T("rangeSlider.end"),
|
|
135
|
+
"aria-describedby": _e,
|
|
136
|
+
"aria-invalid": S ? !0 : void 0,
|
|
137
|
+
tabIndex: v ? -1 : 0,
|
|
138
|
+
onMouseDown: (e) => Y(e, "max"),
|
|
139
|
+
onTouchStart: (e) => Y(e, "max"),
|
|
140
|
+
onKeyDown: (e) => ye(e, "max")
|
|
139
141
|
})
|
|
140
142
|
]
|
|
141
143
|
}),
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
ref:
|
|
144
|
+
/* @__PURE__ */ f("input", {
|
|
145
|
+
ref: V,
|
|
144
146
|
type: "hidden",
|
|
145
|
-
name:
|
|
146
|
-
value:
|
|
147
|
+
name: b ? `${b}-min` : "",
|
|
148
|
+
value: I[0]
|
|
147
149
|
}),
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
ref:
|
|
150
|
+
/* @__PURE__ */ f("input", {
|
|
151
|
+
ref: H,
|
|
150
152
|
type: "hidden",
|
|
151
|
-
name:
|
|
152
|
-
value:
|
|
153
|
+
name: b ? `${b}-max` : "",
|
|
154
|
+
value: I[1]
|
|
153
155
|
}),
|
|
154
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ f(t, { children: pe })
|
|
155
157
|
]
|
|
156
158
|
})
|
|
157
159
|
});
|
|
158
160
|
};
|
|
159
|
-
|
|
161
|
+
p.displayName = "RangeSlider";
|
|
160
162
|
//#endregion
|
|
161
|
-
export {
|
|
163
|
+
export { p as RangeSlider };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/composeEventHandlers.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("../../../utilities/slider-utils.cjs"),a=require("./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=(0,o.forwardRef)(({value:e,defaultValue:l=0,min:u=0,max:d=100,step:f=1,disabled:p=!1,onChange:m,onAfterChange:h,className:g,name:_,label:v,error:y,required:b,layout:x=`vertical`,id:S,"aria-label":C,"aria-labelledby":w,"aria-describedby":T,asChild:E=!1,styles:D,children:O,...k},A)=>{let j=e!==void 0,[M,N]=(0,o.useState)(l),P=j?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)(!1),B=(0,o.useRef)(P),V=(0,o.useId)(),H=S||V,U=`wim-slider-label-${H}`,W=`wim-slider-error-${H}`,{calculateValue:G}=i.useSliderCommon(u,d,f),K=(0,o.useCallback)(e=>(e-u)/(d-u)*100,[u,d]),q=(0,o.useCallback)(e=>{let t=K(e);L.current&&(L.current.style.width=`${t}%`),I.current&&(I.current.style.left=`${t}%`,I.current.setAttribute(`aria-valuenow`,String(e))),R.current&&(R.current.value=String(e))},[K]);(0,o.useEffect)(()=>{z.current||q(P)},[P,q]);let J=e=>{if(p)return;z.current=!0;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=G(t,F.current);B.current=n,q(n),m?.(n),e.preventDefault()},Y=(0,o.useCallback)(e=>{if(!z.current||p)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=G(t,F.current);B.current=n,q(n),m?.(n)},[p,G,m,q]),X=(0,o.useCallback)(()=>{if(z.current){z.current=!1;let e=B.current;j||N(e),h?.(e)}},[j,h]);(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=>{if(p)return;let t;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)t=Math.max(u,P-f);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)t=Math.min(d,P+f);else if(e.key===`Home`)t=u;else if(e.key===`End`)t=d;else return;j||N(t),m?.(t),e.preventDefault()},Q=K(P);return(0,c.jsx)(r.FieldTemplate,{label:v,error:y,required:b,layout:x,labelId:U,errorId:W,className:g,styles:D,children:(0,c.jsxs)(E?t.Root:`div`,{role:`presentation`,className:(0,s.default)(`wim-slider`,a.default.root,p&&a.default.disabled,y&&a.default.danger),ref:A,...k,onMouseDown:n.composeEventHandlers(k.onMouseDown,J),onTouchStart:n.composeEventHandlers(k.onTouchStart,J),children:[(0,c.jsxs)(`div`,{className:a.default.trackContainer,ref:F,children:[(0,c.jsx)(`div`,{ref:L,className:a.default.track,style:{width:`${Q}%`}}),(0,c.jsx)(`div`,{ref:I,className:a.default.thumb,style:{left:`${Q}%`},role:`slider`,"aria-valuemin":u,"aria-valuemax":d,"aria-valuenow":P,"aria-disabled":p,"aria-labelledby":v?U:w,"aria-label":v?void 0:C,"aria-describedby":[T,y?W:void 0].filter(Boolean).join(` `)||void 0,"aria-invalid":y?!0:void 0,tabIndex:p?-1:0,onKeyDown:Z})]}),(0,c.jsx)(`input`,{ref:R,type:`hidden`,name:_,value:P}),E?(0,c.jsx)(t.Slottable,{children:O}):null]})})});l.displayName=`Slider`,exports.Slider=l,exports.default=l;
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/composeEventHandlers.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("../../../utilities/slider-utils.cjs"),a=require("./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=(0,o.forwardRef)(({value:e,defaultValue:l=0,min:u=0,max:d=100,step:f=1,disabled:p=!1,onChange:m,onAfterChange:h,className:g,name:_,label:v,error:y,required:b,layout:x=`vertical`,id:S,"aria-label":C,"aria-labelledby":w,"aria-describedby":T,asChild:E=!1,styles:D,children:O,...k},A)=>{let j=e!==void 0,[M,N]=(0,o.useState)(l),P=j?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)(!1),B=(0,o.useRef)(P),V=(0,o.useId)(),H=S||V,U=`wim-slider-label-${H}`,W=`wim-slider-error-${H}`,{calculateValue:G}=i.useSliderCommon(u,d,f),K=(0,o.useCallback)(e=>(e-u)/(d-u)*100,[u,d]),q=(0,o.useCallback)(e=>{let t=K(e);L.current&&(L.current.style.width=`${t}%`),I.current&&(I.current.style.left=`${t}%`,I.current.setAttribute(`aria-valuenow`,String(e))),R.current&&(R.current.value=String(e))},[K]);(0,o.useEffect)(()=>{z.current||q(P)},[P,q]);let J=e=>{if(p)return;z.current=!0;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=G(t,F.current);B.current=n,q(n),m?.(n),e.preventDefault()},Y=(0,o.useCallback)(e=>{if(!z.current||p)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=G(t,F.current);B.current=n,q(n),m?.(n)},[p,G,m,q]),X=(0,o.useCallback)(()=>{if(z.current){z.current=!1;let e=B.current;j||N(e),h?.(e)}},[j,h]);(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=>{if(p)return;let t;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)t=Math.max(u,P-f);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)t=Math.min(d,P+f);else if(e.key===`PageDown`)t=Math.max(u,P-i.largeStepOf(u,d,f));else if(e.key===`PageUp`)t=Math.min(d,P+i.largeStepOf(u,d,f));else if(e.key===`Home`)t=u;else if(e.key===`End`)t=d;else return;j||N(t),m?.(t),e.preventDefault()},Q=K(P);return(0,c.jsx)(r.FieldTemplate,{label:v,error:y,required:b,layout:x,labelId:U,errorId:W,className:g,styles:D,children:(0,c.jsxs)(E?t.Root:`div`,{role:`presentation`,className:(0,s.default)(`wim-slider`,a.default.root,p&&a.default.disabled,y&&a.default.danger),ref:A,...k,onMouseDown:n.composeEventHandlers(k.onMouseDown,J),onTouchStart:n.composeEventHandlers(k.onTouchStart,J),children:[(0,c.jsxs)(`div`,{className:a.default.trackContainer,ref:F,children:[(0,c.jsx)(`div`,{ref:L,className:a.default.track,style:{width:`${Q}%`}}),(0,c.jsx)(`div`,{ref:I,className:a.default.thumb,style:{left:`${Q}%`},role:`slider`,"aria-valuemin":u,"aria-valuemax":d,"aria-valuenow":P,"aria-disabled":p,"aria-labelledby":v?U:w,"aria-label":v?void 0:C,"aria-describedby":[T,y?W:void 0].filter(Boolean).join(` `)||void 0,"aria-invalid":y?!0:void 0,tabIndex:p?-1:0,onKeyDown:Z})]}),(0,c.jsx)(`input`,{ref:R,type:`hidden`,name:_,value:P}),E?(0,c.jsx)(t.Slottable,{children:O}):null]})})});l.displayName=`Slider`,exports.Slider=l,exports.default=l;
|
|
@@ -2,106 +2,108 @@
|
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { composeEventHandlers as n } from "../../_internal/composeEventHandlers.js";
|
|
4
4
|
import { FieldTemplate as r } from "../FieldTemplate/FieldTemplate.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { forwardRef as
|
|
8
|
-
import
|
|
9
|
-
import { jsx as
|
|
5
|
+
import { largeStepOf as i, useSliderCommon as a } from "../../../utilities/slider-utils.js";
|
|
6
|
+
import o from "./slider.module.js";
|
|
7
|
+
import { forwardRef as s, useCallback as c, useEffect as l, useId as u, useRef as d, useState as f } from "react";
|
|
8
|
+
import p from "classnames";
|
|
9
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
10
|
//#region src/components/form/Slider/Slider.tsx
|
|
11
|
-
var
|
|
12
|
-
let
|
|
11
|
+
var g = s(({ value: s, defaultValue: g = 0, min: _ = 0, max: v = 100, step: y = 1, disabled: b = !1, onChange: x, onAfterChange: S, className: C, name: w, label: T, error: E, required: ee, layout: te = "vertical", id: ne, "aria-label": re, "aria-labelledby": D, "aria-describedby": O, asChild: k = !1, styles: A, children: j, ...M }, N) => {
|
|
12
|
+
let P = s !== void 0, [F, I] = f(g), L = P ? s : F, R = d(null), z = d(null), B = d(null), V = d(null), H = d(!1), U = d(L), ie = u(), W = ne || ie, G = `wim-slider-label-${W}`, K = `wim-slider-error-${W}`, { calculateValue: q } = a(_, v, y), J = c((e) => (e - _) / (v - _) * 100, [_, v]), Y = c((e) => {
|
|
13
13
|
let t = J(e);
|
|
14
|
-
|
|
14
|
+
B.current && (B.current.style.width = `${t}%`), z.current && (z.current.style.left = `${t}%`, z.current.setAttribute("aria-valuenow", String(e))), V.current && (V.current.value = String(e));
|
|
15
15
|
}, [J]);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, [
|
|
16
|
+
l(() => {
|
|
17
|
+
H.current || Y(L);
|
|
18
|
+
}, [L, Y]);
|
|
19
19
|
let X = (e) => {
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = q(t,
|
|
23
|
-
|
|
24
|
-
}, Z =
|
|
25
|
-
if (!
|
|
26
|
-
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = q(t,
|
|
27
|
-
|
|
20
|
+
if (b) return;
|
|
21
|
+
H.current = !0;
|
|
22
|
+
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = q(t, R.current);
|
|
23
|
+
U.current = n, Y(n), x?.(n), e.preventDefault();
|
|
24
|
+
}, Z = c((e) => {
|
|
25
|
+
if (!H.current || b) return;
|
|
26
|
+
let t = "touches" in e ? e.touches[0].clientX : e.clientX, n = q(t, R.current);
|
|
27
|
+
U.current = n, Y(n), x?.(n);
|
|
28
28
|
}, [
|
|
29
|
-
y,
|
|
30
|
-
q,
|
|
31
29
|
b,
|
|
30
|
+
q,
|
|
31
|
+
x,
|
|
32
32
|
Y
|
|
33
|
-
]), Q =
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
let e =
|
|
37
|
-
|
|
33
|
+
]), Q = c(() => {
|
|
34
|
+
if (H.current) {
|
|
35
|
+
H.current = !1;
|
|
36
|
+
let e = U.current;
|
|
37
|
+
P || I(e), S?.(e);
|
|
38
38
|
}
|
|
39
|
-
}, [
|
|
40
|
-
|
|
39
|
+
}, [P, S]);
|
|
40
|
+
l(() => (document.addEventListener("mousemove", Z), document.addEventListener("mouseup", Q), document.addEventListener("touchmove", Z, { passive: !1 }), document.addEventListener("touchend", Q), () => {
|
|
41
41
|
document.removeEventListener("mousemove", Z), document.removeEventListener("mouseup", Q), document.removeEventListener("touchmove", Z), document.removeEventListener("touchend", Q);
|
|
42
42
|
}), [Z, Q]);
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
43
|
+
let ae = (e) => {
|
|
44
|
+
if (b) return;
|
|
45
45
|
let t;
|
|
46
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowDown") t = Math.max(
|
|
47
|
-
else if (e.key === "ArrowRight" || e.key === "ArrowUp") t = Math.min(
|
|
48
|
-
else if (e.key === "
|
|
49
|
-
else if (e.key === "
|
|
46
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") t = Math.max(_, L - y);
|
|
47
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") t = Math.min(v, L + y);
|
|
48
|
+
else if (e.key === "PageDown") t = Math.max(_, L - i(_, v, y));
|
|
49
|
+
else if (e.key === "PageUp") t = Math.min(v, L + i(_, v, y));
|
|
50
|
+
else if (e.key === "Home") t = _;
|
|
51
|
+
else if (e.key === "End") t = v;
|
|
50
52
|
else return;
|
|
51
|
-
|
|
52
|
-
}, $ = J(
|
|
53
|
-
return /* @__PURE__ */
|
|
54
|
-
label:
|
|
55
|
-
error:
|
|
56
|
-
required:
|
|
57
|
-
layout:
|
|
53
|
+
P || I(t), x?.(t), e.preventDefault();
|
|
54
|
+
}, $ = J(L);
|
|
55
|
+
return /* @__PURE__ */ m(r, {
|
|
56
|
+
label: T,
|
|
57
|
+
error: E,
|
|
58
|
+
required: ee,
|
|
59
|
+
layout: te,
|
|
58
60
|
labelId: G,
|
|
59
61
|
errorId: K,
|
|
60
|
-
className:
|
|
61
|
-
styles:
|
|
62
|
-
children: /* @__PURE__ */
|
|
62
|
+
className: C,
|
|
63
|
+
styles: A,
|
|
64
|
+
children: /* @__PURE__ */ h(k ? e : "div", {
|
|
63
65
|
role: "presentation",
|
|
64
|
-
className:
|
|
65
|
-
ref:
|
|
66
|
-
...
|
|
67
|
-
onMouseDown: n(
|
|
68
|
-
onTouchStart: n(
|
|
66
|
+
className: p("wim-slider", o.root, b && o.disabled, E && o.danger),
|
|
67
|
+
ref: N,
|
|
68
|
+
...M,
|
|
69
|
+
onMouseDown: n(M.onMouseDown, X),
|
|
70
|
+
onTouchStart: n(M.onTouchStart, X),
|
|
69
71
|
children: [
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
className:
|
|
72
|
-
ref:
|
|
73
|
-
children: [/* @__PURE__ */
|
|
74
|
-
ref:
|
|
75
|
-
className:
|
|
72
|
+
/* @__PURE__ */ h("div", {
|
|
73
|
+
className: o.trackContainer,
|
|
74
|
+
ref: R,
|
|
75
|
+
children: [/* @__PURE__ */ m("div", {
|
|
76
|
+
ref: B,
|
|
77
|
+
className: o.track,
|
|
76
78
|
style: { width: `${$}%` }
|
|
77
|
-
}), /* @__PURE__ */
|
|
78
|
-
ref:
|
|
79
|
-
className:
|
|
79
|
+
}), /* @__PURE__ */ m("div", {
|
|
80
|
+
ref: z,
|
|
81
|
+
className: o.thumb,
|
|
80
82
|
style: { left: `${$}%` },
|
|
81
83
|
role: "slider",
|
|
82
|
-
"aria-valuemin":
|
|
83
|
-
"aria-valuemax":
|
|
84
|
-
"aria-valuenow":
|
|
85
|
-
"aria-disabled":
|
|
86
|
-
"aria-labelledby":
|
|
87
|
-
"aria-label":
|
|
88
|
-
"aria-describedby": [
|
|
89
|
-
"aria-invalid":
|
|
90
|
-
tabIndex:
|
|
91
|
-
onKeyDown:
|
|
84
|
+
"aria-valuemin": _,
|
|
85
|
+
"aria-valuemax": v,
|
|
86
|
+
"aria-valuenow": L,
|
|
87
|
+
"aria-disabled": b,
|
|
88
|
+
"aria-labelledby": T ? G : D,
|
|
89
|
+
"aria-label": T ? void 0 : re,
|
|
90
|
+
"aria-describedby": [O, E ? K : void 0].filter(Boolean).join(" ") || void 0,
|
|
91
|
+
"aria-invalid": E ? !0 : void 0,
|
|
92
|
+
tabIndex: b ? -1 : 0,
|
|
93
|
+
onKeyDown: ae
|
|
92
94
|
})]
|
|
93
95
|
}),
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
ref:
|
|
96
|
+
/* @__PURE__ */ m("input", {
|
|
97
|
+
ref: V,
|
|
96
98
|
type: "hidden",
|
|
97
|
-
name:
|
|
98
|
-
value:
|
|
99
|
+
name: w,
|
|
100
|
+
value: L
|
|
99
101
|
}),
|
|
100
|
-
|
|
102
|
+
k ? /* @__PURE__ */ m(t, { children: j }) : null
|
|
101
103
|
]
|
|
102
104
|
})
|
|
103
105
|
});
|
|
104
106
|
});
|
|
105
|
-
|
|
107
|
+
g.displayName = "Slider";
|
|
106
108
|
//#endregion
|
|
107
|
-
export {
|
|
109
|
+
export { g as Slider, g as default };
|
package/dist/llms-full.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
**wimui** v0.76.
|
|
7
|
+
**wimui** v0.76.1 — a React 19 component library: 231 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
|
|
8
8
|
|
|
9
9
|
## Install & required setup
|
|
10
10
|
|
package/dist/llms.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
**wimui** v0.76.
|
|
7
|
+
**wimui** v0.76.1 — a React 19 component library: 231 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
|
|
8
8
|
|
|
9
9
|
## Install & required setup
|
|
10
10
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
let e=require("react");var t=(e,t,n)=>Math.max(t,Math.min(e,n)),n=(n,r,i)=>{let a=(0,e.useCallback)(e=>t(n+Math.round((e-n)/i)*i,n,r),[n,r,i]);return{clamp:t,alignToStep:a,calculateValue:(0,e.useCallback)((e,i)=>{if(!i)return n;let o=i.getBoundingClientRect(),s=n+t((e-o.left)/o.width,0,1)*(r-n);return a(s)},[a,r,n])}};exports.clamp=t,exports.useSliderCommon=
|
|
2
|
+
let e=require("react");var t=(e,t,n)=>Math.max(t,Math.min(e,n)),n=(e,t,n)=>Math.max(n,Math.round((t-e)/10/n)*n),r=(n,r,i)=>{let a=(0,e.useCallback)(e=>t(n+Math.round((e-n)/i)*i,n,r),[n,r,i]);return{clamp:t,alignToStep:a,calculateValue:(0,e.useCallback)((e,i)=>{if(!i)return n;let o=i.getBoundingClientRect(),s=n+t((e-o.left)/o.width,0,1)*(r-n);return a(s)},[a,r,n])}};exports.clamp=t,exports.largeStepOf=n,exports.useSliderCommon=r;
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* 値をminとmaxの範囲内に収めます。
|
|
3
3
|
*/
|
|
4
4
|
export declare const clamp: (val: number, min: number, max: number) => number;
|
|
5
|
+
/**
|
|
6
|
+
* PageUp / PageDown で 1 回に動く幅(T410)。範囲の 10 分の 1 を step の倍数に丸め、step より小さくしない。
|
|
7
|
+
* 固定の 10 にすると、0〜1 の範囲では 1 回で端まで飛び、step 50 の範囲では目盛りからずれる。
|
|
8
|
+
*/
|
|
9
|
+
export declare const largeStepOf: (min: number, max: number, step: number) => number;
|
|
5
10
|
/**
|
|
6
11
|
* スライダーの共通ロジックを提供するカスタムフック。
|
|
7
12
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCallback as e } from "react";
|
|
3
3
|
//#region src/utilities/slider-utils.ts
|
|
4
|
-
var t = (e, t, n) => Math.max(t, Math.min(e, n)), n = (n, r, i) => {
|
|
4
|
+
var t = (e, t, n) => Math.max(t, Math.min(e, n)), n = (e, t, n) => Math.max(n, Math.round((t - e) / 10 / n) * n), r = (n, r, i) => {
|
|
5
5
|
let a = e((e) => t(n + Math.round((e - n) / i) * i, n, r), [
|
|
6
6
|
n,
|
|
7
7
|
r,
|
|
@@ -22,4 +22,4 @@ var t = (e, t, n) => Math.max(t, Math.min(e, n)), n = (n, r, i) => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
//#endregion
|
|
25
|
-
export { t as clamp, n as useSliderCommon };
|
|
25
|
+
export { t as clamp, n as largeStepOf, r as useSliderCommon };
|