@pega/cosmos-react-build 2.1.6 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/lib/components/AppHeader/AppHeader.d.ts +29 -0
  2. package/lib/components/AppHeader/AppHeader.d.ts.map +1 -0
  3. package/lib/components/AppHeader/AppHeader.js +32 -0
  4. package/lib/components/AppHeader/AppHeader.js.map +1 -0
  5. package/lib/components/AppHeader/AppHeader.styles.d.ts +12 -0
  6. package/lib/components/AppHeader/AppHeader.styles.d.ts.map +1 -0
  7. package/lib/components/AppHeader/AppHeader.styles.js +123 -0
  8. package/lib/components/AppHeader/AppHeader.styles.js.map +1 -0
  9. package/lib/components/AppHeader/index.d.ts +3 -0
  10. package/lib/components/AppHeader/index.d.ts.map +1 -0
  11. package/lib/components/AppHeader/index.js +2 -0
  12. package/lib/components/AppHeader/index.js.map +1 -0
  13. package/lib/components/AppShell/AppShell.d.ts +4 -0
  14. package/lib/components/AppShell/AppShell.d.ts.map +1 -0
  15. package/lib/components/AppShell/AppShell.js +84 -0
  16. package/lib/components/AppShell/AppShell.js.map +1 -0
  17. package/lib/components/AppShell/AppShell.styles.d.ts +20 -0
  18. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -0
  19. package/lib/components/AppShell/AppShell.styles.js +331 -0
  20. package/lib/components/AppShell/AppShell.styles.js.map +1 -0
  21. package/lib/components/AppShell/AppShell.types.d.ts +43 -0
  22. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -0
  23. package/lib/components/AppShell/AppShell.types.js +2 -0
  24. package/lib/components/AppShell/AppShell.types.js.map +1 -0
  25. package/lib/components/AppShell/AppShellContext.d.ts +4 -0
  26. package/lib/components/AppShell/AppShellContext.d.ts.map +1 -0
  27. package/lib/components/AppShell/AppShellContext.js +10 -0
  28. package/lib/components/AppShell/AppShellContext.js.map +1 -0
  29. package/lib/components/AppShell/index.d.ts +3 -0
  30. package/lib/components/AppShell/index.d.ts.map +1 -0
  31. package/lib/components/AppShell/index.js +2 -0
  32. package/lib/components/AppShell/index.js.map +1 -0
  33. package/lib/components/FlowModeller/AddNode.d.ts +16 -0
  34. package/lib/components/FlowModeller/AddNode.d.ts.map +1 -0
  35. package/lib/components/FlowModeller/AddNode.js +62 -0
  36. package/lib/components/FlowModeller/AddNode.js.map +1 -0
  37. package/lib/components/FlowModeller/FlowModeller.d.ts +21 -0
  38. package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -0
  39. package/lib/components/FlowModeller/FlowModeller.js +190 -0
  40. package/lib/components/FlowModeller/FlowModeller.js.map +1 -0
  41. package/lib/components/FlowModeller/Node/Node.types.d.ts +54 -0
  42. package/lib/components/FlowModeller/Node/Node.types.d.ts.map +1 -0
  43. package/lib/components/FlowModeller/Node/Node.types.js +28 -0
  44. package/lib/components/FlowModeller/Node/Node.types.js.map +1 -0
  45. package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts +15 -0
  46. package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -0
  47. package/lib/components/FlowModeller/Node/NodeTemplate.styles.js +128 -0
  48. package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -0
  49. package/lib/components/FlowModeller/Node/NodeTemplates.d.ts +6 -0
  50. package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -0
  51. package/lib/components/FlowModeller/Node/NodeTemplates.js +64 -0
  52. package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -0
  53. package/lib/components/FlowModeller/NodeLibrary.d.ts +13 -0
  54. package/lib/components/FlowModeller/NodeLibrary.d.ts.map +1 -0
  55. package/lib/components/FlowModeller/NodeLibrary.js +51 -0
  56. package/lib/components/FlowModeller/NodeLibrary.js.map +1 -0
  57. package/lib/components/FlowModeller/Renderer/Connectors.d.ts +13 -0
  58. package/lib/components/FlowModeller/Renderer/Connectors.d.ts.map +1 -0
  59. package/lib/components/FlowModeller/Renderer/Connectors.js +47 -0
  60. package/lib/components/FlowModeller/Renderer/Connectors.js.map +1 -0
  61. package/lib/components/FlowModeller/Renderer/Nodes.d.ts +9 -0
  62. package/lib/components/FlowModeller/Renderer/Nodes.d.ts.map +1 -0
  63. package/lib/components/FlowModeller/Renderer/Nodes.js +25 -0
  64. package/lib/components/FlowModeller/Renderer/Nodes.js.map +1 -0
  65. package/lib/components/FlowModeller/Renderer/Renderer.d.ts +5 -0
  66. package/lib/components/FlowModeller/Renderer/Renderer.d.ts.map +1 -0
  67. package/lib/components/FlowModeller/Renderer/Renderer.js +17 -0
  68. package/lib/components/FlowModeller/Renderer/Renderer.js.map +1 -0
  69. package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts +18 -0
  70. package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts.map +1 -0
  71. package/lib/components/FlowModeller/Renderer/Renderer.types.js +2 -0
  72. package/lib/components/FlowModeller/Renderer/Renderer.types.js.map +1 -0
  73. package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts +54 -0
  74. package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts.map +1 -0
  75. package/lib/components/FlowModeller/Renderer/Utils/Graph.js +302 -0
  76. package/lib/components/FlowModeller/Renderer/Utils/Graph.js.map +1 -0
  77. package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts +35 -0
  78. package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts.map +1 -0
  79. package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js +107 -0
  80. package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js.map +1 -0
  81. package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts +24 -0
  82. package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts.map +1 -0
  83. package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js +152 -0
  84. package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js.map +1 -0
  85. package/lib/components/FlowModeller/Utils/AddNodeUtils.d.ts +16 -0
  86. package/lib/components/FlowModeller/Utils/AddNodeUtils.d.ts.map +1 -0
  87. package/lib/components/FlowModeller/Utils/AddNodeUtils.js +118 -0
  88. package/lib/components/FlowModeller/Utils/AddNodeUtils.js.map +1 -0
  89. package/lib/components/FlowModeller/helper.d.ts +23 -0
  90. package/lib/components/FlowModeller/helper.d.ts.map +1 -0
  91. package/lib/components/FlowModeller/helper.js +128 -0
  92. package/lib/components/FlowModeller/helper.js.map +1 -0
  93. package/lib/components/FlowModeller/index.d.ts +10 -0
  94. package/lib/components/FlowModeller/index.d.ts.map +1 -0
  95. package/lib/components/FlowModeller/index.js +8 -0
  96. package/lib/components/FlowModeller/index.js.map +1 -0
  97. package/lib/components/LifeCycle/Category.d.ts +32 -0
  98. package/lib/components/LifeCycle/Category.d.ts.map +1 -0
  99. package/lib/components/LifeCycle/Category.js +98 -0
  100. package/lib/components/LifeCycle/Category.js.map +1 -0
  101. package/lib/components/LifeCycle/LifeCycle.d.ts +22 -0
  102. package/lib/components/LifeCycle/LifeCycle.d.ts.map +1 -0
  103. package/lib/components/LifeCycle/LifeCycle.js +73 -0
  104. package/lib/components/LifeCycle/LifeCycle.js.map +1 -0
  105. package/lib/components/LifeCycle/LifeCycle.types.d.ts +56 -0
  106. package/lib/components/LifeCycle/LifeCycle.types.d.ts.map +1 -0
  107. package/lib/components/LifeCycle/LifeCycle.types.js +2 -0
  108. package/lib/components/LifeCycle/LifeCycle.types.js.map +1 -0
  109. package/lib/components/LifeCycle/LifeCycleList.d.ts +22 -0
  110. package/lib/components/LifeCycle/LifeCycleList.d.ts.map +1 -0
  111. package/lib/components/LifeCycle/LifeCycleList.js +65 -0
  112. package/lib/components/LifeCycle/LifeCycleList.js.map +1 -0
  113. package/lib/components/LifeCycle/Stage.d.ts +49 -0
  114. package/lib/components/LifeCycle/Stage.d.ts.map +1 -0
  115. package/lib/components/LifeCycle/Stage.js +293 -0
  116. package/lib/components/LifeCycle/Stage.js.map +1 -0
  117. package/lib/components/LifeCycle/Step.d.ts +51 -0
  118. package/lib/components/LifeCycle/Step.d.ts.map +1 -0
  119. package/lib/components/LifeCycle/Step.js +241 -0
  120. package/lib/components/LifeCycle/Step.js.map +1 -0
  121. package/lib/components/LifeCycle/Task.d.ts +53 -0
  122. package/lib/components/LifeCycle/Task.d.ts.map +1 -0
  123. package/lib/components/LifeCycle/Task.js +188 -0
  124. package/lib/components/LifeCycle/Task.js.map +1 -0
  125. package/lib/components/LifeCycle/index.d.ts +4 -0
  126. package/lib/components/LifeCycle/index.d.ts.map +1 -0
  127. package/lib/components/LifeCycle/index.js +2 -0
  128. package/lib/components/LifeCycle/index.js.map +1 -0
  129. package/lib/components/PageTemplates/GalleryPage.d.ts +23 -0
  130. package/lib/components/PageTemplates/GalleryPage.d.ts.map +1 -0
  131. package/lib/components/PageTemplates/GalleryPage.js +23 -0
  132. package/lib/components/PageTemplates/GalleryPage.js.map +1 -0
  133. package/lib/components/PageTemplates/GalleryPage.styles.d.ts +9 -0
  134. package/lib/components/PageTemplates/GalleryPage.styles.d.ts.map +1 -0
  135. package/lib/components/PageTemplates/GalleryPage.styles.js +70 -0
  136. package/lib/components/PageTemplates/GalleryPage.styles.js.map +1 -0
  137. package/lib/components/PageTemplates/PageTemplates.d.ts +27 -0
  138. package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -0
  139. package/lib/components/PageTemplates/PageTemplates.js +105 -0
  140. package/lib/components/PageTemplates/PageTemplates.js.map +1 -0
  141. package/lib/components/PageTemplates/index.d.ts +5 -0
  142. package/lib/components/PageTemplates/index.d.ts.map +1 -0
  143. package/lib/components/PageTemplates/index.js +4 -0
  144. package/lib/components/PageTemplates/index.js.map +1 -0
  145. package/lib/components/SummaryCard/SummaryCard.d.ts +16 -0
  146. package/lib/components/SummaryCard/SummaryCard.d.ts.map +1 -0
  147. package/lib/components/SummaryCard/SummaryCard.js +31 -0
  148. package/lib/components/SummaryCard/SummaryCard.js.map +1 -0
  149. package/lib/components/SummaryCard/index.d.ts +3 -0
  150. package/lib/components/SummaryCard/index.d.ts.map +1 -0
  151. package/lib/components/SummaryCard/index.js +3 -0
  152. package/lib/components/SummaryCard/index.js.map +1 -0
  153. package/lib/components/Visual/Visual.d.ts +17 -0
  154. package/lib/components/Visual/Visual.d.ts.map +1 -0
  155. package/lib/components/Visual/Visual.js +28 -0
  156. package/lib/components/Visual/Visual.js.map +1 -0
  157. package/lib/components/Visual/index.d.ts +3 -0
  158. package/lib/components/Visual/index.d.ts.map +1 -0
  159. package/lib/components/Visual/index.js +3 -0
  160. package/lib/components/Visual/index.js.map +1 -0
  161. package/lib/components/Workbench/ConfigurationPanel.d.ts +5 -0
  162. package/lib/components/Workbench/ConfigurationPanel.d.ts.map +1 -0
  163. package/lib/components/Workbench/ConfigurationPanel.js +21 -0
  164. package/lib/components/Workbench/ConfigurationPanel.js.map +1 -0
  165. package/lib/components/Workbench/Toolbar.d.ts +14 -0
  166. package/lib/components/Workbench/Toolbar.d.ts.map +1 -0
  167. package/lib/components/Workbench/Toolbar.js +14 -0
  168. package/lib/components/Workbench/Toolbar.js.map +1 -0
  169. package/lib/components/Workbench/UtilityPanel.d.ts +7 -0
  170. package/lib/components/Workbench/UtilityPanel.d.ts.map +1 -0
  171. package/lib/components/Workbench/UtilityPanel.js +12 -0
  172. package/lib/components/Workbench/UtilityPanel.js.map +1 -0
  173. package/lib/components/Workbench/Workbench.d.ts +6 -0
  174. package/lib/components/Workbench/Workbench.d.ts.map +1 -0
  175. package/lib/components/Workbench/Workbench.js +24 -0
  176. package/lib/components/Workbench/Workbench.js.map +1 -0
  177. package/lib/components/Workbench/Workbench.styles.d.ts +10 -0
  178. package/lib/components/Workbench/Workbench.styles.d.ts.map +1 -0
  179. package/lib/components/Workbench/Workbench.styles.js +71 -0
  180. package/lib/components/Workbench/Workbench.styles.js.map +1 -0
  181. package/lib/components/Workbench/Workbench.types.d.ts +49 -0
  182. package/lib/components/Workbench/Workbench.types.d.ts.map +1 -0
  183. package/lib/components/Workbench/Workbench.types.js +2 -0
  184. package/lib/components/Workbench/Workbench.types.js.map +1 -0
  185. package/lib/components/Workbench/index.d.ts +2 -0
  186. package/lib/components/Workbench/index.d.ts.map +1 -0
  187. package/lib/components/Workbench/index.js +2 -0
  188. package/lib/components/Workbench/index.js.map +1 -0
  189. package/lib/index.d.ts +13 -0
  190. package/lib/index.d.ts.map +1 -0
  191. package/lib/index.js +14 -0
  192. package/lib/index.js.map +1 -0
  193. package/package.json +3 -3
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import styled from 'styled-components';
4
+ import { readableColor } from 'polished';
5
+ import { Icon, Menu, menuHelpers, Popover, SearchInput, useI18n, cap, createStringMatcher } from '@pega/cosmos-react-core';
6
+ import { StyledIcon } from './Node/NodeTemplate.styles';
7
+ const StyledPopover = styled(Popover) `
8
+ min-width: 40ch;
9
+ `;
10
+ const NodeLibrary = forwardRef(({ show, target, items, onClick }, ref) => {
11
+ const [search, setSearch] = useState('');
12
+ const t = useI18n();
13
+ const searchEleRef = useRef(null);
14
+ useEffect(() => {
15
+ if (show) {
16
+ setSearch('');
17
+ searchEleRef?.current?.focus();
18
+ }
19
+ }, [show, searchEleRef.current]);
20
+ const searchRegex = useMemo(() => (search ? createStringMatcher(cap(search), 'contains', '') : null), [search]);
21
+ const itemsToRender = useMemo(() => {
22
+ return menuHelpers.mapTree(searchRegex
23
+ ? menuHelpers.flatten(items).filter(({ primary }) => {
24
+ return searchRegex.test(primary);
25
+ })
26
+ : items, node => {
27
+ let selectable = false;
28
+ if (!node.items) {
29
+ selectable = true;
30
+ }
31
+ const nodeItem = node;
32
+ return {
33
+ ...node,
34
+ visual: nodeItem.type ? (_jsx(StyledIcon, { id: node.id, style: {
35
+ '--bg-color': nodeItem.type.color,
36
+ '--fg-color': readableColor(nodeItem.type.color)
37
+ }, children: _jsx(Icon, { name: nodeItem.type.icon }, void 0) }, void 0)) : undefined,
38
+ count: node.items ? node.items.length : undefined,
39
+ secondary: node.secondary,
40
+ selected: selectable ? !!node.selected : undefined
41
+ };
42
+ });
43
+ }, [items, searchRegex]);
44
+ const onItemSelect = useCallback((id) => {
45
+ const selectedNode = menuHelpers.getItem(items, id);
46
+ onClick(selectedNode);
47
+ }, [onClick]);
48
+ return (_jsx(_Fragment, { children: show && (_jsx(StyledPopover, { show: show, target: target, ref: ref, children: _jsx(Menu, { items: itemsToRender, onItemClick: onItemSelect, header: _jsx(SearchInput, { ref: searchEleRef, onSearchChange: setSearch, value: search, searchInputAriaLabel: t('search_nodes'), placeholder: t('search_nodes') }, void 0) }, void 0) }, void 0)) }, void 0));
49
+ });
50
+ export default NodeLibrary;
51
+ //# sourceMappingURL=NodeLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeLibrary.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/NodeLibrary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAGV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,WAAW,EAEX,OAAO,EACP,WAAW,EACX,OAAO,EACP,GAAG,EACH,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,aAAa,GAAmB,MAAM,CAAC,OAAO,CAAC,CAAA;;CAEpD,CAAC;AAUF,MAAM,WAAW,GAAwC,UAAU,CACjE,CACE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAqC,EACnE,GAA4B,EAC5B,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC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WithoutRef,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n CSSProperties\n} from 'react';\nimport styled from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n ForwardProps,\n Icon,\n Menu,\n MenuGroupProps,\n menuHelpers,\n MenuItemProps,\n Popover,\n SearchInput,\n useI18n,\n cap,\n createStringMatcher\n} from '@pega/cosmos-react-core';\n\nimport { NodeLibraryItem } from './Node/Node.types';\nimport { StyledIcon } from './Node/NodeTemplate.styles';\n\nconst StyledPopover: typeof Popover = styled(Popover)`\n min-width: 40ch;\n`;\n\nexport interface NodeLibraryProps {\n show: boolean;\n target: HTMLElement | null;\n items: NodeLibraryItem[];\n onClick: (libItem: NodeLibraryItem) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst NodeLibrary: FC<NodeLibraryProps & ForwardProps> = forwardRef(\n (\n { show, target, items, onClick }: PropsWithoutRef<NodeLibraryProps>,\n ref: NodeLibraryProps['ref']\n ) => {\n const [search, setSearch] = useState('');\n\n const t = useI18n();\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: NodeLibraryItem = node as NodeLibraryItem;\n return {\n ...node,\n visual: nodeItem.type ? (\n <StyledIcon\n id={node.id}\n style={\n {\n '--bg-color': nodeItem.type.color,\n '--fg-color': readableColor(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 NodeLibraryItem;\n onClick(selectedNode);\n },\n [onClick]\n );\n return (\n <>\n {show && (\n <StyledPopover show={show} 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={t('search_nodes')}\n placeholder={t('search_nodes')}\n />\n }\n />\n </StyledPopover>\n )}\n </>\n );\n }\n);\n\nexport default NodeLibrary;\n"]}
@@ -0,0 +1,13 @@
1
+ import { FC, ComponentType } from 'react';
2
+ import { RendererConnectorProps } from './Renderer.types';
3
+ export interface ConnectorProps {
4
+ items: RendererConnectorProps[];
5
+ dimensions: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ content?: ComponentType<RendererConnectorProps>;
10
+ }
11
+ declare const Connectors: FC<ConnectorProps>;
12
+ export default Connectors;
13
+ //# sourceMappingURL=Connectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connectors.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Connectors.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAyD1D,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CACjD;AACD,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,cAAc,CAqClC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styled from 'styled-components';
3
+ import { useTheme } from '@pega/cosmos-react-core';
4
+ const CURVE_RADIUS = 16;
5
+ const genLine = (points) => {
6
+ const lineStr = points
7
+ .map((point, idx, arr) => {
8
+ const { x, y } = point;
9
+ const prev = arr[idx - 1];
10
+ const next = arr[idx + 1];
11
+ const line = `L${x},${y}`;
12
+ // if the point is extream end, no need to add a curve
13
+ if (!prev || !next)
14
+ return line;
15
+ // if point is colinear with prev and next, no need to add a curve
16
+ if (prev.x === next.x || prev.y === next.y)
17
+ return line;
18
+ if (point.x > next.x)
19
+ // BOTTOM-RIGHT ↲
20
+ return `L${x},${y - CURVE_RADIUS}a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 1 -${CURVE_RADIUS},${CURVE_RADIUS}`;
21
+ // BOTTOM-LEFT ↳
22
+ if (point.x < next.x)
23
+ return `L${x},${y - CURVE_RADIUS}a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 0 ${CURVE_RADIUS},${CURVE_RADIUS}`;
24
+ // TOP-LEFT ↱
25
+ if (point.x < prev.x)
26
+ return `L${x + CURVE_RADIUS},${y}a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 0 -${CURVE_RADIUS},${CURVE_RADIUS}`;
27
+ // TOP-RIGHT ↴
28
+ if (point.x > prev.x)
29
+ return `L${x - CURVE_RADIUS},${y}a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 1 ${CURVE_RADIUS},${CURVE_RADIUS}`;
30
+ return `L${x},${y}`;
31
+ })
32
+ .join('');
33
+ return `M${lineStr.substr(1)}`;
34
+ };
35
+ const StyledConnectorContainer = styled.div `
36
+ position: absolute;
37
+ top: 0;
38
+ left: 0;
39
+ `;
40
+ const Connectors = ({ items, dimensions, content: Content }) => {
41
+ const theme = useTheme();
42
+ return (_jsx(StyledConnectorContainer, { children: _jsx("svg", { width: dimensions.width, height: dimensions.height, xmlns: 'http://www.w3.org/2000/svg', viewBox: `0 0 ${dimensions.width} ${dimensions.height}`, children: items.map(item => {
43
+ return (_jsxs("g", { children: [_jsx("path", { id: item.id, d: genLine(item.points), stroke: theme.base.colors.slate.dark, strokeWidth: '1', fill: 'none' }, void 0), item.labelLayout && (_jsx("foreignObject", { x: item.labelLayout.x - item.labelLayout.width, y: item.points.length > 10 ? item.points[3].y - 15 : item.labelLayout.y - 7.5, width: item.labelLayout.width, height: item.labelLayout.height, children: Content && _jsx(Content, { ...item }, void 0) }, void 0))] }, item.id));
44
+ }) }, void 0) }, void 0));
45
+ };
46
+ export default Connectors;
47
+ //# sourceMappingURL=Connectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connectors.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Connectors.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AASnD,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,OAAO,GAAG,CAAC,MAAgB,EAAE,EAAE;IACnC,MAAM,OAAO,GAAW,MAAM;SAC3B,GAAG,CAAC,CAAC,KAAa,EAAE,GAAW,EAAE,GAAa,EAAE,EAAE;QACjD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC;QACvB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAE1B,sDAAsD;QACtD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEhC,kEAAkE;QAClE,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAA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AU,CAAC,MAAM,EACzB,KAAK,EAAC,4BAA4B,EAClC,OAAO,EAAE,OAAO,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE,YAEtD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBAChB,OAAO,CACL,wBACE,eACE,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACpC,WAAW,EAAC,GAAG,EACf,IAAI,EAAC,MAAM,WACX,EACD,IAAI,CAAC,WAAW,IAAI,CACnB,wBACE,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAC9C,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,GAAG,EAC7E,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,EAC7B,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,YAE9B,OAAO,IAAI,KAAC,OAAO,OAAK,IAAI,WAAI,WACnB,CACjB,KAjBK,IAAI,CAAC,EAAE,CAkBX,CACL,CAAC;YACJ,CAAC,CAAC,WACE,WACmB,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC, ComponentType } from 'react';\nimport styled from 'styled-components';\n\nimport { useTheme } from '@pega/cosmos-react-core';\n\nimport { RendererConnectorProps } from './Renderer.types';\n\ninterface Points {\n x: number;\n y: number;\n}\n\nconst CURVE_RADIUS = 16;\nconst genLine = (points: Points[]) => {\n const lineStr: string = points\n .map((point: Points, idx: number, arr: Points[]) => {\n const { x, y } = point;\n const prev = arr[idx - 1];\n const next = arr[idx + 1];\n const line = `L${x},${y}`;\n\n // if the point is extream end, no need to add a curve\n if (!prev || !next) return line;\n\n // if point is colinear with prev and next, no need to add a curve\n if (prev.x === next.x || prev.y === next.y) return line;\n\n if (point.x > next.x)\n // BOTTOM-RIGHT ↲\n return `L${x},${\n y - CURVE_RADIUS\n }a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 1 -${CURVE_RADIUS},${CURVE_RADIUS}`;\n\n // BOTTOM-LEFT ↳\n if (point.x < next.x)\n return `L${x},${\n y - CURVE_RADIUS\n }a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 0 ${CURVE_RADIUS},${CURVE_RADIUS}`;\n\n // TOP-LEFT ↱\n if (point.x < prev.x)\n return `L${\n x + CURVE_RADIUS\n },${y}a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 0 -${CURVE_RADIUS},${CURVE_RADIUS}`;\n\n // TOP-RIGHT ↴\n if (point.x > prev.x)\n return `L${\n x - CURVE_RADIUS\n },${y}a${CURVE_RADIUS},${CURVE_RADIUS} 0 0 1 ${CURVE_RADIUS},${CURVE_RADIUS}`;\n\n return `L${x},${y}`;\n })\n .join('');\n return `M${lineStr.substr(1)}`;\n};\n\nconst StyledConnectorContainer = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n`;\nexport interface ConnectorProps {\n items: RendererConnectorProps[];\n dimensions: {\n width: number;\n height: number;\n };\n content?: ComponentType<RendererConnectorProps>;\n}\nconst Connectors: FC<ConnectorProps> = ({ items, dimensions, content: Content }) => {\n const theme = useTheme();\n\n return (\n <StyledConnectorContainer>\n <svg\n width={dimensions.width}\n height={dimensions.height}\n xmlns='http://www.w3.org/2000/svg'\n viewBox={`0 0 ${dimensions.width} ${dimensions.height}`}\n >\n {items.map(item => {\n return (\n <g key={item.id}>\n <path\n id={item.id}\n d={genLine(item.points)}\n stroke={theme.base.colors.slate.dark}\n strokeWidth='1'\n fill='none'\n />\n {item.labelLayout && (\n <foreignObject\n x={item.labelLayout.x - item.labelLayout.width}\n y={item.points.length > 10 ? item.points[3].y - 15 : item.labelLayout.y - 7.5}\n width={item.labelLayout.width}\n height={item.labelLayout.height}\n >\n {Content && <Content {...item} />}\n </foreignObject>\n )}\n </g>\n );\n })}\n </svg>\n </StyledConnectorContainer>\n );\n};\n\nexport default Connectors;\n"]}
@@ -0,0 +1,9 @@
1
+ import { ComponentType, FC } from 'react';
2
+ import { RendererNodeProps } from './Renderer.types';
3
+ export interface NodesProps {
4
+ items: RendererNodeProps[];
5
+ content?: ComponentType<RendererNodeProps>;
6
+ }
7
+ declare const Nodes: FC<NodesProps>;
8
+ export default Nodes;
9
+ //# sourceMappingURL=Nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nodes.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Nodes.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAoBrD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC5C;AACD,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAmBzB,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled, { css } from 'styled-components';
3
+ import { Flex } from '@pega/cosmos-react-core';
4
+ const StyledNodeWrapper = styled.div(({ dimensions, position }) => {
5
+ return css `
6
+ position: absolute;
7
+ top: 0;
8
+ left: 0;
9
+ width: ${dimensions.width}px;
10
+ height: ${dimensions.height}px;
11
+ transform: translate(${position.x}px, ${position.y}px);
12
+ `;
13
+ });
14
+ const StyledNodeContainer = styled.div `
15
+ position: absolute;
16
+ top: 0;
17
+ left: 0;
18
+ `;
19
+ const Nodes = ({ items, content: Node }) => {
20
+ return (_jsx(StyledNodeContainer, { children: items.map(item => {
21
+ return (_jsx(Flex, { as: StyledNodeWrapper, id: item.id, dimensions: item.dimensions, position: item.position, container: { justify: 'center' }, children: Node && _jsx(Node, { ...item }, void 0) }, item.id));
22
+ }) }, void 0));
23
+ };
24
+ export default Nodes;
25
+ //# sourceMappingURL=Nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nodes.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Nodes.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAI/C,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAGjC,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAA;;;;aAIC,UAAU,CAAC,KAAK;cACf,UAAU,CAAC,MAAM;2BACJ,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC,CAAC;GACnD,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIrC,CAAC;AAKF,MAAM,KAAK,GAAmB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;IACzD,OAAO,CACL,KAAC,mBAAmB,cACjB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,CACL,KAAC,IAAI,IAEH,EAAE,EAAE,iBAAiB,EACrB,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YAE/B,IAAI,IAAI,KAAC,IAAI,OAAK,IAAI,WAAI,IAPtB,IAAI,CAAC,EAAE,CAQP,CACR,CAAC;QACJ,CAAC,CAAC,WACkB,CACvB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { ComponentType, FC } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex } from '@pega/cosmos-react-core';\n\nimport { RendererNodeProps } from './Renderer.types';\n\nconst StyledNodeWrapper = styled.div<{\n dimensions: RendererNodeProps['dimensions'];\n position: RendererNodeProps['position'];\n}>(({ dimensions, position }) => {\n return css`\n position: absolute;\n top: 0;\n left: 0;\n width: ${dimensions.width}px;\n height: ${dimensions.height}px;\n transform: translate(${position.x}px, ${position.y}px);\n `;\n});\nconst StyledNodeContainer = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n`;\nexport interface NodesProps {\n items: RendererNodeProps[];\n content?: ComponentType<RendererNodeProps>;\n}\nconst Nodes: FC<NodesProps> = ({ items, content: Node }) => {\n return (\n <StyledNodeContainer>\n {items.map(item => {\n return (\n <Flex\n key={item.id}\n as={StyledNodeWrapper}\n id={item.id}\n dimensions={item.dimensions}\n position={item.position}\n container={{ justify: 'center' }}\n >\n {Node && <Node {...item} />}\n </Flex>\n );\n })}\n </StyledNodeContainer>\n );\n};\n\nexport default Nodes;\n"]}
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { RendererProps } from './Renderer.types';
3
+ declare const Renderer: FC<RendererProps>;
4
+ export default Renderer;
5
+ //# sourceMappingURL=Renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUjD,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAU/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styled from 'styled-components';
3
+ import Connectors from './Connectors';
4
+ import Nodes from './Nodes';
5
+ import GraphLayout from './Utils/GraphLayout';
6
+ const StyledWrapper = styled.div `
7
+ position: relative;
8
+ width: 100%;
9
+ height: 100%;
10
+ `;
11
+ const Renderer = ({ graphData, connector, node }) => {
12
+ // apply the plotted positions
13
+ const graphDimensions = GraphLayout.plot(graphData);
14
+ return (_jsxs(StyledWrapper, { children: [_jsx(Connectors, { items: graphData.connectors, content: connector, dimensions: graphDimensions }, void 0), _jsx(Nodes, { items: graphData.nodes, content: node }, void 0)] }, void 0));
15
+ };
16
+ export default Renderer;
17
+ //# sourceMappingURL=Renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderer.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAC;AAEF,MAAM,QAAQ,GAAsB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;IACrE,8BAA8B;IAC9B,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAA6B,SAAS,CAAC,CAAC;IAEhF,OAAO,CACL,MAAC,aAAa,eACZ,KAAC,UAAU,IAAC,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,WAAI,EAC5F,KAAC,KAAK,IAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,WAAI,YAClC,CACjB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FC } from 'react';\nimport styled from 'styled-components';\n\nimport Connectors from './Connectors';\nimport { RendererProps } from './Renderer.types';\nimport Nodes from './Nodes';\nimport GraphLayout from './Utils/GraphLayout';\n\nconst StyledWrapper = styled.div`\n position: relative;\n width: 100%;\n height: 100%;\n`;\n\nconst Renderer: FC<RendererProps> = ({ graphData, connector, node }) => {\n // apply the plotted positions\n const graphDimensions = GraphLayout.plot<RendererProps['graphData']>(graphData);\n\n return (\n <StyledWrapper>\n <Connectors items={graphData.connectors} content={connector} dimensions={graphDimensions} />\n <Nodes items={graphData.nodes} content={node} />\n </StyledWrapper>\n );\n};\n\nexport default Renderer;\n"]}
@@ -0,0 +1,18 @@
1
+ import { ComponentType } from 'react';
2
+ import { GraphData } from './Utils/Graph';
3
+ import { PlottedGraphConnector, PlottedGraphNode } from './Utils/GraphLayout';
4
+ export interface AddNodeHandlerParams {
5
+ refType: 'node' | 'connector';
6
+ refId: string | string[];
7
+ }
8
+ export interface RendererNodeProps extends PlottedGraphNode {
9
+ }
10
+ export interface RendererConnectorProps extends PlottedGraphConnector {
11
+ }
12
+ export interface RendererProps {
13
+ graphData: GraphData<RendererNodeProps, RendererConnectorProps>;
14
+ disableAutoLayout?: boolean;
15
+ connector?: ComponentType<RendererConnectorProps>;
16
+ node?: ComponentType<RendererNodeProps>;
17
+ }
18
+ //# sourceMappingURL=Renderer.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderer.types.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;CAAG;AAE9D,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;CAAG;AAExE,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,SAAS,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;IAChE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Renderer.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderer.types.js","sourceRoot":"","sources":["../../../../src/components/FlowModeller/Renderer/Renderer.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from 'react';\n\nimport { 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 RendererNodeProps extends PlottedGraphNode {}\n\nexport interface RendererConnectorProps extends PlottedGraphConnector {}\n\nexport interface RendererProps {\n graphData: GraphData<RendererNodeProps, RendererConnectorProps>;\n disableAutoLayout?: boolean;\n connector?: ComponentType<RendererConnectorProps>;\n node?: ComponentType<RendererNodeProps>;\n}\n"]}
@@ -0,0 +1,54 @@
1
+ export interface ConnectorProps<T = unknown> {
2
+ id: string;
3
+ fromNodeId: string;
4
+ toNodeId: string;
5
+ label?: string;
6
+ data?: T;
7
+ }
8
+ export interface Node<T = unknown> {
9
+ id: string;
10
+ data?: T;
11
+ }
12
+ export interface GraphData<T extends Node = Node, U extends ConnectorProps = ConnectorProps> {
13
+ nodes: T[];
14
+ connectors: U[];
15
+ }
16
+ export declare class DirectedGraph<T extends Node = Node, U extends ConnectorProps = ConnectorProps, D1 = unknown, D2 = unknown> {
17
+ private nodes;
18
+ private connectors;
19
+ private nodeData;
20
+ private connectorData;
21
+ private inConnectors;
22
+ private prevNodesCount;
23
+ private outConnectors;
24
+ private nextNodesCount;
25
+ private nodeCount;
26
+ private connectorsCount;
27
+ constructor(graphData?: GraphData<T, U>);
28
+ getGraphData(): GraphData<T, U>;
29
+ getNodeCount(): number;
30
+ getNodes(): T[];
31
+ addNode(node: T, data?: D1): DirectedGraph;
32
+ getNode(nodeId: string): T;
33
+ hasNode(nodeId: string): boolean;
34
+ deleteNode(nodeId: string, ignoreConnectors?: boolean): DirectedGraph<T, U>;
35
+ getPrevNodes(nodeId: string): T[];
36
+ getNextNodes(nodeId: string): T[];
37
+ getPrevNodesCount(nodeId: string): number;
38
+ getNextNodesCount(nodeId: string): number;
39
+ isLeaf(nodeId: string): boolean;
40
+ getConnectorsCount(): number;
41
+ getConnectors(): U[];
42
+ addConnector(connector: U, data?: D2): DirectedGraph<T, U>;
43
+ hasConnector(id: string): boolean;
44
+ getConnector(id: string): U;
45
+ removeConnector(id: string): DirectedGraph<T, U>;
46
+ setConnector(id: string, data: {
47
+ fromNodeId?: string;
48
+ toNodeId?: string;
49
+ }): DirectedGraph<T, U>;
50
+ getInConnectors(toNodeId: string, fromNodeId?: string): ConnectorProps[];
51
+ getOutConnectors(fromNodeId: string, toNodeId?: string): ConnectorProps[];
52
+ getAllNodeConnectors(nodeId: string): ConnectorProps<unknown>[] | undefined;
53
+ }
54
+ //# sourceMappingURL=Graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Graph.d.ts","sourceRoot":"","sources":["../../../../../src/components/FlowModeller/Renderer/Utils/Graph.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACn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,UAAQ,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IAyBzE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE;IAMjC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE;IAMjC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAOzC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAOzC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAK/B,kBAAkB,IAAI,MAAM;IAI5B,aAAa;IAIb,YAAY,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IAgD1D,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIjC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC;IAI3B,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IA+BhD,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IAiE/F,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE;IAkBxE,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE;IAkBzE,oBAAoB,CAAC,MAAM,EAAE,MAAM;CAOpC"}
@@ -0,0 +1,302 @@
1
+ export class DirectedGraph {
2
+ constructor(graphData = { nodes: [], connectors: [] }) {
3
+ Object.defineProperty(this, "nodes", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: {}
8
+ });
9
+ Object.defineProperty(this, "connectors", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: {}
14
+ });
15
+ // additional way to maintain related data - for cases where Graph is used for indirect purposes
16
+ Object.defineProperty(this, "nodeData", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: {}
21
+ });
22
+ Object.defineProperty(this, "connectorData", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: {}
27
+ });
28
+ Object.defineProperty(this, "inConnectors", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: {}
33
+ }); // we are maintaining connector reference instead of id, to avoid iterations later on.
34
+ Object.defineProperty(this, "prevNodesCount", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: {}
39
+ });
40
+ Object.defineProperty(this, "outConnectors", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: {}
45
+ }); // we are maintaining connector reference instead of id, to avoid iterations later on
46
+ Object.defineProperty(this, "nextNodesCount", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: {}
51
+ });
52
+ Object.defineProperty(this, "nodeCount", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: 0
57
+ });
58
+ Object.defineProperty(this, "connectorsCount", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: 0
63
+ });
64
+ // Not necessary to clone, as this class never modifies any nodes
65
+ graphData.nodes.forEach(item => this.addNode(item));
66
+ // copy/clone, connectors properties 'fromNodeId' and 'toNodeId' values may get modified by this class
67
+ graphData.connectors.forEach(item => this.addConnector(JSON.parse(JSON.stringify(item))));
68
+ }
69
+ getGraphData() {
70
+ return {
71
+ nodes: this.getNodes(),
72
+ connectors: this.getConnectors()
73
+ };
74
+ }
75
+ getNodeCount() {
76
+ return this.nodeCount;
77
+ }
78
+ getNodes() {
79
+ return Object.values(this.nodes);
80
+ }
81
+ addNode(node, data) {
82
+ if (this.nodes[node.id] !== undefined) {
83
+ this.nodes[node.id] = node;
84
+ this.nodeData[node.id] = data;
85
+ }
86
+ else {
87
+ this.nodes[node.id] = node;
88
+ this.nodeData[node.id] = data;
89
+ this.inConnectors[node.id] = {};
90
+ this.prevNodesCount[node.id] = {};
91
+ this.outConnectors[node.id] = {};
92
+ this.nextNodesCount[node.id] = {};
93
+ this.nodeCount += 1;
94
+ }
95
+ return this;
96
+ }
97
+ getNode(nodeId) {
98
+ return this.nodes[nodeId];
99
+ }
100
+ hasNode(nodeId) {
101
+ return this.nodes[nodeId] !== undefined;
102
+ }
103
+ deleteNode(nodeId, ignoreConnectors = false) {
104
+ if (this.hasNode(nodeId)) {
105
+ delete this.nodes[nodeId];
106
+ delete this.nodeData[nodeId];
107
+ if (ignoreConnectors !== true) {
108
+ const removeConnector = (id) => this.removeConnector(id);
109
+ // IMP NOTE its the responsibility of the callee to make sure that the connectors are cleanly reassigned, or else all attached connectors will be deleted
110
+ Object.keys(this.inConnectors[nodeId]).forEach(removeConnector);
111
+ delete this.inConnectors[nodeId];
112
+ delete this.prevNodesCount[nodeId];
113
+ Object.keys(this.outConnectors[nodeId]).forEach(removeConnector);
114
+ delete this.outConnectors[nodeId];
115
+ delete this.nextNodesCount[nodeId];
116
+ }
117
+ this.nodeCount += 1;
118
+ }
119
+ return this;
120
+ }
121
+ getPrevNodes(nodeId) {
122
+ return this.prevNodesCount[nodeId]
123
+ ? Object.keys(this.prevNodesCount[nodeId]).map(id => this.getNode(id))
124
+ : [];
125
+ }
126
+ getNextNodes(nodeId) {
127
+ return this.nextNodesCount[nodeId]
128
+ ? Object.keys(this.nextNodesCount[nodeId]).map(id => this.getNode(id))
129
+ : [];
130
+ }
131
+ getPrevNodesCount(nodeId) {
132
+ return (this.prevNodesCount[nodeId] ? Object.values(this.prevNodesCount[nodeId]) : []).reduce((prev, current) => prev + current, 0);
133
+ }
134
+ getNextNodesCount(nodeId) {
135
+ return (this.nextNodesCount[nodeId] ? Object.values(this.nextNodesCount[nodeId]) : []).reduce((prev, current) => prev + current, 0);
136
+ }
137
+ isLeaf(nodeId) {
138
+ return this.getNextNodes(nodeId).length === 0;
139
+ }
140
+ // -- Connectors
141
+ getConnectorsCount() {
142
+ return this.connectorsCount;
143
+ }
144
+ getConnectors() {
145
+ return Object.values(this.connectors);
146
+ }
147
+ addConnector(connector, data) {
148
+ if (this.connectors[connector.id] !== undefined) {
149
+ // update the map
150
+ this.connectors[connector.id] = connector;
151
+ this.connectorData[connector.id] = data;
152
+ return this;
153
+ }
154
+ const id = connector.id;
155
+ const fromNodeId = connector.fromNodeId;
156
+ const toNodeId = connector.toNodeId;
157
+ // check if nodes with given ids exist
158
+ if (this.nodes[fromNodeId] === undefined || this.nodes[toNodeId] === undefined) {
159
+ throw new Error(`One or more nodes does not exist, cannot add connector ${fromNodeId}-${toNodeId}`);
160
+ }
161
+ // add it to the map
162
+ this.connectors[id] = connector;
163
+ this.connectorData[id] = data;
164
+ // update prev nodes count
165
+ if (this.prevNodesCount[toNodeId][fromNodeId]) {
166
+ this.prevNodesCount[toNodeId][fromNodeId] += 1;
167
+ }
168
+ else {
169
+ this.prevNodesCount[toNodeId][fromNodeId] = 1;
170
+ }
171
+ // update next nodes count
172
+ if (this.nextNodesCount[fromNodeId][toNodeId]) {
173
+ this.nextNodesCount[fromNodeId][toNodeId] += 1;
174
+ }
175
+ else {
176
+ this.nextNodesCount[fromNodeId][toNodeId] = 1;
177
+ }
178
+ // update in and out connectors for both the nodes
179
+ this.inConnectors[toNodeId][id] = connector;
180
+ this.outConnectors[fromNodeId][id] = connector;
181
+ // increment total connectors count
182
+ this.connectorsCount += 1;
183
+ return this;
184
+ }
185
+ hasConnector(id) {
186
+ return this.connectors[id] !== undefined;
187
+ }
188
+ getConnector(id) {
189
+ return this.connectors[id];
190
+ }
191
+ removeConnector(id) {
192
+ const connector = this.connectors[id];
193
+ if (connector !== undefined) {
194
+ const fromNodeId = connector.fromNodeId;
195
+ const toNodeId = connector.toNodeId;
196
+ delete this.connectors[id];
197
+ delete this.connectorData[id];
198
+ // update prev nodes count
199
+ this.prevNodesCount[toNodeId][fromNodeId] -= 1;
200
+ if (this.prevNodesCount[toNodeId][fromNodeId] === 0) {
201
+ delete this.prevNodesCount[toNodeId][fromNodeId];
202
+ }
203
+ // update next nodes count
204
+ this.nextNodesCount[fromNodeId][toNodeId] -= 1;
205
+ if (this.nextNodesCount[fromNodeId][toNodeId] === 0) {
206
+ delete this.nextNodesCount[fromNodeId][toNodeId];
207
+ }
208
+ delete this.inConnectors[toNodeId][id];
209
+ delete this.outConnectors[fromNodeId][id];
210
+ this.connectorsCount -= 1;
211
+ }
212
+ return this;
213
+ }
214
+ setConnector(id, data) {
215
+ // VALIDATE
216
+ // -connector with given id exists
217
+ // -node with given fromNodeId exists
218
+ // -node with given toNodeId exists
219
+ if (!this.getConnector(id)) {
220
+ throw new Error(`Connector with id '${id}' does not exist.`);
221
+ }
222
+ if (data.fromNodeId && !this.getNode(data.fromNodeId)) {
223
+ throw new Error(`Node with id '${data.fromNodeId}' does not exist, to update fromNodeId.`);
224
+ }
225
+ if (data.toNodeId && !this.getNode(data.toNodeId)) {
226
+ throw new Error(`Node with id '${data.toNodeId}' does not exist, to update toNodeId.`);
227
+ }
228
+ const connector = this.getConnector(id);
229
+ // current references
230
+ let fromNodeId = connector.fromNodeId;
231
+ let toNodeId = connector.toNodeId;
232
+ // update prev nodes count - unset prev values
233
+ this.prevNodesCount[toNodeId][fromNodeId] -= 1;
234
+ if (this.prevNodesCount[toNodeId][fromNodeId] === 0) {
235
+ delete this.prevNodesCount[toNodeId][fromNodeId];
236
+ }
237
+ // update next nodes count - unset prev values
238
+ this.nextNodesCount[fromNodeId][toNodeId] -= 1;
239
+ if (this.nextNodesCount[fromNodeId][toNodeId] === 0) {
240
+ delete this.nextNodesCount[fromNodeId][toNodeId];
241
+ }
242
+ // remove prev references
243
+ delete this.inConnectors[toNodeId][id];
244
+ delete this.outConnectors[fromNodeId][id];
245
+ // new references
246
+ fromNodeId = data.fromNodeId ? data.fromNodeId : connector.fromNodeId;
247
+ toNodeId = data.toNodeId ? data.toNodeId : connector.toNodeId;
248
+ connector.fromNodeId = fromNodeId;
249
+ connector.toNodeId = toNodeId;
250
+ // update prev nodes count
251
+ if (this.prevNodesCount[toNodeId][fromNodeId]) {
252
+ this.prevNodesCount[toNodeId][fromNodeId] += 1;
253
+ }
254
+ else {
255
+ this.prevNodesCount[toNodeId][fromNodeId] = 1;
256
+ }
257
+ // update next nodes count
258
+ if (this.nextNodesCount[fromNodeId][toNodeId]) {
259
+ this.nextNodesCount[fromNodeId][toNodeId] += 1;
260
+ }
261
+ else {
262
+ this.nextNodesCount[fromNodeId][toNodeId] = 1;
263
+ }
264
+ // update in and out connectors for both the nodes
265
+ this.inConnectors[toNodeId][id] = connector;
266
+ this.outConnectors[fromNodeId][id] = connector;
267
+ return this;
268
+ }
269
+ getInConnectors(toNodeId, fromNodeId) {
270
+ const allInConnectors = this.inConnectors[toNodeId];
271
+ if (allInConnectors) {
272
+ const connectorValues = Object.values(allInConnectors);
273
+ if (fromNodeId === undefined) {
274
+ return connectorValues;
275
+ }
276
+ return connectorValues.filter(connector => {
277
+ return connector.fromNodeId === fromNodeId;
278
+ });
279
+ }
280
+ return [];
281
+ }
282
+ getOutConnectors(fromNodeId, toNodeId) {
283
+ const allOutConnectors = this.outConnectors[fromNodeId];
284
+ if (allOutConnectors) {
285
+ const connectorValues = Object.values(allOutConnectors);
286
+ if (toNodeId === undefined) {
287
+ return connectorValues;
288
+ }
289
+ return connectorValues.filter(connector => {
290
+ return connector.toNodeId === toNodeId;
291
+ });
292
+ }
293
+ return [];
294
+ }
295
+ getAllNodeConnectors(nodeId) {
296
+ const inConnectors = this.getInConnectors(nodeId);
297
+ if (inConnectors) {
298
+ return inConnectors.concat(this.getOutConnectors(nodeId));
299
+ }
300
+ }
301
+ }
302
+ //# sourceMappingURL=Graph.js.map