@dmsi/wedgekit-react 0.0.207 → 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.
Files changed (45) hide show
  1. package/dist/{chunk-WNQ53SVY.js → chunk-E6Y7ZHQX.js} +45 -1
  2. package/dist/{chunk-WXHRJSDG.js → chunk-ERW3AMED.js} +1 -1
  3. package/dist/{chunk-2JRZCC2K.js → chunk-JITZWSPR.js} +3 -3
  4. package/dist/{chunk-WE55TGZZ.js → chunk-NIHZMIOL.js} +1 -1
  5. package/dist/{chunk-RXPS5GVE.js → chunk-Q3TNALWH.js} +17 -26
  6. package/dist/{chunk-M3433XEJ.js → chunk-T3F37S6Z.js} +15 -1
  7. package/dist/{chunk-2B5T4NCT.js → chunk-UKSJPFN2.js} +2 -2
  8. package/dist/components/DataGridCell.cjs +814 -824
  9. package/dist/components/DataGridCell.js +7 -6
  10. package/dist/components/DateInput.cjs +23 -23
  11. package/dist/components/DateInput.js +4 -4
  12. package/dist/components/DateRangeInput.cjs +23 -23
  13. package/dist/components/DateRangeInput.js +4 -4
  14. package/dist/components/Menu.cjs +38 -35
  15. package/dist/components/Menu.js +6 -4
  16. package/dist/components/MenuOption.cjs +7 -4
  17. package/dist/components/MenuOption.js +5 -2
  18. package/dist/components/Modal.cjs +15 -12
  19. package/dist/components/Modal.js +5 -3
  20. package/dist/components/NestedMenu.cjs +9 -6
  21. package/dist/components/NestedMenu.js +5 -2
  22. package/dist/components/PDFViewer.cjs +22 -19
  23. package/dist/components/PDFViewer.js +5 -3
  24. package/dist/components/ProjectBar.cjs +3 -0
  25. package/dist/components/ProjectBar.js +4 -1
  26. package/dist/components/Time.js +2 -1
  27. package/dist/components/index.cjs +963 -905
  28. package/dist/components/index.js +70 -45
  29. package/dist/components/useMenuSystem.cjs +22 -19
  30. package/dist/components/useMenuSystem.js +5 -2
  31. package/dist/hooks/index.cjs +66 -2
  32. package/dist/hooks/index.js +8 -3
  33. package/dist/utils/index.cjs +25 -0
  34. package/dist/utils/index.js +3 -1
  35. package/package.json +1 -1
  36. package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -4
  37. package/src/components/DataGrid/TableBody/index.tsx +14 -3
  38. package/src/components/DataGrid/index.tsx +58 -35
  39. package/src/components/DataGridCell.tsx +11 -17
  40. package/src/hooks/index.ts +1 -0
  41. package/src/hooks/useTableLayout.ts +68 -0
  42. package/src/utils/index.ts +1 -0
  43. package/src/utils/mergeObjectArrays.ts +18 -0
  44. package/src/utils.ts +1 -0
  45. /package/dist/{chunk-6LN6QT6M.js → chunk-VXWSAIB5.js} +0 -0
@@ -118,7 +118,7 @@ var CSS = /* @__PURE__ */ Object.freeze({
118
118
 
119
119
  // src/components/DataGridCell.tsx
120
120
  var import_clsx8 = __toESM(require("clsx"), 1);
121
- var import_react10 = require("react");
121
+ var import_react11 = require("react");
122
122
 
123
123
  // src/classNames.ts
124
124
  var import_clsx = __toESM(require("clsx"), 1);
@@ -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,536 +436,219 @@ 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)
853
- ),
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
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
+ })
583
+ ),
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
  ] });
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
+ }
610
+ }
611
+ function mobileBackMenuOption() {
612
+ if (!isMobile) {
613
+ return;
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
+ );
628
+ }
865
629
  };
866
- Search.displayName = "Search";
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
+ );
643
+ }
867
644
 
868
645
  // src/components/Menu.tsx
869
- var import_clsx5 = __toESM(require("clsx"), 1);
646
+ var import_clsx6 = __toESM(require("clsx"), 1);
870
647
  var import_react8 = require("react");
871
648
  var import_react_dom = require("react-dom");
872
649
 
873
650
  // src/components/useMenuSystem.tsx
874
651
  var import_react7 = 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/components/useMenuSystem.tsx
898
652
  function useSubMenuSystem(mobilePositionTo) {
899
653
  const [activeMenus, setActiveMenus] = (0, import_react7.useState)(
900
654
  {}
@@ -1233,29 +987,6 @@ function useMenuPosition(elementRef, position = "bottom", options) {
1233
987
  return { menuPosition, updatePosition };
1234
988
  }
1235
989
 
1236
- // src/utils.ts
1237
- function findDocumentRoot(element) {
1238
- if (typeof window === "undefined" || typeof document === "undefined") {
1239
- throw new Error(
1240
- "findDocumentRoot can only be used in a browser environment."
1241
- );
1242
- }
1243
- if (!element || !(element instanceof Node)) {
1244
- return window.document.body;
1245
- }
1246
- let currentElement = element;
1247
- while (currentElement && currentElement.parentNode) {
1248
- if (currentElement.parentNode === document) {
1249
- return document.body;
1250
- } else if (currentElement.parentNode instanceof DocumentFragment) {
1251
- return currentElement.parentNode;
1252
- } else {
1253
- currentElement = currentElement.parentNode;
1254
- }
1255
- }
1256
- return window.document.body;
1257
- }
1258
-
1259
990
  // src/components/Menu.tsx
1260
991
  var import_jsx_runtime5 = require("react/jsx-runtime");
1261
992
  var Menu = (_a) => {
@@ -1379,7 +1110,7 @@ var Menu = (_a) => {
1379
1110
  id,
1380
1111
  "data-testid": testid,
1381
1112
  ref: setRefs,
1382
- className: (0, import_clsx5.default)(
1113
+ className: (0, import_clsx6.default)(
1383
1114
  "shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
1384
1115
  "fixed",
1385
1116
  "z-50",
@@ -1501,253 +1232,521 @@ var Menu = (_a) => {
1501
1232
  ref.current = node;
1502
1233
  }
1503
1234
  }
1504
- }
1505
- function stopPropagation(e) {
1506
- e.stopPropagation();
1507
- }
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
+ );
1508
1411
  };
1509
- Menu.displayName = "Menu";
1510
-
1511
- // src/components/MenuOption.tsx
1512
- var import_clsx7 = __toESM(require("clsx"), 1);
1513
- var import_react9 = require("react");
1514
-
1515
- // src/components/Paragraph.tsx
1516
- var import_clsx6 = __toESM(require("clsx"), 1);
1517
- var import_jsx_runtime6 = require("react/jsx-runtime");
1518
- var Paragraph = (_a) => {
1412
+ var Input = (_a) => {
1519
1413
  var _b = _a, {
1520
- className,
1521
- color,
1522
- padded,
1523
- align = "left",
1524
- tall,
1525
- addOverflow,
1526
- children,
1527
- as = "p",
1414
+ variant = "default",
1415
+ decimals,
1416
+ uom,
1417
+ removeSearchIcon,
1418
+ value: propValue,
1419
+ onChange,
1420
+ onBlur,
1421
+ onClear,
1528
1422
  id,
1529
1423
  testid
1530
1424
  } = _b, props = __objRest(_b, [
1531
- "className",
1532
- "color",
1533
- "padded",
1534
- "align",
1535
- "tall",
1536
- "addOverflow",
1537
- "children",
1538
- "as",
1425
+ "variant",
1426
+ "decimals",
1427
+ "uom",
1428
+ "removeSearchIcon",
1429
+ "value",
1430
+ "onChange",
1431
+ "onBlur",
1432
+ "onClear",
1539
1433
  "id",
1540
1434
  "testid"
1541
1435
  ]);
1542
- const Element = as;
1543
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1544
- Element,
1545
- __spreadProps(__spreadValues({
1546
- id,
1547
- "data-testid": testid
1548
- }, props), {
1549
- className: (0, import_clsx6.default)(
1550
- typography.paragraph,
1551
- className,
1552
- padded && componentPaddingXUsingComponentGap,
1553
- align === "left" && "text-left",
1554
- align === "center" && "text-center",
1555
- align === "right" && "text-right",
1556
- tall && "!leading-6",
1557
- addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
1558
- ),
1559
- style: __spreadProps(__spreadValues({}, props.style), {
1560
- color: color ? `var(--color-${color})` : void 0
1561
- }),
1562
- children
1563
- })
1564
- );
1565
- };
1566
- Paragraph.displayName = "Paragraph";
1567
-
1568
- // src/components/MenuOption.tsx
1569
- var import_jsx_runtime7 = require("react/jsx-runtime");
1570
- var MenuOption = ({
1571
- id,
1572
- testid,
1573
- children,
1574
- disabled = false,
1575
- variant = "normal",
1576
- value,
1577
- before,
1578
- after,
1579
- subMenu,
1580
- onClick,
1581
- selected,
1582
- ref,
1583
- onSubMenuHover,
1584
- onSubMenuLeave,
1585
- onSubMenuEnter,
1586
- toggleMenu,
1587
- subMenuLevel = 1,
1588
- currentSubMenuLevel,
1589
- closeSubMenuLevel,
1590
- activeMenu,
1591
- mobilePositionTo,
1592
- highlightMatchingText = false,
1593
- menuValue,
1594
- onMouseMove
1595
- }) => {
1596
- const uniqueId = (0, import_react9.useId)();
1597
- const internalRef = (0, import_react9.useRef)(null);
1598
- const actualRef = ref || internalRef;
1599
- const menuId = (0, import_react9.useRef)(`menu-${uniqueId}`);
1600
- const isMobile = useMatchesMobile();
1601
- const handleMouseEnter = () => {
1602
- if (subMenu && onSubMenuHover && !disabled) {
1603
- 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;
1604
1487
  }
1605
1488
  };
1606
- const handleMouseLeave = () => {
1607
- if (subMenu && onSubMenuLeave && !disabled) {
1608
- 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;
1609
1498
  }
1610
1499
  };
1611
- const handleMouseMove = () => {
1612
- if (subMenu && onMouseMove && !disabled) {
1613
- 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;
1614
1524
  }
1615
1525
  };
1616
- const handleSubMenuEnter = () => {
1617
- if (onSubMenuEnter) {
1618
- 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;
1619
1594
  }
1595
+ onBlur == null ? void 0 : onBlur(e);
1620
1596
  };
1621
- const additionalAttributes = {
1622
- "data-selected": selected || null
1623
- };
1624
- const svgStyles = (0, import_clsx7.default)(
1625
- "[&>svg]:shrink-0 [&>svg]:fill-icon-action-primary-normal"
1626
- );
1627
- const textLabelStyles = (0, import_clsx7.default)("w-full whitespace-nowrap !leading-6");
1628
- const normalStyles = variant === "normal" && !disabled && (0, import_clsx7.default)(
1629
- "bg-transparent text-text-primary-normal",
1630
- "hover:bg-background-action-secondary-hover",
1631
- "focus:bg-background-action-secondary-hover",
1632
- "data-selected:bg-background-action-secondary-hover",
1633
- "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
+ })
1634
1607
  );
1635
- const normalDisabledStyles = variant === "normal" && disabled && (0, import_clsx7.default)("text-text-primary-disabled");
1636
- const actionStyles = variant === "action" && !disabled && (0, import_clsx7.default)(
1637
- "text-action-400 bg-transparent",
1638
- "hover:bg-background-action-secondary-hover hover:text-text-action-hover",
1639
- "focus:bg-background-action-secondary-hover focus:text-text-action-hover",
1640
- "data-selected:bg-background-action-secondary-active data-selected:text-text-action-active",
1641
- "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
+ })
1642
1625
  );
1643
- const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx7.default)("text-text-action-disabled");
1644
- const disabledStyles = disabled && (0, import_clsx7.default)("bg-transparent cursor-default pointer-events-none");
1645
- const processChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
1646
- 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]);
1647
1674
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1648
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1649
- "div",
1650
- __spreadProps(__spreadValues({
1675
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1676
+ Input,
1677
+ __spreadValues({
1651
1678
  id,
1652
- "data-testid": testid,
1653
- ref: actualRef,
1654
- className: (0, import_clsx7.default)(
1655
- "flex items-center cursor-pointer w-full text-left relative outline-none",
1656
- svgStyles,
1657
- componentGap,
1658
- componentPadding,
1659
- baseTransition,
1660
- normalStyles,
1661
- normalDisabledStyles,
1662
- actionStyles,
1663
- actionDisabledStyles,
1664
- disabledStyles
1665
- ),
1666
- "data-value": value || children,
1667
- onClick: () => {
1668
- onClick == null ? void 0 : onClick(menuId.current, value || children);
1669
- if (subMenu) {
1670
- 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;
1671
1692
  }
1693
+ onClick == null ? void 0 : onClick(e);
1694
+ setShow(!show);
1672
1695
  },
1673
- onMouseEnter: handleMouseEnter,
1674
- onMouseLeave: handleMouseLeave,
1675
- onMouseMove: handleMouseMove
1676
- }, additionalAttributes), {
1677
- tabIndex: -1,
1678
- role: "menuitem",
1679
- "aria-haspopup": subMenu ? "menu" : void 0,
1680
- children: [
1681
- before && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
1682
- renderChildren,
1683
- renderAfterProp()
1684
- ]
1685
- })
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)
1686
1732
  ),
1687
- subMenu && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1688
- "div",
1689
- {
1690
- onMouseEnter: handleSubMenuEnter,
1691
- onMouseLeave: handleMouseLeave,
1692
- "data-submenu-parent": menuId.current,
1693
- "data-menu-level": subMenuLevel + 1,
1694
- children: subMenu({
1695
- menuId: menuId.current,
1696
- positionTo: actualRef,
1697
- mobilePositionTo,
1698
- position: "right",
1699
- subMenuLevel,
1700
- mobileBackMenuOption,
1701
- mobileHide: isMobile && activeMenu !== menuId.current
1702
- })
1703
- }
1704
- )
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
1705
1743
  ] });
1706
- function renderAfterProp() {
1707
- if (after) {
1708
- return after;
1709
- }
1710
- if (subMenu && after !== null) {
1711
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron_right" });
1712
- }
1713
- }
1714
- function mobileBackMenuOption() {
1715
- if (!isMobile) {
1716
- return;
1717
- }
1718
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1719
- MenuOption,
1720
- {
1721
- id: id ? `${id}-back` : void 0,
1722
- testid: testid ? `${testid}-back` : void 0,
1723
- onClick: () => {
1724
- closeSubMenuLevel == null ? void 0 : closeSubMenuLevel(currentSubMenuLevel != null ? currentSubMenuLevel : 0);
1725
- },
1726
- variant: "action",
1727
- before: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron_left" }),
1728
- children: "Back"
1729
- }
1730
- );
1731
- }
1732
1744
  };
1733
- MenuOption.displayName = "MenuOption";
1734
- function highlightMatch(text, searchValue) {
1735
- if (!searchValue || !searchValue.trim()) {
1736
- return text;
1737
- }
1738
- const regex = new RegExp(
1739
- `(${searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
1740
- "gi"
1741
- );
1742
- const parts = text.split(regex);
1743
- return parts.map(
1744
- (part, index) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-bold", children: part }, index) : part
1745
- );
1746
- }
1745
+ Search.displayName = "Search";
1747
1746
 
1748
1747
  // src/components/DataGridCell.tsx
1749
1748
  var import_jsx_runtime8 = require("react/jsx-runtime");
1750
- var DataGridCell = (0, import_react10.memo)(
1749
+ var DataGridCell = (0, import_react11.memo)(
1751
1750
  (_a) => {
1752
1751
  var _b = _a, {
1753
1752
  id,
@@ -1765,6 +1764,7 @@ var DataGridCell = (0, import_react10.memo)(
1765
1764
  warning,
1766
1765
  center,
1767
1766
  width,
1767
+ minWidth,
1768
1768
  testid
1769
1769
  } = _b, props = __objRest(_b, [
1770
1770
  "id",
@@ -1782,13 +1782,14 @@ var DataGridCell = (0, import_react10.memo)(
1782
1782
  "warning",
1783
1783
  "center",
1784
1784
  "width",
1785
+ "minWidth",
1785
1786
  "testid"
1786
1787
  ]);
1787
1788
  const Element = type === "header" ? "th" : "td";
1788
- const timerRef = (0, import_react10.useRef)(null);
1789
- const [isGrabbing, setIsGrabbing] = (0, import_react10.useState)(false);
1790
- const [isPointerPressed, setIsPointerPressed] = (0, import_react10.useState)(false);
1791
- (0, import_react10.useEffect)(() => {
1789
+ const timerRef = (0, import_react11.useRef)(null);
1790
+ const [isGrabbing, setIsGrabbing] = (0, import_react11.useState)(false);
1791
+ const [isPointerPressed, setIsPointerPressed] = (0, import_react11.useState)(false);
1792
+ (0, import_react11.useEffect)(() => {
1792
1793
  return () => {
1793
1794
  if (timerRef.current) {
1794
1795
  clearTimeout(timerRef.current);
@@ -1855,7 +1856,7 @@ var DataGridCell = (0, import_react10.memo)(
1855
1856
  id,
1856
1857
  "data-testid": testid,
1857
1858
  className: (0, import_clsx8.default)("flex h-10", !width && "flex-1"),
1858
- style: { width }
1859
+ style: { width, minWidth }
1859
1860
  }, props), {
1860
1861
  "data-theme": type === "header" && !locked ? "brand" : void 0,
1861
1862
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1896,13 +1897,13 @@ function DataCellHeader(_a) {
1896
1897
  "testid",
1897
1898
  "useMenuDefaultMinWidth"
1898
1899
  ]);
1899
- var _a2, _b2, _c;
1900
- const [showMenu, setShowMenu] = (0, import_react10.useState)(false);
1901
- const [filter, setFilter] = (0, import_react10.useState)(
1900
+ var _a2;
1901
+ const [showMenu, setShowMenu] = (0, import_react11.useState)(false);
1902
+ const [filter, setFilter] = (0, import_react11.useState)(
1902
1903
  (_a2 = header.column.getFilterValue()) != null ? _a2 : ""
1903
1904
  );
1904
- const ref = (0, import_react10.useRef)(null);
1905
- const predeterminedPinned = (0, import_react10.useRef)(false);
1905
+ const ref = (0, import_react11.useRef)(null);
1906
+ const predeterminedPinned = (0, import_react11.useRef)(false);
1906
1907
  const {
1907
1908
  menuRootRef,
1908
1909
  isMenuActive,
@@ -1910,7 +1911,7 @@ function DataCellHeader(_a) {
1910
1911
  listeners: subMenuListeners,
1911
1912
  mobileHide
1912
1913
  } = useSubMenuSystem(node ? node : ref);
1913
- (0, import_react10.useEffect)(() => {
1914
+ (0, import_react11.useEffect)(() => {
1914
1915
  var _a3;
1915
1916
  const columnPinning = (_a3 = header.getContext().table.options.initialState) == null ? void 0 : _a3.columnPinning;
1916
1917
  const left = (columnPinning == null ? void 0 : columnPinning.left) ? columnPinning.left : [];
@@ -1919,7 +1920,7 @@ function DataCellHeader(_a) {
1919
1920
  header.column.id
1920
1921
  );
1921
1922
  }, []);
1922
- (0, import_react10.useEffect)(() => {
1923
+ (0, import_react11.useEffect)(() => {
1923
1924
  const handler = setTimeout(() => {
1924
1925
  header.column.setFilterValue(filter);
1925
1926
  }, 500);
@@ -1930,7 +1931,7 @@ function DataCellHeader(_a) {
1930
1931
  const style = __spreadValues({
1931
1932
  position: "relative",
1932
1933
  whiteSpace: "nowrap",
1933
- width: (_c = (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.headerWidth) != null ? _c : header.column.getSize(),
1934
+ minWidth: header.column.getSize(),
1934
1935
  "--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
1935
1936
  "--color-icon-on-action-primary-normal": "var(--color-text-brand-primary-normal)",
1936
1937
  "--background-action-secondary-normal": "var(--color-text-brand-primary-normal)"
@@ -1944,6 +1945,7 @@ function DataCellHeader(_a) {
1944
1945
  type: "header",
1945
1946
  component: "header",
1946
1947
  style,
1948
+ minWidth: `${header.column.getSize()}px`,
1947
1949
  onClick: header.column.getToggleSortingHandler(),
1948
1950
  onRightClick: () => setShowMenu(!showMenu)
1949
1951
  }, props), {
@@ -1967,8 +1969,8 @@ function DataCellHeader(_a) {
1967
1969
  id: id ? `${id}-filter-option` : void 0,
1968
1970
  testid: testid ? `${testid}-filter-option` : void 0
1969
1971
  }, subMenuListeners), {
1970
- subMenu: (_d) => {
1971
- 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"]);
1972
1974
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1973
1975
  Menu,
1974
1976
  __spreadProps(__spreadValues({
@@ -2041,8 +2043,8 @@ function DataCellHeader(_a) {
2041
2043
  setShowMenu(!showMenu);
2042
2044
  }
2043
2045
  }, subMenuListeners), {
2044
- subMenu: (_f) => {
2045
- 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"]);
2046
2048
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2047
2049
  Menu,
2048
2050
  __spreadProps(__spreadValues({}, props2), {
@@ -2130,7 +2132,6 @@ function DraggableCellHeader(_a) {
2130
2132
  "header",
2131
2133
  "children"
2132
2134
  ]);
2133
- var _a2, _b2;
2134
2135
  const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
2135
2136
  id: header.column.id
2136
2137
  });
@@ -2141,7 +2142,6 @@ function DraggableCellHeader(_a) {
2141
2142
  transition: "width transform 0.2s ease-in-out",
2142
2143
  whiteSpace: "nowrap",
2143
2144
  zIndex: isDragging ? 1 : 0,
2144
- width: (_b2 = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : header.column.getSize(),
2145
2145
  "--color-text-primary-normal": "var(--color-action-000)",
2146
2146
  "--color-icon-on-action-primary-normal": "var(--color-action-000)",
2147
2147
  userSelect: "none"
@@ -2167,7 +2167,6 @@ function DragAlongCell(_a) {
2167
2167
  "cell",
2168
2168
  "children"
2169
2169
  ]);
2170
- var _a2, _b2, _c, _d;
2171
2170
  const { isDragging, setNodeRef, transform } = (0, import_sortable.useSortable)({
2172
2171
  id: cell.column.id
2173
2172
  });
@@ -2176,19 +2175,10 @@ function DragAlongCell(_a) {
2176
2175
  position: "relative",
2177
2176
  transform: CSS.Translate.toString(transform),
2178
2177
  transition: "width transform 0.2s ease-in-out",
2179
- width: (_b2 = (_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : cell.column.getSize(),
2178
+ minWidth: cell.column.getSize(),
2180
2179
  zIndex: isDragging ? 1 : 0
2181
2180
  };
2182
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2183
- DataGridCell,
2184
- __spreadProps(__spreadValues({
2185
- style,
2186
- ref: setNodeRef,
2187
- width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`
2188
- }, props), {
2189
- children
2190
- })
2191
- );
2181
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
2192
2182
  }
2193
2183
  DragAlongCell.displayName = "DragAlongCell";
2194
2184
  // Annotate the CommonJS export names for ESM import in node: