@teamturing/react-kit 2.7.1 → 2.8.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/dist/core/Tab/TabItem.d.ts +11 -0
- package/dist/core/Tab/index.d.ts +18 -0
- package/dist/core/Toast/index.d.ts +16 -0
- package/dist/core/Tooltip/index.d.ts +14 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2322 -1200
- package/dist/utils/scrollIntoView.d.ts +11 -0
- package/esm/core/Tab/TabItem.js +217 -0
- package/esm/core/Tab/index.js +147 -0
- package/esm/core/Toast/index.js +76 -0
- package/esm/core/Tooltip/index.js +256 -0
- package/esm/enigma/View/GridView/index.js +1 -1
- package/esm/index.js +3 -0
- package/esm/node_modules/lodash.throttle/index.js +424 -0
- package/esm/utils/scrollIntoView.js +46 -0
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
behavior?: ScrollBehavior;
|
|
3
|
+
direction?: 'horizontal' | 'vertical';
|
|
4
|
+
offset?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const scrollIntoView: ({ childrenRef, scrollContainerRef, options, }: {
|
|
7
|
+
childrenRef: HTMLElement;
|
|
8
|
+
scrollContainerRef?: HTMLElement | undefined;
|
|
9
|
+
options: Options;
|
|
10
|
+
}) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import typography from '../../packages/token-studio/esm/token/typography/index.js';
|
|
2
|
+
import { useRef, useContext } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import '../../node_modules/styled-system/dist/index.esm.js';
|
|
5
|
+
import { scrollIntoView } from '../../utils/scrollIntoView.js';
|
|
6
|
+
import View from '../View/index.js';
|
|
7
|
+
import UnstyledButton from '../_UnstyledButton.js';
|
|
8
|
+
import { TabContext } from './index.js';
|
|
9
|
+
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
10
|
+
import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
|
|
11
|
+
|
|
12
|
+
const TabItem = ({
|
|
13
|
+
children,
|
|
14
|
+
leadingIcon: LeadingIcon,
|
|
15
|
+
selected = false,
|
|
16
|
+
onClick,
|
|
17
|
+
size: propSize,
|
|
18
|
+
variant: propVariant
|
|
19
|
+
}) => {
|
|
20
|
+
const ref = useRef(null);
|
|
21
|
+
const {
|
|
22
|
+
size: contextSize,
|
|
23
|
+
variant: contextVariant,
|
|
24
|
+
containerRef
|
|
25
|
+
} = useContext(TabContext);
|
|
26
|
+
const size = propSize ?? contextSize;
|
|
27
|
+
const variant = propVariant ?? contextVariant;
|
|
28
|
+
const handleClick = e => {
|
|
29
|
+
if (containerRef && containerRef.current && ref.current) {
|
|
30
|
+
scrollIntoView({
|
|
31
|
+
scrollContainerRef: containerRef.current,
|
|
32
|
+
childrenRef: ref.current,
|
|
33
|
+
options: {
|
|
34
|
+
behavior: 'smooth',
|
|
35
|
+
offset: 72
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
onClick?.(e);
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(BaseTabItem, {
|
|
42
|
+
role: 'tab',
|
|
43
|
+
ref: ref,
|
|
44
|
+
variant: variant,
|
|
45
|
+
size: size,
|
|
46
|
+
leadingIcon: LeadingIcon,
|
|
47
|
+
selected: selected,
|
|
48
|
+
onClick: handleClick,
|
|
49
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsxs(View, {
|
|
50
|
+
sx: {
|
|
51
|
+
display: 'flex',
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
columnGap: 1
|
|
56
|
+
},
|
|
57
|
+
children: [LeadingIcon ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingIcon, {}) : null, /*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
58
|
+
children: children
|
|
59
|
+
})]
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const BaseTabItem = styled(UnstyledButton)(({
|
|
64
|
+
theme
|
|
65
|
+
}) => ({
|
|
66
|
+
'width': 'initial',
|
|
67
|
+
'position': 'relative',
|
|
68
|
+
'transition': 'background-color 100ms, color 100ms',
|
|
69
|
+
'whiteSpace': 'nowrap',
|
|
70
|
+
'& svg': {
|
|
71
|
+
transition: 'color 100ms'
|
|
72
|
+
},
|
|
73
|
+
'&:focus-visible': {
|
|
74
|
+
outlineColor: theme.colors['border/focused'],
|
|
75
|
+
outlineStyle: 'solid',
|
|
76
|
+
outlineWidth: 2,
|
|
77
|
+
outlineOffset: 2
|
|
78
|
+
}
|
|
79
|
+
}), () => variant({
|
|
80
|
+
prop: 'size',
|
|
81
|
+
variants: {
|
|
82
|
+
l: {
|
|
83
|
+
'px': 4,
|
|
84
|
+
'py': 2,
|
|
85
|
+
'fontSize': typography['s'].fontSize,
|
|
86
|
+
'fontWeight': typography['s'].fontWeight,
|
|
87
|
+
'lineHeight': typography['s'].lineHeight,
|
|
88
|
+
'& svg': {
|
|
89
|
+
width: 20,
|
|
90
|
+
height: 20
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
m: {
|
|
94
|
+
'px': 4,
|
|
95
|
+
'py': 2,
|
|
96
|
+
'fontSize': typography['xs'].fontSize,
|
|
97
|
+
'fontWeight': typography['xs'].fontWeight,
|
|
98
|
+
'lineHeight': typography['xs'].lineHeight,
|
|
99
|
+
'& svg': {
|
|
100
|
+
width: 20,
|
|
101
|
+
height: 20
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
s: {
|
|
105
|
+
'px': 3,
|
|
106
|
+
'py': 2,
|
|
107
|
+
'fontSize': typography['xxs'].fontSize,
|
|
108
|
+
'fontWeight': typography['xxs'].fontWeight,
|
|
109
|
+
'lineHeight': typography['xxs'].lineHeight,
|
|
110
|
+
'& svg': {
|
|
111
|
+
width: 16,
|
|
112
|
+
height: 16
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}), ({
|
|
117
|
+
theme,
|
|
118
|
+
selected
|
|
119
|
+
}) => variant({
|
|
120
|
+
prop: 'variant',
|
|
121
|
+
variants: {
|
|
122
|
+
plain: {
|
|
123
|
+
borderRadius: theme.radii.full,
|
|
124
|
+
...(selected ? {
|
|
125
|
+
'color': theme.colors['text/neutral'],
|
|
126
|
+
'backgroundColor': theme.colors['bg/selected/subtle'],
|
|
127
|
+
'& svg': {
|
|
128
|
+
color: theme.colors['icon/selected']
|
|
129
|
+
}
|
|
130
|
+
} : {
|
|
131
|
+
'color': theme.colors['text/neutral/subtler'],
|
|
132
|
+
'backgroundColor': theme.colors['bg/neutral/subtler'],
|
|
133
|
+
'& svg': {
|
|
134
|
+
color: theme.colors['icon/neutral']
|
|
135
|
+
},
|
|
136
|
+
'&:hover, &:active': {
|
|
137
|
+
'color': theme.colors['text/neutral/subtle'],
|
|
138
|
+
'& svg': {
|
|
139
|
+
color: theme.colors['icon/neutral/bolder']
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
},
|
|
144
|
+
outlined: {
|
|
145
|
+
borderRadius: theme.radii.full,
|
|
146
|
+
...(selected ? {
|
|
147
|
+
'color': theme.colors['text/inverse'],
|
|
148
|
+
'backgroundColor': theme.colors['bg/selected'],
|
|
149
|
+
'& svg': {
|
|
150
|
+
color: theme.colors['icon/inverse']
|
|
151
|
+
}
|
|
152
|
+
} : {
|
|
153
|
+
'color': theme.colors['text/neutral/subtler'],
|
|
154
|
+
'backgroundColor': theme.colors['bg/neutral/subtler'],
|
|
155
|
+
'& svg': {
|
|
156
|
+
color: theme.colors['icon/neutral']
|
|
157
|
+
},
|
|
158
|
+
'&:after': {
|
|
159
|
+
content: '""',
|
|
160
|
+
position: 'absolute',
|
|
161
|
+
top: 0,
|
|
162
|
+
right: 0,
|
|
163
|
+
bottom: 0,
|
|
164
|
+
left: 0,
|
|
165
|
+
borderWidth: 1,
|
|
166
|
+
borderStyle: 'solid',
|
|
167
|
+
borderColor: theme.colors['border/neutral/bolder'],
|
|
168
|
+
borderRadius: theme.radii.full,
|
|
169
|
+
boxSizing: 'border-box'
|
|
170
|
+
},
|
|
171
|
+
'&:hover': {
|
|
172
|
+
backgroundColor: theme.colors['bg/neutral/subtler/hovered']
|
|
173
|
+
},
|
|
174
|
+
'&:active': {
|
|
175
|
+
backgroundColor: theme.colors['bg/neutral/subtler/pressed']
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
},
|
|
179
|
+
underline: {
|
|
180
|
+
borderRadius: theme.radii.xxs,
|
|
181
|
+
...(selected ? {
|
|
182
|
+
'color': theme.colors['text/selected'],
|
|
183
|
+
'backgroundColor': theme.colors['bg/neutral/subtler'],
|
|
184
|
+
'& svg': {
|
|
185
|
+
color: theme.colors['icon/selected']
|
|
186
|
+
},
|
|
187
|
+
':after': {
|
|
188
|
+
content: '""',
|
|
189
|
+
position: 'absolute',
|
|
190
|
+
top: 0,
|
|
191
|
+
right: 0,
|
|
192
|
+
bottom: 0,
|
|
193
|
+
left: 0,
|
|
194
|
+
borderBottomWidth: 2,
|
|
195
|
+
borderBottomStyle: 'solid',
|
|
196
|
+
borderBottomColor: theme.colors['border/selected'],
|
|
197
|
+
borderRadius: theme.radii.none,
|
|
198
|
+
boxSizing: 'border-box'
|
|
199
|
+
}
|
|
200
|
+
} : {
|
|
201
|
+
'color': theme.colors['text/neutral/subtler'],
|
|
202
|
+
'backgroundColor': theme.colors['bg/neutral/subtler'],
|
|
203
|
+
'& svg': {
|
|
204
|
+
color: theme.colors['icon/neutral']
|
|
205
|
+
},
|
|
206
|
+
':hover, :active': {
|
|
207
|
+
'color': theme.colors['text/neutral/subtle'],
|
|
208
|
+
'& svg': {
|
|
209
|
+
color: theme.colors['icon/neutral/bolder']
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}));
|
|
216
|
+
|
|
217
|
+
export { TabItem as default };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { createContext, useRef, useState, useEffect } from 'react';
|
|
2
|
+
import SvgChevronLeft from '../../packages/icons/esm/ChevronLeft.js';
|
|
3
|
+
import SvgChevronRight from '../../packages/icons/esm/ChevronRight.js';
|
|
4
|
+
import elevation from '../../packages/token-studio/esm/token/elevation/index.js';
|
|
5
|
+
import gradient from '../../packages/token-studio/esm/token/gradient/index.js';
|
|
6
|
+
import '../../packages/token-studio/esm/token/typography/index.js';
|
|
7
|
+
import throttle from '../../node_modules/lodash.throttle/index.js';
|
|
8
|
+
import useResize from '../../hook/useResize.js';
|
|
9
|
+
import { forcePixelValue } from '../../utils/forcePixelValue.js';
|
|
10
|
+
import IconButton from '../IconButton/index.js';
|
|
11
|
+
import View from '../View/index.js';
|
|
12
|
+
import TabItem from './TabItem.js';
|
|
13
|
+
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
14
|
+
|
|
15
|
+
const TabContext = /*#__PURE__*/createContext({});
|
|
16
|
+
const Tab = ({
|
|
17
|
+
variant = 'plain',
|
|
18
|
+
size = 'm',
|
|
19
|
+
gap = 2,
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
const rootRef = useRef(null);
|
|
23
|
+
const [isLeftButtonVisible, setIsLeftButtonVisible] = useState(rootRef.current ? rootRef.current.scrollLeft > 0 : false);
|
|
24
|
+
const [isRightButtonVisible, setIsRightButtonVisible] = useState(rootRef.current ? rootRef.current.clientWidth + rootRef.current.scrollLeft < rootRef.current.scrollWidth : false);
|
|
25
|
+
const handleScrollButtonVisibility = () => {
|
|
26
|
+
if (rootRef.current) {
|
|
27
|
+
setIsLeftButtonVisible(rootRef.current ? rootRef.current.scrollLeft > 0 : false);
|
|
28
|
+
setIsRightButtonVisible(rootRef.current ? rootRef.current.clientWidth + Math.ceil(rootRef.current.scrollLeft) < rootRef.current.scrollWidth : false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const buttonWidth = 32;
|
|
32
|
+
const gradientWidth = 40;
|
|
33
|
+
const handleLeftButtonClick = () => {
|
|
34
|
+
if (rootRef.current) {
|
|
35
|
+
rootRef.current.scrollTo({
|
|
36
|
+
left: rootRef.current.scrollLeft - rootRef.current.clientWidth + buttonWidth + gradientWidth,
|
|
37
|
+
behavior: 'smooth'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const handleRightButtonClick = () => {
|
|
42
|
+
if (rootRef.current) {
|
|
43
|
+
rootRef.current.scrollTo({
|
|
44
|
+
left: rootRef.current.scrollLeft + rootRef.current.clientWidth - (buttonWidth + gradientWidth),
|
|
45
|
+
behavior: 'smooth'
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
handleScrollButtonVisibility();
|
|
51
|
+
}, []);
|
|
52
|
+
useResize(handleScrollButtonVisibility);
|
|
53
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(TabContext.Provider, {
|
|
54
|
+
value: {
|
|
55
|
+
variant,
|
|
56
|
+
size,
|
|
57
|
+
containerRef: rootRef
|
|
58
|
+
},
|
|
59
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsxs(View, {
|
|
60
|
+
position: 'relative',
|
|
61
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
62
|
+
ref: rootRef,
|
|
63
|
+
role: 'tablist',
|
|
64
|
+
sx: {
|
|
65
|
+
'width': 'auto',
|
|
66
|
+
'display': 'flex',
|
|
67
|
+
'flexDirection': 'row',
|
|
68
|
+
'alignItems': 'center',
|
|
69
|
+
'columnGap': gap,
|
|
70
|
+
'overflowX': 'auto',
|
|
71
|
+
'msOverflowStyle': 'none',
|
|
72
|
+
'::-webkit-scrollbar': {
|
|
73
|
+
display: 'none'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
onScroll: throttle(handleScrollButtonVisibility, 150),
|
|
77
|
+
children: children
|
|
78
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsxs(View, {
|
|
79
|
+
display: ['none', 'initial', 'initial'],
|
|
80
|
+
children: [isLeftButtonVisible ? /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
|
|
81
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
82
|
+
sx: {
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
top: 0,
|
|
85
|
+
left: forcePixelValue(buttonWidth),
|
|
86
|
+
bottom: 0,
|
|
87
|
+
width: forcePixelValue(gradientWidth),
|
|
88
|
+
height: '100%',
|
|
89
|
+
background: `linear-gradient(${gradient['overlay/floating/toright']})`,
|
|
90
|
+
pointerEvents: 'none'
|
|
91
|
+
}
|
|
92
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
93
|
+
sx: {
|
|
94
|
+
position: 'absolute',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
top: 0,
|
|
98
|
+
left: 0,
|
|
99
|
+
bottom: 0,
|
|
100
|
+
backgroundColor: elevation.surface
|
|
101
|
+
},
|
|
102
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(IconButton, {
|
|
103
|
+
size: 's',
|
|
104
|
+
variant: 'plain-bold',
|
|
105
|
+
icon: SvgChevronLeft,
|
|
106
|
+
onClick: handleLeftButtonClick
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
}) : null, isRightButtonVisible ? /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
|
|
110
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
111
|
+
sx: {
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
top: 0,
|
|
114
|
+
right: forcePixelValue(buttonWidth),
|
|
115
|
+
bottom: 0,
|
|
116
|
+
width: forcePixelValue(gradientWidth),
|
|
117
|
+
height: '100%',
|
|
118
|
+
background: `linear-gradient(${gradient['overlay/floating/toleft']})`,
|
|
119
|
+
pointerEvents: 'none'
|
|
120
|
+
}
|
|
121
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsx(View, {
|
|
122
|
+
sx: {
|
|
123
|
+
position: 'absolute',
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
top: 0,
|
|
127
|
+
right: 0,
|
|
128
|
+
bottom: 0,
|
|
129
|
+
backgroundColor: elevation.surface
|
|
130
|
+
},
|
|
131
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(IconButton, {
|
|
132
|
+
size: 's',
|
|
133
|
+
variant: 'plain-bold',
|
|
134
|
+
icon: SvgChevronRight,
|
|
135
|
+
onClick: handleRightButtonClick
|
|
136
|
+
})
|
|
137
|
+
})]
|
|
138
|
+
}) : null]
|
|
139
|
+
})]
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
var index = Object.assign(Tab, {
|
|
144
|
+
Item: TabItem
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export { TabContext, index as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import SvgCheckInCircle from '../../packages/icons/esm/CheckInCircle.js';
|
|
3
|
+
import SvgExclamationPointInCircle from '../../packages/icons/esm/ExclamationPointInCircle.js';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import '../../node_modules/styled-system/dist/index.esm.js';
|
|
6
|
+
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
7
|
+
import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
|
|
8
|
+
|
|
9
|
+
const Toast = ({
|
|
10
|
+
variant = 'success',
|
|
11
|
+
resizing = 'hug',
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const IconByVariant = {
|
|
15
|
+
success: SvgCheckInCircle,
|
|
16
|
+
warning: SvgExclamationPointInCircle
|
|
17
|
+
}[variant];
|
|
18
|
+
return /*#__PURE__*/jsxRuntimeExports.jsxs(BaseToast, {
|
|
19
|
+
variant: variant,
|
|
20
|
+
resizing: resizing,
|
|
21
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(IconByVariant, {}), children]
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const BaseToast = styled.div(({
|
|
25
|
+
theme
|
|
26
|
+
}) => ({
|
|
27
|
+
'display': 'flex',
|
|
28
|
+
'flexDirection': 'row',
|
|
29
|
+
'alignItems': 'center',
|
|
30
|
+
'columnGap': theme.space[3],
|
|
31
|
+
'backgroundColor': theme.colors['bg/neutral/bold'],
|
|
32
|
+
'color': theme.colors['text/inverse'],
|
|
33
|
+
'borderRadius': theme.radii.m,
|
|
34
|
+
'padding': theme.space[4],
|
|
35
|
+
'fontSize': theme.fontSizes.s,
|
|
36
|
+
'fontWeight': theme.fontWeights.medium,
|
|
37
|
+
'lineHeight': theme.lineHeights[2],
|
|
38
|
+
'& div': {
|
|
39
|
+
margin: 0,
|
|
40
|
+
display: 'inline-block'
|
|
41
|
+
},
|
|
42
|
+
'& svg': {
|
|
43
|
+
width: 24,
|
|
44
|
+
minWidth: 24,
|
|
45
|
+
height: 24,
|
|
46
|
+
minHeight: 24
|
|
47
|
+
}
|
|
48
|
+
}), ({
|
|
49
|
+
theme
|
|
50
|
+
}) => variant({
|
|
51
|
+
prop: 'variant',
|
|
52
|
+
variants: {
|
|
53
|
+
success: {
|
|
54
|
+
'& svg': {
|
|
55
|
+
color: theme.colors['icon/success']
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
warning: {
|
|
59
|
+
'& svg': {
|
|
60
|
+
color: theme.colors['icon/warning']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}), () => variant({
|
|
65
|
+
prop: 'resizing',
|
|
66
|
+
variants: {
|
|
67
|
+
fill: {
|
|
68
|
+
width: '100%'
|
|
69
|
+
},
|
|
70
|
+
hug: {
|
|
71
|
+
width: 'fit-content'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
export { Toast as default };
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import styled, { keyframes } from 'styled-components';
|
|
2
|
+
import { forcePixelValue } from '../../utils/forcePixelValue.js';
|
|
3
|
+
import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
|
|
4
|
+
|
|
5
|
+
const Tooltip = ({
|
|
6
|
+
children,
|
|
7
|
+
direction = 'top-center',
|
|
8
|
+
text,
|
|
9
|
+
className: propClassName
|
|
10
|
+
}) => {
|
|
11
|
+
const className = [propClassName, `tooltip-direction-${direction}`].join(' ');
|
|
12
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(BaseTooltip, {
|
|
13
|
+
role: 'tooltip',
|
|
14
|
+
"aria-label": text,
|
|
15
|
+
className: className,
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const tooltipAppear = keyframes`
|
|
20
|
+
from {
|
|
21
|
+
opacity: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
to {
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const BaseTooltip = styled.span`
|
|
29
|
+
display: inline-block;
|
|
30
|
+
position: relative;
|
|
31
|
+
|
|
32
|
+
&::before {
|
|
33
|
+
position: absolute;
|
|
34
|
+
z-index: 1000001;
|
|
35
|
+
display: none;
|
|
36
|
+
width: 0px;
|
|
37
|
+
height: 0px;
|
|
38
|
+
color: ${({
|
|
39
|
+
theme
|
|
40
|
+
}) => theme.colors['bg/neutral/bolder']};
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
content: '';
|
|
43
|
+
border: 6px solid transparent;
|
|
44
|
+
opacity: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&::after {
|
|
48
|
+
position: absolute;
|
|
49
|
+
z-index: 1000000;
|
|
50
|
+
display: none;
|
|
51
|
+
padding: ${({
|
|
52
|
+
theme
|
|
53
|
+
}) => `${forcePixelValue(theme.space[2])} ${forcePixelValue(theme.space[3])}`};
|
|
54
|
+
font-size: ${({
|
|
55
|
+
theme
|
|
56
|
+
}) => forcePixelValue(theme.fontSizes.xxs)};
|
|
57
|
+
font-weight: ${({
|
|
58
|
+
theme
|
|
59
|
+
}) => theme.fontWeights.medium};
|
|
60
|
+
line-height: ${({
|
|
61
|
+
theme
|
|
62
|
+
}) => theme.lineHeights[2]};
|
|
63
|
+
-webkit-font-smoothing: subpixel-antialiased;
|
|
64
|
+
color: ${({
|
|
65
|
+
theme
|
|
66
|
+
}) => theme.colors['text/inverse']};
|
|
67
|
+
text-align: center;
|
|
68
|
+
text-decoration: none;
|
|
69
|
+
text-shadow: none;
|
|
70
|
+
text-transform: none;
|
|
71
|
+
letter-spacing: normal;
|
|
72
|
+
word-wrap: break-word;
|
|
73
|
+
white-space: pre;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
content: attr(aria-label);
|
|
76
|
+
background: ${({
|
|
77
|
+
theme
|
|
78
|
+
}) => theme.colors['bg/neutral/bolder']};
|
|
79
|
+
border-radius: ${({
|
|
80
|
+
theme
|
|
81
|
+
}) => forcePixelValue(theme.radii.xs)};
|
|
82
|
+
box-shadow: ${({
|
|
83
|
+
theme
|
|
84
|
+
}) => theme.shadows['shadow/overlay']};
|
|
85
|
+
opacity: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&:hover,
|
|
89
|
+
&:active,
|
|
90
|
+
&:focus {
|
|
91
|
+
&::before,
|
|
92
|
+
&::after {
|
|
93
|
+
display: table-cell;
|
|
94
|
+
text-decoration: none;
|
|
95
|
+
animation-name: ${tooltipAppear};
|
|
96
|
+
animation-duration: 100ms;
|
|
97
|
+
animation-fill-mode: forwards;
|
|
98
|
+
animation-timing-function: ease-in;
|
|
99
|
+
animation-delay: 300ms;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.tooltip-direction-bottom-center,
|
|
104
|
+
&.tooltip-direction-bottom-right,
|
|
105
|
+
&.tooltip-direction-bottom-left {
|
|
106
|
+
&::after {
|
|
107
|
+
top: 100%;
|
|
108
|
+
right: 50%;
|
|
109
|
+
margin-top: ${({
|
|
110
|
+
theme
|
|
111
|
+
}) => forcePixelValue(theme.space[2])};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&::before {
|
|
115
|
+
top: auto;
|
|
116
|
+
right: 50%;
|
|
117
|
+
bottom: ${({
|
|
118
|
+
theme
|
|
119
|
+
}) => forcePixelValue(theme.space[-2] + theme.space['-0.25'])};
|
|
120
|
+
margin-right: -6px;
|
|
121
|
+
border-bottom-color: ${({
|
|
122
|
+
theme
|
|
123
|
+
}) => theme.colors['bg/neutral/bolder']};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.tooltip-direction-bottom-right {
|
|
128
|
+
&::after {
|
|
129
|
+
right: auto;
|
|
130
|
+
left: 50%;
|
|
131
|
+
margin-left: -${({
|
|
132
|
+
theme
|
|
133
|
+
}) => forcePixelValue(theme.space[4])};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&.tooltip-direction-bottom-left::after {
|
|
138
|
+
margin-right: -${({
|
|
139
|
+
theme
|
|
140
|
+
}) => forcePixelValue(theme.space[4])};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Tooltips above the object
|
|
144
|
+
&.tooltip-direction-top-center,
|
|
145
|
+
&.tooltip-direction-top-right,
|
|
146
|
+
&.tooltip-direction-top-left {
|
|
147
|
+
&::after {
|
|
148
|
+
right: 50%;
|
|
149
|
+
bottom: 100%;
|
|
150
|
+
margin-bottom: ${({
|
|
151
|
+
theme
|
|
152
|
+
}) => forcePixelValue(theme.space[2])};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
&::before {
|
|
156
|
+
top: ${({
|
|
157
|
+
theme
|
|
158
|
+
}) => forcePixelValue(theme.space[-2] + theme.space['-0.25'])};
|
|
159
|
+
right: 50%;
|
|
160
|
+
bottom: auto;
|
|
161
|
+
margin-right: -6px;
|
|
162
|
+
border-top-color: ${({
|
|
163
|
+
theme
|
|
164
|
+
}) => theme.colors['bg/neutral/bolder']};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&.tooltip-direction-top-right {
|
|
169
|
+
&::after {
|
|
170
|
+
right: auto;
|
|
171
|
+
left: 50%;
|
|
172
|
+
margin-left: -${({
|
|
173
|
+
theme
|
|
174
|
+
}) => forcePixelValue(theme.space[4])};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&.tooltip-direction-top-left::after {
|
|
179
|
+
margin-right: -${({
|
|
180
|
+
theme
|
|
181
|
+
}) => forcePixelValue(theme.space[4])};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&.tooltip-direction-top-center::after,
|
|
185
|
+
&.tooltip-direction-bottom-center::after {
|
|
186
|
+
transform: translateX(50%);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&.tooltip-direction-left {
|
|
190
|
+
&::after {
|
|
191
|
+
right: 100%;
|
|
192
|
+
bottom: 50%;
|
|
193
|
+
margin-right: ${({
|
|
194
|
+
theme
|
|
195
|
+
}) => forcePixelValue(theme.space[2])};
|
|
196
|
+
transform: translateY(50%);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&::before {
|
|
200
|
+
top: 50%;
|
|
201
|
+
bottom: 50%;
|
|
202
|
+
left: ${({
|
|
203
|
+
theme
|
|
204
|
+
}) => forcePixelValue(theme.space[-2] + theme.space['-0.25'])};
|
|
205
|
+
margin-top: -6px;
|
|
206
|
+
border-left-color: ${({
|
|
207
|
+
theme
|
|
208
|
+
}) => theme.colors['bg/neutral/bolder']};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&.tooltip-direction-right {
|
|
213
|
+
&::after {
|
|
214
|
+
bottom: 50%;
|
|
215
|
+
left: 100%;
|
|
216
|
+
margin-left: ${({
|
|
217
|
+
theme
|
|
218
|
+
}) => forcePixelValue(theme.space[2])};
|
|
219
|
+
transform: translateY(50%);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&::before {
|
|
223
|
+
top: 50%;
|
|
224
|
+
right: ${({
|
|
225
|
+
theme
|
|
226
|
+
}) => forcePixelValue(theme.space[-2] + theme.space['-0.25'])};
|
|
227
|
+
bottom: 50%;
|
|
228
|
+
margin-top: -6px;
|
|
229
|
+
border-right-color: ${({
|
|
230
|
+
theme
|
|
231
|
+
}) => theme.colors['bg/neutral/bolder']};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&::after {
|
|
236
|
+
width: max-content;
|
|
237
|
+
max-width: 240px;
|
|
238
|
+
word-wrap: break-word;
|
|
239
|
+
white-space: pre-line;
|
|
240
|
+
border-collapse: separate;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
&.tooltip-direction-bottom-center::after,
|
|
244
|
+
&.tooltip-direction-top-center::after {
|
|
245
|
+
right: auto;
|
|
246
|
+
left: 50%;
|
|
247
|
+
transform: translateX(-50%);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&.tooltip-direction-left::after,
|
|
251
|
+
&.tooltip-direction-right::after {
|
|
252
|
+
right: 100%;
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
255
|
+
|
|
256
|
+
export { Tooltip as default };
|