@dmsi/wedgekit-react 0.0.208 → 0.0.209

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.
@@ -246,66 +246,78 @@ var gapUsingContainerPadding = (0, import_clsx.default)(
246
246
  "gap-mobile-container-padding desktop:gap-desktop-container-padding compact:gap-desktop-compact-container-padding"
247
247
  );
248
248
 
249
- // src/components/Icon.tsx
249
+ // src/components/MenuOption.tsx
250
+ var import_clsx5 = __toESM(require("clsx"), 1);
251
+ var import_react6 = require("react");
252
+
253
+ // src/components/Label.tsx
250
254
  var import_clsx2 = __toESM(require("clsx"), 1);
251
255
  var import_jsx_runtime = require("react/jsx-runtime");
252
- function Icon(_a) {
256
+ var Label = (_a) => {
253
257
  var _b = _a, {
254
- name,
255
- size = 24,
256
- variant = "outline",
258
+ as = "span",
259
+ padded,
260
+ className,
261
+ color,
262
+ align,
263
+ id,
257
264
  testid
258
265
  } = _b, props = __objRest(_b, [
259
- "name",
260
- "size",
261
- "variant",
266
+ "as",
267
+ "padded",
268
+ "className",
269
+ "color",
270
+ "align",
271
+ "id",
262
272
  "testid"
263
273
  ]);
264
- const variantStyle = variant === "filled" ? '"FILL" 1' : '"FILL" 0';
265
- const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
274
+ const Element = as;
266
275
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
267
- "span",
268
- __spreadProps(__spreadValues({}, props), {
276
+ Element,
277
+ __spreadProps(__spreadValues({
278
+ id,
269
279
  "data-testid": testid,
270
280
  className: (0, import_clsx2.default)(
271
- "icon",
272
- `icon-${size}`,
273
- // size === 16 ? "font-normal" : "font-light", // size 16 font weight is not working as normal from before
274
- props.className
275
- ),
276
- style: __spreadValues({
277
- fontVariationSettings: variantStyle + `, ${weightStyle}`
278
- }, props.style),
279
- children: name
281
+ typography.label,
282
+ align === "left" && "text-left",
283
+ align === "center" && "text-center",
284
+ align === "right" && "text-right",
285
+ className,
286
+ padded && componentPaddingXUsingComponentGap
287
+ )
288
+ }, props), {
289
+ style: __spreadProps(__spreadValues({}, props.style), {
290
+ color: color ? `var(--color-${color})` : void 0
291
+ })
280
292
  })
281
293
  );
282
- }
283
-
284
- // src/components/Search.tsx
285
- var import_react3 = require("react");
286
-
287
- // src/components/Input.tsx
288
- var import_react2 = require("react");
289
- var import_clsx4 = __toESM(require("clsx"), 1);
294
+ };
295
+ Label.displayName = "Label";
290
296
 
291
- // src/components/Label.tsx
297
+ // src/components/Paragraph.tsx
292
298
  var import_clsx3 = __toESM(require("clsx"), 1);
293
299
  var import_jsx_runtime2 = require("react/jsx-runtime");
294
- var Label = (_a) => {
300
+ var Paragraph = (_a) => {
295
301
  var _b = _a, {
296
- as = "span",
297
- padded,
298
302
  className,
299
303
  color,
300
- align,
304
+ padded,
305
+ align = "left",
306
+ tall,
307
+ addOverflow,
308
+ children,
309
+ as = "p",
301
310
  id,
302
311
  testid
303
312
  } = _b, props = __objRest(_b, [
304
- "as",
305
- "padded",
306
313
  "className",
307
314
  "color",
315
+ "padded",
308
316
  "align",
317
+ "tall",
318
+ "addOverflow",
319
+ "children",
320
+ "as",
309
321
  "id",
310
322
  "testid"
311
323
  ]);
@@ -314,23 +326,82 @@ var Label = (_a) => {
314
326
  Element,
315
327
  __spreadProps(__spreadValues({
316
328
  id,
317
- "data-testid": testid,
329
+ "data-testid": testid
330
+ }, props), {
318
331
  className: (0, import_clsx3.default)(
319
- typography.label,
332
+ typography.paragraph,
333
+ className,
334
+ padded && componentPaddingXUsingComponentGap,
320
335
  align === "left" && "text-left",
321
336
  align === "center" && "text-center",
322
337
  align === "right" && "text-right",
323
- className,
324
- padded && componentPaddingXUsingComponentGap
325
- )
326
- }, props), {
338
+ tall && "!leading-6",
339
+ addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
340
+ ),
327
341
  style: __spreadProps(__spreadValues({}, props.style), {
328
342
  color: color ? `var(--color-${color})` : void 0
329
- })
343
+ }),
344
+ children
330
345
  })
331
346
  );
332
347
  };
333
- Label.displayName = "Label";
348
+ Paragraph.displayName = "Paragraph";
349
+
350
+ // src/components/Icon.tsx
351
+ var import_clsx4 = __toESM(require("clsx"), 1);
352
+ var import_jsx_runtime3 = require("react/jsx-runtime");
353
+ function Icon(_a) {
354
+ var _b = _a, {
355
+ name,
356
+ size = 24,
357
+ variant = "outline",
358
+ testid
359
+ } = _b, props = __objRest(_b, [
360
+ "name",
361
+ "size",
362
+ "variant",
363
+ "testid"
364
+ ]);
365
+ const variantStyle = variant === "filled" ? '"FILL" 1' : '"FILL" 0';
366
+ const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
367
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
368
+ "span",
369
+ __spreadProps(__spreadValues({}, props), {
370
+ "data-testid": testid,
371
+ className: (0, import_clsx4.default)(
372
+ "icon",
373
+ `icon-${size}`,
374
+ // size === 16 ? "font-normal" : "font-light", // size 16 font weight is not working as normal from before
375
+ props.className
376
+ ),
377
+ style: __spreadValues({
378
+ fontVariationSettings: variantStyle + `, ${weightStyle}`
379
+ }, props.style),
380
+ children: name
381
+ })
382
+ );
383
+ }
384
+
385
+ // src/hooks/useKeydown.ts
386
+ var import_react2 = require("react");
387
+
388
+ // src/hooks/useInfiniteScroll.tsx
389
+ var import_react3 = require("react");
390
+
391
+ // src/hooks/useMatchesMedia.ts
392
+ var import_react4 = require("react");
393
+ var useMatchesMedia = (query) => {
394
+ const [matches, setMatches] = (0, import_react4.useState)();
395
+ (0, import_react4.useLayoutEffect)(() => {
396
+ const mediaQueryList = window.matchMedia(query);
397
+ const listener = () => setMatches(mediaQueryList.matches);
398
+ listener();
399
+ mediaQueryList.addEventListener("change", listener);
400
+ return () => mediaQueryList.removeEventListener("change", listener);
401
+ }, [query]);
402
+ return matches;
403
+ };
404
+ var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
334
405
 
335
406
  // src/utils/formatting.tsx
336
407
  function getDecimalPlaceholder(decimals) {
@@ -365,578 +436,235 @@ function formatCurrencyDisplay(value) {
365
436
  return decimalPart !== void 0 ? `${formattedInteger}.${decimalPart}` : formattedInteger;
366
437
  }
367
438
 
368
- // src/components/Input.tsx
369
- var import_jsx_runtime3 = require("react/jsx-runtime");
370
- var InputBase = (_a) => {
371
- var _b = _a, {
372
- id,
373
- testid,
374
- before,
375
- after,
376
- type,
377
- label,
378
- error,
379
- className,
380
- align = "left",
381
- caption,
382
- required,
383
- selectOnFocus,
384
- removeRoundness,
385
- inputContainerRef,
386
- removeBorder,
387
- wrapperClassName,
388
- focus,
389
- fullWidth = true
390
- } = _b, props = __objRest(_b, [
391
- "id",
392
- "testid",
393
- "before",
394
- "after",
395
- "type",
396
- "label",
397
- "error",
398
- "className",
399
- "align",
400
- "caption",
401
- "required",
402
- "selectOnFocus",
403
- "removeRoundness",
404
- "inputContainerRef",
405
- "removeBorder",
406
- "wrapperClassName",
407
- "focus",
408
- "fullWidth"
409
- ]);
410
- const attributes = {
411
- "data-error": error && !focus || null,
412
- "data-focus": focus || null
413
- };
414
- const inputRef = (0, import_react2.useRef)(null);
415
- const inputId = id ? `${id}-input` : void 0;
416
- (0, import_react2.useEffect)(() => {
417
- var _a2;
418
- const input = inputRef.current;
419
- const focusHandler = () => {
420
- input == null ? void 0 : input.select();
421
- };
422
- if (selectOnFocus) {
423
- (_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
424
- return () => {
425
- input == null ? void 0 : input.removeEventListener("focus", focusHandler);
426
- };
439
+ // src/utils.ts
440
+ function findDocumentRoot(element) {
441
+ if (typeof window === "undefined" || typeof document === "undefined") {
442
+ throw new Error(
443
+ "findDocumentRoot can only be used in a browser environment."
444
+ );
445
+ }
446
+ if (!element || !(element instanceof Node)) {
447
+ return window.document.body;
448
+ }
449
+ let currentElement = element;
450
+ while (currentElement && currentElement.parentNode) {
451
+ if (currentElement.parentNode === document) {
452
+ return document.body;
453
+ } else if (currentElement.parentNode instanceof DocumentFragment) {
454
+ return currentElement.parentNode;
455
+ } else {
456
+ currentElement = currentElement.parentNode;
427
457
  }
428
- }, [selectOnFocus]);
429
- const inputBaseClass = (0, import_clsx4.default)(
430
- fullWidth ? "w-full" : "w-fit",
431
- "flex flex-row items-center",
432
- "bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
433
- componentGap,
434
- baseTransition,
435
- "outline-transparent outline-2 -outline-offset-2",
436
- componentPaddingMinusBorder,
437
- !removeRoundness && "rounded-base",
438
- !removeBorder && "border border-border-primary-normal",
439
- "relative"
440
- );
441
- const inputFocusClass = (0, import_clsx4.default)(
442
- "has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
443
- );
444
- const inputDisabledClass = (0, import_clsx4.default)(
445
- "has-disabled:bg-background-action-secondary-disabled"
446
- );
447
- const inputReadOnlyClass = (0, import_clsx4.default)(
448
- "has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
449
- );
450
- const inputInvalidClass = (0, import_clsx4.default)(
451
- "has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
452
- );
453
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
454
- "label",
455
- {
456
- id,
457
- "data-testid": testid,
458
- htmlFor: inputId,
459
- ref: inputContainerRef,
460
- className: (0, import_clsx4.default)(
461
- "w-full flex flex-col",
462
- "block",
463
- "text-text-primary-normal has-disabled:text-text-primary-disabled",
464
- componentGap
465
- ),
466
- style: __spreadValues({}, props.style),
467
- children: [
468
- label && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_clsx4.default)("flex items-center", componentGap), children: [
469
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
470
- Label,
471
- {
472
- id: id ? `${id}-label` : void 0,
473
- className: (0, import_clsx4.default)(
474
- props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
475
- ),
476
- children: label
477
- }
478
- ),
479
- required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
480
- "span",
481
- {
482
- className: (0, import_clsx4.default)(typography.label, "text-text-critical-normal"),
483
- children: "*"
484
- }
485
- )
486
- ] }),
487
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
488
- "div",
489
- {
490
- className: (0, import_clsx4.default)(
491
- inputBaseClass,
492
- !props.disabled && inputInvalidClass,
493
- inputFocusClass,
494
- inputDisabledClass,
495
- inputReadOnlyClass,
496
- wrapperClassName
497
- ),
498
- children: [
499
- before,
500
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
501
- "input",
502
- __spreadProps(__spreadValues(__spreadValues({
503
- ref: (el) => {
504
- inputRef.current = el;
505
- },
506
- type,
507
- required
508
- }, props), attributes), {
509
- id: inputId,
510
- "data-testid": testid ? `${testid}-input` : void 0,
511
- className: (0, import_clsx4.default)(
512
- "flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
513
- "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
514
- "placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
515
- align === "right" && "text-right",
516
- align === "center" && "text-center",
517
- componentPaddingXUsingComponentGap,
518
- typography.paragraph,
519
- className,
520
- props.readOnly && !props.disabled && "!px-0"
521
- )
522
- })
523
- ),
524
- after
525
- ]
526
- }
527
- ),
528
- caption && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { id: id ? `${id}-caption` : void 0, "data-testid": testid ? `${testid}-caption` : void 0, children: caption })
529
- ]
530
- }
531
- );
532
- };
533
- var Input = (_a) => {
534
- var _b = _a, {
535
- variant = "default",
536
- decimals,
537
- uom,
538
- removeSearchIcon,
539
- value: propValue,
540
- onChange,
541
- onBlur,
542
- onClear,
543
- id,
544
- testid
545
- } = _b, props = __objRest(_b, [
546
- "variant",
547
- "decimals",
548
- "uom",
549
- "removeSearchIcon",
550
- "value",
551
- "onChange",
552
- "onBlur",
553
- "onClear",
554
- "id",
555
- "testid"
556
- ]);
557
- const [internalValue, setInternalValue] = (0, import_react2.useState)("");
558
- const [displayValue, setDisplayValue] = (0, import_react2.useState)("");
559
- (0, import_react2.useEffect)(() => {
560
- var _a2;
561
- const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
562
- setInternalValue(stringValue);
563
- setDisplayValue(stringValue);
564
- }, [propValue]);
565
- (0, import_react2.useEffect)(() => {
566
- var _a2;
567
- if (variant !== "currency") {
568
- return;
569
- }
570
- const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
571
- if (!stringValue) {
572
- return;
573
- }
574
- const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
575
- setInternalValue(formatted);
576
- setDisplayValue(formatCurrencyDisplay(formatted));
577
- }, []);
578
- const getInputProps = () => {
579
- var _a2;
580
- const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
581
- id
582
- }), getDecimalPlaceholder(decimals)), {
583
- value: propValue
584
- });
585
- switch (variant) {
586
- case "search":
587
- return __spreadProps(__spreadValues({}, baseProps), {
588
- placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
589
- className: "!mr-6",
590
- value: displayValue
591
- });
592
- case "finder":
593
- return baseProps;
594
- case "currency":
595
- return __spreadProps(__spreadValues({}, baseProps), {
596
- align: "right",
597
- type: "text",
598
- value: displayValue
599
- });
600
- case "percentage":
601
- case "uom":
602
- return __spreadProps(__spreadValues({}, baseProps), {
603
- type: "number",
604
- align: "right"
605
- });
606
- default:
607
- return baseProps;
608
- }
609
- };
610
- const getBeforeElement = () => {
611
- if (props.before) return props.before;
612
- switch (variant) {
613
- case "search":
614
- return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "search" }) }) : null;
615
- case "currency":
616
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "attach_money" }) });
617
- default:
618
- return null;
458
+ }
459
+ return window.document.body;
460
+ }
461
+
462
+ // src/hooks/useTableLayout.ts
463
+ var import_react5 = require("react");
464
+
465
+ // src/components/MenuOption.tsx
466
+ var import_jsx_runtime4 = require("react/jsx-runtime");
467
+ var MenuOption = ({
468
+ id,
469
+ testid,
470
+ children,
471
+ disabled = false,
472
+ variant = "normal",
473
+ value,
474
+ before,
475
+ after,
476
+ subMenu,
477
+ onClick,
478
+ selected,
479
+ ref,
480
+ onSubMenuHover,
481
+ onSubMenuLeave,
482
+ onSubMenuEnter,
483
+ toggleMenu,
484
+ subMenuLevel = 1,
485
+ currentSubMenuLevel,
486
+ closeSubMenuLevel,
487
+ activeMenu,
488
+ mobilePositionTo,
489
+ highlightMatchingText = false,
490
+ menuValue,
491
+ onMouseMove
492
+ }) => {
493
+ const uniqueId = (0, import_react6.useId)();
494
+ const internalRef = (0, import_react6.useRef)(null);
495
+ const actualRef = ref || internalRef;
496
+ const menuId = (0, import_react6.useRef)(`menu-${uniqueId}`);
497
+ const isMobile = useMatchesMobile();
498
+ const handleMouseEnter = () => {
499
+ if (subMenu && onSubMenuHover && !disabled) {
500
+ onSubMenuHover(menuId.current, subMenuLevel);
619
501
  }
620
502
  };
621
- const getAfterElement = () => {
622
- if (props.after) return props.after;
623
- switch (variant) {
624
- case "search": {
625
- const hasValue = displayValue.length > 0;
626
- return hasValue && !props.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
627
- Icon,
628
- {
629
- id: id ? `${id}-clear-button` : void 0,
630
- testid: testid ? `${testid}-clear-button` : void 0,
631
- name: "close",
632
- onClick: handleSearchReset,
633
- className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
634
- }
635
- ) : null;
636
- }
637
- case "finder":
638
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "search" });
639
- case "uom":
640
- return uom ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
641
- case "percentage":
642
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "percent" }) });
643
- default:
644
- return null;
503
+ const handleMouseLeave = () => {
504
+ if (subMenu && onSubMenuLeave && !disabled) {
505
+ onSubMenuLeave(subMenuLevel);
645
506
  }
646
507
  };
647
- const handleSearchReset = () => {
648
- setInternalValue("");
649
- setDisplayValue("");
650
- if (onChange) {
651
- const syntheticEvent = {
652
- target: { value: "" }
653
- };
654
- if (typeof onChange === "function") {
655
- onChange(syntheticEvent);
656
- }
508
+ const handleMouseMove = () => {
509
+ if (subMenu && onMouseMove && !disabled) {
510
+ onMouseMove();
657
511
  }
658
- onClear == null ? void 0 : onClear();
659
512
  };
660
- const handleChange = (e) => {
661
- const rawValue = e.target.value;
662
- if (variant === "currency") {
663
- const raw = rawValue.replace(/,/g, "");
664
- if (raw === "") {
665
- setInternalValue("");
666
- setDisplayValue("");
667
- if (onChange) {
668
- const syntheticEvent = __spreadProps(__spreadValues({}, e), {
669
- target: __spreadProps(__spreadValues({}, e.target), { value: "" })
670
- });
671
- onChange(syntheticEvent);
672
- }
673
- return;
674
- }
675
- const regex = /^\d*\.?\d*$/;
676
- if (!regex.test(raw)) return;
677
- const parts = raw.split(".");
678
- const currentDecimals = decimals != null ? decimals : 2;
679
- if (parts.length === 2 && parts[1].length > currentDecimals) return;
680
- setInternalValue(raw);
681
- setDisplayValue(formatCurrencyDisplay(raw));
682
- const asNumber = Number(raw);
683
- if (!isNaN(asNumber) && onChange) {
684
- const syntheticEvent = __spreadProps(__spreadValues({}, e), {
685
- target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
686
- });
687
- onChange(syntheticEvent);
688
- }
689
- return;
690
- }
691
- setInternalValue(rawValue);
692
- setDisplayValue(rawValue);
693
- if (typeof onChange === "function") {
694
- onChange(e);
513
+ const handleSubMenuEnter = () => {
514
+ if (onSubMenuEnter) {
515
+ onSubMenuEnter();
695
516
  }
696
517
  };
697
- const handleBlur = (e) => {
698
- if (!internalValue) {
699
- return;
700
- }
701
- if (variant === "currency") {
702
- const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
703
- setInternalValue(formatted);
704
- setDisplayValue(formatCurrencyDisplay(formatted));
705
- const asNumber = Number(formatted);
706
- if (!isNaN(asNumber) && onChange) {
707
- const syntheticEvent = __spreadProps(__spreadValues({}, e), {
708
- target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
709
- });
710
- onChange(syntheticEvent);
711
- }
712
- } else if (variant === "uom" || variant === "percentage") {
713
- const formattedValue = formatDecimalValue(e.target.value, decimals);
714
- e.target.value = formattedValue;
715
- }
716
- onBlur == null ? void 0 : onBlur(e);
518
+ const additionalAttributes = {
519
+ "data-selected": selected || null
717
520
  };
718
- const inputProps = getInputProps();
719
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
720
- InputBase,
721
- __spreadProps(__spreadValues({}, inputProps), {
722
- before: getBeforeElement(),
723
- after: getAfterElement(),
724
- onChange: handleChange,
725
- onBlur: handleBlur,
726
- testid
727
- })
521
+ const svgStyles = (0, import_clsx5.default)(
522
+ "[&>svg]:shrink-0 [&>svg]:fill-icon-action-primary-normal"
728
523
  );
729
- };
730
- Input.displayName = "Input";
731
- var Finder = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
732
- var UOM = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
733
- var Currency = (props) => {
734
- var _a;
735
- const handleCurrencyChange = (e) => {
736
- var _a2;
737
- (_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
738
- };
739
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
740
- Input,
741
- __spreadProps(__spreadValues({}, props), {
742
- variant: "currency",
743
- decimals: (_a = props.decimals) != null ? _a : 2,
744
- onChange: handleCurrencyChange
745
- })
524
+ const textLabelStyles = (0, import_clsx5.default)("w-full whitespace-nowrap !leading-6");
525
+ const normalStyles = variant === "normal" && !disabled && (0, import_clsx5.default)(
526
+ "bg-transparent text-text-primary-normal",
527
+ "hover:bg-background-action-secondary-hover",
528
+ "focus:bg-background-action-secondary-hover",
529
+ "data-selected:bg-background-action-secondary-hover",
530
+ "active:bg-background-action-secondary-active"
746
531
  );
747
- };
748
- var Percentage = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
749
- Finder.displayName = "Finder";
750
- UOM.displayName = "UOM";
751
- Currency.displayName = "Currency";
752
- Percentage.displayName = "Percentage";
753
-
754
- // src/components/Search.tsx
755
- var import_jsx_runtime4 = require("react/jsx-runtime");
756
- var Search = (_a) => {
757
- var _b = _a, {
758
- id,
759
- testid,
760
- label,
761
- error,
762
- children,
763
- readOnly,
764
- renderMenu,
765
- onClick,
766
- wrapperClassName,
767
- removeRoundness
768
- } = _b, props = __objRest(_b, [
769
- "id",
770
- "testid",
771
- "label",
772
- "error",
773
- "children",
774
- "readOnly",
775
- "renderMenu",
776
- "onClick",
777
- "wrapperClassName",
778
- "removeRoundness"
779
- ]);
780
- const inputRef = (0, import_react3.useRef)(null);
781
- const inputContainerRef = (0, import_react3.useRef)(null);
782
- const preventFocusOnInitialRender = (0, import_react3.useRef)(true);
783
- const [show, setShow] = (0, import_react3.useState)(false);
784
- const [clearing, setClearing] = (0, import_react3.useState)(false);
785
- const uniqueId = (0, import_react3.useId)();
786
- const searchMenuName = `search-menu-${uniqueId}`;
787
- (0, import_react3.useEffect)(() => {
788
- var _a2;
789
- if (preventFocusOnInitialRender.current) {
790
- preventFocusOnInitialRender.current = false;
791
- return;
792
- }
793
- (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
794
- }, [props.value]);
532
+ const normalDisabledStyles = variant === "normal" && disabled && (0, import_clsx5.default)("text-text-primary-disabled");
533
+ const actionStyles = variant === "action" && !disabled && (0, import_clsx5.default)(
534
+ "text-action-400 bg-transparent",
535
+ "hover:bg-background-action-secondary-hover hover:text-text-action-hover",
536
+ "focus:bg-background-action-secondary-hover focus:text-text-action-hover",
537
+ "data-selected:bg-background-action-secondary-active data-selected:text-text-action-active",
538
+ "active:bg-background-action-secondary-active active:text-text-action-active"
539
+ );
540
+ const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx5.default)("text-text-action-disabled");
541
+ const disabledStyles = disabled && (0, import_clsx5.default)("bg-transparent cursor-default pointer-events-none");
542
+ const processChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
543
+ const renderChildren = typeof children === "object" ? children : variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Label, { padded: true, className: textLabelStyles, children: processChildren }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: processChildren });
795
544
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
796
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
797
- Input,
798
- __spreadValues({
545
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
546
+ "div",
547
+ __spreadProps(__spreadValues({
799
548
  id,
800
- testid,
801
- variant: "search",
802
- inputContainerRef,
803
- ref: inputRef,
804
- label,
805
- wrapperClassName,
806
- onClick: (e) => {
807
- if (props.disabled || readOnly) {
808
- return;
809
- }
810
- if (clearing) {
811
- setClearing(false);
812
- return;
813
- }
814
- onClick == null ? void 0 : onClick(e);
815
- setShow(!show);
816
- },
817
- onClear: () => {
818
- setClearing(true);
819
- },
820
- onKeyDown: (e) => {
821
- setShow(true);
822
- if (["ArrowUp", "ArrowDown"].includes(e.key)) {
823
- e.preventDefault();
824
- const menu = document.querySelector(
825
- `[data-menu="${searchMenuName}"]`
826
- );
827
- const selectedMenuOption = menu == null ? void 0 : menu.querySelector("[data-selected]");
828
- if (selectedMenuOption) {
829
- const allMenuOptions = Array.from(
830
- (menu == null ? void 0 : menu.querySelectorAll('[role="menuitem"]')) || []
831
- );
832
- const currentIndex = allMenuOptions.indexOf(selectedMenuOption);
833
- let targetOption;
834
- if (e.key === "ArrowDown") {
835
- targetOption = allMenuOptions[currentIndex + 1] || allMenuOptions[0];
836
- } else {
837
- targetOption = allMenuOptions[currentIndex - 1] || allMenuOptions[allMenuOptions.length - 1];
838
- }
839
- targetOption == null ? void 0 : targetOption.focus();
840
- } else {
841
- const toFocusMenuOption = e.key === "ArrowDown" ? menu == null ? void 0 : menu.querySelector('[role="menuitem"]') : menu == null ? void 0 : menu.querySelector(
842
- '[role="menuitem"]:last-child'
843
- );
844
- toFocusMenuOption == null ? void 0 : toFocusMenuOption.focus();
845
- }
549
+ "data-testid": testid,
550
+ ref: actualRef,
551
+ className: (0, import_clsx5.default)(
552
+ "flex items-center cursor-pointer w-full text-left relative outline-none",
553
+ svgStyles,
554
+ componentGap,
555
+ componentPadding,
556
+ baseTransition,
557
+ normalStyles,
558
+ normalDisabledStyles,
559
+ actionStyles,
560
+ actionDisabledStyles,
561
+ disabledStyles
562
+ ),
563
+ "data-value": value || children,
564
+ onClick: () => {
565
+ onClick == null ? void 0 : onClick(menuId.current, value || children);
566
+ if (subMenu) {
567
+ toggleMenu(menuId.current, subMenuLevel);
846
568
  }
847
569
  },
848
- error,
849
- readOnly,
850
- removeRoundness,
851
- focus: renderMenu && show
852
- }, props)
570
+ onMouseEnter: handleMouseEnter,
571
+ onMouseLeave: handleMouseLeave,
572
+ onMouseMove: handleMouseMove
573
+ }, additionalAttributes), {
574
+ tabIndex: -1,
575
+ role: "menuitem",
576
+ "aria-haspopup": subMenu ? "menu" : void 0,
577
+ children: [
578
+ before && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
579
+ renderChildren,
580
+ renderAfterProp()
581
+ ]
582
+ })
853
583
  ),
854
- renderMenu ? renderMenu({
855
- id: id ? `${id}-menu` : void 0,
856
- testid: testid ? `${testid}-menu` : void 0,
857
- positionTo: inputContainerRef,
858
- show,
859
- setShow,
860
- topOffset: props.caption ? -16 : null,
861
- autoFocusOff: true,
862
- menuName: searchMenuName
863
- }) : children
584
+ subMenu && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
585
+ "div",
586
+ {
587
+ onMouseEnter: handleSubMenuEnter,
588
+ onMouseLeave: handleMouseLeave,
589
+ "data-submenu-parent": menuId.current,
590
+ "data-menu-level": subMenuLevel + 1,
591
+ children: subMenu({
592
+ menuId: menuId.current,
593
+ positionTo: actualRef,
594
+ mobilePositionTo,
595
+ position: "right",
596
+ subMenuLevel,
597
+ mobileBackMenuOption,
598
+ mobileHide: isMobile && activeMenu !== menuId.current
599
+ })
600
+ }
601
+ )
864
602
  ] });
865
- };
866
- Search.displayName = "Search";
867
-
868
- // src/components/Menu.tsx
869
- var import_clsx5 = __toESM(require("clsx"), 1);
870
- var import_react9 = require("react");
871
- var import_react_dom = require("react-dom");
872
-
873
- // src/components/useMenuSystem.tsx
874
- var import_react8 = require("react");
875
-
876
- // src/hooks/useKeydown.ts
877
- var import_react4 = require("react");
878
-
879
- // src/hooks/useInfiniteScroll.tsx
880
- var import_react5 = require("react");
881
-
882
- // src/hooks/useMatchesMedia.ts
883
- var import_react6 = require("react");
884
- var useMatchesMedia = (query) => {
885
- const [matches, setMatches] = (0, import_react6.useState)();
886
- (0, import_react6.useLayoutEffect)(() => {
887
- const mediaQueryList = window.matchMedia(query);
888
- const listener = () => setMatches(mediaQueryList.matches);
889
- listener();
890
- mediaQueryList.addEventListener("change", listener);
891
- return () => mediaQueryList.removeEventListener("change", listener);
892
- }, [query]);
893
- return matches;
894
- };
895
- var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
896
-
897
- // src/utils.ts
898
- function findDocumentRoot(element) {
899
- if (typeof window === "undefined" || typeof document === "undefined") {
900
- throw new Error(
901
- "findDocumentRoot can only be used in a browser environment."
902
- );
903
- }
904
- if (!element || !(element instanceof Node)) {
905
- return window.document.body;
603
+ function renderAfterProp() {
604
+ if (after) {
605
+ return after;
606
+ }
607
+ if (subMenu && after !== null) {
608
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "chevron_right" });
609
+ }
906
610
  }
907
- let currentElement = element;
908
- while (currentElement && currentElement.parentNode) {
909
- if (currentElement.parentNode === document) {
910
- return document.body;
911
- } else if (currentElement.parentNode instanceof DocumentFragment) {
912
- return currentElement.parentNode;
913
- } else {
914
- currentElement = currentElement.parentNode;
611
+ function mobileBackMenuOption() {
612
+ if (!isMobile) {
613
+ return;
915
614
  }
615
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
616
+ MenuOption,
617
+ {
618
+ id: id ? `${id}-back` : void 0,
619
+ testid: testid ? `${testid}-back` : void 0,
620
+ onClick: () => {
621
+ closeSubMenuLevel == null ? void 0 : closeSubMenuLevel(currentSubMenuLevel != null ? currentSubMenuLevel : 0);
622
+ },
623
+ variant: "action",
624
+ before: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "chevron_left" }),
625
+ children: "Back"
626
+ }
627
+ );
916
628
  }
917
- return window.document.body;
629
+ };
630
+ MenuOption.displayName = "MenuOption";
631
+ function highlightMatch(text, searchValue) {
632
+ if (!searchValue || !searchValue.trim()) {
633
+ return text;
634
+ }
635
+ const regex = new RegExp(
636
+ `(${searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
637
+ "gi"
638
+ );
639
+ const parts = text.split(regex);
640
+ return parts.map(
641
+ (part, index) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-bold", children: part }, index) : part
642
+ );
918
643
  }
919
644
 
920
- // src/hooks/useTableLayout.ts
921
- var import_react7 = require("react");
645
+ // src/components/Menu.tsx
646
+ var import_clsx6 = __toESM(require("clsx"), 1);
647
+ var import_react8 = require("react");
648
+ var import_react_dom = require("react-dom");
922
649
 
923
650
  // src/components/useMenuSystem.tsx
651
+ var import_react7 = require("react");
924
652
  function useSubMenuSystem(mobilePositionTo) {
925
- const [activeMenus, setActiveMenus] = (0, import_react8.useState)(
653
+ const [activeMenus, setActiveMenus] = (0, import_react7.useState)(
926
654
  {}
927
655
  );
928
- const [activeMenu, setActiveMenu] = (0, import_react8.useState)("");
929
- const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0, import_react8.useState)(
656
+ const [activeMenu, setActiveMenu] = (0, import_react7.useState)("");
657
+ const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0, import_react7.useState)(
930
658
  null
931
659
  );
932
- const menuRootRef = (0, import_react8.useRef)(null);
933
- const subMenuRefs = (0, import_react8.useRef)({});
934
- const hoverTimeoutRef = (0, import_react8.useRef)(null);
935
- const closeTimeoutRef = (0, import_react8.useRef)(null);
936
- const mouseStopTimeoutRef = (0, import_react8.useRef)(null);
937
- const isMouseMovingRef = (0, import_react8.useRef)(false);
938
- const pendingOpenActionRef = (0, import_react8.useRef)(null);
939
- const pendingCloseActionRef = (0, import_react8.useRef)(null);
660
+ const menuRootRef = (0, import_react7.useRef)(null);
661
+ const subMenuRefs = (0, import_react7.useRef)({});
662
+ const hoverTimeoutRef = (0, import_react7.useRef)(null);
663
+ const closeTimeoutRef = (0, import_react7.useRef)(null);
664
+ const mouseStopTimeoutRef = (0, import_react7.useRef)(null);
665
+ const isMouseMovingRef = (0, import_react7.useRef)(false);
666
+ const pendingOpenActionRef = (0, import_react7.useRef)(null);
667
+ const pendingCloseActionRef = (0, import_react7.useRef)(null);
940
668
  const isMobile = useMatchesMobile();
941
669
  const toggleMenu = (menuId, level) => {
942
670
  if (closeTimeoutRef.current) {
@@ -976,7 +704,7 @@ function useSubMenuSystem(mobilePositionTo) {
976
704
  return newActiveMenus;
977
705
  });
978
706
  };
979
- const executePendingActions = (0, import_react8.useCallback)(() => {
707
+ const executePendingActions = (0, import_react7.useCallback)(() => {
980
708
  if (pendingCloseActionRef.current) {
981
709
  pendingCloseActionRef.current();
982
710
  pendingCloseActionRef.current = null;
@@ -1065,7 +793,7 @@ function useSubMenuSystem(mobilePositionTo) {
1065
793
  const isMenuActive = (menuId, level) => {
1066
794
  return activeMenus[level] === menuId;
1067
795
  };
1068
- (0, import_react8.useEffect)(() => {
796
+ (0, import_react7.useEffect)(() => {
1069
797
  const handleClickOutside = (event) => {
1070
798
  var _a;
1071
799
  if (Object.keys(activeMenus).length === 0) return;
@@ -1084,7 +812,7 @@ function useSubMenuSystem(mobilePositionTo) {
1084
812
  document.removeEventListener("mousedown", handleClickOutside);
1085
813
  };
1086
814
  }, [activeMenus]);
1087
- (0, import_react8.useEffect)(() => {
815
+ (0, import_react7.useEffect)(() => {
1088
816
  return () => {
1089
817
  if (hoverTimeoutRef.current) {
1090
818
  clearTimeout(hoverTimeoutRef.current);
@@ -1162,13 +890,13 @@ function useSubMenuSystem(mobilePositionTo) {
1162
890
  };
1163
891
  }
1164
892
  function useMenuPosition(elementRef, position = "bottom", options) {
1165
- const [menuPosition, setMenuPosition] = (0, import_react8.useState)({
893
+ const [menuPosition, setMenuPosition] = (0, import_react7.useState)({
1166
894
  top: 0,
1167
895
  left: 0,
1168
896
  minWidth: 0
1169
897
  });
1170
898
  const isMobile = options == null ? void 0 : options.isMobile;
1171
- const updatePosition = (0, import_react8.useCallback)(() => {
899
+ const updatePosition = (0, import_react7.useCallback)(() => {
1172
900
  var _a, _b, _c;
1173
901
  if (!(elementRef == null ? void 0 : elementRef.current)) return;
1174
902
  const triggerRect = elementRef.current.getBoundingClientRect();
@@ -1216,7 +944,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
1216
944
  minWidth: triggerRect.width
1217
945
  });
1218
946
  }, [elementRef, position, options == null ? void 0 : options.menuRef, options == null ? void 0 : options.topOffset, isMobile]);
1219
- (0, import_react8.useEffect)(() => {
947
+ (0, import_react7.useEffect)(() => {
1220
948
  if (!(options == null ? void 0 : options.isOpen) || !(options == null ? void 0 : options.setIsOpen)) return;
1221
949
  const handleClickOutside = (event) => {
1222
950
  var _a, _b, _c, _d, _e;
@@ -1242,7 +970,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
1242
970
  options == null ? void 0 : options.menuRef,
1243
971
  options == null ? void 0 : options.additionalRefs
1244
972
  ]);
1245
- (0, import_react8.useEffect)(() => {
973
+ (0, import_react7.useEffect)(() => {
1246
974
  updatePosition();
1247
975
  const resizeObserver = new ResizeObserver(updatePosition);
1248
976
  if (elementRef == null ? void 0 : elementRef.current) {
@@ -1301,9 +1029,9 @@ var Menu = (_a) => {
1301
1029
  "menuName",
1302
1030
  "calculateMinMaxHeight"
1303
1031
  ]);
1304
- const internalRef = (0, import_react9.useRef)(null);
1032
+ const internalRef = (0, import_react8.useRef)(null);
1305
1033
  const actualRef = ref || internalRef;
1306
- const [maxHeight, setMaxHeight] = (0, import_react9.useState)("180px");
1034
+ const [maxHeight, setMaxHeight] = (0, import_react8.useState)("180px");
1307
1035
  const isMobile = useMatchesMobile();
1308
1036
  const { menuPosition, updatePosition } = useMenuPosition(
1309
1037
  isMobile && mobilePositionTo ? mobilePositionTo : positionTo,
@@ -1316,7 +1044,7 @@ var Menu = (_a) => {
1316
1044
  isMobile: !!(isMobile && mobilePositionTo)
1317
1045
  }
1318
1046
  );
1319
- (0, import_react9.useEffect)(() => {
1047
+ (0, import_react8.useEffect)(() => {
1320
1048
  if (calculateMinMaxHeight) {
1321
1049
  return;
1322
1050
  }
@@ -1340,7 +1068,7 @@ var Menu = (_a) => {
1340
1068
  cancelAnimationFrame(raf);
1341
1069
  };
1342
1070
  }, [actualRef.current, customMaxHeight, calculateMinMaxHeight]);
1343
- (0, import_react9.useEffect)(() => {
1071
+ (0, import_react8.useEffect)(() => {
1344
1072
  if (!calculateMinMaxHeight) {
1345
1073
  return;
1346
1074
  }
@@ -1351,14 +1079,14 @@ var Menu = (_a) => {
1351
1079
  setMaxHeight(`${calculatedMaxHeight}px`);
1352
1080
  }
1353
1081
  }, [actualRef.current, positionTo == null ? void 0 : positionTo.current, calculateMinMaxHeight]);
1354
- (0, import_react9.useEffect)(() => {
1082
+ (0, import_react8.useEffect)(() => {
1355
1083
  if (!show) {
1356
1084
  return;
1357
1085
  }
1358
1086
  initializeMenuFocus();
1359
1087
  updatePosition();
1360
1088
  }, [show, updatePosition]);
1361
- (0, import_react9.useEffect)(() => {
1089
+ (0, import_react8.useEffect)(() => {
1362
1090
  if (!show || !setShow) {
1363
1091
  return;
1364
1092
  }
@@ -1382,7 +1110,7 @@ var Menu = (_a) => {
1382
1110
  id,
1383
1111
  "data-testid": testid,
1384
1112
  ref: setRefs,
1385
- className: (0, import_clsx5.default)(
1113
+ className: (0, import_clsx6.default)(
1386
1114
  "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
1387
1115
  "fixed",
1388
1116
  "z-50",
@@ -1504,249 +1232,517 @@ var Menu = (_a) => {
1504
1232
  ref.current = node;
1505
1233
  }
1506
1234
  }
1507
- }
1508
- function stopPropagation(e) {
1509
- e.stopPropagation();
1510
- }
1235
+ }
1236
+ function stopPropagation(e) {
1237
+ e.stopPropagation();
1238
+ }
1239
+ };
1240
+ Menu.displayName = "Menu";
1241
+
1242
+ // src/components/Search.tsx
1243
+ var import_react10 = require("react");
1244
+
1245
+ // src/components/Input.tsx
1246
+ var import_react9 = require("react");
1247
+ var import_clsx7 = __toESM(require("clsx"), 1);
1248
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1249
+ var InputBase = (_a) => {
1250
+ var _b = _a, {
1251
+ id,
1252
+ testid,
1253
+ before,
1254
+ after,
1255
+ type,
1256
+ label,
1257
+ error,
1258
+ className,
1259
+ align = "left",
1260
+ caption,
1261
+ required,
1262
+ selectOnFocus,
1263
+ removeRoundness,
1264
+ inputContainerRef,
1265
+ removeBorder,
1266
+ wrapperClassName,
1267
+ focus,
1268
+ fullWidth = true
1269
+ } = _b, props = __objRest(_b, [
1270
+ "id",
1271
+ "testid",
1272
+ "before",
1273
+ "after",
1274
+ "type",
1275
+ "label",
1276
+ "error",
1277
+ "className",
1278
+ "align",
1279
+ "caption",
1280
+ "required",
1281
+ "selectOnFocus",
1282
+ "removeRoundness",
1283
+ "inputContainerRef",
1284
+ "removeBorder",
1285
+ "wrapperClassName",
1286
+ "focus",
1287
+ "fullWidth"
1288
+ ]);
1289
+ const attributes = {
1290
+ "data-error": error && !focus || null,
1291
+ "data-focus": focus || null
1292
+ };
1293
+ const inputRef = (0, import_react9.useRef)(null);
1294
+ const inputId = id ? `${id}-input` : void 0;
1295
+ (0, import_react9.useEffect)(() => {
1296
+ var _a2;
1297
+ const input = inputRef.current;
1298
+ const focusHandler = () => {
1299
+ input == null ? void 0 : input.select();
1300
+ };
1301
+ if (selectOnFocus) {
1302
+ (_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
1303
+ return () => {
1304
+ input == null ? void 0 : input.removeEventListener("focus", focusHandler);
1305
+ };
1306
+ }
1307
+ }, [selectOnFocus]);
1308
+ const inputBaseClass = (0, import_clsx7.default)(
1309
+ fullWidth ? "w-full" : "w-fit",
1310
+ "flex flex-row items-center",
1311
+ "bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
1312
+ componentGap,
1313
+ baseTransition,
1314
+ "outline-transparent outline-2 -outline-offset-2",
1315
+ componentPaddingMinusBorder,
1316
+ !removeRoundness && "rounded-base",
1317
+ !removeBorder && "border border-border-primary-normal",
1318
+ "relative"
1319
+ );
1320
+ const inputFocusClass = (0, import_clsx7.default)(
1321
+ "has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
1322
+ );
1323
+ const inputDisabledClass = (0, import_clsx7.default)(
1324
+ "has-disabled:bg-background-action-secondary-disabled"
1325
+ );
1326
+ const inputReadOnlyClass = (0, import_clsx7.default)(
1327
+ "has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
1328
+ );
1329
+ const inputInvalidClass = (0, import_clsx7.default)(
1330
+ "has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
1331
+ );
1332
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1333
+ "label",
1334
+ {
1335
+ id,
1336
+ "data-testid": testid,
1337
+ htmlFor: inputId,
1338
+ ref: inputContainerRef,
1339
+ className: (0, import_clsx7.default)(
1340
+ "w-full flex flex-col",
1341
+ "block",
1342
+ "text-text-primary-normal has-disabled:text-text-primary-disabled",
1343
+ componentGap
1344
+ ),
1345
+ style: __spreadValues({}, props.style),
1346
+ children: [
1347
+ label && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_clsx7.default)("flex items-center", componentGap), children: [
1348
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1349
+ Label,
1350
+ {
1351
+ id: id ? `${id}-label` : void 0,
1352
+ className: (0, import_clsx7.default)(
1353
+ props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
1354
+ ),
1355
+ children: label
1356
+ }
1357
+ ),
1358
+ required && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1359
+ "span",
1360
+ {
1361
+ className: (0, import_clsx7.default)(typography.label, "text-text-critical-normal"),
1362
+ children: "*"
1363
+ }
1364
+ )
1365
+ ] }),
1366
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1367
+ "div",
1368
+ {
1369
+ className: (0, import_clsx7.default)(
1370
+ inputBaseClass,
1371
+ !props.disabled && inputInvalidClass,
1372
+ inputFocusClass,
1373
+ inputDisabledClass,
1374
+ inputReadOnlyClass,
1375
+ wrapperClassName
1376
+ ),
1377
+ children: [
1378
+ before,
1379
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1380
+ "input",
1381
+ __spreadProps(__spreadValues(__spreadValues({
1382
+ ref: (el) => {
1383
+ inputRef.current = el;
1384
+ },
1385
+ type,
1386
+ required
1387
+ }, props), attributes), {
1388
+ id: inputId,
1389
+ "data-testid": testid ? `${testid}-input` : void 0,
1390
+ className: (0, import_clsx7.default)(
1391
+ "flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
1392
+ "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
1393
+ "placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
1394
+ align === "right" && "text-right",
1395
+ align === "center" && "text-center",
1396
+ componentPaddingXUsingComponentGap,
1397
+ typography.paragraph,
1398
+ className,
1399
+ props.readOnly && !props.disabled && "!px-0"
1400
+ )
1401
+ })
1402
+ ),
1403
+ after
1404
+ ]
1405
+ }
1406
+ ),
1407
+ caption && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: id ? `${id}-caption` : void 0, "data-testid": testid ? `${testid}-caption` : void 0, children: caption })
1408
+ ]
1409
+ }
1410
+ );
1511
1411
  };
1512
- Menu.displayName = "Menu";
1513
-
1514
- // src/components/MenuOption.tsx
1515
- var import_clsx7 = __toESM(require("clsx"), 1);
1516
- var import_react10 = require("react");
1517
-
1518
- // src/components/Paragraph.tsx
1519
- var import_clsx6 = __toESM(require("clsx"), 1);
1520
- var import_jsx_runtime6 = require("react/jsx-runtime");
1521
- var Paragraph = (_a) => {
1412
+ var Input = (_a) => {
1522
1413
  var _b = _a, {
1523
- className,
1524
- color,
1525
- padded,
1526
- align = "left",
1527
- tall,
1528
- addOverflow,
1529
- children,
1530
- as = "p",
1414
+ variant = "default",
1415
+ decimals,
1416
+ uom,
1417
+ removeSearchIcon,
1418
+ value: propValue,
1419
+ onChange,
1420
+ onBlur,
1421
+ onClear,
1531
1422
  id,
1532
1423
  testid
1533
1424
  } = _b, props = __objRest(_b, [
1534
- "className",
1535
- "color",
1536
- "padded",
1537
- "align",
1538
- "tall",
1539
- "addOverflow",
1540
- "children",
1541
- "as",
1425
+ "variant",
1426
+ "decimals",
1427
+ "uom",
1428
+ "removeSearchIcon",
1429
+ "value",
1430
+ "onChange",
1431
+ "onBlur",
1432
+ "onClear",
1542
1433
  "id",
1543
1434
  "testid"
1544
1435
  ]);
1545
- const Element = as;
1546
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1547
- Element,
1548
- __spreadProps(__spreadValues({
1549
- id,
1550
- "data-testid": testid
1551
- }, props), {
1552
- className: (0, import_clsx6.default)(
1553
- typography.paragraph,
1554
- className,
1555
- padded && componentPaddingXUsingComponentGap,
1556
- align === "left" && "text-left",
1557
- align === "center" && "text-center",
1558
- align === "right" && "text-right",
1559
- tall && "!leading-6",
1560
- addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
1561
- ),
1562
- style: __spreadProps(__spreadValues({}, props.style), {
1563
- color: color ? `var(--color-${color})` : void 0
1564
- }),
1565
- children
1566
- })
1567
- );
1568
- };
1569
- Paragraph.displayName = "Paragraph";
1570
-
1571
- // src/components/MenuOption.tsx
1572
- var import_jsx_runtime7 = require("react/jsx-runtime");
1573
- var MenuOption = ({
1574
- id,
1575
- testid,
1576
- children,
1577
- disabled = false,
1578
- variant = "normal",
1579
- value,
1580
- before,
1581
- after,
1582
- subMenu,
1583
- onClick,
1584
- selected,
1585
- ref,
1586
- onSubMenuHover,
1587
- onSubMenuLeave,
1588
- onSubMenuEnter,
1589
- toggleMenu,
1590
- subMenuLevel = 1,
1591
- currentSubMenuLevel,
1592
- closeSubMenuLevel,
1593
- activeMenu,
1594
- mobilePositionTo,
1595
- highlightMatchingText = false,
1596
- menuValue,
1597
- onMouseMove
1598
- }) => {
1599
- const uniqueId = (0, import_react10.useId)();
1600
- const internalRef = (0, import_react10.useRef)(null);
1601
- const actualRef = ref || internalRef;
1602
- const menuId = (0, import_react10.useRef)(`menu-${uniqueId}`);
1603
- const isMobile = useMatchesMobile();
1604
- const handleMouseEnter = () => {
1605
- if (subMenu && onSubMenuHover && !disabled) {
1606
- onSubMenuHover(menuId.current, subMenuLevel);
1436
+ const [internalValue, setInternalValue] = (0, import_react9.useState)("");
1437
+ const [displayValue, setDisplayValue] = (0, import_react9.useState)("");
1438
+ (0, import_react9.useEffect)(() => {
1439
+ var _a2;
1440
+ const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
1441
+ setInternalValue(stringValue);
1442
+ setDisplayValue(stringValue);
1443
+ }, [propValue]);
1444
+ (0, import_react9.useEffect)(() => {
1445
+ var _a2;
1446
+ if (variant !== "currency") {
1447
+ return;
1448
+ }
1449
+ const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
1450
+ if (!stringValue) {
1451
+ return;
1452
+ }
1453
+ const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
1454
+ setInternalValue(formatted);
1455
+ setDisplayValue(formatCurrencyDisplay(formatted));
1456
+ }, []);
1457
+ const getInputProps = () => {
1458
+ var _a2;
1459
+ const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
1460
+ id
1461
+ }), getDecimalPlaceholder(decimals)), {
1462
+ value: propValue
1463
+ });
1464
+ switch (variant) {
1465
+ case "search":
1466
+ return __spreadProps(__spreadValues({}, baseProps), {
1467
+ placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
1468
+ className: "!mr-6",
1469
+ value: displayValue
1470
+ });
1471
+ case "finder":
1472
+ return baseProps;
1473
+ case "currency":
1474
+ return __spreadProps(__spreadValues({}, baseProps), {
1475
+ align: "right",
1476
+ type: "text",
1477
+ value: displayValue
1478
+ });
1479
+ case "percentage":
1480
+ case "uom":
1481
+ return __spreadProps(__spreadValues({}, baseProps), {
1482
+ type: "number",
1483
+ align: "right"
1484
+ });
1485
+ default:
1486
+ return baseProps;
1607
1487
  }
1608
1488
  };
1609
- const handleMouseLeave = () => {
1610
- if (subMenu && onSubMenuLeave && !disabled) {
1611
- onSubMenuLeave(subMenuLevel);
1489
+ const getBeforeElement = () => {
1490
+ if (props.before) return props.before;
1491
+ switch (variant) {
1492
+ case "search":
1493
+ return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" }) }) : null;
1494
+ case "currency":
1495
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "attach_money" }) });
1496
+ default:
1497
+ return null;
1612
1498
  }
1613
1499
  };
1614
- const handleMouseMove = () => {
1615
- if (subMenu && onMouseMove && !disabled) {
1616
- onMouseMove();
1500
+ const getAfterElement = () => {
1501
+ if (props.after) return props.after;
1502
+ switch (variant) {
1503
+ case "search": {
1504
+ const hasValue = displayValue.length > 0;
1505
+ return hasValue && !props.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1506
+ Icon,
1507
+ {
1508
+ id: id ? `${id}-clear-button` : void 0,
1509
+ testid: testid ? `${testid}-clear-button` : void 0,
1510
+ name: "close",
1511
+ onClick: handleSearchReset,
1512
+ className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
1513
+ }
1514
+ ) : null;
1515
+ }
1516
+ case "finder":
1517
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" });
1518
+ case "uom":
1519
+ return uom ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
1520
+ case "percentage":
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "percent" }) });
1522
+ default:
1523
+ return null;
1617
1524
  }
1618
1525
  };
1619
- const handleSubMenuEnter = () => {
1620
- if (onSubMenuEnter) {
1621
- onSubMenuEnter();
1526
+ const handleSearchReset = () => {
1527
+ setInternalValue("");
1528
+ setDisplayValue("");
1529
+ if (onChange) {
1530
+ const syntheticEvent = {
1531
+ target: { value: "" }
1532
+ };
1533
+ if (typeof onChange === "function") {
1534
+ onChange(syntheticEvent);
1535
+ }
1536
+ }
1537
+ onClear == null ? void 0 : onClear();
1538
+ };
1539
+ const handleChange = (e) => {
1540
+ const rawValue = e.target.value;
1541
+ if (variant === "currency") {
1542
+ const raw = rawValue.replace(/,/g, "");
1543
+ if (raw === "") {
1544
+ setInternalValue("");
1545
+ setDisplayValue("");
1546
+ if (onChange) {
1547
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
1548
+ target: __spreadProps(__spreadValues({}, e.target), { value: "" })
1549
+ });
1550
+ onChange(syntheticEvent);
1551
+ }
1552
+ return;
1553
+ }
1554
+ const regex = /^\d*\.?\d*$/;
1555
+ if (!regex.test(raw)) return;
1556
+ const parts = raw.split(".");
1557
+ const currentDecimals = decimals != null ? decimals : 2;
1558
+ if (parts.length === 2 && parts[1].length > currentDecimals) return;
1559
+ setInternalValue(raw);
1560
+ setDisplayValue(formatCurrencyDisplay(raw));
1561
+ const asNumber = Number(raw);
1562
+ if (!isNaN(asNumber) && onChange) {
1563
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
1564
+ target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
1565
+ });
1566
+ onChange(syntheticEvent);
1567
+ }
1568
+ return;
1569
+ }
1570
+ setInternalValue(rawValue);
1571
+ setDisplayValue(rawValue);
1572
+ if (typeof onChange === "function") {
1573
+ onChange(e);
1574
+ }
1575
+ };
1576
+ const handleBlur = (e) => {
1577
+ if (!internalValue) {
1578
+ return;
1579
+ }
1580
+ if (variant === "currency") {
1581
+ const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
1582
+ setInternalValue(formatted);
1583
+ setDisplayValue(formatCurrencyDisplay(formatted));
1584
+ const asNumber = Number(formatted);
1585
+ if (!isNaN(asNumber) && onChange) {
1586
+ const syntheticEvent = __spreadProps(__spreadValues({}, e), {
1587
+ target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
1588
+ });
1589
+ onChange(syntheticEvent);
1590
+ }
1591
+ } else if (variant === "uom" || variant === "percentage") {
1592
+ const formattedValue = formatDecimalValue(e.target.value, decimals);
1593
+ e.target.value = formattedValue;
1622
1594
  }
1595
+ onBlur == null ? void 0 : onBlur(e);
1623
1596
  };
1624
- const additionalAttributes = {
1625
- "data-selected": selected || null
1626
- };
1627
- const svgStyles = (0, import_clsx7.default)(
1628
- "[&>svg]:shrink-0 [&>svg]:fill-icon-action-primary-normal"
1629
- );
1630
- const textLabelStyles = (0, import_clsx7.default)("w-full whitespace-nowrap !leading-6");
1631
- const normalStyles = variant === "normal" && !disabled && (0, import_clsx7.default)(
1632
- "bg-transparent text-text-primary-normal",
1633
- "hover:bg-background-action-secondary-hover",
1634
- "focus:bg-background-action-secondary-hover",
1635
- "data-selected:bg-background-action-secondary-hover",
1636
- "active:bg-background-action-secondary-active"
1597
+ const inputProps = getInputProps();
1598
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1599
+ InputBase,
1600
+ __spreadProps(__spreadValues({}, inputProps), {
1601
+ before: getBeforeElement(),
1602
+ after: getAfterElement(),
1603
+ onChange: handleChange,
1604
+ onBlur: handleBlur,
1605
+ testid
1606
+ })
1637
1607
  );
1638
- const normalDisabledStyles = variant === "normal" && disabled && (0, import_clsx7.default)("text-text-primary-disabled");
1639
- const actionStyles = variant === "action" && !disabled && (0, import_clsx7.default)(
1640
- "text-action-400 bg-transparent",
1641
- "hover:bg-background-action-secondary-hover hover:text-text-action-hover",
1642
- "focus:bg-background-action-secondary-hover focus:text-text-action-hover",
1643
- "data-selected:bg-background-action-secondary-active data-selected:text-text-action-active",
1644
- "active:bg-background-action-secondary-active active:text-text-action-active"
1608
+ };
1609
+ Input.displayName = "Input";
1610
+ var Finder = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
1611
+ var UOM = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
1612
+ var Currency = (props) => {
1613
+ var _a;
1614
+ const handleCurrencyChange = (e) => {
1615
+ var _a2;
1616
+ (_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
1617
+ };
1618
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1619
+ Input,
1620
+ __spreadProps(__spreadValues({}, props), {
1621
+ variant: "currency",
1622
+ decimals: (_a = props.decimals) != null ? _a : 2,
1623
+ onChange: handleCurrencyChange
1624
+ })
1645
1625
  );
1646
- const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx7.default)("text-text-action-disabled");
1647
- const disabledStyles = disabled && (0, import_clsx7.default)("bg-transparent cursor-default pointer-events-none");
1648
- const processChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
1649
- const renderChildren = typeof children === "object" ? children : variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { padded: true, className: textLabelStyles, children: processChildren }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: processChildren });
1626
+ };
1627
+ var Percentage = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
1628
+ Finder.displayName = "Finder";
1629
+ UOM.displayName = "UOM";
1630
+ Currency.displayName = "Currency";
1631
+ Percentage.displayName = "Percentage";
1632
+
1633
+ // src/components/Search.tsx
1634
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1635
+ var Search = (_a) => {
1636
+ var _b = _a, {
1637
+ id,
1638
+ testid,
1639
+ label,
1640
+ error,
1641
+ children,
1642
+ readOnly,
1643
+ renderMenu,
1644
+ onClick,
1645
+ wrapperClassName,
1646
+ removeRoundness
1647
+ } = _b, props = __objRest(_b, [
1648
+ "id",
1649
+ "testid",
1650
+ "label",
1651
+ "error",
1652
+ "children",
1653
+ "readOnly",
1654
+ "renderMenu",
1655
+ "onClick",
1656
+ "wrapperClassName",
1657
+ "removeRoundness"
1658
+ ]);
1659
+ const inputRef = (0, import_react10.useRef)(null);
1660
+ const inputContainerRef = (0, import_react10.useRef)(null);
1661
+ const preventFocusOnInitialRender = (0, import_react10.useRef)(true);
1662
+ const [show, setShow] = (0, import_react10.useState)(false);
1663
+ const [clearing, setClearing] = (0, import_react10.useState)(false);
1664
+ const uniqueId = (0, import_react10.useId)();
1665
+ const searchMenuName = `search-menu-${uniqueId}`;
1666
+ (0, import_react10.useEffect)(() => {
1667
+ var _a2;
1668
+ if (preventFocusOnInitialRender.current) {
1669
+ preventFocusOnInitialRender.current = false;
1670
+ return;
1671
+ }
1672
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
1673
+ }, [props.value]);
1650
1674
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1651
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1652
- "div",
1653
- __spreadProps(__spreadValues({
1675
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1676
+ Input,
1677
+ __spreadValues({
1654
1678
  id,
1655
- "data-testid": testid,
1656
- ref: actualRef,
1657
- className: (0, import_clsx7.default)(
1658
- "flex items-center cursor-pointer w-full text-left relative outline-none",
1659
- svgStyles,
1660
- componentGap,
1661
- componentPadding,
1662
- baseTransition,
1663
- normalStyles,
1664
- normalDisabledStyles,
1665
- actionStyles,
1666
- actionDisabledStyles,
1667
- disabledStyles
1668
- ),
1669
- "data-value": value || children,
1670
- onClick: () => {
1671
- onClick == null ? void 0 : onClick(menuId.current, value || children);
1672
- if (subMenu) {
1673
- toggleMenu(menuId.current, subMenuLevel);
1679
+ testid,
1680
+ variant: "search",
1681
+ inputContainerRef,
1682
+ ref: inputRef,
1683
+ label,
1684
+ wrapperClassName,
1685
+ onClick: (e) => {
1686
+ if (props.disabled || readOnly) {
1687
+ return;
1688
+ }
1689
+ if (clearing) {
1690
+ setClearing(false);
1691
+ return;
1674
1692
  }
1693
+ onClick == null ? void 0 : onClick(e);
1694
+ setShow(!show);
1675
1695
  },
1676
- onMouseEnter: handleMouseEnter,
1677
- onMouseLeave: handleMouseLeave,
1678
- onMouseMove: handleMouseMove
1679
- }, additionalAttributes), {
1680
- tabIndex: -1,
1681
- role: "menuitem",
1682
- "aria-haspopup": subMenu ? "menu" : void 0,
1683
- children: [
1684
- before && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
1685
- renderChildren,
1686
- renderAfterProp()
1687
- ]
1688
- })
1696
+ onClear: () => {
1697
+ setClearing(true);
1698
+ },
1699
+ onKeyDown: (e) => {
1700
+ setShow(true);
1701
+ if (["ArrowUp", "ArrowDown"].includes(e.key)) {
1702
+ e.preventDefault();
1703
+ const menu = document.querySelector(
1704
+ `[data-menu="${searchMenuName}"]`
1705
+ );
1706
+ const selectedMenuOption = menu == null ? void 0 : menu.querySelector("[data-selected]");
1707
+ if (selectedMenuOption) {
1708
+ const allMenuOptions = Array.from(
1709
+ (menu == null ? void 0 : menu.querySelectorAll('[role="menuitem"]')) || []
1710
+ );
1711
+ const currentIndex = allMenuOptions.indexOf(selectedMenuOption);
1712
+ let targetOption;
1713
+ if (e.key === "ArrowDown") {
1714
+ targetOption = allMenuOptions[currentIndex + 1] || allMenuOptions[0];
1715
+ } else {
1716
+ targetOption = allMenuOptions[currentIndex - 1] || allMenuOptions[allMenuOptions.length - 1];
1717
+ }
1718
+ targetOption == null ? void 0 : targetOption.focus();
1719
+ } else {
1720
+ const toFocusMenuOption = e.key === "ArrowDown" ? menu == null ? void 0 : menu.querySelector('[role="menuitem"]') : menu == null ? void 0 : menu.querySelector(
1721
+ '[role="menuitem"]:last-child'
1722
+ );
1723
+ toFocusMenuOption == null ? void 0 : toFocusMenuOption.focus();
1724
+ }
1725
+ }
1726
+ },
1727
+ error,
1728
+ readOnly,
1729
+ removeRoundness,
1730
+ focus: renderMenu && show
1731
+ }, props)
1689
1732
  ),
1690
- subMenu && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1691
- "div",
1692
- {
1693
- onMouseEnter: handleSubMenuEnter,
1694
- onMouseLeave: handleMouseLeave,
1695
- "data-submenu-parent": menuId.current,
1696
- "data-menu-level": subMenuLevel + 1,
1697
- children: subMenu({
1698
- menuId: menuId.current,
1699
- positionTo: actualRef,
1700
- mobilePositionTo,
1701
- position: "right",
1702
- subMenuLevel,
1703
- mobileBackMenuOption,
1704
- mobileHide: isMobile && activeMenu !== menuId.current
1705
- })
1706
- }
1707
- )
1733
+ renderMenu ? renderMenu({
1734
+ id: id ? `${id}-menu` : void 0,
1735
+ testid: testid ? `${testid}-menu` : void 0,
1736
+ positionTo: inputContainerRef,
1737
+ show,
1738
+ setShow,
1739
+ topOffset: props.caption ? -16 : null,
1740
+ autoFocusOff: true,
1741
+ menuName: searchMenuName
1742
+ }) : children
1708
1743
  ] });
1709
- function renderAfterProp() {
1710
- if (after) {
1711
- return after;
1712
- }
1713
- if (subMenu && after !== null) {
1714
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron_right" });
1715
- }
1716
- }
1717
- function mobileBackMenuOption() {
1718
- if (!isMobile) {
1719
- return;
1720
- }
1721
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1722
- MenuOption,
1723
- {
1724
- id: id ? `${id}-back` : void 0,
1725
- testid: testid ? `${testid}-back` : void 0,
1726
- onClick: () => {
1727
- closeSubMenuLevel == null ? void 0 : closeSubMenuLevel(currentSubMenuLevel != null ? currentSubMenuLevel : 0);
1728
- },
1729
- variant: "action",
1730
- before: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron_left" }),
1731
- children: "Back"
1732
- }
1733
- );
1734
- }
1735
1744
  };
1736
- MenuOption.displayName = "MenuOption";
1737
- function highlightMatch(text, searchValue) {
1738
- if (!searchValue || !searchValue.trim()) {
1739
- return text;
1740
- }
1741
- const regex = new RegExp(
1742
- `(${searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
1743
- "gi"
1744
- );
1745
- const parts = text.split(regex);
1746
- return parts.map(
1747
- (part, index) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-bold", children: part }, index) : part
1748
- );
1749
- }
1745
+ Search.displayName = "Search";
1750
1746
 
1751
1747
  // src/components/DataGridCell.tsx
1752
1748
  var import_jsx_runtime8 = require("react/jsx-runtime");
@@ -1768,6 +1764,7 @@ var DataGridCell = (0, import_react11.memo)(
1768
1764
  warning,
1769
1765
  center,
1770
1766
  width,
1767
+ minWidth,
1771
1768
  testid
1772
1769
  } = _b, props = __objRest(_b, [
1773
1770
  "id",
@@ -1785,6 +1782,7 @@ var DataGridCell = (0, import_react11.memo)(
1785
1782
  "warning",
1786
1783
  "center",
1787
1784
  "width",
1785
+ "minWidth",
1788
1786
  "testid"
1789
1787
  ]);
1790
1788
  const Element = type === "header" ? "th" : "td";
@@ -1858,7 +1856,7 @@ var DataGridCell = (0, import_react11.memo)(
1858
1856
  id,
1859
1857
  "data-testid": testid,
1860
1858
  className: (0, import_clsx8.default)("flex h-10", !width && "flex-1"),
1861
- style: { width }
1859
+ style: { width, minWidth }
1862
1860
  }, props), {
1863
1861
  "data-theme": type === "header" && !locked ? "brand" : void 0,
1864
1862
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1899,7 +1897,7 @@ function DataCellHeader(_a) {
1899
1897
  "testid",
1900
1898
  "useMenuDefaultMinWidth"
1901
1899
  ]);
1902
- var _a2, _b2, _c;
1900
+ var _a2;
1903
1901
  const [showMenu, setShowMenu] = (0, import_react11.useState)(false);
1904
1902
  const [filter, setFilter] = (0, import_react11.useState)(
1905
1903
  (_a2 = header.column.getFilterValue()) != null ? _a2 : ""
@@ -1933,7 +1931,7 @@ function DataCellHeader(_a) {
1933
1931
  const style = __spreadValues({
1934
1932
  position: "relative",
1935
1933
  whiteSpace: "nowrap",
1936
- width: (_c = (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.headerWidth) != null ? _c : header.column.getSize(),
1934
+ minWidth: header.column.getSize(),
1937
1935
  "--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
1938
1936
  "--color-icon-on-action-primary-normal": "var(--color-text-brand-primary-normal)",
1939
1937
  "--background-action-secondary-normal": "var(--color-text-brand-primary-normal)"
@@ -1947,6 +1945,7 @@ function DataCellHeader(_a) {
1947
1945
  type: "header",
1948
1946
  component: "header",
1949
1947
  style,
1948
+ minWidth: `${header.column.getSize()}px`,
1950
1949
  onClick: header.column.getToggleSortingHandler(),
1951
1950
  onRightClick: () => setShowMenu(!showMenu)
1952
1951
  }, props), {
@@ -1970,8 +1969,8 @@ function DataCellHeader(_a) {
1970
1969
  id: id ? `${id}-filter-option` : void 0,
1971
1970
  testid: testid ? `${testid}-filter-option` : void 0
1972
1971
  }, subMenuListeners), {
1973
- subMenu: (_d) => {
1974
- var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
1972
+ subMenu: (_b2) => {
1973
+ var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
1975
1974
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1976
1975
  Menu,
1977
1976
  __spreadProps(__spreadValues({
@@ -2044,8 +2043,8 @@ function DataCellHeader(_a) {
2044
2043
  setShowMenu(!showMenu);
2045
2044
  }
2046
2045
  }, subMenuListeners), {
2047
- subMenu: (_f) => {
2048
- var _g = _f, { menuId, subMenuLevel } = _g, props2 = __objRest(_g, ["menuId", "subMenuLevel"]);
2046
+ subMenu: (_d) => {
2047
+ var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
2049
2048
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2050
2049
  Menu,
2051
2050
  __spreadProps(__spreadValues({}, props2), {
@@ -2133,7 +2132,6 @@ function DraggableCellHeader(_a) {
2133
2132
  "header",
2134
2133
  "children"
2135
2134
  ]);
2136
- var _a2, _b2;
2137
2135
  const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
2138
2136
  id: header.column.id
2139
2137
  });
@@ -2144,7 +2142,6 @@ function DraggableCellHeader(_a) {
2144
2142
  transition: "width transform 0.2s ease-in-out",
2145
2143
  whiteSpace: "nowrap",
2146
2144
  zIndex: isDragging ? 1 : 0,
2147
- width: (_b2 = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : header.column.getSize(),
2148
2145
  "--color-text-primary-normal": "var(--color-action-000)",
2149
2146
  "--color-icon-on-action-primary-normal": "var(--color-action-000)",
2150
2147
  userSelect: "none"
@@ -2170,7 +2167,6 @@ function DragAlongCell(_a) {
2170
2167
  "cell",
2171
2168
  "children"
2172
2169
  ]);
2173
- var _a2, _b2, _c, _d;
2174
2170
  const { isDragging, setNodeRef, transform } = (0, import_sortable.useSortable)({
2175
2171
  id: cell.column.id
2176
2172
  });
@@ -2179,19 +2175,10 @@ function DragAlongCell(_a) {
2179
2175
  position: "relative",
2180
2176
  transform: CSS.Translate.toString(transform),
2181
2177
  transition: "width transform 0.2s ease-in-out",
2182
- width: (_b2 = (_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : cell.column.getSize(),
2178
+ minWidth: cell.column.getSize(),
2183
2179
  zIndex: isDragging ? 1 : 0
2184
2180
  };
2185
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2186
- DataGridCell,
2187
- __spreadProps(__spreadValues({
2188
- style,
2189
- ref: setNodeRef,
2190
- width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`
2191
- }, props), {
2192
- children
2193
- })
2194
- );
2181
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
2195
2182
  }
2196
2183
  DragAlongCell.displayName = "DragAlongCell";
2197
2184
  // Annotate the CommonJS export names for ESM import in node: