@dotss/ui 1.4.0 → 1.5.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.
- package/Tab/Tab.cjs +7 -7
- package/Tab/Tab.es.js +145 -96
- package/Tab/TabBlock/TabBlock.cjs +6 -6
- package/Tab/TabBlock/TabBlock.es.js +72 -55
- package/Tooltip/Tooltip.cjs +11 -6
- package/Tooltip/Tooltip.d.ts +2 -1
- package/Tooltip/Tooltip.es.js +177 -160
- package/Tooltip/Tooltip.stories.d.ts +6 -0
- package/package.json +1 -1
package/Tab/Tab.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 L=require("@emotion/react/jsx-runtime"),c=require("react"),st=require("@emotion/styled"),it=o=>o&&o.__esModule?o:{default:o},R=it(st),ct=R.default.div`
|
|
2
2
|
width: 100%;
|
|
3
3
|
background-color: ${({theme:o})=>o.palette.grey.white};
|
|
4
|
-
${({scrollable:o})=>o?{overflow:"hidden"}:{}}
|
|
5
|
-
`,
|
|
4
|
+
${({scrollable:o})=>o?{overflow:"hidden",cursor:"grab",'& [role="tab"]':{flex:"0 0 auto"}}:{}}
|
|
5
|
+
`,ot=R.default.div`
|
|
6
6
|
display: flex;
|
|
7
7
|
position: relative;
|
|
8
8
|
background: ${({theme:o})=>o.palette.grey.white};
|
|
9
|
-
${({theme:o,isChipped:
|
|
10
|
-
`,
|
|
9
|
+
${({theme:o,isChipped:m})=>m?{gap:o.spacing.content(2)}:{}}
|
|
10
|
+
`,at=R.default.div`
|
|
11
11
|
position: absolute;
|
|
12
12
|
height: 2px;
|
|
13
13
|
bottom: 0;
|
|
14
|
-
background: ${({theme:o,disabled:
|
|
14
|
+
background: ${({theme:o,disabled:m})=>m?o.palette.brand.primary.disableLine:o.palette.brand.primary.main};
|
|
15
15
|
transition: all 0.2s ease-in-out;
|
|
16
16
|
transition-property: transform, width;
|
|
17
17
|
${({isChipped:o})=>o?{display:"none"}:{}}
|
|
18
|
-
`,
|
|
18
|
+
`,A=3,g=Object.freeze({FRICTION:.85,MIN_VELOCITY:.01,MAX_VELOCITY:1.62,STOP_VELOCITY:.02,SAMPLE_DURATION:100}),ut=c.forwardRef(function({value:m,scrollable:h=!1,disabled:k=!1,onChange:w,size:I="medium",inlineCSS:V,wrapperProps:M,children:C,...q},X){const s=c.useRef(null),u=c.useRef(),b=c.useRef(0),j=c.useRef(!0),S=c.useRef(!1),T=c.useRef(!1),l=c.useRef(!1),v=c.useRef([]),[U,H]=c.useState(!1),[E,z]=c.useState(0),[D,K]=c.useState(0),[O,G]=c.useState(0),_=k,Y=c.Children.toArray(C).every(t=>c.isValidElement(t)&&c.Children.toArray(t.props.children).every(r=>c.isValidElement(r)&&!Array.isArray(r.props.children))),J=t=>r=>{h&&!S.current||(w(t,r.currentTarget),S.current=!1)},Q=t=>{if(!s.current)return;const r=s.current.querySelectorAll('[role="tab"]:not([disabled])'),i=Array.from(r).findIndex(e=>e===document.activeElement);if(t.key==="ArrowLeft"){t.preventDefault();const e=i<=0?r.length-1:i-1,n=r[e];n&&!n.getAttribute("disabled")&&n.focus()}else if(t.key==="ArrowRight"){t.preventDefault();const e=i>=r.length-1?0:i+1,n=r[e];n&&!n.getAttribute("disabled")&&n.focus()}else if(t.key==="Home"){t.preventDefault();const e=r[0];e&&!e.getAttribute("disabled")&&e.focus()}else if(t.key==="End"){t.preventDefault();const e=r[r.length-1];e&&!e.getAttribute("disabled")&&e.focus()}else if(t.key===" "||t.key==="Enter"){t.preventDefault();const e=r[i];if(e&&!e.getAttribute("disabled")){const n=e.getAttribute("value");if(n){w(n,e);const a=s.current.querySelector(".indicator");a&&(a.style.width=`${e.clientWidth}px`,a.style.transform=`translate3d(${e.offsetLeft}px, 0px, 0px)`,T.current?a.style.transition="all 0.2s ease-in-out":(a.style.transition="unset",T.current=!0))}}}},Z=t=>{if(t.length<2)return 0;const r=t[0],i=t[t.length-1],e=i.time-r.time,n=i.x-r.x;if(e===0)return 0;const a=n/e;return Math.max(-g.MAX_VELOCITY,Math.min(g.MAX_VELOCITY,a))},p=c.useCallback(t=>{const r=s.current?s.current.scrollWidth-s.current.clientWidth:0;return Math.max(0,Math.min(t,r))},[]),x=c.useCallback(t=>{if(!s.current)return;const r=p(t);s.current.style.transition="unset",s.current.style.transform=`translate3d(-${r}px, 0px, 0px)`,b.current=r},[p]),B=c.useCallback(t=>{u.current&&cancelAnimationFrame(u.current);let r=t*-1,i=b.current,e=performance.now();const n=a=>{if(!s.current)return;const d=a-e;e=a,i=p(i+r*d);const f=i<=0,y=i>=s.current.scrollWidth-s.current.clientWidth;(f&&r<0||y&&r>0)&&(r=0),r*=g.FRICTION,x(i),Math.abs(r)>g.STOP_VELOCITY?u.current=requestAnimationFrame(n):u.current=void 0};u.current=requestAnimationFrame(n)},[p,x]),$=(t,r)=>{u.current&&(cancelAnimationFrame(u.current),u.current=void 0),S.current=!1,z(t),K(r),G(b.current),v.current=[{time:performance.now(),x:t}]},F=(t,r)=>{if(!l.current||!s.current)return;l.current=!1,s.current.style.cursor="grab";const i=E-t,e=D-r;t&&Math.abs(i)<A&&Math.abs(e)<A*2&&(S.current=!0);const n=Z(v.current);v.current=[],u.current&&(cancelAnimationFrame(u.current),u.current=void 0),!S.current&&Math.abs(n)>=g.MIN_VELOCITY&&B(n)},tt=t=>{h&&(l.current=!0,$(t.clientX,t.clientY))},et=t=>{h&&$(t.touches[0].clientX,t.touches[0].clientY)},N=t=>F(t.changedTouches[0].clientX,t.changedTouches[0].clientY),P=t=>F(t.clientX,t.clientY);return c.useEffect(()=>{const t=()=>{var r;if(s.current){const i=s.current.querySelector(".indicator"),e=(r=s.current)==null?void 0:r.querySelectorAll('[role="tab"][data-selected="true"]')[0];if(e&&i&&(i.style.width=`${e.clientWidth}px`,i.style.transform=`translate3d(${e.offsetLeft}px, 0px, 0px)`,T.current?i.style.transition="all 0.2s ease-in-out":(i.style.transition="unset",T.current=!0),H(e.getAttribute("data-disabled")==="true")),e&&h){const n=e.offsetLeft,a=e.offsetLeft+e.clientWidth,d=b.current,f=b.current+s.current.clientWidth;if(n<d||a>f){const y=Math.min(n,Math.max(s.current.scrollWidth-s.current.clientWidth,s.current.scrollWidth-f));s.current.style.transition="all 0.2s ease-in-out",s.current.style.transform=`translate3d(-${y}px, 0px, 0px)`,b.current=y}}}};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[h,m,I]),c.useEffect(()=>{const t=s.current,r=(n,a,d)=>{if(!s.current)return;const f=E-n,y=D-a;if(l.current=l.current||Math.abs(f)>A&&Math.abs(y)<A*2,l.current&&d.cancelable&&(d.preventDefault(),d.stopPropagation()),l.current){const rt=p(O+f),W=performance.now();v.current=[...v.current,{time:W,x:n}].filter(nt=>W-nt.time<=g.SAMPLE_DURATION),s.current&&(u.current&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{s.current&&(x(rt),s.current.style.cursor="grabbing",j.current=!1)}))}},i=n=>{l.current&&r(n.clientX,n.clientY,n)},e=n=>{n.stopPropagation(),r(n.touches[0].clientX,n.touches[0].clientY,n)};return t==null||t.addEventListener("mousemove",i),t==null||t.addEventListener("touchmove",e),()=>{t==null||t.removeEventListener("mousemove",i),t==null||t.removeEventListener("touchmove",e)}},[p,E,D,O,x]),c.useEffect(()=>()=>{u.current&&cancelAnimationFrame(u.current)},[]),L.jsx(ct,{className:"tab-wrapper",ref:X,scrollable:h,...M,css:M==null?void 0:M.inlineCSS,children:L.jsxs(ot,{className:"tab-list",role:"tablist",ref:s,isChipped:Y,css:V,...q,onMouseDown:tt,onMouseUp:P,onMouseLeave:P,onTouchStart:et,onTouchEnd:N,onTouchCancel:N,children:[c.Children.map(C,(t,r)=>{var n,a;if(!c.isValidElement(t))return null;const i=m===t.props.value,e=_||((n=t.props)==null?void 0:n.disabled);return c.cloneElement(t,{...t.props,className:`tab-block-${r}`,selected:i,"aria-selected":i,tabIndex:i?0:-1,onClick:(a=t.props)!=null&&a.disabled?void 0:J(t.props.value),onKeyDown:Q,disabled:e,size:I})}),L.jsx(at,{className:"indicator",disabled:_||U,isChipped:Y})]})})});exports.default=ut;
|
package/Tab/Tab.es.js
CHANGED
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { jsx as U, jsxs as ut } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as lt, useRef as l, useState as M, Children as w, isValidElement as I, useCallback as O, useEffect as C, cloneElement as dt } from "react";
|
|
3
|
+
import Y from "@emotion/styled";
|
|
4
|
+
const ft = Y.div`
|
|
5
5
|
width: 100%;
|
|
6
|
-
background-color: ${({ theme:
|
|
7
|
-
${({ scrollable:
|
|
8
|
-
overflow: "hidden"
|
|
6
|
+
background-color: ${({ theme: a }) => a.palette.grey.white};
|
|
7
|
+
${({ scrollable: a }) => a ? {
|
|
8
|
+
overflow: "hidden",
|
|
9
|
+
cursor: "grab",
|
|
10
|
+
'& [role="tab"]': {
|
|
11
|
+
flex: "0 0 auto"
|
|
12
|
+
}
|
|
9
13
|
} : {}}
|
|
10
|
-
`,
|
|
14
|
+
`, mt = Y.div`
|
|
11
15
|
display: flex;
|
|
12
16
|
position: relative;
|
|
13
|
-
background: ${({ theme:
|
|
14
|
-
${({ theme:
|
|
15
|
-
gap:
|
|
17
|
+
background: ${({ theme: a }) => a.palette.grey.white};
|
|
18
|
+
${({ theme: a, isChipped: m }) => m ? {
|
|
19
|
+
gap: a.spacing.content(2)
|
|
16
20
|
} : {}}
|
|
17
|
-
`,
|
|
21
|
+
`, ht = Y.div`
|
|
18
22
|
position: absolute;
|
|
19
23
|
height: 2px;
|
|
20
24
|
bottom: 0;
|
|
21
|
-
background: ${({ theme:
|
|
25
|
+
background: ${({ theme: a, disabled: m }) => m ? a.palette.brand.primary.disableLine : a.palette.brand.primary.main};
|
|
22
26
|
transition: all 0.2s ease-in-out;
|
|
23
27
|
transition-property: transform, width;
|
|
24
|
-
${({ isChipped:
|
|
28
|
+
${({ isChipped: a }) => a ? {
|
|
25
29
|
display: "none"
|
|
26
30
|
} : {}}
|
|
27
|
-
`,
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
`, L = 3, g = Object.freeze({
|
|
32
|
+
FRICTION: 0.85,
|
|
33
|
+
MIN_VELOCITY: 0.01,
|
|
34
|
+
MAX_VELOCITY: 1.62,
|
|
35
|
+
STOP_VELOCITY: 0.02,
|
|
36
|
+
SAMPLE_DURATION: 100
|
|
37
|
+
}), gt = lt(function({
|
|
38
|
+
value: m,
|
|
39
|
+
scrollable: h = !1,
|
|
30
40
|
disabled: j = !1,
|
|
31
|
-
onChange:
|
|
41
|
+
onChange: R,
|
|
32
42
|
size: $ = "medium",
|
|
33
|
-
inlineCSS:
|
|
34
|
-
wrapperProps:
|
|
35
|
-
children:
|
|
36
|
-
...
|
|
37
|
-
},
|
|
38
|
-
const
|
|
39
|
-
(r) =>
|
|
40
|
-
)),
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
if (!
|
|
44
|
-
const r =
|
|
43
|
+
inlineCSS: H,
|
|
44
|
+
wrapperProps: v,
|
|
45
|
+
children: F,
|
|
46
|
+
...z
|
|
47
|
+
}, K) {
|
|
48
|
+
const o = l(null), c = l(), p = l(0), G = l(!0), S = l(!1), x = l(!1), u = l(!1), T = l([]), [J, Q] = M(!1), [D, Z] = M(0), [E, B] = M(0), [N, tt] = M(0), W = j, P = w.toArray(F).every((t) => I(t) && w.toArray(t.props.children).every(
|
|
49
|
+
(r) => I(r) && !Array.isArray(r.props.children)
|
|
50
|
+
)), et = (t) => (r) => {
|
|
51
|
+
h && !S.current || (R(t, r.currentTarget), S.current = !1);
|
|
52
|
+
}, rt = (t) => {
|
|
53
|
+
if (!o.current) return;
|
|
54
|
+
const r = o.current.querySelectorAll(
|
|
45
55
|
'[role="tab"]:not([disabled])'
|
|
46
56
|
), i = Array.from(r).findIndex((e) => e === document.activeElement);
|
|
47
57
|
if (t.key === "ArrowLeft") {
|
|
@@ -66,42 +76,77 @@ const st = L.div`
|
|
|
66
76
|
if (e && !e.getAttribute("disabled")) {
|
|
67
77
|
const n = e.getAttribute("value");
|
|
68
78
|
if (n) {
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
79
|
+
R(n, e);
|
|
80
|
+
const s = o.current.querySelector(".indicator");
|
|
81
|
+
s && (s.style.width = `${e.clientWidth}px`, s.style.transform = `translate3d(${e.offsetLeft}px, 0px, 0px)`, x.current ? s.style.transition = "all 0.2s ease-in-out" : (s.style.transition = "unset", x.current = !0));
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
}, nt = (t) => {
|
|
86
|
+
if (t.length < 2) return 0;
|
|
87
|
+
const r = t[0], i = t[t.length - 1], e = i.time - r.time, n = i.x - r.x;
|
|
88
|
+
if (e === 0) return 0;
|
|
89
|
+
const s = n / e;
|
|
90
|
+
return Math.max(
|
|
91
|
+
-g.MAX_VELOCITY,
|
|
92
|
+
Math.min(g.MAX_VELOCITY, s)
|
|
93
|
+
);
|
|
94
|
+
}, b = O((t) => {
|
|
95
|
+
const r = o.current ? o.current.scrollWidth - o.current.clientWidth : 0;
|
|
96
|
+
return Math.max(0, Math.min(t, r));
|
|
97
|
+
}, []), A = O(
|
|
98
|
+
(t) => {
|
|
99
|
+
if (!o.current) return;
|
|
100
|
+
const r = b(t);
|
|
101
|
+
o.current.style.transition = "unset", o.current.style.transform = `translate3d(-${r}px, 0px, 0px)`, p.current = r;
|
|
102
|
+
},
|
|
103
|
+
[b]
|
|
104
|
+
), ot = O(
|
|
105
|
+
(t) => {
|
|
106
|
+
c.current && cancelAnimationFrame(c.current);
|
|
107
|
+
let r = t * -1, i = p.current, e = performance.now();
|
|
108
|
+
const n = (s) => {
|
|
109
|
+
if (!o.current) return;
|
|
110
|
+
const d = s - e;
|
|
111
|
+
e = s, i = b(i + r * d);
|
|
112
|
+
const f = i <= 0, y = i >= o.current.scrollWidth - o.current.clientWidth;
|
|
113
|
+
(f && r < 0 || y && r > 0) && (r = 0), r *= g.FRICTION, A(i), Math.abs(r) > g.STOP_VELOCITY ? c.current = requestAnimationFrame(n) : c.current = void 0;
|
|
114
|
+
};
|
|
115
|
+
c.current = requestAnimationFrame(n);
|
|
116
|
+
},
|
|
117
|
+
[b, A]
|
|
118
|
+
), _ = (t, r) => {
|
|
119
|
+
c.current && (cancelAnimationFrame(c.current), c.current = void 0), S.current = !1, Z(t), B(r), tt(p.current), T.current = [{ time: performance.now(), x: t }];
|
|
120
|
+
}, X = (t, r) => {
|
|
121
|
+
if (!u.current || !o.current) return;
|
|
122
|
+
u.current = !1, o.current.style.cursor = "grab";
|
|
123
|
+
const i = D - t, e = E - r;
|
|
124
|
+
t && Math.abs(i) < L && Math.abs(e) < L * 2 && (S.current = !0);
|
|
125
|
+
const n = nt(T.current);
|
|
126
|
+
T.current = [], c.current && (cancelAnimationFrame(c.current), c.current = void 0), !S.current && Math.abs(n) >= g.MIN_VELOCITY && ot(n);
|
|
127
|
+
}, it = (t) => {
|
|
128
|
+
h && (u.current = !0, _(t.clientX, t.clientY));
|
|
129
|
+
}, st = (t) => {
|
|
130
|
+
h && _(t.touches[0].clientX, t.touches[0].clientY);
|
|
131
|
+
}, k = (t) => X(t.changedTouches[0].clientX, t.changedTouches[0].clientY), V = (t) => X(t.clientX, t.clientY);
|
|
132
|
+
return C(() => {
|
|
88
133
|
const t = () => {
|
|
89
134
|
var r;
|
|
90
|
-
if (
|
|
91
|
-
const i =
|
|
135
|
+
if (o.current) {
|
|
136
|
+
const i = o.current.querySelector(".indicator"), e = (r = o.current) == null ? void 0 : r.querySelectorAll(
|
|
92
137
|
'[role="tab"][data-selected="true"]'
|
|
93
138
|
)[0];
|
|
94
|
-
if (e && i && (i.style.width = `${e.clientWidth}px`, i.style.transform = `translate3d(${e.offsetLeft}px, 0px, 0px)`,
|
|
95
|
-
const n = e.offsetLeft,
|
|
96
|
-
if (n <
|
|
97
|
-
const
|
|
139
|
+
if (e && i && (i.style.width = `${e.clientWidth}px`, i.style.transform = `translate3d(${e.offsetLeft}px, 0px, 0px)`, x.current ? i.style.transition = "all 0.2s ease-in-out" : (i.style.transition = "unset", x.current = !0), Q(e.getAttribute("data-disabled") === "true")), e && h) {
|
|
140
|
+
const n = e.offsetLeft, s = e.offsetLeft + e.clientWidth, d = p.current, f = p.current + o.current.clientWidth;
|
|
141
|
+
if (n < d || s > f) {
|
|
142
|
+
const y = Math.min(
|
|
98
143
|
n,
|
|
99
144
|
Math.max(
|
|
100
|
-
|
|
101
|
-
|
|
145
|
+
o.current.scrollWidth - o.current.clientWidth,
|
|
146
|
+
o.current.scrollWidth - f
|
|
102
147
|
)
|
|
103
148
|
);
|
|
104
|
-
|
|
149
|
+
o.current.style.transition = "all 0.2s ease-in-out", o.current.style.transform = `translate3d(-${y}px, 0px, 0px)`, p.current = y;
|
|
105
150
|
}
|
|
106
151
|
}
|
|
107
152
|
}
|
|
@@ -109,72 +154,76 @@ const st = L.div`
|
|
|
109
154
|
return t(), window.addEventListener("resize", t), () => {
|
|
110
155
|
window.removeEventListener("resize", t);
|
|
111
156
|
};
|
|
112
|
-
}, [
|
|
113
|
-
const t =
|
|
114
|
-
if (!
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
157
|
+
}, [h, m, $]), C(() => {
|
|
158
|
+
const t = o.current, r = (n, s, d) => {
|
|
159
|
+
if (!o.current) return;
|
|
160
|
+
const f = D - n, y = E - s;
|
|
161
|
+
if (u.current = u.current || Math.abs(f) > L && Math.abs(y) < L * 2, u.current && d.cancelable && (d.preventDefault(), d.stopPropagation()), u.current) {
|
|
162
|
+
const ct = b(N + f), q = performance.now();
|
|
163
|
+
T.current = [
|
|
164
|
+
...T.current,
|
|
165
|
+
{ time: q, x: n }
|
|
166
|
+
].filter((at) => q - at.time <= g.SAMPLE_DURATION), o.current && (c.current && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
167
|
+
o.current && (A(ct), o.current.style.cursor = "grabbing", G.current = !1);
|
|
121
168
|
}));
|
|
122
169
|
}
|
|
123
170
|
}, i = (n) => {
|
|
124
|
-
|
|
171
|
+
u.current && r(n.clientX, n.clientY, n);
|
|
125
172
|
}, e = (n) => {
|
|
126
|
-
r(n.touches[0].clientX, n.touches[0].clientY, n);
|
|
173
|
+
n.stopPropagation(), r(n.touches[0].clientX, n.touches[0].clientY, n);
|
|
127
174
|
};
|
|
128
175
|
return t == null || t.addEventListener("mousemove", i), t == null || t.addEventListener("touchmove", e), () => {
|
|
129
176
|
t == null || t.removeEventListener("mousemove", i), t == null || t.removeEventListener("touchmove", e);
|
|
130
177
|
};
|
|
131
|
-
}, [
|
|
132
|
-
|
|
178
|
+
}, [b, D, E, N, A]), C(() => () => {
|
|
179
|
+
c.current && cancelAnimationFrame(c.current);
|
|
180
|
+
}, []), /* @__PURE__ */ U(
|
|
181
|
+
ft,
|
|
133
182
|
{
|
|
134
183
|
className: "tab-wrapper",
|
|
135
|
-
ref:
|
|
136
|
-
scrollable:
|
|
137
|
-
...
|
|
138
|
-
css:
|
|
139
|
-
children: /* @__PURE__ */
|
|
140
|
-
|
|
184
|
+
ref: K,
|
|
185
|
+
scrollable: h,
|
|
186
|
+
...v,
|
|
187
|
+
css: v == null ? void 0 : v.inlineCSS,
|
|
188
|
+
children: /* @__PURE__ */ ut(
|
|
189
|
+
mt,
|
|
141
190
|
{
|
|
142
191
|
className: "tab-list",
|
|
143
192
|
role: "tablist",
|
|
144
|
-
ref:
|
|
145
|
-
isChipped:
|
|
146
|
-
css:
|
|
147
|
-
...
|
|
148
|
-
onMouseDown:
|
|
149
|
-
onMouseUp:
|
|
150
|
-
onMouseLeave:
|
|
151
|
-
onTouchStart:
|
|
152
|
-
onTouchEnd:
|
|
153
|
-
onTouchCancel:
|
|
193
|
+
ref: o,
|
|
194
|
+
isChipped: P,
|
|
195
|
+
css: H,
|
|
196
|
+
...z,
|
|
197
|
+
onMouseDown: it,
|
|
198
|
+
onMouseUp: V,
|
|
199
|
+
onMouseLeave: V,
|
|
200
|
+
onTouchStart: st,
|
|
201
|
+
onTouchEnd: k,
|
|
202
|
+
onTouchCancel: k,
|
|
154
203
|
children: [
|
|
155
|
-
w.map(
|
|
156
|
-
var n,
|
|
157
|
-
if (!
|
|
204
|
+
w.map(F, (t, r) => {
|
|
205
|
+
var n, s;
|
|
206
|
+
if (!I(t))
|
|
158
207
|
return null;
|
|
159
|
-
const i =
|
|
160
|
-
return
|
|
208
|
+
const i = m === t.props.value, e = W || ((n = t.props) == null ? void 0 : n.disabled);
|
|
209
|
+
return dt(t, {
|
|
161
210
|
...t.props,
|
|
162
211
|
className: `tab-block-${r}`,
|
|
163
212
|
selected: i,
|
|
164
213
|
"aria-selected": i,
|
|
165
214
|
tabIndex: i ? 0 : -1,
|
|
166
|
-
onClick: (
|
|
167
|
-
onKeyDown:
|
|
215
|
+
onClick: (s = t.props) != null && s.disabled ? void 0 : et(t.props.value),
|
|
216
|
+
onKeyDown: rt,
|
|
168
217
|
disabled: e,
|
|
169
218
|
size: $
|
|
170
219
|
});
|
|
171
220
|
}),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
|
|
221
|
+
/* @__PURE__ */ U(
|
|
222
|
+
ht,
|
|
174
223
|
{
|
|
175
224
|
className: "indicator",
|
|
176
|
-
disabled:
|
|
177
|
-
isChipped:
|
|
225
|
+
disabled: W || J,
|
|
226
|
+
isChipped: P
|
|
178
227
|
}
|
|
179
228
|
)
|
|
180
229
|
]
|
|
@@ -184,5 +233,5 @@ const st = L.div`
|
|
|
184
233
|
);
|
|
185
234
|
});
|
|
186
235
|
export {
|
|
187
|
-
|
|
236
|
+
gt as default
|
|
188
237
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
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"),d=require("react"),m=require("../../Chip/Chip.cjs"),p=require("@emotion/styled"),x=t=>t&&t.__esModule?t:{default:t},h=x(p),y=h.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex: 1;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
align-items: center;
|
|
6
|
-
padding: ${({theme:{spacing:
|
|
7
|
-
border-bottom: ${({theme:
|
|
8
|
-
cursor: ${({disabled:
|
|
6
|
+
padding: ${({theme:{spacing:t},size:r})=>r==="small"?`${t.content(2)}px ${t.content(3)}px`:`${t.content(3)}px ${t.content(4)}px`};
|
|
7
|
+
border-bottom: ${({theme:t})=>`1px solid ${t.palette.grey[10]}`};
|
|
8
|
+
cursor: ${({disabled:t})=>t?"not-allowed":"pointer"};
|
|
9
9
|
|
|
10
|
-
${({theme:{typography:
|
|
11
|
-
`,$=d.forwardRef(function({size:
|
|
10
|
+
${({theme:{typography:t,palette:r},size:e,selected:o,disabled:a})=>{if(o){const{size:g,weight:n,lineHeight:c,letterSpacing:b}=t[e==="medium"?"h4B":"h5B"];return{fontSize:g,fontWeight:n,lineHeight:c,letterSpacing:b,color:a?r.grey[30]:r.grey[100]}}const{size:i,weight:u,lineHeight:l,letterSpacing:s}=t[e==="medium"?"b2R":"b4R"];return{fontSize:i,fontWeight:u,lineHeight:l,letterSpacing:s,color:a?r.grey[30]:r.grey[70]}}}}
|
|
11
|
+
`,$=d.forwardRef(function({size:r="medium",selected:e,disabled:o=!1,inlineCSS:a,children:i,onClick:u,...l},s){var g;return((g=d.Children.toArray(i))==null?void 0:g.length)!==1?f.jsx(y,{as:"button",role:"tab",ref:s,size:r,disabled:o,selected:e,"data-selected":e,"data-disabled":o,onClick:u,css:a,...l,children:i}):f.jsx(f.Fragment,{children:d.Children.map(i,n=>{var c;return d.isValidElement(n)&&n.type===m.default&&!Array.isArray((c=n==null?void 0:n.props)==null?void 0:c.children)?f.jsx(m.default,{tag:"button",role:"tab",ref:s,"data-shape":"chip","data-selected":e,disabled:o,variant:e?"filled":"outlined",selected:e,onClick:u,inlineCSS:a,...n.props,...l}):f.jsx(y,{as:"button",role:"tab",ref:s,size:r,disabled:o,selected:e,"data-selected":e,"data-disabled":o,onClick:u,css:a,...l,children:n})})})});exports.default=$;
|
|
@@ -1,84 +1,101 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsx as p, Fragment as h } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, Children as s, isValidElement as $ } from "react";
|
|
3
|
+
import y from "../../Chip/Chip.es.js";
|
|
4
|
+
import d from "@emotion/styled";
|
|
5
|
+
const b = d.div`
|
|
6
6
|
display: flex;
|
|
7
7
|
flex: 1;
|
|
8
8
|
justify-content: center;
|
|
9
9
|
align-items: center;
|
|
10
|
-
padding: ${({ theme: { spacing: t }, size:
|
|
10
|
+
padding: ${({ theme: { spacing: t }, size: r }) => r === "small" ? `${t.content(2)}px ${t.content(3)}px` : `${t.content(3)}px ${t.content(4)}px`};
|
|
11
11
|
border-bottom: ${({ theme: t }) => `1px solid ${t.palette.grey[10]}`};
|
|
12
12
|
cursor: ${({ disabled: t }) => t ? "not-allowed" : "pointer"};
|
|
13
13
|
|
|
14
|
-
${({ theme: { typography: t, palette:
|
|
15
|
-
if (
|
|
14
|
+
${({ theme: { typography: t, palette: r }, size: e, selected: n, disabled: a }) => {
|
|
15
|
+
if (n) {
|
|
16
16
|
const {
|
|
17
|
-
size:
|
|
18
|
-
weight:
|
|
19
|
-
lineHeight:
|
|
20
|
-
letterSpacing:
|
|
21
|
-
} = t[
|
|
17
|
+
size: u,
|
|
18
|
+
weight: o,
|
|
19
|
+
lineHeight: l,
|
|
20
|
+
letterSpacing: c
|
|
21
|
+
} = t[e === "medium" ? "h4B" : "h5B"];
|
|
22
22
|
return {
|
|
23
|
-
fontSize:
|
|
24
|
-
fontWeight:
|
|
25
|
-
lineHeight:
|
|
26
|
-
letterSpacing:
|
|
27
|
-
color:
|
|
23
|
+
fontSize: u,
|
|
24
|
+
fontWeight: o,
|
|
25
|
+
lineHeight: l,
|
|
26
|
+
letterSpacing: c,
|
|
27
|
+
color: a ? r.grey[30] : r.grey[100]
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
const {
|
|
31
|
-
size:
|
|
32
|
-
weight:
|
|
33
|
-
lineHeight:
|
|
34
|
-
letterSpacing:
|
|
35
|
-
} = t[
|
|
31
|
+
size: i,
|
|
32
|
+
weight: m,
|
|
33
|
+
lineHeight: f,
|
|
34
|
+
letterSpacing: g
|
|
35
|
+
} = t[e === "medium" ? "b2R" : "b4R"];
|
|
36
36
|
return {
|
|
37
|
-
fontSize:
|
|
38
|
-
fontWeight:
|
|
39
|
-
lineHeight:
|
|
40
|
-
letterSpacing:
|
|
41
|
-
color:
|
|
37
|
+
fontSize: i,
|
|
38
|
+
fontWeight: m,
|
|
39
|
+
lineHeight: f,
|
|
40
|
+
letterSpacing: g,
|
|
41
|
+
color: a ? r.grey[30] : r.grey[70]
|
|
42
42
|
};
|
|
43
43
|
}}}
|
|
44
|
-
`,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
`, z = x(function({ size: r = "medium", selected: e, disabled: n = !1, inlineCSS: a, children: i, onClick: m, ...f }, g) {
|
|
45
|
+
var u;
|
|
46
|
+
return ((u = s.toArray(i)) == null ? void 0 : u.length) !== 1 ? /* @__PURE__ */ p(
|
|
47
|
+
b,
|
|
48
|
+
{
|
|
49
|
+
as: "button",
|
|
50
|
+
role: "tab",
|
|
51
|
+
ref: g,
|
|
52
|
+
size: r,
|
|
53
|
+
disabled: n,
|
|
54
|
+
selected: e,
|
|
55
|
+
"data-selected": e,
|
|
56
|
+
"data-disabled": n,
|
|
57
|
+
onClick: m,
|
|
58
|
+
css: a,
|
|
59
|
+
...f,
|
|
60
|
+
children: i
|
|
61
|
+
}
|
|
62
|
+
) : /* @__PURE__ */ p(h, { children: s.map(i, (o) => {
|
|
63
|
+
var l;
|
|
64
|
+
return $(o) && o.type === y && !Array.isArray((l = o == null ? void 0 : o.props) == null ? void 0 : l.children) ? /* @__PURE__ */ p(
|
|
65
|
+
y,
|
|
49
66
|
{
|
|
50
67
|
tag: "button",
|
|
51
68
|
role: "tab",
|
|
52
|
-
ref:
|
|
69
|
+
ref: g,
|
|
53
70
|
"data-shape": "chip",
|
|
54
|
-
"data-selected":
|
|
55
|
-
disabled:
|
|
56
|
-
variant:
|
|
57
|
-
selected:
|
|
58
|
-
onClick:
|
|
59
|
-
inlineCSS:
|
|
60
|
-
...
|
|
61
|
-
...
|
|
71
|
+
"data-selected": e,
|
|
72
|
+
disabled: n,
|
|
73
|
+
variant: e ? "filled" : "outlined",
|
|
74
|
+
selected: e,
|
|
75
|
+
onClick: m,
|
|
76
|
+
inlineCSS: a,
|
|
77
|
+
...o.props,
|
|
78
|
+
...f
|
|
62
79
|
}
|
|
63
|
-
) : /* @__PURE__ */
|
|
64
|
-
|
|
80
|
+
) : /* @__PURE__ */ p(
|
|
81
|
+
b,
|
|
65
82
|
{
|
|
66
83
|
as: "button",
|
|
67
84
|
role: "tab",
|
|
68
|
-
ref:
|
|
69
|
-
size:
|
|
70
|
-
disabled:
|
|
71
|
-
selected:
|
|
72
|
-
"data-selected":
|
|
73
|
-
"data-disabled":
|
|
74
|
-
onClick:
|
|
75
|
-
css:
|
|
76
|
-
...
|
|
77
|
-
children:
|
|
85
|
+
ref: g,
|
|
86
|
+
size: r,
|
|
87
|
+
disabled: n,
|
|
88
|
+
selected: e,
|
|
89
|
+
"data-selected": e,
|
|
90
|
+
"data-disabled": n,
|
|
91
|
+
onClick: m,
|
|
92
|
+
css: a,
|
|
93
|
+
...f,
|
|
94
|
+
children: o
|
|
78
95
|
}
|
|
79
96
|
);
|
|
80
97
|
}) });
|
|
81
98
|
});
|
|
82
99
|
export {
|
|
83
|
-
|
|
100
|
+
z as default
|
|
84
101
|
};
|