@trackunit/react-form-components 0.0.452 → 0.0.453

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.esm.js CHANGED
@@ -16,6 +16,7 @@ import ReactAsyncCreatableSelect from 'react-select/async-creatable';
16
16
  import ReactCreatableSelect from 'react-select/creatable';
17
17
  import ReactAsyncSelect from 'react-select/async';
18
18
  import { nonNullable } from '@trackunit/shared-utils';
19
+ import { twMerge } from 'tailwind-merge';
19
20
  import { z } from 'zod';
20
21
 
21
22
  var defaultTranslations = {
@@ -126,14 +127,14 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, className }
126
127
  case "PHONE_NUMBER":
127
128
  return window.open(`tel:${value}`);
128
129
  case "COPY":
130
+ // Typescript seems to be unable to detect RefObject
131
+ // as one of the members of the union RefObject | string | null which gives access to the `current` property
132
+ // eslint-disable-next-line react/prop-types
129
133
  return copyToClipboard((_b = (_a = value === null || value === void 0 ? void 0 : value.current) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "");
130
134
  default:
131
135
  return null;
132
136
  }
133
137
  };
134
- if (ButtonAction === null) {
135
- return null;
136
- }
137
138
  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" }) }));
138
139
  };
139
140
 
@@ -277,7 +278,7 @@ const cvaInputSuffix = cvaMerge(["flex", "justify-center", "items-center", "text
277
278
  * This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
278
279
  */
279
280
  const BaseInput = React.forwardRef((_a, ref) => {
280
- var _b, _c;
281
+ var _b;
281
282
  var { className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName } = _a, rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize", "nonInteractive", "showDefaultActions", "inputClassName", "placeholder", "addonBeforeClassName"]);
282
283
  const renderAsDisabled = rest.disabled || rest.readOnly;
283
284
  const innerRef = React.useRef(null);
@@ -288,15 +289,16 @@ const BaseInput = React.forwardRef((_a, ref) => {
288
289
  invalid: isInvalid,
289
290
  size: fieldSize,
290
291
  className,
291
- }), "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({
292
+ }), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [addonBefore ? (jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && addonBefore !== prefix ? (jsx("div", { className: cvaInputPrefix({
292
293
  disabled: renderAsDisabled,
293
- }), "data-testid": dataTestId && `${dataTestId}-prefix`, children: prefix })) : null, jsx("input", Object.assign({ "aria-required": rest.required, className: cvaInputField({ size: fieldSize, disabled: renderAsDisabled, className: inputClassName }), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef }, rest, { readOnly: rest.readOnly || nonInteractive })), suffix && addonBefore !== suffix ? (jsx("div", { className: cvaInputSuffix({
294
+ }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, jsx("input", Object.assign({ "aria-required": rest.required, className: cvaInputField({ size: fieldSize, disabled: renderAsDisabled, className: inputClassName }), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef }, rest, { readOnly: rest.readOnly || nonInteractive })), suffix && addonBefore !== suffix ? (jsx("div", { className: cvaInputSuffix({
294
295
  disabled: renderAsDisabled,
295
- }), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix })) : null, rest.readOnly === true &&
296
+ }), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null, rest.readOnly === true &&
296
297
  showDefaultActions &&
297
- ((_b = innerRef === null || innerRef === void 0 ? void 0 : innerRef.current) === null || _b === void 0 ? void 0 : _b.value.length) &&
298
- ((_c = innerRef === null || innerRef === void 0 ? void 0 : innerRef.current) === null || _c === void 0 ? void 0 : _c.value.length) > 0 ? (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] }));
298
+ ((_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.value.length) &&
299
+ innerRef.current.value.length > 0 ? (jsx(ActionButton, { type: "COPY", value: innerRef }, "default-copy-action")) : null, actions && addonBefore !== actions ? actions : null, addonAfter && addonBefore !== addonAfter ? (jsx("div", { className: cvaInputAddonAfter(), "data-testid": dataTestId ? `${dataTestId}-addonAfter` : null, children: addonAfter })) : null] }));
299
300
  });
301
+ BaseInput.displayName = "BaseInput";
300
302
 
301
303
  const cvaLabel = cvaMerge([
302
304
  "text-base",
@@ -489,10 +491,10 @@ const Checkbox = React.forwardRef((_a, ref) => {
489
491
  var _a, _b;
490
492
  e.preventDefault();
491
493
  if ("Space" === e.code) {
492
- (_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
494
+ (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
493
495
  }
494
496
  if ("Enter" === e.code) {
495
- (_b = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
497
+ (_b = internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
496
498
  }
497
499
  };
498
500
  const [labelRef, setLabelRef] = React.useState(null);
@@ -500,16 +502,17 @@ const Checkbox = React.forwardRef((_a, ref) => {
500
502
  onLabelRefChange && labelRef && onLabelRefChange(labelRef);
501
503
  }, [labelRef, onLabelRefChange]);
502
504
  const uuid = rest.id;
503
- 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({
505
+ return (jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-container` : null, 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({
504
506
  disabled: isReadonly,
505
507
  invalid: isReadonly ? false : isInvalid,
506
508
  state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
507
- }), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label && (jsx("span", { className: "flex", children: jsx("span", { className: cvaLabel({
509
+ }), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label ? (jsx("span", { className: "flex", children: jsx("span", { className: cvaLabel({
508
510
  invalid: isReadonly ? false : isInvalid,
509
511
  disabled: isReadonly,
510
512
  className: "cursor-pointer",
511
- }), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })), suffix] }));
513
+ }), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })) : null, suffix] }));
512
514
  });
515
+ Checkbox.displayName = "Checkbox";
513
516
 
514
517
  /**
515
518
  * The Label component is used for labels for input fields.
@@ -549,7 +552,7 @@ const cvaHelpAddon = cvaMerge(["ml-auto"]);
549
552
  * @returns {JSX.Element} FormGroup component
550
553
  */
551
554
  const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, htmlFor, children, tipIconProps, disabled = false, required = false, }) => {
552
- return (jsxs("div", { className: cvaFormGroup({ disabled, className }), "data-testid": dataTestId, children: [jsxs("div", { className: cvaFormGroupContainerBefore(), children: [label ? (jsxs(Fragment, { children: [jsx(Label, { className: "component-formGroup-font", dataTestId: dataTestId && `${dataTestId}-label`, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required && jsx("span", { className: "required-asterisk", children: "*" })] })) : null, tip ? (jsx(Tooltip, { className: "ml-1", dataTestId: dataTestId && `${dataTestId}-tooltip`, iconProps: tipIconProps, label: tip, placement: "bottom" })) : null] }), children, jsxs("div", { className: cvaFormGroupContainerAfter({ invalid: isInvalid }), children: [helpText && jsx("span", { "data-testid": dataTestId && `${dataTestId}-helpText`, children: helpText }), helpAddon && (jsx("span", { className: cvaHelpAddon(), "data-testid": dataTestId && `${dataTestId}-helpAddon`, children: helpAddon }))] })] }));
555
+ return (jsxs("div", { className: cvaFormGroup({ disabled, className }), "data-testid": dataTestId, children: [jsxs("div", { className: cvaFormGroupContainerBefore(), children: [label ? (jsxs(Fragment, { children: [jsx(Label, { className: "component-formGroup-font", dataTestId: dataTestId ? `${dataTestId}-label` : undefined, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required ? jsx("span", { className: "required-asterisk", children: "*" }) : null] })) : null, tip ? (jsx(Tooltip, { className: "ml-1", dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, iconProps: tipIconProps, label: tip, placement: "bottom" })) : null] }), children, jsxs("div", { className: cvaFormGroupContainerAfter({ invalid: isInvalid }), children: [helpText ? jsx("span", { "data-testid": dataTestId ? `${dataTestId}-helpText` : undefined, children: helpText }) : undefined, helpAddon ? (jsx("span", { className: cvaHelpAddon(), "data-testid": dataTestId ? `${dataTestId}-helpAddon` : null, children: helpAddon })) : null] })] }));
553
556
  };
554
557
 
555
558
  /**
@@ -560,8 +563,9 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
560
563
  const CheckboxField = forwardRef((_a, ref) => {
561
564
  var { label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "helpAddon", "isInvalid", "className", "checked", "dataTestId", "checkboxLabel", "onChange"]);
562
565
  const htmlForId = id ? id : "checkboxField-" + v4();
563
- return (jsx(FormGroup, { className: "flex flex-col gap-1", dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: rest.required, tip: tip, children: jsx(Checkbox, Object.assign({ checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref }, rest)) }));
566
+ return (jsx(FormGroup, { className: "flex flex-col gap-1", dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, disabled: rest.disabled, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: rest.required, tip: tip, children: jsx(Checkbox, Object.assign({ checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref }, rest)) }));
564
567
  });
568
+ CheckboxField.displayName = "CheckboxField";
565
569
 
566
570
  /**
567
571
  * Validates if the given value is a valid hex color.
@@ -594,16 +598,17 @@ const ColorField = forwardRef((_a, ref) => {
594
598
  }
595
599
  }, [onChange]);
596
600
  const renderAsInvalid = !!errorMessage || (value && typeof value === "string" && !isValidHEXColor(value)) || isInvalid;
597
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxs("div", { className: cvaInput({
601
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxs("div", { className: cvaInput({
598
602
  disabled: false,
599
603
  invalid: false,
600
604
  className,
601
- }), "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputField({ disabled: false }), "data-testid": dataTestId && `${dataTestId}-textField`, onChange: handleChange, type: "text", value: value }), jsx("input", { "aria-labelledby": htmlForId + "-label", className: "mr-1 h-[25px] w-[25px] self-center bg-inherit", "data-testid": dataTestId, defaultValue: defaultValue, id: htmlForId, onChange: handleChange, ref: innerRef, type: "color", value: value }), jsx(IconButton, { className: "mr-1 self-center", icon: jsx(Icon, { name: "Pencil", type: "outline" }), onClick: () => {
602
- if (innerRef === null || innerRef === void 0 ? void 0 : innerRef.current) {
605
+ }), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputField({ disabled: false }), "data-testid": dataTestId ? `${dataTestId}-textField` : null, onChange: handleChange, type: "text", value: value }), jsx("input", { "aria-labelledby": htmlForId + "-label", className: "mr-1 h-[25px] w-[25px] self-center bg-inherit", "data-testid": dataTestId, defaultValue: defaultValue, id: htmlForId, onChange: handleChange, ref: innerRef, type: "color", value: value }), jsx(IconButton, { className: "mr-1 self-center", icon: jsx(Icon, { name: "Pencil", type: "outline" }), onClick: () => {
606
+ if (innerRef.current) {
603
607
  innerRef.current.click();
604
608
  }
605
609
  }, variant: "ghost-neutral" })] }) }));
606
610
  });
611
+ ColorField.displayName = "ColorField";
607
612
 
608
613
  /**
609
614
  * A wrapper around BaseInput with a pop-up day picker.
@@ -615,8 +620,9 @@ const DateInput = forwardRef((_a, ref) => {
615
620
  const formatDateToInputString = (date) => isValidDate(date) ? format(date, "yyyy-MM-dd") : date;
616
621
  // Chrome and Firefox need their default icon to have datepicker functionality.
617
622
  const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
618
- 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)));
623
+ 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" }) : null, type: "date", value: formatDateToInputString(value) }, rest)));
619
624
  });
625
+ DateInput.displayName = "DateInput";
620
626
 
621
627
  /**
622
628
  * The date field component is used for entering date values.
@@ -629,8 +635,9 @@ const DateField = forwardRef((_a, ref) => {
629
635
  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"]);
630
636
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
631
637
  const htmlForId = id ? id : "dateField-" + v4();
632
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(DateInput, Object.assign({ "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
638
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(DateInput, Object.assign({ "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
633
639
  });
640
+ DateField.displayName = "DateField";
634
641
 
635
642
  const cvaDropZone = cvaMerge([
636
643
  "flex",
@@ -720,7 +727,7 @@ const DropZone = (_a) => {
720
727
  e.preventDefault();
721
728
  e.stopPropagation();
722
729
  setDragActive(false);
723
- if (e.dataTransfer.files && e.dataTransfer.files[0] && !disabled) {
730
+ if (e.dataTransfer.files[0] && !disabled) {
724
731
  filesSelected(e.dataTransfer.files);
725
732
  setFileDropped(true);
726
733
  }
@@ -740,7 +747,7 @@ const DropZone = (_a) => {
740
747
  e.preventDefault();
741
748
  e.stopPropagation();
742
749
  }
743
- }, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop }, rest, { children: [jsx("input", { accept: accept, className: "hidden", id: "input-file-upload", onChange: handleChange, title: t("dropzone.input.title"), type: "file" }), jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId && `${dataTestId}-label`, htmlFor: "input-file-upload", ref: inputLabelRef, children: [jsx("div", { className: cvaDropZoneIconBackground({ invalid: isInvalid }), children: jsx(Icon, { className: !isInvalid ? "text-gray-400" : "", color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", type: "solid" }) }), jsx("button", { disabled: disabled, onClick: handleButtonClick, children: label })] })] })));
750
+ }, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop }, rest, { children: [jsx("input", { accept: accept, className: "hidden", id: "input-file-upload", onChange: handleChange, title: t("dropzone.input.title"), type: "file" }), jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : null, htmlFor: "input-file-upload", ref: inputLabelRef, children: [jsx("div", { className: cvaDropZoneIconBackground({ invalid: isInvalid }), children: jsx(Icon, { className: !isInvalid ? "text-gray-400" : "", color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", type: "solid" }) }), jsx("button", { disabled: disabled, onClick: handleButtonClick, children: label })] })] })));
744
751
  };
745
752
 
746
753
  // Doing the same check as we do on the backend
@@ -781,9 +788,9 @@ const EmailInput = React.forwardRef((_a, ref) => {
781
788
  setEmail(newValue);
782
789
  }, [onChange]);
783
790
  const renderAsInvalid = (email && !validateEmailAddress(email)) || isInvalid;
784
- return (jsx(BaseInput, Object.assign({ actions: email &&
785
- email.length > 0 && (jsx(ActionButton, { dataTestId: dataTestId && `${dataTestId}-emailIcon`, disabled: disabled, iconSize: fieldSize, onClick: sendEmail, type: "EMAIL", value: email })), dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: handleChange, placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email" }, rest)));
791
+ return (jsx(BaseInput, Object.assign({ actions: email && email.length > 0 ? (jsx(ActionButton, { dataTestId: dataTestId ? `${dataTestId}-emailIcon` : undefined, disabled: disabled, iconSize: fieldSize, onClick: sendEmail, type: "EMAIL", value: email })) : null, dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: handleChange, placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email" }, rest)));
786
792
  });
793
+ EmailInput.displayName = "EmailInput";
787
794
 
788
795
  /**
789
796
  * The EmailField component is used to enter email.
@@ -803,8 +810,9 @@ const EmailField = forwardRef((_a, ref) => {
803
810
  onChange(event);
804
811
  }
805
812
  }, [onChange]);
806
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
813
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
807
814
  });
815
+ EmailField.displayName = "EmailField";
808
816
 
809
817
  /**
810
818
  * A thin wrapper around the `BaseInput` component for number input fields.
@@ -814,6 +822,7 @@ const EmailField = forwardRef((_a, ref) => {
814
822
  const NumberInput = forwardRef((props, ref) => {
815
823
  return jsx(BaseInput, Object.assign({ ref: ref, type: "number" }, props, { value: props.value }));
816
824
  });
825
+ NumberInput.displayName = "NumberInput";
817
826
 
818
827
  /**
819
828
  * The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
@@ -826,8 +835,9 @@ const NumberField = forwardRef((_a, ref) => {
826
835
  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"]);
827
836
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
828
837
  const htmlForId = id ? id : "numberField-" + v4();
829
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
838
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(NumberInput, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId })) }));
830
839
  });
840
+ NumberField.displayName = "NumberField";
831
841
 
832
842
  const cvaOptionCardLabel = cvaMerge([
833
843
  cvaInputBase(),
@@ -861,11 +871,11 @@ const cvaOptionCardContainer = cvaMerge(["contents"]);
861
871
  const OptionCard = forwardRef((_a, ref) => {
862
872
  var { icon, heading, subheading, description, disabled, id, value, className, contentClassName, dataTestId, customImage } = _a, rest = __rest(_a, ["icon", "heading", "subheading", "description", "disabled", "id", "value", "className", "contentClassName", "dataTestId", "customImage"]);
863
873
  const htmlForId = id !== null && id !== void 0 ? id : "option-card-" + v4();
864
- return (jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsx("input", Object.assign({ className: "peer absolute h-0 w-0 opacity-0", id: htmlForId, ref: ref, type: "radio", value: value }, rest)), jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), htmlFor: htmlForId, children: [disabled &&
865
- icon &&
866
- !customImage &&
867
- cloneElement(icon, { className: `${icon.props.className} text-secondary-400` }), disabled && customImage && jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }), !disabled && !customImage && icon, !disabled && customImage && jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }), heading && (jsx(Heading, { subtle: disabled, variant: "secondary", children: heading })), (subheading || description) && (jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), 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 }))] }))] })] }));
874
+ return (jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsx("input", Object.assign({ className: "peer absolute h-0 w-0 opacity-0", id: htmlForId, ref: ref, type: "radio", value: value }, rest)), jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), htmlFor: htmlForId, children: [disabled && icon && !customImage
875
+ ? cloneElement(icon, { className: `${icon.props.className} text-secondary-400` })
876
+ : null, disabled && customImage ? jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, !disabled && !customImage && icon, !disabled && customImage ? jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, heading ? (jsx(Heading, { subtle: disabled, variant: "secondary", children: heading })) : null, subheading || description ? (jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading ? (jsx(Text, { align: "center", subtle: disabled, type: "span", weight: "thick", children: subheading })) : null, description ? (jsx(Text, { align: "center", subtle: true, type: "span", children: description })) : null] })) : null] })] }));
868
877
  });
878
+ OptionCard.displayName = "OptionCard";
869
879
 
870
880
  /**
871
881
  * A thin wrapper around the `BaseInput` component for password input fields.
@@ -876,6 +886,7 @@ const PasswordInput = forwardRef((props, ref) => {
876
886
  const [showPassword, setShowPassword] = useState(false);
877
887
  return (jsx(BaseInput, Object.assign({ ref: ref }, props, { actions: jsx("div", { className: cvaActionContainer(), children: jsx(IconButton, { className: cvaActionButton({ size: props.fieldSize }), icon: jsx(Icon, { name: showPassword ? "EyeSlash" : "Eye", size: "small" }), onClick: () => setShowPassword(prevState => !prevState), size: "small", variant: "secondary" }) }), type: showPassword ? "text" : "password" })));
878
888
  });
889
+ PasswordInput.displayName = "PasswordInput";
879
890
 
880
891
  /**
881
892
  * Password fields enter a password or other confidential information. Characters are masked as they are typed.
@@ -891,8 +902,9 @@ const PasswordField = forwardRef((_a, ref) => {
891
902
  const handleChange = useCallback((event) => {
892
903
  onChange === null || onChange === void 0 ? void 0 : onChange(event);
893
904
  }, [onChange]);
894
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(PasswordInput, Object.assign({}, rest, { "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value })) }));
905
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(PasswordInput, Object.assign({}, rest, { "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value })) }));
895
906
  });
907
+ PasswordField.displayName = "PasswordField";
896
908
 
897
909
  /**
898
910
  * @param phoneNumber - a phone number as a string
@@ -1003,10 +1015,9 @@ const PhoneInput = forwardRef((_a, ref) => {
1003
1015
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
1004
1016
  fieldIsFocused.current = true;
1005
1017
  }, [onFocus]);
1006
- return (jsx("div", { className: "grid grid-cols-1 gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: jsx(BaseInput, Object.assign({ actions: !disableAction &&
1007
- innerValue &&
1008
- (innerValue === null || innerValue === void 0 ? void 0 : innerValue.length) > 0 && (jsx(ActionButton, { dataTestId: dataTestId && `${dataTestId}-phoneIcon`, disabled: disabled || isInvalid, iconSize: fieldSize, type: "PHONE_NUMBER", value: (value === null || value === void 0 ? void 0 : value.toString()) || "" })), dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, disabled: disabled, fieldSize: fieldSize, id: "phoneInput-number", isInvalid: isInvalid, name: name, onBlur: handleBlur, onChange: handleChange, onFocus: handleFocus, prefix: (countryCode && countryCodeToFlagEmoji(countryCode)) || undefined, readOnly: readOnly, ref: ref, type: "tel", value: innerValue }, rest)) }));
1018
+ return (jsx("div", { className: "grid grid-cols-1 gap-2", "data-testid": dataTestId ? `${dataTestId}-container` : null, children: jsx(BaseInput, Object.assign({ actions: !disableAction && innerValue && innerValue.length > 0 ? (jsx(ActionButton, { dataTestId: dataTestId ? `${dataTestId}-phoneIcon` : undefined, disabled: disabled || isInvalid, iconSize: fieldSize, type: "PHONE_NUMBER", value: (value === null || value === void 0 ? void 0 : value.toString()) || "" })) : null, dataTestId: dataTestId ? `${dataTestId}-phoneNumberInput` : undefined, disabled: disabled, fieldSize: fieldSize, id: "phoneInput-number", isInvalid: isInvalid, name: name, onBlur: handleBlur, onChange: handleChange, onFocus: handleFocus, prefix: (countryCode && countryCodeToFlagEmoji(countryCode)) || undefined, readOnly: readOnly, ref: ref, type: "tel", value: innerValue }, rest)) }));
1009
1019
  });
1020
+ PhoneInput.displayName = "PhoneInput";
1010
1021
 
1011
1022
  /**
1012
1023
  * The PhoneField component is used to enter phone number.
@@ -1028,8 +1039,9 @@ const PhoneField = forwardRef((_a, ref) => {
1028
1039
  var { label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId, name, onChange, onBlur } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "isInvalid", "errorMessage", "value", "helpAddon", "className", "defaultValue", "dataTestId", "name", "onChange", "onBlur"]);
1029
1040
  const htmlForId = id ? id : "phoneField-" + v4();
1030
1041
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1031
- return (jsx(FormGroup, { className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(PhoneInput, Object.assign({ "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: onBlur, onChange: onChange, ref: ref, value: value }, rest)) }));
1042
+ return (jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, disabled: rest.disabled, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(PhoneInput, Object.assign({ "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: onBlur, onChange: onChange, ref: ref, value: value }, rest)) }));
1032
1043
  });
1044
+ PhoneField.displayName = "PhoneField";
1033
1045
 
1034
1046
  /**
1035
1047
  * The PhoneFieldWithController component is a wrapper for the PhoneField component to connect it to react-hook-form.
@@ -1040,6 +1052,7 @@ const PhoneFieldWithController = forwardRef((_a, ref) => {
1040
1052
  var { control, controllerProps, name, value } = _a, rest = __rest(_a, ["control", "controllerProps", "name", "value"]);
1041
1053
  return (jsx(Controller, Object.assign({ control: control, defaultValue: value, name: name }, controllerProps, { render: ({ field }) => jsx(PhoneField, Object.assign({}, rest, field, { ref: ref })) })));
1042
1054
  });
1055
+ PhoneFieldWithController.displayName = "PhoneFieldWithController";
1043
1056
 
1044
1057
  /**
1045
1058
  * Validates a phone number
@@ -1052,7 +1065,7 @@ const validatePhoneNumber = (phoneNumber) => {
1052
1065
  asYouType.input(phoneNumber);
1053
1066
  const countryCode = asYouType.getCallingCode();
1054
1067
  const national = asYouType.getNationalNumber();
1055
- const safePhoneNumber = getPhoneNumberWithPlus(phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.trim());
1068
+ const safePhoneNumber = getPhoneNumberWithPlus(phoneNumber.trim());
1056
1069
  const number = parsePhoneNumberFromString(safePhoneNumber);
1057
1070
  if (phoneNumber && isValidPhoneNumber(phoneNumber)) {
1058
1071
  return undefined;
@@ -1193,7 +1206,7 @@ const RadioGroupContext = React.createContext(null);
1193
1206
  * @returns {JSX.Element} RadioGroup component
1194
1207
  */
1195
1208
  const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
1196
- 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: {
1209
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, label: label, children: jsx("div", { className: cvaRadioGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, children: jsx(RadioGroupContext.Provider, { value: {
1197
1210
  id,
1198
1211
  value,
1199
1212
  name: name || id,
@@ -1213,11 +1226,11 @@ RadioGroup.displayName = "RadioGroup";
1213
1226
  const RadioItem = ({ label, value, dataTestId, className, description, }) => {
1214
1227
  const groupCtx = React.useContext(RadioGroupContext);
1215
1228
  const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
1216
- 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({
1229
+ return (jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId ? `${dataTestId}-Wrapper` : null, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: [jsx("input", { checked: isChecked, className: cvaRadioItem({
1217
1230
  checked: isChecked,
1218
1231
  disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
1219
1232
  invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
1220
- }), "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 }))] })] }));
1233
+ }), "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` : undefined, 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` : null, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: description })) : null] })] }));
1221
1234
  };
1222
1235
 
1223
1236
  const cvaTimeRange = cvaMerge(["flex", "flex-1", "items-center", "gap-4", "border-transparent", "rounded-md"]);
@@ -1229,7 +1242,6 @@ const cvaTimeRange = cvaMerge(["flex", "flex-1", "items-center", "gap-4", "borde
1229
1242
  * @returns {JSX.Element} TimeRange component
1230
1243
  */
1231
1244
  const TimeRange = ({ id, className, dataTestId, children, range, onChange, disabled, isInvalid, }) => {
1232
- var _a, _b;
1233
1245
  const [timeRange, setTimeRange] = React__default.useState(range !== null && range !== void 0 ? range : {
1234
1246
  timeFrom: "",
1235
1247
  timeTo: "",
@@ -1241,7 +1253,7 @@ const TimeRange = ({ id, className, dataTestId, children, range, onChange, disab
1241
1253
  setTimeRange(prev => (Object.assign(Object.assign({}, prev), { timeTo })));
1242
1254
  };
1243
1255
  const onRangeChange = () => onChange(timeRange);
1244
- 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 : "" })] }));
1256
+ 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: timeRange.timeFrom }), 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: timeRange.timeTo })] }));
1245
1257
  };
1246
1258
 
1247
1259
  const cvaScheduleItem = cvaMerge(["grid", "pb-4", "gap-2", "grid-cols-[60px,200px,60px,2fr]"]);
@@ -1268,7 +1280,7 @@ const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = []
1268
1280
  onChange(newSchedule);
1269
1281
  };
1270
1282
  return (jsx("div", { className: className, "data-testid": dataTestId, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDayActive }, index) => {
1271
- 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 + label));
1283
+ 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 : undefined, 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 + label));
1272
1284
  }) }));
1273
1285
  };
1274
1286
 
@@ -1316,32 +1328,19 @@ const parseSchedule = (scheduleString) => {
1316
1328
  };
1317
1329
  });
1318
1330
  const filteredSchedule = schedule
1319
- .filter(daySchedule => daySchedule.range !== null && daySchedule.range !== undefined)
1320
- .map(daySchedule => ({ day: daySchedule.day, range: daySchedule.range, isAllDay: daySchedule.isAllDay }));
1331
+ .filter(daySchedule => "range" in daySchedule && daySchedule.range)
1332
+ .map(daySchedule => ({
1333
+ day: daySchedule.day,
1334
+ range: daySchedule.range,
1335
+ isAllDay: daySchedule.isAllDay,
1336
+ }));
1321
1337
  let variant;
1322
1338
  switch (schedule.length) {
1323
1339
  case 7:
1324
- const areEqual = schedule.every((day, _, collection) => {
1325
- var _a, _b, _c, _d, _e, _f;
1326
- return ((_b = (_a = collection === null || collection === void 0 ? void 0 : collection[0]) === null || _a === void 0 ? void 0 : _a.range) === null || _b === void 0 ? void 0 : _b.timeFrom) === ((_c = day === null || day === void 0 ? void 0 : day.range) === null || _c === void 0 ? void 0 : _c.timeFrom) &&
1327
- ((_e = (_d = collection === null || collection === void 0 ? void 0 : collection[0]) === null || _d === void 0 ? void 0 : _d.range) === null || _e === void 0 ? void 0 : _e.timeTo) === ((_f = day === null || day === void 0 ? void 0 : day.range) === null || _f === void 0 ? void 0 : _f.timeTo);
1328
- });
1329
- if (areEqual) {
1330
- variant = ScheduleVariant.ALL_DAYS;
1331
- }
1332
- else {
1333
- variant = ScheduleVariant.CUSTOM;
1334
- }
1340
+ variant = isUniform(schedule) ? ScheduleVariant.ALL_DAYS : ScheduleVariant.CUSTOM;
1335
1341
  break;
1336
1342
  case 5:
1337
- const days = [1, 2, 3, 4, 5];
1338
- const hasConsecutiveDays = schedule.every(({ day }, index) => day === days[index]);
1339
- if (hasConsecutiveDays) {
1340
- variant = ScheduleVariant.WEEKDAYS;
1341
- }
1342
- else {
1343
- variant = ScheduleVariant.CUSTOM;
1344
- }
1343
+ variant = hasConsecutiveDays(schedule) ? ScheduleVariant.WEEKDAYS : ScheduleVariant.CUSTOM;
1345
1344
  break;
1346
1345
  default:
1347
1346
  return {
@@ -1363,7 +1362,7 @@ const parseSchedule = (scheduleString) => {
1363
1362
  const serializeSchedule = (weekSchedule) => {
1364
1363
  return weekSchedule.schedule
1365
1364
  .filter(({ range, day, isAllDay }) => {
1366
- const hasRange = (range === null || range === void 0 ? void 0 : range.timeFrom) && (range === null || range === void 0 ? void 0 : range.timeTo);
1365
+ const hasRange = range.timeFrom && range.timeTo;
1367
1366
  switch (weekSchedule.variant) {
1368
1367
  case ScheduleVariant.WEEKDAYS:
1369
1368
  return day <= 5 && hasRange;
@@ -1382,6 +1381,25 @@ const serializeSchedule = (weekSchedule) => {
1382
1381
  })
1383
1382
  .join(",");
1384
1383
  };
1384
+ /**
1385
+ * Checks if a list of schedule objects have the same ranges
1386
+ *
1387
+ * @param {RawSchedule[]} schedule List of schedule objects
1388
+ * @returns {boolean} Whether the schedule is uniform
1389
+ */
1390
+ const isUniform = (schedule) => {
1391
+ return schedule.every((day, _, collection) => { var _a, _b, _c, _d, _e, _f; return ((_b = (_a = collection[0]) === null || _a === void 0 ? void 0 : _a.range) === null || _b === void 0 ? void 0 : _b.timeFrom) === ((_c = day.range) === null || _c === void 0 ? void 0 : _c.timeFrom) && ((_e = (_d = collection[0]) === null || _d === void 0 ? void 0 : _d.range) === null || _e === void 0 ? void 0 : _e.timeTo) === ((_f = day.range) === null || _f === void 0 ? void 0 : _f.timeTo); });
1392
+ };
1393
+ /**
1394
+ * Checks if a list of schedule objects are consecutive days
1395
+ *
1396
+ * @param {RawSchedule[]} schedule List of schedule objects
1397
+ * @returns {boolean} Whether the schedule has consecutive days
1398
+ */
1399
+ const hasConsecutiveDays = (schedule) => {
1400
+ const days = [1, 2, 3, 4, 5];
1401
+ return schedule.every(({ day }, index) => day === days[index]);
1402
+ };
1385
1403
 
1386
1404
  /**
1387
1405
  * A thin wrapper around the `BaseInput` component for text input fields.
@@ -1389,6 +1407,7 @@ const serializeSchedule = (weekSchedule) => {
1389
1407
  * NOTE: If shown with a label, please use the `TextField` component instead.
1390
1408
  */
1391
1409
  const TextInput = forwardRef((props, ref) => (jsx(BaseInput, Object.assign({ ref: ref, type: "text" }, props))));
1410
+ TextInput.displayName = "TextInput";
1392
1411
 
1393
1412
  const cvaSearch = cvaMerge([
1394
1413
  "shadow-none",
@@ -1424,10 +1443,11 @@ const cvaSearch = cvaMerge([
1424
1443
  */
1425
1444
  const Search = forwardRef((_a, ref) => {
1426
1445
  var { className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on" } = _a, rest = __rest(_a, ["className", "placeholder", "value", "widenInputOnFocus", "hideBorderWhenNotInFocus", "disabled", "onKeyUp", "onChange", "onFocus", "onBlur", "name", "onClear", "dataTestId", "autoComplete"]);
1427
- return (jsx(TextInput, Object.assign({}, rest, { autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, 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: () => {
1446
+ return (jsx(TextInput, Object.assign({}, rest, { autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, 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` : null, onClick: () => {
1428
1447
  onClear();
1429
1448
  }, children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value })));
1430
1449
  });
1450
+ Search.displayName = "Search";
1431
1451
 
1432
1452
  const cvaSelect = cvaMerge([
1433
1453
  "relative",
@@ -1488,6 +1508,8 @@ function isMultiValue(arg) {
1488
1508
  return Array.isArray(arg);
1489
1509
  }
1490
1510
  function isGroupBase(arg) {
1511
+ // This is apparently needed
1512
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1491
1513
  return arg.options !== undefined;
1492
1514
  }
1493
1515
  const isSelectedOption = (option, selected) => {
@@ -1523,7 +1545,7 @@ const getOrderedOptions = (options, value) => {
1523
1545
  .filter(option => !isSelectedOption(option, value))
1524
1546
  .map(option => removeSelectedFromGroups(option, value));
1525
1547
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1526
- return orderedValues.concat(selectableOptions) || [];
1548
+ return orderedValues.concat(selectableOptions);
1527
1549
  }
1528
1550
  return options || [];
1529
1551
  };
@@ -1584,7 +1606,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
1584
1606
  const itemsCount = items.length;
1585
1607
  React__default.useLayoutEffect(() => {
1586
1608
  var _a;
1587
- availableWidth.current = ((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
1609
+ availableWidth.current = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
1588
1610
  }, [containerRef]);
1589
1611
  const onWidthKnownHandler = ({ width: reportedWidth }) => {
1590
1612
  childrenWidth.current.push({ width: reportedWidth + itemsGap });
@@ -1596,7 +1618,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
1596
1618
  return previous + current.width;
1597
1619
  }, 0);
1598
1620
  let counter = 0;
1599
- const availableSpace = ((availableWidth === null || availableWidth === void 0 ? void 0 : availableWidth.current) || 0) - counterWidth;
1621
+ const availableSpace = (availableWidth.current || 0) - counterWidth;
1600
1622
  const renderedElements = items
1601
1623
  .concat({ text: "", onClick: () => null, disabled: false }) // reserved element for a potential counter
1602
1624
  .map((item, index) => {
@@ -1653,9 +1675,12 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1653
1675
  var _a;
1654
1676
  if (props.isMulti && Array.isArray(props.children) && props.children.length > 0) {
1655
1677
  const PLACEHOLDER_KEY = "placeholder";
1678
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1656
1679
  const key = props && props.children && props.children[0] ? (_a = props.children[0]) === null || _a === void 0 ? void 0 : _a.key : "";
1680
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1657
1681
  const values = props && props.children ? props.children[0] : [];
1658
1682
  const tags = key === PLACEHOLDER_KEY ? [] : values;
1683
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1659
1684
  const searchInput = props && props.children && props.children[1];
1660
1685
  return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsx(TagsContainer, { disabled: disabled, items: tags
1661
1686
  ? tags.map(({ props: tagProps }) => {
@@ -1664,27 +1689,26 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1664
1689
  onClick: disabled
1665
1690
  ? undefined
1666
1691
  : (e) => {
1667
- var _a, _b;
1668
1692
  refMenuIsEnabled.current = false;
1669
- ((_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));
1693
+ tagProps.removeProps.onClick && tagProps.removeProps.onClick(e);
1670
1694
  },
1671
1695
  disabled: disabled,
1672
1696
  };
1673
1697
  })
1674
- : [], postFix: searchInput, width: "100%" })) : (jsxs(Fragment, { children: [tags &&
1675
- tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
1676
- var _a, _b;
1677
- 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 => {
1678
- var _a, _b;
1698
+ : [], postFix: searchInput, width: "100%" })) : (jsxs(Fragment, { children: [tags
1699
+ ? tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
1700
+ var _a;
1701
+ return (jsx(Tag, { className: "inline-flex shrink-0", color: disabled ? "unknown" : "primary", dataTestId: tagProps.children ? `${tagProps.children.toString()}-tag` : undefined, onClose: e => {
1679
1702
  e.stopPropagation();
1680
1703
  refMenuIsEnabled.current = false;
1681
- ((_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));
1682
- }, children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
1683
- }), tags && tags.length > maxSelectedDisplayCount && (jsxs(Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
1704
+ tagProps.removeProps.onClick && tagProps.removeProps.onClick(e);
1705
+ }, children: tagProps.children }, (_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()));
1706
+ })
1707
+ : null, tags && tags.length > maxSelectedDisplayCount ? (jsxs(Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })) : null, searchInput] })) })));
1684
1708
  }
1685
1709
  return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: props.children })));
1686
1710
  }, LoadingIndicator: props => {
1687
- return jsx(Spinner, { className: "mt-1.5 mr-1", size: "small" });
1711
+ return jsx(Spinner, { className: "mr-1 mt-1.5", size: "small" });
1688
1712
  }, DropdownIndicator: props => {
1689
1713
  const icon = props.selectProps.menuIsOpen ? (jsx(Icon, { name: "ChevronUp", size: "medium" })) : (jsx(Icon, { name: "ChevronDown", size: "medium" }));
1690
1714
  return props.selectProps.isLoading ? null : (jsx(components.DropdownIndicator, Object.assign({}, props, { children: jsx("div", { className: cvaSelectIcon(), children: dropdownIcon ? dropdownIcon : icon }) })));
@@ -1692,7 +1716,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1692
1716
  if (disabled) {
1693
1717
  return null;
1694
1718
  }
1695
- 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") }) }) })));
1719
+ return (jsx(components.ClearIndicator, Object.assign({}, props, { children: jsx("div", { className: cvaSelectXIcon(), "data-testid": dataTestId ? `${dataTestId}-XMarkIcon` : null, onClick: props.clearValue, children: jsx(Icon, { name: "XCircle", size: "medium", title: t("clearIndicator.icon.tooltip.clearAll") }) }) })));
1696
1720
  }, Control: props => {
1697
1721
  return jsx(components.Control, Object.assign({}, props, { className: props.isDisabled ? "bg-slate-100" : "" }));
1698
1722
  }, SingleValue: props => {
@@ -1741,7 +1765,7 @@ const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, style
1741
1765
  width: "0px",
1742
1766
  }), menu: base => {
1743
1767
  return Object.assign(Object.assign({}, base), { width: "100%", marginTop: "4px", marginBottom: "18px", transition: "all 1s ease-in-out" });
1744
- }, input: base => (Object.assign(Object.assign({}, base), { marginLeft: "0px" })), placeholder: base => (Object.assign({}, base)), option: () => ({}), menuPortal: base => (Object.assign(Object.assign({}, base), { width: (refContainer === null || refContainer === void 0 ? void 0 : refContainer.current) ? `${refContainer.current.clientWidth}px` : base.width, transform: (refPrefix === null || refPrefix === void 0 ? void 0 : refPrefix.current) ? `translate(-${refPrefix.current.clientWidth + 2}px)` : "translate(-2px)", backgroundColor: "#ffffff", borderRadius: "var(--border-radius-lg)", zIndex: 20, borderColor: "rgb(var(--color-slate-300))", boxShadow: "var(--tw-ring-inset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)" })), menuList: base => {
1768
+ }, input: base => (Object.assign(Object.assign({}, base), { marginLeft: "0px" })), placeholder: base => (Object.assign({}, base)), option: () => ({}), menuPortal: base => (Object.assign(Object.assign({}, base), { width: refContainer.current ? `${refContainer.current.clientWidth}px` : base.width, transform: refPrefix.current ? `translate(-${refPrefix.current.clientWidth + 2}px)` : "translate(-2px)", backgroundColor: "#ffffff", borderRadius: "var(--border-radius-lg)", zIndex: 20, borderColor: "rgb(var(--color-slate-300))", boxShadow: "var(--tw-ring-inset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)" })), menuList: base => {
1745
1769
  return Object.assign(Object.assign({}, base), { position: "relative", padding: "var(--spacing-1)", display: "grid", gap: "var(--spacing-1)", width: "100%", borderRadius: "0px", boxShadow: "none", paddingTop: "0px" });
1746
1770
  }, valueContainer: base => {
1747
1771
  return Object.assign(Object.assign({}, base), { flexWrap: maxSelectedDisplayCount !== undefined ? "wrap" : "nowrap", gap: "0.25rem" });
@@ -1810,7 +1834,7 @@ const useSelect = (_a) => {
1810
1834
  */
1811
1835
  const CreatableSelect = (props) => {
1812
1836
  const { className, placeholder } = props, rest = __rest(props, ["className", "placeholder"]);
1813
- const { id, dataTestId = "creatableSelect", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, value, options, onChange, isLoading, classNamePrefix = dataTestId !== null && dataTestId !== void 0 ? dataTestId : "creatableSelect", onMenuScrollToBottom, filterOption, onInputChange, isSearchable, isClearable = false, readOnly, openMenuOnClick = !disabled, openMenuOnFocus = !disabled, allowCreateWhileLoading, onCreateOption, } = rest;
1837
+ const { id, dataTestId = "creatableSelect", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, value, options, onChange, isLoading, classNamePrefix = dataTestId, onMenuScrollToBottom, filterOption, onInputChange, isSearchable, isClearable = false, readOnly, openMenuOnClick = !disabled, openMenuOnFocus = !disabled, allowCreateWhileLoading, onCreateOption, } = rest;
1814
1838
  const { refContainer, refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
1815
1839
  const creatableSelectProps = {
1816
1840
  value,
@@ -1842,7 +1866,7 @@ const CreatableSelect = (props) => {
1842
1866
  onCreateOption,
1843
1867
  };
1844
1868
  const renderAsDisabled = rest.disabled || rest.readOnly || rest.isDisabled; // TODO remove one of the disable props from the type
1845
- 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(ReactAsyncCreatableSelect, Object.assign({}, rest, creatableSelectProps, async, { onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, placeholder: renderAsDisabled ? null : placeholder }))) : (jsx(ReactCreatableSelect, Object.assign({}, rest, creatableSelectProps, { hideSelectedOptions: false, isMulti: isMulti, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options, placeholder: renderAsDisabled ? null : placeholder })))] }));
1869
+ 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` : null, ref: refPrefix, children: prefix })), async ? (jsx(ReactAsyncCreatableSelect, Object.assign({}, rest, creatableSelectProps, async, { onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, placeholder: renderAsDisabled ? null : placeholder }))) : (jsx(ReactCreatableSelect, Object.assign({}, rest, creatableSelectProps, { hideSelectedOptions: false, isMulti: isMulti, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options, placeholder: renderAsDisabled ? null : placeholder })))] }));
1846
1870
  };
1847
1871
  CreatableSelect.displayName = "CreatableSelect";
1848
1872
 
@@ -1854,7 +1878,7 @@ CreatableSelect.displayName = "CreatableSelect";
1854
1878
  */
1855
1879
  const Select = (props) => {
1856
1880
  const { className, placeholder } = props, rest = __rest(props, ["className", "placeholder"]);
1857
- const { id, dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, menuPosition = "absolute", value, options, onChange, isLoading, classNamePrefix = dataTestId !== null && dataTestId !== void 0 ? dataTestId : "select", onMenuScrollToBottom, filterOption, onInputChange, isSearchable, isClearable = false, readOnly, openMenuOnClick = !disabled, openMenuOnFocus = !disabled, hideSelectedOptions = false, } = props;
1881
+ const { id, dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, menuPosition = "absolute", value, options, onChange, isLoading, classNamePrefix = dataTestId, onMenuScrollToBottom, filterOption, onInputChange, isSearchable, isClearable = false, readOnly, openMenuOnClick = !disabled, openMenuOnFocus = !disabled, hideSelectedOptions = false, } = props;
1858
1882
  const { refContainer, refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
1859
1883
  const selectProps = {
1860
1884
  value,
@@ -1885,7 +1909,7 @@ const Select = (props) => {
1885
1909
  hideSelectedOptions,
1886
1910
  };
1887
1911
  const renderAsDisabled = rest.disabled || rest.readOnly || rest.isDisabled; // TODO remove one of the disable props from the type
1888
- 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({}, rest, selectProps, async, { menuPosition: menuPosition, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, placeholder: renderAsDisabled ? null : placeholder }))) : (jsx(ReactSelect, Object.assign({}, rest, selectProps, { isMulti: isMulti, menuPosition: menuPosition, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options, placeholder: renderAsDisabled ? null : placeholder })))] }));
1912
+ 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` : null, ref: refPrefix, children: prefix })), async ? (jsx(ReactAsyncSelect, Object.assign({}, rest, selectProps, async, { menuPosition: menuPosition, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, placeholder: renderAsDisabled ? null : placeholder }))) : (jsx(ReactSelect, Object.assign({}, rest, selectProps, { isMulti: isMulti, menuPosition: menuPosition, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options, placeholder: renderAsDisabled ? null : placeholder })))] }));
1889
1913
  };
1890
1914
  Select.displayName = "Select";
1891
1915
 
@@ -1938,6 +1962,7 @@ const FormFieldSelectAdapter = forwardRef((_a, ref) => {
1938
1962
  setInnerValue(!e ? "" : e.value);
1939
1963
  }, value: selectedOption, defaultValue: selectedOption }))] }));
1940
1964
  });
1965
+ FormFieldSelectAdapter.displayName = "FormFieldSelectAdapter";
1941
1966
 
1942
1967
  /**
1943
1968
  * The CreatableSelectField component is a CreatableSelect component wrapped in the FromGroup component.
@@ -1954,6 +1979,7 @@ const CreatableSelectField = forwardRef((_a, ref) => {
1954
1979
  const creatableSelectOnlyProps = { allowCreateWhileLoading, onCreateOption };
1955
1980
  return (jsx(FormFieldSelectAdapter, Object.assign({}, props, { ref: ref, children: convertedProps => jsx(CreatableSelect, Object.assign({}, convertedProps, creatableSelectOnlyProps)) })));
1956
1981
  });
1982
+ CreatableSelectField.displayName = "CreatableSelectField";
1957
1983
 
1958
1984
  /**
1959
1985
  * The SelectField component is a Select component wrapped in the FromGroup component.
@@ -1969,6 +1995,7 @@ const SelectField = forwardRef((_a, ref) => {
1969
1995
  var props = __rest(_a, []);
1970
1996
  return (jsx(FormFieldSelectAdapter, Object.assign({}, props, { ref: ref, children: convertedProps => jsx(Select, Object.assign({}, convertedProps)) })));
1971
1997
  });
1998
+ SelectField.displayName = "SelectField";
1972
1999
 
1973
2000
  const cvaTextArea = cvaMerge([
1974
2001
  cvaInputBase(),
@@ -2011,6 +2038,7 @@ const TextArea = React.forwardRef((_a, ref) => {
2011
2038
  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"]);
2012
2039
  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 })));
2013
2040
  });
2041
+ TextArea.displayName = "TextArea";
2014
2042
 
2015
2043
  /**
2016
2044
  * The TextLengthIndicator component shows a `{length}/{maxLength}` label.
@@ -2034,9 +2062,10 @@ const TextAreaField = React.forwardRef((_a, ref) => {
2034
2062
  onChange(event);
2035
2063
  }
2036
2064
  }, [onChange]);
2037
- return (jsx(FormGroup, { className: `${className} grid grid-rows-[auto_1fr_auto]`, dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon ||
2038
- (maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
2065
+ return (jsx(FormGroup, { className: twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
2066
+ (typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(TextArea, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: "h-auto", dataTestId: dataTestId, onChange: handleChange })) }));
2039
2067
  });
2068
+ TextAreaField.displayName = "TextAreaField";
2040
2069
 
2041
2070
  /**
2042
2071
  * Text fields enable the user to interact with and input content and data. This component can be used for long and short form entries. Allow the size of the text input box to reflect the length of the content you expect the user to enter.
@@ -2056,9 +2085,10 @@ const TextField = React.forwardRef((_a, ref) => {
2056
2085
  onChange(event);
2057
2086
  }
2058
2087
  }, [onChange]);
2059
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon ||
2060
- (maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
2088
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
2089
+ (typeof maxLength === "number" && jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(TextInput, 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 })) }));
2061
2090
  });
2091
+ TextField.displayName = "TextField";
2062
2092
 
2063
2093
  /**
2064
2094
  * TimeRangeField Description. <-- Please add a proper Description this is used in Storybook.
@@ -2070,7 +2100,7 @@ const TimeRangeField = (_a) => {
2070
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"]);
2071
2101
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
2072
2102
  const htmlFor = id ? id : "timeRangeField-" + v4();
2073
- 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 })) }));
2103
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, 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 })) }));
2074
2104
  };
2075
2105
 
2076
2106
  const cvaToggleWrapper = cvaMerge(["flex", "gap-2", "items-center"]);
@@ -2145,11 +2175,12 @@ const Toggle = React.forwardRef(({ toggled = false, onChange, onClick, disabled,
2145
2175
  const showLabelContainer = Boolean(name || description);
2146
2176
  const showDescription = Boolean(description);
2147
2177
  const getTestId = (suffix) => `${dataTestId}-${suffix}`;
2148
- 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 => {
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 })) : null] })) : null, jsx("input", { "aria-checked": toggled, checked: toggled, className: cvaToggleInput(), "data-testid": getTestId("input"), disabled: disabled, id: id, name: name, onBlur: onBlur, onChange: e => {
2149
2179
  e.stopPropagation();
2150
2180
  onChange(!toggled, e);
2151
2181
  }, ref: ref, required: required, tabIndex: tabIndex, type: "checkbox" })] }) }));
2152
2182
  });
2183
+ Toggle.displayName = "Toggle";
2153
2184
 
2154
2185
  const cvaUploadInputField = cvaMerge([
2155
2186
  "px-0",
@@ -2178,6 +2209,7 @@ const UploadInput = forwardRef((_a, ref) => {
2178
2209
  }
2179
2210
  }, ref: ref, type: "file" }, rest)) }));
2180
2211
  });
2212
+ UploadInput.displayName = "UploadInput";
2181
2213
 
2182
2214
  /**
2183
2215
  * Upload fields enable the user to upload Files.
@@ -2188,6 +2220,7 @@ const UploadField = forwardRef((_a, ref) => {
2188
2220
  const htmlForId = id ? id : "uploadField-" + v4();
2189
2221
  return (jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsx(UploadInput, Object.assign({ "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref }, rest, { className: className, dataTestId: dataTestId })) }));
2190
2222
  });
2223
+ UploadField.displayName = "UploadField";
2191
2224
 
2192
2225
  /**
2193
2226
  * @description Validate given url id.
@@ -2213,8 +2246,9 @@ const UrlInput = forwardRef((_a, ref) => {
2213
2246
  var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction", "value", "defaultValue"]);
2214
2247
  const [url, setUrl] = useState((value === null || value === void 0 ? void 0 : value.toString()) || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()));
2215
2248
  const renderAsInvalid = (url && typeof url === "string" && !validateUrlAddress(url)) || isInvalid;
2216
- 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 })) })));
2249
+ return (jsx(BaseInput, Object.assign({ dataTestId: dataTestId ? `${dataTestId}-url-input` : undefined, disabled: disabled, id: "url-input", isInvalid: renderAsInvalid, onChange: e => setUrl(e.target.value), placeholder: rest.placeholder || "https://www.example.com", ref: ref, type: "url", value: url }, rest, { actions: !disableAction && (jsx(ActionButton, { dataTestId: (dataTestId && `${dataTestId}-url-input-Icon`) || "url-input-action-icon", disabled: renderAsInvalid || disabled, iconSize: fieldSize, type: "WEB_ADDRESS", value: url })) })));
2217
2250
  });
2251
+ UrlInput.displayName = "UrlField";
2218
2252
 
2219
2253
  /**
2220
2254
  * The UrlField component is used to enter url.
@@ -2229,8 +2263,9 @@ const UrlField = forwardRef((_a, ref) => {
2229
2263
  return typeof inputValue === "string";
2230
2264
  }
2231
2265
  const renderAsInvalid = !!errorMessage || (value && isString(value) && !validateUrlAddress(value)) || isInvalid;
2232
- return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.disabled, helpAddon: helpAddon, helpText: renderAsInvalid ? errorMessage : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
2266
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, disabled: rest.disabled, helpAddon: helpAddon, helpText: renderAsInvalid ? errorMessage : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, 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 })) }));
2233
2267
  });
2268
+ UrlField.displayName = "UrlField";
2234
2269
 
2235
2270
  /**
2236
2271
  * Custom hook to get phone number validation rules.
@@ -2247,7 +2282,7 @@ const useGetPhoneValidationRules = () => {
2247
2282
  const pattern = {
2248
2283
  validate: (value) => {
2249
2284
  const validationResult = t(`phoneField.error.${validatePhoneNumber(value)}`);
2250
- return !validationResult || value === "" || value === undefined || value === null || validationResult;
2285
+ return !validationResult || !value || validationResult;
2251
2286
  },
2252
2287
  };
2253
2288
  return !skipValidation