@okta/odyssey-react-mui 1.32.0 → 1.32.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/theme/components.cjs +6 -0
- package/dist/cjs/theme/components.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNav.cjs +2 -1
- package/dist/cjs/ui-shell/SideNav/SideNav.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavItemContent.cjs +36 -11
- package/dist/cjs/ui-shell/SideNav/SideNavItemContent.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavItemLinkContent.cjs +3 -1
- package/dist/cjs/ui-shell/SideNav/SideNavItemLinkContent.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavLogo.cjs +14 -2
- package/dist/cjs/ui-shell/SideNav/SideNavLogo.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/types.cjs.map +1 -1
- package/dist/cjs/ui-shell/UiShellContent.cjs +48 -32
- package/dist/cjs/ui-shell/UiShellContent.cjs.map +1 -1
- package/dist/cjs/ui-shell/index.cjs +9 -1
- package/dist/cjs/ui-shell/index.cjs.map +1 -1
- package/dist/cjs/useContrastMode.cjs +1 -1
- package/dist/cjs/useContrastMode.cjs.map +1 -1
- package/dist/esm/theme/components.js +6 -0
- package/dist/esm/theme/components.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNav.js +2 -1
- package/dist/esm/ui-shell/SideNav/SideNav.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavItemContent.js +37 -12
- package/dist/esm/ui-shell/SideNav/SideNavItemContent.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavItemLinkContent.js +3 -1
- package/dist/esm/ui-shell/SideNav/SideNavItemLinkContent.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavLogo.js +14 -2
- package/dist/esm/ui-shell/SideNav/SideNavLogo.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/types.js.map +1 -1
- package/dist/esm/ui-shell/UiShellContent.js +45 -31
- package/dist/esm/ui-shell/UiShellContent.js.map +1 -1
- package/dist/esm/ui-shell/index.js +1 -0
- package/dist/esm/ui-shell/index.js.map +1 -1
- package/dist/esm/useContrastMode.js +2 -2
- package/dist/esm/useContrastMode.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.scss +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/types/theme/components.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNav.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavItemContent.d.ts +9 -7
- package/dist/types/ui-shell/SideNav/SideNavItemContent.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavItemLinkContent.d.ts +1 -1
- package/dist/types/ui-shell/SideNav/SideNavItemLinkContent.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavLogo.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/types.d.ts +5 -1
- package/dist/types/ui-shell/SideNav/types.d.ts.map +1 -1
- package/dist/types/ui-shell/UiShellContent.d.ts +8 -2
- package/dist/types/ui-shell/UiShellContent.d.ts.map +1 -1
- package/dist/types/ui-shell/index.d.ts +1 -1
- package/dist/types/ui-shell/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/.browserslistrc +0 -1
- package/.svgrrc.cjs +0 -13
- package/CHANGELOG.md +0 -1490
- package/babel.config.cjs +0 -112
- package/i18n.config.json +0 -10
- package/scripts/generateIconsIndex.ts +0 -49
- package/scripts/generateTestSelectorsJson.ts +0 -33
- package/scripts/properties-to-ts.ts +0 -111
- package/src/@types/i18next.d.ts +0 -24
- package/src/@types/properties.d.ts +0 -292
- package/src/@types/react-augment.d.ts +0 -22
- package/src/Accordion.tsx +0 -117
- package/src/Autocomplete.tsx +0 -321
- package/src/Badge.tsx +0 -112
- package/src/Banner.tsx +0 -112
- package/src/Box.tsx +0 -44
- package/src/Breadcrumbs.tsx +0 -221
- package/src/Buttons/BaseButton.tsx +0 -250
- package/src/Buttons/BaseMenuButton.tsx +0 -342
- package/src/Buttons/Button.tsx +0 -30
- package/src/Buttons/ButtonContext.tsx +0 -23
- package/src/Buttons/MenuButton.tsx +0 -33
- package/src/Buttons/MenuContext.ts +0 -25
- package/src/Buttons/MenuItem.tsx +0 -103
- package/src/Buttons/index.ts +0 -25
- package/src/Callout.tsx +0 -176
- package/src/Card.tsx +0 -186
- package/src/Checkbox.tsx +0 -261
- package/src/CheckboxGroup.tsx +0 -127
- package/src/CircularProgress.tsx +0 -42
- package/src/CssBaseline.tsx +0 -20
- package/src/DataTable/DataTable.tsx +0 -968
- package/src/DataTable/DataTableRowActions.tsx +0 -132
- package/src/DataTable/DataTableSettings.tsx +0 -136
- package/src/DataTable/constants.ts +0 -13
- package/src/DataTable/index.tsx +0 -28
- package/src/DataTable/reorderDataRowsLocally.tsx +0 -48
- package/src/DataTable/useRowReordering.tsx +0 -232
- package/src/DataTable/useScrollIndication.tsx +0 -125
- package/src/DatePickers/DateField.tsx +0 -267
- package/src/DatePickers/DateFieldActionBar.tsx +0 -65
- package/src/DatePickers/DateFieldLocalizationProvider.tsx +0 -46
- package/src/DatePickers/DatePicker.test.tsx +0 -66
- package/src/DatePickers/DatePicker.tsx +0 -299
- package/src/DatePickers/DatePicker.types.d.ts +0 -14
- package/src/DatePickers/TimeZonePicker.tsx +0 -59
- package/src/DatePickers/datePickerTheme.tsx +0 -377
- package/src/DatePickers/index.ts +0 -15
- package/src/DatePickers/useDateFieldsTranslations.ts +0 -94
- package/src/DatePickers/useOdysseyDateFields.ts +0 -303
- package/src/Dialog.tsx +0 -178
- package/src/Drawer.tsx +0 -255
- package/src/EmptyState.tsx +0 -79
- package/src/ErrorMessageList.tsx +0 -56
- package/src/Field.tsx +0 -189
- package/src/FieldComponentProps.ts +0 -66
- package/src/FieldError.tsx +0 -59
- package/src/FieldHint.tsx +0 -72
- package/src/FieldLabel.tsx +0 -67
- package/src/Fieldset.tsx +0 -116
- package/src/FieldsetContext.tsx +0 -23
- package/src/FileUploader/FileUploadIllustration.tsx +0 -66
- package/src/FileUploader/FileUploadPreview.tsx +0 -151
- package/src/FileUploader/FileUploader.tsx +0 -311
- package/src/FileUploader/index.ts +0 -13
- package/src/Form.tsx +0 -185
- package/src/FormCheckedProps.ts +0 -59
- package/src/HintLink.tsx +0 -28
- package/src/HtmlProps.ts +0 -112
- package/src/IconWithTooltip.tsx +0 -90
- package/src/Link.tsx +0 -115
- package/src/MuiPropsChild.tsx +0 -42
- package/src/MuiPropsContext.ts +0 -18
- package/src/NativeSelect.tsx +0 -249
- package/src/NullElement.tsx +0 -13
- package/src/OdysseyCacheProvider.test.tsx +0 -39
- package/src/OdysseyCacheProvider.tsx +0 -86
- package/src/OdysseyDesignTokensContext.tsx +0 -23
- package/src/OdysseyProvider.tsx +0 -92
- package/src/OdysseyThemeProvider.test.tsx +0 -211
- package/src/OdysseyThemeProvider.tsx +0 -109
- package/src/OdysseyTranslationProvider.test.tsx +0 -95
- package/src/OdysseyTranslationProvider.tsx +0 -77
- package/src/OdysseyTranslationProvider.types.ts +0 -47
- package/src/Pagination/Pagination.test.tsx +0 -327
- package/src/Pagination/Pagination.tsx +0 -417
- package/src/Pagination/constants.ts +0 -13
- package/src/Pagination/index.ts +0 -15
- package/src/Pagination/usePagination.ts +0 -45
- package/src/PasswordField.tsx +0 -253
- package/src/Radio.tsx +0 -199
- package/src/RadioGroup.tsx +0 -164
- package/src/ScreenReaderText.tsx +0 -53
- package/src/SearchField.tsx +0 -240
- package/src/Select.tsx +0 -576
- package/src/Stack.tsx +0 -56
- package/src/Status.tsx +0 -67
- package/src/Surface.tsx +0 -61
- package/src/SvgIcon.ts +0 -22
- package/src/Switch.tsx +0 -425
- package/src/Tabs.tsx +0 -259
- package/src/Tag.tsx +0 -317
- package/src/TagList.tsx +0 -55
- package/src/TagListContext.tsx +0 -23
- package/src/TextField.tsx +0 -298
- package/src/Toast.tsx +0 -151
- package/src/ToastStack.tsx +0 -43
- package/src/Tooltip.tsx +0 -61
- package/src/Typography.test.tsx +0 -26
- package/src/Typography.tsx +0 -474
- package/src/createContrastColors.ts +0 -112
- package/src/createUniqueAlphabeticalId.test.ts +0 -22
- package/src/createUniqueAlphabeticalId.ts +0 -17
- package/src/createUniqueId.test.ts +0 -22
- package/src/createUniqueId.ts +0 -17
- package/src/getTypedObjectKeys.ts +0 -15
- package/src/hexToRgb.ts +0 -40
- package/src/i18n.ts +0 -110
- package/src/icons.generated/Add.tsx +0 -44
- package/src/icons.generated/AddCircle.tsx +0 -46
- package/src/icons.generated/Apps.tsx +0 -44
- package/src/icons.generated/ArrowBottom.tsx +0 -46
- package/src/icons.generated/ArrowDown.tsx +0 -46
- package/src/icons.generated/ArrowLeft.tsx +0 -46
- package/src/icons.generated/ArrowLowerLeft.tsx +0 -46
- package/src/icons.generated/ArrowLowerRight.tsx +0 -46
- package/src/icons.generated/ArrowRight.tsx +0 -46
- package/src/icons.generated/ArrowTop.tsx +0 -46
- package/src/icons.generated/ArrowUnsorted.tsx +0 -46
- package/src/icons.generated/ArrowUp.tsx +0 -46
- package/src/icons.generated/ArrowUpperLeft.tsx +0 -46
- package/src/icons.generated/ArrowUpperRight.tsx +0 -46
- package/src/icons.generated/Bug.tsx +0 -44
- package/src/icons.generated/Calendar.tsx +0 -46
- package/src/icons.generated/Call.tsx +0 -44
- package/src/icons.generated/Chat.tsx +0 -44
- package/src/icons.generated/Check.tsx +0 -44
- package/src/icons.generated/CheckCircleFilled.tsx +0 -47
- package/src/icons.generated/ChevronDown.tsx +0 -46
- package/src/icons.generated/ChevronLeft.tsx +0 -46
- package/src/icons.generated/ChevronRight.tsx +0 -46
- package/src/icons.generated/ChevronUp.tsx +0 -46
- package/src/icons.generated/Clock.tsx +0 -44
- package/src/icons.generated/Close.tsx +0 -44
- package/src/icons.generated/CloseCircleFilled.tsx +0 -47
- package/src/icons.generated/CollapseLeft.tsx +0 -46
- package/src/icons.generated/CollapseRight.tsx +0 -46
- package/src/icons.generated/Copy.tsx +0 -44
- package/src/icons.generated/Custom.tsx +0 -50
- package/src/icons.generated/DangerDiamond.tsx +0 -46
- package/src/icons.generated/DangerDiamondFilled.tsx +0 -47
- package/src/icons.generated/Delete.tsx +0 -44
- package/src/icons.generated/Deny.tsx +0 -44
- package/src/icons.generated/Devices.tsx +0 -46
- package/src/icons.generated/Directory.tsx +0 -46
- package/src/icons.generated/Documentation.tsx +0 -46
- package/src/icons.generated/Download.tsx +0 -46
- package/src/icons.generated/DragIndicator.tsx +0 -46
- package/src/icons.generated/Duo.tsx +0 -62
- package/src/icons.generated/Edit.tsx +0 -44
- package/src/icons.generated/Email.tsx +0 -49
- package/src/icons.generated/ExpandLeft.tsx +0 -46
- package/src/icons.generated/ExpandRight.tsx +0 -46
- package/src/icons.generated/ExternalLink.tsx +0 -44
- package/src/icons.generated/Fido2.tsx +0 -72
- package/src/icons.generated/Filter.tsx +0 -44
- package/src/icons.generated/Folder.tsx +0 -44
- package/src/icons.generated/Globe.tsx +0 -44
- package/src/icons.generated/GoogleAuth.tsx +0 -70
- package/src/icons.generated/Grid.tsx +0 -47
- package/src/icons.generated/Group.tsx +0 -44
- package/src/icons.generated/Hide.tsx +0 -44
- package/src/icons.generated/Home.tsx +0 -44
- package/src/icons.generated/Idp.tsx +0 -54
- package/src/icons.generated/InformationCircle.tsx +0 -47
- package/src/icons.generated/InformationCircleFilled.tsx +0 -47
- package/src/icons.generated/Link.tsx +0 -44
- package/src/icons.generated/List.tsx +0 -44
- package/src/icons.generated/Lock.tsx +0 -44
- package/src/icons.generated/More.tsx +0 -44
- package/src/icons.generated/Notification.tsx +0 -46
- package/src/icons.generated/OktaVerify.tsx +0 -46
- package/src/icons.generated/OnPremMfa.tsx +0 -52
- package/src/icons.generated/OneTimePassword.tsx +0 -65
- package/src/icons.generated/Password.tsx +0 -80
- package/src/icons.generated/Pause.tsx +0 -44
- package/src/icons.generated/QuestionCircle.tsx +0 -46
- package/src/icons.generated/QuestionCircleFilled.tsx +0 -47
- package/src/icons.generated/Refresh.tsx +0 -46
- package/src/icons.generated/Reset.tsx +0 -44
- package/src/icons.generated/Resume.tsx +0 -44
- package/src/icons.generated/Search.tsx +0 -44
- package/src/icons.generated/SecurityQuestion.tsx +0 -51
- package/src/icons.generated/Server.tsx +0 -44
- package/src/icons.generated/Settings.tsx +0 -46
- package/src/icons.generated/Show.tsx +0 -44
- package/src/icons.generated/SmartCard.tsx +0 -65
- package/src/icons.generated/Sms.tsx +0 -55
- package/src/icons.generated/Subtract.tsx +0 -46
- package/src/icons.generated/SymantecVip.tsx +0 -52
- package/src/icons.generated/Sync.tsx +0 -44
- package/src/icons.generated/ThumbsDown.tsx +0 -46
- package/src/icons.generated/ThumbsUp.tsx +0 -46
- package/src/icons.generated/Unlock.tsx +0 -44
- package/src/icons.generated/Upload.tsx +0 -44
- package/src/icons.generated/User.tsx +0 -44
- package/src/icons.generated/Video.tsx +0 -44
- package/src/icons.generated/VoiceCall.tsx +0 -62
- package/src/icons.generated/Warning.tsx +0 -46
- package/src/icons.generated/WarningFilled.tsx +0 -46
- package/src/icons.generated/Yubikey.tsx +0 -44
- package/src/icons.generated/index.ts +0 -107
- package/src/index.ts +0 -118
- package/src/inputUtils.ts +0 -80
- package/src/labs/AppTile.tsx +0 -421
- package/src/labs/DataFilters.tsx +0 -871
- package/src/labs/DataTable.tsx +0 -877
- package/src/labs/DataTablePagination.tsx +0 -88
- package/src/labs/DataView/BulkActionsMenu.tsx +0 -98
- package/src/labs/DataView/CardLayoutContent.tsx +0 -272
- package/src/labs/DataView/DataCard.tsx +0 -357
- package/src/labs/DataView/DataTable.tsx +0 -128
- package/src/labs/DataView/DataView.test.tsx +0 -1168
- package/src/labs/DataView/DataView.tsx +0 -504
- package/src/labs/DataView/DetailPanel.tsx +0 -31
- package/src/labs/DataView/LayoutSwitcher.tsx +0 -72
- package/src/labs/DataView/RowActions.tsx +0 -125
- package/src/labs/DataView/TableLayoutContent.tsx +0 -500
- package/src/labs/DataView/TableSettings.tsx +0 -144
- package/src/labs/DataView/componentTypes.ts +0 -129
- package/src/labs/DataView/constants.tsx +0 -28
- package/src/labs/DataView/dataTypes.ts +0 -83
- package/src/labs/DataView/fetchData.ts +0 -49
- package/src/labs/DataView/index.ts +0 -19
- package/src/labs/DataView/tableConstants.tsx +0 -137
- package/src/labs/DataView/testSupportData.tsx +0 -301
- package/src/labs/DataView/useFilterConversion.ts +0 -88
- package/src/labs/DatePickers/DateTimeField.tsx +0 -267
- package/src/labs/DatePickers/DateTimePicker.test.tsx +0 -70
- package/src/labs/DatePickers/DateTimePicker.tsx +0 -303
- package/src/labs/DatePickers/dateTimePickerTheme.ts +0 -216
- package/src/labs/DatePickers/index.ts +0 -13
- package/src/labs/GroupPicker.tsx +0 -261
- package/src/labs/OdysseyPickers/ComposablePicker.test.tsx +0 -32
- package/src/labs/OdysseyPickers/ComposablePicker.tsx +0 -188
- package/src/labs/OdysseyPickers/Picker.tsx +0 -381
- package/src/labs/OdysseyPickers/PickerVirtualizationListBox.tsx +0 -192
- package/src/labs/OdysseyPickers/PickerWithOptionAdornment.tsx +0 -429
- package/src/labs/OdysseyPickers/index.ts +0 -15
- package/src/labs/PageTemplate/Layout.tsx +0 -85
- package/src/labs/PageTemplate/PageTemplate.tsx +0 -234
- package/src/labs/PageTemplate/index.ts +0 -14
- package/src/labs/PaginatedTable.tsx +0 -290
- package/src/labs/README.md +0 -46
- package/src/labs/StaticTable.tsx +0 -131
- package/src/labs/UserProfile.tsx +0 -104
- package/src/labs/UserProfileMenuButton.tsx +0 -86
- package/src/labs/index.ts +0 -47
- package/src/labs/materialReactTableTypes.tsx +0 -19
- package/src/properties/odyssey-react-mui.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_cs.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_da.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_de.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_el.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_es.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_fi.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_fr.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ht.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_hu.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_id.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_it.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ja.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ko.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ms.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_nb.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_nl_NL.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ok_PL.properties +0 -126
- package/src/properties/translations/odyssey-react-mui_ok_SK.properties +0 -126
- package/src/properties/translations/odyssey-react-mui_pl.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_pt_BR.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ro.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_ru.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_sv.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_th.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_tr.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_uk.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_vi.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_zh_CN.properties +0 -140
- package/src/properties/translations/odyssey-react-mui_zh_TW.properties +0 -140
- package/src/properties/ts/odyssey-react-mui.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_cs.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_da.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_de.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_el.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_es.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_fi.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_fr.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ht.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_hu.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_id.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_it.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ja.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ko.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ms.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_nb.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_nl_NL.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ok_PL.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ok_SK.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_pl.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_pt_BR.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ro.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_ru.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_sv.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_th.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_tr.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_uk.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_vi.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_zh_CN.ts +0 -1
- package/src/properties/ts/odyssey-react-mui_zh_TW.ts +0 -1
- package/src/remUtils.ts +0 -27
- package/src/shadow-dom/index.ts +0 -13
- package/src/shadow-dom/shadow-dom.test.ts +0 -24
- package/src/shadow-dom/shadow-dom.ts +0 -54
- package/src/test-selectors/getByQuerySelector.ts +0 -176
- package/src/test-selectors/getComputedAccessibleErrorMessageText.ts +0 -52
- package/src/test-selectors/getComputedAccessibleText.ts +0 -36
- package/src/test-selectors/index.ts +0 -15
- package/src/test-selectors/interpolateString.ts +0 -41
- package/src/test-selectors/linkedHtmlSelectors.ts +0 -73
- package/src/test-selectors/queryOdysseySelector.ts +0 -36
- package/src/test-selectors/querySelector.ts +0 -249
- package/src/test-selectors/sanityChecks.ts +0 -53
- package/src/test-selectors/testSelector.ts +0 -143
- package/src/theme/components.tsx +0 -3275
- package/src/theme/components.types.ts +0 -111
- package/src/theme/createOdysseyMuiTheme.ts +0 -54
- package/src/theme/index.ts +0 -13
- package/src/theme/mixins.ts +0 -29
- package/src/theme/mixins.types.ts +0 -31
- package/src/theme/palette.ts +0 -112
- package/src/theme/palette.types.ts +0 -24
- package/src/theme/shape.ts +0 -31
- package/src/theme/spacing.ts +0 -34
- package/src/theme/theme.ts +0 -13
- package/src/theme/typography.ts +0 -137
- package/src/theme/typography.types.ts +0 -41
- package/src/theme/useContrastMode.test.tsx +0 -504
- package/src/ui-shell/AppSwitcher/AppSwitcher.tsx +0 -94
- package/src/ui-shell/AppSwitcher/AppSwitcherApp.tsx +0 -146
- package/src/ui-shell/AppSwitcher/OktaAura.tsx +0 -50
- package/src/ui-shell/AppSwitcher/index.ts +0 -13
- package/src/ui-shell/SideNav/CollapseIcon.tsx +0 -34
- package/src/ui-shell/SideNav/HandleIcon.tsx +0 -35
- package/src/ui-shell/SideNav/NavAccordion.tsx +0 -243
- package/src/ui-shell/SideNav/OktaLogo.tsx +0 -34
- package/src/ui-shell/SideNav/SideNav.test.tsx +0 -326
- package/src/ui-shell/SideNav/SideNav.tsx +0 -810
- package/src/ui-shell/SideNav/SideNavFooterContent.tsx +0 -85
- package/src/ui-shell/SideNav/SideNavHeader.tsx +0 -134
- package/src/ui-shell/SideNav/SideNavItemContent.tsx +0 -402
- package/src/ui-shell/SideNav/SideNavItemContentContext.tsx +0 -29
- package/src/ui-shell/SideNav/SideNavItemLinkContent.tsx +0 -90
- package/src/ui-shell/SideNav/SideNavLogo.tsx +0 -65
- package/src/ui-shell/SideNav/SideNavToggleButton.tsx +0 -272
- package/src/ui-shell/SideNav/SortableList/SortableItem.tsx +0 -237
- package/src/ui-shell/SideNav/SortableList/SortableList.tsx +0 -132
- package/src/ui-shell/SideNav/SortableList/SortableOverlay.tsx +0 -34
- package/src/ui-shell/SideNav/index.ts +0 -16
- package/src/ui-shell/SideNav/types.ts +0 -224
- package/src/ui-shell/TopNav/TopNav.tsx +0 -109
- package/src/ui-shell/TopNav/TopNavLinksList.tsx +0 -68
- package/src/ui-shell/TopNav/TopNavListItem.tsx +0 -209
- package/src/ui-shell/TopNav/index.ts +0 -13
- package/src/ui-shell/UiShell.test.tsx +0 -366
- package/src/ui-shell/UiShell.tsx +0 -153
- package/src/ui-shell/UiShellContent.tsx +0 -350
- package/src/ui-shell/UiShellProvider.tsx +0 -103
- package/src/ui-shell/bufferLatest.test.ts +0 -79
- package/src/ui-shell/bufferLatest.ts +0 -64
- package/src/ui-shell/createMessageBus.test.ts +0 -115
- package/src/ui-shell/createMessageBus.ts +0 -53
- package/src/ui-shell/createStore.test.ts +0 -103
- package/src/ui-shell/createStore.ts +0 -37
- package/src/ui-shell/index.ts +0 -21
- package/src/ui-shell/renderUiShell.test.tsx +0 -203
- package/src/ui-shell/renderUiShell.tsx +0 -158
- package/src/ui-shell/useHasUiShell.ts +0 -25
- package/src/ui-shell/useScrollState.ts +0 -59
- package/src/useAutocomplete.tsx +0 -184
- package/src/useContrastMode.tsx +0 -143
- package/src/useNormalizedKey.ts +0 -17
- package/src/useUniqueAlphabeticalId.ts +0 -21
- package/src/useUniqueId.ts +0 -21
- package/src/web-component/createReactRootElements.test.ts +0 -40
- package/src/web-component/createReactRootElements.ts +0 -39
- package/src/web-component/index.ts +0 -13
- package/src/web-component/renderReactInWebComponent.test.tsx +0 -128
- package/src/web-component/renderReactInWebComponent.ts +0 -135
- package/tsconfig.json +0 -16
- package/tsconfig.production.json +0 -13
- package/vitest.config.ts +0 -36
- package/vitest.setup.ts +0 -32
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
-
*
|
|
10
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { Status } from "../../Status.js";
|
|
14
|
-
import { DataColumns, DataFilter, DataGetDataType } from "../index.js";
|
|
15
|
-
|
|
16
|
-
export type Person = {
|
|
17
|
-
order: number;
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
city: string;
|
|
21
|
-
state: string;
|
|
22
|
-
age: number;
|
|
23
|
-
risk: "high" | "medium" | "low";
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const columns: DataColumns<Person> = [
|
|
27
|
-
{
|
|
28
|
-
accessorKey: "order",
|
|
29
|
-
header: "ID",
|
|
30
|
-
enableColumnFilter: false,
|
|
31
|
-
size: 120,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
accessorKey: "name",
|
|
35
|
-
header: "Name",
|
|
36
|
-
enableHiding: false,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
accessorKey: "city",
|
|
40
|
-
header: "City",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
accessorKey: "state",
|
|
44
|
-
header: "State",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
accessorKey: "age",
|
|
48
|
-
header: "Age",
|
|
49
|
-
size: 80,
|
|
50
|
-
filterVariant: "range",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
accessorKey: "risk",
|
|
54
|
-
header: "Risk level",
|
|
55
|
-
Cell: ({ cell }) => {
|
|
56
|
-
const value = cell.getValue<string>();
|
|
57
|
-
const severity =
|
|
58
|
-
value === "low" ? "success" : value === "medium" ? "warning" : "error";
|
|
59
|
-
return (
|
|
60
|
-
<Status
|
|
61
|
-
label={value.charAt(0).toUpperCase() + value.slice(1)}
|
|
62
|
-
severity={severity}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
filterVariant: "multi-select",
|
|
67
|
-
filterSelectOptions: [
|
|
68
|
-
{
|
|
69
|
-
label: "Low",
|
|
70
|
-
value: "low",
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
label: "Medium",
|
|
74
|
-
value: "medium",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
label: "High",
|
|
78
|
-
value: "high",
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
export const data: Person[] = [
|
|
85
|
-
{
|
|
86
|
-
order: 1,
|
|
87
|
-
id: "1",
|
|
88
|
-
name: "Luke Skywalker",
|
|
89
|
-
city: "Mos Eisley",
|
|
90
|
-
state: "Tatooine",
|
|
91
|
-
age: 19,
|
|
92
|
-
risk: "low",
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
order: 2,
|
|
96
|
-
id: "2",
|
|
97
|
-
name: "Han Solo",
|
|
98
|
-
city: "Corellia",
|
|
99
|
-
state: "Corellia",
|
|
100
|
-
age: 40,
|
|
101
|
-
risk: "medium",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
order: 3,
|
|
105
|
-
id: "3",
|
|
106
|
-
name: "Leia Organa",
|
|
107
|
-
city: "Alderaan City",
|
|
108
|
-
state: "Alderaan",
|
|
109
|
-
age: 19,
|
|
110
|
-
risk: "low",
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
order: 4,
|
|
114
|
-
id: "4",
|
|
115
|
-
name: "Chewbacca",
|
|
116
|
-
city: "Kashyyyk City",
|
|
117
|
-
state: "Kashyyyk",
|
|
118
|
-
age: 50,
|
|
119
|
-
risk: "high",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
order: 5,
|
|
123
|
-
id: "5",
|
|
124
|
-
name: "C-3P0",
|
|
125
|
-
city: "Mos Espa",
|
|
126
|
-
state: "Tatooine",
|
|
127
|
-
age: 25,
|
|
128
|
-
risk: "low",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
order: 6,
|
|
132
|
-
id: "6",
|
|
133
|
-
name: "R2-D2",
|
|
134
|
-
city: "Theed",
|
|
135
|
-
state: "Naboo",
|
|
136
|
-
age: 25,
|
|
137
|
-
risk: "low",
|
|
138
|
-
},
|
|
139
|
-
];
|
|
140
|
-
|
|
141
|
-
let result: Person[] = [];
|
|
142
|
-
for (let i = 0; i < 50; i++) {
|
|
143
|
-
result = result.concat(data);
|
|
144
|
-
}
|
|
145
|
-
export const lotsOfData = result;
|
|
146
|
-
|
|
147
|
-
export const filterData = ({
|
|
148
|
-
data,
|
|
149
|
-
...args
|
|
150
|
-
}: {
|
|
151
|
-
data: Person[];
|
|
152
|
-
} & DataGetDataType) => {
|
|
153
|
-
const { search, filters, sort, page = 1, resultsPerPage = 20 } = args;
|
|
154
|
-
|
|
155
|
-
const searchFiltered = search
|
|
156
|
-
? data.filter((row) =>
|
|
157
|
-
Object.values(row).some((value) =>
|
|
158
|
-
value.toString().toLowerCase().includes(search.toLowerCase()),
|
|
159
|
-
),
|
|
160
|
-
)
|
|
161
|
-
: data;
|
|
162
|
-
|
|
163
|
-
const personKeys: (keyof Person)[] = [
|
|
164
|
-
"order",
|
|
165
|
-
"id",
|
|
166
|
-
"name",
|
|
167
|
-
"city",
|
|
168
|
-
"state",
|
|
169
|
-
"age",
|
|
170
|
-
"risk",
|
|
171
|
-
];
|
|
172
|
-
|
|
173
|
-
const isKeyOfPerson = (key: string): key is keyof Person => {
|
|
174
|
-
return personKeys.includes(key as keyof Person);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const handleStartLetterFilter = (
|
|
178
|
-
row: Person,
|
|
179
|
-
value: DataFilter["value"],
|
|
180
|
-
): boolean => {
|
|
181
|
-
if (typeof row.name !== "string") return true;
|
|
182
|
-
const firstLetter = row.name[0]?.toLowerCase();
|
|
183
|
-
if (value === "vowel") return "aeiou".includes(firstLetter);
|
|
184
|
-
if (value === "consonant") return !"aeiou".includes(firstLetter);
|
|
185
|
-
return true;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const handleStandardFilter = (
|
|
189
|
-
row: Person,
|
|
190
|
-
id: keyof Person,
|
|
191
|
-
value: DataFilter["value"],
|
|
192
|
-
): boolean => {
|
|
193
|
-
const rowValue = String(row[id]).toLowerCase();
|
|
194
|
-
|
|
195
|
-
if (value === null || value === undefined) {
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
200
|
-
return rowValue.includes(String(value).toLowerCase());
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (Array.isArray(value)) {
|
|
204
|
-
return value.some((arrayValue) => {
|
|
205
|
-
const filterValue =
|
|
206
|
-
typeof arrayValue === "object" ? arrayValue.value : arrayValue;
|
|
207
|
-
return row[id]
|
|
208
|
-
?.toString()
|
|
209
|
-
.toLowerCase()
|
|
210
|
-
.includes(filterValue.toString().toLowerCase());
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return false;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const compareValues = (
|
|
218
|
-
a: string | number,
|
|
219
|
-
b: string | number,
|
|
220
|
-
desc: boolean,
|
|
221
|
-
): number => {
|
|
222
|
-
if (a < b) return desc ? 1 : -1;
|
|
223
|
-
if (a > b) return desc ? -1 : 1;
|
|
224
|
-
return 0;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// In a real-world scenario, the consumer would provide their own backend
|
|
228
|
-
// filtering/searching logic. This is a demo of what that could look like
|
|
229
|
-
// for the provided sample data and demo filters.
|
|
230
|
-
const columnFiltered = filters
|
|
231
|
-
? searchFiltered.filter((row) =>
|
|
232
|
-
filters.every(({ id, value }: DataFilter) => {
|
|
233
|
-
// If the filter value is null, return all the data
|
|
234
|
-
if (value === null || value === undefined) {
|
|
235
|
-
return true;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Handle custom filters
|
|
239
|
-
if (id === "startLetter") {
|
|
240
|
-
return handleStartLetterFilter(row, value);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Handle standard Person properties
|
|
244
|
-
if (isKeyOfPerson(id)) {
|
|
245
|
-
return handleStandardFilter(row, id, value);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return true;
|
|
249
|
-
}),
|
|
250
|
-
)
|
|
251
|
-
: searchFiltered;
|
|
252
|
-
|
|
253
|
-
const sorted =
|
|
254
|
-
sort && sort.length > 0
|
|
255
|
-
? [...columnFiltered].sort((a, b) =>
|
|
256
|
-
sort.reduce((result, { id, desc }) => {
|
|
257
|
-
if (result !== 0) return result;
|
|
258
|
-
|
|
259
|
-
if (isKeyOfPerson(id)) {
|
|
260
|
-
const aValue = a[id];
|
|
261
|
-
const bValue = b[id];
|
|
262
|
-
return compareValues(aValue, bValue, desc);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Handle custom sort fields if needed
|
|
266
|
-
return 0;
|
|
267
|
-
}, 0),
|
|
268
|
-
)
|
|
269
|
-
: columnFiltered;
|
|
270
|
-
|
|
271
|
-
const startRow = (page - 1) * resultsPerPage;
|
|
272
|
-
const endRow = startRow + resultsPerPage;
|
|
273
|
-
|
|
274
|
-
return sorted.slice(startRow, endRow);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export const reorderData = <Data extends Person>({
|
|
278
|
-
data,
|
|
279
|
-
rowId,
|
|
280
|
-
newRowIndex,
|
|
281
|
-
}: {
|
|
282
|
-
data: Data[];
|
|
283
|
-
rowId: string | number;
|
|
284
|
-
newRowIndex: number;
|
|
285
|
-
}): Data[] => {
|
|
286
|
-
const rowIndex = data.findIndex((row) => row.id === rowId);
|
|
287
|
-
|
|
288
|
-
if (rowIndex === -1) {
|
|
289
|
-
return data;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const [removedRow] = data.splice(rowIndex, 1);
|
|
293
|
-
|
|
294
|
-
const reorderedData = [
|
|
295
|
-
...data.slice(0, newRowIndex),
|
|
296
|
-
removedRow,
|
|
297
|
-
...data.slice(newRowIndex),
|
|
298
|
-
];
|
|
299
|
-
|
|
300
|
-
return reorderedData;
|
|
301
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
-
*
|
|
10
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useCallback, useMemo } from "react";
|
|
14
|
-
import { MRT_RowData } from "material-react-table";
|
|
15
|
-
|
|
16
|
-
import { DataFilter } from "../DataFilters.js";
|
|
17
|
-
import { DataTableColumn } from "../../DataTable/index.js";
|
|
18
|
-
import { UniversalProps, TableLayoutProps } from "./componentTypes.js";
|
|
19
|
-
|
|
20
|
-
type FilterConversionType<TData extends MRT_RowData> = {
|
|
21
|
-
columns?: TableLayoutProps<TData>["columns"];
|
|
22
|
-
filters?: UniversalProps<TData>["filters"];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const useFilterConversion = <TData extends MRT_RowData>({
|
|
26
|
-
columns,
|
|
27
|
-
filters,
|
|
28
|
-
}: FilterConversionType<TData>) => {
|
|
29
|
-
const convertFilterSelectOptions = useCallback(
|
|
30
|
-
(options: DataTableColumn<MRT_RowData>["filterSelectOptions"]) =>
|
|
31
|
-
options?.map((option) =>
|
|
32
|
-
typeof option === "string"
|
|
33
|
-
? {
|
|
34
|
-
label: option,
|
|
35
|
-
value: option,
|
|
36
|
-
}
|
|
37
|
-
: {
|
|
38
|
-
// If the option isn't a string, it must have value and/or option defined
|
|
39
|
-
// If either is undefined, use the other
|
|
40
|
-
label: (option.label ?? option.value) as string,
|
|
41
|
-
value: (option.value ?? option.label) as string,
|
|
42
|
-
},
|
|
43
|
-
),
|
|
44
|
-
[],
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const convertColumnToFilter = useCallback(
|
|
48
|
-
(column: DataTableColumn<TData>) =>
|
|
49
|
-
column.enableColumnFilter !== false && column.accessorKey
|
|
50
|
-
? {
|
|
51
|
-
id: column.accessorKey,
|
|
52
|
-
label: column.header,
|
|
53
|
-
variant: column.filterVariant,
|
|
54
|
-
options: convertFilterSelectOptions(column.filterSelectOptions),
|
|
55
|
-
}
|
|
56
|
-
: null,
|
|
57
|
-
[convertFilterSelectOptions],
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const dataTableFilters = useMemo(() => {
|
|
61
|
-
// Filters may be manually set via the `filters` variable;
|
|
62
|
-
// If not, they may be inferred from `columns`
|
|
63
|
-
const providedFilters = filters || columns || [];
|
|
64
|
-
|
|
65
|
-
return providedFilters.reduce<DataFilter[]>((accumulator, item) => {
|
|
66
|
-
if (typeof item === "string") {
|
|
67
|
-
const foundColumn = columns?.find(
|
|
68
|
-
(column) => column.accessorKey === item,
|
|
69
|
-
);
|
|
70
|
-
const filter = foundColumn && convertColumnToFilter(foundColumn);
|
|
71
|
-
return filter ? accumulator.concat(filter) : accumulator;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if ("accessorKey" in item) {
|
|
75
|
-
const filter = convertColumnToFilter(item);
|
|
76
|
-
return filter ? accumulator.concat(filter) : accumulator;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if ("label" in item) {
|
|
80
|
-
return accumulator.concat(item);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return accumulator;
|
|
84
|
-
}, []);
|
|
85
|
-
}, [columns, filters]);
|
|
86
|
-
|
|
87
|
-
return dataTableFilters;
|
|
88
|
-
};
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
-
*
|
|
10
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
FocusEventHandler,
|
|
15
|
-
memo,
|
|
16
|
-
useCallback,
|
|
17
|
-
useEffect,
|
|
18
|
-
useImperativeHandle,
|
|
19
|
-
useRef,
|
|
20
|
-
useState,
|
|
21
|
-
} from "react";
|
|
22
|
-
import { InputAdornment } from "@mui/material";
|
|
23
|
-
import {
|
|
24
|
-
DateTimeField as MuiDateTimeField,
|
|
25
|
-
DateTimeFieldProps as MuiDateTimeFieldProps,
|
|
26
|
-
DateTimeValidationError,
|
|
27
|
-
} from "@mui/x-date-pickers";
|
|
28
|
-
import { DateTime } from "luxon";
|
|
29
|
-
import { useTranslation } from "react-i18next";
|
|
30
|
-
|
|
31
|
-
import { Field, RenderFieldComponentProps } from "../../Field.js";
|
|
32
|
-
import { TextFieldProps } from "../../TextField.js";
|
|
33
|
-
|
|
34
|
-
export type DateTimeFieldProps = {
|
|
35
|
-
onChange?: (value: string) => void;
|
|
36
|
-
} & Pick<
|
|
37
|
-
MuiDateTimeFieldProps<DateTime>,
|
|
38
|
-
"defaultValue" | "inputRef" | "minDate" | "maxDate" | "timezone" | "value"
|
|
39
|
-
> &
|
|
40
|
-
Pick<
|
|
41
|
-
TextFieldProps,
|
|
42
|
-
| "endAdornment"
|
|
43
|
-
| "errorMessage"
|
|
44
|
-
| "hasInitialFocus"
|
|
45
|
-
| "hint"
|
|
46
|
-
| "HintLinkComponent"
|
|
47
|
-
| "id"
|
|
48
|
-
| "isDisabled"
|
|
49
|
-
| "isOptional"
|
|
50
|
-
| "isReadOnly"
|
|
51
|
-
| "label"
|
|
52
|
-
| "onBlur"
|
|
53
|
-
| "onFocus"
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
const useOdysseyDateError = () => {
|
|
57
|
-
const { t } = useTranslation();
|
|
58
|
-
|
|
59
|
-
return new Map<DateTimeValidationError, string>([
|
|
60
|
-
["invalidDate", t("picker.error.invalid")],
|
|
61
|
-
["maxDate", t("picker.error.maxdate")],
|
|
62
|
-
["minDate", t("picker.error.mindate")],
|
|
63
|
-
]);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const formatDateTimeToUtcIsoDateString = (value: DateTime) =>
|
|
67
|
-
value.toUTC().toISO();
|
|
68
|
-
|
|
69
|
-
const DateTimeField = ({
|
|
70
|
-
defaultValue,
|
|
71
|
-
endAdornment,
|
|
72
|
-
errorMessage,
|
|
73
|
-
hasInitialFocus,
|
|
74
|
-
hint,
|
|
75
|
-
HintLinkComponent,
|
|
76
|
-
id: idOverride,
|
|
77
|
-
inputRef,
|
|
78
|
-
isDisabled = false,
|
|
79
|
-
isOptional = false,
|
|
80
|
-
isReadOnly,
|
|
81
|
-
label,
|
|
82
|
-
minDate,
|
|
83
|
-
maxDate,
|
|
84
|
-
onBlur,
|
|
85
|
-
onChange,
|
|
86
|
-
onFocus,
|
|
87
|
-
timezone,
|
|
88
|
-
value,
|
|
89
|
-
}: DateTimeFieldProps) => {
|
|
90
|
-
const errorMap = useOdysseyDateError();
|
|
91
|
-
const [displayedErrorMessage, setDisplayedErrorMessage] =
|
|
92
|
-
useState(errorMessage);
|
|
93
|
-
|
|
94
|
-
const internalValidationError = useRef<string | undefined>();
|
|
95
|
-
const localInputRef = useRef<HTMLInputElement>(null);
|
|
96
|
-
|
|
97
|
-
useImperativeHandle(inputRef, () => {
|
|
98
|
-
return {
|
|
99
|
-
focus: () => {
|
|
100
|
-
localInputRef.current?.focus();
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
}, []);
|
|
104
|
-
|
|
105
|
-
const checkMinMaxValidity = useCallback(
|
|
106
|
-
(value: DateTime) => {
|
|
107
|
-
const hasMinError = minDate && value.toUTC() < minDate.toUTC();
|
|
108
|
-
const hasMaxError = maxDate && value.toUTC() > maxDate.toUTC();
|
|
109
|
-
|
|
110
|
-
if (hasMinError || hasMaxError) {
|
|
111
|
-
if (hasMinError) {
|
|
112
|
-
setDisplayedErrorMessage(errorMap.get("minDate"));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (hasMaxError) {
|
|
116
|
-
setDisplayedErrorMessage(errorMap.get("maxDate"));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return true;
|
|
123
|
-
},
|
|
124
|
-
[errorMap, minDate, maxDate],
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (value) {
|
|
129
|
-
checkMinMaxValidity(value);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (defaultValue) {
|
|
133
|
-
checkMinMaxValidity(defaultValue);
|
|
134
|
-
}
|
|
135
|
-
}, [checkMinMaxValidity, defaultValue, minDate, maxDate, value]);
|
|
136
|
-
|
|
137
|
-
const clearErrorMessages = useCallback(() => {
|
|
138
|
-
setDisplayedErrorMessage(undefined);
|
|
139
|
-
internalValidationError.current = undefined;
|
|
140
|
-
}, [internalValidationError, setDisplayedErrorMessage]);
|
|
141
|
-
|
|
142
|
-
const validateAndCallOnChange = useCallback<
|
|
143
|
-
NonNullable<MuiDateTimeFieldProps<DateTime>["onChange"]>
|
|
144
|
-
>(
|
|
145
|
-
(value, validationContext) => {
|
|
146
|
-
clearErrorMessages();
|
|
147
|
-
const { validationError } = validationContext;
|
|
148
|
-
const hasEnteredFullYear = value?.year.toString().length === 4;
|
|
149
|
-
|
|
150
|
-
if (validationError) {
|
|
151
|
-
const odysseyValidationError = errorMap.get(validationError);
|
|
152
|
-
|
|
153
|
-
if (odysseyValidationError) {
|
|
154
|
-
internalValidationError.current = odysseyValidationError;
|
|
155
|
-
|
|
156
|
-
if (value?.isValid && hasEnteredFullYear) {
|
|
157
|
-
setDisplayedErrorMessage(odysseyValidationError);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (value?.isValid && !validationError) {
|
|
163
|
-
const dateStringFromDateTime = formatDateTimeToUtcIsoDateString(value);
|
|
164
|
-
|
|
165
|
-
if (dateStringFromDateTime && checkMinMaxValidity(value)) {
|
|
166
|
-
onChange?.(dateStringFromDateTime);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
[checkMinMaxValidity, clearErrorMessages, errorMap, onChange],
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
const checkFieldValidityAndSetError = useCallback<
|
|
174
|
-
FocusEventHandler<HTMLInputElement>
|
|
175
|
-
>(
|
|
176
|
-
(event) => {
|
|
177
|
-
if (internalValidationError?.current && !displayedErrorMessage) {
|
|
178
|
-
setDisplayedErrorMessage(internalValidationError.current);
|
|
179
|
-
}
|
|
180
|
-
onBlur?.(event);
|
|
181
|
-
},
|
|
182
|
-
[displayedErrorMessage, internalValidationError, onBlur],
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const hasVisibleAdornment = !isReadOnly && !isDisabled;
|
|
186
|
-
|
|
187
|
-
const renderFieldComponent = useCallback(
|
|
188
|
-
({
|
|
189
|
-
ariaDescribedBy,
|
|
190
|
-
errorMessageElementId,
|
|
191
|
-
id,
|
|
192
|
-
labelElementId,
|
|
193
|
-
}: RenderFieldComponentProps) => (
|
|
194
|
-
<MuiDateTimeField
|
|
195
|
-
/* eslint-disable-next-line jsx-a11y/no-autofocus */
|
|
196
|
-
autoFocus={hasInitialFocus}
|
|
197
|
-
defaultValue={defaultValue}
|
|
198
|
-
disabled={isDisabled}
|
|
199
|
-
id={id}
|
|
200
|
-
inputProps={{
|
|
201
|
-
"aria-describedby": ariaDescribedBy,
|
|
202
|
-
"aria-errormessage": errorMessageElementId,
|
|
203
|
-
"aria-labelledby": labelElementId,
|
|
204
|
-
}}
|
|
205
|
-
InputProps={{
|
|
206
|
-
error: Boolean(displayedErrorMessage || errorMessage),
|
|
207
|
-
endAdornment: (
|
|
208
|
-
<>
|
|
209
|
-
{hasVisibleAdornment && (
|
|
210
|
-
<InputAdornment position="end">{endAdornment}</InputAdornment>
|
|
211
|
-
)}
|
|
212
|
-
</>
|
|
213
|
-
),
|
|
214
|
-
}}
|
|
215
|
-
inputRef={localInputRef}
|
|
216
|
-
minDate={minDate}
|
|
217
|
-
maxDate={maxDate}
|
|
218
|
-
name={id}
|
|
219
|
-
onBlur={checkFieldValidityAndSetError}
|
|
220
|
-
onChange={validateAndCallOnChange}
|
|
221
|
-
onFocus={onFocus}
|
|
222
|
-
readOnly={isReadOnly}
|
|
223
|
-
timezone={timezone}
|
|
224
|
-
value={value}
|
|
225
|
-
variant="standard"
|
|
226
|
-
/>
|
|
227
|
-
),
|
|
228
|
-
[
|
|
229
|
-
checkFieldValidityAndSetError,
|
|
230
|
-
defaultValue,
|
|
231
|
-
displayedErrorMessage,
|
|
232
|
-
endAdornment,
|
|
233
|
-
errorMessage,
|
|
234
|
-
hasInitialFocus,
|
|
235
|
-
hasVisibleAdornment,
|
|
236
|
-
isDisabled,
|
|
237
|
-
localInputRef,
|
|
238
|
-
minDate,
|
|
239
|
-
maxDate,
|
|
240
|
-
onFocus,
|
|
241
|
-
isReadOnly,
|
|
242
|
-
timezone,
|
|
243
|
-
validateAndCallOnChange,
|
|
244
|
-
value,
|
|
245
|
-
],
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
return (
|
|
249
|
-
<Field
|
|
250
|
-
errorMessage={displayedErrorMessage || errorMessage}
|
|
251
|
-
fieldType="single"
|
|
252
|
-
hasVisibleLabel
|
|
253
|
-
hint={hint}
|
|
254
|
-
HintLinkComponent={HintLinkComponent}
|
|
255
|
-
id={idOverride}
|
|
256
|
-
isDisabled={isDisabled}
|
|
257
|
-
isOptional={isOptional}
|
|
258
|
-
label={label}
|
|
259
|
-
renderFieldComponent={renderFieldComponent}
|
|
260
|
-
/>
|
|
261
|
-
);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
const MemoizedDateTimeField = memo(DateTimeField);
|
|
265
|
-
MemoizedDateTimeField.displayName = "DateTimeField";
|
|
266
|
-
|
|
267
|
-
export { MemoizedDateTimeField as DateTimeField };
|