@ultraviolet/ui 1.0.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/LICENSE +189 -0
- package/README.md +64 -0
- package/dist/index.d.ts +2427 -0
- package/dist/react-datepicker/dist/react-datepicker.min.css.js +3 -0
- package/dist/react-toastify/dist/ReactToastify.min.css.js +3 -0
- package/dist/src/components/ActionBar/index.js +55 -0
- package/dist/src/components/Alert/index.js +144 -0
- package/dist/src/components/Avatar/index.js +90 -0
- package/dist/src/components/Badge/index.js +143 -0
- package/dist/src/components/Banner/index.js +117 -0
- package/dist/src/components/BarChart/Tooltip.js +63 -0
- package/dist/src/components/BarChart/index.js +94 -0
- package/dist/src/components/BarStack/index.js +223 -0
- package/dist/src/components/Breadcrumbs/index.js +89 -0
- package/dist/src/components/Bullet/index.js +137 -0
- package/dist/src/components/Button/index.js +303 -0
- package/dist/src/components/Card/index.js +81 -0
- package/dist/src/components/Carousel/index.js +162 -0
- package/dist/src/components/Checkbox/index.js +338 -0
- package/dist/src/components/CopyButton/index.js +92 -0
- package/dist/src/components/DateInput/index.js +250 -0
- package/dist/src/components/EmptyState/index.js +124 -0
- package/dist/src/components/Expandable/index.js +84 -0
- package/dist/src/components/Icon/index.js +350 -0
- package/dist/src/components/LineChart/CustomLegend.js +147 -0
- package/dist/src/components/LineChart/Tooltip.js +58 -0
- package/dist/src/components/LineChart/helpers.js +75 -0
- package/dist/src/components/LineChart/index.js +139 -0
- package/dist/src/components/Link/index.js +159 -0
- package/dist/src/components/List/Body.js +22 -0
- package/dist/src/components/List/Cell.js +38 -0
- package/dist/src/components/List/HeaderCell.js +118 -0
- package/dist/src/components/List/HeaderRow.js +47 -0
- package/dist/src/components/List/ListContext.js +120 -0
- package/dist/src/components/List/Row.js +211 -0
- package/dist/src/components/List/SelectBar.js +52 -0
- package/dist/src/components/List/SkeletonRows.js +54 -0
- package/dist/src/components/List/constants.js +3 -0
- package/dist/src/components/List/index.js +77 -0
- package/dist/src/components/Loader/index.js +87 -0
- package/dist/src/components/Menu/Item.js +122 -0
- package/dist/src/components/Menu/index.js +143 -0
- package/dist/src/components/Modal/index.js +279 -0
- package/dist/src/components/Notice/index.js +33 -0
- package/dist/src/components/NumberInput/helpers.js +6 -0
- package/dist/src/components/NumberInput/index.js +366 -0
- package/dist/src/components/Pagination/getPageNumbers.js +32 -0
- package/dist/src/components/Pagination/index.js +118 -0
- package/dist/src/components/PasswordCheck/index.js +42 -0
- package/dist/src/components/PasswordStrengthMeter/index.js +116 -0
- package/dist/src/components/PieChart/Legends.js +183 -0
- package/dist/src/components/PieChart/Tooltip.js +64 -0
- package/dist/src/components/PieChart/index.js +133 -0
- package/dist/src/components/PieChart/patterns.js +9 -0
- package/dist/src/components/Popover/index.js +131 -0
- package/dist/src/components/ProgressBar/index.js +72 -0
- package/dist/src/components/Radio/index.js +231 -0
- package/dist/src/components/Row/index.js +43 -0
- package/dist/src/components/SelectInput/index.js +662 -0
- package/dist/src/components/SelectableCard/index.js +154 -0
- package/dist/src/components/Separator/index.js +91 -0
- package/dist/src/components/Skeleton/Block.js +53 -0
- package/dist/src/components/Skeleton/Blocks.js +52 -0
- package/dist/src/components/Skeleton/BoxWithIcon.js +47 -0
- package/dist/src/components/Skeleton/Donut.js +58 -0
- package/dist/src/components/Skeleton/IconSkeleton.js +37 -0
- package/dist/src/components/Skeleton/Line.js +19 -0
- package/dist/src/components/Skeleton/List.js +60 -0
- package/dist/src/components/Skeleton/Slider.js +57 -0
- package/dist/src/components/Skeleton/index.js +85 -0
- package/dist/src/components/Snippet/index.js +250 -0
- package/dist/src/components/Stack/index.js +24 -0
- package/dist/src/components/Status/index.js +101 -0
- package/dist/src/components/StepList/index.js +81 -0
- package/dist/src/components/Stepper/index.js +217 -0
- package/dist/src/components/SwitchButton/FocusOverlay.js +47 -0
- package/dist/src/components/SwitchButton/index.js +131 -0
- package/dist/src/components/Table/Body.js +12 -0
- package/dist/src/components/Table/Cell.js +27 -0
- package/dist/src/components/Table/Header.js +21 -0
- package/dist/src/components/Table/HeaderCell.js +119 -0
- package/dist/src/components/Table/HeaderRow.js +35 -0
- package/dist/src/components/Table/Row.js +70 -0
- package/dist/src/components/Table/SelectBar.js +52 -0
- package/dist/src/components/Table/SkeletonRows.js +52 -0
- package/dist/src/components/Table/TableContext.js +91 -0
- package/dist/src/components/Table/index.js +84 -0
- package/dist/src/components/Tabs/Tab.js +165 -0
- package/dist/src/components/Tabs/TabMenu.js +46 -0
- package/dist/src/components/Tabs/TabMenuItem.js +40 -0
- package/dist/src/components/Tabs/TabsContext.js +6 -0
- package/dist/src/components/Tabs/index.js +117 -0
- package/dist/src/components/Tag/index.js +177 -0
- package/dist/src/components/TagInput/index.js +277 -0
- package/dist/src/components/TagList/index.js +110 -0
- package/dist/src/components/Text/index.js +106 -0
- package/dist/src/components/TextInput/index.js +529 -0
- package/dist/src/components/TimeInput/index.js +38 -0
- package/dist/src/components/Toaster/index.js +116 -0
- package/dist/src/components/Toggle/index.js +192 -0
- package/dist/src/components/Tooltip/helpers.js +131 -0
- package/dist/src/components/Tooltip/index.js +275 -0
- package/dist/src/components/VerificationCode/index.js +203 -0
- package/dist/src/helpers/isJSON.js +11 -0
- package/dist/src/helpers/legend.js +13 -0
- package/dist/src/helpers/recursivelyGetChildrenString.js +12 -0
- package/dist/src/index.js +63 -0
- package/dist/src/theme/index.js +25 -0
- package/dist/src/utils/animations.js +250 -0
- package/dist/src/utils/capitalize.js +4 -0
- package/dist/src/utils/ids.js +12 -0
- package/dist/src/utils/normalize.js +36 -0
- package/dist/src/utils/responsive/Breakpoint.js +12 -0
- package/dist/src/utils/responsive/utilities.js +12 -0
- package/package.json +70 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { keyframes, css } from '@emotion/react';
|
|
3
|
+
import { Children, Fragment } from 'react';
|
|
4
|
+
import flattenChildren from 'react-flatten-children';
|
|
5
|
+
import { Icon } from '../Icon/index.js';
|
|
6
|
+
import { Text } from '../Text/index.js';
|
|
7
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
10
|
+
const loadingAnimation = keyframes`
|
|
11
|
+
from {
|
|
12
|
+
width: 0;
|
|
13
|
+
}
|
|
14
|
+
to {
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
const StyledStepContainer = /*#__PURE__*/_styled("div", {
|
|
19
|
+
target: "e19ft7rb5"
|
|
20
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
21
|
+
name: "b8wmnj",
|
|
22
|
+
styles: "display:flex;flex-direction:column;align-items:center;justify-content:flex-start"
|
|
23
|
+
} : {
|
|
24
|
+
name: "b8wmnj",
|
|
25
|
+
styles: "display:flex;flex-direction:column;align-items:center;justify-content:flex-start",
|
|
26
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
27
|
+
});
|
|
28
|
+
const StyledStep = /*#__PURE__*/_styled('div', {
|
|
29
|
+
shouldForwardProp: prop => !['temporal'].includes(prop),
|
|
30
|
+
target: "e19ft7rb4"
|
|
31
|
+
})("border-radius:", _ref => {
|
|
32
|
+
let {
|
|
33
|
+
theme
|
|
34
|
+
} = _ref;
|
|
35
|
+
return theme.radii.circle;
|
|
36
|
+
}, ";display:flex;align-items:center;justify-content:center;color:", _ref2 => {
|
|
37
|
+
let {
|
|
38
|
+
temporal,
|
|
39
|
+
theme
|
|
40
|
+
} = _ref2;
|
|
41
|
+
if (temporal === 'previous') return theme.colors.success.text;
|
|
42
|
+
if (temporal === 'current') return theme.colors.primary.text;
|
|
43
|
+
return theme.colors.neutral.textWeak;
|
|
44
|
+
}, ";background-color:", _ref3 => {
|
|
45
|
+
let {
|
|
46
|
+
temporal,
|
|
47
|
+
theme
|
|
48
|
+
} = _ref3;
|
|
49
|
+
if (temporal === 'previous') return theme.colors.success.background;
|
|
50
|
+
if (temporal === 'current') return theme.colors.primary.background;
|
|
51
|
+
return 'transparent';
|
|
52
|
+
}, ";border:", _ref4 => {
|
|
53
|
+
let {
|
|
54
|
+
temporal,
|
|
55
|
+
theme
|
|
56
|
+
} = _ref4;
|
|
57
|
+
return temporal === 'next' ? `1px solid ${theme.colors.neutral.borderWeak}` : null;
|
|
58
|
+
}, ";");
|
|
59
|
+
const StyledText = /*#__PURE__*/_styled(Text, {
|
|
60
|
+
target: "e19ft7rb3"
|
|
61
|
+
})("margin-top:", _ref5 => {
|
|
62
|
+
let {
|
|
63
|
+
theme
|
|
64
|
+
} = _ref5;
|
|
65
|
+
return theme.space['1'];
|
|
66
|
+
}, ";");
|
|
67
|
+
const StyledIcon = /*#__PURE__*/_styled(Icon, {
|
|
68
|
+
target: "e19ft7rb2"
|
|
69
|
+
})("fill:", _ref6 => {
|
|
70
|
+
let {
|
|
71
|
+
theme
|
|
72
|
+
} = _ref6;
|
|
73
|
+
return theme.colors.success.text;
|
|
74
|
+
}, ";");
|
|
75
|
+
const loadingStyle = /*#__PURE__*/css("animation:", loadingAnimation, " 1s linear infinite;");
|
|
76
|
+
const StyledLine = /*#__PURE__*/_styled("div", {
|
|
77
|
+
target: "e19ft7rb1"
|
|
78
|
+
})("border-radius:", _ref7 => {
|
|
79
|
+
let {
|
|
80
|
+
theme
|
|
81
|
+
} = _ref7;
|
|
82
|
+
return theme.radii.default;
|
|
83
|
+
}, ";flex-grow:1;border-radius:", _ref8 => {
|
|
84
|
+
let {
|
|
85
|
+
theme
|
|
86
|
+
} = _ref8;
|
|
87
|
+
return theme.radii.default;
|
|
88
|
+
}, ";background-color:", _ref9 => {
|
|
89
|
+
let {
|
|
90
|
+
theme
|
|
91
|
+
} = _ref9;
|
|
92
|
+
return theme.colors.neutral.borderWeak;
|
|
93
|
+
}, ";position:relative;::after{content:'';position:absolute;left:0;top:0;height:100%;border-radius:", _ref10 => {
|
|
94
|
+
let {
|
|
95
|
+
theme
|
|
96
|
+
} = _ref10;
|
|
97
|
+
return theme.radii.default;
|
|
98
|
+
}, ";background-color:", _ref11 => {
|
|
99
|
+
let {
|
|
100
|
+
theme
|
|
101
|
+
} = _ref11;
|
|
102
|
+
return theme.colors.success.backgroundStrong;
|
|
103
|
+
}, ";", _ref12 => {
|
|
104
|
+
let {
|
|
105
|
+
temporal
|
|
106
|
+
} = _ref12;
|
|
107
|
+
return temporal === 'previous' && `width: 100%;`;
|
|
108
|
+
}, " ", _ref13 => {
|
|
109
|
+
let {
|
|
110
|
+
temporal,
|
|
111
|
+
animated
|
|
112
|
+
} = _ref13;
|
|
113
|
+
return temporal === 'current' && animated && loadingStyle;
|
|
114
|
+
}, ";}");
|
|
115
|
+
const StyledContainer = /*#__PURE__*/_styled("div", {
|
|
116
|
+
target: "e19ft7rb0"
|
|
117
|
+
})("display:flex;flex-direction:row;justify-content:center;align-items:flex-start;gap:0 ", _ref14 => {
|
|
118
|
+
let {
|
|
119
|
+
theme
|
|
120
|
+
} = _ref14;
|
|
121
|
+
return theme.space['1'];
|
|
122
|
+
}, ";", StyledStep, "{height:", _ref15 => {
|
|
123
|
+
let {
|
|
124
|
+
theme
|
|
125
|
+
} = _ref15;
|
|
126
|
+
return theme.space['4'];
|
|
127
|
+
}, ";width:", _ref16 => {
|
|
128
|
+
let {
|
|
129
|
+
theme
|
|
130
|
+
} = _ref16;
|
|
131
|
+
return theme.space['4'];
|
|
132
|
+
}, ";}", StyledStepContainer, "{width:", _ref17 => {
|
|
133
|
+
let {
|
|
134
|
+
theme
|
|
135
|
+
} = _ref17;
|
|
136
|
+
return theme.space['4'];
|
|
137
|
+
}, ";white-space:nowrap;}", StyledLine, "{height:", _ref18 => {
|
|
138
|
+
let {
|
|
139
|
+
theme
|
|
140
|
+
} = _ref18;
|
|
141
|
+
return theme.space['0.5'];
|
|
142
|
+
}, ";margin-top:", _ref19 => {
|
|
143
|
+
let {
|
|
144
|
+
theme
|
|
145
|
+
} = _ref19;
|
|
146
|
+
return theme.space['2'];
|
|
147
|
+
}, ";margin-bottom:", _ref20 => {
|
|
148
|
+
let {
|
|
149
|
+
theme
|
|
150
|
+
} = _ref20;
|
|
151
|
+
return theme.space['2'];
|
|
152
|
+
}, ";}");
|
|
153
|
+
const StepperNumbers = _ref21 => {
|
|
154
|
+
let {
|
|
155
|
+
temporal,
|
|
156
|
+
children,
|
|
157
|
+
CurrentStep
|
|
158
|
+
} = _ref21;
|
|
159
|
+
return jsxs(StyledStepContainer, {
|
|
160
|
+
children: [jsx(StyledStep, {
|
|
161
|
+
temporal: temporal,
|
|
162
|
+
children: temporal !== 'previous' ? jsx(Text, {
|
|
163
|
+
as: "span",
|
|
164
|
+
variant: "bodySmall",
|
|
165
|
+
color: "neutral",
|
|
166
|
+
prominence: temporal === 'next' ? 'weak' : 'default',
|
|
167
|
+
children: CurrentStep
|
|
168
|
+
}) : jsx(StyledIcon, {
|
|
169
|
+
name: "check",
|
|
170
|
+
size: 20
|
|
171
|
+
})
|
|
172
|
+
}), jsx(StyledText, {
|
|
173
|
+
as: "span",
|
|
174
|
+
variant: "bodySmall",
|
|
175
|
+
prominence: temporal === 'next' ? 'weak' : 'default',
|
|
176
|
+
children: children
|
|
177
|
+
})]
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
const Stepper = _ref22 => {
|
|
181
|
+
let {
|
|
182
|
+
children,
|
|
183
|
+
selected = 0,
|
|
184
|
+
animated = false,
|
|
185
|
+
className,
|
|
186
|
+
'data-testid': dataTestId
|
|
187
|
+
} = _ref22;
|
|
188
|
+
const lastStep = Children.count(children) - 1;
|
|
189
|
+
return jsx(StyledContainer, {
|
|
190
|
+
className: className,
|
|
191
|
+
"data-testid": dataTestId,
|
|
192
|
+
children: flattenChildren(children).map((child, index) => {
|
|
193
|
+
const getTemporal = () => {
|
|
194
|
+
if (selected > index) return 'previous';
|
|
195
|
+
if (selected === index) return 'current';
|
|
196
|
+
return 'next';
|
|
197
|
+
};
|
|
198
|
+
const isNotLast = index < lastStep;
|
|
199
|
+
const temporal = getTemporal();
|
|
200
|
+
return (
|
|
201
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
202
|
+
jsxs(Fragment, {
|
|
203
|
+
children: [jsx(StepperNumbers, {
|
|
204
|
+
CurrentStep: index + 1,
|
|
205
|
+
temporal: temporal,
|
|
206
|
+
children: child
|
|
207
|
+
}), isNotLast ? jsx(StyledLine, {
|
|
208
|
+
temporal: temporal,
|
|
209
|
+
animated: animated
|
|
210
|
+
}) : null]
|
|
211
|
+
}, `creation-progress-${index}`)
|
|
212
|
+
);
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export { Stepper };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
const FOCUS_OVERLAY_SCALE_RATIO = 6;
|
|
6
|
+
const FOCUS_OVERLAY_PIXEL_RIGHT_OFFSET = 8;
|
|
7
|
+
const StyledDiv = /*#__PURE__*/_styled("div", {
|
|
8
|
+
target: "etutiin0"
|
|
9
|
+
})("position:absolute;height:calc(100% - ", _ref => {
|
|
10
|
+
let {
|
|
11
|
+
theme
|
|
12
|
+
} = _ref;
|
|
13
|
+
return theme.space['1'];
|
|
14
|
+
}, ");border-radius:", _ref2 => {
|
|
15
|
+
let {
|
|
16
|
+
theme
|
|
17
|
+
} = _ref2;
|
|
18
|
+
return theme.radii.default;
|
|
19
|
+
}, ";background:", _ref3 => {
|
|
20
|
+
let {
|
|
21
|
+
theme
|
|
22
|
+
} = _ref3;
|
|
23
|
+
return theme.colors.primary.backgroundStrong;
|
|
24
|
+
}, ";transform-origin:left center;transition:all 200ms ease-in-out;&[data-focusposition='right']{transform-origin:right center;}");
|
|
25
|
+
const FocusOverlay = _ref4 => {
|
|
26
|
+
let {
|
|
27
|
+
focusPosition,
|
|
28
|
+
rightCardWidth,
|
|
29
|
+
leftCardWidth,
|
|
30
|
+
hasMouseDown
|
|
31
|
+
} = _ref4;
|
|
32
|
+
const translateXValue = useMemo(() => focusPosition === 'left' ? 0 : leftCardWidth + FOCUS_OVERLAY_PIXEL_RIGHT_OFFSET, [focusPosition, leftCardWidth]);
|
|
33
|
+
const getScaleXValue = () => {
|
|
34
|
+
if (!hasMouseDown || !leftCardWidth || !rightCardWidth) return 1;
|
|
35
|
+
const currentWidth = focusPosition === 'left' ? leftCardWidth : rightCardWidth;
|
|
36
|
+
return 1 + FOCUS_OVERLAY_SCALE_RATIO / currentWidth;
|
|
37
|
+
};
|
|
38
|
+
return jsx(StyledDiv, {
|
|
39
|
+
"data-focusposition": focusPosition,
|
|
40
|
+
style: {
|
|
41
|
+
transform: `translate3d(${translateXValue}px, 0, 0) scale3d(${getScaleXValue()}, 1, 1)`,
|
|
42
|
+
width: `${focusPosition === 'left' ? leftCardWidth : rightCardWidth}px`
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { FocusOverlay };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { SelectableCard } from '../SelectableCard/index.js';
|
|
4
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
5
|
+
import { FocusOverlay } from './FocusOverlay.js';
|
|
6
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const StyledBorderedBox = /*#__PURE__*/_styled("div", {
|
|
9
|
+
target: "e4ryteh1"
|
|
10
|
+
})("border:1px solid ", _ref => {
|
|
11
|
+
let {
|
|
12
|
+
theme
|
|
13
|
+
} = _ref;
|
|
14
|
+
return theme.colors.neutral.border;
|
|
15
|
+
}, ";border-radius:", _ref2 => {
|
|
16
|
+
let {
|
|
17
|
+
theme
|
|
18
|
+
} = _ref2;
|
|
19
|
+
return theme.radii.default;
|
|
20
|
+
}, ";padding:", _ref3 => {
|
|
21
|
+
let {
|
|
22
|
+
theme
|
|
23
|
+
} = _ref3;
|
|
24
|
+
return theme.space['0.5'];
|
|
25
|
+
}, ";display:flex;gap:", _ref4 => {
|
|
26
|
+
let {
|
|
27
|
+
theme
|
|
28
|
+
} = _ref4;
|
|
29
|
+
return theme.space['1'];
|
|
30
|
+
}, ";position:relative;");
|
|
31
|
+
const StyledSelectableCard = /*#__PURE__*/_styled(SelectableCard, {
|
|
32
|
+
target: "e4ryteh0"
|
|
33
|
+
})("border:none;height:40px;padding:", _ref5 => {
|
|
34
|
+
let {
|
|
35
|
+
theme
|
|
36
|
+
} = _ref5;
|
|
37
|
+
return theme.space['1'];
|
|
38
|
+
}, " ", _ref6 => {
|
|
39
|
+
let {
|
|
40
|
+
theme
|
|
41
|
+
} = _ref6;
|
|
42
|
+
return theme.space['2'];
|
|
43
|
+
}, ";font-weight:", _ref7 => {
|
|
44
|
+
let {
|
|
45
|
+
theme
|
|
46
|
+
} = _ref7;
|
|
47
|
+
return theme.typography.bodyStrong.weight;
|
|
48
|
+
}, ";justify-content:center;align-items:center;transition:all 200ms ease-in-out;&:hover,&:focus-within,&:active{box-shadow:none;border:none;&:not([data-error='true'][data-disabled='true']){border:none;}}&[data-checked='true']{border:none;}&[data-checked='true'] label{color:", _ref8 => {
|
|
49
|
+
let {
|
|
50
|
+
theme
|
|
51
|
+
} = _ref8;
|
|
52
|
+
return theme.colors.primary.textStrong;
|
|
53
|
+
}, ";}&:not([data-checked='true']) label{&:hover{color:", _ref9 => {
|
|
54
|
+
let {
|
|
55
|
+
theme
|
|
56
|
+
} = _ref9;
|
|
57
|
+
return theme.colors.primary.textWeak;
|
|
58
|
+
}, ";}}");
|
|
59
|
+
const SwitchButton = _ref10 => {
|
|
60
|
+
let {
|
|
61
|
+
value,
|
|
62
|
+
onChange,
|
|
63
|
+
onFocus,
|
|
64
|
+
onBlur,
|
|
65
|
+
name,
|
|
66
|
+
leftButton,
|
|
67
|
+
rightButton,
|
|
68
|
+
tooltip,
|
|
69
|
+
className,
|
|
70
|
+
'data-testid': dataTestId
|
|
71
|
+
} = _ref10;
|
|
72
|
+
const leftButtonRef = useRef(null);
|
|
73
|
+
const rightButtonRef = useRef(null);
|
|
74
|
+
const [leftCardWidth, setLeftCardWidth] = useState();
|
|
75
|
+
const [rightCardWidth, setRightCardWidth] = useState();
|
|
76
|
+
const [hasMouseDown, setHasMouseDown] = useState(false);
|
|
77
|
+
const [localValue, setLocalValue] = useState(value === leftButton.value ? leftButton.value : rightButton.value);
|
|
78
|
+
const handleOnChange = event => {
|
|
79
|
+
onChange?.(event);
|
|
80
|
+
setLocalValue(event.target.value);
|
|
81
|
+
};
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!leftButtonRef.current || !rightButtonRef.current) return;
|
|
84
|
+
setLeftCardWidth(leftButtonRef.current.getBoundingClientRect().width);
|
|
85
|
+
setRightCardWidth(rightButtonRef.current.getBoundingClientRect().width);
|
|
86
|
+
}, [leftButton.value, leftButtonRef, localValue, rightButtonRef]);
|
|
87
|
+
const setMouseDown = isMouseDown => () => setHasMouseDown(isMouseDown);
|
|
88
|
+
return jsx(Tooltip, {
|
|
89
|
+
text: tooltip,
|
|
90
|
+
children: jsx("div", {
|
|
91
|
+
style: {
|
|
92
|
+
display: 'inline-flex'
|
|
93
|
+
},
|
|
94
|
+
className: className,
|
|
95
|
+
"data-testid": dataTestId,
|
|
96
|
+
children: jsxs(StyledBorderedBox, {
|
|
97
|
+
onMouseDown: setMouseDown(true),
|
|
98
|
+
onMouseUp: setMouseDown(false),
|
|
99
|
+
onMouseLeave: setMouseDown(false),
|
|
100
|
+
children: [rightCardWidth && leftCardWidth ? jsx(FocusOverlay, {
|
|
101
|
+
focusPosition: localValue === leftButton.value ? 'left' : 'right',
|
|
102
|
+
rightCardWidth: rightCardWidth,
|
|
103
|
+
leftCardWidth: leftCardWidth,
|
|
104
|
+
hasMouseDown: hasMouseDown
|
|
105
|
+
}) : null, jsx(StyledSelectableCard, {
|
|
106
|
+
ref: leftButtonRef,
|
|
107
|
+
name: name,
|
|
108
|
+
value: leftButton.value,
|
|
109
|
+
checked: localValue === leftButton.value,
|
|
110
|
+
onChange: handleOnChange,
|
|
111
|
+
onBlur: onBlur,
|
|
112
|
+
onFocus: onFocus,
|
|
113
|
+
"data-checked": localValue === leftButton.value,
|
|
114
|
+
label: leftButton.label
|
|
115
|
+
}), jsx(StyledSelectableCard, {
|
|
116
|
+
ref: rightButtonRef,
|
|
117
|
+
name: name,
|
|
118
|
+
value: rightButton.value,
|
|
119
|
+
checked: localValue === rightButton.value,
|
|
120
|
+
onChange: handleOnChange,
|
|
121
|
+
onBlur: onBlur,
|
|
122
|
+
onFocus: onFocus,
|
|
123
|
+
"data-checked": localValue === rightButton.value,
|
|
124
|
+
label: rightButton.label
|
|
125
|
+
})]
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { SwitchButton };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
const StyledCell = /*#__PURE__*/_styled('td', {
|
|
5
|
+
target: "e78o8ww0"
|
|
6
|
+
})("padding:", _ref => {
|
|
7
|
+
let {
|
|
8
|
+
theme
|
|
9
|
+
} = _ref;
|
|
10
|
+
return theme.space['1'];
|
|
11
|
+
}, ";font-size:14px;");
|
|
12
|
+
const Cell = _ref2 => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
colSpan,
|
|
17
|
+
rowSpan
|
|
18
|
+
} = _ref2;
|
|
19
|
+
return jsx(StyledCell, {
|
|
20
|
+
className: className,
|
|
21
|
+
colSpan: colSpan,
|
|
22
|
+
rowSpan: rowSpan,
|
|
23
|
+
children: children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { Cell };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
const StyledHeader = /*#__PURE__*/_styled('thead', {
|
|
5
|
+
target: "ekxedod0"
|
|
6
|
+
})("border-bottom:1px solid ", _ref => {
|
|
7
|
+
let {
|
|
8
|
+
theme
|
|
9
|
+
} = _ref;
|
|
10
|
+
return theme.colors.neutral.borderStrong;
|
|
11
|
+
}, ";");
|
|
12
|
+
const Header = _ref2 => {
|
|
13
|
+
let {
|
|
14
|
+
children
|
|
15
|
+
} = _ref2;
|
|
16
|
+
return jsx(StyledHeader, {
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Header };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { Icon } from '../Icon/index.js';
|
|
3
|
+
import { Stack } from '../Stack/index.js';
|
|
4
|
+
import { Text } from '../Text/index.js';
|
|
5
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
6
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const StyledIconContainer = /*#__PURE__*/_styled(Stack, {
|
|
9
|
+
target: "ev6jkq82"
|
|
10
|
+
})("color:", _ref => {
|
|
11
|
+
let {
|
|
12
|
+
theme
|
|
13
|
+
} = _ref;
|
|
14
|
+
return theme.colors.neutral.textWeak;
|
|
15
|
+
}, ";&[aria-disabled='true']{cursor:not-allowed;}&[role*='button']{cursor:pointer;user-select:none;}");
|
|
16
|
+
const SortIcon = _ref2 => {
|
|
17
|
+
let {
|
|
18
|
+
order
|
|
19
|
+
} = _ref2;
|
|
20
|
+
return jsxs(StyledIconContainer, {
|
|
21
|
+
children: [jsx(Icon, {
|
|
22
|
+
name: "arrow-up",
|
|
23
|
+
size: 10,
|
|
24
|
+
color: order === 'ascending' ? 'primary' : 'neutral',
|
|
25
|
+
prominence: "weak"
|
|
26
|
+
}), jsx(Icon, {
|
|
27
|
+
name: "arrow-down",
|
|
28
|
+
size: 10,
|
|
29
|
+
color: order === 'descending' ? 'primary' : 'neutral',
|
|
30
|
+
prominence: "weak"
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const StyledHeaderCell = /*#__PURE__*/_styled('th', {
|
|
35
|
+
shouldForwardProp: prop => !['width', 'maxWidth', 'minWidth'].includes(prop),
|
|
36
|
+
target: "ev6jkq81"
|
|
37
|
+
})(_ref3 => {
|
|
38
|
+
let {
|
|
39
|
+
width,
|
|
40
|
+
maxWidth,
|
|
41
|
+
minWidth
|
|
42
|
+
} = _ref3;
|
|
43
|
+
return `
|
|
44
|
+
${width ? `width: ${width};` : ''}
|
|
45
|
+
${maxWidth ? `max-width: ${maxWidth};` : ''}
|
|
46
|
+
${minWidth ? `min-width: ${minWidth};` : ''}
|
|
47
|
+
`;
|
|
48
|
+
}, " padding:", _ref4 => {
|
|
49
|
+
let {
|
|
50
|
+
theme
|
|
51
|
+
} = _ref4;
|
|
52
|
+
return theme.space['1'];
|
|
53
|
+
}, ";&[role*='button']{cursor:pointer;user-select:none;}");
|
|
54
|
+
const StyledText = /*#__PURE__*/_styled(Text, {
|
|
55
|
+
target: "ev6jkq80"
|
|
56
|
+
})("display:flex;flex-direction:row;align-items:center;gap:", _ref5 => {
|
|
57
|
+
let {
|
|
58
|
+
theme
|
|
59
|
+
} = _ref5;
|
|
60
|
+
return theme.space['1'];
|
|
61
|
+
}, ";");
|
|
62
|
+
const HeaderCell = _ref6 => {
|
|
63
|
+
let {
|
|
64
|
+
children,
|
|
65
|
+
className,
|
|
66
|
+
isOrdered,
|
|
67
|
+
onOrder,
|
|
68
|
+
orderDirection,
|
|
69
|
+
width,
|
|
70
|
+
maxWidth,
|
|
71
|
+
minWidth,
|
|
72
|
+
info
|
|
73
|
+
} = _ref6;
|
|
74
|
+
let order;
|
|
75
|
+
if (isOrdered && orderDirection === 'asc') {
|
|
76
|
+
order = 'ascending';
|
|
77
|
+
} else if (isOrdered && orderDirection === 'desc') {
|
|
78
|
+
order = 'descending';
|
|
79
|
+
}
|
|
80
|
+
const handleOrder = onOrder ? () => onOrder(order === 'ascending' ? 'desc' : 'asc') : undefined;
|
|
81
|
+
return jsx(StyledHeaderCell, {
|
|
82
|
+
className: className,
|
|
83
|
+
onClick: handleOrder,
|
|
84
|
+
onKeyDown: handleOrder ? event => {
|
|
85
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
86
|
+
handleOrder();
|
|
87
|
+
if (event.key === ' ') {
|
|
88
|
+
// @note: it avoid scroll when pressing Space
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} : undefined,
|
|
93
|
+
role: onOrder ? 'button columnheader' : undefined,
|
|
94
|
+
width: width,
|
|
95
|
+
maxWidth: maxWidth,
|
|
96
|
+
minWidth: minWidth,
|
|
97
|
+
tabIndex: handleOrder ? 0 : -1,
|
|
98
|
+
"aria-sort": order,
|
|
99
|
+
children: jsxs(StyledText, {
|
|
100
|
+
as: "div",
|
|
101
|
+
variant: "bodySmall",
|
|
102
|
+
color: order !== undefined ? 'primary' : 'neutral',
|
|
103
|
+
children: [children, info ? jsx(Tooltip, {
|
|
104
|
+
text: info,
|
|
105
|
+
children: jsx(Icon, {
|
|
106
|
+
name: "information-outline",
|
|
107
|
+
size: 20,
|
|
108
|
+
prominence: "weak",
|
|
109
|
+
color: "neutral"
|
|
110
|
+
})
|
|
111
|
+
}) : null, orderDirection !== undefined && isOrdered !== undefined ? jsx(SortIcon, {
|
|
112
|
+
"aria-disabled": !onOrder,
|
|
113
|
+
order: order
|
|
114
|
+
}) : null]
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { HeaderCell };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Checkbox } from '../Checkbox/index.js';
|
|
2
|
+
import { HeaderCell } from './HeaderCell.js';
|
|
3
|
+
import { useTableContext } from './TableContext.js';
|
|
4
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const SELECT_CHECKBOX_SIZE = 24;
|
|
7
|
+
const HeaderRow = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
hasSelectAllColumn
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
allRowSelectValue,
|
|
14
|
+
selectAll,
|
|
15
|
+
unselectAll,
|
|
16
|
+
selectedRowIds
|
|
17
|
+
} = useTableContext();
|
|
18
|
+
const selectableRowCount = Object.keys(selectedRowIds).length;
|
|
19
|
+
return jsxs("tr", {
|
|
20
|
+
children: [hasSelectAllColumn ? jsx(HeaderCell, {
|
|
21
|
+
width: `${SELECT_CHECKBOX_SIZE}px`,
|
|
22
|
+
children: jsx(Checkbox, {
|
|
23
|
+
name: "table-select-all-checkbox",
|
|
24
|
+
value: "all",
|
|
25
|
+
"aria-label": "select all",
|
|
26
|
+
checked: allRowSelectValue,
|
|
27
|
+
onChange: allRowSelectValue === false ? selectAll : unselectAll,
|
|
28
|
+
disabled: selectableRowCount === 0,
|
|
29
|
+
size: SELECT_CHECKBOX_SIZE
|
|
30
|
+
})
|
|
31
|
+
}) : null, children]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { HeaderRow, SELECT_CHECKBOX_SIZE };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { Checkbox } from '../Checkbox/index.js';
|
|
4
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
5
|
+
import { Cell } from './Cell.js';
|
|
6
|
+
import { SELECT_CHECKBOX_SIZE } from './HeaderRow.js';
|
|
7
|
+
import { useTableContext } from './TableContext.js';
|
|
8
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
const StyledCheckboxContainer = /*#__PURE__*/_styled("div", {
|
|
11
|
+
target: "e1qvrbgq0"
|
|
12
|
+
})("display:flex;background:", _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme
|
|
15
|
+
} = _ref;
|
|
16
|
+
return theme.colors.neutral.background;
|
|
17
|
+
}, ";");
|
|
18
|
+
const Row = _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
children,
|
|
21
|
+
className,
|
|
22
|
+
id,
|
|
23
|
+
selectDisabled,
|
|
24
|
+
'data-testid': dataTestid
|
|
25
|
+
} = _ref2;
|
|
26
|
+
const {
|
|
27
|
+
allRowSelectValue,
|
|
28
|
+
selectable,
|
|
29
|
+
registerSelectableRow,
|
|
30
|
+
selectedRowIds,
|
|
31
|
+
selectRow,
|
|
32
|
+
unselectRow
|
|
33
|
+
} = useTableContext();
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!selectDisabled) {
|
|
36
|
+
const unregisterCallback = registerSelectableRow(id);
|
|
37
|
+
return unregisterCallback;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}, [id, registerSelectableRow, selectDisabled]);
|
|
41
|
+
return jsxs("tr", {
|
|
42
|
+
className: className,
|
|
43
|
+
"data-testid": dataTestid,
|
|
44
|
+
children: [selectable ? jsx(Cell, {
|
|
45
|
+
children: jsx(StyledCheckboxContainer, {
|
|
46
|
+
"data-visibility": allRowSelectValue === false ? 'hover' : undefined,
|
|
47
|
+
children: jsx(Tooltip, {
|
|
48
|
+
text: typeof selectDisabled === 'string' ? selectDisabled : undefined,
|
|
49
|
+
children: jsx(Checkbox, {
|
|
50
|
+
name: "table-select-checkbox",
|
|
51
|
+
"aria-label": "select",
|
|
52
|
+
checked: selectedRowIds[id],
|
|
53
|
+
value: id,
|
|
54
|
+
onChange: () => {
|
|
55
|
+
if (selectedRowIds[id]) {
|
|
56
|
+
unselectRow(id);
|
|
57
|
+
} else {
|
|
58
|
+
selectRow(id);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
disabled: selectDisabled !== undefined,
|
|
62
|
+
size: SELECT_CHECKBOX_SIZE
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}) : null, children]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { Row };
|