@dotss/ui 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@emotion/react/jsx-runtime"),c=require("react"),le=require("@emotion/styled"),ue=require("../hooks/useCheckHasFocus/useCheckHasFocus.cjs"),he=require("../hooks/useCheckHoverPossible/useCheckHoverPossible.cjs"),de=require("../hooks/useCheckKeyboardMode/useCheckKeyboardMode.cjs"),fe=l=>l&&l.__esModule?l:{default:l},D=fe(le),ge=D.default.div`
|
|
2
2
|
list-style-type: none;
|
|
3
3
|
margin: 0;
|
|
4
4
|
padding: 0;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
position: relative;
|
|
9
9
|
cursor: grab;
|
|
10
10
|
transition: transform 0.3s ease-out;
|
|
11
|
-
`,
|
|
11
|
+
`,me=D.default.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
width: auto;
|
|
14
14
|
height: fit-content;
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
@supports not selector(:has(:focus-visible)) {
|
|
41
41
|
${({focusWithin:l,theme:i})=>l?{outline:`${i.palette.grey[100]} solid 2px`}:{}}
|
|
42
42
|
}
|
|
43
|
-
`,
|
|
43
|
+
`,k=D.default.div`
|
|
44
44
|
height: 54px;
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
scroll-snap-align: start;
|
|
49
49
|
position: relative;
|
|
50
50
|
|
|
51
|
-
${({theme:{palette:{grey:l},typography:{h2M:i},spacing:{content:
|
|
51
|
+
${({theme:{palette:{grey:l},typography:{h2M:i},spacing:{content:h}}})=>({fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,color:l[100],padding:h(3)})};
|
|
52
52
|
|
|
53
|
-
${({selected:l,theme:{palette:{grey:i},typography:{h4M:
|
|
54
|
-
`,f=Object.freeze({FRICTION:.95,SNAP_FORCE:.2,SNAP_VELOCITY_THRESHOLD:.04,MIN_VELOCITY:.01,MAX_VELOCITY:1.62,NEAR_ZERO_VELOCITY:.2,BOUNDARY_PX:4}),
|
|
53
|
+
${({selected:l,theme:{palette:{grey:i},typography:{h4M:h}}})=>l?{"&, & *":{color:`${i[100]} !important`}}:{color:`${i[30]} !important`,fontSize:`${h.size} !important`,fontWeight:`${h.weight} !important`,lineHeight:`${h.lineHeight} !important`,letterSpacing:`${h.letterSpacing} !important`,"& *":{color:`${i[30]} !important`}}}
|
|
54
|
+
`,f=Object.freeze({FRICTION:.95,SNAP_FORCE:.2,SNAP_VELOCITY_THRESHOLD:.04,MIN_VELOCITY:.01,MAX_VELOCITY:1.62,NEAR_ZERO_VELOCITY:.2,BOUNDARY_PX:4}),pe=c.forwardRef(function({column:i,value:h=i[0].value,onChange:E,onSpin:S,onSnap:p,renderLabel:N,inlineCSS:$,wrapperProps:x,thumbProps:V,...q},j){const T=i.findIndex(t=>t.value===h),M=c.useRef(T),o=c.useRef(null),[H,v]=c.useState(T*54),[b,L]=c.useState(!1),[P,U]=c.useState(0),[_,W]=c.useState(0),[w,C]=c.useState(!1),[z,O]=c.useState([]),X=c.useId(),d=c.useRef(null),A=c.useRef(T),{isHoverPossible:K}=he.default(),{isKeyboardMode:B}=de.default(),{hasFocus:Z}=ue.default({ref:o}),g=c.useCallback(t=>{const e=Math.max(0,Math.min(Math.round(t/54),i.length-1));e===A.current||!i[e]||(A.current=e,S==null||S(i[e].value))},[i,54,S]),G=t=>{if(t.length<2)return 0;const e=t[0],n=t[t.length-1],r=n.time-e.time,a=n.y-e.y;if(r===0)return 0;const s=a/r;return Math.max(-f.MAX_VELOCITY,Math.min(f.MAX_VELOCITY,s))},J=t=>{d.current&&cancelAnimationFrame(d.current),C(!0);let e=t*-1,n=H,r=performance.now();const a=54*(i.length-1),s=u=>{const m=u-r;r=u,n+=e*m,n<0?(n=0,e=0):n>a&&(n=a,e=0),e*=f.FRICTION,v(n),g(n),o.current&&(o.current.children[0].scrollTop=n);const R=Math.round(n/54)*54,se=Math.abs(n-R),oe=Math.abs(e)<=f.NEAR_ZERO_VELOCITY,ae=Math.abs(e)<=f.SNAP_VELOCITY_THRESHOLD,ce=se<=f.BOUNDARY_PX;oe&&ce||ae?(C(!1),Q(n)):d.current=requestAnimationFrame(s)};d.current=requestAnimationFrame(s)},Q=t=>{d.current&&cancelAnimationFrame(d.current);const e=Math.max(0,Math.min(Math.round(t/54),i.length-1)),n=e*54;M.current=e;const r=a=>{if(Math.abs(a-n)<1)v(n),g(n),o.current&&(o.current.children[0].scrollTop=n),i[e]&&(E(i[e].value),p==null||p(i[e].value));else{const s=a+(n-a)*f.SNAP_FORCE;v(s),g(s),o.current&&(o.current.children[0].scrollTop=s),d.current=requestAnimationFrame(()=>r(s))}};d.current=requestAnimationFrame(()=>r(t))},Y=t=>{L(!0),W(t),U(H),C(!1),O([{time:performance.now(),y:t}])},ee=t=>{if(!b||w)return;const e=_-t;let n=P+e;const r=54*(i.length-1);n<0?n=0:n>r&&(n=r),v(n),g(n),o.current&&(o.current.children[0].scrollTop=n);const a=performance.now();O(s=>[...s,{time:a,y:t}].filter(u=>a-u.time<=100))},te=t=>{var n,r;t.stopPropagation();let e=M.current;t.key==="ArrowUp"?(e+=1,e>i.length-1&&(e=0)):t.key==="ArrowDown"?(e-=1,e<0&&(e=i.length-1)):t.key==="PageUp"?(e+=5,e>i.length-1&&(e=0)):t.key==="PageDown"?(e-=5,e<0&&(e=i.length-1)):t.key==="Home"?e=0:t.key==="End"&&(e=i.length-1),E(i[e].value),M.current=e,(r=(n=o.current)==null?void 0:n.querySelector(`.chain-picker-item[data-index="${M.current}"]`))==null||r.focus()},ie=t=>{t.preventDefault(),t.stopPropagation(),Y(t.clientY)},ne=t=>Y(t.touches[0].clientY),re=t=>{t.preventDefault(),t.stopPropagation(),ee(t.clientY)},I=t=>{if(!b||(L(!1),!K&&t.type==="mouseup"))return;const e=G(z);if(Math.abs(e)<f.MIN_VELOCITY){const r=t.target.closest("[data-index]");if(r){const a=Number(r.dataset.index);if(i[a]&&o.current){const s=o.current.children[0],u=a*54;g(u),s.scrollTo({top:u,behavior:"smooth"});const m=()=>{Math.abs(s.scrollTop-u)<1&&(E(i[a].value),p==null||p(i[a].value),s.removeEventListener("scroll",m))};s.addEventListener("scroll",m)}}return}J(e)};return c.useLayoutEffect(()=>{const t=i.findIndex(n=>n.value===h),e=t*54;v(e),A.current=t,o.current&&(o.current.children[0].scrollTop=e)},[h,i,54]),c.useLayoutEffect(()=>()=>{d.current&&cancelAnimationFrame(d.current)},[]),c.useEffect(()=>{const t=o.current;if(!t)return;const e=n=>{const r=n;if(r.preventDefault(),r.stopPropagation(),!b||w)return;const a=_-r.touches[0].clientY;let s=P+a;const u=54*(i.length-1);s<0?s=0:s>u&&(s=u),v(s),g(s),o.current&&(o.current.children[0].scrollTop=s);const m=performance.now();O(F=>[...F,{time:m,y:r.touches[0].clientY}].filter(R=>m-R.time<=100))};return t.addEventListener("touchmove",e,{passive:!1}),()=>{t.removeEventListener("touchmove",e)}},[b,w,_,P,54,i.length,g]),y.jsx(me,{ref:o,...x,css:x==null?void 0:x.inlineCSS,focusWithin:B&&Z,children:y.jsx(ge,{role:"group",ref:j,css:$,...q,onMouseDown:ie,onMouseMove:re,onMouseUp:I,onMouseLeave:I,onTouchStart:ne,onTouchEnd:I,onTouchCancel:I,children:i.map((t,e)=>{const n=Math.round(H/54),r=e===n;return y.jsxs(c.Fragment,{children:[e===0&&y.jsx(k,{className:"chain-picker-item","data-index":e-1,selected:!1,distance:-1}),y.jsx(k,{className:"chain-picker-item","data-index":e,"data-selected":r,selected:r,distance:e-n,role:"spinbutton",tabIndex:r?0:-1,"aria-hidden":r?"false":"true","aria-valuenow":t.value,"aria-valuetext":t.ariaValueText??t.label,"aria-valuemin":i[0].value,"aria-valuemax":i[i.length-1].value,...V,onKeyDown:te,children:N?N(t,r):t.label}),e===i.length-1&&y.jsx(k,{className:"chain-picker-item","data-index":e+1,selected:!1,distance:i.length-n})]},`${X}_${t.label}`)})})})});exports.default=pe;
|
|
@@ -14,6 +14,8 @@ export interface ChainPickerProps extends GeneralComponentProps<Omit<HTMLAttribu
|
|
|
14
14
|
column: ChainPickerItem[];
|
|
15
15
|
value?: number;
|
|
16
16
|
onChange: (selectedValue: number) => void;
|
|
17
|
+
onSpin?: (selectedValue: number) => void;
|
|
18
|
+
onSnap?: (selectedValue: number) => void;
|
|
17
19
|
renderLabel?: (item: ChainPickerItem, isSelected: boolean) => ReactNode;
|
|
18
20
|
wrapperProps?: GeneralComponentProps<HTMLAttributes<HTMLDivElement>>;
|
|
19
21
|
thumbProps?: GeneralComponentProps<HTMLAttributes<HTMLDivElement>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const
|
|
1
|
+
import { jsx as y, jsxs as ue } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as de, useRef as S, useState as v, useId as fe, useCallback as ge, useLayoutEffect as V, useEffect as me, Fragment as pe } from "react";
|
|
3
|
+
import Y from "@emotion/styled";
|
|
4
|
+
import ve from "../hooks/useCheckHasFocus/useCheckHasFocus.es.js";
|
|
5
|
+
import ye from "../hooks/useCheckHoverPossible/useCheckHoverPossible.es.js";
|
|
6
|
+
import Ie from "../hooks/useCheckKeyboardMode/useCheckKeyboardMode.es.js";
|
|
7
|
+
const be = Y.div`
|
|
8
8
|
list-style-type: none;
|
|
9
9
|
margin: 0;
|
|
10
10
|
padding: 0;
|
|
@@ -14,7 +14,7 @@ const me = O.div`
|
|
|
14
14
|
position: relative;
|
|
15
15
|
cursor: grab;
|
|
16
16
|
transition: transform 0.3s ease-out;
|
|
17
|
-
`,
|
|
17
|
+
`, xe = Y.div`
|
|
18
18
|
position: relative;
|
|
19
19
|
width: auto;
|
|
20
20
|
height: fit-content;
|
|
@@ -48,7 +48,7 @@ const me = O.div`
|
|
|
48
48
|
outline: `${i.palette.grey[100]} solid 2px`
|
|
49
49
|
} : {}}
|
|
50
50
|
}
|
|
51
|
-
`,
|
|
51
|
+
`, _ = Y.div`
|
|
52
52
|
height: 54px;
|
|
53
53
|
display: flex;
|
|
54
54
|
align-items: center;
|
|
@@ -60,7 +60,7 @@ const me = O.div`
|
|
|
60
60
|
theme: {
|
|
61
61
|
palette: { grey: u },
|
|
62
62
|
typography: { h2M: i },
|
|
63
|
-
spacing: { content:
|
|
63
|
+
spacing: { content: l }
|
|
64
64
|
}
|
|
65
65
|
}) => ({
|
|
66
66
|
fontSize: i.size,
|
|
@@ -68,14 +68,14 @@ const me = O.div`
|
|
|
68
68
|
lineHeight: i.lineHeight,
|
|
69
69
|
letterSpacing: i.letterSpacing,
|
|
70
70
|
color: u[100],
|
|
71
|
-
padding:
|
|
71
|
+
padding: l(3)
|
|
72
72
|
})};
|
|
73
73
|
|
|
74
74
|
${({
|
|
75
75
|
selected: u,
|
|
76
76
|
theme: {
|
|
77
77
|
palette: { grey: i },
|
|
78
|
-
typography: { h4M:
|
|
78
|
+
typography: { h4M: l }
|
|
79
79
|
}
|
|
80
80
|
}) => u ? {
|
|
81
81
|
"&, & *": {
|
|
@@ -83,10 +83,10 @@ const me = O.div`
|
|
|
83
83
|
}
|
|
84
84
|
} : {
|
|
85
85
|
color: `${i[30]} !important`,
|
|
86
|
-
fontSize: `${
|
|
87
|
-
fontWeight: `${
|
|
88
|
-
lineHeight: `${
|
|
89
|
-
letterSpacing: `${
|
|
86
|
+
fontSize: `${l.size} !important`,
|
|
87
|
+
fontWeight: `${l.weight} !important`,
|
|
88
|
+
lineHeight: `${l.lineHeight} !important`,
|
|
89
|
+
letterSpacing: `${l.letterSpacing} !important`,
|
|
90
90
|
"& *": {
|
|
91
91
|
color: `${i[30]} !important`
|
|
92
92
|
}
|
|
@@ -105,180 +105,199 @@ const me = O.div`
|
|
|
105
105
|
// px/ms 이 값 이하이면 '거의 멈춤'으로 판단
|
|
106
106
|
BOUNDARY_PX: 4
|
|
107
107
|
// px 아이템 경계(정렬 위치)와의 거리 허용치
|
|
108
|
-
}),
|
|
108
|
+
}), Ce = de(function({
|
|
109
109
|
column: i,
|
|
110
|
-
value:
|
|
111
|
-
onChange:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
110
|
+
value: l = i[0].value,
|
|
111
|
+
onChange: T,
|
|
112
|
+
onSpin: I,
|
|
113
|
+
onSnap: m,
|
|
114
|
+
renderLabel: L,
|
|
115
|
+
inlineCSS: U,
|
|
116
|
+
wrapperProps: b,
|
|
117
|
+
thumbProps: W,
|
|
118
|
+
...q
|
|
119
|
+
}, z) {
|
|
120
|
+
const H = i.findIndex((t) => t.value === l), x = S(H), s = S(null), [P, p] = v(H * 54), [M, R] = v(!1), [w, X] = v(0), [C, j] = v(0), [A, O] = v(!1), [K, k] = v([]), B = fe(), h = S(null), N = S(H), { isHoverPossible: Z } = ye(), { isKeyboardMode: G } = Ie(), { hasFocus: J } = ve({ ref: s }), f = ge(
|
|
121
|
+
(t) => {
|
|
122
|
+
const e = Math.max(
|
|
123
|
+
0,
|
|
124
|
+
Math.min(Math.round(t / 54), i.length - 1)
|
|
125
|
+
);
|
|
126
|
+
e === N.current || !i[e] || (N.current = e, I == null || I(i[e].value));
|
|
127
|
+
},
|
|
128
|
+
[i, 54, I]
|
|
129
|
+
), Q = (t) => {
|
|
130
|
+
if (t.length < 2) return 0;
|
|
131
|
+
const e = t[0], n = t[t.length - 1], r = n.time - e.time, a = n.y - e.y;
|
|
121
132
|
if (r === 0) return 0;
|
|
122
133
|
const o = a / r;
|
|
123
134
|
return Math.max(
|
|
124
135
|
-d.MAX_VELOCITY,
|
|
125
136
|
Math.min(d.MAX_VELOCITY, o)
|
|
126
137
|
);
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
let
|
|
130
|
-
const a = 54 * (i.length - 1), o = (
|
|
131
|
-
const
|
|
132
|
-
r =
|
|
133
|
-
const
|
|
134
|
-
|
|
138
|
+
}, ee = (t) => {
|
|
139
|
+
h.current && cancelAnimationFrame(h.current), O(!0);
|
|
140
|
+
let e = t * -1, n = P, r = performance.now();
|
|
141
|
+
const a = 54 * (i.length - 1), o = (c) => {
|
|
142
|
+
const g = c - r;
|
|
143
|
+
r = c, n += e * g, n < 0 ? (n = 0, e = 0) : n > a && (n = a, e = 0), e *= d.FRICTION, p(n), f(n), s.current && (s.current.children[0].scrollTop = n);
|
|
144
|
+
const D = Math.round(n / 54) * 54, ae = Math.abs(n - D), ce = Math.abs(e) <= d.NEAR_ZERO_VELOCITY, le = Math.abs(e) <= d.SNAP_VELOCITY_THRESHOLD, he = ae <= d.BOUNDARY_PX;
|
|
145
|
+
ce && he || le ? (O(!1), te(n)) : h.current = requestAnimationFrame(o);
|
|
135
146
|
};
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
147
|
+
h.current = requestAnimationFrame(o);
|
|
148
|
+
}, te = (t) => {
|
|
149
|
+
h.current && cancelAnimationFrame(h.current);
|
|
150
|
+
const e = Math.max(0, Math.min(Math.round(t / 54), i.length - 1)), n = e * 54;
|
|
151
|
+
x.current = e;
|
|
141
152
|
const r = (a) => {
|
|
142
153
|
if (Math.abs(a - n) < 1)
|
|
143
|
-
f(n), s.current && (s.current.children[0].scrollTop = n), i[
|
|
154
|
+
p(n), f(n), s.current && (s.current.children[0].scrollTop = n), i[e] && (T(i[e].value), m == null || m(i[e].value));
|
|
144
155
|
else {
|
|
145
156
|
const o = a + (n - a) * d.SNAP_FORCE;
|
|
146
|
-
f(o), s.current && (s.current.children[0].scrollTop = o),
|
|
157
|
+
p(o), f(o), s.current && (s.current.children[0].scrollTop = o), h.current = requestAnimationFrame(() => r(o));
|
|
147
158
|
}
|
|
148
159
|
};
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
if (!
|
|
154
|
-
const
|
|
155
|
-
let n =
|
|
160
|
+
h.current = requestAnimationFrame(() => r(t));
|
|
161
|
+
}, F = (t) => {
|
|
162
|
+
R(!0), j(t), X(P), O(!1), k([{ time: performance.now(), y: t }]);
|
|
163
|
+
}, ie = (t) => {
|
|
164
|
+
if (!M || A) return;
|
|
165
|
+
const e = C - t;
|
|
166
|
+
let n = w + e;
|
|
156
167
|
const r = 54 * (i.length - 1);
|
|
157
|
-
n < 0 ? n = 0 : n > r && (n = r), f(n), s.current && (s.current.children[0].scrollTop = n);
|
|
168
|
+
n < 0 ? n = 0 : n > r && (n = r), p(n), f(n), s.current && (s.current.children[0].scrollTop = n);
|
|
158
169
|
const a = performance.now();
|
|
159
|
-
|
|
160
|
-
(o) => [...o, { time: a, y:
|
|
170
|
+
k(
|
|
171
|
+
(o) => [...o, { time: a, y: t }].filter((c) => a - c.time <= 100)
|
|
161
172
|
);
|
|
162
|
-
},
|
|
173
|
+
}, ne = (t) => {
|
|
163
174
|
var n, r;
|
|
164
|
-
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
if (!
|
|
173
|
-
const
|
|
174
|
-
if (Math.abs(
|
|
175
|
-
const r =
|
|
175
|
+
t.stopPropagation();
|
|
176
|
+
let e = x.current;
|
|
177
|
+
t.key === "ArrowUp" ? (e += 1, e > i.length - 1 && (e = 0)) : t.key === "ArrowDown" ? (e -= 1, e < 0 && (e = i.length - 1)) : t.key === "PageUp" ? (e += 5, e > i.length - 1 && (e = 0)) : t.key === "PageDown" ? (e -= 5, e < 0 && (e = i.length - 1)) : t.key === "Home" ? e = 0 : t.key === "End" && (e = i.length - 1), T(i[e].value), x.current = e, (r = (n = s.current) == null ? void 0 : n.querySelector(`.chain-picker-item[data-index="${x.current}"]`)) == null || r.focus();
|
|
178
|
+
}, re = (t) => {
|
|
179
|
+
t.preventDefault(), t.stopPropagation(), F(t.clientY);
|
|
180
|
+
}, oe = (t) => F(t.touches[0].clientY), se = (t) => {
|
|
181
|
+
t.preventDefault(), t.stopPropagation(), ie(t.clientY);
|
|
182
|
+
}, E = (t) => {
|
|
183
|
+
if (!M || (R(!1), !Z && t.type === "mouseup")) return;
|
|
184
|
+
const e = Q(K);
|
|
185
|
+
if (Math.abs(e) < d.MIN_VELOCITY) {
|
|
186
|
+
const r = t.target.closest("[data-index]");
|
|
176
187
|
if (r) {
|
|
177
188
|
const a = Number(r.dataset.index);
|
|
178
189
|
if (i[a] && s.current) {
|
|
179
|
-
const o = s.current.children[0];
|
|
180
|
-
o.scrollTo({
|
|
181
|
-
top:
|
|
190
|
+
const o = s.current.children[0], c = a * 54;
|
|
191
|
+
f(c), o.scrollTo({
|
|
192
|
+
top: c,
|
|
182
193
|
behavior: "smooth"
|
|
183
194
|
});
|
|
184
|
-
const
|
|
185
|
-
Math.abs(o.scrollTop -
|
|
195
|
+
const g = () => {
|
|
196
|
+
Math.abs(o.scrollTop - c) < 1 && (T(i[a].value), m == null || m(i[a].value), o.removeEventListener("scroll", g));
|
|
186
197
|
};
|
|
187
|
-
o.addEventListener("scroll",
|
|
198
|
+
o.addEventListener("scroll", g);
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
201
|
return;
|
|
191
202
|
}
|
|
192
|
-
|
|
203
|
+
ee(e);
|
|
193
204
|
};
|
|
194
|
-
return
|
|
195
|
-
const t = i.findIndex((n) => n.value ===
|
|
196
|
-
|
|
197
|
-
}, [
|
|
198
|
-
|
|
199
|
-
}, []),
|
|
200
|
-
const
|
|
201
|
-
if (!
|
|
202
|
-
const
|
|
205
|
+
return V(() => {
|
|
206
|
+
const t = i.findIndex((n) => n.value === l), e = t * 54;
|
|
207
|
+
p(e), N.current = t, s.current && (s.current.children[0].scrollTop = e);
|
|
208
|
+
}, [l, i, 54]), V(() => () => {
|
|
209
|
+
h.current && cancelAnimationFrame(h.current);
|
|
210
|
+
}, []), me(() => {
|
|
211
|
+
const t = s.current;
|
|
212
|
+
if (!t) return;
|
|
213
|
+
const e = (n) => {
|
|
203
214
|
const r = n;
|
|
204
|
-
if (r.preventDefault(), r.stopPropagation(), !
|
|
205
|
-
const a =
|
|
206
|
-
let o =
|
|
207
|
-
const
|
|
208
|
-
o < 0 ? o = 0 : o >
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
(
|
|
212
|
-
(
|
|
215
|
+
if (r.preventDefault(), r.stopPropagation(), !M || A) return;
|
|
216
|
+
const a = C - r.touches[0].clientY;
|
|
217
|
+
let o = w + a;
|
|
218
|
+
const c = 54 * (i.length - 1);
|
|
219
|
+
o < 0 ? o = 0 : o > c && (o = c), p(o), f(o), s.current && (s.current.children[0].scrollTop = o);
|
|
220
|
+
const g = performance.now();
|
|
221
|
+
k(
|
|
222
|
+
($) => [...$, { time: g, y: r.touches[0].clientY }].filter(
|
|
223
|
+
(D) => g - D.time <= 100
|
|
213
224
|
)
|
|
214
225
|
);
|
|
215
226
|
};
|
|
216
|
-
return
|
|
217
|
-
|
|
227
|
+
return t.addEventListener("touchmove", e, { passive: !1 }), () => {
|
|
228
|
+
t.removeEventListener("touchmove", e);
|
|
218
229
|
};
|
|
219
|
-
}, [
|
|
220
|
-
|
|
230
|
+
}, [
|
|
231
|
+
M,
|
|
232
|
+
A,
|
|
233
|
+
C,
|
|
234
|
+
w,
|
|
235
|
+
54,
|
|
236
|
+
i.length,
|
|
237
|
+
f
|
|
238
|
+
]), /* @__PURE__ */ y(
|
|
239
|
+
xe,
|
|
221
240
|
{
|
|
222
241
|
ref: s,
|
|
223
|
-
...
|
|
224
|
-
css:
|
|
225
|
-
focusWithin:
|
|
226
|
-
children: /* @__PURE__ */
|
|
227
|
-
|
|
242
|
+
...b,
|
|
243
|
+
css: b == null ? void 0 : b.inlineCSS,
|
|
244
|
+
focusWithin: G && J,
|
|
245
|
+
children: /* @__PURE__ */ y(
|
|
246
|
+
be,
|
|
228
247
|
{
|
|
229
248
|
role: "group",
|
|
230
|
-
ref:
|
|
231
|
-
css:
|
|
232
|
-
|
|
233
|
-
onMouseDown:
|
|
234
|
-
onMouseMove:
|
|
235
|
-
onMouseUp:
|
|
236
|
-
onMouseLeave:
|
|
237
|
-
onTouchStart:
|
|
238
|
-
onTouchEnd:
|
|
239
|
-
onTouchCancel:
|
|
240
|
-
children: i.map((
|
|
241
|
-
const n = Math.round(
|
|
242
|
-
return /* @__PURE__ */
|
|
243
|
-
|
|
244
|
-
|
|
249
|
+
ref: z,
|
|
250
|
+
css: U,
|
|
251
|
+
...q,
|
|
252
|
+
onMouseDown: re,
|
|
253
|
+
onMouseMove: se,
|
|
254
|
+
onMouseUp: E,
|
|
255
|
+
onMouseLeave: E,
|
|
256
|
+
onTouchStart: oe,
|
|
257
|
+
onTouchEnd: E,
|
|
258
|
+
onTouchCancel: E,
|
|
259
|
+
children: i.map((t, e) => {
|
|
260
|
+
const n = Math.round(P / 54), r = e === n;
|
|
261
|
+
return /* @__PURE__ */ ue(pe, { children: [
|
|
262
|
+
e === 0 && /* @__PURE__ */ y(
|
|
263
|
+
_,
|
|
245
264
|
{
|
|
246
265
|
className: "chain-picker-item",
|
|
247
|
-
"data-index":
|
|
266
|
+
"data-index": e - 1,
|
|
248
267
|
selected: !1,
|
|
249
268
|
distance: -1
|
|
250
269
|
}
|
|
251
270
|
),
|
|
252
|
-
/* @__PURE__ */
|
|
253
|
-
|
|
271
|
+
/* @__PURE__ */ y(
|
|
272
|
+
_,
|
|
254
273
|
{
|
|
255
274
|
className: "chain-picker-item",
|
|
256
|
-
"data-index":
|
|
275
|
+
"data-index": e,
|
|
257
276
|
"data-selected": r,
|
|
258
277
|
selected: r,
|
|
259
|
-
distance:
|
|
278
|
+
distance: e - n,
|
|
260
279
|
role: "spinbutton",
|
|
261
280
|
tabIndex: r ? 0 : -1,
|
|
262
281
|
"aria-hidden": r ? "false" : "true",
|
|
263
|
-
"aria-valuenow":
|
|
264
|
-
"aria-valuetext":
|
|
282
|
+
"aria-valuenow": t.value,
|
|
283
|
+
"aria-valuetext": t.ariaValueText ?? t.label,
|
|
265
284
|
"aria-valuemin": i[0].value,
|
|
266
285
|
"aria-valuemax": i[i.length - 1].value,
|
|
267
|
-
...
|
|
268
|
-
onKeyDown:
|
|
269
|
-
children:
|
|
286
|
+
...W,
|
|
287
|
+
onKeyDown: ne,
|
|
288
|
+
children: L ? L(t, r) : t.label
|
|
270
289
|
}
|
|
271
290
|
),
|
|
272
|
-
|
|
273
|
-
|
|
291
|
+
e === i.length - 1 && /* @__PURE__ */ y(
|
|
292
|
+
_,
|
|
274
293
|
{
|
|
275
294
|
className: "chain-picker-item",
|
|
276
|
-
"data-index":
|
|
295
|
+
"data-index": e + 1,
|
|
277
296
|
selected: !1,
|
|
278
297
|
distance: i.length - n
|
|
279
298
|
}
|
|
280
299
|
)
|
|
281
|
-
] }, `${
|
|
300
|
+
] }, `${B}_${t.label}`);
|
|
282
301
|
})
|
|
283
302
|
}
|
|
284
303
|
)
|
|
@@ -286,5 +305,5 @@ const me = O.div`
|
|
|
286
305
|
);
|
|
287
306
|
});
|
|
288
307
|
export {
|
|
289
|
-
|
|
308
|
+
Ce as default
|
|
290
309
|
};
|