@pega/cosmos-react-build 3.0.0-dev.2.0 → 3.0.0-dev.4.1

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.
Files changed (68) hide show
  1. package/lib/components/AppHeader/AppHeader.styles.d.ts +1 -0
  2. package/lib/components/AppHeader/AppHeader.styles.d.ts.map +1 -1
  3. package/lib/components/AppShell/AppShell.d.ts +1 -0
  4. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  5. package/lib/components/AppShell/AppShell.styles.d.ts +1 -0
  6. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  7. package/lib/components/AppShell/AppShellContext.d.ts +1 -0
  8. package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
  9. package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts +9 -0
  10. package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +1 -0
  11. package/lib/components/DynamicContentEditor/DynamicContentEditor.js +209 -0
  12. package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -0
  13. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +21 -0
  14. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +1 -0
  15. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js +2 -0
  16. package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js.map +1 -0
  17. package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts +4 -0
  18. package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts.map +1 -0
  19. package/lib/components/DynamicContentEditor/PegaCustomElement.js +23 -0
  20. package/lib/components/DynamicContentEditor/PegaCustomElement.js.map +1 -0
  21. package/lib/components/DynamicContentEditor/index.d.ts +3 -0
  22. package/lib/components/DynamicContentEditor/index.d.ts.map +1 -0
  23. package/lib/components/DynamicContentEditor/index.js +2 -0
  24. package/lib/components/DynamicContentEditor/index.js.map +1 -0
  25. package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts +1 -0
  26. package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -1
  27. package/lib/components/ObjectSelect/ObjectConfig.d.ts +18 -0
  28. package/lib/components/ObjectSelect/ObjectConfig.d.ts.map +1 -0
  29. package/lib/components/ObjectSelect/ObjectConfig.js +14 -0
  30. package/lib/components/ObjectSelect/ObjectConfig.js.map +1 -0
  31. package/lib/components/ObjectSelect/ObjectPicker.d.ts +10 -0
  32. package/lib/components/ObjectSelect/ObjectPicker.d.ts.map +1 -0
  33. package/lib/components/ObjectSelect/ObjectPicker.js +25 -0
  34. package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -0
  35. package/lib/components/ObjectSelect/ObjectSelect.d.ts +22 -0
  36. package/lib/components/ObjectSelect/ObjectSelect.d.ts.map +1 -0
  37. package/lib/components/ObjectSelect/ObjectSelect.js +20 -0
  38. package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -0
  39. package/lib/components/ObjectSelect/ObjectSummary.d.ts +21 -0
  40. package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -0
  41. package/lib/components/ObjectSelect/ObjectSummary.js +71 -0
  42. package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -0
  43. package/lib/components/ObjectSelect/index.d.ts +3 -0
  44. package/lib/components/ObjectSelect/index.d.ts.map +1 -0
  45. package/lib/components/ObjectSelect/index.js +2 -0
  46. package/lib/components/ObjectSelect/index.js.map +1 -0
  47. package/lib/components/Workbench/ConfigurationPanel.d.ts.map +1 -1
  48. package/lib/components/Workbench/ConfigurationPanel.js +2 -3
  49. package/lib/components/Workbench/ConfigurationPanel.js.map +1 -1
  50. package/lib/components/Workbench/Toolbar.d.ts +1 -5
  51. package/lib/components/Workbench/Toolbar.d.ts.map +1 -1
  52. package/lib/components/Workbench/Toolbar.js +8 -8
  53. package/lib/components/Workbench/Toolbar.js.map +1 -1
  54. package/lib/components/Workbench/Workbench.d.ts.map +1 -1
  55. package/lib/components/Workbench/Workbench.js +2 -3
  56. package/lib/components/Workbench/Workbench.js.map +1 -1
  57. package/lib/components/Workbench/Workbench.styles.d.ts +1 -1
  58. package/lib/components/Workbench/Workbench.styles.d.ts.map +1 -1
  59. package/lib/components/Workbench/Workbench.styles.js +12 -17
  60. package/lib/components/Workbench/Workbench.styles.js.map +1 -1
  61. package/lib/components/Workbench/Workbench.types.d.ts +0 -2
  62. package/lib/components/Workbench/Workbench.types.d.ts.map +1 -1
  63. package/lib/components/Workbench/Workbench.types.js.map +1 -1
  64. package/lib/index.d.ts +4 -0
  65. package/lib/index.d.ts.map +1 -1
  66. package/lib/index.js +4 -0
  67. package/lib/index.js.map +1 -1
  68. package/package.json +13 -12
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Avatar, Flex, Text, Tabs, Button } from '@pega/cosmos-react-core';
2
3
  export declare const StyledAppHeader: import("styled-components").StyledComponent<"header", import("styled-components").DefaultTheme, {}, never>;
3
4
  export declare const StyledTitle: typeof Text;
@@ -1 +1 @@
1
- {"version":3,"file":"AppHeader.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppHeader/AppHeader.styles.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EAEN,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACP,MAAM,yBAAyB,CAAC;AAIjC,eAAO,MAAM,eAAe,4GAQ1B,CAAC;AAIH,eAAO,MAAM,WAAW,EAAE,OAAO,IAU/B,CAAC;AAIH,eAAO,MAAM,oBAAoB,EAAE,OAAO,IAKxC,CAAC;AAIH,eAAO,MAAM,mBAAmB,EAAE,OAAO,IAcvC,CAAC;AAIH,eAAO,MAAM,iBAAiB,0QAM5B,CAAC;AAIH,eAAO,MAAM,UAAU,EAAE,OAAO,IAqB9B,CAAC;AAIH,eAAO,MAAM,oBAAoB,EAAE,OAAO,IAmBzC,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,OAAO,IAYzC,CAAC;AAIH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAExC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OAAO,MAQnC,CAAC"}
1
+ {"version":3,"file":"AppHeader.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppHeader/AppHeader.styles.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,MAAM,EAEN,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACP,MAAM,yBAAyB,CAAC;AAIjC,eAAO,MAAM,eAAe,4GAQ1B,CAAC;AAIH,eAAO,MAAM,WAAW,EAAE,OAAO,IAU/B,CAAC;AAIH,eAAO,MAAM,oBAAoB,EAAE,OAAO,IAKxC,CAAC;AAIH,eAAO,MAAM,mBAAmB,EAAE,OAAO,IAcvC,CAAC;AAIH,eAAO,MAAM,iBAAiB,0QAM5B,CAAC;AAIH,eAAO,MAAM,UAAU,EAAE,OAAO,IAqB9B,CAAC;AAIH,eAAO,MAAM,oBAAoB,EAAE,OAAO,IAmBzC,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,OAAO,IAYzC,CAAC;AAIH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAExC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OAAO,MAQnC,CAAC"}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { AppShellProps } from './AppShell.types';
2
3
  declare const AppShell: import("react").ForwardRefExoticComponent<Pick<AppShellProps, "main" | "children" | "navigation" | "appInfo" | "appHeader" | "utils" | "hideNav"> & import("react").RefAttributes<HTMLElement>>;
3
4
  export default AppShell;
@@ -1 +1 @@
1
- {"version":3,"file":"AppShell.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.tsx"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,kBAAkB,CAAC;AA+FhF,QAAA,MAAM,QAAQ,iMAkIb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"AppShell.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.tsx"],"names":[],"mappings":";AA8CA,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,kBAAkB,CAAC;AA+FhF,QAAA,MAAM,QAAQ,iMAkIb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const StyledNavToggle: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
2
3
  export declare const StyledHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
4
  export declare const StyledDrawerHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"AppShell.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.styles.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,eAAe,qOA4B1B,CAAC;AAIH,eAAO,MAAM,YAAY,yGAUvB,CAAC;AAIH,eAAO,MAAM,kBAAkB,yGAI7B,CAAC;AAIH,eAAO,MAAM,mBAAmB,mOAI9B,CAAC;AAIH,eAAO,MAAM,cAAc,mOAOzB,CAAC;AAIH,eAAO,MAAM,WAAW;iBAA6B,OAAO;SA8B1D,CAAC;AAIH,eAAO,MAAM,cAAc,wGA2BzB,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGAO3B,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGAmB3B,CAAC;AAIH,eAAO,MAAM,UAAU,0GAOrB,CAAC;AAIH,eAAO,MAAM,mBAAmB,yGAQ9B,CAAC;AAIH,eAAO,MAAM,qBAAqB;aAAyB,MAAM;SAY/D,CAAC;AAIH,eAAO,MAAM,uBAAuB,qOAYlC,CAAC;AAIH,eAAO,MAAM,cAAc,yGAUzB,CAAC;AAIH,eAAO,MAAM,SAAS,yGAsHpB,CAAC"}
1
+ {"version":3,"file":"AppShell.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShell.styles.ts"],"names":[],"mappings":";AA0BA,eAAO,MAAM,eAAe,qOA4B1B,CAAC;AAIH,eAAO,MAAM,YAAY,yGAUvB,CAAC;AAIH,eAAO,MAAM,kBAAkB,yGAI7B,CAAC;AAIH,eAAO,MAAM,mBAAmB,mOAI9B,CAAC;AAIH,eAAO,MAAM,cAAc,mOAOzB,CAAC;AAIH,eAAO,MAAM,WAAW;iBAA6B,OAAO;SA8B1D,CAAC;AAIH,eAAO,MAAM,cAAc,wGA2BzB,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGAO3B,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGAmB3B,CAAC;AAIH,eAAO,MAAM,UAAU,0GAOrB,CAAC;AAIH,eAAO,MAAM,mBAAmB,yGAQ9B,CAAC;AAIH,eAAO,MAAM,qBAAqB;aAAyB,MAAM;SAY/D,CAAC;AAIH,eAAO,MAAM,uBAAuB,qOAYlC,CAAC;AAIH,eAAO,MAAM,cAAc,yGAUzB,CAAC;AAIH,eAAO,MAAM,SAAS,yGAsHpB,CAAC"}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { AppShellContextValue } from './AppShell.types';
2
3
  declare const AppShellContext: import("react").Context<AppShellContextValue>;
3
4
  export default AppShellContext;
@@ -1 +1 @@
1
- {"version":3,"file":"AppShellContext.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,QAAA,MAAM,eAAe,+CAMnB,CAAC;AAEH,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"AppShellContext.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellContext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,QAAA,MAAM,eAAe,+CAMnB,CAAC;AAEH,eAAe,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
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>;
7
+ declare const DynamicContentEditor: FunctionComponent<DynamicContentEditorProps & ForwardProps>;
8
+ export default DynamicContentEditor;
9
+ //# sourceMappingURL=DynamicContentEditor.d.ts.map
@@ -0,0 +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,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,CAyRnF,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,209 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useContext, useRef, useEffect, useState } from 'react';
3
+ import styled from 'styled-components';
4
+ import { Editor } from '@pega/cosmos-react-rte';
5
+ import { Button, defaultThemeProp, Menu, Modal, ModalManagerContext, Popover, StyledPopover, useConsolidatedRef, useI18n } from '@pega/cosmos-react-core';
6
+ import { getKeyCommand } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/Toolbar/utils';
7
+ import PegaCustomElement from './PegaCustomElement';
8
+ const StyledDynamicContentEditor = styled.div ``;
9
+ export const StyledSearchPopover = styled(StyledPopover) `
10
+ min-width: 20rem;
11
+ `;
12
+ StyledDynamicContentEditor.defaultProps = defaultThemeProp;
13
+ const DynamicContentEditor = forwardRef(({ form: { dynamicContentPicker, onSubmit }, onActiveFieldChange, label, toolbar, fieldItems, ...restProps }, ref) => {
14
+ const { create } = useContext(ModalManagerContext);
15
+ const t = useI18n();
16
+ const modalMethods = useRef();
17
+ const [editor, setEditor] = useState();
18
+ const [bookmark, setBookmark] = useState();
19
+ const [fieldMenu, setFieldMenu] = useState({ items: fieldItems || [] });
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);
34
+ const editorRef = useConsolidatedRef(ref);
35
+ const tooltip = getKeyCommand(navigator.appVersion.includes('Mac'), ({ ctrl }) => `${t('rte_insert_field')} (${ctrl}/)`);
36
+ const insertField = (field) => {
37
+ if (!editor)
38
+ return;
39
+ const fieldContent = `<pega-reference role="button" contenteditable="false" data-rule-type='field' data-rule-id=${field.id}>${field.text}</pega-reference>`;
40
+ if (bookmark) {
41
+ editor.selection.moveToBookmark(bookmark);
42
+ editor.selection.setContent(fieldContent);
43
+ }
44
+ else {
45
+ editor.insertContent(fieldContent);
46
+ }
47
+ modalMethods.current?.dismiss();
48
+ };
49
+ const modalProps = {
50
+ children: dynamicContentPicker,
51
+ heading: t('rte_insert_field'),
52
+ actions: (_jsxs(_Fragment, { children: [_jsx(Button, { variant: 'secondary', onClick: () => modalMethods.current?.dismiss(), children: t('cancel') }, void 0), _jsx(Button, { variant: 'primary', onClick: () => onSubmit(insertField), children: t('submit') }, void 0)] }, void 0)),
53
+ center: true,
54
+ onAfterClose: () => {
55
+ setBookmark(undefined);
56
+ setCurrentElementContent('');
57
+ onActiveFieldChange({ id: '', text: '' });
58
+ },
59
+ onBeforeOpen: () => {
60
+ if (currentElementContent)
61
+ onActiveFieldChange({ id: currentElementContent, text: currentElementContent });
62
+ }
63
+ };
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
+ };
108
+ const updateBookmarkAndCurrentElement = (editorSelection) => {
109
+ const targetEl = editorSelection.getNode();
110
+ const fieldValue = targetEl.getAttribute('data-rule-id');
111
+ setBookmark(editorSelection.getBookmark());
112
+ setCurrentElementContent(fieldValue);
113
+ };
114
+ const handleElementClick = ({ target }) => {
115
+ if (editor && target instanceof HTMLElement && target.tagName === 'PEGA-REFERENCE') {
116
+ updateBookmarkAndCurrentElement(editor.selection);
117
+ }
118
+ hidePopover();
119
+ };
120
+ const onInsertField = (incEditor) => {
121
+ const targetEl = incEditor.selection.getNode();
122
+ if (targetEl.tagName === 'PEGA-REFERENCE') {
123
+ updateBookmarkAndCurrentElement(incEditor.selection);
124
+ }
125
+ else {
126
+ modalMethods.current = create(Modal, modalProps);
127
+ }
128
+ };
129
+ const isPegaRefActive = (incEditor) => {
130
+ const targetEl = incEditor.selection.getNode();
131
+ return targetEl.tagName === 'PEGA-REFERENCE';
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]);
142
+ useEffect(() => {
143
+ editorRef.current?.element?.addEventListener('click', handleElementClick);
144
+ return () => {
145
+ editorRef.current?.element?.removeEventListener('click', handleElementClick);
146
+ };
147
+ }, [editor, editorRef.current]);
148
+ useEffect(() => {
149
+ if (modalMethods.current) {
150
+ modalMethods.current.update(modalProps);
151
+ }
152
+ }, [modalProps]);
153
+ const onEditorChange = (formEditor) => {
154
+ if (formEditor) {
155
+ const targetEl = formEditor?.selection?.getBoundingClientRect();
156
+ const { left = 0, top = 0 } = targetEl;
157
+ setCurrentCursorPosition({
158
+ ...formEditor?.selection?.getBoundingClientRect(),
159
+ x: left,
160
+ y: top,
161
+ toJSON: () => { }
162
+ });
163
+ }
164
+ if (formEditor?.selection?.isCollapsed()) {
165
+ // get the full line string
166
+ const selectedRange = formEditor.selection.getRng();
167
+ const endOffset = selectedRange.endOffset;
168
+ const stringToSearch = selectedRange.commonAncestorContainer.nodeValue?.slice(0, endOffset);
169
+ const fieldString = stringToSearch?.split(' ')[stringToSearch?.split(' ').length - 1];
170
+ if (fieldString?.startsWith('@') &&
171
+ fieldString.indexOf('@') === fieldString.lastIndexOf('@')) {
172
+ filterFieldMenu(fieldString.slice(1));
173
+ }
174
+ else
175
+ setShowFieldsPopover(false);
176
+ }
177
+ };
178
+ const onKeyDown = event => {
179
+ if ((event?.key === 'Enter' || event?.key === 'ArrowLeft' || event?.key === 'ArrowRight') &&
180
+ !!fieldPopoverRef.current) {
181
+ event?.preventDefault();
182
+ }
183
+ if (event?.key === 'Escape' && !!fieldPopoverRef.current) {
184
+ hidePopover();
185
+ }
186
+ };
187
+ return (_jsx(_Fragment, { children: _jsx(Editor, { ref: editorRef, ...restProps, label: label, toolbar: toolbar, customComponents: [
188
+ {
189
+ customElement: PegaCustomElement,
190
+ name: 'pega-reference'
191
+ }
192
+ ], customActions: [
193
+ {
194
+ icon: 'code',
195
+ text: tooltip,
196
+ onMouseDown: () => {
197
+ modalMethods.current = create(Modal, modalProps);
198
+ },
199
+ active: isPegaRefActive,
200
+ shortcut: {
201
+ pattern: 'meta+191',
202
+ description: tooltip,
203
+ command: onInsertField
204
+ }
205
+ }
206
+ ], onInit: initializedEditor => setEditor(initializedEditor), onChange: onEditorChange, onBlur: hidePopover, onKeyDown: onKeyDown, children: fieldSelectionPopover }, void 0) }, void 0));
207
+ });
208
+ export default DynamicContentEditor;
209
+ //# sourceMappingURL=DynamicContentEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicContentEditor.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/DynamicContentEditor.tsx"],"names":[],"mappings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,\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 ...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 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={initializedEditor => setEditor(initializedEditor)}\n onChange={onEditorChange}\n onBlur={hidePopover}\n onKeyDown={onKeyDown}\n >\n {fieldSelectionPopover}\n </Editor>\n </>\n );\n }\n );\n\nexport default DynamicContentEditor;\n"]}
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+ import { EditorProps } from '@pega/cosmos-react-rte';
3
+ import { MenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';
4
+ export declare type ItemType = {
5
+ id: string;
6
+ text: string;
7
+ };
8
+ export interface DynamicContentEditorProps extends EditorProps {
9
+ /** Insert field form */
10
+ form: {
11
+ onSubmit: (insertField: (selectedField: ItemType) => void) => void;
12
+ dynamicContentPicker: ReactNode;
13
+ };
14
+ onActiveFieldChange: (field: ItemType) => void;
15
+ /** Property selection array */
16
+ fieldItems?: MenuItemProps[];
17
+ }
18
+ export interface DynamicContentEditorContextProps extends DynamicContentEditorProps {
19
+ updateProperties?: (selectedfield: ItemType) => void;
20
+ }
21
+ //# sourceMappingURL=DynamicContentEditor.types.d.ts.map
@@ -0,0 +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;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;CAC9B;AAED,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IACjF,gBAAgB,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=DynamicContentEditor.types.js.map
@@ -0,0 +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';\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}\n\nexport interface DynamicContentEditorContextProps extends DynamicContentEditorProps {\n updateProperties?: (selectedfield: ItemType) => void;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export default class PegaCustomElement extends HTMLElement {
2
+ connectedCallback(): void;
3
+ }
4
+ //# sourceMappingURL=PegaCustomElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PegaCustomElement.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/PegaCustomElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,iBAAiB;CAoBlB"}
@@ -0,0 +1,23 @@
1
+ export default class PegaCustomElement extends HTMLElement {
2
+ connectedCallback() {
3
+ const template = document.createElement('template');
4
+ template.innerHTML = `<style>
5
+ pega-reference {
6
+ color:#076bc9;
7
+ cursor:pointer;
8
+ }
9
+ pega-reference:hover{
10
+ text-decoration:underline;
11
+ }
12
+ pega-reference::before{
13
+ content: '['
14
+ }
15
+ pega-reference::after{
16
+ content: ']'
17
+ }
18
+ </style>`;
19
+ const temp = document.importNode(template.content, true);
20
+ this.append(temp);
21
+ }
22
+ }
23
+ //# sourceMappingURL=PegaCustomElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PegaCustomElement.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/PegaCustomElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,iBAAiB;QACf,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACpD,QAAQ,CAAC,SAAS,GAAG;;;;;;;;;;;;;;WAcd,CAAC;QACR,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;CACF","sourcesContent":["export default class PegaCustomElement extends HTMLElement {\n connectedCallback() {\n const template = document.createElement('template');\n template.innerHTML = `<style>\n pega-reference {\n color:#076bc9;\n cursor:pointer;\n }\n pega-reference:hover{\n text-decoration:underline;\n }\n pega-reference::before{\n content: '['\n }\n pega-reference::after{\n content: ']'\n }\n </style>`;\n const temp = document.importNode(template.content, true);\n this.append(temp);\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export { default } from './DynamicContentEditor';
2
+ export { DynamicContentEditorProps, ItemType } from './DynamicContentEditor.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './DynamicContentEditor';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DynamicContentEditor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { default } from './DynamicContentEditor';\nexport { DynamicContentEditorProps, ItemType } from './DynamicContentEditor.types';\n"]}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { NodeType } from './Node.types';
2
3
  export declare const StyledCircle: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
4
  export declare const StyledLabel: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").TextProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {
@@ -1 +1 @@
1
- {"version":3,"file":"NodeTemplate.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Node/NodeTemplate.styles.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,YAAY,yGAYvB,CAAC;AAIH,eAAO,MAAM,WAAW;cAA4B,QAAQ;SAW1D,CAAC;AAIH,eAAO,MAAM,UAAU,yGAWrB,CAAC;AAIH,eAAO,MAAM,gBAAgB,4GAQ3B,CAAC;AAIH,eAAO,MAAM,UAAU,mOAOrB,CAAC;AAIH,eAAO,MAAM,UAAU,mOAoBrB,CAAC;AAEH,eAAO,MAAM,gBAAgB,yOAO3B,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAa5B,CAAC;AAIH,eAAO,MAAM,oBAAoB,wGAEhC,CAAC;AAEF,eAAO,MAAM,wBAAwB,yGAMnC,CAAC;AAGH,eAAO,MAAM,sBAAsB,mOAQjC,CAAC"}
1
+ {"version":3,"file":"NodeTemplate.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Node/NodeTemplate.styles.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,YAAY,yGAYvB,CAAC;AAIH,eAAO,MAAM,WAAW;cAA4B,QAAQ;SAW1D,CAAC;AAIH,eAAO,MAAM,UAAU,yGAWrB,CAAC;AAIH,eAAO,MAAM,gBAAgB,4GAQ3B,CAAC;AAIH,eAAO,MAAM,UAAU,mOAOrB,CAAC;AAIH,eAAO,MAAM,UAAU,mOAoBrB,CAAC;AAEH,eAAO,MAAM,gBAAgB,yOAO3B,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAa5B,CAAC;AAIH,eAAO,MAAM,oBAAoB,wGAEhC,CAAC;AAEF,eAAO,MAAM,wBAAwB,yGAMnC,CAAC;AAGH,eAAO,MAAM,sBAAsB,mOAQjC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { ReactNode, FC, Ref } from 'react';
2
+ import { ForwardProps, Action } from '@pega/cosmos-react-core';
3
+ export interface ObjectConfigProps {
4
+ label: string;
5
+ heading: string;
6
+ primaryAction: Action;
7
+ secondaryAction: Action;
8
+ content?: ReactNode;
9
+ onBeforeOpen?: () => void;
10
+ onAfterClose?: (id?: string) => void;
11
+ ref?: Ref<HTMLDivElement>;
12
+ }
13
+ declare const ObjectConfig: FC<ObjectConfigProps & ForwardProps & {
14
+ disabled?: boolean;
15
+ dismissPopover: (id?: string) => void;
16
+ }>;
17
+ export default ObjectConfig;
18
+ //# sourceMappingURL=ObjectConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectConfig.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAc,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAsB,MAAM,EAAiB,MAAM,yBAAyB,CAAC;AAElG,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CACpB,iBAAiB,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAqCjG,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Flex, Icon, Text, useI18n } from '@pega/cosmos-react-core';
3
+ const ObjectConfig = ({ heading, content, primaryAction, secondaryAction, disabled, dismissPopover }) => {
4
+ const t = useI18n();
5
+ return (_jsxs(Flex, { container: { direction: 'column', pad: 2, gap: 2 }, children: [_jsxs(Flex, { container: { justify: 'between', alignItems: 'center' }, children: [_jsx(Text, { variant: 'h3', children: heading }, void 0), _jsx(Button, { icon: true, variant: 'simple', label: t('close'), onClick: () => dismissPopover(), children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)] }, void 0), content, _jsxs(Flex, { container: { justify: 'between' }, children: [_jsx(Button, { variant: 'secondary', disabled: disabled, onClick: (e) => {
6
+ secondaryAction.onClick?.(secondaryAction.id, e);
7
+ dismissPopover(secondaryAction.id);
8
+ }, children: secondaryAction.text }, void 0), _jsx(Button, { variant: 'primary', disabled: disabled, onClick: (e) => {
9
+ primaryAction.onClick?.(primaryAction.id, e);
10
+ dismissPopover(primaryAction.id);
11
+ }, children: primaryAction.text }, void 0)] }, void 0)] }, void 0));
12
+ };
13
+ export default ObjectConfig;
14
+ //# sourceMappingURL=ObjectConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectConfig.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectConfig.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAgB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAU,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAalG,MAAM,YAAY,GAEd,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,EAAE;IACrF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,aACtD,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,aAC3D,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,WAAQ,EACnC,KAAC,MAAM,IAAC,IAAI,QAAC,OAAO,EAAC,QAAQ,EAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,YAC9E,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,WAAG,WACd,YACJ,EACN,OAAO,EACR,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,aACrC,KAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC5C,eAAe,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;4BACjD,cAAc,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;wBACrC,CAAC,YAEA,eAAe,CAAC,IAAI,WACd,EACT,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC5C,aAAa,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;4BAC7C,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;wBACnC,CAAC,YAEA,aAAa,CAAC,IAAI,WACZ,YACJ,YACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { ReactNode, FC, Ref, MouseEvent } from 'react';\n\nimport { ForwardProps, Button, Flex, Icon, Action, Text, useI18n } from '@pega/cosmos-react-core';\n\nexport interface ObjectConfigProps {\n label: string;\n heading: string;\n primaryAction: Action;\n secondaryAction: Action;\n content?: ReactNode;\n onBeforeOpen?: () => void;\n onAfterClose?: (id?: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectConfig: FC<\n ObjectConfigProps & ForwardProps & { disabled?: boolean; dismissPopover: (id?: string) => void }\n> = ({ heading, content, primaryAction, secondaryAction, disabled, dismissPopover }) => {\n const t = useI18n();\n\n return (\n <Flex container={{ direction: 'column', pad: 2, gap: 2 }}>\n <Flex container={{ justify: 'between', alignItems: 'center' }}>\n <Text variant='h3'>{heading}</Text>\n <Button icon variant='simple' label={t('close')} onClick={() => dismissPopover()}>\n <Icon name='times' />\n </Button>\n </Flex>\n {content}\n <Flex container={{ justify: 'between' }}>\n <Button\n variant='secondary'\n disabled={disabled}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n secondaryAction.onClick?.(secondaryAction.id, e);\n dismissPopover(secondaryAction.id);\n }}\n >\n {secondaryAction.text}\n </Button>\n <Button\n variant='primary'\n disabled={disabled}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n primaryAction.onClick?.(primaryAction.id, e);\n dismissPopover(primaryAction.id);\n }}\n >\n {primaryAction.text}\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default ObjectConfig;\n"]}
@@ -0,0 +1,10 @@
1
+ import { FC, Ref } from 'react';
2
+ import { BaseProps, ForwardProps, MenuProps, MenuItemProps, ComboBoxProps, NoChildrenProp } from '@pega/cosmos-react-core';
3
+ interface ObjectPickerProps extends BaseProps, NoChildrenProp, Pick<ComboBoxProps, 'id' | 'label' | 'labelHidden' | 'required' | 'disabled' | 'readOnly' | 'name' | 'status' | 'info' | 'placeholder'> {
4
+ items: MenuProps['items'];
5
+ onSelect: (id: MenuItemProps['id']) => void;
6
+ ref?: Ref<HTMLDivElement>;
7
+ }
8
+ declare const ObjectPicker: FC<ObjectPickerProps & ForwardProps>;
9
+ export default ObjectPicker;
10
+ //# sourceMappingURL=ObjectPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAkC,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EACL,SAAS,EAGT,YAAY,EACZ,SAAS,EACT,aAAa,EAEb,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,UAAU,iBACR,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CACF,aAAa,EACX,IAAI,GACJ,OAAO,GACP,aAAa,GACb,UAAU,GACV,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,MAAM,GACN,aAAa,CAChB;IACH,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,QAAQ,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC5C,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAkCtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useMemo } from 'react';
3
+ import { ComboBox, menuHelpers, createStringMatcher } from '@pega/cosmos-react-core';
4
+ const ObjectPicker = forwardRef(({ items, onSelect, ...restProps }, ref) => {
5
+ const [filterValue, setFilterValue] = useState('');
6
+ const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;
7
+ const itemsToRender = useMemo(() => {
8
+ const newItems = filterValue
9
+ ? menuHelpers.flatten(items).filter(({ primary }) => {
10
+ return filterRegex?.test(primary);
11
+ })
12
+ : items;
13
+ return menuHelpers.mapTree(newItems, item => ({
14
+ ...item,
15
+ selected: item.items ? undefined : !!item.selected
16
+ }));
17
+ }, [filterValue, items]);
18
+ return (_jsx(ComboBox, { ...restProps, ref: ref, mode: 'single-select', value: filterValue, onChange: (e) => setFilterValue(e.target.value), onBlur: () => setFilterValue(''), menu: {
19
+ items: itemsToRender,
20
+ onItemClick: onSelect,
21
+ accent: filterRegex
22
+ } }, void 0));
23
+ });
24
+ export default ObjectPicker;
25
+ //# sourceMappingURL=ObjectPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAM,QAAQ,EAAE,OAAO,EAAoB,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,QAAQ,EACR,WAAW,EAIX,mBAAmB,EAGpB,MAAM,yBAAyB,CAAC;AAuBjC,MAAM,Y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,WAAW;SACpB,WACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, FC, useState, useMemo, ChangeEvent, Ref } from 'react';\n\nimport {\n BaseProps,\n ComboBox,\n menuHelpers,\n ForwardProps,\n MenuProps,\n MenuItemProps,\n createStringMatcher,\n ComboBoxProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\ninterface ObjectPickerProps\n extends BaseProps,\n NoChildrenProp,\n Pick<\n ComboBoxProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'name'\n | 'status'\n | 'info'\n | 'placeholder'\n > {\n items: MenuProps['items'];\n onSelect: (id: MenuItemProps['id']) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectPicker: FC<ObjectPickerProps & ForwardProps> = forwardRef(\n ({ items, onSelect, ...restProps }, ref: ObjectPickerProps['ref']) => {\n const [filterValue, setFilterValue] = useState('');\n const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return filterRegex?.test(primary);\n })\n : items;\n\n return menuHelpers.mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }, [filterValue, items]);\n\n return (\n <ComboBox\n {...restProps}\n ref={ref}\n mode='single-select'\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setFilterValue(e.target.value)}\n onBlur={() => setFilterValue('')}\n menu={{\n items: itemsToRender,\n onItemClick: onSelect,\n accent: filterRegex\n }}\n />\n );\n }\n);\n\nexport default ObjectPicker;\n"]}
@@ -0,0 +1,22 @@
1
+ import { FunctionComponent, Ref } from 'react';
2
+ import { BaseProps, ForwardProps, FormControlProps, MenuItemProps, NoChildrenProp, MenuProps } from '@pega/cosmos-react-core';
3
+ import { ObjectSummaryProps } from './ObjectSummary';
4
+ export interface ObjectSelectProps extends BaseProps, NoChildrenProp, Omit<FormControlProps, 'value'> {
5
+ /** An array of MenuItemProps to be shown in the ObjectPicker menu. */
6
+ items: MenuProps['items'];
7
+ /** The value for the ObjectSummary */
8
+ value?: ObjectSummaryProps['value'];
9
+ /** Props for configuration popover */
10
+ configuration?: ObjectSummaryProps['configuration'];
11
+ /** Callback fired when a new item is selected and on clearing the selected item. */
12
+ onChange: (id: MenuItemProps['id']) => void;
13
+ /** Callback fired when the preview in the ObjectSummary link is clicked. */
14
+ onPreview?: (id: MenuItemProps['id'], e: {
15
+ href: string;
16
+ }) => void;
17
+ /** Ref placed on the element. */
18
+ ref?: Ref<HTMLDivElement>;
19
+ }
20
+ declare const ObjectSelect: FunctionComponent<ObjectSelectProps & ForwardProps>;
21
+ export default ObjectSelect;
22
+ //# sourceMappingURL=ObjectSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectSelect.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,GAAG,EAAU,MAAM,OAAO,CAAC;AAEnE,OAAO,EACL,SAAS,EACT,YAAY,EAEZ,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,SAAS,EACV,MAAM,yBAAyB,CAAC;AAGjC,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,WAAW,iBACf,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACjC,sEAAsE;IACtE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,sCAAsC;IACtC,KAAK,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACpC,sCAAsC;IACtC,aAAa,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACpD,oFAAoF;IACpF,QAAQ,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC5C,4EAA4E;IAC5E,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,iCAAiC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CAwCrE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useRef } from 'react';
3
+ import { useAfterInitialEffect } from '@pega/cosmos-react-core';
4
+ import ObjectPicker from './ObjectPicker';
5
+ import ObjectSummary from './ObjectSummary';
6
+ const ObjectSelect = forwardRef(({ items, value, configuration, disabled, onChange, onPreview, ...restProps }, ref) => {
7
+ const objectPickerRef = useRef(null);
8
+ const objectSummaryRef = useRef(null);
9
+ useAfterInitialEffect(() => {
10
+ if (disabled)
11
+ return;
12
+ const element = value
13
+ ? objectSummaryRef.current?.querySelector('a')
14
+ : objectPickerRef.current?.querySelector('input');
15
+ element?.focus();
16
+ }, [value, disabled]);
17
+ return (_jsx("div", { ref: ref, children: value ? (_jsx(ObjectSummary, { ...restProps, value: value, disabled: disabled, onDelete: () => onChange(''), ref: objectSummaryRef, configuration: configuration, onPreview: e => onPreview?.(value.id, e) }, void 0)) : (_jsx(ObjectPicker, { ...restProps, disabled: disabled, ref: objectPickerRef, items: items, onSelect: onChange }, void 0)) }, void 0));
18
+ });
19
+ export default ObjectSelect;
20
+ //# sourceMappingURL=ObjectSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA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B,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,WAClB,CACH,WACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, useRef } from 'react';\n\nimport {\n BaseProps,\n ForwardProps,\n useAfterInitialEffect,\n FormControlProps,\n MenuItemProps,\n NoChildrenProp,\n MenuProps\n} from '@pega/cosmos-react-core';\n\nimport ObjectPicker from './ObjectPicker';\nimport ObjectSummary, { ObjectSummaryProps } from './ObjectSummary';\n\nexport interface ObjectSelectProps\n extends BaseProps,\n NoChildrenProp,\n Omit<FormControlProps, 'value'> {\n /** An array of MenuItemProps to be shown in the ObjectPicker menu. */\n items: MenuProps['items'];\n /** The value for the ObjectSummary */\n value?: ObjectSummaryProps['value'];\n /** Props for configuration popover */\n configuration?: ObjectSummaryProps['configuration'];\n /** Callback fired when a new item is selected and on clearing the selected item. */\n onChange: (id: MenuItemProps['id']) => void;\n /** Callback fired when the preview in the ObjectSummary link is clicked. */\n onPreview?: (id: MenuItemProps['id'], e: { href: string }) => void;\n /** Ref placed on the element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectSelect: FunctionComponent<ObjectSelectProps & ForwardProps> = forwardRef(\n (\n { items, value, configuration, disabled, onChange, onPreview, ...restProps },\n ref: ObjectSelectProps['ref']\n ) => {\n const objectPickerRef = useRef<HTMLDivElement>(null);\n const objectSummaryRef = useRef<HTMLDivElement>(null);\n\n useAfterInitialEffect(() => {\n if (disabled) return;\n const element = value\n ? objectSummaryRef.current?.querySelector('a')\n : objectPickerRef.current?.querySelector('input');\n element?.focus();\n }, [value, disabled]);\n\n return (\n <div ref={ref}>\n {value ? (\n <ObjectSummary\n {...restProps}\n value={value}\n disabled={disabled}\n onDelete={() => onChange('')}\n ref={objectSummaryRef}\n configuration={configuration}\n onPreview={e => onPreview?.(value.id, e)}\n />\n ) : (\n <ObjectPicker\n {...restProps}\n disabled={disabled}\n ref={objectPickerRef}\n items={items}\n onSelect={onChange}\n />\n )}\n </div>\n );\n }\n);\n\nexport default ObjectSelect;\n"]}
@@ -0,0 +1,21 @@
1
+ import { FC, Ref, PropsWithoutRef } from 'react';
2
+ import { BaseProps, ForwardProps, FormControlProps, MenuItemProps } from '@pega/cosmos-react-core';
3
+ import { ObjectConfigProps } from './ObjectConfig';
4
+ interface ObjectSummaryValueProps {
5
+ id: MenuItemProps['id'];
6
+ primary: MenuItemProps['primary'];
7
+ href: string;
8
+ meta?: string;
9
+ }
10
+ export interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {
11
+ value: ObjectSummaryValueProps;
12
+ configuration?: ObjectConfigProps;
13
+ onDelete: () => void;
14
+ onPreview?: (e: {
15
+ href: string;
16
+ }) => void;
17
+ ref: Ref<HTMLDivElement>;
18
+ }
19
+ declare const ObjectSummary: FC<PropsWithoutRef<ObjectSummaryProps> & ForwardProps>;
20
+ export default ObjectSummary;
21
+ //# sourceMappingURL=ObjectSummary.d.ts.map