@hitachivantara/uikit-react-core 5.82.2 → 5.82.3

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 (160) hide show
  1. package/dist/cjs/BaseInput/BaseInput.cjs +11 -12
  2. package/dist/cjs/BaseInput/validations.cjs +3 -3
  3. package/dist/cjs/Calendar/Calendar.cjs +14 -15
  4. package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +8 -10
  5. package/dist/cjs/CheckBox/CheckBox.cjs +10 -10
  6. package/dist/cjs/CheckBoxGroup/CheckBoxGroup.cjs +8 -8
  7. package/dist/cjs/ColorPicker/ColorPicker.cjs +6 -9
  8. package/dist/cjs/DatePicker/DatePicker.cjs +15 -15
  9. package/dist/cjs/Dropdown/Dropdown.cjs +9 -9
  10. package/dist/cjs/FileUploader/DropZone/DropZone.cjs +2 -2
  11. package/dist/cjs/FilterGroup/FilterGroup.cjs +6 -6
  12. package/dist/cjs/{Forms → FormElement}/Adornment/Adornment.cjs +9 -10
  13. package/dist/cjs/{Forms → FormElement}/CharCounter/CharCounter.cjs +15 -15
  14. package/dist/cjs/FormElement/FormElement.cjs +35 -0
  15. package/dist/cjs/{Forms → FormElement}/InfoMessage/InfoMessage.cjs +8 -8
  16. package/dist/cjs/{Forms → FormElement}/Label/Label.cjs +13 -13
  17. package/dist/cjs/{Forms → FormElement}/Suggestions/Suggestions.cjs +6 -6
  18. package/dist/cjs/{Forms → FormElement}/WarningText/WarningText.cjs +5 -5
  19. package/dist/cjs/FormElement/context.cjs +11 -0
  20. package/dist/cjs/{Forms/FormElement/utils/FormUtils.cjs → FormElement/utils.cjs} +19 -11
  21. package/dist/cjs/Input/Input.cjs +17 -17
  22. package/dist/cjs/Input/Input.styles.cjs +2 -2
  23. package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +1 -1
  24. package/dist/cjs/Radio/Radio.cjs +10 -13
  25. package/dist/cjs/RadioGroup/RadioGroup.cjs +7 -7
  26. package/dist/cjs/Select/Select.cjs +4 -4
  27. package/dist/cjs/SelectionList/SelectionList.cjs +7 -7
  28. package/dist/cjs/Slider/Slider.cjs +10 -10
  29. package/dist/cjs/Slider/utils.cjs +7 -7
  30. package/dist/cjs/Switch/Switch.cjs +9 -12
  31. package/dist/cjs/TagsInput/TagsInput.cjs +17 -17
  32. package/dist/cjs/TagsInput/TagsInput.styles.cjs +1 -1
  33. package/dist/cjs/TextArea/TextArea.cjs +17 -17
  34. package/dist/cjs/TimePicker/TimePicker.cjs +7 -7
  35. package/dist/cjs/index.cjs +15 -36
  36. package/dist/esm/BaseInput/BaseInput.js +5 -6
  37. package/dist/esm/BaseInput/BaseInput.js.map +1 -1
  38. package/dist/esm/BaseInput/validations.js +3 -3
  39. package/dist/esm/BaseInput/validations.js.map +1 -1
  40. package/dist/esm/Calendar/Calendar.js +13 -14
  41. package/dist/esm/Calendar/Calendar.js.map +1 -1
  42. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +6 -8
  43. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
  44. package/dist/esm/CheckBox/CheckBox.js +9 -9
  45. package/dist/esm/CheckBox/CheckBox.js.map +1 -1
  46. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js +8 -8
  47. package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
  48. package/dist/esm/ColorPicker/ColorPicker.js +6 -9
  49. package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
  50. package/dist/esm/DatePicker/DatePicker.js +9 -9
  51. package/dist/esm/DatePicker/DatePicker.js.map +1 -1
  52. package/dist/esm/Dropdown/Dropdown.js +8 -8
  53. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  54. package/dist/esm/FileUploader/DropZone/DropZone.js +2 -2
  55. package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
  56. package/dist/esm/FilterGroup/FilterContent/FilterContent.js.map +1 -1
  57. package/dist/esm/FilterGroup/FilterGroup.js +6 -6
  58. package/dist/esm/FilterGroup/FilterGroup.js.map +1 -1
  59. package/dist/esm/{Forms → FormElement}/Adornment/Adornment.js +8 -9
  60. package/dist/esm/FormElement/Adornment/Adornment.js.map +1 -0
  61. package/dist/esm/FormElement/Adornment/Adornment.styles.js.map +1 -0
  62. package/dist/esm/{Forms → FormElement}/CharCounter/CharCounter.js +15 -15
  63. package/dist/esm/FormElement/CharCounter/CharCounter.js.map +1 -0
  64. package/dist/esm/FormElement/CharCounter/CharCounter.styles.js.map +1 -0
  65. package/dist/esm/FormElement/FormElement.js +36 -0
  66. package/dist/esm/FormElement/FormElement.js.map +1 -0
  67. package/dist/esm/FormElement/FormElement.styles.js.map +1 -0
  68. package/dist/esm/{Forms → FormElement}/InfoMessage/InfoMessage.js +8 -8
  69. package/dist/esm/FormElement/InfoMessage/InfoMessage.js.map +1 -0
  70. package/dist/esm/FormElement/InfoMessage/InfoMessage.styles.js.map +1 -0
  71. package/dist/esm/{Forms → FormElement}/Label/Label.js +12 -12
  72. package/dist/esm/FormElement/Label/Label.js.map +1 -0
  73. package/dist/esm/FormElement/Label/Label.styles.js.map +1 -0
  74. package/dist/esm/{Forms → FormElement}/Suggestions/Suggestions.js +6 -6
  75. package/dist/esm/FormElement/Suggestions/Suggestions.js.map +1 -0
  76. package/dist/esm/FormElement/Suggestions/Suggestions.styles.js.map +1 -0
  77. package/dist/esm/{Forms → FormElement}/WarningText/WarningText.js +5 -5
  78. package/dist/esm/FormElement/WarningText/WarningText.js.map +1 -0
  79. package/dist/esm/FormElement/WarningText/WarningText.styles.js.map +1 -0
  80. package/dist/esm/FormElement/context.js +11 -0
  81. package/dist/esm/FormElement/context.js.map +1 -0
  82. package/dist/esm/{Forms/FormElement/utils/FormUtils.js → FormElement/utils.js} +21 -11
  83. package/dist/esm/FormElement/utils.js.map +1 -0
  84. package/dist/esm/Input/Input.js +21 -21
  85. package/dist/esm/Input/Input.js.map +1 -1
  86. package/dist/esm/Input/Input.styles.js +2 -2
  87. package/dist/esm/Input/Input.styles.js.map +1 -1
  88. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +1 -1
  89. package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
  90. package/dist/esm/QueryBuilder/Rule/Value/TextValue/TextValue.js.map +1 -1
  91. package/dist/esm/Radio/Radio.js +9 -12
  92. package/dist/esm/Radio/Radio.js.map +1 -1
  93. package/dist/esm/RadioGroup/RadioGroup.js +7 -7
  94. package/dist/esm/RadioGroup/RadioGroup.js.map +1 -1
  95. package/dist/esm/Select/Select.js +4 -4
  96. package/dist/esm/Select/Select.js.map +1 -1
  97. package/dist/esm/SelectionList/SelectionList.js +7 -7
  98. package/dist/esm/SelectionList/SelectionList.js.map +1 -1
  99. package/dist/esm/Slider/Slider.js +10 -10
  100. package/dist/esm/Slider/Slider.js.map +1 -1
  101. package/dist/esm/Slider/SliderInput/SliderInput.js.map +1 -1
  102. package/dist/esm/Slider/utils.js +7 -7
  103. package/dist/esm/Slider/utils.js.map +1 -1
  104. package/dist/esm/Switch/Switch.js +8 -11
  105. package/dist/esm/Switch/Switch.js.map +1 -1
  106. package/dist/esm/TagsInput/TagsInput.js +19 -19
  107. package/dist/esm/TagsInput/TagsInput.js.map +1 -1
  108. package/dist/esm/TagsInput/TagsInput.styles.js +1 -1
  109. package/dist/esm/TagsInput/TagsInput.styles.js.map +1 -1
  110. package/dist/esm/TextArea/TextArea.js +19 -19
  111. package/dist/esm/TextArea/TextArea.js.map +1 -1
  112. package/dist/esm/TimePicker/TimePicker.js +7 -7
  113. package/dist/esm/TimePicker/TimePicker.js.map +1 -1
  114. package/dist/esm/index.js +14 -35
  115. package/dist/esm/index.js.map +1 -1
  116. package/dist/types/index.d.ts +66 -143
  117. package/package.json +2 -2
  118. package/dist/cjs/Forms/FormElement/FormElement.cjs +0 -44
  119. package/dist/cjs/Forms/FormElement/context/FormElementContext.cjs +0 -12
  120. package/dist/cjs/Forms/FormElement/context/FormElementDescriptorsContext.cjs +0 -12
  121. package/dist/cjs/Forms/FormElement/context/FormElementValueContext.cjs +0 -12
  122. package/dist/cjs/Forms/FormElement/validationStates.cjs +0 -12
  123. package/dist/esm/Forms/Adornment/Adornment.js.map +0 -1
  124. package/dist/esm/Forms/Adornment/Adornment.styles.js.map +0 -1
  125. package/dist/esm/Forms/CharCounter/CharCounter.js.map +0 -1
  126. package/dist/esm/Forms/CharCounter/CharCounter.styles.js.map +0 -1
  127. package/dist/esm/Forms/FormElement/FormElement.js +0 -45
  128. package/dist/esm/Forms/FormElement/FormElement.js.map +0 -1
  129. package/dist/esm/Forms/FormElement/FormElement.styles.js.map +0 -1
  130. package/dist/esm/Forms/FormElement/context/FormElementContext.js +0 -10
  131. package/dist/esm/Forms/FormElement/context/FormElementContext.js.map +0 -1
  132. package/dist/esm/Forms/FormElement/context/FormElementDescriptorsContext.js +0 -10
  133. package/dist/esm/Forms/FormElement/context/FormElementDescriptorsContext.js.map +0 -1
  134. package/dist/esm/Forms/FormElement/context/FormElementValueContext.js +0 -10
  135. package/dist/esm/Forms/FormElement/context/FormElementValueContext.js.map +0 -1
  136. package/dist/esm/Forms/FormElement/utils/FormUtils.js.map +0 -1
  137. package/dist/esm/Forms/FormElement/validationStates.js +0 -12
  138. package/dist/esm/Forms/FormElement/validationStates.js.map +0 -1
  139. package/dist/esm/Forms/InfoMessage/InfoMessage.js.map +0 -1
  140. package/dist/esm/Forms/InfoMessage/InfoMessage.styles.js.map +0 -1
  141. package/dist/esm/Forms/Label/Label.js.map +0 -1
  142. package/dist/esm/Forms/Label/Label.styles.js.map +0 -1
  143. package/dist/esm/Forms/Suggestions/Suggestions.js.map +0 -1
  144. package/dist/esm/Forms/Suggestions/Suggestions.styles.js.map +0 -1
  145. package/dist/esm/Forms/WarningText/WarningText.js.map +0 -1
  146. package/dist/esm/Forms/WarningText/WarningText.styles.js.map +0 -1
  147. /package/dist/cjs/{Forms → FormElement}/Adornment/Adornment.styles.cjs +0 -0
  148. /package/dist/cjs/{Forms → FormElement}/CharCounter/CharCounter.styles.cjs +0 -0
  149. /package/dist/cjs/{Forms/FormElement → FormElement}/FormElement.styles.cjs +0 -0
  150. /package/dist/cjs/{Forms → FormElement}/InfoMessage/InfoMessage.styles.cjs +0 -0
  151. /package/dist/cjs/{Forms → FormElement}/Label/Label.styles.cjs +0 -0
  152. /package/dist/cjs/{Forms → FormElement}/Suggestions/Suggestions.styles.cjs +0 -0
  153. /package/dist/cjs/{Forms → FormElement}/WarningText/WarningText.styles.cjs +0 -0
  154. /package/dist/esm/{Forms → FormElement}/Adornment/Adornment.styles.js +0 -0
  155. /package/dist/esm/{Forms → FormElement}/CharCounter/CharCounter.styles.js +0 -0
  156. /package/dist/esm/{Forms/FormElement → FormElement}/FormElement.styles.js +0 -0
  157. /package/dist/esm/{Forms → FormElement}/InfoMessage/InfoMessage.styles.js +0 -0
  158. /package/dist/esm/{Forms → FormElement}/Label/Label.styles.js +0 -0
  159. /package/dist/esm/{Forms → FormElement}/Suggestions/Suggestions.styles.js +0 -0
  160. /package/dist/esm/{Forms → FormElement}/WarningText/WarningText.styles.js +0 -0
@@ -2,32 +2,32 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { setId } from "../../utils/setId.js";
5
+ import { HvFormElementContext } from "../context.js";
5
6
  import { useClasses } from "./InfoMessage.styles.js";
6
7
  import { staticClasses } from "./InfoMessage.styles.js";
7
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
8
8
  import { HvTypography } from "../../Typography/Typography.js";
9
9
  const HvInfoMessage = (props) => {
10
10
  const {
11
- id,
11
+ id: idProp,
12
12
  classes: classesProp,
13
13
  className,
14
14
  children,
15
- disabled,
15
+ disabled: disabledProp,
16
16
  disableGutter = false,
17
17
  ...others
18
18
  } = useDefaultProps("HvInfoMessage", props);
19
19
  const { classes, cx } = useClasses(classesProp);
20
- const { elementId, elementDisabled } = useContext(HvFormElementContext);
21
- const localDisabled = disabled || elementDisabled;
22
- const localId = id ?? setId(elementId, "description");
20
+ const context = useContext(HvFormElementContext);
21
+ const disabled = disabledProp ?? context.disabled;
22
+ const id = idProp ?? setId(context.id, "description");
23
23
  return /* @__PURE__ */ jsx(
24
24
  HvTypography,
25
25
  {
26
- id: localId,
26
+ id,
27
27
  className: cx(
28
28
  classes.root,
29
29
  {
30
- [classes.infoDisabled]: !!localDisabled,
30
+ [classes.infoDisabled]: !!disabled,
31
31
  [classes.gutter]: !disableGutter
32
32
  },
33
33
  className
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoMessage.js","sources":["../../../../src/FormElement/InfoMessage/InfoMessage.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./InfoMessage.styles\";\n\nexport { staticClasses as infoMessageClasses };\n\nexport type HvInfoMessageClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvInfoMessageProps extends HvTypographyProps<\"label\"> {\n /** If `true` the label is disabled. */\n disabled?: boolean;\n /** If `true` the info message won't have margins. */\n disableGutter?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInfoMessageClasses;\n}\n\n/**\n * Provides the user with additional descriptive text for the form element.\n */\nexport const HvInfoMessage = (props: HvInfoMessageProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n children,\n disabled: disabledProp,\n disableGutter = false,\n ...others\n } = useDefaultProps(\"HvInfoMessage\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const disabled = disabledProp ?? context.disabled;\n const id = idProp ?? setId(context.id, \"description\");\n\n return (\n <HvTypography\n id={id}\n className={cx(\n classes.root,\n {\n [classes.infoDisabled]: !!disabled,\n [classes.gutter]: !disableGutter,\n },\n className,\n )}\n variant=\"body\"\n component=\"label\"\n {...others}\n >\n {children}\n </HvTypography>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA2Ba,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AACzC,QAAA,WAAW,gBAAgB,QAAQ;AACzC,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,aAAa;AAGlD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,YAAY,GAAG,CAAC,CAAC;AAAA,UAC1B,CAAC,QAAQ,MAAM,GAAG,CAAC;AAAA,QACrB;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAQ;AAAA,MACR,WAAU;AAAA,MACT,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoMessage.styles.js","sources":["../../../../src/FormElement/InfoMessage/InfoMessage.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvInfoMessage\", {\n root: { color: theme.colors.secondary_80, display: \"inline-block\" },\n infoDisabled: { color: theme.colors.secondary_60 },\n gutter: { padding: `0 0 6px ${theme.space.xs}` },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,OAAO,MAAM,OAAO,cAAc,SAAS,eAAe;AAAA,EAClE,cAAc,EAAE,OAAO,MAAM,OAAO,aAAa;AAAA,EACjD,QAAQ,EAAE,SAAS,WAAW,MAAM,MAAM,EAAE,GAAG;AACjD,CAAC;"}
@@ -2,38 +2,38 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { setId } from "../../utils/setId.js";
5
- import { findDescriptors } from "../FormElement/utils/FormUtils.js";
5
+ import { HvFormElementContext } from "../context.js";
6
+ import { findDescriptors } from "../utils.js";
6
7
  import { useClasses } from "./Label.styles.js";
7
8
  import { staticClasses } from "./Label.styles.js";
8
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
9
9
  import { HvTypography } from "../../Typography/Typography.js";
10
10
  const HvLabel = (props) => {
11
11
  const {
12
- id,
12
+ id: idProp,
13
13
  classes: classesProp,
14
14
  className,
15
15
  children,
16
16
  label,
17
- disabled,
18
- required,
17
+ disabled: disabledProp,
18
+ required: requiredProp,
19
19
  htmlFor: htmlForProp,
20
20
  ...others
21
21
  } = useDefaultProps("HvLabel", props);
22
22
  const { classes, cx } = useClasses(classesProp);
23
- const { elementId, elementDisabled, elementRequired } = useContext(HvFormElementContext);
24
- const localDisabled = disabled || elementDisabled;
25
- const localRequired = required || elementRequired;
26
- const localId = id ?? setId(elementId, "label");
23
+ const context = useContext(HvFormElementContext);
24
+ const disabled = disabledProp ?? context.disabled;
25
+ const required = requiredProp ?? context.required;
26
+ const id = idProp ?? setId(context.id, "label");
27
27
  const forId = htmlForProp || findDescriptors(children)?.input?.[0]?.id;
28
28
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29
29
  /* @__PURE__ */ jsxs(
30
30
  HvTypography,
31
31
  {
32
- id: localId,
32
+ id,
33
33
  className: cx(
34
34
  classes.root,
35
35
  {
36
- [classes.labelDisabled]: !!localDisabled,
36
+ [classes.labelDisabled]: !!disabled,
37
37
  [classes.childGutter]: !!(children && label)
38
38
  },
39
39
  className
@@ -44,7 +44,7 @@ const HvLabel = (props) => {
44
44
  ...others,
45
45
  children: [
46
46
  label,
47
- localRequired && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "*" })
47
+ required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "*" })
48
48
  ]
49
49
  }
50
50
  ),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Label.js","sources":["../../../../src/FormElement/Label/Label.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { findDescriptors } from \"../utils\";\nimport { staticClasses, useClasses } from \"./Label.styles\";\n\nexport { staticClasses as labelClasses };\n\nexport type HvLabelClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvLabelProps extends HvTypographyProps<\"label\"> {\n /** Id to be applied to the root node */\n id?: string;\n /** The text to be shown by the label. */\n label?: React.ReactNode;\n /** The id of the form element the label is bound to. */\n htmlFor?: string;\n /** If `true` the label is displayed with a disabled style. */\n disabled?: boolean;\n /** If `true`, the label will indicate that the form element is required (an `*` after the label text). */\n required?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvLabelClasses;\n}\n\n/**\n * Provides the user with a recognizable name for a given form element.\n */\nexport const HvLabel = (props: HvLabelProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n children,\n label,\n disabled: disabledProp,\n required: requiredProp,\n htmlFor: htmlForProp,\n ...others\n } = useDefaultProps(\"HvLabel\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n\n const disabled = disabledProp ?? context.disabled;\n const required = requiredProp ?? context.required;\n const id = idProp ?? setId(context.id, \"label\");\n\n const forId = htmlForProp || findDescriptors(children)?.input?.[0]?.id;\n\n return (\n <>\n <HvTypography\n id={id}\n className={cx(\n classes.root,\n {\n [classes.labelDisabled]: !!disabled,\n [classes.childGutter]: !!(children && label),\n },\n className,\n )}\n variant=\"label\"\n component=\"label\"\n htmlFor={forId}\n {...others}\n >\n {label}\n {required && <span aria-hidden=\"true\">*</span>}\n </HvTypography>\n {children}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAkCa,MAAA,UAAU,CAAC,UAAwB;AACxC,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,UAAU;AAAA,IACV,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,WAAW,KAAK;AAEpC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AAEzC,QAAA,WAAW,gBAAgB,QAAQ;AACnC,QAAA,WAAW,gBAAgB,QAAQ;AACzC,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,OAAO;AAE9C,QAAM,QAAQ,eAAe,gBAAgB,QAAQ,GAAG,QAAQ,CAAC,GAAG;AAEpE,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT,QAAQ;AAAA,UACR;AAAA,YACE,CAAC,QAAQ,aAAa,GAAG,CAAC,CAAC;AAAA,YAC3B,CAAC,QAAQ,WAAW,GAAG,CAAC,EAAE,YAAY;AAAA,UACxC;AAAA,UACA;AAAA,QACF;AAAA,QACA,SAAQ;AAAA,QACR,WAAU;AAAA,QACV,SAAS;AAAA,QACR,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA,YAAY,oBAAC,QAAK,EAAA,eAAY,QAAO,UAAC,IAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACzC;AAAA,IACC;AAAA,EAAA,GACH;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Label.styles.js","sources":["../../../../src/FormElement/Label/Label.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvLabel\", {\n root: { fontWeight: theme.fontWeights.normal, display: \"inline-block\" },\n labelDisabled: { color: theme.colors.secondary_60 },\n childGutter: { paddingBottom: \"6px\" },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,WAAW;AAAA,EACpE,MAAM,EAAE,YAAY,MAAM,YAAY,QAAQ,SAAS,eAAe;AAAA,EACtE,eAAe,EAAE,OAAO,MAAM,OAAO,aAAa;AAAA,EAClD,aAAa,EAAE,eAAe,MAAM;AACtC,CAAC;"}
@@ -6,14 +6,14 @@ import { useForkRef } from "@mui/material/utils";
6
6
  import { useTheme } from "@hitachivantara/uikit-react-utils";
7
7
  import { getContainerElement } from "../../utils/document.js";
8
8
  import { setId } from "../../utils/setId.js";
9
+ import { HvFormElementContext } from "../context.js";
9
10
  import { useClasses } from "./Suggestions.styles.js";
10
11
  import { staticClasses } from "./Suggestions.styles.js";
11
12
  import { HvSelectionList } from "../../SelectionList/SelectionList.js";
12
13
  import { HvListItem } from "../../ListContainer/ListItem/ListItem.js";
13
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
14
14
  const HvSuggestions = forwardRef((props, extRef) => {
15
15
  const {
16
- id,
16
+ id: idProp,
17
17
  className,
18
18
  classes: classesProp,
19
19
  expanded = false,
@@ -28,8 +28,8 @@ const HvSuggestions = forwardRef((props, extRef) => {
28
28
  } = props;
29
29
  const { classes, cx } = useClasses(classesProp);
30
30
  const { rootId } = useTheme();
31
- const { elementId } = useContext(HvFormElementContext);
32
- const localId = id ?? setId(elementId, "suggestions");
31
+ const context = useContext(HvFormElementContext);
32
+ const id = idProp ?? setId(context.id, "suggestions");
33
33
  const ref = useRef(null);
34
34
  const forkedRef = useForkRef(ref, extRef);
35
35
  const [isOpen, setIsOpen] = useState(expanded);
@@ -39,7 +39,7 @@ const HvSuggestions = forwardRef((props, extRef) => {
39
39
  return /* @__PURE__ */ jsx(
40
40
  "div",
41
41
  {
42
- id: localId,
42
+ id,
43
43
  ref: forkedRef,
44
44
  className: cx(classes.root, className),
45
45
  ...others,
@@ -69,7 +69,7 @@ const HvSuggestions = forwardRef((props, extRef) => {
69
69
  HvSelectionList,
70
70
  {
71
71
  className: classes.list,
72
- id: setId(localId, "list"),
72
+ id: setId(id, "list"),
73
73
  onChange: onSuggestionSelected,
74
74
  children: suggestionValues?.map((item) => /* @__PURE__ */ jsx(HvListItem, { value: item, disabled: item.disabled, children: item.label }, item.id))
75
75
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Suggestions.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useRef, useState } from \"react\";\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n} from \"@mui/base/ClickAwayListener\";\nimport { Popper, PopperProps } from \"@mui/base/Popper\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport { useTheme, type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvListItem } from \"../../ListContainer\";\nimport { HvSelectionList } from \"../../SelectionList\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { getContainerElement } from \"../../utils/document\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./Suggestions.styles\";\n\nexport { staticClasses as suggestionsClasses };\n\nexport type HvSuggestionsClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSuggestion {\n id?: string;\n label: React.ReactNode;\n value?: string;\n disabled?: boolean;\n}\n\nexport interface HvSuggestionsProps extends HvBaseProps {\n /** Whether suggestions is visible */\n open?: boolean;\n /**\n * Whether suggestions is visible.\n * @deprecated use `open` instead.\n * */\n expanded?: boolean;\n /** The HTML element Suggestions attaches to. */\n anchorEl?: HTMLElement | null;\n /** Array of { id, label, ...others } values to display in the suggestion list */\n suggestionValues?: HvSuggestion[] | null;\n /** Function called when a suggestion is selected */\n onSuggestionSelected?: (event: React.MouseEvent, value: HvSuggestion) => void;\n /** Function called when suggestion list is closed */\n onClose?: ClickAwayListenerProps[\"onClickAway\"];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSuggestionsClasses;\n /**\n * If enabled, the suggestions list will be rendered using a portal.\n * If disabled, it will be under the DOM hierarchy of the parent component.\n * @default false\n * */\n enablePortal?: boolean;\n /** Props passed to the underlying MUI Popper component */\n popperProps?: Partial<PopperProps>;\n}\n\nexport const HvSuggestions = forwardRef<\n // no-indent\n unknown,\n HvSuggestionsProps\n>((props, extRef) => {\n const {\n id: idProp,\n className,\n classes: classesProp,\n expanded = false,\n enablePortal = false,\n open: openProp,\n anchorEl,\n suggestionValues = [],\n onClose,\n onSuggestionSelected,\n popperProps,\n ...others\n } = props;\n\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const context = useContext(HvFormElementContext);\n const id = idProp ?? setId(context.id, \"suggestions\");\n\n const ref = useRef<HTMLDivElement>(null);\n const forkedRef = useForkRef(ref, extRef);\n\n // TODO: remove controlled+uncontrolled `expanded` prop in v6\n const [isOpen, setIsOpen] = useState(expanded);\n useEffect(() => {\n setIsOpen(expanded);\n }, [expanded]);\n\n return (\n <div\n id={id}\n ref={forkedRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <ClickAwayListener\n onClickAway={(event) => {\n setIsOpen(false);\n onClose?.(event);\n }}\n >\n <Popper\n style={{\n // @ts-ignore\n \"--popper-width\": enablePortal\n ? `${anchorEl?.clientWidth}px`\n : \"100%\",\n }}\n open={openProp ?? isOpen}\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={anchorEl}\n className={cx(classes.popper, {\n [classes.portal]: enablePortal,\n })}\n {...popperProps}\n >\n <HvSelectionList\n className={classes.list}\n id={setId(id, \"list\")}\n onChange={onSuggestionSelected}\n >\n {suggestionValues?.map((item) => (\n <HvListItem key={item.id} value={item} disabled={item.disabled}>\n {item.label}\n </HvListItem>\n ))}\n </HvSelectionList>\n </Popper>\n </ClickAwayListener>\n </div>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwDO,MAAM,gBAAgB,WAI3B,CAAC,OAAO,WAAW;AACb,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,eAAe;AAAA,IACf,MAAM;AAAA,IACN;AAAA,IACA,mBAAmB,CAAC;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,EAAE,OAAO,IAAI,SAAS;AAEtB,QAAA,UAAU,WAAW,oBAAoB;AAC/C,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,aAAa;AAE9C,QAAA,MAAM,OAAuB,IAAI;AACjC,QAAA,YAAY,WAAW,KAAK,MAAM;AAGxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,QAAQ;AAC7C,YAAU,MAAM;AACd,cAAU,QAAQ;AAAA,EAAA,GACjB,CAAC,QAAQ,CAAC;AAGX,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,KAAK;AAAA,MACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,MACpC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAa,CAAC,UAAU;AACtB,sBAAU,KAAK;AACf,sBAAU,KAAK;AAAA,UACjB;AAAA,UAEA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO;AAAA;AAAA,gBAEL,kBAAkB,eACd,GAAG,UAAU,WAAW,OACxB;AAAA,cACN;AAAA,cACA,MAAM,YAAY;AAAA,cAClB,eAAe,CAAC;AAAA,cAChB,WAAW,eAAe,oBAAoB,MAAM,IAAI;AAAA,cACxD;AAAA,cACA,WAAW,GAAG,QAAQ,QAAQ;AAAA,gBAC5B,CAAC,QAAQ,MAAM,GAAG;AAAA,cAAA,CACnB;AAAA,cACA,GAAG;AAAA,cAEJ,UAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAW,QAAQ;AAAA,kBACnB,IAAI,MAAM,IAAI,MAAM;AAAA,kBACpB,UAAU;AAAA,kBAET,UAAkB,kBAAA,IAAI,CAAC,6BACrB,YAAyB,EAAA,OAAO,MAAM,UAAU,KAAK,UACnD,UAAA,KAAK,MADS,GAAA,KAAK,EAEtB,CACD;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Suggestions.styles.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSuggestions\", {\n root: { position: \"relative\" },\n list: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n padding: theme.space.xs,\n width: \"100%\",\n },\n popper: {\n width: \"var(--popper-width)\",\n position: \"absolute\",\n zIndex: theme.zIndices.tooltip,\n \":not($portal)\": {\n transform: \"translate3d(0, -1px, 0) !important\",\n },\n },\n portal: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,UAAU,WAAW;AAAA,EAC7B,MAAM;AAAA,IACJ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,WAAW,MAAM,OAAO;AAAA,IACxB,SAAS,MAAM,MAAM;AAAA,IACrB,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ,MAAM,SAAS;AAAA,IACvB,iBAAiB;AAAA,MACf,WAAW;AAAA,IAAA;AAAA,EAEf;AAAA,EACA,QAAQ,CAAA;AACV,CAAC;"}
@@ -3,9 +3,9 @@ import { useContext } from "react";
3
3
  import { Fail } from "@hitachivantara/uikit-react-icons";
4
4
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
5
5
  import { setId } from "../../utils/setId.js";
6
+ import { HvFormElementContext } from "../context.js";
6
7
  import { useClasses } from "./WarningText.styles.js";
7
8
  import { staticClasses } from "./WarningText.styles.js";
8
- import { HvFormElementContext } from "../FormElement/context/FormElementContext.js";
9
9
  const HvWarningText = (props) => {
10
10
  const {
11
11
  children,
@@ -22,10 +22,10 @@ const HvWarningText = (props) => {
22
22
  ...others
23
23
  } = useDefaultProps("HvWarningText", props);
24
24
  const { classes, cx } = useClasses(classesProp);
25
- const { elementId, elementStatus, elementDisabled } = useContext(HvFormElementContext);
26
- const disabled = disabledProp || elementDisabled;
27
- const visible = isVisibleProp ?? elementStatus === "invalid";
28
- const id = idProp ?? setId(elementId, "error");
25
+ const context = useContext(HvFormElementContext);
26
+ const disabled = disabledProp ?? context.disabled;
27
+ const visible = isVisibleProp ?? context.status === "invalid";
28
+ const id = idProp ?? setId(context.id, "error");
29
29
  const showWarning = visible && !disabled;
30
30
  const adornment = adornmentProp || /* @__PURE__ */ jsx(Fail, { size: "xs", className: classes.defaultIcon });
31
31
  return /* @__PURE__ */ jsxs(
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WarningText.js","sources":["../../../../src/FormElement/WarningText/WarningText.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { Fail } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../../types/generic\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./WarningText.styles\";\n\nexport { staticClasses as warningTextClasses };\n\nexport type HvWarningTextClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvWarningTextProps extends HvBaseProps {\n /** Icon to be rendered alongside the warning text. */\n adornment?: React.ReactNode;\n /** If `true` the text is not rendered. */\n isVisible?: boolean;\n /** If `true` the text is disabled. */\n disabled?: boolean;\n /** If `true` the text won't include a gutter. */\n disableGutter?: boolean;\n /** If `true` the text won't include the top border. */\n disableBorder?: boolean;\n /** If `true` the adornment icon isn't shown. */\n disableAdornment?: boolean;\n /** If `true` the text isn't shown. */\n hideText?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvWarningTextClasses;\n}\n\n/**\n * Provides the user with a descriptive text, signaling an error, for when the form element is in an invalid state.\n */\nexport const HvWarningText = (props: HvWarningTextProps) => {\n const {\n children,\n adornment: adornmentProp,\n isVisible: isVisibleProp,\n classes: classesProp,\n className,\n id: idProp,\n disabled: disabledProp,\n disableGutter = false,\n disableBorder = false,\n disableAdornment = false,\n hideText = false,\n ...others\n } = useDefaultProps(\"HvWarningText\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(HvFormElementContext);\n const disabled = disabledProp ?? context.disabled;\n const visible = isVisibleProp ?? context.status === \"invalid\";\n const id = idProp ?? setId(context.id, \"error\");\n const showWarning = visible && !disabled;\n const adornment = adornmentProp || (\n <Fail size=\"xs\" className={classes.defaultIcon} />\n );\n\n return (\n <div\n className={cx(\n classes.root,\n {\n [classes.show]: showWarning,\n [classes.topBorder]: !disableBorder,\n },\n className,\n )}\n >\n {!disableAdornment && adornment}\n <span\n id={id}\n className={cx(classes.warningText, {\n [classes.topGutter]: !disableGutter,\n [classes.hideText]: hideText,\n })}\n role=\"status\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n {...others}\n >\n {showWarning && children}\n </span>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAsCa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,UAAU,WAAW,oBAAoB;AACzC,QAAA,WAAW,gBAAgB,QAAQ;AACnC,QAAA,UAAU,iBAAiB,QAAQ,WAAW;AACpD,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,OAAO;AACxC,QAAA,cAAc,WAAW,CAAC;AAC1B,QAAA,YAAY,iBACf,oBAAA,MAAA,EAAK,MAAK,MAAK,WAAW,QAAQ,aAAa;AAIhD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,IAAI,GAAG;AAAA,UAChB,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,QACxB;AAAA,QACA;AAAA,MACF;AAAA,MAEC,UAAA;AAAA,QAAA,CAAC,oBAAoB;AAAA,QACtB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,WAAW,GAAG,QAAQ,aAAa;AAAA,cACjC,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,cACtB,CAAC,QAAQ,QAAQ,GAAG;AAAA,YAAA,CACrB;AAAA,YACD,MAAK;AAAA,YACL,aAAU;AAAA,YACV,iBAAc;AAAA,YACb,GAAG;AAAA,YAEH,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WarningText.styles.js","sources":["../../../../src/FormElement/WarningText/WarningText.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvWarningText\", {\n root: {\n display: \"none\",\n color: theme.colors.negative_120,\n },\n defaultIcon: { minWidth: \"24px\", width: \"24px\", height: \"24px\" },\n warningText: {\n ...theme.typography.caption1,\n color: \"inherit\",\n paddingRight: theme.space.xs,\n },\n show: { display: \"flex\" },\n topGutter: { paddingTop: \"3px\" },\n hideText: {\n // display none or visibility hidden prevents\n // browser to trigger the aria-alert\n width: 0,\n height: 0,\n padding: 0,\n margin: 0,\n overflow: \"hidden\",\n },\n topBorder: { borderTop: \"1px solid currentcolor\" },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,aAAa,EAAE,UAAU,QAAQ,OAAO,QAAQ,QAAQ,OAAO;AAAA,EAC/D,aAAa;AAAA,IACX,GAAG,MAAM,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,MAAM,EAAE,SAAS,OAAO;AAAA,EACxB,WAAW,EAAE,YAAY,MAAM;AAAA,EAC/B,UAAU;AAAA;AAAA;AAAA,IAGR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,WAAW,EAAE,WAAW,yBAAyB;AACnD,CAAC;"}
@@ -0,0 +1,11 @@
1
+ import { createContext } from "react";
2
+ const HvFormElementContext = createContext(
3
+ {}
4
+ );
5
+ const HvFormElementDescriptorsContext = createContext({});
6
+ const HvFormElementValueContext = createContext(void 0);
7
+ export {
8
+ HvFormElementContext,
9
+ HvFormElementDescriptorsContext,
10
+ HvFormElementValueContext
11
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/FormElement/context.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nimport type { HvFormStatus } from \"./FormElement\";\n\nexport interface HvFormElementContextValue {\n /** id to be applied to the form element root node. */\n id?: string;\n /**\n * Name of the form element.\n *\n * Part of a name/value pair, should be the name property of the underling native input.\n */\n name?: string;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /** Whether the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: boolean;\n}\n\nexport const HvFormElementContext = createContext<HvFormElementContextValue>(\n {},\n);\n\nexport interface HvFormElementDescriptorsContextValue {\n input?: any;\n label?: any;\n descriptors?: any;\n}\n\nexport const HvFormElementDescriptorsContext =\n createContext<HvFormElementDescriptorsContextValue>({});\n\nexport const HvFormElementValueContext = createContext<any>(undefined);\n"],"names":[],"mappings":";AA8BO,MAAM,uBAAuB;AAAA,EAClC,CAAA;AACF;AAQa,MAAA,kCACX,cAAoD,CAAE,CAAA;AAE3C,MAAA,4BAA4B,cAAmB,MAAS;"}
@@ -1,4 +1,4 @@
1
- import React__default from "react";
1
+ import { Children } from "react";
2
2
  const findDescriptors = (children, descriptors = {
3
3
  input: [],
4
4
  label: [],
@@ -8,7 +8,7 @@ const findDescriptors = (children, descriptors = {
8
8
  // TODO: refactor this out
9
9
  HvCalendarHeader: []
10
10
  }) => {
11
- React__default.Children.forEach(children, (child) => {
11
+ Children.forEach(children, (child) => {
12
12
  if (child?.type?.formElementType && child.props?.id) {
13
13
  descriptors[child.type.formElementType]?.push(
14
14
  {
@@ -33,29 +33,39 @@ const getIdReferenceFor = (formElementType, descriptors, filterFor = null) => {
33
33
  };
34
34
  const buildFormElementPropsFromContext = (name, disabled, readOnly, required, context) => {
35
35
  return {
36
- name: name || context?.elementName,
37
- disabled: disabled !== void 0 ? disabled : context?.elementDisabled,
38
- readOnly: readOnly !== void 0 ? readOnly : context?.elementReadOnly,
39
- required: required !== void 0 ? required : context?.elementRequired,
40
- status: context?.elementStatus
36
+ name: name || context?.name,
37
+ disabled: disabled ?? context?.disabled,
38
+ readOnly: readOnly ?? context?.readOnly,
39
+ required: required ?? context?.required,
40
+ status: context?.status
41
41
  };
42
42
  };
43
- const buildAriaPropsFromContext = (props, context, isInvalid, inputId) => {
43
+ const buildAriaPropsFromContext = (props, context, isInvalid2, inputId) => {
44
44
  const arias = {
45
45
  "aria-labelledby": props?.["aria-labelledby"] !== void 0 ? props?.["aria-labelledby"] : getIdReferenceListFor("label", context?.descriptors, inputId),
46
46
  "aria-describedby": props?.["aria-describedby"] !== void 0 ? props?.["aria-describedby"] : getIdReferenceListFor("description", context?.descriptors),
47
47
  "aria-controls": props?.["aria-controls"] !== void 0 ? props?.["aria-controls"] : getIdReferenceListFor("controlled", context?.descriptors)
48
48
  };
49
- if (isInvalid) {
50
- arias["aria-invalid"] = isInvalid;
49
+ if (isInvalid2) {
50
+ arias["aria-invalid"] = isInvalid2;
51
51
  arias["aria-errormessage"] = props?.["aria-errormessage"] !== void 0 ? props?.["aria-errormessage"] : getIdReferenceFor("errormessage", context?.descriptors);
52
52
  }
53
53
  return arias;
54
54
  };
55
+ const validationStates = Object.freeze({
56
+ standBy: "standBy",
57
+ valid: "valid",
58
+ invalid: "invalid"
59
+ });
60
+ const isValid = (state) => state === validationStates.valid;
61
+ const isInvalid = (state) => state === validationStates.invalid;
55
62
  export {
56
63
  buildAriaPropsFromContext,
57
64
  buildFormElementPropsFromContext,
58
65
  findDescriptors,
59
66
  getIdReferenceFor,
60
- getIdReferenceListFor
67
+ getIdReferenceListFor,
68
+ isInvalid,
69
+ isValid,
70
+ validationStates
61
71
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../src/FormElement/utils.ts"],"sourcesContent":["import { Children } from \"react\";\nimport type { InputBaseComponentProps } from \"@mui/material/InputBase\";\n\nimport type {\n HvFormElementContextValue,\n HvFormElementDescriptorsContextValue,\n} from \"./context\";\nimport type { HvFormStatus } from \"./FormElement\";\n\ninterface Descriptor {\n id?: string;\n htmlFor?: string;\n}\n/**\n * Scans the element's children looking for the children IDs that match the different form element types.\n * This function will produce an object that has a key for each provided name\n * Inside each key there will be an array with each id of the found descriptor.\n *\n * @param {Array} children - The children inside the form element to scan.\n * @param {Object} descriptors - Initial descriptors map (used for recursion).\n *\n */\nexport const findDescriptors = (\n children: React.ReactNode,\n descriptors: {\n input: Descriptor[];\n label: Descriptor[];\n description: Descriptor[];\n controlled: Descriptor[];\n errormessage: Descriptor[];\n HvCalendarHeader?: Descriptor[];\n } = {\n input: [],\n label: [],\n description: [],\n controlled: [],\n errormessage: [],\n\n // TODO: refactor this out\n HvCalendarHeader: [],\n },\n) => {\n Children.forEach(children, (child: any) => {\n if (child?.type?.formElementType && child.props?.id) {\n descriptors[child.type.formElementType as keyof typeof descriptors]?.push(\n {\n id: child.props?.id,\n htmlFor: child.props?.htmlFor,\n },\n );\n }\n\n if (child?.type?.formElementType !== \"formelement\") {\n findDescriptors(child?.props?.children, descriptors);\n }\n });\n\n return descriptors;\n};\n\nexport const getIdReferenceListFor = (\n formElementType: string,\n descriptors: any,\n filterFor: string | null = null,\n) => {\n const referenceList = descriptors?.[formElementType]\n ?.filter((d: any) => d.htmlFor !== filterFor)\n ?.map((d: any) => d.id)\n .join(\" \")\n .trim();\n\n return referenceList !== \"\" ? referenceList : undefined;\n};\n\nexport const getIdReferenceFor = (\n formElementType: string,\n descriptors: any,\n filterFor = null,\n) => {\n const referenceList = descriptors?.[formElementType]\n ?.filter((d: any) => d.htmlFor !== filterFor)\n ?.map((d: any) => d.id)?.[0];\n\n return referenceList !== \"\" ? referenceList : undefined;\n};\n\nexport const buildFormElementPropsFromContext = (\n name?: string,\n disabled?: boolean,\n readOnly?: boolean,\n required?: boolean,\n context?: HvFormElementContextValue,\n) => {\n return {\n name: name || context?.name,\n disabled: disabled ?? context?.disabled,\n readOnly: readOnly ?? context?.readOnly,\n required: required ?? context?.required,\n status: context?.status,\n };\n};\n\nexport const buildAriaPropsFromContext = (\n props: InputBaseComponentProps,\n context: HvFormElementDescriptorsContextValue,\n isInvalid: boolean,\n inputId?: string,\n) => {\n const arias: React.AriaAttributes = {\n \"aria-labelledby\":\n props?.[\"aria-labelledby\"] !== undefined\n ? props?.[\"aria-labelledby\"]\n : getIdReferenceListFor(\"label\", context?.descriptors, inputId),\n \"aria-describedby\":\n props?.[\"aria-describedby\"] !== undefined\n ? props?.[\"aria-describedby\"]\n : getIdReferenceListFor(\"description\", context?.descriptors),\n \"aria-controls\":\n props?.[\"aria-controls\"] !== undefined\n ? props?.[\"aria-controls\"]\n : getIdReferenceListFor(\"controlled\", context?.descriptors),\n };\n\n if (isInvalid) {\n arias[\"aria-invalid\"] = isInvalid;\n arias[\"aria-errormessage\"] =\n props?.[\"aria-errormessage\"] !== undefined\n ? props?.[\"aria-errormessage\"]\n : getIdReferenceFor(\"errormessage\", context?.descriptors);\n }\n\n return arias;\n};\n\nexport const validationStates = Object.freeze({\n standBy: \"standBy\",\n valid: \"valid\",\n invalid: \"invalid\",\n});\n\nexport const isValid = (state: HvFormStatus) =>\n state === validationStates.valid;\nexport const isInvalid = (state: HvFormStatus) =>\n state === validationStates.invalid;\n"],"names":["isInvalid"],"mappings":";AAsBa,MAAA,kBAAkB,CAC7B,UACA,cAOI;AAAA,EACF,OAAO,CAAC;AAAA,EACR,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,YAAY,CAAC;AAAA,EACb,cAAc,CAAC;AAAA;AAAA,EAGf,kBAAkB,CAAA;AACpB,MACG;AACM,WAAA,QAAQ,UAAU,CAAC,UAAe;AACzC,QAAI,OAAO,MAAM,mBAAmB,MAAM,OAAO,IAAI;AACvC,kBAAA,MAAM,KAAK,eAA2C,GAAG;AAAA,QACnE;AAAA,UACE,IAAI,MAAM,OAAO;AAAA,UACjB,SAAS,MAAM,OAAO;AAAA,QAAA;AAAA,MAE1B;AAAA,IAAA;AAGE,QAAA,OAAO,MAAM,oBAAoB,eAAe;AAClC,sBAAA,OAAO,OAAO,UAAU,WAAW;AAAA,IAAA;AAAA,EACrD,CACD;AAEM,SAAA;AACT;AAEO,MAAM,wBAAwB,CACnC,iBACA,aACA,YAA2B,SACxB;AACG,QAAA,gBAAgB,cAAc,eAAe,GAC/C,OAAO,CAAC,MAAW,EAAE,YAAY,SAAS,GAC1C,IAAI,CAAC,MAAW,EAAE,EAAE,EACrB,KAAK,GAAG,EACR,KAAK;AAED,SAAA,kBAAkB,KAAK,gBAAgB;AAChD;AAEO,MAAM,oBAAoB,CAC/B,iBACA,aACA,YAAY,SACT;AACH,QAAM,gBAAgB,cAAc,eAAe,GAC/C,OAAO,CAAC,MAAW,EAAE,YAAY,SAAS,GAC1C,IAAI,CAAC,MAAW,EAAE,EAAE,IAAI,CAAC;AAEtB,SAAA,kBAAkB,KAAK,gBAAgB;AAChD;AAEO,MAAM,mCAAmC,CAC9C,MACA,UACA,UACA,UACA,YACG;AACI,SAAA;AAAA,IACL,MAAM,QAAQ,SAAS;AAAA,IACvB,UAAU,YAAY,SAAS;AAAA,IAC/B,UAAU,YAAY,SAAS;AAAA,IAC/B,UAAU,YAAY,SAAS;AAAA,IAC/B,QAAQ,SAAS;AAAA,EACnB;AACF;AAEO,MAAM,4BAA4B,CACvC,OACA,SACAA,YACA,YACG;AACH,QAAM,QAA8B;AAAA,IAClC,mBACE,QAAQ,iBAAiB,MAAM,SAC3B,QAAQ,iBAAiB,IACzB,sBAAsB,SAAS,SAAS,aAAa,OAAO;AAAA,IAClE,oBACE,QAAQ,kBAAkB,MAAM,SAC5B,QAAQ,kBAAkB,IAC1B,sBAAsB,eAAe,SAAS,WAAW;AAAA,IAC/D,iBACE,QAAQ,eAAe,MAAM,SACzB,QAAQ,eAAe,IACvB,sBAAsB,cAAc,SAAS,WAAW;AAAA,EAChE;AAEA,MAAIA,YAAW;AACb,UAAM,cAAc,IAAIA;AACxB,UAAM,mBAAmB,IACvB,QAAQ,mBAAmB,MAAM,SAC7B,QAAQ,mBAAmB,IAC3B,kBAAkB,gBAAgB,SAAS,WAAW;AAAA,EAAA;AAGvD,SAAA;AACT;AAEa,MAAA,mBAAmB,OAAO,OAAO;AAAA,EAC5C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AACX,CAAC;AAEM,MAAM,UAAU,CAAC,UACtB,UAAU,iBAAiB;AACtB,MAAM,YAAY,CAAC,UACxB,UAAU,iBAAiB;"}
@@ -4,7 +4,7 @@ import { useForkRef } from "@mui/material/utils";
4
4
  import { CloseXS, Search, PreviewOff, Preview, Success } from "@hitachivantara/uikit-react-icons";
5
5
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
6
6
  import { DEFAULT_ERROR_MESSAGES, computeValidationType, validateInput, computeValidationState, computeValidationMessage, hasBuiltInValidations } from "../BaseInput/validations.js";
7
- import validationState, { isInvalid, isValid } from "../Forms/FormElement/validationStates.js";
7
+ import { HvSuggestions } from "../FormElement/Suggestions/Suggestions.js";
8
8
  import { useControlled } from "../hooks/useControlled.js";
9
9
  import { useIsMounted } from "../hooks/useIsMounted.js";
10
10
  import { useLabels } from "../hooks/useLabels.js";
@@ -13,14 +13,14 @@ import { isKey } from "../utils/keyboardUtils.js";
13
13
  import { setId } from "../utils/setId.js";
14
14
  import { useClasses } from "./Input.styles.js";
15
15
  import { staticClasses } from "./Input.styles.js";
16
- import { HvAdornment } from "../Forms/Adornment/Adornment.js";
16
+ import { HvAdornment } from "../FormElement/Adornment/Adornment.js";
17
+ import { validationStates, isInvalid, isValid } from "../FormElement/utils.js";
17
18
  import { HvBaseInput } from "../BaseInput/BaseInput.js";
18
- import { HvSuggestions } from "../Forms/Suggestions/Suggestions.js";
19
19
  import { HvTooltip } from "../Tooltip/Tooltip.js";
20
- import { HvFormElement } from "../Forms/FormElement/FormElement.js";
21
- import { HvLabel } from "../Forms/Label/Label.js";
22
- import { HvInfoMessage } from "../Forms/InfoMessage/InfoMessage.js";
23
- import { HvWarningText } from "../Forms/WarningText/WarningText.js";
20
+ import { HvFormElement } from "../FormElement/FormElement.js";
21
+ import { HvLabel } from "../FormElement/Label/Label.js";
22
+ import { HvInfoMessage } from "../FormElement/InfoMessage/InfoMessage.js";
23
+ import { HvWarningText } from "../FormElement/WarningText/WarningText.js";
24
24
  const DEFAULT_LABELS = {
25
25
  /** The label of the clear button. */
26
26
  clearButtonLabel: "Clear the text",
@@ -53,9 +53,9 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
53
53
  name,
54
54
  value: valueProp,
55
55
  defaultValue = "",
56
- required = false,
57
- readOnly = false,
58
- disabled = false,
56
+ required,
57
+ readOnly,
58
+ disabled,
59
59
  enablePortal = false,
60
60
  suggestOnFocus = false,
61
61
  label,
@@ -99,9 +99,9 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
99
99
  const isDirty = useRef(false);
100
100
  const [value, setValue] = useControlled(valueProp, defaultValue);
101
101
  const isEmptyValue = value == null || value === "";
102
- const [validationState$1, setValidationState] = useControlled(
102
+ const [validationState, setValidationState] = useControlled(
103
103
  status,
104
- validationState.standBy
104
+ validationStates.standBy
105
105
  );
106
106
  const [validationMessage, setValidationMessage] = useControlled(
107
107
  statusMessage,
@@ -154,7 +154,7 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
154
154
  validation,
155
155
  inputProps
156
156
  ));
157
- const isStateInvalid = isInvalid(validationState$1);
157
+ const isStateInvalid = isInvalid(validationState);
158
158
  const [revealPassword, setRevealPassword] = useState(false);
159
159
  const realType = useMemo(() => {
160
160
  if (type === "password") {
@@ -212,7 +212,7 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
212
212
  };
213
213
  const onFocusHandler = (event) => {
214
214
  setFocused(true);
215
- setValidationState(validationState.standBy);
215
+ setValidationState(validationStates.standBy);
216
216
  onFocus?.(event, value);
217
217
  };
218
218
  const getSuggestions = (li) => {
@@ -247,12 +247,12 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
247
247
  }
248
248
  };
249
249
  const hasOnEnter = onEnter != null;
250
- const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!hasOnEnter || type !== "search" || disableSearchButton || validationState$1 !== validationState.standBy);
250
+ const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!hasOnEnter || type !== "search" || disableSearchButton || validationState !== validationStates.standBy);
251
251
  const showSearchIcon = type === "search" && !disableSearchButton;
252
252
  const showRevealPasswordButton = type === "password" && !disableRevealPassword;
253
253
  const handleClear = useCallback(
254
254
  (event) => {
255
- setValidationState(validationState.standBy);
255
+ setValidationState(validationStates.standBy);
256
256
  changeInputValue(inputRef.current, "");
257
257
  if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
258
258
  else {
@@ -294,7 +294,7 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
294
294
  [onEnter, value]
295
295
  );
296
296
  const searchButton = useMemo(() => {
297
- const reallyShowIt = showSearchIcon && (isEmptyValue || hasOnEnter && validationState$1 === validationState.standBy);
297
+ const reallyShowIt = showSearchIcon && (isEmptyValue || hasOnEnter && validationState === validationStates.standBy);
298
298
  if (!reallyShowIt) {
299
299
  return null;
300
300
  }
@@ -311,7 +311,7 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
311
311
  showSearchIcon,
312
312
  isEmptyValue,
313
313
  hasOnEnter,
314
- validationState$1,
314
+ validationState,
315
315
  classes.adornmentButton,
316
316
  handleSearch,
317
317
  labels?.searchButtonLabel
@@ -355,11 +355,11 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
355
355
  if (!showValidationIcon) {
356
356
  return null;
357
357
  }
358
- if (!isValid(validationState$1)) {
358
+ if (!isValid(validationState)) {
359
359
  return null;
360
360
  }
361
361
  return /* @__PURE__ */ jsx(Success, { color: "positive", className: classes.icon });
362
- }, [showValidationIcon, validationState$1, classes.icon]);
362
+ }, [showValidationIcon, validationState, classes.icon]);
363
363
  const customIconEl = useMemo(
364
364
  () => isValidElement(endAdornment) && cloneElement(endAdornment, {
365
365
  className: cx(endAdornment.props.className, classes.icon)
@@ -395,7 +395,7 @@ const HvInput = forwardRef(function HvInput2(props, ref) {
395
395
  {
396
396
  id,
397
397
  name,
398
- status: validationState$1,
398
+ status: validationState,
399
399
  disabled,
400
400
  required,
401
401
  readOnly,