@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,86 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import classify from '../../utils/classify';
|
|
4
|
+
import {
|
|
5
|
+
ForbiddenImage,
|
|
6
|
+
NotFoundImage,
|
|
7
|
+
ServerErrorImage,
|
|
8
|
+
UnauthorizedImage,
|
|
9
|
+
} from './ErrorImages';
|
|
10
|
+
import css from './ErrorMessage.module.css';
|
|
11
|
+
type ClassNames = $ReadOnly<{
|
|
12
|
+
wrapper?: string;
|
|
13
|
+
image?: string;
|
|
14
|
+
heading?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
children?: string;
|
|
18
|
+
}>;
|
|
19
|
+
export type ErrorMessageProps = {
|
|
20
|
+
classNames?: ClassNames;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
imageVariant?: 'unauthorized' | 'forbidden' | 'notFound' | 'serverError';
|
|
23
|
+
title?: React.ReactNode;
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
heading?: React.ReactNode;
|
|
26
|
+
customImageUrl?: string;
|
|
27
|
+
};
|
|
28
|
+
export const ErrorMessage: React$AbstractComponent<
|
|
29
|
+
ErrorMessageProps,
|
|
30
|
+
HTMLDivElement
|
|
31
|
+
> = React.forwardRef<ErrorMessageProps, HTMLDivElement>(
|
|
32
|
+
(
|
|
33
|
+
{
|
|
34
|
+
classNames,
|
|
35
|
+
children,
|
|
36
|
+
imageVariant,
|
|
37
|
+
title,
|
|
38
|
+
description,
|
|
39
|
+
customImageUrl,
|
|
40
|
+
heading,
|
|
41
|
+
...props
|
|
42
|
+
}: ErrorMessageProps,
|
|
43
|
+
ref,
|
|
44
|
+
): React.ReactNode => (
|
|
45
|
+
<div
|
|
46
|
+
{...props}
|
|
47
|
+
data-testid="ErrorMessage"
|
|
48
|
+
className={classify(css.wrapper, classNames?.wrapper)}
|
|
49
|
+
ref={ref}
|
|
50
|
+
>
|
|
51
|
+
{!!imageVariant && !customImageUrl && (
|
|
52
|
+
<div className={classify(css.image, classNames?.image)}>
|
|
53
|
+
{imageVariant === 'unauthorized' && <UnauthorizedImage />}
|
|
54
|
+
{imageVariant === 'forbidden' && <ForbiddenImage />}
|
|
55
|
+
{imageVariant === 'notFound' && <NotFoundImage />}
|
|
56
|
+
{imageVariant === 'serverError' && <ServerErrorImage />}
|
|
57
|
+
</div>
|
|
58
|
+
)}
|
|
59
|
+
{customImageUrl && (
|
|
60
|
+
<img
|
|
61
|
+
className={classify(css.image, classNames?.image)}
|
|
62
|
+
src={customImageUrl}
|
|
63
|
+
alt="Empty State"
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
{!!heading && (
|
|
67
|
+
<div className={classify(css.heading, classNames?.heading)}>
|
|
68
|
+
{heading}
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
{!!title && (
|
|
72
|
+
<div className={classify(css.title, classNames?.title)}>{title}</div>
|
|
73
|
+
)}
|
|
74
|
+
{!!description && (
|
|
75
|
+
<div className={classify(css.description, classNames?.description)}>
|
|
76
|
+
{description}
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
{!!children && (
|
|
80
|
+
<div className={classify(css.childrenWrapper, classNames?.children)}>
|
|
81
|
+
{children}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
),
|
|
86
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ErrorMessage';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import classify from '../../../utils/classify';
|
|
4
|
+
import {ClickableIcon, CloseIcon, Icon} from '../../Icon';
|
|
5
|
+
import {LinearLoader} from '../../LinearLoader';
|
|
6
|
+
import {Truncate} from '../../Truncate';
|
|
7
|
+
import type {FileObject} from '../FileUpload';
|
|
8
|
+
import css from '../FileUpload.module.css';
|
|
9
|
+
type ClassNames = $ReadOnly<{
|
|
10
|
+
wrapper?: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type FileBlockProps = {
|
|
13
|
+
classNames?: ClassNames;
|
|
14
|
+
fileObject: FileObject;
|
|
15
|
+
onFileRefreshClick?: (file: FileObject) => unknown;
|
|
16
|
+
handleFileClear?: (id: string) => unknown;
|
|
17
|
+
};
|
|
18
|
+
export const FileBlock: React$AbstractComponent<
|
|
19
|
+
FileBlockProps,
|
|
20
|
+
HTMLDivElement
|
|
21
|
+
> = React.forwardRef<FileBlockProps, HTMLDivElement>(
|
|
22
|
+
(
|
|
23
|
+
{
|
|
24
|
+
classNames,
|
|
25
|
+
fileObject,
|
|
26
|
+
onFileRefreshClick,
|
|
27
|
+
handleFileClear,
|
|
28
|
+
}: FileBlockProps,
|
|
29
|
+
ref,
|
|
30
|
+
): React.ReactNode => (
|
|
31
|
+
<>
|
|
32
|
+
<div className={classify(css.file, classNames?.wrapper)} ref={ref}>
|
|
33
|
+
<div className={css.fileInfo}>
|
|
34
|
+
<div className={css.fileNameBlock}>
|
|
35
|
+
<div className={css.icon}>
|
|
36
|
+
<FileStatusIcon fileObject={fileObject} />
|
|
37
|
+
</div>
|
|
38
|
+
<div className={css.fileName}>
|
|
39
|
+
<Truncate>{fileObject.file.name}</Truncate>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
{fileObject.success &&
|
|
44
|
+
!!fileObject.successMessage &&
|
|
45
|
+
!fileObject.progress && (
|
|
46
|
+
<div className={css.fileSuccess}>
|
|
47
|
+
<Truncate>{fileObject.successMessage}</Truncate>
|
|
48
|
+
</div>
|
|
49
|
+
)}
|
|
50
|
+
|
|
51
|
+
{fileObject.reject &&
|
|
52
|
+
!!fileObject.rejectReason &&
|
|
53
|
+
!fileObject.progress && (
|
|
54
|
+
<div className={css.fileError}>
|
|
55
|
+
<Truncate>{fileObject.rejectReason}</Truncate>
|
|
56
|
+
</div>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
{!!fileObject.progress && (
|
|
60
|
+
<div className={css.progress}>
|
|
61
|
+
<LinearLoader
|
|
62
|
+
size="small"
|
|
63
|
+
value={
|
|
64
|
+
fileObject.progress === 'indeterminate'
|
|
65
|
+
? 0
|
|
66
|
+
: fileObject.progress
|
|
67
|
+
}
|
|
68
|
+
indeterminate={fileObject.progress === 'indeterminate'}
|
|
69
|
+
></LinearLoader>
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
<div className={css.rightSection}>
|
|
74
|
+
{fileObject.showReUpload && (
|
|
75
|
+
<div className={css.rightBlock}>
|
|
76
|
+
<ClickableIcon
|
|
77
|
+
name="refresh"
|
|
78
|
+
size="small"
|
|
79
|
+
onClick={() => onFileRefreshClick?.(fileObject)}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
<div className={css.rightBlock}>
|
|
85
|
+
<CloseIcon
|
|
86
|
+
size="small"
|
|
87
|
+
onClick={() => handleFileClear?.(fileObject.id)}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</>
|
|
93
|
+
),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// This function returns the status of a file
|
|
97
|
+
const getFileStatus = (fileObject: FileObject) => {
|
|
98
|
+
if (fileObject.progress) {
|
|
99
|
+
return 'progress';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (fileObject.success) {
|
|
103
|
+
return 'success';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (fileObject.reject) {
|
|
107
|
+
return 'error';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return 'default';
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// This component renders the status icon for a file
|
|
114
|
+
const FileStatusIcon = ({fileObject}: {fileObject: FileObject}) => {
|
|
115
|
+
const status = getFileStatus(fileObject);
|
|
116
|
+
|
|
117
|
+
switch (status) {
|
|
118
|
+
case 'progress':
|
|
119
|
+
return <Icon size="small" name="loader" color="tertiary" />;
|
|
120
|
+
|
|
121
|
+
case 'success':
|
|
122
|
+
return <Icon size="small" name="check" color="success" />;
|
|
123
|
+
|
|
124
|
+
case 'error':
|
|
125
|
+
return (
|
|
126
|
+
<Icon
|
|
127
|
+
size="small"
|
|
128
|
+
name="circle-exclamation"
|
|
129
|
+
color="danger"
|
|
130
|
+
type="solid"
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
default:
|
|
135
|
+
return <Icon size="small" name="check" color="success" />;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FileBlock';
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
// @ts-expect-error[untyped-import] -- this should be fixed soon
|
|
4
|
+
import type {UseFileUploadReturnProps} from '../../hooks/useFileUpload';
|
|
5
|
+
import {useFileUpload} from '../../hooks/useFileUpload';
|
|
6
|
+
import classify from '../../utils/classify';
|
|
7
|
+
import {UnstyledButton} from '../Button';
|
|
8
|
+
import {Truncate} from '../Truncate';
|
|
9
|
+
import {FileBlock} from './FileBlock';
|
|
10
|
+
import css from './FileUpload.module.css';
|
|
11
|
+
type ClassNames = $ReadOnly<{
|
|
12
|
+
wrapper?: string;
|
|
13
|
+
instruction?: string;
|
|
14
|
+
secondaryInstruction?: string;
|
|
15
|
+
dropZone?: string;
|
|
16
|
+
files?: string;
|
|
17
|
+
}>;
|
|
18
|
+
export type FileProgress = number | 'indeterminate';
|
|
19
|
+
export type FileObject = {
|
|
20
|
+
file: File;
|
|
21
|
+
id: string;
|
|
22
|
+
reject?: boolean;
|
|
23
|
+
rejectReason?: string;
|
|
24
|
+
progress?: FileProgress;
|
|
25
|
+
success?: boolean;
|
|
26
|
+
successMessage?: string;
|
|
27
|
+
// This is a flag that is used to show/hide re-upload button
|
|
28
|
+
showReUpload?: boolean;
|
|
29
|
+
};
|
|
30
|
+
// This is a file error object that is passed to onRejectedFilesDrop callback in useFileUpload hook
|
|
31
|
+
export type FileError = {
|
|
32
|
+
code: string;
|
|
33
|
+
};
|
|
34
|
+
// This is a file rejection object that is passed to handleDropRejected function in useFileUpload hook
|
|
35
|
+
export type FileRejection = {
|
|
36
|
+
errors: Array<FileError>;
|
|
37
|
+
file: File;
|
|
38
|
+
};
|
|
39
|
+
// This is a ref object that is passed to FileUpload component for managing state of a single file
|
|
40
|
+
export type FileUploadRef = {
|
|
41
|
+
moveFileToProgress: (id: string, progress: FileProgress) => unknown;
|
|
42
|
+
moveFileToSuccess: (id: string, successMessage?: string) => unknown;
|
|
43
|
+
moveFileToReject: (id: string, rejectReason?: string) => unknown;
|
|
44
|
+
setShowReUpload: (id: string, showReUpload?: boolean) => unknown;
|
|
45
|
+
handleFileClear: (id: string) => unknown;
|
|
46
|
+
validFiles: Array<FileObject>;
|
|
47
|
+
rejectedFiles: Array<FileObject>;
|
|
48
|
+
files: Array<FileObject>;
|
|
49
|
+
};
|
|
50
|
+
// These props are shared between FileUpload component and useFileUpload hook
|
|
51
|
+
export type FileUploadBaseProps = {
|
|
52
|
+
maxFiles?: number;
|
|
53
|
+
maxSize?: number;
|
|
54
|
+
accept?: Record<string, string[]>;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
// File drop callbacks
|
|
57
|
+
onValidFilesDrop?: (acceptedFiles: Array<FileObject>) => unknown;
|
|
58
|
+
onRejectedFilesDrop?: (fileRejections: Array<FileObject>) => unknown;
|
|
59
|
+
// File clear callbacks
|
|
60
|
+
onFileClear?: (id: string) => unknown;
|
|
61
|
+
onClear?: () => unknown;
|
|
62
|
+
};
|
|
63
|
+
export type FileUploadProps = FileUploadBaseProps & {
|
|
64
|
+
classNames?: ClassNames;
|
|
65
|
+
label?: React.ReactNode;
|
|
66
|
+
instruction?: React.ReactNode;
|
|
67
|
+
draggingInstruction?: React.ReactNode;
|
|
68
|
+
secondaryInstruction?: React.ReactNode;
|
|
69
|
+
required?: boolean;
|
|
70
|
+
handleFileDeletionExternally?: boolean;
|
|
71
|
+
// File refresh callback
|
|
72
|
+
onFileRefreshClick?: (file: FileObject) => unknown;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const FileUploadBase = (props: FileUploadProps, ref) => {
|
|
76
|
+
const {
|
|
77
|
+
classNames,
|
|
78
|
+
label = 'Upload File',
|
|
79
|
+
disabled = false,
|
|
80
|
+
instruction = 'Drag and drop or click to upload',
|
|
81
|
+
draggingInstruction = 'Drop here to start uploading..',
|
|
82
|
+
error = false,
|
|
83
|
+
required = false,
|
|
84
|
+
secondaryInstruction = '',
|
|
85
|
+
maxSize,
|
|
86
|
+
accept,
|
|
87
|
+
onValidFilesDrop,
|
|
88
|
+
onRejectedFilesDrop,
|
|
89
|
+
onFileClear,
|
|
90
|
+
onFileRefreshClick,
|
|
91
|
+
maxFiles = 1,
|
|
92
|
+
handleFileDeletionExternally,
|
|
93
|
+
} = props;
|
|
94
|
+
// Get file upload state from useFileUpload hook
|
|
95
|
+
const {
|
|
96
|
+
validFiles,
|
|
97
|
+
rejectedFiles,
|
|
98
|
+
isDragActive,
|
|
99
|
+
getRootProps,
|
|
100
|
+
shouldAcceptFiles,
|
|
101
|
+
getInputProps,
|
|
102
|
+
handleFileClear,
|
|
103
|
+
moveFileToProgress,
|
|
104
|
+
moveFileToSuccess,
|
|
105
|
+
moveFileToReject,
|
|
106
|
+
setShowReUpload,
|
|
107
|
+
}: UseFileUploadReturnProps = useFileUpload({
|
|
108
|
+
maxFiles,
|
|
109
|
+
maxSize,
|
|
110
|
+
accept,
|
|
111
|
+
disabled,
|
|
112
|
+
onValidFilesDrop,
|
|
113
|
+
onRejectedFilesDrop,
|
|
114
|
+
onFileClear,
|
|
115
|
+
});
|
|
116
|
+
// Expose file upload actions to parent component
|
|
117
|
+
React.useImperativeHandle(ref, () => ({
|
|
118
|
+
moveFileToProgress,
|
|
119
|
+
moveFileToSuccess,
|
|
120
|
+
moveFileToReject,
|
|
121
|
+
handleFileClear,
|
|
122
|
+
setShowReUpload,
|
|
123
|
+
validFiles,
|
|
124
|
+
rejectedFiles,
|
|
125
|
+
files: [...validFiles, ...rejectedFiles],
|
|
126
|
+
}));
|
|
127
|
+
// Merge valid and rejected files
|
|
128
|
+
const files = [...validFiles, ...rejectedFiles];
|
|
129
|
+
return (
|
|
130
|
+
<div className={classify(css.wrapper, classNames?.wrapper)}>
|
|
131
|
+
{Boolean(label) && (
|
|
132
|
+
<div className={css.label}>
|
|
133
|
+
<Truncate>{label}</Truncate>
|
|
134
|
+
{required && <span className={css.required}>{'*'}</span>}
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
|
|
138
|
+
<UnstyledButton
|
|
139
|
+
disabled={disabled || !shouldAcceptFiles}
|
|
140
|
+
{...getRootProps()}
|
|
141
|
+
className={classify(
|
|
142
|
+
css.dropzone,
|
|
143
|
+
{
|
|
144
|
+
[css.disabled]: disabled || !shouldAcceptFiles,
|
|
145
|
+
[css.dragActive]: isDragActive,
|
|
146
|
+
[css.error]: error,
|
|
147
|
+
},
|
|
148
|
+
classNames?.dropZone,
|
|
149
|
+
)}
|
|
150
|
+
>
|
|
151
|
+
<input {...getInputProps()} />
|
|
152
|
+
<div className={classify(css.instruction, classNames?.instruction)}>
|
|
153
|
+
{isDragActive ? draggingInstruction : instruction}
|
|
154
|
+
</div>
|
|
155
|
+
<div
|
|
156
|
+
className={classify(
|
|
157
|
+
css.secondaryInstruction,
|
|
158
|
+
classNames?.secondaryInstruction,
|
|
159
|
+
)}
|
|
160
|
+
>
|
|
161
|
+
{secondaryInstruction}
|
|
162
|
+
</div>
|
|
163
|
+
</UnstyledButton>
|
|
164
|
+
|
|
165
|
+
{files.length > 0 && (
|
|
166
|
+
<div className={css.files}>
|
|
167
|
+
{files.map((fileObject: FileObject) => (
|
|
168
|
+
<React.Fragment key={fileObject.id}>
|
|
169
|
+
<FileBlock
|
|
170
|
+
fileObject={fileObject}
|
|
171
|
+
onFileRefreshClick={onFileRefreshClick}
|
|
172
|
+
handleFileClear={
|
|
173
|
+
handleFileDeletionExternally ? onFileClear : handleFileClear
|
|
174
|
+
}
|
|
175
|
+
classNames={{
|
|
176
|
+
wrapper: classNames?.files,
|
|
177
|
+
}}
|
|
178
|
+
/>
|
|
179
|
+
</React.Fragment>
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
</div>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const FileUpload: React.AbstractComponent<
|
|
188
|
+
FileUploadProps,
|
|
189
|
+
FileUploadRef
|
|
190
|
+
> = React.forwardRef<FileUploadProps, FileUploadRef>(FileUploadBase);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
// $FlowFixMe[untyped-import]
|
|
5
|
+
FloatingFocusManager, // $FlowFixMe[untyped-import]
|
|
6
|
+
useFloating,
|
|
7
|
+
} from '@floating-ui/react';
|
|
8
|
+
import classify from '../../utils/classify';
|
|
9
|
+
import css from './FocusManager.module.css';
|
|
10
|
+
type ClassNames = $ReadOnly<{
|
|
11
|
+
wrapper?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type FocusManagerProps = {
|
|
14
|
+
classNames?: ClassNames;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
initialFocus?: number;
|
|
17
|
+
returnFocus?: boolean;
|
|
18
|
+
guards?: boolean;
|
|
19
|
+
modal?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export const FocusManager = (props: FocusManagerProps): React.ReactNode => {
|
|
22
|
+
const {refs, context} = useFloating({
|
|
23
|
+
open: true,
|
|
24
|
+
});
|
|
25
|
+
const {
|
|
26
|
+
classNames,
|
|
27
|
+
children,
|
|
28
|
+
initialFocus = -1,
|
|
29
|
+
returnFocus = true,
|
|
30
|
+
modal = true,
|
|
31
|
+
guards = true,
|
|
32
|
+
...restFloatingFocusManagerProps
|
|
33
|
+
} = props;
|
|
34
|
+
return (
|
|
35
|
+
<FloatingFocusManager
|
|
36
|
+
context={context}
|
|
37
|
+
initialFocus={initialFocus}
|
|
38
|
+
modal={modal}
|
|
39
|
+
guards={guards}
|
|
40
|
+
returnFocus={returnFocus}
|
|
41
|
+
{...restFloatingFocusManagerProps}
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
ref={refs.setFloating}
|
|
45
|
+
data-testid="FocusManager"
|
|
46
|
+
className={classify(css.wrapper, classNames?.wrapper)}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
</FloatingFocusManager>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FocusManager';
|
package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
// $FlowFixMe[untyped-import]
|
|
4
|
+
FloatingFocusManager, // $FlowFixMe[untyped-import]
|
|
5
|
+
useFloating, // $FlowFixMe[untyped-import]
|
|
6
|
+
useInteractions, // $FlowFixMe[untyped-import]
|
|
7
|
+
useListNavigation,
|
|
8
|
+
} from '@floating-ui/react';
|
|
9
|
+
import classify from '../../utils/classify';
|
|
10
|
+
import type {FocusManagerProps} from '../FocusManager';
|
|
11
|
+
import css from './FocusManagerWithArrowKeyNavigation.module.css';
|
|
12
|
+
const SKIP_ELEMENT_DISPLAY_NAME = 'SkipElementFromNavigation';
|
|
13
|
+
export type SkipElementFromNavigationProps = {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
export const SkipElementFromNavigation: React$AbstractComponent<
|
|
18
|
+
SkipElementFromNavigationProps,
|
|
19
|
+
HTMLDivElement
|
|
20
|
+
> = React.forwardRef<SkipElementFromNavigationProps, HTMLDivElement>(
|
|
21
|
+
(
|
|
22
|
+
{children, className, ...restProps}: SkipElementFromNavigationProps,
|
|
23
|
+
ref,
|
|
24
|
+
) => (
|
|
25
|
+
<div {...restProps} className={className} tabIndex={-1} ref={ref}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
SkipElementFromNavigation.displayName = SKIP_ELEMENT_DISPLAY_NAME;
|
|
31
|
+
export type FocusManagerWithArrowKeyNavigationProps = FocusManagerProps & {
|
|
32
|
+
cols?: number;
|
|
33
|
+
orientation?: 'horizontal' | 'vertical';
|
|
34
|
+
focusItemOnOpen?: 'auto' | boolean;
|
|
35
|
+
loop?: boolean;
|
|
36
|
+
listReference?: {
|
|
37
|
+
current: Array<HTMLElement>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export const FocusManagerWithArrowKeyNavigation = (
|
|
41
|
+
props: FocusManagerWithArrowKeyNavigationProps,
|
|
42
|
+
): React.ReactNode => {
|
|
43
|
+
const {
|
|
44
|
+
classNames,
|
|
45
|
+
children,
|
|
46
|
+
initialFocus = -1,
|
|
47
|
+
orientation = 'vertical',
|
|
48
|
+
modal = false,
|
|
49
|
+
cols = 1,
|
|
50
|
+
focusItemOnOpen = 'auto',
|
|
51
|
+
loop = false,
|
|
52
|
+
listReference,
|
|
53
|
+
...restFloatingFocusManagerProps
|
|
54
|
+
} = props;
|
|
55
|
+
const {refs, context} = useFloating({
|
|
56
|
+
open: true,
|
|
57
|
+
});
|
|
58
|
+
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
59
|
+
const listRef = React.useRef([]);
|
|
60
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
61
|
+
|
|
62
|
+
// Note(Nishant): This is to correctly call the onClick handler which could have been on child
|
|
63
|
+
// we also need to set the active index correctly on click for list navigation to work
|
|
64
|
+
const childOnClickPassthrough = (childOnClickHandler, index, ...args) => {
|
|
65
|
+
if (childOnClickHandler) {
|
|
66
|
+
childOnClickHandler(...args);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setActiveIndex(index);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Add childOnClickPassthrough for the list of references passed in case of custom nodes passed
|
|
73
|
+
if (listReference) {
|
|
74
|
+
listReference.current.map((element, index) => {
|
|
75
|
+
const childClickHandler = element.onclick;
|
|
76
|
+
|
|
77
|
+
element.onclick = (...args) => {
|
|
78
|
+
childOnClickPassthrough(childClickHandler, index, ...args);
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Note(Nishant): Force the list navigation props onto the children
|
|
84
|
+
// while using this component make sure your all the passed children have a focus state
|
|
85
|
+
let skippedChildrenCount = 0;
|
|
86
|
+
const clonedChildren = listReference
|
|
87
|
+
? children
|
|
88
|
+
: childrenArray.map((child, index) => {
|
|
89
|
+
const {onClick: childClickHandler} = child.props;
|
|
90
|
+
let adjustedIndex = index - skippedChildrenCount;
|
|
91
|
+
|
|
92
|
+
if (child?.type?.displayName === SKIP_ELEMENT_DISPLAY_NAME) {
|
|
93
|
+
skippedChildrenCount++;
|
|
94
|
+
adjustedIndex = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return React.cloneElement(child, {
|
|
98
|
+
...child.props,
|
|
99
|
+
tabIndex: activeIndex === index ? 0 : -1,
|
|
100
|
+
ref: (node) => {
|
|
101
|
+
if (adjustedIndex !== null) {
|
|
102
|
+
listRef.current[adjustedIndex] = node;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
onClick: (...args) => {
|
|
106
|
+
childOnClickPassthrough(childClickHandler, adjustedIndex, ...args);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const listNavigation = useListNavigation(context, {
|
|
111
|
+
orientation,
|
|
112
|
+
cols,
|
|
113
|
+
listRef: listReference ? listReference : listRef,
|
|
114
|
+
activeIndex,
|
|
115
|
+
onNavigate: setActiveIndex,
|
|
116
|
+
focusItemOnOpen,
|
|
117
|
+
loop,
|
|
118
|
+
});
|
|
119
|
+
const {getFloatingProps} = useInteractions([listNavigation]);
|
|
120
|
+
return (
|
|
121
|
+
<FloatingFocusManager
|
|
122
|
+
context={context}
|
|
123
|
+
modal={modal}
|
|
124
|
+
initialFocus={initialFocus}
|
|
125
|
+
{...restFloatingFocusManagerProps}
|
|
126
|
+
>
|
|
127
|
+
<div
|
|
128
|
+
ref={refs.setFloating}
|
|
129
|
+
data-testid="FocusManagerWithArrowKeyNavigation"
|
|
130
|
+
{...getFloatingProps()}
|
|
131
|
+
className={classify(css.wrapper, classNames?.wrapper)}
|
|
132
|
+
>
|
|
133
|
+
{clonedChildren}
|
|
134
|
+
</div>
|
|
135
|
+
</FloatingFocusManager>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FocusManagerWithArrowKeyNavigation';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {$ReadOnly} from 'utility-types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type {ColorTypes} from '../../types/typography';
|
|
4
|
+
import classify from '../../utils/classify';
|
|
5
|
+
import type {IconSize, IconType} from '../Icon';
|
|
6
|
+
import {Icon} from '../Icon';
|
|
7
|
+
import css from './FormTitleWrapper.module.css';
|
|
8
|
+
type ClassNames = $ReadOnly<{
|
|
9
|
+
wrapper?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
rightSlot?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type FormTitleWrapperProps = {
|
|
14
|
+
classNames?: ClassNames;
|
|
15
|
+
iconType?: IconType;
|
|
16
|
+
iconName?: string;
|
|
17
|
+
iconSize?: IconSize;
|
|
18
|
+
iconColor?: ColorTypes;
|
|
19
|
+
title: React.ReactNode;
|
|
20
|
+
// Should always atleast have a title
|
|
21
|
+
rightSlot?: React.ReactNode;
|
|
22
|
+
};
|
|
23
|
+
export const FormTitleWrapper: React$AbstractComponent<
|
|
24
|
+
FormTitleWrapperProps,
|
|
25
|
+
HTMLDivElement
|
|
26
|
+
> = React.forwardRef<FormTitleWrapperProps, HTMLDivElement>(
|
|
27
|
+
(
|
|
28
|
+
{
|
|
29
|
+
classNames,
|
|
30
|
+
iconType,
|
|
31
|
+
iconName,
|
|
32
|
+
iconSize = 'small',
|
|
33
|
+
iconColor,
|
|
34
|
+
title,
|
|
35
|
+
rightSlot,
|
|
36
|
+
}: FormTitleWrapperProps,
|
|
37
|
+
ref,
|
|
38
|
+
) => (
|
|
39
|
+
<div ref={ref} data-testid="FormTitleWrapper" className={css.container}>
|
|
40
|
+
<div className={classify(css.leftSection, classNames?.wrapper)}>
|
|
41
|
+
{!!iconName && (
|
|
42
|
+
<Icon
|
|
43
|
+
type={iconType}
|
|
44
|
+
name={iconName}
|
|
45
|
+
size={iconSize}
|
|
46
|
+
color={iconColor}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
{/* This is to safeguard semantics as it internally composes from a subTitleSmall className
|
|
50
|
+
we don't fix the component here as <SubtitleSmall> resolves to <h4> and since title is a React.Node,
|
|
51
|
+
this would break semantics in case custom components are passed inside
|
|
52
|
+
*/}
|
|
53
|
+
<div className={classify(css.componentHousing, classNames?.title)}>
|
|
54
|
+
{title}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div className={classify(css.rightSection, classNames?.rightSlot)}>
|
|
58
|
+
{rightSlot}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormTitleWrapper';
|