codeforlife 2.8.3 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Countdown-DFI1RljW.js +28 -0
- package/dist/Countdown-DFI1RljW.js.map +1 -0
- package/dist/Countdown-zY3nMzmi.cjs +2 -0
- package/dist/Countdown-zY3nMzmi.cjs.map +1 -0
- package/dist/Image-D5jC9UoX.js +21 -0
- package/dist/Image-D5jC9UoX.js.map +1 -0
- package/dist/Image-mgT45r_B.cjs +2 -0
- package/dist/Image-mgT45r_B.cjs.map +1 -0
- package/dist/LinkButton-BYFkvL_O.cjs +2 -0
- package/dist/LinkButton-BYFkvL_O.cjs.map +1 -0
- package/dist/LinkButton-oK0RThqn.js +12 -0
- package/dist/LinkButton-oK0RThqn.js.map +1 -0
- package/dist/Navigate-Dq47aqC8.js +25 -0
- package/dist/Navigate-Dq47aqC8.js.map +1 -0
- package/dist/Navigate-dQocLhzN.cjs +2 -0
- package/dist/Navigate-dQocLhzN.cjs.map +1 -0
- package/dist/api/createApi.d.ts +7 -0
- package/dist/api/endpoints/authFactor.d.ts +11 -0
- package/dist/api/endpoints/index.cjs.js +2 -0
- package/dist/api/endpoints/index.cjs.js.map +1 -0
- package/dist/api/endpoints/index.d.ts +9 -0
- package/dist/api/endpoints/index.es.js +78 -0
- package/dist/api/endpoints/index.es.js.map +1 -0
- package/dist/api/endpoints/klass.d.ts +26 -0
- package/dist/api/endpoints/school.d.ts +11 -0
- package/dist/api/endpoints/session.d.ts +9 -0
- package/dist/api/endpoints/user.d.ts +19 -0
- package/dist/api/index.cjs.js +4 -0
- package/dist/api/index.cjs.js.map +1 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.es.js +541 -0
- package/dist/api/index.es.js.map +1 -0
- package/dist/api/models.d.ts +92 -0
- package/dist/api/schemas.d.ts +20 -0
- package/dist/api/tagTypes.d.ts +3 -0
- package/dist/api/urls.d.ts +31 -0
- package/dist/api-Cbyt3rw0.js +92 -0
- package/dist/api-Cbyt3rw0.js.map +1 -0
- package/dist/api-CnMfjRk3.cjs +2 -0
- package/dist/api-CnMfjRk3.cjs.map +1 -0
- package/dist/api-Cs4Y-WeI.js +20 -0
- package/dist/api-Cs4Y-WeI.js.map +1 -0
- package/dist/api-DIgp_6Vr.cjs +2 -0
- package/dist/api-DIgp_6Vr.cjs.map +1 -0
- package/dist/auth-BPfUPjmM.js +237 -0
- package/dist/auth-BPfUPjmM.js.map +1 -0
- package/dist/auth-Vf1MgMci.cjs +2 -0
- package/dist/auth-Vf1MgMci.cjs.map +1 -0
- package/dist/components/App.d.ts +18 -0
- package/dist/components/ClickableTooltip.d.ts +6 -0
- package/dist/components/CopyIconButton.d.ts +7 -0
- package/dist/components/CopyIconButton.test.d.ts +1 -0
- package/dist/components/Countdown.d.ts +9 -0
- package/dist/components/DownloadFileButton.d.ts +13 -0
- package/dist/components/ElevatedAppBar.d.ts +8 -0
- package/dist/components/Image.d.ts +10 -0
- package/dist/components/InputFileButton.d.ts +7 -0
- package/dist/components/ItemizedList.d.ts +11 -0
- package/dist/components/OrderedGrid.d.ts +21 -0
- package/dist/components/ScrollIntoViewLink.d.ts +8 -0
- package/dist/components/SyncError.d.ts +5 -0
- package/dist/components/TablePagination.d.ts +20 -0
- package/dist/components/YouTubeVideo.d.ts +7 -0
- package/dist/components/form/ApiAutocompleteField.d.ts +14 -0
- package/dist/components/form/AutocompleteField.d.ts +11 -0
- package/dist/components/form/CheckboxField.d.ts +11 -0
- package/dist/components/form/CountryField.d.ts +10 -0
- package/dist/components/form/DatePickerField.d.ts +10 -0
- package/dist/components/form/EmailField.d.ts +5 -0
- package/dist/components/form/FirstNameField.d.ts +5 -0
- package/dist/components/form/Form.d.ts +36 -0
- package/dist/components/form/OtpField.d.ts +5 -0
- package/dist/components/form/PasswordField.d.ts +9 -0
- package/dist/components/form/RepeatField.d.ts +9 -0
- package/dist/components/form/SubmitButton.d.ts +6 -0
- package/dist/components/form/TextField.d.ts +14 -0
- package/dist/components/form/UkCountyField.d.ts +10 -0
- package/dist/components/form/index.cjs.js +2 -0
- package/dist/components/form/index.cjs.js.map +1 -0
- package/dist/components/form/index.d.ts +14 -0
- package/dist/components/form/index.es.js +18 -0
- package/dist/components/form/index.es.js.map +1 -0
- package/dist/components/index.cjs.js +11 -0
- package/dist/components/index.cjs.js.map +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.es.js +383 -0
- package/dist/components/index.es.js.map +1 -0
- package/dist/components/page/Banner.d.ts +13 -0
- package/dist/components/page/Notification.d.ts +10 -0
- package/dist/components/page/Page.d.ts +19 -0
- package/dist/components/page/Section.d.ts +7 -0
- package/dist/components/page/TabBar.d.ts +13 -0
- package/dist/components/page/index.cjs.js +2 -0
- package/dist/components/page/index.cjs.js.map +1 -0
- package/dist/components/page/index.d.ts +5 -0
- package/dist/components/page/index.es.js +9 -0
- package/dist/components/page/index.es.js.map +1 -0
- package/dist/components/router/Link.d.ts +9 -0
- package/dist/components/router/LinkButton.d.ts +9 -0
- package/dist/components/router/LinkIconButton.d.ts +9 -0
- package/dist/components/router/LinkListItem.d.ts +9 -0
- package/dist/components/router/LinkTab.d.ts +9 -0
- package/dist/components/router/Navigate.d.ts +15 -0
- package/dist/components/router/index.cjs.js +2 -0
- package/dist/components/router/index.cjs.js.map +1 -0
- package/dist/components/router/index.d.ts +6 -0
- package/dist/components/router/index.es.js +11 -0
- package/dist/components/router/index.es.js.map +1 -0
- package/dist/components/table/CellStack.d.ts +7 -0
- package/dist/components/table/Table.d.ts +12 -0
- package/dist/components/table/index.cjs.js +2 -0
- package/dist/components/table/index.cjs.js.map +1 -0
- package/dist/components/table/index.d.ts +3 -0
- package/dist/components/table/index.es.js +9 -0
- package/dist/components/table/index.es.js.map +1 -0
- package/dist/en-gb-B_rK7Jx1.js +20 -0
- package/dist/en-gb-B_rK7Jx1.js.map +1 -0
- package/dist/en-gb-CpyEkKq3.cjs +2 -0
- package/dist/en-gb-CpyEkKq3.cjs.map +1 -0
- package/dist/features/InactiveDialog.d.ts +7 -0
- package/dist/features/ScreenTimeDialog.d.ts +7 -0
- package/dist/features/index.cjs.js +2 -0
- package/dist/features/index.cjs.js.map +1 -0
- package/dist/features/index.d.ts +4 -0
- package/dist/features/index.es.js +47 -0
- package/dist/features/index.es.js.map +1 -0
- package/dist/general-BPbbmkeX.cjs +2 -0
- package/dist/general-BPbbmkeX.cjs.map +1 -0
- package/dist/general-CtTJPCJn.js +58 -0
- package/dist/general-CtTJPCJn.js.map +1 -0
- package/dist/hooks/api.d.ts +15 -0
- package/dist/hooks/auth.d.ts +46 -0
- package/{src/hooks/form.tsx → dist/hooks/form.d.ts} +2 -5
- package/dist/hooks/general.d.ts +13 -0
- package/dist/hooks/index.cjs.js +2 -0
- package/dist/hooks/index.cjs.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.es.js +25 -0
- package/dist/hooks/index.es.js.map +1 -0
- package/dist/hooks/router.d.ts +29 -0
- package/dist/index-2W--_sNE.js +30 -0
- package/dist/index-2W--_sNE.js.map +1 -0
- package/dist/index-BUMdUVBH.cjs +5 -0
- package/dist/index-BUMdUVBH.cjs.map +1 -0
- package/dist/index-B_Zy_zwA.cjs +2 -0
- package/dist/index-B_Zy_zwA.cjs.map +1 -0
- package/dist/index-BgsynEGX.cjs +2 -0
- package/dist/index-BgsynEGX.cjs.map +1 -0
- package/dist/index-CA-ugBSa.cjs +2 -0
- package/dist/index-CA-ugBSa.cjs.map +1 -0
- package/dist/index-CNtOlJ49.js +572 -0
- package/dist/index-CNtOlJ49.js.map +1 -0
- package/dist/index-DkM_cG3a.js +237 -0
- package/dist/index-DkM_cG3a.js.map +1 -0
- package/dist/index-Dqp7dpn3.js +1111 -0
- package/dist/index-Dqp7dpn3.js.map +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +7 -0
- package/dist/index.es.js.map +1 -0
- package/dist/jsx-runtime-CeSfJrVB.cjs +31 -0
- package/dist/jsx-runtime-CeSfJrVB.cjs.map +1 -0
- package/dist/jsx-runtime-Dpn_P65e.js +634 -0
- package/dist/jsx-runtime-Dpn_P65e.js.map +1 -0
- package/dist/middlewares/index.cjs.js +2 -0
- package/dist/middlewares/index.cjs.js.map +1 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.es.js +10 -0
- package/dist/middlewares/index.es.js.map +1 -0
- package/dist/middlewares/session.d.ts +2 -0
- package/dist/palette-CE2mKYse.cjs +2 -0
- package/dist/palette-CE2mKYse.cjs.map +1 -0
- package/dist/palette-C_L0akN_.js +43 -0
- package/dist/palette-C_L0akN_.js.map +1 -0
- package/dist/rtk-query.modern-CjetfYPg.js +3038 -0
- package/dist/rtk-query.modern-CjetfYPg.js.map +1 -0
- package/dist/rtk-query.modern-PBCErCqb.cjs +15 -0
- package/dist/rtk-query.modern-PBCErCqb.cjs.map +1 -0
- package/dist/schemas-BZbJpkD5.cjs +2 -0
- package/dist/schemas-BZbJpkD5.cjs.map +1 -0
- package/dist/schemas-DlOtf2vf.js +162 -0
- package/dist/schemas-DlOtf2vf.js.map +1 -0
- package/dist/scripts/index.d.ts +0 -0
- package/dist/server.cjs.js +6 -0
- package/dist/server.cjs.js.map +1 -0
- package/dist/server.d.ts +44 -0
- package/dist/server.es.js +127 -0
- package/dist/server.es.js.map +1 -0
- package/dist/session-CE2U7oL1.cjs +2 -0
- package/dist/session-CE2U7oL1.cjs.map +1 -0
- package/dist/session-CacrgFSv.cjs +2 -0
- package/dist/session-CacrgFSv.cjs.map +1 -0
- package/dist/session-D312kYKk.js +32 -0
- package/dist/session-D312kYKk.js.map +1 -0
- package/dist/session-oI-Ht2C8.js +30 -0
- package/dist/session-oI-Ht2C8.js.map +1 -0
- package/dist/settings/custom.d.ts +11 -0
- package/dist/settings/index.cjs.js +2 -0
- package/dist/settings/index.cjs.js.map +1 -0
- package/dist/settings/index.d.ts +4 -0
- package/dist/settings/index.es.js +17 -0
- package/dist/settings/index.es.js.map +1 -0
- package/dist/settings/vite.d.ts +10 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/slices/createSlice.d.ts +3 -0
- package/dist/slices/index.cjs.js +2 -0
- package/dist/slices/index.cjs.js.map +1 -0
- package/dist/slices/index.d.ts +2 -0
- package/dist/slices/index.es.js +6 -0
- package/dist/slices/index.es.js.map +1 -0
- package/dist/slices/session.d.ts +28 -0
- package/dist/style.css +1 -0
- package/dist/theme/ThemedBox.d.ts +10 -0
- package/dist/theme/colors.d.ts +18 -0
- package/dist/theme/components/MuiAccordion.d.ts +3 -0
- package/dist/theme/components/MuiAutocomplete.d.ts +3 -0
- package/dist/theme/components/MuiButton.d.ts +3 -0
- package/dist/theme/components/MuiCardActions.d.ts +3 -0
- package/dist/theme/components/MuiCheckbox.d.ts +3 -0
- package/dist/theme/components/MuiContainer.d.ts +3 -0
- package/dist/theme/components/MuiDialog.d.ts +3 -0
- package/dist/theme/components/MuiFormControlLabel.d.ts +3 -0
- package/dist/theme/components/MuiFormHelperText.d.ts +3 -0
- package/dist/theme/components/MuiGrid2.d.ts +3 -0
- package/dist/theme/components/MuiInputBase.d.ts +3 -0
- package/dist/theme/components/MuiLink.d.ts +3 -0
- package/dist/theme/components/MuiList.d.ts +3 -0
- package/dist/theme/components/MuiListItemText.d.ts +3 -0
- package/dist/theme/components/MuiMenu.d.ts +3 -0
- package/dist/theme/components/MuiMenuItem.d.ts +3 -0
- package/dist/theme/components/MuiSelect.d.ts +3 -0
- package/dist/theme/components/MuiTab.d.ts +3 -0
- package/dist/theme/components/MuiTable.d.ts +3 -0
- package/dist/theme/components/MuiTableBody.d.ts +3 -0
- package/dist/theme/components/MuiTableHead.d.ts +3 -0
- package/dist/theme/components/MuiTabs.d.ts +3 -0
- package/dist/theme/components/MuiTextField.d.ts +3 -0
- package/dist/theme/components/MuiToolbar.d.ts +3 -0
- package/dist/theme/components/MuiTypography.d.ts +3 -0
- package/dist/theme/components/_components.d.ts +11 -0
- package/dist/theme/components/index.cjs.js +2 -0
- package/dist/theme/components/index.cjs.js.map +1 -0
- package/dist/theme/components/index.d.ts +3 -0
- package/dist/theme/components/index.es.js +6 -0
- package/dist/theme/components/index.es.js.map +1 -0
- package/dist/theme/index.cjs.js +2 -0
- package/dist/theme/index.cjs.js.map +1 -0
- package/dist/theme/index.d.ts +7 -0
- package/dist/theme/index.es.js +222 -0
- package/dist/theme/index.es.js.map +1 -0
- package/dist/theme/palette.d.ts +79 -0
- package/dist/theme/spacing.d.ts +1 -0
- package/dist/theme/typography.d.ts +4 -0
- package/dist/urls-DtHr1d3H.js +14 -0
- package/dist/urls-DtHr1d3H.js.map +1 -0
- package/dist/urls-MaVXL_C2.cjs +2 -0
- package/dist/urls-MaVXL_C2.cjs.map +1 -0
- package/dist/utils/api.cjs.js +2 -0
- package/dist/utils/api.cjs.js.map +1 -0
- package/dist/utils/api.d.ts +72 -0
- package/dist/utils/api.es.js +16 -0
- package/dist/utils/api.es.js.map +1 -0
- package/dist/utils/api.test.d.ts +1 -0
- package/dist/utils/auth.cjs.js +2 -0
- package/dist/utils/auth.cjs.js.map +1 -0
- package/dist/utils/auth.d.ts +28 -0
- package/dist/utils/auth.es.js +117 -0
- package/dist/utils/auth.es.js.map +1 -0
- package/dist/utils/form.cjs.js +2 -0
- package/dist/utils/form.cjs.js.map +1 -0
- package/dist/utils/form.d.ts +25 -0
- package/dist/utils/form.es.js +76 -0
- package/dist/utils/form.es.js.map +1 -0
- package/dist/utils/form.test.d.ts +1 -0
- package/dist/utils/general.cjs.js +2 -0
- package/dist/utils/general.cjs.js.map +1 -0
- package/dist/utils/general.d.ts +30 -0
- package/{src/utils/general.ts → dist/utils/general.es.js} +87 -165
- package/dist/utils/general.es.js.map +1 -0
- package/dist/utils/general.test.d.ts +1 -0
- package/dist/utils/router.cjs.js +2 -0
- package/dist/utils/router.cjs.js.map +1 -0
- package/dist/utils/router.d.ts +19 -0
- package/dist/utils/router.es.js +33 -0
- package/dist/utils/router.es.js.map +1 -0
- package/dist/utils/router.test.d.ts +1 -0
- package/dist/utils/schema.cjs.js +2 -0
- package/dist/utils/schema.cjs.js.map +1 -0
- package/dist/utils/schema.d.ts +43 -0
- package/dist/utils/schema.es.js +123 -0
- package/dist/utils/schema.es.js.map +1 -0
- package/dist/utils/store.cjs.js +2 -0
- package/dist/utils/store.cjs.js.map +1 -0
- package/dist/utils/store.d.ts +10 -0
- package/dist/utils/store.es.js +20 -0
- package/dist/utils/store.es.js.map +1 -0
- package/dist/utils/test.cjs.js +2 -0
- package/dist/utils/test.cjs.js.map +1 -0
- package/dist/utils/test.d.ts +53 -0
- package/dist/utils/test.es.js +60 -0
- package/dist/utils/test.es.js.map +1 -0
- package/dist/utils/theme.cjs.js +2 -0
- package/dist/utils/theme.cjs.js.map +1 -0
- package/dist/utils/theme.d.ts +11 -0
- package/dist/utils/theme.es.js +12 -0
- package/dist/utils/theme.es.js.map +1 -0
- package/dist/utils/window.cjs.js +2 -0
- package/dist/utils/window.cjs.js.map +1 -0
- package/dist/utils/window.d.ts +2 -0
- package/dist/utils/window.es.js +11 -0
- package/dist/utils/window.es.js.map +1 -0
- package/package.json +142 -37
- package/.github/workflows/main.yml +0 -55
- package/.prettierignore +0 -1
- package/CHANGELOG.md +0 -2027
- package/CONTRIBUTING.md +0 -3
- package/eslint.config.js +0 -17
- package/src/api/createApi.ts +0 -91
- package/src/api/endpoints/authFactor.ts +0 -31
- package/src/api/endpoints/index.ts +0 -9
- package/src/api/endpoints/klass.ts +0 -87
- package/src/api/endpoints/school.ts +0 -34
- package/src/api/endpoints/session.ts +0 -47
- package/src/api/endpoints/user.ts +0 -70
- package/src/api/index.ts +0 -5
- package/src/api/models.ts +0 -145
- package/src/api/schemas.ts +0 -243
- package/src/api/tagTypes.ts +0 -12
- package/src/api/urls.ts +0 -13
- package/src/components/App.css +0 -38
- package/src/components/App.tsx +0 -152
- package/src/components/ClickableTooltip.tsx +0 -43
- package/src/components/CopyIconButton.test.tsx +0 -16
- package/src/components/CopyIconButton.tsx +0 -27
- package/src/components/Countdown.tsx +0 -42
- package/src/components/DownloadFileButton.tsx +0 -55
- package/src/components/ElevatedAppBar.tsx +0 -41
- package/src/components/Image.tsx +0 -41
- package/src/components/InputFileButton.tsx +0 -27
- package/src/components/ItemizedList.tsx +0 -63
- package/src/components/OrderedGrid.tsx +0 -92
- package/src/components/ScrollIntoViewLink.tsx +0 -22
- package/src/components/SyncError.tsx +0 -14
- package/src/components/TablePagination.tsx +0 -142
- package/src/components/YouTubeVideo.tsx +0 -26
- package/src/components/form/ApiAutocompleteField.tsx +0 -187
- package/src/components/form/AutocompleteField.tsx +0 -135
- package/src/components/form/CheckboxField.tsx +0 -86
- package/src/components/form/CountryField.tsx +0 -75
- package/src/components/form/DatePickerField.tsx +0 -126
- package/src/components/form/EmailField.tsx +0 -38
- package/src/components/form/FirstNameField.tsx +0 -40
- package/src/components/form/Form.tsx +0 -165
- package/src/components/form/OtpField.tsx +0 -28
- package/src/components/form/PasswordField.tsx +0 -71
- package/src/components/form/RepeatField.tsx +0 -123
- package/src/components/form/SubmitButton.tsx +0 -57
- package/src/components/form/TextField.tsx +0 -150
- package/src/components/form/UkCountyField.tsx +0 -68
- package/src/components/form/index.tsx +0 -35
- package/src/components/index.ts +0 -28
- package/src/components/page/Banner.tsx +0 -95
- package/src/components/page/Notification.tsx +0 -71
- package/src/components/page/Page.tsx +0 -73
- package/src/components/page/Section.tsx +0 -21
- package/src/components/page/TabBar.tsx +0 -131
- package/src/components/page/index.ts +0 -10
- package/src/components/router/Link.tsx +0 -23
- package/src/components/router/LinkButton.tsx +0 -22
- package/src/components/router/LinkIconButton.tsx +0 -22
- package/src/components/router/LinkListItem.tsx +0 -22
- package/src/components/router/LinkTab.tsx +0 -22
- package/src/components/router/Navigate.tsx +0 -33
- package/src/components/router/index.tsx +0 -9
- package/src/components/table/CellStack.tsx +0 -19
- package/src/components/table/Table.tsx +0 -55
- package/src/components/table/index.tsx +0 -8
- package/src/features/InactiveDialog.tsx +0 -40
- package/src/features/ScreenTimeDialog.tsx +0 -30
- package/src/features/index.ts +0 -4
- package/src/fonts/ttf/Inter-VariableFont_slnt,wght.ttf +0 -0
- package/src/fonts/ttf/SpaceGrotesk-VariableFont_wght.ttf +0 -0
- package/src/hooks/api.tsx +0 -39
- package/src/hooks/auth.tsx +0 -397
- package/src/hooks/general.tsx +0 -110
- package/src/hooks/index.ts +0 -5
- package/src/hooks/router.tsx +0 -168
- package/src/images/svg/brain.svg +0 -1
- package/src/index.ts +0 -2
- package/src/middlewares/index.ts +0 -1
- package/src/middlewares/session.ts +0 -21
- package/src/scripts/freshDesk.js +0 -473
- package/src/scripts/index.ts +0 -1
- package/src/server.js +0 -187
- package/src/settings/custom.ts +0 -22
- package/src/settings/index.ts +0 -7
- package/src/settings/vite.ts +0 -26
- package/src/setupTests.ts +0 -2
- package/src/slices/createSlice.ts +0 -8
- package/src/slices/index.ts +0 -2
- package/src/slices/session.ts +0 -32
- package/src/theme/ThemedBox.tsx +0 -265
- package/src/theme/colors.ts +0 -57
- package/src/theme/components/MuiAccordion.tsx +0 -13
- package/src/theme/components/MuiAutocomplete.tsx +0 -11
- package/src/theme/components/MuiButton.ts +0 -70
- package/src/theme/components/MuiCardActions.tsx +0 -12
- package/src/theme/components/MuiCheckbox.ts +0 -12
- package/src/theme/components/MuiContainer.ts +0 -19
- package/src/theme/components/MuiDialog.tsx +0 -16
- package/src/theme/components/MuiFormControlLabel.ts +0 -18
- package/src/theme/components/MuiFormHelperText.ts +0 -12
- package/src/theme/components/MuiGrid2.ts +0 -16
- package/src/theme/components/MuiInputBase.ts +0 -14
- package/src/theme/components/MuiLink.ts +0 -41
- package/src/theme/components/MuiList.ts +0 -12
- package/src/theme/components/MuiListItemText.ts +0 -18
- package/src/theme/components/MuiMenu.ts +0 -14
- package/src/theme/components/MuiMenuItem.ts +0 -15
- package/src/theme/components/MuiSelect.ts +0 -16
- package/src/theme/components/MuiTab.ts +0 -29
- package/src/theme/components/MuiTable.ts +0 -29
- package/src/theme/components/MuiTableBody.ts +0 -15
- package/src/theme/components/MuiTableHead.ts +0 -26
- package/src/theme/components/MuiTabs.ts +0 -26
- package/src/theme/components/MuiTextField.ts +0 -86
- package/src/theme/components/MuiToolbar.ts +0 -11
- package/src/theme/components/MuiTypography.ts +0 -12
- package/src/theme/components/_components.ts +0 -95
- package/src/theme/components/index.ts +0 -57
- package/src/theme/index.ts +0 -25
- package/src/theme/palette.ts +0 -98
- package/src/theme/spacing.ts +0 -8
- package/src/theme/typography.ts +0 -101
- package/src/utils/api.test.ts +0 -19
- package/src/utils/api.tsx +0 -339
- package/src/utils/auth.ts +0 -78
- package/src/utils/form.test.ts +0 -50
- package/src/utils/form.ts +0 -193
- package/src/utils/general.test.ts +0 -55
- package/src/utils/router.test.ts +0 -156
- package/src/utils/router.ts +0 -67
- package/src/utils/schema.ts +0 -290
- package/src/utils/store.ts +0 -31
- package/src/utils/test.tsx +0 -82
- package/src/utils/theme.tsx +0 -83
- package/src/utils/window.ts +0 -11
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -4
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -4
- package/types/fixes.d.ts +0 -18
- package/vite.config.ts +0 -23
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Autocomplete,
|
|
3
|
-
type AutocompleteProps,
|
|
4
|
-
type ChipTypeMap,
|
|
5
|
-
TextField,
|
|
6
|
-
type TextFieldProps,
|
|
7
|
-
} from "@mui/material"
|
|
8
|
-
import { type ElementType, type JSX } from "react"
|
|
9
|
-
import { Field, type FieldConfig, type FieldProps } from "formik"
|
|
10
|
-
import {
|
|
11
|
-
type ValidateOptions,
|
|
12
|
-
number as YupNumber,
|
|
13
|
-
string as YupString,
|
|
14
|
-
} from "yup"
|
|
15
|
-
|
|
16
|
-
import { type FormValues, schemaToFieldValidator } from "../../utils/form"
|
|
17
|
-
import { getNestedProperty } from "../../utils/general"
|
|
18
|
-
|
|
19
|
-
export interface AutocompleteFieldProps<
|
|
20
|
-
Value extends string | number,
|
|
21
|
-
Multiple extends boolean | undefined = false,
|
|
22
|
-
DisableClearable extends boolean | undefined = false,
|
|
23
|
-
FreeSolo extends boolean | undefined = false,
|
|
24
|
-
ChipComponent extends ElementType = ChipTypeMap["defaultComponent"],
|
|
25
|
-
> extends Omit<
|
|
26
|
-
AutocompleteProps<
|
|
27
|
-
Value,
|
|
28
|
-
Multiple,
|
|
29
|
-
DisableClearable,
|
|
30
|
-
FreeSolo,
|
|
31
|
-
ChipComponent
|
|
32
|
-
>,
|
|
33
|
-
"renderInput" | "defaultValue" | "onChange" | "onBlur" | "value"
|
|
34
|
-
> {
|
|
35
|
-
textFieldProps: Omit<
|
|
36
|
-
TextFieldProps,
|
|
37
|
-
| "name"
|
|
38
|
-
| "value"
|
|
39
|
-
| "onChange"
|
|
40
|
-
| "onBlur"
|
|
41
|
-
| "error"
|
|
42
|
-
| "helperText"
|
|
43
|
-
| "defaultValue"
|
|
44
|
-
| "type"
|
|
45
|
-
> & {
|
|
46
|
-
name: string
|
|
47
|
-
}
|
|
48
|
-
validateOptions?: ValidateOptions
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const AutocompleteField = <
|
|
52
|
-
Value extends string | number,
|
|
53
|
-
Multiple extends boolean | undefined = false,
|
|
54
|
-
DisableClearable extends boolean | undefined = false,
|
|
55
|
-
FreeSolo extends boolean | undefined = false,
|
|
56
|
-
ChipComponent extends ElementType = ChipTypeMap["defaultComponent"],
|
|
57
|
-
>({
|
|
58
|
-
textFieldProps,
|
|
59
|
-
options,
|
|
60
|
-
validateOptions,
|
|
61
|
-
...otherAutocompleteProps
|
|
62
|
-
}: AutocompleteFieldProps<
|
|
63
|
-
Value,
|
|
64
|
-
Multiple,
|
|
65
|
-
DisableClearable,
|
|
66
|
-
FreeSolo,
|
|
67
|
-
ChipComponent
|
|
68
|
-
>): JSX.Element => {
|
|
69
|
-
const { id, name, required, ...otherTextFieldProps } = textFieldProps
|
|
70
|
-
|
|
71
|
-
const dotPath = name.split(".")
|
|
72
|
-
|
|
73
|
-
const message = "not a valid option"
|
|
74
|
-
let schema =
|
|
75
|
-
typeof options[0] === "string"
|
|
76
|
-
? YupString().oneOf(options as readonly string[], message)
|
|
77
|
-
: YupNumber().oneOf(options as readonly number[], message)
|
|
78
|
-
if (required) schema = schema.required()
|
|
79
|
-
|
|
80
|
-
const fieldConfig: FieldConfig = {
|
|
81
|
-
name,
|
|
82
|
-
type: typeof options[0] === "string" ? "text" : "number",
|
|
83
|
-
validate: schemaToFieldValidator(schema, validateOptions),
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<Field {...fieldConfig}>
|
|
88
|
-
{({ form, meta }: FieldProps) => {
|
|
89
|
-
const value = getNestedProperty(
|
|
90
|
-
form.values as FormValues,
|
|
91
|
-
dotPath,
|
|
92
|
-
) as string
|
|
93
|
-
const touched = getNestedProperty(form.touched, dotPath) as boolean
|
|
94
|
-
const error = getNestedProperty(form.errors, dotPath) as
|
|
95
|
-
| string
|
|
96
|
-
| undefined
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<Autocomplete
|
|
100
|
-
options={options}
|
|
101
|
-
// @ts-expect-error value can be assigned
|
|
102
|
-
defaultValue={
|
|
103
|
-
meta.initialValue === ""
|
|
104
|
-
? undefined
|
|
105
|
-
: (meta.initialValue as string)
|
|
106
|
-
}
|
|
107
|
-
renderInput={({
|
|
108
|
-
id: _, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
109
|
-
...otherParams
|
|
110
|
-
}) => (
|
|
111
|
-
<TextField
|
|
112
|
-
id={id ?? name}
|
|
113
|
-
name={name}
|
|
114
|
-
required={required}
|
|
115
|
-
type="text" // Force to be string to avoid number incrementor/decrementor
|
|
116
|
-
value={value}
|
|
117
|
-
error={touched && Boolean(error)}
|
|
118
|
-
helperText={touched && error}
|
|
119
|
-
{...otherTextFieldProps}
|
|
120
|
-
{...otherParams}
|
|
121
|
-
/>
|
|
122
|
-
)}
|
|
123
|
-
onChange={(_, value) => {
|
|
124
|
-
void form.setFieldValue(name, value ?? undefined, true)
|
|
125
|
-
}}
|
|
126
|
-
onBlur={form.handleBlur}
|
|
127
|
-
{...otherAutocompleteProps}
|
|
128
|
-
/>
|
|
129
|
-
)
|
|
130
|
-
}}
|
|
131
|
-
</Field>
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export default AutocompleteField
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Checkbox,
|
|
3
|
-
type CheckboxProps,
|
|
4
|
-
FormControl,
|
|
5
|
-
FormControlLabel,
|
|
6
|
-
type FormControlLabelProps,
|
|
7
|
-
FormHelperText,
|
|
8
|
-
} from "@mui/material"
|
|
9
|
-
import { Field, type FieldConfig, type FieldProps } from "formik"
|
|
10
|
-
import { type ValidateOptions, bool as YupBool } from "yup"
|
|
11
|
-
import { type FC } from "react"
|
|
12
|
-
|
|
13
|
-
import { type FormValues, schemaToFieldValidator } from "../../utils/form"
|
|
14
|
-
import { getNestedProperty } from "../../utils/general"
|
|
15
|
-
|
|
16
|
-
export interface CheckboxFieldProps
|
|
17
|
-
extends Omit<
|
|
18
|
-
CheckboxProps,
|
|
19
|
-
"defaultChecked" | "value" | "onChange" | "onBlur"
|
|
20
|
-
> {
|
|
21
|
-
name: string
|
|
22
|
-
formControlLabelProps: Omit<FormControlLabelProps, "control">
|
|
23
|
-
errorMessage?: string
|
|
24
|
-
validateOptions?: ValidateOptions
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const CheckboxField: FC<CheckboxFieldProps> = ({
|
|
28
|
-
id,
|
|
29
|
-
name,
|
|
30
|
-
formControlLabelProps,
|
|
31
|
-
required = false,
|
|
32
|
-
errorMessage = "this is a required field",
|
|
33
|
-
validateOptions,
|
|
34
|
-
...otherCheckboxProps
|
|
35
|
-
}) => {
|
|
36
|
-
const dotPath = name.split(".")
|
|
37
|
-
|
|
38
|
-
let schema = YupBool()
|
|
39
|
-
if (required) schema = schema.oneOf([true], errorMessage)
|
|
40
|
-
|
|
41
|
-
const fieldConfig: FieldConfig = {
|
|
42
|
-
name,
|
|
43
|
-
type: "checkbox",
|
|
44
|
-
validate: schemaToFieldValidator(schema, validateOptions),
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Field {...fieldConfig}>
|
|
49
|
-
{({ form, meta }: FieldProps) => {
|
|
50
|
-
const touched = getNestedProperty(form.touched, dotPath) as boolean
|
|
51
|
-
const error = getNestedProperty(form.errors, dotPath) as
|
|
52
|
-
| string
|
|
53
|
-
| undefined
|
|
54
|
-
const value = getNestedProperty(
|
|
55
|
-
form.values as FormValues,
|
|
56
|
-
dotPath,
|
|
57
|
-
) as boolean
|
|
58
|
-
|
|
59
|
-
const hasError = touched && Boolean(error)
|
|
60
|
-
|
|
61
|
-
// https://mui.com/material-ui/react-checkbox/#formgroup
|
|
62
|
-
return (
|
|
63
|
-
<FormControl error={hasError} required={required}>
|
|
64
|
-
<FormControlLabel
|
|
65
|
-
control={
|
|
66
|
-
<Checkbox
|
|
67
|
-
defaultChecked={meta.initialValue as boolean}
|
|
68
|
-
id={id ?? name}
|
|
69
|
-
name={name}
|
|
70
|
-
value={value}
|
|
71
|
-
onChange={form.handleChange}
|
|
72
|
-
onBlur={form.handleBlur}
|
|
73
|
-
{...otherCheckboxProps}
|
|
74
|
-
/>
|
|
75
|
-
}
|
|
76
|
-
{...formControlLabelProps}
|
|
77
|
-
/>
|
|
78
|
-
{hasError && <FormHelperText>{error}</FormHelperText>}
|
|
79
|
-
</FormControl>
|
|
80
|
-
)
|
|
81
|
-
}}
|
|
82
|
-
</Field>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default CheckboxField
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { type ElementType, type JSX } from "react"
|
|
2
|
-
import { type ChipTypeMap } from "@mui/material"
|
|
3
|
-
|
|
4
|
-
import AutocompleteField, {
|
|
5
|
-
type AutocompleteFieldProps,
|
|
6
|
-
} from "./AutocompleteField"
|
|
7
|
-
import {
|
|
8
|
-
COUNTRY_ISO_CODES,
|
|
9
|
-
COUNTRY_ISO_CODE_MAPPING,
|
|
10
|
-
type CountryIsoCodes,
|
|
11
|
-
} from "../../utils/general"
|
|
12
|
-
|
|
13
|
-
export interface CountryFieldProps<
|
|
14
|
-
Multiple extends boolean | undefined = false,
|
|
15
|
-
DisableClearable extends boolean | undefined = false,
|
|
16
|
-
FreeSolo extends boolean | undefined = false,
|
|
17
|
-
ChipComponent extends ElementType = ChipTypeMap["defaultComponent"],
|
|
18
|
-
> extends Omit<
|
|
19
|
-
AutocompleteFieldProps<
|
|
20
|
-
string,
|
|
21
|
-
Multiple,
|
|
22
|
-
DisableClearable,
|
|
23
|
-
FreeSolo,
|
|
24
|
-
ChipComponent
|
|
25
|
-
>,
|
|
26
|
-
"options" | "textFieldProps" | "getOptionLabel"
|
|
27
|
-
> {
|
|
28
|
-
textFieldProps?: Omit<
|
|
29
|
-
AutocompleteFieldProps<
|
|
30
|
-
string,
|
|
31
|
-
Multiple,
|
|
32
|
-
DisableClearable,
|
|
33
|
-
FreeSolo,
|
|
34
|
-
ChipComponent
|
|
35
|
-
>["textFieldProps"],
|
|
36
|
-
"name"
|
|
37
|
-
> & {
|
|
38
|
-
name?: string
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const CountryField = <
|
|
43
|
-
Multiple extends boolean | undefined = false,
|
|
44
|
-
DisableClearable extends boolean | undefined = false,
|
|
45
|
-
FreeSolo extends boolean | undefined = false,
|
|
46
|
-
ChipComponent extends ElementType = ChipTypeMap["defaultComponent"],
|
|
47
|
-
>({
|
|
48
|
-
textFieldProps,
|
|
49
|
-
...otherAutocompleteFieldProps
|
|
50
|
-
}: CountryFieldProps<
|
|
51
|
-
Multiple,
|
|
52
|
-
DisableClearable,
|
|
53
|
-
FreeSolo,
|
|
54
|
-
ChipComponent
|
|
55
|
-
>): JSX.Element => {
|
|
56
|
-
const {
|
|
57
|
-
name = "country",
|
|
58
|
-
label = "Country",
|
|
59
|
-
placeholder = "Select your country",
|
|
60
|
-
...otherTextFieldProps
|
|
61
|
-
} = textFieldProps || {}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<AutocompleteField
|
|
65
|
-
options={COUNTRY_ISO_CODES}
|
|
66
|
-
getOptionLabel={isoCode =>
|
|
67
|
-
COUNTRY_ISO_CODE_MAPPING[isoCode as CountryIsoCodes]
|
|
68
|
-
}
|
|
69
|
-
textFieldProps={{ name, label, placeholder, ...otherTextFieldProps }}
|
|
70
|
-
{...otherAutocompleteFieldProps}
|
|
71
|
-
/>
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default CountryField
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import "dayjs/locale/en-gb"
|
|
2
|
-
import {
|
|
3
|
-
DatePicker,
|
|
4
|
-
type DatePickerProps,
|
|
5
|
-
LocalizationProvider,
|
|
6
|
-
type PickerValidDate,
|
|
7
|
-
} from "@mui/x-date-pickers"
|
|
8
|
-
import { Field, type FieldConfig, type FieldProps } from "formik"
|
|
9
|
-
import { type ValidateOptions, date as YupDate } from "yup"
|
|
10
|
-
import dayjs, { type Dayjs } from "dayjs"
|
|
11
|
-
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"
|
|
12
|
-
import { type JSX } from "react"
|
|
13
|
-
|
|
14
|
-
import { type FormValues, schemaToFieldValidator } from "../../utils/form"
|
|
15
|
-
import { getNestedProperty } from "../../utils/general"
|
|
16
|
-
|
|
17
|
-
export interface DatePickerFieldProps<
|
|
18
|
-
TDate extends PickerValidDate,
|
|
19
|
-
TEnableAccessibleFieldDOMStructure extends boolean = false,
|
|
20
|
-
> extends Omit<
|
|
21
|
-
DatePickerProps<TDate, TEnableAccessibleFieldDOMStructure>,
|
|
22
|
-
"name" | "value" | "onChange" | "slotProps"
|
|
23
|
-
> {
|
|
24
|
-
name: string
|
|
25
|
-
required?: boolean
|
|
26
|
-
validateOptions?: ValidateOptions
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const DatePickerField = <
|
|
30
|
-
TDate extends PickerValidDate,
|
|
31
|
-
TEnableAccessibleFieldDOMStructure extends boolean = false,
|
|
32
|
-
>({
|
|
33
|
-
name,
|
|
34
|
-
required,
|
|
35
|
-
minDate,
|
|
36
|
-
maxDate,
|
|
37
|
-
validateOptions,
|
|
38
|
-
...otherDatePickerProps
|
|
39
|
-
}: DatePickerFieldProps<
|
|
40
|
-
TDate,
|
|
41
|
-
TEnableAccessibleFieldDOMStructure
|
|
42
|
-
>): JSX.Element => {
|
|
43
|
-
const dotPath = name.split(".")
|
|
44
|
-
|
|
45
|
-
function dateToString(date: Dayjs) {
|
|
46
|
-
return date.locale("en-gb").format("L")
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let schema = YupDate()
|
|
50
|
-
if (required) schema = schema.required()
|
|
51
|
-
if (minDate) {
|
|
52
|
-
schema = schema.min(
|
|
53
|
-
minDate,
|
|
54
|
-
`this field must be after or equal to ${dateToString(minDate)}`,
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
if (maxDate) {
|
|
58
|
-
schema = schema.max(
|
|
59
|
-
maxDate,
|
|
60
|
-
`this field must be before or equal to ${dateToString(maxDate)}`,
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const fieldConfig: FieldConfig = {
|
|
65
|
-
name,
|
|
66
|
-
type: "date",
|
|
67
|
-
validate: schemaToFieldValidator(schema, validateOptions),
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<Field {...fieldConfig}>
|
|
72
|
-
{({ form }: FieldProps) => {
|
|
73
|
-
const error = getNestedProperty(form.errors, dotPath) as
|
|
74
|
-
| string
|
|
75
|
-
| undefined
|
|
76
|
-
const touched = getNestedProperty(form.touched, dotPath) as boolean
|
|
77
|
-
let value: Dayjs | null | string = getNestedProperty(
|
|
78
|
-
form.values as FormValues,
|
|
79
|
-
dotPath,
|
|
80
|
-
) as string
|
|
81
|
-
|
|
82
|
-
value = value ? dayjs(value) : null
|
|
83
|
-
|
|
84
|
-
function handleChange(value: Dayjs | null) {
|
|
85
|
-
void form.setFieldValue(
|
|
86
|
-
name,
|
|
87
|
-
value && value.isValid() ? value.format("YYYY-MM-DD") : null,
|
|
88
|
-
true,
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<LocalizationProvider
|
|
94
|
-
dateAdapter={AdapterDayjs}
|
|
95
|
-
adapterLocale="en-gb"
|
|
96
|
-
>
|
|
97
|
-
{/* @ts-expect-error value is compatible */}
|
|
98
|
-
<DatePicker
|
|
99
|
-
name={name}
|
|
100
|
-
value={value}
|
|
101
|
-
minDate={minDate}
|
|
102
|
-
maxDate={maxDate}
|
|
103
|
-
onChange={handleChange}
|
|
104
|
-
slotProps={{
|
|
105
|
-
textField: {
|
|
106
|
-
id: name,
|
|
107
|
-
onChange: value => {
|
|
108
|
-
// @ts-expect-error value is compatible
|
|
109
|
-
handleChange(value as Dayjs | null)
|
|
110
|
-
},
|
|
111
|
-
onBlur: form.handleBlur,
|
|
112
|
-
required,
|
|
113
|
-
error: touched && Boolean(error),
|
|
114
|
-
helperText: (touched && error) as false | string,
|
|
115
|
-
},
|
|
116
|
-
}}
|
|
117
|
-
{...otherDatePickerProps}
|
|
118
|
-
/>
|
|
119
|
-
</LocalizationProvider>
|
|
120
|
-
)
|
|
121
|
-
}}
|
|
122
|
-
</Field>
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export default DatePickerField
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { EmailOutlined as EmailOutlinedIcon } from "@mui/icons-material"
|
|
2
|
-
import type { FC } from "react"
|
|
3
|
-
import { InputAdornment } from "@mui/material"
|
|
4
|
-
import { string as YupString } from "yup"
|
|
5
|
-
|
|
6
|
-
import TextField, { type TextFieldProps } from "./TextField"
|
|
7
|
-
|
|
8
|
-
export type EmailFieldProps = Omit<TextFieldProps, "type" | "name" | "schema"> &
|
|
9
|
-
Partial<Pick<TextFieldProps, "name">>
|
|
10
|
-
|
|
11
|
-
const EmailField: FC<EmailFieldProps> = ({
|
|
12
|
-
name = "email",
|
|
13
|
-
label = "Email address",
|
|
14
|
-
placeholder = "Enter your email address",
|
|
15
|
-
InputProps = {},
|
|
16
|
-
...otherTextFieldProps
|
|
17
|
-
}) => {
|
|
18
|
-
return (
|
|
19
|
-
<TextField
|
|
20
|
-
type="email"
|
|
21
|
-
schema={YupString().email()}
|
|
22
|
-
name={name}
|
|
23
|
-
label={label}
|
|
24
|
-
placeholder={placeholder}
|
|
25
|
-
InputProps={{
|
|
26
|
-
endAdornment: (
|
|
27
|
-
<InputAdornment position="end">
|
|
28
|
-
<EmailOutlinedIcon />
|
|
29
|
-
</InputAdornment>
|
|
30
|
-
),
|
|
31
|
-
...InputProps,
|
|
32
|
-
}}
|
|
33
|
-
{...otherTextFieldProps}
|
|
34
|
-
/>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default EmailField
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { FC } from "react"
|
|
2
|
-
import { InputAdornment } from "@mui/material"
|
|
3
|
-
import { PersonOutlined as PersonOutlinedIcon } from "@mui/icons-material"
|
|
4
|
-
|
|
5
|
-
import TextField, { type TextFieldProps } from "./TextField"
|
|
6
|
-
import { schemas } from "../../api"
|
|
7
|
-
|
|
8
|
-
export type FirstNameFieldProps = Omit<
|
|
9
|
-
TextFieldProps,
|
|
10
|
-
"type" | "name" | "schema"
|
|
11
|
-
> &
|
|
12
|
-
Partial<Pick<TextFieldProps, "name">>
|
|
13
|
-
|
|
14
|
-
const FirstNameField: FC<FirstNameFieldProps> = ({
|
|
15
|
-
name = "first_name",
|
|
16
|
-
label = "First name",
|
|
17
|
-
placeholder = "Enter your first name",
|
|
18
|
-
InputProps = {},
|
|
19
|
-
...otherTextFieldProps
|
|
20
|
-
}) => {
|
|
21
|
-
return (
|
|
22
|
-
<TextField
|
|
23
|
-
schema={schemas.user.first_name}
|
|
24
|
-
name={name}
|
|
25
|
-
label={label}
|
|
26
|
-
placeholder={placeholder}
|
|
27
|
-
InputProps={{
|
|
28
|
-
endAdornment: (
|
|
29
|
-
<InputAdornment position="end">
|
|
30
|
-
<PersonOutlinedIcon />
|
|
31
|
-
</InputAdornment>
|
|
32
|
-
),
|
|
33
|
-
...InputProps,
|
|
34
|
-
}}
|
|
35
|
-
{...otherTextFieldProps}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default FirstNameField
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type FC,
|
|
3
|
-
type JSX,
|
|
4
|
-
type ReactNode,
|
|
5
|
-
type RefObject,
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
} from "react"
|
|
9
|
-
import { FormHelperText, type FormHelperTextProps } from "@mui/material"
|
|
10
|
-
import {
|
|
11
|
-
Formik,
|
|
12
|
-
type FormikConfig,
|
|
13
|
-
type FormikErrors,
|
|
14
|
-
Form as FormikForm,
|
|
15
|
-
type FormikProps,
|
|
16
|
-
} from "formik"
|
|
17
|
-
import type { TypedUseMutation } from "@reduxjs/toolkit/query/react"
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
type FormValues,
|
|
21
|
-
type SubmitFormOptions,
|
|
22
|
-
submitForm,
|
|
23
|
-
} from "../../utils/form"
|
|
24
|
-
import { getKeyPaths } from "../../utils/general"
|
|
25
|
-
|
|
26
|
-
const SCROLL_INTO_VIEW_OPTIONS: ScrollIntoViewOptions = {
|
|
27
|
-
behavior: "smooth",
|
|
28
|
-
block: "start",
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type NonFieldErrorsProps = Omit<FormHelperTextProps, "error" | "ref"> & {
|
|
32
|
-
scrollIntoViewOptions?: ScrollIntoViewOptions
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const NonFieldErrors: FC<NonFieldErrorsProps> = ({
|
|
36
|
-
scrollIntoViewOptions = SCROLL_INTO_VIEW_OPTIONS,
|
|
37
|
-
...formHelperTextProps
|
|
38
|
-
}) => {
|
|
39
|
-
const pRef = useRef<HTMLParagraphElement>(null)
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (pRef.current) pRef.current.scrollIntoView(scrollIntoViewOptions)
|
|
43
|
-
}, [scrollIntoViewOptions])
|
|
44
|
-
|
|
45
|
-
return <FormHelperText ref={pRef} error {...formHelperTextProps} />
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export type FormErrors<Values> = FormikErrors<
|
|
49
|
-
Omit<Values, "__all__"> & { __all__: string }
|
|
50
|
-
>
|
|
51
|
-
|
|
52
|
-
type _FormikProps<Values> = Omit<FormikProps<Values>, "errors"> & {
|
|
53
|
-
errors: FormErrors<Values>
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type BaseFormProps<Values> = Omit<FormikConfig<Values>, "children"> & {
|
|
57
|
-
children: ReactNode | ((props: _FormikProps<Values>) => ReactNode)
|
|
58
|
-
scrollIntoViewOptions?: ScrollIntoViewOptions
|
|
59
|
-
nonFieldErrorsProps?: Omit<NonFieldErrorsProps, "children">
|
|
60
|
-
fieldRefs?: Array<{
|
|
61
|
-
name: string
|
|
62
|
-
inputRef: RefObject<HTMLInputElement | null>
|
|
63
|
-
}>
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const BaseForm = <Values extends FormValues>({
|
|
67
|
-
children,
|
|
68
|
-
scrollIntoViewOptions = SCROLL_INTO_VIEW_OPTIONS,
|
|
69
|
-
nonFieldErrorsProps,
|
|
70
|
-
fieldRefs = [],
|
|
71
|
-
...otherFormikProps
|
|
72
|
-
}: BaseFormProps<Values>) => (
|
|
73
|
-
<Formik {...otherFormikProps}>
|
|
74
|
-
{/* @ts-expect-error value is assignable */}
|
|
75
|
-
{(formik: _FormikProps<Values>) => {
|
|
76
|
-
const hasErrors = Boolean(Object.keys(formik.errors).length)
|
|
77
|
-
const hasNonFieldErrors =
|
|
78
|
-
hasErrors && typeof formik.errors.__all__ === "string"
|
|
79
|
-
|
|
80
|
-
// If a submission was attempted and refs to the fields were provided.
|
|
81
|
-
if (
|
|
82
|
-
hasErrors &&
|
|
83
|
-
!hasNonFieldErrors &&
|
|
84
|
-
formik.isSubmitting &&
|
|
85
|
-
fieldRefs.length
|
|
86
|
-
) {
|
|
87
|
-
const errorNames = getKeyPaths(formik.errors)
|
|
88
|
-
|
|
89
|
-
const input = fieldRefs.find(({ name }) => errorNames.includes(name))
|
|
90
|
-
?.inputRef.current
|
|
91
|
-
|
|
92
|
-
if (input) input.scrollIntoView(scrollIntoViewOptions)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<>
|
|
97
|
-
{hasNonFieldErrors && (
|
|
98
|
-
<NonFieldErrors {...nonFieldErrorsProps}>
|
|
99
|
-
{formik.errors.__all__ as string}
|
|
100
|
-
</NonFieldErrors>
|
|
101
|
-
)}
|
|
102
|
-
<FormikForm>
|
|
103
|
-
{typeof children === "function" ? children(formik) : children}
|
|
104
|
-
</FormikForm>
|
|
105
|
-
</>
|
|
106
|
-
)
|
|
107
|
-
}}
|
|
108
|
-
</Formik>
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
type SubmitFormProps<
|
|
112
|
-
Values extends FormValues,
|
|
113
|
-
QueryArg extends FormValues,
|
|
114
|
-
ResultType,
|
|
115
|
-
> = Omit<BaseFormProps<Values>, "onSubmit"> & {
|
|
116
|
-
useMutation: TypedUseMutation<ResultType, QueryArg, any>
|
|
117
|
-
} & (Values extends QueryArg
|
|
118
|
-
? { submitOptions?: SubmitFormOptions<Values, QueryArg, ResultType> }
|
|
119
|
-
: { submitOptions: SubmitFormOptions<Values, QueryArg, ResultType> })
|
|
120
|
-
|
|
121
|
-
const SubmitForm = <
|
|
122
|
-
Values extends FormValues,
|
|
123
|
-
QueryArg extends FormValues,
|
|
124
|
-
ResultType,
|
|
125
|
-
>({
|
|
126
|
-
useMutation,
|
|
127
|
-
submitOptions,
|
|
128
|
-
...baseFormProps
|
|
129
|
-
}: SubmitFormProps<Values, QueryArg, ResultType>): JSX.Element => {
|
|
130
|
-
const [trigger] = useMutation()
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<BaseForm
|
|
134
|
-
{...baseFormProps}
|
|
135
|
-
onSubmit={submitForm<Values, QueryArg, ResultType>(
|
|
136
|
-
trigger,
|
|
137
|
-
baseFormProps.initialValues,
|
|
138
|
-
submitOptions as SubmitFormOptions<Values, QueryArg, ResultType>,
|
|
139
|
-
)}
|
|
140
|
-
/>
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export type FormProps<
|
|
145
|
-
Values extends FormValues,
|
|
146
|
-
QueryArg extends FormValues,
|
|
147
|
-
ResultType,
|
|
148
|
-
> = BaseFormProps<Values> | SubmitFormProps<Values, QueryArg, ResultType>
|
|
149
|
-
|
|
150
|
-
const Form: {
|
|
151
|
-
<Values extends FormValues>(props: BaseFormProps<Values>): JSX.Element
|
|
152
|
-
<Values extends FormValues, QueryArg extends FormValues, ResultType>(
|
|
153
|
-
props: SubmitFormProps<Values, QueryArg, ResultType>,
|
|
154
|
-
): JSX.Element
|
|
155
|
-
} = <
|
|
156
|
-
Values extends FormValues = FormValues,
|
|
157
|
-
QueryArg extends FormValues = FormValues,
|
|
158
|
-
ResultType = any,
|
|
159
|
-
>(
|
|
160
|
-
props: FormProps<Values, QueryArg, ResultType>,
|
|
161
|
-
): JSX.Element => {
|
|
162
|
-
return "onSubmit" in props ? <BaseForm {...props} /> : SubmitForm(props)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export default Form
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type FC } from "react"
|
|
2
|
-
import { string as YupString } from "yup"
|
|
3
|
-
|
|
4
|
-
import TextField, { type TextFieldProps } from "./TextField"
|
|
5
|
-
|
|
6
|
-
export type OtpFieldProps = Omit<
|
|
7
|
-
TextFieldProps,
|
|
8
|
-
"name" | "schema" | "required"
|
|
9
|
-
> &
|
|
10
|
-
Partial<Pick<TextFieldProps, "name">>
|
|
11
|
-
|
|
12
|
-
const OtpField: FC<OtpFieldProps> = ({
|
|
13
|
-
name = "otp",
|
|
14
|
-
label = "OTP",
|
|
15
|
-
placeholder = "Enter your OTP",
|
|
16
|
-
...otherTextFieldProps
|
|
17
|
-
}) => (
|
|
18
|
-
<TextField
|
|
19
|
-
name={name}
|
|
20
|
-
label={label}
|
|
21
|
-
schema={YupString().matches(/^[0-9]{6}$/, "Must be exactly 6 digits.")}
|
|
22
|
-
placeholder={placeholder}
|
|
23
|
-
required
|
|
24
|
-
{...otherTextFieldProps}
|
|
25
|
-
/>
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
export default OtpField
|