@pega/cosmos-react-build 9.0.0-build.9.4 → 9.0.0-build.9.6

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 (60) hide show
  1. package/lib/components/Automation/Automation.d.ts +7 -0
  2. package/lib/components/Automation/Automation.d.ts.map +1 -0
  3. package/lib/components/Automation/Automation.js +113 -0
  4. package/lib/components/Automation/Automation.js.map +1 -0
  5. package/lib/components/Automation/Automation.styles.d.ts +12 -0
  6. package/lib/components/Automation/Automation.styles.d.ts.map +1 -0
  7. package/lib/components/Automation/Automation.styles.js +68 -0
  8. package/lib/components/Automation/Automation.styles.js.map +1 -0
  9. package/lib/components/Automation/Automation.test-ids.d.ts +3 -0
  10. package/lib/components/Automation/Automation.test-ids.d.ts.map +1 -0
  11. package/lib/components/Automation/Automation.test-ids.js +21 -0
  12. package/lib/components/Automation/Automation.test-ids.js.map +1 -0
  13. package/lib/components/Automation/Automation.types.d.ts +95 -0
  14. package/lib/components/Automation/Automation.types.d.ts.map +1 -0
  15. package/lib/components/Automation/Automation.types.js +18 -0
  16. package/lib/components/Automation/Automation.types.js.map +1 -0
  17. package/lib/components/Automation/Automation.utils.d.ts +109 -0
  18. package/lib/components/Automation/Automation.utils.d.ts.map +1 -0
  19. package/lib/components/Automation/Automation.utils.js +208 -0
  20. package/lib/components/Automation/Automation.utils.js.map +1 -0
  21. package/lib/components/Automation/AutomationContext.d.ts +4 -0
  22. package/lib/components/Automation/AutomationContext.d.ts.map +1 -0
  23. package/lib/components/Automation/AutomationContext.js +9 -0
  24. package/lib/components/Automation/AutomationContext.js.map +1 -0
  25. package/lib/components/Automation/RuleStep.d.ts +7 -0
  26. package/lib/components/Automation/RuleStep.d.ts.map +1 -0
  27. package/lib/components/Automation/RuleStep.js +151 -0
  28. package/lib/components/Automation/RuleStep.js.map +1 -0
  29. package/lib/components/Automation/index.d.ts +5 -0
  30. package/lib/components/Automation/index.d.ts.map +1 -0
  31. package/lib/components/Automation/index.js +4 -0
  32. package/lib/components/Automation/index.js.map +1 -0
  33. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.d.ts +34 -0
  34. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.d.ts.map +1 -0
  35. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.js +55 -0
  36. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.js.map +1 -0
  37. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.test-ids.d.ts +2 -0
  38. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.test-ids.d.ts.map +1 -0
  39. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.test-ids.js +10 -0
  40. package/lib/components/EmptyRuleTemplate/EmptyRuleTemplate.test-ids.js.map +1 -0
  41. package/lib/components/EmptyRuleTemplate/index.d.ts +3 -0
  42. package/lib/components/EmptyRuleTemplate/index.d.ts.map +1 -0
  43. package/lib/components/EmptyRuleTemplate/index.js +2 -0
  44. package/lib/components/EmptyRuleTemplate/index.js.map +1 -0
  45. package/lib/components/FieldReference/index.d.ts +1 -1
  46. package/lib/components/FieldReference/index.d.ts.map +1 -1
  47. package/lib/components/FieldReference/index.js.map +1 -1
  48. package/lib/index.d.ts +4 -1
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +4 -1
  51. package/lib/index.js.map +1 -1
  52. package/package.json +4 -4
  53. package/lib/utils/index.d.ts +0 -2
  54. package/lib/utils/index.d.ts.map +0 -1
  55. package/lib/utils/index.js +0 -2
  56. package/lib/utils/index.js.map +0 -1
  57. package/lib/utils/utils.d.ts +0 -14
  58. package/lib/utils/utils.d.ts.map +0 -1
  59. package/lib/utils/utils.js +0 -13
  60. package/lib/utils/utils.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ import type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
2
+ import type { AutomationProps } from './Automation.types';
3
+ declare const _default: ForwardRefForwardPropsComponent<AutomationProps> & {
4
+ getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["expand-all", "collapse-all", "generate-comments", "steps"]>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=Automation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/Automation.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAa,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAS1F,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;;;;AAyL5E,wBAA6D"}
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState, useEffect, useMemo, forwardRef } from 'react';
3
+ import { Flex, Button, Icon, useTestIds, withTestIds, useDirection, useEvent, useI18n, registerIcon } from '@pega/cosmos-react-core';
4
+ import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
5
+ import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
6
+ import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
7
+ import RuleStep from './RuleStep';
8
+ import { getAutomationTestIds } from './Automation.test-ids';
9
+ import { automationTreeHelpers } from './Automation.utils';
10
+ import { StyledAIButton, StyledAutomation, StyledBaseTree } from './Automation.styles';
11
+ import AutomationContext from './AutomationContext';
12
+ registerIcon(caretDownIcon, caretLeftIcon, caretRightIcon);
13
+ const NodeRenderer = ({ subTree, ...restProps }) => {
14
+ return (_jsxs(_Fragment, { children: [_jsx(RuleStep, { ...restProps }), subTree] }));
15
+ };
16
+ const Automation = forwardRef(({ testId, nodes, onExpandAll, onCollapseAll, focusedNodeId, onGenerateCommentsUsingGenAI }) => {
17
+ const t = useI18n();
18
+ const { rtl } = useDirection();
19
+ const testIds = useTestIds(testId, getAutomationTestIds);
20
+ const treeRef = useRef(null);
21
+ const [focusedNode, setFocusedNode] = useState('');
22
+ const [focusInsideNode, setFocusInsideNode] = useState(false);
23
+ const [focusInsideTree, setFocusInsideTree] = useState(false);
24
+ // handle key strokes on tree
25
+ const handlekeyDown = (e) => {
26
+ if (['Enter', 'ArrowDown', 'ArrowUp'].includes(e.key) && focusInsideNode) {
27
+ return;
28
+ }
29
+ switch (e.key) {
30
+ case 'ArrowDown': {
31
+ const nextNode = automationTreeHelpers.getNextNode(nodes, focusedNode);
32
+ setFocusedNode(nextNode.stepId);
33
+ break;
34
+ }
35
+ case 'ArrowUp': {
36
+ const previousNode = automationTreeHelpers.getPreviousNode(nodes, focusedNode);
37
+ setFocusedNode(previousNode.stepId);
38
+ break;
39
+ }
40
+ case 'Enter': {
41
+ setFocusInsideNode(true);
42
+ break;
43
+ }
44
+ case 'Escape': {
45
+ if (focusInsideNode) {
46
+ const currentFocussedNodeId = document.activeElement
47
+ ?.closest('[role="treeitem"]')
48
+ ?.getAttribute('id');
49
+ if (currentFocussedNodeId) {
50
+ setFocusedNode(currentFocussedNodeId);
51
+ }
52
+ setFocusInsideNode(false);
53
+ }
54
+ break;
55
+ }
56
+ default:
57
+ break;
58
+ }
59
+ };
60
+ // handle focus movements in and out of tree
61
+ const handleFocusEvent = (e) => {
62
+ switch (e.type) {
63
+ case 'focusin': {
64
+ if (!focusedNode) {
65
+ setFocusedNode(nodes[0].stepId);
66
+ }
67
+ if (!focusInsideTree) {
68
+ setFocusInsideTree(true);
69
+ }
70
+ break;
71
+ }
72
+ case 'focusout': {
73
+ if (focusInsideTree) {
74
+ setFocusInsideTree(false);
75
+ }
76
+ break;
77
+ }
78
+ default:
79
+ break;
80
+ }
81
+ };
82
+ const handleClick = (e) => {
83
+ const currentNodeId = e.target instanceof Element
84
+ ? e.target.closest('[role="treeitem"]')?.getAttribute('id')
85
+ : null;
86
+ if (focusInsideTree && !focusInsideNode && currentNodeId) {
87
+ setFocusInsideNode(true);
88
+ setFocusedNode(currentNodeId);
89
+ }
90
+ };
91
+ // event handlers for focus management.
92
+ useEvent('keydown', handlekeyDown, { target: treeRef });
93
+ useEvent('focusin', handleFocusEvent, { target: treeRef });
94
+ useEvent('focusout', handleFocusEvent, { target: treeRef });
95
+ useEvent('click', handleClick, { target: treeRef });
96
+ // To capture focusNode from story
97
+ useEffect(() => {
98
+ if (focusedNodeId) {
99
+ setFocusInsideNode(false);
100
+ setFocusedNode(focusedNodeId);
101
+ }
102
+ }, [focusedNodeId]);
103
+ const indexedNodes = useMemo(() => automationTreeHelpers.calculateStepIndices(nodes), [nodes]);
104
+ const automationCtxValue = useMemo(() => ({
105
+ focusedNodeId: focusedNode,
106
+ focusInsideNode,
107
+ focusInsideTree,
108
+ firstNodeId: nodes[0]?.stepId
109
+ }), [focusedNode, focusInsideNode, focusInsideTree, nodes]);
110
+ return (_jsx(AutomationContext.Provider, { value: automationCtxValue, children: _jsxs(StyledAutomation, { children: [_jsxs(Flex, { container: { pad: [0, 0, 2, 2] }, justify: 'space-between', "data-testid": testIds.root, alignItems: 'center', children: [onExpandAll && (_jsxs(Button, { "aria-label": t('expand_steps'), "data-testid": testIds.expandAll, onClick: onExpandAll, children: [_jsx(Icon, { name: 'caret-down' }), t('expand_all')] })), onCollapseAll && (_jsxs(Button, { "aria-label": t('collapse_steps'), "data-testid": testIds.collapseAll, onClick: onCollapseAll, children: [_jsx(Icon, { name: `caret-${rtl ? 'left' : 'right'}` }), t('collapse_all')] })), onGenerateCommentsUsingGenAI && (_jsx(StyledAIButton, { label: t('generate_comments'), variant: 'secondary', onClick: onGenerateCommentsUsingGenAI, "data-testid": testIds.generateComments }))] }), _jsx(StyledBaseTree, { ref: treeRef, testId: testIds.steps, nodes: indexedNodes, nodeRenderer: NodeRenderer })] }) }));
111
+ });
112
+ export default withTestIds(Automation, getAutomationTestIds);
113
+ //# sourceMappingURL=Automation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.js","sourceRoot":"","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,CAAC,SAAS,EAC9B,OAAO,EAAE,WAAW,aAEpB,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,EACzB,CAAC,CAAC,YAAY,CAAC,IACT,CACV,EAEA,aAAa,IAAI,CAChB,MAAC,MAAM,kBACO,CAAC,CAAC,gBAAgB,CAAC,iBAClB,OAAO,CAAC,WAAW,EAChC,OAAO,EAAE,aAAa,aAEtB,KAAC,IAAI,IAAC,IAAI,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,GAAI,EAChD,CAAC,CAAC,cAAc,CAAC,IACX,CACV,EAEA,4BAA4B,IAAI,CAC/B,KAAC,cAAc,IACb,KAAK,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAC7B,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,4BAA4B,iBACxB,OAAO,CAAC,gBAAgB,GACrC,CACH,IACI,EAEP,KAAC,cAAc,IACb,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,OAAO,CAAC,KAAK,EACrB,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,YAAY,GAC1B,IACe,GACQ,CAC9B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { useRef, useState, useEffect, useMemo, forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport {\n Flex,\n Button,\n Icon,\n useTestIds,\n withTestIds,\n useDirection,\n useEvent,\n useI18n,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type { TreeProps, ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\nimport * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\n\nimport RuleStep from './RuleStep';\nimport { getAutomationTestIds } from './Automation.test-ids';\nimport { automationTreeHelpers } from './Automation.utils';\nimport { StyledAIButton, StyledAutomation, StyledBaseTree } from './Automation.styles';\nimport type { AutomationProps, RuleStepTreeNode } from './Automation.types';\nimport AutomationContext from './AutomationContext';\n\nregisterIcon(caretDownIcon, caretLeftIcon, caretRightIcon);\n\nconst NodeRenderer: TreeProps<RuleStepTreeNode>['nodeRenderer'] = ({ subTree, ...restProps }) => {\n return (\n <>\n <RuleStep {...restProps} />\n {subTree}\n </>\n );\n};\n\nconst Automation: ForwardRefForwardPropsComponent<AutomationProps> = forwardRef(\n ({\n testId,\n nodes,\n onExpandAll,\n onCollapseAll,\n focusedNodeId,\n onGenerateCommentsUsingGenAI\n }: PropsWithoutRef<AutomationProps>) => {\n const t = useI18n();\n const { rtl } = useDirection();\n const testIds = useTestIds(testId, getAutomationTestIds);\n\n const treeRef = useRef<HTMLDivElement>(null);\n\n const [focusedNode, setFocusedNode] = useState<RuleStepTreeNode['stepId']>('');\n const [focusInsideNode, setFocusInsideNode] = useState(false);\n const [focusInsideTree, setFocusInsideTree] = useState(false);\n\n // handle key strokes on tree\n const handlekeyDown = (e: KeyboardEvent) => {\n if (['Enter', 'ArrowDown', 'ArrowUp'].includes(e.key) && focusInsideNode) {\n return;\n }\n switch (e.key) {\n case 'ArrowDown': {\n const nextNode = automationTreeHelpers.getNextNode(nodes, focusedNode);\n setFocusedNode(nextNode.stepId);\n break;\n }\n case 'ArrowUp': {\n const previousNode = automationTreeHelpers.getPreviousNode(nodes, focusedNode);\n setFocusedNode(previousNode.stepId);\n break;\n }\n case 'Enter': {\n setFocusInsideNode(true);\n break;\n }\n case 'Escape': {\n if (focusInsideNode) {\n const currentFocussedNodeId = document.activeElement\n ?.closest('[role=\"treeitem\"]')\n ?.getAttribute('id');\n if (currentFocussedNodeId) {\n setFocusedNode(currentFocussedNodeId);\n }\n setFocusInsideNode(false);\n }\n\n break;\n }\n default:\n break;\n }\n };\n\n // handle focus movements in and out of tree\n const handleFocusEvent = (e: FocusEvent) => {\n switch (e.type) {\n case 'focusin': {\n if (!focusedNode) {\n setFocusedNode(nodes[0].stepId);\n }\n if (!focusInsideTree) {\n setFocusInsideTree(true);\n }\n\n break;\n }\n case 'focusout': {\n if (focusInsideTree) {\n setFocusInsideTree(false);\n }\n break;\n }\n default:\n break;\n }\n };\n\n const handleClick = (e: Event) => {\n const currentNodeId =\n e.target instanceof Element\n ? e.target.closest('[role=\"treeitem\"]')?.getAttribute('id')\n : null;\n if (focusInsideTree && !focusInsideNode && currentNodeId) {\n setFocusInsideNode(true);\n setFocusedNode(currentNodeId);\n }\n };\n\n // event handlers for focus management.\n useEvent('keydown', handlekeyDown, { target: treeRef });\n useEvent('focusin', handleFocusEvent, { target: treeRef });\n useEvent('focusout', handleFocusEvent, { target: treeRef });\n useEvent('click', handleClick, { target: treeRef });\n\n // To capture focusNode from story\n useEffect(() => {\n if (focusedNodeId) {\n setFocusInsideNode(false);\n setFocusedNode(focusedNodeId);\n }\n }, [focusedNodeId]);\n\n const indexedNodes = useMemo(() => automationTreeHelpers.calculateStepIndices(nodes), [nodes]);\n\n const automationCtxValue = useMemo(\n () => ({\n focusedNodeId: focusedNode,\n focusInsideNode,\n focusInsideTree,\n firstNodeId: nodes[0]?.stepId\n }),\n [focusedNode, focusInsideNode, focusInsideTree, nodes]\n );\n\n return (\n <AutomationContext.Provider value={automationCtxValue}>\n <StyledAutomation>\n <Flex\n container={{ pad: [0, 0, 2, 2] }}\n justify='space-between'\n data-testid={testIds.root}\n alignItems='center'\n >\n {onExpandAll && (\n <Button\n aria-label={t('expand_steps')}\n data-testid={testIds.expandAll}\n onClick={onExpandAll}\n >\n <Icon name='caret-down' />\n {t('expand_all')}\n </Button>\n )}\n\n {onCollapseAll && (\n <Button\n aria-label={t('collapse_steps')}\n data-testid={testIds.collapseAll}\n onClick={onCollapseAll}\n >\n <Icon name={`caret-${rtl ? 'left' : 'right'}`} />\n {t('collapse_all')}\n </Button>\n )}\n\n {onGenerateCommentsUsingGenAI && (\n <StyledAIButton\n label={t('generate_comments')}\n variant='secondary'\n onClick={onGenerateCommentsUsingGenAI}\n data-testid={testIds.generateComments}\n />\n )}\n </Flex>\n\n <StyledBaseTree\n ref={treeRef}\n testId={testIds.steps}\n nodes={indexedNodes}\n nodeRenderer={NodeRenderer}\n />\n </StyledAutomation>\n </AutomationContext.Provider>\n );\n }\n);\n\nexport default withTestIds(Automation, getAutomationTestIds);\n"]}
@@ -0,0 +1,12 @@
1
+ export declare const StyledContainer: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").CardProps>, import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const StyledSummary: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").TextProps>, import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const StyledContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const StyledErrorIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, import("styled-components").DefaultTheme, {}, never>;
5
+ export declare const StyledComment: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").TextProps>, import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const StyledStepHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const StyledBaseTree: import("styled-components").StyledComponent<(<T extends import("@pega/cosmos-react-core").TreeNode = import("@pega/cosmos-react-core").TreeNode>(props: import("@pega/cosmos-react-core").TreeProps<T> & import("@pega/cosmos-react-core").ForwardProps) => JSX.Element | null) & {
8
+ getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly []>;
9
+ }, import("styled-components").DefaultTheme, {}, never>;
10
+ export declare const StyledAIButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<import("@pega/cosmos-react-core").AIButtonProps> & import("react").RefAttributes<HTMLButtonElement>>, import("styled-components").DefaultTheme, {}, never>;
11
+ export declare const StyledAutomation: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
12
+ //# sourceMappingURL=Automation.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/Automation.styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe,kNAiB1B,CAAC;AAIH,eAAO,MAAM,aAAa,kNAEzB,CAAC;AAIF,eAAO,MAAM,aAAa,yGAKxB,CAAC;AAIH,eAAO,MAAM,eAAe,0LAI1B,CAAC;AAIH,eAAO,MAAM,aAAa,kNAIxB,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGAG5B,CAAC;AAMF,eAAO,MAAM,cAAc;2BAAxB,CAAC;uDAWF,CAAC;AAIH,eAAO,MAAM,cAAc,kRAI1B,CAAC;AAIF,eAAO,MAAM,gBAAgB,yGAI5B,CAAC"}
@@ -0,0 +1,68 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { Card, Text, Tree, Icon, defaultThemeProp, AIButton } from '@pega/cosmos-react-core';
3
+ import { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';
4
+ import { ellipsisOverflow } from '@pega/cosmos-react-core/lib/styles/mixins';
5
+ // Rule step styles
6
+ export const StyledContainer = styled(Card)(({ theme: { base: { shadow, palette: { 'border-line': borderLine } } } }) => {
7
+ return css `
8
+ border-bottom: 0.0625rem solid ${borderLine};
9
+
10
+ &:focus,
11
+ &:focus-visible {
12
+ box-shadow: inset ${shadow['focus-solid']};
13
+ outline: none;
14
+ }
15
+ `;
16
+ });
17
+ StyledContainer.defaultProps = defaultThemeProp;
18
+ export const StyledSummary = styled(Text) `
19
+ ${ellipsisOverflow}
20
+ `;
21
+ StyledSummary.defaultProps = defaultThemeProp;
22
+ export const StyledContent = styled.div(({ theme }) => {
23
+ return css `
24
+ position: relative;
25
+ padding: ${theme.base.spacing};
26
+ `;
27
+ });
28
+ StyledContent.defaultProps = defaultThemeProp;
29
+ export const StyledErrorIcon = styled(Icon)(({ theme }) => {
30
+ return css `
31
+ color: ${theme.base.palette.urgent};
32
+ `;
33
+ });
34
+ StyledErrorIcon.defaultProps = defaultThemeProp;
35
+ export const StyledComment = styled(StyledSummary)(({ theme }) => {
36
+ return css `
37
+ padding-inline-start: calc(4 * ${theme.base.spacing});
38
+ `;
39
+ });
40
+ StyledComment.defaultProps = defaultThemeProp;
41
+ export const StyledStepHeader = styled.div `
42
+ min-width: 0;
43
+ flex: 1 1 auto;
44
+ `;
45
+ StyledStepHeader.defaultProps = defaultThemeProp;
46
+ // Automation wrapper styles
47
+ export const StyledBaseTree = styled(Tree)(({ theme: { base: { spacing } } }) => {
48
+ return css `
49
+ &,
50
+ & ul {
51
+ padding-inline-start: calc(2 * ${spacing});
52
+ }
53
+ `;
54
+ });
55
+ StyledBaseTree.defaultProps = defaultThemeProp;
56
+ export const StyledAIButton = styled(AIButton) `
57
+ && {
58
+ margin-inline-start: auto;
59
+ }
60
+ `;
61
+ StyledAIButton.defaultProps = defaultThemeProp;
62
+ export const StyledAutomation = styled.div `
63
+ ${StyledCardContent}:has(&&&) {
64
+ padding: unset;
65
+ }
66
+ `;
67
+ StyledAutomation.defaultProps = defaultThemeProp;
68
+ //# sourceMappingURL=Automation.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.styles.js","sourceRoot":"","sources":["../../../src/components/Automation/Automation.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7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A;qCACyB,KAAK,CAAC,IAAI,CAAC,OAAO;GACpD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGzC,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,4BAA4B;AAE5B,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAC1C,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;;uCAG2B,OAAO;;GAE3C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;;;CAI7C,CAAC;AAEF,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,iBAAiB;;;CAGpB,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { Card, Text, Tree, Icon, defaultThemeProp, AIButton } from '@pega/cosmos-react-core';\nimport { StyledCardContent } from '@pega/cosmos-react-core/lib/components/Card/CardContent';\nimport { ellipsisOverflow } from '@pega/cosmos-react-core/lib/styles/mixins';\n\n// Rule step styles\n\nexport const StyledContainer = styled(Card)(({\n theme: {\n base: {\n shadow,\n palette: { 'border-line': borderLine }\n }\n }\n}) => {\n return css`\n border-bottom: 0.0625rem solid ${borderLine};\n\n &:focus,\n &:focus-visible {\n box-shadow: inset ${shadow['focus-solid']};\n outline: none;\n }\n `;\n});\n\nStyledContainer.defaultProps = defaultThemeProp;\n\nexport const StyledSummary = styled(Text)`\n ${ellipsisOverflow}\n`;\n\nStyledSummary.defaultProps = defaultThemeProp;\n\nexport const StyledContent = styled.div(({ theme }) => {\n return css`\n position: relative;\n padding: ${theme.base.spacing};\n `;\n});\n\nStyledContent.defaultProps = defaultThemeProp;\n\nexport const StyledErrorIcon = styled(Icon)(({ theme }) => {\n return css`\n color: ${theme.base.palette.urgent};\n `;\n});\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledComment = styled(StyledSummary)(({ theme }) => {\n return css`\n padding-inline-start: calc(4 * ${theme.base.spacing});\n `;\n});\n\nStyledComment.defaultProps = defaultThemeProp;\n\nexport const StyledStepHeader = styled.div`\n min-width: 0;\n flex: 1 1 auto;\n`;\n\nStyledStepHeader.defaultProps = defaultThemeProp;\n\n// Automation wrapper styles\n\nexport const StyledBaseTree = styled(Tree)(({\n theme: {\n base: { spacing }\n }\n}) => {\n return css`\n &,\n & ul {\n padding-inline-start: calc(2 * ${spacing});\n }\n `;\n});\n\nStyledBaseTree.defaultProps = defaultThemeProp;\n\nexport const StyledAIButton = styled(AIButton)`\n && {\n margin-inline-start: auto;\n }\n`;\n\nStyledAIButton.defaultProps = defaultThemeProp;\n\nexport const StyledAutomation = styled.div`\n ${StyledCardContent}:has(&&&) {\n padding: unset;\n }\n`;\n\nStyledAutomation.defaultProps = defaultThemeProp;\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const getAutomationTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["expand-all", "collapse-all", "generate-comments", "steps"]>;
2
+ export declare const getRuleStepTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["expand-collapse-button", "error-icon", "step-number", "switch-menu", "summary", "summary-tooltip", "comment", "comment-tooltip", "add-step-menu", "step-actions", "content"]>;
3
+ //# sourceMappingURL=Automation.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/Automation.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,iMAKtB,CAAC;AAEZ,eAAO,MAAM,kBAAkB,mTAYpB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { createTestIds } from '@pega/cosmos-react-core';
2
+ export const getAutomationTestIds = createTestIds('automation', [
3
+ 'expand-all',
4
+ 'collapse-all',
5
+ 'generate-comments',
6
+ 'steps'
7
+ ]);
8
+ export const getRuleStepTestIds = createTestIds('rule-step', [
9
+ 'expand-collapse-button',
10
+ 'error-icon',
11
+ 'step-number',
12
+ 'switch-menu',
13
+ 'summary',
14
+ 'summary-tooltip',
15
+ 'comment',
16
+ 'comment-tooltip',
17
+ 'add-step-menu',
18
+ 'step-actions',
19
+ 'content'
20
+ ]);
21
+ //# sourceMappingURL=Automation.test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.test-ids.js","sourceRoot":"","sources":["../../../src/components/Automation/Automation.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,YAAY,EAAE;IAC9D,YAAY;IACZ,cAAc;IACd,mBAAmB;IACnB,OAAO;CACC,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,WAAW,EAAE;IAC3D,wBAAwB;IACxB,YAAY;IACZ,aAAa;IACb,aAAa;IACb,SAAS;IACT,iBAAiB;IACjB,SAAS;IACT,iBAAiB;IACjB,eAAe;IACf,cAAc;IACd,SAAS;CACD,CAAC,CAAC","sourcesContent":["import { createTestIds } from '@pega/cosmos-react-core';\n\nexport const getAutomationTestIds = createTestIds('automation', [\n 'expand-all',\n 'collapse-all',\n 'generate-comments',\n 'steps'\n] as const);\n\nexport const getRuleStepTestIds = createTestIds('rule-step', [\n 'expand-collapse-button',\n 'error-icon',\n 'step-number',\n 'switch-menu',\n 'summary',\n 'summary-tooltip',\n 'comment',\n 'comment-tooltip',\n 'add-step-menu',\n 'step-actions',\n 'content'\n] as const);\n"]}
@@ -0,0 +1,95 @@
1
+ import type { ReactNode, Ref } from 'react';
2
+ import type { MenuProps, MenuButtonProps, BaseProps, NoChildrenProp, TestIdProp, Action, TreeNode, TreeProps } from '@pega/cosmos-react-core';
3
+ import type { IconTileProps } from '../IconTile';
4
+ export declare const AutomationActions: {
5
+ readonly ActionSet: "ActionSet";
6
+ readonly ActionSetRow: "ActionSetRow";
7
+ readonly ActionWhen: "ActionWhen";
8
+ readonly ActionAppend: "ActionAppend";
9
+ readonly ActionCall: "ActionCall";
10
+ readonly ActionCreate: "ActionCreate";
11
+ readonly ActionForEach: "ActionForEach";
12
+ readonly ActionExit: "ActionExit";
13
+ readonly ActionExitForEach: "ActionExitForEach";
14
+ readonly ActionExitAutomation: "ActionExitAutomation";
15
+ readonly ActionExitIteration: "ActionExitIteration";
16
+ readonly ActionReturn: "ActionReturn";
17
+ readonly ActionRemove: "ActionRemove";
18
+ readonly ActionRemoveRow: "ActionRemoveRow";
19
+ readonly ActionErrorHandler: "ActionErrorHandler";
20
+ };
21
+ export type AutomationActionType = (typeof AutomationActions)[keyof typeof AutomationActions];
22
+ interface StepMenu {
23
+ items: MenuProps['items'];
24
+ loading?: MenuProps['loading'];
25
+ onItemClick?: (itemId: AutomationActionType, stepId: string, stepNumber: string) => void;
26
+ }
27
+ export interface StepMenuData {
28
+ menu: StepMenu;
29
+ onClick?: MenuButtonProps['onClick'];
30
+ onKeyDown?: MenuButtonProps['onKeyDown'];
31
+ }
32
+ export interface RuleStepProps extends BaseProps, NoChildrenProp, TestIdProp {
33
+ /** Id of the rulestep */
34
+ stepId: string;
35
+ /** Step number displayed on the step to user */
36
+ stepNumber: string;
37
+ /** Name of the rulestep */
38
+ stepName: AutomationActionType;
39
+ /** Menu for add operations for the rulestep */
40
+ addStepMenu: StepMenuData;
41
+ /** Visual of the rulestep */
42
+ stepVisual?: IconTileProps;
43
+ /** Menu to switch between rules */
44
+ switchMenu?: StepMenuData;
45
+ /** Summary of the rulestep */
46
+ summary?: string;
47
+ /** Comment of the rulestep */
48
+ comment?: string;
49
+ /** Content of the rulestep */
50
+ content?: ReactNode;
51
+ /** Callback to handle expand/collapse of rulestep */
52
+ onExpandCollapse?: (id: RuleStepProps['stepId']) => void;
53
+ /** Secondary actions for the rulestep */
54
+ stepActions?: Action[];
55
+ /** Sets rulestep to expand */
56
+ expanded?: boolean;
57
+ /** Loader for the content */
58
+ loading?: boolean;
59
+ /** If true, mounts the content */
60
+ mountContent?: boolean;
61
+ /** Error state of the rulestep */
62
+ error?: boolean;
63
+ /** Enables readonly mode of the rulestep */
64
+ readOnly?: boolean;
65
+ /** Ref for the rulestep */
66
+ ref?: Ref<HTMLDivElement>;
67
+ }
68
+ export interface RuleStepTreeNode extends TreeNode, RuleStepProps {
69
+ nodes?: RuleStepTreeNode[];
70
+ meta?: Record<string, unknown>;
71
+ }
72
+ export interface RuleStepData {
73
+ Id: RuleStepTreeNode['stepId'];
74
+ Type: AutomationActionType;
75
+ RuleSteps?: RuleStepData[];
76
+ [key: string]: unknown;
77
+ }
78
+ export interface AutomationProps extends TestIdProp, TreeProps<RuleStepTreeNode> {
79
+ /** Expands all the rulesteps */
80
+ onExpandAll?: () => void;
81
+ /** Collapses all the rulesteps */
82
+ onCollapseAll?: () => void;
83
+ /** Generates comments for rulesteps */
84
+ onGenerateCommentsUsingGenAI?: () => void;
85
+ /** Focuses the rulestep that is passed */
86
+ focusedNodeId?: RuleStepTreeNode['stepId'];
87
+ }
88
+ export interface AutomationContextValue {
89
+ focusInsideTree: boolean;
90
+ focusInsideNode: boolean;
91
+ focusedNodeId?: RuleStepTreeNode['stepId'];
92
+ firstNodeId?: RuleStepTreeNode['stepId'];
93
+ }
94
+ export {};
95
+ //# sourceMappingURL=Automation.types.d.ts.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AAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,uCAAuC;IACvC,4BAA4B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1C,0CAA0C;IAC1C,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,18 @@
1
+ export const AutomationActions = {
2
+ ActionSet: 'ActionSet',
3
+ ActionSetRow: 'ActionSetRow',
4
+ ActionWhen: 'ActionWhen',
5
+ ActionAppend: 'ActionAppend',
6
+ ActionCall: 'ActionCall',
7
+ ActionCreate: 'ActionCreate',
8
+ ActionForEach: 'ActionForEach',
9
+ ActionExit: 'ActionExit',
10
+ ActionExitForEach: 'ActionExitForEach',
11
+ ActionExitAutomation: 'ActionExitAutomation',
12
+ ActionExitIteration: 'ActionExitIteration',
13
+ ActionReturn: 'ActionReturn',
14
+ ActionRemove: 'ActionRemove',
15
+ ActionRemoveRow: 'ActionRemoveRow',
16
+ ActionErrorHandler: 'ActionErrorHandler'
17
+ };
18
+ //# sourceMappingURL=Automation.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.types.js","sourceRoot":"","sources":["../../../src/components/Automation/Automation.types.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB;CAChC,CAAC","sourcesContent":["import type { ReactNode, Ref } from 'react';\n\nimport type {\n MenuProps,\n MenuButtonProps,\n BaseProps,\n NoChildrenProp,\n TestIdProp,\n Action,\n TreeNode,\n TreeProps\n} from '@pega/cosmos-react-core';\n\nimport type { IconTileProps } from '../IconTile';\n\nexport const AutomationActions = {\n ActionSet: 'ActionSet',\n ActionSetRow: 'ActionSetRow',\n ActionWhen: 'ActionWhen',\n ActionAppend: 'ActionAppend',\n ActionCall: 'ActionCall',\n ActionCreate: 'ActionCreate',\n ActionForEach: 'ActionForEach',\n ActionExit: 'ActionExit',\n ActionExitForEach: 'ActionExitForEach',\n ActionExitAutomation: 'ActionExitAutomation',\n ActionExitIteration: 'ActionExitIteration',\n ActionReturn: 'ActionReturn',\n ActionRemove: 'ActionRemove',\n ActionRemoveRow: 'ActionRemoveRow',\n ActionErrorHandler: 'ActionErrorHandler'\n} as const;\n\nexport type AutomationActionType = (typeof AutomationActions)[keyof typeof AutomationActions];\n\n// Rule step interfaces\ninterface StepMenu {\n items: MenuProps['items'];\n loading?: MenuProps['loading'];\n onItemClick?: (itemId: AutomationActionType, stepId: string, stepNumber: string) => void;\n}\n\nexport interface StepMenuData {\n menu: StepMenu;\n onClick?: MenuButtonProps['onClick'];\n onKeyDown?: MenuButtonProps['onKeyDown'];\n}\n\nexport interface RuleStepProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** Id of the rulestep */\n stepId: string;\n /** Step number displayed on the step to user */\n stepNumber: string;\n /** Name of the rulestep */\n stepName: AutomationActionType;\n /** Menu for add operations for the rulestep */\n addStepMenu: StepMenuData;\n /** Visual of the rulestep */\n stepVisual?: IconTileProps;\n /** Menu to switch between rules */\n switchMenu?: StepMenuData;\n /** Summary of the rulestep */\n summary?: string;\n /** Comment of the rulestep */\n comment?: string;\n /** Content of the rulestep */\n content?: ReactNode;\n /** Callback to handle expand/collapse of rulestep */\n onExpandCollapse?: (id: RuleStepProps['stepId']) => void;\n /** Secondary actions for the rulestep */\n stepActions?: Action[];\n /** Sets rulestep to expand */\n expanded?: boolean;\n /** Loader for the content */\n loading?: boolean;\n /** If true, mounts the content */\n mountContent?: boolean;\n /** Error state of the rulestep */\n error?: boolean;\n /** Enables readonly mode of the rulestep */\n readOnly?: boolean;\n /** Ref for the rulestep */\n ref?: Ref<HTMLDivElement>;\n}\n\n// Automation Wrapper interfaces\nexport interface RuleStepTreeNode extends TreeNode, RuleStepProps {\n nodes?: RuleStepTreeNode[];\n meta?: Record<string, unknown>;\n}\n\nexport interface RuleStepData {\n Id: RuleStepTreeNode['stepId'];\n Type: AutomationActionType;\n RuleSteps?: RuleStepData[];\n [key: string]: unknown;\n}\n\nexport interface AutomationProps extends TestIdProp, TreeProps<RuleStepTreeNode> {\n /** Expands all the rulesteps */\n onExpandAll?: () => void;\n /** Collapses all the rulesteps */\n onCollapseAll?: () => void;\n /** Generates comments for rulesteps */\n onGenerateCommentsUsingGenAI?: () => void;\n /** Focuses the rulestep that is passed */\n focusedNodeId?: RuleStepTreeNode['stepId'];\n}\n\nexport interface AutomationContextValue {\n focusInsideTree: boolean;\n focusInsideNode: boolean;\n focusedNodeId?: RuleStepTreeNode['stepId'];\n firstNodeId?: RuleStepTreeNode['stepId'];\n}\n"]}
@@ -0,0 +1,109 @@
1
+ import type { RuleStepData, RuleStepTreeNode, AutomationActionType } from './Automation.types';
2
+ export declare const automationTreeHelpers: {
3
+ /**
4
+ * Get the index of a node
5
+ * @param nodes Rulesteps
6
+ * @param id Id of required node
7
+ * @returns Index of the node in list of nodes
8
+ */
9
+ getNodeIndex(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"]): number;
10
+ /**
11
+ * Add a node
12
+ * @param nodes Current tree nodes
13
+ * @param index Index in list where new node should be appended.
14
+ * @param newNode New node
15
+ * @returns Updated node list
16
+ */
17
+ addNode(nodes: RuleStepTreeNode[], index: number, newNode: RuleStepTreeNode): RuleStepTreeNode[];
18
+ /**
19
+ * Add a step before a node.
20
+ * @param nodes Current tree nodes
21
+ * @param id Id of node clicked
22
+ * @param newNode New node
23
+ * @returns Updated tree
24
+ */
25
+ addStepBefore(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"], newNode: RuleStepTreeNode): RuleStepTreeNode[];
26
+ /**
27
+ * Add step after a node.
28
+ * @param nodes Current tree nodes
29
+ * @param id Id of node clicked
30
+ * @param newNode New node
31
+ * @returns Updated tree
32
+ */
33
+ addStepAfter(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"], newNode: RuleStepTreeNode): RuleStepTreeNode[];
34
+ /**
35
+ * Add sub-step on a node.
36
+ * @param nodes Current tree nodes
37
+ * @param id Id of node clicked
38
+ * @param newNode New node
39
+ * @returns Updated tree
40
+ */
41
+ addSubStep(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"], newNode: RuleStepTreeNode): RuleStepTreeNode[];
42
+ /**
43
+ * Delete the node.
44
+ * @param nodes Current tree nodes
45
+ * @param id Id of node clicked
46
+ * @returns Updated tree
47
+ */
48
+ deleteStep(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"]): RuleStepTreeNode[];
49
+ /**
50
+ * Toggle expand/collapse of node.
51
+ * @param nodes Current tree nodes
52
+ * @param id Id of node clicked
53
+ * @param expand Option to set expand collapse if user specifies explicitly
54
+ * @returns Updated tree
55
+ */
56
+ toggleExpandCollapse(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"]): RuleStepTreeNode[];
57
+ /**
58
+ * Change step type of a node.
59
+ * @param nodes Current tree nodes
60
+ * @param id Id of node clicked
61
+ * @param stepName Name of step,
62
+ * @param stepVisual Visual of step
63
+ * @returns Updated tree
64
+ */
65
+ changeStep(nodes: RuleStepTreeNode[], id: RuleStepTreeNode["id"], stepName: RuleStepTreeNode["stepName"], stepVisual: RuleStepTreeNode["stepVisual"]): RuleStepTreeNode[];
66
+ /**
67
+ * Expand all nodes of tree.
68
+ * @param nodes Current tree nodes
69
+ * @returns Updated tree
70
+ */
71
+ expandAll(nodes: RuleStepTreeNode[]): RuleStepTreeNode[];
72
+ /**
73
+ * Collapse all nodes of tree.
74
+ * @param nodes Current tree nodes
75
+ * @returns Updated tree
76
+ */
77
+ collapseAll(nodes: RuleStepTreeNode[]): RuleStepTreeNode[];
78
+ /**
79
+ * Calculate the step numbers and append to tree
80
+ * @param nodes Current tree nodes
81
+ * @param prefix Helper prefix text
82
+ * @param depth Depth of node
83
+ * @returns Updated tree with step numbers
84
+ */
85
+ calculateStepIndices(nodes: RuleStepTreeNode[], prefix?: string, depth?: number): RuleStepTreeNode[];
86
+ /**
87
+ *
88
+ * @param nodes Rule steps
89
+ * @param stepId Current step id
90
+ * @returns Next node.
91
+ */
92
+ getNextNode(nodes: RuleStepTreeNode[], stepId: RuleStepTreeNode["stepId"]): RuleStepTreeNode;
93
+ /**
94
+ *
95
+ * @param nodes Rule steps
96
+ * @param stepId Current step id
97
+ * @returns Previous node.
98
+ */
99
+ getPreviousNode(nodes: RuleStepTreeNode[], stepId: RuleStepTreeNode["stepId"]): RuleStepTreeNode;
100
+ /**
101
+ * Converts rule step data to AutomationWrapperProps
102
+ * @param ruleStepData Raw rule data
103
+ * @param fn Helper function to create node.
104
+ * @returns Tree in AutomationWrapperProps structure.
105
+ */
106
+ constructRuleStepTree(ruleStepData: RuleStepData[], fn: (stepId: RuleStepTreeNode["stepId"], stepName: AutomationActionType) => RuleStepTreeNode): RuleStepTreeNode[];
107
+ };
108
+ export declare const isValidAutomationActionType: (value: string) => value is AutomationActionType;
109
+ //# sourceMappingURL=Automation.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.utils.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/Automation.utils.ts"],"names":[],"mappings":"AAGA,OAA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