@ultraviolet/ui 3.0.0-beta.27 → 3.0.0-beta.29
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/README.md +47 -18
- package/dist/components/ActionBar/index.js +19 -7
- package/dist/components/Alert/index.d.ts +2 -1
- package/dist/components/Alert/index.js +98 -20
- package/dist/components/Alert/styles.css.d.ts +10 -1
- package/dist/components/Alert/styles.css.js +7 -5
- package/dist/components/Avatar/index.d.ts +1 -1
- package/dist/components/Avatar/index.js +46 -36
- package/dist/components/Avatar/styles.css.js +0 -1
- package/dist/components/Avatar/variables.css.js +1 -0
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Badge/index.js +19 -8
- package/dist/components/Banner/index.d.ts +1 -1
- package/dist/components/Banner/index.js +87 -28
- package/dist/components/BarChart/Tooltip.d.ts +1 -1
- package/dist/components/BarChart/Tooltip.js +23 -10
- package/dist/components/BarChart/index.d.ts +1 -1
- package/dist/components/BarChart/index.js +51 -31
- package/dist/components/BarStack/index.d.ts +1 -1
- package/dist/components/BarStack/index.js +64 -19
- package/dist/components/Breadcrumbs/components/Item.d.ts +1 -1
- package/dist/components/Breadcrumbs/components/Item.js +48 -12
- package/dist/components/Breadcrumbs/index.js +11 -2
- package/dist/components/Bullet/index.d.ts +1 -1
- package/dist/components/Bullet/index.js +10 -7
- package/dist/components/Button/index.js +122 -72
- package/dist/components/Card/index.js +80 -20
- package/dist/components/Carousel/index.d.ts +3 -3
- package/dist/components/Carousel/index.js +72 -26
- package/dist/components/Checkbox/index.js +139 -43
- package/dist/components/CheckboxGroup/index.d.ts +3 -3
- package/dist/components/CheckboxGroup/index.js +77 -24
- package/dist/components/Chip/ChipIcon.d.ts +1 -1
- package/dist/components/Chip/ChipIcon.js +46 -12
- package/dist/components/Chip/index.d.ts +3 -3
- package/dist/components/Chip/index.js +36 -11
- package/dist/components/CopyButton/index.d.ts +1 -1
- package/dist/components/CopyButton/index.js +23 -8
- package/dist/components/DateInput/components/CalendarContent.d.ts +1 -1
- package/dist/components/DateInput/components/CalendarContent.js +61 -26
- package/dist/components/DateInput/components/CalendarDaily.d.ts +1 -1
- package/dist/components/DateInput/components/CalendarDaily.js +105 -62
- package/dist/components/DateInput/components/CalendarMonthly.d.ts +1 -1
- package/dist/components/DateInput/components/CalendarMonthly.js +62 -39
- package/dist/components/DateInput/components/Popup.d.ts +1 -1
- package/dist/components/DateInput/components/Popup.js +29 -6
- package/dist/components/DateInput/helpers.js +9 -2
- package/dist/components/DateInput/helpersLocale.js +3 -9
- package/dist/components/DateInput/index.d.ts +1 -1
- package/dist/components/DateInput/index.js +193 -62
- package/dist/components/Dialog/Context.js +3 -1
- package/dist/components/Dialog/components/Button.d.ts +1 -1
- package/dist/components/Dialog/components/Button.js +12 -2
- package/dist/components/Dialog/components/Buttons.d.ts +1 -1
- package/dist/components/Dialog/components/Buttons.js +1 -1
- package/dist/components/Dialog/components/CancelButton.d.ts +1 -1
- package/dist/components/Dialog/components/CancelButton.js +12 -2
- package/dist/components/Dialog/components/Stack.d.ts +1 -1
- package/dist/components/Dialog/components/Stack.js +2 -5
- package/dist/components/Dialog/components/Text.d.ts +1 -1
- package/dist/components/Dialog/components/Text.js +2 -5
- package/dist/components/Dialog/index.d.ts +7 -7
- package/dist/components/Dialog/index.js +43 -12
- package/dist/components/Drawer/index.d.ts +4 -4
- package/dist/components/Drawer/index.js +53 -15
- package/dist/components/EmptyState/index.d.ts +1 -1
- package/dist/components/EmptyState/index.js +63 -21
- package/dist/components/Expandable/index.d.ts +2 -2
- package/dist/components/Expandable/index.js +52 -15
- package/dist/components/ExpandableCard/components/Title.d.ts +1 -1
- package/dist/components/ExpandableCard/components/Title.js +12 -2
- package/dist/components/ExpandableCard/index.d.ts +1 -1
- package/dist/components/ExpandableCard/index.js +197 -96
- package/dist/components/GlobalAlert/GlobalAlertLink.d.ts +1 -1
- package/dist/components/GlobalAlert/GlobalAlertLink.js +21 -5
- package/dist/components/GlobalAlert/index.d.ts +2 -2
- package/dist/components/GlobalAlert/index.js +51 -11
- package/dist/components/InfiniteScroll/index.d.ts +1 -1
- package/dist/components/InfiniteScroll/index.js +40 -33
- package/dist/components/Key/index.d.ts +1 -1
- package/dist/components/Key/index.js +29 -8
- package/dist/components/Label/index.d.ts +1 -1
- package/dist/components/Label/index.js +67 -6
- package/dist/components/LineChart/CustomLegend.d.ts +1 -1
- package/dist/components/LineChart/CustomLegend.js +69 -45
- package/dist/components/LineChart/Tooltip.d.ts +1 -1
- package/dist/components/LineChart/Tooltip.js +31 -9
- package/dist/components/LineChart/helpers.js +13 -12
- package/dist/components/LineChart/index.d.ts +1 -1
- package/dist/components/LineChart/index.js +56 -40
- package/dist/components/Link/index.js +74 -57
- package/dist/components/List/Cell.js +24 -22
- package/dist/components/List/ColumnProvider.d.ts +1 -1
- package/dist/components/List/ColumnProvider.js +12 -6
- package/dist/components/List/HeaderCell.d.ts +1 -1
- package/dist/components/List/HeaderCell.js +36 -19
- package/dist/components/List/HeaderRow.d.ts +1 -1
- package/dist/components/List/HeaderRow.js +14 -12
- package/dist/components/List/ListContext.d.ts +1 -1
- package/dist/components/List/ListContext.js +128 -78
- package/dist/components/List/Row.js +166 -90
- package/dist/components/List/SelectBar.d.ts +1 -1
- package/dist/components/List/SelectBar.js +20 -10
- package/dist/components/List/SkeletonRows.d.ts +1 -1
- package/dist/components/List/SkeletonRows.js +26 -16
- package/dist/components/List/index.d.ts +1 -1
- package/dist/components/List/index.js +60 -22
- package/dist/components/Loader/index.d.ts +1 -1
- package/dist/components/Loader/index.js +47 -23
- package/dist/components/Menu/MenuContent.d.ts +1 -1
- package/dist/components/Menu/MenuContent.js +216 -162
- package/dist/components/Menu/MenuProvider.d.ts +1 -1
- package/dist/components/Menu/MenuProvider.js +26 -13
- package/dist/components/Menu/components/Group.d.ts +1 -1
- package/dist/components/Menu/components/Group.js +11 -2
- package/dist/components/Menu/components/Item.js +144 -82
- package/dist/components/Menu/helpers.js +3 -1
- package/dist/components/Menu/index.d.ts +2 -2
- package/dist/components/Menu/index.js +5 -11
- package/dist/components/Menu/types.d.ts +2 -2
- package/dist/components/Meter/index.d.ts +1 -1
- package/dist/components/Meter/index.js +43 -12
- package/dist/components/Modal/ModalContent.d.ts +1 -1
- package/dist/components/Modal/ModalContent.js +41 -11
- package/dist/components/Modal/ModalProvider.d.ts +1 -1
- package/dist/components/Modal/ModalProvider.js +14 -11
- package/dist/components/Modal/components/Dialog.js +91 -47
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.js +60 -3
- package/dist/components/Notice/index.d.ts +1 -1
- package/dist/components/Notice/index.js +24 -5
- package/dist/components/Notification/Notification.js +12 -2
- package/dist/components/Notification/NotificationContainer.d.ts +1 -1
- package/dist/components/Notification/NotificationContainer.js +18 -2
- package/dist/components/NumberInput/index.d.ts +1 -1
- package/dist/components/NumberInput/index.js +239 -130
- package/dist/components/Pagination/PaginationButtons.d.ts +1 -1
- package/dist/components/Pagination/PaginationButtons.js +75 -10
- package/dist/components/Pagination/PerPage.d.ts +1 -1
- package/dist/components/Pagination/PerPage.js +32 -17
- package/dist/components/Pagination/getPageNumbers.js +12 -13
- package/dist/components/Pagination/index.d.ts +1 -1
- package/dist/components/Pagination/index.js +26 -3
- package/dist/components/PasswordCheck/index.d.ts +1 -1
- package/dist/components/PasswordCheck/index.js +27 -5
- package/dist/components/PieChart/Legends.d.ts +1 -1
- package/dist/components/PieChart/Legends.js +52 -20
- package/dist/components/PieChart/Tooltip.d.ts +1 -1
- package/dist/components/PieChart/Tooltip.js +2 -4
- package/dist/components/PieChart/index.d.ts +1 -1
- package/dist/components/PieChart/index.js +80 -40
- package/dist/components/Popover/index.js +104 -46
- package/dist/components/Popup/helpers.d.ts +5 -1
- package/dist/components/Popup/helpers.js +49 -35
- package/dist/components/Popup/index.d.ts +2 -1
- package/dist/components/Popup/index.js +373 -255
- package/dist/components/Popup/styles.css.js +0 -1
- package/dist/components/Popup/variables.css.js +1 -0
- package/dist/components/ProgressBar/index.d.ts +1 -1
- package/dist/components/ProgressBar/index.js +74 -20
- package/dist/components/Radio/index.js +83 -51
- package/dist/components/RadioGroup/index.d.ts +2 -2
- package/dist/components/RadioGroup/index.js +74 -20
- package/dist/components/Row/index.d.ts +1 -1
- package/dist/components/Row/index.js +38 -27
- package/dist/components/Row/styles.css.d.ts +11 -0
- package/dist/components/Row/styles.css.js +2 -2
- package/dist/components/SearchInput/KeyGroup.d.ts +1 -1
- package/dist/components/SearchInput/KeyGroup.js +2 -6
- package/dist/components/SearchInput/index.js +232 -164
- package/dist/components/SelectInput/SelectInputProvider.d.ts +1 -1
- package/dist/components/SelectInput/SelectInputProvider.js +91 -55
- package/dist/components/SelectInput/components/Dropdown.d.ts +1 -1
- package/dist/components/SelectInput/components/Dropdown.js +442 -101
- package/dist/components/SelectInput/components/DropdownOption.d.ts +1 -1
- package/dist/components/SelectInput/components/DropdownOption.js +176 -27
- package/dist/components/SelectInput/components/SearchBarDropdown.d.ts +1 -1
- package/dist/components/SelectInput/components/SearchBarDropdown.js +40 -14
- package/dist/components/SelectInput/components/SelectBar.d.ts +1 -1
- package/dist/components/SelectInput/components/SelectBar.js +252 -97
- package/dist/components/SelectInput/index.d.ts +1 -1
- package/dist/components/SelectInput/index.js +102 -10
- package/dist/components/SelectableCard/index.js +200 -114
- package/dist/components/SelectableCardGroup/index.d.ts +2 -2
- package/dist/components/SelectableCardGroup/index.js +67 -25
- package/dist/components/SelectableCardOptionGroup/Provider.js +3 -1
- package/dist/components/SelectableCardOptionGroup/components/Image.d.ts +1 -1
- package/dist/components/SelectableCardOptionGroup/components/Image.js +12 -8
- package/dist/components/SelectableCardOptionGroup/components/Option.d.ts +1 -1
- package/dist/components/SelectableCardOptionGroup/components/Option.js +96 -19
- package/dist/components/SelectableCardOptionGroup/index.d.ts +2 -2
- package/dist/components/SelectableCardOptionGroup/index.js +53 -17
- package/dist/components/Separator/index.d.ts +1 -1
- package/dist/components/Separator/index.js +43 -26
- package/dist/components/Skeleton/Block.d.ts +1 -1
- package/dist/components/Skeleton/Block.js +2 -6
- package/dist/components/Skeleton/Blocks.d.ts +1 -1
- package/dist/components/Skeleton/Blocks.js +14 -9
- package/dist/components/Skeleton/BoxWithIcon.d.ts +1 -1
- package/dist/components/Skeleton/BoxWithIcon.js +14 -9
- package/dist/components/Skeleton/Donut.d.ts +1 -1
- package/dist/components/Skeleton/Donut.js +10 -2
- package/dist/components/Skeleton/IconSkeleton.d.ts +1 -1
- package/dist/components/Skeleton/IconSkeleton.js +1 -1
- package/dist/components/Skeleton/Line.d.ts +1 -1
- package/dist/components/Skeleton/Line.js +10 -4
- package/dist/components/Skeleton/List.d.ts +1 -1
- package/dist/components/Skeleton/List.js +3 -9
- package/dist/components/Skeleton/Slider.d.ts +1 -1
- package/dist/components/Skeleton/Slider.js +11 -8
- package/dist/components/Skeleton/Square.d.ts +1 -1
- package/dist/components/Skeleton/Square.js +1 -1
- package/dist/components/Skeleton/index.d.ts +9 -9
- package/dist/components/Skeleton/index.js +16 -5
- package/dist/components/Slider/components/DoubleSlider.d.ts +1 -1
- package/dist/components/Slider/components/DoubleSlider.js +191 -88
- package/dist/components/Slider/components/Options.d.ts +1 -1
- package/dist/components/Slider/components/Options.js +44 -28
- package/dist/components/Slider/components/SingleSlider.d.ts +1 -1
- package/dist/components/Slider/components/SingleSlider.js +133 -53
- package/dist/components/Slider/index.d.ts +1 -1
- package/dist/components/Slider/index.js +82 -12
- package/dist/components/Snippet/index.d.ts +1 -1
- package/dist/components/Snippet/index.js +103 -19
- package/dist/components/Stack/index.d.ts +1 -1
- package/dist/components/Stack/index.js +20 -24
- package/dist/components/Stack/styles.css.js +2 -2
- package/dist/components/Status/index.d.ts +1 -1
- package/dist/components/Status/index.js +13 -11
- package/dist/components/StepList/index.d.ts +2 -2
- package/dist/components/StepList/index.js +31 -10
- package/dist/components/Stepper/Step.d.ts +1 -1
- package/dist/components/Stepper/Step.js +65 -30
- package/dist/components/Stepper/StepperProvider.d.ts +1 -1
- package/dist/components/Stepper/StepperProvider.js +13 -10
- package/dist/components/Stepper/index.d.ts +2 -2
- package/dist/components/Stepper/index.js +46 -26
- package/dist/components/SwitchButton/FocusOverlay.d.ts +1 -1
- package/dist/components/SwitchButton/FocusOverlay.js +11 -5
- package/dist/components/SwitchButton/Option.d.ts +1 -1
- package/dist/components/SwitchButton/Option.js +20 -2
- package/dist/components/SwitchButton/index.d.ts +2 -2
- package/dist/components/SwitchButton/index.js +95 -48
- package/dist/components/Table/Body.d.ts +1 -1
- package/dist/components/Table/Body.js +2 -4
- package/dist/components/Table/Cell.d.ts +1 -1
- package/dist/components/Table/Cell.js +20 -17
- package/dist/components/Table/Header.d.ts +1 -1
- package/dist/components/Table/Header.js +2 -4
- package/dist/components/Table/HeaderCell.d.ts +1 -1
- package/dist/components/Table/HeaderCell.js +46 -22
- package/dist/components/Table/HeaderRow.d.ts +1 -1
- package/dist/components/Table/HeaderRow.js +21 -12
- package/dist/components/Table/Row.d.ts +1 -1
- package/dist/components/Table/Row.js +70 -14
- package/dist/components/Table/SelectBar.d.ts +1 -1
- package/dist/components/Table/SelectBar.js +20 -10
- package/dist/components/Table/SkeletonRows.d.ts +1 -1
- package/dist/components/Table/SkeletonRows.js +17 -16
- package/dist/components/Table/TableContext.d.ts +1 -1
- package/dist/components/Table/TableContext.js +22 -13
- package/dist/components/Table/index.d.ts +6 -6
- package/dist/components/Table/index.js +64 -23
- package/dist/components/Tabs/Tab.js +79 -41
- package/dist/components/Tabs/TabMenu.js +39 -23
- package/dist/components/Tabs/TabMenuItem.d.ts +1 -1
- package/dist/components/Tabs/TabMenuItem.js +20 -11
- package/dist/components/Tabs/TabsContext.js +3 -1
- package/dist/components/Tabs/index.d.ts +3 -3
- package/dist/components/Tabs/index.js +34 -14
- package/dist/components/Tag/index.d.ts +1 -1
- package/dist/components/Tag/index.js +45 -12
- package/dist/components/TagInput/index.d.ts +1 -1
- package/dist/components/TagInput/index.js +131 -52
- package/dist/components/TagInput/styles.css.d.ts +3 -0
- package/dist/components/TagList/index.d.ts +1 -1
- package/dist/components/TagList/index.js +132 -59
- package/dist/components/Text/index.d.ts +1 -1
- package/dist/components/Text/index.js +21 -17
- package/dist/components/TextArea/index.js +178 -103
- package/dist/components/TextInput/index.d.ts +1 -1
- package/dist/components/TextInput/index.js +286 -106
- package/dist/components/TimeInput/constants.js +1 -5
- package/dist/components/TimeInput/index.d.ts +1 -1
- package/dist/components/TimeInput/index.js +207 -118
- package/dist/components/Toaster/Toaster.js +1 -1
- package/dist/components/Toaster/ToasterContainer.d.ts +1 -1
- package/dist/components/Toaster/ToasterContainer.js +21 -2
- package/dist/components/Toaster/components/Button.d.ts +1 -1
- package/dist/components/Toaster/components/CloseButton.d.ts +1 -1
- package/dist/components/Toaster/components/CloseButton.js +12 -2
- package/dist/components/Toaster/components/Content.d.ts +1 -1
- package/dist/components/Toaster/components/Content.js +2 -4
- package/dist/components/Toaster/components/Link.d.ts +1 -1
- package/dist/components/Toaster/index.d.ts +2 -2
- package/dist/components/Toggle/index.js +101 -40
- package/dist/components/ToggleGroup/index.d.ts +3 -3
- package/dist/components/ToggleGroup/index.js +61 -22
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/components/Tooltip/index.js +42 -19
- package/dist/components/TreeMapChart/Tooltip.d.ts +1 -1
- package/dist/components/TreeMapChart/Tooltip.js +1 -1
- package/dist/components/TreeMapChart/index.d.ts +1 -1
- package/dist/components/TreeMapChart/index.js +33 -27
- package/dist/components/UnitInput/index.d.ts +1 -1
- package/dist/components/UnitInput/index.js +110 -29
- package/dist/components/VerificationCode/index.d.ts +1 -1
- package/dist/components/VerificationCode/index.js +80 -21
- package/dist/helpers/legend.js +4 -4
- package/dist/helpers/treeMap.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -4
- package/dist/theme/ThemeProvider.d.ts +1 -1
- package/dist/theme/ThemeProvider.js +4 -2
- package/dist/theme/index.js +1 -8
- package/dist/ui.css +1 -1
- package/dist/utils/ids.js +1 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/responsive/index.d.ts +0 -1
- package/dist/utils/responsive/style.css.d.ts +3 -0
- package/package.json +5 -10
- package/dist/utils/responsive/Breakpoint.d.ts +0 -9
- package/dist/utils/responsive/Breakpoint.js +0 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs, jsx } from "
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { Stack } from "../Stack/index.js";
|
|
5
5
|
import { Text } from "../Text/index.js";
|
|
@@ -26,11 +26,46 @@ const LabelRequiredOrNot = ({
|
|
|
26
26
|
}, [disabled, htmlFor]);
|
|
27
27
|
if (required) {
|
|
28
28
|
return /* @__PURE__ */ jsxs(Stack, { alignItems: "start", direction: "row", gap: "0.5", style, children: [
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
Text,
|
|
31
|
+
{
|
|
32
|
+
as: as === "label" ? "label" : "legend",
|
|
33
|
+
className: textPointer[textPointerValue],
|
|
34
|
+
disabled,
|
|
35
|
+
htmlFor,
|
|
36
|
+
id,
|
|
37
|
+
sentiment,
|
|
38
|
+
variant: size === "large" ? "bodyStrong" : "bodySmallStrong",
|
|
39
|
+
children
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Text,
|
|
44
|
+
{
|
|
45
|
+
"aria-label": "required",
|
|
46
|
+
as: "span",
|
|
47
|
+
disabled,
|
|
48
|
+
sentiment: "danger",
|
|
49
|
+
variant: size === "large" ? "bodyStrong" : "bodySmallStrong",
|
|
50
|
+
children: "*"
|
|
51
|
+
}
|
|
52
|
+
)
|
|
31
53
|
] });
|
|
32
54
|
}
|
|
33
|
-
return /* @__PURE__ */ jsx(
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
Text,
|
|
57
|
+
{
|
|
58
|
+
as: as === "label" ? "label" : "legend",
|
|
59
|
+
className: textPointer[textPointerValue],
|
|
60
|
+
disabled,
|
|
61
|
+
htmlFor,
|
|
62
|
+
id,
|
|
63
|
+
sentiment,
|
|
64
|
+
style,
|
|
65
|
+
variant: size === "large" ? "bodyStrong" : "bodySmallStrong",
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
);
|
|
34
69
|
};
|
|
35
70
|
const Label = ({
|
|
36
71
|
as = "label",
|
|
@@ -44,9 +79,35 @@ const Label = ({
|
|
|
44
79
|
disabled,
|
|
45
80
|
style
|
|
46
81
|
}) => labelDescription ? /* @__PURE__ */ jsxs(Stack, { alignItems: "center", direction: "row", gap: "1", children: [
|
|
47
|
-
/* @__PURE__ */ jsx(
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
LabelRequiredOrNot,
|
|
84
|
+
{
|
|
85
|
+
as,
|
|
86
|
+
disabled,
|
|
87
|
+
htmlFor,
|
|
88
|
+
id,
|
|
89
|
+
required,
|
|
90
|
+
sentiment,
|
|
91
|
+
size,
|
|
92
|
+
style,
|
|
93
|
+
children
|
|
94
|
+
}
|
|
95
|
+
),
|
|
48
96
|
typeof labelDescription === "string" ? /* @__PURE__ */ jsx(Text, { as: "span", variant: "bodySmall", children: labelDescription }) : labelDescription
|
|
49
|
-
] }) : /* @__PURE__ */ jsx(
|
|
97
|
+
] }) : /* @__PURE__ */ jsx(
|
|
98
|
+
LabelRequiredOrNot,
|
|
99
|
+
{
|
|
100
|
+
as,
|
|
101
|
+
disabled,
|
|
102
|
+
htmlFor,
|
|
103
|
+
id,
|
|
104
|
+
required,
|
|
105
|
+
sentiment,
|
|
106
|
+
size,
|
|
107
|
+
style,
|
|
108
|
+
children
|
|
109
|
+
}
|
|
110
|
+
);
|
|
50
111
|
export {
|
|
51
112
|
Label
|
|
52
113
|
};
|
|
@@ -9,5 +9,5 @@ type CustomLegendProps = {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
'data-testid'?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const CustomLegend: ({ axisTransformer, data, selected, setSelected, className, "data-testid": dataTestId, }: CustomLegendProps) => import("
|
|
12
|
+
export declare const CustomLegend: ({ axisTransformer, data, selected, setSelected, className, "data-testid": dataTestId, }: CustomLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs, jsx } from "
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { theme } from "@ultraviolet/themes";
|
|
4
4
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
5
5
|
import { getLegendColor } from "../../helpers/legend.js";
|
|
@@ -7,10 +7,7 @@ import { Checkbox } from "../Checkbox/index.js";
|
|
|
7
7
|
import { Text } from "../Text/index.js";
|
|
8
8
|
import { getSelected, getMin, getMax, getAverage, getCurrent } from "./helpers.js";
|
|
9
9
|
import { container, lineChartHead, longContainer, lineChartBody, lineChartRow, cellValueContainer, lineChartLegend, backgroundColorLegend, textLegend } from "./styles.css.js";
|
|
10
|
-
const Cell = ({
|
|
11
|
-
value,
|
|
12
|
-
variant
|
|
13
|
-
}) => /* @__PURE__ */ jsx(Text, { as: "span", className: textLegend, sentiment: "neutral", variant, children: value });
|
|
10
|
+
const Cell = ({ value, variant }) => /* @__PURE__ */ jsx(Text, { as: "span", className: textLegend, sentiment: "neutral", variant, children: value });
|
|
14
11
|
const noop = (value) => value.toString();
|
|
15
12
|
const CustomLegend = ({
|
|
16
13
|
axisTransformer = noop,
|
|
@@ -19,46 +16,73 @@ const CustomLegend = ({
|
|
|
19
16
|
setSelected,
|
|
20
17
|
className,
|
|
21
18
|
"data-testid": dataTestId
|
|
22
|
-
}) => /* @__PURE__ */ jsxs(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"div",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
19
|
+
}) => /* @__PURE__ */ jsxs(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
className: `${className ? `${className} ` : ""}${container}`,
|
|
23
|
+
"data-testid": dataTestId,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ jsxs("div", { className: lineChartHead, children: [
|
|
26
|
+
/* @__PURE__ */ jsx("div", { className: longContainer, children: "Legend" }),
|
|
27
|
+
/* @__PURE__ */ jsx(Cell, { value: "Minimum", variant: "body" }),
|
|
28
|
+
/* @__PURE__ */ jsx(Cell, { value: "Maximum", variant: "body" }),
|
|
29
|
+
/* @__PURE__ */ jsx(Cell, { value: "Average", variant: "body" }),
|
|
30
|
+
/* @__PURE__ */ jsx(Cell, { value: "Current", variant: "body" })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: lineChartBody, children: data?.map((row, index) => {
|
|
33
|
+
const values = row.data.map((val) => val.y);
|
|
34
|
+
const labelIndexed = `${row.id}${index}`;
|
|
35
|
+
const id = row.id.toString();
|
|
36
|
+
return /* @__PURE__ */ jsxs(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
className: lineChartRow,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx("div", { className: longContainer, children: /* @__PURE__ */ jsx(
|
|
42
|
+
Checkbox,
|
|
43
|
+
{
|
|
44
|
+
checked: selected.includes(labelIndexed),
|
|
45
|
+
name: id,
|
|
46
|
+
onChange: () => setSelected([...getSelected(id, index, selected)]),
|
|
47
|
+
children: /* @__PURE__ */ jsxs("div", { className: cellValueContainer, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Text, { as: "span", sentiment: "neutral", variant: "bodySmall", children: row?.["label"] }),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: lineChartLegend,
|
|
53
|
+
"data-testid": `label-${id}`,
|
|
54
|
+
style: assignInlineVars({
|
|
55
|
+
[backgroundColorLegend]: getLegendColor(theme)[index]
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] })
|
|
60
|
+
}
|
|
61
|
+
) }),
|
|
62
|
+
/* @__PURE__ */ jsx(Cell, { value: axisTransformer(getMin(values)), variant: "bodySmall" }),
|
|
63
|
+
/* @__PURE__ */ jsx(Cell, { value: axisTransformer(getMax(values)), variant: "bodySmall" }),
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
Cell,
|
|
66
|
+
{
|
|
67
|
+
value: axisTransformer(getAverage(values)),
|
|
68
|
+
variant: "bodySmall"
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
Cell,
|
|
73
|
+
{
|
|
74
|
+
value: axisTransformer(getCurrent(values)),
|
|
75
|
+
variant: "bodySmall"
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
labelIndexed
|
|
81
|
+
);
|
|
82
|
+
}) })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
62
86
|
export {
|
|
63
87
|
CustomLegend
|
|
64
88
|
};
|
|
@@ -2,5 +2,5 @@ import type { Point } from '@nivo/line';
|
|
|
2
2
|
type LineChartTooltipProps = {
|
|
3
3
|
point: Point;
|
|
4
4
|
};
|
|
5
|
-
export declare const LineChartTooltip: ({ point }: LineChartTooltipProps) => import("
|
|
5
|
+
export declare const LineChartTooltip: ({ point }: LineChartTooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs, jsx } from "
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
4
4
|
import { Text } from "../Text/index.js";
|
|
5
5
|
import { lineTooltipContainer, lineColorSquare, colorLine } from "./styles.css.js";
|
|
6
|
-
const LineChartTooltip = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const LineChartTooltip = ({ point }) => /* @__PURE__ */ jsxs("div", { className: lineTooltipContainer, children: [
|
|
7
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
8
|
+
"span",
|
|
9
|
+
{
|
|
10
|
+
className: lineColorSquare,
|
|
11
|
+
style: assignInlineVars({
|
|
12
|
+
[colorLine]: point.serieColor
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
) }),
|
|
12
16
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
13
|
-
/* @__PURE__ */ jsx(
|
|
14
|
-
|
|
17
|
+
/* @__PURE__ */ jsx(
|
|
18
|
+
Text,
|
|
19
|
+
{
|
|
20
|
+
as: "div",
|
|
21
|
+
prominence: "stronger",
|
|
22
|
+
sentiment: "neutral",
|
|
23
|
+
variant: "bodyStronger",
|
|
24
|
+
children: point.data.yFormatted
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
Text,
|
|
29
|
+
{
|
|
30
|
+
as: "div",
|
|
31
|
+
prominence: "stronger",
|
|
32
|
+
sentiment: "neutral",
|
|
33
|
+
variant: "bodySmall",
|
|
34
|
+
children: point.data.xFormatted
|
|
35
|
+
}
|
|
36
|
+
)
|
|
15
37
|
] })
|
|
16
38
|
] });
|
|
17
39
|
export {
|
|
@@ -12,30 +12,31 @@ const parse = (data) => {
|
|
|
12
12
|
};
|
|
13
13
|
const getMin = (values = []) => values.length > 0 ? Math.min(...values.map((data) => parse(data))) : 0;
|
|
14
14
|
const getMax = (values = []) => values.length > 0 ? Math.max(...values.map((data) => parse(data))) : 0;
|
|
15
|
-
const getAverage = (values = []) => values.length > 0 ? Math.round(
|
|
15
|
+
const getAverage = (values = []) => values.length > 0 ? Math.round(
|
|
16
|
+
values.reduce((sum, curr) => sum + parse(curr), 0) / values.length * 100
|
|
17
|
+
) / 100 : 0;
|
|
16
18
|
const getMaxChartValue = (preppedData) => {
|
|
17
19
|
if (!preppedData?.length) {
|
|
18
20
|
return 0;
|
|
19
21
|
}
|
|
20
|
-
const maximum = Math.max(
|
|
21
|
-
data
|
|
22
|
-
|
|
23
|
-
y
|
|
24
|
-
}) => y || 0))));
|
|
22
|
+
const maximum = Math.max(
|
|
23
|
+
...preppedData.map(({ data }) => getMax(data.map(({ y }) => y || 0)))
|
|
24
|
+
);
|
|
25
25
|
return Math.ceil(maximum + maximum * 0.1);
|
|
26
26
|
};
|
|
27
27
|
const getMinChartValue = (preppedData) => {
|
|
28
28
|
if (!preppedData?.length) {
|
|
29
29
|
return 0;
|
|
30
30
|
}
|
|
31
|
-
const minimum = Math.min(
|
|
32
|
-
data
|
|
33
|
-
|
|
34
|
-
y
|
|
35
|
-
}) => y || 0))));
|
|
31
|
+
const minimum = Math.min(
|
|
32
|
+
...preppedData.map(({ data }) => getMin(data.map(({ y }) => y || 0)))
|
|
33
|
+
);
|
|
36
34
|
return Math.floor(minimum - minimum * 0.1);
|
|
37
35
|
};
|
|
38
|
-
const getCurrent = (values = []) =>
|
|
36
|
+
const getCurrent = (values = []) => {
|
|
37
|
+
const val = values.at(-1);
|
|
38
|
+
return val ? val : 0;
|
|
39
|
+
};
|
|
39
40
|
const getSelected = (label, index, selected = []) => {
|
|
40
41
|
const labelIndexed = label + index.toString();
|
|
41
42
|
const found = selected.indexOf(labelIndexed);
|
|
@@ -22,5 +22,5 @@ type LineChartProps = {
|
|
|
22
22
|
* See https://nivo.rocks/line/ for more information.
|
|
23
23
|
* @experimental This component is experimental and may be subject to breaking changes in the future.
|
|
24
24
|
*/
|
|
25
|
-
export declare const LineChart: ({ height, margin, xScale, yScale, data, withLegend, axisFormatters, pointFormatters, tickValues, chartProps, style, "data-testid": dataTestId, }: LineChartProps) => import("
|
|
25
|
+
export declare const LineChart: ({ height, margin, xScale, yScale, data, withLegend, axisFormatters, pointFormatters, tickValues, chartProps, style, "data-testid": dataTestId, }: LineChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
26
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs, Fragment, jsx } from "
|
|
2
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { ResponsiveLine } from "@nivo/line";
|
|
4
4
|
import { useTheme } from "@ultraviolet/themes";
|
|
5
5
|
import { useState, useEffect } from "react";
|
|
@@ -8,12 +8,7 @@ import { getNivoTheme } from "../../helpers/nivoTheme.js";
|
|
|
8
8
|
import { CustomLegend } from "./CustomLegend.js";
|
|
9
9
|
import { getMinChartValue, getMaxChartValue } from "./helpers.js";
|
|
10
10
|
import { LineChartTooltip } from "./Tooltip.js";
|
|
11
|
-
const DEFAULT_MARGIN = {
|
|
12
|
-
bottom: 50,
|
|
13
|
-
left: 60,
|
|
14
|
-
right: 25,
|
|
15
|
-
top: 50
|
|
16
|
-
};
|
|
11
|
+
const DEFAULT_MARGIN = { bottom: 50, left: 60, right: 25, top: 50 };
|
|
17
12
|
const DEFAULT_XSCALE = {
|
|
18
13
|
format: "%Y-%m-%dT%H:%M:%S%Z",
|
|
19
14
|
// 2021-08-30T02:56:07Z
|
|
@@ -21,9 +16,7 @@ const DEFAULT_XSCALE = {
|
|
|
21
16
|
type: "time",
|
|
22
17
|
useUTC: false
|
|
23
18
|
};
|
|
24
|
-
const DEFAULT_YSCALE = {
|
|
25
|
-
type: "linear"
|
|
26
|
-
};
|
|
19
|
+
const DEFAULT_YSCALE = { type: "linear" };
|
|
27
20
|
const DEFAULT_CHARTPROPS = {};
|
|
28
21
|
const LineChart = ({
|
|
29
22
|
height = "537px",
|
|
@@ -48,43 +41,66 @@ const LineChart = ({
|
|
|
48
41
|
label: d?.["label"]
|
|
49
42
|
}))
|
|
50
43
|
};
|
|
51
|
-
const [selected, setSelected] = useState(
|
|
52
|
-
id
|
|
53
|
-
|
|
54
|
-
const finalData = dataset.datasets?.filter(
|
|
55
|
-
id
|
|
56
|
-
|
|
44
|
+
const [selected, setSelected] = useState(
|
|
45
|
+
dataset.datasets?.map(({ id }, index) => `${id}${index}`)
|
|
46
|
+
);
|
|
47
|
+
const finalData = dataset.datasets?.filter(
|
|
48
|
+
({ id }, index) => selected ? selected.includes(`${id}${index}`) : false
|
|
49
|
+
);
|
|
57
50
|
useEffect(() => {
|
|
58
51
|
if (selected !== void 0) {
|
|
59
52
|
return;
|
|
60
53
|
}
|
|
61
|
-
setSelected(dataset.datasets?.map(({
|
|
62
|
-
id
|
|
63
|
-
}, index) => `${id}${index}`));
|
|
54
|
+
setSelected(dataset.datasets?.map(({ id }, index) => `${id}${index}`));
|
|
64
55
|
}, [dataset.datasets, selected]);
|
|
65
56
|
const localColors = getLegendColor(theme);
|
|
66
57
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
-
/* @__PURE__ */ jsx("div", { style: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
/* @__PURE__ */ jsx("div", { style: { height, ...style }, children: /* @__PURE__ */ jsx(
|
|
59
|
+
ResponsiveLine,
|
|
60
|
+
{
|
|
61
|
+
axisBottom: {
|
|
62
|
+
format: axisFormatters?.bottom,
|
|
63
|
+
tickPadding: 5,
|
|
64
|
+
tickRotation: 0,
|
|
65
|
+
tickSize: 5,
|
|
66
|
+
tickValues: tickValues?.bottom
|
|
67
|
+
},
|
|
68
|
+
axisLeft: {
|
|
69
|
+
format: axisFormatters?.left,
|
|
70
|
+
tickPadding: 5,
|
|
71
|
+
tickRotation: 0,
|
|
72
|
+
tickSize: 5,
|
|
73
|
+
tickValues: tickValues?.left
|
|
74
|
+
},
|
|
75
|
+
colors: localColors,
|
|
76
|
+
curve: "monotoneX",
|
|
77
|
+
data: finalData ?? [],
|
|
78
|
+
"data-testid": dataTestId,
|
|
79
|
+
margin,
|
|
80
|
+
pointSize: 10,
|
|
81
|
+
theme: getNivoTheme(theme),
|
|
82
|
+
tooltip: LineChartTooltip,
|
|
83
|
+
useMesh: true,
|
|
84
|
+
xFormat: pointFormatters?.x,
|
|
85
|
+
xScale,
|
|
86
|
+
yFormat: pointFormatters?.y,
|
|
87
|
+
yScale: {
|
|
88
|
+
max: getMaxChartValue(finalData),
|
|
89
|
+
min: getMinChartValue(finalData),
|
|
90
|
+
...yScale
|
|
91
|
+
},
|
|
92
|
+
...chartProps
|
|
93
|
+
}
|
|
94
|
+
) }),
|
|
95
|
+
withLegend && /* @__PURE__ */ jsx(
|
|
96
|
+
CustomLegend,
|
|
97
|
+
{
|
|
98
|
+
axisTransformer: axisFormatters?.left,
|
|
99
|
+
data: dataset.datasets,
|
|
100
|
+
selected: selected ?? [],
|
|
101
|
+
setSelected
|
|
102
|
+
}
|
|
103
|
+
)
|
|
88
104
|
] });
|
|
89
105
|
};
|
|
90
106
|
export {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ArrowLeftIcon, OpenInNewIcon, ArrowRightIcon } from "@ultraviolet/icons";
|
|
4
4
|
import { forwardRef, useState, useRef, useMemo, useEffect } from "react";
|
|
5
5
|
import recursivelyGetChildrenString from "../../helpers/recursivelyGetChildrenString.js";
|
|
@@ -7,63 +7,80 @@ import { Tooltip } from "../Tooltip/index.js";
|
|
|
7
7
|
import { link, defaultLink, iconLeftLink, containerIconLink, iconRightLink } from "./styles.css.js";
|
|
8
8
|
const ICON_SIZE = "small";
|
|
9
9
|
const BLANK_TARGET_ICON_SIZE = "small";
|
|
10
|
-
const Link = forwardRef(
|
|
11
|
-
|
|
12
|
-
href,
|
|
13
|
-
target,
|
|
14
|
-
download,
|
|
15
|
-
sentiment = "info",
|
|
16
|
-
prominence,
|
|
17
|
-
size = "large",
|
|
18
|
-
iconPosition,
|
|
19
|
-
rel,
|
|
20
|
-
className,
|
|
21
|
-
onClick,
|
|
22
|
-
"aria-label": ariaLabel,
|
|
23
|
-
"aria-current": ariaCurrent,
|
|
24
|
-
"aria-keyshortcuts": ariaKeyshortcuts,
|
|
25
|
-
oneLine = false,
|
|
26
|
-
"data-testid": dataTestId,
|
|
27
|
-
variant = "standalone",
|
|
28
|
-
style
|
|
29
|
-
}, ref) => {
|
|
30
|
-
const isBlank = target === "_blank";
|
|
31
|
-
const computedRel = rel || (isBlank ? "noopener noreferrer" : void 0);
|
|
32
|
-
const [isTruncated, setIsTruncated] = useState(false);
|
|
33
|
-
const elementRef = useRef(null);
|
|
34
|
-
const usedRef = ref ?? elementRef;
|
|
35
|
-
const finalStringChildren = recursivelyGetChildrenString(children);
|
|
36
|
-
const textVariant = useMemo(() => {
|
|
37
|
-
if (size === "xsmall") {
|
|
38
|
-
return "captionStrong";
|
|
39
|
-
}
|
|
40
|
-
if (size === "small") {
|
|
41
|
-
return "bodySmallStrong";
|
|
42
|
-
}
|
|
43
|
-
return "bodyStrong";
|
|
44
|
-
}, [size]);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (oneLine && usedRef?.current) {
|
|
47
|
-
const {
|
|
48
|
-
offsetWidth,
|
|
49
|
-
scrollWidth
|
|
50
|
-
} = usedRef.current;
|
|
51
|
-
setIsTruncated(offsetWidth < scrollWidth);
|
|
52
|
-
}
|
|
53
|
-
}, [oneLine, ref, usedRef]);
|
|
54
|
-
return /* @__PURE__ */ jsx(Tooltip, { text: oneLine && isTruncated ? finalStringChildren : "", children: /* @__PURE__ */ jsxs("a", { "aria-current": ariaCurrent, "aria-keyshortcuts": ariaKeyshortcuts, "aria-label": ariaLabel, className: `${className ? `${className} ` : ""}${link({
|
|
55
|
-
oneLine,
|
|
56
|
-
prominence,
|
|
57
|
-
sentiment,
|
|
58
|
-
type: variant,
|
|
59
|
-
variant: textVariant
|
|
60
|
-
})} ${defaultLink}`, "data-testid": dataTestId, "data-variant": variant, download, href, onClick, ref: usedRef, rel: computedRel, style, target, children: [
|
|
61
|
-
!isBlank && iconPosition === "left" ? /* @__PURE__ */ jsx(ArrowLeftIcon, { className: iconLeftLink, size: ICON_SIZE }) : null,
|
|
10
|
+
const Link = forwardRef(
|
|
11
|
+
({
|
|
62
12
|
children,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
13
|
+
href,
|
|
14
|
+
target,
|
|
15
|
+
download,
|
|
16
|
+
sentiment = "info",
|
|
17
|
+
prominence,
|
|
18
|
+
size = "large",
|
|
19
|
+
iconPosition,
|
|
20
|
+
rel,
|
|
21
|
+
className,
|
|
22
|
+
onClick,
|
|
23
|
+
"aria-label": ariaLabel,
|
|
24
|
+
"aria-current": ariaCurrent,
|
|
25
|
+
"aria-keyshortcuts": ariaKeyshortcuts,
|
|
26
|
+
oneLine = false,
|
|
27
|
+
"data-testid": dataTestId,
|
|
28
|
+
variant = "standalone",
|
|
29
|
+
style
|
|
30
|
+
}, ref) => {
|
|
31
|
+
const isBlank = target === "_blank";
|
|
32
|
+
const computedRel = rel || (isBlank ? "noopener noreferrer" : void 0);
|
|
33
|
+
const [isTruncated, setIsTruncated] = useState(false);
|
|
34
|
+
const elementRef = useRef(null);
|
|
35
|
+
const usedRef = ref ?? elementRef;
|
|
36
|
+
const finalStringChildren = recursivelyGetChildrenString(children);
|
|
37
|
+
const textVariant = useMemo(() => {
|
|
38
|
+
if (size === "xsmall") {
|
|
39
|
+
return "captionStrong";
|
|
40
|
+
}
|
|
41
|
+
if (size === "small") {
|
|
42
|
+
return "bodySmallStrong";
|
|
43
|
+
}
|
|
44
|
+
return "bodyStrong";
|
|
45
|
+
}, [size]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (oneLine && usedRef?.current) {
|
|
48
|
+
const { offsetWidth, scrollWidth } = usedRef.current;
|
|
49
|
+
setIsTruncated(offsetWidth < scrollWidth);
|
|
50
|
+
}
|
|
51
|
+
}, [oneLine, ref, usedRef]);
|
|
52
|
+
return /* @__PURE__ */ jsx(Tooltip, { text: oneLine && isTruncated ? finalStringChildren : "", children: /* @__PURE__ */ jsxs(
|
|
53
|
+
"a",
|
|
54
|
+
{
|
|
55
|
+
"aria-current": ariaCurrent,
|
|
56
|
+
"aria-keyshortcuts": ariaKeyshortcuts,
|
|
57
|
+
"aria-label": ariaLabel,
|
|
58
|
+
className: `${className ? `${className} ` : ""}${link({ oneLine, prominence, sentiment, type: variant, variant: textVariant })} ${defaultLink}`,
|
|
59
|
+
"data-testid": dataTestId,
|
|
60
|
+
"data-variant": variant,
|
|
61
|
+
download,
|
|
62
|
+
href,
|
|
63
|
+
onClick,
|
|
64
|
+
ref: usedRef,
|
|
65
|
+
rel: computedRel,
|
|
66
|
+
style,
|
|
67
|
+
target,
|
|
68
|
+
children: [
|
|
69
|
+
!isBlank && iconPosition === "left" ? /* @__PURE__ */ jsx(ArrowLeftIcon, { className: iconLeftLink, size: ICON_SIZE }) : null,
|
|
70
|
+
children,
|
|
71
|
+
isBlank ? /* @__PURE__ */ jsx("span", { className: containerIconLink, children: /* @__PURE__ */ jsx(
|
|
72
|
+
OpenInNewIcon,
|
|
73
|
+
{
|
|
74
|
+
className: iconRightLink,
|
|
75
|
+
size: BLANK_TARGET_ICON_SIZE
|
|
76
|
+
}
|
|
77
|
+
) }) : null,
|
|
78
|
+
!isBlank && iconPosition === "right" ? /* @__PURE__ */ jsx(ArrowRightIcon, { className: iconRightLink, size: ICON_SIZE }) : null
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
) });
|
|
82
|
+
}
|
|
83
|
+
);
|
|
67
84
|
export {
|
|
68
85
|
Link
|
|
69
86
|
};
|