@hyphen/hyphen-components 8.0.1 → 9.0.0-beta.1

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 (66) hide show
  1. package/dist/css/utilities.css +1 -1
  2. package/dist/css/utilities.css.map +1 -1
  3. package/dist/hyphen-components.cjs.development.js +353 -313
  4. package/dist/hyphen-components.cjs.development.js.map +1 -1
  5. package/dist/hyphen-components.cjs.production.min.js +2 -2
  6. package/dist/hyphen-components.cjs.production.min.js.map +1 -1
  7. package/dist/hyphen-components.esm.js +357 -314
  8. package/dist/hyphen-components.esm.js.map +1 -1
  9. package/dist/index.d.ts +222 -212
  10. package/package.json +6 -5
  11. package/src/components/Alert/Alert.tsx +5 -6
  12. package/src/components/Badge/Badge.test.tsx +12 -0
  13. package/src/components/Badge/Badge.tsx +52 -20
  14. package/src/components/Box/Box.mdx +1 -1
  15. package/src/components/Box/Box.stories.tsx +1 -1
  16. package/src/components/Box/Box.test.tsx +24 -1
  17. package/src/components/Box/Box.tsx +108 -82
  18. package/src/components/Card/Card.tsx +5 -1
  19. package/src/components/Card/components/CardFooter/CardFooter.tsx +0 -4
  20. package/src/components/Card/components/CardHeader/CardHeader.tsx +4 -1
  21. package/src/components/Card/components/CardSection/CardSection.tsx +4 -5
  22. package/src/components/CheckboxInput/CheckboxInput.test.tsx +17 -0
  23. package/src/components/CheckboxInput/CheckboxInput.tsx +15 -4
  24. package/src/components/CheckboxInput/components/Checkbox.test.tsx +36 -0
  25. package/src/components/CheckboxInput/components/Checkbox.tsx +8 -2
  26. package/src/components/Details/Details.test.tsx +8 -0
  27. package/src/components/Details/Details.tsx +5 -2
  28. package/src/components/Details/DetailsSummary.tsx +4 -1
  29. package/src/components/Drawer/Drawer.test.tsx +8 -0
  30. package/src/components/Drawer/Drawer.tsx +1 -1
  31. package/src/components/FormLabel/FormLabel.tsx +6 -3
  32. package/src/components/Formik/FormikCheckboxInput/FormikCheckboxInput.test.tsx +9 -0
  33. package/src/components/Formik/FormikCheckboxInput/FormikCheckboxInput.tsx +1 -0
  34. package/src/components/Formik/FormikSelectInput/FormikSelectInput.tsx +21 -11
  35. package/src/components/Formik/FormikSelectInputNative/FormikSelectInputNative.tsx +1 -1
  36. package/src/components/Formik/FormikTimePicker/FormikTimePicker.tsx +1 -1
  37. package/src/components/Heading/Heading.tsx +5 -6
  38. package/src/components/Icon/Icon.test.tsx +8 -0
  39. package/src/components/Icon/Icon.tsx +6 -7
  40. package/src/components/Modal/Modal.test.tsx +31 -1
  41. package/src/components/Modal/Modal.tsx +13 -7
  42. package/src/components/Popover/Popover.test.tsx +3 -4
  43. package/src/components/RadioGroup/RadioGroup.tsx +11 -6
  44. package/src/components/RadioGroup/RadioInput/RadioInputIcon.tsx +0 -4
  45. package/src/components/SelectInput/SelectInput.test.tsx +18 -0
  46. package/src/components/SelectInput/SelectInput.tsx +47 -27
  47. package/src/components/SelectInputInset/SelectInputInset.tsx +8 -9
  48. package/src/components/SelectInputNative/SelectInputNative.test.tsx +24 -0
  49. package/src/components/SelectInputNative/SelectInputNative.tsx +79 -14
  50. package/src/components/Switch/Switch.tsx +1 -1
  51. package/src/components/Table/Table.mdx +21 -1
  52. package/src/components/Table/Table.stories.tsx +5 -1
  53. package/src/components/Table/Table.tsx +7 -7
  54. package/src/components/Table/TableBody/TableBody.test.tsx +89 -1
  55. package/src/components/Table/TableBody/TableBody.tsx +23 -8
  56. package/src/components/Table/TableHead/TableHead.tsx +6 -6
  57. package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.tsx +6 -6
  58. package/src/components/Table/common/TableRow/TableRow.test.tsx +17 -1
  59. package/src/components/Table/common/TableRow/TableRow.tsx +30 -10
  60. package/src/components/TextInput/TextInput.tsx +10 -8
  61. package/src/components/TextInputInset/TextInputInset.tsx +5 -6
  62. package/src/components/TextareaInput/TextareaInput.tsx +4 -5
  63. package/src/components/TextareaInputInset/TextareaInputInset.tsx +10 -17
  64. package/src/components/Toast/Toast.stories.tsx +5 -1
  65. package/src/lib/getColumnKeys.ts +5 -3
  66. package/src/types/index.ts +6 -7
@@ -371,18 +371,6 @@ function getDimensionCss(dimension, value) {
371
371
  };
372
372
  }
373
373
 
374
- // src/lib/getElementType.ts
375
- function getElementType(Component, props, getDefault) {
376
- const { defaultProps = {} } = Component;
377
- if (props.as && props.as !== defaultProps.as) return props.as;
378
- if (getDefault) {
379
- const computedDefault = getDefault();
380
- if (computedDefault) return computedDefault;
381
- }
382
- if (props.href) return "a";
383
- return defaultProps.as || "div";
384
- }
385
-
386
374
  // src/components/Box/Box.module.scss
387
375
  var Box_module_default = { "box-transition": "box-transition__sKpxg" };
388
376
 
@@ -393,9 +381,9 @@ var AUTO_FONT_COLOR_BACKGROUNDS = [
393
381
  "danger",
394
382
  "info"
395
383
  ];
396
- var Box = (0, import_react.forwardRef)(
397
- ({
398
- as = "div",
384
+ var BoxBaseComponent = (props, ref) => {
385
+ const {
386
+ as,
399
387
  alignItems = void 0,
400
388
  alignContent = void 0,
401
389
  alignSelf = void 0,
@@ -440,256 +428,259 @@ var Box = (0, import_react.forwardRef)(
440
428
  wordBreak = void 0,
441
429
  zIndex = void 0,
442
430
  ...restProps
443
- }, ref) => {
444
- const heightCss = getDimensionCss("h", height);
445
- const widthCss = getDimensionCss("w", width);
446
- const maxHeightCss = getDimensionCss("mh", maxHeight);
447
- const maxWidthCss = getDimensionCss("mw", maxWidth);
448
- const minHeightCss = getDimensionCss("minh", minHeight);
449
- const minWidthCss = getDimensionCss("minw", minWidth);
450
- const finalColor = color ?? (background === "inverse" ? "inverse" : AUTO_FONT_COLOR_BACKGROUNDS.includes(background) ? "grey" : void 0);
451
- const isFlexBox = typeof display === "string" && display.includes("flex");
452
- const flexDirectionClasses = isFlexBox ? generateResponsiveClasses("flex-direction", direction) : null;
453
- const cssPropertyMap = {
454
- color: {
455
- classPrefix: "font-color",
456
- transformer: generateResponsiveClasses
457
- },
458
- background: {
459
- classPrefix: "background-color",
460
- transformer: generateResponsiveClasses
461
- },
462
- borderColor: {
463
- classPrefix: "border-color",
464
- transformer: generateResponsiveClasses
465
- },
466
- borderWidth: {
467
- classPrefix: "border-width",
468
- transformer: cssShorthandToClasses
469
- },
470
- shadow: { classPrefix: "shadow", transformer: generateResponsiveClasses },
471
- fontSize: {
472
- classPrefix: "font-size",
473
- transformer: generateResponsiveClasses
474
- }
475
- };
476
- const getStatefulClasses = (stateKey, values) => values ? Object.entries(values).map(
477
- ([key, value]) => cssPropertyMap[key].transformer(
478
- `${stateKey}:${cssPropertyMap[key].classPrefix}`,
479
- value
480
- )
481
- // eslint-disable-line max-len
482
- ) : void 0;
483
- const hoverClasses = getStatefulClasses("hover", hover);
484
- const focusClasses = getStatefulClasses("focus", focus);
485
- const boxClasses = (0, import_classnames.default)(
486
- className,
487
- cssShorthandToClasses("m", margin),
488
- cssShorthandToClasses("p", padding),
489
- cssShorthandToClasses("br", radius),
490
- cssShorthandToClasses("g", gap),
491
- cssShorthandToClasses("cg", columnGap),
492
- cssShorthandToClasses("rg", rowGap),
493
- heightCss.classes,
494
- maxHeightCss.classes,
495
- minHeightCss.classes,
496
- maxWidthCss.classes,
497
- minWidthCss.classes,
498
- widthCss.classes,
499
- flexDirectionClasses,
500
- generateResponsiveClasses("display", display),
501
- generateResponsiveClasses("justify-content", justifyContent),
502
- generateResponsiveClasses("align-items", alignItems),
503
- generateResponsiveClasses("align-content", alignContent),
504
- generateResponsiveClasses("align-self", alignSelf),
505
- generateResponsiveClasses("font-family", fontFamily),
506
- generateResponsiveClasses("font-size", fontSize),
507
- generateResponsiveClasses("overflow", overflow),
508
- generateResponsiveClasses("shadow", shadow),
509
- generateResponsiveClasses("flex", flex),
510
- cssShorthandToClasses("bw", borderWidth),
511
- generateResponsiveClasses("font-weight", fontWeight),
512
- generateResponsiveClasses("text-align", textAlign),
513
- generateResponsiveClasses("transform", textTransform),
514
- generateResponsiveClasses("text-wrap", textWrap),
515
- generateResponsiveClasses("position", position),
516
- generateResponsiveClasses("z-index", zIndex),
517
- generateResponsiveClasses("whitespace", whiteSpace),
518
- generateResponsiveClasses("break", wordBreak),
519
- ...hoverClasses ?? [],
520
- ...focusClasses ?? [],
521
- {
522
- "flex-wrap": isFlexBox && wrap,
523
- "flex-nowrap": isFlexBox && wrap === false,
524
- [`background-color-${background}`]: background,
525
- [`font-color-${finalColor}`]: finalColor,
526
- [`border-color-${borderColor}`]: borderColor,
527
- [`cursor-${cursor}`]: cursor,
528
- [Box_module_default["box-transition"]]: hover || focus
529
- }
530
- );
531
- const boxStyles = {
532
- ...style,
533
- ...heightCss.styles,
534
- ...maxHeightCss.styles,
535
- ...maxWidthCss.styles,
536
- ...widthCss.styles,
537
- ...minHeightCss.styles,
538
- ...minWidthCss.styles
539
- };
540
- const generateChildGapDirection = () => {
541
- let childGapDirection = {};
542
- const getChildGapMarginDirection = (d) => {
543
- let marginDirection = "";
544
- if (d?.includes("row")) marginDirection = "right";
545
- else if (d?.includes("column")) marginDirection = "bottom";
546
- return marginDirection;
547
- };
548
- if (typeof direction === "string") {
549
- childGapDirection = {
550
- base: getChildGapMarginDirection(direction)
551
- };
552
- } else if (typeof direction === "object" && direction !== null) {
553
- childGapDirection = Object.keys(direction).reduce(
554
- (acc, curr) => ({
555
- ...acc,
556
- [curr]: getChildGapMarginDirection(
557
- direction[curr]
558
- )
559
- }),
560
- {}
561
- );
562
- }
563
- return childGapDirection;
564
- };
565
- const generateChildGap = () => {
566
- let childGapObj = {};
567
- if (typeof childGap === "string") {
568
- childGapObj = { base: childGap };
569
- } else if (typeof childGap === "object" && childGap !== null) {
570
- childGapObj = { ...childGap };
571
- }
572
- return childGapObj;
431
+ } = props;
432
+ const heightCss = getDimensionCss("h", height);
433
+ const widthCss = getDimensionCss("w", width);
434
+ const maxHeightCss = getDimensionCss("mh", maxHeight);
435
+ const maxWidthCss = getDimensionCss("mw", maxWidth);
436
+ const minHeightCss = getDimensionCss("minh", minHeight);
437
+ const minWidthCss = getDimensionCss("minw", minWidth);
438
+ const finalColor = color ?? (background === "inverse" ? "inverse" : background && AUTO_FONT_COLOR_BACKGROUNDS.includes(background) ? "grey" : void 0);
439
+ const isFlexBox = typeof display === "string" && display.includes("flex");
440
+ const flexDirectionClasses = isFlexBox ? generateResponsiveClasses("flex-direction", direction) : null;
441
+ const cssPropertyMap = {
442
+ color: {
443
+ classPrefix: "font-color",
444
+ transformer: generateResponsiveClasses
445
+ },
446
+ background: {
447
+ classPrefix: "background-color",
448
+ transformer: generateResponsiveClasses
449
+ },
450
+ borderColor: {
451
+ classPrefix: "border-color",
452
+ transformer: generateResponsiveClasses
453
+ },
454
+ borderWidth: {
455
+ classPrefix: "border-width",
456
+ transformer: cssShorthandToClasses
457
+ },
458
+ shadow: { classPrefix: "shadow", transformer: generateResponsiveClasses },
459
+ fontSize: {
460
+ classPrefix: "font-size",
461
+ transformer: generateResponsiveClasses
462
+ }
463
+ };
464
+ const getStatefulClasses = (stateKey, values) => values ? Object.entries(values).map(
465
+ ([key, value]) => cssPropertyMap[key].transformer(
466
+ `${stateKey}:${cssPropertyMap[key].classPrefix}`,
467
+ value
468
+ )
469
+ // eslint-disable-line max-len
470
+ ) : void 0;
471
+ const hoverClasses = getStatefulClasses("hover", hover);
472
+ const focusClasses = getStatefulClasses("focus", focus);
473
+ const boxClasses = (0, import_classnames.default)(
474
+ className,
475
+ cssShorthandToClasses("m", margin),
476
+ cssShorthandToClasses("p", padding),
477
+ cssShorthandToClasses("br", radius),
478
+ cssShorthandToClasses("g", gap),
479
+ cssShorthandToClasses("cg", columnGap),
480
+ cssShorthandToClasses("rg", rowGap),
481
+ heightCss.classes,
482
+ maxHeightCss.classes,
483
+ minHeightCss.classes,
484
+ maxWidthCss.classes,
485
+ minWidthCss.classes,
486
+ widthCss.classes,
487
+ flexDirectionClasses,
488
+ generateResponsiveClasses("display", display),
489
+ generateResponsiveClasses("justify-content", justifyContent),
490
+ generateResponsiveClasses("align-items", alignItems),
491
+ generateResponsiveClasses("align-content", alignContent),
492
+ generateResponsiveClasses("align-self", alignSelf),
493
+ generateResponsiveClasses("font-family", fontFamily),
494
+ generateResponsiveClasses("font-size", fontSize),
495
+ generateResponsiveClasses("overflow", overflow),
496
+ generateResponsiveClasses("shadow", shadow),
497
+ generateResponsiveClasses("flex", flex),
498
+ cssShorthandToClasses("bw", borderWidth),
499
+ generateResponsiveClasses("font-weight", fontWeight),
500
+ generateResponsiveClasses("text-align", textAlign),
501
+ generateResponsiveClasses("transform", textTransform),
502
+ generateResponsiveClasses("text-wrap", textWrap),
503
+ generateResponsiveClasses("position", position),
504
+ generateResponsiveClasses("z-index", zIndex),
505
+ generateResponsiveClasses("whitespace", whiteSpace),
506
+ generateResponsiveClasses("break", wordBreak),
507
+ ...hoverClasses ?? [],
508
+ ...focusClasses ?? [],
509
+ {
510
+ "flex-wrap": isFlexBox && wrap,
511
+ "flex-nowrap": isFlexBox && wrap === false,
512
+ [`background-color-${background}`]: background,
513
+ [`font-color-${finalColor}`]: finalColor,
514
+ [`border-color-${borderColor}`]: borderColor,
515
+ [`cursor-${cursor}`]: cursor,
516
+ [Box_module_default["box-transition"]]: hover || focus
517
+ }
518
+ );
519
+ const boxStyles = {
520
+ ...style,
521
+ ...heightCss.styles,
522
+ ...maxHeightCss.styles,
523
+ ...maxWidthCss.styles,
524
+ ...widthCss.styles,
525
+ ...minHeightCss.styles,
526
+ ...minWidthCss.styles
527
+ };
528
+ const generateChildGapDirection = () => {
529
+ let childGapDirection = {};
530
+ const getChildGapMarginDirection = (d) => {
531
+ let marginDirection = "";
532
+ if (d?.includes("row")) marginDirection = "right";
533
+ else if (d?.includes("column")) marginDirection = "bottom";
534
+ return marginDirection;
573
535
  };
574
- const childGapClasses = [];
575
- if (childGap && direction) {
576
- const childGapDirection = generateChildGapDirection();
577
- const childGapValues = generateChildGap();
578
- const breakpoints = [
579
- "hd",
580
- "desktop",
581
- "tablet",
582
- "base"
583
- ];
584
- const findMatchingBreakpoint = (responsiveObj, key) => {
585
- const index = breakpoints.findIndex((breakpoint) => breakpoint === key);
586
- let value = "";
587
- value = responsiveObj[key];
588
- if (!value)
589
- return findMatchingBreakpoint(responsiveObj, breakpoints[index + 1]);
590
- return value;
536
+ if (typeof direction === "string") {
537
+ childGapDirection = {
538
+ base: getChildGapMarginDirection(direction)
591
539
  };
592
- breakpoints.forEach((breakpoint) => {
593
- const foundDirection = findMatchingBreakpoint(
594
- childGapDirection,
595
- breakpoint
596
- );
597
- const foundChildGap = findMatchingBreakpoint(
598
- childGapValues,
599
- breakpoint
600
- );
601
- const classSuffix = breakpoint === "base" ? "" : `-${breakpoint}`;
602
- const oppositeDirection = foundDirection === "bottom" ? "right" : "bottom";
603
- childGapClasses.push(
604
- `m-${foundDirection}-${foundChildGap}${classSuffix}`
605
- );
606
- childGapClasses.push(`m-${oppositeDirection}-0${classSuffix}`);
607
- });
540
+ } else if (typeof direction === "object" && direction !== null) {
541
+ childGapDirection = Object.keys(direction).reduce(
542
+ (acc, curr) => ({
543
+ ...acc,
544
+ [curr]: getChildGapMarginDirection(
545
+ direction[curr]
546
+ )
547
+ }),
548
+ {}
549
+ );
608
550
  }
609
- const decorateChildren = (child, i, array) => {
610
- if (i === array.length - 1 || !child || typeof child === "string" || typeof child === "number") {
611
- return child;
612
- }
613
- const childClasses = (0, import_classnames.default)(child.props?.className, [
614
- ...Array.from(new Set(childGapClasses))
615
- ]);
616
- return (0, import_react.cloneElement)(child, {
617
- className: childClasses,
618
- key: child.key ?? i
619
- });
551
+ return childGapDirection;
552
+ };
553
+ const generateChildGap = () => {
554
+ let childGapObj = {};
555
+ if (typeof childGap === "string") {
556
+ childGapObj = { base: childGap };
557
+ } else if (typeof childGap === "object" && childGap !== null) {
558
+ childGapObj = { ...childGap };
559
+ }
560
+ return childGapObj;
561
+ };
562
+ const childGapClasses = [];
563
+ if (childGap && direction) {
564
+ const childGapDirection = generateChildGapDirection();
565
+ const childGapValues = generateChildGap();
566
+ const breakpoints = [
567
+ "hd",
568
+ "desktop",
569
+ "tablet",
570
+ "base"
571
+ ];
572
+ const findMatchingBreakpoint = (responsiveObj, key) => {
573
+ const index = breakpoints.findIndex((breakpoint) => breakpoint === key);
574
+ let value = "";
575
+ value = responsiveObj[key];
576
+ if (!value)
577
+ return findMatchingBreakpoint(responsiveObj, breakpoints[index + 1]);
578
+ return value;
620
579
  };
621
- let decoratedChildren = import_react.Children.toArray(children).filter(
622
- (child) => child !== null
623
- );
624
- if (childGapClasses && decoratedChildren.length > 1) {
625
- decoratedChildren = decoratedChildren.map(
626
- (value, index, array) => decorateChildren(
627
- value,
628
- // eslint-disable-line @typescript-eslint/no-explicit-any
629
- index,
630
- array
631
- // eslint-disable-line @typescript-eslint/no-explicit-any
632
- )
580
+ breakpoints.forEach((breakpoint) => {
581
+ const foundDirection = findMatchingBreakpoint(
582
+ childGapDirection,
583
+ breakpoint
584
+ );
585
+ const foundChildGap = findMatchingBreakpoint(
586
+ childGapValues,
587
+ breakpoint
588
+ );
589
+ const classSuffix = breakpoint === "base" ? "" : `-${breakpoint}`;
590
+ const oppositeDirection = foundDirection === "bottom" ? "right" : "bottom";
591
+ childGapClasses.push(
592
+ `m-${foundDirection}-${foundChildGap}${classSuffix}`
633
593
  );
594
+ childGapClasses.push(`m-${oppositeDirection}-0${classSuffix}`);
595
+ });
596
+ }
597
+ const decorateChildren = (child, i, array) => {
598
+ if (i === array.length - 1 || !child || typeof child === "string" || typeof child === "number") {
599
+ return child;
634
600
  }
635
- const element = getElementType(Box, { as });
636
- return (0, import_react.createElement)(
637
- element,
638
- {
639
- className: boxClasses,
640
- style: boxStyles,
641
- ref,
642
- ...restProps
643
- },
644
- children !== null && children !== void 0 ? decoratedChildren : null
601
+ const childClasses = (0, import_classnames.default)(child.props?.className, [
602
+ ...Array.from(new Set(childGapClasses))
603
+ ]);
604
+ return (0, import_react.cloneElement)(child, {
605
+ className: childClasses,
606
+ key: child.key ?? i
607
+ });
608
+ };
609
+ let decoratedChildren = import_react.Children.toArray(children).filter(
610
+ (child) => child !== null
611
+ );
612
+ if (childGapClasses && decoratedChildren.length > 1) {
613
+ decoratedChildren = decoratedChildren.map(
614
+ (value, index, array) => decorateChildren(
615
+ value,
616
+ // eslint-disable-line @typescript-eslint/no-explicit-any
617
+ index,
618
+ array
619
+ // eslint-disable-line @typescript-eslint/no-explicit-any
620
+ )
645
621
  );
646
622
  }
647
- );
623
+ const element = as ?? "div";
624
+ return (0, import_react.createElement)(
625
+ element,
626
+ {
627
+ className: boxClasses,
628
+ style: boxStyles,
629
+ ref,
630
+ ...restProps
631
+ },
632
+ children !== null && children !== void 0 ? decoratedChildren : null
633
+ );
634
+ };
635
+ var Box = (0, import_react.forwardRef)(BoxBaseComponent);
648
636
  Box.displayName = "Box";
649
- var boxPropsKeys = [
650
- "as",
651
- "alignItems",
652
- "alignContent",
653
- "alignSelf",
654
- "background",
655
- "borderColor",
656
- "borderWidth",
657
- "className",
658
- "childGap",
659
- "children",
660
- "color",
661
- "columnGap",
662
- "cursor",
663
- "direction",
664
- "display",
665
- "flex",
666
- "focus",
667
- "fontFamily",
668
- "fontSize",
669
- "fontWeight",
670
- "gap",
671
- "height",
672
- "hover",
673
- "justifyContent",
674
- "margin",
675
- "maxHeight",
676
- "minHeight",
677
- "maxWidth",
678
- "minWidth",
679
- "overflow",
680
- "padding",
681
- "position",
682
- "radius",
683
- "rowGap",
684
- "shadow",
685
- "style",
686
- "textAlign",
687
- "textTransform",
688
- "textWrap",
689
- "wrap",
690
- "width",
691
- "zIndex"
692
- ];
637
+ var boxPropsKeyMap = {
638
+ as: true,
639
+ alignItems: true,
640
+ alignContent: true,
641
+ alignSelf: true,
642
+ background: true,
643
+ borderColor: true,
644
+ borderWidth: true,
645
+ className: true,
646
+ childGap: true,
647
+ children: true,
648
+ color: true,
649
+ columnGap: true,
650
+ cursor: true,
651
+ direction: true,
652
+ display: true,
653
+ flex: true,
654
+ focus: true,
655
+ fontFamily: true,
656
+ fontSize: true,
657
+ fontWeight: true,
658
+ gap: true,
659
+ height: true,
660
+ hover: true,
661
+ justifyContent: true,
662
+ margin: true,
663
+ maxHeight: true,
664
+ minHeight: true,
665
+ maxWidth: true,
666
+ minWidth: true,
667
+ overflow: true,
668
+ padding: true,
669
+ position: true,
670
+ radius: true,
671
+ rowGap: true,
672
+ shadow: true,
673
+ style: true,
674
+ textAlign: true,
675
+ textTransform: true,
676
+ textWrap: true,
677
+ whiteSpace: true,
678
+ wrap: true,
679
+ width: true,
680
+ wordBreak: true,
681
+ zIndex: true
682
+ };
683
+ var boxPropsKeys = Object.keys(boxPropsKeyMap);
693
684
 
694
685
  // src/components/Icon/Icon.tsx
695
686
  var import_react2 = __toESM(require("react"));
@@ -849,8 +840,8 @@ var renderBadgeChildren = (children) => import_react5.Children.map(
849
840
  children,
850
841
  (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ import_react5.default.createElement("span", { className: Badge_module_default.label }, child) : child
851
842
  );
852
- var Badge = (0, import_react5.forwardRef)(
853
- ({
843
+ var BadgeBaseComponent = (props, ref) => {
844
+ const {
854
845
  className = "",
855
846
  color = "grey",
856
847
  radius = "full",
@@ -858,33 +849,34 @@ var Badge = (0, import_react5.forwardRef)(
858
849
  size = "md",
859
850
  children,
860
851
  ...restProps
861
- }, ref) => {
862
- const responsiveClasses = generateResponsiveClasses("size", size).map(
863
- (c) => Badge_module_default[c]
864
- );
865
- const hue = BADGE_COLOR_ALIASES[color] ?? color;
866
- const badgeClasses = (0, import_classnames4.default)(
867
- Badge_module_default.badge,
868
- className,
869
- responsiveClasses,
870
- Badge_module_default[variant],
871
- Badge_module_default[`color-${hue}`],
872
- Badge_module_default[`radius-${radius}`]
873
- );
874
- return /* @__PURE__ */ import_react5.default.createElement(
875
- Box,
876
- {
877
- ref,
878
- className: badgeClasses,
879
- display: "inline-flex",
880
- alignItems: "center",
881
- direction: "row",
882
- ...restProps
883
- },
884
- renderBadgeChildren(children)
885
- );
852
+ } = props;
853
+ const responsiveClasses = generateResponsiveClasses("size", size).map(
854
+ (c) => Badge_module_default[c]
855
+ );
856
+ const hue = BADGE_COLOR_ALIASES[color] ?? color;
857
+ const badgeClasses = (0, import_classnames4.default)(
858
+ Badge_module_default.badge,
859
+ className,
860
+ responsiveClasses,
861
+ Badge_module_default[variant],
862
+ Badge_module_default[`color-${hue}`],
863
+ Badge_module_default[`radius-${radius}`]
864
+ );
865
+ const boxProps = {
866
+ className: badgeClasses,
867
+ display: "inline-flex",
868
+ alignItems: "center",
869
+ direction: "row",
870
+ ...restProps
871
+ };
872
+ const badgeChildren = renderBadgeChildren(children);
873
+ if (boxProps.as) {
874
+ const boxPropsWithAs = boxProps;
875
+ return /* @__PURE__ */ import_react5.default.createElement(Box, { ref, ...boxPropsWithAs }, badgeChildren);
886
876
  }
887
- );
877
+ return /* @__PURE__ */ import_react5.default.createElement(Box, { ref, ...boxProps }, badgeChildren);
878
+ };
879
+ var Badge = (0, import_react5.forwardRef)(BadgeBaseComponent);
888
880
  Badge.displayName = "Badge";
889
881
 
890
882
  // src/components/Button/Button.tsx
@@ -1254,6 +1246,18 @@ var HEADING_DEFAULT_SIZE_MAP = {
1254
1246
  // src/components/Heading/Heading.tsx
1255
1247
  var import_classnames8 = __toESM(require("classnames"));
1256
1248
 
1249
+ // src/lib/getElementType.ts
1250
+ function getElementType(Component, props, getDefault) {
1251
+ const { defaultProps = {} } = Component;
1252
+ if (props.as && props.as !== defaultProps.as) return props.as;
1253
+ if (getDefault) {
1254
+ const computedDefault = getDefault();
1255
+ if (computedDefault) return computedDefault;
1256
+ }
1257
+ if (props.href) return "a";
1258
+ return defaultProps.as || "div";
1259
+ }
1260
+
1257
1261
  // src/components/Heading/Heading.module.scss
1258
1262
  var Heading_module_default = { "heading": "heading__Jti1g" };
1259
1263
 
@@ -1437,6 +1441,7 @@ var Checkbox = import_react16.default.forwardRef(
1437
1441
  isChecked,
1438
1442
  label,
1439
1443
  labelledby,
1444
+ name = void 0,
1440
1445
  onChange,
1441
1446
  error = false,
1442
1447
  isDisabled = false,
@@ -1470,6 +1475,7 @@ var Checkbox = import_react16.default.forwardRef(
1470
1475
  "aria-labelledby": labelledby,
1471
1476
  "aria-required": isRequired,
1472
1477
  id,
1478
+ name,
1473
1479
  checked: !!isChecked,
1474
1480
  disabled: isDisabled,
1475
1481
  onBlur: handleBlur,
@@ -1478,7 +1484,7 @@ var Checkbox = import_react16.default.forwardRef(
1478
1484
  required: isRequired,
1479
1485
  type: "checkbox",
1480
1486
  ref: inputRef,
1481
- ...value && { value }
1487
+ ...value !== void 0 && { value }
1482
1488
  };
1483
1489
  const responsiveClasses = generateResponsiveClasses("size", size);
1484
1490
  const containerClasses = (0, import_classnames10.default)(
@@ -1656,10 +1662,12 @@ var CheckboxInput = ({
1656
1662
  isDisabled = false,
1657
1663
  isIndeterminate = false,
1658
1664
  isRequired = false,
1665
+ name = void 0,
1659
1666
  onBlur = void 0,
1660
1667
  onFocus = void 0,
1661
1668
  requiredIndicator = " *",
1662
1669
  size = "md",
1670
+ value = void 0,
1663
1671
  ...restProps
1664
1672
  }) => {
1665
1673
  const handleBlur = (event) => {
@@ -1676,11 +1684,13 @@ var CheckboxInput = ({
1676
1684
  isChecked: !!isChecked,
1677
1685
  isDisabled,
1678
1686
  isIndeterminate,
1687
+ name,
1679
1688
  onBlur: handleBlur,
1680
1689
  onChange: handleChange,
1681
1690
  onFocus: handleFocus,
1682
1691
  isRequired,
1683
1692
  size,
1693
+ value,
1684
1694
  label,
1685
1695
  className: (0, import_classnames14.default)(
1686
1696
  "hyphen-components__variables__form-control",
@@ -2233,6 +2243,7 @@ var FormikCheckboxInput = ({
2233
2243
  ...props,
2234
2244
  id,
2235
2245
  label,
2246
+ name,
2236
2247
  error: (0, import_formik.getIn)(touched, name) && (0, import_formik.getIn)(errors, name),
2237
2248
  isChecked: value,
2238
2249
  onBlur,
@@ -2671,6 +2682,8 @@ function SelectInput(props) {
2671
2682
  placeholder = void 0,
2672
2683
  requiredIndicator = " *",
2673
2684
  size = "md",
2685
+ cacheOptions,
2686
+ defaultOptions,
2674
2687
  ...restProps
2675
2688
  } = props;
2676
2689
  const handleChange = (values) => {
@@ -2709,7 +2722,11 @@ function SelectInput(props) {
2709
2722
  };
2710
2723
  const ClearIndicator = (props2) => /* @__PURE__ */ import_react32.default.createElement(import_react_select.components.ClearIndicator, { ...props2 }, /* @__PURE__ */ import_react32.default.createElement(Icon, { name: "remove" }));
2711
2724
  const Component = isCreatable && isAsync ? import_async_creatable.default : isCreatable ? import_creatable.default : isAsync ? import_async.default : import_react_select.default;
2712
- const selectOptions = isAsync ? { loadOptions: options } : { options };
2725
+ const selectOptions = isAsync ? {
2726
+ loadOptions: options,
2727
+ cacheOptions,
2728
+ defaultOptions
2729
+ } : { options };
2713
2730
  return /* @__PURE__ */ import_react32.default.createElement(Box, { width: "100%", className: wrapperClasses }, label && !hideLabel && /* @__PURE__ */ import_react32.default.createElement(FormLabel, { ...labelProps }, label), /* @__PURE__ */ import_react32.default.createElement(
2714
2731
  Component,
2715
2732
  {
@@ -2747,11 +2764,8 @@ var FormikSelectInput = ({
2747
2764
  field: { name, onBlur, onChange: formikOnChange, value },
2748
2765
  form: { touched, errors },
2749
2766
  onChange,
2750
- id,
2751
- label,
2752
- options,
2753
2767
  error: errorProp,
2754
- ...props
2768
+ ...selectProps
2755
2769
  }) => {
2756
2770
  let errorMessage;
2757
2771
  const error = errorProp ?? ((0, import_formik3.getIn)(touched, name) && (0, import_formik3.getIn)(errors, name));
@@ -2763,15 +2777,12 @@ var FormikSelectInput = ({
2763
2777
  return /* @__PURE__ */ import_react33.default.createElement(
2764
2778
  SelectInput,
2765
2779
  {
2766
- id,
2767
- label,
2768
- options,
2780
+ ...selectProps,
2769
2781
  name,
2770
2782
  onBlur,
2771
2783
  onChange: onChange ?? formikOnChange,
2772
2784
  value,
2773
- error: errorMessage,
2774
- ...props
2785
+ error: errorMessage
2775
2786
  }
2776
2787
  );
2777
2788
  };
@@ -2954,8 +2965,7 @@ var TextareaInputInset = (0, import_react36.forwardRef)(
2954
2965
  requiredIndicator = " *",
2955
2966
  resize = "vertical",
2956
2967
  rows = 5,
2957
- size = "md",
2958
- type = "text"
2968
+ size = "md"
2959
2969
  }, ref) => {
2960
2970
  const responsiveClasses = generateResponsiveClasses("size", size);
2961
2971
  const inputWrapperClasses = (0, import_classnames22.default)(
@@ -2988,7 +2998,6 @@ var TextareaInputInset = (0, import_react36.forwardRef)(
2988
2998
  placeholder,
2989
2999
  required: isRequired,
2990
3000
  rows,
2991
- type,
2992
3001
  value
2993
3002
  };
2994
3003
  return /* @__PURE__ */ import_react36.default.createElement(Box, { width: "100", ref, className }, /* @__PURE__ */ import_react36.default.createElement(
@@ -3208,6 +3217,7 @@ var SelectInputNative = ({
3208
3217
  helpText,
3209
3218
  error,
3210
3219
  id,
3220
+ inputProps = {},
3211
3221
  isDisabled,
3212
3222
  isRequired,
3213
3223
  name,
@@ -3219,6 +3229,15 @@ var SelectInputNative = ({
3219
3229
  size = "md",
3220
3230
  ...restProps
3221
3231
  }) => {
3232
+ const isBoxProp = (key) => boxPropsKeys.includes(key);
3233
+ const formControlProps = Object.fromEntries(
3234
+ Object.entries(restProps).filter(([key]) => isBoxProp(key))
3235
+ );
3236
+ const selectProps = Object.fromEntries(
3237
+ Object.entries(restProps).filter(([key]) => !isBoxProp(key))
3238
+ );
3239
+ const selectIsDisabled = isDisabled || selectProps.disabled;
3240
+ const selectIsRequired = isRequired || selectProps.required;
3222
3241
  const placeholderOption = {
3223
3242
  value: "",
3224
3243
  label: placeholder,
@@ -3234,7 +3253,7 @@ var SelectInputNative = ({
3234
3253
  SelectInputNative_module_default["select-input-native-wrapper"],
3235
3254
  ...responsiveClasses.map((className) => SelectInputNative_module_default[className]),
3236
3255
  {
3237
- [SelectInputNative_module_default.disabled]: isDisabled,
3256
+ [SelectInputNative_module_default.disabled]: selectIsDisabled,
3238
3257
  [SelectInputNative_module_default.error]: error
3239
3258
  }
3240
3259
  );
@@ -3246,26 +3265,28 @@ var SelectInputNative = ({
3246
3265
  id,
3247
3266
  error,
3248
3267
  helpText,
3249
- isDisabled,
3250
- isRequired,
3268
+ isDisabled: selectIsDisabled,
3269
+ isRequired: selectIsRequired,
3251
3270
  requiredIndicator,
3252
- ...restProps
3271
+ ...formControlProps
3253
3272
  },
3254
3273
  /* @__PURE__ */ import_react40.default.createElement(Box, { className: selectWrapperClasses }, /* @__PURE__ */ import_react40.default.createElement(
3255
3274
  Box,
3256
3275
  {
3257
3276
  as: "select",
3277
+ ...inputProps,
3278
+ ...selectProps,
3258
3279
  "aria-label": label,
3259
3280
  "aria-labelledby": label && !hideLabel ? `${id}Label` : void 0,
3260
- "aria-required": isRequired,
3281
+ "aria-required": selectIsRequired,
3261
3282
  value: value ?? "",
3262
3283
  onChange,
3263
3284
  color: !value ? "disabled" : "base",
3264
3285
  autoFocus,
3265
- disabled: isDisabled,
3286
+ disabled: selectIsDisabled,
3266
3287
  name,
3267
3288
  id,
3268
- required: isRequired
3289
+ required: selectIsRequired
3269
3290
  },
3270
3291
  optionsWithPlaceholder.map((option) => /* @__PURE__ */ import_react40.default.createElement(
3271
3292
  Box,
@@ -3719,7 +3740,7 @@ var Switch = ({
3719
3740
  alignItems: helpText ? "flex-start" : "center",
3720
3741
  isFieldRequired: isRequired,
3721
3742
  requiredIndicator,
3722
- size
3743
+ ...typeof size === "string" && { size }
3723
3744
  };
3724
3745
  return /* @__PURE__ */ import_react48.default.createElement(Box, { className }, /* @__PURE__ */ import_react48.default.createElement(Box, { className: wrapperClasses }, /* @__PURE__ */ import_react48.default.createElement(FormLabel, { ...labelProps }, /* @__PURE__ */ import_react48.default.createElement("input", { ...inputProps }), /* @__PURE__ */ import_react48.default.createElement(
3725
3746
  "span",
@@ -4053,14 +4074,14 @@ var ModalBaseComponent = (0, import_react56.forwardRef)(
4053
4074
  /* @__PURE__ */ import_react56.default.createElement(import_react_remove_scroll2.RemoveScroll, { allowPinchZoom, enabled: isOpen }, /* @__PURE__ */ import_react56.default.createElement(Box, { ref }, /* @__PURE__ */ import_react56.default.createElement(
4054
4075
  import_react_modal2.default,
4055
4076
  {
4077
+ ...restProps,
4056
4078
  isOpen,
4057
4079
  overlayClassName: overlayClassnames,
4058
4080
  className: contentClassnames,
4059
4081
  onRequestClose: onDismiss,
4060
4082
  ariaHideApp: false,
4061
4083
  parentSelector: parentElement ? () => parentElement : void 0,
4062
- style: { content: { ...maxWidthCss.styles, ...style } },
4063
- ...restProps
4084
+ style: { content: { ...maxWidthCss.styles, ...style } }
4064
4085
  },
4065
4086
  /* @__PURE__ */ import_react56.default.createElement(
4066
4087
  Box,
@@ -5268,17 +5289,28 @@ var TableRow = ({
5268
5289
  { [TableRow_module_default.hoverable]: isHoverable },
5269
5290
  className
5270
5291
  );
5292
+ const isRenderableCell = (value) => {
5293
+ if (value === null || value === void 0) return true;
5294
+ const valueType = typeof value;
5295
+ if (valueType === "string" || valueType === "number" || valueType === "boolean") {
5296
+ return true;
5297
+ }
5298
+ if (Array.isArray(value)) return value.every(isRenderableCell);
5299
+ return import_react65.default.isValidElement(value);
5300
+ };
5271
5301
  const renderCellContent = (column) => {
5272
5302
  if (column.render) {
5273
- const cellValue = column.dataKey && row ? row[column.dataKey] : void 0;
5274
- return column.render(cellValue, row, rowIndex);
5303
+ const cellValue2 = column.dataKey && row ? row[column.dataKey] : void 0;
5304
+ return column.render(cellValue2, row, rowIndex);
5275
5305
  }
5276
- return column.dataKey && row ? row[column.dataKey] : null;
5306
+ const cellValue = column.dataKey && row ? row[column.dataKey] : null;
5307
+ return isRenderableCell(cellValue) ? cellValue : null;
5277
5308
  };
5278
5309
  const getCellClassName = (column) => {
5279
5310
  if (column.cellClassName) {
5280
5311
  if (typeof column.cellClassName === "function") {
5281
- return column.cellClassName(column, row, rowIndex);
5312
+ const cellValue = column.dataKey && row ? row[column.dataKey] : void 0;
5313
+ return column.cellClassName(cellValue, row, rowIndex);
5282
5314
  }
5283
5315
  return column.cellClassName;
5284
5316
  }
@@ -5325,6 +5357,7 @@ var TableRow = ({
5325
5357
  var TableBody = ({
5326
5358
  columns,
5327
5359
  rows,
5360
+ rowKey,
5328
5361
  align = "left",
5329
5362
  className = "",
5330
5363
  emptyCellPlaceholder = "",
@@ -5342,6 +5375,13 @@ var TableBody = ({
5342
5375
  },
5343
5376
  className
5344
5377
  );
5378
+ const getRowKey = (row, rowIndex) => {
5379
+ const keyValue = row?.[rowKey];
5380
+ if (typeof keyValue === "string" || typeof keyValue === "number" || typeof keyValue === "bigint") {
5381
+ return `row-key-${String(keyValue)}`;
5382
+ }
5383
+ return `row-index-${rowIndex}`;
5384
+ };
5345
5385
  return /* @__PURE__ */ import_react66.default.createElement("tbody", { className: tableBodyClasses }, rows.map((row, rowIndex) => /* @__PURE__ */ import_react66.default.createElement(
5346
5386
  TableRow,
5347
5387
  {
@@ -5349,7 +5389,7 @@ var TableBody = ({
5349
5389
  row,
5350
5390
  rowIndex,
5351
5391
  align,
5352
- key: rowIndex,
5392
+ key: getRowKey(row, rowIndex),
5353
5393
  emptyCellPlaceholder,
5354
5394
  truncateOverflow,
5355
5395
  isBorderless,