@hitachivantara/uikit-react-core 5.58.0 → 5.58.2

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 (136) hide show
  1. package/dist/cjs/Accordion/Accordion.cjs +1 -1
  2. package/dist/cjs/Accordion/Accordion.cjs.map +1 -1
  3. package/dist/cjs/AppSwitcher/Action/Action.cjs +1 -1
  4. package/dist/cjs/AppSwitcher/Action/Action.cjs.map +1 -1
  5. package/dist/cjs/BaseDropdown/BaseDropdown.cjs +1 -1
  6. package/dist/cjs/BaseDropdown/BaseDropdown.cjs.map +1 -1
  7. package/dist/cjs/Button/Button.styles.cjs +22 -6
  8. package/dist/cjs/Button/Button.styles.cjs.map +1 -1
  9. package/dist/cjs/CheckBox/CheckBox.cjs +1 -1
  10. package/dist/cjs/CheckBox/CheckBox.cjs.map +1 -1
  11. package/dist/cjs/CheckBoxGroup/CheckBoxGroup.cjs +1 -1
  12. package/dist/cjs/CheckBoxGroup/CheckBoxGroup.cjs.map +1 -1
  13. package/dist/cjs/ColorPicker/ColorPicker.cjs +1 -1
  14. package/dist/cjs/ColorPicker/ColorPicker.cjs.map +1 -1
  15. package/dist/cjs/DatePicker/DatePicker.cjs +1 -1
  16. package/dist/cjs/DatePicker/DatePicker.cjs.map +1 -1
  17. package/dist/cjs/DropDownMenu/DropDownMenu.cjs +1 -1
  18. package/dist/cjs/DropDownMenu/DropDownMenu.cjs.map +1 -1
  19. package/dist/cjs/Dropdown/Dropdown.cjs +1 -1
  20. package/dist/cjs/Dropdown/Dropdown.cjs.map +1 -1
  21. package/dist/cjs/FileUploader/DropZone/DropZone.cjs +1 -1
  22. package/dist/cjs/FileUploader/DropZone/DropZone.cjs.map +1 -1
  23. package/dist/cjs/FileUploader/FileList/FileList.cjs +1 -1
  24. package/dist/cjs/FileUploader/FileList/FileList.cjs.map +1 -1
  25. package/dist/cjs/FilterGroup/FilterGroup.cjs +1 -1
  26. package/dist/cjs/FilterGroup/FilterGroup.cjs.map +1 -1
  27. package/dist/cjs/Forms/FormElement/FormElement.cjs +1 -1
  28. package/dist/cjs/Forms/FormElement/FormElement.cjs.map +1 -1
  29. package/dist/cjs/Input/Input.cjs +1 -1
  30. package/dist/cjs/Input/Input.cjs.map +1 -1
  31. package/dist/cjs/Radio/Radio.cjs +1 -1
  32. package/dist/cjs/Radio/Radio.cjs.map +1 -1
  33. package/dist/cjs/RadioGroup/RadioGroup.cjs +1 -1
  34. package/dist/cjs/RadioGroup/RadioGroup.cjs.map +1 -1
  35. package/dist/cjs/ScrollTo/Horizontal/ScrollToHorizontal.cjs +1 -1
  36. package/dist/cjs/ScrollTo/Horizontal/ScrollToHorizontal.cjs.map +1 -1
  37. package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs +1 -1
  38. package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -1
  39. package/dist/cjs/Section/Section.cjs +1 -1
  40. package/dist/cjs/Section/Section.cjs.map +1 -1
  41. package/dist/cjs/SelectionList/SelectionList.cjs +1 -1
  42. package/dist/cjs/SelectionList/SelectionList.cjs.map +1 -1
  43. package/dist/cjs/Skeleton/Skeleton.cjs +49 -0
  44. package/dist/cjs/Skeleton/Skeleton.cjs.map +1 -0
  45. package/dist/cjs/Skeleton/Skeleton.styles.cjs +81 -0
  46. package/dist/cjs/Skeleton/Skeleton.styles.cjs.map +1 -0
  47. package/dist/cjs/Slider/Slider.cjs +1 -1
  48. package/dist/cjs/Slider/Slider.cjs.map +1 -1
  49. package/dist/cjs/Switch/Switch.cjs +1 -1
  50. package/dist/cjs/Switch/Switch.cjs.map +1 -1
  51. package/dist/cjs/TableSection/TableSection.cjs +1 -1
  52. package/dist/cjs/TableSection/TableSection.cjs.map +1 -1
  53. package/dist/cjs/TagsInput/TagsInput.cjs +1 -1
  54. package/dist/cjs/TagsInput/TagsInput.cjs.map +1 -1
  55. package/dist/cjs/TextArea/TextArea.cjs +1 -1
  56. package/dist/cjs/TextArea/TextArea.cjs.map +1 -1
  57. package/dist/cjs/TimePicker/TimePicker.cjs +1 -1
  58. package/dist/cjs/TimePicker/TimePicker.cjs.map +1 -1
  59. package/dist/cjs/VerticalNavigation/TreeView/TreeView.cjs +1 -1
  60. package/dist/cjs/VerticalNavigation/TreeView/TreeView.cjs.map +1 -1
  61. package/dist/cjs/VerticalNavigation/VerticalNavigation.cjs.map +1 -1
  62. package/dist/cjs/hooks/useUniqueId.cjs.map +1 -1
  63. package/dist/cjs/index.cjs +4 -0
  64. package/dist/cjs/index.cjs.map +1 -1
  65. package/dist/cjs/providers/Provider.cjs +2 -1
  66. package/dist/cjs/providers/Provider.cjs.map +1 -1
  67. package/dist/cjs/utils/setId.cjs.map +1 -1
  68. package/dist/esm/Accordion/Accordion.js +1 -1
  69. package/dist/esm/Accordion/Accordion.js.map +1 -1
  70. package/dist/esm/AppSwitcher/Action/Action.js +1 -1
  71. package/dist/esm/AppSwitcher/Action/Action.js.map +1 -1
  72. package/dist/esm/BaseDropdown/BaseDropdown.js +1 -1
  73. package/dist/esm/BaseDropdown/BaseDropdown.js.map +1 -1
  74. package/dist/esm/Button/Button.styles.js +22 -6
  75. package/dist/esm/Button/Button.styles.js.map +1 -1
  76. package/dist/esm/CheckBox/CheckBox.js +1 -1
  77. package/dist/esm/CheckBox/CheckBox.js.map +1 -1
  78. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js +1 -1
  79. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
  80. package/dist/esm/ColorPicker/ColorPicker.js +1 -1
  81. package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
  82. package/dist/esm/DatePicker/DatePicker.js +1 -1
  83. package/dist/esm/DatePicker/DatePicker.js.map +1 -1
  84. package/dist/esm/DropDownMenu/DropDownMenu.js +1 -1
  85. package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
  86. package/dist/esm/Dropdown/Dropdown.js +1 -1
  87. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  88. package/dist/esm/FileUploader/DropZone/DropZone.js +1 -1
  89. package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
  90. package/dist/esm/FileUploader/FileList/FileList.js +1 -1
  91. package/dist/esm/FileUploader/FileList/FileList.js.map +1 -1
  92. package/dist/esm/FilterGroup/FilterGroup.js +1 -1
  93. package/dist/esm/FilterGroup/FilterGroup.js.map +1 -1
  94. package/dist/esm/Forms/FormElement/FormElement.js +1 -1
  95. package/dist/esm/Forms/FormElement/FormElement.js.map +1 -1
  96. package/dist/esm/Input/Input.js +1 -1
  97. package/dist/esm/Input/Input.js.map +1 -1
  98. package/dist/esm/Radio/Radio.js +1 -1
  99. package/dist/esm/Radio/Radio.js.map +1 -1
  100. package/dist/esm/RadioGroup/RadioGroup.js +1 -1
  101. package/dist/esm/RadioGroup/RadioGroup.js.map +1 -1
  102. package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js +1 -1
  103. package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
  104. package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js +1 -1
  105. package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
  106. package/dist/esm/Section/Section.js +1 -1
  107. package/dist/esm/Section/Section.js.map +1 -1
  108. package/dist/esm/SelectionList/SelectionList.js +1 -1
  109. package/dist/esm/SelectionList/SelectionList.js.map +1 -1
  110. package/dist/esm/Skeleton/Skeleton.js +50 -0
  111. package/dist/esm/Skeleton/Skeleton.js.map +1 -0
  112. package/dist/esm/Skeleton/Skeleton.styles.js +81 -0
  113. package/dist/esm/Skeleton/Skeleton.styles.js.map +1 -0
  114. package/dist/esm/Slider/Slider.js +1 -1
  115. package/dist/esm/Slider/Slider.js.map +1 -1
  116. package/dist/esm/Switch/Switch.js +1 -1
  117. package/dist/esm/Switch/Switch.js.map +1 -1
  118. package/dist/esm/TableSection/TableSection.js +1 -1
  119. package/dist/esm/TableSection/TableSection.js.map +1 -1
  120. package/dist/esm/TagsInput/TagsInput.js +1 -1
  121. package/dist/esm/TagsInput/TagsInput.js.map +1 -1
  122. package/dist/esm/TextArea/TextArea.js +1 -1
  123. package/dist/esm/TextArea/TextArea.js.map +1 -1
  124. package/dist/esm/TimePicker/TimePicker.js +1 -1
  125. package/dist/esm/TimePicker/TimePicker.js.map +1 -1
  126. package/dist/esm/VerticalNavigation/TreeView/TreeView.js +1 -1
  127. package/dist/esm/VerticalNavigation/TreeView/TreeView.js.map +1 -1
  128. package/dist/esm/VerticalNavigation/VerticalNavigation.js.map +1 -1
  129. package/dist/esm/hooks/useUniqueId.js.map +1 -1
  130. package/dist/esm/index.js +4 -0
  131. package/dist/esm/index.js.map +1 -1
  132. package/dist/esm/providers/Provider.js +2 -1
  133. package/dist/esm/providers/Provider.js.map +1 -1
  134. package/dist/esm/utils/setId.js.map +1 -1
  135. package/dist/types/index.d.ts +54 -14
  136. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"FormElement.cjs","sources":["../../../../src/Forms/FormElement/FormElement.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { findDescriptors } from \"./utils/FormUtils\";\nimport { HvFormElementContextProvider } from \"./context/FormElementContext\";\nimport { HvFormElementValueContextProvider } from \"./context/FormElementValueContext\";\nimport { HvFormElementDescriptorsContextProvider } from \"./context/FormElementDescriptorsContext\";\nimport { staticClasses, useClasses } from \"./FormElement.styles\";\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 HvBaseProps<HTMLDivElement, \"onChange\"> {\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 * 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 /** Whether the form element is disabled. */\n disabled?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: 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\". */\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\nexport const HvFormElement = (props: HvFormElementProps) => {\n const {\n classes: classesProp,\n className,\n children,\n id,\n name,\n value,\n disabled = false,\n required = false,\n readOnly = false,\n status = \"standBy\",\n ...others\n } = useDefaultProps(\"HvFormElement\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvformelement\");\n\n const contextValue = useMemo(\n () => ({\n elementId,\n elementName: name,\n elementStatus: status,\n elementDisabled: disabled,\n elementRequired: required,\n elementReadOnly: readOnly,\n }),\n [disabled, elementId, name, readOnly, required, status]\n );\n\n const descriptors = useMemo(() => findDescriptors(children), [children]);\n\n return (\n <div id={id} className={cx(classes.root, className)} {...others}>\n <HvFormElementContextProvider value={contextValue}>\n <HvFormElementValueContextProvider value={value}>\n <HvFormElementDescriptorsContextProvider value={descriptors}>\n {children}\n </HvFormElementDescriptorsContextProvider>\n </HvFormElementValueContextProvider>\n </HvFormElementContextProvider>\n </div>\n );\n};\n\nHvFormElement.formElementType = \"formelement\";\n"],"names":["useDefaultProps","useClasses","useUniqueId","useMemo","findDescriptors","jsx","HvFormElementContextProvider","HvFormElementValueContextProvider","HvFormElementDescriptorsContextProvider"],"mappings":";;;;;;;;;;;AAiEa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,GAAG,IAAIC,8BAAW,WAAW;AAExC,QAAA,YAAYC,YAAAA,YAAY,IAAI,eAAe;AAEjD,QAAM,eAAeC,MAAA;AAAA,IACnB,OAAO;AAAA,MACL;AAAA,MACA,aAAa;AAAA,MACb,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,CAAC,UAAU,WAAW,MAAM,UAAU,UAAU,MAAM;AAAA,EAAA;AAGlD,QAAA,cAAcA,MAAAA,QAAQ,MAAMC,UAAAA,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAGrE,SAAAC,2BAAAA,IAAC,OAAI,EAAA,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QACvD,UAAAA,2BAAA,IAACC,mDAA6B,OAAO,cACnC,UAACD,2BAAA,IAAAE,wBAAA,mCAAA,EAAkC,OACjC,UAAAF,2BAAAA,IAACG,8BAAAA,yCAAwC,EAAA,OAAO,aAC7C,SAAA,CACH,EACF,CAAA,EAAA,CACF,EACF,CAAA;AAEJ;AAEA,cAAc,kBAAkB;;;"}
1
+ {"version":3,"file":"FormElement.cjs","sources":["../../../../src/Forms/FormElement/FormElement.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { findDescriptors } from \"./utils/FormUtils\";\nimport { HvFormElementContextProvider } from \"./context/FormElementContext\";\nimport { HvFormElementValueContextProvider } from \"./context/FormElementValueContext\";\nimport { HvFormElementDescriptorsContextProvider } from \"./context/FormElementDescriptorsContext\";\nimport { staticClasses, useClasses } from \"./FormElement.styles\";\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 HvBaseProps<HTMLDivElement, \"onChange\"> {\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 * 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 /** Whether the form element is disabled. */\n disabled?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: 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\". */\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\nexport const HvFormElement = (props: HvFormElementProps) => {\n const {\n classes: classesProp,\n className,\n children,\n id,\n name,\n value,\n disabled = false,\n required = false,\n readOnly = false,\n status = \"standBy\",\n ...others\n } = useDefaultProps(\"HvFormElement\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const contextValue = useMemo(\n () => ({\n elementId,\n elementName: name,\n elementStatus: status,\n elementDisabled: disabled,\n elementRequired: required,\n elementReadOnly: readOnly,\n }),\n [disabled, elementId, name, readOnly, required, status]\n );\n\n const descriptors = useMemo(() => findDescriptors(children), [children]);\n\n return (\n <div id={id} className={cx(classes.root, className)} {...others}>\n <HvFormElementContextProvider value={contextValue}>\n <HvFormElementValueContextProvider value={value}>\n <HvFormElementDescriptorsContextProvider value={descriptors}>\n {children}\n </HvFormElementDescriptorsContextProvider>\n </HvFormElementValueContextProvider>\n </HvFormElementContextProvider>\n </div>\n );\n};\n\nHvFormElement.formElementType = \"formelement\";\n"],"names":["useDefaultProps","useClasses","useUniqueId","useMemo","findDescriptors","jsx","HvFormElementContextProvider","HvFormElementValueContextProvider","HvFormElementDescriptorsContextProvider"],"mappings":";;;;;;;;;;;AAiEa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,GAAG,IAAIC,8BAAW,WAAW;AAExC,QAAA,YAAYC,wBAAY,EAAE;AAEhC,QAAM,eAAeC,MAAA;AAAA,IACnB,OAAO;AAAA,MACL;AAAA,MACA,aAAa;AAAA,MACb,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,CAAC,UAAU,WAAW,MAAM,UAAU,UAAU,MAAM;AAAA,EAAA;AAGlD,QAAA,cAAcA,MAAAA,QAAQ,MAAMC,UAAAA,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAGrE,SAAAC,2BAAAA,IAAC,OAAI,EAAA,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QACvD,UAAAA,2BAAA,IAACC,mDAA6B,OAAO,cACnC,UAACD,2BAAA,IAAAE,wBAAA,mCAAA,EAAkC,OACjC,UAAAF,2BAAAA,IAACG,8BAAAA,yCAAwC,EAAA,OAAO,aAC7C,SAAA,CACH,EACF,CAAA,EAAA,CACF,EACF,CAAA;AAEJ;AAEA,cAAc,kBAAkB;;;"}
@@ -94,7 +94,7 @@ const HvInput = React.forwardRef((props, ref) => {
94
94
  } = useDefaultProps.useDefaultProps("HvInput", props);
95
95
  const { classes, cx } = Input_styles.useClasses(classesProp);
96
96
  const labels = useLabels.useLabels(DEFAULT_LABELS, labelsProp);
97
- const elementId = useUniqueId.useUniqueId(id, "hvinput");
97
+ const elementId = useUniqueId.useUniqueId(id);
98
98
  const inputRef = React.useRef(null);
99
99
  const forkedRef = utils.useForkRef(ref, inputRef, inputRefProp);
100
100
  const suggestionsRef = React.useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"Input.cjs","sources":["../../../src/Input/Input.tsx"],"sourcesContent":["import React, {\n FocusEvent,\n HTMLInputTypeAttribute,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { InputBaseComponentProps as MuiInputBaseComponentProps } from \"@mui/material/InputBase\";\nimport { useForkRef } from \"@mui/material/utils\";\n\nimport {\n CloseXS,\n PreviewOff,\n Preview,\n Search,\n Success,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { ExtractNames } from \"../utils/classes\";\nimport { isBrowser } from \"../utils/browser\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { HvInputSuggestion, HvValidationMessages } from \"../types/forms\";\nimport { HvBaseProps } from \"../types/generic\";\nimport {\n HvAdornment,\n HvAdornmentProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestion,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n isValid,\n isInvalid,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { HvBaseInput, HvBaseInputProps } from \"../BaseInput\";\nimport {\n DEFAULT_ERROR_MESSAGES,\n computeValidationType,\n hasBuiltInValidations,\n validateInput,\n computeValidationState,\n computeValidationMessage,\n HvInputValidity,\n} from \"../BaseInput/validations\";\nimport { HvTooltip } from \"../Tooltip\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useLabels } from \"../hooks/useLabels\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./Input.styles\";\n\nexport { staticClasses as inputClasses };\n\nexport type HvInputClasses = ExtractNames<typeof useClasses>;\n\ntype InputElement = HTMLInputElement | HTMLTextAreaElement;\n\nexport interface HvInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string;\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: 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 inputted via inputProps.\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 the form element is not editable. */\n readOnly?: 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 `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /**\n * The function that will be executed onChange, allows modification of the input,\n * it receives the value. If a new value should be presented it must returned it.\n */\n onChange?: HvBaseInputProps[\"onChange\"];\n /**\n * Callback called when the user submits the value by pressing Enter/Return.\n *\n * Also called when the search button is clicked (when type is \"search\").\n */\n onEnter?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the validation state,\n * it receives the value and the validation state.\n */\n onBlur?: (\n event: React.FocusEvent<InputElement>,\n value: string,\n validationState: HvInputValidity\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (event: React.FocusEvent<InputElement>, value: string) => void;\n /**\n * The function that will be executed onKeyDown, allows checking the value state,\n * it receives the event and value.\n */\n onKeyDown?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /** The input type. */\n type?: HTMLInputTypeAttribute;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** Internal labels?. */\n labels?: HvInputLabels & Record<string, any>;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /**\n * Allows passing a ref to the underlying input\n * @deprecated Use `ref` directly instead\n * */\n inputRef?: HvBaseInputProps[\"inputRef\"];\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */\n suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the clear button is disabled. */\n disableClear?: boolean;\n /** If `true` the reveal password button is disabled. Valid only when type is \"password\". */\n disableRevealPassword?: boolean;\n /** If `true` the search button is disabled. Valid only when type is \"search\". */\n disableSearchButton?: boolean;\n /**\n * If `true` the validation icon adornment is visible. Defaults to `false`.\n *\n * Currently, DS specifications define only a positive feedback icon;\n * errors are signaled through the border style and by displaying the error message.\n */\n showValidationIcon?: boolean;\n /** A custom icon to be added into the input. */\n endAdornment?: React.ReactNode;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxCharQuantity?: number;\n /** The minimum allowed length of the characters, if this value is null no check will be perform. */\n minCharQuantity?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInputClasses;\n}\n\nconst DEFAULT_LABELS = {\n /** The label of the clear button. */\n clearButtonLabel: \"Clear the text\",\n /** The label of the reveal password button. */\n revealPasswordButtonLabel: \"Reveal password\",\n /** The tooltip of the reveal password button when the password is hidden. */\n revealPasswordButtonClickToShowTooltip: \"Click to show password.\",\n /** The tooltip of the reveal password button when the password is revealed. */\n revealPasswordButtonClickToHideTooltip: \"Click to hide password.\",\n /** The label of the search button. */\n searchButtonLabel: \"Search\",\n};\n\nexport type HvInputLabels = Partial<typeof DEFAULT_LABELS>;\n\n/**\n * Find the focused element onBlur.\n */\nconst getFocusedElement = (event: FocusEvent) =>\n isBrowser(\"ie\") ? document.activeElement : event.relatedTarget;\n\nfunction eventTargetIsInsideContainer(\n container: HTMLElement | null,\n event: FocusEvent<any>\n) {\n return container != null && container.contains(getFocusedElement(event));\n}\n\n/** Changes a given `input`'s `value`, triggering its `onChange` */\nconst changeInputValue = (input: HTMLInputElement | null, value = \"\") => {\n const event = new Event(\"input\", { bubbles: true });\n\n /** Original `input.value` setter (React overrides it). */\n const setInputValue = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\"\n )?.set;\n\n setInputValue?.call(input, value);\n input?.dispatchEvent(event);\n};\n\n/**\n * A text input box is a graphical control element intended to enable the user to input text information to be used by the software.\n */\nexport const HvInput = forwardRef<InputElement, HvInputProps>((props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = \"\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onEnter,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n type = \"text\",\n placeholder,\n autoFocus = false,\n labels: labelsProp,\n validationMessages,\n disableClear = false,\n disableRevealPassword = false,\n disableSearchButton = false,\n endAdornment,\n maxCharQuantity,\n minCharQuantity,\n validation,\n showValidationIcon = false,\n suggestionListCallback,\n inputRef: inputRefProp,\n onBlur,\n onFocus,\n onKeyDown,\n inputProps = {},\n ...others\n } = useDefaultProps(\"HvInput\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const elementId = useUniqueId(id, \"hvinput\");\n\n const inputRef = useRef<HTMLInputElement>(null);\n const forkedRef = useForkRef(ref, inputRef, inputRefProp);\n const suggestionsRef = useRef<HTMLElement>(null);\n\n const [focused, setFocused] = useState(false);\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n // Value related state\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isEmptyValue = value == null || value === \"\";\n\n // Validation related state\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\"\n );\n\n // validationMessages reference tends to change, as users will not memoize/useState for it;\n // dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n validationMessages?.error,\n validationMessages?.requiredError,\n validationMessages?.minCharError,\n validationMessages?.maxCharError,\n validationMessages?.typeMismatchError,\n ]\n );\n\n const validationType = useMemo(() => computeValidationType(type), [type]);\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationType,\n validation\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages)\n );\n\n return inputValidity;\n }, [\n errorMessages,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n validationType,\n value,\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 any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationType,\n minCharQuantity,\n maxCharQuantity,\n validation,\n inputProps\n )));\n\n const isStateInvalid = isInvalid(validationState);\n\n // Input type related state\n const [revealPassword, setRevealPassword] = useState(false);\n\n const realType = useMemo(() => {\n if (type === \"password\") {\n return revealPassword ? \"text\" : \"password\";\n }\n\n if (type === \"search\") {\n return \"search\";\n }\n\n return \"text\";\n }, [revealPassword, type]);\n\n // Suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvSuggestion[] | null\n >(null);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n // Miscellaneous state\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n inputRef.current?.focus();\n };\n\n const isMounted = useIsMounted();\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = () => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n };\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n };\n\n /**\n * Executes the user callback adds the selection to the state and clears the suggestions.\n */\n const suggestionSelectedHandler: HvSuggestionsProps[\"onSuggestionSelected\"] =\n (event, item) => {\n const newValue = item.value || (item.label as any);\n\n changeInputValue(inputRef.current, newValue);\n\n focusInput();\n suggestionClearHandler();\n\n if (type === \"search\") {\n // trigger the onEnter callback when the user selects an option in a search box\n onEnter?.(event, newValue);\n }\n };\n\n const onChangeHandler: HvBaseInputProps[\"onChange\"] = (event, newValue) => {\n isDirty.current = true;\n\n // set the input value (only when value is uncontrolled)\n setValue(newValue);\n\n onChange?.(event, newValue);\n\n if (canShowSuggestions) {\n // an edge case might be a controlled input whose onChange callback\n // doesn't change the value (or sets another): the suggestionListCallback\n // callback will still receive the original rejected value.\n // a refactor is needed so the suggestionListCallback might be called only\n // when the input is uncontrolled, providing a way to externally control\n // the suggestion values.\n suggestionHandler(newValue);\n }\n };\n\n /**\n * Validates the input updating the state and modifying the info text, also executes\n * the user provided onBlur passing the current validation status and value.\n */\n const onInputBlurHandler: HvBaseInputProps[\"onBlur\"] = (event) => {\n // If the blur is executed when choosing an suggestion it should be ignored.\n if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;\n\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler: HvBaseInputProps[\"onFocus\"] = (event) => {\n setFocused(true);\n\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const getSuggestions = (li: number | null) => {\n // TODO Replace with ref\n const listEl = document.getElementById(\n setId(elementId, \"suggestions-list\") || \"\"\n );\n return li != null ? listEl?.getElementsByTagName(\"li\")?.[li] : listEl;\n };\n\n const onSuggestionKeyDown: HvSuggestionsProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /** Focus the suggestion list when the arrow down is pressed. */\n const onKeyDownHandler: HvBaseInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"ArrowDown\") && hasSuggestions) {\n const li = getSuggestions(0);\n li?.focus();\n } else if (isKey(event, \"Enter\")) {\n onEnter?.(event, value);\n }\n\n onKeyDown?.(event, value);\n };\n\n /** Clears the suggestion list on blur. */\n const onContainerBlurHandler: HvFormElementProps[\"onBlur\"] = (event) => {\n if (event.relatedTarget) {\n setTimeout(() => {\n const list = getSuggestions(null);\n if (!list?.contains(document.activeElement)) suggestionClearHandler();\n }, 10);\n }\n };\n\n const hasOnEnter = onEnter != null;\n\n // show the clear button only if the input is enabled, not read-only, disableClear is false and the input is not empty\n // also, don't show it when the input type is \"search\" and the input is active (standBy)\n const showClear =\n !disabled &&\n !readOnly &&\n !disableClear &&\n !isEmptyValue &&\n (!hasOnEnter ||\n type !== \"search\" ||\n disableSearchButton ||\n validationState !== validationStates.standBy);\n\n const showSearchIcon = type === \"search\" && !disableSearchButton;\n\n const showRevealPasswordButton =\n type === \"password\" && !disableRevealPassword;\n\n /**\n * Clears the input value from the state and refocus the input.\n */\n const handleClear = useCallback(() => {\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n changeInputValue(inputRef.current, \"\");\n\n // we want to focus the input when clicked and not active\n setTimeout(focusInput);\n }, [setValidationState]);\n\n const clearButton = useMemo(() => {\n if (!showClear) {\n return null;\n }\n\n return (\n <HvAdornment\n // Don't control visibility when the search icon is enabled\n className={cx(classes.adornmentButton, {\n [classes.iconClear]: !showSearchIcon,\n })}\n onClick={handleClear}\n aria-label={labels?.clearButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={<CloseXS />}\n />\n );\n }, [\n showClear,\n classes.adornmentButton,\n classes.iconClear,\n showSearchIcon,\n handleClear,\n labels?.clearButtonLabel,\n elementId,\n cx,\n ]);\n\n /**\n * Calls the onEnter callback and refocus the input.\n */\n const handleSearch = useCallback<NonNullable<HvAdornmentProps[\"onClick\"]>>(\n (event) => {\n onEnter?.(event, value);\n },\n [onEnter, value]\n );\n\n const searchButton = useMemo(() => {\n // If the search icon is not actionable, only show it when the input is empty or active\n const reallyShowIt =\n showSearchIcon &&\n (isEmptyValue ||\n (hasOnEnter && validationState === validationStates.standBy));\n\n if (!reallyShowIt) {\n return null;\n }\n\n return (\n <HvAdornment\n className={classes.adornmentButton}\n onClick={hasOnEnter ? handleSearch : undefined}\n aria-label={labels?.searchButtonLabel}\n icon={<Search />}\n />\n );\n }, [\n showSearchIcon,\n isEmptyValue,\n hasOnEnter,\n validationState,\n classes.adornmentButton,\n handleSearch,\n labels?.searchButtonLabel,\n ]);\n\n /**\n * Changes input type and refocus the input.\n */\n const handleRevealPassword = useCallback(() => {\n setRevealPassword(!revealPassword);\n }, [revealPassword]);\n\n const revealPasswordButton = useMemo(() => {\n if (!showRevealPasswordButton) {\n return null;\n }\n\n return (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={\n revealPassword\n ? labels?.revealPasswordButtonClickToHideTooltip\n : labels?.revealPasswordButtonClickToShowTooltip\n }\n >\n <HvAdornment\n className={classes.adornmentButton}\n onClick={handleRevealPassword}\n aria-label={labels?.revealPasswordButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={revealPassword ? <PreviewOff /> : <Preview />}\n />\n </HvTooltip>\n );\n }, [\n showRevealPasswordButton,\n revealPassword,\n labels?.revealPasswordButtonClickToHideTooltip,\n labels?.revealPasswordButtonClickToShowTooltip,\n labels?.revealPasswordButtonLabel,\n classes.adornmentButton,\n handleRevealPassword,\n elementId,\n ]);\n\n const validationIcon = useMemo(() => {\n if (!showValidationIcon) {\n return null;\n }\n\n if (!isValid(validationState)) {\n return null;\n }\n\n return <Success color=\"positive\" className={classes.icon} />;\n }, [showValidationIcon, validationState, classes.icon]);\n\n // useMemo to avoid repetitive cloning of the custom icon\n const customIconEl = useMemo(\n () =>\n isValidElement(endAdornment) &&\n React.cloneElement(endAdornment as React.ReactElement, {\n className: cx(endAdornment.props.className, classes.icon),\n }),\n [classes.icon, endAdornment, cx]\n );\n\n const adornments = useMemo(() => {\n if (\n !clearButton &&\n !revealPasswordButton &&\n !searchButton &&\n !validationIcon &&\n !customIconEl\n )\n return null;\n\n // note: specification implies that the custom icon should be hidden when\n // a validation feedback icon is being shown.\n return (\n <div className={classes.adornmentsBox} aria-hidden=\"true\">\n {clearButton}\n {revealPasswordButton}\n {searchButton}\n {validationIcon || customIconEl}\n </div>\n );\n }, [\n classes.adornmentsBox,\n clearButton,\n customIconEl,\n revealPasswordButton,\n searchButton,\n validationIcon,\n ]);\n\n // run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage\n : undefined;\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(\n classes.root,\n {\n [classes.hasSuggestions]: hasSuggestions,\n },\n className\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={setId(elementId, \"input\")}\n label={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 <HvBaseInput\n id={\n hasLabel || showClear || showRevealPasswordButton\n ? setId(elementId, \"input\")\n : setId(id, \"input\")\n }\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onKeyDown={onKeyDownHandler}\n onBlur={onInputBlurHandler}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n type={realType}\n classes={{\n input: classes.input,\n inputRoot: classes.inputRoot,\n inputRootFocused: classes.inputRootFocused,\n inputRootDisabled: classes.inputRootDisabled,\n inputRootMultiline: classes.inputRootMultiline,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n invalid={isStateInvalid}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : description\n ? setId(elementId, \"description\")\n : undefined,\n \"aria-controls\": canShowSuggestions\n ? setId(elementId, \"suggestions\")\n : undefined,\n\n ref: inputRef,\n\n // prevent browsers auto-fill/suggestions when we have our own\n autoComplete: canShowSuggestions ? \"off\" : undefined,\n\n ...inputProps,\n }}\n inputRef={forkedRef}\n endAdornment={adornments}\n {...others}\n />\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n ref={suggestionsRef}\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={inputRef.current?.parentElement}\n onClose={suggestionClearHandler}\n onKeyDown={onSuggestionKeyDown}\n onSuggestionSelected={suggestionSelectedHandler}\n suggestionValues={suggestionValues}\n />\n </>\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"],"names":["isBrowser","forwardRef","useDefaultProps","useClasses","useLabels","useUniqueId","useRef","useForkRef","useState","useControlled","validationStates","useMemo","DEFAULT_ERROR_MESSAGES","computeValidationType","useCallback","validateInput","computeValidationState","computeValidationMessage","hasBuiltInValidations","isInvalid","useIsMounted","setId","isKey","jsx","HvAdornment","CloseXS","Search","HvTooltip","PreviewOff","Preview","isValid","Success","isValidElement","React","useEffect","jsxs","HvFormElement","HvLabel","HvInfoMessage","HvBaseInput","Fragment","HvSuggestions","HvWarningText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgMA,MAAM,iBAAiB;AAAA;AAAA,EAErB,kBAAkB;AAAA;AAAA,EAElB,2BAA2B;AAAA;AAAA,EAE3B,wCAAwC;AAAA;AAAA,EAExC,wCAAwC;AAAA;AAAA,EAExC,mBAAmB;AACrB;AAOA,MAAM,oBAAoB,CAAC,UACzBA,kBAAU,IAAI,IAAI,SAAS,gBAAgB,MAAM;AAEnD,SAAS,6BACP,WACA,OACA;AACA,SAAO,aAAa,QAAQ,UAAU,SAAS,kBAAkB,KAAK,CAAC;AACzE;AAGA,MAAM,mBAAmB,CAAC,OAAgC,QAAQ,OAAO;AACvE,QAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;AAGlD,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,iBAAiB;AAAA,IACxB;AAAA,EACC,GAAA;AAEY,iBAAA,KAAK,OAAO,KAAK;AAChC,SAAO,cAAc,KAAK;AAC5B;AAKO,MAAM,UAAUC,MAAA,WAAuC,CAAC,OAAO,QAAQ;AACtE,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP;AAAA,IACA,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR;AAAA,IACA,eAAe;AAAA,IACf,wBAAwB;AAAA,IACxB,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YACA,SAAS;AAAA,YACT,YAAY;AAAA,cACV,cAAc;AAAA,cACd,mBAAmB;AAAA,cACnB,gBAAgB,iBAAiB,OAAO;AAAA,cACxC,qBAAqB;AAAA,cACrB,oBACE,mBAAmB,OACf,kBACA,cACAA,MAAAA,MAAM,WAAW,aAAa,IAC9B;AAAA,cACN,iBAAiB,qBACbA,MAAM,MAAA,WAAW,aAAa,IAC9B;AAAA,cAEJ,KAAK;AAAA;AAAA,cAGL,cAAc,qBAAqB,QAAQ;AAAA,cAE3C,GAAG;AAAA,YACL;AAAA,YACA,UAAU;AAAA,YACV,cAAc;AAAA,YACb,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,sBAEIc,2BAAA,KAAAK,qBAAA,EAAA,UAAA;AAAA,UAAA,iDACE,OAAI,EAAA,MAAK,gBAAe,WAAW,QAAQ,gBAAgB;AAAA,UAE9DjB,2BAAA;AAAA,YAACkB,YAAA;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,IAAIpB,MAAAA,MAAM,WAAW,aAAa;AAAA,cAClC,SAAS;AAAA,gBACP,MAAM,QAAQ;AAAA,gBACd,MAAM,QAAQ;AAAA,cAChB;AAAA,cACA,UAAU;AAAA,cACV,UAAU,SAAS,SAAS;AAAA,cAC5B,SAAS;AAAA,cACT,WAAW;AAAA,cACX,sBAAsB;AAAA,cACtB;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GACF;AAAA,QAED,gBACCE,2BAAA;AAAA,UAACmB,YAAA;AAAA,UAAA;AAAA,YACC,IAAIrB,MAAAA,MAAM,WAAW,OAAO;AAAA,YAC5B,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;;;"}
1
+ {"version":3,"file":"Input.cjs","sources":["../../../src/Input/Input.tsx"],"sourcesContent":["import React, {\n FocusEvent,\n HTMLInputTypeAttribute,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { InputBaseComponentProps as MuiInputBaseComponentProps } from \"@mui/material/InputBase\";\nimport { useForkRef } from \"@mui/material/utils\";\n\nimport {\n CloseXS,\n PreviewOff,\n Preview,\n Search,\n Success,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { ExtractNames } from \"../utils/classes\";\nimport { isBrowser } from \"../utils/browser\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { HvInputSuggestion, HvValidationMessages } from \"../types/forms\";\nimport { HvBaseProps } from \"../types/generic\";\nimport {\n HvAdornment,\n HvAdornmentProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestion,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n isValid,\n isInvalid,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { HvBaseInput, HvBaseInputProps } from \"../BaseInput\";\nimport {\n DEFAULT_ERROR_MESSAGES,\n computeValidationType,\n hasBuiltInValidations,\n validateInput,\n computeValidationState,\n computeValidationMessage,\n HvInputValidity,\n} from \"../BaseInput/validations\";\nimport { HvTooltip } from \"../Tooltip\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useLabels } from \"../hooks/useLabels\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./Input.styles\";\n\nexport { staticClasses as inputClasses };\n\nexport type HvInputClasses = ExtractNames<typeof useClasses>;\n\ntype InputElement = HTMLInputElement | HTMLTextAreaElement;\n\nexport interface HvInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string;\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: 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 inputted via inputProps.\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 the form element is not editable. */\n readOnly?: 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 `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /**\n * The function that will be executed onChange, allows modification of the input,\n * it receives the value. If a new value should be presented it must returned it.\n */\n onChange?: HvBaseInputProps[\"onChange\"];\n /**\n * Callback called when the user submits the value by pressing Enter/Return.\n *\n * Also called when the search button is clicked (when type is \"search\").\n */\n onEnter?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the validation state,\n * it receives the value and the validation state.\n */\n onBlur?: (\n event: React.FocusEvent<InputElement>,\n value: string,\n validationState: HvInputValidity\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (event: React.FocusEvent<InputElement>, value: string) => void;\n /**\n * The function that will be executed onKeyDown, allows checking the value state,\n * it receives the event and value.\n */\n onKeyDown?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /** The input type. */\n type?: HTMLInputTypeAttribute;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** Internal labels?. */\n labels?: HvInputLabels & Record<string, any>;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /**\n * Allows passing a ref to the underlying input\n * @deprecated Use `ref` directly instead\n * */\n inputRef?: HvBaseInputProps[\"inputRef\"];\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */\n suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the clear button is disabled. */\n disableClear?: boolean;\n /** If `true` the reveal password button is disabled. Valid only when type is \"password\". */\n disableRevealPassword?: boolean;\n /** If `true` the search button is disabled. Valid only when type is \"search\". */\n disableSearchButton?: boolean;\n /**\n * If `true` the validation icon adornment is visible. Defaults to `false`.\n *\n * Currently, DS specifications define only a positive feedback icon;\n * errors are signaled through the border style and by displaying the error message.\n */\n showValidationIcon?: boolean;\n /** A custom icon to be added into the input. */\n endAdornment?: React.ReactNode;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxCharQuantity?: number;\n /** The minimum allowed length of the characters, if this value is null no check will be perform. */\n minCharQuantity?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInputClasses;\n}\n\nconst DEFAULT_LABELS = {\n /** The label of the clear button. */\n clearButtonLabel: \"Clear the text\",\n /** The label of the reveal password button. */\n revealPasswordButtonLabel: \"Reveal password\",\n /** The tooltip of the reveal password button when the password is hidden. */\n revealPasswordButtonClickToShowTooltip: \"Click to show password.\",\n /** The tooltip of the reveal password button when the password is revealed. */\n revealPasswordButtonClickToHideTooltip: \"Click to hide password.\",\n /** The label of the search button. */\n searchButtonLabel: \"Search\",\n};\n\nexport type HvInputLabels = Partial<typeof DEFAULT_LABELS>;\n\n/**\n * Find the focused element onBlur.\n */\nconst getFocusedElement = (event: FocusEvent) =>\n isBrowser(\"ie\") ? document.activeElement : event.relatedTarget;\n\nfunction eventTargetIsInsideContainer(\n container: HTMLElement | null,\n event: FocusEvent<any>\n) {\n return container != null && container.contains(getFocusedElement(event));\n}\n\n/** Changes a given `input`'s `value`, triggering its `onChange` */\nconst changeInputValue = (input: HTMLInputElement | null, value = \"\") => {\n const event = new Event(\"input\", { bubbles: true });\n\n /** Original `input.value` setter (React overrides it). */\n const setInputValue = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\"\n )?.set;\n\n setInputValue?.call(input, value);\n input?.dispatchEvent(event);\n};\n\n/**\n * A text input box is a graphical control element intended to enable the user to input text information to be used by the software.\n */\nexport const HvInput = forwardRef<InputElement, HvInputProps>((props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = \"\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onEnter,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n type = \"text\",\n placeholder,\n autoFocus = false,\n labels: labelsProp,\n validationMessages,\n disableClear = false,\n disableRevealPassword = false,\n disableSearchButton = false,\n endAdornment,\n maxCharQuantity,\n minCharQuantity,\n validation,\n showValidationIcon = false,\n suggestionListCallback,\n inputRef: inputRefProp,\n onBlur,\n onFocus,\n onKeyDown,\n inputProps = {},\n ...others\n } = useDefaultProps(\"HvInput\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const elementId = useUniqueId(id);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const forkedRef = useForkRef(ref, inputRef, inputRefProp);\n const suggestionsRef = useRef<HTMLElement>(null);\n\n const [focused, setFocused] = useState(false);\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n // Value related state\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isEmptyValue = value == null || value === \"\";\n\n // Validation related state\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\"\n );\n\n // validationMessages reference tends to change, as users will not memoize/useState for it;\n // dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n validationMessages?.error,\n validationMessages?.requiredError,\n validationMessages?.minCharError,\n validationMessages?.maxCharError,\n validationMessages?.typeMismatchError,\n ]\n );\n\n const validationType = useMemo(() => computeValidationType(type), [type]);\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationType,\n validation\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages)\n );\n\n return inputValidity;\n }, [\n errorMessages,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n validationType,\n value,\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 any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationType,\n minCharQuantity,\n maxCharQuantity,\n validation,\n inputProps\n )));\n\n const isStateInvalid = isInvalid(validationState);\n\n // Input type related state\n const [revealPassword, setRevealPassword] = useState(false);\n\n const realType = useMemo(() => {\n if (type === \"password\") {\n return revealPassword ? \"text\" : \"password\";\n }\n\n if (type === \"search\") {\n return \"search\";\n }\n\n return \"text\";\n }, [revealPassword, type]);\n\n // Suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvSuggestion[] | null\n >(null);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n // Miscellaneous state\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n inputRef.current?.focus();\n };\n\n const isMounted = useIsMounted();\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = () => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n };\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n };\n\n /**\n * Executes the user callback adds the selection to the state and clears the suggestions.\n */\n const suggestionSelectedHandler: HvSuggestionsProps[\"onSuggestionSelected\"] =\n (event, item) => {\n const newValue = item.value || (item.label as any);\n\n changeInputValue(inputRef.current, newValue);\n\n focusInput();\n suggestionClearHandler();\n\n if (type === \"search\") {\n // trigger the onEnter callback when the user selects an option in a search box\n onEnter?.(event, newValue);\n }\n };\n\n const onChangeHandler: HvBaseInputProps[\"onChange\"] = (event, newValue) => {\n isDirty.current = true;\n\n // set the input value (only when value is uncontrolled)\n setValue(newValue);\n\n onChange?.(event, newValue);\n\n if (canShowSuggestions) {\n // an edge case might be a controlled input whose onChange callback\n // doesn't change the value (or sets another): the suggestionListCallback\n // callback will still receive the original rejected value.\n // a refactor is needed so the suggestionListCallback might be called only\n // when the input is uncontrolled, providing a way to externally control\n // the suggestion values.\n suggestionHandler(newValue);\n }\n };\n\n /**\n * Validates the input updating the state and modifying the info text, also executes\n * the user provided onBlur passing the current validation status and value.\n */\n const onInputBlurHandler: HvBaseInputProps[\"onBlur\"] = (event) => {\n // If the blur is executed when choosing an suggestion it should be ignored.\n if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;\n\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler: HvBaseInputProps[\"onFocus\"] = (event) => {\n setFocused(true);\n\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const getSuggestions = (li: number | null) => {\n // TODO Replace with ref\n const listEl = document.getElementById(\n setId(elementId, \"suggestions-list\") || \"\"\n );\n return li != null ? listEl?.getElementsByTagName(\"li\")?.[li] : listEl;\n };\n\n const onSuggestionKeyDown: HvSuggestionsProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /** Focus the suggestion list when the arrow down is pressed. */\n const onKeyDownHandler: HvBaseInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"ArrowDown\") && hasSuggestions) {\n const li = getSuggestions(0);\n li?.focus();\n } else if (isKey(event, \"Enter\")) {\n onEnter?.(event, value);\n }\n\n onKeyDown?.(event, value);\n };\n\n /** Clears the suggestion list on blur. */\n const onContainerBlurHandler: HvFormElementProps[\"onBlur\"] = (event) => {\n if (event.relatedTarget) {\n setTimeout(() => {\n const list = getSuggestions(null);\n if (!list?.contains(document.activeElement)) suggestionClearHandler();\n }, 10);\n }\n };\n\n const hasOnEnter = onEnter != null;\n\n // show the clear button only if the input is enabled, not read-only, disableClear is false and the input is not empty\n // also, don't show it when the input type is \"search\" and the input is active (standBy)\n const showClear =\n !disabled &&\n !readOnly &&\n !disableClear &&\n !isEmptyValue &&\n (!hasOnEnter ||\n type !== \"search\" ||\n disableSearchButton ||\n validationState !== validationStates.standBy);\n\n const showSearchIcon = type === \"search\" && !disableSearchButton;\n\n const showRevealPasswordButton =\n type === \"password\" && !disableRevealPassword;\n\n /**\n * Clears the input value from the state and refocus the input.\n */\n const handleClear = useCallback(() => {\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n changeInputValue(inputRef.current, \"\");\n\n // we want to focus the input when clicked and not active\n setTimeout(focusInput);\n }, [setValidationState]);\n\n const clearButton = useMemo(() => {\n if (!showClear) {\n return null;\n }\n\n return (\n <HvAdornment\n // Don't control visibility when the search icon is enabled\n className={cx(classes.adornmentButton, {\n [classes.iconClear]: !showSearchIcon,\n })}\n onClick={handleClear}\n aria-label={labels?.clearButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={<CloseXS />}\n />\n );\n }, [\n showClear,\n classes.adornmentButton,\n classes.iconClear,\n showSearchIcon,\n handleClear,\n labels?.clearButtonLabel,\n elementId,\n cx,\n ]);\n\n /**\n * Calls the onEnter callback and refocus the input.\n */\n const handleSearch = useCallback<NonNullable<HvAdornmentProps[\"onClick\"]>>(\n (event) => {\n onEnter?.(event, value);\n },\n [onEnter, value]\n );\n\n const searchButton = useMemo(() => {\n // If the search icon is not actionable, only show it when the input is empty or active\n const reallyShowIt =\n showSearchIcon &&\n (isEmptyValue ||\n (hasOnEnter && validationState === validationStates.standBy));\n\n if (!reallyShowIt) {\n return null;\n }\n\n return (\n <HvAdornment\n className={classes.adornmentButton}\n onClick={hasOnEnter ? handleSearch : undefined}\n aria-label={labels?.searchButtonLabel}\n icon={<Search />}\n />\n );\n }, [\n showSearchIcon,\n isEmptyValue,\n hasOnEnter,\n validationState,\n classes.adornmentButton,\n handleSearch,\n labels?.searchButtonLabel,\n ]);\n\n /**\n * Changes input type and refocus the input.\n */\n const handleRevealPassword = useCallback(() => {\n setRevealPassword(!revealPassword);\n }, [revealPassword]);\n\n const revealPasswordButton = useMemo(() => {\n if (!showRevealPasswordButton) {\n return null;\n }\n\n return (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={\n revealPassword\n ? labels?.revealPasswordButtonClickToHideTooltip\n : labels?.revealPasswordButtonClickToShowTooltip\n }\n >\n <HvAdornment\n className={classes.adornmentButton}\n onClick={handleRevealPassword}\n aria-label={labels?.revealPasswordButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={revealPassword ? <PreviewOff /> : <Preview />}\n />\n </HvTooltip>\n );\n }, [\n showRevealPasswordButton,\n revealPassword,\n labels?.revealPasswordButtonClickToHideTooltip,\n labels?.revealPasswordButtonClickToShowTooltip,\n labels?.revealPasswordButtonLabel,\n classes.adornmentButton,\n handleRevealPassword,\n elementId,\n ]);\n\n const validationIcon = useMemo(() => {\n if (!showValidationIcon) {\n return null;\n }\n\n if (!isValid(validationState)) {\n return null;\n }\n\n return <Success color=\"positive\" className={classes.icon} />;\n }, [showValidationIcon, validationState, classes.icon]);\n\n // useMemo to avoid repetitive cloning of the custom icon\n const customIconEl = useMemo(\n () =>\n isValidElement(endAdornment) &&\n React.cloneElement(endAdornment as React.ReactElement, {\n className: cx(endAdornment.props.className, classes.icon),\n }),\n [classes.icon, endAdornment, cx]\n );\n\n const adornments = useMemo(() => {\n if (\n !clearButton &&\n !revealPasswordButton &&\n !searchButton &&\n !validationIcon &&\n !customIconEl\n )\n return null;\n\n // note: specification implies that the custom icon should be hidden when\n // a validation feedback icon is being shown.\n return (\n <div className={classes.adornmentsBox} aria-hidden=\"true\">\n {clearButton}\n {revealPasswordButton}\n {searchButton}\n {validationIcon || customIconEl}\n </div>\n );\n }, [\n classes.adornmentsBox,\n clearButton,\n customIconEl,\n revealPasswordButton,\n searchButton,\n validationIcon,\n ]);\n\n // run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage\n : undefined;\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(\n classes.root,\n {\n [classes.hasSuggestions]: hasSuggestions,\n },\n className\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={setId(elementId, \"input\")}\n label={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 <HvBaseInput\n id={\n hasLabel || showClear || showRevealPasswordButton\n ? setId(elementId, \"input\")\n : setId(id, \"input\")\n }\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onKeyDown={onKeyDownHandler}\n onBlur={onInputBlurHandler}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n type={realType}\n classes={{\n input: classes.input,\n inputRoot: classes.inputRoot,\n inputRootFocused: classes.inputRootFocused,\n inputRootDisabled: classes.inputRootDisabled,\n inputRootMultiline: classes.inputRootMultiline,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n invalid={isStateInvalid}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : description\n ? setId(elementId, \"description\")\n : undefined,\n \"aria-controls\": canShowSuggestions\n ? setId(elementId, \"suggestions\")\n : undefined,\n\n ref: inputRef,\n\n // prevent browsers auto-fill/suggestions when we have our own\n autoComplete: canShowSuggestions ? \"off\" : undefined,\n\n ...inputProps,\n }}\n inputRef={forkedRef}\n endAdornment={adornments}\n {...others}\n />\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n ref={suggestionsRef}\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={inputRef.current?.parentElement}\n onClose={suggestionClearHandler}\n onKeyDown={onSuggestionKeyDown}\n onSuggestionSelected={suggestionSelectedHandler}\n suggestionValues={suggestionValues}\n />\n </>\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"],"names":["isBrowser","forwardRef","useDefaultProps","useClasses","useLabels","useUniqueId","useRef","useForkRef","useState","useControlled","validationStates","useMemo","DEFAULT_ERROR_MESSAGES","computeValidationType","useCallback","validateInput","computeValidationState","computeValidationMessage","hasBuiltInValidations","isInvalid","useIsMounted","setId","isKey","jsx","HvAdornment","CloseXS","Search","HvTooltip","PreviewOff","Preview","isValid","Success","isValidElement","React","useEffect","jsxs","HvFormElement","HvLabel","HvInfoMessage","HvBaseInput","Fragment","HvSuggestions","HvWarningText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgMA,MAAM,iBAAiB;AAAA;AAAA,EAErB,kBAAkB;AAAA;AAAA,EAElB,2BAA2B;AAAA;AAAA,EAE3B,wCAAwC;AAAA;AAAA,EAExC,wCAAwC;AAAA;AAAA,EAExC,mBAAmB;AACrB;AAOA,MAAM,oBAAoB,CAAC,UACzBA,kBAAU,IAAI,IAAI,SAAS,gBAAgB,MAAM;AAEnD,SAAS,6BACP,WACA,OACA;AACA,SAAO,aAAa,QAAQ,UAAU,SAAS,kBAAkB,KAAK,CAAC;AACzE;AAGA,MAAM,mBAAmB,CAAC,OAAgC,QAAQ,OAAO;AACvE,QAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;AAGlD,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,iBAAiB;AAAA,IACxB;AAAA,EACC,GAAA;AAEY,iBAAA,KAAK,OAAO,KAAK;AAChC,SAAO,cAAc,KAAK;AAC5B;AAKO,MAAM,UAAUC,MAAA,WAAuC,CAAC,OAAO,QAAQ;AACtE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,cACtB;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GACF;AAAA,QAED,gBACCE,2BAAA;AAAA,UAACmB,YAAA;AAAA,UAAA;AAAA,YACC,IAAIrB,MAAAA,MAAM,WAAW,OAAO;AAAA,YAC5B,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;;;"}
@@ -41,7 +41,7 @@ const HvRadio = React.forwardRef(
41
41
  ...others
42
42
  } = useDefaultProps.useDefaultProps("HvRadio", props);
43
43
  const { classes, cx } = Radio_styles.useClasses(classesProp);
44
- const elementId = useUniqueId.useUniqueId(id, "hvradio");
44
+ const elementId = useUniqueId.useUniqueId(id);
45
45
  const [focusVisible, setFocusVisible] = React.useState(false);
46
46
  const onFocusVisibleCallback = React.useCallback(
47
47
  (evt) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.cjs","sources":["../../../src/Radio/Radio.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useState } from \"react\";\n\nimport { RadioProps as MuiRadioProps } from \"@mui/material/Radio\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseRadio } from \"../BaseRadio\";\nimport {\n HvWarningText,\n HvLabelProps,\n isInvalid,\n HvFormElement,\n HvLabel,\n} from \"../Forms\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { setId } from \"../utils/setId\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Radio.styles\";\n\nexport { staticClasses as radioClasses };\n\nexport type HvRadioClasses = ExtractNames<typeof useClasses>;\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\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.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: 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 status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /** @ignore */\n ref?: MuiRadioProps[\"ref\"];\n /** @ignore */\n component?: MuiRadioProps[\"component\"];\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user <b>may select just one option</b> to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = forwardRef<HTMLButtonElement, HvRadioProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic = false,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvradio\");\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value]\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\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <HvBaseRadio\n ref={ref}\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={cx(classes.radio, {\n [classes.invalidRadio]: isStateInvalid,\n })}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {hasLabel ? (\n <div\n className={cx(classes.container, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: !!(focusVisible && label),\n [classes.invalidContainer]: isStateInvalid,\n })}\n >\n {radio}\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n </div>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["forwardRef","useDefaultProps","useClasses","useUniqueId","useState","useCallback","useControlled","isInvalid","setId","jsx","HvBaseRadio","jsxs","HvFormElement","HvLabel","HvWarningText"],"mappings":";;;;;;;;;;;;;;AAqIO,MAAM,UAAUA,MAAA;AAAA,EACrB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB;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AAIN,MAAAA,MAAM,WAAW,OAAO,GAAG,eAAa,MACxD,UACH,cAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;;;"}
1
+ {"version":3,"file":"Radio.cjs","sources":["../../../src/Radio/Radio.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useState } from \"react\";\n\nimport { RadioProps as MuiRadioProps } from \"@mui/material/Radio\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseRadio } from \"../BaseRadio\";\nimport {\n HvWarningText,\n HvLabelProps,\n isInvalid,\n HvFormElement,\n HvLabel,\n} from \"../Forms\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { setId } from \"../utils/setId\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Radio.styles\";\n\nexport { staticClasses as radioClasses };\n\nexport type HvRadioClasses = ExtractNames<typeof useClasses>;\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\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.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: 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 status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /** @ignore */\n ref?: MuiRadioProps[\"ref\"];\n /** @ignore */\n component?: MuiRadioProps[\"component\"];\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user <b>may select just one option</b> to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = forwardRef<HTMLButtonElement, HvRadioProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic = false,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value]\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\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <HvBaseRadio\n ref={ref}\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={cx(classes.radio, {\n [classes.invalidRadio]: isStateInvalid,\n })}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {hasLabel ? (\n <div\n className={cx(classes.container, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: !!(focusVisible && label),\n [classes.invalidContainer]: isStateInvalid,\n })}\n >\n {radio}\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n </div>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["forwardRef","useDefaultProps","useClasses","useUniqueId","useState","useCallback","useControlled","isInvalid","setId","jsx","HvBaseRadio","jsxs","HvFormElement","HvLabel","HvWarningText"],"mappings":";;;;;;;;;;;;;;AAqIO,MAAM,UAAUA,MAAA;AAAA,EACrB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA,qBAAqB;AAAA,MACrB,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACDC,gBAAgB,gBAAA,WAAW,KAAK;AAEpC,UAAM,EAAE,SAAS,GAAG,IAAIC,wBAAW,WAAW;AAExC,UAAA,YAAYC,wBAAY,EAAE;AAEhC,UAAM,CAAC,cAAc,eAAe,IAAIC,eAAS,KAAK;AAEtD,UAAM,yBAAyBC,MAAA;AAAA,MAC7B,CAAC,QAA+B;AAC9B,wBAAgB,IAAI;AACpB,yBAAiB,GAAG;AAAA,MACtB;AAAA,MACA,CAA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YAAA;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,QAAQ,UAAU;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QAEpC,UAAA;AAAA,UACC,WAAAD,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,QAAQ,WAAW;AAAA,gBAC/B,CAAC,QAAQ,QAAQ,GAAG;AAAA,gBACpB,CAAC,QAAQ,YAAY,GAAG,CAAC,EAAE,gBAAgB;AAAA,gBAC3C,CAAC,QAAQ,gBAAgB,GAAG;AAAA,cAAA,CAC7B;AAAA,cAEA,UAAA;AAAA,gBAAA;AAAA,gBACDF,2BAAA;AAAA,kBAACI,MAAA;AAAA,kBAAA;AAAA,oBACC,IAAIL,MAAAA,MAAM,WAAW,OAAO;AAAA,oBAC5B,SAASA,MAAAA,MAAM,WAAW,OAAO;AAAA,oBACjC;AAAA,oBACA,WAAW,QAAQ;AAAA,oBAClB,GAAG;AAAA,kBAAA;AAAA,gBACN;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA,IAGF;AAAA,UAED,gBACEC,2BAAAA,IAAAK,YAAAA,eAAA,EAAc,IAAIN,MAAAA,MAAM,WAAW,OAAO,GAAG,eAAa,MACxD,UACH,cAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;;;"}
@@ -50,7 +50,7 @@ const HvRadioGroup = React.forwardRef(
50
50
  ...others
51
51
  } = useDefaultProps.useDefaultProps("HvRadioGroup", props);
52
52
  const { classes, cx } = RadioGroup_styles.useClasses(classesProp);
53
- const elementId = useUniqueId.useUniqueId(id, "hvradiogroup");
53
+ const elementId = useUniqueId.useUniqueId(id);
54
54
  const [value, setValue] = useControlled.useControlled(
55
55
  valueProp,
56
56
  defaultValue !== void 0 ? defaultValue : (
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.cjs","sources":["../../../src/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import {\n Children,\n useMemo,\n useCallback,\n cloneElement,\n forwardRef,\n} from \"react\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { setId } from \"../utils/setId\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { staticClasses, useClasses } from \"./RadioGroup.styles\";\n\nexport { staticClasses as radioGroupClasses };\n\nexport type HvRadioGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvRadioGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children radio buttons, unless they already have one (which they shouldn't).\n */\n name?: string;\n /**\n * The value of the form element, represented in one of the child radio buttons values.\n *\n * When defined the radio button 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 radio buttons.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children radio buttons.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n * If `true` the state is propagated to the children radio buttons' input 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 `status` is \"invalid\".\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 radio buttons group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvRadioGroupClasses;\n}\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const childrenArray = Children.toArray(children);\n const childrenCount = childrenArray.length;\n for (let i = 0; i !== childrenCount; i += 1) {\n const child: any = childrenArray[i];\n\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n if (childIsSelected) {\n return child?.props?.value;\n }\n }\n\n return null;\n};\n\n/**\n * A group of radio buttons.\n *\n * A radio group is a type of selection list that can only have a single entry checked at any one time.\n */\nexport const HvRadioGroup = forwardRef<HTMLDivElement, HvRadioGroupProps>(\n (props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n value: valueProp,\n defaultValue,\n label,\n description,\n status,\n statusMessage,\n required = false,\n readOnly = false,\n disabled = false,\n orientation = \"vertical\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvRadioGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvradiogroup\");\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 onChildChangeInterceptor = useCallback(\n (\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) => {\n childOnChange?.(event, isChecked, newValue);\n\n onChange?.(event, newValue);\n\n setValue(newValue);\n },\n [onChange, setValue]\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any) => {\n const childValue = child?.props?.value ?? \"on\";\n\n const childIsSelected = childValue === value;\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name || elementId,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) =>\n onChildChangeInterceptor(\n child?.props?.onChange,\n event,\n isChecked,\n newValue\n ),\n inputProps: {\n ...child?.props?.inputProps,\n // Set the required attribute directly in the input\n // the radio form element context shouldn't be aware so the\n // label doesn't show redundant asterisk\n required,\n },\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n elementId,\n name,\n onChildChangeInterceptor,\n readOnly,\n required,\n value,\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={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\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=\"radiogroup\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={status === \"invalid\" ? errorMessageId : undefined}\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]: status === \"invalid\",\n })}\n {...others}\n >\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["Children","forwardRef","useDefaultProps","useClasses","useUniqueId","useControlled","useCallback","useMemo","cloneElement","setId","jsxs","HvFormElement","jsx","HvLabel","HvInfoMessage","HvWarningText"],"mappings":";;;;;;;;;;;;;AAqGA,MAAM,+BAA+B,CAAC,aAA8B;AAC5D,QAAA,gBAAgBA,MAAAA,SAAS,QAAQ,QAAQ;AAC/C,QAAM,gBAAgB,cAAc;AACpC,WAAS,IAAI,GAAG,MAAM,eAAe,KAAK,GAAG;AACrC,UAAA,QAAa,cAAc,CAAC;AAE5B,UAAA,oBAAoB,OAAO,OAAO,YAAY;AACpD,UAAM,kBAAkB,oBACpB,OAAO,OAAO,UACd,OAAO,OAAO;AAElB,QAAI,iBAAiB;AACnB,aAAO,OAAO,OAAO;AAAA,IACvB;AAAA,EACF;AAEO,SAAA;AACT;AAOO,MAAM,eAAeC,MAAA;AAAA,EAC1B,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,qBAAqB;AAAA,MACrB;AAAA,MACA,GAAG;AAAA,IAAA,IACDC,gBAAgB,gBAAA,gBAAgB,KAAK;AAEzC,UAAM,EAAE,SAA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;AACF;;;"}
1
+ {"version":3,"file":"RadioGroup.cjs","sources":["../../../src/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import {\n Children,\n useMemo,\n useCallback,\n cloneElement,\n forwardRef,\n} from \"react\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { setId } from \"../utils/setId\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../Forms\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { staticClasses, useClasses } from \"./RadioGroup.styles\";\n\nexport { staticClasses as radioGroupClasses };\n\nexport type HvRadioGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvRadioGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children radio buttons, unless they already have one (which they shouldn't).\n */\n name?: string;\n /**\n * The value of the form element, represented in one of the child radio buttons values.\n *\n * When defined the radio button 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 radio buttons.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children radio buttons.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n * If `true` the state is propagated to the children radio buttons' input 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 `status` is \"invalid\".\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 radio buttons group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvRadioGroupClasses;\n}\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const childrenArray = Children.toArray(children);\n const childrenCount = childrenArray.length;\n for (let i = 0; i !== childrenCount; i += 1) {\n const child: any = childrenArray[i];\n\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n if (childIsSelected) {\n return child?.props?.value;\n }\n }\n\n return null;\n};\n\n/**\n * A group of radio buttons.\n *\n * A radio group is a type of selection list that can only have a single entry checked at any one time.\n */\nexport const HvRadioGroup = forwardRef<HTMLDivElement, HvRadioGroupProps>(\n (props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n value: valueProp,\n defaultValue,\n label,\n description,\n status,\n statusMessage,\n required = false,\n readOnly = false,\n disabled = false,\n orientation = \"vertical\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvRadioGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\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 onChildChangeInterceptor = useCallback(\n (\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) => {\n childOnChange?.(event, isChecked, newValue);\n\n onChange?.(event, newValue);\n\n setValue(newValue);\n },\n [onChange, setValue]\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any) => {\n const childValue = child?.props?.value ?? \"on\";\n\n const childIsSelected = childValue === value;\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name || elementId,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) =>\n onChildChangeInterceptor(\n child?.props?.onChange,\n event,\n isChecked,\n newValue\n ),\n inputProps: {\n ...child?.props?.inputProps,\n // Set the required attribute directly in the input\n // the radio form element context shouldn't be aware so the\n // label doesn't show redundant asterisk\n required,\n },\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n elementId,\n name,\n onChildChangeInterceptor,\n readOnly,\n required,\n value,\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={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\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=\"radiogroup\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={status === \"invalid\" ? errorMessageId : undefined}\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]: status === \"invalid\",\n })}\n {...others}\n >\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["Children","forwardRef","useDefaultProps","useClasses","useUniqueId","useControlled","useCallback","useMemo","cloneElement","setId","jsxs","HvFormElement","jsx","HvLabel","HvInfoMessage","HvWarningText"],"mappings":";;;;;;;;;;;;;AAqGA,MAAM,+BAA+B,CAAC,aAA8B;AAC5D,QAAA,gBAAgBA,MAAAA,SAAS,QAAQ,QAAQ;AAC/C,QAAM,gBAAgB,cAAc;AACpC,WAAS,IAAI,GAAG,MAAM,eAAe,KAAK,GAAG;AACrC,UAAA,QAAa,cAAc,CAAC;AAE5B,UAAA,oBAAoB,OAAO,OAAO,YAAY;AACpD,UAAM,kBAAkB,oBACpB,OAAO,OAAO,UACd,OAAO,OAAO;AAElB,QAAI,iBAAiB;AACnB,aAAO,OAAO,OAAO;AAAA,IACvB;AAAA,EACF;AAEO,SAAA;AACT;AAOO,MAAM,eAAeC,MAAA;AAAA,EAC1B,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,qBAAqB;AAAA,MACrB;AAAA,MACA,GAAG;AAAA,IAAA,IACDC,gBA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A;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;;;"}
@@ -41,7 +41,7 @@ const HvScrollToHorizontal = (props) => {
41
41
  const downSm = useMediaQuery__default.default(muiTheme.breakpoints.down("sm"));
42
42
  const upMd = useMediaQuery__default.default(muiTheme.breakpoints.up("md"));
43
43
  const { activeTheme } = useTheme.useTheme();
44
- const elementId = useUniqueId.useUniqueId(id, "hvHorizontalScrollto");
44
+ const elementId = useUniqueId.useUniqueId(id);
45
45
  const [selectedIndex, setScrollTo, elements] = useScrollTo.useScrollTo(
46
46
  defaultSelectedIndex,
47
47
  scrollElementId,
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollToHorizontal.cjs","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { useTheme } from \"../../hooks/useTheme\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\n\nimport { HvScrollToTooltipPositions } from \"../types\";\nimport { withTooltip } from \"../withTooltip\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToHorizontalOption {\n key?: string;\n label: string;\n value: string;\n offset?: number;\n}\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToHorizontalOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const { activeTheme } = useTheme();\n\n const elementId = useUniqueId(id, \"hvHorizontalScrollto\");\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition);\n });\n }, [options, tooltipPosition]);\n\n const NotSelected = useCallback(() => {\n return (\n <div className={classes.notSelectedRoot}>\n <div className={classes.notSelected} />\n </div>\n );\n }, [classes.notSelectedRoot, classes.notSelected]);\n\n const Selected = useCallback(() => {\n return (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n className={classes.selected}\n />\n );\n }, [classes.selected, activeTheme?.scrollTo.dotSelectedSize]);\n\n const tabs = elements.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvHorizontalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n >\n <p>{option.label}</p>\n {selected ? <Selected /> : <NotSelected />}\n </HvHorizontalScrollListItem>\n );\n });\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n }),\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n },\n className\n )}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useDefaultProps","useClasses","useMuiTheme","useMediaQuery","useTheme","useUniqueId","useScrollTo","useMemo","withTooltip","useCallback","jsx","CurrentStep","jsxs","HvHorizontalScrollListItem","setId","isKey","theme"],"mappings":";;;;;;;;;;;;;;;;;;;AAiHa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IAC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A;AAAA,EAI5B,CAEH;AAGC,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,IAAI;AAAA,UACF,OACE,aAAa,YAAY,QAAQ,UAC7B,iBAAiBM,YAAM,MAAA,QAAQ,OAAO,IAAI,CAAC,CAAC,MAC5C;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,UACd,aACE,aAAa,YAAY,QAAQ,UAC7BA,kBAAM,QAAQ,OAAO,IAAI,CAAC,IAC1B;AAAA,UACN,YACE,aAAa,YAAY,QAAQ,UAC7BA,kBAAM,QAAQ,OAAO,IAAI,CAAC,IAC1B;AAAA,QAAA,CACP;AAAA,QACD,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,cAAc,GAAG,aAAa;AAAA,UACvC,CAAC,QAAQ,aAAa,GAAG,aAAa;AAAA,QACxC;AAAA,QACA;AAAA,MACF;AAAA,MACA,IAAI;AAAA,MACH,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;;;"}
1
+ {"version":3,"file":"ScrollToHorizontal.cjs","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { useTheme } from \"../../hooks/useTheme\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\n\nimport { HvScrollToTooltipPositions } from \"../types\";\nimport { withTooltip } from \"../withTooltip\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToHorizontalOption {\n key?: string;\n label: string;\n value: string;\n offset?: number;\n}\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToHorizontalOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const { activeTheme } = useTheme();\n\n const elementId = useUniqueId(id);\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition);\n });\n }, [options, tooltipPosition]);\n\n const NotSelected = useCallback(() => {\n return (\n <div className={classes.notSelectedRoot}>\n <div className={classes.notSelected} />\n </div>\n );\n }, [classes.notSelectedRoot, classes.notSelected]);\n\n const Selected = useCallback(() => {\n return (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n className={classes.selected}\n />\n );\n }, [classes.selected, activeTheme?.scrollTo.dotSelectedSize]);\n\n const tabs = elements.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvHorizontalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n >\n <p>{option.label}</p>\n {selected ? <Selected /> : <NotSelected />}\n </HvHorizontalScrollListItem>\n );\n });\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n }),\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n },\n className\n )}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useDefaultProps","useClasses","useMuiTheme","useMediaQuery","useTheme","useUniqueId","useScrollTo","useMemo","withTooltip","useCallback","jsx","CurrentStep","jsxs","HvHorizontalScrollListItem","setId","isKey","theme"],"mappings":";;;;;;;;;;;;;;;;;;;AAiHa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,wBAAwB,KAAK;AAEjD,QAAM,EAAE,SAAS,KAAK,GAAG,IAAIC,0BAAAA,WAAW,WAAW;AACnD,QAAM,WAAWC,OAAAA;AAEjB,QAAM,SAASC,uBAAAA,QAAc,SAAS,YAAY,KAAK,IAAI,CAAC;AAC5D,QAAM,OAAOA,uBAAAA,QAAc,SAAS,YAAY,GAAG,IAAI,CAAC;AAElD,QAAA,EAAE,gBAAgBC,SAAAA;AAElB,QAAA,YAAYC,wBAAY,EAAE;AAEhC,QAAM,CAAC,eAAe,aAAa,QAAQ,IAAIC,YAAA;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,kBAAkB,CACtB,OAGA,OACA,UACG;AACH,UAAM,eAAe;AAErB,UAAM,kBAAkB,MAAM;AAC5B,iBAAW,OAAO,KAAK;AAAA,IAAA;AAGb,gBAAA,OAAO,OAAO,OAAO,eAAe;AAAA,EAAA;AAG5C,QAAA,kBAAkBC,MAAAA,QAAQ,MAAM;AAC7B,WAAA,QAAQ,IAAI,CAAC,WAAW;AAC7B,aA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A,QAChD;AAAA,QACA;AAAA,QAGA,UAAA;AAAA,UAACL,2BAAAA,IAAA,KAAA,EAAG,iBAAO,MAAM,CAAA;AAAA,UAChB,WAAWA,2BAAA,IAAC,UAAS,CAAA,CAAA,mCAAM,aAAY,EAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAHnC,OAAO,OAAO,OAAO;AAAA,IAAA;AAAA,EAI5B,CAEH;AAGC,SAAAA,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,IAAI;AAAA,UACF,OACE,aAAa,YAAY,QAAQ,UAC7B,iBAAiBM,YAAM,MAAA,QAAQ,OAAO,IAAI,CAAC,CAAC,MAC5C;AAAA,UACN,WAAW;AAAA,UACX,cAAc;AAAA,UACd,aACE,aAAa,YAAY,QAAQ,UAC7BA,kBAAM,QAAQ,OAAO,IAAI,CAAC,IAC1B;AAAA,UACN,YACE,aAAa,YAAY,QAAQ,UAC7BA,kBAAM,QAAQ,OAAO,IAAI,CAAC,IAC1B;AAAA,QAAA,CACP;AAAA,QACD,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,cAAc,GAAG,aAAa;AAAA,UACvC,CAAC,QAAQ,aAAa,GAAG,aAAa;AAAA,QACxC;AAAA,QACA;AAAA,MACF;AAAA,MACA,IAAI;AAAA,MACH,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;;;"}
@@ -29,7 +29,7 @@ const HvScrollToVertical = (props) => {
29
29
  ...others
30
30
  } = useDefaultProps.useDefaultProps("HvScrollToVertical", props);
31
31
  const { classes, cx } = ScrollToVertical_styles.useClasses(classesProp);
32
- const elementId = useUniqueId.useUniqueId(id, "hvVerticalScrollto");
32
+ const elementId = useUniqueId.useUniqueId(id);
33
33
  const [selectedIndex, setScrollTo, elements] = useScrollTo.useScrollTo(
34
34
  defaultSelectedIndex,
35
35
  scrollElementId,
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollToVertical.cjs","sources":["../../../../src/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\n\nimport {\n staticClasses,\n useClasses,\n calculateOffset,\n} from \"./ScrollToVertical.styles\";\nimport { HvVerticalScrollListItem } from \"./VerticalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport {\n HvScrollToTooltipPositions,\n HvScrollToOption,\n HvScrollToVerticalPositions,\n} from \"../types\";\n\nexport { staticClasses as scrollToVerticalClasses };\n\nexport type HvScrollToVerticalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToVerticalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Vertical scroll to. */\n position?: HvScrollToVerticalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToVerticalClasses;\n}\n\n/**\n * The vertical scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToVertical = (props: HvScrollToVerticalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"left\",\n style,\n ...others\n } = useDefaultProps(\"HvScrollToVertical\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvVerticalScrollto\");\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tabs = elements.map((option, index) => (\n <HvVerticalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n />\n ));\n\n const positionOffset = calculateOffset(options.length);\n\n return (\n <ol\n className={cx(\n classes.root,\n {\n [classes.positionFixed]: position === \"fixed\",\n [classes.positionAbsolute]: position === \"absolute\",\n },\n className\n )}\n style={{ top: `calc(50% - ${positionOffset}px)`, ...style }}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useDefaultProps","useClasses","useUniqueId","useScrollTo","jsx","HvVerticalScrollListItem","setId","isKey","calculateOffset"],"mappings":";;;;;;;;;;AAwGa,MAAA,qBAAqB,CAAC,UAAmC;AAC9D,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB;AAAA,IACA,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,sBAAsB,KAAK;AAE/C,QAAM,EAAE,SAAS,GAAG,IAAIC,mCAAW,WAAW;AAExC,Q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,aAAa,GAAG,aAAa;AAAA,UACtC,CAAC,QAAQ,gBAAgB,GAAG,aAAa;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,EAAE,KAAK,cAAc,cAAc,OAAO,GAAG,MAAM;AAAA,MAC1D,IAAI;AAAA,MACH,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;;;"}
1
+ {"version":3,"file":"ScrollToVertical.cjs","sources":["../../../../src/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\n\nimport {\n staticClasses,\n useClasses,\n calculateOffset,\n} from \"./ScrollToVertical.styles\";\nimport { HvVerticalScrollListItem } from \"./VerticalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport {\n HvScrollToTooltipPositions,\n HvScrollToOption,\n HvScrollToVerticalPositions,\n} from \"../types\";\n\nexport { staticClasses as scrollToVerticalClasses };\n\nexport type HvScrollToVerticalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToVerticalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Vertical scroll to. */\n position?: HvScrollToVerticalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToVerticalClasses;\n}\n\n/**\n * The vertical scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToVertical = (props: HvScrollToVerticalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"left\",\n style,\n ...others\n } = useDefaultProps(\"HvScrollToVertical\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tabs = elements.map((option, index) => (\n <HvVerticalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n if (navigationMode !== \"none\") {\n event.preventDefault();\n }\n\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n />\n ));\n\n const positionOffset = calculateOffset(options.length);\n\n return (\n <ol\n className={cx(\n classes.root,\n {\n [classes.positionFixed]: position === \"fixed\",\n [classes.positionAbsolute]: position === \"absolute\",\n },\n className\n )}\n style={{ top: `calc(50% - ${positionOffset}px)`, ...style }}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useDefaultProps","useClasses","useUniqueId","useScrollTo","jsx","HvVerticalScrollListItem","setId","isKey","calculateOffset"],"mappings":";;;;;;;;;;AAwGa,MAAA,qBAAqB,CAAC,UAAmC;AAC9D,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,g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;AAAA,MAE5B,OAAO,OAAO;AAAA,IAAA;AAAA,IADT,OAAO,OAAO,OAAO;AAAA,EAAA,CAG7B;AAEK,QAAA,iBAAiBC,wBAAAA,gBAAgB,QAAQ,MAAM;AAGnD,SAAAJ,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,aAAa,GAAG,aAAa;AAAA,UACtC,CAAC,QAAQ,gBAAgB,GAAG,aAAa;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,EAAE,KAAK,cAAc,cAAc,OAAO,GAAG,MAAM;AAAA,MAC1D,IAAI;AAAA,MACH,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;;;"}
@@ -32,7 +32,7 @@ const HvSection = React.forwardRef(
32
32
  expanded,
33
33
  Boolean(defaultExpanded)
34
34
  );
35
- const elementId = useUniqueId.useUniqueId(id, "hvSection");
35
+ const elementId = useUniqueId.useUniqueId(id);
36
36
  const contentId = setId.setId(elementId, "content");
37
37
  const showContent = expandable ? !!isOpen : true;
38
38
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1 +1 @@
1
- {"version":3,"file":"Section.cjs","sources":["../../../src/Section/Section.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { Down, Up } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\n\nimport { staticClasses, useClasses } from \"./Section.styles\";\n\nexport { staticClasses as sectionClasses };\n\nexport type HvSectionClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSectionProps\n extends Omit<HvBaseProps<HTMLDivElement>, \"title\"> {\n /** The title of the section */\n title?: React.ReactNode;\n /** Whether or not the section is expandable. */\n expandable?: boolean;\n /** Whether the section is open or not, if this property is defined the accordion must be fully controlled. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** Section actions */\n actions?: React.ReactNode;\n /** Section onExpand callback */\n onToggle?: (\n event: React.MouseEvent<HTMLButtonElement>,\n open: boolean\n ) => void;\n /** Props to be passed to the expand button */\n expandButtonProps?: HvButtonProps;\n /** Determines whether or not the header has a shadow on the bottom border. */\n raisedHeader?: boolean;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvSectionClasses;\n /** Content container ref. */\n contentRef?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Sections allow grouping information on a page under the same topic.\n */\nexport const HvSection = forwardRef<HTMLDivElement, HvSectionProps>(\n (props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n title,\n expandable,\n expanded,\n defaultExpanded = true,\n actions,\n onToggle,\n expandButtonProps,\n raisedHeader,\n contentRef,\n children,\n ...others\n } = useDefaultProps(\"HvSection\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n\n const elementId = useUniqueId(id, \"hvSection\");\n const contentId = setId(elementId, \"content\");\n\n const showContent = expandable ? !!isOpen : true;\n\n return (\n <div\n ref={ref}\n id={elementId}\n className={cx(classes.root, className)}\n {...others}\n >\n {(title || actions || expandable) && (\n <div\n className={cx(classes.header, {\n [classes.raisedHeader]: raisedHeader && isOpen,\n })}\n >\n {expandable && (\n <HvButton\n icon\n onClick={(event) => {\n setIsOpen((o) => !o);\n onToggle?.(event, !isOpen);\n }}\n aria-expanded={isOpen}\n aria-controls={contentId}\n aria-label={isOpen ? \"Collapse\" : \"Expand\"}\n {...expandButtonProps}\n >\n {isOpen ? <Up /> : <Down />}\n </HvButton>\n )}\n {title}\n <div className={classes.actions}>{actions}</div>\n </div>\n )}\n <div\n ref={contentRef}\n id={contentId}\n hidden={!isOpen}\n className={cx(classes.content, {\n [classes.hidden]: !showContent,\n [classes.spaceTop]: !(title || actions || expandable),\n })}\n >\n {children}\n </div>\n </div>\n );\n }\n);\n"],"names":["forwardRef","useDefaultProps","useClasses","useControlled","useUniqueId","setId","jsxs","jsx","HvButton","Up","Down"],"mappings":";;;;;;;;;;;AA+CO,MAAM,YAAYA,MAAA;AAAA,EACvB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACDC,gBAAgB,gBAAA,aAAa,KAAK;AAEtC,UAAM,EAAE,SAAS,GAAG,IAAIC,0BAAW,WAAW;AAExC,UAAA,CAAC,QAAQ,SAAS,IAAIC,cAAA;AAAA,MAC1B;AAAA,MACA,QAAQ,eAAe;AAAA,IAAA;AAGnB,UAAA,YAAYC,YAAAA,YAAY,IAAI,WAAW;AACvC,UAAA,YAAYC,MAAAA,MAAM,WAAW,SAAS;AAE5C,UAAM,cAAc,aAAa,CAAC,CAAC,SAAS;AAG1C,WAAAC,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,IAAI;AAAA,QACJ,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QACpC,GAAG;AAAA,QAEF,UAAA;AAAA,WAAA,SAAS,WAAW,eACpBA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,QAAQ,QAAQ;AAAA,gBAC5B,CAAC,QAAQ,YAAY,GAAG,gBAAgB;AAAA,cAAA,CACzC;AAAA,cAEA,UAAA;AAAA,gBACC,cAAAC,2BAAA;AAAA,kBAACC,OAAA;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,SAAS,CAAC,UAAU;AACR,gCAAA,CAAC,MAAM,CAAC,CAAC;AACR,iCAAA,OAAO,CAAC,MAAM;AAAA,oBAC3B;AAAA,oBACA,iBAAe;AAAA,oBACf,iBAAe;AAAA,oBACf,cAAY,SAAS,aAAa;AAAA,oBACjC,GAAG;AAAA,oBAEH,UAAS,SAAAD,2BAAAA,IAACE,gBAAG,IAAA,CAAA,CAAA,mCAAMC,gBAAK,MAAA,EAAA;AAAA,kBAAA;AAAA,gBAC3B;AAAA,gBAED;AAAA,gBACAH,2BAAA,IAAA,OAAA,EAAI,WAAW,QAAQ,SAAU,UAAQ,SAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAC5C;AAAA,UAEFA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,IAAI;AAAA,cACJ,QAAQ,CAAC;AAAA,cACT,WAAW,GAAG,QAAQ,SAAS;AAAA,gBAC7B,CAAC,QAAQ,MAAM,GAAG,CAAC;AAAA,gBACnB,CAAC,QAAQ,QAAQ,GAAG,EAAE,SAAS,WAAW;AAAA,cAAA,CAC3C;AAAA,cAEA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;;;"}
1
+ {"version":3,"file":"Section.cjs","sources":["../../../src/Section/Section.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { Down, Up } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { HvButton, HvButtonProps } from \"../Button\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\n\nimport { staticClasses, useClasses } from \"./Section.styles\";\n\nexport { staticClasses as sectionClasses };\n\nexport type HvSectionClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSectionProps\n extends Omit<HvBaseProps<HTMLDivElement>, \"title\"> {\n /** The title of the section */\n title?: React.ReactNode;\n /** Whether or not the section is expandable. */\n expandable?: boolean;\n /** Whether the section is open or not, if this property is defined the accordion must be fully controlled. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** Section actions */\n actions?: React.ReactNode;\n /** Section onExpand callback */\n onToggle?: (\n event: React.MouseEvent<HTMLButtonElement>,\n open: boolean\n ) => void;\n /** Props to be passed to the expand button */\n expandButtonProps?: HvButtonProps;\n /** Determines whether or not the header has a shadow on the bottom border. */\n raisedHeader?: boolean;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvSectionClasses;\n /** Content container ref. */\n contentRef?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Sections allow grouping information on a page under the same topic.\n */\nexport const HvSection = forwardRef<HTMLDivElement, HvSectionProps>(\n (props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n title,\n expandable,\n expanded,\n defaultExpanded = true,\n actions,\n onToggle,\n expandButtonProps,\n raisedHeader,\n contentRef,\n children,\n ...others\n } = useDefaultProps(\"HvSection\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n\n const elementId = useUniqueId(id);\n const contentId = setId(elementId, \"content\");\n\n const showContent = expandable ? !!isOpen : true;\n\n return (\n <div\n ref={ref}\n id={elementId}\n className={cx(classes.root, className)}\n {...others}\n >\n {(title || actions || expandable) && (\n <div\n className={cx(classes.header, {\n [classes.raisedHeader]: raisedHeader && isOpen,\n })}\n >\n {expandable && (\n <HvButton\n icon\n onClick={(event) => {\n setIsOpen((o) => !o);\n onToggle?.(event, !isOpen);\n }}\n aria-expanded={isOpen}\n aria-controls={contentId}\n aria-label={isOpen ? \"Collapse\" : \"Expand\"}\n {...expandButtonProps}\n >\n {isOpen ? <Up /> : <Down />}\n </HvButton>\n )}\n {title}\n <div className={classes.actions}>{actions}</div>\n </div>\n )}\n <div\n ref={contentRef}\n id={contentId}\n hidden={!isOpen}\n className={cx(classes.content, {\n [classes.hidden]: !showContent,\n [classes.spaceTop]: !(title || actions || expandable),\n })}\n >\n {children}\n </div>\n </div>\n );\n }\n);\n"],"names":["forwardRef","useDefaultProps","useClasses","useControlled","useUniqueId","setId","jsxs","jsx","HvButton","Up","Down"],"mappings":";;;;;;;;;;;AA+CO,MAAM,YAAYA,MAAA;AAAA,EACvB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACDC,gBAAgB,gBAAA,aAAa,KAAK;AAEtC,UAAM,EAAE,SAAS,GAAG,IAAIC,0BAAW,WAAW;AAExC,UAAA,CAAC,QAAQ,SAAS,IAAIC,cAAA;AAAA,MAC1B;AAAA,MACA,QAAQ,eAAe;AAAA,IAAA;AAGnB,UAAA,YAAYC,wBAAY,EAAE;AAC1B,UAAA,YAAYC,MAAAA,MAAM,WAAW,SAAS;AAE5C,UAAM,cAAc,aAAa,CAAC,CAAC,SAAS;AAG1C,WAAAC,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,IAAI;AAAA,QACJ,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QACpC,GAAG;AAAA,QAEF,UAAA;AAAA,WAAA,SAAS,WAAW,eACpBA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,QAAQ,QAAQ;AAAA,gBAC5B,CAAC,QAAQ,YAAY,GAAG,gBAAgB;AAAA,cAAA,CACzC;AAAA,cAEA,UAAA;AAAA,gBACC,cAAAC,2BAAA;AAAA,kBAACC,OAAA;AAAA,kBAAA;AAAA,oBACC,MAAI;AAAA,oBACJ,SAAS,CAAC,UAAU;AACR,gCAAA,CAAC,MAAM,CAAC,CAAC;AACR,iCAAA,OAAO,CAAC,MAAM;AAAA,oBAC3B;AAAA,oBACA,iBAAe;AAAA,oBACf,iBAAe;AAAA,oBACf,cAAY,SAAS,aAAa;AAAA,oBACjC,GAAG;AAAA,oBAEH,UAAS,SAAAD,2BAAAA,IAACE,gBAAG,IAAA,CAAA,CAAA,mCAAMC,gBAAK,MAAA,EAAA;AAAA,kBAAA;AAAA,gBAC3B;AAAA,gBAED;AAAA,gBACAH,2BAAA,IAAA,OAAA,EAAI,WAAW,QAAQ,SAAU,UAAQ,SAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAC5C;AAAA,UAEFA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,IAAI;AAAA,cACJ,QAAQ,CAAC;AAAA,cACT,WAAW,GAAG,QAAQ,SAAS;AAAA,gBAC7B,CAAC,QAAQ,MAAM,GAAG,CAAC;AAAA,gBACnB,CAAC,QAAQ,QAAQ,GAAG,EAAE,SAAS,WAAW;AAAA,cAAA,CAC3C;AAAA,cAEA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;;;"}
@@ -52,7 +52,7 @@ const HvSelectionList = React.forwardRef((props, ref) => {
52
52
  ...others
53
53
  } = useDefaultProps.useDefaultProps("HvSelectionList", props);
54
54
  const { classes, cx } = SelectionList_styles.useClasses(classesProp);
55
- const elementId = useUniqueId.useUniqueId(id, "hvselectionlist");
55
+ const elementId = useUniqueId.useUniqueId(id);
56
56
  const [value, setValue] = useControlled.useControlled(
57
57
  valueProp,
58
58
  defaultValue !== void 0 ? defaultValue : (