@trackunit/react-form-components 1.8.116 → 1.8.119
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 +92 -84
- package/index.esm.js +92 -84
- package/package.json +7 -7
- package/src/components/ActionButton/ActionButton.d.ts +1 -1
- package/src/components/BaseInput/BaseInput.d.ts +1 -1
- package/src/components/BaseInput/components/AddonRenderer.d.ts +1 -1
- package/src/components/BaseInput/components/LockReasonRenderer.d.ts +2 -2
- package/src/components/BaseInput/components/PrefixRenderer.d.ts +1 -1
- package/src/components/BaseInput/components/SuffixRenderer.d.ts +2 -2
- package/src/components/BaseSelect/SelectMenuItem/SelectMenuItem.d.ts +2 -2
- package/src/components/BaseSelect/useCustomComponents.d.ts +2 -2
- package/src/components/BaseSelect/useSelect.d.ts +1 -1
- package/src/components/Checkbox/CheckIcon.d.ts +1 -1
- package/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/src/components/CheckboxField/CheckboxField.d.ts +1 -1
- package/src/components/DateField/DateField.d.ts +1 -1
- package/src/components/DropZone/DropZone.d.ts +1 -1
- package/src/components/EmailField/EmailBaseInput/EmailBaseInput.d.ts +1 -1
- package/src/components/EmailField/EmailField.d.ts +1 -1
- package/src/components/FormGroup/FormGroup.d.ts +1 -1
- package/src/components/Label/Label.d.ts +1 -1
- package/src/components/NumberField/NumberField.d.ts +1 -1
- package/src/components/OptionCard/OptionCard.d.ts +1 -1
- package/src/components/PasswordField/PasswordField.d.ts +1 -1
- package/src/components/PhoneField/PhoneBaseInput/CountryCodeSelect.d.ts +1 -1
- package/src/components/PhoneField/PhoneBaseInput/PhoneBaseInput.d.ts +1 -1
- package/src/components/PhoneField/PhoneField.d.ts +1 -1
- package/src/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/src/components/RadioGroup/RadioItem.d.ts +1 -1
- package/src/components/Schedule/Schedule.d.ts +1 -1
- package/src/components/Search/Search.d.ts +1 -1
- package/src/components/SelectField/FormFieldSelectAdapter.d.ts +1 -1
- package/src/components/TextAreaField/TextArea/TextAreaBaseInput.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/TimeRange/TimeRange.d.ts +1 -1
- package/src/components/TimeRangeField/TimeRangeField.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/UrlBaseInput/UrlBaseInput.d.ts +1 -1
- package/src/components/UrlField/UrlField.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -275,7 +275,7 @@ const cvaInputSuffix = cssClassVarianceUtilities.cvaMerge(["flex", "justify-cent
|
|
|
275
275
|
/**
|
|
276
276
|
* Renders the addon element if provided
|
|
277
277
|
*/
|
|
278
|
-
const AddonRenderer = ({ addon, dataTestId, className, fieldSize, position }) => {
|
|
278
|
+
const AddonRenderer = ({ addon, "data-testid": dataTestId, className, fieldSize, position, }) => {
|
|
279
279
|
if (!addon) {
|
|
280
280
|
return null;
|
|
281
281
|
}
|
|
@@ -316,7 +316,7 @@ const cvaActionContainer = cssClassVarianceUtilities.cvaMerge(["flex", "items-ce
|
|
|
316
316
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
317
317
|
* @returns {ReactElement} ActionButton component
|
|
318
318
|
*/
|
|
319
|
-
const ActionButton = ({ type, value, dataTestId, size, disabled, className, onClick }) => {
|
|
319
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, }) => {
|
|
320
320
|
const [, copyToClipboard] = usehooksTs.useCopyToClipboard();
|
|
321
321
|
const getIconName = () => {
|
|
322
322
|
switch (type) {
|
|
@@ -355,7 +355,7 @@ const ActionButton = ({ type, value, dataTestId, size, disabled, className, onCl
|
|
|
355
355
|
}
|
|
356
356
|
};
|
|
357
357
|
const adjustedIconSize = size === "large" ? "medium" : size;
|
|
358
|
-
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className, size }), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: adjustedIconSize }),
|
|
358
|
+
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className, size }), 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: "secondary" }) }));
|
|
359
359
|
};
|
|
360
360
|
|
|
361
361
|
const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef, tooltipLabel, }) => {
|
|
@@ -363,7 +363,7 @@ const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef,
|
|
|
363
363
|
if (!genericAction) {
|
|
364
364
|
return null;
|
|
365
365
|
}
|
|
366
|
-
return (jsxRuntime.jsx(reactComponents.Tooltip, { label: tooltipLabel ?? t("baseInput.copyAction.toolTip"), placement: "top", children: jsxRuntime.jsx(ActionButton, {
|
|
366
|
+
return (jsxRuntime.jsx(reactComponents.Tooltip, { label: tooltipLabel ?? t("baseInput.copyAction.toolTip"), placement: "top", children: jsxRuntime.jsx(ActionButton, { "data-testid": "copy-value-button", disabled: disabled, size: fieldSize ?? undefined, type: genericAction === "edit" ? "EDIT" : "COPY", value: innerRef }) }));
|
|
367
367
|
};
|
|
368
368
|
|
|
369
369
|
/**
|
|
@@ -383,7 +383,7 @@ const InputLockReasonTooltip = ({ reasons, kind }) => {
|
|
|
383
383
|
};
|
|
384
384
|
|
|
385
385
|
// Renders a tooltip for lock reasons if the prop is an object
|
|
386
|
-
const LockReasonRenderer = ({ lockReason, dataTestId, }) => {
|
|
386
|
+
const LockReasonRenderer = ({ lockReason, "data-testid": dataTestId, }) => {
|
|
387
387
|
// Only render if lockReason is an object
|
|
388
388
|
if (typeof lockReason !== "object") {
|
|
389
389
|
return null;
|
|
@@ -392,7 +392,7 @@ const LockReasonRenderer = ({ lockReason, dataTestId, }) => {
|
|
|
392
392
|
};
|
|
393
393
|
|
|
394
394
|
// Renders the prefix element or falls back to a default prefix for certain types
|
|
395
|
-
const PrefixRenderer = react.forwardRef(({ prefix, type, dataTestId, disabled }, ref) => {
|
|
395
|
+
const PrefixRenderer = react.forwardRef(({ prefix, type, "data-testid": dataTestId, disabled }, ref) => {
|
|
396
396
|
// Default icons for specific input types
|
|
397
397
|
const defaultPrefixMap = {
|
|
398
398
|
email: jsxRuntime.jsx(reactComponents.Icon, { name: "AtSymbol", size: "small" }),
|
|
@@ -408,7 +408,7 @@ const PrefixRenderer = react.forwardRef(({ prefix, type, dataTestId, disabled },
|
|
|
408
408
|
});
|
|
409
409
|
|
|
410
410
|
// Renders the suffix element or shows an icon if invalid/warning
|
|
411
|
-
const SuffixRenderer = ({ suffix, isInvalid, isWarning, dataTestId, disabled, }) => {
|
|
411
|
+
const SuffixRenderer = ({ suffix, isInvalid, isWarning, "data-testid": dataTestId, disabled, }) => {
|
|
412
412
|
// If user provided suffix that's not identical to addonBefore, render it
|
|
413
413
|
if (suffix) {
|
|
414
414
|
return (jsxRuntime.jsx("div", { className: cvaInputSuffix({
|
|
@@ -434,7 +434,7 @@ const SuffixRenderer = ({ suffix, isInvalid, isWarning, dataTestId, disabled, })
|
|
|
434
434
|
* For specific input types make sure to use the corresponding input component.
|
|
435
435
|
* This is a base used by our other input components such as TextBaseInput, NumberBaseInput, PasswordBaseInput, etc.
|
|
436
436
|
*/
|
|
437
|
-
const BaseInput = ({ className, isInvalid = false, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, inputClassName, placeholder, isWarning = false, type, genericAction, style, ref, required = false, ...rest }) => {
|
|
437
|
+
const BaseInput = ({ className, isInvalid = false, "data-testid": dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, inputClassName, placeholder, isWarning = false, type, genericAction, style, ref, required = false, ...rest }) => {
|
|
438
438
|
// Derive final flags
|
|
439
439
|
const renderAsDisabled = Boolean(rest.disabled);
|
|
440
440
|
const renderAsReadonly = Boolean(rest.readOnly);
|
|
@@ -473,13 +473,13 @@ const BaseInput = ({ className, isInvalid = false, dataTestId, prefix, suffix, a
|
|
|
473
473
|
isWarning,
|
|
474
474
|
size: fieldSize,
|
|
475
475
|
className,
|
|
476
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "before" }) }), "data-testid": dataTestId ? `${dataTestId}-before-container` : undefined, ref: beforeContainerRef, children: [jsxRuntime.jsx(AddonRenderer, { addon: addonBefore,
|
|
476
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "before" }) }), "data-testid": dataTestId ? `${dataTestId}-before-container` : undefined, ref: beforeContainerRef, children: [jsxRuntime.jsx(AddonRenderer, { addon: addonBefore, "data-testid": dataTestId, fieldSize: fieldSize, position: "before" }), jsxRuntime.jsx(PrefixRenderer, { "data-testid": dataTestId, disabled: renderAsDisabled, prefix: prefix, type: type })] }), jsxRuntime.jsx("input", { "aria-required": required, className: cvaInputElement({
|
|
477
477
|
size: fieldSize,
|
|
478
478
|
className: cvaInputItemPlacementManager({ position: "span", className: inputClassName }),
|
|
479
479
|
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef, required: required, style: {
|
|
480
480
|
paddingLeft: `calc(var(--before-width, 0px) + ${uiDesignTokens.themeSpacing[2]})`,
|
|
481
481
|
paddingRight: `calc(var(--after-width, 0px) + ${uiDesignTokens.themeSpacing[2]})`,
|
|
482
|
-
}, type: type, ...rest, disabled: renderAsDisabled, readOnly: renderAsReadonly || nonInteractive }), jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "after" }) }), "data-testid": dataTestId ? `${dataTestId}-after-container` : undefined, ref: afterContainerRef, children: [jsxRuntime.jsx(LockReasonRenderer, {
|
|
482
|
+
}, type: type, ...rest, disabled: renderAsDisabled, readOnly: renderAsReadonly || nonInteractive }), jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "after" }) }), "data-testid": dataTestId ? `${dataTestId}-after-container` : undefined, ref: afterContainerRef, children: [jsxRuntime.jsx(LockReasonRenderer, { "data-testid": dataTestId + "-disabled", lockReason: rest.disabled }), jsxRuntime.jsx(LockReasonRenderer, { "data-testid": dataTestId + "-readonly", lockReason: Boolean(rest.readOnly) && !Boolean(rest.disabled) ? rest.readOnly : undefined }), jsxRuntime.jsx(GenericActionsRenderer, { fieldSize: fieldSize, genericAction: genericAction, innerRef: innerRef }), jsxRuntime.jsx(SuffixRenderer, { "data-testid": dataTestId, disabled: renderAsDisabled, isInvalid: isInvalid, isWarning: isWarning, suffix: suffix }), actions, jsxRuntime.jsx(AddonRenderer, { addon: addonAfter, "data-testid": dataTestId, fieldSize: fieldSize, position: "after" })] })] }));
|
|
483
483
|
};
|
|
484
484
|
BaseInput.displayName = "BaseInput";
|
|
485
485
|
|
|
@@ -502,7 +502,7 @@ const DateBaseInput = ({ min, max, defaultValue, value, ref, ...rest }) => {
|
|
|
502
502
|
: date;
|
|
503
503
|
// Chrome and Firefox need their default icon to have datepicker functionality.
|
|
504
504
|
const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
|
|
505
|
-
return (jsxRuntime.jsx(BaseInput, { defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon ? jsxRuntime.jsx(reactComponents.Icon, {
|
|
505
|
+
return (jsxRuntime.jsx(BaseInput, { defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon ? jsxRuntime.jsx(reactComponents.Icon, { "data-testid": "calendar", name: "Calendar", size: "medium", type: "solid" }) : null, type: "date", value: formatDateToInputString(value), ...rest }));
|
|
506
506
|
};
|
|
507
507
|
|
|
508
508
|
/**
|
|
@@ -610,7 +610,7 @@ const DEFAULT_COUNTRY_CODE = undefined;
|
|
|
610
610
|
* @param {string} [fieldSize="medium"] - The size of the input field.
|
|
611
611
|
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
612
612
|
*/
|
|
613
|
-
const PhoneBaseInput = ({ dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, readOnly, onFocus, onBlur, name, ref, ...rest }) => {
|
|
613
|
+
const PhoneBaseInput = ({ "data-testid": dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, readOnly, onFocus, onBlur, name, ref, ...rest }) => {
|
|
614
614
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
615
615
|
return (value?.toString() || defaultValue?.toString()) ?? "";
|
|
616
616
|
});
|
|
@@ -652,7 +652,7 @@ const PhoneBaseInput = ({ dataTestId, isInvalid, disabled = false, value, defaul
|
|
|
652
652
|
onFocus?.(event);
|
|
653
653
|
fieldIsFocused.current = true;
|
|
654
654
|
}, [onFocus]);
|
|
655
|
-
return (jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2", "data-testid": dataTestId ? `${dataTestId}-container` : null, children: jsxRuntime.jsx(BaseInput, { actions: !disableAction && innerValue && innerValue.length > 0 ? (jsxRuntime.jsx(ActionButton, {
|
|
655
|
+
return (jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2", "data-testid": dataTestId ? `${dataTestId}-container` : null, children: jsxRuntime.jsx(BaseInput, { actions: !disableAction && innerValue && innerValue.length > 0 ? (jsxRuntime.jsx(ActionButton, { "data-testid": dataTestId ? `${dataTestId}-phoneIcon` : undefined, disabled: isInvalid, size: fieldSize ?? undefined, type: "PHONE_NUMBER", value: value?.toString() || "" })) : null, "data-testid": dataTestId ? `${dataTestId}-phoneNumberInput` : undefined, disabled: disabled, fieldSize: fieldSize, id: "phoneInput-number", isInvalid: isInvalid, name: name, onBlur: handleBlur, onChange: handleChange, onFocus: handleFocus, prefix: (countryCode && countryCodeToFlagEmoji(countryCode)) || undefined, readOnly: readOnly, ref: ref, type: "tel", value: innerValue, ...rest }) }));
|
|
656
656
|
};
|
|
657
657
|
|
|
658
658
|
const cvaTextAreaBaseInput = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -691,7 +691,7 @@ const cvaTextAreaBaseInput = cssClassVarianceUtilities.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, dataTestId, isInvalid, className, ref, ...rest }) => {
|
|
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 }) => {
|
|
695
695
|
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 }));
|
|
696
696
|
};
|
|
697
697
|
|
|
@@ -866,7 +866,7 @@ const cvaLabel = cssClassVarianceUtilities.cvaMerge([
|
|
|
866
866
|
* @param {CheckIconProps} props - The props for the CheckIcon component
|
|
867
867
|
* @returns {ReactElement} CheckIcon component
|
|
868
868
|
*/
|
|
869
|
-
const CheckIcon = ({ className, dataTestId }) => {
|
|
869
|
+
const CheckIcon = ({ className, "data-testid": dataTestId }) => {
|
|
870
870
|
return (jsxRuntime.jsx("svg", { className: className, "data-testid": dataTestId, fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 10 10", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "m2 5.5 2 2L8.5 3", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
871
871
|
};
|
|
872
872
|
|
|
@@ -991,7 +991,7 @@ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", { className:
|
|
|
991
991
|
* @augments props from [React.InputHTMLAttributes](https://reactjs.org/docs/dom-elements.html#input)
|
|
992
992
|
* @param {CheckboxProps} props - The props for the Checkbox component
|
|
993
993
|
*/
|
|
994
|
-
const Checkbox = ({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, stopPropagation, ref, ...rest }) => {
|
|
994
|
+
const Checkbox = ({ className, "data-testid": dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, stopPropagation, ref, ...rest }) => {
|
|
995
995
|
const icon = indeterminate ? (jsxRuntime.jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsxRuntime.jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
996
996
|
const internalRef = react.useRef(null);
|
|
997
997
|
const { isTextTruncated: isLabelCutOff, ref: labelRef } = reactComponents.useIsTextTruncated();
|
|
@@ -1030,8 +1030,8 @@ Checkbox.displayName = "Checkbox";
|
|
|
1030
1030
|
* @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
|
|
1031
1031
|
* @returns {ReactElement} SingleSelectMenuItem
|
|
1032
1032
|
*/
|
|
1033
|
-
const SingleSelectMenuItem = ({ label, icon, onClick, selected, focused, dataTestId, disabled, optionLabelDescription, optionPrefix, fieldSize, }) => {
|
|
1034
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, {
|
|
1033
|
+
const SingleSelectMenuItem = ({ label, icon, onClick, selected, focused, "data-testid": dataTestId, disabled, optionLabelDescription, optionPrefix, fieldSize, }) => {
|
|
1034
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, focused: focused, label: label, onClick: onClick, optionLabelDescription: optionLabelDescription, optionPrefix: react.isValidElement(optionPrefix)
|
|
1035
1035
|
? react.cloneElement(optionPrefix, {
|
|
1036
1036
|
className: "mr-1 flex items-center",
|
|
1037
1037
|
size: "medium",
|
|
@@ -1044,8 +1044,8 @@ const SingleSelectMenuItem = ({ label, icon, onClick, selected, focused, dataTes
|
|
|
1044
1044
|
* @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
|
|
1045
1045
|
* @returns {ReactElement} multi select menu item
|
|
1046
1046
|
*/
|
|
1047
|
-
const MultiSelectMenuItem = ({ label, onClick, selected, focused, dataTestId, disabled, optionLabelDescription, optionPrefix, fieldSize, }) => {
|
|
1048
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, {
|
|
1047
|
+
const MultiSelectMenuItem = ({ label, onClick, selected, focused, "data-testid": dataTestId, disabled, optionLabelDescription, optionPrefix, fieldSize, }) => {
|
|
1048
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, focused: focused, label: label, onClick: e => {
|
|
1049
1049
|
e.stopPropagation();
|
|
1050
1050
|
onClick && onClick(e);
|
|
1051
1051
|
}, optionLabelDescription: optionLabelDescription, optionPrefix: react.isValidElement(optionPrefix)
|
|
@@ -1132,7 +1132,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 6, postFix, preFix, d
|
|
|
1132
1132
|
...acc,
|
|
1133
1133
|
elements: [
|
|
1134
1134
|
...acc.elements,
|
|
1135
|
-
jsxRuntime.jsx(TagWithWidth, { className: "inline-flex shrink-0", color: item.disabled ? "neutral" : "white",
|
|
1135
|
+
jsxRuntime.jsx(TagWithWidth, { className: "inline-flex shrink-0", color: item.disabled ? "neutral" : "white", "data-testid": `${item.text}-tag`, disabled: disabled, icon: item.Icon, onClose: e => {
|
|
1136
1136
|
e.stopPropagation();
|
|
1137
1137
|
item.onClick();
|
|
1138
1138
|
}, onWidthKnown: onWidthKnownHandler, children: item.text }, item.text + index),
|
|
@@ -1166,7 +1166,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 6, postFix, preFix, d
|
|
|
1166
1166
|
* @param {ReactNode} prefix a prefix element
|
|
1167
1167
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
1168
1168
|
*/
|
|
1169
|
-
const useCustomComponents = ({ componentsProps, disabled, readOnly, setMenuIsEnabled, dataTestId, maxSelectedDisplayCount, prefix, hasError, fieldSize, getOptionLabelDescription, getOptionPrefix, }) => {
|
|
1169
|
+
const useCustomComponents = ({ componentsProps, disabled, readOnly, setMenuIsEnabled, "data-testid": dataTestId, maxSelectedDisplayCount, prefix, hasError, fieldSize, getOptionLabelDescription, getOptionPrefix, }) => {
|
|
1170
1170
|
const [t] = useTranslation();
|
|
1171
1171
|
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
1172
1172
|
const customComponents = react.useMemo(() => {
|
|
@@ -1201,13 +1201,13 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, setMenuIsEna
|
|
|
1201
1201
|
})
|
|
1202
1202
|
: [], postFix: searchInput, preFix: placeholderElement ? jsxRuntime.jsx("span", { className: "absolute", children: placeholderElement }) : null, width: "100%" })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [tags
|
|
1203
1203
|
? tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
|
|
1204
|
-
return (jsxRuntime.jsx(reactComponents.Tag, { className: "inline-flex shrink-0", color: disabled ? "unknown" : "primary",
|
|
1204
|
+
return (jsxRuntime.jsx(reactComponents.Tag, { className: "inline-flex shrink-0", color: disabled ? "unknown" : "primary", "data-testid": tagProps.children ? `${tagProps.children.toString()}-tag` : undefined, onClose: e => {
|
|
1205
1205
|
e.stopPropagation();
|
|
1206
1206
|
setMenuIsEnabled(false);
|
|
1207
1207
|
tagProps.removeProps.onClick && tagProps.removeProps.onClick(e);
|
|
1208
1208
|
}, children: tagProps.children }, tagProps.children?.toString()));
|
|
1209
1209
|
})
|
|
1210
|
-
: null, tags && tags.length > maxSelectedDisplayCount ? (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral",
|
|
1210
|
+
: null, tags && tags.length > maxSelectedDisplayCount ? (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral", "data-testid": "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })) : null, searchInput, placeholderElement] })) }));
|
|
1211
1211
|
}
|
|
1212
1212
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ReactSelect.components.ValueContainer, { ...props, isDisabled: props.selectProps.isDisabled, children: props.children }) }));
|
|
1213
1213
|
},
|
|
@@ -1272,7 +1272,7 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, setMenuIsEna
|
|
|
1272
1272
|
...props.innerProps,
|
|
1273
1273
|
role: "option",
|
|
1274
1274
|
onClick: () => { },
|
|
1275
|
-
}, children: props.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, { ...componentProps,
|
|
1275
|
+
}, children: props.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, { ...componentProps, "data-testid": typeof props.label === "string" ? props.label : undefined, disabled: disabled, fieldSize: fieldSize, optionLabelDescription: getOptionLabelDescription?.(props.data), optionPrefix: getOptionPrefix?.(props.data) })) : (jsxRuntime.jsx(SingleSelectMenuItem, { ...componentProps, "data-testid": typeof props.label === "string" ? props.label : undefined, disabled: disabled || props.isDisabled, fieldSize: fieldSize, optionLabelDescription: getOptionLabelDescription?.(props.data), optionPrefix: getOptionPrefix?.(props.data) })) }));
|
|
1276
1276
|
},
|
|
1277
1277
|
...componentsProps,
|
|
1278
1278
|
};
|
|
@@ -1401,7 +1401,7 @@ const useCustomStyles = ({ refContainer, maxSelectedDisplayCount, styles, disabl
|
|
|
1401
1401
|
* @param {SelectProps} props - The props for the Select component
|
|
1402
1402
|
* @returns {UseSelectProps} Select component
|
|
1403
1403
|
*/
|
|
1404
|
-
const useSelect = ({ id, className, dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix = "", onMenuOpen, onMenuClose, maxSelectedDisplayCount = undefined, isClearable = false, isSearchable = true, onMenuScrollToBottom, styles, filterOption, onInputChange, getOptionLabelDescription, getOptionPrefix, fieldSize = "medium", ...props }) => {
|
|
1404
|
+
const useSelect = ({ id, className, "data-testid": dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix = "", onMenuOpen, onMenuClose, maxSelectedDisplayCount = undefined, isClearable = false, isSearchable = true, onMenuScrollToBottom, styles, filterOption, onInputChange, getOptionLabelDescription, getOptionPrefix, fieldSize = "medium", ...props }) => {
|
|
1405
1405
|
const refContainer = react.useRef(document.createElement("div"));
|
|
1406
1406
|
const { customStyles } = useCustomStyles({
|
|
1407
1407
|
refContainer,
|
|
@@ -1417,7 +1417,7 @@ const useSelect = ({ id, className, dataTestId = "select", prefix, async, maxMen
|
|
|
1417
1417
|
disabled: Boolean(disabled),
|
|
1418
1418
|
readOnly: Boolean(props.readOnly),
|
|
1419
1419
|
setMenuIsEnabled,
|
|
1420
|
-
dataTestId,
|
|
1420
|
+
"data-testid": dataTestId,
|
|
1421
1421
|
maxSelectedDisplayCount,
|
|
1422
1422
|
prefix,
|
|
1423
1423
|
hasError,
|
|
@@ -1459,7 +1459,7 @@ const ReactSyncSelect = ReactSelect.default || ReactSelect;
|
|
|
1459
1459
|
* @returns {ReactElement} Select component
|
|
1460
1460
|
*/
|
|
1461
1461
|
const BaseSelect = (props) => {
|
|
1462
|
-
const { id, dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, menuPosition = "absolute", value, options, onChange, isLoading, classNamePrefix = "select", onMenuScrollToBottom, onInputChange, isSearchable, isClearable = false, readOnly, fieldSize = "medium", openMenuOnClick = !disabled, openMenuOnFocus = false, hideSelectedOptions = false, } = props;
|
|
1462
|
+
const { id, "data-testid": dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, menuPosition = "absolute", value, options, onChange, isLoading, classNamePrefix = "select", onMenuScrollToBottom, onInputChange, isSearchable, isClearable = false, readOnly, fieldSize = "medium", openMenuOnClick = !disabled, openMenuOnFocus = false, hideSelectedOptions = false, } = props;
|
|
1463
1463
|
const { refContainer, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler } = useSelect(props);
|
|
1464
1464
|
const reactSelectProps = react.useMemo(() => ({
|
|
1465
1465
|
value,
|
|
@@ -1534,7 +1534,7 @@ BaseSelect.displayName = "BaseSelect";
|
|
|
1534
1534
|
* @returns {ReactElement} CreatableSelect component
|
|
1535
1535
|
*/
|
|
1536
1536
|
const CreatableSelect = (props) => {
|
|
1537
|
-
const { id, dataTestId = "creatableSelect", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, value, options, onChange, isLoading, classNamePrefix = "creatableSelect", onMenuScrollToBottom, onInputChange, isSearchable, isClearable = false, readOnly, openMenuOnClick = !disabled, openMenuOnFocus = !disabled, allowCreateWhileLoading, onCreateOption, } = props;
|
|
1537
|
+
const { id, "data-testid": dataTestId = "creatableSelect", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, value, options, onChange, isLoading, classNamePrefix = "creatableSelect", onMenuScrollToBottom, onInputChange, isSearchable, isClearable = false, readOnly, openMenuOnClick = !disabled, openMenuOnFocus = !disabled, allowCreateWhileLoading, onCreateOption, } = props;
|
|
1538
1538
|
const { refContainer, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler } = useSelect(props);
|
|
1539
1539
|
const reactCreatableSelectProps = react.useMemo(() => ({
|
|
1540
1540
|
value,
|
|
@@ -1603,7 +1603,7 @@ CreatableSelect.displayName = "CreatableSelect";
|
|
|
1603
1603
|
* @param {LabelProps} props - The props for the Label component
|
|
1604
1604
|
* @returns {ReactElement} Label component
|
|
1605
1605
|
*/
|
|
1606
|
-
const Label = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
|
|
1606
|
+
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled, isInvalid, }) => {
|
|
1607
1607
|
return (jsxRuntime.jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", children: children }));
|
|
1608
1608
|
};
|
|
1609
1609
|
|
|
@@ -1637,13 +1637,13 @@ const cvaHelpAddon = cssClassVarianceUtilities.cvaMerge(["ml-auto"]);
|
|
|
1637
1637
|
* @param {FormGroupProps} props - The props for the FormGroup component
|
|
1638
1638
|
* @returns {ReactElement} FormGroup component
|
|
1639
1639
|
*/
|
|
1640
|
-
const FormGroup = ({ isInvalid, isWarning, helpText, helpAddon, tip, className, dataTestId, label, htmlFor, children, required = false, }) => {
|
|
1640
|
+
const FormGroup = ({ isInvalid, isWarning, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required = false, }) => {
|
|
1641
1641
|
const [t] = useTranslation();
|
|
1642
1642
|
const validationStateIcon = react.useMemo(() => {
|
|
1643
1643
|
const color = isInvalid ? "danger" : isWarning ? "warning" : null;
|
|
1644
1644
|
return color ? jsxRuntime.jsx(reactComponents.Icon, { color: color, name: "ExclamationTriangle", size: "small" }) : null;
|
|
1645
1645
|
}, [isInvalid, isWarning]);
|
|
1646
|
-
return (jsxRuntime.jsxs("div", { className: cvaFormGroup({ className }), "data-testid": dataTestId, children: [label ? (jsxRuntime.jsxs("div", { className: cvaFormGroupContainerBefore(), children: [jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Label, { className: "component-formGroup-font",
|
|
1646
|
+
return (jsxRuntime.jsxs("div", { className: cvaFormGroup({ className }), "data-testid": dataTestId, children: [label ? (jsxRuntime.jsxs("div", { className: cvaFormGroupContainerBefore(), children: [jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Label, { className: "component-formGroup-font", "data-testid": dataTestId ? `${dataTestId}-label` : undefined, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required ? (jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": "required-asterisk", label: t("field.required.asterisk.tooltip"), children: "*" })) : null] }), tip ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: "ml-1", "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, label: tip, placement: "bottom" })) : null] })) : null, children, helpText || helpAddon ? (jsxRuntime.jsxs("div", { className: cvaFormGroupContainerAfter({ invalid: isInvalid, isWarning: isWarning }), children: [helpText ? (jsxRuntime.jsxs("div", { className: "flex gap-1", children: [validationStateIcon, jsxRuntime.jsx("span", { "data-testid": dataTestId ? `${dataTestId}-helpText` : undefined, children: helpText })] })) : undefined, helpAddon ? (jsxRuntime.jsx("span", { className: cvaHelpAddon(), "data-testid": dataTestId ? `${dataTestId}-helpAddon` : null, children: helpAddon })) : null] })) : null] }));
|
|
1647
1647
|
};
|
|
1648
1648
|
|
|
1649
1649
|
/**
|
|
@@ -1651,9 +1651,9 @@ const FormGroup = ({ isInvalid, isWarning, helpText, helpAddon, tip, className,
|
|
|
1651
1651
|
*
|
|
1652
1652
|
* _**Do use**_ the CheckboxField for boolean input.
|
|
1653
1653
|
*/
|
|
1654
|
-
const CheckboxField = ({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange, ref, ...rest }) => {
|
|
1654
|
+
const CheckboxField = ({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, "data-testid": dataTestId, checkboxLabel, onChange, ref, ...rest }) => {
|
|
1655
1655
|
const htmlForId = id ? id : "checkboxField-" + sharedUtils.uuidv4();
|
|
1656
|
-
return (jsxRuntime.jsx(FormGroup, { className: "flex flex-col gap-1",
|
|
1656
|
+
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: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(Checkbox, { checked: checked, className: className, "data-testid": dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref, ...rest }) }));
|
|
1657
1657
|
};
|
|
1658
1658
|
CheckboxField.displayName = "CheckboxField";
|
|
1659
1659
|
|
|
@@ -1731,7 +1731,7 @@ const isValidHEXColor = (value) => {
|
|
|
1731
1731
|
* ColorField validates that user enters a valid color address.
|
|
1732
1732
|
*
|
|
1733
1733
|
*/
|
|
1734
|
-
const ColorField = react.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false, onBlur, fieldSize = "medium", ...rest }, ref) => {
|
|
1734
|
+
const ColorField = react.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid = false, onBlur, fieldSize = "medium", ...rest }, ref) => {
|
|
1735
1735
|
const renderAsDisabled = Boolean(rest.disabled);
|
|
1736
1736
|
const renderAsReadonly = Boolean(rest.readOnly);
|
|
1737
1737
|
const htmlForId = react.useMemo(() => (id ? id : "colorField-" + sharedUtils.uuidv4()), [id]);
|
|
@@ -1756,7 +1756,7 @@ const ColorField = react.forwardRef(({ label, id, tip, helpText, errorMessage, h
|
|
|
1756
1756
|
setRenderAsInvalid(!!errorType);
|
|
1757
1757
|
onBlur?.(event);
|
|
1758
1758
|
}, [errorType, onBlur]);
|
|
1759
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1759
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(renderAsDisabled || renderAsReadonly) : false, tip: tip, children: jsxRuntime.jsxs("div", { className: cvaInput$1({
|
|
1760
1760
|
size: fieldSize,
|
|
1761
1761
|
disabled: renderAsDisabled,
|
|
1762
1762
|
invalid: renderAsInvalid,
|
|
@@ -1775,10 +1775,10 @@ ColorField.displayName = "ColorField";
|
|
|
1775
1775
|
*
|
|
1776
1776
|
* _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
|
|
1777
1777
|
*/
|
|
1778
|
-
const DateField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId, ref, ...rest }) => {
|
|
1778
|
+
const DateField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, "data-testid": dataTestId, ref, ...rest }) => {
|
|
1779
1779
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1780
1780
|
const htmlForId = id ? id : "dateField-" + sharedUtils.uuidv4();
|
|
1781
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1781
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(DateBaseInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
1782
1782
|
};
|
|
1783
1783
|
DateField.displayName = "DateField";
|
|
1784
1784
|
|
|
@@ -1846,7 +1846,7 @@ const DropZoneDefaultLabel = () => (jsxRuntime.jsx(Trans, { components: {
|
|
|
1846
1846
|
* @param {DropZoneProps} props - The props for the DropZone component
|
|
1847
1847
|
* @returns {ReactElement} DropZone component
|
|
1848
1848
|
*/
|
|
1849
|
-
const DropZone = ({ className, dataTestId, filesSelected, label = jsxRuntime.jsx(DropZoneDefaultLabel, {}), size = "large", isInvalid = false, disabled = false, accept, multiple = false, ...rest }) => {
|
|
1849
|
+
const DropZone = ({ className, "data-testid": dataTestId, filesSelected, label = jsxRuntime.jsx(DropZoneDefaultLabel, {}), size = "large", isInvalid = false, disabled = false, accept, multiple = false, ...rest }) => {
|
|
1850
1850
|
const [dragActive, setDragActive] = react.useState(false);
|
|
1851
1851
|
const [fileDropped, setFileDropped] = react.useState(false);
|
|
1852
1852
|
const [t] = useTranslation();
|
|
@@ -1939,7 +1939,7 @@ const validateEmailId = (emailId, required) => {
|
|
|
1939
1939
|
* A reference to the input element is provided as the `ref` prop.
|
|
1940
1940
|
* For specific input types make sure to use the corresponding input component.
|
|
1941
1941
|
*/
|
|
1942
|
-
const EmailBaseInput = ({ fieldSize = "medium", disabled = false, dataTestId, isInvalid = false, onChange, disableAction = false, ref, ...rest }) => {
|
|
1942
|
+
const EmailBaseInput = ({ fieldSize = "medium", disabled = false, "data-testid": dataTestId, isInvalid = false, onChange, disableAction = false, ref, ...rest }) => {
|
|
1943
1943
|
const [email, setEmail] = react.useState(rest.value?.toString() || rest.defaultValue?.toString());
|
|
1944
1944
|
const sendEmail = () => {
|
|
1945
1945
|
return window.open(`mailto:${email}`);
|
|
@@ -1950,7 +1950,7 @@ const EmailBaseInput = ({ fieldSize = "medium", disabled = false, dataTestId, is
|
|
|
1950
1950
|
setEmail(newValue);
|
|
1951
1951
|
}, [onChange]);
|
|
1952
1952
|
const renderAsInvalid = (email && !validateEmailAddress(email)) || isInvalid;
|
|
1953
|
-
return (jsxRuntime.jsx(BaseInput, { actions: email && email.length > 0 ? (jsxRuntime.jsx(ActionButton, {
|
|
1953
|
+
return (jsxRuntime.jsx(BaseInput, { actions: email && email.length > 0 ? (jsxRuntime.jsx(ActionButton, { "data-testid": dataTestId ? `${dataTestId}-emailIcon` : undefined, disabled: disableAction || isInvalid, onClick: sendEmail, size: fieldSize ?? undefined, type: "EMAIL", value: email })) : null, "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, isInvalid: renderAsInvalid, onChange: handleChange, placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email", ...rest }));
|
|
1954
1954
|
};
|
|
1955
1955
|
|
|
1956
1956
|
/**
|
|
@@ -1958,7 +1958,7 @@ const EmailBaseInput = ({ fieldSize = "medium", disabled = false, dataTestId, is
|
|
|
1958
1958
|
* EmailField validates that user enters a valid email address.
|
|
1959
1959
|
*
|
|
1960
1960
|
*/
|
|
1961
|
-
const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, onChange, onBlur, isInvalid = false, ref, ...rest }) => {
|
|
1961
|
+
const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value, onChange, onBlur, isInvalid = false, ref, ...rest }) => {
|
|
1962
1962
|
const htmlForId = id ? id : "emailField-" + sharedUtils.uuidv4();
|
|
1963
1963
|
const [t] = useTranslation();
|
|
1964
1964
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
@@ -1979,7 +1979,7 @@ const EmailField = ({ label, id, tip, helpText, errorMessage, helpAddon, classNa
|
|
|
1979
1979
|
onChange(event);
|
|
1980
1980
|
}
|
|
1981
1981
|
}, [onChange]);
|
|
1982
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1982
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(EmailBaseInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
1983
1983
|
};
|
|
1984
1984
|
EmailField.displayName = "EmailField";
|
|
1985
1985
|
|
|
@@ -1996,7 +1996,7 @@ function isWritableRef(r) {
|
|
|
1996
1996
|
* - passes through all remaining BaseSelect props with isMulti=true
|
|
1997
1997
|
*/
|
|
1998
1998
|
const FormFieldSelectAdapterMulti = (props) => {
|
|
1999
|
-
const { className, dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ref, ...selectProps } = props;
|
|
1999
|
+
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ref, ...selectProps } = props;
|
|
2000
2000
|
// Hidden select for a stable DOM ref target (API parity with single adapter)
|
|
2001
2001
|
const innerRef = react.useRef(null);
|
|
2002
2002
|
// Bridge external ref (supports both callback and object refs)
|
|
@@ -2029,7 +2029,7 @@ const FormFieldSelectAdapterMulti = (props) => {
|
|
|
2029
2029
|
defaultValue,
|
|
2030
2030
|
onChange: next => onChange?.(next),
|
|
2031
2031
|
};
|
|
2032
|
-
return (jsxRuntime.jsxs(FormGroup, { className: className,
|
|
2032
|
+
return (jsxRuntime.jsxs(FormGroup, { className: className, "data-testid": dataTestId, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: controlId, isInvalid: renderAsInvalid, label: label, required: "required" in selectProps && selectProps.required
|
|
2033
2033
|
? !(("disabled" in selectProps && Boolean(selectProps.disabled)) ||
|
|
2034
2034
|
("readOnly" in selectProps && Boolean(selectProps.readOnly)))
|
|
2035
2035
|
: false, tip: tip, children: [jsxRuntime.jsx("select", { "aria-hidden": "true", defaultValue: "", hidden: true, name: name, ref: innerRef }), typeof getOptionValue === "function" &&
|
|
@@ -2107,7 +2107,7 @@ const validateNumber = (number, required = false, min, max) => {
|
|
|
2107
2107
|
*
|
|
2108
2108
|
* _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
|
|
2109
2109
|
*/
|
|
2110
|
-
const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId, defaultValue, onBlur, onChange, ref, ...rest }) => {
|
|
2110
|
+
const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, "data-testid": dataTestId, defaultValue, onBlur, onChange, ref, ...rest }) => {
|
|
2111
2111
|
const htmlForId = id ? id : "numberField-" + sharedUtils.uuidv4();
|
|
2112
2112
|
const [t] = useTranslation();
|
|
2113
2113
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
@@ -2149,7 +2149,7 @@ const NumberField = ({ label, id, tip, helpText, errorMessage, helpAddon, isInva
|
|
|
2149
2149
|
onChange(event);
|
|
2150
2150
|
}
|
|
2151
2151
|
}, [onChange]);
|
|
2152
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2152
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && error) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(NumberBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, onBlur: handleBlur, onChange: handleChange, ref: ref, value: value, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
2153
2153
|
};
|
|
2154
2154
|
NumberField.displayName = "NumberField";
|
|
2155
2155
|
|
|
@@ -2232,7 +2232,7 @@ const cvaTag = cssClassVarianceUtilities.cvaMerge([], {
|
|
|
2232
2232
|
/**
|
|
2233
2233
|
* A card version of a radio button that includes an icon, headings and a description.
|
|
2234
2234
|
*/
|
|
2235
|
-
const OptionCard = ({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, dataTestId, customImage, layout = "default", ref, tagProps, ...rest }) => {
|
|
2235
|
+
const OptionCard = ({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, "data-testid": dataTestId, customImage, layout = "default", ref, tagProps, ...rest }) => {
|
|
2236
2236
|
const htmlForId = id ?? "option-card-" + sharedUtils.uuidv4();
|
|
2237
2237
|
const subContent = react.useMemo(() => (jsxRuntime.jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", className: cvaOptionCardText({ type: "subheading", disabled }), type: "span", children: subheading })) : null, description ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", className: cvaOptionCardText({ type: "description", disabled }), type: "span", children: description })) : null] })), [subheading, description, contentClassName, disabled]);
|
|
2238
2238
|
return (jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-fit", disabled: layout !== "compact" || (!subheading && !description), label: subContent, mode: "light", placement: "top", children: jsxRuntime.jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsxRuntime.jsx("input", { className: cvaInput(), "data-testid": `${dataTestId}-option-card`, disabled: disabled, id: htmlForId, ref: ref, type: "radio", value: value, ...rest }), jsxRuntime.jsxs("label", { className: cvaOptionCardLabel({ className, disabled, layout }), "data-testid": `${dataTestId}-option-card-label`, htmlFor: htmlForId, children: [disabled && icon && !customImage
|
|
@@ -2258,13 +2258,13 @@ const PasswordBaseInput = ({ ref, fieldSize, ...rest }) => {
|
|
|
2258
2258
|
*
|
|
2259
2259
|
* _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
|
|
2260
2260
|
*/
|
|
2261
|
-
const PasswordField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ref, ...rest }) => {
|
|
2261
|
+
const PasswordField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2262
2262
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2263
2263
|
const htmlFor = id ? id : "passwordField-" + sharedUtils.uuidv4();
|
|
2264
2264
|
const handleChange = react.useCallback((event) => {
|
|
2265
2265
|
onChange?.(event);
|
|
2266
2266
|
}, [onChange]);
|
|
2267
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2267
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(PasswordBaseInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, "data-testid": dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value }) }));
|
|
2268
2268
|
};
|
|
2269
2269
|
PasswordField.displayName = "PasswordField";
|
|
2270
2270
|
|
|
@@ -2333,7 +2333,7 @@ const phoneErrorMessage = (phoneNumber, required) => {
|
|
|
2333
2333
|
* @param {string} [fieldSize="medium"] - The size of the input field.
|
|
2334
2334
|
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
2335
2335
|
*/
|
|
2336
|
-
const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId, name, onBlur, ref, ...rest }) => {
|
|
2336
|
+
const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, "data-testid": dataTestId, name, onBlur, ref, ...rest }) => {
|
|
2337
2337
|
const htmlForId = id ? id : "phoneField-" + sharedUtils.uuidv4();
|
|
2338
2338
|
const [t] = useTranslation();
|
|
2339
2339
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
@@ -2367,7 +2367,7 @@ const PhoneField = ({ label, id, tip, helpText, isInvalid, errorMessage, value,
|
|
|
2367
2367
|
}
|
|
2368
2368
|
onBlur?.(event);
|
|
2369
2369
|
}, [errorMessage, onBlur, rest.required]);
|
|
2370
|
-
return (jsxRuntime.jsx(FormGroup, { className: className,
|
|
2370
|
+
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: rest.required ? !(rest.disabled || 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, value: value, ...rest }) }));
|
|
2371
2371
|
};
|
|
2372
2372
|
PhoneField.displayName = "PhoneField";
|
|
2373
2373
|
|
|
@@ -2465,8 +2465,8 @@ const RadioGroupContext = react.createContext(null);
|
|
|
2465
2465
|
* @param {RadioGroupProps} props - The props for the RadioGroup component
|
|
2466
2466
|
* @returns {ReactElement} RadioGroup component
|
|
2467
2467
|
*/
|
|
2468
|
-
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
|
|
2469
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2468
|
+
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, "data-testid": dataTestId, isInvalid, }) => {
|
|
2469
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, label: label, children: jsxRuntime.jsx("div", { className: cvaRadioGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, children: jsxRuntime.jsx(RadioGroupContext.Provider, { value: {
|
|
2470
2470
|
id,
|
|
2471
2471
|
value,
|
|
2472
2472
|
name: name || id,
|
|
@@ -2483,7 +2483,7 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
2483
2483
|
* @param {RadioItemProps} props - The props for the RadioItem component
|
|
2484
2484
|
* @returns {ReactElement} RadioItem component
|
|
2485
2485
|
*/
|
|
2486
|
-
const RadioItem = ({ label, value, dataTestId, className, description, suffix, ...rest }) => {
|
|
2486
|
+
const RadioItem = ({ label, value, "data-testid": dataTestId, className, description, suffix, ...rest }) => {
|
|
2487
2487
|
const groupCtx = react.useContext(RadioGroupContext);
|
|
2488
2488
|
const isChecked = groupCtx?.value === value;
|
|
2489
2489
|
const { ref: labelRef, isTextTruncated: isLabelTruncated } = reactComponents.useIsTextTruncated();
|
|
@@ -2497,10 +2497,10 @@ const RadioItem = ({ label, value, dataTestId, className, description, suffix, .
|
|
|
2497
2497
|
checked: isChecked,
|
|
2498
2498
|
disabled: groupCtx?.disabled,
|
|
2499
2499
|
invalid: groupCtx?.isInvalid,
|
|
2500
|
-
}), "data-testid": dataTestId, id: inputId, onChange: groupCtx?.onChange, type: "radio", value: value, ...rest }), hasLabel ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlLabelTooltip(),
|
|
2500
|
+
}), "data-testid": dataTestId, id: inputId, onChange: groupCtx?.onChange, type: "radio", value: value, ...rest }), hasLabel ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlLabelTooltip(), "data-testid": dataTestId ? `${dataTestId}-Label-Tooltip` : undefined, disabled: !isLabelTruncated, label: label, placement: "top", children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
2501
2501
|
invalid: groupCtx?.isInvalid,
|
|
2502
2502
|
disabled: groupCtx?.disabled,
|
|
2503
|
-
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, ref: labelRef, children: label }) }, "tooltip-" + rest.name)) : null, suffix ? (jsxRuntime.jsx("div", { className: cvaBinaryControlSuffixContainer(), "data-testid": dataTestId ? `${dataTestId}-suffix-container` : undefined, children: suffix })) : null, description ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlDescriptionTooltip(),
|
|
2503
|
+
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, ref: labelRef, children: label }) }, "tooltip-" + rest.name)) : null, suffix ? (jsxRuntime.jsx("div", { className: cvaBinaryControlSuffixContainer(), "data-testid": dataTestId ? `${dataTestId}-suffix-container` : undefined, children: suffix })) : null, description ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlDescriptionTooltip(), "data-testid": dataTestId ? `${dataTestId}-Description-Tooltip` : undefined, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsxRuntime.jsx("span", { className: cvaBinaryControlDescription({ disabled: groupCtx?.disabled }), "data-testid": dataTestId ? `${dataTestId}-Description` : undefined, id: descriptionId, ref: descriptionRef, children: description }) }, "description-tooltip-" + rest.name)) : null] }));
|
|
2504
2504
|
};
|
|
2505
2505
|
|
|
2506
2506
|
const cvaTimeRange = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -2519,7 +2519,7 @@ const cvaTimeRange = cssClassVarianceUtilities.cvaMerge([
|
|
|
2519
2519
|
* @param {TimeRangeProps} props - The props for the TimeRange component
|
|
2520
2520
|
* @returns {ReactElement} TimeRange component
|
|
2521
2521
|
*/
|
|
2522
|
-
const TimeRange = ({ id, className, dataTestId, children, range, onChange, disabled, isInvalid, }) => {
|
|
2522
|
+
const TimeRange = ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, }) => {
|
|
2523
2523
|
const [timeRange, setTimeRange] = react.useState(range ?? {
|
|
2524
2524
|
timeFrom: DEFAULT_TIME,
|
|
2525
2525
|
timeTo: DEFAULT_TIME,
|
|
@@ -2531,7 +2531,7 @@ const TimeRange = ({ id, className, dataTestId, children, range, onChange, disab
|
|
|
2531
2531
|
setTimeRange(prev => ({ ...prev, timeTo }));
|
|
2532
2532
|
};
|
|
2533
2533
|
const onRangeChange = () => onChange(timeRange);
|
|
2534
|
-
return (jsxRuntime.jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, children: [jsxRuntime.jsx(BaseInput, {
|
|
2534
|
+
return (jsxRuntime.jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, children: [jsxRuntime.jsx(BaseInput, { "data-testid": `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: timeRange.timeFrom === "" ? DEFAULT_TIME : timeRange.timeFrom }), children ?? jsxRuntime.jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsxRuntime.jsx(BaseInput, { "data-testid": `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: timeRange.timeTo === "" ? DEFAULT_TIME : timeRange.timeTo })] }));
|
|
2535
2535
|
};
|
|
2536
2536
|
const DEFAULT_TIME = "12:00";
|
|
2537
2537
|
|
|
@@ -2550,7 +2550,7 @@ const cvaScheduleItemText = cssClassVarianceUtilities.cvaMerge(["flex", "font-bo
|
|
|
2550
2550
|
* @param {ScheduleProps} props - The props for the Schedule component
|
|
2551
2551
|
* @returns {ReactElement} Schedule component
|
|
2552
2552
|
*/
|
|
2553
|
-
const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = [] }) => {
|
|
2553
|
+
const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys = [], }) => {
|
|
2554
2554
|
const [t] = useTranslation();
|
|
2555
2555
|
const onRangeChange = (range, index) => {
|
|
2556
2556
|
const newSchedule = schedule.map((day, dayIndex) => (index === dayIndex ? { ...day, range: { ...range } } : day));
|
|
@@ -2583,7 +2583,7 @@ const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = []
|
|
|
2583
2583
|
onChange(newSchedule);
|
|
2584
2584
|
};
|
|
2585
2585
|
return (jsxRuntime.jsx("div", { className: className, "data-testid": dataTestId, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDay }, index) => {
|
|
2586
|
-
return (jsxRuntime.jsxs("div", { className: cvaScheduleItem(), children: [jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4 sm:hidden", children: [jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.day") }), jsxRuntime.jsx(reactComponents.Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.active") }), jsxRuntime.jsx(Checkbox, { checked: isActive, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.allDay") }), jsxRuntime.jsx(Checkbox, { checked: isAllDay ? isActive : undefined, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(TimeRange, { disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: range })] }), jsxRuntime.jsxs("div", { className: "max-sm:hidden sm:grid sm:grid-cols-[100px,200px,60px,250px,250px] sm:gap-2", children: [jsxRuntime.jsx(Checkbox, { checked: isActive,
|
|
2586
|
+
return (jsxRuntime.jsxs("div", { className: cvaScheduleItem(), children: [jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4 sm:hidden", children: [jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.day") }), jsxRuntime.jsx(reactComponents.Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.active") }), jsxRuntime.jsx(Checkbox, { checked: isActive, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.allDay") }), jsxRuntime.jsx(Checkbox, { checked: isAllDay ? isActive : undefined, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(TimeRange, { disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: range })] }), jsxRuntime.jsxs("div", { className: "max-sm:hidden sm:grid sm:grid-cols-[100px,200px,60px,250px,250px] sm:gap-2", children: [jsxRuntime.jsx(Checkbox, { checked: isActive, "data-testid": `${dataTestId}-${key}-checkbox`, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(reactComponents.Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsxRuntime.jsx(Checkbox, { checked: isAllDay ? isActive : undefined, "data-testid": `${dataTestId}-${key}-allday-checkbox`, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(TimeRange, { "data-testid": `${dataTestId}-${key}-range`, disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: isAllDay ? undefined : range })] })] }, key + label));
|
|
2587
2587
|
}) }));
|
|
2588
2588
|
};
|
|
2589
2589
|
|
|
@@ -2740,9 +2740,9 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
|
|
|
2740
2740
|
*
|
|
2741
2741
|
* @param {SearchProps} props - The props for the Search component
|
|
2742
2742
|
*/
|
|
2743
|
-
const Search = ({ className, placeholder, value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled = false, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", loading = false, inputClassName, iconName = "MagnifyingGlass", style, xMarkRef, ref, ...rest }) => {
|
|
2743
|
+
const Search = ({ className, placeholder, value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled = false, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete = "on", loading = false, inputClassName, iconName = "MagnifyingGlass", style, xMarkRef, ref, ...rest }) => {
|
|
2744
2744
|
const { t } = useTranslation();
|
|
2745
|
-
return (jsxRuntime.jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }),
|
|
2745
|
+
return (jsxRuntime.jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", size: rest.fieldSize ?? undefined })) : (jsxRuntime.jsx(reactComponents.Icon, { name: iconName, size: rest.fieldSize ?? undefined })), ref: ref, suffix:
|
|
2746
2746
|
//only show the clear button if there is a value and the onClear function is provided
|
|
2747
2747
|
onClear && value ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
2748
2748
|
onClear();
|
|
@@ -2753,7 +2753,7 @@ Search.displayName = "Search";
|
|
|
2753
2753
|
/**
|
|
2754
2754
|
*
|
|
2755
2755
|
*/
|
|
2756
|
-
const FormFieldSelectAdapter = ({ className, dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ref, ...rest }) => {
|
|
2756
|
+
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ref, ...rest }) => {
|
|
2757
2757
|
const isFirstRender = reactComponents.useIsFirstRender();
|
|
2758
2758
|
const [innerValue, setInnerValue] = react.useState(value || defaultValue);
|
|
2759
2759
|
react.useEffect(() => {
|
|
@@ -2786,7 +2786,7 @@ const FormFieldSelectAdapter = ({ className, dataTestId, helpText, helpAddon, ti
|
|
|
2786
2786
|
return (jsxRuntime.jsxs(FormGroup, { isInvalid: renderAsInvalid,
|
|
2787
2787
|
htmlFor,
|
|
2788
2788
|
className,
|
|
2789
|
-
dataTestId,
|
|
2789
|
+
"data-testid": dataTestId,
|
|
2790
2790
|
helpText: (renderAsInvalid && errorMessage) || helpText,
|
|
2791
2791
|
helpAddon,
|
|
2792
2792
|
tip,
|
|
@@ -2853,7 +2853,7 @@ const TextLengthIndicator = ({ length, maxLength }) => {
|
|
|
2853
2853
|
/**
|
|
2854
2854
|
*
|
|
2855
2855
|
*/
|
|
2856
|
-
const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ref, ...rest }) => {
|
|
2856
|
+
const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2857
2857
|
const [valueLength, setValueLength] = react.useState(value ? `${value}`.length : 0);
|
|
2858
2858
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2859
2859
|
const htmlForId = id ? id : "textAreaField-" + sharedUtils.uuidv4();
|
|
@@ -2863,15 +2863,15 @@ const TextAreaField = ({ id, label, tip, helpText, helpAddon, errorMessage, isIn
|
|
|
2863
2863
|
onChange(event);
|
|
2864
2864
|
}
|
|
2865
2865
|
}, [onChange]);
|
|
2866
|
-
return (jsxRuntime.jsx(FormGroup, { className: tailwindMerge.twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"),
|
|
2867
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextAreaBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto",
|
|
2866
|
+
return (jsxRuntime.jsx(FormGroup, { className: tailwindMerge.twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2867
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextAreaBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto", "data-testid": dataTestId, onChange: handleChange }) }));
|
|
2868
2868
|
};
|
|
2869
2869
|
TextAreaField.displayName = "TextAreaField";
|
|
2870
2870
|
|
|
2871
2871
|
/**
|
|
2872
2872
|
* Text fields enable the user to interact with and input content and data. This component can be used for long and short form entries. Allow the size of the text input box to reflect the length of the content you expect the user to enter.
|
|
2873
2873
|
*/
|
|
2874
|
-
const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, isWarning, ref, ...rest }) => {
|
|
2874
|
+
const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, "data-testid": dataTestId, isWarning, ref, ...rest }) => {
|
|
2875
2875
|
const [valueLength, setValueLength] = react.useState(value ? `${value}`.length : 0);
|
|
2876
2876
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2877
2877
|
const htmlFor = id ? id : "textField-" + sharedUtils.uuidv4();
|
|
@@ -2881,8 +2881,8 @@ const TextField = ({ id, label, tip, helpText, helpAddon, errorMessage, isInvali
|
|
|
2881
2881
|
onChange(event);
|
|
2882
2882
|
}
|
|
2883
2883
|
}, [onChange]);
|
|
2884
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2885
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextBaseInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, maxLength: maxLength, ref: ref, value: value, ...rest, className: className,
|
|
2884
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2885
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(TextBaseInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, isWarning: isWarning, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, "data-testid": dataTestId, onChange: handleChange }) }));
|
|
2886
2886
|
};
|
|
2887
2887
|
TextField.displayName = "TextField";
|
|
2888
2888
|
|
|
@@ -2892,10 +2892,10 @@ TextField.displayName = "TextField";
|
|
|
2892
2892
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
2893
2893
|
* @returns {ReactElement} TimeRangeField component
|
|
2894
2894
|
*/
|
|
2895
|
-
const TimeRangeField = ({ className, dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ...rest }) => {
|
|
2895
|
+
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ...rest }) => {
|
|
2896
2896
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2897
2897
|
const htmlFor = id ? id : "timeRangeField-" + sharedUtils.uuidv4();
|
|
2898
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2898
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
2899
2899
|
};
|
|
2900
2900
|
|
|
2901
2901
|
const cvaToggleSwitchWrapper = cssClassVarianceUtilities.cvaMerge(["grid", "grid-cols-[auto]", "items-center"]);
|
|
@@ -2980,9 +2980,17 @@ const cvaToggleSwitchThumb = cssClassVarianceUtilities.cvaMerge(["block", "round
|
|
|
2980
2980
|
* @param {ToggleSwitchProps} props - The props for the ToggleSwitch component
|
|
2981
2981
|
* @returns {ReactElement} ToggleSwitch component
|
|
2982
2982
|
*/
|
|
2983
|
-
const ToggleSwitch = react.forwardRef(({ onChange, onClick, preventDefaultOnClick, className, dataTestId = "toggle-switch", showInputFocus, toggled, size = "medium", tabIndex = 0, readOnly, disabled, ...rest }, ref) => {
|
|
2983
|
+
const ToggleSwitch = react.forwardRef(({ onChange, onClick, preventDefaultOnClick, className, "data-testid": dataTestId = "toggle-switch", showInputFocus, toggled, size = "medium", tabIndex = 0, readOnly, disabled, ...rest }, ref) => {
|
|
2984
2984
|
const localInputRef = react.useRef(null);
|
|
2985
2985
|
const inputRef = typeof ref === "function" ? localInputRef : ref || localInputRef;
|
|
2986
|
+
// Extract data attributes to apply to wrapper
|
|
2987
|
+
const dataAttributes = react.useMemo(() => Object.keys(rest).reduce((acc, key) => {
|
|
2988
|
+
if (key.startsWith("data-")) {
|
|
2989
|
+
acc[key] = rest[key];
|
|
2990
|
+
delete rest[key];
|
|
2991
|
+
}
|
|
2992
|
+
return acc;
|
|
2993
|
+
}, {}), [rest]);
|
|
2986
2994
|
const handleWrapperClick = (e) => {
|
|
2987
2995
|
// Prevents double-toggling when wrapped in a label or if preventDefaultOnClick is true
|
|
2988
2996
|
const isFromLabel = e.target instanceof Element && e.target.closest("label");
|
|
@@ -3005,7 +3013,7 @@ const ToggleSwitch = react.forwardRef(({ onChange, onClick, preventDefaultOnClic
|
|
|
3005
3013
|
e.stopPropagation();
|
|
3006
3014
|
onChange?.(!toggled, e);
|
|
3007
3015
|
};
|
|
3008
|
-
return (jsxRuntime.jsx("span", { className: cvaToggleSwitchWrapper({ className }), "data-testid": `${dataTestId}`, onClick: handleWrapperClick, onKeyDown: handleKeyPress, children: jsxRuntime.jsxs("span", { className: cvaToggleSwitchTrack({
|
|
3016
|
+
return (jsxRuntime.jsx("span", { className: cvaToggleSwitchWrapper({ className }), "data-testid": `${dataTestId}`, onClick: handleWrapperClick, onKeyDown: handleKeyPress, ...dataAttributes, children: jsxRuntime.jsxs("span", { className: cvaToggleSwitchTrack({
|
|
3009
3017
|
toggled,
|
|
3010
3018
|
disabled: disabled || readOnly,
|
|
3011
3019
|
size,
|
|
@@ -3025,13 +3033,13 @@ ToggleSwitch.displayName = "ToggleSwitch";
|
|
|
3025
3033
|
* @param {ToggleSwitchOptionProps} props - The props for the ToggleSwitchOption component
|
|
3026
3034
|
* @returns {ReactElement} ToggleSwitchOption component
|
|
3027
3035
|
*/
|
|
3028
|
-
const ToggleSwitchOption = ({ label, className, description, suffix, id, dataTestId = "toggle-switch-option", ...rest }) => {
|
|
3036
|
+
const ToggleSwitchOption = ({ label, className, description, suffix, id, "data-testid": dataTestId = "toggle-switch-option", ...rest }) => {
|
|
3029
3037
|
const { ref: labelRef, isTextTruncated: isLabelTruncated } = reactComponents.useIsTextTruncated();
|
|
3030
3038
|
const { ref: descriptionRef, isTextTruncated: isDescriptionTruncated } = reactComponents.useIsTextTruncated();
|
|
3031
|
-
return (jsxRuntime.jsxs("label", { className: cvaBinaryControlWrapper({ className }), "data-testid": dataTestId, htmlFor: `${id}-toggle-switch`, tabIndex: -1, children: [jsxRuntime.jsx(ToggleSwitch, {
|
|
3039
|
+
return (jsxRuntime.jsxs("label", { className: cvaBinaryControlWrapper({ className }), "data-testid": dataTestId, htmlFor: `${id}-toggle-switch`, tabIndex: -1, children: [jsxRuntime.jsx(ToggleSwitch, { "data-testid": `${dataTestId}-switcher`, id: `${id}-toggle-switch`, ...rest }), jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlLabelTooltip(), "data-testid": `${dataTestId}-label-tooltip`, disabled: !isLabelTruncated, label: label, placement: "top", children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
3032
3040
|
disabled: rest.disabled || rest.readOnly,
|
|
3033
3041
|
className: "select-none",
|
|
3034
|
-
}), "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 ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlDescriptionTooltip(),
|
|
3042
|
+
}), "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 ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaBinaryControlDescriptionTooltip(), "data-testid": `${dataTestId}-description-tooltip`, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsxRuntime.jsx("span", { className: cvaBinaryControlDescription({ disabled: rest.disabled || rest.readOnly }), "data-testid": `${dataTestId}-description`, id: `${id}-description`, ref: descriptionRef, children: description }) }, `${id}-description-tooltip`)) : null] }));
|
|
3035
3043
|
};
|
|
3036
3044
|
ToggleSwitchOption.displayName = "ToggleSwitchOption";
|
|
3037
3045
|
|
|
@@ -3063,10 +3071,10 @@ UploadInput.displayName = "UploadInput";
|
|
|
3063
3071
|
/**
|
|
3064
3072
|
* Upload fields enable the user to upload Files.
|
|
3065
3073
|
*/
|
|
3066
|
-
const UploadField = ({ label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId, ref, ...rest }) => {
|
|
3074
|
+
const UploadField = ({ label, id, tip, helpText, errorMessage, isInvalid, className, value, "data-testid": dataTestId, ref, ...rest }) => {
|
|
3067
3075
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
3068
3076
|
const htmlForId = id ? id : "uploadField-" + sharedUtils.uuidv4();
|
|
3069
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
3077
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
3070
3078
|
};
|
|
3071
3079
|
UploadField.displayName = "UploadField";
|
|
3072
3080
|
|
|
@@ -3106,10 +3114,10 @@ const validateUrl = (url, required) => {
|
|
|
3106
3114
|
*
|
|
3107
3115
|
* NOTE: If shown with a label, please use the `UrlField` component instead.
|
|
3108
3116
|
*/
|
|
3109
|
-
const UrlBaseInput = ({ dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue, ref, ...rest }) => {
|
|
3117
|
+
const UrlBaseInput = ({ "data-testid": dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue, ref, ...rest }) => {
|
|
3110
3118
|
const [url, setUrl] = react.useState(value?.toString() || defaultValue?.toString());
|
|
3111
3119
|
const renderAsInvalid = (url && typeof url === "string" && !validateUrlAddress(url)) || isInvalid;
|
|
3112
|
-
return (jsxRuntime.jsx(BaseInput, {
|
|
3120
|
+
return (jsxRuntime.jsx(BaseInput, { "data-testid": dataTestId ? `${dataTestId}-url-input` : undefined, disabled: disabled, id: "url-input", isInvalid: renderAsInvalid, onChange: e => setUrl(e.target.value), placeholder: rest.placeholder || "https://www.example.com", ref: ref, type: "url", value: url, ...rest, actions: !disableAction && (jsxRuntime.jsx(ActionButton, { "data-testid": (dataTestId && `${dataTestId}-url-input-Icon`) || "url-input-action-icon", disabled: renderAsInvalid || Boolean(disabled) || disableAction, size: fieldSize ?? undefined, type: "WEB_ADDRESS", value: url })) }));
|
|
3113
3121
|
};
|
|
3114
3122
|
|
|
3115
3123
|
/**
|
|
@@ -3117,7 +3125,7 @@ const UrlBaseInput = ({ dataTestId, isInvalid, disabled = false, fieldSize = "me
|
|
|
3117
3125
|
* UrlField validates that user enters a valid web address.
|
|
3118
3126
|
*
|
|
3119
3127
|
*/
|
|
3120
|
-
const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, isInvalid = false, value, onBlur, ref, ...rest }) => {
|
|
3128
|
+
const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, isInvalid = false, value, onBlur, ref, ...rest }) => {
|
|
3121
3129
|
const htmlForId = id ? id : "urlField-" + sharedUtils.uuidv4();
|
|
3122
3130
|
const [t] = useTranslation();
|
|
3123
3131
|
const [innerValue, setInnerValue] = react.useState(() => {
|
|
@@ -3132,7 +3140,7 @@ const UrlField = ({ label, id, tip, helpText, errorMessage, helpAddon, className
|
|
|
3132
3140
|
setRenderAsInvalid(!!validateUrl(newValue, rest.required));
|
|
3133
3141
|
onBlur?.(event);
|
|
3134
3142
|
}, [onBlur, rest.required]);
|
|
3135
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
3143
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? error : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required ? !(rest.disabled || rest.readOnly) : false, tip: tip, children: jsxRuntime.jsx(UrlBaseInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, onBlur: handleBlur, ref: ref, value: value || defaultValue, ...rest, className: className, "data-testid": dataTestId }) }));
|
|
3136
3144
|
};
|
|
3137
3145
|
UrlField.displayName = "UrlField";
|
|
3138
3146
|
|