@trackunit/custom-field-components 0.0.386 → 0.0.395
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/index.cjs +3472 -317
- package/index.js +3472 -317
- package/package.json +7 -7
- package/src/BooleanCustomField.d.ts +80 -80
- package/src/CustomField.d.ts +36 -36
- package/src/DateCustomField.d.ts +54 -54
- package/src/DropdownCustomField.d.ts +100 -100
- package/src/UnitPreference.d.ts +1 -1
- package/src/getValidationRules.d.ts +62 -62
- package/src/index.d.ts +2 -2
- package/src/types.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.395",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=16.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/iris-app-runtime-core": "0.3.
|
|
11
|
-
"@trackunit/iris-app-runtime-core-api": "0.3.
|
|
12
|
-
"@trackunit/react-components": "0.1.
|
|
13
|
-
"@trackunit/react-core-contexts-test": "0.1.
|
|
14
|
-
"@trackunit/react-form-components": "0.0.
|
|
15
|
-
"@trackunit/tailwind-styled-components": "0.0.
|
|
10
|
+
"@trackunit/iris-app-runtime-core": "0.3.51",
|
|
11
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.45",
|
|
12
|
+
"@trackunit/react-components": "0.1.124",
|
|
13
|
+
"@trackunit/react-core-contexts-test": "0.1.77",
|
|
14
|
+
"@trackunit/react-form-components": "0.0.76",
|
|
15
|
+
"@trackunit/tailwind-styled-components": "0.0.58",
|
|
16
16
|
"libphonenumber-js": "1.10.36",
|
|
17
17
|
"react": "18.2.0",
|
|
18
18
|
"react-hook-form": "7.40.0",
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { CheckboxProps } from "@trackunit/react-form-components";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { FieldValues, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
4
|
-
import { ValidationRules } from "./getValidationRules";
|
|
5
|
-
import { FormGroupExposedProps } from "./types";
|
|
6
|
-
export interface BooleanCustomFieldProps extends Omit<CheckboxProps, "value" | "defaultValue" | "label">, FormGroupExposedProps {
|
|
7
|
-
/**
|
|
8
|
-
* A id for the field
|
|
9
|
-
*
|
|
10
|
-
* @memberof BooleanCustomFieldProps
|
|
11
|
-
*/
|
|
12
|
-
id: string;
|
|
13
|
-
/**
|
|
14
|
-
* A value to be displayed by a input field
|
|
15
|
-
*
|
|
16
|
-
* @memberof BooleanCustomFieldProps
|
|
17
|
-
*/
|
|
18
|
-
description?: string;
|
|
19
|
-
/**
|
|
20
|
-
* A text to be displayed under the input with a short description of field purpose
|
|
21
|
-
*
|
|
22
|
-
* @memberof BooleanCustomFieldProps
|
|
23
|
-
*/
|
|
24
|
-
value?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* A default value to be displayed by a input field
|
|
27
|
-
*
|
|
28
|
-
* @memberof BooleanCustomFieldProps
|
|
29
|
-
*/
|
|
30
|
-
defaultValue?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* A id that can be used in tests to get the component
|
|
33
|
-
*
|
|
34
|
-
* @memberof BooleanCustomFieldProps
|
|
35
|
-
*/
|
|
36
|
-
dataTestId?: string;
|
|
37
|
-
/**
|
|
38
|
-
* A custom handler for onChange event
|
|
39
|
-
*
|
|
40
|
-
* @memberof BooleanCustomFieldProps
|
|
41
|
-
*/
|
|
42
|
-
onChange?: (event: React.SyntheticEvent<HTMLInputElement>) => void;
|
|
43
|
-
/**
|
|
44
|
-
* A flag that can be used to disable the input, default value is false
|
|
45
|
-
*
|
|
46
|
-
* @memberof BooleanCustomFieldProps
|
|
47
|
-
*/
|
|
48
|
-
disabled?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Used for field validation by React Hook Form library it dynamically set the value of a registered field and have the options to validate and update the form state. At the same time, it tries to avoid unnecessary rerender.
|
|
51
|
-
*
|
|
52
|
-
* @memberof BooleanCustomFieldProps
|
|
53
|
-
*/
|
|
54
|
-
setValue?: UseFormSetValue<FieldValues>;
|
|
55
|
-
/**
|
|
56
|
-
* This method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.
|
|
57
|
-
*
|
|
58
|
-
* @memberof BooleanCustomFieldProps
|
|
59
|
-
*/
|
|
60
|
-
register?: UseFormRegister<FieldValues>;
|
|
61
|
-
/**
|
|
62
|
-
* Validation rules that can be passed to the field, they can be pass along with error messages. Rules are described here https://react-hook-form.com/api/useform/register
|
|
63
|
-
*
|
|
64
|
-
* @memberof BooleanCustomFieldProps
|
|
65
|
-
*/
|
|
66
|
-
validationRules?: ValidationRules;
|
|
67
|
-
/**
|
|
68
|
-
* If a value is set, the field is rendered in its invalid state.
|
|
69
|
-
*
|
|
70
|
-
* @memberof BooleanCustomFieldProps
|
|
71
|
-
*/
|
|
72
|
-
errorMessage?: string;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* A component that can be used to render a boolean field
|
|
76
|
-
*
|
|
77
|
-
* @param options BooleanCustomFieldProps - options for the component
|
|
78
|
-
* @returns { JSX.Element } JSX.Element - a component that can be used to render a boolean field
|
|
79
|
-
*/
|
|
80
|
-
export declare const BooleanCustomField: ({ defaultValue, dataTestId, onChange, value, id, setValue, register, validationRules, disabled, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }: BooleanCustomFieldProps) => JSX.Element;
|
|
1
|
+
import { CheckboxProps } from "@trackunit/react-form-components";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { FieldValues, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
4
|
+
import { ValidationRules } from "./getValidationRules";
|
|
5
|
+
import { FormGroupExposedProps } from "./types";
|
|
6
|
+
export interface BooleanCustomFieldProps extends Omit<CheckboxProps, "value" | "defaultValue" | "label">, FormGroupExposedProps {
|
|
7
|
+
/**
|
|
8
|
+
* A id for the field
|
|
9
|
+
*
|
|
10
|
+
* @memberof BooleanCustomFieldProps
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* A value to be displayed by a input field
|
|
15
|
+
*
|
|
16
|
+
* @memberof BooleanCustomFieldProps
|
|
17
|
+
*/
|
|
18
|
+
description?: string;
|
|
19
|
+
/**
|
|
20
|
+
* A text to be displayed under the input with a short description of field purpose
|
|
21
|
+
*
|
|
22
|
+
* @memberof BooleanCustomFieldProps
|
|
23
|
+
*/
|
|
24
|
+
value?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* A default value to be displayed by a input field
|
|
27
|
+
*
|
|
28
|
+
* @memberof BooleanCustomFieldProps
|
|
29
|
+
*/
|
|
30
|
+
defaultValue?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A id that can be used in tests to get the component
|
|
33
|
+
*
|
|
34
|
+
* @memberof BooleanCustomFieldProps
|
|
35
|
+
*/
|
|
36
|
+
dataTestId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* A custom handler for onChange event
|
|
39
|
+
*
|
|
40
|
+
* @memberof BooleanCustomFieldProps
|
|
41
|
+
*/
|
|
42
|
+
onChange?: (event: React.SyntheticEvent<HTMLInputElement>) => void;
|
|
43
|
+
/**
|
|
44
|
+
* A flag that can be used to disable the input, default value is false
|
|
45
|
+
*
|
|
46
|
+
* @memberof BooleanCustomFieldProps
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Used for field validation by React Hook Form library it dynamically set the value of a registered field and have the options to validate and update the form state. At the same time, it tries to avoid unnecessary rerender.
|
|
51
|
+
*
|
|
52
|
+
* @memberof BooleanCustomFieldProps
|
|
53
|
+
*/
|
|
54
|
+
setValue?: UseFormSetValue<FieldValues>;
|
|
55
|
+
/**
|
|
56
|
+
* This method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.
|
|
57
|
+
*
|
|
58
|
+
* @memberof BooleanCustomFieldProps
|
|
59
|
+
*/
|
|
60
|
+
register?: UseFormRegister<FieldValues>;
|
|
61
|
+
/**
|
|
62
|
+
* Validation rules that can be passed to the field, they can be pass along with error messages. Rules are described here https://react-hook-form.com/api/useform/register
|
|
63
|
+
*
|
|
64
|
+
* @memberof BooleanCustomFieldProps
|
|
65
|
+
*/
|
|
66
|
+
validationRules?: ValidationRules;
|
|
67
|
+
/**
|
|
68
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
69
|
+
*
|
|
70
|
+
* @memberof BooleanCustomFieldProps
|
|
71
|
+
*/
|
|
72
|
+
errorMessage?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A component that can be used to render a boolean field
|
|
76
|
+
*
|
|
77
|
+
* @param options BooleanCustomFieldProps - options for the component
|
|
78
|
+
* @returns { JSX.Element } JSX.Element - a component that can be used to render a boolean field
|
|
79
|
+
*/
|
|
80
|
+
export declare const BooleanCustomField: ({ defaultValue, dataTestId, onChange, value, id, setValue, register, validationRules, disabled, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }: BooleanCustomFieldProps) => JSX.Element;
|
package/src/CustomField.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { AbstractValueAndDefinition } from "@trackunit/iris-app-runtime-core";
|
|
3
|
-
import { ValueAndDefinition } from "@trackunit/iris-app-runtime-core-api";
|
|
4
|
-
import { FieldValues, FormState, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
5
|
-
import { UnitPreference } from "./UnitPreference";
|
|
6
|
-
interface ICustomFieldProps {
|
|
7
|
-
field: AbstractValueAndDefinition;
|
|
8
|
-
register: UseFormRegister<FieldValues>;
|
|
9
|
-
formState: FormState<FieldValues>;
|
|
10
|
-
setValue: UseFormSetValue<FieldValues>;
|
|
11
|
-
unitPreference?: UnitPreference;
|
|
12
|
-
/**
|
|
13
|
-
* An optional Id to override the definition.key
|
|
14
|
-
*/
|
|
15
|
-
fieldId?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface ICustomFieldValidation {
|
|
18
|
-
register: UseFormRegister<FieldValues>;
|
|
19
|
-
setValue: UseFormSetValue<FieldValues>;
|
|
20
|
-
formState: FormState<FieldValues>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* A component that renders a custom field based on the field definition
|
|
24
|
-
*
|
|
25
|
-
* @param field A field definition and value
|
|
26
|
-
* @param validation A validation object that contains the register, setValue and formState
|
|
27
|
-
* @param unitPreference A unit preference that can be used to override the default unit preference
|
|
28
|
-
* @param fieldId An optional Id to override the definition.key
|
|
29
|
-
* @returns { JSX.Element } A JSX.Element or null if the field definition is undefined
|
|
30
|
-
*/
|
|
31
|
-
export declare const useCustomFieldResolver: (field: ValueAndDefinition, validation: ICustomFieldValidation, unitPreference?: UnitPreference, fieldId?: string) => JSX.Element | null;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
export declare const CustomField: ({ field, register, formState, setValue, unitPreference, fieldId }: ICustomFieldProps) => JSX.Element | null;
|
|
36
|
-
export {};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AbstractValueAndDefinition } from "@trackunit/iris-app-runtime-core";
|
|
3
|
+
import { ValueAndDefinition } from "@trackunit/iris-app-runtime-core-api";
|
|
4
|
+
import { FieldValues, FormState, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
5
|
+
import { UnitPreference } from "./UnitPreference";
|
|
6
|
+
interface ICustomFieldProps {
|
|
7
|
+
field: AbstractValueAndDefinition;
|
|
8
|
+
register: UseFormRegister<FieldValues>;
|
|
9
|
+
formState: FormState<FieldValues>;
|
|
10
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
11
|
+
unitPreference?: UnitPreference;
|
|
12
|
+
/**
|
|
13
|
+
* An optional Id to override the definition.key
|
|
14
|
+
*/
|
|
15
|
+
fieldId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ICustomFieldValidation {
|
|
18
|
+
register: UseFormRegister<FieldValues>;
|
|
19
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
20
|
+
formState: FormState<FieldValues>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A component that renders a custom field based on the field definition
|
|
24
|
+
*
|
|
25
|
+
* @param field A field definition and value
|
|
26
|
+
* @param validation A validation object that contains the register, setValue and formState
|
|
27
|
+
* @param unitPreference A unit preference that can be used to override the default unit preference
|
|
28
|
+
* @param fieldId An optional Id to override the definition.key
|
|
29
|
+
* @returns { JSX.Element } A JSX.Element or null if the field definition is undefined
|
|
30
|
+
*/
|
|
31
|
+
export declare const useCustomFieldResolver: (field: ValueAndDefinition, validation: ICustomFieldValidation, unitPreference?: UnitPreference, fieldId?: string) => JSX.Element | null;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
export declare const CustomField: ({ field, register, formState, setValue, unitPreference, fieldId }: ICustomFieldProps) => JSX.Element | null;
|
|
36
|
+
export {};
|
package/src/DateCustomField.d.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { DateFieldProps } from "@trackunit/react-form-components";
|
|
3
|
-
import { FieldValues, RegisterOptions, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
4
|
-
import { FormGroupExposedProps } from "./types";
|
|
5
|
-
export interface DateCustomFieldProps extends Omit<DateFieldProps, "label">, FormGroupExposedProps {
|
|
6
|
-
/**
|
|
7
|
-
* A id for the field
|
|
8
|
-
*
|
|
9
|
-
* @memberof DateCustomFieldProps
|
|
10
|
-
*/
|
|
11
|
-
id: string;
|
|
12
|
-
/**
|
|
13
|
-
* Used for field validation by React Hook Form library it dynamically set the value of a registered field and have the options to validate and update the form state. At the same time, it tries to avoid unnecessary rerender.
|
|
14
|
-
*
|
|
15
|
-
* @memberof DateCustomFieldProps
|
|
16
|
-
*/
|
|
17
|
-
setValue?: UseFormSetValue<FieldValues>;
|
|
18
|
-
/**
|
|
19
|
-
* This method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.
|
|
20
|
-
*
|
|
21
|
-
* @memberof DateCustomFieldProps
|
|
22
|
-
*/
|
|
23
|
-
register?: UseFormRegister<FieldValues>;
|
|
24
|
-
/**
|
|
25
|
-
* Validation rules that can be passed to the field, they can be pass along with error messages. Rules are described here https://react-hook-form.com/api/useform/register
|
|
26
|
-
*
|
|
27
|
-
* @memberof DateCustomFieldProps
|
|
28
|
-
*/
|
|
29
|
-
validationRules?: RegisterOptions;
|
|
30
|
-
/**
|
|
31
|
-
* If a value is set, the field is rendered in its invalid state.
|
|
32
|
-
*
|
|
33
|
-
* @memberof DateCustomFieldProps
|
|
34
|
-
*/
|
|
35
|
-
errorMessage?: string;
|
|
36
|
-
/**
|
|
37
|
-
* A boolean flag to set a component into invalid state
|
|
38
|
-
* which means that selected value is breaking validation rules
|
|
39
|
-
*
|
|
40
|
-
* @memberof DateCustomFieldProps
|
|
41
|
-
*/
|
|
42
|
-
isInvalid?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* The label for the Date.
|
|
45
|
-
*/
|
|
46
|
-
title?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* A component that can be used to render a date field
|
|
50
|
-
*
|
|
51
|
-
* @param props DateCustomFieldProps - options for the component
|
|
52
|
-
* @returns { JSX.Element } JSX.Element - a component that can be used to render a date field
|
|
53
|
-
*/
|
|
54
|
-
export declare const DateCustomField: (props: DateCustomFieldProps) => JSX.Element;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DateFieldProps } from "@trackunit/react-form-components";
|
|
3
|
+
import { FieldValues, RegisterOptions, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
4
|
+
import { FormGroupExposedProps } from "./types";
|
|
5
|
+
export interface DateCustomFieldProps extends Omit<DateFieldProps, "label">, FormGroupExposedProps {
|
|
6
|
+
/**
|
|
7
|
+
* A id for the field
|
|
8
|
+
*
|
|
9
|
+
* @memberof DateCustomFieldProps
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* Used for field validation by React Hook Form library it dynamically set the value of a registered field and have the options to validate and update the form state. At the same time, it tries to avoid unnecessary rerender.
|
|
14
|
+
*
|
|
15
|
+
* @memberof DateCustomFieldProps
|
|
16
|
+
*/
|
|
17
|
+
setValue?: UseFormSetValue<FieldValues>;
|
|
18
|
+
/**
|
|
19
|
+
* This method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.
|
|
20
|
+
*
|
|
21
|
+
* @memberof DateCustomFieldProps
|
|
22
|
+
*/
|
|
23
|
+
register?: UseFormRegister<FieldValues>;
|
|
24
|
+
/**
|
|
25
|
+
* Validation rules that can be passed to the field, they can be pass along with error messages. Rules are described here https://react-hook-form.com/api/useform/register
|
|
26
|
+
*
|
|
27
|
+
* @memberof DateCustomFieldProps
|
|
28
|
+
*/
|
|
29
|
+
validationRules?: RegisterOptions;
|
|
30
|
+
/**
|
|
31
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
32
|
+
*
|
|
33
|
+
* @memberof DateCustomFieldProps
|
|
34
|
+
*/
|
|
35
|
+
errorMessage?: string;
|
|
36
|
+
/**
|
|
37
|
+
* A boolean flag to set a component into invalid state
|
|
38
|
+
* which means that selected value is breaking validation rules
|
|
39
|
+
*
|
|
40
|
+
* @memberof DateCustomFieldProps
|
|
41
|
+
*/
|
|
42
|
+
isInvalid?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The label for the Date.
|
|
45
|
+
*/
|
|
46
|
+
title?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A component that can be used to render a date field
|
|
50
|
+
*
|
|
51
|
+
* @param props DateCustomFieldProps - options for the component
|
|
52
|
+
* @returns { JSX.Element } JSX.Element - a component that can be used to render a date field
|
|
53
|
+
*/
|
|
54
|
+
export declare const DateCustomField: (props: DateCustomFieldProps) => JSX.Element;
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { FieldValues, RegisterOptions, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
3
|
-
import { FormGroupExposedProps } from "./types";
|
|
4
|
-
export interface DropdownCustomFieldProps extends FormGroupExposedProps {
|
|
5
|
-
/**
|
|
6
|
-
* A id for the field
|
|
7
|
-
*
|
|
8
|
-
* @memberof DropdownCustomFieldProps
|
|
9
|
-
*/
|
|
10
|
-
id: string;
|
|
11
|
-
/**
|
|
12
|
-
* A text to be displayed under the input with a short description of field purpose
|
|
13
|
-
*
|
|
14
|
-
* @memberof DropdownCustomFieldProps
|
|
15
|
-
*/
|
|
16
|
-
description?: string;
|
|
17
|
-
/**
|
|
18
|
-
* A default value to be displayed by a input field
|
|
19
|
-
*
|
|
20
|
-
* @memberof DropdownCustomFieldProps
|
|
21
|
-
*/
|
|
22
|
-
defaultValue?: string[];
|
|
23
|
-
/**
|
|
24
|
-
* A id that can be used in tests to get the component
|
|
25
|
-
*
|
|
26
|
-
* @memberof DropdownCustomFieldProps
|
|
27
|
-
*/
|
|
28
|
-
dataTestId?: string;
|
|
29
|
-
/**
|
|
30
|
-
* A custom handler for onChange event
|
|
31
|
-
*
|
|
32
|
-
* @memberof DropdownCustomFieldProps
|
|
33
|
-
*/
|
|
34
|
-
onChange?: OnChange;
|
|
35
|
-
/**
|
|
36
|
-
* A flag that can be used to disable the dropdown, default value is false
|
|
37
|
-
*
|
|
38
|
-
* @memberof DropdownCustomFieldProps
|
|
39
|
-
*/
|
|
40
|
-
disabled?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* A flag that can be used to enable multiselect mode, default value is false
|
|
43
|
-
*
|
|
44
|
-
* @memberof DropdownCustomFieldProps
|
|
45
|
-
*/
|
|
46
|
-
multiSelect?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* An array of values to select for
|
|
49
|
-
*
|
|
50
|
-
* @memberof DropdownCustomFieldProps
|
|
51
|
-
*/
|
|
52
|
-
allValues: string[] | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Used for field validation by React Hook Form library it dynamically set the value of a registered field and have the options to validate and update the form state. At the same time, it tries to avoid unnecessary rerender.
|
|
55
|
-
*
|
|
56
|
-
* @memberof DropdownCustomFieldProps
|
|
57
|
-
*/
|
|
58
|
-
setValue?: UseFormSetValue<FieldValues>;
|
|
59
|
-
/**
|
|
60
|
-
* This method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.
|
|
61
|
-
*
|
|
62
|
-
* @memberof DropdownCustomFieldProps
|
|
63
|
-
*/
|
|
64
|
-
register?: UseFormRegister<FieldValues>;
|
|
65
|
-
/**
|
|
66
|
-
* Validation rules that can be passed to the field, they can be pass along with error messages. Rules are described here https://react-hook-form.com/api/useform/register
|
|
67
|
-
*
|
|
68
|
-
* @memberof DropdownCustomFieldProps
|
|
69
|
-
*/
|
|
70
|
-
validationRules?: RegisterOptions;
|
|
71
|
-
/**
|
|
72
|
-
* A custom handler for the onBlur event
|
|
73
|
-
*
|
|
74
|
-
* @memberof DropdownCustomFieldProps
|
|
75
|
-
*/
|
|
76
|
-
onBlur?: OnBlur;
|
|
77
|
-
/**
|
|
78
|
-
* If a value is set, the field is rendered in its invalid state.
|
|
79
|
-
*
|
|
80
|
-
* @memberof DropdownCustomFieldProps
|
|
81
|
-
*/
|
|
82
|
-
errorMessage?: string;
|
|
83
|
-
/**
|
|
84
|
-
* A boolean flag to set a component into invalid state
|
|
85
|
-
* which means that selected value is breaking validation rules
|
|
86
|
-
*
|
|
87
|
-
* @memberof DropdownCustomFieldProps
|
|
88
|
-
*/
|
|
89
|
-
isInvalid?: boolean;
|
|
90
|
-
}
|
|
91
|
-
type OnChange = (event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
92
|
-
type OnBlur = (event: React.FocusEvent<HTMLDivElement>) => void;
|
|
93
|
-
/**
|
|
94
|
-
* A custom field that can be used to render a dropdown
|
|
95
|
-
*
|
|
96
|
-
* @param options DropdownCustomFieldProps - an object with all the props
|
|
97
|
-
* @returns {JSX.Element} - a dropdown component
|
|
98
|
-
*/
|
|
99
|
-
export declare const DropdownCustomField: ({ defaultValue, dataTestId, onChange, onBlur, id, disabled, allValues, multiSelect, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }: DropdownCustomFieldProps) => JSX.Element;
|
|
100
|
-
export {};
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { FieldValues, RegisterOptions, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
3
|
+
import { FormGroupExposedProps } from "./types";
|
|
4
|
+
export interface DropdownCustomFieldProps extends FormGroupExposedProps {
|
|
5
|
+
/**
|
|
6
|
+
* A id for the field
|
|
7
|
+
*
|
|
8
|
+
* @memberof DropdownCustomFieldProps
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* A text to be displayed under the input with a short description of field purpose
|
|
13
|
+
*
|
|
14
|
+
* @memberof DropdownCustomFieldProps
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A default value to be displayed by a input field
|
|
19
|
+
*
|
|
20
|
+
* @memberof DropdownCustomFieldProps
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* A id that can be used in tests to get the component
|
|
25
|
+
*
|
|
26
|
+
* @memberof DropdownCustomFieldProps
|
|
27
|
+
*/
|
|
28
|
+
dataTestId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* A custom handler for onChange event
|
|
31
|
+
*
|
|
32
|
+
* @memberof DropdownCustomFieldProps
|
|
33
|
+
*/
|
|
34
|
+
onChange?: OnChange;
|
|
35
|
+
/**
|
|
36
|
+
* A flag that can be used to disable the dropdown, default value is false
|
|
37
|
+
*
|
|
38
|
+
* @memberof DropdownCustomFieldProps
|
|
39
|
+
*/
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* A flag that can be used to enable multiselect mode, default value is false
|
|
43
|
+
*
|
|
44
|
+
* @memberof DropdownCustomFieldProps
|
|
45
|
+
*/
|
|
46
|
+
multiSelect?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* An array of values to select for
|
|
49
|
+
*
|
|
50
|
+
* @memberof DropdownCustomFieldProps
|
|
51
|
+
*/
|
|
52
|
+
allValues: string[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Used for field validation by React Hook Form library it dynamically set the value of a registered field and have the options to validate and update the form state. At the same time, it tries to avoid unnecessary rerender.
|
|
55
|
+
*
|
|
56
|
+
* @memberof DropdownCustomFieldProps
|
|
57
|
+
*/
|
|
58
|
+
setValue?: UseFormSetValue<FieldValues>;
|
|
59
|
+
/**
|
|
60
|
+
* This method allows you to register an input or select element and apply validation rules to React Hook Form. Validation rules are all based on the HTML standard and also allow for custom validation methods.
|
|
61
|
+
*
|
|
62
|
+
* @memberof DropdownCustomFieldProps
|
|
63
|
+
*/
|
|
64
|
+
register?: UseFormRegister<FieldValues>;
|
|
65
|
+
/**
|
|
66
|
+
* Validation rules that can be passed to the field, they can be pass along with error messages. Rules are described here https://react-hook-form.com/api/useform/register
|
|
67
|
+
*
|
|
68
|
+
* @memberof DropdownCustomFieldProps
|
|
69
|
+
*/
|
|
70
|
+
validationRules?: RegisterOptions;
|
|
71
|
+
/**
|
|
72
|
+
* A custom handler for the onBlur event
|
|
73
|
+
*
|
|
74
|
+
* @memberof DropdownCustomFieldProps
|
|
75
|
+
*/
|
|
76
|
+
onBlur?: OnBlur;
|
|
77
|
+
/**
|
|
78
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
79
|
+
*
|
|
80
|
+
* @memberof DropdownCustomFieldProps
|
|
81
|
+
*/
|
|
82
|
+
errorMessage?: string;
|
|
83
|
+
/**
|
|
84
|
+
* A boolean flag to set a component into invalid state
|
|
85
|
+
* which means that selected value is breaking validation rules
|
|
86
|
+
*
|
|
87
|
+
* @memberof DropdownCustomFieldProps
|
|
88
|
+
*/
|
|
89
|
+
isInvalid?: boolean;
|
|
90
|
+
}
|
|
91
|
+
type OnChange = (event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
92
|
+
type OnBlur = (event: React.FocusEvent<HTMLDivElement>) => void;
|
|
93
|
+
/**
|
|
94
|
+
* A custom field that can be used to render a dropdown
|
|
95
|
+
*
|
|
96
|
+
* @param options DropdownCustomFieldProps - an object with all the props
|
|
97
|
+
* @returns {JSX.Element} - a dropdown component
|
|
98
|
+
*/
|
|
99
|
+
export declare const DropdownCustomField: ({ defaultValue, dataTestId, onChange, onBlur, id, disabled, allValues, multiSelect, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }: DropdownCustomFieldProps) => JSX.Element;
|
|
100
|
+
export {};
|
package/src/UnitPreference.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type UnitPreference = "SI" | "US_CUSTOMARY";
|
|
1
|
+
export type UnitPreference = "SI" | "US_CUSTOMARY";
|