@elyra/canvas 12.41.0 → 12.42.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/dist/{_baseIteratee-05ccf6a8.js → _baseIteratee-148093b7.js} +3 -3
- package/dist/{_baseIteratee-05ccf6a8.js.map → _baseIteratee-148093b7.js.map} +1 -1
- package/dist/{canvas-constants-079172c0.js → canvas-constants-13b58448.js} +2 -2
- package/dist/{canvas-constants-079172c0.js.map → canvas-constants-13b58448.js.map} +1 -1
- package/dist/canvas-controller-a53943e4.js +2 -0
- package/dist/canvas-controller-a53943e4.js.map +1 -0
- package/dist/canvas-controller-cb1d7420.js +2 -0
- package/dist/canvas-controller-cb1d7420.js.map +1 -0
- package/dist/common-canvas-42027a3f.js +2 -0
- package/dist/common-canvas-42027a3f.js.map +1 -0
- package/dist/common-canvas-f758ff42.js +2 -0
- package/dist/common-canvas-f758ff42.js.map +1 -0
- package/dist/common-canvas.es.js +1 -1
- package/dist/common-canvas.es.js.map +1 -1
- package/dist/common-canvas.js +1 -1
- package/dist/common-canvas.js.map +1 -1
- package/dist/common-properties-2e1b7ec7.js +2 -0
- package/dist/common-properties-2e1b7ec7.js.map +1 -0
- package/dist/common-properties-5e8870e3.js +2 -0
- package/dist/common-properties-5e8870e3.js.map +1 -0
- package/dist/context-menu-wrapper-49f9a1af.js +2 -0
- package/dist/context-menu-wrapper-49f9a1af.js.map +1 -0
- package/dist/context-menu-wrapper-5d6a399f.js +2 -0
- package/dist/context-menu-wrapper-5d6a399f.js.map +1 -0
- package/dist/{datarecord-metadata-v3-schema-59505bc5.js → datarecord-metadata-v3-schema-98ec66e9.js} +2 -2
- package/dist/{datarecord-metadata-v3-schema-59505bc5.js.map → datarecord-metadata-v3-schema-98ec66e9.js.map} +1 -1
- package/dist/{flexible-table-43e2d052.js → flexible-table-35e9922a.js} +2 -2
- package/dist/{flexible-table-43e2d052.js.map → flexible-table-35e9922a.js.map} +1 -1
- package/dist/{flexible-table-63ffd573.js → flexible-table-7c7de0f9.js} +1 -1
- package/dist/{flexible-table-63ffd573.js.map → flexible-table-7c7de0f9.js.map} +1 -1
- package/dist/{icon-0390f1fe.js → icon-9edff40c.js} +2 -2
- package/dist/{icon-0390f1fe.js.map → icon-9edff40c.js.map} +1 -1
- package/dist/{index-57503b50.js → index-94fec521.js} +2 -2
- package/dist/{index-57503b50.js.map → index-94fec521.js.map} +1 -1
- package/dist/{index-1cd54914.js → index-e2f8a935.js} +2 -2
- package/dist/{index-1cd54914.js.map → index-e2f8a935.js.map} +1 -1
- package/dist/{isArrayLikeObject-36898fcb.js → isArrayLikeObject-7a30aa4b.js} +2 -2
- package/dist/{isArrayLikeObject-36898fcb.js.map → isArrayLikeObject-7a30aa4b.js.map} +1 -1
- package/dist/lib/canvas-controller.es.js +1 -1
- package/dist/lib/canvas-controller.js +1 -1
- package/dist/lib/canvas.es.js +1 -1
- package/dist/lib/canvas.js +1 -1
- package/dist/lib/context-menu.es.js +1 -1
- package/dist/lib/context-menu.js +1 -1
- package/dist/lib/properties/field-picker.es.js +1 -1
- package/dist/lib/properties/field-picker.js +1 -1
- package/dist/lib/properties/flexible-table.es.js +1 -1
- package/dist/lib/properties/flexible-table.js +1 -1
- package/dist/lib/properties.es.js +1 -1
- package/dist/lib/properties.js +1 -1
- package/dist/lib/tooltip.es.js +1 -1
- package/dist/lib/tooltip.es.js.map +1 -1
- package/dist/lib/tooltip.js +1 -1
- package/dist/lib/tooltip.js.map +1 -1
- package/dist/styles/common-canvas.min.css +1 -1
- package/dist/styles/common-canvas.min.css.map +1 -1
- package/dist/toolbar-6acda0a2.js +2 -0
- package/dist/toolbar-6acda0a2.js.map +1 -0
- package/dist/toolbar-d5647da2.js +2 -0
- package/dist/toolbar-d5647da2.js.map +1 -0
- package/package.json +12 -4
- package/src/color-picker/color-picker.jsx +92 -17
- package/src/command-actions/arrangeLayoutAction.js +7 -6
- package/src/command-actions/attachNodeToLinksAction.js +4 -4
- package/src/command-actions/collapseSuperNodeInPlaceAction.js +5 -5
- package/src/command-actions/colorSelectedObjectsAction.js +4 -4
- package/src/command-actions/commonPropertiesAction.js +1 -1
- package/src/command-actions/convertSuperNodeExternalToLocalAction.js +4 -4
- package/src/command-actions/convertSuperNodeLocalToExternalAction.js +4 -4
- package/src/command-actions/createAutoNodeAction.js +14 -5
- package/src/command-actions/createCommentAction.js +4 -10
- package/src/command-actions/createCommentLinkAction.js +4 -4
- package/src/command-actions/createNodeAction.js +13 -4
- package/src/command-actions/createNodeAttachLinksAction.js +4 -4
- package/src/command-actions/createNodeLinkAction.js +13 -4
- package/src/command-actions/createNodeLinkDetachedAction.js +4 -4
- package/src/command-actions/createNodeOnLinkAction.js +4 -4
- package/src/command-actions/createSuperNodeAction.js +7 -7
- package/src/command-actions/deconstructSuperNodeAction.js +5 -5
- package/src/command-actions/deleteLinkAction.js +4 -4
- package/src/command-actions/deleteObjectsAction.js +15 -6
- package/src/command-actions/disconnectObjectsAction.js +13 -4
- package/src/command-actions/displayPreviousPipelineAction.js +4 -4
- package/src/command-actions/displaySubPipelineAction.js +4 -4
- package/src/command-actions/editCommentAction.js +4 -4
- package/src/command-actions/editDecorationLabelAction.js +4 -4
- package/src/command-actions/expandSuperNodeInPlaceAction.js +5 -5
- package/src/command-actions/insertNodeIntoLinkAction.js +4 -4
- package/src/command-actions/moveObjectsAction.js +4 -4
- package/src/command-actions/pasteAction.js +16 -7
- package/src/command-actions/saveToPaletteAction.js +4 -4
- package/src/command-actions/setLinksStyleAction.js +4 -4
- package/src/command-actions/setNodeLabelAction.js +4 -4
- package/src/command-actions/setObjectsStyleAction.js +4 -4
- package/src/command-actions/sizeAndPositionObjectsAction.js +4 -4
- package/src/command-actions/updateLinkAction.js +4 -4
- package/src/common-canvas/canvas-controller-menu-utils.js +1 -1
- package/src/common-canvas/canvas-controller.js +78 -62
- package/src/common-canvas/cc-central-items.jsx +1 -1
- package/src/common-canvas/cc-context-toolbar.jsx +9 -13
- package/src/common-canvas/cc-toolbar.jsx +2 -0
- package/src/common-canvas/svg-canvas-renderer.js +6 -2
- package/src/common-canvas/svg-canvas-utils-drag-det-link.js +8 -1
- package/src/common-canvas/svg-canvas-utils-drag-new-link.js +1 -1
- package/src/common-properties/components/table-buttons/table-buttons.scss +0 -1
- package/src/common-properties/controls/expression/expression-builder/expression-builder.jsx +32 -26
- package/src/common-properties/controls/expression/expression.jsx +146 -117
- package/src/common-properties/controls/expression/expression.scss +43 -45
- package/src/common-properties/controls/expression/languages/CLEM-hint.js +86 -159
- package/src/common-properties/controls/expression/languages/python-hint.js +53 -104
- package/src/common-properties/controls/expression/languages/r-hint.js +55 -130
- package/src/common-properties/properties-controller.js +5 -0
- package/src/context-menu/common-context-menu.jsx +4 -1
- package/src/index.js +12 -2
- package/src/object-model/redux/canvas-store.js +4 -3
- package/src/toolbar/toolbar-action-item.jsx +90 -314
- package/src/toolbar/toolbar-button-item.jsx +354 -0
- package/src/toolbar/toolbar-divider-item.jsx +3 -4
- package/src/toolbar/toolbar-overflow-item.jsx +82 -36
- package/src/toolbar/toolbar-sub-menu-item.jsx +235 -0
- package/src/toolbar/toolbar-sub-menu.jsx +254 -0
- package/src/toolbar/toolbar-sub-panel.jsx +81 -0
- package/src/toolbar/toolbar-sub-utils.js +77 -0
- package/src/toolbar/toolbar.jsx +330 -146
- package/src/toolbar/toolbar.scss +22 -15
- package/src/tooltip/tooltip.jsx +9 -2
- package/stats.html +1 -1
- package/dist/canvas-controller-1e71b405.js +0 -2
- package/dist/canvas-controller-1e71b405.js.map +0 -1
- package/dist/canvas-controller-4bed5320.js +0 -2
- package/dist/canvas-controller-4bed5320.js.map +0 -1
- package/dist/common-canvas-097c5169.js +0 -2
- package/dist/common-canvas-097c5169.js.map +0 -1
- package/dist/common-canvas-e13c0858.js +0 -2
- package/dist/common-canvas-e13c0858.js.map +0 -1
- package/dist/common-properties-706cef87.js +0 -2
- package/dist/common-properties-706cef87.js.map +0 -1
- package/dist/common-properties-9bd69b61.js +0 -2
- package/dist/common-properties-9bd69b61.js.map +0 -1
- package/dist/context-menu-wrapper-3a7fdec8.js +0 -2
- package/dist/context-menu-wrapper-3a7fdec8.js.map +0 -1
- package/dist/context-menu-wrapper-fc85d853.js +0 -2
- package/dist/context-menu-wrapper-fc85d853.js.map +0 -1
- package/dist/toolbar-918ab52e.js +0 -2
- package/dist/toolbar-918ab52e.js.map +0 -1
- package/dist/toolbar-fdb750f9.js +0 -2
- package/dist/toolbar-fdb750f9.js.map +0 -1
- package/src/toolbar/toolbar-action-sub-area.jsx +0 -126
- package/src/toolbar/toolbar-overflow-menu.jsx +0 -77
- package/src/toolbar/toolbar-utils.js +0 -33
|
@@ -17,33 +17,13 @@
|
|
|
17
17
|
import React from "react";
|
|
18
18
|
import PropTypes from "prop-types";
|
|
19
19
|
|
|
20
|
-
import
|
|
21
|
-
import ArrangeHorizontally from "./../../assets/images/arrange_horizontally.svg";
|
|
22
|
-
import ArrangeVertically from "./../../assets/images/arrange_vertically.svg";
|
|
23
|
-
import ToggleNotificationPanel from "./../../assets/images/notification_counter_icon.svg";
|
|
24
|
-
import PaletteClose from "./../../assets/images/palette/palette_close.svg";
|
|
25
|
-
import PaletteOpen from "./../../assets/images/palette/palette_open.svg";
|
|
26
|
-
import ZoomToFit from "./../../assets/images/zoom_to_fit.svg";
|
|
20
|
+
import ToolbarButtonItem from "./toolbar-button-item.jsx";
|
|
27
21
|
|
|
28
|
-
import { Button } from "carbon-components-react";
|
|
29
|
-
import SVG from "react-inlinesvg";
|
|
30
22
|
import classNames from "classnames";
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
ChevronRight16, ChevronDown16, ChevronUp16 } from "@carbon/icons-react";
|
|
36
|
-
import { TOOLBAR_STOP, TOOLBAR_RUN, TOOLBAR_UNDO, TOOLBAR_REDO,
|
|
37
|
-
TOOLBAR_CUT, TOOLBAR_COPY, TOOLBAR_PASTE, TOOLBAR_CLIPBOARD,
|
|
38
|
-
TOOLBAR_CREATE_COMMENT, TOOLBAR_CREATE_AUTO_COMMENT, TOOLBAR_COLOR_BACKGROUND,
|
|
39
|
-
TOOLBAR_DELETE_SELECTED_OBJECTS, TOOLBAR_DELETE_LINK,
|
|
40
|
-
TOOLBAR_ZOOM_IN, TOOLBAR_ZOOM_OUT, TOOLBAR_ZOOM_FIT,
|
|
41
|
-
TOOLBAR_ARRANGE_HORIZONALLY, TOOLBAR_ARRANGE_VERTICALLY,
|
|
42
|
-
TOOLBAR_OPEN_PALETTE, TOOLBAR_CLOSE_PALETTE, TOOLBAR_TOGGLE_NOTIFICATION_PANEL,
|
|
43
|
-
TOOLBAR_SHOW_COMMENTS, TOOLBAR_HIDE_COMMENTS,
|
|
44
|
-
TOOLBAR_EXPAND_SUPERNODE_IN_PLACE, TOOLBAR_COLLAPSE_SUPERNODE_IN_PLACE,
|
|
45
|
-
TOOLBAR_EXPAND_SUPERNODE_FULL_PAGE, TOOLBAR_SET_NODE_LABEL_EDIT, TOOLBAR_SET_COMMENT_EDIT_MODE }
|
|
46
|
-
from "../common-canvas/constants/canvas-constants.js";
|
|
23
|
+
import ToolbarSubMenu from "./toolbar-sub-menu.jsx";
|
|
24
|
+
import ToolbarSubPanel from "./toolbar-sub-panel.jsx";
|
|
25
|
+
|
|
26
|
+
const ESC_KEY = 27;
|
|
47
27
|
|
|
48
28
|
class ToolbarActionItem extends React.Component {
|
|
49
29
|
constructor(props) {
|
|
@@ -53,147 +33,41 @@ class ToolbarActionItem extends React.Component {
|
|
|
53
33
|
subAreaDisplayed: false
|
|
54
34
|
};
|
|
55
35
|
|
|
36
|
+
this.divRef = React.createRef();
|
|
37
|
+
|
|
56
38
|
this.actionClickHandler = this.actionClickHandler.bind(this);
|
|
57
|
-
this.
|
|
58
|
-
this.onMouseLeave = this.onMouseLeave.bind(this);
|
|
39
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
59
40
|
this.openSubArea = this.openSubArea.bind(this);
|
|
60
41
|
this.closeSubArea = this.closeSubArea.bind(this);
|
|
61
42
|
this.clickOutside = this.clickOutside.bind(this);
|
|
62
43
|
}
|
|
63
44
|
|
|
64
|
-
componentDidMount() {
|
|
65
|
-
if (this.props.actionObj.getSubPanelCloseFn) {
|
|
66
|
-
this.props.actionObj.getSubPanelCloseFn(this.closeSubArea);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
45
|
// We must remove the eventListener in case this class is unmounted due
|
|
71
46
|
// to the toolbar getting redrawn.
|
|
72
47
|
componentWillUnmount() {
|
|
73
48
|
document.removeEventListener("click", this.clickOutside, false);
|
|
74
49
|
}
|
|
75
50
|
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
this.openSubArea();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
onMouseLeave(evt) {
|
|
83
|
-
if ((this.props.actionObj.subMenu || this.props.actionObj.subPanel) && this.props.overflow) {
|
|
51
|
+
onKeyDown(evt) {
|
|
52
|
+
if (evt.keyCode === ESC_KEY) {
|
|
84
53
|
this.closeSubArea();
|
|
54
|
+
return;
|
|
85
55
|
}
|
|
86
56
|
}
|
|
87
57
|
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const disabled = !actionObj.enable;
|
|
92
|
-
|
|
93
|
-
switch (actionObj.action) {
|
|
94
|
-
case (TOOLBAR_STOP):
|
|
95
|
-
return <StopFilledAlt16 disabled={disabled} />;
|
|
96
|
-
case (TOOLBAR_RUN):
|
|
97
|
-
return <Play16 disabled={disabled} />;
|
|
98
|
-
case (TOOLBAR_EXPAND_SUPERNODE_IN_PLACE):
|
|
99
|
-
return <Maximize16 disabled={disabled} />;
|
|
100
|
-
case (TOOLBAR_COLLAPSE_SUPERNODE_IN_PLACE):
|
|
101
|
-
return <Minimize16 disabled={disabled} />;
|
|
102
|
-
case (TOOLBAR_EXPAND_SUPERNODE_FULL_PAGE):
|
|
103
|
-
return <Launch16 disabled={disabled} />;
|
|
104
|
-
case (TOOLBAR_UNDO):
|
|
105
|
-
return <Undo16 disabled={disabled} />;
|
|
106
|
-
case (TOOLBAR_REDO):
|
|
107
|
-
return <Redo16 disabled={disabled} />;
|
|
108
|
-
case (TOOLBAR_CLIPBOARD):
|
|
109
|
-
return <Result16 disabled={disabled} />;
|
|
110
|
-
case (TOOLBAR_CUT):
|
|
111
|
-
return <Cut16 disabled={disabled} />;
|
|
112
|
-
case (TOOLBAR_COPY):
|
|
113
|
-
return <Copy16 disabled={disabled} />;
|
|
114
|
-
case (TOOLBAR_PASTE):
|
|
115
|
-
return <Paste16 disabled={disabled} />;
|
|
116
|
-
case (TOOLBAR_CREATE_COMMENT):
|
|
117
|
-
case (TOOLBAR_CREATE_AUTO_COMMENT):
|
|
118
|
-
return <AddComment16 disabled={disabled} />;
|
|
119
|
-
case (TOOLBAR_SHOW_COMMENTS):
|
|
120
|
-
return <Chat16 disabled={disabled} />;
|
|
121
|
-
case (TOOLBAR_HIDE_COMMENTS):
|
|
122
|
-
return <ChatOff16 disabled={disabled} />;
|
|
123
|
-
case (TOOLBAR_COLOR_BACKGROUND):
|
|
124
|
-
return <ColorPalette16 disabled={disabled} />;
|
|
125
|
-
case (TOOLBAR_DELETE_LINK):
|
|
126
|
-
case (TOOLBAR_DELETE_SELECTED_OBJECTS):
|
|
127
|
-
return <TrashCan16 disabled={disabled} />;
|
|
128
|
-
case (TOOLBAR_SET_COMMENT_EDIT_MODE):
|
|
129
|
-
case (TOOLBAR_SET_NODE_LABEL_EDIT):
|
|
130
|
-
return <Edit16 disabled={disabled} />;
|
|
131
|
-
case (TOOLBAR_ZOOM_IN):
|
|
132
|
-
return <ZoomIn16 disabled={disabled} />;
|
|
133
|
-
case (TOOLBAR_ZOOM_OUT):
|
|
134
|
-
return <ZoomOut16 disabled={disabled} />;
|
|
135
|
-
|
|
136
|
-
case (TOOLBAR_ZOOM_FIT):
|
|
137
|
-
return <SVG src={ZoomToFit} disabled={disabled} />;
|
|
138
|
-
case (TOOLBAR_ARRANGE_HORIZONALLY):
|
|
139
|
-
return <SVG src={ArrangeHorizontally} disabled={disabled} />;
|
|
140
|
-
case (TOOLBAR_ARRANGE_VERTICALLY):
|
|
141
|
-
return <SVG src={ArrangeVertically} disabled={disabled} />;
|
|
142
|
-
case (TOOLBAR_OPEN_PALETTE):
|
|
143
|
-
return <SVG src={PaletteOpen} disabled={disabled} />;
|
|
144
|
-
case (TOOLBAR_CLOSE_PALETTE):
|
|
145
|
-
return <SVG src={PaletteClose} disabled={disabled} />;
|
|
146
|
-
case (TOOLBAR_TOGGLE_NOTIFICATION_PANEL):
|
|
147
|
-
return <SVG src={ToggleNotificationPanel} disabled={disabled} />;
|
|
148
|
-
|
|
149
|
-
default:
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
58
|
+
// Called by toolbar.jsx
|
|
59
|
+
getBoundingRect() {
|
|
60
|
+
return this.divRef.current.getBoundingClientRect();
|
|
152
61
|
}
|
|
153
62
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
className += disable ? " disabled" : "";
|
|
158
|
-
return (<div className={className}>{label}</div>);
|
|
63
|
+
// Called by toolbar.jsx
|
|
64
|
+
getAction() {
|
|
65
|
+
return this.props.actionObj.action;
|
|
159
66
|
}
|
|
160
67
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} else if (inLabelWithIcon === "before") {
|
|
165
|
-
return " before";
|
|
166
|
-
} else if (inLabelWithIcon === "after") {
|
|
167
|
-
return " after";
|
|
168
|
-
}
|
|
169
|
-
return "";
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
generateIcon(actionObj) {
|
|
173
|
-
let icon = this.getDefaultIcon(actionObj);
|
|
174
|
-
|
|
175
|
-
// Host application provided icon. This will override any default icon.
|
|
176
|
-
if (actionObj.iconEnabled) {
|
|
177
|
-
const iconEnabled = actionObj.iconEnabled;
|
|
178
|
-
const iconDisabled = actionObj.iconDisabled || actionObj.iconEnabled;
|
|
179
|
-
const customIcon = actionObj.enable ? iconEnabled : iconDisabled;
|
|
180
|
-
const id = "toolbar-icon-" + this.props.instanceId + " -" + actionObj.action;
|
|
181
|
-
|
|
182
|
-
if (typeof customIcon === "string") {
|
|
183
|
-
icon = (<SVG id={id} src={customIcon} disabled={!actionObj.enable} />);
|
|
184
|
-
} else {
|
|
185
|
-
icon = customIcon;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (icon) {
|
|
190
|
-
return (
|
|
191
|
-
<div className={"toolbar-icon"}>
|
|
192
|
-
{icon}
|
|
193
|
-
</div>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
return null;
|
|
68
|
+
// Called by toolbar.jsx
|
|
69
|
+
isEnabled() {
|
|
70
|
+
return this.props.actionObj.enable;
|
|
197
71
|
}
|
|
198
72
|
|
|
199
73
|
clickOutside(evt) {
|
|
@@ -211,210 +85,112 @@ class ToolbarActionItem extends React.Component {
|
|
|
211
85
|
this.setState({ subAreaDisplayed: true });
|
|
212
86
|
}
|
|
213
87
|
|
|
214
|
-
closeSubArea() {
|
|
215
|
-
|
|
88
|
+
closeSubArea(checkCloseSubAreaOnClick) {
|
|
89
|
+
if (!checkCloseSubAreaOnClick || this.props.actionObj.closeSubAreaOnClick) {
|
|
90
|
+
this.setState({ subAreaDisplayed: false });
|
|
91
|
+
}
|
|
216
92
|
}
|
|
217
93
|
|
|
218
94
|
actionClickHandler(evt) {
|
|
219
95
|
if (this.props.actionObj.subMenu || this.props.actionObj.subPanel) {
|
|
220
|
-
if (this.state.
|
|
96
|
+
if (this.state.subAreaDisplayed) {
|
|
221
97
|
document.removeEventListener("click", this.clickOutside, false);
|
|
98
|
+
this.closeSubArea();
|
|
99
|
+
this.props.setToolbarFocusAction(this.props.actionObj.action);
|
|
100
|
+
|
|
222
101
|
} else {
|
|
223
102
|
document.addEventListener("click", this.clickOutside, false);
|
|
103
|
+
this.openSubArea();
|
|
224
104
|
}
|
|
225
105
|
|
|
226
|
-
if (this.props.setResizeHandler) {
|
|
227
|
-
if (this.state.subAreaDisplayed) {
|
|
228
|
-
this.props.setResizeHandler(null);
|
|
229
|
-
} else {
|
|
230
|
-
this.props.setResizeHandler(this.closeSubArea);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (!this.props.overflow) {
|
|
235
|
-
this.setState({ subAreaDisplayed: !this.state.subAreaDisplayed });
|
|
236
|
-
}
|
|
237
106
|
} else {
|
|
238
107
|
this.props.toolbarActionHandler(this.props.actionObj.action, evt);
|
|
108
|
+
this.props.setToolbarFocusAction(this.props.actionObj.action);
|
|
239
109
|
}
|
|
240
110
|
}
|
|
241
111
|
|
|
242
|
-
|
|
243
|
-
let labelBefore = null;
|
|
244
|
-
let labelAfter = null;
|
|
245
|
-
|
|
246
|
-
if (this.props.overflow) {
|
|
247
|
-
labelAfter = this.generateLabel(actionObj.label, !actionObj.enable, true);
|
|
248
|
-
|
|
249
|
-
} else if (actionObj.incLabelWithIcon === "before") {
|
|
250
|
-
labelBefore = this.generateLabel(actionObj.label, !actionObj.enable, false, actionObj.incLabelWithIcon);
|
|
251
|
-
|
|
252
|
-
} else if (actionObj.incLabelWithIcon === "after") {
|
|
253
|
-
labelAfter = this.generateLabel(actionObj.label, !actionObj.enable, false, actionObj.incLabelWithIcon);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const icon = this.generateIcon(actionObj);
|
|
257
|
-
const textContent = actionObj.textContent ? (<div className="toolbar-text-content"> {actionObj.textContent} </div>) : null;
|
|
258
|
-
|
|
259
|
-
const itemContentClassName = classNames(
|
|
260
|
-
"toolbar-item-content",
|
|
261
|
-
actionObj.className ? actionObj.className : null,
|
|
262
|
-
{ "overflow": this.props.overflow, "disabled": !actionObj.enable, "default": !actionObj.kind });
|
|
263
|
-
|
|
264
|
-
// If no 'kind' is set, use ghost and then override colors using the "default" class in innerDivClassName.
|
|
265
|
-
const kind = actionObj.kind || "ghost";
|
|
266
|
-
|
|
267
|
-
const chevronIcon = this.generateChevronIcon(actionObj);
|
|
268
|
-
|
|
269
|
-
let buttonContent = (
|
|
270
|
-
<div className={itemContentClassName}>
|
|
271
|
-
{labelBefore}
|
|
272
|
-
{icon}
|
|
273
|
-
{labelAfter}
|
|
274
|
-
{textContent}
|
|
275
|
-
{chevronIcon}
|
|
276
|
-
</div>
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
buttonContent = this.wrapInTooltip(buttonContent);
|
|
280
|
-
|
|
281
|
-
// Only specify an aria label for the button if a label is not displayed
|
|
282
|
-
// with the button icon.
|
|
283
|
-
const ariaLabel = actionObj.incLabelWithIcon ? null : actionObj.label;
|
|
284
|
-
|
|
285
|
-
buttonContent = (
|
|
286
|
-
<Button kind={kind}
|
|
287
|
-
onClick={this.actionClickHandler}
|
|
288
|
-
disabled={!actionObj.enable}
|
|
289
|
-
onFocus={this.props.onFocus}
|
|
290
|
-
aria-label={ariaLabel}
|
|
291
|
-
size={this.props.size}
|
|
292
|
-
>
|
|
293
|
-
{buttonContent}
|
|
294
|
-
</Button>
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
return buttonContent;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Returns a chevron icon if the action icon is displaying a sub-menu or
|
|
301
|
-
// sub-panel. The chevron will:
|
|
302
|
-
// * point right if this action item is in a drop down menu
|
|
303
|
-
// * point down if this action item is displayed with text in the toolbar
|
|
304
|
-
// and the menu isn't displayed
|
|
305
|
-
// * point up if this action item is displayed with text in the toolbar
|
|
306
|
-
// and the menu is displayed
|
|
307
|
-
// * be a mini-chevron (small triangle in the bottom right of icon) if this
|
|
308
|
-
// action item isn't displayed with text.
|
|
309
|
-
generateChevronIcon(actionObj) {
|
|
310
|
-
if (actionObj.subMenu || actionObj.subPanel) {
|
|
311
|
-
if (this.props.overflow) {
|
|
312
|
-
return (<ChevronRight16 />);
|
|
313
|
-
}
|
|
314
|
-
if (actionObj.incLabelWithIcon === "before" ||
|
|
315
|
-
actionObj.incLabelWithIcon === "after") {
|
|
316
|
-
const chev = this.state.subAreaDisplayed ? (<ChevronUp16 />) : (<ChevronDown16 />);
|
|
317
|
-
return (<div className={"toolbar-up-down-chevron"}>{chev}</div>);
|
|
318
|
-
}
|
|
319
|
-
return this.generateChevronMini();
|
|
320
|
-
}
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Returns an svg to display the little triangle that appears in the bottom
|
|
325
|
-
// right corner of icons that, when clicked, show a drop down menu.
|
|
326
|
-
generateChevronMini() {
|
|
327
|
-
const path = this.props.size === "sm" ? "M 29 29 L 29 23 23 29 Z" : "M 37 37 L 37 30 30 37 Z";
|
|
328
|
-
return (
|
|
329
|
-
<svg className="toolbar-tick-svg">
|
|
330
|
-
<path d={path} className="toolbar-tick-mark" />
|
|
331
|
-
</svg>
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
generateActionName(actionObj) {
|
|
112
|
+
generateActionName() {
|
|
336
113
|
return this.props.actionObj.action + "-action";
|
|
337
114
|
}
|
|
338
115
|
|
|
339
|
-
wrapInTooltip(content) {
|
|
340
|
-
if (!this.props.overflow && (this.showLabelAsTip(this.props.actionObj) || this.props.actionObj.tooltip)) {
|
|
341
|
-
const actionName = this.generateActionName();
|
|
342
|
-
const tip = this.props.actionObj.tooltip ? this.props.actionObj.tooltip : this.props.actionObj.label;
|
|
343
|
-
const tooltipId = actionName + "-" + this.props.instanceId + "-tooltip";
|
|
344
|
-
const enableTooltip = this.props.actionObj.enable || this.props.actionObj.jsx; // JSX 'tools' don't have enable attr so always display a tooltip for them.
|
|
345
|
-
const direction = this.props.tooltipDirection ? this.props.tooltipDirection : "bottom";
|
|
346
|
-
|
|
347
|
-
return (
|
|
348
|
-
<Tooltip id={tooltipId} tip={tip} disable={!enableTooltip} className="icon-tooltip" direction={direction}>
|
|
349
|
-
{content}
|
|
350
|
-
</Tooltip>
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
return content;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Returns true if the label should be shown as a tooltip or false if not.
|
|
357
|
-
// We do not show the label as a tooltip if it is already shown in the
|
|
358
|
-
// toolbar next to the icon (i.e. incLabelWithIcon is set to something).
|
|
359
|
-
showLabelAsTip(actionObj) {
|
|
360
|
-
if (actionObj.label) {
|
|
361
|
-
if (actionObj.incLabelWithIcon === "before" ||
|
|
362
|
-
actionObj.incLabelWithIcon === "after") {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
return true;
|
|
366
|
-
}
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
116
|
// Returns a sub-area for a cascading menu item. The sub-area can be either a
|
|
371
117
|
// sub-panel which is a div contaiing whatever the caller passes in within the
|
|
372
118
|
// supPanel field OR a sub-menu which is a list of options which is created
|
|
373
119
|
// from the array of items the caller passes in the subMenu field.
|
|
374
120
|
generateSubArea() {
|
|
375
|
-
const
|
|
376
|
-
const actionItemRect = elements && elements.length > 0 ? elements[0].getBoundingClientRect() : { top: 0, left: 0, width: 120 };
|
|
121
|
+
const actionItemRect = this.divRef.current.getBoundingClientRect();
|
|
377
122
|
|
|
123
|
+
if (this.props.actionObj.subPanel) {
|
|
124
|
+
return (
|
|
125
|
+
<ToolbarSubPanel
|
|
126
|
+
subPanel={this.props.actionObj.subPanel}
|
|
127
|
+
subPanelData={this.props.actionObj.subPanelData}
|
|
128
|
+
closeSubArea={this.closeSubArea}
|
|
129
|
+
setToolbarFocusAction={this.props.setToolbarFocusAction}
|
|
130
|
+
actionItemRect={actionItemRect}
|
|
131
|
+
expandDirection={"vertical"}
|
|
132
|
+
containingDivId={this.props.containingDivId}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
378
136
|
return (
|
|
379
|
-
<
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
137
|
+
<ToolbarSubMenu
|
|
138
|
+
subMenuActions={this.props.actionObj.subMenu}
|
|
139
|
+
instanceId={this.props.instanceId}
|
|
140
|
+
toolbarActionHandler={this.props.toolbarActionHandler}
|
|
141
|
+
closeSubArea={this.closeSubArea}
|
|
142
|
+
setToolbarFocusAction={this.props.setToolbarFocusAction}
|
|
383
143
|
actionItemRect={actionItemRect}
|
|
144
|
+
expandDirection={"vertical"}
|
|
384
145
|
containingDivId={this.props.containingDivId}
|
|
385
|
-
|
|
146
|
+
parentSelector={this.generateSelector(this.props.actionObj)}
|
|
147
|
+
isCascadeMenu={false}
|
|
148
|
+
size={this.props.size}
|
|
386
149
|
/>
|
|
387
150
|
);
|
|
388
151
|
}
|
|
389
152
|
|
|
390
|
-
|
|
391
|
-
const actionObj = this.props.actionObj;
|
|
392
|
-
const actionName = this.generateActionName();
|
|
393
|
-
let divContent = null;
|
|
394
|
-
|
|
153
|
+
generateSelector(actionObj) {
|
|
395
154
|
if (actionObj.jsx) {
|
|
396
|
-
|
|
397
|
-
} else {
|
|
398
|
-
divContent = this.generateButton(actionObj);
|
|
155
|
+
return ".toolbar-jsx-item";
|
|
399
156
|
}
|
|
157
|
+
return ".toolbar-item";
|
|
158
|
+
}
|
|
400
159
|
|
|
401
|
-
|
|
160
|
+
render() {
|
|
161
|
+
const actionObj = this.props.actionObj;
|
|
162
|
+
const actionName = this.generateActionName();
|
|
402
163
|
const kindAsClass = actionObj.kind ? actionObj.kind : "default";
|
|
403
164
|
|
|
404
165
|
const itemClassName = classNames(
|
|
405
|
-
{
|
|
406
|
-
"toolbar-item": !
|
|
407
|
-
"toolbar-jsx-item":
|
|
408
|
-
"toolbar-
|
|
409
|
-
|
|
166
|
+
{
|
|
167
|
+
"toolbar-item": !actionObj.jsx,
|
|
168
|
+
"toolbar-jsx-item": actionObj.jsx,
|
|
169
|
+
"toolbar-item-selected": actionObj.isSelected
|
|
170
|
+
},
|
|
410
171
|
kindAsClass,
|
|
411
172
|
actionName);
|
|
412
173
|
|
|
413
174
|
const subArea = this.state.subAreaDisplayed ? this.generateSubArea() : null;
|
|
414
175
|
|
|
415
176
|
return (
|
|
416
|
-
<div className={itemClassName} data-toolbar-
|
|
417
|
-
{
|
|
177
|
+
<div ref={this.divRef} className={itemClassName} data-toolbar-action={actionObj.action} data-toolbar-item
|
|
178
|
+
onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} onKeyDown={this.onKeyDown}
|
|
179
|
+
>
|
|
180
|
+
<div>
|
|
181
|
+
<ToolbarButtonItem
|
|
182
|
+
actionObj={actionObj}
|
|
183
|
+
actionName={this.generateActionName()}
|
|
184
|
+
tooltipDirection={this.props.tooltipDirection}
|
|
185
|
+
instanceId={this.props.instanceId}
|
|
186
|
+
isInMenu={false}
|
|
187
|
+
subAreaDisplayed={this.state.subAreaDisplayed}
|
|
188
|
+
actionClickHandler={this.actionClickHandler}
|
|
189
|
+
buttonFocusAction={this.state.subAreaDisplayed ? null : this.props.toolbarFocusAction}
|
|
190
|
+
isFocusInToolbar={this.props.isFocusInToolbar}
|
|
191
|
+
size={this.props.size}
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
418
194
|
{subArea}
|
|
419
195
|
</div>
|
|
420
196
|
);
|
|
@@ -443,9 +219,9 @@ ToolbarActionItem.propTypes = {
|
|
|
443
219
|
isSelected: PropTypes.bool,
|
|
444
220
|
kind: PropTypes.string,
|
|
445
221
|
closeSubAreaOnClick: PropTypes.bool,
|
|
446
|
-
getSubPanelCloseFn: PropTypes.func,
|
|
447
222
|
subMenu: PropTypes.array,
|
|
448
|
-
subPanel: PropTypes.
|
|
223
|
+
subPanel: PropTypes.any,
|
|
224
|
+
subPanelData: PropTypes.object,
|
|
449
225
|
jsx: PropTypes.object,
|
|
450
226
|
tooltip: PropTypes.oneOfType([
|
|
451
227
|
PropTypes.string,
|
|
@@ -455,12 +231,12 @@ ToolbarActionItem.propTypes = {
|
|
|
455
231
|
}),
|
|
456
232
|
tooltipDirection: PropTypes.oneOf(["top", "bottom"]),
|
|
457
233
|
toolbarActionHandler: PropTypes.func.isRequired,
|
|
458
|
-
generateToolbarItems: PropTypes.func.isRequired,
|
|
459
|
-
setResizeHandler: PropTypes.func,
|
|
460
234
|
instanceId: PropTypes.number.isRequired,
|
|
461
235
|
containingDivId: PropTypes.string,
|
|
462
|
-
|
|
463
|
-
|
|
236
|
+
closeParentSubArea: PropTypes.func,
|
|
237
|
+
toolbarFocusAction: PropTypes.string,
|
|
238
|
+
setToolbarFocusAction: PropTypes.func,
|
|
239
|
+
isFocusInToolbar: PropTypes.bool,
|
|
464
240
|
size: PropTypes.oneOf(["md", "sm"])
|
|
465
241
|
};
|
|
466
242
|
|