@dotss/ui 1.3.1 → 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/Button/Button.cjs +8 -7
- package/Button/Button.d.ts +3 -0
- package/Button/Button.es.js +77 -66
- package/Button/Button.stories.d.ts +1 -0
- 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/TextField/TextField.stories.d.ts +1 -0
- 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/hooks/index.cjs +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.es.js +6 -4
- package/hooks/useForm/useForm.cjs +1 -0
- package/hooks/useForm/useForm.d.ts +48 -0
- package/hooks/useForm/useForm.es.js +98 -0
- package/hooks/useForm/useForm.utils.cjs +1 -0
- package/hooks/useForm/useForm.utils.d.ts +4 -0
- package/hooks/useForm/useForm.utils.es.js +12 -0
- package/package.json +1 -1
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
|
};
|
package/Tooltip/Tooltip.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 d=require("@emotion/react/jsx-runtime"),p=require("react"),y=require("../Flexbox/Flexbox.cjs"),q=require("../Icon/Icon.cjs"),X=require("../Typography/Typography.cjs"),N=require("../hooks/useCheckKeyboardMode/useCheckKeyboardMode.cjs"),F=require("@emotion/styled"),W=t=>t&&t.__esModule?t:{default:t},E=W(F),V=E.default.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: inline-block;
|
|
4
4
|
&[open] > [role='dialog'] {
|
|
5
5
|
display: flex;
|
|
6
6
|
}
|
|
7
|
-
`,
|
|
7
|
+
`,G=E.default.div`
|
|
8
8
|
position: absolute;
|
|
9
9
|
display: none;
|
|
10
10
|
flex-direction: column;
|
|
@@ -19,9 +19,14 @@
|
|
|
19
19
|
white-space: nowrap;
|
|
20
20
|
word-break: break-all;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
& svg:not(.tooltip-closer) {
|
|
23
|
+
width: 24,
|
|
24
|
+
height: 24
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
${({theme:{palette:{brand:t,grey:e}},color:x})=>{if(x==="primary")return{backgroundColor:t.primary.tooltip,color:e[100]};if(x==="secondary")return{backgroundColor:e[80],color:e.white}}}
|
|
23
28
|
|
|
24
|
-
${({theme:{typography:
|
|
29
|
+
${({size:t,theme:{typography:e,spacing:x}})=>{if(t==="small")return{fontSize:e.c3R.size,fontWeight:e.c3R.weight,lineHeight:e.c3R.lineHeight,letterSpacing:e.c3R.letterSpacing,padding:x.content(2)};if(t==="medium")return{fontSize:e.b4R.size,fontWeight:e.b4R.weight,lineHeight:e.b4R.lineHeight,letterSpacing:e.b4R.letterSpacing,padding:x.content(3)}}};
|
|
25
30
|
|
|
26
|
-
${({theme:{palette:{brand:t,grey:
|
|
27
|
-
`,
|
|
31
|
+
${({theme:{palette:{brand:t,grey:e}},placement:x,color:r,offset:u,arrowOffset:s})=>{let o={};const i=(u==null?void 0:u.x)||0,n=(u==null?void 0:u.y)||0,f=(s==null?void 0:s.x)||0,l=(s==null?void 0:s.y)||0;switch(x){case"bottom-left":o={top:`calc(-12px + ${n}px)`,left:`calc(-6px + ${i}px)`,transform:"translateY(-100%)","&:after":{content:'""',position:"absolute",top:"100%",left:`calc(12px + ${f}px)`,borderTop:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderRight:"6px solid transparent",borderBottom:"8px solid transparent",borderLeft:"6px solid transparent"}};break;case"bottom-center":o={top:`calc(-12px + ${n}px)`,left:"50%",transform:`translate(calc(-50% + ${i}px), -100%)`,"&:after":{content:'""',position:"absolute",top:"100%",left:`calc(50% + ${f}px)`,transform:"translateX(-50%)",borderTop:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderRight:"6px solid transparent",borderBottom:"8px solid transparent",borderLeft:"6px solid transparent"}};break;case"bottom-right":o={top:`calc(-12px + ${n}px)`,right:`calc(-6px - ${i}px)`,transform:"translateY(-100%)","&:after":{content:'""',position:"absolute",top:"100%",right:`calc(12px - ${f}px)`,borderTop:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderRight:"6px solid transparent",borderBottom:"8px solid transparent",borderLeft:"6px solid transparent"}};break;case"left-top":o={top:`calc(-6px + ${n}px)`,left:`calc(100% + 12px + ${i}px)`,"&:after":{content:'""',position:"absolute",top:`calc(12px + ${l}px)`,right:"100%",borderTop:"6px solid transparent",borderRight:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderBottom:"6px solid transparent",borderLeft:"8px solid transparent"}};break;case"left-middle":o={top:"50%",left:`calc(100% + 12px + ${i}px)`,transform:`translateY(calc(-50% + ${n}px))`,"&:after":{content:'""',position:"absolute",top:`calc(50% + ${l}px)`,right:"100%",transform:"translateY(-50%)",borderTop:"6px solid transparent",borderRight:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderBottom:"6px solid transparent",borderLeft:"8px solid transparent"}};break;case"left-bottom":o={bottom:`calc(-6px - ${n}px)`,left:`calc(100% + 12px + ${i}px)`,"&:after":{content:'""',position:"absolute",bottom:`calc(12px - ${l}px)`,right:"100%",borderTop:"6px solid transparent",borderRight:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderBottom:"6px solid transparent",borderLeft:"8px solid transparent"}};break;case"top-left":o={left:`calc(-6px + ${i}px)`,transform:`translate(0, calc(12px + ${n}px))`,"&:after":{content:'""',position:"absolute",bottom:"100%",left:`calc(12px + ${f}px)`,borderTop:"8px solid transparent",borderRight:"6px solid transparent",borderBottom:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderLeft:"6px solid transparent"}};break;case"top-center":o={right:"50%",transform:`translate(calc(50% + ${i}px), calc(12px + ${n}px))`,"&:after":{content:'""',position:"absolute",bottom:"100%",left:`calc(50% + ${f}px)`,transform:"translateX(-50%)",borderTop:"8px solid transparent",borderRight:"6px solid transparent",borderBottom:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderLeft:"6px solid transparent"}};break;case"top-right":o={right:`calc(-6px - ${i}px)`,transform:`translate(0, calc(12px + ${n}px))`,"&:after":{content:'""',position:"absolute",bottom:"100%",right:`calc(12px - ${f}px)`,borderTop:"8px solid transparent",borderRight:"6px solid transparent",borderBottom:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`,borderLeft:"6px solid transparent"}};break;case"right-top":o={top:`calc(-6px + ${n}px)`,right:`calc(100% + 12px + ${i}px)`,"&:after":{content:'""',position:"absolute",top:`calc(12px + ${l}px)`,left:"100%",borderTop:"6px solid transparent",borderRight:"8px solid transparent",borderBottom:"6px solid transparent",borderLeft:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`}};break;case"right-middle":o={top:"50%",right:`calc(100% + 12px + ${i}px)`,transform:`translateY(calc(-50% + ${n}px))`,"&:after":{content:'""',position:"absolute",top:`calc(50% + ${l}px)`,left:"100%",transform:"translateY(-50%)",borderTop:"6px solid transparent",borderRight:"8px solid transparent",borderBottom:"6px solid transparent",borderLeft:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`}};break;case"right-bottom":o={bottom:`calc(-6px - ${n}px)`,right:`calc(100% + 12px + ${i}px)`,"&:after":{content:'""',position:"absolute",bottom:`calc(12px - ${l}px)`,left:"100%",borderTop:"6px solid transparent",borderRight:"8px solid transparent",borderBottom:"6px solid transparent",borderLeft:`8px solid ${r==="primary"?t.primary.tooltip:e[80]}`}};break}return o}};
|
|
32
|
+
`,J=p.forwardRef(function({children:e,placement:x="bottom-center",color:r="primary",size:u="medium",title:s,body:o,closer:i,endAdornment:n,inlineCSS:f,open:l=!1,onClose:b,wrapperProps:S,offset:K,arrowOffset:Y,...c},C){const D=p.useId(),_=p.useId(),z=p.useId(),{isKeyboardMode:k}=N.default(),R=p.useRef(null),T=p.useRef(null),I=p.useRef(!0),[M,H]=p.useState(!1),w=(c==null?void 0:c.id)||D,L=(c==null?void 0:c.titleId)||_,B=(c==null?void 0:c.bodyId)||z,v=a=>{(a.key==="Enter"||a.key===" ")&&(b==null||b(a))};return p.useEffect(()=>{T.current&&T.current.getBoundingClientRect().width>=276&&H(!0)},[l]),p.useEffect(()=>{const a=m=>{m.key==="Escape"&&l&&(m.stopPropagation(),b==null||b(m))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[l,b]),p.useEffect(()=>{var m,$,h;if(I.current){I.current=!1;return}if(l){const g=(m=R.current)==null?void 0:m.querySelector('.tooltip-closer[role="button"]');if(g&&k&&g.focus(),!g){const j=($=R.current)==null?void 0:$.querySelector('[role="button"]');j&&k&&j.focus()}return}const a=(h=R.current)==null?void 0:h.querySelector('[role="button"]');a&&k&&a.focus()},[l,k]),d.jsxs(V,{ref:R,open:l,...S,css:S==null?void 0:S.inlineCSS,children:[p.Children.map(e,a=>{if(!p.isValidElement(a))return a;const m=$=>{var h,g;($.key==="Enter"||$.key===" ")&&((g=(h=a.props)==null?void 0:h.onClick)==null||g.call(h,$))};return p.cloneElement(a,{inlineCSS:{cursor:"pointer","&:active":{outline:"none"},...a.props.inlineCSS},role:"button",tabIndex:0,"aria-hidden":!1,"aria-expanded":l,"aria-haspopup":"dialog","aria-controls":w,focusable:!0,onKeyDown:m,...a.props})}),d.jsxs(G,{id:w,className:"tooltip",role:"dialog","aria-modal":"true","aria-labelledby":s?L:B,"aria-describedby":o?B:void 0,size:u,ref:C,placement:x,color:r,offset:K,arrowOffset:Y,...c,css:f,children:[s&&d.jsxs(y.default,{alignItems:"center",justifyContent:"space-between",gap:2,children:[d.jsx(X.default,{id:L,variant:u==="medium"?"h5B":"c3B",color:r==="primary"?"grey.100":"grey.white",children:s}),i&&d.jsx(y.default,{flexShrink:0,children:d.jsx(q.default,{className:"tooltip-closer",name:"CloseLine",size:"xSmall",color:r==="primary"?"grey.100":"grey.white",role:"button","aria-hidden":"false",focusable:"true",tabIndex:0,onClick:b,onKeyDown:v,"aria-label":"닫기",inlineCSS:{marginLeft:"2px",cursor:"pointer","&:active":{outline:"none"}}})})]}),o&&d.jsxs(y.default,{id:B,alignItems:"center",gap:2,ref:T,style:M?{width:"276px",whiteSpace:"wrap"}:{},children:[o,n&&d.jsx(y.default,{flexShrink:0,inlineCSS:{fontSize:"24px"},children:n}),!s&&i&&d.jsx(y.default,{flexShrink:0,children:d.jsx(q.default,{className:"tooltip-closer",name:"CloseLine",size:"xSmall",color:r==="primary"?"grey.100":"grey.white",role:"button","aria-hidden":"false",focusable:"true",tabIndex:0,onClick:b,onKeyDown:v,"aria-label":"닫기",inlineCSS:{marginLeft:"2px",cursor:"pointer","&:active":{outline:"none"}}})})]})]})]})});exports.default=J;
|
package/Tooltip/Tooltip.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
import { BrandColorKey } from '../typings/color';
|
|
3
|
-
import { GeneralComponentProps } from '../typings/component';
|
|
3
|
+
import { GeneralComponentProps, Size } from '../typings/component';
|
|
4
4
|
|
|
5
5
|
export interface TooltipOffset {
|
|
6
6
|
x?: number;
|
|
@@ -12,6 +12,7 @@ export interface TooltipProps extends GeneralComponentProps<Omit<HTMLAttributes<
|
|
|
12
12
|
title?: ReactNode;
|
|
13
13
|
body?: ReactNode;
|
|
14
14
|
endAdornment?: ReactNode;
|
|
15
|
+
size?: Extract<Size, 'small' | 'medium'>;
|
|
15
16
|
open?: boolean;
|
|
16
17
|
closer?: boolean;
|
|
17
18
|
onClose?: (e: SyntheticEvent) => void;
|