@trackunit/react-form-components 0.0.452 → 0.0.454

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
@@ -4,7 +4,7 @@ import { IconButton, Icon, Tooltip, Heading, Text, MenuItem, Tag, Spinner, useIs
4
4
  import { useCopyToClipboard } from 'react-use';
5
5
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
6
6
  import * as React from 'react';
7
- import React__default, { forwardRef, useState, useCallback, useRef, cloneElement, useEffect, useMemo, useImperativeHandle } from 'react';
7
+ import React__default, { isValidElement, forwardRef, useState, useCallback, useRef, cloneElement, useEffect, useMemo, useImperativeHandle } from 'react';
8
8
  import { v4 } from 'uuid';
9
9
  import { format } from 'date-fns';
10
10
  import { isValidDate } from 'rxjs/internal/util/isDate';
@@ -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
 
@@ -179,21 +180,56 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
179
180
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
180
181
  };
181
182
 
183
+ /**
184
+ * Used to compare two React nodes for deep equality.
185
+ */
186
+ const compareReactNodes = (node1, node2) => {
187
+ // Base case: If both objects are identical, return true.
188
+ if (node1 === node2) {
189
+ return true;
190
+ }
191
+ // Check if both objects are valid React elements.
192
+ if (isValidElement(node1) && isValidElement(node2)) {
193
+ const { type: type1, props: props1, key: key1 } = node1;
194
+ const { type: type2, props: props2, key: key2 } = node2;
195
+ if (type1 !== type2 || key1 !== key2) {
196
+ return false;
197
+ }
198
+ return compareReactNodes(props1, props2);
199
+ }
200
+ // Check if both objects are objects and not null.
201
+ if (typeof node1 !== "object" || typeof node2 !== "object" || node1 === null || node2 === null) {
202
+ return false;
203
+ }
204
+ // Get the keys of both objects.
205
+ const keys1 = Object.keys(node1);
206
+ const keys2 = Object.keys(node2);
207
+ // Check if the number of keys is the same.
208
+ if (keys1.length !== keys2.length) {
209
+ return false;
210
+ }
211
+ // Iterate through the keys and compare their values recursively.
212
+ for (const key of keys1) {
213
+ if (!keys2.includes(key) ||
214
+ !compareReactNodes(node1[key], node2[key])) {
215
+ return false;
216
+ }
217
+ }
218
+ // If all checks pass, the objects are deep equal.
219
+ return true;
220
+ };
221
+
182
222
  const cvaInputBase = cvaMerge([
183
223
  "component-baseInput-shadow",
184
224
  "component-baseInput-border",
185
225
  "component-baseInput-background",
186
226
  "border-slate-300",
187
- "focus-within:ring-2",
188
- "focus-within:ring-inset",
189
- "focus-within:ring-primary-500",
190
- "focus-within:border-slate-400",
191
227
  "hover:border-slate-400",
192
228
  "hover:bg-slate-50",
193
229
  "transition",
194
230
  ]);
195
231
  const cvaInputBaseDisabled = cvaMerge(["bg-slate-100", "hover:bg-slate-100", "hover:border-slate-300"]);
196
- const cvaInputBaseInvalid = cvaMerge(["border-danger-600", "focus-within:ring-danger-600"]);
232
+ const cvaInputBaseInvalid = cvaMerge(["border-danger-600"]);
197
233
  const cvaInput = cvaMerge(["relative", "flex", "h-10", cvaInputBase()], {
198
234
  variants: {
199
235
  size: {
@@ -202,24 +238,15 @@ const cvaInput = cvaMerge(["relative", "flex", "h-10", cvaInputBase()], {
202
238
  },
203
239
  disabled: {
204
240
  true: cvaInputBaseDisabled(),
205
- false: "",
241
+ false: [""],
206
242
  },
207
243
  invalid: {
208
244
  true: cvaInputBaseInvalid(),
209
- false: "",
245
+ false: [""],
210
246
  },
211
247
  },
212
248
  });
213
- const cvaInputField = cvaMerge([
214
- "w-full",
215
- "px-3",
216
- "border-0",
217
- "bg-transparent",
218
- "text-base",
219
- "text-slate-900",
220
- "placeholder-slate-400",
221
- "focus-visible:outline-none",
222
- ], {
249
+ const cvaInputField = cvaMerge(["w-full", "px-3", "border-0", "bg-transparent", "text-base", "text-slate-900", "placeholder-slate-400", "component-baseInput-border"], {
223
250
  variants: {
224
251
  size: {
225
252
  small: ["py-1"],
@@ -227,9 +254,28 @@ const cvaInputField = cvaMerge([
227
254
  },
228
255
  disabled: {
229
256
  true: ["text-slate-700"],
230
- false: "",
257
+ false: [""],
258
+ },
259
+ autoFocus: {
260
+ true: [""],
261
+ false: ["focus-visible:outline-none"],
262
+ },
263
+ addonBefore: {
264
+ true: [""],
265
+ false: [""],
266
+ },
267
+ prefix: {
268
+ true: ["ps-10"],
269
+ false: [""],
231
270
  },
232
271
  },
272
+ compoundVariants: [
273
+ {
274
+ addonBefore: true,
275
+ prefix: true,
276
+ className: ["ps-4"],
277
+ },
278
+ ],
233
279
  });
234
280
  const cvaInputAddon = cvaMerge([
235
281
  "flex",
@@ -241,7 +287,6 @@ const cvaInputAddon = cvaMerge([
241
287
  "bg-slate-50",
242
288
  ]);
243
289
  const cvaInputAddonBefore = cvaMerge([cvaInputAddon(), "border-r", "rounded-l-lg"]);
244
- const cvaInputAddonAfter = cvaMerge([cvaInputAddon(), "border-l", "rounded-r-lg"]);
245
290
  const cvaInputPrefix = cvaMerge([
246
291
  "flex",
247
292
  "justify-center",
@@ -251,21 +296,62 @@ const cvaInputPrefix = cvaMerge([
251
296
  "component-baseInput-prefix",
252
297
  "component-search-borderless",
253
298
  "pl-3",
299
+ "absolute",
300
+ "inset-y-0",
254
301
  ], {
255
302
  variants: {
256
303
  disabled: {
257
304
  true: ["text-slate-500"],
258
- false: "",
305
+ false: [""],
306
+ },
307
+ addonBefore: {
308
+ true: ["relative"],
309
+ false: [""],
259
310
  },
260
311
  },
261
312
  });
262
- const cvaInputSuffix = cvaMerge(["flex", "justify-center", "items-center", "text-slate-400", "px-3"], {
313
+ const cvaInputSuffix = cvaMerge(["flex", "justify-center", "items-center", "text-slate-400", "px-3", "absolute", "inset-y-0", "right-0"], {
263
314
  variants: {
264
315
  disabled: {
265
316
  true: ["text-slate-500"],
266
- false: "",
317
+ false: [""],
318
+ },
319
+ addonAfter: {
320
+ true: ["relative"],
321
+ false: [""],
322
+ },
323
+ actions: {
324
+ true: ["right-10"],
325
+ false: [""],
267
326
  },
268
327
  },
328
+ compoundVariants: [
329
+ {
330
+ addonAfter: true,
331
+ actions: true,
332
+ className: ["right-0"],
333
+ },
334
+ ],
335
+ });
336
+ const cvaInputAddonAfter = cvaMerge([cvaInputAddon(), "border-l", "rounded-r-lg", "ml-[1px]"]);
337
+ const cvaInputAction = cvaMerge(["absolute", "end-0.5"], {
338
+ variants: {
339
+ addonAfter: {
340
+ true: ["relative"],
341
+ false: [""],
342
+ },
343
+ suffix: {
344
+ true: ["absolute"],
345
+ false: [""],
346
+ },
347
+ },
348
+ compoundVariants: [
349
+ {
350
+ addonAfter: true,
351
+ suffix: true,
352
+ className: ["relative"],
353
+ },
354
+ ],
269
355
  });
270
356
 
271
357
  /**
@@ -277,7 +363,7 @@ const cvaInputSuffix = cvaMerge(["flex", "justify-center", "items-center", "text
277
363
  * This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
278
364
  */
279
365
  const BaseInput = React.forwardRef((_a, ref) => {
280
- var _b, _c;
366
+ var _b;
281
367
  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
368
  const renderAsDisabled = rest.disabled || rest.readOnly;
283
369
  const innerRef = React.useRef(null);
@@ -288,15 +374,29 @@ const BaseInput = React.forwardRef((_a, ref) => {
288
374
  invalid: isInvalid,
289
375
  size: fieldSize,
290
376
  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({
377
+ }), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [addonBefore ? (jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && !compareReactNodes(addonBefore, prefix) ? (jsx("div", { className: cvaInputPrefix({
378
+ disabled: renderAsDisabled,
379
+ addonBefore: addonBefore !== undefined,
380
+ }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, jsx("input", Object.assign({ "aria-required": rest.required, className: cvaInputField({
381
+ autoFocus: rest.autoFocus,
382
+ size: fieldSize,
292
383
  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({
384
+ className: inputClassName,
385
+ addonBefore: addonBefore !== undefined,
386
+ prefix: !compareReactNodes(addonBefore, prefix),
387
+ }), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef }, rest, { disabled: renderAsDisabled, readOnly: rest.readOnly || nonInteractive })), suffix && addonBefore !== suffix ? (jsx("div", { className: cvaInputSuffix({
294
388
  disabled: renderAsDisabled,
295
- }), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix })) : null, rest.readOnly === true &&
389
+ addonAfter: addonAfter !== undefined && !compareReactNodes(addonBefore, addonAfter),
390
+ actions: (actions && !compareReactNodes(addonBefore, actions)) || false,
391
+ }), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null, rest.readOnly === true &&
296
392
  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] }));
393
+ ((_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.value.length) &&
394
+ innerRef.current.value.length > 0 ? (jsx(ActionButton, { type: "COPY", value: innerRef }, "default-copy-action")) : null, actions && !compareReactNodes(addonBefore, actions) ? (jsx("div", { className: cvaInputAction({
395
+ addonAfter: addonAfter !== undefined && !compareReactNodes(addonBefore, addonAfter),
396
+ suffix: !compareReactNodes(addonBefore, suffix),
397
+ }), children: actions })) : null, addonAfter && !compareReactNodes(addonBefore, addonAfter) && !compareReactNodes(addonAfter, suffix) ? (jsx("div", { className: cvaInputAddonAfter(), "data-testid": dataTestId ? `${dataTestId}-addonAfter` : null, children: addonAfter })) : null] }));
299
398
  });
399
+ BaseInput.displayName = "BaseInput";
300
400
 
301
401
  const cvaLabel = cvaMerge([
302
402
  "text-base",
@@ -349,15 +449,11 @@ const cvaCheckbox = cvaMerge([
349
449
  "justify-center",
350
450
  "box-border",
351
451
  "transition",
352
- "focus:bg-slate-200",
353
452
  "outline-0",
354
453
  "active:bg-slate-200",
355
454
  "active:ring-2",
356
455
  "active:ring-inset",
357
456
  "active:ring-primary-700",
358
- "focus:ring-2",
359
- "focus:ring-inset",
360
- "focus:ring-primary-700",
361
457
  "cursor-pointer",
362
458
  "group-active:ring-2",
363
459
  "group-active:ring-inset",
@@ -365,13 +461,7 @@ const cvaCheckbox = cvaMerge([
365
461
  ], {
366
462
  variants: {
367
463
  invalid: {
368
- true: [
369
- "border-red-600",
370
- "active:ring-red-700",
371
- "focus:ring-red-700",
372
- "group-focus:ring-2",
373
- "group-focus:ring-inset",
374
- ],
464
+ true: ["border-red-600", "active:ring-red-700", "group-focus:ring-2", "group-focus:ring-inset"],
375
465
  false: "",
376
466
  },
377
467
  state: {
@@ -381,11 +471,8 @@ const cvaCheckbox = cvaMerge([
381
471
  "hover:bg-primary-700",
382
472
  "hover:border-primary-700",
383
473
  "active:bg-primary-700",
384
- "focus:bg-primary-700",
385
474
  "group-hover:bg-primary-700",
386
475
  "group-hover:border-primary-700",
387
- "group-focus:bg-primary-700",
388
- "group-focus:border-primary-700",
389
476
  ],
390
477
  deselected: ["group-hover:bg-slate-100"],
391
478
  indeterminate: [
@@ -393,14 +480,10 @@ const cvaCheckbox = cvaMerge([
393
480
  "border-primary-600",
394
481
  "hover:bg-primary-700",
395
482
  "hover:border-primary-700",
396
- "focus:bg-primary-800",
397
- "focus:border-primary-800",
398
483
  "active:bg-primary-800",
399
484
  "active:border-primary-800",
400
485
  "group-hover:bg-primary-700",
401
486
  "group-hover:border-primary-700",
402
- "group-focus:bg-primary-800",
403
- "group-focus:border-primary-800",
404
487
  ],
405
488
  },
406
489
  disabled: {
@@ -408,13 +491,8 @@ const cvaCheckbox = cvaMerge([
408
491
  "bg-slate-300",
409
492
  "border-slate-300",
410
493
  "cursor-not-allowed",
411
- "group-hover:bg-slate-300",
412
- "group-focus:bg-slate-300",
413
494
  "hover:bg-slate-300",
414
- "focus:bg-slate-300",
415
495
  "active:bg-slate-300",
416
- "focus:ring-0",
417
- "focus:ring-inset",
418
496
  "group-active:ring-0",
419
497
  "group-active:ring-inset",
420
498
  ],
@@ -489,10 +567,10 @@ const Checkbox = React.forwardRef((_a, ref) => {
489
567
  var _a, _b;
490
568
  e.preventDefault();
491
569
  if ("Space" === e.code) {
492
- (_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
570
+ (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
493
571
  }
494
572
  if ("Enter" === e.code) {
495
- (_b = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
573
+ (_b = internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
496
574
  }
497
575
  };
498
576
  const [labelRef, setLabelRef] = React.useState(null);
@@ -500,16 +578,17 @@ const Checkbox = React.forwardRef((_a, ref) => {
500
578
  onLabelRefChange && labelRef && onLabelRefChange(labelRef);
501
579
  }, [labelRef, onLabelRefChange]);
502
580
  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({
581
+ 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
582
  disabled: isReadonly,
505
583
  invalid: isReadonly ? false : isInvalid,
506
584
  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({
585
+ }), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label ? (jsx("span", { className: "flex", children: jsx("span", { className: cvaLabel({
508
586
  invalid: isReadonly ? false : isInvalid,
509
587
  disabled: isReadonly,
510
588
  className: "cursor-pointer",
511
- }), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })), suffix] }));
589
+ }), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })) : null, suffix] }));
512
590
  });
591
+ Checkbox.displayName = "Checkbox";
513
592
 
514
593
  /**
515
594
  * The Label component is used for labels for input fields.
@@ -549,7 +628,7 @@ const cvaHelpAddon = cvaMerge(["ml-auto"]);
549
628
  * @returns {JSX.Element} FormGroup component
550
629
  */
551
630
  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 }))] })] }));
631
+ 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
632
  };
554
633
 
555
634
  /**
@@ -560,8 +639,9 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
560
639
  const CheckboxField = forwardRef((_a, ref) => {
561
640
  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
641
  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)) }));
642
+ 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
643
  });
644
+ CheckboxField.displayName = "CheckboxField";
565
645
 
566
646
  /**
567
647
  * Validates if the given value is a valid hex color.
@@ -594,16 +674,17 @@ const ColorField = forwardRef((_a, ref) => {
594
674
  }
595
675
  }, [onChange]);
596
676
  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({
677
+ 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
678
  disabled: false,
599
679
  invalid: false,
600
680
  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) {
681
+ }), "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: () => {
682
+ if (innerRef.current) {
603
683
  innerRef.current.click();
604
684
  }
605
685
  }, variant: "ghost-neutral" })] }) }));
606
686
  });
687
+ ColorField.displayName = "ColorField";
607
688
 
608
689
  /**
609
690
  * A wrapper around BaseInput with a pop-up day picker.
@@ -615,8 +696,9 @@ const DateInput = forwardRef((_a, ref) => {
615
696
  const formatDateToInputString = (date) => isValidDate(date) ? format(date, "yyyy-MM-dd") : date;
616
697
  // Chrome and Firefox need their default icon to have datepicker functionality.
617
698
  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)));
699
+ 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
700
  });
701
+ DateInput.displayName = "DateInput";
620
702
 
621
703
  /**
622
704
  * The date field component is used for entering date values.
@@ -629,8 +711,9 @@ const DateField = forwardRef((_a, ref) => {
629
711
  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
712
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
631
713
  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 })) }));
714
+ 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
715
  });
716
+ DateField.displayName = "DateField";
634
717
 
635
718
  const cvaDropZone = cvaMerge([
636
719
  "flex",
@@ -720,7 +803,7 @@ const DropZone = (_a) => {
720
803
  e.preventDefault();
721
804
  e.stopPropagation();
722
805
  setDragActive(false);
723
- if (e.dataTransfer.files && e.dataTransfer.files[0] && !disabled) {
806
+ if (e.dataTransfer.files[0] && !disabled) {
724
807
  filesSelected(e.dataTransfer.files);
725
808
  setFileDropped(true);
726
809
  }
@@ -740,7 +823,7 @@ const DropZone = (_a) => {
740
823
  e.preventDefault();
741
824
  e.stopPropagation();
742
825
  }
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 })] })] })));
826
+ }, 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
827
  };
745
828
 
746
829
  // Doing the same check as we do on the backend
@@ -770,7 +853,7 @@ const validateEmailAddress = (email) => {
770
853
  * For specific input types make sure to use the corresponding input component.
771
854
  */
772
855
  const EmailInput = React.forwardRef((_a, ref) => {
773
- var { fieldSize = "medium", disabled = false, dataTestId, isInvalid = false, onChange } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId", "isInvalid", "onChange"]);
856
+ var { fieldSize = "medium", disabled = false, dataTestId, isInvalid = false, onChange, disableAction = false } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId", "isInvalid", "onChange", "disableAction"]);
774
857
  const [email, setEmail] = React.useState("");
775
858
  const sendEmail = () => {
776
859
  return window.open(`mailto:${email}`);
@@ -781,9 +864,9 @@ const EmailInput = React.forwardRef((_a, ref) => {
781
864
  setEmail(newValue);
782
865
  }, [onChange]);
783
866
  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)));
867
+ return (jsx(BaseInput, Object.assign({ actions: email && email.length > 0 ? (jsx(ActionButton, { dataTestId: dataTestId ? `${dataTestId}-emailIcon` : undefined, disabled: disableAction || isInvalid, iconSize: fieldSize, onClick: sendEmail, type: "EMAIL", value: email })) : null, dataTestId: dataTestId, disabled: disabled, isInvalid: renderAsInvalid, onChange: handleChange, placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email" }, rest)));
786
868
  });
869
+ EmailInput.displayName = "EmailInput";
787
870
 
788
871
  /**
789
872
  * The EmailField component is used to enter email.
@@ -803,8 +886,9 @@ const EmailField = forwardRef((_a, ref) => {
803
886
  onChange(event);
804
887
  }
805
888
  }, [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 })) }));
889
+ 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
890
  });
891
+ EmailField.displayName = "EmailField";
808
892
 
809
893
  /**
810
894
  * A thin wrapper around the `BaseInput` component for number input fields.
@@ -814,6 +898,7 @@ const EmailField = forwardRef((_a, ref) => {
814
898
  const NumberInput = forwardRef((props, ref) => {
815
899
  return jsx(BaseInput, Object.assign({ ref: ref, type: "number" }, props, { value: props.value }));
816
900
  });
901
+ NumberInput.displayName = "NumberInput";
817
902
 
818
903
  /**
819
904
  * The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
@@ -826,8 +911,9 @@ const NumberField = forwardRef((_a, ref) => {
826
911
  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
912
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
828
913
  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 })) }));
914
+ 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
915
  });
916
+ NumberField.displayName = "NumberField";
831
917
 
832
918
  const cvaOptionCardLabel = cvaMerge([
833
919
  cvaInputBase(),
@@ -861,11 +947,11 @@ const cvaOptionCardContainer = cvaMerge(["contents"]);
861
947
  const OptionCard = forwardRef((_a, ref) => {
862
948
  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
949
  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 }))] }))] })] }));
950
+ 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
951
+ ? cloneElement(icon, { className: `${icon.props.className} text-secondary-400` })
952
+ : 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
953
  });
954
+ OptionCard.displayName = "OptionCard";
869
955
 
870
956
  /**
871
957
  * A thin wrapper around the `BaseInput` component for password input fields.
@@ -876,6 +962,7 @@ const PasswordInput = forwardRef((props, ref) => {
876
962
  const [showPassword, setShowPassword] = useState(false);
877
963
  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
964
  });
965
+ PasswordInput.displayName = "PasswordInput";
879
966
 
880
967
  /**
881
968
  * Password fields enter a password or other confidential information. Characters are masked as they are typed.
@@ -891,8 +978,9 @@ const PasswordField = forwardRef((_a, ref) => {
891
978
  const handleChange = useCallback((event) => {
892
979
  onChange === null || onChange === void 0 ? void 0 : onChange(event);
893
980
  }, [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 })) }));
981
+ 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
982
  });
983
+ PasswordField.displayName = "PasswordField";
896
984
 
897
985
  /**
898
986
  * @param phoneNumber - a phone number as a string
@@ -1003,10 +1091,9 @@ const PhoneInput = forwardRef((_a, ref) => {
1003
1091
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
1004
1092
  fieldIsFocused.current = true;
1005
1093
  }, [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)) }));
1094
+ 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: 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
1095
  });
1096
+ PhoneInput.displayName = "PhoneInput";
1010
1097
 
1011
1098
  /**
1012
1099
  * The PhoneField component is used to enter phone number.
@@ -1028,8 +1115,9 @@ const PhoneField = forwardRef((_a, ref) => {
1028
1115
  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
1116
  const htmlForId = id ? id : "phoneField-" + v4();
1030
1117
  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)) }));
1118
+ 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
1119
  });
1120
+ PhoneField.displayName = "PhoneField";
1033
1121
 
1034
1122
  /**
1035
1123
  * The PhoneFieldWithController component is a wrapper for the PhoneField component to connect it to react-hook-form.
@@ -1040,6 +1128,7 @@ const PhoneFieldWithController = forwardRef((_a, ref) => {
1040
1128
  var { control, controllerProps, name, value } = _a, rest = __rest(_a, ["control", "controllerProps", "name", "value"]);
1041
1129
  return (jsx(Controller, Object.assign({ control: control, defaultValue: value, name: name }, controllerProps, { render: ({ field }) => jsx(PhoneField, Object.assign({}, rest, field, { ref: ref })) })));
1042
1130
  });
1131
+ PhoneFieldWithController.displayName = "PhoneFieldWithController";
1043
1132
 
1044
1133
  /**
1045
1134
  * Validates a phone number
@@ -1052,7 +1141,7 @@ const validatePhoneNumber = (phoneNumber) => {
1052
1141
  asYouType.input(phoneNumber);
1053
1142
  const countryCode = asYouType.getCallingCode();
1054
1143
  const national = asYouType.getNationalNumber();
1055
- const safePhoneNumber = getPhoneNumberWithPlus(phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.trim());
1144
+ const safePhoneNumber = getPhoneNumberWithPlus(phoneNumber.trim());
1056
1145
  const number = parsePhoneNumberFromString(safePhoneNumber);
1057
1146
  if (phoneNumber && isValidPhoneNumber(phoneNumber)) {
1058
1147
  return undefined;
@@ -1103,9 +1192,6 @@ const cvaRadioItem = cvaMerge([
1103
1192
  "box-border",
1104
1193
  "hover:cursor-pointer",
1105
1194
  "hover:bg-slate-100",
1106
- "focus:ring-2",
1107
- "focus:ring-inset",
1108
- "focus:ring-primary-700",
1109
1195
  ], {
1110
1196
  variants: {
1111
1197
  checked: {
@@ -1121,10 +1207,6 @@ const cvaRadioItem = cvaMerge([
1121
1207
  "active:ring-2",
1122
1208
  "active:ring-inset",
1123
1209
  "active:ring-primary-700",
1124
- "focus:bg-slate-200",
1125
- "focus:ring-2",
1126
- "focus:ring-inset",
1127
- "focus:ring-primary-700",
1128
1210
  "group-active:ring-2",
1129
1211
  "group-active:ring-inset",
1130
1212
  "group-active:ring-primary-700",
@@ -1132,13 +1214,7 @@ const cvaRadioItem = cvaMerge([
1132
1214
  false: "",
1133
1215
  },
1134
1216
  invalid: {
1135
- true: [
1136
- "border-red-600",
1137
- "active:ring-red-700",
1138
- "focus:ring-red-700",
1139
- "group-focus:ring-2",
1140
- "group-focus:ring-inset",
1141
- ],
1217
+ true: ["border-red-600", "active:ring-red-700"],
1142
1218
  false: "",
1143
1219
  },
1144
1220
  disabled: {
@@ -1146,13 +1222,8 @@ const cvaRadioItem = cvaMerge([
1146
1222
  "bg-slate-400",
1147
1223
  "border-slate-300",
1148
1224
  "cursor-not-allowed",
1149
- "group-hover:bg-slate-400",
1150
- "group-focus:bg-slate-400",
1151
1225
  "hover:bg-slate-400",
1152
- "focus:bg-slate-400",
1153
1226
  "active:bg-slate-400",
1154
- "focus:ring-0",
1155
- "focus:ring-inset",
1156
1227
  "group-active:ring-0",
1157
1228
  "group-active:ring-inset",
1158
1229
  ],
@@ -1193,7 +1264,7 @@ const RadioGroupContext = React.createContext(null);
1193
1264
  * @returns {JSX.Element} RadioGroup component
1194
1265
  */
1195
1266
  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: {
1267
+ 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
1268
  id,
1198
1269
  value,
1199
1270
  name: name || id,
@@ -1213,11 +1284,11 @@ RadioGroup.displayName = "RadioGroup";
1213
1284
  const RadioItem = ({ label, value, dataTestId, className, description, }) => {
1214
1285
  const groupCtx = React.useContext(RadioGroupContext);
1215
1286
  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({
1287
+ 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
1288
  checked: isChecked,
1218
1289
  disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
1219
1290
  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 }))] })] }));
1291
+ }), "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
1292
  };
1222
1293
 
1223
1294
  const cvaTimeRange = cvaMerge(["flex", "flex-1", "items-center", "gap-4", "border-transparent", "rounded-md"]);
@@ -1229,7 +1300,6 @@ const cvaTimeRange = cvaMerge(["flex", "flex-1", "items-center", "gap-4", "borde
1229
1300
  * @returns {JSX.Element} TimeRange component
1230
1301
  */
1231
1302
  const TimeRange = ({ id, className, dataTestId, children, range, onChange, disabled, isInvalid, }) => {
1232
- var _a, _b;
1233
1303
  const [timeRange, setTimeRange] = React__default.useState(range !== null && range !== void 0 ? range : {
1234
1304
  timeFrom: "",
1235
1305
  timeTo: "",
@@ -1241,7 +1311,7 @@ const TimeRange = ({ id, className, dataTestId, children, range, onChange, disab
1241
1311
  setTimeRange(prev => (Object.assign(Object.assign({}, prev), { timeTo })));
1242
1312
  };
1243
1313
  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 : "" })] }));
1314
+ 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
1315
  };
1246
1316
 
1247
1317
  const cvaScheduleItem = cvaMerge(["grid", "pb-4", "gap-2", "grid-cols-[60px,200px,60px,2fr]"]);
@@ -1268,7 +1338,7 @@ const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = []
1268
1338
  onChange(newSchedule);
1269
1339
  };
1270
1340
  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));
1341
+ 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
1342
  }) }));
1273
1343
  };
1274
1344
 
@@ -1316,32 +1386,19 @@ const parseSchedule = (scheduleString) => {
1316
1386
  };
1317
1387
  });
1318
1388
  const filteredSchedule = schedule
1319
- .filter(daySchedule => daySchedule.range !== null && daySchedule.range !== undefined)
1320
- .map(daySchedule => ({ day: daySchedule.day, range: daySchedule.range, isAllDay: daySchedule.isAllDay }));
1389
+ .filter(daySchedule => "range" in daySchedule && daySchedule.range)
1390
+ .map(daySchedule => ({
1391
+ day: daySchedule.day,
1392
+ range: daySchedule.range,
1393
+ isAllDay: daySchedule.isAllDay,
1394
+ }));
1321
1395
  let variant;
1322
1396
  switch (schedule.length) {
1323
1397
  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
- }
1398
+ variant = isUniform(schedule) ? ScheduleVariant.ALL_DAYS : ScheduleVariant.CUSTOM;
1335
1399
  break;
1336
1400
  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
- }
1401
+ variant = hasConsecutiveDays(schedule) ? ScheduleVariant.WEEKDAYS : ScheduleVariant.CUSTOM;
1345
1402
  break;
1346
1403
  default:
1347
1404
  return {
@@ -1363,7 +1420,7 @@ const parseSchedule = (scheduleString) => {
1363
1420
  const serializeSchedule = (weekSchedule) => {
1364
1421
  return weekSchedule.schedule
1365
1422
  .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);
1423
+ const hasRange = range.timeFrom && range.timeTo;
1367
1424
  switch (weekSchedule.variant) {
1368
1425
  case ScheduleVariant.WEEKDAYS:
1369
1426
  return day <= 5 && hasRange;
@@ -1382,6 +1439,25 @@ const serializeSchedule = (weekSchedule) => {
1382
1439
  })
1383
1440
  .join(",");
1384
1441
  };
1442
+ /**
1443
+ * Checks if a list of schedule objects have the same ranges
1444
+ *
1445
+ * @param {RawSchedule[]} schedule List of schedule objects
1446
+ * @returns {boolean} Whether the schedule is uniform
1447
+ */
1448
+ const isUniform = (schedule) => {
1449
+ 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); });
1450
+ };
1451
+ /**
1452
+ * Checks if a list of schedule objects are consecutive days
1453
+ *
1454
+ * @param {RawSchedule[]} schedule List of schedule objects
1455
+ * @returns {boolean} Whether the schedule has consecutive days
1456
+ */
1457
+ const hasConsecutiveDays = (schedule) => {
1458
+ const days = [1, 2, 3, 4, 5];
1459
+ return schedule.every(({ day }, index) => day === days[index]);
1460
+ };
1385
1461
 
1386
1462
  /**
1387
1463
  * A thin wrapper around the `BaseInput` component for text input fields.
@@ -1389,6 +1465,7 @@ const serializeSchedule = (weekSchedule) => {
1389
1465
  * NOTE: If shown with a label, please use the `TextField` component instead.
1390
1466
  */
1391
1467
  const TextInput = forwardRef((props, ref) => (jsx(BaseInput, Object.assign({ ref: ref, type: "text" }, props))));
1468
+ TextInput.displayName = "TextInput";
1392
1469
 
1393
1470
  const cvaSearch = cvaMerge([
1394
1471
  "shadow-none",
@@ -1396,21 +1473,13 @@ const cvaSearch = cvaMerge([
1396
1473
  "component-search-background",
1397
1474
  "hover:component-search-background",
1398
1475
  "hover:component-search-focus-hover",
1399
- "focus:component-search-focus-hover",
1400
- "focus-within:component-search-focus-within",
1401
1476
  "transition-all",
1402
1477
  "duration-300",
1403
1478
  ], {
1404
1479
  variants: {
1405
1480
  border: { true: ["!component-search-borderless"], false: "" },
1406
1481
  widenOnFocus: {
1407
- true: [
1408
- "component-search-width",
1409
- "component-search-widen",
1410
- "hover:component-search-widen",
1411
- "focus-within:component-search-widen-focus",
1412
- "focus-within:w-full",
1413
- ],
1482
+ true: ["component-search-width", "component-search-widen", "hover:component-search-widen"],
1414
1483
  false: "w-full",
1415
1484
  },
1416
1485
  },
@@ -1424,35 +1493,30 @@ const cvaSearch = cvaMerge([
1424
1493
  */
1425
1494
  const Search = forwardRef((_a, ref) => {
1426
1495
  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: () => {
1496
+ 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
1497
  onClear();
1429
1498
  }, children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value })));
1430
1499
  });
1500
+ Search.displayName = "Search";
1431
1501
 
1432
1502
  const cvaSelect = cvaMerge([
1433
1503
  "relative",
1434
1504
  "flex",
1435
1505
  "shadow-sm",
1436
1506
  "rounded-lg",
1437
- "border",
1438
1507
  "border-slate-300",
1439
- "focus-within:ring-2",
1440
- "focus-within:ring-inset",
1441
- "focus-within:ring-primary-600",
1442
- "focus-within:border-slate-400",
1443
1508
  "hover:border-slate-400",
1444
1509
  "hover:bg-slate-50",
1445
1510
  "bg-white",
1446
1511
  "transition",
1447
- "overflow-hidden",
1448
1512
  ], {
1449
1513
  variants: {
1450
1514
  invalid: {
1451
- true: "border-red-600 text-red-600 focus-within:ring-red-600 hover:border-red-600",
1515
+ true: "border border-red-600 text-red-600 hover:border-red-600",
1452
1516
  false: "",
1453
1517
  },
1454
1518
  disabled: {
1455
- true: "!bg-slate-100",
1519
+ true: "!bg-slate-100 hover:border-slate-300",
1456
1520
  false: "",
1457
1521
  },
1458
1522
  },
@@ -1461,10 +1525,56 @@ const cvaSelect = cvaMerge([
1461
1525
  disabled: false,
1462
1526
  },
1463
1527
  });
1464
- const cvaSelectIcon = cvaMerge(["mr-2", "flex", "cursor-pointer", "items-center", "justify-center", "text-slate-400", "hover:text-slate-500"]);
1465
- const cvaSelectPrefix = cvaMerge(["flex", "justify-center", "items-center", "text-slate-400", "pl-2"]);
1466
- const cvaSelectXIcon = cvaMerge(["mr-2", "flex", "cursor-pointer", "items-center", "justify-center", "text-slate-400", "hover:text-slate-500", "ml-1"]);
1467
- const cvaSelectMenuList = cvaMerge(["min-w-min", "shadow-md", "rounded-lg", "z-20", "bg-white", "p-1", "border", "border-slate-300", "gap-1", "grid"], {
1528
+ const cvaSelectControl = cvaMerge([], {
1529
+ variants: {
1530
+ isDisabled: {
1531
+ true: "!bg-slate-100",
1532
+ false: "",
1533
+ },
1534
+ prefix: {
1535
+ true: ["ps-7"],
1536
+ false: "",
1537
+ },
1538
+ invalid: {
1539
+ true: "!border-0",
1540
+ false: "",
1541
+ },
1542
+ },
1543
+ defaultVariants: {
1544
+ isDisabled: false,
1545
+ prefix: false,
1546
+ invalid: false,
1547
+ },
1548
+ });
1549
+ const cvaSelectIcon = cvaMerge([
1550
+ "mr-2",
1551
+ "flex",
1552
+ "cursor-pointer",
1553
+ "items-center",
1554
+ "justify-center",
1555
+ "text-slate-400",
1556
+ "hover:text-slate-500",
1557
+ ]);
1558
+ const cvaSelectPrefix = cvaMerge([
1559
+ "flex",
1560
+ "justify-center",
1561
+ "items-center",
1562
+ "text-slate-400",
1563
+ "pl-2",
1564
+ "absolute",
1565
+ "inset-y-0",
1566
+ ]);
1567
+ const cvaSelectXIcon = cvaMerge([
1568
+ "mr-2",
1569
+ "flex",
1570
+ "cursor-pointer",
1571
+ "items-center",
1572
+ "justify-center",
1573
+ "text-slate-400",
1574
+ "hover:text-slate-500",
1575
+ "ml-1",
1576
+ ]);
1577
+ const cvaSelectMenuList = cvaMerge([], {
1468
1578
  variants: {
1469
1579
  menuIsOpen: {
1470
1580
  true: "animate-fade-in-fast",
@@ -1488,6 +1598,8 @@ function isMultiValue(arg) {
1488
1598
  return Array.isArray(arg);
1489
1599
  }
1490
1600
  function isGroupBase(arg) {
1601
+ // This is apparently needed
1602
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1491
1603
  return arg.options !== undefined;
1492
1604
  }
1493
1605
  const isSelectedOption = (option, selected) => {
@@ -1523,7 +1635,7 @@ const getOrderedOptions = (options, value) => {
1523
1635
  .filter(option => !isSelectedOption(option, value))
1524
1636
  .map(option => removeSelectedFromGroups(option, value));
1525
1637
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1526
- return orderedValues.concat(selectableOptions) || [];
1638
+ return orderedValues.concat(selectableOptions);
1527
1639
  }
1528
1640
  return options || [];
1529
1641
  };
@@ -1584,7 +1696,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
1584
1696
  const itemsCount = items.length;
1585
1697
  React__default.useLayoutEffect(() => {
1586
1698
  var _a;
1587
- availableWidth.current = ((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
1699
+ availableWidth.current = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
1588
1700
  }, [containerRef]);
1589
1701
  const onWidthKnownHandler = ({ width: reportedWidth }) => {
1590
1702
  childrenWidth.current.push({ width: reportedWidth + itemsGap });
@@ -1596,7 +1708,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
1596
1708
  return previous + current.width;
1597
1709
  }, 0);
1598
1710
  let counter = 0;
1599
- const availableSpace = ((availableWidth === null || availableWidth === void 0 ? void 0 : availableWidth.current) || 0) - counterWidth;
1711
+ const availableSpace = (availableWidth.current || 0) - counterWidth;
1600
1712
  const renderedElements = items
1601
1713
  .concat({ text: "", onClick: () => null, disabled: false }) // reserved element for a potential counter
1602
1714
  .map((item, index) => {
@@ -1645,7 +1757,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
1645
1757
  * @param {JSX.Element} dropdownIcon an custom dropdown icon
1646
1758
  * @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
1647
1759
  */
1648
- const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
1760
+ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon, prefix, hasError) => {
1649
1761
  const [t] = useTranslation();
1650
1762
  // perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
1651
1763
  const customComponents = React.useMemo(() => {
@@ -1653,9 +1765,12 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1653
1765
  var _a;
1654
1766
  if (props.isMulti && Array.isArray(props.children) && props.children.length > 0) {
1655
1767
  const PLACEHOLDER_KEY = "placeholder";
1768
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1656
1769
  const key = props && props.children && props.children[0] ? (_a = props.children[0]) === null || _a === void 0 ? void 0 : _a.key : "";
1770
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1657
1771
  const values = props && props.children ? props.children[0] : [];
1658
1772
  const tags = key === PLACEHOLDER_KEY ? [] : values;
1773
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1659
1774
  const searchInput = props && props.children && props.children[1];
1660
1775
  return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsx(TagsContainer, { disabled: disabled, items: tags
1661
1776
  ? tags.map(({ props: tagProps }) => {
@@ -1664,27 +1779,26 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1664
1779
  onClick: disabled
1665
1780
  ? undefined
1666
1781
  : (e) => {
1667
- var _a, _b;
1668
1782
  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));
1783
+ tagProps.removeProps.onClick && tagProps.removeProps.onClick(e);
1670
1784
  },
1671
1785
  disabled: disabled,
1672
1786
  };
1673
1787
  })
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;
1788
+ : [], postFix: searchInput, width: "100%" })) : (jsxs(Fragment, { children: [tags
1789
+ ? tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
1790
+ var _a;
1791
+ return (jsx(Tag, { className: "inline-flex shrink-0", color: disabled ? "unknown" : "primary", dataTestId: tagProps.children ? `${tagProps.children.toString()}-tag` : undefined, onClose: e => {
1679
1792
  e.stopPropagation();
1680
1793
  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] })) })));
1794
+ tagProps.removeProps.onClick && tagProps.removeProps.onClick(e);
1795
+ }, children: tagProps.children }, (_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()));
1796
+ })
1797
+ : null, tags && tags.length > maxSelectedDisplayCount ? (jsxs(Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })) : null, searchInput] })) })));
1684
1798
  }
1685
1799
  return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: props.children })));
1686
1800
  }, LoadingIndicator: props => {
1687
- return jsx(Spinner, { className: "mt-1.5 mr-1", size: "small" });
1801
+ return jsx(Spinner, { className: "mr-1 mt-1.5", size: "small" });
1688
1802
  }, DropdownIndicator: props => {
1689
1803
  const icon = props.selectProps.menuIsOpen ? (jsx(Icon, { name: "ChevronUp", size: "medium" })) : (jsx(Icon, { name: "ChevronDown", size: "medium" }));
1690
1804
  return props.selectProps.isLoading ? null : (jsx(components.DropdownIndicator, Object.assign({}, props, { children: jsx("div", { className: cvaSelectIcon(), children: dropdownIcon ? dropdownIcon : icon }) })));
@@ -1692,9 +1806,13 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1692
1806
  if (disabled) {
1693
1807
  return null;
1694
1808
  }
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") }) }) })));
1809
+ 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
1810
  }, Control: props => {
1697
- return jsx(components.Control, Object.assign({}, props, { className: props.isDisabled ? "bg-slate-100" : "" }));
1811
+ return (jsx(components.Control, Object.assign({}, props, { className: cvaSelectControl({
1812
+ isDisabled: props.isDisabled,
1813
+ prefix: prefix ? true : false,
1814
+ invalid: hasError,
1815
+ }) })));
1698
1816
  }, SingleValue: props => {
1699
1817
  return (jsx(components.SingleValue, Object.assign({}, props, { className: props.isDisabled ? "text-slate-700" : "", children: jsx("div", { "data-testid": dataTestId + "-singleValue", children: props.children }) })));
1700
1818
  }, Menu: props => {
@@ -1734,18 +1852,16 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
1734
1852
  const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, styles, disabled) => {
1735
1853
  const customStyles = React.useMemo(() => {
1736
1854
  return Object.assign({ control: base => {
1737
- return Object.assign(Object.assign({}, base), { border: "0", boxShadow: "0", "&:hover": {
1738
- border: "0",
1739
- }, backgroundColor: "" });
1855
+ return Object.assign(Object.assign({}, base), { borderRadius: "var(--border-radius-lg)", backgroundColor: "" });
1740
1856
  }, singleValue: base => (Object.assign({}, base)), multiValue: base => (Object.assign({}, base)), multiValueLabel: base => (Object.assign({}, base)), indicatorsContainer: base => (Object.assign(Object.assign({}, base), (disabled && { display: "none" }))), indicatorSeparator: () => ({
1741
1857
  width: "0px",
1742
1858
  }), menu: base => {
1743
1859
  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 => {
1860
+ }, 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: "translate(0px, 0px)", 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
1861
  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
1862
  }, valueContainer: base => {
1747
1863
  return Object.assign(Object.assign({}, base), { flexWrap: maxSelectedDisplayCount !== undefined ? "wrap" : "nowrap", gap: "0.25rem" });
1748
- }, container: base => (Object.assign(Object.assign({}, base), { border: "none", width: "100%" })), dropdownIndicator: base => (Object.assign(Object.assign({}, base), { padding: "0px" })), clearIndicator: base => {
1864
+ }, container: base => (Object.assign(Object.assign({}, base), { width: "100%" })), dropdownIndicator: base => (Object.assign(Object.assign({}, base), { padding: "0px" })), clearIndicator: base => {
1749
1865
  return Object.assign(Object.assign({}, base), { padding: "0px" });
1750
1866
  } }, styles);
1751
1867
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1767,7 +1883,7 @@ const useSelect = (_a) => {
1767
1883
  const { customStyles } = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles, disabled);
1768
1884
  const [menuIsOpen, setMenuIsOpen] = React__default.useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
1769
1885
  const refMenuIsEnabled = React__default.useRef(true);
1770
- const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
1886
+ const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon, prefix, hasError);
1771
1887
  const menuPlacement = "auto";
1772
1888
  const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
1773
1889
  onMenuOpen && onMenuOpen();
@@ -1810,7 +1926,7 @@ const useSelect = (_a) => {
1810
1926
  */
1811
1927
  const CreatableSelect = (props) => {
1812
1928
  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;
1929
+ 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
1930
  const { refContainer, refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
1815
1931
  const creatableSelectProps = {
1816
1932
  value,
@@ -1840,9 +1956,11 @@ const CreatableSelect = (props) => {
1840
1956
  onInputChange,
1841
1957
  allowCreateWhileLoading,
1842
1958
  onCreateOption,
1959
+ isDisabled: disabled || props.isDisabled,
1960
+ readOnly,
1843
1961
  };
1844
1962
  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 })))] }));
1963
+ 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
1964
  };
1847
1965
  CreatableSelect.displayName = "CreatableSelect";
1848
1966
 
@@ -1854,7 +1972,7 @@ CreatableSelect.displayName = "CreatableSelect";
1854
1972
  */
1855
1973
  const Select = (props) => {
1856
1974
  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;
1975
+ 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
1976
  const { refContainer, refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
1859
1977
  const selectProps = {
1860
1978
  value,
@@ -1883,9 +2001,11 @@ const Select = (props) => {
1883
2001
  onMenuScrollToBottom,
1884
2002
  onInputChange,
1885
2003
  hideSelectedOptions,
2004
+ isDisabled: disabled || props.isDisabled,
2005
+ readOnly,
1886
2006
  };
1887
2007
  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 })))] }));
2008
+ 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
2009
  };
1890
2010
  Select.displayName = "Select";
1891
2011
 
@@ -1938,6 +2058,7 @@ const FormFieldSelectAdapter = forwardRef((_a, ref) => {
1938
2058
  setInnerValue(!e ? "" : e.value);
1939
2059
  }, value: selectedOption, defaultValue: selectedOption }))] }));
1940
2060
  });
2061
+ FormFieldSelectAdapter.displayName = "FormFieldSelectAdapter";
1941
2062
 
1942
2063
  /**
1943
2064
  * The CreatableSelectField component is a CreatableSelect component wrapped in the FromGroup component.
@@ -1954,6 +2075,7 @@ const CreatableSelectField = forwardRef((_a, ref) => {
1954
2075
  const creatableSelectOnlyProps = { allowCreateWhileLoading, onCreateOption };
1955
2076
  return (jsx(FormFieldSelectAdapter, Object.assign({}, props, { ref: ref, children: convertedProps => jsx(CreatableSelect, Object.assign({}, convertedProps, creatableSelectOnlyProps)) })));
1956
2077
  });
2078
+ CreatableSelectField.displayName = "CreatableSelectField";
1957
2079
 
1958
2080
  /**
1959
2081
  * The SelectField component is a Select component wrapped in the FromGroup component.
@@ -1969,6 +2091,7 @@ const SelectField = forwardRef((_a, ref) => {
1969
2091
  var props = __rest(_a, []);
1970
2092
  return (jsx(FormFieldSelectAdapter, Object.assign({}, props, { ref: ref, children: convertedProps => jsx(Select, Object.assign({}, convertedProps)) })));
1971
2093
  });
2094
+ SelectField.displayName = "SelectField";
1972
2095
 
1973
2096
  const cvaTextArea = cvaMerge([
1974
2097
  cvaInputBase(),
@@ -1980,7 +2103,6 @@ const cvaTextArea = cvaMerge([
1980
2103
  "text-base",
1981
2104
  "text-slate-900",
1982
2105
  "placeholder-slate-400",
1983
- "focus-visible:outline-none",
1984
2106
  "w-full",
1985
2107
  "h-20",
1986
2108
  "transition",
@@ -2011,6 +2133,7 @@ const TextArea = React.forwardRef((_a, ref) => {
2011
2133
  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
2134
  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
2135
  });
2136
+ TextArea.displayName = "TextArea";
2014
2137
 
2015
2138
  /**
2016
2139
  * The TextLengthIndicator component shows a `{length}/{maxLength}` label.
@@ -2034,9 +2157,10 @@ const TextAreaField = React.forwardRef((_a, ref) => {
2034
2157
  onChange(event);
2035
2158
  }
2036
2159
  }, [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 })) }));
2160
+ return (jsx(FormGroup, { className: twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
2161
+ (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
2162
  });
2163
+ TextAreaField.displayName = "TextAreaField";
2040
2164
 
2041
2165
  /**
2042
2166
  * 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 +2180,10 @@ const TextField = React.forwardRef((_a, ref) => {
2056
2180
  onChange(event);
2057
2181
  }
2058
2182
  }, [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 })) }));
2183
+ return (jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
2184
+ (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", id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value }, rest, { className: className, dataTestId: dataTestId, onChange: handleChange })) }));
2061
2185
  });
2186
+ TextField.displayName = "TextField";
2062
2187
 
2063
2188
  /**
2064
2189
  * TimeRangeField Description. <-- Please add a proper Description this is used in Storybook.
@@ -2070,21 +2195,12 @@ const TimeRangeField = (_a) => {
2070
2195
  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
2196
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
2072
2197
  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 })) }));
2198
+ 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
2199
  };
2075
2200
 
2076
2201
  const cvaToggleWrapper = cvaMerge(["flex", "gap-2", "items-center"]);
2077
2202
  cvaMerge(["relative"]);
2078
- const cvaToggleTrack = cvaMerge([
2079
- "shrink-0",
2080
- "p-1",
2081
- "cursor-pointer",
2082
- "rounded-full",
2083
- "bg-slate-300",
2084
- "focus:bg-slate-400",
2085
- "hover:bg-slate-400",
2086
- "active:bg-slate-500",
2087
- ], {
2203
+ const cvaToggleTrack = cvaMerge(["shrink-0", "p-1", "cursor-pointer", "rounded-full", "bg-slate-300", "hover:bg-slate-400", "active:bg-slate-500"], {
2088
2204
  variants: {
2089
2205
  size: {
2090
2206
  small: ["w-8", "h-4"],
@@ -2095,7 +2211,7 @@ const cvaToggleTrack = cvaMerge([
2095
2211
  false: "",
2096
2212
  },
2097
2213
  toggled: {
2098
- true: ["bg-primary-600", "focus:bg-primary-700", "hover:bg-primary-700", "active:bg-primary-800"],
2214
+ true: ["bg-primary-600", "hover:bg-primary-700", "active:bg-primary-800"],
2099
2215
  false: "",
2100
2216
  },
2101
2217
  },
@@ -2145,11 +2261,12 @@ const Toggle = React.forwardRef(({ toggled = false, onChange, onClick, disabled,
2145
2261
  const showLabelContainer = Boolean(name || description);
2146
2262
  const showDescription = Boolean(description);
2147
2263
  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 => {
2264
+ 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
2265
  e.stopPropagation();
2150
2266
  onChange(!toggled, e);
2151
2267
  }, ref: ref, required: required, tabIndex: tabIndex, type: "checkbox" })] }) }));
2152
2268
  });
2269
+ Toggle.displayName = "Toggle";
2153
2270
 
2154
2271
  const cvaUploadInputField = cvaMerge([
2155
2272
  "px-0",
@@ -2178,6 +2295,7 @@ const UploadInput = forwardRef((_a, ref) => {
2178
2295
  }
2179
2296
  }, ref: ref, type: "file" }, rest)) }));
2180
2297
  });
2298
+ UploadInput.displayName = "UploadInput";
2181
2299
 
2182
2300
  /**
2183
2301
  * Upload fields enable the user to upload Files.
@@ -2188,6 +2306,7 @@ const UploadField = forwardRef((_a, ref) => {
2188
2306
  const htmlForId = id ? id : "uploadField-" + v4();
2189
2307
  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
2308
  });
2309
+ UploadField.displayName = "UploadField";
2191
2310
 
2192
2311
  /**
2193
2312
  * @description Validate given url id.
@@ -2213,8 +2332,9 @@ const UrlInput = forwardRef((_a, ref) => {
2213
2332
  var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction", "value", "defaultValue"]);
2214
2333
  const [url, setUrl] = useState((value === null || value === void 0 ? void 0 : value.toString()) || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()));
2215
2334
  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 })) })));
2335
+ 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 || disableAction, iconSize: fieldSize, type: "WEB_ADDRESS", value: url })) })));
2217
2336
  });
2337
+ UrlInput.displayName = "UrlField";
2218
2338
 
2219
2339
  /**
2220
2340
  * The UrlField component is used to enter url.
@@ -2229,8 +2349,9 @@ const UrlField = forwardRef((_a, ref) => {
2229
2349
  return typeof inputValue === "string";
2230
2350
  }
2231
2351
  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 })) }));
2352
+ 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", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, value: value || defaultValue }, rest, { className: className, dataTestId: dataTestId })) }));
2233
2353
  });
2354
+ UrlField.displayName = "UrlField";
2234
2355
 
2235
2356
  /**
2236
2357
  * Custom hook to get phone number validation rules.
@@ -2247,7 +2368,7 @@ const useGetPhoneValidationRules = () => {
2247
2368
  const pattern = {
2248
2369
  validate: (value) => {
2249
2370
  const validationResult = t(`phoneField.error.${validatePhoneNumber(value)}`);
2250
- return !validationResult || value === "" || value === undefined || value === null || validationResult;
2371
+ return !validationResult || !value || validationResult;
2251
2372
  },
2252
2373
  };
2253
2374
  return !skipValidation
@@ -2336,4 +2457,4 @@ const useZodValidators = () => {
2336
2457
  */
2337
2458
  setupLibraryTranslations();
2338
2459
 
2339
- export { ActionButton, BaseInput, Checkbox, CheckboxField, ColorField, CreatableSelect, CreatableSelectField, DateField, DateInput, DropZone, EMAIL_REGEX, EmailField, EmailInput, FormFieldSelectAdapter, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneFieldWithController, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SelectField, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaActionButton, cvaActionContainer, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, isValidHEXColor, parseSchedule, serializeSchedule, useCustomComponents, useGetPhoneValidationRules, usePhoneInput, useZodValidators, validateEmailAddress, validatePhoneNumber, weekDay };
2460
+ export { ActionButton, BaseInput, Checkbox, CheckboxField, ColorField, CreatableSelect, CreatableSelectField, DateField, DateInput, DropZone, EMAIL_REGEX, EmailField, EmailInput, FormFieldSelectAdapter, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneFieldWithController, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SelectField, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaActionButton, cvaActionContainer, cvaInput, cvaInputAction, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectControl, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, isValidHEXColor, parseSchedule, serializeSchedule, useCustomComponents, useGetPhoneValidationRules, usePhoneInput, useZodValidators, validateEmailAddress, validatePhoneNumber, weekDay };