@hitachivantara/uikit-react-core 5.56.0 → 5.58.0

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 (166) hide show
  1. package/dist/cjs/ActionsGeneric/ActionsGeneric.cjs +39 -21
  2. package/dist/cjs/ActionsGeneric/ActionsGeneric.cjs.map +1 -1
  3. package/dist/cjs/Banner/Banner.cjs +3 -0
  4. package/dist/cjs/Banner/Banner.cjs.map +1 -1
  5. package/dist/cjs/Banner/BannerContent/ActionContainer/ActionContainer.cjs +5 -2
  6. package/dist/cjs/Banner/BannerContent/ActionContainer/ActionContainer.cjs.map +1 -1
  7. package/dist/cjs/Banner/BannerContent/BannerContent.cjs +7 -3
  8. package/dist/cjs/Banner/BannerContent/BannerContent.cjs.map +1 -1
  9. package/dist/cjs/Banner/BannerContent/MessageContainer/MessageContainer.cjs +9 -4
  10. package/dist/cjs/Banner/BannerContent/MessageContainer/MessageContainer.cjs.map +1 -1
  11. package/dist/cjs/BulkActions/BulkActions.cjs +4 -1
  12. package/dist/cjs/BulkActions/BulkActions.cjs.map +1 -1
  13. package/dist/cjs/Button/Button.cjs +11 -0
  14. package/dist/cjs/Button/Button.cjs.map +1 -1
  15. package/dist/cjs/Button/Button.styles.cjs +71 -62
  16. package/dist/cjs/Button/Button.styles.cjs.map +1 -1
  17. package/dist/cjs/Button/types.cjs +9 -0
  18. package/dist/cjs/Button/types.cjs.map +1 -1
  19. package/dist/cjs/Calendar/model.cjs +23 -14
  20. package/dist/cjs/Calendar/model.cjs.map +1 -1
  21. package/dist/cjs/Calendar/utils.cjs +2 -3
  22. package/dist/cjs/Calendar/utils.cjs.map +1 -1
  23. package/dist/cjs/Carousel/Carousel.cjs +3 -3
  24. package/dist/cjs/Carousel/Carousel.cjs.map +1 -1
  25. package/dist/cjs/DotPagination/DotPagination.cjs +2 -2
  26. package/dist/cjs/DotPagination/DotPagination.cjs.map +1 -1
  27. package/dist/cjs/DropDownMenu/DropDownMenu.cjs +1 -0
  28. package/dist/cjs/DropDownMenu/DropDownMenu.cjs.map +1 -1
  29. package/dist/cjs/FileUploader/DropZone/DropZone.cjs +2 -4
  30. package/dist/cjs/FileUploader/DropZone/DropZone.cjs.map +1 -1
  31. package/dist/cjs/FilterGroup/FilterGroupContext.cjs +2 -4
  32. package/dist/cjs/FilterGroup/FilterGroupContext.cjs.map +1 -1
  33. package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs +1 -4
  34. package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs.map +1 -1
  35. package/dist/cjs/Grid/Grid.cjs +1 -3
  36. package/dist/cjs/Grid/Grid.cjs.map +1 -1
  37. package/dist/cjs/Loading/Loading.cjs +2 -4
  38. package/dist/cjs/Loading/Loading.cjs.map +1 -1
  39. package/dist/cjs/MultiButton/MultiButton.cjs +2 -1
  40. package/dist/cjs/MultiButton/MultiButton.cjs.map +1 -1
  41. package/dist/cjs/MultiButton/MultiButton.styles.cjs +3 -2
  42. package/dist/cjs/MultiButton/MultiButton.styles.cjs.map +1 -1
  43. package/dist/cjs/ProgressBar/ProgressBar.cjs +2 -4
  44. package/dist/cjs/ProgressBar/ProgressBar.cjs.map +1 -1
  45. package/dist/cjs/QueryBuilder/QueryBuilder.cjs +4 -8
  46. package/dist/cjs/QueryBuilder/QueryBuilder.cjs.map +1 -1
  47. package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +2 -3
  48. package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs.map +1 -1
  49. package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +4 -7
  50. package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs.map +1 -1
  51. package/dist/cjs/Snackbar/Snackbar.cjs +5 -3
  52. package/dist/cjs/Snackbar/Snackbar.cjs.map +1 -1
  53. package/dist/cjs/Snackbar/SnackbarContent/SnackbarContent.cjs +5 -2
  54. package/dist/cjs/Snackbar/SnackbarContent/SnackbarContent.cjs.map +1 -1
  55. package/dist/cjs/Stack/Stack.cjs +2 -6
  56. package/dist/cjs/Stack/Stack.cjs.map +1 -1
  57. package/dist/cjs/Table/TableCell/TableCell.cjs +3 -5
  58. package/dist/cjs/Table/TableCell/TableCell.cjs.map +1 -1
  59. package/dist/cjs/Table/TableHeader/TableHeader.cjs +4 -6
  60. package/dist/cjs/Table/TableHeader/TableHeader.cjs.map +1 -1
  61. package/dist/cjs/TreeView/internals/utils/EventManager.cjs +3 -5
  62. package/dist/cjs/TreeView/internals/utils/EventManager.cjs.map +1 -1
  63. package/dist/cjs/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.cjs +5 -7
  64. package/dist/cjs/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.cjs.map +1 -1
  65. package/dist/cjs/TreeView/internals/utils/TimerBasedCleanupTracking.cjs +2 -2
  66. package/dist/cjs/TreeView/internals/utils/TimerBasedCleanupTracking.cjs.map +1 -1
  67. package/dist/cjs/Typography/Typography.cjs +1 -0
  68. package/dist/cjs/Typography/Typography.cjs.map +1 -1
  69. package/dist/cjs/Typography/Typography.styles.cjs +1 -0
  70. package/dist/cjs/Typography/Typography.styles.cjs.map +1 -1
  71. package/dist/cjs/Typography/utils.cjs +1 -0
  72. package/dist/cjs/Typography/utils.cjs.map +1 -1
  73. package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs +3 -5
  74. package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs.map +1 -1
  75. package/dist/cjs/utils/Random.cjs +3 -0
  76. package/dist/cjs/utils/Random.cjs.map +1 -1
  77. package/dist/cjs/utils/classes.cjs +1 -1
  78. package/dist/cjs/utils/classes.cjs.map +1 -1
  79. package/dist/cjs/utils/helpers.cjs +33 -0
  80. package/dist/cjs/utils/helpers.cjs.map +1 -0
  81. package/dist/cjs/utils/setId.cjs +2 -4
  82. package/dist/cjs/utils/setId.cjs.map +1 -1
  83. package/dist/esm/ActionsGeneric/ActionsGeneric.js +39 -21
  84. package/dist/esm/ActionsGeneric/ActionsGeneric.js.map +1 -1
  85. package/dist/esm/Banner/Banner.js +3 -0
  86. package/dist/esm/Banner/Banner.js.map +1 -1
  87. package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js +5 -2
  88. package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js.map +1 -1
  89. package/dist/esm/Banner/BannerContent/BannerContent.js +7 -3
  90. package/dist/esm/Banner/BannerContent/BannerContent.js.map +1 -1
  91. package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.js +9 -4
  92. package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.js.map +1 -1
  93. package/dist/esm/BulkActions/BulkActions.js +4 -1
  94. package/dist/esm/BulkActions/BulkActions.js.map +1 -1
  95. package/dist/esm/Button/Button.js +12 -1
  96. package/dist/esm/Button/Button.js.map +1 -1
  97. package/dist/esm/Button/Button.styles.js +71 -62
  98. package/dist/esm/Button/Button.styles.js.map +1 -1
  99. package/dist/esm/Button/types.js +9 -0
  100. package/dist/esm/Button/types.js.map +1 -1
  101. package/dist/esm/Calendar/model.js +23 -14
  102. package/dist/esm/Calendar/model.js.map +1 -1
  103. package/dist/esm/Calendar/utils.js +1 -1
  104. package/dist/esm/Calendar/utils.js.map +1 -1
  105. package/dist/esm/Carousel/Carousel.js +3 -3
  106. package/dist/esm/Carousel/Carousel.js.map +1 -1
  107. package/dist/esm/DotPagination/DotPagination.js +1 -1
  108. package/dist/esm/DotPagination/DotPagination.js.map +1 -1
  109. package/dist/esm/DropDownMenu/DropDownMenu.js +1 -0
  110. package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
  111. package/dist/esm/FileUploader/DropZone/DropZone.js +1 -1
  112. package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
  113. package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
  114. package/dist/esm/FilterGroup/FilterGroupContext.js.map +1 -1
  115. package/dist/esm/FilterGroup/RightPanel/RightPanel.js +1 -2
  116. package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
  117. package/dist/esm/Grid/Grid.js +1 -2
  118. package/dist/esm/Grid/Grid.js.map +1 -1
  119. package/dist/esm/Loading/Loading.js +2 -2
  120. package/dist/esm/Loading/Loading.js.map +1 -1
  121. package/dist/esm/MultiButton/MultiButton.js +2 -1
  122. package/dist/esm/MultiButton/MultiButton.js.map +1 -1
  123. package/dist/esm/MultiButton/MultiButton.styles.js +3 -2
  124. package/dist/esm/MultiButton/MultiButton.styles.js.map +1 -1
  125. package/dist/esm/ProgressBar/ProgressBar.js +2 -2
  126. package/dist/esm/ProgressBar/ProgressBar.js.map +1 -1
  127. package/dist/esm/QueryBuilder/QueryBuilder.js +3 -4
  128. package/dist/esm/QueryBuilder/QueryBuilder.js.map +1 -1
  129. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +1 -1
  130. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
  131. package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +3 -4
  132. package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
  133. package/dist/esm/Snackbar/Snackbar.js +4 -1
  134. package/dist/esm/Snackbar/Snackbar.js.map +1 -1
  135. package/dist/esm/Snackbar/SnackbarContent/SnackbarContent.js +5 -2
  136. package/dist/esm/Snackbar/SnackbarContent/SnackbarContent.js.map +1 -1
  137. package/dist/esm/Stack/Stack.js +2 -4
  138. package/dist/esm/Stack/Stack.js.map +1 -1
  139. package/dist/esm/Table/TableCell/TableCell.js +1 -1
  140. package/dist/esm/Table/TableCell/TableCell.js.map +1 -1
  141. package/dist/esm/Table/TableHeader/TableHeader.js +1 -1
  142. package/dist/esm/Table/TableHeader/TableHeader.js.map +1 -1
  143. package/dist/esm/TreeView/internals/utils/EventManager.js +3 -5
  144. package/dist/esm/TreeView/internals/utils/EventManager.js.map +1 -1
  145. package/dist/esm/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js +5 -7
  146. package/dist/esm/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js.map +1 -1
  147. package/dist/esm/TreeView/internals/utils/TimerBasedCleanupTracking.js +2 -2
  148. package/dist/esm/TreeView/internals/utils/TimerBasedCleanupTracking.js.map +1 -1
  149. package/dist/esm/Typography/Typography.js +1 -0
  150. package/dist/esm/Typography/Typography.js.map +1 -1
  151. package/dist/esm/Typography/Typography.styles.js +1 -0
  152. package/dist/esm/Typography/Typography.styles.js.map +1 -1
  153. package/dist/esm/Typography/utils.js +1 -0
  154. package/dist/esm/Typography/utils.js.map +1 -1
  155. package/dist/esm/VerticalNavigation/Navigation/Navigation.js +1 -1
  156. package/dist/esm/VerticalNavigation/Navigation/Navigation.js.map +1 -1
  157. package/dist/esm/utils/Random.js +3 -0
  158. package/dist/esm/utils/Random.js.map +1 -1
  159. package/dist/esm/utils/classes.js +1 -1
  160. package/dist/esm/utils/classes.js.map +1 -1
  161. package/dist/esm/utils/helpers.js +33 -0
  162. package/dist/esm/utils/helpers.js.map +1 -0
  163. package/dist/esm/utils/setId.js +1 -1
  164. package/dist/esm/utils/setId.js.map +1 -1
  165. package/dist/types/index.d.ts +130 -90
  166. package/package.json +5 -6
@@ -8,26 +8,22 @@ const { staticClasses, useClasses } = createClasses("HvButton", {
8
8
  justifyContent: "center",
9
9
  textTransform: "none",
10
10
  cursor: "pointer",
11
- minWidth: "70px",
12
11
  whiteSpace: "nowrap",
13
- "&:hover:not($disabled)": {
12
+ // Background color common for almost all variants
13
+ "&:hover": {
14
14
  backgroundColor: theme.colors.containerBackgroundHover
15
15
  },
16
16
  "&:focus-visible": {
17
17
  ...outlineStyles,
18
- "&:not($disabled)": {
19
- backgroundColor: theme.colors.containerBackgroundHover
20
- }
18
+ backgroundColor: theme.colors.containerBackgroundHover
21
19
  },
22
20
  // Default button - no size specified
23
21
  fontFamily: theme.fontFamily.body,
24
- fontSize: theme.fontSizes.base,
25
- fontWeight: theme.fontWeights.semibold,
26
- lineHeight: "11px",
27
- letterSpacing: 0,
22
+ ...theme.typography.label,
28
23
  height: "32px",
24
+ border: "1px solid currentcolor",
29
25
  borderRadius: theme.radii.base,
30
- padding: theme.spacing("xs", "sm")
26
+ padding: theme.spacing(0, "sm")
31
27
  },
32
28
  startIcon: {
33
29
  marginLeft: `calc(-1 * ${theme.space.xs})`
@@ -37,85 +33,98 @@ const { staticClasses, useClasses } = createClasses("HvButton", {
37
33
  },
38
34
  focusVisible: {},
39
35
  disabled: {
36
+ cursor: "not-allowed",
40
37
  color: theme.colors.secondary_60,
41
- borderColor: theme.colors.atmo4,
42
- backgroundColor: theme.colors.atmo3,
43
- cursor: "not-allowed"
38
+ borderColor: "transparent",
39
+ backgroundColor: "transparent",
40
+ "&:hover, &:focus-visible": {
41
+ backgroundColor: "transparent",
42
+ borderColor: "transparent"
43
+ }
44
44
  },
45
45
  icon: {
46
46
  margin: 0,
47
47
  padding: 0,
48
48
  height: "fit-content",
49
- minWidth: "unset"
50
- },
51
- primary: {
52
- color: theme.colors.atmo1,
53
- backgroundColor: theme.colors.primary,
54
- "&:not($disabled)": {
55
- "&:hover, &:focus-visible": {
56
- backgroundColor: theme.colors.primary_80
57
- }
58
- }
59
- },
60
- primarySubtle: {
61
- color: theme.colors.primary,
62
- backgroundColor: "transparent",
63
- border: "1px solid currentColor"
64
- },
65
- primaryGhost: {
66
- color: theme.colors.primary,
67
- backgroundColor: "transparent",
68
- "&$disabled": {
69
- backgroundColor: "transparent"
49
+ "& > *": {
50
+ margin: -1
70
51
  }
71
52
  },
72
- secondarySubtle: {
73
- color: theme.colors.secondary,
74
- backgroundColor: "transparent",
75
- border: "1px solid currentColor"
76
- },
77
- secondaryGhost: {
78
- color: theme.colors.secondary,
79
- backgroundColor: "transparent",
80
- "&$disabled": {
81
- backgroundColor: "transparent"
82
- }
53
+ subtle: { backgroundColor: "transparent" },
54
+ ghost: {
55
+ borderColor: "transparent",
56
+ backgroundColor: "transparent"
83
57
  },
84
58
  semantic: {
85
59
  color: theme.colors.base_dark,
86
60
  backgroundColor: "transparent",
87
- "&:not($disabled)": {
88
- "&:hover, &:focus-visible": {
89
- backgroundColor: "rgba(251, 252, 252, 0.3)"
90
- }
61
+ borderColor: "transparent",
62
+ "&:hover, &:focus-visible": {
63
+ backgroundColor: "rgba(251, 252, 252, 0.3)"
91
64
  },
92
65
  "&$disabled": {
93
66
  backgroundColor: "rgba(251, 252, 252, 0.1)"
94
67
  }
95
68
  },
96
- secondary: {},
97
- ghost: {}
69
+ // TODO - remove in v6
70
+ primary: {},
71
+ primarySubtle: {},
72
+ primaryGhost: {},
73
+ secondarySubtle: {},
74
+ secondaryGhost: {},
75
+ // Deprecated (DS3)
76
+ secondary: {}
98
77
  });
78
+ const getColoringStyle = (color, type) => {
79
+ if (type)
80
+ return {
81
+ color: theme.colors[color !== "warning" ? color : `${color}_140`]
82
+ };
83
+ const bg = theme.colors[color !== "warning" ? color : `${color}_120`];
84
+ const hoverBg = theme.colors[color !== "warning" ? `${color}_80` : `${color}_140`];
85
+ return {
86
+ color: theme.colors.atmo1,
87
+ backgroundColor: bg,
88
+ borderColor: bg,
89
+ "&:hover, &:focus-visible": {
90
+ backgroundColor: hoverBg,
91
+ borderColor: hoverBg
92
+ }
93
+ };
94
+ };
99
95
  const getRadiusStyles = (radius) => ({
100
96
  borderRadius: theme.radii[radius]
101
97
  });
102
- const getSizeStyles = (size) => ({
103
- height: theme.sizes[size],
104
- paddingLeft: theme.space[size],
105
- paddingRight: theme.space[size],
106
- // @ts-ignore TODO: align font<-> button sizes
107
- fontSize: theme.fontSizes[size]
108
- });
109
- const getIconSizeStyles = (size) => ({
110
- height: theme.sizes[size],
111
- width: theme.sizes[size]
112
- });
98
+ const sizes = {
99
+ xs: { height: "24px", space: "sm", typography: "captionLabel" },
100
+ sm: { height: "24px", space: "sm", typography: "captionLabel" },
101
+ md: { height: "32px", space: "sm", typography: "label" },
102
+ lg: { height: "48px", space: "md", typography: "label" },
103
+ xl: { height: "48px", space: "md", typography: "label" }
104
+ };
105
+ const getSizeStyles = (size) => {
106
+ const { height, space, typography } = sizes[size];
107
+ const { color, ...typoProps } = theme.typography[typography];
108
+ return {
109
+ height,
110
+ padding: theme.spacing(0, space),
111
+ ...typoProps
112
+ };
113
+ };
114
+ const getIconSizeStyles = (size) => {
115
+ const { height } = sizes[size];
116
+ return {
117
+ height,
118
+ width: height
119
+ };
120
+ };
113
121
  const getOverrideColors = () => ({
114
122
  "& svg .color0": {
115
123
  fill: "currentcolor"
116
124
  }
117
125
  });
118
126
  export {
127
+ getColoringStyle,
119
128
  getIconSizeStyles,
120
129
  getOverrideColors,
121
130
  getRadiusStyles,
@@ -1 +1 @@
1
- {"version":3,"file":"Button.styles.js","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"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esContent":["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 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: \"transparent\",\n backgroundColor: \"transparent\",\n \"&:hover, &:focus-visible\": {\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n },\n },\n icon: {\n margin: 0,\n padding: 0,\n height: \"fit-content\",\n \"& > *\": {\n margin: -1,\n },\n },\n subtle: { backgroundColor: \"transparent\" },\n ghost: {\n borderColor: \"transparent\",\n backgroundColor: \"transparent\",\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":[],"mappings":";;;AAOO,MAAM,EAAE,eAAe,eAAe,cAAc,YAAY;AAAA,EACrE,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,YAAY;AAAA;AAAA,IAGZ,WAAW;AAAA,MACT,iBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,IACA,mBAAmB;AAAA,MACjB,GAAG;AA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B;AAAA,EACxD,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF;"}
@@ -2,6 +2,15 @@ const buttonVariant = [
2
2
  "primary",
3
3
  "primarySubtle",
4
4
  "primaryGhost",
5
+ "positive",
6
+ "positiveSubtle",
7
+ "positiveGhost",
8
+ "negative",
9
+ "negativeSubtle",
10
+ "negativeGhost",
11
+ "warning",
12
+ "warningSubtle",
13
+ "warningGhost",
5
14
  "secondarySubtle",
6
15
  "secondaryGhost",
7
16
  "semantic",
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","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.js","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;"}
@@ -1,22 +1,31 @@
1
1
  import { createDatesArray, isRange } from "./utils.js";
2
2
  class CalendarModel {
3
+ month;
4
+ year;
5
+ dates = [];
3
6
  constructor(month, year) {
4
- this.dates = [];
5
- this.updateModel = (month2, year2) => {
6
- let validMonth = month2;
7
- let validYear = year2;
8
- if (!Number.isInteger(validMonth)) {
9
- validMonth = (/* @__PURE__ */ new Date()).getMonth() + 1;
10
- }
11
- if (!Number.isInteger(validYear)) {
12
- validYear = (/* @__PURE__ */ new Date()).getFullYear();
13
- }
14
- this.month = validMonth;
15
- this.year = validYear;
16
- this.dates = createDatesArray(validMonth, validYear);
17
- };
18
7
  this.updateModel(month, year);
19
8
  }
9
+ /**
10
+ * Updates the model with the received month and year
11
+ *
12
+ * @param month - Number of the month (1 to 12).
13
+ * @param year - Number of the year.
14
+ * @memberOf CalendarModel
15
+ */
16
+ updateModel = (month, year) => {
17
+ let validMonth = month;
18
+ let validYear = year;
19
+ if (!Number.isInteger(validMonth)) {
20
+ validMonth = (/* @__PURE__ */ new Date()).getMonth() + 1;
21
+ }
22
+ if (!Number.isInteger(validYear)) {
23
+ validYear = (/* @__PURE__ */ new Date()).getFullYear();
24
+ }
25
+ this.month = validMonth;
26
+ this.year = validYear;
27
+ this.dates = createDatesArray(validMonth, validYear);
28
+ };
20
29
  }
21
30
  const generateModelFromDate = (seedValue) => {
22
31
  let calendarModel;
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","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"],"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,QAAQ,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,WACS,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.js","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":[],"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;AAAA;AAAA,EASA,cAAc,CAAC,OAAe,SAAiB;AAC7C,QAAI,aAAa;AACjB,QAAI,YAAY;AAChB,QAAI,CAAC,OAAO,UAAU,UAAU,GAAG;AACjC,oBAAiB,oBAAA,KAAO,GAAA,SAAA,IAAa;AAAA,IACvC;AACA,QAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AACpB,mBAAA,oBAAI,KAAK,GAAE,YAAY;AAAA,IACrC;AAEA,SAAK,QAAQ;AACb,SAAK,OAAO;AACP,SAAA,QAAQ,iBAAiB,YAAY,SAAS;AAAA,EAAA;AAEvD;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,WACS,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,5 +1,5 @@
1
1
  import dayjs from "dayjs";
2
- import capitalize from "lodash/capitalize";
2
+ import { capitalize } from "../utils/helpers.js";
3
3
  const CALENDAR_WEEKS = 6;
4
4
  const getMonthDays = (month, year) => new Date(year, month, 0).getDate();
5
5
  const getMonthFirstWeekday = (month, year) => new Date(year, month - 1, 1).getDay();
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","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":[],"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,IAAI,KAAK,KAAK,IAAI,MAAM,YAAY,KAAK,IAAI,CAAC;AAQ5C,MAAM,SAAS,CAAC,SACrB,OAAO,UAAU,SAAS,KAAK,IAAI,MAAM,mBACzC,CAAC,OAAO,MAAM,K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AAK,cAAc,MAAM,cAAc,QAAQ,GAAG,GAAG;AAAA,EAAA,CACjE;AAED,SAAO,CAAC,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,cAAc;AACpE;AAEa,MAAA,UAAU,CAAC,SACtB,QAAQ,QAAQ,OAAO,SAAS,YAAY,eAAe;AAShD,MAAA,2BAA2B,CACtC,MACA,uBACG;AACG,QAAA,EAAE,WAAW,QAAY,IAAA;AAE/B,MAAI,CAAC,QAAQ,kBAAkB,KAAK,WAAW;AAAa,WAAA;AAC5D,QAAM,eAAe;AAErB,QAAM,eAAe,MAAM,SAAS,EAAE,OAAO,YAAY;AACzD,QAAM,aAAa,MAAM,YAAY,EAAE,OAAO,YAAY;AAE1D,QAAM,gBAAgB,MAAM,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,cACjB,MAAM,WAAW,EAAE,OAAO,YAAY,IACtC;AACJ,QAAM,aAAa,cACf,MAAM,WAAW,EAAE,OAAO,YAAY,IACtC;AAEJ,QAAM,gBAAgB,MAAM,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;"}
1
+ {"version":3,"file":"utils.js","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 =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AAY,IACtC;AAEJ,QAAM,gBAAgB,MAAM,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;"}
@@ -4,15 +4,15 @@ import useCarousel from "embla-carousel-react";
4
4
  import { Close, Fullscreen, Backwards, Forwards } from "@hitachivantara/uikit-react-icons";
5
5
  import { useDefaultProps } from "../hooks/useDefaultProps.js";
6
6
  import { useTheme } from "../hooks/useTheme.js";
7
+ import { clamp } from "../utils/helpers.js";
7
8
  import { HvCarouselControls } from "./CarouselControls.js";
8
9
  import { HvCarouselThumbnails } from "./CarouselThumbnails.js";
9
10
  import { useClasses } from "./Carousel.styles.js";
10
11
  import { staticClasses } from "./Carousel.styles.js";
11
- import { HvIconButton } from "../IconButton/IconButton.js";
12
12
  import { HvContainer } from "../Container/Container.js";
13
13
  import { HvButton } from "../Button/Button.js";
14
+ import { HvIconButton } from "../IconButton/IconButton.js";
14
15
  import { HvTypography } from "../Typography/Typography.js";
15
- const clamp = (num, max, min = 0) => Math.min(Math.max(num, min), max);
16
16
  const HvCarousel = (props) => {
17
17
  const {
18
18
  className,
@@ -84,7 +84,7 @@ const HvCarousel = (props) => {
84
84
  if (!controller)
85
85
  return;
86
86
  controller.reInit();
87
- setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides, 0));
87
+ setSelectedIndex((currentIndex) => clamp(currentIndex, numSlides));
88
88
  }, [numSlides, controller]);
89
89
  const canPrev = controller?.canScrollPrev() ?? false;
90
90
  const canNext = controller?.canScrollNext() ?? false;
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.js","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":[],"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,I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AI;AAAA,oBACJ,UAAU,CAAC;AAAA,oBACX,SAAQ;AAAA,oBACR,cAAW;AAAA,oBACX,SAAS;AAAA,oBAET,UAAA,oBAAC,WAAU,EAAA,UAAS,KAAK,CAAA;AAAA,kBAAA;AAAA,gBAC3B;AAAA,gBACA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,UAAU,CAAC;AAAA,oBACX,SAAQ;AAAA,oBACR,cAAW;AAAA,oBACX,SAAS;AAAA,oBAET,UAAA,oBAAC,UAAS,EAAA,UAAS,KAAK,CAAA;AAAA,kBAAA;AAAA,gBAC1B;AAAA,cAAA,GACF;AAAA,cAGF;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,KAAK;AAAA,kBACL,OAAO,EAAE,OAAO;AAAA,kBAChB,WAAW,QAAQ;AAAA,kBAEnB,UAAC,oBAAA,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.js","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":[],"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,IACD,gBAAgB,cAAc,KAAK;AACjC,QAAA,EAAE,gBAAgB;AACxB,QAAM,EAAE,SAAS,KAAK,GAAG,IAAI,WAAW,WAAW;AAC7C,QAAA,gBAAgB,OAAuB,IAAI;AACjD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AAEhD,QAAA,QAAQ,aAAa,SAAS;AAC9B,QAAA,kBAAkB,QAAQ,WAAW;AACrC,QAAA,mBAAmB,yBAAyB,QAAQ,WAAW;AACrE,QAAM,qBAAqB,0BAA0B;AAErD,Q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A,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,6 +1,7 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
2
  import { cloneElement } from "react";
3
3
  import { OtherStep, CurrentStep } from "@hitachivantara/uikit-react-icons";
4
+ import { range } from "../utils/helpers.js";
4
5
  import { useDefaultProps } from "../hooks/useDefaultProps.js";
5
6
  import { useClasses } from "./DotPagination.styles.js";
6
7
  import { staticClasses } from "./DotPagination.styles.js";
@@ -19,7 +20,6 @@ const getSelectorIcons = (radioIcon, radioCheckedIcon, classes) => {
19
20
  )
20
21
  };
21
22
  };
22
- const range = (n) => Array.from(Array(n), (_, i) => i);
23
23
  const HvDotPagination = (props) => {
24
24
  const {
25
25
  className,
@@ -1 +1 @@
1
- {"version":3,"file":"DotPagination.js","sources":["../../../src/DotPagination/DotPagination.tsx"],"sourcesContent":["import { cloneElement } from \"react\";\nimport { CurrentStep, OtherStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvRadio } from \"../Radio\";\nimport { HvRadioGroup, HvRadioGroupProps } from \"../RadioGroup\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./DotPagination.styles\";\n\nexport { staticClasses as dotPaginationClasses };\n\nexport type HvDotPaginationClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDotPaginationProps\n extends Omit<HvRadioGroupProps, \"classes\"> {\n /**\n * Icon to override the default one used for the unselected state.\n *\n * The default icon is `OtherStep`.\n */\n unselectedIcon?: React.ReactElement;\n /**\n * Icon to override the default one used for the selected state.\n *\n * The default icon is `CurrentStep`.\n */\n selectedIcon?: React.ReactElement;\n /**\n * The number of pages the component has.\n */\n pages?: number;\n /**\n * The currently selected page.\n */\n page?: number;\n /**\n * The callback fired when the page value changes.\n */\n onPageChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n page: number\n ) => void;\n /**\n * The callback fired to get the page aria label.\n */\n getItemAriaLabel?: (page: number) => string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvDotPaginationClasses;\n}\n\nconst getSelectorIcons = (\n radioIcon?: React.ReactElement,\n radioCheckedIcon?: React.ReactElement,\n classes?: HvDotPaginationClasses\n) => {\n return {\n radio: cloneElement(radioIcon || <OtherStep width={8} height={8} />, {\n className: classes?.icon,\n }),\n radioChecked: cloneElement(\n radioCheckedIcon || <CurrentStep width={8} height={8} />,\n {\n className: classes?.icon,\n }\n ),\n };\n};\n\nconst range = (n: number) => Array.from(Array(n), (_, i) => i);\n\n/**\n * Pagination is the process of dividing a document into discrete pages. It relates to how users interact with structured content on a website or application.\n * This component uses Radio Buttons to represent each page.\n */\nexport const HvDotPagination = (props: HvDotPaginationProps) => {\n const {\n className,\n classes: classesProp,\n unselectedIcon,\n selectedIcon,\n pages = 1,\n page = 0,\n onPageChange,\n getItemAriaLabel,\n ...others\n } = useDefaultProps(\"HvDotPagination\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const icons = getSelectorIcons(unselectedIcon, selectedIcon, classes);\n\n return (\n <HvRadioGroup\n className={cx(classes.root, className)}\n classes={{\n horizontal: classes.horizontal,\n }}\n orientation=\"horizontal\"\n {...others}\n >\n {range(pages).map((i) => (\n <HvRadio\n classes={{\n radio: classes.radio,\n root: classes.radioRoot,\n }}\n key={i}\n value={i}\n checked={page === i}\n onChange={(event) => onPageChange?.(event, i)}\n icon={icons.radio}\n checkedIcon={icons.radioChecked}\n aria-label={getItemAriaLabel?.(i)}\n />\n ))}\n </HvRadioGroup>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAsDA,MAAM,mBAAmB,CACvB,WACA,kBACA,YACG;AACI,SAAA;AAAA,IACL,OAAO,aA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"version":3,"file":"DotPagination.js","sources":["../../../src/DotPagination/DotPagination.tsx"],"sourcesContent":["import { cloneElement } from \"react\";\nimport { CurrentStep, OtherStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvRadio } from \"../Radio\";\nimport { HvRadioGroup, HvRadioGroupProps } from \"../RadioGroup\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { range } from \"../utils/helpers\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./DotPagination.styles\";\n\nexport { staticClasses as dotPaginationClasses };\n\nexport type HvDotPaginationClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDotPaginationProps\n extends Omit<HvRadioGroupProps, \"classes\"> {\n /**\n * Icon to override the default one used for the unselected state.\n *\n * The default icon is `OtherStep`.\n */\n unselectedIcon?: React.ReactElement;\n /**\n * Icon to override the default one used for the selected state.\n *\n * The default icon is `CurrentStep`.\n */\n selectedIcon?: React.ReactElement;\n /**\n * The number of pages the component has.\n */\n pages?: number;\n /**\n * The currently selected page.\n */\n page?: number;\n /**\n * The callback fired when the page value changes.\n */\n onPageChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n page: number\n ) => void;\n /**\n * The callback fired to get the page aria label.\n */\n getItemAriaLabel?: (page: number) => string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvDotPaginationClasses;\n}\n\nconst getSelectorIcons = (\n radioIcon?: React.ReactElement,\n radioCheckedIcon?: React.ReactElement,\n classes?: HvDotPaginationClasses\n) => {\n return {\n radio: cloneElement(radioIcon || <OtherStep width={8} height={8} />, {\n className: classes?.icon,\n }),\n radioChecked: cloneElement(\n radioCheckedIcon || <CurrentStep width={8} height={8} />,\n {\n className: classes?.icon,\n }\n ),\n };\n};\n\n/**\n * Pagination is the process of dividing a document into discrete pages. It relates to how users interact with structured content on a website or application.\n * This component uses Radio Buttons to represent each page.\n */\nexport const HvDotPagination = (props: HvDotPaginationProps) => {\n const {\n className,\n classes: classesProp,\n unselectedIcon,\n selectedIcon,\n pages = 1,\n page = 0,\n onPageChange,\n getItemAriaLabel,\n ...others\n } = useDefaultProps(\"HvDotPagination\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const icons = getSelectorIcons(unselectedIcon, selectedIcon, classes);\n\n return (\n <HvRadioGroup\n className={cx(classes.root, className)}\n classes={{\n horizontal: classes.horizontal,\n }}\n orientation=\"horizontal\"\n {...others}\n >\n {range(pages).map((i) => (\n <HvRadio\n classes={{\n radio: classes.radio,\n root: classes.radioRoot,\n }}\n key={i}\n value={i}\n checked={page === i}\n onChange={(event) => onPageChange?.(event, i)}\n icon={icons.radio}\n checkedIcon={icons.radioChecked}\n aria-label={getItemAriaLabel?.(i)}\n />\n ))}\n </HvRadioGroup>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAuDA,MAAM,mBAAmB,CACvB,WACA,kBACA,YACG;AACI,SAAA;AAAA,IACL,OAAO,aAAa,aAAa,oBAAC,aAAU,OAAO,GAAG,QAAQ,EAAA,CAAG,GAAI;AAAA,MACnE,WAAW,SAAS;AAAA,IAAA,CACrB;AAAA,IACD,cAAc;AAAA,MACZ,oBAAqB,oBAAA,aAAA,EAAY,OAAO,GAAG,QAAQ,GAAG;AAAA,MACtD;AAAA,QACE,WAAW,SAAS;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;AAMa,MAAA,kBAAkB,CAAC,UAAgC;AACxD,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,mBAAmB,KAAK;AAE5C,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,QAAQ,iBAAiB,gBAAgB,cAAc,OAAO;AAGlE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,MACrC,SAAS;AAAA,QACP,YAAY,QAAQ;AAAA,MACtB;AAAA,MACA,aAAY;AAAA,MACX,GAAG;AAAA,MAEH,UAAM,MAAA,KAAK,EAAE,IAAI,CAAC,MACjB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,SAAS;AAAA,YACP,OAAO,QAAQ;AAAA,YACf,MAAM,QAAQ;AAAA,UAChB;AAAA,UAEA,OAAO;AAAA,UACP,SAAS,SAAS;AAAA,UAClB,UAAU,CAAC,UAAU,eAAe,OAAO,CAAC;AAAA,UAC5C,MAAM,MAAM;AAAA,UACZ,aAAa,MAAM;AAAA,UACnB,cAAY,mBAAmB,CAAC;AAAA,QAAA;AAAA,QAN3B;AAAA,MAAA,CAQR;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -30,6 +30,7 @@ const HvDropDownMenu = (props) => {
30
30
  expanded,
31
31
  defaultExpanded = false,
32
32
  category = "secondaryGhost",
33
+ // TODO - remove and update variant default in v6
33
34
  variant,
34
35
  size,
35
36
  ...others
@@ -1 +1 @@
1
- {"version":3,"file":"DropDownMenu.js","sources":["../../../src/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { ChangeEvent, useMemo } from \"react\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { getPrevNextFocus } from \"../utils/focusableElementFinder\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport { HvButton, HvButtonSize, HvButtonVariant } from \"../Button\";\nimport { HvList, HvListProps, HvListValue } from \"../List\";\nimport { HvPanel } from \"../Panel\";\n\nimport { staticClasses, useClasses } from \"./DropDownMenu.styles\";\nimport { getIconSizeStyles } from \"../Button/Button.styles\";\n\nexport { staticClasses as dropDownMenuClasses };\n\nexport type HvDropDownMenuClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (event: Event, open: boolean) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event: React.ChangeEvent<HTMLLIElement>,\n value: HvListValue\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /**\n * The variant to be used in the header.\n * @deprecated Use `variant` instead\n */\n category?: HvButtonVariant;\n /** The variant to be used in the header. */\n variant?: HvButtonVariant;\n /** Button size. */\n size?: HvButtonSize;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n}\n\n/**\n * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nexport const HvDropDownMenu = (props: HvDropDownMenuProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\",\n variant,\n size,\n ...others\n } = useDefaultProps(\"HvDropDownMenu\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const id = useUniqueId(idProp, \"dropdown-menu\");\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (event: ChangeEvent) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event as any, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown: HvListProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Tab\")) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event as any);\n }\n event.preventDefault();\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n\n return (\n <HvBaseDropdown\n id={id}\n className={cx(classes.container, className)}\n classes={{\n root: classes.root,\n container: classes.baseContainer,\n }}\n expanded={open && !disabled}\n component={\n <HvButton\n icon\n variant={variant ?? category}\n id={setId(id, \"icon-button\")}\n className={cx(\n classes.icon,\n { [classes.iconSelected]: open },\n size && icon && css(getIconSizeStyles(size))\n )}\n aria-expanded={open}\n disabled={disabled}\n size={size}\n aria-label=\"Dropdown menu\"\n aria-haspopup=\"menu\"\n >\n {icon || (\n <MoreOptionsVertical\n aria-hidden\n color={disabled ? \"secondary_60\" : undefined}\n />\n )}\n </HvButton>\n }\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n {...others}\n >\n <HvPanel className={classes.menuListRoot}>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?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A,GAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"DropDownMenu.js","sources":["../../../src/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { ChangeEvent, useMemo } from \"react\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { getPrevNextFocus } from \"../utils/focusableElementFinder\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport { HvButton, HvButtonSize, HvButtonVariant } from \"../Button\";\nimport { HvList, HvListProps, HvListValue } from \"../List\";\nimport { HvPanel } from \"../Panel\";\nimport { staticClasses, useClasses } from \"./DropDownMenu.styles\";\nimport { getIconSizeStyles } from \"../Button/Button.styles\";\n\nexport { staticClasses as dropDownMenuClasses };\n\nexport type HvDropDownMenuClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (event: Event, open: boolean) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event: React.ChangeEvent<HTMLLIElement>,\n value: HvListValue\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /**\n * The variant to be used in the header.\n * @deprecated Use `variant` instead\n */\n category?: HvButtonVariant;\n /** The variant to be used in the header. */\n variant?: HvButtonVariant;\n /** Button size. */\n size?: HvButtonSize;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n}\n\n/**\n * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nexport const HvDropDownMenu = (props: HvDropDownMenuProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\", // TODO - remove and update variant default in v6\n variant,\n size,\n ...others\n } = useDefaultProps(\"HvDropDownMenu\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const id = useUniqueId(idProp, \"dropdown-menu\");\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (event: ChangeEvent) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event as any, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown: HvListProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Tab\")) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event as any);\n }\n event.preventDefault();\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n\n return (\n <HvBaseDropdown\n id={id}\n className={cx(classes.container, className)}\n classes={{\n root: classes.root,\n container: classes.baseContainer,\n }}\n expanded={open && !disabled}\n component={\n <HvButton\n icon\n variant={variant ?? category}\n id={setId(id, \"icon-button\")}\n className={cx(\n classes.icon,\n { [classes.iconSelected]: open },\n size && icon && css(getIconSizeStyles(size))\n )}\n aria-expanded={open}\n disabled={disabled}\n size={size}\n aria-label=\"Dropdown menu\"\n aria-haspopup=\"menu\"\n >\n {icon || (\n <MoreOptionsVertical\n aria-hidden\n color={disabled ? \"secondary_60\" : undefined}\n />\n )}\n </HvButton>\n }\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n {...others}\n >\n <HvPanel className={classes.menuListRoot}>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?.(event, item);\n }}\n onKeyDown={handleKeyDown}\n classes={{\n root: classes.menuList,\n }}\n />\n </HvPanel>\n </HvBaseDropdown>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuEa,MAAA,iBAAiB,CAAC,UAA+B;AACtD,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,WAAW;AAAA,IACX;AAAA,IACA,kBAAkB;AAAA,IAClB,WAAW;AAAA;AAAA,IACX;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,kBAAkB,KAAK;AAE3C,QAAM,EAAE,SAAS,IAAI,IAAI,IAAI,WAAW,WAAW;AAC7C,QAAA,CAAC,MAAM,OAAO,IAAI,cAAc,UAAU,QAAQ,eAAe,CAA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AA,YAAA;AAAA,cACC,eAAW;AAAA,cACX,OAAO,WAAW,iBAAiB;AAAA,YAAA;AAAA,UACrC;AAAA,QAAA;AAAA,MAEJ;AAAA,MAEF;AAAA,MACA,eAAa;AAAA,MACb;AAAA,MACA,UAAU,CAAC,GAAG,MAAM;AAElB,gBAAQ,CAAC;AACT,mBAAW,GAAG,CAAC;AAAA,MACjB;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,MACpB,GAAG;AAAA,MAEJ,UAAC,oBAAA,SAAA,EAAQ,WAAW,QAAQ,cAC1B,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAI;AAAA,UACJ,QAAQ;AAAA,UACR,YAAY;AAAA,UACZ;AAAA,UACA,SAAS,CAAC,OAAO,SAAS;AACxB,gBAAI,CAAC;AAAY,0BAAY,KAAK;AAClC,sBAAU,OAAO,IAAI;AAAA,UACvB;AAAA,UACA,WAAW;AAAA,UACX,SAAS;AAAA,YACP,MAAM,QAAQ;AAAA,UAChB;AAAA,QAAA;AAAA,MAAA,GAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,9 +1,9 @@
1
1
  import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
2
2
  import { useState, useRef } from "react";
3
- import uniqueId from "lodash/uniqueId";
4
3
  import { Doc } from "@hitachivantara/uikit-react-icons";
5
4
  import { setId } from "../../utils/setId.js";
6
5
  import { useUniqueId } from "../../hooks/useUniqueId.js";
6
+ import { uniqueId } from "../../utils/helpers.js";
7
7
  import { useDefaultProps } from "../../hooks/useDefaultProps.js";
8
8
  import { convertUnits } from "../utils.js";
9
9
  import { useClasses } from "./DropZone.styles.js";