@hitachivantara/uikit-react-core 5.82.2 → 5.82.4

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 (231) hide show
  1. package/dist/cjs/BaseDropdown/BaseDropdown.cjs +1 -1
  2. package/dist/cjs/BaseInput/BaseInput.cjs +11 -12
  3. package/dist/cjs/BaseInput/validations.cjs +3 -3
  4. package/dist/cjs/Calendar/Calendar.cjs +14 -15
  5. package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +8 -10
  6. package/dist/cjs/Card/Card.cjs +1 -1
  7. package/dist/cjs/CheckBox/CheckBox.cjs +10 -10
  8. package/dist/cjs/CheckBoxGroup/CheckBoxGroup.cjs +8 -8
  9. package/dist/cjs/ColorPicker/ColorPicker.cjs +6 -9
  10. package/dist/cjs/ColorPicker/Fields/Fields.cjs +4 -4
  11. package/dist/cjs/ColorPicker/Picker/Picker.cjs +11 -3
  12. package/dist/cjs/ColorPicker/Picker/Picker.styles.cjs +6 -1
  13. package/dist/cjs/Controls/context/ControlsContext.cjs +1 -3
  14. package/dist/cjs/DatePicker/DatePicker.cjs +15 -15
  15. package/dist/cjs/DropDownMenu/DropDownMenu.cjs +1 -1
  16. package/dist/cjs/Dropdown/Dropdown.cjs +9 -9
  17. package/dist/cjs/FileUploader/DropZone/DropZone.cjs +2 -2
  18. package/dist/cjs/FilterGroup/FilterGroup.cjs +6 -6
  19. package/dist/cjs/{Forms → FormElement}/Adornment/Adornment.cjs +10 -11
  20. package/dist/cjs/{Forms → FormElement}/CharCounter/CharCounter.cjs +15 -15
  21. package/dist/cjs/FormElement/FormElement.cjs +35 -0
  22. package/dist/cjs/{Forms → FormElement}/InfoMessage/InfoMessage.cjs +8 -8
  23. package/dist/cjs/{Forms → FormElement}/Label/Label.cjs +13 -13
  24. package/dist/cjs/{Forms → FormElement}/Suggestions/Suggestions.cjs +7 -7
  25. package/dist/cjs/{Forms → FormElement}/WarningText/WarningText.cjs +5 -5
  26. package/dist/cjs/FormElement/context.cjs +11 -0
  27. package/dist/cjs/{Forms/FormElement/utils/FormUtils.cjs → FormElement/utils.cjs} +19 -11
  28. package/dist/cjs/Grid/Grid.cjs +1 -1
  29. package/dist/cjs/Input/Input.cjs +17 -17
  30. package/dist/cjs/Input/Input.styles.cjs +2 -2
  31. package/dist/cjs/ListContainer/ListContext/ListContext.cjs +1 -3
  32. package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +1 -1
  33. package/dist/cjs/Radio/Radio.cjs +10 -13
  34. package/dist/cjs/RadioGroup/RadioGroup.cjs +7 -7
  35. package/dist/cjs/Select/Select.cjs +5 -7
  36. package/dist/cjs/SelectionList/SelectionList.cjs +7 -7
  37. package/dist/cjs/Slider/Slider.cjs +12 -12
  38. package/dist/cjs/Slider/utils.cjs +7 -7
  39. package/dist/cjs/Snackbar/SnackbarContent/SnackbarContent.cjs +1 -1
  40. package/dist/cjs/SnackbarProvider/SnackbarProvider.cjs +1 -1
  41. package/dist/cjs/Switch/Switch.cjs +9 -12
  42. package/dist/cjs/Table/TableBody/TableBody.cjs +10 -8
  43. package/dist/cjs/Table/TableCell/TableCell.cjs +2 -2
  44. package/dist/cjs/Table/TableContainer/TableContainer.cjs +9 -2
  45. package/dist/cjs/Table/TableHead/TableHead.cjs +10 -2
  46. package/dist/cjs/Table/TableHeader/TableHeader.cjs +2 -2
  47. package/dist/cjs/Table/TableRow/TableRow.cjs +2 -2
  48. package/dist/cjs/TableSection/TableSection.styles.cjs +6 -2
  49. package/dist/cjs/TagsInput/TagsInput.cjs +17 -17
  50. package/dist/cjs/TagsInput/TagsInput.styles.cjs +1 -1
  51. package/dist/cjs/TextArea/TextArea.cjs +17 -17
  52. package/dist/cjs/TimePicker/TimePicker.cjs +7 -7
  53. package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs +1 -1
  54. package/dist/cjs/hocs/withTooltip.cjs +40 -37
  55. package/dist/cjs/hooks/useIsMounted.cjs +2 -4
  56. package/dist/cjs/index.cjs +15 -36
  57. package/dist/esm/BaseDropdown/BaseDropdown.js +1 -1
  58. package/dist/esm/BaseDropdown/BaseDropdown.js.map +1 -1
  59. package/dist/esm/BaseInput/BaseInput.js +5 -6
  60. package/dist/esm/BaseInput/BaseInput.js.map +1 -1
  61. package/dist/esm/BaseInput/validations.js +3 -3
  62. package/dist/esm/BaseInput/validations.js.map +1 -1
  63. package/dist/esm/Calendar/Calendar.js +13 -14
  64. package/dist/esm/Calendar/Calendar.js.map +1 -1
  65. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +6 -8
  66. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
  67. package/dist/esm/Card/Card.js +1 -1
  68. package/dist/esm/Card/Card.js.map +1 -1
  69. package/dist/esm/CheckBox/CheckBox.js +9 -9
  70. package/dist/esm/CheckBox/CheckBox.js.map +1 -1
  71. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js +8 -8
  72. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
  73. package/dist/esm/ColorPicker/ColorPicker.js +6 -9
  74. package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
  75. package/dist/esm/ColorPicker/Fields/Fields.js +4 -4
  76. package/dist/esm/ColorPicker/Fields/Fields.js.map +1 -1
  77. package/dist/esm/ColorPicker/Picker/Picker.js +11 -3
  78. package/dist/esm/ColorPicker/Picker/Picker.js.map +1 -1
  79. package/dist/esm/ColorPicker/Picker/Picker.styles.js +6 -1
  80. package/dist/esm/ColorPicker/Picker/Picker.styles.js.map +1 -1
  81. package/dist/esm/Controls/context/ControlsContext.js +2 -2
  82. package/dist/esm/Controls/context/ControlsContext.js.map +1 -1
  83. package/dist/esm/DatePicker/DatePicker.js +9 -9
  84. package/dist/esm/DatePicker/DatePicker.js.map +1 -1
  85. package/dist/esm/Dialog/Dialog.js.map +1 -1
  86. package/dist/esm/DropDownMenu/DropDownMenu.js +1 -1
  87. package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
  88. package/dist/esm/Dropdown/Dropdown.js +8 -8
  89. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  90. package/dist/esm/EmptyState/EmptyState.js.map +1 -1
  91. package/dist/esm/FileUploader/DropZone/DropZone.js +2 -2
  92. package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
  93. package/dist/esm/FilterGroup/FilterContent/FilterContent.js.map +1 -1
  94. package/dist/esm/FilterGroup/FilterGroup.js +6 -6
  95. package/dist/esm/FilterGroup/FilterGroup.js.map +1 -1
  96. package/dist/esm/{Forms → FormElement}/Adornment/Adornment.js +9 -10
  97. package/dist/esm/FormElement/Adornment/Adornment.js.map +1 -0
  98. package/dist/esm/FormElement/Adornment/Adornment.styles.js.map +1 -0
  99. package/dist/esm/{Forms → FormElement}/CharCounter/CharCounter.js +15 -15
  100. package/dist/esm/FormElement/CharCounter/CharCounter.js.map +1 -0
  101. package/dist/esm/FormElement/CharCounter/CharCounter.styles.js.map +1 -0
  102. package/dist/esm/FormElement/FormElement.js +36 -0
  103. package/dist/esm/FormElement/FormElement.js.map +1 -0
  104. package/dist/esm/FormElement/FormElement.styles.js.map +1 -0
  105. package/dist/esm/{Forms → FormElement}/InfoMessage/InfoMessage.js +8 -8
  106. package/dist/esm/FormElement/InfoMessage/InfoMessage.js.map +1 -0
  107. package/dist/esm/FormElement/InfoMessage/InfoMessage.styles.js.map +1 -0
  108. package/dist/esm/{Forms → FormElement}/Label/Label.js +12 -12
  109. package/dist/esm/FormElement/Label/Label.js.map +1 -0
  110. package/dist/esm/FormElement/Label/Label.styles.js.map +1 -0
  111. package/dist/esm/{Forms → FormElement}/Suggestions/Suggestions.js +7 -7
  112. package/dist/esm/FormElement/Suggestions/Suggestions.js.map +1 -0
  113. package/dist/esm/FormElement/Suggestions/Suggestions.styles.js.map +1 -0
  114. package/dist/esm/{Forms → FormElement}/WarningText/WarningText.js +5 -5
  115. package/dist/esm/FormElement/WarningText/WarningText.js.map +1 -0
  116. package/dist/esm/FormElement/WarningText/WarningText.styles.js.map +1 -0
  117. package/dist/esm/FormElement/context.js +11 -0
  118. package/dist/esm/FormElement/context.js.map +1 -0
  119. package/dist/esm/{Forms/FormElement/utils/FormUtils.js → FormElement/utils.js} +21 -11
  120. package/dist/esm/FormElement/utils.js.map +1 -0
  121. package/dist/esm/GlobalActions/GlobalActions.js.map +1 -1
  122. package/dist/esm/Grid/Grid.js +1 -1
  123. package/dist/esm/Grid/Grid.js.map +1 -1
  124. package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
  125. package/dist/esm/Input/Input.js +21 -21
  126. package/dist/esm/Input/Input.js.map +1 -1
  127. package/dist/esm/Input/Input.styles.js +2 -2
  128. package/dist/esm/Input/Input.styles.js.map +1 -1
  129. package/dist/esm/List/List.js.map +1 -1
  130. package/dist/esm/ListContainer/ListContext/ListContext.js +2 -2
  131. package/dist/esm/ListContainer/ListContext/ListContext.js.map +1 -1
  132. package/dist/esm/Pagination/Pagination.js.map +1 -1
  133. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +1 -1
  134. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
  135. package/dist/esm/QueryBuilder/Rule/Value/TextValue/TextValue.js.map +1 -1
  136. package/dist/esm/Radio/Radio.js +9 -12
  137. package/dist/esm/Radio/Radio.js.map +1 -1
  138. package/dist/esm/RadioGroup/RadioGroup.js +7 -7
  139. package/dist/esm/RadioGroup/RadioGroup.js.map +1 -1
  140. package/dist/esm/Select/Select.js +5 -5
  141. package/dist/esm/Select/Select.js.map +1 -1
  142. package/dist/esm/SelectionList/SelectionList.js +7 -7
  143. package/dist/esm/SelectionList/SelectionList.js.map +1 -1
  144. package/dist/esm/Slider/Slider.js +12 -12
  145. package/dist/esm/Slider/Slider.js.map +1 -1
  146. package/dist/esm/Slider/SliderInput/SliderInput.js.map +1 -1
  147. package/dist/esm/Slider/utils.js +7 -7
  148. package/dist/esm/Slider/utils.js.map +1 -1
  149. package/dist/esm/Snackbar/SnackbarContent/SnackbarContent.js +1 -1
  150. package/dist/esm/Snackbar/SnackbarContent/SnackbarContent.js.map +1 -1
  151. package/dist/esm/SnackbarProvider/SnackbarProvider.js +1 -1
  152. package/dist/esm/SnackbarProvider/SnackbarProvider.js.map +1 -1
  153. package/dist/esm/Switch/Switch.js +8 -11
  154. package/dist/esm/Switch/Switch.js.map +1 -1
  155. package/dist/esm/Table/TableBody/TableBody.js +10 -8
  156. package/dist/esm/Table/TableBody/TableBody.js.map +1 -1
  157. package/dist/esm/Table/TableCell/TableCell.js +2 -2
  158. package/dist/esm/Table/TableCell/TableCell.js.map +1 -1
  159. package/dist/esm/Table/TableContainer/TableContainer.js +9 -2
  160. package/dist/esm/Table/TableContainer/TableContainer.js.map +1 -1
  161. package/dist/esm/Table/TableHead/TableHead.js +10 -2
  162. package/dist/esm/Table/TableHead/TableHead.js.map +1 -1
  163. package/dist/esm/Table/TableHeader/TableHeader.js +2 -2
  164. package/dist/esm/Table/TableHeader/TableHeader.js.map +1 -1
  165. package/dist/esm/Table/TableRow/TableRow.js +2 -2
  166. package/dist/esm/Table/TableRow/TableRow.js.map +1 -1
  167. package/dist/esm/TableSection/TableSection.styles.js +6 -2
  168. package/dist/esm/TableSection/TableSection.styles.js.map +1 -1
  169. package/dist/esm/TagsInput/TagsInput.js +19 -19
  170. package/dist/esm/TagsInput/TagsInput.js.map +1 -1
  171. package/dist/esm/TagsInput/TagsInput.styles.js +1 -1
  172. package/dist/esm/TagsInput/TagsInput.styles.js.map +1 -1
  173. package/dist/esm/TextArea/TextArea.js +19 -19
  174. package/dist/esm/TextArea/TextArea.js.map +1 -1
  175. package/dist/esm/TimePicker/TimePicker.js +7 -7
  176. package/dist/esm/TimePicker/TimePicker.js.map +1 -1
  177. package/dist/esm/TreeView/internals/utils/EventManager.js.map +1 -1
  178. package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js +1 -1
  179. package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
  180. package/dist/esm/hocs/withTooltip.js +40 -37
  181. package/dist/esm/hocs/withTooltip.js.map +1 -1
  182. package/dist/esm/hooks/useIsMounted.js +3 -3
  183. package/dist/esm/hooks/useIsMounted.js.map +1 -1
  184. package/dist/esm/index.js +14 -35
  185. package/dist/esm/index.js.map +1 -1
  186. package/dist/esm/utils/deepMerge.js.map +1 -1
  187. package/dist/types/index.d.ts +66 -143
  188. package/package.json +6 -6
  189. package/dist/cjs/Forms/FormElement/FormElement.cjs +0 -44
  190. package/dist/cjs/Forms/FormElement/context/FormElementContext.cjs +0 -12
  191. package/dist/cjs/Forms/FormElement/context/FormElementDescriptorsContext.cjs +0 -12
  192. package/dist/cjs/Forms/FormElement/context/FormElementValueContext.cjs +0 -12
  193. package/dist/cjs/Forms/FormElement/validationStates.cjs +0 -12
  194. package/dist/esm/Forms/Adornment/Adornment.js.map +0 -1
  195. package/dist/esm/Forms/Adornment/Adornment.styles.js.map +0 -1
  196. package/dist/esm/Forms/CharCounter/CharCounter.js.map +0 -1
  197. package/dist/esm/Forms/CharCounter/CharCounter.styles.js.map +0 -1
  198. package/dist/esm/Forms/FormElement/FormElement.js +0 -45
  199. package/dist/esm/Forms/FormElement/FormElement.js.map +0 -1
  200. package/dist/esm/Forms/FormElement/FormElement.styles.js.map +0 -1
  201. package/dist/esm/Forms/FormElement/context/FormElementContext.js +0 -10
  202. package/dist/esm/Forms/FormElement/context/FormElementContext.js.map +0 -1
  203. package/dist/esm/Forms/FormElement/context/FormElementDescriptorsContext.js +0 -10
  204. package/dist/esm/Forms/FormElement/context/FormElementDescriptorsContext.js.map +0 -1
  205. package/dist/esm/Forms/FormElement/context/FormElementValueContext.js +0 -10
  206. package/dist/esm/Forms/FormElement/context/FormElementValueContext.js.map +0 -1
  207. package/dist/esm/Forms/FormElement/utils/FormUtils.js.map +0 -1
  208. package/dist/esm/Forms/FormElement/validationStates.js +0 -12
  209. package/dist/esm/Forms/FormElement/validationStates.js.map +0 -1
  210. package/dist/esm/Forms/InfoMessage/InfoMessage.js.map +0 -1
  211. package/dist/esm/Forms/InfoMessage/InfoMessage.styles.js.map +0 -1
  212. package/dist/esm/Forms/Label/Label.js.map +0 -1
  213. package/dist/esm/Forms/Label/Label.styles.js.map +0 -1
  214. package/dist/esm/Forms/Suggestions/Suggestions.js.map +0 -1
  215. package/dist/esm/Forms/Suggestions/Suggestions.styles.js.map +0 -1
  216. package/dist/esm/Forms/WarningText/WarningText.js.map +0 -1
  217. package/dist/esm/Forms/WarningText/WarningText.styles.js.map +0 -1
  218. /package/dist/cjs/{Forms → FormElement}/Adornment/Adornment.styles.cjs +0 -0
  219. /package/dist/cjs/{Forms → FormElement}/CharCounter/CharCounter.styles.cjs +0 -0
  220. /package/dist/cjs/{Forms/FormElement → FormElement}/FormElement.styles.cjs +0 -0
  221. /package/dist/cjs/{Forms → FormElement}/InfoMessage/InfoMessage.styles.cjs +0 -0
  222. /package/dist/cjs/{Forms → FormElement}/Label/Label.styles.cjs +0 -0
  223. /package/dist/cjs/{Forms → FormElement}/Suggestions/Suggestions.styles.cjs +0 -0
  224. /package/dist/cjs/{Forms → FormElement}/WarningText/WarningText.styles.cjs +0 -0
  225. /package/dist/esm/{Forms → FormElement}/Adornment/Adornment.styles.js +0 -0
  226. /package/dist/esm/{Forms → FormElement}/CharCounter/CharCounter.styles.js +0 -0
  227. /package/dist/esm/{Forms/FormElement → FormElement}/FormElement.styles.js +0 -0
  228. /package/dist/esm/{Forms → FormElement}/InfoMessage/InfoMessage.styles.js +0 -0
  229. /package/dist/esm/{Forms → FormElement}/Label/Label.styles.js +0 -0
  230. /package/dist/esm/{Forms → FormElement}/Suggestions/Suggestions.styles.js +0 -0
  231. /package/dist/esm/{Forms → FormElement}/WarningText/WarningText.styles.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"FilterGroup.js","sources":["../../../src/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { staticClasses, useClasses } from \"./FilterGroup.styles\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport {\n HvFilterGroupFilters,\n HvFilterGroupHorizontalPlacement,\n HvFilterGroupValue,\n} from \"./types\";\n\nexport { staticClasses as filterGroupClasses };\n\nexport type HvFilterGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\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 /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\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 /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue,\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS = {\n /** Apply button label. */\n applyLabel: \"Apply\",\n /** Cancel button label. */\n cancelLabel: \"Cancel\",\n /** Clear button label. */\n clearLabel: \"Clear Filters\",\n /** Placeholder label. */\n placeholder: \"Filters\",\n /** SearchBox placeholder label. */\n searchBoxPlaceholder: \"Search\",\n /** Select All placeholder label. */\n selectAll: \"All\",\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction: \"/\",\n};\n\nexport type HvFilterGroupLabels = Partial<typeof DEFAULT_LABELS>;\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = forwardRef<HTMLDivElement, HvFilterGroupProps>(\n function HvFilterGroup(props, ref) {\n const {\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvFilterGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={cx(classes.root, className)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n ref={ref}\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n );\n },\n);\n"],"names":["HvFilterGroup"],"mappings":";;;;;;;;;;;;;;;AAkGA,MAAM,iBAAiB;AAAA;AAAA,EAErB,YAAY;AAAA;AAAA,EAEZ,aAAa;AAAA;AAAA,EAEb,YAAY;AAAA;AAAA,EAEZ,aAAa;AAAA;AAAA,EAEb,sBAAsB;AAAA;AAAA,EAEtB,WAAW;AAAA;AAAA,EAEX,2BAA2B;AAC7B;AASO,MAAM,gBAAgB;AAAA,EAC3B,SAASA,eAAc,OAAO,KAAK;AAC3B,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA,sBAAsB;AAAA,MACtB,gBAAgB;AAAA,MAChB,sBAAsB;AAAA,MACtB,SAAS;AAAA,MACT;AAAA,MACA,SAAS;AAAA,MACT,GAAG;AAAA,IAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,UAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAC9C,UAAM,CAAC,iBAAiB,IAAI,cAAc,eAAe,UAAU;AAE7D,UAAA,YAAY,YAAY,EAAE;AAE1B,UAAA,SAAS,UAAU,gBAAgB,UAAU;AAEnD,UAAM,WAAW,SAAS;AAE1B,UAAM,iBAAiB,eAAe;AAIhC,UAAA,eAAe,WAAW,UAAa;AAG3C,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QACpC,GAAG;AAAA,QAEF,UAAA;AAAA,WAAA,YAAY,mBACZ,qBAAC,OAAI,EAAA,WAAW,QAAQ,gBACrB,UAAA;AAAA,YACC,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI,MAAM,WAAW,OAAO;AAAA,gBAC5B,SAAS,MAAM,WAAW,OAAO;AAAA,gBACjC;AAAA,gBACA,WAAW,QAAQ;AAAA,cAAA;AAAA,YACrB;AAAA,YAGD,kBACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI,MAAM,WAAW,aAAa;AAAA,gBAClC,WAAW,QAAQ;AAAA,gBAElB,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,UAEF;AAAA,YAAC;AAAA,YAAA;AAAA,cACC;AAAA,cACA;AAAA,cACA;AAAA,cAEA,UAAA;AAAA,gBAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC;AAAA,oBACA,IAAI;AAAA,oBACJ;AAAA,oBACA;AAAA,oBACA,eAAa;AAAA,oBACb,WAAW;AAAA,oBACX;AAAA,oBACA,cAAY;AAAA,oBACZ,mBAAiB;AAAA,oBACjB;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACC,GAAG;AAAA,kBAAA;AAAA,gBACN;AAAA,gBACC,gBACC;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,IAAI,MAAM,WAAW,OAAO;AAAA,oBAC5B,eAAa;AAAA,oBACb,WAAW,QAAQ;AAAA,oBAElB,UAAA;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,YAAA;AAAA,UAAA;AAAA,QAEJ;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"FilterGroup.js","sources":["../../../src/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { staticClasses, useClasses } from \"./FilterGroup.styles\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport {\n HvFilterGroupFilters,\n HvFilterGroupHorizontalPlacement,\n HvFilterGroupValue,\n} from \"./types\";\n\nexport { staticClasses as filterGroupClasses };\n\nexport type HvFilterGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\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 /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\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 /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue,\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS = {\n /** Apply button label. */\n applyLabel: \"Apply\",\n /** Cancel button label. */\n cancelLabel: \"Cancel\",\n /** Clear button label. */\n clearLabel: \"Clear Filters\",\n /** Placeholder label. */\n placeholder: \"Filters\",\n /** SearchBox placeholder label. */\n searchBoxPlaceholder: \"Search\",\n /** Select All placeholder label. */\n selectAll: \"All\",\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction: \"/\",\n};\n\nexport type HvFilterGroupLabels = Partial<typeof DEFAULT_LABELS>;\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = forwardRef<HTMLDivElement, HvFilterGroupProps>(\n function HvFilterGroup(props, ref) {\n const {\n className,\n id,\n name,\n required,\n disabled,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvFilterGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={cx(classes.root, className)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n ref={ref}\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n );\n },\n);\n"],"names":["HvFilterGroup"],"mappings":";;;;;;;;;;;;;;;AAkGA,MAAM,iBAAiB;AAAA;AAAA,EAErB,YAAY;AAAA;AAAA,EAEZ,aAAa;AAAA;AAAA,EAEb,YAAY;AAAA;AAAA,EAEZ,aAAa;AAAA;AAAA,EAEb,sBAAsB;AAAA;AAAA,EAEtB,WAAW;AAAA;AAAA,EAEX,2BAA2B;AAC7B;AASO,MAAM,gBAAgB;AAAA,EAC3B,SAASA,eAAc,OAAO,KAAK;AAC3B,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA,sBAAsB;AAAA,MACtB,gBAAgB;AAAA,MAChB,sBAAsB;AAAA,MACtB,SAAS;AAAA,MACT;AAAA,MACA,SAAS;AAAA,MACT,GAAG;AAAA,IAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,UAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAC9C,UAAM,CAAC,iBAAiB,IAAI,cAAc,eAAe,UAAU;AAE7D,UAAA,YAAY,YAAY,EAAE;AAE1B,UAAA,SAAS,UAAU,gBAAgB,UAAU;AAEnD,UAAM,WAAW,SAAS;AAE1B,UAAM,iBAAiB,eAAe;AAIhC,UAAA,eAAe,WAAW,UAAa;AAG3C,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QACpC,GAAG;AAAA,QAEF,UAAA;AAAA,WAAA,YAAY,mBACZ,qBAAC,OAAI,EAAA,WAAW,QAAQ,gBACrB,UAAA;AAAA,YACC,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI,MAAM,WAAW,OAAO;AAAA,gBAC5B,SAAS,MAAM,WAAW,OAAO;AAAA,gBACjC;AAAA,gBACA,WAAW,QAAQ;AAAA,cAAA;AAAA,YACrB;AAAA,YAGD,kBACC;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI,MAAM,WAAW,aAAa;AAAA,gBAClC,WAAW,QAAQ;AAAA,gBAElB,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,UAEF;AAAA,YAAC;AAAA,YAAA;AAAA,cACC;AAAA,cACA;AAAA,cACA;AAAA,cAEA,UAAA;AAAA,gBAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC;AAAA,oBACA,IAAI;AAAA,oBACJ;AAAA,oBACA;AAAA,oBACA,eAAa;AAAA,oBACb,WAAW;AAAA,oBACX;AAAA,oBACA,cAAY;AAAA,oBACZ,mBAAiB;AAAA,oBACjB;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACC,GAAG;AAAA,kBAAA;AAAA,gBACN;AAAA,gBACC,gBACC;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,IAAI,MAAM,WAAW,OAAO;AAAA,oBAC5B,eAAa;AAAA,oBACb,WAAW,QAAQ;AAAA,oBAElB,UAAA;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,YAAA;AAAA,UAAA;AAAA,QAEJ;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
@@ -1,28 +1,27 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useContext } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
+ import { HvFormElementContext, HvFormElementDescriptorsContext } from "../context.js";
4
5
  import { useClasses } from "./Adornment.styles.js";
5
6
  import { staticClasses } from "./Adornment.styles.js";
6
- import { HvFormElementDescriptorsContext } from "../FormElement/context/FormElementDescriptorsContext.js";
7
7
  import { HvButtonBase } from "../../ButtonBase/ButtonBase.js";
8
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
9
8
  const noop = () => {
10
9
  };
11
- const HvAdornment = forwardRef((props, ref) => {
10
+ const HvAdornment = forwardRef(function HvAdornment2(props, ref) {
12
11
  const {
13
12
  id,
14
13
  classes: classesProp,
15
14
  className,
16
15
  icon,
17
- showWhen = void 0,
16
+ showWhen,
18
17
  onClick,
19
- isVisible = void 0,
18
+ isVisible,
20
19
  ...others
21
20
  } = useDefaultProps("HvAdornment", props);
22
21
  const { classes, cx } = useClasses(classesProp);
23
- const { elementStatus = "", elementDisabled } = useContext(HvFormElementContext);
22
+ const { status, disabled } = useContext(HvFormElementContext);
24
23
  const { input } = useContext(HvFormElementDescriptorsContext);
25
- const displayIcon = isVisible ?? (showWhen === void 0 || elementStatus === showWhen);
24
+ const displayIcon = isVisible ?? (showWhen == null || status === showWhen);
26
25
  const isClickable = !!onClick;
27
26
  return isClickable ? /* @__PURE__ */ jsx(
28
27
  HvButtonBase,
@@ -39,14 +38,14 @@ const HvAdornment = forwardRef((props, ref) => {
39
38
  classes.adornmentButton,
40
39
  {
41
40
  [classes.hideIcon]: !displayIcon,
42
- [classes.disabled]: elementDisabled
41
+ [classes.disabled]: disabled
43
42
  },
44
43
  className
45
44
  ),
46
45
  onClick,
47
46
  onMouseDown: (event) => event.preventDefault(),
48
47
  onKeyDown: noop,
49
- disabled: elementDisabled,
48
+ disabled,
50
49
  ...others,
51
50
  children: /* @__PURE__ */ jsx("div", { className: classes.icon, children: icon })
52
51
  }
@@ -61,7 +60,7 @@ const HvAdornment = forwardRef((props, ref) => {
61
60
  classes.adornmentIcon,
62
61
  {
63
62
  [classes.hideIcon]: !displayIcon,
64
- [classes.disabled]: elementDisabled
63
+ [classes.disabled]: disabled
65
64
  },
66
65
  className
67
66
  ),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Adornment.js","sources":["../../../../src/FormElement/Adornment/Adornment.tsx"],"sourcesContent":["import { forwardRef, useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButtonBase } from \"../../ButtonBase\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport {\n HvFormElementContext,\n HvFormElementDescriptorsContext,\n} from \"../context\";\nimport { HvFormStatus } from \"../FormElement\";\nimport { staticClasses, useClasses } from \"./Adornment.styles\";\n\nconst noop = () => {};\n\nexport { staticClasses as adornmentClasses };\n\nexport type HvAdornmentClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvAdornmentProps\n extends HvBaseProps<\n HTMLDivElement | HTMLButtonElement,\n \"onMouseDown\" | \"onKeyDown\"\n > {\n /** The icon to be added into the input. */\n icon: React.ReactNode;\n /** When the adornment should be displayed. */\n showWhen?: HvFormStatus;\n /** Function to be executed when this element is clicked. */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** If this property is defined the adornment visibility will be exclusively controlled by this value. */\n isVisible?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvAdornmentClasses;\n}\n\n/**\n * Allows to add a decorative icon or an action to a form element, usually on the right side of an input.\n * E.g., the reveal password button.\n *\n * In addition to the showWhen feature, which uses the form element's context validation state to determine\n * its visibility, this component also ensures that it does not steal focus from the input and that it is\n * not accessible using the keyboard.\n *\n * As such, its functionality, if any, for accessibility purposes must be provided through an alternative mean,\n * or by using a regular icon button or toggle button instead.\n */\nexport const HvAdornment = forwardRef<\n HTMLDivElement | HTMLButtonElement,\n HvAdornmentProps\n>(function HvAdornment(props, ref) {\n const {\n id,\n classes: classesProp,\n className,\n icon,\n showWhen,\n onClick,\n isVisible,\n ...others\n } = useDefaultProps(\"HvAdornment\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { status, disabled } = useContext(HvFormElementContext);\n const { input } = useContext(HvFormElementDescriptorsContext);\n\n const displayIcon = isVisible ?? (showWhen == null || status === showWhen);\n\n const isClickable = !!onClick;\n\n return isClickable ? (\n <HvButtonBase\n id={id}\n focusableWhenDisabled\n ref={ref as React.ForwardedRef<HTMLButtonElement>}\n type=\"button\"\n tabIndex={-1}\n aria-controls={input?.[0]?.id}\n className={cx(\n classes.root,\n classes.adornment,\n classes.adornmentButton,\n {\n [classes.hideIcon]: !displayIcon,\n [classes.disabled]: disabled,\n },\n className,\n )}\n onClick={onClick}\n onMouseDown={(event) => event.preventDefault()}\n onKeyDown={noop}\n disabled={disabled}\n {...others}\n >\n <div className={classes.icon}>{icon}</div>\n </HvButtonBase>\n ) : (\n <div\n id={id}\n ref={ref as React.ForwardedRef<HTMLDivElement>}\n className={cx(\n classes.root,\n classes.adornment,\n classes.adornmentIcon,\n {\n [classes.hideIcon]: !displayIcon,\n [classes.disabled]: disabled,\n },\n className,\n )}\n role=\"presentation\"\n {...others}\n >\n <div className={classes.icon}>{icon}</div>\n </div>\n );\n});\n"],"names":["HvAdornment"],"mappings":";;;;;;;AAeA,MAAM,OAAO,MAAM;AAAC;AAkCb,MAAM,cAAc,WAGzB,SAASA,aAAY,OAAO,KAAK;AAC3B,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,eAAe,KAAK;AACxC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAE9C,QAAM,EAAE,QAAQ,aAAa,WAAW,oBAAoB;AAC5D,QAAM,EAAE,MAAA,IAAU,WAAW,+BAA+B;AAE5D,QAAM,cAAc,cAAc,YAAY,QAAQ,WAAW;AAE3D,QAAA,cAAc,CAAC,CAAC;AAEtB,SAAO,cACL;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,uBAAqB;AAAA,MACrB;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,iBAAe,QAAQ,CAAC,GAAG;AAAA,MAC3B,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,QAAQ,GAAG,CAAC;AAAA,UACrB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,CAAC,UAAU,MAAM,eAAe;AAAA,MAC7C,WAAW;AAAA,MACX;AAAA,MACC,GAAG;AAAA,MAEJ,UAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,MAAO,UAAK,KAAA,CAAA;AAAA,IAAA;AAAA,EAAA,IAGtC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,QAAQ,GAAG,CAAC;AAAA,UACrB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA;AAAA,MACF;AAAA,MACA,MAAK;AAAA,MACJ,GAAG;AAAA,MAEJ,UAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,MAAO,UAAK,KAAA,CAAA;AAAA,IAAA;AAAA,EACtC;AAEJ,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Adornment.styles.js","sources":["../../../../src/FormElement/Adornment/Adornment.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(\"HvAdornment\", {\n root: {},\n icon: { width: 32, height: 32 },\n adornment: {\n backgroundColor: \"transparent\",\n border: \"none\",\n padding: 0,\n margin: 0,\n },\n adornmentIcon: { cursor: \"default\", pointerEvents: \"none\" },\n hideIcon: { display: \"none\" },\n adornmentButton: {\n cursor: \"pointer\",\n \"&:focus\": {\n ...outlineStyles,\n },\n },\n disabled: {\n \"&$adornmentButton\": { cursor: \"not-allowed\" },\n \"&$adornmentIcon\": { cursor: \"not-allowed\" },\n \"& svg *.color0\": { fill: theme.colors.secondary_60 },\n },\n});\n"],"names":[],"mappings":";;;AAKO,MAAM,EAAE,eAAe,eAAe,cAAc,eAAe;AAAA,EACxE,MAAM,CAAC;AAAA,EACP,MAAM,EAAE,OAAO,IAAI,QAAQ,GAAG;AAAA,EAC9B,WAAW;AAAA,IACT,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA,eAAe,EAAE,QAAQ,WAAW,eAAe,OAAO;AAAA,EAC1D,UAAU,EAAE,SAAS,OAAO;AAAA,EAC5B,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,WAAW;AAAA,MACT,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EACA,UAAU;AAAA,IACR,qBAAqB,EAAE,QAAQ,cAAc;AAAA,IAC7C,mBAAmB,EAAE,QAAQ,cAAc;AAAA,IAC3C,kBAAkB,EAAE,MAAM,MAAM,OAAO,aAAa;AAAA,EAAA;AAExD,CAAC;"}
@@ -2,9 +2,9 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { setId } from "../../utils/setId.js";
5
+ import { HvFormElementContext } from "../context.js";
5
6
  import { useClasses } from "./CharCounter.styles.js";
6
7
  import { staticClasses } from "./CharCounter.styles.js";
7
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
8
8
  import { HvTypography } from "../../Typography/Typography.js";
9
9
  const HvCharCounter = (props) => {
10
10
  const {
@@ -13,32 +13,32 @@ const HvCharCounter = (props) => {
13
13
  currentCharQuantity = 0,
14
14
  classes: classesProp,
15
15
  className,
16
- id,
17
- disabled,
16
+ id: idProp,
17
+ disabled: disabledProp,
18
18
  disableGutter = false,
19
19
  ...others
20
20
  } = useDefaultProps("HvCharCounter", props);
21
21
  const { classes, cx } = useClasses(classesProp);
22
- const { elementId, elementDisabled } = useContext(HvFormElementContext);
23
- const localDisabled = disabled || elementDisabled;
24
- const localId = id ?? setId(elementId, "counter");
25
- const currentId = setId(localId, "currentQuantity");
26
- const maxQuantityId = setId(localId, "maxQuantity");
22
+ const context = useContext(HvFormElementContext);
23
+ const disabled = disabledProp ?? context.disabled;
24
+ const id = idProp ?? setId(context.id, "counter");
25
+ const currentId = setId(id, "currentQuantity");
26
+ const maxQuantityId = setId(id, "maxQuantity");
27
27
  const isOverloaded = currentCharQuantity > maxCharQuantity;
28
28
  return /* @__PURE__ */ jsxs(
29
29
  "div",
30
30
  {
31
- id: localId,
31
+ id,
32
32
  className: cx(
33
33
  classes.root,
34
34
  {
35
- [classes.counterDisabled]: !!localDisabled,
35
+ [classes.counterDisabled]: disabled,
36
36
  [classes.gutter]: !disableGutter
37
37
  },
38
38
  className
39
39
  ),
40
40
  "aria-live": "polite",
41
- "aria-disabled": localDisabled,
41
+ "aria-disabled": disabled,
42
42
  ...others,
43
43
  children: [
44
44
  /* @__PURE__ */ jsx(
@@ -46,8 +46,8 @@ const HvCharCounter = (props) => {
46
46
  {
47
47
  id: currentId,
48
48
  className: cx({
49
- [classes.overloaded]: isOverloaded && !localDisabled,
50
- [classes.counterDisabled]: !!localDisabled
49
+ [classes.overloaded]: isOverloaded && !disabled,
50
+ [classes.counterDisabled]: disabled
51
51
  }),
52
52
  variant: "label",
53
53
  component: "label",
@@ -59,8 +59,8 @@ const HvCharCounter = (props) => {
59
59
  {
60
60
  id: maxQuantityId,
61
61
  className: cx({
62
- [classes.overloaded]: isOverloaded && !localDisabled,
63
- [classes.counterDisabled]: !!localDisabled
62
+ [classes.overloaded]: isOverloaded && !disabled,
63
+ [classes.counterDisabled]: disabled
64
64
  }),
65
65
  variant: "body",
66
66
  component: "label",
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CharCounter.js","sources":["../../../../src/FormElement/CharCounter/CharCounter.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../../types/generic\";\nimport { HvTypography } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./CharCounter.styles\";\n\nexport { staticClasses as charCounterClasses };\n\nexport type HvCharCounterClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCharCounterProps extends HvBaseProps {\n /** The string that separates the current char quantity from the max quantity. */\n separator?: string;\n /** The maximum allowed length of the characters. */\n maxCharQuantity: number;\n /** The current char quantity to be rendered. */\n currentCharQuantity?: number;\n /** If `true` the counter is disabled. */\n disabled?: boolean;\n /** If `true` the info message won't have margins. */\n disableGutter?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvCharCounterClasses;\n}\n\n/**\n * Displays the capacity and current usage of a text input box (character count by default).\n *\n * Use the character counter when there is a character or word limit.\n * By itself it doesn't block the user from going above the limit.\n */\nexport const HvCharCounter = (props: HvCharCounterProps) => {\n const {\n separator = \"/\",\n maxCharQuantity,\n currentCharQuantity = 0,\n classes: classesProp,\n className,\n id: idProp,\n disabled: disabledProp,\n disableGutter = false,\n ...others\n } = useDefaultProps(\"HvCharCounter\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const disabled = disabledProp ?? context.disabled;\n const id = idProp ?? setId(context.id, \"counter\");\n const currentId = setId(id, \"currentQuantity\");\n const maxQuantityId = setId(id, \"maxQuantity\");\n const isOverloaded = currentCharQuantity > maxCharQuantity;\n\n return (\n <div\n id={id}\n className={cx(\n classes.root,\n {\n [classes.counterDisabled]: disabled,\n [classes.gutter]: !disableGutter,\n },\n className,\n )}\n aria-live=\"polite\"\n aria-disabled={disabled}\n {...others}\n >\n <HvTypography\n id={currentId}\n className={cx({\n [classes.overloaded]: isOverloaded && !disabled,\n [classes.counterDisabled]: disabled,\n })}\n variant=\"label\"\n component=\"label\"\n >\n {currentCharQuantity}\n </HvTypography>\n <HvTypography\n id={maxQuantityId}\n className={cx({\n [classes.overloaded]: isOverloaded && !disabled,\n [classes.counterDisabled]: disabled,\n })}\n variant=\"body\"\n component=\"label\"\n >\n {` ${separator} ${maxCharQuantity}`}\n </HvTypography>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAqCa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA,sBAAsB;AAAA,IACtB,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AACzC,QAAA,WAAW,gBAAgB,QAAQ;AACzC,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,SAAS;AAC1C,QAAA,YAAY,MAAM,IAAI,iBAAiB;AACvC,QAAA,gBAAgB,MAAM,IAAI,aAAa;AAC7C,QAAM,eAAe,sBAAsB;AAGzC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,eAAe,GAAG;AAAA,UAC3B,CAAC,QAAQ,MAAM,GAAG,CAAC;AAAA,QACrB;AAAA,QACA;AAAA,MACF;AAAA,MACA,aAAU;AAAA,MACV,iBAAe;AAAA,MACd,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI;AAAA,YACJ,WAAW,GAAG;AAAA,cACZ,CAAC,QAAQ,UAAU,GAAG,gBAAgB,CAAC;AAAA,cACvC,CAAC,QAAQ,eAAe,GAAG;AAAA,YAAA,CAC5B;AAAA,YACD,SAAQ;AAAA,YACR,WAAU;AAAA,YAET,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI;AAAA,YACJ,WAAW,GAAG;AAAA,cACZ,CAAC,QAAQ,UAAU,GAAG,gBAAgB,CAAC;AAAA,cACvC,CAAC,QAAQ,eAAe,GAAG;AAAA,YAAA,CAC5B;AAAA,YACD,SAAQ;AAAA,YACR,WAAU;AAAA,YAET,UAAA,IAAI,SAAS,IAAI,eAAe;AAAA,UAAA;AAAA,QAAA;AAAA,MACnC;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CharCounter.styles.js","sources":["../../../../src/FormElement/CharCounter/CharCounter.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvCharCounter\", {\n root: { display: \"inline-block\", float: \"right\" },\n counterDisabled: { color: theme.colors.secondary_60 },\n gutter: { paddingLeft: \"6px\" },\n overloaded: { color: theme.colors.negative },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,SAAS,gBAAgB,OAAO,QAAQ;AAAA,EAChD,iBAAiB,EAAE,OAAO,MAAM,OAAO,aAAa;AAAA,EACpD,QAAQ,EAAE,aAAa,MAAM;AAAA,EAC7B,YAAY,EAAE,OAAO,MAAM,OAAO,SAAS;AAC7C,CAAC;"}
@@ -0,0 +1,36 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
+ import { useUniqueId } from "../hooks/useUniqueId.js";
5
+ import { HvFormElementContext, HvFormElementValueContext, HvFormElementDescriptorsContext } from "./context.js";
6
+ import { useClasses } from "./FormElement.styles.js";
7
+ import { staticClasses } from "./FormElement.styles.js";
8
+ import { findDescriptors } from "./utils.js";
9
+ const HvFormElement = (props) => {
10
+ const {
11
+ classes: classesProp,
12
+ className,
13
+ children,
14
+ id: idProp,
15
+ name,
16
+ value,
17
+ disabled,
18
+ required,
19
+ readOnly,
20
+ status = "standBy",
21
+ ...others
22
+ } = useDefaultProps("HvFormElement", props);
23
+ const { classes, cx } = useClasses(classesProp);
24
+ const id = useUniqueId(idProp);
25
+ const contextValue = useMemo(
26
+ () => ({ id, name, status, disabled, required, readOnly }),
27
+ [id, name, status, disabled, required, readOnly]
28
+ );
29
+ const descriptors = useMemo(() => findDescriptors(children), [children]);
30
+ return /* @__PURE__ */ jsx("div", { id, className: cx(classes.root, className), ...others, children: /* @__PURE__ */ jsx(HvFormElementContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(HvFormElementValueContext.Provider, { value, children: /* @__PURE__ */ jsx(HvFormElementDescriptorsContext.Provider, { value: descriptors, children }) }) }) });
31
+ };
32
+ HvFormElement.formElementType = "formelement";
33
+ export {
34
+ HvFormElement,
35
+ staticClasses as formElementClasses
36
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormElement.js","sources":["../../../src/FormElement/FormElement.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport {\n HvFormElementContext,\n HvFormElementDescriptorsContext,\n HvFormElementValueContext,\n type HvFormElementContextValue,\n} from \"./context\";\nimport { staticClasses, useClasses } from \"./FormElement.styles\";\nimport { findDescriptors } from \"./utils\";\n\nexport { staticClasses as formElementClasses };\n\nexport type HvFormElementClasses = ExtractNames<typeof useClasses>;\n\nexport type HvFormStatus = \"standBy\" | \"valid\" | \"invalid\" | \"empty\";\n\nexport interface HvFormElementProps\n extends HvFormElementContextValue,\n HvBaseProps<HTMLDivElement, \"onChange\" | \"onToggle\"> {\n /**\n * Current value of the form element.\n *\n * Part of a name/value pair, should be the value property of the underling native input.\n */\n value?: 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 /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /** The callback fired when the value changes. */\n onChange?: (event: React.FormEvent<HTMLDivElement>) => void;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFormElementClasses;\n}\n\n/**\n * Provides form-related context (ie. required/disabled/readOnly) for building form components,\n * analogous to MUI's [`FormControl`](https://mui.com/material-ui/api/form-control/) component.\n *\n * It is used internally to build UI Kit's form components (eg. `HvInput`, `HvDatePicker`), and can be used to build custom form components.\n */\nexport const HvFormElement = (props: HvFormElementProps) => {\n const {\n classes: classesProp,\n className,\n children,\n id: idProp,\n name,\n value,\n disabled,\n required,\n readOnly,\n status = \"standBy\",\n ...others\n } = useDefaultProps(\"HvFormElement\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const id = useUniqueId(idProp);\n\n const contextValue = useMemo<HvFormElementContextValue>(\n () => ({ id, name, status, disabled, required, readOnly }),\n [id, name, status, disabled, required, readOnly],\n );\n\n const descriptors = useMemo(() => findDescriptors(children), [children]);\n\n return (\n <div id={id} className={cx(classes.root, className)} {...others}>\n <HvFormElementContext.Provider value={contextValue}>\n <HvFormElementValueContext.Provider value={value}>\n <HvFormElementDescriptorsContext.Provider value={descriptors}>\n {children}\n </HvFormElementDescriptorsContext.Provider>\n </HvFormElementValueContext.Provider>\n </HvFormElementContext.Provider>\n </div>\n );\n};\n\nHvFormElement.formElementType = \"formelement\";\n"],"names":[],"mappings":";;;;;;;;AAuDa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,KAAK,YAAY,MAAM;AAE7B,QAAM,eAAe;AAAA,IACnB,OAAO,EAAE,IAAI,MAAM,QAAQ,UAAU,UAAU;IAC/C,CAAC,IAAI,MAAM,QAAQ,UAAU,UAAU,QAAQ;AAAA,EACjD;AAEM,QAAA,cAAc,QAAQ,MAAM,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAEvE,SACG,oBAAA,OAAA,EAAI,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QACvD,UAAA,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,cACpC,UAAC,oBAAA,0BAA0B,UAA1B,EAAmC,OAClC,UAAC,oBAAA,gCAAgC,UAAhC,EAAyC,OAAO,aAC9C,SACH,CAAA,EACF,CAAA,EACF,CAAA,GACF;AAEJ;AAEA,cAAc,kBAAkB;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormElement.styles.js","sources":["../../../src/FormElement/FormElement.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFormElement\", {\n root: {},\n});\n"],"names":[],"mappings":";AAEO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,CAAA;AACR,CAAC;"}
@@ -2,32 +2,32 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { setId } from "../../utils/setId.js";
5
+ import { HvFormElementContext } from "../context.js";
5
6
  import { useClasses } from "./InfoMessage.styles.js";
6
7
  import { staticClasses } from "./InfoMessage.styles.js";
7
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
8
8
  import { HvTypography } from "../../Typography/Typography.js";
9
9
  const HvInfoMessage = (props) => {
10
10
  const {
11
- id,
11
+ id: idProp,
12
12
  classes: classesProp,
13
13
  className,
14
14
  children,
15
- disabled,
15
+ disabled: disabledProp,
16
16
  disableGutter = false,
17
17
  ...others
18
18
  } = useDefaultProps("HvInfoMessage", props);
19
19
  const { classes, cx } = useClasses(classesProp);
20
- const { elementId, elementDisabled } = useContext(HvFormElementContext);
21
- const localDisabled = disabled || elementDisabled;
22
- const localId = id ?? setId(elementId, "description");
20
+ const context = useContext(HvFormElementContext);
21
+ const disabled = disabledProp ?? context.disabled;
22
+ const id = idProp ?? setId(context.id, "description");
23
23
  return /* @__PURE__ */ jsx(
24
24
  HvTypography,
25
25
  {
26
- id: localId,
26
+ id,
27
27
  className: cx(
28
28
  classes.root,
29
29
  {
30
- [classes.infoDisabled]: !!localDisabled,
30
+ [classes.infoDisabled]: !!disabled,
31
31
  [classes.gutter]: !disableGutter
32
32
  },
33
33
  className
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoMessage.js","sources":["../../../../src/FormElement/InfoMessage/InfoMessage.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./InfoMessage.styles\";\n\nexport { staticClasses as infoMessageClasses };\n\nexport type HvInfoMessageClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvInfoMessageProps extends HvTypographyProps<\"label\"> {\n /** If `true` the label is disabled. */\n disabled?: boolean;\n /** If `true` the info message won't have margins. */\n disableGutter?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInfoMessageClasses;\n}\n\n/**\n * Provides the user with additional descriptive text for the form element.\n */\nexport const HvInfoMessage = (props: HvInfoMessageProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n children,\n disabled: disabledProp,\n disableGutter = false,\n ...others\n } = useDefaultProps(\"HvInfoMessage\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const disabled = disabledProp ?? context.disabled;\n const id = idProp ?? setId(context.id, \"description\");\n\n return (\n <HvTypography\n id={id}\n className={cx(\n classes.root,\n {\n [classes.infoDisabled]: !!disabled,\n [classes.gutter]: !disableGutter,\n },\n className,\n )}\n variant=\"body\"\n component=\"label\"\n {...others}\n >\n {children}\n </HvTypography>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA2Ba,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AACzC,QAAA,WAAW,gBAAgB,QAAQ;AACzC,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,aAAa;AAGlD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,YAAY,GAAG,CAAC,CAAC;AAAA,UAC1B,CAAC,QAAQ,MAAM,GAAG,CAAC;AAAA,QACrB;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAQ;AAAA,MACR,WAAU;AAAA,MACT,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoMessage.styles.js","sources":["../../../../src/FormElement/InfoMessage/InfoMessage.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvInfoMessage\", {\n root: { color: theme.colors.secondary_80, display: \"inline-block\" },\n infoDisabled: { color: theme.colors.secondary_60 },\n gutter: { padding: `0 0 6px ${theme.space.xs}` },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,OAAO,MAAM,OAAO,cAAc,SAAS,eAAe;AAAA,EAClE,cAAc,EAAE,OAAO,MAAM,OAAO,aAAa;AAAA,EACjD,QAAQ,EAAE,SAAS,WAAW,MAAM,MAAM,EAAE,GAAG;AACjD,CAAC;"}
@@ -2,38 +2,38 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { setId } from "../../utils/setId.js";
5
- import { findDescriptors } from "../FormElement/utils/FormUtils.js";
5
+ import { HvFormElementContext } from "../context.js";
6
+ import { findDescriptors } from "../utils.js";
6
7
  import { useClasses } from "./Label.styles.js";
7
8
  import { staticClasses } from "./Label.styles.js";
8
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
9
9
  import { HvTypography } from "../../Typography/Typography.js";
10
10
  const HvLabel = (props) => {
11
11
  const {
12
- id,
12
+ id: idProp,
13
13
  classes: classesProp,
14
14
  className,
15
15
  children,
16
16
  label,
17
- disabled,
18
- required,
17
+ disabled: disabledProp,
18
+ required: requiredProp,
19
19
  htmlFor: htmlForProp,
20
20
  ...others
21
21
  } = useDefaultProps("HvLabel", props);
22
22
  const { classes, cx } = useClasses(classesProp);
23
- const { elementId, elementDisabled, elementRequired } = useContext(HvFormElementContext);
24
- const localDisabled = disabled || elementDisabled;
25
- const localRequired = required || elementRequired;
26
- const localId = id ?? setId(elementId, "label");
23
+ const context = useContext(HvFormElementContext);
24
+ const disabled = disabledProp ?? context.disabled;
25
+ const required = requiredProp ?? context.required;
26
+ const id = idProp ?? setId(context.id, "label");
27
27
  const forId = htmlForProp || findDescriptors(children)?.input?.[0]?.id;
28
28
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29
29
  /* @__PURE__ */ jsxs(
30
30
  HvTypography,
31
31
  {
32
- id: localId,
32
+ id,
33
33
  className: cx(
34
34
  classes.root,
35
35
  {
36
- [classes.labelDisabled]: !!localDisabled,
36
+ [classes.labelDisabled]: !!disabled,
37
37
  [classes.childGutter]: !!(children && label)
38
38
  },
39
39
  className
@@ -44,7 +44,7 @@ const HvLabel = (props) => {
44
44
  ...others,
45
45
  children: [
46
46
  label,
47
- localRequired && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "*" })
47
+ required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "*" })
48
48
  ]
49
49
  }
50
50
  ),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Label.js","sources":["../../../../src/FormElement/Label/Label.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { findDescriptors } from \"../utils\";\nimport { staticClasses, useClasses } from \"./Label.styles\";\n\nexport { staticClasses as labelClasses };\n\nexport type HvLabelClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvLabelProps extends HvTypographyProps<\"label\"> {\n /** Id to be applied to the root node */\n id?: string;\n /** The text to be shown by the label. */\n label?: React.ReactNode;\n /** The id of the form element the label is bound to. */\n htmlFor?: string;\n /** If `true` the label is displayed with a disabled style. */\n disabled?: boolean;\n /** If `true`, the label will indicate that the form element is required (an `*` after the label text). */\n required?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvLabelClasses;\n}\n\n/**\n * Provides the user with a recognizable name for a given form element.\n */\nexport const HvLabel = (props: HvLabelProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n children,\n label,\n disabled: disabledProp,\n required: requiredProp,\n htmlFor: htmlForProp,\n ...others\n } = useDefaultProps(\"HvLabel\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n\n const disabled = disabledProp ?? context.disabled;\n const required = requiredProp ?? context.required;\n const id = idProp ?? setId(context.id, \"label\");\n\n const forId = htmlForProp || findDescriptors(children)?.input?.[0]?.id;\n\n return (\n <>\n <HvTypography\n id={id}\n className={cx(\n classes.root,\n {\n [classes.labelDisabled]: !!disabled,\n [classes.childGutter]: !!(children && label),\n },\n className,\n )}\n variant=\"label\"\n component=\"label\"\n htmlFor={forId}\n {...others}\n >\n {label}\n {required && <span aria-hidden=\"true\">*</span>}\n </HvTypography>\n {children}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAkCa,MAAA,UAAU,CAAC,UAAwB;AACxC,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,UAAU;AAAA,IACV,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,WAAW,KAAK;AAEpC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AAEzC,QAAA,WAAW,gBAAgB,QAAQ;AACnC,QAAA,WAAW,gBAAgB,QAAQ;AACzC,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,OAAO;AAE9C,QAAM,QAAQ,eAAe,gBAAgB,QAAQ,GAAG,QAAQ,CAAC,GAAG;AAEpE,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT,QAAQ;AAAA,UACR;AAAA,YACE,CAAC,QAAQ,aAAa,GAAG,CAAC,CAAC;AAAA,YAC3B,CAAC,QAAQ,WAAW,GAAG,CAAC,EAAE,YAAY;AAAA,UACxC;AAAA,UACA;AAAA,QACF;AAAA,QACA,SAAQ;AAAA,QACR,WAAU;AAAA,QACV,SAAS;AAAA,QACR,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA,YAAY,oBAAC,QAAK,EAAA,eAAY,QAAO,UAAC,IAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACzC;AAAA,IACC;AAAA,EAAA,GACH;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Label.styles.js","sources":["../../../../src/FormElement/Label/Label.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvLabel\", {\n root: { fontWeight: theme.fontWeights.normal, display: \"inline-block\" },\n labelDisabled: { color: theme.colors.secondary_60 },\n childGutter: { paddingBottom: \"6px\" },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,WAAW;AAAA,EACpE,MAAM,EAAE,YAAY,MAAM,YAAY,QAAQ,SAAS,eAAe;AAAA,EACtE,eAAe,EAAE,OAAO,MAAM,OAAO,aAAa;AAAA,EAClD,aAAa,EAAE,eAAe,MAAM;AACtC,CAAC;"}
@@ -6,14 +6,14 @@ import { useForkRef } from "@mui/material/utils";
6
6
  import { useTheme } from "@hitachivantara/uikit-react-utils";
7
7
  import { getContainerElement } from "../../utils/document.js";
8
8
  import { setId } from "../../utils/setId.js";
9
+ import { HvFormElementContext } from "../context.js";
9
10
  import { useClasses } from "./Suggestions.styles.js";
10
11
  import { staticClasses } from "./Suggestions.styles.js";
11
12
  import { HvSelectionList } from "../../SelectionList/SelectionList.js";
12
13
  import { HvListItem } from "../../ListContainer/ListItem/ListItem.js";
13
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
14
- const HvSuggestions = forwardRef((props, extRef) => {
14
+ const HvSuggestions = forwardRef(function HvSuggestions2(props, extRef) {
15
15
  const {
16
- id,
16
+ id: idProp,
17
17
  className,
18
18
  classes: classesProp,
19
19
  expanded = false,
@@ -28,8 +28,8 @@ const HvSuggestions = forwardRef((props, extRef) => {
28
28
  } = props;
29
29
  const { classes, cx } = useClasses(classesProp);
30
30
  const { rootId } = useTheme();
31
- const { elementId } = useContext(HvFormElementContext);
32
- const localId = id ?? setId(elementId, "suggestions");
31
+ const context = useContext(HvFormElementContext);
32
+ const id = idProp ?? setId(context.id, "suggestions");
33
33
  const ref = useRef(null);
34
34
  const forkedRef = useForkRef(ref, extRef);
35
35
  const [isOpen, setIsOpen] = useState(expanded);
@@ -39,7 +39,7 @@ const HvSuggestions = forwardRef((props, extRef) => {
39
39
  return /* @__PURE__ */ jsx(
40
40
  "div",
41
41
  {
42
- id: localId,
42
+ id,
43
43
  ref: forkedRef,
44
44
  className: cx(classes.root, className),
45
45
  ...others,
@@ -69,7 +69,7 @@ const HvSuggestions = forwardRef((props, extRef) => {
69
69
  HvSelectionList,
70
70
  {
71
71
  className: classes.list,
72
- id: setId(localId, "list"),
72
+ id: setId(id, "list"),
73
73
  onChange: onSuggestionSelected,
74
74
  children: suggestionValues?.map((item) => /* @__PURE__ */ jsx(HvListItem, { value: item, disabled: item.disabled, children: item.label }, item.id))
75
75
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Suggestions.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useRef, useState } from \"react\";\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n} from \"@mui/base/ClickAwayListener\";\nimport { Popper, PopperProps } from \"@mui/base/Popper\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport { useTheme, type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvListItem } from \"../../ListContainer\";\nimport { HvSelectionList } from \"../../SelectionList\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { getContainerElement } from \"../../utils/document\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./Suggestions.styles\";\n\nexport { staticClasses as suggestionsClasses };\n\nexport type HvSuggestionsClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSuggestion {\n id?: string;\n label: React.ReactNode;\n value?: string;\n disabled?: boolean;\n}\n\nexport interface HvSuggestionsProps extends HvBaseProps {\n /** Whether suggestions is visible */\n open?: boolean;\n /**\n * Whether suggestions is visible.\n * @deprecated use `open` instead.\n * */\n expanded?: boolean;\n /** The HTML element Suggestions attaches to. */\n anchorEl?: HTMLElement | null;\n /** Array of { id, label, ...others } values to display in the suggestion list */\n suggestionValues?: HvSuggestion[] | null;\n /** Function called when a suggestion is selected */\n onSuggestionSelected?: (event: React.MouseEvent, value: HvSuggestion) => void;\n /** Function called when suggestion list is closed */\n onClose?: ClickAwayListenerProps[\"onClickAway\"];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSuggestionsClasses;\n /**\n * If enabled, the suggestions list will be rendered using a portal.\n * If disabled, it will be under the DOM hierarchy of the parent component.\n * @default false\n * */\n enablePortal?: boolean;\n /** Props passed to the underlying MUI Popper component */\n popperProps?: Partial<PopperProps>;\n}\n\nexport const HvSuggestions = forwardRef<\n // no-indent\n unknown,\n HvSuggestionsProps\n>(function HvSuggestions(props, extRef) {\n const {\n id: idProp,\n className,\n classes: classesProp,\n expanded = false,\n enablePortal = false,\n open: openProp,\n anchorEl,\n suggestionValues = [],\n onClose,\n onSuggestionSelected,\n popperProps,\n ...others\n } = props;\n\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const context = useContext(HvFormElementContext);\n const id = idProp ?? setId(context.id, \"suggestions\");\n\n const ref = useRef<HTMLDivElement>(null);\n const forkedRef = useForkRef(ref, extRef);\n\n // TODO: remove controlled+uncontrolled `expanded` prop in v6\n const [isOpen, setIsOpen] = useState(expanded);\n useEffect(() => {\n setIsOpen(expanded);\n }, [expanded]);\n\n return (\n <div\n id={id}\n ref={forkedRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <ClickAwayListener\n onClickAway={(event) => {\n setIsOpen(false);\n onClose?.(event);\n }}\n >\n <Popper\n style={{\n // @ts-ignore\n \"--popper-width\": enablePortal\n ? `${anchorEl?.clientWidth}px`\n : \"100%\",\n }}\n open={openProp ?? isOpen}\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={anchorEl}\n className={cx(classes.popper, {\n [classes.portal]: enablePortal,\n })}\n {...popperProps}\n >\n <HvSelectionList\n className={classes.list}\n id={setId(id, \"list\")}\n onChange={onSuggestionSelected}\n >\n {suggestionValues?.map((item) => (\n <HvListItem key={item.id} value={item} disabled={item.disabled}>\n {item.label}\n </HvListItem>\n ))}\n </HvSelectionList>\n </Popper>\n </ClickAwayListener>\n </div>\n );\n});\n"],"names":["HvSuggestions"],"mappings":";;;;;;;;;;;;;AAwDO,MAAM,gBAAgB,WAI3B,SAASA,eAAc,OAAO,QAAQ;AAChC,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,eAAe;AAAA,IACf,MAAM;AAAA,IACN;AAAA,IACA,mBAAmB,CAAC;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,EAAE,OAAO,IAAI,SAAS;AAEtB,QAAA,UAAU,WAAW,oBAAoB;AAC/C,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,aAAa;AAE9C,QAAA,MAAM,OAAuB,IAAI;AACjC,QAAA,YAAY,WAAW,KAAK,MAAM;AAGxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,QAAQ;AAC7C,YAAU,MAAM;AACd,cAAU,QAAQ;AAAA,EAAA,GACjB,CAAC,QAAQ,CAAC;AAGX,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,KAAK;AAAA,MACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,MACpC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAa,CAAC,UAAU;AACtB,sBAAU,KAAK;AACf,sBAAU,KAAK;AAAA,UACjB;AAAA,UAEA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO;AAAA;AAAA,gBAEL,kBAAkB,eACd,GAAG,UAAU,WAAW,OACxB;AAAA,cACN;AAAA,cACA,MAAM,YAAY;AAAA,cAClB,eAAe,CAAC;AAAA,cAChB,WAAW,eAAe,oBAAoB,MAAM,IAAI;AAAA,cACxD;AAAA,cACA,WAAW,GAAG,QAAQ,QAAQ;AAAA,gBAC5B,CAAC,QAAQ,MAAM,GAAG;AAAA,cAAA,CACnB;AAAA,cACA,GAAG;AAAA,cAEJ,UAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAW,QAAQ;AAAA,kBACnB,IAAI,MAAM,IAAI,MAAM;AAAA,kBACpB,UAAU;AAAA,kBAET,UAAkB,kBAAA,IAAI,CAAC,6BACrB,YAAyB,EAAA,OAAO,MAAM,UAAU,KAAK,UACnD,UAAA,KAAK,MADS,GAAA,KAAK,EAEtB,CACD;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Suggestions.styles.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSuggestions\", {\n root: { position: \"relative\" },\n list: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n padding: theme.space.xs,\n width: \"100%\",\n },\n popper: {\n width: \"var(--popper-width)\",\n position: \"absolute\",\n zIndex: theme.zIndices.tooltip,\n \":not($portal)\": {\n transform: \"translate3d(0, -1px, 0) !important\",\n },\n },\n portal: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,UAAU,WAAW;AAAA,EAC7B,MAAM;AAAA,IACJ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,WAAW,MAAM,OAAO;AAAA,IACxB,SAAS,MAAM,MAAM;AAAA,IACrB,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ,MAAM,SAAS;AAAA,IACvB,iBAAiB;AAAA,MACf,WAAW;AAAA,IAAA;AAAA,EAEf;AAAA,EACA,QAAQ,CAAA;AACV,CAAC;"}
@@ -3,9 +3,9 @@ import { useContext } from "react";
3
3
  import { Fail } from "@hitachivantara/uikit-react-icons";
4
4
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
5
5
  import { setId } from "../../utils/setId.js";
6
+ import { HvFormElementContext } from "../context.js";
6
7
  import { useClasses } from "./WarningText.styles.js";
7
8
  import { staticClasses } from "./WarningText.styles.js";
8
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
9
9
  const HvWarningText = (props) => {
10
10
  const {
11
11
  children,
@@ -22,10 +22,10 @@ const HvWarningText = (props) => {
22
22
  ...others
23
23
  } = useDefaultProps("HvWarningText", props);
24
24
  const { classes, cx } = useClasses(classesProp);
25
- const { elementId, elementStatus, elementDisabled } = useContext(HvFormElementContext);
26
- const disabled = disabledProp || elementDisabled;
27
- const visible = isVisibleProp ?? elementStatus === "invalid";
28
- const id = idProp ?? setId(elementId, "error");
25
+ const context = useContext(HvFormElementContext);
26
+ const disabled = disabledProp ?? context.disabled;
27
+ const visible = isVisibleProp ?? context.status === "invalid";
28
+ const id = idProp ?? setId(context.id, "error");
29
29
  const showWarning = visible && !disabled;
30
30
  const adornment = adornmentProp || /* @__PURE__ */ jsx(Fail, { size: "xs", className: classes.defaultIcon });
31
31
  return /* @__PURE__ */ jsxs(
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WarningText.js","sources":["../../../../src/FormElement/WarningText/WarningText.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { Fail } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../../types/generic\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./WarningText.styles\";\n\nexport { staticClasses as warningTextClasses };\n\nexport type HvWarningTextClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvWarningTextProps extends HvBaseProps {\n /** Icon to be rendered alongside the warning text. */\n adornment?: React.ReactNode;\n /** If `true` the text is not rendered. */\n isVisible?: boolean;\n /** If `true` the text is disabled. */\n disabled?: boolean;\n /** If `true` the text won't include a gutter. */\n disableGutter?: boolean;\n /** If `true` the text won't include the top border. */\n disableBorder?: boolean;\n /** If `true` the adornment icon isn't shown. */\n disableAdornment?: boolean;\n /** If `true` the text isn't shown. */\n hideText?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvWarningTextClasses;\n}\n\n/**\n * Provides the user with a descriptive text, signaling an error, for when the form element is in an invalid state.\n */\nexport const HvWarningText = (props: HvWarningTextProps) => {\n const {\n children,\n adornment: adornmentProp,\n isVisible: isVisibleProp,\n classes: classesProp,\n className,\n id: idProp,\n disabled: disabledProp,\n disableGutter = false,\n disableBorder = false,\n disableAdornment = false,\n hideText = false,\n ...others\n } = useDefaultProps(\"HvWarningText\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const disabled = disabledProp ?? context.disabled;\n const visible = isVisibleProp ?? context.status === \"invalid\";\n const id = idProp ?? setId(context.id, \"error\");\n const showWarning = visible && !disabled;\n const adornment = adornmentProp || (\n <Fail size=\"xs\" className={classes.defaultIcon} />\n );\n\n return (\n <div\n className={cx(\n classes.root,\n {\n [classes.show]: showWarning,\n [classes.topBorder]: !disableBorder,\n },\n className,\n )}\n >\n {!disableAdornment && adornment}\n <span\n id={id}\n className={cx(classes.warningText, {\n [classes.topGutter]: !disableGutter,\n [classes.hideText]: hideText,\n })}\n role=\"status\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n {...others}\n >\n {showWarning && children}\n </span>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAsCa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AACzC,QAAA,WAAW,gBAAgB,QAAQ;AACnC,QAAA,UAAU,iBAAiB,QAAQ,WAAW;AACpD,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,OAAO;AACxC,QAAA,cAAc,WAAW,CAAC;AAC1B,QAAA,YAAY,iBACf,oBAAA,MAAA,EAAK,MAAK,MAAK,WAAW,QAAQ,aAAa;AAIhD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,IAAI,GAAG;AAAA,UAChB,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,QACxB;AAAA,QACA;AAAA,MACF;AAAA,MAEC,UAAA;AAAA,QAAA,CAAC,oBAAoB;AAAA,QACtB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,WAAW,GAAG,QAAQ,aAAa;AAAA,cACjC,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,cACtB,CAAC,QAAQ,QAAQ,GAAG;AAAA,YAAA,CACrB;AAAA,YACD,MAAK;AAAA,YACL,aAAU;AAAA,YACV,iBAAc;AAAA,YACb,GAAG;AAAA,YAEH,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WarningText.styles.js","sources":["../../../../src/FormElement/WarningText/WarningText.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvWarningText\", {\n root: {\n display: \"none\",\n color: theme.colors.negative_120,\n },\n defaultIcon: { minWidth: \"24px\", width: \"24px\", height: \"24px\" },\n warningText: {\n ...theme.typography.caption1,\n color: \"inherit\",\n paddingRight: theme.space.xs,\n },\n show: { display: \"flex\" },\n topGutter: { paddingTop: \"3px\" },\n hideText: {\n // display none or visibility hidden prevents\n // browser to trigger the aria-alert\n width: 0,\n height: 0,\n padding: 0,\n margin: 0,\n overflow: \"hidden\",\n },\n topBorder: { borderTop: \"1px solid currentcolor\" },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,aAAa,EAAE,UAAU,QAAQ,OAAO,QAAQ,QAAQ,OAAO;AAAA,EAC/D,aAAa;AAAA,IACX,GAAG,MAAM,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,MAAM,EAAE,SAAS,OAAO;AAAA,EACxB,WAAW,EAAE,YAAY,MAAM;AAAA,EAC/B,UAAU;AAAA;AAAA;AAAA,IAGR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,WAAW,EAAE,WAAW,yBAAyB;AACnD,CAAC;"}
@@ -0,0 +1,11 @@
1
+ import { createContext } from "react";
2
+ const HvFormElementContext = createContext(
3
+ {}
4
+ );
5
+ const HvFormElementDescriptorsContext = createContext({});
6
+ const HvFormElementValueContext = createContext(void 0);
7
+ export {
8
+ HvFormElementContext,
9
+ HvFormElementDescriptorsContext,
10
+ HvFormElementValueContext
11
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/FormElement/context.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nimport type { HvFormStatus } from \"./FormElement\";\n\nexport interface HvFormElementContextValue {\n /** id to be applied to the form element root node. */\n id?: string;\n /**\n * Name of the form element.\n *\n * Part of a name/value pair, should be the name property of the underling native input.\n */\n name?: string;\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 /** Whether the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: boolean;\n}\n\nexport const HvFormElementContext = createContext<HvFormElementContextValue>(\n {},\n);\n\nexport interface HvFormElementDescriptorsContextValue {\n input?: any;\n label?: any;\n descriptors?: any;\n}\n\nexport const HvFormElementDescriptorsContext =\n createContext<HvFormElementDescriptorsContextValue>({});\n\nexport const HvFormElementValueContext = createContext<any>(undefined);\n"],"names":[],"mappings":";AA8BO,MAAM,uBAAuB;AAAA,EAClC,CAAA;AACF;AAQa,MAAA,kCACX,cAAoD,CAAE,CAAA;AAE3C,MAAA,4BAA4B,cAAmB,MAAS;"}
@@ -1,4 +1,4 @@
1
- import React__default from "react";
1
+ import { Children } from "react";
2
2
  const findDescriptors = (children, descriptors = {
3
3
  input: [],
4
4
  label: [],
@@ -8,7 +8,7 @@ const findDescriptors = (children, descriptors = {
8
8
  // TODO: refactor this out
9
9
  HvCalendarHeader: []
10
10
  }) => {
11
- React__default.Children.forEach(children, (child) => {
11
+ Children.forEach(children, (child) => {
12
12
  if (child?.type?.formElementType && child.props?.id) {
13
13
  descriptors[child.type.formElementType]?.push(
14
14
  {
@@ -33,29 +33,39 @@ const getIdReferenceFor = (formElementType, descriptors, filterFor = null) => {
33
33
  };
34
34
  const buildFormElementPropsFromContext = (name, disabled, readOnly, required, context) => {
35
35
  return {
36
- name: name || context?.elementName,
37
- disabled: disabled !== void 0 ? disabled : context?.elementDisabled,
38
- readOnly: readOnly !== void 0 ? readOnly : context?.elementReadOnly,
39
- required: required !== void 0 ? required : context?.elementRequired,
40
- status: context?.elementStatus
36
+ name: name || context?.name,
37
+ disabled: disabled ?? context?.disabled,
38
+ readOnly: readOnly ?? context?.readOnly,
39
+ required: required ?? context?.required,
40
+ status: context?.status
41
41
  };
42
42
  };
43
- const buildAriaPropsFromContext = (props, context, isInvalid, inputId) => {
43
+ const buildAriaPropsFromContext = (props, context, isInvalid2, inputId) => {
44
44
  const arias = {
45
45
  "aria-labelledby": props?.["aria-labelledby"] !== void 0 ? props?.["aria-labelledby"] : getIdReferenceListFor("label", context?.descriptors, inputId),
46
46
  "aria-describedby": props?.["aria-describedby"] !== void 0 ? props?.["aria-describedby"] : getIdReferenceListFor("description", context?.descriptors),
47
47
  "aria-controls": props?.["aria-controls"] !== void 0 ? props?.["aria-controls"] : getIdReferenceListFor("controlled", context?.descriptors)
48
48
  };
49
- if (isInvalid) {
50
- arias["aria-invalid"] = isInvalid;
49
+ if (isInvalid2) {
50
+ arias["aria-invalid"] = isInvalid2;
51
51
  arias["aria-errormessage"] = props?.["aria-errormessage"] !== void 0 ? props?.["aria-errormessage"] : getIdReferenceFor("errormessage", context?.descriptors);
52
52
  }
53
53
  return arias;
54
54
  };
55
+ const validationStates = Object.freeze({
56
+ standBy: "standBy",
57
+ valid: "valid",
58
+ invalid: "invalid"
59
+ });
60
+ const isValid = (state) => state === validationStates.valid;
61
+ const isInvalid = (state) => state === validationStates.invalid;
55
62
  export {
56
63
  buildAriaPropsFromContext,
57
64
  buildFormElementPropsFromContext,
58
65
  findDescriptors,
59
66
  getIdReferenceFor,
60
- getIdReferenceListFor
67
+ getIdReferenceListFor,
68
+ isInvalid,
69
+ isValid,
70
+ validationStates
61
71
  };