@pega/cosmos-react-build 3.0.0-dev.3.0 → 3.0.0-dev.4.2
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/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts +3 -0
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js +138 -32
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +6 -0
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js.map +1 -1
- package/lib/components/FlowModeller/AddNode.d.ts +9 -7
- package/lib/components/FlowModeller/AddNode.d.ts.map +1 -1
- package/lib/components/FlowModeller/AddNode.js +9 -3
- package/lib/components/FlowModeller/AddNode.js.map +1 -1
- package/lib/components/FlowModeller/Connector.d.ts +7 -0
- package/lib/components/FlowModeller/Connector.d.ts.map +1 -0
- package/lib/components/FlowModeller/Connector.js +34 -0
- package/lib/components/FlowModeller/Connector.js.map +1 -0
- package/lib/components/FlowModeller/DeletePopover.d.ts +26 -0
- package/lib/components/FlowModeller/DeletePopover.d.ts.map +1 -0
- package/lib/components/FlowModeller/DeletePopover.js +105 -0
- package/lib/components/FlowModeller/DeletePopover.js.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.d.ts +3 -1
- package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.js +107 -57
- package/lib/components/FlowModeller/FlowModeller.js.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.d.ts +13 -4
- package/lib/components/FlowModeller/Node/Node.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts +6 -4
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js +17 -10
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.js +15 -5
- package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -1
- package/lib/components/FlowModeller/Node.d.ts +5 -0
- package/lib/components/FlowModeller/Node.d.ts.map +1 -0
- package/lib/components/FlowModeller/Node.js +23 -0
- package/lib/components/FlowModeller/Node.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Connectors.d.ts +2 -0
- package/lib/components/FlowModeller/Renderer/Connectors.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Connectors.js +4 -2
- package/lib/components/FlowModeller/Renderer/Connectors.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Nodes.d.ts +2 -0
- package/lib/components/FlowModeller/Renderer/Nodes.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Nodes.js +8 -2
- package/lib/components/FlowModeller/Renderer/Nodes.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.js +2 -2
- package/lib/components/FlowModeller/Renderer/Renderer.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts +10 -4
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.types.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts +3 -3
- package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js +7 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts +8 -4
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js +23 -3
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js.map +1 -1
- package/lib/components/FlowModeller/Utils/{AddNodeUtils.d.ts → addNodeUtils.d.ts} +1 -1
- package/lib/components/FlowModeller/Utils/{AddNodeUtils.d.ts.map → addNodeUtils.d.ts.map} +1 -1
- package/lib/components/FlowModeller/Utils/{AddNodeUtils.js → addNodeUtils.js} +1 -1
- package/lib/components/FlowModeller/Utils/addNodeUtils.js.map +1 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts +21 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts.map +1 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js +71 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js.map +1 -0
- package/lib/components/FlowModeller/helper.d.ts +2 -1
- package/lib/components/FlowModeller/helper.d.ts.map +1 -1
- package/lib/components/FlowModeller/helper.js +17 -2
- package/lib/components/FlowModeller/helper.js.map +1 -1
- package/lib/components/FlowModeller/index.d.ts +5 -1
- package/lib/components/FlowModeller/index.d.ts.map +1 -1
- package/lib/components/FlowModeller/index.js +5 -1
- package/lib/components/FlowModeller/index.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.d.ts +1 -1
- package/lib/components/LifeCycle/LifeCycleList.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.js +2 -1
- package/lib/components/LifeCycle/LifeCycleList.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectConfig.d.ts +18 -0
- package/lib/components/ObjectSelect/ObjectConfig.d.ts.map +1 -0
- package/lib/components/ObjectSelect/ObjectConfig.js +14 -0
- package/lib/components/ObjectSelect/ObjectConfig.js.map +1 -0
- package/lib/components/ObjectSelect/ObjectPicker.d.ts +10 -0
- package/lib/components/ObjectSelect/ObjectPicker.d.ts.map +1 -0
- package/lib/components/ObjectSelect/ObjectPicker.js +25 -0
- package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -0
- package/lib/components/ObjectSelect/ObjectSelect.d.ts +22 -0
- package/lib/components/ObjectSelect/ObjectSelect.d.ts.map +1 -0
- package/lib/components/ObjectSelect/ObjectSelect.js +20 -0
- package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -0
- package/lib/components/ObjectSelect/ObjectSummary.d.ts +21 -0
- package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -0
- package/lib/components/ObjectSelect/ObjectSummary.js +71 -0
- package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -0
- package/lib/components/ObjectSelect/index.d.ts +3 -0
- package/lib/components/ObjectSelect/index.d.ts.map +1 -0
- package/lib/components/ObjectSelect/index.js +2 -0
- package/lib/components/ObjectSelect/index.js.map +1 -0
- package/lib/components/Workbench/ConfigurationPanel.d.ts.map +1 -1
- package/lib/components/Workbench/ConfigurationPanel.js +2 -3
- package/lib/components/Workbench/ConfigurationPanel.js.map +1 -1
- package/lib/components/Workbench/Toolbar.d.ts +1 -5
- package/lib/components/Workbench/Toolbar.d.ts.map +1 -1
- package/lib/components/Workbench/Toolbar.js +8 -8
- package/lib/components/Workbench/Toolbar.js.map +1 -1
- package/lib/components/Workbench/Workbench.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.js +2 -3
- package/lib/components/Workbench/Workbench.js.map +1 -1
- package/lib/components/Workbench/Workbench.styles.d.ts +0 -1
- package/lib/components/Workbench/Workbench.styles.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.styles.js +12 -17
- package/lib/components/Workbench/Workbench.styles.js.map +1 -1
- package/lib/components/Workbench/Workbench.types.d.ts +0 -2
- package/lib/components/Workbench/Workbench.types.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.types.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +10 -10
- package/lib/components/FlowModeller/Utils/AddNodeUtils.js.map +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import { DynamicContentEditorProps } from './DynamicContentEditor.types';
|
|
4
|
+
export declare const StyledSearchPopover: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
5
|
+
offset?: number | undefined;
|
|
6
|
+
}, never>;
|
|
4
7
|
declare const DynamicContentEditor: FunctionComponent<DynamicContentEditorProps & ForwardProps>;
|
|
5
8
|
export default DynamicContentEditor;
|
|
6
9
|
//# sourceMappingURL=DynamicContentEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicContentEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAGL,YAAY,
|
|
1
|
+
{"version":3,"file":"DynamicContentEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAGL,YAAY,EAYb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,yBAAyB,EAAY,MAAM,8BAA8B,CAAC;AAOnF,eAAO,MAAM,mBAAmB;;SAE/B,CAAC;AAIF,QAAA,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,yBAAyB,GAAG,YAAY,CA+RnF,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
|
|
@@ -2,21 +2,40 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { forwardRef, useContext, useRef, useEffect, useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Editor } from '@pega/cosmos-react-rte';
|
|
5
|
-
import { Button, defaultThemeProp, Modal, ModalManagerContext, useConsolidatedRef, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
+
import { Button, defaultThemeProp, Menu, Modal, ModalManagerContext, Popover, StyledPopover, useConsolidatedRef, useI18n } from '@pega/cosmos-react-core';
|
|
6
6
|
import { getKeyCommand } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/Toolbar/utils';
|
|
7
7
|
import PegaCustomElement from './PegaCustomElement';
|
|
8
8
|
const StyledDynamicContentEditor = styled.div ``;
|
|
9
|
+
export const StyledSearchPopover = styled(StyledPopover) `
|
|
10
|
+
min-width: 20rem;
|
|
11
|
+
`;
|
|
9
12
|
StyledDynamicContentEditor.defaultProps = defaultThemeProp;
|
|
10
|
-
const DynamicContentEditor = forwardRef(({ form: { dynamicContentPicker, onSubmit }, onActiveFieldChange, label, toolbar, ...restProps }, ref) => {
|
|
13
|
+
const DynamicContentEditor = forwardRef(({ form: { dynamicContentPicker, onSubmit }, onActiveFieldChange, label, toolbar, fieldItems, defaultValue, onBlur, ...restProps }, ref) => {
|
|
11
14
|
const { create } = useContext(ModalManagerContext);
|
|
12
15
|
const t = useI18n();
|
|
13
16
|
const modalMethods = useRef();
|
|
14
|
-
const [editor, setEditor] = useState(
|
|
17
|
+
const [editor, setEditor] = useState();
|
|
15
18
|
const [bookmark, setBookmark] = useState();
|
|
19
|
+
const [fieldMenu, setFieldMenu] = useState({ items: fieldItems || [] });
|
|
16
20
|
const [currentElementContent, setCurrentElementContent] = useState(null);
|
|
21
|
+
const [currentCursorPosition, setCurrentCursorPosition] = useState({
|
|
22
|
+
bottom: 0,
|
|
23
|
+
height: 0,
|
|
24
|
+
left: 0,
|
|
25
|
+
right: 0,
|
|
26
|
+
top: 0,
|
|
27
|
+
width: 0,
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
toJSON: () => { }
|
|
31
|
+
});
|
|
32
|
+
const [showFieldsPopover, setShowFieldsPopover] = useState(false);
|
|
33
|
+
const fieldPopoverRef = useRef(null);
|
|
17
34
|
const editorRef = useConsolidatedRef(ref);
|
|
18
|
-
const tooltip = getKeyCommand(navigator.appVersion.includes('Mac'), ({ ctrl }) => `${t('
|
|
35
|
+
const tooltip = getKeyCommand(navigator.appVersion.includes('Mac'), ({ ctrl }) => `${t('rte_insert_field')} (${ctrl}/)`);
|
|
19
36
|
const insertField = (field) => {
|
|
37
|
+
if (!editor)
|
|
38
|
+
return;
|
|
20
39
|
const fieldContent = `<pega-reference role="button" contenteditable="false" data-rule-type='field' data-rule-id=${field.id}>${field.text}</pega-reference>`;
|
|
21
40
|
if (bookmark) {
|
|
22
41
|
editor.selection.moveToBookmark(bookmark);
|
|
@@ -42,24 +61,64 @@ const DynamicContentEditor = forwardRef(({ form: { dynamicContentPicker, onSubmi
|
|
|
42
61
|
onActiveFieldChange({ id: currentElementContent, text: currentElementContent });
|
|
43
62
|
}
|
|
44
63
|
};
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
const findAndRenameField = (fieldId) => {
|
|
65
|
+
if (!editor || !fieldItems)
|
|
66
|
+
return;
|
|
67
|
+
const selectedRange = editor.selection.getRng();
|
|
68
|
+
const endOffset = selectedRange.endOffset;
|
|
69
|
+
const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);
|
|
70
|
+
if (stringToSearch === undefined)
|
|
71
|
+
return;
|
|
72
|
+
const splitSearch = stringToSearch.split(' ');
|
|
73
|
+
const fieldString = splitSearch[splitSearch.length - 1];
|
|
74
|
+
const range = document.createRange();
|
|
75
|
+
const startPos = stringToSearch.lastIndexOf(fieldString);
|
|
76
|
+
const endPos = startPos + fieldString.length;
|
|
77
|
+
range.setStart(selectedRange.commonAncestorContainer, startPos);
|
|
78
|
+
range.setEnd(selectedRange.commonAncestorContainer, endPos);
|
|
79
|
+
document.getSelection()?.removeAllRanges();
|
|
80
|
+
document.getSelection()?.addRange(range);
|
|
81
|
+
const selectedFieldId = fieldItems.find(item => item.id === fieldId)?.id;
|
|
82
|
+
if (selectedFieldId) {
|
|
83
|
+
editor.selection.setContent(`<pega-reference contenteditable="false" data-rule-type="field" data-rule-id=${selectedFieldId}>${selectedFieldId}</pega-reference>`);
|
|
84
|
+
setShowFieldsPopover(false);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const hidePopover = () => {
|
|
88
|
+
if (fieldPopoverRef)
|
|
89
|
+
setShowFieldsPopover(false);
|
|
90
|
+
};
|
|
91
|
+
const filterFieldMenu = (searchString) => {
|
|
92
|
+
setShowFieldsPopover(true);
|
|
93
|
+
setFieldMenu({ items: fieldItems || [] });
|
|
94
|
+
if (/\s/.test(searchString)) {
|
|
95
|
+
setShowFieldsPopover(false);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (searchString && fieldItems) {
|
|
99
|
+
const newFieldItems = fieldItems.filter(item => item.id.toLowerCase().startsWith(searchString.toLowerCase()));
|
|
100
|
+
if (newFieldItems) {
|
|
101
|
+
setShowFieldsPopover(true);
|
|
102
|
+
setFieldMenu({ items: newFieldItems });
|
|
103
|
+
}
|
|
104
|
+
else
|
|
105
|
+
setShowFieldsPopover(false);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
49
108
|
const updateBookmarkAndCurrentElement = (editorSelection) => {
|
|
50
109
|
const targetEl = editorSelection.getNode();
|
|
51
110
|
const fieldValue = targetEl.getAttribute('data-rule-id');
|
|
52
111
|
setBookmark(editorSelection.getBookmark());
|
|
53
112
|
setCurrentElementContent(fieldValue);
|
|
54
113
|
};
|
|
55
|
-
const handleElementClick = (
|
|
56
|
-
|
|
57
|
-
if (targetEl.tagName === 'PEGA-REFERENCE') {
|
|
114
|
+
const handleElementClick = ({ target }) => {
|
|
115
|
+
if (editor && target instanceof HTMLElement && target.tagName === 'PEGA-REFERENCE') {
|
|
58
116
|
updateBookmarkAndCurrentElement(editor.selection);
|
|
59
117
|
}
|
|
118
|
+
hidePopover();
|
|
60
119
|
};
|
|
61
120
|
const onInsertField = (incEditor) => {
|
|
62
|
-
const targetEl = incEditor.selection
|
|
121
|
+
const targetEl = incEditor.selection.getNode();
|
|
63
122
|
if (targetEl.tagName === 'PEGA-REFERENCE') {
|
|
64
123
|
updateBookmarkAndCurrentElement(incEditor.selection);
|
|
65
124
|
}
|
|
@@ -68,11 +127,21 @@ const DynamicContentEditor = forwardRef(({ form: { dynamicContentPicker, onSubmi
|
|
|
68
127
|
}
|
|
69
128
|
};
|
|
70
129
|
const isPegaRefActive = (incEditor) => {
|
|
71
|
-
const targetEl = incEditor.selection
|
|
72
|
-
return targetEl
|
|
130
|
+
const targetEl = incEditor.selection.getNode();
|
|
131
|
+
return targetEl.tagName === 'PEGA-REFERENCE';
|
|
73
132
|
};
|
|
133
|
+
const fieldSelectionPopover = (_jsx(Popover, { show: showFieldsPopover, strategy: 'fixed', ref: fieldPopoverRef, target: {
|
|
134
|
+
getBoundingClientRect: () => {
|
|
135
|
+
return currentCursorPosition;
|
|
136
|
+
}
|
|
137
|
+
}, placement: 'bottom-start', children: fieldItems && (_jsx(Menu, { ...fieldMenu, as: StyledSearchPopover, focusControlEl: editorRef.current?.element?.querySelector('[role="textbox"]') || undefined, mode: 'action', onItemClick: findAndRenameField }, void 0)) }, void 0));
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (currentElementContent)
|
|
140
|
+
modalMethods.current = create(Modal, modalProps);
|
|
141
|
+
}, [currentElementContent]);
|
|
74
142
|
useEffect(() => {
|
|
75
143
|
editorRef.current?.element?.addEventListener('click', handleElementClick);
|
|
144
|
+
editorRef.current?.insertHtml(defaultValue?.trim() || '', false);
|
|
76
145
|
return () => {
|
|
77
146
|
editorRef.current?.element?.removeEventListener('click', handleElementClick);
|
|
78
147
|
};
|
|
@@ -82,26 +151,63 @@ const DynamicContentEditor = forwardRef(({ form: { dynamicContentPicker, onSubmi
|
|
|
82
151
|
modalMethods.current.update(modalProps);
|
|
83
152
|
}
|
|
84
153
|
}, [modalProps]);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
154
|
+
const onEditorChange = (formEditor) => {
|
|
155
|
+
if (formEditor) {
|
|
156
|
+
const targetEl = formEditor?.selection?.getBoundingClientRect();
|
|
157
|
+
const { left = 0, top = 0 } = targetEl;
|
|
158
|
+
setCurrentCursorPosition({
|
|
159
|
+
...formEditor?.selection?.getBoundingClientRect(),
|
|
160
|
+
x: left,
|
|
161
|
+
y: top,
|
|
162
|
+
toJSON: () => { }
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (formEditor?.selection?.isCollapsed()) {
|
|
166
|
+
// get the full line string
|
|
167
|
+
const selectedRange = formEditor.selection.getRng();
|
|
168
|
+
const endOffset = selectedRange.endOffset;
|
|
169
|
+
const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);
|
|
170
|
+
const fieldString = stringToSearch?.split(' ')[stringToSearch?.split(' ').length - 1];
|
|
171
|
+
if (fieldString?.startsWith('@') &&
|
|
172
|
+
fieldString.indexOf('@') === fieldString.lastIndexOf('@')) {
|
|
173
|
+
filterFieldMenu(fieldString.slice(1));
|
|
89
174
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
175
|
+
else
|
|
176
|
+
setShowFieldsPopover(false);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
const onKeyDown = event => {
|
|
180
|
+
if ((event?.key === 'Enter' || event?.key === 'ArrowLeft' || event?.key === 'ArrowRight') &&
|
|
181
|
+
!!fieldPopoverRef.current) {
|
|
182
|
+
event?.preventDefault();
|
|
183
|
+
}
|
|
184
|
+
if (event?.key === 'Escape' && !!fieldPopoverRef.current) {
|
|
185
|
+
hidePopover();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
return (_jsx(_Fragment, { children: _jsx(Editor, { ref: editorRef, ...restProps, label: label, toolbar: toolbar, customComponents: [
|
|
189
|
+
{
|
|
190
|
+
customElement: PegaCustomElement,
|
|
191
|
+
name: 'pega-reference'
|
|
102
192
|
}
|
|
103
|
-
|
|
104
|
-
|
|
193
|
+
], customActions: [
|
|
194
|
+
{
|
|
195
|
+
icon: 'code',
|
|
196
|
+
text: tooltip,
|
|
197
|
+
onMouseDown: () => {
|
|
198
|
+
modalMethods.current = create(Modal, modalProps);
|
|
199
|
+
},
|
|
200
|
+
active: isPegaRefActive,
|
|
201
|
+
shortcut: {
|
|
202
|
+
pattern: 'meta+191',
|
|
203
|
+
description: tooltip,
|
|
204
|
+
command: onInsertField
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
], onInit: setEditor, onChange: onEditorChange, onBlur: () => {
|
|
208
|
+
onBlur?.();
|
|
209
|
+
hidePopover();
|
|
210
|
+
}, onKeyDown: onKeyDown, children: fieldSelectionPopover }, void 0) }, void 0));
|
|
105
211
|
});
|
|
106
212
|
export default DynamicContentEditor;
|
|
107
213
|
//# sourceMappingURL=DynamicContentEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicContentEditor.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,MAAM,EACN,gBAAgB,EAEhB,KAAK,EACL,mBAAmB,EAGnB,kBAAkB,EAClB,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oEAAoE,CAAC;AAGnG,O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SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAEhC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACzC;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,KAAC,MAAM,IACL,GAAG,EAAE,SAAS,KACV,SAAS,EACb,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE;YAChB;gBACE,aAAa,EAAE,iBAAiB;gBAChC,IAAI,EAAE,gBAAgB;aACvB;SACF,EACD,aAAa,EAAE;YACb;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,GAAG,EAAE;oBAChB,YAAY,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBACnD,CAAC;gBACD,MAAM,EAAE,eAAe;gBACvB,QAAQ,EAAE;oBACR,OAAO,EAAE,UAAU;oBACnB,WAAW,EAAE,OAAO;oBACpB,OAAO,EAAE,aAAa;iBACvB;aACF;SACF,EACD,MAAM,EAAE,iBAAiB,CAAC,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,WACzD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,eAAe,oBAAoB,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useContext,\n useRef,\n useEffect,\n useState\n} from 'react';\nimport styled from 'styled-components';\nimport { Bookmark, Editor as TinymceEditor, EditorSelection } from 'tinymce';\n\nimport { Editor } from '@pega/cosmos-react-rte';\nimport {\n Button,\n defaultThemeProp,\n ForwardProps,\n Modal,\n ModalManagerContext,\n ModalMethods,\n PropsWithDefaults,\n useConsolidatedRef,\n useI18n\n} from '@pega/cosmos-react-core';\nimport { getKeyCommand } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/Toolbar/utils';\n\nimport { DynamicContentEditorProps, ItemType } from './DynamicContentEditor.types';\nimport PegaCustomElement from './PegaCustomElement';\n\ntype DynamicContentEditorPropsWithDefaults = PropsWithDefaults<DynamicContentEditorProps>;\n\nconst StyledDynamicContentEditor = styled.div<DynamicContentEditorPropsWithDefaults>``;\n\nStyledDynamicContentEditor.defaultProps = defaultThemeProp;\n\nconst DynamicContentEditor: FunctionComponent<DynamicContentEditorProps & ForwardProps> =\n forwardRef(\n (\n {\n form: { dynamicContentPicker, onSubmit },\n onActiveFieldChange,\n label,\n toolbar,\n ...restProps\n }: PropsWithoutRef<DynamicContentEditorProps>,\n ref: DynamicContentEditorProps['ref']\n ) => {\n const { create } = useContext(ModalManagerContext);\n const t = useI18n();\n\n const modalMethods = useRef<ModalMethods>();\n const [editor, setEditor] = useState({} as TinymceEditor);\n const [bookmark, setBookmark] = useState<Bookmark | undefined>();\n const [currentElementContent, setCurrentElementContent] = useState<string | null>(null);\n const editorRef = useConsolidatedRef(ref);\n const tooltip = getKeyCommand(\n navigator.appVersion.includes('Mac'),\n ({ ctrl }) => `${t('rte_anchor')} (${ctrl}/)`\n );\n\n const insertField = (field: ItemType) => {\n const fieldContent = `<pega-reference role=\"button\" contenteditable=\"false\" data-rule-type='field' data-rule-id=${field.id}>${field.text}</pega-reference>`;\n if (bookmark) {\n editor.selection.moveToBookmark(bookmark);\n editor.selection.setContent(fieldContent);\n } else {\n editor.insertContent(fieldContent);\n }\n\n modalMethods.current?.dismiss();\n };\n\n const modalProps = {\n children: dynamicContentPicker,\n heading: t('rte_insert_field'),\n actions: (\n <>\n <Button variant='secondary' onClick={() => modalMethods.current?.dismiss()}>\n {t('cancel')}\n </Button>\n <Button variant='primary' onClick={() => onSubmit(insertField)}>\n {t('submit')}\n </Button>\n </>\n ),\n center: true,\n onAfterClose: () => {\n setBookmark(undefined);\n setCurrentElementContent('');\n onActiveFieldChange({ id: '', text: '' });\n },\n onBeforeOpen: () => {\n if (currentElementContent)\n onActiveFieldChange({ id: currentElementContent, text: currentElementContent });\n }\n };\n\n useEffect(() => {\n if (currentElementContent) modalMethods.current = create(Modal, modalProps);\n }, [currentElementContent]);\n\n const updateBookmarkAndCurrentElement = (editorSelection: EditorSelection) => {\n const targetEl = editorSelection.getNode();\n const fieldValue = targetEl.getAttribute('data-rule-id');\n setBookmark(editorSelection.getBookmark());\n setCurrentElementContent(fieldValue);\n };\n\n const handleElementClick = (e: MouseEvent) => {\n const targetEl = e.target as HTMLElement;\n if (targetEl.tagName === 'PEGA-REFERENCE') {\n updateBookmarkAndCurrentElement(editor.selection);\n }\n };\n\n const onInsertField = (incEditor: TinymceEditor) => {\n const targetEl = incEditor.selection?.getNode();\n if (targetEl.tagName === 'PEGA-REFERENCE') {\n updateBookmarkAndCurrentElement(incEditor.selection);\n } else {\n modalMethods.current = create(Modal, modalProps);\n }\n };\n\n const isPegaRefActive = (incEditor: TinymceEditor) => {\n const targetEl = incEditor.selection?.getNode();\n return targetEl?.tagName === 'PEGA-REFERENCE';\n };\n\n useEffect(() => {\n editorRef.current?.element?.addEventListener('click', handleElementClick);\n return () => {\n editorRef.current?.element?.removeEventListener('click', handleElementClick);\n };\n }, [editor, editorRef.current]);\n\n useEffect(() => {\n if (modalMethods.current) {\n modalMethods.current.update(modalProps);\n }\n }, [modalProps]);\n\n return (\n <Editor\n ref={editorRef}\n {...restProps}\n label={label}\n toolbar={toolbar}\n customComponents={[\n {\n customElement: PegaCustomElement,\n name: 'pega-reference'\n }\n ]}\n customActions={[\n {\n icon: 'code',\n text: tooltip,\n onMouseDown: () => {\n modalMethods.current = create(Modal, modalProps);\n },\n active: isPegaRefActive,\n shortcut: {\n pattern: 'meta+191',\n description: tooltip,\n command: onInsertField\n }\n }\n ]}\n onInit={initializedEditor => setEditor(initializedEditor)}\n />\n );\n }\n );\n\nexport default DynamicContentEditor;\n"]}
|
|
1
|
+
{"version":3,"file":"DynamicContentEditor.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/D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AE,CAAC;gBACX,WAAW,EAAE,CAAC;YAChB,CAAC,EACD,SAAS,EAAE,SAAS,YAEnB,qBAAqB,WACf,WACR,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,eAAe,oBAAoB,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useContext,\n useRef,\n useEffect,\n useState\n} from 'react';\nimport styled from 'styled-components';\nimport { Bookmark, Editor as TinymceEditor, EditorSelection } from 'tinymce';\n\nimport { Editor, EditorProps } from '@pega/cosmos-react-rte';\nimport {\n Button,\n defaultThemeProp,\n ForwardProps,\n Menu,\n MenuItemProps,\n MenuProps,\n Modal,\n ModalManagerContext,\n ModalMethods,\n Popover,\n PropsWithDefaults,\n StyledPopover,\n useConsolidatedRef,\n useI18n\n} from '@pega/cosmos-react-core';\nimport { getKeyCommand } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/Toolbar/utils';\n\nimport { DynamicContentEditorProps, ItemType } from './DynamicContentEditor.types';\nimport PegaCustomElement from './PegaCustomElement';\n\ntype DynamicContentEditorPropsWithDefaults = PropsWithDefaults<DynamicContentEditorProps>;\n\nconst StyledDynamicContentEditor = styled.div<DynamicContentEditorPropsWithDefaults>``;\n\nexport const StyledSearchPopover = styled(StyledPopover)`\n min-width: 20rem;\n`;\n\nStyledDynamicContentEditor.defaultProps = defaultThemeProp;\n\nconst DynamicContentEditor: FunctionComponent<DynamicContentEditorProps & ForwardProps> =\n forwardRef(\n (\n {\n form: { dynamicContentPicker, onSubmit },\n onActiveFieldChange,\n label,\n toolbar,\n fieldItems,\n defaultValue,\n onBlur,\n ...restProps\n }: PropsWithoutRef<DynamicContentEditorProps>,\n ref: DynamicContentEditorProps['ref']\n ) => {\n const { create } = useContext(ModalManagerContext);\n const t = useI18n();\n\n const modalMethods = useRef<ModalMethods>();\n const [editor, setEditor] = useState<TinymceEditor | undefined>();\n const [bookmark, setBookmark] = useState<Bookmark | undefined>();\n const [fieldMenu, setFieldMenu] = useState<MenuProps>({ items: fieldItems || [] });\n const [currentElementContent, setCurrentElementContent] = useState<string | null>(null);\n const [currentCursorPosition, setCurrentCursorPosition] = useState({\n bottom: 0,\n height: 0,\n left: 0,\n right: 0,\n top: 0,\n width: 0,\n x: 0,\n y: 0,\n toJSON: () => {}\n });\n const [showFieldsPopover, setShowFieldsPopover] = useState<boolean>(false);\n\n const fieldPopoverRef = useRef<HTMLDivElement>(null);\n const editorRef = useConsolidatedRef(ref);\n\n const tooltip = getKeyCommand(\n navigator.appVersion.includes('Mac'),\n ({ ctrl }) => `${t('rte_insert_field')} (${ctrl}/)`\n );\n\n const insertField = (field: ItemType) => {\n if (!editor) return;\n\n const fieldContent = `<pega-reference role=\"button\" contenteditable=\"false\" data-rule-type='field' data-rule-id=${field.id}>${field.text}</pega-reference>`;\n if (bookmark) {\n editor.selection.moveToBookmark(bookmark);\n editor.selection.setContent(fieldContent);\n } else {\n editor.insertContent(fieldContent);\n }\n\n modalMethods.current?.dismiss();\n };\n\n const modalProps = {\n children: dynamicContentPicker,\n heading: t('rte_insert_field'),\n actions: (\n <>\n <Button variant='secondary' onClick={() => modalMethods.current?.dismiss()}>\n {t('cancel')}\n </Button>\n <Button variant='primary' onClick={() => onSubmit(insertField)}>\n {t('submit')}\n </Button>\n </>\n ),\n center: true,\n onAfterClose: () => {\n setBookmark(undefined);\n setCurrentElementContent('');\n onActiveFieldChange({ id: '', text: '' });\n },\n onBeforeOpen: () => {\n if (currentElementContent)\n onActiveFieldChange({ id: currentElementContent, text: currentElementContent });\n }\n };\n\n const findAndRenameField = (fieldId: string) => {\n if (!editor || !fieldItems) return;\n\n const selectedRange = editor.selection.getRng();\n const endOffset = selectedRange.endOffset;\n const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);\n if (stringToSearch === undefined) return;\n\n const splitSearch = stringToSearch.split(' ');\n const fieldString = splitSearch[splitSearch.length - 1];\n const range = document.createRange();\n\n const startPos = stringToSearch.lastIndexOf(fieldString);\n const endPos = startPos + fieldString.length;\n range.setStart(selectedRange.commonAncestorContainer, startPos);\n range.setEnd(selectedRange.commonAncestorContainer, endPos);\n document.getSelection()?.removeAllRanges();\n document.getSelection()?.addRange(range);\n const selectedFieldId = fieldItems.find(item => item.id === fieldId)?.id;\n if (selectedFieldId) {\n editor.selection.setContent(\n `<pega-reference contenteditable=\"false\" data-rule-type=\"field\" data-rule-id=${selectedFieldId}>${selectedFieldId}</pega-reference>`\n );\n setShowFieldsPopover(false);\n }\n };\n\n const hidePopover = () => {\n if (fieldPopoverRef) setShowFieldsPopover(false);\n };\n\n const filterFieldMenu = (searchString: string) => {\n setShowFieldsPopover(true);\n setFieldMenu({ items: fieldItems || [] });\n if (/\\s/.test(searchString)) {\n setShowFieldsPopover(false);\n return;\n }\n if (searchString && fieldItems) {\n const newFieldItems: MenuItemProps[] = fieldItems.filter(item =>\n item.id.toLowerCase().startsWith(searchString.toLowerCase())\n );\n if (newFieldItems) {\n setShowFieldsPopover(true);\n setFieldMenu({ items: newFieldItems });\n } else setShowFieldsPopover(false);\n }\n };\n\n const updateBookmarkAndCurrentElement = (editorSelection: EditorSelection) => {\n const targetEl = editorSelection.getNode();\n const fieldValue = targetEl.getAttribute('data-rule-id');\n setBookmark(editorSelection.getBookmark());\n setCurrentElementContent(fieldValue);\n };\n\n const handleElementClick = ({ target }: MouseEvent) => {\n if (editor && target instanceof HTMLElement && target.tagName === 'PEGA-REFERENCE') {\n updateBookmarkAndCurrentElement(editor.selection);\n }\n hidePopover();\n };\n\n const onInsertField = (incEditor: TinymceEditor) => {\n const targetEl = incEditor.selection.getNode();\n if (targetEl.tagName === 'PEGA-REFERENCE') {\n updateBookmarkAndCurrentElement(incEditor.selection);\n } else {\n modalMethods.current = create(Modal, modalProps);\n }\n };\n\n const isPegaRefActive = (incEditor: TinymceEditor) => {\n const targetEl = incEditor.selection.getNode();\n return targetEl.tagName === 'PEGA-REFERENCE';\n };\n\n const fieldSelectionPopover = (\n <Popover\n show={showFieldsPopover}\n strategy='fixed'\n ref={fieldPopoverRef}\n target={{\n getBoundingClientRect: () => {\n return currentCursorPosition;\n }\n }}\n placement='bottom-start'\n >\n {fieldItems && (\n <Menu\n {...fieldMenu}\n as={StyledSearchPopover}\n focusControlEl={\n editorRef.current?.element?.querySelector('[role=\"textbox\"]') || undefined\n }\n mode='action'\n onItemClick={findAndRenameField}\n />\n )}\n </Popover>\n );\n\n useEffect(() => {\n if (currentElementContent) modalMethods.current = create(Modal, modalProps);\n }, [currentElementContent]);\n\n useEffect(() => {\n editorRef.current?.element?.addEventListener('click', handleElementClick);\n editorRef.current?.insertHtml(defaultValue?.trim() || '', false);\n return () => {\n editorRef.current?.element?.removeEventListener('click', handleElementClick);\n };\n }, [editor, editorRef.current]);\n\n useEffect(() => {\n if (modalMethods.current) {\n modalMethods.current.update(modalProps);\n }\n }, [modalProps]);\n\n const onEditorChange: EditorProps['onChange'] = (formEditor?: TinymceEditor) => {\n if (formEditor) {\n const targetEl = formEditor?.selection?.getBoundingClientRect();\n const { left = 0, top = 0 } = targetEl;\n setCurrentCursorPosition({\n ...formEditor?.selection?.getBoundingClientRect(),\n x: left,\n y: top,\n toJSON: () => {}\n });\n }\n\n if (formEditor?.selection?.isCollapsed()) {\n // get the full line string\n const selectedRange = formEditor.selection.getRng();\n const endOffset = selectedRange.endOffset;\n const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(\n 0,\n endOffset\n );\n const fieldString = stringToSearch?.split(' ')[stringToSearch?.split(' ').length - 1];\n if (\n fieldString?.startsWith('@') &&\n fieldString.indexOf('@') === fieldString.lastIndexOf('@')\n ) {\n filterFieldMenu(fieldString.slice(1));\n } else setShowFieldsPopover(false);\n }\n };\n\n const onKeyDown: EditorProps['onKeyDown'] = event => {\n if (\n (event?.key === 'Enter' || event?.key === 'ArrowLeft' || event?.key === 'ArrowRight') &&\n !!fieldPopoverRef.current\n ) {\n event?.preventDefault();\n }\n if (event?.key === 'Escape' && !!fieldPopoverRef.current) {\n hidePopover();\n }\n };\n\n return (\n <>\n <Editor\n ref={editorRef}\n {...restProps}\n label={label}\n toolbar={toolbar}\n customComponents={[\n {\n customElement: PegaCustomElement,\n name: 'pega-reference'\n }\n ]}\n customActions={[\n {\n icon: 'code',\n text: tooltip,\n onMouseDown: () => {\n modalMethods.current = create(Modal, modalProps);\n },\n active: isPegaRefActive,\n shortcut: {\n pattern: 'meta+191',\n description: tooltip,\n command: onInsertField\n }\n }\n ]}\n onInit={setEditor}\n onChange={onEditorChange}\n onBlur={() => {\n onBlur?.();\n hidePopover();\n }}\n onKeyDown={onKeyDown}\n >\n {fieldSelectionPopover}\n </Editor>\n </>\n );\n }\n );\n\nexport default DynamicContentEditor;\n"]}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { EditorProps } from '@pega/cosmos-react-rte';
|
|
3
|
+
import { MenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';
|
|
3
4
|
export declare type ItemType = {
|
|
4
5
|
id: string;
|
|
5
6
|
text: string;
|
|
6
7
|
};
|
|
7
8
|
export interface DynamicContentEditorProps extends EditorProps {
|
|
9
|
+
/** Insert field form */
|
|
8
10
|
form: {
|
|
9
11
|
onSubmit: (insertField: (selectedField: ItemType) => void) => void;
|
|
10
12
|
dynamicContentPicker: ReactNode;
|
|
11
13
|
};
|
|
12
14
|
onActiveFieldChange: (field: ItemType) => void;
|
|
15
|
+
/** Property selection array */
|
|
16
|
+
fieldItems?: MenuItemProps[];
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
onBlur?: () => void;
|
|
13
19
|
}
|
|
14
20
|
export interface DynamicContentEditorContextProps extends DynamicContentEditorProps {
|
|
15
21
|
updateProperties?: (selectedfield: ItemType) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicContentEditor.types.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DynamicContentEditor.types.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wDAAwD,CAAC;AAEvF,oBAAY,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,yBAA0B,SAAQ,WAAW;IAC5D,wBAAwB;IACxB,IAAI,EAAE;QACJ,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC,aAAa,EAAE,QAAQ,KAAK,IAAI,KAAK,IAAI,CAAC;QACnE,oBAAoB,EAAE,SAAS,CAAC;KACjC,CAAC;IACF,mBAAmB,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC/C,+BAA+B;IAC/B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IACjF,gBAAgB,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicContentEditor.types.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactNode } from 'react';\n\nimport { EditorProps } from '@pega/cosmos-react-rte';\n\nexport type ItemType = {\n id: string;\n text: string;\n};\n\nexport interface DynamicContentEditorProps extends EditorProps {\n form: {\n onSubmit: (insertField: (selectedField: ItemType) => void) => void;\n dynamicContentPicker: ReactNode;\n };\n onActiveFieldChange: (field: ItemType) => void;\n}\n\nexport interface DynamicContentEditorContextProps extends DynamicContentEditorProps {\n updateProperties?: (selectedfield: ItemType) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DynamicContentEditor.types.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactNode } from 'react';\n\nimport { EditorProps } from '@pega/cosmos-react-rte';\nimport { MenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';\n\nexport type ItemType = {\n id: string;\n text: string;\n};\n\nexport interface DynamicContentEditorProps extends EditorProps {\n /** Insert field form */\n form: {\n onSubmit: (insertField: (selectedField: ItemType) => void) => void;\n dynamicContentPicker: ReactNode;\n };\n onActiveFieldChange: (field: ItemType) => void;\n /** Property selection array */\n fieldItems?: MenuItemProps[];\n defaultValue?: string;\n onBlur?: () => void;\n}\n\nexport interface DynamicContentEditorContextProps extends DynamicContentEditorProps {\n updateProperties?: (selectedfield: ItemType) => void;\n}\n"]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { FC, MouseEvent } from 'react';
|
|
2
2
|
import { RendererNodeProps } from './Renderer/Renderer.types';
|
|
3
|
-
export declare const StyledDot: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").IconProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
3
|
+
export declare const StyledDot: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").IconProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
4
|
+
highlight: boolean;
|
|
5
|
+
}, never>;
|
|
4
6
|
export declare const StyledPlus: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").IconProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
5
7
|
export declare const StyledWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
8
|
export declare const StyledButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
-
interface AddBtnProps {
|
|
8
|
-
addNodeHandler: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
9
|
-
}
|
|
10
9
|
export interface AddNodeProps extends RendererNodeProps {
|
|
11
10
|
onClick?: (ev: Event) => void;
|
|
11
|
+
addNodeHandler: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
12
|
+
highlight?: boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare const StyledConnectorLabel: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export declare const StyledConnectorLabel: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
15
|
+
highlight: boolean;
|
|
16
|
+
}, never>;
|
|
17
|
+
export declare const AddButton: FC<Pick<AddNodeProps, 'addNodeHandler' | 'highlight'>>;
|
|
16
18
|
//# sourceMappingURL=AddNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNode.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"AddNode.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,eAAO,MAAM,SAAS;eAA6B,OAAO;SAWxD,CAAC;AAIH,eAAO,MAAM,UAAU,mOAAiB,CAAC;AACzC,eAAO,MAAM,aAAa,yGAUxB,CAAC;AAIH,eAAO,MAAM,YAAY,qOAsBvB,CAAC;AAIH,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,cAAc,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB;eAA6B,OAAO;SAQnE,CAAC;AAIH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,WAAW,CAAC,CAc5E,CAAC"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { Button, defaultThemeProp, Flex, Icon, useI18n, StyledTooltip, Text } from '@pega/cosmos-react-core';
|
|
4
|
-
export const StyledDot = styled(Icon)(({ theme }) => {
|
|
4
|
+
export const StyledDot = styled(Icon)(({ theme, highlight }) => {
|
|
5
5
|
return css `
|
|
6
6
|
position: absolute;
|
|
7
7
|
color: ${theme.base.colors.slate.dark};
|
|
8
|
+
${highlight &&
|
|
9
|
+
css `
|
|
10
|
+
{
|
|
11
|
+
color: ${theme.base.colors.red.dark};
|
|
12
|
+
}
|
|
13
|
+
`}
|
|
8
14
|
`;
|
|
9
15
|
});
|
|
10
16
|
StyledDot.defaultProps = defaultThemeProp;
|
|
@@ -55,8 +61,8 @@ export const StyledConnectorLabel = styled(Text)(({ theme }) => {
|
|
|
55
61
|
`;
|
|
56
62
|
});
|
|
57
63
|
StyledConnectorLabel.defaultProps = defaultThemeProp;
|
|
58
|
-
export const AddButton = ({ addNodeHandler }) => {
|
|
64
|
+
export const AddButton = ({ addNodeHandler, highlight }) => {
|
|
59
65
|
const t = useI18n();
|
|
60
|
-
return (_jsx(Flex, { container: { justify: 'center' }, as: StyledWrapper, children: _jsxs(StyledButton, { label: t('add_node'), icon: true, onClick: addNodeHandler, children: [_jsx(StyledDot, { name: 'circle-solid' }, void 0), _jsx(StyledPlus, { name: 'plus' }, void 0)] }, void 0) }, void 0));
|
|
66
|
+
return (_jsx(Flex, { container: { justify: 'center' }, as: StyledWrapper, children: _jsxs(StyledButton, { label: t('add_node'), icon: true, onClick: addNodeHandler, children: [_jsx(StyledDot, { name: 'circle-solid', highlight: highlight }, void 0), _jsx(StyledPlus, { name: 'plus' }, void 0)] }, void 0) }, void 0));
|
|
61
67
|
};
|
|
62
68
|
//# sourceMappingURL=AddNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNode.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACL,MAAM,yBAAyB,CAAC;AAIjC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"AddNode.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGh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C,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAyB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACrF,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;kBAC9B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;aACjC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;0BAEV,KAAK,CAAC,IAAI,CAAC,OAAO;GACzC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,SAAS,GAA2D,CAAC,EAChF,cAAc,EACd,SAAS,EACV,EAAE,EAAE;IACH,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,aAAa,YACvD,MAAC,YAAY,IAAC,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,QAAC,OAAO,EAAE,cAAc,aAC9D,KAAC,SAAS,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAE,SAAS,WAAI,EACvD,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,WAAG,YACb,WACV,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { FC, MouseEvent } from 'react';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n Icon,\n useI18n,\n StyledTooltip,\n Text\n} from '@pega/cosmos-react-core';\n\nimport { RendererNodeProps } from './Renderer/Renderer.types';\n\nexport const StyledDot = styled(Icon)<{ highlight: boolean }>(({ theme, highlight }) => {\n return css`\n position: absolute;\n color: ${theme.base.colors.slate.dark};\n ${highlight &&\n css`\n {\n color: ${theme.base.colors.red.dark};\n }\n `}\n `;\n});\n\nStyledDot.defaultProps = defaultThemeProp;\n\nexport const StyledPlus = styled(Icon)``;\nexport const StyledWrapper = styled.div(({ theme }) => {\n return css`\n margin-block-start: ${theme.base.spacing};\n ${StyledTooltip} {\n ${css`\n min-width: 12ch;\n text-align: center;\n `}\n }\n `;\n});\n\nStyledWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledButton = styled(Button)(({ theme }) => {\n return css`\n top: -0.25rem;\n border: 0;\n background: transparent;\n color: ${theme.base.colors.black};\n ${StyledPlus} {\n opacity: 0;\n }\n &:hover,\n &:active,\n &:focus {\n opacity: 1;\n background: ${theme.base.colors.white};\n ${StyledDot} {\n opacity: 0;\n }\n ${StyledPlus} {\n opacity: 1;\n }\n }\n `;\n});\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport interface AddNodeProps extends RendererNodeProps {\n onClick?: (ev: Event) => void;\n addNodeHandler: (e: MouseEvent<HTMLButtonElement>) => void;\n highlight?: boolean;\n}\n\nexport const StyledConnectorLabel = styled(Text)<{ highlight: boolean }>(({ theme }) => {\n return css`\n border-radius: ${theme.base['border-radius']};\n background: ${theme.base.colors.slate.dark};\n color: ${theme.base.colors.white};\n text-align: center;\n padding: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledConnectorLabel.defaultProps = defaultThemeProp;\n\nexport const AddButton: FC<Pick<AddNodeProps, 'addNodeHandler' | 'highlight'>> = ({\n addNodeHandler,\n highlight\n}) => {\n const t = useI18n();\n\n return (\n <Flex container={{ justify: 'center' }} as={StyledWrapper}>\n <StyledButton label={t('add_node')} icon onClick={addNodeHandler}>\n <StyledDot name='circle-solid' highlight={highlight} />\n <StyledPlus name='plus' />\n </StyledButton>\n </Flex>\n );\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RendererConnectorProps } from './Renderer/Renderer.types';
|
|
3
|
+
import { PlaceHolderConnector } from './Utils/addNodeUtils';
|
|
4
|
+
declare type ConnectorProps = Pick<RendererConnectorProps, 'id' | 'data' | 'labelLayout' | 'highlight'> & Partial<Pick<PlaceHolderConnector, 'realConnectors'>>;
|
|
5
|
+
declare const Connector: ({ id, labelLayout, highlight, data, realConnectors }: ConnectorProps) => JSX.Element;
|
|
6
|
+
export default Connector;
|
|
7
|
+
//# sourceMappingURL=Connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAwB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAwB5D,aAAK,cAAc,GAAG,IAAI,CAAC,sBAAsB,EAAE,IAAI,GAAG,MAAM,GAAG,aAAa,GAAG,WAAW,CAAC,GAC7F,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAExD,QAAA,MAAM,SAAS,yDAA0D,cAAc,gBAuBtF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { defaultThemeProp, Flex, Text } from '@pega/cosmos-react-core';
|
|
4
|
+
import { AddButton } from './AddNode';
|
|
5
|
+
const StyledLabel = styled(Text)(({ theme, highlight }) => {
|
|
6
|
+
return css `
|
|
7
|
+
border-radius: ${theme.base['border-radius']};
|
|
8
|
+
background: ${theme.base.colors.slate.dark};
|
|
9
|
+
${highlight &&
|
|
10
|
+
css `
|
|
11
|
+
{
|
|
12
|
+
background-color: ${theme.base.colors.red.dark};
|
|
13
|
+
}
|
|
14
|
+
`}
|
|
15
|
+
color: ${theme.base.colors.white};
|
|
16
|
+
text-align: center;
|
|
17
|
+
padding: calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
max-width: 32ch;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
`;
|
|
23
|
+
});
|
|
24
|
+
StyledLabel.defaultProps = defaultThemeProp;
|
|
25
|
+
const Connector = ({ id, labelLayout, highlight, data, realConnectors }) => {
|
|
26
|
+
const refId = realConnectors || id;
|
|
27
|
+
const metaData = {
|
|
28
|
+
refType: 'connector',
|
|
29
|
+
refId
|
|
30
|
+
};
|
|
31
|
+
return (_jsxs(_Fragment, { children: [labelLayout?.value && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledLabel, { highlight: highlight, children: labelLayout.value }, void 0) }, void 0)), _jsx(AddButton, { highlight: highlight, addNodeHandler: (e) => data?.onNodeCreate(e.currentTarget, metaData) }, void 0)] }, void 0));
|
|
32
|
+
};
|
|
33
|
+
export default Connector;
|
|
34
|
+
//# sourceMappingURL=Connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAyB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IAChF,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;kBAC9B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;MACxC,SAAS;QACX,GAAG,CAAA;;4BAEqB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;;KAEjD;aACQ,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;0BAEV,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,OAAO;;;;;GAKhE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAK5C,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAkB,EAAE,EAAE;IACzF,MAAM,KAAK,GAAG,cAAc,IAAI,EAAE,CAAC;IAEnC,MAAM,QAAQ,GAAyB;QACrC,OAAO,EAAE,WAAW;QACpB,KAAK;KACN,CAAC;IAEF,OAAO,CACL,8BACG,WAAW,EAAE,KAAK,IAAI,CACrB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YACpC,KAAC,WAAW,IAAC,SAAS,EAAE,SAAS,YAAG,WAAW,CAAC,KAAK,WAAe,WAC/D,CACR,EACD,KAAC,SAAS,IACR,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,CAAC,CAAgC,EAAE,EAAE,CACnD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,WAE/C,YACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Flex, Text } from '@pega/cosmos-react-core';\n\nimport { AddButton } from './AddNode';\nimport { AddNodeHandlerParams, RendererConnectorProps } from './Renderer/Renderer.types';\nimport { PlaceHolderConnector } from './Utils/addNodeUtils';\n\nconst StyledLabel = styled(Text)<{ highlight: boolean }>(({ theme, highlight }) => {\n return css`\n border-radius: ${theme.base['border-radius']};\n background: ${theme.base.colors.slate.dark};\n ${highlight &&\n css`\n {\n background-color: ${theme.base.colors.red.dark};\n }\n `}\n color: ${theme.base.colors.white};\n text-align: center;\n padding: calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 32ch;\n white-space: nowrap;\n `;\n});\n\nStyledLabel.defaultProps = defaultThemeProp;\n\ntype ConnectorProps = Pick<RendererConnectorProps, 'id' | 'data' | 'labelLayout' | 'highlight'> &\n Partial<Pick<PlaceHolderConnector, 'realConnectors'>>;\n\nconst Connector = ({ id, labelLayout, highlight, data, realConnectors }: ConnectorProps) => {\n const refId = realConnectors || id;\n\n const metaData: AddNodeHandlerParams = {\n refType: 'connector',\n refId\n };\n\n return (\n <>\n {labelLayout?.value && (\n <Flex container={{ justify: 'center' }}>\n <StyledLabel highlight={highlight}>{labelLayout.value}</StyledLabel>\n </Flex>\n )}\n <AddButton\n highlight={highlight}\n addNodeHandler={(e: MouseEvent<HTMLButtonElement>) =>\n data?.onNodeCreate(e.currentTarget, metaData)\n }\n />\n </>\n );\n};\n\nexport default Connector;\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChangeEvent, Ref } from 'react';
|
|
2
|
+
import { PopoverProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { GraphData, ConnectorProps } from './Renderer/Utils/Graph';
|
|
4
|
+
import { GraphDataAsMap } from './Utils/deleteNodeUtils';
|
|
5
|
+
export interface DeleteNodeOutcome {
|
|
6
|
+
graphData: GraphData;
|
|
7
|
+
updates: {
|
|
8
|
+
connectors: ConnectorProps[];
|
|
9
|
+
};
|
|
10
|
+
deletes: GraphDataAsMap;
|
|
11
|
+
}
|
|
12
|
+
export interface DeleteNodePopoverProps {
|
|
13
|
+
show: boolean;
|
|
14
|
+
target: PopoverProps['target'];
|
|
15
|
+
flowGraphData: GraphData;
|
|
16
|
+
rendererGraphData: GraphData;
|
|
17
|
+
nodeId: string;
|
|
18
|
+
onChange?: (itemsToDelete: GraphDataAsMap, itemsToRetain: GraphDataAsMap | undefined, ev?: ChangeEvent) => void;
|
|
19
|
+
ref?: Ref<HTMLDivElement>;
|
|
20
|
+
onSubmit?: (outcome: DeleteNodeOutcome, ev: Event) => void;
|
|
21
|
+
onCancel?: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const StyledDeletePopover: import("styled-components").StyledComponent<(<Modifiers extends string = string>(props: PopoverProps<Modifiers> & import("@pega/cosmos-react-core").ForwardProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null), import("styled-components").DefaultTheme, {}, never>;
|
|
24
|
+
declare const DeletePopover: import("react").ForwardRefExoticComponent<Pick<DeleteNodePopoverProps, "show" | "target" | "onChange" | "onSubmit" | "onCancel" | "flowGraphData" | "rendererGraphData" | "nodeId"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
|
+
export default DeletePopover;
|
|
26
|
+
//# sourceMappingURL=DeletePopover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeletePopover.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeletePopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,WAAW,EAAyB,GAAG,EAAE,MAAM,OAAO,CAAC;AAG9F,OAAO,EASL,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAiB,SAAS,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAwB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE;QACP,UAAU,EAAE,cAAc,EAAE,CAAC;KAC9B,CAAC;IACF,OAAO,EAAE,cAAc,CAAC;CACzB;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC/B,aAAa,EAAE,SAAS,CAAC;IACzB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CACT,aAAa,EAAE,cAAc,EAC7B,aAAa,EAAE,cAAc,GAAG,SAAS,EACzC,EAAE,CAAC,EAAE,WAAW,KACb,IAAI,CAAC;IACV,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,mBAAmB,2TAE/B,CAAC;AAEF,QAAA,MAAM,aAAa,sOA+KlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|