@hitachivantara/uikit-react-core 5.25.0 → 5.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs +6 -6
- package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs.map +1 -1
- package/dist/cjs/components/Forms/WarningText/WarningText.cjs +1 -0
- package/dist/cjs/components/Forms/WarningText/WarningText.cjs.map +1 -1
- package/dist/cjs/components/TagsInput/TagsInput.cjs +2 -2
- package/dist/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Actions/Action.cjs +12 -5
- package/dist/cjs/components/VerticalNavigation/Actions/Action.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Actions/Action.styles.cjs +31 -34
- package/dist/cjs/components/VerticalNavigation/Actions/Action.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Actions/Actions.cjs +10 -5
- package/dist/cjs/components/VerticalNavigation/Actions/Actions.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Actions/Actions.styles.cjs +16 -19
- package/dist/cjs/components/VerticalNavigation/Actions/Actions.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Header/Header.cjs +13 -7
- package/dist/cjs/components/VerticalNavigation/Header/Header.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Header/Header.styles.cjs +21 -37
- package/dist/cjs/components/VerticalNavigation/Header/Header.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Navigation/Navigation.cjs +13 -8
- package/dist/cjs/components/VerticalNavigation/Navigation/Navigation.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Navigation/Navigation.styles.cjs +20 -17
- package/dist/cjs/components/VerticalNavigation/Navigation/Navigation.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/NavigationPopup/NavigationPopup.styles.cjs +16 -10
- package/dist/cjs/components/VerticalNavigation/NavigationPopup/NavigationPopup.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/NavigationPopup/NavigationPopupContainer.cjs +7 -1
- package/dist/cjs/components/VerticalNavigation/NavigationPopup/NavigationPopupContainer.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/NavigationSlider.cjs +10 -6
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/NavigationSlider.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/NavigationSlider.styles.cjs +19 -22
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/NavigationSlider.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeView.cjs +8 -5
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeView.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeView.styles.cjs +16 -17
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeView.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.cjs +74 -49
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.styles.cjs +106 -130
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/VerticalNavigation.cjs +13 -7
- package/dist/cjs/components/VerticalNavigation/VerticalNavigation.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/VerticalNavigation.styles.cjs +36 -36
- package/dist/cjs/components/VerticalNavigation/VerticalNavigation.styles.cjs.map +1 -1
- package/dist/cjs/index.cjs +16 -16
- package/dist/esm/components/BaseDropdown/BaseDropdown.js +6 -6
- package/dist/esm/components/BaseDropdown/BaseDropdown.js.map +1 -1
- package/dist/esm/components/Forms/WarningText/WarningText.js +1 -0
- package/dist/esm/components/Forms/WarningText/WarningText.js.map +1 -1
- package/dist/esm/components/TagsInput/TagsInput.js +2 -2
- package/dist/esm/components/TagsInput/TagsInput.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Actions/Action.js +15 -7
- package/dist/esm/components/VerticalNavigation/Actions/Action.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Actions/Action.styles.js +31 -32
- package/dist/esm/components/VerticalNavigation/Actions/Action.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Actions/Actions.js +13 -7
- package/dist/esm/components/VerticalNavigation/Actions/Actions.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Actions/Actions.styles.js +16 -17
- package/dist/esm/components/VerticalNavigation/Actions/Actions.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Header/Header.js +16 -9
- package/dist/esm/components/VerticalNavigation/Header/Header.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Header/Header.styles.js +21 -35
- package/dist/esm/components/VerticalNavigation/Header/Header.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Navigation/Navigation.js +16 -10
- package/dist/esm/components/VerticalNavigation/Navigation/Navigation.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Navigation/Navigation.styles.js +20 -15
- package/dist/esm/components/VerticalNavigation/Navigation/Navigation.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/NavigationPopup/NavigationPopup.styles.js +16 -10
- package/dist/esm/components/VerticalNavigation/NavigationPopup/NavigationPopup.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js +10 -3
- package/dist/esm/components/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/NavigationSlider/NavigationSlider.js +13 -8
- package/dist/esm/components/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/NavigationSlider/NavigationSlider.styles.js +19 -20
- package/dist/esm/components/VerticalNavigation/NavigationSlider/NavigationSlider.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/TreeView/TreeView.js +11 -7
- package/dist/esm/components/VerticalNavigation/TreeView/TreeView.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/TreeView/TreeView.styles.js +16 -15
- package/dist/esm/components/VerticalNavigation/TreeView/TreeView.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.js +77 -51
- package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.styles.js +106 -128
- package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/VerticalNavigation.js +15 -8
- package/dist/esm/components/VerticalNavigation/VerticalNavigation.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/VerticalNavigation.styles.js +36 -34
- package/dist/esm/components/VerticalNavigation/VerticalNavigation.styles.js.map +1 -1
- package/dist/esm/index.js +42 -42
- package/dist/types/index.d.ts +241 -174
- package/package.json +3 -3
- package/dist/cjs/components/VerticalNavigation/Actions/actionClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/Actions/actionClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/Actions/actionsClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/Actions/actionsClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/Header/headerClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/Header/headerClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/Navigation/navigationClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/Navigation/navigationClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/navigationSliderClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/navigationSliderClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/treeViewClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/TreeView/treeViewClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/treeViewItemClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/TreeView/treeViewItemClasses.cjs.map +0 -1
- package/dist/cjs/components/VerticalNavigation/verticalNavigationClasses.cjs +0 -8
- package/dist/cjs/components/VerticalNavigation/verticalNavigationClasses.cjs.map +0 -1
- package/dist/cjs/utils/transientOptions.cjs +0 -7
- package/dist/cjs/utils/transientOptions.cjs.map +0 -1
- package/dist/esm/components/VerticalNavigation/Actions/actionClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/Actions/actionClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/Actions/actionsClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/Actions/actionsClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/Header/headerClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/Header/headerClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/Navigation/navigationClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/Navigation/navigationClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/NavigationSlider/navigationSliderClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/NavigationSlider/navigationSliderClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/TreeView/treeViewClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/TreeView/treeViewClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/TreeView/treeViewItemClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/TreeView/treeViewItemClasses.js.map +0 -1
- package/dist/esm/components/VerticalNavigation/verticalNavigationClasses.js +0 -8
- package/dist/esm/components/VerticalNavigation/verticalNavigationClasses.js.map +0 -1
- package/dist/esm/utils/transientOptions.js +0 -7
- package/dist/esm/utils/transientOptions.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewItem.styles.cjs","sources":["../../../../../src/components/VerticalNavigation/TreeView/TreeViewItem.styles.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"TreeViewItem.styles.cjs","sources":["../../../../../src/components/VerticalNavigation/TreeView/TreeViewItem.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\n\nimport { createClasses } from \"@core/utils/classes\";\n\nconst selected = () => ({\n background: theme.colors.atmo3,\n borderLeft: theme.verticalNavigation.activeBorderLeft,\n \"& *\": {\n background: theme.colors.atmo3,\n },\n});\n\nconst hover = () => ({\n background: theme.verticalNavigation.hoverColor,\n});\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvVerticalNavigationTreeViewItem\",\n {\n node: {\n listStyle: \"none\",\n minHeight: \"32px\",\n \"&:not(:last-child)\": {\n marginBottom: \"8px\",\n },\n \"&$collapsed\": {\n \"&>$group\": {\n display: \"none\",\n },\n },\n \"&$expanded\": {\n \"&>$group\": {\n display: \"block\",\n },\n },\n \"&$link\": {\n textDecoration: \"none\",\n },\n \"&$hide\": {\n display: \"none\",\n },\n },\n content: {\n width: \"100%\",\n display: \"flex\",\n justifyContent: \"flex-start\",\n alignItems: \"center\",\n height: \"32px\",\n borderLeft: theme.verticalNavigation.inactiveBorderLeft,\n paddingRight: theme.space.xs,\n \"&$minimized\": {\n justifyContent: \"center\",\n paddingRight: 0,\n },\n \"$expandable>&\": {\n fontWeight: 600,\n },\n \"$selected>&\": selected(),\n // hover\n \":not($disabled>&):not($selected>&):hover\": hover(),\n \":not($disabled)$selected>&:hover\": {},\n\n // focus\n \":not($disabled>&):not($selected>&):focus-visible\": hover(),\n \":not($disabled>&):not($selected>&).focus-visible\": hover(),\n\n \"*:focus-visible $focused>&\": {\n ...outlineStyles,\n },\n\n \".focus-visible $focused>&\": {\n ...outlineStyles,\n },\n \"$focused>&\": {\n ...hover(),\n },\n\n \"&[disabled], &:active\": {\n outline: \"none\",\n },\n\n \"&:focus\": {\n outline: \"none\",\n },\n\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n\n \"&.focus-visible\": {\n ...outlineStyles,\n },\n\n // cursor\n cursor: \"pointer\",\n \"& *\": {\n cursor: \"pointer\",\n },\n\n \"$disabled>&\": {\n cursor: \"not-allowed\",\n \"& *\": {\n cursor: \"not-allowed\",\n },\n },\n },\n link: {},\n group: {\n margin: \"8px 0 0 0\",\n padding: 0,\n },\n disabled: {},\n expandable: {\n fontWeight: 600,\n },\n collapsed: {},\n expanded: {},\n selectable: {},\n unselectable: {},\n selected: {},\n unselected: {},\n focused: {},\n minimized: {},\n hide: {},\n label: {\n display: \"flex\",\n flexGrow: 1,\n maxWidth: \"100%\",\n },\n labelIcon: {\n maxWidth: \"calc(100% - 32px)\",\n },\n labelExpandable: {\n maxWidth: \"calc(100% - 32px)\",\n\n \"&$labelIcon\": {\n maxWidth: \"calc(100% - 64px)\",\n },\n },\n }\n);\n"],"names":["selected","background","theme","colors","atmo3","borderLeft","verticalNavigation","activeBorderLeft","hover","hoverColor","staticClasses","useClasses","createClasses","node","listStyle","minHeight","marginBottom","display","textDecoration","content","width","justifyContent","alignItems","height","inactiveBorderLeft","paddingRight","space","xs","fontWeight","outlineStyles","outline","cursor","link","group","margin","padding","disabled","expandable","collapsed","expanded","selectable","unselectable","unselected","focused","minimized","hide","label","flexGrow","maxWidth","labelIcon","labelExpandable"],"mappings":";;;;;AAMA,MAAMA,WAAWA,OAAO;AAAA,EACtBC,YAAYC,YAAAA,MAAMC,OAAOC;AAAAA,EACzBC,YAAYH,YAAAA,MAAMI,mBAAmBC;AAAAA,EACrC,OAAO;AAAA,IACLN,YAAYC,YAAAA,MAAMC,OAAOC;AAAAA,EAC3B;AACF;AAEA,MAAMI,QAAQA,OAAO;AAAA,EACnBP,YAAYC,YAAAA,MAAMI,mBAAmBG;AACvC;AAEa,MAAA;AAAA,EAAEC;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAC3C,oCACA;AAAA,EACEC,MAAM;AAAA,IACJC,WAAW;AAAA,I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,MACLA,QAAQ;AAAA,IACV;AAAA,IAEA,eAAe;AAAA,MACbA,QAAQ;AAAA,MACR,OAAO;AAAA,QACLA,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA,EACAC,MAAM,CAAC;AAAA,EACPC,OAAO;AAAA,IACLC,QAAQ;AAAA,IACRC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU,CAAC;AAAA,EACXC,YAAY;AAAA,IACVT,YAAY;AAAA,EACd;AAAA,EACAU,WAAW,CAAC;AAAA,EACZC,UAAU,CAAC;AAAA,EACXC,YAAY,CAAC;AAAA,EACbC,cAAc,CAAC;AAAA,EACfzC,UAAU,CAAC;AAAA,EACX0C,YAAY,CAAC;AAAA,EACbC,SAAS,CAAC;AAAA,EACVC,WAAW,CAAC;AAAA,EACZC,MAAM,CAAC;AAAA,EACPC,OAAO;AAAA,IACL7B,SAAS;AAAA,IACT8B,UAAU;AAAA,IACVC,UAAU;AAAA,EACZ;AAAA,EACAC,WAAW;AAAA,IACTD,UAAU;AAAA,EACZ;AAAA,EACAE,iBAAiB;AAAA,IACfF,UAAU;AAAA,IAEV,eAAe;AAAA,MACbA,UAAU;AAAA,IACZ;AAAA,EACF;AACF,CACF;;;"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const clsx = require("clsx");
|
|
4
3
|
const useDefaultProps = require("../../hooks/useDefaultProps.cjs");
|
|
5
4
|
const React = require("react");
|
|
6
|
-
const VerticalNavigation_styles = require("./VerticalNavigation.styles.cjs");
|
|
7
|
-
const verticalNavigationClasses = require("./verticalNavigationClasses.cjs");
|
|
8
5
|
const VerticalNavigationContext = require("./VerticalNavigationContext.cjs");
|
|
9
6
|
const VerticalNavigation_utils = require("./utils/VerticalNavigation.utils.cjs");
|
|
7
|
+
const VerticalNavigation_styles = require("./VerticalNavigation.styles.cjs");
|
|
10
8
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
9
|
const NavigationSlider_utils = require("./NavigationSlider/utils/NavigationSlider.utils.cjs");
|
|
12
10
|
const HvVerticalNavigation = (props) => {
|
|
13
11
|
const {
|
|
14
12
|
id,
|
|
15
13
|
className,
|
|
16
|
-
classes,
|
|
14
|
+
classes: classesProp,
|
|
17
15
|
children,
|
|
18
16
|
open = true,
|
|
19
17
|
slider = false,
|
|
20
18
|
useIcons = false,
|
|
21
19
|
...others
|
|
22
20
|
} = useDefaultProps.useDefaultProps("HvVerticalNavigation", props);
|
|
21
|
+
const {
|
|
22
|
+
classes,
|
|
23
|
+
cx
|
|
24
|
+
} = VerticalNavigation_styles.useClasses(classesProp);
|
|
23
25
|
const [parentData, setParentData] = React.useState([]);
|
|
24
26
|
const [parentSelected, setParentSelected] = React.useState();
|
|
25
27
|
const [headerTitle, setHeaderTitle] = React.useState();
|
|
@@ -54,15 +56,19 @@ const HvVerticalNavigation = (props) => {
|
|
|
54
56
|
}), [open, useIcons, slider, headerTitle, setHeaderTitle, parentItem, setParentItem, withParentData, navigateToChildHandler, navigateToParentHandler, hasAnyChildWithData, parentData, parentSelected]);
|
|
55
57
|
const content = /* @__PURE__ */ jsxRuntime.jsx(VerticalNavigationContext.VerticalNavigationContext.Provider, {
|
|
56
58
|
value,
|
|
57
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
58
60
|
id,
|
|
59
|
-
className:
|
|
60
|
-
|
|
61
|
+
className: cx(classes.root, {
|
|
62
|
+
[classes.collapsed]: !open,
|
|
63
|
+
[classes.slider]: slider,
|
|
64
|
+
[classes.childData]: hasAnyChildWithData
|
|
65
|
+
}, className),
|
|
61
66
|
...others,
|
|
62
67
|
children
|
|
63
68
|
})
|
|
64
69
|
});
|
|
65
70
|
return content;
|
|
66
71
|
};
|
|
72
|
+
exports.verticalNavigationClasses = VerticalNavigation_styles.staticClasses;
|
|
67
73
|
exports.HvVerticalNavigation = HvVerticalNavigation;
|
|
68
74
|
//# sourceMappingURL=VerticalNavigation.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalNavigation.cjs","sources":["../../../../src/components/VerticalNavigation/VerticalNavigation.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"VerticalNavigation.cjs","sources":["../../../../src/components/VerticalNavigation/VerticalNavigation.tsx"],"sourcesContent":["import { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport {\n VerticalNavigationContext,\n NavigationData,\n} from \"./VerticalNavigationContext\";\nimport {\n fillDataWithParentId,\n getNavigationItemById,\n getParentItemById,\n} from \"./NavigationSlider/utils\";\nimport { hasChildNavigationItems } from \"./utils/VerticalNavigation.utils\";\n\nimport { staticClasses, useClasses } from \"./VerticalNavigation.styles\";\n\nexport { staticClasses as verticalNavigationClasses };\n\nexport type HvVerticalNavigationClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvVerticalNavigationProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvVerticalNavigationClasses;\n /**\n * Current State of the Vertical Navigation Collapse\n */\n open?: boolean;\n /**\n * Collpased Mode for the Vertical Navigation, the default value is \"simple\".\n *\n * @deprecated - `useIcons` property should be used instead.\n */\n collapsedMode?: HvVerticalNavigationMode;\n /**\n * Boolean to determine if treeview is in slider mode (for mobile navigation), the default value is false.\n */\n slider?: boolean;\n /**\n * The content inside the actions container.\n */\n children?: React.ReactNode;\n /**\n * Boolean to determine if icons should be displayed in the navigation menu.\n * When `true` a icon will always be displayed, if no icon is provided the first letter of the label will be\n * displayed inside an Avatar component.\n * When `false` no icons will be shown, even if an icon is provided.\n */\n useIcons?: boolean;\n}\n\n/**\n * Navigation enables users to move through an app to complete tasks.\n *\n * It is recommended to use vertical navigation when your application requires global navigation that is displayed on the left.\n * While vertical navigation menus generally consume more space than their horizontal counterparts, they have become more popular as desktop monitors move to wide-screen formats.\n *\n * Although both the hierarchically organized data and the visual style resemble a treeview-like structure, the [Treeview Design Pattern](https://w3c.github.io/aria-practices/#TreeView)\n * isn't necessarily the most appropriate.\n *\n * The tree role provides complex functionality that is not needed for typical site navigation, and changes the most common keyboard navigation using TAB.\n *\n * The [Disclosure Design Pattern](https://w3c.github.io/aria-practices/#disclosure) is more suited for typical site navigation, with expandable groups of links.\n * However it can be tedious to TAB through all navigation items to reach the actions panel.\n *\n * Both modes are available via the `mode` property and each app should choose the most appropriate.\n */\nexport const HvVerticalNavigation = (props: HvVerticalNavigationProps) => {\n const {\n id,\n className,\n classes: classesProp,\n\n children,\n\n open = true,\n\n slider = false,\n\n useIcons = false,\n\n ...others\n } = useDefaultProps(\"HvVerticalNavigation\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const [parentData, setParentData] = useState<NavigationData[]>([]);\n\n const [parentSelected, setParentSelected] = useState();\n\n const [headerTitle, setHeaderTitle] = useState<string | undefined>();\n\n // navigationSlider\n const withParentData = useMemo(\n () => fillDataWithParentId(parentData),\n [parentData]\n );\n\n const initialParentItem = useMemo(\n () => getParentItemById(withParentData, parentSelected),\n [withParentData, parentSelected]\n );\n\n const [parentItem, setParentItem] = useState(initialParentItem);\n\n const hasAnyChildWithData = useMemo(\n () => hasChildNavigationItems(parentData),\n [parentData]\n );\n\n useEffect(\n () => setHeaderTitle(parentItem?.label),\n [parentItem, setParentItem]\n );\n\n const navigateToParentHandler = useCallback(() => {\n setParentItem(getParentItemById(withParentData, parentItem.id));\n }, [parentItem, setParentItem, withParentData]);\n\n const navigateToChildHandler = useCallback(\n (event, item) => {\n setParentItem(getNavigationItemById(withParentData, item.id));\n event.stopPropagation();\n },\n [setParentItem, withParentData]\n );\n\n const value = useMemo(\n () => ({\n isOpen: open,\n useIcons,\n slider,\n headerTitle,\n setHeaderTitle,\n\n parentItem,\n setParentItem,\n withParentData,\n navigateToChildHandler,\n navigateToParentHandler,\n\n parentData,\n setParentData,\n parentSelected,\n setParentSelected,\n hasAnyChildWithData,\n }),\n [\n open,\n useIcons,\n slider,\n headerTitle,\n setHeaderTitle,\n parentItem,\n setParentItem,\n withParentData,\n navigateToChildHandler,\n navigateToParentHandler,\n hasAnyChildWithData,\n parentData,\n parentSelected,\n ]\n );\n\n const content = (\n <VerticalNavigationContext.Provider value={value}>\n <div\n id={id}\n className={cx(\n classes.root,\n {\n [classes.collapsed]: !open,\n [classes.slider]: slider,\n [classes.childData]: hasAnyChildWithData,\n },\n className\n )}\n {...others}\n >\n {children}\n </div>\n </VerticalNavigationContext.Provider>\n );\n\n return content;\n};\n\nexport type HvVerticalNavigationMode = \"icon\" | \"simple\";\n\nexport type HvVerticalNavigationPosition =\n | \"static\"\n | \"relative\"\n | \"fixed\"\n | \"absolute\";\n"],"names":["HvVerticalNavigation","props","id","className","classes","classesProp","children","open","slider","useIcons","others","useDefaultProps","cx","useClasses","parentData","setParentData","useState","parentSelected","setParentSelected","headerTitle","setHeaderTitle","withParentData","useMemo","fillDataWithParentId","initialParentItem","getParentItemById","parentItem","setParentItem","hasAnyChildWithData","hasChildNavigationItems","useEffect","label","navigateToParentHandler","useCallback","navigateToChildHandler","event","item","getNavigationItemById","stopPropagation","value","isOpen","content","VerticalNavigationContext","Provider","root","collapsed","childData"],"mappings":";;;;;;;;;AA8EaA,MAAAA,uBAAuBA,CAACC,UAAqC;AAClE,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IAETC;AAAAA,IAEAC,OAAO;AAAA,IAEPC,SAAS;AAAA,IAETC,WAAW;AAAA,IAEX,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,wBAAwBV,KAAK;AAC3C,QAAA;AAAA,IAAEG;AAAAA,IAASQ;AAAAA,EAAAA,IAAOC,0BAAAA,WAAWR,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AE,UACAD,QACAW,aACAC,gBACAM,YACAC,eACAN,gBACAa,wBACAF,yBACAJ,qBACAd,YACAG,cAAc,CAElB;AAEMwB,QAAAA,UACHC,2BAAAA,IAAAA,0BAAAA,0BAA0BC,UAAQ;AAAA,IAACJ;AAAAA,IAAajC,yCAC/C,OAAA;AAAA,MACEJ;AAAAA,MACAC,WAAWS,GACTR,QAAQwC,MACR;AAAA,QACE,CAACxC,QAAQyC,SAAS,GAAG,CAACtC;AAAAA,QACtB,CAACH,QAAQI,MAAM,GAAGA;AAAAA,QAClB,CAACJ,QAAQ0C,SAAS,GAAGlB;AAAAA,SAEvBzB,SACF;AAAA,MAAE,GACEO;AAAAA,MAAMJ;AAAAA,IAAAA,CAGP;AAAA,EAAA,CAC6B;AAG/BmC,SAAAA;AACT;;;"}
|
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const classes = require("../../utils/classes.cjs");
|
|
4
4
|
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
const {
|
|
6
|
+
staticClasses,
|
|
7
|
+
useClasses
|
|
8
|
+
} = classes.createClasses("HvVerticalNavigation", {
|
|
9
|
+
root: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
justifyContent: uikitStyles.theme.verticalNavigation.justifyContent,
|
|
13
|
+
width: "220px",
|
|
14
|
+
background: uikitStyles.theme.colors.atmo1,
|
|
15
|
+
boxShadow: uikitStyles.theme.colors.shadow,
|
|
16
|
+
clipPath: "inset(0px -12px 0px 0px)",
|
|
17
|
+
"& > :only-child": {
|
|
18
|
+
padding: uikitStyles.theme.space.sm
|
|
19
|
+
},
|
|
20
|
+
"& > :not(nav:first-of-type)": {
|
|
21
|
+
borderTop: `3px solid ${uikitStyles.theme.colors.atmo2}`,
|
|
22
|
+
padding: uikitStyles.theme.spacing(["xs", "sm", "sm", "sm"])
|
|
23
|
+
},
|
|
24
|
+
"& > :first-of-type:not(:last-child)": {
|
|
25
|
+
borderTop: "none",
|
|
26
|
+
padding: uikitStyles.theme.spacing(["sm", "sm", "xs", "sm"])
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
collapsed: {
|
|
30
|
+
width: "56px",
|
|
31
|
+
"&$childData": {
|
|
32
|
+
width: "66px"
|
|
33
|
+
},
|
|
25
34
|
"& > :first-of-type:not(:last-child)": {
|
|
26
35
|
padding: uikitStyles.theme.spacing(["sm", "xs", "xs", "xs"])
|
|
27
36
|
},
|
|
@@ -29,22 +38,13 @@ const StyledRoot = /* @__PURE__ */ _styled__default.default("div", process.env.N
|
|
|
29
38
|
padding: uikitStyles.theme.spacing(["xs", "xs", "sm", "xs"])
|
|
30
39
|
}
|
|
31
40
|
},
|
|
32
|
-
|
|
33
|
-
padding: uikitStyles.theme.space.sm
|
|
34
|
-
},
|
|
35
|
-
"& > :not(nav:first-of-type)": {
|
|
36
|
-
borderTop: `3px solid ${uikitStyles.theme.colors.atmo2}`,
|
|
37
|
-
padding: uikitStyles.theme.spacing(["xs", "sm", "sm", "sm"])
|
|
38
|
-
},
|
|
39
|
-
"& > :first-of-type:not(:last-child)": {
|
|
40
|
-
borderTop: "none",
|
|
41
|
-
padding: uikitStyles.theme.spacing(["sm", "sm", "xs", "sm"])
|
|
42
|
-
},
|
|
43
|
-
[`&.${verticalNavigationClasses.default.slider}`]: {
|
|
41
|
+
slider: {
|
|
44
42
|
"& > div:first-of-type": {
|
|
45
43
|
borderBottom: `3px solid ${uikitStyles.theme.colors.atmo2}`
|
|
46
44
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
},
|
|
46
|
+
childData: {}
|
|
47
|
+
});
|
|
48
|
+
exports.staticClasses = staticClasses;
|
|
49
|
+
exports.useClasses = useClasses;
|
|
50
50
|
//# sourceMappingURL=VerticalNavigation.styles.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalNavigation.styles.cjs","sources":["../../../../src/components/VerticalNavigation/VerticalNavigation.styles.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"VerticalNavigation.styles.cjs","sources":["../../../../src/components/VerticalNavigation/VerticalNavigation.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvVerticalNavigation\",\n {\n root: {\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: theme.verticalNavigation.justifyContent,\n\n width: \"220px\",\n\n background: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n clipPath: \"inset(0px -12px 0px 0px)\",\n\n \"& > :only-child\": {\n padding: theme.space.sm,\n },\n \"& > :not(nav:first-of-type)\": {\n borderTop: `3px solid ${theme.colors.atmo2}`,\n padding: theme.spacing([\"xs\", \"sm\", \"sm\", \"sm\"]),\n },\n\n \"& > :first-of-type:not(:last-child)\": {\n borderTop: \"none\",\n padding: theme.spacing([\"sm\", \"sm\", \"xs\", \"sm\"]),\n },\n },\n collapsed: {\n width: \"56px\",\n \"&$childData\": {\n width: \"66px\",\n },\n \"& > :first-of-type:not(:last-child)\": {\n padding: theme.spacing([\"sm\", \"xs\", \"xs\", \"xs\"]),\n },\n\n \"& > :not(nav:first-of-type)\": {\n padding: theme.spacing([\"xs\", \"xs\", \"sm\", \"xs\"]),\n },\n },\n\n slider: {\n \"& > div:first-of-type\": {\n borderBottom: `3px solid ${theme.colors.atmo2}`,\n },\n },\n\n childData: {},\n }\n);\n"],"names":["staticClasses","useClasses","createClasses","root","display","flexDirection","justifyContent","theme","verticalNavigation","width","background","colors","atmo1","boxShadow","shadow","clipPath","padding","space","sm","borderTop","atmo2","spacing","collapsed","slider","borderBottom","childData"],"mappings":";;;;AAGa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAC3C,wBACA;AAAA,EACEC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgBC,YAAAA,MAAMC,mBAAmBF;AAAAA,IAEzCG,OAAO;AAAA,IAEPC,YAAYH,YAAAA,MAAMI,OAAOC;AAAAA,IACzBC,WAAWN,YAAAA,MAAMI,OAAOG;AAAAA,IACxBC,UAAU;AAAA,IAEV,mBAAmB;AAAA,MACjBC,SAAST,YAAAA,MAAMU,MAAMC;AAAAA,IACvB;AAAA,IACA,+BAA+B;AAAA,MAC7BC,WAAY,aAAYZ,YAAAA,MAAMI,OAAOS;AAAAA,MACrCJ,SAAST,kBAAMc,QAAQ,CAAC,MAAM,MAAM,MAAM,IAAI,CAAC;AAAA,IACjD;AAAA,IAEA,uCAAuC;AAAA,MACrCF,WAAW;AAAA,MACXH,SAAST,kBAAMc,QAAQ,CAAC,MAAM,MAAM,MAAM,IAAI,CAAC;AAAA,IACjD;AAAA,EACF;AAAA,EACAC,WAAW;AAAA,IACTb,OAAO;AAAA,IACP,eAAe;AAAA,MACbA,OAAO;AAAA,IACT;AAAA,IACA,uCAAuC;AAAA,MACrCO,SAAST,kBAAMc,QAAQ,CAAC,MAAM,MAAM,MAAM,IAAI,CAAC;AAAA,IACjD;AAAA,IAEA,+BAA+B;AAAA,MAC7BL,SAAST,kBAAMc,QAAQ,CAAC,MAAM,MAAM,MAAM,IAAI,CAAC;AAAA,IACjD;AAAA,EACF;AAAA,EAEAE,QAAQ;AAAA,IACN,yBAAyB;AAAA,MACvBC,cAAe,aAAYjB,YAAAA,MAAMI,OAAOS;AAAAA,IAC1C;AAAA,EACF;AAAA,EAEAK,WAAW,CAAC;AACd,CACF;;;"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -215,21 +215,21 @@ const Calendar_styles = require("./components/Calendar/Calendar.styles.cjs");
|
|
|
215
215
|
const Calendar = require("./components/Calendar/Calendar.cjs");
|
|
216
216
|
const CalendarHeader_styles = require("./components/Calendar/CalendarHeader/CalendarHeader.styles.cjs");
|
|
217
217
|
const CalendarHeader = require("./components/Calendar/CalendarHeader/CalendarHeader.cjs");
|
|
218
|
-
const
|
|
218
|
+
const VerticalNavigation_styles = require("./components/VerticalNavigation/VerticalNavigation.styles.cjs");
|
|
219
219
|
const VerticalNavigation = require("./components/VerticalNavigation/VerticalNavigation.cjs");
|
|
220
|
-
const
|
|
220
|
+
const Header_styles$2 = require("./components/VerticalNavigation/Header/Header.styles.cjs");
|
|
221
221
|
const Header$2 = require("./components/VerticalNavigation/Header/Header.cjs");
|
|
222
|
-
const
|
|
223
|
-
const actionsClasses = require("./components/VerticalNavigation/Actions/actionsClasses.cjs");
|
|
222
|
+
const Actions_styles$2 = require("./components/VerticalNavigation/Actions/Actions.styles.cjs");
|
|
224
223
|
const Actions$2 = require("./components/VerticalNavigation/Actions/Actions.cjs");
|
|
224
|
+
const Action_styles$1 = require("./components/VerticalNavigation/Actions/Action.styles.cjs");
|
|
225
225
|
const Action$1 = require("./components/VerticalNavigation/Actions/Action.cjs");
|
|
226
|
-
const
|
|
226
|
+
const Navigation_styles$1 = require("./components/VerticalNavigation/Navigation/Navigation.styles.cjs");
|
|
227
227
|
const Navigation$1 = require("./components/VerticalNavigation/Navigation/Navigation.cjs");
|
|
228
|
-
const
|
|
228
|
+
const NavigationSlider_styles = require("./components/VerticalNavigation/NavigationSlider/NavigationSlider.styles.cjs");
|
|
229
229
|
const NavigationSlider = require("./components/VerticalNavigation/NavigationSlider/NavigationSlider.cjs");
|
|
230
|
-
const
|
|
231
|
-
const treeViewItemClasses = require("./components/VerticalNavigation/TreeView/treeViewItemClasses.cjs");
|
|
230
|
+
const TreeView_styles = require("./components/VerticalNavigation/TreeView/TreeView.styles.cjs");
|
|
232
231
|
const TreeView = require("./components/VerticalNavigation/TreeView/TreeView.cjs");
|
|
232
|
+
const TreeViewItem_styles = require("./components/VerticalNavigation/TreeView/TreeViewItem.styles.cjs");
|
|
233
233
|
const TreeViewItem = require("./components/VerticalNavigation/TreeView/TreeViewItem.cjs");
|
|
234
234
|
const VerticalNavigationContext = require("./components/VerticalNavigation/VerticalNavigationContext.cjs");
|
|
235
235
|
const Slider_styles = require("./components/Slider/Slider.styles.cjs");
|
|
@@ -571,21 +571,21 @@ exports.calendarClasses = Calendar_styles.staticClasses;
|
|
|
571
571
|
exports.HvCalendar = Calendar.HvCalendar;
|
|
572
572
|
exports.calendarHeaderClasses = CalendarHeader_styles.staticClasses;
|
|
573
573
|
exports.HvCalendarHeader = CalendarHeader.HvCalendarHeader;
|
|
574
|
-
exports.verticalNavigationClasses =
|
|
574
|
+
exports.verticalNavigationClasses = VerticalNavigation_styles.staticClasses;
|
|
575
575
|
exports.HvVerticalNavigation = VerticalNavigation.HvVerticalNavigation;
|
|
576
|
-
exports.verticalNavigationHeaderClasses =
|
|
576
|
+
exports.verticalNavigationHeaderClasses = Header_styles$2.staticClasses;
|
|
577
577
|
exports.HvVerticalNavigationHeader = Header$2.HvVerticalNavigationHeader;
|
|
578
|
-
exports.
|
|
579
|
-
exports.actionsClasses = actionsClasses.default;
|
|
578
|
+
exports.actionsClasses = Actions_styles$2.staticClasses;
|
|
580
579
|
exports.HvVerticalNavigationActions = Actions$2.HvVerticalNavigationActions;
|
|
580
|
+
exports.actionClasses = Action_styles$1.staticClasses;
|
|
581
581
|
exports.HvVerticalNavigationAction = Action$1.HvVerticalNavigationAction;
|
|
582
|
-
exports.verticalNavigationTreeClasses =
|
|
582
|
+
exports.verticalNavigationTreeClasses = Navigation_styles$1.staticClasses;
|
|
583
583
|
exports.HvVerticalNavigationTree = Navigation$1.HvVerticalNavigationTree;
|
|
584
|
-
exports.verticalNavigationSliderClasses =
|
|
584
|
+
exports.verticalNavigationSliderClasses = NavigationSlider_styles.staticClasses;
|
|
585
585
|
exports.HvVerticalNavigationSlider = NavigationSlider.HvVerticalNavigationSlider;
|
|
586
|
-
exports.treeViewClasses =
|
|
587
|
-
exports.treeViewItemClasses = treeViewItemClasses.default;
|
|
586
|
+
exports.treeViewClasses = TreeView_styles.staticClasses;
|
|
588
587
|
exports.HvVerticalNavigationTreeView = TreeView.HvVerticalNavigationTreeView;
|
|
588
|
+
exports.treeViewItemClasses = TreeViewItem_styles.staticClasses;
|
|
589
589
|
exports.HvVerticalNavigationTreeViewItem = TreeViewItem.HvVerticalNavigationTreeViewItem;
|
|
590
590
|
exports.VerticalNavigationContext = VerticalNavigationContext.VerticalNavigationContext;
|
|
591
591
|
exports.sliderClasses = Slider_styles.staticClasses;
|
|
@@ -31,12 +31,12 @@ const HvBaseDropdown = (props) => {
|
|
|
31
31
|
adornment,
|
|
32
32
|
expanded,
|
|
33
33
|
dropdownHeaderProps,
|
|
34
|
-
defaultExpanded
|
|
35
|
-
disabled
|
|
36
|
-
readOnly
|
|
37
|
-
required
|
|
38
|
-
disablePortal
|
|
39
|
-
variableWidth
|
|
34
|
+
defaultExpanded,
|
|
35
|
+
disabled,
|
|
36
|
+
readOnly,
|
|
37
|
+
required,
|
|
38
|
+
disablePortal,
|
|
39
|
+
variableWidth,
|
|
40
40
|
placement = "right",
|
|
41
41
|
popperProps = {},
|
|
42
42
|
dropdownHeaderRef: dropdownHeaderRefProp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDropdown.js","sources":["../../../../src/components/BaseDropdown/BaseDropdown.tsx"],"sourcesContent":["import React, {\n useMemo,\n useState,\n useCallback,\n KeyboardEventHandler,\n} from \"react\";\n\nimport { createPortal } from \"react-dom\";\n\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n PopperPlacementType,\n PopperProps,\n} from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { usePopper } from \"react-popper\";\nimport { detectOverflow, ModifierArguments, Options } from \"@popperjs/core\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { isKey, isOneOfKeys } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { getFirstAndLastFocus } from \"@core/utils/focusableElementFinder\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./BaseDropdown.styles\";\nimport BaseDropdownContext from \"./BaseDropdownContext\";\n\nexport { staticClasses as baseDropdownClasses };\n\nexport type HvBaseDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBaseDropdownProps\n extends HvBaseProps<HTMLDivElement, \"placeholder\"> {\n /**\n * The role of the element that triggers the popup.\n *\n * Defaults to \"combobox\" if `component` and the default\n * \"textbox\" header is used, undefined otherwise.\n */\n role?: string;\n /**\n * Header placeholder.\n */\n placeholder?: string | React.ReactNode;\n /**\n * If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled.\n */\n disabled?: boolean;\n /**\n * If `true` the dropdown will be in read only mode, unable to be interacted.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * Replacement for the header component.\n */\n component?: React.ReactNode;\n /**\n * Adornment to replace the default arrows.\n */\n adornment?: React.ReactNode;\n /**\n * When dropdown changes the expanded state.\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * When user click outside the open container.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * Callback called when the dropdown is opened and ready,\n * commonly used to set focus to the content.\n */\n onContainerCreation?: (container: HTMLElement | null) => void;\n /**\n * Attributes applied to the dropdown header element.\n */\n dropdownHeaderProps?: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n >;\n /**\n * Pass a ref to the dropdown header element.\n */\n dropdownHeaderRef?: React.Ref<any>;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvBaseDropdownClasses;\n}\n\nexport const HvBaseDropdown = (props: HvBaseDropdownProps) => {\n const {\n id,\n className,\n classes: classesProp,\n children,\n role,\n placeholder,\n component,\n adornment,\n expanded,\n dropdownHeaderProps,\n defaultExpanded = false,\n disabled = false,\n readOnly = false,\n required = false,\n disablePortal = false,\n variableWidth = false,\n placement = \"right\",\n popperProps = {},\n dropdownHeaderRef: dropdownHeaderRefProp,\n onToggle,\n onClickOutside,\n onContainerCreation,\n \"aria-expanded\": ariaExpandedProp,\n ...others\n } = useDefaultProps(\"HvBaseDropdown\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(\n null\n );\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(null);\n const [popperMaxSize, setPopperMaxSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n const handleDropdownHeaderRefProp = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderProps?.ref\n );\n const handleDropdownHeaderRef = useForkRef(\n setReferenceElement,\n handleDropdownHeaderRefProp\n );\n\n const ariaRole = role || (component == null ? \"combobox\" : undefined);\n\n const ariaExpanded = ariaExpandedProp ?? (ariaRole ? !!isOpen : undefined);\n\n const elementId = useUniqueId(id, \"hvbasedropdown\");\n\n const bottom: PopperPlacementType =\n placement && `bottom-${placement === \"right\" ? \"start\" : \"end\"}`;\n\n const extensionWidth = referenceElement\n ? referenceElement?.offsetWidth\n : \"inherit\";\n\n const { modifiers: popperPropsModifiers = [], ...otherPopperProps } =\n popperProps;\n\n const onFirstUpdate = useCallback(() => {\n if (onContainerCreation) onContainerCreation(popperElement);\n }, [onContainerCreation, popperElement]);\n\n const widthCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n []\n );\n\n const widthCalculatorEffect = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.elements.popper.style.width = `${\n (state.elements.reference as any).offsetWidth\n }px`;\n },\n []\n );\n\n const applyMaxSizeCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n // The `maxSize` modifier provides this data\n const { width, height } = state.modifiersData.maxSize;\n if (width !== popperMaxSize?.width || height !== popperMaxSize?.height) {\n setPopperMaxSize({ width, height });\n }\n\n state.styles.popper = {\n ...state.styles.popper,\n maxWidth: `${width}px`,\n maxHeight: `${height}px`,\n };\n },\n [popperMaxSize]\n );\n\n const maxSizeCalculator = useCallback(\n ({ state, name, options }: ModifierArguments<Options>) => {\n const overflow = detectOverflow(state, options);\n\n const x = state.modifiersData.preventOverflow?.x || 0;\n const y = state.modifiersData.preventOverflow?.y || 0;\n\n const popperWidth = state.rects.popper.width;\n const popperHeight = state.rects.popper.height;\n\n const basePlacement = state.placement.split(\"-\")[0];\n\n const widthProp = basePlacement === \"left\" ? \"left\" : \"right\";\n const heightProp = basePlacement === \"top\" ? \"top\" : \"bottom\";\n\n state.modifiersData[name] = {\n width: popperWidth - overflow[widthProp] - x,\n height: popperHeight - overflow[heightProp] - y,\n };\n },\n []\n );\n\n const modifiers: PopperProps[\"modifiers\"] = useMemo(\n () => [\n {\n name: \"variableWidth\",\n enabled: !variableWidth,\n phase: \"beforeWrite\",\n requires: [\"computeStyles\"],\n fn: widthCalculator,\n effect: widthCalculatorEffect,\n },\n {\n name: \"maxSize\",\n enabled: true,\n phase: \"main\",\n requiresIfExists: [\"offset\", \"preventOverflow\", \"flip\"],\n fn: maxSizeCalculator,\n },\n {\n name: \"applyMaxSize\",\n enabled: true,\n phase: \"beforeWrite\",\n requires: [\"maxSize\"],\n fn: applyMaxSizeCalculator,\n },\n ...popperPropsModifiers,\n ],\n [\n maxSizeCalculator,\n applyMaxSizeCalculator,\n popperPropsModifiers,\n variableWidth,\n widthCalculator,\n widthCalculatorEffect,\n ]\n );\n\n const { styles: popperStyles, attributes } = usePopper(\n referenceElement,\n popperElement,\n {\n placement: bottom,\n modifiers,\n onFirstUpdate,\n ...otherPopperProps,\n }\n );\n\n const popperPlacement =\n attributes.popper?.[\"data-popper-placement\"] ?? \"bottom\";\n\n const handleToggle = useCallback(\n (event) => {\n if (event && !isKey(event, \"Tab\")) {\n event.preventDefault();\n }\n\n const notControlKey =\n !!event?.code &&\n !isOneOfKeys(event, [\"Tab\", \"Enter\", \"Esc\", \"ArrowDown\", \"Space\"]);\n\n const ignoredCombinations =\n (isKey(event, \"Esc\") && !isOpen) ||\n (isKey(event, \"ArrowDown\") && isOpen) ||\n (isKey(event, \"Tab\") && !isOpen);\n\n if (disabled || notControlKey || ignoredCombinations) return;\n\n const newOpen = !isOpen;\n\n /* If about to close focus on the header component. */\n const focusHeader = () => {\n if (!newOpen) {\n // Focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n referenceElement?.focus({ preventScroll: true });\n }\n\n return newOpen;\n };\n setIsOpen(focusHeader());\n\n onToggle?.(event, newOpen);\n },\n [isOpen, disabled, setIsOpen, onToggle, referenceElement]\n );\n\n const headerComponent = (() => {\n if (component) {\n return React.cloneElement(component as React.ReactElement, {\n ref: handleDropdownHeaderRef,\n \"aria-controls\": isOpen\n ? setId(elementId, \"children-container\")\n : undefined,\n });\n }\n\n const ExpanderComponent = isOpen ? DropUpXS : DropDownXS;\n\n return (\n <div\n id={setId(id, \"header\")}\n className={cx(classes.header, {\n [classes.headerDisabled]: disabled,\n [classes.headerReadOnly]: readOnly,\n [classes.headerOpen]: isOpen,\n [classes.headerOpenUp]: isOpen && popperPlacement.includes(\"top\"),\n [classes.headerOpenDown]:\n isOpen && popperPlacement.includes(\"bottom\"),\n })}\n role={ariaRole === \"combobox\" ? \"textbox\" : undefined}\n style={disabled || readOnly ? { pointerEvents: \"none\" } : undefined}\n aria-controls={\n isOpen ? setId(elementId, \"children-container\") : undefined\n }\n aria-label={others[\"aria-label\"] ?? undefined}\n aria-labelledby={others[\"aria-labelledby\"] ?? undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n // Removes the element from the navigation sequence for keyboard focus if disabled\n tabIndex={disabled ? -1 : 0}\n ref={handleDropdownHeaderRef}\n {...dropdownHeaderProps}\n >\n <div className={classes.selection}>\n {placeholder && typeof placeholder === \"string\" ? (\n <HvTypography\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n {placeholder}\n </HvTypography>\n ) : (\n placeholder\n )}\n </div>\n <div className={classes.arrowContainer}>\n {adornment || (\n <ExpanderComponent\n iconSize=\"XS\"\n color={disabled ? theme.colors.secondary_60 : undefined}\n className={classes.arrow}\n />\n )}\n </div>\n </div>\n );\n })();\n\n const containerComponent = (() => {\n /**\n * Handle keyboard inside children container.\n */\n const handleContainerKeyDown: KeyboardEventHandler = (event) => {\n if (isKey(event, \"Esc\")) {\n handleToggle(event);\n }\n if (isKey(event, \"Tab\") && !event.shiftKey) {\n const focusList = getFirstAndLastFocus(popperElement);\n if (document.activeElement === focusList?.last) {\n event.preventDefault();\n focusList?.first?.focus();\n }\n }\n };\n\n const handleOutside: ClickAwayListenerProps[\"onClickAway\"] = (event) => {\n const isButtonClick = referenceElement?.contains(event.target as any);\n if (!isButtonClick) {\n onClickOutside?.(event);\n setIsOpen(false);\n onToggle?.(event, false);\n }\n };\n\n const container = (\n <div\n role=\"tooltip\"\n ref={setPopperElement}\n className={classes.container}\n style={popperStyles.popper}\n {...attributes.popper}\n >\n <ClickAwayListener onClickAway={handleOutside}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div onKeyDown={handleContainerKeyDown}>\n {popperPlacement.includes(\"bottom\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(classes.inputExtensionOpen, {\n [classes.inputExtensionLeftPosition]:\n popperPlacement.includes(\"end\"),\n })}\n />\n )}\n <BaseDropdownContext.Provider value={popperMaxSize}>\n <div\n id={setId(elementId, \"children-container\")}\n className={cx(classes.panel, {\n [classes.panelOpenedUp]: popperPlacement.includes(\"top\"),\n [classes.panelOpenedDown]: popperPlacement.includes(\"bottom\"),\n })}\n >\n {children}\n </div>\n </BaseDropdownContext.Provider>\n {popperPlacement.includes(\"top\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(\n classes.inputExtensionOpen,\n classes.inputExtensionOpenShadow,\n {\n [classes.inputExtensionFloatRight]:\n popperPlacement.includes(\"end\"),\n [classes.inputExtensionFloatLeft]:\n popperPlacement.includes(\"start\"),\n }\n )}\n />\n )}\n </div>\n </ClickAwayListener>\n </div>\n );\n\n if (disablePortal) return container;\n\n return createPortal(\n container,\n document.getElementById(rootId || \"\") || document.body\n );\n })();\n\n return (\n <div className={classes.root}>\n <div\n id={id}\n role={ariaRole}\n aria-expanded={ariaExpanded}\n aria-owns={isOpen ? setId(elementId, \"children-container\") : undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n className={cx(\n classes.anchor,\n { [classes.rootDisabled]: disabled },\n className\n )}\n {...(!readOnly && {\n onKeyDown: handleToggle,\n onClick: handleToggle,\n })}\n // Removes the element from the navigation sequence for keyboard focus\n tabIndex={-1}\n {...others}\n >\n {headerComponent}\n </div>\n {isOpen && containerComponent}\n </div>\n );\n};\n"],"names":["HvBaseDropdown","props","id","className","classes","classesProp","children","role","placeholder","component","adornment","expanded","dropdownHeaderProps","defaultExpanded","disabled","readOnly","required","disablePortal","variableWidth","placement","popperProps","dropdownHeaderRef","dropdownHeaderRefProp","onToggle","onClickOutside","onContainerCreation","ariaExpandedProp","others","useDefaultProps","cx","useClasses","rootId","useTheme","isOpen","setIsOpen","useControlled","Boolean","referenceElement","setReferenceElement","useState","popperElement","setPopperElement","popperMaxSize","setPopperMaxSize","handleDropdownHeaderRefProp","useForkRef","ref","handleDropdownHeaderRef","ariaRole","undefined","ariaExpanded","elementId","useUniqueId","bottom","extensionWidth","offsetWidth","modifiers","popperPropsModifiers","otherPopperProps","onFirstUpdate","useCallback","widthCalculator","state","styles","popper","width","rects","reference","widthCalculatorEffect","elements","style","applyMaxSizeCalculator","height","modifiersData","maxSize","maxWidth","maxHeight","maxSizeCalculator","name","options","overflow","detectOverflow","x","preventOverflow","y","popperWidth","popperHeight","basePlacement","split","widthProp","heightProp","useMemo","enabled","phase","requires","fn","effect","requiresIfExists","popperStyles","attributes","usePopper","popperPlacement","handleToggle","event","isKey","preventDefault","notControlKey","code","isOneOfKeys","ignoredCombinations","newOpen","focusHeader","focus","preventScroll","headerComponent","React","cloneElement","setId","ExpanderComponent","DropUpXS","DropDownXS","header","headerDisabled","headerReadOnly","headerOpen","headerOpenUp","includes","headerOpenDown","pointerEvents","tabIndex","_jsx","selection","HvTypography","selectionDisabled","variant","arrowContainer","iconSize","color","theme","colors","secondary_60","arrow","containerComponent","handleContainerKeyDown","shiftKey","focusList","getFirstAndLastFocus","document","activeElement","last","first","handleOutside","isButtonClick","contains","target","container","ClickAwayListener","onClickAway","onKeyDown","inputExtensionOpen","inputExtensionLeftPosition","BaseDropdownContext","Provider","value","panel","panelOpenedUp","panelOpenedDown","inputExtensionOpenShadow","inputExtensionFloatRight","inputExtensionFloatLeft","createPortal","getElementById","body","root","anchor","rootDisabled","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkIaA,MAAAA,iBAAiBA,CAACC,UAA+B;;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,gBAAgB;AAAA,IAChBC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZC,cAAc,CAAC;AAAA,IACfC,mBAAmBC;AAAAA,IACnBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,iBAAiBC;AAAAA,IACjB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,kBAAkB3B,KAAK;AACrC,QAAA;AAAA,IAAEG;AAAAA,IAASyB;AAAAA,EAAAA,IAAOC,WAAWzB,WAAW;AAExC,QAAA;AAAA,IAAE0B;AAAAA,MAAWC,SAAS;AAEtB,QAAA,CAACC,QAAQC,SAAS,IAAIC,cAAcxB,UAAUyB,QAAQvB,eAAe,CAAC;AAE5E,QAAM,CAACwB,kBAAkBC,mBAAmB,IAAIC,SAC9C,IACF;AACA,QAAM,CAACC,eAAeC,gBAAgB,IAAIF,SAA6B,IAAI;AAC3E,QAAM,CAACG,eAAeC,gBAAgB,IAAIJ,SAGvC,CAAE,CAAA;AAEL,QAAMK,8BAA8BC,WAClCvB,uBACAV,2DAAqBkC,GACvB;AACMC,QAAAA,0BAA0BF,WAC9BP,qBACAM,2BACF;AAEA,QAAMI,WAAWzC,SAASE,aAAa,OAAO,aAAawC;AAE3D,QAAMC,eAAexB,qBAAqBsB,WAAW,CAAC,CAACf,SAASgB;AAE1DE,QAAAA,YAAYC,YAAYlD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AAA,SAC1BX,SACF;AAAA,MAAE,GACG,CAACY,YAAY;AAAA,QAChB+I,WAAWxD;AAAAA,QACX0E,SAAS1E;AAAAA,MACX;AAAA;AAAA,MAEA2B,UAAU;AAAA,MAAG,GACTtG;AAAAA,MAAMrB,UAET4G;AAAAA,IAAAA,CACE,GACJjF,UAAU6G,kBAAkB;AAAA,EAAA,CAC1B;AAET;"}
|
|
1
|
+
{"version":3,"file":"BaseDropdown.js","sources":["../../../../src/components/BaseDropdown/BaseDropdown.tsx"],"sourcesContent":["import React, {\n useMemo,\n useState,\n useCallback,\n KeyboardEventHandler,\n} from \"react\";\n\nimport { createPortal } from \"react-dom\";\n\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n PopperPlacementType,\n PopperProps,\n} from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { usePopper } from \"react-popper\";\nimport { detectOverflow, ModifierArguments, Options } from \"@popperjs/core\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { isKey, isOneOfKeys } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { getFirstAndLastFocus } from \"@core/utils/focusableElementFinder\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./BaseDropdown.styles\";\nimport BaseDropdownContext from \"./BaseDropdownContext\";\n\nexport { staticClasses as baseDropdownClasses };\n\nexport type HvBaseDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvBaseDropdownProps\n extends HvBaseProps<HTMLDivElement, \"placeholder\"> {\n /**\n * The role of the element that triggers the popup.\n *\n * Defaults to \"combobox\" if `component` and the default\n * \"textbox\" header is used, undefined otherwise.\n */\n role?: string;\n /**\n * Header placeholder.\n */\n placeholder?: string | React.ReactNode;\n /**\n * If `true` the dropdown is disabled unable to be interacted, if `false` it is enabled.\n */\n disabled?: boolean;\n /**\n * If `true` the dropdown will be in read only mode, unable to be interacted.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * Replacement for the header component.\n */\n component?: React.ReactNode;\n /**\n * Adornment to replace the default arrows.\n */\n adornment?: React.ReactNode;\n /**\n * When dropdown changes the expanded state.\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * When user click outside the open container.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * Callback called when the dropdown is opened and ready,\n * commonly used to set focus to the content.\n */\n onContainerCreation?: (container: HTMLElement | null) => void;\n /**\n * Attributes applied to the dropdown header element.\n */\n dropdownHeaderProps?: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n >;\n /**\n * Pass a ref to the dropdown header element.\n */\n dropdownHeaderRef?: React.Ref<any>;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvBaseDropdownClasses;\n}\n\nexport const HvBaseDropdown = (props: HvBaseDropdownProps) => {\n const {\n id,\n className,\n classes: classesProp,\n children,\n role,\n placeholder,\n component,\n adornment,\n expanded,\n dropdownHeaderProps,\n defaultExpanded,\n disabled,\n readOnly,\n required,\n disablePortal,\n variableWidth,\n placement = \"right\",\n popperProps = {},\n dropdownHeaderRef: dropdownHeaderRefProp,\n onToggle,\n onClickOutside,\n onContainerCreation,\n \"aria-expanded\": ariaExpandedProp,\n ...others\n } = useDefaultProps(\"HvBaseDropdown\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [isOpen, setIsOpen] = useControlled(expanded, Boolean(defaultExpanded));\n\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(\n null\n );\n const [popperElement, setPopperElement] = useState<HTMLElement | null>(null);\n const [popperMaxSize, setPopperMaxSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n const handleDropdownHeaderRefProp = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderProps?.ref\n );\n const handleDropdownHeaderRef = useForkRef(\n setReferenceElement,\n handleDropdownHeaderRefProp\n );\n\n const ariaRole = role || (component == null ? \"combobox\" : undefined);\n\n const ariaExpanded = ariaExpandedProp ?? (ariaRole ? !!isOpen : undefined);\n\n const elementId = useUniqueId(id, \"hvbasedropdown\");\n\n const bottom: PopperPlacementType =\n placement && `bottom-${placement === \"right\" ? \"start\" : \"end\"}`;\n\n const extensionWidth = referenceElement\n ? referenceElement?.offsetWidth\n : \"inherit\";\n\n const { modifiers: popperPropsModifiers = [], ...otherPopperProps } =\n popperProps;\n\n const onFirstUpdate = useCallback(() => {\n if (onContainerCreation) onContainerCreation(popperElement);\n }, [onContainerCreation, popperElement]);\n\n const widthCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n []\n );\n\n const widthCalculatorEffect = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n state.elements.popper.style.width = `${\n (state.elements.reference as any).offsetWidth\n }px`;\n },\n []\n );\n\n const applyMaxSizeCalculator = useCallback(\n ({ state }: ModifierArguments<Options>) => {\n // The `maxSize` modifier provides this data\n const { width, height } = state.modifiersData.maxSize;\n if (width !== popperMaxSize?.width || height !== popperMaxSize?.height) {\n setPopperMaxSize({ width, height });\n }\n\n state.styles.popper = {\n ...state.styles.popper,\n maxWidth: `${width}px`,\n maxHeight: `${height}px`,\n };\n },\n [popperMaxSize]\n );\n\n const maxSizeCalculator = useCallback(\n ({ state, name, options }: ModifierArguments<Options>) => {\n const overflow = detectOverflow(state, options);\n\n const x = state.modifiersData.preventOverflow?.x || 0;\n const y = state.modifiersData.preventOverflow?.y || 0;\n\n const popperWidth = state.rects.popper.width;\n const popperHeight = state.rects.popper.height;\n\n const basePlacement = state.placement.split(\"-\")[0];\n\n const widthProp = basePlacement === \"left\" ? \"left\" : \"right\";\n const heightProp = basePlacement === \"top\" ? \"top\" : \"bottom\";\n\n state.modifiersData[name] = {\n width: popperWidth - overflow[widthProp] - x,\n height: popperHeight - overflow[heightProp] - y,\n };\n },\n []\n );\n\n const modifiers: PopperProps[\"modifiers\"] = useMemo(\n () => [\n {\n name: \"variableWidth\",\n enabled: !variableWidth,\n phase: \"beforeWrite\",\n requires: [\"computeStyles\"],\n fn: widthCalculator,\n effect: widthCalculatorEffect,\n },\n {\n name: \"maxSize\",\n enabled: true,\n phase: \"main\",\n requiresIfExists: [\"offset\", \"preventOverflow\", \"flip\"],\n fn: maxSizeCalculator,\n },\n {\n name: \"applyMaxSize\",\n enabled: true,\n phase: \"beforeWrite\",\n requires: [\"maxSize\"],\n fn: applyMaxSizeCalculator,\n },\n ...popperPropsModifiers,\n ],\n [\n maxSizeCalculator,\n applyMaxSizeCalculator,\n popperPropsModifiers,\n variableWidth,\n widthCalculator,\n widthCalculatorEffect,\n ]\n );\n\n const { styles: popperStyles, attributes } = usePopper(\n referenceElement,\n popperElement,\n {\n placement: bottom,\n modifiers,\n onFirstUpdate,\n ...otherPopperProps,\n }\n );\n\n const popperPlacement =\n attributes.popper?.[\"data-popper-placement\"] ?? \"bottom\";\n\n const handleToggle = useCallback(\n (event) => {\n if (event && !isKey(event, \"Tab\")) {\n event.preventDefault();\n }\n\n const notControlKey =\n !!event?.code &&\n !isOneOfKeys(event, [\"Tab\", \"Enter\", \"Esc\", \"ArrowDown\", \"Space\"]);\n\n const ignoredCombinations =\n (isKey(event, \"Esc\") && !isOpen) ||\n (isKey(event, \"ArrowDown\") && isOpen) ||\n (isKey(event, \"Tab\") && !isOpen);\n\n if (disabled || notControlKey || ignoredCombinations) return;\n\n const newOpen = !isOpen;\n\n /* If about to close focus on the header component. */\n const focusHeader = () => {\n if (!newOpen) {\n // Focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n referenceElement?.focus({ preventScroll: true });\n }\n\n return newOpen;\n };\n setIsOpen(focusHeader());\n\n onToggle?.(event, newOpen);\n },\n [isOpen, disabled, setIsOpen, onToggle, referenceElement]\n );\n\n const headerComponent = (() => {\n if (component) {\n return React.cloneElement(component as React.ReactElement, {\n ref: handleDropdownHeaderRef,\n \"aria-controls\": isOpen\n ? setId(elementId, \"children-container\")\n : undefined,\n });\n }\n\n const ExpanderComponent = isOpen ? DropUpXS : DropDownXS;\n\n return (\n <div\n id={setId(id, \"header\")}\n className={cx(classes.header, {\n [classes.headerDisabled]: disabled,\n [classes.headerReadOnly]: readOnly,\n [classes.headerOpen]: isOpen,\n [classes.headerOpenUp]: isOpen && popperPlacement.includes(\"top\"),\n [classes.headerOpenDown]:\n isOpen && popperPlacement.includes(\"bottom\"),\n })}\n role={ariaRole === \"combobox\" ? \"textbox\" : undefined}\n style={disabled || readOnly ? { pointerEvents: \"none\" } : undefined}\n aria-controls={\n isOpen ? setId(elementId, \"children-container\") : undefined\n }\n aria-label={others[\"aria-label\"] ?? undefined}\n aria-labelledby={others[\"aria-labelledby\"] ?? undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n // Removes the element from the navigation sequence for keyboard focus if disabled\n tabIndex={disabled ? -1 : 0}\n ref={handleDropdownHeaderRef}\n {...dropdownHeaderProps}\n >\n <div className={classes.selection}>\n {placeholder && typeof placeholder === \"string\" ? (\n <HvTypography\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n {placeholder}\n </HvTypography>\n ) : (\n placeholder\n )}\n </div>\n <div className={classes.arrowContainer}>\n {adornment || (\n <ExpanderComponent\n iconSize=\"XS\"\n color={disabled ? theme.colors.secondary_60 : undefined}\n className={classes.arrow}\n />\n )}\n </div>\n </div>\n );\n })();\n\n const containerComponent = (() => {\n /**\n * Handle keyboard inside children container.\n */\n const handleContainerKeyDown: KeyboardEventHandler = (event) => {\n if (isKey(event, \"Esc\")) {\n handleToggle(event);\n }\n if (isKey(event, \"Tab\") && !event.shiftKey) {\n const focusList = getFirstAndLastFocus(popperElement);\n if (document.activeElement === focusList?.last) {\n event.preventDefault();\n focusList?.first?.focus();\n }\n }\n };\n\n const handleOutside: ClickAwayListenerProps[\"onClickAway\"] = (event) => {\n const isButtonClick = referenceElement?.contains(event.target as any);\n if (!isButtonClick) {\n onClickOutside?.(event);\n setIsOpen(false);\n onToggle?.(event, false);\n }\n };\n\n const container = (\n <div\n role=\"tooltip\"\n ref={setPopperElement}\n className={classes.container}\n style={popperStyles.popper}\n {...attributes.popper}\n >\n <ClickAwayListener onClickAway={handleOutside}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div onKeyDown={handleContainerKeyDown}>\n {popperPlacement.includes(\"bottom\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(classes.inputExtensionOpen, {\n [classes.inputExtensionLeftPosition]:\n popperPlacement.includes(\"end\"),\n })}\n />\n )}\n <BaseDropdownContext.Provider value={popperMaxSize}>\n <div\n id={setId(elementId, \"children-container\")}\n className={cx(classes.panel, {\n [classes.panelOpenedUp]: popperPlacement.includes(\"top\"),\n [classes.panelOpenedDown]: popperPlacement.includes(\"bottom\"),\n })}\n >\n {children}\n </div>\n </BaseDropdownContext.Provider>\n {popperPlacement.includes(\"top\") && (\n <div\n style={{ width: extensionWidth }}\n className={cx(\n classes.inputExtensionOpen,\n classes.inputExtensionOpenShadow,\n {\n [classes.inputExtensionFloatRight]:\n popperPlacement.includes(\"end\"),\n [classes.inputExtensionFloatLeft]:\n popperPlacement.includes(\"start\"),\n }\n )}\n />\n )}\n </div>\n </ClickAwayListener>\n </div>\n );\n\n if (disablePortal) return container;\n\n return createPortal(\n container,\n document.getElementById(rootId || \"\") || document.body\n );\n })();\n\n return (\n <div className={classes.root}>\n <div\n id={id}\n role={ariaRole}\n aria-expanded={ariaExpanded}\n aria-owns={isOpen ? setId(elementId, \"children-container\") : undefined}\n aria-required={required ?? undefined}\n aria-readonly={readOnly ?? undefined}\n className={cx(\n classes.anchor,\n { [classes.rootDisabled]: disabled },\n className\n )}\n {...(!readOnly && {\n onKeyDown: handleToggle,\n onClick: handleToggle,\n })}\n // Removes the element from the navigation sequence for keyboard focus\n tabIndex={-1}\n {...others}\n >\n {headerComponent}\n </div>\n {isOpen && containerComponent}\n </div>\n );\n};\n"],"names":["HvBaseDropdown","props","id","className","classes","classesProp","children","role","placeholder","component","adornment","expanded","dropdownHeaderProps","defaultExpanded","disabled","readOnly","required","disablePortal","variableWidth","placement","popperProps","dropdownHeaderRef","dropdownHeaderRefProp","onToggle","onClickOutside","onContainerCreation","ariaExpandedProp","others","useDefaultProps","cx","useClasses","rootId","useTheme","isOpen","setIsOpen","useControlled","Boolean","referenceElement","setReferenceElement","useState","popperElement","setPopperElement","popperMaxSize","setPopperMaxSize","handleDropdownHeaderRefProp","useForkRef","ref","handleDropdownHeaderRef","ariaRole","undefined","ariaExpanded","elementId","useUniqueId","bottom","extensionWidth","offsetWidth","modifiers","popperPropsModifiers","otherPopperProps","onFirstUpdate","useCallback","widthCalculator","state","styles","popper","width","rects","reference","widthCalculatorEffect","elements","style","applyMaxSizeCalculator","height","modifiersData","maxSize","maxWidth","maxHeight","maxSizeCalculator","name","options","overflow","detectOverflow","x","preventOverflow","y","popperWidth","popperHeight","basePlacement","split","widthProp","heightProp","useMemo","enabled","phase","requires","fn","effect","requiresIfExists","popperStyles","attributes","usePopper","popperPlacement","handleToggle","event","isKey","preventDefault","notControlKey","code","isOneOfKeys","ignoredCombinations","newOpen","focusHeader","focus","preventScroll","headerComponent","React","cloneElement","setId","ExpanderComponent","DropUpXS","DropDownXS","header","headerDisabled","headerReadOnly","headerOpen","headerOpenUp","includes","headerOpenDown","pointerEvents","tabIndex","_jsx","selection","HvTypography","selectionDisabled","variant","arrowContainer","iconSize","color","theme","colors","secondary_60","arrow","containerComponent","handleContainerKeyDown","shiftKey","focusList","getFirstAndLastFocus","document","activeElement","last","first","handleOutside","isButtonClick","contains","target","container","ClickAwayListener","onClickAway","onKeyDown","inputExtensionOpen","inputExtensionLeftPosition","BaseDropdownContext","Provider","value","panel","panelOpenedUp","panelOpenedDown","inputExtensionOpenShadow","inputExtensionFloatRight","inputExtensionFloatLeft","createPortal","getElementById","body","root","anchor","rootDisabled","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkIaA,MAAAA,iBAAiBA,CAACC,UAA+B;;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC,cAAc,CAAC;AAAA,IACfC,mBAAmBC;AAAAA,IACnBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,iBAAiBC;AAAAA,IACjB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,kBAAkB3B,KAAK;AACrC,QAAA;AAAA,IAAEG;AAAAA,IAASyB;AAAAA,EAAAA,IAAOC,WAAWzB,WAAW;AAExC,QAAA;AAAA,IAAE0B;AAAAA,MAAWC,SAAS;AAEtB,QAAA,CAACC,QAAQC,SAAS,IAAIC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;AAEnBe,WAAAA,aACLf,WACAR,SAASwB,eAAe5I,UAAU,EAAE,KAAKoH,SAASyB,IACpD;AAAA,EAAA;AAGF,8BACE,OAAA;AAAA,IAAKzK,WAAWC,QAAQyK;AAAAA,IAAKvK,WAC3B4H,oBAAA,OAAA;AAAA,MACEhI;AAAAA,MACAK,MAAMyC;AAAAA,MACN,iBAAeE;AAAAA,MACf,aAAWjB,SAASoF,MAAMlE,WAAW,oBAAoB,IAAIF;AAAAA,MAC7D,iBAAejC,YAAYiC;AAAAA,MAC3B,iBAAelC,YAAYkC;AAAAA,MAC3B9C,WAAW0B,GACTzB,QAAQ0K,QACR;AAAA,QAAE,CAAC1K,QAAQ2K,YAAY,GAAGjK;AAAAA,SAC1BX,SACF;AAAA,MAAE,GACG,CAACY,YAAY;AAAA,QAChB+I,WAAWxD;AAAAA,QACX0E,SAAS1E;AAAAA,MACX;AAAA;AAAA,MAEA2B,UAAU;AAAA,MAAG,GACTtG;AAAAA,MAAMrB,UAET4G;AAAAA,IAAAA,CACE,GACJjF,UAAU6G,kBAAkB;AAAA,EAAA,CAC1B;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WarningText.js","sources":["../../../../../src/components/Forms/WarningText/WarningText.tsx"],"sourcesContent":["import { useContext } from \"react\";\n\nimport isNil from \"lodash/isNil\";\n\nimport { Fail } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { setId } from \"@core/utils/setId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { staticClasses, useClasses } from \"./WarningText.styles\";\nimport { HvFormElementContext } from \"../FormElement\";\n\nexport { staticClasses as warningTextClasses };\n\nexport type HvWarningTextClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvWarningTextProps extends HvBaseProps {\n /** Icon to be rendered alongside the warning text. */\n adornment?: React.ReactNode;\n /** If `true` the text is not rendered. */\n isVisible?: boolean;\n /** If `true` the text is disabled. */\n disabled?: boolean;\n /** If `true` the text won't include a gutter. */\n disableGutter?: boolean;\n /** If `true` the text won't include the top border. */\n disableBorder?: boolean;\n /** If `true` the adornment icon isn't shown. */\n disableAdornment?: boolean;\n /** If `true` the text isn't shown. */\n hideText?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvWarningTextClasses;\n}\n\n/**\n * Provides the user with a descriptive text, signaling an error, for when the form element is in an invalid state.\n */\nexport const HvWarningText = (props: HvWarningTextProps) => {\n const {\n children,\n adornment,\n isVisible,\n classes: classesProp,\n className,\n id,\n disabled,\n disableGutter = false,\n disableBorder = false,\n disableAdornment = false,\n hideText = false,\n ...others\n } = useDefaultProps(\"HvWarningText\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId, elementStatus, elementDisabled } =\n useContext(HvFormElementContext);\n const localDisabled = disabled || elementDisabled;\n const localVisible = !isNil(isVisible)\n ? isVisible\n : elementStatus === \"invalid\";\n const localId = id ?? setId(elementId, \"error\");\n const showWarning = localVisible && !localDisabled;\n const content = showWarning ? children : \"\";\n const localAdornment = adornment || (\n <Fail className={classes.defaultIcon} semantic=\"negative\" />\n );\n\n return (\n <div\n className={cx(\n classes.root,\n {\n [classes.show]: showWarning,\n [classes.topBorder]: !disableBorder,\n },\n className\n )}\n >\n {!disableAdornment && localAdornment}\n <HvTypography\n id={localId}\n className={cx(classes.warningText, {\n [classes.topGutter]: !disableGutter,\n [classes.hideText]: hideText,\n })}\n role=\"status\"\n aria-relevant=\"additions text\"\n {...others}\n >\n {showWarning && content}\n </HvTypography>\n </div>\n );\n};\n"],"names":["HvWarningText","props","children","adornment","isVisible","classes","classesProp","className","id","disabled","disableGutter","disableBorder","disableAdornment","hideText","others","useDefaultProps","cx","useClasses","elementId","elementStatus","elementDisabled","useContext","HvFormElementContext","localDisabled","localVisible","isNil","localId","setId","showWarning","content","localAdornment","_jsx","Fail","defaultIcon","semantic","root","show","topBorder","HvTypography","warningText","topGutter","role"],"mappings":";;;;;;;;;;AAyCaA,MAAAA,gBAAgBA,CAACC,UAA8B;AACpD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC,gBAAgB;AAAA,IAChBC,mBAAmB;AAAA,IACnBC,WAAW;AAAA,IACX,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,iBAAiBd,KAAK;AAEpC,QAAA;AAAA,IAAEI;AAAAA,IAASW;AAAAA,EAAAA,IAAOC,WAAWX,WAAW;AAExC,QAAA;AAAA,IAAEY;AAAAA,IAAWC;AAAAA,IAAeC;AAAAA,EAAAA,IAChCC,WAAWC,oBAAoB;AACjC,QAAMC,gBAAgBd,YAAYW;AAClC,QAAMI,eAAe,CAACC,MAAMrB,SAAS,IACjCA,YACAe,kBAAkB;AACtB,QAAMO,UAAUlB,MAAMmB,MAAMT,WAAW,OAAO;AACxCU,QAAAA,cAAcJ,gBAAgB,CAACD;AAC/BM,QAAAA,UAAUD,cAAc1B,WAAW;AACnC4B,QAAAA,iBAAiB3B,aACrB4B,oBAACC,MAAI;AAAA,IAACzB,WAAWF,QAAQ4B;AAAAA,IAAaC,UAAS;AAAA,EAAA,CAAY;AAG7D,8BACE,OAAA;AAAA,IACE3B,WAAWS,GACTX,QAAQ8B,MACR;AAAA,MACE,CAAC9B,QAAQ+B,IAAI,GAAGR;AAAAA,MAChB,CAACvB,QAAQgC,SAAS,GAAG,CAAC1B;AAAAA,OAExBJ,SACF;AAAA,IAAEL,UAAA,CAED,CAACU,oBAAoBkB,oCACrBQ,cAAY;AAAA,MACX9B,IAAIkB;AAAAA,MACJnB,WAAWS,GAAGX,QAAQkC,aAAa;AAAA,QACjC,CAAClC,QAAQmC,SAAS,GAAG,CAAC9B;AAAAA,QACtB,CAACL,QAAQQ,QAAQ,GAAGA;AAAAA,MAAAA,CACrB;AAAA,MACD4B,MAAK;AAAA,MACL,iBAAc;AAAA,MAAgB,GAC1B3B;AAAAA,MAAMZ,UAET0B,eAAeC;AAAAA,IAAAA,CACJ,CAAC;AAAA,EAAA,CACZ;AAET;"}
|
|
1
|
+
{"version":3,"file":"WarningText.js","sources":["../../../../../src/components/Forms/WarningText/WarningText.tsx"],"sourcesContent":["import { useContext } from \"react\";\n\nimport isNil from \"lodash/isNil\";\n\nimport { Fail } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { setId } from \"@core/utils/setId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { staticClasses, useClasses } from \"./WarningText.styles\";\nimport { HvFormElementContext } from \"../FormElement\";\n\nexport { staticClasses as warningTextClasses };\n\nexport type HvWarningTextClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvWarningTextProps extends HvBaseProps {\n /** Icon to be rendered alongside the warning text. */\n adornment?: React.ReactNode;\n /** If `true` the text is not rendered. */\n isVisible?: boolean;\n /** If `true` the text is disabled. */\n disabled?: boolean;\n /** If `true` the text won't include a gutter. */\n disableGutter?: boolean;\n /** If `true` the text won't include the top border. */\n disableBorder?: boolean;\n /** If `true` the adornment icon isn't shown. */\n disableAdornment?: boolean;\n /** If `true` the text isn't shown. */\n hideText?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvWarningTextClasses;\n}\n\n/**\n * Provides the user with a descriptive text, signaling an error, for when the form element is in an invalid state.\n */\nexport const HvWarningText = (props: HvWarningTextProps) => {\n const {\n children,\n adornment,\n isVisible,\n classes: classesProp,\n className,\n id,\n disabled,\n disableGutter = false,\n disableBorder = false,\n disableAdornment = false,\n hideText = false,\n ...others\n } = useDefaultProps(\"HvWarningText\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId, elementStatus, elementDisabled } =\n useContext(HvFormElementContext);\n const localDisabled = disabled || elementDisabled;\n const localVisible = !isNil(isVisible)\n ? isVisible\n : elementStatus === \"invalid\";\n const localId = id ?? setId(elementId, \"error\");\n const showWarning = localVisible && !localDisabled;\n const content = showWarning ? children : \"\";\n const localAdornment = adornment || (\n <Fail className={classes.defaultIcon} semantic=\"negative\" />\n );\n\n return (\n <div\n className={cx(\n classes.root,\n {\n [classes.show]: showWarning,\n [classes.topBorder]: !disableBorder,\n },\n className\n )}\n >\n {!disableAdornment && localAdornment}\n <HvTypography\n id={localId}\n className={cx(classes.warningText, {\n [classes.topGutter]: !disableGutter,\n [classes.hideText]: hideText,\n })}\n role=\"status\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n {...others}\n >\n {showWarning && content}\n </HvTypography>\n </div>\n );\n};\n"],"names":["HvWarningText","props","children","adornment","isVisible","classes","classesProp","className","id","disabled","disableGutter","disableBorder","disableAdornment","hideText","others","useDefaultProps","cx","useClasses","elementId","elementStatus","elementDisabled","useContext","HvFormElementContext","localDisabled","localVisible","isNil","localId","setId","showWarning","content","localAdornment","_jsx","Fail","defaultIcon","semantic","root","show","topBorder","HvTypography","warningText","topGutter","role"],"mappings":";;;;;;;;;;AAyCaA,MAAAA,gBAAgBA,CAACC,UAA8B;AACpD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC,gBAAgB;AAAA,IAChBC,mBAAmB;AAAA,IACnBC,WAAW;AAAA,IACX,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,iBAAiBd,KAAK;AAEpC,QAAA;AAAA,IAAEI;AAAAA,IAASW;AAAAA,EAAAA,IAAOC,WAAWX,WAAW;AAExC,QAAA;AAAA,IAAEY;AAAAA,IAAWC;AAAAA,IAAeC;AAAAA,EAAAA,IAChCC,WAAWC,oBAAoB;AACjC,QAAMC,gBAAgBd,YAAYW;AAClC,QAAMI,eAAe,CAACC,MAAMrB,SAAS,IACjCA,YACAe,kBAAkB;AACtB,QAAMO,UAAUlB,MAAMmB,MAAMT,WAAW,OAAO;AACxCU,QAAAA,cAAcJ,gBAAgB,CAACD;AAC/BM,QAAAA,UAAUD,cAAc1B,WAAW;AACnC4B,QAAAA,iBAAiB3B,aACrB4B,oBAACC,MAAI;AAAA,IAACzB,WAAWF,QAAQ4B;AAAAA,IAAaC,UAAS;AAAA,EAAA,CAAY;AAG7D,8BACE,OAAA;AAAA,IACE3B,WAAWS,GACTX,QAAQ8B,MACR;AAAA,MACE,CAAC9B,QAAQ+B,IAAI,GAAGR;AAAAA,MAChB,CAACvB,QAAQgC,SAAS,GAAG,CAAC1B;AAAAA,OAExBJ,SACF;AAAA,IAAEL,UAAA,CAED,CAACU,oBAAoBkB,oCACrBQ,cAAY;AAAA,MACX9B,IAAIkB;AAAAA,MACJnB,WAAWS,GAAGX,QAAQkC,aAAa;AAAA,QACjC,CAAClC,QAAQmC,SAAS,GAAG,CAAC9B;AAAAA,QACtB,CAACL,QAAQQ,QAAQ,GAAGA;AAAAA,MAAAA,CACrB;AAAA,MACD4B,MAAK;AAAA,MACL,aAAU;AAAA,MACV,iBAAc;AAAA,MAAgB,GAC1B3B;AAAAA,MAAMZ,UAET0B,eAAeC;AAAAA,IAAAA,CACJ,CAAC;AAAA,EAAA,CACZ;AAET;"}
|
|
@@ -312,7 +312,7 @@ const HvTagsInput = (props) => {
|
|
|
312
312
|
gutters: classes.listItemGutters,
|
|
313
313
|
root: classes.listItemRoot
|
|
314
314
|
},
|
|
315
|
-
id: `tag-${i}
|
|
315
|
+
id: setId(elementId, `tag-${i}`),
|
|
316
316
|
children: /* @__PURE__ */ jsx(HvTag, {
|
|
317
317
|
label,
|
|
318
318
|
className: cx({
|
|
@@ -344,7 +344,7 @@ const HvTagsInput = (props) => {
|
|
|
344
344
|
root: classes.tagInputContainerRoot,
|
|
345
345
|
gutters: classes.listItemGutters
|
|
346
346
|
},
|
|
347
|
-
id: `tag-${value.length}
|
|
347
|
+
id: setId(elementId, `tag-${value.length}`),
|
|
348
348
|
children: /* @__PURE__ */ jsx(HvInput, {
|
|
349
349
|
value: tagInput,
|
|
350
350
|
disableClear: true,
|