@ncdai/react-wheel-picker 1.0.11 → 1.0.13
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/index.css +1 -1
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-rwp-wrapper]{display:flex;
|
|
1
|
+
[data-rwp-wrapper]{position:relative;overflow:hidden;display:flex;width:100%;align-items:stretch;justify-content:space-between;perspective:2000px;-webkit-user-select:none;-moz-user-select:none;user-select:none}[data-rwp]{position:relative;overflow:hidden;flex:1;cursor:default;-webkit-mask-image:linear-gradient(to bottom,transparent 0%,black 20%,black 80%,transparent 100%);mask-image:linear-gradient(to bottom,transparent 0%,black 20%,black 80%,transparent 100%)}[data-rwp-highlight-wrapper]{position:absolute;overflow:hidden;top:50%;width:100%;transform:translateY(-50%);font-size:1rem;font-weight:500}[data-rwp-highlight-list]{position:absolute;width:100%;list-style:none}[data-rwp-options]{position:absolute;top:50%;left:0;display:block;width:100%;height:0;margin:0 auto;-webkit-font-smoothing:subpixel-antialiased;will-change:transform;backface-visibility:hidden;transform-style:preserve-3d;list-style:none}[data-rwp-option]{position:absolute;top:0;left:0;width:100%;-webkit-font-smoothing:subpixel-antialiased;will-change:visibility;font-size:.875rem}[data-rwp-option],[data-rwp-highlight-item]{display:flex;align-items:center;justify-content:center}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Represents a single option in the wheel picker
|
|
@@ -6,8 +6,8 @@ import React$1 from 'react';
|
|
|
6
6
|
type WheelPickerOption = {
|
|
7
7
|
/** The value that will be returned when this option is selected */
|
|
8
8
|
value: string;
|
|
9
|
-
/** The
|
|
10
|
-
label:
|
|
9
|
+
/** The content displayed for this option */
|
|
10
|
+
label: ReactNode;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Custom class names for styling different parts of the wheel picker
|
|
@@ -38,6 +38,8 @@ type WheelPickerProps = {
|
|
|
38
38
|
visibleCount?: number;
|
|
39
39
|
/** Sensitivity of the drag interaction (higher = more sensitive) */
|
|
40
40
|
dragSensitivity?: number;
|
|
41
|
+
/** Height (in pixels) of each item in the picker list */
|
|
42
|
+
optionItemHeight?: number;
|
|
41
43
|
/** Custom class names for styling different parts of the wheel */
|
|
42
44
|
classNames?: WheelPickerClassNames;
|
|
43
45
|
};
|
|
@@ -48,10 +50,10 @@ type WheelPickerWrapperProps = {
|
|
|
48
50
|
/** Additional CSS class name for the wrapper */
|
|
49
51
|
className?: string;
|
|
50
52
|
/** Child elements to be rendered inside the wrapper */
|
|
51
|
-
children:
|
|
53
|
+
children: ReactNode;
|
|
52
54
|
};
|
|
53
55
|
|
|
54
|
-
declare const WheelPickerWrapper: React
|
|
55
|
-
declare const WheelPicker: React
|
|
56
|
+
declare const WheelPickerWrapper: React.FC<WheelPickerWrapperProps>;
|
|
57
|
+
declare const WheelPicker: React.FC<WheelPickerProps>;
|
|
56
58
|
|
|
57
59
|
export { WheelPicker, type WheelPickerClassNames, type WheelPickerOption, WheelPickerWrapper };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Represents a single option in the wheel picker
|
|
@@ -6,8 +6,8 @@ import React$1 from 'react';
|
|
|
6
6
|
type WheelPickerOption = {
|
|
7
7
|
/** The value that will be returned when this option is selected */
|
|
8
8
|
value: string;
|
|
9
|
-
/** The
|
|
10
|
-
label:
|
|
9
|
+
/** The content displayed for this option */
|
|
10
|
+
label: ReactNode;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Custom class names for styling different parts of the wheel picker
|
|
@@ -38,6 +38,8 @@ type WheelPickerProps = {
|
|
|
38
38
|
visibleCount?: number;
|
|
39
39
|
/** Sensitivity of the drag interaction (higher = more sensitive) */
|
|
40
40
|
dragSensitivity?: number;
|
|
41
|
+
/** Height (in pixels) of each item in the picker list */
|
|
42
|
+
optionItemHeight?: number;
|
|
41
43
|
/** Custom class names for styling different parts of the wheel */
|
|
42
44
|
classNames?: WheelPickerClassNames;
|
|
43
45
|
};
|
|
@@ -48,10 +50,10 @@ type WheelPickerWrapperProps = {
|
|
|
48
50
|
/** Additional CSS class name for the wrapper */
|
|
49
51
|
className?: string;
|
|
50
52
|
/** Child elements to be rendered inside the wrapper */
|
|
51
|
-
children:
|
|
53
|
+
children: ReactNode;
|
|
52
54
|
};
|
|
53
55
|
|
|
54
|
-
declare const WheelPickerWrapper: React
|
|
55
|
-
declare const WheelPicker: React
|
|
56
|
+
declare const WheelPickerWrapper: React.FC<WheelPickerWrapperProps>;
|
|
57
|
+
declare const WheelPicker: React.FC<WheelPickerProps>;
|
|
56
58
|
|
|
57
59
|
export { WheelPicker, type WheelPickerClassNames, type WheelPickerOption, WheelPickerWrapper };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var St=Object.create;var A=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty;var It=(s,c)=>{for(var d in c)A(s,d,{get:c[d],enumerable:!0})},st=(s,c,d,g)=>{if(c&&typeof c=="object"||typeof c=="function")for(let i of Et(c))!Ct.call(s,i)&&i!==d&&A(s,i,{get:()=>c[i],enumerable:!(g=kt(c,i))||g.enumerable});return s};var at=(s,c,d)=>(d=s!=null?St(Dt(s)):{},st(c||!s||!s.__esModule?A(d,"default",{value:s,enumerable:!0}):d,s)),Lt=s=>st(A({},"__esModule",{value:!0}),s);var Ht={};It(Ht,{WheelPicker:()=>Rt,WheelPickerWrapper:()=>At});module.exports=Lt(Ht);var S=at(require("react")),h=require("react");var T=at(require("react"));function ct(s){let c=T.default.useRef(s);return T.default.useEffect(()=>{c.current=s}),T.default.useMemo(()=>(...d)=>{var g;return(g=c.current)==null?void 0:g.call(c,...d)},[])}function Wt({defaultProp:s,onChange:c}){let d=T.default.useState(s),[g]=d,i=T.default.useRef(g),w=ct(c);return T.default.useEffect(()=>{i.current!==g&&(w(g),i.current=g)},[g,i,w]),d}function it({prop:s,defaultProp:c,onChange:d=()=>{}}){let[g,i]=Wt({defaultProp:c,onChange:d}),w=s!==void 0,R=w?s:g,I=ct(d),f=T.default.useCallback(k=>{if(w){let a=typeof k=="function"?k(s):k;a!==s&&I(a)}else i(k)},[w,s,i,I]);return[R,f]}var lt=.3,xt=30,Yt=s=>Math.pow(s-1,3)+1,q=(s,c,d)=>Math.max(c,Math.min(s,d)),At=({className:s,children:c})=>S.default.createElement("div",{className:s,"data-rwp-wrapper":!0},c),Rt=({defaultValue:s,value:c,onValueChange:d,options:g,infinite:i=!1,visibleCount:w=20,dragSensitivity:R=3,optionItemHeight:I=30,classNames:f})=>{var et,nt;let[k=(nt=(et=g[0])==null?void 0:et.value)!=null?nt:"",B]=it({defaultProp:s,prop:c,onChange:d}),a=(0,h.useMemo)(()=>{if(!i)return g;let t=[],n=Math.ceil(w/2);if(g.length===0)return t;for(;t.length<n;)t.push(...g);return t},[w,g,i]),p=I,j=p*.5,M=360/w,L=p/Math.tan(M*Math.PI/180),ut=Math.round(L*2+p*.25),E=w>>2,X=R*10,ht=10,b=(0,h.useRef)(null),W=(0,h.useRef)(null),H=(0,h.useRef)(null),v=(0,h.useRef)(0),G=(0,h.useRef)(0),D=(0,h.useRef)(!1),Z=(0,h.useRef)(0),O=(0,h.useRef)({startY:0,yList:[],touchScroll:0,isClick:!0}),z=(0,h.useRef)(null),dt=(0,h.useMemo)(()=>{let t=(e,r,o)=>S.default.createElement("li",{key:r,className:f==null?void 0:f.optionItem,"data-slot":"option-item","data-rwp-option":!0,"data-index":r,style:{top:-j,height:p,lineHeight:`${p}px`,transform:`rotateX(${o}deg) translateZ(${L}px)`,visibility:"hidden"}},e.label),n=a.map((e,r)=>t(e,r,-M*r));if(i)for(let e=0;e<E;++e){let r=-e-1,o=e+a.length;n.unshift(t(a[a.length-e-1],r,M*(e+1))),n.push(t(a[e],o,-M*o))}return n},[p,j,i,M,a,E,L,f==null?void 0:f.optionItem]),gt=(0,h.useMemo)(()=>{let t=(e,r)=>S.default.createElement("li",{key:r,className:f==null?void 0:f.highlightItem,"data-slot":"highlight-item","data-rwp-highlight-item":!0,style:{height:p}},e.label),n=a.map((e,r)=>t(e,r));if(i){let e=a[0],r=a[a.length-1];n.unshift(t(r,"infinite-start")),n.push(t(e,"infinite-end"))}return n},[f==null?void 0:f.highlightItem,p,i,a]),ft=(0,h.useMemo)(()=>{let t=0,n=Math.PI/180,e=[];for(let r=E-1;r>=-E+1;--r){let o=r*M,u=p*Math.cos(o*n),l=t;t+=u,e.push([l,t])}return e},[M,p,E]),P=t=>(t%a.length+a.length)%a.length,C=t=>{let n=i?P(t):t;if(W.current){let e=`translateZ(${-L}px) rotateX(${M*n}deg)`;W.current.style.transform=e,W.current.childNodes.forEach(r=>{let o=r,u=Math.abs(Number(o.dataset.index)-n);o.style.visibility=u>E?"hidden":"visible"})}return H.current&&(H.current.style.transform=`translateY(${-n*p}px)`),n},x=()=>{cancelAnimationFrame(G.current)},K=(t,n,e,r)=>{if(t===n||e===0){C(t);return}let o=performance.now(),u=n-t,l=m=>{let y=(m-o)/1e3;if(y<e){let $=Yt(y/e);v.current=C(t+$*u),G.current=requestAnimationFrame(l)}else x(),v.current=C(n),r==null||r()};requestAnimationFrame(l)},Y=t=>{let n=P(t)|0,e=i?n:Math.min(Math.max(n,0),a.length-1);if(!i&&e!==t)return;v.current=C(e);let r=a[v.current];B(r.value)},pt=t=>{let n=a.findIndex(e=>e.value===t);if(n===-1){console.error("Invalid value selected:",t);return}x(),Y(n)},_=t=>{let n=v.current,e=n+t;i?e=Math.round(e):e=q(Math.round(e),0,a.length-1);let r=Math.abs(e-n);if(r===0)return;let o=Math.sqrt(r/5);x(),K(n,e,o,()=>{Y(v.current)})},mt=t=>{let n=b.current;if(!n){console.error("Container reference is not set.");return}let{top:e}=n.getBoundingClientRect(),r=t-e,o=ft.findIndex(([l,m])=>r>=l&&r<=m);if(o===-1){console.error("No item found for click position:",r);return}let u=(E-o-1)*-1;_(u)},bt=t=>{var n,e;try{let r=(t instanceof MouseEvent?t.clientY:(e=(n=t.touches)==null?void 0:n[0])==null?void 0:e.clientY)||0,o=O.current;o.isClick&&Math.abs(r-o.startY)>5&&(o.isClick=!1),o.yList.push([r,Date.now()]),o.yList.length>5&&o.yList.shift();let u=(o.startY-r)/p,l=v.current+u;if(i)l=P(l);else{let m=a.length;l<0?l*=lt:l>m&&(l=m+(l-m)*lt)}o.touchScroll=C(l)}catch(r){console.error("Error in updateScrollDuringDrag:",r)}},J=t=>{!D.current&&!b.current.contains(t.target)&&t.target!==b.current||(t.cancelable&&t.preventDefault(),a.length&&bt(t))},Q=t=>{var n,e,r;try{D.current=!0;let o=new AbortController,{signal:u}=o;z.current=o;let l={signal:u,passive:!1};(n=b.current)==null||n.addEventListener("touchmove",J,l),document.addEventListener("mousemove",J,l);let m=(t instanceof MouseEvent?t.clientY:(r=(e=t.touches)==null?void 0:e[0])==null?void 0:r.clientY)||0,y=O.current;y.startY=m,y.yList=[[m,Date.now()]],y.touchScroll=v.current,y.isClick=!0,x()}catch(o){console.error("Error in initiateDragGesture:",o)}},F=(0,h.useCallback)(t=>{let n=D.current,e=b.current.contains(t.target)||t.target===b.current;(n||e)&&t.cancelable&&(t.preventDefault(),a.length&&Q(t))},[Q]),vt=t=>{let n=v.current,e=n,r=t>0?-X:X,o=0;if(i){o=Math.abs(t/r);let u=t*o+.5*r*o*o;e=Math.round(n+u)}else if(n<0||n>a.length-1){let u=q(n,0,a.length-1),l=n-u;r=ht,o=Math.sqrt(Math.abs(l/r)),t=r*o,t=n>0?-t:t,e=u}else{o=Math.abs(t/r);let u=t*o+.5*r*o*o;e=Math.round(n+u),e=q(e,0,a.length-1);let l=e-n;o=Math.sqrt(Math.abs(l/r))}K(n,e,o,()=>{Y(v.current)}),Y(v.current)},V=()=>{var t,n,e,r;try{(t=z.current)==null||t.abort(),z.current=null;let o=O.current;if(o.isClick){mt(o.startY);return}let u=o.yList,l=0;if(u.length>1){let m=u.length,[y,$]=(n=u[m-2])!=null?n:[0,0],[wt,yt]=(e=u[m-1])!=null?e:[0,0],rt=yt-$;if(rt>0){let ot=(y-wt)/p*1e3/rt,Mt=xt,Tt=ot>0?1:-1;l=Math.min(Math.abs(ot),Mt)*Tt}}v.current=(r=o.touchScroll)!=null?r:v.current,vt(l)}catch(o){console.error("Error in finalizeDragAndStartInertiaScroll:",o)}finally{D.current=!1}},U=(0,h.useCallback)(t=>{if(!a.length)return;let n=D.current,e=b.current.contains(t.target)||t.target===b.current;(n||e)&&t.cancelable&&(t.preventDefault(),V())},[V]),N=t=>{t.preventDefault();let n=Date.now();if(n-Z.current<100)return;let e=Math.sign(t.deltaY);e&&(Z.current=n,_(e))},tt=(0,h.useCallback)(t=>{if(!a.length||!b.current)return;let n=D.current,e=b.current.contains(t.target)||t.target===b.current;(n||e)&&t.cancelable&&(t.preventDefault(),N(t))},[N]);return(0,h.useEffect)(()=>{let t=b.current;if(!t)return;let n=new AbortController,{signal:e}=n,r={signal:e,passive:!1};return t.addEventListener("touchstart",F,r),t.addEventListener("touchend",U,r),t.addEventListener("wheel",tt,r),document.addEventListener("mousedown",F,r),document.addEventListener("mouseup",U,r),()=>n.abort()},[U,F,tt]),(0,h.useEffect)(()=>{pt(k)},[k,c]),S.default.createElement("div",{ref:b,"data-rwp":!0,style:{height:ut}},S.default.createElement("ul",{ref:W,"data-rwp-options":!0},dt),S.default.createElement("div",{className:f==null?void 0:f.highlightWrapper,"data-rwp-highlight-wrapper":!0,"data-slot":"highlight-wrapper",style:{height:p,lineHeight:`${p}px`}},S.default.createElement("ul",{ref:H,"data-rwp-highlight-list":!0,style:{top:i?-p:void 0}},gt)))};0&&(module.exports={WheelPicker,WheelPickerWrapper});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import
|
|
1
|
+
"use client";import E from"react";import{useCallback as q,useEffect as it,useMemo as A,useRef as y}from"react";import k from"react";function at(l){let g=k.useRef(l);return k.useEffect(()=>{g.current=l}),k.useMemo(()=>(...b)=>{var h;return(h=g.current)==null?void 0:h.call(g,...b)},[])}function St({defaultProp:l,onChange:g}){let b=k.useState(l),[h]=b,i=k.useRef(h),v=at(g);return k.useEffect(()=>{i.current!==h&&(v(h),i.current=h)},[h,i,v]),b}function ct({prop:l,defaultProp:g,onChange:b=()=>{}}){let[h,i]=St({defaultProp:g,onChange:b}),v=l!==void 0,R=v?l:h,I=at(b),u=k.useCallback(T=>{if(v){let s=typeof T=="function"?T(l):T;s!==l&&I(s)}else i(T)},[v,l,i,I]);return[R,u]}var lt=.3,kt=30,Et=l=>Math.pow(l-1,3)+1,B=(l,g,b)=>Math.max(g,Math.min(l,b)),Ot=({className:l,children:g})=>E.createElement("div",{className:l,"data-rwp-wrapper":!0},g),zt=({defaultValue:l,value:g,onValueChange:b,options:h,infinite:i=!1,visibleCount:v=20,dragSensitivity:R=3,optionItemHeight:I=30,classNames:u})=>{var nt,rt;let[T=(rt=(nt=h[0])==null?void 0:nt.value)!=null?rt:"",j]=ct({defaultProp:l,prop:g,onChange:b}),s=A(()=>{if(!i)return h;let t=[],n=Math.ceil(v/2);if(h.length===0)return t;for(;t.length<n;)t.push(...h);return t},[v,h,i]),d=I,X=d*.5,M=360/v,L=d/Math.tan(M*Math.PI/180),ut=Math.round(L*2+d*.25),S=v>>2,G=R*10,ht=10,p=y(null),W=y(null),H=y(null),m=y(0),Z=y(0),D=y(!1),K=y(0),O=y({startY:0,yList:[],touchScroll:0,isClick:!0}),z=y(null),dt=A(()=>{let t=(e,r,o)=>E.createElement("li",{key:r,className:u==null?void 0:u.optionItem,"data-slot":"option-item","data-rwp-option":!0,"data-index":r,style:{top:-X,height:d,lineHeight:`${d}px`,transform:`rotateX(${o}deg) translateZ(${L}px)`,visibility:"hidden"}},e.label),n=s.map((e,r)=>t(e,r,-M*r));if(i)for(let e=0;e<S;++e){let r=-e-1,o=e+s.length;n.unshift(t(s[s.length-e-1],r,M*(e+1))),n.push(t(s[e],o,-M*o))}return n},[d,X,i,M,s,S,L,u==null?void 0:u.optionItem]),gt=A(()=>{let t=(e,r)=>E.createElement("li",{key:r,className:u==null?void 0:u.highlightItem,"data-slot":"highlight-item","data-rwp-highlight-item":!0,style:{height:d}},e.label),n=s.map((e,r)=>t(e,r));if(i){let e=s[0],r=s[s.length-1];n.unshift(t(r,"infinite-start")),n.push(t(e,"infinite-end"))}return n},[u==null?void 0:u.highlightItem,d,i,s]),ft=A(()=>{let t=0,n=Math.PI/180,e=[];for(let r=S-1;r>=-S+1;--r){let o=r*M,c=d*Math.cos(o*n),a=t;t+=c,e.push([a,t])}return e},[M,d,S]),P=t=>(t%s.length+s.length)%s.length,C=t=>{let n=i?P(t):t;if(W.current){let e=`translateZ(${-L}px) rotateX(${M*n}deg)`;W.current.style.transform=e,W.current.childNodes.forEach(r=>{let o=r,c=Math.abs(Number(o.dataset.index)-n);o.style.visibility=c>S?"hidden":"visible"})}return H.current&&(H.current.style.transform=`translateY(${-n*d}px)`),n},x=()=>{cancelAnimationFrame(Z.current)},_=(t,n,e,r)=>{if(t===n||e===0){C(t);return}let o=performance.now(),c=n-t,a=f=>{let w=(f-o)/1e3;if(w<e){let $=Et(w/e);m.current=C(t+$*c),Z.current=requestAnimationFrame(a)}else x(),m.current=C(n),r==null||r()};requestAnimationFrame(a)},Y=t=>{let n=P(t)|0,e=i?n:Math.min(Math.max(n,0),s.length-1);if(!i&&e!==t)return;m.current=C(e);let r=s[m.current];j(r.value)},pt=t=>{let n=s.findIndex(e=>e.value===t);if(n===-1){console.error("Invalid value selected:",t);return}x(),Y(n)},J=t=>{let n=m.current,e=n+t;i?e=Math.round(e):e=B(Math.round(e),0,s.length-1);let r=Math.abs(e-n);if(r===0)return;let o=Math.sqrt(r/5);x(),_(n,e,o,()=>{Y(m.current)})},mt=t=>{let n=p.current;if(!n){console.error("Container reference is not set.");return}let{top:e}=n.getBoundingClientRect(),r=t-e,o=ft.findIndex(([a,f])=>r>=a&&r<=f);if(o===-1){console.error("No item found for click position:",r);return}let c=(S-o-1)*-1;J(c)},bt=t=>{var n,e;try{let r=(t instanceof MouseEvent?t.clientY:(e=(n=t.touches)==null?void 0:n[0])==null?void 0:e.clientY)||0,o=O.current;o.isClick&&Math.abs(r-o.startY)>5&&(o.isClick=!1),o.yList.push([r,Date.now()]),o.yList.length>5&&o.yList.shift();let c=(o.startY-r)/d,a=m.current+c;if(i)a=P(a);else{let f=s.length;a<0?a*=lt:a>f&&(a=f+(a-f)*lt)}o.touchScroll=C(a)}catch(r){console.error("Error in updateScrollDuringDrag:",r)}},Q=t=>{!D.current&&!p.current.contains(t.target)&&t.target!==p.current||(t.cancelable&&t.preventDefault(),s.length&&bt(t))},V=t=>{var n,e,r;try{D.current=!0;let o=new AbortController,{signal:c}=o;z.current=o;let a={signal:c,passive:!1};(n=p.current)==null||n.addEventListener("touchmove",Q,a),document.addEventListener("mousemove",Q,a);let f=(t instanceof MouseEvent?t.clientY:(r=(e=t.touches)==null?void 0:e[0])==null?void 0:r.clientY)||0,w=O.current;w.startY=f,w.yList=[[f,Date.now()]],w.touchScroll=m.current,w.isClick=!0,x()}catch(o){console.error("Error in initiateDragGesture:",o)}},F=q(t=>{let n=D.current,e=p.current.contains(t.target)||t.target===p.current;(n||e)&&t.cancelable&&(t.preventDefault(),s.length&&V(t))},[V]),vt=t=>{let n=m.current,e=n,r=t>0?-G:G,o=0;if(i){o=Math.abs(t/r);let c=t*o+.5*r*o*o;e=Math.round(n+c)}else if(n<0||n>s.length-1){let c=B(n,0,s.length-1),a=n-c;r=ht,o=Math.sqrt(Math.abs(a/r)),t=r*o,t=n>0?-t:t,e=c}else{o=Math.abs(t/r);let c=t*o+.5*r*o*o;e=Math.round(n+c),e=B(e,0,s.length-1);let a=e-n;o=Math.sqrt(Math.abs(a/r))}_(n,e,o,()=>{Y(m.current)}),Y(m.current)},N=()=>{var t,n,e,r;try{(t=z.current)==null||t.abort(),z.current=null;let o=O.current;if(o.isClick){mt(o.startY);return}let c=o.yList,a=0;if(c.length>1){let f=c.length,[w,$]=(n=c[f-2])!=null?n:[0,0],[wt,yt]=(e=c[f-1])!=null?e:[0,0],ot=yt-$;if(ot>0){let st=(w-wt)/d*1e3/ot,Mt=kt,Tt=st>0?1:-1;a=Math.min(Math.abs(st),Mt)*Tt}}m.current=(r=o.touchScroll)!=null?r:m.current,vt(a)}catch(o){console.error("Error in finalizeDragAndStartInertiaScroll:",o)}finally{D.current=!1}},U=q(t=>{if(!s.length)return;let n=D.current,e=p.current.contains(t.target)||t.target===p.current;(n||e)&&t.cancelable&&(t.preventDefault(),N())},[N]),tt=t=>{t.preventDefault();let n=Date.now();if(n-K.current<100)return;let e=Math.sign(t.deltaY);e&&(K.current=n,J(e))},et=q(t=>{if(!s.length||!p.current)return;let n=D.current,e=p.current.contains(t.target)||t.target===p.current;(n||e)&&t.cancelable&&(t.preventDefault(),tt(t))},[tt]);return it(()=>{let t=p.current;if(!t)return;let n=new AbortController,{signal:e}=n,r={signal:e,passive:!1};return t.addEventListener("touchstart",F,r),t.addEventListener("touchend",U,r),t.addEventListener("wheel",et,r),document.addEventListener("mousedown",F,r),document.addEventListener("mouseup",U,r),()=>n.abort()},[U,F,et]),it(()=>{pt(T)},[T,g]),E.createElement("div",{ref:p,"data-rwp":!0,style:{height:ut}},E.createElement("ul",{ref:W,"data-rwp-options":!0},dt),E.createElement("div",{className:u==null?void 0:u.highlightWrapper,"data-rwp-highlight-wrapper":!0,"data-slot":"highlight-wrapper",style:{height:d,lineHeight:`${d}px`}},E.createElement("ul",{ref:H,"data-rwp-highlight-list":!0,style:{top:i?-d:void 0}},gt)))};export{zt as WheelPicker,Ot as WheelPickerWrapper};
|