codeforlife 2.11.7 → 2.11.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index-Dadidnct.cjs","sources":["../src/components/form/ApiAutocompleteField.tsx","../src/components/form/AutocompleteField.tsx","../src/components/form/CheckboxField.tsx","../src/components/form/CountryField.tsx","../src/components/form/DatePickerField.tsx","../src/components/form/TextField.tsx","../src/components/form/EmailField.tsx","../src/components/form/FirstNameField.tsx","../src/components/form/Form.tsx","../src/components/form/OtpField.tsx","../src/components/form/RepeatField.tsx","../src/components/form/PasswordField.tsx","../src/components/form/SubmitButton.tsx","../src/components/form/UkCountyField.tsx"],"sourcesContent":["import { Button, type ChipTypeMap, CircularProgress } from \"@mui/material\"\nimport {\n Children,\n type ElementType,\n type ForwardRefRenderFunction,\n type HTMLAttributes,\n type JSX,\n forwardRef,\n useEffect,\n useState,\n} from \"react\"\nimport type { TypedUseLazyQuery } from \"@reduxjs/toolkit/query/react\"\n\nimport {\n AutocompleteField,\n type AutocompleteFieldProps,\n} from \"../../components/form\"\nimport type { ListArg, ListResult, ModelId } from \"../../utils/api\"\nimport SyncError from \"../SyncError\"\nimport { usePagination } from \"../../hooks/api\"\n\nexport interface ApiAutocompleteFieldProps<\n SearchKey extends keyof Omit<QueryArg, \"limit\" | \"offset\">,\n // api type args\n QueryArg extends ListArg,\n ResultType extends ListResult<any>,\n // autocomplete type args\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteFieldProps<\n ModelId,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n | \"options\"\n | \"ListboxComponent\"\n | \"filterOptions\"\n | \"getOptionLabel\"\n | \"getOptionKey\"\n | \"onInputChange\"\n > {\n useLazyListQuery: TypedUseLazyQuery<ResultType, QueryArg, any>\n filterOptions?: Omit<QueryArg, \"limit\" | \"offset\" | SearchKey>\n getOptionLabel: (result: ResultType[\"data\"][number]) => string\n getOptionKey?: (result: ResultType[\"data\"][number]) => ModelId\n searchKey: SearchKey\n}\n\nconst ApiAutocompleteField = <\n SearchKey extends keyof Omit<QueryArg, \"limit\" | \"offset\">,\n // api type args\n QueryArg extends ListArg,\n ResultType extends ListResult<any>,\n // autocomplete type args\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n useLazyListQuery,\n filterOptions,\n getOptionLabel,\n getOptionKey = result => result.id as ModelId,\n searchKey,\n ...otherAutocompleteFieldProps\n}: ApiAutocompleteFieldProps<\n SearchKey,\n // api type args\n QueryArg,\n ResultType,\n // autocomplete type args\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const [search, setSearch] = useState(\"\")\n const [trigger, { isLoading, isError }] = useLazyListQuery()\n const [{ limit, offset }, setPagination] = usePagination()\n const [{ options, hasMore }, setState] = useState<{\n options: Record<ModelId, ResultType[\"data\"][number]>\n hasMore: boolean\n }>({ options: {}, hasMore: true })\n\n // Call api\n useEffect(\n () => {\n const arg = { limit, offset, ...filterOptions } as QueryArg\n // @ts-expect-error search key can index arg\n if (search) arg[searchKey] = search\n\n trigger(arg, true)\n .unwrap()\n .then(({ data, offset, limit, count }) => {\n setState(({ options: previousOptions }) => {\n const options = { ...previousOptions }\n data.forEach(result => {\n options[getOptionKey(result)] = result\n })\n return { options, hasMore: offset + limit < count }\n })\n })\n .catch(error => {\n if (error) console.error(error)\n // TODO: gracefully handle error\n })\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n trigger,\n limit,\n offset,\n searchKey,\n search,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n ...Object.values(filterOptions || {}),\n ],\n )\n\n // Get options keys\n let optionKeys: ModelId[] = Object.keys(options)\n if (!optionKeys.length) return <></>\n if (typeof getOptionKey(Object.values(options)[0]) === \"number\") {\n optionKeys = optionKeys.map(Number)\n }\n\n function loadNextPage() {\n setPagination(({ page, limit }) => ({ page: page + 1, limit }))\n }\n\n const ListboxComponent: ForwardRefRenderFunction<\n unknown,\n HTMLAttributes<HTMLElement>\n > = ({ children, ...props }, ref) => {\n const listItems = Children.toArray(children)\n if (isLoading) listItems.push(<CircularProgress key=\"is-loading\" />)\n else {\n if (isError) listItems.push(<SyncError key=\"is-error\" />)\n if (hasMore) {\n listItems.push(\n <Button key=\"load-more\" onClick={loadNextPage}>\n Load more\n </Button>,\n )\n }\n }\n\n return (\n <ul\n {...props}\n // @ts-expect-error ref is assignable\n ref={ref}\n onScroll={event => {\n // If not already loading and scrolled to bottom\n if (\n !isLoading &&\n event.currentTarget.clientHeight + event.currentTarget.scrollTop >=\n event.currentTarget.scrollHeight\n ) {\n loadNextPage()\n }\n }}\n >\n {listItems}\n </ul>\n )\n }\n\n return (\n <AutocompleteField\n options={optionKeys}\n getOptionLabel={id => getOptionLabel(options[id])}\n onInputChange={(_, value, reason) => {\n setSearch(reason === \"input\" ? value : \"\")\n }}\n ListboxComponent={forwardRef(ListboxComponent)}\n {...otherAutocompleteFieldProps}\n />\n )\n}\n\nexport default ApiAutocompleteField\n","import {\n Autocomplete,\n type AutocompleteProps,\n type ChipTypeMap,\n TextField,\n type TextFieldProps,\n} from \"@mui/material\"\nimport { type ElementType, type JSX } from \"react\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport {\n type ValidateOptions,\n number as YupNumber,\n string as YupString,\n} from \"yup\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport interface AutocompleteFieldProps<\n Value extends string | number,\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteProps<\n Value,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n \"renderInput\" | \"defaultValue\" | \"onChange\" | \"onBlur\" | \"value\"\n > {\n textFieldProps: Omit<\n TextFieldProps,\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"defaultValue\"\n | \"type\"\n > & {\n name: string\n }\n validateOptions?: ValidateOptions\n}\n\nconst AutocompleteField = <\n Value extends string | number,\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n textFieldProps,\n options,\n validateOptions,\n ...otherAutocompleteProps\n}: AutocompleteFieldProps<\n Value,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const { id, name, required, ...otherTextFieldProps } = textFieldProps\n\n const dotPath = name.split(\".\")\n\n const message = \"not a valid option\"\n let schema =\n typeof options[0] === \"string\"\n ? YupString().oneOf(options as readonly string[], message)\n : YupNumber().oneOf(options as readonly number[], message)\n if (required) schema = schema.required()\n\n const fieldConfig: FieldConfig = {\n name,\n type: typeof options[0] === \"string\" ? \"text\" : \"number\",\n validate: schemaToFieldValidator(schema, validateOptions),\n }\n\n return (\n <Field {...fieldConfig}>\n {({ form, meta }: FieldProps) => {\n const value = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as string\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n const error = getNestedProperty(form.errors, dotPath) as\n | string\n | undefined\n\n return (\n <Autocomplete\n options={options}\n // @ts-expect-error value can be assigned\n defaultValue={\n meta.initialValue === \"\"\n ? undefined\n : (meta.initialValue as string)\n }\n renderInput={({\n id: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...otherParams\n }) => (\n <TextField\n id={id ?? name}\n name={name}\n required={required}\n type=\"text\" // Force to be string to avoid number incrementor/decrementor\n value={value}\n error={touched && Boolean(error)}\n helperText={touched && error}\n {...otherTextFieldProps}\n {...otherParams}\n />\n )}\n onChange={(_, value) => {\n void form.setFieldValue(name, value ?? undefined, true)\n }}\n onBlur={form.handleBlur}\n {...otherAutocompleteProps}\n />\n )\n }}\n </Field>\n )\n}\n\nexport default AutocompleteField\n","import {\n Checkbox,\n type CheckboxProps,\n FormControl,\n FormControlLabel,\n type FormControlLabelProps,\n FormHelperText,\n} from \"@mui/material\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport { type ValidateOptions, bool as YupBool } from \"yup\"\nimport { type FC } from \"react\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport interface CheckboxFieldProps\n extends Omit<\n CheckboxProps,\n \"defaultChecked\" | \"value\" | \"onChange\" | \"onBlur\"\n > {\n name: string\n formControlLabelProps: Omit<FormControlLabelProps, \"control\">\n errorMessage?: string\n validateOptions?: ValidateOptions\n}\n\nconst CheckboxField: FC<CheckboxFieldProps> = ({\n id,\n name,\n formControlLabelProps,\n required = false,\n errorMessage = \"this is a required field\",\n validateOptions,\n ...otherCheckboxProps\n}) => {\n const dotPath = name.split(\".\")\n\n let schema = YupBool()\n if (required) schema = schema.oneOf([true], errorMessage)\n\n const fieldConfig: FieldConfig = {\n name,\n type: \"checkbox\",\n validate: schemaToFieldValidator(schema, validateOptions),\n }\n\n return (\n <Field {...fieldConfig}>\n {({ form, meta }: FieldProps) => {\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n const error = getNestedProperty(form.errors, dotPath) as\n | string\n | undefined\n const value = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as boolean\n\n const hasError = touched && Boolean(error)\n\n // https://mui.com/material-ui/react-checkbox/#formgroup\n return (\n <FormControl error={hasError} required={required}>\n <FormControlLabel\n control={\n <Checkbox\n defaultChecked={meta.initialValue as boolean}\n id={id ?? name}\n name={name}\n value={value}\n onChange={form.handleChange}\n onBlur={form.handleBlur}\n {...otherCheckboxProps}\n />\n }\n {...formControlLabelProps}\n />\n {hasError && <FormHelperText>{error}</FormHelperText>}\n </FormControl>\n )\n }}\n </Field>\n )\n}\n\nexport default CheckboxField\n","import { type ElementType, type JSX } from \"react\"\nimport { type ChipTypeMap } from \"@mui/material\"\n\nimport AutocompleteField, {\n type AutocompleteFieldProps,\n} from \"./AutocompleteField\"\nimport {\n COUNTRY_ISO_CODES,\n COUNTRY_ISO_CODE_MAPPING,\n type CountryIsoCodes,\n} from \"../../utils/general\"\n\nexport interface CountryFieldProps<\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n \"options\" | \"textFieldProps\" | \"getOptionLabel\"\n > {\n textFieldProps?: Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >[\"textFieldProps\"],\n \"name\"\n > & {\n name?: string\n }\n}\n\nconst CountryField = <\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n textFieldProps,\n ...otherAutocompleteFieldProps\n}: CountryFieldProps<\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const {\n name = \"country\",\n label = \"Country\",\n placeholder = \"Select your country\",\n ...otherTextFieldProps\n } = textFieldProps || {}\n\n return (\n <AutocompleteField\n options={COUNTRY_ISO_CODES}\n getOptionLabel={isoCode =>\n COUNTRY_ISO_CODE_MAPPING[isoCode as CountryIsoCodes]\n }\n textFieldProps={{ name, label, placeholder, ...otherTextFieldProps }}\n {...otherAutocompleteFieldProps}\n />\n )\n}\n\nexport default CountryField\n","import \"dayjs/locale/en-gb\"\nimport {\n DatePicker,\n type DatePickerProps,\n LocalizationProvider,\n} from \"@mui/x-date-pickers\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport { type ValidateOptions, date as YupDate } from \"yup\"\nimport dayjs, { type Dayjs } from \"dayjs\"\nimport { AdapterDayjs } from \"@mui/x-date-pickers/AdapterDayjs\"\nimport { type JSX } from \"react\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport interface DatePickerFieldProps<\n TEnableAccessibleFieldDOMStructure extends boolean = true,\n> extends Omit<\n DatePickerProps<TEnableAccessibleFieldDOMStructure>,\n \"name\" | \"value\" | \"onChange\" | \"slotProps\"\n > {\n name: string\n required?: boolean\n validateOptions?: ValidateOptions\n}\n\nconst DatePickerField = <\n TEnableAccessibleFieldDOMStructure extends boolean = false,\n>({\n name,\n required,\n minDate,\n maxDate,\n validateOptions,\n ...otherDatePickerProps\n}: DatePickerFieldProps<TEnableAccessibleFieldDOMStructure>): JSX.Element => {\n const dotPath = name.split(\".\")\n\n function dateToString(date: Dayjs) {\n return date.locale(\"en-gb\").format(\"L\")\n }\n\n let schema = YupDate()\n if (required) schema = schema.required()\n if (minDate) {\n schema = schema.min(\n minDate,\n `this field must be after or equal to ${dateToString(minDate)}`,\n )\n }\n if (maxDate) {\n schema = schema.max(\n maxDate,\n `this field must be before or equal to ${dateToString(maxDate)}`,\n )\n }\n\n const fieldConfig: FieldConfig = {\n name,\n type: \"date\",\n validate: schemaToFieldValidator(schema, validateOptions),\n }\n\n return (\n <Field {...fieldConfig}>\n {({ form }: FieldProps) => {\n const error = getNestedProperty(form.errors, dotPath) as\n | string\n | undefined\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n let value: Dayjs | null | string = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as string\n\n value = value ? dayjs(value) : null\n\n function handleChange(value: Dayjs | null) {\n void form.setFieldValue(\n name,\n value && value.isValid() ? value.format(\"YYYY-MM-DD\") : null,\n true,\n )\n }\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDayjs}\n adapterLocale=\"en-gb\"\n >\n <DatePicker\n name={name}\n value={value}\n minDate={minDate}\n maxDate={maxDate}\n onChange={handleChange}\n slotProps={{\n textField: {\n id: name,\n // @ts-expect-error value is compatible\n onChange: value => {\n handleChange(value as Dayjs | null)\n },\n onBlur: form.handleBlur,\n required,\n error: touched && Boolean(error),\n helperText: (touched && error) as false | string,\n },\n }}\n {...otherDatePickerProps}\n />\n </LocalizationProvider>\n )\n }}\n </Field>\n )\n}\n\nexport default DatePickerField\n","import { type FC, useEffect, useState } from \"react\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport {\n TextField as MuiTextField,\n type TextFieldProps as MuiTextFieldProps,\n} from \"@mui/material\"\nimport { type StringSchema, type ValidateOptions, array as YupArray } from \"yup\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport type TextFieldProps = Omit<\n MuiTextFieldProps,\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"defaultValue\"\n | \"helperText\"\n> & {\n name: string\n schema: StringSchema\n validateOptions?: ValidateOptions\n dirty?: boolean\n split?: string | RegExp\n unique?: boolean\n uniqueCaseInsensitive?: boolean\n}\n\n// https://formik.org/docs/examples/with-material-ui\nconst TextField: FC<TextFieldProps> = ({\n id,\n name,\n schema,\n type = \"text\",\n required = false,\n dirty = false,\n unique = false,\n uniqueCaseInsensitive = false,\n split,\n validateOptions,\n ...otherTextFieldProps\n}) => {\n const [initialValue, setInitialValue] = useState<string | string[]>(\"\")\n\n const dotPath = name.split(\".\")\n\n function buildSchema() {\n // Build a schema for a single string.\n let stringSchema = schema\n // 1: Validate string is required.\n stringSchema = required ? stringSchema.required() : stringSchema.optional()\n // 2: Validate string is dirty.\n if (dirty && !split)\n stringSchema = stringSchema.notOneOf(\n [initialValue as string],\n \"cannot be initial value\",\n )\n // Return a schema for a single string.\n if (!split) return stringSchema\n\n // Build a schema for an array of strings.\n let arraySchema = YupArray().of(stringSchema)\n // 1: Validate array has min one string.\n arraySchema = required\n ? arraySchema.required().min(1)\n : arraySchema.optional()\n // 2: Validate array has unique strings.\n if (unique || uniqueCaseInsensitive)\n arraySchema = arraySchema.test({\n message: \"cannot have duplicates\",\n test: values => {\n if (\n Array.isArray(values) &&\n values.length >= 2 &&\n values.every(value => typeof value === \"string\")\n ) {\n return (\n new Set(\n uniqueCaseInsensitive\n ? values.map(value => value.toLowerCase())\n : values,\n ).size === values.length\n )\n }\n\n return true\n },\n })\n // 3: Validate array is dirty.\n if (dirty)\n arraySchema = arraySchema.notOneOf(\n [initialValue as string[]],\n \"cannot be initial value\",\n )\n // Return a schema for an array of strings.\n return arraySchema\n }\n\n const fieldConfig: FieldConfig = {\n name,\n type,\n validate: schemaToFieldValidator(buildSchema(), validateOptions),\n }\n\n const FieldInternal: FC<FieldProps> = ({ form }) => {\n const initialValue = getNestedProperty(\n form.initialValues as FormValues,\n dotPath,\n ) as string\n const value = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as string\n const error = getNestedProperty(form.errors, dotPath) as string | undefined\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n\n useEffect(() => {\n setInitialValue(initialValue)\n }, [initialValue])\n\n useEffect(() => {\n void form.setFieldValue(\n name,\n split && typeof value === \"string\" ? value.split(split) : value,\n true,\n )\n }, [value]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <MuiTextField\n id={id ?? name}\n name={name}\n type={type}\n required={required}\n value={value}\n onChange={form.handleChange}\n onBlur={form.handleBlur}\n error={touched && Boolean(error)}\n helperText={(touched && error) as false | string}\n {...otherTextFieldProps}\n />\n )\n }\n\n return <Field {...fieldConfig}>{FieldInternal}</Field>\n}\n\nexport default TextField\n","import { EmailOutlined as EmailOutlinedIcon } from \"@mui/icons-material\"\nimport type { FC } from \"react\"\nimport { InputAdornment } from \"@mui/material\"\nimport { string as YupString } from \"yup\"\n\nimport TextField, { type TextFieldProps } from \"./TextField\"\n\nexport type EmailFieldProps = Omit<TextFieldProps, \"type\" | \"name\" | \"schema\"> &\n Partial<Pick<TextFieldProps, \"name\">>\n\nconst EmailField: FC<EmailFieldProps> = ({\n name = \"email\",\n label = \"Email address\",\n placeholder = \"Enter your email address\",\n InputProps = {},\n ...otherTextFieldProps\n}) => {\n return (\n <TextField\n type=\"email\"\n schema={YupString().email()}\n name={name}\n label={label}\n placeholder={placeholder}\n InputProps={{\n endAdornment: (\n <InputAdornment position=\"end\">\n <EmailOutlinedIcon />\n </InputAdornment>\n ),\n ...InputProps,\n }}\n {...otherTextFieldProps}\n />\n )\n}\n\nexport default EmailField\n","import type { FC } from \"react\"\nimport { InputAdornment } from \"@mui/material\"\nimport { PersonOutlined as PersonOutlinedIcon } from \"@mui/icons-material\"\n\nimport TextField, { type TextFieldProps } from \"./TextField\"\nimport { schemas } from \"../../api\"\n\nexport type FirstNameFieldProps = Omit<\n TextFieldProps,\n \"type\" | \"name\" | \"schema\"\n> &\n Partial<Pick<TextFieldProps, \"name\">>\n\nconst FirstNameField: FC<FirstNameFieldProps> = ({\n name = \"first_name\",\n label = \"First name\",\n placeholder = \"Enter your first name\",\n InputProps = {},\n ...otherTextFieldProps\n}) => {\n return (\n <TextField\n schema={schemas.user.first_name}\n name={name}\n label={label}\n placeholder={placeholder}\n InputProps={{\n endAdornment: (\n <InputAdornment position=\"end\">\n <PersonOutlinedIcon />\n </InputAdornment>\n ),\n ...InputProps,\n }}\n {...otherTextFieldProps}\n />\n )\n}\n\nexport default FirstNameField\n","import {\n type FC,\n type JSX,\n type ReactNode,\n type RefObject,\n useEffect,\n useRef,\n} from \"react\"\nimport { FormHelperText, type FormHelperTextProps } from \"@mui/material\"\nimport {\n Formik,\n type FormikConfig,\n type FormikErrors,\n Form as FormikForm,\n type FormikProps,\n} from \"formik\"\nimport type { TypedUseMutation } from \"@reduxjs/toolkit/query/react\"\n\nimport {\n type FormValues,\n type SubmitFormOptions,\n submitForm,\n} from \"../../utils/form\"\nimport { getKeyPaths } from \"../../utils/general\"\n\nconst SCROLL_INTO_VIEW_OPTIONS: ScrollIntoViewOptions = {\n behavior: \"smooth\",\n block: \"start\",\n}\n\ntype NonFieldErrorsProps = Omit<FormHelperTextProps, \"error\" | \"ref\"> & {\n scrollIntoViewOptions?: ScrollIntoViewOptions\n}\n\nconst NonFieldErrors: FC<NonFieldErrorsProps> = ({\n scrollIntoViewOptions = SCROLL_INTO_VIEW_OPTIONS,\n ...formHelperTextProps\n}) => {\n const pRef = useRef<HTMLParagraphElement>(null)\n\n useEffect(() => {\n if (pRef.current) pRef.current.scrollIntoView(scrollIntoViewOptions)\n }, [scrollIntoViewOptions])\n\n return <FormHelperText ref={pRef} error {...formHelperTextProps} />\n}\n\nexport type FormErrors<Values> = FormikErrors<\n Omit<Values, \"__all__\"> & { __all__: string }\n>\n\ntype _FormikProps<Values> = Omit<FormikProps<Values>, \"errors\"> & {\n errors: FormErrors<Values>\n}\n\ntype BaseFormProps<Values> = Omit<FormikConfig<Values>, \"children\"> & {\n children: ReactNode | ((props: _FormikProps<Values>) => ReactNode)\n scrollIntoViewOptions?: ScrollIntoViewOptions\n nonFieldErrorsProps?: Omit<NonFieldErrorsProps, \"children\">\n fieldRefs?: Array<{\n name: string\n inputRef: RefObject<HTMLInputElement | null>\n }>\n}\n\nconst BaseForm = <Values extends FormValues>({\n children,\n scrollIntoViewOptions = SCROLL_INTO_VIEW_OPTIONS,\n nonFieldErrorsProps,\n fieldRefs = [],\n ...otherFormikProps\n}: BaseFormProps<Values>) => (\n <Formik {...otherFormikProps}>\n {/* @ts-expect-error value is assignable */}\n {(formik: _FormikProps<Values>) => {\n const hasErrors = Boolean(Object.keys(formik.errors).length)\n const hasNonFieldErrors =\n hasErrors && typeof formik.errors.__all__ === \"string\"\n\n // If a submission was attempted and refs to the fields were provided.\n if (\n hasErrors &&\n !hasNonFieldErrors &&\n formik.isSubmitting &&\n fieldRefs.length\n ) {\n const errorNames = getKeyPaths(formik.errors)\n\n const input = fieldRefs.find(({ name }) => errorNames.includes(name))\n ?.inputRef.current\n\n if (input) input.scrollIntoView(scrollIntoViewOptions)\n }\n\n return (\n <>\n {hasNonFieldErrors && (\n <NonFieldErrors {...nonFieldErrorsProps}>\n {formik.errors.__all__ as string}\n </NonFieldErrors>\n )}\n <FormikForm>\n {typeof children === \"function\" ? children(formik) : children}\n </FormikForm>\n </>\n )\n }}\n </Formik>\n)\n\ntype SubmitFormProps<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n> = Omit<BaseFormProps<Values>, \"onSubmit\"> & {\n useMutation: TypedUseMutation<ResultType, QueryArg, any>\n} & (Values extends QueryArg\n ? { submitOptions?: SubmitFormOptions<Values, QueryArg, ResultType> }\n : { submitOptions: SubmitFormOptions<Values, QueryArg, ResultType> })\n\nconst SubmitForm = <\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n>({\n useMutation,\n submitOptions,\n ...baseFormProps\n}: SubmitFormProps<Values, QueryArg, ResultType>): JSX.Element => {\n const [trigger] = useMutation()\n\n return (\n <BaseForm\n {...baseFormProps}\n onSubmit={submitForm<Values, QueryArg, ResultType>(\n trigger,\n baseFormProps.initialValues,\n submitOptions as SubmitFormOptions<Values, QueryArg, ResultType>,\n )}\n />\n )\n}\n\nexport type FormProps<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n> = BaseFormProps<Values> | SubmitFormProps<Values, QueryArg, ResultType>\n\nconst Form: {\n <Values extends FormValues>(props: BaseFormProps<Values>): JSX.Element\n <Values extends FormValues, QueryArg extends FormValues, ResultType>(\n props: SubmitFormProps<Values, QueryArg, ResultType>,\n ): JSX.Element\n} = <\n Values extends FormValues = FormValues,\n QueryArg extends FormValues = FormValues,\n ResultType = any,\n>(\n props: FormProps<Values, QueryArg, ResultType>,\n): JSX.Element => {\n return \"onSubmit\" in props ? <BaseForm {...props} /> : SubmitForm(props)\n}\n\nexport default Form\n","import { type FC } from \"react\"\nimport { string as YupString } from \"yup\"\n\nimport TextField, { type TextFieldProps } from \"./TextField\"\n\nexport type OtpFieldProps = Omit<\n TextFieldProps,\n \"name\" | \"schema\" | \"required\"\n> &\n Partial<Pick<TextFieldProps, \"name\">>\n\nconst OtpField: FC<OtpFieldProps> = ({\n name = \"otp\",\n label = \"OTP\",\n placeholder = \"Enter your OTP\",\n ...otherTextFieldProps\n}) => (\n <TextField\n name={name}\n label={label}\n schema={YupString().matches(/^[0-9]{6}$/, \"Must be exactly 6 digits.\")}\n placeholder={placeholder}\n required\n {...otherTextFieldProps}\n />\n)\n\nexport default OtpField\n","import {\n type Dispatch,\n type FC,\n type SetStateAction,\n useEffect,\n useState,\n} from \"react\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport { TextField as MuiTextField, type TextFieldProps } from \"@mui/material\"\nimport { type ValidateOptions, string as YupString } from \"yup\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport type RepeatFieldProps = Omit<\n TextFieldProps,\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"defaultValue\"\n | \"required\"\n> & {\n name: string\n validateOptions?: ValidateOptions\n}\n\nconst TextField: FC<\n RepeatFieldProps & {\n repeatName: string\n setValue: Dispatch<SetStateAction<string>>\n fieldProps: FieldProps\n }\n> = ({\n id,\n repeatName,\n setValue,\n fieldProps,\n name,\n label,\n placeholder,\n type,\n ...otherTextFieldProps\n}) => {\n const { form } = fieldProps\n\n const dotPath = name.split(\".\")\n const value = getNestedProperty(form.values as FormValues, dotPath) as string\n\n const repeatDotPath = repeatName.split(\".\")\n const repeatValue = getNestedProperty(\n form.values as FormValues,\n repeatDotPath,\n ) as string\n const repeatTouched = getNestedProperty(\n form.touched,\n repeatDotPath,\n ) as boolean\n const repeatError = getNestedProperty(form.errors, repeatDotPath) as\n | string\n | undefined\n\n useEffect(() => {\n setValue(value)\n }, [setValue, value])\n\n return (\n <MuiTextField\n required\n type={type}\n label={label ?? `Repeat ${name.replace(\"_\", \" \")}`}\n placeholder={placeholder ?? `Enter your ${name.replace(\"_\", \" \")} again`}\n id={id ?? repeatName}\n name={repeatName}\n value={repeatValue}\n onChange={form.handleChange}\n onBlur={form.handleBlur}\n error={repeatTouched && Boolean(repeatError)}\n helperText={(repeatTouched && repeatError) as false | string}\n {...otherTextFieldProps}\n />\n )\n}\n\n// https://formik.org/docs/examples/with-material-ui\nconst RepeatField: FC<RepeatFieldProps> = ({\n name,\n type = \"text\",\n validateOptions,\n ...otherTextFieldProps\n}) => {\n const [value, setValue] = useState(\"\")\n\n const repeatName = `${name}_repeat`\n\n const fieldConfig: FieldConfig = {\n name: repeatName,\n type,\n validate: schemaToFieldValidator(\n YupString().required().equals([value], \"does not match\"),\n validateOptions,\n ),\n }\n\n return (\n <Field {...fieldConfig}>\n {(fieldProps: FieldProps) => (\n <TextField\n name={name}\n type={type}\n repeatName={repeatName}\n setValue={setValue}\n fieldProps={fieldProps}\n {...otherTextFieldProps}\n />\n )}\n </Field>\n )\n}\n\nexport default RepeatField\n","import { type FC, useState } from \"react\"\nimport { IconButton, InputAdornment } from \"@mui/material\"\nimport {\n Visibility as VisibilityIcon,\n VisibilityOff as VisibilityOffIcon,\n} from \"@mui/icons-material\"\nimport { string as YupString } from \"yup\"\n\nimport RepeatField, { type RepeatFieldProps } from \"./RepeatField\"\nimport TextField, { type TextFieldProps } from \"./TextField\"\n\nexport type PasswordFieldProps = Omit<\n TextFieldProps,\n \"type\" | \"name\" | \"schema\" | \"autoComplete\"\n> &\n Partial<Pick<TextFieldProps, \"name\" | \"schema\">> & {\n withRepeatField?: boolean\n repeatFieldProps?: Omit<RepeatFieldProps, \"name\" | \"type\">\n }\n\nconst PasswordField: FC<PasswordFieldProps> = ({\n name = \"password\",\n label = \"Password\",\n placeholder = \"Enter your password\",\n schema = YupString(),\n InputProps = {},\n withRepeatField = false,\n repeatFieldProps = {},\n ...otherTextFieldProps\n}) => {\n const [isVisible, setIsVisible] = useState(false)\n\n const type = isVisible ? \"text\" : \"password\"\n const endAdornment = (\n <InputAdornment position=\"end\">\n <IconButton\n onClick={() => {\n setIsVisible(previousIsVisible => !previousIsVisible)\n }}\n edge=\"end\"\n >\n {isVisible ? <VisibilityIcon /> : <VisibilityOffIcon />}\n </IconButton>\n </InputAdornment>\n )\n\n return (\n <>\n <TextField\n autoComplete=\"off\"\n type={type}\n name={name}\n label={label}\n schema={schema}\n placeholder={placeholder}\n InputProps={{ endAdornment, ...InputProps }}\n {...otherTextFieldProps}\n />\n {withRepeatField && (\n <RepeatField\n name={name}\n type={type}\n {...repeatFieldProps}\n InputProps={{ endAdornment, ...repeatFieldProps.InputProps }}\n />\n )}\n </>\n )\n}\n\nexport default PasswordField\n","import { Button, type ButtonProps } from \"@mui/material\"\nimport { Field, type FieldProps } from \"formik\"\nimport type { FC } from \"react\"\n\nimport { type FormValues } from \"../../utils/form\"\n\nexport interface SubmitButtonProps\n extends Omit<ButtonProps, \"type\" | \"onClick\"> {}\n\nconst SubmitButton: FC<SubmitButtonProps> = ({\n children = \"Submit\",\n ...otherButtonProps\n}) => {\n function getTouched(\n values: Record<string, any>,\n touched?: Record<string, any>,\n ) {\n touched = touched || {}\n for (const key in values) {\n const value: unknown = values[key]\n touched[key] =\n value instanceof Object && value.constructor === Object\n ? getTouched(value, touched)\n : true\n }\n\n return touched\n }\n\n return (\n <Field name=\"submit\" type=\"submit\">\n {({ form }: FieldProps) => (\n <Button\n type=\"button\"\n onClick={() => {\n void form\n .setTouched(getTouched(form.values as FormValues), true)\n .then(errors => {\n const hasErrors = Boolean(errors && Object.keys(errors).length)\n // If has errors, set isSubmitting=true so fields in the form are\n // aware that a submission was attempted. Else, set\n // isSubmitting=false as it will be set to true when calling\n // submitForm().\n form.setSubmitting(hasErrors)\n if (!hasErrors) void form.submitForm()\n })\n }}\n {...otherButtonProps}\n >\n {children}\n </Button>\n )}\n </Field>\n )\n}\n\nexport default SubmitButton\n","import { type ElementType, type JSX } from \"react\"\nimport { type ChipTypeMap } from \"@mui/material\"\n\nimport AutocompleteField, {\n type AutocompleteFieldProps,\n} from \"./AutocompleteField\"\nimport { UK_COUNTIES } from \"../../utils/general\"\n\nexport interface UkCountyFieldProps<\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n \"options\" | \"textFieldProps\"\n > {\n textFieldProps?: Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >[\"textFieldProps\"],\n \"name\"\n > & {\n name?: string\n }\n}\n\nconst UkCountyField = <\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n textFieldProps,\n ...otherAutocompleteFieldProps\n}: UkCountyFieldProps<\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const {\n name = \"uk_county\",\n label = \"UK county\",\n placeholder = \"Select your UK county\",\n ...otherTextFieldProps\n } = textFieldProps || {}\n\n return (\n <AutocompleteField\n options={UK_COUNTIES}\n textFieldProps={{ name, label, placeholder, ...otherTextFieldProps }}\n {...otherAutocompleteFieldProps}\n />\n )\n}\n\nexport default UkCountyField\n"],"names":["ApiAutocompleteField","useLazyListQuery","filterOptions","getOptionLabel","getOptionKey","result","searchKey","otherAutocompleteFieldProps","search","setSearch","useState","trigger","isLoading","isError","limit","offset","setPagination","usePagination","options","hasMore","setState","useEffect","arg","data","count","previousOptions","error","optionKeys","jsx","Fragment","loadNextPage","page","ListboxComponent","children","props","ref","listItems","Children","CircularProgress","SyncError","Button","event","AutocompleteField","id","_","value","reason","forwardRef","textFieldProps","validateOptions","otherAutocompleteProps","name","required","otherTextFieldProps","dotPath","message","schema","YupString","YupNumber","fieldConfig","schemaToFieldValidator","Field","form","meta","getNestedProperty","touched","Autocomplete","otherParams","TextField","CheckboxField","formControlLabelProps","errorMessage","otherCheckboxProps","YupBool","hasError","jsxs","FormControl","FormControlLabel","Checkbox","FormHelperText","CountryField","label","placeholder","COUNTRY_ISO_CODES","isoCode","COUNTRY_ISO_CODE_MAPPING","DatePickerField","minDate","maxDate","otherDatePickerProps","dateToString","date","YupDate","dayjs","handleChange","LocalizationProvider","AdapterDayjs","DatePicker","type","dirty","unique","uniqueCaseInsensitive","split","initialValue","setInitialValue","buildSchema","stringSchema","arraySchema","YupArray","values","FieldInternal","MuiTextField","EmailField","InputProps","InputAdornment","EmailOutlinedIcon","FirstNameField","schemas.user","PersonOutlinedIcon","SCROLL_INTO_VIEW_OPTIONS","NonFieldErrors","scrollIntoViewOptions","formHelperTextProps","pRef","useRef","BaseForm","nonFieldErrorsProps","fieldRefs","otherFormikProps","Formik","formik","hasErrors","hasNonFieldErrors","errorNames","getKeyPaths","input","FormikForm","SubmitForm","useMutation","submitOptions","baseFormProps","submitForm","Form","OtpField","repeatName","setValue","fieldProps","repeatDotPath","repeatValue","repeatTouched","repeatError","RepeatField","PasswordField","withRepeatField","repeatFieldProps","isVisible","setIsVisible","endAdornment","IconButton","previousIsVisible","VisibilityIcon","VisibilityOffIcon","SubmitButton","otherButtonProps","getTouched","key","errors","UkCountyField","UK_COUNTIES"],"mappings":"goBAqDA,MAAMA,EAAuB,CAU3B,CACA,iBAAAC,EACA,cAAAC,EACA,eAAAC,EACA,aAAAC,KAAyBC,EAAO,GAChC,UAAAC,EACA,GAAGC,CACL,IAUmB,CACjB,KAAM,CAACC,EAAQC,CAAS,EAAIC,EAAAA,SAAS,EAAE,EACjC,CAACC,EAAS,CAAE,UAAAC,EAAW,QAAAC,CAAA,CA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EJ,ECjBMsI,EAAgB,CAKpB,CACA,eAAAvH,EACA,GAAGzC,CACL,IAKmB,CACjB,KAAM,CACJ,KAAA4C,EAAO,YACP,MAAA8B,EAAQ,YACR,YAAAC,EAAc,wBACd,GAAG7B,CAAA,EACDL,GAAkB,CAAA,EAEtB,OACEpB,EAAAA,IAACc,EAAA,CACC,QAAS8H,EAAAA,YACT,eAAgB,CAAE,KAAArH,EAAM,MAAA8B,EAAO,YAAAC,EAAa,GAAG7B,CAAA,EAC9C,GAAG9C,CAAA,CAAA,CAGV"}
1
+ {"version":3,"file":"index-BsxcGeQL.cjs","sources":["../src/components/form/ApiAutocompleteField.tsx","../src/components/form/AutocompleteField.tsx","../src/components/form/CheckboxField.tsx","../src/components/form/CountryField.tsx","../src/components/form/DatePickerField.tsx","../src/components/form/TextField.tsx","../src/components/form/EmailField.tsx","../src/components/form/FirstNameField.tsx","../src/components/form/Form.tsx","../src/components/form/OtpField.tsx","../src/components/form/RepeatField.tsx","../src/components/form/PasswordField.tsx","../src/components/form/SubmitButton.tsx","../src/components/form/UkCountyField.tsx"],"sourcesContent":["import { Button, type ChipTypeMap, CircularProgress } from \"@mui/material\"\nimport {\n Children,\n type ElementType,\n type ForwardRefRenderFunction,\n type HTMLAttributes,\n type JSX,\n forwardRef,\n useEffect,\n useState,\n} from \"react\"\nimport type { TypedUseLazyQuery } from \"@reduxjs/toolkit/query/react\"\n\nimport {\n AutocompleteField,\n type AutocompleteFieldProps,\n} from \"../../components/form\"\nimport type { ListArg, ListResult, ModelId } from \"../../utils/api\"\nimport SyncError from \"../SyncError\"\nimport { usePagination } from \"../../hooks/api\"\n\nexport interface ApiAutocompleteFieldProps<\n SearchKey extends keyof Omit<QueryArg, \"limit\" | \"offset\">,\n // api type args\n QueryArg extends ListArg,\n ResultType extends ListResult<any>,\n // autocomplete type args\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteFieldProps<\n ModelId,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n | \"options\"\n | \"ListboxComponent\"\n | \"filterOptions\"\n | \"getOptionLabel\"\n | \"getOptionKey\"\n | \"onInputChange\"\n > {\n useLazyListQuery: TypedUseLazyQuery<ResultType, QueryArg, any>\n filterOptions?: Omit<QueryArg, \"limit\" | \"offset\" | SearchKey>\n getOptionLabel: (result: ResultType[\"data\"][number]) => string\n getOptionKey?: (result: ResultType[\"data\"][number]) => ModelId\n searchKey: SearchKey\n}\n\nconst ApiAutocompleteField = <\n SearchKey extends keyof Omit<QueryArg, \"limit\" | \"offset\">,\n // api type args\n QueryArg extends ListArg,\n ResultType extends ListResult<any>,\n // autocomplete type args\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n useLazyListQuery,\n filterOptions,\n getOptionLabel,\n getOptionKey = result => result.id as ModelId,\n searchKey,\n ...otherAutocompleteFieldProps\n}: ApiAutocompleteFieldProps<\n SearchKey,\n // api type args\n QueryArg,\n ResultType,\n // autocomplete type args\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const [search, setSearch] = useState(\"\")\n const [trigger, { isLoading, isError }] = useLazyListQuery()\n const [{ limit, offset }, setPagination] = usePagination()\n const [{ options, hasMore }, setState] = useState<{\n options: Record<ModelId, ResultType[\"data\"][number]>\n hasMore: boolean\n }>({ options: {}, hasMore: true })\n\n // Call api\n useEffect(\n () => {\n const arg = { limit, offset, ...filterOptions } as QueryArg\n // @ts-expect-error search key can index arg\n if (search) arg[searchKey] = search\n\n trigger(arg, true)\n .unwrap()\n .then(({ data, offset, limit, count }) => {\n setState(({ options: previousOptions }) => {\n const options = { ...previousOptions }\n data.forEach(result => {\n options[getOptionKey(result)] = result\n })\n return { options, hasMore: offset + limit < count }\n })\n })\n .catch(error => {\n if (error) console.error(error)\n // TODO: gracefully handle error\n })\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n trigger,\n limit,\n offset,\n searchKey,\n search,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n ...Object.values(filterOptions || {}),\n ],\n )\n\n // Get options keys\n let optionKeys: ModelId[] = Object.keys(options)\n if (!optionKeys.length) return <></>\n if (typeof getOptionKey(Object.values(options)[0]) === \"number\") {\n optionKeys = optionKeys.map(Number)\n }\n\n function loadNextPage() {\n setPagination(({ page, limit }) => ({ page: page + 1, limit }))\n }\n\n const ListboxComponent: ForwardRefRenderFunction<\n unknown,\n HTMLAttributes<HTMLElement>\n > = ({ children, ...props }, ref) => {\n const listItems = Children.toArray(children)\n if (isLoading) listItems.push(<CircularProgress key=\"is-loading\" />)\n else {\n if (isError) listItems.push(<SyncError key=\"is-error\" />)\n if (hasMore) {\n listItems.push(\n <Button key=\"load-more\" onClick={loadNextPage}>\n Load more\n </Button>,\n )\n }\n }\n\n return (\n <ul\n {...props}\n // @ts-expect-error ref is assignable\n ref={ref}\n onScroll={event => {\n // If not already loading and scrolled to bottom\n if (\n !isLoading &&\n event.currentTarget.clientHeight + event.currentTarget.scrollTop >=\n event.currentTarget.scrollHeight\n ) {\n loadNextPage()\n }\n }}\n >\n {listItems}\n </ul>\n )\n }\n\n return (\n <AutocompleteField\n options={optionKeys}\n getOptionLabel={id => getOptionLabel(options[id])}\n onInputChange={(_, value, reason) => {\n setSearch(reason === \"input\" ? value : \"\")\n }}\n ListboxComponent={forwardRef(ListboxComponent)}\n {...otherAutocompleteFieldProps}\n />\n )\n}\n\nexport default ApiAutocompleteField\n","import {\n Autocomplete,\n type AutocompleteProps,\n type ChipTypeMap,\n TextField,\n type TextFieldProps,\n} from \"@mui/material\"\nimport { type ElementType, type JSX } from \"react\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport {\n type ValidateOptions,\n number as YupNumber,\n string as YupString,\n} from \"yup\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport interface AutocompleteFieldProps<\n Value extends string | number,\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteProps<\n Value,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n \"renderInput\" | \"defaultValue\" | \"onChange\" | \"onBlur\" | \"value\"\n > {\n textFieldProps: Omit<\n TextFieldProps,\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"defaultValue\"\n | \"type\"\n > & {\n name: string\n }\n validateOptions?: ValidateOptions\n}\n\nconst AutocompleteField = <\n Value extends string | number,\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n textFieldProps,\n options,\n validateOptions,\n ...otherAutocompleteProps\n}: AutocompleteFieldProps<\n Value,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const { id, name, required, ...otherTextFieldProps } = textFieldProps\n\n const dotPath = name.split(\".\")\n\n const message = \"not a valid option\"\n let schema =\n typeof options[0] === \"string\"\n ? YupString().oneOf(options as readonly string[], message)\n : YupNumber().oneOf(options as readonly number[], message)\n if (required) schema = schema.required()\n\n const fieldConfig: FieldConfig = {\n name,\n type: typeof options[0] === \"string\" ? \"text\" : \"number\",\n validate: schemaToFieldValidator(schema, validateOptions),\n }\n\n return (\n <Field {...fieldConfig}>\n {({ form, meta }: FieldProps) => {\n const value = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as string\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n const error = getNestedProperty(form.errors, dotPath) as\n | string\n | undefined\n\n return (\n <Autocomplete\n options={options}\n // @ts-expect-error value can be assigned\n defaultValue={\n meta.initialValue === \"\"\n ? undefined\n : (meta.initialValue as string)\n }\n renderInput={({\n id: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...otherParams\n }) => (\n <TextField\n id={id ?? name}\n name={name}\n required={required}\n type=\"text\" // Force to be string to avoid number incrementor/decrementor\n value={value}\n error={touched && Boolean(error)}\n helperText={touched && error}\n {...otherTextFieldProps}\n {...otherParams}\n />\n )}\n onChange={(_, value) => {\n void form.setFieldValue(name, value ?? undefined, true)\n }}\n onBlur={form.handleBlur}\n {...otherAutocompleteProps}\n />\n )\n }}\n </Field>\n )\n}\n\nexport default AutocompleteField\n","import {\n Checkbox,\n type CheckboxProps,\n FormControl,\n FormControlLabel,\n type FormControlLabelProps,\n FormHelperText,\n} from \"@mui/material\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport { type ValidateOptions, bool as YupBool } from \"yup\"\nimport { type FC } from \"react\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport interface CheckboxFieldProps\n extends Omit<\n CheckboxProps,\n \"defaultChecked\" | \"value\" | \"onChange\" | \"onBlur\"\n > {\n name: string\n formControlLabelProps: Omit<FormControlLabelProps, \"control\">\n errorMessage?: string\n validateOptions?: ValidateOptions\n}\n\nconst CheckboxField: FC<CheckboxFieldProps> = ({\n id,\n name,\n formControlLabelProps,\n required = false,\n errorMessage = \"this is a required field\",\n validateOptions,\n ...otherCheckboxProps\n}) => {\n const dotPath = name.split(\".\")\n\n let schema = YupBool()\n if (required) schema = schema.oneOf([true], errorMessage)\n\n const fieldConfig: FieldConfig = {\n name,\n type: \"checkbox\",\n validate: schemaToFieldValidator(schema, validateOptions),\n }\n\n return (\n <Field {...fieldConfig}>\n {({ form, meta }: FieldProps) => {\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n const error = getNestedProperty(form.errors, dotPath) as\n | string\n | undefined\n const value = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as boolean\n\n const hasError = touched && Boolean(error)\n\n // https://mui.com/material-ui/react-checkbox/#formgroup\n return (\n <FormControl error={hasError} required={required}>\n <FormControlLabel\n control={\n <Checkbox\n defaultChecked={meta.initialValue as boolean}\n id={id ?? name}\n name={name}\n value={value}\n onChange={form.handleChange}\n onBlur={form.handleBlur}\n {...otherCheckboxProps}\n />\n }\n {...formControlLabelProps}\n />\n {hasError && <FormHelperText>{error}</FormHelperText>}\n </FormControl>\n )\n }}\n </Field>\n )\n}\n\nexport default CheckboxField\n","import { type ElementType, type JSX } from \"react\"\nimport { type ChipTypeMap } from \"@mui/material\"\n\nimport AutocompleteField, {\n type AutocompleteFieldProps,\n} from \"./AutocompleteField\"\nimport {\n COUNTRY_ISO_CODES,\n COUNTRY_ISO_CODE_MAPPING,\n type CountryIsoCodes,\n} from \"../../utils/general\"\n\nexport interface CountryFieldProps<\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n \"options\" | \"textFieldProps\" | \"getOptionLabel\"\n > {\n textFieldProps?: Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >[\"textFieldProps\"],\n \"name\"\n > & {\n name?: string\n }\n}\n\nconst CountryField = <\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n textFieldProps,\n ...otherAutocompleteFieldProps\n}: CountryFieldProps<\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const {\n name = \"country\",\n label = \"Country\",\n placeholder = \"Select your country\",\n ...otherTextFieldProps\n } = textFieldProps || {}\n\n return (\n <AutocompleteField\n options={COUNTRY_ISO_CODES}\n getOptionLabel={isoCode =>\n COUNTRY_ISO_CODE_MAPPING[isoCode as CountryIsoCodes]\n }\n textFieldProps={{ name, label, placeholder, ...otherTextFieldProps }}\n {...otherAutocompleteFieldProps}\n />\n )\n}\n\nexport default CountryField\n","import \"dayjs/locale/en-gb\"\nimport {\n DatePicker,\n type DatePickerProps,\n LocalizationProvider,\n} from \"@mui/x-date-pickers\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport { type ValidateOptions, date as YupDate } from \"yup\"\nimport dayjs, { type Dayjs } from \"dayjs\"\nimport { AdapterDayjs } from \"@mui/x-date-pickers/AdapterDayjs\"\nimport { type JSX } from \"react\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport interface DatePickerFieldProps<\n TEnableAccessibleFieldDOMStructure extends boolean = true,\n> extends Omit<\n DatePickerProps<TEnableAccessibleFieldDOMStructure>,\n \"name\" | \"value\" | \"onChange\" | \"slotProps\"\n > {\n name: string\n required?: boolean\n validateOptions?: ValidateOptions\n}\n\nconst DatePickerField = <\n TEnableAccessibleFieldDOMStructure extends boolean = false,\n>({\n name,\n required,\n minDate,\n maxDate,\n validateOptions,\n ...otherDatePickerProps\n}: DatePickerFieldProps<TEnableAccessibleFieldDOMStructure>): JSX.Element => {\n const dotPath = name.split(\".\")\n\n function dateToString(date: Dayjs) {\n return date.locale(\"en-gb\").format(\"L\")\n }\n\n let schema = YupDate()\n if (required) schema = schema.required()\n if (minDate) {\n schema = schema.min(\n minDate,\n `this field must be after or equal to ${dateToString(minDate)}`,\n )\n }\n if (maxDate) {\n schema = schema.max(\n maxDate,\n `this field must be before or equal to ${dateToString(maxDate)}`,\n )\n }\n\n const fieldConfig: FieldConfig = {\n name,\n type: \"date\",\n validate: schemaToFieldValidator(schema, validateOptions),\n }\n\n return (\n <Field {...fieldConfig}>\n {({ form }: FieldProps) => {\n const error = getNestedProperty(form.errors, dotPath) as\n | string\n | undefined\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n let value: Dayjs | null | string = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as string\n\n value = value ? dayjs(value) : null\n\n function handleChange(value: Dayjs | null) {\n void form.setFieldValue(\n name,\n value && value.isValid() ? value.format(\"YYYY-MM-DD\") : null,\n true,\n )\n }\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDayjs}\n adapterLocale=\"en-gb\"\n >\n <DatePicker\n name={name}\n value={value}\n minDate={minDate}\n maxDate={maxDate}\n onChange={handleChange}\n slotProps={{\n textField: {\n id: name,\n // @ts-expect-error value is compatible\n onChange: value => {\n handleChange(value as Dayjs | null)\n },\n onBlur: form.handleBlur,\n required,\n error: touched && Boolean(error),\n helperText: (touched && error) as false | string,\n },\n }}\n {...otherDatePickerProps}\n />\n </LocalizationProvider>\n )\n }}\n </Field>\n )\n}\n\nexport default DatePickerField\n","import { type FC, useEffect, useState } from \"react\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport {\n TextField as MuiTextField,\n type TextFieldProps as MuiTextFieldProps,\n} from \"@mui/material\"\nimport { type StringSchema, type ValidateOptions, array as YupArray } from \"yup\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport type TextFieldProps = Omit<\n MuiTextFieldProps,\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"defaultValue\"\n | \"helperText\"\n> & {\n name: string\n schema: StringSchema\n validateOptions?: ValidateOptions\n dirty?: boolean\n split?: string | RegExp\n unique?: boolean\n uniqueCaseInsensitive?: boolean\n}\n\n// https://formik.org/docs/examples/with-material-ui\nconst TextField: FC<TextFieldProps> = ({\n id,\n name,\n schema,\n type = \"text\",\n required = false,\n dirty = false,\n unique = false,\n uniqueCaseInsensitive = false,\n split,\n validateOptions,\n ...otherTextFieldProps\n}) => {\n const [initialValue, setInitialValue] = useState<string | string[]>(\"\")\n\n const dotPath = name.split(\".\")\n\n function buildSchema() {\n // Build a schema for a single string.\n let stringSchema = schema\n // 1: Validate string is required.\n stringSchema = required ? stringSchema.required() : stringSchema.optional()\n // 2: Validate string is dirty.\n if (dirty && !split)\n stringSchema = stringSchema.notOneOf(\n [initialValue as string],\n \"cannot be initial value\",\n )\n // Return a schema for a single string.\n if (!split) return stringSchema\n\n // Build a schema for an array of strings.\n let arraySchema = YupArray().of(stringSchema)\n // 1: Validate array has min one string.\n arraySchema = required\n ? arraySchema.required().min(1)\n : arraySchema.optional()\n // 2: Validate array has unique strings.\n if (unique || uniqueCaseInsensitive)\n arraySchema = arraySchema.test({\n message: \"cannot have duplicates\",\n test: values => {\n if (\n Array.isArray(values) &&\n values.length >= 2 &&\n values.every(value => typeof value === \"string\")\n ) {\n return (\n new Set(\n uniqueCaseInsensitive\n ? values.map(value => value.toLowerCase())\n : values,\n ).size === values.length\n )\n }\n\n return true\n },\n })\n // 3: Validate array is dirty.\n if (dirty)\n arraySchema = arraySchema.notOneOf(\n [initialValue as string[]],\n \"cannot be initial value\",\n )\n // Return a schema for an array of strings.\n return arraySchema\n }\n\n const fieldConfig: FieldConfig = {\n name,\n type,\n validate: schemaToFieldValidator(buildSchema(), validateOptions),\n }\n\n const FieldInternal: FC<FieldProps> = ({ form }) => {\n const initialValue = getNestedProperty(\n form.initialValues as FormValues,\n dotPath,\n ) as string\n const value = getNestedProperty(\n form.values as FormValues,\n dotPath,\n ) as string\n const error = getNestedProperty(form.errors, dotPath) as string | undefined\n const touched = getNestedProperty(form.touched, dotPath) as boolean\n\n useEffect(() => {\n setInitialValue(initialValue)\n }, [initialValue])\n\n useEffect(() => {\n void form.setFieldValue(\n name,\n split && typeof value === \"string\" ? value.split(split) : value,\n true,\n )\n }, [value]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <MuiTextField\n id={id ?? name}\n name={name}\n type={type}\n required={required}\n value={value}\n onChange={form.handleChange}\n onBlur={form.handleBlur}\n error={touched && Boolean(error)}\n helperText={(touched && error) as false | string}\n {...otherTextFieldProps}\n />\n )\n }\n\n return <Field {...fieldConfig}>{FieldInternal}</Field>\n}\n\nexport default TextField\n","import { EmailOutlined as EmailOutlinedIcon } from \"@mui/icons-material\"\nimport type { FC } from \"react\"\nimport { InputAdornment } from \"@mui/material\"\nimport { string as YupString } from \"yup\"\n\nimport TextField, { type TextFieldProps } from \"./TextField\"\n\nexport type EmailFieldProps = Omit<TextFieldProps, \"type\" | \"name\" | \"schema\"> &\n Partial<Pick<TextFieldProps, \"name\">>\n\nconst EmailField: FC<EmailFieldProps> = ({\n name = \"email\",\n label = \"Email address\",\n placeholder = \"Enter your email address\",\n InputProps = {},\n ...otherTextFieldProps\n}) => {\n return (\n <TextField\n type=\"email\"\n schema={YupString().email()}\n name={name}\n label={label}\n placeholder={placeholder}\n InputProps={{\n endAdornment: (\n <InputAdornment position=\"end\">\n <EmailOutlinedIcon />\n </InputAdornment>\n ),\n ...InputProps,\n }}\n {...otherTextFieldProps}\n />\n )\n}\n\nexport default EmailField\n","import type { FC } from \"react\"\nimport { InputAdornment } from \"@mui/material\"\nimport { PersonOutlined as PersonOutlinedIcon } from \"@mui/icons-material\"\n\nimport TextField, { type TextFieldProps } from \"./TextField\"\nimport { schemas } from \"../../api\"\n\nexport type FirstNameFieldProps = Omit<\n TextFieldProps,\n \"type\" | \"name\" | \"schema\"\n> &\n Partial<Pick<TextFieldProps, \"name\">>\n\nconst FirstNameField: FC<FirstNameFieldProps> = ({\n name = \"first_name\",\n label = \"First name\",\n placeholder = \"Enter your first name\",\n InputProps = {},\n ...otherTextFieldProps\n}) => {\n return (\n <TextField\n schema={schemas.user.first_name}\n name={name}\n label={label}\n placeholder={placeholder}\n InputProps={{\n endAdornment: (\n <InputAdornment position=\"end\">\n <PersonOutlinedIcon />\n </InputAdornment>\n ),\n ...InputProps,\n }}\n {...otherTextFieldProps}\n />\n )\n}\n\nexport default FirstNameField\n","import {\n type FC,\n type JSX,\n type ReactNode,\n type RefObject,\n useEffect,\n useRef,\n} from \"react\"\nimport { FormHelperText, type FormHelperTextProps } from \"@mui/material\"\nimport {\n Formik,\n type FormikConfig,\n type FormikErrors,\n Form as FormikForm,\n type FormikProps,\n} from \"formik\"\nimport type { TypedUseMutation } from \"@reduxjs/toolkit/query/react\"\n\nimport {\n type FormValues,\n type SubmitFormOptions,\n submitForm,\n} from \"../../utils/form\"\nimport { getKeyPaths } from \"../../utils/general\"\n\nconst SCROLL_INTO_VIEW_OPTIONS: ScrollIntoViewOptions = {\n behavior: \"smooth\",\n block: \"start\",\n}\n\ntype NonFieldErrorsProps = Omit<FormHelperTextProps, \"error\" | \"ref\"> & {\n scrollIntoViewOptions?: ScrollIntoViewOptions\n}\n\nconst NonFieldErrors: FC<NonFieldErrorsProps> = ({\n scrollIntoViewOptions = SCROLL_INTO_VIEW_OPTIONS,\n ...formHelperTextProps\n}) => {\n const pRef = useRef<HTMLParagraphElement>(null)\n\n useEffect(() => {\n if (pRef.current) pRef.current.scrollIntoView(scrollIntoViewOptions)\n }, [scrollIntoViewOptions])\n\n return <FormHelperText ref={pRef} error {...formHelperTextProps} />\n}\n\nexport type FormErrors<Values> = FormikErrors<\n Omit<Values, \"__all__\"> & { __all__: string }\n>\n\ntype _FormikProps<Values> = Omit<FormikProps<Values>, \"errors\"> & {\n errors: FormErrors<Values>\n}\n\ntype BaseFormProps<Values> = Omit<FormikConfig<Values>, \"children\"> & {\n children: ReactNode | ((props: _FormikProps<Values>) => ReactNode)\n scrollIntoViewOptions?: ScrollIntoViewOptions\n nonFieldErrorsProps?: Omit<NonFieldErrorsProps, \"children\">\n fieldRefs?: Array<{\n name: string\n inputRef: RefObject<HTMLInputElement | null>\n }>\n}\n\nconst BaseForm = <Values extends FormValues>({\n children,\n scrollIntoViewOptions = SCROLL_INTO_VIEW_OPTIONS,\n nonFieldErrorsProps,\n fieldRefs = [],\n ...otherFormikProps\n}: BaseFormProps<Values>) => (\n <Formik {...otherFormikProps}>\n {/* @ts-expect-error value is assignable */}\n {(formik: _FormikProps<Values>) => {\n const hasErrors = Boolean(Object.keys(formik.errors).length)\n const hasNonFieldErrors =\n hasErrors && typeof formik.errors.__all__ === \"string\"\n\n // If a submission was attempted and refs to the fields were provided.\n if (\n hasErrors &&\n !hasNonFieldErrors &&\n formik.isSubmitting &&\n fieldRefs.length\n ) {\n const errorNames = getKeyPaths(formik.errors)\n\n const input = fieldRefs.find(({ name }) => errorNames.includes(name))\n ?.inputRef.current\n\n if (input) input.scrollIntoView(scrollIntoViewOptions)\n }\n\n return (\n <>\n {hasNonFieldErrors && (\n <NonFieldErrors {...nonFieldErrorsProps}>\n {formik.errors.__all__ as string}\n </NonFieldErrors>\n )}\n <FormikForm>\n {typeof children === \"function\" ? children(formik) : children}\n </FormikForm>\n </>\n )\n }}\n </Formik>\n)\n\ntype SubmitFormProps<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n> = Omit<BaseFormProps<Values>, \"onSubmit\"> & {\n useMutation: TypedUseMutation<ResultType, QueryArg, any>\n} & (Values extends QueryArg\n ? { submitOptions?: SubmitFormOptions<Values, QueryArg, ResultType> }\n : { submitOptions: SubmitFormOptions<Values, QueryArg, ResultType> })\n\nconst SubmitForm = <\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n>({\n useMutation,\n submitOptions,\n ...baseFormProps\n}: SubmitFormProps<Values, QueryArg, ResultType>): JSX.Element => {\n const [trigger] = useMutation()\n\n return (\n <BaseForm\n {...baseFormProps}\n onSubmit={submitForm<Values, QueryArg, ResultType>(\n trigger,\n baseFormProps.initialValues,\n submitOptions as SubmitFormOptions<Values, QueryArg, ResultType>,\n )}\n />\n )\n}\n\nexport type FormProps<\n Values extends FormValues,\n QueryArg extends FormValues,\n ResultType,\n> = BaseFormProps<Values> | SubmitFormProps<Values, QueryArg, ResultType>\n\nconst Form: {\n <Values extends FormValues>(props: BaseFormProps<Values>): JSX.Element\n <Values extends FormValues, QueryArg extends FormValues, ResultType>(\n props: SubmitFormProps<Values, QueryArg, ResultType>,\n ): JSX.Element\n} = <\n Values extends FormValues = FormValues,\n QueryArg extends FormValues = FormValues,\n ResultType = any,\n>(\n props: FormProps<Values, QueryArg, ResultType>,\n): JSX.Element => {\n return \"onSubmit\" in props ? <BaseForm {...props} /> : SubmitForm(props)\n}\n\nexport default Form\n","import { type FC } from \"react\"\nimport { string as YupString } from \"yup\"\n\nimport TextField, { type TextFieldProps } from \"./TextField\"\n\nexport type OtpFieldProps = Omit<\n TextFieldProps,\n \"name\" | \"schema\" | \"required\"\n> &\n Partial<Pick<TextFieldProps, \"name\">>\n\nconst OtpField: FC<OtpFieldProps> = ({\n name = \"otp\",\n label = \"OTP\",\n placeholder = \"Enter your OTP\",\n ...otherTextFieldProps\n}) => (\n <TextField\n name={name}\n label={label}\n schema={YupString().matches(/^[0-9]{6}$/, \"Must be exactly 6 digits.\")}\n placeholder={placeholder}\n required\n {...otherTextFieldProps}\n />\n)\n\nexport default OtpField\n","import {\n type Dispatch,\n type FC,\n type SetStateAction,\n useEffect,\n useState,\n} from \"react\"\nimport { Field, type FieldConfig, type FieldProps } from \"formik\"\nimport { TextField as MuiTextField, type TextFieldProps } from \"@mui/material\"\nimport { type ValidateOptions, string as YupString } from \"yup\"\n\nimport { type FormValues, schemaToFieldValidator } from \"../../utils/form\"\nimport { getNestedProperty } from \"../../utils/general\"\n\nexport type RepeatFieldProps = Omit<\n TextFieldProps,\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"defaultValue\"\n | \"required\"\n> & {\n name: string\n validateOptions?: ValidateOptions\n}\n\nconst TextField: FC<\n RepeatFieldProps & {\n repeatName: string\n setValue: Dispatch<SetStateAction<string>>\n fieldProps: FieldProps\n }\n> = ({\n id,\n repeatName,\n setValue,\n fieldProps,\n name,\n label,\n placeholder,\n type,\n ...otherTextFieldProps\n}) => {\n const { form } = fieldProps\n\n const dotPath = name.split(\".\")\n const value = getNestedProperty(form.values as FormValues, dotPath) as string\n\n const repeatDotPath = repeatName.split(\".\")\n const repeatValue = getNestedProperty(\n form.values as FormValues,\n repeatDotPath,\n ) as string\n const repeatTouched = getNestedProperty(\n form.touched,\n repeatDotPath,\n ) as boolean\n const repeatError = getNestedProperty(form.errors, repeatDotPath) as\n | string\n | undefined\n\n useEffect(() => {\n setValue(value)\n }, [setValue, value])\n\n return (\n <MuiTextField\n required\n type={type}\n label={label ?? `Repeat ${name.replace(\"_\", \" \")}`}\n placeholder={placeholder ?? `Enter your ${name.replace(\"_\", \" \")} again`}\n id={id ?? repeatName}\n name={repeatName}\n value={repeatValue}\n onChange={form.handleChange}\n onBlur={form.handleBlur}\n error={repeatTouched && Boolean(repeatError)}\n helperText={(repeatTouched && repeatError) as false | string}\n {...otherTextFieldProps}\n />\n )\n}\n\n// https://formik.org/docs/examples/with-material-ui\nconst RepeatField: FC<RepeatFieldProps> = ({\n name,\n type = \"text\",\n validateOptions,\n ...otherTextFieldProps\n}) => {\n const [value, setValue] = useState(\"\")\n\n const repeatName = `${name}_repeat`\n\n const fieldConfig: FieldConfig = {\n name: repeatName,\n type,\n validate: schemaToFieldValidator(\n YupString().required().equals([value], \"does not match\"),\n validateOptions,\n ),\n }\n\n return (\n <Field {...fieldConfig}>\n {(fieldProps: FieldProps) => (\n <TextField\n name={name}\n type={type}\n repeatName={repeatName}\n setValue={setValue}\n fieldProps={fieldProps}\n {...otherTextFieldProps}\n />\n )}\n </Field>\n )\n}\n\nexport default RepeatField\n","import { type FC, useState } from \"react\"\nimport { IconButton, InputAdornment } from \"@mui/material\"\nimport {\n Visibility as VisibilityIcon,\n VisibilityOff as VisibilityOffIcon,\n} from \"@mui/icons-material\"\nimport { string as YupString } from \"yup\"\n\nimport RepeatField, { type RepeatFieldProps } from \"./RepeatField\"\nimport TextField, { type TextFieldProps } from \"./TextField\"\n\nexport type PasswordFieldProps = Omit<\n TextFieldProps,\n \"type\" | \"name\" | \"schema\" | \"autoComplete\"\n> &\n Partial<Pick<TextFieldProps, \"name\" | \"schema\">> & {\n withRepeatField?: boolean\n repeatFieldProps?: Omit<RepeatFieldProps, \"name\" | \"type\">\n }\n\nconst PasswordField: FC<PasswordFieldProps> = ({\n name = \"password\",\n label = \"Password\",\n placeholder = \"Enter your password\",\n schema = YupString(),\n InputProps = {},\n withRepeatField = false,\n repeatFieldProps = {},\n ...otherTextFieldProps\n}) => {\n const [isVisible, setIsVisible] = useState(false)\n\n const type = isVisible ? \"text\" : \"password\"\n const endAdornment = (\n <InputAdornment position=\"end\">\n <IconButton\n onClick={() => {\n setIsVisible(previousIsVisible => !previousIsVisible)\n }}\n edge=\"end\"\n >\n {isVisible ? <VisibilityIcon /> : <VisibilityOffIcon />}\n </IconButton>\n </InputAdornment>\n )\n\n return (\n <>\n <TextField\n autoComplete=\"off\"\n type={type}\n name={name}\n label={label}\n schema={schema}\n placeholder={placeholder}\n InputProps={{ endAdornment, ...InputProps }}\n {...otherTextFieldProps}\n />\n {withRepeatField && (\n <RepeatField\n name={name}\n type={type}\n {...repeatFieldProps}\n InputProps={{ endAdornment, ...repeatFieldProps.InputProps }}\n />\n )}\n </>\n )\n}\n\nexport default PasswordField\n","import { Button, type ButtonProps } from \"@mui/material\"\nimport { Field, type FieldProps } from \"formik\"\nimport type { FC } from \"react\"\n\nimport { type FormValues } from \"../../utils/form\"\n\nexport interface SubmitButtonProps\n extends Omit<ButtonProps, \"type\" | \"onClick\"> {}\n\nconst SubmitButton: FC<SubmitButtonProps> = ({\n children = \"Submit\",\n ...otherButtonProps\n}) => {\n function getTouched(\n values: Record<string, any>,\n touched?: Record<string, any>,\n ) {\n touched = touched || {}\n for (const key in values) {\n const value: unknown = values[key]\n touched[key] =\n value instanceof Object && value.constructor === Object\n ? getTouched(value, touched)\n : true\n }\n\n return touched\n }\n\n return (\n <Field name=\"submit\" type=\"submit\">\n {({ form }: FieldProps) => (\n <Button\n type=\"button\"\n onClick={() => {\n void form\n .setTouched(getTouched(form.values as FormValues), true)\n .then(errors => {\n const hasErrors = Boolean(errors && Object.keys(errors).length)\n // If has errors, set isSubmitting=true so fields in the form are\n // aware that a submission was attempted. Else, set\n // isSubmitting=false as it will be set to true when calling\n // submitForm().\n form.setSubmitting(hasErrors)\n if (!hasErrors) void form.submitForm()\n })\n }}\n {...otherButtonProps}\n >\n {children}\n </Button>\n )}\n </Field>\n )\n}\n\nexport default SubmitButton\n","import { type ElementType, type JSX } from \"react\"\nimport { type ChipTypeMap } from \"@mui/material\"\n\nimport AutocompleteField, {\n type AutocompleteFieldProps,\n} from \"./AutocompleteField\"\nimport { UK_COUNTIES } from \"../../utils/general\"\n\nexport interface UkCountyFieldProps<\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n> extends Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >,\n \"options\" | \"textFieldProps\"\n > {\n textFieldProps?: Omit<\n AutocompleteFieldProps<\n string,\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n >[\"textFieldProps\"],\n \"name\"\n > & {\n name?: string\n }\n}\n\nconst UkCountyField = <\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n FreeSolo extends boolean | undefined = false,\n ChipComponent extends ElementType = ChipTypeMap[\"defaultComponent\"],\n>({\n textFieldProps,\n ...otherAutocompleteFieldProps\n}: UkCountyFieldProps<\n Multiple,\n DisableClearable,\n FreeSolo,\n ChipComponent\n>): JSX.Element => {\n const {\n name = \"uk_county\",\n label = \"UK county\",\n placeholder = \"Select your UK county\",\n ...otherTextFieldProps\n } = textFieldProps || {}\n\n return (\n <AutocompleteField\n options={UK_COUNTIES}\n textFieldProps={{ name, label, placeholder, ...otherTextFieldProps }}\n {...otherAutocompleteFieldProps}\n />\n )\n}\n\nexport default UkCountyField\n"],"names":["ApiAutocompleteField","useLazyListQuery","filterOptions","getOptionLabel","getOptionKey","result","searchKey","otherAutocompleteFieldProps","search","setSearch","useState","trigger","isLoading","isError","limit","offset","setPagination","usePagination","options","hasMore","setState","useEffect","arg","data","count","previousOptions","error","optionKeys","jsx","Fragment","loadNextPage","page","ListboxComponent","children","props","ref","listItems","Children","CircularProgress","SyncError","Button","event","AutocompleteField","id","_","value","reason","forwardRef","textFieldProps","validateOptions","otherAutocompleteProps","name","required","otherTextFieldProps","dotPath","message","schema","YupString","YupNumber","fieldConfig","schemaToFieldValidator","Field","form","meta","getNestedProperty","touched","Autocomplete","otherParams","TextField","CheckboxField","formControlLabelProps","errorMessage","otherCheckboxProps","YupBool","hasError","jsxs","FormControl","FormControlLabel","Checkbox","FormHelperText","CountryField","label","placeholder","COUNTRY_ISO_CODES","isoCode","COUNTRY_ISO_CODE_MAPPING","DatePickerField","minDate","maxDate","otherDatePickerProps","dateToString","date","YupDate","dayjs","handleChange","LocalizationProvider","AdapterDayjs","DatePicker","type","dirty","unique","uniqueCaseInsensitive","split","initialValue","setInitialValue","buildSchema","stringSchema","arraySchema","YupArray","values","FieldInternal","MuiTextField","EmailField","InputProps","InputAdornment","EmailOutlinedIcon","FirstNameField","schemas.user","PersonOutlinedIcon","SCROLL_INTO_VIEW_OPTIONS","NonFieldErrors","scrollIntoViewOptions","formHelperTextProps","pRef","useRef","BaseForm","nonFieldErrorsProps","fieldRefs","otherFormikProps","Formik","formik","hasErrors","hasNonFieldErrors","errorNames","getKeyPaths","input","FormikForm","SubmitForm","useMutation","submitOptions","baseFormProps","submitForm","Form","OtpField","repeatName","setValue","fieldProps","repeatDotPath","repeatValue","repeatTouched","repeatError","RepeatField","PasswordField","withRepeatField","repeatFieldProps","isVisible","setIsVisible","endAdornment","IconButton","previousIsVisible","VisibilityIcon","VisibilityOffIcon","SubmitButton","otherButtonProps","getTouched","key","errors","UkCountyField","UK_COUNTIES"],"mappings":"+mBAqDA,MAAMA,E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,MAAoB,EAAG,EAAI,EACtD,KAAKwG,GAAU,CACd,MAAMnC,EAAY,GAAQmC,GAAU,OAAO,KAAKA,CAAM,EAAE,QAKxDxG,EAAK,cAAcqE,CAAS,EACvBA,GAAgBrE,EAAK,WAAA,CAC5B,CAAC,CACL,EACC,GAAGqG,EAEH,SAAAlI,CAAA,CAAA,EAGP,CAEJ,ECjBMsI,EAAgB,CAKpB,CACA,eAAAvH,EACA,GAAGzC,CACL,IAKmB,CACjB,KAAM,CACJ,KAAA4C,EAAO,YACP,MAAA8B,EAAQ,YACR,YAAAC,EAAc,wBACd,GAAG7B,CAAA,EACDL,GAAkB,CAAA,EAEtB,OACEpB,EAAAA,IAACc,EAAA,CACC,QAAS8H,EAAAA,YACT,eAAgB,CAAE,KAAArH,EAAM,MAAA8B,EAAO,YAAAC,EAAa,GAAG7B,CAAA,EAC9C,GAAG9C,CAAA,CAAA,CAGV"}
@@ -7,9 +7,8 @@ import { Field as T, Formik as oe, Form as ne } from "formik";
7
7
  import { string as I, number as ie, bool as se, date as le, array as ae } from "yup";
8
8
  import { schemaToFieldValidator as V, submitForm as ce } from "./utils/form.es.js";
9
9
  import { getNestedProperty as y, COUNTRY_ISO_CODE_MAPPING as ue, COUNTRY_ISO_CODES as de, getKeyPaths as he, UK_COUNTIES as pe } from "./utils/general.es.js";
10
- import "dayjs/locale/en-gb";
11
- import { LocalizationProvider as fe, DatePicker as me } from "@mui/x-date-pickers";
12
- import ge from "dayjs";
10
+ import { d as fe } from "./dayjs.min-Bgcc5o9W.js";
11
+ import { LocalizationProvider as me, DatePicker as ge } from "@mui/x-date-pickers";
13
12
  import { AdapterDayjs as be } from "@mui/x-date-pickers/AdapterDayjs";
14
13
  import { EmailOutlined as ye, PersonOutlined as Fe, Visibility as Ce, VisibilityOff as Pe } from "@mui/icons-material";
15
14
  import "@reduxjs/toolkit/query/react";
@@ -229,7 +228,7 @@ const xe = ({
229
228
  c.values,
230
229
  l
231
230
  );
232
- f = f ? ge(f) : null;
231
+ f = f ? fe(f) : null;
233
232
  function C(g) {
234
233
  c.setFieldValue(
235
234
  t,
@@ -238,12 +237,12 @@ const xe = ({
238
237
  );
239
238
  }
240
239
  return /* @__PURE__ */ o(
241
- fe,
240
+ me,
242
241
  {
243
242
  dateAdapter: be,
244
243
  adapterLocale: "en-gb",
245
244
  children: /* @__PURE__ */ o(
246
- me,
245
+ ge,
247
246
  {
248
247
  name: t,
249
248
  value: f,
@@ -585,7 +584,7 @@ const xe = ({
585
584
  ...e
586
585
  }
587
586
  );
588
- }, ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
587
+ }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
589
588
  __proto__: null,
590
589
  ApiAutocompleteField: xe,
591
590
  AutocompleteField: L,
@@ -617,6 +616,6 @@ export {
617
616
  L as a,
618
617
  _e as b,
619
618
  Ve as c,
620
- ot as i
619
+ rt as i
621
620
  };
622
- //# sourceMappingURL=index-BIL7PoEV.js.map
621
+ //# sourceMappingURL=index-uvqsz6fM.js.map