@trackunit/custom-field-components 0.0.972 → 0.0.974
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 +2 -3
- package/index.esm.js +3 -4
- package/package.json +1 -2
package/index.cjs.js
CHANGED
|
@@ -7,7 +7,6 @@ var reactFormComponents = require('@trackunit/react-form-components');
|
|
|
7
7
|
var sharedUtils = require('@trackunit/shared-utils');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var reactHookForm = require('react-hook-form');
|
|
10
|
-
var uuid = require('uuid');
|
|
11
10
|
|
|
12
11
|
function _interopNamespaceDefault(e) {
|
|
13
12
|
var n = Object.create(null);
|
|
@@ -145,7 +144,7 @@ const setupLibraryTranslations = () => {
|
|
|
145
144
|
const BooleanCustomField = ({ defaultValue, dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
146
145
|
const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
|
|
147
146
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
148
|
-
const htmlForId = id ? id : "boolean-custom-field-" +
|
|
147
|
+
const htmlForId = id ? id : "boolean-custom-field-" + sharedUtils.uuidv4();
|
|
149
148
|
const [internalValue, setInternalValue] = React__namespace.useState(initialValue);
|
|
150
149
|
React__namespace.useEffect(() => {
|
|
151
150
|
setInternalValue((value === undefined ? defaultValue : value) || false);
|
|
@@ -199,7 +198,7 @@ const convertToValueFormat = (value) => {
|
|
|
199
198
|
*/
|
|
200
199
|
const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
|
|
201
200
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
202
|
-
const htmlForId = id ? id : "dropdown-custom-field-" +
|
|
201
|
+
const htmlForId = id ? id : "dropdown-custom-field-" + sharedUtils.uuidv4();
|
|
203
202
|
const [selectedValue, setSelectedValue] = React__namespace.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
|
|
204
203
|
const onChangeHandler = React__namespace.useCallback((selected) => {
|
|
205
204
|
var _a, _b;
|
package/index.esm.js
CHANGED
|
@@ -2,11 +2,10 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { getCustomFieldValueForDisplayInUI } from '@trackunit/iris-app-runtime-core';
|
|
4
4
|
import { FormGroup, Checkbox, DateField, Select, useGetPhoneValidationRules, NumberField, TextField, PhoneField, ActionButton } from '@trackunit/react-form-components';
|
|
5
|
-
import { exhaustiveCheck } from '@trackunit/shared-utils';
|
|
5
|
+
import { uuidv4, exhaustiveCheck } from '@trackunit/shared-utils';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { useCallback, useEffect, createElement, useState } from 'react';
|
|
8
8
|
import { useWatch } from 'react-hook-form';
|
|
9
|
-
import { v4 } from 'uuid';
|
|
10
9
|
|
|
11
10
|
var defaultTranslations = {
|
|
12
11
|
"customfield.unit.ACRE": "acre",
|
|
@@ -125,7 +124,7 @@ const setupLibraryTranslations = () => {
|
|
|
125
124
|
const BooleanCustomField = ({ defaultValue, dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
126
125
|
const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
|
|
127
126
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
128
|
-
const htmlForId = id ? id : "boolean-custom-field-" +
|
|
127
|
+
const htmlForId = id ? id : "boolean-custom-field-" + uuidv4();
|
|
129
128
|
const [internalValue, setInternalValue] = React.useState(initialValue);
|
|
130
129
|
React.useEffect(() => {
|
|
131
130
|
setInternalValue((value === undefined ? defaultValue : value) || false);
|
|
@@ -179,7 +178,7 @@ const convertToValueFormat = (value) => {
|
|
|
179
178
|
*/
|
|
180
179
|
const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, disabled = false, allValues, multiSelect = false, register, validationRules, setValue, label, tip, errorMessage, helpText, isInvalid, helpAddon, }) => {
|
|
181
180
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
182
|
-
const htmlForId = id ? id : "dropdown-custom-field-" +
|
|
181
|
+
const htmlForId = id ? id : "dropdown-custom-field-" + uuidv4();
|
|
183
182
|
const [selectedValue, setSelectedValue] = React.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
|
|
184
183
|
const onChangeHandler = React.useCallback((selected) => {
|
|
185
184
|
var _a, _b;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.974",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"react-hook-form": "7.40.0",
|
|
13
13
|
"@trackunit/custom-field-api": "*",
|
|
14
14
|
"@trackunit/shared-utils": "*",
|
|
15
|
-
"uuid": "^9.0.1",
|
|
16
15
|
"@trackunit/iris-app-runtime-core": "*",
|
|
17
16
|
"@trackunit/iris-app-runtime-core-api": "*",
|
|
18
17
|
"react-select": "^5.8.0",
|