@hitachivantara/uikit-react-pentaho 6.0.13 → 6.0.15

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.
@@ -1,46 +1,42 @@
1
+ import { createContext, useCallback, useContext, useMemo, useState } from "react";
1
2
  import { jsx } from "react/jsx-runtime";
2
- import { createContext, useState, useCallback, useMemo, useContext } from "react";
3
- const HvCanvasContext = createContext(null);
4
- const HvCanvasProvider = ({
5
- children
6
- }) => {
7
- const [sidePanelOpen, setSidePanelOpen] = useState(false);
8
- const [width, setWidth] = useState(0);
9
- const [sidePanelDragging, setSidePanelDragging] = useState(false);
10
- const handleSidePanelWidth = useCallback((newWidth) => {
11
- setWidth(newWidth);
12
- }, []);
13
- const handleSidePanelOpen = useCallback((open) => {
14
- setSidePanelOpen(open);
15
- }, []);
16
- const handleSidePanelDragging = useCallback((dragging) => {
17
- setSidePanelDragging(dragging);
18
- }, []);
19
- const value = useMemo(
20
- () => ({
21
- sidePanelOpen,
22
- handleSidePanelOpen,
23
- sidePanelWidth: sidePanelOpen ? width : 0,
24
- handleSidePanelWidth,
25
- sidePanelDragging,
26
- handleSidePanelDragging
27
- }),
28
- [
29
- sidePanelOpen,
30
- handleSidePanelOpen,
31
- width,
32
- handleSidePanelWidth,
33
- sidePanelDragging,
34
- handleSidePanelDragging
35
- ]
36
- );
37
- return /* @__PURE__ */ jsx(HvCanvasContext.Provider, { value, children });
3
+ //#region src/Canvas/CanvasContext.tsx
4
+ var HvCanvasContext = createContext(null);
5
+ var HvCanvasProvider = ({ children }) => {
6
+ const [sidePanelOpen, setSidePanelOpen] = useState(false);
7
+ const [width, setWidth] = useState(0);
8
+ const [sidePanelDragging, setSidePanelDragging] = useState(false);
9
+ const handleSidePanelWidth = useCallback((newWidth) => {
10
+ setWidth(newWidth);
11
+ }, []);
12
+ const handleSidePanelOpen = useCallback((open) => {
13
+ setSidePanelOpen(open);
14
+ }, []);
15
+ const handleSidePanelDragging = useCallback((dragging) => {
16
+ setSidePanelDragging(dragging);
17
+ }, []);
18
+ const value = useMemo(() => ({
19
+ sidePanelOpen,
20
+ handleSidePanelOpen,
21
+ sidePanelWidth: sidePanelOpen ? width : 0,
22
+ handleSidePanelWidth,
23
+ sidePanelDragging,
24
+ handleSidePanelDragging
25
+ }), [
26
+ sidePanelOpen,
27
+ handleSidePanelOpen,
28
+ width,
29
+ handleSidePanelWidth,
30
+ sidePanelDragging,
31
+ handleSidePanelDragging
32
+ ]);
33
+ return /* @__PURE__ */ jsx(HvCanvasContext.Provider, {
34
+ value,
35
+ children
36
+ });
38
37
  };
39
- const useCanvasContext = () => {
40
- return useContext(HvCanvasContext);
41
- };
42
- export {
43
- HvCanvasContext,
44
- HvCanvasProvider,
45
- useCanvasContext
38
+ var useCanvasContext = () => {
39
+ return useContext(HvCanvasContext);
46
40
  };
41
+ //#endregion
42
+ export { HvCanvasContext, HvCanvasProvider, useCanvasContext };
@@ -1,42 +1,34 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { useClasses } from "./PanelTab.styles.js";
2
2
  import { forwardRef, useRef } from "react";
3
- import { Tab } from "@mui/base";
4
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-core";
5
- import { useClasses } from "./PanelTab.styles.js";
6
- import { staticClasses } from "./PanelTab.styles.js";
7
- const HvCanvasPanelTab = forwardRef(function HvCanvasPanelTab2(props, ref) {
8
- const {
9
- classes: classesProp,
10
- className,
11
- style,
12
- startActions,
13
- endActions,
14
- ...others
15
- } = useDefaultProps("HvCanvasPanelTab", props);
16
- const tabRef = useRef(null);
17
- const { classes, cx } = useClasses(classesProp);
18
- return (
19
- // oxlint-disable-next-line jsx_a11y/click-events-have-key-events,jsx_a11y/no-static-element-interactions, simulate tab click
20
- /* @__PURE__ */ jsxs(
21
- "div",
22
- {
23
- ref,
24
- style,
25
- className: cx(classes.root, className),
26
- onClick: (evt) => {
27
- if (evt.target === tabRef.current) return;
28
- tabRef.current?.click();
29
- },
30
- children: [
31
- startActions,
32
- /* @__PURE__ */ jsx(Tab, { ref: tabRef, className: classes.tab, ...others }),
33
- endActions
34
- ]
35
- }
36
- )
37
- );
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Tab } from "@mui/base";
6
+ //#region src/Canvas/PanelTab/PanelTab.tsx
7
+ /**
8
+ * The tab component to use inside `HvCanvasPanelTabs`.
9
+ */
10
+ var HvCanvasPanelTab = forwardRef(function HvCanvasPanelTab(props, ref) {
11
+ const { classes: classesProp, className, style, startActions, endActions, ...others } = useDefaultProps("HvCanvasPanelTab", props);
12
+ const tabRef = useRef(null);
13
+ const { classes, cx } = useClasses(classesProp);
14
+ return /* @__PURE__ */ jsxs("div", {
15
+ ref,
16
+ style,
17
+ className: cx(classes.root, className),
18
+ onClick: (evt) => {
19
+ if (evt.target === tabRef.current) return;
20
+ tabRef.current?.click();
21
+ },
22
+ children: [
23
+ startActions,
24
+ /* @__PURE__ */ jsx(Tab, {
25
+ ref: tabRef,
26
+ className: classes.tab,
27
+ ...others
28
+ }),
29
+ endActions
30
+ ]
31
+ });
38
32
  });
39
- export {
40
- HvCanvasPanelTab,
41
- staticClasses as canvasPanelTabClasses
42
- };
33
+ //#endregion
34
+ export { HvCanvasPanelTab };
@@ -1,48 +1,41 @@
1
+ import { createClasses, outlineStyles, theme } from "@hitachivantara/uikit-react-core";
1
2
  import { tabClasses } from "@mui/base";
2
- import { createClasses, theme, outlineStyles } from "@hitachivantara/uikit-react-core";
3
- const { staticClasses, useClasses } = createClasses("HvCanvasPanelTab", {
4
- root: {
5
- height: "100%",
6
- display: "flex",
7
- position: "relative",
8
- alignItems: "center",
9
- justifyContent: "center",
10
- borderRadius: `${theme.radii.large} ${theme.radii.large} 0 0`,
11
- backgroundColor: theme.colors.bgPage,
12
- overflow: "hidden",
13
- width: "100%",
14
- boxShadow: "0px -2px 8px 0px #4141410F",
15
- color: theme.colors.textDisabled,
16
- "&:hover": {
17
- cursor: "pointer"
18
- },
19
- "&:has(:focus)": {
20
- backgroundColor: theme.colors.bgContainer
21
- },
22
- [`:has(.${tabClasses.selected})`]: {
23
- color: theme.colors.text,
24
- backgroundColor: theme.colors.bgContainer
25
- },
26
- "&:has(:focus-visible)": {
27
- ...outlineStyles
28
- }
29
- },
30
- tab: {
31
- appearance: "none",
32
- color: theme.colors.textSubtle,
33
- backgroundColor: "inherit",
34
- cursor: "inherit",
35
- textAlign: "initial",
36
- flex: 1,
37
- paddingInlineEnd: 0,
38
- paddingInlineStart: 0,
39
- [`&.${tabClasses.selected}`]: {
40
- color: theme.colors.text,
41
- fontWeight: theme.fontWeights.semibold
42
- }
43
- }
3
+ //#region src/Canvas/PanelTab/PanelTab.styles.tsx
4
+ var { staticClasses, useClasses } = createClasses("HvCanvasPanelTab", {
5
+ root: {
6
+ height: "100%",
7
+ display: "flex",
8
+ position: "relative",
9
+ alignItems: "center",
10
+ justifyContent: "center",
11
+ borderRadius: `${theme.radii.large} ${theme.radii.large} 0 0`,
12
+ backgroundColor: theme.colors.bgPage,
13
+ overflow: "hidden",
14
+ width: "100%",
15
+ boxShadow: "0px -2px 8px 0px #4141410F",
16
+ color: theme.colors.textDisabled,
17
+ "&:hover": { cursor: "pointer" },
18
+ "&:has(:focus)": { backgroundColor: theme.colors.bgContainer },
19
+ [`:has(.${tabClasses.selected})`]: {
20
+ color: theme.colors.text,
21
+ backgroundColor: theme.colors.bgContainer
22
+ },
23
+ "&:has(:focus-visible)": { ...outlineStyles }
24
+ },
25
+ tab: {
26
+ appearance: "none",
27
+ color: theme.colors.textSubtle,
28
+ backgroundColor: "inherit",
29
+ cursor: "inherit",
30
+ textAlign: "initial",
31
+ flex: 1,
32
+ paddingInlineEnd: 0,
33
+ paddingInlineStart: 0,
34
+ [`&.${tabClasses.selected}`]: {
35
+ color: theme.colors.text,
36
+ fontWeight: theme.fontWeights.semibold
37
+ }
38
+ }
44
39
  });
45
- export {
46
- staticClasses,
47
- useClasses
48
- };
40
+ //#endregion
41
+ export { staticClasses, useClasses };
@@ -1,30 +1,25 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { useClasses } from "./PanelTabs.styles.js";
2
2
  import { forwardRef } from "react";
3
- import { Tabs, TabsList } from "@mui/base";
4
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-core";
5
- import { useClasses } from "./PanelTabs.styles.js";
6
- import { staticClasses } from "./PanelTabs.styles.js";
7
- const HvCanvasPanelTabs = forwardRef(function HvCanvasPanelTabs2(props, ref) {
8
- const {
9
- selectionFollowsFocus = true,
10
- children,
11
- className,
12
- classes: classesProp,
13
- ...others
14
- } = useDefaultProps("HvCanvasPanelTabs", props);
15
- const { classes, cx } = useClasses(classesProp);
16
- return /* @__PURE__ */ jsx(
17
- Tabs,
18
- {
19
- ref,
20
- className: cx(classes.root, className),
21
- selectionFollowsFocus,
22
- ...others,
23
- children: /* @__PURE__ */ jsx(TabsList, { className: classes.list, children })
24
- }
25
- );
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { Tabs, TabsList } from "@mui/base";
6
+ //#region src/Canvas/PanelTabs/PanelTabs.tsx
7
+ /**
8
+ * A tabs component to use in a canvas context.
9
+ */
10
+ var HvCanvasPanelTabs = forwardRef(function HvCanvasPanelTabs(props, ref) {
11
+ const { selectionFollowsFocus = true, children, className, classes: classesProp, ...others } = useDefaultProps("HvCanvasPanelTabs", props);
12
+ const { classes, cx } = useClasses(classesProp);
13
+ return /* @__PURE__ */ jsx(Tabs, {
14
+ ref,
15
+ className: cx(classes.root, className),
16
+ selectionFollowsFocus,
17
+ ...others,
18
+ children: /* @__PURE__ */ jsx(TabsList, {
19
+ className: classes.list,
20
+ children
21
+ })
22
+ });
26
23
  });
27
- export {
28
- HvCanvasPanelTabs,
29
- staticClasses as canvasPanelTabsClasses
30
- };
24
+ //#endregion
25
+ export { HvCanvasPanelTabs };
@@ -1,16 +1,12 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-core";
2
- const { staticClasses, useClasses } = createClasses(
3
- "HvCanvasPanelTabs",
4
- {
5
- root: {},
6
- list: {
7
- display: "flex",
8
- width: "100%",
9
- height: 48
10
- }
11
- }
12
- );
13
- export {
14
- staticClasses,
15
- useClasses
16
- };
2
+ //#region src/Canvas/PanelTabs/PanelTabs.styles.tsx
3
+ var { staticClasses, useClasses } = createClasses("HvCanvasPanelTabs", {
4
+ root: {},
5
+ list: {
6
+ display: "flex",
7
+ width: "100%",
8
+ height: 48
9
+ }
10
+ });
11
+ //#endregion
12
+ export { staticClasses, useClasses };
@@ -1,153 +1,107 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useId, useEffect } from "react";
3
- import { useDefaultProps, useUniqueId, useLabels, useControlled, HvPanel, HvButton } from "@hitachivantara/uikit-react-core";
4
- import { End } from "@hitachivantara/uikit-react-icons";
5
1
  import { useCanvasContext } from "../CanvasContext.js";
2
+ import { HvCanvasPanelTab } from "../PanelTab/PanelTab.js";
3
+ import { HvCanvasPanelTabs } from "../PanelTabs/PanelTabs.js";
6
4
  import { useClasses } from "./SidePanel.styles.js";
7
- import { staticClasses } from "./SidePanel.styles.js";
8
5
  import { useResizable } from "./useResizable.js";
9
- import { HvCanvasPanelTabs } from "../PanelTabs/PanelTabs.js";
10
- import { HvCanvasPanelTab } from "../PanelTab/PanelTab.js";
11
- const DEFAULT_LABELS = {
12
- open: "Open",
13
- close: "Close"
6
+ import { forwardRef, useEffect, useId } from "react";
7
+ import { HvButton, HvPanel, useControlled, useDefaultProps, useLabels, useUniqueId } from "@hitachivantara/uikit-react-core";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { End } from "@hitachivantara/uikit-react-icons";
10
+ //#region src/Canvas/SidePanel/SidePanel.tsx
11
+ var DEFAULT_LABELS = {
12
+ open: "Open",
13
+ close: "Close"
14
14
  };
15
- const HvCanvasSidePanel = forwardRef(function HvCanvasSidePanel2(props, ref) {
16
- const {
17
- id: idProp,
18
- tab: tabProp,
19
- open: openProp,
20
- defaultOpen = false,
21
- tabs,
22
- onToggle,
23
- onTabChange,
24
- labels: labelsProp,
25
- minWidth = 100,
26
- maxWidth = 500,
27
- initialWidth = 320,
28
- onResize,
29
- className,
30
- children,
31
- classes: classesProp,
32
- ...others
33
- } = useDefaultProps("HvCanvasSidePanel", props);
34
- const id = useUniqueId(idProp);
35
- const panelId = useId();
36
- const {
37
- handleSidePanelWidth,
38
- sidePanelOpen,
39
- handleSidePanelOpen,
40
- handleSidePanelDragging
41
- } = useCanvasContext() || {};
42
- const { classes, cx } = useClasses(classesProp);
43
- const labels = useLabels(DEFAULT_LABELS, labelsProp);
44
- const [open, setOpen] = useControlled(openProp, defaultOpen);
45
- const [selectedTab, setSelectedTab] = useControlled(
46
- tabProp,
47
- tabs?.[0]?.id ?? "none"
48
- );
49
- useEffect(() => {
50
- handleSidePanelOpen?.(open);
51
- }, [handleSidePanelOpen, open]);
52
- useEffect(() => {
53
- handleSidePanelWidth?.(initialWidth);
54
- }, [handleSidePanelWidth, initialWidth]);
55
- const updateWidth = (width2) => {
56
- handleSidePanelWidth?.(width2);
57
- onResize?.(width2);
58
- };
59
- const { width, isDragging, getContainerProps, getSeparatorProps } = useResizable({
60
- ref,
61
- initialWidth,
62
- minWidth,
63
- maxWidth,
64
- onResize: updateWidth
65
- });
66
- useEffect(() => {
67
- handleSidePanelDragging?.(isDragging);
68
- }, [handleSidePanelDragging, isDragging]);
69
- const handleTogglePanel = (event) => {
70
- setOpen((prev) => !prev);
71
- handleSidePanelOpen?.(!sidePanelOpen);
72
- onToggle?.(event, !open);
73
- };
74
- const handleTabChange = (event, tabId) => {
75
- setSelectedTab(tabId);
76
- onTabChange?.(event, tabId);
77
- };
78
- return /* @__PURE__ */ jsxs(Fragment, { children: [
79
- /* @__PURE__ */ jsxs(
80
- "div",
81
- {
82
- id,
83
- className: cx(classes.root, className, {
84
- [classes.open]: open,
85
- [classes.close]: !open
86
- }),
87
- ...getContainerProps({ style: { ...!open && { width: 0 } } }),
88
- ...others,
89
- children: [
90
- tabs && /* @__PURE__ */ jsx(
91
- HvCanvasPanelTabs,
92
- {
93
- className: classes.tabs,
94
- value: selectedTab,
95
- onChange: handleTabChange,
96
- children: tabs.map((tab) => /* @__PURE__ */ jsx(
97
- HvCanvasPanelTab,
98
- {
99
- id: `${id}-${tab.id}`,
100
- value: tab.id,
101
- children: tab.content
102
- },
103
- tab.id
104
- ))
105
- }
106
- ),
107
- /* @__PURE__ */ jsx(
108
- HvPanel,
109
- {
110
- role: tabs ? "tabpanel" : void 0,
111
- id: panelId,
112
- "aria-labelledby": tabs ? `${id}-${selectedTab}` : void 0,
113
- className: classes.content,
114
- children
115
- }
116
- )
117
- ]
118
- }
119
- ),
120
- /* @__PURE__ */ jsx(
121
- "div",
122
- {
123
- "data-resizing": isDragging || void 0,
124
- className: classes.separator,
125
- ...getSeparatorProps()
126
- }
127
- ),
128
- /* @__PURE__ */ jsx(
129
- HvButton,
130
- {
131
- icon: true,
132
- variant: "primaryGhost",
133
- "aria-label": open ? labels.close : labels.open,
134
- onClick: handleTogglePanel,
135
- "aria-expanded": open,
136
- "aria-controls": panelId,
137
- className: cx(classes.handle, {
138
- [classes.handleOpen]: open,
139
- [classes.handleClose]: !open
140
- }),
141
- style: {
142
- left: open ? width : 0,
143
- transition: isDragging ? "none" : void 0
144
- },
145
- children: /* @__PURE__ */ jsx(End, { rotate: open })
146
- }
147
- )
148
- ] });
15
+ /**
16
+ * A side panel component to use in a canvas context.
17
+ */
18
+ var HvCanvasSidePanel = forwardRef(function HvCanvasSidePanel(props, ref) {
19
+ const { id: idProp, tab: tabProp, open: openProp, defaultOpen = false, tabs, onToggle, onTabChange, labels: labelsProp, minWidth = 100, maxWidth = 500, initialWidth = 320, onResize, className, children, classes: classesProp, ...others } = useDefaultProps("HvCanvasSidePanel", props);
20
+ const id = useUniqueId(idProp);
21
+ const panelId = useId();
22
+ const { handleSidePanelWidth, sidePanelOpen, handleSidePanelOpen, handleSidePanelDragging } = useCanvasContext() || {};
23
+ const { classes, cx } = useClasses(classesProp);
24
+ const labels = useLabels(DEFAULT_LABELS, labelsProp);
25
+ const [open, setOpen] = useControlled(openProp, defaultOpen);
26
+ const [selectedTab, setSelectedTab] = useControlled(tabProp, tabs?.[0]?.id ?? "none");
27
+ useEffect(() => {
28
+ handleSidePanelOpen?.(open);
29
+ }, [handleSidePanelOpen, open]);
30
+ useEffect(() => {
31
+ handleSidePanelWidth?.(initialWidth);
32
+ }, [handleSidePanelWidth, initialWidth]);
33
+ const updateWidth = (width) => {
34
+ handleSidePanelWidth?.(width);
35
+ onResize?.(width);
36
+ };
37
+ const { width, isDragging, getContainerProps, getSeparatorProps } = useResizable({
38
+ ref,
39
+ initialWidth,
40
+ minWidth,
41
+ maxWidth,
42
+ onResize: updateWidth
43
+ });
44
+ useEffect(() => {
45
+ handleSidePanelDragging?.(isDragging);
46
+ }, [handleSidePanelDragging, isDragging]);
47
+ const handleTogglePanel = (event) => {
48
+ setOpen((prev) => !prev);
49
+ handleSidePanelOpen?.(!sidePanelOpen);
50
+ onToggle?.(event, !open);
51
+ };
52
+ const handleTabChange = (event, tabId) => {
53
+ setSelectedTab(tabId);
54
+ onTabChange?.(event, tabId);
55
+ };
56
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ /* @__PURE__ */ jsxs("div", {
58
+ id,
59
+ className: cx(classes.root, className, {
60
+ [classes.open]: open,
61
+ [classes.close]: !open
62
+ }),
63
+ ...getContainerProps({ style: { ...!open && { width: 0 } } }),
64
+ ...others,
65
+ children: [tabs && /* @__PURE__ */ jsx(HvCanvasPanelTabs, {
66
+ className: classes.tabs,
67
+ value: selectedTab,
68
+ onChange: handleTabChange,
69
+ children: tabs.map((tab) => /* @__PURE__ */ jsx(HvCanvasPanelTab, {
70
+ id: `${id}-${tab.id}`,
71
+ value: tab.id,
72
+ children: tab.content
73
+ }, tab.id))
74
+ }), /* @__PURE__ */ jsx(HvPanel, {
75
+ role: tabs ? "tabpanel" : void 0,
76
+ id: panelId,
77
+ "aria-labelledby": tabs ? `${id}-${selectedTab}` : void 0,
78
+ className: classes.content,
79
+ children
80
+ })]
81
+ }),
82
+ /* @__PURE__ */ jsx("div", {
83
+ "data-resizing": isDragging || void 0,
84
+ className: classes.separator,
85
+ ...getSeparatorProps()
86
+ }),
87
+ /* @__PURE__ */ jsx(HvButton, {
88
+ icon: true,
89
+ variant: "primaryGhost",
90
+ "aria-label": open ? labels.close : labels.open,
91
+ onClick: handleTogglePanel,
92
+ "aria-expanded": open,
93
+ "aria-controls": panelId,
94
+ className: cx(classes.handle, {
95
+ [classes.handleOpen]: open,
96
+ [classes.handleClose]: !open
97
+ }),
98
+ style: {
99
+ left: open ? width : 0,
100
+ transition: isDragging ? "none" : void 0
101
+ },
102
+ children: /* @__PURE__ */ jsx(End, { rotate: open })
103
+ })
104
+ ] });
149
105
  });
150
- export {
151
- HvCanvasSidePanel,
152
- staticClasses as canvasSidePanelClasses
153
- };
106
+ //#endregion
107
+ export { HvCanvasSidePanel };