@hitachivantara/uikit-react-pentaho 6.0.13 → 6.0.14

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,60 +1,53 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { useDefaultProps, useLabels, HvIconButton, HvTypography } from "@hitachivantara/uikit-react-core";
4
- import { Previous } from "@hitachivantara/uikit-react-icons";
5
- import { mergeStyles } from "@hitachivantara/uikit-react-utils";
6
1
  import { useCanvasContext } from "../CanvasContext.js";
7
2
  import { useClasses } from "./Toolbar.styles.js";
8
- import { staticClasses } from "./Toolbar.styles.js";
9
- const DEFAULT_LABELS = {
10
- back: "Back"
11
- };
12
- const HvCanvasToolbar = forwardRef(
13
- function HvCanvasToolbar2(props, ref) {
14
- const {
15
- title: titleProp,
16
- backButton,
17
- labels: labelsProp,
18
- className,
19
- style,
20
- children,
21
- backButtonProps,
22
- classes: classesProp,
23
- ...others
24
- } = useDefaultProps("HvCanvasToolbar", props);
25
- const { classes, cx } = useClasses(classesProp);
26
- const labels = useLabels(DEFAULT_LABELS, labelsProp);
27
- const canvasContext = useCanvasContext();
28
- const sidePanelWidth = canvasContext?.sidePanelWidth ?? 0;
29
- const title = typeof titleProp === "string" ? /* @__PURE__ */ jsx(HvTypography, { variant: "title4", children: titleProp }) : titleProp;
30
- return /* @__PURE__ */ jsxs(
31
- "div",
32
- {
33
- ref,
34
- className: cx(classes.root, className),
35
- style: mergeStyles(style, {
36
- "--sidepanel-width": `${sidePanelWidth}px`,
37
- transition: canvasContext?.sidePanelDragging ? void 0 : "width 0.3s ease"
38
- }),
39
- ...others,
40
- children: [
41
- /* @__PURE__ */ jsx("div", { className: classes.back, children: backButton ?? /* @__PURE__ */ jsx(
42
- HvIconButton,
43
- {
44
- title: labels.back,
45
- variant: "primaryGhost",
46
- ...backButtonProps,
47
- children: /* @__PURE__ */ jsx(Previous, {})
48
- }
49
- ) }),
50
- /* @__PURE__ */ jsx("div", { className: classes.title, children: title }),
51
- children && /* @__PURE__ */ jsx("div", { className: classes.actions, children })
52
- ]
53
- }
54
- );
55
- }
56
- );
57
- export {
58
- HvCanvasToolbar,
59
- staticClasses as canvasToolbarClasses
60
- };
3
+ import { forwardRef } from "react";
4
+ import { HvIconButton, HvTypography, useDefaultProps, useLabels } from "@hitachivantara/uikit-react-core";
5
+ import { mergeStyles } from "@hitachivantara/uikit-react-utils";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { Previous } from "@hitachivantara/uikit-react-icons";
8
+ //#region src/Canvas/Toolbar/Toolbar.tsx
9
+ var DEFAULT_LABELS = { back: "Back" };
10
+ /**
11
+ * A toolbar component to use in a canvas context.
12
+ */
13
+ var HvCanvasToolbar = forwardRef(function HvCanvasToolbar(props, ref) {
14
+ const { title: titleProp, backButton, labels: labelsProp, className, style, children, backButtonProps, classes: classesProp, ...others } = useDefaultProps("HvCanvasToolbar", props);
15
+ const { classes, cx } = useClasses(classesProp);
16
+ const labels = useLabels(DEFAULT_LABELS, labelsProp);
17
+ const canvasContext = useCanvasContext();
18
+ const sidePanelWidth = canvasContext?.sidePanelWidth ?? 0;
19
+ const title = typeof titleProp === "string" ? /* @__PURE__ */ jsx(HvTypography, {
20
+ variant: "title4",
21
+ children: titleProp
22
+ }) : titleProp;
23
+ return /* @__PURE__ */ jsxs("div", {
24
+ ref,
25
+ className: cx(classes.root, className),
26
+ style: mergeStyles(style, {
27
+ "--sidepanel-width": `${sidePanelWidth}px`,
28
+ transition: canvasContext?.sidePanelDragging ? void 0 : "width 0.3s ease"
29
+ }),
30
+ ...others,
31
+ children: [
32
+ /* @__PURE__ */ jsx("div", {
33
+ className: classes.back,
34
+ children: backButton ?? /* @__PURE__ */ jsx(HvIconButton, {
35
+ title: labels.back,
36
+ variant: "primaryGhost",
37
+ ...backButtonProps,
38
+ children: /* @__PURE__ */ jsx(Previous, {})
39
+ })
40
+ }),
41
+ /* @__PURE__ */ jsx("div", {
42
+ className: classes.title,
43
+ children: title
44
+ }),
45
+ children && /* @__PURE__ */ jsx("div", {
46
+ className: classes.actions,
47
+ children
48
+ })
49
+ ]
50
+ });
51
+ });
52
+ //#endregion
53
+ export { HvCanvasToolbar };
@@ -1,40 +1,39 @@
1
1
  import { createClasses, theme } from "@hitachivantara/uikit-react-core";
2
- const { staticClasses, useClasses } = createClasses("HvCanvasToolbar", {
3
- root: {
4
- width: `calc(100% - var(--sidepanel-width) - 2 * ${theme.space.sm})`,
5
- height: 54,
6
- display: "flex",
7
- alignItems: "center",
8
- borderRadius: theme.radii.full,
9
- backgroundColor: theme.colors.bgContainer,
10
- position: "absolute",
11
- right: theme.space.sm,
12
- top: 0
13
- },
14
- back: {
15
- borderRadius: `${theme.radii.full} 0 0 ${theme.radii.full}`,
16
- minWidth: 68,
17
- backgroundColor: theme.colors.bgHover,
18
- height: "100%",
19
- display: "flex",
20
- alignItems: "center",
21
- justifyContent: "center"
22
- },
23
- title: {
24
- display: "flex",
25
- alignItems: "center",
26
- padding: theme.spacing(0, "md"),
27
- height: "100%",
28
- flexGrow: 1
29
- },
30
- actions: {
31
- display: "flex",
32
- flexWrap: "nowrap",
33
- overflow: "auto",
34
- paddingRight: theme.space.md
35
- }
2
+ //#region src/Canvas/Toolbar/Toolbar.styles.tsx
3
+ var { staticClasses, useClasses } = createClasses("HvCanvasToolbar", {
4
+ root: {
5
+ width: `calc(100% - var(--sidepanel-width) - 2 * ${theme.space.sm})`,
6
+ height: 54,
7
+ display: "flex",
8
+ alignItems: "center",
9
+ borderRadius: theme.radii.full,
10
+ backgroundColor: theme.colors.bgContainer,
11
+ position: "absolute",
12
+ right: theme.space.sm,
13
+ top: 0
14
+ },
15
+ back: {
16
+ borderRadius: `${theme.radii.full} 0 0 ${theme.radii.full}`,
17
+ minWidth: 68,
18
+ backgroundColor: theme.colors.bgHover,
19
+ height: "100%",
20
+ display: "flex",
21
+ alignItems: "center",
22
+ justifyContent: "center"
23
+ },
24
+ title: {
25
+ display: "flex",
26
+ alignItems: "center",
27
+ padding: theme.spacing(0, "md"),
28
+ height: "100%",
29
+ flexGrow: 1
30
+ },
31
+ actions: {
32
+ display: "flex",
33
+ flexWrap: "nowrap",
34
+ overflow: "auto",
35
+ paddingRight: theme.space.md
36
+ }
36
37
  });
37
- export {
38
- staticClasses,
39
- useClasses
40
- };
38
+ //#endregion
39
+ export { staticClasses, useClasses };
@@ -1,154 +1,129 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
1
  import { useRef, useState } from "react";
3
- import { useControlled, useEnhancedEffect, HvTypography, createClasses, theme, isKey } from "@hitachivantara/uikit-react-core";
2
+ import { HvTypography, createClasses, isKey, theme, useControlled, useEnhancedEffect } from "@hitachivantara/uikit-react-core";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { Edit } from "@hitachivantara/uikit-react-icons";
5
- const { staticClasses, useClasses } = createClasses(
6
- "HvCanvasToolbarTabsEditor",
7
- {
8
- root: {
9
- position: "relative",
10
- display: "flex",
11
- width: "100%",
12
- overflow: "hidden",
13
- "&:has($label:hover:not($edit))": {
14
- color: theme.colors.textSubtle,
15
- "& $editIcon": { visibility: "visible" }
16
- }
17
- },
18
- edit: {
19
- color: theme.colors.textSubtle,
20
- borderColor: "currentColor",
21
- backgroundColor: theme.colors.bgContainer,
22
- cursor: "text"
23
- },
24
- label: {
25
- width: "100%",
26
- boxSizing: "border-box",
27
- border: "1px solid transparent",
28
- borderRadius: theme.radii.base,
29
- padding: theme.spacing(0, "sm", 0, "xs"),
30
- textAlign: "start",
31
- whiteSpace: "nowrap",
32
- overflow: "hidden",
33
- outline: "none",
34
- "&:not($edit)": {
35
- textOverflow: "ellipsis"
36
- },
37
- "&:hover:not($edit)": {
38
- color: theme.colors.textSubtle,
39
- borderColor: theme.colors.bgHover,
40
- backgroundColor: theme.colors.bgHover
41
- }
42
- },
43
- editIcon: {
44
- position: "absolute",
45
- right: theme.space.xxs,
46
- top: 4,
47
- width: 16,
48
- height: 16,
49
- visibility: "hidden",
50
- pointerEvents: "none"
51
- }
52
- }
53
- );
54
- const sanitize = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
55
- const ToolbarTabEditor = ({
56
- id,
57
- className,
58
- edit: editProp,
59
- value: valueProp,
60
- defaultValue: defaultValueProp = "",
61
- classes: classesProp,
62
- onInput: onInputProp,
63
- onClick: onClickProp,
64
- onBlur: onBlurProp,
65
- onKeyDown: onKeyDownProp,
66
- onChange: onChangeProp,
67
- onEditChange: onEditChangeProp,
68
- ...others
69
- }) => {
70
- const { cx, classes } = useClasses(classesProp);
71
- const contentEditableRef = useRef(null);
72
- const [value, setValue] = useControlled(
73
- valueProp ? sanitize(valueProp) : valueProp,
74
- defaultValueProp ? sanitize(defaultValueProp) : defaultValueProp
75
- );
76
- const [cachedValue, setCachedValue] = useState(value);
77
- const [isEditing, setIsEditing] = useControlled(editProp, false);
78
- const moveCursorToEnd = () => {
79
- if (!contentEditableRef.current) return;
80
- const element = contentEditableRef.current;
81
- const range = document.createRange();
82
- const selection = window.getSelection();
83
- range.selectNodeContents(element);
84
- range.collapse(false);
85
- selection?.removeAllRanges();
86
- selection?.addRange(range);
87
- element.scrollLeft = element.scrollWidth;
88
- };
89
- const scrollContentToStart = () => {
90
- if (!contentEditableRef.current) return;
91
- const element = contentEditableRef.current;
92
- element.scrollLeft = 0;
93
- };
94
- const changeEdit = (edit) => {
95
- setIsEditing(edit);
96
- onEditChangeProp?.(edit);
97
- };
98
- useEnhancedEffect(() => {
99
- if (isEditing) moveCursorToEnd();
100
- }, [isEditing, value]);
101
- const handleInput = (event) => {
102
- const newValue = sanitize(event.target.textContent) || "";
103
- setValue(newValue);
104
- onInputProp?.(event);
105
- onChangeProp?.(event, newValue);
106
- };
107
- const handleClick = (event) => {
108
- setCachedValue(value);
109
- changeEdit(true);
110
- onClickProp?.(event);
111
- };
112
- const handleBlur = (event) => {
113
- changeEdit(false);
114
- scrollContentToStart();
115
- const newValue = value.trim() || cachedValue;
116
- setValue(newValue);
117
- onBlurProp?.(event, newValue);
118
- };
119
- const handleKeyDown = (event) => {
120
- if (isKey(event, "Enter")) {
121
- handleBlur(event);
122
- } else if (isKey(event, "Esc")) {
123
- changeEdit(false);
124
- setValue(cachedValue);
125
- onChangeProp?.(event, cachedValue);
126
- }
127
- onKeyDownProp?.(event);
128
- };
129
- return /* @__PURE__ */ jsxs("div", { id, className: cx(classes.root, className), children: [
130
- /* @__PURE__ */ jsx(
131
- HvTypography,
132
- {
133
- ref: contentEditableRef,
134
- contentEditable: isEditing,
135
- className: cx(classes.label, { [classes.edit]: isEditing }),
136
- variant: "label",
137
- component: "span",
138
- onInput: handleInput,
139
- onClick: handleClick,
140
- onBlur: handleBlur,
141
- onKeyDown: handleKeyDown,
142
- dangerouslySetInnerHTML: {
143
- __html: value
144
- },
145
- ...others
146
- }
147
- ),
148
- /* @__PURE__ */ jsx(Edit, { className: classes.editIcon, iconSize: "XS" })
149
- ] });
150
- };
151
- export {
152
- ToolbarTabEditor,
153
- staticClasses as toolbarTabEditorClasses
5
+ //#region src/Canvas/ToolbarTabs/ToolbarTabEditor.tsx
6
+ var { staticClasses, useClasses } = createClasses("HvCanvasToolbarTabsEditor", {
7
+ root: {
8
+ position: "relative",
9
+ display: "flex",
10
+ width: "100%",
11
+ overflow: "hidden",
12
+ "&:has($label:hover:not($edit))": {
13
+ color: theme.colors.textSubtle,
14
+ "& $editIcon": { visibility: "visible" }
15
+ }
16
+ },
17
+ edit: {
18
+ color: theme.colors.textSubtle,
19
+ borderColor: "currentColor",
20
+ backgroundColor: theme.colors.bgContainer,
21
+ cursor: "text"
22
+ },
23
+ label: {
24
+ width: "100%",
25
+ boxSizing: "border-box",
26
+ border: "1px solid transparent",
27
+ borderRadius: theme.radii.base,
28
+ padding: theme.spacing(0, "sm", 0, "xs"),
29
+ textAlign: "start",
30
+ whiteSpace: "nowrap",
31
+ overflow: "hidden",
32
+ outline: "none",
33
+ "&:not($edit)": { textOverflow: "ellipsis" },
34
+ "&:hover:not($edit)": {
35
+ color: theme.colors.textSubtle,
36
+ borderColor: theme.colors.bgHover,
37
+ backgroundColor: theme.colors.bgHover
38
+ }
39
+ },
40
+ editIcon: {
41
+ position: "absolute",
42
+ right: theme.space.xxs,
43
+ top: 4,
44
+ width: 16,
45
+ height: 16,
46
+ visibility: "hidden",
47
+ pointerEvents: "none"
48
+ }
49
+ });
50
+ var sanitize = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
51
+ var ToolbarTabEditor = ({ id, className, edit: editProp, value: valueProp, defaultValue: defaultValueProp = "", classes: classesProp, onInput: onInputProp, onClick: onClickProp, onBlur: onBlurProp, onKeyDown: onKeyDownProp, onChange: onChangeProp, onEditChange: onEditChangeProp, ...others }) => {
52
+ const { cx, classes } = useClasses(classesProp);
53
+ const contentEditableRef = useRef(null);
54
+ const [value, setValue] = useControlled(valueProp ? sanitize(valueProp) : valueProp, defaultValueProp ? sanitize(defaultValueProp) : defaultValueProp);
55
+ const [cachedValue, setCachedValue] = useState(value);
56
+ const [isEditing, setIsEditing] = useControlled(editProp, false);
57
+ const moveCursorToEnd = () => {
58
+ if (!contentEditableRef.current) return;
59
+ const element = contentEditableRef.current;
60
+ const range = document.createRange();
61
+ const selection = window.getSelection();
62
+ range.selectNodeContents(element);
63
+ range.collapse(false);
64
+ selection?.removeAllRanges();
65
+ selection?.addRange(range);
66
+ element.scrollLeft = element.scrollWidth;
67
+ };
68
+ const scrollContentToStart = () => {
69
+ if (!contentEditableRef.current) return;
70
+ const element = contentEditableRef.current;
71
+ element.scrollLeft = 0;
72
+ };
73
+ const changeEdit = (edit) => {
74
+ setIsEditing(edit);
75
+ onEditChangeProp?.(edit);
76
+ };
77
+ useEnhancedEffect(() => {
78
+ if (isEditing) moveCursorToEnd();
79
+ }, [isEditing, value]);
80
+ const handleInput = (event) => {
81
+ const newValue = sanitize(event.target.textContent) || "";
82
+ setValue(newValue);
83
+ onInputProp?.(event);
84
+ onChangeProp?.(event, newValue);
85
+ };
86
+ const handleClick = (event) => {
87
+ setCachedValue(value);
88
+ changeEdit(true);
89
+ onClickProp?.(event);
90
+ };
91
+ const handleBlur = (event) => {
92
+ changeEdit(false);
93
+ scrollContentToStart();
94
+ const newValue = value.trim() || cachedValue;
95
+ setValue(newValue);
96
+ onBlurProp?.(event, newValue);
97
+ };
98
+ const handleKeyDown = (event) => {
99
+ if (isKey(event, "Enter")) handleBlur(event);
100
+ else if (isKey(event, "Esc")) {
101
+ changeEdit(false);
102
+ setValue(cachedValue);
103
+ onChangeProp?.(event, cachedValue);
104
+ }
105
+ onKeyDownProp?.(event);
106
+ };
107
+ return /* @__PURE__ */ jsxs("div", {
108
+ id,
109
+ className: cx(classes.root, className),
110
+ children: [/* @__PURE__ */ jsx(HvTypography, {
111
+ ref: contentEditableRef,
112
+ contentEditable: isEditing,
113
+ className: cx(classes.label, { [classes.edit]: isEditing }),
114
+ variant: "label",
115
+ component: "span",
116
+ onInput: handleInput,
117
+ onClick: handleClick,
118
+ onBlur: handleBlur,
119
+ onKeyDown: handleKeyDown,
120
+ dangerouslySetInnerHTML: { __html: value },
121
+ ...others
122
+ }), /* @__PURE__ */ jsx(Edit, {
123
+ className: classes.editIcon,
124
+ iconSize: "XS"
125
+ })]
126
+ });
154
127
  };
128
+ //#endregion
129
+ export { ToolbarTabEditor, staticClasses };