@okta/odyssey-react-mui 1.25.0 → 1.27.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/CHANGELOG.md +17 -0
- package/dist/Autocomplete.js +30 -191
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Box.js +2 -0
- package/dist/Box.js.map +1 -1
- package/dist/Card.js +1 -0
- package/dist/Card.js.map +1 -1
- package/dist/OdysseyDesignTokensContext.js +3 -2
- package/dist/OdysseyDesignTokensContext.js.map +1 -1
- package/dist/OdysseyProvider.js +9 -7
- package/dist/OdysseyProvider.js.map +1 -1
- package/dist/OdysseyThemeProvider.js +33 -13
- package/dist/OdysseyThemeProvider.js.map +1 -1
- package/dist/Pagination/Pagination.js +46 -14
- package/dist/Pagination/Pagination.js.map +1 -1
- package/dist/Surface.js +14 -3
- package/dist/Surface.js.map +1 -1
- package/dist/Tag.js +42 -27
- package/dist/Tag.js.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/index.scss +1 -1
- package/dist/labs/AppTile.js +137 -39
- package/dist/labs/AppTile.js.map +1 -1
- package/dist/labs/DataView/CardLayoutContent.js +7 -8
- package/dist/labs/DataView/CardLayoutContent.js.map +1 -1
- package/dist/labs/DataView/DataCard.js +96 -43
- package/dist/labs/DataView/DataCard.js.map +1 -1
- package/dist/labs/DataView/DataView.js +6 -0
- package/dist/labs/DataView/DataView.js.map +1 -1
- package/dist/labs/DataView/TableLayoutContent.js +3 -2
- package/dist/labs/DataView/TableLayoutContent.js.map +1 -1
- package/dist/labs/DataView/componentTypes.js.map +1 -1
- package/dist/labs/DataView/index.js.map +1 -1
- package/dist/labs/OdysseyPickers/ComposablePicker.js +113 -0
- package/dist/labs/OdysseyPickers/ComposablePicker.js.map +1 -0
- package/dist/labs/OdysseyPickers/Picker.js +261 -0
- package/dist/labs/OdysseyPickers/Picker.js.map +1 -0
- package/dist/labs/OdysseyPickers/PickerVirtualizationListBox.js +132 -0
- package/dist/labs/OdysseyPickers/PickerVirtualizationListBox.js.map +1 -0
- package/dist/labs/OdysseyPickers/PickerWithOptionAdornment.js +291 -0
- package/dist/labs/OdysseyPickers/PickerWithOptionAdornment.js.map +1 -0
- package/dist/{src/createShadowDomElements.d.ts → labs/OdysseyPickers/index.js} +4 -7
- package/dist/labs/OdysseyPickers/index.js.map +1 -0
- package/dist/labs/PageTemplate.js +14 -10
- package/dist/labs/PageTemplate.js.map +1 -1
- package/dist/labs/SideNav/CollapseIcon.js +11 -25
- package/dist/labs/SideNav/CollapseIcon.js.map +1 -1
- package/dist/labs/SideNav/HandleIcon.js +32 -0
- package/dist/labs/SideNav/HandleIcon.js.map +1 -0
- package/dist/labs/{NavAccordion.js → SideNav/NavAccordion.js} +36 -8
- package/dist/labs/SideNav/NavAccordion.js.map +1 -0
- package/dist/labs/SideNav/OktaAura.js +32 -0
- package/dist/labs/SideNav/OktaAura.js.map +1 -0
- package/dist/labs/SideNav/OktaLogo.js +6 -9
- package/dist/labs/SideNav/OktaLogo.js.map +1 -1
- package/dist/labs/SideNav/SideNav.js +316 -172
- package/dist/labs/SideNav/SideNav.js.map +1 -1
- package/dist/labs/SideNav/SideNavFooterContent.js +32 -18
- package/dist/labs/SideNav/SideNavFooterContent.js.map +1 -1
- package/dist/labs/SideNav/SideNavHeader.js +48 -37
- package/dist/labs/SideNav/SideNavHeader.js.map +1 -1
- package/dist/labs/SideNav/SideNavItemContent.js +150 -68
- package/dist/labs/SideNav/SideNavItemContent.js.map +1 -1
- package/dist/labs/SideNav/SideNavItemContentContext.js +20 -0
- package/dist/labs/SideNav/SideNavItemContentContext.js.map +1 -0
- package/dist/labs/SideNav/SideNavItemLinkContent.js +15 -14
- package/dist/labs/SideNav/SideNavItemLinkContent.js.map +1 -1
- package/dist/labs/SideNav/SideNavLogo.js +42 -0
- package/dist/labs/SideNav/SideNavLogo.js.map +1 -0
- package/dist/labs/SideNav/SideNavToggleButton.js +170 -0
- package/dist/labs/SideNav/SideNavToggleButton.js.map +1 -0
- package/dist/labs/SideNav/SortableList/SortableItem.js +162 -0
- package/dist/labs/SideNav/SortableList/SortableItem.js.map +1 -0
- package/dist/labs/SideNav/SortableList/SortableList.js +118 -0
- package/dist/labs/SideNav/SortableList/SortableList.js.map +1 -0
- package/dist/labs/SideNav/SortableList/SortableOverlay.js +30 -0
- package/dist/labs/SideNav/SortableList/SortableOverlay.js.map +1 -0
- package/dist/labs/SideNav/types.js.map +1 -1
- package/dist/labs/TopNav/TopNav.js +65 -0
- package/dist/labs/TopNav/TopNav.js.map +1 -0
- package/dist/labs/TopNav/TopNavLinksList.js +38 -0
- package/dist/labs/TopNav/TopNavLinksList.js.map +1 -0
- package/dist/labs/TopNav/TopNavListItem.js +132 -0
- package/dist/labs/TopNav/TopNavListItem.js.map +1 -0
- package/dist/labs/TopNav/UserProfile.js +65 -0
- package/dist/labs/TopNav/UserProfile.js.map +1 -0
- package/dist/labs/TopNav/index.js +14 -0
- package/dist/labs/TopNav/index.js.map +1 -0
- package/dist/labs/UiShell/UiShell.js +68 -0
- package/dist/labs/UiShell/UiShell.js.map +1 -0
- package/dist/labs/UiShell/UiShellContent.js +114 -0
- package/dist/labs/UiShell/UiShellContent.js.map +1 -0
- package/dist/labs/UiShell/bufferLatest.js +37 -0
- package/dist/labs/UiShell/bufferLatest.js.map +1 -0
- package/dist/labs/UiShell/createMessageBus.js +30 -0
- package/dist/labs/UiShell/createMessageBus.js.map +1 -0
- package/dist/labs/UiShell/createStore.js +24 -0
- package/dist/labs/UiShell/createStore.js.map +1 -0
- package/dist/labs/UiShell/index.js +15 -0
- package/dist/labs/UiShell/index.js.map +1 -0
- package/dist/labs/UiShell/renderUiShell.js +78 -0
- package/dist/labs/UiShell/renderUiShell.js.map +1 -0
- package/dist/labs/UiShell/useHasUiShell.js +22 -0
- package/dist/labs/UiShell/useHasUiShell.js.map +1 -0
- package/dist/labs/UiShell/useScrollState.js +41 -0
- package/dist/labs/UiShell/useScrollState.js.map +1 -0
- package/dist/labs/index.js +5 -3
- package/dist/labs/index.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui.js +14 -1
- package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_cs.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_cs.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_da.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_da.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_de.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_de.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_el.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_el.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_es.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_es.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_fi.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_fi.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_fr.js +5 -3
- package/dist/properties/ts/odyssey-react-mui_fr.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_ht.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_ht.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_hu.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_hu.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_id.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_id.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_it.js +4 -2
- package/dist/properties/ts/odyssey-react-mui_it.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_ja.js +9 -7
- package/dist/properties/ts/odyssey-react-mui_ja.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_ko.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_ko.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_ms.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_ms.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_nb.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_nb.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_nl_NL.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_nl_NL.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_pl.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_pl.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_pt_BR.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_pt_BR.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_ro.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_ro.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_ru.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_ru.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_sv.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_sv.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_th.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_th.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_tr.js +4 -2
- package/dist/properties/ts/odyssey-react-mui_tr.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_uk.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_uk.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_vi.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_vi.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_zh_CN.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_zh_CN.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui_zh_TW.js +3 -1
- package/dist/properties/ts/odyssey-react-mui_zh_TW.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +21 -22
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Box.d.ts +3 -1
- package/dist/src/Box.d.ts.map +1 -1
- package/dist/src/Card.d.ts.map +1 -1
- package/dist/src/OdysseyDesignTokensContext.d.ts +5 -4
- package/dist/src/OdysseyDesignTokensContext.d.ts.map +1 -1
- package/dist/src/OdysseyProvider.d.ts +3 -3
- package/dist/src/OdysseyProvider.d.ts.map +1 -1
- package/dist/src/OdysseyThemeProvider.d.ts +10 -12
- package/dist/src/OdysseyThemeProvider.d.ts.map +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
- package/dist/src/Pagination/Pagination.d.ts +21 -7
- package/dist/src/Pagination/Pagination.d.ts.map +1 -1
- package/dist/src/Surface.d.ts.map +1 -1
- package/dist/src/Tag.d.ts +5 -2
- package/dist/src/Tag.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/labs/AppTile.d.ts +3 -1
- package/dist/src/labs/AppTile.d.ts.map +1 -1
- package/dist/src/labs/DataView/CardLayoutContent.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataCard.d.ts +9 -3
- package/dist/src/labs/DataView/DataCard.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataView.d.ts +1 -1
- package/dist/src/labs/DataView/DataView.d.ts.map +1 -1
- package/dist/src/labs/DataView/TableLayoutContent.d.ts.map +1 -1
- package/dist/src/labs/DataView/componentTypes.d.ts +4 -3
- package/dist/src/labs/DataView/componentTypes.d.ts.map +1 -1
- package/dist/src/labs/DataView/index.d.ts +1 -0
- package/dist/src/labs/DataView/index.d.ts.map +1 -1
- package/dist/src/labs/OdysseyPickers/ComposablePicker.d.ts +33 -0
- package/dist/src/labs/OdysseyPickers/ComposablePicker.d.ts.map +1 -0
- package/dist/src/labs/OdysseyPickers/Picker.d.ts +98 -0
- package/dist/src/labs/OdysseyPickers/Picker.d.ts.map +1 -0
- package/dist/src/labs/OdysseyPickers/PickerVirtualizationListBox.d.ts +17 -0
- package/dist/src/labs/OdysseyPickers/PickerVirtualizationListBox.d.ts.map +1 -0
- package/dist/src/labs/OdysseyPickers/PickerWithOptionAdornment.d.ts +26 -0
- package/dist/src/labs/OdysseyPickers/PickerWithOptionAdornment.d.ts.map +1 -0
- package/dist/src/labs/OdysseyPickers/index.d.ts +15 -0
- package/dist/src/labs/OdysseyPickers/index.d.ts.map +1 -0
- package/dist/src/labs/PageTemplate.d.ts +1 -1
- package/dist/src/labs/PageTemplate.d.ts.map +1 -1
- package/dist/src/labs/SideNav/CollapseIcon.d.ts +1 -4
- package/dist/src/labs/SideNav/CollapseIcon.d.ts.map +1 -1
- package/dist/src/labs/SideNav/HandleIcon.d.ts +14 -0
- package/dist/src/labs/SideNav/HandleIcon.d.ts.map +1 -0
- package/dist/src/labs/{NavAccordion.d.ts → SideNav/NavAccordion.d.ts} +7 -7
- package/dist/src/labs/SideNav/NavAccordion.d.ts.map +1 -0
- package/dist/src/labs/SideNav/OktaAura.d.ts +14 -0
- package/dist/src/labs/SideNav/OktaAura.d.ts.map +1 -0
- package/dist/src/labs/SideNav/OktaLogo.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNav.d.ts +2 -1
- package/dist/src/labs/SideNav/SideNav.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavFooterContent.d.ts +1 -1
- package/dist/src/labs/SideNav/SideNavFooterContent.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavHeader.d.ts +12 -3
- package/dist/src/labs/SideNav/SideNavHeader.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavItemContent.d.ts +38 -3
- package/dist/src/labs/SideNav/SideNavItemContent.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavItemContentContext.d.ts +19 -0
- package/dist/src/labs/SideNav/SideNavItemContentContext.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SideNavItemLinkContent.d.ts +1 -1
- package/dist/src/labs/SideNav/SideNavItemLinkContent.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavLogo.d.ts +15 -0
- package/dist/src/labs/SideNav/SideNavLogo.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SideNavToggleButton.d.ts +38 -0
- package/dist/src/labs/SideNav/SideNavToggleButton.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SortableList/SortableItem.d.ts +26 -0
- package/dist/src/labs/SideNav/SortableList/SortableItem.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SortableList/SortableList.d.ts +36 -0
- package/dist/src/labs/SideNav/SortableList/SortableList.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SortableList/SortableOverlay.d.ts +17 -0
- package/dist/src/labs/SideNav/SortableList/SortableOverlay.d.ts.map +1 -0
- package/dist/src/labs/SideNav/types.d.ts +79 -35
- package/dist/src/labs/SideNav/types.d.ts.map +1 -1
- package/dist/src/labs/TopNav/TopNav.d.ts +31 -0
- package/dist/src/labs/TopNav/TopNav.d.ts.map +1 -0
- package/dist/src/labs/TopNav/TopNavLinksList.d.ts +44 -0
- package/dist/src/labs/TopNav/TopNavLinksList.d.ts.map +1 -0
- package/dist/src/labs/TopNav/TopNavListItem.d.ts +42 -0
- package/dist/src/labs/TopNav/TopNavListItem.d.ts.map +1 -0
- package/dist/src/labs/TopNav/UserProfile.d.ts +29 -0
- package/dist/src/labs/TopNav/UserProfile.d.ts.map +1 -0
- package/dist/src/labs/TopNav/index.d.ts +14 -0
- package/dist/src/labs/TopNav/index.d.ts.map +1 -0
- package/dist/src/labs/UiShell/UiShell.d.ts +33 -0
- package/dist/src/labs/UiShell/UiShell.d.ts.map +1 -0
- package/dist/src/labs/UiShell/UiShellContent.d.ts +47 -0
- package/dist/src/labs/UiShell/UiShellContent.d.ts.map +1 -0
- package/dist/src/labs/UiShell/bufferLatest.d.ts +31 -0
- package/dist/src/labs/UiShell/bufferLatest.d.ts.map +1 -0
- package/dist/src/labs/UiShell/createMessageBus.d.ts +24 -0
- package/dist/src/labs/UiShell/createMessageBus.d.ts.map +1 -0
- package/dist/src/labs/UiShell/createStore.d.ts +22 -0
- package/dist/src/labs/UiShell/createStore.d.ts.map +1 -0
- package/dist/src/labs/UiShell/index.d.ts +16 -0
- package/dist/src/labs/UiShell/index.d.ts.map +1 -0
- package/dist/src/labs/UiShell/renderUiShell.d.ts +45 -0
- package/dist/src/labs/UiShell/renderUiShell.d.ts.map +1 -0
- package/dist/src/labs/UiShell/useHasUiShell.d.ts +13 -0
- package/dist/src/labs/UiShell/useHasUiShell.d.ts.map +1 -0
- package/dist/src/labs/UiShell/useScrollState.d.ts +16 -0
- package/dist/src/labs/UiShell/useScrollState.d.ts.map +1 -0
- package/dist/src/labs/index.d.ts +6 -2
- package/dist/src/labs/index.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui.d.ts +13 -0
- package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_cs.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_cs.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_da.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_da.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_de.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_de.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_el.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_el.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_es.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_es.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_fi.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_fi.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_fr.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_fr.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_ht.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_ht.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_hu.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_hu.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_id.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_id.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_it.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_it.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_ja.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_ja.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_ko.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_ko.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_ms.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_ms.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_nb.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_nb.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_nl_NL.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_nl_NL.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_pl.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_pl.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_pt_BR.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_pt_BR.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_ro.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_ro.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_ru.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_ru.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_sv.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_sv.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_th.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_th.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_tr.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_tr.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_uk.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_uk.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_vi.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_vi.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_zh_CN.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_zh_CN.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui_zh_TW.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui_zh_TW.d.ts.map +1 -1
- package/dist/src/test-selectors/querySelector.d.ts +2 -2
- package/dist/src/theme/components.d.ts +3 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/src/theme/createOdysseyMuiTheme.d.ts +2 -1
- package/dist/src/theme/createOdysseyMuiTheme.d.ts.map +1 -1
- package/dist/src/useAutocomplete.d.ts +29 -0
- package/dist/src/useAutocomplete.d.ts.map +1 -0
- package/dist/src/useContrastMode.d.ts +46 -0
- package/dist/src/useContrastMode.d.ts.map +1 -0
- package/dist/src/web-component/index.d.ts +14 -0
- package/dist/src/web-component/index.d.ts.map +1 -0
- package/dist/src/web-component/renderReactInWebComponent.d.ts +76 -0
- package/dist/src/web-component/renderReactInWebComponent.d.ts.map +1 -0
- package/dist/src/web-component/shadow-dom.d.ts +23 -0
- package/dist/src/web-component/shadow-dom.d.ts.map +1 -0
- package/dist/test-selectors/querySelector.js.map +1 -1
- package/dist/theme/components.js +36 -32
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/createOdysseyMuiTheme.js +3 -2
- package/dist/theme/createOdysseyMuiTheme.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAutocomplete.js +105 -0
- package/dist/useAutocomplete.js.map +1 -0
- package/dist/useContrastMode.js +93 -0
- package/dist/useContrastMode.js.map +1 -0
- package/dist/web-component/index.js +14 -0
- package/dist/web-component/index.js.map +1 -0
- package/dist/web-component/renderReactInWebComponent.js +72 -0
- package/dist/web-component/renderReactInWebComponent.js.map +1 -0
- package/dist/{createShadowDomElements.js → web-component/shadow-dom.js} +10 -12
- package/dist/web-component/shadow-dom.js.map +1 -0
- package/i18n.config.json +2 -1
- package/jest.config.cjs +1 -1
- package/jest.setup.js +0 -3
- package/package.json +7 -3
- package/src/Autocomplete.tsx +40 -330
- package/src/Box.tsx +4 -2
- package/src/Card.tsx +1 -0
- package/src/OdysseyDesignTokensContext.tsx +6 -3
- package/src/OdysseyProvider.tsx +13 -8
- package/src/OdysseyThemeProvider.test.tsx +209 -0
- package/src/OdysseyThemeProvider.tsx +42 -26
- package/src/Pagination/Pagination.test.tsx +305 -0
- package/src/Pagination/Pagination.tsx +86 -38
- package/src/Surface.tsx +18 -5
- package/src/Tag.tsx +64 -39
- package/src/createUniqueAlphabeticalId.test.ts +1 -1
- package/src/createUniqueId.test.ts +1 -1
- package/src/index.ts +6 -7
- package/src/labs/AppTile.tsx +169 -40
- package/src/labs/DataView/CardLayoutContent.tsx +12 -14
- package/src/labs/DataView/DataCard.tsx +137 -69
- package/src/labs/DataView/DataView.test.tsx +6 -4
- package/src/labs/DataView/DataView.tsx +6 -0
- package/src/labs/DataView/TableLayoutContent.tsx +6 -2
- package/src/labs/DataView/componentTypes.ts +7 -3
- package/src/labs/DataView/index.tsx +1 -0
- package/src/labs/OdysseyPickers/ComposablePicker.test.tsx +29 -0
- package/src/labs/OdysseyPickers/ComposablePicker.tsx +188 -0
- package/src/labs/OdysseyPickers/Picker.tsx +381 -0
- package/src/labs/OdysseyPickers/PickerVirtualizationListBox.tsx +191 -0
- package/src/labs/OdysseyPickers/PickerWithOptionAdornment.tsx +429 -0
- package/src/labs/OdysseyPickers/index.ts +15 -0
- package/src/labs/PageTemplate.tsx +18 -10
- package/src/labs/SideNav/CollapseIcon.tsx +14 -28
- package/src/labs/SideNav/HandleIcon.tsx +35 -0
- package/src/labs/{NavAccordion.tsx → SideNav/NavAccordion.tsx} +51 -16
- package/src/labs/SideNav/OktaAura.tsx +35 -0
- package/src/labs/SideNav/OktaLogo.tsx +5 -10
- package/src/labs/SideNav/SideNav.test.tsx +323 -0
- package/src/labs/SideNav/SideNav.tsx +405 -205
- package/src/labs/SideNav/SideNavFooterContent.tsx +36 -28
- package/src/labs/SideNav/SideNavHeader.tsx +62 -45
- package/src/labs/SideNav/SideNavItemContent.tsx +202 -69
- package/src/labs/SideNav/SideNavItemContentContext.tsx +29 -0
- package/src/labs/SideNav/SideNavItemLinkContent.tsx +18 -15
- package/src/labs/SideNav/SideNavLogo.tsx +41 -0
- package/src/labs/SideNav/SideNavToggleButton.tsx +245 -0
- package/src/labs/SideNav/SortableList/SortableItem.tsx +202 -0
- package/src/labs/SideNav/SortableList/SortableList.tsx +122 -0
- package/src/labs/SideNav/SortableList/SortableOverlay.tsx +34 -0
- package/src/labs/SideNav/types.ts +85 -36
- package/src/labs/TopNav/TopNav.tsx +95 -0
- package/src/labs/TopNav/TopNavLinksList.tsx +68 -0
- package/src/labs/TopNav/TopNavListItem.tsx +209 -0
- package/src/labs/TopNav/UserProfile.tsx +79 -0
- package/src/labs/TopNav/index.ts +14 -0
- package/src/labs/UiShell/UiShell.test.tsx +284 -0
- package/src/labs/UiShell/UiShell.tsx +109 -0
- package/src/labs/UiShell/UiShellContent.tsx +170 -0
- package/src/labs/UiShell/bufferLatest.test.ts +79 -0
- package/src/labs/UiShell/bufferLatest.ts +64 -0
- package/src/labs/UiShell/createMessageBus.test.ts +115 -0
- package/src/labs/UiShell/createMessageBus.ts +53 -0
- package/src/labs/UiShell/createStore.test.ts +103 -0
- package/src/labs/UiShell/createStore.ts +37 -0
- package/src/labs/UiShell/index.ts +17 -0
- package/src/labs/UiShell/renderUiShell.test.tsx +197 -0
- package/src/labs/UiShell/renderUiShell.tsx +132 -0
- package/src/labs/UiShell/useHasUiShell.ts +25 -0
- package/src/labs/UiShell/useScrollState.ts +56 -0
- package/src/labs/index.ts +10 -3
- package/src/properties/odyssey-react-mui.properties +14 -0
- package/src/properties/translations/odyssey-react-mui_cs.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_da.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_de.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_el.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_es.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_fi.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_fr.properties +4 -3
- package/src/properties/translations/odyssey-react-mui_ht.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_hu.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_id.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_it.properties +3 -2
- package/src/properties/translations/odyssey-react-mui_ja.properties +8 -7
- package/src/properties/translations/odyssey-react-mui_ko.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_ms.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_nb.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_nl_NL.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_pl.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_pt_BR.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_ro.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_ru.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_sv.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_th.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_tr.properties +3 -2
- package/src/properties/translations/odyssey-react-mui_uk.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_vi.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_zh_CN.properties +2 -1
- package/src/properties/translations/odyssey-react-mui_zh_TW.properties +2 -1
- package/src/properties/ts/odyssey-react-mui.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_cs.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_da.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_de.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_el.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_es.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_fi.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_fr.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_ht.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_hu.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_id.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_it.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_ja.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_ko.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_ms.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_nb.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_nl_NL.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_pl.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_pt_BR.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_ro.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_ru.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_sv.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_th.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_tr.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_uk.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_vi.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_zh_CN.ts +1 -1
- package/src/properties/ts/odyssey-react-mui_zh_TW.ts +1 -1
- package/src/test-selectors/querySelector.ts +1 -1
- package/src/theme/components.tsx +50 -33
- package/src/theme/createOdysseyMuiTheme.ts +4 -3
- package/src/theme/useContrastMode.test.tsx +503 -0
- package/src/useAutocomplete.tsx +183 -0
- package/src/useContrastMode.tsx +149 -0
- package/src/web-component/index.ts +14 -0
- package/src/web-component/renderReactInWebComponent.test.tsx +156 -0
- package/src/web-component/renderReactInWebComponent.ts +153 -0
- package/src/web-component/shadow-dom.test.ts +24 -0
- package/src/{createShadowDomElements.ts → web-component/shadow-dom.ts} +15 -14
- package/dist/ContrastModeProvider.js +0 -86
- package/dist/ContrastModeProvider.js.map +0 -1
- package/dist/createShadowDomElements.js.map +0 -1
- package/dist/labs/NavAccordion.js.map +0 -1
- package/dist/labs/TopNav.js +0 -281
- package/dist/labs/TopNav.js.map +0 -1
- package/dist/src/ContrastModeProvider.d.ts +0 -34
- package/dist/src/ContrastModeProvider.d.ts.map +0 -1
- package/dist/src/createShadowDomElements.d.ts.map +0 -1
- package/dist/src/labs/NavAccordion.d.ts.map +0 -1
- package/dist/src/labs/TopNav.d.ts +0 -78
- package/dist/src/labs/TopNav.d.ts.map +0 -1
- package/src/ContrastModeProvider.tsx +0 -131
- package/src/labs/TopNav.tsx +0 -396
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import _Button from "@mui/material/Button";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
4
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
5
|
+
*
|
|
6
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
9
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
*
|
|
11
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import { memo, useCallback, useImperativeHandle, useMemo, useRef } from "react";
|
|
14
|
+
import styled from "@emotion/styled";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
16
|
+
import { MuiPropsContext } from "../../MuiPropsContext.js";
|
|
17
|
+
import { useOdysseyDesignTokens } from "../../OdysseyDesignTokensContext.js";
|
|
18
|
+
import { Tooltip } from "../../Tooltip.js";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
const StyledToggleButton = styled(_Button, {
|
|
22
|
+
shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "isSideNavCollapsed"
|
|
23
|
+
})(({
|
|
24
|
+
isSideNavCollapsed,
|
|
25
|
+
odysseyDesignTokens
|
|
26
|
+
}) => ({
|
|
27
|
+
backgroundColor: "transparent",
|
|
28
|
+
position: "relative",
|
|
29
|
+
width: odysseyDesignTokens.Spacing6,
|
|
30
|
+
height: odysseyDesignTokens.Spacing6,
|
|
31
|
+
border: 0,
|
|
32
|
+
zIndex: 2,
|
|
33
|
+
"&:focus-visible": {
|
|
34
|
+
boxShadow: `inset 0 0 0 2px ${odysseyDesignTokens.PalettePrimaryMain}`,
|
|
35
|
+
outline: "none"
|
|
36
|
+
},
|
|
37
|
+
"&:hover, &:focus": {
|
|
38
|
+
backgroundColor: "transparent",
|
|
39
|
+
"#lineOne": {
|
|
40
|
+
animation: `lineOne-animate-to-collapse ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,
|
|
41
|
+
animationFillMode: "forwards",
|
|
42
|
+
"@keyframes lineOne-animate-to-collapse": {
|
|
43
|
+
"0%": {
|
|
44
|
+
transform: "translate3d(-50%, -50%, 0)"
|
|
45
|
+
},
|
|
46
|
+
"50%": {
|
|
47
|
+
transform: "translate3d(-50%, -50%, 0) rotate(-90deg) scaleY(.75)"
|
|
48
|
+
},
|
|
49
|
+
"100%": {
|
|
50
|
+
transform: "translate3d(-50%, -27%, 0) rotate(-45deg) scaleY(.75)"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"#lineTwo": {
|
|
55
|
+
animation: `lineTwo-animate-to-collapse ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,
|
|
56
|
+
animationFillMode: "forwards",
|
|
57
|
+
"@keyframes lineTwo-animate-to-collapse": {
|
|
58
|
+
"0%": {
|
|
59
|
+
transform: "translate3d(-50%, -50%, 0)"
|
|
60
|
+
},
|
|
61
|
+
"50%": {
|
|
62
|
+
transform: "translate3d(-50%, -50%, 0) rotate(-90deg) scaleY(.75)"
|
|
63
|
+
},
|
|
64
|
+
"100%": {
|
|
65
|
+
transform: "translate3d(-50%, -73%, 0) rotate(-135deg) scaleY(.75)"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
...(isSideNavCollapsed && {
|
|
70
|
+
"#lineOne": {
|
|
71
|
+
animation: `lineOne-animate-to-expand ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,
|
|
72
|
+
animationFillMode: "forwards",
|
|
73
|
+
"@keyframes lineOne-animate-to-expand": {
|
|
74
|
+
"0%": {
|
|
75
|
+
transform: "translate3d(-50%, -50%, 0)"
|
|
76
|
+
},
|
|
77
|
+
"50%": {
|
|
78
|
+
transform: "translate3d(-50%, -50%, 0) rotate(90deg) scaleY(.75)"
|
|
79
|
+
},
|
|
80
|
+
"100%": {
|
|
81
|
+
transform: "translate3d(-50%, -73%, 0) rotate(135deg) scaleY(.75)"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"#lineTwo": {
|
|
86
|
+
animation: `lineTwo-animate-to-expand ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,
|
|
87
|
+
animationFillMode: "forwards",
|
|
88
|
+
"@keyframes lineTwo-animate-to-expand": {
|
|
89
|
+
"0%": {
|
|
90
|
+
transform: "translate3d(-50%, -50%, 0)"
|
|
91
|
+
},
|
|
92
|
+
"50%": {
|
|
93
|
+
transform: "translate3d(-50%, -50%, 0) rotate(90deg) scaleY(.75)"
|
|
94
|
+
},
|
|
95
|
+
"100%": {
|
|
96
|
+
transform: "translate3d(-50%, -27%, 0) rotate(45deg) scaleY(.75)"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
},
|
|
102
|
+
span: {
|
|
103
|
+
position: "absolute",
|
|
104
|
+
top: "50%",
|
|
105
|
+
left: "50%",
|
|
106
|
+
width: "2px",
|
|
107
|
+
height: odysseyDesignTokens.Spacing4,
|
|
108
|
+
backgroundColor: odysseyDesignTokens.HueNeutral600,
|
|
109
|
+
transform: "translate3d(-50%, -50%, 0)",
|
|
110
|
+
transition: `transform ${odysseyDesignTokens.TransitionDurationMain}`
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
const SideNavToggleButton = ({
|
|
114
|
+
ariaControls,
|
|
115
|
+
buttonRef,
|
|
116
|
+
id,
|
|
117
|
+
isSideNavCollapsed,
|
|
118
|
+
onClick,
|
|
119
|
+
tabIndex
|
|
120
|
+
}) => {
|
|
121
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
122
|
+
const {
|
|
123
|
+
t
|
|
124
|
+
} = useTranslation();
|
|
125
|
+
const localButtonRef = useRef(null);
|
|
126
|
+
useImperativeHandle(buttonRef, () => ({
|
|
127
|
+
focus: () => {
|
|
128
|
+
localButtonRef.current?.focus();
|
|
129
|
+
}
|
|
130
|
+
}), []);
|
|
131
|
+
const toggleLabel = useMemo(() => isSideNavCollapsed ? t("sidenav.toggle.expand") : t("sidenav.toggle.collapse"), [isSideNavCollapsed, t]);
|
|
132
|
+
const renderButton = useCallback(muiProps => {
|
|
133
|
+
return _jsxs(StyledToggleButton, {
|
|
134
|
+
...muiProps,
|
|
135
|
+
"aria-controls": ariaControls,
|
|
136
|
+
"aria-expanded": !isSideNavCollapsed,
|
|
137
|
+
"aria-label": toggleLabel,
|
|
138
|
+
"data-sidenav-toggle": true,
|
|
139
|
+
id: id,
|
|
140
|
+
isSideNavCollapsed: isSideNavCollapsed,
|
|
141
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
142
|
+
onClick: onClick,
|
|
143
|
+
ref: element => {
|
|
144
|
+
if (element) {
|
|
145
|
+
localButtonRef.current = element;
|
|
146
|
+
muiProps?.ref?.(element);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
tabIndex: tabIndex,
|
|
150
|
+
variant: "floating",
|
|
151
|
+
children: [_jsx("span", {
|
|
152
|
+
id: "lineOne"
|
|
153
|
+
}), _jsx("span", {
|
|
154
|
+
id: "lineTwo"
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
157
|
+
}, [ariaControls, id, isSideNavCollapsed, odysseyDesignTokens, onClick, tabIndex, toggleLabel]);
|
|
158
|
+
return _jsx(Tooltip, {
|
|
159
|
+
ariaType: "description",
|
|
160
|
+
placement: "right",
|
|
161
|
+
text: toggleLabel,
|
|
162
|
+
children: _jsx(MuiPropsContext.Consumer, {
|
|
163
|
+
children: renderButton
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
const MemoizedSideNavToggleButton = memo(SideNavToggleButton);
|
|
168
|
+
MemoizedSideNavToggleButton.displayName = "SideNavToggleButton";
|
|
169
|
+
export { MemoizedSideNavToggleButton as SideNavToggleButton };
|
|
170
|
+
//# sourceMappingURL=SideNavToggleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SideNavToggleButton.js","names":["memo","useCallback","useImperativeHandle","useMemo","useRef","styled","useTranslation","MuiPropsContext","useOdysseyDesignTokens","Tooltip","jsx","_jsx","jsxs","_jsxs","StyledToggleButton","_Button","shouldForwardProp","prop","isSideNavCollapsed","odysseyDesignTokens","backgroundColor","position","width","Spacing6","height","border","zIndex","boxShadow","PalettePrimaryMain","outline","animation","TransitionDurationMain","animationFillMode","transform","span","top","left","Spacing4","HueNeutral600","transition","SideNavToggleButton","ariaControls","buttonRef","id","onClick","tabIndex","t","localButtonRef","focus","current","toggleLabel","renderButton","muiProps","ref","element","variant","children","ariaType","placement","text","Consumer","MemoizedSideNavToggleButton","displayName"],"sources":["../../../src/labs/SideNav/SideNavToggleButton.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { Button as MuiButton } from \"@mui/material\";\nimport type { ButtonProps as MuiButtonProps } from \"@mui/material\";\nimport {\n HTMLAttributes,\n memo,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { FocusHandle } from \"../../inputUtils\";\nimport { MuiPropsContext, MuiPropsContextType } from \"../../MuiPropsContext\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../../OdysseyDesignTokensContext\";\nimport { Tooltip } from \"../../Tooltip\";\n\nconst StyledToggleButton = styled(MuiButton, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" && prop !== \"isSideNavCollapsed\",\n})(\n ({\n isSideNavCollapsed,\n odysseyDesignTokens,\n }: {\n isSideNavCollapsed: boolean;\n odysseyDesignTokens: DesignTokens;\n }) => ({\n backgroundColor: \"transparent\",\n position: \"relative\",\n width: odysseyDesignTokens.Spacing6,\n height: odysseyDesignTokens.Spacing6,\n border: 0,\n zIndex: 2,\n\n \"&:focus-visible\": {\n boxShadow: `inset 0 0 0 2px ${odysseyDesignTokens.PalettePrimaryMain}`,\n outline: \"none\",\n },\n\n \"&:hover, &:focus\": {\n backgroundColor: \"transparent\",\n\n \"#lineOne\": {\n animation: `lineOne-animate-to-collapse ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,\n animationFillMode: \"forwards\",\n \"@keyframes lineOne-animate-to-collapse\": {\n \"0%\": {\n transform: \"translate3d(-50%, -50%, 0)\",\n },\n \"50%\": {\n transform: \"translate3d(-50%, -50%, 0) rotate(-90deg) scaleY(.75)\",\n },\n \"100%\": {\n transform: \"translate3d(-50%, -27%, 0) rotate(-45deg) scaleY(.75)\",\n },\n },\n },\n\n \"#lineTwo\": {\n animation: `lineTwo-animate-to-collapse ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,\n animationFillMode: \"forwards\",\n \"@keyframes lineTwo-animate-to-collapse\": {\n \"0%\": {\n transform: \"translate3d(-50%, -50%, 0)\",\n },\n \"50%\": {\n transform: \"translate3d(-50%, -50%, 0) rotate(-90deg) scaleY(.75)\",\n },\n \"100%\": {\n transform: \"translate3d(-50%, -73%, 0) rotate(-135deg) scaleY(.75)\",\n },\n },\n },\n\n ...(isSideNavCollapsed && {\n \"#lineOne\": {\n animation: `lineOne-animate-to-expand ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,\n animationFillMode: \"forwards\",\n \"@keyframes lineOne-animate-to-expand\": {\n \"0%\": {\n transform: \"translate3d(-50%, -50%, 0)\",\n },\n \"50%\": {\n transform: \"translate3d(-50%, -50%, 0) rotate(90deg) scaleY(.75)\",\n },\n \"100%\": {\n transform:\n \"translate3d(-50%, -73%, 0) rotate(135deg) scaleY(.75)\",\n },\n },\n },\n\n \"#lineTwo\": {\n animation: `lineTwo-animate-to-expand ${odysseyDesignTokens.TransitionDurationMain} cubic-bezier(0, 0, 0.2, 1)`,\n animationFillMode: \"forwards\",\n \"@keyframes lineTwo-animate-to-expand\": {\n \"0%\": {\n transform: \"translate3d(-50%, -50%, 0)\",\n },\n \"50%\": {\n transform: \"translate3d(-50%, -50%, 0) rotate(90deg) scaleY(.75)\",\n },\n \"100%\": {\n transform: \"translate3d(-50%, -27%, 0) rotate(45deg) scaleY(.75)\",\n },\n },\n },\n }),\n },\n\n span: {\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n width: \"2px\",\n height: odysseyDesignTokens.Spacing4,\n backgroundColor: odysseyDesignTokens.HueNeutral600,\n transform: \"translate3d(-50%, -50%, 0)\",\n transition: `transform ${odysseyDesignTokens.TransitionDurationMain}`,\n },\n }),\n);\n\nexport type SideNavToggleButtonProps = {\n /**\n * The ref forwarded to the Button\n */\n buttonRef?: React.RefObject<FocusHandle>;\n /**\n * The `id` of the item this button controls\n */\n ariaControls: string;\n /**\n * The ID of the Button\n */\n id?: string;\n isSideNavCollapsed: boolean;\n tabIndex?: HTMLAttributes<HTMLElement>[\"tabIndex\"];\n /**\n * The click event handler for the Button\n */\n onClick?: MuiButtonProps[\"onClick\"];\n onKeyDown?: MuiButtonProps[\"onKeyDown\"];\n};\n\nconst SideNavToggleButton = ({\n ariaControls,\n buttonRef,\n id,\n isSideNavCollapsed,\n onClick,\n tabIndex,\n}: SideNavToggleButtonProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const localButtonRef = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n\n useImperativeHandle(\n buttonRef,\n () => ({\n focus: () => {\n localButtonRef.current?.focus();\n },\n }),\n [],\n );\n\n const toggleLabel = useMemo(\n () =>\n isSideNavCollapsed\n ? t(\"sidenav.toggle.expand\")\n : t(\"sidenav.toggle.collapse\"),\n [isSideNavCollapsed, t],\n );\n\n const renderButton = useCallback(\n (muiProps: MuiPropsContextType) => {\n return (\n <StyledToggleButton\n {...muiProps}\n aria-controls={ariaControls}\n aria-expanded={!isSideNavCollapsed}\n aria-label={toggleLabel}\n data-sidenav-toggle={true}\n id={id}\n isSideNavCollapsed={isSideNavCollapsed}\n odysseyDesignTokens={odysseyDesignTokens}\n onClick={onClick}\n ref={(element) => {\n if (element) {\n (\n localButtonRef as React.MutableRefObject<HTMLButtonElement>\n ).current = element;\n //@ts-expect-error ref is not an optional prop on the props context type\n muiProps?.ref?.(element);\n }\n }}\n tabIndex={tabIndex}\n variant=\"floating\"\n >\n <span id=\"lineOne\" />\n <span id=\"lineTwo\" />\n </StyledToggleButton>\n );\n },\n [\n ariaControls,\n id,\n isSideNavCollapsed,\n odysseyDesignTokens,\n onClick,\n tabIndex,\n toggleLabel,\n ],\n );\n\n return (\n <Tooltip ariaType=\"description\" placement=\"right\" text={toggleLabel}>\n <MuiPropsContext.Consumer>{renderButton}</MuiPropsContext.Consumer>\n </Tooltip>\n );\n};\n\nconst MemoizedSideNavToggleButton = memo(SideNavToggleButton);\nMemoizedSideNavToggleButton.displayName = \"SideNavToggleButton\";\n\nexport { MemoizedSideNavToggleButton as SideNavToggleButton };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,SAEEA,IAAI,EACJC,WAAW,EACXC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,cAAc,QAAQ,eAAe;AAAC,SAGtCC,eAAe;AAAA,SAGtBC,sBAAsB;AAAA,SAEfC,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEhB,MAAMC,kBAAkB,GAAGT,MAAM,CAAAU,OAAA,EAAY;EAC3CC,iBAAiB,EAAGC,IAAI,IACtBA,IAAI,KAAK,qBAAqB,IAAIA,IAAI,KAAK;AAC/C,CAAC,CAAC,CACA,CAAC;EACCC,kBAAkB;EAClBC;AAIF,CAAC,MAAM;EACLC,eAAe,EAAE,aAAa;EAC9BC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAEH,mBAAmB,CAACI,QAAQ;EACnCC,MAAM,EAAEL,mBAAmB,CAACI,QAAQ;EACpCE,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,CAAC;EAET,iBAAiB,EAAE;IACjBC,SAAS,EAAG,mBAAkBR,mBAAmB,CA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,OAAO,EAAEA,OAAQ;MACjBS,GAAG,EAAGC,OAAO,IAAK;QAChB,IAAIA,OAAO,EAAE;UAETP,cAAc,CACdE,OAAO,GAAGK,OAAO;UAEnBF,QAAQ,EAAEC,GAAG,GAAGC,OAAO,CAAC;QAC1B;MACF,CAAE;MACFT,QAAQ,EAAEA,QAAS;MACnBU,OAAO,EAAC,UAAU;MAAAC,QAAA,GAElB7C,IAAA;QAAMgC,EAAE,EAAC;MAAS,CAAE,CAAC,EACrBhC,IAAA;QAAMgC,EAAE,EAAC;MAAS,CAAE,CAAC;IAAA,CACH,CAAC;EAEzB,CAAC,EACD,CACEF,YAAY,EACZE,EAAE,EACFzB,kBAAkB,EAClBC,mBAAmB,EACnByB,OAAO,EACPC,QAAQ,EACRK,WAAW,CAEf,CAAC;EAED,OACEvC,IAAA,CAACF,OAAO;IAACgD,QAAQ,EAAC,aAAa;IAACC,SAAS,EAAC,OAAO;IAACC,IAAI,EAAET,WAAY;IAAAM,QAAA,EAClE7C,IAAA,CAACJ,eAAe,CAACqD,QAAQ;MAAAJ,QAAA,EAAEL;IAAY,CAA2B;EAAC,CAC5D,CAAC;AAEd,CAAC;AAED,MAAMU,2BAA2B,GAAG7D,IAAI,CAACwC,mBAAmB,CAAC;AAC7DqB,2BAA2B,CAACC,WAAW,GAAG,qBAAqB;AAE/D,SAASD,2BAA2B,IAAIrB,mBAAmB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { createContext, useContext, useMemo } from "react";
|
|
14
|
+
import { useSortable } from "@dnd-kit/sortable";
|
|
15
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
16
|
+
import styled from "@emotion/styled";
|
|
17
|
+
import { useOdysseyDesignTokens } from "../../../OdysseyDesignTokensContext.js";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
const SortableItemContext = createContext({
|
|
22
|
+
attributes: {},
|
|
23
|
+
listeners: undefined,
|
|
24
|
+
ref() {}
|
|
25
|
+
});
|
|
26
|
+
const StyledSortableListItem = styled("li", {
|
|
27
|
+
shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "isSelected"
|
|
28
|
+
})(({
|
|
29
|
+
odysseyDesignTokens,
|
|
30
|
+
isSelected
|
|
31
|
+
}) => ({
|
|
32
|
+
position: "relative",
|
|
33
|
+
button: {
|
|
34
|
+
top: "50%",
|
|
35
|
+
left: odysseyDesignTokens.Spacing2,
|
|
36
|
+
transform: "translateY(-50%)"
|
|
37
|
+
},
|
|
38
|
+
svg: {
|
|
39
|
+
path: {
|
|
40
|
+
fill: "currentColor"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"&:has(a:hover, button:hover, a:focus, button:focus, a:focus-visible, button:focus-visible, [role='button']:hover, [role='button']:focus, [role='button']:focus-visible)": {
|
|
44
|
+
button: {
|
|
45
|
+
opacity: 1,
|
|
46
|
+
outlineWidth: 0
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
...(isSelected && {
|
|
50
|
+
svg: {
|
|
51
|
+
path: {
|
|
52
|
+
fill: odysseyDesignTokens.TypographyColorAction
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}));
|
|
57
|
+
const StyledUl = styled("ul")({
|
|
58
|
+
padding: 0,
|
|
59
|
+
listStyle: "none",
|
|
60
|
+
listStyleType: "none"
|
|
61
|
+
});
|
|
62
|
+
const StyledDragHandleButton = styled("button", {
|
|
63
|
+
shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "isDragging"
|
|
64
|
+
})(({
|
|
65
|
+
odysseyDesignTokens,
|
|
66
|
+
isDragging
|
|
67
|
+
}) => ({
|
|
68
|
+
position: "absolute",
|
|
69
|
+
opacity: 0,
|
|
70
|
+
padding: odysseyDesignTokens.Spacing2,
|
|
71
|
+
border: "none",
|
|
72
|
+
backgroundColor: "transparent",
|
|
73
|
+
cursor: `${isDragging ? "grabbing" : "grab"}`,
|
|
74
|
+
transition: `opacity ${odysseyDesignTokens.TransitionDurationMain}`,
|
|
75
|
+
borderRadius: odysseyDesignTokens.BorderRadiusMain,
|
|
76
|
+
svg: {
|
|
77
|
+
display: "flex"
|
|
78
|
+
},
|
|
79
|
+
"&:focus, &:focus-visible": {
|
|
80
|
+
outline: "none",
|
|
81
|
+
boxShadow: `inset 0 0 0 2px ${odysseyDesignTokens.PalettePrimaryMain}`
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
export const DragHandle = ({
|
|
85
|
+
isDragging
|
|
86
|
+
}) => {
|
|
87
|
+
const {
|
|
88
|
+
attributes,
|
|
89
|
+
listeners,
|
|
90
|
+
ref
|
|
91
|
+
} = useContext(SortableItemContext);
|
|
92
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
93
|
+
const {
|
|
94
|
+
t
|
|
95
|
+
} = useTranslation();
|
|
96
|
+
return _jsx(StyledDragHandleButton, {
|
|
97
|
+
...attributes,
|
|
98
|
+
...listeners,
|
|
99
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
100
|
+
isDragging: isDragging,
|
|
101
|
+
ref: ref,
|
|
102
|
+
"aria-label": t("navigation.drag.handle"),
|
|
103
|
+
children: _jsx("svg", {
|
|
104
|
+
width: "16",
|
|
105
|
+
height: "16",
|
|
106
|
+
viewBox: "0 0 16 16",
|
|
107
|
+
fill: "none",
|
|
108
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
109
|
+
children: _jsx("path", {
|
|
110
|
+
fillRule: "evenodd",
|
|
111
|
+
clipRule: "evenodd",
|
|
112
|
+
d: "M6 2.33331C6 2.8856 5.55228 3.33331 5 3.33331C4.44772 3.33331 4 2.8856 4 2.33331C4 1.78103 4.44772 1.33331 5 1.33331C5.55228 1.33331 6 1.78103 6 2.33331ZM11 3.33331C11.5523 3.33331 12 2.8856 12 2.33331C12 1.78103 11.5523 1.33331 11 1.33331C10.4477 1.33331 10 1.78103 10 2.33331C10 2.8856 10.4477 3.33331 11 3.33331ZM11 7.11109C11.5523 7.11109 12 6.66338 12 6.11109C12 5.55881 11.5523 5.11109 11 5.11109C10.4477 5.11109 10 5.55881 10 6.11109C10 6.66338 10.4477 7.11109 11 7.11109ZM12 9.88887C12 10.4412 11.5523 10.8889 11 10.8889C10.4477 10.8889 10 10.4412 10 9.88887C10 9.33659 10.4477 8.88887 11 8.88887C11.5523 8.88887 12 9.33659 12 9.88887ZM11 14.6666C11.5523 14.6666 12 14.2189 12 13.6666C12 13.1144 11.5523 12.6666 11 12.6666C10.4477 12.6666 10 13.1144 10 13.6666C10 14.2189 10.4477 14.6666 11 14.6666ZM5 7.11109C5.55228 7.11109 6 6.66338 6 6.11109C6 5.55881 5.55228 5.11109 5 5.11109C4.44772 5.11109 4 5.55881 4 6.11109C4 6.66338 4.44772 7.11109 5 7.11109ZM6 9.88888C6 10.4412 5.55228 10.8889 5 10.8889C4.44772 10.8889 4 10.4412 4 9.88888C4 9.33659 4.44772 8.88888 5 8.88888C5.55228 8.88888 6 9.33659 6 9.88888ZM5 14.6666C5.55228 14.6666 6 14.2189 6 13.6666C6 13.1144 5.55228 12.6666 5 12.6666C4.44772 12.6666 4 13.1144 4 13.6666C4 14.2189 4.44772 14.6666 5 14.6666Z",
|
|
113
|
+
fill: "#3F59E4"
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
export const SortableItem = ({
|
|
119
|
+
id,
|
|
120
|
+
isDisabled,
|
|
121
|
+
isSelected,
|
|
122
|
+
children
|
|
123
|
+
}) => {
|
|
124
|
+
const {
|
|
125
|
+
attributes,
|
|
126
|
+
isDragging,
|
|
127
|
+
listeners,
|
|
128
|
+
setNodeRef,
|
|
129
|
+
setActivatorNodeRef,
|
|
130
|
+
transform,
|
|
131
|
+
transition
|
|
132
|
+
} = useSortable({
|
|
133
|
+
id
|
|
134
|
+
});
|
|
135
|
+
const context = useMemo(() => ({
|
|
136
|
+
attributes,
|
|
137
|
+
listeners,
|
|
138
|
+
ref: setActivatorNodeRef
|
|
139
|
+
}), [attributes, listeners, setActivatorNodeRef]);
|
|
140
|
+
const style = {
|
|
141
|
+
opacity: isDragging ? 0.4 : undefined,
|
|
142
|
+
transform: CSS.Translate.toString(transform),
|
|
143
|
+
transition
|
|
144
|
+
};
|
|
145
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
146
|
+
return _jsx(SortableItemContext.Provider, {
|
|
147
|
+
value: context,
|
|
148
|
+
children: _jsxs(StyledSortableListItem, {
|
|
149
|
+
"data-sortable-container": "true",
|
|
150
|
+
ref: setNodeRef,
|
|
151
|
+
style: style,
|
|
152
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
153
|
+
isSelected: isSelected,
|
|
154
|
+
children: [!isDisabled && _jsx(DragHandle, {
|
|
155
|
+
isDragging: isDragging
|
|
156
|
+
}), _jsx(StyledUl, {
|
|
157
|
+
children: children
|
|
158
|
+
})]
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=SortableItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableItem.js","names":["createContext","useContext","useMemo","useSortable","CSS","styled","useOdysseyDesignTokens","useTranslation","jsx","_jsx","jsxs","_jsxs","SortableItemContext","attributes","listeners","undefined","ref","StyledSortableListItem","shouldForwardProp","prop","odysseyDesignTokens","isSelected","position","button","top","left","Spacing2","transform","svg","path","fill","opacity","outlineWidth","TypographyColorAction","StyledUl","padding","listStyle","listStyleType","StyledDragHandleButton","isDragging","border","backgroundColor","cursor","transition","TransitionDurationMain","borderRadius","BorderRadiusMain","display","outline","boxShadow","PalettePrimaryMain","DragHandle","t","children","width","height","viewBox","xmlns","fillRule","clipRule","d","SortableItem","id","isDisabled","setNodeRef","setActivatorNodeRef","context","style","Translate","toString","Provider","value"],"sources":["../../../../src/labs/SideNav/SortableList/SortableItem.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { CSSProperties, PropsWithChildren } from \"react\";\nimport type {\n DraggableSyntheticListeners,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { useSortable } from \"@dnd-kit/sortable\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { CSS } from \"@dnd-kit/utilities\";\nimport styled from \"@emotion/styled\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../../../OdysseyDesignTokensContext\";\nimport { useTranslation } from \"react-i18next\";\n\ntype ItemProps = {\n id: UniqueIdentifier;\n isDisabled?: boolean;\n isSelected?: boolean;\n};\n\ninterface Context {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n attributes: Record<string, any>;\n listeners: DraggableSyntheticListeners;\n ref(node: HTMLElement | null): void;\n}\n\nconst SortableItemContext = createContext<Context>({\n attributes: {},\n listeners: undefined,\n ref() {},\n});\n\nconst StyledSortableListItem = styled(\"li\", {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" && prop !== \"isSelected\",\n})<{\n odysseyDesignTokens: DesignTokens;\n isSelected?: boolean;\n}>(({ odysseyDesignTokens, isSelected }) => ({\n position: \"relative\",\n\n button: {\n top: \"50%\",\n left: odysseyDesignTokens.Spacing2,\n transform: \"translateY(-50%)\",\n },\n\n svg: {\n path: {\n fill: \"currentColor\",\n },\n },\n\n \"&:has(a:hover, button:hover, a:focus, button:focus, a:focus-visible, button:focus-visible, [role='button']:hover, [role='button']:focus, [role='button']:focus-visible)\":\n {\n button: {\n opacity: 1,\n outlineWidth: 0,\n },\n },\n\n ...(isSelected && {\n svg: {\n path: {\n fill: odysseyDesignTokens.TypographyColorAction,\n },\n },\n }),\n}));\n\nconst StyledUl = styled(\"ul\")({\n padding: 0,\n listStyle: \"none\",\n listStyleType: \"none\",\n});\n\nconst StyledDragHandleButton = styled(\"button\", {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" && prop !== \"isDragging\",\n})<{\n odysseyDesignTokens: DesignTokens;\n isDragging?: boolean;\n}>(({ odysseyDesignTokens, isDragging }) => ({\n position: \"absolute\",\n opacity: 0,\n // paddingInlineStart: odysseyDesignTokens.Spacing4,\n padding: odysseyDesignTokens.Spacing2,\n // paddingBlock: 0,\n border: \"none\",\n backgroundColor: \"transparent\",\n cursor: `${isDragging ? \"grabbing\" : \"grab\"}`,\n transition: `opacity ${odysseyDesignTokens.TransitionDurationMain}`,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n\n svg: {\n display: \"flex\",\n },\n\n \"&:focus, &:focus-visible\": {\n outline: \"none\",\n boxShadow: `inset 0 0 0 2px ${odysseyDesignTokens.PalettePrimaryMain}`,\n },\n}));\n\ntype DragHandleProps = {\n isDisabled?: boolean;\n isDragging?: boolean;\n};\n\nexport const DragHandle = ({ isDragging }: DragHandleProps) => {\n const { attributes, listeners, ref } = useContext(SortableItemContext);\n const odysseyDesignTokens: DesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n return (\n <StyledDragHandleButton\n {...attributes}\n {...listeners}\n odysseyDesignTokens={odysseyDesignTokens}\n isDragging={isDragging}\n ref={ref}\n aria-label={t(\"navigation.drag.handle\")}\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M6 2.33331C6 2.8856 5.55228 3.33331 5 3.33331C4.44772 3.33331 4 2.8856 4 2.33331C4 1.78103 4.44772 1.33331 5 1.33331C5.55228 1.33331 6 1.78103 6 2.33331ZM11 3.33331C11.5523 3.33331 12 2.8856 12 2.33331C12 1.78103 11.5523 1.33331 11 1.33331C10.4477 1.33331 10 1.78103 10 2.33331C10 2.8856 10.4477 3.33331 11 3.33331ZM11 7.11109C11.5523 7.11109 12 6.66338 12 6.11109C12 5.55881 11.5523 5.11109 11 5.11109C10.4477 5.11109 10 5.55881 10 6.11109C10 6.66338 10.4477 7.11109 11 7.11109ZM12 9.88887C12 10.4412 11.5523 10.8889 11 10.8889C10.4477 10.8889 10 10.4412 10 9.88887C10 9.33659 10.4477 8.88887 11 8.88887C11.5523 8.88887 12 9.33659 12 9.88887ZM11 14.6666C11.5523 14.6666 12 14.2189 12 13.6666C12 13.1144 11.5523 12.6666 11 12.6666C10.4477 12.6666 10 13.1144 10 13.6666C10 14.2189 10.4477 14.6666 11 14.6666ZM5 7.11109C5.55228 7.11109 6 6.66338 6 6.11109C6 5.55881 5.55228 5.11109 5 5.11109C4.44772 5.11109 4 5.55881 4 6.11109C4 6.66338 4.44772 7.11109 5 7.11109ZM6 9.88888C6 10.4412 5.55228 10.8889 5 10.8889C4.44772 10.8889 4 10.4412 4 9.88888C4 9.33659 4.44772 8.88888 5 8.88888C5.55228 8.88888 6 9.33659 6 9.88888ZM5 14.6666C5.55228 14.6666 6 14.2189 6 13.6666C6 13.1144 5.55228 12.6666 5 12.6666C4.44772 12.6666 4 13.1144 4 13.6666C4 14.2189 4.44772 14.6666 5 14.6666Z\"\n fill=\"#3F59E4\"\n />\n </svg>\n </StyledDragHandleButton>\n );\n};\n\nexport const SortableItem = ({\n id,\n isDisabled,\n isSelected,\n children,\n}: PropsWithChildren<ItemProps>) => {\n const {\n attributes,\n isDragging,\n listeners,\n setNodeRef,\n setActivatorNodeRef,\n transform,\n transition,\n } = useSortable({ id });\n const context: Context = useMemo(\n () => ({\n attributes,\n listeners,\n ref: setActivatorNodeRef,\n }),\n [attributes, listeners, setActivatorNodeRef],\n );\n const style: CSSProperties = {\n opacity: isDragging ? 0.4 : undefined,\n transform: CSS.Translate.toString(transform),\n transition,\n };\n\n const odysseyDesignTokens: DesignTokens = useOdysseyDesignTokens();\n return (\n <SortableItemContext.Provider value={context}>\n <StyledSortableListItem\n data-sortable-container=\"true\"\n ref={setNodeRef}\n style={style}\n odysseyDesignTokens={odysseyDesignTokens}\n isSelected={isSelected}\n >\n {!isDisabled && <DragHandle isDragging={isDragging} />}\n <StyledUl>{children}</StyledUl>\n </StyledSortableListItem>\n </SortableItemContext.Provider>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAO1D,SAASC,WAAW,QAAQ,mBAAmB;AAE/C,SAASC,GAAG,QAAQ,oBAAoB;AACxC,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAGnCC,sBAAsB;AAExB,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAe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3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import React, { useMemo, useState } from "react";
|
|
14
|
+
import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
|
15
|
+
import { SortableContext, sortableKeyboardCoordinates } from "@dnd-kit/sortable";
|
|
16
|
+
import { SortableItem } from "./SortableItem.js";
|
|
17
|
+
import { SortableOverlay } from "./SortableOverlay.js";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
export const SortableList = ({
|
|
22
|
+
parentId,
|
|
23
|
+
items,
|
|
24
|
+
onChange,
|
|
25
|
+
renderItem
|
|
26
|
+
}) => {
|
|
27
|
+
const [active, setActive] = useState(null);
|
|
28
|
+
const activeItem = useMemo(() => items.find(item => item.id === active?.id), [active, items]);
|
|
29
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
30
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
31
|
+
}));
|
|
32
|
+
const {
|
|
33
|
+
t
|
|
34
|
+
} = useTranslation();
|
|
35
|
+
const announcements = useMemo(() => ({
|
|
36
|
+
onDragStart: ({
|
|
37
|
+
active
|
|
38
|
+
}) => {
|
|
39
|
+
return `${t("sortable.list.drag.start", {
|
|
40
|
+
activeId: active.id
|
|
41
|
+
})}`;
|
|
42
|
+
},
|
|
43
|
+
onDragOver: ({
|
|
44
|
+
active,
|
|
45
|
+
over
|
|
46
|
+
}) => {
|
|
47
|
+
if (over) {
|
|
48
|
+
return `${t("sortable.list.drag.moved.over", {
|
|
49
|
+
activeId: active.id,
|
|
50
|
+
overId: over.id
|
|
51
|
+
})}`;
|
|
52
|
+
}
|
|
53
|
+
return `${t("sortable.list.drag.nolonger.over", {
|
|
54
|
+
activeId: active.id
|
|
55
|
+
})}`;
|
|
56
|
+
},
|
|
57
|
+
onDragEnd: ({
|
|
58
|
+
active,
|
|
59
|
+
over
|
|
60
|
+
}) => {
|
|
61
|
+
if (over) {
|
|
62
|
+
return `${t("sortable.list.drag.end.dropped.over", {
|
|
63
|
+
activeId: active.id,
|
|
64
|
+
overId: over.id
|
|
65
|
+
})}`;
|
|
66
|
+
}
|
|
67
|
+
return `${t("sortable.list.drag.end.dropped", {
|
|
68
|
+
activeId: active.id
|
|
69
|
+
})}`;
|
|
70
|
+
},
|
|
71
|
+
onDragCancel: ({
|
|
72
|
+
active
|
|
73
|
+
}) => {
|
|
74
|
+
return `${t("sortable.list.drag.cancel", {
|
|
75
|
+
activeId: active.id
|
|
76
|
+
})}`;
|
|
77
|
+
}
|
|
78
|
+
}), [t]);
|
|
79
|
+
return _jsxs(DndContext, {
|
|
80
|
+
accessibility: {
|
|
81
|
+
announcements: announcements
|
|
82
|
+
},
|
|
83
|
+
sensors: sensors,
|
|
84
|
+
onDragStart: ({
|
|
85
|
+
active
|
|
86
|
+
}) => {
|
|
87
|
+
setActive(active);
|
|
88
|
+
},
|
|
89
|
+
onDragEnd: ({
|
|
90
|
+
active,
|
|
91
|
+
over
|
|
92
|
+
}) => {
|
|
93
|
+
if (over && active.id !== over?.id) {
|
|
94
|
+
const activeIndex = items.findIndex(({
|
|
95
|
+
id
|
|
96
|
+
}) => id === active.id);
|
|
97
|
+
const overIndex = items.findIndex(({
|
|
98
|
+
id
|
|
99
|
+
}) => id === over.id);
|
|
100
|
+
onChange(parentId, activeIndex, overIndex);
|
|
101
|
+
}
|
|
102
|
+
setActive(null);
|
|
103
|
+
},
|
|
104
|
+
onDragCancel: () => {
|
|
105
|
+
setActive(null);
|
|
106
|
+
},
|
|
107
|
+
children: [_jsx(SortableContext, {
|
|
108
|
+
items: items,
|
|
109
|
+
children: items.map(item => _jsx(React.Fragment, {
|
|
110
|
+
children: renderItem(item)
|
|
111
|
+
}, item.id))
|
|
112
|
+
}), _jsx(SortableOverlay, {
|
|
113
|
+
children: activeItem ? renderItem(activeItem) : null
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
SortableList.Item = SortableItem;
|
|
118
|
+
//# sourceMappingURL=SortableList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableList.js","names":["React","useMemo","useState","DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","SortableContext","sortableKeyboardCoordinates","SortableItem","SortableOverlay","useTranslation","jsx","_jsx","jsxs","_jsxs","SortableList","parentId","items","onChange","renderItem","active","setActive","activeItem","find","item","id","sensors","coordinateGetter","t","announcements","onDragStart","activeId","onDragOver","over","overId","onDragEnd","onDragCancel","accessibility","activeIndex","findIndex","overIndex","children","map","Fragment","Item"],"sources":["../../../../src/labs/SideNav/SortableList/SortableList.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n DndContext,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport type { Active, Announcements, UniqueIdentifier } from \"@dnd-kit/core\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n SortableContext,\n sortableKeyboardCoordinates,\n} from \"@dnd-kit/sortable\";\n\nimport { SortableItem } from \"./SortableItem\";\nimport { SortableOverlay } from \"./SortableOverlay\";\nimport { useTranslation } from \"react-i18next\";\n\nexport interface BaseItem {\n id: UniqueIdentifier;\n isDisabled: boolean | undefined;\n isSelected: boolean | undefined;\n navItem: ReactNode;\n}\n\ninterface ListProps<T extends BaseItem> {\n parentId: string;\n items: T[];\n onChange(parentId: string, activeIndex: number, overIndex: number): void;\n renderItem(item: T): ReactNode;\n}\n\nexport const SortableList = <T extends BaseItem>({\n parentId,\n items,\n onChange,\n renderItem,\n}: ListProps<T>) => {\n const [active, setActive] = useState<Active | null>(null);\n const activeItem = useMemo(\n () => items.find((item) => item.id === active?.id),\n [active, items],\n );\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const { t } = useTranslation();\n const announcements: Announcements = useMemo(\n () => ({\n onDragStart: ({ active }) => {\n return `${t(\"sortable.list.drag.start\", { activeId: active.id })}`;\n },\n onDragOver: ({ active, over }) => {\n if (over) {\n return `${t(\"sortable.list.drag.moved.over\", { activeId: active.id, overId: over.id })}`;\n }\n return `${t(\"sortable.list.drag.nolonger.over\", { activeId: active.id })}`;\n },\n onDragEnd: ({ active, over }) => {\n if (over) {\n return `${t(\"sortable.list.drag.end.dropped.over\", { activeId: active.id, overId: over.id })}`;\n }\n return `${t(\"sortable.list.drag.end.dropped\", { activeId: active.id })}`;\n },\n onDragCancel: ({ active }) => {\n return `${t(\"sortable.list.drag.cancel\", { activeId: active.id })}`;\n },\n }),\n [t],\n );\n\n return (\n <DndContext\n accessibility={{ announcements: announcements }}\n sensors={sensors}\n onDragStart={({ active }) => {\n setActive(active);\n }}\n onDragEnd={({ active, over }) => {\n if (over && active.id !== over?.id) {\n const activeIndex = items.findIndex(({ id }) => id === active.id);\n const overIndex = items.findIndex(({ id }) => id === over.id);\n onChange(parentId, activeIndex, overIndex);\n }\n setActive(null);\n }}\n onDragCancel={() => {\n setActive(null);\n }}\n >\n <SortableContext items={items}>\n {items.map((item) => (\n <React.Fragment key={item.id}>{renderItem(item)}</React.Fragment>\n ))}\n </SortableContext>\n <SortableOverlay>\n {activeItem ? renderItem(activeItem) : null}\n </SortableOverlay>\n </DndContext>\n );\n};\n\nSortableList.Item = SortableItem;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAGhD,SACEC,UAAU,EACVC,cAAc,EACdC,aAAa,EACbC,SAAS,EACTC,UAAU,QACL,eAAe;AAGtB,SACEC,eAAe,EACfC,2BAA2B,QACtB,mBAAmB;AAAC,SAElBC,YAAY;AAAA,SACZC,eAAe;AACxB,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAgB/C,OAAO,MAAMC,YAAY,GAAGA,CAAqB;EAC/CC,QAAQ;EACRC,KAAK;EACLC,QAAQ;EACRC;AACY,CAAC,KAAK;EAClB,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGrB,QAAQ,CAAgB,IAAI,CAAC;EACzD,MAAMsB,UAAU,GAAGvB,OAAO,CACxB,MAAMkB,KAAK,CAACM,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,EAAE,KAAKL,MAAM,EAAEK,EAAE,CAAC,EAClD,CAACL,MAAM,EAAEH,KAAK,CAChB,CAAC;EACD,MAAMS,OAAO,GAAGrB,UAAU,CACxBD,SAAS,CAACD,aAAa,CAAC,EACxBC,SAAS,CAACF,cAAc,EAAE;IACxByB,gBAAgB,EAA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,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/import { DragOverlay, defaultDropAnimationSideEffects } from "@dnd-kit/core";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const dropAnimationConfig = {
|
|
14
|
+
sideEffects: defaultDropAnimationSideEffects({
|
|
15
|
+
styles: {
|
|
16
|
+
active: {
|
|
17
|
+
opacity: "0.4"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
export function SortableOverlay({
|
|
23
|
+
children
|
|
24
|
+
}) {
|
|
25
|
+
return _jsx(DragOverlay, {
|
|
26
|
+
dropAnimation: dropAnimationConfig,
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=SortableOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableOverlay.js","names":["DragOverlay","defaultDropAnimationSideEffects","jsx","_jsx","dropAnimationConfig","sideEffects","styles","active","opacity","SortableOverlay","children","dropAnimation"],"sources":["../../../../src/labs/SideNav/SortableList/SortableOverlay.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport type { PropsWithChildren } from \"react\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { DragOverlay, defaultDropAnimationSideEffects } from \"@dnd-kit/core\";\nimport type { DropAnimation } from \"@dnd-kit/core\";\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.4\",\n },\n },\n }),\n};\n\ninterface Props {}\n\nexport function SortableOverlay({ children }: PropsWithChildren<Props>) {\n return (\n <DragOverlay dropAnimation={dropAnimationConfig}>{children}</DragOverlay>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAIA,SAASA,WAAW,EAAEC,+BAA+B,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG7E,MAAMC,mBAAkC,GAAG;EACzCC,WAAW,EAAEJ,+BAA+B,CAAC;IAC3CK,MAAM,EAAE;MACNC,MAAM,EAAE;QACNC,OAAO,EAAE;MACX;IACF;EACF,CAAC;AACH,CAAC;AAID,OAAO,SAASC,eAAeA,CAAC;EAAEC;AAAmC,CAAC,EAAE;EACtE,OACEP,IAAA,CAACH,WAAW;IAACW,aAAa,EAAEP,mBAAoB;IAAAM,QAAA,EAAEA;EAAQ,CAAc,CAAC;AAE7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/labs/SideNav/types.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport type { ReactElement } from \"react\";\nimport type { HtmlProps } from \"../../HtmlProps\";\nimport type { statusSeverityValues } from \"../../Status\";\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/labs/SideNav/types.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport type { ReactElement } from \"react\";\nimport type { HtmlProps } from \"../../HtmlProps\";\nimport type { statusSeverityValues } from \"../../Status\";\n\nexport type SideNavLogoProps = {\n href?: string;\n} & (\n | {\n /**\n * a component to render as the logo\n */\n logoComponent: ReactElement;\n imageAltText?: never;\n imageUrl?: never;\n }\n | {\n /**\n * The src url to render in an `img` tag\n */\n imageUrl: string;\n /**\n * alt text for the img logo\n */\n imageAltText: string;\n logoComponent?: never;\n }\n | {\n /**\n * The src url to render in an `img` tag\n */\n imageUrl?: never;\n /**\n * alt text for the img logo\n */\n imageAltText?: never;\n logoComponent?: never;\n }\n);\n\nexport type SideNavProps = {\n /**\n * Side Nav header text that is usually reserved to show the App name\n */\n appName: string;\n /**\n * Determines whether the side nav is collapsible\n */\n isCollapsible?: boolean;\n /**\n * Determines whether the side nav items use compact layout\n */\n isCompact?: boolean;\n /**\n * Before the side nav has items, it will be in a loading state.\n */\n isLoading?: boolean;\n /**\n * An optional logo component or src string for an img to display in the header. If not provided, will default to the Okta logo\n */\n logoProps?: SideNavLogoProps;\n /**\n * Triggers when the side nav is collapsed\n */\n onCollapse?(): void;\n /**\n * Triggers when the side nav is expanded\n */\n onExpand?(): void;\n /**\n * Triggers when the item is reordered\n */\n onSort?(reorderedItems: SideNavItem[]): void;\n /**\n * Nav items in the side nav\n */\n sideNavItems: SideNavItem[];\n} & (\n | {\n /**\n * The component to display as the footer; if present the `footerItems` are ignored and not rendered.\n */\n footerComponent?: ReactElement;\n footerItems?: never;\n hasCustomFooter: true;\n }\n | {\n footerComponent?: never;\n /**\n * Footer items in the side nav\n */\n footerItems?: SideNavFooterItem[];\n hasCustomFooter?: false;\n }\n) &\n Pick<HtmlProps, \"testId\">;\n\nexport type SideNavItem = {\n /**\n * The number to display as a count alongside the nav item\n */\n count?: number;\n /**\n * The icon element to display at the end of the Nav Item\n */\n endIcon?: ReactElement;\n id: string;\n /**\n * Whether the item is disabled. When set to true the nav item is set to Disabled color,\n * the link/item is not clickable, and item with nestedNavItems is not expandable.\n */\n isDisabled?: boolean;\n /**\n * Whether the item is active/selected\n */\n isSelected?: boolean;\n label: string;\n /**\n * Event fired when the nav item is clicked\n */\n onClick?(): void;\n /**\n * The status element to display after the label\n */\n severity?: (typeof statusSeverityValues)[number];\n /**\n * The icon element to display at the start of the Nav Item\n */\n startIcon?: ReactElement;\n /**\n * The label to display inside the status\n */\n statusLabel?: string;\n /**\n * The link target prop. e.g., \"_blank\"\n */\n target?: string;\n} & (\n | {\n nestedNavItems?: never;\n href?: never;\n isDefaultExpanded?: never;\n isExpanded?: never;\n /**\n * Determines if the side nav item is a section header\n */\n isSectionHeader: true;\n isSortable?: never;\n }\n | {\n nestedNavItems?: never;\n /**\n * link added to the nav item. if it is undefined, static text will be displayed.\n * fires onClick event when it is passed\n */\n href?: string;\n isDefaultExpanded?: never;\n isExpanded?: never;\n isSectionHeader?: never;\n isSortable?: never;\n }\n | {\n /**\n * An array of side nav items to be displayed as nestedNavItems within Accordion\n */\n nestedNavItems?: Array<Omit<SideNavItem, \"startIcon\" | \"nestedNavItems\">>;\n endIcon?: never;\n href?: never;\n /**\n * Whether the accordion (nav item with nestedNavItems) is expanded by default\n */\n isDefaultExpanded?: boolean;\n /**\n * If true, expands the accordion, otherwise collapse it.\n * Setting this prop enables control over the accordion.\n */\n isExpanded?: boolean;\n /**\n * If true, enables sorting for the accordion items\n */\n isSectionHeader?: never;\n isSortable?: boolean;\n }\n);\n\nexport type SideNavFooterItem = {\n href?: string;\n id: string;\n label: string;\n};\n"],"mappings":""}
|