@trackunit/react-form-components 0.1.59 → 0.1.60
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 +15 -16
- package/index.esm.js +15 -16
- package/package.json +1 -2
package/index.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var reactComponents = require('@trackunit/react-components');
|
|
|
6
6
|
var usehooksTs = require('usehooks-ts');
|
|
7
7
|
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
8
8
|
var React = require('react');
|
|
9
|
-
var
|
|
9
|
+
var sharedUtils = require('@trackunit/shared-utils');
|
|
10
10
|
var dateFns = require('date-fns');
|
|
11
11
|
var parsePhoneNumberFromString = require('libphonenumber-js');
|
|
12
12
|
var reactHookForm = require('react-hook-form');
|
|
@@ -14,7 +14,6 @@ var ReactSelect = require('react-select');
|
|
|
14
14
|
var ReactAsyncCreatableSelect = require('react-select/async-creatable');
|
|
15
15
|
var ReactCreatableSelect = require('react-select/creatable');
|
|
16
16
|
var ReactAsyncSelect = require('react-select/async');
|
|
17
|
-
var sharedUtils = require('@trackunit/shared-utils');
|
|
18
17
|
var tailwindMerge = require('tailwind-merge');
|
|
19
18
|
var zod = require('zod');
|
|
20
19
|
|
|
@@ -635,7 +634,7 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
|
|
|
635
634
|
* _**Do use**_ the CheckboxField for boolean input.
|
|
636
635
|
*/
|
|
637
636
|
const CheckboxField = React.forwardRef(({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange, ...rest }, ref) => {
|
|
638
|
-
const htmlForId = id ? id : "checkboxField-" +
|
|
637
|
+
const htmlForId = id ? id : "checkboxField-" + sharedUtils.uuidv4();
|
|
639
638
|
return (jsxRuntime.jsx(FormGroup, { className: "flex flex-col gap-1", dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(Checkbox, { checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref, ...rest }) }));
|
|
640
639
|
});
|
|
641
640
|
CheckboxField.displayName = "CheckboxField";
|
|
@@ -689,7 +688,7 @@ const isValidHEXColor = (value) => {
|
|
|
689
688
|
*
|
|
690
689
|
*/
|
|
691
690
|
const ColorField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false, onBlur, ...rest }, ref) => {
|
|
692
|
-
const htmlForId = React.useMemo(() => (id ? id : "colorField-" +
|
|
691
|
+
const htmlForId = React.useMemo(() => (id ? id : "colorField-" + sharedUtils.uuidv4()), [id]);
|
|
693
692
|
const innerRef = React.useRef(null);
|
|
694
693
|
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
695
694
|
const [t] = useTranslation();
|
|
@@ -745,7 +744,7 @@ DateInput.displayName = "DateInput";
|
|
|
745
744
|
*/
|
|
746
745
|
const DateField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId, ...rest }, ref) => {
|
|
747
746
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
748
|
-
const htmlForId = id ? id : "dateField-" +
|
|
747
|
+
const htmlForId = id ? id : "dateField-" + sharedUtils.uuidv4();
|
|
749
748
|
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(DateInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
750
749
|
});
|
|
751
750
|
DateField.displayName = "DateField";
|
|
@@ -923,7 +922,7 @@ EmailInput.displayName = "EmailInput";
|
|
|
923
922
|
*
|
|
924
923
|
*/
|
|
925
924
|
const EmailField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, disabled, onChange, onBlur, isInvalid = false, ...rest }, ref) => {
|
|
926
|
-
const htmlForId = id ? id : "emailField-" +
|
|
925
|
+
const htmlForId = id ? id : "emailField-" + sharedUtils.uuidv4();
|
|
927
926
|
const [t] = useTranslation();
|
|
928
927
|
const [innerValue, setInnerValue] = React.useState(() => {
|
|
929
928
|
var _a;
|
|
@@ -1016,7 +1015,7 @@ NumberInput.displayName = "NumberInput";
|
|
|
1016
1015
|
* _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
|
|
1017
1016
|
*/
|
|
1018
1017
|
const NumberField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId, defaultValue, onBlur, onChange, ...rest }, ref) => {
|
|
1019
|
-
const htmlForId = id ? id : "numberField-" +
|
|
1018
|
+
const htmlForId = id ? id : "numberField-" + sharedUtils.uuidv4();
|
|
1020
1019
|
const [t] = useTranslation();
|
|
1021
1020
|
const [innerValue, setInnerValue] = React.useState(() => {
|
|
1022
1021
|
return Number(value === null || value === void 0 ? void 0 : value.toString()) || Number(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString());
|
|
@@ -1087,7 +1086,7 @@ const cvaOptionCardContainer = cssClassVarianceUtilities.cvaMerge(["contents"]);
|
|
|
1087
1086
|
* A card version of a radio button that includes an icon, headings and a description.
|
|
1088
1087
|
*/
|
|
1089
1088
|
const OptionCard = React.forwardRef(({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, dataTestId, customImage, ...rest }, ref) => {
|
|
1090
|
-
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" +
|
|
1089
|
+
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" + sharedUtils.uuidv4();
|
|
1091
1090
|
return (jsxRuntime.jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsxRuntime.jsx("input", { className: "peer absolute h-0 w-0 opacity-0", "data-testid": `${dataTestId}-option-card`, id: htmlForId, ref: ref, type: "radio", value: value, ...rest }), jsxRuntime.jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), "data-testid": `${dataTestId}-option-card-label`, htmlFor: htmlForId, children: [disabled && icon && !customImage
|
|
1092
1091
|
? React.cloneElement(icon, { className: `${icon.props.className} text-secondary-400` })
|
|
1093
1092
|
: null, disabled && customImage ? jsxRuntime.jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, !disabled && !customImage && icon, !disabled && customImage ? jsxRuntime.jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, heading ? (jsxRuntime.jsx(reactComponents.Heading, { subtle: disabled, variant: "secondary", children: heading })) : null, subheading || description ? (jsxRuntime.jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: disabled, type: "span", weight: "thick", children: subheading })) : null, description ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: true, type: "span", children: description })) : null] })) : null] })] }));
|
|
@@ -1114,7 +1113,7 @@ PasswordInput.displayName = "PasswordInput";
|
|
|
1114
1113
|
*/
|
|
1115
1114
|
const PasswordField = React.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
1116
1115
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1117
|
-
const htmlFor = id ? id : "passwordField-" +
|
|
1116
|
+
const htmlFor = id ? id : "passwordField-" + sharedUtils.uuidv4();
|
|
1118
1117
|
const handleChange = React.useCallback((event) => {
|
|
1119
1118
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1120
1119
|
}, [onChange]);
|
|
@@ -1301,7 +1300,7 @@ const phoneErrorMessage = (phoneNumber, required) => {
|
|
|
1301
1300
|
* @returns {JSX.Element} - The PhoneField component.
|
|
1302
1301
|
*/
|
|
1303
1302
|
const PhoneField = React.forwardRef(({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId, name, onBlur, ...rest }, ref) => {
|
|
1304
|
-
const htmlForId = id ? id : "phoneField-" +
|
|
1303
|
+
const htmlForId = id ? id : "phoneField-" + sharedUtils.uuidv4();
|
|
1305
1304
|
const [t] = useTranslation();
|
|
1306
1305
|
const [innerValue, setInnerValue] = React.useState(() => {
|
|
1307
1306
|
var _a;
|
|
@@ -2392,7 +2391,7 @@ const FormFieldSelectAdapter = React.forwardRef(({ className, dataTestId, helpTe
|
|
|
2392
2391
|
setInnerValue(defaultValue);
|
|
2393
2392
|
}, [defaultValue]);
|
|
2394
2393
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2395
|
-
const htmlFor = React.useMemo(() => (id ? id : "selectField-" +
|
|
2394
|
+
const htmlFor = React.useMemo(() => (id ? id : "selectField-" + sharedUtils.uuidv4()), [id]);
|
|
2396
2395
|
const innerRef = React.useRef(null);
|
|
2397
2396
|
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
2398
2397
|
React.useEffect(() => {
|
|
@@ -2529,7 +2528,7 @@ const TextLengthIndicator = ({ length, maxLength }) => {
|
|
|
2529
2528
|
const TextAreaField = React__namespace.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
2530
2529
|
const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
|
|
2531
2530
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2532
|
-
const htmlForId = id ? id : "textAreaField-" +
|
|
2531
|
+
const htmlForId = id ? id : "textAreaField-" + sharedUtils.uuidv4();
|
|
2533
2532
|
const handleChange = React__namespace.useCallback((event) => {
|
|
2534
2533
|
setValueLength(event.target.value.length);
|
|
2535
2534
|
if (onChange) {
|
|
@@ -2551,7 +2550,7 @@ TextAreaField.displayName = "TextAreaField";
|
|
|
2551
2550
|
const TextField = React__namespace.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
2552
2551
|
const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
|
|
2553
2552
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2554
|
-
const htmlFor = id ? id : "textField-" +
|
|
2553
|
+
const htmlFor = id ? id : "textField-" + sharedUtils.uuidv4();
|
|
2555
2554
|
const handleChange = React__namespace.useCallback((event) => {
|
|
2556
2555
|
setValueLength(event.target.value.length);
|
|
2557
2556
|
if (onChange) {
|
|
@@ -2571,7 +2570,7 @@ TextField.displayName = "TextField";
|
|
|
2571
2570
|
*/
|
|
2572
2571
|
const TimeRangeField = ({ className, dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ...rest }) => {
|
|
2573
2572
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2574
|
-
const htmlFor = id ? id : "timeRangeField-" +
|
|
2573
|
+
const htmlFor = id ? id : "timeRangeField-" + sharedUtils.uuidv4();
|
|
2575
2574
|
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TimeRange, { className: className, dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
2576
2575
|
};
|
|
2577
2576
|
|
|
@@ -2676,7 +2675,7 @@ UploadInput.displayName = "UploadInput";
|
|
|
2676
2675
|
*/
|
|
2677
2676
|
const UploadField = React.forwardRef(({ label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId, ...rest }, ref) => {
|
|
2678
2677
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2679
|
-
const htmlForId = id ? id : "uploadField-" +
|
|
2678
|
+
const htmlForId = id ? id : "uploadField-" + sharedUtils.uuidv4();
|
|
2680
2679
|
return (jsxRuntime.jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2681
2680
|
});
|
|
2682
2681
|
UploadField.displayName = "UploadField";
|
|
@@ -2730,7 +2729,7 @@ UrlInput.displayName = "UrlField";
|
|
|
2730
2729
|
*
|
|
2731
2730
|
*/
|
|
2732
2731
|
const UrlField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, isInvalid = false, value, onBlur, ...rest }, ref) => {
|
|
2733
|
-
const htmlForId = id ? id : "urlField-" +
|
|
2732
|
+
const htmlForId = id ? id : "urlField-" + sharedUtils.uuidv4();
|
|
2734
2733
|
const [t] = useTranslation();
|
|
2735
2734
|
const [innerValue, setInnerValue] = React.useState(() => {
|
|
2736
2735
|
var _a;
|
package/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useCopyToClipboard } from 'usehooks-ts';
|
|
|
5
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import React__default, { isValidElement, forwardRef, useMemo, useState, useCallback, useRef, cloneElement, useEffect, useImperativeHandle } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { uuidv4, nonNullable } from '@trackunit/shared-utils';
|
|
9
9
|
import { format } from 'date-fns';
|
|
10
10
|
import parsePhoneNumberFromString, { isSupportedCountry, getCountries, getCountryCallingCode, AsYouType, parseIncompletePhoneNumber, isValidPhoneNumber } from 'libphonenumber-js';
|
|
11
11
|
import { Controller } from 'react-hook-form';
|
|
@@ -14,7 +14,6 @@ export { default as ValueType } from 'react-select';
|
|
|
14
14
|
import ReactAsyncCreatableSelect from 'react-select/async-creatable';
|
|
15
15
|
import ReactCreatableSelect from 'react-select/creatable';
|
|
16
16
|
import ReactAsyncSelect from 'react-select/async';
|
|
17
|
-
import { nonNullable } from '@trackunit/shared-utils';
|
|
18
17
|
import { twMerge } from 'tailwind-merge';
|
|
19
18
|
import { z } from 'zod';
|
|
20
19
|
|
|
@@ -616,7 +615,7 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
|
|
|
616
615
|
* _**Do use**_ the CheckboxField for boolean input.
|
|
617
616
|
*/
|
|
618
617
|
const CheckboxField = forwardRef(({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange, ...rest }, ref) => {
|
|
619
|
-
const htmlForId = id ? id : "checkboxField-" +
|
|
618
|
+
const htmlForId = id ? id : "checkboxField-" + uuidv4();
|
|
620
619
|
return (jsx(FormGroup, { className: "flex flex-col gap-1", dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: rest.required, tip: tip, children: jsx(Checkbox, { checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref, ...rest }) }));
|
|
621
620
|
});
|
|
622
621
|
CheckboxField.displayName = "CheckboxField";
|
|
@@ -670,7 +669,7 @@ const isValidHEXColor = (value) => {
|
|
|
670
669
|
*
|
|
671
670
|
*/
|
|
672
671
|
const ColorField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false, onBlur, ...rest }, ref) => {
|
|
673
|
-
const htmlForId = useMemo(() => (id ? id : "colorField-" +
|
|
672
|
+
const htmlForId = useMemo(() => (id ? id : "colorField-" + uuidv4()), [id]);
|
|
674
673
|
const innerRef = React__default.useRef(null);
|
|
675
674
|
React__default.useImperativeHandle(ref, () => innerRef.current, []);
|
|
676
675
|
const [t] = useTranslation();
|
|
@@ -726,7 +725,7 @@ DateInput.displayName = "DateInput";
|
|
|
726
725
|
*/
|
|
727
726
|
const DateField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId, ...rest }, ref) => {
|
|
728
727
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
729
|
-
const htmlForId = id ? id : "dateField-" +
|
|
728
|
+
const htmlForId = id ? id : "dateField-" + uuidv4();
|
|
730
729
|
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(DateInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
731
730
|
});
|
|
732
731
|
DateField.displayName = "DateField";
|
|
@@ -904,7 +903,7 @@ EmailInput.displayName = "EmailInput";
|
|
|
904
903
|
*
|
|
905
904
|
*/
|
|
906
905
|
const EmailField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, disabled, onChange, onBlur, isInvalid = false, ...rest }, ref) => {
|
|
907
|
-
const htmlForId = id ? id : "emailField-" +
|
|
906
|
+
const htmlForId = id ? id : "emailField-" + uuidv4();
|
|
908
907
|
const [t] = useTranslation();
|
|
909
908
|
const [innerValue, setInnerValue] = useState(() => {
|
|
910
909
|
var _a;
|
|
@@ -997,7 +996,7 @@ NumberInput.displayName = "NumberInput";
|
|
|
997
996
|
* _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
|
|
998
997
|
*/
|
|
999
998
|
const NumberField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId, defaultValue, onBlur, onChange, ...rest }, ref) => {
|
|
1000
|
-
const htmlForId = id ? id : "numberField-" +
|
|
999
|
+
const htmlForId = id ? id : "numberField-" + uuidv4();
|
|
1001
1000
|
const [t] = useTranslation();
|
|
1002
1001
|
const [innerValue, setInnerValue] = useState(() => {
|
|
1003
1002
|
return Number(value === null || value === void 0 ? void 0 : value.toString()) || Number(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString());
|
|
@@ -1068,7 +1067,7 @@ const cvaOptionCardContainer = cvaMerge(["contents"]);
|
|
|
1068
1067
|
* A card version of a radio button that includes an icon, headings and a description.
|
|
1069
1068
|
*/
|
|
1070
1069
|
const OptionCard = forwardRef(({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, dataTestId, customImage, ...rest }, ref) => {
|
|
1071
|
-
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" +
|
|
1070
|
+
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" + uuidv4();
|
|
1072
1071
|
return (jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsx("input", { className: "peer absolute h-0 w-0 opacity-0", "data-testid": `${dataTestId}-option-card`, id: htmlForId, ref: ref, type: "radio", value: value, ...rest }), jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), "data-testid": `${dataTestId}-option-card-label`, htmlFor: htmlForId, children: [disabled && icon && !customImage
|
|
1073
1072
|
? cloneElement(icon, { className: `${icon.props.className} text-secondary-400` })
|
|
1074
1073
|
: null, disabled && customImage ? jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, !disabled && !customImage && icon, !disabled && customImage ? jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, heading ? (jsx(Heading, { subtle: disabled, variant: "secondary", children: heading })) : null, subheading || description ? (jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading ? (jsx(Text, { align: "center", subtle: disabled, type: "span", weight: "thick", children: subheading })) : null, description ? (jsx(Text, { align: "center", subtle: true, type: "span", children: description })) : null] })) : null] })] }));
|
|
@@ -1095,7 +1094,7 @@ PasswordInput.displayName = "PasswordInput";
|
|
|
1095
1094
|
*/
|
|
1096
1095
|
const PasswordField = forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
1097
1096
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1098
|
-
const htmlFor = id ? id : "passwordField-" +
|
|
1097
|
+
const htmlFor = id ? id : "passwordField-" + uuidv4();
|
|
1099
1098
|
const handleChange = useCallback((event) => {
|
|
1100
1099
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1101
1100
|
}, [onChange]);
|
|
@@ -1282,7 +1281,7 @@ const phoneErrorMessage = (phoneNumber, required) => {
|
|
|
1282
1281
|
* @returns {JSX.Element} - The PhoneField component.
|
|
1283
1282
|
*/
|
|
1284
1283
|
const PhoneField = forwardRef(({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId, name, onBlur, ...rest }, ref) => {
|
|
1285
|
-
const htmlForId = id ? id : "phoneField-" +
|
|
1284
|
+
const htmlForId = id ? id : "phoneField-" + uuidv4();
|
|
1286
1285
|
const [t] = useTranslation();
|
|
1287
1286
|
const [innerValue, setInnerValue] = useState(() => {
|
|
1288
1287
|
var _a;
|
|
@@ -2373,7 +2372,7 @@ const FormFieldSelectAdapter = forwardRef(({ className, dataTestId, helpText, he
|
|
|
2373
2372
|
setInnerValue(defaultValue);
|
|
2374
2373
|
}, [defaultValue]);
|
|
2375
2374
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2376
|
-
const htmlFor = useMemo(() => (id ? id : "selectField-" +
|
|
2375
|
+
const htmlFor = useMemo(() => (id ? id : "selectField-" + uuidv4()), [id]);
|
|
2377
2376
|
const innerRef = useRef(null);
|
|
2378
2377
|
useImperativeHandle(ref, () => innerRef.current, []);
|
|
2379
2378
|
useEffect(() => {
|
|
@@ -2510,7 +2509,7 @@ const TextLengthIndicator = ({ length, maxLength }) => {
|
|
|
2510
2509
|
const TextAreaField = React.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
2511
2510
|
const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
|
|
2512
2511
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2513
|
-
const htmlForId = id ? id : "textAreaField-" +
|
|
2512
|
+
const htmlForId = id ? id : "textAreaField-" + uuidv4();
|
|
2514
2513
|
const handleChange = React.useCallback((event) => {
|
|
2515
2514
|
setValueLength(event.target.value.length);
|
|
2516
2515
|
if (onChange) {
|
|
@@ -2532,7 +2531,7 @@ TextAreaField.displayName = "TextAreaField";
|
|
|
2532
2531
|
const TextField = React.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
2533
2532
|
const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
|
|
2534
2533
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2535
|
-
const htmlFor = id ? id : "textField-" +
|
|
2534
|
+
const htmlFor = id ? id : "textField-" + uuidv4();
|
|
2536
2535
|
const handleChange = React.useCallback((event) => {
|
|
2537
2536
|
setValueLength(event.target.value.length);
|
|
2538
2537
|
if (onChange) {
|
|
@@ -2552,7 +2551,7 @@ TextField.displayName = "TextField";
|
|
|
2552
2551
|
*/
|
|
2553
2552
|
const TimeRangeField = ({ className, dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ...rest }) => {
|
|
2554
2553
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2555
|
-
const htmlFor = id ? id : "timeRangeField-" +
|
|
2554
|
+
const htmlFor = id ? id : "timeRangeField-" + uuidv4();
|
|
2556
2555
|
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(TimeRange, { className: className, dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
2557
2556
|
};
|
|
2558
2557
|
|
|
@@ -2657,7 +2656,7 @@ UploadInput.displayName = "UploadInput";
|
|
|
2657
2656
|
*/
|
|
2658
2657
|
const UploadField = forwardRef(({ label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId, ...rest }, ref) => {
|
|
2659
2658
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2660
|
-
const htmlForId = id ? id : "uploadField-" +
|
|
2659
|
+
const htmlForId = id ? id : "uploadField-" + uuidv4();
|
|
2661
2660
|
return (jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2662
2661
|
});
|
|
2663
2662
|
UploadField.displayName = "UploadField";
|
|
@@ -2711,7 +2710,7 @@ UrlInput.displayName = "UrlField";
|
|
|
2711
2710
|
*
|
|
2712
2711
|
*/
|
|
2713
2712
|
const UrlField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, isInvalid = false, value, onBlur, ...rest }, ref) => {
|
|
2714
|
-
const htmlForId = id ? id : "urlField-" +
|
|
2713
|
+
const htmlForId = id ? id : "urlField-" + uuidv4();
|
|
2715
2714
|
const [t] = useTranslation();
|
|
2716
2715
|
const [innerValue, setInnerValue] = useState(() => {
|
|
2717
2716
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"@trackunit/react-components": "*",
|
|
11
11
|
"@trackunit/ui-icons": "*",
|
|
12
12
|
"react": "18.3.1",
|
|
13
|
-
"uuid": "^9.0.1",
|
|
14
13
|
"usehooks-ts": "^3.1.0",
|
|
15
14
|
"date-fns": "^2.30.0",
|
|
16
15
|
"react-select": "^5.8.0",
|