@pega/cosmos-react-build 5.0.0-dev.5.0 → 5.0.0-dev.6.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 +2 -2
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +4 -4
- 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 +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.d.ts +3 -3
- package/lib/components/AppShell/Header/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.js.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.types.d.ts +4 -4
- package/lib/components/AppShell/Header/AppHeader.types.d.ts.map +1 -1
- package/lib/components/AppShell/Header/AppHeader.types.js.map +1 -1
- package/lib/components/AppShell/Header/BranchButton.d.ts +4 -3
- package/lib/components/AppShell/Header/BranchButton.d.ts.map +1 -1
- package/lib/components/AppShell/Header/BranchButton.js.map +1 -1
- package/lib/components/AppShell/NavigationList.d.ts +2 -2
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts +3 -3
- package/lib/components/DynamicContentEditor/DynamicContentEditor.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts +3 -3
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.d.ts.map +1 -1
- package/lib/components/DynamicContentEditor/DynamicContentEditor.types.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts +3 -3
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.d.ts +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.styles.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts +3 -3
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/CodeEditor.types.js.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.d.ts +2 -2
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/CodeEditor/getCodeSuggestions.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts +3 -3
- package/lib/components/ExpressionBuilder/ExpressionBuilder.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.styles.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts +3 -3
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilder.types.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.d.ts +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionBuilderContext.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionDetails.d.ts +3 -3
- package/lib/components/ExpressionBuilder/ExpressionDetails.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionDetails.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionItem.d.ts +3 -3
- package/lib/components/ExpressionBuilder/ExpressionItem.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionItem.js.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionList.d.ts +3 -3
- package/lib/components/ExpressionBuilder/ExpressionList.d.ts.map +1 -1
- package/lib/components/ExpressionBuilder/ExpressionList.js.map +1 -1
- package/lib/components/FlowModeller/AddNode.d.ts +2 -2
- package/lib/components/FlowModeller/AddNode.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/components/FlowModeller/DeletePopover.d.ts +4 -4
- 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 +2 -2
- package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.js.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.types.d.ts +5 -5
- package/lib/components/FlowModeller/FlowModeller.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModeller.types.js.map +1 -1
- package/lib/components/FlowModeller/FlowModellerContext.d.ts +2 -2
- package/lib/components/FlowModeller/FlowModellerContext.d.ts.map +1 -1
- package/lib/components/FlowModeller/FlowModellerContext.js.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.d.ts +4 -4
- package/lib/components/FlowModeller/Node/Node.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/Node.types.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts +2 -2
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -1
- package/lib/components/FlowModeller/Node.d.ts +2 -2
- package/lib/components/FlowModeller/Node.d.ts.map +1 -1
- package/lib/components/FlowModeller/Node.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.d.ts +2 -2
- package/lib/components/FlowModeller/Renderer/Renderer.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts +3 -3
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Renderer.types.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts +2 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts.map +1 -1
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js.map +1 -1
- package/lib/components/FlowModeller/Utils/addNodeUtils.d.ts +4 -3
- package/lib/components/FlowModeller/Utils/addNodeUtils.d.ts.map +1 -1
- package/lib/components/FlowModeller/Utils/addNodeUtils.js.map +1 -1
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts +2 -2
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts.map +1 -1
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js.map +1 -1
- package/lib/components/FlowModeller/helper.d.ts +4 -4
- package/lib/components/FlowModeller/helper.d.ts.map +1 -1
- package/lib/components/FlowModeller/helper.js.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.d.ts +3 -3
- package/lib/components/ItemLibrary/ItemLibrary.d.ts.map +1 -1
- package/lib/components/ItemLibrary/ItemLibrary.js.map +1 -1
- package/lib/components/LifeCycle/Category.d.ts +3 -3
- package/lib/components/LifeCycle/Category.d.ts.map +1 -1
- package/lib/components/LifeCycle/Category.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.d.ts +3 -3
- package/lib/components/LifeCycle/LifeCycle.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.d.ts +4 -4
- 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/LifeCycleContext.d.ts +1 -1
- package/lib/components/LifeCycle/LifeCycleContext.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycleContext.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.d.ts +3 -3
- package/lib/components/LifeCycle/LifeCycleList.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycleList.js.map +1 -1
- package/lib/components/LifeCycle/Stage.d.ts +3 -3
- package/lib/components/LifeCycle/Stage.d.ts.map +1 -1
- package/lib/components/LifeCycle/Stage.js.map +1 -1
- package/lib/components/LifeCycle/Step.d.ts +4 -4
- package/lib/components/LifeCycle/Step.d.ts.map +1 -1
- package/lib/components/LifeCycle/Step.js.map +1 -1
- package/lib/components/LifeCycle/Task.d.ts +3 -3
- package/lib/components/LifeCycle/Task.d.ts.map +1 -1
- package/lib/components/LifeCycle/Task.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.d.ts +3 -3
- package/lib/components/MobileBuildSummary/MobileBuildSummary.d.ts.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.js.map +1 -1
- package/lib/components/MobileBuildSummary/MobileBuildSummary.types.d.ts +2 -2
- 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 +3 -3
- package/lib/components/ObjectPreview/ObjectPreview.d.ts.map +1 -1
- package/lib/components/ObjectPreview/ObjectPreview.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectPicker.d.ts +2 -2
- package/lib/components/ObjectSelect/ObjectPicker.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.d.ts +5 -5
- package/lib/components/ObjectSelect/ObjectSelect.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.d.ts +3 -3
- package/lib/components/ObjectSelect/ObjectSummary.d.ts.map +1 -1
- package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.d.ts +2 -2
- package/lib/components/ObjectSelect/useCreateModal.d.ts.map +1 -1
- package/lib/components/ObjectSelect/useCreateModal.js.map +1 -1
- package/lib/components/PageBanner/PageBanner.d.ts +2 -2
- package/lib/components/PageBanner/PageBanner.d.ts.map +1 -1
- package/lib/components/PageBanner/PageBanner.js.map +1 -1
- package/lib/components/PageTemplates/GalleryPage.d.ts +4 -4
- package/lib/components/PageTemplates/GalleryPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/GalleryPage.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts +2 -2
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/PageTemplates/ShowcasePage.d.ts +3 -3
- package/lib/components/PageTemplates/ShowcasePage.d.ts.map +1 -1
- package/lib/components/PageTemplates/ShowcasePage.js.map +1 -1
- package/lib/components/SummaryCard/SummaryCard.d.ts +3 -2
- package/lib/components/SummaryCard/SummaryCard.d.ts.map +1 -1
- package/lib/components/SummaryCard/SummaryCard.js.map +1 -1
- package/lib/components/Workbench/ConfigurationPanel.d.ts +2 -2
- package/lib/components/Workbench/ConfigurationPanel.d.ts.map +1 -1
- package/lib/components/Workbench/ConfigurationPanel.js.map +1 -1
- package/lib/components/Workbench/Toolbar.d.ts +2 -2
- package/lib/components/Workbench/Toolbar.d.ts.map +1 -1
- package/lib/components/Workbench/Toolbar.js.map +1 -1
- package/lib/components/Workbench/UtilityPanel.d.ts +2 -2
- package/lib/components/Workbench/UtilityPanel.d.ts.map +1 -1
- package/lib/components/Workbench/UtilityPanel.js.map +1 -1
- package/lib/components/Workbench/Workbench.d.ts +3 -3
- package/lib/components/Workbench/Workbench.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.js.map +1 -1
- package/lib/components/Workbench/Workbench.types.d.ts +2 -2
- package/lib/components/Workbench/Workbench.types.d.ts.map +1 -1
- package/lib/components/Workbench/Workbench.types.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/Node.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/Node.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,IAAI,GAAkB,IAAI,CAAC,KAAK,CAAC,EAAE;IACvC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,GAC3C,KAAsD,CAAC;IAEzD,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,MAAc,EAAE,CAAa,EAAE,EAAE;QAChC,IAAI,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,EACD,CAAC,IAAI,EAAE,OAAO,CAAC,CAChB,CAAC;IAEF,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,IAAI,IAAI,EAAE,EAAE,KAAK,cAAc,CAAC,EAAE,EAAE;QAClC,OAAO,KAAC,SAAS,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,GAAI,CAAC;KACtE;IACD,IAAI,IAAI,EAAE,EAAE,KAAK,aAAa,CAAC,EAAE,EAAE;QACjC,OAAO,KAAC,OAAO,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,GAAI,CAAC;KACpE;IACD,OAAO,CACL,KAAC,WAAW,OACN,SAAS,EACb,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,YAA6C,EACtD,QAAQ,EAAE,IAAI,EAAE,QAAQ,EACxB,aAAa,EAAE,IAAI,EAAE,aAAa,EAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACvB,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import { memo, useCallback } from 'react';\nimport type { FC, MouseEvent } from 'react';\n\nimport { START_NODETYPE, STOP_NODETYPE } from './Node/Node.types';\nimport type {\n ModellerNodeComponentProps,\n NodeComponentData,\n NodeComponentProps\n} from './Node/Node.types';\nimport { DefaultNode, EndNode, StartNode } from './Node/NodeTemplates';\nimport type { Node as GraphNode } from './Renderer/Utils/Graph';\n\nconst Node: FC<GraphNode> = memo(props => {\n const { id, type, label, data, ...restProps } =\n props as ModellerNodeComponentProps<NodeComponentData>;\n\n const clickHandler = useCallback(\n (nodeId: string, e: MouseEvent) => {\n data?.onClick?.(nodeId, e);\n },\n [data?.onClick]\n );\n\n if (!type) {\n return null;\n }\n\n if (type?.id === START_NODETYPE.id) {\n return <StartNode id={id} type={type} label={label.toUpperCase()} />;\n }\n if (type?.id === STOP_NODETYPE.id) {\n return <EndNode id={id} type={type} label={label.toUpperCase()} />;\n }\n return (\n <DefaultNode\n {...restProps}\n id={id}\n label={label}\n type={type}\n onClick={clickHandler as NodeComponentProps['onClick']}\n onDelete={data?.onDelete}\n onActionClick={data?.onActionClick}\n actions={data?.actions}\n selected={data.selected}\n />\n );\n});\n\nexport default Node;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { RendererProps } from './Renderer.types';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { RendererProps } from './Renderer.types';
|
|
3
3
|
declare const Renderer: FC<RendererProps>;
|
|
4
4
|
export default Renderer;
|
|
5
5
|
//# sourceMappingURL=Renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAOhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAwBtD,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CA+C/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.tsx"],"names":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,SAAS;wBACR,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;4BAC9B,OAAO,eAAC,SAAS,OAAK,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAI,CAAC;wBAC/C,CAAC,CAAC,GACA,GACe,EACvB,KAAC,oBAAoB,cAClB,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBAC1B,IAAI,cAAc,CAAC;oBACnB,IAAI,IAAI,CAAC,IAAI,EAAE,aAAa,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;wBACpD,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;qBAChD;oBAED,OAAO,CACL,KAAC,IAAI,IAEH,EAAE,EAAE,iBAAiB,EACrB,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,KAAK,EAAE;4BACL,SAAS,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI;4BACvC,UAAU,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI;4BACzC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI;4BAChC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI;yBACjC,EACD,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YAE/B,IAAI,IAAI,KAAC,IAAI,OAAK,IAAI,EAAE,cAAc,EAAE,cAAc,GAAI,IAXtD,IAAI,CAAC,EAAE,CAYP,CACR,CAAC;gBACJ,CAAC,CAAC,GACmB,IACT,CACjB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { useContext } from 'react';\nimport type { FC } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex } from '@pega/cosmos-react-core';\n\nimport FlowModellerContext from '../FlowModellerContext';\n\nimport type { RendererProps } from './Renderer.types';\nimport GraphLayout from './Utils/GraphLayout';\nimport { DirectedGraph } from './Utils/Graph';\n\nconst StyledWrapper = styled.div`\n position: relative;\n width: 100%;\n height: 100%;\n`;\n\nconst StyledContentWrapper = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n`;\n\nconst StyledNodeWrapper = styled(StyledContentWrapper)(() => {\n return css`\n width: var(--width);\n height: var(--height);\n transform: translate(var(--xPos), var(--yPos));\n `;\n});\n\nconst Renderer: FC<RendererProps> = ({ graphData, connector: Connector, node: Node }) => {\n // apply the plotted positions\n const { readOnly } = useContext(FlowModellerContext);\n const graph = new DirectedGraph(graphData);\n const graphDimensions = GraphLayout.plot<RendererProps['graphData']>(graphData, readOnly);\n\n return (\n <StyledWrapper>\n <StyledContentWrapper>\n <svg\n width={graphDimensions.width}\n height={graphDimensions.height}\n viewBox={`0 0 ${graphDimensions.width} ${graphDimensions.height}`}\n >\n {Connector &&\n graphData.connectors.map(item => {\n return <Connector {...item} key={item.id} />;\n })}\n </svg>\n </StyledContentWrapper>\n <StyledContentWrapper>\n {graphData.nodes.map(item => {\n let referencedNode;\n if (item.type?.minConnectors === 0 && item.reference) {\n referencedNode = graph.getNode(item.reference);\n }\n\n return (\n <Flex\n key={item.id}\n as={StyledNodeWrapper}\n id={item.id}\n style={{\n '--width': `${item.dimensions.width}px`,\n '--height': `${item.dimensions.height}px`,\n '--xPos': `${item.position.x}px`,\n '--yPos': `${item.position.y}px`\n }}\n container={{ justify: 'center' }}\n >\n {Node && <Node {...item} referencedNode={referencedNode} />}\n </Flex>\n );\n })}\n </StyledContentWrapper>\n </StyledWrapper>\n );\n};\n\nexport default Renderer;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ConnectorProps, Node, GraphData } from './Utils/Graph';
|
|
3
|
-
import { PlottedGraphConnector, PlottedGraphNode } from './Utils/GraphLayout';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ConnectorProps, Node, GraphData } from './Utils/Graph';
|
|
3
|
+
import type { PlottedGraphConnector, PlottedGraphNode } from './Utils/GraphLayout';
|
|
4
4
|
export interface AddNodeHandlerParams {
|
|
5
5
|
refType: 'node' | 'connector';
|
|
6
6
|
refId: string | string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.types.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Renderer.types.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,SAAS,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;IAC9D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE;QACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;KAC5C,CAAC;IACF,SAAS,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.types.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.types.ts"],"names":[],"mappings":"","sourcesContent":["import { FC } from 'react';\n\nimport { ConnectorProps, Node, GraphData } from './Utils/Graph';\nimport { PlottedGraphConnector, PlottedGraphNode } from './Utils/GraphLayout';\n\nexport interface AddNodeHandlerParams {\n refType: 'node' | 'connector';\n refId: string | string[];\n}\n\nexport interface RendererProps {\n graphData: GraphData<PlottedGraphNode, PlottedGraphConnector>;\n disableAutoLayout?: boolean;\n highlights?: {\n nodes: Record<string, Node>;\n connectors: Record<string, ConnectorProps>;\n };\n connector?: FC<PlottedGraphConnector>;\n node?: FC<PlottedGraphNode>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Renderer.types.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { FC } from 'react';\n\nimport type { ConnectorProps, Node, GraphData } from './Utils/Graph';\nimport type { PlottedGraphConnector, PlottedGraphNode } from './Utils/GraphLayout';\n\nexport interface AddNodeHandlerParams {\n refType: 'node' | 'connector';\n refId: string | string[];\n}\n\nexport interface RendererProps {\n graphData: GraphData<PlottedGraphNode, PlottedGraphConnector>;\n disableAutoLayout?: boolean;\n highlights?: {\n nodes: Record<string, Node>;\n connectors: Record<string, ConnectorProps>;\n };\n connector?: FC<PlottedGraphConnector>;\n node?: FC<PlottedGraphNode>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphLayout.d.ts","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphLayout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"GraphLayout.d.ts","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphLayout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,IAAI,CAAC,CAAC,CAAC;IACxD,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,EAAE;QACR,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,cAAc,CAAC,EAAE,CAAC,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACvE,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnC,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH;AAED,oBAAY,oBAAoB;IAC9B,WAAW,OAAO;IAClB,WAAW,OAAO;CACnB;AAKD,MAAM,CAAC,OAAO,OAAO,WAAW;IAE9B,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,SAAS,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,EACtE,SAAS,EAAE,CAAC,EACZ,QAAQ,GAAE,OAAe,EACzB,SAAS,GAAE,oBAAuD;;;;CAyIrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphLayout.js","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,0CAAkB,CAAA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K,CAAC,EACnB;gBACA,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACxC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC;QACvC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;QAEzC,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE;YAC/C,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB;gBAC3D,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB;aAChE,CAAC;SACH;QAED,OAAO;YACL,KAAK,EAAE,mBAAmB;YAC1B,MAAM,EAAE,oBAAoB;SAC7B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import dagre from 'dagre';\n\nimport { ConnectorProps, GraphData, Node } from './Graph';\n\nexport interface PlottedGraphNode<T = any> extends Node<T> {\n dimensions: {\n width: number;\n height: number;\n };\n position: {\n x: number;\n y: number;\n };\n referencedNode?: T;\n}\n\nexport interface PlottedGraphConnector<T = any> extends ConnectorProps<T> {\n points: { x: number; y: number }[];\n labelLayout?: {\n value: any;\n width: number;\n height: number;\n x: number;\n y: number;\n };\n}\n\nexport enum GraphLayoutDirection {\n LeftToRight = 'LR',\n TopToBottom = 'TB'\n}\n\nconst DEFAULT_GRAPH_WIDTH = 2000;\nconst DEFAULT_GRAPH_HEIGHT = 2000;\n\nexport default class GraphLayout {\n // Using Dagre layouting\n static plot<T extends GraphData<PlottedGraphNode, PlottedGraphConnector>>(\n graphData: T,\n readOnly: boolean = false,\n direction: GraphLayoutDirection = GraphLayoutDirection.TopToBottom\n ) {\n const dagreGraph = new dagre.graphlib.Graph({ multigraph: true });\n\n dagreGraph.setDefaultEdgeLabel(() => ({}));\n\n const defaultNodeWidth = 280;\n const defaultNodeHeight = 112;\n\n dagreGraph.setGraph({\n rankdir: direction,\n ranksep: readOnly ? 2 : 4,\n edgesep: defaultNodeWidth / 2,\n nodesep: 20,\n // cspell:disable-next-line\n marginx: 200,\n // cspell:disable-next-line\n marginy: 32\n });\n\n graphData.nodes.forEach(node => {\n const height = node.dimensions.height === 0 ? 0 : node.dimensions.height || defaultNodeHeight;\n const width = node.dimensions.width === 0 ? 0 : node.dimensions.width || defaultNodeWidth;\n dagreGraph.setNode(node.id, {\n width,\n height\n });\n });\n\n graphData.connectors.forEach((con, index) => {\n dagreGraph.setEdge(\n con.fromNodeId,\n con.toNodeId,\n {\n weight: 1,\n minlen: 2,\n label: con.data?.label || '',\n width: 250,\n height: con.data?.label ? 90 : 40,\n // cspell:disable-next-line\n lablepos: 'c',\n labeloffset: 0\n },\n index.toString()\n );\n });\n\n dagre.layout(dagreGraph, {});\n\n graphData.nodes.forEach(el => {\n const node = dagreGraph.node(el.id);\n el.position.x = node.x - el.dimensions.width / 2;\n el.position.y = node.y - el.dimensions.height / 2;\n });\n\n graphData.connectors.forEach((con, index) => {\n const edge = dagreGraph.edge(con.fromNodeId, con.toNodeId, index.toString());\n\n con.labelLayout = {\n value: edge.label,\n x: edge.x,\n y: edge.y,\n width: edge.width,\n height: edge.height\n };\n\n const lastIndex = edge.points.length - 1;\n let firstPoint = edge.points[0];\n const secondPoint = edge.points[1];\n let lastPoint = edge.points[lastIndex];\n const secondLastPoint = edge.points[lastIndex - 1];\n\n const fromNode = dagreGraph.node(con.fromNodeId);\n const toNode = dagreGraph.node(con.toNodeId);\n\n firstPoint =\n firstPoint.x !== secondPoint.x\n ? {\n ...edge.points[0],\n x: fromNode.x,\n y: edge.points[1].y\n }\n : firstPoint;\n\n lastPoint =\n lastPoint.x !== secondLastPoint.x\n ? {\n ...edge.points[lastIndex],\n x: toNode.x,\n y: edge.points[lastIndex - 1].y\n }\n : lastPoint;\n\n con.points = [\n { x: fromNode.x, y: fromNode.y + fromNode.height / 2 },\n { ...firstPoint, y: firstPoint.y + 10 },\n { ...secondPoint, y: secondPoint.y + 10 },\n ...edge.points.slice(2, lastIndex),\n lastPoint\n ];\n\n // Only add the last point incase the edge has an arc at end\n if (edge.points[lastIndex].x !== edge.points[lastIndex - 1].x) {\n con.points.push({ x: toNode.x, y: toNode.y });\n }\n\n // if current edge source node is an placeholder node move down the starting point of placeholder node by 12\n if (fromNode.height === 0) {\n con.points[0].y += 12;\n }\n\n const edgeLastPointIndex = con.points.length - 1;\n\n // Move the merging arcs last point to the starting point of placeholder node\n if (\n con.points[edgeLastPointIndex].x === con.points[edgeLastPointIndex - 1].x &&\n toNode.height === 0\n ) {\n con.points[edgeLastPointIndex].y += 12;\n }\n });\n\n const width = dagreGraph.graph().width;\n const height = dagreGraph.graph().height;\n\n if (width !== undefined && height !== undefined) {\n return {\n width: Number.isFinite(width) ? width : DEFAULT_GRAPH_WIDTH,\n height: Number.isFinite(height) ? height : DEFAULT_GRAPH_HEIGHT\n };\n }\n\n return {\n width: DEFAULT_GRAPH_WIDTH,\n height: DEFAULT_GRAPH_HEIGHT\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GraphLayout.js","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,0CAAkB,CAAA;IAClB,0CAAkB,CAAA;AACpB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AAED,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,wBAAwB;IACxB,MAAM,CAAC,IAAI,CACT,SAAY,EACZ,WAAoB,KA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C;QAEzC,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE;YAC/C,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB;gBAC3D,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB;aAChE,CAAC;SACH;QAED,OAAO;YACL,KAAK,EAAE,mBAAmB;YAC1B,MAAM,EAAE,oBAAoB;SAC7B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import dagre from 'dagre';\n\nimport type { ConnectorProps, GraphData, Node } from './Graph';\n\nexport interface PlottedGraphNode<T = any> extends Node<T> {\n dimensions: {\n width: number;\n height: number;\n };\n position: {\n x: number;\n y: number;\n };\n referencedNode?: T;\n}\n\nexport interface PlottedGraphConnector<T = any> extends ConnectorProps<T> {\n points: { x: number; y: number }[];\n labelLayout?: {\n value: any;\n width: number;\n height: number;\n x: number;\n y: number;\n };\n}\n\nexport enum GraphLayoutDirection {\n LeftToRight = 'LR',\n TopToBottom = 'TB'\n}\n\nconst DEFAULT_GRAPH_WIDTH = 2000;\nconst DEFAULT_GRAPH_HEIGHT = 2000;\n\nexport default class GraphLayout {\n // Using Dagre layouting\n static plot<T extends GraphData<PlottedGraphNode, PlottedGraphConnector>>(\n graphData: T,\n readOnly: boolean = false,\n direction: GraphLayoutDirection = GraphLayoutDirection.TopToBottom\n ) {\n const dagreGraph = new dagre.graphlib.Graph({ multigraph: true });\n\n dagreGraph.setDefaultEdgeLabel(() => ({}));\n\n const defaultNodeWidth = 280;\n const defaultNodeHeight = 112;\n\n dagreGraph.setGraph({\n rankdir: direction,\n ranksep: readOnly ? 2 : 4,\n edgesep: defaultNodeWidth / 2,\n nodesep: 20,\n // cspell:disable-next-line\n marginx: 200,\n // cspell:disable-next-line\n marginy: 32\n });\n\n graphData.nodes.forEach(node => {\n const height = node.dimensions.height === 0 ? 0 : node.dimensions.height || defaultNodeHeight;\n const width = node.dimensions.width === 0 ? 0 : node.dimensions.width || defaultNodeWidth;\n dagreGraph.setNode(node.id, {\n width,\n height\n });\n });\n\n graphData.connectors.forEach((con, index) => {\n dagreGraph.setEdge(\n con.fromNodeId,\n con.toNodeId,\n {\n weight: 1,\n minlen: 2,\n label: con.data?.label || '',\n width: 250,\n height: con.data?.label ? 90 : 40,\n // cspell:disable-next-line\n lablepos: 'c',\n labeloffset: 0\n },\n index.toString()\n );\n });\n\n dagre.layout(dagreGraph, {});\n\n graphData.nodes.forEach(el => {\n const node = dagreGraph.node(el.id);\n el.position.x = node.x - el.dimensions.width / 2;\n el.position.y = node.y - el.dimensions.height / 2;\n });\n\n graphData.connectors.forEach((con, index) => {\n const edge = dagreGraph.edge(con.fromNodeId, con.toNodeId, index.toString());\n\n con.labelLayout = {\n value: edge.label,\n x: edge.x,\n y: edge.y,\n width: edge.width,\n height: edge.height\n };\n\n const lastIndex = edge.points.length - 1;\n let firstPoint = edge.points[0];\n const secondPoint = edge.points[1];\n let lastPoint = edge.points[lastIndex];\n const secondLastPoint = edge.points[lastIndex - 1];\n\n const fromNode = dagreGraph.node(con.fromNodeId);\n const toNode = dagreGraph.node(con.toNodeId);\n\n firstPoint =\n firstPoint.x !== secondPoint.x\n ? {\n ...edge.points[0],\n x: fromNode.x,\n y: edge.points[1].y\n }\n : firstPoint;\n\n lastPoint =\n lastPoint.x !== secondLastPoint.x\n ? {\n ...edge.points[lastIndex],\n x: toNode.x,\n y: edge.points[lastIndex - 1].y\n }\n : lastPoint;\n\n con.points = [\n { x: fromNode.x, y: fromNode.y + fromNode.height / 2 },\n { ...firstPoint, y: firstPoint.y + 10 },\n { ...secondPoint, y: secondPoint.y + 10 },\n ...edge.points.slice(2, lastIndex),\n lastPoint\n ];\n\n // Only add the last point incase the edge has an arc at end\n if (edge.points[lastIndex].x !== edge.points[lastIndex - 1].x) {\n con.points.push({ x: toNode.x, y: toNode.y });\n }\n\n // if current edge source node is an placeholder node move down the starting point of placeholder node by 12\n if (fromNode.height === 0) {\n con.points[0].y += 12;\n }\n\n const edgeLastPointIndex = con.points.length - 1;\n\n // Move the merging arcs last point to the starting point of placeholder node\n if (\n con.points[edgeLastPointIndex].x === con.points[edgeLastPointIndex - 1].x &&\n toNode.height === 0\n ) {\n con.points[edgeLastPointIndex].y += 12;\n }\n });\n\n const width = dagreGraph.graph().width;\n const height = dagreGraph.graph().height;\n\n if (width !== undefined && height !== undefined) {\n return {\n width: Number.isFinite(width) ? width : DEFAULT_GRAPH_WIDTH,\n height: Number.isFinite(height) ? height : DEFAULT_GRAPH_HEIGHT\n };\n }\n\n return {\n width: DEFAULT_GRAPH_WIDTH,\n height: DEFAULT_GRAPH_HEIGHT\n };\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DirectedGraph } from './Graph';
|
|
2
|
+
import type { ConnectorProps, GraphData, Node } from './Graph';
|
|
2
3
|
export interface NestedArray<T> extends Array<T | NestedArray<T>> {
|
|
3
4
|
}
|
|
4
5
|
export interface ConvergenceData<T extends Node, U extends ConnectorProps> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphTraversal.d.ts","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphTraversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"GraphTraversal.d.ts","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphTraversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,WAAW,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC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{ ConnectorProps, DirectedGraph, GraphData, Node } from './Graph';\n\nexport interface NestedArray<T> extends Array<T | NestedArray<T>> {}\n\nexport interface ConvergenceData<T extends Node, U extends ConnectorProps> {\n nodeId: string;\n connectors: NestedArray<string>;\n summary: {\n nodesinvolved: Record<string, T>;\n connectorsInvolved: Record<string, U>;\n };\n paths?: NestedArray<ConvergenceData<T, U>>;\n}\n\nexport default class GraphTraversal {\n static bfs(gd: GraphData, src?: string): string[] {\n const graph = new DirectedGraph(gd);\n\n if (!src) {\n const rootNodeId = GraphTraversal.findRootNode(graph);\n\n if (!rootNodeId) {\n throw Error('Invalid graph, cannot find root node.');\n }\n\n src = rootNodeId;\n }\n\n const queue: string[] = [src];\n const result: string[] = [];\n const map: Record<string, string> = {\n src\n }; // needed for duplicate comparision\n\n while (queue.length > 0) {\n const source = queue.shift();\n if (source !== undefined) {\n result.push(source);\n\n const nextNodes = graph.getNextNodes(source);\n nextNodes.forEach((node: Node) => {\n if (!map[node.id]) {\n queue.push(node.id);\n map[node.id] = node.id;\n }\n });\n }\n }\n\n return result;\n }\n\n static dfs(gd: GraphData, src?: string): string[] {\n const graph = new DirectedGraph(gd);\n\n // finding the start node automatically\n if (!src) {\n const rootNodeId = GraphTraversal.findRootNode(graph);\n\n if (!rootNodeId) {\n throw Error('Invalid graph, cannot find root node.');\n }\n\n src = rootNodeId;\n }\n\n const stack: string[] = [src];\n const result: string[] = [];\n const map: Record<string, string> = {\n src\n }; // needed for duplicate comparision\n\n while (stack.length > 0) {\n const source = stack.pop();\n if (source !== undefined) {\n result.push(source);\n\n const nextNodes = graph.getNextNodes(source);\n\n nextNodes.forEach(node => {\n if (map[node.id] === undefined) {\n stack.push(node.id);\n map[node.id] = node.id;\n }\n });\n }\n }\n\n return result;\n }\n\n // Assuming the given graph has no unconnected nodes and the graph is not cyclic(if start node have in-connectors(ie., cyclic), this will fail).\n // - returns first encountered node with no in-connectors as a rootnode, if more than one exists\n static findRootNode(graph: DirectedGraph): string | false {\n const nodes = graph.getNodes();\n\n for (let i = 0; i < nodes.length; i += 1) {\n if (graph.getPrevNodesCount(nodes[i].id) === 0) {\n return nodes[i].id;\n }\n }\n\n return false;\n }\n\n /**\n * Given the graphData and the source node with morethan one branch, It calculates the convergence node, involved connectors and paths\n * Assuming, goTo is not supported\n *\n * @param gd graphData to process on\n * @param src id of the source node. This needs to be a node with multiple branches\n * @returns id of the destination node or null if not found\n */\n // TODO-OPTIMIZE Memoize, for a given GraphData\n static getConvergenceData<T extends Node = Node, U extends ConnectorProps = ConnectorProps>(\n gd: GraphData<T, U>,\n src: string\n ): ConvergenceData<T, U> | false {\n const graph = new DirectedGraph<T, U>(gd);\n\n // return false, if there is no node with given source node id\n if (graph.getNode(src) === undefined || graph.getNextNodesCount(src) < 2) {\n return false;\n }\n\n // traverse the nodes -- and record the paths of each connector\n const path: ConvergenceData<T, U>[][] = []; // array of path-arrays\n const initialConnectors = graph.getOutConnectors(src);\n\n // iterate the initial set of connectors\n initialConnectors.forEach((item, index) => {\n path[index] = [];\n\n let currentConnector = item;\n // traverse through each connector and push the encountered nodes\n while (currentConnector && currentConnector.toNodeId !== undefined) {\n path[index].push({\n nodeId: currentConnector.toNodeId,\n connectors: [currentConnector.id],\n summary: {\n nodesinvolved: {\n [currentConnector.toNodeId]: graph.getNode(currentConnector.toNodeId)\n },\n connectorsInvolved: { [currentConnector.id]: currentConnector }\n }\n });\n\n const inConnectors = graph.getInConnectors(currentConnector.toNodeId);\n // if this node has multiple in connectors, that means this is a join [IMP TODO NOTE until we support goTo option]\n if (inConnectors.length > 1) {\n return;\n }\n\n let outConnectors = graph.getOutConnectors(currentConnector.toNodeId);\n\n let newCurrentNodeId = currentConnector.toNodeId;\n // check if this node has multiple branches and call recursively\n while (outConnectors.length > 1) {\n const result = GraphTraversal.getConvergenceData(gd, newCurrentNodeId);\n\n // handle resultNodeId val as false use case: just cancel futher processing and return false\n if (result === false) {\n return false;\n }\n\n // add result node to the path\n path[index].push(result);\n\n // handle, resultNode as destination shape of alternate connector too\n const tempInConnectors = graph.getInConnectors(result.nodeId);\n // if this node has multiple in connectors and more than expected count, that means this is a join [IMP TODO NOTE until we support goTo option]\n if (tempInConnectors.length > outConnectors.length) {\n return;\n }\n\n // handle, resultNode as decision shape\n outConnectors = graph.getOutConnectors(result.nodeId);\n newCurrentNodeId = result.nodeId;\n }\n\n // else if out connectors is 1\n currentConnector = outConnectors[0];\n }\n });\n\n // validate and return false if no convergence node found\n for (let i = 1; i < path.length; i += 1) {\n if (path[i][path[i].length - 1].nodeId !== path[i - 1][path[i - 1].length - 1].nodeId) {\n return false;\n }\n }\n\n const result: ConvergenceData<T, U> = {\n nodeId: path[0][path[0].length - 1].nodeId,\n connectors: [],\n paths: [],\n summary: {\n nodesinvolved: {},\n connectorsInvolved: {}\n }\n };\n\n for (let i = 0; i < path.length; i += 1) {\n const current = path[i];\n result.connectors.push(current[current.length - 1].connectors);\n\n if (result.paths !== undefined) {\n result.paths[i] = current;\n }\n\n current.forEach(item => {\n result.summary.nodesinvolved = {\n ...result.summary.nodesinvolved,\n ...item.summary.nodesinvolved\n };\n\n result.summary.connectorsInvolved = {\n ...result.summary.connectorsInvolved,\n ...item.summary.connectorsInvolved\n };\n });\n }\n\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GraphTraversal.js","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/GraphTraversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAexC,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,MAAM,CAAC,GAAG,CAAC,EAAa,EAAE,GAAY;QACpC,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,UAAU,GAAG,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAEtD,IAAI,CAAC,UAAU,EAAE;gBACf,MAAM,KAAK,CAAC,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,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM;YAC1C,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;YACT,OAAO,EAAE;gBACP,aAAa,EAAE,EAAE;gBACjB,kBAAkB,EAAE,EAAE;aACvB;SACF,CAAC;QAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YACvC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YAE/D,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;gBAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;aAC3B;YAED,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACrB,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG;oBAC7B,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa;oBAC/B,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa;iBAC9B,CAAC;gBAEF,MAAM,CAAC,OAAO,CAAC,kBAAkB,GAAG;oBAClC,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB;oBACpC,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB;iBACnC,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { DirectedGraph } from './Graph';\nimport type { ConnectorProps, GraphData, Node } from './Graph';\n\nexport interface NestedArray<T> extends Array<T | NestedArray<T>> {}\n\nexport interface ConvergenceData<T extends Node, U extends ConnectorProps> {\n nodeId: string;\n connectors: NestedArray<string>;\n summary: {\n nodesinvolved: Record<string, T>;\n connectorsInvolved: Record<string, U>;\n };\n paths?: NestedArray<ConvergenceData<T, U>>;\n}\n\nexport default class GraphTraversal {\n static bfs(gd: GraphData, src?: string): string[] {\n const graph = new DirectedGraph(gd);\n\n if (!src) {\n const rootNodeId = GraphTraversal.findRootNode(graph);\n\n if (!rootNodeId) {\n throw Error('Invalid graph, cannot find root node.');\n }\n\n src = rootNodeId;\n }\n\n const queue: string[] = [src];\n const result: string[] = [];\n const map: Record<string, string> = {\n src\n }; // needed for duplicate comparision\n\n while (queue.length > 0) {\n const source = queue.shift();\n if (source !== undefined) {\n result.push(source);\n\n const nextNodes = graph.getNextNodes(source);\n nextNodes.forEach((node: Node) => {\n if (!map[node.id]) {\n queue.push(node.id);\n map[node.id] = node.id;\n }\n });\n }\n }\n\n return result;\n }\n\n static dfs(gd: GraphData, src?: string): string[] {\n const graph = new DirectedGraph(gd);\n\n // finding the start node automatically\n if (!src) {\n const rootNodeId = GraphTraversal.findRootNode(graph);\n\n if (!rootNodeId) {\n throw Error('Invalid graph, cannot find root node.');\n }\n\n src = rootNodeId;\n }\n\n const stack: string[] = [src];\n const result: string[] = [];\n const map: Record<string, string> = {\n src\n }; // needed for duplicate comparision\n\n while (stack.length > 0) {\n const source = stack.pop();\n if (source !== undefined) {\n result.push(source);\n\n const nextNodes = graph.getNextNodes(source);\n\n nextNodes.forEach(node => {\n if (map[node.id] === undefined) {\n stack.push(node.id);\n map[node.id] = node.id;\n }\n });\n }\n }\n\n return result;\n }\n\n // Assuming the given graph has no unconnected nodes and the graph is not cyclic(if start node have in-connectors(ie., cyclic), this will fail).\n // - returns first encountered node with no in-connectors as a rootnode, if more than one exists\n static findRootNode(graph: DirectedGraph): string | false {\n const nodes = graph.getNodes();\n\n for (let i = 0; i < nodes.length; i += 1) {\n if (graph.getPrevNodesCount(nodes[i].id) === 0) {\n return nodes[i].id;\n }\n }\n\n return false;\n }\n\n /**\n * Given the graphData and the source node with morethan one branch, It calculates the convergence node, involved connectors and paths\n * Assuming, goTo is not supported\n *\n * @param gd graphData to process on\n * @param src id of the source node. This needs to be a node with multiple branches\n * @returns id of the destination node or null if not found\n */\n // TODO-OPTIMIZE Memoize, for a given GraphData\n static getConvergenceData<T extends Node = Node, U extends ConnectorProps = ConnectorProps>(\n gd: GraphData<T, U>,\n src: string\n ): ConvergenceData<T, U> | false {\n const graph = new DirectedGraph<T, U>(gd);\n\n // return false, if there is no node with given source node id\n if (graph.getNode(src) === undefined || graph.getNextNodesCount(src) < 2) {\n return false;\n }\n\n // traverse the nodes -- and record the paths of each connector\n const path: ConvergenceData<T, U>[][] = []; // array of path-arrays\n const initialConnectors = graph.getOutConnectors(src);\n\n // iterate the initial set of connectors\n initialConnectors.forEach((item, index) => {\n path[index] = [];\n\n let currentConnector = item;\n // traverse through each connector and push the encountered nodes\n while (currentConnector && currentConnector.toNodeId !== undefined) {\n path[index].push({\n nodeId: currentConnector.toNodeId,\n connectors: [currentConnector.id],\n summary: {\n nodesinvolved: {\n [currentConnector.toNodeId]: graph.getNode(currentConnector.toNodeId)\n },\n connectorsInvolved: { [currentConnector.id]: currentConnector }\n }\n });\n\n const inConnectors = graph.getInConnectors(currentConnector.toNodeId);\n // if this node has multiple in connectors, that means this is a join [IMP TODO NOTE until we support goTo option]\n if (inConnectors.length > 1) {\n return;\n }\n\n let outConnectors = graph.getOutConnectors(currentConnector.toNodeId);\n\n let newCurrentNodeId = currentConnector.toNodeId;\n // check if this node has multiple branches and call recursively\n while (outConnectors.length > 1) {\n const result = GraphTraversal.getConvergenceData(gd, newCurrentNodeId);\n\n // handle resultNodeId val as false use case: just cancel futher processing and return false\n if (result === false) {\n return false;\n }\n\n // add result node to the path\n path[index].push(result);\n\n // handle, resultNode as destination shape of alternate connector too\n const tempInConnectors = graph.getInConnectors(result.nodeId);\n // if this node has multiple in connectors and more than expected count, that means this is a join [IMP TODO NOTE until we support goTo option]\n if (tempInConnectors.length > outConnectors.length) {\n return;\n }\n\n // handle, resultNode as decision shape\n outConnectors = graph.getOutConnectors(result.nodeId);\n newCurrentNodeId = result.nodeId;\n }\n\n // else if out connectors is 1\n currentConnector = outConnectors[0];\n }\n });\n\n // validate and return false if no convergence node found\n for (let i = 1; i < path.length; i += 1) {\n if (path[i][path[i].length - 1].nodeId !== path[i - 1][path[i - 1].length - 1].nodeId) {\n return false;\n }\n }\n\n const result: ConvergenceData<T, U> = {\n nodeId: path[0][path[0].length - 1].nodeId,\n connectors: [],\n paths: [],\n summary: {\n nodesinvolved: {},\n connectorsInvolved: {}\n }\n };\n\n for (let i = 0; i < path.length; i += 1) {\n const current = path[i];\n result.connectors.push(current[current.length - 1].connectors);\n\n if (result.paths !== undefined) {\n result.paths[i] = current;\n }\n\n current.forEach(item => {\n result.summary.nodesinvolved = {\n ...result.summary.nodesinvolved,\n ...item.summary.nodesinvolved\n };\n\n result.summary.connectorsInvolved = {\n ...result.summary.connectorsInvolved,\n ...item.summary.connectorsInvolved\n };\n });\n }\n\n return result;\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AddNodeHandlerParams } from '../Renderer/Renderer.types';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { AddNodeHandlerParams } from '../Renderer/Renderer.types';
|
|
2
|
+
import { DirectedGraph } from '../Renderer/Utils/Graph';
|
|
3
|
+
import type { ConnectorProps, GraphData, Node } from '../Renderer/Utils/Graph';
|
|
4
|
+
import type { PlottedGraphNode, PlottedGraphConnector } from '../Renderer/Utils/GraphLayout';
|
|
4
5
|
export interface PlaceHolderNode extends PlottedGraphNode {
|
|
5
6
|
realConnectors: string[];
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNodeUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/addNodeUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"addNodeUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/addNodeUtils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAI7F,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AACD,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAGD,eAAO,MAAM,iBAAiB,SAAU,eAAe,GAAG,IAAI,4BAE7D,CAAC;AAGF,eAAO,MAAM,sBAAsB,cACtB,oBAAoB,GAAG,cAAc,sCAGjD,CAAC;AAwBF,QAAA,MAAM,iBAAiB;qCAEZ,aAAa,gCACU,oBAAoB,KAAK,gBAAgB,kCAE3D,MAAM,UACR,MAAM,eACD,oBAAoB,KAC9B,qBAAqB;wCAyEf,UAAU,gBAAgB,EAAE,qBAAqB,CAAC,2BACpC,oBAAoB,KAAK,gBAAgB,kCAEpD,MAAM,YACR,MAAM,YACN,oBAAoB,KAC3B,qBAAqB;CA8D7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNodeUtils.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/addNodeUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,aAAa,EAAmB,MAAM,yBAAyB,CAAC;AAEzF,OAAO,cAA+B,MAAM,kCAAkC,CAAC;AAS/E,6BAA6B;AAC7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAA4B,EAA2B,EAAE;IACzF,OAAQ,IAAwB,CAAC,cAAc,KAAK,SAAS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;aAChD;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { OmitStrict } from '@pega/cosmos-react-core';\n\nimport { AddNodeProps } from '../AddNode';\nimport { AddNodeHandlerParams } from '../Renderer/Renderer.types';\nimport { ConnectorProps, DirectedGraph, GraphData, Node } from '../Renderer/Utils/Graph';\nimport { PlottedGraphNode, PlottedGraphConnector } from '../Renderer/Utils/GraphLayout';\nimport GraphTraversal, { NestedArray } from '../Renderer/Utils/GraphTraversal';\n\nexport interface PlaceHolderNode extends PlottedGraphNode {\n realConnectors: string[];\n}\nexport interface PlaceHolderConnector extends PlottedGraphConnector {\n realConnectors: string[];\n}\n\n// type-guard PlaceHolderNode\nexport const isPlaceHolderNode = (node: PlaceHolderNode | Node): node is PlaceHolderNode => {\n return (node as PlaceHolderNode).realConnectors !== undefined;\n};\n\n// type-guard PlaceHolderConnector\nexport const isPlaceHolderConnector = (\n connector: PlaceHolderConnector | ConnectorProps\n): connector is PlaceHolderConnector => {\n return (connector as PlaceHolderConnector).realConnectors !== undefined;\n};\n\nconst countInvisibleConnectors = (\n graph: DirectedGraph,\n connectors: NestedArray<string>\n): number => {\n let invisibleConnectorsCount = 0;\n for (let i = 0; i < connectors.length; i += 1) {\n if (Array.isArray(connectors[i]))\n invisibleConnectorsCount += countInvisibleConnectors(\n graph,\n connectors[i] as NestedArray<string>\n );\n else {\n const connectorData = graph.getConnector(connectors[i] as string);\n const fromNode = graph.getNode(connectorData.fromNodeId);\n if (fromNode?.type?.minConnectors === 0) {\n invisibleConnectorsCount += 1;\n }\n }\n }\n return invisibleConnectorsCount;\n};\n\nconst PlaceHolderHelper = {\n insertAtConnectorsMerge: (\n graph: DirectedGraph,\n getNewPHNodeCB: (addNodeMeta: AddNodeHandlerParams) => PlottedGraphNode,\n getNewPHConnectorCB: (\n fromNode: string,\n toNode: string,\n addNodeMeta: AddNodeHandlerParams\n ) => PlottedGraphConnector\n ) => {\n const gd = graph.getGraphData();\n\n // process the graph and find the first node automatically. We can find it easily by iterating and finding the node with no in-connectors\n const bfs = GraphTraversal.bfs(gd);\n bfs.reverse().forEach(nodeId => {\n const node = graph.getNode(nodeId);\n\n // get the node's convergence data\n const result = GraphTraversal.getConvergenceData(graph.getGraphData(), node.id);\n\n // if node has more than one out-connector and has convergence data\n if (result !== false) {\n // iterate over the resultant connectors\n for (let i = 0; i < result.connectors.length; i += 1) {\n const connectorsToUpdate = result.connectors[i];\n let invisibleConnectorsCount = 0;\n\n /** Count number of invisible connectors originating from go to shapes forming a convergence/join\n * compare invisible connectors count with connectors forming a convergence\n */\n if (typeof connectorsToUpdate !== 'string' && connectorsToUpdate.length > 1) {\n invisibleConnectorsCount = countInvisibleConnectors(graph, connectorsToUpdate);\n\n // ensure connectors converging are greater than invisible connectors\n if (connectorsToUpdate.length > invisibleConnectorsCount) {\n let refConnectorIdsArray: string[] = [];\n\n connectorsToUpdate.forEach(itrConId => {\n let conId = itrConId;\n if (Array.isArray(conId)) {\n conId = itrConId[0] as string;\n }\n\n const connector = graph.getConnector(conId);\n if (isPlaceHolderConnector(connector)) {\n refConnectorIdsArray = [...refConnectorIdsArray, ...connector.realConnectors];\n } else {\n refConnectorIdsArray.push(conId);\n }\n });\n\n const addNodeMeta: AddNodeHandlerParams = {\n refType: 'connector',\n refId: refConnectorIdsArray\n };\n const newNode = getNewPHNodeCB(addNodeMeta);\n const newPNode: PlaceHolderNode = {\n ...newNode,\n realConnectors: refConnectorIdsArray\n };\n graph.addNode(newPNode);\n\n connectorsToUpdate.forEach(item => {\n graph.setConnector(item as string, {\n toNodeId: newNode.id\n });\n });\n\n const newConnector = getNewPHConnectorCB(newNode.id, result.nodeId, addNodeMeta);\n const newPConnector: PlaceHolderConnector = {\n ...newConnector,\n realConnectors: refConnectorIdsArray\n };\n graph.addConnector(newPConnector);\n }\n }\n }\n }\n });\n },\n injectPlaceholderNodes: (\n graphData: GraphData<PlottedGraphNode, PlottedGraphConnector>,\n onGetNewNode: (metaData: AddNodeHandlerParams) => PlottedGraphNode,\n onGetNewConnector: (\n fromNodeId: string,\n toNodeId: string,\n metaData: AddNodeHandlerParams\n ) => PlottedGraphConnector\n ) => {\n // gets GraphData<RendererNodeProps, RendererConnectorProps>\n const targetGraph = new DirectedGraph(graphData);\n\n // insert placeholder-nodes at connector convergence point for nodes with multiple out connectors.\n PlaceHolderHelper.insertAtConnectorsMerge(targetGraph, onGetNewNode, onGetNewConnector);\n\n // iterate all nodes with more than one in-connectors and insert addNode before current one.\n targetGraph.getNodes().forEach(node => {\n // should not add a node before a placeholder node\n if (isPlaceHolderNode(node)) {\n return;\n }\n\n if (targetGraph.getPrevNodesCount(node.id) > 1) {\n let refConnectorIdsArray: string[] = [];\n\n // connect all in-connectors to a new node and create a new connector that connects from new node to the actual toNodeId.\n targetGraph.getInConnectors(node.id).forEach(con => {\n const connector = targetGraph.getConnector(con.id);\n if (isPlaceHolderConnector(connector)) {\n refConnectorIdsArray = [...refConnectorIdsArray, ...connector.realConnectors];\n } else {\n refConnectorIdsArray.push(con.id);\n }\n });\n\n const metaData: AddNodeHandlerParams = {\n refType: 'connector',\n refId: refConnectorIdsArray\n };\n\n // create a new placeholder node\n const newNode: OmitStrict<AddNodeProps, 'highlight' | 'addNodeHandler'> =\n onGetNewNode(metaData);\n const placeHolderNode: PlaceHolderNode = {\n ...newNode,\n realConnectors: refConnectorIdsArray\n };\n\n targetGraph.addNode(placeHolderNode);\n\n // connect all in-connectors to a new node and create a new connector that connects from new node to the actual toNodeId.\n targetGraph.getInConnectors(node.id).forEach(con => {\n targetGraph.setConnector(con.id, {\n toNodeId: placeHolderNode.id\n });\n });\n\n const newConnector = onGetNewConnector(placeHolderNode.id, node.id, metaData);\n const placeholderConnector: PlaceHolderConnector = {\n ...newConnector,\n realConnectors: refConnectorIdsArray\n };\n\n targetGraph.addConnector(placeholderConnector);\n }\n });\n\n return targetGraph.getGraphData();\n }\n};\n\nexport default PlaceHolderHelper;\n"]}
|
|
1
|
+
{"version":3,"file":"addNodeUtils.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/addNodeUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAU9D,6BAA6B;AAC7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAA4B,EAA2B,EAAE;IACzF,OAAQ,IAAwB,CAAC,cAAc,KAAK,SAAS,CAAC;AAChE,CAAC,CAAC;AAEF,kCAAkC;AAClC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,SAAgD,EACb,EAAE;IACrC,OAAQ,SAAkC,CAAC,cAAc,KAAK,SAAS,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAC/B,KAAoB,EACpB,UAA+B,EACvB,EAAE;IACV,IAAI,wBAAwB,GAAG,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC9B,wBAAwB,IAAI,wBAAwB,CAClD,KAAK,EACL,UAAU,CAAC,CAAC,CAAwB,CACrC,CAAC;aACC;YACH,MAAM,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAW,CAAC,CAAC;YAClE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACzD,IAAI,QAAQ,EAAE,IAAI,EAAE,aAAa,KAAK,CAAC,EAAE;gBACvC,wBAAwB,IAAI,CAAC,CAAC;aAC/B;SACF;KACF;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,iBAAiB,G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AC,GAAG,CAAC,EAAE,EAAE;wBAC/B,QAAQ,EAAE,eAAe,CAAC,EAAE;qBAC7B,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,MAAM,YAAY,GAAG,iBAAiB,CAAC,eAAe,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;gBAC9E,MAAM,oBAAoB,GAAyB;oBACjD,GAAG,YAAY;oBACf,cAAc,EAAE,oBAAoB;iBACrC,CAAC;gBAEF,WAAW,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;aAChD;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import type { OmitStrict } from '@pega/cosmos-react-core';\n\nimport type { AddNodeProps } from '../AddNode';\nimport type { AddNodeHandlerParams } from '../Renderer/Renderer.types';\nimport { DirectedGraph } from '../Renderer/Utils/Graph';\nimport type { ConnectorProps, GraphData, Node } from '../Renderer/Utils/Graph';\nimport type { PlottedGraphNode, PlottedGraphConnector } from '../Renderer/Utils/GraphLayout';\nimport GraphTraversal from '../Renderer/Utils/GraphTraversal';\nimport type { NestedArray } from '../Renderer/Utils/GraphTraversal';\n\nexport interface PlaceHolderNode extends PlottedGraphNode {\n realConnectors: string[];\n}\nexport interface PlaceHolderConnector extends PlottedGraphConnector {\n realConnectors: string[];\n}\n\n// type-guard PlaceHolderNode\nexport const isPlaceHolderNode = (node: PlaceHolderNode | Node): node is PlaceHolderNode => {\n return (node as PlaceHolderNode).realConnectors !== undefined;\n};\n\n// type-guard PlaceHolderConnector\nexport const isPlaceHolderConnector = (\n connector: PlaceHolderConnector | ConnectorProps\n): connector is PlaceHolderConnector => {\n return (connector as PlaceHolderConnector).realConnectors !== undefined;\n};\n\nconst countInvisibleConnectors = (\n graph: DirectedGraph,\n connectors: NestedArray<string>\n): number => {\n let invisibleConnectorsCount = 0;\n for (let i = 0; i < connectors.length; i += 1) {\n if (Array.isArray(connectors[i]))\n invisibleConnectorsCount += countInvisibleConnectors(\n graph,\n connectors[i] as NestedArray<string>\n );\n else {\n const connectorData = graph.getConnector(connectors[i] as string);\n const fromNode = graph.getNode(connectorData.fromNodeId);\n if (fromNode?.type?.minConnectors === 0) {\n invisibleConnectorsCount += 1;\n }\n }\n }\n return invisibleConnectorsCount;\n};\n\nconst PlaceHolderHelper = {\n insertAtConnectorsMerge: (\n graph: DirectedGraph,\n getNewPHNodeCB: (addNodeMeta: AddNodeHandlerParams) => PlottedGraphNode,\n getNewPHConnectorCB: (\n fromNode: string,\n toNode: string,\n addNodeMeta: AddNodeHandlerParams\n ) => PlottedGraphConnector\n ) => {\n const gd = graph.getGraphData();\n\n // process the graph and find the first node automatically. We can find it easily by iterating and finding the node with no in-connectors\n const bfs = GraphTraversal.bfs(gd);\n bfs.reverse().forEach(nodeId => {\n const node = graph.getNode(nodeId);\n\n // get the node's convergence data\n const result = GraphTraversal.getConvergenceData(graph.getGraphData(), node.id);\n\n // if node has more than one out-connector and has convergence data\n if (result !== false) {\n // iterate over the resultant connectors\n for (let i = 0; i < result.connectors.length; i += 1) {\n const connectorsToUpdate = result.connectors[i];\n let invisibleConnectorsCount = 0;\n\n /** Count number of invisible connectors originating from go to shapes forming a convergence/join\n * compare invisible connectors count with connectors forming a convergence\n */\n if (typeof connectorsToUpdate !== 'string' && connectorsToUpdate.length > 1) {\n invisibleConnectorsCount = countInvisibleConnectors(graph, connectorsToUpdate);\n\n // ensure connectors converging are greater than invisible connectors\n if (connectorsToUpdate.length > invisibleConnectorsCount) {\n let refConnectorIdsArray: string[] = [];\n\n connectorsToUpdate.forEach(itrConId => {\n let conId = itrConId;\n if (Array.isArray(conId)) {\n conId = itrConId[0] as string;\n }\n\n const connector = graph.getConnector(conId);\n if (isPlaceHolderConnector(connector)) {\n refConnectorIdsArray = [...refConnectorIdsArray, ...connector.realConnectors];\n } else {\n refConnectorIdsArray.push(conId);\n }\n });\n\n const addNodeMeta: AddNodeHandlerParams = {\n refType: 'connector',\n refId: refConnectorIdsArray\n };\n const newNode = getNewPHNodeCB(addNodeMeta);\n const newPNode: PlaceHolderNode = {\n ...newNode,\n realConnectors: refConnectorIdsArray\n };\n graph.addNode(newPNode);\n\n connectorsToUpdate.forEach(item => {\n graph.setConnector(item as string, {\n toNodeId: newNode.id\n });\n });\n\n const newConnector = getNewPHConnectorCB(newNode.id, result.nodeId, addNodeMeta);\n const newPConnector: PlaceHolderConnector = {\n ...newConnector,\n realConnectors: refConnectorIdsArray\n };\n graph.addConnector(newPConnector);\n }\n }\n }\n }\n });\n },\n injectPlaceholderNodes: (\n graphData: GraphData<PlottedGraphNode, PlottedGraphConnector>,\n onGetNewNode: (metaData: AddNodeHandlerParams) => PlottedGraphNode,\n onGetNewConnector: (\n fromNodeId: string,\n toNodeId: string,\n metaData: AddNodeHandlerParams\n ) => PlottedGraphConnector\n ) => {\n // gets GraphData<RendererNodeProps, RendererConnectorProps>\n const targetGraph = new DirectedGraph(graphData);\n\n // insert placeholder-nodes at connector convergence point for nodes with multiple out connectors.\n PlaceHolderHelper.insertAtConnectorsMerge(targetGraph, onGetNewNode, onGetNewConnector);\n\n // iterate all nodes with more than one in-connectors and insert addNode before current one.\n targetGraph.getNodes().forEach(node => {\n // should not add a node before a placeholder node\n if (isPlaceHolderNode(node)) {\n return;\n }\n\n if (targetGraph.getPrevNodesCount(node.id) > 1) {\n let refConnectorIdsArray: string[] = [];\n\n // connect all in-connectors to a new node and create a new connector that connects from new node to the actual toNodeId.\n targetGraph.getInConnectors(node.id).forEach(con => {\n const connector = targetGraph.getConnector(con.id);\n if (isPlaceHolderConnector(connector)) {\n refConnectorIdsArray = [...refConnectorIdsArray, ...connector.realConnectors];\n } else {\n refConnectorIdsArray.push(con.id);\n }\n });\n\n const metaData: AddNodeHandlerParams = {\n refType: 'connector',\n refId: refConnectorIdsArray\n };\n\n // create a new placeholder node\n const newNode: OmitStrict<AddNodeProps, 'highlight' | 'addNodeHandler'> =\n onGetNewNode(metaData);\n const placeHolderNode: PlaceHolderNode = {\n ...newNode,\n realConnectors: refConnectorIdsArray\n };\n\n targetGraph.addNode(placeHolderNode);\n\n // connect all in-connectors to a new node and create a new connector that connects from new node to the actual toNodeId.\n targetGraph.getInConnectors(node.id).forEach(con => {\n targetGraph.setConnector(con.id, {\n toNodeId: placeHolderNode.id\n });\n });\n\n const newConnector = onGetNewConnector(placeHolderNode.id, node.id, metaData);\n const placeholderConnector: PlaceHolderConnector = {\n ...newConnector,\n realConnectors: refConnectorIdsArray\n };\n\n targetGraph.addConnector(placeholderConnector);\n }\n });\n\n return targetGraph.getGraphData();\n }\n};\n\nexport default PlaceHolderHelper;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeProps } from '../Node/Node.types';
|
|
2
|
-
import { Node, ConnectorProps, DirectedGraph, GraphData } from '../Renderer/Utils/Graph';
|
|
1
|
+
import type { NodeProps } from '../Node/Node.types';
|
|
2
|
+
import type { Node, ConnectorProps, DirectedGraph, GraphData } from '../Renderer/Utils/Graph';
|
|
3
3
|
export interface GraphDataAsMap {
|
|
4
4
|
nodes: Record<string, Node>;
|
|
5
5
|
connectors: Record<string, ConnectorProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteNodeUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/deleteNodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"deleteNodeUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/deleteNodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAI9F,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE;QACR,UAAU,EAAE,cAAc,EAAE,CAAC;KAC9B,CAAC;IACF,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,QAAA,MAAM,eAAe;kCACW,aAAa,UAAU,MAAM,KAAG,qBAAqB;CA0FpF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteNodeUtils.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/deleteNodeUtils.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"deleteNodeUtils.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Utils/deleteNodeUtils.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,kCAAkC,CAAC;AA8B9D,MAAM,eAAe,GAAG;IACtB,oBAAoB,EAAE,CAAC,KAAoB,EAAE,MAAc,EAAyB,EAAE;QACpF,MAAM,eAAe,GACnB,cAAc,CAAC,kBAAkB,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,MAAM,CA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,EAAE;gCACnC,OAAO,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;4BAClC,CAAC,CAAC,CAAC;yBACJ;oBACH,CAAC,CAAC,CAAC;oBAEH,8BAA8B;oBAC9B,OAAO,SAAS,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBAE/C,OAAO;wBACL,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;wBACpD,SAAS,EAAE;4BACT,KAAK;4BACL,UAAU;yBACX;wBACD,SAAS;qBACV,CAAC;iBACH;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,MAAM,MAAM,GAA0B;gBACpC,OAAO,EAAE,OAAkC;gBAC3C,cAAc,EAAE,MAAM;gBACtB,iBAAiB,EAAE,eAAe,CAAC,MAAM;gBACzC,QAAQ,EAAE;oBACR,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,aAAa;oBAC5C,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,kBAAkB;iBACvD;aACF,CAAC;YAEF,8BAA8B;YAC9B,IAAI,MAAM,CAAC,QAAQ;gBAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAE1E,OAAO,MAAM,CAAC;SACf;QACD,OAAO;YACL,OAAO,EAAE,EAAE;YACX,cAAc,EAAE,MAAM;YACtB,iBAAiB,EAAE,SAAS;YAC5B,QAAQ,EAAE;gBACR,KAAK,EAAE,EAAE;gBACT,UAAU,EAAE,EAAE;aACf;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import type { NodeProps } from '../Node/Node.types';\nimport type { Node, ConnectorProps, DirectedGraph, GraphData } from '../Renderer/Utils/Graph';\nimport GraphTraversal from '../Renderer/Utils/GraphTraversal';\nimport type { ConvergenceData } from '../Renderer/Utils/GraphTraversal';\n\nexport interface GraphDataAsMap {\n nodes: Record<string, Node>;\n connectors: Record<string, ConnectorProps>;\n}\n\nexport interface DeleteNodeModalOption {\n connector: ConnectorProps;\n pathItems: GraphDataAsMap;\n restItems: GraphDataAsMap;\n}\n\nexport interface DeleteNodeModalResult {\n options: DeleteNodeModalOption[];\n selectedNodeId: string;\n destinationNodeId?: string;\n allItems: GraphDataAsMap;\n}\n\nexport interface DeleteNodeOutcome {\n graphData: GraphData<NodeProps, ConnectorProps>;\n updates?: {\n connectors: ConnectorProps[];\n };\n deletes: GraphDataAsMap;\n error: boolean;\n}\n\nconst deleteNodeUtils = {\n getDeleteNodeOptions: (graph: DirectedGraph, nodeId: string): DeleteNodeModalResult => {\n const convergenceData: ConvergenceData<Node, ConnectorProps> | false =\n GraphTraversal.getConvergenceData(graph.getGraphData(), nodeId);\n\n if (convergenceData && convergenceData.paths) {\n const options = convergenceData.paths.map(path => {\n if (\n Array.isArray(path) &&\n !Array.isArray(path[0]) &&\n typeof path[0].connectors[0] === 'string'\n ) {\n let nodes: GraphDataAsMap['nodes'] = {};\n let connectors: GraphDataAsMap['connectors'] = {};\n\n // rest of the overall items\n const restItems = {\n nodes: {\n ...convergenceData.summary.nodesinvolved\n },\n connectors: {\n ...convergenceData.summary.connectorsInvolved\n }\n };\n\n path.forEach(item => {\n if (!Array.isArray(item)) {\n nodes = {\n ...nodes,\n ...item.summary.nodesinvolved\n };\n\n delete nodes[convergenceData.nodeId];\n\n // remove the above nodes from the restItems\n Object.keys(nodes).forEach(id => {\n delete restItems.nodes[id];\n });\n\n connectors = {\n ...connectors,\n ...item.summary.connectorsInvolved\n };\n\n // remove the above connectors from the restItems\n Object.keys(connectors).forEach(id => {\n delete restItems.connectors[id];\n });\n }\n });\n\n // ignore the destination node\n delete restItems.nodes[convergenceData.nodeId];\n\n return {\n connector: graph.getConnector(path[0].connectors[0]),\n pathItems: {\n nodes,\n connectors\n },\n restItems\n };\n }\n return [];\n });\n\n const result: DeleteNodeModalResult = {\n options: options as DeleteNodeModalOption[],\n selectedNodeId: nodeId,\n destinationNodeId: convergenceData.nodeId,\n allItems: {\n nodes: convergenceData.summary.nodesinvolved,\n connectors: convergenceData.summary.connectorsInvolved\n }\n };\n\n // ignore the destination node\n if (result.allItems) delete result.allItems.nodes[convergenceData.nodeId];\n\n return result;\n }\n return {\n options: [],\n selectedNodeId: nodeId,\n destinationNodeId: undefined,\n allItems: {\n nodes: {},\n connectors: {}\n }\n };\n }\n};\n\nexport default deleteNodeUtils;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GraphData, ConnectorProps } from './Renderer/Utils/Graph';
|
|
2
|
-
import { AddNodeHandlerParams } from './Renderer/Renderer.types';
|
|
3
|
-
import { NodeProps, NodeType } from './Node/Node.types';
|
|
4
|
-
import { DeleteNodeOutcome } from './Utils/deleteNodeUtils';
|
|
1
|
+
import type { GraphData, ConnectorProps } from './Renderer/Utils/Graph';
|
|
2
|
+
import type { AddNodeHandlerParams } from './Renderer/Renderer.types';
|
|
3
|
+
import type { NodeProps, NodeType } from './Node/Node.types';
|
|
4
|
+
import type { DeleteNodeOutcome } from './Utils/deleteNodeUtils';
|
|
5
5
|
export interface AddHelperParams {
|
|
6
6
|
nodeType: NodeType;
|
|
7
7
|
graphData: GraphData<NodeProps, ConnectorProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/helper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7D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AO,CAAC;IACjB,CAAC;IAED,UAAU,CAAC,SAA+C,EAAE,MAAuB;QACjF,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,YAAY;YACZ,aAAa;SACd,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { createUID } from '@pega/cosmos-react-core';\n\nimport { DirectedGraph, GraphData, ConnectorProps } from './Renderer/Utils/Graph';\nimport { AddNodeHandlerParams } from './Renderer/Renderer.types';\nimport { NodeProps, NodeType } from './Node/Node.types';\nimport GraphTraversal from './Renderer/Utils/GraphTraversal';\nimport deleteNodeUtils, { DeleteNodeOutcome, GraphDataAsMap } from './Utils/deleteNodeUtils';\n\nexport interface AddHelperParams {\n nodeType: NodeType;\n graphData: GraphData<NodeProps, ConnectorProps>;\n metaData: AddNodeHandlerParams;\n connectorsCount?: number;\n getNewNode?: () => NodeProps;\n isBranchNode: boolean;\n getNewConnector?: (fromNodeId: string, toNodeId: string) => ConnectorProps;\n}\n\nexport interface NodeInfo<\n T extends NodeProps = NodeProps,\n U extends ConnectorProps = ConnectorProps\n> {\n node: T;\n inConnectors: U[];\n outConnectors: U[];\n}\n\nconst helpers = {\n addConnector(\n graphData: GraphData<NodeProps, ConnectorProps>,\n nodeId: string,\n label?: string,\n getNewConnector?: AddHelperParams['getNewConnector']\n ) {\n const graph = new DirectedGraph<NodeProps, ConnectorProps>(graphData);\n const convergenceData = GraphTraversal.getConvergenceData(graphData, nodeId);\n const outConnectors = graph.getOutConnectors(nodeId);\n const convergenceNodeId = convergenceData ? convergenceData.nodeId : undefined;\n const targetNodeId = outConnectors.length < 2 ? outConnectors[0].toNodeId : convergenceNodeId;\n\n if (targetNodeId) {\n const newConnector = getNewConnector\n ? getNewConnector(nodeId, targetNodeId)\n : {\n id: createUID(),\n fromNodeId: nodeId,\n toNodeId: targetNodeId,\n label: label || ''\n };\n\n graph.addConnector(newConnector);\n\n return {\n graphData: graph.getGraphData(),\n connector: newConnector\n };\n }\n return { graphData: { nodes: [], connectors: [] }, connector: {} };\n },\n\n deleteConnector: (graphData: GraphData<NodeProps, ConnectorProps>, connector: ConnectorProps) => {\n const nodeId = connector.fromNodeId;\n const graph = new DirectedGraph(graphData);\n const deleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(graph, nodeId);\n const deleteOptions = deleteOptionsResult.options;\n let itemsToDelete: GraphDataAsMap = deleteOptionsResult.allItems;\n const targetNodeId = deleteOptionsResult?.destinationNodeId\n ? deleteOptionsResult.destinationNodeId\n : '';\n\n const targetBranch = deleteOptions.find(\n deleteOption => connector.id === deleteOption.connector.id\n );\n let flowConnectorExists = false;\n\n if (targetBranch) {\n itemsToDelete = targetBranch?.pathItems;\n let visibleInConnectors = graph.getInConnectors(targetNodeId);\n\n /** From the rest of the connectors check if any connector originating from a shape other than go to and\n * is having the toNode as destination node ensuring the flow to continue\n */\n const restConnectors = targetBranch.restItems.connectors;\n const connectors = Object.keys(restConnectors);\n for (let i = 0; i < connectors.length; i += 1) {\n const connectorData = restConnectors[connectors[i]];\n if (\n connectorData &&\n graph.getNode(connectorData.fromNodeId).type.minConnectors !== 0 &&\n connectorData.toNodeId === deleteOptionsResult.destinationNodeId\n ) {\n flowConnectorExists = true;\n break;\n }\n if (\n connectorData &&\n graph.getNode(connectorData.fromNodeId).type.minConnectors === 0 &&\n connectorData.toNodeId === deleteOptionsResult.destinationNodeId\n ) {\n visibleInConnectors = visibleInConnectors.filter(con => {\n return (\n graph.getNode(con.fromNodeId).type.minConnectors !== 0 &&\n con.id !== connectorData.id &&\n !targetBranch.pathItems.connectors[con.id]\n );\n });\n }\n }\n\n if (!flowConnectorExists && visibleInConnectors.length >= 1) {\n flowConnectorExists = true;\n }\n }\n // filter the highlighted nodes, including the selected node\n const nodes = graphData.nodes.filter(item => !itemsToDelete.nodes[item.id]);\n // filter the highlighted connectors\n const connectors = graphData.connectors.filter(item => !itemsToDelete.connectors[item.id]);\n\n const outcome: DeleteNodeOutcome = {\n graphData: {\n nodes,\n connectors\n },\n deletes: itemsToDelete,\n error: false\n };\n if (!flowConnectorExists) outcome.error = true;\n return outcome;\n },\n\n addNode: ({\n graphData,\n nodeType,\n isBranchNode,\n metaData,\n getNewNode,\n getNewConnector,\n connectorsCount\n }: AddHelperParams) => {\n const graph = new DirectedGraph(graphData);\n const newNode = getNewNode\n ? getNewNode()\n : {\n ...nodeType.defaults.node,\n id: createUID(),\n type: nodeType\n };\n // add new node\n graph.addNode(newNode);\n\n let toNodeId = '';\n if (metaData.refType === 'connector') {\n if (!Array.isArray(metaData.refId)) {\n metaData.refId = [metaData.refId];\n }\n metaData.refId.forEach(conId => {\n const refConnector = graph.getConnector(conId);\n // backup current connectors toNodeId\n toNodeId = refConnector.toNodeId;\n // update the actual connector\n graph.setConnector(conId, {\n toNodeId: newNode.id\n });\n });\n } else if (metaData.refType === 'node') {\n toNodeId = metaData.refId as string;\n // iterate and update all in-connectors to point to the new node\n graph.getInConnectors(metaData.refId as string).forEach(con => {\n graph.setConnector(con.id, {\n toNodeId: newNode.id\n });\n });\n }\n\n let minConnectors = 1;\n if (connectorsCount !== undefined) {\n minConnectors = connectorsCount;\n } else {\n minConnectors =\n nodeType.minConnectors !== undefined && !isBranchNode ? nodeType.minConnectors : 1;\n }\n for (let i = 0; i < minConnectors; i += 1) {\n const newConnector = getNewConnector\n ? getNewConnector(newNode.id, toNodeId)\n : {\n id: createUID(),\n fromNodeId: newNode.id,\n toNodeId,\n label: !isBranchNode ? nodeType.defaults?.connector[i].label : ''\n };\n graph.addConnector(newConnector);\n }\n\n return {\n graphData: graph.getGraphData(),\n node: newNode\n };\n },\n\n deleteNode(\n graphData: GraphData<NodeProps, ConnectorProps>,\n nodeId: string\n ): DeleteNodeOutcome | false {\n const graph = new DirectedGraph<NodeProps, ConnectorProps>(graphData);\n const node = graph.getNode(nodeId);\n const outConnectors = graph.getOutConnectors(nodeId);\n const nodes = graph.getNodes();\n\n const outcome: DeleteNodeOutcome = {\n graphData: graph.getGraphData(),\n deletes: {\n nodes: {\n [nodeId]: node\n },\n connectors: {}\n },\n error: false\n };\n\n for (let i = 0; i < nodes.length; i += 1) {\n if (nodes[i].type.minConnectors === 0 && nodes[i].reference === nodeId) {\n outcome.error = true;\n return outcome;\n }\n }\n\n if (outConnectors.length > 1) {\n return false;\n }\n\n const inConnectors = graph.getInConnectors(nodeId);\n\n const connectorUpdates: ConnectorProps[] = [];\n\n inConnectors.forEach(con => {\n graph.setConnector(con.id, {\n toNodeId: outConnectors[0].toNodeId\n });\n\n connectorUpdates.push(con);\n });\n\n graph.removeConnector(outConnectors[0].id);\n graph.deleteNode(nodeId, true);\n\n outcome.graphData = graph.getGraphData();\n outcome.updates = {\n connectors: connectorUpdates\n };\n return outcome;\n },\n\n selectNode(graphData: GraphData<NodeProps, ConnectorProps>, nodeId: NodeProps['id']): NodeInfo {\n const graph = new DirectedGraph(graphData);\n const selectedNode = graph.getNode(nodeId);\n const outConnectors = graph.getOutConnectors(nodeId);\n const inConnectors = graph.getInConnectors(nodeId);\n return {\n node: selectedNode,\n inConnectors,\n outConnectors\n };\n }\n};\n\nexport default helpers;\n"]}
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAC7D,OAAO,eAAe,MAAM,yBAAyB,CAAC;AAsBtD,MA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I,aAAa,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,YAAY;YACZ,aAAa;SACd,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { createUID } from '@pega/cosmos-react-core';\n\nimport { DirectedGraph } from './Renderer/Utils/Graph';\nimport type { GraphData, ConnectorProps } from './Renderer/Utils/Graph';\nimport type { AddNodeHandlerParams } from './Renderer/Renderer.types';\nimport type { NodeProps, NodeType } from './Node/Node.types';\nimport GraphTraversal from './Renderer/Utils/GraphTraversal';\nimport deleteNodeUtils from './Utils/deleteNodeUtils';\nimport type { DeleteNodeOutcome, GraphDataAsMap } from './Utils/deleteNodeUtils';\n\nexport interface AddHelperParams {\n nodeType: NodeType;\n graphData: GraphData<NodeProps, ConnectorProps>;\n metaData: AddNodeHandlerParams;\n connectorsCount?: number;\n getNewNode?: () => NodeProps;\n isBranchNode: boolean;\n getNewConnector?: (fromNodeId: string, toNodeId: string) => ConnectorProps;\n}\n\nexport interface NodeInfo<\n T extends NodeProps = NodeProps,\n U extends ConnectorProps = ConnectorProps\n> {\n node: T;\n inConnectors: U[];\n outConnectors: U[];\n}\n\nconst helpers = {\n addConnector(\n graphData: GraphData<NodeProps, ConnectorProps>,\n nodeId: string,\n label?: string,\n getNewConnector?: AddHelperParams['getNewConnector']\n ) {\n const graph = new DirectedGraph<NodeProps, ConnectorProps>(graphData);\n const convergenceData = GraphTraversal.getConvergenceData(graphData, nodeId);\n const outConnectors = graph.getOutConnectors(nodeId);\n const convergenceNodeId = convergenceData ? convergenceData.nodeId : undefined;\n const targetNodeId = outConnectors.length < 2 ? outConnectors[0].toNodeId : convergenceNodeId;\n\n if (targetNodeId) {\n const newConnector = getNewConnector\n ? getNewConnector(nodeId, targetNodeId)\n : {\n id: createUID(),\n fromNodeId: nodeId,\n toNodeId: targetNodeId,\n label: label || ''\n };\n\n graph.addConnector(newConnector);\n\n return {\n graphData: graph.getGraphData(),\n connector: newConnector\n };\n }\n return { graphData: { nodes: [], connectors: [] }, connector: {} };\n },\n\n deleteConnector: (graphData: GraphData<NodeProps, ConnectorProps>, connector: ConnectorProps) => {\n const nodeId = connector.fromNodeId;\n const graph = new DirectedGraph(graphData);\n const deleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(graph, nodeId);\n const deleteOptions = deleteOptionsResult.options;\n let itemsToDelete: GraphDataAsMap = deleteOptionsResult.allItems;\n const targetNodeId = deleteOptionsResult?.destinationNodeId\n ? deleteOptionsResult.destinationNodeId\n : '';\n\n const targetBranch = deleteOptions.find(\n deleteOption => connector.id === deleteOption.connector.id\n );\n let flowConnectorExists = false;\n\n if (targetBranch) {\n itemsToDelete = targetBranch?.pathItems;\n let visibleInConnectors = graph.getInConnectors(targetNodeId);\n\n /** From the rest of the connectors check if any connector originating from a shape other than go to and\n * is having the toNode as destination node ensuring the flow to continue\n */\n const restConnectors = targetBranch.restItems.connectors;\n const connectors = Object.keys(restConnectors);\n for (let i = 0; i < connectors.length; i += 1) {\n const connectorData = restConnectors[connectors[i]];\n if (\n connectorData &&\n graph.getNode(connectorData.fromNodeId).type.minConnectors !== 0 &&\n connectorData.toNodeId === deleteOptionsResult.destinationNodeId\n ) {\n flowConnectorExists = true;\n break;\n }\n if (\n connectorData &&\n graph.getNode(connectorData.fromNodeId).type.minConnectors === 0 &&\n connectorData.toNodeId === deleteOptionsResult.destinationNodeId\n ) {\n visibleInConnectors = visibleInConnectors.filter(con => {\n return (\n graph.getNode(con.fromNodeId).type.minConnectors !== 0 &&\n con.id !== connectorData.id &&\n !targetBranch.pathItems.connectors[con.id]\n );\n });\n }\n }\n\n if (!flowConnectorExists && visibleInConnectors.length >= 1) {\n flowConnectorExists = true;\n }\n }\n // filter the highlighted nodes, including the selected node\n const nodes = graphData.nodes.filter(item => !itemsToDelete.nodes[item.id]);\n // filter the highlighted connectors\n const connectors = graphData.connectors.filter(item => !itemsToDelete.connectors[item.id]);\n\n const outcome: DeleteNodeOutcome = {\n graphData: {\n nodes,\n connectors\n },\n deletes: itemsToDelete,\n error: false\n };\n if (!flowConnectorExists) outcome.error = true;\n return outcome;\n },\n\n addNode: ({\n graphData,\n nodeType,\n isBranchNode,\n metaData,\n getNewNode,\n getNewConnector,\n connectorsCount\n }: AddHelperParams) => {\n const graph = new DirectedGraph(graphData);\n const newNode = getNewNode\n ? getNewNode()\n : {\n ...nodeType.defaults.node,\n id: createUID(),\n type: nodeType\n };\n // add new node\n graph.addNode(newNode);\n\n let toNodeId = '';\n if (metaData.refType === 'connector') {\n if (!Array.isArray(metaData.refId)) {\n metaData.refId = [metaData.refId];\n }\n metaData.refId.forEach(conId => {\n const refConnector = graph.getConnector(conId);\n // backup current connectors toNodeId\n toNodeId = refConnector.toNodeId;\n // update the actual connector\n graph.setConnector(conId, {\n toNodeId: newNode.id\n });\n });\n } else if (metaData.refType === 'node') {\n toNodeId = metaData.refId as string;\n // iterate and update all in-connectors to point to the new node\n graph.getInConnectors(metaData.refId as string).forEach(con => {\n graph.setConnector(con.id, {\n toNodeId: newNode.id\n });\n });\n }\n\n let minConnectors = 1;\n if (connectorsCount !== undefined) {\n minConnectors = connectorsCount;\n } else {\n minConnectors =\n nodeType.minConnectors !== undefined && !isBranchNode ? nodeType.minConnectors : 1;\n }\n for (let i = 0; i < minConnectors; i += 1) {\n const newConnector = getNewConnector\n ? getNewConnector(newNode.id, toNodeId)\n : {\n id: createUID(),\n fromNodeId: newNode.id,\n toNodeId,\n label: !isBranchNode ? nodeType.defaults?.connector[i].label : ''\n };\n graph.addConnector(newConnector);\n }\n\n return {\n graphData: graph.getGraphData(),\n node: newNode\n };\n },\n\n deleteNode(\n graphData: GraphData<NodeProps, ConnectorProps>,\n nodeId: string\n ): DeleteNodeOutcome | false {\n const graph = new DirectedGraph<NodeProps, ConnectorProps>(graphData);\n const node = graph.getNode(nodeId);\n const outConnectors = graph.getOutConnectors(nodeId);\n const nodes = graph.getNodes();\n\n const outcome: DeleteNodeOutcome = {\n graphData: graph.getGraphData(),\n deletes: {\n nodes: {\n [nodeId]: node\n },\n connectors: {}\n },\n error: false\n };\n\n for (let i = 0; i < nodes.length; i += 1) {\n if (nodes[i].type.minConnectors === 0 && nodes[i].reference === nodeId) {\n outcome.error = true;\n return outcome;\n }\n }\n\n if (outConnectors.length > 1) {\n return false;\n }\n\n const inConnectors = graph.getInConnectors(nodeId);\n\n const connectorUpdates: ConnectorProps[] = [];\n\n inConnectors.forEach(con => {\n graph.setConnector(con.id, {\n toNodeId: outConnectors[0].toNodeId\n });\n\n connectorUpdates.push(con);\n });\n\n graph.removeConnector(outConnectors[0].id);\n graph.deleteNode(nodeId, true);\n\n outcome.graphData = graph.getGraphData();\n outcome.updates = {\n connectors: connectorUpdates\n };\n return outcome;\n },\n\n selectNode(graphData: GraphData<NodeProps, ConnectorProps>, nodeId: NodeProps['id']): NodeInfo {\n const graph = new DirectedGraph(graphData);\n const selectedNode = graph.getNode(nodeId);\n const outConnectors = graph.getOutConnectors(nodeId);\n const inConnectors = graph.getInConnectors(nodeId);\n return {\n node: selectedNode,\n inConnectors,\n outConnectors\n };\n }\n};\n\nexport default helpers;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC, Ref } from 'react';
|
|
2
|
-
import { SearchInputProps, ForwardProps, MenuItemProps, PopoverProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { ColorName } from '../../utils';
|
|
1
|
+
import type { FC, Ref } from 'react';
|
|
2
|
+
import type { SearchInputProps, ForwardProps, MenuItemProps, PopoverProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { ColorName } from '../../utils';
|
|
4
4
|
export interface LibraryItem extends MenuItemProps {
|
|
5
5
|
id: string;
|
|
6
6
|
type: ItemVisual;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemLibrary.d.ts","sourceRoot":"","sources":["../../../src/components/ItemLibrary/ItemLibrary.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ItemLibrary.d.ts","sourceRoot":"","sources":["../../../src/components/ItemLibrary/ItemLibrary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAmB,GAAG,EAAiB,MAAM,OAAO,CAAC;AAcrE,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EAEZ,aAAa,EACb,YAAY,EACb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;CACvB;AACD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IACnE,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACtC;AAED,eAAO,MAAM,UAAU,yGAWrB,CAAC;AAIH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,GAAG,YAAY,CA4FnD,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemLibrary.js","sourceRoot":"","sources":["../../../src/components/ItemLibrary/ItemLibrary.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ItemLibrary.js","sourceRoot":"","sources":["../../../src/components/ItemLibrary/ItemLibrary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,OAAO,EACP,WAAW,EACX,GAAG,EACH,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsBvC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjD,OAAO,GAAG,CAAA;;;0BAGc,KAAK,CAAC,IAAI,CAAC,OAAO;yBACnB,KAAK,CAAC,IAAI,CAAC,OAAO;;;;qBAItB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;GAC7C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,WAAW,GAAwC,UAAU,CAAC,SAAS,WAAW,CACtF,EACE,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,QAAQ,GAAG,cAAc,EACS,EACpC,GAA4B;IAE5B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CA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AAI,CAAC;AACX,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { FC, PropsWithoutRef, Ref, CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Icon,\n Menu,\n menuHelpers,\n Popover,\n SearchInput,\n cap,\n createStringMatcher,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\nimport type {\n SearchInputProps,\n ForwardProps,\n MenuGroupProps,\n MenuItemProps,\n PopoverProps\n} from '@pega/cosmos-react-core';\n\nimport { colorMap } from '../../utils';\nimport type { ColorName } from '../../utils';\n\nexport interface LibraryItem extends MenuItemProps {\n id: string;\n type: ItemVisual;\n items?: LibraryItem[];\n}\nexport interface ItemVisual {\n color: ColorName;\n icon: string;\n}\nexport interface ItemLibraryProps<T extends LibraryItem = LibraryItem> {\n show: boolean;\n target: HTMLElement | null;\n items: T[];\n onClick?: (libItem: T) => void;\n ref?: Ref<HTMLDivElement>;\n placeholder?: SearchInputProps['placeholder'];\n position?: PopoverProps['placement'];\n}\n\nexport const StyledIcon = styled.div(({ theme }) => {\n return css`\n min-height: 2rem;\n min-width: 2rem;\n padding: calc(0.5 * ${theme.base.spacing});\n margin-inline-end: ${theme.base.spacing};\n text-align: center;\n background-color: var(--bg-color);\n color: var(--fg-color);\n border-radius: ${theme.base['border-radius']};\n `;\n});\n\nStyledIcon.defaultProps = defaultThemeProp;\n\nconst ItemLibrary: FC<ItemLibraryProps & ForwardProps> = forwardRef(function ItemLibrary(\n {\n show,\n target,\n items,\n onClick,\n placeholder,\n position = 'bottom-start'\n }: PropsWithoutRef<ItemLibraryProps>,\n ref: ItemLibraryProps['ref']\n) {\n const [search, setSearch] = useState('');\n\n const searchEleRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (show) {\n setSearch('');\n searchEleRef?.current?.focus();\n }\n }, [show, searchEleRef.current]);\n\n const searchRegex = useMemo(\n () => (search ? createStringMatcher(cap(search), 'contains', '') : null),\n [search]\n );\n\n const itemsToRender: (MenuItemProps | MenuGroupProps)[] = useMemo(() => {\n return menuHelpers.mapTree(\n searchRegex\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return searchRegex.test(primary);\n })\n : items,\n node => {\n let selectable = false;\n if (!node.items) {\n selectable = true;\n }\n\n const nodeItem: LibraryItem = node as LibraryItem;\n return {\n ...node,\n visual: nodeItem.type ? (\n <StyledIcon\n id={node.id}\n style={\n {\n '--bg-color': colorMap[nodeItem.type.color],\n '--fg-color': readableColor(colorMap[nodeItem.type.color])\n } as CSSProperties\n }\n >\n <Icon name={nodeItem.type.icon} />\n </StyledIcon>\n ) : undefined,\n count: node.items ? node.items.length : undefined,\n secondary: node.secondary,\n selected: selectable ? !!node.selected : undefined\n };\n }\n );\n }, [items, searchRegex]);\n\n const onItemSelect = useCallback(\n (id: MenuItemProps['id']) => {\n const selectedNode = menuHelpers.getItem(items, id) as LibraryItem;\n if (onClick) {\n onClick(selectedNode);\n }\n },\n [onClick]\n );\n\n return show ? (\n <Popover show={show} placement={position} target={target} ref={ref}>\n <Menu\n items={itemsToRender}\n onItemClick={onItemSelect}\n header={\n <SearchInput\n ref={searchEleRef}\n onSearchChange={setSearch}\n value={search}\n searchInputAriaLabel={placeholder}\n placeholder={placeholder}\n />\n }\n focusControlEl={searchEleRef.current || undefined}\n />\n </Popover>\n ) : null;\n});\n\nexport default ItemLibrary;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { CategoriesProps, CategoryProps } from './LifeCycle.types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { CategoriesProps, CategoryProps } from './LifeCycle.types';
|
|
4
4
|
export declare const StyledCategory: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {
|
|
5
5
|
showTitle: boolean;
|
|
6
6
|
}, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Category.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/Category.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Category.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/Category.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAI5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAGV,eAAe,EACf,aAAa,EACd,MAAM,mBAAmB,CAAC;AAI3B,eAAO,MAAM,cAAc;eAA0B,OAAO;SAQ1D,CAAC;AAIH,eAAO,MAAM,UAAU;eAA0B,eAAe,GAAG,SAAS;QAAM,MAAM;SAWvF,CAAC;AAIF,eAAO,MAAM,mBAAmB,yGA0B9B,CAAC;AAIH,eAAO,MAAM,aAAa,yGAaxB,CAAC;AAIH,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CA2G5D,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|