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
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { type FC, useState } from "react"
|
|
2
|
-
import { IconButton, InputAdornment } from "@mui/material"
|
|
3
|
-
import {
|
|
4
|
-
Visibility as VisibilityIcon,
|
|
5
|
-
VisibilityOff as VisibilityOffIcon,
|
|
6
|
-
} from "@mui/icons-material"
|
|
7
|
-
import { string as YupString } from "yup"
|
|
8
|
-
|
|
9
|
-
import RepeatField, { type RepeatFieldProps } from "./RepeatField"
|
|
10
|
-
import TextField, { type TextFieldProps } from "./TextField"
|
|
11
|
-
|
|
12
|
-
export type PasswordFieldProps = Omit<
|
|
13
|
-
TextFieldProps,
|
|
14
|
-
"type" | "name" | "schema" | "autoComplete"
|
|
15
|
-
> &
|
|
16
|
-
Partial<Pick<TextFieldProps, "name" | "schema">> & {
|
|
17
|
-
withRepeatField?: boolean
|
|
18
|
-
repeatFieldProps?: Omit<RepeatFieldProps, "name" | "type">
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const PasswordField: FC<PasswordFieldProps> = ({
|
|
22
|
-
name = "password",
|
|
23
|
-
label = "Password",
|
|
24
|
-
placeholder = "Enter your password",
|
|
25
|
-
schema = YupString(),
|
|
26
|
-
InputProps = {},
|
|
27
|
-
withRepeatField = false,
|
|
28
|
-
repeatFieldProps = {},
|
|
29
|
-
...otherTextFieldProps
|
|
30
|
-
}) => {
|
|
31
|
-
const [isVisible, setIsVisible] = useState(false)
|
|
32
|
-
|
|
33
|
-
const type = isVisible ? "text" : "password"
|
|
34
|
-
const endAdornment = (
|
|
35
|
-
<InputAdornment position="end">
|
|
36
|
-
<IconButton
|
|
37
|
-
onClick={() => {
|
|
38
|
-
setIsVisible(previousIsVisible => !previousIsVisible)
|
|
39
|
-
}}
|
|
40
|
-
edge="end"
|
|
41
|
-
>
|
|
42
|
-
{isVisible ? <VisibilityIcon /> : <VisibilityOffIcon />}
|
|
43
|
-
</IconButton>
|
|
44
|
-
</InputAdornment>
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
<TextField
|
|
50
|
-
autoComplete="off"
|
|
51
|
-
type={type}
|
|
52
|
-
name={name}
|
|
53
|
-
label={label}
|
|
54
|
-
schema={schema}
|
|
55
|
-
placeholder={placeholder}
|
|
56
|
-
InputProps={{ endAdornment, ...InputProps }}
|
|
57
|
-
{...otherTextFieldProps}
|
|
58
|
-
/>
|
|
59
|
-
{withRepeatField && (
|
|
60
|
-
<RepeatField
|
|
61
|
-
name={name}
|
|
62
|
-
type={type}
|
|
63
|
-
{...repeatFieldProps}
|
|
64
|
-
InputProps={{ endAdornment, ...repeatFieldProps.InputProps }}
|
|
65
|
-
/>
|
|
66
|
-
)}
|
|
67
|
-
</>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default PasswordField
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Dispatch,
|
|
3
|
-
type FC,
|
|
4
|
-
type SetStateAction,
|
|
5
|
-
useEffect,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react"
|
|
8
|
-
import { Field, type FieldConfig, type FieldProps } from "formik"
|
|
9
|
-
import { TextField as MuiTextField, type TextFieldProps } from "@mui/material"
|
|
10
|
-
import { type ValidateOptions, string as YupString } from "yup"
|
|
11
|
-
|
|
12
|
-
import { type FormValues, schemaToFieldValidator } from "../../utils/form"
|
|
13
|
-
import { getNestedProperty } from "../../utils/general"
|
|
14
|
-
|
|
15
|
-
export type RepeatFieldProps = Omit<
|
|
16
|
-
TextFieldProps,
|
|
17
|
-
| "name"
|
|
18
|
-
| "value"
|
|
19
|
-
| "onChange"
|
|
20
|
-
| "onBlur"
|
|
21
|
-
| "error"
|
|
22
|
-
| "helperText"
|
|
23
|
-
| "defaultValue"
|
|
24
|
-
| "required"
|
|
25
|
-
> & {
|
|
26
|
-
name: string
|
|
27
|
-
validateOptions?: ValidateOptions
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const TextField: FC<
|
|
31
|
-
RepeatFieldProps & {
|
|
32
|
-
repeatName: string
|
|
33
|
-
setValue: Dispatch<SetStateAction<string>>
|
|
34
|
-
fieldProps: FieldProps
|
|
35
|
-
}
|
|
36
|
-
> = ({
|
|
37
|
-
id,
|
|
38
|
-
repeatName,
|
|
39
|
-
setValue,
|
|
40
|
-
fieldProps,
|
|
41
|
-
name,
|
|
42
|
-
label,
|
|
43
|
-
placeholder,
|
|
44
|
-
type,
|
|
45
|
-
...otherTextFieldProps
|
|
46
|
-
}) => {
|
|
47
|
-
const { form } = fieldProps
|
|
48
|
-
|
|
49
|
-
const dotPath = name.split(".")
|
|
50
|
-
const value = getNestedProperty(form.values as FormValues, dotPath) as string
|
|
51
|
-
|
|
52
|
-
const repeatDotPath = repeatName.split(".")
|
|
53
|
-
const repeatValue = getNestedProperty(
|
|
54
|
-
form.values as FormValues,
|
|
55
|
-
repeatDotPath,
|
|
56
|
-
) as string
|
|
57
|
-
const repeatTouched = getNestedProperty(
|
|
58
|
-
form.touched,
|
|
59
|
-
repeatDotPath,
|
|
60
|
-
) as boolean
|
|
61
|
-
const repeatError = getNestedProperty(form.errors, repeatDotPath) as
|
|
62
|
-
| string
|
|
63
|
-
| undefined
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
setValue(value)
|
|
67
|
-
}, [setValue, value])
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<MuiTextField
|
|
71
|
-
required
|
|
72
|
-
type={type}
|
|
73
|
-
label={label ?? `Repeat ${name.replace("_", " ")}`}
|
|
74
|
-
placeholder={placeholder ?? `Enter your ${name.replace("_", " ")} again`}
|
|
75
|
-
id={id ?? repeatName}
|
|
76
|
-
name={repeatName}
|
|
77
|
-
value={repeatValue}
|
|
78
|
-
onChange={form.handleChange}
|
|
79
|
-
onBlur={form.handleBlur}
|
|
80
|
-
error={repeatTouched && Boolean(repeatError)}
|
|
81
|
-
helperText={(repeatTouched && repeatError) as false | string}
|
|
82
|
-
{...otherTextFieldProps}
|
|
83
|
-
/>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// https://formik.org/docs/examples/with-material-ui
|
|
88
|
-
const RepeatField: FC<RepeatFieldProps> = ({
|
|
89
|
-
name,
|
|
90
|
-
type = "text",
|
|
91
|
-
validateOptions,
|
|
92
|
-
...otherTextFieldProps
|
|
93
|
-
}) => {
|
|
94
|
-
const [value, setValue] = useState("")
|
|
95
|
-
|
|
96
|
-
const repeatName = `${name}_repeat`
|
|
97
|
-
|
|
98
|
-
const fieldConfig: FieldConfig = {
|
|
99
|
-
name: repeatName,
|
|
100
|
-
type,
|
|
101
|
-
validate: schemaToFieldValidator(
|
|
102
|
-
YupString().required().equals([value], "does not match"),
|
|
103
|
-
validateOptions,
|
|
104
|
-
),
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<Field {...fieldConfig}>
|
|
109
|
-
{(fieldProps: FieldProps) => (
|
|
110
|
-
<TextField
|
|
111
|
-
name={name}
|
|
112
|
-
type={type}
|
|
113
|
-
repeatName={repeatName}
|
|
114
|
-
setValue={setValue}
|
|
115
|
-
fieldProps={fieldProps}
|
|
116
|
-
{...otherTextFieldProps}
|
|
117
|
-
/>
|
|
118
|
-
)}
|
|
119
|
-
</Field>
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export default RepeatField
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Button, type ButtonProps } from "@mui/material"
|
|
2
|
-
import { Field, type FieldProps } from "formik"
|
|
3
|
-
import type { FC } from "react"
|
|
4
|
-
|
|
5
|
-
import { type FormValues } from "../../utils/form"
|
|
6
|
-
|
|
7
|
-
export interface SubmitButtonProps
|
|
8
|
-
extends Omit<ButtonProps, "type" | "onClick"> {}
|
|
9
|
-
|
|
10
|
-
const SubmitButton: FC<SubmitButtonProps> = ({
|
|
11
|
-
children = "Submit",
|
|
12
|
-
...otherButtonProps
|
|
13
|
-
}) => {
|
|
14
|
-
function getTouched(
|
|
15
|
-
values: Record<string, any>,
|
|
16
|
-
touched?: Record<string, any>,
|
|
17
|
-
) {
|
|
18
|
-
touched = touched || {}
|
|
19
|
-
for (const key in values) {
|
|
20
|
-
const value: unknown = values[key]
|
|
21
|
-
touched[key] =
|
|
22
|
-
value instanceof Object && value.constructor === Object
|
|
23
|
-
? getTouched(value, touched)
|
|
24
|
-
: true
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return touched
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Field name="submit" type="submit">
|
|
32
|
-
{({ form }: FieldProps) => (
|
|
33
|
-
<Button
|
|
34
|
-
type="button"
|
|
35
|
-
onClick={() => {
|
|
36
|
-
void form
|
|
37
|
-
.setTouched(getTouched(form.values as FormValues), true)
|
|
38
|
-
.then(errors => {
|
|
39
|
-
const hasErrors = Boolean(errors && Object.keys(errors).length)
|
|
40
|
-
// If has errors, set isSubmitting=true so fields in the form are
|
|
41
|
-
// aware that a submission was attempted. Else, set
|
|
42
|
-
// isSubmitting=false as it will be set to true when calling
|
|
43
|
-
// submitForm().
|
|
44
|
-
form.setSubmitting(hasErrors)
|
|
45
|
-
if (!hasErrors) void form.submitForm()
|
|
46
|
-
})
|
|
47
|
-
}}
|
|
48
|
-
{...otherButtonProps}
|
|
49
|
-
>
|
|
50
|
-
{children}
|
|
51
|
-
</Button>
|
|
52
|
-
)}
|
|
53
|
-
</Field>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default SubmitButton
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { type FC, useEffect, useState } from "react"
|
|
2
|
-
import { Field, type FieldConfig, type FieldProps } from "formik"
|
|
3
|
-
import {
|
|
4
|
-
TextField as MuiTextField,
|
|
5
|
-
type TextFieldProps as MuiTextFieldProps,
|
|
6
|
-
} from "@mui/material"
|
|
7
|
-
import { type StringSchema, type ValidateOptions, array as YupArray } from "yup"
|
|
8
|
-
|
|
9
|
-
import { type FormValues, schemaToFieldValidator } from "../../utils/form"
|
|
10
|
-
import { getNestedProperty } from "../../utils/general"
|
|
11
|
-
|
|
12
|
-
export type TextFieldProps = Omit<
|
|
13
|
-
MuiTextFieldProps,
|
|
14
|
-
| "name"
|
|
15
|
-
| "value"
|
|
16
|
-
| "onChange"
|
|
17
|
-
| "onBlur"
|
|
18
|
-
| "error"
|
|
19
|
-
| "defaultValue"
|
|
20
|
-
| "helperText"
|
|
21
|
-
> & {
|
|
22
|
-
name: string
|
|
23
|
-
schema: StringSchema
|
|
24
|
-
validateOptions?: ValidateOptions
|
|
25
|
-
dirty?: boolean
|
|
26
|
-
split?: string | RegExp
|
|
27
|
-
unique?: boolean
|
|
28
|
-
uniqueCaseInsensitive?: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// https://formik.org/docs/examples/with-material-ui
|
|
32
|
-
const TextField: FC<TextFieldProps> = ({
|
|
33
|
-
id,
|
|
34
|
-
name,
|
|
35
|
-
schema,
|
|
36
|
-
type = "text",
|
|
37
|
-
required = false,
|
|
38
|
-
dirty = false,
|
|
39
|
-
unique = false,
|
|
40
|
-
uniqueCaseInsensitive = false,
|
|
41
|
-
split,
|
|
42
|
-
validateOptions,
|
|
43
|
-
...otherTextFieldProps
|
|
44
|
-
}) => {
|
|
45
|
-
const [initialValue, setInitialValue] = useState<string | string[]>("")
|
|
46
|
-
|
|
47
|
-
const dotPath = name.split(".")
|
|
48
|
-
|
|
49
|
-
function buildSchema() {
|
|
50
|
-
// Build a schema for a single string.
|
|
51
|
-
let stringSchema = schema
|
|
52
|
-
// 1: Validate string is required.
|
|
53
|
-
stringSchema = required ? stringSchema.required() : stringSchema.optional()
|
|
54
|
-
// 2: Validate string is dirty.
|
|
55
|
-
if (dirty && !split)
|
|
56
|
-
stringSchema = stringSchema.notOneOf(
|
|
57
|
-
[initialValue as string],
|
|
58
|
-
"cannot be initial value",
|
|
59
|
-
)
|
|
60
|
-
// Return a schema for a single string.
|
|
61
|
-
if (!split) return stringSchema
|
|
62
|
-
|
|
63
|
-
// Build a schema for an array of strings.
|
|
64
|
-
let arraySchema = YupArray().of(stringSchema)
|
|
65
|
-
// 1: Validate array has min one string.
|
|
66
|
-
arraySchema = required
|
|
67
|
-
? arraySchema.required().min(1)
|
|
68
|
-
: arraySchema.optional()
|
|
69
|
-
// 2: Validate array has unique strings.
|
|
70
|
-
if (unique || uniqueCaseInsensitive)
|
|
71
|
-
arraySchema = arraySchema.test({
|
|
72
|
-
message: "cannot have duplicates",
|
|
73
|
-
test: values => {
|
|
74
|
-
if (
|
|
75
|
-
Array.isArray(values) &&
|
|
76
|
-
values.length >= 2 &&
|
|
77
|
-
values.every(value => typeof value === "string")
|
|
78
|
-
) {
|
|
79
|
-
return (
|
|
80
|
-
new Set(
|
|
81
|
-
uniqueCaseInsensitive
|
|
82
|
-
? values.map(value => value.toLowerCase())
|
|
83
|
-
: values,
|
|
84
|
-
).size === values.length
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return true
|
|
89
|
-
},
|
|
90
|
-
})
|
|
91
|
-
// 3: Validate array is dirty.
|
|
92
|
-
if (dirty)
|
|
93
|
-
arraySchema = arraySchema.notOneOf(
|
|
94
|
-
[initialValue as string[]],
|
|
95
|
-
"cannot be initial value",
|
|
96
|
-
)
|
|
97
|
-
// Return a schema for an array of strings.
|
|
98
|
-
return arraySchema
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const fieldConfig: FieldConfig = {
|
|
102
|
-
name,
|
|
103
|
-
type,
|
|
104
|
-
validate: schemaToFieldValidator(buildSchema(), validateOptions),
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const FieldInternal: FC<FieldProps> = ({ form }) => {
|
|
108
|
-
const initialValue = getNestedProperty(
|
|
109
|
-
form.initialValues as FormValues,
|
|
110
|
-
dotPath,
|
|
111
|
-
) as string
|
|
112
|
-
const value = getNestedProperty(
|
|
113
|
-
form.values as FormValues,
|
|
114
|
-
dotPath,
|
|
115
|
-
) as string
|
|
116
|
-
const error = getNestedProperty(form.errors, dotPath) as string | undefined
|
|
117
|
-
const touched = getNestedProperty(form.touched, dotPath) as boolean
|
|
118
|
-
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
setInitialValue(initialValue)
|
|
121
|
-
}, [initialValue])
|
|
122
|
-
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
void form.setFieldValue(
|
|
125
|
-
name,
|
|
126
|
-
split && typeof value === "string" ? value.split(split) : value,
|
|
127
|
-
true,
|
|
128
|
-
)
|
|
129
|
-
}, [value]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<MuiTextField
|
|
133
|
-
id={id ?? name}
|
|
134
|
-
name={name}
|
|
135
|
-
type={type}
|
|
136
|
-
required={required}
|
|
137
|
-
value={value}
|
|
138
|
-
onChange={form.handleChange}
|
|
139
|
-
onBlur={form.handleBlur}
|
|
140
|
-
error={touched && Boolean(error)}
|
|
141
|
-
helperText={(touched && error) as false | string}
|
|
142
|
-
{...otherTextFieldProps}
|
|
143
|
-
/>
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return <Field {...fieldConfig}>{FieldInternal}</Field>
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export default TextField
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { type ElementType, type JSX } from "react"
|
|
2
|
-
import { type ChipTypeMap } from "@mui/material"
|
|
3
|
-
|
|
4
|
-
import AutocompleteField, {
|
|
5
|
-
type AutocompleteFieldProps,
|
|
6
|
-
} from "./AutocompleteField"
|
|
7
|
-
import { UK_COUNTIES } from "../../utils/general"
|
|
8
|
-
|
|
9
|
-
export interface UkCountyFieldProps<
|
|
10
|
-
Multiple extends boolean | undefined = false,
|
|
11
|
-
DisableClearable extends boolean | undefined = false,
|
|
12
|
-
FreeSolo extends boolean | undefined = false,
|
|
13
|
-
ChipComponent extends ElementType = ChipTypeMap["defaultComponent"],
|
|
14
|
-
> extends Omit<
|
|
15
|
-
AutocompleteFieldProps<
|
|
16
|
-
string,
|
|
17
|
-
Multiple,
|
|
18
|
-
DisableClearable,
|
|
19
|
-
FreeSolo,
|
|
20
|
-
ChipComponent
|
|
21
|
-
>,
|
|
22
|
-
"options" | "textFieldProps"
|
|
23
|
-
> {
|
|
24
|
-
textFieldProps?: Omit<
|
|
25
|
-
AutocompleteFieldProps<
|
|
26
|
-
string,
|
|
27
|
-
Multiple,
|
|
28
|
-
DisableClearable,
|
|
29
|
-
FreeSolo,
|
|
30
|
-
ChipComponent
|
|
31
|
-
>["textFieldProps"],
|
|
32
|
-
"name"
|
|
33
|
-
> & {
|
|
34
|
-
name?: string
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const UkCountyField = <
|
|
39
|
-
Multiple extends boolean | undefined = false,
|
|
40
|
-
DisableClearable extends boolean | undefined = false,
|
|
41
|
-
FreeSolo extends boolean | undefined = false,
|
|
42
|
-
ChipComponent extends ElementType = ChipTypeMap["defaultComponent"],
|
|
43
|
-
>({
|
|
44
|
-
textFieldProps,
|
|
45
|
-
...otherAutocompleteFieldProps
|
|
46
|
-
}: UkCountyFieldProps<
|
|
47
|
-
Multiple,
|
|
48
|
-
DisableClearable,
|
|
49
|
-
FreeSolo,
|
|
50
|
-
ChipComponent
|
|
51
|
-
>): JSX.Element => {
|
|
52
|
-
const {
|
|
53
|
-
name = "uk_county",
|
|
54
|
-
label = "UK county",
|
|
55
|
-
placeholder = "Select your UK county",
|
|
56
|
-
...otherTextFieldProps
|
|
57
|
-
} = textFieldProps || {}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<AutocompleteField
|
|
61
|
-
options={UK_COUNTIES}
|
|
62
|
-
textFieldProps={{ name, label, placeholder, ...otherTextFieldProps }}
|
|
63
|
-
{...otherAutocompleteFieldProps}
|
|
64
|
-
/>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default UkCountyField
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
default as ApiAutocompleteField,
|
|
3
|
-
type ApiAutocompleteFieldProps,
|
|
4
|
-
} from "./ApiAutocompleteField"
|
|
5
|
-
export {
|
|
6
|
-
default as AutocompleteField,
|
|
7
|
-
type AutocompleteFieldProps,
|
|
8
|
-
} from "./AutocompleteField"
|
|
9
|
-
export {
|
|
10
|
-
default as CheckboxField,
|
|
11
|
-
type CheckboxFieldProps,
|
|
12
|
-
} from "./CheckboxField"
|
|
13
|
-
export { default as CountryField, type CountryFieldProps } from "./CountryField"
|
|
14
|
-
export {
|
|
15
|
-
default as DatePickerField,
|
|
16
|
-
type DatePickerFieldProps,
|
|
17
|
-
} from "./DatePickerField"
|
|
18
|
-
export { default as EmailField, type EmailFieldProps } from "./EmailField"
|
|
19
|
-
export {
|
|
20
|
-
default as FirstNameField,
|
|
21
|
-
type FirstNameFieldProps,
|
|
22
|
-
} from "./FirstNameField"
|
|
23
|
-
export { default as Form, type FormProps, type FormErrors } from "./Form"
|
|
24
|
-
export { default as OtpField, type OtpFieldProps } from "./OtpField"
|
|
25
|
-
export {
|
|
26
|
-
default as PasswordField,
|
|
27
|
-
type PasswordFieldProps,
|
|
28
|
-
} from "./PasswordField"
|
|
29
|
-
export { default as RepeatField, type RepeatFieldProps } from "./RepeatField"
|
|
30
|
-
export { default as SubmitButton, type SubmitButtonProps } from "./SubmitButton"
|
|
31
|
-
export { default as TextField, type TextFieldProps } from "./TextField"
|
|
32
|
-
export {
|
|
33
|
-
default as UkCountyField,
|
|
34
|
-
type UkCountyFieldProps,
|
|
35
|
-
} from "./UkCountyField"
|
package/src/components/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from "./App"
|
|
2
|
-
export { default as App } from "./App"
|
|
3
|
-
export * from "./ClickableTooltip"
|
|
4
|
-
export { default as ClickableTooltip } from "./ClickableTooltip"
|
|
5
|
-
export * from "./CopyIconButton"
|
|
6
|
-
export { default as CopyIconButton } from "./CopyIconButton"
|
|
7
|
-
export * from "./Countdown"
|
|
8
|
-
export { default as Countdown } from "./Countdown"
|
|
9
|
-
export * from "./DownloadFileButton"
|
|
10
|
-
export { default as DownloadFileButton } from "./DownloadFileButton"
|
|
11
|
-
export * from "./ElevatedAppBar"
|
|
12
|
-
export { default as ElevatedAppBar } from "./ElevatedAppBar"
|
|
13
|
-
export * from "./Image"
|
|
14
|
-
export { default as Image } from "./Image"
|
|
15
|
-
export * from "./ItemizedList"
|
|
16
|
-
export { default as InputFileButton } from "./InputFileButton"
|
|
17
|
-
export * from "./InputFileButton"
|
|
18
|
-
export { default as ItemizedList } from "./ItemizedList"
|
|
19
|
-
export * from "./OrderedGrid"
|
|
20
|
-
export { default as OrderedGrid } from "./OrderedGrid"
|
|
21
|
-
export * from "./ScrollIntoViewLink"
|
|
22
|
-
export { default as ScrollIntoViewLink } from "./ScrollIntoViewLink"
|
|
23
|
-
export * from "./SyncError"
|
|
24
|
-
export { default as SyncError } from "./SyncError"
|
|
25
|
-
export * from "./TablePagination"
|
|
26
|
-
export { default as TablePagination } from "./TablePagination"
|
|
27
|
-
export * from "./YouTubeVideo"
|
|
28
|
-
export { default as YouTubeVideo } from "./YouTubeVideo"
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Stack, Typography } from "@mui/material"
|
|
2
|
-
|
|
3
|
-
import Image, { type ImageProps } from "../Image"
|
|
4
|
-
import { LinkButton, type LinkButtonProps } from "../router"
|
|
5
|
-
import { primary, secondary, tertiary } from "../../theme/colors"
|
|
6
|
-
import Section from "./Section"
|
|
7
|
-
import palette from "../../theme/palette"
|
|
8
|
-
|
|
9
|
-
export interface BannerProps<
|
|
10
|
-
Button1State extends Record<string, any> = Record<string, any>,
|
|
11
|
-
Button2State extends Record<string, any> = Record<string, any>,
|
|
12
|
-
> {
|
|
13
|
-
header: string
|
|
14
|
-
subheader?: string
|
|
15
|
-
textAlign?: "start" | "center"
|
|
16
|
-
imageProps?: ImageProps
|
|
17
|
-
button1Props?: LinkButtonProps<"to", Button1State>
|
|
18
|
-
button2Props?: LinkButtonProps<"to", Button2State>
|
|
19
|
-
bgcolor?: "primary" | "secondary" | "tertiary"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const Banner = <
|
|
23
|
-
Button1State extends Record<string, any> = Record<string, any>,
|
|
24
|
-
Button2State extends Record<string, any> = Record<string, any>,
|
|
25
|
-
>({
|
|
26
|
-
header,
|
|
27
|
-
subheader,
|
|
28
|
-
textAlign = "start",
|
|
29
|
-
imageProps,
|
|
30
|
-
button1Props,
|
|
31
|
-
button2Props,
|
|
32
|
-
bgcolor = "primary",
|
|
33
|
-
}: BannerProps<Button1State, Button2State>) => {
|
|
34
|
-
// @ts-expect-error guaranteed to be in palette
|
|
35
|
-
const contrastText = palette[bgcolor].contrastText as string
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Section
|
|
39
|
-
boxProps={{
|
|
40
|
-
bgcolor: {
|
|
41
|
-
primary: primary[500],
|
|
42
|
-
secondary: secondary[500],
|
|
43
|
-
tertiary: tertiary[500],
|
|
44
|
-
}[bgcolor],
|
|
45
|
-
}}
|
|
46
|
-
sx={{ paddingY: 0 }}
|
|
47
|
-
>
|
|
48
|
-
<Stack
|
|
49
|
-
direction="row"
|
|
50
|
-
alignItems="center"
|
|
51
|
-
justifyContent={textAlign}
|
|
52
|
-
gap={2}
|
|
53
|
-
>
|
|
54
|
-
<Stack
|
|
55
|
-
py={{
|
|
56
|
-
xs: "80px",
|
|
57
|
-
md: imageProps !== undefined ? 0 : "100px",
|
|
58
|
-
}}
|
|
59
|
-
textAlign={textAlign}
|
|
60
|
-
>
|
|
61
|
-
<Typography
|
|
62
|
-
variant="h2"
|
|
63
|
-
color={contrastText}
|
|
64
|
-
mb={subheader !== undefined ? undefined : 0}
|
|
65
|
-
>
|
|
66
|
-
{header}
|
|
67
|
-
</Typography>
|
|
68
|
-
{subheader !== undefined && (
|
|
69
|
-
<Typography
|
|
70
|
-
color={contrastText}
|
|
71
|
-
variant="h4"
|
|
72
|
-
mb={button1Props !== undefined ? undefined : 0}
|
|
73
|
-
>
|
|
74
|
-
{subheader}
|
|
75
|
-
</Typography>
|
|
76
|
-
)}
|
|
77
|
-
<Stack direction="row" gap={2}>
|
|
78
|
-
{button1Props !== undefined && <LinkButton {...button1Props} />}
|
|
79
|
-
{button2Props !== undefined && <LinkButton {...button2Props} />}
|
|
80
|
-
</Stack>
|
|
81
|
-
</Stack>
|
|
82
|
-
{imageProps !== undefined && (
|
|
83
|
-
<Image
|
|
84
|
-
{...imageProps}
|
|
85
|
-
display={{ xs: "none", md: "block" }}
|
|
86
|
-
maxWidth="320px"
|
|
87
|
-
marginLeft="auto"
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
</Stack>
|
|
91
|
-
</Section>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export default Banner
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CloseOutlined as CloseOutlinedIcon,
|
|
3
|
-
ErrorOutline as ErrorOutlineIcon,
|
|
4
|
-
InfoOutlined as InfoOutlinedIcon,
|
|
5
|
-
} from "@mui/icons-material"
|
|
6
|
-
import { type FC, type ReactNode, useEffect, useState } from "react"
|
|
7
|
-
import { IconButton, Stack, Typography } from "@mui/material"
|
|
8
|
-
|
|
9
|
-
import Section from "./Section"
|
|
10
|
-
import palette from "../../theme/palette"
|
|
11
|
-
|
|
12
|
-
export interface NotificationProps {
|
|
13
|
-
open?: boolean
|
|
14
|
-
error?: boolean
|
|
15
|
-
onClose?: () => void
|
|
16
|
-
children: ReactNode
|
|
17
|
-
bgcolor?: "secondary" | "tertiary"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const Notification: FC<NotificationProps> = ({
|
|
21
|
-
open = true,
|
|
22
|
-
error = false,
|
|
23
|
-
onClose,
|
|
24
|
-
children,
|
|
25
|
-
bgcolor = "secondary",
|
|
26
|
-
}) => {
|
|
27
|
-
const [_open, _setOpen] = useState(open)
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
_setOpen(open)
|
|
31
|
-
}, [open])
|
|
32
|
-
|
|
33
|
-
if (!_open) return <></>
|
|
34
|
-
|
|
35
|
-
// @ts-expect-error guaranteed to be in palette
|
|
36
|
-
const contrastText = palette[bgcolor].contrastText as string
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Section
|
|
40
|
-
boxProps={{
|
|
41
|
-
bgcolor: {
|
|
42
|
-
secondary: "#ffd23b",
|
|
43
|
-
tertiary: "#08bafc",
|
|
44
|
-
}[bgcolor],
|
|
45
|
-
}}
|
|
46
|
-
sx={{ paddingY: "5px" }}
|
|
47
|
-
>
|
|
48
|
-
<Stack direction="row" alignItems="center" gap={2}>
|
|
49
|
-
{error ? (
|
|
50
|
-
<ErrorOutlineIcon htmlColor={contrastText} />
|
|
51
|
-
) : (
|
|
52
|
-
<InfoOutlinedIcon htmlColor={contrastText} />
|
|
53
|
-
)}
|
|
54
|
-
<Typography variant="body2" color={contrastText} mb={0}>
|
|
55
|
-
{children}
|
|
56
|
-
</Typography>
|
|
57
|
-
<IconButton
|
|
58
|
-
style={{ marginLeft: "auto" }}
|
|
59
|
-
onClick={() => {
|
|
60
|
-
_setOpen(false)
|
|
61
|
-
if (onClose !== undefined) onClose()
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
<CloseOutlinedIcon htmlColor={contrastText} />
|
|
65
|
-
</IconButton>
|
|
66
|
-
</Stack>
|
|
67
|
-
</Section>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default Notification
|