@spaced-out/ui-design-system 0.4.13-beta.0 → 0.4.13-beta.1
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 +2 -0
- package/CHANGELOG.md +7 -0
- package/cspell.json +3 -1
- package/gulpfile.js +2 -1
- package/lib/styles/index.js +535 -275
- package/package.json +2 -2
- package/lib/components/AIPromptFlow/AIPromptFlow.stories.tsx +0 -465
- package/lib/components/Accordion/Accordion.stories.tsx +0 -165
- package/lib/components/Accordion/Accordion.tsx +0 -112
- package/lib/components/Accordion/AccordionGroup.stories.tsx +0 -215
- package/lib/components/Accordion/AccordionGroup.tsx +0 -77
- package/lib/components/Accordion/index.ts +0 -2
- package/lib/components/Avatar/Avatar.stories.tsx +0 -152
- package/lib/components/Avatar/Avatar.tsx +0 -272
- package/lib/components/Avatar/index.ts +0 -1
- package/lib/components/AvatarGroup/AvatarGroup.stories.tsx +0 -138
- package/lib/components/AvatarGroup/AvatarGroup.tsx +0 -164
- package/lib/components/AvatarGroup/index.ts +0 -1
- package/lib/components/Badge/Badge.stories.tsx +0 -131
- package/lib/components/Badge/Badge.tsx +0 -149
- package/lib/components/Badge/index.ts +0 -1
- package/lib/components/BadgedIcon/BadgedIcon.stories.tsx +0 -80
- package/lib/components/BadgedIcon/BadgedIcon.tsx +0 -76
- package/lib/components/BadgedIcon/index.ts +0 -1
- package/lib/components/Banner/Banner.stories.tsx +0 -187
- package/lib/components/Banner/Banner.tsx +0 -55
- package/lib/components/Banner/index.ts +0 -1
- package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.stories.tsx +0 -114
- package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.tsx +0 -52
- package/lib/components/Breadcrumbs/BreadcrumbLink/index.ts +0 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.tsx +0 -189
- package/lib/components/Breadcrumbs/Breadcrumbs.tsx +0 -59
- package/lib/components/Breadcrumbs/index.ts +0 -2
- package/lib/components/Button/Button.stories.tsx +0 -220
- package/lib/components/Button/Button.tsx +0 -285
- package/lib/components/Button/index.ts +0 -8
- package/lib/components/ButtonDropdown/ButtonDropdown.stories.tsx +0 -677
- package/lib/components/ButtonDropdown/ButtonDropdown.tsx +0 -221
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.stories.tsx +0 -624
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.tsx +0 -167
- package/lib/components/ButtonDropdown/index.ts +0 -2
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.stories.tsx +0 -125
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.tsx +0 -76
- package/lib/components/ButtonTabs/ButtonTab/index.ts +0 -1
- package/lib/components/ButtonTabs/ButtonTabDropdown.tsx +0 -147
- package/lib/components/ButtonTabs/ButtonTabs.stories.tsx +0 -393
- package/lib/components/ButtonTabs/ButtonTabs.tsx +0 -119
- package/lib/components/ButtonTabs/index.ts +0 -2
- package/lib/components/Card/Card.stories.tsx +0 -245
- package/lib/components/Card/Card.tsx +0 -172
- package/lib/components/Card/index.ts +0 -1
- package/lib/components/Charts/ChartTooltip/index.ts +0 -13
- package/lib/components/Charts/ChartWrapper/ChartWrapper.tsx +0 -179
- package/lib/components/Charts/ChartWrapper/index.ts +0 -1
- package/lib/components/Charts/ColumnChart/ColumnChart.stories.tsx +0 -574
- package/lib/components/Charts/ColumnChart/ColumnChart.tsx +0 -125
- package/lib/components/Charts/ColumnChart/index.ts +0 -1
- package/lib/components/Charts/DonutChart/DonutChart.stories.tsx +0 -415
- package/lib/components/Charts/DonutChart/DonutChart.tsx +0 -155
- package/lib/components/Charts/DonutChart/index.ts +0 -1
- package/lib/components/Charts/FunnelChart/FunnelChart.stories.tsx +0 -510
- package/lib/components/Charts/FunnelChart/FunnelChart.tsx +0 -110
- package/lib/components/Charts/FunnelChart/index.ts +0 -1
- package/lib/components/Charts/LineChart/LineChart.stories.tsx +0 -590
- package/lib/components/Charts/LineChart/LineChart.tsx +0 -109
- package/lib/components/Charts/LineChart/index.ts +0 -1
- package/lib/components/Charts/SpiderChart/SpiderChart.stories.tsx +0 -467
- package/lib/components/Charts/SpiderChart/SpiderChart.tsx +0 -104
- package/lib/components/Charts/SpiderChart/index.ts +0 -1
- package/lib/components/Charts/index.ts +0 -11
- package/lib/components/ChatBubble/ChatAnchor.stories.tsx +0 -95
- package/lib/components/ChatBubble/ChatBubble.stories.tsx +0 -277
- package/lib/components/ChatBubble/ChatBubble.tsx +0 -232
- package/lib/components/ChatBubble/index.ts +0 -1
- package/lib/components/Checkbox/Checkbox.stories.tsx +0 -180
- package/lib/components/Checkbox/Checkbox.tsx +0 -168
- package/lib/components/Checkbox/CheckboxGroup.stories.tsx +0 -381
- package/lib/components/Checkbox/CheckboxGroup.tsx +0 -119
- package/lib/components/Checkbox/index.ts +0 -2
- package/lib/components/Chip/Chip.stories.tsx +0 -335
- package/lib/components/Chip/Chip.tsx +0 -204
- package/lib/components/Chip/index.ts +0 -2
- package/lib/components/CircularLoader/CircularLoader.stories.tsx +0 -75
- package/lib/components/CircularLoader/CircularLoader.tsx +0 -51
- package/lib/components/CircularLoader/index.ts +0 -1
- package/lib/components/CollapsibleCard/CollapsibleCard.stories.tsx +0 -311
- package/lib/components/CollapsibleCard/CollapsibleCard.tsx +0 -135
- package/lib/components/CollapsibleCard/index.ts +0 -1
- package/lib/components/Combobox/Combobox.stories.tsx +0 -306
- package/lib/components/Combobox/Combobox.tsx +0 -297
- package/lib/components/Combobox/helper.ts +0 -201
- package/lib/components/Combobox/index.ts +0 -1
- package/lib/components/ConditionalWrapper/ConditionalWrapper.stories.tsx +0 -51
- package/lib/components/ConditionalWrapper/ConditionalWrapper.ts +0 -16
- package/lib/components/ConditionalWrapper/index.ts +0 -1
- package/lib/components/DateRangePicker/Calendar.tsx +0 -110
- package/lib/components/DateRangePicker/DateRangePicker.stories.tsx +0 -397
- package/lib/components/DateRangePicker/DateRangePicker.tsx +0 -210
- package/lib/components/DateRangePicker/DateRangeWrapper.tsx +0 -386
- package/lib/components/DateRangePicker/Day.tsx +0 -74
- package/lib/components/DateRangePicker/index.ts +0 -1
- package/lib/components/Dialog/Dialog.stories.tsx +0 -254
- package/lib/components/Dialog/Dialog.tsx +0 -222
- package/lib/components/Dialog/index.ts +0 -1
- package/lib/components/Disclaimer/Disclaimer.stories.tsx +0 -148
- package/lib/components/Disclaimer/Disclaimer.tsx +0 -35
- package/lib/components/Disclaimer/index.ts +0 -1
- package/lib/components/Dropdown/Dropdown.stories.tsx +0 -785
- package/lib/components/Dropdown/Dropdown.tsx +0 -174
- package/lib/components/Dropdown/SimpleDropdown.stories.tsx +0 -534
- package/lib/components/Dropdown/SimpleDropdown.tsx +0 -167
- package/lib/components/Dropdown/index.ts +0 -2
- package/lib/components/EmptyState/EmptyImages/CalendarEmptyImage.tsx +0 -108
- package/lib/components/EmptyState/EmptyImages/ChartEmptyImage.tsx +0 -194
- package/lib/components/EmptyState/EmptyImages/DataEmptyImage.tsx +0 -116
- package/lib/components/EmptyState/EmptyImages/FileEmptyImage.tsx +0 -133
- package/lib/components/EmptyState/EmptyImages/MessageEmptyImage.tsx +0 -64
- package/lib/components/EmptyState/EmptyImages/UploadEmptyImage.tsx +0 -67
- package/lib/components/EmptyState/EmptyImages/index.ts +0 -6
- package/lib/components/EmptyState/EmptyState.stories.tsx +0 -104
- package/lib/components/EmptyState/EmptyState.tsx +0 -83
- package/lib/components/EmptyState/index.ts +0 -1
- package/lib/components/ErrorMessage/ErrorImages/ForbiddenImage.tsx +0 -85
- package/lib/components/ErrorMessage/ErrorImages/NotFoundImage.tsx +0 -117
- package/lib/components/ErrorMessage/ErrorImages/ServerErrorImage.tsx +0 -237
- package/lib/components/ErrorMessage/ErrorImages/UnauthorizedImage.tsx +0 -73
- package/lib/components/ErrorMessage/ErrorImages/index.ts +0 -4
- package/lib/components/ErrorMessage/ErrorMessage.stories.tsx +0 -112
- package/lib/components/ErrorMessage/ErrorMessage.tsx +0 -87
- package/lib/components/ErrorMessage/index.ts +0 -1
- package/lib/components/FileUpload/FileBlock/FileBlock.stories.tsx +0 -85
- package/lib/components/FileUpload/FileBlock/FileBlock.tsx +0 -136
- package/lib/components/FileUpload/FileBlock/index.ts +0 -1
- package/lib/components/FileUpload/FileUpload.stories.tsx +0 -958
- package/lib/components/FileUpload/FileUpload.tsx +0 -206
- package/lib/components/FileUpload/index.ts +0 -2
- package/lib/components/FilterButtonOverlay/FilterButtonOverlay.stories.tsx +0 -345
- package/lib/components/FilterButtonOverlay/FilterButtonOverlay.tsx +0 -163
- package/lib/components/FilterButtonOverlay/index.ts +0 -1
- package/lib/components/FocusManager/FocusManager.stories.tsx +0 -117
- package/lib/components/FocusManager/FocusManager.tsx +0 -59
- package/lib/components/FocusManager/index.ts +0 -1
- package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.stories.tsx +0 -557
- package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.tsx +0 -156
- package/lib/components/FocusManagerWithArrowKeyNavigation/index.ts +0 -1
- package/lib/components/FormTitleWrapper/FormTitleWrapper.stories.tsx +0 -173
- package/lib/components/FormTitleWrapper/FormTitleWrapper.tsx +0 -63
- package/lib/components/FormTitleWrapper/index.ts +0 -1
- package/lib/components/Grid/Col.stories.tsx +0 -114
- package/lib/components/Grid/Grid.tsx +0 -119
- package/lib/components/Grid/GridPatterns.stories.tsx +0 -420
- package/lib/components/Grid/Row.stories.tsx +0 -135
- package/lib/components/Grid/Tablist.layout.stories.tsx +0 -281
- package/lib/components/Grid/index.ts +0 -1
- package/lib/components/Icon/ClickableIcon.tsx +0 -104
- package/lib/components/Icon/Icon.docs.ts +0 -118
- package/lib/components/Icon/Icon.stories.tsx +0 -79
- package/lib/components/Icon/Icon.tsx +0 -78
- package/lib/components/Icon/SemanticIcon.stories.tsx +0 -74
- package/lib/components/Icon/SemanticIcon.tsx +0 -49
- package/lib/components/Icon/index.ts +0 -3
- package/lib/components/InContextAlert/InContextAlert.stories.tsx +0 -164
- package/lib/components/InContextAlert/InContextAlert.tsx +0 -204
- package/lib/components/InContextAlert/index.ts +0 -1
- package/lib/components/InfinitePagination/InfinitePagination.stories.tsx +0 -323
- package/lib/components/InfinitePagination/InfinitePagination.tsx +0 -121
- package/lib/components/InfinitePagination/index.ts +0 -1
- package/lib/components/InlineDropdown/InlineDropdown.stories.tsx +0 -415
- package/lib/components/InlineDropdown/InlineDropdown.tsx +0 -175
- package/lib/components/InlineDropdown/SimpleInlineDropdown.stories.tsx +0 -513
- package/lib/components/InlineDropdown/SimpleInlineDropdown.tsx +0 -165
- package/lib/components/InlineDropdown/index.ts +0 -2
- package/lib/components/Input/Input.stories.tsx +0 -590
- package/lib/components/Input/Input.tsx +0 -336
- package/lib/components/Input/NativeColorpicker.stories.tsx +0 -337
- package/lib/components/Input/NativeDatepicker.stories.tsx +0 -424
- package/lib/components/Input/index.ts +0 -1
- package/lib/components/KPIBox/KPIBox.stories.tsx +0 -321
- package/lib/components/KPIBox/KPIBox.tsx +0 -94
- package/lib/components/KPIBox/index.ts +0 -1
- package/lib/components/LinearLoader/LinearLoader.stories.tsx +0 -132
- package/lib/components/LinearLoader/LinearLoader.tsx +0 -48
- package/lib/components/LinearLoader/index.ts +0 -1
- package/lib/components/Link/Link.stories.tsx +0 -302
- package/lib/components/Link/Link.tsx +0 -231
- package/lib/components/Link/index.ts +0 -1
- package/lib/components/Menu/Menu.stories.tsx +0 -1046
- package/lib/components/Menu/Menu.tsx +0 -391
- package/lib/components/Menu/MenuOptionButton.tsx +0 -206
- package/lib/components/Menu/index.ts +0 -2
- package/lib/components/Modal/Modal.stories.tsx +0 -430
- package/lib/components/Modal/Modal.tsx +0 -379
- package/lib/components/Modal/index.ts +0 -8
- package/lib/components/Notification/Notification.stories.tsx +0 -132
- package/lib/components/Notification/Notification.tsx +0 -140
- package/lib/components/Notification/index.ts +0 -1
- package/lib/components/OptionButton/OptionButton.stories.tsx +0 -397
- package/lib/components/OptionButton/OptionButton.tsx +0 -149
- package/lib/components/OptionButton/SimpleOptionButton.stories.tsx +0 -525
- package/lib/components/OptionButton/SimpleOptionButton.tsx +0 -160
- package/lib/components/OptionButton/index.ts +0 -2
- package/lib/components/PageTitle/PageTitle.stories.tsx +0 -257
- package/lib/components/PageTitle/PageTitle.tsx +0 -276
- package/lib/components/PageTitle/index.ts +0 -1
- package/lib/components/Pagination/Pagination.stories.tsx +0 -259
- package/lib/components/Pagination/Pagination.tsx +0 -147
- package/lib/components/Pagination/PaginationItem.tsx +0 -118
- package/lib/components/Pagination/index.ts +0 -1
- package/lib/components/Panel/Panel.stories.tsx +0 -452
- package/lib/components/Panel/Panel.tsx +0 -181
- package/lib/components/Panel/index.ts +0 -2
- package/lib/components/ProgressDonut/ProgressDonut.stories.tsx +0 -97
- package/lib/components/ProgressDonut/ProgressDonut.tsx +0 -111
- package/lib/components/ProgressDonut/index.ts +0 -1
- package/lib/components/PromptChip/PromptChip.stories.tsx +0 -202
- package/lib/components/PromptChip/PromptChip.tsx +0 -166
- package/lib/components/PromptChip/index.ts +0 -1
- package/lib/components/PromptInput/PromptInput.stories.tsx +0 -349
- package/lib/components/PromptInput/PromptInput.tsx +0 -190
- package/lib/components/PromptInput/index.ts +0 -1
- package/lib/components/RadioButton/RadioButton.stories.tsx +0 -157
- package/lib/components/RadioButton/RadioButton.tsx +0 -135
- package/lib/components/RadioButton/RadioGroup.stories.tsx +0 -283
- package/lib/components/RadioButton/RadioGroup.tsx +0 -90
- package/lib/components/RadioButton/index.ts +0 -2
- package/lib/components/RadioTile/RadioTile.stories.tsx +0 -276
- package/lib/components/RadioTile/RadioTile.tsx +0 -107
- package/lib/components/RadioTile/index.ts +0 -1
- package/lib/components/RangeSlider/RangeSlider.stories.tsx +0 -342
- package/lib/components/RangeSlider/RangeSlider.tsx +0 -201
- package/lib/components/RangeSlider/index.ts +0 -1
- package/lib/components/Rating/Rating.stories.tsx +0 -257
- package/lib/components/Rating/Rating.tsx +0 -141
- package/lib/components/Rating/index.ts +0 -1
- package/lib/components/ScoreBar/ScoreBar.stories.tsx +0 -182
- package/lib/components/ScoreBar/ScoreBar.tsx +0 -133
- package/lib/components/ScoreBar/index.ts +0 -1
- package/lib/components/SearchInput/SearchInput.stories.tsx +0 -260
- package/lib/components/SearchInput/SearchInput.tsx +0 -81
- package/lib/components/SearchInput/index.ts +0 -2
- package/lib/components/Separator/Separator.stories.tsx +0 -95
- package/lib/components/Separator/Separator.tsx +0 -57
- package/lib/components/Separator/index.ts +0 -1
- package/lib/components/Shimmer/Shimmer.stories.tsx +0 -317
- package/lib/components/Shimmer/Shimmer.tsx +0 -143
- package/lib/components/Shimmer/index.ts +0 -1
- package/lib/components/SideMenuLink/SideMenuLink.stories.tsx +0 -153
- package/lib/components/SideMenuLink/SideMenuLink.tsx +0 -344
- package/lib/components/SideMenuLink/index.ts +0 -1
- package/lib/components/StatusIndicator/StatusIndicator.stories.tsx +0 -130
- package/lib/components/StatusIndicator/StatusIndicator.tsx +0 -62
- package/lib/components/StatusIndicator/index.ts +0 -1
- package/lib/components/Stepper/Step/Step.stories.tsx +0 -117
- package/lib/components/Stepper/Step/Step.tsx +0 -125
- package/lib/components/Stepper/Step/StepContent.tsx +0 -40
- package/lib/components/Stepper/Step/StepLabel.tsx +0 -40
- package/lib/components/Stepper/Step/index.ts +0 -3
- package/lib/components/Stepper/Stepper.stories.tsx +0 -422
- package/lib/components/Stepper/Stepper.tsx +0 -68
- package/lib/components/Stepper/index.ts +0 -2
- package/lib/components/StickyBar/StickyBar.stories.tsx +0 -152
- package/lib/components/StickyBar/StickyBar.tsx +0 -65
- package/lib/components/StickyBar/index.ts +0 -1
- package/lib/components/SubMenu/SubMenu.stories.tsx +0 -413
- package/lib/components/SubMenu/SubMenu.tsx +0 -96
- package/lib/components/SubMenu/SubMenuGroup.tsx +0 -161
- package/lib/components/SubMenu/SubMenuItem.tsx +0 -170
- package/lib/components/SubMenu/SubMenuLink.tsx +0 -87
- package/lib/components/SubMenu/index.ts +0 -4
- package/lib/components/Table/BasicTable.stories.tsx +0 -647
- package/lib/components/Table/BulkActions.stories.tsx +0 -267
- package/lib/components/Table/Cell.tsx +0 -125
- package/lib/components/Table/DefaultRow.tsx +0 -159
- package/lib/components/Table/DefaultTableHeader.tsx +0 -244
- package/lib/components/Table/InlineEdit.stories.tsx +0 -390
- package/lib/components/Table/StaticTable.tsx +0 -230
- package/lib/components/Table/Table.docs.ts +0 -495
- package/lib/components/Table/Table.tsx +0 -135
- package/lib/components/Table/TableActionBar.tsx +0 -55
- package/lib/components/Table/TableBottomBar.tsx +0 -25
- package/lib/components/Table/TableTopBar.tsx +0 -25
- package/lib/components/Table/dummyTableData.ts +0 -2189
- package/lib/components/Table/hooks.ts +0 -102
- package/lib/components/Table/index.ts +0 -8
- package/lib/components/Tabs/Tab/Tab.stories.tsx +0 -151
- package/lib/components/Tabs/Tab/Tab.tsx +0 -152
- package/lib/components/Tabs/Tab/index.ts +0 -1
- package/lib/components/Tabs/TabList/TabDropdown.tsx +0 -125
- package/lib/components/Tabs/TabList/TabList.stories.tsx +0 -172
- package/lib/components/Tabs/TabList/TabList.tsx +0 -178
- package/lib/components/Tabs/TabList/index.ts +0 -1
- package/lib/components/Tabs/index.ts +0 -2
- package/lib/components/Text/HighlightedText.stories.tsx +0 -122
- package/lib/components/Text/Text.stories.tsx +0 -302
- package/lib/components/Text/Text.tsx +0 -882
- package/lib/components/Text/index.ts +0 -30
- package/lib/components/TextTile/TextTile.stories.tsx +0 -89
- package/lib/components/TextTile/TextTile.tsx +0 -51
- package/lib/components/TextTile/index.ts +0 -1
- package/lib/components/Textarea/Textarea.stories.tsx +0 -324
- package/lib/components/Textarea/Textarea.tsx +0 -148
- package/lib/components/Textarea/index.ts +0 -2
- package/lib/components/Timeline/Timeline.stories.tsx +0 -272
- package/lib/components/Timeline/Timeline.tsx +0 -57
- package/lib/components/Timeline/TimelineItem/TimelineItem.stories.tsx +0 -216
- package/lib/components/Timeline/TimelineItem/TimelineItem.tsx +0 -128
- package/lib/components/Timeline/TimelineItem/index.ts +0 -1
- package/lib/components/Timeline/index.ts +0 -2
- package/lib/components/Toast/Toast.stories.tsx +0 -274
- package/lib/components/Toast/Toast.tsx +0 -264
- package/lib/components/Toast/ToastContainer.tsx +0 -123
- package/lib/components/Toast/ToastManager.ts +0 -60
- package/lib/components/Toast/index.ts +0 -10
- package/lib/components/Toggle/Toggle.stories.tsx +0 -175
- package/lib/components/Toggle/Toggle.tsx +0 -121
- package/lib/components/Toggle/index.ts +0 -1
- package/lib/components/TokenListInput/TokenListInput.stories.tsx +0 -678
- package/lib/components/TokenListInput/TokenListInput.tsx +0 -393
- package/lib/components/TokenListInput/TokenValueChips.tsx +0 -69
- package/lib/components/TokenListInput/index.ts +0 -1
- package/lib/components/Tooltip/Tooltip.stories.tsx +0 -316
- package/lib/components/Tooltip/Tooltip.tsx +0 -188
- package/lib/components/Tooltip/index.ts +0 -1
- package/lib/components/Truncate/Truncate.stories.tsx +0 -106
- package/lib/components/Truncate/Truncate.tsx +0 -80
- package/lib/components/Truncate/index.ts +0 -2
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.stories.tsx +0 -147
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.tsx +0 -109
- package/lib/components/TruncatedTextWithTooltip/index.ts +0 -1
- package/lib/components/Typeahead/SimpleTypeahead.stories.tsx +0 -567
- package/lib/components/Typeahead/SimpleTypeahead.tsx +0 -159
- package/lib/components/Typeahead/Typeahead.stories.tsx +0 -552
- package/lib/components/Typeahead/Typeahead.tsx +0 -243
- package/lib/components/Typeahead/index.ts +0 -2
- package/lib/components/WeekdayPicker/WeekdayPicker.stories.tsx +0 -263
- package/lib/components/WeekdayPicker/WeekdayPicker.tsx +0 -224
- package/lib/components/WeekdayPicker/index.ts +0 -1
- package/lib/components/index.ts +0 -77
- package/lib/hooks/index.ts +0 -16
- package/lib/hooks/useArbitraryOptionAddition/index.ts +0 -1
- package/lib/hooks/useArbitraryOptionAddition/useArbitraryOptionAddition.stories.tsx +0 -158
- package/lib/hooks/useArbitraryOptionAddition/useArbitraryOptionAddition.ts +0 -127
- package/lib/hooks/useCopyToClipboard/index.ts +0 -1
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.stories.tsx +0 -112
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.ts +0 -29
- package/lib/hooks/useDebounce/index.ts +0 -1
- package/lib/hooks/useDebounce/useDebounce.stories.tsx +0 -82
- package/lib/hooks/useDebounce/useDebounce.ts +0 -15
- package/lib/hooks/useFileUpload/index.ts +0 -1
- package/lib/hooks/useFileUpload/useFileUpload.stories.tsx +0 -468
- package/lib/hooks/useFileUpload/useFileUpload.ts +0 -326
- package/lib/hooks/useFilteredOptions/index.ts +0 -1
- package/lib/hooks/useFilteredOptions/useFilteredOptions.stories.tsx +0 -142
- package/lib/hooks/useFilteredOptions/useFilteredOptions.ts +0 -92
- package/lib/hooks/useInfiniteScroll/index.ts +0 -1
- package/lib/hooks/useInfiniteScroll/useInfiniteScroll.ts +0 -85
- package/lib/hooks/useInputState/index.ts +0 -1
- package/lib/hooks/useInputState/useInputState.stories.tsx +0 -62
- package/lib/hooks/useInputState/useInputState.ts +0 -24
- package/lib/hooks/useLockedBody/index.ts +0 -1
- package/lib/hooks/useLockedBody/useLockedBody.stories.tsx +0 -71
- package/lib/hooks/useLockedBody/useLockedBody.ts +0 -53
- package/lib/hooks/useModal/index.ts +0 -1
- package/lib/hooks/useModal/useModal.stories.tsx +0 -134
- package/lib/hooks/useModal/useModal.ts +0 -36
- package/lib/hooks/useMountTransition/index.ts +0 -25
- package/lib/hooks/useMountTransition/useMountTransition.stories.tsx +0 -64
- package/lib/hooks/usePagination/index.ts +0 -1
- package/lib/hooks/usePagination/usePagination.stories.tsx +0 -72
- package/lib/hooks/usePagination/usePagination.ts +0 -151
- package/lib/hooks/useReferenceElementWidth/index.ts +0 -1
- package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.ts +0 -19
- package/lib/hooks/useResizeObserver/index.ts +0 -1
- package/lib/hooks/useResizeObserver/useResizeObserver.ts +0 -29
- package/lib/hooks/useToastPortal/index.ts +0 -1
- package/lib/hooks/useToastPortal/useToastPortal.ts +0 -34
- package/lib/hooks/useToggle/index.ts +0 -1
- package/lib/hooks/useToggle/useToggle.stories.tsx +0 -70
- package/lib/hooks/useToggle/useToggle.ts +0 -13
- package/lib/hooks/useWindowSize/index.ts +0 -1
- package/lib/hooks/useWindowSize/useWindowSize.stories.tsx +0 -62
- package/lib/hooks/useWindowSize/useWindowSize.ts +0 -39
- package/lib/index.ts +0 -6
- package/lib/styles/index.ts +0 -533
- package/lib/styles/variables/_border.ts +0 -23
- package/lib/styles/variables/_color.ts +0 -207
- package/lib/styles/variables/_elevation.ts +0 -13
- package/lib/styles/variables/_font.ts +0 -59
- package/lib/styles/variables/_motion.ts +0 -11
- package/lib/styles/variables/_opacity.ts +0 -29
- package/lib/styles/variables/_shadow.ts +0 -47
- package/lib/styles/variables/_size.ts +0 -113
- package/lib/styles/variables/_space.ts +0 -23
- package/lib/types/charts.ts +0 -247
- package/lib/types/common.ts +0 -11
- package/lib/types/cssvariables.d.ts +0 -8
- package/lib/types/date-range-picker.ts +0 -20
- package/lib/types/flow-to-typescript-codemod.d.ts +0 -48
- package/lib/types/global.d.ts +0 -84
- package/lib/types/index.ts +0 -6
- package/lib/types/menu.ts +0 -13
- package/lib/types/toast.ts +0 -34
- package/lib/types/typography.ts +0 -17
- package/lib/utils/array/are-arrays-equal.ts +0 -12
- package/lib/utils/array/index.ts +0 -1
- package/lib/utils/charts/charts.ts +0 -110
- package/lib/utils/charts/columnChart.ts +0 -62
- package/lib/utils/charts/donutChart.ts +0 -123
- package/lib/utils/charts/funnelChart.ts +0 -97
- package/lib/utils/charts/helpers.ts +0 -65
- package/lib/utils/charts/index.ts +0 -7
- package/lib/utils/charts/lineChart.ts +0 -51
- package/lib/utils/charts/spiderChart.ts +0 -57
- package/lib/utils/charts/typography.ts +0 -52
- package/lib/utils/classify/classify.stories.tsx +0 -65
- package/lib/utils/classify/index.ts +0 -27
- package/lib/utils/click-away/ClickAway.stories.tsx +0 -248
- package/lib/utils/click-away/click-away.ts +0 -230
- package/lib/utils/click-away/index.ts +0 -1
- package/lib/utils/date-range-picker/date-range-picker.ts +0 -430
- package/lib/utils/date-range-picker/index.ts +0 -2
- package/lib/utils/date-range-picker/timezones.ts +0 -263
- package/lib/utils/dom/dom.stories.tsx +0 -59
- package/lib/utils/dom/dom.ts +0 -247
- package/lib/utils/dom/index.ts +0 -1
- package/lib/utils/helpers/helpers.stories.tsx +0 -124
- package/lib/utils/helpers/helpers.ts +0 -51
- package/lib/utils/helpers/index.ts +0 -1
- package/lib/utils/index.ts +0 -14
- package/lib/utils/makeClassNameComponent/index.ts +0 -1
- package/lib/utils/makeClassNameComponent/makeClassNameComponent.stories.tsx +0 -46
- package/lib/utils/makeClassNameComponent/makeClassNameComponent.tsx +0 -60
- package/lib/utils/menu/index.ts +0 -1
- package/lib/utils/menu/menu.ts +0 -174
- package/lib/utils/merge-refs/index.ts +0 -1
- package/lib/utils/merge-refs/merge-refs.stories.tsx +0 -92
- package/lib/utils/merge-refs/merge-refs.ts +0 -16
- package/lib/utils/rating/index.ts +0 -1
- package/lib/utils/rating/rating.ts +0 -30
- package/lib/utils/score-bar/index.ts +0 -1
- package/lib/utils/score-bar/score-bar.ts +0 -45
- package/lib/utils/string/index.ts +0 -1
- package/lib/utils/string/string.stories.tsx +0 -71
- package/lib/utils/string/string.ts +0 -26
- package/lib/utils/token-list-input/token-list-input.ts +0 -32
- package/lib/utils/tokens/index.ts +0 -1
- package/lib/utils/tokens/tokens.ts +0 -237
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import type {PaginationBaseProps, PaginationItemProps} from '../../components/Pagination';
|
|
2
|
-
import {range} from '../../utils/helpers';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const usePagination = (props: PaginationBaseProps): {
|
|
6
|
-
items: PaginationItemProps[] | null | undefined;
|
|
7
|
-
} => {
|
|
8
|
-
const {
|
|
9
|
-
boundaryCount = 1,
|
|
10
|
-
totalPages = 1,
|
|
11
|
-
disabled = false,
|
|
12
|
-
hideNextButton = false,
|
|
13
|
-
hidePrevButton = false,
|
|
14
|
-
onChange: handleChange,
|
|
15
|
-
currentPage = 1,
|
|
16
|
-
showFirstButton = false,
|
|
17
|
-
showLastButton = false,
|
|
18
|
-
siblingCount = 1,
|
|
19
|
-
style = 'primary',
|
|
20
|
-
} = props;
|
|
21
|
-
|
|
22
|
-
let itemList: Array<never> | Array<string> | Array<number | string> = [];
|
|
23
|
-
|
|
24
|
-
const handleClick = (event: React.SyntheticEvent<HTMLElement>, value: null | number) => {
|
|
25
|
-
if (handleChange) {
|
|
26
|
-
handleChange(value, event);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const startPages = range(1, Math.min(boundaryCount, totalPages));
|
|
31
|
-
const endPages = range(
|
|
32
|
-
Math.max(totalPages - boundaryCount + 1, boundaryCount + 1),
|
|
33
|
-
totalPages,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const siblingsStart = Math.max(
|
|
37
|
-
Math.min(
|
|
38
|
-
// Natural start
|
|
39
|
-
currentPage - siblingCount,
|
|
40
|
-
// Lower boundary when currentPage is high
|
|
41
|
-
totalPages - boundaryCount - siblingCount * 2 - 1,
|
|
42
|
-
),
|
|
43
|
-
// Greater than startPages
|
|
44
|
-
boundaryCount + 2,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const siblingsEnd = Math.min(
|
|
48
|
-
Math.max(
|
|
49
|
-
// Natural end
|
|
50
|
-
currentPage + siblingCount,
|
|
51
|
-
// Upper boundary when currentPage is low
|
|
52
|
-
boundaryCount + siblingCount * 2 + 2,
|
|
53
|
-
),
|
|
54
|
-
// Less than endPages
|
|
55
|
-
endPages.length > 0 ? endPages[0] - 2 : totalPages - 1,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
// Basic list of items to render
|
|
59
|
-
// For primary style: itemList = ['first', 'previous', 1, 'start-ellipsis', 4, 5, 6, 'end-ellipsis', 10, 'next', 'last']
|
|
60
|
-
// For secondary style: itemList = ['first', 'previous', 'next', 'last']
|
|
61
|
-
if (style === 'primary') {
|
|
62
|
-
itemList = [
|
|
63
|
-
...(showFirstButton ? ['first'] : []),
|
|
64
|
-
...(hidePrevButton ? [] : ['previous']),
|
|
65
|
-
...startPages,
|
|
66
|
-
|
|
67
|
-
// Start ellipsis
|
|
68
|
-
// eslint-disable-next-line no-nested-ternary
|
|
69
|
-
...(siblingsStart > boundaryCount + 2
|
|
70
|
-
? ['start-ellipsis']
|
|
71
|
-
: boundaryCount + 1 < totalPages - boundaryCount
|
|
72
|
-
? [boundaryCount + 1]
|
|
73
|
-
: []),
|
|
74
|
-
|
|
75
|
-
// Sibling pages
|
|
76
|
-
...range(siblingsStart, siblingsEnd),
|
|
77
|
-
|
|
78
|
-
// End ellipsis
|
|
79
|
-
// eslint-disable-next-line no-nested-ternary
|
|
80
|
-
...(siblingsEnd < totalPages - boundaryCount - 1
|
|
81
|
-
? ['end-ellipsis']
|
|
82
|
-
: totalPages - boundaryCount > boundaryCount
|
|
83
|
-
? [totalPages - boundaryCount]
|
|
84
|
-
: []),
|
|
85
|
-
|
|
86
|
-
...endPages,
|
|
87
|
-
...(hideNextButton ? [] : ['next']),
|
|
88
|
-
...(showLastButton ? ['last'] : []),
|
|
89
|
-
];
|
|
90
|
-
} else if (style === 'secondary') {
|
|
91
|
-
itemList = [
|
|
92
|
-
...(showFirstButton ? ['first'] : []),
|
|
93
|
-
...(hidePrevButton ? [] : ['previous']),
|
|
94
|
-
...(hideNextButton ? [] : ['next']),
|
|
95
|
-
...(showLastButton ? ['last'] : []),
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Map the button type to its page number
|
|
100
|
-
const buttonPage = (type: string) => {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case 'first':
|
|
103
|
-
return 1;
|
|
104
|
-
case 'previous':
|
|
105
|
-
return currentPage - 1;
|
|
106
|
-
case 'next':
|
|
107
|
-
return currentPage + 1;
|
|
108
|
-
case 'last':
|
|
109
|
-
return totalPages;
|
|
110
|
-
default:
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// Convert the basic item list to contain PaginationItem props objects
|
|
116
|
-
const items = itemList.map((item, idx) =>
|
|
117
|
-
typeof item === 'number'
|
|
118
|
-
? {
|
|
119
|
-
id: idx.toString(),
|
|
120
|
-
// @ts-ignore - TS7006 - Parameter 'event' implicitly has an 'any' type.
|
|
121
|
-
onClick: (event) => {
|
|
122
|
-
handleClick(event, item);
|
|
123
|
-
},
|
|
124
|
-
type: 'page',
|
|
125
|
-
page: item,
|
|
126
|
-
selected: item === currentPage,
|
|
127
|
-
disabled,
|
|
128
|
-
}
|
|
129
|
-
: {
|
|
130
|
-
id: idx.toString(),
|
|
131
|
-
// @ts-ignore - TS7006 - Parameter 'event' implicitly has an 'any' type.
|
|
132
|
-
onClick: (event) => {
|
|
133
|
-
handleClick(event, buttonPage(item));
|
|
134
|
-
},
|
|
135
|
-
type: item,
|
|
136
|
-
page: buttonPage(item),
|
|
137
|
-
selected: false,
|
|
138
|
-
disabled:
|
|
139
|
-
disabled ||
|
|
140
|
-
(item.indexOf('ellipsis') === -1 &&
|
|
141
|
-
(item === 'next' || item === 'last'
|
|
142
|
-
? currentPage >= totalPages
|
|
143
|
-
: currentPage <= 1)),
|
|
144
|
-
},
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
// @ts-ignore - TS2322 - Type '{ id: string; onClick: (event: any) => void; type: string; page: number | null; selected: boolean; disabled: boolean; }[]' is not assignable to type 'PaginationItemProps[]'.
|
|
149
|
-
items,
|
|
150
|
-
};
|
|
151
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useReferenceElementWidth';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import {sizeFluid} from '../../styles/variables/_size';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const MIN_FLUID_WIDTH = 160;
|
|
7
|
-
|
|
8
|
-
export function useReferenceElementWidth(ref?: HTMLElement | null, minWidth: number = MIN_FLUID_WIDTH): string {
|
|
9
|
-
const [width, setWidth] = React.useState(sizeFluid);
|
|
10
|
-
|
|
11
|
-
const refWidth = ref?.offsetWidth;
|
|
12
|
-
React.useLayoutEffect(() => {
|
|
13
|
-
if (refWidth) {
|
|
14
|
-
setWidth(Math.max(refWidth, minWidth) + 'px');
|
|
15
|
-
}
|
|
16
|
-
}, [refWidth, minWidth]);
|
|
17
|
-
|
|
18
|
-
return width;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useResizeObserver';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function useResizeObserver(): [React.Ref<'div'>, number] {
|
|
5
|
-
const ref = React.useRef(null);
|
|
6
|
-
const [height, setHeight] = React.useState(0);
|
|
7
|
-
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
const node = ref.current;
|
|
10
|
-
if (!node) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// @ts-ignore - TS2345 - Argument of type '([entry]: [any]) => void' is not assignable to parameter of type 'ResizeObserverCallback'.
|
|
15
|
-
const resizeObserver = new ResizeObserver(([entry]: [any]) => {
|
|
16
|
-
setHeight(entry.contentRect.height);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
resizeObserver.observe(node);
|
|
20
|
-
// @ts-ignore - TS2339 - Property 'getBoundingClientRect' does not exist on type 'never'.
|
|
21
|
-
setHeight(node.getBoundingClientRect().height);
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
resizeObserver.disconnect();
|
|
25
|
-
};
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
return [ref, height];
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useToastPortal';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {useEffect, useState} from 'react';
|
|
2
|
-
|
|
3
|
-
import {elevationToast} from '../../styles/variables/_elevation';
|
|
4
|
-
import {spaceMedium} from '../../styles/variables/_space';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type UseToastPortal = {
|
|
8
|
-
toastRef: {
|
|
9
|
-
current: HTMLDivElement | null;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const useToastPortal = (
|
|
14
|
-
{
|
|
15
|
-
toastRef,
|
|
16
|
-
}: UseToastPortal,
|
|
17
|
-
): {
|
|
18
|
-
loaded: boolean;
|
|
19
|
-
} => {
|
|
20
|
-
const [loaded, setLoaded] = useState(false);
|
|
21
|
-
|
|
22
|
-
// @ts-ignore - TS2345 - Argument of type '() => () => HTMLDivElement' is not assignable to parameter of type 'EffectCallback'.
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const div = document.createElement('div');
|
|
25
|
-
|
|
26
|
-
// @ts-ignore - TS2540 - Cannot assign to 'style' because it is a read-only property.
|
|
27
|
-
div.style = `position: fixed; bottom: ${spaceMedium}; left: ${spaceMedium}; z-index: ${elevationToast};`;
|
|
28
|
-
document.body.prepend(div);
|
|
29
|
-
toastRef.current = div;
|
|
30
|
-
setLoaded(true);
|
|
31
|
-
return () => document.body.removeChild(div);
|
|
32
|
-
}, []);
|
|
33
|
-
return {loaded};
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useToggle';
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {Button} from '../../components/Button';
|
|
4
|
-
import {BodyLarge} from '../../components/Text';
|
|
5
|
-
|
|
6
|
-
import {useToggle} from './useToggle';
|
|
7
|
-
|
|
8
|
-
import css from './useToggle.stories.module.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
tags: ['autodocs'],
|
|
13
|
-
title: 'Hooks/useToggle',
|
|
14
|
-
component: useToggle,
|
|
15
|
-
parameters: {
|
|
16
|
-
docs: {
|
|
17
|
-
description: {
|
|
18
|
-
component: `
|
|
19
|
-
\`\`\`js
|
|
20
|
-
import { useToggle } from "@spaced-out/ui-design-system/lib/hooks/useToggle";
|
|
21
|
-
\`\`\`
|
|
22
|
-
The \`useToggle\` hook is a custom hook that provides a boolean state value and a function to toggle its value between true and false.
|
|
23
|
-
|
|
24
|
-
### Props Accepted
|
|
25
|
-
- \`initialState\` (optional): The initial state value. Defaults to false.
|
|
26
|
-
|
|
27
|
-
### Props Returned
|
|
28
|
-
- \`stateValue\`: The current state value.
|
|
29
|
-
- \`toggle\`: A function to toggle the state value.
|
|
30
|
-
|
|
31
|
-
### Usage
|
|
32
|
-
\`\`\`jsx
|
|
33
|
-
import { useToggle } from './useToggle';
|
|
34
|
-
|
|
35
|
-
const MyComponent = () => {
|
|
36
|
-
const [isActive, toggleActive] = useToggle(false);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div>
|
|
40
|
-
<button onClick={toggleActive}>
|
|
41
|
-
Toggle
|
|
42
|
-
</button>
|
|
43
|
-
{isActive && <BodyLarge>Active</BodyLarge>}
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default MyComponent;
|
|
49
|
-
\`\`\`
|
|
50
|
-
`,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Example = (): React.ReactElement<React.ComponentProps<'div'>> => {
|
|
57
|
-
const [isActive, toggleActive] = useToggle(false);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div>
|
|
61
|
-
{}
|
|
62
|
-
{ /* @ts-ignore - TS2769 - No overload matches this call. */}
|
|
63
|
-
<Button className={css.button} onClick={toggleActive}>
|
|
64
|
-
Toggle
|
|
65
|
-
</Button>
|
|
66
|
-
{isActive && <BodyLarge className={css.text}>Active</BodyLarge>}
|
|
67
|
-
{!isActive && <BodyLarge className={css.text}>InActive</BodyLarge>}
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {useCallback, useState} from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function useToggle(initialState: boolean = false): [boolean, (newValue: boolean) => void] {
|
|
5
|
-
// Initialize the state
|
|
6
|
-
const [stateValue, setStateValue] = useState(initialState);
|
|
7
|
-
|
|
8
|
-
// Define and memorize toggle function in case we pass down the component,
|
|
9
|
-
// This function change the boolean value to it's opposite value
|
|
10
|
-
const toggle = useCallback(() => setStateValue((state) => !state), []);
|
|
11
|
-
|
|
12
|
-
return [stateValue, toggle];
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useWindowSize';
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {BodyLarge} from '../../components/Text';
|
|
4
|
-
|
|
5
|
-
import {useWindowSize} from './useWindowSize';
|
|
6
|
-
|
|
7
|
-
import css from './useWindowSize.stories.module.css';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
tags: ['autodocs'],
|
|
12
|
-
title: 'Hooks/useWindowSize',
|
|
13
|
-
component: useWindowSize,
|
|
14
|
-
parameters: {
|
|
15
|
-
docs: {
|
|
16
|
-
description: {
|
|
17
|
-
component: `
|
|
18
|
-
\`\`\`js
|
|
19
|
-
import { useWindowSize } from "@spaced-out/ui-design-system/lib/hooks/useWindowSize";
|
|
20
|
-
\`\`\`
|
|
21
|
-
The \`useWindowSize\` hook is a custom hook that provides the current dimensions of the window as an object with the \`width\` and \`height\` properties.
|
|
22
|
-
|
|
23
|
-
### Props Returned
|
|
24
|
-
- \`windowSize\`: An object containing the current dimensions of the window.
|
|
25
|
-
|
|
26
|
-
### Usage
|
|
27
|
-
\`\`\`jsx
|
|
28
|
-
import { useWindowSize } from './useWindowSize';
|
|
29
|
-
|
|
30
|
-
const MyComponent = () => {
|
|
31
|
-
const windowSize = useWindowSize();
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
<BodyLarge>Window Width: {windowSize.width}px</BodyLarge>
|
|
36
|
-
<BodyLarge>Window Height: {windowSize.height}px</BodyLarge>
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default MyComponent;
|
|
42
|
-
\`\`\`
|
|
43
|
-
`,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Example = (): React.ReactElement<React.ComponentProps<'div'>> => {
|
|
50
|
-
const windowSize = useWindowSize();
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<div>
|
|
54
|
-
<BodyLarge className={css.text}>
|
|
55
|
-
Window Width: {windowSize.width}px
|
|
56
|
-
</BodyLarge>
|
|
57
|
-
<BodyLarge className={css.text}>
|
|
58
|
-
Window Height: {windowSize.height}px
|
|
59
|
-
</BodyLarge>
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {useEffect, useState} from 'react';
|
|
2
|
-
import {throttle} from 'lodash';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type WindowSize = {
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const THROTTLE_DURATION = 200;
|
|
11
|
-
|
|
12
|
-
export function useWindowSize(): WindowSize {
|
|
13
|
-
const [windowSize, setWindowSize] = useState<WindowSize>({
|
|
14
|
-
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
15
|
-
height: typeof window !== 'undefined' ? window.innerHeight : 0,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const updateSize = throttle(() => {
|
|
20
|
-
const {innerWidth, innerHeight} = window;
|
|
21
|
-
setWindowSize((prevSize) => {
|
|
22
|
-
if (prevSize.width !== innerWidth || prevSize.height !== innerHeight) {
|
|
23
|
-
return {width: innerWidth, height: innerHeight};
|
|
24
|
-
}
|
|
25
|
-
return prevSize;
|
|
26
|
-
});
|
|
27
|
-
}, THROTTLE_DURATION);
|
|
28
|
-
|
|
29
|
-
window.addEventListener('resize', updateSize);
|
|
30
|
-
updateSize();
|
|
31
|
-
|
|
32
|
-
return () => {
|
|
33
|
-
window.removeEventListener('resize', updateSize);
|
|
34
|
-
updateSize.cancel();
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
return windowSize;
|
|
39
|
-
}
|
package/lib/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './components';
|
|
2
|
-
export * from './hooks';
|
|
3
|
-
export * from './styles';
|
|
4
|
-
// @ts-ignore - TS2308 - Module './components' has already exported a member named 'Breadcrumbs'. Consider explicitly re-exporting to resolve the ambiguity. | TS2308 - Module './components' has already exported a member named 'Tooltip'. Consider explicitly re-exporting to resolve the ambiguity.
|
|
5
|
-
export * from './types';
|
|
6
|
-
export * from './utils';
|