@pega/cosmos-react-build 4.0.0-dev.9.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +2 -2
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +4 -4
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +55 -57
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +3 -3
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.js +10 -14
- package/lib/components/AppShell/Header/AppHeader.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.styles.d.ts +1 -2
- package/lib/components/AppShell/Header/AppHeader.styles.d.ts.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.styles.js +1 -16
- package/lib/components/AppShell/Header/AppHeader.styles.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.types.d.ts +6 -5
- package/lib/components/AppShell/Header/AppHeader.types.d.ts.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.types.js.map +1 -1
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js +9 -4
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/AppShell/index.d.ts +3 -3
- package/lib/components/AppShell/index.d.ts.map +1 -1
- package/lib/components/AppShell/index.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts +1 -0
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js +26 -26
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts +41 -27
- package/lib/components/DynamicContentEditor/PegaCustomElement.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/index.d.ts +1 -1
- package/lib/components/DynamicContentEditor/index.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/index.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js +10 -11
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js +6 -6
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts +3 -3
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.js +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionDetails.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionDetails.js +1 -1
- package/lib/components/ExpressionBuilder/ExpressionDetails.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionList.js +1 -1
- package/lib/components/ExpressionBuilder/ExpressionList.js.map +1 -1
- package/lib/components/ExpressionBuilder/index.d.ts +2 -2
- package/lib/components/ExpressionBuilder/index.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/index.js.map +1 -1
- package/lib/components/FlowModeller/AddNode.d.ts.map +1 -1
- package/lib/components/FlowModeller/AddNode.js +3 -4
- package/lib/components/FlowModeller/AddNode.js.map +1 -1
- package/lib/components/FlowModeller/Connector.d.ts +2 -2
- package/lib/components/FlowModeller/Connector.d.ts.map +1 -1
- package/lib/components/FlowModeller/Connector.js +2 -4
- package/lib/components/FlowModeller/Connector.js.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.d.ts +3 -3
- package/lib/components/FlowModeller/DeletePopover.d.ts.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.js +1 -1
- package/lib/components/FlowModeller/DeletePopover.js.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.js +1 -3
- package/lib/components/FlowModeller/FlowModeller.js.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.d.ts +5 -0
- 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/NodeTemplates.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.js +3 -3
- package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js +3 -3
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js.map +1 -1
- package/lib/components/FlowModeller/index.d.ts +13 -8
- package/lib/components/FlowModeller/index.d.ts.map +1 -1
- package/lib/components/FlowModeller/index.js.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.d.ts.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.js +3 -3
- package/lib/components/ItemLibrary/ItemLibrary.js.map +1 -1
- package/lib/components/LifeCycle/Category.d.ts.map +1 -1
- package/lib/components/LifeCycle/Category.js +3 -3
- package/lib/components/LifeCycle/Category.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.js +1 -1
- package/lib/components/LifeCycle/LifeCycle.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.d.ts +22 -1
- package/lib/components/LifeCycle/LifeCycle.types.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.d.ts +11 -0
- package/lib/components/LifeCycle/LifeCycleList.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.js +2 -2
- package/lib/components/LifeCycle/LifeCycleList.js.map +1 -1
- package/lib/components/LifeCycle/Stage.d.ts +2 -0
- package/lib/components/LifeCycle/Stage.d.ts.map +1 -1
- package/lib/components/LifeCycle/Stage.js +2 -2
- package/lib/components/LifeCycle/Stage.js.map +1 -1
- package/lib/components/LifeCycle/Step.d.ts +3 -0
- package/lib/components/LifeCycle/Step.d.ts.map +1 -1
- package/lib/components/LifeCycle/Step.js +6 -5
- package/lib/components/LifeCycle/Step.js.map +1 -1
- package/lib/components/LifeCycle/Task.d.ts +1 -0
- package/lib/components/LifeCycle/Task.d.ts.map +1 -1
- package/lib/components/LifeCycle/Task.js +1 -1
- package/lib/components/LifeCycle/Task.js.map +1 -1
- package/lib/components/LifeCycle/index.d.ts +1 -1
- package/lib/components/LifeCycle/index.d.ts.map +1 -1
- package/lib/components/LifeCycle/index.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts +2 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.js.map +1 -1
- package/lib/components/MobileBuildSummary/index.d.ts +1 -1
- package/lib/components/MobileBuildSummary/index.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/index.js.map +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.d.ts +2 -2
- package/lib/components/ObjectPreview/ObjectPreview.d.ts.map +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.js +2 -2
- package/lib/components/ObjectPreview/ObjectPreview.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectPicker.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectPicker.js +1 -1
- package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.js +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.d.ts +5 -4
- package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.js +15 -13
- package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -1
- package/lib/components/ObjectSelect/index.d.ts +1 -1
- package/lib/components/ObjectSelect/index.d.ts.map +1 -1
- package/lib/components/ObjectSelect/index.js.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.d.ts +6 -13
- package/lib/components/ObjectSelect/useCreateModal.d.ts.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.js.map +1 -1
- package/lib/components/PageTemplates/GalleryPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/GalleryPage.js +1 -1
- package/lib/components/PageTemplates/GalleryPage.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +2 -2
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/PageTemplates/ShowcasePage.d.ts.map +1 -1
- package/lib/components/PageTemplates/ShowcasePage.js +1 -1
- package/lib/components/PageTemplates/ShowcasePage.js.map +1 -1
- package/lib/components/PageTemplates/index.d.ts +3 -4
- package/lib/components/PageTemplates/index.d.ts.map +1 -1
- package/lib/components/PageTemplates/index.js +1 -2
- package/lib/components/PageTemplates/index.js.map +1 -1
- package/lib/components/SummaryCard/SummaryCard.d.ts.map +1 -1
- package/lib/components/SummaryCard/SummaryCard.js +1 -5
- package/lib/components/SummaryCard/SummaryCard.js.map +1 -1
- package/lib/components/Workbench/Workbench.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.js +1 -1
- package/lib/components/Workbench/Workbench.js.map +1 -1
- package/lib/components/Workbench/Workbench.types.d.ts +2 -2
- package/lib/components/Workbench/Workbench.types.d.ts.map +1 -1
- package/lib/utils/utils.d.ts +1 -1
- package/lib/utils/utils.d.ts.map +1 -1
- package/package.json +17 -18
|
@@ -1 +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,
|
|
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,YAAY,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1 +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
|
+
{"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 type { DynamicContentEditorProps, ItemType } from './DynamicContentEditor.types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAUf,OAAO,qCAAqC,CAAC;AAC7C,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAkC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvF,OAAO,EAEL,eAAe,EAGhB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAUf,OAAO,qCAAqC,CAAC;AAC7C,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAkC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvF,OAAO,EAEL,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AA0E5B,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAsJjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// cspell:words unfocus
|
|
3
3
|
import { forwardRef, useRef, useState, useEffect, useImperativeHandle } from 'react';
|
|
4
4
|
import { Controlled as ReactCodeMirror } from 'react-codemirror2';
|
|
5
5
|
import { showHint, defineMode } from 'codemirror';
|
|
@@ -11,17 +11,17 @@ import { StyledCodeEditor } from './CodeEditor.styles';
|
|
|
11
11
|
import getCodeSuggestions from './getCodeSuggestions';
|
|
12
12
|
defineMode('expression', () => {
|
|
13
13
|
const tokens = [
|
|
14
|
-
|
|
14
|
+
// Below regex is used to identify the context
|
|
15
15
|
{ token: /\w+@/, style: 'ex-context' },
|
|
16
|
-
|
|
16
|
+
// Below regex is used to identify the RuleType
|
|
17
17
|
{ token: /\w+:/, style: 'ex-context' },
|
|
18
|
-
|
|
18
|
+
// Below regex is used to identify the RuleName
|
|
19
19
|
{ token: /\w+[(]/, style: 'ex-ruleName' },
|
|
20
|
-
|
|
20
|
+
// Below regex is used to identify the delimeters
|
|
21
21
|
{ token: /[:.(),]/, style: 'ex-delimeter' },
|
|
22
|
-
|
|
22
|
+
// Below regex is used to identify the operators
|
|
23
23
|
{ token: /[-+\\/*=<>@]+/, style: 'ex-operator' },
|
|
24
|
-
|
|
24
|
+
// Below regex is used to identify the spaces
|
|
25
25
|
{ token: / /, style: 'ex-space' }
|
|
26
26
|
];
|
|
27
27
|
return {
|
|
@@ -29,7 +29,7 @@ defineMode('expression', () => {
|
|
|
29
29
|
return { inString: false };
|
|
30
30
|
},
|
|
31
31
|
token(stream, state) {
|
|
32
|
-
|
|
32
|
+
// Used to identify the constants in the expression
|
|
33
33
|
const nextChar = stream.peek();
|
|
34
34
|
if (!state.inString && (nextChar === "'" || nextChar === '"')) {
|
|
35
35
|
stream.next(); // Skip quote
|
|
@@ -51,8 +51,7 @@ defineMode('expression', () => {
|
|
|
51
51
|
if (stream.match(/.\w+\(/))
|
|
52
52
|
return 'ex-delimeter';
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
54
|
+
// Used to match the regex in the expression
|
|
56
55
|
for (const element of tokens) {
|
|
57
56
|
const match = stream.match(element.token, false);
|
|
58
57
|
if (match) {
|
|
@@ -73,7 +72,7 @@ const defaultConfigOptions = {
|
|
|
73
72
|
autoCloseBrackets: true,
|
|
74
73
|
extraKeys: { Tab: false, 'Shift-Tab': false }
|
|
75
74
|
};
|
|
76
|
-
const CodeEditor = forwardRef(({ fetchSuggestions, autoCompleteTriggers, editorConfigProps, codeEditorHandle, defaultValue = '', loading = false, readOnly, errors, onChange, ...props }, ref)
|
|
75
|
+
const CodeEditor = forwardRef(function CodeEditor({ fetchSuggestions, autoCompleteTriggers, editorConfigProps, codeEditorHandle, defaultValue = '', loading = false, readOnly, errors, onChange, ...props }, ref) {
|
|
77
76
|
const [value, setCode] = useState(defaultValue);
|
|
78
77
|
const [suggestions, setSuggestions] = useState([]);
|
|
79
78
|
const [codeMirror, setCodeMirror] = useState(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":";AAAA,uBAAuB;AACvB,OAAO,EACL,UAAU,EAGV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,mBAAmB,EACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,QAAQ,EACR,UAAU,EAKX,MAAM,YAAY,CAAC;AACpB,OAAO,qCAAqC,CAAC;AAC7C,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAgB,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4DAA4D,CAAC;AAQjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE;IAC5B,MAAM,MAAM,GAAG;QACb,kDAAkD;QAClD,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;QACtC,oDAAoD;QACpD,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;QACtC,mDAAmD;QACnD,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE;QACzC,qDAAqD;QACrD,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE;QAC3C,oDAAoD;QACpD,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE;QAChD,iDAAiD;QACjD,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,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vB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,MAAC,gBAAgB,IACf,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,SAAS;SACnB,EACD,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC;SACR,EACD,GAAG,EAAE,yBAAyB,EAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,OAAO,EAClB,WAAW,EAAE,WAAW,KACpB,KAAK,aAET,KAAC,eAAe,IACd,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,EAAE,GAAG,oBAAoB,EAAE,GAAG,iBAAiB,EAAE,EAC1D,cAAc,EAAE,MAAM,CAAC,EAAE;oBACvB,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC/B,aAAa,CAAC,MAAM,CAAC,CAAC;gBACxB,CAAC,GACD,EACD,MAAM,IAAI,KAAC,mBAAmB,IAAC,MAAM,EAAC,OAAO,YAAE,MAAM,GAAuB,IAC5D,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["// cSpell:words unfocus\nimport {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useRef,\n useState,\n useEffect,\n useImperativeHandle\n} from 'react';\nimport { Controlled as ReactCodeMirror } from 'react-codemirror2';\nimport {\n showHint,\n defineMode,\n Editor,\n Position,\n EditorChange,\n EditorConfiguration\n} from 'codemirror';\nimport 'codemirror/addon/edit/closebrackets';\nimport 'codemirror/addon/hint/show-hint.js';\n\nimport { useConsolidatedRef, useElement, ForwardProps } from '@pega/cosmos-react-core';\nimport { StyledFormFieldInfo } from '@pega/cosmos-react-core/lib/components/FormField/FormField';\n\nimport {\n AutoCompleteTriggerChar,\n CodeEditorProps,\n EditorState,\n SuggestionType\n} from './CodeEditor.types';\nimport { StyledCodeEditor } from './CodeEditor.styles';\nimport getCodeSuggestions from './getCodeSuggestions';\n\ndefineMode('expression', () => {\n const tokens = [\n /* Below regex is used to identify the context */\n { token: /\\w+@/, style: 'ex-context' },\n /* Below regex is used to identify the RuleType */\n { token: /\\w+:/, style: 'ex-context' },\n /* Below regex is used to identify the RuleName */\n { token: /\\w+[(]/, style: 'ex-ruleName' },\n /* Below regex is used to identify the delimeters */\n { token: /[:.(),]/, style: 'ex-delimeter' },\n /* Below regex is used to identify the operators */\n { token: /[-+\\\\/*=<>@]+/, style: 'ex-operator' },\n /* Below regex is used to identify the spaces */\n { token: / /, style: 'ex-space' }\n ];\n\n return {\n startState() {\n return { inString: false };\n },\n token(stream, state) {\n /* Used to identify the constants in the expression */\n const nextChar = stream.peek();\n if (!state.inString && (nextChar === \"'\" || nextChar === '\"')) {\n stream.next(); // Skip quote\n state.inString = true; // Update state\n }\n\n if (state.inString) {\n if (nextChar && stream.skipTo(nextChar)) {\n // Quote found on this line\n stream.next(); // Skip quote\n state.inString = false; // Clear flag\n } else {\n stream.skipToEnd(); // Rest of line is string\n }\n return nextChar === '\"' ? 'ex-constant' : 'ex-context'; // Token style\n }\n\n if (stream.peek() === '.') {\n stream.next();\n if (stream.match(/.\\w+\\(/)) return 'ex-delimeter';\n }\n\n /* Used to match the regex in the expression */\n // eslint-disable-next-line no-restricted-syntax\n for (const element of tokens) {\n const match = stream.match(element.token, false);\n if (match) {\n if (stream.pos === stream.start) {\n stream.next();\n }\n return element.style;\n }\n }\n stream.next();\n return null;\n }\n };\n});\n\nconst defaultConfigOptions: Pick<\n EditorConfiguration,\n 'lineWrapping' | 'smartIndent' | 'autoCloseBrackets' | 'extraKeys'\n> = {\n lineWrapping: true,\n smartIndent: true,\n autoCloseBrackets: true,\n extraKeys: { Tab: false, 'Shift-Tab': false }\n};\n\nconst CodeEditor: FunctionComponent<CodeEditorProps & ForwardProps> = forwardRef(\n (\n {\n fetchSuggestions,\n autoCompleteTriggers,\n editorConfigProps,\n codeEditorHandle,\n defaultValue = '',\n loading = false,\n readOnly,\n errors,\n onChange,\n ...props\n }: PropsWithoutRef<CodeEditorProps>,\n ref: CodeEditorProps['ref']\n ) => {\n const [value, setCode] = useState<string>(defaultValue);\n const [suggestions, setSuggestions] = useState<SuggestionType[]>([]);\n const [codeMirror, setCodeMirror] = useState<Editor | null>(null);\n const [codeEditorContainer, setCodeEditorContainer] = useElement<HTMLDivElement>();\n const codeEditorConsolidatedRef = useConsolidatedRef(setCodeEditorContainer, ref);\n const [suggestionTrigger, setSuggestionTrigger] = useState<{\n character: AutoCompleteTriggerChar;\n cursorPosition: Position;\n } | null>(null);\n const [popover, showPopover] = useState(false);\n const mounted = useRef(false);\n\n useImperativeHandle<any, EditorState>(\n codeEditorHandle,\n () => ({\n insertText: (text: string) => {\n if (codeMirror) {\n if (codeMirror.getSelection()) {\n codeMirror.replaceSelection(text);\n } else {\n const cur: Position = codeMirror.getCursor();\n codeMirror.replaceRange(text, cur);\n }\n }\n },\n getValue: () => {\n return codeMirror?.getValue();\n }\n }),\n [codeMirror]\n );\n\n const autoComplete = (codeEditor: Editor) => {\n const hintOptions = {\n completeSingle: false,\n completeOnSingleClick: true,\n closeOnUnfocus: true,\n suggestions,\n container: codeEditorContainer,\n loading,\n triggerCharacterCursorPos: suggestionTrigger?.cursorPosition\n };\n showHint(codeEditor, getCodeSuggestions, hintOptions);\n };\n\n const onBeforeChange = async (editor: Editor, _data: EditorChange, textvalue: string) => {\n setCode(textvalue);\n onChange?.(textvalue);\n const currentCursor = editor.getCursor();\n const currentCharacter = editor\n .getTokenAt(currentCursor)\n .string.trim() as AutoCompleteTriggerChar;\n\n let newSuggestions: SuggestionType[] = [];\n\n if (autoCompleteTriggers?.includes(currentCharacter) && fetchSuggestions) {\n setSuggestionTrigger({\n character: currentCharacter,\n cursorPosition: currentCursor\n });\n\n newSuggestions = [\n ...(await fetchSuggestions(currentCharacter, {\n line: currentCursor.line,\n ch: currentCursor.ch\n }))\n ];\n if (mounted.current) {\n setSuggestions(newSuggestions);\n }\n }\n };\n\n useEffect(() => {\n if (!popover) return;\n const isSuggestionTriggerPresent =\n suggestionTrigger &&\n codeMirror\n ?.getTokenAt(suggestionTrigger.cursorPosition)\n .string.includes(suggestionTrigger.character);\n\n if (!isSuggestionTriggerPresent) {\n codeMirror?.closeHint();\n showPopover(false);\n setSuggestionTrigger(null);\n }\n }, [onBeforeChange]);\n\n useEffect(() => {\n if (codeMirror && (suggestionTrigger || loading)) {\n autoComplete(codeMirror);\n showPopover(true);\n } else {\n codeMirror?.closeHint();\n showPopover(false);\n }\n }, [suggestions, loading]);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n return (\n <StyledCodeEditor\n container={{\n direction: 'column',\n justify: 'between'\n }}\n item={{\n grow: 1\n }}\n ref={codeEditorConsolidatedRef}\n errors={errors}\n readOnly={readOnly}\n isLoading={loading}\n suggestions={suggestions}\n {...props}\n >\n <ReactCodeMirror\n value={value}\n onBeforeChange={onBeforeChange}\n options={{ ...defaultConfigOptions, ...editorConfigProps }}\n editorDidMount={editor => {\n editor.setSize('100%', '100%');\n setCodeMirror(editor);\n }}\n />\n {errors && <StyledFormFieldInfo status='error'>{errors}</StyledFormFieldInfo>}\n </StyledCodeEditor>\n );\n }\n);\n\nexport default CodeEditor;\n"]}
|
|
1
|
+
{"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":";AAAA,uBAAuB;AACvB,OAAO,EACL,UAAU,EAGV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,mBAAmB,EACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,QAAQ,EACR,UAAU,EAKX,MAAM,YAAY,CAAC;A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,cAAc,EAC9B,OAAO,EAAE,EAAE,GAAG,oBAAoB,EAAE,GAAG,iBAAiB,EAAE,EAC1D,cAAc,EAAE,MAAM,CAAC,EAAE;oBACvB,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC/B,aAAa,CAAC,MAAM,CAAC,CAAC;gBACxB,CAAC,GACD,EACD,MAAM,IAAI,KAAC,mBAAmB,IAAC,MAAM,EAAC,OAAO,YAAE,MAAM,GAAuB,IAC5D,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["// cspell:words unfocus\nimport {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useRef,\n useState,\n useEffect,\n useImperativeHandle\n} from 'react';\nimport { Controlled as ReactCodeMirror } from 'react-codemirror2';\nimport {\n showHint,\n defineMode,\n Editor,\n Position,\n EditorChange,\n EditorConfiguration\n} from 'codemirror';\nimport 'codemirror/addon/edit/closebrackets';\nimport 'codemirror/addon/hint/show-hint.js';\n\nimport { useConsolidatedRef, useElement, ForwardProps } from '@pega/cosmos-react-core';\nimport { StyledFormFieldInfo } from '@pega/cosmos-react-core/lib/components/FormField/FormField';\n\nimport {\n AutoCompleteTriggerChar,\n CodeEditorProps,\n EditorState,\n SuggestionType\n} from './CodeEditor.types';\nimport { StyledCodeEditor } from './CodeEditor.styles';\nimport getCodeSuggestions from './getCodeSuggestions';\n\ndefineMode('expression', () => {\n const tokens = [\n // Below regex is used to identify the context\n { token: /\\w+@/, style: 'ex-context' },\n // Below regex is used to identify the RuleType\n { token: /\\w+:/, style: 'ex-context' },\n // Below regex is used to identify the RuleName\n { token: /\\w+[(]/, style: 'ex-ruleName' },\n // Below regex is used to identify the delimeters\n { token: /[:.(),]/, style: 'ex-delimeter' },\n // Below regex is used to identify the operators\n { token: /[-+\\\\/*=<>@]+/, style: 'ex-operator' },\n // Below regex is used to identify the spaces\n { token: / /, style: 'ex-space' }\n ];\n\n return {\n startState() {\n return { inString: false };\n },\n token(stream, state) {\n // Used to identify the constants in the expression\n const nextChar = stream.peek();\n if (!state.inString && (nextChar === \"'\" || nextChar === '\"')) {\n stream.next(); // Skip quote\n state.inString = true; // Update state\n }\n\n if (state.inString) {\n if (nextChar && stream.skipTo(nextChar)) {\n // Quote found on this line\n stream.next(); // Skip quote\n state.inString = false; // Clear flag\n } else {\n stream.skipToEnd(); // Rest of line is string\n }\n return nextChar === '\"' ? 'ex-constant' : 'ex-context'; // Token style\n }\n\n if (stream.peek() === '.') {\n stream.next();\n if (stream.match(/.\\w+\\(/)) return 'ex-delimeter';\n }\n\n // Used to match the regex in the expression\n for (const element of tokens) {\n const match = stream.match(element.token, false);\n if (match) {\n if (stream.pos === stream.start) {\n stream.next();\n }\n return element.style;\n }\n }\n stream.next();\n return null;\n }\n };\n});\n\nconst defaultConfigOptions: Pick<\n EditorConfiguration,\n 'lineWrapping' | 'smartIndent' | 'autoCloseBrackets' | 'extraKeys'\n> = {\n lineWrapping: true,\n smartIndent: true,\n autoCloseBrackets: true,\n extraKeys: { Tab: false, 'Shift-Tab': false }\n};\n\nconst CodeEditor: FunctionComponent<CodeEditorProps & ForwardProps> = forwardRef(\n function CodeEditor(\n {\n fetchSuggestions,\n autoCompleteTriggers,\n editorConfigProps,\n codeEditorHandle,\n defaultValue = '',\n loading = false,\n readOnly,\n errors,\n onChange,\n ...props\n }: PropsWithoutRef<CodeEditorProps>,\n ref: CodeEditorProps['ref']\n ) {\n const [value, setCode] = useState<string>(defaultValue);\n const [suggestions, setSuggestions] = useState<SuggestionType[]>([]);\n const [codeMirror, setCodeMirror] = useState<Editor | null>(null);\n const [codeEditorContainer, setCodeEditorContainer] = useElement<HTMLDivElement>();\n const codeEditorConsolidatedRef = useConsolidatedRef(setCodeEditorContainer, ref);\n const [suggestionTrigger, setSuggestionTrigger] = useState<{\n character: AutoCompleteTriggerChar;\n cursorPosition: Position;\n } | null>(null);\n const [popover, showPopover] = useState(false);\n const mounted = useRef(false);\n\n useImperativeHandle<any, EditorState>(\n codeEditorHandle,\n () => ({\n insertText: (text: string) => {\n if (codeMirror) {\n if (codeMirror.getSelection()) {\n codeMirror.replaceSelection(text);\n } else {\n const cur: Position = codeMirror.getCursor();\n codeMirror.replaceRange(text, cur);\n }\n }\n },\n getValue: () => {\n return codeMirror?.getValue();\n }\n }),\n [codeMirror]\n );\n\n const autoComplete = (codeEditor: Editor) => {\n const hintOptions = {\n completeSingle: false,\n completeOnSingleClick: true,\n closeOnUnfocus: true,\n suggestions,\n container: codeEditorContainer,\n loading,\n triggerCharacterCursorPos: suggestionTrigger?.cursorPosition\n };\n showHint(codeEditor, getCodeSuggestions, hintOptions);\n };\n\n const onBeforeChange = async (editor: Editor, _data: EditorChange, textvalue: string) => {\n setCode(textvalue);\n onChange?.(textvalue);\n const currentCursor = editor.getCursor();\n const currentCharacter = editor\n .getTokenAt(currentCursor)\n .string.trim() as AutoCompleteTriggerChar;\n\n let newSuggestions: SuggestionType[] = [];\n\n if (autoCompleteTriggers?.includes(currentCharacter) && fetchSuggestions) {\n setSuggestionTrigger({\n character: currentCharacter,\n cursorPosition: currentCursor\n });\n\n newSuggestions = [\n ...(await fetchSuggestions(currentCharacter, {\n line: currentCursor.line,\n ch: currentCursor.ch\n }))\n ];\n if (mounted.current) {\n setSuggestions(newSuggestions);\n }\n }\n };\n\n useEffect(() => {\n if (!popover) return;\n const isSuggestionTriggerPresent =\n suggestionTrigger &&\n codeMirror\n ?.getTokenAt(suggestionTrigger.cursorPosition)\n .string.includes(suggestionTrigger.character);\n\n if (!isSuggestionTriggerPresent) {\n codeMirror?.closeHint();\n showPopover(false);\n setSuggestionTrigger(null);\n }\n }, [onBeforeChange]);\n\n useEffect(() => {\n if (codeMirror && (suggestionTrigger || loading)) {\n autoComplete(codeMirror);\n showPopover(true);\n } else {\n codeMirror?.closeHint();\n showPopover(false);\n }\n }, [suggestions, loading]);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n return (\n <StyledCodeEditor\n container={{\n direction: 'column',\n justify: 'between'\n }}\n item={{\n grow: 1\n }}\n ref={codeEditorConsolidatedRef}\n errors={errors}\n readOnly={readOnly}\n isLoading={loading}\n suggestions={suggestions}\n {...props}\n >\n <ReactCodeMirror\n value={value}\n onBeforeChange={onBeforeChange}\n options={{ ...defaultConfigOptions, ...editorConfigProps }}\n editorDidMount={editor => {\n editor.setSize('100%', '100%');\n setCodeMirror(editor);\n }}\n />\n {errors && <StyledFormFieldInfo status='error'>{errors}</StyledFormFieldInfo>}\n </StyledCodeEditor>\n );\n }\n);\n\nexport default CodeEditor;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// cspell:words vscrollbar hscrollbar
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { mix } from 'polished';
|
|
4
4
|
import { defaultThemeProp, calculateFontSize, Flex } from '@pega/cosmos-react-core';
|
|
@@ -464,7 +464,7 @@ export const StyledCodeEditor = styled(Flex)(({ theme: { base, components: { 'fo
|
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
.cm-ex-context {
|
|
467
|
-
color: ${base.palette
|
|
467
|
+
color: ${base.palette.interactive};
|
|
468
468
|
}
|
|
469
469
|
.cm-ex-operator {
|
|
470
470
|
color: ${base.palette.warn};
|
|
@@ -517,13 +517,13 @@ export const StyledCodeEditor = styled(Flex)(({ theme: { base, components: { 'fo
|
|
|
517
517
|
padding-inline: ${base.spacing};
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
|
|
521
|
-
${!isLoading &&
|
|
520
|
+
${!isLoading &&
|
|
522
521
|
suggestions?.length > 0 &&
|
|
523
522
|
css `
|
|
523
|
+
li.CodeMirror-hint-active {
|
|
524
524
|
background-color: ${activeColor};
|
|
525
|
-
|
|
526
|
-
}
|
|
525
|
+
}
|
|
526
|
+
`}
|
|
527
527
|
`;
|
|
528
528
|
});
|
|
529
529
|
StyledCodeEditor.defaultProps = defaultThemeProp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.styles.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAC;AAI7F,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEtC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,CAM1C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,cAAc,EAAE,EACd,YAAY,EAAE,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,EAC9D,EACD,YAAY,EAAE,EACZ,KAAK,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE,EAC3C,EACF,EACF,EACD,MAAM,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACT,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE5F,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3F,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3E,OAAO,GAAG,CAAA;;;;QAIN,eAA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I,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;;oCAE3C,IAAI,CAAC,eAAe,CAAC;sBACnC,IAAI,CAAC,MAAM,CAAC,GAAG;kCACH,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;4BACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;qBACzC,SAAS,CAAC,CAAC;;;;;;;UAOtB,CAAC,SAAS,IAAI,WAAW,EAAE,MAAM,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAA;;SAEF;;4BAEmB,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;;;;;;;8BAOtB,WAAW;;;;8BAIX,UAAU;;0BAEd,IAAI,CAAC,OAAO;;;;UAI5B,CAAC,SAAS;QACZ,WAAW,EAAE,MAAM,GAAG,CAAC;QACvB,GAAG,CAAA;8BACmB,WAAW;SAChC;;KAEJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["// cSpell:words vscrollbar hscrollbar\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport { defaultThemeProp, calculateFontSize, Flex } from '@pega/cosmos-react-core';\nimport { StyledFormField } from '@pega/cosmos-react-core/lib/components/FormField/FormField';\n\nimport { SuggestionType } from './CodeEditor.types';\n\nexport const StyledLoading = styled.div`\n font-size: 1.5rem;\n`;\n\nexport const StyledCodeEditor = styled(Flex)<{\n isLoading?: boolean;\n errors?: string;\n readOnly?: boolean;\n suggestions: SuggestionType[];\n}>(\n ({\n theme: {\n base,\n components: {\n 'form-control': {\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n },\n 'form-field': {\n error: { 'status-color': errorBackground }\n }\n }\n },\n errors,\n isLoading,\n suggestions,\n readOnly\n }) => {\n const activeColor = mix(0.85, base.palette['primary-background'], base.palette.interactive);\n\n const hoverColor = mix(0.95, base.palette['primary-background'], base.palette.interactive);\n\n const fontSizes = calculateFontSize(base['font-size'], base['font-scale']);\n return css`\n position: relative;\n max-height: 100%;\n overflow-y: auto;\n ${StyledFormField} {\n flex-grow: 1;\n }\n\n /* PADDING */\n .react-codemirror2 {\n flex-grow: 1;\n min-height: 3.75rem;\n overflow-y: auto;\n ${readOnly &&\n css`\n max-height: 5.625rem;\n `}\n }\n\n .CodeMirror-lines {\n cursor: text;\n min-height: 0.063rem; /* prevents collapsing before first draw */\n padding: ${base.spacing};\n }\n\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n }\n\n /* GUTTER */\n\n .CodeMirror-gutters {\n position: absolute;\n left: 0;\n top: 0;\n min-height: 100%;\n z-index: 3;\n border-right: 0.063rem solid #dddddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n }\n .CodeMirror-linenumber {\n padding: 0 0.125rem 0 0.313rem;\n min-width: 1.25rem;\n text-align: right;\n color: #999999;\n white-space: nowrap;\n }\n\n .CodeMirror-guttermarker {\n color: black;\n }\n .CodeMirror-guttermarker-subtle {\n color: #999999;\n }\n\n /* CURSOR */\n\n .CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n border-left: 0.0625rem solid ${base.palette.dark};\n border-right: none;\n width: 0;\n ${readOnly &&\n css`\n display: none;\n `}\n }\n\n /* Shown when moving in bi-directional text */\n .CodeMirror div.CodeMirror-secondarycursor {\n border-left: 0.063rem solid silver;\n }\n .cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n }\n .cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #77ee77;\n }\n @-moz-keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n @-webkit-keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n @keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n\n .cm-tab {\n display: inline-block;\n text-decoration: inherit;\n }\n\n .CodeMirror-rulers {\n position: absolute;\n left: 0;\n right: 0;\n top: -3.125rem;\n bottom: 0;\n overflow: hidden;\n }\n .CodeMirror-ruler {\n border-left: 0.063rem solid #cccccc;\n top: 0;\n bottom: 0;\n position: absolute;\n }\n\n /* DEFAULT THEME */\n\n .cm-s-default .cm-header {\n color: blue;\n }\n .cm-negative {\n color: #dd4444;\n }\n .cm-positive {\n color: #229922;\n }\n .cm-strong {\n font-weight: bold;\n }\n .cm-s-default .cm-quote {\n color: #009900;\n }\n .cm-em {\n font-style: italic;\n }\n .cm-link {\n text-decoration: underline;\n }\n .cm-strikethrough {\n text-decoration: line-through;\n }\n\n .cm-s-default .cm-keyword {\n color: #770088;\n }\n .cm-s-default .cm-atom {\n color: #221199;\n }\n .cm-s-default .cm-number {\n color: #116644;\n }\n .cm-s-default .cm-def {\n color: #0000ff;\n }\n .cm-s-default .cm-variable-2 {\n color: #0055aa;\n }\n .cm-s-default .cm-variable-3,\n .cm-s-default .cm-type {\n color: #008855;\n }\n .cm-s-default .cm-comment {\n color: #aa5500;\n }\n .cm-s-default .cm-string {\n color: #aa1111;\n }\n .cm-s-default .cm-string-2 {\n color: #ff5500;\n }\n .cm-s-default .cm-meta {\n color: #555555;\n }\n .cm-s-default .cm-qualifier {\n color: #555555;\n }\n .cm-s-default .cm-builtin {\n color: #3300aa;\n }\n .cm-s-default .cm-bracket {\n color: #999977;\n }\n .cm-s-default .cm-tag {\n color: #117700;\n }\n .cm-s-default .cm-attribute {\n color: #0000cc;\n }\n .cm-s-default .cm-hr {\n color: #999999;\n }\n .cm-s-default .cm-link {\n color: #0000cc;\n }\n\n .cm-s-default .cm-error {\n color: #ff0000;\n }\n .cm-invalidchar {\n color: #ff0000;\n }\n\n .CodeMirror-composing {\n border-bottom: 0.125rem solid;\n }\n\n /* Default styles for common addons */\n\n div.CodeMirror span.CodeMirror-matchingbracket {\n color: #00bb00;\n }\n div.CodeMirror span.CodeMirror-nonmatchingbracket {\n color: #aa2222;\n }\n .CodeMirror-matchingtag {\n background: rgba(255, 150, 0, 0.3);\n }\n .CodeMirror-activeline-background {\n background: #e8f2ff;\n }\n\n /* STOP */\n\n /* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n .CodeMirror-scroll {\n overflow: scroll !important;\n margin-bottom: -3.125rem;\n margin-right: -3.125rem;\n padding-bottom: 3.125rem;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n }\n .CodeMirror-sizer {\n position: relative;\n border-right: 3.125rem solid transparent;\n }\n\n /* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n .CodeMirror-vscrollbar,\n .CodeMirror-hscrollbar,\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n }\n .CodeMirror-vscrollbar {\n right: 0;\n top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n }\n .CodeMirror-hscrollbar {\n bottom: 0;\n left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n }\n .CodeMirror-scrollbar-filler {\n right: 0;\n bottom: 0;\n }\n .CodeMirror-gutter-filler {\n left: 0;\n bottom: 0;\n }\n .CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -3.125rem;\n }\n .CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n }\n .CodeMirror-gutter-background {\n position: absolute;\n top: 0;\n bottom: 0;\n z-index: 4;\n }\n .CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n }\n .CodeMirror-gutter-wrapper ::selection {\n background-color: transparent;\n }\n .CodeMirror-gutter-wrapper ::-moz-selection {\n background-color: transparent;\n }\n\n .CodeMirror pre.CodeMirror-line,\n .CodeMirror pre.CodeMirror-line-like {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0;\n -webkit-border-radius: 0;\n border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n }\n .CodeMirror-wrap pre.CodeMirror-line,\n .CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n }\n\n .CodeMirror-linebackground {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n z-index: 0;\n }\n\n .CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.006rem; /* Force widget margins to stay inside of the container */\n }\n\n .CodeMirror-rtl pre {\n direction: rtl;\n }\n\n .CodeMirror-code {\n outline: none;\n }\n\n /* Force content-box sizing for the elements where we expect it */\n .CodeMirror-scroll,\n .CodeMirror-sizer,\n .CodeMirror-gutter,\n .CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n }\n\n .CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n\n .CodeMirror-measure pre {\n position: static;\n }\n\n div.CodeMirror-dragcursors {\n visibility: visible;\n }\n\n .CodeMirror-selected {\n background: #d9d9d9;\n }\n .CodeMirror-focused .CodeMirror-selected {\n background: #d7d4f0;\n }\n .CodeMirror-focused {\n border-color: ${base.palette.interactive} !important;\n }\n .CodeMirror:not(.CodeMirror-focused) .CodeMirror-cursors {\n visibility: hidden;\n }\n .CodeMirror-crosshair {\n cursor: crosshair;\n }\n .CodeMirror-line::selection,\n .CodeMirror-line > span::selection,\n .CodeMirror-line > span > span::selection {\n background: #d7d4f0;\n }\n .CodeMirror-line::-moz-selection,\n .CodeMirror-line > span::-moz-selection,\n .CodeMirror-line > span > span::-moz-selection {\n background: #d7d4f0;\n }\n\n .cm-searching {\n background-color: rgba(255, 255, 0, 0.4);\n }\n\n /* Used to force a border model for a node */\n .cm-force-border {\n padding-right: 0.006rem;\n }\n\n /* See issue #2901 */\n .cm-tab-wrap-hack::after {\n content: '';\n }\n\n /* Help users use markselection to safely style text background */\n span.CodeMirror-selectedtext {\n background: none;\n }\n\n .CodeMirror {\n overflow: hidden;\n font-family: monospace;\n direction: ltr;\n position: relative;\n background-color: ${base.palette['background-color']};\n color: ${base.palette['foreground-color']};\n border: 0.0625rem solid ${base.palette['border-line']};\n border-radius: calc(0.5 * ${base['border-radius']});\n ${errors &&\n css`\n border-color: ${errorBackground};\n `}\n ${readOnly &&\n css`\n background-color: ${readOnlyBackgroundColor};\n `}\n }\n\n .cm-ex-context {\n color: ${base.palette['brand-primary']};\n }\n .cm-ex-operator {\n color: ${base.palette.warn};\n font-weight: bold;\n }\n .cm-ex-ruleName {\n color: ${base.palette.success};\n }\n .cm-ex-delimeter {\n color: ${base.palette['foreground-color']};\n }\n .cm-ex-constant {\n color: ${base.palette.pending};\n }\n\n .CodeMirror-hints {\n position: absolute;\n z-index: 10;\n transition: height ${base.animation.speed} ${base.animation.timing.ease};\n padding: 0;\n border-radius: calc(0.5 * ${base['border-radius']});\n box-shadow: ${base.shadow.low};\n border: 0.0625rem solid ${base.palette['border-line']};\n background-color: ${base.palette['primary-background']};\n font-size: ${fontSizes.s};\n max-height: 12rem;\n overflow-y: auto;\n min-width: 8rem;\n }\n\n .CodeMirror-hint {\n ${(isLoading || suggestions?.length === 0) &&\n css`\n pointer-events: none;\n `}\n min-height: 1.2rem;\n width: calc(1.5 * ${base['content-width'].xs});\n cursor: pointer;\n @media (pointer: coarse) {\n min-height: 1.2rem;\n }\n line-height: 1.2rem;\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n padding-inline: ${base.spacing};\n }\n\n li.CodeMirror-hint-active {\n ${!isLoading &&\n suggestions?.length > 0 &&\n css`\n background-color: ${activeColor};\n `}\n }\n `;\n }\n);\n\nStyledCodeEditor.defaultProps = defaultThemeProp;\n"]}
|
|
1
|
+
{"version":3,"file":"CodeEditor.styles.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAC;AAI7F,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEtC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,CAM1C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,cAAc,EAAE,EACd,YAAY,EAAE,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,EAC9D,EACD,YAAY,EAAE,EACZ,KAAK,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE,EAC3C,EACF,EACF,EACD,MAAM,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACT,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE5F,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3F,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,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;iBAGhC,IAAI,CAAC,OAAO,CAAC,OAAO;;;;;;6BAMR,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;;oCAE3C,IAAI,CAAC,eAAe,CAAC;sBACnC,IAAI,CAAC,MAAM,CAAC,GAAG;kCACH,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;4BACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;qBACzC,SAAS,CAAC,CAAC;;;;;;;UAOtB,CAAC,SAAS,IAAI,WAAW,EAAE,MAAM,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAA;;SAEF;;4BAEmB,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;;;;;;;8BAOtB,WAAW;;;;8BAIX,UAAU;;0BAEd,IAAI,CAAC,OAAO;;;QAG9B,CAAC,SAAS;QACZ,WAAW,EAAE,MAAM,GAAG,CAAC;QACvB,GAAG,CAAA;;8BAEqB,WAAW;;OAElC;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["// cspell:words vscrollbar hscrollbar\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport { defaultThemeProp, calculateFontSize, Flex } from '@pega/cosmos-react-core';\nimport { StyledFormField } from '@pega/cosmos-react-core/lib/components/FormField/FormField';\n\nimport { SuggestionType } from './CodeEditor.types';\n\nexport const StyledLoading = styled.div`\n font-size: 1.5rem;\n`;\n\nexport const StyledCodeEditor = styled(Flex)<{\n isLoading?: boolean;\n errors?: string;\n readOnly?: boolean;\n suggestions: SuggestionType[];\n}>(\n ({\n theme: {\n base,\n components: {\n 'form-control': {\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n },\n 'form-field': {\n error: { 'status-color': errorBackground }\n }\n }\n },\n errors,\n isLoading,\n suggestions,\n readOnly\n }) => {\n const activeColor = mix(0.85, base.palette['primary-background'], base.palette.interactive);\n\n const hoverColor = mix(0.95, base.palette['primary-background'], base.palette.interactive);\n\n const fontSizes = calculateFontSize(base['font-size'], base['font-scale']);\n return css`\n position: relative;\n max-height: 100%;\n overflow-y: auto;\n ${StyledFormField} {\n flex-grow: 1;\n }\n\n /* PADDING */\n .react-codemirror2 {\n flex-grow: 1;\n min-height: 3.75rem;\n overflow-y: auto;\n ${readOnly &&\n css`\n max-height: 5.625rem;\n `}\n }\n\n .CodeMirror-lines {\n cursor: text;\n min-height: 0.063rem; /* prevents collapsing before first draw */\n padding: ${base.spacing};\n }\n\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n }\n\n /* GUTTER */\n\n .CodeMirror-gutters {\n position: absolute;\n left: 0;\n top: 0;\n min-height: 100%;\n z-index: 3;\n border-right: 0.063rem solid #dddddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n }\n .CodeMirror-linenumber {\n padding: 0 0.125rem 0 0.313rem;\n min-width: 1.25rem;\n text-align: right;\n color: #999999;\n white-space: nowrap;\n }\n\n .CodeMirror-guttermarker {\n color: black;\n }\n .CodeMirror-guttermarker-subtle {\n color: #999999;\n }\n\n /* CURSOR */\n\n .CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n border-left: 0.0625rem solid ${base.palette.dark};\n border-right: none;\n width: 0;\n ${readOnly &&\n css`\n display: none;\n `}\n }\n\n /* Shown when moving in bi-directional text */\n .CodeMirror div.CodeMirror-secondarycursor {\n border-left: 0.063rem solid silver;\n }\n .cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n }\n .cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #77ee77;\n }\n @-moz-keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n @-webkit-keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n @keyframes blink {\n 50% {\n background-color: transparent;\n }\n }\n\n .cm-tab {\n display: inline-block;\n text-decoration: inherit;\n }\n\n .CodeMirror-rulers {\n position: absolute;\n left: 0;\n right: 0;\n top: -3.125rem;\n bottom: 0;\n overflow: hidden;\n }\n .CodeMirror-ruler {\n border-left: 0.063rem solid #cccccc;\n top: 0;\n bottom: 0;\n position: absolute;\n }\n\n /* DEFAULT THEME */\n\n .cm-s-default .cm-header {\n color: blue;\n }\n .cm-negative {\n color: #dd4444;\n }\n .cm-positive {\n color: #229922;\n }\n .cm-strong {\n font-weight: bold;\n }\n .cm-s-default .cm-quote {\n color: #009900;\n }\n .cm-em {\n font-style: italic;\n }\n .cm-link {\n text-decoration: underline;\n }\n .cm-strikethrough {\n text-decoration: line-through;\n }\n\n .cm-s-default .cm-keyword {\n color: #770088;\n }\n .cm-s-default .cm-atom {\n color: #221199;\n }\n .cm-s-default .cm-number {\n color: #116644;\n }\n .cm-s-default .cm-def {\n color: #0000ff;\n }\n .cm-s-default .cm-variable-2 {\n color: #0055aa;\n }\n .cm-s-default .cm-variable-3,\n .cm-s-default .cm-type {\n color: #008855;\n }\n .cm-s-default .cm-comment {\n color: #aa5500;\n }\n .cm-s-default .cm-string {\n color: #aa1111;\n }\n .cm-s-default .cm-string-2 {\n color: #ff5500;\n }\n .cm-s-default .cm-meta {\n color: #555555;\n }\n .cm-s-default .cm-qualifier {\n color: #555555;\n }\n .cm-s-default .cm-builtin {\n color: #3300aa;\n }\n .cm-s-default .cm-bracket {\n color: #999977;\n }\n .cm-s-default .cm-tag {\n color: #117700;\n }\n .cm-s-default .cm-attribute {\n color: #0000cc;\n }\n .cm-s-default .cm-hr {\n color: #999999;\n }\n .cm-s-default .cm-link {\n color: #0000cc;\n }\n\n .cm-s-default .cm-error {\n color: #ff0000;\n }\n .cm-invalidchar {\n color: #ff0000;\n }\n\n .CodeMirror-composing {\n border-bottom: 0.125rem solid;\n }\n\n /* Default styles for common addons */\n\n div.CodeMirror span.CodeMirror-matchingbracket {\n color: #00bb00;\n }\n div.CodeMirror span.CodeMirror-nonmatchingbracket {\n color: #aa2222;\n }\n .CodeMirror-matchingtag {\n background: rgba(255, 150, 0, 0.3);\n }\n .CodeMirror-activeline-background {\n background: #e8f2ff;\n }\n\n /* STOP */\n\n /* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n .CodeMirror-scroll {\n overflow: scroll !important;\n margin-bottom: -3.125rem;\n margin-right: -3.125rem;\n padding-bottom: 3.125rem;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n }\n .CodeMirror-sizer {\n position: relative;\n border-right: 3.125rem solid transparent;\n }\n\n /* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n .CodeMirror-vscrollbar,\n .CodeMirror-hscrollbar,\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n }\n .CodeMirror-vscrollbar {\n right: 0;\n top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n }\n .CodeMirror-hscrollbar {\n bottom: 0;\n left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n }\n .CodeMirror-scrollbar-filler {\n right: 0;\n bottom: 0;\n }\n .CodeMirror-gutter-filler {\n left: 0;\n bottom: 0;\n }\n .CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -3.125rem;\n }\n .CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n }\n .CodeMirror-gutter-background {\n position: absolute;\n top: 0;\n bottom: 0;\n z-index: 4;\n }\n .CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n }\n .CodeMirror-gutter-wrapper ::selection {\n background-color: transparent;\n }\n .CodeMirror-gutter-wrapper ::-moz-selection {\n background-color: transparent;\n }\n\n .CodeMirror pre.CodeMirror-line,\n .CodeMirror pre.CodeMirror-line-like {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0;\n -webkit-border-radius: 0;\n border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n }\n .CodeMirror-wrap pre.CodeMirror-line,\n .CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n }\n\n .CodeMirror-linebackground {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n z-index: 0;\n }\n\n .CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.006rem; /* Force widget margins to stay inside of the container */\n }\n\n .CodeMirror-rtl pre {\n direction: rtl;\n }\n\n .CodeMirror-code {\n outline: none;\n }\n\n /* Force content-box sizing for the elements where we expect it */\n .CodeMirror-scroll,\n .CodeMirror-sizer,\n .CodeMirror-gutter,\n .CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n }\n\n .CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n\n .CodeMirror-measure pre {\n position: static;\n }\n\n div.CodeMirror-dragcursors {\n visibility: visible;\n }\n\n .CodeMirror-selected {\n background: #d9d9d9;\n }\n .CodeMirror-focused .CodeMirror-selected {\n background: #d7d4f0;\n }\n .CodeMirror-focused {\n border-color: ${base.palette.interactive} !important;\n }\n .CodeMirror:not(.CodeMirror-focused) .CodeMirror-cursors {\n visibility: hidden;\n }\n .CodeMirror-crosshair {\n cursor: crosshair;\n }\n .CodeMirror-line::selection,\n .CodeMirror-line > span::selection,\n .CodeMirror-line > span > span::selection {\n background: #d7d4f0;\n }\n .CodeMirror-line::-moz-selection,\n .CodeMirror-line > span::-moz-selection,\n .CodeMirror-line > span > span::-moz-selection {\n background: #d7d4f0;\n }\n\n .cm-searching {\n background-color: rgba(255, 255, 0, 0.4);\n }\n\n /* Used to force a border model for a node */\n .cm-force-border {\n padding-right: 0.006rem;\n }\n\n /* See issue #2901 */\n .cm-tab-wrap-hack::after {\n content: '';\n }\n\n /* Help users use markselection to safely style text background */\n span.CodeMirror-selectedtext {\n background: none;\n }\n\n .CodeMirror {\n overflow: hidden;\n font-family: monospace;\n direction: ltr;\n position: relative;\n background-color: ${base.palette['background-color']};\n color: ${base.palette['foreground-color']};\n border: 0.0625rem solid ${base.palette['border-line']};\n border-radius: calc(0.5 * ${base['border-radius']});\n ${errors &&\n css`\n border-color: ${errorBackground};\n `}\n ${readOnly &&\n css`\n background-color: ${readOnlyBackgroundColor};\n `}\n }\n\n .cm-ex-context {\n color: ${base.palette.interactive};\n }\n .cm-ex-operator {\n color: ${base.palette.warn};\n font-weight: bold;\n }\n .cm-ex-ruleName {\n color: ${base.palette.success};\n }\n .cm-ex-delimeter {\n color: ${base.palette['foreground-color']};\n }\n .cm-ex-constant {\n color: ${base.palette.pending};\n }\n\n .CodeMirror-hints {\n position: absolute;\n z-index: 10;\n transition: height ${base.animation.speed} ${base.animation.timing.ease};\n padding: 0;\n border-radius: calc(0.5 * ${base['border-radius']});\n box-shadow: ${base.shadow.low};\n border: 0.0625rem solid ${base.palette['border-line']};\n background-color: ${base.palette['primary-background']};\n font-size: ${fontSizes.s};\n max-height: 12rem;\n overflow-y: auto;\n min-width: 8rem;\n }\n\n .CodeMirror-hint {\n ${(isLoading || suggestions?.length === 0) &&\n css`\n pointer-events: none;\n `}\n min-height: 1.2rem;\n width: calc(1.5 * ${base['content-width'].xs});\n cursor: pointer;\n @media (pointer: coarse) {\n min-height: 1.2rem;\n }\n line-height: 1.2rem;\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n padding-inline: ${base.spacing};\n }\n\n ${!isLoading &&\n suggestions?.length > 0 &&\n css`\n li.CodeMirror-hint-active {\n background-color: ${activeColor};\n }\n `}\n `;\n }\n);\n\nStyledCodeEditor.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { ShowHintOptions, EditorConfiguration, Position } from 'codemirror';
|
|
3
3
|
import { MenuItemProps } from '@pega/cosmos-react-core';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type AutoCompleteTriggerChar = '@' | '.' | ':';
|
|
5
|
+
export type SuggestionType = Pick<MenuItemProps, 'primary' | 'secondary' | 'id'>;
|
|
6
6
|
export interface EditorState {
|
|
7
7
|
getValue: () => string | undefined;
|
|
8
8
|
insertText: (text: string) => void;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type CursorPosition = Pick<Position, 'ch' | 'line'>;
|
|
11
11
|
export interface CodeEditorProps {
|
|
12
12
|
/** Default expression to set in the code editor */
|
|
13
13
|
defaultValue?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.types.d.ts","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,
|
|
1
|
+
{"version":3,"file":"CodeEditor.types.d.ts","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO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;IACxD,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yBAAyB,CAAC,EAAE,QAAQ,CAAC;CACtC"}
|
|
@@ -5,7 +5,7 @@ import ExpressionList from './ExpressionList';
|
|
|
5
5
|
import { StyledExpressionBuilder } from './ExpressionBuilder.styles';
|
|
6
6
|
import CodeEditor from './CodeEditor/CodeEditor';
|
|
7
7
|
import ExpressionBuilderContext from './ExpressionBuilderContext';
|
|
8
|
-
const ExpressionBuilder = forwardRef(({ list, search, errors, defaultValue, handle, fetchSuggestions, loading, readOnly, onChange, ...restProps }, ref)
|
|
8
|
+
const ExpressionBuilder = forwardRef(function ExpressionBuilder({ list, search, errors, defaultValue, handle, fetchSuggestions, loading, readOnly, onChange, ...restProps }, ref) {
|
|
9
9
|
const t = useI18n();
|
|
10
10
|
const codeEditorHandle = useRef(null);
|
|
11
11
|
const getExpression = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionBuilder.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,mBAAmB,EACnB,OAAO,EACP,MAAM,EACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,IAAI,EAEJ,WAAW,EACX,OAAO,EACP,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE,MAAM,iBAAiB,GAA6D,UAAU,CAC5F,
|
|
1
|
+
{"version":3,"file":"ExpressionBuilder.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionBuilder.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAG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E;wBACjB,IAAI,EAAE,YAAY;wBAClB,QAAQ;qBACT,EACD,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,gBACN,CAAC,CAAC,mBAAmB,CAAC,GAClC,GACG,IACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useImperativeHandle,\n useMemo,\n useRef\n} from 'react';\n\nimport {\n Flex,\n ForwardProps,\n SearchInput,\n useI18n,\n VisuallyHiddenText\n} from '@pega/cosmos-react-core';\n\nimport { ExpressionItemProps, ExpressionBuilderProps } from './ExpressionBuilder.types';\nimport { EditorState } from './CodeEditor/CodeEditor.types';\nimport ExpressionList from './ExpressionList';\nimport { StyledExpressionBuilder } from './ExpressionBuilder.styles';\nimport CodeEditor from './CodeEditor/CodeEditor';\nimport ExpressionBuilderContext from './ExpressionBuilderContext';\n\nconst ExpressionBuilder: FunctionComponent<ExpressionBuilderProps & ForwardProps> = forwardRef(\n function ExpressionBuilder(\n {\n list,\n search,\n errors,\n defaultValue,\n handle,\n fetchSuggestions,\n loading,\n readOnly,\n onChange,\n ...restProps\n }: PropsWithoutRef<ExpressionBuilderProps>,\n ref: ExpressionBuilderProps['ref']\n ) {\n const t = useI18n();\n const codeEditorHandle = useRef<EditorState>(null);\n\n const getExpression = () => {\n return codeEditorHandle.current?.getValue() || '';\n };\n\n useImperativeHandle(\n handle,\n () => ({\n getExpression\n }),\n [getExpression]\n );\n\n const addExpression = (expression: string) => {\n codeEditorHandle.current?.insertText(expression);\n };\n const onItemAdd = (id: ExpressionItemProps['id']) => {\n list.onItemAdd(id, addExpression);\n };\n\n const ctxValue = useMemo(\n () => ({\n accent: search.accent\n }),\n [search.accent]\n );\n\n return (\n <Flex\n {...restProps}\n as={StyledExpressionBuilder}\n ref={ref}\n container={{\n justify: 'between',\n colGap: 2,\n pad: 1\n }}\n item={{\n grow: 1\n }}\n >\n {!readOnly && (\n <VisuallyHiddenText aria-live='polite' role='status'>\n {t('results_count', [list.items?.length || 0], { count: list.items?.length || 0 })}\n </VisuallyHiddenText>\n )}\n {/* Column 1 */}\n {!readOnly && (\n <Flex\n container={{\n direction: 'column',\n justify: 'between',\n gap: 1\n }}\n item={{\n grow: 1,\n basis: '50%'\n }}\n >\n <SearchInput {...search} />\n <ExpressionBuilderContext.Provider value={ctxValue}>\n <ExpressionList {...list} onItemAdd={onItemAdd} />\n </ExpressionBuilderContext.Provider>\n </Flex>\n )}\n {/* Column 2 */}\n <Flex\n container={{\n direction: 'column',\n justify: 'between'\n }}\n item={{\n grow: 1,\n basis: '50%'\n }}\n >\n <CodeEditor\n fetchSuggestions={fetchSuggestions}\n codeEditorHandle={codeEditorHandle}\n autoCompleteTriggers={['.', '@', ':']}\n editorConfigProps={{\n mode: 'expression',\n readOnly\n }}\n defaultValue={defaultValue}\n loading={loading}\n errors={errors}\n readOnly={readOnly}\n onChange={onChange}\n aria-label={t('expression_editor')}\n />\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default ExpressionBuilder;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionDetails.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAwB,YAAY,EAAiB,MAAM,yBAAyB,CAAC;AAE5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"ExpressionDetails.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAwB,YAAY,EAAiB,MAAM,yBAAyB,CAAC;AAE5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,GAAG,YAAY,CAiC/E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { FieldValueList, Flex, Text, useI18n } from '@pega/cosmos-react-core';
|
|
4
4
|
import { StyledExpressionDetails, StyledInputParamsGroup, StyledParamsGroup } from './ExpressionBuilder.styles';
|
|
5
|
-
const ExpressionDetails = forwardRef(({ primary, inputParams, outputParams, ...restProps }, ref)
|
|
5
|
+
const ExpressionDetails = forwardRef(function ExpressionDetails({ primary, inputParams, outputParams, ...restProps }, ref) {
|
|
6
6
|
const t = useI18n();
|
|
7
7
|
return (_jsxs(Flex, { ...restProps, ref: ref, container: { direction: 'column' }, as: StyledExpressionDetails, children: [_jsx(FieldValueList, { fields: primary }), outputParams && (_jsxs(StyledParamsGroup, { children: [_jsx(Text, { variant: 'h4', children: t('output_parameters') }), _jsx(FieldValueList, { fields: outputParams })] })), inputParams && (_jsxs(StyledInputParamsGroup, { children: [_jsx(Text, { variant: 'h4', children: t('input_parameters') }), _jsx(Flex, { container: { direction: 'column', gap: 1 }, children: inputParams.map(({ id, renderer: Renderer, rendererProps }) => {
|
|
8
8
|
return _jsx(Renderer, { ...rendererProps }, id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionDetails.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionDetails.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,IAAI,EAAgB,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG5F,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,iBAAiB,GAA6D,UAAU,CAC5F,
|
|
1
|
+
{"version":3,"file":"ExpressionDetails.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionDetails.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,IAAI,EAAgB,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG5F,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,iBAAiB,GAA6D,UAAU,CAC5F,SAAS,iBAAiB,CACxB,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,EACpD,GAAkC;IAElC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,OAAO,CACL,MAAC,IAAI,OACC,SAAS,EACb,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,EAAE,EAAE,uBAAuB,aAE3B,KAAC,cAAc,IAAC,MAAM,EAAE,OAAO,GAAI,EAClC,YAAY,IAAI,CACf,MAAC,iBAAiB,eAChB,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,CAAC,CAAC,mBAAmB,CAAC,GAAQ,EAClD,KAAC,cAAc,IAAC,MAAM,EAAE,YAAY,GAAI,IACtB,CACrB,EACA,WAAW,IAAI,CACd,MAAC,sBAAsB,eACrB,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,CAAC,CAAC,kBAAkB,CAAC,GAAQ,EACjD,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,YAC7C,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE;4BAC7D,OAAO,KAAC,QAAQ,OAAc,aAAa,IAArB,EAAE,CAAuB,CAAC;wBAClD,CAAC,CAAC,GACG,IACgB,CAC1B,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent } from 'react';\n\nimport { FieldValueList, Flex, ForwardProps, Text, useI18n } from '@pega/cosmos-react-core';\n\nimport { ExpressionDetailsProps } from './ExpressionBuilder.types';\nimport {\n StyledExpressionDetails,\n StyledInputParamsGroup,\n StyledParamsGroup\n} from './ExpressionBuilder.styles';\n\nconst ExpressionDetails: FunctionComponent<ExpressionDetailsProps & ForwardProps> = forwardRef(\n function ExpressionDetails(\n { primary, inputParams, outputParams, ...restProps },\n ref: ExpressionDetailsProps['ref']\n ) {\n const t = useI18n();\n return (\n <Flex\n {...restProps}\n ref={ref}\n container={{ direction: 'column' }}\n as={StyledExpressionDetails}\n >\n <FieldValueList fields={primary} />\n {outputParams && (\n <StyledParamsGroup>\n <Text variant='h4'>{t('output_parameters')}</Text>\n <FieldValueList fields={outputParams} />\n </StyledParamsGroup>\n )}\n {inputParams && (\n <StyledInputParamsGroup>\n <Text variant='h4'>{t('input_parameters')}</Text>\n <Flex container={{ direction: 'column', gap: 1 }}>\n {inputParams.map(({ id, renderer: Renderer, rendererProps }) => {\n return <Renderer key={id} {...rendererProps} />;\n })}\n </Flex>\n </StyledInputParamsGroup>\n )}\n </Flex>\n );\n }\n);\n\nexport default ExpressionDetails;\n"]}
|
|
@@ -4,7 +4,7 @@ import { forwardRef, useState } from 'react';
|
|
|
4
4
|
import { EmptyState } from '@pega/cosmos-react-core';
|
|
5
5
|
import ExpressionItem from './ExpressionItem';
|
|
6
6
|
import { StyledExpressionList } from './ExpressionBuilder.styles';
|
|
7
|
-
const ExpressionList = forwardRef(({ items, emptyText, onItemAdd, onItemExpand, onItemCollapse, details, ...restProps }, ref)
|
|
7
|
+
const ExpressionList = forwardRef(function ExpressionList({ items, emptyText, onItemAdd, onItemExpand, onItemCollapse, details, ...restProps }, ref) {
|
|
8
8
|
const [expandedItems, setExpandedItems] = useState([]);
|
|
9
9
|
const handleItemExpand = (id) => {
|
|
10
10
|
setExpandedItems(prev => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionList.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAgB,MAAM,yBAAyB,CAAC;AAGnE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,cAAc,GAA0D,UAAU,CACtF,
|
|
1
|
+
{"version":3,"file":"ExpressionList.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/ExpressionList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAgB,MAAM,yBAAyB,CAAC;AAGnE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,cAAc,GAA0D,UAAU,CACtF,SAAS,cAAc,CACrB,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EACpF,GAA+B;IAE/B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAA8B,EAAE,CAAC,CAAC;IAEpF,MAAM,gBAAgB,GAAG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AAC,CAAC,CAAC,CACF,KAAC,UAAU,IAAC,OAAO,EAAE,SAAS,GAAI,CACnC,GACoB,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, useState } from 'react';\n\nimport { EmptyState, ForwardProps } from '@pega/cosmos-react-core';\n\nimport { ExpressionItemProps, ExpressionListProps } from './ExpressionBuilder.types';\nimport ExpressionItem from './ExpressionItem';\nimport { StyledExpressionList } from './ExpressionBuilder.styles';\n\nconst ExpressionList: FunctionComponent<ExpressionListProps & ForwardProps> = forwardRef(\n function ExpressionList(\n { items, emptyText, onItemAdd, onItemExpand, onItemCollapse, details, ...restProps },\n ref: ExpressionListProps['ref']\n ) {\n const [expandedItems, setExpandedItems] = useState<ExpressionItemProps['id'][]>([]);\n\n const handleItemExpand = (id: ExpressionItemProps['id']) => {\n setExpandedItems(prev => {\n const itemIndex = prev.indexOf(id);\n if (itemIndex !== -1) return prev;\n onItemExpand?.(id);\n return [...prev, id];\n });\n };\n\n const handleItemCollapse = (id: ExpressionItemProps['id']) => {\n setExpandedItems(prev => {\n const itemIndex = prev.indexOf(id);\n if (itemIndex === -1) return prev;\n onItemCollapse?.(id);\n return prev.filter(itemId => itemId !== id);\n });\n };\n\n return (\n <StyledExpressionList {...restProps} ref={ref}>\n {items && items.length > 0 ? (\n items.map(item => {\n return (\n <ExpressionItem\n {...item}\n onAdd={onItemAdd}\n onExpand={handleItemExpand}\n onCollapse={handleItemCollapse}\n expanded={expandedItems.includes(item.id)}\n key={item.id}\n details={details?.[item.id]}\n />\n );\n })\n ) : (\n <EmptyState message={emptyText} />\n )}\n </StyledExpressionList>\n );\n }\n);\n\nexport default ExpressionList;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default } from './ExpressionBuilder';
|
|
2
|
-
export { ExpressionListProps, ExpressionItemProps, ExpressionBuilderProps, HandleValue, InputParams } from './ExpressionBuilder.types';
|
|
3
|
-
export { EditorState, CodeEditorProps, AutoCompleteTriggerChar, SuggestionType, CursorPosition } from './CodeEditor/CodeEditor.types';
|
|
2
|
+
export type { ExpressionListProps, ExpressionItemProps, ExpressionBuilderProps, HandleValue, InputParams } from './ExpressionBuilder.types';
|
|
3
|
+
export type { EditorState, CodeEditorProps, AutoCompleteTriggerChar, SuggestionType, CursorPosition } from './CodeEditor/CodeEditor.types';
|
|
4
4
|
export { default as ExpressionItem } from './ExpressionItem';
|
|
5
5
|
export { default as ExpressionList } from './ExpressionList';
|
|
6
6
|
export { default as ExpressionDetails } from './ExpressionDetails';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,cAAc,EACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAe9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { default } from './ExpressionBuilder';\nexport {\n ExpressionListProps,\n ExpressionItemProps,\n ExpressionBuilderProps,\n HandleValue,\n InputParams\n} from './ExpressionBuilder.types';\nexport {\n EditorState,\n CodeEditorProps,\n AutoCompleteTriggerChar,\n SuggestionType,\n CursorPosition\n} from './CodeEditor/CodeEditor.types';\nexport { default as ExpressionItem } from './ExpressionItem';\nexport { default as ExpressionList } from './ExpressionList';\nexport { default as ExpressionDetails } from './ExpressionDetails';\nexport { default as CodeEditor } from './CodeEditor/CodeEditor';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ExpressionBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAe9C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { default } from './ExpressionBuilder';\nexport type {\n ExpressionListProps,\n ExpressionItemProps,\n ExpressionBuilderProps,\n HandleValue,\n InputParams\n} from './ExpressionBuilder.types';\nexport type {\n EditorState,\n CodeEditorProps,\n AutoCompleteTriggerChar,\n SuggestionType,\n CursorPosition\n} from './CodeEditor/CodeEditor.types';\nexport { default as ExpressionItem } from './ExpressionItem';\nexport { default as ExpressionList } from './ExpressionList';\nexport { default as ExpressionDetails } from './ExpressionDetails';\nexport { default as CodeEditor } from './CodeEditor/CodeEditor';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNode.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAmC,MAAM,OAAO,CAAC;AAYxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,eAAO,MAAM,SAAS;eAA6B,OAAO;SAWxD,CAAC;AAIH,eAAO,MAAM,UAAU,mOAEtB,CAAC;AAEF,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"AddNode.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAmC,MAAM,OAAO,CAAC;AAYxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,eAAO,MAAM,SAAS;eAA6B,OAAO;SAWxD,CAAC;AAIH,eAAO,MAAM,UAAU,mOAEtB,CAAC;AAEF,eAAO,MAAM,aAAa,yGASxB,CAAC;AAIH,eAAO,MAAM,YAAY,qOA0BvB,CAAC;AAIH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,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,CAgC5E,CAAC"}
|
|
@@ -22,11 +22,10 @@ export const StyledPlus = styled(Icon) `
|
|
|
22
22
|
export const StyledWrapper = styled.div(({ theme }) => {
|
|
23
23
|
return css `
|
|
24
24
|
margin-block-start: ${theme.base.spacing};
|
|
25
|
+
|
|
25
26
|
${StyledTooltip} {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
text-align: center;
|
|
29
|
-
`}
|
|
27
|
+
min-width: 12ch;
|
|
28
|
+
text-align: center;
|
|
30
29
|
}
|
|
31
30
|
`;
|
|
32
31
|
});
|
|
@@ -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;AAChD,OAAO,EAAkB,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACL,MAAM,yBAAyB,CAAC;AAGjC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAyB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IACrF,OAAO,GAAG,CAAA;;aAEC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;MACnC,SAAS;QACX,GAAG,CAAA;;iBAEU,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;;KAEtC;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;C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,CAAC;QACvB,cAAc,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,eAAe,EAAE;YACpB,gBAAgB,CAAC,KAAK,CAAC,CAAC;SACzB;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,OAAO,CACL,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,aAAa,YACvD,MAAC,YAAY,IACX,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,mBACL,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAC7C,IAAI,QACJ,OAAO,EAAE,mBAAmB,aAE5B,KAAC,SAAS,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAE,SAAS,GAAI,EACvD,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,GAAG,IACb,GACV,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { FC, MouseEvent, useContext, useState, useEffect } 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 { PlottedGraphNode } from './Renderer/Utils/GraphLayout';\nimport FlowModellerContext from './FlowModellerContext';\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)`\n opacity: 0;\n`;\n\nexport const StyledWrapper = styled.div(({ theme }) => {\n return css`\n margin-block-start: ${theme.base.spacing};\n\n ${StyledTooltip} {\n min-width: 12ch;\n text-align: center;\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 &:hover,\n &:focus {\n background: ${theme.base.colors.white};\n ${StyledDot} {\n opacity: 0;\n }\n ${StyledPlus} {\n opacity: 1;\n }\n }\n &[aria-haspopup='menu'] {\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 PlottedGraphNode {\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 const [hasMenuActive, setHasMenuActive] = useState(false);\n const { showNodeLibrary } = useContext(FlowModellerContext);\n\n const addNodeClickHandler = (e: MouseEvent<HTMLButtonElement>) => {\n setHasMenuActive(true);\n addNodeHandler(e);\n };\n\n useEffect(() => {\n if (!showNodeLibrary) {\n setHasMenuActive(false);\n }\n }, [showNodeLibrary]);\n\n return (\n <Flex container={{ justify: 'center' }} as={StyledWrapper}>\n <StyledButton\n label={t('add_node')}\n aria-haspopup={hasMenuActive ? 'menu' : false}\n icon\n onClick={addNodeClickHandler}\n >\n <StyledDot name='circle-solid' highlight={highlight} />\n <StyledPlus name='plus' />\n </StyledButton>\n </Flex>\n );\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PlaceHolderConnector } from './Utils/addNodeUtils';
|
|
3
3
|
import { PlottedGraphConnector } from './Renderer/Utils/GraphLayout';
|
|
4
|
-
|
|
5
|
-
declare const Connector: ({ id, labelLayout, data, realConnectors, points }: ConnectorProps) => JSX.Element;
|
|
4
|
+
type ConnectorProps = Pick<PlottedGraphConnector, 'id' | 'data' | 'labelLayout' | 'points'> & Partial<Pick<PlaceHolderConnector, 'realConnectors'>>;
|
|
5
|
+
declare const Connector: ({ id, labelLayout, data, realConnectors, points }: ConnectorProps) => JSX.Element | null;
|
|
6
6
|
export default Connector;
|
|
7
7
|
//# sourceMappingURL=Connector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AA0ErE,
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AA0ErE,KAAK,cAAc,GAAG,IAAI,CAAC,qBAAqB,EAAE,IAAI,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC,GACzF,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAExD,QAAA,MAAM,SAAS,sDAAuD,cAAc,uBA8CnF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { defaultThemeProp, Flex, Text, useTheme } from '@pega/cosmos-react-core';
|
|
@@ -63,9 +63,7 @@ const Connector = ({ id, labelLayout, data, realConnectors, points }) => {
|
|
|
63
63
|
refType: 'connector',
|
|
64
64
|
refId
|
|
65
65
|
};
|
|
66
|
-
return
|
|
67
|
-
? theme.base.colors.red.medium
|
|
68
|
-
: theme.base.colors.slate.dark, strokeWidth: highlights?.connectors?.[id] ? 2 : 1, fill: 'none' }), labelLayout && (_jsxs("foreignObject", { x: labelLayout.x - labelLayout.width, y: points[3].y - 20, width: labelLayout.width, height: labelLayout.height, children: [labelLayout?.value && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledLabel, { highlight: !!highlights?.connectors?.[id], children: labelLayout.value }) })), !readOnly && (_jsx(AddButton, { highlight: !!highlights?.connectors?.[id], addNodeHandler: (e) => data?.onNodeCreate(e.currentTarget, metaData) }))] }))] }, id)) }));
|
|
66
|
+
return data.type === 'default' ? (_jsxs("g", { children: [_jsx("path", { id: id, d: genLine(points), stroke: highlights?.connectors?.[id] ? theme.base.colors.red.medium : theme.base.colors.slate.dark, strokeWidth: highlights?.connectors?.[id] ? 2 : 1, fill: 'none' }), labelLayout && (_jsxs("foreignObject", { x: labelLayout.x - labelLayout.width, y: points[3].y - 20, width: labelLayout.width, height: labelLayout.height, children: [labelLayout?.value && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledLabel, { highlight: !!highlights?.connectors?.[id], children: labelLayout.value }) })), !readOnly && (_jsx(AddButton, { highlight: !!highlights?.connectors?.[id], addNodeHandler: (e) => data?.onNodeCreate(e.currentTarget, metaData) }))] }))] }, id)) : null;
|
|
69
67
|
};
|
|
70
68
|
export default Connector;
|
|
71
69
|
//# sourceMappingURL=Connector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connector.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mapp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AAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EACnB,KAAK,EAAE,WAAW,CAAC,KAAK,EACxB,MAAM,EAAE,WAAW,CAAC,MAAM,aAEzB,WAAW,EAAE,KAAK,IAAI,CACrB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YACpC,KAAC,WAAW,IAAC,SAAS,EAAE,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,YACnD,WAAW,CAAC,KAAK,GACN,GACT,CACR,EACA,CAAC,QAAQ,IAAI,CACZ,KAAC,SAAS,IACR,SAAS,EAAE,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EACzC,cAAc,EAAE,CAAC,CAAgC,EAAE,EAAE,CACnD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,GAE/C,CACH,IACa,CACjB,KAjCK,EAAE,CAkCN,CACL,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { MouseEvent, useContext } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Flex, Text, useTheme } from '@pega/cosmos-react-core';\n\nimport { AddButton } from './AddNode';\nimport { AddNodeHandlerParams } from './Renderer/Renderer.types';\nimport { PlaceHolderConnector } from './Utils/addNodeUtils';\nimport FlowModellerContext from './FlowModellerContext';\nimport { PlottedGraphConnector } from './Renderer/Utils/GraphLayout';\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\ninterface Points {\n x: number;\n y: number;\n}\n\nconst curveRadius = 12;\nconst genLine = (points: Points[]) => {\n const lineStr: string = points\n .map((point: Points, idx: number, arr: Points[]) => {\n const { x, y } = point;\n const prev = arr[idx - 1];\n const next = arr[idx + 1];\n const line = `L${x},${y}`;\n\n // if the point is extreme end, no need to add a curve\n if (!prev || !next) return line;\n\n // if point is colinear with prev and next, no need to add a curve\n if (prev.x === next.x || prev.y === next.y) return line;\n\n if (point.x > next.x)\n // BOTTOM-RIGHT ↲\n return `L${x},${\n y - curveRadius\n }a${curveRadius},${curveRadius} 0 0 1 -${curveRadius},${curveRadius}`;\n\n // BOTTOM-LEFT ↳\n if (point.x < next.x)\n return `L${x},${\n y - curveRadius\n }a${curveRadius},${curveRadius} 0 0 0 ${curveRadius},${curveRadius}`;\n\n // TOP-LEFT ↱\n if (point.x < prev.x)\n return `L${\n x + curveRadius\n },${y}a${curveRadius},${curveRadius} 0 0 0 -${curveRadius},${curveRadius}`;\n\n // TOP-RIGHT ↴\n if (point.x > prev.x)\n return `L${\n x - curveRadius\n },${y}a${curveRadius},${curveRadius} 0 0 1 ${curveRadius},${curveRadius}`;\n\n return `L${x},${y}`;\n })\n .join('');\n return `M${lineStr.substr(1)}`;\n};\n\ntype ConnectorProps = Pick<PlottedGraphConnector, 'id' | 'data' | 'labelLayout' | 'points'> &\n Partial<Pick<PlaceHolderConnector, 'realConnectors'>>;\n\nconst Connector = ({ id, labelLayout, data, realConnectors, points }: ConnectorProps) => {\n const refId = realConnectors || id;\n const { readOnly, highlights } = useContext(FlowModellerContext);\n const theme = useTheme();\n\n const metaData: AddNodeHandlerParams = {\n refType: 'connector',\n refId\n };\n return data.type === 'default' ? (\n <g key={id}>\n <path\n id={id}\n d={genLine(points)}\n stroke={\n highlights?.connectors?.[id] ? theme.base.colors.red.medium : theme.base.colors.slate.dark\n }\n strokeWidth={highlights?.connectors?.[id] ? 2 : 1}\n fill='none'\n />\n {labelLayout && (\n <foreignObject\n x={labelLayout.x - labelLayout.width}\n y={points[3].y - 20}\n width={labelLayout.width}\n height={labelLayout.height}\n >\n {labelLayout?.value && (\n <Flex container={{ justify: 'center' }}>\n <StyledLabel highlight={!!highlights?.connectors?.[id]}>\n {labelLayout.value}\n </StyledLabel>\n </Flex>\n )}\n {!readOnly && (\n <AddButton\n highlight={!!highlights?.connectors?.[id]}\n addNodeHandler={(e: MouseEvent<HTMLButtonElement>) =>\n data?.onNodeCreate(e.currentTarget, metaData)\n }\n />\n )}\n </foreignObject>\n )}\n </g>\n ) : null;\n};\n\nexport default Connector;\n"]}
|