@hitachivantara/uikit-react-core 5.35.0 → 5.36.1
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/Drawer/Drawer.cjs +26 -8
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/ListContainer/ListItem/ListItem.cjs +3 -2
- package/dist/cjs/components/ListContainer/ListItem/ListItem.cjs.map +1 -1
- package/dist/cjs/components/TreeView/TreeItem/DefaultContent.cjs +54 -0
- package/dist/cjs/components/TreeView/TreeItem/DefaultContent.cjs.map +1 -0
- package/dist/cjs/components/TreeView/TreeItem/TreeItem.cjs +124 -0
- package/dist/cjs/components/TreeView/TreeItem/TreeItem.cjs.map +1 -0
- package/dist/cjs/components/TreeView/TreeItem/TreeItem.styles.cjs +74 -0
- package/dist/cjs/components/TreeView/TreeItem/TreeItem.styles.cjs.map +1 -0
- package/dist/cjs/components/TreeView/TreeItem/useHvTreeItem.cjs +62 -0
- package/dist/cjs/components/TreeView/TreeItem/useHvTreeItem.cjs.map +1 -0
- package/dist/cjs/components/TreeView/TreeView.cjs +72 -0
- package/dist/cjs/components/TreeView/TreeView.cjs.map +1 -0
- package/dist/cjs/components/TreeView/TreeView.styles.cjs +18 -0
- package/dist/cjs/components/TreeView/TreeView.styles.cjs.map +1 -0
- package/dist/cjs/components/TreeView/internals.cjs +30 -0
- package/dist/cjs/components/TreeView/internals.cjs.map +1 -0
- package/dist/cjs/index.cjs +10 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/components/Drawer/Drawer.js +28 -10
- package/dist/esm/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/components/ListContainer/ListItem/ListItem.js +4 -3
- package/dist/esm/components/ListContainer/ListItem/ListItem.js.map +1 -1
- package/dist/esm/components/TreeView/TreeItem/DefaultContent.js +54 -0
- package/dist/esm/components/TreeView/TreeItem/DefaultContent.js.map +1 -0
- package/dist/esm/components/TreeView/TreeItem/TreeItem.js +125 -0
- package/dist/esm/components/TreeView/TreeItem/TreeItem.js.map +1 -0
- package/dist/esm/components/TreeView/TreeItem/TreeItem.styles.js +74 -0
- package/dist/esm/components/TreeView/TreeItem/TreeItem.styles.js.map +1 -0
- package/dist/esm/components/TreeView/TreeItem/useHvTreeItem.js +62 -0
- package/dist/esm/components/TreeView/TreeItem/useHvTreeItem.js.map +1 -0
- package/dist/esm/components/TreeView/TreeView.js +73 -0
- package/dist/esm/components/TreeView/TreeView.js.map +1 -0
- package/dist/esm/components/TreeView/TreeView.styles.js +18 -0
- package/dist/esm/components/TreeView/TreeView.styles.js.map +1 -0
- package/dist/esm/components/TreeView/internals.js +15 -0
- package/dist/esm/components/TreeView/internals.js.map +1 -0
- package/dist/esm/index.js +12 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +125 -8
- package/package.json +4 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const classes = require("../../utils/classes.cjs");
|
|
4
|
+
const {
|
|
5
|
+
staticClasses,
|
|
6
|
+
useClasses
|
|
7
|
+
} = classes.createClasses("HvTreeView", {
|
|
8
|
+
/** Applied to the root element */
|
|
9
|
+
root: {
|
|
10
|
+
padding: 0,
|
|
11
|
+
margin: 0,
|
|
12
|
+
listStyle: "none",
|
|
13
|
+
outline: "none"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
exports.staticClasses = staticClasses;
|
|
17
|
+
exports.useClasses = useClasses;
|
|
18
|
+
//# sourceMappingURL=TreeView.styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeView.styles.cjs","sources":["../../../../src/components/TreeView/TreeView.styles.ts"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTreeView\", {\n /** Applied to the root element */\n root: {\n padding: 0,\n margin: 0,\n listStyle: \"none\",\n outline: \"none\",\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","padding","margin","listStyle","outline"],"mappings":";;;AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,cAAc;AAAA;AAAA,EAEvEC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,SAAS;AAAA,EACX;AACF,CAAC;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useTreeViewContext = require("@mui/x-tree-view/internals/TreeViewProvider/useTreeViewContext");
|
|
4
|
+
const TreeViewProvider = require("@mui/x-tree-view/internals/TreeViewProvider");
|
|
5
|
+
const DescendantProvider = require("@mui/x-tree-view/internals/TreeViewProvider/DescendantProvider");
|
|
6
|
+
const defaultPlugins = require("@mui/x-tree-view/internals/plugins/defaultPlugins");
|
|
7
|
+
const useTreeView = require("@mui/x-tree-view/internals/useTreeView");
|
|
8
|
+
const HV_TREE_VIEW_PLUGINS = [...defaultPlugins.DEFAULT_TREE_VIEW_PLUGINS];
|
|
9
|
+
Object.defineProperty(exports, "useTreeViewContext", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: () => useTreeViewContext.useTreeViewContext
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "TreeViewProvider", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => TreeViewProvider.TreeViewProvider
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DescendantProvider", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: () => DescendantProvider.DescendantProvider
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "useDescendant", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: () => DescendantProvider.useDescendant
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "useTreeView", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: () => useTreeView.useTreeView
|
|
28
|
+
});
|
|
29
|
+
exports.HV_TREE_VIEW_PLUGINS = HV_TREE_VIEW_PLUGINS;
|
|
30
|
+
//# sourceMappingURL=internals.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internals.cjs","sources":["../../../../src/components/TreeView/internals.ts"],"sourcesContent":["import { useTreeViewContext } from \"@mui/x-tree-view/internals/TreeViewProvider/useTreeViewContext\";\nimport { TreeViewProvider } from \"@mui/x-tree-view/internals/TreeViewProvider\";\nimport {\n DescendantProvider,\n TreeItemDescendant,\n useDescendant,\n} from \"@mui/x-tree-view/internals/TreeViewProvider/DescendantProvider\";\nimport {\n DEFAULT_TREE_VIEW_PLUGINS,\n DefaultTreeViewPlugins,\n DefaultTreeViewPluginParameters,\n} from \"@mui/x-tree-view/internals/plugins/defaultPlugins\";\nimport { useTreeView } from \"@mui/x-tree-view/internals/useTreeView\";\n\nexport type {\n DefaultTreeViewPlugins as HvTreeViewPlugins,\n DefaultTreeViewPluginParameters as HvTreeViewPluginParameters,\n TreeItemDescendant,\n};\n\nexport const HV_TREE_VIEW_PLUGINS = [...DEFAULT_TREE_VIEW_PLUGINS] as const;\n\nexport {\n DescendantProvider,\n TreeViewProvider,\n useDescendant,\n useTreeView,\n useTreeViewContext,\n};\n"],"names":["HV_TREE_VIEW_PLUGINS","DEFAULT_TREE_VIEW_PLUGINS"],"mappings":";;;;;;;AAoBaA,MAAAA,uBAAuB,CAAC,GAAGC,eAAyB,yBAAA;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -262,6 +262,11 @@ const CarouselControls = require("./components/Carousel/CarouselControls.cjs");
|
|
|
262
262
|
const CarouselThumbnails = require("./components/Carousel/CarouselThumbnails.cjs");
|
|
263
263
|
const TimePicker_styles = require("./components/TimePicker/TimePicker.styles.cjs");
|
|
264
264
|
const TimePicker = require("./components/TimePicker/TimePicker.cjs");
|
|
265
|
+
const TreeView_styles$1 = require("./components/TreeView/TreeView.styles.cjs");
|
|
266
|
+
const TreeView$1 = require("./components/TreeView/TreeView.cjs");
|
|
267
|
+
const TreeItem_styles = require("./components/TreeView/TreeItem/TreeItem.styles.cjs");
|
|
268
|
+
const TreeItem = require("./components/TreeView/TreeItem/TreeItem.cjs");
|
|
269
|
+
const useHvTreeItem = require("./components/TreeView/TreeItem/useHvTreeItem.cjs");
|
|
265
270
|
const Section_styles = require("./components/Section/Section.styles.cjs");
|
|
266
271
|
const Section = require("./components/Section/Section.cjs");
|
|
267
272
|
const useClickOutside = require("./hooks/useClickOutside.cjs");
|
|
@@ -624,6 +629,11 @@ exports.HvCarouselControls = CarouselControls.HvCarouselControls;
|
|
|
624
629
|
exports.HvCarouselThumbnails = CarouselThumbnails.HvCarouselThumbnails;
|
|
625
630
|
exports.timePickerClasses = TimePicker_styles.staticClasses;
|
|
626
631
|
exports.HvTimePicker = TimePicker.HvTimePicker;
|
|
632
|
+
exports.treeView2Classes = TreeView_styles$1.staticClasses;
|
|
633
|
+
exports.HvTreeView = TreeView$1.HvTreeView;
|
|
634
|
+
exports.treeItemClasses = TreeItem_styles.staticClasses;
|
|
635
|
+
exports.HvTreeItem = TreeItem.HvTreeItem;
|
|
636
|
+
exports.useHvTreeItem = useHvTreeItem.useHvTreeItem;
|
|
627
637
|
exports.sectionClasses = Section_styles.staticClasses;
|
|
628
638
|
exports.HvSection = Section.HvSection;
|
|
629
639
|
exports.useClickOutside = useClickOutside.useClickOutside;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { Drawer } from "@mui/material";
|
|
1
|
+
import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Drawer, Backdrop } from "@mui/material";
|
|
3
3
|
import { Close } from "@hitachivantara/uikit-react-icons";
|
|
4
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
4
5
|
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
5
6
|
import { withTooltip } from "../../hocs/withTooltip.js";
|
|
6
7
|
import { setId } from "../../utils/setId.js";
|
|
8
|
+
import { useTheme } from "../../hooks/useTheme.js";
|
|
9
|
+
import { hexToRgbA } from "../../utils/hexToRgbA.js";
|
|
7
10
|
import { useClasses } from "./Drawer.styles.js";
|
|
8
11
|
import { staticClasses } from "./Drawer.styles.js";
|
|
9
12
|
import { HvButton } from "../Button/Button.js";
|
|
@@ -17,21 +20,36 @@ const HvDrawer = (props) => {
|
|
|
17
20
|
onClose,
|
|
18
21
|
anchor = "right",
|
|
19
22
|
buttonTitle = "Close",
|
|
23
|
+
showBackdrop = true,
|
|
24
|
+
disableBackdropClick = false,
|
|
20
25
|
...others
|
|
21
26
|
} = useDefaultProps("HvDrawer", props);
|
|
22
27
|
const {
|
|
23
28
|
classes,
|
|
24
|
-
cx
|
|
29
|
+
cx,
|
|
30
|
+
css
|
|
25
31
|
} = useClasses(classesProp);
|
|
32
|
+
const {
|
|
33
|
+
colors
|
|
34
|
+
} = useTheme();
|
|
26
35
|
const closeButtonDisplay = () => /* @__PURE__ */ jsx(Close, { role: "none" });
|
|
27
36
|
const CloseButtonTooltipWrapper = buttonTitle ? withTooltip(closeButtonDisplay, buttonTitle, "top") : closeButtonDisplay;
|
|
28
|
-
return /* @__PURE__ */ jsxs(
|
|
29
|
-
classes: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
|
+
/* @__PURE__ */ jsxs(Drawer, { className: cx(classes.root, className), id, anchor, open, PaperProps: {
|
|
39
|
+
classes: {
|
|
40
|
+
root: classes.paper
|
|
41
|
+
}
|
|
42
|
+
}, onClose, ...others, children: [
|
|
43
|
+
/* @__PURE__ */ jsx(HvButton, { id: setId(id, "close"), className: classes.closeButton, variant: "secondaryGhost", onClick: onClose, "aria-label": buttonTitle, children: /* @__PURE__ */ jsx(CloseButtonTooltipWrapper, {}) }),
|
|
44
|
+
children
|
|
45
|
+
] }),
|
|
46
|
+
showBackdrop && /* @__PURE__ */ jsx(Backdrop, { open: !!open, onClick: (event) => {
|
|
47
|
+
if (disableBackdropClick)
|
|
48
|
+
return;
|
|
49
|
+
onClose?.(event, "backdropClick");
|
|
50
|
+
}, className: cx(css({
|
|
51
|
+
background: hexToRgbA(colors?.atmo4 || theme.colors.atmo4)
|
|
52
|
+
}), classes.background) })
|
|
35
53
|
] });
|
|
36
54
|
};
|
|
37
55
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import {\n Drawer as MuiDrawer,\n DrawerProps as MuiDrawerProps,\n} from \"@mui/material\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\nimport { setId } from \"@core/utils/setId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvButton } from \"@core/components/Button\";\n\nimport { staticClasses, useClasses } from \"./Drawer.styles\";\n\nexport { staticClasses as drawerClasses };\n\nexport type HvDrawerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDrawerProps\n extends MuiDrawerProps,\n Omit<MuiDrawerProps, \"classes\">,\n HvBaseProps<HTMLDivElement> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvDrawerClasses;\n /**\n * Components of the Drawer.\n */\n children?: React.ReactNode;\n /**\n * Current state of the Drawer.\n */\n open?: boolean;\n /**\n * Function executed on close.\n * Extended from Modal from material-ui\n *\n */\n onClose?: (\n event: React.SyntheticEvent,\n reason?: \"escapeKeyDown\" | \"backdropClick\"\n ) => void;\n /**\n * The side the drawer opens from.\n */\n anchor?: \"left\" | \"top\" | \"right\" | \"bottom\";\n /**\n * Title for the button close.\n */\n buttonTitle?: string;\n /** @ignore */\n ref?: MuiDrawerProps[\"ref\"];\n /** @ignore */\n component?: MuiDrawerProps[\"component\"];\n}\n\n/**\n * The Drawer component provides a foundation to create a sliding pane.\n * It only provides the pane with a close button, the rest of the\n * content can be customized.\n */\nexport const HvDrawer = (props: HvDrawerProps) => {\n const {\n className,\n classes: classesProp,\n id,\n children,\n open,\n onClose,\n anchor = \"right\",\n buttonTitle = \"Close\",\n ...others\n } = useDefaultProps(\"HvDrawer\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const closeButtonDisplay = () => <Close role=\"none\" />;\n\n const CloseButtonTooltipWrapper = buttonTitle\n ? withTooltip(closeButtonDisplay, buttonTitle, \"top\")\n : closeButtonDisplay;\n\n return (\n <MuiDrawer\n
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import {\n Drawer as MuiDrawer,\n DrawerProps as MuiDrawerProps,\n Backdrop as MuiBackdrop,\n} from \"@mui/material\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\nimport { setId } from \"@core/utils/setId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvButton } from \"@core/components/Button\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { staticClasses, useClasses } from \"./Drawer.styles\";\n\nexport { staticClasses as drawerClasses };\n\nexport type HvDrawerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDrawerProps\n extends MuiDrawerProps,\n Omit<MuiDrawerProps, \"classes\">,\n HvBaseProps<HTMLDivElement> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes?: HvDrawerClasses;\n /**\n * Components of the Drawer.\n */\n children?: React.ReactNode;\n /**\n * Current state of the Drawer.\n */\n open?: boolean;\n /**\n * Function executed on close.\n * Extended from Modal from material-ui\n *\n */\n onClose?: (\n event: React.SyntheticEvent,\n reason?: \"escapeKeyDown\" | \"backdropClick\"\n ) => void;\n /**\n * The side the drawer opens from.\n */\n anchor?: \"left\" | \"top\" | \"right\" | \"bottom\";\n /**\n * Title for the button close.\n */\n buttonTitle?: string;\n /**\n * Show backdrop when drawer ix open.\n */\n showBackdrop?: boolean;\n /**\n * Prevent closing the dialog when clicking on the backdrop.\n */\n disableBackdropClick?: boolean;\n /** @ignore */\n ref?: MuiDrawerProps[\"ref\"];\n /** @ignore */\n component?: MuiDrawerProps[\"component\"];\n}\n\n/**\n * The Drawer component provides a foundation to create a sliding pane.\n * It only provides the pane with a close button, the rest of the\n * content can be customized.\n */\nexport const HvDrawer = (props: HvDrawerProps) => {\n const {\n className,\n classes: classesProp,\n id,\n children,\n open,\n onClose,\n anchor = \"right\",\n buttonTitle = \"Close\",\n showBackdrop = true,\n disableBackdropClick = false,\n ...others\n } = useDefaultProps(\"HvDrawer\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n const { colors } = useTheme();\n\n const closeButtonDisplay = () => <Close role=\"none\" />;\n\n const CloseButtonTooltipWrapper = buttonTitle\n ? withTooltip(closeButtonDisplay, buttonTitle, \"top\")\n : closeButtonDisplay;\n\n return (\n <>\n <MuiDrawer\n className={cx(classes.root, className)}\n id={id}\n anchor={anchor}\n open={open}\n PaperProps={{\n classes: {\n root: classes.paper,\n },\n }}\n onClose={onClose}\n {...others}\n >\n <HvButton\n id={setId(id, \"close\")}\n className={classes.closeButton}\n variant=\"secondaryGhost\"\n onClick={onClose}\n aria-label={buttonTitle}\n >\n <CloseButtonTooltipWrapper />\n </HvButton>\n {children}\n </MuiDrawer>\n {showBackdrop && (\n <MuiBackdrop\n open={!!open}\n onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {\n if (disableBackdropClick) return;\n onClose?.(event, \"backdropClick\");\n }}\n className={cx(\n css({\n background: hexToRgbA(colors?.atmo4 || theme.colors.atmo4),\n }),\n classes.background\n )}\n />\n )}\n </>\n );\n};\n"],"names":["HvDrawer","props","className","classes","classesProp","id","children","open","onClose","anchor","buttonTitle","showBackdrop","disableBackdropClick","others","useDefaultProps","cx","css","useClasses","colors","useTheme","closeButtonDisplay","CloseButtonTooltipWrapper","withTooltip","MuiDrawer","root","paper","setId","closeButton","MuiBackdrop","event","background","hexToRgbA","atmo4","theme"],"mappings":";;;;;;;;;;;;AAsFaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAAS;AAAA,IACTC,cAAc;AAAA,IACdC,eAAe;AAAA,IACfC,uBAAuB;AAAA,IACvB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,YAAYb,KAAK;AAE/B,QAAA;AAAA,IAAEE;AAAAA,IAASY;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,WAAWb,WAAW;AAC7C,QAAA;AAAA,IAAEc;AAAAA,MAAWC,SAAS;AAE5B,QAAMC,qBAAqBA,MAAO,oBAAA,OAAA,EAAM,MAAK,OAAS,CAAA;AAEtD,QAAMC,4BAA4BX,cAC9BY,YAAYF,oBAAoBV,aAAa,KAAK,IAClDU;AAEJ,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,qBAAAG,QAAA,EACC,WAAWR,GAAGZ,QAAQqB,MAAMtB,SAAS,GACrC,IACA,QACA,MACA,YAAY;AAAA,MACVC,SAAS;AAAA,QACPqB,MAAMrB,QAAQsB;AAAAA,MAChB;AAAA,IAAA,GAEF,SACIZ,GAAAA,QAEJ,UAAA;AAAA,MAAA,oBAAC,YACC,IAAIa,MAAMrB,IAAI,OAAO,GACrB,WAAWF,QAAQwB,aACnB,SAAQ,kBACR,SAASnB,SACT,cAAYE,aAEZ,UAAA,oBAAC,4BAAyB,CAAA,GAC5B;AAAA,MACCJ;AAAAA,IAAAA,GACH;AAAA,IACCK,oCACEiB,UACC,EAAA,MAAM,CAAC,CAACrB,MACR,SAAS,CAACsB,UAAqD;AACzDjB,UAAAA;AAAsB;AAC1BJ,gBAAUqB,OAAO,eAAe;AAAA,IAAA,GAElC,WAAWd,GACTC,IAAI;AAAA,MACFc,YAAYC,UAAUb,QAAQc,SAASC,MAAMf,OAAOc,KAAK;AAAA,IAAA,CAC1D,GACD7B,QAAQ2B,UACV,GAEH;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import React__default, { useContext, useCallback, useMemo } from "react";
|
|
2
|
+
import React__default, { forwardRef, useContext, useCallback, useMemo } from "react";
|
|
3
3
|
import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
|
|
4
4
|
import { useClasses } from "./ListItem.styles.js";
|
|
5
5
|
import { staticClasses } from "./ListItem.styles.js";
|
|
@@ -24,7 +24,7 @@ const applyClassNameToElement = (element, className) => {
|
|
|
24
24
|
}
|
|
25
25
|
return null;
|
|
26
26
|
};
|
|
27
|
-
const HvListItem = (props) => {
|
|
27
|
+
const HvListItem = forwardRef((props, ref) => {
|
|
28
28
|
const {
|
|
29
29
|
id,
|
|
30
30
|
classes: classesProp,
|
|
@@ -78,6 +78,7 @@ const HvListItem = (props) => {
|
|
|
78
78
|
"li",
|
|
79
79
|
{
|
|
80
80
|
id,
|
|
81
|
+
ref,
|
|
81
82
|
role,
|
|
82
83
|
value,
|
|
83
84
|
className: cx(classes.root, {
|
|
@@ -107,7 +108,7 @@ const HvListItem = (props) => {
|
|
|
107
108
|
}, configuration: {
|
|
108
109
|
tabIndex
|
|
109
110
|
}, children: listItem }) : listItem;
|
|
110
|
-
};
|
|
111
|
+
});
|
|
111
112
|
export {
|
|
112
113
|
HvListItem,
|
|
113
114
|
staticClasses as listItemClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","sources":["../../../../../src/components/ListContainer/ListItem/ListItem.tsx"],"sourcesContent":["import React, { useCallback, useContext, useMemo } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvFocus } from \"@core/components/Focus\";\n\nimport HvListContext from \"../ListContext\";\nimport { staticClasses, useClasses } from \"./ListItem.styles\";\n\nexport { staticClasses as listItemClasses };\n\nexport type HvListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListItemProps extends HvBaseProps<HTMLLIElement> {\n /**\n * Overrides the implicit list item role.\n */\n role?: string;\n /** Indicates if the list item is selected. */\n selected?: boolean;\n /** If true, the list item will be disabled. */\n disabled?: boolean;\n /**\n * If the list item is focusable and reacts to mouse over events.\n * Defaults to true if the container list is interactive, false otherwise.\n */\n interactive?: boolean;\n /**\n * If `true` compacts the vertical spacing intended to separate the list items.\n * Defaults to the value set in container list.\n */\n condensed?: boolean;\n /**\n * If `true`, the left and right padding is removed.\n * Defaults to the value set in container list.\n */\n disableGutters?: boolean;\n /**\n * Element placed before the children.\n * Also removes the left padding (gutter).\n *\n * Some modifications are applied, assuming that it is either an icon (changing the color when the item is disabled)\n * or a selector (preventing the double focus ring, propagating the checked and disabled states and wiring the onChange event).\n * If unwanted, the element should be placed directly as a child.\n */\n startAdornment?: React.ReactNode;\n /**\n * Element placed after the children and aligned next to the margin.\n * Also removes the right padding (gutter).\n *\n * Some modifications are applied, assuming that it is an icon (changing the color when the item is disabled).\n * If unwanted, the element should be placed directly as a child.\n */\n endAdornment?: React.ReactNode;\n /** The value to be set on the 'li' element */\n value?: any;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListItemClasses;\n}\n\nconst applyClassNameAndStateToElement = (\n element,\n selected,\n disabled,\n onClick,\n className\n) => {\n if (element != null) {\n return React.cloneElement(element, {\n className,\n checked: !!selected,\n disabled,\n onChange: (evt) => onClick?.(evt),\n });\n }\n\n return null;\n};\n\nconst applyClassNameToElement = (element, className) => {\n if (element != null) {\n return React.cloneElement(element, {\n className,\n });\n }\n\n return null;\n};\n\n/**\n * ListItem description/documentation paragraph\n */\nexport const HvListItem = (props: HvListItemProps) => {\n const {\n id,\n classes: classesProp,\n className,\n role,\n value,\n selected,\n disabled,\n interactive: interactiveProp,\n condensed: condensedProp,\n disableGutters: disableGuttersProp,\n startAdornment,\n endAdornment,\n onClick,\n children,\n tabIndex,\n ...others\n } = useDefaultProps(\"HvListItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n topContainerRef,\n condensed: condensedContext,\n disableGutters: disableGuttersContext,\n interactive: interactiveContext,\n } = useContext(HvListContext);\n\n const condensed = condensedProp != null ? condensedProp : condensedContext;\n const disableGutters =\n disableGuttersProp != null ? disableGuttersProp : disableGuttersContext;\n const interactive =\n interactiveProp != null ? interactiveProp : interactiveContext;\n\n const handleOnClick = useCallback(\n (evt) => {\n if (!disabled) {\n onClick?.(evt);\n }\n },\n [disabled, onClick]\n );\n\n const clonedStartAdornment = useMemo(\n () =>\n applyClassNameAndStateToElement(\n startAdornment,\n selected,\n disabled,\n handleOnClick,\n cx(\n classes.startAdornment,\n { [classes.disabled]: disabled },\n React.isValidElement(startAdornment)\n ? startAdornment.props.className\n : undefined\n )\n ),\n [\n cx,\n classes?.startAdornment,\n classes?.disabled,\n disabled,\n handleOnClick,\n selected,\n startAdornment,\n ]\n );\n const clonedEndAdornment = useMemo(\n () =>\n applyClassNameToElement(\n endAdornment,\n cx(\n classes.endAdornment,\n { [classes.disabled]: disabled },\n React.isValidElement(endAdornment)\n ? endAdornment.props.className\n : undefined\n )\n ),\n [cx, classes?.endAdornment, classes?.disabled, disabled, endAdornment]\n );\n\n const roleOptionAriaProps =\n role === \"option\" || role === \"menuitem\"\n ? {\n \"aria-disabled\": disabled || undefined,\n \"aria-selected\": selected,\n }\n : {};\n\n const listItem = (\n // For later: this should only have an onClick event if interactive and has the appropriate role.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <li\n id={id}\n role={role}\n value={value}\n className={cx(\n classes.root,\n {\n [classes.gutters]: !disableGutters,\n [classes.condensed]: condensed,\n [classes.interactive]: interactive,\n [classes.selected]: !!selected,\n [classes.disabled]: !!disabled,\n [classes.withStartAdornment]: startAdornment != null,\n [classes.withEndAdornment]: endAdornment != null,\n },\n className\n )}\n onClick={handleOnClick}\n onKeyDown={() => {}} // Needed because of jsx-a11yclick-events-have-key-events\n {...roleOptionAriaProps}\n {...others}\n >\n {clonedStartAdornment}\n {children}\n {clonedEndAdornment}\n </li>\n );\n\n return interactive ? (\n <HvFocus\n rootRef={topContainerRef}\n selected={selected}\n disabledClass={disabled || undefined}\n strategy={role === \"option\" ? \"listbox\" : \"menu\"}\n classes={{ focus: classes.focus }}\n configuration={{\n tabIndex,\n }}\n >\n {listItem}\n </HvFocus>\n ) : (\n listItem\n );\n};\n"],"names":["applyClassNameAndStateToElement","element","selected","disabled","onClick","className","React","cloneElement","checked","onChange","evt","applyClassNameToElement","HvListItem","props","id","classes","classesProp","role","value","interactive","interactiveProp","condensed","condensedProp","disableGutters","disableGuttersProp","startAdornment","endAdornment","children","tabIndex","others","useDefaultProps","cx","useClasses","topContainerRef","condensedContext","disableGuttersContext","interactiveContext","useContext","HvListContext","handleOnClick","useCallback","clonedStartAdornment","useMemo","isValidElement","undefined","clonedEndAdornment","roleOptionAriaProps","listItem","root","gutters","withStartAdornment","withEndAdornment","focus"],"mappings":";;;;;;;AA6DA,MAAMA,kCAAkCA,CACtCC,SACAC,UACAC,UACAC,SACAC,cACG;AACH,MAAIJ,WAAW,MAAM;AACZK,WAAAA,eAAMC,aAAaN,SAAS;AAAA,MACjCI;AAAAA,MACAG,SAAS,CAAC,CAACN;AAAAA,MACXC;AAAAA,MACAM,UAAWC,CAAQN,QAAAA,UAAUM,GAAG;AAAA,IAAA,CACjC;AAAA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,YAAYyC,QAC3B,UAAU3B,SAAS,WAAW,YAAY,QAC1C,SAAS;AAAA,IAAEmC,OAAOrC,QAAQqC;AAAAA,KAC1B,eAAe;AAAA,IACbxB;AAAAA,EACF,GAECmB,oBACH,IAEAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ListItem.js","sources":["../../../../../src/components/ListContainer/ListItem/ListItem.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useContext, useMemo } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvFocus } from \"@core/components/Focus\";\n\nimport HvListContext from \"../ListContext\";\nimport { staticClasses, useClasses } from \"./ListItem.styles\";\n\nexport { staticClasses as listItemClasses };\n\nexport type HvListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListItemProps extends HvBaseProps<HTMLLIElement> {\n /**\n * Overrides the implicit list item role.\n */\n role?: HvBaseProps<HTMLLIElement>[\"role\"];\n /** Indicates if the list item is selected. */\n selected?: boolean;\n /** If true, the list item will be disabled. */\n disabled?: boolean;\n /**\n * If the list item is focusable and reacts to mouse over events.\n * Defaults to true if the container list is interactive, false otherwise.\n */\n interactive?: boolean;\n /**\n * If `true` compacts the vertical spacing intended to separate the list items.\n * Defaults to the value set in container list.\n */\n condensed?: boolean;\n /**\n * If `true`, the left and right padding is removed.\n * Defaults to the value set in container list.\n */\n disableGutters?: boolean;\n /**\n * Element placed before the children.\n * Also removes the left padding (gutter).\n *\n * Some modifications are applied, assuming that it is either an icon (changing the color when the item is disabled)\n * or a selector (preventing the double focus ring, propagating the checked and disabled states and wiring the onChange event).\n * If unwanted, the element should be placed directly as a child.\n */\n startAdornment?: React.ReactNode;\n /**\n * Element placed after the children and aligned next to the margin.\n * Also removes the right padding (gutter).\n *\n * Some modifications are applied, assuming that it is an icon (changing the color when the item is disabled).\n * If unwanted, the element should be placed directly as a child.\n */\n endAdornment?: React.ReactNode;\n /** The value to be set on the 'li' element */\n value?: any;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListItemClasses;\n}\n\nconst applyClassNameAndStateToElement = (\n element,\n selected,\n disabled,\n onClick,\n className\n) => {\n if (element != null) {\n return React.cloneElement(element, {\n className,\n checked: !!selected,\n disabled,\n onChange: (evt) => onClick?.(evt),\n });\n }\n\n return null;\n};\n\nconst applyClassNameToElement = (element, className) => {\n if (element != null) {\n return React.cloneElement(element, {\n className,\n });\n }\n\n return null;\n};\n\n/**\n * ListItem description/documentation paragraph\n */\nexport const HvListItem = forwardRef<any, HvListItemProps>((props, ref) => {\n const {\n id,\n classes: classesProp,\n className,\n role,\n value,\n selected,\n disabled,\n interactive: interactiveProp,\n condensed: condensedProp,\n disableGutters: disableGuttersProp,\n startAdornment,\n endAdornment,\n onClick,\n children,\n tabIndex,\n ...others\n } = useDefaultProps(\"HvListItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n topContainerRef,\n condensed: condensedContext,\n disableGutters: disableGuttersContext,\n interactive: interactiveContext,\n } = useContext(HvListContext);\n\n const condensed = condensedProp != null ? condensedProp : condensedContext;\n const disableGutters =\n disableGuttersProp != null ? disableGuttersProp : disableGuttersContext;\n const interactive =\n interactiveProp != null ? interactiveProp : interactiveContext;\n\n const handleOnClick = useCallback(\n (evt) => {\n if (!disabled) {\n onClick?.(evt);\n }\n },\n [disabled, onClick]\n );\n\n const clonedStartAdornment = useMemo(\n () =>\n applyClassNameAndStateToElement(\n startAdornment,\n selected,\n disabled,\n handleOnClick,\n cx(\n classes.startAdornment,\n { [classes.disabled]: disabled },\n React.isValidElement(startAdornment)\n ? startAdornment.props.className\n : undefined\n )\n ),\n [\n cx,\n classes?.startAdornment,\n classes?.disabled,\n disabled,\n handleOnClick,\n selected,\n startAdornment,\n ]\n );\n const clonedEndAdornment = useMemo(\n () =>\n applyClassNameToElement(\n endAdornment,\n cx(\n classes.endAdornment,\n { [classes.disabled]: disabled },\n React.isValidElement(endAdornment)\n ? endAdornment.props.className\n : undefined\n )\n ),\n [cx, classes?.endAdornment, classes?.disabled, disabled, endAdornment]\n );\n\n const roleOptionAriaProps =\n role === \"option\" || role === \"menuitem\"\n ? {\n \"aria-disabled\": disabled || undefined,\n \"aria-selected\": selected,\n }\n : {};\n\n const listItem = (\n // For later: this should only have an onClick event if interactive and has the appropriate role.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <li\n id={id}\n ref={ref}\n role={role}\n value={value}\n className={cx(\n classes.root,\n {\n [classes.gutters]: !disableGutters,\n [classes.condensed]: condensed,\n [classes.interactive]: interactive,\n [classes.selected]: !!selected,\n [classes.disabled]: !!disabled,\n [classes.withStartAdornment]: startAdornment != null,\n [classes.withEndAdornment]: endAdornment != null,\n },\n className\n )}\n onClick={handleOnClick}\n onKeyDown={() => {}} // Needed because of jsx-a11yclick-events-have-key-events\n {...roleOptionAriaProps}\n {...others}\n >\n {clonedStartAdornment}\n {children}\n {clonedEndAdornment}\n </li>\n );\n\n return interactive ? (\n <HvFocus\n rootRef={topContainerRef}\n selected={selected}\n disabledClass={disabled || undefined}\n strategy={role === \"option\" ? \"listbox\" : \"menu\"}\n classes={{ focus: classes.focus }}\n configuration={{\n tabIndex,\n }}\n >\n {listItem}\n </HvFocus>\n ) : (\n listItem\n );\n});\n"],"names":["applyClassNameAndStateToElement","element","selected","disabled","onClick","className","React","cloneElement","checked","onChange","evt","applyClassNameToElement","HvListItem","forwardRef","props","ref","id","classes","classesProp","role","value","interactive","interactiveProp","condensed","condensedProp","disableGutters","disableGuttersProp","startAdornment","endAdornment","children","tabIndex","others","useDefaultProps","cx","useClasses","topContainerRef","condensedContext","disableGuttersContext","interactiveContext","useContext","HvListContext","handleOnClick","useCallback","clonedStartAdornment","useMemo","isValidElement","undefined","clonedEndAdornment","roleOptionAriaProps","listItem","root","gutters","withStartAdornment","withEndAdornment","focus"],"mappings":";;;;;;;AA6DA,MAAMA,kCAAkCA,CACtCC,SAC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AAM;AAAA,QAAC;AAAA,QAClB,GAAIO;AAAAA,QACJ,GAAIjB;AAAAA,QAEHY,UAAAA;AAAAA,UAAAA;AAAAA,UACAd;AAAAA,UACAkB;AAAAA,QAAAA;AAAAA,MAAAA;AAAAA,IACH;AAAA;AAGF,SAAO1B,cACL,oBAAC,SACC,EAAA,SAASc,iBACT,UACA,eAAehC,YAAY2C,QAC3B,UAAU3B,SAAS,WAAW,YAAY,QAC1C,SAAS;AAAA,IAAEmC,OAAOrC,QAAQqC;AAAAA,KAC1B,eAAe;AAAA,IACbxB;AAAAA,EACF,GAECmB,oBACH,IAEAA;AAEJ,CAAC;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useCss } from "../../../hooks/useCss.js";
|
|
4
|
+
import { useHvTreeItem } from "./useHvTreeItem.js";
|
|
5
|
+
const DefaultContent = forwardRef((props, ref) => {
|
|
6
|
+
const {
|
|
7
|
+
classes,
|
|
8
|
+
className,
|
|
9
|
+
displayIcon,
|
|
10
|
+
expansionIcon,
|
|
11
|
+
icon: iconProp,
|
|
12
|
+
label,
|
|
13
|
+
nodeId,
|
|
14
|
+
onClick,
|
|
15
|
+
onMouseDown,
|
|
16
|
+
...others
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
cx
|
|
20
|
+
} = useCss();
|
|
21
|
+
const {
|
|
22
|
+
disabled,
|
|
23
|
+
expanded,
|
|
24
|
+
selected,
|
|
25
|
+
focused,
|
|
26
|
+
handleExpansion,
|
|
27
|
+
handleSelection,
|
|
28
|
+
preventSelection
|
|
29
|
+
} = useHvTreeItem(nodeId);
|
|
30
|
+
const icon = iconProp ?? expansionIcon ?? displayIcon;
|
|
31
|
+
return (
|
|
32
|
+
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */
|
|
33
|
+
/* @__PURE__ */ jsxs("div", { ...others, className: cx(className, classes.root, {
|
|
34
|
+
[classes.expanded]: expanded,
|
|
35
|
+
[classes.selected]: selected,
|
|
36
|
+
[classes.focused]: focused,
|
|
37
|
+
[classes.disabled]: disabled
|
|
38
|
+
}), onClick: (event) => {
|
|
39
|
+
handleExpansion(event);
|
|
40
|
+
handleSelection(event);
|
|
41
|
+
onClick?.(event);
|
|
42
|
+
}, onMouseDown: (event) => {
|
|
43
|
+
preventSelection(event);
|
|
44
|
+
onMouseDown?.(event);
|
|
45
|
+
}, ref, children: [
|
|
46
|
+
/* @__PURE__ */ jsx("div", { className: classes.iconContainer, children: icon }),
|
|
47
|
+
/* @__PURE__ */ jsx("div", { className: classes.label, children: label })
|
|
48
|
+
] })
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
export {
|
|
52
|
+
DefaultContent
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=DefaultContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultContent.js","sources":["../../../../../src/components/TreeView/TreeItem/DefaultContent.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport { useCss } from \"@core/hooks/useCss\";\n\nimport type { HvTreeContentProps } from \"./TreeItem\";\nimport { useHvTreeItem } from \"./useHvTreeItem\";\n\n/**\n * Internal default TreeItem `component`.\n * Use this as a basis to create a custom component.\n */\nexport const DefaultContent = forwardRef<HTMLDivElement, HvTreeContentProps>(\n (props, ref) => {\n const {\n classes,\n className,\n displayIcon,\n expansionIcon,\n icon: iconProp,\n label,\n nodeId,\n onClick,\n onMouseDown,\n ...others\n } = props;\n\n const { cx } = useCss();\n\n const {\n disabled,\n expanded,\n selected,\n focused,\n handleExpansion,\n handleSelection,\n preventSelection,\n } = useHvTreeItem(nodeId);\n\n const icon = iconProp ?? expansionIcon ?? displayIcon;\n\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */\n <div\n {...others}\n className={cx(className, classes.root, {\n [classes.expanded]: expanded,\n [classes.selected]: selected,\n [classes.focused]: focused,\n [classes.disabled]: disabled,\n })}\n onClick={(event) => {\n handleExpansion(event);\n handleSelection(event);\n onClick?.(event);\n }}\n onMouseDown={(event) => {\n preventSelection(event);\n onMouseDown?.(event);\n }}\n ref={ref}\n >\n <div className={classes.iconContainer}>{icon}</div>\n <div className={classes.label}>{label}</div>\n </div>\n );\n }\n);\n"],"names":["DefaultContent","forwardRef","props","ref","classes","className","displayIcon","expansionIcon","icon","iconProp","label","nodeId","onClick","onMouseDown","others","cx","useCss","disabled","expanded","selected","focused","handleExpansion","handleSelection","preventSelection","useHvTreeItem","root","event","iconContainer"],"mappings":";;;;AAWO,MAAMA,iBAAiBC,WAC5B,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,MAAMC;AAAAA,IACNC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EACDZ,IAAAA;AAEE,QAAA;AAAA,IAAEa;AAAAA,MAAOC,OAAO;AAEhB,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,cAAcb,MAAM;AAElBH,QAAAA,OAAOC,YAAYF,iBAAiBD;AAE1C;AAAA;AAAA,IAEE,qBAAC,SACC,GAAIQ,QACJ,WAAWC,GAAGV,WAAWD,QAAQqB,MAAM;AAAA,MACrC,CAACrB,QAAQc,QAAQ,GAAGA;AAAAA,MACpB,CAACd,QAAQe,QAAQ,GAAGA;AAAAA,MACpB,CAACf,QAAQgB,OAAO,GAAGA;AAAAA,MACnB,CAAChB,QAAQa,QAAQ,GAAGA;AAAAA,IAAAA,CACrB,GACD,SAAUS,CAAU,UAAA;AAClBL,sBAAgBK,KAAK;AACrBJ,sBAAgBI,KAAK;AACrBd,gBAAUc,KAAK;AAAA,IAAA,GAEjB,aAAcA,CAAU,UAAA;AACtBH,uBAAiBG,KAAK;AACtBb,oBAAca,KAAK;AAAA,IAAA,GAErB,KAEA,UAAA;AAAA,MAAA,oBAAC,OAAI,EAAA,WAAWtB,QAAQuB,eAAgBnB,UAAK,MAAA;AAAA,MAC5C,oBAAA,OAAA,EAAI,WAAWJ,QAAQM,OAAQA,UAAM,OAAA;AAAA,IAAA,GACxC;AAAA;AAEJ,CACF;"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useRef, useMemo, useEffect } from "react";
|
|
3
|
+
import { Collapse } from "@mui/material";
|
|
4
|
+
import { useForkRef } from "../../../hooks/useForkRef.js";
|
|
5
|
+
import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
|
|
6
|
+
import "../internals.js";
|
|
7
|
+
import { useClasses } from "./TreeItem.styles.js";
|
|
8
|
+
import { staticClasses } from "./TreeItem.styles.js";
|
|
9
|
+
import { DefaultContent } from "./DefaultContent.js";
|
|
10
|
+
import { useTreeViewContext } from "@mui/x-tree-view/internals/TreeViewProvider/useTreeViewContext";
|
|
11
|
+
import { useDescendant, DescendantProvider } from "@mui/x-tree-view/internals/TreeViewProvider/DescendantProvider";
|
|
12
|
+
const HvTreeItem = forwardRef((props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
id: idProp,
|
|
15
|
+
nodeId,
|
|
16
|
+
children,
|
|
17
|
+
classes: classesProp,
|
|
18
|
+
className,
|
|
19
|
+
label,
|
|
20
|
+
disabled: disabledProp,
|
|
21
|
+
icon,
|
|
22
|
+
endIcon,
|
|
23
|
+
expandIcon,
|
|
24
|
+
collapseIcon,
|
|
25
|
+
ContentComponent: Component = DefaultContent,
|
|
26
|
+
TransitionProps: transitionProps,
|
|
27
|
+
ContentProps: contentProps,
|
|
28
|
+
...others
|
|
29
|
+
} = useDefaultProps("HvTreeItem", props);
|
|
30
|
+
const {
|
|
31
|
+
classes,
|
|
32
|
+
cx
|
|
33
|
+
} = useClasses(classesProp);
|
|
34
|
+
const {
|
|
35
|
+
instance,
|
|
36
|
+
multiSelect,
|
|
37
|
+
disabledItemsFocusable,
|
|
38
|
+
treeId,
|
|
39
|
+
icons: contextIcons
|
|
40
|
+
} = useTreeViewContext();
|
|
41
|
+
const id = idProp || treeId && nodeId && `${treeId}-${nodeId}` || void 0;
|
|
42
|
+
const [treeItemElement, setTreeItemElement] = useState(null);
|
|
43
|
+
const contentRef = useRef(null);
|
|
44
|
+
const handleRef = useForkRef(setTreeItemElement, ref);
|
|
45
|
+
const descendant = useMemo(() => ({
|
|
46
|
+
element: treeItemElement,
|
|
47
|
+
id: nodeId
|
|
48
|
+
}), [nodeId, treeItemElement]);
|
|
49
|
+
const {
|
|
50
|
+
index,
|
|
51
|
+
parentId
|
|
52
|
+
} = useDescendant(descendant);
|
|
53
|
+
const expandable = !!(Array.isArray(children) ? children.length : children);
|
|
54
|
+
const expanded = instance ? instance.isNodeExpanded(nodeId) : false;
|
|
55
|
+
const focused = instance ? instance.isNodeFocused(nodeId) : false;
|
|
56
|
+
const selected = instance ? instance.isNodeSelected(nodeId) : false;
|
|
57
|
+
const disabled = instance ? instance.isNodeDisabled(nodeId) : false;
|
|
58
|
+
const expansionIcon = !expanded ? expandIcon || contextIcons.defaultExpandIcon : collapseIcon || contextIcons.defaultCollapseIcon;
|
|
59
|
+
const displayIcon = expandable ? contextIcons.defaultParentIcon : endIcon || contextIcons.defaultEndIcon;
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (instance && index !== -1) {
|
|
62
|
+
instance.updateNode({
|
|
63
|
+
id: nodeId,
|
|
64
|
+
idAttribute: id,
|
|
65
|
+
index,
|
|
66
|
+
parentId,
|
|
67
|
+
expandable,
|
|
68
|
+
disabled: disabledProp
|
|
69
|
+
});
|
|
70
|
+
return () => instance.removeNode(nodeId);
|
|
71
|
+
}
|
|
72
|
+
return void 0;
|
|
73
|
+
}, [instance, parentId, index, nodeId, expandable, disabledProp, id]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (instance && label) {
|
|
76
|
+
return instance.mapFirstChar(nodeId, (contentRef.current?.textContent ?? "").substring(0, 1).toLowerCase());
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
}, [instance, nodeId, label]);
|
|
80
|
+
const handleFocus = (event) => {
|
|
81
|
+
if (event.target === event.currentTarget) {
|
|
82
|
+
const rootElement = typeof event.target.getRootNode === "function" ? event.target.getRootNode() : event.target.ownerDocument || document;
|
|
83
|
+
rootElement.getElementById(treeId).focus({
|
|
84
|
+
preventScroll: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const unfocusable = !disabledItemsFocusable && disabled;
|
|
88
|
+
const canFocus = instance && !focused && !disabled && !unfocusable && event.currentTarget === event.target;
|
|
89
|
+
if (canFocus) {
|
|
90
|
+
instance.focusNode(event, nodeId);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
94
|
+
"li",
|
|
95
|
+
{
|
|
96
|
+
id,
|
|
97
|
+
ref: handleRef,
|
|
98
|
+
role: "treeitem",
|
|
99
|
+
"aria-expanded": expandable ? expanded : void 0,
|
|
100
|
+
"aria-selected": multiSelect && selected || selected || void 0,
|
|
101
|
+
"aria-disabled": disabled || void 0,
|
|
102
|
+
className: cx(classes.root, className),
|
|
103
|
+
onFocus: handleFocus,
|
|
104
|
+
tabIndex: -1,
|
|
105
|
+
...others,
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(Component, { ref: contentRef, nodeId, classes: {
|
|
108
|
+
root: classes.content,
|
|
109
|
+
expanded: classes.expanded,
|
|
110
|
+
selected: classes.selected,
|
|
111
|
+
focused: classes.focused,
|
|
112
|
+
disabled: classes.disabled,
|
|
113
|
+
label: classes.label,
|
|
114
|
+
iconContainer: classes.iconContainer
|
|
115
|
+
}, label, icon, expansionIcon: expandable && expansionIcon, displayIcon, ...contentProps }),
|
|
116
|
+
children && /* @__PURE__ */ jsx(DescendantProvider, { id: nodeId, children: /* @__PURE__ */ jsx(Collapse, { component: "ul", role: "group", unmountOnExit: true, className: classes.group, in: expanded, ...transitionProps, children }) })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
export {
|
|
122
|
+
HvTreeItem,
|
|
123
|
+
staticClasses as treeItemClasses
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=TreeItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeItem.js","sources":["../../../../../src/components/TreeView/TreeItem/TreeItem.tsx"],"sourcesContent":["import {\n FocusEvent,\n ReactNode,\n forwardRef,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Collapse } from \"@mui/material\";\nimport type { TreeItemContentProps, TreeItemProps } from \"@mui/x-tree-view\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport {\n HvTreeViewPlugins,\n DescendantProvider,\n TreeItemDescendant,\n useDescendant,\n useTreeViewContext,\n} from \"../internals\";\nimport { staticClasses, useClasses } from \"./TreeItem.styles\";\nimport { DefaultContent } from \"./DefaultContent\";\n\nexport { staticClasses as treeItemClasses };\n\nexport type HvTreeItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTreeContentProps extends TreeItemContentProps {}\n\nexport interface HvTreeItemProps extends TreeItemProps {\n classes?: HvTreeItemClasses;\n disabled?: boolean;\n icon?: ReactNode;\n ContentComponent?: React.JSXElementConstructor<HvTreeContentProps>;\n}\n\nexport const HvTreeItem = forwardRef<HTMLLIElement, HvTreeItemProps>(\n (props, ref) => {\n const {\n id: idProp,\n nodeId,\n children,\n classes: classesProp,\n className,\n label,\n disabled: disabledProp,\n icon,\n endIcon,\n expandIcon,\n collapseIcon,\n ContentComponent: Component = DefaultContent,\n TransitionProps: transitionProps,\n ContentProps: contentProps,\n ...others\n } = useDefaultProps(\"HvTreeItem\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const {\n instance,\n multiSelect,\n disabledItemsFocusable,\n treeId,\n icons: contextIcons,\n } = useTreeViewContext<HvTreeViewPlugins>();\n\n const id =\n idProp || (treeId && nodeId && `${treeId}-${nodeId}`) || undefined;\n\n const [treeItemElement, setTreeItemElement] =\n useState<HTMLLIElement | null>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(setTreeItemElement, ref);\n\n const descendant = useMemo<TreeItemDescendant>(\n () => ({ element: treeItemElement!, id: nodeId }),\n [nodeId, treeItemElement]\n );\n\n const { index, parentId } = useDescendant(descendant);\n\n const expandable = !!(Array.isArray(children) ? children.length : children);\n const expanded = instance ? instance.isNodeExpanded(nodeId) : false;\n const focused = instance ? instance.isNodeFocused(nodeId) : false;\n const selected = instance ? instance.isNodeSelected(nodeId) : false;\n const disabled = instance ? instance.isNodeDisabled(nodeId) : false;\n\n const expansionIcon = !expanded\n ? expandIcon || contextIcons.defaultExpandIcon\n : collapseIcon || contextIcons.defaultCollapseIcon;\n\n const displayIcon = expandable\n ? contextIcons.defaultParentIcon\n : endIcon || contextIcons.defaultEndIcon;\n\n useEffect(() => {\n // On the first render a node's index will be -1. We want to wait for the real index.\n if (instance && index !== -1) {\n instance.updateNode({\n id: nodeId,\n idAttribute: id,\n index,\n parentId,\n expandable,\n disabled: disabledProp,\n });\n\n return () => instance.removeNode(nodeId);\n }\n\n return undefined;\n }, [instance, parentId, index, nodeId, expandable, disabledProp, id]);\n\n useEffect(() => {\n if (instance && label) {\n return instance.mapFirstChar(\n nodeId,\n (contentRef.current?.textContent ?? \"\").substring(0, 1).toLowerCase()\n );\n }\n return undefined;\n }, [instance, nodeId, label]);\n\n const handleFocus = (event: FocusEvent<HTMLLIElement, any>) => {\n // DOM focus stays on the tree which manages focus with aria-activedescendant\n if (event.target === event.currentTarget) {\n const rootElement: any =\n typeof event.target.getRootNode === \"function\"\n ? event.target.getRootNode()\n : event.target.ownerDocument || document;\n\n rootElement.getElementById(treeId).focus({ preventScroll: true });\n }\n\n const unfocusable = !disabledItemsFocusable && disabled;\n const canFocus =\n instance &&\n !focused &&\n !disabled &&\n !unfocusable &&\n event.currentTarget === event.target;\n\n if (canFocus) {\n instance.focusNode(event, nodeId);\n }\n };\n\n return (\n <li\n id={id}\n ref={handleRef}\n role=\"treeitem\"\n aria-expanded={expandable ? expanded : undefined}\n aria-selected={(multiSelect && selected) || selected || undefined}\n aria-disabled={disabled || undefined}\n className={cx(classes.root, className)}\n // @ts-ignore\n onFocus={handleFocus}\n tabIndex={-1}\n {...others}\n >\n <Component\n ref={contentRef}\n nodeId={nodeId}\n classes={{\n root: classes.content,\n expanded: classes.expanded,\n selected: classes.selected,\n focused: classes.focused,\n disabled: classes.disabled,\n label: classes.label,\n iconContainer: classes.iconContainer,\n }}\n label={label}\n icon={icon}\n expansionIcon={expandable && expansionIcon}\n displayIcon={displayIcon}\n {...contentProps}\n />\n {children && (\n <DescendantProvider id={nodeId}>\n <Collapse\n component=\"ul\"\n role=\"group\"\n unmountOnExit\n className={classes.group}\n in={expanded}\n {...transitionProps}\n >\n {children}\n </Collapse>\n </DescendantProvider>\n )}\n </li>\n );\n }\n);\n"],"names":["HvTreeItem","forwardRef","props","ref","id","idProp","nodeId","children","classes","classesProp","className","label","disabled","disabledProp","icon","endIcon","expandIcon","collapseIcon","ContentComponent","Component","DefaultContent","TransitionProps","transitionProps","ContentProps","contentProps","others","useDefaultProps","cx","useClasses","instance","multiSelect","disabledItemsFocusable","treeId","icons","contextIcons","useTreeViewContext","undefined","treeItemElement","setTreeItemElement","useState","contentRef","useRef","handleRef","useForkRef","descendant","useMemo","element","index","parentId","useDescendant","expandable","Array","isArray","length","expanded","isNodeExpanded","focused","isNodeFocused","selected","isNodeSelected","isNodeDisabled","expansionIcon","defaultExpandIcon","defaultCollapseIcon","displayIcon","defaultParentIcon","defaultEndIcon","useEffect","updateNode","idAttribute","removeNode","mapFirstChar","current","textContent","substring","toLowerCase","handleFocus","event","target","currentTarget","rootElement","getRootNode","ownerDocument","document","getElementById","focus","preventScroll","unfocusable","canFocus","focusNode","root","content","iconContainer","group"],"mappings":";;;;;;;;;;;AAuCO,MAAMA,aAAaC,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,IAAIC;AAAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,UAAUC;AAAAA,IACVC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,kBAAkBC,YAAYC;AAAAA,IAC9BC,iBAAiBC;AAAAA,IACjBC,cAAcC;AAAAA,IACd,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,cAAcxB,KAAK;AACjC,QAAA;AAAA,IAAEM;AAAAA,IAASmB;AAAAA,EAAAA,IAAOC,WAAWnB,WAAW;AAExC,QAAA;AAAA,IACJoB;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAOC;AAAAA,MACLC,mBAAsC;AAEpC/B,QAAAA,KACJC,UAAW2B,UAAU1B,UAAW,GAAE0B,MAAO,IAAG1B,MAAO,MAAM8B;AAE3D,QAAM,CAACC,iBAAiBC,kBAAkB,IACxCC,SAA+B,IAAI;AAC/BC,QAAAA,aAAaC,OAAuB,IAAI;AACxCC,QAAAA,YAAYC,WAAWL,oBAAoBnC,GAAG;AAE9CyC,QAAAA,aAAaC,QACjB,OAAO;AAAA,IAAEC,SAAST;AAAAA,IAAkBjC,IAAIE;AAAAA,EACxC,IAAA,CAACA,QAAQ+B,eAAe,CAC1B;AAEM,QAAA;AAAA,IAAEU;AAAAA,IAAOC;AAAAA,EAAAA,IAAaC,cAAcL,UAAU;AA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@
|
|
|
1
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
import { createClasses } from "../../../utils/classes.js";
|
|
3
|
+
import { outlineStyles } from "../../../utils/focusUtils.js";
|
|
4
|
+
const {
|
|
5
|
+
staticClasses,
|
|
6
|
+
useClasses
|
|
7
|
+
} = createClasses("HvTreeItem", {
|
|
8
|
+
/** Applied to the root element */
|
|
9
|
+
root: {
|
|
10
|
+
listStyle: "none",
|
|
11
|
+
margin: 0,
|
|
12
|
+
padding: 0,
|
|
13
|
+
outline: 0
|
|
14
|
+
},
|
|
15
|
+
group: {
|
|
16
|
+
margin: 0,
|
|
17
|
+
padding: 0,
|
|
18
|
+
marginLeft: theme.space.sm
|
|
19
|
+
},
|
|
20
|
+
content: {
|
|
21
|
+
padding: theme.spacing(0, 1),
|
|
22
|
+
minHeight: 32,
|
|
23
|
+
// TODO: review
|
|
24
|
+
width: "100%",
|
|
25
|
+
boxSizing: "border-box",
|
|
26
|
+
// prevent width + padding to overflow
|
|
27
|
+
display: "flex",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
cursor: "pointer",
|
|
30
|
+
WebkitTapHighlightColor: "transparent",
|
|
31
|
+
"&:hover:not($disabled)": {
|
|
32
|
+
backgroundColor: theme.colors.containerBackgroundHover
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
expanded: {},
|
|
36
|
+
selected: {
|
|
37
|
+
backgroundColor: theme.colors.atmo3
|
|
38
|
+
},
|
|
39
|
+
focused: {
|
|
40
|
+
backgroundColor: theme.colors.containerBackgroundHover,
|
|
41
|
+
"&:focus-visible": {
|
|
42
|
+
...outlineStyles
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
disabled: {
|
|
46
|
+
cursor: "not-allowed",
|
|
47
|
+
color: theme.colors.secondary_60,
|
|
48
|
+
"& $label": {
|
|
49
|
+
color: theme.colors.secondary_60
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
label: {
|
|
53
|
+
paddingLeft: 4,
|
|
54
|
+
width: "100%",
|
|
55
|
+
boxSizing: "border-box",
|
|
56
|
+
// fixes overflow
|
|
57
|
+
minWidth: 0,
|
|
58
|
+
position: "relative",
|
|
59
|
+
...theme.typography.body
|
|
60
|
+
},
|
|
61
|
+
iconContainer: {
|
|
62
|
+
display: "flex",
|
|
63
|
+
flexShrink: 0,
|
|
64
|
+
justifyContent: "center",
|
|
65
|
+
width: 16,
|
|
66
|
+
// TODO: review
|
|
67
|
+
marginRight: 4
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
export {
|
|
71
|
+
staticClasses,
|
|
72
|
+
useClasses
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=TreeItem.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeItem.styles.js","sources":["../../../../../src/components/TreeView/TreeItem/TreeItem.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\nimport { outlineStyles } from \"@core/utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTreeItem\", {\n /** Applied to the root element */\n root: {\n listStyle: \"none\",\n margin: 0,\n padding: 0,\n outline: 0,\n },\n group: {\n margin: 0,\n padding: 0,\n marginLeft: theme.space.sm,\n },\n\n content: {\n padding: theme.spacing(0, 1),\n minHeight: 32, // TODO: review\n\n width: \"100%\",\n boxSizing: \"border-box\", // prevent width + padding to overflow\n display: \"flex\",\n alignItems: \"center\",\n cursor: \"pointer\",\n WebkitTapHighlightColor: \"transparent\",\n \"&:hover:not($disabled)\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n },\n expanded: {},\n selected: {\n backgroundColor: theme.colors.atmo3,\n },\n focused: {\n backgroundColor: theme.colors.containerBackgroundHover,\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n disabled: {\n cursor: \"not-allowed\",\n color: theme.colors.secondary_60,\n \"& $label\": {\n color: theme.colors.secondary_60,\n },\n },\n label: {\n paddingLeft: 4,\n width: \"100%\",\n boxSizing: \"border-box\",\n\n // fixes overflow\n minWidth: 0,\n position: \"relative\",\n ...theme.typography.body,\n },\n iconContainer: {\n display: \"flex\",\n flexShrink: 0,\n justifyContent: \"center\",\n\n width: 16, // TODO: review\n marginRight: 4,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","listStyle","margin","padding","outline","group","marginLeft","theme","space","sm","content","spacing","minHeight","width","boxSizing","display","alignItems","cursor","WebkitTapHighlightColor","backgroundColor","colors","containerBackgroundHover","expanded","selected","atmo3","focused","outlineStyles","disabled","color","secondary_60","label","paddingLeft","minWidth","position","typography","body","iconContainer","flexShrink","justifyContent","marginRight"],"mappings":";;;AAKa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,cAAc;AAAA;AAAA,EAEvEC,MAAM;AAAA,IACJC,WAAW;AAAA,IACXC,QAAQ;AAAA,IACRC,SAAS;AAAA,IACTC,SAAS;AAAA,EACX;AAAA,EACAC,OAAO;AAAA,IACLH,QAAQ;AAAA,IACRC,SAAS;AAAA,IACTG,YAAYC,MAAMC,MAAMC;AAAAA,EAC1B;AAAA,EAEAC,SAAS;AAAA,IACPP,SAASI,MAAMI,QAAQ,GAAG,CAAC;AAAA,IAC3BC,WAAW;AAAA;AAAA,IAEXC,OAAO;AAAA,IACPC,WAAW;AAAA;AAAA,IACXC,SAAS;AAAA,IACTC,YAAY;AAAA,IACZC,QAAQ;AAAA,IACRC,yBAAyB;AAAA,IACzB,0BAA0B;AAAA,MACxBC,iBAAiBZ,MAAMa,OAAOC;AAAAA,IAChC;AAAA,EACF;AAAA,EACAC,UAAU,CAAC;AAAA,EACXC,UAAU;AAAA,IACRJ,iBAAiBZ,MAAMa,OAAOI;AAAAA,EAChC;AAAA,EACAC,SAAS;AAAA,IACPN,iBAAiBZ,MAAMa,OAAOC;AAAAA,IAC9B,mBAAmB;AAAA,MACjB,GAAGK;AAAAA,IACL;AAAA,EACF;AAAA,EACAC,UAAU;AAAA,IACRV,QAAQ;AAAA,IACRW,OAAOrB,MAAMa,OAAOS;AAAAA,IACpB,YAAY;AAAA,MACVD,OAAOrB,MAAMa,OAAOS;AAAAA,IACtB;AAAA,EACF;AAAA,EACAC,OAAO;AAAA,IACLC,aAAa;AAAA,IACblB,OAAO;AAAA,IACPC,WAAW;AAAA;AAAA,IAGXkB,UAAU;AAAA,IACVC,UAAU;AAAA,IACV,GAAG1B,MAAM2B,WAAWC;AAAAA,EACtB;AAAA,EACAC,eAAe;AAAA,IACbrB,SAAS;AAAA,IACTsB,YAAY;AAAA,IACZC,gBAAgB;AAAA,IAEhBzB,OAAO;AAAA;AAAA,IACP0B,aAAa;AAAA,EACf;AACF,CAAC;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "../internals.js";
|
|
2
|
+
import { useTreeViewContext } from "@mui/x-tree-view/internals/TreeViewProvider/useTreeViewContext";
|
|
3
|
+
function useHvTreeItem(nodeId) {
|
|
4
|
+
const {
|
|
5
|
+
instance,
|
|
6
|
+
multiSelect
|
|
7
|
+
} = useTreeViewContext();
|
|
8
|
+
const expandable = instance ? instance.isNodeExpandable(nodeId) : false;
|
|
9
|
+
const expanded = instance ? instance.isNodeExpanded(nodeId) : false;
|
|
10
|
+
const focused = instance ? instance.isNodeFocused(nodeId) : false;
|
|
11
|
+
const selected = instance ? instance.isNodeSelected(nodeId) : false;
|
|
12
|
+
const disabled = instance ? instance.isNodeDisabled(nodeId) : false;
|
|
13
|
+
const handleExpansion = (event) => {
|
|
14
|
+
if (!instance || disabled)
|
|
15
|
+
return;
|
|
16
|
+
if (!focused) {
|
|
17
|
+
instance.focusNode(event, nodeId);
|
|
18
|
+
}
|
|
19
|
+
const multiple = multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);
|
|
20
|
+
if (expandable && !(multiple && instance.isNodeExpanded(nodeId))) {
|
|
21
|
+
instance.toggleNodeExpansion(event, nodeId);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const handleSelection = (event) => {
|
|
25
|
+
if (!instance || disabled)
|
|
26
|
+
return;
|
|
27
|
+
if (!focused) {
|
|
28
|
+
instance.focusNode(event, nodeId);
|
|
29
|
+
}
|
|
30
|
+
const multiple = multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);
|
|
31
|
+
if (multiple) {
|
|
32
|
+
if (event.shiftKey) {
|
|
33
|
+
instance.selectRange(event, {
|
|
34
|
+
end: nodeId
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
instance.selectNode(event, nodeId, true);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
instance.selectNode(event, nodeId);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const preventSelection = (event) => {
|
|
44
|
+
if (event.shiftKey || event.ctrlKey || event.metaKey || disabled) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
instance,
|
|
50
|
+
disabled,
|
|
51
|
+
expanded,
|
|
52
|
+
selected,
|
|
53
|
+
focused,
|
|
54
|
+
handleExpansion,
|
|
55
|
+
handleSelection,
|
|
56
|
+
preventSelection
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
useHvTreeItem
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=useHvTreeItem.js.map
|