@pega/cosmos-react-build 4.0.0-dev.2.0 → 4.0.0-dev.20.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 +3 -2
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +42 -80
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +12 -16
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +208 -283
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +63 -31
- 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/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +3 -5
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.d.ts.map +1 -0
- package/lib/components/AppShell/Header/AppHeader.js +73 -0
- package/lib/components/AppShell/Header/AppHeader.js.map +1 -0
- package/lib/components/{AppHeader → AppShell/Header}/AppHeader.styles.d.ts +7 -7
- package/lib/components/AppShell/Header/AppHeader.styles.d.ts.map +1 -0
- package/lib/components/AppShell/Header/AppHeader.styles.js +158 -0
- package/lib/components/AppShell/Header/AppHeader.styles.js.map +1 -0
- package/lib/components/{AppHeader → AppShell/Header}/AppHeader.types.d.ts +6 -5
- package/lib/components/AppShell/Header/AppHeader.types.d.ts.map +1 -0
- package/lib/components/AppShell/Header/AppHeader.types.js.map +1 -0
- package/lib/components/AppShell/Header/BranchButton.d.ts.map +1 -0
- package/lib/components/{AppHeader → AppShell/Header}/BranchButton.js +5 -5
- package/lib/components/AppShell/Header/BranchButton.js.map +1 -0
- package/lib/components/AppShell/NavigationList.d.ts +6 -0
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -0
- package/lib/components/AppShell/NavigationList.js +97 -0
- package/lib/components/AppShell/NavigationList.js.map +1 -0
- package/lib/components/AppShell/index.d.ts +3 -1
- 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.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js +27 -27
- 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/ExpressionBuilder/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js +17 -33
- 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 +4 -3
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.js.map +1 -1
- package/lib/components/ExpressionBuilder/index.d.ts +1 -1
- 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.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/NodeTemplate.styles.d.ts +5 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js +10 -3
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.js +11 -29
- 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/ItemLibrary/ItemLibrary.d.ts.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.js +2 -2
- 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 +2 -2
- package/lib/components/LifeCycle/Category.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 +1 -1
- 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 +4 -10
- package/lib/components/LifeCycle/Stage.js.map +1 -1
- package/lib/components/LifeCycle/Step.d.ts +6 -2
- package/lib/components/LifeCycle/Step.d.ts.map +1 -1
- package/lib/components/LifeCycle/Step.js +30 -24
- 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 +6 -12
- package/lib/components/LifeCycle/Task.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.d.ts +0 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js +5 -16
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts +5 -3
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.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 +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.d.ts +11 -3
- package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.js +50 -14
- package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.d.ts +9 -11
- package/lib/components/ObjectSelect/useCreateModal.d.ts.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.js +5 -6
- package/lib/components/ObjectSelect/useCreateModal.js.map +1 -1
- package/lib/components/PageBanner/PageBanner.d.ts +22 -0
- package/lib/components/PageBanner/PageBanner.d.ts.map +1 -0
- package/lib/components/PageBanner/PageBanner.js +59 -0
- package/lib/components/PageBanner/PageBanner.js.map +1 -0
- package/lib/components/PageBanner/index.d.ts +3 -0
- package/lib/components/PageBanner/index.d.ts.map +1 -0
- package/lib/components/PageBanner/index.js +2 -0
- package/lib/components/PageBanner/index.js.map +1 -0
- package/lib/components/PageTemplates/GalleryPage.d.ts +10 -10
- package/lib/components/PageTemplates/GalleryPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/GalleryPage.js +35 -11
- 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 +8 -45
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/PageTemplates/ShowcasePage.d.ts +16 -0
- package/lib/components/PageTemplates/ShowcasePage.d.ts.map +1 -0
- package/lib/components/PageTemplates/ShowcasePage.js +29 -0
- package/lib/components/PageTemplates/ShowcasePage.js.map +1 -0
- package/lib/components/PageTemplates/index.d.ts +3 -1
- package/lib/components/PageTemplates/index.d.ts.map +1 -1
- package/lib/components/PageTemplates/index.js +2 -1
- 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 +4 -7
- package/lib/components/SummaryCard/SummaryCard.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/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/utils.d.ts +1 -1
- package/lib/utils/utils.d.ts.map +1 -1
- package/package.json +16 -9
- package/lib/components/AppHeader/AppHeader.d.ts.map +0 -1
- package/lib/components/AppHeader/AppHeader.js +0 -40
- package/lib/components/AppHeader/AppHeader.js.map +0 -1
- package/lib/components/AppHeader/AppHeader.styles.d.ts.map +0 -1
- package/lib/components/AppHeader/AppHeader.styles.js +0 -118
- package/lib/components/AppHeader/AppHeader.styles.js.map +0 -1
- package/lib/components/AppHeader/AppHeader.types.d.ts.map +0 -1
- package/lib/components/AppHeader/AppHeader.types.js.map +0 -1
- package/lib/components/AppHeader/BranchButton.d.ts.map +0 -1
- package/lib/components/AppHeader/BranchButton.js.map +0 -1
- package/lib/components/AppHeader/index.d.ts +0 -4
- package/lib/components/AppHeader/index.d.ts.map +0 -1
- package/lib/components/AppHeader/index.js +0 -3
- package/lib/components/AppHeader/index.js.map +0 -1
- package/lib/components/PageTemplates/GalleryPage.styles.d.ts +0 -9
- package/lib/components/PageTemplates/GalleryPage.styles.d.ts.map +0 -1
- package/lib/components/PageTemplates/GalleryPage.styles.js +0 -70
- package/lib/components/PageTemplates/GalleryPage.styles.js.map +0 -1
- /package/lib/components/{AppHeader → AppShell/Header}/AppHeader.d.ts +0 -0
- /package/lib/components/{AppHeader → AppShell/Header}/AppHeader.types.js +0 -0
- /package/lib/components/{AppHeader → AppShell/Header}/BranchButton.d.ts +0 -0
|
@@ -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,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outRef,\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 ];\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 /* Used to find the query token which is present before the triggering character\n to get updated list. */\n const cursorLineText = editor.getValue().split('\\n')[currentCursor.line];\n const textTillCursorPos = cursorLineText.substring(0, currentCursor.ch);\n let start = textTillCursorPos?.lastIndexOf(' ');\n if (start === -1) {\n start = 0;\n }\n const currentWord = textTillCursorPos.substring(start, currentCursor.ch);\n\n let regexp;\n if (currentCharacter === '.') {\n regexp = /[\\w$]*(\\.+[\\w$)[\\](]*)+/g;\n } else {\n regexp = /[\\w@'-]*[@:]/g;\n }\n\n const tokenArray = [...currentWord.matchAll(regexp)];\n let queryToken = '';\n if (tokenArray.length > 0) {\n const queryString = tokenArray[tokenArray.length - 1][0];\n queryToken = queryString.substring(0, queryString.length - 1);\n }\n\n newSuggestions = [...(await fetchSuggestions(currentCharacter, queryToken))];\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;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,8CAA8C;QAC9C,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;QACtC,+CAA+C;QAC/C,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;QACtC,+CAA+C;QAC/C,EAAE,KAAK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AAW,CAAC,IAAI,CAAC,CAAC;SACnB;aAAM;YACL,UAAU,EAAE,SAAS,EAAE,CAAC;YACxB,WAAW,CAAC,KAAK,CAAC,CAAC;SACpB;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,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 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,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,I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J,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,aAA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,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,12 +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 type CursorPosition = Pick<Position, 'ch' | 'line'>;
|
|
10
11
|
export interface CodeEditorProps {
|
|
11
12
|
/** Default expression to set in the code editor */
|
|
12
13
|
defaultValue?: string;
|
|
@@ -15,7 +16,7 @@ export interface CodeEditorProps {
|
|
|
15
16
|
/** Enable read only mode */
|
|
16
17
|
readOnly?: boolean;
|
|
17
18
|
/** Fetches suggestion list for suggestions popover */
|
|
18
|
-
fetchSuggestions?: (autoCompleteTrigger: AutoCompleteTriggerChar,
|
|
19
|
+
fetchSuggestions?: (autoCompleteTrigger: AutoCompleteTriggerChar, cursorPosition: CursorPosition) => Promise<SuggestionType[]>;
|
|
19
20
|
/** characters which triggers suggestions */
|
|
20
21
|
autoCompleteTriggers?: AutoCompleteTriggerChar[];
|
|
21
22
|
/** Code editor configuration props */
|
|
@@ -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,EAAE,eAAe,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,MAAM,uBAAuB,GAAG,GAAG,GAAG,GAAG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":3,"file":"CodeEditor.types.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\nimport { ShowHintOptions, EditorConfiguration, Position } from 'codemirror';\n\nimport { MenuItemProps } from '@pega/cosmos-react-core';\n\nexport type AutoCompleteTriggerChar = '@' | '.' | ':';\n\nexport type SuggestionType = Pick<MenuItemProps, 'primary' | 'secondary' | 'id'>;\n\nexport interface EditorState {\n getValue: () => string | undefined;\n insertText: (text: string) => void;\n}\n\nexport interface CodeEditorProps {\n /** Default expression to set in the code editor */\n defaultValue?: string;\n /** Compiled error message */\n errors?: string;\n /** Enable read only mode */\n readOnly?: boolean;\n /** Fetches suggestion list for suggestions popover */\n fetchSuggestions?: (\n autoCompleteTrigger: AutoCompleteTriggerChar,\n
|
|
1
|
+
{"version":3,"file":"CodeEditor.types.js","sourceRoot":"","sources":["../../../../src/components/ExpressionBuilder/CodeEditor/CodeEditor.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\nimport { ShowHintOptions, EditorConfiguration, Position } from 'codemirror';\n\nimport { MenuItemProps } from '@pega/cosmos-react-core';\n\nexport type AutoCompleteTriggerChar = '@' | '.' | ':';\n\nexport type SuggestionType = Pick<MenuItemProps, 'primary' | 'secondary' | 'id'>;\n\nexport interface EditorState {\n getValue: () => string | undefined;\n insertText: (text: string) => void;\n}\n\nexport type CursorPosition = Pick<Position, 'ch' | 'line'>;\n\nexport interface CodeEditorProps {\n /** Default expression to set in the code editor */\n defaultValue?: string;\n /** Compiled error message */\n errors?: string;\n /** Enable read only mode */\n readOnly?: boolean;\n /** Fetches suggestion list for suggestions popover */\n fetchSuggestions?: (\n autoCompleteTrigger: AutoCompleteTriggerChar,\n cursorPosition: CursorPosition\n ) => Promise<SuggestionType[]>;\n /** characters which triggers suggestions */\n autoCompleteTriggers?: AutoCompleteTriggerChar[];\n /** Code editor configuration props */\n editorConfigProps?: EditorConfiguration;\n /** To show loader for intellisense popover */\n loading?: boolean;\n /** Called when editor content changes. */\n onChange?: (expression: string) => void;\n codeEditorHandle: Ref<EditorState>;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport interface EditorHintOptions extends ShowHintOptions {\n suggestions?: SuggestionType[];\n loading?: boolean;\n triggerCharacterCursorPos?: Position;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default } from './ExpressionBuilder';
|
|
2
2
|
export { ExpressionListProps, ExpressionItemProps, ExpressionBuilderProps, HandleValue, InputParams } from './ExpressionBuilder.types';
|
|
3
|
-
export { EditorState, CodeEditorProps } from './CodeEditor/CodeEditor.types';
|
|
3
|
+
export { 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,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,
|
|
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,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,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;
|
|
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 +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;;CAErC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,OAAO,GAAG,CAAA;0BACc,KAAK,CAAC,IAAI,CAAC,OAAO
|
|
1
|
+
{"version":3,"file":"AddNode.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/Add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,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":[],"mappings":";AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,SAAS,EA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,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"]}
|
|
@@ -2,18 +2,18 @@ import { ChangeEvent, Ref } from 'react';
|
|
|
2
2
|
import { PopoverProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import { GraphData } from './Renderer/Utils/Graph';
|
|
4
4
|
import { GraphDataAsMap, DeleteNodeOutcome } from './Utils/deleteNodeUtils';
|
|
5
|
-
export interface
|
|
5
|
+
export interface DeletePopoverProps {
|
|
6
6
|
show: boolean;
|
|
7
7
|
target: PopoverProps['target'];
|
|
8
8
|
flowGraphData: GraphData;
|
|
9
9
|
rendererGraphData: GraphData;
|
|
10
10
|
nodeId: string;
|
|
11
11
|
onChange?: (itemsToDelete: GraphDataAsMap, itemsToRetain: GraphDataAsMap | undefined, ev?: ChangeEvent) => void;
|
|
12
|
-
ref?: Ref<HTMLDivElement>;
|
|
13
12
|
onSubmit?: (outcome: DeleteNodeOutcome, ev: Event) => void;
|
|
14
13
|
onCancel?: () => void;
|
|
14
|
+
ref?: Ref<HTMLDivElement>;
|
|
15
15
|
}
|
|
16
16
|
export declare const StyledDeletePopover: import("styled-components").StyledComponent<(<Modifiers extends string = string>(props: PopoverProps<Modifiers> & import("@pega/cosmos-react-core").ForwardProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null), import("styled-components").DefaultTheme, {}, never>;
|
|
17
|
-
declare const DeletePopover: import("react").ForwardRefExoticComponent<Pick<
|
|
17
|
+
declare const DeletePopover: import("react").ForwardRefExoticComponent<Pick<DeletePopoverProps, "show" | "target" | "onChange" | "onSubmit" | "onCancel" | "flowGraphData" | "rendererGraphData" | "nodeId"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
18
18
|
export default DeletePopover;
|
|
19
19
|
//# sourceMappingURL=DeletePopover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeletePopover.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeletePopover.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"DeletePopover.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeletePopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAIX,GAAG,EACJ,MAAM,OAAO,CAAC;AAGf,OAAO,EASL,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAiB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAwB,EACtB,cAAc,EACd,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC/B,aAAa,EAAE,SAAS,CAAC;IACzB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CACT,aAAa,EAAE,cAAc,EAC7B,aAAa,EAAE,cAAc,GAAG,SAAS,EACzC,EAAE,CAAC,EAAE,WAAW,KACb,IAAI,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,2TAE/B,CAAC;AAEF,QAAA,MAAM,aAAa,kOA+NlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeletePopover.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeletePopover.tsx"],"names":[],"mappings":";AAAA,OAA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,CAAC,CACzB,8BACE,KAAC,IAAI,cAAE,CAAC,CAAC,sBAAsB,CAAC,GAAQ,EACxC,MAAC,MAAM,IACL,EAAE,EAAC,aAAa,EAChB,KAAK,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAC/B,QAAQ,QACR,QAAQ,EAAE,eAAe,aAExB,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oCACjC,OAAO,CACL,KAAC,MAAM,IAAyB,QAAQ,EAAE,gBAAgB,KAAK,KAAK,YACjE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IADrD,IAAI,CAAC,SAAS,CAAC,EAAE,CAErB,CACV,CAAC;gCACJ,CAAC,CAAC,EAEF,KAAC,MAAM,IAAY,QAAQ,EAAE,gBAAgB,KAAK,CAAC,CAAC,YACjD,CAAC,CAAC,qBAAqB,CAAC,IADf,MAAM,CAET,IACF,IACR,CACJ,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,cAAE,CAAC,CAAC,aAAa,CAAC,GAAQ,CAChC,EAED,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aACvD,KAAC,MAAM,IAAC,OAAO,EAAE,eAAe,YAAG,CAAC,CAAC,QAAQ,CAAC,GAAU,EACxD,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,aAAa,YAC7C,CAAC,CAAC,QAAQ,CAAC,GACL,IACJ,IACF,GACa,CACvB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { useState, ChangeEventHandler, ChangeEvent, useEffect, forwardRef, Ref } from 'react';\nimport styled from 'styled-components';\n\nimport {\n Button,\n Select,\n Option,\n Text,\n Flex,\n useI18n,\n Icon,\n Popover,\n PopoverProps\n} from '@pega/cosmos-react-core';\n\nimport { DirectedGraph, GraphData } from './Renderer/Utils/Graph';\nimport deleteNodeUtils, {\n GraphDataAsMap,\n DeleteNodeOutcome,\n DeleteNodeModalOption\n} from './Utils/deleteNodeUtils';\nimport { NodeProps } from './Node/Node.types';\n\nexport interface DeleteNodePopoverProps {\n show: boolean;\n target: PopoverProps['target'];\n flowGraphData: GraphData;\n rendererGraphData: GraphData;\n nodeId: string;\n onChange?: (\n itemsToDelete: GraphDataAsMap,\n itemsToRetain: GraphDataAsMap | undefined,\n ev?: ChangeEvent\n ) => void;\n ref?: Ref<HTMLDivElement>;\n onSubmit?: (outcome: DeleteNodeOutcome, ev: Event) => void;\n onCancel?: () => void;\n}\n\nexport const StyledDeletePopover = styled(Popover)`\n max-width: 25rem;\n`;\n\nconst DeletePopover = forwardRef(\n (\n {\n show,\n target,\n flowGraphData,\n rendererGraphData,\n nodeId,\n onChange,\n onSubmit,\n onCancel\n }: DeleteNodePopoverProps,\n ref: DeleteNodePopoverProps['ref']\n ) => {\n const [currentSelection, setCurrentSelection] = useState<number>(0);\n\n const t = useI18n();\n\n const graph = new DirectedGraph(rendererGraphData);\n\n const deleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(graph, nodeId);\n\n const deleteOptions: DeleteNodeModalOption[] = deleteOptionsResult.options;\n const nodeType = (graph.getNode(nodeId) as NodeProps).type.name;\n\n useEffect(() => {\n if (deleteOptionsResult) {\n const itemsToDelete: GraphDataAsMap =\n nodeType !== 'Decision'\n ? deleteOptionsResult.allItems\n : deleteOptions[currentSelection].restItems;\n\n // add the actual node to be deleted also, to the list\n itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);\n\n onChange?.(itemsToDelete, deleteOptions[currentSelection].pathItems);\n }\n }, [rendererGraphData]);\n\n const onChangeHandler: ChangeEventHandler = (ev: ChangeEvent<HTMLSelectElement>) => {\n const newSelection =\n ev.target.selectedIndex >= deleteOptions.length ? -1 : ev.target.selectedIndex;\n\n setCurrentSelection(newSelection);\n\n let itemsToDelete;\n if (deleteOptionsResult) itemsToDelete = deleteOptionsResult.allItems;\n\n let itemsToRetain;\n\n if (newSelection !== -1) {\n itemsToDelete = deleteOptions[newSelection].restItems;\n itemsToRetain = deleteOptions[newSelection].pathItems;\n }\n\n // add the actual node to be deleted also, to the list\n if (itemsToDelete) itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);\n\n if (itemsToDelete) onChange?.(itemsToDelete, itemsToRetain, ev);\n };\n\n const submitHandler = (ev: Event) => {\n let error = true;\n const finalGraph = new DirectedGraph(flowGraphData);\n const finalDeleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(finalGraph, nodeId);\n\n let newTargetNode = finalDeleteOptionsResult?.destinationNodeId\n ? finalGraph.getNode(finalDeleteOptionsResult.destinationNodeId)\n : undefined;\n let itemsToDelete = finalDeleteOptionsResult.allItems;\n\n const selectedOption =\n currentSelection === -1 || nodeType !== 'Decision'\n ? undefined\n : finalDeleteOptionsResult?.options[currentSelection];\n let finalMetaData = selectedOption;\n\n if (selectedOption) {\n const pathConnectors = selectedOption.pathItems.connectors;\n const connectors = Object.keys(pathConnectors);\n for (let i = 0; i < connectors.length; i += 1) {\n const connectorData = pathConnectors[connectors[i]];\n if (\n connectorData &&\n finalGraph.getNode(connectorData.fromNodeId).type?.minConnectors !== 0 &&\n connectorData.toNodeId === finalDeleteOptionsResult.destinationNodeId\n ) {\n error = false;\n break;\n }\n }\n if (error) {\n onSubmit?.(\n {\n graphData: {\n nodes: [],\n connectors: []\n },\n updates: {\n connectors: []\n },\n deletes: { nodes: {}, connectors: {} },\n error: true\n },\n ev\n );\n return;\n }\n\n finalMetaData = finalDeleteOptionsResult.options.find(\n current => selectedOption.connector.id === current.connector.id\n );\n\n if (finalMetaData) {\n // get the ref of the first node of the retaining path\n newTargetNode = finalGraph.getNode(finalMetaData.connector.toNodeId);\n itemsToDelete = finalMetaData.restItems;\n }\n }\n\n // get the in-connectors of the selected node\n const nodeInConnectors = finalGraph.getInConnectors(nodeId);\n\n // iterate and set the targetNode to the above first node instead of the selected node.\n\n nodeInConnectors.forEach(con => {\n finalGraph.setConnector(con.id, {\n toNodeId: newTargetNode ? newTargetNode.id : undefined\n });\n });\n\n const resultGraphData = finalGraph.getGraphData();\n\n itemsToDelete.nodes[nodeId] = finalGraph.getNode(nodeId);\n\n // filter the highlighted nodes, including the selected node\n const nodes = resultGraphData.nodes.filter(item => {\n return itemsToDelete.nodes[item.id] === undefined;\n });\n\n if (finalMetaData) {\n itemsToDelete.connectors[finalMetaData.connector.id] = finalMetaData.connector;\n }\n\n // filter the highlighted connectors\n const connectors = resultGraphData.connectors.filter(item => {\n return itemsToDelete.connectors[item.id] === undefined;\n });\n\n const outcome: DeleteNodeOutcome = {\n graphData: {\n nodes: nodes as NodeProps[],\n connectors\n },\n updates: {\n connectors: nodeInConnectors\n },\n deletes: itemsToDelete,\n error: false\n };\n onSubmit?.(outcome, ev);\n };\n\n const onCancelHandler = () => {\n onCancel?.();\n };\n\n return (\n <StyledDeletePopover\n show={show}\n target={target}\n placement='right-end'\n ref={ref}\n modifiers={[\n {\n name: 'offset',\n options: { offset: [0, 8] }\n }\n ]}\n >\n <Flex container={{ gap: 2, pad: 2, direction: 'column' }}>\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n <Text variant='h4'>{t('delete_step_title')}</Text>\n <Button variant='simple' icon label={t('close')} onClick={onCancelHandler}>\n <Icon name='times' />\n </Button>\n </Flex>\n {nodeType === 'Decision' ? (\n <>\n <Text>{t('delete_decision_step')}</Text>\n <Select\n id='select-demo'\n label={t('delete_step_outcome')}\n required\n onChange={onChangeHandler}\n >\n {deleteOptions.map((item, index) => {\n return (\n <Option key={item.connector.id} selected={currentSelection === index}>\n {item.connector.label ? item.connector.label : item.connector.id}\n </Option>\n );\n })}\n\n <Option key='none' selected={currentSelection === -1}>\n {t('delete_all_outcomes')}\n </Option>\n </Select>\n </>\n ) : (\n <Text>{t('delete_step')}</Text>\n )}\n\n <Flex container={{ direction: 'row', justify: 'between' }}>\n <Button onClick={onCancelHandler}>{t('cancel')}</Button>\n <Button variant='primary' onClick={submitHandler}>\n {t('delete')}\n </Button>\n </Flex>\n </Flex>\n </StyledDeletePopover>\n );\n }\n);\n\nexport default DeletePopover;\n"]}
|
|
1
|
+
{"version":3,"file":"DeletePopover.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeletePopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EAGR,SAAS,EACT,UAAU,EAGX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,OAAO,EAER,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAa,MAAM,wBAAwB,CAAC;AAClE,OAAO,eAIN,MAAM,yBAAyB,CAAC;AAmBjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;;CAEjD,CAAC;AAEF,MAAM,aAAa,GAAG,UAAU,CAC9B,CACE,EACE,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EAC4B,EACtC,GAA8B,EAC9B,EAAE;IACF,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAEpE,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAEnD,MAAM,mBAAmB,GAAG,eAAe,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEhF,MAAM,aAAa,GAA4B,mBAAmB,CAAC,OAAO,CAAC;IAC3E,MAAM,QAAQ,GAAI,KAAK,CAAC,OAAO,C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AS,EAAC,OAAO,EAAE,aAAa,YAC7C,CAAC,CAAC,QAAQ,CAAC,GACL,IACJ,IACF,GACa,CACvB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n useState,\n ChangeEventHandler,\n ChangeEvent,\n useEffect,\n forwardRef,\n PropsWithoutRef,\n Ref\n} from 'react';\nimport styled from 'styled-components';\n\nimport {\n Button,\n Select,\n Option,\n Text,\n Flex,\n useI18n,\n Icon,\n Popover,\n PopoverProps\n} from '@pega/cosmos-react-core';\n\nimport { DirectedGraph, GraphData } from './Renderer/Utils/Graph';\nimport deleteNodeUtils, {\n GraphDataAsMap,\n DeleteNodeOutcome,\n DeleteNodeModalOption\n} from './Utils/deleteNodeUtils';\nimport { NodeProps } from './Node/Node.types';\n\nexport interface DeletePopoverProps {\n show: boolean;\n target: PopoverProps['target'];\n flowGraphData: GraphData;\n rendererGraphData: GraphData;\n nodeId: string;\n onChange?: (\n itemsToDelete: GraphDataAsMap,\n itemsToRetain: GraphDataAsMap | undefined,\n ev?: ChangeEvent\n ) => void;\n onSubmit?: (outcome: DeleteNodeOutcome, ev: Event) => void;\n onCancel?: () => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledDeletePopover = styled(Popover)`\n max-width: 25rem;\n`;\n\nconst DeletePopover = forwardRef(\n (\n {\n show,\n target,\n flowGraphData,\n rendererGraphData,\n nodeId,\n onChange,\n onSubmit,\n onCancel\n }: PropsWithoutRef<DeletePopoverProps>,\n ref: DeletePopoverProps['ref']\n ) => {\n const [currentSelection, setCurrentSelection] = useState<number>(0);\n\n const t = useI18n();\n\n const graph = new DirectedGraph(rendererGraphData);\n\n const deleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(graph, nodeId);\n\n const deleteOptions: DeleteNodeModalOption[] = deleteOptionsResult.options;\n const nodeType = (graph.getNode(nodeId) as NodeProps).type.name;\n\n useEffect(() => {\n if (deleteOptionsResult) {\n const itemsToDelete: GraphDataAsMap =\n nodeType !== 'Decision'\n ? deleteOptionsResult.allItems\n : deleteOptions[currentSelection].restItems;\n\n // add the actual node to be deleted also, to the list\n itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);\n\n onChange?.(itemsToDelete, deleteOptions[currentSelection].pathItems);\n }\n }, [rendererGraphData]);\n\n const onChangeHandler: ChangeEventHandler = (ev: ChangeEvent<HTMLSelectElement>) => {\n const newSelection =\n ev.target.selectedIndex >= deleteOptions.length ? -1 : ev.target.selectedIndex;\n\n setCurrentSelection(newSelection);\n\n let itemsToDelete;\n if (deleteOptionsResult) itemsToDelete = deleteOptionsResult.allItems;\n\n let itemsToRetain;\n\n if (newSelection !== -1) {\n itemsToDelete = deleteOptions[newSelection].restItems;\n itemsToRetain = deleteOptions[newSelection].pathItems;\n }\n\n // add the actual node to be deleted also, to the list\n if (itemsToDelete) itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);\n\n if (itemsToDelete) onChange?.(itemsToDelete, itemsToRetain, ev);\n };\n\n const submitHandler = (ev: Event) => {\n let error = true;\n const finalGraph = new DirectedGraph(flowGraphData);\n const finalDeleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(finalGraph, nodeId);\n\n let newTargetNode = finalDeleteOptionsResult?.destinationNodeId\n ? finalGraph.getNode(finalDeleteOptionsResult.destinationNodeId)\n : undefined;\n let itemsToDelete = finalDeleteOptionsResult.allItems;\n\n const selectedOption =\n currentSelection === -1 || nodeType !== 'Decision'\n ? undefined\n : finalDeleteOptionsResult?.options[currentSelection];\n let finalMetaData = selectedOption;\n\n if (selectedOption) {\n const pathConnectors = selectedOption.pathItems.connectors;\n const connectors = Object.keys(pathConnectors);\n for (let i = 0; i < connectors.length; i += 1) {\n const connectorData = pathConnectors[connectors[i]];\n if (\n connectorData &&\n finalGraph.getNode(connectorData.fromNodeId).type?.minConnectors !== 0 &&\n connectorData.toNodeId === finalDeleteOptionsResult.destinationNodeId\n ) {\n error = false;\n break;\n }\n }\n if (error) {\n onSubmit?.(\n {\n graphData: {\n nodes: [],\n connectors: []\n },\n updates: {\n connectors: []\n },\n deletes: { nodes: {}, connectors: {} },\n error: true\n },\n ev\n );\n return;\n }\n\n finalMetaData = finalDeleteOptionsResult.options.find(\n current => selectedOption.connector.id === current.connector.id\n );\n\n if (finalMetaData) {\n // get the ref of the first node of the retaining path\n newTargetNode = finalGraph.getNode(finalMetaData.connector.toNodeId);\n itemsToDelete = finalMetaData.restItems;\n }\n }\n\n // get the in-connectors of the selected node\n const nodeInConnectors = finalGraph.getInConnectors(nodeId);\n\n // iterate and set the targetNode to the above first node instead of the selected node.\n\n nodeInConnectors.forEach(con => {\n finalGraph.setConnector(con.id, {\n toNodeId: newTargetNode ? newTargetNode.id : undefined\n });\n });\n\n const resultGraphData = finalGraph.getGraphData();\n\n itemsToDelete.nodes[nodeId] = finalGraph.getNode(nodeId);\n\n // filter the highlighted nodes, including the selected node\n const nodes = resultGraphData.nodes.filter(item => {\n return itemsToDelete.nodes[item.id] === undefined;\n });\n\n if (finalMetaData) {\n itemsToDelete.connectors[finalMetaData.connector.id] = finalMetaData.connector;\n }\n\n // filter the highlighted connectors\n const connectors = resultGraphData.connectors.filter(item => {\n return itemsToDelete.connectors[item.id] === undefined;\n });\n\n const outcome: DeleteNodeOutcome = {\n graphData: {\n nodes: nodes as NodeProps[],\n connectors\n },\n updates: {\n connectors: nodeInConnectors\n },\n deletes: itemsToDelete,\n error: false\n };\n onSubmit?.(outcome, ev);\n };\n\n const onCancelHandler = () => {\n onCancel?.();\n };\n\n return (\n <StyledDeletePopover\n show={show}\n target={target}\n placement='right-end'\n ref={ref}\n modifiers={[\n {\n name: 'offset',\n options: { offset: [0, 8] }\n }\n ]}\n >\n <Flex container={{ gap: 2, pad: 2, direction: 'column' }}>\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n <Text variant='h4'>{t('delete_step_title')}</Text>\n <Button variant='simple' icon label={t('close')} onClick={onCancelHandler}>\n <Icon name='times' />\n </Button>\n </Flex>\n {nodeType === 'Decision' ? (\n <>\n <Text>{t('delete_decision_step')}</Text>\n <Select\n id='select-demo'\n label={t('delete_step_outcome')}\n required\n onChange={onChangeHandler}\n >\n {deleteOptions.map((item, index) => {\n return (\n <Option key={item.connector.id} selected={currentSelection === index}>\n {item.connector.label ? item.connector.label : item.connector.id}\n </Option>\n );\n })}\n\n <Option key='none' selected={currentSelection === -1}>\n {t('delete_all_outcomes')}\n </Option>\n </Select>\n </>\n ) : (\n <Text>{t('delete_step')}</Text>\n )}\n\n <Flex container={{ direction: 'row', justify: 'between' }}>\n <Button onClick={onCancelHandler}>{t('cancel')}</Button>\n <Button variant='primary' onClick={submitHandler}>\n {t('delete')}\n </Button>\n </Flex>\n </Flex>\n </StyledDeletePopover>\n );\n }\n);\n\nexport default DeletePopover;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowModeller.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/FlowModeller.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAQhB,MAAM,OAAO,CAAC;AA+Bf,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAsFzD,QAAA,MAAM,YAAY,sIAWf,gBAAgB,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"FlowModeller.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/FlowModeller.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAQhB,MAAM,OAAO,CAAC;AA+Bf,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAsFzD,QAAA,MAAM,YAAY,sIAWf,gBAAgB,iBAAiB,CAAC,gBAgTpC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -278,9 +278,7 @@ const FlowModeller = ({ graphData, highlightData, onNodeActionClick, onNodeAdd,
|
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
280
|
}, [graphData, selectedNodeId]);
|
|
281
|
-
|
|
282
|
-
* Library popover functionality
|
|
283
|
-
*/
|
|
281
|
+
// Library popover functionality
|
|
284
282
|
const onLibraryItemSelect = useCallback((libItem) => {
|
|
285
283
|
const metaData = state.activeAddBtnMeta.meta;
|
|
286
284
|
closeMenu();
|