@okta/odyssey-react-mui 1.27.1 → 1.29.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 +25 -0
- package/dist/Breadcrumbs.js +1 -0
- package/dist/Breadcrumbs.js.map +1 -1
- package/dist/{Button.js → Buttons/BaseButton.js} +11 -10
- package/dist/Buttons/BaseButton.js.map +1 -0
- package/dist/{MenuButton.js → Buttons/BaseMenuButton.js} +30 -10
- package/dist/Buttons/BaseMenuButton.js.map +1 -0
- package/dist/Buttons/Button.js +24 -0
- package/dist/Buttons/Button.js.map +1 -0
- package/dist/Buttons/ButtonContext.js.map +1 -0
- package/dist/Buttons/MenuButton.js +25 -0
- package/dist/Buttons/MenuButton.js.map +1 -0
- package/dist/Buttons/MenuContext.js.map +1 -0
- package/dist/{MenuItem.js → Buttons/MenuItem.js} +1 -0
- package/dist/Buttons/MenuItem.js.map +1 -0
- package/dist/Buttons/index.js +18 -0
- package/dist/{labs/UiShell → Buttons}/index.js.map +1 -1
- package/dist/Card.js +1 -2
- package/dist/Card.js.map +1 -1
- package/dist/Checkbox.js +62 -35
- package/dist/Checkbox.js.map +1 -1
- package/dist/DataTable/DataTable.js +1 -2
- package/dist/DataTable/DataTable.js.map +1 -1
- package/dist/DataTable/DataTableRowActions.js +1 -2
- package/dist/DataTable/DataTableRowActions.js.map +1 -1
- package/dist/DataTable/DataTableSettings.js +1 -2
- package/dist/DataTable/DataTableSettings.js.map +1 -1
- package/dist/DataTable/reorderDataRowsLocally.js.map +1 -1
- package/dist/DataTable/useRowReordering.js.map +1 -1
- package/dist/Dialog.js +1 -1
- package/dist/Dialog.js.map +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/Drawer.js.map +1 -1
- package/dist/FileUploader/FileUploader.js +1 -1
- package/dist/FileUploader/FileUploader.js.map +1 -1
- package/dist/Form.js.map +1 -1
- package/dist/HtmlProps.js.map +1 -1
- package/dist/Pagination/Pagination.js +3 -2
- package/dist/Pagination/Pagination.js.map +1 -1
- package/dist/Radio.js +65 -38
- package/dist/Radio.js.map +1 -1
- package/dist/Toast.js +1 -1
- package/dist/Toast.js.map +1 -1
- package/dist/Typography.js +20 -0
- package/dist/Typography.js.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/index.scss +1 -1
- package/dist/labs/AppSwitcher/AppSwitcher.js +76 -0
- package/dist/labs/AppSwitcher/AppSwitcher.js.map +1 -0
- package/dist/labs/AppSwitcher/AppSwitcherApp.js +112 -0
- package/dist/labs/AppSwitcher/AppSwitcherApp.js.map +1 -0
- package/dist/labs/{SideNav → AppSwitcher}/OktaAura.js +16 -3
- package/dist/labs/AppSwitcher/OktaAura.js.map +1 -0
- package/dist/{src/labs/UiShell/useHasUiShell.d.ts → labs/AppSwitcher/index.js} +2 -2
- package/dist/labs/AppSwitcher/index.js.map +1 -0
- package/dist/labs/AppTile.js +102 -65
- package/dist/labs/AppTile.js.map +1 -1
- package/dist/labs/DataFilters.js +10 -6
- package/dist/labs/DataFilters.js.map +1 -1
- package/dist/labs/DataTable.js +7 -7
- package/dist/labs/DataTable.js.map +1 -1
- package/dist/labs/DataTablePagination.js +1 -1
- package/dist/labs/DataTablePagination.js.map +1 -1
- package/dist/labs/DataView/BulkActionsMenu.js +1 -2
- package/dist/labs/DataView/BulkActionsMenu.js.map +1 -1
- package/dist/labs/DataView/CardLayoutContent.js +6 -5
- package/dist/labs/DataView/CardLayoutContent.js.map +1 -1
- package/dist/labs/DataView/DataCard.js +54 -42
- package/dist/labs/DataView/DataCard.js.map +1 -1
- package/dist/labs/DataView/DataTable.js.map +1 -1
- package/dist/labs/DataView/DataView.js +3 -3
- package/dist/labs/DataView/DataView.js.map +1 -1
- package/dist/labs/DataView/DetailPanel.js.map +1 -1
- package/dist/labs/DataView/LayoutSwitcher.js +1 -2
- package/dist/labs/DataView/LayoutSwitcher.js.map +1 -1
- package/dist/labs/DataView/RowActions.js +1 -1
- package/dist/labs/DataView/RowActions.js.map +1 -1
- package/dist/labs/DataView/TableLayoutContent.js +2 -3
- package/dist/labs/DataView/TableLayoutContent.js.map +1 -1
- package/dist/labs/DataView/TableSettings.js +1 -2
- package/dist/labs/DataView/TableSettings.js.map +1 -1
- package/dist/labs/DataView/componentTypes.js.map +1 -1
- package/dist/labs/DataView/dataTypes.js.map +1 -1
- package/dist/labs/DataView/fetchData.js.map +1 -1
- package/dist/labs/DataView/testSupportData.js +201 -0
- package/dist/labs/DataView/testSupportData.js.map +1 -0
- package/dist/labs/DataView/useFilterConversion.js.map +1 -1
- package/dist/labs/{DateField.js → DatePickers/DateField.js} +1 -1
- package/dist/labs/DatePickers/DateField.js.map +1 -0
- package/dist/labs/DatePickers/DateFieldActionBar.js +56 -0
- package/dist/labs/DatePickers/DateFieldActionBar.js.map +1 -0
- package/dist/labs/DatePickers/DateFieldLocalizationProvider.js +32 -0
- package/dist/labs/DatePickers/DateFieldLocalizationProvider.js.map +1 -0
- package/dist/labs/{DatePicker.js → DatePickers/DatePicker.js} +30 -73
- package/dist/labs/DatePickers/DatePicker.js.map +1 -0
- package/dist/labs/DatePickers/DatePicker.types.d.js.map +1 -0
- package/dist/labs/DatePickers/DateTimeField.js +166 -0
- package/dist/labs/DatePickers/DateTimeField.js.map +1 -0
- package/dist/labs/DatePickers/DateTimePicker.js +233 -0
- package/dist/labs/DatePickers/DateTimePicker.js.map +1 -0
- package/dist/labs/{datePickerTheme.js → DatePickers/datePickerTheme.js} +2 -2
- package/dist/labs/DatePickers/datePickerTheme.js.map +1 -0
- package/dist/labs/DatePickers/dateTimePickerTheme.js +230 -0
- package/dist/labs/DatePickers/dateTimePickerTheme.js.map +1 -0
- package/dist/labs/DatePickers/index.js +15 -0
- package/dist/labs/DatePickers/index.js.map +1 -0
- package/dist/labs/DatePickers/useDateFieldsTranslations.js.map +1 -0
- package/dist/labs/{useOdysseyDateFields.js → DatePickers/useOdysseyDateFields.js} +36 -3
- package/dist/labs/DatePickers/useOdysseyDateFields.js.map +1 -0
- package/dist/labs/PageTemplate.js +1 -1
- package/dist/labs/PageTemplate.js.map +1 -1
- package/dist/labs/SideNav/SideNav.js +45 -38
- package/dist/labs/SideNav/SideNav.js.map +1 -1
- package/dist/labs/SideNav/SideNavHeader.js +6 -4
- package/dist/labs/SideNav/SideNavHeader.js.map +1 -1
- package/dist/labs/SideNav/SideNavItemContent.js +11 -11
- package/dist/labs/SideNav/SideNavItemContent.js.map +1 -1
- package/dist/labs/SideNav/SideNavToggleButton.js +1 -1
- package/dist/labs/SideNav/SideNavToggleButton.js.map +1 -1
- package/dist/labs/SideNav/types.js.map +1 -1
- package/dist/labs/TimeZonePicker.js.map +1 -1
- package/dist/labs/TopNav/UserProfile.js +16 -3
- package/dist/labs/TopNav/UserProfile.js.map +1 -1
- package/dist/labs/TopNav/UserProfileMenuButton.js +41 -0
- package/dist/labs/TopNav/UserProfileMenuButton.js.map +1 -0
- package/dist/labs/TopNav/index.js +1 -0
- package/dist/labs/TopNav/index.js.map +1 -1
- package/dist/labs/index.js +2 -3
- package/dist/labs/index.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui.js +2 -0
- package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/src/Breadcrumbs.d.ts.map +1 -1
- package/dist/src/{Button.d.ts → Buttons/BaseButton.d.ts} +12 -34
- package/dist/src/Buttons/BaseButton.d.ts.map +1 -0
- package/dist/src/{MenuButton.d.ts → Buttons/BaseMenuButton.d.ts} +37 -14
- package/dist/src/Buttons/BaseMenuButton.d.ts.map +1 -0
- package/dist/src/Buttons/Button.d.ts +16 -0
- package/dist/src/Buttons/Button.d.ts.map +1 -0
- package/dist/src/Buttons/ButtonContext.d.ts.map +1 -0
- package/dist/src/Buttons/MenuButton.d.ts +17 -0
- package/dist/src/Buttons/MenuButton.d.ts.map +1 -0
- package/dist/src/Buttons/MenuContext.d.ts.map +1 -0
- package/dist/src/{MenuItem.d.ts → Buttons/MenuItem.d.ts} +1 -1
- package/dist/src/Buttons/MenuItem.d.ts.map +1 -0
- package/dist/src/Buttons/index.d.ts +18 -0
- package/dist/src/Buttons/index.d.ts.map +1 -0
- package/dist/src/Card.d.ts +1 -2
- package/dist/src/Card.d.ts.map +1 -1
- package/dist/src/Checkbox.d.ts.map +1 -1
- package/dist/src/DataTable/DataTable.d.ts +1 -1
- package/dist/src/DataTable/DataTable.d.ts.map +1 -1
- package/dist/src/DataTable/DataTableRowActions.d.ts +1 -2
- package/dist/src/DataTable/DataTableRowActions.d.ts.map +1 -1
- package/dist/src/DataTable/DataTableSettings.d.ts.map +1 -1
- package/dist/src/DataTable/reorderDataRowsLocally.d.ts +3 -3
- package/dist/src/DataTable/reorderDataRowsLocally.d.ts.map +1 -1
- package/dist/src/DataTable/useRowReordering.d.ts +10 -10
- package/dist/src/DataTable/useRowReordering.d.ts.map +1 -1
- package/dist/src/Dialog.d.ts +1 -1
- package/dist/src/Dialog.d.ts.map +1 -1
- package/dist/src/Drawer.d.ts +1 -1
- package/dist/src/Drawer.d.ts.map +1 -1
- package/dist/src/Form.d.ts +1 -1
- package/dist/src/Form.d.ts.map +1 -1
- package/dist/src/HtmlProps.d.ts +27 -0
- package/dist/src/HtmlProps.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/Radio.d.ts +1 -1
- package/dist/src/Radio.d.ts.map +1 -1
- package/dist/src/Typography.d.ts +11 -11
- package/dist/src/Typography.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/labs/AppSwitcher/AppSwitcher.d.ts +20 -0
- package/dist/src/labs/AppSwitcher/AppSwitcher.d.ts.map +1 -0
- package/dist/src/labs/AppSwitcher/AppSwitcherApp.d.ts +24 -0
- package/dist/src/labs/AppSwitcher/AppSwitcherApp.d.ts.map +1 -0
- package/dist/src/labs/AppSwitcher/OktaAura.d.ts.map +1 -0
- package/dist/src/labs/AppSwitcher/index.d.ts +13 -0
- package/dist/src/labs/AppSwitcher/index.d.ts.map +1 -0
- package/dist/src/labs/AppTile.d.ts +6 -4
- package/dist/src/labs/AppTile.d.ts.map +1 -1
- package/dist/src/labs/DataFilters.d.ts.map +1 -1
- package/dist/src/labs/DataTable.d.ts +12 -12
- package/dist/src/labs/DataTable.d.ts.map +1 -1
- package/dist/src/labs/DataView/BulkActionsMenu.d.ts +3 -3
- package/dist/src/labs/DataView/BulkActionsMenu.d.ts.map +1 -1
- package/dist/src/labs/DataView/CardLayoutContent.d.ts +18 -15
- package/dist/src/labs/DataView/CardLayoutContent.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataCard.d.ts +8 -6
- package/dist/src/labs/DataView/DataCard.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataTable.d.ts +6 -2
- package/dist/src/labs/DataView/DataTable.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataView.d.ts +6 -2
- package/dist/src/labs/DataView/DataView.d.ts.map +1 -1
- package/dist/src/labs/DataView/DetailPanel.d.ts +5 -5
- package/dist/src/labs/DataView/DetailPanel.d.ts.map +1 -1
- package/dist/src/labs/DataView/LayoutSwitcher.d.ts.map +1 -1
- package/dist/src/labs/DataView/RowActions.d.ts +4 -5
- package/dist/src/labs/DataView/RowActions.d.ts.map +1 -1
- package/dist/src/labs/DataView/TableLayoutContent.d.ts +18 -15
- package/dist/src/labs/DataView/TableLayoutContent.d.ts.map +1 -1
- package/dist/src/labs/DataView/TableSettings.d.ts +7 -3
- package/dist/src/labs/DataView/TableSettings.d.ts.map +1 -1
- package/dist/src/labs/DataView/componentTypes.d.ts +17 -17
- package/dist/src/labs/DataView/componentTypes.d.ts.map +1 -1
- package/dist/src/labs/DataView/dataTypes.d.ts +6 -6
- package/dist/src/labs/DataView/dataTypes.d.ts.map +1 -1
- package/dist/src/labs/DataView/fetchData.d.ts +6 -6
- package/dist/src/labs/DataView/fetchData.d.ts.map +1 -1
- package/dist/src/labs/DataView/testSupportData.d.ts +33 -0
- package/dist/src/labs/DataView/testSupportData.d.ts.map +1 -0
- package/dist/src/labs/DataView/useFilterConversion.d.ts +5 -4
- package/dist/src/labs/DataView/useFilterConversion.d.ts.map +1 -1
- package/dist/src/labs/{DateField.d.ts → DatePickers/DateField.d.ts} +1 -1
- package/dist/src/labs/DatePickers/DateField.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/DateFieldActionBar.d.ts +15 -0
- package/dist/src/labs/DatePickers/DateFieldActionBar.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/DateFieldLocalizationProvider.d.ts +20 -0
- package/dist/src/labs/DatePickers/DateFieldLocalizationProvider.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/DatePicker.d.ts +17 -0
- package/dist/src/labs/DatePickers/DatePicker.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/DateTimeField.d.ts +20 -0
- package/dist/src/labs/DatePickers/DateTimeField.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/DateTimePicker.d.ts +17 -0
- package/dist/src/labs/DatePickers/DateTimePicker.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/datePickerTheme.d.ts +22 -0
- package/dist/src/labs/DatePickers/datePickerTheme.d.ts.map +1 -0
- package/dist/src/labs/{datePickerTheme.d.ts → DatePickers/dateTimePickerTheme.d.ts} +2 -2
- package/dist/src/labs/DatePickers/dateTimePickerTheme.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/index.d.ts +15 -0
- package/dist/src/labs/DatePickers/index.d.ts.map +1 -0
- package/dist/src/labs/DatePickers/useDateFieldsTranslations.d.ts.map +1 -0
- package/dist/src/labs/{useOdysseyDateFields.d.ts → DatePickers/useOdysseyDateFields.d.ts} +49 -6
- package/dist/src/labs/DatePickers/useOdysseyDateFields.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SideNav.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavHeader.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavItemContent.d.ts +1 -1
- package/dist/src/labs/SideNav/SideNavItemContent.d.ts.map +1 -1
- package/dist/src/labs/SideNav/types.d.ts +2 -2
- package/dist/src/labs/SideNav/types.d.ts.map +1 -1
- package/dist/src/labs/TimeZonePicker.d.ts +4 -1
- package/dist/src/labs/TimeZonePicker.d.ts.map +1 -1
- package/dist/src/labs/TopNav/UserProfile.d.ts +5 -1
- package/dist/src/labs/TopNav/UserProfile.d.ts.map +1 -1
- package/dist/src/labs/TopNav/UserProfileMenuButton.d.ts +17 -0
- package/dist/src/labs/TopNav/UserProfileMenuButton.d.ts.map +1 -0
- package/dist/src/labs/TopNav/index.d.ts +1 -0
- package/dist/src/labs/TopNav/index.d.ts.map +1 -1
- package/dist/src/labs/index.d.ts +2 -3
- package/dist/src/labs/index.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/src/theme/mixins.d.ts.map +1 -1
- package/dist/src/theme/mixins.types.d.ts +2 -0
- package/dist/src/theme/mixins.types.d.ts.map +1 -1
- package/dist/src/{labs → ui-shell}/UiShell/UiShell.d.ts +2 -2
- package/dist/src/ui-shell/UiShell/UiShell.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/UiShellContent.d.ts +68 -0
- package/dist/src/ui-shell/UiShell/UiShellContent.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/bufferLatest.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/createMessageBus.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/createStore.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/index.d.ts.map +1 -0
- package/dist/src/{labs → ui-shell}/UiShell/renderUiShell.d.ts +3 -4
- package/dist/src/ui-shell/UiShell/renderUiShell.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/useHasUiShell.d.ts +14 -0
- package/dist/src/ui-shell/UiShell/useHasUiShell.d.ts.map +1 -0
- package/dist/src/ui-shell/UiShell/useScrollState.d.ts.map +1 -0
- package/dist/src/ui-shell/index.d.ts +14 -0
- package/dist/src/ui-shell/index.d.ts.map +1 -0
- package/dist/src/{web-component → ui-shell}/renderReactInWebComponent.d.ts +1 -21
- package/dist/src/ui-shell/renderReactInWebComponent.d.ts.map +1 -0
- package/dist/src/web-component/index.d.ts +0 -1
- package/dist/src/web-component/index.d.ts.map +1 -1
- package/dist/src/web-component/shadow-dom.d.ts +23 -2
- package/dist/src/web-component/shadow-dom.d.ts.map +1 -1
- package/dist/theme/components.js +62 -30
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/mixins.js +2 -1
- package/dist/theme/mixins.js.map +1 -1
- package/dist/theme/mixins.types.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/{labs → ui-shell}/UiShell/UiShell.js +8 -5
- package/dist/ui-shell/UiShell/UiShell.js.map +1 -0
- package/dist/{labs → ui-shell}/UiShell/UiShellContent.js +64 -16
- package/dist/ui-shell/UiShell/UiShellContent.js.map +1 -0
- package/dist/ui-shell/UiShell/bufferLatest.js.map +1 -0
- package/dist/ui-shell/UiShell/createMessageBus.js.map +1 -0
- package/dist/ui-shell/UiShell/createStore.js.map +1 -0
- package/dist/ui-shell/UiShell/index.js.map +1 -0
- package/dist/{labs → ui-shell}/UiShell/renderUiShell.js +8 -2
- package/dist/ui-shell/UiShell/renderUiShell.js.map +1 -0
- package/dist/{labs → ui-shell}/UiShell/useHasUiShell.js +1 -1
- package/dist/ui-shell/UiShell/useHasUiShell.js.map +1 -0
- package/dist/ui-shell/UiShell/useScrollState.js.map +1 -0
- package/dist/ui-shell/index.js +14 -0
- package/dist/ui-shell/index.js.map +1 -0
- package/dist/{web-component → ui-shell}/renderReactInWebComponent.js +1 -12
- package/dist/ui-shell/renderReactInWebComponent.js.map +1 -0
- package/dist/web-component/index.js +0 -1
- package/dist/web-component/index.js.map +1 -1
- package/dist/web-component/shadow-dom.js +12 -2
- package/dist/web-component/shadow-dom.js.map +1 -1
- package/package.json +10 -3
- package/src/Breadcrumbs.tsx +5 -1
- package/src/{Button.tsx → Buttons/BaseButton.tsx} +48 -68
- package/src/{MenuButton.tsx → Buttons/BaseMenuButton.tsx} +94 -32
- package/src/Buttons/Button.tsx +30 -0
- package/src/Buttons/MenuButton.tsx +35 -0
- package/src/{MenuItem.tsx → Buttons/MenuItem.tsx} +2 -1
- package/src/Buttons/index.ts +22 -0
- package/src/Card.tsx +1 -3
- package/src/Checkbox.tsx +86 -44
- package/src/DataTable/DataTable.tsx +1 -2
- package/src/DataTable/DataTableRowActions.tsx +1 -3
- package/src/DataTable/DataTableSettings.tsx +1 -2
- package/src/DataTable/reorderDataRowsLocally.tsx +3 -3
- package/src/DataTable/useRowReordering.tsx +16 -23
- package/src/Dialog.tsx +1 -1
- package/src/Drawer.tsx +1 -1
- package/src/FileUploader/FileUploader.tsx +1 -1
- package/src/Form.tsx +1 -1
- package/src/HtmlProps.ts +27 -0
- package/src/Pagination/Pagination.test.tsx +58 -36
- package/src/Pagination/Pagination.tsx +3 -3
- package/src/Radio.tsx +78 -39
- package/src/Toast.tsx +1 -1
- package/src/Typography.tsx +26 -1
- package/src/index.ts +1 -3
- package/src/labs/AppSwitcher/AppSwitcher.tsx +94 -0
- package/src/labs/AppSwitcher/AppSwitcherApp.tsx +146 -0
- package/src/labs/{SideNav → AppSwitcher}/OktaAura.tsx +19 -4
- package/src/labs/AppSwitcher/index.ts +13 -0
- package/src/labs/AppTile.tsx +171 -85
- package/src/labs/DataFilters.tsx +8 -4
- package/src/labs/DataTable.tsx +42 -34
- package/src/labs/DataTablePagination.tsx +1 -1
- package/src/labs/DataView/BulkActionsMenu.tsx +5 -6
- package/src/labs/DataView/CardLayoutContent.tsx +34 -28
- package/src/labs/DataView/DataCard.tsx +69 -37
- package/src/labs/DataView/DataTable.tsx +11 -4
- package/src/labs/DataView/DataView.test.tsx +1012 -87
- package/src/labs/DataView/DataView.tsx +19 -12
- package/src/labs/DataView/DetailPanel.tsx +4 -4
- package/src/labs/DataView/LayoutSwitcher.tsx +1 -2
- package/src/labs/DataView/RowActions.tsx +5 -7
- package/src/labs/DataView/TableLayoutContent.tsx +31 -26
- package/src/labs/DataView/TableSettings.tsx +13 -8
- package/src/labs/DataView/componentTypes.ts +17 -17
- package/src/labs/DataView/dataTypes.ts +14 -8
- package/src/labs/DataView/fetchData.ts +9 -7
- package/src/labs/DataView/testSupportData.tsx +301 -0
- package/src/labs/DataView/useFilterConversion.ts +8 -8
- package/src/labs/{DateField.tsx → DatePickers/DateField.tsx} +2 -2
- package/src/labs/DatePickers/DateFieldActionBar.tsx +65 -0
- package/src/labs/DatePickers/DateFieldLocalizationProvider.tsx +46 -0
- package/src/labs/{DatePicker.tsx → DatePickers/DatePicker.tsx} +31 -136
- package/src/labs/DatePickers/DateTimeField.tsx +271 -0
- package/src/labs/DatePickers/DateTimePicker.test.tsx +66 -0
- package/src/labs/DatePickers/DateTimePicker.tsx +303 -0
- package/src/labs/{datePickerTheme.tsx → DatePickers/datePickerTheme.tsx} +2 -2
- package/src/labs/DatePickers/dateTimePickerTheme.ts +213 -0
- package/src/labs/DatePickers/index.ts +15 -0
- package/src/labs/{useOdysseyDateFields.ts → DatePickers/useOdysseyDateFields.ts} +112 -10
- package/src/labs/PageTemplate.tsx +1 -1
- package/src/labs/SideNav/SideNav.tsx +48 -43
- package/src/labs/SideNav/SideNavHeader.tsx +6 -4
- package/src/labs/SideNav/SideNavItemContent.tsx +21 -18
- package/src/labs/SideNav/SideNavToggleButton.tsx +1 -1
- package/src/labs/SideNav/types.ts +2 -2
- package/src/labs/TimeZonePicker.tsx +5 -1
- package/src/labs/TopNav/UserProfile.tsx +26 -2
- package/src/labs/TopNav/UserProfileMenuButton.tsx +57 -0
- package/src/labs/TopNav/index.ts +1 -0
- package/src/labs/index.ts +3 -3
- package/src/properties/odyssey-react-mui.properties +2 -0
- package/src/properties/ts/odyssey-react-mui.ts +1 -1
- package/src/theme/components.tsx +69 -31
- package/src/theme/mixins.ts +1 -0
- package/src/theme/mixins.types.ts +2 -0
- package/src/{labs → ui-shell}/UiShell/UiShell.test.tsx +23 -38
- package/src/{labs → ui-shell}/UiShell/UiShell.tsx +17 -6
- package/src/ui-shell/UiShell/UiShellContent.tsx +268 -0
- package/src/{labs → ui-shell}/UiShell/renderUiShell.test.tsx +1 -1
- package/src/{labs → ui-shell}/UiShell/renderUiShell.tsx +14 -4
- package/src/{labs → ui-shell}/UiShell/useHasUiShell.ts +1 -1
- package/src/ui-shell/index.ts +14 -0
- package/src/{web-component → ui-shell}/renderReactInWebComponent.test.tsx +1 -1
- package/src/{web-component → ui-shell}/renderReactInWebComponent.ts +4 -35
- package/src/web-component/index.ts +0 -1
- package/src/web-component/shadow-dom.ts +36 -3
- package/dist/Button.js.map +0 -1
- package/dist/ButtonContext.js.map +0 -1
- package/dist/MenuButton.js.map +0 -1
- package/dist/MenuContext.js.map +0 -1
- package/dist/MenuItem.js.map +0 -1
- package/dist/labs/DateField.js.map +0 -1
- package/dist/labs/DatePicker.js.map +0 -1
- package/dist/labs/DatePicker.types.d.js.map +0 -1
- package/dist/labs/SideNav/OktaAura.js.map +0 -1
- package/dist/labs/UiShell/UiShell.js.map +0 -1
- package/dist/labs/UiShell/UiShellContent.js.map +0 -1
- package/dist/labs/UiShell/bufferLatest.js.map +0 -1
- package/dist/labs/UiShell/createMessageBus.js.map +0 -1
- package/dist/labs/UiShell/createStore.js.map +0 -1
- package/dist/labs/UiShell/renderUiShell.js.map +0 -1
- package/dist/labs/UiShell/useHasUiShell.js.map +0 -1
- package/dist/labs/UiShell/useScrollState.js.map +0 -1
- package/dist/labs/datePickerTheme.js.map +0 -1
- package/dist/labs/useDateFieldsTranslations.js.map +0 -1
- package/dist/labs/useOdysseyDateFields.js.map +0 -1
- package/dist/src/Button.d.ts.map +0 -1
- package/dist/src/ButtonContext.d.ts.map +0 -1
- package/dist/src/MenuButton.d.ts.map +0 -1
- package/dist/src/MenuContext.d.ts.map +0 -1
- package/dist/src/MenuItem.d.ts.map +0 -1
- package/dist/src/labs/DateField.d.ts.map +0 -1
- package/dist/src/labs/DatePicker.d.ts +0 -47
- package/dist/src/labs/DatePicker.d.ts.map +0 -1
- package/dist/src/labs/SideNav/OktaAura.d.ts.map +0 -1
- package/dist/src/labs/UiShell/UiShell.d.ts.map +0 -1
- package/dist/src/labs/UiShell/UiShellContent.d.ts +0 -47
- package/dist/src/labs/UiShell/UiShellContent.d.ts.map +0 -1
- package/dist/src/labs/UiShell/bufferLatest.d.ts.map +0 -1
- package/dist/src/labs/UiShell/createMessageBus.d.ts.map +0 -1
- package/dist/src/labs/UiShell/createStore.d.ts.map +0 -1
- package/dist/src/labs/UiShell/index.d.ts.map +0 -1
- package/dist/src/labs/UiShell/renderUiShell.d.ts.map +0 -1
- package/dist/src/labs/UiShell/useHasUiShell.d.ts.map +0 -1
- package/dist/src/labs/UiShell/useScrollState.d.ts.map +0 -1
- package/dist/src/labs/datePickerTheme.d.ts.map +0 -1
- package/dist/src/labs/useDateFieldsTranslations.d.ts.map +0 -1
- package/dist/src/labs/useOdysseyDateFields.d.ts.map +0 -1
- package/dist/src/web-component/renderReactInWebComponent.d.ts.map +0 -1
- package/dist/web-component/renderReactInWebComponent.js.map +0 -1
- package/src/labs/UiShell/UiShellContent.tsx +0 -170
- /package/dist/{ButtonContext.js → Buttons/ButtonContext.js} +0 -0
- /package/dist/{MenuContext.js → Buttons/MenuContext.js} +0 -0
- /package/dist/labs/{DatePicker.types.d.js → DatePickers/DatePicker.types.d.js} +0 -0
- /package/dist/labs/{useDateFieldsTranslations.js → DatePickers/useDateFieldsTranslations.js} +0 -0
- /package/dist/src/{ButtonContext.d.ts → Buttons/ButtonContext.d.ts} +0 -0
- /package/dist/src/{MenuContext.d.ts → Buttons/MenuContext.d.ts} +0 -0
- /package/dist/src/labs/{SideNav → AppSwitcher}/OktaAura.d.ts +0 -0
- /package/dist/src/labs/{useDateFieldsTranslations.d.ts → DatePickers/useDateFieldsTranslations.d.ts} +0 -0
- /package/dist/src/{labs → ui-shell}/UiShell/bufferLatest.d.ts +0 -0
- /package/dist/src/{labs → ui-shell}/UiShell/createMessageBus.d.ts +0 -0
- /package/dist/src/{labs → ui-shell}/UiShell/createStore.d.ts +0 -0
- /package/dist/src/{labs → ui-shell}/UiShell/index.d.ts +0 -0
- /package/dist/src/{labs → ui-shell}/UiShell/useScrollState.d.ts +0 -0
- /package/dist/{labs → ui-shell}/UiShell/bufferLatest.js +0 -0
- /package/dist/{labs → ui-shell}/UiShell/createMessageBus.js +0 -0
- /package/dist/{labs → ui-shell}/UiShell/createStore.js +0 -0
- /package/dist/{labs → ui-shell}/UiShell/index.js +0 -0
- /package/dist/{labs → ui-shell}/UiShell/useScrollState.js +0 -0
- /package/src/{ButtonContext.tsx → Buttons/ButtonContext.tsx} +0 -0
- /package/src/{MenuContext.ts → Buttons/MenuContext.ts} +0 -0
- /package/src/labs/{DatePicker.types.d.ts → DatePickers/DatePicker.types.d.ts} +0 -0
- /package/src/labs/{useDateFieldsTranslations.ts → DatePickers/useDateFieldsTranslations.ts} +0 -0
- /package/src/{labs → ui-shell}/UiShell/bufferLatest.test.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/bufferLatest.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/createMessageBus.test.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/createMessageBus.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/createStore.test.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/createStore.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/index.ts +0 -0
- /package/src/{labs → ui-shell}/UiShell/useScrollState.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reorderDataRowsLocally.js","names":["reorderDataRowsLocally","currentData","rowId","newRowIndex","updatedData","rowIndex","findIndex","row","id","length","console","warn","removedRow","splice"],"sources":["../../src/DataTable/reorderDataRowsLocally.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { MRT_RowData } from \"material-react-table\";\n\n/**\n * Reorders data rows locally.\n *\n * @param currentData - The current array of data rows.\n * @param rowId - The ID of the row to move.\n * @param newIndex - The new index to move the row to.\n * @returns A new array of data with the row moved to the specified index.\n */\nexport const reorderDataRowsLocally = ({\n currentData,\n rowId,\n newRowIndex,\n}: {\n currentData:
|
|
1
|
+
{"version":3,"file":"reorderDataRowsLocally.js","names":["reorderDataRowsLocally","currentData","rowId","newRowIndex","updatedData","rowIndex","findIndex","row","id","length","console","warn","removedRow","splice"],"sources":["../../src/DataTable/reorderDataRowsLocally.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { MRT_RowData } from \"material-react-table\";\n\n/**\n * Reorders data rows locally.\n *\n * @param currentData - The current array of data rows.\n * @param rowId - The ID of the row to move.\n * @param newIndex - The new index to move the row to.\n * @returns A new array of data with the row moved to the specified index.\n */\nexport const reorderDataRowsLocally = <TData extends MRT_RowData>({\n currentData,\n rowId,\n newRowIndex,\n}: {\n currentData: TData[];\n rowId: string;\n newRowIndex: number;\n}): TData[] => {\n const updatedData = [...currentData];\n const rowIndex = updatedData.findIndex((row) => row.id === rowId);\n\n // Ensure the row exists and the new index is within bounds\n if (rowIndex === -1 || newRowIndex < 0 || newRowIndex >= updatedData.length) {\n console.warn(\"Invalid row ID or newIndex; cannot reorder rows.\");\n return updatedData; // Return the original data if conditions aren't met\n }\n\n // Remove the row from its current position\n const [removedRow] = updatedData.splice(rowIndex, 1);\n\n // Insert the row at the new index\n updatedData.splice(newRowIndex, 0, removedRow);\n\n return updatedData;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAYA,OAAO,MAAMA,sBAAsB,GAAGA,CAA4B;EAChEC,WAAW;EACXC,KAAK;EACLC;AAKF,CAAC,KAAc;EACb,MAAMC,WAAW,GAAG,CAAC,GAAGH,WAAW,CAAC;EACpC,MAAMI,QAAQ,GAAGD,WAAW,CAACE,SAAS,CAAEC,GAAG,IAAKA,GAAG,CAACC,EAAE,KAAKN,KAAK,CAAC;EAGjE,IAAIG,QAAQ,KAAK,CAAC,CAAC,IAAIF,WAAW,GAAG,CAAC,IAAIA,WAAW,IAAIC,WAAW,CAACK,MAAM,EAAE;IAC3EC,OAAO,CAACC,IAAI,CAAC,kDAAkD,CAAC;IAChE,OAAOP,WAAW;EACpB;EAGA,MAAM,CAACQ,UAAU,CAAC,GAAGR,WAAW,CAACS,MAAM,CAACR,QAAQ,EAAE,CAAC,CAAC;EAGpDD,WAAW,CAACS,MAAM,CAACV,WAAW,EAAE,CAAC,EAAES,UAAU,CAAC;EAE9C,OAAOR,WAAW;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRowReordering.js","names":["reorderDataRowsLocally","useOdysseyDesignTokens","useRowReordering","totalRows","onReorderRows","data","setData","draggingRow","setDraggingRow","resultsPerPage","page","updateRowOrder","rowId","newRowIndex","newData","currentData","odysseyDesignTokens","dragHandleStyles","padding","Spacing1","borderRadius","BorderRadiusMain","boxShadow","HueNeutralWhite","PalettePrimaryMain","outline","outlineOffset","dragHandleText","title","draggableTableBodyRowClassName","currentRowId","draggingRowId","hoveredRowId","undefined","setHoveredRow","table","id","nextRow","getRow","handleDragHandleKeyDown","row","event","hoveredRow","getState","key","isSpaceKey","isEnterKey","isEscapeKey","isArrowDown","isArrowUp","isSpaceOrEnter","zeroIndexedPageNumber","currentIndex","index","resetDraggingAndHoveredRow","preventDefault","stopPropagation","pageRelativeIndex","setTimeout","TransitionDurationMainAsNumber","nextIndex","handleDragHandleOnDragEnd","cols","getAllColumns","toggleVisibility","handleDragHandleOnDragCapture"],"sources":["../../src/DataTable/useRowReordering.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { Dispatch, SetStateAction, KeyboardEvent } from \"react\";\nimport { DataTableProps } from \"./DataTable\";\nimport { reorderDataRowsLocally } from \"./reorderDataRowsLocally\";\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext\";\nimport { MRT_Row, MRT_RowData, MRT_TableInstance } from \"material-react-table\";\n\nexport const useRowReordering = ({\n totalRows,\n onReorderRows,\n data,\n setData,\n draggingRow,\n setDraggingRow,\n resultsPerPage,\n page,\n}: {\n totalRows: DataTableProps[\"totalRows\"];\n onReorderRows: DataTableProps[\"onReorderRows\"];\n data: MRT_RowData[];\n setData: Dispatch<SetStateAction<MRT_RowData[]>>;\n draggingRow?: MRT_Row<MRT_RowData> | null;\n setDraggingRow: Dispatch<\n SetStateAction<MRT_Row<MRT_RowData> | null | undefined>\n >;\n resultsPerPage: number;\n page: number;\n}) => {\n const updateRowOrder = ({\n rowId,\n newRowIndex,\n }: {\n rowId: string;\n newRowIndex: number;\n }) => {\n if (newRowIndex < 0) {\n return;\n }\n\n // Needs to include the totalRows check because totalRows might not\n // be set. If it isn't set, this whole check doesn't matter.\n if (totalRows && newRowIndex > totalRows) {\n return;\n }\n\n const newData = reorderDataRowsLocally({\n currentData: data,\n rowId,\n newRowIndex,\n });\n\n setData(newData);\n onReorderRows?.({ rowId, newRowIndex });\n };\n\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const dragHandleStyles = {\n padding: odysseyDesignTokens.Spacing1,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n\n \"&:focus-visible\": {\n boxShadow: `0 0 0 2px ${odysseyDesignTokens.HueNeutralWhite}, 0 0 0 4px ${odysseyDesignTokens.PalettePrimaryMain}`,\n outline: \"2px solid transparent\",\n outlineOffset: \"1px\",\n },\n };\n\n const dragHandleText = {\n title: \"Drag row or press space/enter key to start and stop reordering\",\n \"aria-label\":\n \"Drag row to reorder. Or, press space or enter to start and stop reordering and esc to cancel.\",\n };\n\n const draggableTableBodyRowClassName = ({\n currentRowId,\n draggingRowId,\n hoveredRowId,\n }: {\n currentRowId: string;\n draggingRowId?: string;\n hoveredRowId?: string;\n }) => {\n if (draggingRowId === currentRowId && hoveredRowId !== currentRowId) {\n return \"isDragging\";\n }\n\n if (hoveredRowId === currentRowId && draggingRowId !== currentRowId) {\n return \"isDragTarget\";\n }\n\n if (draggingRowId === currentRowId && hoveredRowId === currentRowId) {\n return \"isDragging isDragTarget\";\n }\n\n return undefined;\n };\n\n const setHoveredRow = (\n table: MRT_TableInstance<MRT_RowData>,\n id: MRT_RowData[\"id\"],\n ) => {\n if (id) {\n const nextRow: MRT_RowData = table.getRow(id);\n\n if (nextRow) {\n table.setHoveredRow(nextRow);\n }\n }\n };\n\n type HandleDragHandleKeyDownArgs = {\n table: MRT_TableInstance<MRT_RowData>;\n row: MRT_Row<MRT_RowData>;\n event: KeyboardEvent<HTMLButtonElement>;\n };\n\n const handleDragHandleKeyDown = ({\n table,\n row,\n event,\n }: HandleDragHandleKeyDownArgs) => {\n const { hoveredRow } = table.getState();\n\n const { key } = event;\n\n const isSpaceKey = key === \" \";\n const isEnterKey = key === \"Enter\";\n const isEscapeKey = key === \"Escape\";\n const isArrowDown = key === \"ArrowDown\";\n const isArrowUp = key === \"ArrowUp\";\n const isSpaceOrEnter = isSpaceKey || isEnterKey;\n const zeroIndexedPageNumber = page - 1;\n const currentIndex = row.index + zeroIndexedPageNumber * resultsPerPage;\n\n if (isEscapeKey) {\n resetDraggingAndHoveredRow(table);\n return;\n }\n\n if (isSpaceOrEnter) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n if (draggingRow) {\n if (typeof hoveredRow?.index === \"number\") {\n const { index } = hoveredRow;\n\n if (isSpaceOrEnter) {\n const pageRelativeIndex =\n index + zeroIndexedPageNumber * resultsPerPage;\n\n if (pageRelativeIndex !== currentIndex) {\n updateRowOrder({\n rowId: row.id,\n newRowIndex: pageRelativeIndex,\n });\n\n // Can't transition CSS hover effect. Use timeout to delay hovered row effect removal\n setTimeout(() => {\n resetDraggingAndHoveredRow(table);\n }, odysseyDesignTokens.TransitionDurationMainAsNumber);\n return;\n }\n }\n\n if (isArrowDown || isArrowUp) {\n const nextIndex = isArrowDown ? index + 1 : index - 1;\n setHoveredRow(table, data[nextIndex]?.id);\n }\n } else {\n if (isArrowDown || isArrowUp) {\n const nextIndex = isArrowDown ? row.index + 1 : row.index - 1;\n setHoveredRow(table, data[nextIndex]?.id);\n }\n }\n } else {\n if (isSpaceOrEnter) {\n setDraggingRow(row);\n }\n }\n };\n\n const handleDragHandleOnDragEnd = (table: MRT_TableInstance<MRT_RowData>) => {\n const cols = table.getAllColumns();\n cols[0].toggleVisibility();\n\n const { draggingRow, hoveredRow } = table.getState();\n if (draggingRow) {\n updateRowOrder({\n rowId: draggingRow.id,\n newRowIndex: (hoveredRow as MRT_RowData).index,\n });\n }\n\n setDraggingRow(null);\n };\n\n const handleDragHandleOnDragCapture = (\n table: MRT_TableInstance<MRT_RowData>,\n ) => {\n if (!draggingRow && table.getState().draggingRow?.id) {\n setDraggingRow(table.getState().draggingRow);\n }\n };\n\n const resetDraggingAndHoveredRow = (\n table: MRT_TableInstance<MRT_RowData>,\n ) => {\n setDraggingRow(null);\n table.setHoveredRow(null);\n };\n\n return {\n dragHandleStyles,\n dragHandleText,\n draggableTableBodyRowClassName,\n handleDragHandleKeyDown,\n handleDragHandleOnDragCapture,\n handleDragHandleOnDragEnd,\n resetDraggingAndHoveredRow,\n updateRowOrder,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,SAcSA,sBAAsB;AAAA,SACtBC,sBAAsB;AAG/B,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,SAAS;EACTC,aAAa;EACbC,IAAI;EACJC,OAAO;EACPC,WAAW;EACXC,cAAc;EACdC,cAAc;EACdC;AAYF,CAAC,KAAK;EACJ,MAAMC,cAAc,GAAGA,CAAC;IACtBC,KAAK;IACLC;EAIF,CAAC,KAAK;IACJ,IAAIA,WAAW,GAAG,CAAC,EAAE;MACnB;IACF;IAIA,IAAIV,SAAS,IAAIU,WAAW,GAAGV,SAAS,EAAE;MACxC;IACF;IAEA,MAAMW,OAAO,GAAGd,sBAAsB,CAAC;MACrCe,WAAW,EAAEV,IAAI;MACjBO,KAAK;MACLC;IACF,CAAC,CAAC;IAEFP,OAAO,CAACQ,OAAO,CAAC;IAChBV,aAAa,GAAG;MAAEQ,KAAK;MAAEC;IAAY,CAAC,CAAC;EACzC,CAAC;EAED,MAAMG,mBAAmB,GAAGf,sBAAsB,CAAC,CAAC;EACpD,MAAMgB,gBAAgB,GAAG;IACvBC,OAAO,EAAEF,mBAAmB,CAACG,QAAQ;IACrCC,YAAY,EAAEJ,mBAAmB,CAACK,gBAAgB;IAElD,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ering.js","names":["reorderDataRowsLocally","useOdysseyDesignTokens","useRowReordering","totalRows","onReorderRows","data","setData","draggingRow","setDraggingRow","resultsPerPage","page","updateRowOrder","rowId","newRowIndex","newData","currentData","odysseyDesignTokens","dragHandleStyles","padding","Spacing1","borderRadius","BorderRadiusMain","boxShadow","HueNeutralWhite","PalettePrimaryMain","outline","outlineOffset","dragHandleText","title","draggableTableBodyRowClassName","currentRowId","draggingRowId","hoveredRowId","undefined","setHoveredRow","table","id","nextRow","getRow","handleDragHandleKeyDown","row","event","hoveredRow","getState","key","isSpaceKey","isEnterKey","isEscapeKey","isArrowDown","isArrowUp","isSpaceOrEnter","zeroIndexedPageNumber","currentIndex","index","resetDraggingAndHoveredRow","preventDefault","stopPropagation","pageRelativeIndex","setTimeout","TransitionDurationMainAsNumber","nextIndex","handleDragHandleOnDragEnd","cols","getAllColumns","toggleVisibility","handleDragHandleOnDragCapture"],"sources":["../../src/DataTable/useRowReordering.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { Dispatch, SetStateAction, KeyboardEvent } from \"react\";\nimport { DataTableProps } from \"./DataTable\";\nimport { reorderDataRowsLocally } from \"./reorderDataRowsLocally\";\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext\";\nimport { MRT_Row, MRT_RowData, MRT_TableInstance } from \"material-react-table\";\n\nexport const useRowReordering = <TData extends MRT_RowData>({\n totalRows,\n onReorderRows,\n data,\n setData,\n draggingRow,\n setDraggingRow,\n resultsPerPage,\n page,\n}: {\n totalRows: DataTableProps[\"totalRows\"];\n onReorderRows: DataTableProps[\"onReorderRows\"];\n data: TData[];\n setData: Dispatch<SetStateAction<TData[]>>;\n draggingRow?: MRT_Row<TData> | null;\n setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null | undefined>>;\n resultsPerPage: number;\n page: number;\n}) => {\n const updateRowOrder = ({\n rowId,\n newRowIndex,\n }: {\n rowId: string;\n newRowIndex: number;\n }) => {\n if (newRowIndex < 0) {\n return;\n }\n\n // Needs to include the totalRows check because totalRows might not\n // be set. If it isn't set, this whole check doesn't matter.\n if (totalRows && newRowIndex > totalRows) {\n return;\n }\n\n const newData = reorderDataRowsLocally({\n currentData: data,\n rowId,\n newRowIndex,\n });\n\n setData(newData);\n onReorderRows?.({ rowId, newRowIndex });\n };\n\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const dragHandleStyles = {\n padding: odysseyDesignTokens.Spacing1,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n \"&:focus-visible\": {\n boxShadow: `0 0 0 2px ${odysseyDesignTokens.HueNeutralWhite}, 0 0 0 4px ${odysseyDesignTokens.PalettePrimaryMain}`,\n outline: \"2px solid transparent\",\n outlineOffset: \"1px\",\n },\n };\n\n const dragHandleText = {\n title: \"Drag row or press space/enter key to start and stop reordering\",\n \"aria-label\":\n \"Drag row to reorder. Or, press space or enter to start and stop reordering and esc to cancel.\",\n };\n\n const draggableTableBodyRowClassName = ({\n currentRowId,\n draggingRowId,\n hoveredRowId,\n }: {\n currentRowId: string;\n draggingRowId?: string;\n hoveredRowId?: string;\n }) => {\n if (draggingRowId === currentRowId && hoveredRowId !== currentRowId) {\n return \"isDragging\";\n }\n\n if (hoveredRowId === currentRowId && draggingRowId !== currentRowId) {\n return \"isDragTarget\";\n }\n\n if (draggingRowId === currentRowId && hoveredRowId === currentRowId) {\n return \"isDragging isDragTarget\";\n }\n\n return undefined;\n };\n\n const setHoveredRow = (table: MRT_TableInstance<TData>, id: TData[\"id\"]) => {\n if (id) {\n // The `as MRT_Row<TData>` is necessary here to overcome some type/generic\n // issues with the type of `setHoveredRow` defined by MRT. It's not ideal code,\n // but it's the only way that works without a much larger rewrite.\n const nextRow = table.getRow(id) as MRT_Row<TData>;\n\n if (nextRow) {\n table.setHoveredRow(nextRow);\n }\n }\n };\n\n type HandleDragHandleKeyDownArgs = {\n table: MRT_TableInstance<TData>;\n row: MRT_Row<TData>;\n event: KeyboardEvent<HTMLButtonElement>;\n };\n\n const handleDragHandleKeyDown = ({\n table,\n row,\n event,\n }: HandleDragHandleKeyDownArgs) => {\n const { hoveredRow } = table.getState();\n\n const { key } = event;\n\n const isSpaceKey = key === \" \";\n const isEnterKey = key === \"Enter\";\n const isEscapeKey = key === \"Escape\";\n const isArrowDown = key === \"ArrowDown\";\n const isArrowUp = key === \"ArrowUp\";\n const isSpaceOrEnter = isSpaceKey || isEnterKey;\n const zeroIndexedPageNumber = page - 1;\n const currentIndex = row.index + zeroIndexedPageNumber * resultsPerPage;\n\n if (isEscapeKey) {\n resetDraggingAndHoveredRow(table);\n return;\n }\n\n if (isSpaceOrEnter) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n if (draggingRow) {\n if (typeof hoveredRow?.index === \"number\") {\n const { index } = hoveredRow;\n\n if (isSpaceOrEnter) {\n const pageRelativeIndex =\n index + zeroIndexedPageNumber * resultsPerPage;\n\n if (pageRelativeIndex !== currentIndex) {\n updateRowOrder({\n rowId: row.id,\n newRowIndex: pageRelativeIndex,\n });\n\n // Can't transition CSS hover effect. Use timeout to delay hovered row effect removal\n setTimeout(() => {\n resetDraggingAndHoveredRow(table);\n }, odysseyDesignTokens.TransitionDurationMainAsNumber);\n return;\n }\n }\n\n if (isArrowDown || isArrowUp) {\n const nextIndex = isArrowDown ? index + 1 : index - 1;\n setHoveredRow(table, data[nextIndex]?.id);\n }\n } else {\n if (isArrowDown || isArrowUp) {\n const nextIndex = isArrowDown ? row.index + 1 : row.index - 1;\n setHoveredRow(table, data[nextIndex]?.id);\n }\n }\n } else {\n if (isSpaceOrEnter) {\n setDraggingRow(row);\n }\n }\n };\n\n const handleDragHandleOnDragEnd = (table: MRT_TableInstance<TData>) => {\n const cols = table.getAllColumns();\n cols[0].toggleVisibility();\n\n const { draggingRow, hoveredRow } = table.getState();\n if (draggingRow) {\n updateRowOrder({\n rowId: draggingRow.id,\n newRowIndex: (hoveredRow as TData).index,\n });\n }\n\n setDraggingRow(null);\n };\n\n const handleDragHandleOnDragCapture = (table: MRT_TableInstance<TData>) => {\n if (!draggingRow && table.getState().draggingRow?.id) {\n setDraggingRow(table.getState().draggingRow);\n }\n };\n\n const resetDraggingAndHoveredRow = (table: MRT_TableInstance<TData>) => {\n setDraggingRow(null);\n table.setHoveredRow(null);\n };\n\n return {\n dragHandleStyles,\n dragHandleText,\n draggableTableBodyRowClassName,\n handleDragHandleKeyDown,\n handleDragHandleOnDragCapture,\n handleDragHandleOnDragEnd,\n resetDraggingAndHoveredRow,\n updateRowOrder,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,SAcSA,sBAAsB;AAAA,SACtBC,sBAAsB;AAG/B,OAAO,MAAMC,gBAAgB,GAAGA,CAA4B;EAC1DC,SAAS;EACTC,aAAa;EACbC,IAAI;EACJC,OAAO;EACPC,WAAW;EACXC,cAAc;EACdC,cAAc;EACdC;AAUF,CAAC,KAAK;EACJ,MAAMC,cAAc,GAAGA,CAAC;IACtBC,KAAK;IACLC;EAIF,CAAC,KAAK;IACJ,IAAIA,WAAW,GAAG,CAAC,EAAE;MACnB;IACF;IAIA,IAAIV,SAAS,IAAIU,WAAW,GAAGV,SAAS,EAAE;MACxC;IACF;IAEA,MAAMW,OAAO,GAAGd,sBAAsB,CAAC;MACrCe,WAAW,EAAEV,IAAI;MACjBO,KAAK;MACLC;IACF,CAAC,CAAC;IAEFP,OAAO,CAACQ,OAAO,CAAC;IAChBV,aAAa,GAAG;MAAEQ,KAAK;MAAEC;IAAY,CAAC,CAAC;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AO;IACLjB,gBAAgB;IAChBU,cAAc;IACdE,8BAA8B;IAC9BU,uBAAuB;IACvB0B,6BAA6B;IAC7BJ,yBAAyB;IACzBP,0BAA0B;IAC1B3C;EACF,CAAC;AACH,CAAC"}
|
package/dist/Dialog.js
CHANGED
|
@@ -16,7 +16,7 @@ import _DialogContentText from "@mui/material/DialogContentText";
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { useTranslation } from "react-i18next";
|
|
19
|
-
import { Button } from "./
|
|
19
|
+
import { Button } from "./Buttons/index.js";
|
|
20
20
|
import { CloseIcon } from "./icons.generated/index.js";
|
|
21
21
|
import { cloneElement, memo, useState, useEffect, useRef } from "react";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
package/dist/Dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["useTranslation","Button","CloseIcon","cloneElement","memo","useState","useEffect","useRef","jsx","_jsx","jsxs","_jsxs","Dialog","primaryCallToActionComponent","secondaryCallToActionComponent","tertiaryCallToActionComponent","callToActionFirstComponent","callToActionSecondComponent","callToActionLastComponent","children","isOpen","onClose","testId","title","translate","t","isContentScrollable","setIsContentScrollable","dialogContentRef","frameId","handleContentScroll","dialogContentElement","current","cancelAnimationFrame","scrollHeight","clientHeight","requestAnimationFrame","content","_DialogContentText","actionButtons","filter","Boolean","_Dialog","open","_DialogTitle","ariaLabel","onClick","size","startIcon","variant","_DialogContent","tabIndex","dividers","ref","length","_DialogActions","map","actionButton","index","key","MemoizedDialog","displayName"],"sources":["../src/Dialog.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 { useTranslation } from \"react-i18next\";\nimport { Dialog as MuiDialog } from \"@mui/material\";\nimport {\n DialogTitle,\n DialogContent,\n DialogContentText,\n DialogActions,\n} from \"@mui/material\";\nimport { Button } from \"./
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["useTranslation","Button","CloseIcon","cloneElement","memo","useState","useEffect","useRef","jsx","_jsx","jsxs","_jsxs","Dialog","primaryCallToActionComponent","secondaryCallToActionComponent","tertiaryCallToActionComponent","callToActionFirstComponent","callToActionSecondComponent","callToActionLastComponent","children","isOpen","onClose","testId","title","translate","t","isContentScrollable","setIsContentScrollable","dialogContentRef","frameId","handleContentScroll","dialogContentElement","current","cancelAnimationFrame","scrollHeight","clientHeight","requestAnimationFrame","content","_DialogContentText","actionButtons","filter","Boolean","_Dialog","open","_DialogTitle","ariaLabel","onClick","size","startIcon","variant","_DialogContent","tabIndex","dividers","ref","length","_DialogActions","map","actionButton","index","key","MemoizedDialog","displayName"],"sources":["../src/Dialog.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 { useTranslation } from \"react-i18next\";\nimport { Dialog as MuiDialog } from \"@mui/material\";\nimport {\n DialogTitle,\n DialogContent,\n DialogContentText,\n DialogActions,\n} from \"@mui/material\";\nimport { Button } from \"./Buttons\";\nimport { CloseIcon } from \"./icons.generated\";\nimport {\n cloneElement,\n memo,\n useState,\n useEffect,\n useRef,\n ReactElement,\n ReactNode,\n} from \"react\";\n\nimport type { HtmlProps } from \"./HtmlProps\";\n\nexport type DialogProps = {\n /**\n * @deprecated `aria-label` for close button comes from translation file\n */\n ariaLabel?: string;\n\n /**\n * An optional Button object to be situated in the Dialog footer as the primary call to action.\n */\n primaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `primaryCallToActionComponent` instead.\n */\n callToActionFirstComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Dialog footer as the secondary call to action, alongside the `primaryCallToActionComponent`.\n */\n secondaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `secondaryCallToActionComponent` instead.\n */\n callToActionSecondComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Dialog footer as the tertiary call to action, alongside the other `callToAction` components.\n */\n tertiaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `tertiaryCallToActionComponent` instead.\n */\n callToActionLastComponent?: ReactElement<typeof Button>;\n /**\n * The content of the Dialog. May be a `string` or any other `ReactNode` or array of `ReactNode`s.\n */\n children: ReactNode;\n\n /**\n * When set to `true`, the Dialog will be visible.\n */\n isOpen: boolean;\n\n /**\n * Callback that controls what happens when the Dialog is dismissed.\n */\n onClose: () => void;\n\n /**\n * The title of the Dialog.\n */\n title: string;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst Dialog = ({\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n tertiaryCallToActionComponent,\n callToActionFirstComponent,\n callToActionSecondComponent,\n callToActionLastComponent,\n children,\n isOpen,\n onClose,\n testId,\n title,\n translate,\n}: DialogProps) => {\n const { t } = useTranslation();\n const [isContentScrollable, setIsContentScrollable] = useState(false);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n let frameId: number;\n\n const handleContentScroll = () => {\n const dialogContentElement = dialogContentRef.current;\n if (dialogContentElement) {\n cancelAnimationFrame(frameId);\n setIsContentScrollable(\n dialogContentElement.scrollHeight > dialogContentElement.clientHeight,\n );\n }\n frameId = requestAnimationFrame(handleContentScroll);\n };\n\n if (isOpen) {\n frameId = requestAnimationFrame(handleContentScroll);\n }\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [isOpen]);\n\n const content =\n typeof children === \"string\" ? (\n <DialogContentText>{children}</DialogContentText>\n ) : (\n children\n );\n\n // Prioritize new action button format (|| used as a fallback)\n const actionButtons = [\n tertiaryCallToActionComponent || callToActionLastComponent,\n secondaryCallToActionComponent || callToActionSecondComponent,\n primaryCallToActionComponent || callToActionFirstComponent,\n ].filter(Boolean);\n\n return (\n <MuiDialog data-se={testId} open={isOpen} onClose={onClose}>\n <DialogTitle translate={translate}>\n {title}\n <Button\n ariaLabel={t(\"close.text\")}\n onClick={onClose}\n size=\"small\"\n startIcon={<CloseIcon />}\n variant=\"floating\"\n />\n </DialogTitle>\n <DialogContent\n {...(isContentScrollable && {\n // Sets tabIndex on content element if scrollable so content is easier to navigate with the keyboard\n tabIndex: 0,\n })}\n dividers={isContentScrollable}\n ref={dialogContentRef}\n >\n {content}\n </DialogContent>\n\n {actionButtons.length > 0 && (\n <DialogActions>\n {actionButtons.map((actionButton, index) =>\n actionButton ? cloneElement(actionButton, { key: index }) : null,\n )}\n </DialogActions>\n )}\n </MuiDialog>\n );\n};\n\nconst MemoizedDialog = memo(Dialog);\nMemoizedDialog.displayName = \"Dialog\";\n\nexport { MemoizedDialog as Dialog };\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,eAAe;AAAC,SAQtCC,MAAM;AAAA,SACNC,SAAS;AAClB,SACEC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,SAAS,EACTC,MAAM,QAGD,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AA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ACC,OAAO,CAAC;EAEjB,OACE9B,KAAA,CAAA+B,OAAA;IAAW,WAASpB,MAAO;IAACqB,IAAI,EAAEvB,MAAO;IAACC,OAAO,EAAEA,OAAQ;IAAAF,QAAA,GACzDR,KAAA,CAAAiC,YAAA;MAAapB,SAAS,EAAEA,SAAU;MAAAL,QAAA,GAC/BI,KAAK,EACNd,IAAA,CAACR,MAAM;QACL4C,SAAS,EAAEpB,CAAC,CAAC,YAAY,CAAE;QAC3BqB,OAAO,EAAEzB,OAAQ;QACjB0B,IAAI,EAAC,OAAO;QACZC,SAAS,EAAEvC,IAAA,CAACP,SAAS,IAAE,CAAE;QACzB+C,OAAO,EAAC;MAAU,CACnB,CAAC;IAAA,CACS,CAAC,EACdxC,IAAA,CAAAyC,cAAA;MAAA,IACOxB,mBAAmB,IAAI;QAE1ByB,QAAQ,EAAE;MACZ,CAAC;MACDC,QAAQ,EAAE1B,mBAAoB;MAC9B2B,GAAG,EAAEzB,gBAAiB;MAAAT,QAAA,EAErBkB;IAAO,CACK,CAAC,EAEfE,aAAa,CAACe,MAAM,GAAG,CAAC,IACvB7C,IAAA,CAAA8C,cAAA;MAAApC,QAAA,EACGoB,aAAa,CAACiB,GAAG,CAAC,CAACC,YAAY,EAAEC,KAAK,KACrCD,YAAY,GAAGtD,YAAY,CAACsD,YAAY,EAAE;QAAEE,GAAG,EAAED;MAAM,CAAC,CAAC,GAAG,IAC9D;IAAC,CACY,CAChB;EAAA,CACQ,CAAC;AAEhB,CAAC;AAED,MAAME,cAAc,GAAGxD,IAAI,CAACQ,MAAM,CAAC;AACnCgD,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIhD,MAAM"}
|
package/dist/Drawer.js
CHANGED
|
@@ -14,7 +14,7 @@ import _Drawer from "@mui/material/Drawer";
|
|
|
14
14
|
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
15
15
|
import styled from "@emotion/styled";
|
|
16
16
|
import { useTranslation } from "react-i18next";
|
|
17
|
-
import { Button } from "./
|
|
17
|
+
import { Button } from "./Buttons/index.js";
|
|
18
18
|
import { CloseIcon } from "./icons.generated/index.js";
|
|
19
19
|
import { useOdysseyDesignTokens } from "./OdysseyDesignTokensContext.js";
|
|
20
20
|
import { Heading5 } from "./Typography.js";
|
package/dist/Drawer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","names":["memo","useEffect","useMemo","useRef","useState","styled","useTranslation","Button","CloseIcon","useOdysseyDesignTokens","Heading5","jsx","_jsx","jsxs","_jsxs","variantValues","DrawerHeader","shouldForwardProp","prop","odysseyDesignTokens","Spacing4","Spacing5","HueNeutral900","HueNeutralWhite","showDividers","HueNeutral200","DrawerContentWrapper","DrawerContent","DrawerFooter","Drawer","ariaLabel","children","isOpen","onClose","primaryCallToActionComponent","secondaryCallToActionComponent","tertiaryCallToActionComponent","testId","title","translate","variant","isContentScrollable","setIsContentScrollable","drawerContentRef","i18n","anchorDirection","dir","frameId","handleContentScroll","drawerContentElement","current","cancelAnimationFrame","scrollHeight","clientHeight","requestAnimationFrame","dividersVisible","hasFooter","_Drawer","anchor","open","sx","transition","tabIndex","ref","onClick","size","startIcon","MemoizedDrawer","displayName"],"sources":["../src/Drawer.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 {\n memo,\n ReactElement,\n ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { Drawer as MuiDrawer } from \"@mui/material\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"./Button\";\nimport { CloseIcon } from \"./icons.generated\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext\";\nimport { Heading5 } from \"./Typography\";\nimport type { HtmlProps } from \"./HtmlProps\";\n\nexport const variantValues = [\"temporary\", \"persistent\"] as const;\n\nexport type DrawerProps = {\n /**\n * An optional Button object to be situated in the Drawerfooter. Should almost always be of variant `primary`.\n */\n primaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Drawer footer, alongside the `callToActionPrimaryComponent`.\n */\n secondaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Drawer footer, alongside the other two `callToAction` components.\n */\n tertiaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * The content of the Drawer. May be a `string` or any other `ReactNode` or array of `ReactNode`s.\n */\n children?: ReactNode;\n /**\n * When set to `true`, the Drawer will be visible.\n */\n isOpen?: boolean;\n /**\n * Callback that controls what happens when the Drawer is dismissed\n */\n onClose: () => void;\n /**\n * Shows divider lines separating header, content, and footer (if using action buttons)\n */\n showDividers: boolean;\n /**\n * The title of the Drawer\n */\n title?: string;\n /**\n * Type of Drawer\n */\n variant?: (typeof variantValues)[number];\n} & Pick<HtmlProps, \"ariaLabel\" | \"testId\" | \"translate\">;\n\ninterface DrawerStyleProps {\n odysseyDesignTokens: DesignTokens;\n showDividers: boolean;\n}\nconst DrawerHeader = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<DrawerStyleProps>`\n position: sticky;\n top: 0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin: 0;\n padding: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing4}\n ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing5};\n color: ${({ odysseyDesignTokens }) => odysseyDesignTokens.HueNeutral900};\n background-color: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.HueNeutralWhite};\n border-bottom: ${({ showDividers, odysseyDesignTokens }) =>\n showDividers ? `1px solid ${odysseyDesignTokens.HueNeutral200}` : \"none\"};\n`;\n\nconst DrawerContentWrapper = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n overflow-y: auto;\n`;\n\nconst DrawerContent = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<DrawerStyleProps>`\n padding: ${({ showDividers, odysseyDesignTokens }) =>\n showDividers\n ? `${odysseyDesignTokens.Spacing5}`\n : `0 ${odysseyDesignTokens.Spacing5}`};\n`;\n\nconst DrawerFooter = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<DrawerStyleProps>`\n position: sticky;\n bottom: 0;\n display: flex;\n justify-content: flex-end;\n align-items: center;\n align-content: center;\n padding: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing4};\n border-top: ${({ showDividers, odysseyDesignTokens }) =>\n showDividers ? `1px solid ${odysseyDesignTokens.HueNeutral200}` : \"none\"};\n background-color: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.HueNeutralWhite};\n`;\n\nconst Drawer = ({\n ariaLabel,\n children,\n isOpen,\n onClose,\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n showDividers = false,\n tertiaryCallToActionComponent,\n testId,\n title,\n translate,\n variant = \"temporary\",\n}: DrawerProps) => {\n const [isContentScrollable, setIsContentScrollable] = useState(false);\n const drawerContentRef = useRef<HTMLDivElement>(null);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n //If RTL is set in the theme, align the drawer on the left side of the screen, uses right by default.\n const { i18n } = useTranslation();\n const anchorDirection = i18n.dir() === \"rtl\" ? \"left\" : \"right\";\n\n useEffect(() => {\n let frameId: number;\n\n const handleContentScroll = () => {\n const drawerContentElement = drawerContentRef.current;\n if (drawerContentElement) {\n cancelAnimationFrame(frameId);\n setIsContentScrollable(\n drawerContentElement.scrollHeight > drawerContentElement.clientHeight,\n );\n }\n frameId = requestAnimationFrame(handleContentScroll);\n };\n\n if (isOpen) {\n frameId = requestAnimationFrame(handleContentScroll);\n }\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [isOpen]);\n\n const dividersVisible = useMemo(() => {\n return showDividers || isContentScrollable;\n }, [showDividers, isContentScrollable]);\n\n const hasFooter = useMemo(\n () =>\n primaryCallToActionComponent ||\n secondaryCallToActionComponent ||\n tertiaryCallToActionComponent,\n [\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n tertiaryCallToActionComponent,\n ],\n );\n\n return (\n <MuiDrawer\n data-se={testId}\n anchor={anchorDirection}\n open={isOpen}\n onClose={onClose}\n variant={variant}\n sx={{\n //Overrides defualt MUI inline style\n ...(variant === \"persistent\" && {\n \"& .MuiDrawer-paper\": {\n transition: \"none\",\n },\n }),\n }}\n >\n <DrawerContentWrapper\n {...(isContentScrollable && {\n //Sets tabIndex on content element if scrollable so content is easier to navigate with the keyboard\n tabIndex: 0,\n })}\n odysseyDesignTokens={odysseyDesignTokens}\n ref={drawerContentRef}\n >\n <DrawerHeader\n translate={translate}\n odysseyDesignTokens={odysseyDesignTokens}\n showDividers={dividersVisible}\n >\n <Heading5>{title}</Heading5>\n <Button\n ariaLabel={ariaLabel}\n onClick={onClose}\n size=\"small\"\n startIcon={<CloseIcon />}\n variant=\"floating\"\n />\n </DrawerHeader>\n <DrawerContent\n showDividers={dividersVisible}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {children}\n </DrawerContent>\n </DrawerContentWrapper>\n {hasFooter && (\n <DrawerFooter\n odysseyDesignTokens={odysseyDesignTokens}\n showDividers={dividersVisible}\n >\n {tertiaryCallToActionComponent}\n {secondaryCallToActionComponent}\n {primaryCallToActionComponent}\n </DrawerFooter>\n )}\n </MuiDrawer>\n );\n};\n\nconst MemoizedDrawer = memo(Drawer);\nMemoizedDrawer.displayName = \"Dr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,QAAA,GAEtBjB,KAAA,CAACE,YAAY;QACXuB,SAAS,EAAEA,SAAU;QACrBpB,mBAAmB,EAAEA,mBAAoB;QACzCK,YAAY,EAAE+B,eAAgB;QAAAxB,QAAA,GAE9BnB,IAAA,CAACF,QAAQ;UAAAqB,QAAA,EAAEO;QAAK,CAAW,CAAC,EAC5B1B,IAAA,CAACL,MAAM;UACLuB,SAAS,EAAEA,SAAU;UACrBkC,OAAO,EAAE/B,OAAQ;UACjBgC,IAAI,EAAC,OAAO;UACZC,SAAS,EAAEtD,IAAA,CAACJ,SAAS,IAAE,CAAE;UACzBgC,OAAO,EAAC;QAAU,CACnB,CAAC;MAAA,CACU,CAAC,EACf5B,IAAA,CAACe,aAAa;QACZH,YAAY,EAAE+B,eAAgB;QAC9BpC,mBAAmB,EAAEA,mBAAoB;QAAAY,QAAA,EAExCA;MAAQ,CACI,CAAC;IAAA,CACI,CAAC,EACtByB,SAAS,IACR1C,KAAA,CAACc,YAAY;MACXT,mBAAmB,EAAEA,mBAAoB;MACzCK,YAAY,EAAE+B,eAAgB;MAAAxB,QAAA,GAE7BK,6BAA6B,EAC7BD,8BAA8B,EAC9BD,4BAA4B;IAAA,CACjB,CACf;EAAA,CACQ,CAAC;AAEhB,CAAC;AAED,MAAMiC,cAAc,GAAGnE,IAAI,CAAC6B,MAAM,CAAC;AACnCsC,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAItC,MAAM"}
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["memo","useEffect","useMemo","useRef","useState","styled","useTranslation","Button","CloseIcon","useOdysseyDesignTokens","Heading5","jsx","_jsx","jsxs","_jsxs","variantValues","DrawerHeader","shouldForwardProp","prop","odysseyDesignTokens","Spacing4","Spacing5","HueNeutral900","HueNeutralWhite","showDividers","HueNeutral200","DrawerContentWrapper","DrawerContent","DrawerFooter","Drawer","ariaLabel","children","isOpen","onClose","primaryCallToActionComponent","secondaryCallToActionComponent","tertiaryCallToActionComponent","testId","title","translate","variant","isContentScrollable","setIsContentScrollable","drawerContentRef","i18n","anchorDirection","dir","frameId","handleContentScroll","drawerContentElement","current","cancelAnimationFrame","scrollHeight","clientHeight","requestAnimationFrame","dividersVisible","hasFooter","_Drawer","anchor","open","sx","transition","tabIndex","ref","onClick","size","startIcon","MemoizedDrawer","displayName"],"sources":["../src/Drawer.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 {\n memo,\n ReactElement,\n ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { Drawer as MuiDrawer } from \"@mui/material\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"./Buttons\";\nimport { CloseIcon } from \"./icons.generated\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext\";\nimport { Heading5 } from \"./Typography\";\nimport type { HtmlProps } from \"./HtmlProps\";\n\nexport const variantValues = [\"temporary\", \"persistent\"] as const;\n\nexport type DrawerProps = {\n /**\n * An optional Button object to be situated in the Drawerfooter. Should almost always be of variant `primary`.\n */\n primaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Drawer footer, alongside the `callToActionPrimaryComponent`.\n */\n secondaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Drawer footer, alongside the other two `callToAction` components.\n */\n tertiaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * The content of the Drawer. May be a `string` or any other `ReactNode` or array of `ReactNode`s.\n */\n children?: ReactNode;\n /**\n * When set to `true`, the Drawer will be visible.\n */\n isOpen?: boolean;\n /**\n * Callback that controls what happens when the Drawer is dismissed\n */\n onClose: () => void;\n /**\n * Shows divider lines separating header, content, and footer (if using action buttons)\n */\n showDividers: boolean;\n /**\n * The title of the Drawer\n */\n title?: string;\n /**\n * Type of Drawer\n */\n variant?: (typeof variantValues)[number];\n} & Pick<HtmlProps, \"ariaLabel\" | \"testId\" | \"translate\">;\n\ninterface DrawerStyleProps {\n odysseyDesignTokens: DesignTokens;\n showDividers: boolean;\n}\nconst DrawerHeader = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<DrawerStyleProps>`\n position: sticky;\n top: 0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin: 0;\n padding: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing4}\n ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing5};\n color: ${({ odysseyDesignTokens }) => odysseyDesignTokens.HueNeutral900};\n background-color: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.HueNeutralWhite};\n border-bottom: ${({ showDividers, odysseyDesignTokens }) =>\n showDividers ? `1px solid ${odysseyDesignTokens.HueNeutral200}` : \"none\"};\n`;\n\nconst DrawerContentWrapper = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n overflow-y: auto;\n`;\n\nconst DrawerContent = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<DrawerStyleProps>`\n padding: ${({ showDividers, odysseyDesignTokens }) =>\n showDividers\n ? `${odysseyDesignTokens.Spacing5}`\n : `0 ${odysseyDesignTokens.Spacing5}`};\n`;\n\nconst DrawerFooter = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<DrawerStyleProps>`\n position: sticky;\n bottom: 0;\n display: flex;\n justify-content: flex-end;\n align-items: center;\n align-content: center;\n padding: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing4};\n border-top: ${({ showDividers, odysseyDesignTokens }) =>\n showDividers ? `1px solid ${odysseyDesignTokens.HueNeutral200}` : \"none\"};\n background-color: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.HueNeutralWhite};\n`;\n\nconst Drawer = ({\n ariaLabel,\n children,\n isOpen,\n onClose,\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n showDividers = false,\n tertiaryCallToActionComponent,\n testId,\n title,\n translate,\n variant = \"temporary\",\n}: DrawerProps) => {\n const [isContentScrollable, setIsContentScrollable] = useState(false);\n const drawerContentRef = useRef<HTMLDivElement>(null);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n //If RTL is set in the theme, align the drawer on the left side of the screen, uses right by default.\n const { i18n } = useTranslation();\n const anchorDirection = i18n.dir() === \"rtl\" ? \"left\" : \"right\";\n\n useEffect(() => {\n let frameId: number;\n\n const handleContentScroll = () => {\n const drawerContentElement = drawerContentRef.current;\n if (drawerContentElement) {\n cancelAnimationFrame(frameId);\n setIsContentScrollable(\n drawerContentElement.scrollHeight > drawerContentElement.clientHeight,\n );\n }\n frameId = requestAnimationFrame(handleContentScroll);\n };\n\n if (isOpen) {\n frameId = requestAnimationFrame(handleContentScroll);\n }\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [isOpen]);\n\n const dividersVisible = useMemo(() => {\n return showDividers || isContentScrollable;\n }, [showDividers, isContentScrollable]);\n\n const hasFooter = useMemo(\n () =>\n primaryCallToActionComponent ||\n secondaryCallToActionComponent ||\n tertiaryCallToActionComponent,\n [\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n tertiaryCallToActionComponent,\n ],\n );\n\n return (\n <MuiDrawer\n data-se={testId}\n anchor={anchorDirection}\n open={isOpen}\n onClose={onClose}\n variant={variant}\n sx={{\n //Overrides defualt MUI inline style\n ...(variant === \"persistent\" && {\n \"& .MuiDrawer-paper\": {\n transition: \"none\",\n },\n }),\n }}\n >\n <DrawerContentWrapper\n {...(isContentScrollable && {\n //Sets tabIndex on content element if scrollable so content is easier to navigate with the keyboard\n tabIndex: 0,\n })}\n odysseyDesignTokens={odysseyDesignTokens}\n ref={drawerContentRef}\n >\n <DrawerHeader\n translate={translate}\n odysseyDesignTokens={odysseyDesignTokens}\n showDividers={dividersVisible}\n >\n <Heading5>{title}</Heading5>\n <Button\n ariaLabel={ariaLabel}\n onClick={onClose}\n size=\"small\"\n startIcon={<CloseIcon />}\n variant=\"floating\"\n />\n </DrawerHeader>\n <DrawerContent\n showDividers={dividersVisible}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {children}\n </DrawerContent>\n </DrawerContentWrapper>\n {hasFooter && (\n <DrawerFooter\n odysseyDesignTokens={odysseyDesignTokens}\n showDividers={dividersVisible}\n >\n {tertiaryCallToActionComponent}\n {secondaryCallToActionComponent}\n {primaryCallToActionComponent}\n </DrawerFooter>\n )}\n </MuiDrawer>\n );\n};\n\nconst MemoizedDrawer = memo(Drawer);\nMemoizedDrawer.displayName = \"Drawer\";\n\nexport { MemoizedDrawer as Drawer };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAGJC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,cAAc,QAAQ,eAAe;AAAC,SAEtCC,MAAM;AAAA,SACNC,SAAS;AAAA,SAGhBC,sBAAsB;AAAA,SAEfC,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAGjB,OAAO,MAAMC,aAAa,GAAG,CAAC,WAAW,EAAE,YAAY,CAAU;AA6CjE,MAAMC,YAAY,GAAGX,MAAM,CAAC,KAAK,EAAE;EACjCY,iBAAiB,EAAGC,IAAI,IAAKA,IAAI,KAAK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AA,CACI,CAAC,EACtByB,SAAS,IACR1C,KAAA,CAACc,YAAY;MACXT,mBAAmB,EAAEA,mBAAoB;MACzCK,YAAY,EAAE+B,eAAgB;MAAAxB,QAAA,GAE7BK,6BAA6B,EAC7BD,8BAA8B,EAC9BD,4BAA4B;IAAA,CACjB,CACf;EAAA,CACQ,CAAC;AAEhB,CAAC;AAED,MAAMiC,cAAc,GAAGnE,IAAI,CAAC6B,MAAM,CAAC;AACnCsC,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAItC,MAAM"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
14
14
|
import styled from "@emotion/styled";
|
|
15
15
|
import { useTranslation } from "react-i18next";
|
|
16
|
-
import { Button } from "../
|
|
16
|
+
import { Button } from "../Buttons/index.js";
|
|
17
17
|
import { UploadIcon } from "../icons.generated/index.js";
|
|
18
18
|
import { Field } from "../Field.js";
|
|
19
19
|
import { FileUploadPreview } from "./FileUploadPreview.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploader.js","names":["memo","useCallback","useEffect","useRef","useState","styled","useTranslation","Button","UploadIcon","Field","FileUploadPreview","FileUploadIllustration","useOdysseyDesignTokens","Support","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","fileUploadTypes","fileUploadVariants","BaseInputWrapper","div","position","alignSelf","input","width","height","opacity","InputContainer","display","alignItems","justifyContent","borderStyle","hasError","odysseyDesignTokens","padding","Spacing6","Spacing3","border","PaletteDangerMain","HueNeutral300","borderRadius","BorderRadiusMain","transition","TransitionTimingMain","borderColor","HueNeutral700","FocusOutlineColorPrimary","boxShadow","outline","FocusOutlineWidthMain","FocusOutlineStyle","outlineOffset","FocusOutlineOffsetTight","backgroundColor","HueNeutral50","BorderColorDisabled","color","TypographyColorDisabled","ButtonAndInfoContainer","flexDirection","CenterAlignedSupportText","textAlign","FileUploader","acceptedFileTypes","errorMessage","id","isDisabled","isFullWidth","isOptional","hint","HintLinkComponent","label","onChange","type","variant","t","inputRef","filesToUpload","setFilesToUpload","updateFilesToUpload","event","files","target","length","mergedFiles","value","triggerFileInputClick","current","click","removeFileFromFilesToUploadList","name","deletedFileFilteredOut","filter","file","renderFileInput","ariaDescribedBy","errorMessageElementId","labelElementId","acceptedFileTypesAsString","join","Input","accept","disabled","multiple","ref","title","children","onClick","startIcon","Boolean","fieldType","hasVisibleLabel","renderFieldComponent","fileNames","map","onFileRemove","MemoizedFileUploader","displayName","FileUpload"],"sources":["../../src/FileUploader/FileUploader.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 {\n memo,\n ChangeEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"../Button\";\nimport { UploadIcon } from \"../icons.generated\";\nimport { Field, RenderFieldComponentProps } from \"../Field\";\nimport { FieldComponentProps } from \"../FieldComponentProps\";\nimport { FileUploadPreview } from \"./FileUploadPreview\";\nimport { FileUploadIllustration } from \"./FileUploadIllustration\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { Support } from \"../Typography\";\n\nexport const fileUploadTypes = [\"single\", \"multiple\"] as const;\nexport const fileUploadVariants = [\n \"button\",\n \"dragAndDrop\",\n \"dragAndDropWithIcon\",\n] as const;\n\nconst BaseInputWrapper = styled.div({\n position: \"relative\",\n alignSelf: \"flex-start\",\n\n input: {\n position: \"absolute\",\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n },\n});\n\nconst InputContainer = styled(BaseInputWrapper)<{\n odysseyDesignTokens: DesignTokens;\n hasError: boolean;\n}>(\n {\n display: \"flex\",\n alignSelf: \"unset\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n \"&:has(input:focus)\": {\n borderStyle: \"solid\",\n },\n },\n ({ hasError, odysseyDesignTokens }) => ({\n padding: `${odysseyDesignTokens.Spacing6} ${odysseyDesignTokens.Spacing3}`,\n border: hasError\n ? `1px solid ${odysseyDesignTokens.PaletteDangerMain}`\n : `1px dashed ${odysseyDesignTokens.HueNeutral300}`,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n transition: `border-color ${odysseyDesignTokens.TransitionTimingMain}, box-shadow ${odysseyDesignTokens.TransitionTimingMain}`,\n\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral700,\n },\n\n \"&:has(input:focus)\": {\n borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,\n boxShadow: `0 0 0 1px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,\n outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,\n outlineOffset: odysseyDesignTokens.FocusOutlineOffsetTight,\n },\n\n \"&:has(input:disabled)\": {\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n border: `1px solid ${odysseyDesignTokens.BorderColorDisabled}`,\n color: odysseyDesignTokens.TypographyColorDisabled,\n\n \"&:hover\": {\n borderColor: odysseyDesignTokens.BorderColorDisabled,\n },\n },\n }),\n);\n\nconst ButtonAndInfoContainer = styled.div({\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n});\n\nconst CenterAlignedSupportText = styled.div({\n textAlign: \"center\",\n});\n\nexport type FileUploaderProps = {\n /**\n * an array of file types the user is able to upload. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers for examples\n */\n acceptedFileTypes?: string[];\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Function that is called when the list of ifles to upload is changed\n */\n onChange: (files: File[]) => void;\n /**\n * Either `single` or `multiple`. If `multiple`, multiple files can be uploaded\n */\n type?: (typeof fileUploadTypes)[number];\n /**\n * Either `button`, `dragAndDrop` or `dragAndDropWithIcon`. Will determine how component appears visually\n */\n variant: (typeof fileUploadVariants)[number];\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n>;\n\nconst FileUploader = ({\n acceptedFileTypes,\n errorMessage,\n id,\n isDisabled = false,\n isFullWidth,\n isOptional,\n hint,\n HintLinkComponent,\n label,\n onChange,\n type,\n variant,\n}: FileUploaderProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n const inputRef = useRef<HTMLInputElement>(null);\n const [filesToUpload, setFilesToUpload] = useState<File[]>([]);\n\n useEffect(() => {\n onChange(filesToUpload);\n }, [filesToUpload, onChange]);\n\n const updateFilesToUpload = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { files } = event.target;\n\n if (files && files.length > 0) {\n const mergedFiles =\n type === \"multiple\"\n ? [...filesToUpload, ...files]\n : ([...files] satisfies File[] as File[]);\n\n setFilesToUpload(mergedFiles);\n }\n\n // reset input value to allow re-upload of a file with the same name\n event.target.value = \"\";\n },\n [type, filesToUpload],\n );\n\n const triggerFileInputClick = useCallback(() => {\n inputRef.current?.click();\n }, [inputRef]);\n\n const removeFileFromFilesToUploadList = useCallback<(name: string) => void>(\n (name) => {\n const deletedFileFilteredOut = filesToUpload.filter(\n (file) => file.name !== name,\n );\n setFilesToUpload(deletedFileFilteredOut);\n },\n [filesToUpload],\n );\n\n const renderFileInput = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: RenderFieldComponentProps) => {\n const acceptedFileTypesAsString = acceptedFileTypes?.join(\",\");\n\n const Input = () => (\n <input\n accept={acceptedFileTypesAsString}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n aria-labelledby={labelElementId}\n disabled={isDisabled}\n id={id}\n multiple={type === \"multiple\"}\n onChange={updateFilesToUpload}\n ref={inputRef}\n title=\"\"\n type=\"file\"\n />\n );\n\n if (variant === \"button\") {\n return (\n <>\n <BaseInputWrapper>\n <Input />\n <Button\n isDisabled={isDisabled}\n label={t(\"fileupload.button.text\")}\n onClick={triggerFileInputClick}\n startIcon={<UploadIcon />}\n variant=\"secondary\"\n />\n </BaseInputWrapper>\n </>\n );\n }\n\n return (\n <>\n <InputContainer\n hasError={Boolean(errorMessage)}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Input />\n <ButtonAndInfoContainer>\n {variant === \"dragAndDropWithIcon\" && <FileUploadIllustration />}\n <CenterAlignedSupportText>\n <Support color=\"textSecondary\">\n {t(\"fileupload.prompt.text\")}\n </Support>\n </CenterAlignedSupportText>\n <Button\n isDisabled={isDisabled}\n label={t(\"fileupload.button.text\")}\n onClick={triggerFileInputClick}\n startIcon={<UploadIcon />}\n variant=\"secondary\"\n />\n </ButtonAndInfoContainer>\n </InputContainer>\n </>\n );\n },\n [\n acceptedFileTypes,\n errorMessage,\n isDisabled,\n inputRef,\n odysseyDesignTokens,\n triggerFileInputClick,\n t,\n type,\n updateFilesToUpload,\n variant,\n ],\n );\n\n return (\n <>\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={id}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth && variant !== \"button\"}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFileInput}\n />\n {filesToUpload.length > 0 && (\n <FileUploadPreview\n fileNames={filesToUpload.map((file) => file.name)}\n onFileRemove={removeFileFromFilesToUploadList}\n isDisabled={isDisabled}\n />\n )}\n </>\n );\n};\n\nconst MemoizedFileUploader = memo(FileUploader);\nMemoizedFileUploader.displayName = \"FileUploader\";\n\nexport { MemoizedFileUploader as FileUpload };\nexport { MemoizedFileUploader as FileUploader };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAEJC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,cAAc,QAAQ,eAAe;AAAC,SAEtCC,MAAM;AAAA,SACNC,UAAU;AAAA,SACVC,KAAK;AAAA,SAELC,iBAAiB;AAAA,SACjBC,sBAAsB;AAAA,SAE7BC,sBAAsB;AAAA,SAGfC,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAEhB,OAAO,MAAMC,eAAe,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAU;AAC9D,OAAO,MAAMC,kBAAkB,GAAG,CAChC,QAAQ,EACR,aAAa,EACb,qBAAqB,CACb;AAEV,MAAMC,gBAAgB,GAAGjB,MAAM,CAACkB,GAAG,CAAC;EAClCC,QAAQ,EAAE,UAAU;EACpBC,SAAS,EAAE,YAAY;EAEvBC,KAAK,EAAE;IACLF,QAAQ,EAAE,UAAU;IACpBG,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAEF,MAAMC,cAAc,GAAGzB,MAAM,CAACiB,gBAAgB,CAAC,CAI7C;EACES,OAAO,EAAE,MAAM;EACfN,SAAS,EAAE,OAAO;EAClBO,UAAU,EAAE,QAAQ;EACpBC,cAAc,EAAE,QAAQ;EAExB,oBAAoB,EAAE;IACpBC,WAAW,EAAE;EACf;AACF,CAAC,EACD,CAAC;EAAEC,QAAQ;EAAEC;AAAoB,CAAC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vBvE,IAAA,CAACL,iBAAiB;MAChB0G,SAAS,EAAEpC,aAAa,CAACqC,GAAG,CAAErB,IAAI,IAAKA,IAAI,CAACH,IAAI,CAAE;MAClDyB,YAAY,EAAE1B,+BAAgC;MAC9CvB,UAAU,EAAEA;IAAW,CACxB,CACF;EAAA,CACD,CAAC;AAEP,CAAC;AAED,MAAMkD,oBAAoB,GAAGvH,IAAI,CAACiE,YAAY,CAAC;AAC/CsD,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIE,UAAU;AAC3C,SAASF,oBAAoB,IAAItD,YAAY"}
|
|
1
|
+
{"version":3,"file":"FileUploader.js","names":["memo","useCallback","useEffect","useRef","useState","styled","useTranslation","Button","UploadIcon","Field","FileUploadPreview","FileUploadIllustration","useOdysseyDesignTokens","Support","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","fileUploadTypes","fileUploadVariants","BaseInputWrapper","div","position","alignSelf","input","width","height","opacity","InputContainer","display","alignItems","justifyContent","borderStyle","hasError","odysseyDesignTokens","padding","Spacing6","Spacing3","border","PaletteDangerMain","HueNeutral300","borderRadius","BorderRadiusMain","transition","TransitionTimingMain","borderColor","HueNeutral700","FocusOutlineColorPrimary","boxShadow","outline","FocusOutlineWidthMain","FocusOutlineStyle","outlineOffset","FocusOutlineOffsetTight","backgroundColor","HueNeutral50","BorderColorDisabled","color","TypographyColorDisabled","ButtonAndInfoContainer","flexDirection","CenterAlignedSupportText","textAlign","FileUploader","acceptedFileTypes","errorMessage","id","isDisabled","isFullWidth","isOptional","hint","HintLinkComponent","label","onChange","type","variant","t","inputRef","filesToUpload","setFilesToUpload","updateFilesToUpload","event","files","target","length","mergedFiles","value","triggerFileInputClick","current","click","removeFileFromFilesToUploadList","name","deletedFileFilteredOut","filter","file","renderFileInput","ariaDescribedBy","errorMessageElementId","labelElementId","acceptedFileTypesAsString","join","Input","accept","disabled","multiple","ref","title","children","onClick","startIcon","Boolean","fieldType","hasVisibleLabel","renderFieldComponent","fileNames","map","onFileRemove","MemoizedFileUploader","displayName","FileUpload"],"sources":["../../src/FileUploader/FileUploader.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 {\n memo,\n ChangeEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"../Buttons\";\nimport { UploadIcon } from \"../icons.generated\";\nimport { Field, RenderFieldComponentProps } from \"../Field\";\nimport { FieldComponentProps } from \"../FieldComponentProps\";\nimport { FileUploadPreview } from \"./FileUploadPreview\";\nimport { FileUploadIllustration } from \"./FileUploadIllustration\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { Support } from \"../Typography\";\n\nexport const fileUploadTypes = [\"single\", \"multiple\"] as const;\nexport const fileUploadVariants = [\n \"button\",\n \"dragAndDrop\",\n \"dragAndDropWithIcon\",\n] as const;\n\nconst BaseInputWrapper = styled.div({\n position: \"relative\",\n alignSelf: \"flex-start\",\n\n input: {\n position: \"absolute\",\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n },\n});\n\nconst InputContainer = styled(BaseInputWrapper)<{\n odysseyDesignTokens: DesignTokens;\n hasError: boolean;\n}>(\n {\n display: \"flex\",\n alignSelf: \"unset\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n \"&:has(input:focus)\": {\n borderStyle: \"solid\",\n },\n },\n ({ hasError, odysseyDesignTokens }) => ({\n padding: `${odysseyDesignTokens.Spacing6} ${odysseyDesignTokens.Spacing3}`,\n border: hasError\n ? `1px solid ${odysseyDesignTokens.PaletteDangerMain}`\n : `1px dashed ${odysseyDesignTokens.HueNeutral300}`,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n transition: `border-color ${odysseyDesignTokens.TransitionTimingMain}, box-shadow ${odysseyDesignTokens.TransitionTimingMain}`,\n\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral700,\n },\n\n \"&:has(input:focus)\": {\n borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,\n boxShadow: `0 0 0 1px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,\n outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,\n outlineOffset: odysseyDesignTokens.FocusOutlineOffsetTight,\n },\n\n \"&:has(input:disabled)\": {\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n border: `1px solid ${odysseyDesignTokens.BorderColorDisabled}`,\n color: odysseyDesignTokens.TypographyColorDisabled,\n\n \"&:hover\": {\n borderColor: odysseyDesignTokens.BorderColorDisabled,\n },\n },\n }),\n);\n\nconst ButtonAndInfoContainer = styled.div({\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n});\n\nconst CenterAlignedSupportText = styled.div({\n textAlign: \"center\",\n});\n\nexport type FileUploaderProps = {\n /**\n * an array of file types the user is able to upload. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers for examples\n */\n acceptedFileTypes?: string[];\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Function that is called when the list of ifles to upload is changed\n */\n onChange: (files: File[]) => void;\n /**\n * Either `single` or `multiple`. If `multiple`, multiple files can be uploaded\n */\n type?: (typeof fileUploadTypes)[number];\n /**\n * Either `button`, `dragAndDrop` or `dragAndDropWithIcon`. Will determine how component appears visually\n */\n variant: (typeof fileUploadVariants)[number];\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n>;\n\nconst FileUploader = ({\n acceptedFileTypes,\n errorMessage,\n id,\n isDisabled = false,\n isFullWidth,\n isOptional,\n hint,\n HintLinkComponent,\n label,\n onChange,\n type,\n variant,\n}: FileUploaderProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n const inputRef = useRef<HTMLInputElement>(null);\n const [filesToUpload, setFilesToUpload] = useState<File[]>([]);\n\n useEffect(() => {\n onChange(filesToUpload);\n }, [filesToUpload, onChange]);\n\n const updateFilesToUpload = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { files } = event.target;\n\n if (files && files.length > 0) {\n const mergedFiles =\n type === \"multiple\"\n ? [...filesToUpload, ...files]\n : ([...files] satisfies File[] as File[]);\n\n setFilesToUpload(mergedFiles);\n }\n\n // reset input value to allow re-upload of a file with the same name\n event.target.value = \"\";\n },\n [type, filesToUpload],\n );\n\n const triggerFileInputClick = useCallback(() => {\n inputRef.current?.click();\n }, [inputRef]);\n\n const removeFileFromFilesToUploadList = useCallback<(name: string) => void>(\n (name) => {\n const deletedFileFilteredOut = filesToUpload.filter(\n (file) => file.name !== name,\n );\n setFilesToUpload(deletedFileFilteredOut);\n },\n [filesToUpload],\n );\n\n const renderFileInput = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: RenderFieldComponentProps) => {\n const acceptedFileTypesAsString = acceptedFileTypes?.join(\",\");\n\n const Input = () => (\n <input\n accept={acceptedFileTypesAsString}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n aria-labelledby={labelElementId}\n disabled={isDisabled}\n id={id}\n multiple={type === \"multiple\"}\n onChange={updateFilesToUpload}\n ref={inputRef}\n title=\"\"\n type=\"file\"\n />\n );\n\n if (variant === \"button\") {\n return (\n <>\n <BaseInputWrapper>\n <Input />\n <Button\n isDisabled={isDisabled}\n label={t(\"fileupload.button.text\")}\n onClick={triggerFileInputClick}\n startIcon={<UploadIcon />}\n variant=\"secondary\"\n />\n </BaseInputWrapper>\n </>\n );\n }\n\n return (\n <>\n <InputContainer\n hasError={Boolean(errorMessage)}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Input />\n <ButtonAndInfoContainer>\n {variant === \"dragAndDropWithIcon\" && <FileUploadIllustration />}\n <CenterAlignedSupportText>\n <Support color=\"textSecondary\">\n {t(\"fileupload.prompt.text\")}\n </Support>\n </CenterAlignedSupportText>\n <Button\n isDisabled={isDisabled}\n label={t(\"fileupload.button.text\")}\n onClick={triggerFileInputClick}\n startIcon={<UploadIcon />}\n variant=\"secondary\"\n />\n </ButtonAndInfoContainer>\n </InputContainer>\n </>\n );\n },\n [\n acceptedFileTypes,\n errorMessage,\n isDisabled,\n inputRef,\n odysseyDesignTokens,\n triggerFileInputClick,\n t,\n type,\n updateFilesToUpload,\n variant,\n ],\n );\n\n return (\n <>\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={id}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth && variant !== \"button\"}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFileInput}\n />\n {filesToUpload.length > 0 && (\n <FileUploadPreview\n fileNames={filesToUpload.map((file) => file.name)}\n onFileRemove={removeFileFromFilesToUploadList}\n isDisabled={isDisabled}\n />\n )}\n </>\n );\n};\n\nconst MemoizedFileUploader = memo(FileUploader);\nMemoizedFileUploader.displayName = \"FileUploader\";\n\nexport { MemoizedFileUploader as FileUpload };\nexport { MemoizedFileUploader as FileUploader };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAEJC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,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C,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIE,UAAU;AAC3C,SAASF,oBAAoB,IAAItD,YAAY"}
|
package/dist/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","names":["memo","styled","Heading4","Support","useUniqueId","useOdysseyDesignTokens","jsx","_jsx","jsxs","_jsxs","formEncodingTypeValues","formAutoCompleteTypeValues","formMethodValues","StyledForm","form","isFullWidth","odysseyDesignTokens","maxWidth","TypographyLineLengthMax","margin","padding","TitleContainer","div","marginBlockEnd","Spacing4","FormActionContainer","display","justifyContent","gap","Spacing1","marginBlockStart","Spacing7","Form","alert","autoCompleteType","children","description","encodingType","formActions","id","idOverride","method","name","noValidate","onSubmit","target","testId","title","translate","autoComplete","encType","component","MemoizedForm","displayName"],"sources":["../src/Form.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 { FormEventHandler, memo, ReactElement } from \"react\";\nimport styled from \"@emotion/styled\";\n\nimport { Button } from \"./
|
|
1
|
+
{"version":3,"file":"Form.js","names":["memo","styled","Heading4","Support","useUniqueId","useOdysseyDesignTokens","jsx","_jsx","jsxs","_jsxs","formEncodingTypeValues","formAutoCompleteTypeValues","formMethodValues","StyledForm","form","isFullWidth","odysseyDesignTokens","maxWidth","TypographyLineLengthMax","margin","padding","TitleContainer","div","marginBlockEnd","Spacing4","FormActionContainer","display","justifyContent","gap","Spacing1","marginBlockStart","Spacing7","Form","alert","autoCompleteType","children","description","encodingType","formActions","id","idOverride","method","name","noValidate","onSubmit","target","testId","title","translate","autoComplete","encType","component","MemoizedForm","displayName"],"sources":["../src/Form.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 { FormEventHandler, memo, ReactElement } from \"react\";\nimport styled from \"@emotion/styled\";\n\nimport { Button } from \"./Buttons\";\nimport { Callout } from \"./Callout\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { HtmlProps } from \"./HtmlProps\";\nimport { Heading4, Support } from \"./Typography\";\nimport { useUniqueId } from \"./useUniqueId\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext\";\n\nexport const formEncodingTypeValues = [\n \"application/x-www-form-urlencoded\",\n \"application/json\",\n \"multipart/form-data\",\n \"text/plain\",\n] as const;\nexport const formAutoCompleteTypeValues = [\"on\", \"off\"] as const;\nexport const formMethodValues = [\"post\", \"get\", \"dialog\"] as const;\n\nconst StyledForm = styled.form<{\n isFullWidth?: boolean;\n odysseyDesignTokens: DesignTokens;\n}>(({ isFullWidth, odysseyDesignTokens }) => ({\n maxWidth: isFullWidth ? \"100%\" : odysseyDesignTokens.TypographyLineLengthMax,\n margin: 0,\n padding: 0,\n}));\n\nconst TitleContainer = styled.div<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n marginBlockEnd: odysseyDesignTokens.Spacing4,\n}));\n\nconst FormActionContainer = styled.div<{\n odysseyDesignTokens: DesignTokens;\n}>(\n {\n display: \"flex\",\n justifyContent: \"flex-end\",\n },\n ({ odysseyDesignTokens }) => ({\n gap: odysseyDesignTokens.Spacing1,\n marginBlockStart: odysseyDesignTokens.Spacing7,\n }),\n);\n\nexport type FormProps = {\n /**\n * A Callout indicating a Form-wide error or status update.\n */\n alert?: ReactElement<typeof Callout>;\n /**\n * Indicates whether input elements can by default have their values automatically completed by the browser.\n * `autocomplete` attributes on form elements override it on <form>\n */\n autoCompleteType?: (typeof formAutoCompleteTypeValues)[number];\n /**\n * The Field or FieldSet components within the Form\n */\n children: ReactElement | Array<ReactElement>;\n /**\n * A supplementary description\n */\n description?: string;\n /**\n * If the value of the method attribute is post, enctype is the MIME type of the form submission.\n * This value can be overridden by formenctype attributes on <button>, <input type=\"submit\">, or <input type=\"image\"> elements.\n */\n encodingType?: (typeof formEncodingTypeValues)[number];\n /**\n * The Field or FieldGroup components within the Form\n */\n formActions?:\n | ReactElement<typeof Button>\n | Array<ReactElement<typeof Button>>;\n /**\n * Defines a unique identifier (ID) which must be unique in the whole document.\n */\n id?: string;\n /**\n * The HTTP method to submit the form with.\n * This value is overridden by formmethod attributes on <button>, <input type=\"submit\">, or <input type=\"image\"> elements.\n */\n method?: (typeof formMethodValues)[number];\n /**\n * The name of the form. The value must not be the empty string, and must be unique among the form elements in the forms collection that it is in, if any.\n */\n name: string;\n /**\n * This Boolean attribute indicates that the form shouldn't be validated when submitted.\n * If this attribute is not set (and therefore the form is validated),\n * it can be overridden by a formnovalidate attribute on a <button>, <input type=\"submit\">, or <input type=\"image\"> element belonging to the form.\n */\n noValidate?: boolean;\n /**\n * Callback that passes the submit event to the consumer\n */\n onSubmit?: FormEventHandler<HTMLFormElement>;\n /**\n * Indicates where to display the response after submitting the form. It is a name/keyword for a browsing context (for example, tab, window, or iframe).\n * This value can be overridden by a formtarget attribute on a <button>, <input type=\"submit\">, or <input type=\"image\"> element.\n */\n target?: string;\n /**\n * The title of the Form\n */\n title?: string;\n} & Pick<FieldComponentProps, \"isFullWidth\"> &\n Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst Form = ({\n alert,\n autoCompleteType,\n children,\n description,\n encodingType,\n formActions,\n id: idOverride,\n isFullWidth,\n method,\n name,\n noValidate = false,\n onSubmit,\n target,\n testId,\n title,\n translate,\n}: FormProps) => {\n const id = useUniqueId(idOverride);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n return (\n <StyledForm\n autoComplete={autoCompleteType}\n data-se={testId}\n encType={encodingType}\n id={id}\n isFullWidth={isFullWidth}\n method={method}\n name={name}\n noValidate={noValidate}\n odysseyDesignTokens={odysseyDesignTokens}\n onSubmit={onSubmit}\n target={target}\n >\n <TitleContainer odysseyDesignTokens={odysseyDesignTokens}>\n {title && (\n <Heading4 component=\"h1\" translate={translate}>\n {title}\n </Heading4>\n )}\n {description && <Support translate={translate}>{description}</Support>}\n {alert}\n </TitleContainer>\n <div>{children}</div>\n {formActions && (\n <FormActionContainer odysseyDesignTokens={odysseyDesignTokens}>\n {formActions}\n </FormActionContainer>\n )}\n </StyledForm>\n );\n};\n\nconst MemoizedForm = memo(Form);\nMemoizedForm.displayName = \"Form\";\n\nexport { MemoizedForm as Form };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAA2BA,IAAI,QAAsB,OAAO;AAC5D,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAM5BC,QAAQ,EAAEC,OAAO;AAAA,SACjBC,WAAW;AAAA,SAElBC,sBAAsB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAIxB,OAAO,MAAMC,sBAAsB,GAAG,CACpC,mCAAmC,EACnC,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,CACJ;AACV,OAAO,MAAMC,0BAA0B,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU;AAChE,OAAO,MAAMC,gBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU;AAElE,MAAMC,UAAU,GAAGZ,MAAM,CAACa,I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AAoB;IACzC4B,QAAQ,EAAEA,QAAS;IACnBC,MAAM,EAAEA,MAAO;IAAAV,QAAA,GAEf1B,KAAA,CAACY,cAAc;MAACL,mBAAmB,EAAEA,mBAAoB;MAAAmB,QAAA,GACtDY,KAAK,IACJxC,IAAA,CAACL,QAAQ;QAACiD,SAAS,EAAC,IAAI;QAACH,SAAS,EAAEA,SAAU;QAAAb,QAAA,EAC3CY;MAAK,CACE,CACX,EACAX,WAAW,IAAI7B,IAAA,CAACJ,OAAO;QAAC6C,SAAS,EAAEA,SAAU;QAAAb,QAAA,EAAEC;MAAW,CAAU,CAAC,EACrEH,KAAK;IAAA,CACQ,CAAC,EACjB1B,IAAA;MAAA4B,QAAA,EAAMA;IAAQ,CAAM,CAAC,EACpBG,WAAW,IACV/B,IAAA,CAACkB,mBAAmB;MAACT,mBAAmB,EAAEA,mBAAoB;MAAAmB,QAAA,EAC3DG;IAAW,CACO,CACtB;EAAA,CACS,CAAC;AAEjB,CAAC;AAED,MAAMc,YAAY,GAAGpD,IAAI,CAACgC,IAAI,CAAC;AAC/BoB,YAAY,CAACC,WAAW,GAAG,MAAM;AAEjC,SAASD,YAAY,IAAIpB,IAAI"}
|
package/dist/HtmlProps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlProps.js","names":[],"sources":["../src/HtmlProps.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { HTMLAttributes } from \"react\";\n\nexport type HtmlProps = {\n /**\n * Used in [ARIA live regions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions), the global aria-busy state indicates an element is being modified and that assistive technologies may want to wait until the changes are complete before informing the user about the update.\n */\n ariaBusy?: HTMLAttributes<HTMLElement>[\"aria-busy\"];\n /**\n * The `aria-checked` attribute indicates the current \"checked\" state of checkboxes, radio buttons, and other widgets.\n *\n * NOTE: Where possible use an HTML `<input>` element with `type=\"checkbox\"` and `type=\"radio\"` as these have built in semantics and do not require ARIA attributes.\n */\n ariaChecked?: HTMLAttributes<HTMLElement>[\"aria-checked\"];\n /**\n * The global `aria-controls` property identifies the element (or elements) whose contents or presence are controlled by the element on which this attribute is set.\n *\n * Value: A space-separated list of one or more ID values referencing the elements being controlled by the current element\n */\n ariaControls?: HTMLAttributes<HTMLElement>[\"aria-controls\"];\n /**\n * The global `aria-describedby` attribute identifies the element (or elements) that describes the element on which the attribute is set.\n *\n * Value: The id or space-separated list of element ids that describe the current element.\n *\n * Note: The `aria-describedby` attribute is not designed to reference descriptions from external resources. It must reference elements in the same DOM document.\n */\n ariaDescribedBy?: HTMLAttributes<HTMLElement>[\"aria-describedby\"];\n /**\n * The `aria-errormessage` attribute on an object identifies the element that provides an error message for that object.\n *\n * Value: The value of the id of the element containing the error message for the current element\n */\n ariaErrorMessage?: HTMLAttributes<HTMLElement>[\"aria-errormessage\"];\n /**\n * The `aria-expanded` attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not the controlled elements are displayed or hidden.\n */\n ariaExpanded?: HTMLAttributes<HTMLElement>[\"aria-expanded\"];\n /**\n * The `aria-haspopup` attribute indicates the availability and type of interactive popup element that can be triggered by the element on which the attribute is set.\n */\n ariaHasPopup?: HTMLAttributes<HTMLElement>[\"aria-haspopup\"];\n ariaHidden?: HTMLAttributes<HTMLElement>[\"aria-hidden\"];\n /**\n * The `aria-label` attribute defines a string value that labels an interactive element.\n */\n ariaLabel?: HTMLAttributes<HTMLElement>[\"aria-label\"];\n /**\n * The `aria-labelledby` attribute identifies the element (or elements) that labels the element it is applied to.\n *\n * Value: Space separated list of one or more ID values referencing the elements that label the current element.\n */\n ariaLabelledBy?: HTMLAttributes<HTMLElement>[\"aria-labelledby\"];\n /**\n * The `aria-pressed` attribute indicates the current \"pressed\" state of a toggle button.\n */\n ariaPressed?: HTMLAttributes<HTMLElement>[\"aria-pressed\"];\n /**\n * The `tabindex` global attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable\n *\n * Note: Manipulating the natural tab order is generally advised against\n */\n tabIndex?: HTMLAttributes<HTMLElement>[\"tabIndex\"];\n /**\n * This prop puts a `data` attribute on an HTML element in this component with the value provided.\n *\n * @deprecated **WARNING:** You should be using Semantic Selectors instead of this property. This is a temporary measure for backwards compatibility with existing Selenium tests.\n */\n testId?: string;\n /**\n * This prop puts a `translate` attribute on an HTML element. It should be used to indicate whether text within the element should be translated.\n */\n translate?: \"yes\" | \"no\";\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"HtmlProps.js","names":[],"sources":["../src/HtmlProps.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { HTMLAttributes } from \"react\";\n\nexport type HtmlProps = {\n /**\n * Used in [ARIA live regions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions), the global aria-busy state indicates an element is being modified and that assistive technologies may want to wait until the changes are complete before informing the user about the update.\n */\n ariaBusy?: HTMLAttributes<HTMLElement>[\"aria-busy\"];\n /**\n * The `aria-checked` attribute indicates the current \"checked\" state of checkboxes, radio buttons, and other widgets.\n *\n * NOTE: Where possible use an HTML `<input>` element with `type=\"checkbox\"` and `type=\"radio\"` as these have built in semantics and do not require ARIA attributes.\n */\n ariaChecked?: HTMLAttributes<HTMLElement>[\"aria-checked\"];\n /**\n * The global `aria-controls` property identifies the element (or elements) whose contents or presence are controlled by the element on which this attribute is set.\n *\n * Value: A space-separated list of one or more ID values referencing the elements being controlled by the current element\n */\n ariaControls?: HTMLAttributes<HTMLElement>[\"aria-controls\"];\n /**\n * A non-null aria-current state on an element indicates that this element represents the current item within a container or set of related elements.\n *\n * Value:\n * \n * `page`\n Represents the current page within a set of pages such as the link to the current document in a breadcrumb.\n\n `step`\n Represents the current step within a process such as the current step in an enumerated multi step checkout flow.\n\n `location`\n Represents the current location within an environment or context such as the image that is visually highlighted as the current component of a flow chart.\n\n `date`\n Represents the current date within a collection of dates such as the current date within a calendar.\n\n `time`\n Represents the current time within a set of times such as the current time within a timetable.\n\n `true`\n Represents the current item within a set.\n\n `false` (default)\n Does not represent the current item within a set.\n */\n ariaCurrent?: HTMLAttributes<HTMLElement>[\"aria-current\"];\n /**\n * The global `aria-describedby` attribute identifies the element (or elements) that describes the element on which the attribute is set.\n *\n * Value: The id or space-separated list of element ids that describe the current element.\n *\n * Note: The `aria-describedby` attribute is not designed to reference descriptions from external resources. It must reference elements in the same DOM document.\n */\n ariaDescribedBy?: HTMLAttributes<HTMLElement>[\"aria-describedby\"];\n /**\n * The `aria-errormessage` attribute on an object identifies the element that provides an error message for that object.\n *\n * Value: The value of the id of the element containing the error message for the current element\n */\n ariaErrorMessage?: HTMLAttributes<HTMLElement>[\"aria-errormessage\"];\n /**\n * The `aria-expanded` attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not the controlled elements are displayed or hidden.\n */\n ariaExpanded?: HTMLAttributes<HTMLElement>[\"aria-expanded\"];\n /**\n * The `aria-haspopup` attribute indicates the availability and type of interactive popup element that can be triggered by the element on which the attribute is set.\n */\n ariaHasPopup?: HTMLAttributes<HTMLElement>[\"aria-haspopup\"];\n ariaHidden?: HTMLAttributes<HTMLElement>[\"aria-hidden\"];\n /**\n * The `aria-label` attribute defines a string value that labels an interactive element.\n */\n ariaLabel?: HTMLAttributes<HTMLElement>[\"aria-label\"];\n /**\n * The `aria-labelledby` attribute identifies the element (or elements) that labels the element it is applied to.\n *\n * Value: Space separated list of one or more ID values referencing the elements that label the current element.\n */\n ariaLabelledBy?: HTMLAttributes<HTMLElement>[\"aria-labelledby\"];\n /**\n * The `aria-pressed` attribute indicates the current \"pressed\" state of a toggle button.\n */\n ariaPressed?: HTMLAttributes<HTMLElement>[\"aria-pressed\"];\n /**\n * The `tabindex` global attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable\n *\n * Note: Manipulating the natural tab order is generally advised against\n */\n tabIndex?: HTMLAttributes<HTMLElement>[\"tabIndex\"];\n /**\n * This prop puts a `data` attribute on an HTML element in this component with the value provided.\n *\n * @deprecated **WARNING:** You should be using Semantic Selectors instead of this property. This is a temporary measure for backwards compatibility with existing Selenium tests.\n */\n testId?: string;\n /**\n * This prop puts a `translate` attribute on an HTML element. It should be used to indicate whether text within the element should be translated.\n */\n translate?: \"yes\" | \"no\";\n};\n"],"mappings":""}
|
|
@@ -12,7 +12,7 @@ import _InputBase from "@mui/material/InputBase";
|
|
|
12
12
|
*/
|
|
13
13
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { Paragraph } from "../Typography.js";
|
|
15
|
-
import { Button } from "../
|
|
15
|
+
import { Button } from "../Buttons/index.js";
|
|
16
16
|
import { ArrowLeftIcon, ArrowRightIcon } from "../icons.generated/index.js";
|
|
17
17
|
import styled from "@emotion/styled";
|
|
18
18
|
import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext.js";
|
|
@@ -21,7 +21,7 @@ import { usePagination } from "./usePagination.js";
|
|
|
21
21
|
import { useTranslation } from "react-i18next";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
const PaginationContainer = styled("
|
|
24
|
+
const PaginationContainer = styled("nav")({
|
|
25
25
|
display: "flex",
|
|
26
26
|
alignItems: "center",
|
|
27
27
|
justifyContent: "space-between"
|
|
@@ -190,6 +190,7 @@ const Pagination = ({
|
|
|
190
190
|
max: maxPageIndex
|
|
191
191
|
}), [currentPageLabel, maxPageIndex]);
|
|
192
192
|
return variant === "paged" ? _jsxs(PaginationContainer, {
|
|
193
|
+
"aria-label": t("pagination.label"),
|
|
193
194
|
children: [_jsxs(PaginationSegment, {
|
|
194
195
|
odysseyDesignTokens: odysseyDesignTokens,
|
|
195
196
|
children: [hasRowCountInput && _jsxs(Box, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","Paragraph","Button","ArrowLeftIcon","ArrowRightIcon","styled","useOdysseyDesignTokens","Box","usePagination","useTranslation","jsx","_jsx","jsxs","_jsxs","PaginationContainer","display","alignItems","justifyContent","PaginationSegment","shouldForwardProp","prop","odysseyDesignTokens","gap","Spacing4","Spacing2","PaginationInput","_InputBase","borderColor","HueNeutral200","borderRadius","BorderRadiusTight","height","Spacing6","width","HueNeutral400","PalettePrimaryMain","PaginationButtonContainer","marginInlineStart","Pagination","currentPageLabel","currentPageLabelProp","currentRowsCount","hasPageInput","hasRowCountInput","hasRowCountLabel","isDisabled","isMoreDisabled","lastRow","loadMoreLabel","loadMoreLabelProp","maxPageIndex","maxPageSize","nextLabel","nextLabelProp","onPaginationChange","onPaginationChangeProp","pageIndex","pageSize","previousLabel","previousLabelProp","rowsPerPageLabel","rowsPerPageLabelProp","totalRows","variant","t","page","setPage","rowsPerPage","setRowsPerPage","initialRowsPerPage","totalRowsLabel","handlePaginationChange","updatedPage","updatedRowsPerPage","Math","ceil","handlePageSubmit","event","key","parseInt","currentTarget","value","handleRowsPerPageSubmit","setPageFromEvent","min","target","setRowsPerPageFromEvent","max","handleLoadMore","current","handleNextButton","handlePreviousButton","loadMoreIsDisabled","nextButtonDisabled","previousButtonDisabled","rowsPerPageInputProps","currentPageInputProps","children","component","color","type","onChange","onBlur","onKeyDown","disabled","inputProps","startIcon","size","ariaLabel","onClick","endIcon","label","MemoizedPagination","displayName"],"sources":["../../src/Pagination/Pagination.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { InputBase } from \"@mui/material\";\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Paragraph } from \"../Typography\";\nimport { Button } from \"../Button\";\nimport { ArrowLeftIcon, ArrowRightIcon } from \"../icons.generated\";\nimport styled from \"@emotion/styled\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { Box } from \"../Box\";\nimport { paginationTypeValues } from \"./constants\";\nimport { usePagination } from \"./usePagination\";\nimport { useTranslation } from \"react-i18next\";\n\nconst PaginationContainer = styled(\"div\")({\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n});\n\nconst PaginationSegment = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing4,\n \"& > div\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing2,\n },\n}));\n\nconst PaginationInput = styled(InputBase, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n borderColor: odysseyDesignTokens.HueNeutral200,\n borderRadius: odysseyDesignTokens.BorderRadiusTight,\n height: odysseyDesignTokens.Spacing6,\n width: \"4.5714285714rem\", // This is a hardcoded value, keep as string\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral400,\n },\n \"&.Mui-focused:hover\": {\n borderColor: odysseyDesignTokens.PalettePrimaryMain,\n },\n}));\n\nconst PaginationButtonContainer = styled(\"div\")({\n \"& > *\": {\n marginInlineStart: `0 !important`,\n },\n});\n\nexport type PaginationProps = {\n /**\n * The labeled rendered for the current page index\n */\n currentPageLabel?: string;\n /**\n * The number of items currently visible on the page\n */\n currentRowsCount?: number;\n /**\n * If true, the page input will be visible and the user can directly manipulate which page\n * is visible.\n */\n hasPageInput?: boolean;\n /**\n * If true, the row count input will be visible and the user can directly manipulate how many rows\n * are visible.\n */\n hasRowCountInput?: boolean;\n /**\n * If true, the \"X - X of total X\" label will be visible\n */\n hasRowCountLabel?: boolean;\n /**\n * If true, the pagination controls will be disabled\n */\n isDisabled?: boolean;\n /**\n * If true, the next or Show More button will be disabled\n */\n isMoreDisabled?: boolean;\n /**\n * The current page last row index\n */\n lastRow?: number;\n /**\n * If the pagination is of \"loadMore\" variant, then this is the the load more label\n */\n loadMoreLabel?: string;\n /**\n * The max page\n */\n maxPageIndex?: number;\n /**\n * The max rows per page\n */\n maxPageSize?: number;\n /**\n * The label for the next control\n */\n nextLabel?: string;\n /**\n * Page index and page size setter\n */\n onPaginationChange: ({\n pageIndex,\n pageSize,\n }: {\n pageIndex: number;\n pageSize: number;\n }) => void;\n /**\n * The current page index\n */\n pageIndex: number;\n /**\n * The current page size\n */\n pageSize: number;\n /**\n * The label for the previous control\n */\n previousLabel?: string;\n /**\n * The label that shows how many results are rendered per page\n */\n rowsPerPageLabel?: string;\n /**\n * Total rows count\n */\n totalRows?: number;\n /**\n * The type of pagination controls shown. Defaults to next/prev buttons, but can be\n * set to a simple \"Load more\" button by setting to \"loadMore\".\n */\n variant?: (typeof paginationTypeValues)[number];\n};\n\nconst Pagination = ({\n currentPageLabel: currentPageLabelProp,\n currentRowsCount,\n hasPageInput = true,\n hasRowCountInput = true,\n hasRowCountLabel = true,\n isDisabled,\n isMoreDisabled,\n lastRow,\n loadMoreLabel: loadMoreLabelProp,\n maxPageIndex,\n maxPageSize,\n nextLabel: nextLabelProp,\n onPaginationChange: onPaginationChangeProp,\n pageIndex,\n pageSize,\n previousLabel: previousLabelProp,\n rowsPerPageLabel: rowsPerPageLabelProp,\n totalRows,\n variant,\n}: PaginationProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const [page, setPage] = useState<number>(pageIndex);\n const [rowsPerPage, setRowsPerPage] = useState<number>(pageSize);\n const initialRowsPerPage = useRef<number>(pageSize);\n\n const currentPageLabel = currentPageLabelProp ?? t(\"pagination.page\");\n const loadMoreLabel = loadMoreLabelProp ?? t(\"pagination.loadmore\");\n const nextLabel = nextLabelProp ?? t(\"pagination.next\");\n const previousLabel = previousLabelProp ?? t(\"pagination.previous\");\n const rowsPerPageLabel = rowsPerPageLabelProp ?? t(\"pagination.rowsperpage\");\n\n useEffect(() => {\n setPage(pageIndex);\n setRowsPerPage(pageSize);\n }, [pageIndex, pageSize]);\n\n const onPaginationChange = useCallback(\n ({ pageIndex, pageSize }: { pageIndex: number; pageSize: number }) => {\n onPaginationChangeProp({ pageIndex, pageSize });\n },\n [onPaginationChangeProp],\n );\n\n const { totalRowsLabel } = usePagination({\n pageIndex,\n pageSize,\n currentRowsCount: currentRowsCount || pageSize,\n totalRows,\n });\n\n const handlePaginationChange = useCallback(() => {\n let updatedPage = page;\n let updatedRowsPerPage = rowsPerPage;\n\n if (totalRows) {\n const maxPageIndex = Math.ceil(totalRows / updatedRowsPerPage);\n\n // Ensure rowsPerPage does not exceed totalRows\n if (updatedRowsPerPage > totalRows) {\n updatedRowsPerPage = totalRows;\n }\n\n // Ensure page is within valid range\n if (updatedPage > maxPageIndex) {\n updatedPage = maxPageIndex;\n } else if (updatedPage < 1) {\n updatedPage = 1;\n }\n }\n\n onPaginationChange({\n pageIndex: updatedPage,\n pageSize: updatedRowsPerPage,\n });\n }, [page, rowsPerPage, onPaginationChange, totalRows]);\n\n // The following handlers use React.KeyboardEvent (rather than just KeyboardEvent) becuase React.KeyboardEvent\n // is generic, while plain KeyboardEvent is not. We need this generic so we can specify the HTMLInputElement,\n // which allows us to use currentTarget.value\n const handlePageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: parseInt(event.currentTarget.value),\n pageSize: rowsPerPage,\n });\n }\n },\n [rowsPerPage, onPaginationChange],\n );\n\n const handleRowsPerPageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: page,\n pageSize: parseInt(event.currentTarget.value),\n });\n }\n },\n [page, onPaginationChange],\n );\n\n const setPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageIndex\n ? Math.min(parseInt(event.target.value), maxPageIndex)\n : parseInt(event.target.value);\n setPage(value);\n },\n [setPage, maxPageIndex],\n );\n\n const setRowsPerPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageSize\n ? Math.min(parseInt(event.target.value), maxPageSize)\n : parseInt(event.target.value);\n\n // Ensure the value can't be less than 1\n setRowsPerPage(Math.max(1, value));\n },\n [setRowsPerPage, maxPageSize],\n );\n\n const handleLoadMore = useCallback(() => {\n onPaginationChange({\n pageIndex: 1,\n pageSize: rowsPerPage + initialRowsPerPage.current,\n });\n }, [rowsPerPage, onPaginationChange]);\n\n const handleNextButton = useCallback(() => {\n onPaginationChange({ pageIndex: page + 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const handlePreviousButton = useCallback(() => {\n onPaginationChange({ pageIndex: page - 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const loadMoreIsDisabled = useMemo(() => {\n return isMoreDisabled || (totalRows ? rowsPerPage >= totalRows : false);\n }, [isMoreDisabled, rowsPerPage, totalRows]);\n\n const nextButtonDisabled = useMemo(\n () =>\n isMoreDisabled ||\n (lastRow && (totalRows ? lastRow >= totalRows : false)) ||\n isDisabled,\n [isMoreDisabled, totalRows, lastRow, isDisabled],\n );\n\n const previousButtonDisabled = useMemo(\n () => pageIndex <= 1 || isDisabled,\n [pageIndex, isDisabled],\n );\n\n const rowsPerPageInputProps = useMemo(\n () => ({\n \"aria-label\": rowsPerPageLabel,\n max: maxPageSize || totalRows,\n }),\n [maxPageSize, rowsPerPageLabel, totalRows],\n );\n\n const currentPageInputProps = useMemo(\n () => ({\n \"aria-label\": currentPageLabel,\n max: maxPageIndex,\n }),\n [currentPageLabel, maxPageIndex],\n );\n\n return variant === \"paged\" ? (\n <PaginationContainer>\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {hasRowCountInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {rowsPerPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={rowsPerPage}\n onChange={setRowsPerPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handleRowsPerPageSubmit}\n disabled={isDisabled}\n inputProps={rowsPerPageInputProps}\n />\n </Box>\n )}\n {hasRowCountLabel && (\n <Paragraph component=\"span\" color=\"textSecondary\">\n {totalRowsLabel}\n </Paragraph>\n )}\n </PaginationSegment>\n\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {totalRows && hasPageInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {currentPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={page}\n onChange={setPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handlePageSubmit}\n disabled={isDisabled}\n inputProps={currentPageInputProps}\n />\n </Box>\n )}\n <PaginationButtonContainer>\n <Button\n startIcon={<ArrowLeftIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={previousLabel}\n onClick={handlePreviousButton}\n isDisabled={previousButtonDisabled}\n />\n <Button\n endIcon={<ArrowRightIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={nextLabel}\n onClick={handleNextButton}\n isDisabled={nextButtonDisabled}\n />\n </PaginationButtonContainer>\n </PaginationSegment>\n </PaginationContainer>\n ) : (\n <Button\n variant=\"secondary\"\n label={loadMoreLabel}\n onClick={handleLoadMore}\n isDisabled={loadMoreIsDisabled}\n />\n );\n};\n\nconst MemoizedPagination = memo(Pagination);\nMemoizedPagination.displayName = \"Pagination\";\n\nexport { MemoizedPagination as Pagination };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SACvEC,SAAS;AAAA,SACTC,MAAM;AAAA,SACNC,aAAa,EAAEC,cAAc;AACtC,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAGnCC,sBAAsB;AAAA,SAEfC,GAAG;AAAA,SAEHC,aAAa;AACtB,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE/C,MAAMC,mBAAmB,GAAGT,MAAM,CAAC,KAAK,CAAC,CAAC;EACxCU,OAAO,EAAE,MAAM;EACfC,UAAU,EAAE,QAAQ;EACpBC,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAGb,MAAM,CAAC,KAAK,EAAE;EACtCc,iBAAiB,EAAGC,IA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ACT,MAAM;UACLwG,SAAS,EAAE/F,IAAA,CAACR,aAAa,IAAE,CAAE;UAC7B4D,OAAO,EAAC,UAAU;UAClB4C,IAAI,EAAC,OAAO;UACZC,SAAS,EAAElD,aAAc;UACzBmD,OAAO,EAAElB,oBAAqB;UAC9B9C,UAAU,EAAEiD;QAAuB,CACpC,CAAC,EACFnF,IAAA,CAACT,MAAM;UACL4G,OAAO,EAAEnG,IAAA,CAACP,cAAc,IAAE,CAAE;UAC5B2D,OAAO,EAAC,UAAU;UAClB4C,IAAI,EAAC,OAAO;UACZC,SAAS,EAAExD,SAAU;UACrByD,OAAO,EAAEnB,gBAAiB;UAC1B7C,UAAU,EAAEgD;QAAmB,CAChC,CAAC;MAAA,CACuB,CAAC;IAAA,CACX,CAAC;EAAA,CACD,CAAC,GAEtBlF,IAAA,CAACT,MAAM;IACL6D,OAAO,EAAC,WAAW;IACnBgD,KAAK,EAAE/D,aAAc;IACrB6D,OAAO,EAAErB,cAAe;IACxB3C,UAAU,EAAE+C;EAAmB,CAChC,CACF;AACH,CAAC;AAED,MAAMoB,kBAAkB,GAAGrH,IAAI,CAAC2C,UAAU,CAAC;AAC3C0E,kBAAkB,CAACC,WAAW,GAAG,YAAY;AAE7C,SAASD,kBAAkB,IAAI1E,UAAU"}
|
|
1
|
+
{"version":3,"file":"Pagination.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","Paragraph","Button","ArrowLeftIcon","ArrowRightIcon","styled","useOdysseyDesignTokens","Box","usePagination","useTranslation","jsx","_jsx","jsxs","_jsxs","PaginationContainer","display","alignItems","justifyContent","PaginationSegment","shouldForwardProp","prop","odysseyDesignTokens","gap","Spacing4","Spacing2","PaginationInput","_InputBase","borderColor","HueNeutral200","borderRadius","BorderRadiusTight","height","Spacing6","width","HueNeutral400","PalettePrimaryMain","PaginationButtonContainer","marginInlineStart","Pagination","currentPageLabel","currentPageLabelProp","currentRowsCount","hasPageInput","hasRowCountInput","hasRowCountLabel","isDisabled","isMoreDisabled","lastRow","loadMoreLabel","loadMoreLabelProp","maxPageIndex","maxPageSize","nextLabel","nextLabelProp","onPaginationChange","onPaginationChangeProp","pageIndex","pageSize","previousLabel","previousLabelProp","rowsPerPageLabel","rowsPerPageLabelProp","totalRows","variant","t","page","setPage","rowsPerPage","setRowsPerPage","initialRowsPerPage","totalRowsLabel","handlePaginationChange","updatedPage","updatedRowsPerPage","Math","ceil","handlePageSubmit","event","key","parseInt","currentTarget","value","handleRowsPerPageSubmit","setPageFromEvent","min","target","setRowsPerPageFromEvent","max","handleLoadMore","current","handleNextButton","handlePreviousButton","loadMoreIsDisabled","nextButtonDisabled","previousButtonDisabled","rowsPerPageInputProps","currentPageInputProps","children","component","color","type","onChange","onBlur","onKeyDown","disabled","inputProps","startIcon","size","ariaLabel","onClick","endIcon","label","MemoizedPagination","displayName"],"sources":["../../src/Pagination/Pagination.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 { InputBase } from \"@mui/material\";\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Paragraph } from \"../Typography\";\nimport { Button } from \"../Buttons\";\nimport { ArrowLeftIcon, ArrowRightIcon } from \"../icons.generated\";\nimport styled from \"@emotion/styled\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { Box } from \"../Box\";\nimport { paginationTypeValues } from \"./constants\";\nimport { usePagination } from \"./usePagination\";\nimport { useTranslation } from \"react-i18next\";\n\nconst PaginationContainer = styled(\"nav\")({\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n});\n\nconst PaginationSegment = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing4,\n \"& > div\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing2,\n },\n}));\n\nconst PaginationInput = styled(InputBase, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n borderColor: odysseyDesignTokens.HueNeutral200,\n borderRadius: odysseyDesignTokens.BorderRadiusTight,\n height: odysseyDesignTokens.Spacing6,\n width: \"4.5714285714rem\", // This is a hardcoded value, keep as string\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral400,\n },\n \"&.Mui-focused:hover\": {\n borderColor: odysseyDesignTokens.PalettePrimaryMain,\n },\n}));\n\nconst PaginationButtonContainer = styled(\"div\")({\n \"& > *\": {\n marginInlineStart: `0 !important`,\n },\n});\n\nexport type PaginationProps = {\n /**\n * The labeled rendered for the current page index\n */\n currentPageLabel?: string;\n /**\n * The number of items currently visible on the page\n */\n currentRowsCount?: number;\n /**\n * If true, the page input will be visible and the user can directly manipulate which page\n * is visible.\n */\n hasPageInput?: boolean;\n /**\n * If true, the row count input will be visible and the user can directly manipulate how many rows\n * are visible.\n */\n hasRowCountInput?: boolean;\n /**\n * If true, the \"X - X of total X\" label will be visible\n */\n hasRowCountLabel?: boolean;\n /**\n * If true, the pagination controls will be disabled\n */\n isDisabled?: boolean;\n /**\n * If true, the next or Show More button will be disabled\n */\n isMoreDisabled?: boolean;\n /**\n * The current page last row index\n */\n lastRow?: number;\n /**\n * If the pagination is of \"loadMore\" variant, then this is the the load more label\n */\n loadMoreLabel?: string;\n /**\n * The max page\n */\n maxPageIndex?: number;\n /**\n * The max rows per page\n */\n maxPageSize?: number;\n /**\n * The label for the next control\n */\n nextLabel?: string;\n /**\n * Page index and page size setter\n */\n onPaginationChange: ({\n pageIndex,\n pageSize,\n }: {\n pageIndex: number;\n pageSize: number;\n }) => void;\n /**\n * The current page index\n */\n pageIndex: number;\n /**\n * The current page size\n */\n pageSize: number;\n /**\n * The label for the previous control\n */\n previousLabel?: string;\n /**\n * The label that shows how many results are rendered per page\n */\n rowsPerPageLabel?: string;\n /**\n * Total rows count\n */\n totalRows?: number;\n /**\n * The type of pagination controls shown. Defaults to next/prev buttons, but can be\n * set to a simple \"Load more\" button by setting to \"loadMore\".\n */\n variant?: (typeof paginationTypeValues)[number];\n};\n\nconst Pagination = ({\n currentPageLabel: currentPageLabelProp,\n currentRowsCount,\n hasPageInput = true,\n hasRowCountInput = true,\n hasRowCountLabel = true,\n isDisabled,\n isMoreDisabled,\n lastRow,\n loadMoreLabel: loadMoreLabelProp,\n maxPageIndex,\n maxPageSize,\n nextLabel: nextLabelProp,\n onPaginationChange: onPaginationChangeProp,\n pageIndex,\n pageSize,\n previousLabel: previousLabelProp,\n rowsPerPageLabel: rowsPerPageLabelProp,\n totalRows,\n variant,\n}: PaginationProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const [page, setPage] = useState<number>(pageIndex);\n const [rowsPerPage, setRowsPerPage] = useState<number>(pageSize);\n const initialRowsPerPage = useRef<number>(pageSize);\n\n const currentPageLabel = currentPageLabelProp ?? t(\"pagination.page\");\n const loadMoreLabel = loadMoreLabelProp ?? t(\"pagination.loadmore\");\n const nextLabel = nextLabelProp ?? t(\"pagination.next\");\n const previousLabel = previousLabelProp ?? t(\"pagination.previous\");\n const rowsPerPageLabel = rowsPerPageLabelProp ?? t(\"pagination.rowsperpage\");\n\n useEffect(() => {\n setPage(pageIndex);\n setRowsPerPage(pageSize);\n }, [pageIndex, pageSize]);\n\n const onPaginationChange = useCallback(\n ({ pageIndex, pageSize }: { pageIndex: number; pageSize: number }) => {\n onPaginationChangeProp({ pageIndex, pageSize });\n },\n [onPaginationChangeProp],\n );\n\n const { totalRowsLabel } = usePagination({\n pageIndex,\n pageSize,\n currentRowsCount: currentRowsCount || pageSize,\n totalRows,\n });\n\n const handlePaginationChange = useCallback(() => {\n let updatedPage = page;\n let updatedRowsPerPage = rowsPerPage;\n\n if (totalRows) {\n const maxPageIndex = Math.ceil(totalRows / updatedRowsPerPage);\n\n // Ensure rowsPerPage does not exceed totalRows\n if (updatedRowsPerPage > totalRows) {\n updatedRowsPerPage = totalRows;\n }\n\n // Ensure page is within valid range\n if (updatedPage > maxPageIndex) {\n updatedPage = maxPageIndex;\n } else if (updatedPage < 1) {\n updatedPage = 1;\n }\n }\n\n onPaginationChange({\n pageIndex: updatedPage,\n pageSize: updatedRowsPerPage,\n });\n }, [page, rowsPerPage, onPaginationChange, totalRows]);\n\n // The following handlers use React.KeyboardEvent (rather than just KeyboardEvent) becuase React.KeyboardEvent\n // is generic, while plain KeyboardEvent is not. We need this generic so we can specify the HTMLInputElement,\n // which allows us to use currentTarget.value\n const handlePageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: parseInt(event.currentTarget.value),\n pageSize: rowsPerPage,\n });\n }\n },\n [rowsPerPage, onPaginationChange],\n );\n\n const handleRowsPerPageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: page,\n pageSize: parseInt(event.currentTarget.value),\n });\n }\n },\n [page, onPaginationChange],\n );\n\n const setPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageIndex\n ? Math.min(parseInt(event.target.value), maxPageIndex)\n : parseInt(event.target.value);\n setPage(value);\n },\n [setPage, maxPageIndex],\n );\n\n const setRowsPerPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageSize\n ? Math.min(parseInt(event.target.value), maxPageSize)\n : parseInt(event.target.value);\n\n // Ensure the value can't be less than 1\n setRowsPerPage(Math.max(1, value));\n },\n [setRowsPerPage, maxPageSize],\n );\n\n const handleLoadMore = useCallback(() => {\n onPaginationChange({\n pageIndex: 1,\n pageSize: rowsPerPage + initialRowsPerPage.current,\n });\n }, [rowsPerPage, onPaginationChange]);\n\n const handleNextButton = useCallback(() => {\n onPaginationChange({ pageIndex: page + 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const handlePreviousButton = useCallback(() => {\n onPaginationChange({ pageIndex: page - 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const loadMoreIsDisabled = useMemo(() => {\n return isMoreDisabled || (totalRows ? rowsPerPage >= totalRows : false);\n }, [isMoreDisabled, rowsPerPage, totalRows]);\n\n const nextButtonDisabled = useMemo(\n () =>\n isMoreDisabled ||\n (lastRow && (totalRows ? lastRow >= totalRows : false)) ||\n isDisabled,\n [isMoreDisabled, totalRows, lastRow, isDisabled],\n );\n\n const previousButtonDisabled = useMemo(\n () => pageIndex <= 1 || isDisabled,\n [pageIndex, isDisabled],\n );\n\n const rowsPerPageInputProps = useMemo(\n () => ({\n \"aria-label\": rowsPerPageLabel,\n max: maxPageSize || totalRows,\n }),\n [maxPageSize, rowsPerPageLabel, totalRows],\n );\n\n const currentPageInputProps = useMemo(\n () => ({\n \"aria-label\": currentPageLabel,\n max: maxPageIndex,\n }),\n [currentPageLabel, maxPageIndex],\n );\n\n return variant === \"paged\" ? (\n <PaginationContainer aria-label={t(\"pagination.label\")}>\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {hasRowCountInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {rowsPerPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={rowsPerPage}\n onChange={setRowsPerPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handleRowsPerPageSubmit}\n disabled={isDisabled}\n inputProps={rowsPerPageInputProps}\n />\n </Box>\n )}\n {hasRowCountLabel && (\n <Paragraph component=\"span\" color=\"textSecondary\">\n {totalRowsLabel}\n </Paragraph>\n )}\n </PaginationSegment>\n\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {totalRows && hasPageInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {currentPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={page}\n onChange={setPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handlePageSubmit}\n disabled={isDisabled}\n inputProps={currentPageInputProps}\n />\n </Box>\n )}\n <PaginationButtonContainer>\n <Button\n startIcon={<ArrowLeftIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={previousLabel}\n onClick={handlePreviousButton}\n isDisabled={previousButtonDisabled}\n />\n <Button\n endIcon={<ArrowRightIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={nextLabel}\n onClick={handleNextButton}\n isDisabled={nextButtonDisabled}\n />\n </PaginationButtonContainer>\n </PaginationSegment>\n </PaginationContainer>\n ) : (\n <Button\n variant=\"secondary\"\n label={loadMoreLabel}\n onClick={handleLoadMore}\n isDisabled={loadMoreIsDisabled}\n />\n );\n};\n\nconst MemoizedPagination = memo(Pagination);\nMemoizedPagination.displayName = \"Pagination\";\n\nexport { MemoizedPagination as Pagination };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SACvEC,SAAS;AAAA,SACTC,MAAM;AAAA,SACNC,aAAa,EAAEC,cAAc;AACtC,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAGnCC,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