@luscii-healthtech/web-ui 2.48.2 → 2.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Form/Form.d.ts +12 -2
- package/dist/components/Form/FormFieldCheckbox.d.ts +7 -1
- package/dist/components/Form/FormFieldCheckboxList.d.ts +9 -0
- package/dist/components/Form/FormFieldLabeler.d.ts +7 -0
- package/dist/components/Form/FormImagePicker.d.ts +7 -1
- package/dist/components/Form/FormInput.d.ts +10 -2
- package/dist/components/Form/FormRadioGroup.d.ts +8 -1
- package/dist/components/Form/FormSelect.d.ts +8 -1
- package/dist/components/Form/form.types.d.ts +36 -45
- package/dist/index.d.ts +1 -2
- package/dist/web-ui.cjs.development.js +100 -7
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.js +100 -7
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Form/FormFieldDecorator.d.ts +0 -7
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { type FieldValues } from "react-hook-form/dist/index.ie11";
|
|
2
|
-
import {
|
|
1
|
+
import { type FieldValues, type UseFormMethods as UseFormReturn, DeepPartial, SubmitErrorHandler, SubmitHandler, UnpackNestedValue } from "react-hook-form/dist/index.ie11";
|
|
2
|
+
import { FormFieldConfiguration } from "./form.types";
|
|
3
|
+
export interface GenericFormProps<TFieldValues extends FieldValues> {
|
|
4
|
+
fields: FormFieldConfiguration<TFieldValues>[];
|
|
5
|
+
onValid: SubmitHandler<TFieldValues>;
|
|
6
|
+
onError?: SubmitErrorHandler<TFieldValues>;
|
|
7
|
+
defaultValues?: UnpackNestedValue<DeepPartial<TFieldValues>>;
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* Create a straight forward Form, which takes away the 'overhead' of react-hook-form.
|
|
5
11
|
*
|
|
@@ -9,6 +15,10 @@ import { FormProps, GenericFormProps } from "./form.types";
|
|
|
9
15
|
* TODO: make the buttons configurable.
|
|
10
16
|
*/
|
|
11
17
|
export declare function GenericForm<TFieldValues extends FieldValues>({ fields, onValid, onError, defaultValues, }: GenericFormProps<TFieldValues>): JSX.Element;
|
|
18
|
+
export interface FormProps<TFieldValues extends FieldValues> {
|
|
19
|
+
fields: FormFieldConfiguration<TFieldValues>[];
|
|
20
|
+
useFormReturn: UseFormReturn<TFieldValues>;
|
|
21
|
+
}
|
|
12
22
|
/**
|
|
13
23
|
* Creates a Form based on the fields input.
|
|
14
24
|
*
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
3
|
+
import { FieldCheckboxConfiguration, FormFieldLabelerWithFormProps } from "./form.types";
|
|
4
|
+
interface FormCheckboxProps extends FieldCheckboxConfiguration, FormFieldLabelerWithFormProps {
|
|
5
|
+
control: Control;
|
|
6
|
+
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
7
|
+
}
|
|
3
8
|
export declare const FormFieldCheckbox: React.ForwardRefExoticComponent<FormCheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
3
|
+
import { FieldCheckboxListConfiguration, FormFieldLabelerWithFormProps } from "./form.types";
|
|
4
|
+
interface FormCheckboxListProps extends FieldCheckboxListConfiguration, FormFieldLabelerWithFormProps {
|
|
5
|
+
control: Control;
|
|
6
|
+
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
7
|
+
}
|
|
8
|
+
export declare const FormFieldCheckboxList: React.FC<FormCheckboxListProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormFieldLabelerWithFormProps } from "./form.types";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator for any input component. Adds a label and additional information to be shown.
|
|
4
|
+
*
|
|
5
|
+
* Includes the default error handling from react-hook-form.
|
|
6
|
+
*/
|
|
7
|
+
export declare function FormFieldLabeler({ name, children, label, fieldRequired, info, fieldErrors, decoratorClassname, }: FormFieldLabelerWithFormProps): JSX.Element;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
3
|
+
import { ImagePickerFieldConfiguration, FormFieldLabelerWithFormProps } from "./form.types";
|
|
4
|
+
interface FormImagePickerProps extends ImagePickerFieldConfiguration, FormFieldLabelerWithFormProps {
|
|
5
|
+
control: Control;
|
|
6
|
+
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
7
|
+
}
|
|
3
8
|
export declare const FormImagePicker: React.ForwardRefExoticComponent<FormImagePickerProps & React.RefAttributes<any>>;
|
|
9
|
+
export {};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
1
|
+
import React, { HTMLInputTypeAttribute } from "react";
|
|
2
|
+
import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
3
|
+
import { InputProps } from "../Input/Input";
|
|
4
|
+
import { FormFieldLabelerWithFormProps } from "./form.types";
|
|
5
|
+
interface FormInputProps extends Omit<InputProps, "name">, FormFieldLabelerWithFormProps {
|
|
6
|
+
control: Control;
|
|
7
|
+
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
8
|
+
type: Extract<HTMLInputTypeAttribute, "email" | "number" | "password" | "text">;
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* Input field that can be used in any react-hook-form context.
|
|
5
12
|
*/
|
|
6
13
|
export declare const FormInput: React.ForwardRefExoticComponent<FormInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
14
|
+
export {};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
3
|
+
import { RadioGroupProps } from "../RadioGroup/RadioGroupV2";
|
|
4
|
+
import { FormFieldLabelerWithFormProps } from "./form.types";
|
|
5
|
+
interface FormRadioGroupProps extends Omit<RadioGroupProps, "name">, FormFieldLabelerWithFormProps {
|
|
6
|
+
control: Control;
|
|
7
|
+
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* Radio Group that can be used in any react-hook-form context.
|
|
5
11
|
*/
|
|
6
12
|
export declare const FormRadioGroup: React.ForwardRefExoticComponent<FormRadioGroupProps & React.RefAttributes<HTMLInputElement>>;
|
|
13
|
+
export {};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Control, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
3
|
+
import { SelectProps } from "../Select/Select";
|
|
4
|
+
import { FormFieldLabelerWithFormProps } from "./form.types";
|
|
5
|
+
interface FormSelectProps extends Omit<SelectProps, "name">, FormFieldLabelerWithFormProps {
|
|
6
|
+
control: Control;
|
|
7
|
+
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
8
|
+
}
|
|
3
9
|
export declare const FormSelect: React.ForwardRefExoticComponent<FormSelectProps & React.RefAttributes<any>>;
|
|
10
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldErrors, FieldName, FieldValues, RegisterOptions } from "react-hook-form/dist/index.ie11";
|
|
2
2
|
import React, { HTMLInputTypeAttribute } from "react";
|
|
3
3
|
import { InputProps } from "../Input/Input";
|
|
4
4
|
import { RadioGroupProps } from "../RadioGroup/RadioGroupV2";
|
|
@@ -6,78 +6,69 @@ import { SelectProps } from "../Select/Select";
|
|
|
6
6
|
import { ImagePickerProps } from "../ImagePicker/ImagePicker";
|
|
7
7
|
import { PartialProperties } from "../../types/general.types";
|
|
8
8
|
import { CheckboxProps } from "../Checkbox/Checkbox";
|
|
9
|
+
import { CheckboxListProps } from "../CheckboxList/CheckboxList.types";
|
|
9
10
|
export declare type AllowedTextInputTypes = Extract<HTMLInputTypeAttribute, "email" | "number" | "password" | "text">;
|
|
10
11
|
export declare type FormFieldWidth = "sm" | "md" | "lg" | "xl" | "full";
|
|
11
|
-
|
|
12
|
-
fields: FormFieldProps<TFieldValues>[];
|
|
13
|
-
onValid: SubmitHandler<TFieldValues>;
|
|
14
|
-
onError?: SubmitErrorHandler<TFieldValues>;
|
|
15
|
-
defaultValues?: UnpackNestedValue<DeepPartial<TFieldValues>>;
|
|
16
|
-
}
|
|
17
|
-
export interface FormProps<TFieldValues extends FieldValues> {
|
|
18
|
-
fields: FormFieldProps<TFieldValues>[];
|
|
19
|
-
useFormReturn: UseFormReturn<TFieldValues>;
|
|
20
|
-
}
|
|
21
|
-
interface FormFieldGenericProps<TFieldType> extends FormFieldDecoratorProps {
|
|
12
|
+
interface FormFieldBaseConfiguration<TFieldType> extends FormFieldLabelerProps {
|
|
22
13
|
name: FieldName<FieldValues>;
|
|
23
14
|
options?: RegisterOptions;
|
|
24
15
|
fieldProps?: TFieldType;
|
|
25
16
|
}
|
|
26
|
-
export interface
|
|
17
|
+
export interface FormFieldLabelerProps {
|
|
27
18
|
label?: string;
|
|
28
19
|
info?: string;
|
|
20
|
+
/**
|
|
21
|
+
* allow for custom styling of the labeler component
|
|
22
|
+
*/
|
|
29
23
|
decoratorClassname?: string;
|
|
30
24
|
}
|
|
31
|
-
export declare type
|
|
32
|
-
|
|
25
|
+
export declare type FormFieldConfiguration<TFieldValues> = FieldInputConfiguration | FieldSelectConfiguration | FieldImagePickerConfiguration | FieldRadioGroupConfiguration | FieldRowConfiguration<TFieldValues> | FieldCheckboxConfiguration | FieldCheckboxListConfiguration;
|
|
26
|
+
/**
|
|
27
|
+
* @backwardscompatibility
|
|
28
|
+
* @deprecated - this is an alias for `FormFieldConfiguration`, for backwards compatibility the name can remain for now, but
|
|
29
|
+
* import `FormFieldConfiguration` whenever you need this type in the future.
|
|
30
|
+
*/
|
|
31
|
+
export declare type FormFieldProps<TFieldValues> = FormFieldConfiguration<TFieldValues>;
|
|
32
|
+
export interface FieldRowConfiguration<TFieldValues> extends Record<keyof FormFieldBaseConfiguration<never>, never> {
|
|
33
33
|
type: "row";
|
|
34
34
|
key: string;
|
|
35
|
-
fields:
|
|
35
|
+
fields: FormFieldConfiguration<TFieldValues>[];
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface FieldInputConfiguration extends FormFieldBaseConfiguration<Omit<InputProps, "name">> {
|
|
38
38
|
type: AllowedTextInputTypes;
|
|
39
39
|
}
|
|
40
|
-
export interface
|
|
40
|
+
export interface FieldRadioGroupConfiguration extends FormFieldBaseConfiguration<Omit<RadioGroupProps, "name">> {
|
|
41
41
|
type: "radioGroup";
|
|
42
42
|
}
|
|
43
|
-
export interface
|
|
43
|
+
export interface FieldSelectConfiguration extends FormFieldBaseConfiguration<SelectProps> {
|
|
44
44
|
type: "select";
|
|
45
45
|
fieldProps: SelectProps;
|
|
46
46
|
}
|
|
47
|
-
declare type
|
|
48
|
-
export interface
|
|
47
|
+
export declare type ImagePickerFieldConfiguration = PartialProperties<Omit<ImagePickerProps, "name">, "handleChange">;
|
|
48
|
+
export interface FieldImagePickerConfiguration extends FormFieldBaseConfiguration<ImagePickerFieldConfiguration> {
|
|
49
49
|
type: "imagePicker";
|
|
50
|
-
fieldProps:
|
|
50
|
+
fieldProps: ImagePickerFieldConfiguration;
|
|
51
51
|
}
|
|
52
|
-
export interface
|
|
52
|
+
export interface FieldCheckboxConfiguration extends FormFieldBaseConfiguration<Omit<CheckboxProps, "name" | "type">> {
|
|
53
53
|
type: "checkbox";
|
|
54
54
|
variant?: CheckboxProps["type"];
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Omiting `groups` and `onChange` here because these will be handled by
|
|
58
|
+
* the `Control` component from react-hook-form.
|
|
59
|
+
*/
|
|
60
|
+
export interface FieldCheckboxListConfiguration extends FormFieldBaseConfiguration<Omit<CheckboxListProps, "groups" | "onChange">> {
|
|
61
|
+
type: "checkboxlist";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* This type is the base for every form field component wrapped in the `FormFieldLabeler` and `Control` from `react-form-hook`.
|
|
65
|
+
* This is your baseline for creating a new form field type. For reference, look at FormInput.tsx.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
export interface FormFieldLabelerWithFormProps extends FormFieldLabelerProps {
|
|
57
69
|
name: string;
|
|
58
70
|
fieldErrors: FieldErrors;
|
|
59
71
|
fieldRequired: boolean;
|
|
60
72
|
children?: React.ReactNode;
|
|
61
73
|
}
|
|
62
|
-
export interface FormInputProps extends Omit<InputProps, "name">, FormFieldDecoratorWithGeneratedProps {
|
|
63
|
-
control: Control;
|
|
64
|
-
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
65
|
-
type: Extract<HTMLInputTypeAttribute, "email" | "number" | "password" | "text">;
|
|
66
|
-
}
|
|
67
|
-
export interface FormRadioGroupProps extends Omit<RadioGroupProps, "name">, FormFieldDecoratorWithGeneratedProps {
|
|
68
|
-
control: Control;
|
|
69
|
-
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
70
|
-
}
|
|
71
|
-
export interface FormSelectProps extends Omit<SelectProps, "name">, FormFieldDecoratorWithGeneratedProps {
|
|
72
|
-
control: Control;
|
|
73
|
-
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
74
|
-
}
|
|
75
|
-
export interface FormImagePickerProps extends ImagePickerFieldProps, FormFieldDecoratorWithGeneratedProps {
|
|
76
|
-
control: Control;
|
|
77
|
-
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
78
|
-
}
|
|
79
|
-
export interface FormCheckboxProps extends FormFieldCheckboxBaseProps, FormFieldDecoratorWithGeneratedProps {
|
|
80
|
-
control: Control;
|
|
81
|
-
rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
|
|
82
|
-
}
|
|
83
74
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -71,8 +71,7 @@ export { Timeline } from "./components/Timeline/Timeline";
|
|
|
71
71
|
export { ViewItem, ViewItemProps } from "./components/ViewItem/ViewItem";
|
|
72
72
|
export { default as Text } from "./components/Text/Text";
|
|
73
73
|
export { SearchInput, SearchInputProps } from "./components/Input/SearchInput";
|
|
74
|
-
export { GenericForm, Form } from "./components/Form/Form";
|
|
75
|
-
export { GenericFormProps, FormProps } from "./components/Form/form.types";
|
|
74
|
+
export { GenericForm, Form, FormProps, GenericFormProps, } from "./components/Form/Form";
|
|
76
75
|
export { Icon } from "./components/Icon";
|
|
77
76
|
export type { IconProps, IconKey, } from "./components/Icons/types/IconProps.type";
|
|
78
77
|
export * from "./components/Icons";
|
|
@@ -7585,7 +7585,7 @@ var FormFieldErrorMessages = function FormFieldErrorMessages(props) {
|
|
|
7585
7585
|
* Includes the default error handling from react-hook-form.
|
|
7586
7586
|
*/
|
|
7587
7587
|
|
|
7588
|
-
function
|
|
7588
|
+
function FormFieldLabeler(_ref) {
|
|
7589
7589
|
var name = _ref.name,
|
|
7590
7590
|
children = _ref.children,
|
|
7591
7591
|
label = _ref.label,
|
|
@@ -7596,7 +7596,7 @@ function FormFieldDecorator(_ref) {
|
|
|
7596
7596
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
7597
7597
|
className: classNames(decoratorClassname)
|
|
7598
7598
|
}, label && /*#__PURE__*/React__default.createElement("label", {
|
|
7599
|
-
className: "cweb-form-field-label
|
|
7599
|
+
className: "block mb-1 cweb-form-field-label",
|
|
7600
7600
|
htmlFor: name,
|
|
7601
7601
|
"data-is-required": fieldRequired
|
|
7602
7602
|
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
@@ -7639,7 +7639,7 @@ var FormInput = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef)
|
|
|
7639
7639
|
decoratorClassname = _ref.decoratorClassname,
|
|
7640
7640
|
fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$p);
|
|
7641
7641
|
|
|
7642
|
-
return /*#__PURE__*/React__default.createElement(
|
|
7642
|
+
return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
|
|
7643
7643
|
name: name,
|
|
7644
7644
|
fieldErrors: fieldErrors,
|
|
7645
7645
|
fieldRequired: fieldRequired,
|
|
@@ -7676,7 +7676,7 @@ var FormRadioGroup = /*#__PURE__*/React__default.forwardRef(function (_ref, inne
|
|
|
7676
7676
|
decoratorClassname = _ref.decoratorClassname,
|
|
7677
7677
|
fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$q);
|
|
7678
7678
|
|
|
7679
|
-
return /*#__PURE__*/React__default.createElement(
|
|
7679
|
+
return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
|
|
7680
7680
|
name: name,
|
|
7681
7681
|
fieldErrors: fieldErrors,
|
|
7682
7682
|
fieldRequired: fieldRequired,
|
|
@@ -7714,7 +7714,7 @@ var FormSelect = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef
|
|
|
7714
7714
|
decoratorClassname = _ref.decoratorClassname,
|
|
7715
7715
|
selectProps = _objectWithoutPropertiesLoose(_ref, _excluded$r);
|
|
7716
7716
|
|
|
7717
|
-
return /*#__PURE__*/React__default.createElement(
|
|
7717
|
+
return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
|
|
7718
7718
|
name: name,
|
|
7719
7719
|
fieldErrors: fieldErrors,
|
|
7720
7720
|
fieldRequired: fieldRequired,
|
|
@@ -7747,7 +7747,7 @@ var FormImagePicker = /*#__PURE__*/React__default.forwardRef(function (_ref, inn
|
|
|
7747
7747
|
decoratorClassname = _ref.decoratorClassname,
|
|
7748
7748
|
fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$s);
|
|
7749
7749
|
|
|
7750
|
-
return /*#__PURE__*/React__default.createElement(
|
|
7750
|
+
return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
|
|
7751
7751
|
name: name,
|
|
7752
7752
|
fieldErrors: fieldErrors,
|
|
7753
7753
|
fieldRequired: fieldRequired,
|
|
@@ -7796,7 +7796,7 @@ var FormFieldCheckbox = /*#__PURE__*/React__default.forwardRef(function (_ref, i
|
|
|
7796
7796
|
decoratorClassname = _ref.decoratorClassname,
|
|
7797
7797
|
fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$t);
|
|
7798
7798
|
|
|
7799
|
-
return /*#__PURE__*/React__default.createElement(
|
|
7799
|
+
return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
|
|
7800
7800
|
name: name,
|
|
7801
7801
|
fieldErrors: fieldErrors,
|
|
7802
7802
|
fieldRequired: fieldRequired,
|
|
@@ -7830,6 +7830,84 @@ var FormFieldCheckbox = /*#__PURE__*/React__default.forwardRef(function (_ref, i
|
|
|
7830
7830
|
}));
|
|
7831
7831
|
});
|
|
7832
7832
|
|
|
7833
|
+
var FormFieldCheckboxList = function FormFieldCheckboxList(_ref) {
|
|
7834
|
+
var control = _ref.control,
|
|
7835
|
+
name = _ref.name,
|
|
7836
|
+
rules = _ref.rules,
|
|
7837
|
+
fieldErrors = _ref.fieldErrors,
|
|
7838
|
+
fieldRequired = _ref.fieldRequired,
|
|
7839
|
+
label = _ref.label,
|
|
7840
|
+
info = _ref.info,
|
|
7841
|
+
decoratorClassname = _ref.decoratorClassname,
|
|
7842
|
+
_ref$fieldProps = _ref.fieldProps,
|
|
7843
|
+
fieldProps = _ref$fieldProps === void 0 ? {
|
|
7844
|
+
groups: [],
|
|
7845
|
+
onChange: function onChange() {
|
|
7846
|
+
return undefined;
|
|
7847
|
+
}
|
|
7848
|
+
} : _ref$fieldProps;
|
|
7849
|
+
return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
|
|
7850
|
+
name: name,
|
|
7851
|
+
fieldErrors: fieldErrors,
|
|
7852
|
+
fieldRequired: fieldRequired,
|
|
7853
|
+
label: label,
|
|
7854
|
+
info: info,
|
|
7855
|
+
decoratorClassname: decoratorClassname
|
|
7856
|
+
}, /*#__PURE__*/React__default.createElement(index_ie11.Controller, {
|
|
7857
|
+
name: name,
|
|
7858
|
+
control: control,
|
|
7859
|
+
rules: rules,
|
|
7860
|
+
render: function render(_ref2) {
|
|
7861
|
+
var _onChange = _ref2.onChange,
|
|
7862
|
+
value = _ref2.value;
|
|
7863
|
+
var className = fieldProps.className,
|
|
7864
|
+
hasDividers = fieldProps.hasDividers;
|
|
7865
|
+
|
|
7866
|
+
var _useState = React.useState(value),
|
|
7867
|
+
checkboxListValues = _useState[0],
|
|
7868
|
+
setCheckboxListValues = _useState[1];
|
|
7869
|
+
|
|
7870
|
+
React.useEffect(function () {
|
|
7871
|
+
setCheckboxListValues(value);
|
|
7872
|
+
}, [value]);
|
|
7873
|
+
return /*#__PURE__*/React__default.createElement(CheckboxList, {
|
|
7874
|
+
groups: checkboxListValues,
|
|
7875
|
+
hasDividers: hasDividers,
|
|
7876
|
+
className: className,
|
|
7877
|
+
onChange: function onChange(event) {
|
|
7878
|
+
/**
|
|
7879
|
+
* This needs to be asynchronously orchestrated
|
|
7880
|
+
* because the CheckboxList component triggers multiple onChange
|
|
7881
|
+
* events after each other when you click a group that checks/unchecks the items.
|
|
7882
|
+
*
|
|
7883
|
+
* By always relying on the previous state, React can make put all changes together in one go.
|
|
7884
|
+
*/
|
|
7885
|
+
setCheckboxListValues(function (previousState) {
|
|
7886
|
+
var newState = previousState.map(function (group) {
|
|
7887
|
+
var newItems = group.items.map(function (item) {
|
|
7888
|
+
if (item.id === event.id) {
|
|
7889
|
+
return _extends({}, item, {
|
|
7890
|
+
isChecked: event.newCheckedValue
|
|
7891
|
+
});
|
|
7892
|
+
} else {
|
|
7893
|
+
return item;
|
|
7894
|
+
}
|
|
7895
|
+
});
|
|
7896
|
+
return _extends({}, group, {
|
|
7897
|
+
items: newItems
|
|
7898
|
+
});
|
|
7899
|
+
});
|
|
7900
|
+
|
|
7901
|
+
_onChange(newState);
|
|
7902
|
+
|
|
7903
|
+
return newState;
|
|
7904
|
+
});
|
|
7905
|
+
}
|
|
7906
|
+
});
|
|
7907
|
+
}
|
|
7908
|
+
}));
|
|
7909
|
+
};
|
|
7910
|
+
|
|
7833
7911
|
/**
|
|
7834
7912
|
* Create a straight forward Form, which takes away the 'overhead' of react-hook-form.
|
|
7835
7913
|
*
|
|
@@ -7971,6 +8049,21 @@ function FormFieldMapper(formFieldProps, useFormReturn) {
|
|
|
7971
8049
|
}));
|
|
7972
8050
|
}
|
|
7973
8051
|
|
|
8052
|
+
case "checkboxlist":
|
|
8053
|
+
{
|
|
8054
|
+
return /*#__PURE__*/React__default.createElement(FormFieldCheckboxList, _extends({
|
|
8055
|
+
key: name
|
|
8056
|
+
}, decoratorProps, {
|
|
8057
|
+
fieldRequired: isRequired(options),
|
|
8058
|
+
fieldErrors: errors,
|
|
8059
|
+
type: "checkboxlist",
|
|
8060
|
+
name: name,
|
|
8061
|
+
rules: options,
|
|
8062
|
+
control: control,
|
|
8063
|
+
fieldProps: fieldProps
|
|
8064
|
+
}));
|
|
8065
|
+
}
|
|
8066
|
+
|
|
7974
8067
|
default:
|
|
7975
8068
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
7976
8069
|
}
|