@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,183 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { keyframes, css } from '@emotion/react';
|
|
3
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
4
|
+
import TooltipContainer from './Tooltip.js';
|
|
5
|
+
import patternVariants from './patterns.js';
|
|
6
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
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)."; }
|
|
9
|
+
const bulletFlashAnim = keyframes`
|
|
10
|
+
0% {
|
|
11
|
+
opacity: 1;
|
|
12
|
+
}
|
|
13
|
+
50% {
|
|
14
|
+
opacity: 0.1;
|
|
15
|
+
}
|
|
16
|
+
100% {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const animationFlash = isFocused => isFocused ? /*#__PURE__*/css(bulletFlashAnim.styles, " animation:", bulletFlashAnim.name, " linear 1500ms infinite;") : '';
|
|
21
|
+
const List = /*#__PURE__*/_styled("ul", {
|
|
22
|
+
target: "e12qyakg8"
|
|
23
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
24
|
+
name: "1yalzuy",
|
|
25
|
+
styles: "font-size:14px;list-style-type:none;display:flex;flex:1;flex-direction:column;max-height:100%;overflow-y:auto"
|
|
26
|
+
} : {
|
|
27
|
+
name: "1yalzuy",
|
|
28
|
+
styles: "font-size:14px;list-style-type:none;display:flex;flex:1;flex-direction:column;max-height:100%;overflow-y:auto",
|
|
29
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
30
|
+
});
|
|
31
|
+
const ListItem = /*#__PURE__*/_styled("li", {
|
|
32
|
+
target: "e12qyakg7"
|
|
33
|
+
})("display:flex;align-items:center;margin-top:", _ref => {
|
|
34
|
+
let {
|
|
35
|
+
theme
|
|
36
|
+
} = _ref;
|
|
37
|
+
return theme.space['1'];
|
|
38
|
+
}, ";width:100%;color:", _ref2 => {
|
|
39
|
+
let {
|
|
40
|
+
isFocused,
|
|
41
|
+
theme
|
|
42
|
+
} = _ref2;
|
|
43
|
+
return isFocused ? theme.colors.primary.textWeak : theme.colors.neutral.text;
|
|
44
|
+
}, ";");
|
|
45
|
+
const Bullet = /*#__PURE__*/_styled("div", {
|
|
46
|
+
target: "e12qyakg6"
|
|
47
|
+
})("display:inline-block;border-radius:", _ref3 => {
|
|
48
|
+
let {
|
|
49
|
+
theme
|
|
50
|
+
} = _ref3;
|
|
51
|
+
return theme.radii.circle;
|
|
52
|
+
}, ";width:10px;height:10px;margin:0 ", _ref4 => {
|
|
53
|
+
let {
|
|
54
|
+
theme
|
|
55
|
+
} = _ref4;
|
|
56
|
+
return theme.space['1'];
|
|
57
|
+
}, ";background:", _ref5 => {
|
|
58
|
+
let {
|
|
59
|
+
color
|
|
60
|
+
} = _ref5;
|
|
61
|
+
return color;
|
|
62
|
+
}, ";", _ref6 => {
|
|
63
|
+
let {
|
|
64
|
+
needPattern,
|
|
65
|
+
color,
|
|
66
|
+
id
|
|
67
|
+
} = _ref6;
|
|
68
|
+
if (!needPattern) return null;
|
|
69
|
+
return patternVariants?.[`${id}-dot`]?.(color);
|
|
70
|
+
}, " ", _ref7 => {
|
|
71
|
+
let {
|
|
72
|
+
isFocused
|
|
73
|
+
} = _ref7;
|
|
74
|
+
return animationFlash(isFocused);
|
|
75
|
+
}, ";");
|
|
76
|
+
const Label = /*#__PURE__*/_styled("div", {
|
|
77
|
+
target: "e12qyakg5"
|
|
78
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
79
|
+
name: "lvt6sf",
|
|
80
|
+
styles: "display:flex;flex:1;align-items:baseline"
|
|
81
|
+
} : {
|
|
82
|
+
name: "lvt6sf",
|
|
83
|
+
styles: "display:flex;flex:1;align-items:baseline",
|
|
84
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
85
|
+
});
|
|
86
|
+
const Value = /*#__PURE__*/_styled("div", {
|
|
87
|
+
target: "e12qyakg4"
|
|
88
|
+
})("margin-left:6px;font-weight:", _ref8 => {
|
|
89
|
+
let {
|
|
90
|
+
isFocused
|
|
91
|
+
} = _ref8;
|
|
92
|
+
return isFocused ? 500 : 400;
|
|
93
|
+
}, ";");
|
|
94
|
+
const Text = /*#__PURE__*/_styled("span", {
|
|
95
|
+
target: "e12qyakg3"
|
|
96
|
+
})("flex:none;margin-right:6px;font-weight:", _ref9 => {
|
|
97
|
+
let {
|
|
98
|
+
isFocused
|
|
99
|
+
} = _ref9;
|
|
100
|
+
return isFocused ? 500 : 400;
|
|
101
|
+
}, ";");
|
|
102
|
+
const ToggleBox = /*#__PURE__*/_styled("div", {
|
|
103
|
+
target: "e12qyakg2"
|
|
104
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
105
|
+
name: "ki8u62",
|
|
106
|
+
styles: "width:250px;height:21px;position:absolute"
|
|
107
|
+
} : {
|
|
108
|
+
name: "ki8u62",
|
|
109
|
+
styles: "width:250px;height:21px;position:absolute",
|
|
110
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
111
|
+
});
|
|
112
|
+
const Line = /*#__PURE__*/_styled("span", {
|
|
113
|
+
target: "e12qyakg1"
|
|
114
|
+
})("border-bottom:1px solid ", _ref10 => {
|
|
115
|
+
let {
|
|
116
|
+
theme
|
|
117
|
+
} = _ref10;
|
|
118
|
+
return theme.colors.neutral.border;
|
|
119
|
+
}, ";position:relative;width:100%;");
|
|
120
|
+
const ProgressiveLine = /*#__PURE__*/_styled("span", {
|
|
121
|
+
target: "e12qyakg0"
|
|
122
|
+
})("border-bottom:1px solid ", _ref11 => {
|
|
123
|
+
let {
|
|
124
|
+
theme
|
|
125
|
+
} = _ref11;
|
|
126
|
+
return theme.colors.primary.borderWeak;
|
|
127
|
+
}, ";position:absolute;left:0;top:0;bottom:-1px;transition:width 500ms ease;width:", _ref12 => {
|
|
128
|
+
let {
|
|
129
|
+
isFocused
|
|
130
|
+
} = _ref12;
|
|
131
|
+
return isFocused ? 100 : 0;
|
|
132
|
+
}, "%;");
|
|
133
|
+
const Legends = _ref13 => {
|
|
134
|
+
let {
|
|
135
|
+
focused,
|
|
136
|
+
data,
|
|
137
|
+
onFocusChange,
|
|
138
|
+
colors
|
|
139
|
+
} = _ref13;
|
|
140
|
+
return jsx(List, {
|
|
141
|
+
children: data?.map((item, index) => {
|
|
142
|
+
const isSegmentFocused = focused !== undefined && item.id === focused;
|
|
143
|
+
const id = `chart-legend-${item.id}`;
|
|
144
|
+
return jsx(Tooltip, {
|
|
145
|
+
visible: isSegmentFocused,
|
|
146
|
+
id: id,
|
|
147
|
+
text: jsx(TooltipContainer, {
|
|
148
|
+
data: item
|
|
149
|
+
}),
|
|
150
|
+
children: jsxs(ListItem, {
|
|
151
|
+
isFocused: isSegmentFocused,
|
|
152
|
+
children: [jsx(ToggleBox, {
|
|
153
|
+
"data-testid": id,
|
|
154
|
+
onMouseOver: () => onFocusChange(item.id),
|
|
155
|
+
onFocus: () => onFocusChange(item.id),
|
|
156
|
+
onMouseOut: () => onFocusChange(),
|
|
157
|
+
onBlur: () => onFocusChange()
|
|
158
|
+
}), jsx(Bullet, {
|
|
159
|
+
color: colors[index],
|
|
160
|
+
isFocused: isSegmentFocused,
|
|
161
|
+
needPattern: item.needPattern,
|
|
162
|
+
id: `chart-legend-${item.id}`
|
|
163
|
+
}), jsxs(Label, {
|
|
164
|
+
children: [jsx(Text, {
|
|
165
|
+
isFocused: isSegmentFocused,
|
|
166
|
+
children: item.name
|
|
167
|
+
}), jsx(Line, {
|
|
168
|
+
children: jsx(ProgressiveLine, {
|
|
169
|
+
isFocused: isSegmentFocused
|
|
170
|
+
})
|
|
171
|
+
})]
|
|
172
|
+
}), jsx(Value, {
|
|
173
|
+
isFocused: isSegmentFocused,
|
|
174
|
+
children: item.value
|
|
175
|
+
})]
|
|
176
|
+
})
|
|
177
|
+
}, item.id);
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
var Legends$1 = Legends;
|
|
182
|
+
|
|
183
|
+
export { Legends$1 as default };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { Text } from '../Text/index.js';
|
|
3
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
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)."; }
|
|
6
|
+
const StyledList = /*#__PURE__*/_styled("ul", {
|
|
7
|
+
target: "e44jccr1"
|
|
8
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
9
|
+
name: "1vatjen",
|
|
10
|
+
styles: "padding:0 8px 8px 8px;margin:0;width:100%"
|
|
11
|
+
} : {
|
|
12
|
+
name: "1vatjen",
|
|
13
|
+
styles: "padding:0 8px 8px 8px;margin:0;width:100%",
|
|
14
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
15
|
+
});
|
|
16
|
+
const StyledItem = /*#__PURE__*/_styled("li", {
|
|
17
|
+
target: "e44jccr0"
|
|
18
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
19
|
+
name: "1duinrf",
|
|
20
|
+
styles: "display:flex;margin-top:6px;width:100%;justify-content:space-between;text-align:left;gap:8px"
|
|
21
|
+
} : {
|
|
22
|
+
name: "1duinrf",
|
|
23
|
+
styles: "display:flex;margin-top:6px;width:100%;justify-content:space-between;text-align:left;gap:8px",
|
|
24
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
25
|
+
});
|
|
26
|
+
const Tooltip = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
data
|
|
29
|
+
} = _ref;
|
|
30
|
+
return jsx("div", {
|
|
31
|
+
tabIndex: -1,
|
|
32
|
+
role: "tooltip",
|
|
33
|
+
children: jsxs(StyledList, {
|
|
34
|
+
children: [jsxs(StyledItem, {
|
|
35
|
+
children: [jsx(Text, {
|
|
36
|
+
as: "p",
|
|
37
|
+
variant: "body",
|
|
38
|
+
prominence: "stronger",
|
|
39
|
+
children: data.name
|
|
40
|
+
}), jsx(Text, {
|
|
41
|
+
as: "p",
|
|
42
|
+
variant: "body",
|
|
43
|
+
prominence: "stronger",
|
|
44
|
+
children: data.value
|
|
45
|
+
})]
|
|
46
|
+
}), data.details?.map(detail => jsxs(StyledItem, {
|
|
47
|
+
children: [jsx(Text, {
|
|
48
|
+
as: "p",
|
|
49
|
+
variant: "bodySmall",
|
|
50
|
+
prominence: "stronger",
|
|
51
|
+
children: detail.name
|
|
52
|
+
}), jsx(Text, {
|
|
53
|
+
as: "p",
|
|
54
|
+
variant: "bodySmall",
|
|
55
|
+
prominence: "stronger",
|
|
56
|
+
children: detail.value
|
|
57
|
+
})]
|
|
58
|
+
}, detail.name))]
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var TooltipContainer = Tooltip;
|
|
63
|
+
|
|
64
|
+
export { TooltipContainer as default };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { useTheme } from '@emotion/react';
|
|
3
|
+
import { Pie } from '@nivo/pie';
|
|
4
|
+
import { useState, useCallback } from 'react';
|
|
5
|
+
import { getLegendColor } from '../../helpers/legend.js';
|
|
6
|
+
import { Text } from '../Text/index.js';
|
|
7
|
+
import Legends from './Legends.js';
|
|
8
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
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)."; }
|
|
11
|
+
const Container = /*#__PURE__*/_styled("div", {
|
|
12
|
+
target: "epjfe5p2"
|
|
13
|
+
})("display:flex;align-items:center;height:", _ref => {
|
|
14
|
+
let {
|
|
15
|
+
height
|
|
16
|
+
} = _ref;
|
|
17
|
+
return `${height}px`;
|
|
18
|
+
}, ";");
|
|
19
|
+
const EmptyLegend = /*#__PURE__*/_styled("div", {
|
|
20
|
+
target: "epjfe5p1"
|
|
21
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
22
|
+
name: "dwqz7h",
|
|
23
|
+
styles: "display:flex;align-items:center;margin-left:20px"
|
|
24
|
+
} : {
|
|
25
|
+
name: "dwqz7h",
|
|
26
|
+
styles: "display:flex;align-items:center;margin-left:20px",
|
|
27
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
28
|
+
});
|
|
29
|
+
const StyledContent = /*#__PURE__*/_styled("div", {
|
|
30
|
+
target: "epjfe5p0"
|
|
31
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
32
|
+
name: "qcd8cv",
|
|
33
|
+
styles: "display:inline-block;position:absolute;bottom:0;left:0;right:0;top:0;font-size:25px;line-height:100px;height:100px;width:100px;margin:auto;text-align:center;vertical-align:middle"
|
|
34
|
+
} : {
|
|
35
|
+
name: "qcd8cv",
|
|
36
|
+
styles: "display:inline-block;position:absolute;bottom:0;left:0;right:0;top:0;font-size:25px;line-height:100px;height:100px;width:100px;margin:auto;text-align:center;vertical-align:middle",
|
|
37
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
38
|
+
});
|
|
39
|
+
const DEFAULT_CHARTPROPS = {};
|
|
40
|
+
const DEFAULT_MARGIN = {
|
|
41
|
+
bottom: 10,
|
|
42
|
+
left: 10,
|
|
43
|
+
right: 10,
|
|
44
|
+
top: 10
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @experimental This component is experimental and may be subject to breaking changes in the future.
|
|
49
|
+
*/
|
|
50
|
+
const PieChart = _ref2 => {
|
|
51
|
+
let {
|
|
52
|
+
height = 206,
|
|
53
|
+
width = 206,
|
|
54
|
+
data = undefined,
|
|
55
|
+
emptyLegend,
|
|
56
|
+
content,
|
|
57
|
+
withLegend = false,
|
|
58
|
+
margin = DEFAULT_MARGIN,
|
|
59
|
+
chartProps = DEFAULT_CHARTPROPS
|
|
60
|
+
} = _ref2;
|
|
61
|
+
const theme = useTheme();
|
|
62
|
+
const [currentFocusIndex, setCurrentFocusIndex] = useState();
|
|
63
|
+
const emptyTooltip = useCallback(() => jsx("span", {}), []);
|
|
64
|
+
const isEmpty = !data || data.length === 0;
|
|
65
|
+
const EmptyLegendDisplayed = useCallback(() => emptyLegend ? jsx(EmptyLegend, {
|
|
66
|
+
children: jsx(Text, {
|
|
67
|
+
variant: "body",
|
|
68
|
+
as: "p",
|
|
69
|
+
children: emptyLegend
|
|
70
|
+
})
|
|
71
|
+
}) : null, [emptyLegend]);
|
|
72
|
+
const localColors = getLegendColor(theme);
|
|
73
|
+
const LegendDisplayer = useCallback(() => isEmpty ? jsx(EmptyLegendDisplayed, {}) : jsx(Legends, {
|
|
74
|
+
focused: currentFocusIndex,
|
|
75
|
+
data: data,
|
|
76
|
+
onFocusChange: setCurrentFocusIndex,
|
|
77
|
+
colors: localColors
|
|
78
|
+
}), [isEmpty, currentFocusIndex, data, EmptyLegendDisplayed, localColors]);
|
|
79
|
+
return jsxs(Container, {
|
|
80
|
+
height: height,
|
|
81
|
+
children: [jsxs("div", {
|
|
82
|
+
style: {
|
|
83
|
+
position: 'relative'
|
|
84
|
+
},
|
|
85
|
+
children: [jsx(Pie, {
|
|
86
|
+
colors: localColors,
|
|
87
|
+
height: height,
|
|
88
|
+
width: width,
|
|
89
|
+
value: "percent",
|
|
90
|
+
enableArcLabels: false,
|
|
91
|
+
enableArcLinkLabels: false,
|
|
92
|
+
data: !isEmpty ? data : [{
|
|
93
|
+
id: 'empty',
|
|
94
|
+
percent: 100
|
|
95
|
+
}],
|
|
96
|
+
defs: [{
|
|
97
|
+
background: 'inherit',
|
|
98
|
+
color: theme.colors.neutral.textStrong,
|
|
99
|
+
id: 'lines',
|
|
100
|
+
lineWidth: 2,
|
|
101
|
+
rotation: 0,
|
|
102
|
+
spacing: 5,
|
|
103
|
+
type: 'patternLines'
|
|
104
|
+
}],
|
|
105
|
+
fill: [{
|
|
106
|
+
id: 'lines',
|
|
107
|
+
match: {
|
|
108
|
+
id: 'discount'
|
|
109
|
+
}
|
|
110
|
+
}],
|
|
111
|
+
margin: margin,
|
|
112
|
+
innerRadius: 0.8,
|
|
113
|
+
cornerRadius: 0,
|
|
114
|
+
padAngle: 1,
|
|
115
|
+
activeOuterRadiusOffset: !isEmpty ? 4 : 0,
|
|
116
|
+
tooltip: emptyTooltip,
|
|
117
|
+
onMouseEnter: (datum, event) => {
|
|
118
|
+
if (!isEmpty) {
|
|
119
|
+
const pie = event.currentTarget;
|
|
120
|
+
pie.style.cursor = 'pointer';
|
|
121
|
+
setCurrentFocusIndex(datum.id.toString());
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
onMouseLeave: () => setCurrentFocusIndex(undefined),
|
|
125
|
+
...chartProps
|
|
126
|
+
}), content ? jsx(StyledContent, {
|
|
127
|
+
children: content
|
|
128
|
+
}) : null]
|
|
129
|
+
}), withLegend ? jsx(LegendDisplayer, {}) : null]
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export { PieChart };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
|
|
3
|
+
const discountDot = color => /*#__PURE__*/css("opacity:0.6;border:0.3px solid ", color, ";background-size:10px;background:repeating-linear-gradient(\n 0deg,\n transparent,\n transparent 1px,\n ", color, " 1px,\n ", color, " 3px\n );");
|
|
4
|
+
const patterns = {
|
|
5
|
+
'discount-dot': discountDot
|
|
6
|
+
};
|
|
7
|
+
var patternVariants = patterns;
|
|
8
|
+
|
|
9
|
+
export { patternVariants as default };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { Button } from '../Button/index.js';
|
|
4
|
+
import { Stack } from '../Stack/index.js';
|
|
5
|
+
import { Text } from '../Text/index.js';
|
|
6
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
7
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
const SIZES_WIDTH = {
|
|
10
|
+
small: 320,
|
|
11
|
+
medium: 420,
|
|
12
|
+
large: 520
|
|
13
|
+
};
|
|
14
|
+
const StyledTooltip = /*#__PURE__*/_styled(Tooltip, {
|
|
15
|
+
shouldForwardProp: prop => !['sentiment', 'size'].includes(prop),
|
|
16
|
+
target: "ejpxv5a0"
|
|
17
|
+
})("padding:", _ref => {
|
|
18
|
+
let {
|
|
19
|
+
theme
|
|
20
|
+
} = _ref;
|
|
21
|
+
return theme.space['2'];
|
|
22
|
+
}, ";width:", _ref2 => {
|
|
23
|
+
let {
|
|
24
|
+
size
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return SIZES_WIDTH[size];
|
|
27
|
+
}, "px;max-width:", _ref3 => {
|
|
28
|
+
let {
|
|
29
|
+
size
|
|
30
|
+
} = _ref3;
|
|
31
|
+
return SIZES_WIDTH[size];
|
|
32
|
+
}, "px;text-align:initial;", _ref4 => {
|
|
33
|
+
let {
|
|
34
|
+
theme,
|
|
35
|
+
sentiment
|
|
36
|
+
} = _ref4;
|
|
37
|
+
if (sentiment === 'neutral') {
|
|
38
|
+
return `
|
|
39
|
+
background: ${theme.colors.neutral.background};
|
|
40
|
+
box-shadow: ${theme.shadows.popover};
|
|
41
|
+
&::after {
|
|
42
|
+
border-color: ${theme.colors.neutral.background} transparent transparent transparent;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
return `
|
|
47
|
+
background: ${theme.colors.primary.backgroundStrong};
|
|
48
|
+
box-shadow: ${theme.shadows.popover};
|
|
49
|
+
&::after {
|
|
50
|
+
border-color: ${theme.colors.primary.backgroundStrong} transparent transparent transparent;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
}, ";");
|
|
54
|
+
const ContentWrapper = _ref5 => {
|
|
55
|
+
let {
|
|
56
|
+
title,
|
|
57
|
+
onClose,
|
|
58
|
+
children,
|
|
59
|
+
sentiment
|
|
60
|
+
} = _ref5;
|
|
61
|
+
return jsxs(Stack, {
|
|
62
|
+
gap: 1,
|
|
63
|
+
children: [jsxs(Stack, {
|
|
64
|
+
direction: "row",
|
|
65
|
+
justifyContent: "space-between",
|
|
66
|
+
children: [jsx(Text, {
|
|
67
|
+
variant: "bodyStrong",
|
|
68
|
+
as: "h3",
|
|
69
|
+
prominence: sentiment === 'neutral' ? 'strong' : 'stronger',
|
|
70
|
+
children: title
|
|
71
|
+
}), jsx(Button, {
|
|
72
|
+
variant: sentiment === 'neutral' ? 'ghost' : 'filled',
|
|
73
|
+
sentiment: sentiment === 'neutral' ? 'neutral' : 'primary',
|
|
74
|
+
onClick: onClose,
|
|
75
|
+
size: "small",
|
|
76
|
+
icon: "close",
|
|
77
|
+
"aria-label": "close"
|
|
78
|
+
})]
|
|
79
|
+
}), typeof children === 'string' ? jsx(Text, {
|
|
80
|
+
variant: "bodySmall",
|
|
81
|
+
as: "p",
|
|
82
|
+
prominence: sentiment === 'neutral' ? 'strong' : 'stronger',
|
|
83
|
+
children: children
|
|
84
|
+
}) : children]
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const Popover = _ref6 => {
|
|
88
|
+
let {
|
|
89
|
+
visible = false,
|
|
90
|
+
children,
|
|
91
|
+
placement,
|
|
92
|
+
content,
|
|
93
|
+
title,
|
|
94
|
+
sentiment = 'neutral',
|
|
95
|
+
size = 'medium',
|
|
96
|
+
onClose,
|
|
97
|
+
className,
|
|
98
|
+
'data-testid': dataTestId
|
|
99
|
+
} = _ref6;
|
|
100
|
+
const ref = useRef(null);
|
|
101
|
+
const handleClickOutside = useCallback(event => {
|
|
102
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
103
|
+
onClose();
|
|
104
|
+
}
|
|
105
|
+
}, [onClose]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
108
|
+
return () => {
|
|
109
|
+
document.removeEventListener('click', handleClickOutside, true);
|
|
110
|
+
};
|
|
111
|
+
}, [handleClickOutside]);
|
|
112
|
+
return jsx(StyledTooltip, {
|
|
113
|
+
visible: visible,
|
|
114
|
+
placement: placement,
|
|
115
|
+
text: jsx(ContentWrapper, {
|
|
116
|
+
title: title,
|
|
117
|
+
onClose: onClose,
|
|
118
|
+
sentiment: sentiment,
|
|
119
|
+
children: content
|
|
120
|
+
}),
|
|
121
|
+
className: className,
|
|
122
|
+
sentiment: sentiment,
|
|
123
|
+
"data-testid": dataTestId,
|
|
124
|
+
size: size,
|
|
125
|
+
role: "dialog",
|
|
126
|
+
ref: ref,
|
|
127
|
+
children: children
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { Popover };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { keyframes } from '@emotion/react';
|
|
3
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
const shineAnimation = keyframes`
|
|
6
|
+
from {
|
|
7
|
+
left: -25%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
to {
|
|
11
|
+
left: 100%;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
const StyledProgressContainer = /*#__PURE__*/_styled("div", {
|
|
15
|
+
target: "e1b95x8r2"
|
|
16
|
+
})("overflow:hidden;position:relative;height:4px;margin-left:0;margin-right:0;border-radius:", _ref => {
|
|
17
|
+
let {
|
|
18
|
+
theme
|
|
19
|
+
} = _ref;
|
|
20
|
+
return theme.radii.default;
|
|
21
|
+
}, ";background-color:", _ref2 => {
|
|
22
|
+
let {
|
|
23
|
+
theme
|
|
24
|
+
} = _ref2;
|
|
25
|
+
return theme.colors.neutral.backgroundStrong;
|
|
26
|
+
}, ";");
|
|
27
|
+
const StyledProgress = /*#__PURE__*/_styled("div", {
|
|
28
|
+
target: "e1b95x8r1"
|
|
29
|
+
})("position:absolute;top:0;left:0;bottom:0;width:25%;opacity:0.8;background:linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0),\n rgba(255, 255, 255, 0.3),\n rgba(255, 255, 255, 0.4),\n rgba(255, 255, 255, 0.3),\n rgba(255, 255, 255, 0)\n );animation:", shineAnimation, " 1s linear infinite;");
|
|
30
|
+
const StyledFilled = /*#__PURE__*/_styled('div', {
|
|
31
|
+
shouldForwardProp: prop => !['sentiment', 'value'].includes(prop),
|
|
32
|
+
target: "e1b95x8r0"
|
|
33
|
+
})("border-radius:", _ref3 => {
|
|
34
|
+
let {
|
|
35
|
+
theme
|
|
36
|
+
} = _ref3;
|
|
37
|
+
return theme.radii.default;
|
|
38
|
+
}, ";position:absolute;top:0;left:0;bottom:0;background-color:", _ref4 => {
|
|
39
|
+
let {
|
|
40
|
+
theme,
|
|
41
|
+
sentiment
|
|
42
|
+
} = _ref4;
|
|
43
|
+
return theme.colors[sentiment].backgroundStrong ?? 'inherit';
|
|
44
|
+
}, ";transition:0.3s width;width:", _ref5 => {
|
|
45
|
+
let {
|
|
46
|
+
value
|
|
47
|
+
} = _ref5;
|
|
48
|
+
return Math.max(0, Math.min(100, value));
|
|
49
|
+
}, "%;");
|
|
50
|
+
const ProgressBar = _ref6 => {
|
|
51
|
+
let {
|
|
52
|
+
progress = false,
|
|
53
|
+
value = 0,
|
|
54
|
+
sentiment = 'primary',
|
|
55
|
+
className,
|
|
56
|
+
'data-testid': dataTestId
|
|
57
|
+
} = _ref6;
|
|
58
|
+
return jsx(StyledProgressContainer, {
|
|
59
|
+
role: "progressbar",
|
|
60
|
+
"aria-valuenow": value,
|
|
61
|
+
"aria-valuemin": 0,
|
|
62
|
+
"aria-valuemax": 100,
|
|
63
|
+
className: className,
|
|
64
|
+
"data-testid": dataTestId,
|
|
65
|
+
children: progress ? jsx(StyledProgress, {}) : jsx(StyledFilled, {
|
|
66
|
+
sentiment: sentiment,
|
|
67
|
+
value: value
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { ProgressBar };
|