@spaced-out/ui-design-system 0.3.38 → 0.3.39
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/.cspell/custom-words.txt +4 -0
- package/.github/workflows/publish_to_npm.yml +32 -4
- package/CHANGELOG.md +21 -0
- package/dts-generator/.editorconfig +10 -0
- package/dts-generator/.gitattributes +4 -0
- package/dts-generator/README.md +63 -0
- package/dts-generator/convert.js +101 -0
- package/dts-generator/package.json +16 -0
- package/gulpfile.js +20 -1
- package/lib/components/Avatar/Avatar.d.ts +264 -0
- package/lib/components/Avatar/index.d.ts +1 -0
- package/lib/components/AvatarGroup/AvatarGroup.d.ts +161 -0
- package/lib/components/AvatarGroup/index.d.ts +1 -0
- package/lib/components/Badge/Badge.d.ts +138 -0
- package/lib/components/Badge/index.d.ts +1 -0
- package/lib/components/Banner/Banner.d.ts +52 -0
- package/lib/components/Banner/index.d.ts +1 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.d.ts +50 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/index.d.ts +1 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +64 -0
- package/lib/components/Breadcrumbs/index.d.ts +2 -0
- package/lib/components/Button/Button.d.ts +288 -0
- package/lib/components/Button/index.d.ts +14 -0
- package/lib/components/ButtonDropdown/ButtonDropdown.d.ts +192 -0
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.d.ts +148 -0
- package/lib/components/ButtonDropdown/index.d.ts +2 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.d.ts +82 -0
- package/lib/components/ButtonTabs/ButtonTab/index.d.ts +1 -0
- package/lib/components/ButtonTabs/ButtonTabDropdown.d.ts +118 -0
- package/lib/components/ButtonTabs/ButtonTabs.d.ts +113 -0
- package/lib/components/ButtonTabs/index.d.ts +2 -0
- package/lib/components/Card/Card.d.ts +163 -0
- package/lib/components/Card/index.d.ts +1 -0
- package/lib/components/Charts/ChartTooltip/index.d.ts +10 -0
- package/lib/components/Charts/ChartWrapper/ChartWrapper.d.ts +184 -0
- package/lib/components/Charts/ChartWrapper/index.d.ts +1 -0
- package/lib/components/Charts/ColumnChart/ColumnChart.d.ts +111 -0
- package/lib/components/Charts/ColumnChart/index.d.ts +1 -0
- package/lib/components/Charts/DonutChart/DonutChart.d.ts +142 -0
- package/lib/components/Charts/DonutChart/index.d.ts +1 -0
- package/lib/components/Charts/FunnelChart/FunnelChart.d.ts +99 -0
- package/lib/components/Charts/FunnelChart/index.d.ts +1 -0
- package/lib/components/Charts/LineChart/LineChart.d.ts +97 -0
- package/lib/components/Charts/LineChart/index.d.ts +1 -0
- package/lib/components/Charts/SpiderChart/SpiderChart.d.ts +95 -0
- package/lib/components/Charts/SpiderChart/index.d.ts +1 -0
- package/lib/components/Charts/index.d.ts +7 -0
- package/lib/components/ChatBubble/ChatBubble.d.ts +203 -0
- package/lib/components/ChatBubble/index.d.ts +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts +165 -0
- package/lib/components/Checkbox/CheckboxGroup.d.ts +113 -0
- package/lib/components/Checkbox/index.d.ts +2 -0
- package/lib/components/Chip/Chip.d.ts +181 -0
- package/lib/components/Chip/index.d.ts +2 -0
- package/lib/components/CircularLoader/CircularLoader.d.ts +56 -0
- package/lib/components/CircularLoader/index.d.ts +1 -0
- package/lib/components/CollapsibleCard/CollapsibleCard.d.ts +134 -0
- package/lib/components/CollapsibleCard/index.d.ts +1 -0
- package/lib/components/Combobox/Combobox.d.ts +292 -0
- package/lib/components/Combobox/helper.d.ts +205 -0
- package/lib/components/Combobox/index.d.ts +1 -0
- package/lib/components/ConditionalWrapper/ConditionalWrapper.d.ts +12 -0
- package/lib/components/ConditionalWrapper/index.d.ts +1 -0
- package/lib/components/DateRangePicker/Calendar.d.ts +119 -0
- package/lib/components/DateRangePicker/DateRangePicker.d.ts +196 -0
- package/lib/components/DateRangePicker/DateRangeWrapper.d.ts +311 -0
- package/lib/components/DateRangePicker/Day.d.ts +70 -0
- package/lib/components/DateRangePicker/index.d.ts +1 -0
- package/lib/components/Dialog/Dialog.d.ts +208 -0
- package/lib/components/Dialog/index.d.ts +1 -0
- package/lib/components/Disclaimer/Disclaimer.d.ts +32 -0
- package/lib/components/Disclaimer/index.d.ts +1 -0
- package/lib/components/Dropdown/Dropdown.d.ts +145 -0
- package/lib/components/Dropdown/SimpleDropdown.d.ts +142 -0
- package/lib/components/Dropdown/index.d.ts +2 -0
- package/lib/components/EmptyState/EmptyImages/CalendarEmptyImage.d.ts +108 -0
- package/lib/components/EmptyState/EmptyImages/ChartEmptyImage.d.ts +194 -0
- package/lib/components/EmptyState/EmptyImages/DataEmptyImage.d.ts +116 -0
- package/lib/components/EmptyState/EmptyImages/FileEmptyImage.d.ts +133 -0
- package/lib/components/EmptyState/EmptyImages/MessageEmptyImage.d.ts +64 -0
- package/lib/components/EmptyState/EmptyImages/UploadEmptyImage.d.ts +67 -0
- package/lib/components/EmptyState/EmptyImages/index.d.ts +6 -0
- package/lib/components/EmptyState/EmptyState.d.ts +82 -0
- package/lib/components/EmptyState/index.d.ts +1 -0
- package/lib/components/ErrorMessage/ErrorImages/ForbiddenImage.d.ts +85 -0
- package/lib/components/ErrorMessage/ErrorImages/NotFoundImage.d.ts +117 -0
- package/lib/components/ErrorMessage/ErrorImages/ServerErrorImage.d.ts +237 -0
- package/lib/components/ErrorMessage/ErrorImages/UnauthorizedImage.d.ts +73 -0
- package/lib/components/ErrorMessage/ErrorImages/index.d.ts +4 -0
- package/lib/components/ErrorMessage/ErrorMessage.d.ts +86 -0
- package/lib/components/ErrorMessage/index.d.ts +1 -0
- package/lib/components/FileUpload/FileBlock/FileBlock.d.ts +137 -0
- package/lib/components/FileUpload/FileBlock/index.d.ts +1 -0
- package/lib/components/FileUpload/FileUpload.d.ts +190 -0
- package/lib/components/FileUpload/index.d.ts +2 -0
- package/lib/components/FocusManager/FocusManager.d.ts +52 -0
- package/lib/components/FocusManager/index.d.ts +1 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.d.ts +137 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/index.d.ts +1 -0
- package/lib/components/FormTitleWrapper/FormTitleWrapper.d.ts +62 -0
- package/lib/components/FormTitleWrapper/index.d.ts +1 -0
- package/lib/components/Grid/Grid.d.ts +104 -0
- package/lib/components/Grid/index.d.ts +1 -0
- package/lib/components/Icon/ClickableIcon.d.ts +101 -0
- package/lib/components/Icon/Icon.d.ts +71 -0
- package/lib/components/Icon/Icon.docs.d.ts +138 -0
- package/lib/components/Icon/SemanticIcon.d.ts +42 -0
- package/lib/components/Icon/index.d.ts +3 -0
- package/lib/components/InContextAlert/InContextAlert.d.ts +210 -0
- package/lib/components/InContextAlert/index.d.ts +1 -0
- package/lib/components/InlineDropdown/InlineDropdown.d.ts +146 -0
- package/lib/components/InlineDropdown/SimpleInlineDropdown.d.ts +145 -0
- package/lib/components/InlineDropdown/index.d.ts +2 -0
- package/lib/components/Input/Input.d.ts +327 -0
- package/lib/components/Input/index.d.ts +1 -0
- package/lib/components/KPIBox/KPIBox.d.ts +89 -0
- package/lib/components/KPIBox/index.d.ts +1 -0
- package/lib/components/LinearLoader/LinearLoader.d.ts +44 -0
- package/lib/components/LinearLoader/index.d.ts +1 -0
- package/lib/components/Link/Link.d.ts +225 -0
- package/lib/components/Link/index.d.ts +1 -0
- package/lib/components/Menu/Menu.d.ts +379 -0
- package/lib/components/Menu/MenuOptionButton.d.ts +199 -0
- package/lib/components/Menu/index.d.ts +2 -0
- package/lib/components/Modal/Modal.d.ts +354 -0
- package/lib/components/Modal/index.d.ts +14 -0
- package/lib/components/Notification/Notification.d.ts +147 -0
- package/lib/components/Notification/index.d.ts +1 -0
- package/lib/components/OptionButton/OptionButton.d.ts +150 -0
- package/lib/components/OptionButton/SimpleOptionButton.d.ts +150 -0
- package/lib/components/OptionButton/index.d.ts +2 -0
- package/lib/components/PageTitle/PageTitle.d.ts +256 -0
- package/lib/components/PageTitle/index.d.ts +1 -0
- package/lib/components/Pagination/Pagination.d.ts +144 -0
- package/lib/components/Pagination/PaginationItem.d.ts +136 -0
- package/lib/components/Pagination/index.d.ts +1 -0
- package/lib/components/Panel/Panel.d.ts +168 -0
- package/lib/components/Panel/index.d.ts +9 -0
- package/lib/components/ProgressDonut/ProgressDonut.d.ts +102 -0
- package/lib/components/ProgressDonut/index.d.ts +1 -0
- package/lib/components/PromptChip/PromptChip.d.ts +167 -0
- package/lib/components/PromptChip/index.d.ts +1 -0
- package/lib/components/PromptInput/PromptInput.d.ts +189 -0
- package/lib/components/PromptInput/index.d.ts +1 -0
- package/lib/components/RadioButton/RadioButton.d.ts +132 -0
- package/lib/components/RadioButton/RadioGroup.d.ts +88 -0
- package/lib/components/RadioButton/index.d.ts +2 -0
- package/lib/components/RadioTile/RadioTile.d.ts +109 -0
- package/lib/components/RadioTile/index.d.ts +1 -0
- package/lib/components/RangeSlider/RangeSlider.d.ts +207 -0
- package/lib/components/RangeSlider/index.d.ts +1 -0
- package/lib/components/Rating/Rating.d.ts +131 -0
- package/lib/components/Rating/index.d.ts +1 -0
- package/lib/components/ScoreBar/ScoreBar.d.ts +122 -0
- package/lib/components/ScoreBar/index.d.ts +1 -0
- package/lib/components/SearchInput/SearchInput.d.ts +79 -0
- package/lib/components/SearchInput/index.d.ts +2 -0
- package/lib/components/Separator/Separator.d.ts +51 -0
- package/lib/components/Separator/index.d.ts +1 -0
- package/lib/components/Shimmer/Shimmer.d.ts +131 -0
- package/lib/components/Shimmer/index.d.ts +1 -0
- package/lib/components/SideMenuLink/SideMenuLink.d.ts +336 -0
- package/lib/components/SideMenuLink/index.d.ts +1 -0
- package/lib/components/StatusIndicator/StatusIndicator.d.ts +60 -0
- package/lib/components/StatusIndicator/index.d.ts +1 -0
- package/lib/components/Stepper/Step/Step.d.ts +119 -0
- package/lib/components/Stepper/Step/StepContent.d.ts +35 -0
- package/lib/components/Stepper/Step/StepLabel.d.ts +35 -0
- package/lib/components/Stepper/Step/index.d.ts +3 -0
- package/lib/components/Stepper/Stepper.d.ts +60 -0
- package/lib/components/Stepper/index.d.ts +2 -0
- package/lib/components/StickyBar/StickyBar.d.ts +55 -0
- package/lib/components/StickyBar/index.d.ts +1 -0
- package/lib/components/SubMenu/SubMenu.d.ts +89 -0
- package/lib/components/SubMenu/SubMenuGroup.d.ts +156 -0
- package/lib/components/SubMenu/SubMenuItem.d.ts +161 -0
- package/lib/components/SubMenu/SubMenuLink.d.ts +81 -0
- package/lib/components/SubMenu/index.d.ts +4 -0
- package/lib/components/Table/Cell.d.ts +107 -0
- package/lib/components/Table/DefaultRow.d.ts +144 -0
- package/lib/components/Table/DefaultTableHeader.d.ts +236 -0
- package/lib/components/Table/StaticTable.d.ts +198 -0
- package/lib/components/Table/Table.d.ts +113 -0
- package/lib/components/Table/Table.docs.d.ts +532 -0
- package/lib/components/Table/TableActionBar.d.ts +48 -0
- package/lib/components/Table/TableBottomBar.d.ts +20 -0
- package/lib/components/Table/TableTopBar.d.ts +20 -0
- package/lib/components/Table/dummyTableData.d.ts +2189 -0
- package/lib/components/Table/hooks.d.ts +98 -0
- package/lib/components/Table/index.d.ts +8 -0
- package/lib/components/Tabs/Tab/Tab.d.ts +146 -0
- package/lib/components/Tabs/Tab/index.d.ts +1 -0
- package/lib/components/Tabs/TabList/TabDropdown.d.ts +100 -0
- package/lib/components/Tabs/TabList/TabList.d.ts +157 -0
- package/lib/components/Tabs/TabList/index.d.ts +1 -0
- package/lib/components/Tabs/index.d.ts +2 -0
- package/lib/components/Text/Text.d.ts +1021 -0
- package/lib/components/Text/index.d.ts +30 -0
- package/lib/components/TextTile/TextTile.d.ts +40 -0
- package/lib/components/TextTile/index.d.ts +1 -0
- package/lib/components/Textarea/Textarea.d.ts +132 -0
- package/lib/components/Textarea/index.d.ts +2 -0
- package/lib/components/Timeline/Timeline.d.ts +40 -0
- package/lib/components/Timeline/TimelineItem/TimelineItem.d.ts +121 -0
- package/lib/components/Timeline/TimelineItem/index.d.ts +1 -0
- package/lib/components/Timeline/index.d.ts +2 -0
- package/lib/components/Toast/Toast.d.ts +248 -0
- package/lib/components/Toast/ToastContainer.d.ts +140 -0
- package/lib/components/Toast/ToastManager.d.ts +58 -0
- package/lib/components/Toast/index.d.ts +10 -0
- package/lib/components/Toggle/Toggle.d.ts +111 -0
- package/lib/components/Toggle/index.d.ts +1 -0
- package/lib/components/TokenListInput/TokenListInput.d.ts +333 -0
- package/lib/components/TokenListInput/TokenValueChips.d.ts +64 -0
- package/lib/components/TokenListInput/index.d.ts +1 -0
- package/lib/components/Tooltip/Tooltip.d.ts +186 -0
- package/lib/components/Tooltip/index.d.ts +1 -0
- package/lib/components/Truncate/Truncate.d.ts +87 -0
- package/lib/components/Truncate/index.d.ts +2 -0
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.d.ts +95 -0
- package/lib/components/TruncatedTextWithTooltip/index.d.ts +1 -0
- package/lib/components/Typeahead/SimpleTypeahead.d.ts +141 -0
- package/lib/components/Typeahead/Typeahead.d.ts +217 -0
- package/lib/components/Typeahead/index.d.ts +2 -0
- package/lib/components/WeekdayPicker/WeekdayPicker.d.ts +242 -0
- package/lib/components/WeekdayPicker/index.d.ts +1 -0
- package/lib/components/index.d.ts +71 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/useArbitraryOptionAddition/index.d.ts +1 -0
- package/lib/hooks/useArbitraryOptionAddition/useArbitraryOptionAddition.d.ts +124 -0
- package/lib/hooks/useCopyToClipboard/index.d.ts +1 -0
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.d.ts +27 -0
- package/lib/hooks/useFileUpload/index.d.ts +1 -0
- package/lib/hooks/useFileUpload/useFileUpload.d.ts +342 -0
- package/lib/hooks/useFilteredOptions/index.d.ts +1 -0
- package/lib/hooks/useFilteredOptions/useFilteredOptions.d.ts +87 -0
- package/lib/hooks/useInputState/index.d.ts +1 -0
- package/lib/hooks/useInputState/useInputState.d.ts +22 -0
- package/lib/hooks/useLockedBody/index.d.ts +1 -0
- package/lib/hooks/useLockedBody/useLockedBody.d.ts +46 -0
- package/lib/hooks/useModal/index.d.ts +1 -0
- package/lib/hooks/useModal/useModal.d.ts +32 -0
- package/lib/hooks/useMountTransition/index.d.ts +24 -0
- package/lib/hooks/usePagination/index.d.ts +1 -0
- package/lib/hooks/usePagination/usePagination.d.ts +140 -0
- package/lib/hooks/useToastPortal/index.d.ts +1 -0
- package/lib/hooks/useToastPortal/useToastPortal.d.ts +31 -0
- package/lib/hooks/useToggle/index.d.ts +1 -0
- package/lib/hooks/useToggle/useToggle.d.ts +11 -0
- package/lib/hooks/useWindowSize/index.d.ts +1 -0
- package/lib/hooks/useWindowSize/useWindowSize.d.ts +28 -0
- package/lib/index.d.ts +5 -0
- package/lib/styles/index.d.ts +267 -0
- package/lib/styles/variables/_border.d.ts +12 -0
- package/lib/styles/variables/_color.d.ts +104 -0
- package/lib/styles/variables/_elevation.d.ts +7 -0
- package/lib/styles/variables/_font.d.ts +30 -0
- package/lib/styles/variables/_motion.d.ts +6 -0
- package/lib/styles/variables/_opacity.d.ts +15 -0
- package/lib/styles/variables/_shadow.d.ts +24 -0
- package/lib/styles/variables/_size.d.ts +57 -0
- package/lib/styles/variables/_space.d.ts +12 -0
- package/lib/types/charts.d.ts +225 -0
- package/lib/types/common.d.ts +10 -0
- package/lib/types/date-range-picker.d.ts +17 -0
- package/lib/types/date-range-picker.js.flow +2 -3
- package/lib/types/index.d.ts +6 -0
- package/lib/types/menu.d.ts +13 -0
- package/lib/types/toast.d.ts +32 -0
- package/lib/types/typography.d.ts +17 -0
- package/lib/utils/array/are-arrays-equal.d.ts +11 -0
- package/lib/utils/array/index.d.ts +1 -0
- package/lib/utils/charts/charts.d.ts +102 -0
- package/lib/utils/charts/columnChart.d.ts +51 -0
- package/lib/utils/charts/donutChart.d.ts +116 -0
- package/lib/utils/charts/funnelChart.d.ts +94 -0
- package/lib/utils/charts/helpers.d.ts +44 -0
- package/lib/utils/charts/index.d.ts +7 -0
- package/lib/utils/charts/lineChart.d.ts +44 -0
- package/lib/utils/charts/spiderChart.d.ts +46 -0
- package/lib/utils/charts/typography.d.ts +42 -0
- package/lib/utils/classify/index.d.ts +27 -0
- package/lib/utils/click-away/click-away.d.ts +194 -0
- package/lib/utils/click-away/index.d.ts +1 -0
- package/lib/utils/date-range-picker/date-range-picker.d.ts +391 -0
- package/lib/utils/date-range-picker/index.d.ts +2 -0
- package/lib/utils/date-range-picker/timezones.d.ts +262 -0
- package/lib/utils/dom/dom.d.ts +245 -0
- package/lib/utils/dom/index.d.ts +1 -0
- package/lib/utils/helpers/helpers.d.ts +48 -0
- package/lib/utils/helpers/index.d.ts +1 -0
- package/lib/utils/index.d.ts +14 -0
- package/lib/utils/makeClassNameComponent/index.d.ts +1 -0
- package/lib/utils/makeClassNameComponent/makeClassNameComponent.d.ts +73 -0
- package/lib/utils/menu/index.d.ts +1 -0
- package/lib/utils/merge-refs/index.d.ts +1 -0
- package/lib/utils/merge-refs/merge-refs.d.ts +15 -0
- package/lib/utils/rating/index.d.ts +1 -0
- package/lib/utils/rating/rating.d.ts +31 -0
- package/lib/utils/score-bar/index.d.ts +1 -0
- package/lib/utils/score-bar/score-bar.d.ts +54 -0
- package/lib/utils/string/index.d.ts +1 -0
- package/lib/utils/string/string.d.ts +30 -0
- package/lib/utils/token-list-input/token-list-input.d.ts +32 -0
- package/lib/utils/tokens/index.d.ts +1 -0
- package/lib/utils/tokens/tokens.d.ts +230 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import classify from '../../../utils/classify';
|
|
4
|
+
import {Button} from '../../Button';
|
|
5
|
+
import type {IconType} from '../../Icon';
|
|
6
|
+
import css from './ButtonTab.module.css';
|
|
7
|
+
type ClassNames = $ReadOnly<{
|
|
8
|
+
wrapper?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type ButtonTabProps = {
|
|
11
|
+
classNames?: ClassNames;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onButtonTabSelect?:
|
|
15
|
+
| ((
|
|
16
|
+
id: string,
|
|
17
|
+
e?: React.SyntheticEvent<HTMLElement> | null | undefined,
|
|
18
|
+
) => unknown)
|
|
19
|
+
| null
|
|
20
|
+
| undefined;
|
|
21
|
+
iconName?: string;
|
|
22
|
+
iconType?: IconType;
|
|
23
|
+
size?: 'medium' | 'small';
|
|
24
|
+
isFluid?: boolean;
|
|
25
|
+
ariaLabel?: string;
|
|
26
|
+
id: string;
|
|
27
|
+
selectedButtonTabId?: string;
|
|
28
|
+
isLoading?: boolean;
|
|
29
|
+
isLeftCurved?: boolean;
|
|
30
|
+
isRightCurved?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export const ButtonTab: React$AbstractComponent<
|
|
33
|
+
ButtonTabProps,
|
|
34
|
+
HTMLButtonElement
|
|
35
|
+
> = React.forwardRef<ButtonTabProps, HTMLButtonElement>(
|
|
36
|
+
(
|
|
37
|
+
{
|
|
38
|
+
classNames,
|
|
39
|
+
children,
|
|
40
|
+
iconName,
|
|
41
|
+
iconType = 'regular',
|
|
42
|
+
size,
|
|
43
|
+
onButtonTabSelect,
|
|
44
|
+
id,
|
|
45
|
+
selectedButtonTabId,
|
|
46
|
+
disabled,
|
|
47
|
+
isLeftCurved,
|
|
48
|
+
isRightCurved,
|
|
49
|
+
...props
|
|
50
|
+
}: ButtonTabProps,
|
|
51
|
+
ref,
|
|
52
|
+
): React.ReactNode => (
|
|
53
|
+
<Button
|
|
54
|
+
{...props}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
size={size}
|
|
57
|
+
type="tertiary"
|
|
58
|
+
ref={ref}
|
|
59
|
+
classNames={{
|
|
60
|
+
wrapper: classify(
|
|
61
|
+
css.buttonTabWrapper,
|
|
62
|
+
{
|
|
63
|
+
[css.mediumButtonTab]: size === 'medium',
|
|
64
|
+
[css.smallButtonTab]: size === 'small',
|
|
65
|
+
[css.onlyIcon]: iconName && !children,
|
|
66
|
+
[css.isSelected]: id === selectedButtonTabId,
|
|
67
|
+
[css.disabled]: disabled,
|
|
68
|
+
[css.leftCurved]: isLeftCurved,
|
|
69
|
+
[css.rightCurved]: isRightCurved,
|
|
70
|
+
},
|
|
71
|
+
classNames?.wrapper,
|
|
72
|
+
),
|
|
73
|
+
icon: css.icon,
|
|
74
|
+
}}
|
|
75
|
+
iconLeftName={iconName}
|
|
76
|
+
iconLeftType={iconType}
|
|
77
|
+
onClick={(e) => onButtonTabSelect && onButtonTabSelect(id, e)}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</Button>
|
|
81
|
+
),
|
|
82
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonTab';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
// $FlowFixMe[untyped-import]
|
|
4
|
+
autoUpdate, // $FlowFixMe[untyped-import]
|
|
5
|
+
flip, // $FlowFixMe[untyped-import]
|
|
6
|
+
offset, // $FlowFixMe[untyped-import]
|
|
7
|
+
shift, // $FlowFixMe[untyped-import]
|
|
8
|
+
useFloating,
|
|
9
|
+
} from '@floating-ui/react';
|
|
10
|
+
import {includes} from 'lodash';
|
|
11
|
+
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
12
|
+
import classify from '../../utils/classify';
|
|
13
|
+
import {ClickAway} from '../../utils/click-away';
|
|
14
|
+
import {mergeRefs} from '../../utils/merge-refs';
|
|
15
|
+
import type {AnchorType} from '../ButtonDropdown';
|
|
16
|
+
import {Menu} from '../Menu';
|
|
17
|
+
import type {ButtonTabProps} from './ButtonTab';
|
|
18
|
+
import {ButtonTab} from './ButtonTab';
|
|
19
|
+
import css from './ButtonTabDropdown.module.css';
|
|
20
|
+
export type ButtonTabDropdownProps = ButtonTabProps & {
|
|
21
|
+
title: string;
|
|
22
|
+
anchorPosition?: AnchorType;
|
|
23
|
+
dropdownClass?: string;
|
|
24
|
+
};
|
|
25
|
+
export const ButtonTabDropdown = ({
|
|
26
|
+
title,
|
|
27
|
+
anchorPosition = 'bottom-end',
|
|
28
|
+
...buttonTabProps
|
|
29
|
+
}: ButtonTabDropdownProps): React.ReactNode => {
|
|
30
|
+
const menuBtnRef = React.useRef();
|
|
31
|
+
const {
|
|
32
|
+
size,
|
|
33
|
+
children,
|
|
34
|
+
selectedButtonTabId,
|
|
35
|
+
onButtonTabSelect: onTabSelect,
|
|
36
|
+
dropdownClass,
|
|
37
|
+
} = buttonTabProps;
|
|
38
|
+
const childrenArray = React.Children.toArray(children);
|
|
39
|
+
const menuOptions = childrenArray.map((child) => {
|
|
40
|
+
const {
|
|
41
|
+
id,
|
|
42
|
+
children,
|
|
43
|
+
disabled,
|
|
44
|
+
iconName,
|
|
45
|
+
iconType,
|
|
46
|
+
classNames,
|
|
47
|
+
size: buttonSize,
|
|
48
|
+
} = child.props;
|
|
49
|
+
return {
|
|
50
|
+
key: id,
|
|
51
|
+
disabled,
|
|
52
|
+
classNames,
|
|
53
|
+
label: children,
|
|
54
|
+
iconLeft: iconName,
|
|
55
|
+
iconLeftType: iconType,
|
|
56
|
+
customComponent: children,
|
|
57
|
+
optionSize: buttonSize ?? size,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
const moreTabSelectedId = includes(
|
|
61
|
+
menuOptions.map(({key}) => key),
|
|
62
|
+
selectedButtonTabId,
|
|
63
|
+
)
|
|
64
|
+
? 'more-tab'
|
|
65
|
+
: selectedButtonTabId;
|
|
66
|
+
const {x, y, refs, strategy} = useFloating({
|
|
67
|
+
open: true,
|
|
68
|
+
strategy: 'absolute',
|
|
69
|
+
placement: anchorPosition,
|
|
70
|
+
whileElementsMounted: autoUpdate,
|
|
71
|
+
middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
|
|
72
|
+
});
|
|
73
|
+
return (
|
|
74
|
+
<ClickAway>
|
|
75
|
+
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
76
|
+
<div
|
|
77
|
+
data-testid="ButtonTabDropdown"
|
|
78
|
+
ref={menuBtnRef}
|
|
79
|
+
className={classify(css.buttonTabDropDownWrapper, dropdownClass)}
|
|
80
|
+
>
|
|
81
|
+
<ButtonTab
|
|
82
|
+
{...buttonTabProps}
|
|
83
|
+
ref={mergeRefs([refs.setReference, triggerRef])}
|
|
84
|
+
selectedButtonTabId={moreTabSelectedId}
|
|
85
|
+
onButtonTabSelect={(id, e) => {
|
|
86
|
+
e?.stopPropagation();
|
|
87
|
+
onOpen();
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
{title}
|
|
91
|
+
</ButtonTab>
|
|
92
|
+
{isOpen && (
|
|
93
|
+
<div
|
|
94
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
95
|
+
style={{
|
|
96
|
+
display: 'flex',
|
|
97
|
+
position: strategy,
|
|
98
|
+
top: y ?? spaceNone,
|
|
99
|
+
left: x ?? spaceNone,
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
<Menu
|
|
103
|
+
onSelect={(option, e) => {
|
|
104
|
+
onTabSelect && onTabSelect(option.key, e);
|
|
105
|
+
clickAway();
|
|
106
|
+
}}
|
|
107
|
+
size={size}
|
|
108
|
+
options={menuOptions}
|
|
109
|
+
onTabOut={clickAway}
|
|
110
|
+
selectedKeys={[selectedButtonTabId ?? '']}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
)}
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
</ClickAway>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import classify from '../../utils/classify';
|
|
4
|
+
import type {AnchorType} from '../ButtonDropdown';
|
|
5
|
+
import {ButtonTabDropdown} from './ButtonTabDropdown';
|
|
6
|
+
import css from './ButtonTabs.module.css';
|
|
7
|
+
type ClassNames = $ReadOnly<{
|
|
8
|
+
wrapper?: string;
|
|
9
|
+
buttonTabDropdownWrapper?: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type ButtonTabsProps = {
|
|
12
|
+
classNames?: ClassNames;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
isFluid?: boolean;
|
|
15
|
+
size?: 'medium' | 'small';
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
selectedButtonTabId?: string;
|
|
18
|
+
onButtonTabSelect?:
|
|
19
|
+
| ((
|
|
20
|
+
id: string,
|
|
21
|
+
e?: React.SyntheticEvent<HTMLElement> | null | undefined,
|
|
22
|
+
) => unknown)
|
|
23
|
+
| null
|
|
24
|
+
| undefined;
|
|
25
|
+
wrapAfter?: number;
|
|
26
|
+
wrapTabTitle?: string;
|
|
27
|
+
anchorPosition?: AnchorType;
|
|
28
|
+
};
|
|
29
|
+
export const ButtonTabs: React$AbstractComponent<
|
|
30
|
+
ButtonTabsProps,
|
|
31
|
+
HTMLDivElement
|
|
32
|
+
> = React.forwardRef<ButtonTabsProps, HTMLDivElement>(
|
|
33
|
+
(
|
|
34
|
+
{
|
|
35
|
+
classNames,
|
|
36
|
+
children,
|
|
37
|
+
isFluid,
|
|
38
|
+
size = 'medium',
|
|
39
|
+
disabled,
|
|
40
|
+
selectedButtonTabId,
|
|
41
|
+
onButtonTabSelect,
|
|
42
|
+
wrapAfter,
|
|
43
|
+
wrapTabTitle = 'more',
|
|
44
|
+
anchorPosition,
|
|
45
|
+
}: ButtonTabsProps,
|
|
46
|
+
ref,
|
|
47
|
+
): React.ReactNode => {
|
|
48
|
+
const childrenArray = React.Children.toArray(children);
|
|
49
|
+
let unwrappedNodes = childrenArray;
|
|
50
|
+
let wrappedNodes = [];
|
|
51
|
+
|
|
52
|
+
if (typeof wrapAfter === 'number' && wrapAfter > -1) {
|
|
53
|
+
unwrappedNodes = childrenArray.slice(0, wrapAfter);
|
|
54
|
+
wrappedNodes = childrenArray.slice(wrapAfter);
|
|
55
|
+
|
|
56
|
+
if (wrappedNodes.length) {
|
|
57
|
+
unwrappedNodes.push(
|
|
58
|
+
<ButtonTabDropdown
|
|
59
|
+
id="more-tab"
|
|
60
|
+
title={wrapTabTitle}
|
|
61
|
+
iconName="ellipsis-vertical"
|
|
62
|
+
anchorPosition={anchorPosition}
|
|
63
|
+
dropdownClass={classNames?.buttonTabDropdownWrapper}
|
|
64
|
+
>
|
|
65
|
+
{wrappedNodes}
|
|
66
|
+
</ButtonTabDropdown>,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const childrenWithProps = unwrappedNodes.map((child, index) => {
|
|
72
|
+
if (React.isValidElement(child)) {
|
|
73
|
+
const {disabled: disabledChild, classNames: classNamesChild} =
|
|
74
|
+
child.props;
|
|
75
|
+
const isFirst = index === 0;
|
|
76
|
+
const isLast = index === unwrappedNodes.length - 1;
|
|
77
|
+
return React.cloneElement(child, {
|
|
78
|
+
...child.props,
|
|
79
|
+
isFluid,
|
|
80
|
+
size,
|
|
81
|
+
isLeftCurved: isFirst,
|
|
82
|
+
isRightCurved: isLast,
|
|
83
|
+
disabled: disabledChild || disabled,
|
|
84
|
+
selectedButtonTabId,
|
|
85
|
+
onButtonTabSelect,
|
|
86
|
+
classNames: {
|
|
87
|
+
wrapper: classNamesChild?.wrapper,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return child;
|
|
93
|
+
});
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-testid="ButtonTabs"
|
|
97
|
+
ref={ref}
|
|
98
|
+
className={classify(
|
|
99
|
+
css.buttonTabsWrapper,
|
|
100
|
+
{
|
|
101
|
+
[css.medium]: size === 'medium',
|
|
102
|
+
[css.small]: size === 'small',
|
|
103
|
+
[css.isFluid]: isFluid,
|
|
104
|
+
[css.disabled]: disabled,
|
|
105
|
+
},
|
|
106
|
+
classNames?.wrapper,
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
109
|
+
{childrenWithProps}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
);
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {$ReadOnly, $Values} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SPACES from '../../styles/variables/_space';
|
|
4
|
+
import classify from '../../utils/classify';
|
|
5
|
+
import {capitalize} from '../../utils/string';
|
|
6
|
+
import css from './Card.module.css';
|
|
7
|
+
type ClassNames = $ReadOnly<{
|
|
8
|
+
wrapper?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export const PADDING_SIZES = Object.freeze({
|
|
11
|
+
small: 'small',
|
|
12
|
+
medium: 'medium',
|
|
13
|
+
large: 'large',
|
|
14
|
+
});
|
|
15
|
+
export type PaddingSizeType = $Values<typeof PADDING_SIZES>;
|
|
16
|
+
export type CardProps = {
|
|
17
|
+
classNames?: ClassNames;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
paddingTop?: PaddingSizeType;
|
|
20
|
+
paddingRight?: PaddingSizeType;
|
|
21
|
+
paddingBottom?: PaddingSizeType;
|
|
22
|
+
paddingLeft?: PaddingSizeType;
|
|
23
|
+
};
|
|
24
|
+
export type CardChildProps = {
|
|
25
|
+
className?: string;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
};
|
|
28
|
+
export type ClickableCardProps = CardProps & {
|
|
29
|
+
onClick?:
|
|
30
|
+
| ((arg0: React.SyntheticEvent<HTMLElement>) => unknown)
|
|
31
|
+
| null
|
|
32
|
+
| undefined;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getPaddingValue = (size: PaddingSizeType): string => {
|
|
37
|
+
const spaceKey = 'space' + capitalize(size);
|
|
38
|
+
return SPACES[spaceKey] || SPACES['spaceNone'];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const CardHeader = ({
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
...props
|
|
45
|
+
}: CardChildProps): React.ReactNode => (
|
|
46
|
+
<div {...props} className={classify(css.cardHeader, className)}>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
export const CardTitle = ({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
...props
|
|
54
|
+
}: CardChildProps): React.ReactNode => (
|
|
55
|
+
<div {...props} className={classify(css.cardTitle, className)}>
|
|
56
|
+
{children}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
export const CardActions = ({
|
|
60
|
+
className,
|
|
61
|
+
children,
|
|
62
|
+
...props
|
|
63
|
+
}: CardChildProps): React.ReactNode => (
|
|
64
|
+
<div {...props} className={classify(css.cardActions, className)}>
|
|
65
|
+
{children}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
export const CardFooter = ({
|
|
69
|
+
className,
|
|
70
|
+
children,
|
|
71
|
+
...props
|
|
72
|
+
}: CardChildProps): React.ReactNode => (
|
|
73
|
+
<div {...props} className={classify(css.cardFooter, className)}>
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
export const CardContent = ({
|
|
78
|
+
className,
|
|
79
|
+
children,
|
|
80
|
+
...props
|
|
81
|
+
}: CardChildProps): React.ReactNode => (
|
|
82
|
+
<div {...props} className={classify(css.cardContent, className)}>
|
|
83
|
+
{children}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
export const Card: React$AbstractComponent<CardProps, HTMLDivElement> =
|
|
87
|
+
React.forwardRef<CardProps, HTMLDivElement>(
|
|
88
|
+
(
|
|
89
|
+
{
|
|
90
|
+
children,
|
|
91
|
+
classNames,
|
|
92
|
+
paddingTop = 'medium',
|
|
93
|
+
paddingRight = 'medium',
|
|
94
|
+
paddingBottom = 'medium',
|
|
95
|
+
paddingLeft = 'medium',
|
|
96
|
+
...props
|
|
97
|
+
}: CardProps,
|
|
98
|
+
ref,
|
|
99
|
+
): React.ReactNode => (
|
|
100
|
+
<div
|
|
101
|
+
{...props}
|
|
102
|
+
style={{
|
|
103
|
+
'--card-padding-top': getPaddingValue(paddingTop),
|
|
104
|
+
'--card-padding-right': getPaddingValue(paddingRight),
|
|
105
|
+
'--card-padding-bottom': getPaddingValue(paddingBottom),
|
|
106
|
+
'--card-padding-left': getPaddingValue(paddingLeft),
|
|
107
|
+
}}
|
|
108
|
+
data-testid="Card"
|
|
109
|
+
className={classify(css.cardWrapper, classNames?.wrapper)}
|
|
110
|
+
ref={ref}
|
|
111
|
+
>
|
|
112
|
+
{children}
|
|
113
|
+
</div>
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
export const ClickableCard: React$AbstractComponent<
|
|
117
|
+
ClickableCardProps,
|
|
118
|
+
HTMLDivElement
|
|
119
|
+
> = React.forwardRef<ClickableCardProps, HTMLDivElement>(
|
|
120
|
+
(
|
|
121
|
+
{classNames, onClick, disabled = false, ...props}: ClickableCardProps,
|
|
122
|
+
ref,
|
|
123
|
+
): React.ReactNode => {
|
|
124
|
+
const componentRef = React.useRef(null);
|
|
125
|
+
React.useImperativeHandle(ref, () => componentRef.current);
|
|
126
|
+
React.useEffect(() => {
|
|
127
|
+
if (disabled) {
|
|
128
|
+
componentRef.current?.blur();
|
|
129
|
+
}
|
|
130
|
+
}, [disabled]);
|
|
131
|
+
|
|
132
|
+
const onClickHandler = (e) => {
|
|
133
|
+
if (!disabled) {
|
|
134
|
+
onClick && onClick(e);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const onKeyDownHandler = (e) => {
|
|
139
|
+
if (e.key === 'Enter') {
|
|
140
|
+
onClickHandler(e);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<Card
|
|
146
|
+
{...props}
|
|
147
|
+
classNames={{
|
|
148
|
+
wrapper: classify(
|
|
149
|
+
css.clickableCard,
|
|
150
|
+
{
|
|
151
|
+
[css.disabled]: disabled,
|
|
152
|
+
},
|
|
153
|
+
classNames?.wrapper,
|
|
154
|
+
),
|
|
155
|
+
}}
|
|
156
|
+
tabIndex={disabled ? -1 : 0}
|
|
157
|
+
onClick={onClickHandler}
|
|
158
|
+
onKeyDown={onKeyDownHandler}
|
|
159
|
+
ref={ref}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Card';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type {Tooltip} from '../../../types/charts';
|
|
2
|
+
import typographyCss from '../../../styles/typography.module.css';
|
|
3
|
+
import css from './ChartTooltip.module.css';
|
|
4
|
+
export const tooltipTheme: Tooltip = {
|
|
5
|
+
headerFormat: `<span class="${typographyCss.bodySmall} ${css.tooltipHeader}">{point.key}</span>`,
|
|
6
|
+
pointFormat: `<span class=${css.tooltipPoint}>
|
|
7
|
+
<span style="background-color:{point.color};" class=${css.indicatorCircle}></span>
|
|
8
|
+
<span class="${css.tooltipContent} ${typographyCss.bodyMedium}"> {series.name}: {point.y}</span>
|
|
9
|
+
</span>`,
|
|
10
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
//@ts-expect-error[untyped-import]
|
|
4
|
+
import Highcharts from 'highcharts';
|
|
5
|
+
//@ts-expect-error[untyped-import]
|
|
6
|
+
import accessibility from 'highcharts/modules/accessibility';
|
|
7
|
+
//@ts-expect-error[untyped-import]
|
|
8
|
+
import drilldown from 'highcharts/modules/drilldown';
|
|
9
|
+
//@ts-expect-error[untyped-import]
|
|
10
|
+
import exporting from 'highcharts/modules/exporting';
|
|
11
|
+
import {size180} from '../../../styles/variables/_size';
|
|
12
|
+
import classify from '../../../utils/classify';
|
|
13
|
+
import {ANCHOR_POSITION_TYPE, ButtonDropdown} from '../../ButtonDropdown';
|
|
14
|
+
import {
|
|
15
|
+
Card,
|
|
16
|
+
CardActions,
|
|
17
|
+
CardContent,
|
|
18
|
+
CardHeader,
|
|
19
|
+
CardTitle,
|
|
20
|
+
} from '../../Card';
|
|
21
|
+
import {CircularLoader} from '../../CircularLoader';
|
|
22
|
+
import type {MenuOption} from '../../Menu';
|
|
23
|
+
import css from './ChartWrapper.module.css';
|
|
24
|
+
export type ExportOptionType = {
|
|
25
|
+
key: string;
|
|
26
|
+
label: string;
|
|
27
|
+
format: string;
|
|
28
|
+
};
|
|
29
|
+
export const EXPORT_OPTIONS = Object.freeze({
|
|
30
|
+
download_as_png: {
|
|
31
|
+
key: 'download_as_png',
|
|
32
|
+
label: 'Download as PNG',
|
|
33
|
+
format: 'image/png',
|
|
34
|
+
},
|
|
35
|
+
download_as_jpeg: {
|
|
36
|
+
key: 'download_as_jpeg',
|
|
37
|
+
label: 'Download as JPEG',
|
|
38
|
+
format: 'image/jpeg',
|
|
39
|
+
},
|
|
40
|
+
download_as_pdf: {
|
|
41
|
+
key: 'download_as_pdf',
|
|
42
|
+
label: 'Download as PDF',
|
|
43
|
+
format: 'application/pdf',
|
|
44
|
+
},
|
|
45
|
+
download_as_svg: {
|
|
46
|
+
key: 'download_as_svg',
|
|
47
|
+
label: 'Download as SVG',
|
|
48
|
+
format: 'image/svg+xml',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
// on assumption that all export options will be shown by default
|
|
52
|
+
const DEFAULT_EXPORT_OPTIONS = Object.keys(EXPORT_OPTIONS).map(
|
|
53
|
+
(exportKey) => EXPORT_OPTIONS[exportKey],
|
|
54
|
+
);
|
|
55
|
+
type CustomExportButtonProps = {
|
|
56
|
+
ref?: HTMLDivElement;
|
|
57
|
+
customExportOptions?: Array<ExportOptionType> | null;
|
|
58
|
+
};
|
|
59
|
+
const CustomExportButton = React.forwardRef<
|
|
60
|
+
CustomExportButtonProps,
|
|
61
|
+
HTMLDivElement
|
|
62
|
+
>(({customExportOptions = null}: CustomExportButtonProps, ref) => {
|
|
63
|
+
exporting(Highcharts);
|
|
64
|
+
drilldown(Highcharts);
|
|
65
|
+
accessibility(Highcharts);
|
|
66
|
+
const exportOptions = customExportOptions
|
|
67
|
+
? customExportOptions
|
|
68
|
+
: DEFAULT_EXPORT_OPTIONS;
|
|
69
|
+
const menuOptions: Array<MenuOption> = exportOptions.map((exportOption) => {
|
|
70
|
+
const {key, label} = exportOption;
|
|
71
|
+
return {
|
|
72
|
+
key,
|
|
73
|
+
label,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const handleDownload = (exportKey: string): void => {
|
|
78
|
+
const exportOptionObject = exportOptions.find(
|
|
79
|
+
(exportOption) => exportOption.key === exportKey,
|
|
80
|
+
);
|
|
81
|
+
const exportFormat = exportOptionObject?.format || '';
|
|
82
|
+
|
|
83
|
+
if (ref.current) {
|
|
84
|
+
// $FlowFixMe[prop-missing]
|
|
85
|
+
// $FlowFixMe[incompatible-use]
|
|
86
|
+
ref.current.chart?.exportChart({
|
|
87
|
+
type: exportFormat,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<ButtonDropdown
|
|
94
|
+
ariaLabel="Export Chart Menu"
|
|
95
|
+
menu={{
|
|
96
|
+
isFluid: true,
|
|
97
|
+
menuDisabled: false,
|
|
98
|
+
options: menuOptions,
|
|
99
|
+
size: 'medium',
|
|
100
|
+
width: size180,
|
|
101
|
+
}}
|
|
102
|
+
iconLeftName="ellipsis"
|
|
103
|
+
onOptionSelect={(option) => handleDownload(option.key)}
|
|
104
|
+
size="small"
|
|
105
|
+
type="ghost"
|
|
106
|
+
anchorPosition={ANCHOR_POSITION_TYPE.bottomEnd}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
export type ChartWrapperClassNames = $ReadOnly<{
|
|
111
|
+
wrapper?: string;
|
|
112
|
+
header?: string;
|
|
113
|
+
title?: string;
|
|
114
|
+
actions?: string;
|
|
115
|
+
content?: string;
|
|
116
|
+
loader?: string;
|
|
117
|
+
}>;
|
|
118
|
+
type ChartWrapperProps = {
|
|
119
|
+
isLoading?: boolean;
|
|
120
|
+
title: React.ReactNode;
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
classNames?: ChartWrapperClassNames;
|
|
123
|
+
customExportOptions?: Array<ExportOptionType> | null;
|
|
124
|
+
headerActions?: React.ReactNode;
|
|
125
|
+
hasEmptyData?: boolean;
|
|
126
|
+
emptyText?: React.ReactNode;
|
|
127
|
+
};
|
|
128
|
+
export const ChartWrapper: React$AbstractComponent<
|
|
129
|
+
ChartWrapperProps,
|
|
130
|
+
HTMLDivElement
|
|
131
|
+
> = React.forwardRef<ChartWrapperProps, HTMLDivElement>(
|
|
132
|
+
(
|
|
133
|
+
{
|
|
134
|
+
isLoading,
|
|
135
|
+
title,
|
|
136
|
+
children,
|
|
137
|
+
classNames,
|
|
138
|
+
customExportOptions,
|
|
139
|
+
headerActions,
|
|
140
|
+
hasEmptyData = false,
|
|
141
|
+
emptyText,
|
|
142
|
+
}: ChartWrapperProps,
|
|
143
|
+
ref,
|
|
144
|
+
): React.ReactNode => (
|
|
145
|
+
<Card
|
|
146
|
+
classNames={{
|
|
147
|
+
wrapper: classify(
|
|
148
|
+
css.wrapper,
|
|
149
|
+
{
|
|
150
|
+
[css.justifyCenter]: isLoading,
|
|
151
|
+
},
|
|
152
|
+
classNames?.wrapper,
|
|
153
|
+
),
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
{isLoading ? (
|
|
157
|
+
<CircularLoader
|
|
158
|
+
size="large"
|
|
159
|
+
className={classify(css.loader, classNames?.loader)}
|
|
160
|
+
/>
|
|
161
|
+
) : (
|
|
162
|
+
<>
|
|
163
|
+
<CardHeader className={classNames?.header}>
|
|
164
|
+
<CardTitle className={classNames?.title}>{title}</CardTitle>
|
|
165
|
+
<CardActions
|
|
166
|
+
className={classify(css.chartCardActions, classNames?.actions)}
|
|
167
|
+
>
|
|
168
|
+
<CustomExportButton
|
|
169
|
+
ref={ref}
|
|
170
|
+
customExportOptions={customExportOptions}
|
|
171
|
+
/>
|
|
172
|
+
{headerActions ? headerActions : null}
|
|
173
|
+
</CardActions>
|
|
174
|
+
</CardHeader>
|
|
175
|
+
<CardContent
|
|
176
|
+
className={classify(css.chartContent, classNames?.content)}
|
|
177
|
+
>
|
|
178
|
+
{hasEmptyData && emptyText ? emptyText : children}
|
|
179
|
+
</CardContent>
|
|
180
|
+
</>
|
|
181
|
+
)}
|
|
182
|
+
</Card>
|
|
183
|
+
),
|
|
184
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChartWrapper';
|