@eccenca/gui-elements 24.2.0 → 24.4.0
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/CHANGELOG.md +47 -0
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +12 -9
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +10 -9
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js +2 -2
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
- package/dist/cjs/components/Icon/IconButton.js +1 -0
- package/dist/cjs/components/Icon/IconButton.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +12 -7
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/extensions/codemirror/CodeMirror.js +83 -21
- package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js +22 -1
- package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
- package/dist/cjs/extensions/react-flow/edges/EdgeDefaultV12.js +56 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefaultV12.js.map +1 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefs.js +14 -0
- package/dist/cjs/extensions/react-flow/edges/EdgeDefs.js.map +1 -0
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js +3 -0
- package/dist/cjs/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/cjs/extensions/react-flow/index.js +3 -0
- package/dist/cjs/extensions/react-flow/index.js.map +1 -1
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +49 -28
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/cjs/extensions/react-flow/versionsupport.js +6 -0
- package/dist/cjs/extensions/react-flow/versionsupport.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +12 -9
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +10 -9
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js +2 -2
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
- package/dist/esm/components/Icon/IconButton.js +1 -0
- package/dist/esm/components/Icon/IconButton.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +14 -9
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/extensions/codemirror/CodeMirror.js +84 -22
- package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js +20 -0
- package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
- package/dist/esm/extensions/react-flow/edges/EdgeDefaultV12.js +77 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefaultV12.js.map +1 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefs.js +8 -0
- package/dist/esm/extensions/react-flow/edges/EdgeDefs.js.map +1 -0
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js +3 -0
- package/dist/esm/extensions/react-flow/handles/HandleDefault.js.map +1 -1
- package/dist/esm/extensions/react-flow/index.js +3 -0
- package/dist/esm/extensions/react-flow/index.js.map +1 -1
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js +66 -44
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/esm/extensions/react-flow/versionsupport.js +6 -0
- package/dist/esm/extensions/react-flow/versionsupport.js.map +1 -1
- package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +4 -0
- package/dist/types/components/AutoSuggestion/AutoSuggestion.d.ts +7 -1
- package/dist/types/components/AutoSuggestion/ExtendedCodeEditor.d.ts +5 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +7 -1
- package/dist/types/extensions/codemirror/CodeMirror.d.ts +3 -2
- package/dist/types/extensions/codemirror/tests/codemirrorTestHelper.d.ts +3 -1
- package/dist/types/extensions/react-flow/edges/EdgeDefaultV12.d.ts +38 -0
- package/dist/types/extensions/react-flow/edges/EdgeDefs.d.ts +2 -0
- package/dist/types/extensions/react-flow/handles/HandleDefault.d.ts +4 -1
- package/dist/types/extensions/react-flow/index.d.ts +3 -0
- package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +5 -4
- package/dist/types/extensions/react-flow/versionsupport.d.ts +3 -2
- package/package.json +6 -3
- package/src/cmem/ActivityControl/ActivityControlWidget.stories.tsx +45 -5
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +47 -9
- package/src/cmem/ActivityControl/tests/ActivityControlWidget.test.tsx +99 -0
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +30 -16
- package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +8 -0
- package/src/components/Icon/IconButton.tsx +1 -0
- package/src/components/Tooltip/Tooltip.tsx +24 -13
- package/src/extensions/codemirror/CodeMirror.tsx +102 -26
- package/src/extensions/codemirror/tests/codemirrorTestHelper.ts +20 -1
- package/src/extensions/react-flow/_react-flow.scss +1 -0
- package/src/extensions/react-flow/_react-flow_v12.scss +5 -0
- package/src/extensions/react-flow/edges/EdgeDefaultV12.tsx +154 -0
- package/src/extensions/react-flow/edges/EdgeDefs.tsx +30 -0
- package/src/extensions/react-flow/edges/_edges.scss +18 -0
- package/src/extensions/react-flow/edges/stories/EdgeDefaultV12.stories.tsx +183 -0
- package/src/extensions/react-flow/handles/HandleDefault.tsx +12 -4
- package/src/extensions/react-flow/index.ts +3 -0
- package/src/extensions/react-flow/nodes/NodeContent.tsx +85 -48
- package/src/extensions/react-flow/nodes/NodeDefaultV12.tsx +53 -0
- package/src/extensions/react-flow/nodes/stories/NodeContentV12.stories.tsx +270 -0
- package/src/extensions/react-flow/versionsupport.ts +7 -2
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* 'EditorView is not a constructor'
|
|
6
6
|
* This errors do not exist during compilation only during testing.
|
|
7
7
|
*/
|
|
8
|
-
import { Extension } from "@codemirror/state";
|
|
8
|
+
import { Extension, Compartment } from "@codemirror/state";
|
|
9
9
|
/** placeholder extension, current error '_view.placeholder is not a function' */
|
|
10
10
|
export declare const adaptedPlaceholder: (text?: string) => Extension;
|
|
11
11
|
/** current error '_view.Editor is not a constructor' */
|
|
12
12
|
export declare const AdaptedEditorView: any;
|
|
13
|
+
/** Creates a new compartment or a mock of a compartment. */
|
|
14
|
+
export declare const compartment: () => Compartment;
|
|
13
15
|
/** extension adding event handlers, current error '(view, domEventHandlers) is not a function' */
|
|
14
16
|
export declare const AdaptedEditorViewDomEventHandlers: any;
|
|
15
17
|
export declare const adaptedSyntaxHighlighting: (style: any) => any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Edge, EdgeProps } from "@xyflow/react";
|
|
3
|
+
import { IntentTypes } from "../../../common/Intent";
|
|
4
|
+
import { NodeHighlightColor } from "../nodes/sharedTypes";
|
|
5
|
+
export type EdgeDefaultV12DataProps = Record<string, unknown> & {
|
|
6
|
+
/**
|
|
7
|
+
* Overwrites the default style how the edge stroke is displayed.
|
|
8
|
+
*/
|
|
9
|
+
strokeType?: "solid" | "dashed" | "dotted" | "double" | "doubledashed";
|
|
10
|
+
/**
|
|
11
|
+
* Feedback state of the node.
|
|
12
|
+
*/
|
|
13
|
+
intent?: IntentTypes;
|
|
14
|
+
/**
|
|
15
|
+
* Set the color of used highlights to mark the edge.
|
|
16
|
+
*/
|
|
17
|
+
highlightColor?: NodeHighlightColor | [NodeHighlightColor, NodeHighlightColor];
|
|
18
|
+
/**
|
|
19
|
+
* Size of the "glow" effect when the edge is hovered.
|
|
20
|
+
*/
|
|
21
|
+
pathGlowWidth?: number;
|
|
22
|
+
inversePath?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Callback handler that returns a React element used as edge title.
|
|
25
|
+
*/
|
|
26
|
+
renderLabel?: (edgeCenter: [number, number, number, number]) => React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Properties are forwarded to the internally used SVG `g` element.
|
|
29
|
+
* Data attributes for test ids coud be included here.
|
|
30
|
+
*/
|
|
31
|
+
edgeSvgProps?: React.SVGProps<SVGGElement>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* This element cannot be used directly, it must be connected via a `edgeTypes` definition.
|
|
35
|
+
* @see https://reactflow.dev/docs/api/nodes/
|
|
36
|
+
* @deprecated (v26) will be removed when `EdgeDefault` supports v12 directly
|
|
37
|
+
*/
|
|
38
|
+
export declare const EdgeDefaultV12: React.MemoExoticComponent<({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius, data, ...edgeOriginalProperties }: EdgeProps<Edge<EdgeDefaultV12DataProps>>) => React.JSX.Element>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { HandleProps as ReactFlowHandleLegacyProps } from "react-flow-renderer";
|
|
3
3
|
import { HandleProps as ReactFlowHandleNextProps } from "react-flow-renderer-lts";
|
|
4
|
+
import { HandleProps as ReactFlowHandleV12Props } from "@xyflow/react";
|
|
4
5
|
import { IntentTypes } from "../../../common/Intent";
|
|
5
6
|
import { ReacFlowVersionSupportProps } from "../versionsupport";
|
|
6
7
|
import { HandleContentProps } from "./HandleContent";
|
|
@@ -28,6 +29,8 @@ export interface HandleProps extends HandleExtensionProps, ReactFlowHandleLegacy
|
|
|
28
29
|
}
|
|
29
30
|
export interface HandleNextProps extends HandleExtensionProps, ReactFlowHandleNextProps {
|
|
30
31
|
}
|
|
31
|
-
export
|
|
32
|
+
export interface HandleV12Props extends HandleExtensionProps, ReactFlowHandleV12Props {
|
|
33
|
+
}
|
|
34
|
+
export type HandleDefaultProps = HandleProps | HandleNextProps | HandleV12Props;
|
|
32
35
|
export declare const HandleDefault: React.MemoExoticComponent<({ flowVersion, data, tooltip, children, category, intent, ...handleProps }: HandleDefaultProps) => React.JSX.Element>;
|
|
33
36
|
export {};
|
|
@@ -10,8 +10,11 @@ export * from "./edges/EdgeDefault";
|
|
|
10
10
|
export * from "./edges/EdgeStep";
|
|
11
11
|
export * from "./edges/EdgeTools";
|
|
12
12
|
export * from "./edges/EdgeLabel";
|
|
13
|
+
export * from "./edges/EdgeDefs";
|
|
14
|
+
export * from "./edges/EdgeDefaultV12";
|
|
13
15
|
export * from "./markers/ReactFlowMarkers";
|
|
14
16
|
export * from "./minimap/MiniMap";
|
|
15
17
|
export * from "./minimap/utils";
|
|
18
|
+
export * from "./versionsupport";
|
|
16
19
|
export { nodeTypes } from "./nodes/nodeTypes";
|
|
17
20
|
export { edgeTypes } from "./edges/edgeTypes";
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Position } from "react-flow-renderer";
|
|
3
3
|
import { IntentTypes } from "../../../common/Intent";
|
|
4
|
-
import { DepictionProps } from "../../../components
|
|
4
|
+
import { DepictionProps } from "../../../components";
|
|
5
5
|
import { ValidIconName } from "../../../components/Icon/canonicalIconNames";
|
|
6
|
+
import { HandleNextProps, HandleProps, HandleV12Props } from "../handles/HandleDefault";
|
|
6
7
|
import { ReacFlowVersionSupportProps } from "../versionsupport";
|
|
7
|
-
import { HandleNextProps, HandleProps } from "./../handles/HandleDefault";
|
|
8
8
|
import { NodeContentExtensionProps } from "./NodeContentExtension";
|
|
9
9
|
import { NodeDefaultProps } from "./NodeDefault";
|
|
10
10
|
import { NodeHighlightColor } from "./sharedTypes";
|
|
11
11
|
type NodeContentHandleLegacyProps = HandleProps;
|
|
12
12
|
type NodeContentHandleNextProps = HandleNextProps;
|
|
13
|
-
|
|
13
|
+
type NodeContentHandleV12Props = HandleV12Props;
|
|
14
|
+
export type NodeContentHandleProps = NodeContentHandleLegacyProps | NodeContentHandleNextProps | NodeContentHandleV12Props;
|
|
14
15
|
export type NodeDimensions = {
|
|
15
16
|
width?: number;
|
|
16
17
|
height?: number;
|
|
@@ -134,7 +135,7 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any> extends N
|
|
|
134
135
|
* Array of property definition objects for `Handle` components that need to be created for the node.
|
|
135
136
|
* @see https://reactflow.dev/docs/api/handle/
|
|
136
137
|
*/
|
|
137
|
-
handles?:
|
|
138
|
+
handles?: NodeContentHandleProps[];
|
|
138
139
|
/**
|
|
139
140
|
* Set the minimal number of handles on left or right side of the node to activate the recalculation of the minimal height of the node.
|
|
140
141
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export interface ReacFlowVersionSupportProps {
|
|
2
2
|
/**
|
|
3
3
|
* Spevifies the context of the react flow renderer version that is used for the component.
|
|
4
|
+
* @deprecated (v25) `legacy` and `next` will be removed/replaced by `v##` values in future versions
|
|
4
5
|
*/
|
|
5
|
-
flowVersion?: "legacy" | "next" | "none";
|
|
6
|
+
flowVersion?: "v12" | "legacy" | "next" | "none";
|
|
6
7
|
}
|
|
7
|
-
export declare const useReactFlowVersion: () => "none" | "next" | "legacy";
|
|
8
|
+
export declare const useReactFlowVersion: () => "none" | "next" | "legacy" | "v12";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eccenca/gui-elements",
|
|
3
3
|
"description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
|
|
4
|
-
"version": "24.
|
|
4
|
+
"version": "24.4.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/eccenca/gui-elements",
|
|
7
7
|
"bugs": "https://github.com/eccenca/gui-elements/issues",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"@codemirror/lang-yaml": "^6.1.2",
|
|
82
82
|
"@codemirror/legacy-modes": "^6.5.0",
|
|
83
83
|
"@mavrin/remark-typograf": "^2.2.0",
|
|
84
|
+
"@xyflow/react": "^12.6.0",
|
|
84
85
|
"classnames": "^2.5.1",
|
|
85
86
|
"codemirror": "^6.0.1",
|
|
86
87
|
"color": "^4.2.3",
|
|
@@ -148,8 +149,8 @@
|
|
|
148
149
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
149
150
|
"husky": "4",
|
|
150
151
|
"identity-obj-proxy": "^3.0.0",
|
|
151
|
-
"jest": "^
|
|
152
|
-
"jest-environment-jsdom": "^
|
|
152
|
+
"jest": "^30.0.5",
|
|
153
|
+
"jest-environment-jsdom": "^30.0.5",
|
|
153
154
|
"jest-pnp-resolver": "^1.2.3",
|
|
154
155
|
"lint-staged": "^15.5.1",
|
|
155
156
|
"node-sass-package-importer": "^5.3.3",
|
|
@@ -179,6 +180,8 @@
|
|
|
179
180
|
"resolutions": {
|
|
180
181
|
"**/@types/react": "^17.0.85",
|
|
181
182
|
"node-sass-package-importer/**/postcss": "^8.4.49",
|
|
183
|
+
"string-width": "^4.2.3",
|
|
184
|
+
"wrap-ansi": "^7.0.0",
|
|
182
185
|
"hast-util-from-parse5": "8.0.0"
|
|
183
186
|
},
|
|
184
187
|
"husky": {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useMemo, useState } from "react";
|
|
2
2
|
import { loremIpsum } from "react-lorem-ipsum";
|
|
3
|
+
import { OverlaysProvider } from "@blueprintjs/core";
|
|
3
4
|
import { Meta, StoryFn } from "@storybook/react";
|
|
4
5
|
|
|
5
6
|
import { helpersArgTypes } from "../../../.storybook/helpers";
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ActivityControlWidget,
|
|
9
|
+
ActivityControlWidgetAction,
|
|
10
|
+
IconButton,
|
|
11
|
+
SimpleDialog,
|
|
12
|
+
Tag,
|
|
13
|
+
TagList,
|
|
14
|
+
} from "../../../index";
|
|
7
15
|
|
|
8
16
|
export default {
|
|
9
17
|
title: "Cmem/ActivityControlWidget",
|
|
@@ -19,7 +27,7 @@ const Template: StoryFn<typeof ActivityControlWidget> = (args) => <ActivityContr
|
|
|
19
27
|
|
|
20
28
|
export const FullExample = Template.bind({});
|
|
21
29
|
|
|
22
|
-
const actions = [
|
|
30
|
+
const actions: ActivityControlWidgetAction[] = [
|
|
23
31
|
{
|
|
24
32
|
"data-test-id": "activity-reload-activity",
|
|
25
33
|
icon: "item-reload",
|
|
@@ -30,6 +38,7 @@ const actions = [
|
|
|
30
38
|
{
|
|
31
39
|
"data-test-id": "activity-start-activity",
|
|
32
40
|
icon: "item-start",
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
33
42
|
action: () => console.log("start"),
|
|
34
43
|
tooltip: "Start Activity",
|
|
35
44
|
disabled: false,
|
|
@@ -37,6 +46,7 @@ const actions = [
|
|
|
37
46
|
{
|
|
38
47
|
"data-test-id": "activity-stop-activity",
|
|
39
48
|
icon: "item-stop",
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
40
50
|
action: () => console.log("cancel"),
|
|
41
51
|
tooltip: "Stop Activity",
|
|
42
52
|
disabled: false,
|
|
@@ -57,8 +67,8 @@ const commonWidgetArgs = {
|
|
|
57
67
|
progressSpinner: {
|
|
58
68
|
intent: "none",
|
|
59
69
|
value: 0.5,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
70
|
+
} as const,
|
|
71
|
+
} as const;
|
|
62
72
|
|
|
63
73
|
FullExample.args = {
|
|
64
74
|
...commonWidgetArgs,
|
|
@@ -80,3 +90,33 @@ WidgetWithTags.args = {
|
|
|
80
90
|
...commonWidgetArgs,
|
|
81
91
|
tags: widgetTags,
|
|
82
92
|
};
|
|
93
|
+
|
|
94
|
+
export const WidgetWithAdditionalActions: StoryFn<typeof ActivityControlWidget> = (args) => {
|
|
95
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
96
|
+
|
|
97
|
+
const params = useMemo(
|
|
98
|
+
() => ({
|
|
99
|
+
...commonWidgetArgs,
|
|
100
|
+
...args,
|
|
101
|
+
additionalActions: args.additionalActions ?? [
|
|
102
|
+
<IconButton name="application-explore" onClick={() => setIsOpen(true)} />,
|
|
103
|
+
],
|
|
104
|
+
}),
|
|
105
|
+
[]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<OverlaysProvider>
|
|
110
|
+
<ActivityControlWidget {...params} />
|
|
111
|
+
<SimpleDialog
|
|
112
|
+
title="Additional actions dialog"
|
|
113
|
+
isOpen={isOpen}
|
|
114
|
+
onClose={() => setIsOpen(false)}
|
|
115
|
+
canOutsideClickClose
|
|
116
|
+
canEscapeKeyClose
|
|
117
|
+
>
|
|
118
|
+
Modal content
|
|
119
|
+
</SimpleDialog>
|
|
120
|
+
</OverlaysProvider>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
@@ -81,6 +81,10 @@ export interface ActivityControlWidgetProps extends TestableComponent {
|
|
|
81
81
|
* execution timer messages for waiting and running times.
|
|
82
82
|
*/
|
|
83
83
|
timerExecutionMsg?: JSX.Element | null;
|
|
84
|
+
/**
|
|
85
|
+
* additional actions that can serve as a complex component, positioned between the default actions and the context menu
|
|
86
|
+
*/
|
|
87
|
+
additionalActions?: React.ReactElement<unknown>[];
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
interface IActivityContextMenu extends TestableComponent {
|
|
@@ -110,11 +114,13 @@ interface IActivityMenuAction extends ActivityControlWidgetAction {
|
|
|
110
114
|
/** Shows the status of activities and supports actions on these activities. */
|
|
111
115
|
export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
112
116
|
const {
|
|
113
|
-
"data-test-id":
|
|
117
|
+
"data-test-id": dataTestIdLegacy,
|
|
118
|
+
"data-testid": dataTestId,
|
|
114
119
|
progressBar,
|
|
115
120
|
progressSpinner,
|
|
116
121
|
activityActions,
|
|
117
122
|
activityContextMenu,
|
|
123
|
+
additionalActions,
|
|
118
124
|
small,
|
|
119
125
|
border,
|
|
120
126
|
hasSpacing,
|
|
@@ -126,10 +132,19 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
|
126
132
|
} = props;
|
|
127
133
|
const spinnerClassNames = (progressSpinner?.className ?? "") + ` ${eccgui}-spinner--permanent`;
|
|
128
134
|
const widget = (
|
|
129
|
-
<OverviewItem
|
|
135
|
+
<OverviewItem
|
|
136
|
+
data-test-id={dataTestIdLegacy}
|
|
137
|
+
data-testid={dataTestId}
|
|
138
|
+
hasSpacing={border || hasSpacing}
|
|
139
|
+
densityHigh={small}
|
|
140
|
+
>
|
|
130
141
|
{progressBar && <ProgressBar {...progressBar} />}
|
|
131
142
|
{(progressSpinner || progressSpinnerFinishedIcon) && (
|
|
132
|
-
<OverviewItemDepiction
|
|
143
|
+
<OverviewItemDepiction
|
|
144
|
+
data-testid={dataTestId ? `${dataTestId}-progress-spinner` : undefined}
|
|
145
|
+
data-test-id={dataTestIdLegacy ? `${dataTestIdLegacy}-progress-spinner` : undefined}
|
|
146
|
+
keepColors
|
|
147
|
+
>
|
|
133
148
|
{progressSpinnerFinishedIcon ? (
|
|
134
149
|
React.cloneElement(progressSpinnerFinishedIcon as JSX.Element, { small, large: !small })
|
|
135
150
|
) : (
|
|
@@ -145,13 +160,21 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
|
145
160
|
)}
|
|
146
161
|
<OverviewItemDescription>
|
|
147
162
|
{props.label && (
|
|
148
|
-
<OverviewItemLine
|
|
163
|
+
<OverviewItemLine
|
|
164
|
+
data-testid={dataTestId ? `${dataTestId}-label` : undefined}
|
|
165
|
+
data-test-id={dataTestIdLegacy ? `${dataTestIdLegacy}-label` : undefined}
|
|
166
|
+
small={small}
|
|
167
|
+
>
|
|
149
168
|
{React.cloneElement(labelWrapper, {}, props.label)}
|
|
150
169
|
{timerExecutionMsg && (props.statusMessage || tags) && <> ({timerExecutionMsg})</>}
|
|
151
170
|
</OverviewItemLine>
|
|
152
171
|
)}
|
|
153
172
|
{(props.statusMessage || tags) && (
|
|
154
|
-
<OverviewItemLine
|
|
173
|
+
<OverviewItemLine
|
|
174
|
+
data-testid={dataTestId ? `${dataTestId}-status-message` : undefined}
|
|
175
|
+
data-test-id={dataTestIdLegacy ? `${dataTestIdLegacy}-status-message` : undefined}
|
|
176
|
+
small
|
|
177
|
+
>
|
|
155
178
|
{tags}
|
|
156
179
|
{props.statusMessage && (
|
|
157
180
|
<OverflowText passDown>
|
|
@@ -172,21 +195,35 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
|
172
195
|
</OverviewItemLine>
|
|
173
196
|
)}
|
|
174
197
|
{timerExecutionMsg && !(props.statusMessage || tags) && (
|
|
175
|
-
<OverviewItemLine
|
|
198
|
+
<OverviewItemLine
|
|
199
|
+
data-testid={dataTestId ? `${dataTestId}-status-message` : undefined}
|
|
200
|
+
data-test-id={dataTestIdLegacy ? `${dataTestIdLegacy}-status-message` : undefined}
|
|
201
|
+
small
|
|
202
|
+
>
|
|
203
|
+
{timerExecutionMsg}
|
|
204
|
+
</OverviewItemLine>
|
|
176
205
|
)}
|
|
177
206
|
</OverviewItemDescription>
|
|
178
|
-
<OverviewItemActions
|
|
207
|
+
<OverviewItemActions
|
|
208
|
+
data-testid={dataTestId ? `${dataTestId}-actions` : undefined}
|
|
209
|
+
data-test-id={dataTestIdLegacy ? `${dataTestIdLegacy}-actions` : undefined}
|
|
210
|
+
>
|
|
179
211
|
{activityActions &&
|
|
180
212
|
activityActions.map((action, idx) => {
|
|
181
213
|
return (
|
|
182
214
|
<IconButton
|
|
183
|
-
key={
|
|
215
|
+
key={
|
|
216
|
+
typeof action.icon === "string"
|
|
217
|
+
? action.icon
|
|
218
|
+
: action["data-test-id"] ?? action["data-testid"] ?? idx
|
|
219
|
+
}
|
|
184
220
|
data-test-id={action["data-test-id"]}
|
|
221
|
+
data-testid={action["data-testid"]}
|
|
185
222
|
name={action.icon}
|
|
186
223
|
text={action.tooltip}
|
|
187
224
|
onClick={action.action}
|
|
188
225
|
disabled={action.disabled}
|
|
189
|
-
|
|
226
|
+
intent={action.hasStateWarning ? "warning" : undefined}
|
|
190
227
|
tooltipProps={{
|
|
191
228
|
hoverOpenDelay: 200,
|
|
192
229
|
placement: "bottom",
|
|
@@ -194,6 +231,7 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
|
194
231
|
/>
|
|
195
232
|
);
|
|
196
233
|
})}
|
|
234
|
+
{additionalActions}
|
|
197
235
|
{activityContextMenu && activityContextMenu.menuItems.length > 0 && (
|
|
198
236
|
<ContextMenu
|
|
199
237
|
data-test-id={activityContextMenu["data-test-id"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
+
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
6
|
+
import { IconButton, Tag, TagList } from "../../../index";
|
|
7
|
+
import { ActivityControlWidget, ActivityControlWidgetAction } from "../ActivityControlWidget";
|
|
8
|
+
|
|
9
|
+
describe("ActivityControlWidget", () => {
|
|
10
|
+
it("Renders basic widget with actions and handles clicks", () => {
|
|
11
|
+
const mockAction1 = jest.fn();
|
|
12
|
+
const mockAction2 = jest.fn();
|
|
13
|
+
const actions: ActivityControlWidgetAction[] = [
|
|
14
|
+
{
|
|
15
|
+
"data-testid": "action-1",
|
|
16
|
+
icon: "item-reload",
|
|
17
|
+
action: mockAction1,
|
|
18
|
+
tooltip: "Action 1",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"data-testid": "action-2",
|
|
22
|
+
icon: "item-start",
|
|
23
|
+
action: mockAction2,
|
|
24
|
+
tooltip: "Action 2",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
render(
|
|
29
|
+
<ActivityControlWidget
|
|
30
|
+
label="Basic widget"
|
|
31
|
+
data-testid="basic-widget"
|
|
32
|
+
activityActions={actions}
|
|
33
|
+
statusMessage="Status message"
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const button1 = screen.getByTestId("action-1");
|
|
38
|
+
const button2 = screen.getByTestId("action-2");
|
|
39
|
+
|
|
40
|
+
const label = screen.getByTestId("basic-widget-label");
|
|
41
|
+
const statusMessage = screen.getByTestId("basic-widget-status-message");
|
|
42
|
+
const actionsContainer = screen.getByTestId("basic-widget-actions");
|
|
43
|
+
|
|
44
|
+
expect(label).toBeInTheDocument();
|
|
45
|
+
expect(statusMessage).toBeInTheDocument();
|
|
46
|
+
expect(actionsContainer).toBeInTheDocument();
|
|
47
|
+
|
|
48
|
+
expect(label).toHaveTextContent("Basic widget");
|
|
49
|
+
expect(statusMessage).toHaveTextContent("Status message");
|
|
50
|
+
|
|
51
|
+
expect(button1).toBeInTheDocument();
|
|
52
|
+
expect(button2).toBeInTheDocument();
|
|
53
|
+
|
|
54
|
+
fireEvent.click(button1);
|
|
55
|
+
expect(mockAction1).toHaveBeenCalledTimes(1);
|
|
56
|
+
|
|
57
|
+
fireEvent.click(button2);
|
|
58
|
+
expect(mockAction2).toHaveBeenCalledTimes(1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("Renders widget with tags", () => {
|
|
62
|
+
const tags = (
|
|
63
|
+
<TagList>
|
|
64
|
+
<Tag>Tag one</Tag>
|
|
65
|
+
<Tag>Other tag</Tag>
|
|
66
|
+
</TagList>
|
|
67
|
+
);
|
|
68
|
+
render(<ActivityControlWidget label="Widget with tags" tags={tags} data-testid="widget-with-tags" />);
|
|
69
|
+
|
|
70
|
+
const label = screen.getByTestId("widget-with-tags-label");
|
|
71
|
+
const statusMessage = screen.getByTestId("widget-with-tags-status-message");
|
|
72
|
+
|
|
73
|
+
expect(label).toBeInTheDocument();
|
|
74
|
+
expect(statusMessage).toBeInTheDocument();
|
|
75
|
+
|
|
76
|
+
expect(label).toHaveTextContent("Widget with tags");
|
|
77
|
+
expect(statusMessage).toHaveTextContent("Tag one");
|
|
78
|
+
expect(statusMessage).toHaveTextContent("Other tag");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("Renders widget with additional actions and handles click", () => {
|
|
82
|
+
const mockAction = jest.fn();
|
|
83
|
+
const additionalActions = [
|
|
84
|
+
<IconButton
|
|
85
|
+
key="add-btn"
|
|
86
|
+
name="application-explore"
|
|
87
|
+
onClick={mockAction}
|
|
88
|
+
data-testid="additional-action"
|
|
89
|
+
/>,
|
|
90
|
+
];
|
|
91
|
+
render(<ActivityControlWidget additionalActions={additionalActions} />);
|
|
92
|
+
|
|
93
|
+
const customButton = screen.getByTestId("additional-action");
|
|
94
|
+
expect(customButton).toBeInTheDocument();
|
|
95
|
+
|
|
96
|
+
fireEvent.click(customButton);
|
|
97
|
+
expect(mockAction).toHaveBeenCalledTimes(1);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -166,6 +166,12 @@ export interface AutoSuggestionProps {
|
|
|
166
166
|
/** If this is enabled the value of the editor is replaced with the initialValue if it changes.
|
|
167
167
|
* FIXME: This property is a workaround for some "controlled" usages of the component via the initialValue property. */
|
|
168
168
|
reInitOnInitialValueChange?: boolean;
|
|
169
|
+
/** Optional height of the component */
|
|
170
|
+
height?: number | string;
|
|
171
|
+
/** Set read-only mode. Default: false */
|
|
172
|
+
readOnly?: boolean;
|
|
173
|
+
/** Properties that should be added to the outer div container. */
|
|
174
|
+
outerDivAttributes?: Omit<React.HTMLAttributes<HTMLDivElement>, "id" | "data-test-id">;
|
|
169
175
|
}
|
|
170
176
|
|
|
171
177
|
// Meta data regarding a request
|
|
@@ -198,6 +204,9 @@ const AutoSuggestion = ({
|
|
|
198
204
|
mode,
|
|
199
205
|
multiline = false,
|
|
200
206
|
reInitOnInitialValueChange = false,
|
|
207
|
+
height,
|
|
208
|
+
readOnly,
|
|
209
|
+
outerDivAttributes
|
|
201
210
|
}: AutoSuggestionProps) => {
|
|
202
211
|
const value = React.useRef<string>(initialValue);
|
|
203
212
|
const cursorPosition = React.useRef(0);
|
|
@@ -208,7 +217,7 @@ const AutoSuggestion = ({
|
|
|
208
217
|
const suggestionRequestData = React.useRef<RequestMetaData>({ requestId: undefined });
|
|
209
218
|
const [pathValidationPending, setPathValidationPending] = React.useState(false);
|
|
210
219
|
const validationRequestData = React.useRef<RequestMetaData>({ requestId: undefined });
|
|
211
|
-
const errorMarkers = React.useRef<any[]>([])
|
|
220
|
+
const errorMarkers = React.useRef<any[]>([]);
|
|
212
221
|
const [validationResponse, setValidationResponse] = useState<CodeAutocompleteFieldValidationResult | undefined>(
|
|
213
222
|
undefined
|
|
214
223
|
);
|
|
@@ -300,26 +309,26 @@ const AutoSuggestion = ({
|
|
|
300
309
|
const parseError = validationResponse?.parseError;
|
|
301
310
|
if (cm) {
|
|
302
311
|
const clearCurrentErrorMarker = () => {
|
|
303
|
-
if(errorMarkers.current.length) {
|
|
312
|
+
if (errorMarkers.current.length) {
|
|
304
313
|
const [from, to] = errorMarkers.current;
|
|
305
|
-
removeMarkFromText({ view: cm, from, to })
|
|
306
|
-
errorMarkers.current = []
|
|
314
|
+
removeMarkFromText({ view: cm, from, to });
|
|
315
|
+
errorMarkers.current = [];
|
|
307
316
|
}
|
|
308
|
-
}
|
|
317
|
+
};
|
|
309
318
|
if (parseError) {
|
|
310
319
|
const { message, start, end } = parseError;
|
|
311
320
|
const { toOffset, fromOffset } = getOffsetRange(cm, start, end);
|
|
312
|
-
clearCurrentErrorMarker()
|
|
313
|
-
const {from, to} = markText({
|
|
321
|
+
clearCurrentErrorMarker();
|
|
322
|
+
const { from, to } = markText({
|
|
314
323
|
view: cm,
|
|
315
324
|
from: fromOffset,
|
|
316
325
|
to: toOffset,
|
|
317
326
|
className: `${eccgui}-autosuggestion__text--highlighted-error`,
|
|
318
327
|
title: message,
|
|
319
328
|
});
|
|
320
|
-
errorMarkers.current = [from, to]
|
|
329
|
+
errorMarkers.current = [from, to];
|
|
321
330
|
} else {
|
|
322
|
-
clearCurrentErrorMarker()
|
|
331
|
+
clearCurrentErrorMarker();
|
|
323
332
|
}
|
|
324
333
|
}
|
|
325
334
|
|
|
@@ -354,7 +363,7 @@ const AutoSuggestion = ({
|
|
|
354
363
|
editorState.suggestions = [];
|
|
355
364
|
setSuggestions([]);
|
|
356
365
|
}
|
|
357
|
-
|
|
366
|
+
setCurrentIndex(0);
|
|
358
367
|
}, [suggestionResponse, editorState]);
|
|
359
368
|
|
|
360
369
|
const getOffsetRange = (cm: EditorView, from: number, to: number) => {
|
|
@@ -368,7 +377,7 @@ const AutoSuggestion = ({
|
|
|
368
377
|
return { fromOffset, toOffset };
|
|
369
378
|
};
|
|
370
379
|
|
|
371
|
-
const
|
|
380
|
+
const inputActionsDisplayed = React.useCallback((node) => {
|
|
372
381
|
if (!node) return;
|
|
373
382
|
const width = node.offsetWidth;
|
|
374
383
|
const slCodeEditor = node.parentElement.getElementsByClassName(`${eccgui}-singlelinecodeeditor`);
|
|
@@ -448,13 +457,13 @@ const AutoSuggestion = ({
|
|
|
448
457
|
[asyncHandleEditorInputChange, autoCompletionRequestDelay]
|
|
449
458
|
);
|
|
450
459
|
|
|
451
|
-
const handleChange = React.useMemo(
|
|
460
|
+
const handleChange = React.useMemo(() => {
|
|
452
461
|
return (val: string) => {
|
|
453
462
|
value.current = val;
|
|
454
463
|
checkValuePathValidity.cancel();
|
|
455
464
|
checkValuePathValidity(value.current);
|
|
456
465
|
onChange(val);
|
|
457
|
-
}
|
|
466
|
+
};
|
|
458
467
|
}, [onChange, checkValuePathValidity]);
|
|
459
468
|
|
|
460
469
|
const handleCursorChange = (cursor: number, coords: Rect, scrollinfo: HTMLElement, view: EditorView) => {
|
|
@@ -482,8 +491,7 @@ const AutoSuggestion = ({
|
|
|
482
491
|
}, 1);
|
|
483
492
|
};
|
|
484
493
|
|
|
485
|
-
|
|
486
|
-
const handleInputEditorKeyPress = (event: any) => {
|
|
494
|
+
const handleInputEditorKeyPress = (event: KeyboardEvent) => {
|
|
487
495
|
const overWrittenKeys: Array<string> = Object.values(OVERWRITTEN_KEYS);
|
|
488
496
|
if (overWrittenKeys.includes(event.key) && (useTabForCompletions || event.key !== OVERWRITTEN_KEYS.Tab)) {
|
|
489
497
|
//don't prevent when enter should create new line (multiline config) and dropdown isn't shown
|
|
@@ -619,6 +627,7 @@ const AutoSuggestion = ({
|
|
|
619
627
|
break;
|
|
620
628
|
default:
|
|
621
629
|
//do nothing
|
|
630
|
+
closeDropDown();
|
|
622
631
|
}
|
|
623
632
|
}
|
|
624
633
|
};
|
|
@@ -653,6 +662,8 @@ const AutoSuggestion = ({
|
|
|
653
662
|
showScrollBar={showScrollBar}
|
|
654
663
|
multiline={multiline}
|
|
655
664
|
onMouseDown={handleInputMouseDown}
|
|
665
|
+
height={height}
|
|
666
|
+
readOnly={readOnly}
|
|
656
667
|
/>
|
|
657
668
|
);
|
|
658
669
|
}, [
|
|
@@ -665,6 +676,7 @@ const AutoSuggestion = ({
|
|
|
665
676
|
showScrollBar,
|
|
666
677
|
multiline,
|
|
667
678
|
handleInputMouseDown,
|
|
679
|
+
readOnly
|
|
668
680
|
]);
|
|
669
681
|
|
|
670
682
|
const hasError = !!value.current && !pathIsValid && !pathValidationPending;
|
|
@@ -673,6 +685,7 @@ const AutoSuggestion = ({
|
|
|
673
685
|
id={id}
|
|
674
686
|
ref={autoSuggestionDivRef}
|
|
675
687
|
className={`${eccgui}-autosuggestion` + (className ? ` ${className}` : "")}
|
|
688
|
+
{...outerDivAttributes}
|
|
676
689
|
>
|
|
677
690
|
<div
|
|
678
691
|
className={` ${eccgui}-autosuggestion__inputfield ${BlueprintClassNames.INPUT_GROUP} ${
|
|
@@ -703,11 +716,12 @@ const AutoSuggestion = ({
|
|
|
703
716
|
{codeEditor}
|
|
704
717
|
</ContextOverlay>
|
|
705
718
|
{!!value.current && (
|
|
706
|
-
<span className={BlueprintClassNames.INPUT_ACTION} ref={
|
|
719
|
+
<span className={BlueprintClassNames.INPUT_ACTION} ref={inputActionsDisplayed}>
|
|
707
720
|
<IconButton
|
|
708
721
|
data-test-id={"value-path-clear-btn"}
|
|
709
722
|
name="operation-clear"
|
|
710
723
|
text={clearIconText}
|
|
724
|
+
disabled={readOnly}
|
|
711
725
|
onClick={handleInputEditorClear}
|
|
712
726
|
/>
|
|
713
727
|
</span>
|
|
@@ -61,6 +61,10 @@ export interface ExtendedCodeEditorProps {
|
|
|
61
61
|
| "additionalExtensions"
|
|
62
62
|
| "outerDivAttributes"
|
|
63
63
|
>;
|
|
64
|
+
/** Optional height of the component */
|
|
65
|
+
height?: number | string;
|
|
66
|
+
/** Set read-only mode. Default: false */
|
|
67
|
+
readOnly?: boolean;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export type IEditorProps = ExtendedCodeEditorProps;
|
|
@@ -80,6 +84,8 @@ export const ExtendedCodeEditor = ({
|
|
|
80
84
|
onCursorChange,
|
|
81
85
|
onSelection,
|
|
82
86
|
codeEditorProps,
|
|
87
|
+
height,
|
|
88
|
+
readOnly
|
|
83
89
|
}: ExtendedCodeEditorProps) => {
|
|
84
90
|
const initialContent = React.useRef(multiline ? initialValue : initialValue.replace(/[\r\n]/g, " "));
|
|
85
91
|
const multilineExtensions = multiline
|
|
@@ -102,6 +108,8 @@ export const ExtendedCodeEditor = ({
|
|
|
102
108
|
shouldHaveMinimalSetup={false}
|
|
103
109
|
preventLineNumbers={!multiline}
|
|
104
110
|
mode={mode}
|
|
111
|
+
height={height}
|
|
112
|
+
readOnly={readOnly}
|
|
105
113
|
name=""
|
|
106
114
|
enableTab={enableTab}
|
|
107
115
|
additionalExtensions={[...multilineExtensions]}
|