@scality/core-ui 0.115.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +17 -0
- package/.eslintrc.json +7 -0
- package/.flowconfig +21 -0
- package/.github/ISSUE_TEMPLATE/bug.md +18 -0
- package/.github/ISSUE_TEMPLATE/improvement.md +18 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- package/.github/workflows/codeql.yaml +25 -0
- package/.github/workflows/dependency-review.yaml +16 -0
- package/.github/workflows/github-pages.yml +17 -0
- package/.github/workflows/post-release.yml +52 -0
- package/.github/workflows/tests.yaml +32 -0
- package/.prettierrc +5 -0
- package/.storybook/main.ts +38 -0
- package/.storybook/manager.ts +6 -0
- package/.storybook/preview-head.html +99 -0
- package/.storybook/preview.js +68 -0
- package/.storybook/public/favicon.ico +0 -0
- package/.storybook/public/logo-core-ui.png +0 -0
- package/.storybook/theme.storybook.ts +13 -0
- package/LICENSE +201 -0
- package/README.md +296 -0
- package/__mocks__/fileMock.js +2 -0
- package/__mocks__/styleMock.js +2 -0
- package/dist/components/IconHelper.d.ts +10 -0
- package/dist/components/IconHelper.d.ts.map +1 -0
- package/dist/components/IconHelper.js +4 -0
- package/dist/components/areachart/AreaChart.component.d.ts +14 -0
- package/dist/components/areachart/AreaChart.component.d.ts.map +1 -0
- package/dist/components/areachart/AreaChart.component.js +27 -0
- package/dist/components/banner/Banner.component.d.ts +11 -0
- package/dist/components/banner/Banner.component.d.ts.map +1 -0
- package/dist/components/banner/Banner.component.js +40 -0
- package/dist/components/barchart/BarChart.component.d.ts +13 -0
- package/dist/components/barchart/BarChart.component.d.ts.map +1 -0
- package/dist/components/barchart/BarChart.component.js +22 -0
- package/dist/components/box/Box.d.ts +9 -0
- package/dist/components/box/Box.d.ts.map +1 -0
- package/dist/components/box/Box.js +21 -0
- package/dist/components/breadcrumb/Breadcrumb.component.d.ts +7 -0
- package/dist/components/breadcrumb/Breadcrumb.component.d.ts.map +1 -0
- package/dist/components/breadcrumb/Breadcrumb.component.js +77 -0
- package/dist/components/button/Button.component.d.ts +28 -0
- package/dist/components/button/Button.component.d.ts.map +1 -0
- package/dist/components/button/Button.component.js +227 -0
- package/dist/components/buttonv2/Buttonv2.component.d.ts +34 -0
- package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -0
- package/dist/components/buttonv2/Buttonv2.component.js +198 -0
- package/dist/components/buttonv2/CopyButton.component.d.ts +24 -0
- package/dist/components/buttonv2/CopyButton.component.d.ts.map +1 -0
- package/dist/components/buttonv2/CopyButton.component.js +52 -0
- package/dist/components/card/Card.component.d.ts +28 -0
- package/dist/components/card/Card.component.d.ts.map +1 -0
- package/dist/components/card/Card.component.js +105 -0
- package/dist/components/checkbox/Checkbox.component.d.ts +10 -0
- package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -0
- package/dist/components/checkbox/Checkbox.component.js +94 -0
- package/dist/components/chips/Chips.component.d.ts +22 -0
- package/dist/components/chips/Chips.component.d.ts.map +1 -0
- package/dist/components/chips/Chips.component.js +105 -0
- package/dist/components/circularprogressbar/CircularProgressBar.component.d.ts +13 -0
- package/dist/components/circularprogressbar/CircularProgressBar.component.d.ts.map +1 -0
- package/dist/components/circularprogressbar/CircularProgressBar.component.js +9 -0
- package/dist/components/circularprogressbar/CircularProgressBar.component.style.d.ts +11 -0
- package/dist/components/circularprogressbar/CircularProgressBar.component.style.d.ts.map +1 -0
- package/dist/components/circularprogressbar/CircularProgressBar.component.style.js +27 -0
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts +11 -0
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts.map +1 -0
- package/dist/components/cloudprogressbar/CloudProgressBar.component.js +38 -0
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts +10 -0
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts.map +1 -0
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.js +44 -0
- package/dist/components/constants.d.ts +27 -0
- package/dist/components/constants.d.ts.map +1 -0
- package/dist/components/constants.js +47 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts +12 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -0
- package/dist/components/constrainedtext/Constrainedtext.component.js +46 -0
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts +9 -0
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -0
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.js +13 -0
- package/dist/components/date/FormattedDateTime.d.ts +11 -0
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -0
- package/dist/components/date/FormattedDateTime.js +66 -0
- package/dist/components/date/FormattedDateTime.spec.d.ts +2 -0
- package/dist/components/date/FormattedDateTime.spec.d.ts.map +1 -0
- package/dist/components/date/FormattedDateTime.spec.js +140 -0
- package/dist/components/date/dateDiffer.d.ts +2 -0
- package/dist/components/date/dateDiffer.d.ts.map +1 -0
- package/dist/components/date/dateDiffer.js +7 -0
- package/dist/components/date/dateDiffer.spec.d.ts +2 -0
- package/dist/components/date/dateDiffer.spec.d.ts.map +1 -0
- package/dist/components/date/dateDiffer.spec.js +6 -0
- package/dist/components/dropdown/Dropdown.component.d.ts +20 -0
- package/dist/components/dropdown/Dropdown.component.d.ts.map +1 -0
- package/dist/components/dropdown/Dropdown.component.js +99 -0
- package/dist/components/dropzone/Dropzone.d.ts +16 -0
- package/dist/components/dropzone/Dropzone.d.ts.map +1 -0
- package/dist/components/dropzone/Dropzone.js +79 -0
- package/dist/components/emptystate/Emptystate.component.d.ts +13 -0
- package/dist/components/emptystate/Emptystate.component.d.ts.map +1 -0
- package/dist/components/emptystate/Emptystate.component.js +32 -0
- package/dist/components/emptytable/Emptytable.component.d.ts +8 -0
- package/dist/components/emptytable/Emptytable.component.d.ts.map +1 -0
- package/dist/components/emptytable/Emptytable.component.js +62 -0
- package/dist/components/error-pages/ErrorPage401.component.d.ts +9 -0
- package/dist/components/error-pages/ErrorPage401.component.d.ts.map +1 -0
- package/dist/components/error-pages/ErrorPage401.component.js +28 -0
- package/dist/components/error-pages/ErrorPage404.component.d.ts +8 -0
- package/dist/components/error-pages/ErrorPage404.component.d.ts.map +1 -0
- package/dist/components/error-pages/ErrorPage404.component.js +26 -0
- package/dist/components/error-pages/ErrorPage500.component.d.ts +13 -0
- package/dist/components/error-pages/ErrorPage500.component.d.ts.map +1 -0
- package/dist/components/error-pages/ErrorPage500.component.js +32 -0
- package/dist/components/error-pages/ErrorPageAuth.component.d.ts +8 -0
- package/dist/components/error-pages/ErrorPageAuth.component.d.ts.map +1 -0
- package/dist/components/error-pages/ErrorPageAuth.component.js +27 -0
- package/dist/components/error-pages/ErrorPageStyle.d.ts +7 -0
- package/dist/components/error-pages/ErrorPageStyle.d.ts.map +1 -0
- package/dist/components/error-pages/ErrorPageStyle.js +34 -0
- package/dist/components/form/Form.component.d.ts +61 -0
- package/dist/components/form/Form.component.d.ts.map +1 -0
- package/dist/components/form/Form.component.js +115 -0
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +20 -0
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +1 -0
- package/dist/components/globalhealthbar/GlobalHealthBar.component.js +169 -0
- package/dist/components/globalhealthbar/tooltip/index.d.ts +8 -0
- package/dist/components/globalhealthbar/tooltip/index.d.ts.map +1 -0
- package/dist/components/globalhealthbar/tooltip/index.js +55 -0
- package/dist/components/healthselectorv2/HealthSelector.component.d.ts +61 -0
- package/dist/components/healthselectorv2/HealthSelector.component.d.ts.map +1 -0
- package/dist/components/healthselectorv2/HealthSelector.component.js +70 -0
- package/dist/components/icon/Icon.component.d.ts +134 -0
- package/dist/components/icon/Icon.component.d.ts.map +1 -0
- package/dist/components/icon/Icon.component.js +209 -0
- package/dist/components/infomessage/InfoMessage.component.d.ts +9 -0
- package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -0
- package/dist/components/infomessage/InfoMessage.component.js +20 -0
- package/dist/components/infomessage/InfoMessageUtils.d.ts +8 -0
- package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -0
- package/dist/components/infomessage/InfoMessageUtils.js +32 -0
- package/dist/components/input/Input.component.d.ts +24 -0
- package/dist/components/input/Input.component.d.ts.map +1 -0
- package/dist/components/input/Input.component.js +55 -0
- package/dist/components/input/Input.component.style.d.ts +9 -0
- package/dist/components/input/Input.component.style.d.ts.map +1 -0
- package/dist/components/input/Input.component.style.js +136 -0
- package/dist/components/inputlist/InputButtons.d.ts +20 -0
- package/dist/components/inputlist/InputButtons.d.ts.map +1 -0
- package/dist/components/inputlist/InputButtons.js +48 -0
- package/dist/components/inputlist/InputList.component.d.ts +27 -0
- package/dist/components/inputlist/InputList.component.d.ts.map +1 -0
- package/dist/components/inputlist/InputList.component.js +30 -0
- package/dist/components/inputv2/inputv2.d.ts +12 -0
- package/dist/components/inputv2/inputv2.d.ts.map +1 -0
- package/dist/components/inputv2/inputv2.js +80 -0
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts +9 -0
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts.map +1 -0
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.js +23 -0
- package/dist/components/layout/Layout.component.d.ts +12 -0
- package/dist/components/layout/Layout.component.d.ts.map +1 -0
- package/dist/components/layout/Layout.component.js +26 -0
- package/dist/components/layout/v2/AppContainer.d.ts +28 -0
- package/dist/components/layout/v2/AppContainer.d.ts.map +1 -0
- package/dist/components/layout/v2/AppContainer.js +63 -0
- package/dist/components/layout/v2/index.d.ts +6 -0
- package/dist/components/layout/v2/index.d.ts.map +1 -0
- package/dist/components/layout/v2/index.js +16 -0
- package/dist/components/layout/v2/panels.d.ts +17 -0
- package/dist/components/layout/v2/panels.d.ts.map +1 -0
- package/dist/components/layout/v2/panels.js +52 -0
- package/dist/components/linechart/LineChart.component.d.ts +22 -0
- package/dist/components/linechart/LineChart.component.d.ts.map +1 -0
- package/dist/components/linechart/LineChart.component.js +109 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts +40 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -0
- package/dist/components/linetemporalchart/ChartUtil.js +126 -0
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +43 -0
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -0
- package/dist/components/linetemporalchart/LineTemporalChart.component.js +576 -0
- package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts +8 -0
- package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts.map +1 -0
- package/dist/components/linetemporalchart/MetricTimespanProvider.js +31 -0
- package/dist/components/linetemporalchart/tooltip/index.d.ts +30 -0
- package/dist/components/linetemporalchart/tooltip/index.d.ts.map +1 -0
- package/dist/components/linetemporalchart/tooltip/index.js +104 -0
- package/dist/components/loader/Loader.component.d.ts +11 -0
- package/dist/components/loader/Loader.component.d.ts.map +1 -0
- package/dist/components/loader/Loader.component.js +41 -0
- package/dist/components/modal/Modal.component.d.ts +13 -0
- package/dist/components/modal/Modal.component.d.ts.map +1 -0
- package/dist/components/modal/Modal.component.js +64 -0
- package/dist/components/multiselect/MultiSelect.component.d.ts +29 -0
- package/dist/components/multiselect/MultiSelect.component.d.ts.map +1 -0
- package/dist/components/multiselect/MultiSelect.component.js +73 -0
- package/dist/components/navbar/Navbar.component.d.ts +23 -0
- package/dist/components/navbar/Navbar.component.d.ts.map +1 -0
- package/dist/components/navbar/Navbar.component.js +151 -0
- package/dist/components/notifications/Notification.component.d.ts +13 -0
- package/dist/components/notifications/Notification.component.d.ts.map +1 -0
- package/dist/components/notifications/Notification.component.js +107 -0
- package/dist/components/notifications/Notifications.component.d.ts +15 -0
- package/dist/components/notifications/Notifications.component.d.ts.map +1 -0
- package/dist/components/notifications/Notifications.component.js +42 -0
- package/dist/components/prettybytes/PrettyBytes.component.d.ts +9 -0
- package/dist/components/prettybytes/PrettyBytes.component.d.ts.map +1 -0
- package/dist/components/prettybytes/PrettyBytes.component.js +24 -0
- package/dist/components/progressbar/ProgressBar.component.d.ts +18 -0
- package/dist/components/progressbar/ProgressBar.component.d.ts.map +1 -0
- package/dist/components/progressbar/ProgressBar.component.js +129 -0
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts +7 -0
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts.map +1 -0
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.js +54 -0
- package/dist/components/searchinput/SearchInput.component.d.ts +12 -0
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -0
- package/dist/components/searchinput/SearchInput.component.js +91 -0
- package/dist/components/select/Select.component.d.ts +15 -0
- package/dist/components/select/Select.component.d.ts.map +1 -0
- package/dist/components/select/Select.component.js +71 -0
- package/dist/components/selectv2/SelectStyle.d.ts +3 -0
- package/dist/components/selectv2/SelectStyle.d.ts.map +1 -0
- package/dist/components/selectv2/SelectStyle.js +238 -0
- package/dist/components/selectv2/Selectv2.component.d.ts +32 -0
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -0
- package/dist/components/selectv2/Selectv2.component.js +267 -0
- package/dist/components/sidebar/Sidebar.component.d.ts +22 -0
- package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -0
- package/dist/components/sidebar/Sidebar.component.js +136 -0
- package/dist/components/spacedbox/SpacedBox.d.ts +34 -0
- package/dist/components/spacedbox/SpacedBox.d.ts.map +1 -0
- package/dist/components/spacedbox/SpacedBox.js +64 -0
- package/dist/components/sparkline/SparkLine.component.d.ts +19 -0
- package/dist/components/sparkline/SparkLine.component.d.ts.map +1 -0
- package/dist/components/sparkline/SparkLine.component.js +148 -0
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts +9 -0
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts.map +1 -0
- package/dist/components/statuswrapper/Statuswrapper.component.js +44 -0
- package/dist/components/steppers/Stepper.component.d.ts +14 -0
- package/dist/components/steppers/Stepper.component.d.ts.map +1 -0
- package/dist/components/steppers/Stepper.component.js +33 -0
- package/dist/components/steppers/Steppers.component.d.ts +18 -0
- package/dist/components/steppers/Steppers.component.d.ts.map +1 -0
- package/dist/components/steppers/Steppers.component.js +96 -0
- package/dist/components/tablev2/MultiSelectableContent.d.ts +22 -0
- package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -0
- package/dist/components/tablev2/MultiSelectableContent.js +129 -0
- package/dist/components/tablev2/Search.d.ts +29 -0
- package/dist/components/tablev2/Search.d.ts.map +1 -0
- package/dist/components/tablev2/Search.js +49 -0
- package/dist/components/tablev2/SearchWithQueryParams.d.ts +7 -0
- package/dist/components/tablev2/SearchWithQueryParams.d.ts.map +1 -0
- package/dist/components/tablev2/SearchWithQueryParams.js +24 -0
- package/dist/components/tablev2/SingleSelectableContent.d.ts +17 -0
- package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -0
- package/dist/components/tablev2/SingleSelectableContent.js +75 -0
- package/dist/components/tablev2/TableCommon.d.ts +24 -0
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -0
- package/dist/components/tablev2/TableCommon.js +35 -0
- package/dist/components/tablev2/TableUtils.d.ts +18 -0
- package/dist/components/tablev2/TableUtils.d.ts.map +1 -0
- package/dist/components/tablev2/TableUtils.js +32 -0
- package/dist/components/tablev2/Tablestyle.d.ts +36 -0
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -0
- package/dist/components/tablev2/Tablestyle.js +136 -0
- package/dist/components/tablev2/Tablev2.component.d.ts +71 -0
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -0
- package/dist/components/tablev2/Tablev2.component.js +144 -0
- package/dist/components/tablev2/react-table-config.d.ts +28 -0
- package/dist/components/tablev2/react-table-config.d.ts.map +1 -0
- package/dist/components/tablev2/react-table-config.js +1 -0
- package/dist/components/tablev2/useCheckbox.d.ts +6 -0
- package/dist/components/tablev2/useCheckbox.d.ts.map +1 -0
- package/dist/components/tablev2/useCheckbox.js +40 -0
- package/dist/components/tablev2/useSyncedScroll.d.ts +7 -0
- package/dist/components/tablev2/useSyncedScroll.d.ts.map +1 -0
- package/dist/components/tablev2/useSyncedScroll.js +43 -0
- package/dist/components/tabsv2/ScrollButton.d.ts +8 -0
- package/dist/components/tabsv2/ScrollButton.d.ts.map +1 -0
- package/dist/components/tabsv2/ScrollButton.js +32 -0
- package/dist/components/tabsv2/StyledTabs.d.ts +18 -0
- package/dist/components/tabsv2/StyledTabs.d.ts.map +1 -0
- package/dist/components/tabsv2/StyledTabs.js +96 -0
- package/dist/components/tabsv2/Tab.d.ts +17 -0
- package/dist/components/tabsv2/Tab.d.ts.map +1 -0
- package/dist/components/tabsv2/Tab.js +10 -0
- package/dist/components/tabsv2/Tabsv2.component.d.ts +21 -0
- package/dist/components/tabsv2/Tabsv2.component.d.ts.map +1 -0
- package/dist/components/tabsv2/Tabsv2.component.js +89 -0
- package/dist/components/tabsv2/useScrollingTabs.d.ts +17 -0
- package/dist/components/tabsv2/useScrollingTabs.d.ts.map +1 -0
- package/dist/components/tabsv2/useScrollingTabs.js +261 -0
- package/dist/components/text/Text.component.d.ts +33 -0
- package/dist/components/text/Text.component.d.ts.map +1 -0
- package/dist/components/text/Text.component.js +154 -0
- package/dist/components/textarea/TextArea.component.d.ts +10 -0
- package/dist/components/textarea/TextArea.component.d.ts.map +1 -0
- package/dist/components/textarea/TextArea.component.js +60 -0
- package/dist/components/textbadge/TextBadge.component.d.ts +9 -0
- package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -0
- package/dist/components/textbadge/TextBadge.component.js +19 -0
- package/dist/components/toast/DurationBasedProgressBar.d.ts +6 -0
- package/dist/components/toast/DurationBasedProgressBar.d.ts.map +1 -0
- package/dist/components/toast/DurationBasedProgressBar.js +24 -0
- package/dist/components/toast/Toast.component.d.ts +20 -0
- package/dist/components/toast/Toast.component.d.ts.map +1 -0
- package/dist/components/toast/Toast.component.js +106 -0
- package/dist/components/toast/ToastPositionHelpers.d.ts +4 -0
- package/dist/components/toast/ToastPositionHelpers.d.ts.map +1 -0
- package/dist/components/toast/ToastPositionHelpers.js +28 -0
- package/dist/components/toast/ToastProvider.d.ts +14 -0
- package/dist/components/toast/ToastProvider.d.ts.map +1 -0
- package/dist/components/toast/ToastProvider.js +18 -0
- package/dist/components/toast/useMutationsHandler.d.ts +40 -0
- package/dist/components/toast/useMutationsHandler.d.ts.map +1 -0
- package/dist/components/toast/useMutationsHandler.js +66 -0
- package/dist/components/toast/useToastParameters.d.ts +10 -0
- package/dist/components/toast/useToastParameters.d.ts.map +1 -0
- package/dist/components/toast/useToastParameters.js +39 -0
- package/dist/components/toggle/Toggle.component.d.ts +11 -0
- package/dist/components/toggle/Toggle.component.d.ts.map +1 -0
- package/dist/components/toggle/Toggle.component.js +80 -0
- package/dist/components/tooltip/Tooltip.component.d.ts +23 -0
- package/dist/components/tooltip/Tooltip.component.d.ts.map +1 -0
- package/dist/components/tooltip/Tooltip.component.js +82 -0
- package/dist/components/vegachart/VegaChart.component.d.ts +14 -0
- package/dist/components/vegachart/VegaChart.component.d.ts.map +1 -0
- package/dist/components/vegachart/VegaChart.component.js +120 -0
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +13 -0
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -0
- package/dist/components/vegachartv2/SyncedCursorCharts.js +17 -0
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts +16 -0
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +1 -0
- package/dist/components/vegachartv2/VegaChartV2.component.js +216 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +19 -0
- package/dist/icons/branding.d.ts +4 -0
- package/dist/icons/branding.d.ts.map +1 -0
- package/dist/icons/branding.js +3 -0
- package/dist/icons/scality-loading.d.ts +4 -0
- package/dist/icons/scality-loading.d.ts.map +1 -0
- package/dist/icons/scality-loading.js +3 -0
- package/dist/index.css +25 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/next.d.ts +15 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +14 -0
- package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts +22 -0
- package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts.map +1 -0
- package/dist/organisms/attachments/AttachmentConfirmationModal.js +142 -0
- package/dist/organisms/attachments/AttachmentTable.d.ts +37 -0
- package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -0
- package/dist/organisms/attachments/AttachmentTable.js +375 -0
- package/dist/organisms/attachments/AttachmentTypes.d.ts +15 -0
- package/dist/organisms/attachments/AttachmentTypes.d.ts.map +1 -0
- package/dist/organisms/attachments/AttachmentTypes.js +5 -0
- package/dist/spacing.d.ts +44 -0
- package/dist/spacing.d.ts.map +1 -0
- package/dist/spacing.js +60 -0
- package/dist/style/fonts/Lato-Bold.woff +0 -0
- package/dist/style/fonts/Lato-Bold.woff2 +0 -0
- package/dist/style/fonts/Lato-Regular.woff +0 -0
- package/dist/style/fonts/Lato-Regular.woff2 +0 -0
- package/dist/style/theme.d.ts +160 -0
- package/dist/style/theme.d.ts.map +1 -0
- package/dist/style/theme.js +234 -0
- package/dist/testUtils.d.ts +9 -0
- package/dist/testUtils.d.ts.map +1 -0
- package/dist/testUtils.js +11 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +46 -0
- package/global-setup.js +3 -0
- package/jest.config.js +8 -0
- package/package.json +161 -0
- package/plop-templates/component.hbs +18 -0
- package/plop-templates/component.test.hbs +10 -0
- package/plop-templates/stories.hbs +18 -0
- package/plopfile.js +38 -0
- package/setupTests.js +3 -0
- package/src/lib/components/IconHelper.tsx +23 -0
- package/src/lib/components/areachart/AreaChart.component.tsx +49 -0
- package/src/lib/components/banner/Banner.component.tsx +59 -0
- package/src/lib/components/barchart/BarChart.component.tsx +46 -0
- package/src/lib/components/box/Box.ts +57 -0
- package/src/lib/components/breadcrumb/Breadcrumb.component.tsx +101 -0
- package/src/lib/components/button/Button.component.tsx +312 -0
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +270 -0
- package/src/lib/components/buttonv2/CopyButton.component.tsx +89 -0
- package/src/lib/components/card/Card.component.tsx +196 -0
- package/src/lib/components/checkbox/Checkbox.component.tsx +131 -0
- package/src/lib/components/chips/Chips.component.tsx +169 -0
- package/src/lib/components/circularprogressbar/CircularProgressBar.component.style.ts +31 -0
- package/src/lib/components/circularprogressbar/CircularProgressBar.component.tsx +58 -0
- package/src/lib/components/cloudprogressbar/CloudProgressBar.component.tsx +105 -0
- package/src/lib/components/collapsiblepanel/CollapsiblePanel.component.tsx +77 -0
- package/src/lib/components/constants.ts +67 -0
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +93 -0
- package/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx +21 -0
- package/src/lib/components/date/FormattedDateTime.spec.tsx +217 -0
- package/src/lib/components/date/FormattedDateTime.tsx +150 -0
- package/src/lib/components/date/dateDiffer.spec.ts +13 -0
- package/src/lib/components/date/dateDiffer.ts +12 -0
- package/src/lib/components/dropdown/Dropdown.component.tsx +184 -0
- package/src/lib/components/dropzone/Dropzone.tsx +181 -0
- package/src/lib/components/emptystate/Emptystate.component.tsx +66 -0
- package/src/lib/components/emptytable/Emptytable.component.tsx +79 -0
- package/src/lib/components/error-pages/ErrorPage401.component.tsx +77 -0
- package/src/lib/components/error-pages/ErrorPage404.component.tsx +64 -0
- package/src/lib/components/error-pages/ErrorPage500.component.tsx +88 -0
- package/src/lib/components/error-pages/ErrorPageAuth.component.tsx +70 -0
- package/src/lib/components/error-pages/ErrorPageStyle.ts +34 -0
- package/src/lib/components/form/Form.component.tsx +416 -0
- package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +201 -0
- package/src/lib/components/globalhealthbar/tooltip/index.ts +72 -0
- package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +62 -0
- package/src/lib/components/healthselectorv2/HealthSelector.component.tsx +103 -0
- package/src/lib/components/icon/Icon.component.tsx +280 -0
- package/src/lib/components/infomessage/InfoMessage.component.tsx +47 -0
- package/src/lib/components/infomessage/InfoMessageUtils.test.tsx +110 -0
- package/src/lib/components/infomessage/InfoMessageUtils.ts +39 -0
- package/src/lib/components/input/Input.component.style.ts +141 -0
- package/src/lib/components/input/Input.component.tsx +174 -0
- package/src/lib/components/inputlist/InputButtons.tsx +111 -0
- package/src/lib/components/inputlist/InputList.component.tsx +98 -0
- package/src/lib/components/inputlist/InputList.test.tsx +102 -0
- package/src/lib/components/inputv2/inputv2.tsx +155 -0
- package/src/lib/components/lateralnavbarlayout/LateralNavbarLayout.component.tsx +38 -0
- package/src/lib/components/layout/Layout.component.tsx +46 -0
- package/src/lib/components/layout/v2/AppContainer.tsx +160 -0
- package/src/lib/components/layout/v2/index.tsx +30 -0
- package/src/lib/components/layout/v2/panels.tsx +105 -0
- package/src/lib/components/linechart/LineChart.component.tsx +152 -0
- package/src/lib/components/linetemporalchart/ChartUtil.test.ts +261 -0
- package/src/lib/components/linetemporalchart/ChartUtil.ts +187 -0
- package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +797 -0
- package/src/lib/components/linetemporalchart/MetricTimespanProvider.tsx +50 -0
- package/src/lib/components/linetemporalchart/tooltip/index.ts +178 -0
- package/src/lib/components/loader/Loader.component.tsx +71 -0
- package/src/lib/components/modal/Modal.component.tsx +121 -0
- package/src/lib/components/multiselect/MultiSelect.component.tsx +158 -0
- package/src/lib/components/navbar/Navbar.component.tsx +238 -0
- package/src/lib/components/notifications/Notification.component.tsx +160 -0
- package/src/lib/components/notifications/Notifications.component.tsx +73 -0
- package/src/lib/components/prettybytes/PrettyBytes.component.tsx +39 -0
- package/src/lib/components/prettybytes/prettybytes.test.tsx +217 -0
- package/src/lib/components/progressbar/ProgressBar.component.tsx +217 -0
- package/src/lib/components/scrollbarwrapper/ScrollbarWrapper.component.tsx +66 -0
- package/src/lib/components/searchinput/SearchInput.component.tsx +146 -0
- package/src/lib/components/select/Select.component.tsx +98 -0
- package/src/lib/components/selectv2/SelectStyle.ts +267 -0
- package/src/lib/components/selectv2/Selectv2.component.tsx +487 -0
- package/src/lib/components/selectv2/selectv2.test.tsx +277 -0
- package/src/lib/components/sidebar/Sidebar.component.tsx +217 -0
- package/src/lib/components/spacedbox/SpacedBox.ts +116 -0
- package/src/lib/components/sparkline/SparkLine.component.tsx +176 -0
- package/src/lib/components/statuswrapper/Statuswrapper.component.tsx +66 -0
- package/src/lib/components/steppers/Stepper.component.d.ts +70 -0
- package/src/lib/components/steppers/Stepper.component.tsx +62 -0
- package/src/lib/components/steppers/Steppers.component.tsx +157 -0
- package/src/lib/components/tablev2/MultiSelectableContent.tsx +318 -0
- package/src/lib/components/tablev2/Search.tsx +112 -0
- package/src/lib/components/tablev2/SearchWithQueryParams.tsx +38 -0
- package/src/lib/components/tablev2/SingleSelectableContent.tsx +222 -0
- package/src/lib/components/tablev2/TableCommon.tsx +102 -0
- package/src/lib/components/tablev2/TableUtils.test.ts +17 -0
- package/src/lib/components/tablev2/TableUtils.ts +60 -0
- package/src/lib/components/tablev2/Tablestyle.tsx +184 -0
- package/src/lib/components/tablev2/Tablev2.component.tsx +316 -0
- package/src/lib/components/tablev2/Tablev2.test.tsx +136 -0
- package/src/lib/components/tablev2/react-table-config.ts +90 -0
- package/src/lib/components/tablev2/useCheckbox.tsx +62 -0
- package/src/lib/components/tablev2/useSyncedScroll.ts +64 -0
- package/src/lib/components/tabsv2/ScrollButton.tsx +39 -0
- package/src/lib/components/tabsv2/StyledTabs.ts +108 -0
- package/src/lib/components/tabsv2/Tab.ts +27 -0
- package/src/lib/components/tabsv2/Tabsv2.component.tsx +247 -0
- package/src/lib/components/tabsv2/useScrollingTabs.ts +335 -0
- package/src/lib/components/text/Text.component.tsx +194 -0
- package/src/lib/components/textarea/TextArea.component.tsx +106 -0
- package/src/lib/components/textbadge/TextBadge.component.tsx +44 -0
- package/src/lib/components/toast/DurationBasedProgressBar.tsx +45 -0
- package/src/lib/components/toast/Toast.component.tsx +181 -0
- package/src/lib/components/toast/ToastPositionHelpers.ts +38 -0
- package/src/lib/components/toast/ToastProvider.tsx +40 -0
- package/src/lib/components/toast/useMutationsHandler.test.tsx +238 -0
- package/src/lib/components/toast/useMutationsHandler.ts +172 -0
- package/src/lib/components/toast/useToastParameters.ts +59 -0
- package/src/lib/components/toggle/Toggle.component.tsx +128 -0
- package/src/lib/components/tooltip/Tooltip.component.tsx +136 -0
- package/src/lib/components/vegachart/VegaChart.component.tsx +146 -0
- package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +30 -0
- package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +279 -0
- package/src/lib/hooks.ts +26 -0
- package/src/lib/icons/branding.tsx +55 -0
- package/src/lib/icons/scality-loading.tsx +118 -0
- package/src/lib/index.css +25 -0
- package/src/lib/index.ts +75 -0
- package/src/lib/next.ts +17 -0
- package/src/lib/organisms/attachments/AttachmentConfirmationModal.tsx +311 -0
- package/src/lib/organisms/attachments/AttachmentTable.tsx +728 -0
- package/src/lib/organisms/attachments/AttachmentTypes.ts +16 -0
- package/src/lib/spacing.tsx +108 -0
- package/src/lib/style/fonts/Lato-Bold.woff +0 -0
- package/src/lib/style/fonts/Lato-Bold.woff2 +0 -0
- package/src/lib/style/fonts/Lato-Regular.woff +0 -0
- package/src/lib/style/fonts/Lato-Regular.woff2 +0 -0
- package/src/lib/style/theme.ts +270 -0
- package/src/lib/testUtils.tsx +18 -0
- package/src/lib/utils.ts +57 -0
- package/stories/Button/button.guideline.mdx +199 -0
- package/stories/Button/button.stories.tsx +299 -0
- package/stories/Icon.mdx +31 -0
- package/stories/InfoMessage/infomessage.guideline.mdx +32 -0
- package/stories/InfoMessage/infomessage.stories.tsx +124 -0
- package/stories/Introduction.mdx +32 -0
- package/stories/Select/select.guideline.mdx +91 -0
- package/stories/Select/selectv2.stories.tsx +169 -0
- package/stories/areachart.stories.tsx +121 -0
- package/stories/banner.stories.tsx +75 -0
- package/stories/barchart.stories.tsx +148 -0
- package/stories/box.stories.tsx +114 -0
- package/stories/breadcrumb.stories.tsx +42 -0
- package/stories/card.stories.tsx +195 -0
- package/stories/checkbox.stories.tsx +63 -0
- package/stories/chips.stories.tsx +107 -0
- package/stories/circularprogressbar.stories.tsx +136 -0
- package/stories/cloudprogressbar.stories.tsx +93 -0
- package/stories/collapsiblepanel.stories.tsx +57 -0
- package/stories/color.mdx +43 -0
- package/stories/common.tsx +39 -0
- package/stories/constrainedtext.stories.tsx +51 -0
- package/stories/controls.ts +59 -0
- package/stories/copybutton.stories.tsx +58 -0
- package/stories/data/areachart.ts +122 -0
- package/stories/data/barchart.ts +1497 -0
- package/stories/data/linechart.ts +1516 -0
- package/stories/data/list.ts +802 -0
- package/stories/data/sparklinechart.ts +164 -0
- package/stories/designprinciples.mdx +29 -0
- package/stories/dropdown.stories.tsx +146 -0
- package/stories/dropzone.stories.tsx +49 -0
- package/stories/emptystate.stories.tsx +22 -0
- package/stories/errorpage401.stories.tsx +25 -0
- package/stories/errorpage404.stories.tsx +24 -0
- package/stories/errorpage500.stories.tsx +44 -0
- package/stories/errorpageauth.stories.tsx +31 -0
- package/stories/form.stories.tsx +255 -0
- package/stories/format.mdx +44 -0
- package/stories/formattedate.stories.tsx +58 -0
- package/stories/globalhealthbar.stories.tsx +171 -0
- package/stories/guideline/chart-guideline.mdx +63 -0
- package/stories/guideline/docs-template.mdx +43 -0
- package/stories/guideline/mdxExampleComponents.tsx +57 -0
- package/stories/healthselectorv2.stories.tsx +74 -0
- package/stories/icon.stories.tsx +146 -0
- package/stories/icons.mdx +108 -0
- package/stories/input.stories.tsx +228 -0
- package/stories/inputlist.stories.tsx +57 -0
- package/stories/lateralnavbarlayout.stories.tsx +127 -0
- package/stories/layout.stories.tsx +378 -0
- package/stories/linechart.stories.tsx +319 -0
- package/stories/linecharttemporal.stories.tsx +88 -0
- package/stories/loader.stories.tsx +49 -0
- package/stories/modal.mdx +17 -0
- package/stories/modal.stories.tsx +177 -0
- package/stories/multiselect.stories.tsx +126 -0
- package/stories/navbar.stories.tsx +156 -0
- package/stories/notifications.stories.tsx +199 -0
- package/stories/pictures/icon-design-system.png +0 -0
- package/stories/prettybytes.stories.tsx +51 -0
- package/stories/progressbar.stories.tsx +174 -0
- package/stories/scrollbar.stories.tsx +76 -0
- package/stories/searchinput.stories.tsx +86 -0
- package/stories/select.stories.tsx +52 -0
- package/stories/selectinput.stories.tsx +73 -0
- package/stories/sidebar.stories.tsx +95 -0
- package/stories/spacing.stories.mdx +50 -0
- package/stories/spacing.stories.tsx +116 -0
- package/stories/sparkline.stories.tsx +85 -0
- package/stories/statuswrapper.stories.tsx +108 -0
- package/stories/stepper.stories.tsx +124 -0
- package/stories/steppers.stories.tsx +115 -0
- package/stories/tablev2.stories.tsx +539 -0
- package/stories/tabsv2.stories.tsx +168 -0
- package/stories/text.stories.tsx +138 -0
- package/stories/textarea.stories.tsx +69 -0
- package/stories/textbadge.stories.tsx +27 -0
- package/stories/toast.stories.tsx +144 -0
- package/stories/toggle.stories.tsx +45 -0
- package/stories/tooltip.stories.tsx +170 -0
- package/stories/typography.mdx +28 -0
- package/stories/vegachart.stories.tsx +98 -0
- package/tsconfig.json +18 -0
- package/types/styled.d.ts +6 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { createContext, useEffect, useState, useCallback } from 'react';
|
|
3
|
+
import { Element, ChildrenArray } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
TabBar,
|
|
6
|
+
ScrollableContainer,
|
|
7
|
+
TabContent,
|
|
8
|
+
TabItem,
|
|
9
|
+
TabsContainer,
|
|
10
|
+
TabsScroller,
|
|
11
|
+
} from './StyledTabs';
|
|
12
|
+
import {
|
|
13
|
+
useHistory,
|
|
14
|
+
useLocation,
|
|
15
|
+
useRouteMatch,
|
|
16
|
+
matchPath,
|
|
17
|
+
Route,
|
|
18
|
+
} from 'react-router-dom';
|
|
19
|
+
import { SecondaryText, BasicText, EmphaseText } from '../text/Text.component';
|
|
20
|
+
import { ScrollButton } from './ScrollButton';
|
|
21
|
+
import { Tab } from './Tab';
|
|
22
|
+
import { TabProps, Query } from './Tab';
|
|
23
|
+
import { useScrollingTabs } from './useScrollingTabs';
|
|
24
|
+
import { ButtonIcon } from '../buttonv2/Buttonv2.component';
|
|
25
|
+
import styled from 'styled-components';
|
|
26
|
+
|
|
27
|
+
type TabsProps = {
|
|
28
|
+
activeTabColor?: string;
|
|
29
|
+
activeTabSeparator?: string;
|
|
30
|
+
tabLineColor?: string;
|
|
31
|
+
inactiveTabColor?: string;
|
|
32
|
+
tabContentColor?: string;
|
|
33
|
+
separatorColor?: string;
|
|
34
|
+
tabHoverColor?: string;
|
|
35
|
+
children: ChildrenArray<Element<typeof Tab>>;
|
|
36
|
+
className?: string;
|
|
37
|
+
};
|
|
38
|
+
export const TabsContext = createContext<boolean>(false);
|
|
39
|
+
|
|
40
|
+
const TabIcon = styled(ButtonIcon)`
|
|
41
|
+
color: ${(props) => props.theme.textSecondary};
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
function Tabs({
|
|
45
|
+
activeTabColor,
|
|
46
|
+
activeTabSeparator,
|
|
47
|
+
tabLineColor,
|
|
48
|
+
inactiveTabColor,
|
|
49
|
+
tabContentColor,
|
|
50
|
+
separatorColor,
|
|
51
|
+
tabHoverColor,
|
|
52
|
+
children,
|
|
53
|
+
className,
|
|
54
|
+
...rest
|
|
55
|
+
}: TabsProps) {
|
|
56
|
+
const location = useLocation();
|
|
57
|
+
const history = useHistory();
|
|
58
|
+
const { url } = useRouteMatch();
|
|
59
|
+
const [selectedTabIndex, setSelectedTabIndex] = useState<
|
|
60
|
+
number | null | undefined
|
|
61
|
+
>(null);
|
|
62
|
+
const queryURL = new URLSearchParams(location.search);
|
|
63
|
+
const filteredTabsChildren = React.Children.toArray(children).filter(
|
|
64
|
+
(child) => React.isValidElement(child) && child.type === Tab,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const matchQuery = useCallback(
|
|
68
|
+
(query: Query): boolean => {
|
|
69
|
+
for (const key of Object.keys(query)) {
|
|
70
|
+
// To support the case of {tab:null}
|
|
71
|
+
if (queryURL.get(key) === null && !query[key]) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!(queryURL.has(key) && queryURL.get(key) === query[key]))
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
},
|
|
81
|
+
[queryURL],
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const serialize = (query?: Query): string => {
|
|
85
|
+
if (!query) {
|
|
86
|
+
return '';
|
|
87
|
+
} else {
|
|
88
|
+
const o = Object.fromEntries(
|
|
89
|
+
Object.entries(query).filter(([_, v]) => v != null),
|
|
90
|
+
);
|
|
91
|
+
//$FlowFixMe
|
|
92
|
+
return '?' + new URLSearchParams(o).toString();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const getPushHistoryPath = (path: string, query?: Query): string => {
|
|
97
|
+
if (path.startsWith('/')) {
|
|
98
|
+
return `${path}${serialize(query)}`;
|
|
99
|
+
}
|
|
100
|
+
return `${url}/${path}${serialize(query)}`;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
let hasSelectedTab = false;
|
|
105
|
+
filteredTabsChildren.forEach((child, index) => {
|
|
106
|
+
const isSelected =
|
|
107
|
+
!!matchPath(location.pathname, {
|
|
108
|
+
path: child.props.path.startsWith('/')
|
|
109
|
+
? child.props.path
|
|
110
|
+
: url + '/' + child.props.path,
|
|
111
|
+
exact: child.props.exact,
|
|
112
|
+
strict: child.props.strict,
|
|
113
|
+
sensitive: child.props.sensitive,
|
|
114
|
+
}) && (child.props.query ? matchQuery(child.props.query) : true);
|
|
115
|
+
|
|
116
|
+
if (isSelected) {
|
|
117
|
+
setSelectedTabIndex(index);
|
|
118
|
+
hasSelectedTab = true;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (!hasSelectedTab) setSelectedTabIndex(null);
|
|
122
|
+
}, [location.pathname, filteredTabsChildren, matchQuery]);
|
|
123
|
+
const {
|
|
124
|
+
scrollButtonEndRef,
|
|
125
|
+
scrollButtonStartRef,
|
|
126
|
+
tabsListRef,
|
|
127
|
+
tabsRef,
|
|
128
|
+
handleStartScrollClick,
|
|
129
|
+
handleEndScrollClick,
|
|
130
|
+
handleTabsScroll,
|
|
131
|
+
handleKeyDown,
|
|
132
|
+
displayScroll,
|
|
133
|
+
} = useScrollingTabs(selectedTabIndex);
|
|
134
|
+
const tabItems = filteredTabsChildren.map((child, index) => {
|
|
135
|
+
const {
|
|
136
|
+
path,
|
|
137
|
+
query,
|
|
138
|
+
label,
|
|
139
|
+
textBadge,
|
|
140
|
+
children,
|
|
141
|
+
icon,
|
|
142
|
+
...childRest
|
|
143
|
+
}: TabProps = child.props;
|
|
144
|
+
const isSelected = selectedTabIndex === index;
|
|
145
|
+
return (
|
|
146
|
+
<TabItem
|
|
147
|
+
className={`sc-tabs-item ${isSelected ? 'selected' : ''}`}
|
|
148
|
+
key={index}
|
|
149
|
+
role="tab"
|
|
150
|
+
onClick={() => history.push(getPushHistoryPath(path, query))}
|
|
151
|
+
selected={isSelected}
|
|
152
|
+
tabHoverColor={tabHoverColor}
|
|
153
|
+
inactiveTabColor={inactiveTabColor}
|
|
154
|
+
activeTabColor={activeTabColor}
|
|
155
|
+
activeTabSeparator={activeTabSeparator}
|
|
156
|
+
tabIndex={isSelected ? 0 : -1}
|
|
157
|
+
onKeyDown={(event) => {
|
|
158
|
+
if (
|
|
159
|
+
event.key === ' ' ||
|
|
160
|
+
event.key === 'Enter' ||
|
|
161
|
+
event.key === 'Spacebar'
|
|
162
|
+
) {
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
history.push(getPushHistoryPath(path, query));
|
|
165
|
+
}
|
|
166
|
+
}}
|
|
167
|
+
{...childRest}
|
|
168
|
+
>
|
|
169
|
+
{icon && <TabIcon label={label}>{icon}</TabIcon>}
|
|
170
|
+
{isSelected ? (
|
|
171
|
+
<BasicText className="sc-tabs-item-title">{label}</BasicText>
|
|
172
|
+
) : (
|
|
173
|
+
<SecondaryText className="sc-tabs-item-title">{label}</SecondaryText>
|
|
174
|
+
)}
|
|
175
|
+
{textBadge && (
|
|
176
|
+
<EmphaseText className="sc-tabs-item-icon">{textBadge}</EmphaseText>
|
|
177
|
+
)}
|
|
178
|
+
</TabItem>
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
return (
|
|
182
|
+
<TabsContext.Provider value={true}>
|
|
183
|
+
<TabsContainer
|
|
184
|
+
className={['sc-tabs', className].join(' ')}
|
|
185
|
+
tabLineColor={tabLineColor}
|
|
186
|
+
separatorColor={separatorColor}
|
|
187
|
+
{...rest}
|
|
188
|
+
>
|
|
189
|
+
<ScrollableContainer>
|
|
190
|
+
{displayScroll.start && (
|
|
191
|
+
<ScrollButton
|
|
192
|
+
ref={scrollButtonStartRef}
|
|
193
|
+
direction="left"
|
|
194
|
+
onClick={handleStartScrollClick}
|
|
195
|
+
/>
|
|
196
|
+
)}
|
|
197
|
+
<TabsScroller ref={tabsRef} onScroll={handleTabsScroll}>
|
|
198
|
+
<TabBar
|
|
199
|
+
onKeyDown={handleKeyDown}
|
|
200
|
+
ref={tabsListRef}
|
|
201
|
+
className="sc-tabs-bar"
|
|
202
|
+
role="tablist"
|
|
203
|
+
>
|
|
204
|
+
{tabItems}
|
|
205
|
+
</TabBar>
|
|
206
|
+
</TabsScroller>
|
|
207
|
+
{displayScroll.end && (
|
|
208
|
+
<ScrollButton
|
|
209
|
+
ref={scrollButtonEndRef}
|
|
210
|
+
direction="right"
|
|
211
|
+
onClick={handleEndScrollClick}
|
|
212
|
+
/>
|
|
213
|
+
)}
|
|
214
|
+
</ScrollableContainer>
|
|
215
|
+
<TabContent
|
|
216
|
+
className="sc-tabs-item-content"
|
|
217
|
+
tabContentColor={tabContentColor}
|
|
218
|
+
>
|
|
219
|
+
{filteredTabsChildren.map((tab: Element<typeof Tab>, index) => (
|
|
220
|
+
<Route
|
|
221
|
+
exact={tab.props.exact}
|
|
222
|
+
sensitive={tab.props.sensitive}
|
|
223
|
+
strict={tab.props.strict}
|
|
224
|
+
key={index}
|
|
225
|
+
path={
|
|
226
|
+
tab.props.path.startsWith('/')
|
|
227
|
+
? tab.props.path
|
|
228
|
+
: url + '/' + tab.props.path
|
|
229
|
+
}
|
|
230
|
+
>
|
|
231
|
+
{!tab.props.query ||
|
|
232
|
+
(tab.props.query && matchQuery(tab.props.query)) ? (
|
|
233
|
+
tab.props.children
|
|
234
|
+
) : (
|
|
235
|
+
<></>
|
|
236
|
+
)}
|
|
237
|
+
</Route>
|
|
238
|
+
))}
|
|
239
|
+
</TabContent>
|
|
240
|
+
</TabsContainer>
|
|
241
|
+
</TabsContext.Provider>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
Tabs.Tab = Tab;
|
|
246
|
+
// re-export Tab
|
|
247
|
+
export { Tabs, Tab };
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The Tabs component uses a lot of the code from Material-UI Scrollable Tabs to have the same behavior as it.
|
|
3
|
+
Here is the license of material-ui:
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2014 Call-Em-All
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
28
|
+
|
|
29
|
+
function easeInOutSin(time: number): number {
|
|
30
|
+
return (1 + Math.sin(Math.PI * time - Math.PI / 2)) / 2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function animate(property: string, element: any, to: number): () => void {
|
|
34
|
+
const duration = 1000; // standard
|
|
35
|
+
|
|
36
|
+
let start: number | null = null;
|
|
37
|
+
const from = element[property];
|
|
38
|
+
let cancelled = false;
|
|
39
|
+
|
|
40
|
+
const cancel = () => {
|
|
41
|
+
cancelled = true;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const step = (timestamp: number) => {
|
|
45
|
+
if (cancelled) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (start === null) {
|
|
50
|
+
start = timestamp;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const time = Math.min(1, (timestamp - start) / duration);
|
|
54
|
+
element[property] = easeInOutSin(time) * (to - from) + from;
|
|
55
|
+
|
|
56
|
+
if (time >= 1) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
requestAnimationFrame(step);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (from === to) {
|
|
64
|
+
return cancel;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
requestAnimationFrame(step);
|
|
68
|
+
return cancel;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const nextItem = (
|
|
72
|
+
list: Element,
|
|
73
|
+
item: Element | null | undefined,
|
|
74
|
+
): Node | null | undefined => {
|
|
75
|
+
if (list === item) {
|
|
76
|
+
return list.firstChild;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (item && item.nextElementSibling) {
|
|
80
|
+
return item.nextElementSibling;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return list.firstChild;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const previousItem = (
|
|
87
|
+
list: Element,
|
|
88
|
+
item: Element | null | undefined,
|
|
89
|
+
): Node | null | undefined => {
|
|
90
|
+
if (list === item) {
|
|
91
|
+
return list.lastChild;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (item && item.previousElementSibling) {
|
|
95
|
+
return item.previousElementSibling;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return list.lastChild;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const moveFocus = (
|
|
102
|
+
list: Element,
|
|
103
|
+
currentFocus: Element | null | undefined,
|
|
104
|
+
traversalFunction: (
|
|
105
|
+
arg0: Element,
|
|
106
|
+
arg1: Element | null | undefined,
|
|
107
|
+
) => Node | null | undefined,
|
|
108
|
+
) => {
|
|
109
|
+
let wrappedOnce = false;
|
|
110
|
+
let nextFocus = traversalFunction(list, currentFocus) as any;
|
|
111
|
+
|
|
112
|
+
while (nextFocus) {
|
|
113
|
+
// Prevent infinite loop.
|
|
114
|
+
if (nextFocus === list.firstChild) {
|
|
115
|
+
if (wrappedOnce) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
wrappedOnce = true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!nextFocus.hasAttribute('tabindex')) {
|
|
123
|
+
// Move to the next element.
|
|
124
|
+
nextFocus = traversalFunction(list, nextFocus) as any;
|
|
125
|
+
} else {
|
|
126
|
+
nextFocus.focus();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const useScrollingTabs = (selectedTabIndex: number | null | undefined) => {
|
|
133
|
+
const [displayScroll, setDisplayScroll] = useState({
|
|
134
|
+
start: false,
|
|
135
|
+
end: false,
|
|
136
|
+
});
|
|
137
|
+
const scrollButtonEndRef = useRef<HTMLDivElement | null | undefined>(null);
|
|
138
|
+
const scrollButtonStartRef = useRef<HTMLDivElement | null | undefined>(null);
|
|
139
|
+
const tabsListRef = useRef<HTMLDivElement>(null);
|
|
140
|
+
const tabsRef = useRef<any>(null);
|
|
141
|
+
|
|
142
|
+
const scroll = (scrollValue: number) => {
|
|
143
|
+
animate('scrollLeft', tabsRef.current, scrollValue);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const moveTabsScroll = (delta) => {
|
|
147
|
+
let scrollValue = tabsRef.current.scrollLeft;
|
|
148
|
+
scrollValue += delta;
|
|
149
|
+
scroll(scrollValue);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const getScrollSize = (isStart = false) => {
|
|
153
|
+
if (!tabsListRef.current) return 0;
|
|
154
|
+
const fullContainerSize = tabsListRef.current.clientWidth;
|
|
155
|
+
const containerSize = tabsRef.current.clientWidth;
|
|
156
|
+
let totalSize = 0;
|
|
157
|
+
const children = Array.from(tabsListRef.current.children);
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
160
|
+
const tab = children[i];
|
|
161
|
+
|
|
162
|
+
if (totalSize + tab.clientWidth > containerSize) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
totalSize += tab.clientWidth;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const cornerChild = isStart ? children[0] : children[children.length - 1];
|
|
170
|
+
|
|
171
|
+
if (
|
|
172
|
+
totalSize +
|
|
173
|
+
tabsRef.current.scrollLeft +
|
|
174
|
+
containerSize +
|
|
175
|
+
cornerChild.clientWidth >
|
|
176
|
+
fullContainerSize
|
|
177
|
+
) {
|
|
178
|
+
totalSize += cornerChild.clientWidth;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return totalSize;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const handleStartScrollClick = () => {
|
|
185
|
+
moveTabsScroll(-1 * getScrollSize(true));
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const handleEndScrollClick = () => {
|
|
189
|
+
moveTabsScroll(getScrollSize(false));
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const getTabsMeta = useCallback(() => {
|
|
193
|
+
const tabsNode = tabsRef.current;
|
|
194
|
+
let tabsMeta;
|
|
195
|
+
|
|
196
|
+
if (tabsNode) {
|
|
197
|
+
const rect = tabsNode.getBoundingClientRect();
|
|
198
|
+
tabsMeta = {
|
|
199
|
+
scrollLeft: tabsNode.scrollLeft,
|
|
200
|
+
left: rect.left,
|
|
201
|
+
right: rect.right,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let selectedTabMeta;
|
|
206
|
+
|
|
207
|
+
if (tabsNode && tabsListRef.current && selectedTabIndex) {
|
|
208
|
+
const children = tabsListRef.current.children;
|
|
209
|
+
|
|
210
|
+
if (children.length > 0) {
|
|
211
|
+
const tab = children[selectedTabIndex];
|
|
212
|
+
selectedTabMeta = tab ? tab.getBoundingClientRect() : null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
tabsMeta,
|
|
218
|
+
selectedTabMeta,
|
|
219
|
+
};
|
|
220
|
+
}, [selectedTabIndex]);
|
|
221
|
+
const scrollSelectedIntoView = useCallback(
|
|
222
|
+
() => {
|
|
223
|
+
const { tabsMeta, selectedTabMeta } = getTabsMeta();
|
|
224
|
+
if (!selectedTabMeta || !tabsMeta) return;
|
|
225
|
+
|
|
226
|
+
if (selectedTabMeta.left < tabsMeta.left) {
|
|
227
|
+
// left side of button is out of view
|
|
228
|
+
const nextScrollStart =
|
|
229
|
+
tabsMeta.scrollLeft + (selectedTabMeta.left - tabsMeta.left);
|
|
230
|
+
scroll(nextScrollStart);
|
|
231
|
+
} else if (selectedTabMeta.right > tabsMeta.right) {
|
|
232
|
+
// right side of button is out of view
|
|
233
|
+
let nextScrollStart =
|
|
234
|
+
tabsMeta.scrollLeft + (selectedTabMeta.right - tabsMeta.right);
|
|
235
|
+
|
|
236
|
+
if (
|
|
237
|
+
scrollButtonEndRef.current &&
|
|
238
|
+
((displayScroll.start && !displayScroll.end) ||
|
|
239
|
+
(!displayScroll.start && displayScroll.end))
|
|
240
|
+
) {
|
|
241
|
+
nextScrollStart +=
|
|
242
|
+
scrollButtonEndRef.current.getBoundingClientRect().width;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
scroll(nextScrollStart);
|
|
246
|
+
}
|
|
247
|
+
}, // we do not want to re-trigger this function if display.start / display.end are modified
|
|
248
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
249
|
+
[getTabsMeta],
|
|
250
|
+
);
|
|
251
|
+
const updateScrollButtonState = useCallback(() => {
|
|
252
|
+
if (tabsRef.current) {
|
|
253
|
+
const { scrollLeft, scrollWidth, clientWidth } = tabsRef.current;
|
|
254
|
+
let showStartScroll = scrollLeft > 1;
|
|
255
|
+
let showEndScroll = scrollLeft < scrollWidth - clientWidth - 1;
|
|
256
|
+
|
|
257
|
+
if (
|
|
258
|
+
showStartScroll !== displayScroll.start ||
|
|
259
|
+
showEndScroll !== displayScroll.end
|
|
260
|
+
) {
|
|
261
|
+
setDisplayScroll({
|
|
262
|
+
start: showStartScroll,
|
|
263
|
+
end: showEndScroll,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}, [displayScroll.end, displayScroll.start]);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
window.addEventListener('resize', updateScrollButtonState);
|
|
270
|
+
return () => {
|
|
271
|
+
window.removeEventListener('resize', updateScrollButtonState);
|
|
272
|
+
};
|
|
273
|
+
}, [updateScrollButtonState]);
|
|
274
|
+
const handleTabsScroll = useMemo(
|
|
275
|
+
() => () => updateScrollButtonState(),
|
|
276
|
+
[updateScrollButtonState],
|
|
277
|
+
);
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
updateScrollButtonState();
|
|
280
|
+
});
|
|
281
|
+
// scroll to selected tab on first render
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
scrollSelectedIntoView();
|
|
284
|
+
}, [scrollSelectedIntoView, selectedTabIndex]);
|
|
285
|
+
|
|
286
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
287
|
+
const list = tabsListRef.current;
|
|
288
|
+
const ownerDocument = (list && list.ownerDocument) || document;
|
|
289
|
+
const currentFocus = ownerDocument.activeElement;
|
|
290
|
+
const role = currentFocus?.getAttribute('role');
|
|
291
|
+
|
|
292
|
+
if (role !== 'tab' || !list) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
switch (event.key) {
|
|
297
|
+
case 'ArrowLeft':
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
moveFocus(list, currentFocus, previousItem);
|
|
300
|
+
break;
|
|
301
|
+
|
|
302
|
+
case 'ArrowRight':
|
|
303
|
+
event.preventDefault();
|
|
304
|
+
moveFocus(list, currentFocus, nextItem);
|
|
305
|
+
break;
|
|
306
|
+
|
|
307
|
+
case 'Home':
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
moveFocus(list, null, nextItem);
|
|
310
|
+
break;
|
|
311
|
+
|
|
312
|
+
case 'End':
|
|
313
|
+
event.preventDefault();
|
|
314
|
+
moveFocus(list, null, previousItem);
|
|
315
|
+
break;
|
|
316
|
+
|
|
317
|
+
default:
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
return {
|
|
323
|
+
scrollButtonStartRef,
|
|
324
|
+
scrollButtonEndRef,
|
|
325
|
+
tabsRef,
|
|
326
|
+
tabsListRef,
|
|
327
|
+
handleKeyDown,
|
|
328
|
+
handleTabsScroll,
|
|
329
|
+
handleStartScrollClick,
|
|
330
|
+
handleEndScrollClick,
|
|
331
|
+
displayScroll,
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export { useScrollingTabs };
|