@hitachivantara/uikit-react-core 5.44.5 → 5.44.7
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.
- package/dist/cjs/AppSwitcher/Action/Action.cjs +1 -1
- package/dist/cjs/AppSwitcher/Action/Action.cjs.map +1 -1
- package/dist/cjs/Input/Input.cjs +1 -2
- package/dist/cjs/Input/Input.cjs.map +1 -1
- package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs +18 -29
- package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -1
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs +8 -15
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs.map +1 -1
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.cjs +2 -7
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.cjs.map +1 -1
- package/dist/cjs/VerticalNavigation/TreeView/IconWrapper/IconWrapper.cjs +14 -23
- package/dist/cjs/VerticalNavigation/TreeView/IconWrapper/IconWrapper.cjs.map +1 -1
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs +7 -5
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs.map +1 -1
- package/dist/cjs/hocs/withTooltip.cjs +1 -3
- package/dist/cjs/hocs/withTooltip.cjs.map +1 -1
- package/dist/esm/AppSwitcher/Action/Action.js +1 -1
- package/dist/esm/AppSwitcher/Action/Action.js.map +1 -1
- package/dist/esm/Input/Input.js +1 -2
- package/dist/esm/Input/Input.js.map +1 -1
- package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js +18 -29
- package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js +8 -15
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js.map +1 -1
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js +2 -7
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/IconWrapper/IconWrapper.js +15 -24
- package/dist/esm/VerticalNavigation/TreeView/IconWrapper/IconWrapper.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js +8 -6
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
- package/dist/esm/hocs/withTooltip.js +1 -3
- package/dist/esm/hocs/withTooltip.js.map +1 -1
- package/package.json +3 -3
- package/dist/cjs/VerticalNavigation/TreeView/TooltipWrapper/TooltipWrapper.cjs +0 -25
- package/dist/cjs/VerticalNavigation/TreeView/TooltipWrapper/TooltipWrapper.cjs.map +0 -1
- package/dist/esm/VerticalNavigation/TreeView/TooltipWrapper/TooltipWrapper.js +0 -25
- package/dist/esm/VerticalNavigation/TreeView/TooltipWrapper/TooltipWrapper.js.map +0 -1
|
@@ -126,7 +126,7 @@ const HvAppSwitcherAction = ({
|
|
|
126
126
|
{
|
|
127
127
|
disableFocusListener: true,
|
|
128
128
|
disableTouchListener: true,
|
|
129
|
-
title:
|
|
129
|
+
title: description,
|
|
130
130
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
131
131
|
uikitReactIcons.Info,
|
|
132
132
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.cjs","sources":["../../../../src/AppSwitcher/Action/Action.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nimport { theme, getColor, HvColorAny } from \"@hitachivantara/uikit-styles\";\nimport { Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvAvatar } from \"../../Avatar\";\nimport { HvListItem } from \"../../ListContainer\";\nimport { HvTypography } from \"../../Typography\";\nimport { HvTooltip } from \"../../Tooltip\";\nimport { HvOverflowTooltip } from \"../../OverflowTooltip\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { useClasses, staticClasses } from \"./Action.styles\";\n\nexport { staticClasses as appSwitcherActionClasses };\n\nexport type HvAppSwitcherActionClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvAppSwitcherActionApplication {\n /** Id of the application. */\n id?: string;\n /** Name of the application, this is the value that will be displayed on the component. */\n name: string;\n /** URL with the icon location to be used to represent the application. iconUrl will only be used if no iconElement is provided. */\n iconUrl?: string;\n /** Element to be added as the icon representing the application. The iconElement will be the primary option to be displayed. */\n iconElement?: React.ReactElement;\n /** Small description of the application. */\n description?: string;\n /** URL where the application is accessible. */\n url?: string;\n /** Defines if the application should be opened in the same tab or in a new one. */\n target?: \"_top\" | \"_blank\";\n /** If true, the item will be disabled. */\n disabled?: boolean;\n /** True when the application is selected, false otherwise. */\n isSelected?: boolean;\n /** The color of the application. */\n color?: HvColorAny;\n}\n\nexport interface HvAppSwitcherActionProps extends HvBaseProps {\n /** The application data to be used to render the Action object. */\n application: HvAppSwitcherActionApplication;\n /** Callback triggered when the action is clicked. */\n onClickCallback?: (\n event: React.MouseEvent,\n application: HvAppSwitcherActionApplication\n ) => void;\n /** Must return a boolean stating if the action element is selected or not. */\n isSelectedCallback?: (application: HvAppSwitcherActionApplication) => boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvAppSwitcherActionClasses;\n}\n\nexport const HvAppSwitcherAction = ({\n id,\n className,\n classes: classesProp,\n application,\n onClickCallback = () => {},\n isSelectedCallback = () => false,\n}: HvAppSwitcherActionProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const { name, description, disabled, iconElement, iconUrl, url, target } =\n application;\n\n const color = disabled\n ? theme.colors.secondary_60\n : getColor(application?.color, theme.colors.secondary);\n\n const [validIconUrl, setValidIconUrl] = useState<boolean>(true);\n\n const renderApplicationIcon = () => {\n if (iconElement) {\n return iconElement;\n }\n\n if (iconUrl && validIconUrl) {\n return (\n <img\n className={classes.iconUrl}\n src={iconUrl}\n onError={() => {\n setValidIconUrl(false);\n }}\n alt={description}\n />\n );\n }\n\n const brokenTitle = name.split(\" \");\n const initials =\n brokenTitle[0].substring(0, 1) +\n (brokenTitle[1] ? brokenTitle[1].substring(0, 1) : \"\");\n\n return (\n <HvAvatar size=\"sm\" backgroundColor={color} variant=\"square\" aria-hidden>\n {initials}\n </HvAvatar>\n );\n };\n\n const isSelected = isSelectedCallback(application);\n\n /**\n * Handles the onClick event and triggers the appropriate callback if it exists.\n */\n const handleOnClick = useCallback(\n (event: React.MouseEvent) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n\n onClickCallback?.(event, { ...application, isSelected });\n },\n [application, disabled, isSelected, onClickCallback]\n );\n\n const isLink = url != null;\n const descriptionElementId = useUniqueId(id, \"hvAction-description\");\n\n const renderApplication = useCallback(\n (children: React.ReactNode) => {\n const typographyProps = {\n className: classes.typography,\n onClick: handleOnClick,\n style: { borderColor: color },\n \"aria-label\": name,\n ...(description && { \"aria-describedby\": descriptionElementId }),\n };\n\n if (isLink) {\n return (\n <HvTypography\n component=\"a\"\n href={url}\n target={target || \"_top\"}\n {...typographyProps}\n >\n {children}\n </HvTypography>\n );\n }\n\n return (\n <HvTypography component=\"button\" {...typographyProps}>\n {children}\n </HvTypography>\n );\n },\n [\n classes.typography,\n color,\n description,\n descriptionElementId,\n handleOnClick,\n isLink,\n name,\n target,\n url,\n ]\n );\n\n return (\n <HvListItem\n id={id}\n interactive\n tabIndex={0}\n selected={isSelected}\n disabled={disabled}\n className={cx(\n classes.root,\n { [classes.disabled]: disabled, [classes.selected]: isSelected },\n className\n )}\n >\n {/* As HvTooltip don't have the id prop, is not possible to use the aria-labelledby to reference it.\n In substitution is used the aria-label with the \"title\" value */}\n {renderApplication(\n <>\n <div className={classes.icon}>{renderApplicationIcon()}</div>\n\n <HvOverflowTooltip\n paragraphOverflow\n className={classes.title}\n placement=\"top-start\"\n data={name}\n classes={{\n tooltipAnchorParagraph: classes.titleAnchor,\n }}\n />\n\n {description && (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={
|
|
1
|
+
{"version":3,"file":"Action.cjs","sources":["../../../../src/AppSwitcher/Action/Action.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nimport { theme, getColor, HvColorAny } from \"@hitachivantara/uikit-styles\";\nimport { Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvAvatar } from \"../../Avatar\";\nimport { HvListItem } from \"../../ListContainer\";\nimport { HvTypography } from \"../../Typography\";\nimport { HvTooltip } from \"../../Tooltip\";\nimport { HvOverflowTooltip } from \"../../OverflowTooltip\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\n\nimport { useClasses, staticClasses } from \"./Action.styles\";\n\nexport { staticClasses as appSwitcherActionClasses };\n\nexport type HvAppSwitcherActionClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvAppSwitcherActionApplication {\n /** Id of the application. */\n id?: string;\n /** Name of the application, this is the value that will be displayed on the component. */\n name: string;\n /** URL with the icon location to be used to represent the application. iconUrl will only be used if no iconElement is provided. */\n iconUrl?: string;\n /** Element to be added as the icon representing the application. The iconElement will be the primary option to be displayed. */\n iconElement?: React.ReactElement;\n /** Small description of the application. */\n description?: string;\n /** URL where the application is accessible. */\n url?: string;\n /** Defines if the application should be opened in the same tab or in a new one. */\n target?: \"_top\" | \"_blank\";\n /** If true, the item will be disabled. */\n disabled?: boolean;\n /** True when the application is selected, false otherwise. */\n isSelected?: boolean;\n /** The color of the application. */\n color?: HvColorAny;\n}\n\nexport interface HvAppSwitcherActionProps extends HvBaseProps {\n /** The application data to be used to render the Action object. */\n application: HvAppSwitcherActionApplication;\n /** Callback triggered when the action is clicked. */\n onClickCallback?: (\n event: React.MouseEvent,\n application: HvAppSwitcherActionApplication\n ) => void;\n /** Must return a boolean stating if the action element is selected or not. */\n isSelectedCallback?: (application: HvAppSwitcherActionApplication) => boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvAppSwitcherActionClasses;\n}\n\nexport const HvAppSwitcherAction = ({\n id,\n className,\n classes: classesProp,\n application,\n onClickCallback = () => {},\n isSelectedCallback = () => false,\n}: HvAppSwitcherActionProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const { name, description, disabled, iconElement, iconUrl, url, target } =\n application;\n\n const color = disabled\n ? theme.colors.secondary_60\n : getColor(application?.color, theme.colors.secondary);\n\n const [validIconUrl, setValidIconUrl] = useState<boolean>(true);\n\n const renderApplicationIcon = () => {\n if (iconElement) {\n return iconElement;\n }\n\n if (iconUrl && validIconUrl) {\n return (\n <img\n className={classes.iconUrl}\n src={iconUrl}\n onError={() => {\n setValidIconUrl(false);\n }}\n alt={description}\n />\n );\n }\n\n const brokenTitle = name.split(\" \");\n const initials =\n brokenTitle[0].substring(0, 1) +\n (brokenTitle[1] ? brokenTitle[1].substring(0, 1) : \"\");\n\n return (\n <HvAvatar size=\"sm\" backgroundColor={color} variant=\"square\" aria-hidden>\n {initials}\n </HvAvatar>\n );\n };\n\n const isSelected = isSelectedCallback(application);\n\n /**\n * Handles the onClick event and triggers the appropriate callback if it exists.\n */\n const handleOnClick = useCallback(\n (event: React.MouseEvent) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n\n onClickCallback?.(event, { ...application, isSelected });\n },\n [application, disabled, isSelected, onClickCallback]\n );\n\n const isLink = url != null;\n const descriptionElementId = useUniqueId(id, \"hvAction-description\");\n\n const renderApplication = useCallback(\n (children: React.ReactNode) => {\n const typographyProps = {\n className: classes.typography,\n onClick: handleOnClick,\n style: { borderColor: color },\n \"aria-label\": name,\n ...(description && { \"aria-describedby\": descriptionElementId }),\n };\n\n if (isLink) {\n return (\n <HvTypography\n component=\"a\"\n href={url}\n target={target || \"_top\"}\n {...typographyProps}\n >\n {children}\n </HvTypography>\n );\n }\n\n return (\n <HvTypography component=\"button\" {...typographyProps}>\n {children}\n </HvTypography>\n );\n },\n [\n classes.typography,\n color,\n description,\n descriptionElementId,\n handleOnClick,\n isLink,\n name,\n target,\n url,\n ]\n );\n\n return (\n <HvListItem\n id={id}\n interactive\n tabIndex={0}\n selected={isSelected}\n disabled={disabled}\n className={cx(\n classes.root,\n { [classes.disabled]: disabled, [classes.selected]: isSelected },\n className\n )}\n >\n {/* As HvTooltip don't have the id prop, is not possible to use the aria-labelledby to reference it.\n In substitution is used the aria-label with the \"title\" value */}\n {renderApplication(\n <>\n <div className={classes.icon}>{renderApplicationIcon()}</div>\n\n <HvOverflowTooltip\n paragraphOverflow\n className={classes.title}\n placement=\"top-start\"\n data={name}\n classes={{\n tooltipAnchorParagraph: classes.titleAnchor,\n }}\n />\n\n {description && (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={description}\n >\n <div>\n <Info\n className={classes.iconInfo}\n role=\"img\"\n aria-label={description}\n id={descriptionElementId}\n />\n </div>\n </HvTooltip>\n )}\n </>\n )}\n </HvListItem>\n );\n};\n"],"names":["useClasses","theme","getColor","useState","jsx","HvAvatar","useCallback","useUniqueId","HvTypography","HvListItem","jsxs","Fragment","HvOverflowTooltip","HvTooltip","Info"],"mappings":";;;;;;;;;;;;;AAyDO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,qBAAqB,MAAM;AAC7B,MAAgC;AAC9B,QAAM,EAAE,SAAS,GAAG,IAAIA,yBAAW,WAAW;AAExC,QAAA,EAAE,MAAM,aAAa,UAAU,aAAa,SAAS,KAAK,OAC9D,IAAA;AAEI,QAAA,QAAQ,WACVC,YAAA,MAAM,OAAO,eACbC,qBAAS,aAAa,OAAOD,YAAAA,MAAM,OAAO,SAAS;AAEvD,QAAM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A,gBAAA;AAAA,cAAA,GAER;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GAEJ;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;;;"}
|
package/dist/cjs/Input/Input.cjs
CHANGED
|
@@ -19,7 +19,6 @@ const Adornment = require("../Forms/Adornment/Adornment.cjs");
|
|
|
19
19
|
const BaseInput = require("../BaseInput/BaseInput.cjs");
|
|
20
20
|
const Suggestions = require("../Forms/Suggestions/Suggestions.cjs");
|
|
21
21
|
const Tooltip = require("../Tooltip/Tooltip.cjs");
|
|
22
|
-
const Typography = require("../Typography/Typography.cjs");
|
|
23
22
|
const FormElement = require("../Forms/FormElement/FormElement.cjs");
|
|
24
23
|
const Label = require("../Forms/Label/Label.cjs");
|
|
25
24
|
const InfoMessage = require("../Forms/InfoMessage/InfoMessage.cjs");
|
|
@@ -323,7 +322,7 @@ const HvInput = React.forwardRef((props, ref) => {
|
|
|
323
322
|
{
|
|
324
323
|
disableFocusListener: true,
|
|
325
324
|
disableTouchListener: true,
|
|
326
|
-
title:
|
|
325
|
+
title: revealPassword ? labels?.revealPasswordButtonClickToHideTooltip : labels?.revealPasswordButtonClickToShowTooltip,
|
|
327
326
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
328
327
|
Adornment.HvAdornment,
|
|
329
328
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.cjs","sources":["../../../src/Input/Input.tsx"],"sourcesContent":["import React, {\n FocusEvent,\n HTMLInputTypeAttribute,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { InputBaseComponentProps as MuiInputBaseComponentProps } from \"@mui/material/InputBase\";\nimport { useForkRef } from \"@mui/material/utils\";\n\nimport {\n CloseXS,\n PreviewOff,\n Preview,\n Search,\n Success,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { ExtractNames } from \"../utils/classes\";\nimport { isBrowser } from \"../utils/browser\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport {\n HvInputLabels,\n HvInputSuggestion,\n HvValidationMessages,\n} from \"../types/forms\";\nimport { HvBaseProps, HvExtraProps } from \"../types/generic\";\nimport {\n HvAdornment,\n HvAdornmentProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestion,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n isValid,\n isInvalid,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { HvBaseInput, HvBaseInputProps } from \"../BaseInput\";\nimport {\n DEFAULT_ERROR_MESSAGES,\n computeValidationType,\n hasBuiltInValidations,\n validateInput,\n computeValidationState,\n computeValidationMessage,\n HvInputValidity,\n} from \"../BaseInput/validations\";\nimport { HvTypography } from \"../Typography\";\nimport { HvTooltip } from \"../Tooltip\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useLabels } from \"../hooks/useLabels\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./Input.styles\";\n\nexport { staticClasses as inputClasses };\n\nexport type HvInputClasses = ExtractNames<typeof useClasses>;\n\ntype InputElement = HTMLInputElement | HTMLTextAreaElement;\n\nexport interface HvInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string;\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /**\n * The function that will be executed onChange, allows modification of the input,\n * it receives the value. If a new value should be presented it must returned it.\n */\n onChange?: HvBaseInputProps[\"onChange\"];\n /**\n * Callback called when the user submits the value by pressing Enter/Return.\n *\n * Also called when the search button is clicked (when type is \"search\").\n */\n onEnter?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the validation state,\n * it receives the value and the validation state.\n */\n onBlur?: (\n event: React.FocusEvent<InputElement>,\n value: string,\n validationState: HvInputValidity\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (event: React.FocusEvent<InputElement>, value: string) => void;\n /**\n * The function that will be executed onKeyDown, allows checking the value state,\n * it receives the event and value.\n */\n onKeyDown?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /** The input type. */\n type?: HTMLInputTypeAttribute;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** Internal labels?. */\n labels?: HvInputLabels & HvExtraProps;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /**\n * Allows passing a ref to the underlying input\n * @deprecated Use `ref` directly instead\n * */\n inputRef?: HvBaseInputProps[\"inputRef\"];\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */\n suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the clear button is disabled. */\n disableClear?: boolean;\n /** If `true` the reveal password button is disabled. Valid only when type is \"password\". */\n disableRevealPassword?: boolean;\n /** If `true` the search button is disabled. Valid only when type is \"search\". */\n disableSearchButton?: boolean;\n /**\n * If `true` the validation icon adornment is visible. Defaults to `false`.\n *\n * Currently, DS specifications define only a positive feedback icon;\n * errors are signaled through the border style and by displaying the error message.\n */\n showValidationIcon?: boolean;\n /** A custom icon to be added into the input. */\n endAdornment?: React.ReactNode;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxCharQuantity?: number;\n /** The minimum allowed length of the characters, if this value is null no check will be perform. */\n minCharQuantity?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInputClasses;\n}\n\nconst DEFAULT_LABELS = {\n clearButtonLabel: \"Clear the text\",\n revealPasswordButtonLabel: \"Reveal password\",\n revealPasswordButtonClickToShowTooltip: \"Click to show password.\",\n revealPasswordButtonClickToHideTooltip: \"Click to hide password.\",\n searchButtonLabel: \"Search\",\n};\n\n/**\n * Find the focused element onBlur.\n */\nconst getFocusedElement = (event: FocusEvent) =>\n isBrowser(\"ie\") ? document.activeElement : event.relatedTarget;\n\nfunction eventTargetIsInsideContainer(\n container: HTMLElement | null,\n event: FocusEvent<any>\n) {\n return container != null && container.contains(getFocusedElement(event));\n}\n\n/** Changes a given `input`'s `value`, triggering its `onChange` */\nconst changeInputValue = (input: HTMLInputElement | null, value = \"\") => {\n const event = new Event(\"input\", { bubbles: true });\n\n /** Original `input.value` setter (React overrides it). */\n const setInputValue = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\"\n )?.set;\n\n setInputValue?.call(input, value);\n input?.dispatchEvent(event);\n};\n\n/**\n * A text input box is a graphical control element intended to enable the user to input text information to be used by the software.\n */\nexport const HvInput = forwardRef<InputElement, HvInputProps>((props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = \"\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onEnter,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n type = \"text\",\n placeholder,\n autoFocus = false,\n labels: labelsProp,\n validationMessages,\n disableClear = false,\n disableRevealPassword = false,\n disableSearchButton = false,\n endAdornment,\n maxCharQuantity,\n minCharQuantity,\n validation,\n showValidationIcon = false,\n suggestionListCallback,\n inputRef: inputRefProp,\n onBlur,\n onFocus,\n onKeyDown,\n inputProps = {},\n ...others\n } = useDefaultProps(\"HvInput\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const elementId = useUniqueId(id, \"hvinput\");\n\n const inputRef = useRef<HTMLInputElement>(null);\n const forkedRef = useForkRef(ref, inputRef, inputRefProp);\n const suggestionsRef = useRef<HTMLElement>(null);\n\n const [focused, setFocused] = useState(false);\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n // Value related state\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isEmptyValue = value == null || value === \"\";\n\n // Validation related state\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\"\n );\n\n // validationMessages reference tends to change, as users will not memoize/useState for it;\n // dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n validationMessages?.error,\n validationMessages?.requiredError,\n validationMessages?.minCharError,\n validationMessages?.maxCharError,\n validationMessages?.typeMismatchError,\n ]\n );\n\n const validationType = useMemo(() => computeValidationType(type), [type]);\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationType,\n validation\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages)\n );\n\n return inputValidity;\n }, [\n errorMessages,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n validationType,\n value,\n ]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationType,\n minCharQuantity,\n maxCharQuantity,\n validation,\n inputProps\n )));\n\n const isStateInvalid = isInvalid(validationState);\n\n // Input type related state\n const [revealPassword, setRevealPassword] = useState(false);\n\n const realType = useMemo(() => {\n if (type === \"password\") {\n return revealPassword ? \"text\" : \"password\";\n }\n\n if (type === \"search\") {\n return \"search\";\n }\n\n return \"text\";\n }, [revealPassword, type]);\n\n // Suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvSuggestion[] | null\n >(null);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n // Miscellaneous state\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n inputRef.current?.focus();\n };\n\n const isMounted = useIsMounted();\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = () => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n };\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n };\n\n /**\n * Executes the user callback adds the selection to the state and clears the suggestions.\n */\n const suggestionSelectedHandler: HvSuggestionsProps[\"onSuggestionSelected\"] =\n (event, item) => {\n const newValue = item.value || (item.label as any);\n\n changeInputValue(inputRef.current, newValue);\n\n focusInput();\n suggestionClearHandler();\n\n if (type === \"search\") {\n // trigger the onEnter callback when the user selects an option in a search box\n onEnter?.(event, newValue);\n }\n };\n\n const onChangeHandler: HvBaseInputProps[\"onChange\"] = (event, newValue) => {\n isDirty.current = true;\n\n // set the input value (only when value is uncontrolled)\n setValue(newValue);\n\n onChange?.(event, newValue);\n\n if (canShowSuggestions) {\n // an edge case might be a controlled input whose onChange callback\n // doesn't change the value (or sets another): the suggestionListCallback\n // callback will still receive the original rejected value.\n // a refactor is needed so the suggestionListCallback might be called only\n // when the input is uncontrolled, providing a way to externally control\n // the suggestion values.\n suggestionHandler(newValue);\n }\n };\n\n /**\n * Validates the input updating the state and modifying the info text, also executes\n * the user provided onBlur passing the current validation status and value.\n */\n const onInputBlurHandler: HvBaseInputProps[\"onBlur\"] = (event) => {\n // If the blur is executed when choosing an suggestion it should be ignored.\n if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;\n\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler: HvBaseInputProps[\"onFocus\"] = (event) => {\n setFocused(true);\n\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const getSuggestions = (li: number | null) => {\n // TODO Replace with ref\n const listEl = document.getElementById(\n setId(elementId, \"suggestions-list\") || \"\"\n );\n return li != null ? listEl?.getElementsByTagName(\"li\")?.[li] : listEl;\n };\n\n const onSuggestionKeyDown: HvSuggestionsProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /** Focus the suggestion list when the arrow down is pressed. */\n const onKeyDownHandler: HvBaseInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"ArrowDown\") && hasSuggestions) {\n const li = getSuggestions(0);\n li?.focus();\n } else if (isKey(event, \"Enter\")) {\n onEnter?.(event, value);\n }\n\n onKeyDown?.(event, value);\n };\n\n /** Clears the suggestion list on blur. */\n const onContainerBlurHandler: HvFormElementProps[\"onBlur\"] = (event) => {\n if (event.relatedTarget) {\n setTimeout(() => {\n const list = getSuggestions(null);\n if (!list?.contains(document.activeElement)) suggestionClearHandler();\n }, 10);\n }\n };\n\n const hasOnEnter = onEnter != null;\n\n // show the clear button only if the input is enabled, not read-only, disableClear is false and the input is not empty\n // also, don't show it when the input type is \"search\" and the input is active (standBy)\n const showClear =\n !disabled &&\n !readOnly &&\n !disableClear &&\n !isEmptyValue &&\n (!hasOnEnter ||\n type !== \"search\" ||\n disableSearchButton ||\n validationState !== validationStates.standBy);\n\n const showSearchIcon = type === \"search\" && !disableSearchButton;\n\n const showRevealPasswordButton =\n type === \"password\" && !disableRevealPassword;\n\n /**\n * Clears the input value from the state and refocus the input.\n */\n const handleClear = useCallback(() => {\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n changeInputValue(inputRef.current, \"\");\n\n // we want to focus the input when clicked and not active\n setTimeout(focusInput);\n }, [setValidationState]);\n\n const clearButton = useMemo(() => {\n if (!showClear) {\n return null;\n }\n\n return (\n <HvAdornment\n // Don't control visibility when the search icon is enabled\n className={cx(classes.adornmentButton, {\n [classes.iconClear]: !showSearchIcon,\n })}\n onClick={handleClear}\n aria-label={labels?.clearButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={<CloseXS />}\n />\n );\n }, [\n showClear,\n classes.adornmentButton,\n classes.iconClear,\n showSearchIcon,\n handleClear,\n labels?.clearButtonLabel,\n elementId,\n cx,\n ]);\n\n /**\n * Calls the onEnter callback and refocus the input.\n */\n const handleSearch = useCallback<NonNullable<HvAdornmentProps[\"onClick\"]>>(\n (event) => {\n onEnter?.(event, value);\n },\n [onEnter, value]\n );\n\n const searchButton = useMemo(() => {\n // If the search icon is not actionable, only show it when the input is empty or active\n const reallyShowIt =\n showSearchIcon &&\n (isEmptyValue ||\n (hasOnEnter && validationState === validationStates.standBy));\n\n if (!reallyShowIt) {\n return null;\n }\n\n return (\n <HvAdornment\n className={classes.adornmentButton}\n onClick={hasOnEnter ? handleSearch : undefined}\n aria-label={labels?.searchButtonLabel}\n icon={<Search />}\n />\n );\n }, [\n showSearchIcon,\n isEmptyValue,\n hasOnEnter,\n validationState,\n classes.adornmentButton,\n handleSearch,\n labels?.searchButtonLabel,\n ]);\n\n /**\n * Changes input type and refocus the input.\n */\n const handleRevealPassword = useCallback(() => {\n setRevealPassword(!revealPassword);\n }, [revealPassword]);\n\n const revealPasswordButton = useMemo(() => {\n if (!showRevealPasswordButton) {\n return null;\n }\n\n return (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={\n <HvTypography>\n {revealPassword\n ? labels?.revealPasswordButtonClickToHideTooltip\n : labels?.revealPasswordButtonClickToShowTooltip}\n </HvTypography>\n }\n >\n <HvAdornment\n className={classes.adornmentButton}\n onClick={handleRevealPassword}\n aria-label={labels?.revealPasswordButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={revealPassword ? <PreviewOff /> : <Preview />}\n />\n </HvTooltip>\n );\n }, [\n showRevealPasswordButton,\n revealPassword,\n labels?.revealPasswordButtonClickToHideTooltip,\n labels?.revealPasswordButtonClickToShowTooltip,\n labels?.revealPasswordButtonLabel,\n classes.adornmentButton,\n handleRevealPassword,\n elementId,\n ]);\n\n const validationIcon = useMemo(() => {\n if (!showValidationIcon) {\n return null;\n }\n\n if (!isValid(validationState)) {\n return null;\n }\n\n return <Success color=\"positive\" className={classes.icon} />;\n }, [showValidationIcon, validationState, classes.icon]);\n\n // useMemo to avoid repetitive cloning of the custom icon\n const customIconEl = useMemo(\n () =>\n isValidElement(endAdornment) &&\n React.cloneElement(endAdornment as React.ReactElement, {\n className: cx(endAdornment.props.className, classes.icon),\n }),\n [classes.icon, endAdornment, cx]\n );\n\n const adornments = useMemo(() => {\n if (\n !clearButton &&\n !revealPasswordButton &&\n !searchButton &&\n !validationIcon &&\n !customIconEl\n )\n return null;\n\n // note: specification implies that the custom icon should be hidden when\n // a validation feedback icon is being shown.\n return (\n <div className={classes.adornmentsBox} aria-hidden=\"true\">\n {clearButton}\n {revealPasswordButton}\n {searchButton}\n {validationIcon || customIconEl}\n </div>\n );\n }, [\n classes.adornmentsBox,\n clearButton,\n customIconEl,\n revealPasswordButton,\n searchButton,\n validationIcon,\n ]);\n\n // run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(\n classes.root,\n {\n [classes.hasSuggestions]: hasSuggestions,\n },\n className\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseInput\n id={\n hasLabel || showClear || showRevealPasswordButton\n ? setId(elementId, \"input\")\n : setId(id, \"input\")\n }\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onKeyDown={onKeyDownHandler}\n onBlur={onInputBlurHandler}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n type={realType}\n classes={{\n input: classes.input,\n inputRoot: classes.inputRoot,\n inputRootFocused: classes.inputRootFocused,\n inputRootDisabled: classes.inputRootDisabled,\n inputRootMultiline: classes.inputRootMultiline,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n invalid={isStateInvalid}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : description\n ? setId(elementId, \"description\")\n : undefined,\n \"aria-controls\": canShowSuggestions\n ? setId(elementId, \"suggestions\")\n : undefined,\n\n ref: inputRef,\n\n // prevent browsers auto-fill/suggestions when we have our own\n autoComplete: canShowSuggestions ? \"off\" : undefined,\n\n ...inputProps,\n }}\n inputRef={forkedRef}\n endAdornment={adornments}\n {...others}\n />\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n ref={suggestionsRef}\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={inputRef.current?.parentElement}\n onClose={suggestionClearHandler}\n onKeyDown={onSuggestionKeyDown}\n onSuggestionSelected={suggestionSelectedHandler}\n suggestionValues={suggestionValues}\n />\n </>\n )}\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["isBrowser","forwardRef","useDefaultProps","useClasses","useLabels","useUniqueId","useRef","useForkRef","useState","useControlled","validationStates","useMemo","DEFAULT_ERROR_MESSAGES","computeValidationType","useCallback","validateInput","computeValidationState","computeValidationMessage","hasBuiltInValidations","isInvalid","useIsMounted","setId","isKey","jsx","HvAdornment","CloseXS","Search","HvTooltip","HvTypography","PreviewOff","Preview","isValid","Success","isValidElement","React","useEffect","jsxs","HvFormElement","HvLabel","HvInfoMessage","HvBaseInput","Fragment","HvSuggestions","HvWarningText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqMA,MAAM,iBAAiB;AAAA,EACrB,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EAC3B,wCAAwC;AAAA,EACxC,wCAAwC;AAAA,EACxC,mBAAmB;AACrB;AAKA,MAAM,oBAAoB,CAAC,UACzBA,kBAAU,IAAI,IAAI,SAAS,gBAAgB,MAAM;AAEnD,SAAS,6BACP,WACA,OACA;AACA,SAAO,aAAa,QAAQ,UAAU,SAAS,kBAAkB,KAAK,CAAC;AACzE;AAGA,MAAM,mBAAmB,CAAC,OAAgC,QAAQ,OAAO;AACvE,QAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;AAGlD,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,iBAAiB;AAAA,IACxB;AAAA,EACC,GAAA;AAEY,iBAAA,KAAK,OAAO,KAAK;AAChC,SAAO,cAAc,KAAK;AAC5B;AAKO,MAAM,UAAUC,MAAA,WAAuC,CAAC,OAAO,QAAQ;AACtE,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP;AAAA,IACA,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR;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Input.cjs","sources":["../../../src/Input/Input.tsx"],"sourcesContent":["import React, {\n FocusEvent,\n HTMLInputTypeAttribute,\n forwardRef,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { InputBaseComponentProps as MuiInputBaseComponentProps } from \"@mui/material/InputBase\";\nimport { useForkRef } from \"@mui/material/utils\";\n\nimport {\n CloseXS,\n PreviewOff,\n Preview,\n Search,\n Success,\n} from \"@hitachivantara/uikit-react-icons\";\n\nimport { ExtractNames } from \"../utils/classes\";\nimport { isBrowser } from \"../utils/browser\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport {\n HvInputLabels,\n HvInputSuggestion,\n HvValidationMessages,\n} from \"../types/forms\";\nimport { HvBaseProps, HvExtraProps } from \"../types/generic\";\nimport {\n HvAdornment,\n HvAdornmentProps,\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvSuggestion,\n HvSuggestions,\n HvSuggestionsProps,\n HvWarningText,\n isValid,\n isInvalid,\n} from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { HvBaseInput, HvBaseInputProps } from \"../BaseInput\";\nimport {\n DEFAULT_ERROR_MESSAGES,\n computeValidationType,\n hasBuiltInValidations,\n validateInput,\n computeValidationState,\n computeValidationMessage,\n HvInputValidity,\n} from \"../BaseInput/validations\";\nimport { HvTooltip } from \"../Tooltip\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useIsMounted } from \"../hooks/useIsMounted\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { useLabels } from \"../hooks/useLabels\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./Input.styles\";\n\nexport { staticClasses as inputClasses };\n\nexport type HvInputClasses = ExtractNames<typeof useClasses>;\n\ntype InputElement = HTMLInputElement | HTMLTextAreaElement;\n\nexport interface HvInputProps\n extends HvBaseProps<\n HTMLElement,\n \"onChange\" | \"onBlur\" | \"onFocus\" | \"onKeyDown\" | \"color\"\n > {\n /** The form element name. */\n name?: string;\n /** The value of the form element. */\n value?: string;\n /** When uncontrolled, defines the initial input value. */\n defaultValue?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that the form element is not editable. */\n readOnly?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". */\n statusMessage?: string;\n /**\n * The function that will be executed onChange, allows modification of the input,\n * it receives the value. If a new value should be presented it must returned it.\n */\n onChange?: HvBaseInputProps[\"onChange\"];\n /**\n * Callback called when the user submits the value by pressing Enter/Return.\n *\n * Also called when the search button is clicked (when type is \"search\").\n */\n onEnter?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the validation state,\n * it receives the value and the validation state.\n */\n onBlur?: (\n event: React.FocusEvent<InputElement>,\n value: string,\n validationState: HvInputValidity\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (event: React.FocusEvent<InputElement>, value: string) => void;\n /**\n * The function that will be executed onKeyDown, allows checking the value state,\n * it receives the event and value.\n */\n onKeyDown?: (\n event: React.KeyboardEvent<InputElement> | React.MouseEvent,\n value: string\n ) => void;\n /** The input type. */\n type?: HTMLInputTypeAttribute;\n /** The placeholder value of the input. */\n placeholder?: string;\n /** Internal labels?. */\n labels?: HvInputLabels & HvExtraProps;\n /** An Object containing the various texts associated with the input. */\n validationMessages?: HvValidationMessages;\n /** Attributes applied to the input element. */\n inputProps?: MuiInputBaseComponentProps;\n /**\n * Allows passing a ref to the underlying input\n * @deprecated Use `ref` directly instead\n * */\n inputRef?: HvBaseInputProps[\"inputRef\"];\n /** The function that will be executed to received an array of objects that has a label and id to create list of suggestion */\n suggestionListCallback?: (value: string) => HvInputSuggestion[] | null;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /** If `true` it should autofocus. */\n autoFocus?: boolean;\n /** If `true` the clear button is disabled. */\n disableClear?: boolean;\n /** If `true` the reveal password button is disabled. Valid only when type is \"password\". */\n disableRevealPassword?: boolean;\n /** If `true` the search button is disabled. Valid only when type is \"search\". */\n disableSearchButton?: boolean;\n /**\n * If `true` the validation icon adornment is visible. Defaults to `false`.\n *\n * Currently, DS specifications define only a positive feedback icon;\n * errors are signaled through the border style and by displaying the error message.\n */\n showValidationIcon?: boolean;\n /** A custom icon to be added into the input. */\n endAdornment?: React.ReactNode;\n /** The maximum allowed length of the characters, if this value is null no check will be performed. */\n maxCharQuantity?: number;\n /** The minimum allowed length of the characters, if this value is null no check will be perform. */\n minCharQuantity?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvInputClasses;\n}\n\nconst DEFAULT_LABELS = {\n clearButtonLabel: \"Clear the text\",\n revealPasswordButtonLabel: \"Reveal password\",\n revealPasswordButtonClickToShowTooltip: \"Click to show password.\",\n revealPasswordButtonClickToHideTooltip: \"Click to hide password.\",\n searchButtonLabel: \"Search\",\n};\n\n/**\n * Find the focused element onBlur.\n */\nconst getFocusedElement = (event: FocusEvent) =>\n isBrowser(\"ie\") ? document.activeElement : event.relatedTarget;\n\nfunction eventTargetIsInsideContainer(\n container: HTMLElement | null,\n event: FocusEvent<any>\n) {\n return container != null && container.contains(getFocusedElement(event));\n}\n\n/** Changes a given `input`'s `value`, triggering its `onChange` */\nconst changeInputValue = (input: HTMLInputElement | null, value = \"\") => {\n const event = new Event(\"input\", { bubbles: true });\n\n /** Original `input.value` setter (React overrides it). */\n const setInputValue = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\"\n )?.set;\n\n setInputValue?.call(input, value);\n input?.dispatchEvent(event);\n};\n\n/**\n * A text input box is a graphical control element intended to enable the user to input text information to be used by the software.\n */\nexport const HvInput = forwardRef<InputElement, HvInputProps>((props, ref) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value: valueProp,\n defaultValue = \"\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onEnter,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n type = \"text\",\n placeholder,\n autoFocus = false,\n labels: labelsProp,\n validationMessages,\n disableClear = false,\n disableRevealPassword = false,\n disableSearchButton = false,\n endAdornment,\n maxCharQuantity,\n minCharQuantity,\n validation,\n showValidationIcon = false,\n suggestionListCallback,\n inputRef: inputRefProp,\n onBlur,\n onFocus,\n onKeyDown,\n inputProps = {},\n ...others\n } = useDefaultProps(\"HvInput\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n const elementId = useUniqueId(id, \"hvinput\");\n\n const inputRef = useRef<HTMLInputElement>(null);\n const forkedRef = useForkRef(ref, inputRef, inputRefProp);\n const suggestionsRef = useRef<HTMLElement>(null);\n\n const [focused, setFocused] = useState(false);\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef(false);\n\n // Value related state\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isEmptyValue = value == null || value === \"\";\n\n // Validation related state\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\"\n );\n\n // validationMessages reference tends to change, as users will not memoize/useState for it;\n // dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n validationMessages?.error,\n validationMessages?.requiredError,\n validationMessages?.minCharError,\n validationMessages?.maxCharError,\n validationMessages?.typeMismatchError,\n ]\n );\n\n const validationType = useMemo(() => computeValidationType(type), [type]);\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationType,\n validation\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages)\n );\n\n return inputValidity;\n }, [\n errorMessages,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n validationType,\n value,\n ]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationType,\n minCharQuantity,\n maxCharQuantity,\n validation,\n inputProps\n )));\n\n const isStateInvalid = isInvalid(validationState);\n\n // Input type related state\n const [revealPassword, setRevealPassword] = useState(false);\n\n const realType = useMemo(() => {\n if (type === \"password\") {\n return revealPassword ? \"text\" : \"password\";\n }\n\n if (type === \"search\") {\n return \"search\";\n }\n\n return \"text\";\n }, [revealPassword, type]);\n\n // Suggestions related state\n const [suggestionValues, setSuggestionValues] = useState<\n HvSuggestion[] | null\n >(null);\n\n const canShowSuggestions = suggestionListCallback != null;\n const hasSuggestions = !!suggestionValues;\n\n // Miscellaneous state\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n /**\n * Looks for the node that represent the input inside the material tree and focus it.\n */\n const focusInput = () => {\n inputRef.current?.focus();\n };\n\n const isMounted = useIsMounted();\n\n /**\n * Clears the suggestion array.\n */\n const suggestionClearHandler = () => {\n if (isMounted.current) {\n setSuggestionValues(null);\n }\n };\n\n /**\n * Fills of the suggestion array.\n */\n const suggestionHandler = (val: string) => {\n const suggestionsArray = suggestionListCallback?.(val);\n if (suggestionsArray?.[0]?.label) {\n setSuggestionValues(suggestionsArray);\n } else {\n suggestionClearHandler();\n }\n };\n\n /**\n * Executes the user callback adds the selection to the state and clears the suggestions.\n */\n const suggestionSelectedHandler: HvSuggestionsProps[\"onSuggestionSelected\"] =\n (event, item) => {\n const newValue = item.value || (item.label as any);\n\n changeInputValue(inputRef.current, newValue);\n\n focusInput();\n suggestionClearHandler();\n\n if (type === \"search\") {\n // trigger the onEnter callback when the user selects an option in a search box\n onEnter?.(event, newValue);\n }\n };\n\n const onChangeHandler: HvBaseInputProps[\"onChange\"] = (event, newValue) => {\n isDirty.current = true;\n\n // set the input value (only when value is uncontrolled)\n setValue(newValue);\n\n onChange?.(event, newValue);\n\n if (canShowSuggestions) {\n // an edge case might be a controlled input whose onChange callback\n // doesn't change the value (or sets another): the suggestionListCallback\n // callback will still receive the original rejected value.\n // a refactor is needed so the suggestionListCallback might be called only\n // when the input is uncontrolled, providing a way to externally control\n // the suggestion values.\n suggestionHandler(newValue);\n }\n };\n\n /**\n * Validates the input updating the state and modifying the info text, also executes\n * the user provided onBlur passing the current validation status and value.\n */\n const onInputBlurHandler: HvBaseInputProps[\"onBlur\"] = (event) => {\n // If the blur is executed when choosing an suggestion it should be ignored.\n if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;\n\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler: HvBaseInputProps[\"onFocus\"] = (event) => {\n setFocused(true);\n\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const getSuggestions = (li: number | null) => {\n // TODO Replace with ref\n const listEl = document.getElementById(\n setId(elementId, \"suggestions-list\") || \"\"\n );\n return li != null ? listEl?.getElementsByTagName(\"li\")?.[li] : listEl;\n };\n\n const onSuggestionKeyDown: HvSuggestionsProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Esc\")) {\n suggestionClearHandler();\n focusInput();\n } else if (isKey(event, \"Tab\")) {\n suggestionClearHandler();\n }\n };\n\n /** Focus the suggestion list when the arrow down is pressed. */\n const onKeyDownHandler: HvBaseInputProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"ArrowDown\") && hasSuggestions) {\n const li = getSuggestions(0);\n li?.focus();\n } else if (isKey(event, \"Enter\")) {\n onEnter?.(event, value);\n }\n\n onKeyDown?.(event, value);\n };\n\n /** Clears the suggestion list on blur. */\n const onContainerBlurHandler: HvFormElementProps[\"onBlur\"] = (event) => {\n if (event.relatedTarget) {\n setTimeout(() => {\n const list = getSuggestions(null);\n if (!list?.contains(document.activeElement)) suggestionClearHandler();\n }, 10);\n }\n };\n\n const hasOnEnter = onEnter != null;\n\n // show the clear button only if the input is enabled, not read-only, disableClear is false and the input is not empty\n // also, don't show it when the input type is \"search\" and the input is active (standBy)\n const showClear =\n !disabled &&\n !readOnly &&\n !disableClear &&\n !isEmptyValue &&\n (!hasOnEnter ||\n type !== \"search\" ||\n disableSearchButton ||\n validationState !== validationStates.standBy);\n\n const showSearchIcon = type === \"search\" && !disableSearchButton;\n\n const showRevealPasswordButton =\n type === \"password\" && !disableRevealPassword;\n\n /**\n * Clears the input value from the state and refocus the input.\n */\n const handleClear = useCallback(() => {\n // reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n changeInputValue(inputRef.current, \"\");\n\n // we want to focus the input when clicked and not active\n setTimeout(focusInput);\n }, [setValidationState]);\n\n const clearButton = useMemo(() => {\n if (!showClear) {\n return null;\n }\n\n return (\n <HvAdornment\n // Don't control visibility when the search icon is enabled\n className={cx(classes.adornmentButton, {\n [classes.iconClear]: !showSearchIcon,\n })}\n onClick={handleClear}\n aria-label={labels?.clearButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={<CloseXS />}\n />\n );\n }, [\n showClear,\n classes.adornmentButton,\n classes.iconClear,\n showSearchIcon,\n handleClear,\n labels?.clearButtonLabel,\n elementId,\n cx,\n ]);\n\n /**\n * Calls the onEnter callback and refocus the input.\n */\n const handleSearch = useCallback<NonNullable<HvAdornmentProps[\"onClick\"]>>(\n (event) => {\n onEnter?.(event, value);\n },\n [onEnter, value]\n );\n\n const searchButton = useMemo(() => {\n // If the search icon is not actionable, only show it when the input is empty or active\n const reallyShowIt =\n showSearchIcon &&\n (isEmptyValue ||\n (hasOnEnter && validationState === validationStates.standBy));\n\n if (!reallyShowIt) {\n return null;\n }\n\n return (\n <HvAdornment\n className={classes.adornmentButton}\n onClick={hasOnEnter ? handleSearch : undefined}\n aria-label={labels?.searchButtonLabel}\n icon={<Search />}\n />\n );\n }, [\n showSearchIcon,\n isEmptyValue,\n hasOnEnter,\n validationState,\n classes.adornmentButton,\n handleSearch,\n labels?.searchButtonLabel,\n ]);\n\n /**\n * Changes input type and refocus the input.\n */\n const handleRevealPassword = useCallback(() => {\n setRevealPassword(!revealPassword);\n }, [revealPassword]);\n\n const revealPasswordButton = useMemo(() => {\n if (!showRevealPasswordButton) {\n return null;\n }\n\n return (\n <HvTooltip\n disableFocusListener\n disableTouchListener\n title={\n revealPassword\n ? labels?.revealPasswordButtonClickToHideTooltip\n : labels?.revealPasswordButtonClickToShowTooltip\n }\n >\n <HvAdornment\n className={classes.adornmentButton}\n onClick={handleRevealPassword}\n aria-label={labels?.revealPasswordButtonLabel}\n aria-controls={setId(elementId, \"input\")}\n icon={revealPassword ? <PreviewOff /> : <Preview />}\n />\n </HvTooltip>\n );\n }, [\n showRevealPasswordButton,\n revealPassword,\n labels?.revealPasswordButtonClickToHideTooltip,\n labels?.revealPasswordButtonClickToShowTooltip,\n labels?.revealPasswordButtonLabel,\n classes.adornmentButton,\n handleRevealPassword,\n elementId,\n ]);\n\n const validationIcon = useMemo(() => {\n if (!showValidationIcon) {\n return null;\n }\n\n if (!isValid(validationState)) {\n return null;\n }\n\n return <Success color=\"positive\" className={classes.icon} />;\n }, [showValidationIcon, validationState, classes.icon]);\n\n // useMemo to avoid repetitive cloning of the custom icon\n const customIconEl = useMemo(\n () =>\n isValidElement(endAdornment) &&\n React.cloneElement(endAdornment as React.ReactElement, {\n className: cx(endAdornment.props.className, classes.icon),\n }),\n [classes.icon, endAdornment, cx]\n );\n\n const adornments = useMemo(() => {\n if (\n !clearButton &&\n !revealPasswordButton &&\n !searchButton &&\n !validationIcon &&\n !customIconEl\n )\n return null;\n\n // note: specification implies that the custom icon should be hidden when\n // a validation feedback icon is being shown.\n return (\n <div className={classes.adornmentsBox} aria-hidden=\"true\">\n {clearButton}\n {revealPasswordButton}\n {searchButton}\n {validationIcon || customIconEl}\n </div>\n );\n }, [\n classes.adornmentsBox,\n clearButton,\n customIconEl,\n revealPasswordButton,\n searchButton,\n validationIcon,\n ]);\n\n // run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(\n classes.root,\n {\n [classes.hasSuggestions]: hasSuggestions,\n },\n className\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n className={classes.label}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseInput\n id={\n hasLabel || showClear || showRevealPasswordButton\n ? setId(elementId, \"input\")\n : setId(id, \"input\")\n }\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onKeyDown={onKeyDownHandler}\n onBlur={onInputBlurHandler}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n type={realType}\n classes={{\n input: classes.input,\n inputRoot: classes.inputRoot,\n inputRootFocused: classes.inputRootFocused,\n inputRootDisabled: classes.inputRootDisabled,\n inputRootMultiline: classes.inputRootMultiline,\n inputBorderContainer: classes.inputBorderContainer,\n }}\n invalid={isStateInvalid}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : description\n ? setId(elementId, \"description\")\n : undefined,\n \"aria-controls\": canShowSuggestions\n ? setId(elementId, \"suggestions\")\n : undefined,\n\n ref: inputRef,\n\n // prevent browsers auto-fill/suggestions when we have our own\n autoComplete: canShowSuggestions ? \"off\" : undefined,\n\n ...inputProps,\n }}\n inputRef={forkedRef}\n endAdornment={adornments}\n {...others}\n />\n {canShowSuggestions && (\n <>\n {hasSuggestions && (\n <div role=\"presentation\" className={classes.inputExtension} />\n )}\n <HvSuggestions\n ref={suggestionsRef}\n id={setId(elementId, \"suggestions\")}\n classes={{\n root: classes.suggestionsContainer,\n list: classes.suggestionList,\n }}\n expanded={hasSuggestions}\n anchorEl={inputRef.current?.parentElement}\n onClose={suggestionClearHandler}\n onKeyDown={onSuggestionKeyDown}\n onSuggestionSelected={suggestionSelectedHandler}\n suggestionValues={suggestionValues}\n />\n </>\n )}\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["isBrowser","forwardRef","useDefaultProps","useClasses","useLabels","useUniqueId","useRef","useForkRef","useState","useControlled","validationStates","useMemo","DEFAULT_ERROR_MESSAGES","computeValidationType","useCallback","validateInput","computeValidationState","computeValidationMessage","hasBuiltInValidations","isInvalid","useIsMounted","setId","isKey","jsx","HvAdornment","CloseXS","Search","HvTooltip","PreviewOff","Preview","isValid","Success","isValidElement","React","useEffect","jsxs","HvFormElement","HvLabel","HvInfoMessage","HvBaseInput","Fragment","HvSuggestions","HvWarningText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoMA,MAAM,iBAAiB;AAAA,EACrB,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EAC3B,wCAAwC;AAAA,EACxC,wCAAwC;AAAA,EACxC,mBAAmB;AACrB;AAKA,MAAM,oBAAoB,CAAC,UACzBA,kBAAU,IAAI,IAAI,SAAS,gBAAgB,MAAM;AAEnD,SAAS,6BACP,WACA,OACA;AACA,SAAO,aAAa,QAAQ,UAAU,SAAS,kBAAkB,KAAK,CAAC;AACzE;AAGA,MAAM,mBAAmB,CAAC,OAAgC,QAAQ,OAAO;AACvE,QAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,MAAM;AAGlD,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,iBAAiB;AAAA,IACxB;AAAA,EACC,GAAA;AAEY,iBAAA,KAAK,OAAO,KAAK;AAChC,SAAO,cAAc,KAAK;AAC5B;AAKO,MAAM,UAAUC,MAAA,WAAuC,CAAC,OAAO,QAAQ;AACtE,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;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QAAA,GACF;AAAA,QAED,gBACCE,2BAAA;AAAA,UAACmB,YAAA;AAAA,UAAA;AAAA,YACC,IAAIrB,MAAAA,MAAM,WAAW,OAAO;AAAA,YAC5B,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;;;"}
|
|
@@ -1,14 +1,12 @@
|
|
|
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");
|
|
5
4
|
const useDefaultProps = require("../../hooks/useDefaultProps.cjs");
|
|
6
5
|
const useUniqueId = require("../../hooks/useUniqueId.cjs");
|
|
7
6
|
const keyboardUtils = require("../../utils/keyboardUtils.cjs");
|
|
8
7
|
const setId = require("../../utils/setId.cjs");
|
|
9
8
|
const ScrollToVertical_styles = require("./ScrollToVertical.styles.cjs");
|
|
10
9
|
const useScrollTo = require("../useScrollTo.cjs");
|
|
11
|
-
const withTooltip = require("../withTooltip.cjs");
|
|
12
10
|
const VerticalScrollListItem = require("./VerticalScrollListItem/VerticalScrollListItem.cjs");
|
|
13
11
|
const HvScrollToVertical = (props) => {
|
|
14
12
|
const {
|
|
@@ -45,35 +43,26 @@ const HvScrollToVertical = (props) => {
|
|
|
45
43
|
};
|
|
46
44
|
setScrollTo(event, value, index, wrappedOnChange);
|
|
47
45
|
};
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
id: setId.setId(elementId, `item-${index}`),
|
|
60
|
-
onClick: (event) => {
|
|
46
|
+
const tabs = options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
VerticalScrollListItem.HvVerticalScrollListItem,
|
|
48
|
+
{
|
|
49
|
+
id: setId.setId(elementId, `item-${index}`),
|
|
50
|
+
onClick: (event) => {
|
|
51
|
+
handleSelection(event, option.value, index);
|
|
52
|
+
onClick?.(event, index);
|
|
53
|
+
},
|
|
54
|
+
onKeyDown: (event) => {
|
|
55
|
+
if (keyboardUtils.isKey(event, "Enter") === true) {
|
|
61
56
|
handleSelection(event, option.value, index);
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
onKeyDown: (event) => {
|
|
65
|
-
if (keyboardUtils.isKey(event, "Enter") === true) {
|
|
66
|
-
handleSelection(event, option.value, index);
|
|
67
|
-
onEnter?.(event, index);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
tooltipWrapper,
|
|
71
|
-
selected,
|
|
72
|
-
"aria-label": option.label
|
|
57
|
+
onEnter?.(event, index);
|
|
58
|
+
}
|
|
73
59
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
tooltipPlacement: tooltipPosition,
|
|
61
|
+
selected: selectedIndex === index,
|
|
62
|
+
label: option.label
|
|
63
|
+
},
|
|
64
|
+
option.key || option.label
|
|
65
|
+
));
|
|
77
66
|
const positionOffset = ScrollToVertical_styles.calculateOffset(options.length);
|
|
78
67
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
68
|
"ol",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollToVertical.cjs","sources":["../../../../src/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ScrollToVertical.cjs","sources":["../../../../src/ScrollTo/Vertical/ScrollToVertical.tsx"],"sourcesContent":["import { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { useUniqueId } from \"../../hooks/useUniqueId\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\n\nimport {\n staticClasses,\n useClasses,\n calculateOffset,\n} from \"./ScrollToVertical.styles\";\nimport { HvVerticalScrollListItem } from \"./VerticalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport {\n HvScrollToTooltipPositions,\n HvScrollToVerticalOption,\n HvScrollToVerticalPositions,\n} from \"../types\";\n\nexport { staticClasses as scrollToVerticalClasses };\n\nexport type HvScrollToVerticalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToVerticalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToVerticalOption[];\n /** True if the href location link should be applied. It will create an a element around every list item */\n href?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Vertical scroll to. */\n position?: HvScrollToVerticalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, index: number) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (event: React.KeyboardEvent<HTMLDivElement>, index: number) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToVerticalClasses;\n}\n\n/**\n * The vertical scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToVertical = (props: HvScrollToVerticalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"left\",\n style,\n ...others\n } = useDefaultProps(\"HvScrollToVertical\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvVerticalScrollto\");\n\n const [selectedIndex, setScrollTo] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n href,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tabs = options.map((option, index) => (\n <HvVerticalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n />\n ));\n\n const positionOffset = calculateOffset(options.length);\n\n return (\n <ol\n className={cx(\n classes.root,\n {\n [classes.positionFixed]: position === \"fixed\",\n [classes.positionAbsolute]: position === \"absolute\",\n },\n className\n )}\n style={{ top: `calc(50% - ${positionOffset}px)`, ...style }}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useDefaultProps","useClasses","useUniqueId","useScrollTo","jsx","HvVerticalScrollListItem","setId","isKey","calculateOffset"],"mappings":";;;;;;;;;;AAqEa,MAAA,qBAAqB,CAAC,UAAmC;AAC9D,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,I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AAAA,UACE,CAAC,QAAQ,aAAa,GAAG,aAAa;AAAA,UACtC,CAAC,QAAQ,gBAAgB,GAAG,aAAa;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,EAAE,KAAK,cAAc,cAAc,OAAO,GAAG,MAAM;AAAA,MAC1D,IAAI;AAAA,MACH,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;;;"}
|
|
@@ -2,50 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
4
|
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
5
|
-
const setId = require("../../../utils/setId.cjs");
|
|
6
5
|
const useTheme = require("../../../hooks/useTheme.cjs");
|
|
7
6
|
const useDefaultProps = require("../../../hooks/useDefaultProps.cjs");
|
|
8
7
|
const VerticalScrollListItem_styles = require("./VerticalScrollListItem.styles.cjs");
|
|
8
|
+
const Tooltip = require("../../../Tooltip/Tooltip.cjs");
|
|
9
9
|
const HvVerticalScrollListItem = (props) => {
|
|
10
10
|
const {
|
|
11
11
|
id,
|
|
12
12
|
className,
|
|
13
13
|
classes: classesProp,
|
|
14
14
|
selected,
|
|
15
|
-
|
|
15
|
+
label,
|
|
16
16
|
onClick,
|
|
17
17
|
onKeyDown,
|
|
18
|
-
|
|
18
|
+
tooltipPlacement = "left",
|
|
19
19
|
...others
|
|
20
20
|
} = useDefaultProps.useDefaultProps("HvVerticalScrollListItem", props);
|
|
21
21
|
const { classes, cx } = VerticalScrollListItem_styles.useClasses(classesProp);
|
|
22
22
|
const { activeTheme } = useTheme.useTheme();
|
|
23
|
-
const variant = selected ? "label" : "body";
|
|
24
|
-
const labelId = setId.setId(id, "label");
|
|
25
|
-
const buttonId = setId.setId(id, "button");
|
|
26
|
-
const Tooltip = tooltipWrapper;
|
|
27
23
|
const icon = selected ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
28
24
|
uikitReactIcons.CurrentStep,
|
|
29
25
|
{
|
|
30
26
|
height: activeTheme?.scrollTo.dotSelectedSize,
|
|
31
27
|
width: activeTheme?.scrollTo.dotSelectedSize
|
|
32
28
|
}
|
|
33
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
34
|
-
return /* @__PURE__ */ jsxRuntime.jsx("li", { id, className: cx(classes.root, className), "aria-current": selected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
29
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.notSelected });
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { id, className: cx(classes.root, className), "aria-current": selected, children: /* @__PURE__ */ jsxRuntime.jsx(Tooltip.HvTooltip, { title: label, placement: tooltipPlacement, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35
31
|
"div",
|
|
36
32
|
{
|
|
37
|
-
id: buttonId,
|
|
38
33
|
role: "button",
|
|
39
34
|
tabIndex: 0,
|
|
40
35
|
onClick,
|
|
41
36
|
onKeyDown,
|
|
42
|
-
className: classes.button,
|
|
43
|
-
"aria-label": ariaLabel,
|
|
44
|
-
"aria-labelledby": labelId,
|
|
37
|
+
className: cx(classes.button, classes.text),
|
|
45
38
|
...others,
|
|
46
|
-
children:
|
|
39
|
+
children: icon
|
|
47
40
|
}
|
|
48
|
-
) });
|
|
41
|
+
) }) });
|
|
49
42
|
};
|
|
50
43
|
exports.verticalScrollListItemClasses = VerticalScrollListItem_styles.staticClasses;
|
|
51
44
|
exports.HvVerticalScrollListItem = HvVerticalScrollListItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalScrollListItem.cjs","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.tsx"],"sourcesContent":["import { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"../../../types/generic\";\nimport {
|
|
1
|
+
{"version":3,"file":"VerticalScrollListItem.cjs","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.tsx"],"sourcesContent":["import { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"../../../types/generic\";\nimport { HvTooltip, HvTooltipProps } from \"../../../Tooltip\";\nimport { ExtractNames } from \"../../../utils/classes\";\nimport { useTheme } from \"../../../hooks/useTheme\";\nimport { useDefaultProps } from \"../../../hooks/useDefaultProps\";\n\nimport { staticClasses, useClasses } from \"./VerticalScrollListItem.styles\";\n\nexport { staticClasses as verticalScrollListItemClasses };\n\nexport type HvVerticalScrollListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvVerticalScrollListItemProps\n extends HvBaseProps<HTMLDivElement> {\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvVerticalScrollListItemClasses;\n /** Whether the element is selected. */\n selected?: boolean;\n label?: React.ReactNode;\n tooltipPlacement?: HvTooltipProps[\"placement\"];\n}\n\n/**\n * HvVerticalScrollListItem a focusable item to be used as part of the vertical scroll\n */\nexport const HvVerticalScrollListItem = (\n props: HvVerticalScrollListItemProps\n) => {\n const {\n id,\n className,\n classes: classesProp,\n selected,\n label,\n onClick,\n onKeyDown,\n tooltipPlacement = \"left\",\n ...others\n } = useDefaultProps(\"HvVerticalScrollListItem\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const icon = selected ? (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n />\n ) : (\n <div className={classes.notSelected} />\n );\n\n return (\n <li id={id} className={cx(classes.root, className)} aria-current={selected}>\n <HvTooltip title={label} placement={tooltipPlacement}>\n <div\n role=\"button\"\n tabIndex={0}\n onClick={onClick}\n onKeyDown={onKeyDown}\n className={cx(classes.button, classes.text)}\n {...others}\n >\n {icon}\n </div>\n </HvTooltip>\n </li>\n );\n};\n"],"names":["useDefaultProps","useClasses","useTheme","jsx","CurrentStep","HvTooltip"],"mappings":";;;;;;;;AA2Ba,MAAA,2BAA2B,CACtC,UACG;AACG,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB,GAAG;AAAA,EAAA,IACDA,gBAAgB,gBAAA,4BAA4B,KAAK;AACrD,QAAM,EAAE,SAAS,GAAG,IAAIC,yCAAW,WAAW;AACxC,QAAA,EAAE,gBAAgBC,SAAAA;AAExB,QAAM,OAAO,WACXC,2BAAA;AAAA,IAACC,gBAAA;AAAA,IAAA;AAAA,MACC,QAAQ,aAAa,SAAS;AAAA,MAC9B,OAAO,aAAa,SAAS;AAAA,IAAA;AAAA,EAAA,IAG/BD,2BAAAA,IAAC,OAAI,EAAA,WAAW,QAAQ,YAAa,CAAA;AAGvC,wCACG,MAAG,EAAA,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAG,gBAAc,UAChE,UAACA,+BAAAE,QAAAA,WAAA,EAAU,OAAO,OAAO,WAAW,kBAClC,UAAAF,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,WAAW,GAAG,QAAQ,QAAQ,QAAQ,IAAI;AAAA,MACzC,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA,EAEL,CAAA,EACF,CAAA;AAEJ;;;"}
|
|
@@ -20,13 +20,8 @@ const { staticClasses, useClasses } = classes.createClasses(name, {
|
|
|
20
20
|
display: "inline-block",
|
|
21
21
|
backgroundColor: uikitStyles.theme.colors.secondary_60
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
width: "16px",
|
|
26
|
-
display: "flex",
|
|
27
|
-
justifyContent: "center",
|
|
28
|
-
alignItems: "center"
|
|
29
|
-
},
|
|
23
|
+
// TODO: remove in v6 (use classes.button)
|
|
24
|
+
text: {},
|
|
30
25
|
button: {
|
|
31
26
|
display: "flex",
|
|
32
27
|
justifyContent: "center",
|
package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalScrollListItem.styles.cjs","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../../../utils/focusUtils\";\n\nimport { createClasses } from \"../../../utils/classes\";\n\nconst name = \"HvVerticalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: \"0\",\n height: \"32px\",\n width: \"32px\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n notSelected: {\n height: \"4px\",\n width: \"4px\",\n borderRadius: \"50%\",\n display: \"inline-block\",\n backgroundColor: theme.colors.secondary_60,\n },\n
|
|
1
|
+
{"version":3,"file":"VerticalScrollListItem.styles.cjs","sources":["../../../../../src/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../../../utils/focusUtils\";\n\nimport { createClasses } from \"../../../utils/classes\";\n\nconst name = \"HvVerticalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: \"0\",\n height: \"32px\",\n width: \"32px\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n notSelected: {\n height: \"4px\",\n width: \"4px\",\n borderRadius: \"50%\",\n display: \"inline-block\",\n backgroundColor: theme.colors.secondary_60,\n },\n // TODO: remove in v6 (use classes.button)\n text: {},\n button: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: \"16px\",\n width: \"16px\",\n borderRadius: \"50%\",\n cursor: \"pointer\",\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n\n \"& $notSelected\": {\n height: \"6px\",\n width: \"6px\",\n backgroundColor: theme.colors.secondary,\n },\n },\n \"&:focus\": {\n outline: \"none\",\n },\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n});\n"],"names":["createClasses","theme","outlineStyles"],"mappings":";;;;;AAMA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAeA,QAAAA,cAAc,MAAM;AAAA,EAC/D,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,cAAc;AAAA,IACd,SAAS;AAAA,IACT,iBAAiBC,YAAAA,MAAM,OAAO;AAAA,EAChC;AAAA;AAAA,EAEA,MAAM,CAAC;AAAA,EACP,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,WAAW;AAAA,MACT,iBAAiBA,YAAAA,MAAM,OAAO;AAAA,MAE9B,kBAAkB;AAAA,QAChB,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,iBAAiBA,YAAAA,MAAM,OAAO;AAAA,MAChC;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACT,SAAS;AAAA,IACX;AAAA,IACA,mBAAmB;AAAA,MACjB,GAAGC,WAAA;AAAA,IACL;AAAA,EACF;AACF,CAAC;;;"}
|
|
@@ -5,37 +5,28 @@ const React = require("react");
|
|
|
5
5
|
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
6
6
|
const VerticalNavigationContext = require("../../VerticalNavigationContext.cjs");
|
|
7
7
|
const IconWrapper_styles = require("./IconWrapper.styles.cjs");
|
|
8
|
-
const TooltipWrapper = require("../TooltipWrapper/TooltipWrapper.cjs");
|
|
9
8
|
const Avatar = require("../../../Avatar/Avatar.cjs");
|
|
10
9
|
const IconWrapper = ({
|
|
11
10
|
icon,
|
|
12
11
|
label,
|
|
13
12
|
hasChildren,
|
|
14
13
|
showAvatar,
|
|
15
|
-
isOpen
|
|
16
|
-
disableTooltip
|
|
14
|
+
isOpen
|
|
17
15
|
}) => {
|
|
18
16
|
const { hasAnyChildWithData } = React.useContext(VerticalNavigationContext.VerticalNavigationContext);
|
|
19
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
children: label.substring(0, 1)
|
|
33
|
-
}
|
|
34
|
-
) : icon,
|
|
35
|
-
hasChildren && !isOpen ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Forwards, { iconSize: "XS" }) : hasAnyChildWithData && !isOpen && /* @__PURE__ */ jsxRuntime.jsx(IconWrapper_styles.SpacerDiv, {})
|
|
36
|
-
] })
|
|
37
|
-
}
|
|
38
|
-
);
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(IconWrapper_styles.StyledIconsContainer, { hasAnyChildWithData, children: [
|
|
18
|
+
showAvatar ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
19
|
+
Avatar.HvAvatar,
|
|
20
|
+
{
|
|
21
|
+
variant: "square",
|
|
22
|
+
size: "xs",
|
|
23
|
+
backgroundColor: "secondary_80",
|
|
24
|
+
style: { fontSize: "15px" },
|
|
25
|
+
children: label.substring(0, 1)
|
|
26
|
+
}
|
|
27
|
+
) : icon,
|
|
28
|
+
hasChildren && !isOpen ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Forwards, { iconSize: "XS" }) : hasAnyChildWithData && !isOpen && /* @__PURE__ */ jsxRuntime.jsx(IconWrapper_styles.SpacerDiv, {})
|
|
29
|
+
] });
|
|
39
30
|
};
|
|
40
31
|
exports.IconWrapper = IconWrapper;
|
|
41
32
|
//# sourceMappingURL=IconWrapper.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconWrapper.cjs","sources":["../../../../../src/VerticalNavigation/TreeView/IconWrapper/IconWrapper.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { Forwards } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvAvatar } from \"../../../Avatar\";\n\nimport { VerticalNavigationContext } from \"../../VerticalNavigationContext\";\nimport {
|
|
1
|
+
{"version":3,"file":"IconWrapper.cjs","sources":["../../../../../src/VerticalNavigation/TreeView/IconWrapper/IconWrapper.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { Forwards } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvAvatar } from \"../../../Avatar\";\n\nimport { VerticalNavigationContext } from \"../../VerticalNavigationContext\";\nimport { SpacerDiv, StyledIconsContainer } from \"./IconWrapper.styles\";\n\nexport const IconWrapper = ({\n icon,\n label,\n hasChildren,\n showAvatar,\n isOpen,\n}) => {\n const { hasAnyChildWithData } = useContext(VerticalNavigationContext);\n return (\n <StyledIconsContainer hasAnyChildWithData={hasAnyChildWithData}>\n {showAvatar ? (\n <HvAvatar\n variant=\"square\"\n size=\"xs\"\n backgroundColor=\"secondary_80\"\n style={{ fontSize: \"15px\" }}\n >\n {label.substring(0, 1)}\n </HvAvatar>\n ) : (\n icon\n )}\n\n {hasChildren && !isOpen ? (\n <Forwards iconSize=\"XS\" />\n ) : (\n hasAnyChildWithData && !isOpen && <SpacerDiv />\n )}\n </StyledIconsContainer>\n );\n};\n"],"names":["useContext","VerticalNavigationContext","jsxs","StyledIconsContainer","jsx","HvAvatar","Forwards","SpacerDiv"],"mappings":";;;;;;;;AAQO,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,oBAAA,IAAwBA,MAAA,WAAWC,0BAAyB,yBAAA;AAElE,SAAAC,gCAACC,mBAAAA,wBAAqB,qBACnB,UAAA;AAAA,IACC,aAAAC,2BAAA;AAAA,MAACC,OAAA;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,iBAAgB;AAAA,QAChB,OAAO,EAAE,UAAU,OAAO;AAAA,QAEzB,UAAA,MAAM,UAAU,GAAG,CAAC;AAAA,MAAA;AAAA,IAAA,IAGvB;AAAA,IAGD,eAAe,CAAC,SACfD,2BAAA,IAACE,gBAAS,UAAA,EAAA,UAAS,MAAK,IAExB,uBAAuB,CAAC,UAAUF,2BAAAA,IAACG,mBAAAA,WAAU,CAAA,CAAA;AAAA,EAEjD,EAAA,CAAA;AAEJ;;"}
|
|
@@ -11,6 +11,7 @@ const descendants = require("./descendants.cjs");
|
|
|
11
11
|
const TreeViewContext = require("./TreeViewContext.cjs");
|
|
12
12
|
const VerticalNavigationContext = require("../VerticalNavigationContext.cjs");
|
|
13
13
|
const IconWrapper = require("./IconWrapper/IconWrapper.cjs");
|
|
14
|
+
const Tooltip = require("../../Tooltip/Tooltip.cjs");
|
|
14
15
|
const Typography = require("../../Typography/Typography.cjs");
|
|
15
16
|
const preventSelection = (event, disabled) => {
|
|
16
17
|
if (event.shiftKey || event.ctrlKey || event.metaKey || disabled) {
|
|
@@ -261,7 +262,9 @@ const HvVerticalNavigationTreeViewItem = React.forwardRef(
|
|
|
261
262
|
href,
|
|
262
263
|
target
|
|
263
264
|
};
|
|
264
|
-
|
|
265
|
+
const hasChildren = !!children;
|
|
266
|
+
const showTooltip = !hasChildren && !isOpen && !disableTooltip;
|
|
267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tooltip.HvTooltip, { placement: "right", title: showTooltip && label, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
265
268
|
Typography.HvTypography,
|
|
266
269
|
{
|
|
267
270
|
id: setId.setId(id, "button"),
|
|
@@ -297,10 +300,9 @@ const HvVerticalNavigationTreeViewItem = React.forwardRef(
|
|
|
297
300
|
{
|
|
298
301
|
icon: useIcons && icon,
|
|
299
302
|
label: payload?.label,
|
|
300
|
-
hasChildren
|
|
303
|
+
hasChildren,
|
|
301
304
|
showAvatar: !icon && useIcons,
|
|
302
|
-
isOpen
|
|
303
|
-
disableTooltip
|
|
305
|
+
isOpen
|
|
304
306
|
}
|
|
305
307
|
),
|
|
306
308
|
isOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -316,7 +318,7 @@ const HvVerticalNavigationTreeViewItem = React.forwardRef(
|
|
|
316
318
|
isOpen && expandable && (expanded ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.DropUpXS, {}) : /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.DropDownXS, {}))
|
|
317
319
|
]
|
|
318
320
|
}
|
|
319
|
-
);
|
|
321
|
+
) });
|
|
320
322
|
}, [
|
|
321
323
|
id,
|
|
322
324
|
href,
|