@pega/cosmos-react-build 9.0.0-build.21.8 → 9.0.0-build.22.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/DynamicInput/DynamicInput.styles.d.ts.map +1 -1
- package/lib/components/DynamicInput/DynamicInput.styles.js +0 -2
- package/lib/components/DynamicInput/DynamicInput.styles.js.map +1 -1
- package/lib/components/FlowModeller/AddNode.d.ts +22 -0
- package/lib/components/FlowModeller/AddNode.d.ts.map +1 -0
- package/lib/components/FlowModeller/AddNode.js +95 -0
- package/lib/components/FlowModeller/AddNode.js.map +1 -0
- package/lib/components/FlowModeller/Connector.d.ts +12 -0
- package/lib/components/FlowModeller/Connector.d.ts.map +1 -0
- package/lib/components/FlowModeller/Connector.js +84 -0
- package/lib/components/FlowModeller/Connector.js.map +1 -0
- package/lib/components/FlowModeller/DeleteDialog.d.ts +39 -0
- package/lib/components/FlowModeller/DeleteDialog.d.ts.map +1 -0
- package/lib/components/FlowModeller/DeleteDialog.js +158 -0
- package/lib/components/FlowModeller/DeleteDialog.js.map +1 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.d.ts +4 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.js +37 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.js.map +1 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.styles.d.ts +8 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.styles.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.styles.js +73 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.styles.js.map +1 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.types.d.ts +36 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.types.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.types.js +2 -0
- package/lib/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.types.js.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.d.ts +5 -0
- package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.js +359 -0
- package/lib/components/FlowModeller/FlowModeller.js.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.test-ids.d.ts +3 -0
- package/lib/components/FlowModeller/FlowModeller.test-ids.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.test-ids.js +5 -0
- package/lib/components/FlowModeller/FlowModeller.test-ids.js.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.types.d.ts +84 -0
- package/lib/components/FlowModeller/FlowModeller.types.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowModeller.types.js +2 -0
- package/lib/components/FlowModeller/FlowModeller.types.js.map +1 -0
- package/lib/components/FlowModeller/FlowModellerContext.d.ts +10 -0
- package/lib/components/FlowModeller/FlowModellerContext.d.ts.map +1 -0
- package/lib/components/FlowModeller/FlowModellerContext.js +8 -0
- package/lib/components/FlowModeller/FlowModellerContext.js.map +1 -0
- package/lib/components/FlowModeller/Node/Node.types.d.ts +93 -0
- package/lib/components/FlowModeller/Node/Node.types.d.ts.map +1 -0
- package/lib/components/FlowModeller/Node/Node.types.js +27 -0
- package/lib/components/FlowModeller/Node/Node.types.js.map +1 -0
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts +212 -0
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.d.ts.map +1 -0
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js +144 -0
- package/lib/components/FlowModeller/Node/NodeTemplate.styles.js.map +1 -0
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts +5 -0
- package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -0
- package/lib/components/FlowModeller/Node/NodeTemplates.js +130 -0
- package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -0
- package/lib/components/FlowModeller/Node.d.ts +10 -0
- package/lib/components/FlowModeller/Node.d.ts.map +1 -0
- package/lib/components/FlowModeller/Node.js +43 -0
- package/lib/components/FlowModeller/Node.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Renderer.d.ts +4 -0
- package/lib/components/FlowModeller/Renderer/Renderer.d.ts.map +1 -0
- package/lib/components/FlowModeller/Renderer/Renderer.js +198 -0
- package/lib/components/FlowModeller/Renderer/Renderer.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts +20 -0
- package/lib/components/FlowModeller/Renderer/Renderer.types.d.ts.map +1 -0
- package/lib/components/FlowModeller/Renderer/Renderer.types.js +2 -0
- package/lib/components/FlowModeller/Renderer/Renderer.types.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts +63 -0
- package/lib/components/FlowModeller/Renderer/Utils/Graph.d.ts.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js +291 -0
- package/lib/components/FlowModeller/Renderer/Utils/Graph.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts +37 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.d.ts.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js +114 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphLayout.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts +29 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.d.ts.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js +191 -0
- package/lib/components/FlowModeller/Renderer/Utils/GraphTraversal.js.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/RendererUtils.d.ts +38 -0
- package/lib/components/FlowModeller/Renderer/Utils/RendererUtils.d.ts.map +1 -0
- package/lib/components/FlowModeller/Renderer/Utils/RendererUtils.js +363 -0
- package/lib/components/FlowModeller/Renderer/Utils/RendererUtils.js.map +1 -0
- package/lib/components/FlowModeller/Utils/addNodeUtils.d.ts +18 -0
- package/lib/components/FlowModeller/Utils/addNodeUtils.d.ts.map +1 -0
- package/lib/components/FlowModeller/Utils/addNodeUtils.js +148 -0
- package/lib/components/FlowModeller/Utils/addNodeUtils.js.map +1 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts +33 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.d.ts.map +1 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js +89 -0
- package/lib/components/FlowModeller/Utils/deleteNodeUtils.js.map +1 -0
- package/lib/components/FlowModeller/constants.d.ts +10 -0
- package/lib/components/FlowModeller/constants.d.ts.map +1 -0
- package/lib/components/FlowModeller/constants.js +9 -0
- package/lib/components/FlowModeller/constants.js.map +1 -0
- package/lib/components/FlowModeller/helper.d.ts +39 -0
- package/lib/components/FlowModeller/helper.d.ts.map +1 -0
- package/lib/components/FlowModeller/helper.js +230 -0
- package/lib/components/FlowModeller/helper.js.map +1 -0
- package/lib/components/FlowModeller/index.d.ts +18 -0
- package/lib/components/FlowModeller/index.d.ts.map +1 -0
- package/lib/components/FlowModeller/index.js +11 -0
- package/lib/components/FlowModeller/index.js.map +1 -0
- package/lib/components/ObjectSelect/InputTree/InputTree.styles.js +1 -1
- package/lib/components/ObjectSelect/InputTree/InputTree.styles.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/utils.d.ts +5 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +19 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.styles.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sOAAiB,CAAC;AAEtD,eAAO,MAAM,kBAAkB;eAA2B,OAAO;eAAa,OAAO;
|
|
1
|
+
{"version":3,"file":"DynamicInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.styles.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sOAAiB,CAAC;AAEtD,eAAO,MAAM,kBAAkB;eAA2B,OAAO;eAAa,OAAO;YA6FpF,CAAC"}
|
|
@@ -49,12 +49,10 @@ export const StyledDynamicInput = styled.div(({ theme: { base: { palette: { 'for
|
|
|
49
49
|
|
|
50
50
|
${StyledMenuButton} {
|
|
51
51
|
z-index: 0;
|
|
52
|
-
height: 100%;
|
|
53
52
|
border-inline-end: 0;
|
|
54
53
|
border-color: ${formControlBorderColor};
|
|
55
54
|
border-start-end-radius: 0;
|
|
56
55
|
border-end-end-radius: 0;
|
|
57
|
-
align-self: flex-start;
|
|
58
56
|
color: ${foregroundColor};
|
|
59
57
|
&:focus {
|
|
60
58
|
z-index: 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicInput.styles.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAEhG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,yCAAyC,CAAC;AAEjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA,EAAE,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAC1C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EAAE,EAAE,kBAAkB,EAAE,eAAe,EAAE,EAChD,eAAe,EAAE,YAAY,EAC9B,EACD,UAAU,EAAE,EACV,cAAc,EAAE,EACd,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,EAC9D,EACF,EACF,EACD,QAAQ,EACT,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;;;QAIN,eAAe;;;;QAIf,0BAA0B,MAAM,yBAAyB,MAAM,UAAU;;;;QAIzE,oBAAoB;;;;QAIpB,iBAAiB;;;;QAIjB,iBAAiB;;;;;;QAMjB,uBAAuB;;;;;;;;;;0BAUL,sBAAsB;;;;;;QAMxC,gBAAgB
|
|
1
|
+
{"version":3,"file":"DynamicInput.styles.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ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ledSelectInput,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\nimport { StyledMenuButton } from '@pega/cosmos-react-core/lib/components/MenuButton/MenuButton';\n\nimport { StyledContentWrapper, StyledInputTree } from '../ObjectSelect/InputTree/InputTree.styles';\nimport {\n StyledFieldReferenceInput,\n StyledFieldReferencePicker\n} from '../FieldReference/FieldReference.styles';\n\nexport const StyledExpressionControl = styled(Flex)``;\n\nexport const StyledDynamicInput = styled.div<{ disabled?: boolean; readOnly?: boolean }>(\n ({\n theme: {\n base: {\n palette: { 'foreground-color': foregroundColor },\n 'content-width': contentWidth\n },\n components: {\n 'form-control': {\n 'border-color': formControlBorderColor,\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n }\n }\n },\n readOnly\n }) => {\n return css`\n display: flex;\n flex-grow: 1;\n\n ${StyledInputTree} {\n margin-inline-start: -2.5rem;\n }\n\n ${StyledFieldReferencePicker} > ${StyledFieldReferenceInput} > ${StyledGrid} {\n padding: 0;\n }\n\n ${StyledContentWrapper} {\n padding-block-start: 0;\n }\n\n ${StyledSelectInput} {\n height: 100%;\n }\n\n ${StyledFormControl} {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n width: 100%;\n }\n\n ${StyledExpressionControl} {\n position: relative;\n z-index: 1;\n\n .react-codemirror2 {\n min-height: 0;\n }\n\n .CodeMirror,\n .CodeMirror-wrap {\n border-color: ${formControlBorderColor};\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n }\n\n ${StyledMenuButton} {\n z-index: 0;\n border-inline-end: 0;\n border-color: ${formControlBorderColor};\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n color: ${foregroundColor};\n &:focus {\n z-index: 2;\n }\n }\n\n /* disabled-opacity is already being applied on DynamicInput, so we need to unset it on MenuButton */\n &[disabled] {\n ${StyledMenuButton}:disabled {\n opacity: 1;\n }\n }\n\n ${readOnly &&\n css`\n ${StyledMenuButton} {\n background-color: ${readOnlyBackgroundColor};\n }\n `}\n\n ${StyledMenuButton} + * {\n flex-grow: 1;\n z-index: 1;\n width: 100%;\n height: auto;\n min-width: ${contentWidth.xs};\n }\n `;\n }\n);\n\nStyledDynamicInput.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MouseEvent } from 'react';
|
|
2
|
+
import type { PlottedGraphNode } from './Renderer/Utils/GraphLayout';
|
|
3
|
+
import type { NodeEvents, NodeLabels } from './Node/Node.types';
|
|
4
|
+
export declare const StyledDot: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("@pega/cosmos-react-core").IconProps & import("styled-components/dist/types").BaseObject, {
|
|
5
|
+
highlight: boolean | undefined;
|
|
6
|
+
}>> & string & Omit<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, keyof import("react").Component<any, {}, any>>;
|
|
7
|
+
export declare const StyledPlus: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("@pega/cosmos-react-core").IconProps & import("styled-components/dist/types").BaseObject, import("styled-components/dist/types").BaseObject>> & string & Omit<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, keyof import("react").Component<any, {}, any>>;
|
|
8
|
+
export declare const StyledWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
9
|
+
export declare const StyledButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("@pega/cosmos-react-core").ButtonProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement> & import("@pega/cosmos-react-core").ForwardProps, "ref"> & {
|
|
10
|
+
ref?: ((instance: HTMLAnchorElement | HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLAnchorElement | HTMLButtonElement> | null | undefined;
|
|
11
|
+
}, never>> & string & Omit<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").ButtonProps>, keyof import("react").Component<any, {}, any>>;
|
|
12
|
+
export interface AddNodeProps extends PlottedGraphNode {
|
|
13
|
+
onClick?: (ev: Event) => void;
|
|
14
|
+
addNodeHandler: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
15
|
+
highlight?: boolean;
|
|
16
|
+
}
|
|
17
|
+
type AddButtonProps = Pick<AddNodeProps, 'addNodeHandler' | 'highlight'> & Pick<NodeEvents, 'active' | 'onFocus'> & NodeLabels;
|
|
18
|
+
declare const _default: (({ addNodeHandler, highlight, active, fromNodeLabel, toNodeLabel, ...restProps }: AddButtonProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
19
|
+
getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly []>;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=AddNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddNode.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAexC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGhE,eAAO,MAAM,SAAS;eAA6B,OAAO,GAAG,SAAS;0JAcpE,CAAC;AAIH,eAAO,MAAM,UAAU,kaAEtB,CAAC;AAEF,eAAO,MAAM,aAAa,6NASxB,CAAC;AAIH,eAAO,MAAM,YAAY;;2LA0BvB,CAAC;AAIH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,cAAc,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,KAAK,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,WAAW,CAAC,GACtE,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC,GACtC,UAAU,CAAC;2GASV,cAAc;;;AAuDjB,wBAA2D"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { useContext, useState, useEffect, useRef } from 'react';
|
|
4
|
+
import { Button, defaultThemeProp, Flex, Icon, StyledTooltip, useI18n, withTestIds, useTestIds } from '@pega/cosmos-react-core';
|
|
5
|
+
import { generateDynamicTestId } from '../../utils/utils';
|
|
6
|
+
import FlowModellerContext from './FlowModellerContext';
|
|
7
|
+
import { getConnectorTestIds } from './FlowModeller.test-ids';
|
|
8
|
+
export const StyledDot = styled(Icon)(({ highlight, theme }) => {
|
|
9
|
+
return css `
|
|
10
|
+
position: absolute;
|
|
11
|
+
color: transparent;
|
|
12
|
+
background-color: ${highlight ? theme.base.colors.red.dark : theme.base.colors.slate.dark};
|
|
13
|
+
border-radius: 50%;
|
|
14
|
+
|
|
15
|
+
path {
|
|
16
|
+
fill: ${highlight ? theme.base.colors.red.dark : theme.base.colors.slate.dark};
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
});
|
|
20
|
+
StyledDot.defaultProps = defaultThemeProp;
|
|
21
|
+
export const StyledPlus = styled(Icon) `
|
|
22
|
+
opacity: 0;
|
|
23
|
+
`;
|
|
24
|
+
export const StyledWrapper = styled.div(({ theme }) => {
|
|
25
|
+
return css `
|
|
26
|
+
margin-block-start: ${theme.base.spacing};
|
|
27
|
+
|
|
28
|
+
${StyledTooltip} {
|
|
29
|
+
min-width: calc(${theme.base['content-width'].xs} * 0.6);
|
|
30
|
+
text-align: center;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
});
|
|
34
|
+
StyledWrapper.defaultProps = defaultThemeProp;
|
|
35
|
+
export const StyledButton = styled(Button)(({ theme }) => {
|
|
36
|
+
return css `
|
|
37
|
+
top: calc(-0.5 * ${theme.base.spacing});
|
|
38
|
+
border: 0;
|
|
39
|
+
background: transparent;
|
|
40
|
+
color: ${theme.base.colors.black};
|
|
41
|
+
&:hover,
|
|
42
|
+
&:focus {
|
|
43
|
+
background: ${theme.base.colors.white};
|
|
44
|
+
${StyledDot} {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
${StyledPlus} {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
&[aria-haspopup='menu'] {
|
|
52
|
+
background: ${theme.base.colors.white};
|
|
53
|
+
${StyledDot} {
|
|
54
|
+
opacity: 0;
|
|
55
|
+
}
|
|
56
|
+
${StyledPlus} {
|
|
57
|
+
opacity: 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
});
|
|
62
|
+
StyledButton.defaultProps = defaultThemeProp;
|
|
63
|
+
const AddButton = ({ addNodeHandler, highlight, active = false, fromNodeLabel, toNodeLabel, ...restProps }) => {
|
|
64
|
+
const t = useI18n();
|
|
65
|
+
const [hasMenuActive, setHasMenuActive] = useState(false);
|
|
66
|
+
const { showNodeLibrary } = useContext(FlowModellerContext);
|
|
67
|
+
const addNodeRef = useRef(null);
|
|
68
|
+
const [isFocused, setFocused] = useState(false);
|
|
69
|
+
const addNodeClickHandler = (e) => {
|
|
70
|
+
setHasMenuActive(true);
|
|
71
|
+
addNodeHandler(e);
|
|
72
|
+
};
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (active) {
|
|
75
|
+
addNodeRef.current?.focus();
|
|
76
|
+
}
|
|
77
|
+
}, [active]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!showNodeLibrary) {
|
|
80
|
+
setHasMenuActive(false);
|
|
81
|
+
}
|
|
82
|
+
}, [showNodeLibrary]);
|
|
83
|
+
const connectorTestID = generateDynamicTestId([
|
|
84
|
+
fromNodeLabel || 'merge',
|
|
85
|
+
toNodeLabel || 'branch-end'
|
|
86
|
+
]);
|
|
87
|
+
const testIds = useTestIds(connectorTestID, getConnectorTestIds);
|
|
88
|
+
return (_jsx(Flex, { "data-testid": testIds.root, container: { justify: 'center' }, as: StyledWrapper, children: _jsxs(StyledButton, { ...restProps, ref: addNodeRef, label: t('step_name', [t('add')]), "aria-haspopup": hasMenuActive ? 'menu' : false, icon: true, onClick: addNodeClickHandler, tabIndex: isFocused ? 0 : -1, onFocus: () => {
|
|
89
|
+
setFocused(true);
|
|
90
|
+
}, onBlur: () => {
|
|
91
|
+
setFocused(false);
|
|
92
|
+
}, children: [_jsx(StyledDot, { name: 'circle', highlight: highlight }), _jsx(StyledPlus, { name: 'plus' })] }) }));
|
|
93
|
+
};
|
|
94
|
+
export default withTestIds(AddButton, getConnectorTestIds);
|
|
95
|
+
//# sourceMappingURL=AddNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddNode.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/AddNode.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGhE,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,OAAO,EACP,WAAW,EACX,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,q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,MAAM,eAAe,GAAG,qBAAqB,CAAC;QAC5C,aAAa,IAAI,OAAO;QACxB,WAAW,IAAI,YAAY;KAC5B,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;IAEjE,OAAO,CACL,KAAC,IAAI,mBAAc,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,aAAa,YAClF,MAAC,YAAY,OACP,SAAS,EACb,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,mBAClB,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAC7C,IAAI,QACJ,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5B,OAAO,EAAE,GAAG,EAAE;gBACZ,UAAU,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC,EACD,MAAM,EAAE,GAAG,EAAE;gBACX,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,aAED,KAAC,SAAS,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,SAAS,GAAI,EACjD,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,GAAG,IACb,GACV,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { useContext, useState, useEffect, useRef } from 'react';\nimport type { MouseEvent } from 'react';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n Icon,\n StyledTooltip,\n useI18n,\n withTestIds,\n useTestIds\n} from '@pega/cosmos-react-core';\n\nimport { generateDynamicTestId } from '../../utils/utils';\n\nimport type { PlottedGraphNode } from './Renderer/Utils/GraphLayout';\nimport FlowModellerContext from './FlowModellerContext';\nimport type { NodeEvents, NodeLabels } from './Node/Node.types';\nimport { getConnectorTestIds } from './FlowModeller.test-ids';\n\nexport const StyledDot = styled(Icon)<{ highlight: boolean | undefined }>(({\n highlight,\n theme\n}) => {\n return css`\n position: absolute;\n color: transparent;\n background-color: ${highlight ? theme.base.colors.red.dark : theme.base.colors.slate.dark};\n border-radius: 50%;\n\n path {\n fill: ${highlight ? theme.base.colors.red.dark : theme.base.colors.slate.dark};\n }\n `;\n});\n\nStyledDot.defaultProps = defaultThemeProp;\n\nexport const StyledPlus = styled(Icon)`\n opacity: 0;\n`;\n\nexport const StyledWrapper = styled.div(({ theme }) => {\n return css`\n margin-block-start: ${theme.base.spacing};\n\n ${StyledTooltip} {\n min-width: calc(${theme.base['content-width'].xs} * 0.6);\n text-align: center;\n }\n `;\n});\n\nStyledWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledButton = styled(Button)(({ theme }) => {\n return css`\n top: calc(-0.5 * ${theme.base.spacing});\n border: 0;\n background: transparent;\n color: ${theme.base.colors.black};\n &:hover,\n &:focus {\n background: ${theme.base.colors.white};\n ${StyledDot} {\n opacity: 0;\n }\n ${StyledPlus} {\n opacity: 1;\n }\n }\n &[aria-haspopup='menu'] {\n background: ${theme.base.colors.white};\n ${StyledDot} {\n opacity: 0;\n }\n ${StyledPlus} {\n opacity: 1;\n }\n }\n `;\n});\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport interface AddNodeProps extends PlottedGraphNode {\n onClick?: (ev: Event) => void;\n addNodeHandler: (e: MouseEvent<HTMLButtonElement>) => void;\n highlight?: boolean;\n}\n\ntype AddButtonProps = Pick<AddNodeProps, 'addNodeHandler' | 'highlight'> &\n Pick<NodeEvents, 'active' | 'onFocus'> &\n NodeLabels;\n\nconst AddButton = ({\n addNodeHandler,\n highlight,\n active = false,\n fromNodeLabel,\n toNodeLabel,\n ...restProps\n}: AddButtonProps) => {\n const t = useI18n();\n const [hasMenuActive, setHasMenuActive] = useState(false);\n const { showNodeLibrary } = useContext(FlowModellerContext);\n const addNodeRef = useRef<HTMLButtonElement>(null);\n const [isFocused, setFocused] = useState(false);\n\n const addNodeClickHandler = (e: MouseEvent<HTMLButtonElement>) => {\n setHasMenuActive(true);\n addNodeHandler(e);\n };\n\n useEffect(() => {\n if (active) {\n addNodeRef.current?.focus();\n }\n }, [active]);\n\n useEffect(() => {\n if (!showNodeLibrary) {\n setHasMenuActive(false);\n }\n }, [showNodeLibrary]);\n\n const connectorTestID = generateDynamicTestId([\n fromNodeLabel || 'merge',\n toNodeLabel || 'branch-end'\n ]);\n\n const testIds = useTestIds(connectorTestID, getConnectorTestIds);\n\n return (\n <Flex data-testid={testIds.root} container={{ justify: 'center' }} as={StyledWrapper}>\n <StyledButton\n {...restProps}\n ref={addNodeRef}\n label={t('step_name', [t('add')])}\n aria-haspopup={hasMenuActive ? 'menu' : false}\n icon\n onClick={addNodeClickHandler}\n tabIndex={isFocused ? 0 : -1}\n onFocus={() => {\n setFocused(true);\n }}\n onBlur={() => {\n setFocused(false);\n }}\n >\n <StyledDot name='circle' highlight={highlight} />\n <StyledPlus name='plus' />\n </StyledButton>\n </Flex>\n );\n};\n\nexport default withTestIds(AddButton, getConnectorTestIds);\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlaceHolderConnector } from './Utils/addNodeUtils';
|
|
2
|
+
import type { PlottedGraphConnector } from './Renderer/Utils/GraphLayout';
|
|
3
|
+
import type { NodeEvents } from './Node/Node.types';
|
|
4
|
+
export declare const StyledLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("@pega/cosmos-react-core").TextProps, "ref"> & import("react").RefAttributes<HTMLHeadingElement | HTMLSpanElement> & import("@pega/cosmos-react-core").ForwardProps, "ref"> & {
|
|
5
|
+
ref?: ((instance: HTMLHeadingElement | HTMLSpanElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLHeadingElement | HTMLSpanElement> | null | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
highlight: boolean;
|
|
8
|
+
}>> & string & Omit<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").TextProps>, keyof import("react").Component<any, {}, any>>;
|
|
9
|
+
type ConnectorProps = Pick<PlottedGraphConnector, 'id' | 'data' | 'labelLayout' | 'points'> & Partial<Pick<PlaceHolderConnector, 'realConnectors'>>;
|
|
10
|
+
declare const _default: import("react").MemoExoticComponent<({ id, data, labelLayout, points, realConnectors, onKeyDown, ...restProps }: ConnectorProps & NodeEvents) => import("react/jsx-runtime").JSX.Element | null>;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=Connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAWpD,eAAO,MAAM,WAAW;;;eAA6B,OAAO;kLAmB1D,CAAC;AAsDH,KAAK,cAAc,GAAG,IAAI,CAAC,qBAAqB,EAAE,IAAI,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC,GACzF,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC,CAAC;yIAUrD,cAAc,GAAG,UAAU;AAwD9B,wBAA+B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useContext, useRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { defaultThemeProp, Flex, Text, useTheme } from '@pega/cosmos-react-core';
|
|
5
|
+
import AddButton from './AddNode';
|
|
6
|
+
import FlowModellerContext from './FlowModellerContext';
|
|
7
|
+
const isConnectorData = (data) => typeof data === 'object' && data !== null && 'type' in data && typeof data.type === 'string';
|
|
8
|
+
export const StyledLabel = styled(Text)(({ highlight, theme }) => {
|
|
9
|
+
return css `
|
|
10
|
+
border-radius: ${theme.base['border-radius']};
|
|
11
|
+
background: ${theme.base.colors.slate.dark};
|
|
12
|
+
color: ${theme.base.colors.white};
|
|
13
|
+
text-align: center;
|
|
14
|
+
padding: calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
max-width: calc(1.2 * ${theme.base['content-width'].xs});
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
|
|
20
|
+
${highlight &&
|
|
21
|
+
css `
|
|
22
|
+
&& {
|
|
23
|
+
background-color: ${theme.base.colors.red.dark};
|
|
24
|
+
}
|
|
25
|
+
`}
|
|
26
|
+
`;
|
|
27
|
+
});
|
|
28
|
+
StyledLabel.defaultProps = defaultThemeProp;
|
|
29
|
+
const curveRadius = 12;
|
|
30
|
+
const genLine = (points) => {
|
|
31
|
+
const lineStr = points
|
|
32
|
+
.map((point, idx, arr) => {
|
|
33
|
+
const { x, y } = point;
|
|
34
|
+
const prev = arr[idx - 1];
|
|
35
|
+
const next = arr[idx + 1];
|
|
36
|
+
const line = `L${x},${y}`;
|
|
37
|
+
// if the point is extreme end, no need to add a curve
|
|
38
|
+
if (!prev || !next) {
|
|
39
|
+
return line;
|
|
40
|
+
}
|
|
41
|
+
// if point is colinear with prev and next, no need to add a curve
|
|
42
|
+
if (prev.x === next.x || prev.y === next.y) {
|
|
43
|
+
return line;
|
|
44
|
+
}
|
|
45
|
+
if (point.x > next.x) {
|
|
46
|
+
// BOTTOM-RIGHT ↲
|
|
47
|
+
return `L${x},${y - curveRadius}a${curveRadius},${curveRadius} 0 0 1 -${curveRadius},${curveRadius}`;
|
|
48
|
+
}
|
|
49
|
+
// BOTTOM-LEFT ↳
|
|
50
|
+
if (point.x < next.x) {
|
|
51
|
+
return `L${x},${y - curveRadius}a${curveRadius},${curveRadius} 0 0 0 ${curveRadius},${curveRadius}`;
|
|
52
|
+
}
|
|
53
|
+
// TOP-LEFT ↱
|
|
54
|
+
if (point.x < prev.x) {
|
|
55
|
+
return `L${x + curveRadius},${y}a${curveRadius},${curveRadius} 0 0 0 -${curveRadius},${curveRadius}`;
|
|
56
|
+
}
|
|
57
|
+
// TOP-RIGHT ↴
|
|
58
|
+
if (point.x > prev.x) {
|
|
59
|
+
return `L${x - curveRadius},${y}a${curveRadius},${curveRadius} 0 0 1 ${curveRadius},${curveRadius}`;
|
|
60
|
+
}
|
|
61
|
+
return `L${x},${y}`;
|
|
62
|
+
})
|
|
63
|
+
.join('');
|
|
64
|
+
return `M${lineStr.substr(1)}`;
|
|
65
|
+
};
|
|
66
|
+
const Connector = ({ id, data, labelLayout, points, realConnectors, onKeyDown, ...restProps }) => {
|
|
67
|
+
const refId = realConnectors || id;
|
|
68
|
+
const { readOnly, highlights } = useContext(FlowModellerContext);
|
|
69
|
+
const theme = useTheme();
|
|
70
|
+
const connectorRef = useRef(null);
|
|
71
|
+
const metaData = {
|
|
72
|
+
refType: 'connector',
|
|
73
|
+
refId
|
|
74
|
+
};
|
|
75
|
+
return isConnectorData(data) && data.type === 'default' ? (_jsxs("g", { onKeyDown: onKeyDown, children: [_jsx("path", { id: id, d: genLine(points), stroke: highlights?.connectors?.[id] ? theme.base.colors.red.medium : theme.base.colors.slate.dark, strokeWidth: highlights?.connectors?.[id] ? 2 : 1, fill: 'none' }), labelLayout && (_jsxs("foreignObject", { x: labelLayout.x - labelLayout.width, y: points[3].y - 20, width: labelLayout.width, height: labelLayout.height, ref: connectorRef, children: [labelLayout?.value && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(StyledLabel, { highlight: !!highlights?.connectors?.[id], children: labelLayout.value }) })), !readOnly && data.onNodeCreate && (_jsx(AddButton, { ...restProps, highlight: !!highlights?.connectors?.[id], addNodeHandler: (e) => {
|
|
76
|
+
data.onNodeCreate?.(e.currentTarget, metaData);
|
|
77
|
+
connectorRef.current?.scrollIntoView({
|
|
78
|
+
block: 'center',
|
|
79
|
+
behavior: 'smooth'
|
|
80
|
+
});
|
|
81
|
+
} }))] }))] }, id)) : null;
|
|
82
|
+
};
|
|
83
|
+
export default memo(Connector);
|
|
84
|
+
//# sourceMappingURL=Connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/Connector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAUxD,MAAM,eAAe,GAAG,CAAC,IAAa,EAAyB,EAAE,CAC/D,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE/F,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAyB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;IACvF,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;kBAC9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,EACzC,cAAc,EAAE,CAAC,CAAgC,EAAE,EAAE;4BACnD,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;4BAC/C,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC;gCACnC,KAAK,EAAE,QAAQ;gCACf,QAAQ,EAAE,QAAQ;6BACnB,CAAC,CAAC;wBACL,CAAC,GACD,CACH,IACa,CACjB,KAvCK,EAAE,CAwCN,CACL,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import { memo, useContext, useRef } from 'react';\nimport type { MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Flex, Text, useTheme } from '@pega/cosmos-react-core';\n\nimport AddButton from './AddNode';\nimport type { AddNodeHandlerParams } from './Renderer/Renderer.types';\nimport type { PlaceHolderConnector } from './Utils/addNodeUtils';\nimport FlowModellerContext from './FlowModellerContext';\nimport type { PlottedGraphConnector } from './Renderer/Utils/GraphLayout';\nimport type { NodeEvents } from './Node/Node.types';\n\ninterface ConnectorData {\n type: string;\n label?: string;\n onNodeCreate?: (el: HTMLElement | SVGForeignObjectElement, meta: AddNodeHandlerParams) => void;\n}\n\nconst isConnectorData = (data: unknown): data is ConnectorData =>\n typeof data === 'object' && data !== null && 'type' in data && typeof data.type === 'string';\n\nexport const StyledLabel = styled(Text)<{ highlight: boolean }>(({ highlight, theme }) => {\n return css`\n border-radius: ${theme.base['border-radius']};\n background: ${theme.base.colors.slate.dark};\n color: ${theme.base.colors.white};\n text-align: center;\n padding: calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: calc(1.2 * ${theme.base['content-width'].xs});\n white-space: nowrap;\n\n ${highlight &&\n css`\n && {\n background-color: ${theme.base.colors.red.dark};\n }\n `}\n `;\n});\n\nStyledLabel.defaultProps = defaultThemeProp;\n\ninterface Points {\n x: number;\n y: number;\n}\n\nconst curveRadius = 12;\nconst genLine = (points: Points[]) => {\n const lineStr: string = points\n .map((point: Points, idx: number, arr: Points[]) => {\n const { x, y } = point;\n const prev = arr[idx - 1];\n const next = arr[idx + 1];\n const line = `L${x},${y}`;\n\n // if the point is extreme end, no need to add a curve\n if (!prev || !next) {\n return line;\n }\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) {\n return line;\n }\n\n if (point.x > next.x) {\n // BOTTOM-RIGHT ↲\n return `L${x},${y - curveRadius}a${curveRadius},${curveRadius} 0 0 1 -${curveRadius},${curveRadius}`;\n }\n\n // BOTTOM-LEFT ↳\n if (point.x < next.x) {\n return `L${x},${y - curveRadius}a${curveRadius},${curveRadius} 0 0 0 ${curveRadius},${curveRadius}`;\n }\n\n // TOP-LEFT ↱\n if (point.x < prev.x) {\n return `L${x + curveRadius},${y}a${curveRadius},${curveRadius} 0 0 0 -${curveRadius},${curveRadius}`;\n }\n\n // TOP-RIGHT ↴\n if (point.x > prev.x) {\n return `L${x - curveRadius},${y}a${curveRadius},${curveRadius} 0 0 1 ${curveRadius},${curveRadius}`;\n }\n\n return `L${x},${y}`;\n })\n .join('');\n return `M${lineStr.substr(1)}`;\n};\n\ntype ConnectorProps = Pick<PlottedGraphConnector, 'id' | 'data' | 'labelLayout' | 'points'> &\n Partial<Pick<PlaceHolderConnector, 'realConnectors'>>;\n\nconst Connector = ({\n id,\n data,\n labelLayout,\n points,\n realConnectors,\n onKeyDown,\n ...restProps\n}: ConnectorProps & NodeEvents) => {\n const refId = realConnectors || id;\n const { readOnly, highlights } = useContext(FlowModellerContext);\n const theme = useTheme();\n const connectorRef = useRef<SVGForeignObjectElement>(null);\n\n const metaData: AddNodeHandlerParams = {\n refType: 'connector',\n refId\n };\n\n return isConnectorData(data) && data.type === 'default' ? (\n <g key={id} onKeyDown={onKeyDown}>\n <path\n id={id}\n d={genLine(points)}\n stroke={\n highlights?.connectors?.[id] ? theme.base.colors.red.medium : theme.base.colors.slate.dark\n }\n strokeWidth={highlights?.connectors?.[id] ? 2 : 1}\n fill='none'\n />\n {labelLayout && (\n <foreignObject\n x={labelLayout.x - labelLayout.width}\n y={points[3].y - 20}\n width={labelLayout.width}\n height={labelLayout.height}\n ref={connectorRef}\n >\n {labelLayout?.value && (\n <Flex container={{ justify: 'center' }}>\n <StyledLabel highlight={!!highlights?.connectors?.[id]}>\n {labelLayout.value}\n </StyledLabel>\n </Flex>\n )}\n {!readOnly && data.onNodeCreate && (\n <AddButton\n {...restProps}\n highlight={!!highlights?.connectors?.[id]}\n addNodeHandler={(e: MouseEvent<HTMLButtonElement>) => {\n data.onNodeCreate?.(e.currentTarget, metaData);\n connectorRef.current?.scrollIntoView({\n block: 'center',\n behavior: 'smooth'\n });\n }}\n />\n )}\n </foreignObject>\n )}\n </g>\n ) : null;\n};\n\nexport default memo(Connector);\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ChangeEvent, PropsWithoutRef } from 'react';
|
|
2
|
+
import type { FormDialogProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { GraphData } from './Renderer/Utils/Graph';
|
|
4
|
+
import type { GraphDataAsMap, DeleteNodeOutcome } from './Utils/deleteNodeUtils';
|
|
5
|
+
import type { NodeProps } from './Node/Node.types';
|
|
6
|
+
export interface DeleteDialogProps {
|
|
7
|
+
target: FormDialogProps['target'];
|
|
8
|
+
flowGraphData: GraphData<NodeProps>;
|
|
9
|
+
rendererGraphData: GraphData<NodeProps>;
|
|
10
|
+
nodeId: string;
|
|
11
|
+
onChange?: (itemsToDelete: GraphDataAsMap, itemsToRetain: GraphDataAsMap | undefined, ev?: ChangeEvent) => void;
|
|
12
|
+
onSubmit?: (outcome: DeleteNodeOutcome) => void;
|
|
13
|
+
onCancel?: () => void;
|
|
14
|
+
ref?: FormDialogProps['ref'];
|
|
15
|
+
}
|
|
16
|
+
export declare const StyledDeleteDialog: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(Omit<Omit<import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").BaseDialogProps & {
|
|
17
|
+
onDismiss?: () => void;
|
|
18
|
+
onCancel: import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").FormAction;
|
|
19
|
+
onSubmit: import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").FormAction;
|
|
20
|
+
} & {
|
|
21
|
+
heading: string;
|
|
22
|
+
additionalInfo?: import("@pega/cosmos-react-core").AdditionalInfoProps;
|
|
23
|
+
'aria-label'?: never;
|
|
24
|
+
} & Omit<import("@pega/cosmos-react-core").Attributes<"div">, "aria-label" | "onSubmit" | "onCancel" | "heading" | keyof import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").BaseDialogProps | "onDismiss" | "additionalInfo">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
25
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
26
|
+
}) | (Omit<Omit<import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").BaseDialogProps & {
|
|
27
|
+
onDismiss?: () => void;
|
|
28
|
+
onCancel: import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").FormAction;
|
|
29
|
+
onSubmit: import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").FormAction;
|
|
30
|
+
} & {
|
|
31
|
+
heading?: never;
|
|
32
|
+
'aria-label': string;
|
|
33
|
+
additionalInfo?: never;
|
|
34
|
+
} & Omit<import("@pega/cosmos-react-core").Attributes<"div">, "aria-label" | "onSubmit" | "onCancel" | "heading" | keyof import("@pega/cosmos-react-core/lib/components/Dialog/Dialog.types").BaseDialogProps | "onDismiss" | "additionalInfo">, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
35
|
+
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
36
|
+
}), import("styled-components/dist/types").BaseObject>> & string & Omit<import("react").ForwardRefExoticComponent<PropsWithoutRef<FormDialogProps> & import("react").RefAttributes<HTMLDivElement>>, keyof import("react").Component<any, {}, any>>;
|
|
37
|
+
declare const DeleteDialog: ({ target, flowGraphData, rendererGraphData, nodeId, onChange, onSubmit, onCancel }: PropsWithoutRef<DeleteDialogProps>) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export default DeleteDialog;
|
|
39
|
+
//# sourceMappingURL=DeleteDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteDialog.d.ts","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeleteDialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,WAAW,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAa9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAClC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,iBAAiB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CACT,aAAa,EAAE,cAAc,EAC7B,aAAa,EAAE,cAAc,GAAG,SAAS,EACzC,EAAE,CAAC,EAAE,WAAW,KACb,IAAI,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;mPAI7B,CAAC;AAIH,QAAA,MAAM,YAAY,GAAI,oFAQnB,eAAe,CAAC,iBAAiB,CAAC,4CA2NpC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Select, Option, Text, Flex, useI18n, useElement, FormDialog, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
5
|
+
import { DirectedGraph } from './Renderer/Utils/Graph';
|
|
6
|
+
import deleteNodeUtils from './Utils/deleteNodeUtils';
|
|
7
|
+
import { getReferences } from './helper';
|
|
8
|
+
export const StyledDeleteDialog = styled(FormDialog)(({ theme }) => {
|
|
9
|
+
return css `
|
|
10
|
+
min-width: calc(30 * ${theme.base.spacing});
|
|
11
|
+
`;
|
|
12
|
+
});
|
|
13
|
+
StyledDeleteDialog.defaultProps = defaultThemeProp;
|
|
14
|
+
const DeleteDialog = ({ target, flowGraphData, rendererGraphData, nodeId, onChange, onSubmit, onCancel }) => {
|
|
15
|
+
const [currentSelection, setCurrentSelection] = useState(0);
|
|
16
|
+
const [currNode, setCurrNode] = useElement();
|
|
17
|
+
const t = useI18n();
|
|
18
|
+
const graph = new DirectedGraph(rendererGraphData);
|
|
19
|
+
const deleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(graph, nodeId);
|
|
20
|
+
const deleteOptions = deleteOptionsResult.options;
|
|
21
|
+
const selectedPath = useMemo(() => {
|
|
22
|
+
if (currentSelection === -1 || !deleteOptions[currentSelection]) {
|
|
23
|
+
return 'none';
|
|
24
|
+
}
|
|
25
|
+
const option = deleteOptions[currentSelection];
|
|
26
|
+
return option.connector.label || option.connector.id;
|
|
27
|
+
}, [deleteOptions, currentSelection]);
|
|
28
|
+
const nodeType = graph.getNode(nodeId).type.name;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (deleteOptionsResult && deleteOptions[currentSelection]) {
|
|
31
|
+
const itemsToDelete = nodeType !== 'Decision'
|
|
32
|
+
? deleteOptionsResult.allItems
|
|
33
|
+
: deleteOptions[currentSelection].restItems;
|
|
34
|
+
// add the actual node to be deleted also, to the list
|
|
35
|
+
itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);
|
|
36
|
+
setCurrNode(target);
|
|
37
|
+
onChange?.(itemsToDelete, deleteOptions[currentSelection].pathItems);
|
|
38
|
+
}
|
|
39
|
+
}, [rendererGraphData]);
|
|
40
|
+
const onChangeHandler = (ev) => {
|
|
41
|
+
const newSelection = ev.target.selectedIndex >= deleteOptions.length ? -1 : ev.target.selectedIndex;
|
|
42
|
+
setCurrentSelection(newSelection);
|
|
43
|
+
let itemsToDelete;
|
|
44
|
+
if (deleteOptionsResult) {
|
|
45
|
+
itemsToDelete = deleteOptionsResult.allItems;
|
|
46
|
+
}
|
|
47
|
+
let itemsToRetain;
|
|
48
|
+
if (newSelection !== -1) {
|
|
49
|
+
itemsToDelete = deleteOptions[newSelection].restItems;
|
|
50
|
+
itemsToRetain = deleteOptions[newSelection].pathItems;
|
|
51
|
+
}
|
|
52
|
+
// add the actual node to be deleted also, to the list
|
|
53
|
+
if (itemsToDelete) {
|
|
54
|
+
itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);
|
|
55
|
+
}
|
|
56
|
+
if (itemsToDelete) {
|
|
57
|
+
onChange?.(itemsToDelete, itemsToRetain, ev);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const submitHandler = () => {
|
|
61
|
+
let error = true;
|
|
62
|
+
const finalGraph = new DirectedGraph(flowGraphData);
|
|
63
|
+
const finalDeleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(finalGraph, nodeId);
|
|
64
|
+
let newTargetNode = finalDeleteOptionsResult?.destinationNodeId
|
|
65
|
+
? finalGraph.getNode(finalDeleteOptionsResult.destinationNodeId)
|
|
66
|
+
: undefined;
|
|
67
|
+
let itemsToDelete = finalDeleteOptionsResult.allItems;
|
|
68
|
+
const selectedOption = currentSelection === -1 || nodeType !== 'Decision'
|
|
69
|
+
? undefined
|
|
70
|
+
: finalDeleteOptionsResult?.options[currentSelection];
|
|
71
|
+
let finalMetaData = selectedOption;
|
|
72
|
+
if (selectedOption) {
|
|
73
|
+
const pathConnectors = selectedOption.pathItems.connectors;
|
|
74
|
+
const connectors = Object.keys(pathConnectors);
|
|
75
|
+
for (let i = 0; i < connectors.length; i += 1) {
|
|
76
|
+
const connectorData = pathConnectors[connectors[i]];
|
|
77
|
+
if (connectorData &&
|
|
78
|
+
finalGraph.getNode(connectorData.fromNodeId).type?.minConnectors !== 0 &&
|
|
79
|
+
connectorData.toNodeId === finalDeleteOptionsResult.destinationNodeId) {
|
|
80
|
+
error = false;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const references = getReferences(Object.values(itemsToDelete.nodes), finalGraph);
|
|
85
|
+
if (error || references.length > 0) {
|
|
86
|
+
onSubmit?.({
|
|
87
|
+
graphData: {
|
|
88
|
+
nodes: [],
|
|
89
|
+
connectors: []
|
|
90
|
+
},
|
|
91
|
+
updates: {
|
|
92
|
+
connectors: []
|
|
93
|
+
},
|
|
94
|
+
deletes: { nodes: {}, connectors: {} },
|
|
95
|
+
error: true,
|
|
96
|
+
references
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
finalMetaData = finalDeleteOptionsResult.options.find(current => selectedOption.connector.id === current.connector.id);
|
|
101
|
+
if (finalMetaData) {
|
|
102
|
+
// get the ref of the first node of the retaining path
|
|
103
|
+
newTargetNode = finalGraph.getNode(finalMetaData.connector.toNodeId);
|
|
104
|
+
itemsToDelete = finalMetaData.restItems;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// get the in-connectors of the selected node
|
|
108
|
+
const nodeInConnectors = finalGraph.getInConnectors(nodeId);
|
|
109
|
+
// iterate and set the targetNode to the above first node instead of the selected node.
|
|
110
|
+
if (newTargetNode) {
|
|
111
|
+
nodeInConnectors.forEach(con => {
|
|
112
|
+
finalGraph.setConnector(con.id, {
|
|
113
|
+
toNodeId: newTargetNode.id
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// if no retaining path, then remove the in connectors of the deleted node as well
|
|
119
|
+
nodeInConnectors.forEach(con => {
|
|
120
|
+
finalGraph.removeConnector(con.id);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const resultGraphData = finalGraph.getGraphData();
|
|
124
|
+
itemsToDelete.nodes[nodeId] = finalGraph.getNode(nodeId);
|
|
125
|
+
// filter the highlighted nodes, including the selected node
|
|
126
|
+
const nodes = resultGraphData.nodes.filter(item => {
|
|
127
|
+
return itemsToDelete.nodes[item.id] === undefined;
|
|
128
|
+
});
|
|
129
|
+
if (finalMetaData) {
|
|
130
|
+
itemsToDelete.connectors[finalMetaData.connector.id] = finalMetaData.connector;
|
|
131
|
+
}
|
|
132
|
+
// filter the highlighted connectors
|
|
133
|
+
const connectors = resultGraphData.connectors.filter(item => {
|
|
134
|
+
return itemsToDelete.connectors[item.id] === undefined;
|
|
135
|
+
});
|
|
136
|
+
const outcome = {
|
|
137
|
+
graphData: {
|
|
138
|
+
nodes,
|
|
139
|
+
connectors
|
|
140
|
+
},
|
|
141
|
+
updates: {
|
|
142
|
+
connectors: nodeInConnectors
|
|
143
|
+
},
|
|
144
|
+
deletes: itemsToDelete,
|
|
145
|
+
error: false
|
|
146
|
+
};
|
|
147
|
+
onSubmit?.(outcome);
|
|
148
|
+
};
|
|
149
|
+
const onCancelHandler = () => {
|
|
150
|
+
currNode?.focus();
|
|
151
|
+
onCancel?.();
|
|
152
|
+
};
|
|
153
|
+
return (_jsx(StyledDeleteDialog, { target: target, heading: t('delete_step_title'), onCancel: onCancelHandler, onSubmit: submitHandler, placement: 'right-end', children: _jsx(Flex, { container: { gap: 2, pad: 2, direction: 'column' }, children: nodeType === 'Decision' ? (_jsxs(_Fragment, { children: [_jsx(Text, { children: t('delete_decision_step') }), _jsxs(Select, { id: 'select-demo', label: t('delete_step_outcome'), value: selectedPath, required: true, onChange: onChangeHandler, children: [deleteOptions.map(item => {
|
|
154
|
+
return (_jsx(Option, { value: item.connector.label ? item.connector.label : item.connector.id, children: item.connector.label ? item.connector.label : item.connector.id }, item.connector.id));
|
|
155
|
+
}), _jsx(Option, { value: 'none', children: t('delete_all_outcomes') }, 'none')] })] })) : (_jsx(Text, { children: t('delete_step') })) }) }));
|
|
156
|
+
};
|
|
157
|
+
export default DeleteDialog;
|
|
158
|
+
//# sourceMappingURL=DeleteDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteDialog.js","sourceRoot":"","sources":["../../../src/components/FlowModeller/DeleteDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,EACV,UAAU,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB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,CAAC,CACF,KAAC,IAAI,cAAE,CAAC,CAAC,aAAa,CAAC,GAAQ,CAChC,GACI,GACY,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useState, useEffect, useMemo } from 'react';\nimport type { ChangeEventHandler, ChangeEvent, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Select,\n Option,\n Text,\n Flex,\n useI18n,\n useElement,\n FormDialog,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\nimport type { FormDialogProps } from '@pega/cosmos-react-core';\n\nimport { DirectedGraph } from './Renderer/Utils/Graph';\nimport type { GraphData } from './Renderer/Utils/Graph';\nimport type {\n GraphDataAsMap,\n DeleteNodeOutcome,\n DeleteNodeModalOption\n} from './Utils/deleteNodeUtils';\nimport deleteNodeUtils from './Utils/deleteNodeUtils';\nimport type { NodeProps } from './Node/Node.types';\nimport { getReferences } from './helper';\n\nexport interface DeleteDialogProps {\n target: FormDialogProps['target'];\n flowGraphData: GraphData<NodeProps>;\n rendererGraphData: GraphData<NodeProps>;\n nodeId: string;\n onChange?: (\n itemsToDelete: GraphDataAsMap,\n itemsToRetain: GraphDataAsMap | undefined,\n ev?: ChangeEvent\n ) => void;\n onSubmit?: (outcome: DeleteNodeOutcome) => void;\n onCancel?: () => void;\n ref?: FormDialogProps['ref'];\n}\n\nexport const StyledDeleteDialog = styled(FormDialog)(({ theme }) => {\n return css`\n min-width: calc(30 * ${theme.base.spacing});\n `;\n});\n\nStyledDeleteDialog.defaultProps = defaultThemeProp;\n\nconst DeleteDialog = ({\n target,\n flowGraphData,\n rendererGraphData,\n nodeId,\n onChange,\n onSubmit,\n onCancel\n}: PropsWithoutRef<DeleteDialogProps>) => {\n const [currentSelection, setCurrentSelection] = useState<number>(0);\n\n const [currNode, setCurrNode] = useElement<HTMLElement>();\n\n const t = useI18n();\n\n const graph = new DirectedGraph<NodeProps>(rendererGraphData);\n\n const deleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(graph, nodeId);\n\n const deleteOptions: DeleteNodeModalOption[] = deleteOptionsResult.options;\n\n const selectedPath: string = useMemo(() => {\n if (currentSelection === -1 || !deleteOptions[currentSelection]) {\n return 'none';\n }\n const option = deleteOptions[currentSelection];\n return option.connector.label || option.connector.id;\n }, [deleteOptions, currentSelection]);\n\n const nodeType = graph.getNode(nodeId).type.name;\n\n useEffect(() => {\n if (deleteOptionsResult && deleteOptions[currentSelection]) {\n const itemsToDelete: GraphDataAsMap =\n nodeType !== 'Decision'\n ? deleteOptionsResult.allItems\n : deleteOptions[currentSelection].restItems;\n\n // add the actual node to be deleted also, to the list\n itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);\n setCurrNode(target);\n onChange?.(itemsToDelete, deleteOptions[currentSelection].pathItems);\n }\n }, [rendererGraphData]);\n\n const onChangeHandler: ChangeEventHandler = (ev: ChangeEvent<HTMLSelectElement>) => {\n const newSelection =\n ev.target.selectedIndex >= deleteOptions.length ? -1 : ev.target.selectedIndex;\n\n setCurrentSelection(newSelection);\n\n let itemsToDelete;\n if (deleteOptionsResult) {\n itemsToDelete = deleteOptionsResult.allItems;\n }\n\n let itemsToRetain;\n\n if (newSelection !== -1) {\n itemsToDelete = deleteOptions[newSelection].restItems;\n itemsToRetain = deleteOptions[newSelection].pathItems;\n }\n\n // add the actual node to be deleted also, to the list\n if (itemsToDelete) {\n itemsToDelete.nodes[nodeId] = graph.getNode(nodeId);\n }\n\n if (itemsToDelete) {\n onChange?.(itemsToDelete, itemsToRetain, ev);\n }\n };\n\n const submitHandler = () => {\n let error = true;\n const finalGraph = new DirectedGraph<NodeProps>(flowGraphData);\n const finalDeleteOptionsResult = deleteNodeUtils.getDeleteNodeOptions(finalGraph, nodeId);\n\n let newTargetNode = finalDeleteOptionsResult?.destinationNodeId\n ? finalGraph.getNode(finalDeleteOptionsResult.destinationNodeId)\n : undefined;\n let itemsToDelete = finalDeleteOptionsResult.allItems;\n\n const selectedOption =\n currentSelection === -1 || nodeType !== 'Decision'\n ? undefined\n : finalDeleteOptionsResult?.options[currentSelection];\n let finalMetaData = selectedOption;\n\n if (selectedOption) {\n const pathConnectors = selectedOption.pathItems.connectors;\n const connectors = Object.keys(pathConnectors);\n for (let i = 0; i < connectors.length; i += 1) {\n const connectorData = pathConnectors[connectors[i]];\n if (\n connectorData &&\n finalGraph.getNode(connectorData.fromNodeId).type?.minConnectors !== 0 &&\n connectorData.toNodeId === finalDeleteOptionsResult.destinationNodeId\n ) {\n error = false;\n break;\n }\n }\n\n const references = getReferences(Object.values(itemsToDelete.nodes), finalGraph);\n if (error || references.length > 0) {\n onSubmit?.({\n graphData: {\n nodes: [],\n connectors: []\n },\n updates: {\n connectors: []\n },\n deletes: { nodes: {}, connectors: {} },\n error: true,\n references\n });\n return;\n }\n\n finalMetaData = finalDeleteOptionsResult.options.find(\n current => selectedOption.connector.id === current.connector.id\n );\n\n if (finalMetaData) {\n // get the ref of the first node of the retaining path\n newTargetNode = finalGraph.getNode(finalMetaData.connector.toNodeId);\n itemsToDelete = finalMetaData.restItems;\n }\n }\n\n // get the in-connectors of the selected node\n const nodeInConnectors = finalGraph.getInConnectors(nodeId);\n\n // iterate and set the targetNode to the above first node instead of the selected node.\n if (newTargetNode) {\n nodeInConnectors.forEach(con => {\n finalGraph.setConnector(con.id, {\n toNodeId: newTargetNode.id\n });\n });\n } else {\n // if no retaining path, then remove the in connectors of the deleted node as well\n nodeInConnectors.forEach(con => {\n finalGraph.removeConnector(con.id);\n });\n }\n\n const resultGraphData = finalGraph.getGraphData();\n\n itemsToDelete.nodes[nodeId] = finalGraph.getNode(nodeId);\n\n // filter the highlighted nodes, including the selected node\n const nodes = resultGraphData.nodes.filter(item => {\n return itemsToDelete.nodes[item.id] === undefined;\n });\n\n if (finalMetaData) {\n itemsToDelete.connectors[finalMetaData.connector.id] = finalMetaData.connector;\n }\n\n // filter the highlighted connectors\n const connectors = resultGraphData.connectors.filter(item => {\n return itemsToDelete.connectors[item.id] === undefined;\n });\n\n const outcome: DeleteNodeOutcome = {\n graphData: {\n nodes,\n connectors\n },\n updates: {\n connectors: nodeInConnectors\n },\n deletes: itemsToDelete,\n error: false\n };\n onSubmit?.(outcome);\n };\n\n const onCancelHandler = () => {\n currNode?.focus();\n onCancel?.();\n };\n\n return (\n <StyledDeleteDialog\n target={target}\n heading={t('delete_step_title')}\n onCancel={onCancelHandler}\n onSubmit={submitHandler}\n placement='right-end'\n >\n <Flex container={{ gap: 2, pad: 2, direction: 'column' }}>\n {nodeType === 'Decision' ? (\n <>\n <Text>{t('delete_decision_step')}</Text>\n <Select\n id='select-demo'\n label={t('delete_step_outcome')}\n value={selectedPath}\n required\n onChange={onChangeHandler}\n >\n {deleteOptions.map(item => {\n return (\n <Option\n key={item.connector.id}\n value={item.connector.label ? item.connector.label : item.connector.id}\n >\n {item.connector.label ? item.connector.label : item.connector.id}\n </Option>\n );\n })}\n\n <Option key='none' value='none'>\n {t('delete_all_outcomes')}\n </Option>\n </Select>\n </>\n ) : (\n <Text>{t('delete_step')}</Text>\n )}\n </Flex>\n </StyledDeleteDialog>\n );\n};\n\nexport default DeleteDialog;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FlowAuthoringPanelProps } from './FlowAuthoringPanel.types';
|
|
2
|
+
declare const FlowAuthoringPanel: ({ open, content, header, onDismiss, progress, target }: FlowAuthoringPanelProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export default FlowAuthoringPanel;
|
|
4
|
+
//# sourceMappingURL=FlowAuthoringPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowAuthoringPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/FlowModeller/FlowAuthoringPanel/FlowAuthoringPanel.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AA8D1E,QAAA,MAAM,kBAAkB,GAAI,wDAOzB,uBAAuB,mDA2FzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { Icon, registerIcon, Text, Button, Progress, Flex, OneColumnPage, useEscape, useDirection, Drawer, useI18n } from '@pega/cosmos-react-core';
|
|
4
|
+
import { resizeDrawerDefaultWidth } from '@pega/cosmos-react-core/lib/styles/constants';
|
|
5
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
6
|
+
import IconTile from '../../IconTile';
|
|
7
|
+
import { StyledPreviewDrawer, StyledFlowAuthoringPanel, StyledProgressContainer, StyledPanelContent, StyledPanelHeader, StyledPanelPage } from './FlowAuthoringPanel.styles';
|
|
8
|
+
registerIcon(timesIcon);
|
|
9
|
+
const FlowAuthoringPanelHeader = ({ header, onDismiss, dismissButtonRef }) => {
|
|
10
|
+
const t = useI18n();
|
|
11
|
+
return (_jsxs(Flex, { container: { justify: 'between', alignItems: 'center', gap: 2 }, children: [_jsxs(Flex, { container: { gap: 1.5 }, children: [header?.visual && (_jsx(IconTile, { name: header.visual.name, label: header.visual.label, category: header.visual.category, inverted: header.visual.inverted, set: header.visual.set, size: 'xl' })), _jsxs(Flex, { container: { direction: 'column', gap: 0.5 }, children: [header?.secondary?.title && (_jsx(Text, { variant: 'primary', id: 'panel-title', children: header.secondary.title })), header?.primary?.title && _jsx(Text, { variant: 'h2', children: header.primary.title })] })] }), onDismiss && (_jsx(Button, { icon: true, variant: 'simple', compact: true, ref: dismissButtonRef, label: t('close_panel'), onClick: onDismiss, children: _jsx(Icon, { name: 'times' }) }))] }));
|
|
12
|
+
};
|
|
13
|
+
const FlowAuthoringPanel = ({ open, content, header, onDismiss, progress = false, target }) => {
|
|
14
|
+
const panelRef = useRef(null);
|
|
15
|
+
const dismissButtonRef = useRef(null);
|
|
16
|
+
const direction = useDirection();
|
|
17
|
+
const t = useI18n();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (open && dismissButtonRef.current && !progress) {
|
|
20
|
+
dismissButtonRef.current.focus();
|
|
21
|
+
}
|
|
22
|
+
}, [open, progress]);
|
|
23
|
+
const dismissPanel = () => {
|
|
24
|
+
onDismiss?.(target || undefined);
|
|
25
|
+
};
|
|
26
|
+
useEscape(() => {
|
|
27
|
+
if (open) {
|
|
28
|
+
dismissPanel();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (!open) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (_jsx(Drawer, { as: StyledPreviewDrawer, role: 'complementary', forwardedAs: Flex, container: { direction: 'column' }, ref: panelRef, open: open, position: 'absolute', placement: direction.end, "aria-label": header?.primary?.title, shadow: true, nullWhenClosed: true, resizeable: true, size: resizeDrawerDefaultWidth, children: open && (_jsx(Flex, { item: { shrink: 0 }, as: StyledFlowAuthoringPanel, open: open, children: progress ? (_jsxs(Flex, { container: { direction: 'column' }, as: StyledProgressContainer, children: [onDismiss && (_jsx(Flex, { container: { justify: 'end' }, children: _jsx(Button, { icon: true, variant: 'simple', compact: true, ref: dismissButtonRef, label: t('close_panel'), onClick: dismissPanel, children: _jsx(Icon, { name: 'times' }) }) })), _jsx(Progress, { visible: !!progress, focusOnVisible: true, placement: 'local', message: typeof progress === 'string' ? progress : undefined })] })) : (_jsx(Flex, { container: { gap: 1 }, as: OneColumnPage, forwardedAs: StyledPanelPage, title: header?.primary?.title, header: _jsx(StyledPanelHeader, { children: _jsx(FlowAuthoringPanelHeader, { header: header, onDismiss: onDismiss ? dismissPanel : undefined, dismissButtonRef: dismissButtonRef }) }), scrollContent: true, a: _jsx(StyledPanelContent, { children: content }) })) })) }));
|
|
35
|
+
};
|
|
36
|
+
export default FlowAuthoringPanel;
|
|
37
|
+
//# sourceMappingURL=FlowAuthoringPanel.js.map
|