@trackunit/react-form-components 0.0.304 → 0.0.305
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 +70 -71
- package/index.esm.js +70 -71
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -169,7 +169,7 @@ const cvaLabel = cssClassVarianceUtilities.cvaMerge([
|
|
|
169
169
|
* @returns {JSX.Element} Label component
|
|
170
170
|
*/
|
|
171
171
|
const Label = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
|
|
172
|
-
return (jsxRuntime.jsx("label", {
|
|
172
|
+
return (jsxRuntime.jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", children: children }));
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
const cvaFormGroup = cssClassVarianceUtilities.cvaMerge(["component-formGroup-gap"], {
|
|
@@ -320,7 +320,7 @@ const getOrderedOptions = (options, value) => {
|
|
|
320
320
|
* @returns {JSX.Element} CheckIcon component
|
|
321
321
|
*/
|
|
322
322
|
const CheckIcon = ({ className, dataTestId }) => {
|
|
323
|
-
return (jsxRuntime.jsx("svg", {
|
|
323
|
+
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" }) }));
|
|
324
324
|
};
|
|
325
325
|
|
|
326
326
|
const cvaCheckbox = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -453,7 +453,7 @@ const cvaCheckboxIcon = cssClassVarianceUtilities.cvaMerge(["w-2.5", "h-2.5", "t
|
|
|
453
453
|
* @param {IndeterminateIconProps} props - The props for the IndeterminateIcon component
|
|
454
454
|
* @returns {JSX.Element} IndeterminateIcon component
|
|
455
455
|
*/
|
|
456
|
-
const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", {
|
|
456
|
+
const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", { className: className, fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 10 10", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M3 5h4", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
457
457
|
|
|
458
458
|
/**
|
|
459
459
|
* Checkboxes are used when there are multiple items to select in a list. Users can select zero, one, or any number of items.
|
|
@@ -489,15 +489,15 @@ const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
|
489
489
|
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
490
490
|
}, [labelRef, onLabelRefChange]);
|
|
491
491
|
const uuid = rest.id;
|
|
492
|
-
return (jsxRuntime.jsxs("label", { "data-testid": dataTestId && `${dataTestId}-container`, htmlFor: uuid,
|
|
492
|
+
return (jsxRuntime.jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId && `${dataTestId}-container`, htmlFor: uuid, onClick: e => stopPropagation && e.stopPropagation(), onKeyDown: onKeyPress, ref: internalRef, children: [jsxRuntime.jsx("input", Object.assign({ "aria-checked": !indeterminate && checked, checked: !indeterminate && checked, className: cvaCheckboxInput(), "data-testid": dataTestId, disabled: disabled, id: uuid, onChange: onChange, readOnly: readOnly, type: "checkbox" }, rest, { ref: ref })), jsxRuntime.jsx("span", { className: cvaCheckbox({
|
|
493
493
|
disabled: isReadonly,
|
|
494
494
|
invalid: isReadonly ? false : isInvalid,
|
|
495
495
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
496
|
-
}), children: icon }), label && (jsxRuntime.jsx("span", { className: "flex", children: jsxRuntime.jsx("span", {
|
|
496
|
+
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label && (jsxRuntime.jsx("span", { className: "flex", children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
497
497
|
invalid: isReadonly ? false : isInvalid,
|
|
498
498
|
disabled: isReadonly,
|
|
499
499
|
className: "cursor-pointer",
|
|
500
|
-
}), children: label }) })), suffix] }));
|
|
500
|
+
}), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })), suffix] }));
|
|
501
501
|
});
|
|
502
502
|
|
|
503
503
|
/**
|
|
@@ -507,7 +507,7 @@ const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
|
507
507
|
* @returns {JSX.Element} SingleSelectMenuItem
|
|
508
508
|
*/
|
|
509
509
|
const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focused, disabled, }) => {
|
|
510
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId,
|
|
510
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId, disabled: disabled, focused: focused, label: label, onClick: onClick, prefix: icon, selected: selected, suffix: selected ? jsxRuntime.jsx(reactComponents.Icon, { name: "Check", size: "small" }) : undefined }));
|
|
511
511
|
};
|
|
512
512
|
/**
|
|
513
513
|
* A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
|
|
@@ -516,12 +516,12 @@ const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focu
|
|
|
516
516
|
* @returns {JSX.Element} multi select menu item
|
|
517
517
|
*/
|
|
518
518
|
const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, focused, disabled, }) => {
|
|
519
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId,
|
|
520
|
-
e.stopPropagation();
|
|
521
|
-
} }), onClick: e => {
|
|
519
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId, disabled: disabled, focused: focused, label: label, onClick: e => {
|
|
522
520
|
e.stopPropagation();
|
|
523
521
|
onClick && onClick(e);
|
|
524
|
-
},
|
|
522
|
+
}, prefix: jsxRuntime.jsx(Checkbox, { checked: selected, disabled: disabled, onChange: () => null, onClick: e => {
|
|
523
|
+
e.stopPropagation();
|
|
524
|
+
}, readOnly: false }), selected: selected }));
|
|
525
525
|
};
|
|
526
526
|
|
|
527
527
|
/**
|
|
@@ -578,17 +578,17 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
578
578
|
const isLast = index === items.length;
|
|
579
579
|
const counterRequired = requiredSpace > availableSpace && counter !== 0;
|
|
580
580
|
if (isLast && counterRequired) {
|
|
581
|
-
return (jsxRuntime.jsx(TagWithWidth, { onWidthKnown: ({ width: reportedWidth }) => setCounterWidth(reportedWidth),
|
|
581
|
+
return (jsxRuntime.jsx(TagWithWidth, { color: "white", disabled: disabled, onWidthKnown: ({ width: reportedWidth }) => setCounterWidth(reportedWidth), children: jsxRuntime.jsxs("div", { className: cvaSelectCounter(), "data-testid": "select-counter", children: ["+", counter] }) }, item.text + index));
|
|
582
582
|
}
|
|
583
583
|
if (isLast) {
|
|
584
584
|
return null;
|
|
585
585
|
}
|
|
586
586
|
const itemCanFit = spaceNeeded <= availableSpace;
|
|
587
587
|
if (itemCanFit) {
|
|
588
|
-
return (jsxRuntime.jsx(TagWithWidth, {
|
|
588
|
+
return (jsxRuntime.jsx(TagWithWidth, { className: "inline-flex shrink-0", color: item.disabled ? "unknown" : "primary", dataTestId: `${item.text}-tag`, disabled: disabled, onClose: e => {
|
|
589
589
|
e.stopPropagation();
|
|
590
590
|
item.onClick();
|
|
591
|
-
},
|
|
591
|
+
}, onWidthKnown: onWidthKnownHandler, children: item.text }, item.text + index));
|
|
592
592
|
}
|
|
593
593
|
const fromTheItems = item.text !== "";
|
|
594
594
|
if (fromTheItems) {
|
|
@@ -597,9 +597,9 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
597
597
|
return null;
|
|
598
598
|
})
|
|
599
599
|
.filter(element => element !== null);
|
|
600
|
-
return (jsxRuntime.jsxs("div", { style: {
|
|
600
|
+
return (jsxRuntime.jsxs("div", { className: cvaSelectDynamicTagContainer({ visible: isReady }), ref: containerRef, style: {
|
|
601
601
|
width: `${width}`,
|
|
602
|
-
},
|
|
602
|
+
}, children: [renderedElements, postFix] }));
|
|
603
603
|
};
|
|
604
604
|
|
|
605
605
|
/**
|
|
@@ -628,7 +628,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
628
628
|
const values = props && props.children ? props.children[0] : [];
|
|
629
629
|
const tags = key === PLACEHOLDER_KEY ? [] : values;
|
|
630
630
|
const searchInput = props && props.children && props.children[1];
|
|
631
|
-
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsxRuntime.jsx(TagsContainer, {
|
|
631
|
+
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsxRuntime.jsx(TagsContainer, { disabled: disabled, items: tags
|
|
632
632
|
? tags.map(({ props: tagProps }) => {
|
|
633
633
|
return {
|
|
634
634
|
text: tagProps.children,
|
|
@@ -642,20 +642,20 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
642
642
|
disabled: disabled,
|
|
643
643
|
};
|
|
644
644
|
})
|
|
645
|
-
: [], postFix: searchInput,
|
|
645
|
+
: [], postFix: searchInput, width: "100%" })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [tags &&
|
|
646
646
|
tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
|
|
647
647
|
var _a, _b;
|
|
648
|
-
return (jsxRuntime.jsx(reactComponents.Tag, { className: "inline-flex shrink-0", onClose: e => {
|
|
648
|
+
return (jsxRuntime.jsx(reactComponents.Tag, { className: "inline-flex shrink-0", color: disabled ? "unknown" : "primary", dataTestId: tagProps.children ? `${(_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()}-tag` : undefined, onClose: e => {
|
|
649
649
|
var _a, _b;
|
|
650
650
|
e.stopPropagation();
|
|
651
651
|
refMenuIsEnabled.current = false;
|
|
652
652
|
((_a = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _a === void 0 ? void 0 : _a.onClick) && ((_b = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _b === void 0 ? void 0 : _b.onClick(e));
|
|
653
|
-
},
|
|
653
|
+
}, children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
654
654
|
}), tags && tags.length > maxSelectedDisplayCount && (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
|
|
655
655
|
}
|
|
656
656
|
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: props.children })));
|
|
657
657
|
}, LoadingIndicator: props => {
|
|
658
|
-
return jsxRuntime.jsx(reactComponents.Spinner, {
|
|
658
|
+
return jsxRuntime.jsx(reactComponents.Spinner, { className: "mt-1.5 mr-1", size: "small" });
|
|
659
659
|
}, DropdownIndicator: props => {
|
|
660
660
|
const icon = props.selectProps.menuIsOpen ? (jsxRuntime.jsx(reactComponents.Icon, { name: "ChevronUp", size: "medium" })) : (jsxRuntime.jsx(reactComponents.Icon, { name: "ChevronDown", size: "medium" }));
|
|
661
661
|
return props.selectProps.isLoading ? null : (jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, Object.assign({}, props, { children: jsxRuntime.jsx("div", { className: cvaSelectIcon(), children: dropdownIcon ? dropdownIcon : icon }) })));
|
|
@@ -663,7 +663,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
663
663
|
if (disabled) {
|
|
664
664
|
return null;
|
|
665
665
|
}
|
|
666
|
-
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, Object.assign({}, props, { children: jsxRuntime.jsx("div", { className: cvaSelectXIcon(),
|
|
666
|
+
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, Object.assign({}, props, { children: jsxRuntime.jsx("div", { className: cvaSelectXIcon(), "data-testid": dataTestId && `${dataTestId}-XMarkIcon`, onClick: props.clearValue, children: jsxRuntime.jsx(reactComponents.Icon, { name: "XCircle", size: "medium", title: t("clearIndicator.icon.tooltip.clearAll") }) }) })));
|
|
667
667
|
}, Control: props => {
|
|
668
668
|
return jsxRuntime.jsx(ReactSelect.components.Control, Object.assign({}, props, { className: props.isDisabled ? "bg-slate-100" : "" }));
|
|
669
669
|
}, SingleValue: props => {
|
|
@@ -684,7 +684,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
684
684
|
selected: props.isSelected,
|
|
685
685
|
onClick: props.innerProps.onClick,
|
|
686
686
|
};
|
|
687
|
-
return (jsxRuntime.jsx(ReactSelect.components.Option, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { role: "option", onClick: () => { } }), children: props.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, Object.assign({}, componentProps, {
|
|
687
|
+
return (jsxRuntime.jsx(ReactSelect.components.Option, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { role: "option", onClick: () => { } }), children: props.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, Object.assign({}, componentProps, { dataTestId: typeof props.label === "string" ? props.label : undefined, disabled: disabled }))) : (jsxRuntime.jsx(SingleSelectMenuItem, Object.assign({}, componentProps, { dataTestId: typeof props.label === "string" ? props.label : undefined, disabled: disabled || props.isDisabled }))) })));
|
|
688
688
|
} }, componentsProps);
|
|
689
689
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
690
690
|
}, [componentsProps, disabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
|
|
@@ -808,15 +808,15 @@ const CreatableSelect = (props) => {
|
|
|
808
808
|
isClearable,
|
|
809
809
|
id,
|
|
810
810
|
};
|
|
811
|
-
return (jsxRuntime.jsx(SelectContainer, {
|
|
812
|
-
!disabled && openMenuHandler();
|
|
813
|
-
}, onMenuClose: () => {
|
|
811
|
+
return (jsxRuntime.jsx(SelectContainer, { dataTestId: dataTestId, description: description, error: error, hasError: hasError, hideLabel: hideLabel, id: id, info: info, isDisabled: disabled, label: label, children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [prefix !== undefined && (jsxRuntime.jsx("div", { className: cvaSelectPrefix(), "data-testid": dataTestId && `${dataTestId}-prefix`, ref: refPrefix, children: prefix })), async ? (jsxRuntime.jsx(ReactAsyncCreatableSelect__default["default"], Object.assign({ "aria-label": label, components: customComponents, "data-testid": dataTestId, maxMenuHeight: maxMenuHeight }, props, { onMenuClose: () => {
|
|
814
812
|
closeMenuHandler();
|
|
815
|
-
}
|
|
813
|
+
}, onMenuOpen: () => {
|
|
816
814
|
!disabled && openMenuHandler();
|
|
817
|
-
}, onMenuClose: () => {
|
|
815
|
+
} }))) : (jsxRuntime.jsx(ReactCreatableSelect__default["default"], Object.assign({}, selectProps, { isMulti: isMulti, onMenuClose: () => {
|
|
818
816
|
closeMenuHandler();
|
|
819
|
-
}
|
|
817
|
+
}, onMenuOpen: () => {
|
|
818
|
+
!disabled && openMenuHandler();
|
|
819
|
+
}, options: filterOption ? orderedOptions : options })))] }) }));
|
|
820
820
|
};
|
|
821
821
|
|
|
822
822
|
/**
|
|
@@ -856,7 +856,7 @@ const Select = (props) => {
|
|
|
856
856
|
onMenuScrollToBottom,
|
|
857
857
|
onInputChange,
|
|
858
858
|
};
|
|
859
|
-
return (jsxRuntime.jsxs("div", {
|
|
859
|
+
return (jsxRuntime.jsxs("div", { className: cvaSelect({ invalid: hasError, disabled: disabled || readOnly, className }), "data-testid": dataTestId, ref: refContainer, children: [prefix !== undefined && (jsxRuntime.jsx("div", { className: cvaSelectPrefix(), "data-testid": dataTestId && `${dataTestId}-prefix`, ref: refPrefix, children: prefix })), async ? (jsxRuntime.jsx(ReactAsyncSelect__default["default"], Object.assign({}, propsNoClassName, selectProps, async, { onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler }))) : (jsxRuntime.jsx(ReactSelect__default["default"], Object.assign({}, propsNoClassName, selectProps, { hideSelectedOptions: false, isMulti: isMulti, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options })))] }));
|
|
860
860
|
};
|
|
861
861
|
Select.displayName = "Select";
|
|
862
862
|
|
|
@@ -968,7 +968,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, key, classN
|
|
|
968
968
|
if (ButtonAction === null) {
|
|
969
969
|
return null;
|
|
970
970
|
}
|
|
971
|
-
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className }), children: jsxRuntime.jsx(reactComponents.IconButton, {
|
|
971
|
+
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className }), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: "small" }), onClick: ButtonAction, size: "small", variant: "secondary" }) }, elementKey));
|
|
972
972
|
};
|
|
973
973
|
|
|
974
974
|
const cvaInputBase = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1081,7 +1081,7 @@ const BaseInput = React__namespace.forwardRef((_a, ref) => {
|
|
|
1081
1081
|
className,
|
|
1082
1082
|
}), "data-testid": dataTestId && `${dataTestId}-container`, children: [addonBefore && addonBefore !== undefined ? (jsxRuntime.jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId && `${dataTestId}-addonBefore`, children: addonBefore })) : null, prefix && addonBefore !== prefix ? (jsxRuntime.jsx("div", { className: cvaInputPrefix({
|
|
1083
1083
|
disabled: renderAsDisabled,
|
|
1084
|
-
}), "data-testid": dataTestId && `${dataTestId}-prefix`, children: prefix })) : null, jsxRuntime.jsx("input", Object.assign({
|
|
1084
|
+
}), "data-testid": dataTestId && `${dataTestId}-prefix`, children: prefix })) : null, jsxRuntime.jsx("input", Object.assign({ className: cvaInputField({ size: fieldSize, disabled: renderAsDisabled, className: inputClassName }), "data-testid": dataTestId, ref: innerRef, type: isReadOnlyWithPlaceholder ? "text" : type }, rest, { readOnly: rest.readOnly || nonInteractive })), suffix && addonBefore !== suffix ? (jsxRuntime.jsx("div", { className: cvaInputSuffix({
|
|
1085
1085
|
disabled: renderAsDisabled,
|
|
1086
1086
|
}), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix })) : null, rest.readOnly === true && showDefaultActions ? (jsxRuntime.jsx(ActionButton, { type: "COPY", value: innerRef }, "default-copy-action")) : null, actions && addonBefore !== actions ? actions : null, addonAfter && addonAfter !== undefined && addonBefore !== addonAfter ? (jsxRuntime.jsx("div", { className: cvaInputAddonAfter(), "data-testid": dataTestId && `${dataTestId}-addonAfter`, children: addonAfter })) : null] }));
|
|
1087
1087
|
});
|
|
@@ -1096,7 +1096,7 @@ const DateInput = React.forwardRef((_a, ref) => {
|
|
|
1096
1096
|
const formatDateToInputString = (date) => date instanceof Date ? dateFns.format(date, "yyyy-MM-dd") : date;
|
|
1097
1097
|
// Chrome and Firefox need their default icon to have datepicker functionality.
|
|
1098
1098
|
const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
|
|
1099
|
-
return (jsxRuntime.jsx(BaseInput, Object.assign({
|
|
1099
|
+
return (jsxRuntime.jsx(BaseInput, Object.assign({ defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon && jsxRuntime.jsx(reactComponents.Icon, { dataTestId: "calendar", name: "Calendar", size: "medium", type: "solid" }), type: "date", value: formatDateToInputString(value) }, rest)));
|
|
1100
1100
|
});
|
|
1101
1101
|
|
|
1102
1102
|
/**
|
|
@@ -1110,7 +1110,7 @@ const DateField = React.forwardRef((_a, ref) => {
|
|
|
1110
1110
|
var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
|
|
1111
1111
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1112
1112
|
const htmlForId = id ? id : "dateField-" + uuid.v4();
|
|
1113
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1113
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(DateInput, Object.assign({ "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
1114
1114
|
});
|
|
1115
1115
|
|
|
1116
1116
|
const cvaDropZone = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1191,12 +1191,12 @@ const DropZone = (_a) => {
|
|
|
1191
1191
|
setFileDropped(true);
|
|
1192
1192
|
}
|
|
1193
1193
|
};
|
|
1194
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId,
|
|
1194
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId, onClick: e => {
|
|
1195
1195
|
if (disabled) {
|
|
1196
1196
|
e.preventDefault();
|
|
1197
1197
|
e.stopPropagation();
|
|
1198
1198
|
}
|
|
1199
|
-
} }, rest, { children: [jsxRuntime.jsx("input", {
|
|
1199
|
+
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop }, rest, { children: [jsxRuntime.jsx("input", { className: "hidden", id: "input-file-upload", onChange: handleChange, title: "Hidden File Input", type: "file" }), jsxRuntime.jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId && `${dataTestId}-label`, htmlFor: "input-file-upload", children: [jsxRuntime.jsx(reactComponents.Icon, { color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", style: !isInvalid ? { color: "rgb(156 163 175)" } : {}, type: "solid" }), jsxRuntime.jsx("span", { children: label })] })] })));
|
|
1200
1200
|
};
|
|
1201
1201
|
|
|
1202
1202
|
// Doing the same check as we do on the backend
|
|
@@ -1232,7 +1232,7 @@ const EmailInput = React__namespace.forwardRef((_a, ref) => {
|
|
|
1232
1232
|
return window.open(`mailto:${email}`);
|
|
1233
1233
|
};
|
|
1234
1234
|
const renderAsInvalid = (email && !validateEmailAddress(email)) || isInvalid;
|
|
1235
|
-
return (jsxRuntime.jsx(BaseInput, Object.assign({ dataTestId: dataTestId,
|
|
1235
|
+
return (jsxRuntime.jsx(BaseInput, Object.assign({ actions: jsxRuntime.jsx(ActionButton, { dataTestId: dataTestId && `${dataTestId}-emailIcon`, disabled: disabled, iconSize: fieldSize, onClick: sendEmail, type: "EMAIL", value: email }), dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: e => setEmail(e.target.value), placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email" }, rest)));
|
|
1236
1236
|
});
|
|
1237
1237
|
|
|
1238
1238
|
/**
|
|
@@ -1253,7 +1253,7 @@ const EmailField = React.forwardRef((_a, ref) => {
|
|
|
1253
1253
|
onChange(event);
|
|
1254
1254
|
}
|
|
1255
1255
|
}, [onChange]);
|
|
1256
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1256
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(EmailInput, Object.assign({ "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, disabled: renderAsInvalid, id: htmlForId, isInvalid: renderAsInvalid, onChange: handleChange, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
1257
1257
|
});
|
|
1258
1258
|
|
|
1259
1259
|
/**
|
|
@@ -1276,7 +1276,7 @@ const NumberField = React.forwardRef((_a, ref) => {
|
|
|
1276
1276
|
var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
|
|
1277
1277
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1278
1278
|
const htmlForId = id ? id : "numberField-" + uuid.v4();
|
|
1279
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1279
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(NumberInput, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
1280
1280
|
});
|
|
1281
1281
|
|
|
1282
1282
|
const cvaOptionCardLabel = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1311,7 +1311,7 @@ const cvaOptionCardContainer = cssClassVarianceUtilities.cvaMerge(["contents"]);
|
|
|
1311
1311
|
const OptionCard = React.forwardRef((_a, ref) => {
|
|
1312
1312
|
var { icon, heading, subheading, description, disabled, id, value, className, dataTestId } = _a, rest = __rest(_a, ["icon", "heading", "subheading", "description", "disabled", "id", "value", "className", "dataTestId"]);
|
|
1313
1313
|
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" + uuid.v4();
|
|
1314
|
-
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId,
|
|
1314
|
+
return (jsxRuntime.jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsxRuntime.jsx("input", Object.assign({ className: "peer hidden", id: htmlForId, ref: ref, type: "radio", value: value }, rest)), jsxRuntime.jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), htmlFor: htmlForId, children: [disabled && icon && React.cloneElement(icon, { className: `${icon.props.className} text-secondary-400` }), !disabled && icon, heading && (jsxRuntime.jsx(reactComponents.Heading, { subtle: disabled, variant: "secondary", children: heading })), (subheading || description) && (jsxRuntime.jsxs("div", { className: cvaOptionCardContent(), children: [subheading && (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: disabled, type: "span", weight: "thick", children: subheading })), description && (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: true, type: "span", children: description }))] }))] })] }));
|
|
1315
1315
|
});
|
|
1316
1316
|
|
|
1317
1317
|
/**
|
|
@@ -1336,7 +1336,7 @@ const PasswordField = React.forwardRef((_a, ref) => {
|
|
|
1336
1336
|
const handleChange = React.useCallback((event) => {
|
|
1337
1337
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1338
1338
|
}, [onChange]);
|
|
1339
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1339
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(PasswordInput, Object.assign({}, rest, { actions: jsxRuntime.jsx(reactComponents.Icon, { className: "absolute top-0 bottom-0 right-2 h-full content-center", color: "neutral", name: showPassword ? "EyeSlash" : "Eye", onClick: () => setShowPassword(prevState => !prevState), size: "small" }), "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, type: showPassword ? "text" : "password", value: value })) }));
|
|
1340
1340
|
});
|
|
1341
1341
|
|
|
1342
1342
|
/**
|
|
@@ -1521,7 +1521,7 @@ const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, onChange
|
|
|
1521
1521
|
const filteredCodes = countryCodes.filter(code => {
|
|
1522
1522
|
return !(excludedCountries === null || excludedCountries === void 0 ? void 0 : excludedCountries.some(excludedCode => excludedCode.value === code.value));
|
|
1523
1523
|
});
|
|
1524
|
-
return (jsxRuntime.jsx(Select, {
|
|
1524
|
+
return (jsxRuntime.jsx(Select, { "aria-invalid": isCountryCodeMissing, className: "w-36", closeMenuOnSelect: true, dataTestId: dataTestId, disabled: disabled, hasError: isCountryCodeMissing || isInvalid, isClearable: isClearable, maxMenuHeight: 200, menuIsOpen: readOnly ? false : undefined, onBlur: onBlur, onChange: onChange, options: filteredCodes.map(code => code), placeholder: placeholder, readOnly: readOnly, value: filteredCodes.find(({ value }) => value === `+${countryCode}`) }));
|
|
1525
1525
|
};
|
|
1526
1526
|
|
|
1527
1527
|
/**
|
|
@@ -1592,16 +1592,16 @@ const PhoneInput = React.forwardRef((_a, ref) => {
|
|
|
1592
1592
|
// the event's type is inferred as Event, which doesn't have a target property, whereas ChangeEvent does.
|
|
1593
1593
|
onChange && onChange(event);
|
|
1594
1594
|
}, [phoneNumber, onChange]);
|
|
1595
|
-
return (jsxRuntime.jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsx("input", {
|
|
1595
|
+
return (jsxRuntime.jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsx("input", { "aria-invalid": isInvalid, "data-testid": dataTestId, hidden: true, id: "phone-input", onChange: onChange, readOnly: readOnly, ref: hiddenInputRef, value: phoneNumber }), jsxRuntime.jsx(CountryCodeSelect, { countryCode: code, dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, disabled: disabled, isClearable: isCountryCodeClearable, isInvalid: isInvalid, onBlur: e => {
|
|
1596
1596
|
onBlurHandler();
|
|
1597
1597
|
}, onChange: e => {
|
|
1598
1598
|
var _a;
|
|
1599
1599
|
onCodeChangeHandler((_a = e === null || e === void 0 ? void 0 : e.value) !== null && _a !== void 0 ? _a : "");
|
|
1600
|
-
},
|
|
1601
|
-
onPhoneChangeHandler(e.target.value);
|
|
1602
|
-
}, onBlur: () => {
|
|
1600
|
+
}, placeholder: placeholder, readOnly: readOnly }), jsxRuntime.jsx(BaseInput, Object.assign({ actions: !disableAction && (jsxRuntime.jsx(ActionButton, { dataTestId: dataTestId && `${dataTestId}-phoneIcon`, disabled: disabled || isInvalid, iconSize: fieldSize, type: "PHONE_NUMBER", value: phoneNumber })), dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, disabled: disabled, fieldSize: fieldSize, id: "phoneInput-number", isInvalid: isInvalid, onBlur: () => {
|
|
1603
1601
|
onBlurHandler();
|
|
1604
|
-
},
|
|
1602
|
+
}, onChange: e => {
|
|
1603
|
+
onPhoneChangeHandler(e.target.value);
|
|
1604
|
+
}, readOnly: readOnly, type: "tel", value: phone }, rest))] }));
|
|
1605
1605
|
});
|
|
1606
1606
|
|
|
1607
1607
|
/**
|
|
@@ -1679,7 +1679,7 @@ const PhoneField = React.forwardRef((_a, ref) => {
|
|
|
1679
1679
|
validate(phoneNumberValue);
|
|
1680
1680
|
onFieldsBlur && onFieldsBlur(Object.assign(Object.assign({}, phoneNumberValue), { isValid }));
|
|
1681
1681
|
};
|
|
1682
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1682
|
+
return (jsxRuntime.jsx(FormGroup, { className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && (errorMessage || localError)) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(PhoneInput, Object.assign({ "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onChangeValue: onChangeValueHandler, onFieldsBlur: handleOnFieldBlur, ref: ref, value: value }, rest)) }));
|
|
1683
1683
|
});
|
|
1684
1684
|
|
|
1685
1685
|
const cvaRadioGroup = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2", "flex-col", "items-start"], {
|
|
@@ -1794,7 +1794,7 @@ const RadioGroupContext = React__namespace.createContext(null);
|
|
|
1794
1794
|
* @returns {JSX.Element} RadioGroup component
|
|
1795
1795
|
*/
|
|
1796
1796
|
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
|
|
1797
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
1797
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, label: label, children: jsxRuntime.jsx("div", { className: cvaRadioGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, children: jsxRuntime.jsx(RadioGroupContext.Provider, { value: {
|
|
1798
1798
|
id,
|
|
1799
1799
|
value,
|
|
1800
1800
|
name: name || id,
|
|
@@ -1814,11 +1814,11 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
1814
1814
|
const RadioItem = ({ label, value, dataTestId, className, description, }) => {
|
|
1815
1815
|
const groupCtx = React__namespace.useContext(RadioGroupContext);
|
|
1816
1816
|
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
1817
|
-
return (jsxRuntime.jsxs("label", { className: cvaRadioItemWrapper({ className }),
|
|
1817
|
+
return (jsxRuntime.jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId && `${dataTestId}-Wrapper`, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: [jsxRuntime.jsx("input", { checked: isChecked, className: cvaRadioItem({
|
|
1818
1818
|
checked: isChecked,
|
|
1819
1819
|
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
1820
1820
|
invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
|
|
1821
|
-
}), onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, "
|
|
1821
|
+
}), "data-testid": dataTestId, id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, type: "radio", value: value }), jsxRuntime.jsxs("div", { className: cvaRadioItemLabelContainer(), children: [jsxRuntime.jsx(Label, { dataTestId: dataTestId && `${dataTestId}-Label`, disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, isInvalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid, children: label }), description && (jsxRuntime.jsx("label", { className: cvaRadioItemDescription({ disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }), "data-testid": dataTestId && `${dataTestId}-Description`, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: description }))] })] }));
|
|
1822
1822
|
};
|
|
1823
1823
|
|
|
1824
1824
|
const cvaTimeRange = cssClassVarianceUtilities.cvaMerge(["flex", "flex-1", "items-center", "gap-4", "border-transparent", "rounded-md"]);
|
|
@@ -1842,7 +1842,7 @@ const TimeRange = ({ id, className, dataTestId, children, range, onChange, disab
|
|
|
1842
1842
|
setTimeRange(prev => (Object.assign(Object.assign({}, prev), { timeTo })));
|
|
1843
1843
|
};
|
|
1844
1844
|
const onRangeChange = () => onChange(timeRange);
|
|
1845
|
-
return (jsxRuntime.jsxs("div", {
|
|
1845
|
+
return (jsxRuntime.jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, children: [jsxRuntime.jsx(BaseInput, { dataTestId: `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: (_a = timeRange === null || timeRange === void 0 ? void 0 : timeRange.timeFrom) !== null && _a !== void 0 ? _a : "" }), children !== null && children !== void 0 ? children : jsxRuntime.jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsxRuntime.jsx(BaseInput, { dataTestId: `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: (_b = timeRange === null || timeRange === void 0 ? void 0 : timeRange.timeTo) !== null && _b !== void 0 ? _b : "" })] }));
|
|
1846
1846
|
};
|
|
1847
1847
|
|
|
1848
1848
|
const cvaScheduleItem = cssClassVarianceUtilities.cvaMerge(["grid", "pb-4", "gap-2", "grid-cols-[60px,200px,60px,2fr]"]);
|
|
@@ -1868,8 +1868,8 @@ const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = []
|
|
|
1868
1868
|
? Object.assign(Object.assign({}, day), { range: { timeFrom: "", timeTo: "" }, isAllDayActive: isAllDayChecked }) : day);
|
|
1869
1869
|
onChange(newSchedule);
|
|
1870
1870
|
};
|
|
1871
|
-
return (jsxRuntime.jsx("div", { "data-testid": dataTestId,
|
|
1872
|
-
return (jsxRuntime.jsxs("div", { className: cvaScheduleItem(), children: [jsxRuntime.jsx(Checkbox, { dataTestId: `${dataTestId}-${key}-checkbox`,
|
|
1871
|
+
return (jsxRuntime.jsx("div", { className: className, "data-testid": dataTestId, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDayActive }, index) => {
|
|
1872
|
+
return (jsxRuntime.jsxs("div", { className: cvaScheduleItem(), children: [jsxRuntime.jsx(Checkbox, { checked: isActive, dataTestId: `${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: isAllDayActive && isActive, dataTestId: `${dataTestId}-${key}-allday-checkbox`, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(TimeRange, { dataTestId: `${dataTestId}-${key}-range`, disabled: !isActive || isAllDayActive, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: range })] }, key));
|
|
1873
1873
|
}) }));
|
|
1874
1874
|
};
|
|
1875
1875
|
|
|
@@ -2025,9 +2025,9 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
|
|
|
2025
2025
|
*/
|
|
2026
2026
|
const Search = React.forwardRef((_a, ref) => {
|
|
2027
2027
|
var { className, placeholder = "Search", value, widenInputOnFocus, showBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on" } = _a, rest = __rest(_a, ["className", "placeholder", "value", "widenInputOnFocus", "showBorderWhenNotInFocus", "disabled", "onKeyUp", "onChange", "onFocus", "onBlur", "name", "onClear", "dataTestId", "autoComplete"]);
|
|
2028
|
-
return (jsxRuntime.jsx(TextInput, Object.assign({}, rest, {
|
|
2028
|
+
return (jsxRuntime.jsx(TextInput, Object.assign({}, rest, { autoComplete: autoComplete, className: cvaSearch({ className, border: showBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix: onClear ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId && `${dataTestId}_suffix_component`, onClick: () => {
|
|
2029
2029
|
onClear();
|
|
2030
|
-
}, children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value
|
|
2030
|
+
}, children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value })));
|
|
2031
2031
|
});
|
|
2032
2032
|
|
|
2033
2033
|
const cvaTextArea = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -2069,7 +2069,7 @@ const cvaTextArea = cssClassVarianceUtilities.cvaMerge([
|
|
|
2069
2069
|
*/
|
|
2070
2070
|
const TextArea = React__namespace.forwardRef((_a, ref) => {
|
|
2071
2071
|
var { id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, dataTestId, isInvalid, className } = _a, rest = __rest(_a, ["id", "name", "value", "rows", "disabled", "placeholder", "readOnly", "tabIndex", "onChange", "onFocus", "onBlur", "maxLength", "resize", "defaultValue", "required", "dataTestId", "isInvalid", "className"]);
|
|
2072
|
-
return (jsxRuntime.jsx("textarea", Object.assign({
|
|
2072
|
+
return (jsxRuntime.jsx("textarea", Object.assign({ className: cvaTextArea({ 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 })));
|
|
2073
2073
|
});
|
|
2074
2074
|
|
|
2075
2075
|
/**
|
|
@@ -2094,8 +2094,8 @@ const TextAreaField = React__namespace.forwardRef((_a, ref) => {
|
|
|
2094
2094
|
onChange(event);
|
|
2095
2095
|
}
|
|
2096
2096
|
}, [onChange]);
|
|
2097
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2098
|
-
(maxLength !== null && maxLength !== undefined && (jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))),
|
|
2097
|
+
return (jsxRuntime.jsx(FormGroup, { className: `${className} grid grid-rows-[auto_1fr_auto]`, dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon ||
|
|
2098
|
+
(maxLength !== null && maxLength !== undefined && (jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TextArea, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: "h-auto", dataTestId: dataTestId, onChange: handleChange })) }));
|
|
2099
2099
|
});
|
|
2100
2100
|
|
|
2101
2101
|
/**
|
|
@@ -2116,8 +2116,8 @@ const TextField = React__namespace.forwardRef((_a, ref) => {
|
|
|
2116
2116
|
onChange(event);
|
|
2117
2117
|
}
|
|
2118
2118
|
}, [onChange]);
|
|
2119
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2120
|
-
(maxLength !== null && maxLength !== undefined && (jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))),
|
|
2119
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon ||
|
|
2120
|
+
(maxLength !== null && maxLength !== undefined && (jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TextInput, Object.assign({ "aria-labelledby": htmlFor + "-label", disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId, onChange: handleChange })) }));
|
|
2121
2121
|
});
|
|
2122
2122
|
|
|
2123
2123
|
/**
|
|
@@ -2130,7 +2130,7 @@ const TimeRangeField = (_a) => {
|
|
|
2130
2130
|
var { className, dataTestId, onChange, isInvalid, errorMessage, label, tip, disabled, children, helpText, id } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "isInvalid", "errorMessage", "label", "tip", "disabled", "children", "helpText", "id"]);
|
|
2131
2131
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2132
2132
|
const htmlFor = id ? id : "timeRangeField-" + uuid.v4();
|
|
2133
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2133
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: disabled, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TimeRange, Object.assign({ className: className, dataTestId: dataTestId, disabled: disabled, isInvalid: renderAsInvalid, onChange: onChange }, rest, { children: children })) }));
|
|
2134
2134
|
};
|
|
2135
2135
|
|
|
2136
2136
|
const cvaToggleWrapper = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2", "items-center"]);
|
|
@@ -2205,10 +2205,10 @@ const Toggle = React__namespace.forwardRef(({ toggled = false, onChange, onClick
|
|
|
2205
2205
|
const showLabelContainer = Boolean(name || description);
|
|
2206
2206
|
const showDescription = Boolean(description);
|
|
2207
2207
|
const getTestId = (suffix) => `${dataTestId}-${suffix}`;
|
|
2208
|
-
return (jsxRuntime.jsx("span", { className: className,
|
|
2208
|
+
return (jsxRuntime.jsx("span", { className: className, "data-testid": getTestId("outer-wrapper"), onClick: onClick, children: jsxRuntime.jsxs("label", { className: cvaToggleWrapper(), "data-testid": getTestId("wrapper"), htmlFor: id, children: [jsxRuntime.jsx("span", { className: cvaToggleTrack({ disabled, size, toggled }), "data-testid": getTestId("track"), children: jsxRuntime.jsx("span", { className: cvaToggleThumb({ toggled }), "data-testid": getTestId("thumb") }) }), showLabelContainer && (jsxRuntime.jsxs("span", { className: cvaToggleLabelContainer(), "data-testid": getTestId("label-container"), children: [jsxRuntime.jsx(Label, { className: cvaToggleLabel(), "data-testid": getTestId("label"), disabled: disabled, children: name }), showDescription && (jsxRuntime.jsx("span", { className: cvaToggleDescription({ disabled }), "data-testid": getTestId("description"), children: description }))] })), jsxRuntime.jsx("input", { "aria-checked": toggled, checked: toggled, className: cvaToggleInput(), "data-testid": getTestId("input"), disabled: disabled, id: id, name: name, onBlur: onBlur, onChange: e => {
|
|
2209
2209
|
e.stopPropagation();
|
|
2210
2210
|
onChange(!toggled, e);
|
|
2211
|
-
},
|
|
2211
|
+
}, ref: ref, required: required, tabIndex: tabIndex, type: "checkbox" })] }) }));
|
|
2212
2212
|
});
|
|
2213
2213
|
|
|
2214
2214
|
const cvaUploadInputField = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -2230,14 +2230,13 @@ const cvaUploadInputAddonBefore = cssClassVarianceUtilities.cvaMerge(["block", "
|
|
|
2230
2230
|
*/
|
|
2231
2231
|
const UploadInput = React.forwardRef((_a, ref) => {
|
|
2232
2232
|
var { disabled, acceptedTypes, nonInteractive, uploadLabel, multipleFiles } = _a, rest = __rest(_a, ["disabled", "acceptedTypes", "nonInteractive", "uploadLabel", "multipleFiles"]);
|
|
2233
|
-
return (jsxRuntime.jsx("label", { className: "tu-upload-input", children: jsxRuntime.jsx(BaseInput, Object.assign({
|
|
2234
|
-
|
|
2235
|
-
onClick: event => {
|
|
2233
|
+
return (jsxRuntime.jsx("label", { className: "tu-upload-input", children: jsxRuntime.jsx(BaseInput, Object.assign({ accept: acceptedTypes, addonBefore: uploadLabel, addonBeforeClassName: cvaUploadInputAddonBefore(), disabled: disabled, inputClassName: cvaUploadInputField(), multiple: multipleFiles, nonInteractive: nonInteractive, onClick: event => {
|
|
2234
|
+
// onClick used to work with nonInteractive option
|
|
2236
2235
|
if (nonInteractive) {
|
|
2237
2236
|
event.preventDefault();
|
|
2238
2237
|
event.stopPropagation();
|
|
2239
2238
|
}
|
|
2240
|
-
} }, rest)) }));
|
|
2239
|
+
}, ref: ref, type: "file" }, rest)) }));
|
|
2241
2240
|
});
|
|
2242
2241
|
|
|
2243
2242
|
/**
|
|
@@ -2247,7 +2246,7 @@ const UploadField = React.forwardRef((_a, ref) => {
|
|
|
2247
2246
|
var { label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
|
|
2248
2247
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2249
2248
|
const htmlForId = id ? id : "uploadField-" + uuid.v4();
|
|
2250
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2249
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(UploadInput, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
2251
2250
|
});
|
|
2252
2251
|
|
|
2253
2252
|
/**
|
|
@@ -2274,7 +2273,7 @@ const UrlInput = React.forwardRef((_a, ref) => {
|
|
|
2274
2273
|
var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction", "value", "defaultValue"]);
|
|
2275
2274
|
const [url, setUrl] = React.useState((value === null || value === void 0 ? void 0 : value.toString()) || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()));
|
|
2276
2275
|
const renderAsInvalid = (url && typeof url === "string" && !validateUrlAddress(url)) || isInvalid;
|
|
2277
|
-
return (jsxRuntime.jsx(BaseInput, Object.assign({
|
|
2276
|
+
return (jsxRuntime.jsx(BaseInput, Object.assign({ dataTestId: dataTestId && `${dataTestId}-url-input`, 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, { dataTestId: (dataTestId && `${dataTestId}-url-input-Icon`) || "url-input-action-icon", disabled: renderAsInvalid || disabled, iconSize: fieldSize, type: "WEB_ADDRESS", value: url })) })));
|
|
2278
2277
|
});
|
|
2279
2278
|
|
|
2280
2279
|
/**
|
|
@@ -2290,7 +2289,7 @@ const UrlField = React.forwardRef((_a, ref) => {
|
|
|
2290
2289
|
return typeof inputValue === "string";
|
|
2291
2290
|
}
|
|
2292
2291
|
const renderAsInvalid = !!errorMessage || (value && isString(value) && !validateUrlAddress(value)) || isInvalid;
|
|
2293
|
-
return (jsxRuntime.jsx(FormGroup, {
|
|
2292
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: renderAsInvalid ? errorMessage : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(UrlInput, Object.assign({ "aria-labelledby": htmlForId + "-label", disabled: rest.disabled, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, value: value || defaultValue }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
2294
2293
|
});
|
|
2295
2294
|
|
|
2296
2295
|
/*
|
package/index.esm.js
CHANGED
|
@@ -139,7 +139,7 @@ const cvaLabel = cvaMerge([
|
|
|
139
139
|
* @returns {JSX.Element} Label component
|
|
140
140
|
*/
|
|
141
141
|
const Label = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
|
|
142
|
-
return (jsx("label", {
|
|
142
|
+
return (jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", children: children }));
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
const cvaFormGroup = cvaMerge(["component-formGroup-gap"], {
|
|
@@ -290,7 +290,7 @@ const getOrderedOptions = (options, value) => {
|
|
|
290
290
|
* @returns {JSX.Element} CheckIcon component
|
|
291
291
|
*/
|
|
292
292
|
const CheckIcon = ({ className, dataTestId }) => {
|
|
293
|
-
return (jsx("svg", {
|
|
293
|
+
return (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: jsx("path", { d: "m2 5.5 2 2L8.5 3", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
294
294
|
};
|
|
295
295
|
|
|
296
296
|
const cvaCheckbox = cvaMerge([
|
|
@@ -423,7 +423,7 @@ const cvaCheckboxIcon = cvaMerge(["w-2.5", "h-2.5", "text-white"]);
|
|
|
423
423
|
* @param {IndeterminateIconProps} props - The props for the IndeterminateIcon component
|
|
424
424
|
* @returns {JSX.Element} IndeterminateIcon component
|
|
425
425
|
*/
|
|
426
|
-
const IndeterminateIcon = ({ className }) => (jsx("svg", {
|
|
426
|
+
const IndeterminateIcon = ({ className }) => (jsx("svg", { className: className, fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 10 10", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M3 5h4", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
427
427
|
|
|
428
428
|
/**
|
|
429
429
|
* Checkboxes are used when there are multiple items to select in a list. Users can select zero, one, or any number of items.
|
|
@@ -459,15 +459,15 @@ const Checkbox = React.forwardRef((_a, ref) => {
|
|
|
459
459
|
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
460
460
|
}, [labelRef, onLabelRefChange]);
|
|
461
461
|
const uuid = rest.id;
|
|
462
|
-
return (jsxs("label", { "data-testid": dataTestId && `${dataTestId}-container`, htmlFor: uuid,
|
|
462
|
+
return (jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId && `${dataTestId}-container`, htmlFor: uuid, onClick: e => stopPropagation && e.stopPropagation(), onKeyDown: onKeyPress, ref: internalRef, children: [jsx("input", Object.assign({ "aria-checked": !indeterminate && checked, checked: !indeterminate && checked, className: cvaCheckboxInput(), "data-testid": dataTestId, disabled: disabled, id: uuid, onChange: onChange, readOnly: readOnly, type: "checkbox" }, rest, { ref: ref })), jsx("span", { className: cvaCheckbox({
|
|
463
463
|
disabled: isReadonly,
|
|
464
464
|
invalid: isReadonly ? false : isInvalid,
|
|
465
465
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
466
|
-
}), children: icon }), label && (jsx("span", { className: "flex", children: jsx("span", {
|
|
466
|
+
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label && (jsx("span", { className: "flex", children: jsx("span", { className: cvaLabel({
|
|
467
467
|
invalid: isReadonly ? false : isInvalid,
|
|
468
468
|
disabled: isReadonly,
|
|
469
469
|
className: "cursor-pointer",
|
|
470
|
-
}), children: label }) })), suffix] }));
|
|
470
|
+
}), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })), suffix] }));
|
|
471
471
|
});
|
|
472
472
|
|
|
473
473
|
/**
|
|
@@ -477,7 +477,7 @@ const Checkbox = React.forwardRef((_a, ref) => {
|
|
|
477
477
|
* @returns {JSX.Element} SingleSelectMenuItem
|
|
478
478
|
*/
|
|
479
479
|
const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focused, disabled, }) => {
|
|
480
|
-
return (jsx(MenuItem, { dataTestId: dataTestId,
|
|
480
|
+
return (jsx(MenuItem, { dataTestId: dataTestId, disabled: disabled, focused: focused, label: label, onClick: onClick, prefix: icon, selected: selected, suffix: selected ? jsx(Icon, { name: "Check", size: "small" }) : undefined }));
|
|
481
481
|
};
|
|
482
482
|
/**
|
|
483
483
|
* A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
|
|
@@ -486,12 +486,12 @@ const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focu
|
|
|
486
486
|
* @returns {JSX.Element} multi select menu item
|
|
487
487
|
*/
|
|
488
488
|
const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, focused, disabled, }) => {
|
|
489
|
-
return (jsx(MenuItem, { dataTestId: dataTestId,
|
|
490
|
-
e.stopPropagation();
|
|
491
|
-
} }), onClick: e => {
|
|
489
|
+
return (jsx(MenuItem, { dataTestId: dataTestId, disabled: disabled, focused: focused, label: label, onClick: e => {
|
|
492
490
|
e.stopPropagation();
|
|
493
491
|
onClick && onClick(e);
|
|
494
|
-
},
|
|
492
|
+
}, prefix: jsx(Checkbox, { checked: selected, disabled: disabled, onChange: () => null, onClick: e => {
|
|
493
|
+
e.stopPropagation();
|
|
494
|
+
}, readOnly: false }), selected: selected }));
|
|
495
495
|
};
|
|
496
496
|
|
|
497
497
|
/**
|
|
@@ -548,17 +548,17 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
548
548
|
const isLast = index === items.length;
|
|
549
549
|
const counterRequired = requiredSpace > availableSpace && counter !== 0;
|
|
550
550
|
if (isLast && counterRequired) {
|
|
551
|
-
return (jsx(TagWithWidth, { onWidthKnown: ({ width: reportedWidth }) => setCounterWidth(reportedWidth),
|
|
551
|
+
return (jsx(TagWithWidth, { color: "white", disabled: disabled, onWidthKnown: ({ width: reportedWidth }) => setCounterWidth(reportedWidth), children: jsxs("div", { className: cvaSelectCounter(), "data-testid": "select-counter", children: ["+", counter] }) }, item.text + index));
|
|
552
552
|
}
|
|
553
553
|
if (isLast) {
|
|
554
554
|
return null;
|
|
555
555
|
}
|
|
556
556
|
const itemCanFit = spaceNeeded <= availableSpace;
|
|
557
557
|
if (itemCanFit) {
|
|
558
|
-
return (jsx(TagWithWidth, {
|
|
558
|
+
return (jsx(TagWithWidth, { className: "inline-flex shrink-0", color: item.disabled ? "unknown" : "primary", dataTestId: `${item.text}-tag`, disabled: disabled, onClose: e => {
|
|
559
559
|
e.stopPropagation();
|
|
560
560
|
item.onClick();
|
|
561
|
-
},
|
|
561
|
+
}, onWidthKnown: onWidthKnownHandler, children: item.text }, item.text + index));
|
|
562
562
|
}
|
|
563
563
|
const fromTheItems = item.text !== "";
|
|
564
564
|
if (fromTheItems) {
|
|
@@ -567,9 +567,9 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
567
567
|
return null;
|
|
568
568
|
})
|
|
569
569
|
.filter(element => element !== null);
|
|
570
|
-
return (jsxs("div", { style: {
|
|
570
|
+
return (jsxs("div", { className: cvaSelectDynamicTagContainer({ visible: isReady }), ref: containerRef, style: {
|
|
571
571
|
width: `${width}`,
|
|
572
|
-
},
|
|
572
|
+
}, children: [renderedElements, postFix] }));
|
|
573
573
|
};
|
|
574
574
|
|
|
575
575
|
/**
|
|
@@ -598,7 +598,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
598
598
|
const values = props && props.children ? props.children[0] : [];
|
|
599
599
|
const tags = key === PLACEHOLDER_KEY ? [] : values;
|
|
600
600
|
const searchInput = props && props.children && props.children[1];
|
|
601
|
-
return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsx(TagsContainer, {
|
|
601
|
+
return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsx(TagsContainer, { disabled: disabled, items: tags
|
|
602
602
|
? tags.map(({ props: tagProps }) => {
|
|
603
603
|
return {
|
|
604
604
|
text: tagProps.children,
|
|
@@ -612,20 +612,20 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
612
612
|
disabled: disabled,
|
|
613
613
|
};
|
|
614
614
|
})
|
|
615
|
-
: [], postFix: searchInput,
|
|
615
|
+
: [], postFix: searchInput, width: "100%" })) : (jsxs(Fragment, { children: [tags &&
|
|
616
616
|
tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
|
|
617
617
|
var _a, _b;
|
|
618
|
-
return (jsx(Tag, { className: "inline-flex shrink-0", onClose: e => {
|
|
618
|
+
return (jsx(Tag, { className: "inline-flex shrink-0", color: disabled ? "unknown" : "primary", dataTestId: tagProps.children ? `${(_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()}-tag` : undefined, onClose: e => {
|
|
619
619
|
var _a, _b;
|
|
620
620
|
e.stopPropagation();
|
|
621
621
|
refMenuIsEnabled.current = false;
|
|
622
622
|
((_a = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _a === void 0 ? void 0 : _a.onClick) && ((_b = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _b === void 0 ? void 0 : _b.onClick(e));
|
|
623
|
-
},
|
|
623
|
+
}, children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
624
624
|
}), tags && tags.length > maxSelectedDisplayCount && (jsxs(Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
|
|
625
625
|
}
|
|
626
626
|
return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: props.children })));
|
|
627
627
|
}, LoadingIndicator: props => {
|
|
628
|
-
return jsx(Spinner, {
|
|
628
|
+
return jsx(Spinner, { className: "mt-1.5 mr-1", size: "small" });
|
|
629
629
|
}, DropdownIndicator: props => {
|
|
630
630
|
const icon = props.selectProps.menuIsOpen ? (jsx(Icon, { name: "ChevronUp", size: "medium" })) : (jsx(Icon, { name: "ChevronDown", size: "medium" }));
|
|
631
631
|
return props.selectProps.isLoading ? null : (jsx(components.DropdownIndicator, Object.assign({}, props, { children: jsx("div", { className: cvaSelectIcon(), children: dropdownIcon ? dropdownIcon : icon }) })));
|
|
@@ -633,7 +633,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
633
633
|
if (disabled) {
|
|
634
634
|
return null;
|
|
635
635
|
}
|
|
636
|
-
return (jsx(components.ClearIndicator, Object.assign({}, props, { children: jsx("div", { className: cvaSelectXIcon(),
|
|
636
|
+
return (jsx(components.ClearIndicator, Object.assign({}, props, { children: jsx("div", { className: cvaSelectXIcon(), "data-testid": dataTestId && `${dataTestId}-XMarkIcon`, onClick: props.clearValue, children: jsx(Icon, { name: "XCircle", size: "medium", title: t("clearIndicator.icon.tooltip.clearAll") }) }) })));
|
|
637
637
|
}, Control: props => {
|
|
638
638
|
return jsx(components.Control, Object.assign({}, props, { className: props.isDisabled ? "bg-slate-100" : "" }));
|
|
639
639
|
}, SingleValue: props => {
|
|
@@ -654,7 +654,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
654
654
|
selected: props.isSelected,
|
|
655
655
|
onClick: props.innerProps.onClick,
|
|
656
656
|
};
|
|
657
|
-
return (jsx(components.Option, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { role: "option", onClick: () => { } }), children: props.isMulti ? (jsx(MultiSelectMenuItem, Object.assign({}, componentProps, {
|
|
657
|
+
return (jsx(components.Option, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { role: "option", onClick: () => { } }), children: props.isMulti ? (jsx(MultiSelectMenuItem, Object.assign({}, componentProps, { dataTestId: typeof props.label === "string" ? props.label : undefined, disabled: disabled }))) : (jsx(SingleSelectMenuItem, Object.assign({}, componentProps, { dataTestId: typeof props.label === "string" ? props.label : undefined, disabled: disabled || props.isDisabled }))) })));
|
|
658
658
|
} }, componentsProps);
|
|
659
659
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
660
660
|
}, [componentsProps, disabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
|
|
@@ -778,15 +778,15 @@ const CreatableSelect = (props) => {
|
|
|
778
778
|
isClearable,
|
|
779
779
|
id,
|
|
780
780
|
};
|
|
781
|
-
return (jsx(SelectContainer, {
|
|
782
|
-
!disabled && openMenuHandler();
|
|
783
|
-
}, onMenuClose: () => {
|
|
781
|
+
return (jsx(SelectContainer, { dataTestId: dataTestId, description: description, error: error, hasError: hasError, hideLabel: hideLabel, id: id, info: info, isDisabled: disabled, label: label, children: jsxs(Fragment, { children: [prefix !== undefined && (jsx("div", { className: cvaSelectPrefix(), "data-testid": dataTestId && `${dataTestId}-prefix`, ref: refPrefix, children: prefix })), async ? (jsx(ReactAsyncCreatableSelect, Object.assign({ "aria-label": label, components: customComponents, "data-testid": dataTestId, maxMenuHeight: maxMenuHeight }, props, { onMenuClose: () => {
|
|
784
782
|
closeMenuHandler();
|
|
785
|
-
}
|
|
783
|
+
}, onMenuOpen: () => {
|
|
786
784
|
!disabled && openMenuHandler();
|
|
787
|
-
}, onMenuClose: () => {
|
|
785
|
+
} }))) : (jsx(ReactCreatableSelect, Object.assign({}, selectProps, { isMulti: isMulti, onMenuClose: () => {
|
|
788
786
|
closeMenuHandler();
|
|
789
|
-
}
|
|
787
|
+
}, onMenuOpen: () => {
|
|
788
|
+
!disabled && openMenuHandler();
|
|
789
|
+
}, options: filterOption ? orderedOptions : options })))] }) }));
|
|
790
790
|
};
|
|
791
791
|
|
|
792
792
|
/**
|
|
@@ -826,7 +826,7 @@ const Select = (props) => {
|
|
|
826
826
|
onMenuScrollToBottom,
|
|
827
827
|
onInputChange,
|
|
828
828
|
};
|
|
829
|
-
return (jsxs("div", {
|
|
829
|
+
return (jsxs("div", { className: cvaSelect({ invalid: hasError, disabled: disabled || readOnly, className }), "data-testid": dataTestId, ref: refContainer, children: [prefix !== undefined && (jsx("div", { className: cvaSelectPrefix(), "data-testid": dataTestId && `${dataTestId}-prefix`, ref: refPrefix, children: prefix })), async ? (jsx(ReactAsyncSelect, Object.assign({}, propsNoClassName, selectProps, async, { onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler }))) : (jsx(ReactSelect, Object.assign({}, propsNoClassName, selectProps, { hideSelectedOptions: false, isMulti: isMulti, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options })))] }));
|
|
830
830
|
};
|
|
831
831
|
Select.displayName = "Select";
|
|
832
832
|
|
|
@@ -938,7 +938,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, key, classN
|
|
|
938
938
|
if (ButtonAction === null) {
|
|
939
939
|
return null;
|
|
940
940
|
}
|
|
941
|
-
return (jsx("div", { className: cvaActionContainer({ className }), children: jsx(IconButton, {
|
|
941
|
+
return (jsx("div", { className: cvaActionContainer({ className }), children: jsx(IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsx(Icon, { name: getIconName(), size: "small" }), onClick: ButtonAction, size: "small", variant: "secondary" }) }, elementKey));
|
|
942
942
|
};
|
|
943
943
|
|
|
944
944
|
const cvaInputBase = cvaMerge([
|
|
@@ -1051,7 +1051,7 @@ const BaseInput = React.forwardRef((_a, ref) => {
|
|
|
1051
1051
|
className,
|
|
1052
1052
|
}), "data-testid": dataTestId && `${dataTestId}-container`, children: [addonBefore && addonBefore !== undefined ? (jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId && `${dataTestId}-addonBefore`, children: addonBefore })) : null, prefix && addonBefore !== prefix ? (jsx("div", { className: cvaInputPrefix({
|
|
1053
1053
|
disabled: renderAsDisabled,
|
|
1054
|
-
}), "data-testid": dataTestId && `${dataTestId}-prefix`, children: prefix })) : null, jsx("input", Object.assign({
|
|
1054
|
+
}), "data-testid": dataTestId && `${dataTestId}-prefix`, children: prefix })) : null, jsx("input", Object.assign({ className: cvaInputField({ size: fieldSize, disabled: renderAsDisabled, className: inputClassName }), "data-testid": dataTestId, ref: innerRef, type: isReadOnlyWithPlaceholder ? "text" : type }, rest, { readOnly: rest.readOnly || nonInteractive })), suffix && addonBefore !== suffix ? (jsx("div", { className: cvaInputSuffix({
|
|
1055
1055
|
disabled: renderAsDisabled,
|
|
1056
1056
|
}), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix })) : null, rest.readOnly === true && showDefaultActions ? (jsx(ActionButton, { type: "COPY", value: innerRef }, "default-copy-action")) : null, actions && addonBefore !== actions ? actions : null, addonAfter && addonAfter !== undefined && addonBefore !== addonAfter ? (jsx("div", { className: cvaInputAddonAfter(), "data-testid": dataTestId && `${dataTestId}-addonAfter`, children: addonAfter })) : null] }));
|
|
1057
1057
|
});
|
|
@@ -1066,7 +1066,7 @@ const DateInput = forwardRef((_a, ref) => {
|
|
|
1066
1066
|
const formatDateToInputString = (date) => date instanceof Date ? format(date, "yyyy-MM-dd") : date;
|
|
1067
1067
|
// Chrome and Firefox need their default icon to have datepicker functionality.
|
|
1068
1068
|
const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
|
|
1069
|
-
return (jsx(BaseInput, Object.assign({
|
|
1069
|
+
return (jsx(BaseInput, Object.assign({ defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon && jsx(Icon, { dataTestId: "calendar", name: "Calendar", size: "medium", type: "solid" }), type: "date", value: formatDateToInputString(value) }, rest)));
|
|
1070
1070
|
});
|
|
1071
1071
|
|
|
1072
1072
|
/**
|
|
@@ -1080,7 +1080,7 @@ const DateField = forwardRef((_a, ref) => {
|
|
|
1080
1080
|
var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
|
|
1081
1081
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1082
1082
|
const htmlForId = id ? id : "dateField-" + v4();
|
|
1083
|
-
return (jsx(FormGroup, {
|
|
1083
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(DateInput, Object.assign({ "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
1084
1084
|
});
|
|
1085
1085
|
|
|
1086
1086
|
const cvaDropZone = cvaMerge([
|
|
@@ -1161,12 +1161,12 @@ const DropZone = (_a) => {
|
|
|
1161
1161
|
setFileDropped(true);
|
|
1162
1162
|
}
|
|
1163
1163
|
};
|
|
1164
|
-
return (jsxs("div", Object.assign({ className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId,
|
|
1164
|
+
return (jsxs("div", Object.assign({ className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId, onClick: e => {
|
|
1165
1165
|
if (disabled) {
|
|
1166
1166
|
e.preventDefault();
|
|
1167
1167
|
e.stopPropagation();
|
|
1168
1168
|
}
|
|
1169
|
-
} }, rest, { children: [jsx("input", {
|
|
1169
|
+
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop }, rest, { children: [jsx("input", { className: "hidden", id: "input-file-upload", onChange: handleChange, title: "Hidden File Input", type: "file" }), jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId && `${dataTestId}-label`, htmlFor: "input-file-upload", children: [jsx(Icon, { color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", style: !isInvalid ? { color: "rgb(156 163 175)" } : {}, type: "solid" }), jsx("span", { children: label })] })] })));
|
|
1170
1170
|
};
|
|
1171
1171
|
|
|
1172
1172
|
// Doing the same check as we do on the backend
|
|
@@ -1202,7 +1202,7 @@ const EmailInput = React.forwardRef((_a, ref) => {
|
|
|
1202
1202
|
return window.open(`mailto:${email}`);
|
|
1203
1203
|
};
|
|
1204
1204
|
const renderAsInvalid = (email && !validateEmailAddress(email)) || isInvalid;
|
|
1205
|
-
return (jsx(BaseInput, Object.assign({ dataTestId: dataTestId,
|
|
1205
|
+
return (jsx(BaseInput, Object.assign({ actions: jsx(ActionButton, { dataTestId: dataTestId && `${dataTestId}-emailIcon`, disabled: disabled, iconSize: fieldSize, onClick: sendEmail, type: "EMAIL", value: email }), dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: e => setEmail(e.target.value), placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email" }, rest)));
|
|
1206
1206
|
});
|
|
1207
1207
|
|
|
1208
1208
|
/**
|
|
@@ -1223,7 +1223,7 @@ const EmailField = forwardRef((_a, ref) => {
|
|
|
1223
1223
|
onChange(event);
|
|
1224
1224
|
}
|
|
1225
1225
|
}, [onChange]);
|
|
1226
|
-
return (jsx(FormGroup, {
|
|
1226
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(EmailInput, Object.assign({ "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, disabled: renderAsInvalid, id: htmlForId, isInvalid: renderAsInvalid, onChange: handleChange, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
1227
1227
|
});
|
|
1228
1228
|
|
|
1229
1229
|
/**
|
|
@@ -1246,7 +1246,7 @@ const NumberField = forwardRef((_a, ref) => {
|
|
|
1246
1246
|
var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
|
|
1247
1247
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1248
1248
|
const htmlForId = id ? id : "numberField-" + v4();
|
|
1249
|
-
return (jsx(FormGroup, {
|
|
1249
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(NumberInput, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
1250
1250
|
});
|
|
1251
1251
|
|
|
1252
1252
|
const cvaOptionCardLabel = cvaMerge([
|
|
@@ -1281,7 +1281,7 @@ const cvaOptionCardContainer = cvaMerge(["contents"]);
|
|
|
1281
1281
|
const OptionCard = forwardRef((_a, ref) => {
|
|
1282
1282
|
var { icon, heading, subheading, description, disabled, id, value, className, dataTestId } = _a, rest = __rest(_a, ["icon", "heading", "subheading", "description", "disabled", "id", "value", "className", "dataTestId"]);
|
|
1283
1283
|
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" + v4();
|
|
1284
|
-
return (jsxs("div", { "data-testid": dataTestId,
|
|
1284
|
+
return (jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsx("input", Object.assign({ className: "peer hidden", id: htmlForId, ref: ref, type: "radio", value: value }, rest)), jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), htmlFor: htmlForId, children: [disabled && icon && cloneElement(icon, { className: `${icon.props.className} text-secondary-400` }), !disabled && icon, heading && (jsx(Heading, { subtle: disabled, variant: "secondary", children: heading })), (subheading || description) && (jsxs("div", { className: cvaOptionCardContent(), children: [subheading && (jsx(Text, { align: "center", subtle: disabled, type: "span", weight: "thick", children: subheading })), description && (jsx(Text, { align: "center", subtle: true, type: "span", children: description }))] }))] })] }));
|
|
1285
1285
|
});
|
|
1286
1286
|
|
|
1287
1287
|
/**
|
|
@@ -1306,7 +1306,7 @@ const PasswordField = forwardRef((_a, ref) => {
|
|
|
1306
1306
|
const handleChange = useCallback((event) => {
|
|
1307
1307
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1308
1308
|
}, [onChange]);
|
|
1309
|
-
return (jsx(FormGroup, {
|
|
1309
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(PasswordInput, Object.assign({}, rest, { actions: jsx(Icon, { className: "absolute top-0 bottom-0 right-2 h-full content-center", color: "neutral", name: showPassword ? "EyeSlash" : "Eye", onClick: () => setShowPassword(prevState => !prevState), size: "small" }), "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, type: showPassword ? "text" : "password", value: value })) }));
|
|
1310
1310
|
});
|
|
1311
1311
|
|
|
1312
1312
|
/**
|
|
@@ -1491,7 +1491,7 @@ const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, onChange
|
|
|
1491
1491
|
const filteredCodes = countryCodes.filter(code => {
|
|
1492
1492
|
return !(excludedCountries === null || excludedCountries === void 0 ? void 0 : excludedCountries.some(excludedCode => excludedCode.value === code.value));
|
|
1493
1493
|
});
|
|
1494
|
-
return (jsx(Select, {
|
|
1494
|
+
return (jsx(Select, { "aria-invalid": isCountryCodeMissing, className: "w-36", closeMenuOnSelect: true, dataTestId: dataTestId, disabled: disabled, hasError: isCountryCodeMissing || isInvalid, isClearable: isClearable, maxMenuHeight: 200, menuIsOpen: readOnly ? false : undefined, onBlur: onBlur, onChange: onChange, options: filteredCodes.map(code => code), placeholder: placeholder, readOnly: readOnly, value: filteredCodes.find(({ value }) => value === `+${countryCode}`) }));
|
|
1495
1495
|
};
|
|
1496
1496
|
|
|
1497
1497
|
/**
|
|
@@ -1562,16 +1562,16 @@ const PhoneInput = forwardRef((_a, ref) => {
|
|
|
1562
1562
|
// the event's type is inferred as Event, which doesn't have a target property, whereas ChangeEvent does.
|
|
1563
1563
|
onChange && onChange(event);
|
|
1564
1564
|
}, [phoneNumber, onChange]);
|
|
1565
|
-
return (jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx("input", {
|
|
1565
|
+
return (jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx("input", { "aria-invalid": isInvalid, "data-testid": dataTestId, hidden: true, id: "phone-input", onChange: onChange, readOnly: readOnly, ref: hiddenInputRef, value: phoneNumber }), jsx(CountryCodeSelect, { countryCode: code, dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, disabled: disabled, isClearable: isCountryCodeClearable, isInvalid: isInvalid, onBlur: e => {
|
|
1566
1566
|
onBlurHandler();
|
|
1567
1567
|
}, onChange: e => {
|
|
1568
1568
|
var _a;
|
|
1569
1569
|
onCodeChangeHandler((_a = e === null || e === void 0 ? void 0 : e.value) !== null && _a !== void 0 ? _a : "");
|
|
1570
|
-
},
|
|
1571
|
-
onPhoneChangeHandler(e.target.value);
|
|
1572
|
-
}, onBlur: () => {
|
|
1570
|
+
}, placeholder: placeholder, readOnly: readOnly }), jsx(BaseInput, Object.assign({ actions: !disableAction && (jsx(ActionButton, { dataTestId: dataTestId && `${dataTestId}-phoneIcon`, disabled: disabled || isInvalid, iconSize: fieldSize, type: "PHONE_NUMBER", value: phoneNumber })), dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, disabled: disabled, fieldSize: fieldSize, id: "phoneInput-number", isInvalid: isInvalid, onBlur: () => {
|
|
1573
1571
|
onBlurHandler();
|
|
1574
|
-
},
|
|
1572
|
+
}, onChange: e => {
|
|
1573
|
+
onPhoneChangeHandler(e.target.value);
|
|
1574
|
+
}, readOnly: readOnly, type: "tel", value: phone }, rest))] }));
|
|
1575
1575
|
});
|
|
1576
1576
|
|
|
1577
1577
|
/**
|
|
@@ -1649,7 +1649,7 @@ const PhoneField = forwardRef((_a, ref) => {
|
|
|
1649
1649
|
validate(phoneNumberValue);
|
|
1650
1650
|
onFieldsBlur && onFieldsBlur(Object.assign(Object.assign({}, phoneNumberValue), { isValid }));
|
|
1651
1651
|
};
|
|
1652
|
-
return (jsx(FormGroup, {
|
|
1652
|
+
return (jsx(FormGroup, { className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && (errorMessage || localError)) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(PhoneInput, Object.assign({ "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, onChangeValue: onChangeValueHandler, onFieldsBlur: handleOnFieldBlur, ref: ref, value: value }, rest)) }));
|
|
1653
1653
|
});
|
|
1654
1654
|
|
|
1655
1655
|
const cvaRadioGroup = cvaMerge(["flex", "gap-2", "flex-col", "items-start"], {
|
|
@@ -1764,7 +1764,7 @@ const RadioGroupContext = React.createContext(null);
|
|
|
1764
1764
|
* @returns {JSX.Element} RadioGroup component
|
|
1765
1765
|
*/
|
|
1766
1766
|
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
|
|
1767
|
-
return (jsx(FormGroup, {
|
|
1767
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, label: label, children: jsx("div", { className: cvaRadioGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, children: jsx(RadioGroupContext.Provider, { value: {
|
|
1768
1768
|
id,
|
|
1769
1769
|
value,
|
|
1770
1770
|
name: name || id,
|
|
@@ -1784,11 +1784,11 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
1784
1784
|
const RadioItem = ({ label, value, dataTestId, className, description, }) => {
|
|
1785
1785
|
const groupCtx = React.useContext(RadioGroupContext);
|
|
1786
1786
|
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
1787
|
-
return (jsxs("label", { className: cvaRadioItemWrapper({ className }),
|
|
1787
|
+
return (jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId && `${dataTestId}-Wrapper`, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: [jsx("input", { checked: isChecked, className: cvaRadioItem({
|
|
1788
1788
|
checked: isChecked,
|
|
1789
1789
|
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
1790
1790
|
invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
|
|
1791
|
-
}), onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, "
|
|
1791
|
+
}), "data-testid": dataTestId, id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, type: "radio", value: value }), jsxs("div", { className: cvaRadioItemLabelContainer(), children: [jsx(Label, { dataTestId: dataTestId && `${dataTestId}-Label`, disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, isInvalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid, children: label }), description && (jsx("label", { className: cvaRadioItemDescription({ disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }), "data-testid": dataTestId && `${dataTestId}-Description`, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: description }))] })] }));
|
|
1792
1792
|
};
|
|
1793
1793
|
|
|
1794
1794
|
const cvaTimeRange = cvaMerge(["flex", "flex-1", "items-center", "gap-4", "border-transparent", "rounded-md"]);
|
|
@@ -1812,7 +1812,7 @@ const TimeRange = ({ id, className, dataTestId, children, range, onChange, disab
|
|
|
1812
1812
|
setTimeRange(prev => (Object.assign(Object.assign({}, prev), { timeTo })));
|
|
1813
1813
|
};
|
|
1814
1814
|
const onRangeChange = () => onChange(timeRange);
|
|
1815
|
-
return (jsxs("div", {
|
|
1815
|
+
return (jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, children: [jsx(BaseInput, { dataTestId: `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: (_a = timeRange === null || timeRange === void 0 ? void 0 : timeRange.timeFrom) !== null && _a !== void 0 ? _a : "" }), children !== null && children !== void 0 ? children : jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsx(BaseInput, { dataTestId: `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: (_b = timeRange === null || timeRange === void 0 ? void 0 : timeRange.timeTo) !== null && _b !== void 0 ? _b : "" })] }));
|
|
1816
1816
|
};
|
|
1817
1817
|
|
|
1818
1818
|
const cvaScheduleItem = cvaMerge(["grid", "pb-4", "gap-2", "grid-cols-[60px,200px,60px,2fr]"]);
|
|
@@ -1838,8 +1838,8 @@ const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = []
|
|
|
1838
1838
|
? Object.assign(Object.assign({}, day), { range: { timeFrom: "", timeTo: "" }, isAllDayActive: isAllDayChecked }) : day);
|
|
1839
1839
|
onChange(newSchedule);
|
|
1840
1840
|
};
|
|
1841
|
-
return (jsx("div", { "data-testid": dataTestId,
|
|
1842
|
-
return (jsxs("div", { className: cvaScheduleItem(), children: [jsx(Checkbox, { dataTestId: `${dataTestId}-${key}-checkbox`,
|
|
1841
|
+
return (jsx("div", { className: className, "data-testid": dataTestId, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDayActive }, index) => {
|
|
1842
|
+
return (jsxs("div", { className: cvaScheduleItem(), children: [jsx(Checkbox, { checked: isActive, dataTestId: `${dataTestId}-${key}-checkbox`, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsx(Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsx(Checkbox, { checked: isAllDayActive && isActive, dataTestId: `${dataTestId}-${key}-allday-checkbox`, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsx(TimeRange, { dataTestId: `${dataTestId}-${key}-range`, disabled: !isActive || isAllDayActive, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: range })] }, key));
|
|
1843
1843
|
}) }));
|
|
1844
1844
|
};
|
|
1845
1845
|
|
|
@@ -1995,9 +1995,9 @@ const cvaSearch = cvaMerge([
|
|
|
1995
1995
|
*/
|
|
1996
1996
|
const Search = forwardRef((_a, ref) => {
|
|
1997
1997
|
var { className, placeholder = "Search", value, widenInputOnFocus, showBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on" } = _a, rest = __rest(_a, ["className", "placeholder", "value", "widenInputOnFocus", "showBorderWhenNotInFocus", "disabled", "onKeyUp", "onChange", "onFocus", "onBlur", "name", "onClear", "dataTestId", "autoComplete"]);
|
|
1998
|
-
return (jsx(TextInput, Object.assign({}, rest, {
|
|
1998
|
+
return (jsx(TextInput, Object.assign({}, rest, { autoComplete: autoComplete, className: cvaSearch({ className, border: showBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsx(Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix: onClear ? (jsx("button", { className: "flex", "data-testid": dataTestId && `${dataTestId}_suffix_component`, onClick: () => {
|
|
1999
1999
|
onClear();
|
|
2000
|
-
}, children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value
|
|
2000
|
+
}, children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value })));
|
|
2001
2001
|
});
|
|
2002
2002
|
|
|
2003
2003
|
const cvaTextArea = cvaMerge([
|
|
@@ -2039,7 +2039,7 @@ const cvaTextArea = cvaMerge([
|
|
|
2039
2039
|
*/
|
|
2040
2040
|
const TextArea = React.forwardRef((_a, ref) => {
|
|
2041
2041
|
var { id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, dataTestId, isInvalid, className } = _a, rest = __rest(_a, ["id", "name", "value", "rows", "disabled", "placeholder", "readOnly", "tabIndex", "onChange", "onFocus", "onBlur", "maxLength", "resize", "defaultValue", "required", "dataTestId", "isInvalid", "className"]);
|
|
2042
|
-
return (jsx("textarea", Object.assign({
|
|
2042
|
+
return (jsx("textarea", Object.assign({ className: cvaTextArea({ 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 })));
|
|
2043
2043
|
});
|
|
2044
2044
|
|
|
2045
2045
|
/**
|
|
@@ -2064,8 +2064,8 @@ const TextAreaField = React.forwardRef((_a, ref) => {
|
|
|
2064
2064
|
onChange(event);
|
|
2065
2065
|
}
|
|
2066
2066
|
}, [onChange]);
|
|
2067
|
-
return (jsx(FormGroup, {
|
|
2068
|
-
(maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))),
|
|
2067
|
+
return (jsx(FormGroup, { className: `${className} grid grid-rows-[auto_1fr_auto]`, dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon ||
|
|
2068
|
+
(maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(TextArea, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: "h-auto", dataTestId: dataTestId, onChange: handleChange })) }));
|
|
2069
2069
|
});
|
|
2070
2070
|
|
|
2071
2071
|
/**
|
|
@@ -2086,8 +2086,8 @@ const TextField = React.forwardRef((_a, ref) => {
|
|
|
2086
2086
|
onChange(event);
|
|
2087
2087
|
}
|
|
2088
2088
|
}, [onChange]);
|
|
2089
|
-
return (jsx(FormGroup, {
|
|
2090
|
-
(maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))),
|
|
2089
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon ||
|
|
2090
|
+
(maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(TextInput, Object.assign({ "aria-labelledby": htmlFor + "-label", disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId, onChange: handleChange })) }));
|
|
2091
2091
|
});
|
|
2092
2092
|
|
|
2093
2093
|
/**
|
|
@@ -2100,7 +2100,7 @@ const TimeRangeField = (_a) => {
|
|
|
2100
2100
|
var { className, dataTestId, onChange, isInvalid, errorMessage, label, tip, disabled, children, helpText, id } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "isInvalid", "errorMessage", "label", "tip", "disabled", "children", "helpText", "id"]);
|
|
2101
2101
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2102
2102
|
const htmlFor = id ? id : "timeRangeField-" + v4();
|
|
2103
|
-
return (jsx(FormGroup, {
|
|
2103
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: disabled, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(TimeRange, Object.assign({ className: className, dataTestId: dataTestId, disabled: disabled, isInvalid: renderAsInvalid, onChange: onChange }, rest, { children: children })) }));
|
|
2104
2104
|
};
|
|
2105
2105
|
|
|
2106
2106
|
const cvaToggleWrapper = cvaMerge(["flex", "gap-2", "items-center"]);
|
|
@@ -2175,10 +2175,10 @@ const Toggle = React.forwardRef(({ toggled = false, onChange, onClick, disabled,
|
|
|
2175
2175
|
const showLabelContainer = Boolean(name || description);
|
|
2176
2176
|
const showDescription = Boolean(description);
|
|
2177
2177
|
const getTestId = (suffix) => `${dataTestId}-${suffix}`;
|
|
2178
|
-
return (jsx("span", { className: className,
|
|
2178
|
+
return (jsx("span", { className: className, "data-testid": getTestId("outer-wrapper"), onClick: onClick, children: jsxs("label", { className: cvaToggleWrapper(), "data-testid": getTestId("wrapper"), htmlFor: id, children: [jsx("span", { className: cvaToggleTrack({ disabled, size, toggled }), "data-testid": getTestId("track"), children: jsx("span", { className: cvaToggleThumb({ toggled }), "data-testid": getTestId("thumb") }) }), showLabelContainer && (jsxs("span", { className: cvaToggleLabelContainer(), "data-testid": getTestId("label-container"), children: [jsx(Label, { className: cvaToggleLabel(), "data-testid": getTestId("label"), disabled: disabled, children: name }), showDescription && (jsx("span", { className: cvaToggleDescription({ disabled }), "data-testid": getTestId("description"), children: description }))] })), jsx("input", { "aria-checked": toggled, checked: toggled, className: cvaToggleInput(), "data-testid": getTestId("input"), disabled: disabled, id: id, name: name, onBlur: onBlur, onChange: e => {
|
|
2179
2179
|
e.stopPropagation();
|
|
2180
2180
|
onChange(!toggled, e);
|
|
2181
|
-
},
|
|
2181
|
+
}, ref: ref, required: required, tabIndex: tabIndex, type: "checkbox" })] }) }));
|
|
2182
2182
|
});
|
|
2183
2183
|
|
|
2184
2184
|
const cvaUploadInputField = cvaMerge([
|
|
@@ -2200,14 +2200,13 @@ const cvaUploadInputAddonBefore = cvaMerge(["block", "truncate", "w-28", "pt-2"]
|
|
|
2200
2200
|
*/
|
|
2201
2201
|
const UploadInput = forwardRef((_a, ref) => {
|
|
2202
2202
|
var { disabled, acceptedTypes, nonInteractive, uploadLabel, multipleFiles } = _a, rest = __rest(_a, ["disabled", "acceptedTypes", "nonInteractive", "uploadLabel", "multipleFiles"]);
|
|
2203
|
-
return (jsx("label", { className: "tu-upload-input", children: jsx(BaseInput, Object.assign({
|
|
2204
|
-
|
|
2205
|
-
onClick: event => {
|
|
2203
|
+
return (jsx("label", { className: "tu-upload-input", children: jsx(BaseInput, Object.assign({ accept: acceptedTypes, addonBefore: uploadLabel, addonBeforeClassName: cvaUploadInputAddonBefore(), disabled: disabled, inputClassName: cvaUploadInputField(), multiple: multipleFiles, nonInteractive: nonInteractive, onClick: event => {
|
|
2204
|
+
// onClick used to work with nonInteractive option
|
|
2206
2205
|
if (nonInteractive) {
|
|
2207
2206
|
event.preventDefault();
|
|
2208
2207
|
event.stopPropagation();
|
|
2209
2208
|
}
|
|
2210
|
-
} }, rest)) }));
|
|
2209
|
+
}, ref: ref, type: "file" }, rest)) }));
|
|
2211
2210
|
});
|
|
2212
2211
|
|
|
2213
2212
|
/**
|
|
@@ -2217,7 +2216,7 @@ const UploadField = forwardRef((_a, ref) => {
|
|
|
2217
2216
|
var { label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
|
|
2218
2217
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2219
2218
|
const htmlForId = id ? id : "uploadField-" + v4();
|
|
2220
|
-
return (jsx(FormGroup, {
|
|
2219
|
+
return (jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(UploadInput, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
2221
2220
|
});
|
|
2222
2221
|
|
|
2223
2222
|
/**
|
|
@@ -2244,7 +2243,7 @@ const UrlInput = forwardRef((_a, ref) => {
|
|
|
2244
2243
|
var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction", "value", "defaultValue"]);
|
|
2245
2244
|
const [url, setUrl] = useState((value === null || value === void 0 ? void 0 : value.toString()) || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()));
|
|
2246
2245
|
const renderAsInvalid = (url && typeof url === "string" && !validateUrlAddress(url)) || isInvalid;
|
|
2247
|
-
return (jsx(BaseInput, Object.assign({
|
|
2246
|
+
return (jsx(BaseInput, Object.assign({ dataTestId: dataTestId && `${dataTestId}-url-input`, 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 && (jsx(ActionButton, { dataTestId: (dataTestId && `${dataTestId}-url-input-Icon`) || "url-input-action-icon", disabled: renderAsInvalid || disabled, iconSize: fieldSize, type: "WEB_ADDRESS", value: url })) })));
|
|
2248
2247
|
});
|
|
2249
2248
|
|
|
2250
2249
|
/**
|
|
@@ -2260,7 +2259,7 @@ const UrlField = forwardRef((_a, ref) => {
|
|
|
2260
2259
|
return typeof inputValue === "string";
|
|
2261
2260
|
}
|
|
2262
2261
|
const renderAsInvalid = !!errorMessage || (value && isString(value) && !validateUrlAddress(value)) || isInvalid;
|
|
2263
|
-
return (jsx(FormGroup, {
|
|
2262
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: renderAsInvalid ? errorMessage : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(UrlInput, Object.assign({ "aria-labelledby": htmlForId + "-label", disabled: rest.disabled, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, value: value || defaultValue }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
2264
2263
|
});
|
|
2265
2264
|
|
|
2266
2265
|
/*
|