@hitachivantara/uikit-react-core 5.57.0 → 5.58.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 (134) hide show
  1. package/dist/cjs/Button/Button.cjs +11 -0
  2. package/dist/cjs/Button/Button.cjs.map +1 -1
  3. package/dist/cjs/Button/Button.styles.cjs +79 -54
  4. package/dist/cjs/Button/Button.styles.cjs.map +1 -1
  5. package/dist/cjs/Button/types.cjs +9 -0
  6. package/dist/cjs/Button/types.cjs.map +1 -1
  7. package/dist/cjs/Calendar/model.cjs +23 -14
  8. package/dist/cjs/Calendar/model.cjs.map +1 -1
  9. package/dist/cjs/Calendar/utils.cjs +2 -3
  10. package/dist/cjs/Calendar/utils.cjs.map +1 -1
  11. package/dist/cjs/Carousel/Carousel.cjs +2 -2
  12. package/dist/cjs/Carousel/Carousel.cjs.map +1 -1
  13. package/dist/cjs/DotPagination/DotPagination.cjs +2 -2
  14. package/dist/cjs/DotPagination/DotPagination.cjs.map +1 -1
  15. package/dist/cjs/FileUploader/DropZone/DropZone.cjs +2 -4
  16. package/dist/cjs/FileUploader/DropZone/DropZone.cjs.map +1 -1
  17. package/dist/cjs/FilterGroup/FilterGroupContext.cjs +2 -4
  18. package/dist/cjs/FilterGroup/FilterGroupContext.cjs.map +1 -1
  19. package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs +1 -4
  20. package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs.map +1 -1
  21. package/dist/cjs/Grid/Grid.cjs +1 -3
  22. package/dist/cjs/Grid/Grid.cjs.map +1 -1
  23. package/dist/cjs/Loading/Loading.cjs +2 -4
  24. package/dist/cjs/Loading/Loading.cjs.map +1 -1
  25. package/dist/cjs/MultiButton/MultiButton.cjs +2 -1
  26. package/dist/cjs/MultiButton/MultiButton.cjs.map +1 -1
  27. package/dist/cjs/MultiButton/MultiButton.styles.cjs +3 -2
  28. package/dist/cjs/MultiButton/MultiButton.styles.cjs.map +1 -1
  29. package/dist/cjs/ProgressBar/ProgressBar.cjs +2 -4
  30. package/dist/cjs/ProgressBar/ProgressBar.cjs.map +1 -1
  31. package/dist/cjs/QueryBuilder/QueryBuilder.cjs +4 -8
  32. package/dist/cjs/QueryBuilder/QueryBuilder.cjs.map +1 -1
  33. package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +2 -3
  34. package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs.map +1 -1
  35. package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +4 -7
  36. package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs.map +1 -1
  37. package/dist/cjs/Snackbar/Snackbar.cjs +2 -3
  38. package/dist/cjs/Snackbar/Snackbar.cjs.map +1 -1
  39. package/dist/cjs/Stack/Stack.cjs +2 -6
  40. package/dist/cjs/Stack/Stack.cjs.map +1 -1
  41. package/dist/cjs/Table/TableCell/TableCell.cjs +3 -5
  42. package/dist/cjs/Table/TableCell/TableCell.cjs.map +1 -1
  43. package/dist/cjs/Table/TableHeader/TableHeader.cjs +4 -6
  44. package/dist/cjs/Table/TableHeader/TableHeader.cjs.map +1 -1
  45. package/dist/cjs/TreeView/internals/utils/EventManager.cjs +3 -5
  46. package/dist/cjs/TreeView/internals/utils/EventManager.cjs.map +1 -1
  47. package/dist/cjs/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.cjs +5 -7
  48. package/dist/cjs/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.cjs.map +1 -1
  49. package/dist/cjs/TreeView/internals/utils/TimerBasedCleanupTracking.cjs +2 -2
  50. package/dist/cjs/TreeView/internals/utils/TimerBasedCleanupTracking.cjs.map +1 -1
  51. package/dist/cjs/Typography/Typography.cjs +1 -0
  52. package/dist/cjs/Typography/Typography.cjs.map +1 -1
  53. package/dist/cjs/Typography/Typography.styles.cjs +1 -0
  54. package/dist/cjs/Typography/Typography.styles.cjs.map +1 -1
  55. package/dist/cjs/Typography/utils.cjs +1 -0
  56. package/dist/cjs/Typography/utils.cjs.map +1 -1
  57. package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs +3 -5
  58. package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs.map +1 -1
  59. package/dist/cjs/utils/Random.cjs +3 -0
  60. package/dist/cjs/utils/Random.cjs.map +1 -1
  61. package/dist/cjs/utils/classes.cjs +1 -1
  62. package/dist/cjs/utils/classes.cjs.map +1 -1
  63. package/dist/cjs/utils/helpers.cjs +33 -0
  64. package/dist/cjs/utils/helpers.cjs.map +1 -0
  65. package/dist/cjs/utils/setId.cjs +2 -4
  66. package/dist/cjs/utils/setId.cjs.map +1 -1
  67. package/dist/esm/Button/Button.js +12 -1
  68. package/dist/esm/Button/Button.js.map +1 -1
  69. package/dist/esm/Button/Button.styles.js +79 -54
  70. package/dist/esm/Button/Button.styles.js.map +1 -1
  71. package/dist/esm/Button/types.js +9 -0
  72. package/dist/esm/Button/types.js.map +1 -1
  73. package/dist/esm/Calendar/model.js +23 -14
  74. package/dist/esm/Calendar/model.js.map +1 -1
  75. package/dist/esm/Calendar/utils.js +1 -1
  76. package/dist/esm/Calendar/utils.js.map +1 -1
  77. package/dist/esm/Carousel/Carousel.js +2 -2
  78. package/dist/esm/Carousel/Carousel.js.map +1 -1
  79. package/dist/esm/DotPagination/DotPagination.js +1 -1
  80. package/dist/esm/DotPagination/DotPagination.js.map +1 -1
  81. package/dist/esm/FileUploader/DropZone/DropZone.js +1 -1
  82. package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
  83. package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
  84. package/dist/esm/FilterGroup/FilterGroupContext.js.map +1 -1
  85. package/dist/esm/FilterGroup/RightPanel/RightPanel.js +1 -2
  86. package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
  87. package/dist/esm/Grid/Grid.js +1 -2
  88. package/dist/esm/Grid/Grid.js.map +1 -1
  89. package/dist/esm/Loading/Loading.js +2 -2
  90. package/dist/esm/Loading/Loading.js.map +1 -1
  91. package/dist/esm/MultiButton/MultiButton.js +2 -1
  92. package/dist/esm/MultiButton/MultiButton.js.map +1 -1
  93. package/dist/esm/MultiButton/MultiButton.styles.js +3 -2
  94. package/dist/esm/MultiButton/MultiButton.styles.js.map +1 -1
  95. package/dist/esm/ProgressBar/ProgressBar.js +2 -2
  96. package/dist/esm/ProgressBar/ProgressBar.js.map +1 -1
  97. package/dist/esm/QueryBuilder/QueryBuilder.js +3 -4
  98. package/dist/esm/QueryBuilder/QueryBuilder.js.map +1 -1
  99. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +1 -1
  100. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
  101. package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +3 -4
  102. package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
  103. package/dist/esm/Snackbar/Snackbar.js +1 -1
  104. package/dist/esm/Snackbar/Snackbar.js.map +1 -1
  105. package/dist/esm/Stack/Stack.js +2 -4
  106. package/dist/esm/Stack/Stack.js.map +1 -1
  107. package/dist/esm/Table/TableCell/TableCell.js +1 -1
  108. package/dist/esm/Table/TableCell/TableCell.js.map +1 -1
  109. package/dist/esm/Table/TableHeader/TableHeader.js +1 -1
  110. package/dist/esm/Table/TableHeader/TableHeader.js.map +1 -1
  111. package/dist/esm/TreeView/internals/utils/EventManager.js +3 -5
  112. package/dist/esm/TreeView/internals/utils/EventManager.js.map +1 -1
  113. package/dist/esm/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js +5 -7
  114. package/dist/esm/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js.map +1 -1
  115. package/dist/esm/TreeView/internals/utils/TimerBasedCleanupTracking.js +2 -2
  116. package/dist/esm/TreeView/internals/utils/TimerBasedCleanupTracking.js.map +1 -1
  117. package/dist/esm/Typography/Typography.js +1 -0
  118. package/dist/esm/Typography/Typography.js.map +1 -1
  119. package/dist/esm/Typography/Typography.styles.js +1 -0
  120. package/dist/esm/Typography/Typography.styles.js.map +1 -1
  121. package/dist/esm/Typography/utils.js +1 -0
  122. package/dist/esm/Typography/utils.js.map +1 -1
  123. package/dist/esm/VerticalNavigation/Navigation/Navigation.js +1 -1
  124. package/dist/esm/VerticalNavigation/Navigation/Navigation.js.map +1 -1
  125. package/dist/esm/utils/Random.js +3 -0
  126. package/dist/esm/utils/Random.js.map +1 -1
  127. package/dist/esm/utils/classes.js +1 -1
  128. package/dist/esm/utils/classes.js.map +1 -1
  129. package/dist/esm/utils/helpers.js +33 -0
  130. package/dist/esm/utils/helpers.js.map +1 -0
  131. package/dist/esm/utils/setId.js +1 -1
  132. package/dist/esm/utils/setId.js.map +1 -1
  133. package/dist/types/index.d.ts +22 -14
  134. package/package.json +5 -6
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("@emotion/react/jsx-runtime");
4
+ const React = require("react");
4
5
  const useTheme = require("../hooks/useTheme.cjs");
5
6
  const useDefaultProps = require("../hooks/useDefaultProps.cjs");
6
7
  const generic = require("../types/generic.cjs");
@@ -20,6 +21,7 @@ const HvButton = generic.fixedForwardRef(function HvButton2(props, ref) {
20
21
  classes: classesProp,
21
22
  children,
22
23
  variant: variantProp,
24
+ // TODO - should we split into two props (color and type) in v6?
23
25
  disabled = false,
24
26
  className,
25
27
  startIcon,
@@ -51,13 +53,22 @@ const HvButton = generic.fixedForwardRef(function HvButton2(props, ref) {
51
53
  return;
52
54
  onMouseDownProp?.(e);
53
55
  };
56
+ const [color, type] = React.useMemo(() => {
57
+ const result = variant.split(/(?=[A-Z])/);
58
+ if (result[0] === "ghost" || result[0] === "semantic" || result[0] === "secondary" && !result[1])
59
+ return [];
60
+ return result.map((x) => x.toLowerCase());
61
+ }, [variant]);
54
62
  return /* @__PURE__ */ jsxRuntime.jsxs(
55
63
  Component,
56
64
  {
57
65
  ref,
58
66
  className: cx(
59
67
  classes.root,
68
+ type && classes[type],
69
+ color && css(Button_styles.getColoringStyle(color, type)),
60
70
  classes[variant],
71
+ // Placed after type and color CSS for DS3 override
61
72
  size && !icon && css(Button_styles.getSizeStyles(size)),
62
73
  radius && css(Button_styles.getRadiusStyles(radius)),
63
74
  overrideIconColors && css(Button_styles.getOverrideColors()),
@@ -1 +1 @@
1
- {"version":3,"file":"Button.cjs","sources":["../../../src/Button/Button.tsx"],"sourcesContent":["import { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport {\n staticClasses as buttonClasses,\n getOverrideColors,\n getRadiusStyles,\n getSizeStyles,\n getIconSizeStyles,\n useClasses,\n} from \"./Button.styles\";\nimport { HvButtonRadius, HvButtonSize, HvButtonVariant } from \"./types\";\n\nexport { buttonClasses };\n\nexport type HvButtonClasses = ExtractNames<typeof useClasses>;\n\nexport type HvButtonProps<C extends React.ElementType = \"button\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the button. */\n variant?: HvButtonVariant;\n /** Whether the button is an icon-only button. */\n icon?: boolean;\n /** Whether the button is disabled or not. */\n disabled?: boolean;\n /** Class names to be applied. */\n className?: string;\n /** Element placed before the children. */\n startIcon?: React.ReactNode;\n /** Element placed after the children. */\n endIcon?: React.ReactNode;\n /** Button size. */\n size?: HvButtonSize;\n /** Button border radius. */\n radius?: HvButtonRadius;\n /** Defines the default colors of the button are forced into the icon. */\n overrideIconColors?: boolean;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvButtonClasses;\n /** Whether the button is selected or not. */\n selected?: boolean;\n /**\n * Whether the button is focusable when disabled.\n * Without this property, the accessibility of the button decreases when disabled since it's not read by screen readers.\n * Set this property to `true` when you need the button to still be focusable when disabled for accessibility purposes.\n */\n focusableWhenDisabled?: boolean;\n }\n >;\n\n/**\n * Normalize the button variant. It's meant to give us some retro-compatibility with\n * the DS 3.6 API.\n * @returns the normalized variant in DS 5 API\n */\nconst mapVariant = (\n variant: HvButtonVariant,\n theme?: string\n): HvButtonVariant => {\n if (theme === \"ds3\") return variant;\n\n const deprecatedVariantMap: Record<string, HvButtonVariant> = {\n secondary: \"secondarySubtle\",\n ghost: \"primaryGhost\",\n };\n\n const mappedVariant = deprecatedVariantMap[variant];\n\n if (import.meta.env.DEV && mappedVariant) {\n // eslint-disable-next-line no-console\n console.warn(\n `Button variant '${variant}' is deprecated. Please use '${mappedVariant}'.`\n );\n }\n\n return mappedVariant || variant;\n};\n\n/**\n * Button component is used to trigger an action or event.\n */\nexport const HvButton = fixedForwardRef(function HvButton<\n C extends React.ElementType = \"button\"\n>(props: HvButtonProps<C>, ref: PolymorphicRef<C>) {\n const {\n classes: classesProp,\n children,\n variant: variantProp,\n disabled = false,\n className,\n startIcon,\n endIcon,\n icon = false,\n size,\n radius,\n overrideIconColors = true,\n component: Component = \"button\",\n focusableWhenDisabled,\n onClick: onClickProp,\n onMouseDown: onMouseDownProp,\n selected,\n ...others\n } = useDefaultProps(\"HvButton\", props);\n const { classes, css, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n const variant = mapVariant(\n variantProp ?? (icon ? \"secondaryGhost\" : \"primary\"),\n activeTheme?.name\n );\n\n const handleClick: HvButtonProps[\"onClick\"] = (e) => {\n if (disabled) return;\n onClickProp?.(e);\n };\n\n const handleMouseDown: HvButtonProps[\"onMouseDown\"] = (e) => {\n if (disabled) return;\n onMouseDownProp?.(e);\n };\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n size && !icon && css(getSizeStyles(size)),\n radius && css(getRadiusStyles(radius)),\n overrideIconColors && css(getOverrideColors()),\n {\n [classes.icon]: icon,\n [classes.disabled]: disabled,\n },\n size && icon && css(getIconSizeStyles(size)),\n className\n )}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n {...(Component === \"button\" && { type: \"button\" })}\n {...(disabled && {\n disabled: !focusableWhenDisabled,\n tabIndex: focusableWhenDisabled ? 0 : -1,\n \"aria-disabled\": true,\n })}\n {...(selected && { \"aria-pressed\": selected })}\n {...others}\n >\n {startIcon && <span className={classes.startIcon}>{startIcon}</span>}\n {children}\n {endIcon && <span className={classes.endIcon}>{endIcon}</span>}\n </Component>\n );\n});\n"],"names":["fixedForwardRef","HvButton","useDefaultProps","useClasses","useTheme","jsxs","getSizeStyles","getRadiusStyles","getOverrideColors","getIconSizeStyles"],"mappings":";;;;;;;AA+DA,MAAM,aAAa,CACjB,SACA,UACoB;AACpB,MAAI,UAAU;AAAc,WAAA;AAE5B,QAAM,uBAAwD;AAAA,IAC5D,WAAW;AAAA,IACX,OAAO;AAAA,EAAA;AAGH,QAAA,gBAAgB,qBAAqB,OAAO;AASlD,SAAO,iBAAiB;AAC1B;AAKO,MAAM,WAAWA,QAAAA,gBAAgB,SAASC,UAE/C,OAAyB,KAAwB;AAC3C,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB,WAAW,YAAY;AAAA,IACvB;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,IACb;AAAA,IACA,GAAG;AAAA,EAAA,IACDC,gBAAgB,gBAAA,YAAY,KAAK;AACrC,QAAM,EAAE,SAAS,KAAK,GAAG,IAAIC,cAAAA,WAAW,WAAW;AAC7C,QAAA,EAAE,gBAAgBC,SAAAA;AACxB,QAAM,UAAU;AAAA,IACd,gBAAgB,OAAO,mBAAmB;AAAA,IAC1C,aAAa;AAAA,EAAA;AAGT,QAAA,cAAwC,CAAC,MAAM;AAC/C,QAAA;AAAU;AACd,kBAAc,CAAC;AAAA,EAAA;AAGX,QAAA,kBAAgD,CAAC,MAAM;AACvD,QAAA;AAAU;AACd,sBAAkB,CAAC;AAAA,EAAA;AAInB,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ,OAAO;AAAA,QACf,QAAQ,CAAC,QAAQ,IAAIC,cAAA,cAAc,IAAI,CAAC;AAAA,QACxC,UAAU,IAAIC,8BAAgB,MAAM,CAAC;AAAA,QACrC,sBAAsB,IAAIC,cAAAA,mBAAmB;AAAA,QAC7C;AAAA,UACE,CAAC,QAAQ,IAAI,GAAG;AAAA,UAChB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA,QAAQ,QAAQ,IAAIC,cAAA,kBAAkB,IAAI,CAAC;AAAA,QAC3C;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MACT,aAAa;AAAA,MACZ,GAAI,cAAc,YAAY,EAAE,MAAM,SAAS;AAAA,MAC/C,GAAI,YAAY;AAAA,QACf,UAAU,CAAC;AAAA,QACX,UAAU,wBAAwB,IAAI;AAAA,QACtC,iBAAiB;AAAA,MACnB;AAAA,MACC,GAAI,YAAY,EAAE,gBAAgB,SAAS;AAAA,MAC3C,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA,4CAAc,QAAA,EAAK,WAAW,QAAQ,WAAY,UAAU,WAAA;AAAA,QAC5D;AAAA,QACA,0CAAY,QAAA,EAAK,WAAW,QAAQ,SAAU,UAAQ,SAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG7D,CAAC;;;"}
1
+ {"version":3,"file":"Button.cjs","sources":["../../../src/Button/Button.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport {\n staticClasses as buttonClasses,\n getOverrideColors,\n getRadiusStyles,\n getSizeStyles,\n getIconSizeStyles,\n useClasses,\n getColoringStyle,\n} from \"./Button.styles\";\nimport { HvButtonRadius, HvButtonSize, HvButtonVariant } from \"./types\";\n\nexport { buttonClasses };\n\nexport type HvButtonClasses = ExtractNames<typeof useClasses>;\n\nexport type HvButtonProps<C extends React.ElementType = \"button\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the button. */\n variant?: HvButtonVariant;\n /** Whether the button is an icon-only button. */\n icon?: boolean;\n /** Whether the button is disabled or not. */\n disabled?: boolean;\n /** Class names to be applied. */\n className?: string;\n /** Element placed before the children. */\n startIcon?: React.ReactNode;\n /** Element placed after the children. */\n endIcon?: React.ReactNode;\n /** Button size. */\n size?: HvButtonSize;\n /** Button border radius. */\n radius?: HvButtonRadius;\n /** Defines the default colors of the button are forced into the icon. */\n overrideIconColors?: boolean;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvButtonClasses;\n /** Whether the button is selected or not. */\n selected?: boolean;\n /**\n * Whether the button is focusable when disabled.\n * Without this property, the accessibility of the button decreases when disabled since it's not read by screen readers.\n * Set this property to `true` when you need the button to still be focusable when disabled for accessibility purposes.\n */\n focusableWhenDisabled?: boolean;\n }\n >;\n\n/**\n * Normalize the button variant. It's meant to give us some retro-compatibility with\n * the DS 3.6 API.\n * @returns the normalized variant in DS 5 API\n */\nconst mapVariant = (\n variant: HvButtonVariant,\n theme?: string\n): HvButtonVariant => {\n if (theme === \"ds3\") return variant;\n\n const deprecatedVariantMap: Record<string, HvButtonVariant> = {\n secondary: \"secondarySubtle\",\n ghost: \"primaryGhost\",\n };\n\n const mappedVariant = deprecatedVariantMap[variant];\n\n if (import.meta.env.DEV && mappedVariant) {\n // eslint-disable-next-line no-console\n console.warn(\n `Button variant '${variant}' is deprecated. Please use '${mappedVariant}'.`\n );\n }\n\n return mappedVariant || variant;\n};\n\n/**\n * Button component is used to trigger an action or event.\n */\nexport const HvButton = fixedForwardRef(function HvButton<\n C extends React.ElementType = \"button\"\n>(props: HvButtonProps<C>, ref: PolymorphicRef<C>) {\n const {\n classes: classesProp,\n children,\n variant: variantProp, // TODO - should we split into two props (color and type) in v6?\n disabled = false,\n className,\n startIcon,\n endIcon,\n icon = false,\n size,\n radius,\n overrideIconColors = true,\n component: Component = \"button\",\n focusableWhenDisabled,\n onClick: onClickProp,\n onMouseDown: onMouseDownProp,\n selected,\n ...others\n } = useDefaultProps(\"HvButton\", props);\n const { classes, css, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n const variant = mapVariant(\n variantProp ?? (icon ? \"secondaryGhost\" : \"primary\"),\n activeTheme?.name\n );\n\n const handleClick: HvButtonProps[\"onClick\"] = (e) => {\n if (disabled) return;\n onClickProp?.(e);\n };\n\n const handleMouseDown: HvButtonProps[\"onMouseDown\"] = (e) => {\n if (disabled) return;\n onMouseDownProp?.(e);\n };\n\n const [color, type] = useMemo(() => {\n const result = variant.split(/(?=[A-Z])/);\n if (\n result[0] === \"ghost\" ||\n result[0] === \"semantic\" ||\n (result[0] === \"secondary\" && !result[1])\n )\n return [];\n return result.map((x) => x.toLowerCase());\n }, [variant]);\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n type && classes[type],\n color && css(getColoringStyle(color, type)),\n classes[variant], // Placed after type and color CSS for DS3 override\n size && !icon && css(getSizeStyles(size)),\n radius && css(getRadiusStyles(radius)),\n overrideIconColors && css(getOverrideColors()),\n {\n [classes.icon]: icon,\n [classes.disabled]: disabled,\n },\n size && icon && css(getIconSizeStyles(size)),\n className\n )}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n {...(Component === \"button\" && { type: \"button\" })}\n {...(disabled && {\n disabled: !focusableWhenDisabled,\n tabIndex: focusableWhenDisabled ? 0 : -1,\n \"aria-disabled\": true,\n })}\n {...(selected && { \"aria-pressed\": selected })}\n {...others}\n >\n {startIcon && <span className={classes.startIcon}>{startIcon}</span>}\n {children}\n {endIcon && <span className={classes.endIcon}>{endIcon}</span>}\n </Component>\n );\n});\n"],"names":["fixedForwardRef","HvButton","useDefaultProps","useClasses","useTheme","useMemo","jsxs","getColoringStyle","getSizeStyles","getRadiusStyles","getOverrideColors","getIconSizeStyles"],"mappings":";;;;;;;;AAiEA,MAAM,aAAa,CACjB,SACA,UACoB;AACpB,MAAI,UAAU;AAAc,WAAA;AAE5B,QAAM,uBAAwD;AAAA,IAC5D,WAAW;AAAA,IACX,OAAO;AAAA,EAAA;AAGH,QAAA,gBAAgB,qBAAqB,OAAO;AASlD,SAAO,iBAAiB;AAC1B;AAKO,MAAM,WAAWA,QAAAA,gBAAgB,SAASC,UAE/C,OAAyB,KAAwB;AAC3C,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB,WAAW,YAAY;AAAA,IACvB;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,IACb;AAAA,IACA,GAAG;AAAA,EAAA,IACDC,gBAAgB,gBAAA,YAAY,KAAK;AACrC,QAAM,EAAE,SAAS,KAAK,GAAG,IAAIC,cAAAA,WAAW,WAAW;AAC7C,QAAA,EAAE,gBAAgBC,SAAAA;AACxB,QAAM,UAAU;AAAA,IACd,gBAAgB,OAAO,mBAAmB;AAAA,IAC1C,aAAa;AAAA,EAAA;AAGT,QAAA,cAAwC,CAAC,MAAM;AAC/C,QAAA;AAAU;AACd,kBAAc,CAAC;AAAA,EAAA;AAGX,QAAA,kBAAgD,CAAC,MAAM;AACvD,QAAA;AAAU;AACd,sBAAkB,CAAC;AAAA,EAAA;AAGrB,QAAM,CAAC,OAAO,IAAI,IAAIC,cAAQ,MAAM;AAC5B,UAAA,SAAS,QAAQ,MAAM,WAAW;AAC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Classes, useClasses } = classes.createClasses("HvButton", {
10
10
  justifyContent: "center",
11
11
  textTransform: "none",
12
12
  cursor: "pointer",
13
- minWidth: "70px",
14
13
  whiteSpace: "nowrap",
15
- "&:hover:not($disabled)": {
14
+ // Background color common for almost all variants
15
+ "&:hover": {
16
16
  backgroundColor: uikitStyles.theme.colors.containerBackgroundHover
17
17
  },
18
18
  "&:focus-visible": {
19
19
  ...focusUtils.outlineStyles,
20
- "&:not($disabled)": {
21
- backgroundColor: uikitStyles.theme.colors.containerBackgroundHover
22
- }
20
+ backgroundColor: uikitStyles.theme.colors.containerBackgroundHover
23
21
  },
24
22
  // Default button - no size specified
25
23
  fontFamily: uikitStyles.theme.fontFamily.body,
26
- fontSize: uikitStyles.theme.fontSizes.base,
27
- fontWeight: uikitStyles.theme.fontWeights.semibold,
28
- lineHeight: "11px",
29
- letterSpacing: 0,
24
+ ...uikitStyles.theme.typography.label,
30
25
  height: "32px",
26
+ border: "1px solid currentcolor",
31
27
  borderRadius: uikitStyles.theme.radii.base,
32
- padding: uikitStyles.theme.spacing("xs", "sm")
28
+ padding: uikitStyles.theme.spacing(0, "sm")
33
29
  },
34
30
  startIcon: {
35
31
  marginLeft: `calc(-1 * ${uikitStyles.theme.space.xs})`
@@ -39,84 +35,113 @@ const { staticClasses, useClasses } = classes.createClasses("HvButton", {
39
35
  },
40
36
  focusVisible: {},
41
37
  disabled: {
38
+ cursor: "not-allowed",
42
39
  color: uikitStyles.theme.colors.secondary_60,
43
- borderColor: uikitStyles.theme.colors.atmo4,
40
+ borderColor: uikitStyles.theme.colors.atmo3,
44
41
  backgroundColor: uikitStyles.theme.colors.atmo3,
45
- cursor: "not-allowed"
42
+ "&:hover, &:focus-visible": {
43
+ backgroundColor: uikitStyles.theme.colors.atmo3,
44
+ borderColor: uikitStyles.theme.colors.atmo3
45
+ }
46
46
  },
47
47
  icon: {
48
48
  margin: 0,
49
49
  padding: 0,
50
50
  height: "fit-content",
51
- minWidth: "unset"
52
- },
53
- primary: {
54
- color: uikitStyles.theme.colors.atmo1,
55
- backgroundColor: uikitStyles.theme.colors.primary,
56
- "&:not($disabled)": {
57
- "&:hover, &:focus-visible": {
58
- backgroundColor: uikitStyles.theme.colors.primary_80
59
- }
51
+ "& > *": {
52
+ margin: -1
60
53
  }
61
54
  },
62
- primarySubtle: {
63
- color: uikitStyles.theme.colors.primary,
64
- backgroundColor: "transparent",
65
- border: "1px solid currentColor"
66
- },
67
- primaryGhost: {
68
- color: uikitStyles.theme.colors.primary,
55
+ subtle: {
69
56
  backgroundColor: "transparent",
70
57
  "&$disabled": {
71
- backgroundColor: "transparent"
58
+ backgroundColor: "transparent",
59
+ "&:hover, &:focus-visible": {
60
+ backgroundColor: "transparent"
61
+ }
72
62
  }
73
63
  },
74
- secondarySubtle: {
75
- color: uikitStyles.theme.colors.secondary,
76
- backgroundColor: "transparent",
77
- border: "1px solid currentColor"
78
- },
79
- secondaryGhost: {
80
- color: uikitStyles.theme.colors.secondary,
64
+ ghost: {
65
+ borderColor: "transparent",
81
66
  backgroundColor: "transparent",
82
67
  "&$disabled": {
83
- backgroundColor: "transparent"
68
+ borderColor: "transparent",
69
+ backgroundColor: "transparent",
70
+ "&:hover, &:focus-visible": {
71
+ borderColor: "transparent",
72
+ backgroundColor: "transparent"
73
+ }
84
74
  }
85
75
  },
86
76
  semantic: {
87
77
  color: uikitStyles.theme.colors.base_dark,
88
78
  backgroundColor: "transparent",
89
- "&:not($disabled)": {
90
- "&:hover, &:focus-visible": {
91
- backgroundColor: "rgba(251, 252, 252, 0.3)"
92
- }
79
+ borderColor: "transparent",
80
+ "&:hover, &:focus-visible": {
81
+ backgroundColor: "rgba(251, 252, 252, 0.3)"
93
82
  },
94
83
  "&$disabled": {
95
84
  backgroundColor: "rgba(251, 252, 252, 0.1)"
96
85
  }
97
86
  },
98
- secondary: {},
99
- ghost: {}
87
+ // TODO - remove in v6
88
+ primary: {},
89
+ primarySubtle: {},
90
+ primaryGhost: {},
91
+ secondarySubtle: {},
92
+ secondaryGhost: {},
93
+ // Deprecated (DS3)
94
+ secondary: {}
100
95
  });
96
+ const getColoringStyle = (color, type) => {
97
+ if (type)
98
+ return {
99
+ color: uikitStyles.theme.colors[color !== "warning" ? color : `${color}_140`]
100
+ };
101
+ const bg = uikitStyles.theme.colors[color !== "warning" ? color : `${color}_120`];
102
+ const hoverBg = uikitStyles.theme.colors[color !== "warning" ? `${color}_80` : `${color}_140`];
103
+ return {
104
+ color: uikitStyles.theme.colors.atmo1,
105
+ backgroundColor: bg,
106
+ borderColor: bg,
107
+ "&:hover, &:focus-visible": {
108
+ backgroundColor: hoverBg,
109
+ borderColor: hoverBg
110
+ }
111
+ };
112
+ };
101
113
  const getRadiusStyles = (radius) => ({
102
114
  borderRadius: uikitStyles.theme.radii[radius]
103
115
  });
104
- const getSizeStyles = (size) => ({
105
- height: uikitStyles.theme.sizes[size],
106
- paddingLeft: uikitStyles.theme.space[size],
107
- paddingRight: uikitStyles.theme.space[size],
108
- // @ts-ignore TODO: align font<-> button sizes
109
- fontSize: uikitStyles.theme.fontSizes[size]
110
- });
111
- const getIconSizeStyles = (size) => ({
112
- height: uikitStyles.theme.sizes[size],
113
- width: uikitStyles.theme.sizes[size]
114
- });
116
+ const sizes = {
117
+ xs: { height: "24px", space: "sm", typography: "captionLabel" },
118
+ sm: { height: "24px", space: "sm", typography: "captionLabel" },
119
+ md: { height: "32px", space: "sm", typography: "label" },
120
+ lg: { height: "48px", space: "md", typography: "label" },
121
+ xl: { height: "48px", space: "md", typography: "label" }
122
+ };
123
+ const getSizeStyles = (size) => {
124
+ const { height, space, typography } = sizes[size];
125
+ const { color, ...typoProps } = uikitStyles.theme.typography[typography];
126
+ return {
127
+ height,
128
+ padding: uikitStyles.theme.spacing(0, space),
129
+ ...typoProps
130
+ };
131
+ };
132
+ const getIconSizeStyles = (size) => {
133
+ const { height } = sizes[size];
134
+ return {
135
+ height,
136
+ width: height
137
+ };
138
+ };
115
139
  const getOverrideColors = () => ({
116
140
  "& svg .color0": {
117
141
  fill: "currentcolor"
118
142
  }
119
143
  });
144
+ exports.getColoringStyle = getColoringStyle;
120
145
  exports.getIconSizeStyles = getIconSizeStyles;
121
146
  exports.getOverrideColors = getOverrideColors;
122
147
  exports.getRadiusStyles = getRadiusStyles;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.styles.cjs","sources":["../../../src/Button/Button.styles.ts"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\nimport { createClasses } from \"../utils/classes\";\nimport { HvButtonRadius, HvButtonSize } from \"./types\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvButton\", {\n root: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n textTransform: \"none\",\n cursor: \"pointer\",\n minWidth: \"70px\",\n whiteSpace: \"nowrap\",\n\n \"&:hover:not($disabled)\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n\n \"&:focus-visible\": {\n ...outlineStyles,\n\n \"&:not($disabled)\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n },\n\n // Default button - no size specified\n fontFamily: theme.fontFamily.body,\n fontSize: theme.fontSizes.base,\n fontWeight: theme.fontWeights.semibold,\n lineHeight: \"11px\",\n letterSpacing: 0,\n height: \"32px\",\n borderRadius: theme.radii.base,\n padding: theme.spacing(\"xs\", \"sm\"),\n },\n startIcon: {\n marginLeft: `calc(-1 * ${theme.space.xs})`,\n },\n endIcon: {\n marginRight: `calc(-1 * ${theme.space.xs})`,\n },\n focusVisible: {},\n disabled: {\n color: theme.colors.secondary_60,\n borderColor: theme.colors.atmo4,\n backgroundColor: theme.colors.atmo3,\n cursor: \"not-allowed\",\n },\n icon: {\n margin: 0,\n padding: 0,\n height: \"fit-content\",\n minWidth: \"unset\",\n },\n primary: {\n color: theme.colors.atmo1,\n backgroundColor: theme.colors.primary,\n \"&:not($disabled)\": {\n \"&:hover, &:focus-visible\": {\n backgroundColor: theme.colors.primary_80,\n },\n },\n },\n primarySubtle: {\n color: theme.colors.primary,\n backgroundColor: \"transparent\",\n border: \"1px solid currentColor\",\n },\n primaryGhost: {\n color: theme.colors.primary,\n backgroundColor: \"transparent\",\n \"&$disabled\": {\n backgroundColor: \"transparent\",\n },\n },\n secondarySubtle: {\n color: theme.colors.secondary,\n backgroundColor: \"transparent\",\n border: \"1px solid currentColor\",\n },\n secondaryGhost: {\n color: theme.colors.secondary,\n backgroundColor: \"transparent\",\n \"&$disabled\": {\n backgroundColor: \"transparent\",\n },\n },\n semantic: {\n color: theme.colors.base_dark,\n backgroundColor: \"transparent\",\n \"&:not($disabled)\": {\n \"&:hover, &:focus-visible\": {\n backgroundColor: \"rgba(251, 252, 252, 0.3)\",\n },\n },\n \"&$disabled\": {\n backgroundColor: \"rgba(251, 252, 252, 0.1)\",\n },\n },\n secondary: {},\n ghost: {},\n});\n\nexport const getRadiusStyles = (radius: HvButtonRadius): CSSInterpolation => ({\n borderRadius: theme.radii[radius],\n});\n\nexport const getSizeStyles = (size: HvButtonSize): CSSInterpolation => ({\n height: theme.sizes[size],\n paddingLeft: theme.space[size],\n paddingRight: theme.space[size],\n // @ts-ignore TODO: align font<-> button sizes\n fontSize: theme.fontSizes[size],\n});\n\nexport const getIconSizeStyles = (size: HvButtonSize): CSSInterpolation => ({\n height: theme.sizes[size],\n width: theme.sizes[size],\n});\n\nexport const getOverrideColors = (): CSSInterpolation => ({\n \"& svg .color0\": {\n fill: \"currentcolor\",\n },\n});\n"],"names":["createClasses","theme","outlineStyles"],"mappings":";;;;;AAOO,MAAM,EAAE,eAAe,eAAeA,QAAAA,cAAc,YAAY;AAAA,EACrE,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,YAAY;AAAA,IAEZ,0BAA0B;AAAA,MACxB,iBAAiBC,Y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{ CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\nimport { createClasses } from \"../utils/classes\";\nimport { HvButtonRadius, HvButtonSize } from \"./types\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvButton\", {\n root: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n textTransform: \"none\",\n cursor: \"pointer\",\n whiteSpace: \"nowrap\",\n\n // Background color common for almost all variants\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n \"&:focus-visible\": {\n ...outlineStyles,\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n\n // Default button - no size specified\n fontFamily: theme.fontFamily.body,\n ...theme.typography.label,\n height: \"32px\",\n border: \"1px solid currentcolor\",\n borderRadius: theme.radii.base,\n padding: theme.spacing(0, \"sm\"),\n },\n startIcon: {\n marginLeft: `calc(-1 * ${theme.space.xs})`,\n },\n endIcon: {\n marginRight: `calc(-1 * ${theme.space.xs})`,\n },\n focusVisible: {},\n disabled: {\n cursor: \"not-allowed\",\n color: theme.colors.secondary_60,\n borderColor: theme.colors.atmo3,\n backgroundColor: theme.colors.atmo3,\n \"&:hover, &:focus-visible\": {\n backgroundColor: theme.colors.atmo3,\n borderColor: theme.colors.atmo3,\n },\n },\n icon: {\n margin: 0,\n padding: 0,\n height: \"fit-content\",\n \"& > *\": {\n margin: -1,\n },\n },\n subtle: {\n backgroundColor: \"transparent\",\n \"&$disabled\": {\n backgroundColor: \"transparent\",\n \"&:hover, &:focus-visible\": {\n backgroundColor: \"transparent\",\n },\n },\n },\n ghost: {\n borderColor: \"transparent\",\n backgroundColor: \"transparent\",\n \"&$disabled\": {\n borderColor: \"transparent\",\n backgroundColor: \"transparent\",\n \"&:hover, &:focus-visible\": {\n borderColor: \"transparent\",\n backgroundColor: \"transparent\",\n },\n },\n },\n semantic: {\n color: theme.colors.base_dark,\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n \"&:hover, &:focus-visible\": {\n backgroundColor: \"rgba(251, 252, 252, 0.3)\",\n },\n \"&$disabled\": {\n backgroundColor: \"rgba(251, 252, 252, 0.1)\",\n },\n },\n\n // TODO - remove in v6\n primary: {},\n primarySubtle: {},\n primaryGhost: {},\n secondarySubtle: {},\n secondaryGhost: {},\n\n // Deprecated (DS3)\n secondary: {},\n});\n\nexport const getColoringStyle = (color: string, type?: string) => {\n if (type)\n return {\n color: theme.colors[color !== \"warning\" ? color : `${color}_140`],\n };\n\n const bg = theme.colors[color !== \"warning\" ? color : `${color}_120`];\n const hoverBg =\n theme.colors[color !== \"warning\" ? `${color}_80` : `${color}_140`];\n return {\n color: theme.colors.atmo1,\n backgroundColor: bg,\n borderColor: bg,\n \"&:hover, &:focus-visible\": {\n backgroundColor: hoverBg,\n borderColor: hoverBg,\n },\n };\n};\n\nexport const getRadiusStyles = (radius: HvButtonRadius): CSSInterpolation => ({\n borderRadius: theme.radii[radius],\n});\n\n// TODO - remove xs and xl in v6 since they are not DS spec\nconst sizes = {\n xs: { height: \"24px\", space: \"sm\", typography: \"captionLabel\" },\n sm: { height: \"24px\", space: \"sm\", typography: \"captionLabel\" },\n md: { height: \"32px\", space: \"sm\", typography: \"label\" },\n lg: { height: \"48px\", space: \"md\", typography: \"label\" },\n xl: { height: \"48px\", space: \"md\", typography: \"label\" },\n};\n\nexport const getSizeStyles = (size: HvButtonSize): CSSInterpolation => {\n const { height, space, typography } = sizes[size];\n const { color, ...typoProps } = theme.typography[typography];\n return {\n height,\n padding: theme.spacing(0, space),\n ...typoProps,\n };\n};\n\nexport const getIconSizeStyles = (size: HvButtonSize): CSSInterpolation => {\n const { height } = sizes[size];\n return {\n height,\n width: height,\n };\n};\n\nexport const getOverrideColors = (): CSSInterpolation => ({\n \"& svg .color0\": {\n fill: \"currentcolor\",\n },\n});\n"],"names":["createClasses","theme","outlineStyles"],"mappings":";;;;;AAOO,MAAM,EAAE,eAAe,eAAeA,QAAAA,c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EAAE,QAAQ,QAAQ,OAAO,MAAM,YAAY,eAAe;AAAA,EAC9D,IAAI,EAAE,QAAQ,QAAQ,OAAO,MAAM,YAAY,eAAe;AAAA,EAC9D,IAAI,EAAE,QAAQ,QAAQ,OAAO,MAAM,YAAY,QAAQ;AAAA,EACvD,IAAI,EAAE,QAAQ,QAAQ,OAAO,MAAM,YAAY,QAAQ;AAAA,EACvD,IAAI,EAAE,QAAQ,QAAQ,OAAO,MAAM,YAAY,QAAQ;AACzD;AAEa,MAAA,gBAAgB,CAAC,SAAyC;AACrE,QAAM,EAAE,QAAQ,OAAO,WAAW,IAAI,MAAM,IAAI;AAChD,QAAM,EAAE,OAAO,GAAG,cAAcA,YAAAA,MAAM,WAAW,UAAU;AACpD,SAAA;AAAA,IACL;AAAA,IACA,SAASA,YAAA,MAAM,QAAQ,GAAG,KAAK;AAAA,IAC/B,GAAG;AAAA,EAAA;AAEP;AAEa,MAAA,oBAAoB,CAAC,SAAyC;AACzE,QAAM,EAAE,OAAA,IAAW,MAAM,IAAI;AACtB,SAAA;AAAA,IACL;AAAA,IACA,OAAO;AAAA,EAAA;AAEX;AAEO,MAAM,oBAAoB,OAAyB;AAAA,EACxD,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF;;;;;;;;"}
@@ -4,6 +4,15 @@ const buttonVariant = [
4
4
  "primary",
5
5
  "primarySubtle",
6
6
  "primaryGhost",
7
+ "positive",
8
+ "positiveSubtle",
9
+ "positiveGhost",
10
+ "negative",
11
+ "negativeSubtle",
12
+ "negativeGhost",
13
+ "warning",
14
+ "warningSubtle",
15
+ "warningGhost",
7
16
  "secondarySubtle",
8
17
  "secondaryGhost",
9
18
  "semantic",
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../../src/Button/types.ts"],"sourcesContent":["export const buttonVariant = [\n \"primary\",\n \"primarySubtle\",\n \"primaryGhost\",\n \"secondarySubtle\",\n \"secondaryGhost\",\n \"semantic\",\n // deprecated props\n \"secondary\",\n \"ghost\",\n] as const;\nexport type HvButtonVariant = (typeof buttonVariant)[number];\n\nexport const buttonSize = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type HvButtonSize = (typeof buttonSize)[number];\n\nexport const buttonRadius = [\n \"none\",\n \"base\",\n \"round\",\n \"circle\",\n \"full\",\n] as const;\nexport type HvButtonRadius = (typeof buttonRadius)[number];\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AACF;AAGO,MAAM,aAAa,CAAC,MAAM,MAAM,MAAM,MAAM,IAAI;AAGhD,MAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../../../src/Button/types.ts"],"sourcesContent":["export const buttonVariant = [\n \"primary\",\n \"primarySubtle\",\n \"primaryGhost\",\n \"positive\",\n \"positiveSubtle\",\n \"positiveGhost\",\n \"negative\",\n \"negativeSubtle\",\n \"negativeGhost\",\n \"warning\",\n \"warningSubtle\",\n \"warningGhost\",\n \"secondarySubtle\",\n \"secondaryGhost\",\n \"semantic\",\n // deprecated props\n \"secondary\",\n \"ghost\",\n] as const;\nexport type HvButtonVariant = (typeof buttonVariant)[number];\n\nexport const buttonSize = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type HvButtonSize = (typeof buttonSize)[number];\n\nexport const buttonRadius = [\n \"none\",\n \"base\",\n \"round\",\n \"circle\",\n \"full\",\n] as const;\nexport type HvButtonRadius = (typeof buttonRadius)[number];\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AACF;AAGO,MAAM,aAAa,CAAC,MAAM,MAAM,MAAM,MAAM,IAAI;AAGhD,MAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;;"}
@@ -2,23 +2,32 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const utils = require("./utils.cjs");
4
4
  class CalendarModel {
5
+ month;
6
+ year;
7
+ dates = [];
5
8
  constructor(month, year) {
6
- this.dates = [];
7
- this.updateModel = (month2, year2) => {
8
- let validMonth = month2;
9
- let validYear = year2;
10
- if (!Number.isInteger(validMonth)) {
11
- validMonth = (/* @__PURE__ */ new Date()).getMonth() + 1;
12
- }
13
- if (!Number.isInteger(validYear)) {
14
- validYear = (/* @__PURE__ */ new Date()).getFullYear();
15
- }
16
- this.month = validMonth;
17
- this.year = validYear;
18
- this.dates = utils.createDatesArray(validMonth, validYear);
19
- };
20
9
  this.updateModel(month, year);
21
10
  }
11
+ /**
12
+ * Updates the model with the received month and year
13
+ *
14
+ * @param month - Number of the month (1 to 12).
15
+ * @param year - Number of the year.
16
+ * @memberOf CalendarModel
17
+ */
18
+ updateModel = (month, year) => {
19
+ let validMonth = month;
20
+ let validYear = year;
21
+ if (!Number.isInteger(validMonth)) {
22
+ validMonth = (/* @__PURE__ */ new Date()).getMonth() + 1;
23
+ }
24
+ if (!Number.isInteger(validYear)) {
25
+ validYear = (/* @__PURE__ */ new Date()).getFullYear();
26
+ }
27
+ this.month = validMonth;
28
+ this.year = validYear;
29
+ this.dates = utils.createDatesArray(validMonth, validYear);
30
+ };
22
31
  }
23
32
  const generateModelFromDate = (seedValue) => {
24
33
  let calendarModel;
@@ -1 +1 @@
1
- {"version":3,"file":"model.cjs","sources":["../../../src/Calendar/model.tsx"],"sourcesContent":["import { createDatesArray, isRange } from \"./utils\";\n\n/**\n * Calendar builder for a specific month and year.\n * Returns an array of date objects.\n */\nexport default class CalendarModel {\n month: any;\n\n year: any;\n\n dates: Date[] = [];\n\n constructor(month?: number, year?: number) {\n this.updateModel(month!, year!);\n }\n\n /**\n * Updates the model with the received month and year\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @memberOf CalendarModel\n */\n updateModel = (month: number, year: number) => {\n let validMonth = month;\n let validYear = year;\n if (!Number.isInteger(validMonth)) {\n validMonth = new Date().getMonth() + 1;\n }\n if (!Number.isInteger(validYear)) {\n validYear = new Date().getFullYear();\n }\n\n this.month = validMonth;\n this.year = validYear;\n this.dates = createDatesArray(validMonth, validYear);\n };\n}\n\nconst generateModelFromDate = (seedValue: any) => {\n let calendarModel;\n\n if (typeof seedValue === \"string\") {\n const today = new Date();\n calendarModel = new CalendarModel(\n today.getMonth() + 1,\n today.getFullYear()\n );\n } else if (isRange(seedValue)) {\n calendarModel = new CalendarModel(\n seedValue.startDate.getMonth() + 1,\n seedValue.startDate.getFullYear()\n );\n } else {\n calendarModel = new CalendarModel(\n seedValue.getMonth() + 1,\n seedValue.getFullYear()\n );\n }\n\n return calendarModel;\n};\n\nexport const generateCalendarModel = (\n seedValue: any,\n visibleMonth?: number,\n visibleYear?: number\n) => {\n let calendarModel;\n\n if (visibleMonth && visibleYear) {\n calendarModel = new CalendarModel(visibleMonth, visibleYear);\n } else if (visibleMonth && !visibleYear) {\n calendarModel = new CalendarModel(visibleMonth, seedValue.getFullYear());\n } else if (!visibleMonth && visibleYear) {\n calendarModel = new CalendarModel(1, visibleYear);\n } else {\n calendarModel = generateModelFromDate(seedValue);\n }\n\n return calendarModel;\n};\n"],"names":["month","year","createDatesArray","isRange"],"mappings":";;;AAMA,MAAqB,cAAc;AAAA,EAOjC,YAAY,OAAgB,MAAe;AAF3C,SAAA,QAAgB;AAaF,SAAA,cAAA,CAACA,QAAeC,UAAiB;AAC7C,UAAI,aAAaD;AACjB,UAAI,YAAYC;AAChB,UAAI,CAAC,OAAO,UAAU,UAAU,GAAG;AACjC,sBAAiB,oBAAA,KAAO,GAAA,SAAA,IAAa;AAAA,MACvC;AACA,UAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AACpB,qBAAA,oBAAI,KAAK,GAAE,YAAY;AAAA,MACrC;AAEA,WAAK,QAAQ;AACb,WAAK,OAAO;AACP,WAAA,QAAQC,MAAAA,iBAAiB,YAAY,SAAS;AAAA,IAAA;AAtB9C,SAAA,YAAY,OAAQ,IAAK;AAAA,EAChC;AAuBF;AAEA,MAAM,wBAAwB,CAAC,cAAmB;AAC5C,MAAA;AAEA,MAAA,OAAO,cAAc,UAAU;AAC3B,UAAA,4BAAY;AAClB,oBAAgB,IAAI;AAAA,MAClB,MAAM,aAAa;AAAA,MACnB,MAAM,YAAY;AAAA,IAAA;AAAA,EACpB,WACSC,MAAAA,QAAQ,SAAS,GAAG;AAC7B,oBAAgB,IAAI;AAAA,MAClB,UAAU,UAAU,SAAA,IAAa;AAAA,MACjC,UAAU,UAAU,YAAY;AAAA,IAAA;AAAA,EAClC,OACK;AACL,oBAAgB,IAAI;AAAA,MAClB,UAAU,aAAa;AAAA,MACvB,UAAU,YAAY;AAAA,IAAA;AAAA,EAE1B;AAEO,SAAA;AACT;AAEO,MAAM,wBAAwB,CACnC,WACA,cACA,gBACG;AACC,MAAA;AAEJ,MAAI,gBAAgB,aAAa;AACf,oBAAA,IAAI,cAAc,cAAc,WAAW;AAAA,EAAA,WAClD,gBAAgB,CAAC,aAAa;AACvC,oBAAgB,IAAI,cAAc,cAAc,UAAU,YAAa,CAAA;AAAA,EAAA,WAC9D,CAAC,gBAAgB,aAAa;AACvB,oBAAA,IAAI,cAAc,GAAG,WAAW;AAAA,EAAA,OAC3C;AACL,oBAAgB,sBAAsB,SAAS;AAAA,EACjD;AAEO,SAAA;AACT;;;"}
1
+ {"version":3,"file":"model.cjs","sources":["../../../src/Calendar/model.tsx"],"sourcesContent":["import { createDatesArray, isRange } from \"./utils\";\n\n/**\n * Calendar builder for a specific month and year.\n * Returns an array of date objects.\n */\nexport default class CalendarModel {\n month: any;\n\n year: any;\n\n dates: Date[] = [];\n\n constructor(month?: number, year?: number) {\n this.updateModel(month!, year!);\n }\n\n /**\n * Updates the model with the received month and year\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @memberOf CalendarModel\n */\n updateModel = (month: number, year: number) => {\n let validMonth = month;\n let validYear = year;\n if (!Number.isInteger(validMonth)) {\n validMonth = new Date().getMonth() + 1;\n }\n if (!Number.isInteger(validYear)) {\n validYear = new Date().getFullYear();\n }\n\n this.month = validMonth;\n this.year = validYear;\n this.dates = createDatesArray(validMonth, validYear);\n };\n}\n\nconst generateModelFromDate = (seedValue: any) => {\n let calendarModel;\n\n if (typeof seedValue === \"string\") {\n const today = new Date();\n calendarModel = new CalendarModel(\n today.getMonth() + 1,\n today.getFullYear()\n );\n } else if (isRange(seedValue)) {\n calendarModel = new CalendarModel(\n seedValue.startDate.getMonth() + 1,\n seedValue.startDate.getFullYear()\n );\n } else {\n calendarModel = new CalendarModel(\n seedValue.getMonth() + 1,\n seedValue.getFullYear()\n );\n }\n\n return calendarModel;\n};\n\nexport const generateCalendarModel = (\n seedValue: any,\n visibleMonth?: number,\n visibleYear?: number\n) => {\n let calendarModel;\n\n if (visibleMonth && visibleYear) {\n calendarModel = new CalendarModel(visibleMonth, visibleYear);\n } else if (visibleMonth && !visibleYear) {\n calendarModel = new CalendarModel(visibleMonth, seedValue.getFullYear());\n } else if (!visibleMonth && visibleYear) {\n calendarModel = new CalendarModel(1, visibleYear);\n } else {\n calendarModel = generateModelFromDate(seedValue);\n }\n\n return calendarModel;\n};\n"],"names":["createDatesArray","isRange"],"mappings":";;;AAMA,MAAqB,cAAc;AAAA,EACjC;AAAA,EAEA;AAAA,EAEA,QAAgB,CAAA;AAAA,EAEhB,YAAY,OAAgB,MAAe;AACpC,SAAA,YAAY,OAAQ,IAAK;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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ty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const dayjs = require("dayjs");
4
- const capitalize = require("lodash/capitalize");
4
+ const helpers = require("../utils/helpers.cjs");
5
5
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
6
6
  const dayjs__default = /* @__PURE__ */ _interopDefault(dayjs);
7
- const capitalize__default = /* @__PURE__ */ _interopDefault(capitalize);
8
7
  const CALENDAR_WEEKS = 6;
9
8
  const getMonthDays = (month, year) => new Date(year, month, 0).getDate();
10
9
  const getMonthFirstWeekday = (month, year) => new Date(year, month - 1, 1).getDay();
@@ -35,7 +34,7 @@ const getMonthNamesList = (locale, representationValue = "long") => {
35
34
  const options = { month: representationValue, timeZone: "UTC" };
36
35
  return [...new Array(12)].map((n, index) => {
37
36
  const auxDate = makeUTCDate(1970, index, 1);
38
- return capitalize__default.default(Intl.DateTimeFormat(locale, options).format(auxDate));
37
+ return helpers.capitalize(Intl.DateTimeFormat(locale, options).format(auxDate));
39
38
  });
40
39
  };
41
40
  const getWeekdayNamesList = (locale) => {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["../../../src/Calendar/utils.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { DateRangeProp } from \"./types\";\n\n/**\n * Constant with the number of weeks to be displayed on the calendar.\n */\nexport const CALENDAR_WEEKS = 6;\n\n/**\n * Constant with the default locale that should be used as the default.\n */\nexport const DEFAULT_LOCALE = \"en\";\n\n/**\n * Pads a string value with leading zeroes(0) until length is reached.\n *\n * @param value - Value to be padded.\n * @param length - Length of the value after the padding is added.\n * @returns The value as a string with the received amount of padding.\n *\n * @example zeroPad(5, 2) => \"05\"\n */\nexport const zeroPad = (value: number, length: number) =>\n `${value}`.padStart(length, \"0\");\n\n/**\n * Returns the number of days in the month given a month and year.\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The number of days in a month for the received year.\n */\nexport const getMonthDays = (month: number, year: number) =>\n new Date(year, month, 0).getDate();\n\n/**\n * Gets the week day of the first day of a given month and year.\n * From 0 (Sunday) to 6 (Saturday).\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The zero indexed week day where 0 is Sunday (0 to 6).\n */\nexport const getMonthFirstWeekday = (month: number, year: number) =>\n new Date(year, month - 1, 1).getDay();\n\n/**\n * Creates a `Date` instance in UTC timezone.\n *\n * @param year - The year of the date.\n * @param monthIndex - The zero indexed month of the year (0 to 11).\n * @param day - The day of the month.\n * @param [hour=1] - The hour of the day.\n * @returns A `Date` instance in UTC timezone.\n */\nexport const makeUTCDate = (\n year: number,\n monthIndex: number,\n day: number,\n hour = 1\n) => new Date(Date.UTC(year, monthIndex, day, hour));\n\n/**\n * Checks if the received date is a valid date.\n *\n * @param date - The date to be validated.\n * @returns A flag stating if the date is valid or not.\n */\nexport const isDate = (date: any): date is Date =>\n Object.prototype.toString.call(date) === \"[object Date]\" &&\n !Number.isNaN(date.valueOf());\n\nexport const isDateRangeProp = (date: any): date is DateRangeProp =>\n \"startDate\" in date;\n\n/**\n * Checks if two dates are in the same month and year.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same month and year or not.\n */\nexport const isSameMonth = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Checks if two dates are on the same day.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same day or not.\n */\nexport const isSameDay = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getDate() === date2.getDate() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Formats the received date using the ISO format (YYYY-MM-DD).\n *\n * @param date - The date to be formatted.\n * @returns The formatted date in ISO format.\n */\nexport const getDateISO = (date?: Date) => {\n if (!isDate(date)) return null;\n\n return [\n date.getFullYear(),\n zeroPad(date.getMonth() + 1, 2),\n zeroPad(date.getDate(), 2),\n ].join(\"-\");\n};\n\n/**\n * Returns an object with the previous month taking also into consideration the year.\n * For example the previous month of January 2000 will be December 1999.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getPreviousMonth = (month: number, year: number) => {\n const prevMonth = month > 1 ? month - 1 : 12;\n const prevMonthYear = month > 1 ? year : year - 1;\n\n return { month: prevMonth, year: prevMonthYear };\n};\n\n/**\n * Returns an object with the next month taking also into consideration the year.\n * For example the next month of December 2000 will be January 2001.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getNextMonth = (month: number, year: number) => {\n const nextMonth = month < 12 ? month + 1 : 1;\n const nextMonthYear = month < 12 ? year : year + 1;\n\n return { month: nextMonth, year: nextMonthYear };\n};\n\n/**\n * Returns a list with the names of all the months localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The representation value for the month.\n * @returns An array with all the months names.\n */\nexport const getMonthNamesList = (\n locale: string | undefined,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) => {\n const options = { month: representationValue, timeZone: \"UTC\" };\n\n return [...new Array(12)].map((n, index) => {\n const auxDate = makeUTCDate(1970, index, 1);\n return capitalize(Intl.DateTimeFormat(locale, options).format(auxDate));\n });\n};\n\n/**\n * Returns a list with the names of all the weekdays localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied.\n * @returns An array with all the weekday names.\n */\nexport const getWeekdayNamesList = (locale: string) => {\n const formatter = new Intl.DateTimeFormat(locale, {\n weekday: \"narrow\",\n timeZone: \"UTC\",\n });\n\n return [...new Array(7)].map((n, index) => {\n return formatter.format(makeUTCDate(1970, 0, 4 + index));\n });\n};\n\n/**\n * Returns the name of the month for the supplied month localized in the received locale and representation value.\n *\n * @param date - The date from which the month name is extracted.\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The locale to be applied to the Intl format.\n * @returns The name of the month.\n */\nexport const getMonthName = (\n date: Date,\n locale: string,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) =>\n new Intl.DateTimeFormat(locale, { month: representationValue }).format(date);\n\n/**\n * Formats the received date according to Design System specifications.\n * Currently: day month, year => `14 Aug, 2019`.\n *\n * @param date - UTC date to be formatted.\n * @param locale - The locale to be applied to the Intl format.\n * @returns The formatted date as a string.\n */\nexport const getFormattedDate = (\n // TODO: fix this\n date: any,\n locale: any,\n rep: Intl.DateTimeFormatOptions[\"month\"] = \"short\"\n) =>\n `${date.getDate()} ${getMonthName(date, locale, rep)} ${date.getFullYear()}`;\n\n/**\n * Creates an array of 42 days. The complete current month and enough days from the previous and next months to fill\n * the 42 positions.\n *\n * @param month - The number of the month (1 to 12).\n * @param year - The number of the year.\n * @returns The array of dates.\n */\nexport const createDatesArray = (month: number, year: number) => {\n // Initializes the variables needed to calculate the dates for the received month and year\n const monthDays = getMonthDays(month, year);\n const daysFromPrevMonth = getMonthFirstWeekday(month, year);\n const daysFromNextMonth =\n CALENDAR_WEEKS * 7 - (daysFromPrevMonth + monthDays);\n const prevMonthYear = getPreviousMonth(month, year);\n const nextMonthYear = getNextMonth(month, year);\n const prevMonthDays = getMonthDays(prevMonthYear.month, prevMonthYear.year);\n\n // Creates the arrays for the dates for previous, current and next months\n const prevMonthDates = [...new Array(daysFromPrevMonth)].map((n, index) => {\n const day = index + 1 + (prevMonthDays - daysFromPrevMonth);\n return new Date(prevMonthYear.year, prevMonthYear.month - 1, day);\n });\n const currentMonthDates = [...new Array(monthDays)].map((n, index) => {\n const day = index + 1;\n return new Date(year, month - 1, day);\n });\n const nextMonthDates = [...new Array(daysFromNextMonth)].map((n, index) => {\n const day = index + 1;\n return new Date(nextMonthYear.year, nextMonthYear.month - 1, day);\n });\n\n return [...prevMonthDates, ...currentMonthDates, ...nextMonthDates];\n};\n\nexport const isRange = (date: any): date is DateRangeProp =>\n date != null && typeof date === \"object\" && \"startDate\" in date;\n\n/**\n * Checks if the date falls within a specified date range.\n *\n * @param date - The date to be evaluated.\n * @param providedValueRange - Provided selection range.\n * @returns - True if the date falls within the range, false otherwise.\n */\nexport const dateInProvidedValueRange = (\n date: any,\n providedValueRange: any\n) => {\n const { startDate, endDate } = providedValueRange;\n\n if (!isRange(providedValueRange) || endDate == null) return false;\n const localEndDate = endDate;\n\n const modStartDate = dayjs(startDate).format(\"YYYY-MM-DD\");\n const modEndDate = dayjs(localEndDate).format(\"YYYY-MM-DD\");\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return convertedDate >= modStartDate && convertedDate <= modEndDate;\n};\n\nexport const checkIfDateIsDisabled = (\n date?: string | number | Date | dayjs.Dayjs,\n minimumDate?: string | number | Date | dayjs.Dayjs,\n maximumDate?: string | number | Date | dayjs.Dayjs\n) => {\n if (!minimumDate && !maximumDate) return false;\n const modStartDate = minimumDate\n ? dayjs(minimumDate).format(\"YYYY-MM-DD\")\n : undefined;\n const modEndDate = maximumDate\n ? dayjs(maximumDate).format(\"YYYY-MM-DD\")\n : undefined;\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return (\n (modStartDate !== undefined && convertedDate < modStartDate) ||\n (modEndDate !== undefined && convertedDate > modEndDate)\n );\n};\n\nexport const formatToLocale = (date: any, locale: any) => {\n return new Intl.DateTimeFormat(locale, {\n day: \"numeric\",\n month: \"short\",\n year: \"numeric\",\n }).format(date);\n};\n"],"names":["capitalize","dayjs"],"mappings":";;;;;;;AASO,MAAM,iBAAiB;AA0BjB,MAAA,eAAe,CAAC,OAAe,SAC1C,IAAI,KAAK,MAAM,OAAO,CAAC,EAAE,QAAQ;AAUtB,MAAA,uBAAuB,CAAC,OAAe,SAClD,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO;AAW/B,MAAM,cAAc,CACzB,MACA,YACA,KACA,OAAO,MACJ,IAA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;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs","sources":["../../../src/Calendar/utils.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\n\nimport { capitalize } from \"../utils/helpers\";\nimport { DateRangeProp } from \"./types\";\n\n/**\n * Constant with the number of weeks to be displayed on the calendar.\n */\nexport const CALENDAR_WEEKS = 6;\n\n/**\n * Constant with the default locale that should be used as the default.\n */\nexport const DEFAULT_LOCALE = \"en\";\n\n/**\n * Pads a string value with leading zeroes(0) until length is reached.\n *\n * @param value - Value to be padded.\n * @param length - Length of the value after the padding is added.\n * @returns The value as a string with the received amount of padding.\n *\n * @example zeroPad(5, 2) => \"05\"\n */\nexport const zeroPad = (value: number, length: number) =>\n `${value}`.padStart(length, \"0\");\n\n/**\n * Returns the number of days in the month given a month and year.\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The number of days in a month for the received year.\n */\nexport const getMonthDays = (month: number, year: number) =>\n new Date(year, month, 0).getDate();\n\n/**\n * Gets the week day of the first day of a given month and year.\n * From 0 (Sunday) to 6 (Saturday).\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The zero indexed week day where 0 is Sunday (0 to 6).\n */\nexport const getMonthFirstWeekday = (month: number, year: number) =>\n new Date(year, month - 1, 1).getDay();\n\n/**\n * Creates a `Date` instance in UTC timezone.\n *\n * @param year - The year of the date.\n * @param monthIndex - The zero indexed month of the year (0 to 11).\n * @param day - The day of the month.\n * @param [hour=1] - The hour of the day.\n * @returns A `Date` instance in UTC timezone.\n */\nexport const makeUTCDate = (\n year: number,\n monthIndex: number,\n day: number,\n hour = 1\n) => new Date(Date.UTC(year, monthIndex, day, hour));\n\n/**\n * Checks if the received date is a valid date.\n *\n * @param date - The date to be validated.\n * @returns A flag stating if the date is valid or not.\n */\nexport const isDate = (date: any): date is Date =>\n Object.prototype.toString.call(date) === \"[object Date]\" &&\n !Number.isNaN(date.valueOf());\n\nexport const isDateRangeProp = (date: any): date is DateRangeProp =>\n \"startDate\" in date;\n\n/**\n * Checks if two dates are in the same month and year.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same month and year or not.\n */\nexport const isSameMonth = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Checks if two dates are on the same day.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same day or not.\n */\nexport const isSameDay = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getDate() === date2.getDate() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Formats the received date using the ISO format (YYYY-MM-DD).\n *\n * @param date - The date to be formatted.\n * @returns The formatted date in ISO format.\n */\nexport const getDateISO = (date?: Date) => {\n if (!isDate(date)) return null;\n\n return [\n date.getFullYear(),\n zeroPad(date.getMonth() + 1, 2),\n zeroPad(date.getDate(), 2),\n ].join(\"-\");\n};\n\n/**\n * Returns an object with the previous month taking also into consideration the year.\n * For example the previous month of January 2000 will be December 1999.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getPreviousMonth = (month: number, year: number) => {\n const prevMonth = month > 1 ? month - 1 : 12;\n const prevMonthYear = month > 1 ? year : year - 1;\n\n return { month: prevMonth, year: prevMonthYear };\n};\n\n/**\n * Returns an object with the next month taking also into consideration the year.\n * For example the next month of December 2000 will be January 2001.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getNextMonth = (month: number, year: number) => {\n const nextMonth = month < 12 ? month + 1 : 1;\n const nextMonthYear = month < 12 ? year : year + 1;\n\n return { month: nextMonth, year: nextMonthYear };\n};\n\n/**\n * Returns a list with the names of all the months localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The representation value for the month.\n * @returns An array with all the months names.\n */\nexport const getMonthNamesList = (\n locale: string | undefined,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) => {\n const options = { month: representationValue, timeZone: \"UTC\" };\n\n return [...new Array(12)].map((n, index) => {\n const auxDate = makeUTCDate(1970, index, 1);\n return capitalize(Intl.DateTimeFormat(locale, options).format(auxDate));\n });\n};\n\n/**\n * Returns a list with the names of all the weekdays localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied.\n * @returns An array with all the weekday names.\n */\nexport const getWeekdayNamesList = (locale: string) => {\n const formatter = new Intl.DateTimeFormat(locale, {\n weekday: \"narrow\",\n timeZone: \"UTC\",\n });\n\n return [...new Array(7)].map((n, index) => {\n return formatter.format(makeUTCDate(1970, 0, 4 + index));\n });\n};\n\n/**\n * Returns the name of the month for the supplied month localized in the received locale and representation value.\n *\n * @param date - The date from which the month name is extracted.\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The locale to be applied to the Intl format.\n * @returns The name of the month.\n */\nexport const getMonthName = (\n date: Date,\n locale: string,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) =>\n new Intl.DateTimeFormat(locale, { month: representationValue }).format(date);\n\n/**\n * Formats the received date according to Design System specifications.\n * Currently: day month, year => `14 Aug, 2019`.\n *\n * @param date - UTC date to be formatted.\n * @param locale - The locale to be applied to the Intl format.\n * @returns The formatted date as a string.\n */\nexport const getFormattedDate = (\n // TODO: fix this\n date: any,\n locale: any,\n rep: Intl.DateTimeFormatOptions[\"month\"] = \"short\"\n) =>\n `${date.getDate()} ${getMonthName(date, locale, rep)} ${date.getFullYear()}`;\n\n/**\n * Creates an array of 42 days. The complete current month and enough days from the previous and next months to fill\n * the 42 positions.\n *\n * @param month - The number of the month (1 to 12).\n * @param year - The number of the year.\n * @returns The array of dates.\n */\nexport const createDatesArray = (month: number, year: number) => {\n // Initializes the variables needed to calculate the dates for the received month and year\n const monthDays = getMonthDays(month, year);\n const daysFromPrevMonth = getMonthFirstWeekday(month, year);\n const daysFromNextMonth =\n CALENDAR_WEEKS * 7 - (daysFromPrevMonth + monthDays);\n const prevMonthYear = getPreviousMonth(month, year);\n const nextMonthYear = getNextMonth(month, year);\n const prevMonthDays = getMonthDays(prevMonthYear.month, prevMonthYear.year);\n\n // Creates the arrays for the dates for previous, current and next months\n const prevMonthDates = [...new Array(daysFromPrevMonth)].map((n, index) => {\n const day = index + 1 + (prevMonthDays - daysFromPrevMonth);\n return new Date(prevMonthYear.year, prevMonthYear.month - 1, day);\n });\n const currentMonthDates = [...new Array(monthDays)].map((n, index) => {\n const day = index + 1;\n return new Date(year, month - 1, day);\n });\n const nextMonthDates = [...new Array(daysFromNextMonth)].map((n, index) => {\n const day = index + 1;\n return new Date(nextMonthYear.year, nextMonthYear.month - 1, day);\n });\n\n return [...prevMonthDates, ...currentMonthDates, ...nextMonthDates];\n};\n\nexport const isRange = (date: any): date is DateRangeProp =>\n date != null && typeof date === \"object\" && \"startDate\" in date;\n\n/**\n * Checks if the date falls within a specified date range.\n *\n * @param date - The date to be evaluated.\n * @param providedValueRange - Provided selection range.\n * @returns - True if the date falls within the range, false otherwise.\n */\nexport const dateInProvidedValueRange = (\n date: any,\n providedValueRange: any\n) => {\n const { startDate, endDate } = providedValueRange;\n\n if (!isRange(providedValueRange) || endDate == null) return false;\n const localEndDate = endDate;\n\n const modStartDate = dayjs(startDate).format(\"YYYY-MM-DD\");\n const modEndDate = dayjs(localEndDate).format(\"YYYY-MM-DD\");\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return convertedDate >= modStartDate && convertedDate <= modEndDate;\n};\n\nexport const checkIfDateIsDisabled = (\n date?: string | number | Date | dayjs.Dayjs,\n minimumDate?: string | number | Date | dayjs.Dayjs,\n maximumDate?: string | number | Date | dayjs.Dayjs\n) => {\n if (!minimumDate && !maximumDate) return false;\n const modStartDate = minimumDate\n ? dayjs(minimumDate).format(\"YYYY-MM-DD\")\n : undefined;\n const modEndDate = maximumDate\n ? dayjs(maximumDate).format(\"YYYY-MM-DD\")\n : undefined;\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return (\n (modStartDate !== undefined && convertedDate < modStartDate) ||\n (modEndDate !== undefined && convertedDate > modEndDate)\n );\n};\n\nexport const formatToLocale = (date: any, locale: any) => {\n return new Intl.DateTimeFormat(locale, {\n day: \"numeric\",\n month: \"short\",\n year: \"numeric\",\n }).format(date);\n};\n"],"names":["capitalize","dayjs"],"mappings":";;;;;;AAQO,MAAM,iBAAiB;AA0BjB,MAAA,eAAe,CAAC,OAAe,SAC1C,IAAI,KAAK,MAAM,OAAO,CAAC,EAAE,QAAQ;AAUtB,MAAA,uBAAuB,CAAC,OAAe,SAClD,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO;AAW/B,MAAM,cAAc,CACzB,MACA,YACA,KACA,OAAO,MACJ,IAAI,KAAK,KAAK,IAAI,MAAM,YAAY,KAAK,IAAI,CAAC;AAQ5C,MAAM,SAAS,CAAC,SACrB,OAAO,UAAU,SAAS,KAAK,IAAI,MAAM,mBACzC,CAAC,OAAO,MAAM,KAAK,SAAS;AAEjB,MAAA,kBAAkB,CAAC,SAC9B,eAAe;AASJ,MAAA,cAAc,CAAC,OAAY,UAAe;AACrD,MAAI,EAAE,OAAO,KAAK,KAAK,OAAO,KAAK;AAAW,WAAA;AAG5C,SAAA,MAAM,eAAe,MAAM,SAAA,KAC3B,MAAM,YAAkB,MAAA,MAAM;AAElC;AASa,MAAA,YAAY,CAAC,OAAY,UAAe;AACnD,MAAI,EAAE,OAAO,KAAK,KAAK,OAAO,KAAK;AAAW,WAAA;AAE9C,SACE,MAAM,QAAQ,MAAM,MAAM,QAAA,KAC1B,MAAM,SAAA,MAAe,MAAM,SAC3B,KAAA,MAAM,YAAY,MAAM,MAAM;AAElC;AA0Ba,MAAA,mBAAmB,CAAC,OAAe,SAAiB;AAC/D,QAAM,YA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AAM,IAAI,EAAE,OAAO,YAAY;AAE9C,SAAA,iBAAiB,gBAAgB,iBAAiB;AAC3D;AAEO,MAAM,wBAAwB,CACnC,MACA,aACA,gBACG;AACC,MAAA,CAAC,eAAe,CAAC;AAAoB,WAAA;AACzC,QAAM,eAAe,cACjBA,uBAAM,WAAW,EAAE,OAAO,YAAY,IACtC;AACJ,QAAM,aAAa,cACfA,uBAAM,WAAW,EAAE,OAAO,YAAY,IACtC;AAEJ,QAAM,gBAAgBA,eAAAA,QAAM,IAAI,EAAE,OAAO,YAAY;AAErD,SACG,iBAAiB,UAAa,gBAAgB,gBAC9C,eAAe,UAAa,gBAAgB;AAEjD;AAEa,MAAA,iBAAiB,CAAC,MAAW,WAAgB;AACjD,SAAA,IAAI,KAAK,eAAe,QAAQ;AAAA,IACrC,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,EAAA,CACP,EAAE,OAAO,IAAI;AAChB;;;;;;;;;;;;;;;;;;;;"}
@@ -6,6 +6,7 @@ const useCarousel = require("embla-carousel-react");
6
6
  const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
7
7
  const useDefaultProps = require("../hooks/useDefaultProps.cjs");
8
8
  const useTheme = require("../hooks/useTheme.cjs");
9
+ const helpers = require("../utils/helpers.cjs");
9
10
  const CarouselControls = require("./CarouselControls.cjs");
10
11
  const CarouselThumbnails = require("./CarouselThumbnails.cjs");
11
12
  const Carousel_styles = require("./Carousel.styles.cjs");
@@ -15,7 +16,6 @@ const IconButton = require("../IconButton/IconButton.cjs");
15
16
  const Typography = require("../Typography/Typography.cjs");
16
17
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
17
18
  const useCarousel__default = /* @__PURE__ */ _interopDefault(useCarousel);
18
- const clamp = (num, max, min = 0) => Math.min(Math.max(num, min), max);
19
19
  const HvCarousel = (props) => {
20
20
  const {
21
21
  className,
@@ -87,7 +87,7 @@ const HvCarousel = (props) => {
87
87
  if (!controller)
88
88
  return;
89
89
  controller.reInit();
90
- setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides, 0));
90
+ setSelectedIndex((currentIndex) => helpers.clamp(currentIndex, numSlides));
91
91
  }, [numSlides, controller]);
92
92
  const canPrev = controller?.canScrollPrev() ?? false;
93
93
  const canNext = controller?.canScrollNext() ?? false;
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.cjs","sources":["../../../src/Carousel/Carousel.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n Children,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport useCarousel from \"embla-carousel-react\";\nimport {\n Backwards,\n Forwards,\n Close,\n Fullscreen,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvButton } from \"../Button\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { HvTypography } from \"../Typography\";\nimport { HvContainer } from \"../Container\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvCarouselControls } from \"./CarouselControls\";\nimport { HvCarouselThumbnails } from \"./CarouselThumbnails\";\nimport { staticClasses, useClasses } from \"./Carousel.styles\";\nimport { HvIconButton } from \"../IconButton\";\n\nconst clamp = (num: number, max: number, min = 0) =>\n Math.min(Math.max(num, min), max);\n\nexport { staticClasses as carouselClasses };\n\nexport type HvCarouselClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCarouselProps\n extends HvBaseProps<HTMLDivElement, \"title\" | \"onChange\"> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvCarouselClasses;\n /** Height of the Slider container. If `undefined`, images will keep a 16/9 aspect-ratio */\n height?: CSSProperties[\"height\"];\n /** Width of the thumbnail. Height will try to maintain a 16/9 aspect-ratio */\n thumbnailWidth?: CSSProperties[\"width\"];\n /** Title of the carousel */\n title?: React.ReactNode;\n /** Content slides to be displayed. @see `<HvCarouselSlide />` */\n children?: React.ReactNode;\n /** Custom content to render in the actions area */\n actions?: React.ReactNode;\n /** Whether Carousel is in \"xs mode\" - to use in embedded contexts */\n xs?: boolean;\n /** Whether to show dots instead of arrow pagination. Defaults to true under 5 elements */\n showDots?: boolean;\n /** Whether to show the counter on the top-right corner of the active slide */\n showCounter?: boolean;\n /** Whether to show the back/forwards buttons over the active slide */\n showSlideControls?: boolean;\n /** Whether to enable the fullscreen toggle button */\n showFullscreen?: boolean;\n /** Whether to hide the thumbnails. Hidden by default in \"xs\" mode */\n hideThumbnails?: boolean;\n /** Controls position. */\n controlsPosition?: \"top\" | \"bottom\";\n /** Thumbnails position. */\n thumbnailsPosition?: \"top\" | \"bottom\";\n /** Carousel configuration options. @see https://www.embla-carousel.com/api/options/ */\n carouselOptions?: Parameters<typeof useCarousel>[0];\n /** Function that renders the thumbnail. */\n renderThumbnail?: (index: number) => React.ReactNode;\n /** The callback fired when the active slide changes. */\n onChange?: (index: number) => void;\n}\n\n/**\n * A Carousel is commonly used to browse images, it can also be used to browse any kind of content like text, video, or charts.\n * It allows you to focus on a particular content while having a notion of how many you have to explore.\n */\nexport const HvCarousel = (props: HvCarouselProps) => {\n const {\n className,\n classes: classesProp,\n height: heightProp = \"auto\",\n thumbnailWidth = 90,\n title,\n children,\n actions: actionsProp,\n xs,\n showDots: showDotsProp,\n showCounter: showCounterProp,\n showSlideControls,\n showFullscreen: showFullscreenProp,\n hideThumbnails: hideThumbnailsProp,\n controlsPosition: controlsPositionProp,\n thumbnailsPosition: thumbnailsPositionProp,\n carouselOptions,\n renderThumbnail,\n onChange,\n ...others\n } = useDefaultProps(\"HvCarousel\", props);\n const { activeTheme } = useTheme();\n const { classes, css, cx } = useClasses(classesProp);\n const thumbnailsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const isDs3 = activeTheme?.name === \"ds3\";\n const actionsPosition = isDs3 ? \"header\" : \"controls\";\n const controlsPosition = controlsPositionProp ?? (isDs3 ? \"bottom\" : \"top\");\n const thumbnailsPosition = thumbnailsPositionProp ?? \"bottom\";\n\n const [containerRef, controller] = useCarousel({\n align: \"start\",\n loop: true,\n ...carouselOptions,\n });\n\n const [selectedIndex, setSelectedIndex] = useState(\n carouselOptions?.startIndex ?? 0\n );\n\n const numSlides = Children.count(children);\n\n const handlePrevious = useCallback(() => {\n controller?.scrollPrev();\n }, [controller]);\n\n const handleNext = useCallback(() => {\n controller?.scrollNext();\n }, [controller]);\n\n const handleScroll = (index: number) => {\n controller?.scrollTo(index);\n };\n\n const handleSelect = useCallback(() => {\n if (!controller) return;\n\n const slideIndex = controller.selectedScrollSnap();\n setSelectedIndex(slideIndex);\n\n // scroll to thumbnail button\n thumbnailsRef.current\n ?.querySelectorAll(\"button\")\n ?.[slideIndex]?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n });\n\n onChange?.(slideIndex);\n }, [controller, onChange]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.on(\"select\", handleSelect);\n\n return () => {\n controller.off(\"select\", handleSelect);\n };\n }, [controller, handleSelect]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.reInit();\n setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides, 0));\n }, [numSlides, controller]);\n\n const canPrev = controller?.canScrollPrev() ?? false;\n const canNext = controller?.canScrollNext() ?? false;\n const showTitle = !!title && (!xs || isFullscreen);\n const showFullscreen = showFullscreenProp ?? xs;\n const height = isFullscreen ? \"100%\" : heightProp ?? \"auto\";\n const showCounter = xs;\n const hideThumbnails = hideThumbnailsProp ?? (xs && !isFullscreen);\n const showThumbnails = !hideThumbnails && !!renderThumbnail;\n const showDots = showDotsProp ?? numSlides <= 5;\n\n const actions = (\n <div\n className={cx(\n classes.actions,\n actionsPosition === \"header\"\n ? css({ position: \"relative\", top: -40, height: 0 })\n : css({ position: \"absolute\" })\n )}\n >\n {actionsProp}\n {showFullscreen && (\n <HvIconButton\n title={isFullscreen ? \"Close\" : \"Fullscreen\"}\n onClick={() => setIsFullscreen((curr) => !curr)}\n className={classes.closeButton}\n >\n {isFullscreen ? <Close /> : <Fullscreen />}\n </HvIconButton>\n )}\n </div>\n );\n\n const controls = (\n <HvCarouselControls\n classes={classes}\n showDots={showDots}\n page={selectedIndex}\n pages={numSlides}\n canPrevious={canPrev}\n canNext={canNext}\n onPreviousClick={handlePrevious}\n onNextClick={handleNext}\n actions={actionsPosition === \"controls\" && actions}\n />\n );\n\n const thumbnails = showThumbnails && (\n <HvCarouselThumbnails\n classes={classes}\n ref={thumbnailsRef}\n page={selectedIndex}\n pages={numSlides}\n width={thumbnailWidth}\n onThumbnailClick={(evt, i) => handleScroll(i)}\n renderThumbnail={renderThumbnail}\n />\n );\n\n return (\n <HvContainer\n className={cx(classes.root, className, {\n [classes.xs]: xs,\n [classes.fullscreen]: isFullscreen,\n })}\n {...others}\n >\n {showTitle && (\n <HvTypography variant=\"title2\" className={classes.title}>\n {title}\n </HvTypography>\n )}\n\n {actionsPosition === \"header\" && actions}\n {thumbnailsPosition === \"top\" && thumbnails}\n {controlsPosition === \"top\" && controls}\n <div\n className={cx(classes.main, {\n [classes.mainXs]: xs,\n [classes.mainFullscreen]: isFullscreen,\n })}\n >\n {showCounter && (\n <div className={classes.counterContainer}>\n <span className={classes.counter}>\n {`${selectedIndex + 1}/${numSlides}`}\n </span>\n </div>\n )}\n\n {showSlideControls && (\n <div className={classes.slideControls}>\n <HvButton\n icon\n disabled={!canPrev}\n variant=\"secondarySubtle\"\n aria-label=\"Backwards\"\n onClick={handlePrevious}\n >\n <Backwards iconSize=\"XS\" />\n </HvButton>\n <HvButton\n icon\n disabled={!canNext}\n variant=\"secondarySubtle\"\n aria-label=\"Forwards\"\n onClick={handleNext}\n >\n <Forwards iconSize=\"XS\" />\n </HvButton>\n </div>\n )}\n\n <div\n ref={containerRef}\n style={{ height }}\n className={classes.slidesViewport}\n >\n <div className={classes.slidesContainer}>{children}</div>\n </div>\n </div>\n {controlsPosition === \"bottom\" && controls}\n {thumbnailsPosition === \"bottom\" && thumbnails}\n </HvContainer>\n );\n};\n"],"names":["useDefaultProps","useTheme","useClasses","useRef","useState","useCarousel","Children","useCallback","useEffect","jsxs","jsx","HvIconButton","Close","Fullscreen","HvCarouselControls","HvCarouselThumbnails","HvContainer","HvTypography","HvButton","Backwards","Forwards"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAM,QAAQ,CAAC,KAAa,KAAa,MAAM,MAC7C,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,GAAG,GAAG;AAgDrB,MAAA,aAAa,CAAC,UAA2B;AAC9C,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,QAAQ,aAAa;AAAA,IACrB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,UAAU;AAAA,IACV,aAAa;AAAA,IACb;AAAA,IACA,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,cAAc,KAAK;AACjC,QAAA,EAAE,gBAAgBC,SAAAA;AACxB,QAAM,EAAE,SAAS,KAAK,GAAG,IAAIC,gBAAAA,WAAW,WAAW;AAC7C,QAAA,gBAAgBC,aAAuB,IAAI;AACjD,QAAM,CAAC,cAAc,eAAe,IAAIC,eAAS,KAAK;AAEhD,QAAA,QAAQ,aAAa,SAAS;AAC9B,QAAA,kBAAkB,QAAQ,WAAW;AACrC,QAAA,mBAAmB,yBAAyB,QAAQ,WAAW;AACrE,QAAM,qBAAqB,0BAA0B;AAErD,QAAM,CAAC,cAAc,UAAU,IAAIC,6BAAY;AAAA,IAC7C,OAAO;AAAA,IACP,MAAM;AAAA,IACN,GAAG;AAAA,EAAA,CACJ;AAEK,QAAA,CAAC,eAAe,gBAAgB,IAAID,MAAA;AAAA,IACxC,iBAAiB,cAAc;AAAA,EAAA;AAG3B,QAAA,YAAYE,MAAAA,SAAS,MAAM,QAAQ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,2BAAA,IAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAS;AAAA,gBAAA;AAAA,cACrD;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,QACC,qBAAqB,YAAY;AAAA,QACjC,uBAAuB,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;;;"}
1
+ {"version":3,"file":"Carousel.cjs","sources":["../../../src/Carousel/Carousel.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n Children,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport useCarousel from \"embla-carousel-react\";\nimport {\n Backwards,\n Forwards,\n Close,\n Fullscreen,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvButton } from \"../Button\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { HvTypography } from \"../Typography\";\nimport { HvContainer } from \"../Container\";\nimport { clamp } from \"../utils/helpers\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvCarouselControls } from \"./CarouselControls\";\nimport { HvCarouselThumbnails } from \"./CarouselThumbnails\";\nimport { staticClasses, useClasses } from \"./Carousel.styles\";\nimport { HvIconButton } from \"../IconButton\";\n\nexport { staticClasses as carouselClasses };\n\nexport type HvCarouselClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCarouselProps\n extends HvBaseProps<HTMLDivElement, \"title\" | \"onChange\"> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvCarouselClasses;\n /** Height of the Slider container. If `undefined`, images will keep a 16/9 aspect-ratio */\n height?: CSSProperties[\"height\"];\n /** Width of the thumbnail. Height will try to maintain a 16/9 aspect-ratio */\n thumbnailWidth?: CSSProperties[\"width\"];\n /** Title of the carousel */\n title?: React.ReactNode;\n /** Content slides to be displayed. @see `<HvCarouselSlide />` */\n children?: React.ReactNode;\n /** Custom content to render in the actions area */\n actions?: React.ReactNode;\n /** Whether Carousel is in \"xs mode\" - to use in embedded contexts */\n xs?: boolean;\n /** Whether to show dots instead of arrow pagination. Defaults to true under 5 elements */\n showDots?: boolean;\n /** Whether to show the counter on the top-right corner of the active slide */\n showCounter?: boolean;\n /** Whether to show the back/forwards buttons over the active slide */\n showSlideControls?: boolean;\n /** Whether to enable the fullscreen toggle button */\n showFullscreen?: boolean;\n /** Whether to hide the thumbnails. Hidden by default in \"xs\" mode */\n hideThumbnails?: boolean;\n /** Controls position. */\n controlsPosition?: \"top\" | \"bottom\";\n /** Thumbnails position. */\n thumbnailsPosition?: \"top\" | \"bottom\";\n /** Carousel configuration options. @see https://www.embla-carousel.com/api/options/ */\n carouselOptions?: Parameters<typeof useCarousel>[0];\n /** Function that renders the thumbnail. */\n renderThumbnail?: (index: number) => React.ReactNode;\n /** The callback fired when the active slide changes. */\n onChange?: (index: number) => void;\n}\n\n/**\n * A Carousel is commonly used to browse images, it can also be used to browse any kind of content like text, video, or charts.\n * It allows you to focus on a particular content while having a notion of how many you have to explore.\n */\nexport const HvCarousel = (props: HvCarouselProps) => {\n const {\n className,\n classes: classesProp,\n height: heightProp = \"auto\",\n thumbnailWidth = 90,\n title,\n children,\n actions: actionsProp,\n xs,\n showDots: showDotsProp,\n showCounter: showCounterProp,\n showSlideControls,\n showFullscreen: showFullscreenProp,\n hideThumbnails: hideThumbnailsProp,\n controlsPosition: controlsPositionProp,\n thumbnailsPosition: thumbnailsPositionProp,\n carouselOptions,\n renderThumbnail,\n onChange,\n ...others\n } = useDefaultProps(\"HvCarousel\", props);\n const { activeTheme } = useTheme();\n const { classes, css, cx } = useClasses(classesProp);\n const thumbnailsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n const isDs3 = activeTheme?.name === \"ds3\";\n const actionsPosition = isDs3 ? \"header\" : \"controls\";\n const controlsPosition = controlsPositionProp ?? (isDs3 ? \"bottom\" : \"top\");\n const thumbnailsPosition = thumbnailsPositionProp ?? \"bottom\";\n\n const [containerRef, controller] = useCarousel({\n align: \"start\",\n loop: true,\n ...carouselOptions,\n });\n\n const [selectedIndex, setSelectedIndex] = useState(\n carouselOptions?.startIndex ?? 0\n );\n\n const numSlides = Children.count(children);\n\n const handlePrevious = useCallback(() => {\n controller?.scrollPrev();\n }, [controller]);\n\n const handleNext = useCallback(() => {\n controller?.scrollNext();\n }, [controller]);\n\n const handleScroll = (index: number) => {\n controller?.scrollTo(index);\n };\n\n const handleSelect = useCallback(() => {\n if (!controller) return;\n\n const slideIndex = controller.selectedScrollSnap();\n setSelectedIndex(slideIndex);\n\n // scroll to thumbnail button\n thumbnailsRef.current\n ?.querySelectorAll(\"button\")\n ?.[slideIndex]?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n });\n\n onChange?.(slideIndex);\n }, [controller, onChange]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.on(\"select\", handleSelect);\n\n return () => {\n controller.off(\"select\", handleSelect);\n };\n }, [controller, handleSelect]);\n\n useEffect(() => {\n if (!controller) return;\n\n controller.reInit();\n setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides));\n }, [numSlides, controller]);\n\n const canPrev = controller?.canScrollPrev() ?? false;\n const canNext = controller?.canScrollNext() ?? false;\n const showTitle = !!title && (!xs || isFullscreen);\n const showFullscreen = showFullscreenProp ?? xs;\n const height = isFullscreen ? \"100%\" : heightProp ?? \"auto\";\n const showCounter = xs;\n const hideThumbnails = hideThumbnailsProp ?? (xs && !isFullscreen);\n const showThumbnails = !hideThumbnails && !!renderThumbnail;\n const showDots = showDotsProp ?? numSlides <= 5;\n\n const actions = (\n <div\n className={cx(\n classes.actions,\n actionsPosition === \"header\"\n ? css({ position: \"relative\", top: -40, height: 0 })\n : css({ position: \"absolute\" })\n )}\n >\n {actionsProp}\n {showFullscreen && (\n <HvIconButton\n title={isFullscreen ? \"Close\" : \"Fullscreen\"}\n onClick={() => setIsFullscreen((curr) => !curr)}\n className={classes.closeButton}\n >\n {isFullscreen ? <Close /> : <Fullscreen />}\n </HvIconButton>\n )}\n </div>\n );\n\n const controls = (\n <HvCarouselControls\n classes={classes}\n showDots={showDots}\n page={selectedIndex}\n pages={numSlides}\n canPrevious={canPrev}\n canNext={canNext}\n onPreviousClick={handlePrevious}\n onNextClick={handleNext}\n actions={actionsPosition === \"controls\" && actions}\n />\n );\n\n const thumbnails = showThumbnails && (\n <HvCarouselThumbnails\n classes={classes}\n ref={thumbnailsRef}\n page={selectedIndex}\n pages={numSlides}\n width={thumbnailWidth}\n onThumbnailClick={(evt, i) => handleScroll(i)}\n renderThumbnail={renderThumbnail}\n />\n );\n\n return (\n <HvContainer\n className={cx(classes.root, className, {\n [classes.xs]: xs,\n [classes.fullscreen]: isFullscreen,\n })}\n {...others}\n >\n {showTitle && (\n <HvTypography variant=\"title2\" className={classes.title}>\n {title}\n </HvTypography>\n )}\n\n {actionsPosition === \"header\" && actions}\n {thumbnailsPosition === \"top\" && thumbnails}\n {controlsPosition === \"top\" && controls}\n <div\n className={cx(classes.main, {\n [classes.mainXs]: xs,\n [classes.mainFullscreen]: isFullscreen,\n })}\n >\n {showCounter && (\n <div className={classes.counterContainer}>\n <span className={classes.counter}>\n {`${selectedIndex + 1}/${numSlides}`}\n </span>\n </div>\n )}\n\n {showSlideControls && (\n <div className={classes.slideControls}>\n <HvButton\n icon\n disabled={!canPrev}\n variant=\"secondarySubtle\"\n aria-label=\"Backwards\"\n onClick={handlePrevious}\n >\n <Backwards iconSize=\"XS\" />\n </HvButton>\n <HvButton\n icon\n disabled={!canNext}\n variant=\"secondarySubtle\"\n aria-label=\"Forwards\"\n onClick={handleNext}\n >\n <Forwards iconSize=\"XS\" />\n </HvButton>\n </div>\n )}\n\n <div\n ref={containerRef}\n style={{ height }}\n className={classes.slidesViewport}\n >\n <div className={classes.slidesContainer}>{children}</div>\n </div>\n </div>\n {controlsPosition === \"bottom\" && controls}\n {thumbnailsPosition === \"bottom\" && thumbnails}\n </HvContainer>\n );\n};\n"],"names":["useDefaultProps","useTheme","useClasses","useRef","useState","useCarousel","Children","useCallback","useEffect","clamp","jsxs","jsx","HvIconButton","Close","Fullscreen","HvCarouselControls","HvCarouselThumbnails","HvContainer","HvTypography","HvButton","Backwards","Forwards"],"mappings":";;;;;;;;;;;;;;;;;;AA2Ea,MAAA,aAAa,CAAC,UAA2B;AAC9C,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,QAAQ,aAAa;AAAA,IACrB,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,UAAU;AAAA,IACV,aAAa;AAAA,IACb;AAAA,IACA,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,cAAc,KAAK;AACjC,QAAA,EAAE,gBAAgBC,SAAAA;AACxB,QAAM,EAAE,SAAS,KAAK,GAAG,IAAIC,gBAAAA,WAAW,WAAW;AAC7C,QAAA,gBAAgBC,aAAuB,IAAI;AACjD,QAAM,CAAC,cAAc,eAAe,IAAIC,eAAS,KAAK;AAEhD,QAAA,QAAQ,aAAa,SAAS;AAC9B,QAAA,kBAAkB,QAAQ,WAAW;AACrC,QAAA,mBAAmB,yBAAyB,QAAQ,WAAW;AACrE,QAAM,qBAAqB,0BAA0B;AAErD,QAAM,CAAC,cAAc,UAAU,IAAIC,6BAAY;AAAA,IAC7C,OAAO;AAAA,IACP,MAAM;AAAA,IACN,GAAG;AAAA,EAAA,CACJ;AAEK,QAAA,CAAC,eAAe,gBAAgB,IAAID,MAAA;AAAA,IACxC,iBAAiB,cAAc;AAAA,EAAA;AAG3B,QAAA,YAAYE,MAAAA,SAAS,MAAM,QAAQ;AAEnC,QAAA,iBAAiBC,MAAAA,YAAY,MAAM;AACvC,gBAAY,WAAW;AAAA,EAAA,GACtB,CAAC,UAAU,CAAC;AAET,QAAA,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,QACF;AAAA,QACC,qBAAqB,YAAY;AAAA,QACjC,uBAAuB,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;;;"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("@emotion/react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
6
+ const helpers = require("../utils/helpers.cjs");
6
7
  const useDefaultProps = require("../hooks/useDefaultProps.cjs");
7
8
  const DotPagination_styles = require("./DotPagination.styles.cjs");
8
9
  const RadioGroup = require("../RadioGroup/RadioGroup.cjs");
@@ -20,7 +21,6 @@ const getSelectorIcons = (radioIcon, radioCheckedIcon, classes) => {
20
21
  )
21
22
  };
22
23
  };
23
- const range = (n) => Array.from(Array(n), (_, i) => i);
24
24
  const HvDotPagination = (props) => {
25
25
  const {
26
26
  className,
@@ -44,7 +44,7 @@ const HvDotPagination = (props) => {
44
44
  },
45
45
  orientation: "horizontal",
46
46
  ...others,
47
- children: range(pages).map((i) => /* @__PURE__ */ jsxRuntime.jsx(
47
+ children: helpers.range(pages).map((i) => /* @__PURE__ */ jsxRuntime.jsx(
48
48
  Radio.HvRadio,
49
49
  {
50
50
  classes: {