@trackunit/react-form-components 0.2.9 → 0.2.11
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 -15
- package/index.esm.js +15 -15
- package/package.json +7 -7
package/index.cjs.js
CHANGED
|
@@ -644,7 +644,7 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
|
|
|
644
644
|
*/
|
|
645
645
|
const CheckboxField = React.forwardRef(({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange, ...rest }, ref) => {
|
|
646
646
|
const htmlForId = id ? id : "checkboxField-" + sharedUtils.uuidv4();
|
|
647
|
-
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 }) }));
|
|
647
|
+
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 ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(Checkbox, { checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref, ...rest }) }));
|
|
648
648
|
});
|
|
649
649
|
CheckboxField.displayName = "CheckboxField";
|
|
650
650
|
|
|
@@ -719,7 +719,7 @@ const ColorField = React.forwardRef(({ label, id, tip, helpText, errorMessage, h
|
|
|
719
719
|
onChange(event);
|
|
720
720
|
}
|
|
721
721
|
}, [onChange]);
|
|
722
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsxs("div", { className: cvaInput({
|
|
722
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsxs("div", { className: cvaInput({
|
|
723
723
|
disabled: false,
|
|
724
724
|
invalid: false,
|
|
725
725
|
className,
|
|
@@ -760,7 +760,7 @@ DateInput.displayName = "DateInput";
|
|
|
760
760
|
const DateField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId, ...rest }, ref) => {
|
|
761
761
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
762
762
|
const htmlForId = id ? id : "dateField-" + sharedUtils.uuidv4();
|
|
763
|
-
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 }) }));
|
|
763
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(DateInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
764
764
|
});
|
|
765
765
|
DateField.displayName = "DateField";
|
|
766
766
|
|
|
@@ -936,7 +936,7 @@ EmailInput.displayName = "EmailInput";
|
|
|
936
936
|
* EmailField validates that user enters a valid email address.
|
|
937
937
|
*
|
|
938
938
|
*/
|
|
939
|
-
const EmailField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value,
|
|
939
|
+
const EmailField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, onChange, onBlur, isInvalid = false, ...rest }, ref) => {
|
|
940
940
|
const htmlForId = id ? id : "emailField-" + sharedUtils.uuidv4();
|
|
941
941
|
const [t] = useTranslation();
|
|
942
942
|
const [innerValue, setInnerValue] = React.useState(() => {
|
|
@@ -958,7 +958,7 @@ const EmailField = React.forwardRef(({ label, id, tip, helpText, errorMessage, h
|
|
|
958
958
|
onChange(event);
|
|
959
959
|
}
|
|
960
960
|
}, [onChange]);
|
|
961
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(EmailInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue,
|
|
961
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(EmailInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
962
962
|
});
|
|
963
963
|
EmailField.displayName = "EmailField";
|
|
964
964
|
|
|
@@ -1067,7 +1067,7 @@ const NumberField = React.forwardRef(({ label, id, tip, helpText, errorMessage,
|
|
|
1067
1067
|
onChange(event);
|
|
1068
1068
|
}
|
|
1069
1069
|
}, [onChange]);
|
|
1070
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(NumberInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
1070
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(NumberInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
1071
1071
|
});
|
|
1072
1072
|
NumberField.displayName = "NumberField";
|
|
1073
1073
|
|
|
@@ -1132,7 +1132,7 @@ const PasswordField = React.forwardRef(({ id, label, tip, helpText, helpAddon, e
|
|
|
1132
1132
|
const handleChange = React.useCallback((event) => {
|
|
1133
1133
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1134
1134
|
}, [onChange]);
|
|
1135
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(PasswordInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value }) }));
|
|
1135
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(PasswordInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value }) }));
|
|
1136
1136
|
});
|
|
1137
1137
|
PasswordField.displayName = "PasswordField";
|
|
1138
1138
|
|
|
@@ -1347,7 +1347,7 @@ const PhoneField = React.forwardRef(({ label, id, tip, helpText, isInvalid, erro
|
|
|
1347
1347
|
}
|
|
1348
1348
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
1349
1349
|
}, [errorMessage, onBlur, rest.required]);
|
|
1350
|
-
return (jsxRuntime.jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(PhoneInput, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: handleBlur, ref: ref, value: value, ...rest }) }));
|
|
1350
|
+
return (jsxRuntime.jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(PhoneInput, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: handleBlur, ref: ref, value: value, ...rest }) }));
|
|
1351
1351
|
});
|
|
1352
1352
|
PhoneField.displayName = "PhoneField";
|
|
1353
1353
|
|
|
@@ -2346,7 +2346,7 @@ const Select = (props) => {
|
|
|
2346
2346
|
};
|
|
2347
2347
|
Select.displayName = "Select";
|
|
2348
2348
|
|
|
2349
|
-
const FormFieldSelectAdapter = React.forwardRef(({ className, dataTestId, helpText, helpAddon, tip, label,
|
|
2349
|
+
const FormFieldSelectAdapter = React.forwardRef(({ className, dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ...rest }, ref) => {
|
|
2350
2350
|
const isFirstRender = reactComponents.useIsFirstRender();
|
|
2351
2351
|
const [innerValue, setInnerValue] = React.useState(value || defaultValue);
|
|
2352
2352
|
React.useEffect(() => {
|
|
@@ -2384,12 +2384,12 @@ const FormFieldSelectAdapter = React.forwardRef(({ className, dataTestId, helpTe
|
|
|
2384
2384
|
helpText: (renderAsInvalid && errorMessage) || helpText,
|
|
2385
2385
|
helpAddon,
|
|
2386
2386
|
tip,
|
|
2387
|
-
label,
|
|
2387
|
+
label,
|
|
2388
|
+
required: rest.required ? !(rest.disabled || rest.readOnly) : false, children: [jsxRuntime.jsx("select", { onChange, ref: innerRef, name, value: innerValue, hidden: true, children: optionsWithCurrentSelectionBackupOption.map(option => {
|
|
2388
2389
|
return (jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value));
|
|
2389
2390
|
}) }), children({
|
|
2390
2391
|
...rest,
|
|
2391
2392
|
id,
|
|
2392
|
-
disabled,
|
|
2393
2393
|
onBlur,
|
|
2394
2394
|
options: optionsWithCurrentSelectionBackupOption,
|
|
2395
2395
|
onChange: e => {
|
|
@@ -2498,7 +2498,7 @@ const TextAreaField = React__namespace.forwardRef(({ id, label, tip, helpText, h
|
|
|
2498
2498
|
}
|
|
2499
2499
|
}, [onChange]);
|
|
2500
2500
|
return (jsxRuntime.jsx(FormGroup, { className: tailwindMerge.twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2501
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(TextArea, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto", dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2501
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextArea, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto", dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2502
2502
|
});
|
|
2503
2503
|
TextAreaField.displayName = "TextAreaField";
|
|
2504
2504
|
|
|
@@ -2520,7 +2520,7 @@ const TextField = React__namespace.forwardRef(({ id, label, tip, helpText, helpA
|
|
|
2520
2520
|
}
|
|
2521
2521
|
}, [onChange]);
|
|
2522
2522
|
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2523
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(TextInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2523
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2524
2524
|
});
|
|
2525
2525
|
TextField.displayName = "TextField";
|
|
2526
2526
|
|
|
@@ -2661,7 +2661,7 @@ UploadInput.displayName = "UploadInput";
|
|
|
2661
2661
|
const UploadField = React.forwardRef(({ label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId, ...rest }, ref) => {
|
|
2662
2662
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2663
2663
|
const htmlForId = id ? id : "uploadField-" + sharedUtils.uuidv4();
|
|
2664
|
-
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 }) }));
|
|
2664
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2665
2665
|
});
|
|
2666
2666
|
UploadField.displayName = "UploadField";
|
|
2667
2667
|
|
|
@@ -2729,7 +2729,7 @@ const UrlField = React.forwardRef(({ label, id, tip, helpText, errorMessage, hel
|
|
|
2729
2729
|
setRenderAsInvalid(!!validateUrl(newValue, rest.required));
|
|
2730
2730
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
2731
2731
|
}, [onBlur, rest.required]);
|
|
2732
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(UrlInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, value: value || defaultValue, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2732
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(UrlInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, value: value || defaultValue, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2733
2733
|
});
|
|
2734
2734
|
UrlField.displayName = "UrlField";
|
|
2735
2735
|
|
package/index.esm.js
CHANGED
|
@@ -625,7 +625,7 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
|
|
|
625
625
|
*/
|
|
626
626
|
const CheckboxField = forwardRef(({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange, ...rest }, ref) => {
|
|
627
627
|
const htmlForId = id ? id : "checkboxField-" + uuidv4();
|
|
628
|
-
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 }) }));
|
|
628
|
+
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 ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(Checkbox, { checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref, ...rest }) }));
|
|
629
629
|
});
|
|
630
630
|
CheckboxField.displayName = "CheckboxField";
|
|
631
631
|
|
|
@@ -700,7 +700,7 @@ const ColorField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAdd
|
|
|
700
700
|
onChange(event);
|
|
701
701
|
}
|
|
702
702
|
}, [onChange]);
|
|
703
|
-
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxs("div", { className: cvaInput({
|
|
703
|
+
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxs("div", { className: cvaInput({
|
|
704
704
|
disabled: false,
|
|
705
705
|
invalid: false,
|
|
706
706
|
className,
|
|
@@ -741,7 +741,7 @@ DateInput.displayName = "DateInput";
|
|
|
741
741
|
const DateField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId, ...rest }, ref) => {
|
|
742
742
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
743
743
|
const htmlForId = id ? id : "dateField-" + uuidv4();
|
|
744
|
-
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 }) }));
|
|
744
|
+
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(DateInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
745
745
|
});
|
|
746
746
|
DateField.displayName = "DateField";
|
|
747
747
|
|
|
@@ -917,7 +917,7 @@ EmailInput.displayName = "EmailInput";
|
|
|
917
917
|
* EmailField validates that user enters a valid email address.
|
|
918
918
|
*
|
|
919
919
|
*/
|
|
920
|
-
const EmailField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value,
|
|
920
|
+
const EmailField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, onChange, onBlur, isInvalid = false, ...rest }, ref) => {
|
|
921
921
|
const htmlForId = id ? id : "emailField-" + uuidv4();
|
|
922
922
|
const [t] = useTranslation();
|
|
923
923
|
const [innerValue, setInnerValue] = useState(() => {
|
|
@@ -939,7 +939,7 @@ const EmailField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAdd
|
|
|
939
939
|
onChange(event);
|
|
940
940
|
}
|
|
941
941
|
}, [onChange]);
|
|
942
|
-
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(EmailInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue,
|
|
942
|
+
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(EmailInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
943
943
|
});
|
|
944
944
|
EmailField.displayName = "EmailField";
|
|
945
945
|
|
|
@@ -1048,7 +1048,7 @@ const NumberField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAd
|
|
|
1048
1048
|
onChange(event);
|
|
1049
1049
|
}
|
|
1050
1050
|
}, [onChange]);
|
|
1051
|
-
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(NumberInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
1051
|
+
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(NumberInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
1052
1052
|
});
|
|
1053
1053
|
NumberField.displayName = "NumberField";
|
|
1054
1054
|
|
|
@@ -1113,7 +1113,7 @@ const PasswordField = forwardRef(({ id, label, tip, helpText, helpAddon, errorMe
|
|
|
1113
1113
|
const handleChange = useCallback((event) => {
|
|
1114
1114
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1115
1115
|
}, [onChange]);
|
|
1116
|
-
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(PasswordInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value }) }));
|
|
1116
|
+
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(PasswordInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value }) }));
|
|
1117
1117
|
});
|
|
1118
1118
|
PasswordField.displayName = "PasswordField";
|
|
1119
1119
|
|
|
@@ -1328,7 +1328,7 @@ const PhoneField = forwardRef(({ label, id, tip, helpText, isInvalid, errorMessa
|
|
|
1328
1328
|
}
|
|
1329
1329
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
1330
1330
|
}, [errorMessage, onBlur, rest.required]);
|
|
1331
|
-
return (jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(PhoneInput, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: handleBlur, ref: ref, value: value, ...rest }) }));
|
|
1331
|
+
return (jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(PhoneInput, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: handleBlur, ref: ref, value: value, ...rest }) }));
|
|
1332
1332
|
});
|
|
1333
1333
|
PhoneField.displayName = "PhoneField";
|
|
1334
1334
|
|
|
@@ -2327,7 +2327,7 @@ const Select = (props) => {
|
|
|
2327
2327
|
};
|
|
2328
2328
|
Select.displayName = "Select";
|
|
2329
2329
|
|
|
2330
|
-
const FormFieldSelectAdapter = forwardRef(({ className, dataTestId, helpText, helpAddon, tip, label,
|
|
2330
|
+
const FormFieldSelectAdapter = forwardRef(({ className, dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ...rest }, ref) => {
|
|
2331
2331
|
const isFirstRender = useIsFirstRender();
|
|
2332
2332
|
const [innerValue, setInnerValue] = useState(value || defaultValue);
|
|
2333
2333
|
useEffect(() => {
|
|
@@ -2365,12 +2365,12 @@ const FormFieldSelectAdapter = forwardRef(({ className, dataTestId, helpText, he
|
|
|
2365
2365
|
helpText: (renderAsInvalid && errorMessage) || helpText,
|
|
2366
2366
|
helpAddon,
|
|
2367
2367
|
tip,
|
|
2368
|
-
label,
|
|
2368
|
+
label,
|
|
2369
|
+
required: rest.required ? !(rest.disabled || rest.readOnly) : false, children: [jsx("select", { onChange, ref: innerRef, name, value: innerValue, hidden: true, children: optionsWithCurrentSelectionBackupOption.map(option => {
|
|
2369
2370
|
return (jsx("option", { value: option.value, children: option.label }, option.value));
|
|
2370
2371
|
}) }), children({
|
|
2371
2372
|
...rest,
|
|
2372
2373
|
id,
|
|
2373
|
-
disabled,
|
|
2374
2374
|
onBlur,
|
|
2375
2375
|
options: optionsWithCurrentSelectionBackupOption,
|
|
2376
2376
|
onChange: e => {
|
|
@@ -2479,7 +2479,7 @@ const TextAreaField = React.forwardRef(({ id, label, tip, helpText, helpAddon, e
|
|
|
2479
2479
|
}
|
|
2480
2480
|
}, [onChange]);
|
|
2481
2481
|
return (jsx(FormGroup, { className: twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2482
|
-
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(TextArea, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto", dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2482
|
+
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(TextArea, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto", dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2483
2483
|
});
|
|
2484
2484
|
TextAreaField.displayName = "TextAreaField";
|
|
2485
2485
|
|
|
@@ -2501,7 +2501,7 @@ const TextField = React.forwardRef(({ id, label, tip, helpText, helpAddon, error
|
|
|
2501
2501
|
}
|
|
2502
2502
|
}, [onChange]);
|
|
2503
2503
|
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2504
|
-
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(TextInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2504
|
+
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(TextInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2505
2505
|
});
|
|
2506
2506
|
TextField.displayName = "TextField";
|
|
2507
2507
|
|
|
@@ -2642,7 +2642,7 @@ UploadInput.displayName = "UploadInput";
|
|
|
2642
2642
|
const UploadField = forwardRef(({ label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId, ...rest }, ref) => {
|
|
2643
2643
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2644
2644
|
const htmlForId = id ? id : "uploadField-" + uuidv4();
|
|
2645
|
-
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 }) }));
|
|
2645
|
+
return (jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2646
2646
|
});
|
|
2647
2647
|
UploadField.displayName = "UploadField";
|
|
2648
2648
|
|
|
@@ -2710,7 +2710,7 @@ const UrlField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon
|
|
|
2710
2710
|
setRenderAsInvalid(!!validateUrl(newValue, rest.required));
|
|
2711
2711
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
2712
2712
|
}, [onBlur, rest.required]);
|
|
2713
|
-
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(UrlInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, value: value || defaultValue, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2713
|
+
return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsx(UrlInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, value: value || defaultValue, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2714
2714
|
});
|
|
2715
2715
|
UrlField.displayName = "UrlField";
|
|
2716
2716
|
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
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
|
-
"@trackunit/react-components": "*",
|
|
11
|
-
"@trackunit/ui-icons": "*",
|
|
12
10
|
"react": "18.3.1",
|
|
13
11
|
"usehooks-ts": "^3.1.0",
|
|
14
12
|
"react-select": "^5.8.0",
|
|
15
13
|
"@js-temporal/polyfill": "^0.4.4",
|
|
16
14
|
"libphonenumber-js": "1.10.36",
|
|
17
|
-
"@trackunit/shared-utils": "*",
|
|
18
15
|
"@testing-library/react": "15.0.6",
|
|
19
16
|
"jest-fetch-mock": "^3.0.3",
|
|
20
|
-
"@trackunit/css-class-variance-utilities": "*",
|
|
21
|
-
"@trackunit/i18n-library-translation": "*",
|
|
22
17
|
"zod": "3.22.4",
|
|
23
18
|
"react-hook-form": "7.53.1",
|
|
24
|
-
"tailwind-merge": "^2.0.0"
|
|
19
|
+
"tailwind-merge": "^2.0.0",
|
|
20
|
+
"@trackunit/css-class-variance-utilities": "^0.0.61",
|
|
21
|
+
"@trackunit/react-components": "^0.5.41",
|
|
22
|
+
"@trackunit/ui-icons": "^0.0.135",
|
|
23
|
+
"@trackunit/shared-utils": "^0.0.92",
|
|
24
|
+
"@trackunit/i18n-library-translation": "^0.0.230"
|
|
25
25
|
},
|
|
26
26
|
"module": "./index.esm.js",
|
|
27
27
|
"main": "./index.cjs.js",
|