@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,147 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { getLegendColor } from '../../helpers/legend.js';
|
|
4
|
+
import { Checkbox } from '../Checkbox/index.js';
|
|
5
|
+
import { Text } from '../Text/index.js';
|
|
6
|
+
import { getSelected, getMin, getMax, getAverage, getCurrent } from './helpers.js';
|
|
7
|
+
import { jsxs, jsx } 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 styles = {
|
|
11
|
+
body: theme => /*#__PURE__*/css(">:not(:last-child){border-bottom:1px solid ", theme.colors.neutral.backgroundStrong, ";}"),
|
|
12
|
+
head: theme => /*#__PURE__*/css("display:flex;padding-bottom:8px;border-bottom:1px solid ", theme.colors.neutral.backgroundStrong, ";>:not(:last-child){margin-right:8px;}"),
|
|
13
|
+
legend: index => theme => /*#__PURE__*/css("margin-left:16px;width:32px;height:2px;background-color:", getLegendColor(theme)[index], ";"),
|
|
14
|
+
row: process.env.NODE_ENV === "production" ? {
|
|
15
|
+
name: "fevtnc",
|
|
16
|
+
styles: "display:flex;padding:4px 0;>:not(:last-child){margin-right:8px;}"
|
|
17
|
+
} : {
|
|
18
|
+
name: "fevtnc",
|
|
19
|
+
styles: "display:flex;padding:4px 0;>:not(:last-child){margin-right:8px;}",
|
|
20
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const StyledText = /*#__PURE__*/_styled(Text, {
|
|
24
|
+
target: "erndk5t3"
|
|
25
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
26
|
+
name: "1rtr7zh",
|
|
27
|
+
styles: "text-align:right;flex:1;min-width:72px;align-self:center"
|
|
28
|
+
} : {
|
|
29
|
+
name: "1rtr7zh",
|
|
30
|
+
styles: "text-align:right;flex:1;min-width:72px;align-self:center",
|
|
31
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
32
|
+
});
|
|
33
|
+
const Cell = _ref => {
|
|
34
|
+
let {
|
|
35
|
+
value,
|
|
36
|
+
variant
|
|
37
|
+
} = _ref;
|
|
38
|
+
return jsx(StyledText, {
|
|
39
|
+
variant: variant,
|
|
40
|
+
color: "neutral",
|
|
41
|
+
as: "span",
|
|
42
|
+
children: value
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const CellValueContainer = /*#__PURE__*/_styled("div", {
|
|
46
|
+
target: "erndk5t2"
|
|
47
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
48
|
+
name: "s5xdrg",
|
|
49
|
+
styles: "display:flex;align-items:center"
|
|
50
|
+
} : {
|
|
51
|
+
name: "s5xdrg",
|
|
52
|
+
styles: "display:flex;align-items:center",
|
|
53
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
54
|
+
});
|
|
55
|
+
const LongContainer = /*#__PURE__*/_styled("div", {
|
|
56
|
+
target: "erndk5t1"
|
|
57
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
58
|
+
name: "1ajplif",
|
|
59
|
+
styles: "display:flex;flex:6"
|
|
60
|
+
} : {
|
|
61
|
+
name: "1ajplif",
|
|
62
|
+
styles: "display:flex;flex:6",
|
|
63
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
64
|
+
});
|
|
65
|
+
const noop = value => value.toString();
|
|
66
|
+
const StyledContainer = /*#__PURE__*/_styled("div", {
|
|
67
|
+
target: "erndk5t0"
|
|
68
|
+
})("margin-top:", _ref2 => {
|
|
69
|
+
let {
|
|
70
|
+
theme
|
|
71
|
+
} = _ref2;
|
|
72
|
+
return theme.space[2];
|
|
73
|
+
}, ";");
|
|
74
|
+
const CustomLegend = _ref3 => {
|
|
75
|
+
let {
|
|
76
|
+
axisTransformer = noop,
|
|
77
|
+
data,
|
|
78
|
+
selected,
|
|
79
|
+
setSelected,
|
|
80
|
+
className,
|
|
81
|
+
'data-testid': dataTestId
|
|
82
|
+
} = _ref3;
|
|
83
|
+
return jsxs(StyledContainer, {
|
|
84
|
+
className: className,
|
|
85
|
+
"data-testid": dataTestId,
|
|
86
|
+
children: [jsxs("div", {
|
|
87
|
+
css: styles.head,
|
|
88
|
+
children: [jsx(LongContainer, {
|
|
89
|
+
children: "Legend"
|
|
90
|
+
}), jsx(Cell, {
|
|
91
|
+
variant: "body",
|
|
92
|
+
value: "Minimum"
|
|
93
|
+
}), jsx(Cell, {
|
|
94
|
+
variant: "body",
|
|
95
|
+
value: "Maximum"
|
|
96
|
+
}), jsx(Cell, {
|
|
97
|
+
variant: "body",
|
|
98
|
+
value: "Average"
|
|
99
|
+
}), jsx(Cell, {
|
|
100
|
+
variant: "body",
|
|
101
|
+
value: "Current"
|
|
102
|
+
})]
|
|
103
|
+
}), jsx("div", {
|
|
104
|
+
css: styles.body,
|
|
105
|
+
children: data?.map((row, index) => {
|
|
106
|
+
const values = row.data.map(val => val.y);
|
|
107
|
+
const labelIndexed = `${row.id}${index}`;
|
|
108
|
+
const id = row.id.toString();
|
|
109
|
+
return jsxs("div", {
|
|
110
|
+
css: styles.row,
|
|
111
|
+
children: [jsx(LongContainer, {
|
|
112
|
+
children: jsx(Checkbox, {
|
|
113
|
+
checked: selected.includes(labelIndexed),
|
|
114
|
+
name: id,
|
|
115
|
+
onChange: () => setSelected([...getSelected(id, index, selected)]),
|
|
116
|
+
children: jsxs(CellValueContainer, {
|
|
117
|
+
children: [jsx(Text, {
|
|
118
|
+
as: "span",
|
|
119
|
+
variant: "bodySmall",
|
|
120
|
+
color: "neutral",
|
|
121
|
+
children: row?.['label']
|
|
122
|
+
}), jsx("div", {
|
|
123
|
+
"data-testid": `label-${id}`,
|
|
124
|
+
css: styles.legend(index)
|
|
125
|
+
})]
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
}), jsx(Cell, {
|
|
129
|
+
variant: "bodySmall",
|
|
130
|
+
value: axisTransformer(getMin(values))
|
|
131
|
+
}), jsx(Cell, {
|
|
132
|
+
variant: "bodySmall",
|
|
133
|
+
value: axisTransformer(getMax(values))
|
|
134
|
+
}), jsx(Cell, {
|
|
135
|
+
variant: "bodySmall",
|
|
136
|
+
value: axisTransformer(getAverage(values))
|
|
137
|
+
}), jsx(Cell, {
|
|
138
|
+
variant: "bodySmall",
|
|
139
|
+
value: axisTransformer(getCurrent(values))
|
|
140
|
+
})]
|
|
141
|
+
}, labelIndexed);
|
|
142
|
+
})
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export { CustomLegend };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { Text } from '../Text/index.js';
|
|
3
|
+
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
const LineTooltipContainer = /*#__PURE__*/_styled("div", {
|
|
6
|
+
target: "e11niu3b1"
|
|
7
|
+
})("display:flex;background:", _ref => {
|
|
8
|
+
let {
|
|
9
|
+
theme
|
|
10
|
+
} = _ref;
|
|
11
|
+
return theme.colors.neutral.backgroundStronger;
|
|
12
|
+
}, ";border-radius:", _ref2 => {
|
|
13
|
+
let {
|
|
14
|
+
theme
|
|
15
|
+
} = _ref2;
|
|
16
|
+
return theme.radii.small;
|
|
17
|
+
}, ";box-shadow:", _ref3 => {
|
|
18
|
+
let {
|
|
19
|
+
theme
|
|
20
|
+
} = _ref3;
|
|
21
|
+
return theme.shadows.tooltip;
|
|
22
|
+
}, ";padding:5px 9px;align-items:center;");
|
|
23
|
+
const LineColorSquare = /*#__PURE__*/_styled("span", {
|
|
24
|
+
target: "e11niu3b0"
|
|
25
|
+
})("display:block;width:12px;height:12px;background:", _ref4 => {
|
|
26
|
+
let {
|
|
27
|
+
color
|
|
28
|
+
} = _ref4;
|
|
29
|
+
return color;
|
|
30
|
+
}, ";margin-right:12px;");
|
|
31
|
+
const LineChartTooltip = _ref5 => {
|
|
32
|
+
let {
|
|
33
|
+
point
|
|
34
|
+
} = _ref5;
|
|
35
|
+
return jsxs(LineTooltipContainer, {
|
|
36
|
+
children: [jsx("div", {
|
|
37
|
+
children: jsx(LineColorSquare, {
|
|
38
|
+
color: point.serieColor
|
|
39
|
+
})
|
|
40
|
+
}), jsxs("div", {
|
|
41
|
+
children: [jsx(Text, {
|
|
42
|
+
variant: "bodyStronger",
|
|
43
|
+
color: "neutral",
|
|
44
|
+
prominence: "stronger",
|
|
45
|
+
as: "div",
|
|
46
|
+
children: point.data.yFormatted
|
|
47
|
+
}), jsx(Text, {
|
|
48
|
+
variant: "bodySmall",
|
|
49
|
+
color: "neutral",
|
|
50
|
+
prominence: "stronger",
|
|
51
|
+
as: "div",
|
|
52
|
+
children: point.data.xFormatted
|
|
53
|
+
})]
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { LineChartTooltip };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const parse = data => {
|
|
2
|
+
if (typeof data === 'number') return data || 0;
|
|
3
|
+
if (typeof data === 'string') return parseFloat(data) || 0;
|
|
4
|
+
if (data instanceof Date) return data.getTime();
|
|
5
|
+
return 0;
|
|
6
|
+
};
|
|
7
|
+
const getMin = function (values) {
|
|
8
|
+
if (values === void 0) {
|
|
9
|
+
values = [];
|
|
10
|
+
}
|
|
11
|
+
return values.length ? Math.min(...values.map(parse)) : 0;
|
|
12
|
+
};
|
|
13
|
+
const getMax = function (values) {
|
|
14
|
+
if (values === void 0) {
|
|
15
|
+
values = [];
|
|
16
|
+
}
|
|
17
|
+
return values.length ? Math.max(...values.map(parse)) : 0;
|
|
18
|
+
};
|
|
19
|
+
const getAverage = function (values) {
|
|
20
|
+
if (values === void 0) {
|
|
21
|
+
values = [];
|
|
22
|
+
}
|
|
23
|
+
return values.length ? Math.round(values.reduce((sum, curr) => sum + parse(curr), 0) / values.length * 100) / 100 : 0;
|
|
24
|
+
};
|
|
25
|
+
const getMaxChartValue = preppedData => {
|
|
26
|
+
if (!preppedData?.length) return 0;
|
|
27
|
+
const maximum = Math.max(...preppedData.map(_ref => {
|
|
28
|
+
let {
|
|
29
|
+
data
|
|
30
|
+
} = _ref;
|
|
31
|
+
return getMax(data.map(_ref2 => {
|
|
32
|
+
let {
|
|
33
|
+
y
|
|
34
|
+
} = _ref2;
|
|
35
|
+
return y || 0;
|
|
36
|
+
}));
|
|
37
|
+
}));
|
|
38
|
+
return Math.ceil(maximum + maximum * 0.1);
|
|
39
|
+
};
|
|
40
|
+
const getMinChartValue = preppedData => {
|
|
41
|
+
if (!preppedData?.length) return 0;
|
|
42
|
+
const minimum = Math.min(...preppedData.map(_ref3 => {
|
|
43
|
+
let {
|
|
44
|
+
data
|
|
45
|
+
} = _ref3;
|
|
46
|
+
return getMin(data.map(_ref4 => {
|
|
47
|
+
let {
|
|
48
|
+
y
|
|
49
|
+
} = _ref4;
|
|
50
|
+
return y || 0;
|
|
51
|
+
}));
|
|
52
|
+
}));
|
|
53
|
+
return Math.floor(minimum - minimum * 0.1);
|
|
54
|
+
};
|
|
55
|
+
const getCurrent = function (values) {
|
|
56
|
+
if (values === void 0) {
|
|
57
|
+
values = [];
|
|
58
|
+
}
|
|
59
|
+
return values.length ? values[values.length - 1] : 0;
|
|
60
|
+
};
|
|
61
|
+
const getSelected = function (label, index, selected) {
|
|
62
|
+
if (selected === void 0) {
|
|
63
|
+
selected = [];
|
|
64
|
+
}
|
|
65
|
+
const labelIndexed = label + index.toString();
|
|
66
|
+
const found = selected.indexOf(labelIndexed);
|
|
67
|
+
if (found > -1) {
|
|
68
|
+
selected.splice(found, 1);
|
|
69
|
+
} else {
|
|
70
|
+
selected.push(labelIndexed);
|
|
71
|
+
}
|
|
72
|
+
return selected;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { getAverage, getCurrent, getMax, getMaxChartValue, getMin, getMinChartValue, getSelected };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { useTheme } from '@emotion/react';
|
|
2
|
+
import { ResponsiveLine } from '@nivo/line';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { getLegendColor } from '../../helpers/legend.js';
|
|
5
|
+
import { CustomLegend } from './CustomLegend.js';
|
|
6
|
+
import { LineChartTooltip } from './Tooltip.js';
|
|
7
|
+
import { getMaxChartValue, getMinChartValue } from './helpers.js';
|
|
8
|
+
import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_MARGIN = {
|
|
11
|
+
bottom: 50,
|
|
12
|
+
left: 60,
|
|
13
|
+
right: 25,
|
|
14
|
+
top: 50
|
|
15
|
+
};
|
|
16
|
+
const DEFAULT_XSCALE = {
|
|
17
|
+
format: '%Y-%m-%dT%H:%M:%S%Z',
|
|
18
|
+
// 2021-08-30T02:56:07Z
|
|
19
|
+
precision: 'minute',
|
|
20
|
+
type: 'time',
|
|
21
|
+
useUTC: false
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_YSCALE = {
|
|
24
|
+
type: 'linear'
|
|
25
|
+
};
|
|
26
|
+
const DEFAULT_CHARTPROPS = {};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @experimental This component is experimental and may be subject to breaking changes in the future.
|
|
30
|
+
*/
|
|
31
|
+
const LineChart = _ref => {
|
|
32
|
+
let {
|
|
33
|
+
height = '537px',
|
|
34
|
+
// to maintain aspect ratio based on our standard 1074px width
|
|
35
|
+
margin = DEFAULT_MARGIN,
|
|
36
|
+
xScale = DEFAULT_XSCALE,
|
|
37
|
+
yScale = DEFAULT_YSCALE,
|
|
38
|
+
data,
|
|
39
|
+
withLegend = false,
|
|
40
|
+
axisFormatters,
|
|
41
|
+
pointFormatters,
|
|
42
|
+
tickValues,
|
|
43
|
+
chartProps = DEFAULT_CHARTPROPS,
|
|
44
|
+
'data-testid': dataTestId
|
|
45
|
+
} = _ref;
|
|
46
|
+
const theme = useTheme();
|
|
47
|
+
const dataset = {
|
|
48
|
+
datasets: data?.map(d => ({
|
|
49
|
+
data: d.data,
|
|
50
|
+
id: d.id,
|
|
51
|
+
label: d?.['label']
|
|
52
|
+
}))
|
|
53
|
+
};
|
|
54
|
+
const chartTheme = {
|
|
55
|
+
axis: {
|
|
56
|
+
ticks: {
|
|
57
|
+
line: {
|
|
58
|
+
stroke: theme.colors.neutral.backgroundStrong,
|
|
59
|
+
strokeWidth: 1
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
fontFamily: theme.typography.body.fontFamily,
|
|
64
|
+
fontSize: 12,
|
|
65
|
+
textColor: theme.colors.neutral.textWeak
|
|
66
|
+
};
|
|
67
|
+
const [selected, setSelected] = useState(dataset.datasets?.map((_ref2, index) => {
|
|
68
|
+
let {
|
|
69
|
+
id
|
|
70
|
+
} = _ref2;
|
|
71
|
+
return `${id}${index}`;
|
|
72
|
+
}));
|
|
73
|
+
const finalData = dataset.datasets?.filter((_ref3, index) => {
|
|
74
|
+
let {
|
|
75
|
+
id
|
|
76
|
+
} = _ref3;
|
|
77
|
+
return selected ? selected.includes(`${id}${index}`) : false;
|
|
78
|
+
});
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (selected !== undefined) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setSelected(dataset.datasets?.map((_ref4, index) => {
|
|
84
|
+
let {
|
|
85
|
+
id
|
|
86
|
+
} = _ref4;
|
|
87
|
+
return `${id}${index}`;
|
|
88
|
+
}));
|
|
89
|
+
}, [dataset.datasets, selected]);
|
|
90
|
+
const localColors = getLegendColor(theme);
|
|
91
|
+
return jsxs(Fragment, {
|
|
92
|
+
children: [jsx("div", {
|
|
93
|
+
style: {
|
|
94
|
+
height
|
|
95
|
+
},
|
|
96
|
+
children: jsx(ResponsiveLine, {
|
|
97
|
+
colors: localColors,
|
|
98
|
+
data: finalData ?? [],
|
|
99
|
+
margin: margin,
|
|
100
|
+
xScale: xScale,
|
|
101
|
+
yScale: {
|
|
102
|
+
max: getMaxChartValue(finalData),
|
|
103
|
+
min: getMinChartValue(finalData),
|
|
104
|
+
...yScale
|
|
105
|
+
},
|
|
106
|
+
xFormat: pointFormatters?.x,
|
|
107
|
+
yFormat: pointFormatters?.y,
|
|
108
|
+
axisBottom: {
|
|
109
|
+
format: axisFormatters?.bottom,
|
|
110
|
+
tickPadding: 5,
|
|
111
|
+
tickRotation: 0,
|
|
112
|
+
tickSize: 5,
|
|
113
|
+
tickValues: tickValues?.bottom
|
|
114
|
+
},
|
|
115
|
+
axisLeft: {
|
|
116
|
+
format: axisFormatters?.left,
|
|
117
|
+
tickPadding: 5,
|
|
118
|
+
tickRotation: 0,
|
|
119
|
+
tickSize: 5,
|
|
120
|
+
tickValues: tickValues?.left
|
|
121
|
+
},
|
|
122
|
+
pointSize: 10,
|
|
123
|
+
useMesh: true,
|
|
124
|
+
theme: chartTheme,
|
|
125
|
+
curve: "monotoneX",
|
|
126
|
+
tooltip: LineChartTooltip,
|
|
127
|
+
"data-testid": dataTestId,
|
|
128
|
+
...chartProps
|
|
129
|
+
})
|
|
130
|
+
}), withLegend && jsx(CustomLegend, {
|
|
131
|
+
data: dataset.datasets,
|
|
132
|
+
selected: selected ?? [],
|
|
133
|
+
setSelected: setSelected,
|
|
134
|
+
axisTransformer: axisFormatters?.left
|
|
135
|
+
})]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { LineChart };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { forwardRef, useState, useRef, useEffect } from 'react';
|
|
3
|
+
import recursivelyGetChildrenString from '../../helpers/recursivelyGetChildrenString.js';
|
|
4
|
+
import capitalize from '../../utils/capitalize.js';
|
|
5
|
+
import { Icon } from '../Icon/index.js';
|
|
6
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
7
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
const StyledIcon = /*#__PURE__*/_styled(Icon, {
|
|
10
|
+
target: "e1afnb7a2"
|
|
11
|
+
})();
|
|
12
|
+
const PROMINENCES = {
|
|
13
|
+
default: '',
|
|
14
|
+
weak: 'weak',
|
|
15
|
+
strong: 'strong'
|
|
16
|
+
};
|
|
17
|
+
const ICON_SIZE = 16;
|
|
18
|
+
const BLANK_TARGET_ICON_SIZE = 14;
|
|
19
|
+
const TRANSITION_DURATION = 250;
|
|
20
|
+
const StyledExternalIconContainer = /*#__PURE__*/_styled("span", {
|
|
21
|
+
target: "e1afnb7a1"
|
|
22
|
+
})("display:inline-flex;padding-bottom:", _ref => {
|
|
23
|
+
let {
|
|
24
|
+
theme
|
|
25
|
+
} = _ref;
|
|
26
|
+
return theme.space['0.5'];
|
|
27
|
+
}, ";");
|
|
28
|
+
const StyledLink = /*#__PURE__*/_styled('a', {
|
|
29
|
+
shouldForwardProp: prop => !['sentiment', 'iconPosition', 'as', 'oneLine'].includes(prop),
|
|
30
|
+
target: "e1afnb7a0"
|
|
31
|
+
})("background-color:transparent;border:none;padding:0;color:", _ref2 => {
|
|
32
|
+
let {
|
|
33
|
+
theme,
|
|
34
|
+
sentiment,
|
|
35
|
+
prominence
|
|
36
|
+
} = _ref2;
|
|
37
|
+
const definedProminence = capitalize(PROMINENCES[prominence ?? 'default']);
|
|
38
|
+
theme.colors[sentiment];
|
|
39
|
+
const text = `text${definedProminence}`;
|
|
40
|
+
return theme.colors[sentiment]?.[text] ?? theme.colors.neutral.text;
|
|
41
|
+
}, ";text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px;text-decoration-color:transparent;display:inline-flex;flex-direction:row;align-items:center;transition:text-decoration-color ", TRANSITION_DURATION, "ms ease-out;", StyledIcon, "{transition:transform ", TRANSITION_DURATION, "ms ease-out;}gap:", _ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
theme
|
|
44
|
+
} = _ref3;
|
|
45
|
+
return theme.space['1'];
|
|
46
|
+
}, ";position:relative;cursor:pointer;>*{pointer-events:none;}", _ref4 => {
|
|
47
|
+
let {
|
|
48
|
+
oneLine
|
|
49
|
+
} = _ref4;
|
|
50
|
+
return oneLine ? `white-space: nowrap;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
display: block;` : 'width: fit-content;';
|
|
54
|
+
}, " ", _ref5 => {
|
|
55
|
+
let {
|
|
56
|
+
size,
|
|
57
|
+
theme
|
|
58
|
+
} = _ref5;
|
|
59
|
+
const variant = size === 'small' ? 'bodySmallStrong' : 'bodyStrong';
|
|
60
|
+
return `
|
|
61
|
+
font-size: ${theme.typography[variant].fontSize};
|
|
62
|
+
font-family: ${theme.typography[variant].fontFamily};
|
|
63
|
+
font-weight: ${theme.typography[variant].weight};
|
|
64
|
+
letter-spacing: ${theme.typography[variant].letterSpacing};
|
|
65
|
+
line-height: ${theme.typography[variant].lineHeight};
|
|
66
|
+
paragraph-spacing: ${theme.typography[variant].paragraphSpacing};
|
|
67
|
+
text-case: ${theme.typography[variant].textCase};
|
|
68
|
+
`;
|
|
69
|
+
}, " &:hover,&:focus{outline:none;text-decoration:underline;text-decoration-thickness:1px;", _ref6 => {
|
|
70
|
+
let {
|
|
71
|
+
theme,
|
|
72
|
+
sentiment,
|
|
73
|
+
prominence
|
|
74
|
+
} = _ref6;
|
|
75
|
+
const definedProminence = capitalize(PROMINENCES[prominence ?? 'default']);
|
|
76
|
+
theme.colors[sentiment];
|
|
77
|
+
const text = `text${definedProminence}`;
|
|
78
|
+
return `
|
|
79
|
+
color: ${theme.colors[sentiment]?.[text] ?? theme.colors.neutral.text};
|
|
80
|
+
text-decoration-color: ${theme.colors[sentiment]?.[text] ?? theme.colors.neutral.text};`;
|
|
81
|
+
}, ";", StyledIcon, "{transform:", _ref7 => {
|
|
82
|
+
let {
|
|
83
|
+
theme,
|
|
84
|
+
iconPosition
|
|
85
|
+
} = _ref7;
|
|
86
|
+
return iconPosition === 'left' ? `translate(${theme.space['0.5']}, 0)` : `translate(-${theme.space['0.5']}, 0)`;
|
|
87
|
+
}, ";}}&:hover::after,&:focus::after{background-color:", _ref8 => {
|
|
88
|
+
let {
|
|
89
|
+
theme,
|
|
90
|
+
sentiment
|
|
91
|
+
} = _ref8;
|
|
92
|
+
return theme.colors[sentiment]?.text ?? theme.colors.neutral.text;
|
|
93
|
+
}, ";}&:active{text-decoration-thickness:2px;}");
|
|
94
|
+
const Link = /*#__PURE__*/forwardRef((_ref9, ref) => {
|
|
95
|
+
let {
|
|
96
|
+
children,
|
|
97
|
+
href,
|
|
98
|
+
target,
|
|
99
|
+
download,
|
|
100
|
+
sentiment = 'info',
|
|
101
|
+
prominence,
|
|
102
|
+
size = 'large',
|
|
103
|
+
iconPosition,
|
|
104
|
+
rel,
|
|
105
|
+
className,
|
|
106
|
+
onClick,
|
|
107
|
+
'aria-label': ariaLabel,
|
|
108
|
+
oneLine = false,
|
|
109
|
+
'data-testid': dataTestId
|
|
110
|
+
} = _ref9;
|
|
111
|
+
const isBlank = target === '_blank';
|
|
112
|
+
const computedRel = rel || (isBlank ? 'noopener noreferrer' : undefined);
|
|
113
|
+
const [isTruncated, setIsTruncated] = useState(false);
|
|
114
|
+
const elementRef = useRef(null);
|
|
115
|
+
const usedRef = ref ?? elementRef;
|
|
116
|
+
const finalStringChildren = recursivelyGetChildrenString(children);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (oneLine && usedRef && usedRef.current) {
|
|
119
|
+
const {
|
|
120
|
+
offsetWidth,
|
|
121
|
+
scrollWidth
|
|
122
|
+
} = usedRef.current;
|
|
123
|
+
setIsTruncated(offsetWidth < scrollWidth);
|
|
124
|
+
}
|
|
125
|
+
}, [oneLine, ref, usedRef]);
|
|
126
|
+
return jsx(Tooltip, {
|
|
127
|
+
text: oneLine && isTruncated ? finalStringChildren : '',
|
|
128
|
+
children: jsxs(StyledLink, {
|
|
129
|
+
href: href,
|
|
130
|
+
target: target,
|
|
131
|
+
download: download,
|
|
132
|
+
ref: usedRef,
|
|
133
|
+
sentiment: sentiment,
|
|
134
|
+
prominence: prominence,
|
|
135
|
+
rel: computedRel,
|
|
136
|
+
className: className,
|
|
137
|
+
size: size,
|
|
138
|
+
onClick: onClick,
|
|
139
|
+
iconPosition: iconPosition,
|
|
140
|
+
"aria-label": ariaLabel,
|
|
141
|
+
oneLine: oneLine,
|
|
142
|
+
"data-testid": dataTestId,
|
|
143
|
+
children: [!isBlank && iconPosition === 'left' ? jsx(StyledIcon, {
|
|
144
|
+
name: "arrow-left",
|
|
145
|
+
size: ICON_SIZE
|
|
146
|
+
}) : null, children, isBlank ? jsx(StyledExternalIconContainer, {
|
|
147
|
+
children: jsx(StyledIcon, {
|
|
148
|
+
name: "open-in-new",
|
|
149
|
+
size: BLANK_TARGET_ICON_SIZE
|
|
150
|
+
})
|
|
151
|
+
}) : null, !isBlank && iconPosition === 'right' ? jsx(StyledIcon, {
|
|
152
|
+
name: "arrow-right",
|
|
153
|
+
size: ICON_SIZE
|
|
154
|
+
}) : null]
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export { Link, PROMINENCES };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
const StyledBody = /*#__PURE__*/_styled("div", {
|
|
5
|
+
target: "e1wm4no70"
|
|
6
|
+
})("display:flex;flex-direction:column;gap:", _ref => {
|
|
7
|
+
let {
|
|
8
|
+
theme
|
|
9
|
+
} = _ref;
|
|
10
|
+
return theme.space['2'];
|
|
11
|
+
}, ";");
|
|
12
|
+
const Body = _ref2 => {
|
|
13
|
+
let {
|
|
14
|
+
children
|
|
15
|
+
} = _ref2;
|
|
16
|
+
return jsx(StyledBody, {
|
|
17
|
+
role: "rowgroup",
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { Body };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { jsx } 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 StyledCell = /*#__PURE__*/_styled("div", {
|
|
7
|
+
target: "e1e6rck40"
|
|
8
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
9
|
+
name: "humxtf",
|
|
10
|
+
styles: "display:flex;justify-content:center;flex-direction:column;min-height:60px"
|
|
11
|
+
} : {
|
|
12
|
+
name: "humxtf",
|
|
13
|
+
styles: "display:flex;justify-content:center;flex-direction:column;min-height:60px",
|
|
14
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
15
|
+
});
|
|
16
|
+
const Cell = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
preventClick,
|
|
21
|
+
'data-testid': dataTestid
|
|
22
|
+
} = _ref;
|
|
23
|
+
const handleClick = event => {
|
|
24
|
+
if (preventClick) {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return jsx(StyledCell, {
|
|
29
|
+
ref: ref,
|
|
30
|
+
role: "cell",
|
|
31
|
+
className: className,
|
|
32
|
+
onClick: handleClick,
|
|
33
|
+
"data-testid": dataTestid,
|
|
34
|
+
children: children
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export { Cell };
|