@trackunit/react-form-components 1.18.2 → 1.18.4
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 +51 -51
- package/index.esm.js +51 -51
- package/package.json +3 -3
- package/src/components/CheckboxField/CheckboxField.d.ts +1 -1
- package/src/components/ColorField/ColorField.d.ts +1 -1
- package/src/components/DateField/DateField.d.ts +1 -1
- package/src/components/EmailField/EmailField.d.ts +1 -1
- package/src/components/NumberField/NumberField.d.ts +1 -1
- package/src/components/PasswordField/PasswordField.d.ts +1 -1
- package/src/components/PhoneField/PhoneField.d.ts +1 -1
- package/src/components/TextAreaField/TextAreaField.d.ts +1 -1
- package/src/components/TextField/TextField.d.ts +1 -1
- package/src/components/ToggleSwitchOption/ToggleSwitchOption.d.ts +1 -1
- package/src/components/UploadField/UploadField.d.ts +1 -1
- package/src/components/UrlField/UrlField.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -319,7 +319,7 @@ const cvaActionContainer = cssClassVarianceUtilities.cvaMerge(["flex", "items-ce
|
|
|
319
319
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
320
320
|
* @returns {ReactElement} ActionButton component
|
|
321
321
|
*/
|
|
322
|
-
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, ref, }) => {
|
|
322
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium", disabled, className, onClick, ref, }) => {
|
|
323
323
|
const [, copyToClipboard] = usehooksTs.useCopyToClipboard();
|
|
324
324
|
const getIconName = () => {
|
|
325
325
|
switch (type) {
|
|
@@ -361,7 +361,7 @@ const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled,
|
|
|
361
361
|
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className, size }), ref: ref, children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: adjustedIconSize }), "data-testid": dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: adjustedIconSize }), onClick: buttonAction, size: "small", variant: "ghost-neutral" }) }));
|
|
362
362
|
};
|
|
363
363
|
|
|
364
|
-
const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef, tooltipLabel, }) => {
|
|
364
|
+
const GenericActionsRenderer = ({ genericAction = undefined, disabled, fieldSize = undefined, innerRef, tooltipLabel, }) => {
|
|
365
365
|
const [t] = useTranslation();
|
|
366
366
|
if (!genericAction) {
|
|
367
367
|
return null;
|
|
@@ -692,7 +692,7 @@ const cvaTextAreaBaseInput = cssClassVarianceUtilities.cvaMerge([
|
|
|
692
692
|
* The TextArea is a base component, and should not be used very often.
|
|
693
693
|
* For most cases the TextAreaField is the correct component.
|
|
694
694
|
*/
|
|
695
|
-
const TextAreaBaseInput = ({ id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, "data-testid": dataTestId, isInvalid, className, ref, ...rest }) => {
|
|
695
|
+
const TextAreaBaseInput = ({ id, name, value, rows, disabled = false, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, "data-testid": dataTestId, isInvalid = false, className, ref, ...rest }) => {
|
|
696
696
|
return (jsxRuntime.jsx("textarea", { className: cvaTextAreaBaseInput({ className, resize, invalid: isInvalid, disabled }), defaultValue: defaultValue, disabled: disabled, id: id, maxLength: maxLength, name: name, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, readOnly: readOnly, ref: ref, required: required, rows: rows, tabIndex: tabIndex, value: value, ...rest, "data-testid": dataTestId, onChange: onChange }));
|
|
697
697
|
};
|
|
698
698
|
|
|
@@ -2029,7 +2029,7 @@ const CreatableSelect = (props) => {
|
|
|
2029
2029
|
* @param {LabelProps} props - The props for the Label component
|
|
2030
2030
|
* @returns {ReactElement} Label component
|
|
2031
2031
|
*/
|
|
2032
|
-
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled, isInvalid, ref, }) => {
|
|
2032
|
+
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled = false, isInvalid = false, ref, }) => {
|
|
2033
2033
|
return (jsxRuntime.jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", ref: ref, children: children }));
|
|
2034
2034
|
};
|
|
2035
2035
|
|
|
@@ -2120,9 +2120,9 @@ const FormGroup = ({ isInvalid = false, isWarning = false, helpText, helpAddon,
|
|
|
2120
2120
|
* ```
|
|
2121
2121
|
* @param {CheckboxFieldProps} props - The props for the CheckboxField component
|
|
2122
2122
|
*/
|
|
2123
|
-
const CheckboxField = ({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, ...rest }) => {
|
|
2123
|
+
const CheckboxField = ({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, disabled = false, readOnly = false, required = false, ...rest }) => {
|
|
2124
2124
|
const htmlForId = id ? id : "checkboxField-" + sharedUtils.uuidv4();
|
|
2125
|
-
return (jsxRuntime.jsx(FormGroup, { className: "flex flex-col gap-1", "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required:
|
|
2125
|
+
return (jsxRuntime.jsx(FormGroup, { className: "flex flex-col gap-1", "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: required ? !(disabled || readOnly) : false, tip: tip, children: jsxRuntime.jsx(Checkbox, { checked: checked, className: className, "data-testid": dataTestId, disabled: disabled, id: htmlForId, label: checkboxLabel, onChange: onChange, readOnly: readOnly, ref: ref, required: required, ...rest }) }));
|
|
2126
2126
|
};
|
|
2127
2127
|
CheckboxField.displayName = "CheckboxField";
|
|
2128
2128
|
|
|
@@ -2232,7 +2232,7 @@ const isValidHEXColor = (value) => {
|
|
|
2232
2232
|
* />
|
|
2233
2233
|
* ```
|
|
2234
2234
|
*/
|
|
2235
|
-
const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize = "medium", style, disabled, readOnly, isWarning, inputClassName, ref, ...inputProps }) => {
|
|
2235
|
+
const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid = undefined, onBlur, fieldSize = "medium", style, disabled, readOnly, isWarning = false, inputClassName, ref, required = false, ...inputProps }) => {
|
|
2236
2236
|
const renderAsDisabled = Boolean(disabled);
|
|
2237
2237
|
const renderAsReadonly = Boolean(readOnly);
|
|
2238
2238
|
const htmlForId = react.useMemo(() => (id ? id : "colorField-" + sharedUtils.uuidv4()), [id]);
|
|
@@ -2242,7 +2242,7 @@ const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2242
2242
|
// Internal state for color value
|
|
2243
2243
|
const [innerValue, setInnerValue] = react.useState(propValue ?? defaultValue ?? "");
|
|
2244
2244
|
const [hasBeenBlurred, setHasBeenBlurred] = react.useState(false);
|
|
2245
|
-
const errorType = react.useMemo(() => validateColorCode(innerValue,
|
|
2245
|
+
const errorType = react.useMemo(() => validateColorCode(innerValue, required), [required, innerValue]);
|
|
2246
2246
|
const error = react.useMemo(() => (errorType ? t(`colorField.error.${errorType}`) : errorMessage), [errorType, errorMessage, t]);
|
|
2247
2247
|
// Derive renderAsInvalid from props and internal validation
|
|
2248
2248
|
const renderAsInvalid = react.useMemo(() => {
|
|
@@ -2275,7 +2275,7 @@ const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2275
2275
|
setHasBeenBlurred(true);
|
|
2276
2276
|
onBlur?.(event);
|
|
2277
2277
|
}, [onBlur]);
|
|
2278
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2278
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(renderAsDisabled || renderAsReadonly) : false, tip: tip, children: jsxRuntime.jsxs("div", { className: cvaInput$1({
|
|
2279
2279
|
size: fieldSize,
|
|
2280
2280
|
disabled: renderAsDisabled,
|
|
2281
2281
|
invalid: renderAsInvalid,
|
|
@@ -2284,7 +2284,7 @@ const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2284
2284
|
className,
|
|
2285
2285
|
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label", className: cvaInputColorField({ readOnly: renderAsReadonly }), "data-testid": dataTestId, defaultValue: defaultValue, disabled: renderAsDisabled, id: htmlForId, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, ref: mergedRef, type: "color", value: innerValue }), jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputElement({
|
|
2286
2286
|
className: tailwindMerge.twMerge("focus-visible:outline-hidden px-1", inputClassName),
|
|
2287
|
-
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, type: "text", value: innerValue, ...inputProps }), jsxRuntime.jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
2287
|
+
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, required: required, type: "text", value: innerValue, ...inputProps }), jsxRuntime.jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
2288
2288
|
};
|
|
2289
2289
|
ColorField.displayName = "ColorField";
|
|
2290
2290
|
|
|
@@ -2336,10 +2336,10 @@ ColorField.displayName = "ColorField";
|
|
|
2336
2336
|
* };
|
|
2337
2337
|
* ```
|
|
2338
2338
|
*/
|
|
2339
|
-
const DateField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2339
|
+
const DateField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid = undefined, className, defaultValue, "data-testid": dataTestId, ref, required = false, ...rest }) => {
|
|
2340
2340
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2341
2341
|
const htmlForId = id ? id : "dateField-" + sharedUtils.uuidv4();
|
|
2342
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2342
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(DateBaseInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, required: required, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2343
2343
|
};
|
|
2344
2344
|
DateField.displayName = "DateField";
|
|
2345
2345
|
|
|
@@ -2618,14 +2618,14 @@ const EmailBaseInput = ({ fieldSize = "medium", disabled = false, "data-testid":
|
|
|
2618
2618
|
* />
|
|
2619
2619
|
* ```
|
|
2620
2620
|
*/
|
|
2621
|
-
const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid = false, ref, ...rest }) => {
|
|
2621
|
+
const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid = false, ref, required = false, ...rest }) => {
|
|
2622
2622
|
const htmlForId = id ? id : "emailField-" + sharedUtils.uuidv4();
|
|
2623
2623
|
const [t] = useTranslation();
|
|
2624
2624
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
2625
2625
|
return (value?.toString() || defaultValue?.toString()) ?? "";
|
|
2626
2626
|
});
|
|
2627
2627
|
const [renderAsInvalid, setRenderAsInvalid] = react.useState(!!errorMessage || (typeof value === "string" && value !== "" && !validateEmailAddress(value)) || isInvalid);
|
|
2628
|
-
const errorType = react.useMemo(() => validateEmailId(innerValue ?? "",
|
|
2628
|
+
const errorType = react.useMemo(() => validateEmailId(innerValue ?? "", required), [required, innerValue]);
|
|
2629
2629
|
const error = react.useMemo(() => (errorType ? t(`emailField.error.${errorType}`) : errorMessage), [errorType, errorMessage, t]);
|
|
2630
2630
|
const handleBlur = react.useCallback(event => {
|
|
2631
2631
|
const newValue = event.target.value;
|
|
@@ -2639,7 +2639,7 @@ const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2639
2639
|
onChange(event);
|
|
2640
2640
|
}
|
|
2641
2641
|
}, [onChange]);
|
|
2642
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2642
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(EmailBaseInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, onChange: handleChange, ref: ref, required: required, value: value, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2643
2643
|
};
|
|
2644
2644
|
EmailField.displayName = "EmailField";
|
|
2645
2645
|
|
|
@@ -2660,7 +2660,7 @@ const IGNORED_RS_ACTIONS = new Set(["set-value", "input-blur", "menu-close"]);
|
|
|
2660
2660
|
* @returns {ReactElement} FormFieldSelectAdapterMulti component
|
|
2661
2661
|
*/
|
|
2662
2662
|
const FormFieldSelectAdapterMulti = (props) => {
|
|
2663
|
-
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, onInputChange, ...selectProps } = props;
|
|
2663
|
+
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = undefined, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, onInputChange, ...selectProps } = props;
|
|
2664
2664
|
const [inputValue, setInputValue] = react.useState("");
|
|
2665
2665
|
// Hidden select for a stable DOM ref target (API parity with single adapter)
|
|
2666
2666
|
const innerRef = react.useRef(null);
|
|
@@ -2896,15 +2896,15 @@ const validateNumber = (number, required = false, min, max) => {
|
|
|
2896
2896
|
* };
|
|
2897
2897
|
* ```
|
|
2898
2898
|
*/
|
|
2899
|
-
const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, ...rest }) => {
|
|
2899
|
+
const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid = undefined, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, required = false, ...rest }) => {
|
|
2900
2900
|
const htmlForId = id ? id : "numberField-" + sharedUtils.uuidv4();
|
|
2901
2901
|
const [t] = useTranslation();
|
|
2902
2902
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
2903
2903
|
return Number(value?.toString()) || Number(defaultValue?.toString());
|
|
2904
2904
|
});
|
|
2905
2905
|
const [renderAsInvalid, setRenderAsInvalid] = react.useState((isInvalid === undefined ? Boolean(errorMessage) : isInvalid) ||
|
|
2906
|
-
!!validateNumber(value?.toString(),
|
|
2907
|
-
const errorType = react.useMemo(() => validateNumber(innerValue,
|
|
2906
|
+
!!validateNumber(value?.toString(), required, rest.min, rest.max));
|
|
2907
|
+
const errorType = react.useMemo(() => validateNumber(innerValue, required, rest.min, rest.max), [innerValue, rest.max, rest.min, required]);
|
|
2908
2908
|
const error = react.useMemo(() => {
|
|
2909
2909
|
// for the case when a custom error message is provided
|
|
2910
2910
|
if (errorMessage) {
|
|
@@ -2924,21 +2924,21 @@ const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInva
|
|
|
2924
2924
|
const newValue = event.target.value;
|
|
2925
2925
|
setInnerValue(newValue.toString());
|
|
2926
2926
|
// for the case when a custom error message is provided
|
|
2927
|
-
if (errorMessage && !validateNumber(newValue,
|
|
2927
|
+
if (errorMessage && !validateNumber(newValue, required, rest.min, rest.max)) {
|
|
2928
2928
|
setRenderAsInvalid(Boolean(errorMessage));
|
|
2929
2929
|
}
|
|
2930
2930
|
else {
|
|
2931
|
-
setRenderAsInvalid(!!validateNumber(newValue,
|
|
2931
|
+
setRenderAsInvalid(!!validateNumber(newValue, required, rest.min, rest.max));
|
|
2932
2932
|
}
|
|
2933
2933
|
onBlur?.(event);
|
|
2934
|
-
}, [errorMessage, onBlur, rest.max, rest.min,
|
|
2934
|
+
}, [errorMessage, onBlur, rest.max, rest.min, required]);
|
|
2935
2935
|
const handleChange = react.useCallback((event) => {
|
|
2936
2936
|
setInnerValue(event.target.value);
|
|
2937
2937
|
if (onChange) {
|
|
2938
2938
|
onChange(event);
|
|
2939
2939
|
}
|
|
2940
2940
|
}, [onChange]);
|
|
2941
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2941
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(NumberBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, required: required, value: value, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2942
2942
|
};
|
|
2943
2943
|
NumberField.displayName = "NumberField";
|
|
2944
2944
|
|
|
@@ -3021,7 +3021,7 @@ const cvaTag = cssClassVarianceUtilities.cvaMerge([], {
|
|
|
3021
3021
|
/**
|
|
3022
3022
|
* A card version of a radio button that includes an icon, headings and a description.
|
|
3023
3023
|
*/
|
|
3024
|
-
const OptionCard = ({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, "data-testid": dataTestId, customImage, layout = "default", ref, tagProps, ...rest }) => {
|
|
3024
|
+
const OptionCard = ({ icon, heading, subheading, description, disabled = false, id, value, className, contentClassName, "data-testid": dataTestId, customImage, layout = "default", ref, tagProps, ...rest }) => {
|
|
3025
3025
|
const htmlForId = id ?? "option-card-" + sharedUtils.uuidv4();
|
|
3026
3026
|
const subContent = react.useMemo(() => (jsxRuntime.jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading !== undefined && subheading !== null ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", className: cvaOptionCardText({ type: "subheading", disabled }), type: "span", children: subheading })) : null, description !== undefined && description !== null ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", className: cvaOptionCardText({ type: "description", disabled }), type: "span", children: description })) : null] })), [subheading, description, contentClassName, disabled]);
|
|
3027
3027
|
return (jsxRuntime.jsx(reactComponents.Tooltip, { disabled: layout !== "compact" || ((subheading === undefined || subheading === null) && (description === undefined || description === null)), label: subContent, mode: "light", placement: "top", children: jsxRuntime.jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsxRuntime.jsx("input", { className: cvaInput(), "data-testid": dataTestId ? `${dataTestId}-option-card` : undefined, disabled: disabled, id: htmlForId, ref: ref, type: "radio", value: value, ...rest }), jsxRuntime.jsxs("label", { className: cvaOptionCardLabel({ className, disabled, layout }), "data-testid": dataTestId ? `${dataTestId}-option-card-label` : undefined, htmlFor: htmlForId, children: [disabled && icon && !customImage
|
|
@@ -3035,7 +3035,7 @@ OptionCard.displayName = "OptionCard";
|
|
|
3035
3035
|
*
|
|
3036
3036
|
* NOTE: If shown with a label, please use the `PasswordField` component instead.
|
|
3037
3037
|
*/
|
|
3038
|
-
const PasswordBaseInput = ({ ref, fieldSize, ...rest }) => {
|
|
3038
|
+
const PasswordBaseInput = ({ ref, fieldSize = undefined, ...rest }) => {
|
|
3039
3039
|
const [showPassword, setShowPassword] = react.useState(false);
|
|
3040
3040
|
return (jsxRuntime.jsx(BaseInput, { ref: ref, ...rest, actions: jsxRuntime.jsx("div", { className: cvaActionContainer({ size: fieldSize }), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: fieldSize }), icon: jsxRuntime.jsx(reactComponents.Icon, { name: showPassword ? "EyeSlash" : "Eye", size: "small" }), onClick: () => setShowPassword(prevState => !prevState), size: "small", variant: "secondary" }) }), type: showPassword ? "text" : "password" }));
|
|
3041
3041
|
};
|
|
@@ -3096,13 +3096,13 @@ const PasswordBaseInput = ({ ref, fieldSize, ...rest }) => {
|
|
|
3096
3096
|
* />
|
|
3097
3097
|
* ```
|
|
3098
3098
|
*/
|
|
3099
|
-
const PasswordField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
3099
|
+
const PasswordField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid = undefined, maxLength, onChange, className, value, "data-testid": dataTestId, ref, required = false, ...rest }) => {
|
|
3100
3100
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
3101
3101
|
const htmlFor = id ? id : "passwordField-" + sharedUtils.uuidv4();
|
|
3102
3102
|
const handleChange = react.useCallback((event) => {
|
|
3103
3103
|
onChange?.(event);
|
|
3104
3104
|
}, [onChange]);
|
|
3105
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required:
|
|
3105
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(PasswordBaseInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, "data-testid": dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, required: required, value: value }) }));
|
|
3106
3106
|
};
|
|
3107
3107
|
PasswordField.displayName = "PasswordField";
|
|
3108
3108
|
|
|
@@ -3204,15 +3204,15 @@ const phoneErrorMessage = (phoneNumber, required) => {
|
|
|
3204
3204
|
* />
|
|
3205
3205
|
* ```
|
|
3206
3206
|
*/
|
|
3207
|
-
const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, ...rest }) => {
|
|
3207
|
+
const PhoneField = ({ label, id, tip, helpText, isInvalid = undefined, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, required = false, ...rest }) => {
|
|
3208
3208
|
const htmlForId = id ? id : "phoneField-" + sharedUtils.uuidv4();
|
|
3209
3209
|
const [t] = useTranslation();
|
|
3210
3210
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
3211
3211
|
return (value?.toString() || defaultValue?.toString()) ?? undefined;
|
|
3212
3212
|
});
|
|
3213
3213
|
const [renderAsInvalid, setRenderAsInvalid] = react.useState((isInvalid === undefined ? Boolean(errorMessage) : isInvalid) ||
|
|
3214
|
-
!!phoneErrorMessage(value?.toString(),
|
|
3215
|
-
const errorType = react.useMemo(() => phoneErrorMessage(innerValue,
|
|
3214
|
+
!!phoneErrorMessage(value?.toString(), required));
|
|
3215
|
+
const errorType = react.useMemo(() => phoneErrorMessage(innerValue, required), [innerValue, required]);
|
|
3216
3216
|
const error = react.useMemo(() => {
|
|
3217
3217
|
// for the case when a custom error message is provided
|
|
3218
3218
|
if (errorMessage) {
|
|
@@ -3230,15 +3230,15 @@ const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value,
|
|
|
3230
3230
|
const newValue = event.target.value;
|
|
3231
3231
|
setInnerValue(newValue);
|
|
3232
3232
|
// for the case when a custom error message is provided
|
|
3233
|
-
if (errorMessage && !phoneErrorMessage(newValue.toString(),
|
|
3233
|
+
if (errorMessage && !phoneErrorMessage(newValue.toString(), required)) {
|
|
3234
3234
|
setRenderAsInvalid(Boolean(errorMessage));
|
|
3235
3235
|
}
|
|
3236
3236
|
else {
|
|
3237
|
-
setRenderAsInvalid(!!phoneErrorMessage(newValue.toString(),
|
|
3237
|
+
setRenderAsInvalid(!!phoneErrorMessage(newValue.toString(), required));
|
|
3238
3238
|
}
|
|
3239
3239
|
onBlur?.(event);
|
|
3240
|
-
}, [errorMessage, onBlur,
|
|
3241
|
-
return (jsxRuntime.jsx(FormGroup, { className: className, "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
3240
|
+
}, [errorMessage, onBlur, required]);
|
|
3241
|
+
return (jsxRuntime.jsx(FormGroup, { className: className, "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(PhoneBaseInput, { "aria-labelledby": htmlForId + "-label", "data-testid": dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: handleBlur, ref: ref, required: required, value: value, ...rest }) }));
|
|
3242
3242
|
};
|
|
3243
3243
|
PhoneField.displayName = "PhoneField";
|
|
3244
3244
|
|
|
@@ -4003,7 +4003,7 @@ const TextLengthIndicator = ({ length, maxLength }) => {
|
|
|
4003
4003
|
* @param {TextAreaFieldProps} props - The props for the TextAreaField component
|
|
4004
4004
|
* @returns {ReactElement} TextAreaField component
|
|
4005
4005
|
*/
|
|
4006
|
-
const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
4006
|
+
const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid = false, maxLength, onChange, className, value, "data-testid": dataTestId, ref, disabled = false, readOnly = false, required = false, ...rest }) => {
|
|
4007
4007
|
const [valueLength, setValueLength] = react.useState(value !== undefined ? `${value}`.length : 0);
|
|
4008
4008
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
4009
4009
|
const htmlForId = id ? id : "textAreaField-" + sharedUtils.uuidv4();
|
|
@@ -4014,7 +4014,7 @@ const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isIn
|
|
|
4014
4014
|
}
|
|
4015
4015
|
}, [onChange]);
|
|
4016
4016
|
return (jsxRuntime.jsx(FormGroup, { className: tailwindMerge.twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ??
|
|
4017
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
4017
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(disabled || readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextAreaBaseInput, { "aria-labelledby": htmlForId + "-label", disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, readOnly: readOnly, ref: ref, required: required, value: value, ...rest, className: "h-auto", "data-testid": dataTestId, onChange: handleChange }) }));
|
|
4018
4018
|
};
|
|
4019
4019
|
TextAreaField.displayName = "TextAreaField";
|
|
4020
4020
|
|
|
@@ -4076,7 +4076,7 @@ TextAreaField.displayName = "TextAreaField";
|
|
|
4076
4076
|
* };
|
|
4077
4077
|
* ```
|
|
4078
4078
|
*/
|
|
4079
|
-
const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning, ref, ...rest }) => {
|
|
4079
|
+
const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid = undefined, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning = false, ref, required = false, ...rest }) => {
|
|
4080
4080
|
const [valueLength, setValueLength] = react.useState(value !== undefined ? `${value}`.length : 0);
|
|
4081
4081
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
4082
4082
|
const htmlFor = id ? id : "textField-" + sharedUtils.uuidv4();
|
|
@@ -4087,7 +4087,7 @@ const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvali
|
|
|
4087
4087
|
}
|
|
4088
4088
|
}, [onChange]);
|
|
4089
4089
|
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ??
|
|
4090
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, label: label, required:
|
|
4090
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(TextBaseInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, maxLength: maxLength, ref: ref, required: required, value: value, ...rest, className: className, "data-testid": dataTestId, onChange: handleChange }) }));
|
|
4091
4091
|
};
|
|
4092
4092
|
TextField.displayName = "TextField";
|
|
4093
4093
|
|
|
@@ -4130,7 +4130,7 @@ TextField.displayName = "TextField";
|
|
|
4130
4130
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
4131
4131
|
* @returns {ReactElement} TimeRangeField component
|
|
4132
4132
|
*/
|
|
4133
|
-
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ref, ...rest }) => {
|
|
4133
|
+
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid = undefined, errorMessage, label, tip, children, helpText, id, ref, ...rest }) => {
|
|
4134
4134
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
4135
4135
|
const htmlFor = id ? id : "timeRangeField-" + sharedUtils.uuidv4();
|
|
4136
4136
|
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, ref: ref, tip: tip, children: jsxRuntime.jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
@@ -4262,7 +4262,7 @@ const cvaToggleSwitchThumb = cssClassVarianceUtilities.cvaMerge(["block", "round
|
|
|
4262
4262
|
* @param {ToggleSwitchProps} props - The props for the ToggleSwitch component
|
|
4263
4263
|
* @returns {ReactElement} ToggleSwitch component
|
|
4264
4264
|
*/
|
|
4265
|
-
const ToggleSwitch = ({ onChange, onClick, preventDefaultOnClick, className, "data-testid": dataTestId = "toggle-switch", showInputFocus, toggled, size = "medium", tabIndex = 0, readOnly, disabled, ref, ...rest }) => {
|
|
4265
|
+
const ToggleSwitch = ({ onChange, onClick, preventDefaultOnClick = false, className, "data-testid": dataTestId = "toggle-switch", showInputFocus = false, toggled, size = "medium", tabIndex = 0, readOnly = false, disabled = false, ref, ...rest }) => {
|
|
4266
4266
|
const localInputRef = react.useRef(null);
|
|
4267
4267
|
const mergedRef = reactComponents.useMergeRefs([ref, localInputRef]);
|
|
4268
4268
|
// Extract data attributes to apply to wrapper
|
|
@@ -4369,13 +4369,13 @@ ToggleSwitch.displayName = "ToggleSwitch";
|
|
|
4369
4369
|
* @param {ToggleSwitchOptionProps} props - The props for the ToggleSwitchOption component
|
|
4370
4370
|
* @returns {ReactElement} ToggleSwitchOption component
|
|
4371
4371
|
*/
|
|
4372
|
-
const ToggleSwitchOption = ({ label, className, description, suffix, id, "data-testid": dataTestId = "toggle-switch-option", ref, ...rest }) => {
|
|
4372
|
+
const ToggleSwitchOption = ({ label, className, description, suffix, id, "data-testid": dataTestId = "toggle-switch-option", ref, disabled = false, readOnly = false, ...rest }) => {
|
|
4373
4373
|
const { ref: labelRef, isTextTruncated: isLabelTruncated } = reactComponents.useIsTextTruncated();
|
|
4374
4374
|
const { ref: descriptionRef, isTextTruncated: isDescriptionTruncated } = reactComponents.useIsTextTruncated();
|
|
4375
|
-
return (jsxRuntime.jsxs("label", { className: cvaBinaryControlWrapper({ className }), "data-testid": dataTestId, htmlFor: `${id}-toggle-switch`, ref: ref, tabIndex: -1, children: [jsxRuntime.jsx(ToggleSwitch, { "data-testid": `${dataTestId}-switcher`, id: `${id}-toggle-switch`, ...rest }), jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": `${dataTestId}-label-tooltip`, disabled: !isLabelTruncated, label: label, placement: "top", children: jsxRuntime.jsx("div", { className: cvaBinaryControlLabelTooltip(), children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
4376
|
-
disabled:
|
|
4375
|
+
return (jsxRuntime.jsxs("label", { className: cvaBinaryControlWrapper({ className }), "data-testid": dataTestId, htmlFor: `${id}-toggle-switch`, ref: ref, tabIndex: -1, children: [jsxRuntime.jsx(ToggleSwitch, { "data-testid": `${dataTestId}-switcher`, disabled: disabled, id: `${id}-toggle-switch`, readOnly: readOnly, ...rest }), jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": `${dataTestId}-label-tooltip`, disabled: !isLabelTruncated, label: label, placement: "top", children: jsxRuntime.jsx("div", { className: cvaBinaryControlLabelTooltip(), children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
4376
|
+
disabled: disabled || readOnly,
|
|
4377
4377
|
className: "select-none",
|
|
4378
|
-
}), "data-testid": `${dataTestId}-label`, ref: labelRef, children: label }) }) }, `${id}-label-tooltip`), suffix ? (jsxRuntime.jsx("div", { className: cvaBinaryControlSuffixContainer(), "data-testid": `${dataTestId}-suffix-container`, children: suffix })) : null, description !== undefined ? (jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": `${dataTestId}-description-tooltip`, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsxRuntime.jsx("div", { className: cvaBinaryControlDescriptionTooltip(), children: jsxRuntime.jsx("span", { className: cvaBinaryControlDescription({ disabled:
|
|
4378
|
+
}), "data-testid": `${dataTestId}-label`, ref: labelRef, children: label }) }) }, `${id}-label-tooltip`), suffix ? (jsxRuntime.jsx("div", { className: cvaBinaryControlSuffixContainer(), "data-testid": `${dataTestId}-suffix-container`, children: suffix })) : null, description !== undefined ? (jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": `${dataTestId}-description-tooltip`, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsxRuntime.jsx("div", { className: cvaBinaryControlDescriptionTooltip(), children: jsxRuntime.jsx("span", { className: cvaBinaryControlDescription({ disabled: disabled || readOnly }), "data-testid": `${dataTestId}-description`, id: `${id}-description`, ref: descriptionRef, children: description }) }) }, `${id}-description-tooltip`)) : null] }));
|
|
4379
4379
|
};
|
|
4380
4380
|
ToggleSwitchOption.displayName = "ToggleSwitchOption";
|
|
4381
4381
|
|
|
@@ -4474,10 +4474,10 @@ UploadInput.displayName = "UploadInput";
|
|
|
4474
4474
|
* />
|
|
4475
4475
|
* ```
|
|
4476
4476
|
*/
|
|
4477
|
-
const UploadField = ({ label, id, tip, helpText, errorMessage, isInvalid, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
4477
|
+
const UploadField = ({ label, id, tip, helpText, errorMessage, isInvalid = false, className, value, "data-testid": dataTestId, ref, disabled = false, required = false, ...rest }) => {
|
|
4478
4478
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
4479
4479
|
const htmlForId = id ? id : "uploadField-" + sharedUtils.uuidv4();
|
|
4480
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
4480
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(disabled || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, required: required, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
4481
4481
|
};
|
|
4482
4482
|
UploadField.displayName = "UploadField";
|
|
4483
4483
|
|
|
@@ -4572,22 +4572,22 @@ const UrlBaseInput = ({ isInvalid = false, "data-testid": dataTestId, disabled =
|
|
|
4572
4572
|
* />
|
|
4573
4573
|
* ```
|
|
4574
4574
|
*/
|
|
4575
|
-
const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid = false, value, onBlur, ref, ...rest }) => {
|
|
4575
|
+
const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid = false, value, onBlur, ref, required = false, ...rest }) => {
|
|
4576
4576
|
const htmlForId = id ? id : "urlField-" + sharedUtils.uuidv4();
|
|
4577
4577
|
const [t] = useTranslation();
|
|
4578
4578
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
4579
4579
|
return (value?.toString() || defaultValue?.toString()) ?? "";
|
|
4580
4580
|
});
|
|
4581
4581
|
const [renderAsInvalid, setRenderAsInvalid] = react.useState(!!errorMessage || (typeof value === "string" && value !== "" && !validateUrlAddress(value)) || isInvalid);
|
|
4582
|
-
const errorType = react.useMemo(() => validateUrl(innerValue ?? "",
|
|
4582
|
+
const errorType = react.useMemo(() => validateUrl(innerValue ?? "", required), [required, innerValue]);
|
|
4583
4583
|
const error = react.useMemo(() => (errorType ? t(`urlField.error.${errorType}`) : errorMessage), [errorType, errorMessage, t]);
|
|
4584
4584
|
const handleBlur = react.useCallback(event => {
|
|
4585
4585
|
const newValue = event.target.value;
|
|
4586
4586
|
setInnerValue(newValue);
|
|
4587
|
-
setRenderAsInvalid(!!validateUrl(newValue,
|
|
4587
|
+
setRenderAsInvalid(!!validateUrl(newValue, required));
|
|
4588
4588
|
onBlur?.(event);
|
|
4589
|
-
}, [onBlur,
|
|
4590
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
4589
|
+
}, [onBlur, required]);
|
|
4590
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsxRuntime.jsx(UrlBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, required: required, value: value ?? defaultValue, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
4591
4591
|
};
|
|
4592
4592
|
UrlField.displayName = "UrlField";
|
|
4593
4593
|
|
package/index.esm.js
CHANGED
|
@@ -318,7 +318,7 @@ const cvaActionContainer = cvaMerge(["flex", "items-center"], {
|
|
|
318
318
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
319
319
|
* @returns {ReactElement} ActionButton component
|
|
320
320
|
*/
|
|
321
|
-
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, ref, }) => {
|
|
321
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium", disabled, className, onClick, ref, }) => {
|
|
322
322
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
323
323
|
const getIconName = () => {
|
|
324
324
|
switch (type) {
|
|
@@ -360,7 +360,7 @@ const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled,
|
|
|
360
360
|
return (jsx("div", { className: cvaActionContainer({ className, size }), ref: ref, children: jsx(IconButton, { className: cvaActionButton({ size: adjustedIconSize }), "data-testid": dataTestId || "testIconButtonId", disabled: disabled, icon: jsx(Icon, { name: getIconName(), size: adjustedIconSize }), onClick: buttonAction, size: "small", variant: "ghost-neutral" }) }));
|
|
361
361
|
};
|
|
362
362
|
|
|
363
|
-
const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef, tooltipLabel, }) => {
|
|
363
|
+
const GenericActionsRenderer = ({ genericAction = undefined, disabled, fieldSize = undefined, innerRef, tooltipLabel, }) => {
|
|
364
364
|
const [t] = useTranslation();
|
|
365
365
|
if (!genericAction) {
|
|
366
366
|
return null;
|
|
@@ -691,7 +691,7 @@ const cvaTextAreaBaseInput = cvaMerge([
|
|
|
691
691
|
* The TextArea is a base component, and should not be used very often.
|
|
692
692
|
* For most cases the TextAreaField is the correct component.
|
|
693
693
|
*/
|
|
694
|
-
const TextAreaBaseInput = ({ id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, "data-testid": dataTestId, isInvalid, className, ref, ...rest }) => {
|
|
694
|
+
const TextAreaBaseInput = ({ id, name, value, rows, disabled = false, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, "data-testid": dataTestId, isInvalid = false, className, ref, ...rest }) => {
|
|
695
695
|
return (jsx("textarea", { className: cvaTextAreaBaseInput({ className, resize, invalid: isInvalid, disabled }), defaultValue: defaultValue, disabled: disabled, id: id, maxLength: maxLength, name: name, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, readOnly: readOnly, ref: ref, required: required, rows: rows, tabIndex: tabIndex, value: value, ...rest, "data-testid": dataTestId, onChange: onChange }));
|
|
696
696
|
};
|
|
697
697
|
|
|
@@ -2028,7 +2028,7 @@ const CreatableSelect = (props) => {
|
|
|
2028
2028
|
* @param {LabelProps} props - The props for the Label component
|
|
2029
2029
|
* @returns {ReactElement} Label component
|
|
2030
2030
|
*/
|
|
2031
|
-
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled, isInvalid, ref, }) => {
|
|
2031
|
+
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled = false, isInvalid = false, ref, }) => {
|
|
2032
2032
|
return (jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", ref: ref, children: children }));
|
|
2033
2033
|
};
|
|
2034
2034
|
|
|
@@ -2119,9 +2119,9 @@ const FormGroup = ({ isInvalid = false, isWarning = false, helpText, helpAddon,
|
|
|
2119
2119
|
* ```
|
|
2120
2120
|
* @param {CheckboxFieldProps} props - The props for the CheckboxField component
|
|
2121
2121
|
*/
|
|
2122
|
-
const CheckboxField = ({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, ...rest }) => {
|
|
2122
|
+
const CheckboxField = ({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, disabled = false, readOnly = false, required = false, ...rest }) => {
|
|
2123
2123
|
const htmlForId = id ? id : "checkboxField-" + uuidv4();
|
|
2124
|
-
return (jsx(FormGroup, { className: "flex flex-col gap-1", "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required:
|
|
2124
|
+
return (jsx(FormGroup, { className: "flex flex-col gap-1", "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: required ? !(disabled || readOnly) : false, tip: tip, children: jsx(Checkbox, { checked: checked, className: className, "data-testid": dataTestId, disabled: disabled, id: htmlForId, label: checkboxLabel, onChange: onChange, readOnly: readOnly, ref: ref, required: required, ...rest }) }));
|
|
2125
2125
|
};
|
|
2126
2126
|
CheckboxField.displayName = "CheckboxField";
|
|
2127
2127
|
|
|
@@ -2231,7 +2231,7 @@ const isValidHEXColor = (value) => {
|
|
|
2231
2231
|
* />
|
|
2232
2232
|
* ```
|
|
2233
2233
|
*/
|
|
2234
|
-
const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize = "medium", style, disabled, readOnly, isWarning, inputClassName, ref, ...inputProps }) => {
|
|
2234
|
+
const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid = undefined, onBlur, fieldSize = "medium", style, disabled, readOnly, isWarning = false, inputClassName, ref, required = false, ...inputProps }) => {
|
|
2235
2235
|
const renderAsDisabled = Boolean(disabled);
|
|
2236
2236
|
const renderAsReadonly = Boolean(readOnly);
|
|
2237
2237
|
const htmlForId = useMemo(() => (id ? id : "colorField-" + uuidv4()), [id]);
|
|
@@ -2241,7 +2241,7 @@ const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2241
2241
|
// Internal state for color value
|
|
2242
2242
|
const [innerValue, setInnerValue] = useState(propValue ?? defaultValue ?? "");
|
|
2243
2243
|
const [hasBeenBlurred, setHasBeenBlurred] = useState(false);
|
|
2244
|
-
const errorType = useMemo(() => validateColorCode(innerValue,
|
|
2244
|
+
const errorType = useMemo(() => validateColorCode(innerValue, required), [required, innerValue]);
|
|
2245
2245
|
const error = useMemo(() => (errorType ? t(`colorField.error.${errorType}`) : errorMessage), [errorType, errorMessage, t]);
|
|
2246
2246
|
// Derive renderAsInvalid from props and internal validation
|
|
2247
2247
|
const renderAsInvalid = useMemo(() => {
|
|
@@ -2274,7 +2274,7 @@ const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2274
2274
|
setHasBeenBlurred(true);
|
|
2275
2275
|
onBlur?.(event);
|
|
2276
2276
|
}, [onBlur]);
|
|
2277
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2277
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(renderAsDisabled || renderAsReadonly) : false, tip: tip, children: jsxs("div", { className: cvaInput$1({
|
|
2278
2278
|
size: fieldSize,
|
|
2279
2279
|
disabled: renderAsDisabled,
|
|
2280
2280
|
invalid: renderAsInvalid,
|
|
@@ -2283,7 +2283,7 @@ const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2283
2283
|
className,
|
|
2284
2284
|
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsx("input", { "aria-labelledby": htmlForId + "-label", className: cvaInputColorField({ readOnly: renderAsReadonly }), "data-testid": dataTestId, defaultValue: defaultValue, disabled: renderAsDisabled, id: htmlForId, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, ref: mergedRef, type: "color", value: innerValue }), jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputElement({
|
|
2285
2285
|
className: twMerge("focus-visible:outline-hidden px-1", inputClassName),
|
|
2286
|
-
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, type: "text", value: innerValue, ...inputProps }), jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
2286
|
+
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, required: required, type: "text", value: innerValue, ...inputProps }), jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
2287
2287
|
};
|
|
2288
2288
|
ColorField.displayName = "ColorField";
|
|
2289
2289
|
|
|
@@ -2335,10 +2335,10 @@ ColorField.displayName = "ColorField";
|
|
|
2335
2335
|
* };
|
|
2336
2336
|
* ```
|
|
2337
2337
|
*/
|
|
2338
|
-
const DateField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2338
|
+
const DateField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid = undefined, className, defaultValue, "data-testid": dataTestId, ref, required = false, ...rest }) => {
|
|
2339
2339
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2340
2340
|
const htmlForId = id ? id : "dateField-" + uuidv4();
|
|
2341
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2341
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(DateBaseInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, required: required, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2342
2342
|
};
|
|
2343
2343
|
DateField.displayName = "DateField";
|
|
2344
2344
|
|
|
@@ -2617,14 +2617,14 @@ const EmailBaseInput = ({ fieldSize = "medium", disabled = false, "data-testid":
|
|
|
2617
2617
|
* />
|
|
2618
2618
|
* ```
|
|
2619
2619
|
*/
|
|
2620
|
-
const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid = false, ref, ...rest }) => {
|
|
2620
|
+
const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid = false, ref, required = false, ...rest }) => {
|
|
2621
2621
|
const htmlForId = id ? id : "emailField-" + uuidv4();
|
|
2622
2622
|
const [t] = useTranslation();
|
|
2623
2623
|
const [innerValue, setInnerValue] = useState(() => {
|
|
2624
2624
|
return (value?.toString() || defaultValue?.toString()) ?? "";
|
|
2625
2625
|
});
|
|
2626
2626
|
const [renderAsInvalid, setRenderAsInvalid] = useState(!!errorMessage || (typeof value === "string" && value !== "" && !validateEmailAddress(value)) || isInvalid);
|
|
2627
|
-
const errorType = useMemo(() => validateEmailId(innerValue ?? "",
|
|
2627
|
+
const errorType = useMemo(() => validateEmailId(innerValue ?? "", required), [required, innerValue]);
|
|
2628
2628
|
const error = useMemo(() => (errorType ? t(`emailField.error.${errorType}`) : errorMessage), [errorType, errorMessage, t]);
|
|
2629
2629
|
const handleBlur = useCallback(event => {
|
|
2630
2630
|
const newValue = event.target.value;
|
|
@@ -2638,7 +2638,7 @@ const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
2638
2638
|
onChange(event);
|
|
2639
2639
|
}
|
|
2640
2640
|
}, [onChange]);
|
|
2641
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2641
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(EmailBaseInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, onChange: handleChange, ref: ref, required: required, value: value, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2642
2642
|
};
|
|
2643
2643
|
EmailField.displayName = "EmailField";
|
|
2644
2644
|
|
|
@@ -2659,7 +2659,7 @@ const IGNORED_RS_ACTIONS = new Set(["set-value", "input-blur", "menu-close"]);
|
|
|
2659
2659
|
* @returns {ReactElement} FormFieldSelectAdapterMulti component
|
|
2660
2660
|
*/
|
|
2661
2661
|
const FormFieldSelectAdapterMulti = (props) => {
|
|
2662
|
-
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, onInputChange, ...selectProps } = props;
|
|
2662
|
+
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = undefined, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, onInputChange, ...selectProps } = props;
|
|
2663
2663
|
const [inputValue, setInputValue] = useState("");
|
|
2664
2664
|
// Hidden select for a stable DOM ref target (API parity with single adapter)
|
|
2665
2665
|
const innerRef = useRef(null);
|
|
@@ -2895,15 +2895,15 @@ const validateNumber = (number, required = false, min, max) => {
|
|
|
2895
2895
|
* };
|
|
2896
2896
|
* ```
|
|
2897
2897
|
*/
|
|
2898
|
-
const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, ...rest }) => {
|
|
2898
|
+
const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid = undefined, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, required = false, ...rest }) => {
|
|
2899
2899
|
const htmlForId = id ? id : "numberField-" + uuidv4();
|
|
2900
2900
|
const [t] = useTranslation();
|
|
2901
2901
|
const [innerValue, setInnerValue] = useState(() => {
|
|
2902
2902
|
return Number(value?.toString()) || Number(defaultValue?.toString());
|
|
2903
2903
|
});
|
|
2904
2904
|
const [renderAsInvalid, setRenderAsInvalid] = useState((isInvalid === undefined ? Boolean(errorMessage) : isInvalid) ||
|
|
2905
|
-
!!validateNumber(value?.toString(),
|
|
2906
|
-
const errorType = useMemo(() => validateNumber(innerValue,
|
|
2905
|
+
!!validateNumber(value?.toString(), required, rest.min, rest.max));
|
|
2906
|
+
const errorType = useMemo(() => validateNumber(innerValue, required, rest.min, rest.max), [innerValue, rest.max, rest.min, required]);
|
|
2907
2907
|
const error = useMemo(() => {
|
|
2908
2908
|
// for the case when a custom error message is provided
|
|
2909
2909
|
if (errorMessage) {
|
|
@@ -2923,21 +2923,21 @@ const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInva
|
|
|
2923
2923
|
const newValue = event.target.value;
|
|
2924
2924
|
setInnerValue(newValue.toString());
|
|
2925
2925
|
// for the case when a custom error message is provided
|
|
2926
|
-
if (errorMessage && !validateNumber(newValue,
|
|
2926
|
+
if (errorMessage && !validateNumber(newValue, required, rest.min, rest.max)) {
|
|
2927
2927
|
setRenderAsInvalid(Boolean(errorMessage));
|
|
2928
2928
|
}
|
|
2929
2929
|
else {
|
|
2930
|
-
setRenderAsInvalid(!!validateNumber(newValue,
|
|
2930
|
+
setRenderAsInvalid(!!validateNumber(newValue, required, rest.min, rest.max));
|
|
2931
2931
|
}
|
|
2932
2932
|
onBlur?.(event);
|
|
2933
|
-
}, [errorMessage, onBlur, rest.max, rest.min,
|
|
2933
|
+
}, [errorMessage, onBlur, rest.max, rest.min, required]);
|
|
2934
2934
|
const handleChange = useCallback((event) => {
|
|
2935
2935
|
setInnerValue(event.target.value);
|
|
2936
2936
|
if (onChange) {
|
|
2937
2937
|
onChange(event);
|
|
2938
2938
|
}
|
|
2939
2939
|
}, [onChange]);
|
|
2940
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
2940
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(NumberBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, required: required, value: value, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2941
2941
|
};
|
|
2942
2942
|
NumberField.displayName = "NumberField";
|
|
2943
2943
|
|
|
@@ -3020,7 +3020,7 @@ const cvaTag = cvaMerge([], {
|
|
|
3020
3020
|
/**
|
|
3021
3021
|
* A card version of a radio button that includes an icon, headings and a description.
|
|
3022
3022
|
*/
|
|
3023
|
-
const OptionCard = ({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, "data-testid": dataTestId, customImage, layout = "default", ref, tagProps, ...rest }) => {
|
|
3023
|
+
const OptionCard = ({ icon, heading, subheading, description, disabled = false, id, value, className, contentClassName, "data-testid": dataTestId, customImage, layout = "default", ref, tagProps, ...rest }) => {
|
|
3024
3024
|
const htmlForId = id ?? "option-card-" + uuidv4();
|
|
3025
3025
|
const subContent = useMemo(() => (jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading !== undefined && subheading !== null ? (jsx(Text, { align: "center", className: cvaOptionCardText({ type: "subheading", disabled }), type: "span", children: subheading })) : null, description !== undefined && description !== null ? (jsx(Text, { align: "center", className: cvaOptionCardText({ type: "description", disabled }), type: "span", children: description })) : null] })), [subheading, description, contentClassName, disabled]);
|
|
3026
3026
|
return (jsx(Tooltip, { disabled: layout !== "compact" || ((subheading === undefined || subheading === null) && (description === undefined || description === null)), label: subContent, mode: "light", placement: "top", children: jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsx("input", { className: cvaInput(), "data-testid": dataTestId ? `${dataTestId}-option-card` : undefined, disabled: disabled, id: htmlForId, ref: ref, type: "radio", value: value, ...rest }), jsxs("label", { className: cvaOptionCardLabel({ className, disabled, layout }), "data-testid": dataTestId ? `${dataTestId}-option-card-label` : undefined, htmlFor: htmlForId, children: [disabled && icon && !customImage
|
|
@@ -3034,7 +3034,7 @@ OptionCard.displayName = "OptionCard";
|
|
|
3034
3034
|
*
|
|
3035
3035
|
* NOTE: If shown with a label, please use the `PasswordField` component instead.
|
|
3036
3036
|
*/
|
|
3037
|
-
const PasswordBaseInput = ({ ref, fieldSize, ...rest }) => {
|
|
3037
|
+
const PasswordBaseInput = ({ ref, fieldSize = undefined, ...rest }) => {
|
|
3038
3038
|
const [showPassword, setShowPassword] = useState(false);
|
|
3039
3039
|
return (jsx(BaseInput, { ref: ref, ...rest, actions: jsx("div", { className: cvaActionContainer({ size: fieldSize }), children: jsx(IconButton, { className: cvaActionButton({ size: fieldSize }), icon: jsx(Icon, { name: showPassword ? "EyeSlash" : "Eye", size: "small" }), onClick: () => setShowPassword(prevState => !prevState), size: "small", variant: "secondary" }) }), type: showPassword ? "text" : "password" }));
|
|
3040
3040
|
};
|
|
@@ -3095,13 +3095,13 @@ const PasswordBaseInput = ({ ref, fieldSize, ...rest }) => {
|
|
|
3095
3095
|
* />
|
|
3096
3096
|
* ```
|
|
3097
3097
|
*/
|
|
3098
|
-
const PasswordField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
3098
|
+
const PasswordField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid = undefined, maxLength, onChange, className, value, "data-testid": dataTestId, ref, required = false, ...rest }) => {
|
|
3099
3099
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
3100
3100
|
const htmlFor = id ? id : "passwordField-" + uuidv4();
|
|
3101
3101
|
const handleChange = useCallback((event) => {
|
|
3102
3102
|
onChange?.(event);
|
|
3103
3103
|
}, [onChange]);
|
|
3104
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required:
|
|
3104
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(PasswordBaseInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, "data-testid": dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, required: required, value: value }) }));
|
|
3105
3105
|
};
|
|
3106
3106
|
PasswordField.displayName = "PasswordField";
|
|
3107
3107
|
|
|
@@ -3203,15 +3203,15 @@ const phoneErrorMessage = (phoneNumber, required) => {
|
|
|
3203
3203
|
* />
|
|
3204
3204
|
* ```
|
|
3205
3205
|
*/
|
|
3206
|
-
const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, ...rest }) => {
|
|
3206
|
+
const PhoneField = ({ label, id, tip, helpText, isInvalid = undefined, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, required = false, ...rest }) => {
|
|
3207
3207
|
const htmlForId = id ? id : "phoneField-" + uuidv4();
|
|
3208
3208
|
const [t] = useTranslation();
|
|
3209
3209
|
const [innerValue, setInnerValue] = useState(() => {
|
|
3210
3210
|
return (value?.toString() || defaultValue?.toString()) ?? undefined;
|
|
3211
3211
|
});
|
|
3212
3212
|
const [renderAsInvalid, setRenderAsInvalid] = useState((isInvalid === undefined ? Boolean(errorMessage) : isInvalid) ||
|
|
3213
|
-
!!phoneErrorMessage(value?.toString(),
|
|
3214
|
-
const errorType = useMemo(() => phoneErrorMessage(innerValue,
|
|
3213
|
+
!!phoneErrorMessage(value?.toString(), required));
|
|
3214
|
+
const errorType = useMemo(() => phoneErrorMessage(innerValue, required), [innerValue, required]);
|
|
3215
3215
|
const error = useMemo(() => {
|
|
3216
3216
|
// for the case when a custom error message is provided
|
|
3217
3217
|
if (errorMessage) {
|
|
@@ -3229,15 +3229,15 @@ const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value,
|
|
|
3229
3229
|
const newValue = event.target.value;
|
|
3230
3230
|
setInnerValue(newValue);
|
|
3231
3231
|
// for the case when a custom error message is provided
|
|
3232
|
-
if (errorMessage && !phoneErrorMessage(newValue.toString(),
|
|
3232
|
+
if (errorMessage && !phoneErrorMessage(newValue.toString(), required)) {
|
|
3233
3233
|
setRenderAsInvalid(Boolean(errorMessage));
|
|
3234
3234
|
}
|
|
3235
3235
|
else {
|
|
3236
|
-
setRenderAsInvalid(!!phoneErrorMessage(newValue.toString(),
|
|
3236
|
+
setRenderAsInvalid(!!phoneErrorMessage(newValue.toString(), required));
|
|
3237
3237
|
}
|
|
3238
3238
|
onBlur?.(event);
|
|
3239
|
-
}, [errorMessage, onBlur,
|
|
3240
|
-
return (jsx(FormGroup, { className: className, "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
3239
|
+
}, [errorMessage, onBlur, required]);
|
|
3240
|
+
return (jsx(FormGroup, { className: className, "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(PhoneBaseInput, { "aria-labelledby": htmlForId + "-label", "data-testid": dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: handleBlur, ref: ref, required: required, value: value, ...rest }) }));
|
|
3241
3241
|
};
|
|
3242
3242
|
PhoneField.displayName = "PhoneField";
|
|
3243
3243
|
|
|
@@ -4002,7 +4002,7 @@ const TextLengthIndicator = ({ length, maxLength }) => {
|
|
|
4002
4002
|
* @param {TextAreaFieldProps} props - The props for the TextAreaField component
|
|
4003
4003
|
* @returns {ReactElement} TextAreaField component
|
|
4004
4004
|
*/
|
|
4005
|
-
const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
4005
|
+
const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid = false, maxLength, onChange, className, value, "data-testid": dataTestId, ref, disabled = false, readOnly = false, required = false, ...rest }) => {
|
|
4006
4006
|
const [valueLength, setValueLength] = useState(value !== undefined ? `${value}`.length : 0);
|
|
4007
4007
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
4008
4008
|
const htmlForId = id ? id : "textAreaField-" + uuidv4();
|
|
@@ -4013,7 +4013,7 @@ const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isIn
|
|
|
4013
4013
|
}
|
|
4014
4014
|
}, [onChange]);
|
|
4015
4015
|
return (jsx(FormGroup, { className: twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ??
|
|
4016
|
-
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
4016
|
+
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(disabled || readOnly) : false, tip: tip, children: jsx(TextAreaBaseInput, { "aria-labelledby": htmlForId + "-label", disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, readOnly: readOnly, ref: ref, required: required, value: value, ...rest, className: "h-auto", "data-testid": dataTestId, onChange: handleChange }) }));
|
|
4017
4017
|
};
|
|
4018
4018
|
TextAreaField.displayName = "TextAreaField";
|
|
4019
4019
|
|
|
@@ -4075,7 +4075,7 @@ TextAreaField.displayName = "TextAreaField";
|
|
|
4075
4075
|
* };
|
|
4076
4076
|
* ```
|
|
4077
4077
|
*/
|
|
4078
|
-
const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning, ref, ...rest }) => {
|
|
4078
|
+
const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid = undefined, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning = false, ref, required = false, ...rest }) => {
|
|
4079
4079
|
const [valueLength, setValueLength] = useState(value !== undefined ? `${value}`.length : 0);
|
|
4080
4080
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
4081
4081
|
const htmlFor = id ? id : "textField-" + uuidv4();
|
|
@@ -4086,7 +4086,7 @@ const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvali
|
|
|
4086
4086
|
}
|
|
4087
4087
|
}, [onChange]);
|
|
4088
4088
|
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ??
|
|
4089
|
-
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, label: label, required:
|
|
4089
|
+
(typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(TextBaseInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, maxLength: maxLength, ref: ref, required: required, value: value, ...rest, className: className, "data-testid": dataTestId, onChange: handleChange }) }));
|
|
4090
4090
|
};
|
|
4091
4091
|
TextField.displayName = "TextField";
|
|
4092
4092
|
|
|
@@ -4129,7 +4129,7 @@ TextField.displayName = "TextField";
|
|
|
4129
4129
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
4130
4130
|
* @returns {ReactElement} TimeRangeField component
|
|
4131
4131
|
*/
|
|
4132
|
-
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ref, ...rest }) => {
|
|
4132
|
+
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid = undefined, errorMessage, label, tip, children, helpText, id, ref, ...rest }) => {
|
|
4133
4133
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
4134
4134
|
const htmlFor = id ? id : "timeRangeField-" + uuidv4();
|
|
4135
4135
|
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, ref: ref, tip: tip, children: jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
@@ -4261,7 +4261,7 @@ const cvaToggleSwitchThumb = cvaMerge(["block", "rounded-full", "bg-white", "asp
|
|
|
4261
4261
|
* @param {ToggleSwitchProps} props - The props for the ToggleSwitch component
|
|
4262
4262
|
* @returns {ReactElement} ToggleSwitch component
|
|
4263
4263
|
*/
|
|
4264
|
-
const ToggleSwitch = ({ onChange, onClick, preventDefaultOnClick, className, "data-testid": dataTestId = "toggle-switch", showInputFocus, toggled, size = "medium", tabIndex = 0, readOnly, disabled, ref, ...rest }) => {
|
|
4264
|
+
const ToggleSwitch = ({ onChange, onClick, preventDefaultOnClick = false, className, "data-testid": dataTestId = "toggle-switch", showInputFocus = false, toggled, size = "medium", tabIndex = 0, readOnly = false, disabled = false, ref, ...rest }) => {
|
|
4265
4265
|
const localInputRef = useRef(null);
|
|
4266
4266
|
const mergedRef = useMergeRefs([ref, localInputRef]);
|
|
4267
4267
|
// Extract data attributes to apply to wrapper
|
|
@@ -4368,13 +4368,13 @@ ToggleSwitch.displayName = "ToggleSwitch";
|
|
|
4368
4368
|
* @param {ToggleSwitchOptionProps} props - The props for the ToggleSwitchOption component
|
|
4369
4369
|
* @returns {ReactElement} ToggleSwitchOption component
|
|
4370
4370
|
*/
|
|
4371
|
-
const ToggleSwitchOption = ({ label, className, description, suffix, id, "data-testid": dataTestId = "toggle-switch-option", ref, ...rest }) => {
|
|
4371
|
+
const ToggleSwitchOption = ({ label, className, description, suffix, id, "data-testid": dataTestId = "toggle-switch-option", ref, disabled = false, readOnly = false, ...rest }) => {
|
|
4372
4372
|
const { ref: labelRef, isTextTruncated: isLabelTruncated } = useIsTextTruncated();
|
|
4373
4373
|
const { ref: descriptionRef, isTextTruncated: isDescriptionTruncated } = useIsTextTruncated();
|
|
4374
|
-
return (jsxs("label", { className: cvaBinaryControlWrapper({ className }), "data-testid": dataTestId, htmlFor: `${id}-toggle-switch`, ref: ref, tabIndex: -1, children: [jsx(ToggleSwitch, { "data-testid": `${dataTestId}-switcher`, id: `${id}-toggle-switch`, ...rest }), jsx(Tooltip, { "data-testid": `${dataTestId}-label-tooltip`, disabled: !isLabelTruncated, label: label, placement: "top", children: jsx("div", { className: cvaBinaryControlLabelTooltip(), children: jsx("span", { className: cvaLabel({
|
|
4375
|
-
disabled:
|
|
4374
|
+
return (jsxs("label", { className: cvaBinaryControlWrapper({ className }), "data-testid": dataTestId, htmlFor: `${id}-toggle-switch`, ref: ref, tabIndex: -1, children: [jsx(ToggleSwitch, { "data-testid": `${dataTestId}-switcher`, disabled: disabled, id: `${id}-toggle-switch`, readOnly: readOnly, ...rest }), jsx(Tooltip, { "data-testid": `${dataTestId}-label-tooltip`, disabled: !isLabelTruncated, label: label, placement: "top", children: jsx("div", { className: cvaBinaryControlLabelTooltip(), children: jsx("span", { className: cvaLabel({
|
|
4375
|
+
disabled: disabled || readOnly,
|
|
4376
4376
|
className: "select-none",
|
|
4377
|
-
}), "data-testid": `${dataTestId}-label`, ref: labelRef, children: label }) }) }, `${id}-label-tooltip`), suffix ? (jsx("div", { className: cvaBinaryControlSuffixContainer(), "data-testid": `${dataTestId}-suffix-container`, children: suffix })) : null, description !== undefined ? (jsx(Tooltip, { "data-testid": `${dataTestId}-description-tooltip`, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsx("div", { className: cvaBinaryControlDescriptionTooltip(), children: jsx("span", { className: cvaBinaryControlDescription({ disabled:
|
|
4377
|
+
}), "data-testid": `${dataTestId}-label`, ref: labelRef, children: label }) }) }, `${id}-label-tooltip`), suffix ? (jsx("div", { className: cvaBinaryControlSuffixContainer(), "data-testid": `${dataTestId}-suffix-container`, children: suffix })) : null, description !== undefined ? (jsx(Tooltip, { "data-testid": `${dataTestId}-description-tooltip`, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsx("div", { className: cvaBinaryControlDescriptionTooltip(), children: jsx("span", { className: cvaBinaryControlDescription({ disabled: disabled || readOnly }), "data-testid": `${dataTestId}-description`, id: `${id}-description`, ref: descriptionRef, children: description }) }) }, `${id}-description-tooltip`)) : null] }));
|
|
4378
4378
|
};
|
|
4379
4379
|
ToggleSwitchOption.displayName = "ToggleSwitchOption";
|
|
4380
4380
|
|
|
@@ -4473,10 +4473,10 @@ UploadInput.displayName = "UploadInput";
|
|
|
4473
4473
|
* />
|
|
4474
4474
|
* ```
|
|
4475
4475
|
*/
|
|
4476
|
-
const UploadField = ({ label, id, tip, helpText, errorMessage, isInvalid, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
4476
|
+
const UploadField = ({ label, id, tip, helpText, errorMessage, isInvalid = false, className, value, "data-testid": dataTestId, ref, disabled = false, required = false, ...rest }) => {
|
|
4477
4477
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
4478
4478
|
const htmlForId = id ? id : "uploadField-" + uuidv4();
|
|
4479
|
-
return (jsx(FormGroup, { "data-testid": `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
4479
|
+
return (jsx(FormGroup, { "data-testid": `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(disabled || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, required: required, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
4480
4480
|
};
|
|
4481
4481
|
UploadField.displayName = "UploadField";
|
|
4482
4482
|
|
|
@@ -4571,22 +4571,22 @@ const UrlBaseInput = ({ isInvalid = false, "data-testid": dataTestId, disabled =
|
|
|
4571
4571
|
* />
|
|
4572
4572
|
* ```
|
|
4573
4573
|
*/
|
|
4574
|
-
const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid = false, value, onBlur, ref, ...rest }) => {
|
|
4574
|
+
const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid = false, value, onBlur, ref, required = false, ...rest }) => {
|
|
4575
4575
|
const htmlForId = id ? id : "urlField-" + uuidv4();
|
|
4576
4576
|
const [t] = useTranslation();
|
|
4577
4577
|
const [innerValue, setInnerValue] = useState(() => {
|
|
4578
4578
|
return (value?.toString() || defaultValue?.toString()) ?? "";
|
|
4579
4579
|
});
|
|
4580
4580
|
const [renderAsInvalid, setRenderAsInvalid] = useState(!!errorMessage || (typeof value === "string" && value !== "" && !validateUrlAddress(value)) || isInvalid);
|
|
4581
|
-
const errorType = useMemo(() => validateUrl(innerValue ?? "",
|
|
4581
|
+
const errorType = useMemo(() => validateUrl(innerValue ?? "", required), [required, innerValue]);
|
|
4582
4582
|
const error = useMemo(() => (errorType ? t(`urlField.error.${errorType}`) : errorMessage), [errorType, errorMessage, t]);
|
|
4583
4583
|
const handleBlur = useCallback(event => {
|
|
4584
4584
|
const newValue = event.target.value;
|
|
4585
4585
|
setInnerValue(newValue);
|
|
4586
|
-
setRenderAsInvalid(!!validateUrl(newValue,
|
|
4586
|
+
setRenderAsInvalid(!!validateUrl(newValue, required));
|
|
4587
4587
|
onBlur?.(event);
|
|
4588
|
-
}, [onBlur,
|
|
4589
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required:
|
|
4588
|
+
}, [onBlur, required]);
|
|
4589
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: required ? !(Boolean(rest.disabled) || Boolean(rest.readOnly)) : false, tip: tip, children: jsx(UrlBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, required: required, value: value ?? defaultValue, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
4590
4590
|
};
|
|
4591
4591
|
UrlField.displayName = "UrlField";
|
|
4592
4592
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.4",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"zod": "^3.23.8",
|
|
15
15
|
"tailwind-merge": "^2.0.0",
|
|
16
16
|
"@trackunit/css-class-variance-utilities": "1.11.77",
|
|
17
|
-
"@trackunit/react-components": "1.20.
|
|
17
|
+
"@trackunit/react-components": "1.20.4",
|
|
18
18
|
"@trackunit/ui-icons": "1.11.73",
|
|
19
19
|
"@trackunit/shared-utils": "1.13.77",
|
|
20
20
|
"@trackunit/ui-design-tokens": "1.11.74",
|
|
21
|
-
"@trackunit/i18n-library-translation": "1.15.
|
|
21
|
+
"@trackunit/i18n-library-translation": "1.15.4",
|
|
22
22
|
"string-ts": "^2.0.0",
|
|
23
23
|
"es-toolkit": "^1.39.10"
|
|
24
24
|
},
|
|
@@ -40,7 +40,7 @@ export interface CheckboxFieldProps extends CheckboxProps, FormGroupExposedProps
|
|
|
40
40
|
* @param {CheckboxFieldProps} props - The props for the CheckboxField component
|
|
41
41
|
*/
|
|
42
42
|
export declare const CheckboxField: {
|
|
43
|
-
({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, ...rest }: CheckboxFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, disabled, readOnly, required, ...rest }: CheckboxFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
displayName: string;
|
|
45
45
|
};
|
|
46
46
|
export {};
|
|
@@ -54,7 +54,7 @@ export interface ColorFieldProps extends FormGroupExposedProps, ColorFieldBaseIn
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
export declare const ColorField: {
|
|
57
|
-
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize, style, disabled, readOnly, isWarning, inputClassName, ref, ...inputProps }: ColorFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize, style, disabled, readOnly, isWarning, inputClassName, ref, required, ...inputProps }: ColorFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
58
58
|
displayName: string;
|
|
59
59
|
};
|
|
60
60
|
export {};
|
|
@@ -56,7 +56,7 @@ export interface DateFieldProps extends DateBaseInputProps, FormGroupExposedProp
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
export declare const DateField: {
|
|
59
|
-
({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, "data-testid": dataTestId, ref, ...rest }: DateFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, "data-testid": dataTestId, ref, required, ...rest }: DateFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
60
60
|
displayName: string;
|
|
61
61
|
};
|
|
62
62
|
export {};
|
|
@@ -57,7 +57,7 @@ export interface EmailFieldProps extends FormGroupExposedProps, BaseInputProps {
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
export declare const EmailField: {
|
|
60
|
-
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid, ref, ...rest }: EmailFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid, ref, required, ...rest }: EmailFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
61
61
|
displayName: string;
|
|
62
62
|
};
|
|
63
63
|
export {};
|
|
@@ -59,7 +59,7 @@ export interface NumberFieldProps extends NumberBaseInputProps, FormGroupExposed
|
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
export declare const NumberField: {
|
|
62
|
-
({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, ...rest }: NumberFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, required, ...rest }: NumberFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
63
63
|
displayName: string;
|
|
64
64
|
};
|
|
65
65
|
export {};
|
|
@@ -64,7 +64,7 @@ export interface PasswordFieldProps extends Omit<PasswordBaseInputProps, "obfusc
|
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
export declare const PasswordField: {
|
|
67
|
-
({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }: PasswordFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, required, ...rest }: PasswordFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
68
68
|
displayName: string;
|
|
69
69
|
};
|
|
70
70
|
export {};
|
|
@@ -56,7 +56,7 @@ export interface PhoneFieldProps extends FormGroupExposedProps, PhoneBaseInputPr
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
export declare const PhoneField: {
|
|
59
|
-
({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, ...rest }: PhoneFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, required, ...rest }: PhoneFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
60
60
|
displayName: string;
|
|
61
61
|
};
|
|
62
62
|
export {};
|
|
@@ -66,7 +66,7 @@ export interface TextAreaFieldProps extends TextAreaBaseInputProps, FormGroupExp
|
|
|
66
66
|
* @returns {ReactElement} TextAreaField component
|
|
67
67
|
*/
|
|
68
68
|
export declare const TextAreaField: {
|
|
69
|
-
({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }: TextAreaFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, disabled, readOnly, required, ...rest }: TextAreaFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
70
70
|
displayName: string;
|
|
71
71
|
};
|
|
72
72
|
export {};
|
|
@@ -71,7 +71,7 @@ export interface TextFieldProps extends TextBaseInputProps, FormGroupExposedProp
|
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
export declare const TextField: {
|
|
74
|
-
({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning, ref, ...rest }: TextFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning, ref, required, ...rest }: TextFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
75
75
|
displayName: string;
|
|
76
76
|
};
|
|
77
77
|
export {};
|
|
@@ -79,6 +79,6 @@ export interface ToggleSwitchOptionProps extends Omit<ToggleSwitchProps, "ref">,
|
|
|
79
79
|
* @returns {ReactElement} ToggleSwitchOption component
|
|
80
80
|
*/
|
|
81
81
|
export declare const ToggleSwitchOption: {
|
|
82
|
-
({ label, className, description, suffix, id, "data-testid": dataTestId, ref, ...rest }: ToggleSwitchOptionProps): ReactElement;
|
|
82
|
+
({ label, className, description, suffix, id, "data-testid": dataTestId, ref, disabled, readOnly, ...rest }: ToggleSwitchOptionProps): ReactElement;
|
|
83
83
|
displayName: string;
|
|
84
84
|
};
|
|
@@ -57,7 +57,7 @@ export interface UploadFieldProps extends UploadInputProps, FormGroupExposedProp
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
export declare const UploadField: {
|
|
60
|
-
({ label, id, tip, helpText, errorMessage, isInvalid, className, value, "data-testid": dataTestId, ref, ...rest }: UploadFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
({ label, id, tip, helpText, errorMessage, isInvalid, className, value, "data-testid": dataTestId, ref, disabled, required, ...rest }: UploadFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
61
61
|
displayName: string;
|
|
62
62
|
};
|
|
63
63
|
export {};
|
|
@@ -57,7 +57,7 @@ export interface UrlFieldProps extends FormGroupExposedProps, UrlBaseInputProps
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
export declare const UrlField: {
|
|
60
|
-
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid, value, onBlur, ref, ...rest }: UrlFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid, value, onBlur, ref, required, ...rest }: UrlFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
61
61
|
displayName: string;
|
|
62
62
|
};
|
|
63
63
|
export {};
|