@hitachivantara/uikit-react-core 5.30.1 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/cjs/components/ActionBar/ActionBar.styles.cjs +1 -1
  2. package/dist/cjs/components/ActionBar/ActionBar.styles.cjs.map +1 -1
  3. package/dist/cjs/components/BaseCheckBox/BaseCheckBox.cjs +4 -4
  4. package/dist/cjs/components/BaseCheckBox/BaseCheckBox.cjs.map +1 -1
  5. package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs +3 -2
  6. package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs.map +1 -1
  7. package/dist/cjs/components/BaseRadio/BaseRadio.cjs +3 -3
  8. package/dist/cjs/components/BaseRadio/BaseRadio.cjs.map +1 -1
  9. package/dist/cjs/components/BaseSwitch/BaseSwitch.cjs +3 -3
  10. package/dist/cjs/components/BaseSwitch/BaseSwitch.cjs.map +1 -1
  11. package/dist/cjs/components/BreadCrumb/BreadCrumb.cjs +1 -1
  12. package/dist/cjs/components/BreadCrumb/BreadCrumb.cjs.map +1 -1
  13. package/dist/cjs/components/BreadCrumb/Page/Page.cjs +10 -8
  14. package/dist/cjs/components/BreadCrumb/Page/Page.cjs.map +1 -1
  15. package/dist/cjs/components/BreadCrumb/Page/Page.styles.cjs +3 -3
  16. package/dist/cjs/components/BreadCrumb/Page/Page.styles.cjs.map +1 -1
  17. package/dist/cjs/components/CheckBox/CheckBox.cjs +3 -3
  18. package/dist/cjs/components/CheckBox/CheckBox.cjs.map +1 -1
  19. package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs +3 -3
  20. package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs.map +1 -1
  21. package/dist/cjs/components/ColorPicker/ColorPicker.cjs +4 -3
  22. package/dist/cjs/components/ColorPicker/ColorPicker.cjs.map +1 -1
  23. package/dist/cjs/components/DatePicker/DatePicker.cjs +12 -6
  24. package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
  25. package/dist/cjs/components/Dropdown/Dropdown.cjs +12 -4
  26. package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
  27. package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs +3 -3
  28. package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs.map +1 -1
  29. package/dist/cjs/components/FilterGroup/FilterGroup.cjs +4 -3
  30. package/dist/cjs/components/FilterGroup/FilterGroup.cjs.map +1 -1
  31. package/dist/cjs/components/Header/Navigation/MenuItem/MenuItem.cjs +12 -1
  32. package/dist/cjs/components/Header/Navigation/MenuItem/MenuItem.cjs.map +1 -1
  33. package/dist/cjs/components/InlineEditor/InlineEditor.cjs +3 -2
  34. package/dist/cjs/components/InlineEditor/InlineEditor.cjs.map +1 -1
  35. package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs +2 -2
  36. package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs.map +1 -1
  37. package/dist/cjs/components/List/List.cjs.map +1 -1
  38. package/dist/cjs/components/ListContainer/ListContainer.cjs +2 -2
  39. package/dist/cjs/components/ListContainer/ListContainer.cjs.map +1 -1
  40. package/dist/cjs/components/QueryBuilder/Context.cjs.map +1 -1
  41. package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs.map +1 -1
  42. package/dist/cjs/components/Radio/Radio.cjs +3 -3
  43. package/dist/cjs/components/Radio/Radio.cjs.map +1 -1
  44. package/dist/cjs/components/RadioGroup/RadioGroup.cjs +3 -3
  45. package/dist/cjs/components/RadioGroup/RadioGroup.cjs.map +1 -1
  46. package/dist/cjs/components/Section/Section.cjs +50 -0
  47. package/dist/cjs/components/Section/Section.cjs.map +1 -0
  48. package/dist/cjs/components/Section/Section.styles.cjs +40 -0
  49. package/dist/cjs/components/Section/Section.styles.cjs.map +1 -0
  50. package/dist/cjs/components/SelectionList/SelectionList.cjs +7 -5
  51. package/dist/cjs/components/SelectionList/SelectionList.cjs.map +1 -1
  52. package/dist/cjs/components/Slider/Slider.cjs +5 -5
  53. package/dist/cjs/components/Slider/Slider.cjs.map +1 -1
  54. package/dist/cjs/components/Switch/Switch.cjs +3 -3
  55. package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
  56. package/dist/cjs/components/TagsInput/TagsInput.cjs +5 -3
  57. package/dist/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
  58. package/dist/cjs/components/TimePicker/TimePicker.cjs +14 -8
  59. package/dist/cjs/components/TimePicker/TimePicker.cjs.map +1 -1
  60. package/dist/cjs/index.cjs +8 -0
  61. package/dist/cjs/index.cjs.map +1 -1
  62. package/dist/esm/components/ActionBar/ActionBar.styles.js +1 -1
  63. package/dist/esm/components/ActionBar/ActionBar.styles.js.map +1 -1
  64. package/dist/esm/components/BaseCheckBox/BaseCheckBox.js +5 -5
  65. package/dist/esm/components/BaseCheckBox/BaseCheckBox.js.map +1 -1
  66. package/dist/esm/components/BaseDropdown/BaseDropdown.js +4 -3
  67. package/dist/esm/components/BaseDropdown/BaseDropdown.js.map +1 -1
  68. package/dist/esm/components/BaseRadio/BaseRadio.js +4 -4
  69. package/dist/esm/components/BaseRadio/BaseRadio.js.map +1 -1
  70. package/dist/esm/components/BaseSwitch/BaseSwitch.js +4 -4
  71. package/dist/esm/components/BaseSwitch/BaseSwitch.js.map +1 -1
  72. package/dist/esm/components/BreadCrumb/BreadCrumb.js +2 -2
  73. package/dist/esm/components/BreadCrumb/BreadCrumb.js.map +1 -1
  74. package/dist/esm/components/BreadCrumb/Page/Page.js +10 -8
  75. package/dist/esm/components/BreadCrumb/Page/Page.js.map +1 -1
  76. package/dist/esm/components/BreadCrumb/Page/Page.styles.js +3 -3
  77. package/dist/esm/components/BreadCrumb/Page/Page.styles.js.map +1 -1
  78. package/dist/esm/components/CheckBox/CheckBox.js +4 -4
  79. package/dist/esm/components/CheckBox/CheckBox.js.map +1 -1
  80. package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js +4 -4
  81. package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
  82. package/dist/esm/components/ColorPicker/ColorPicker.js +4 -3
  83. package/dist/esm/components/ColorPicker/ColorPicker.js.map +1 -1
  84. package/dist/esm/components/DatePicker/DatePicker.js +13 -7
  85. package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
  86. package/dist/esm/components/Dropdown/Dropdown.js +13 -5
  87. package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
  88. package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js +4 -4
  89. package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js.map +1 -1
  90. package/dist/esm/components/FilterGroup/FilterGroup.js +4 -3
  91. package/dist/esm/components/FilterGroup/FilterGroup.js.map +1 -1
  92. package/dist/esm/components/Header/Navigation/MenuItem/MenuItem.js +12 -1
  93. package/dist/esm/components/Header/Navigation/MenuItem/MenuItem.js.map +1 -1
  94. package/dist/esm/components/InlineEditor/InlineEditor.js +3 -2
  95. package/dist/esm/components/InlineEditor/InlineEditor.js.map +1 -1
  96. package/dist/esm/components/InlineEditor/InlineEditor.styles.js +2 -2
  97. package/dist/esm/components/InlineEditor/InlineEditor.styles.js.map +1 -1
  98. package/dist/esm/components/List/List.js.map +1 -1
  99. package/dist/esm/components/ListContainer/ListContainer.js +2 -2
  100. package/dist/esm/components/ListContainer/ListContainer.js.map +1 -1
  101. package/dist/esm/components/QueryBuilder/Context.js.map +1 -1
  102. package/dist/esm/components/QueryBuilder/QueryBuilder.js.map +1 -1
  103. package/dist/esm/components/Radio/Radio.js +4 -4
  104. package/dist/esm/components/Radio/Radio.js.map +1 -1
  105. package/dist/esm/components/RadioGroup/RadioGroup.js +4 -4
  106. package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
  107. package/dist/esm/components/Section/Section.js +51 -0
  108. package/dist/esm/components/Section/Section.js.map +1 -0
  109. package/dist/esm/components/Section/Section.styles.js +40 -0
  110. package/dist/esm/components/Section/Section.styles.js.map +1 -0
  111. package/dist/esm/components/SelectionList/SelectionList.js +8 -6
  112. package/dist/esm/components/SelectionList/SelectionList.js.map +1 -1
  113. package/dist/esm/components/Slider/Slider.js +5 -5
  114. package/dist/esm/components/Slider/Slider.js.map +1 -1
  115. package/dist/esm/components/Switch/Switch.js +4 -4
  116. package/dist/esm/components/Switch/Switch.js.map +1 -1
  117. package/dist/esm/components/TagsInput/TagsInput.js +6 -4
  118. package/dist/esm/components/TagsInput/TagsInput.js.map +1 -1
  119. package/dist/esm/components/TimePicker/TimePicker.js +15 -9
  120. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  121. package/dist/esm/index.js +8 -0
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/types/index.d.ts +398 -187
  124. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.cjs","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvDropdownStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: HvBaseDropdownProps;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = (props: HvDropdownProps) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (virtualized && !height && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null ? [...containerRef.getElementsByTagName(\"li\")] : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\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 isStateInvalid = isInvalid(validationState);\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={dropdownHeaderRef}\n {...baseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\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":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","props","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","process","env","NODE_ENV","console","error","dropdownHeaderRef","useRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","jsx","HvTypography","selectionDisabled","placeholderClosed","jsxs","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","HvFormElement","root","labelContainer","HvLabel","HvInfoMessage","HvBaseDropdown","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","HvDropdownList","rootList","dropdownListContainer","HvWarningText"],"mappings":";;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKaC,MAAAA,aAAaA,CAACC,UAA2B;AAC9C,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IAEpBC,cAAc;AAAA,IAEdC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,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AAqBC,mBACrB,MAAK,YACL,eACA,cAAY/E,WACZ,mBACE,CAACD,SAASqG,MAAAA,MAAM9D,WAAW,OAAO,GAAGrC,cAAc,EAChDiH,KAAK,GAAG,EACRC,KAAK,KAAKpI,QAEf,gBAAckH,iBAAiB,OAAOlH,QACtC,qBAAmBoH,gBACnB,oBACE,CAACjG,eAAekG,MAAM9D,MAAAA,WAAW,aAAa,GAAGnC,eAAe,EAC7D+G,KAAK,GAAG,EACRC,KAAK,KAAKpI,QAEf,SACA,QACA,mBACA,GAAIgD,mBAEJ,UAAAyD,2BAAAA,IAAC4B,KAAAA,kBACC,IAAIhB,MAAAA,MAAM9D,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACP+E,UAAU9H,QAAQ8H;AAAAA,MAClBC,uBAAuB/H,QAAQ+H;AAAAA,IACjC,GACA,QAAQnE,gBACR,aACA,YACA,UAAUgB,iBACV,UAAUS,cACV,QACA,4BACA,aACA,uBACA,cAAY5E,WACZ,mBAAiB8F,WAAWM,MAAAA,MAAM9D,WAAW,OAAO,IAAIvD,QACxD,QACA,WACA,aACIiD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACCgE,gBACCR,2BAAA,IAAC+B,YACC,eAAA,EAAA,IAAInB,MAAAA,MAAM9D,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQmE,OAElBf,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"Dropdown.cjs","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvDropdownStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (virtualized && !height && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\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 isStateInvalid = isInvalid(validationState);\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","process","env","NODE_ENV","console","error","dropdownHeaderRef","useRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","jsx","HvTypography","selectionDisabled","placeholderClosed","jsxs","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","HvFormElement","root","labelContainer","HvLabel","HvInfoMessage","HvBaseDropdown","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","HvDropdownList","rootList","dropdownListContainer","HvWarningText"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKO,MAAMC,aAAaC,MAAAA,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IAEpBC,cAAc;AAAA,IAEdC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,6BAA6B;AAAA,IAC7BC,QAAQC;AAAAA,IACRC,cAAc;AAAA,IACdC,gBAAgB;AAAA,IAChBC,wBAAwB;AAAA,IACxBC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC,cAAc,CAAC;AAAA,IACfC;AAAAA,IACAC;AAAAA,IACAC,cAAc;AAAA,IACdC,oBAAoB,CAAC;AAAA,IACrBC,YAAY,CAAC;AAAA,IACb,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,cAAc7C,KAAK;AAEjC,QAAA;AAAA,IAAEE;AAAAA,IAAS4C;AAAAA,EAAAA,IAAO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AAA,MAAMpE,WAAW,aAAa,GAAGnC,eAAe,EAC7DqH,KAAK,GAAG,EACRC,KAAAA,KAAU5I,QAEf,SACA,QACA,mBAAmBmF,iBACnB,GAAID,wBAEJ,UAAA+B,2BAAAA,IAAC4B,KAAAA,kBACC,IAAIhB,MAAAA,MAAMpE,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACPqF,UAAUpI,QAAQoI;AAAAA,MAClBC,uBAAuBrI,QAAQqI;AAAAA,IACjC,GACA,QAAQzE,gBACR,aACA,YACA,UAAUsB,iBACV,UAAUS,cACV,QACA,4BACA,aACA,uBACA,cAAYlF,WACZ,mBAAiBoG,WAAWM,MAAAA,MAAMpE,WAAW,OAAO,IAAIzD,QACxD,QACA,WACA,aACImD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACCsE,gBACCR,2BAAA,IAAC+B,YACC,eAAA,EAAA,IAAInB,MAAAA,MAAMpE,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQmE,OAElBf,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;;;"}
@@ -15,7 +15,7 @@ const Typography = require("../../Typography/Typography.cjs");
15
15
  const BaseDropdown = require("../../BaseDropdown/BaseDropdown.cjs");
16
16
  const Counter = require("../Counter/Counter.cjs");
17
17
  const ActionBar = require("../../ActionBar/ActionBar.cjs");
18
- const HvFilterGroupContent = (props) => {
18
+ const HvFilterGroupContent = React.forwardRef((props, ref) => {
19
19
  const {
20
20
  id,
21
21
  status,
@@ -82,7 +82,7 @@ const HvFilterGroupContent = (props) => {
82
82
  /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Filters, {}),
83
83
  /* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, { variant: "label", children: labels == null ? void 0 : labels.placeholder })
84
84
  ] }), [labels == null ? void 0 : labels.placeholder]);
85
- return /* @__PURE__ */ jsxRuntime.jsxs(BaseDropdown.HvBaseDropdown, { id: setId.setId(id, "dropdown"), role: "combobox", classes: {
85
+ return /* @__PURE__ */ jsxRuntime.jsxs(BaseDropdown.HvBaseDropdown, { ref, id: setId.setId(id, "dropdown"), role: "combobox", classes: {
86
86
  root: classes.dropdown,
87
87
  panel: classes.panel,
88
88
  selection: classes.baseDropdownSelection,
@@ -107,7 +107,7 @@ const HvFilterGroupContent = (props) => {
107
107
  /* @__PURE__ */ jsxRuntime.jsx(Button.HvButton, { id: setId.setId(id, "cancel-button"), variant: activeTheme == null ? void 0 : activeTheme.filterGroup.cancelButtonVariant, onClick: onCancelHandler, children: labels == null ? void 0 : labels.cancelLabel })
108
108
  ] })
109
109
  ] });
110
- };
110
+ });
111
111
  exports.filterGroupContentClasses = FilterContent_styles.staticClasses;
112
112
  exports.HvFilterGroupContent = HvFilterGroupContent;
113
113
  //# sourceMappingURL=FilterContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterContent.cjs","sources":["../../../../../src/components/FilterGroup/FilterContent/FilterContent.tsx"],"sourcesContent":["import { useContext, useMemo, useRef, useState } from \"react\";\n\nimport { Filters } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { HvActionBar } from \"@core/components/ActionBar\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvButton, HvButtonVariant } from \"@core/components/Button\";\nimport { HvFormStatus } from \"@core/components/Forms\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { useDefaultProps } from \"@core/hooks\";\nimport {\n HvFilterGroupLabels,\n HvFilterGroupValue,\n HvFilterGroupHorizontalPlacement,\n} from \"../types\";\nimport { staticClasses, useClasses } from \"./FilterContent.styles\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { HvFilterGroupLeftPanel } from \"../LeftPanel\";\nimport { HvFilterGroupRightPanel } from \"../RightPanel\";\n\nexport { staticClasses as filterGroupContentClasses };\n\nexport type HvFilterGroupContentClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupContentProps\n extends Omit<HvBaseDropdownProps, \"onChange\"> {\n description?: React.ReactNode;\n status?: HvFormStatus;\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n labels?: HvFilterGroupLabels;\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n disablePortal?: boolean;\n escapeWithReference?: boolean;\n height?: string | number;\n leftEmptyElement?: React.ReactNode;\n rightEmptyElement?: React.ReactNode;\n disabled?: boolean;\n classes?: HvFilterGroupContentClasses;\n}\n\nexport const HvFilterGroupContent = (props: HvFilterGroupContentProps) => {\n const {\n id,\n status,\n disabled = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n labels,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height,\n leftEmptyElement,\n rightEmptyElement,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvFilterGroupContent\", props);\n const { classes } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const [filterGroupOpen, setFilterGroupOpen] = useState<boolean>(false);\n\n const {\n defaultValue,\n filterValues,\n rollbackFilters,\n clearFilters,\n applyFilters,\n applyDisabled,\n } = useContext(HvFilterGroupContext);\n\n const focusTarget = useRef<HTMLDivElement>(null);\n\n const focusOnContainer = () => {\n focusTarget.current?.focus();\n };\n\n const onApplyHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n applyFilters();\n onChange?.(event, filterValues);\n setFilterGroupOpen(false);\n };\n\n const onCancelHandler = (\n event: React.MouseEvent<HTMLButtonElement> | Event\n ) => {\n rollbackFilters();\n onCancel?.(event);\n setFilterGroupOpen(false);\n };\n\n const onClearHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n clearFilters();\n onClear?.(event);\n };\n\n const handleToggle = (event: Event, open: boolean) => {\n /* \n If evt is null this toggle wasn't triggered by the user.\n instead it was triggered by the baseDropdown useEffect after\n the datepicker changed the expanded value this baseDropdown behavior needs a review\n */\n if (event === null) return;\n setFilterGroupOpen(open);\n if (!open) onCancelHandler?.(event);\n };\n\n const Header = useMemo(\n () => (\n <>\n <Filters />\n <HvTypography variant=\"label\">{labels?.placeholder}</HvTypography>\n </>\n ),\n [labels?.placeholder]\n );\n\n return (\n <HvBaseDropdown\n id={setId(id, \"dropdown\")}\n role=\"combobox\"\n classes={{\n root: classes.dropdown,\n panel: classes.panel,\n selection: classes.baseDropdownSelection,\n header: classes.header,\n }}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n expanded={filterGroupOpen}\n onToggle={handleToggle}\n onClickOutside={onCancelHandler}\n onContainerCreation={focusOnContainer}\n placeholder={Header}\n adornment={<HvFilterGroupCounter />}\n popperProps={{\n modifiers: [{ name: \"preventOverflow\", enabled: escapeWithReference }],\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={status === \"invalid\" ? setId(id, \"error\") : undefined}\n aria-describedby={\n [description && setId(id, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n {...others}\n >\n <div ref={focusTarget} tabIndex={-1} />\n <div className={classes.root} style={{ height }}>\n <HvFilterGroupLeftPanel\n id={id}\n className={classes.leftSidePanel}\n emptyElement={leftEmptyElement}\n />\n <HvFilterGroupRightPanel\n id={id}\n className={classes.rightSidePanel}\n emptyElement={rightEmptyElement}\n labels={labels}\n />\n </div>\n <HvActionBar className={classes.actionBar}>\n <HvButton\n id={setId(id, \"clearFilters-button\")}\n disabled={\n defaultValue\n ? defaultValue?.flat().length === filterValues?.flat().length\n : filterValues?.flat().length === 0\n }\n variant=\"secondaryGhost\"\n onClick={onClearHandler}\n >\n {labels?.clearLabel}\n </HvButton>\n <div aria-hidden=\"true\" className={classes.space}>\n &nbsp;\n </div>\n <HvButton\n id={setId(id, \"apply-button\")}\n disabled={applyDisabled}\n variant={\n activeTheme?.filterGroup.applyButtonVariant as HvButtonVariant\n }\n onClick={onApplyHandler}\n className={classes.applyButton}\n >\n {labels?.applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"cancel-button\")}\n variant={\n activeTheme?.filterGroup.cancelButtonVariant as HvButtonVariant\n }\n onClick={onCancelHandler}\n >\n {labels?.cancelLabel}\n </HvButton>\n </HvActionBar>\n </HvBaseDropdown>\n );\n};\n"],"names":["HvFilterGroupContent","props","id","status","disabled","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","labels","horizontalPlacement","disablePortal","escapeWithReference","height","leftEmptyElement","rightEmptyElement","classes","classesProp","others","useDefaultProps","useClasses","activeTheme","useTheme","filterGroupOpen","setFilterGroupOpen","useState","defaultValue","filterValues","rollbackFilters","clearFilters","applyFilters","applyDisabled","useContext","HvFilterGroupContext","focusTarget","useRef","focusOnContainer","current","focus","onApplyHandler","event","onCancelHandler","onClearHandler","handleToggle","open","Header","useMemo","jsxs","Fragment","jsx","Filters","HvTypography","placeholder","HvBaseDropdown","setId","root","dropdown","panel","selection","baseDropdownSelection","header","HvFilterGroupCounter","modifiers","name","enabled","undefined","join","trim","HvFilterGroupLeftPanel","leftSidePanel","HvFilterGroupRightPanel","rightSidePanel","HvActionBar","actionBar","HvButton","flat","length","clearLabel","space","filterGroup","applyButtonVariant","applyButton","applyLabel","cancelButtonVariant","cancelLabel"],"mappings":";;;;;;;;;;;;;;;;;AAqDaA,MAAAA,uBAAuBA,CAACC,UAAqC;AAClE,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACX,cAAcC;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CmC,+BAACqB,WAAAA,2BACC,IACA,WAAWtD,QAAQuD,gBACnB,cAAcxD,mBACd,QAAe;AAAA,IAAA,GAEnB;AAAA,IACCgC,2BAAA,KAAAyB,UAAA,aAAA,EAAY,WAAWxD,QAAQyD,WAC9B,UAAA;AAAA,MAACxB,2BAAAA,IAAAyB,OAAAA,UAAA,EACC,IAAIpB,MAAAA,MAAMvD,IAAI,qBAAqB,GACnC,UACE2B,gBACIA,6CAAciD,OAAOC,aAAWjD,6CAAcgD,OAAOC,WACrDjD,6CAAcgD,OAAOC,YAAW,GAEtC,SAAQ,kBACR,SAASlC,gBAERjC,UAAAA,iCAAQoE,WACX,CAAA;AAAA,qCACC,OAAI,EAAA,eAAY,QAAO,WAAW7D,QAAQ8D,OAAM,UAEjD,KAAA;AAAA,qCACCJ,OAAAA,UACC,EAAA,IAAIpB,YAAMvD,IAAI,cAAc,GAC5B,UAAUgC,eACV,SACEV,2CAAa0D,YAAYC,oBAE3B,SAASzC,gBACT,WAAWvB,QAAQiE,aAElBxE,2CAAQyE,YACX;AAAA,MACCjC,2BAAA,IAAAyB,OAAA,UAAA,EACC,IAAIpB,MAAAA,MAAMvD,IAAI,eAAe,GAC7B,SACEsB,2CAAa0D,YAAYI,qBAE3B,SAAS1C,iBAERhC,2CAAQ2E,aACX;AAAA,IAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"FilterContent.cjs","sources":["../../../../../src/components/FilterGroup/FilterContent/FilterContent.tsx"],"sourcesContent":["import { forwardRef, useContext, useMemo, useRef, useState } from \"react\";\n\nimport { Filters } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { HvActionBar } from \"@core/components/ActionBar\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvButton, HvButtonVariant } from \"@core/components/Button\";\nimport { HvFormStatus } from \"@core/components/Forms\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { useDefaultProps } from \"@core/hooks\";\nimport {\n HvFilterGroupLabels,\n HvFilterGroupValue,\n HvFilterGroupHorizontalPlacement,\n} from \"../types\";\nimport { staticClasses, useClasses } from \"./FilterContent.styles\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { HvFilterGroupLeftPanel } from \"../LeftPanel\";\nimport { HvFilterGroupRightPanel } from \"../RightPanel\";\n\nexport { staticClasses as filterGroupContentClasses };\n\nexport type HvFilterGroupContentClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupContentProps\n extends Omit<HvBaseDropdownProps, \"onChange\"> {\n description?: React.ReactNode;\n status?: HvFormStatus;\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n labels?: HvFilterGroupLabels;\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n disablePortal?: boolean;\n escapeWithReference?: boolean;\n height?: string | number;\n leftEmptyElement?: React.ReactNode;\n rightEmptyElement?: React.ReactNode;\n disabled?: boolean;\n classes?: HvFilterGroupContentClasses;\n}\n\nexport const HvFilterGroupContent = forwardRef<\n HTMLDivElement,\n HvFilterGroupContentProps\n>((props, ref) => {\n const {\n id,\n status,\n disabled = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n labels,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height,\n leftEmptyElement,\n rightEmptyElement,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvFilterGroupContent\", props);\n\n const { classes } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const [filterGroupOpen, setFilterGroupOpen] = useState<boolean>(false);\n\n const {\n defaultValue,\n filterValues,\n rollbackFilters,\n clearFilters,\n applyFilters,\n applyDisabled,\n } = useContext(HvFilterGroupContext);\n\n const focusTarget = useRef<HTMLDivElement>(null);\n\n const focusOnContainer = () => {\n focusTarget.current?.focus();\n };\n\n const onApplyHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n applyFilters();\n onChange?.(event, filterValues);\n setFilterGroupOpen(false);\n };\n\n const onCancelHandler = (\n event: React.MouseEvent<HTMLButtonElement> | Event\n ) => {\n rollbackFilters();\n onCancel?.(event);\n setFilterGroupOpen(false);\n };\n\n const onClearHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n clearFilters();\n onClear?.(event);\n };\n\n const handleToggle = (event: Event, open: boolean) => {\n /* \n If evt is null this toggle wasn't triggered by the user.\n instead it was triggered by the baseDropdown useEffect after\n the datepicker changed the expanded value this baseDropdown behavior needs a review\n */\n if (event === null) return;\n setFilterGroupOpen(open);\n if (!open) onCancelHandler?.(event);\n };\n\n const Header = useMemo(\n () => (\n <>\n <Filters />\n <HvTypography variant=\"label\">{labels?.placeholder}</HvTypography>\n </>\n ),\n [labels?.placeholder]\n );\n\n return (\n <HvBaseDropdown\n ref={ref}\n id={setId(id, \"dropdown\")}\n role=\"combobox\"\n classes={{\n root: classes.dropdown,\n panel: classes.panel,\n selection: classes.baseDropdownSelection,\n header: classes.header,\n }}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n expanded={filterGroupOpen}\n onToggle={handleToggle}\n onClickOutside={onCancelHandler}\n onContainerCreation={focusOnContainer}\n placeholder={Header}\n adornment={<HvFilterGroupCounter />}\n popperProps={{\n modifiers: [{ name: \"preventOverflow\", enabled: escapeWithReference }],\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={status === \"invalid\" ? setId(id, \"error\") : undefined}\n aria-describedby={\n [description && setId(id, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n {...others}\n >\n <div ref={focusTarget} tabIndex={-1} />\n <div className={classes.root} style={{ height }}>\n <HvFilterGroupLeftPanel\n id={id}\n className={classes.leftSidePanel}\n emptyElement={leftEmptyElement}\n />\n <HvFilterGroupRightPanel\n id={id}\n className={classes.rightSidePanel}\n emptyElement={rightEmptyElement}\n labels={labels}\n />\n </div>\n <HvActionBar className={classes.actionBar}>\n <HvButton\n id={setId(id, \"clearFilters-button\")}\n disabled={\n defaultValue\n ? defaultValue?.flat().length === filterValues?.flat().length\n : filterValues?.flat().length === 0\n }\n variant=\"secondaryGhost\"\n onClick={onClearHandler}\n >\n {labels?.clearLabel}\n </HvButton>\n <div aria-hidden=\"true\" className={classes.space}>\n &nbsp;\n </div>\n <HvButton\n id={setId(id, \"apply-button\")}\n disabled={applyDisabled}\n variant={\n activeTheme?.filterGroup.applyButtonVariant as HvButtonVariant\n }\n onClick={onApplyHandler}\n className={classes.applyButton}\n >\n {labels?.applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"cancel-button\")}\n variant={\n activeTheme?.filterGroup.cancelButtonVariant as HvButtonVariant\n }\n onClick={onCancelHandler}\n >\n {labels?.cancelLabel}\n </HvButton>\n </HvActionBar>\n </HvBaseDropdown>\n );\n});\n"],"names":["HvFilterGroupContent","forwardRef","props","ref","id","status","disabled","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","labels","horizontalPlacement","disablePortal","escapeWithReference","height","leftEmptyElement","rightEmptyElement","classes","classesProp","others","useDefaultProps","useClasses","activeTheme","useTheme","filterGroupOpen","setFilterGroupOpen","useState","defaultValue","filterValues","rollbackFilters","clearFilters","applyFilters","applyDisabled","useContext","HvFilterGroupContext","focusTarget","useRef","focusOnContainer","current","focus","onApplyHandler","event","onCancelHandler","onClearHandler","handleToggle","open","Header","useMemo","jsxs","Fragment","jsx","Filters","HvTypography","placeholder","HvBaseDropdown","setId","root","dropdown","panel","selection","baseDropdownSelection","header","HvFilterGroupCounter","modifiers","name","enabled","undefined","join","trim","HvFilterGroupLeftPanel","leftSidePanel","HvFilterGroupRightPanel","rightSidePanel","HvActionBar","actionBar","HvButton","flat","length","clearLabel","space","filterGroup","applyButtonVariant","applyButton","applyLabel","cancelButtonVariant","cancelLabel"],"mappings":";;;;;;;;;;;;;;;;;AAqDO,MAAMA,uBAAuBC,MAAAA,WAGlC,CAACC,OAAOC,QAAQ;AACV,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACX,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,sBAAsB;AAAA,IACtBC,gBAAgB;AAAA,IAChBC,sBAAsB;AAAA,IACtBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACT,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,wBAAwBtB,KAAK;AAE3C,QAAA;AAAA,IAAEmB;AAAAA,EAAAA,IAAYI,qBAAAA,WAAWH,WAAW;AACpC,QAAA;AAAA,IAAEI;AAAAA,MAAgBC,SAAS,SAAA;AAEjC,QAAM,CAACC,iBAAiBC,kBAAkB,IAAIC,eAAkB,KAAK;AAE/D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,MAAAA,WAAWC,mBAAAA,oBAAoB;AAE7BC,QAAAA,cAAcC,aAAuB,IAAI;AAE/C,QAAMC,mBAAmBA,MAAM;;AAC7BF,sBAAYG,YAAZH,mBAAqBI;AAAAA,EAAM;AAGvBC,QAAAA,iBAAiBA,CAACC,UAA+C;AACxD;AACblC,yCAAWkC,OAAOb;AAClBH,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AA,IAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ,CAAC;;;"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("@emotion/react/jsx-runtime");
4
+ const React = require("react");
4
5
  const useLabels = require("../../hooks/useLabels.cjs");
5
6
  const useUniqueId = require("../../hooks/useUniqueId.cjs");
6
7
  const useControlled = require("../../hooks/useControlled.cjs");
@@ -22,7 +23,7 @@ const DEFAULT_LABELS = {
22
23
  selectAll: "All",
23
24
  multiSelectionConjunction: "/"
24
25
  };
25
- const HvFilterGroup = (props) => {
26
+ const HvFilterGroup = React.forwardRef((props, ref) => {
26
27
  const {
27
28
  className,
28
29
  id,
@@ -67,11 +68,11 @@ const HvFilterGroup = (props) => {
67
68
  hasDescription && /* @__PURE__ */ jsxRuntime.jsx(InfoMessage.HvInfoMessage, { id: setId.setId(elementId, "description"), className: classes.description, children: description })
68
69
  ] }),
69
70
  /* @__PURE__ */ jsxRuntime.jsxs(FilterGroupContext.HvFilterGroupProvider, { defaultValue, value, filters, children: [
70
- /* @__PURE__ */ jsxRuntime.jsx(FilterContent.HvFilterGroupContent, { id: elementId, disabled, disablePortal, variableWidth: true, placement: horizontalPlacement, escapeWithReference, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, status, onChange, onCancel, onClear, labels, height, ...filterContentProps }),
71
+ /* @__PURE__ */ jsxRuntime.jsx(FilterContent.HvFilterGroupContent, { ref, id: elementId, disabled, disablePortal, variableWidth: true, placement: horizontalPlacement, escapeWithReference, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, status, onChange, onCancel, onClear, labels, height, ...filterContentProps }),
71
72
  canShowError && /* @__PURE__ */ jsxRuntime.jsx(WarningText.HvWarningText, { id: setId.setId(elementId, "error"), disableBorder: true, className: classes.error, children: validationMessage })
72
73
  ] })
73
74
  ] });
74
- };
75
+ });
75
76
  exports.filterGroupClasses = FilterGroup_styles.staticClasses;
76
77
  exports.HvFilterGroup = HvFilterGroup;
77
78
  //# sourceMappingURL=FilterGroup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterGroup.cjs","sources":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components/Forms\";\nimport { useLabels } from \"@core/hooks/useLabels\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { staticClasses, useClasses } from \"./FilterGroup.styles\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport {\n HvFilterGroupFilters,\n HvFilterGroupHorizontalPlacement,\n HvFilterGroupLabels,\n HvFilterGroupValue,\n} from \"./types\";\n\nexport { staticClasses as filterGroupClasses };\n\nexport type HvFilterGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = (props: HvFilterGroupProps) => {\n const {\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvFilterGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={cx(classes.root, className)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n );\n};\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","props","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","classesProp","others","useDefaultProps","cx","useClasses","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","jsxs","HvFormElement","root","labelContainer","jsx","HvLabel","setId","HvInfoMessage","HvFilterGroupProvider","HvFilterGroupContent","HvWarningText","error"],"mappings":";;;;;;;;;;;;;;;AAgGA,MAAMA,iBAAsC;AAAA,EAC1CC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,sBAAsB;AAAA,EACtBC,WAAW;AAAA,EACXC,2BAA2B;AAC7B;AAOaC,MAAAA,gBAAgBA,CAACC,UAA8B;AACpD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,QAAQC;AAAAA,IACRC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,sBAAsB;AAAA,IACtBC,gBAAgB;AAAA,IAChBC,sBAAsB;AAAA,IACtBC,SAAS;AAAA,IACTC;AAAAA,IACAC,SAASC;AAAAA,IACT,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,iBAAiB7B,KAAK;AAEpC,QAAA;AAAA,IAAE0B;AAAAA,IAASI;AAAAA,EAAAA,IAAOC,mBAAAA,WAAWJ,WAAW;AAC9C,QAAM,CAACK,iBAAiB,IAAIC,cAAAA,cAAclB,eAAe,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":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components/Forms\";\nimport { useLabels } from \"@core/hooks/useLabels\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { staticClasses, useClasses } from \"./FilterGroup.styles\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport {\n HvFilterGroupFilters,\n HvFilterGroupHorizontalPlacement,\n HvFilterGroupLabels,\n HvFilterGroupValue,\n} from \"./types\";\n\nexport { staticClasses as filterGroupClasses };\n\nexport type HvFilterGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = forwardRef<HTMLDivElement, HvFilterGroupProps>(\n (props, ref) => {\n const {\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvFilterGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={cx(classes.root, className)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n ref={ref}\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","forwardRef","props","ref","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","classesProp","others","useDefaultProps","cx","useClasses","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","jsxs","HvFormElement","root","labelContainer","jsx","HvLabel","setId","HvInfoMessage","HvFilterGroupProvider","HvFilterGroupContent","HvWarningText","error"],"mappings":";;;;;;;;;;;;;;;;AAkGA,MAAMA,iBAAsC;AAAA,EAC1CC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,sBAAsB;AAAA,EACtBC,WAAW;AAAA,EACXC,2BAA2B;AAC7B;AAOO,MAAMC,gBAAgBC,MAAAA,WAC3B,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,QAAQC;AAAAA,IACRC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,sBAAsB;AAAA,IACtBC,gBAAgB;AAAA,IAChBC,sBAAsB;AAAA,IACtBC,SAAS;AAAA,IACTC;AAAAA,IACAC,SAASC;AAAAA,IACT,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,iBAAiB9B,KAAK;AAEpC,QAAA;AAAA,IAAE2B;AAAAA,IAASI;AAAAA,EAAAA,IAAOC,mBAAAA,WAAWJ,WAAW;AAC9C,QAAM,CAACK,iBAAiB,IAAIC,cAAAA,cAAclB,eAAe,UAAU;AAE7DmB,QAAAA,YAAYC,Y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ubar]: !isMenu,
95
95
  [classes.selected]: !!isSelected
96
96
  }, className), children: [
97
- itemHref ? /* @__PURE__ */ jsxRuntime.jsx("a", { className: classes.link, href: itemHref, target: itemTarget, ...itemProps, "aria-current": isCurrent, children: label }) : (
97
+ itemHref ? /* @__PURE__ */ jsxRuntime.jsx(
98
+ "a",
99
+ {
100
+ className: classes.link,
101
+ href: itemHref,
102
+ target: itemTarget,
103
+ ...itemProps,
104
+ "aria-current": isCurrent,
105
+ "aria-label": item.label,
106
+ children: label
107
+ }
108
+ ) : (
98
109
  // keeping this code path for backwards compatibility, but
99
110
  // shouldn't really be used as it's not accessible
100
111
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.button, role: "button", ...itemProps, tabIndex: 0, "aria-current": isCurrent, children: label })
@@ -1 +1 @@
1
- {"version":3,"file":"MenuItem.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { MouseEvent, useContext } from \"react\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\nimport { FocusContext } from \"../utils/FocusContext\";\nimport { SelectionContext } from \"../utils/SelectionContext\";\nimport { useClasses, staticClasses } from \"./MenuItem.styles\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\nimport { Bar } from \"../MenuBar/Bar\";\n\nexport { staticClasses as headerMenuItemClasses };\n\nexport type HvHeaderMenuItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvHeaderMenuItemProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n item: HvHeaderNavigationItemProp;\n type?: string;\n onClick?: (event: MouseEvent, selection: HvHeaderNavigationItemProp) => void;\n levels: number;\n currentLevel: number;\n classes?: HvHeaderMenuItemClasses;\n}\n\n// Traverse the tree of items and return the first href it finds\nconst traverseItem = (node: HvHeaderNavigationItemProp) => {\n let href;\n let target;\n\n if (node?.href) {\n href = node?.href;\n target = node?.target;\n } else if (node?.data != null && node?.data?.length > 0) {\n let i = 0;\n while (href == null && i < node.data.length) {\n const childNavItem = traverseItem(node?.data[i]);\n if (childNavItem?.href != null) {\n href = childNavItem?.href;\n target = childNavItem?.target;\n break;\n }\n\n i += 1;\n }\n }\n\n return { href, target };\n};\n\nexport const HvHeaderMenuItem = (props: HvHeaderMenuItemProps) => {\n const {\n id,\n item,\n type,\n onClick,\n levels,\n currentLevel,\n classes: classesProp,\n className,\n } = useDefaultProps(\"HvHeaderMenuItem\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const selectionPath = useContext(SelectionContext);\n\n const { dispatch } = useContext(FocusContext);\n\n const { data } = item;\n\n const hasSubLevel = data && data.length;\n\n const isMenu = type === \"menu\";\n\n const isSelected = selectionPath?.[isMenu ? 1 : 0] === item.id;\n\n // true: if the item is part of the selection path but is not the current page the user is seeing, i.e has more sub levels\n // page: used when the selected item is actually the current page the user is seeing\n const isCurrent = isSelected ? (hasSubLevel ? true : \"page\") : undefined;\n\n const actionHandler = (event: any) => {\n if (\n event.type === \"click\" ||\n isKey(event, \"Enter\") ||\n isKey(event, \"Space\")\n ) {\n if (event.type === \"click\") {\n event.currentTarget.blur();\n }\n\n onClick?.(event, item);\n }\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n dispatch?.({ type: \"setItemFocused\", itemFocused: event.currentTarget });\n };\n\n const itemProps = {\n onClick: actionHandler,\n onKeyDown: actionHandler,\n onFocus: handleFocus,\n };\n\n const label = (\n <HvTypography\n component=\"span\"\n variant={isSelected ? \"label\" : \"body\"}\n data-text={item.label}\n >\n {item.label}\n </HvTypography>\n );\n\n let itemHref = item?.href;\n let itemTarget = item?.target;\n\n // apps should configure the href even on parent items without content\n // so the fallback logic is theirs, but if not we'll do our best to find a link\n if (item?.href == null) {\n const { href, target } = traverseItem(item);\n itemHref = href;\n itemTarget = target;\n }\n\n return (\n <li\n id={id}\n key={item.label}\n className={cx(\n classes.root,\n {\n [classes.menu]: isMenu,\n [classes.menubar]: !isMenu,\n [classes.selected]: !!isSelected,\n },\n className\n )}\n >\n {itemHref ? (\n <a\n className={classes.link}\n href={itemHref}\n target={itemTarget}\n {...itemProps}\n aria-current={isCurrent}\n >\n {label}\n </a>\n ) : (\n // keeping this code path for backwards compatibility, but\n // shouldn't really be used as it's not accessible\n <div\n className={classes.button}\n role=\"button\"\n {...itemProps}\n tabIndex={0}\n aria-current={isCurrent}\n >\n {label}\n </div>\n )}\n {/* Limits levels to no more than 2. More than that is not expected and not in DS. */}\n {hasSubLevel && currentLevel < levels && currentLevel < 2 && (\n <Bar data={data} type=\"menu\">\n {data.map((itm: HvHeaderNavigationItemProp) => (\n <HvHeaderMenuItem\n key={itm.id}\n item={itm}\n type=\"menu\"\n onClick={onClick}\n levels={levels}\n currentLevel={currentLevel + 1}\n />\n ))}\n </Bar>\n )}\n </li>\n );\n};\n"],"names":["traverseItem","node","href","target","data","length","i","childNavItem","HvHeaderMenuItem","props","id","item","type","onClick","levels","currentLevel","classes","classesProp","className","useDefaultProps","cx","useClasses","selectionPath","useContext","SelectionContext","dispatch","FocusContext","hasSubLevel","isMenu","isSelected","isCurrent","undefined","actionHandler","event","isKey","currentTarget","blur","handleFocus","itemFocused","itemProps","onKeyDown","onFocus","label","jsx","HvTypography","itemHref","itemTarget","root","menu","menubar","selected","link","button","Bar","map","itm"],"mappings":";;;;;;;;;;;AA6BA,MAAMA,eAAeA,CAACC,SAAqC;;AACrDC,MAAAA;AACAC,MAAAA;AAEJ,MAAIF,6BAAMC,MAAM;AACdA,WAAOD,6BAAMC;AACbC,aAASF,6BAAME;AAAAA,EAAAA,YACNF,6BAAMG,SAAQ,UAAQH,kCAAMG,SAANH,mBAAYI,UAAS,GAAG;AACvD,QAAIC,IAAI;AACR,WAAOJ,QAAQ,QAAQI,IAAIL,KAAKG,KAAKC,QAAQ;AAC3C,YAAME,eAAeP,aAAa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EAAA,KA/CGC,KAAK+B,KAiDZ;AAEJ;;;"}
1
+ {"version":3,"file":"MenuItem.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { MouseEvent, useContext } from \"react\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\nimport { FocusContext } from \"../utils/FocusContext\";\nimport { SelectionContext } from \"../utils/SelectionContext\";\nimport { useClasses, staticClasses } from \"./MenuItem.styles\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\nimport { Bar } from \"../MenuBar/Bar\";\n\nexport { staticClasses as headerMenuItemClasses };\n\nexport type HvHeaderMenuItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvHeaderMenuItemProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n item: HvHeaderNavigationItemProp;\n type?: string;\n onClick?: (event: MouseEvent, selection: HvHeaderNavigationItemProp) => void;\n levels: number;\n currentLevel: number;\n classes?: HvHeaderMenuItemClasses;\n}\n\n// Traverse the tree of items and return the first href it finds\nconst traverseItem = (node: HvHeaderNavigationItemProp) => {\n let href;\n let target;\n\n if (node?.href) {\n href = node?.href;\n target = node?.target;\n } else if (node?.data != null && node?.data?.length > 0) {\n let i = 0;\n while (href == null && i < node.data.length) {\n const childNavItem = traverseItem(node?.data[i]);\n if (childNavItem?.href != null) {\n href = childNavItem?.href;\n target = childNavItem?.target;\n break;\n }\n\n i += 1;\n }\n }\n\n return { href, target };\n};\n\nexport const HvHeaderMenuItem = (props: HvHeaderMenuItemProps) => {\n const {\n id,\n item,\n type,\n onClick,\n levels,\n currentLevel,\n classes: classesProp,\n className,\n } = useDefaultProps(\"HvHeaderMenuItem\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const selectionPath = useContext(SelectionContext);\n\n const { dispatch } = useContext(FocusContext);\n\n const { data } = item;\n\n const hasSubLevel = data && data.length;\n\n const isMenu = type === \"menu\";\n\n const isSelected = selectionPath?.[isMenu ? 1 : 0] === item.id;\n\n // true: if the item is part of the selection path but is not the current page the user is seeing, i.e has more sub levels\n // page: used when the selected item is actually the current page the user is seeing\n const isCurrent = isSelected ? (hasSubLevel ? true : \"page\") : undefined;\n\n const actionHandler = (event: any) => {\n if (\n event.type === \"click\" ||\n isKey(event, \"Enter\") ||\n isKey(event, \"Space\")\n ) {\n if (event.type === \"click\") {\n event.currentTarget.blur();\n }\n\n onClick?.(event, item);\n }\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n dispatch?.({ type: \"setItemFocused\", itemFocused: event.currentTarget });\n };\n\n const itemProps = {\n onClick: actionHandler,\n onKeyDown: actionHandler,\n onFocus: handleFocus,\n };\n\n const label = (\n <HvTypography\n component=\"span\"\n variant={isSelected ? \"label\" : \"body\"}\n data-text={item.label}\n >\n {item.label}\n </HvTypography>\n );\n\n let itemHref = item?.href;\n let itemTarget = item?.target;\n\n // apps should configure the href even on parent items without content\n // so the fallback logic is theirs, but if not we'll do our best to find a link\n if (item?.href == null) {\n const { href, target } = traverseItem(item);\n itemHref = href;\n itemTarget = target;\n }\n\n return (\n <li\n id={id}\n key={item.label}\n className={cx(\n classes.root,\n {\n [classes.menu]: isMenu,\n [classes.menubar]: !isMenu,\n [classes.selected]: !!isSelected,\n },\n className\n )}\n >\n {itemHref ? (\n <a\n className={classes.link}\n href={itemHref}\n target={itemTarget}\n {...itemProps}\n aria-current={isCurrent}\n // Fix for a possible bug in playwright where, even though hidden from screen readers and not appearing in the accessibility\n // tree, due to the styling duplication (span::after - using 'data-text'), locators have to double the name.\n aria-label={item.label}\n >\n {label}\n </a>\n ) : (\n // keeping this code path for backwards compatibility, but\n // shouldn't really be used as it's not accessible\n <div\n className={classes.button}\n role=\"button\"\n {...itemProps}\n tabIndex={0}\n aria-current={isCurrent}\n >\n {label}\n </div>\n )}\n {/* Limits levels to no more than 2. More than that is not expected and not in DS. */}\n {hasSubLevel && currentLevel < levels && currentLevel < 2 && (\n <Bar data={data} type=\"menu\">\n {data.map((itm: HvHeaderNavigationItemProp) => (\n <HvHeaderMenuItem\n key={itm.id}\n item={itm}\n type=\"menu\"\n onClick={onClick}\n levels={levels}\n currentLevel={currentLevel + 1}\n />\n ))}\n </Bar>\n )}\n </li>\n );\n};\n"],"names":["traverseItem","node","href","target","data","length","i","childNavItem","HvHeaderMenuItem","props","id","item","type","onClick","levels","currentLevel","classes","classesProp","className","useDefaultProps","cx","useClasses","selectionPath","useContext","SelectionContext","dispatch","FocusContext","hasSubLevel","isMenu","isSelected","isCurrent","undefined","actionHandler","event","isKey","currentTarget","blur","handleFocus","itemFocused","itemProps","onKeyDown","onFocus","label","jsx","HvTypography","itemHref","itemTarget","root","menu","menubar","selected","link","button","Bar","map","itm"],"mappings":";;;;;;;;;;;AA6BA,MAAMA,eAAeA,CAACC,SAAqC;;AACrDC,MAAAA;AACAC,MAAAA;AAEJ,MAAIF,6BAAMC,MAAM;AACdA,WAAOD,6BAAMC;AACbC,aAASF,6BAAME;AAAAA,EAAAA,YACNF,6BAAMG,SAAQ,UAAQH,kCAAMG,SAANH,mBAAYI,UAAS,GAAG;AACvD,QAAIC,IAAI;AACR,WAAOJ,QAAQ,QAAQI,IAAIL,KAAKG,KAAKC,QAAQ;AAC3C,YAAME,eAAeP,aAAaC,6BAAMG,KAAKE,EAAE;AAC3CC,WAAAA,6CAAcL,SAAQ,MAAM;AAC9BA,eAAOK,6CAAcL;AACrBC,iBAASI,6CAAcJ;AACvB;AAAA,MACF;AAEK,WAAA;AAAA,IACP;AAAA,EACF;AAEO,SAAA;AAAA,IAAED;AAAAA,IAAMC;AAAAA,EAAAA;AACjB;AAEaK,MAAAA,mBAAmBA,CAACC,UAAiC;AAC1D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;A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,MAAEA;AAAAA,MAAMC;AAAAA,IAAAA,IAAWH,aAAaW,IAAI;AAC/BT,eAAAA;AACEC,iBAAAA;AAAAA,EACf;AAEA,yCACG,MACC,EAAA,IAEA,WAAWiB,GACTJ,QAAQ+B,MACR;AAAA,IACE,CAAC/B,QAAQgC,IAAI,GAAGpB;AAAAA,IAChB,CAACZ,QAAQiC,OAAO,GAAG,CAACrB;AAAAA,IACpB,CAACZ,QAAQkC,QAAQ,GAAG,CAAC,CAACrB;AAAAA,EAAAA,GAExBX,SACF,GAEC2B,UAAAA;AAAAA,IACC,WAAAF,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW3B,QAAQmC;AAAAA,QACnB,MAAMN;AAAAA,QACN,QAAQC;AAAAA,QACR,GAAIP;AAAAA,QACJ,gBAAcT;AAAAA,QAGd,cAAYnB,KAAK+B;AAAAA,QAEhBA,UAAAA;AAAAA,MAAAA;AAAAA,IACH;AAAA;AAAA;AAAA,MAICC,2BAAA,IAAA,OAAA,EACC,WAAW3B,QAAQoC,QACnB,MAAK,UACDb,GAAAA,WACJ,UAAU,GACV,gBAAcT,WAEbY,UACH,OAAA;AAAA;AAAA,IAGDf,eAAeZ,eAAeD,UAAUC,eAAe,KACtD4B,2BAAA,IAACU,IAAI,KAAA,EAAA,MAAY,MAAK,QACnBjD,UAAKkD,KAAAA,IAAI,CAACC,QACRZ,2BAAA,IAAA,kBAAA,EAEC,MAAMY,KACN,MAAK,QACL,SACA,QACA,cAAcxC,eAAe,EALxBwC,GAAAA,IAAI7C,EAKsB,CAElC,EACH,CAAA;AAAA,EAAA,KAlDGC,KAAK+B,KAoDZ;AAEJ;;;"}
@@ -26,6 +26,7 @@ const HvInlineEditor = (props) => {
26
26
  onKeyDown,
27
27
  buttonProps,
28
28
  typographyProps,
29
+ disabled,
29
30
  ...others
30
31
  } = useDefaultProps.useDefaultProps("HvInlineEditor", props);
31
32
  const {
@@ -71,7 +72,7 @@ const HvInlineEditor = (props) => {
71
72
  setValue(val);
72
73
  onChange == null ? void 0 : onChange(event, val);
73
74
  };
74
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx(classes.root, className), children: editMode ? /* @__PURE__ */ jsxRuntime.jsx(InputComponent, { inputRef, classes: {
75
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx(classes.root, className), children: editMode && !disabled ? /* @__PURE__ */ jsxRuntime.jsx(InputComponent, { inputRef, classes: {
75
76
  root: classes.inputRoot,
76
77
  input: classes.input,
77
78
  inputBorderContainer: classes.inputBorderContainer
@@ -84,7 +85,7 @@ const HvInlineEditor = (props) => {
84
85
  [classes.iconVisible]: showIcon
85
86
  }) }), className: cx(classes.button, {
86
87
  [classes.largeText]: parseInt(lineHeight, 10) >= 28
87
- }), onClick: handleClick, ...buttonProps, children: /* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, { variant, noWrap: true, className: cx(classes.text, {
88
+ }), onClick: handleClick, disabled, ...buttonProps, children: /* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, { variant, noWrap: true, className: cx(classes.text, {
88
89
  [classes.textEmpty]: !value
89
90
  }), ...typographyProps, children: value || placeholder }) }) });
90
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEditor.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { HvButtonProps, HvButton } from \"@core/components/Button\";\nimport {\n HvTypographyVariants,\n HvTypographyProps,\n HvTypography,\n} from \"@core/components/Typography\";\nimport { HvInput, HvInputProps } from \"@core/components/Input\";\n\nimport { staticClasses, useClasses } from \"./InlineEditor.styles\";\n\nexport { staticClasses as inlineEditorClasses };\n\nexport type HvInlineEditorClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvInlineEditorProps\n extends HvBaseProps<HTMLDivElement, \"onBlur\" | \"onChange\"> {\n /** The value of the form element. */\n value?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Component to use as the input. The component \"inherit\" from `HvBaseInput` (such as `HvInput` or `HvTextArea`) */\n component?: React.ElementType;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n}\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = (props: HvInlineEditorProps) => {\n const {\n className,\n classes: classesProp,\n value: valueProp,\n defaultValue,\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n ...others\n } = useDefaultProps(\"HvInlineEditor\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n const { activeTheme } = useTheme();\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur: HvInputProps[\"onBlur\"] = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown: HvInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event as any);\n };\n\n const handleChange: HvInputProps[\"onChange\"] = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <div className={cx(classes.root, className)}>\n {editMode ? (\n <InputComponent\n inputRef={inputRef}\n classes={{\n root: classes.inputRoot,\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n endIcon={\n <Edit\n color=\"secondary_60\"\n role=\"none\"\n className={cx(classes.icon, { [classes.iconVisible]: showIcon })}\n />\n }\n className={cx(classes.button, {\n [classes.largeText]: parseInt(lineHeight as string, 10) >= 28,\n })}\n onClick={handleClick}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={cx(classes.text, { [classes.textEmpty]: !value })}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n </HvButton>\n )}\n </div>\n );\n};\n"],"names":["HvInlineEditor","props","className","classes","classesProp","value","valueProp","defaultValue","showIcon","component","InputComponent","HvInput","variant","placeholder","onBlur","onChange","onKeyDown","buttonProps","typographyProps","others","useDefaultProps","cx","useClasses","setValue","useControlled","editMode","setEditMode","useState","cachedValue","setCachedValue","inputRef","useRef","activeTheme","useTheme","typographyStyles","typography","lineHeight","useLayoutEffect","input","current","focus","select","handleClick","handleBlur","event","newValue","handleKeyDown","isKey","handleChange","val","jsx","root","inputRoot","inputBorderContainer","style","height","undefined","HvButton","Edit","icon","iconVisible","button","largeText","parseInt","HvTypography","text","textEmpty"],"mappings":";;;;;;;;;;;;;AAqDaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC,OAAOC;AAAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC,WAAWC,iBAAiBC,MAAAA;AAAAA,IAC5BC,UAAU;AAAA,IACVC,cAAc;AAAA,IACdC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,kBAAkBnB,KAAK;AAErC,QAAA;AAAA,IAAEE;AAAAA,IAASkB;AAAAA,EAAAA,IAAOC,oBAAAA,WAAWlB,WAAW;AAC9C,QAAM,CAACC,OAAOkB,QAAQ,IAAIC,cAAAA,cAAclB,WAAWC,YAAY;AAC/D,QAAM,CAACkB,UAAUC,WAAW,IAAIC,eAAS,KAAK;AAC9C,QAAM,CAACC,aAAaC,cAAc,IAAIF,eAAStB,KAAK;AACpD,QAAMyB,WAAWC,MAAAA;AACX,QAAA;AAAA,IAAEC;AAAAA,MAAgBC,SAAS,SAAA;AAEjC,QAAMC,oBAAmBF,2CAAaG,WAAWvB,aAAY,CAAA;AACvD,QAAA;AAAA,IAAEwB;AAAAA,EAAeF,IAAAA;AAEvBG,QAAAA,gBAAgB,MAAM;AACpB,UAAMC,QAAQR,SAASS;AACvB,QAAId,YAAYa,OAAO;AACrBA,YAAME,MAAM;AACZF,YAAMG,OAAO;AAAA,IACf;AAAA,EAAA,GACC,CAAChB,QAAQ,CAAC;AAEb,QAAMiB,cAAcA,MAAM;AACxBhB,gBAAY,IAAI;AAChBG,mBAAexB,KAAK;AAAA,EAAA;AAGtB,QAAMsC,aAAsCC,CAAU,UAAA;AACpDlB,gBAAY,KAAK;AAEjB,UAAMmB,WAAWxC,SAASuB;AAC1BL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GlB,QAAQ8D,MAAM;AAAA,IAAE,CAAC9D,QAAQ+D,SAAS,GAAG,CAAC7D;AAAAA,EAAAA,CAAO,GAC3D,GAAIa,iBAEHb,UAASQ,SAAAA,aACZ,GACF,EAEJ,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"InlineEditor.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { HvButtonProps, HvButton } from \"@core/components/Button\";\nimport {\n HvTypographyVariants,\n HvTypographyProps,\n HvTypography,\n} from \"@core/components/Typography\";\nimport { HvInput, HvInputProps } from \"@core/components/Input\";\n\nimport { staticClasses, useClasses } from \"./InlineEditor.styles\";\n\nexport { staticClasses as inlineEditorClasses };\n\nexport type HvInlineEditorClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvInlineEditorProps\n extends HvBaseProps<HTMLDivElement, \"onBlur\" | \"onChange\"> {\n /** The value of the form element. */\n value?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Component to use as the input. The component \"inherit\" from `HvBaseInput` (such as `HvInput` or `HvTextArea`) */\n component?: React.ElementType;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** Whether the editor is disabled or not. */\n disabled?: boolean;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n}\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = (props: HvInlineEditorProps) => {\n const {\n className,\n classes: classesProp,\n value: valueProp,\n defaultValue,\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n disabled,\n ...others\n } = useDefaultProps(\"HvInlineEditor\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n const { activeTheme } = useTheme();\n\n const typographyStyles = activeTheme?.typography[variant] || {};\n const { lineHeight } = typographyStyles;\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur: HvInputProps[\"onBlur\"] = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown: HvInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event as any);\n };\n\n const handleChange: HvInputProps[\"onChange\"] = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <div className={cx(classes.root, className)}>\n {editMode && !disabled ? (\n <InputComponent\n inputRef={inputRef}\n classes={{\n root: classes.inputRoot,\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n endIcon={\n <Edit\n color=\"secondary_60\"\n role=\"none\"\n className={cx(classes.icon, {\n [classes.iconVisible]: showIcon,\n })}\n />\n }\n className={cx(classes.button, {\n [classes.largeText]: parseInt(lineHeight as string, 10) >= 28,\n })}\n onClick={handleClick}\n disabled={disabled}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={cx(classes.text, { [classes.textEmpty]: !value })}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n </HvButton>\n )}\n </div>\n );\n};\n"],"names":["HvInlineEditor","props","className","classes","classesProp","value","valueProp","defaultValue","showIcon","component","InputComponent","HvInput","variant","placeholder","onBlur","onChange","onKeyDown","buttonProps","typographyProps","disabled","others","useDefaultProps","cx","useClasses","setValue","useControlled","editMode","setEditMode","useState","cachedValue","setCachedValue","inputRef","useRef","activeTheme","useTheme","typographyStyles","typography","lineHeight","useLayoutEffect","input","current","focus","select","handleClick","handleBlur","event","newValue","handleKeyDown","isKey","handleChange","val","jsx","root","inputRoot","inputBorderContainer","style","height","undefined","HvButton","Edit","icon","iconVisible","button","largeText","parseInt","HvTypography","text","textEmpty"],"mappings":";;;;;;;;;;;;;AAuDaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC,OAAOC;AAAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC,WAAWC,iBAAiBC,MAAAA;AAAAA,IAC5BC,UAAU;AAAA,IACVC,cAAc;AAAA,IACdC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,kBAAkBpB,KAAK;AAErC,QAAA;AAAA,IAAEE;AAAAA,IAASmB;AAAAA,EAAAA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MjD,QAAQkD;AAAAA,IACdd,OAAOpC,QAAQoC;AAAAA,IACfe,sBAAsBnD,QAAQmD;AAAAA,KAEhC,YAAY;AAAA,IACVC,OAAO;AAAA,MACL,GAAGpB;AAAAA,MACHqB,QAAQ9C,mBAAmBC,gBAAU0B,aAAaoB;AAAAA,IACpD;AAAA,EACF,GACA,OACA,QAAQb,YACR,UAAUK,cACV,WAAWF,eACP3B,GAAAA,OAAO,CAAA,IAGZ+B,2BAAAA,IAAAO,OAAAA,UAAA,EACC,SAAQ,kBACR,oBAAoB,OACpB,SACEP,2BAAAA,IAACQ,gBAAAA,MACC,EAAA,OAAM,gBACN,MAAK,QACL,WAAWrC,GAAGnB,QAAQyD,MAAM;AAAA,IAC1B,CAACzD,QAAQ0D,WAAW,GAAGrD;AAAAA,EACxB,CAAA,EACD,CAAA,GAEJ,WAAWc,GAAGnB,QAAQ2D,QAAQ;AAAA,IAC5B,CAAC3D,QAAQ4D,SAAS,GAAGC,SAAS3B,YAAsB,EAAE,KAAK;AAAA,EAAA,CAC5D,GACD,SAASM,aACT,UACA,GAAI1B,aAEJ,UAACkC,2BAAA,IAAAc,WAAA,cAAA,EACC,SACA,QAAM,MACN,WAAW3C,GAAGnB,QAAQ+D,MAAM;AAAA,IAAE,CAAC/D,QAAQgE,SAAS,GAAG,CAAC9D;AAAAA,EAAAA,CAAO,GAC3D,GAAIa,iBAEHb,UAASQ,SAAAA,aACZ,GACF,EAEJ,CAAA;AAEJ;;;"}
@@ -40,11 +40,11 @@ const {
40
40
  maxWidth: "100%",
41
41
  justifyContent: "flex-start",
42
42
  alignItems: "center",
43
- backgroundColor: "transparent",
43
+ backgroundColor: uikitStyles.theme.colors.atmo1,
44
44
  border: `1px solid transparent`,
45
45
  "&:hover, &:focus": {
46
46
  border: `1px solid ${uikitStyles.theme.colors.primary}`,
47
- backgroundColor: "transparent",
47
+ backgroundColor: uikitStyles.theme.colors.atmo1,
48
48
  "& $icon": {
49
49
  visibility: "visible"
50
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEditor.styles.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\nimport { inputClasses } from \"@core/components/Input\";\nimport { baseInputClasses } from \"@core/components/BaseInput\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvInlineEditor\", {\n root: {\n [`& .${baseInputClasses.inputRoot}.${inputClasses.inputRoot}`]: {\n height: \"100%\",\n minHeight: \"32px\",\n },\n },\n inputBorderContainer: {\n top: \"unset\",\n bottom: 0,\n },\n input: {},\n inputRoot: {},\n text: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n alignSelf: \"center\",\n },\n largeText: {},\n textEmpty: {\n color: theme.colors.secondary_60,\n },\n button: {\n padding: theme.spacing(\"6px\", \"8px\", \"5px\", \"8px\"),\n minHeight: \"32px\",\n\n boxSizing: \"border-box\",\n cursor: \"text\",\n height: \"100%\",\n width: \"100%\",\n maxWidth: \"100%\",\n justifyContent: \"flex-start\",\n alignItems: \"center\",\n\n backgroundColor: \"transparent\",\n border: `1px solid transparent`,\n\n \"&:hover, &:focus\": {\n border: `1px solid ${theme.colors.primary}`,\n backgroundColor: \"transparent\",\n\n \"& $icon\": {\n visibility: \"visible\",\n },\n },\n\n \"&:active\": {\n border: `1px solid ${theme.colors.secondary}`,\n backgroundColor: \"transparent\",\n\n \"& $icon\": {\n visibility: \"visible\",\n },\n },\n\n \"& > div\": {\n width: \"100%\",\n },\n \"& > div > span\": {\n width: \"100%\",\n },\n },\n icon: {\n cursor: \"pointer\",\n visibility: \"hidden\",\n alignSelf: \"center\",\n height: \"16px\",\n width: \"32px\",\n minWidth: \"32px\",\n\n \"& svg\": {\n margin: theme.spacing(0, \"xs\"),\n },\n },\n iconVisible: {\n visibility: \"visible\",\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","baseInputClasses","inputRoot","inputClasses","height","minHeight","inputBorderContainer","top","bottom","input","text","overflow","textOverflow","whiteSpace","alignSelf","largeText","textEmpty","color","theme","colors","secondary_60","button","padding","spacing","boxSizing","cursor","width","maxWidth","justifyContent","alignItems","backgroundColor","border","primary","visibility","secondary","icon","minWidth","margin","iconVisible"],"mappings":";;;;;;AAMa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,kBAAkB;AAAA,EAC3EC,MAAM;AAAA,IACJ,CAAE,MAAKC,+BAAiBC,SAAU,IAAGC,aAAaD,cAAAA,SAAU,EAAC,GAAG;AAAA,MAC9DE,QAAQ;AAAA,MACRC,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACAC,sBAAsB;AAAA,IACpBC,KAAK;AAAA,IACLC,QAAQ;AAAA,EACV;AAAA,EACAC,OAAO,CAAC;AAAA,EACRP,WAAW,CAAC;AAAA,EACZQ,MAAM;AAAA,IACJC,UAAU;AAAA,IACVC,cAAc;AAAA,IACdC,YAAY;AAAA,IACZC,WAAW;AAAA,EACb;AAAA,EACAC,WAAW,CAAC;AAAA,EACZC,WAAW;AAAA,IACTC,OAAOC,YAAAA,MAAMC,OAAOC;AAAAA,EACtB;AAAA,EACAC,QAAQ;AAAA,IACNC,SAASJ,YAAMK,MAAAA,QAAQ,OAAO,OAAO,OAAO,KAAK;AAAA,IACjDlB,WAAW;AAAA,IAEXmB,WAAW;AAAA,IACXC,QAAQ;AAAA,IACRrB,QAAQ;AAAA,IACRsB,OAAO;AAAA,IACPC,UAAU;AAAA,IACVC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IAEZC,iBAAiB;AAAA,IACjBC,QAAS;AAAA,IAET,oBAAoB;AAAA,MAClBA,QAAS,aAAYb,YAAMC,MAAAA,OAAOa,OAAQ;AAAA,MAC1CF,iBAAiB;AAAA,MAEjB,WAAW;AAAA,QACTG,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,YAAY;AAAA,MACVF,QAAS,aAAYb,YAAMC,MAAAA,OAAOe,SAAU;AAAA,MAC5CJ,iBAAiB;AAAA,MAEjB,WAAW;AAAA,QACTG,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACTP,OAAO;AAAA,IACT;AAAA,IACA,kBAAkB;AAAA,MAChBA,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACAS,MAAM;AAAA,IACJV,QAAQ;AAAA,IACRQ,YAAY;AAAA,IACZnB,WAAW;AAAA,IACXV,QAAQ;AAAA,IACRsB,OAAO;AAAA,IACPU,UAAU;AAAA,IAEV,SAAS;AAAA,MACPC,QAAQnB,YAAAA,MAAMK,QAAQ,GAAG,IAAI;AAAA,IAC/B;AAAA,EACF;AAAA,EACAe,aAAa;AAAA,IACXL,YAAY;AAAA,EACd;AACF,CAAC;;;"}
1
+ {"version":3,"file":"InlineEditor.styles.cjs","sources":["../../../../src/components/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\nimport { inputClasses } from \"@core/components/Input\";\nimport { baseInputClasses } from \"@core/components/BaseInput\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvInlineEditor\", {\n root: {\n [`& .${baseInputClasses.inputRoot}.${inputClasses.inputRoot}`]: {\n height: \"100%\",\n minHeight: \"32px\",\n },\n },\n inputBorderContainer: {\n top: \"unset\",\n bottom: 0,\n },\n input: {},\n inputRoot: {},\n text: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n alignSelf: \"center\",\n },\n largeText: {},\n textEmpty: {\n color: theme.colors.secondary_60,\n },\n button: {\n padding: theme.spacing(\"6px\", \"8px\", \"5px\", \"8px\"),\n minHeight: \"32px\",\n\n boxSizing: \"border-box\",\n cursor: \"text\",\n height: \"100%\",\n width: \"100%\",\n maxWidth: \"100%\",\n justifyContent: \"flex-start\",\n alignItems: \"center\",\n\n backgroundColor: theme.colors.atmo1,\n border: `1px solid transparent`,\n\n \"&:hover, &:focus\": {\n border: `1px solid ${theme.colors.primary}`,\n backgroundColor: theme.colors.atmo1,\n\n \"& $icon\": {\n visibility: \"visible\",\n },\n },\n\n \"&:active\": {\n border: `1px solid ${theme.colors.secondary}`,\n backgroundColor: \"transparent\",\n\n \"& $icon\": {\n visibility: \"visible\",\n },\n },\n\n \"& > div\": {\n width: \"100%\",\n },\n \"& > div > span\": {\n width: \"100%\",\n },\n },\n icon: {\n cursor: \"pointer\",\n visibility: \"hidden\",\n alignSelf: \"center\",\n height: \"16px\",\n width: \"32px\",\n minWidth: \"32px\",\n\n \"& svg\": {\n margin: theme.spacing(0, \"xs\"),\n },\n },\n iconVisible: {\n visibility: \"visible\",\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","baseInputClasses","inputRoot","inputClasses","height","minHeight","inputBorderContainer","top","bottom","input","text","overflow","textOverflow","whiteSpace","alignSelf","largeText","textEmpty","color","theme","colors","secondary_60","button","padding","spacing","boxSizing","cursor","width","maxWidth","justifyContent","alignItems","backgroundColor","atmo1","border","primary","visibility","secondary","icon","minWidth","margin","iconVisible"],"mappings":";;;;;;AAMa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,kBAAkB;AAAA,EAC3EC,MAAM;AAAA,IACJ,CAAE,MAAKC,+BAAiBC,SAAU,IAAGC,aAAaD,cAAAA,SAAU,EAAC,GAAG;AAAA,MAC9DE,QAAQ;AAAA,MACRC,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACAC,sBAAsB;AAAA,IACpBC,KAAK;AAAA,IACLC,QAAQ;AAAA,EACV;AAAA,EACAC,OAAO,CAAC;AAAA,EACRP,WAAW,CAAC;AAAA,EACZQ,MAAM;AAAA,IACJC,UAAU;AAAA,IACVC,cAAc;AAAA,IACdC,YAAY;AAAA,IACZC,WAAW;AAAA,EACb;AAAA,EACAC,WAAW,CAAC;AAAA,EACZC,WAAW;AAA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