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

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/dist/LoadingButton/LoadingButton.d.ts +6 -0
  2. package/dist/LoadingButton/LoadingButtonInterfaces.d.ts +33 -0
  3. package/dist/LoadingButton/getLoadingButtonState.d.ts +20 -0
  4. package/dist/LoadingButton/index.d.ts +4 -0
  5. package/dist/formFields/HookFormProvider.d.ts +6 -0
  6. package/dist/formFields/InputEmail/InputEmail.d.ts +10 -0
  7. package/dist/formFields/InputPasswordSet/InputPasswordSet.d.ts +8 -0
  8. package/dist/formFields/InputPasswordSet/InputPasswordSetInterfaces.d.ts +18 -0
  9. package/dist/formFields/TranslatedString.d.ts +13 -0
  10. package/dist/formFields/baseTypes/BaseInputProps.d.ts +33 -0
  11. package/dist/formFields/baseTypes/InputAutocomplete/InputAutocomplete.d.ts +10 -0
  12. package/dist/formFields/baseTypes/InputAutocomplete/InputAutocompleteInterfaces.d.ts +27 -0
  13. package/dist/formFields/baseTypes/InputAutocomplete/useSortedOptionsWithGroup.d.ts +9 -0
  14. package/dist/formFields/baseTypes/InputCheckbox/InputCheckbox.d.ts +18 -0
  15. package/dist/formFields/baseTypes/InputDatePicker/InputDatePicker.d.ts +20 -0
  16. package/dist/formFields/baseTypes/InputDateTimePicker/InputDateTimePicker.d.ts +20 -0
  17. package/dist/formFields/baseTypes/InputNumber/InputNumber.d.ts +15 -0
  18. package/dist/formFields/baseTypes/InputOutlinedInput/InputOutlinedInput.d.ts +13 -0
  19. package/dist/formFields/baseTypes/InputRadio/InputRadio.d.ts +13 -0
  20. package/dist/formFields/baseTypes/InputSelect/InputSelect.d.ts +30 -0
  21. package/dist/formFields/baseTypes/InputSelectFromEnum/InputSelectFromEnum.d.ts +15 -0
  22. package/dist/formFields/baseTypes/InputSelectFromEnum/InputSelectFromEnumInterfaces.d.ts +10 -0
  23. package/dist/formFields/baseTypes/InputSlider/InputSlider.d.ts +13 -0
  24. package/dist/formFields/baseTypes/InputSwitch/InputSwitch.d.ts +11 -0
  25. package/dist/formFields/baseTypes/InputTextField/InputTextField.d.ts +13 -0
  26. package/dist/formFields/baseTypes/InputTimePicker/InputTimePicker.d.ts +20 -0
  27. package/dist/formFields/baseTypes/InputToggleButton/InputToggleButton.d.ts +12 -0
  28. package/dist/formFields/baseTypes/InputToggleButtonGroup/InputToggleButtonGroup.d.ts +34 -0
  29. package/dist/formFields/baseTypes/useEffectFieldUnregisterOnUnmount.d.ts +12 -0
  30. package/dist/formFields/errorMessages.d.ts +1 -0
  31. package/dist/formFields/errors/FormFieldError.d.ts +11 -0
  32. package/dist/formFields/errors/FormFieldErrorDisplay.d.ts +11 -0
  33. package/dist/formFields/errors/getFormErrorForNestedKeys.d.ts +14 -0
  34. package/dist/formFields/errors/useFormFieldError.d.ts +7 -0
  35. package/dist/formFields/errors/useFormFieldHasError.d.ts +6 -0
  36. package/dist/formFields/formHelper/syncSubmit.d.ts +15 -0
  37. package/dist/formFields/formHelper/useHookForm.d.ts +28 -0
  38. package/dist/formFields/formHelper/useHookFormContext.d.ts +9 -0
  39. package/dist/formFields/formHelper/useMergedFormField.d.ts +15 -0
  40. package/dist/formFields/formHelper/useSortedOptionsWithGroup.d.ts +5 -0
  41. package/dist/formFields/formHelper/useTranslateString.d.ts +8 -0
  42. package/dist/formFields/index.d.ts +49 -0
  43. package/dist/formFields/inputTypes.d.ts +76 -0
  44. package/dist/packageExports.d.ts +9 -0
  45. package/dist/packageExports.js +1838 -0
  46. package/dist/packageExports.js.map +1 -0
  47. package/package.json +21 -18
@@ -0,0 +1,15 @@
1
+ import { TFunction } from "i18next";
2
+ import { FormField, FormFieldTranslated } from "../inputTypes";
3
+ /**
4
+ * Merge a form field with defaults.
5
+ */
6
+ export declare const useMergedFormField: (
7
+ /**
8
+ * Form fields, typically those passed into a component.
9
+ *
10
+ */
11
+ formField: FormField, tOverride?: TFunction,
12
+ /**
13
+ * Additional defaults. Duplicate values will be overridden by the formField.
14
+ */
15
+ formFieldDefaults?: Partial<FormField>) => FormFieldTranslated;
@@ -0,0 +1,5 @@
1
+ import { LabeledValueWithGrouping } from "../inputTypes";
2
+ /**
3
+ * Sorts the options by group and value.
4
+ */
5
+ export declare const useSortedOptionsWithGroup: (selectableOptions: LabeledValueWithGrouping[]) => LabeledValueWithGrouping[];
@@ -0,0 +1,8 @@
1
+ import { TFunction } from "i18next";
2
+ import { TranslatedString } from "../TranslatedString";
3
+ /**
4
+ * Return a function which turns our TranslatedString into a plain string.
5
+ *
6
+ * Uses the given t and falls back to the global i18next t.
7
+ */
8
+ export declare const useTranslateString: () => ((input: TranslatedString | string, t?: TFunction) => string);
@@ -0,0 +1,49 @@
1
+ export { InputAutocomplete } from "./baseTypes/InputAutocomplete/InputAutocomplete";
2
+ export type { InputAutocompleteProps } from "./baseTypes/InputAutocomplete/InputAutocompleteInterfaces";
3
+ export type { GroupLabelSorting } from "./baseTypes/InputAutocomplete/useSortedOptionsWithGroup";
4
+ export { InputCheckbox } from "./baseTypes/InputCheckbox/InputCheckbox";
5
+ export type { InputCheckboxProps } from "./baseTypes/InputCheckbox/InputCheckbox";
6
+ export { InputDatePicker } from "./baseTypes/InputDatePicker/InputDatePicker";
7
+ export type { InputDatePickerProps } from "./baseTypes/InputDatePicker/InputDatePicker";
8
+ export { InputDateTimePicker } from "./baseTypes/InputDateTimePicker/InputDateTimePicker";
9
+ export type { InputDateTimePickerProps } from "./baseTypes/InputDateTimePicker/InputDateTimePicker";
10
+ export { InputNumber } from "./baseTypes/InputNumber/InputNumber";
11
+ export type { InputNumberProps } from "./baseTypes/InputNumber/InputNumber";
12
+ export { InputOutlinedInput, InputOutlinedInput as InputText, } from "./baseTypes/InputOutlinedInput/InputOutlinedInput";
13
+ export type { InputOutlinedInputProps, InputOutlinedInputProps as InputTextProps, } from "./baseTypes/InputOutlinedInput/InputOutlinedInput";
14
+ export { InputRadio } from "./baseTypes/InputRadio/InputRadio";
15
+ export type { InputRadioProps } from "./baseTypes/InputRadio/InputRadio";
16
+ export { InputSelect } from "./baseTypes/InputSelect/InputSelect";
17
+ export type { InputSelectProps } from "./baseTypes/InputSelect/InputSelect";
18
+ export { InputSelectFromEnum } from "./baseTypes/InputSelectFromEnum/InputSelectFromEnum";
19
+ export type { InputSelectFromEnumProps } from "./baseTypes/InputSelectFromEnum/InputSelectFromEnumInterfaces";
20
+ export { InputSlider } from "./baseTypes/InputSlider/InputSlider";
21
+ export type { InputSliderProps } from "./baseTypes/InputSlider/InputSlider";
22
+ export { InputSwitch } from "./baseTypes/InputSwitch/InputSwitch";
23
+ export type { InputSwitchProps } from "./baseTypes/InputSwitch/InputSwitch";
24
+ export { InputTextField } from "./baseTypes/InputTextField/InputTextField";
25
+ export type { InputTextFieldProps } from "./baseTypes/InputTextField/InputTextField";
26
+ export { InputTimePicker } from "./baseTypes/InputTimePicker/InputTimePicker";
27
+ export type { InputTimePickerProps } from "./baseTypes/InputTimePicker/InputTimePicker";
28
+ export { InputToggleButton } from "./baseTypes/InputToggleButton/InputToggleButton";
29
+ export type { InputToggleButtonProps } from "./baseTypes/InputToggleButton/InputToggleButton";
30
+ export { InputToggleButtonGroup } from "./baseTypes/InputToggleButtonGroup/InputToggleButtonGroup";
31
+ export type { InputToggleButtonGroupProps, SingleToggleButton, } from "./baseTypes/InputToggleButtonGroup/InputToggleButtonGroup";
32
+ export { getFormErrorForNestedKeys } from "./errors/getFormErrorForNestedKeys";
33
+ export { useFormFieldError } from "./errors/useFormFieldError";
34
+ export { useFormFieldHasError } from "./errors/useFormFieldHasError";
35
+ export { syncSubmit } from "./formHelper/syncSubmit";
36
+ export type { FormSubmitHandler, FormSubmitHandlerAsync, } from "./formHelper/syncSubmit";
37
+ export { useHookForm, useHookFormFieldArray } from "./formHelper/useHookForm";
38
+ export type { FieldNameGetter, FormReturn } from "./formHelper/useHookForm";
39
+ export { useHookFormContext } from "./formHelper/useHookFormContext";
40
+ export { useMergedFormField } from "./formHelper/useMergedFormField";
41
+ export { useSortedOptionsWithGroup } from "./formHelper/useSortedOptionsWithGroup";
42
+ export { useTranslateString } from "./formHelper/useTranslateString";
43
+ export { HookFormProvider } from "./HookFormProvider";
44
+ export { InputEmail } from "./InputEmail/InputEmail";
45
+ export type { InputEmailProps } from "./InputEmail/InputEmail";
46
+ export { InputPasswordSet } from "./InputPasswordSet/InputPasswordSet";
47
+ export type { InputPasswordSetProps } from "./InputPasswordSet/InputPasswordSetInterfaces";
48
+ export type { FormField, FormFieldTranslated, LabeledValue, LabeledValueWithGrouping, TranslatedValidate, } from "./inputTypes";
49
+ export type { TranslatedString } from "./TranslatedString";
@@ -0,0 +1,76 @@
1
+ import { TFunction } from "i18next";
2
+ import { RegisterOptions } from "react-hook-form";
3
+ import { TranslatedString } from "./TranslatedString";
4
+ /**
5
+ * An arbitrary value with a human-readable label.
6
+ * To be used for selects/autocompletes/….
7
+ */
8
+ export interface LabeledValue {
9
+ label: string;
10
+ value: string | number | boolean;
11
+ /**
12
+ * A string can be provided to indicate a reason for being disabled.
13
+ */
14
+ disabled?: boolean | string;
15
+ }
16
+ /**
17
+ * An arbitrary value, a human-readable label and a group.
18
+ * To be used for selects/autocompletes/….
19
+ */
20
+ export interface LabeledValueWithGrouping extends LabeledValue {
21
+ group?: string;
22
+ }
23
+ export type TranslatedValidate = (t: TFunction) => RegisterOptions["validate"];
24
+ /**
25
+ * Generic props received by any form field.
26
+ *
27
+ * String values can be given as TranslatedString to faclitate having static defaults.
28
+ */
29
+ export interface FormField {
30
+ /**
31
+ * The label shown to the user.
32
+ */
33
+ label?: string | TranslatedString;
34
+ /**
35
+ * The name within the react-hook-form context.
36
+ */
37
+ name: string;
38
+ /**
39
+ * T Function from i18next for translating stuff.
40
+ */
41
+ t?: TFunction;
42
+ /**
43
+ * @default false
44
+ */
45
+ required?: boolean;
46
+ /**
47
+ * Shown when the field is not filled out, but required.
48
+ */
49
+ requiredErrorMessage?: string | TranslatedString;
50
+ /**
51
+ * Custom validation function(s) for the field.
52
+ *
53
+ * Note: this is expected to be a function (receiving a TFunction) returning the validation function.
54
+ *
55
+ * @example
56
+ * ```
57
+ * // validate a string input, returning a translated error message
58
+ * const validate = (t) => (input: string) => {
59
+ * if (!input) {
60
+ * return t("common:invalidStuff")
61
+ * }
62
+ * }
63
+ * ```
64
+ */
65
+ validate?: RegisterOptions["validate"] | {
66
+ translated: TranslatedValidate;
67
+ } | undefined;
68
+ }
69
+ /**
70
+ * The FormField with applied translations.
71
+ */
72
+ export interface FormFieldTranslated extends Omit<FormField, "label" | "requiredErrorMessage" | "validate"> {
73
+ label: string;
74
+ requiredErrorMessage: string;
75
+ validate: RegisterOptions["validate"] | undefined;
76
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This is the main package file, containing everything that our package exports.
3
+ */
4
+ export { getFormErrorForNestedKeys, HookFormProvider, InputAutocomplete, InputCheckbox, InputDatePicker, InputDateTimePicker, InputEmail, InputNumber, InputOutlinedInput, InputPasswordSet, InputRadio, InputSelect, InputSelectFromEnum, InputSlider, InputSwitch, InputText, InputTextField, InputTimePicker, InputToggleButton, InputToggleButtonGroup, syncSubmit, useFormFieldError, useFormFieldHasError, useHookForm, useHookFormContext, useHookFormFieldArray, useMergedFormField, useSortedOptionsWithGroup, useTranslateString, } from "./formFields";
5
+ export type { FieldNameGetter, FormField, FormFieldTranslated, FormReturn, FormSubmitHandler, FormSubmitHandlerAsync, GroupLabelSorting, InputAutocompleteProps, InputCheckboxProps, InputDatePickerProps, InputDateTimePickerProps, InputEmailProps, InputNumberProps, InputOutlinedInputProps, InputPasswordSetProps, InputRadioProps, InputSelectFromEnumProps, InputSelectProps, InputSliderProps, InputSwitchProps, InputTextFieldProps, InputTextProps, InputTimePickerProps, InputToggleButtonGroupProps, InputToggleButtonProps, LabeledValue, LabeledValueWithGrouping, SingleToggleButton, TranslatedString, TranslatedValidate, } from "./formFields/";
6
+ export { FormFieldError } from "./formFields/errors/FormFieldError";
7
+ export { FormFieldErrorDisplay } from "./formFields/errors/FormFieldErrorDisplay";
8
+ export { LoadingButton, LoadingButtonState, loadingButtonStateFromFormState, loadingButtonStateFromReactQueryMutationStatus, useLoadingButtonStateFromFormContext, } from "./LoadingButton";
9
+ export type { LoadingButtonProps } from "./LoadingButton";