@dotss/ui 1.0.7 → 1.0.9
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/Backdrop/Backdrop.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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 f=require("@emotion/react/jsx-runtime"),s=require("react"),M=require("react-dom"),O=require("@emotion/styled"),W=e=>e&&e.__esModule?e:{default:e},S=W(O),_=S.default.div`
|
|
2
2
|
position: fixed;
|
|
3
3
|
|
|
4
|
-
${({hasContainer:e,containerTop:
|
|
4
|
+
${({hasContainer:e,containerTop:o,containerLeft:u,containerWidth:d,containerHeight:i})=>e?{top:o,left:u,width:d,height:i}:{top:0,left:0,width:"100%",height:"100%"}};
|
|
5
5
|
|
|
6
6
|
z-index: 100000;
|
|
7
7
|
|
|
8
8
|
background-color: ${({theme:{palette:{etc:e}}})=>e.dimmed01};
|
|
9
9
|
transition: opacity ${({transitionDuration:e})=>e}ms;
|
|
10
10
|
opacity: ${({open:e})=>e?1:0};
|
|
11
|
-
`,
|
|
11
|
+
`,k=S.default.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
|
|
14
|
-
${({theme:{spacing:e},fullScreen:
|
|
14
|
+
${({theme:{spacing:e},fullScreen:o})=>o?{width:"100%",height:"100%"}:{width:`calc(100% - ${e.content(10)}px)`,height:`calc(100% - ${e.content(10)}px)`,margin:e.content(5)}};
|
|
15
15
|
|
|
16
16
|
${({centered:e})=>e?{display:"flex",alignItems:"center",justifyContent:"center"}:null}}
|
|
17
|
-
`,
|
|
17
|
+
`,A=s.forwardRef(function({children:o,open:u,onClose:d,transitionDuration:i=200,fullScreen:a,centered:h,containerRef:r,inlineCSS:m,disablePortal:q=!1,...p},y){const[g,T]=s.useState(!1),[z,v]=s.useState(!0),[w,I]=s.useState(0),[x,L]=s.useState(0),[b,B]=s.useState(0),[C,H]=s.useState(0),c=s.useRef(),n=s.useRef(),$=!!(r!=null&&r.current);return s.useEffect(()=>{u&&(n.current&&clearTimeout(n.current),document.body.style.overflow="hidden",v(!1),c.current=setTimeout(()=>{T(!0)},100))},[u]),s.useEffect(()=>{u||(c.current&&clearTimeout(c.current),document.body.removeAttribute("style"),T(!1),n.current=setTimeout(()=>{v(!0)},i))},[u,i]),s.useEffect(()=>{const t=r==null?void 0:r.current,l=()=>{var j;t&&(I((t==null?void 0:t.offsetTop)||0),L(((j=t.getBoundingClientRect())==null?void 0:j.left)||0),B((t==null?void 0:t.offsetWidth)||0),H((t==null?void 0:t.offsetHeight)||0))};return t&&(l(),window.addEventListener("resize",l)),()=>{t&&window.removeEventListener("resize",l)}},[r]),s.useEffect(()=>()=>{document.body.removeAttribute("style"),c.current&&clearTimeout(c.current),n.current&&clearTimeout(n.current)},[]),z?null:q?f.jsx(_,{ref:y,open:g,transitionDuration:i,onClick:d,hasContainer:$,containerTop:w,containerLeft:x,containerWidth:b,containerHeight:C,...p,css:m,children:f.jsx(k,{fullScreen:a,centered:h,children:o})}):M.createPortal(f.jsx(_,{ref:y,open:g,transitionDuration:i,onClick:d,hasContainer:$,containerTop:w,containerLeft:x,containerWidth:b,containerHeight:C,...p,css:m,children:f.jsx(k,{fullScreen:a,centered:h,children:o})}),document.body)});exports.default=A;
|
package/Backdrop/Backdrop.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface BackdropProps extends GeneralComponentProps<HTMLAttributes<HTML
|
|
|
8
8
|
fullScreen?: boolean;
|
|
9
9
|
centered?: boolean;
|
|
10
10
|
containerRef?: RefObject<HTMLElement>;
|
|
11
|
+
disablePortal?: boolean;
|
|
11
12
|
}
|
|
12
13
|
declare const Backdrop: import('react').ForwardRefExoticComponent<BackdropProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
13
14
|
export default Backdrop;
|
package/Backdrop/Backdrop.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsx as f } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as F, useState as n, useRef as I, useEffect as l } from "react";
|
|
3
|
+
import { createPortal as G } from "react-dom";
|
|
4
|
+
import H from "@emotion/styled";
|
|
5
|
+
const L = H.div`
|
|
6
6
|
position: fixed;
|
|
7
7
|
|
|
8
|
-
${({ hasContainer: t, containerTop:
|
|
9
|
-
top:
|
|
10
|
-
left:
|
|
11
|
-
width:
|
|
12
|
-
height:
|
|
8
|
+
${({ hasContainer: t, containerTop: o, containerLeft: i, containerWidth: d, containerHeight: s }) => t ? {
|
|
9
|
+
top: o,
|
|
10
|
+
left: i,
|
|
11
|
+
width: d,
|
|
12
|
+
height: s
|
|
13
13
|
} : {
|
|
14
14
|
top: 0,
|
|
15
15
|
left: 0,
|
|
@@ -26,10 +26,10 @@ const S = T.div`
|
|
|
26
26
|
}) => t.dimmed01};
|
|
27
27
|
transition: opacity ${({ transitionDuration: t }) => t}ms;
|
|
28
28
|
opacity: ${({ open: t }) => t ? 1 : 0};
|
|
29
|
-
`,
|
|
29
|
+
`, B = H.div`
|
|
30
30
|
position: relative;
|
|
31
31
|
|
|
32
|
-
${({ theme: { spacing: t }, fullScreen:
|
|
32
|
+
${({ theme: { spacing: t }, fullScreen: o }) => o ? {
|
|
33
33
|
width: "100%",
|
|
34
34
|
height: "100%"
|
|
35
35
|
} : {
|
|
@@ -43,57 +43,74 @@ const S = T.div`
|
|
|
43
43
|
alignItems: "center",
|
|
44
44
|
justifyContent: "center"
|
|
45
45
|
} : null}}
|
|
46
|
-
`,
|
|
47
|
-
children:
|
|
48
|
-
open:
|
|
49
|
-
onClose:
|
|
50
|
-
transitionDuration:
|
|
51
|
-
fullScreen:
|
|
52
|
-
centered:
|
|
46
|
+
`, Q = F(function({
|
|
47
|
+
children: o,
|
|
48
|
+
open: i,
|
|
49
|
+
onClose: d,
|
|
50
|
+
transitionDuration: s = 200,
|
|
51
|
+
fullScreen: h,
|
|
52
|
+
centered: p,
|
|
53
53
|
containerRef: r,
|
|
54
|
-
inlineCSS:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
inlineCSS: a,
|
|
55
|
+
disablePortal: W = !1,
|
|
56
|
+
...y
|
|
57
|
+
}, T) {
|
|
58
|
+
const [g, w] = n(!1), [j, v] = n(!0), [C, A] = n(0), [$, O] = n(0), [b, P] = n(0), [x, q] = n(0), c = I(), u = I(), k = !!(r != null && r.current);
|
|
59
|
+
return l(() => {
|
|
60
|
+
i && (u.current && clearTimeout(u.current), document.body.style.overflow = "hidden", v(!1), c.current = setTimeout(() => {
|
|
61
|
+
w(!0);
|
|
61
62
|
}, 100));
|
|
62
|
-
}, [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
}, [
|
|
67
|
-
const e = r == null ? void 0 : r.current,
|
|
68
|
-
var
|
|
69
|
-
e && (
|
|
63
|
+
}, [i]), l(() => {
|
|
64
|
+
i || (c.current && clearTimeout(c.current), document.body.removeAttribute("style"), w(!1), u.current = setTimeout(() => {
|
|
65
|
+
v(!0);
|
|
66
|
+
}, s));
|
|
67
|
+
}, [i, s]), l(() => {
|
|
68
|
+
const e = r == null ? void 0 : r.current, m = () => {
|
|
69
|
+
var z;
|
|
70
|
+
e && (A((e == null ? void 0 : e.offsetTop) || 0), O(((z = e.getBoundingClientRect()) == null ? void 0 : z.left) || 0), P((e == null ? void 0 : e.offsetWidth) || 0), q((e == null ? void 0 : e.offsetHeight) || 0));
|
|
70
71
|
};
|
|
71
|
-
return e && (
|
|
72
|
-
e && window.removeEventListener("resize",
|
|
72
|
+
return e && (m(), window.addEventListener("resize", m)), () => {
|
|
73
|
+
e && window.removeEventListener("resize", m);
|
|
73
74
|
};
|
|
74
|
-
}, [r]),
|
|
75
|
+
}, [r]), l(() => () => {
|
|
75
76
|
document.body.removeAttribute("style"), c.current && clearTimeout(c.current), u.current && clearTimeout(u.current);
|
|
76
|
-
}, []),
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
}, []), j ? null : W ? /* @__PURE__ */ f(
|
|
78
|
+
L,
|
|
79
|
+
{
|
|
80
|
+
ref: T,
|
|
81
|
+
open: g,
|
|
82
|
+
transitionDuration: s,
|
|
83
|
+
onClick: d,
|
|
84
|
+
hasContainer: k,
|
|
85
|
+
containerTop: C,
|
|
86
|
+
containerLeft: $,
|
|
87
|
+
containerWidth: b,
|
|
88
|
+
containerHeight: x,
|
|
89
|
+
...y,
|
|
90
|
+
css: a,
|
|
91
|
+
children: /* @__PURE__ */ f(B, { fullScreen: h, centered: p, children: o })
|
|
92
|
+
}
|
|
93
|
+
) : G(
|
|
94
|
+
/* @__PURE__ */ f(
|
|
95
|
+
L,
|
|
79
96
|
{
|
|
80
|
-
ref:
|
|
81
|
-
open:
|
|
82
|
-
transitionDuration:
|
|
83
|
-
onClick:
|
|
84
|
-
hasContainer:
|
|
85
|
-
containerTop:
|
|
86
|
-
containerLeft:
|
|
87
|
-
containerWidth:
|
|
88
|
-
containerHeight:
|
|
89
|
-
...
|
|
90
|
-
css:
|
|
91
|
-
children: /* @__PURE__ */
|
|
97
|
+
ref: T,
|
|
98
|
+
open: g,
|
|
99
|
+
transitionDuration: s,
|
|
100
|
+
onClick: d,
|
|
101
|
+
hasContainer: k,
|
|
102
|
+
containerTop: C,
|
|
103
|
+
containerLeft: $,
|
|
104
|
+
containerWidth: b,
|
|
105
|
+
containerHeight: x,
|
|
106
|
+
...y,
|
|
107
|
+
css: a,
|
|
108
|
+
children: /* @__PURE__ */ f(B, { fullScreen: h, centered: p, children: o })
|
|
92
109
|
}
|
|
93
110
|
),
|
|
94
111
|
document.body
|
|
95
112
|
);
|
|
96
113
|
});
|
|
97
114
|
export {
|
|
98
|
-
|
|
115
|
+
Q as default
|
|
99
116
|
};
|
|
@@ -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 p=require("@emotion/react/jsx-runtime"),c=require("react"),oe=require("@emotion/styled"),se=require("../hooks/useCheckHasFocus/useCheckHasFocus.cjs"),ae=require("../hooks/useCheckHoverPossible/useCheckHoverPossible.cjs"),ce=require("../hooks/useCheckKeyboardMode/useCheckKeyboardMode.cjs"),le=l=>l&&l.__esModule?l:{default:l},C=le(oe),ue=C.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
|
+
`,de=C.default.div`
|
|
12
12
|
position: relative;
|
|
13
13
|
width: auto;
|
|
14
14
|
height: fit-content;
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
|
|
34
34
|
@supports selector(:has(:focus-visible)) {
|
|
35
35
|
&:has(:focus-visible) {
|
|
36
|
-
outline: ${({theme:
|
|
36
|
+
outline: ${({theme:l})=>l.palette.grey[100]} solid 2px;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@supports not selector(:has(:focus-visible)) {
|
|
41
|
-
${({focusWithin:
|
|
41
|
+
${({focusWithin:l,theme:i})=>l?{outline:`${i.palette.grey[100]} solid 2px`}:{}}
|
|
42
42
|
}
|
|
43
|
-
`,
|
|
43
|
+
`,w=C.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:
|
|
51
|
+
${({theme:{palette:{grey:l},typography:{h2M:i},spacing:{content:u}}})=>({fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,color:l[100],padding:u(3)})};
|
|
52
52
|
|
|
53
|
-
${({selected:
|
|
54
|
-
`,
|
|
53
|
+
${({selected:l,theme:{palette:{grey:i},typography:{h4M:u}}})=>l?{"&, & *":{color:`${i[100]} !important`}}:{color:`${i[30]} !important`,fontSize:`${u.size} !important`,fontWeight:`${u.weight} !important`,lineHeight:`${u.lineHeight} !important`,letterSpacing:`${u.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}),he=c.forwardRef(function({column:i,value:u=i[0].value,onChange:b,renderLabel:O,inlineCSS:R,wrapperProps:m,thumbProps:L,...Y},F){const A=i.findIndex(e=>e.value===u),S=c.useRef(A),s=c.useRef(null),[E,g]=c.useState(A*54),[y,D]=c.useState(!1),[I,$]=c.useState(0),[M,V]=c.useState(0),[T,H]=c.useState(!1),[q,P]=c.useState([]),j=c.useId(),d=c.useRef(null),{isHoverPossible:U}=ae.default(),{isKeyboardMode:W}=ce.default(),{hasFocus:z}=se.default({ref:s}),X=e=>{if(e.length<2)return 0;const t=e[0],n=e[e.length-1],r=n.time-t.time,a=n.y-t.y;if(r===0)return 0;const o=a/r;return Math.max(-f.MAX_VELOCITY,Math.min(f.MAX_VELOCITY,o))},K=e=>{d.current&&cancelAnimationFrame(d.current),H(!0);let t=e*-1,n=E,r=performance.now();const a=54*(i.length-1),o=h=>{const x=h-r;r=h,n+=t*x,n<0?(n=0,t=0):n>a&&(n=a,t=0),t*=f.FRICTION,g(n),s.current&&(s.current.children[0].scrollTop=n);const _=Math.round(n/54)*54,te=Math.abs(n-_),ne=Math.abs(t)<=f.NEAR_ZERO_VELOCITY,ie=Math.abs(t)<=f.SNAP_VELOCITY_THRESHOLD,re=te<=f.BOUNDARY_PX;ne&&re||ie?(H(!1),B(n)):d.current=requestAnimationFrame(o)};d.current=requestAnimationFrame(o)},B=e=>{d.current&&cancelAnimationFrame(d.current);const t=Math.max(0,Math.min(Math.round(e/54),i.length-1)),n=t*54;S.current=t;const r=a=>{if(Math.abs(a-n)<1)g(n),s.current&&(s.current.children[0].scrollTop=n),i[t]&&b(i[t].value);else{const o=a+(n-a)*f.SNAP_FORCE;g(o),s.current&&(s.current.children[0].scrollTop=o),d.current=requestAnimationFrame(()=>r(o))}};d.current=requestAnimationFrame(()=>r(e))},N=e=>{D(!0),V(e),$(E),H(!1),P([{time:performance.now(),y:e}])},Z=e=>{if(!y||T)return;const t=M-e;let n=I+t;const r=54*(i.length-1);n<0?n=0:n>r&&(n=r),g(n),s.current&&(s.current.children[0].scrollTop=n);const a=performance.now();P(o=>[...o,{time:a,y:e}].filter(h=>a-h.time<=100))},G=e=>{var n,r;e.stopPropagation();let t=S.current;e.key==="ArrowUp"?(t+=1,t>i.length-1&&(t=0)):e.key==="ArrowDown"?(t-=1,t<0&&(t=i.length-1)):e.key==="PageUp"?(t+=5,t>i.length-1&&(t=0)):e.key==="PageDown"?(t-=5,t<0&&(t=i.length-1)):e.key==="Home"?t=0:e.key==="End"&&(t=i.length-1),b(i[t].value),S.current=t,(r=(n=s.current)==null?void 0:n.querySelector(`.chain-picker-item[data-index="${S.current}"]`))==null||r.focus()},J=e=>{e.preventDefault(),e.stopPropagation(),N(e.clientY)},Q=e=>N(e.touches[0].clientY),ee=e=>{e.preventDefault(),e.stopPropagation(),Z(e.clientY)},v=e=>{if(!y||(D(!1),!U&&e.type==="mouseup"))return;const t=X(q);if(Math.abs(t)<f.MIN_VELOCITY){const r=e.target.closest("[data-index]");if(r){const a=Number(r.dataset.index);if(i[a]&&s.current){const o=s.current.children[0];o.scrollTo({top:a*54,behavior:"smooth"});const h=()=>{Math.abs(o.scrollTop-a*54)<1&&(b(i[a].value),o.removeEventListener("scroll",h))};o.addEventListener("scroll",h)}}return}K(t)};return c.useLayoutEffect(()=>{const t=i.findIndex(n=>n.value===u)*54;g(t),s.current&&(s.current.children[0].scrollTop=t)},[u,i,54]),c.useLayoutEffect(()=>()=>{d.current&&cancelAnimationFrame(d.current)},[]),c.useEffect(()=>{const e=s.current;if(!e)return;const t=n=>{const r=n;if(r.preventDefault(),r.stopPropagation(),!y||T)return;const a=M-r.touches[0].clientY;let o=I+a;const h=54*(i.length-1);o<0?o=0:o>h&&(o=h),g(o),s.current&&(s.current.children[0].scrollTop=o);const x=performance.now();P(k=>[...k,{time:x,y:r.touches[0].clientY}].filter(_=>x-_.time<=100))};return e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("touchmove",t)}},[y,T,M,I,54,i.length]),p.jsx(de,{ref:s,...m,css:m==null?void 0:m.inlineCSS,focusWithin:W&&z,children:p.jsx(ue,{role:"group",ref:F,css:R,...Y,onMouseDown:J,onMouseMove:ee,onMouseUp:v,onMouseLeave:v,onTouchStart:Q,onTouchEnd:v,onTouchCancel:v,children:i.map((e,t)=>{const n=Math.round(E/54),r=t===n;return p.jsxs(c.Fragment,{children:[t===0&&p.jsx(w,{className:"chain-picker-item","data-index":t-1,selected:!1,distance:-1}),p.jsx(w,{className:"chain-picker-item","data-index":t,"data-selected":r,selected:r,distance:t-n,role:"spinbutton",tabIndex:r?0:-1,"aria-hidden":r?"false":"true","aria-valuenow":e.value,"aria-valuetext":e.ariaValueText??e.label,"aria-valuemin":i[0].value,"aria-valuemax":i[i.length-1].value,...L,onKeyDown:G,children:O?O(e,r):e.label}),t===i.length-1&&p.jsx(w,{className:"chain-picker-item","data-index":t+1,selected:!1,distance:i.length-n})]},`${j}_${e.label}`)})})})});exports.default=he;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { GeneralComponentProps } from '../typings/component';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export interface VelocitySample {
|
|
5
|
+
time: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
5
8
|
export interface ChainPickerItem {
|
|
6
9
|
label: string;
|
|
7
10
|
value: number;
|
|
@@ -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 m, jsxs as ae } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ce, useRef as C, useState as g, useId as le, useLayoutEffect as L, useEffect as he, Fragment as ue } from "react";
|
|
3
|
+
import O from "@emotion/styled";
|
|
4
|
+
import de from "../hooks/useCheckHasFocus/useCheckHasFocus.es.js";
|
|
5
|
+
import fe from "../hooks/useCheckHoverPossible/useCheckHoverPossible.es.js";
|
|
6
|
+
import ge from "../hooks/useCheckKeyboardMode/useCheckKeyboardMode.es.js";
|
|
7
|
+
const me = O.div`
|
|
8
8
|
list-style-type: none;
|
|
9
9
|
margin: 0;
|
|
10
10
|
padding: 0;
|
|
@@ -14,7 +14,7 @@ const ie = H.div`
|
|
|
14
14
|
position: relative;
|
|
15
15
|
cursor: grab;
|
|
16
16
|
transition: transform 0.3s ease-out;
|
|
17
|
-
`,
|
|
17
|
+
`, pe = O.div`
|
|
18
18
|
position: relative;
|
|
19
19
|
width: auto;
|
|
20
20
|
height: fit-content;
|
|
@@ -39,16 +39,16 @@ const ie = H.div`
|
|
|
39
39
|
|
|
40
40
|
@supports selector(:has(:focus-visible)) {
|
|
41
41
|
&:has(:focus-visible) {
|
|
42
|
-
outline: ${({ theme:
|
|
42
|
+
outline: ${({ theme: u }) => u.palette.grey[100]} solid 2px;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
@supports not selector(:has(:focus-visible)) {
|
|
47
|
-
${({ focusWithin:
|
|
48
|
-
outline: `${
|
|
47
|
+
${({ focusWithin: u, theme: i }) => u ? {
|
|
48
|
+
outline: `${i.palette.grey[100]} solid 2px`
|
|
49
49
|
} : {}}
|
|
50
50
|
}
|
|
51
|
-
`,
|
|
51
|
+
`, A = O.div`
|
|
52
52
|
height: 54px;
|
|
53
53
|
display: flex;
|
|
54
54
|
align-items: center;
|
|
@@ -58,162 +58,227 @@ const ie = H.div`
|
|
|
58
58
|
|
|
59
59
|
${({
|
|
60
60
|
theme: {
|
|
61
|
-
palette: { grey:
|
|
62
|
-
typography: { h2M:
|
|
63
|
-
spacing: { content:
|
|
61
|
+
palette: { grey: u },
|
|
62
|
+
typography: { h2M: i },
|
|
63
|
+
spacing: { content: c }
|
|
64
64
|
}
|
|
65
65
|
}) => ({
|
|
66
|
-
fontSize:
|
|
67
|
-
fontWeight:
|
|
68
|
-
lineHeight:
|
|
69
|
-
letterSpacing:
|
|
70
|
-
color:
|
|
71
|
-
padding:
|
|
66
|
+
fontSize: i.size,
|
|
67
|
+
fontWeight: i.weight,
|
|
68
|
+
lineHeight: i.lineHeight,
|
|
69
|
+
letterSpacing: i.letterSpacing,
|
|
70
|
+
color: u[100],
|
|
71
|
+
padding: c(3)
|
|
72
72
|
})};
|
|
73
73
|
|
|
74
74
|
${({
|
|
75
|
-
selected:
|
|
75
|
+
selected: u,
|
|
76
76
|
theme: {
|
|
77
|
-
palette: { grey:
|
|
78
|
-
typography: { h4M:
|
|
77
|
+
palette: { grey: i },
|
|
78
|
+
typography: { h4M: c }
|
|
79
79
|
}
|
|
80
|
-
}) =>
|
|
80
|
+
}) => u ? {
|
|
81
81
|
"&, & *": {
|
|
82
|
-
color: `${
|
|
82
|
+
color: `${i[100]} !important`
|
|
83
83
|
}
|
|
84
84
|
} : {
|
|
85
|
-
color: `${
|
|
86
|
-
fontSize: `${
|
|
87
|
-
fontWeight: `${
|
|
88
|
-
lineHeight: `${
|
|
89
|
-
letterSpacing: `${
|
|
85
|
+
color: `${i[30]} !important`,
|
|
86
|
+
fontSize: `${c.size} !important`,
|
|
87
|
+
fontWeight: `${c.weight} !important`,
|
|
88
|
+
lineHeight: `${c.lineHeight} !important`,
|
|
89
|
+
letterSpacing: `${c.letterSpacing} !important`,
|
|
90
90
|
"& *": {
|
|
91
|
-
color: `${
|
|
91
|
+
color: `${i[30]} !important`
|
|
92
92
|
}
|
|
93
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
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
94
|
+
`, d = Object.freeze({
|
|
95
|
+
FRICTION: 0.95,
|
|
96
|
+
// 마찰 계수
|
|
97
|
+
SNAP_FORCE: 0.2,
|
|
98
|
+
// 스냅 강도: 최종값 결정시 얼마나 빠르게 값을 결정할 것인지?
|
|
99
|
+
SNAP_VELOCITY_THRESHOLD: 0.04,
|
|
100
|
+
// 0.1px/frame
|
|
101
|
+
MIN_VELOCITY: 0.01,
|
|
102
|
+
MAX_VELOCITY: 1.62,
|
|
103
|
+
// px/ms 단위 (27px/frame = 1.619px/ms, 한 프레임에 요소의 최대 절반까지 이동 가능, 60fps 기준)
|
|
104
|
+
NEAR_ZERO_VELOCITY: 0.2,
|
|
105
|
+
// px/ms 이 값 이하이면 '거의 멈춤'으로 판단
|
|
106
|
+
BOUNDARY_PX: 4
|
|
107
|
+
// px 아이템 경계(정렬 위치)와의 거리 허용치
|
|
108
|
+
}), Te = ce(function({
|
|
109
|
+
column: i,
|
|
110
|
+
value: c = i[0].value,
|
|
111
|
+
onChange: b,
|
|
112
|
+
renderLabel: N,
|
|
113
|
+
inlineCSS: F,
|
|
114
|
+
wrapperProps: p,
|
|
115
|
+
thumbProps: R,
|
|
116
|
+
...$
|
|
117
|
+
}, V) {
|
|
118
|
+
const k = i.findIndex((e) => e.value === c), S = C(k), s = C(null), [E, f] = g(k * 54), [y, D] = g(!1), [x, U] = g(0), [T, W] = g(0), [M, H] = g(!1), [q, w] = g([]), z = le(), l = C(null), { isHoverPossible: X } = fe(), { isKeyboardMode: j } = ge(), { hasFocus: K } = de({ ref: s }), B = (e) => {
|
|
119
|
+
if (e.length < 2) return 0;
|
|
120
|
+
const t = e[0], n = e[e.length - 1], r = n.time - t.time, a = n.y - t.y;
|
|
121
|
+
if (r === 0) return 0;
|
|
122
|
+
const o = a / r;
|
|
123
|
+
return Math.max(
|
|
124
|
+
-d.MAX_VELOCITY,
|
|
125
|
+
Math.min(d.MAX_VELOCITY, o)
|
|
126
|
+
);
|
|
127
|
+
}, Z = (e) => {
|
|
128
|
+
l.current && cancelAnimationFrame(l.current), H(!0);
|
|
129
|
+
let t = e * -1, n = E, r = performance.now();
|
|
130
|
+
const a = 54 * (i.length - 1), o = (h) => {
|
|
131
|
+
const I = h - r;
|
|
132
|
+
r = h, n += t * I, n < 0 ? (n = 0, t = 0) : n > a && (n = a, t = 0), t *= d.FRICTION, f(n), s.current && (s.current.children[0].scrollTop = n);
|
|
133
|
+
const P = Math.round(n / 54) * 54, ie = Math.abs(n - P), re = Math.abs(t) <= d.NEAR_ZERO_VELOCITY, oe = Math.abs(t) <= d.SNAP_VELOCITY_THRESHOLD, se = ie <= d.BOUNDARY_PX;
|
|
134
|
+
re && se || oe ? (H(!1), G(n)) : l.current = requestAnimationFrame(o);
|
|
135
|
+
};
|
|
136
|
+
l.current = requestAnimationFrame(o);
|
|
137
|
+
}, G = (e) => {
|
|
138
|
+
l.current && cancelAnimationFrame(l.current);
|
|
139
|
+
const t = Math.max(0, Math.min(Math.round(e / 54), i.length - 1)), n = t * 54;
|
|
140
|
+
S.current = t;
|
|
141
|
+
const r = (a) => {
|
|
142
|
+
if (Math.abs(a - n) < 1)
|
|
143
|
+
f(n), s.current && (s.current.children[0].scrollTop = n), i[t] && b(i[t].value);
|
|
144
|
+
else {
|
|
145
|
+
const o = a + (n - a) * d.SNAP_FORCE;
|
|
146
|
+
f(o), s.current && (s.current.children[0].scrollTop = o), l.current = requestAnimationFrame(() => r(o));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
l.current = requestAnimationFrame(() => r(e));
|
|
150
|
+
}, _ = (e) => {
|
|
151
|
+
D(!0), W(e), U(E), H(!1), w([{ time: performance.now(), y: e }]);
|
|
152
|
+
}, J = (e) => {
|
|
153
|
+
if (!y || M) return;
|
|
154
|
+
const t = T - e;
|
|
155
|
+
let n = x + t;
|
|
156
|
+
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);
|
|
158
|
+
const a = performance.now();
|
|
159
|
+
w(
|
|
160
|
+
(o) => [...o, { time: a, y: e }].filter((h) => a - h.time <= 100)
|
|
161
|
+
);
|
|
162
|
+
}, Q = (e) => {
|
|
163
|
+
var n, r;
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
let t = S.current;
|
|
166
|
+
e.key === "ArrowUp" ? (t += 1, t > i.length - 1 && (t = 0)) : e.key === "ArrowDown" ? (t -= 1, t < 0 && (t = i.length - 1)) : e.key === "PageUp" ? (t += 5, t > i.length - 1 && (t = 0)) : e.key === "PageDown" ? (t -= 5, t < 0 && (t = i.length - 1)) : e.key === "Home" ? t = 0 : e.key === "End" && (t = i.length - 1), b(i[t].value), S.current = t, (r = (n = s.current) == null ? void 0 : n.querySelector(`.chain-picker-item[data-index="${S.current}"]`)) == null || r.focus();
|
|
167
|
+
}, ee = (e) => {
|
|
168
|
+
e.preventDefault(), e.stopPropagation(), _(e.clientY);
|
|
169
|
+
}, te = (e) => _(e.touches[0].clientY), ne = (e) => {
|
|
170
|
+
e.preventDefault(), e.stopPropagation(), J(e.clientY);
|
|
171
|
+
}, v = (e) => {
|
|
172
|
+
if (!y || (D(!1), !X && e.type === "mouseup")) return;
|
|
173
|
+
const t = B(q);
|
|
174
|
+
if (Math.abs(t) < d.MIN_VELOCITY) {
|
|
175
|
+
const r = e.target.closest("[data-index]");
|
|
176
|
+
if (r) {
|
|
177
|
+
const a = Number(r.dataset.index);
|
|
178
|
+
if (i[a] && s.current) {
|
|
179
|
+
const o = s.current.children[0];
|
|
180
|
+
o.scrollTo({
|
|
181
|
+
top: a * 54,
|
|
127
182
|
behavior: "smooth"
|
|
128
183
|
});
|
|
129
|
-
const
|
|
130
|
-
Math.abs(
|
|
184
|
+
const h = () => {
|
|
185
|
+
Math.abs(o.scrollTop - a * 54) < 1 && (b(i[a].value), o.removeEventListener("scroll", h));
|
|
131
186
|
};
|
|
132
|
-
|
|
187
|
+
o.addEventListener("scroll", h);
|
|
133
188
|
}
|
|
134
189
|
}
|
|
135
190
|
return;
|
|
136
191
|
}
|
|
137
|
-
|
|
138
|
-
const s = 54 * (t.length - 1);
|
|
139
|
-
n < 0 ? (n = 0, e = 0) : n > s && (n = s, e = t.length - 1), u.current = e;
|
|
140
|
-
const l = (c) => {
|
|
141
|
-
if (Math.abs(c - n) < 1)
|
|
142
|
-
p(n), o.current && (o.current.children[0].scrollTop = n);
|
|
143
|
-
else {
|
|
144
|
-
const d = c + (n - c) / 5;
|
|
145
|
-
p(d), o.current && (o.current.children[0].scrollTop = d), requestAnimationFrame(() => l(d));
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
requestAnimationFrame(() => l(h)), t[e] && x(t[e].value);
|
|
192
|
+
Z(t);
|
|
149
193
|
};
|
|
150
|
-
return
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
}, [
|
|
154
|
-
|
|
194
|
+
return L(() => {
|
|
195
|
+
const t = i.findIndex((n) => n.value === c) * 54;
|
|
196
|
+
f(t), s.current && (s.current.children[0].scrollTop = t);
|
|
197
|
+
}, [c, i, 54]), L(() => () => {
|
|
198
|
+
l.current && cancelAnimationFrame(l.current);
|
|
199
|
+
}, []), he(() => {
|
|
200
|
+
const e = s.current;
|
|
201
|
+
if (!e) return;
|
|
202
|
+
const t = (n) => {
|
|
203
|
+
const r = n;
|
|
204
|
+
if (r.preventDefault(), r.stopPropagation(), !y || M) return;
|
|
205
|
+
const a = T - r.touches[0].clientY;
|
|
206
|
+
let o = x + a;
|
|
207
|
+
const h = 54 * (i.length - 1);
|
|
208
|
+
o < 0 ? o = 0 : o > h && (o = h), f(o), s.current && (s.current.children[0].scrollTop = o);
|
|
209
|
+
const I = performance.now();
|
|
210
|
+
w(
|
|
211
|
+
(Y) => [...Y, { time: I, y: r.touches[0].clientY }].filter(
|
|
212
|
+
(P) => I - P.time <= 100
|
|
213
|
+
)
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
return e.addEventListener("touchmove", t, { passive: !1 }), () => {
|
|
217
|
+
e.removeEventListener("touchmove", t);
|
|
218
|
+
};
|
|
219
|
+
}, [y, M, T, x, 54, i.length]), /* @__PURE__ */ m(
|
|
220
|
+
pe,
|
|
155
221
|
{
|
|
156
|
-
ref:
|
|
157
|
-
...
|
|
158
|
-
css:
|
|
159
|
-
focusWithin:
|
|
160
|
-
children: /* @__PURE__ */
|
|
161
|
-
|
|
222
|
+
ref: s,
|
|
223
|
+
...p,
|
|
224
|
+
css: p == null ? void 0 : p.inlineCSS,
|
|
225
|
+
focusWithin: j && K,
|
|
226
|
+
children: /* @__PURE__ */ m(
|
|
227
|
+
me,
|
|
162
228
|
{
|
|
163
229
|
role: "group",
|
|
164
|
-
ref:
|
|
165
|
-
css:
|
|
166
|
-
|
|
167
|
-
onMouseDown:
|
|
168
|
-
onMouseMove:
|
|
169
|
-
onMouseUp:
|
|
170
|
-
onMouseLeave:
|
|
171
|
-
onTouchStart:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
y,
|
|
230
|
+
ref: V,
|
|
231
|
+
css: F,
|
|
232
|
+
...$,
|
|
233
|
+
onMouseDown: ee,
|
|
234
|
+
onMouseMove: ne,
|
|
235
|
+
onMouseUp: v,
|
|
236
|
+
onMouseLeave: v,
|
|
237
|
+
onTouchStart: te,
|
|
238
|
+
onTouchEnd: v,
|
|
239
|
+
onTouchCancel: v,
|
|
240
|
+
children: i.map((e, t) => {
|
|
241
|
+
const n = Math.round(E / 54), r = t === n;
|
|
242
|
+
return /* @__PURE__ */ ae(ue, { children: [
|
|
243
|
+
t === 0 && /* @__PURE__ */ m(
|
|
244
|
+
A,
|
|
180
245
|
{
|
|
181
246
|
className: "chain-picker-item",
|
|
182
|
-
"data-index":
|
|
247
|
+
"data-index": t - 1,
|
|
183
248
|
selected: !1,
|
|
184
|
-
distance:
|
|
249
|
+
distance: -1
|
|
185
250
|
}
|
|
186
251
|
),
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
|
|
252
|
+
/* @__PURE__ */ m(
|
|
253
|
+
A,
|
|
189
254
|
{
|
|
190
255
|
className: "chain-picker-item",
|
|
191
|
-
"data-index":
|
|
192
|
-
"data-selected":
|
|
193
|
-
selected:
|
|
194
|
-
distance:
|
|
256
|
+
"data-index": t,
|
|
257
|
+
"data-selected": r,
|
|
258
|
+
selected: r,
|
|
259
|
+
distance: t - n,
|
|
195
260
|
role: "spinbutton",
|
|
196
|
-
tabIndex:
|
|
197
|
-
"aria-hidden":
|
|
198
|
-
"aria-valuenow":
|
|
199
|
-
"aria-valuetext":
|
|
200
|
-
"aria-valuemin":
|
|
201
|
-
"aria-valuemax":
|
|
202
|
-
...
|
|
203
|
-
onKeyDown:
|
|
204
|
-
children:
|
|
261
|
+
tabIndex: r ? 0 : -1,
|
|
262
|
+
"aria-hidden": r ? "false" : "true",
|
|
263
|
+
"aria-valuenow": e.value,
|
|
264
|
+
"aria-valuetext": e.ariaValueText ?? e.label,
|
|
265
|
+
"aria-valuemin": i[0].value,
|
|
266
|
+
"aria-valuemax": i[i.length - 1].value,
|
|
267
|
+
...R,
|
|
268
|
+
onKeyDown: Q,
|
|
269
|
+
children: N ? N(e, r) : e.label
|
|
205
270
|
}
|
|
206
271
|
),
|
|
207
|
-
|
|
208
|
-
|
|
272
|
+
t === i.length - 1 && /* @__PURE__ */ m(
|
|
273
|
+
A,
|
|
209
274
|
{
|
|
210
275
|
className: "chain-picker-item",
|
|
211
|
-
"data-index":
|
|
276
|
+
"data-index": t + 1,
|
|
212
277
|
selected: !1,
|
|
213
|
-
distance:
|
|
278
|
+
distance: i.length - n
|
|
214
279
|
}
|
|
215
280
|
)
|
|
216
|
-
] }, `${z}_${
|
|
281
|
+
] }, `${z}_${e.label}`);
|
|
217
282
|
})
|
|
218
283
|
}
|
|
219
284
|
)
|
|
@@ -221,6 +286,5 @@ const ie = H.div`
|
|
|
221
286
|
);
|
|
222
287
|
});
|
|
223
288
|
export {
|
|
224
|
-
|
|
225
|
-
fe as default
|
|
289
|
+
Te as default
|
|
226
290
|
};
|