@trackunit/custom-field-components 1.3.28 → 1.3.34
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.js +5 -5
- package/index.esm.js +5 -5
- package/package.json +13 -13
- package/src/BooleanCustomField.d.ts +3 -3
- package/src/CustomField.d.ts +5 -4
- package/src/DateCustomField.d.ts +3 -2
- package/src/DropdownCustomField.d.ts +3 -3
package/index.cjs.js
CHANGED
|
@@ -132,7 +132,7 @@ const setupLibraryTranslations = () => {
|
|
|
132
132
|
* A component that can be used to render a boolean field
|
|
133
133
|
*
|
|
134
134
|
* @param options BooleanCustomFieldProps - options for the component
|
|
135
|
-
* @returns {
|
|
135
|
+
* @returns {ReactElement }ReactElement - a component that can be used to render a boolean field
|
|
136
136
|
*/
|
|
137
137
|
const BooleanCustomField = ({ defaultValue, dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
138
138
|
const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
|
|
@@ -161,7 +161,7 @@ const BooleanCustomField = ({ defaultValue, dataTestId = "booleanField", onChang
|
|
|
161
161
|
* A component that can be used to render a date field
|
|
162
162
|
*
|
|
163
163
|
* @param props DateCustomFieldProps - options for the component
|
|
164
|
-
* @returns {
|
|
164
|
+
* @returns {ReactElement }ReactElement - a component that can be used to render a date field
|
|
165
165
|
*/
|
|
166
166
|
const DateCustomField = (props) => {
|
|
167
167
|
const { setValue, defaultValue, register, id, validationRules, ...rest } = props;
|
|
@@ -186,7 +186,7 @@ const convertToValueFormat = (value) => {
|
|
|
186
186
|
* A custom field that can be used to render a dropdown
|
|
187
187
|
*
|
|
188
188
|
* @param options DropdownCustomFieldProps - an object with all the props
|
|
189
|
-
* @returns {
|
|
189
|
+
* @returns {ReactElement} - a dropdown component
|
|
190
190
|
*/
|
|
191
191
|
const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
|
|
192
192
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
@@ -498,7 +498,7 @@ const useUnitTranslation = () => {
|
|
|
498
498
|
*
|
|
499
499
|
* @param {CustomFieldProps} props - The properties of the custom field, including its definition, value,
|
|
500
500
|
* and functions for form registration and state management.
|
|
501
|
-
* @returns {
|
|
501
|
+
* @returns {ReactElement | null} - The JSX Element for the custom field or null if the field definition is not provided.
|
|
502
502
|
*/
|
|
503
503
|
const useCustomFieldResolver = ({ field, definition, register, setValue, formState, formValue, unitPreference = "SI", language, fieldId, isEditable = true, control, }) => {
|
|
504
504
|
const validation = { register, setValue, formState };
|
|
@@ -657,7 +657,7 @@ const useValue = (uniqueIdentifier, numberValue, control, def, field) => {
|
|
|
657
657
|
*
|
|
658
658
|
* @param {CustomFieldProps} props - Props for defining the custom field, including its type, value,
|
|
659
659
|
* validation rules, and form registration functions from react-hook-form.
|
|
660
|
-
* @returns {
|
|
660
|
+
* @returns {ReactElement | null} - The resolved custom field component or null if the field cannot be resolved.
|
|
661
661
|
*/
|
|
662
662
|
const CustomField = (props) => {
|
|
663
663
|
return useCustomFieldResolver(props);
|
package/index.esm.js
CHANGED
|
@@ -130,7 +130,7 @@ const setupLibraryTranslations = () => {
|
|
|
130
130
|
* A component that can be used to render a boolean field
|
|
131
131
|
*
|
|
132
132
|
* @param options BooleanCustomFieldProps - options for the component
|
|
133
|
-
* @returns {
|
|
133
|
+
* @returns {ReactElement }ReactElement - a component that can be used to render a boolean field
|
|
134
134
|
*/
|
|
135
135
|
const BooleanCustomField = ({ defaultValue, dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
136
136
|
const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
|
|
@@ -159,7 +159,7 @@ const BooleanCustomField = ({ defaultValue, dataTestId = "booleanField", onChang
|
|
|
159
159
|
* A component that can be used to render a date field
|
|
160
160
|
*
|
|
161
161
|
* @param props DateCustomFieldProps - options for the component
|
|
162
|
-
* @returns {
|
|
162
|
+
* @returns {ReactElement }ReactElement - a component that can be used to render a date field
|
|
163
163
|
*/
|
|
164
164
|
const DateCustomField = (props) => {
|
|
165
165
|
const { setValue, defaultValue, register, id, validationRules, ...rest } = props;
|
|
@@ -184,7 +184,7 @@ const convertToValueFormat = (value) => {
|
|
|
184
184
|
* A custom field that can be used to render a dropdown
|
|
185
185
|
*
|
|
186
186
|
* @param options DropdownCustomFieldProps - an object with all the props
|
|
187
|
-
* @returns {
|
|
187
|
+
* @returns {ReactElement} - a dropdown component
|
|
188
188
|
*/
|
|
189
189
|
const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
|
|
190
190
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
@@ -496,7 +496,7 @@ const useUnitTranslation = () => {
|
|
|
496
496
|
*
|
|
497
497
|
* @param {CustomFieldProps} props - The properties of the custom field, including its definition, value,
|
|
498
498
|
* and functions for form registration and state management.
|
|
499
|
-
* @returns {
|
|
499
|
+
* @returns {ReactElement | null} - The JSX Element for the custom field or null if the field definition is not provided.
|
|
500
500
|
*/
|
|
501
501
|
const useCustomFieldResolver = ({ field, definition, register, setValue, formState, formValue, unitPreference = "SI", language, fieldId, isEditable = true, control, }) => {
|
|
502
502
|
const validation = { register, setValue, formState };
|
|
@@ -655,7 +655,7 @@ const useValue = (uniqueIdentifier, numberValue, control, def, field) => {
|
|
|
655
655
|
*
|
|
656
656
|
* @param {CustomFieldProps} props - Props for defining the custom field, including its type, value,
|
|
657
657
|
* validation rules, and form registration functions from react-hook-form.
|
|
658
|
-
* @returns {
|
|
658
|
+
* @returns {ReactElement | null} - The resolved custom field component or null if the field cannot be resolved.
|
|
659
659
|
*/
|
|
660
660
|
const CustomField = (props) => {
|
|
661
661
|
return useCustomFieldResolver(props);
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.34",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"react": "
|
|
10
|
+
"react": "19.0.0",
|
|
11
11
|
"react-hook-form": "7.53.1",
|
|
12
|
-
"react-select": "^5.
|
|
13
|
-
"@testing-library/react": "
|
|
12
|
+
"react-select": "^5.10.0",
|
|
13
|
+
"@testing-library/react": "16.2.0",
|
|
14
14
|
"jest-fetch-mock": "^3.0.3",
|
|
15
|
-
"@trackunit/react-form-components": "1.3.
|
|
16
|
-
"@trackunit/shared-utils": "1.5.
|
|
17
|
-
"@trackunit/custom-field-api": "1.3.
|
|
18
|
-
"@trackunit/iris-app-runtime-core": "1.4.
|
|
19
|
-
"@trackunit/react-components": "1.4.
|
|
20
|
-
"@trackunit/react-modal": "1.3.
|
|
21
|
-
"@trackunit/react-core-hooks": "1.3.
|
|
22
|
-
"@trackunit/i18n-library-translation": "1.3.
|
|
23
|
-
"@trackunit/iris-app-runtime-core-api": "1.3.
|
|
15
|
+
"@trackunit/react-form-components": "1.3.32",
|
|
16
|
+
"@trackunit/shared-utils": "1.5.27",
|
|
17
|
+
"@trackunit/custom-field-api": "1.3.28",
|
|
18
|
+
"@trackunit/iris-app-runtime-core": "1.4.28",
|
|
19
|
+
"@trackunit/react-components": "1.4.27",
|
|
20
|
+
"@trackunit/react-modal": "1.3.30",
|
|
21
|
+
"@trackunit/react-core-hooks": "1.3.28",
|
|
22
|
+
"@trackunit/i18n-library-translation": "1.3.28",
|
|
23
|
+
"@trackunit/iris-app-runtime-core-api": "1.3.28"
|
|
24
24
|
},
|
|
25
25
|
"module": "./index.esm.js",
|
|
26
26
|
"main": "./index.cjs.js",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckboxProps } from "@trackunit/react-form-components";
|
|
2
|
-
import { SyntheticEvent } from "react";
|
|
2
|
+
import { ReactElement, SyntheticEvent } from "react";
|
|
3
3
|
import { FieldValues, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
4
4
|
import { ValidationRules } from "./getValidationRules";
|
|
5
5
|
import { FormGroupExposedProps } from "./types";
|
|
@@ -75,6 +75,6 @@ export interface BooleanCustomFieldProps extends Omit<CheckboxProps, "value" | "
|
|
|
75
75
|
* A component that can be used to render a boolean field
|
|
76
76
|
*
|
|
77
77
|
* @param options BooleanCustomFieldProps - options for the component
|
|
78
|
-
* @returns {
|
|
78
|
+
* @returns {ReactElement }ReactElement - a component that can be used to render a boolean field
|
|
79
79
|
*/
|
|
80
|
-
export declare const BooleanCustomField: ({ defaultValue, dataTestId, onChange, value, id, setValue, register, validationRules, disabled, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }: BooleanCustomFieldProps) =>
|
|
80
|
+
export declare const BooleanCustomField: ({ defaultValue, dataTestId, onChange, value, id, setValue, register, validationRules, disabled, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }: BooleanCustomFieldProps) => ReactElement;
|
package/src/CustomField.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CustomFieldDefinition, CustomFieldValueAndDefinition } from "@trackunit/custom-field-api";
|
|
2
|
+
import { ReactElement } from "react";
|
|
2
3
|
import { Control, FieldValues, FormState, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
3
4
|
import { UnitPreference } from "./UnitPreference";
|
|
4
5
|
/**
|
|
@@ -58,9 +59,9 @@ interface CustomFieldProps {
|
|
|
58
59
|
*
|
|
59
60
|
* @param {CustomFieldProps} props - The properties of the custom field, including its definition, value,
|
|
60
61
|
* and functions for form registration and state management.
|
|
61
|
-
* @returns {
|
|
62
|
+
* @returns {ReactElement | null} - The JSX Element for the custom field or null if the field definition is not provided.
|
|
62
63
|
*/
|
|
63
|
-
export declare const useCustomFieldResolver: ({ field, definition, register, setValue, formState, formValue, unitPreference, language, fieldId, isEditable, control, }: CustomFieldProps) =>
|
|
64
|
+
export declare const useCustomFieldResolver: ({ field, definition, register, setValue, formState, formValue, unitPreference, language, fieldId, isEditable, control, }: CustomFieldProps) => ReactElement | null;
|
|
64
65
|
/**
|
|
65
66
|
* CustomField is a React component that takes in the properties of a custom field and renders it.
|
|
66
67
|
* It utilizes the `useCustomFieldResolver` hook to resolve the field into an input element
|
|
@@ -68,7 +69,7 @@ export declare const useCustomFieldResolver: ({ field, definition, register, set
|
|
|
68
69
|
*
|
|
69
70
|
* @param {CustomFieldProps} props - Props for defining the custom field, including its type, value,
|
|
70
71
|
* validation rules, and form registration functions from react-hook-form.
|
|
71
|
-
* @returns {
|
|
72
|
+
* @returns {ReactElement | null} - The resolved custom field component or null if the field cannot be resolved.
|
|
72
73
|
*/
|
|
73
|
-
export declare const CustomField: (props: CustomFieldProps) =>
|
|
74
|
+
export declare const CustomField: (props: CustomFieldProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
74
75
|
export {};
|
package/src/DateCustomField.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateFieldProps } from "@trackunit/react-form-components";
|
|
2
|
+
import { ReactElement } from "react";
|
|
2
3
|
import { FieldValues, RegisterOptions, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
3
4
|
import { FormGroupExposedProps } from "./types";
|
|
4
5
|
export interface DateCustomFieldProps extends Omit<DateFieldProps, "label">, FormGroupExposedProps {
|
|
@@ -48,6 +49,6 @@ export interface DateCustomFieldProps extends Omit<DateFieldProps, "label">, For
|
|
|
48
49
|
* A component that can be used to render a date field
|
|
49
50
|
*
|
|
50
51
|
* @param props DateCustomFieldProps - options for the component
|
|
51
|
-
* @returns {
|
|
52
|
+
* @returns {ReactElement }ReactElement - a component that can be used to render a date field
|
|
52
53
|
*/
|
|
53
|
-
export declare const DateCustomField: (props: DateCustomFieldProps) =>
|
|
54
|
+
export declare const DateCustomField: (props: DateCustomFieldProps) => ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from "react";
|
|
1
|
+
import { ChangeEvent, FocusEvent, ReactElement } from "react";
|
|
2
2
|
import { FieldValues, RegisterOptions, UseFormRegister, UseFormSetValue } from "react-hook-form";
|
|
3
3
|
import { FormGroupExposedProps } from "./types";
|
|
4
4
|
export interface DropdownCustomFieldProps extends FormGroupExposedProps {
|
|
@@ -88,7 +88,7 @@ type OnBlur = (event: FocusEvent<HTMLDivElement>) => void;
|
|
|
88
88
|
* A custom field that can be used to render a dropdown
|
|
89
89
|
*
|
|
90
90
|
* @param options DropdownCustomFieldProps - an object with all the props
|
|
91
|
-
* @returns {
|
|
91
|
+
* @returns {ReactElement} - a dropdown component
|
|
92
92
|
*/
|
|
93
|
-
export declare const DropdownCustomField: ({ defaultValue, dataTestId, onChange, onBlur, id, disabled, allValues, multiSelect, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }: DropdownCustomFieldProps) =>
|
|
93
|
+
export declare const DropdownCustomField: ({ defaultValue, dataTestId, onChange, onBlur, id, disabled, allValues, multiSelect, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }: DropdownCustomFieldProps) => ReactElement;
|
|
94
94
|
export {};
|