@nwon/react-mui-hook-form 3.1.4 → 3.1.6

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.
Files changed (47) hide show
  1. package/package.json +8 -8
  2. package/dist/LoadingButton/LoadingButton.d.ts +0 -6
  3. package/dist/LoadingButton/LoadingButtonInterfaces.d.ts +0 -33
  4. package/dist/LoadingButton/getLoadingButtonState.d.ts +0 -20
  5. package/dist/LoadingButton/index.d.ts +0 -4
  6. package/dist/formFields/HookFormProvider.d.ts +0 -7
  7. package/dist/formFields/InputEmail/InputEmail.d.ts +0 -10
  8. package/dist/formFields/InputPasswordSet/InputPasswordSet.d.ts +0 -8
  9. package/dist/formFields/InputPasswordSet/InputPasswordSetInterfaces.d.ts +0 -18
  10. package/dist/formFields/TranslatedString.d.ts +0 -13
  11. package/dist/formFields/baseTypes/BaseInputProps.d.ts +0 -33
  12. package/dist/formFields/baseTypes/InputAutocomplete/InputAutocomplete.d.ts +0 -9
  13. package/dist/formFields/baseTypes/InputAutocomplete/InputAutocompleteInterfaces.d.ts +0 -24
  14. package/dist/formFields/baseTypes/InputAutocomplete/useSortedOptionsWithGroup.d.ts +0 -9
  15. package/dist/formFields/baseTypes/InputCheckbox/InputCheckbox.d.ts +0 -18
  16. package/dist/formFields/baseTypes/InputDatePicker/InputDatePicker.d.ts +0 -16
  17. package/dist/formFields/baseTypes/InputDateTimePicker/InputDateTimePicker.d.ts +0 -16
  18. package/dist/formFields/baseTypes/InputNumber/InputNumber.d.ts +0 -15
  19. package/dist/formFields/baseTypes/InputOutlinedInput/InputOutlinedInput.d.ts +0 -13
  20. package/dist/formFields/baseTypes/InputRadio/InputRadio.d.ts +0 -13
  21. package/dist/formFields/baseTypes/InputSelect/InputSelect.d.ts +0 -26
  22. package/dist/formFields/baseTypes/InputSelectFromEnum/InputSelectFromEnum.d.ts +0 -15
  23. package/dist/formFields/baseTypes/InputSelectFromEnum/InputSelectFromEnumInterfaces.d.ts +0 -10
  24. package/dist/formFields/baseTypes/InputSlider/InputSlider.d.ts +0 -13
  25. package/dist/formFields/baseTypes/InputSwitch/InputSwitch.d.ts +0 -11
  26. package/dist/formFields/baseTypes/InputTextField/InputTextField.d.ts +0 -13
  27. package/dist/formFields/baseTypes/InputTimePicker/InputTimePicker.d.ts +0 -16
  28. package/dist/formFields/baseTypes/InputToggleButton/InputToggleButton.d.ts +0 -12
  29. package/dist/formFields/baseTypes/InputToggleButtonGroup/InputToggleButtonGroup.d.ts +0 -34
  30. package/dist/formFields/baseTypes/useEffectFieldUnregisterOnUnmount.d.ts +0 -12
  31. package/dist/formFields/errorMessages.d.ts +0 -1
  32. package/dist/formFields/errors/FormFieldError.d.ts +0 -11
  33. package/dist/formFields/errors/FormFieldErrorDisplay.d.ts +0 -11
  34. package/dist/formFields/errors/getFormErrorForNestedKeys.d.ts +0 -14
  35. package/dist/formFields/errors/useFormFieldError.d.ts +0 -7
  36. package/dist/formFields/errors/useFormFieldHasError.d.ts +0 -6
  37. package/dist/formFields/formHelper/syncSubmit.d.ts +0 -15
  38. package/dist/formFields/formHelper/useHookForm.d.ts +0 -56
  39. package/dist/formFields/formHelper/useHookFormContext.d.ts +0 -9
  40. package/dist/formFields/formHelper/useMergedFormField.d.ts +0 -6
  41. package/dist/formFields/formHelper/useSortedOptionsWithGroup.d.ts +0 -5
  42. package/dist/formFields/formHelper/useTranslateString.d.ts +0 -8
  43. package/dist/formFields/index.d.ts +0 -49
  44. package/dist/formFields/inputTypes.d.ts +0 -76
  45. package/dist/packageExports.d.ts +0 -9
  46. package/dist/packageExports.js +0 -1772
  47. package/dist/packageExports.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwon/react-mui-hook-form",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "react",
@@ -61,9 +61,9 @@
61
61
  "eslint-plugin-react": "^7.37.5",
62
62
  "eslint-plugin-react-hooks": "^5.2.0",
63
63
  "typescript-eslint": "^8.35.1",
64
- "@mui/icons-material": "^7.3.2",
65
- "@mui/lab": "^7.0.0-beta.17",
66
- "@mui/material": "^7.3.2",
64
+ "@mui/icons-material": "^7.3.6",
65
+ "@mui/lab": "^7.0.1-beta.20",
66
+ "@mui/material": "^7.3.6",
67
67
  "@mui/x-date-pickers": "^8.11.1",
68
68
  "@nvon/baseline": "^1.0.0",
69
69
  "@nvon/node-toolbox": "^0.20.4",
@@ -79,7 +79,7 @@
79
79
  "i18next": "^22.4.10",
80
80
  "lodash-es": "^4.17.21",
81
81
  "npm": "^9.5.0",
82
- "react-hook-form": "^7.41.3",
82
+ "react-hook-form": "^7.68",
83
83
  "react-i18next": "^11.18.5",
84
84
  "react-number-format": "^5.4.4",
85
85
  "react-scripts": "^5.0.1",
@@ -89,9 +89,9 @@
89
89
  "typescript": "^4.9.5"
90
90
  },
91
91
  "peerDependencies": {
92
- "@mui/icons-material": "^7.3.2",
93
- "@mui/lab": "^7.0.0-beta.17",
94
- "@mui/material": "^7.3.2",
92
+ "@mui/icons-material": "^7.3.6",
93
+ "@mui/lab": "^7.0.1-beta.20",
94
+ "@mui/material": "^7.3.6",
95
95
  "@mui/x-date-pickers": "^8.11.1",
96
96
  "@nvon/baseline": "^1.0.0",
97
97
  "dayjs": "^1.11.10",
@@ -1,6 +0,0 @@
1
- import { JSX } from "react";
2
- import { LoadingButtonProps } from "./LoadingButtonInterfaces";
3
- /**
4
- * A loading button component.
5
- */
6
- export declare const LoadingButton: ({ buttonText, buttonTextSuccess, loadingButtonProps, loadingButtonPropsPropsSuccess, buttonState, successIcon, }: LoadingButtonProps) => JSX.Element;
@@ -1,33 +0,0 @@
1
- import { LoadingButtonProps as MuiLoadingButtonProps } from "@mui/lab";
2
- import { JSX, ReactElement } from "react";
3
- export declare enum LoadingButtonState {
4
- Idle = "idle",
5
- Loading = "loading",
6
- Success = "success"
7
- }
8
- type SelectedButtonProps = Omit<MuiLoadingButtonProps, "children">;
9
- export interface LoadingButtonProps {
10
- buttonState: LoadingButtonState;
11
- /**
12
- * Button label.
13
- */
14
- buttonText: string;
15
- /**
16
- * Button label that is displayed on success.
17
- */
18
- buttonTextSuccess?: string;
19
- /**
20
- * Provide an icon that is displayed in front of the text
21
- * when state is successful.
22
- */
23
- successIcon?: JSX.Element | ReactElement;
24
- /**
25
- * Adjust the button when the state is any other than successful.
26
- */
27
- loadingButtonProps?: SelectedButtonProps;
28
- /**
29
- * Adjust the button when the state is successful.
30
- */
31
- loadingButtonPropsPropsSuccess?: SelectedButtonProps;
32
- }
33
- export {};
@@ -1,20 +0,0 @@
1
- import { FormState } from "react-hook-form";
2
- import { LoadingButtonState } from "./LoadingButtonInterfaces";
3
- /**
4
- * Redefinition of mutation status defined by react query. By doing this
5
- * we don't need to import react-query in the package.
6
- */
7
- declare type MutationStatus = "idle" | "loading" | "success" | "error";
8
- /**
9
- * Get loading button state from react-query mutation status.
10
- */
11
- export declare const loadingButtonStateFromReactQueryMutationStatus: (mutationStatus: MutationStatus) => LoadingButtonState;
12
- /**
13
- * Get loading button state from a react-hook-form context.
14
- */
15
- export declare const useLoadingButtonStateFromFormContext: () => LoadingButtonState;
16
- /**
17
- * Get loading button state from a react-hook-form state.
18
- */
19
- export declare const loadingButtonStateFromFormState: (formState: FormState<any>) => LoadingButtonState;
20
- export {};
@@ -1,4 +0,0 @@
1
- export { LoadingButton } from "./LoadingButton";
2
- export { LoadingButtonState } from "./LoadingButtonInterfaces";
3
- export type { LoadingButtonProps } from "./LoadingButtonInterfaces";
4
- export { loadingButtonStateFromFormState, loadingButtonStateFromReactQueryMutationStatus, useLoadingButtonStateFromFormContext, } from "./getLoadingButtonState";
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Reexport of FormProvider.
4
- *
5
- * This became necessary as context is not available when the FormProvider is initialized outside of the package. Most likely this is some kind of instance mismatch.
6
- */
7
- export declare const HookFormProvider: <TFieldValues extends import("react-hook-form").FieldValues, TContext = any, TTransformedValues extends import("react-hook-form").FieldValues | undefined = undefined>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => import("react").JSX.Element;
@@ -1,10 +0,0 @@
1
- import { TextFieldProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../baseTypes/BaseInputProps";
4
- export interface InputEmailProps {
5
- textFieldProps?: TextFieldProps;
6
- }
7
- /**
8
- * Renders a MUI input for an email address that is embedded in a react hook form context.
9
- */
10
- export declare const InputEmail: (props: BaseInputProps<InputEmailProps>) => JSX.Element;
@@ -1,8 +0,0 @@
1
- import { JSX } from "react";
2
- import { InputPasswordSetProps } from "./InputPasswordSetInterfaces";
3
- /**
4
- * Two fields for setting a password set: input & validation.
5
- *
6
- * Checks for equality of both.
7
- */
8
- export declare const InputPasswordSet: ({ passwordField, passwordValidationField, doNotMatchError, passwordValidationTextFieldProps, passwordTextFieldProps, }: InputPasswordSetProps) => JSX.Element;
@@ -1,18 +0,0 @@
1
- import { TextFieldProps } from "@mui/material";
2
- import { FormField } from "../inputTypes";
3
- export interface InputPasswordSetProps {
4
- /**
5
- * Partial entry, assuming by default a "password"-named field.
6
- */
7
- passwordField: FormField;
8
- passwordTextFieldProps?: TextFieldProps;
9
- /**
10
- * Partial entry, assuming by default a "passwordConfirmation"-named field.
11
- */
12
- passwordValidationField: FormField;
13
- passwordValidationTextFieldProps?: TextFieldProps;
14
- /**
15
- * Error that is displayed when the passwords do not match.
16
- */
17
- doNotMatchError: string;
18
- }
@@ -1,13 +0,0 @@
1
- import { TFunction } from "react-i18next";
2
- /**
3
- * Used for static data definitions outside of react:
4
- * ```.
5
- * // Static definition, somewhere:
6
- * const myString = (t) => t("my.string");
7
- *
8
- * // Using the translated string inside a component:
9
- * const t = useTranslation();
10
- * const string = myString(t);
11
- * ```.
12
- */
13
- export type TranslatedString = (t: TFunction) => string;
@@ -1,33 +0,0 @@
1
- import { FormField } from "../inputTypes";
2
- import { UnregisterOptions } from "./useEffectFieldUnregisterOnUnmount";
3
- interface SharedProps {
4
- /**
5
- * The form field that the input is bound to.
6
- *
7
- * Central configurations like the name of the field, label and validations
8
- * are stored here.
9
- */
10
- formField: FormField;
11
- /**
12
- * If true, the field will unregister when the component unmounts. In that
13
- * case additional options for handling the unregistering can be passed in.
14
- *
15
- * @default false
16
- */
17
- isUnregisteringOnUnmount?: boolean;
18
- }
19
- interface UnregisterOnUnmountProps extends SharedProps {
20
- isUnregisteringOnUnmount?: true;
21
- /**
22
- * Options for handling the current state when unregistering the field.
23
- *
24
- * Documentation: https://react-hook-form.com/docs/useform/unregister.
25
- */
26
- unregisterOptions?: UnregisterOptions;
27
- }
28
- interface DontUnregisterOnUnmountProps extends SharedProps {
29
- isUnregisteringOnUnmount?: false;
30
- unregisterOptions?: never;
31
- }
32
- export type BaseInputProps<T> = (T & UnregisterOnUnmountProps) | (T & DontUnregisterOnUnmountProps);
33
- export {};
@@ -1,9 +0,0 @@
1
- import { JSX } from "react";
2
- import { BaseInputProps } from "../BaseInputProps";
3
- import { InputAutocompleteProps } from "./InputAutocompleteInterfaces";
4
- /**
5
- * Renders a MUI autocomplete input that is embedded in a react hook form context.
6
- *
7
- * @throws Error when FormContext is null.
8
- */
9
- export declare const InputAutocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends import("react").ElementType<any, keyof JSX.IntrinsicElements> = "div">({ formField, selectableOptions, noOptions, autoCompleteProps, checkboxesForMultiselect: renderCheckboxes, groupSorting, inputTextFieldProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>>) => JSX.Element;
@@ -1,24 +0,0 @@
1
- /// <reference types="react" />
2
- import { AutocompleteProps, ChipTypeMap, TextFieldProps } from "@mui/material";
3
- import { LabeledValueWithGrouping } from "../../inputTypes";
4
- import { GroupLabelSorting } from "./useSortedOptionsWithGroup";
5
- export interface CustomAutocompleteProps<T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap["defaultComponent"]> extends Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, "renderInput" | "options"> {
6
- renderInput?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>["renderInput"];
7
- }
8
- export interface InputAutocompleteProps<T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap["defaultComponent"]> {
9
- groupSorting?: GroupLabelSorting;
10
- selectableOptions: LabeledValueWithGrouping[];
11
- /**
12
- * Text that is displayed when there are no more options.
13
- */
14
- noOptions: string;
15
- autoCompleteProps?: CustomAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>;
16
- /**
17
- * Renders checkboxes next to the options.
18
- */
19
- checkboxesForMultiselect?: boolean;
20
- /**
21
- * Props that are passed to the input rendered for the autocomplete field.
22
- */
23
- inputTextFieldProps?: TextFieldProps;
24
- }
@@ -1,9 +0,0 @@
1
- import { LabeledValueWithGrouping } from "../../inputTypes";
2
- export declare enum GroupLabelSorting {
3
- Alphabetical = "alphabetical",
4
- GroupMemberCountAsc = "groupMemberCountAsc"
5
- }
6
- /**
7
- * Sorts option in the desired order.
8
- */
9
- export declare const useSortedOptionsWithGroup: (selectableOptions: LabeledValueWithGrouping[], sorting?: GroupLabelSorting) => LabeledValueWithGrouping[];
@@ -1,18 +0,0 @@
1
- import { CheckboxProps, FormControlLabelProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputCheckboxProps {
5
- checkboxProps?: Omit<CheckboxProps, "checked">;
6
- formControlLabelProps?: Omit<FormControlLabelProps, "control" | "label">;
7
- /**
8
- * In contrast to other FormFields,
9
- * the checkbox supports jsx elements as a label.
10
- *
11
- * If this is provided, formField.label will be ignored.
12
- */
13
- jsxLabel?: JSX.Element;
14
- }
15
- /**
16
- * Input for Checking a box indicating acceptance of something.
17
- */
18
- export declare const InputCheckbox: ({ formField, jsxLabel, checkboxProps, formControlLabelProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputCheckboxProps>) => JSX.Element;
@@ -1,16 +0,0 @@
1
- import { DatePickerProps as MuiDatePickerProps } from "@mui/x-date-pickers";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- /**
5
- * Mangled version of the original DatePickerProps type
6
- * from @mui/x-date-pickers.
7
- */
8
- type DatePickerProps = Omit<MuiDatePickerProps, "label" | "onChange" | "value">;
9
- export interface InputDatePickerProps {
10
- datePickerProps?: DatePickerProps;
11
- }
12
- /**
13
- * A Datetime picker that works with react hook form.
14
- */
15
- export declare const InputDatePicker: ({ formField, datePickerProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputDatePickerProps>) => JSX.Element;
16
- export {};
@@ -1,16 +0,0 @@
1
- import { DateTimePickerProps as MuiDateTimePickerProps } from "@mui/x-date-pickers";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- /**
5
- * Mangled version of the original DateTimePickerProps type
6
- * from @mui/x-date-pickers.
7
- */
8
- type DateTimePickerProps = Omit<MuiDateTimePickerProps, "label" | "onChange" | "value">;
9
- export interface InputDateTimePickerProps {
10
- dateTimePickerProps?: DateTimePickerProps;
11
- }
12
- /**
13
- * A Datetime picker that works with react hook form.
14
- */
15
- export declare const InputDateTimePicker: ({ formField, dateTimePickerProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputDateTimePickerProps>) => JSX.Element;
16
- export {};
@@ -1,15 +0,0 @@
1
- import { TextFieldProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { NumericFormatProps } from "react-number-format";
4
- import { BaseInputProps } from "../BaseInputProps";
5
- export interface InputNumberProps {
6
- textFieldProps?: Omit<TextFieldProps, "required" | "label" | "value">;
7
- numericFormatProps?: Omit<NumericFormatProps, "customInput">;
8
- }
9
- /**
10
- * Renders a MUI input text fields that handles input of number in a nice
11
- * way and is embedded in a react hook form context.
12
- *
13
- * @throws Error when FormContext is null.
14
- */
15
- export declare const InputNumber: ({ formField, textFieldProps, numericFormatProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputNumberProps>) => JSX.Element | null;
@@ -1,13 +0,0 @@
1
- import { OutlinedInputProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputOutlinedInputProps {
5
- outlinedInputProps?: Omit<OutlinedInputProps, "required" | "label">;
6
- }
7
- /**
8
- * Renders a MUI input text fields that is embedded in a react
9
- * hook form context.
10
- *
11
- * @throws Error when FormContext is null.
12
- */
13
- export declare const InputOutlinedInput: ({ formField, outlinedInputProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputOutlinedInputProps>) => JSX.Element | null;
@@ -1,13 +0,0 @@
1
- import { FormControlLabelProps, RadioGroupProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { LabeledValue } from "../../inputTypes";
4
- import { BaseInputProps } from "../BaseInputProps";
5
- export interface InputRadioProps {
6
- selectableOptions: LabeledValue[];
7
- formControlLabelProps?: Omit<FormControlLabelProps, "control" | "label" | "value">;
8
- radioGroupProps?: RadioGroupProps;
9
- }
10
- /**
11
- * Input for selecting between a list of options using radio buttons.
12
- */
13
- export declare const InputRadio: ({ formField, selectableOptions, formControlLabelProps, radioGroupProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputRadioProps>) => JSX.Element;
@@ -1,26 +0,0 @@
1
- import { SelectProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { LabeledValueWithGrouping } from "../../inputTypes";
4
- import { BaseInputProps } from "../BaseInputProps";
5
- export interface InputSelectProps {
6
- selectableOptions: LabeledValueWithGrouping[];
7
- /**
8
- * Text of an disabled item that can be rendered above the selectable options.
9
- */
10
- optionsTitle?: string;
11
- selectComponentProps?: Omit<SelectProps, "labelId" | "error" | "label" | "value">;
12
- /**
13
- * Element that is rendered in the end of a select item and holds
14
- * a tooltip with the disabled message for this option.
15
- *
16
- * If none is given the element is disabled without rendering a tooltip.
17
- */
18
- tooltipHolder?: JSX.Element;
19
- }
20
- /**
21
- * Renders a MUI select based that is embedded in a react hook
22
- * form context.
23
- *
24
- * @throws Error when FormContext is null.
25
- */
26
- export declare const InputSelect: ({ formField, selectableOptions, optionsTitle, selectComponentProps, tooltipHolder, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputSelectProps>) => JSX.Element;
@@ -1,15 +0,0 @@
1
- import { JSX } from "react";
2
- import { BaseInputProps } from "../BaseInputProps";
3
- import { InputSelectFromEnumProps } from "./InputSelectFromEnumInterfaces";
4
- /**
5
- * Renders a MUI select based on an enum that is embedded in a react hook form context.
6
- */
7
- export declare const InputSelectFromEnum: <EnumType extends Record<string, string>>(props: BaseInputProps<InputSelectFromEnumProps<EnumType>> & {
8
- /**
9
- * When this object is set, the input renders as an autocomplete.
10
- * (meaning you can type to search for entries)
11
- */
12
- autocomplete?: {
13
- noOptionText: string;
14
- } | undefined;
15
- }) => JSX.Element;
@@ -1,10 +0,0 @@
1
- import { TranslatedString } from "../../TranslatedString";
2
- import { InputSelectProps } from "../InputSelect/InputSelect";
3
- export interface InputSelectFromEnumProps<EnumType> extends Omit<InputSelectProps, "selectableOptions"> {
4
- enumData: EnumSelectData<EnumType>;
5
- limitOptions?: (keyof EnumType)[];
6
- }
7
- export interface EnumSelectData<EnumType> {
8
- enumToUse: EnumType;
9
- labelsForEnum: Record<keyof EnumType, TranslatedString | string>;
10
- }
@@ -1,13 +0,0 @@
1
- import { SliderProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputSliderProps {
5
- sliderProps?: Omit<SliderProps, "required" | "label">;
6
- }
7
- /**
8
- * Renders a MUI input text fields that is embedded in a react
9
- * hook form context.
10
- *
11
- * @throws Error when FormContext is null.
12
- */
13
- export declare const InputSlider: ({ formField, sliderProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputSliderProps>) => JSX.Element | null;
@@ -1,11 +0,0 @@
1
- import { FormControlLabelProps, SwitchProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputSwitchProps {
5
- switchProps?: Omit<SwitchProps, "checked">;
6
- formControlLabelProps?: Omit<FormControlLabelProps, "control" | "label">;
7
- }
8
- /**
9
- * Input for Checking a box indicating acceptance of something.
10
- */
11
- export declare const InputSwitch: ({ formField, switchProps, formControlLabelProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputSwitchProps>) => JSX.Element;
@@ -1,13 +0,0 @@
1
- import { TextFieldProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputTextFieldProps {
5
- textFieldProps?: Omit<TextFieldProps, "required" | "label">;
6
- }
7
- /**
8
- * Renders a MUI input text field that is embedded in a react
9
- * hook form context.
10
- *
11
- * @throws Error when FormContext is null.
12
- */
13
- export declare const InputTextField: ({ formField, textFieldProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputTextFieldProps>) => JSX.Element | null;
@@ -1,16 +0,0 @@
1
- import { TimePickerProps } from "@mui/x-date-pickers";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- /**
5
- * Mangled version of the original DateTimePickerProps type
6
- * from @mui/x-date-pickers.
7
- */
8
- type MangledTimePickerProps = Omit<TimePickerProps, "label" | "onChange" | "value">;
9
- export interface InputTimePickerProps {
10
- timePickerProps?: MangledTimePickerProps;
11
- }
12
- /**
13
- * A Datetime picker that works with react hook form.
14
- */
15
- export declare const InputTimePicker: ({ formField, timePickerProps, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputTimePickerProps>) => JSX.Element;
16
- export {};
@@ -1,12 +0,0 @@
1
- import { FormControlLabelProps, ToggleButtonProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputToggleButtonProps {
5
- toggleButtonProps?: Omit<ToggleButtonProps, "children" | "value">;
6
- formControlLabelProps?: Omit<FormControlLabelProps, "control" | "label">;
7
- children: React.ReactNode;
8
- }
9
- /**
10
- * Input Toggle button.
11
- */
12
- export declare const InputToggleButton: ({ formField, toggleButtonProps, formControlLabelProps, children, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputToggleButtonProps>) => JSX.Element;
@@ -1,34 +0,0 @@
1
- import { StackProps, ToggleButtonGroupProps, ToggleButtonProps, TypographyProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { BaseInputProps } from "../BaseInputProps";
4
- export interface InputToggleButtonGroupProps {
5
- toggleButtonGroupProps?: Omit<ToggleButtonGroupProps, "onChange" | "value">;
6
- /**
7
- * Props for the Stack component acting as the label-element.
8
- * Only used if a label is set.
9
- *
10
- * Use `direction` to change the label placement.
11
- */
12
- stackProps?: StackProps;
13
- /**
14
- * Props for the Typography component inside the label.
15
- * Does not include the required-asterisk.
16
- */
17
- typographyProps?: TypographyProps;
18
- buttons: SingleToggleButton[];
19
- /**
20
- * Ensures that at least one value needs to be selected.
21
- *
22
- * @default false
23
- */
24
- enforceValueSelected?: boolean;
25
- }
26
- export interface SingleToggleButton {
27
- icon: JSX.Element;
28
- value: string | number | boolean;
29
- toggleButtonProps?: ToggleButtonProps;
30
- }
31
- /**
32
- * Input for a toggle button group.
33
- */
34
- export declare const InputToggleButtonGroup: ({ formField, toggleButtonGroupProps, stackProps, typographyProps, buttons, enforceValueSelected, unregisterOptions, isUnregisteringOnUnmount, }: BaseInputProps<InputToggleButtonGroupProps>) => JSX.Element;
@@ -1,12 +0,0 @@
1
- import { UseFormUnregister } from "react-hook-form";
2
- export type UnregisterOptions = Parameters<UseFormUnregister<any>>[1];
3
- /**
4
- * An effect that unregisters a field from the form when the component unmounts.
5
- *
6
- * @throws Error when FormContext is null.
7
- */
8
- export declare const useEffectFieldUnregisterOnUnmount: ({ name, unregisterOptions, isUnregisteringOnUnmount, }: {
9
- name: string;
10
- isUnregisteringOnUnmount?: boolean | undefined;
11
- unregisterOptions?: UnregisterOptions;
12
- }) => void;
@@ -1 +0,0 @@
1
- export declare const formContextNull = "FormContext is null. This should not happen. You may need to use the HookFormProvider instead of the FormProvider exported by react-hook-form";
@@ -1,11 +0,0 @@
1
- import { FormHelperTextProps } from "@mui/material";
2
- import { JSX } from "react";
3
- /**
4
- * Renders field errors in an opinionated way.
5
- *
6
- * @throws Error when FormContext is null.
7
- */
8
- export declare const FormFieldError: ({ fieldName, formHelperTextProps, }: {
9
- fieldName: string;
10
- formHelperTextProps?: FormHelperTextProps<"p", {}> | undefined;
11
- }) => JSX.Element | null;
@@ -1,11 +0,0 @@
1
- import { FormHelperTextProps } from "@mui/material";
2
- import { JSX } from "react";
3
- import { FieldError } from "react-hook-form";
4
- /**
5
- * Renders field errors in an opinionated way.
6
- *
7
- */
8
- export declare const FormFieldErrorDisplay: ({ error, formHelperTextProps, }: {
9
- error: FieldError | FieldError[] | undefined;
10
- formHelperTextProps?: FormHelperTextProps<"p", {}> | undefined;
11
- }) => JSX.Element | null;
@@ -1,14 +0,0 @@
1
- import type { AnyObject } from "@nvon/baseline";
2
- import type { FieldError, FormState } from "react-hook-form";
3
- /**
4
- * Get the field errors for a (possibly nested) field name.
5
- *
6
- * Checking `formState.errors[fieldName]` only works if fieldName is not a path
7
- * (e.g. Does not include dots).
8
- *
9
- * Did not find a built-in way to do this … there might be one though.
10
- *
11
- * Supports both dot notation (e.g., "response.receipts.0.field") and
12
- * bracket notation (e.g., "response.receipts[0].field") for array fields.
13
- */
14
- export declare const getFormErrorForNestedKeys: (errors: FormState<AnyObject>["errors"], fieldName: string) => FieldError | FieldError[] | undefined;
@@ -1,7 +0,0 @@
1
- import { getFormErrorForNestedKeys } from "./getFormErrorForNestedKeys";
2
- /**
3
- * Returns the error for a given field name.
4
- *
5
- * @throws Error when FormContext is null.
6
- */
7
- export declare const useFormFieldError: (fieldName: string) => ReturnType<typeof getFormErrorForNestedKeys>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Returns whether or not a field has an error.
3
- *
4
- * @throws Error when FormContext is null.
5
- */
6
- export declare const useFormFieldHasError: (fieldName: string) => boolean;
@@ -1,15 +0,0 @@
1
- import { FormEvent } from "react";
2
- export type FormSubmitHandlerAsync = (event?: FormEvent) => Promise<void>;
3
- export type FormSubmitHandler = (event?: FormEvent) => void;
4
- /**
5
- * Turn an async submitHandler into a synchronous one.
6
- *
7
- * Reasoning:
8
- * - we're often talking to the API during form submission. The onSubmit handler will be returning a Promise in this case.
9
- * - the `form` element, per definition, always expects a synchronous function.
10
- * - creating on inline function in every form is a bit clumsy, and does not look clean.
11
- *
12
- * Then/catch cases should be properly handled by the submit handler itself,
13
- * the catch supplied here is only a last safety net against an "unhandled promise rejection" error.
14
- */
15
- export declare const syncSubmit: (asyncSubmitHandler: FormSubmitHandlerAsync) => FormSubmitHandler;