codeforlife 2.8.3 → 2.9.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/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/endpoints/index.cjs.js +2 -0
- package/dist/api/endpoints/index.cjs.js.map +1 -0
- package/dist/api/endpoints/index.d.ts +81 -0
- package/dist/api/endpoints/index.es.js +78 -0
- package/dist/api/endpoints/index.es.js.map +1 -0
- package/dist/api/index.cjs.js +4 -0
- package/dist/api/index.cjs.js.map +1 -0
- package/dist/api/index.d.ts +77 -0
- package/dist/api/index.es.js +541 -0
- package/dist/api/index.es.js.map +1 -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/api.d.ts +123 -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/auth.d.ts +40 -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 +86 -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 +90 -0
- package/dist/components/index.es.js +383 -0
- package/dist/components/index.es.js.map +1 -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 +77 -0
- package/dist/components/page/index.es.js +9 -0
- package/dist/components/page/index.es.js.map +1 -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 +78 -0
- package/dist/components/router/index.es.js +11 -0
- package/dist/components/router/index.es.js.map +1 -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 +75 -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/index.cjs.js +2 -0
- package/dist/features/index.cjs.js.map +1 -0
- package/dist/features/index.d.ts +76 -0
- package/dist/features/index.es.js +47 -0
- package/dist/features/index.es.js.map +1 -0
- package/dist/form.d.ts +40 -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/general.d.ts +53 -0
- package/dist/hooks/index.cjs.js +2 -0
- package/dist/hooks/index.cjs.js.map +1 -0
- package/dist/hooks/index.d.ts +77 -0
- package/dist/hooks/index.es.js +25 -0
- package/dist/hooks/index.es.js.map +1 -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 +78 -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 +73 -0
- package/dist/middlewares/index.es.js +10 -0
- package/dist/middlewares/index.es.js.map +1 -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/router.d.ts +48 -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/schema.d.ts +89 -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/server.cjs.js +6 -0
- package/dist/server.cjs.js.map +1 -0
- package/dist/server.d.ts +129 -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/index.cjs.js +2 -0
- package/dist/settings/index.cjs.js.map +1 -0
- package/dist/settings/index.d.ts +76 -0
- package/dist/settings/index.es.js +17 -0
- package/dist/settings/index.es.js.map +1 -0
- package/dist/slices/index.cjs.js +2 -0
- package/dist/slices/index.cjs.js.map +1 -0
- package/dist/slices/index.d.ts +74 -0
- package/dist/slices/index.es.js +6 -0
- package/dist/slices/index.es.js.map +1 -0
- package/dist/store.d.ts +17 -0
- package/dist/style.css +1 -0
- package/dist/test.d.ts +75 -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 +75 -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 +79 -0
- package/dist/theme/index.es.js +222 -0
- package/dist/theme/index.es.js.map +1 -0
- package/dist/theme.d.ts +19 -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 +144 -0
- package/dist/utils/api.es.js +16 -0
- package/dist/utils/api.es.js.map +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 +100 -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 +97 -0
- package/dist/utils/form.es.js +76 -0
- package/dist/utils/form.es.js.map +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 +102 -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/router.cjs.js +2 -0
- package/dist/utils/router.cjs.js.map +1 -0
- package/dist/utils/router.d.ts +91 -0
- package/dist/utils/router.es.js +33 -0
- package/dist/utils/router.es.js.map +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 +115 -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 +82 -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 +125 -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 +83 -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 +74 -0
- package/dist/utils/window.es.js +11 -0
- package/dist/utils/window.es.js.map +1 -0
- package/dist/window.d.ts +5 -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/form.tsx +0 -11
- 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
package/src/utils/schema.ts
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AnyObject,
|
|
3
|
-
type BooleanSchema,
|
|
4
|
-
type DateSchema,
|
|
5
|
-
type DefaultFromShape,
|
|
6
|
-
type Flags,
|
|
7
|
-
type InferType,
|
|
8
|
-
type MakePartial,
|
|
9
|
-
type NumberSchema,
|
|
10
|
-
type ObjectSchema,
|
|
11
|
-
type ObjectShape,
|
|
12
|
-
type Schema,
|
|
13
|
-
type StringSchema,
|
|
14
|
-
type TypeFromShape,
|
|
15
|
-
type ValidateOptions,
|
|
16
|
-
ValidationError,
|
|
17
|
-
number as YupNumber,
|
|
18
|
-
string as YupString,
|
|
19
|
-
} from "yup"
|
|
20
|
-
|
|
21
|
-
export type _<T> = T extends {}
|
|
22
|
-
? {
|
|
23
|
-
[k in keyof T]: T[k]
|
|
24
|
-
}
|
|
25
|
-
: T
|
|
26
|
-
|
|
27
|
-
export type MakeKeysOptional<T> = T extends AnyObject ? _<MakePartial<T>> : T
|
|
28
|
-
|
|
29
|
-
export type ObjectFromShape<Shape extends ObjectShape> = MakeKeysOptional<
|
|
30
|
-
_<TypeFromShape<Shape, AnyObject>>
|
|
31
|
-
>
|
|
32
|
-
|
|
33
|
-
export type ObjectSchemaFromShape<Shape extends ObjectShape> = ObjectSchema<
|
|
34
|
-
_<TypeFromShape<Shape, AnyObject>>,
|
|
35
|
-
AnyObject,
|
|
36
|
-
_<DefaultFromShape<Shape>>,
|
|
37
|
-
""
|
|
38
|
-
>
|
|
39
|
-
|
|
40
|
-
export type SchemaMap<
|
|
41
|
-
TType,
|
|
42
|
-
TContext = AnyObject,
|
|
43
|
-
TDefault = any,
|
|
44
|
-
TFlags extends Flags = "",
|
|
45
|
-
> =
|
|
46
|
-
NonNullable<TType> extends string
|
|
47
|
-
? StringSchema<
|
|
48
|
-
// @ts-expect-error type is fine
|
|
49
|
-
TType extends undefined ? TType | undefined : TType,
|
|
50
|
-
TContext,
|
|
51
|
-
TDefault,
|
|
52
|
-
TFlags
|
|
53
|
-
>
|
|
54
|
-
: NonNullable<TType> extends number
|
|
55
|
-
? NumberSchema<
|
|
56
|
-
// @ts-expect-error type is fine
|
|
57
|
-
TType extends undefined ? TType | undefined : TType,
|
|
58
|
-
TContext,
|
|
59
|
-
TDefault,
|
|
60
|
-
TFlags
|
|
61
|
-
>
|
|
62
|
-
: NonNullable<TType> extends boolean
|
|
63
|
-
? BooleanSchema<
|
|
64
|
-
// @ts-expect-error type is fine
|
|
65
|
-
TType extends undefined ? TType | undefined : TType,
|
|
66
|
-
TContext,
|
|
67
|
-
TDefault,
|
|
68
|
-
TFlags
|
|
69
|
-
>
|
|
70
|
-
: NonNullable<TType> extends Date
|
|
71
|
-
? DateSchema<
|
|
72
|
-
// @ts-expect-error type is fine
|
|
73
|
-
TType extends undefined ? TType | undefined : TType,
|
|
74
|
-
TContext,
|
|
75
|
-
TDefault,
|
|
76
|
-
TFlags
|
|
77
|
-
>
|
|
78
|
-
: NonNullable<TType> extends object
|
|
79
|
-
? ObjectSchema<
|
|
80
|
-
// @ts-expect-error type is fine
|
|
81
|
-
TType extends undefined ? TType | undefined : TType,
|
|
82
|
-
TContext,
|
|
83
|
-
TDefault,
|
|
84
|
-
TFlags
|
|
85
|
-
>
|
|
86
|
-
: Schema<TType, TContext, TDefault, TFlags>
|
|
87
|
-
|
|
88
|
-
export function numericId(schema: NumberSchema = YupNumber()) {
|
|
89
|
-
return schema.min(1)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// -----------------------------------------------------------------------------
|
|
93
|
-
// Limited Character Sets
|
|
94
|
-
// -----------------------------------------------------------------------------
|
|
95
|
-
|
|
96
|
-
export type MatchesCharSetOptions = Partial<{
|
|
97
|
-
schema: StringSchema
|
|
98
|
-
flags: string
|
|
99
|
-
}>
|
|
100
|
-
|
|
101
|
-
export function matchesCharSet(
|
|
102
|
-
charSet: string,
|
|
103
|
-
message: string,
|
|
104
|
-
options: MatchesCharSetOptions = {},
|
|
105
|
-
) {
|
|
106
|
-
const { schema = YupString(), flags } = options
|
|
107
|
-
|
|
108
|
-
return schema.matches(new RegExp(`^[${charSet}]*$`, flags), message)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export type BuildCharSetOptions = MatchesCharSetOptions &
|
|
112
|
-
Partial<{ spaces: boolean; specialChars: string }>
|
|
113
|
-
|
|
114
|
-
export function buildCharSet(
|
|
115
|
-
charSet: string,
|
|
116
|
-
description: string,
|
|
117
|
-
options: BuildCharSetOptions = {},
|
|
118
|
-
) {
|
|
119
|
-
const { spaces = false, specialChars, ...matchesCharSetOptions } = options
|
|
120
|
-
|
|
121
|
-
let message = `can only contain: ${description}`
|
|
122
|
-
|
|
123
|
-
if (spaces) {
|
|
124
|
-
charSet += " "
|
|
125
|
-
message += ", spaces"
|
|
126
|
-
}
|
|
127
|
-
if (specialChars) {
|
|
128
|
-
charSet += specialChars
|
|
129
|
-
message += `, special characters (${specialChars})`
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return matchesCharSet(charSet, message, matchesCharSetOptions)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function buildUnicodeCharSet(
|
|
136
|
-
charSet: string,
|
|
137
|
-
description: string,
|
|
138
|
-
options: BuildCharSetOptions = {},
|
|
139
|
-
) {
|
|
140
|
-
let { flags = "u" } = options
|
|
141
|
-
|
|
142
|
-
if (!flags.includes("u")) flags += "u"
|
|
143
|
-
|
|
144
|
-
return buildCharSet(charSet, description, { ...options, flags })
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function asciiAlphaString(options?: BuildCharSetOptions) {
|
|
148
|
-
return buildCharSet("a-zA-Z", "ASCII alpha characters (a-z, A-Z)", options)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function lowercaseAsciiAlphaString(options?: BuildCharSetOptions) {
|
|
152
|
-
return buildCharSet("a-z", "lowercase ASCII alpha characters (a-z)", options)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function uppercaseAsciiAlphaString(options?: BuildCharSetOptions) {
|
|
156
|
-
return buildCharSet("A-Z", "uppercase ASCII alpha characters (A-Z)", options)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function asciiNumericString(options?: BuildCharSetOptions) {
|
|
160
|
-
return buildCharSet("0-9", "ASCII numbers (0-9)", options)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function asciiAlphanumericString(options?: BuildCharSetOptions) {
|
|
164
|
-
return buildCharSet(
|
|
165
|
-
"a-zA-Z0-9",
|
|
166
|
-
"ASCII alphanumeric characters (a-z, A-Z, 0-9)",
|
|
167
|
-
options,
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function lowercaseAsciiAlphanumericString(
|
|
172
|
-
options?: BuildCharSetOptions,
|
|
173
|
-
) {
|
|
174
|
-
return buildCharSet(
|
|
175
|
-
"a-z0-9",
|
|
176
|
-
"lowercase ASCII alphanumeric characters (a-z, 0-9)",
|
|
177
|
-
options,
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export function uppercaseAsciiAlphanumericString(
|
|
182
|
-
options?: BuildCharSetOptions,
|
|
183
|
-
) {
|
|
184
|
-
return buildCharSet(
|
|
185
|
-
"A-Z0-9",
|
|
186
|
-
"uppercase ASCII alphanumeric characters (A-Z, 0-9)",
|
|
187
|
-
options,
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export function unicodeAlphaString(options?: BuildCharSetOptions) {
|
|
192
|
-
return buildUnicodeCharSet("\\p{L}", "unicode alpha characters", options)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function lowercaseUnicodeAlphaString(options?: BuildCharSetOptions) {
|
|
196
|
-
return buildUnicodeCharSet(
|
|
197
|
-
"\\p{Ll}",
|
|
198
|
-
"lowercase unicode alpha characters",
|
|
199
|
-
options,
|
|
200
|
-
)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function uppercaseUnicodeAlphaString(options?: BuildCharSetOptions) {
|
|
204
|
-
return buildUnicodeCharSet(
|
|
205
|
-
"\\p{Lu}",
|
|
206
|
-
"uppercase unicode alpha characters",
|
|
207
|
-
options,
|
|
208
|
-
)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function unicodeNumericString(options?: BuildCharSetOptions) {
|
|
212
|
-
return buildUnicodeCharSet("\\p{N}", "unicode numbers", options)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export function unicodeAlphanumericString(options?: BuildCharSetOptions) {
|
|
216
|
-
return buildUnicodeCharSet(
|
|
217
|
-
"\\p{L}\\p{N}",
|
|
218
|
-
"unicode alphanumeric characters",
|
|
219
|
-
options,
|
|
220
|
-
)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export function lowercaseUnicodeAlphanumericString(
|
|
224
|
-
options?: BuildCharSetOptions,
|
|
225
|
-
) {
|
|
226
|
-
return buildUnicodeCharSet(
|
|
227
|
-
"\\p{Ll}\\p{N}",
|
|
228
|
-
"lowercase unicode alphanumeric characters",
|
|
229
|
-
options,
|
|
230
|
-
)
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export function uppercaseUnicodeAlphanumericString(
|
|
234
|
-
options?: BuildCharSetOptions,
|
|
235
|
-
) {
|
|
236
|
-
return buildUnicodeCharSet(
|
|
237
|
-
"\\p{Lu}\\p{N}",
|
|
238
|
-
"uppercase unicode alphanumeric characters",
|
|
239
|
-
options,
|
|
240
|
-
)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// -----------------------------------------------------------------------------
|
|
244
|
-
// Try Validate Sync
|
|
245
|
-
// -----------------------------------------------------------------------------
|
|
246
|
-
|
|
247
|
-
export type TryValidateSyncOnErrorRT<S extends Schema> = InferType<S> | void
|
|
248
|
-
|
|
249
|
-
export type TryValidateSyncRT<
|
|
250
|
-
S extends Schema,
|
|
251
|
-
OnErrorRT extends TryValidateSyncOnErrorRT<S>,
|
|
252
|
-
> = OnErrorRT extends InferType<S> ? InferType<S> : InferType<S> | undefined
|
|
253
|
-
|
|
254
|
-
export type TryValidateSyncOptions<
|
|
255
|
-
S extends Schema,
|
|
256
|
-
OnErrorRT extends TryValidateSyncOnErrorRT<S>,
|
|
257
|
-
> = ValidateOptions & {
|
|
258
|
-
onError?: (error: ValidationError) => OnErrorRT
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function tryValidateSync<S extends Schema>(
|
|
262
|
-
value: any,
|
|
263
|
-
schema: S,
|
|
264
|
-
options?: ValidateOptions,
|
|
265
|
-
): InferType<S> | undefined
|
|
266
|
-
|
|
267
|
-
export function tryValidateSync<
|
|
268
|
-
S extends Schema,
|
|
269
|
-
OnErrorRT extends TryValidateSyncOnErrorRT<S>,
|
|
270
|
-
>(
|
|
271
|
-
value: any,
|
|
272
|
-
schema: S,
|
|
273
|
-
options?: ValidateOptions & {
|
|
274
|
-
onError: (error: ValidationError) => OnErrorRT
|
|
275
|
-
},
|
|
276
|
-
): TryValidateSyncRT<S, OnErrorRT>
|
|
277
|
-
|
|
278
|
-
export function tryValidateSync<
|
|
279
|
-
S extends Schema,
|
|
280
|
-
OnErrorRT extends TryValidateSyncOnErrorRT<S>,
|
|
281
|
-
>(value: any, schema: S, options?: TryValidateSyncOptions<S, OnErrorRT>) {
|
|
282
|
-
const { onError, ...validateOptions } = options || {}
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
return schema.validateSync(value, validateOptions) as unknown
|
|
286
|
-
} catch (error) {
|
|
287
|
-
if (!(error instanceof ValidationError)) throw error
|
|
288
|
-
else if (onError) return onError(error) as unknown
|
|
289
|
-
}
|
|
290
|
-
}
|
package/src/utils/store.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Middleware, Reducer } from "@reduxjs/toolkit"
|
|
2
|
-
import { configureStore } from "@reduxjs/toolkit"
|
|
3
|
-
import { setupListeners } from "@reduxjs/toolkit/query"
|
|
4
|
-
|
|
5
|
-
// The store setup is wrapped in `makeStore` to allow reuse
|
|
6
|
-
// when setting up tests that need the same store config
|
|
7
|
-
export function makeStore<R extends Reducer>({
|
|
8
|
-
reducer,
|
|
9
|
-
middlewares = [],
|
|
10
|
-
preloadedState = {},
|
|
11
|
-
}: {
|
|
12
|
-
reducer: R
|
|
13
|
-
middlewares?: Middleware[]
|
|
14
|
-
preloadedState?: Partial<ReturnType<R>>
|
|
15
|
-
}) {
|
|
16
|
-
const store = configureStore({
|
|
17
|
-
reducer,
|
|
18
|
-
// Adding the api middleware enables caching, invalidation, polling,
|
|
19
|
-
// and other useful features of `rtk-query`.
|
|
20
|
-
middleware: getDefaultMiddleware => {
|
|
21
|
-
return getDefaultMiddleware().concat(middlewares)
|
|
22
|
-
},
|
|
23
|
-
preloadedState,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
// configure listeners using the provided defaults
|
|
27
|
-
// optional, but required for `refetchOnFocus`/`refetchOnReconnect` behaviors
|
|
28
|
-
setupListeners(store.dispatch)
|
|
29
|
-
|
|
30
|
-
return store
|
|
31
|
-
}
|
package/src/utils/test.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Middleware, Reducer, Store } from "@reduxjs/toolkit"
|
|
2
|
-
import type { PropsWithChildren, ReactElement } from "react"
|
|
3
|
-
import { Provider } from "react-redux"
|
|
4
|
-
import type { RenderOptions } from "@testing-library/react"
|
|
5
|
-
import { render } from "@testing-library/react"
|
|
6
|
-
import userEvent from "@testing-library/user-event"
|
|
7
|
-
|
|
8
|
-
import { makeStore } from "./store"
|
|
9
|
-
|
|
10
|
-
export function renderWithUser(
|
|
11
|
-
ui: ReactElement,
|
|
12
|
-
renderOptions: RenderOptions = {},
|
|
13
|
-
) {
|
|
14
|
-
return {
|
|
15
|
-
user: userEvent.setup(),
|
|
16
|
-
...render(ui, renderOptions),
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Renders the given React element with Redux Provider and custom store.
|
|
22
|
-
* This function is useful for testing components that are connected to the
|
|
23
|
-
* Redux store.
|
|
24
|
-
*
|
|
25
|
-
* @param ui - The React component or element to render.
|
|
26
|
-
* @param reducer - The root reducer to use for the store.
|
|
27
|
-
* @param extendedRenderOptions - Optional configuration options for rendering.
|
|
28
|
-
* This includes `preloadedState` for initial Redux state and `store` for a
|
|
29
|
-
* specific Redux store instance. Any additional properties are passed to React
|
|
30
|
-
* Testing Library's render function.
|
|
31
|
-
* @returns An object containing the Redux store used in the render, User event
|
|
32
|
-
* API for simulating user interactions in tests, and all of React Testing
|
|
33
|
-
* Library's query functions for testing the component.
|
|
34
|
-
*/
|
|
35
|
-
export function renderWithStore<R extends Reducer>(
|
|
36
|
-
ui: ReactElement,
|
|
37
|
-
reducer: R,
|
|
38
|
-
extendedRenderOptions: RenderOptions & {
|
|
39
|
-
/**
|
|
40
|
-
* The middlewares used to create the Redux store.
|
|
41
|
-
*/
|
|
42
|
-
middlewares?: Middleware[]
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Defines a specific portion or the entire initial state for the Redux store.
|
|
46
|
-
* This is particularly useful for initializing the state in a
|
|
47
|
-
* controlled manner during testing, allowing components to be rendered
|
|
48
|
-
* with predetermined state conditions.
|
|
49
|
-
*/
|
|
50
|
-
preloadedState?: Partial<ReturnType<R>>
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Allows the use of a specific Redux store instance instead of a
|
|
54
|
-
* default or global store. This flexibility is beneficial when
|
|
55
|
-
* testing components with unique store requirements or when isolating
|
|
56
|
-
* tests from a global store state. The custom store should be configured
|
|
57
|
-
* to match the structure and middleware of the store used by the application.
|
|
58
|
-
*
|
|
59
|
-
* @default makeStore({reducer,middlewares,preloadedState})
|
|
60
|
-
*/
|
|
61
|
-
store?: Store
|
|
62
|
-
} = {},
|
|
63
|
-
) {
|
|
64
|
-
const {
|
|
65
|
-
middlewares,
|
|
66
|
-
preloadedState,
|
|
67
|
-
// Automatically create a store instance if no store was passed in
|
|
68
|
-
store = makeStore({ reducer, middlewares, preloadedState }),
|
|
69
|
-
...renderOptions
|
|
70
|
-
} = extendedRenderOptions
|
|
71
|
-
|
|
72
|
-
const Wrapper = ({ children }: PropsWithChildren) => (
|
|
73
|
-
<Provider store={store}>{children}</Provider>
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
// Return an object with the store and all of RTL's query functions
|
|
77
|
-
return {
|
|
78
|
-
store,
|
|
79
|
-
user: userEvent.setup(),
|
|
80
|
-
...render(ui, { wrapper: Wrapper, ...renderOptions }),
|
|
81
|
-
}
|
|
82
|
-
}
|
package/src/utils/theme.tsx
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Divider, type DividerProps, type ThemeOptions } from "@mui/material"
|
|
2
|
-
import { type CommonProps } from "@mui/material/OverridableComponent"
|
|
3
|
-
import { type ReactElement } from "react"
|
|
4
|
-
|
|
5
|
-
import _components from "../theme/components"
|
|
6
|
-
|
|
7
|
-
export function insertDividerBetweenElements({
|
|
8
|
-
elements,
|
|
9
|
-
dividerProps,
|
|
10
|
-
}: {
|
|
11
|
-
elements: ReactElement[]
|
|
12
|
-
dividerProps?: DividerProps
|
|
13
|
-
}): ReactElement[] {
|
|
14
|
-
return elements.map((element, index) => (
|
|
15
|
-
<>
|
|
16
|
-
{element}
|
|
17
|
-
{index !== elements.length - 1 ? (
|
|
18
|
-
<Divider {...dividerProps} />
|
|
19
|
-
) : undefined}
|
|
20
|
-
</>
|
|
21
|
-
))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function getStyleOverrides(
|
|
25
|
-
ownerState: CommonProps,
|
|
26
|
-
componentKey: keyof NonNullable<ThemeOptions["components"]>,
|
|
27
|
-
muiClassName: string = "root",
|
|
28
|
-
components: ThemeOptions["components"] = _components,
|
|
29
|
-
): object {
|
|
30
|
-
if (components !== undefined) {
|
|
31
|
-
const component = components[componentKey]
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
component !== undefined &&
|
|
35
|
-
"styleOverrides" in component &&
|
|
36
|
-
typeof component.styleOverrides === "object" &&
|
|
37
|
-
muiClassName in component.styleOverrides
|
|
38
|
-
) {
|
|
39
|
-
const muiClass = (component.styleOverrides as Record<string, any>)[
|
|
40
|
-
muiClassName
|
|
41
|
-
] as object
|
|
42
|
-
|
|
43
|
-
switch (typeof muiClass) {
|
|
44
|
-
case "function":
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
46
|
-
return muiClass({ ownerState }) as object
|
|
47
|
-
case "object":
|
|
48
|
-
return muiClass
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getClassNames(props: CommonProps): string[] {
|
|
57
|
-
return props.className?.split(" ") ?? []
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function includesClassNames(
|
|
61
|
-
propsOrClassNames: CommonProps | string[],
|
|
62
|
-
includes: string[],
|
|
63
|
-
): boolean {
|
|
64
|
-
const classNames = Array.isArray(propsOrClassNames)
|
|
65
|
-
? propsOrClassNames
|
|
66
|
-
: getClassNames(propsOrClassNames)
|
|
67
|
-
|
|
68
|
-
return includes.every(className => classNames.includes(className))
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function matchClassNames(
|
|
72
|
-
propsOrClassNames: CommonProps | string[],
|
|
73
|
-
pattern: string | RegExp,
|
|
74
|
-
): RegExpMatchArray[] {
|
|
75
|
-
const classNames = Array.isArray(propsOrClassNames)
|
|
76
|
-
? propsOrClassNames
|
|
77
|
-
: getClassNames(propsOrClassNames)
|
|
78
|
-
|
|
79
|
-
return classNames
|
|
80
|
-
.map(className => className.match(pattern))
|
|
81
|
-
.filter(match => match !== null)
|
|
82
|
-
.map(match => match)
|
|
83
|
-
}
|
package/src/utils/window.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function configureFreshworksWidget(display: "open" | "hide"): void {
|
|
2
|
-
// @ts-expect-error defined in external script
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
4
|
-
window.FreshworksWidget(display)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function toggleOneTrustInfoDisplay(): void {
|
|
8
|
-
// @ts-expect-error defined in external script
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
10
|
-
window.Optanon.ToggleInfoDisplay()
|
|
11
|
-
}
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.app.json
DELETED
package/tsconfig.json
DELETED
package/tsconfig.node.json
DELETED
package/types/fixes.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Namespace 'React' has no exported member 'StatelessComponent'
|
|
3
|
-
* in formik, react-mapbox-gl
|
|
4
|
-
*/
|
|
5
|
-
declare namespace React {
|
|
6
|
-
type StatelessComponent<P> = React.FunctionComponent<P>
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare module "*.svg" {
|
|
10
|
-
const content: string
|
|
11
|
-
export default content
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
* Don't care about the typings of external libraries.
|
|
16
|
-
* All libraries without typings will be imported as `any`.
|
|
17
|
-
*/
|
|
18
|
-
declare module "*" {}
|
package/vite.config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config"
|
|
2
|
-
import react from "@vitejs/plugin-react"
|
|
3
|
-
|
|
4
|
-
// https://vitejs.dev/config/
|
|
5
|
-
// TODO: https://vite.dev/guide/build.html#library-mode
|
|
6
|
-
// TODO: import common configs from src/vite.config.ts
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [react()],
|
|
9
|
-
server: {
|
|
10
|
-
open: true,
|
|
11
|
-
},
|
|
12
|
-
test: {
|
|
13
|
-
globals: true,
|
|
14
|
-
environment: "jsdom",
|
|
15
|
-
setupFiles: "src/setupTests",
|
|
16
|
-
mockReset: true,
|
|
17
|
-
coverage: {
|
|
18
|
-
enabled: true,
|
|
19
|
-
provider: "istanbul",
|
|
20
|
-
reporter: ["html", "cobertura"],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
})
|