@hitachivantara/uikit-react-core 5.87.2 → 5.88.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 (127) hide show
  1. package/dist/cjs/ActionsGeneric/ActionsGeneric.cjs +1 -1
  2. package/dist/cjs/Banner/BannerContent/BannerContent.cjs +1 -1
  3. package/dist/cjs/BaseInput/BaseInput.cjs +44 -83
  4. package/dist/cjs/BaseInput/BaseInput.styles.cjs +68 -142
  5. package/dist/cjs/BaseInput/validations.cjs +2 -1
  6. package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +0 -6
  7. package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.styles.cjs +1 -5
  8. package/dist/cjs/ColorPicker/ColorPicker.cjs +1 -1
  9. package/dist/cjs/DatePicker/DatePicker.cjs +12 -12
  10. package/dist/cjs/Dropdown/Dropdown.cjs +8 -10
  11. package/dist/cjs/FilterGroup/FilterContent/FilterContent.cjs +1 -1
  12. package/dist/cjs/FormElement/Adornment/Adornment.cjs +15 -36
  13. package/dist/cjs/FormElement/Adornment/Adornment.styles.cjs +11 -17
  14. package/dist/cjs/InlineEditor/InlineEditor.cjs +10 -14
  15. package/dist/cjs/InlineEditor/InlineEditor.styles.cjs +13 -36
  16. package/dist/cjs/Input/Input.cjs +33 -56
  17. package/dist/cjs/Input/Input.styles.cjs +6 -19
  18. package/dist/cjs/List/List.cjs +12 -12
  19. package/dist/cjs/Pagination/Pagination.styles.cjs +2 -1
  20. package/dist/cjs/Pagination/Select.cjs +1 -1
  21. package/dist/cjs/Select/Select.styles.cjs +1 -1
  22. package/dist/cjs/Table/TableBody/TableBody.cjs +16 -17
  23. package/dist/cjs/TableSection/TableSection.styles.cjs +10 -10
  24. package/dist/cjs/Tag/Tag.cjs +1 -1
  25. package/dist/cjs/TagsInput/TagsInput.cjs +103 -169
  26. package/dist/cjs/TagsInput/TagsInput.styles.cjs +45 -111
  27. package/dist/cjs/TextArea/TextArea.cjs +1 -3
  28. package/dist/cjs/TextArea/TextArea.styles.cjs +1 -1
  29. package/dist/cjs/TimePicker/TimePicker.cjs +5 -4
  30. package/dist/cjs/TimePicker/Unit/Unit.cjs +0 -1
  31. package/dist/cjs/TimePicker/Unit/Unit.styles.cjs +0 -3
  32. package/dist/cjs/hooks/useFocus.cjs +38 -0
  33. package/dist/cjs/utils/CounterLabel.cjs +3 -2
  34. package/dist/cjs/utils/focusUtils.cjs +0 -4
  35. package/dist/esm/ActionsGeneric/ActionsGeneric.js +1 -1
  36. package/dist/esm/AvatarGroup/AvatarGroupContext.js +1 -1
  37. package/dist/esm/Banner/BannerContent/BannerContent.js +1 -1
  38. package/dist/esm/BaseCheckBox/BaseCheckBox.js +1 -1
  39. package/dist/esm/BaseDropdown/BaseDropdown.js +3 -3
  40. package/dist/esm/BaseInput/BaseInput.js +45 -84
  41. package/dist/esm/BaseInput/BaseInput.js.map +1 -1
  42. package/dist/esm/BaseInput/BaseInput.styles.js +68 -142
  43. package/dist/esm/BaseInput/BaseInput.styles.js.map +1 -1
  44. package/dist/esm/BaseInput/validations.js +2 -1
  45. package/dist/esm/BaseInput/validations.js.map +1 -1
  46. package/dist/esm/BaseRadio/BaseRadio.js +1 -1
  47. package/dist/esm/Button/Button.js +1 -1
  48. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +1 -7
  49. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
  50. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.styles.js +1 -5
  51. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.styles.js.map +1 -1
  52. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
  53. package/dist/esm/ColorPicker/ColorPicker.js +1 -1
  54. package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
  55. package/dist/esm/ColorPicker/Fields/Fields.js.map +1 -1
  56. package/dist/esm/DatePicker/DatePicker.js.map +1 -1
  57. package/dist/esm/DatePicker/utils.js +1 -1
  58. package/dist/esm/Dialog/context.js +1 -1
  59. package/dist/esm/DotPagination/DotPagination.js +1 -1
  60. package/dist/esm/Dropdown/Dropdown.js +8 -10
  61. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  62. package/dist/esm/DropdownButton/DropdownButton.js.map +1 -1
  63. package/dist/esm/FilterGroup/FilterContent/FilterContent.js +1 -1
  64. package/dist/esm/FilterGroup/FilterContent/FilterContent.js.map +1 -1
  65. package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
  66. package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
  67. package/dist/esm/Focus/Focus.js +1 -1
  68. package/dist/esm/FormElement/Adornment/Adornment.js +15 -36
  69. package/dist/esm/FormElement/Adornment/Adornment.js.map +1 -1
  70. package/dist/esm/FormElement/Adornment/Adornment.styles.js +11 -17
  71. package/dist/esm/FormElement/Adornment/Adornment.styles.js.map +1 -1
  72. package/dist/esm/Header/Navigation/useSelectionPath.js.map +1 -1
  73. package/dist/esm/InlineEditor/InlineEditor.js +10 -14
  74. package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
  75. package/dist/esm/InlineEditor/InlineEditor.styles.js +13 -36
  76. package/dist/esm/InlineEditor/InlineEditor.styles.js.map +1 -1
  77. package/dist/esm/Input/Input.js +34 -57
  78. package/dist/esm/Input/Input.js.map +1 -1
  79. package/dist/esm/Input/Input.styles.js +6 -19
  80. package/dist/esm/Input/Input.styles.js.map +1 -1
  81. package/dist/esm/List/List.js +12 -12
  82. package/dist/esm/List/List.js.map +1 -1
  83. package/dist/esm/Pagination/Pagination.styles.js +5 -4
  84. package/dist/esm/Pagination/Pagination.styles.js.map +1 -1
  85. package/dist/esm/Pagination/Select.js +1 -1
  86. package/dist/esm/QueryBuilder/Context.js +1 -1
  87. package/dist/esm/QueryBuilder/QueryBuilder.js +1 -1
  88. package/dist/esm/QueryBuilder/utils/index.js +1 -1
  89. package/dist/esm/RadioGroup/RadioGroup.js.map +1 -1
  90. package/dist/esm/Select/Select.styles.js +1 -1
  91. package/dist/esm/Select/Select.styles.js.map +1 -1
  92. package/dist/esm/SelectionList/SelectionList.js.map +1 -1
  93. package/dist/esm/Slider/Slider.js +1 -1
  94. package/dist/esm/Slider/Slider.js.map +1 -1
  95. package/dist/esm/SnackbarProvider/SnackbarProvider.js +2 -2
  96. package/dist/esm/Table/TableBody/TableBody.js +16 -17
  97. package/dist/esm/Table/TableBody/TableBody.js.map +1 -1
  98. package/dist/esm/TableSection/TableSection.styles.js +24 -24
  99. package/dist/esm/Tag/Tag.js +1 -1
  100. package/dist/esm/Tag/Tag.js.map +1 -1
  101. package/dist/esm/TagsInput/TagsInput.js +103 -169
  102. package/dist/esm/TagsInput/TagsInput.js.map +1 -1
  103. package/dist/esm/TagsInput/TagsInput.styles.js +45 -111
  104. package/dist/esm/TagsInput/TagsInput.styles.js.map +1 -1
  105. package/dist/esm/TextArea/TextArea.js +1 -3
  106. package/dist/esm/TextArea/TextArea.js.map +1 -1
  107. package/dist/esm/TextArea/TextArea.styles.js +1 -1
  108. package/dist/esm/TextArea/TextArea.styles.js.map +1 -1
  109. package/dist/esm/TimePicker/TimePicker.js +1 -0
  110. package/dist/esm/TimePicker/TimePicker.js.map +1 -1
  111. package/dist/esm/TimePicker/Unit/Unit.js +0 -1
  112. package/dist/esm/TimePicker/Unit/Unit.js.map +1 -1
  113. package/dist/esm/TimePicker/Unit/Unit.styles.js +0 -3
  114. package/dist/esm/TimePicker/Unit/Unit.styles.js.map +1 -1
  115. package/dist/esm/TreeView/internals/TreeViewProvider.js +1 -1
  116. package/dist/esm/TreeView/internals/hooks/plugins/useTreeViewKeyboardNavigation.js +1 -1
  117. package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
  118. package/dist/esm/hooks/useFocus.js +38 -0
  119. package/dist/esm/hooks/useFocus.js.map +1 -0
  120. package/dist/esm/hooks/useScrollTo.js.map +1 -1
  121. package/dist/esm/utils/CounterLabel.js +3 -2
  122. package/dist/esm/utils/CounterLabel.js.map +1 -1
  123. package/dist/esm/utils/document.js.map +1 -1
  124. package/dist/esm/utils/focusUtils.js +0 -4
  125. package/dist/esm/utils/focusUtils.js.map +1 -1
  126. package/dist/types/index.d.ts +213 -274
  127. package/package.json +8 -8
@@ -3,176 +3,99 @@ import { theme } from "@hitachivantara/uikit-styles";
3
3
  import { outlineStyles } from "../utils/focusUtils.js";
4
4
  const { staticClasses, useClasses } = createClasses("HvBaseInput", {
5
5
  root: {
6
- display: "inline-block",
7
- width: "100%",
8
- position: "relative",
9
- "&:hover $inputBorderContainer": {
10
- backgroundColor: theme.colors.primary
11
- },
12
- "&:focus-within $inputBorderContainer": {
13
- backgroundColor: theme.colors.primary
14
- }
15
- },
16
- disabled: {
17
- "& $inputRoot": {
18
- backgroundColor: theme.colors.atmo2,
19
- borderColor: theme.colors.secondary_60
20
- },
21
- "& $inputBorderContainer": {
22
- backgroundColor: theme.colors.atmo4
23
- },
24
- "&:hover $inputBorderContainer": {
25
- backgroundColor: theme.colors.atmo4
26
- },
27
- "&& $input": {
28
- color: theme.colors.secondary_60,
29
- WebkitTextFillColor: theme.colors.secondary_60
30
- },
31
- "& $inputRootMultiline": {
32
- "& $input": {
33
- backgroundColor: theme.colors.atmo2,
34
- border: `1px solid ${theme.colors.secondary_60}`
6
+ // #region `input` style reset
7
+ "input:-webkit-autofill": {
8
+ WebkitBoxShadow: `0 0 0px 1000px ${theme.colors.atmo1} inset`,
9
+ WebkitTextFillColor: theme.colors.secondary
10
+ },
11
+ // Clears number input up/down arrows in Chrome and Firefox
12
+ "input[type=number]": {
13
+ MozAppearance: "textfield",
14
+ "&::-webkit-outer-spin-button,&::-webkit-inner-spin-button": {
15
+ WebkitAppearance: "none",
16
+ margin: 0
35
17
  }
36
18
  },
37
- "&:hover $inputRootMultiline": {
38
- "& $input": {
39
- backgroundColor: theme.colors.atmo2,
40
- border: `1px solid ${theme.colors.secondary_60}`
41
- }
42
- }
43
- },
44
- invalid: {
45
- "&:not(.disabled)": {
46
- "& $inputBorderContainer": {
47
- backgroundColor: theme.colors.negative_120
48
- },
49
- "&:hover $inputBorderContainer": {
50
- backgroundColor: theme.colors.negative_120
51
- },
52
- "& $inputRootMultiline": {
53
- "& $input": {
54
- border: `1px solid ${theme.colors.negative_120}`
55
- }
56
- },
57
- "&:hover $inputRootMultiline": {
58
- "& $input": {
59
- border: `1px solid ${theme.colors.negative_120}`
60
- }
61
- },
62
- "&:focus-within $inputRootMultiline": {
63
- "& $input": {
64
- border: `1px solid ${theme.colors.negative_120}`
65
- }
66
- }
67
- }
68
- },
69
- resizable: { width: "auto" },
70
- readOnly: {
71
- "& $inputBorderContainer": {
72
- backgroundColor: "transparent"
73
- },
74
- "&:hover $inputBorderContainer": {
75
- backgroundColor: "transparent"
76
- },
77
- "&:focus-within $inputBorderContainer": {
78
- backgroundColor: "transparent"
79
- },
80
- "& $inputRootMultiline": {
81
- "& $input": {
82
- border: `1px solid ${theme.colors.secondary_60}`,
83
- backgroundColor: theme.colors.atmo2
84
- }
19
+ // Clears time input clock in Chrome
20
+ "input::-webkit-calendar-picker-indicator": {
21
+ display: "none"
85
22
  },
86
- "&:hover $inputRootMultiline": {
87
- "& $input": {
88
- border: `1px solid ${theme.colors.secondary_60}`,
89
- backgroundColor: theme.colors.atmo2
90
- }
23
+ // Clears search input clear button in Chrome
24
+ "input[type=search]::-webkit-search-decoration,input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-results-button,input[type=search]::-webkit-search-results-decoration": {
25
+ display: "none"
91
26
  },
92
- "&:focus-within $inputRootMultiline": {
93
- "& $input": {
94
- border: `1px solid ${theme.colors.secondary_60}`,
95
- backgroundColor: theme.colors.atmo2
96
- }
97
- }
98
- },
99
- inputBorderContainer: {
100
- position: "absolute",
101
- width: "calc(100% - 4px)",
102
- height: "0px",
103
- top: "31px",
104
- left: "2px",
105
- backgroundColor: theme.colors.atmo4
106
- },
107
- inputRootInvalid: { borderColor: theme.colors.negative_120 },
108
- inputRootReadOnly: {
109
- borderColor: theme.colors.secondary_60,
110
- backgroundColor: theme.colors.atmo2
111
- },
112
- inputRoot: {
113
- margin: 0,
27
+ // #endregion
28
+ display: "inline-flex",
114
29
  width: "100%",
30
+ position: "relative",
31
+ margin: 0,
115
32
  borderRadius: theme.radii.base,
116
33
  height: "32px",
117
- border: `1px solid ${theme.colors.secondary}`,
34
+ borderWidth: 1,
35
+ borderColor: theme.colors.secondary,
118
36
  boxSizing: "border-box",
119
37
  backgroundColor: theme.colors.atmo1,
120
38
  fontFamily: theme.fontFamily.body,
121
- "&:hover:not($inputRootDisabled):not($inputRootInvalid):not($inputRootReadOnly)": {
39
+ ":hover:not($disabled,$invalid,$readOnly)": {
122
40
  borderColor: theme.colors.primary
123
41
  },
124
- "&:hover:not($inputRootDisabled)::before": {
125
- borderBottom: "none"
126
- },
127
- "&::before": {
128
- borderBottom: "none"
129
- },
130
- "&::after": {
131
- borderBottom: "none"
132
- }
133
- },
134
- inputRootFocused: {
135
- backgroundColor: theme.colors.atmo1,
136
- ...outlineStyles,
137
- "&:hover": {
138
- backgroundColor: theme.colors.atmo1
139
- },
140
- "&$inputRootReadOnly": {
141
- backgroundColor: theme.colors.atmo2
42
+ ":focus-within:not($disabled)": {
43
+ ...outlineStyles
142
44
  }
143
45
  },
144
- inputRootDisabled: {
46
+ disabled: {
47
+ backgroundColor: theme.colors.atmo2,
48
+ borderColor: theme.colors.secondary_60,
145
49
  cursor: "not-allowed",
146
50
  "&&::before": {
147
51
  borderBottomStyle: "none"
148
52
  }
149
53
  },
150
- inputRootMultiline: {
54
+ invalid: {
55
+ borderColor: theme.colors.negative_120
56
+ },
57
+ multiline: {
151
58
  padding: 0,
152
- backgroundColor: "transparent",
153
59
  overflow: "auto",
154
- border: "none",
155
60
  height: "auto",
156
61
  "& $input": {
157
- border: `1px solid ${theme.colors.secondary}`,
158
62
  borderRadius: theme.radii.base,
159
- backgroundColor: theme.colors.atmo1,
160
63
  height: "auto",
161
64
  minHeight: "21px",
162
65
  padding: "5px 10px",
163
66
  overflow: "auto",
164
- marginLeft: "0px",
165
- marginRight: "0px",
166
- "&:hover": {
167
- border: `1px solid ${theme.colors.primary}`
168
- }
67
+ margin: 0
169
68
  }
170
69
  },
70
+ resizable: { width: "auto" },
71
+ readOnly: {
72
+ borderColor: theme.colors.secondary_60,
73
+ backgroundColor: theme.colors.atmo2
74
+ },
75
+ focused: {},
76
+ /** @deprecated unused. use `::after` instead */
77
+ inputBorderContainer: {},
78
+ /** @deprecated use `classes.invalid` instead */
79
+ inputRootInvalid: { borderColor: theme.colors.negative_120 },
80
+ /** @deprecated use `classes.readOnly` instead */
81
+ inputRootReadOnly: {
82
+ borderColor: theme.colors.secondary_60,
83
+ backgroundColor: theme.colors.atmo2
84
+ },
85
+ /** @deprecated use `classes.root` instead */
86
+ inputRoot: {},
87
+ /** @deprecated unused */
88
+ inputRootFocused: {},
89
+ /** @deprecated use `classes.disabled` instead */
90
+ inputRootDisabled: {},
91
+ /** @deprecated use `classes.multiline` instead */
92
+ inputRootMultiline: {},
171
93
  input: {
172
- height: "19px",
94
+ height: "100%",
173
95
  marginLeft: theme.space.xs,
174
96
  marginRight: theme.space.xs,
175
- padding: "6px 0 5px",
97
+ padding: 0,
98
+ backgroundColor: "transparent",
176
99
  overflow: "hidden",
177
100
  textOverflow: "ellipsis",
178
101
  outline: "none",
@@ -182,16 +105,19 @@ const { staticClasses, useClasses } = createClasses("HvBaseInput", {
182
105
  "&::placeholder": {
183
106
  opacity: 1,
184
107
  color: theme.colors.secondary_80
185
- },
186
- "&::-ms-clear": {
187
- display: "none"
188
108
  }
189
109
  },
190
- inputDisabled: {},
110
+ inputDisabled: {
111
+ color: theme.colors.secondary_60,
112
+ WebkitTextFillColor: theme.colors.secondary_60
113
+ },
191
114
  inputReadOnly: {
192
115
  color: theme.colors.secondary_80
193
116
  },
194
- inputResizable: { resize: "both", width: "100%" }
117
+ inputResizable: {
118
+ resize: "both",
119
+ width: "100%"
120
+ }
195
121
  });
196
122
  export {
197
123
  staticClasses,
@@ -1 +1 @@
1
- {"version":3,"file":"BaseInput.styles.js","sources":["../../../src/BaseInput/BaseInput.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBaseInput\", {\n root: {\n display: \"inline-block\",\n width: \"100%\",\n position: \"relative\",\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n },\n disabled: {\n \"& $inputRoot\": {\n backgroundColor: theme.colors.atmo2,\n borderColor: theme.colors.secondary_60,\n },\n\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&& $input\": {\n color: theme.colors.secondary_60,\n WebkitTextFillColor: theme.colors.secondary_60,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n },\n invalid: {\n \"&:not(.disabled)\": {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.negative_120,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.negative_120,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative_120}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative_120}`,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative_120}`,\n },\n },\n },\n },\n resizable: { width: \"auto\" },\n readOnly: {\n \"& $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n },\n inputBorderContainer: {\n position: \"absolute\",\n width: \"calc(100% - 4px)\",\n height: \"0px\",\n top: \"31px\",\n left: \"2px\",\n backgroundColor: theme.colors.atmo4,\n },\n inputRootInvalid: { borderColor: theme.colors.negative_120 },\n inputRootReadOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: theme.colors.atmo2,\n },\n inputRoot: {\n margin: 0,\n width: \"100%\",\n borderRadius: theme.radii.base,\n height: \"32px\",\n border: `1px solid ${theme.colors.secondary}`,\n boxSizing: \"border-box\",\n backgroundColor: theme.colors.atmo1,\n fontFamily: theme.fontFamily.body,\n\n \"&:hover:not($inputRootDisabled):not($inputRootInvalid):not($inputRootReadOnly)\":\n {\n borderColor: theme.colors.primary,\n },\n\n \"&:hover:not($inputRootDisabled)::before\": {\n borderBottom: \"none\",\n },\n\n \"&::before\": {\n borderBottom: \"none\",\n },\n\n \"&::after\": {\n borderBottom: \"none\",\n },\n },\n inputRootFocused: {\n backgroundColor: theme.colors.atmo1,\n ...outlineStyles,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"&$inputRootReadOnly\": {\n backgroundColor: theme.colors.atmo2,\n },\n },\n inputRootDisabled: {\n cursor: \"not-allowed\",\n\n \"&&::before\": {\n borderBottomStyle: \"none\",\n },\n },\n inputRootMultiline: {\n padding: 0,\n backgroundColor: \"transparent\",\n overflow: \"auto\",\n border: \"none\",\n height: \"auto\",\n\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary}`,\n borderRadius: theme.radii.base,\n backgroundColor: theme.colors.atmo1,\n height: \"auto\",\n minHeight: \"21px\",\n padding: \"5px 10px\",\n overflow: \"auto\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n\n \"&:hover\": {\n border: `1px solid ${theme.colors.primary}`,\n },\n },\n },\n input: {\n height: \"19px\",\n marginLeft: theme.space.xs,\n marginRight: theme.space.xs,\n padding: \"6px 0 5px\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n outline: \"none\",\n width: \"initial\",\n flexGrow: 1,\n ...(theme.typography.body as React.CSSProperties),\n\n \"&::placeholder\": {\n opacity: 1,\n color: theme.colors.secondary_80,\n },\n\n \"&::-ms-clear\": {\n display: \"none\",\n },\n },\n inputDisabled: {},\n inputReadOnly: {\n color: theme.colors.secondary_80,\n },\n inputResizable: { resize: \"both\", width: \"100%\" },\n});\n"],"names":[],"mappings":";;;AAKO,MAAM,EAAE,eAAe,eAAe,cAAc,eAAe;AAAA,EACxE,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IAEV,iCAAiC;AAAA,MAC/B,iBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,IAEA,wCAAwC;AAAA,MACtC,iBAAiB,MAAM,OAAO;AAAA,IAAA;AAAA,EAElC;AAAA,EACA,UAAU;AAAA,IACR,gBAAgB;AAAA,MACd,iBAAiB,MAAM,OAAO;AAAA,MAC9B,aAAa,MAAM,OAAO;AAAA,IAC5B;AAAA,IAEA,2BAA2B;AAAA,MACzB,iBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,IAEA,iCAAiC;AAAA,MAC/B,iBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,IAEA,aAAa;AAAA,MACX,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AAmB;AAAA,IACjB,QAAQ;AAAA,IAER,cAAc;AAAA,MACZ,mBAAmB;AAAA,IAAA;AAAA,EAEvB;AAAA,EACA,oBAAoB;AAAA,IAClB,SAAS;AAAA,IACT,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ;AAAA,IAER,YAAY;AAAA,MACV,QAAQ,aAAa,MAAM,OAAO,SAAS;AAAA,MAC3C,cAAc,MAAM,MAAM;AAAA,MAC1B,iBAAiB,MAAM,OAAO;AAAA,MAC9B,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,SAAS;AAAA,MACT,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,aAAa;AAAA,MAEb,WAAW;AAAA,QACT,QAAQ,aAAa,MAAM,OAAO,OAAO;AAAA,MAAA;AAAA,IAC3C;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,YAAY,MAAM,MAAM;AAAA,IACxB,aAAa,MAAM,MAAM;AAAA,IACzB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,cAAc;AAAA,IACd,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,GAAI,MAAM,WAAW;AAAA,IAErB,kBAAkB;AAAA,MAChB,SAAS;AAAA,MACT,OAAO,MAAM,OAAO;AAAA,IACtB;AAAA,IAEA,gBAAgB;AAAA,MACd,SAAS;AAAA,IAAA;AAAA,EAEb;AAAA,EACA,eAAe,CAAC;AAAA,EAChB,eAAe;AAAA,IACb,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,gBAAgB,EAAE,QAAQ,QAAQ,OAAO,OAAO;AAClD,CAAC;"}
1
+ {"version":3,"file":"BaseInput.styles.js","sources":["../../../src/BaseInput/BaseInput.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBaseInput\", {\n root: {\n // #region `input` style reset\n \"input:-webkit-autofill\": {\n WebkitBoxShadow: `0 0 0px 1000px ${theme.colors.atmo1} inset`,\n WebkitTextFillColor: theme.colors.secondary,\n },\n\n // Clears number input up/down arrows in Chrome and Firefox\n \"input[type=number]\": {\n MozAppearance: \"textfield\",\n \"&::-webkit-outer-spin-button,&::-webkit-inner-spin-button\": {\n WebkitAppearance: \"none\",\n margin: 0,\n },\n },\n\n // Clears time input clock in Chrome\n \"input::-webkit-calendar-picker-indicator\": {\n display: \"none\",\n },\n\n // Clears search input clear button in Chrome\n \"input[type=search]::-webkit-search-decoration,input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-results-button,input[type=search]::-webkit-search-results-decoration\":\n {\n display: \"none\",\n },\n // #endregion\n\n display: \"inline-flex\",\n width: \"100%\",\n position: \"relative\",\n margin: 0,\n borderRadius: theme.radii.base,\n height: \"32px\",\n borderWidth: 1,\n borderColor: theme.colors.secondary,\n boxSizing: \"border-box\",\n backgroundColor: theme.colors.atmo1,\n fontFamily: theme.fontFamily.body,\n\n \":hover:not($disabled,$invalid,$readOnly)\": {\n borderColor: theme.colors.primary,\n },\n \":focus-within:not($disabled)\": {\n ...outlineStyles,\n },\n },\n disabled: {\n backgroundColor: theme.colors.atmo2,\n borderColor: theme.colors.secondary_60,\n\n cursor: \"not-allowed\",\n\n \"&&::before\": {\n borderBottomStyle: \"none\",\n },\n },\n invalid: {\n borderColor: theme.colors.negative_120,\n },\n multiline: {\n padding: 0,\n overflow: \"auto\",\n height: \"auto\",\n\n \"& $input\": {\n borderRadius: theme.radii.base,\n height: \"auto\",\n minHeight: \"21px\",\n padding: \"5px 10px\",\n overflow: \"auto\",\n margin: 0,\n },\n },\n resizable: { width: \"auto\" },\n readOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: theme.colors.atmo2,\n },\n focused: {},\n /** @deprecated unused. use `::after` instead */\n inputBorderContainer: {},\n /** @deprecated use `classes.invalid` instead */\n inputRootInvalid: { borderColor: theme.colors.negative_120 },\n /** @deprecated use `classes.readOnly` instead */\n inputRootReadOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: theme.colors.atmo2,\n },\n /** @deprecated use `classes.root` instead */\n inputRoot: {},\n /** @deprecated unused */\n inputRootFocused: {},\n /** @deprecated use `classes.disabled` instead */\n inputRootDisabled: {},\n /** @deprecated use `classes.multiline` instead */\n inputRootMultiline: {},\n input: {\n height: \"100%\",\n marginLeft: theme.space.xs,\n marginRight: theme.space.xs,\n padding: 0,\n backgroundColor: \"transparent\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n outline: \"none\",\n width: \"initial\",\n flexGrow: 1,\n ...theme.typography.body,\n\n \"&::placeholder\": {\n opacity: 1,\n color: theme.colors.secondary_80,\n },\n },\n inputDisabled: {\n color: theme.colors.secondary_60,\n WebkitTextFillColor: theme.colors.secondary_60,\n },\n inputReadOnly: {\n color: theme.colors.secondary_80,\n },\n inputResizable: {\n resize: \"both\",\n width: \"100%\",\n },\n});\n"],"names":[],"mappings":";;;AAKO,MAAM,EAAE,eAAe,eAAe,cAAc,eAAe;AAAA,EACxE,MAAM;AAAA;AAAA,IAEJ,0BAA0B;AAAA,MACxB,iBAAiB,kBAAkB,MAAM,OAAO,KAAK;AAAA,MACrD,qBAAqB,MAAM,OAAO;AAAA,IACpC;AAAA;AAAA,IAGA,sBAAsB;AAAA,MACpB,eAAe;AAAA,MACf,6DAA6D;AAAA,QAC3D,kBAAkB;AAAA,QAClB,QAAQ;AAAA,MAAA;AAAA,IAEZ;AAAA;AAAA,IAGA,4CAA4C;AAAA,MAC1C,SAAS;AAAA,IACX;AAAA;AAAA,IAGA,0MACE;AAAA,MACE,SAAS;AAAA,IACX;AAAA;AAAA,IAGF,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc,MAAM,MAAM;AAAA,IAC1B,QAAQ;AAAA,IACR,a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AM;AAAA,IACxB,aAAa,MAAM,MAAM;AAAA,IACzB,SAAS;AAAA,IACT,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,GAAG,MAAM,WAAW;AAAA,IAEpB,kBAAkB;AAAA,MAChB,SAAS;AAAA,MACT,OAAO,MAAM,OAAO;AAAA,IAAA;AAAA,EAExB;AAAA,EACA,eAAe;AAAA,IACb,OAAO,MAAM,OAAO;AAAA,IACpB,qBAAqB,MAAM,OAAO;AAAA,EACpC;AAAA,EACA,eAAe;AAAA,IACb,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,gBAAgB;AAAA,IACd,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAEX,CAAC;"}
@@ -47,7 +47,7 @@ const computeValidationMessage = (inputValidity, errorMessages) => {
47
47
  }
48
48
  return errorMessages.error;
49
49
  };
50
- const validateInput = (input, value, required, minCharQuantity, maxCharQuantity, validationType, validation) => {
50
+ const validateInput = (input, required, minCharQuantity, maxCharQuantity, validationType, validation) => {
51
51
  const inputValidity = {
52
52
  valid: input?.validity?.valid ?? true,
53
53
  badInput: input?.validity?.badInput,
@@ -61,6 +61,7 @@ const validateInput = (input, value, required, minCharQuantity, maxCharQuantity,
61
61
  typeMismatch: input?.validity?.typeMismatch,
62
62
  valueMissing: input?.validity?.valueMissing
63
63
  };
64
+ const value = input?.value;
64
65
  if (!value) {
65
66
  if (required) {
66
67
  inputValidity.valueMissing = true;
@@ -1 +1 @@
1
- {"version":3,"file":"validations.js","sources":["../../../src/BaseInput/validations.ts"],"sourcesContent":["import { InputBaseComponentProps } from \"@mui/material/InputBase\";\n\nimport { validationStates } from \"../FormElement\";\n\n/** Checks if the value is a number. */\nconst isNumeric = (num: string) =>\n // to prevent Number( <spaces> ) = 0\n num.trim().length > 0 && !Number.isNaN(Number(num));\n\n/** Checks if the value is an email */\nconst isEmail = (email: string) => {\n const regexp =\n /^[^\\\\s]+[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?[.])+[a-z0-9](?:[a-z0-9-]*[a-z0-9])$/i;\n return regexp.test(email);\n};\n\nexport const validationTypes = Object.freeze({\n none: \"none\",\n number: \"number\",\n email: \"email\",\n});\n\n/** Returns the input's validation type based in the type of the input. */\nexport const computeValidationType = (type: React.HTMLInputTypeAttribute) => {\n switch (type) {\n case \"number\":\n return validationTypes.number;\n case \"email\":\n return validationTypes.email;\n\n default:\n return validationTypes.none;\n }\n};\n\n/**\n * Checks whether any integrated validation, native or not, is active.\n */\nexport const hasBuiltInValidations = (\n required: boolean | undefined,\n validationType: React.HTMLInputTypeAttribute,\n minCharQuantity: number | null | undefined,\n maxCharQuantity: number | null | undefined,\n validation?: (value: string) => boolean,\n inputProps?: InputBaseComponentProps,\n) =>\n required ||\n validationType !== validationTypes.none ||\n minCharQuantity != null ||\n maxCharQuantity != null ||\n validation != null ||\n inputProps?.required != null ||\n inputProps?.minLength != null ||\n inputProps?.maxLength != null ||\n inputProps?.min != null ||\n inputProps?.max != null ||\n (inputProps?.type != null &&\n inputProps?.type !== \"text\" &&\n inputProps?.type !== \"password\") ||\n inputProps?.pattern != null;\n\n/** Returns the form element's validation state based in the validity state of the input. */\nexport const computeValidationState = (\n inputValidity: HvInputValidity,\n isEmptyValue: boolean,\n) => {\n // to keep 2.x behaviour,\n // consider that if the value is empty (and not required) we're returning to the standBy state.\n // might not make sense, as it makes impossible to say if the user explicitly cleared the input.\n if (inputValidity.valid && isEmptyValue) {\n return validationStates.standBy;\n }\n\n return inputValidity.valid\n ? validationStates.valid\n : validationStates.invalid;\n};\n\n/**\n * Returns a error message based in the validity state of the input.\n *\n * Only one error message is returned even if multiple validations fail.\n * Also, only required, minCharQuantity, maxCharQuantity and validationType have specific error messages.\n *\n * For further customization both status and statusMessage should be controlled and\n * set using the onBlur callback that receives both the value and the input validity object.\n */\nexport const computeValidationMessage = (\n inputValidity: HvInputValidity,\n /** The available localized error messages. */\n errorMessages: Record<string, string>,\n) => {\n if (inputValidity.valid) {\n return \"\";\n }\n\n if (inputValidity.valueMissing) {\n return errorMessages.requiredError;\n }\n if (inputValidity.tooLong) {\n return errorMessages.maxCharError;\n }\n if (inputValidity.tooShort) {\n return errorMessages.minCharError;\n }\n if (inputValidity.typeMismatch) {\n return errorMessages.typeMismatchError;\n }\n\n return errorMessages.error;\n};\n\n/**\n * Returns a object describing the validity state of the input.\n *\n * It implements the native browser's ValidityState interface:\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\nexport const validateInput = (\n input: HTMLInputElement | HTMLTextAreaElement | null,\n value: string,\n required: boolean | undefined,\n minCharQuantity: any,\n maxCharQuantity: any,\n validationType: string,\n validation?: (value: string) => boolean,\n): HvInputValidity => {\n // bootstrap validity object using browser's built-in validation\n const inputValidity: HvInputValidity = {\n valid: input?.validity?.valid ?? true,\n badInput: input?.validity?.badInput,\n customError: input?.validity?.customError,\n patternMismatch: input?.validity?.patternMismatch,\n rangeOverflow: input?.validity?.rangeOverflow,\n rangeUnderflow: input?.validity?.rangeUnderflow,\n stepMismatch: input?.validity?.stepMismatch,\n tooLong: input?.validity?.tooLong,\n tooShort: input?.validity?.tooShort,\n typeMismatch: input?.validity?.typeMismatch,\n valueMissing: input?.validity?.valueMissing,\n };\n\n if (!value) {\n if (required) {\n // this is redundant because we're setting the required property in the native input\n inputValidity.valueMissing = true;\n inputValidity.valid = false;\n }\n } else {\n // we're not setting minlength and maxlength in the native input\n // to avoid different browser's behaviours and keep the user experience consistent\n if (minCharQuantity !== null && value.length < minCharQuantity) {\n inputValidity.tooShort = true;\n inputValidity.valid = false;\n }\n\n if (maxCharQuantity !== null && value.length > maxCharQuantity) {\n inputValidity.tooLong = true;\n inputValidity.valid = false;\n }\n\n // the validationType is used instead of type\n // for the same reason stated above\n switch (validationType) {\n case validationTypes.number:\n if (!isNumeric(value)) {\n inputValidity.typeMismatch = true;\n inputValidity.valid = false;\n }\n break;\n\n case validationTypes.email:\n if (!isEmail(value)) {\n inputValidity.typeMismatch = true;\n inputValidity.valid = false;\n }\n break;\n\n default:\n }\n\n if (validation != null && !validation(value)) {\n inputValidity.customError = true;\n inputValidity.valid = false;\n }\n }\n\n return inputValidity;\n};\n\ntype Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\nexport interface HvInputValidity extends Partial<Mutable<ValidityState>> {}\n\nexport const DEFAULT_ERROR_MESSAGES = {\n error: \"Invalid value\",\n requiredError: \"The value is required\",\n minCharError: \"The value is too short\",\n maxCharError: \"The value is too long\",\n typeMismatchError: \"Invalid value\",\n};\n"],"names":[],"mappings":";AAKA,MAAM,YAAY,CAAC;AAAA;AAAA,EAEjB,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC,OAAO,MAAM,OAAO,GAAG,CAAC;AAAA;AAGpD,MAAM,UAAU,CAAC,UAAkB;AACjC,QAAM,SACJ;AACK,SAAA,OAAO,KAAK,KAAK;AAC1B;AAEa,MAAA,kBAAkB,OAAO,OAAO;AAAA,EAC3C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACT,CAAC;AAGY,MAAA,wBAAwB,CAAC,SAAuC;AAC3E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,gBAAgB;AAAA,IACzB,KAAK;AACH,aAAO,gBAAgB;AAAA,IAEzB;AACE,aAAO,gBAAgB;AAAA,EAAA;AAE7B;AAKO,MAAM,wBAAwB,CACnC,UACA,gBACA,iBACA,iBACA,YACA,eAEA,YACA,mBAAmB,gBAAgB,QACnC,mBAAmB,QACnB,mBAAmB,QACnB,cAAc,QACd,YAAY,YAAY,QACxB,YAAY,aAAa,QACzB,YAAY,aAAa,QACzB,YAAY,OAAO,QACnB,YAAY,OAAO,QAClB,YAAY,QAAQ,QACnB,YAAY,SAAS,UACrB,YAAY,SAAS,cACvB,YAAY,WAAW;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c,QAAQ;AAAA,IAAA;AAKxB,YAAQ,gBAAgB;AAAA,MACtB,KAAK,gBAAgB;AACf,YAAA,CAAC,UAAU,KAAK,GAAG;AACrB,wBAAc,eAAe;AAC7B,wBAAc,QAAQ;AAAA,QAAA;AAExB;AAAA,MAEF,KAAK,gBAAgB;AACf,YAAA,CAAC,QAAQ,KAAK,GAAG;AACnB,wBAAc,eAAe;AAC7B,wBAAc,QAAQ;AAAA,QAAA;AAExB;AAAA,IAEF;AAGF,QAAI,cAAc,QAAQ,CAAC,WAAW,KAAK,GAAG;AAC5C,oBAAc,cAAc;AAC5B,oBAAc,QAAQ;AAAA,IAAA;AAAA,EACxB;AAGK,SAAA;AACT;AAMO,MAAM,yBAAyB;AAAA,EACpC,OAAO;AAAA,EACP,eAAe;AAAA,EACf,cAAc;AAAA,EACd,cAAc;AAAA,EACd,mBAAmB;AACrB;"}
1
+ {"version":3,"file":"validations.js","sources":["../../../src/BaseInput/validations.ts"],"sourcesContent":["import { InputBaseComponentProps } from \"@mui/material/InputBase\";\n\nimport { validationStates } from \"../FormElement\";\n\n/** Checks if the value is a number. */\nconst isNumeric = (num: string) =>\n // to prevent Number( <spaces> ) = 0\n num.trim().length > 0 && !Number.isNaN(Number(num));\n\n/** Checks if the value is an email */\nconst isEmail = (email: string) => {\n const regexp =\n /^[^\\\\s]+[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?[.])+[a-z0-9](?:[a-z0-9-]*[a-z0-9])$/i;\n return regexp.test(email);\n};\n\nexport const validationTypes = Object.freeze({\n none: \"none\",\n number: \"number\",\n email: \"email\",\n});\n\n/** Returns the input's validation type based in the type of the input. */\nexport const computeValidationType = (type: React.HTMLInputTypeAttribute) => {\n switch (type) {\n case \"number\":\n return validationTypes.number;\n case \"email\":\n return validationTypes.email;\n\n default:\n return validationTypes.none;\n }\n};\n\n/**\n * Checks whether any integrated validation, native or not, is active.\n */\nexport const hasBuiltInValidations = (\n required: boolean | undefined,\n validationType: React.HTMLInputTypeAttribute,\n minCharQuantity: number | null | undefined,\n maxCharQuantity: number | null | undefined,\n validation?: (value: string) => boolean,\n inputProps?: InputBaseComponentProps,\n) =>\n required ||\n validationType !== validationTypes.none ||\n minCharQuantity != null ||\n maxCharQuantity != null ||\n validation != null ||\n inputProps?.required != null ||\n inputProps?.minLength != null ||\n inputProps?.maxLength != null ||\n inputProps?.min != null ||\n inputProps?.max != null ||\n (inputProps?.type != null &&\n inputProps?.type !== \"text\" &&\n inputProps?.type !== \"password\") ||\n inputProps?.pattern != null;\n\n/** Returns the form element's validation state based in the validity state of the input. */\nexport const computeValidationState = (\n inputValidity: HvInputValidity,\n isEmptyValue: boolean,\n) => {\n // to keep 2.x behaviour,\n // consider that if the value is empty (and not required) we're returning to the standBy state.\n // might not make sense, as it makes impossible to say if the user explicitly cleared the input.\n if (inputValidity.valid && isEmptyValue) {\n return validationStates.standBy;\n }\n\n return inputValidity.valid\n ? validationStates.valid\n : validationStates.invalid;\n};\n\n/**\n * Returns a error message based in the validity state of the input.\n *\n * Only one error message is returned even if multiple validations fail.\n * Also, only required, minCharQuantity, maxCharQuantity and validationType have specific error messages.\n *\n * For further customization both status and statusMessage should be controlled and\n * set using the onBlur callback that receives both the value and the input validity object.\n */\nexport const computeValidationMessage = (\n inputValidity: HvInputValidity,\n /** The available localized error messages. */\n errorMessages: Record<string, string>,\n) => {\n if (inputValidity.valid) {\n return \"\";\n }\n\n if (inputValidity.valueMissing) {\n return errorMessages.requiredError;\n }\n if (inputValidity.tooLong) {\n return errorMessages.maxCharError;\n }\n if (inputValidity.tooShort) {\n return errorMessages.minCharError;\n }\n if (inputValidity.typeMismatch) {\n return errorMessages.typeMismatchError;\n }\n\n return errorMessages.error;\n};\n\n/**\n * Returns a object describing the validity state of the input.\n *\n * It implements the native browser's ValidityState interface:\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\nexport const validateInput = (\n input: HTMLInputElement | HTMLTextAreaElement | null,\n required: boolean | undefined,\n minCharQuantity: any,\n maxCharQuantity: any,\n validationType: string,\n validation?: (value: string) => boolean,\n): HvInputValidity => {\n // bootstrap validity object using browser's built-in validation\n const inputValidity: HvInputValidity = {\n valid: input?.validity?.valid ?? true,\n badInput: input?.validity?.badInput,\n customError: input?.validity?.customError,\n patternMismatch: input?.validity?.patternMismatch,\n rangeOverflow: input?.validity?.rangeOverflow,\n rangeUnderflow: input?.validity?.rangeUnderflow,\n stepMismatch: input?.validity?.stepMismatch,\n tooLong: input?.validity?.tooLong,\n tooShort: input?.validity?.tooShort,\n typeMismatch: input?.validity?.typeMismatch,\n valueMissing: input?.validity?.valueMissing,\n };\n\n const value = input?.value;\n\n if (!value) {\n if (required) {\n // this is redundant because we're setting the required property in the native input\n inputValidity.valueMissing = true;\n inputValidity.valid = false;\n }\n } else {\n // we're not setting minlength and maxlength in the native input\n // to avoid different browser's behaviours and keep the user experience consistent\n if (minCharQuantity !== null && value.length < minCharQuantity) {\n inputValidity.tooShort = true;\n inputValidity.valid = false;\n }\n\n if (maxCharQuantity !== null && value.length > maxCharQuantity) {\n inputValidity.tooLong = true;\n inputValidity.valid = false;\n }\n\n // the validationType is used instead of type\n // for the same reason stated above\n switch (validationType) {\n case validationTypes.number:\n if (!isNumeric(value)) {\n inputValidity.typeMismatch = true;\n inputValidity.valid = false;\n }\n break;\n\n case validationTypes.email:\n if (!isEmail(value)) {\n inputValidity.typeMismatch = true;\n inputValidity.valid = false;\n }\n break;\n\n default:\n }\n\n if (validation != null && !validation(value)) {\n inputValidity.customError = true;\n inputValidity.valid = false;\n }\n }\n\n return inputValidity;\n};\n\ntype Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\nexport interface HvInputValidity extends Partial<Mutable<ValidityState>> {}\n\nexport const DEFAULT_ERROR_MESSAGES = {\n error: \"Invalid value\",\n requiredError: \"The value is required\",\n minCharError: \"The value is too short\",\n maxCharError: \"The value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IAAA;AAAA,EACxB;AAGK,SAAA;AACT;AAMO,MAAM,yBAAyB;AAAA,EACpC,OAAO;AAAA,EACP,eAAe;AAAA,EACf,cAAc;AAAA,EACd,cAAc;AAAA,EACd,mBAAmB;AACrB;"}
@@ -4,7 +4,7 @@ import MuiRadio from "@mui/material/Radio";
4
4
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
5
5
  import { useClasses } from "./BaseRadio.styles.js";
6
6
  import { staticClasses } from "./BaseRadio.styles.js";
7
- import { Unselected, Selected } from "./icons.js";
7
+ import { Selected, Unselected } from "./icons.js";
8
8
  const getSelectorIcons = () => {
9
9
  return {
10
10
  radio: /* @__PURE__ */ jsx(Unselected, {}),
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from "react";
3
3
  import { useDefaultProps, mergeStyles } from "@hitachivantara/uikit-react-utils";
4
- import { getColor, theme } from "@hitachivantara/uikit-styles";
4
+ import { theme, getColor } from "@hitachivantara/uikit-styles";
5
5
  import { fixedForwardRef } from "../types/generic.js";
6
6
  import { useClasses, getIconSizeStyles, getSizeStyles, getOverrideColors } from "./Button.styles.js";
7
7
  import { staticClasses } from "./Button.styles.js";
@@ -3,7 +3,7 @@ import { useContext, useState, useEffect } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { isKey } from "../../utils/keyboardUtils.js";
5
5
  import { setId } from "../../utils/setId.js";
6
- import { isRange, getLocaleDateFormat, isDate, getFormattedDate, DEFAULT_LOCALE, getStringFromDate, parseDateString, isSameDay } from "../utils.js";
6
+ import { DEFAULT_LOCALE, isRange, getLocaleDateFormat, isDate, getFormattedDate, getStringFromDate, parseDateString, isSameDay } from "../utils.js";
7
7
  import { useClasses } from "./CalendarHeader.styles.js";
8
8
  import { staticClasses } from "./CalendarHeader.styles.js";
9
9
  import { HvInput } from "../../Input/Input.js";
@@ -106,12 +106,6 @@ const HvCalendarHeader = (props) => {
106
106
  {
107
107
  type: "text",
108
108
  id: setId(id, "header-input"),
109
- className: classes.headerDate,
110
- classes: {
111
- input: classes.input,
112
- inputBorderContainer: classes.inputBorderContainer,
113
- error: classes.invalidMessageStyling
114
- },
115
109
  placeholder: localeFormat,
116
110
  value: inputValue,
117
111
  "aria-labelledby": label?.[0]?.id,
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarHeader.js","sources":["../../../../src/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useContext, useEffect, useState } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvFormElementContext,\n HvFormElementDescriptorsContext,\n} from \"../../FormElement\";\nimport { HvInput, HvInputProps } from \"../../Input\";\nimport { HvTypography } from \"../../Typography\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\nimport type { HvSingleCalendarProps } from \"../SingleCalendar\";\nimport {\n DEFAULT_LOCALE,\n getFormattedDate,\n getLocaleDateFormat,\n getStringFromDate,\n isDate,\n isRange,\n isSameDay,\n parseDateString,\n} from \"../utils\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id: idProp,\n value: valueProp,\n locale = DEFAULT_LOCALE,\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n } = useDefaultProps(\"HvCalendarHeader\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n const localValue = isRange(valueProp)\n ? showEndDate\n ? valueProp.endDate!\n : valueProp.startDate\n : valueProp;\n\n const [dateValue, setDateValue] = useState(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const id = idProp ?? setId(context.id, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = getLocaleDateFormat(locale);\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (inputValue && isDate(new Date(inputValue))),\n );\n\n const validateInput = (incomingValid: any) =>\n incomingValid === undefined || isDate(new Date(incomingValid));\n\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(getFormattedDate(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event: any, date: string) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = parseDateString(date, locale);\n\n const isValidInput = isDate(localeParsedDate);\n const dateParsed = isValidInput ? localeParsedDate : new Date(date);\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler: HvInputProps[\"onBlur\"] = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler: HvInputProps[\"onKeyDown\"] = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler: HvInputProps[\"onFocus\"] = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? getStringFromDate(localValue, locale)\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler: HvInputProps[\"onChange\"] = (event, val) => {\n setEditedValue(val);\n };\n\n const isInvalid = !isValidValue && inputValue !== \"\";\n\n // This component needs to be further refactored\n // It's not possible to clear the date\n // In a new major there's no need for all these classes\n return (\n <div\n id={id}\n className={cx(classes.root, {\n [classes.invalid]: isInvalid,\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n <HvInput\n type=\"text\"\n id={setId(id, \"header-input\")}\n className={classes.headerDate}\n classes={{\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n error: classes.invalidMessageStyling,\n }}\n placeholder={localeFormat}\n value={inputValue}\n aria-labelledby={label?.[0]?.id}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={invalidDateLabel}\n />\n </div>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps\n extends Pick<\n HvSingleCalendarProps,\n | \"id\"\n | \"value\"\n | \"locale\"\n | \"onChange\"\n | \"showEndDate\"\n | \"showDayOfWeek\"\n | \"invalidDateLabel\"\n > {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n formattedDate: string | null,\n ) => void;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA+Ba,MAAA,mBAAmB,CAAC,UAAiC;AAC1D,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA,mBAAmB;AAA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AAc;AAAA,YAC5B,WAAW,QAAQ;AAAA,YACnB,SAAS;AAAA,cACP,OAAO,QAAQ;AAAA,cACf,sBAAsB,QAAQ;AAAA,cAC9B,OAAO,QAAQ;AAAA,YACjB;AAAA,YACA,aAAa;AAAA,YACb,OAAO;AAAA,YACP,mBAAiB,QAAQ,CAAC,GAAG;AAAA,YAC7B,QAAQ;AAAA,YACR,SAAS;AAAA,YACT,UAAU;AAAA,YACV,WAAW;AAAA,YACX,QAAQ,YAAY,YAAY;AAAA,YAChC,eAAe;AAAA,UAAA;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF;AAEJ;AAGA,iBAAiB,kBAAkB;"}
1
+ {"version":3,"file":"CalendarHeader.js","sources":["../../../../src/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useContext, useEffect, useState } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvFormElementContext,\n HvFormElementDescriptorsContext,\n} from \"../../FormElement\";\nimport { HvInput, HvInputProps } from \"../../Input\";\nimport { HvTypography } from \"../../Typography\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\nimport type { HvSingleCalendarProps } from \"../SingleCalendar\";\nimport {\n DEFAULT_LOCALE,\n getFormattedDate,\n getLocaleDateFormat,\n getStringFromDate,\n isDate,\n isRange,\n isSameDay,\n parseDateString,\n} from \"../utils\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id: idProp,\n value: valueProp,\n locale = DEFAULT_LOCALE,\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n } = useDefaultProps(\"HvCalendarHeader\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n const localValue = isRange(valueProp)\n ? showEndDate\n ? valueProp.endDate!\n : valueProp.startDate\n : valueProp;\n\n const [dateValue, setDateValue] = useState(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const id = idProp ?? setId(context.id, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = getLocaleDateFormat(locale);\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (inputValue && isDate(new Date(inputValue))),\n );\n\n const validateInput = (incomingValid: any) =>\n incomingValid === undefined || isDate(new Date(incomingValid));\n\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(getFormattedDate(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event: any, date: string) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = parseDateString(date, locale);\n\n const isValidInput = isDate(localeParsedDate);\n const dateParsed = isValidInput ? localeParsedDate : new Date(date);\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler: HvInputProps[\"onBlur\"] = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler: HvInputProps[\"onKeyDown\"] = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler: HvInputProps[\"onFocus\"] = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? getStringFromDate(localValue, locale)\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler: HvInputProps[\"onChange\"] = (event, val) => {\n setEditedValue(val);\n };\n\n const isInvalid = !isValidValue && inputValue !== \"\";\n\n // This component needs to be further refactored\n // It's not possible to clear the date\n // In a new major there's no need for all these classes\n return (\n <div\n id={id}\n className={cx(classes.root, {\n [classes.invalid]: isInvalid,\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n <HvInput\n type=\"text\"\n id={setId(id, \"header-input\")}\n placeholder={localeFormat}\n value={inputValue}\n aria-labelledby={label?.[0]?.id}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={invalidDateLabel}\n />\n </div>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps\n extends Pick<\n HvSingleCalendarProps,\n | \"id\"\n | \"value\"\n | \"locale\"\n | \"onChange\"\n | \"showEndDate\"\n | \"showDayOfWeek\"\n | \"invalidDateLabel\"\n > {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n formattedDate: string | null,\n ) => void;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA+Ba,MAAA,mBAAmB,CAAC,UAAiC;AAC1D,QAAA;AAAA,IACJ,IAAI;AA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EAAA,WAAW,QAAQ,iBAC9B,4BAAkB,KACrB;AAAA,QAEF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,IAAI,MAAM,IAAI,cAAc;AAAA,YAC5B,aAAa;AAAA,YACb,OAAO;AAAA,YACP,mBAAiB,QAAQ,CAAC,GAAG;AAAA,YAC7B,QAAQ;AAAA,YACR,SAAS;AAAA,YACT,UAAU;AAAA,YACV,WAAW;AAAA,YACX,QAAQ,YAAY,YAAY;AAAA,YAChC,eAAe;AAAA,UAAA;AAAA,QAAA;AAAA,MACjB;AAAA,IAAA;AAAA,EACF;AAEJ;AAGA,iBAAiB,kBAAkB;"}
@@ -10,11 +10,7 @@ const { staticClasses, useClasses } = createClasses("HvCalendarHeader", {
10
10
  invalid: {},
11
11
  headerDayOfWeek: {
12
12
  color: theme.colors.secondary_80
13
- },
14
- headerDate: {},
15
- input: {},
16
- inputBorderContainer: {},
17
- invalidMessageStyling: {}
13
+ }
18
14
  });
19
15
  export {
20
16
  staticClasses,
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarHeader.styles.js","sources":["../../../../src/Calendar/CalendarHeader/CalendarHeader.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvCalendarHeader\", {\n root: {\n paddingBottom: theme.space.sm,\n\n \"&$invalid\": {\n paddingBottom: 0,\n },\n },\n invalid: {},\n headerDayOfWeek: {\n color: theme.colors.secondary_80,\n },\n headerDate: {},\n input: {},\n inputBorderContainer: {},\n invalidMessageStyling: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,oBAAoB;AAAA,EAC7E,MAAM;AAAA,IACJ,eAAe,MAAM,MAAM;AAAA,IAE3B,aAAa;AAAA,MACX,eAAe;AAAA,IAAA;AAAA,EAEnB;AAAA,EACA,SAAS,CAAC;AAAA,EACV,iBAAiB;AAAA,IACf,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,YAAY,CAAC;AAAA,EACb,OAAO,CAAC;AAAA,EACR,sBAAsB,CAAC;AAAA,EACvB,uBAAuB,CAAA;AACzB,CAAC;"}
1
+ {"version":3,"file":"CalendarHeader.styles.js","sources":["../../../../src/Calendar/CalendarHeader/CalendarHeader.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvCalendarHeader\", {\n root: {\n paddingBottom: theme.space.sm,\n\n \"&$invalid\": {\n paddingBottom: 0,\n },\n },\n invalid: {},\n headerDayOfWeek: {\n color: theme.colors.secondary_80,\n },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,oBAAoB;AAAA,EAC7E,MAAM;AAAA,IACJ,eAAe,MAAM,MAAM;AAAA,IAE3B,aAAa;AAAA,MACX,eAAe;AAAA,IAAA;AAAA,EAEnB;AAAA,EACA,SAAS,CAAC;AAAA,EACV,iBAAiB;AAAA,IACf,OAAO,MAAM,OAAO;AAAA,EAAA;AAExB,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBoxGroup.js","sources":["../../../src/CheckBoxGroup/CheckBoxGroup.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../CheckBox\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { CounterLabel } from \"../utils/CounterLabel\";\nimport { multiSelectionEventHandler } from \"../utils/multiSelectionEventHandler\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./CheckBoxGroup.styles\";\n\nconst computeSelectAllState = (selected: number, total: number) => {\n if (selected === 0) {\n return \"none\";\n }\n\n if (selected === total) {\n return \"all\";\n }\n\n return \"some\";\n};\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const selectedValues = Children.toArray(children)\n .map((child: any) => {\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n return childIsSelected ? child?.props?.value : undefined;\n })\n .filter((v) => v !== undefined);\n\n return selectedValues;\n};\n\nexport { staticClasses as checkBoxGroupClasses };\n\nexport type HvCheckBoxGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCheckBoxGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children checkboxes, unless they already have one.\n */\n name?: string;\n /**\n * The value of the form element. An array of values represented in the child checkboxes.\n *\n * When defined the checkbox group state becomes controlled.\n */\n value?: any[];\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any[];\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children checkboxes.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children checkboxes.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any[]) => void;\n /**\n * Indicates whether the checkbox group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Indicates if an additional select all checkbox should be shown.\n */\n showSelectAll?: boolean;\n /**\n * The label of the select all checkbox. Defaults to \"All\". @deprecated no longer used\n */\n selectAllLabel?: string;\n /**\n * Custom label for select all checkbox conjunction\n */\n selectAllConjunctionLabel?: string;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvCheckBoxGroupClasses;\n}\n\n/**\n * A checkbox group is a type of selection list that allows the user to select multiple options through the use of checkboxes.\n */\nexport const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(\n function HvCheckBoxGroup(props, ref) {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n label,\n description,\n status,\n statusMessage,\n defaultValue,\n value: valueProp,\n required,\n readOnly,\n disabled,\n showSelectAll,\n orientation = \"vertical\",\n selectAllConjunctionLabel = \"/\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvCheckBoxGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children),\n );\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id);\n\n const selectionAnchor = useRef(undefined);\n\n const [allValues, selectedState, selectedCount] = useMemo(() => {\n const childValues: any[] = [];\n const childSelectedState: boolean[] = [];\n let childSelectedCounter = 0;\n\n Children.toArray(children).forEach((child: any, i: number) => {\n const childValue = child?.props?.value;\n const childIsSelected = value.indexOf(childValue) !== -1;\n\n childValues[i] = childValue;\n childSelectedState[i] = childIsSelected;\n\n if (childIsSelected) {\n childSelectedCounter += 1;\n }\n });\n\n return [childValues, childSelectedState, childSelectedCounter];\n }, [children, value]);\n\n const selectAllState = computeSelectAllState(\n value.length,\n selectedState.length,\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n index: number,\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => {\n const newValue = multiSelectionEventHandler(\n event,\n index,\n selectionAnchor,\n allValues,\n selectedState,\n isChecked,\n );\n\n childOnChange?.(event, isChecked);\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n },\n [\n allValues,\n onChange,\n required,\n selectedState,\n setValidationState,\n setValue,\n ],\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any, i: number) => {\n const childIsSelected = selectedState[i];\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) =>\n onChildChangeInterceptor(\n i,\n child?.props?.onChange,\n event,\n isChecked,\n ),\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n name,\n onChildChangeInterceptor,\n readOnly,\n selectedState,\n ]);\n\n const handleSelectAll = (\n event: React.ChangeEvent<HTMLInputElement>,\n selectAllChecked: boolean,\n ) => {\n let newValue: any[];\n if (selectAllState === \"some\") {\n newValue = [];\n } else if (selectAllChecked) {\n newValue = [...allValues];\n } else {\n newValue = [];\n }\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n };\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n showGutter\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <div\n ref={ref}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-disabled={disabled ? true : undefined}\n aria-invalid={validationState === \"invalid\" ? true : undefined}\n aria-errormessage={\n validationState === \"invalid\" ? errorMessageId : undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={cx(classes.group, {\n [classes.vertical]: orientation === \"vertical\",\n [classes.horizontal]: orientation === \"horizontal\",\n [classes.invalid]: validationState === \"invalid\",\n })}\n {...others}\n >\n {showSelectAll && (\n <HvCheckBox\n checked={selectAllState === \"all\"}\n indeterminate={selectAllState === \"some\"}\n label={\n <CounterLabel\n selected={selectedCount}\n total={Children.count(children)}\n conjunctionLabel={selectAllConjunctionLabel}\n />\n }\n disabled={disabled}\n readOnly={readOnly}\n className={classes.selectAll}\n onChange={handleSelectAll}\n />\n )}\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":["HvCheckBoxGroup"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,wBAAwB,CAAC,UAAkB,UAAkB;AACjE,MAAI,aAAa,GAAG;AACX,WAAA;AAAA,EAAA;AAGT,MAAI,aAAa,OAAO;AACf,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AAEA,MAAM,+BAA+B,CAAC,aAA8B;AAClE,QAAM,iBAAiB,SAAS,QAAQ,QAAQ,EAC7C,IAAI,CAAC,UAAe;AACb,UAAA,oBAAoB,OAAO,OAAO,YAAY;AACpD,UAAM,kBAAkB,oBACpB,OAAO,OAAO,UACd,OAAO,OAAO;AAEX,WAAA,kBAAkB,OAAO,OAAO,QAAQ;AAAA,EAChD,CAAA,EACA,OAAO,CAAC,MAAM,MAAM,MAAS;AAEzB,SAAA;AACT;AA+FO,MAAM,kBAAkB;AAAA,EAC7B,SAASA,iBAAgB,OAAO,KAAK;AAC7B,UAAA;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,4BAA4B;AAAA,MAC5B,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,qBAAqB;AAAA,MACrB;AAAA,MACA,GAAG;AAAA,IAAA,IACD,gBAAgB,mBAAmB,KAAK;AAE5C,UAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,UAAA,CAAC,OAAO,QAAQ,IAAI;AAAA,MACxB;AAAA,MACA,iBAAiB,SACb;AAAA;AAAA;AAAA,QAGA,MAAM,6BAA6B,QAAQ;AAAA;AAAA,IACjD;AAEM,UAAA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AAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"CheckBoxGroup.js","sources":["../../../src/CheckBoxGroup/CheckBoxGroup.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../CheckBox\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { CounterLabel } from \"../utils/CounterLabel\";\nimport { multiSelectionEventHandler } from \"../utils/multiSelectionEventHandler\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./CheckBoxGroup.styles\";\n\nconst computeSelectAllState = (selected: number, total: number) => {\n if (selected === 0) {\n return \"none\";\n }\n\n if (selected === total) {\n return \"all\";\n }\n\n return \"some\";\n};\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const selectedValues = Children.toArray(children)\n .map((child: any) => {\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n return childIsSelected ? child?.props?.value : undefined;\n })\n .filter((v) => v !== undefined);\n\n return selectedValues;\n};\n\nexport { staticClasses as checkBoxGroupClasses };\n\nexport type HvCheckBoxGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCheckBoxGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children checkboxes, unless they already have one.\n */\n name?: string;\n /**\n * The value of the form element. An array of values represented in the child checkboxes.\n *\n * When defined the checkbox group state becomes controlled.\n */\n value?: any[];\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any[];\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children checkboxes.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children checkboxes.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any[]) => void;\n /**\n * Indicates whether the checkbox group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Indicates if an additional select all checkbox should be shown.\n */\n showSelectAll?: boolean;\n /**\n * The label of the select all checkbox. Defaults to \"All\". @deprecated no longer used\n */\n selectAllLabel?: string;\n /**\n * Custom label for select all checkbox conjunction\n */\n selectAllConjunctionLabel?: string;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvCheckBoxGroupClasses;\n}\n\n/**\n * A checkbox group is a type of selection list that allows the user to select multiple options through the use of checkboxes.\n */\nexport const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(\n function HvCheckBoxGroup(props, ref) {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n label,\n description,\n status,\n statusMessage,\n defaultValue,\n value: valueProp,\n required,\n readOnly,\n disabled,\n showSelectAll,\n orientation = \"vertical\",\n selectAllConjunctionLabel = \"/\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvCheckBoxGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children),\n );\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id);\n\n const selectionAnchor = useRef(undefined);\n\n const [allValues, selectedState, selectedCount] = useMemo(() => {\n const childValues: any[] = [];\n const childSelectedState: boolean[] = [];\n let childSelectedCounter = 0;\n\n Children.toArray(children).forEach((child: any, i: number) => {\n const childValue = child?.props?.value;\n const childIsSelected = value.indexOf(childValue) !== -1;\n\n childValues[i] = childValue;\n childSelectedState[i] = childIsSelected;\n\n if (childIsSelected) {\n childSelectedCounter += 1;\n }\n });\n\n return [childValues, childSelectedState, childSelectedCounter];\n }, [children, value]);\n\n const selectAllState = computeSelectAllState(\n value.length,\n selectedState.length,\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n index: number,\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => {\n const newValue = multiSelectionEventHandler(\n event,\n index,\n selectionAnchor,\n allValues,\n selectedState,\n isChecked,\n );\n\n childOnChange?.(event, isChecked);\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n },\n [\n allValues,\n onChange,\n required,\n selectedState,\n setValidationState,\n setValue,\n ],\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any, i: number) => {\n const childIsSelected = selectedState[i];\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) =>\n onChildChangeInterceptor(\n i,\n child?.props?.onChange,\n event,\n isChecked,\n ),\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n name,\n onChildChangeInterceptor,\n readOnly,\n selectedState,\n ]);\n\n const handleSelectAll = (\n event: React.ChangeEvent<HTMLInputElement>,\n selectAllChecked: boolean,\n ) => {\n let newValue: any[];\n if (selectAllState === \"some\") {\n newValue = [];\n } else if (selectAllChecked) {\n newValue = [...allValues];\n } else {\n newValue = [];\n }\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n };\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n showGutter\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <div\n ref={ref}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-disabled={disabled ? true : undefined}\n aria-invalid={validationState === \"invalid\" ? true : undefined}\n aria-errormessage={\n validationState === \"invalid\" ? errorMessageId : undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={cx(classes.group, {\n [classes.vertical]: orientation === \"vertical\",\n [classes.horizontal]: orientation === \"horizontal\",\n [classes.invalid]: validationState === \"invalid\",\n })}\n {...others}\n >\n {showSelectAll && (\n <HvCheckBox\n checked={selectAllState === \"all\"}\n indeterminate={selectAllState === \"some\"}\n label={\n <CounterLabel\n selected={selectedCount}\n total={Children.count(children)}\n conjunctionLabel={selectAllConjunctionLabel}\n />\n }\n disabled={disabled}\n readOnly={readOnly}\n className={classes.selectAll}\n onChange={handleSelectAll}\n />\n )}\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":["HvCheckBoxGroup"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,wBAAwB,CAAC,UAAkB,UAAkB;AACjE,MAAI,aAAa,GAAG;AACX,WAAA;AAAA,EAAA;AAGT,MAAI,aAAa,OAAO;AACf,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AAEA,MAAM,+BAA+B,CAAC,aAA8B;AAClE,QAAM,iBAAiB,SAAS,QAAQ,QAAQ,EAC7C,IAAI,CAAC,UAAe;AACb,UAAA,oBAAoB,OAAO,OAAO,YAAY;AACpD,UAAM,kBAAkB,oBACpB,OAAO,OAAO,UACd,OAAO,OAAO;AAEX,WAAA,kBAAkB,OAAO,OAAO,QAAQ;AAAA,EAChD,CAAA,EACA,OAAO,CAAC,MAAM,MAAM,MAAS;AAEzB,SAAA;AACT;AA+FO,MAAM,kBAAkB;AAAA,EAC7B,SAASA,iBAAgB,OAAO,KAAK;AAC7B,UAA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AA,cACA,GAAG;AAAA,cAEH,UAAA;AAAA,gBACC,iBAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,SAAS,mBAAmB;AAAA,oBAC5B,eAAe,mBAAmB;AAAA,oBAClC,OACE;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,UAAU;AAAA,wBACV,OAAO,SAAS,MAAM,QAAQ;AAAA,wBAC9B,kBAAkB;AAAA,sBAAA;AAAA,oBACpB;AAAA,oBAEF;AAAA,oBACA;AAAA,oBACA,WAAW,QAAQ;AAAA,oBACnB,UAAU;AAAA,kBAAA;AAAA,gBACZ;AAAA,gBAED;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,UAEC,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,WAAW,OAAO;AAAA,cAC5B,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
@@ -15,8 +15,8 @@ import { HvFormElement } from "../FormElement/FormElement.js";
15
15
  import { HvLabel } from "../FormElement/Label/Label.js";
16
16
  import { HvInfoMessage } from "../FormElement/InfoMessage/InfoMessage.js";
17
17
  import { HvBaseDropdown } from "../BaseDropdown/BaseDropdown.js";
18
- import { HvTypography } from "../Typography/Typography.js";
19
18
  import { HvPanel } from "../Panel/Panel.js";
19
+ import { HvTypography } from "../Typography/Typography.js";
20
20
  const DEFAULT_LABELS = {
21
21
  recommendedColorsLabel: "Recommended colors:",
22
22
  customColorsLabel: "Custom colors:"