codeforlife 2.8.2 → 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 -2020
- 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 -61
- 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
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { FetchBaseQueryError, TypedUseMutationResult, TypedUseQueryHookResult, TypedUseQueryStateResult } from '@reduxjs/toolkit/query/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Optional, Required } from './general';
|
|
4
|
+
import { SchemaMap } from './schema';
|
|
5
|
+
export type Fields = Record<string, unknown>;
|
|
6
|
+
export interface Tag<Type extends string> {
|
|
7
|
+
type: Type;
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
export type ModelId = string | number;
|
|
11
|
+
/**
|
|
12
|
+
* A data model.
|
|
13
|
+
* Id: The type of Id.
|
|
14
|
+
* Data: The data fields.
|
|
15
|
+
*/
|
|
16
|
+
export type Model<Id extends ModelId, MFields extends Fields = Fields> = {
|
|
17
|
+
id: Id;
|
|
18
|
+
} & Omit<MFields, "id">;
|
|
19
|
+
export type Schemas<M extends Model<any>> = {
|
|
20
|
+
[K in keyof M]-?: SchemaMap<M[K]>;
|
|
21
|
+
};
|
|
22
|
+
export type Result<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never> = Pick<M, "id" | MFields>;
|
|
23
|
+
export type Arg<M extends Model<any>, RequiredFields extends keyof Omit<M, "id">, OptionalFields extends keyof Omit<M, "id" | RequiredFields> = never> = Required<M, RequiredFields> & Optional<M, OptionalFields>;
|
|
24
|
+
export type CreateResult<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never> = Result<M, MFields>;
|
|
25
|
+
export type CreateArg<M extends Model<any>, RequiredFields extends keyof Omit<M, "id">, OptionalFields extends keyof Omit<M, "id" | RequiredFields> = never> = Arg<M, RequiredFields, OptionalFields>;
|
|
26
|
+
export type BulkCreateResult<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never, ExtraFields extends Fields = Fields> = Array<Result<M, MFields> & ExtraFields>;
|
|
27
|
+
export type BulkCreateArg<M extends Model<any>, RequiredFields extends keyof Omit<M, "id">, OptionalFields extends keyof Omit<M, "id" | RequiredFields> = never, ExtraFields extends Fields = Fields> = Array<Arg<M, RequiredFields, OptionalFields> & ExtraFields>;
|
|
28
|
+
export type RetrieveResult<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never> = Result<M, MFields>;
|
|
29
|
+
export type RetrieveArg<M extends Model<any>> = M["id"];
|
|
30
|
+
export interface ListResult<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never, ExtraFields extends Fields = Fields> {
|
|
31
|
+
count: number;
|
|
32
|
+
offset: number;
|
|
33
|
+
limit: number;
|
|
34
|
+
max_limit: number;
|
|
35
|
+
data: Array<Result<M, MFields> & ExtraFields>;
|
|
36
|
+
}
|
|
37
|
+
export type ListArg<Filters extends Fields = Fields> = {
|
|
38
|
+
limit: number;
|
|
39
|
+
offset: number;
|
|
40
|
+
} & Partial<Omit<Filters, "limit" | "offset">>;
|
|
41
|
+
export type UpdateResult<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never> = Result<M, MFields>;
|
|
42
|
+
type UpdateWithBody<M extends Model<any>, RequiredFields extends keyof Omit<M, "id">, OptionalFields extends keyof Omit<M, "id" | RequiredFields>> = Pick<M, "id"> & Arg<M, RequiredFields, OptionalFields>;
|
|
43
|
+
export type UpdateArg<M extends Model<any>, RequiredFields extends keyof Omit<M, "id"> = never, OptionalFields extends keyof Omit<M, "id" | RequiredFields> = never> = [RequiredFields] extends [never] ? [OptionalFields] extends [never] ? M["id"] : UpdateWithBody<M, RequiredFields, OptionalFields> : UpdateWithBody<M, RequiredFields, OptionalFields>;
|
|
44
|
+
export type BulkUpdateResult<M extends Model<any>, MFields extends keyof Omit<M, "id"> = never, ExtraFields extends Fields = Fields> = Array<Result<M, MFields> & ExtraFields>;
|
|
45
|
+
export type BulkUpdateArg<M extends Model<any>, RequiredFields extends keyof Omit<M, "id">, OptionalFields extends keyof Omit<M, "id" | RequiredFields> = never, ExtraFields extends Fields = Fields> = Record<M["id"], Arg<M, RequiredFields, OptionalFields> & ExtraFields>;
|
|
46
|
+
export type DestroyResult = null;
|
|
47
|
+
export type DestroyArg<M extends Model<any>> = M["id"];
|
|
48
|
+
export type BulkDestroyResult = null;
|
|
49
|
+
export type BulkDestroyArg<M extends Model<any>> = Array<M["id"]>;
|
|
50
|
+
export declare function buildUrl(url: string, params: {
|
|
51
|
+
search?: Fields;
|
|
52
|
+
url?: Fields;
|
|
53
|
+
}): string;
|
|
54
|
+
export declare function isModelId(value: unknown): boolean;
|
|
55
|
+
export declare function listTag<Type extends string>(type: Type): Tag<Type>;
|
|
56
|
+
export type TagDataOptions = Partial<{
|
|
57
|
+
includeListTag: boolean;
|
|
58
|
+
argKeysAreIds: boolean;
|
|
59
|
+
id: string;
|
|
60
|
+
}>;
|
|
61
|
+
export declare function tagData<Type extends string, M extends Model<any>>(type: Type, options?: TagDataOptions): (result: Result<M, any> | Array<Result<M, any>> | ListResult<M, any> | null | undefined, error: FetchBaseQueryError | undefined, arg: Arg<M, any> | Array<Arg<M, any>> | Record<M["id"], Arg<M, any>> | ListArg<any> | Array<M["id"]> | string | number | undefined) => Array<Tag<Type>>;
|
|
62
|
+
export declare function modelUrls(list: string, detail: string): {
|
|
63
|
+
list: string;
|
|
64
|
+
detail: string;
|
|
65
|
+
};
|
|
66
|
+
export type HandleQueryStateOptions = Partial<{
|
|
67
|
+
loading: ReactNode;
|
|
68
|
+
error: ReactNode;
|
|
69
|
+
}>;
|
|
70
|
+
export declare function handleResultState<QueryArg, ResultType>(result: TypedUseQueryHookResult<ResultType, QueryArg, any> | TypedUseQueryStateResult<ResultType, QueryArg, any> | TypedUseMutationResult<ResultType, QueryArg, any>, children: (data: NonNullable<ResultType>) => ReactNode, options?: HandleQueryStateOptions): ReactNode;
|
|
71
|
+
export declare function isSafeHttpMethod(method: string): boolean;
|
|
72
|
+
export {};
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
declare module "@mui/material/styles" {
|
|
76
|
+
interface CustomPaletteColors {
|
|
77
|
+
tertiary: PaletteColor;
|
|
78
|
+
white: PaletteColor;
|
|
79
|
+
black: PaletteColor;
|
|
80
|
+
teacher: PaletteColor;
|
|
81
|
+
student: PaletteColor;
|
|
82
|
+
indy: PaletteColor;
|
|
83
|
+
}
|
|
84
|
+
interface Palette extends CustomPaletteColors {
|
|
85
|
+
}
|
|
86
|
+
interface PaletteOptions extends CustomPaletteColors {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
declare module "@mui/material" {
|
|
92
|
+
interface FabPropsColorOverrides extends PropsColorOverrides {
|
|
93
|
+
}
|
|
94
|
+
interface CardPropsColorOverrides extends PropsColorOverrides {
|
|
95
|
+
}
|
|
96
|
+
interface ChipPropsColorOverrides extends PropsColorOverrides {
|
|
97
|
+
}
|
|
98
|
+
interface IconPropsColorOverrides extends PropsColorOverrides {
|
|
99
|
+
}
|
|
100
|
+
interface AlertPropsColorOverrides extends PropsColorOverrides {
|
|
101
|
+
}
|
|
102
|
+
interface BadgePropsColorOverrides extends PropsColorOverrides {
|
|
103
|
+
}
|
|
104
|
+
interface RadioPropsColorOverrides extends PropsColorOverrides {
|
|
105
|
+
}
|
|
106
|
+
interface AppBarPropsColorOverrides extends PropsColorOverrides {
|
|
107
|
+
}
|
|
108
|
+
interface ButtonPropsColorOverrides extends PropsColorOverrides {
|
|
109
|
+
}
|
|
110
|
+
interface SliderPropsColorOverrides extends PropsColorOverrides {
|
|
111
|
+
}
|
|
112
|
+
interface SwitchPropsColorOverrides extends PropsColorOverrides {
|
|
113
|
+
}
|
|
114
|
+
interface SvgIconPropsColorOverrides extends PropsColorOverrides {
|
|
115
|
+
}
|
|
116
|
+
interface CheckboxPropsColorOverrides extends PropsColorOverrides {
|
|
117
|
+
}
|
|
118
|
+
interface FormLabelPropsColorOverrides extends PropsColorOverrides {
|
|
119
|
+
}
|
|
120
|
+
interface InputBasePropsColorOverrides extends PropsColorOverrides {
|
|
121
|
+
}
|
|
122
|
+
interface TextFieldPropsColorOverrides extends PropsColorOverrides {
|
|
123
|
+
}
|
|
124
|
+
interface IconButtonPropsColorOverrides extends PropsColorOverrides {
|
|
125
|
+
}
|
|
126
|
+
interface PaginationPropsColorOverrides extends PropsColorOverrides {
|
|
127
|
+
}
|
|
128
|
+
interface ButtonGroupPropsColorOverrides extends PropsColorOverrides {
|
|
129
|
+
}
|
|
130
|
+
interface FormControlPropsColorOverrides extends PropsColorOverrides {
|
|
131
|
+
}
|
|
132
|
+
interface ToggleButtonPropsColorOverrides extends PropsColorOverrides {
|
|
133
|
+
}
|
|
134
|
+
interface LinearProgressPropsColorOverrides extends PropsColorOverrides {
|
|
135
|
+
}
|
|
136
|
+
interface PaginationItemPropsColorOverrides extends PropsColorOverrides {
|
|
137
|
+
}
|
|
138
|
+
interface CircularProgressPropsColorOverrides extends PropsColorOverrides {
|
|
139
|
+
}
|
|
140
|
+
interface TabsPropsIndicatorColorOverrides extends PropsColorOverrides {
|
|
141
|
+
}
|
|
142
|
+
interface ToggleButtonGroupPropsColorOverrides extends PropsColorOverrides {
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../jsx-runtime-Dpn_P65e.js";
|
|
2
|
+
import "@mui/material";
|
|
3
|
+
import "react";
|
|
4
|
+
import "./general.es.js";
|
|
5
|
+
import "yup";
|
|
6
|
+
import { b as e, h as m, a as p, i as d, l as h, m as b, t as f } from "../api-Cbyt3rw0.js";
|
|
7
|
+
export {
|
|
8
|
+
e as buildUrl,
|
|
9
|
+
m as handleResultState,
|
|
10
|
+
p as isModelId,
|
|
11
|
+
d as isSafeHttpMethod,
|
|
12
|
+
h as listTag,
|
|
13
|
+
b as modelUrls,
|
|
14
|
+
f as tagData
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=api.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("js-cookie"),n=require("../settings/index.cjs.js"),E=require("./general.cjs.js");function i(){o.remove(n.SESSION_COOKIE_NAME),o.remove(n.SESSION_METADATA_COOKIE_NAME)}function c(){return o.get(n.CSRF_COOKIE_NAME)}function g(t,e){return`oauth2.${t}.${e}`}const u=["S256"],C=[43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128];async function O(t){const e=E.generateSecureRandomString(t),r=new TextEncoder().encode(e),a=await window.crypto.subtle.digest("SHA-256",r);return{verifier:e,challenge:btoa(String.fromCharCode(...new Uint8Array(a))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),method:"S256"}}exports.OAUTH2_CODE_CHALLENGE_LENGTHS=C;exports.OAUTH2_CODE_CHALLENGE_METHODS=u;exports.generateOAuth2CodeChallenge=O;exports.getCsrfCookie=c;exports.logout=i;exports.makeOAuth2StorageKey=g;
|
|
2
|
+
//# sourceMappingURL=auth.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.cjs.js","sources":["../../src/utils/auth.ts"],"sourcesContent":["import Cookies from \"js-cookie\"\n\nimport {\n CSRF_COOKIE_NAME,\n SESSION_COOKIE_NAME,\n SESSION_METADATA_COOKIE_NAME,\n} from \"../settings\"\nimport { generateSecureRandomString } from \"./general\"\n\nexport function logout() {\n Cookies.remove(SESSION_COOKIE_NAME)\n Cookies.remove(SESSION_METADATA_COOKIE_NAME)\n}\n\n// https://docs.djangoproject.com/en/3.2/ref/csrf/\nexport function getCsrfCookie() {\n return Cookies.get(CSRF_COOKIE_NAME)\n}\n\nexport function makeOAuth2StorageKey(provider: string, key: string) {\n return `oauth2.${provider}.${key}`\n}\n\nexport const OAUTH2_CODE_CHALLENGE_METHODS = [\"S256\"] as const\n\nexport type OAuth2CodeChallengeMethods =\n (typeof OAUTH2_CODE_CHALLENGE_METHODS)[number]\n\nexport const OAUTH2_CODE_CHALLENGE_LENGTHS = [\n 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,\n 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,\n 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,\n 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,\n] as const\n\nexport type OAuth2CodeChallengeLengths =\n (typeof OAUTH2_CODE_CHALLENGE_LENGTHS)[number]\n\nexport type OAuth2RequestCodeUrlSearchParams = {\n client_id: string\n redirect_uri: string\n scope: string\n response_type: string\n access_type: string\n prompt?: string\n state: string\n code_challenge: string\n code_challenge_method: string\n}\n\nexport type OAuth2ReceiveCodeUrlSearchParams = {\n code: string\n state: string\n}\n\nexport type OAuth2CodeChallenge = {\n verifier: string\n challenge: string\n method: OAuth2CodeChallengeMethods\n}\n\nexport async function generateOAuth2CodeChallenge(\n length: OAuth2CodeChallengeLengths,\n): Promise<OAuth2CodeChallenge> {\n const verifier = generateSecureRandomString(length)\n const data = new TextEncoder().encode(verifier)\n const digest = await window.crypto.subtle.digest(\"SHA-256\", data)\n\n return {\n verifier,\n challenge: btoa(String.fromCharCode(...new Uint8Array(digest)))\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=+$/, \"\"),\n method: \"S256\",\n }\n}\n"],"names":["logout","Cookies","SESSION_COOKIE_NAME","SESSION_METADATA_COOKIE_NAME","getCsrfCookie","CSRF_COOKIE_NAME","makeOAuth2StorageKey","provider","key","OAUTH2_CODE_CHALLENGE_METHODS","OAUTH2_CODE_CHALLENGE_LENGTHS","generateOAuth2CodeChallenge","length","verifier","generateSecureRandomString","data","digest"],"mappings":"iLASO,SAASA,GAAS,CACvBC,EAAQ,OAAOC,qBAAmB,EAClCD,EAAQ,OAAOE,8BAA4B,CAC7C,CAGO,SAASC,GAAgB,CAC9B,OAAOH,EAAQ,IAAII,kBAAgB,CACrC,CAEO,SAASC,EAAqBC,EAAkBC,EAAa,CAClE,MAAO,UAAUD,CAAQ,IAAIC,CAAG,EAClC,CAEO,MAAMC,EAAgC,CAAC,MAAM,EAKvCC,EAAgC,CAC3C,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GACxE,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GACxE,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GACxE,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IACtE,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GACnE,EA4BA,eAAsBC,EACpBC,EAC8B,CAC9B,MAAMC,EAAWC,EAAAA,2BAA2BF,CAAM,EAC5CG,EAAO,IAAI,cAAc,OAAOF,CAAQ,EACxCG,EAAS,MAAM,OAAO,OAAO,OAAO,OAAO,UAAWD,CAAI,EAEhE,MAAO,CACL,SAAAF,EACA,UAAW,KAAK,OAAO,aAAa,GAAG,IAAI,WAAWG,CAAM,CAAC,CAAC,EAC3D,QAAQ,MAAO,GAAG,EAClB,QAAQ,MAAO,GAAG,EAClB,QAAQ,MAAO,EAAE,EACpB,OAAQ,MAAA,CAEZ"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare function logout(): void;
|
|
2
|
+
export declare function getCsrfCookie(): string | undefined;
|
|
3
|
+
export declare function makeOAuth2StorageKey(provider: string, key: string): string;
|
|
4
|
+
export declare const OAUTH2_CODE_CHALLENGE_METHODS: readonly ["S256"];
|
|
5
|
+
export type OAuth2CodeChallengeMethods = (typeof OAUTH2_CODE_CHALLENGE_METHODS)[number];
|
|
6
|
+
export declare const OAUTH2_CODE_CHALLENGE_LENGTHS: readonly [43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128];
|
|
7
|
+
export type OAuth2CodeChallengeLengths = (typeof OAUTH2_CODE_CHALLENGE_LENGTHS)[number];
|
|
8
|
+
export type OAuth2RequestCodeUrlSearchParams = {
|
|
9
|
+
client_id: string;
|
|
10
|
+
redirect_uri: string;
|
|
11
|
+
scope: string;
|
|
12
|
+
response_type: string;
|
|
13
|
+
access_type: string;
|
|
14
|
+
prompt?: string;
|
|
15
|
+
state: string;
|
|
16
|
+
code_challenge: string;
|
|
17
|
+
code_challenge_method: string;
|
|
18
|
+
};
|
|
19
|
+
export type OAuth2ReceiveCodeUrlSearchParams = {
|
|
20
|
+
code: string;
|
|
21
|
+
state: string;
|
|
22
|
+
};
|
|
23
|
+
export type OAuth2CodeChallenge = {
|
|
24
|
+
verifier: string;
|
|
25
|
+
challenge: string;
|
|
26
|
+
method: OAuth2CodeChallengeMethods;
|
|
27
|
+
};
|
|
28
|
+
export declare function generateOAuth2CodeChallenge(length: OAuth2CodeChallengeLengths): Promise<OAuth2CodeChallenge>;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
declare module "@mui/material/styles" {
|
|
32
|
+
interface CustomPaletteColors {
|
|
33
|
+
tertiary: PaletteColor;
|
|
34
|
+
white: PaletteColor;
|
|
35
|
+
black: PaletteColor;
|
|
36
|
+
teacher: PaletteColor;
|
|
37
|
+
student: PaletteColor;
|
|
38
|
+
indy: PaletteColor;
|
|
39
|
+
}
|
|
40
|
+
interface Palette extends CustomPaletteColors {
|
|
41
|
+
}
|
|
42
|
+
interface PaletteOptions extends CustomPaletteColors {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
declare module "@mui/material" {
|
|
48
|
+
interface FabPropsColorOverrides extends PropsColorOverrides {
|
|
49
|
+
}
|
|
50
|
+
interface CardPropsColorOverrides extends PropsColorOverrides {
|
|
51
|
+
}
|
|
52
|
+
interface ChipPropsColorOverrides extends PropsColorOverrides {
|
|
53
|
+
}
|
|
54
|
+
interface IconPropsColorOverrides extends PropsColorOverrides {
|
|
55
|
+
}
|
|
56
|
+
interface AlertPropsColorOverrides extends PropsColorOverrides {
|
|
57
|
+
}
|
|
58
|
+
interface BadgePropsColorOverrides extends PropsColorOverrides {
|
|
59
|
+
}
|
|
60
|
+
interface RadioPropsColorOverrides extends PropsColorOverrides {
|
|
61
|
+
}
|
|
62
|
+
interface AppBarPropsColorOverrides extends PropsColorOverrides {
|
|
63
|
+
}
|
|
64
|
+
interface ButtonPropsColorOverrides extends PropsColorOverrides {
|
|
65
|
+
}
|
|
66
|
+
interface SliderPropsColorOverrides extends PropsColorOverrides {
|
|
67
|
+
}
|
|
68
|
+
interface SwitchPropsColorOverrides extends PropsColorOverrides {
|
|
69
|
+
}
|
|
70
|
+
interface SvgIconPropsColorOverrides extends PropsColorOverrides {
|
|
71
|
+
}
|
|
72
|
+
interface CheckboxPropsColorOverrides extends PropsColorOverrides {
|
|
73
|
+
}
|
|
74
|
+
interface FormLabelPropsColorOverrides extends PropsColorOverrides {
|
|
75
|
+
}
|
|
76
|
+
interface InputBasePropsColorOverrides extends PropsColorOverrides {
|
|
77
|
+
}
|
|
78
|
+
interface TextFieldPropsColorOverrides extends PropsColorOverrides {
|
|
79
|
+
}
|
|
80
|
+
interface IconButtonPropsColorOverrides extends PropsColorOverrides {
|
|
81
|
+
}
|
|
82
|
+
interface PaginationPropsColorOverrides extends PropsColorOverrides {
|
|
83
|
+
}
|
|
84
|
+
interface ButtonGroupPropsColorOverrides extends PropsColorOverrides {
|
|
85
|
+
}
|
|
86
|
+
interface FormControlPropsColorOverrides extends PropsColorOverrides {
|
|
87
|
+
}
|
|
88
|
+
interface ToggleButtonPropsColorOverrides extends PropsColorOverrides {
|
|
89
|
+
}
|
|
90
|
+
interface LinearProgressPropsColorOverrides extends PropsColorOverrides {
|
|
91
|
+
}
|
|
92
|
+
interface PaginationItemPropsColorOverrides extends PropsColorOverrides {
|
|
93
|
+
}
|
|
94
|
+
interface CircularProgressPropsColorOverrides extends PropsColorOverrides {
|
|
95
|
+
}
|
|
96
|
+
interface TabsPropsIndicatorColorOverrides extends PropsColorOverrides {
|
|
97
|
+
}
|
|
98
|
+
interface ToggleButtonGroupPropsColorOverrides extends PropsColorOverrides {
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import o from "js-cookie";
|
|
2
|
+
import { CSRF_COOKIE_NAME as a, SESSION_COOKIE_NAME as c, SESSION_METADATA_COOKIE_NAME as i } from "../settings/index.es.js";
|
|
3
|
+
import { generateSecureRandomString as E } from "./general.es.js";
|
|
4
|
+
function g() {
|
|
5
|
+
o.remove(c), o.remove(i);
|
|
6
|
+
}
|
|
7
|
+
function A() {
|
|
8
|
+
return o.get(a);
|
|
9
|
+
}
|
|
10
|
+
function _(t, e) {
|
|
11
|
+
return `oauth2.${t}.${e}`;
|
|
12
|
+
}
|
|
13
|
+
const u = ["S256"], m = [
|
|
14
|
+
43,
|
|
15
|
+
44,
|
|
16
|
+
45,
|
|
17
|
+
46,
|
|
18
|
+
47,
|
|
19
|
+
48,
|
|
20
|
+
49,
|
|
21
|
+
50,
|
|
22
|
+
51,
|
|
23
|
+
52,
|
|
24
|
+
53,
|
|
25
|
+
54,
|
|
26
|
+
55,
|
|
27
|
+
56,
|
|
28
|
+
57,
|
|
29
|
+
58,
|
|
30
|
+
59,
|
|
31
|
+
60,
|
|
32
|
+
61,
|
|
33
|
+
62,
|
|
34
|
+
63,
|
|
35
|
+
64,
|
|
36
|
+
65,
|
|
37
|
+
66,
|
|
38
|
+
67,
|
|
39
|
+
68,
|
|
40
|
+
69,
|
|
41
|
+
70,
|
|
42
|
+
71,
|
|
43
|
+
72,
|
|
44
|
+
73,
|
|
45
|
+
74,
|
|
46
|
+
75,
|
|
47
|
+
76,
|
|
48
|
+
77,
|
|
49
|
+
78,
|
|
50
|
+
79,
|
|
51
|
+
80,
|
|
52
|
+
81,
|
|
53
|
+
82,
|
|
54
|
+
83,
|
|
55
|
+
84,
|
|
56
|
+
85,
|
|
57
|
+
86,
|
|
58
|
+
87,
|
|
59
|
+
88,
|
|
60
|
+
89,
|
|
61
|
+
90,
|
|
62
|
+
91,
|
|
63
|
+
92,
|
|
64
|
+
93,
|
|
65
|
+
94,
|
|
66
|
+
95,
|
|
67
|
+
96,
|
|
68
|
+
97,
|
|
69
|
+
98,
|
|
70
|
+
99,
|
|
71
|
+
100,
|
|
72
|
+
101,
|
|
73
|
+
102,
|
|
74
|
+
103,
|
|
75
|
+
104,
|
|
76
|
+
105,
|
|
77
|
+
106,
|
|
78
|
+
107,
|
|
79
|
+
108,
|
|
80
|
+
109,
|
|
81
|
+
110,
|
|
82
|
+
111,
|
|
83
|
+
112,
|
|
84
|
+
113,
|
|
85
|
+
114,
|
|
86
|
+
115,
|
|
87
|
+
116,
|
|
88
|
+
117,
|
|
89
|
+
118,
|
|
90
|
+
119,
|
|
91
|
+
120,
|
|
92
|
+
121,
|
|
93
|
+
122,
|
|
94
|
+
123,
|
|
95
|
+
124,
|
|
96
|
+
125,
|
|
97
|
+
126,
|
|
98
|
+
127,
|
|
99
|
+
128
|
|
100
|
+
];
|
|
101
|
+
async function s(t) {
|
|
102
|
+
const e = E(t), r = new TextEncoder().encode(e), n = await window.crypto.subtle.digest("SHA-256", r);
|
|
103
|
+
return {
|
|
104
|
+
verifier: e,
|
|
105
|
+
challenge: btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""),
|
|
106
|
+
method: "S256"
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
m as OAUTH2_CODE_CHALLENGE_LENGTHS,
|
|
111
|
+
u as OAUTH2_CODE_CHALLENGE_METHODS,
|
|
112
|
+
s as generateOAuth2CodeChallenge,
|
|
113
|
+
A as getCsrfCookie,
|
|
114
|
+
g as logout,
|
|
115
|
+
_ as makeOAuth2StorageKey
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=auth.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.es.js","sources":["../../src/utils/auth.ts"],"sourcesContent":["import Cookies from \"js-cookie\"\n\nimport {\n CSRF_COOKIE_NAME,\n SESSION_COOKIE_NAME,\n SESSION_METADATA_COOKIE_NAME,\n} from \"../settings\"\nimport { generateSecureRandomString } from \"./general\"\n\nexport function logout() {\n Cookies.remove(SESSION_COOKIE_NAME)\n Cookies.remove(SESSION_METADATA_COOKIE_NAME)\n}\n\n// https://docs.djangoproject.com/en/3.2/ref/csrf/\nexport function getCsrfCookie() {\n return Cookies.get(CSRF_COOKIE_NAME)\n}\n\nexport function makeOAuth2StorageKey(provider: string, key: string) {\n return `oauth2.${provider}.${key}`\n}\n\nexport const OAUTH2_CODE_CHALLENGE_METHODS = [\"S256\"] as const\n\nexport type OAuth2CodeChallengeMethods =\n (typeof OAUTH2_CODE_CHALLENGE_METHODS)[number]\n\nexport const OAUTH2_CODE_CHALLENGE_LENGTHS = [\n 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,\n 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,\n 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,\n 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,\n] as const\n\nexport type OAuth2CodeChallengeLengths =\n (typeof OAUTH2_CODE_CHALLENGE_LENGTHS)[number]\n\nexport type OAuth2RequestCodeUrlSearchParams = {\n client_id: string\n redirect_uri: string\n scope: string\n response_type: string\n access_type: string\n prompt?: string\n state: string\n code_challenge: string\n code_challenge_method: string\n}\n\nexport type OAuth2ReceiveCodeUrlSearchParams = {\n code: string\n state: string\n}\n\nexport type OAuth2CodeChallenge = {\n verifier: string\n challenge: string\n method: OAuth2CodeChallengeMethods\n}\n\nexport async function generateOAuth2CodeChallenge(\n length: OAuth2CodeChallengeLengths,\n): Promise<OAuth2CodeChallenge> {\n const verifier = generateSecureRandomString(length)\n const data = new TextEncoder().encode(verifier)\n const digest = await window.crypto.subtle.digest(\"SHA-256\", data)\n\n return {\n verifier,\n challenge: btoa(String.fromCharCode(...new Uint8Array(digest)))\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=+$/, \"\"),\n method: \"S256\",\n }\n}\n"],"names":["logout","Cookies","SESSION_COOKIE_NAME","SESSION_METADATA_COOKIE_NAME","getCsrfCookie","CSRF_COOKIE_NAME","makeOAuth2StorageKey","provider","key","OAUTH2_CODE_CHALLENGE_METHODS","OAUTH2_CODE_CHALLENGE_LENGTHS","generateOAuth2CodeChallenge","length","verifier","generateSecureRandomString","data","digest"],"mappings":";;;AASO,SAASA,IAAS;AACvB,EAAAC,EAAQ,OAAOC,CAAmB,GAClCD,EAAQ,OAAOE,CAA4B;AAC7C;AAGO,SAASC,IAAgB;AAC9B,SAAOH,EAAQ,IAAII,CAAgB;AACrC;AAEO,SAASC,EAAqBC,GAAkBC,GAAa;AAClE,SAAO,UAAUD,CAAQ,IAAIC,CAAG;AAClC;AAEO,MAAMC,IAAgC,CAAC,MAAM,GAKvCC,IAAgC;AAAA,EAC3C;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EACxE;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EACxE;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EAAI;AAAA,EACxE;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EACtE;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACnE;AA4BA,eAAsBC,EACpBC,GAC8B;AAC9B,QAAMC,IAAWC,EAA2BF,CAAM,GAC5CG,IAAO,IAAI,cAAc,OAAOF,CAAQ,GACxCG,IAAS,MAAM,OAAO,OAAO,OAAO,OAAO,WAAWD,CAAI;AAEhE,SAAO;AAAA,IACL,UAAAF;AAAA,IACA,WAAW,KAAK,OAAO,aAAa,GAAG,IAAI,WAAWG,CAAM,CAAC,CAAC,EAC3D,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,GAAG,EAClB,QAAQ,OAAO,EAAE;AAAA,IACpB,QAAQ;AAAA,EAAA;AAEZ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("yup"),f=require("./general.cjs.js");function m(t){return typeof t=="object"&&t!==null&&"status"in t&&t.status===400&&"data"in t&&typeof t.data=="object"&&t.data!==null}function g(t,n){if(!m(t))throw t;const i=Object.fromEntries(Object.entries(t.data).map(([e,a])=>(Array.isArray(a)&&(a=a.join(". ")),[e,a])));n(i)}function F(t,n,i){const{include:e,onlyDirtyValues:a=!1,then:s,catch:y,finally:d}=i||{};let{exclude:c=[]}=i||{};return(l,u)=>{let o=i&&i.clean?i.clean(l):l;a&&(c=[...c,...j(l,n).filter(r=>!c.includes(r))]),e&&(c=c.filter(r=>!e.includes(r))),c.length&&(o=f.excludeKeyPaths(o,c)),t(o).unwrap().then(r=>{s&&s(r,l,u)}).catch(r=>{y&&y(r,l,u),g(r,u.setErrors)}).finally(()=>{d&&d(l,u)})}}function D(t,n){return async i=>{try{await t.validate(i,n)}catch(e){if(e instanceof E.ValidationError)return e.errors.join(". ");throw e}}}function b(t,n,i){return i||(i=f.getKeyPaths(t)),Object.fromEntries(i.map(e=>[e,h(t,n,e)]))}function h(t,n,i){const e=f.getNestedProperty(t,i),a=f.getNestedProperty(n,i);return e!==a}function j(t,n,i){return Object.entries(b(t,n,i)).filter(([e,a])=>!a).map(([e])=>e)}exports.getCleanNames=j;exports.getDirty=b;exports.isDirty=h;exports.isFormError=m;exports.schemaToFieldValidator=D;exports.setFormErrors=g;exports.submitForm=F;
|
|
2
|
+
//# sourceMappingURL=form.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.cjs.js","sources":["../../src/utils/form.ts"],"sourcesContent":["import type { FieldValidator, FormikHelpers } from \"formik\"\nimport { type Schema, type ValidateOptions, ValidationError } from \"yup\"\nimport type { TypedMutationTrigger } from \"@reduxjs/toolkit/query/react\"\n\nimport { excludeKeyPaths, getKeyPaths, getNestedProperty } from \"./general\"\n\nexport type FormValues = Record<string, any>\n\nexport function isFormError(error: unknown): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"status\" in error &&\n error.status === 400 &&\n \"data\" in error &&\n typeof error.data === \"object\" &&\n error.data !== null\n )\n}\n\nexport function setFormErrors(\n error: unknown,\n setErrors: (errors: object) => void,\n): void {\n if (!isFormError(error)) throw error\n\n const data = Object.fromEntries(\n Object.entries((error as { data: object }).data).map(([field, errors]) => {\n if (Array.isArray(errors)) errors = errors.join(\". \")\n return [field, errors]\n }),\n )\n\n setErrors(data)\n}\n\nexport type SubmitFormOptions<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n> = Partial<{\n exclude: string[]\n include: string[]\n onlyDirtyValues: boolean\n then: (\n result: ResultType,\n values: Values,\n helpers: FormikHelpers<Values>,\n ) => void\n catch: (\n error: unknown,\n values: Values,\n helpers: FormikHelpers<Values>,\n ) => void\n finally: (values: Values, helpers: FormikHelpers<Values>) => void\n}> &\n (Values extends QueryArg\n ? { clean?: (values: Values) => QueryArg }\n : { clean: (values: Values) => QueryArg })\n\nexport type SubmitFormHandler<Values extends FormValues> = (\n values: Values,\n helpers: FormikHelpers<Values>,\n) => void | Promise<any>\n\nexport function submitForm<\n Values extends QueryArg,\n QueryArg extends FormValues,\n ResultType,\n>(\n trigger: TypedMutationTrigger<ResultType, QueryArg, any>,\n initialValues: Values,\n options?: SubmitFormOptions<Values, QueryArg, ResultType>,\n): SubmitFormHandler<Values>\n\nexport function submitForm<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n>(\n trigger: TypedMutationTrigger<ResultType, QueryArg, any>,\n initialValues: Values,\n options: SubmitFormOptions<Values, QueryArg, ResultType>,\n): SubmitFormHandler<Values>\n\nexport function submitForm<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n>(\n trigger: TypedMutationTrigger<ResultType, QueryArg, any>,\n initialValues: Values,\n options?: SubmitFormOptions<Values, QueryArg, ResultType>,\n): SubmitFormHandler<Values> {\n const {\n include,\n onlyDirtyValues = false,\n then,\n catch: _catch,\n finally: _finally,\n } = options || {}\n let { exclude = [] } = options || {}\n\n return (values, helpers) => {\n let arg =\n options && options.clean\n ? options.clean(values as QueryArg & FormValues)\n : (values as unknown as QueryArg)\n\n if (onlyDirtyValues) {\n exclude = [\n ...exclude,\n ...getCleanNames(values, initialValues).filter(\n cleanName => !exclude.includes(cleanName),\n ),\n ]\n }\n\n if (include) exclude = exclude.filter(name => !include.includes(name))\n\n if (exclude.length) arg = excludeKeyPaths(arg, exclude) as QueryArg\n\n trigger(arg)\n .unwrap()\n .then(result => {\n if (then) then(result, values, helpers)\n })\n .catch(error => {\n if (_catch) _catch(error, values, helpers)\n setFormErrors(error, helpers.setErrors)\n })\n .finally(() => {\n if (_finally) _finally(values, helpers)\n })\n }\n}\n\nexport function schemaToFieldValidator(\n schema: Schema,\n options?: ValidateOptions,\n): FieldValidator {\n return async value => {\n try {\n await schema.validate(value, options)\n } catch (error) {\n if (error instanceof ValidationError) {\n return error.errors.join(\". \")\n }\n\n throw error\n }\n }\n}\n\n// Checking if individual fields are dirty is not currently supported.\n// https://github.com/jaredpalmer/formik/issues/1421\nexport function getDirty<Values extends FormValues>(\n values: Values,\n initialValues: Values,\n names?: string[],\n): Record<string, boolean> {\n if (!names) names = getKeyPaths(values)\n\n return Object.fromEntries(\n names.map(name => [name, isDirty(values, initialValues, name)]),\n )\n}\n\nexport function isDirty<Values extends FormValues>(\n values: Values,\n initialValues: Values,\n name: string,\n): boolean {\n const value: unknown = getNestedProperty(values, name)\n const initialValue: unknown = getNestedProperty(initialValues, name)\n\n return value !== initialValue\n}\n\nexport function getCleanNames<Values extends FormValues>(\n values: Values,\n initialValues: Values,\n names?: string[],\n): string[] {\n return Object.entries(getDirty(values, initialValues, names))\n .filter(\n ([\n _, // eslint-disable-line @typescript-eslint/no-unused-vars\n isDirty,\n ]) => !isDirty,\n )\n .map(([name]) => name)\n}\n"],"names":["isFormError","error","setFormErrors","setErrors","data","field","errors","submitForm","trigger","initialValues","options","include","onlyDirtyValues","then","_catch","_finally","exclude","values","helpers","arg","getCleanNames","cleanName","name","excludeKeyPaths","result","schemaToFieldValidator","schema","value","ValidationError","getDirty","names","getKeyPaths","isDirty","getNestedProperty","initialValue","_"],"mappings":"qIAQO,SAASA,EAAYC,EAAyB,CACnD,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,WAAYA,GACZA,EAAM,SAAW,KACjB,SAAUA,GACV,OAAOA,EAAM,MAAS,UACtBA,EAAM,OAAS,IAEnB,CAEO,SAASC,EACdD,EACAE,EACM,CACN,GAAI,CAACH,EAAYC,CAAK,EAAG,MAAMA,EAE/B,MAAMG,EAAO,OAAO,YAClB,OAAO,QAASH,EAA2B,IAAI,EAAE,IAAI,CAAC,CAACI,EAAOC,CAAM,KAC9D,MAAM,QAAQA,CAAM,IAAGA,EAASA,EAAO,KAAK,IAAI,GAC7C,CAACD,EAAOC,CAAM,EACtB,CAAA,EAGHH,EAAUC,CAAI,CAChB,CAmDO,SAASG,EAKdC,EACAC,EACAC,EAC2B,CAC3B,KAAM,CACJ,QAAAC,EACA,gBAAAC,EAAkB,GAClB,KAAAC,EACA,MAAOC,EACP,QAASC,CAAA,EACPL,GAAW,CAAA,EACf,GAAI,CAAE,QAAAM,EAAU,EAAC,EAAMN,GAAW,CAAA,EAElC,MAAO,CAACO,EAAQC,IAAY,CAC1B,IAAIC,EACFT,GAAWA,EAAQ,MACfA,EAAQ,MAAMO,CAA+B,EAC5CA,EAEHL,IACFI,EAAU,CACR,GAAGA,EACH,GAAGI,EAAcH,EAAQR,CAAa,EAAE,OACtCY,GAAa,CAACL,EAAQ,SAASK,CAAS,CAAA,CAC1C,GAIAV,MAAmBK,EAAQ,UAAe,CAACL,EAAQ,SAASW,CAAI,CAAC,GAEjEN,EAAQ,SAAQG,EAAMI,EAAAA,gBAAgBJ,EAAKH,CAAO,GAEtDR,EAAQW,CAAG,EACR,OAAA,EACA,KAAKK,GAAU,CACVX,GAAMA,EAAKW,EAAQP,EAAQC,CAAO,CACxC,CAAC,EACA,MAAMjB,GAAS,CACVa,GAAQA,EAAOb,EAAOgB,EAAQC,CAAO,EACzChB,EAAcD,EAAOiB,EAAQ,SAAS,CACxC,CAAC,EACA,QAAQ,IAAM,CACTH,GAAUA,EAASE,EAAQC,CAAO,CACxC,CAAC,CACL,CACF,CAEO,SAASO,EACdC,EACAhB,EACgB,CAChB,MAAO,OAAMiB,GAAS,CACpB,GAAI,CACF,MAAMD,EAAO,SAASC,EAAOjB,CAAO,CACtC,OAAST,EAAO,CACd,GAAIA,aAAiB2B,EAAAA,gBACnB,OAAO3B,EAAM,OAAO,KAAK,IAAI,EAG/B,MAAMA,CACR,CACF,CACF,CAIO,SAAS4B,EACdZ,EACAR,EACAqB,EACyB,CACzB,OAAKA,IAAOA,EAAQC,EAAAA,YAAYd,CAAM,GAE/B,OAAO,YACZa,EAAM,IAAIR,GAAQ,CAACA,EAAMU,EAAQf,EAAQR,EAAea,CAAI,CAAC,CAAC,CAAA,CAElE,CAEO,SAASU,EACdf,EACAR,EACAa,EACS,CACT,MAAMK,EAAiBM,EAAAA,kBAAkBhB,EAAQK,CAAI,EAC/CY,EAAwBD,EAAAA,kBAAkBxB,EAAea,CAAI,EAEnE,OAAOK,IAAUO,CACnB,CAEO,SAASd,EACdH,EACAR,EACAqB,EACU,CACV,OAAO,OAAO,QAAQD,EAASZ,EAAQR,EAAeqB,CAAK,CAAC,EACzD,OACC,CAAC,CACCK,EACAH,CAAA,IACI,CAACA,CAAA,EAER,IAAI,CAAC,CAACV,CAAI,IAAMA,CAAI,CACzB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { FieldValidator, FormikHelpers } from 'formik';
|
|
2
|
+
import { Schema, ValidateOptions } from 'yup';
|
|
3
|
+
import { TypedMutationTrigger } from '@reduxjs/toolkit/query/react';
|
|
4
|
+
export type FormValues = Record<string, any>;
|
|
5
|
+
export declare function isFormError(error: unknown): boolean;
|
|
6
|
+
export declare function setFormErrors(error: unknown, setErrors: (errors: object) => void): void;
|
|
7
|
+
export type SubmitFormOptions<Values extends FormValues, QueryArg extends FormValues, ResultType> = Partial<{
|
|
8
|
+
exclude: string[];
|
|
9
|
+
include: string[];
|
|
10
|
+
onlyDirtyValues: boolean;
|
|
11
|
+
then: (result: ResultType, values: Values, helpers: FormikHelpers<Values>) => void;
|
|
12
|
+
catch: (error: unknown, values: Values, helpers: FormikHelpers<Values>) => void;
|
|
13
|
+
finally: (values: Values, helpers: FormikHelpers<Values>) => void;
|
|
14
|
+
}> & (Values extends QueryArg ? {
|
|
15
|
+
clean?: (values: Values) => QueryArg;
|
|
16
|
+
} : {
|
|
17
|
+
clean: (values: Values) => QueryArg;
|
|
18
|
+
});
|
|
19
|
+
export type SubmitFormHandler<Values extends FormValues> = (values: Values, helpers: FormikHelpers<Values>) => void | Promise<any>;
|
|
20
|
+
export declare function submitForm<Values extends QueryArg, QueryArg extends FormValues, ResultType>(trigger: TypedMutationTrigger<ResultType, QueryArg, any>, initialValues: Values, options?: SubmitFormOptions<Values, QueryArg, ResultType>): SubmitFormHandler<Values>;
|
|
21
|
+
export declare function submitForm<Values extends FormValues, QueryArg extends FormValues, ResultType>(trigger: TypedMutationTrigger<ResultType, QueryArg, any>, initialValues: Values, options: SubmitFormOptions<Values, QueryArg, ResultType>): SubmitFormHandler<Values>;
|
|
22
|
+
export declare function schemaToFieldValidator(schema: Schema, options?: ValidateOptions): FieldValidator;
|
|
23
|
+
export declare function getDirty<Values extends FormValues>(values: Values, initialValues: Values, names?: string[]): Record<string, boolean>;
|
|
24
|
+
export declare function isDirty<Values extends FormValues>(values: Values, initialValues: Values, name: string): boolean;
|
|
25
|
+
export declare function getCleanNames<Values extends FormValues>(values: Values, initialValues: Values, names?: string[]): string[];
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
declare module "@mui/material/styles" {
|
|
29
|
+
interface CustomPaletteColors {
|
|
30
|
+
tertiary: PaletteColor;
|
|
31
|
+
white: PaletteColor;
|
|
32
|
+
black: PaletteColor;
|
|
33
|
+
teacher: PaletteColor;
|
|
34
|
+
student: PaletteColor;
|
|
35
|
+
indy: PaletteColor;
|
|
36
|
+
}
|
|
37
|
+
interface Palette extends CustomPaletteColors {
|
|
38
|
+
}
|
|
39
|
+
interface PaletteOptions extends CustomPaletteColors {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
declare module "@mui/material" {
|
|
45
|
+
interface FabPropsColorOverrides extends PropsColorOverrides {
|
|
46
|
+
}
|
|
47
|
+
interface CardPropsColorOverrides extends PropsColorOverrides {
|
|
48
|
+
}
|
|
49
|
+
interface ChipPropsColorOverrides extends PropsColorOverrides {
|
|
50
|
+
}
|
|
51
|
+
interface IconPropsColorOverrides extends PropsColorOverrides {
|
|
52
|
+
}
|
|
53
|
+
interface AlertPropsColorOverrides extends PropsColorOverrides {
|
|
54
|
+
}
|
|
55
|
+
interface BadgePropsColorOverrides extends PropsColorOverrides {
|
|
56
|
+
}
|
|
57
|
+
interface RadioPropsColorOverrides extends PropsColorOverrides {
|
|
58
|
+
}
|
|
59
|
+
interface AppBarPropsColorOverrides extends PropsColorOverrides {
|
|
60
|
+
}
|
|
61
|
+
interface ButtonPropsColorOverrides extends PropsColorOverrides {
|
|
62
|
+
}
|
|
63
|
+
interface SliderPropsColorOverrides extends PropsColorOverrides {
|
|
64
|
+
}
|
|
65
|
+
interface SwitchPropsColorOverrides extends PropsColorOverrides {
|
|
66
|
+
}
|
|
67
|
+
interface SvgIconPropsColorOverrides extends PropsColorOverrides {
|
|
68
|
+
}
|
|
69
|
+
interface CheckboxPropsColorOverrides extends PropsColorOverrides {
|
|
70
|
+
}
|
|
71
|
+
interface FormLabelPropsColorOverrides extends PropsColorOverrides {
|
|
72
|
+
}
|
|
73
|
+
interface InputBasePropsColorOverrides extends PropsColorOverrides {
|
|
74
|
+
}
|
|
75
|
+
interface TextFieldPropsColorOverrides extends PropsColorOverrides {
|
|
76
|
+
}
|
|
77
|
+
interface IconButtonPropsColorOverrides extends PropsColorOverrides {
|
|
78
|
+
}
|
|
79
|
+
interface PaginationPropsColorOverrides extends PropsColorOverrides {
|
|
80
|
+
}
|
|
81
|
+
interface ButtonGroupPropsColorOverrides extends PropsColorOverrides {
|
|
82
|
+
}
|
|
83
|
+
interface FormControlPropsColorOverrides extends PropsColorOverrides {
|
|
84
|
+
}
|
|
85
|
+
interface ToggleButtonPropsColorOverrides extends PropsColorOverrides {
|
|
86
|
+
}
|
|
87
|
+
interface LinearProgressPropsColorOverrides extends PropsColorOverrides {
|
|
88
|
+
}
|
|
89
|
+
interface PaginationItemPropsColorOverrides extends PropsColorOverrides {
|
|
90
|
+
}
|
|
91
|
+
interface CircularProgressPropsColorOverrides extends PropsColorOverrides {
|
|
92
|
+
}
|
|
93
|
+
interface TabsPropsIndicatorColorOverrides extends PropsColorOverrides {
|
|
94
|
+
}
|
|
95
|
+
interface ToggleButtonGroupPropsColorOverrides extends PropsColorOverrides {
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ValidationError as m } from "yup";
|
|
2
|
+
import { excludeKeyPaths as h, getKeyPaths as j, getNestedProperty as s } from "./general.es.js";
|
|
3
|
+
function b(t) {
|
|
4
|
+
return typeof t == "object" && t !== null && "status" in t && t.status === 400 && "data" in t && typeof t.data == "object" && t.data !== null;
|
|
5
|
+
}
|
|
6
|
+
function g(t, a) {
|
|
7
|
+
if (!b(t)) throw t;
|
|
8
|
+
const i = Object.fromEntries(
|
|
9
|
+
Object.entries(t.data).map(([n, c]) => (Array.isArray(c) && (c = c.join(". ")), [n, c]))
|
|
10
|
+
);
|
|
11
|
+
a(i);
|
|
12
|
+
}
|
|
13
|
+
function p(t, a, i) {
|
|
14
|
+
const {
|
|
15
|
+
include: n,
|
|
16
|
+
onlyDirtyValues: c = !1,
|
|
17
|
+
then: o,
|
|
18
|
+
catch: y,
|
|
19
|
+
finally: d
|
|
20
|
+
} = i || {};
|
|
21
|
+
let { exclude: f = [] } = i || {};
|
|
22
|
+
return (r, l) => {
|
|
23
|
+
let u = i && i.clean ? i.clean(r) : r;
|
|
24
|
+
c && (f = [
|
|
25
|
+
...f,
|
|
26
|
+
...F(r, a).filter(
|
|
27
|
+
(e) => !f.includes(e)
|
|
28
|
+
)
|
|
29
|
+
]), n && (f = f.filter((e) => !n.includes(e))), f.length && (u = h(u, f)), t(u).unwrap().then((e) => {
|
|
30
|
+
o && o(e, r, l);
|
|
31
|
+
}).catch((e) => {
|
|
32
|
+
y && y(e, r, l), g(e, l.setErrors);
|
|
33
|
+
}).finally(() => {
|
|
34
|
+
d && d(r, l);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function x(t, a) {
|
|
39
|
+
return async (i) => {
|
|
40
|
+
try {
|
|
41
|
+
await t.validate(i, a);
|
|
42
|
+
} catch (n) {
|
|
43
|
+
if (n instanceof m)
|
|
44
|
+
return n.errors.join(". ");
|
|
45
|
+
throw n;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function E(t, a, i) {
|
|
50
|
+
return i || (i = j(t)), Object.fromEntries(
|
|
51
|
+
i.map((n) => [n, w(t, a, n)])
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function w(t, a, i) {
|
|
55
|
+
const n = s(t, i), c = s(a, i);
|
|
56
|
+
return n !== c;
|
|
57
|
+
}
|
|
58
|
+
function F(t, a, i) {
|
|
59
|
+
return Object.entries(E(t, a, i)).filter(
|
|
60
|
+
([
|
|
61
|
+
n,
|
|
62
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
63
|
+
c
|
|
64
|
+
]) => !c
|
|
65
|
+
).map(([n]) => n);
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
F as getCleanNames,
|
|
69
|
+
E as getDirty,
|
|
70
|
+
w as isDirty,
|
|
71
|
+
b as isFormError,
|
|
72
|
+
x as schemaToFieldValidator,
|
|
73
|
+
g as setFormErrors,
|
|
74
|
+
p as submitForm
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=form.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.es.js","sources":["../../src/utils/form.ts"],"sourcesContent":["import type { FieldValidator, FormikHelpers } from \"formik\"\nimport { type Schema, type ValidateOptions, ValidationError } from \"yup\"\nimport type { TypedMutationTrigger } from \"@reduxjs/toolkit/query/react\"\n\nimport { excludeKeyPaths, getKeyPaths, getNestedProperty } from \"./general\"\n\nexport type FormValues = Record<string, any>\n\nexport function isFormError(error: unknown): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"status\" in error &&\n error.status === 400 &&\n \"data\" in error &&\n typeof error.data === \"object\" &&\n error.data !== null\n )\n}\n\nexport function setFormErrors(\n error: unknown,\n setErrors: (errors: object) => void,\n): void {\n if (!isFormError(error)) throw error\n\n const data = Object.fromEntries(\n Object.entries((error as { data: object }).data).map(([field, errors]) => {\n if (Array.isArray(errors)) errors = errors.join(\". \")\n return [field, errors]\n }),\n )\n\n setErrors(data)\n}\n\nexport type SubmitFormOptions<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n> = Partial<{\n exclude: string[]\n include: string[]\n onlyDirtyValues: boolean\n then: (\n result: ResultType,\n values: Values,\n helpers: FormikHelpers<Values>,\n ) => void\n catch: (\n error: unknown,\n values: Values,\n helpers: FormikHelpers<Values>,\n ) => void\n finally: (values: Values, helpers: FormikHelpers<Values>) => void\n}> &\n (Values extends QueryArg\n ? { clean?: (values: Values) => QueryArg }\n : { clean: (values: Values) => QueryArg })\n\nexport type SubmitFormHandler<Values extends FormValues> = (\n values: Values,\n helpers: FormikHelpers<Values>,\n) => void | Promise<any>\n\nexport function submitForm<\n Values extends QueryArg,\n QueryArg extends FormValues,\n ResultType,\n>(\n trigger: TypedMutationTrigger<ResultType, QueryArg, any>,\n initialValues: Values,\n options?: SubmitFormOptions<Values, QueryArg, ResultType>,\n): SubmitFormHandler<Values>\n\nexport function submitForm<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n>(\n trigger: TypedMutationTrigger<ResultType, QueryArg, any>,\n initialValues: Values,\n options: SubmitFormOptions<Values, QueryArg, ResultType>,\n): SubmitFormHandler<Values>\n\nexport function submitForm<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n>(\n trigger: TypedMutationTrigger<ResultType, QueryArg, any>,\n initialValues: Values,\n options?: SubmitFormOptions<Values, QueryArg, ResultType>,\n): SubmitFormHandler<Values> {\n const {\n include,\n onlyDirtyValues = false,\n then,\n catch: _catch,\n finally: _finally,\n } = options || {}\n let { exclude = [] } = options || {}\n\n return (values, helpers) => {\n let arg =\n options && options.clean\n ? options.clean(values as QueryArg & FormValues)\n : (values as unknown as QueryArg)\n\n if (onlyDirtyValues) {\n exclude = [\n ...exclude,\n ...getCleanNames(values, initialValues).filter(\n cleanName => !exclude.includes(cleanName),\n ),\n ]\n }\n\n if (include) exclude = exclude.filter(name => !include.includes(name))\n\n if (exclude.length) arg = excludeKeyPaths(arg, exclude) as QueryArg\n\n trigger(arg)\n .unwrap()\n .then(result => {\n if (then) then(result, values, helpers)\n })\n .catch(error => {\n if (_catch) _catch(error, values, helpers)\n setFormErrors(error, helpers.setErrors)\n })\n .finally(() => {\n if (_finally) _finally(values, helpers)\n })\n }\n}\n\nexport function schemaToFieldValidator(\n schema: Schema,\n options?: ValidateOptions,\n): FieldValidator {\n return async value => {\n try {\n await schema.validate(value, options)\n } catch (error) {\n if (error instanceof ValidationError) {\n return error.errors.join(\". \")\n }\n\n throw error\n }\n }\n}\n\n// Checking if individual fields are dirty is not currently supported.\n// https://github.com/jaredpalmer/formik/issues/1421\nexport function getDirty<Values extends FormValues>(\n values: Values,\n initialValues: Values,\n names?: string[],\n): Record<string, boolean> {\n if (!names) names = getKeyPaths(values)\n\n return Object.fromEntries(\n names.map(name => [name, isDirty(values, initialValues, name)]),\n )\n}\n\nexport function isDirty<Values extends FormValues>(\n values: Values,\n initialValues: Values,\n name: string,\n): boolean {\n const value: unknown = getNestedProperty(values, name)\n const initialValue: unknown = getNestedProperty(initialValues, name)\n\n return value !== initialValue\n}\n\nexport function getCleanNames<Values extends FormValues>(\n values: Values,\n initialValues: Values,\n names?: string[],\n): string[] {\n return Object.entries(getDirty(values, initialValues, names))\n .filter(\n ([\n _, // eslint-disable-line @typescript-eslint/no-unused-vars\n isDirty,\n ]) => !isDirty,\n )\n .map(([name]) => name)\n}\n"],"names":["isFormError","error","setFormErrors","setErrors","data","field","errors","submitForm","trigger","initialValues","options","include","onlyDirtyValues","then","_catch","_finally","exclude","values","helpers","arg","getCleanNames","cleanName","name","excludeKeyPaths","result","schemaToFieldValidator","schema","value","ValidationError","getDirty","names","getKeyPaths","isDirty","getNestedProperty","initialValue","_"],"mappings":";;AAQO,SAASA,EAAYC,GAAyB;AACnD,SACE,OAAOA,KAAU,YACjBA,MAAU,QACV,YAAYA,KACZA,EAAM,WAAW,OACjB,UAAUA,KACV,OAAOA,EAAM,QAAS,YACtBA,EAAM,SAAS;AAEnB;AAEO,SAASC,EACdD,GACAE,GACM;AACN,MAAI,CAACH,EAAYC,CAAK,EAAG,OAAMA;AAE/B,QAAMG,IAAO,OAAO;AAAA,IAClB,OAAO,QAASH,EAA2B,IAAI,EAAE,IAAI,CAAC,CAACI,GAAOC,CAAM,OAC9D,MAAM,QAAQA,CAAM,MAAGA,IAASA,EAAO,KAAK,IAAI,IAC7C,CAACD,GAAOC,CAAM,EACtB;AAAA,EAAA;AAGH,EAAAH,EAAUC,CAAI;AAChB;AAmDO,SAASG,EAKdC,GACAC,GACAC,GAC2B;AAC3B,QAAM;AAAA,IACJ,SAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,MAAAC;AAAA,IACA,OAAOC;AAAA,IACP,SAASC;AAAA,EAAA,IACPL,KAAW,CAAA;AACf,MAAI,EAAE,SAAAM,IAAU,GAAC,IAAMN,KAAW,CAAA;AAElC,SAAO,CAACO,GAAQC,MAAY;AAC1B,QAAIC,IACFT,KAAWA,EAAQ,QACfA,EAAQ,MAAMO,CAA+B,IAC5CA;AAEP,IAAIL,MACFI,IAAU;AAAA,MACR,GAAGA;AAAA,MACH,GAAGI,EAAcH,GAAQR,CAAa,EAAE;AAAA,QACtC,CAAAY,MAAa,CAACL,EAAQ,SAASK,CAAS;AAAA,MAAA;AAAA,IAC1C,IAIAV,UAAmBK,EAAQ,OAAO,OAAQ,CAACL,EAAQ,SAASW,CAAI,CAAC,IAEjEN,EAAQ,WAAQG,IAAMI,EAAgBJ,GAAKH,CAAO,IAEtDR,EAAQW,CAAG,EACR,OAAA,EACA,KAAK,CAAAK,MAAU;AACd,MAAIX,KAAMA,EAAKW,GAAQP,GAAQC,CAAO;AAAA,IACxC,CAAC,EACA,MAAM,CAAAjB,MAAS;AACd,MAAIa,KAAQA,EAAOb,GAAOgB,GAAQC,CAAO,GACzChB,EAAcD,GAAOiB,EAAQ,SAAS;AAAA,IACxC,CAAC,EACA,QAAQ,MAAM;AACb,MAAIH,KAAUA,EAASE,GAAQC,CAAO;AAAA,IACxC,CAAC;AAAA,EACL;AACF;AAEO,SAASO,EACdC,GACAhB,GACgB;AAChB,SAAO,OAAMiB,MAAS;AACpB,QAAI;AACF,YAAMD,EAAO,SAASC,GAAOjB,CAAO;AAAA,IACtC,SAAST,GAAO;AACd,UAAIA,aAAiB2B;AACnB,eAAO3B,EAAM,OAAO,KAAK,IAAI;AAG/B,YAAMA;AAAA,IACR;AAAA,EACF;AACF;AAIO,SAAS4B,EACdZ,GACAR,GACAqB,GACyB;AACzB,SAAKA,MAAOA,IAAQC,EAAYd,CAAM,IAE/B,OAAO;AAAA,IACZa,EAAM,IAAI,CAAAR,MAAQ,CAACA,GAAMU,EAAQf,GAAQR,GAAea,CAAI,CAAC,CAAC;AAAA,EAAA;AAElE;AAEO,SAASU,EACdf,GACAR,GACAa,GACS;AACT,QAAMK,IAAiBM,EAAkBhB,GAAQK,CAAI,GAC/CY,IAAwBD,EAAkBxB,GAAea,CAAI;AAEnE,SAAOK,MAAUO;AACnB;AAEO,SAASd,EACdH,GACAR,GACAqB,GACU;AACV,SAAO,OAAO,QAAQD,EAASZ,GAAQR,GAAeqB,CAAK,CAAC,EACzD;AAAA,IACC,CAAC;AAAA,MACCK;AAAA;AAAA,MACAH;AAAAA,IAAA,MACI,CAACA;AAAAA,EAAA,EAER,IAAI,CAAC,CAACV,CAAI,MAAMA,CAAI;AACzB;"}
|