@canonical/react-components 1.3.0 → 1.3.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/dist-esm/components/Accordion/Accordion.js +52 -0
- package/dist-esm/components/Accordion/AccordionSection/AccordionSection.js +47 -0
- package/dist-esm/components/Accordion/AccordionSection/index.js +1 -0
- package/dist-esm/components/Accordion/index.js +1 -0
- package/dist-esm/components/ActionButton/ActionButton.js +106 -0
- package/dist-esm/components/ActionButton/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/AppAside/AppAside.js +29 -0
- package/dist-esm/components/ApplicationLayout/AppAside/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/AppMain/AppMain.js +21 -0
- package/dist-esm/components/ApplicationLayout/AppMain/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/AppNavigation/AppNavigation.js +31 -0
- package/dist-esm/components/ApplicationLayout/AppNavigation/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.js +24 -0
- package/dist-esm/components/ApplicationLayout/AppNavigationBar/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/AppStatus/AppStatus.js +21 -0
- package/dist-esm/components/ApplicationLayout/AppStatus/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/Application/Application.js +22 -0
- package/dist-esm/components/ApplicationLayout/Application/index.js +1 -0
- package/dist-esm/components/ApplicationLayout/ApplicationLayout.js +113 -0
- package/dist-esm/components/ApplicationLayout/index.js +7 -0
- package/dist-esm/components/ArticlePagination/ArticlePagination.js +39 -0
- package/dist-esm/components/ArticlePagination/index.js +1 -0
- package/dist-esm/components/Badge/Badge.js +64 -0
- package/dist-esm/components/Badge/index.js +1 -0
- package/dist-esm/components/Button/Button.js +55 -0
- package/dist-esm/components/Button/index.js +1 -0
- package/dist-esm/components/Card/Card.js +45 -0
- package/dist-esm/components/Card/index.js +1 -0
- package/dist-esm/components/CheckboxInput/CheckableInput/CheckableInput.js +35 -0
- package/dist-esm/components/CheckboxInput/CheckableInput/index.js +1 -0
- package/dist-esm/components/CheckboxInput/CheckboxInput.js +24 -0
- package/dist-esm/components/CheckboxInput/index.js +1 -0
- package/dist-esm/components/Chip/Chip.js +81 -0
- package/dist-esm/components/Chip/index.js +1 -0
- package/dist-esm/components/Code/Code.js +49 -0
- package/dist-esm/components/Code/index.js +1 -0
- package/dist-esm/components/CodeSnippet/CodeSnippet.js +28 -0
- package/dist-esm/components/CodeSnippet/CodeSnippetBlock.js +64 -0
- package/dist-esm/components/CodeSnippet/CodeSnippetDropdown.js +27 -0
- package/dist-esm/components/CodeSnippet/index.js +2 -0
- package/dist-esm/components/Col/Col.js +38 -0
- package/dist-esm/components/Col/index.js +1 -0
- package/dist-esm/components/ConfirmationButton/ConfirmationButton.js +63 -0
- package/dist-esm/components/ConfirmationButton/index.js +1 -0
- package/dist-esm/components/ConfirmationModal/ConfirmationModal.js +47 -0
- package/dist-esm/components/ConfirmationModal/index.js +1 -0
- package/dist-esm/components/ContextualMenu/ContextualMenu.js +215 -0
- package/dist-esm/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +249 -0
- package/dist-esm/components/ContextualMenu/ContextualMenuDropdown/index.js +1 -0
- package/dist-esm/components/ContextualMenu/index.js +1 -0
- package/dist-esm/components/EmptyState/EmptyState.js +28 -0
- package/dist-esm/components/EmptyState/index.js +1 -0
- package/dist-esm/components/Field/Field.js +126 -0
- package/dist-esm/components/Field/index.js +1 -0
- package/dist-esm/components/Form/Form.js +28 -0
- package/dist-esm/components/Form/index.js +1 -0
- package/dist-esm/components/FormikField/FormikField.js +33 -0
- package/dist-esm/components/FormikField/index.js +1 -0
- package/dist-esm/components/Icon/Icon.js +61 -0
- package/dist-esm/components/Icon/index.js +1 -0
- package/dist-esm/components/Input/Input.js +103 -0
- package/dist-esm/components/Input/index.js +1 -0
- package/dist-esm/components/Label/Label.js +27 -0
- package/dist-esm/components/Label/index.js +1 -0
- package/dist-esm/components/Link/Link.js +37 -0
- package/dist-esm/components/Link/index.js +1 -0
- package/dist-esm/components/List/List.js +110 -0
- package/dist-esm/components/List/index.js +1 -0
- package/dist-esm/components/Loader/Loader.js +14 -0
- package/dist-esm/components/Loader/index.js +1 -0
- package/dist-esm/components/LoginPageLayout/LoginPageLayout.js +63 -0
- package/dist-esm/components/LoginPageLayout/index.js +1 -0
- package/dist-esm/components/MainTable/MainTable.js +211 -0
- package/dist-esm/components/MainTable/index.js +1 -0
- package/dist-esm/components/Modal/Modal.js +135 -0
- package/dist-esm/components/Modal/index.js +1 -0
- package/dist-esm/components/ModularTable/ModularTable.js +166 -0
- package/dist-esm/components/ModularTable/index.js +1 -0
- package/dist-esm/components/MultiSelect/FadeInDown/FadeInDown.js +25 -0
- package/dist-esm/components/MultiSelect/FadeInDown/index.js +1 -0
- package/dist-esm/components/MultiSelect/MultiSelect.js +308 -0
- package/dist-esm/components/MultiSelect/index.js +1 -0
- package/dist-esm/components/Navigation/Navigation.js +215 -0
- package/dist-esm/components/Navigation/NavigationLink/NavigationLink.js +58 -0
- package/dist-esm/components/Navigation/NavigationLink/index.js +1 -0
- package/dist-esm/components/Navigation/NavigationMenu/NavigationMenu.js +57 -0
- package/dist-esm/components/Navigation/NavigationMenu/index.js +1 -0
- package/dist-esm/components/Navigation/index.js +1 -0
- package/dist-esm/components/Navigation/types.js +1 -0
- package/dist-esm/components/Notification/Notification.js +119 -0
- package/dist-esm/components/Notification/index.js +1 -0
- package/dist-esm/components/NotificationProvider/NotificationProvider.js +83 -0
- package/dist-esm/components/NotificationProvider/index.js +2 -0
- package/dist-esm/components/NotificationProvider/messageBuilder.js +31 -0
- package/dist-esm/components/NotificationProvider/types.js +1 -0
- package/dist-esm/components/Pagination/Pagination.js +173 -0
- package/dist-esm/components/Pagination/PaginationButton/PaginationButton.js +31 -0
- package/dist-esm/components/Pagination/PaginationButton/index.js +1 -0
- package/dist-esm/components/Pagination/PaginationItem/PaginationItem.js +20 -0
- package/dist-esm/components/Pagination/PaginationItem/index.js +1 -0
- package/dist-esm/components/Pagination/index.js +1 -0
- package/dist-esm/components/Panel/Panel.js +89 -0
- package/dist-esm/components/Panel/index.js +1 -0
- package/dist-esm/components/PasswordToggle/PasswordToggle.js +90 -0
- package/dist-esm/components/PasswordToggle/index.js +1 -0
- package/dist-esm/components/RadioInput/RadioInput.js +22 -0
- package/dist-esm/components/RadioInput/index.js +1 -0
- package/dist-esm/components/Row/Row.js +22 -0
- package/dist-esm/components/Row/index.js +1 -0
- package/dist-esm/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +107 -0
- package/dist-esm/components/SearchAndFilter/FilterPanelSection/index.js +1 -0
- package/dist-esm/components/SearchAndFilter/SearchAndFilter.js +286 -0
- package/dist-esm/components/SearchAndFilter/index.js +1 -0
- package/dist-esm/components/SearchAndFilter/types.js +1 -0
- package/dist-esm/components/SearchAndFilter/utils.js +22 -0
- package/dist-esm/components/SearchBox/SearchBox.js +95 -0
- package/dist-esm/components/SearchBox/index.js +1 -0
- package/dist-esm/components/Select/Select.js +84 -0
- package/dist-esm/components/Select/index.js +1 -0
- package/dist-esm/components/SideNavigation/SideNavigation.js +89 -0
- package/dist-esm/components/SideNavigation/SideNavigationBase/SideNavigationBase.js +31 -0
- package/dist-esm/components/SideNavigation/SideNavigationBase/index.js +1 -0
- package/dist-esm/components/SideNavigation/SideNavigationItem/SideNavigationItem.js +32 -0
- package/dist-esm/components/SideNavigation/SideNavigationItem/index.js +1 -0
- package/dist-esm/components/SideNavigation/SideNavigationLink/SideNavigationLink.js +25 -0
- package/dist-esm/components/SideNavigation/SideNavigationLink/index.js +1 -0
- package/dist-esm/components/SideNavigation/SideNavigationText/SideNavigationText.js +20 -0
- package/dist-esm/components/SideNavigation/SideNavigationText/index.js +1 -0
- package/dist-esm/components/SideNavigation/index.js +4 -0
- package/dist-esm/components/Slider/Slider.js +83 -0
- package/dist-esm/components/Slider/index.js +1 -0
- package/dist-esm/components/Spinner/Spinner.js +36 -0
- package/dist-esm/components/Spinner/index.js +1 -0
- package/dist-esm/components/StatusLabel/StatusLabel.js +36 -0
- package/dist-esm/components/StatusLabel/index.js +1 -0
- package/dist-esm/components/Strip/Strip.js +50 -0
- package/dist-esm/components/Strip/index.js +1 -0
- package/dist-esm/components/SummaryButton/SummaryButton.js +28 -0
- package/dist-esm/components/SummaryButton/index.js +1 -0
- package/dist-esm/components/Switch/Switch.js +28 -0
- package/dist-esm/components/Switch/index.js +1 -0
- package/dist-esm/components/Table/Table.js +23 -0
- package/dist-esm/components/Table/index.js +1 -0
- package/dist-esm/components/TableCell/TableCell.js +26 -0
- package/dist-esm/components/TableCell/index.js +1 -0
- package/dist-esm/components/TableHeader/TableHeader.js +17 -0
- package/dist-esm/components/TableHeader/index.js +1 -0
- package/dist-esm/components/TablePagination/TablePagination.js +104 -0
- package/dist-esm/components/TablePagination/TablePaginationControls/TablePaginationControls.js +120 -0
- package/dist-esm/components/TablePagination/TablePaginationControls/index.js +1 -0
- package/dist-esm/components/TablePagination/index.js +1 -0
- package/dist-esm/components/TablePagination/utils.js +67 -0
- package/dist-esm/components/TableRow/TableRow.js +15 -0
- package/dist-esm/components/TableRow/index.js +1 -0
- package/dist-esm/components/Tabs/Tabs.js +42 -0
- package/dist-esm/components/Tabs/index.js +1 -0
- package/dist-esm/components/Textarea/Textarea.js +115 -0
- package/dist-esm/components/Textarea/index.js +1 -0
- package/dist-esm/components/Tooltip/Tooltip.js +245 -0
- package/dist-esm/components/Tooltip/index.js +1 -0
- package/dist-esm/enums.js +8 -0
- package/dist-esm/hooks/index.js +8 -0
- package/dist-esm/hooks/useId.js +13 -0
- package/dist-esm/hooks/useListener.js +51 -0
- package/dist-esm/hooks/useOnClickOutside.js +38 -0
- package/dist-esm/hooks/useOnEscapePressed.js +25 -0
- package/dist-esm/hooks/usePagination.js +45 -0
- package/dist-esm/hooks/usePrevious.js +16 -0
- package/dist-esm/hooks/useThrottle.js +49 -0
- package/dist-esm/hooks/useWindowFitment.js +109 -0
- package/dist-esm/index.js +69 -0
- package/dist-esm/types/index.js +1 -0
- package/dist-esm/types/react-table-config.d.js +1 -0
- package/dist-esm/utils.js +41 -0
- package/dist-types/components/Accordion/Accordion.d.ts +46 -0
- package/dist-types/components/Accordion/AccordionSection/AccordionSection.d.ts +34 -0
- package/dist-types/components/Accordion/AccordionSection/index.d.ts +2 -0
- package/dist-types/components/Accordion/index.d.ts +2 -0
- package/dist-types/components/ActionButton/ActionButton.d.ts +48 -0
- package/dist-types/components/ActionButton/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/AppAside/AppAside.d.ts +33 -0
- package/dist-types/components/ApplicationLayout/AppAside/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/AppMain/AppMain.d.ts +14 -0
- package/dist-types/components/ApplicationLayout/AppMain/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/AppNavigation/AppNavigation.d.ts +26 -0
- package/dist-types/components/ApplicationLayout/AppNavigation/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.d.ts +18 -0
- package/dist-types/components/ApplicationLayout/AppNavigationBar/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/AppStatus/AppStatus.d.ts +14 -0
- package/dist-types/components/ApplicationLayout/AppStatus/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/Application/Application.d.ts +15 -0
- package/dist-types/components/ApplicationLayout/Application/index.d.ts +2 -0
- package/dist-types/components/ApplicationLayout/ApplicationLayout.d.ts +89 -0
- package/dist-types/components/ApplicationLayout/index.d.ts +7 -0
- package/dist-types/components/ArticlePagination/ArticlePagination.d.ts +31 -0
- package/dist-types/components/ArticlePagination/index.d.ts +2 -0
- package/dist-types/components/Badge/Badge.d.ts +34 -0
- package/dist-types/components/Badge/index.d.ts +2 -0
- package/dist-types/components/Button/Button.d.ts +64 -0
- package/dist-types/components/Button/index.d.ts +2 -0
- package/dist-types/components/Card/Card.d.ts +35 -0
- package/dist-types/components/Card/index.d.ts +2 -0
- package/dist-types/components/CheckboxInput/CheckableInput/CheckableInput.d.ts +27 -0
- package/dist-types/components/CheckboxInput/CheckableInput/index.d.ts +2 -0
- package/dist-types/components/CheckboxInput/CheckboxInput.d.ts +9 -0
- package/dist-types/components/CheckboxInput/index.d.ts +2 -0
- package/dist-types/components/Chip/Chip.d.ts +56 -0
- package/dist-types/components/Chip/index.d.ts +2 -0
- package/dist-types/components/Code/Code.d.ts +13 -0
- package/dist-types/components/Code/index.d.ts +2 -0
- package/dist-types/components/CodeSnippet/CodeSnippet.d.ts +21 -0
- package/dist-types/components/CodeSnippet/CodeSnippetBlock.d.ts +40 -0
- package/dist-types/components/CodeSnippet/CodeSnippetDropdown.d.ts +18 -0
- package/dist-types/components/CodeSnippet/index.d.ts +5 -0
- package/dist-types/components/Col/Col.d.ts +53 -0
- package/dist-types/components/Col/index.d.ts +2 -0
- package/dist-types/components/ConfirmationButton/ConfirmationButton.d.ts +28 -0
- package/dist-types/components/ConfirmationButton/index.d.ts +2 -0
- package/dist-types/components/ConfirmationModal/ConfirmationModal.d.ts +53 -0
- package/dist-types/components/ConfirmationModal/index.d.ts +2 -0
- package/dist-types/components/ContextualMenu/ContextualMenu.d.ts +110 -0
- package/dist-types/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +43 -0
- package/dist-types/components/ContextualMenu/ContextualMenuDropdown/index.d.ts +2 -0
- package/dist-types/components/ContextualMenu/index.d.ts +3 -0
- package/dist-types/components/EmptyState/EmptyState.d.ts +25 -0
- package/dist-types/components/EmptyState/index.d.ts +2 -0
- package/dist-types/components/Field/Field.d.ts +77 -0
- package/dist-types/components/Field/index.d.ts +2 -0
- package/dist-types/components/Form/Form.d.ts +21 -0
- package/dist-types/components/Form/index.d.ts +2 -0
- package/dist-types/components/FormikField/FormikField.d.ts +25 -0
- package/dist-types/components/FormikField/index.d.ts +1 -0
- package/dist-types/components/Icon/Icon.d.ts +59 -0
- package/dist-types/components/Icon/index.d.ts +2 -0
- package/dist-types/components/Input/Input.d.ts +70 -0
- package/dist-types/components/Input/index.d.ts +2 -0
- package/dist-types/components/Label/Label.d.ts +25 -0
- package/dist-types/components/Label/index.d.ts +2 -0
- package/dist-types/components/Link/Link.d.ts +31 -0
- package/dist-types/components/Link/index.d.ts +2 -0
- package/dist-types/components/List/List.d.ts +36 -0
- package/dist-types/components/List/index.d.ts +2 -0
- package/dist-types/components/Loader/Loader.d.ts +6 -0
- package/dist-types/components/Loader/index.d.ts +1 -0
- package/dist-types/components/LoginPageLayout/LoginPageLayout.d.ts +17 -0
- package/dist-types/components/LoginPageLayout/index.d.ts +2 -0
- package/dist-types/components/MainTable/MainTable.d.ts +102 -0
- package/dist-types/components/MainTable/index.d.ts +2 -0
- package/dist-types/components/Modal/Modal.d.ts +36 -0
- package/dist-types/components/Modal/index.d.ts +2 -0
- package/dist-types/components/ModularTable/ModularTable.d.ts +105 -0
- package/dist-types/components/ModularTable/index.d.ts +2 -0
- package/dist-types/components/MultiSelect/FadeInDown/FadeInDown.d.ts +10 -0
- package/dist-types/components/MultiSelect/FadeInDown/index.d.ts +1 -0
- package/dist-types/components/MultiSelect/MultiSelect.d.ts +57 -0
- package/dist-types/components/MultiSelect/index.d.ts +1 -0
- package/dist-types/components/Navigation/Navigation.d.ts +66 -0
- package/dist-types/components/Navigation/NavigationLink/NavigationLink.d.ts +10 -0
- package/dist-types/components/Navigation/NavigationLink/index.d.ts +1 -0
- package/dist-types/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
- package/dist-types/components/Navigation/NavigationMenu/index.d.ts +1 -0
- package/dist-types/components/Navigation/index.d.ts +3 -0
- package/dist-types/components/Navigation/types.d.ts +64 -0
- package/dist-types/components/Notification/Notification.d.ts +110 -0
- package/dist-types/components/Notification/index.d.ts +2 -0
- package/dist-types/components/NotificationProvider/NotificationProvider.d.ts +5 -0
- package/dist-types/components/NotificationProvider/index.d.ts +3 -0
- package/dist-types/components/NotificationProvider/messageBuilder.d.ts +6 -0
- package/dist-types/components/NotificationProvider/types.d.ts +35 -0
- package/dist-types/components/Pagination/Pagination.d.ts +102 -0
- package/dist-types/components/Pagination/PaginationButton/PaginationButton.d.ts +30 -0
- package/dist-types/components/Pagination/PaginationButton/index.d.ts +2 -0
- package/dist-types/components/Pagination/PaginationItem/PaginationItem.d.ts +17 -0
- package/dist-types/components/Pagination/PaginationItem/index.d.ts +2 -0
- package/dist-types/components/Pagination/index.d.ts +2 -0
- package/dist-types/components/Panel/Panel.d.ts +123 -0
- package/dist-types/components/Panel/index.d.ts +1 -0
- package/dist-types/components/PasswordToggle/PasswordToggle.d.ts +108 -0
- package/dist-types/components/PasswordToggle/index.d.ts +2 -0
- package/dist-types/components/RadioInput/RadioInput.d.ts +9 -0
- package/dist-types/components/RadioInput/index.d.ts +2 -0
- package/dist-types/components/Row/Row.d.ts +19 -0
- package/dist-types/components/Row/index.d.ts +2 -0
- package/dist-types/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.d.ts +25 -0
- package/dist-types/components/SearchAndFilter/FilterPanelSection/index.d.ts +1 -0
- package/dist-types/components/SearchAndFilter/SearchAndFilter.d.ts +33 -0
- package/dist-types/components/SearchAndFilter/index.d.ts +2 -0
- package/dist-types/components/SearchAndFilter/types.d.ts +11 -0
- package/dist-types/components/SearchAndFilter/utils.d.ts +13 -0
- package/dist-types/components/SearchBox/SearchBox.d.ts +63 -0
- package/dist-types/components/SearchBox/index.d.ts +2 -0
- package/dist-types/components/Select/Select.d.ts +71 -0
- package/dist-types/components/Select/index.d.ts +2 -0
- package/dist-types/components/SideNavigation/SideNavigation.d.ts +50 -0
- package/dist-types/components/SideNavigation/SideNavigationBase/SideNavigationBase.d.ts +31 -0
- package/dist-types/components/SideNavigation/SideNavigationBase/index.d.ts +1 -0
- package/dist-types/components/SideNavigation/SideNavigationItem/SideNavigationItem.d.ts +20 -0
- package/dist-types/components/SideNavigation/SideNavigationItem/index.d.ts +1 -0
- package/dist-types/components/SideNavigation/SideNavigationLink/SideNavigationLink.d.ts +18 -0
- package/dist-types/components/SideNavigation/SideNavigationLink/index.d.ts +1 -0
- package/dist-types/components/SideNavigation/SideNavigationText/SideNavigationText.d.ts +7 -0
- package/dist-types/components/SideNavigation/SideNavigationText/index.d.ts +1 -0
- package/dist-types/components/SideNavigation/index.d.ts +5 -0
- package/dist-types/components/Slider/Slider.d.ts +62 -0
- package/dist-types/components/Slider/index.d.ts +2 -0
- package/dist-types/components/Spinner/Spinner.d.ts +29 -0
- package/dist-types/components/Spinner/index.d.ts +2 -0
- package/dist-types/components/StatusLabel/StatusLabel.d.ts +33 -0
- package/dist-types/components/StatusLabel/index.d.ts +2 -0
- package/dist-types/components/Strip/Strip.d.ts +64 -0
- package/dist-types/components/Strip/index.d.ts +2 -0
- package/dist-types/components/SummaryButton/SummaryButton.d.ts +29 -0
- package/dist-types/components/SummaryButton/index.d.ts +2 -0
- package/dist-types/components/Switch/Switch.d.ts +17 -0
- package/dist-types/components/Switch/index.d.ts +2 -0
- package/dist-types/components/Table/Table.d.ts +22 -0
- package/dist-types/components/Table/index.d.ts +2 -0
- package/dist-types/components/TableCell/TableCell.d.ts +26 -0
- package/dist-types/components/TableCell/index.d.ts +2 -0
- package/dist-types/components/TableHeader/TableHeader.d.ts +14 -0
- package/dist-types/components/TableHeader/index.d.ts +2 -0
- package/dist-types/components/TablePagination/TablePagination.d.ts +98 -0
- package/dist-types/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +24 -0
- package/dist-types/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
- package/dist-types/components/TablePagination/index.d.ts +2 -0
- package/dist-types/components/TablePagination/utils.d.ts +27 -0
- package/dist-types/components/TableRow/TableRow.d.ts +10 -0
- package/dist-types/components/TableRow/index.d.ts +2 -0
- package/dist-types/components/Tabs/Tabs.d.ts +45 -0
- package/dist-types/components/Tabs/index.d.ts +2 -0
- package/dist-types/components/Textarea/Textarea.d.ts +70 -0
- package/dist-types/components/Textarea/index.d.ts +2 -0
- package/dist-types/components/Tooltip/Tooltip.d.ts +75 -0
- package/dist-types/components/Tooltip/index.d.ts +2 -0
- package/dist-types/enums.d.ts +13 -0
- package/dist-types/hooks/index.d.ts +9 -0
- package/dist-types/hooks/useId.d.ts +4 -0
- package/dist-types/hooks/useListener.d.ts +11 -0
- package/dist-types/hooks/useOnClickOutside.d.ts +12 -0
- package/dist-types/hooks/useOnEscapePressed.d.ts +6 -0
- package/dist-types/hooks/usePagination.d.ts +19 -0
- package/dist-types/hooks/usePrevious.d.ts +7 -0
- package/dist-types/hooks/useThrottle.d.ts +9 -0
- package/dist-types/hooks/useWindowFitment.d.ts +54 -0
- package/dist-types/index.d.ts +132 -0
- package/dist-types/types/index.d.ts +38 -0
- package/dist-types/utils.d.ts +27 -0
- package/package.json +3 -1
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import _pt from "prop-types";
|
|
2
|
+
var _excluded = ["items", "selectedItems", "disabledItems", "header", "updateItems", "onSelectItem", "onDeselectItem", "isOpen", "footer", "sortFn", "groupFn"];
|
|
3
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
5
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
6
|
+
import React, { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
7
|
+
import "./MultiSelect.scss";
|
|
8
|
+
import { Button, CheckboxInput, ContextualMenu, SearchBox } from "../../index";
|
|
9
|
+
import { FadeInDown } from "./FadeInDown";
|
|
10
|
+
var sortAlphabetically = (a, b) => {
|
|
11
|
+
return a.label.localeCompare(b.label, "en", {
|
|
12
|
+
numeric: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var createSortSelectedItems = previouslySelectedItemValues => (a, b) => {
|
|
16
|
+
if (previouslySelectedItemValues) {
|
|
17
|
+
var aIsPreviouslySelected = previouslySelectedItemValues.has(a.value);
|
|
18
|
+
var bIsPreviouslySelected = previouslySelectedItemValues.has(b.value);
|
|
19
|
+
if (aIsPreviouslySelected && !bIsPreviouslySelected) return -1;
|
|
20
|
+
if (!aIsPreviouslySelected && bIsPreviouslySelected) return 1;
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
};
|
|
24
|
+
var getGroupedItems = items => {
|
|
25
|
+
var groups = new Map();
|
|
26
|
+
items.forEach(item => {
|
|
27
|
+
var group = item.group || "Ungrouped";
|
|
28
|
+
var groupItems = groups.get(group) || [];
|
|
29
|
+
groupItems.push(item);
|
|
30
|
+
groups.set(group, groupItems);
|
|
31
|
+
});
|
|
32
|
+
return Array.from(groups, _ref => {
|
|
33
|
+
var [group, items] = _ref;
|
|
34
|
+
return {
|
|
35
|
+
group,
|
|
36
|
+
items
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export var MultiSelectDropdown = _ref2 => {
|
|
41
|
+
var {
|
|
42
|
+
items,
|
|
43
|
+
selectedItems,
|
|
44
|
+
disabledItems,
|
|
45
|
+
header,
|
|
46
|
+
updateItems,
|
|
47
|
+
onSelectItem,
|
|
48
|
+
onDeselectItem,
|
|
49
|
+
isOpen,
|
|
50
|
+
footer,
|
|
51
|
+
sortFn = sortAlphabetically,
|
|
52
|
+
groupFn = getGroupedItems
|
|
53
|
+
} = _ref2,
|
|
54
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
55
|
+
var selectedItemValues = useMemo(() => new Set(selectedItems.map(item => item.value)), [selectedItems]);
|
|
56
|
+
var disabledItemValues = useMemo(() => new Set(disabledItems.map(item => item.value)), [disabledItems]);
|
|
57
|
+
var [previouslySelectedItemValues, setPreviouslySelectedItemValues] = useState(new Set(selectedItemValues));
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (isOpen) {
|
|
60
|
+
setPreviouslySelectedItemValues(new Set(selectedItemValues));
|
|
61
|
+
}
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
}, [isOpen]);
|
|
64
|
+
var hasGroup = useMemo(() => items.some(item => item.group), [items]);
|
|
65
|
+
var groupedItems = useMemo(() => hasGroup ? groupFn(items) : [{
|
|
66
|
+
group: "Ungrouped",
|
|
67
|
+
items
|
|
68
|
+
}],
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
[items, groupFn]);
|
|
71
|
+
var handleOnChange = event => {
|
|
72
|
+
var {
|
|
73
|
+
checked,
|
|
74
|
+
value
|
|
75
|
+
} = event.target;
|
|
76
|
+
var foundItem = items.find(item => "".concat(item.value) === value);
|
|
77
|
+
if (foundItem) {
|
|
78
|
+
var _selectedItems$filter;
|
|
79
|
+
var newSelectedItems = checked ? [...selectedItems, foundItem] : (_selectedItems$filter = selectedItems.filter(item => "".concat(item.value) !== value)) !== null && _selectedItems$filter !== void 0 ? _selectedItems$filter : [];
|
|
80
|
+
updateItems(newSelectedItems);
|
|
81
|
+
if (checked) {
|
|
82
|
+
onSelectItem === null || onSelectItem === void 0 || onSelectItem(foundItem);
|
|
83
|
+
} else {
|
|
84
|
+
onDeselectItem === null || onDeselectItem === void 0 || onDeselectItem(foundItem);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return /*#__PURE__*/React.createElement(FadeInDown, {
|
|
89
|
+
isVisible: isOpen
|
|
90
|
+
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
91
|
+
className: "multi-select__dropdown",
|
|
92
|
+
role: "listbox"
|
|
93
|
+
}, props), header ? header : null, groupedItems.map(_ref3 => {
|
|
94
|
+
var {
|
|
95
|
+
group,
|
|
96
|
+
items
|
|
97
|
+
} = _ref3;
|
|
98
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
className: "multi-select__group",
|
|
100
|
+
key: group
|
|
101
|
+
}, hasGroup ? /*#__PURE__*/React.createElement("h5", {
|
|
102
|
+
className: "multi-select__dropdown-header"
|
|
103
|
+
}, group) : null, /*#__PURE__*/React.createElement("ul", {
|
|
104
|
+
className: "multi-select__dropdown-list",
|
|
105
|
+
"aria-label": group
|
|
106
|
+
}, items.sort(sortFn).sort(createSortSelectedItems(previouslySelectedItemValues)).map(item => /*#__PURE__*/React.createElement("li", {
|
|
107
|
+
key: item.value,
|
|
108
|
+
className: "multi-select__dropdown-item"
|
|
109
|
+
}, /*#__PURE__*/React.createElement(CheckboxInput, {
|
|
110
|
+
disabled: disabledItemValues.has(item.value),
|
|
111
|
+
label: item.label,
|
|
112
|
+
checked: selectedItemValues.has(item.value),
|
|
113
|
+
value: item.value,
|
|
114
|
+
onChange: handleOnChange,
|
|
115
|
+
key: item.value
|
|
116
|
+
})))));
|
|
117
|
+
}), footer ? /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: "multi-select__footer"
|
|
119
|
+
}, footer) : null));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Component allowing to select multiple items from a list of options.
|
|
124
|
+
*
|
|
125
|
+
* `MultiSelectDropdown` displays the dropdown with options which are grouped and sorted alphabetically.
|
|
126
|
+
* `SearchBox` or `Button` is used to trigger the dropdown depending on the variant.
|
|
127
|
+
*/
|
|
128
|
+
MultiSelectDropdown.propTypes = {
|
|
129
|
+
isOpen: _pt.bool.isRequired,
|
|
130
|
+
items: _pt.arrayOf(_pt.shape({
|
|
131
|
+
label: _pt.string.isRequired,
|
|
132
|
+
value: _pt.oneOfType([_pt.string, _pt.number]).isRequired,
|
|
133
|
+
group: _pt.string
|
|
134
|
+
})).isRequired,
|
|
135
|
+
selectedItems: _pt.arrayOf(_pt.shape({
|
|
136
|
+
label: _pt.string.isRequired,
|
|
137
|
+
value: _pt.oneOfType([_pt.string, _pt.number]).isRequired,
|
|
138
|
+
group: _pt.string
|
|
139
|
+
})).isRequired,
|
|
140
|
+
disabledItems: _pt.arrayOf(_pt.shape({
|
|
141
|
+
label: _pt.string.isRequired,
|
|
142
|
+
value: _pt.oneOfType([_pt.string, _pt.number]).isRequired,
|
|
143
|
+
group: _pt.string
|
|
144
|
+
})).isRequired,
|
|
145
|
+
header: _pt.node,
|
|
146
|
+
updateItems: _pt.func.isRequired,
|
|
147
|
+
onDeselectItem: _pt.func,
|
|
148
|
+
onSelectItem: _pt.func,
|
|
149
|
+
footer: _pt.node,
|
|
150
|
+
groupFn: _pt.func,
|
|
151
|
+
sortFn: _pt.any
|
|
152
|
+
};
|
|
153
|
+
export var MultiSelect = _ref4 => {
|
|
154
|
+
var {
|
|
155
|
+
disabled,
|
|
156
|
+
selectedItems: externalSelectedItems = [],
|
|
157
|
+
label,
|
|
158
|
+
listSelected = true,
|
|
159
|
+
onItemsUpdate,
|
|
160
|
+
onSelectItem,
|
|
161
|
+
onDeselectItem,
|
|
162
|
+
placeholder,
|
|
163
|
+
required = false,
|
|
164
|
+
items = [],
|
|
165
|
+
disabledItems = [],
|
|
166
|
+
dropdownHeader,
|
|
167
|
+
dropdownFooter,
|
|
168
|
+
showDropdownFooter = true,
|
|
169
|
+
variant = "search"
|
|
170
|
+
} = _ref4;
|
|
171
|
+
var buttonRef = useRef();
|
|
172
|
+
var [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
173
|
+
var [filter, setFilter] = useState("");
|
|
174
|
+
var [internalSelectedItems, setInternalSelectedItems] = useState([]);
|
|
175
|
+
var selectedItems = externalSelectedItems || internalSelectedItems;
|
|
176
|
+
var updateItems = newItems => {
|
|
177
|
+
var uniqueItems = Array.from(new Set(newItems));
|
|
178
|
+
setInternalSelectedItems(uniqueItems);
|
|
179
|
+
onItemsUpdate && onItemsUpdate(uniqueItems);
|
|
180
|
+
};
|
|
181
|
+
var dropdownId = useId();
|
|
182
|
+
var inputId = useId();
|
|
183
|
+
var selectedItemsLabel = selectedItems.filter(selectedItem => items.some(item => item.value === selectedItem.value)).map(el => el.label).join(", ");
|
|
184
|
+
var footer = null;
|
|
185
|
+
if (showDropdownFooter) {
|
|
186
|
+
footer = dropdownFooter ? dropdownFooter : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
187
|
+
appearance: "link",
|
|
188
|
+
onClick: () => {
|
|
189
|
+
var enabledItems = items.filter(item => !disabledItems.some(disabledItem => disabledItem.value === item.value));
|
|
190
|
+
updateItems([...selectedItems, ...enabledItems]);
|
|
191
|
+
},
|
|
192
|
+
type: "button"
|
|
193
|
+
}, "Select all"), /*#__PURE__*/React.createElement(Button, {
|
|
194
|
+
appearance: "link",
|
|
195
|
+
onClick: () => {
|
|
196
|
+
var disabledSelectedItems = selectedItems.filter(item => disabledItems.some(disabledItem => disabledItem.value === item.value));
|
|
197
|
+
updateItems(disabledSelectedItems);
|
|
198
|
+
},
|
|
199
|
+
type: "button"
|
|
200
|
+
}, "Clear"));
|
|
201
|
+
}
|
|
202
|
+
return /*#__PURE__*/React.createElement(ContextualMenu, {
|
|
203
|
+
className: "multi-select",
|
|
204
|
+
onToggleMenu: isOpen => {
|
|
205
|
+
if (!isOpen) {
|
|
206
|
+
setFilter("");
|
|
207
|
+
}
|
|
208
|
+
// Handle syncing the state when toggling the menu from within the
|
|
209
|
+
// contextual menu component e.g. when clicking outside.
|
|
210
|
+
if (isOpen !== isDropdownOpen) {
|
|
211
|
+
setIsDropdownOpen(isOpen);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
position: "left",
|
|
215
|
+
constrainPanelWidth: true,
|
|
216
|
+
toggle: variant === "search" ? /*#__PURE__*/React.createElement(SearchBox, {
|
|
217
|
+
externallyControlled: true,
|
|
218
|
+
"aria-controls": dropdownId,
|
|
219
|
+
"aria-expanded": isDropdownOpen,
|
|
220
|
+
id: inputId,
|
|
221
|
+
role: "combobox",
|
|
222
|
+
"aria-label": label || placeholder || "Search",
|
|
223
|
+
disabled: disabled,
|
|
224
|
+
autoComplete: "off",
|
|
225
|
+
onChange: value => {
|
|
226
|
+
setFilter(value);
|
|
227
|
+
// reopen if dropdown has been closed via ESC
|
|
228
|
+
setIsDropdownOpen(true);
|
|
229
|
+
},
|
|
230
|
+
onFocus: () => setIsDropdownOpen(true),
|
|
231
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Search",
|
|
232
|
+
required: required,
|
|
233
|
+
type: "text",
|
|
234
|
+
value: filter,
|
|
235
|
+
className: "multi-select__input"
|
|
236
|
+
}) : /*#__PURE__*/React.createElement("button", {
|
|
237
|
+
role: "combobox",
|
|
238
|
+
type: "button",
|
|
239
|
+
"aria-label": label || placeholder || "Select items",
|
|
240
|
+
"aria-controls": dropdownId,
|
|
241
|
+
"aria-expanded": isDropdownOpen,
|
|
242
|
+
className: "multi-select__select-button",
|
|
243
|
+
onClick: () => {
|
|
244
|
+
setIsDropdownOpen(!isDropdownOpen);
|
|
245
|
+
},
|
|
246
|
+
onMouseDown: event => {
|
|
247
|
+
// If the dropdown is open when this button is clicked the
|
|
248
|
+
// click-outside event will fire which will close the dropdown, but
|
|
249
|
+
// then the button click event will fire which will immediately
|
|
250
|
+
// reopen the dropdown.
|
|
251
|
+
// To prevent this we can stop the propagation to the click event
|
|
252
|
+
// while `isDropdownOpen` is still set to `true` (by the time we
|
|
253
|
+
// get to the `onClick` event `isDropdownOpen` will already be `false`,
|
|
254
|
+
// hence having to do this on mouse down).
|
|
255
|
+
if (isDropdownOpen) {
|
|
256
|
+
event.stopPropagation();
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
ref: buttonRef
|
|
260
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
261
|
+
className: "multi-select__condensed-text"
|
|
262
|
+
}, listSelected && selectedItems.length > 0 ? selectedItemsLabel : placeholder !== null && placeholder !== void 0 ? placeholder : "Select items")),
|
|
263
|
+
visible: isDropdownOpen
|
|
264
|
+
}, /*#__PURE__*/React.createElement(MultiSelectDropdown, {
|
|
265
|
+
id: dropdownId,
|
|
266
|
+
isOpen: isDropdownOpen,
|
|
267
|
+
items: filter.length > 0 ? items.filter(item => item.label.toLowerCase().includes(filter.toLowerCase())) : items,
|
|
268
|
+
selectedItems: selectedItems,
|
|
269
|
+
disabledItems: disabledItems,
|
|
270
|
+
header: dropdownHeader,
|
|
271
|
+
updateItems: updateItems,
|
|
272
|
+
onSelectItem: onSelectItem,
|
|
273
|
+
onDeselectItem: onDeselectItem,
|
|
274
|
+
footer: footer
|
|
275
|
+
}));
|
|
276
|
+
};
|
|
277
|
+
MultiSelect.propTypes = {
|
|
278
|
+
disabled: _pt.bool,
|
|
279
|
+
error: _pt.string,
|
|
280
|
+
selectedItems: _pt.arrayOf(_pt.shape({
|
|
281
|
+
label: _pt.string.isRequired,
|
|
282
|
+
value: _pt.oneOfType([_pt.string, _pt.number]).isRequired,
|
|
283
|
+
group: _pt.string
|
|
284
|
+
})),
|
|
285
|
+
help: _pt.string,
|
|
286
|
+
label: _pt.oneOfType([_pt.string, _pt.oneOf([null])]),
|
|
287
|
+
listSelected: _pt.bool,
|
|
288
|
+
onDeselectItem: _pt.func,
|
|
289
|
+
onItemsUpdate: _pt.func,
|
|
290
|
+
onSelectItem: _pt.func,
|
|
291
|
+
placeholder: _pt.string,
|
|
292
|
+
required: _pt.bool,
|
|
293
|
+
items: _pt.arrayOf(_pt.shape({
|
|
294
|
+
label: _pt.string.isRequired,
|
|
295
|
+
value: _pt.oneOfType([_pt.string, _pt.number]).isRequired,
|
|
296
|
+
group: _pt.string
|
|
297
|
+
})).isRequired,
|
|
298
|
+
disabledItems: _pt.arrayOf(_pt.shape({
|
|
299
|
+
label: _pt.string.isRequired,
|
|
300
|
+
value: _pt.oneOfType([_pt.string, _pt.number]).isRequired,
|
|
301
|
+
group: _pt.string
|
|
302
|
+
})),
|
|
303
|
+
renderItem: _pt.func,
|
|
304
|
+
dropdownHeader: _pt.node,
|
|
305
|
+
dropdownFooter: _pt.node,
|
|
306
|
+
showDropdownFooter: _pt.bool,
|
|
307
|
+
variant: _pt.oneOf(["condensed", "search"])
|
|
308
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MultiSelect";
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
var _excluded = ["url", "src", "title", "icon", "aria-current", "aria-label"],
|
|
2
|
+
_excluded2 = ["fullWidth", "generateLink", "items", "itemsRight", "leftNavProps", "logo", "navProps", "rightNavProps", "searchProps", "theme"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
9
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
11
|
+
import { useRef, useEffect } from "react";
|
|
12
|
+
import React, { isValidElement, useState } from "react";
|
|
13
|
+
import classNames from "classnames";
|
|
14
|
+
import NavigationLink from "./NavigationLink";
|
|
15
|
+
import NavigationMenu from "./NavigationMenu";
|
|
16
|
+
import SearchBox from "../SearchBox";
|
|
17
|
+
import { useOnEscapePressed } from "../../hooks";
|
|
18
|
+
import { Theme } from "../../enums";
|
|
19
|
+
/**
|
|
20
|
+
* Narrow the type of the nav item to a NavMenu.
|
|
21
|
+
*/
|
|
22
|
+
var isMenu = item => "items" in item;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Narrow the type of the logo prop to LogoProps.
|
|
26
|
+
*/
|
|
27
|
+
var isLogoProps = logo => ! /*#__PURE__*/isValidElement(logo);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Display the standard logo if the props were provided otherwise display the
|
|
31
|
+
* full element provided.
|
|
32
|
+
*/
|
|
33
|
+
var generateLogo = (logo, generateLink) => {
|
|
34
|
+
if (isLogoProps(logo)) {
|
|
35
|
+
var {
|
|
36
|
+
url,
|
|
37
|
+
src,
|
|
38
|
+
title,
|
|
39
|
+
icon,
|
|
40
|
+
"aria-current": ariaCurrent,
|
|
41
|
+
"aria-label": ariaLabel
|
|
42
|
+
} = logo,
|
|
43
|
+
logoProps = _objectWithoutProperties(logo, _excluded);
|
|
44
|
+
var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: "p-navigation__logo-tag"
|
|
46
|
+
}, icon !== null && icon !== void 0 ? icon : /*#__PURE__*/React.createElement("img", {
|
|
47
|
+
className: "p-navigation__logo-icon",
|
|
48
|
+
src: src,
|
|
49
|
+
alt: "Logo"
|
|
50
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
className: "p-navigation__logo-title"
|
|
52
|
+
}, title));
|
|
53
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
54
|
+
className: "p-navigation__tagged-logo"
|
|
55
|
+
}, logoProps), /*#__PURE__*/React.createElement(NavigationLink, {
|
|
56
|
+
generateLink: generateLink,
|
|
57
|
+
link: {
|
|
58
|
+
"aria-label": ariaLabel,
|
|
59
|
+
className: "p-navigation__link",
|
|
60
|
+
isSelected: !!ariaCurrent,
|
|
61
|
+
label: content,
|
|
62
|
+
url: url
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: "p-navigation__logo"
|
|
68
|
+
}, logo);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Generate the JSX for a set of nav items. This will map the items to menus,
|
|
73
|
+
* links or generated components.
|
|
74
|
+
* @param items The nav items to map to elements.
|
|
75
|
+
* @param closeMobileMenu A function to close the mobile menu.
|
|
76
|
+
* @param generateLink The optional function used to generate link components.
|
|
77
|
+
* @returns A list of navigation item elements.
|
|
78
|
+
*/
|
|
79
|
+
var generateItems = (items, closeMobileMenu, generateLink) => items.map((item, i) => isMenu(item) ? /*#__PURE__*/React.createElement(NavigationMenu, _extends({}, item, {
|
|
80
|
+
generateLink: generateLink,
|
|
81
|
+
key: i
|
|
82
|
+
})) : /*#__PURE__*/React.createElement("li", {
|
|
83
|
+
className: classNames("p-navigation__item", {
|
|
84
|
+
"is-selected": item.isSelected
|
|
85
|
+
}),
|
|
86
|
+
key: i
|
|
87
|
+
}, /*#__PURE__*/React.createElement(NavigationLink, {
|
|
88
|
+
generateLink: generateLink,
|
|
89
|
+
link: _objectSpread(_objectSpread({}, item), {}, {
|
|
90
|
+
className: classNames("p-navigation__link", item.className),
|
|
91
|
+
onClick: evt => {
|
|
92
|
+
var _item$onClick;
|
|
93
|
+
(_item$onClick = item.onClick) === null || _item$onClick === void 0 || _item$onClick.call(item, evt);
|
|
94
|
+
closeMobileMenu();
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
})));
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
This is the [React](https://reactjs.org/) component for the Vanilla
|
|
101
|
+
[Navigation](https://vanillaframework.io/docs/patterns/navigation) pattern. It
|
|
102
|
+
is a simple navigation bar that you can add to the top of your site or app.
|
|
103
|
+
|
|
104
|
+
The navigation items are collapsed behind a "Menu" link in small screens and
|
|
105
|
+
displayed horizontally on larger screens.
|
|
106
|
+
*/
|
|
107
|
+
var Navigation = _ref => {
|
|
108
|
+
var {
|
|
109
|
+
fullWidth,
|
|
110
|
+
generateLink,
|
|
111
|
+
items,
|
|
112
|
+
itemsRight,
|
|
113
|
+
leftNavProps,
|
|
114
|
+
logo,
|
|
115
|
+
navProps,
|
|
116
|
+
rightNavProps,
|
|
117
|
+
searchProps,
|
|
118
|
+
theme
|
|
119
|
+
} = _ref,
|
|
120
|
+
headerProps = _objectWithoutProperties(_ref, _excluded2);
|
|
121
|
+
var searchRef = useRef();
|
|
122
|
+
var [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
|
123
|
+
var [searchOpen, setSearchOpen] = useState(false);
|
|
124
|
+
// Display the search box if the props have been provided.
|
|
125
|
+
var hasSearch = !!searchProps;
|
|
126
|
+
// Close the mobile menu when the search box is opened.
|
|
127
|
+
var toggleSearch = open => {
|
|
128
|
+
setSearchOpen(open !== null && open !== void 0 ? open : !searchOpen);
|
|
129
|
+
setMobileMenuOpen(false);
|
|
130
|
+
};
|
|
131
|
+
// Close the search box when the mobile menu is opened.
|
|
132
|
+
var toggleMobileMenu = () => {
|
|
133
|
+
setMobileMenuOpen(!mobileMenuOpen);
|
|
134
|
+
setSearchOpen(false);
|
|
135
|
+
};
|
|
136
|
+
var closeMobileMenu = () => {
|
|
137
|
+
if (mobileMenuOpen) {
|
|
138
|
+
setMobileMenuOpen(false);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
// Hide the searchbox when the escape key is pressed.
|
|
142
|
+
useOnEscapePressed(() => toggleSearch(false));
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (searchOpen) {
|
|
145
|
+
var _searchRef$current;
|
|
146
|
+
// Focus on the searchbox when it appears. This done in a useEffect so
|
|
147
|
+
// that the state change to display the searchbox has already occured and
|
|
148
|
+
// the input has been made visible.
|
|
149
|
+
(_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 || _searchRef$current.focus();
|
|
150
|
+
}
|
|
151
|
+
}, [searchOpen]);
|
|
152
|
+
return /*#__PURE__*/React.createElement("header", _extends({}, headerProps, {
|
|
153
|
+
className: classNames("p-navigation", headerProps.className, {
|
|
154
|
+
"has-menu-open": mobileMenuOpen,
|
|
155
|
+
"has-search-open": searchOpen,
|
|
156
|
+
"is-dark": theme === Theme.DARK,
|
|
157
|
+
"is-light": theme === Theme.LIGHT
|
|
158
|
+
})
|
|
159
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
160
|
+
className: fullWidth ? "p-navigation__row--full-width" : "p-navigation__row"
|
|
161
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
162
|
+
className: "p-navigation__banner"
|
|
163
|
+
}, generateLogo(logo, generateLink), /*#__PURE__*/React.createElement("ul", {
|
|
164
|
+
className: "p-navigation__items"
|
|
165
|
+
},
|
|
166
|
+
// When the header has a search box then this button is used to
|
|
167
|
+
// toggle the search box at mobile size.
|
|
168
|
+
hasSearch ? /*#__PURE__*/React.createElement("li", {
|
|
169
|
+
className: "p-navigation__item"
|
|
170
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
171
|
+
"aria-label": "Search",
|
|
172
|
+
className: "p-navigation__link--search-toggle",
|
|
173
|
+
onClick: () => toggleSearch()
|
|
174
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
175
|
+
className: "p-navigation__search-label"
|
|
176
|
+
}, "Search"))) : null, (items === null || items === void 0 ? void 0 : items.length) > 0 || (itemsRight === null || itemsRight === void 0 ? void 0 : itemsRight.length) > 0 ? /*#__PURE__*/React.createElement("li", {
|
|
177
|
+
className: "p-navigation__item"
|
|
178
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
179
|
+
"aria-pressed": mobileMenuOpen,
|
|
180
|
+
className: "p-navigation__link",
|
|
181
|
+
onClick: toggleMobileMenu
|
|
182
|
+
}, mobileMenuOpen ? "Close menu" : "Menu")) : null)), /*#__PURE__*/React.createElement("nav", _extends({
|
|
183
|
+
className: "p-navigation__nav"
|
|
184
|
+
}, navProps), /*#__PURE__*/React.createElement("ul", _extends({
|
|
185
|
+
className: "p-navigation__items"
|
|
186
|
+
}, leftNavProps), items ? generateItems(items, closeMobileMenu, generateLink) : null), itemsRight || hasSearch ? /*#__PURE__*/React.createElement("ul", _extends({
|
|
187
|
+
className: "p-navigation__items"
|
|
188
|
+
}, rightNavProps), itemsRight ? generateItems(itemsRight, closeMobileMenu, generateLink) : null,
|
|
189
|
+
// When the header has a search box then this button is used to
|
|
190
|
+
// toggle the search box at non-mobile size.
|
|
191
|
+
hasSearch ? /*#__PURE__*/React.createElement("li", {
|
|
192
|
+
className: "p-navigation__item"
|
|
193
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
194
|
+
"aria-label": "Search",
|
|
195
|
+
className: "p-navigation__link--search-toggle",
|
|
196
|
+
onClick: () => toggleSearch()
|
|
197
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
198
|
+
className: "p-navigation__search-label"
|
|
199
|
+
}, "Search"))) : null) : null,
|
|
200
|
+
// When the header has a search box and the user has opened the search
|
|
201
|
+
// form then this search box is displayed.
|
|
202
|
+
hasSearch ? /*#__PURE__*/React.createElement("div", {
|
|
203
|
+
className: "p-navigation__search",
|
|
204
|
+
"aria-hidden": !searchOpen
|
|
205
|
+
}, /*#__PURE__*/React.createElement(SearchBox, {
|
|
206
|
+
ref: searchRef
|
|
207
|
+
})) : null)),
|
|
208
|
+
// When the header has a search box and the user has opened the search
|
|
209
|
+
// form then this element is overlayed over the whole page.
|
|
210
|
+
hasSearch ? /*#__PURE__*/React.createElement("div", {
|
|
211
|
+
className: "p-navigation__search-overlay",
|
|
212
|
+
onClick: () => setSearchOpen(false)
|
|
213
|
+
}) : null);
|
|
214
|
+
};
|
|
215
|
+
export default Navigation;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _pt from "prop-types";
|
|
2
|
+
var _excluded = ["isSelected"],
|
|
3
|
+
_excluded2 = ["isSelected", "label", "url"],
|
|
4
|
+
_excluded3 = ["isSelected", "label", "url"];
|
|
5
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
13
|
+
import React from "react";
|
|
14
|
+
import { isNavigationAnchor, isNavigationButton } from "../../../utils";
|
|
15
|
+
/**
|
|
16
|
+
* This component is used internally to display links inside the Navigation component.
|
|
17
|
+
*/
|
|
18
|
+
var NavigationLink = _ref => {
|
|
19
|
+
var {
|
|
20
|
+
generateLink,
|
|
21
|
+
link
|
|
22
|
+
} = _ref;
|
|
23
|
+
// const ariaCurrent = isSelected ? "page" : undefined;
|
|
24
|
+
if (generateLink) {
|
|
25
|
+
var {
|
|
26
|
+
isSelected
|
|
27
|
+
} = link,
|
|
28
|
+
linkProps = _objectWithoutProperties(link, _excluded);
|
|
29
|
+
// If a function has been provided then use it to generate the link element.
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, generateLink(_objectSpread({
|
|
31
|
+
isSelected,
|
|
32
|
+
"aria-current": isSelected ? "page" : undefined
|
|
33
|
+
}, linkProps)));
|
|
34
|
+
} else if (isNavigationAnchor(link)) {
|
|
35
|
+
var {
|
|
36
|
+
isSelected: _isSelected,
|
|
37
|
+
label,
|
|
38
|
+
url
|
|
39
|
+
} = link,
|
|
40
|
+
linkProps = _objectWithoutProperties(link, _excluded2);
|
|
41
|
+
return /*#__PURE__*/React.createElement("a", _extends({}, linkProps, {
|
|
42
|
+
href: url,
|
|
43
|
+
"aria-current": _isSelected ? "page" : undefined
|
|
44
|
+
}), label);
|
|
45
|
+
} else if (isNavigationButton(link)) {
|
|
46
|
+
var {
|
|
47
|
+
isSelected: _isSelected2,
|
|
48
|
+
label: _label,
|
|
49
|
+
url: _url
|
|
50
|
+
} = link,
|
|
51
|
+
linkProps = _objectWithoutProperties(link, _excluded3);
|
|
52
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, linkProps, {
|
|
53
|
+
"aria-current": _isSelected2 ? "page" : undefined
|
|
54
|
+
}), _label);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
export default NavigationLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./NavigationLink";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var _excluded = ["alignRight", "generateLink", "items", "label"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
import React, { useCallback, useId, useRef, useState } from "react";
|
|
11
|
+
import classNames from "classnames";
|
|
12
|
+
import NavigationLink from "../NavigationLink";
|
|
13
|
+
import { useOnClickOutside } from "../../../hooks";
|
|
14
|
+
/**
|
|
15
|
+
* This component is used internally to display menus inside the Navigation component.
|
|
16
|
+
*/
|
|
17
|
+
var NavigationMenu = _ref => {
|
|
18
|
+
var {
|
|
19
|
+
alignRight,
|
|
20
|
+
generateLink,
|
|
21
|
+
items,
|
|
22
|
+
label
|
|
23
|
+
} = _ref,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
var [isOpen, setIsOpen] = useState(false);
|
|
26
|
+
var closeMenu = useCallback(() => setIsOpen(false), [setIsOpen]);
|
|
27
|
+
var menuRef = useRef(null);
|
|
28
|
+
useOnClickOutside(menuRef, closeMenu);
|
|
29
|
+
var menuId = useId();
|
|
30
|
+
return /*#__PURE__*/React.createElement("li", _extends({}, props, {
|
|
31
|
+
className: classNames(props.className, "p-navigation__item--dropdown-toggle", {
|
|
32
|
+
"is-active": isOpen
|
|
33
|
+
}),
|
|
34
|
+
ref: menuRef
|
|
35
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
36
|
+
"aria-controls": menuId,
|
|
37
|
+
className: "p-navigation__link u-no-margin--right",
|
|
38
|
+
onClick: evt => {
|
|
39
|
+
evt.preventDefault();
|
|
40
|
+
setIsOpen(!isOpen);
|
|
41
|
+
}
|
|
42
|
+
}, label), /*#__PURE__*/React.createElement("ul", {
|
|
43
|
+
"aria-hidden": !isOpen,
|
|
44
|
+
className: classNames("p-navigation__dropdown", {
|
|
45
|
+
"p-navigation__dropdown--right": alignRight
|
|
46
|
+
}),
|
|
47
|
+
id: menuId
|
|
48
|
+
}, items.map((item, i) => /*#__PURE__*/React.createElement("li", {
|
|
49
|
+
key: i
|
|
50
|
+
}, /*#__PURE__*/React.createElement(NavigationLink, {
|
|
51
|
+
generateLink: generateLink,
|
|
52
|
+
link: _objectSpread(_objectSpread({}, item), {}, {
|
|
53
|
+
className: classNames("p-navigation__dropdown-item", item.className)
|
|
54
|
+
})
|
|
55
|
+
})))));
|
|
56
|
+
};
|
|
57
|
+
export default NavigationMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./NavigationMenu";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Navigation";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|