@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,208 @@
1
+ import { treeHelpers } from '@pega/cosmos-react-core';
2
+ import { AutomationActions } from './Automation.types';
3
+ export const automationTreeHelpers = {
4
+ /**
5
+ * Get the index of a node
6
+ * @param nodes Rulesteps
7
+ * @param id Id of required node
8
+ * @returns Index of the node in list of nodes
9
+ */
10
+ getNodeIndex(nodes, id) {
11
+ return (nodes ?? []).findIndex(n => n.id === id);
12
+ },
13
+ /**
14
+ * Add a node
15
+ * @param nodes Current tree nodes
16
+ * @param index Index in list where new node should be appended.
17
+ * @param newNode New node
18
+ * @returns Updated node list
19
+ */
20
+ addNode(nodes, index, newNode) {
21
+ return [...(nodes ?? []).slice(0, index), newNode, ...(nodes ?? []).slice(index)];
22
+ },
23
+ /**
24
+ * Add a step before a node.
25
+ * @param nodes Current tree nodes
26
+ * @param id Id of node clicked
27
+ * @param newNode New node
28
+ * @returns Updated tree
29
+ */
30
+ addStepBefore(nodes, id, newNode) {
31
+ const parentNode = treeHelpers.getParentNode([...nodes], id);
32
+ if (!parentNode) {
33
+ return this.addNode(nodes, this.getNodeIndex(nodes, id), newNode);
34
+ }
35
+ return treeHelpers.mapNode([...nodes], parentNode.id, node => {
36
+ return {
37
+ ...node,
38
+ nodes: this.addNode(node.nodes || [], this.getNodeIndex(node.nodes || [], id), newNode)
39
+ };
40
+ });
41
+ },
42
+ /**
43
+ * Add step after a node.
44
+ * @param nodes Current tree nodes
45
+ * @param id Id of node clicked
46
+ * @param newNode New node
47
+ * @returns Updated tree
48
+ */
49
+ addStepAfter(nodes, id, newNode) {
50
+ const parentNode = treeHelpers.getParentNode([...nodes], id);
51
+ if (!parentNode) {
52
+ return this.addNode(nodes, this.getNodeIndex(nodes, id) + 1, newNode);
53
+ }
54
+ return treeHelpers.mapNode([...nodes], parentNode.id, node => {
55
+ return {
56
+ ...node,
57
+ nodes: this.addNode(node.nodes || [], this.getNodeIndex(node.nodes || [], id) + 1, newNode)
58
+ };
59
+ });
60
+ },
61
+ /**
62
+ * Add sub-step on a node.
63
+ * @param nodes Current tree nodes
64
+ * @param id Id of node clicked
65
+ * @param newNode New node
66
+ * @returns Updated tree
67
+ */
68
+ addSubStep(nodes, id, newNode) {
69
+ return treeHelpers.appendTo([...nodes], id, [newNode]);
70
+ },
71
+ /**
72
+ * Delete the node.
73
+ * @param nodes Current tree nodes
74
+ * @param id Id of node clicked
75
+ * @returns Updated tree
76
+ */
77
+ deleteStep(nodes, id) {
78
+ const parentNode = treeHelpers.getParentNode([...nodes], id);
79
+ if (!parentNode) {
80
+ return nodes.filter(node => node.id !== id);
81
+ }
82
+ return treeHelpers.mapNode([...nodes], parentNode.id, node => ({
83
+ ...node,
84
+ nodes: [...(node.nodes ?? [])].filter(n => n.id !== id)
85
+ }));
86
+ },
87
+ /**
88
+ * Toggle expand/collapse of node.
89
+ * @param nodes Current tree nodes
90
+ * @param id Id of node clicked
91
+ * @param expand Option to set expand collapse if user specifies explicitly
92
+ * @returns Updated tree
93
+ */
94
+ toggleExpandCollapse(nodes, id) {
95
+ return treeHelpers.mapNode([...nodes], id, node => ({
96
+ ...node,
97
+ expanded: !node.expanded,
98
+ mountContent: true
99
+ }));
100
+ },
101
+ /**
102
+ * Change step type of a node.
103
+ * @param nodes Current tree nodes
104
+ * @param id Id of node clicked
105
+ * @param stepName Name of step,
106
+ * @param stepVisual Visual of step
107
+ * @returns Updated tree
108
+ */
109
+ changeStep(nodes, id, stepName, stepVisual) {
110
+ return treeHelpers.mapNode([...nodes], id, node => ({
111
+ ...node,
112
+ stepName,
113
+ stepVisual
114
+ }));
115
+ },
116
+ /**
117
+ * Expand all nodes of tree.
118
+ * @param nodes Current tree nodes
119
+ * @returns Updated tree
120
+ */
121
+ expandAll(nodes) {
122
+ return treeHelpers.mapTree([...nodes], node => ({
123
+ ...node,
124
+ expanded: true,
125
+ mountContent: true
126
+ }));
127
+ },
128
+ /**
129
+ * Collapse all nodes of tree.
130
+ * @param nodes Current tree nodes
131
+ * @returns Updated tree
132
+ */
133
+ collapseAll(nodes) {
134
+ return treeHelpers.mapTree([...nodes], node => ({
135
+ ...node,
136
+ expanded: false
137
+ }));
138
+ },
139
+ /**
140
+ * Calculate the step numbers and append to tree
141
+ * @param nodes Current tree nodes
142
+ * @param prefix Helper prefix text
143
+ * @param depth Depth of node
144
+ * @returns Updated tree with step numbers
145
+ */
146
+ calculateStepIndices(nodes, prefix = '', depth = 0) {
147
+ return nodes?.map((node, index) => {
148
+ let currentPrefix = prefix ? `${prefix}.${index + 1}` : `${index + 1}`;
149
+ if (node.stepName === AutomationActions.ActionErrorHandler) {
150
+ const segments = currentPrefix.split('.');
151
+ segments[segments.length - 1] = 'Err';
152
+ currentPrefix = segments.join('.');
153
+ }
154
+ return {
155
+ ...node,
156
+ stepNumber: currentPrefix,
157
+ nodes: node.nodes ? this.calculateStepIndices(node.nodes, currentPrefix, depth + 1) : []
158
+ };
159
+ });
160
+ },
161
+ /**
162
+ *
163
+ * @param nodes Rule steps
164
+ * @param stepId Current step id
165
+ * @returns Next node.
166
+ */
167
+ getNextNode(nodes, stepId) {
168
+ const nodelist = treeHelpers.flatten(nodes);
169
+ const currentNodeIndex = this.getNodeIndex(nodelist, stepId);
170
+ return currentNodeIndex === nodelist.length - 1
171
+ ? nodelist[nodelist.length - 1]
172
+ : nodelist[currentNodeIndex + 1];
173
+ },
174
+ /**
175
+ *
176
+ * @param nodes Rule steps
177
+ * @param stepId Current step id
178
+ * @returns Previous node.
179
+ */
180
+ getPreviousNode(nodes, stepId) {
181
+ const nodelist = treeHelpers.flatten(nodes);
182
+ const currentNodeIndex = this.getNodeIndex(nodelist, stepId);
183
+ return currentNodeIndex === 0 ? nodelist[0] : nodelist[currentNodeIndex - 1];
184
+ },
185
+ /**
186
+ * Converts rule step data to AutomationWrapperProps
187
+ * @param ruleStepData Raw rule data
188
+ * @param fn Helper function to create node.
189
+ * @returns Tree in AutomationWrapperProps structure.
190
+ */
191
+ constructRuleStepTree(ruleStepData, fn) {
192
+ if (!ruleStepData || ruleStepData.length === 0) {
193
+ return [];
194
+ }
195
+ return ruleStepData.map(({ Id, Type, RuleSteps, ...rest }) => {
196
+ return {
197
+ ...fn(Id, Type),
198
+ meta: { Id, Type, ...rest },
199
+ nodes: this.constructRuleStepTree(Array.isArray(RuleSteps) ? RuleSteps : [], fn)
200
+ };
201
+ });
202
+ }
203
+ };
204
+ const AUTOMATION_ACTION_TYPES_SET = new Set(Object.values(AutomationActions));
205
+ export const isValidAutomationActionType = (value) => {
206
+ return AUTOMATION_ACTION_TYPES_SET.has(value);
207
+ };
208
+ //# sourceMappingURL=Automation.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automation.utils.js","sourceRoot":"","sources":["../../../src/components/Automation/Automation.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;;;;;OAKG;IACH,YAAY,CAAC,KAAyB,EAAE,EAA0B;QAChE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,KAAyB,EAAE,KAAa,EAAE,OAAyB;QACzE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACpF,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CACX,KAAyB,EACzB,EAA0B,EAC1B,OAAyB;QAEzB,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,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,GAAG,IAAI,EAAE;gBAC3B,KAAK,EAAE,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;aACjF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,KAAa,EAAiC,EAAE;IAC1F,OAAO,2BAA2B,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { treeHelpers } from '@pega/cosmos-react-core';\n\nimport { AutomationActions } from './Automation.types';\nimport type { RuleStepData, RuleStepTreeNode, AutomationActionType } from './Automation.types';\n\nexport const automationTreeHelpers = {\n /**\n * Get the index of a node\n * @param nodes Rulesteps\n * @param id Id of required node\n * @returns Index of the node in list of nodes\n */\n getNodeIndex(nodes: RuleStepTreeNode[], id: RuleStepTreeNode['id']): number {\n return (nodes ?? []).findIndex(n => n.id === id);\n },\n\n /**\n * Add a node\n * @param nodes Current tree nodes\n * @param index Index in list where new node should be appended.\n * @param newNode New node\n * @returns Updated node list\n */\n addNode(nodes: RuleStepTreeNode[], index: number, newNode: RuleStepTreeNode): RuleStepTreeNode[] {\n return [...(nodes ?? []).slice(0, index), newNode, ...(nodes ?? []).slice(index)];\n },\n\n /**\n * Add a step before a node.\n * @param nodes Current tree nodes\n * @param id Id of node clicked\n * @param newNode New node\n * @returns Updated tree\n */\n addStepBefore(\n nodes: RuleStepTreeNode[],\n id: RuleStepTreeNode['id'],\n newNode: RuleStepTreeNode\n ): RuleStepTreeNode[] {\n const parentNode = treeHelpers.getParentNode([...nodes], id);\n if (!parentNode) {\n return this.addNode(nodes, this.getNodeIndex(nodes, id), newNode);\n }\n return treeHelpers.mapNode([...nodes], parentNode.id, node => {\n return {\n ...node,\n nodes: this.addNode(node.nodes || [], this.getNodeIndex(node.nodes || [], id), newNode)\n };\n });\n },\n\n /**\n * Add step after a node.\n * @param nodes Current tree nodes\n * @param id Id of node clicked\n * @param newNode New node\n * @returns Updated tree\n */\n addStepAfter(\n nodes: RuleStepTreeNode[],\n id: RuleStepTreeNode['id'],\n newNode: RuleStepTreeNode\n ): RuleStepTreeNode[] {\n const parentNode = treeHelpers.getParentNode([...nodes], id);\n if (!parentNode) {\n return this.addNode(nodes, this.getNodeIndex(nodes, id) + 1, newNode);\n }\n return treeHelpers.mapNode([...nodes], parentNode.id, node => {\n return {\n ...node,\n nodes: this.addNode(node.nodes || [], this.getNodeIndex(node.nodes || [], id) + 1, newNode)\n };\n });\n },\n\n /**\n * Add sub-step on a node.\n * @param nodes Current tree nodes\n * @param id Id of node clicked\n * @param newNode New node\n * @returns Updated tree\n */\n addSubStep(\n nodes: RuleStepTreeNode[],\n id: RuleStepTreeNode['id'],\n newNode: RuleStepTreeNode\n ): RuleStepTreeNode[] {\n return treeHelpers.appendTo([...nodes], id, [newNode]);\n },\n\n /**\n * Delete the node.\n * @param nodes Current tree nodes\n * @param id Id of node clicked\n * @returns Updated tree\n */\n deleteStep(nodes: RuleStepTreeNode[], id: RuleStepTreeNode['id']): RuleStepTreeNode[] {\n const parentNode = treeHelpers.getParentNode([...nodes], id);\n if (!parentNode) {\n return nodes.filter(node => node.id !== id);\n }\n return treeHelpers.mapNode([...nodes], parentNode.id, node => ({\n ...node,\n nodes: [...(node.nodes ?? [])].filter(n => n.id !== id)\n }));\n },\n\n /**\n * Toggle expand/collapse of node.\n * @param nodes Current tree nodes\n * @param id Id of node clicked\n * @param expand Option to set expand collapse if user specifies explicitly\n * @returns Updated tree\n */\n toggleExpandCollapse(nodes: RuleStepTreeNode[], id: RuleStepTreeNode['id']): RuleStepTreeNode[] {\n return treeHelpers.mapNode([...nodes], id, node => ({\n ...node,\n expanded: !node.expanded,\n mountContent: true\n }));\n },\n\n /**\n * Change step type of a node.\n * @param nodes Current tree nodes\n * @param id Id of node clicked\n * @param stepName Name of step,\n * @param stepVisual Visual of step\n * @returns Updated tree\n */\n changeStep(\n nodes: RuleStepTreeNode[],\n id: RuleStepTreeNode['id'],\n stepName: RuleStepTreeNode['stepName'],\n stepVisual: RuleStepTreeNode['stepVisual']\n ): RuleStepTreeNode[] {\n return treeHelpers.mapNode([...nodes], id, node => ({\n ...node,\n stepName,\n stepVisual\n }));\n },\n\n /**\n * Expand all nodes of tree.\n * @param nodes Current tree nodes\n * @returns Updated tree\n */\n expandAll(nodes: RuleStepTreeNode[]): RuleStepTreeNode[] {\n return treeHelpers.mapTree([...nodes], node => ({\n ...node,\n expanded: true,\n mountContent: true\n }));\n },\n\n /**\n * Collapse all nodes of tree.\n * @param nodes Current tree nodes\n * @returns Updated tree\n */\n collapseAll(nodes: RuleStepTreeNode[]): RuleStepTreeNode[] {\n return treeHelpers.mapTree([...nodes], node => ({\n ...node,\n expanded: false\n }));\n },\n\n /**\n * Calculate the step numbers and append to tree\n * @param nodes Current tree nodes\n * @param prefix Helper prefix text\n * @param depth Depth of node\n * @returns Updated tree with step numbers\n */\n calculateStepIndices(\n nodes: RuleStepTreeNode[],\n prefix: string = '',\n depth: number = 0\n ): RuleStepTreeNode[] {\n return nodes?.map((node, index) => {\n let currentPrefix = prefix ? `${prefix}.${index + 1}` : `${index + 1}`;\n if (node.stepName === AutomationActions.ActionErrorHandler) {\n const segments = currentPrefix.split('.');\n segments[segments.length - 1] = 'Err';\n currentPrefix = segments.join('.');\n }\n return {\n ...node,\n stepNumber: currentPrefix,\n nodes: node.nodes ? this.calculateStepIndices(node.nodes, currentPrefix, depth + 1) : []\n };\n });\n },\n\n /**\n *\n * @param nodes Rule steps\n * @param stepId Current step id\n * @returns Next node.\n */\n getNextNode(nodes: RuleStepTreeNode[], stepId: RuleStepTreeNode['stepId']): RuleStepTreeNode {\n const nodelist = treeHelpers.flatten(nodes);\n const currentNodeIndex = this.getNodeIndex(nodelist, stepId);\n return currentNodeIndex === nodelist.length - 1\n ? nodelist[nodelist.length - 1]\n : nodelist[currentNodeIndex + 1];\n },\n\n /**\n *\n * @param nodes Rule steps\n * @param stepId Current step id\n * @returns Previous node.\n */\n getPreviousNode(nodes: RuleStepTreeNode[], stepId: RuleStepTreeNode['stepId']): RuleStepTreeNode {\n const nodelist = treeHelpers.flatten(nodes);\n const currentNodeIndex = this.getNodeIndex(nodelist, stepId);\n return currentNodeIndex === 0 ? nodelist[0] : nodelist[currentNodeIndex - 1];\n },\n\n /**\n * Converts rule step data to AutomationWrapperProps\n * @param ruleStepData Raw rule data\n * @param fn Helper function to create node.\n * @returns Tree in AutomationWrapperProps structure.\n */\n constructRuleStepTree(\n ruleStepData: RuleStepData[],\n fn: (stepId: RuleStepTreeNode['stepId'], stepName: AutomationActionType) => RuleStepTreeNode\n ): RuleStepTreeNode[] {\n if (!ruleStepData || ruleStepData.length === 0) {\n return [];\n }\n\n return ruleStepData.map(({ Id, Type, RuleSteps, ...rest }) => {\n return {\n ...fn(Id, Type),\n meta: { Id, Type, ...rest },\n nodes: this.constructRuleStepTree(Array.isArray(RuleSteps) ? RuleSteps : [], fn)\n };\n });\n }\n};\n\nconst AUTOMATION_ACTION_TYPES_SET = new Set<string>(Object.values(AutomationActions));\n\nexport const isValidAutomationActionType = (value: string): value is AutomationActionType => {\n return AUTOMATION_ACTION_TYPES_SET.has(value);\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import type { AutomationContextValue } from './Automation.types';
2
+ declare const AutomationContext: import("react").Context<AutomationContextValue>;
3
+ export default AutomationContext;
4
+ //# sourceMappingURL=AutomationContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomationContext.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/AutomationContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,QAAA,MAAM,iBAAiB,iDAKrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+ const AutomationContext = createContext({
3
+ firstNodeId: undefined,
4
+ focusInsideNode: false,
5
+ focusInsideTree: false,
6
+ focusedNodeId: undefined
7
+ });
8
+ export default AutomationContext;
9
+ //# sourceMappingURL=AutomationContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomationContext.js","sourceRoot":"","sources":["../../../src/components/Automation/AutomationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,iBAAiB,GAAG,aAAa,CAAyB;IAC9D,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,KAAK;IACtB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,SAAS;CACzB,CAAC,CAAC;AAEH,eAAe,iBAAiB,CAAC","sourcesContent":["import { createContext } from 'react';\n\nimport type { AutomationContextValue } from './Automation.types';\n\nconst AutomationContext = createContext<AutomationContextValue>({\n firstNodeId: undefined,\n focusInsideNode: false,\n focusInsideTree: false,\n focusedNodeId: undefined\n});\n\nexport default AutomationContext;\n"]}
@@ -0,0 +1,7 @@
1
+ import type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
2
+ import type { RuleStepProps } from './Automation.types';
3
+ declare const _default: ForwardRefForwardPropsComponent<RuleStepProps> & {
4
+ getTestIds: (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"]>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=RuleStep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuleStep.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/RuleStep.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAgB/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;;;;AAgVxD,wBAAyD"}
@@ -0,0 +1,151 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useRef, useEffect, useContext, useMemo } from 'react';
3
+ import { useDirection, Progress, Tooltip, useElement, Flex, Button, MenuButton, Icon, VisuallyHiddenText, ExpandCollapse, useConsolidatedRef, Text, useI18n, useTestIds, withTestIds, useEvent, Actions, getFocusables, 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 IconTile from '../IconTile';
8
+ import { StyledContainer, StyledStepHeader, StyledErrorIcon, StyledSummary, StyledComment, StyledContent } from './Automation.styles';
9
+ import { AutomationActions } from './Automation.types';
10
+ import { getRuleStepTestIds } from './Automation.test-ids';
11
+ import AutomationContext from './AutomationContext';
12
+ import { isValidAutomationActionType } from './Automation.utils';
13
+ registerIcon(caretDownIcon, caretLeftIcon, caretRightIcon);
14
+ const RuleStep = forwardRef(({ testId, stepId, stepName, stepNumber, stepVisual, switchMenu, summary, comment, addStepMenu, content, onExpandCollapse, stepActions, expanded, error, readOnly, loading, mountContent = expanded, ...restProps }, ref) => {
15
+ const t = useI18n();
16
+ const { rtl } = useDirection();
17
+ const testIds = useTestIds(testId, getRuleStepTestIds);
18
+ const ruleStepRef = useConsolidatedRef(ref);
19
+ const ruleStepActionsRef = useRef(null);
20
+ const [summaryEl, setSummaryEl] = useElement(null);
21
+ const [commentEl, setCommentEl] = useElement(null);
22
+ const [ruleStepTabIndex, setRuleStepTabIndex] = useState(-1);
23
+ const { focusedNodeId, focusInsideNode, firstNodeId } = useContext(AutomationContext);
24
+ const focused = stepId === focusedNodeId;
25
+ const translatedStepName = useMemo(() => {
26
+ switch (stepName) {
27
+ case AutomationActions.ActionSet:
28
+ case AutomationActions.ActionSetRow:
29
+ return t('action_set');
30
+ case AutomationActions.ActionWhen:
31
+ return t('action_when');
32
+ case AutomationActions.ActionAppend:
33
+ return t('action_append');
34
+ case AutomationActions.ActionCall:
35
+ return t('action_call');
36
+ case AutomationActions.ActionCreate:
37
+ return t('action_create');
38
+ case AutomationActions.ActionForEach:
39
+ return t('action_for_each');
40
+ case AutomationActions.ActionExit:
41
+ case AutomationActions.ActionExitAutomation:
42
+ case AutomationActions.ActionExitIteration:
43
+ case AutomationActions.ActionExitForEach:
44
+ return t('action_exit');
45
+ case AutomationActions.ActionReturn:
46
+ return t('action_return');
47
+ case AutomationActions.ActionRemove:
48
+ case AutomationActions.ActionRemoveRow:
49
+ return t('action_remove');
50
+ case AutomationActions.ActionErrorHandler:
51
+ return t('action_error_handler');
52
+ default:
53
+ return stepName;
54
+ }
55
+ }, [stepName]);
56
+ const stepDetail = `${stepNumber}, ${translatedStepName}, ${summary || ''}, ${comment || ''}`;
57
+ const setFocusableElementsTabIndex = (tabIndex) => {
58
+ const focusables = getFocusables(ruleStepRef, { includeNegativeTabIndex: true });
59
+ focusables.forEach(item => item.setAttribute('tabIndex', tabIndex.toString()));
60
+ return focusables;
61
+ };
62
+ const onKeyDown = (e) => {
63
+ switch (e.key) {
64
+ case 'Escape': {
65
+ if (focusInsideNode && focused) {
66
+ ruleStepRef.current?.focus();
67
+ }
68
+ setFocusableElementsTabIndex('-1');
69
+ break;
70
+ }
71
+ case 'Enter': {
72
+ if (!focusInsideNode) {
73
+ e.preventDefault();
74
+ const focusables = setFocusableElementsTabIndex('0');
75
+ if (focused) {
76
+ focusables[0]?.focus();
77
+ }
78
+ }
79
+ break;
80
+ }
81
+ case 'ArrowRight': {
82
+ if (!focusInsideNode && !expanded) {
83
+ onExpandCollapse?.(stepId);
84
+ setFocusableElementsTabIndex('-1');
85
+ }
86
+ break;
87
+ }
88
+ case 'ArrowLeft': {
89
+ if (!focusInsideNode && expanded) {
90
+ onExpandCollapse?.(stepId);
91
+ }
92
+ break;
93
+ }
94
+ default:
95
+ break;
96
+ }
97
+ };
98
+ useEvent('keydown', onKeyDown, { target: ruleStepRef });
99
+ // effect to focus the current step
100
+ useEffect(() => {
101
+ if (!focusInsideNode) {
102
+ setFocusableElementsTabIndex('-1');
103
+ if (focused) {
104
+ ruleStepRef.current?.focus();
105
+ }
106
+ }
107
+ else {
108
+ const focusables = setFocusableElementsTabIndex('0');
109
+ if (focused) {
110
+ focusables[0]?.focus();
111
+ }
112
+ }
113
+ }, [focused, focusedNodeId, focusInsideNode]);
114
+ // effect to calculate tabIndex for step
115
+ useEffect(() => {
116
+ if (focusedNodeId) {
117
+ setRuleStepTabIndex(stepId === focusedNodeId && !focusInsideNode ? 0 : -1);
118
+ }
119
+ else {
120
+ setRuleStepTabIndex(stepId === firstNodeId ? 0 : -1);
121
+ }
122
+ }, [focusedNodeId, firstNodeId, focusInsideNode]);
123
+ useEffect(() => {
124
+ if (expanded) {
125
+ setFocusableElementsTabIndex(focusInsideNode ? '0' : '-1');
126
+ }
127
+ if (!expanded && !focusInsideNode) {
128
+ setFocusableElementsTabIndex('-1');
129
+ }
130
+ }, [expanded]);
131
+ return (_jsxs(Flex, { item: { grow: 1 }, as: StyledContainer, "data-testid": `${stepNumber}-${testIds.root}`, tabIndex: ruleStepTabIndex, ref: ruleStepRef, role: 'treeitem', "aria-expanded": expanded, "aria-describedby": stepId, "aria-label": `${expanded ? t('expanded_step', [stepDetail]) : t('collapsed_step', [stepDetail])}`, ...restProps, children: [_jsxs(Flex, { container: { justify: 'between', pad: 1 }, children: [_jsxs(Flex, { as: StyledStepHeader, container: { direction: 'column' }, children: [_jsxs(Flex, { item: { shrink: 1, grow: 1, basis: 'auto' }, container: { gap: 1, alignItems: 'center' }, children: [_jsx(Button, { icon: true, variant: 'simple', compact: true, onClick: () => onExpandCollapse?.(stepId), "data-testid": `${stepNumber}-${testIds.expandCollapseButton}`, "aria-label": `${expanded ? t('collapse_step', [stepNumber]) : t('expand_step', [stepNumber])}`, "aria-expanded": expanded, label: expanded ? t('collapse') : t('expand'), tabIndex: focusInsideNode ? 0 : -1, children: _jsx(Icon, { name: expanded ? 'caret-down' : `caret-${rtl ? 'left' : 'right'}` }) }), _jsx(Text, { "data-testid": `${stepNumber}-${testIds.stepNumber}`, children: stepNumber }), error && (_jsx(StyledErrorIcon, { "data-testid": `${stepNumber}-${testIds.errorIcon}`, name: 'warn-solid' })), _jsx(Flex, { item: { shrink: 0 }, children: stepVisual && _jsx(IconTile, { ...stepVisual }) }), switchMenu && !readOnly ? (_jsx(MenuButton, { testId: `${stepNumber}${testIds.switchMenu}`, ...switchMenu, tabIndex: focusInsideNode ? 0 : -1, variant: 'text', text: translatedStepName, menu: {
132
+ ...switchMenu.menu,
133
+ onItemClick: (id) => {
134
+ if (isValidAutomationActionType(id)) {
135
+ switchMenu?.menu.onItemClick?.(id, stepId, stepNumber);
136
+ }
137
+ }
138
+ } })) : (translatedStepName), summary && (_jsxs(_Fragment, { children: [_jsx(StyledSummary, { "data-testid": `${stepNumber}-${testIds.summary}`, variant: 'secondary', ref: setSummaryEl, children: summary }), _jsx(Tooltip, { smart: true, target: summaryEl, hideDelay: 'none', "data-testid": `${stepNumber}-${testIds.summaryTooltip}`, children: summary })] }))] }), comment && (_jsxs(_Fragment, { children: [_jsx(StyledComment, { ref: setCommentEl, "data-testid": `${stepNumber}-${testIds.comment}`, variant: 'secondary', children: comment }), _jsx(Tooltip, { smart: true, target: commentEl, hideDelay: 'none', "data-testid": `${stepNumber}-${testIds.commentTooltip}`, children: comment })] }))] }), _jsxs(Flex, { ref: ruleStepActionsRef, item: { shrink: 0 }, container: { justify: 'center', alignItems: 'center' }, children: [addStepMenu && !readOnly && (_jsx(MenuButton, { testId: `${stepNumber}-${testIds.addStepMenu}`, ...addStepMenu, icon: 'plus', iconOnly: true, compact: true, text: t('add_step'), variant: 'simple', tabIndex: focusInsideNode ? 0 : -1, menu: {
139
+ ...addStepMenu.menu,
140
+ scrollAt: 20,
141
+ mode: 'action',
142
+ variant: 'drill-down',
143
+ onItemClick: (id) => {
144
+ if (isValidAutomationActionType(id)) {
145
+ addStepMenu?.menu.onItemClick?.(id, stepId, stepNumber);
146
+ }
147
+ }
148
+ } })), stepActions && (_jsx(Actions, { "data-testid": `${stepNumber}-${testIds.stepActions}`, compact: true, contextualLabel: `step-${stepNumber}`, items: stepActions, tabIndex: focusInsideNode ? 0 : -1 }))] })] }), _jsx(VisuallyHiddenText, { id: stepId, children: error ? `Step name ${translatedStepName} has errors` : `Step name ${translatedStepName}` }), (content || loading) && (_jsx(ExpandCollapse, { transitionSpeed: '0.1s', collapsed: !expanded, children: _jsxs(StyledContent, { "data-testid": `${stepNumber}-${testIds.content}`, children: [(expanded || mountContent) && content, loading && (_jsx(Progress, { variant: 'ring', placement: 'local', focusOnVisible: true, message: t('loading') }))] }) }))] }));
149
+ });
150
+ export default withTestIds(RuleStep, getRuleStepTestIds);
151
+ //# sourceMappingURL=RuleStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuleStep.js","sourceRoot":"","sources":["../../../src/components/Automation/RuleStep.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGrF,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,UAAU,EACV,IAAI,EACJ,MAAM,EACN,UAAU,EACV,IAAI,EACJ,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,IAAI,EACJ,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,EACR,OAAO,EACP,aAAa,EACb,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK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,EAAE,aAC3D,CAAC,QAAQ,IAAI,YAAY,CAAC,IAAI,OAAO,EAErC,OAAO,IAAI,CACV,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,OAAO,EAAC,cAAc,QAAC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,GAAI,CACpF,IACa,GACD,CAClB,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useRef, useEffect, useContext, useMemo } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport {\n useDirection,\n Progress,\n Tooltip,\n useElement,\n Flex,\n Button,\n MenuButton,\n Icon,\n VisuallyHiddenText,\n ExpandCollapse,\n useConsolidatedRef,\n Text,\n useI18n,\n useTestIds,\n withTestIds,\n useEvent,\n Actions,\n getFocusables,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type { 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 IconTile from '../IconTile';\n\nimport {\n StyledContainer,\n StyledStepHeader,\n StyledErrorIcon,\n StyledSummary,\n StyledComment,\n StyledContent\n} from './Automation.styles';\nimport { AutomationActions } from './Automation.types';\nimport type { RuleStepProps } from './Automation.types';\nimport { getRuleStepTestIds } from './Automation.test-ids';\nimport AutomationContext from './AutomationContext';\nimport { isValidAutomationActionType } from './Automation.utils';\n\nregisterIcon(caretDownIcon, caretLeftIcon, caretRightIcon);\n\nconst RuleStep: ForwardRefForwardPropsComponent<RuleStepProps> = forwardRef(\n (\n {\n testId,\n stepId,\n stepName,\n stepNumber,\n stepVisual,\n switchMenu,\n summary,\n comment,\n addStepMenu,\n content,\n onExpandCollapse,\n stepActions,\n expanded,\n error,\n readOnly,\n loading,\n mountContent = expanded,\n ...restProps\n }: PropsWithoutRef<RuleStepProps>,\n ref: RuleStepProps['ref']\n ) => {\n const t = useI18n();\n const { rtl } = useDirection();\n const testIds = useTestIds(testId, getRuleStepTestIds);\n\n const ruleStepRef = useConsolidatedRef(ref);\n const ruleStepActionsRef = useRef<HTMLDivElement | null>(null);\n\n const [summaryEl, setSummaryEl] = useElement(null);\n const [commentEl, setCommentEl] = useElement(null);\n\n const [ruleStepTabIndex, setRuleStepTabIndex] = useState(-1);\n const { focusedNodeId, focusInsideNode, firstNodeId } = useContext(AutomationContext);\n\n const focused = stepId === focusedNodeId;\n\n const translatedStepName = useMemo(() => {\n switch (stepName) {\n case AutomationActions.ActionSet:\n case AutomationActions.ActionSetRow:\n return t('action_set');\n\n case AutomationActions.ActionWhen:\n return t('action_when');\n\n case AutomationActions.ActionAppend:\n return t('action_append');\n\n case AutomationActions.ActionCall:\n return t('action_call');\n\n case AutomationActions.ActionCreate:\n return t('action_create');\n\n case AutomationActions.ActionForEach:\n return t('action_for_each');\n\n case AutomationActions.ActionExit:\n case AutomationActions.ActionExitAutomation:\n case AutomationActions.ActionExitIteration:\n case AutomationActions.ActionExitForEach:\n return t('action_exit');\n\n case AutomationActions.ActionReturn:\n return t('action_return');\n\n case AutomationActions.ActionRemove:\n case AutomationActions.ActionRemoveRow:\n return t('action_remove');\n\n case AutomationActions.ActionErrorHandler:\n return t('action_error_handler');\n\n default:\n return stepName;\n }\n }, [stepName]);\n\n const stepDetail = `${stepNumber}, ${translatedStepName}, ${summary || ''}, ${comment || ''}`;\n\n const setFocusableElementsTabIndex = (tabIndex: number | string) => {\n const focusables = getFocusables(ruleStepRef, { includeNegativeTabIndex: true });\n focusables.forEach(item => item.setAttribute('tabIndex', tabIndex.toString()));\n\n return focusables;\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'Escape': {\n if (focusInsideNode && focused) {\n ruleStepRef.current?.focus();\n }\n setFocusableElementsTabIndex('-1');\n break;\n }\n case 'Enter': {\n if (!focusInsideNode) {\n e.preventDefault();\n const focusables = setFocusableElementsTabIndex('0');\n if (focused) {\n focusables[0]?.focus();\n }\n }\n break;\n }\n case 'ArrowRight': {\n if (!focusInsideNode && !expanded) {\n onExpandCollapse?.(stepId);\n setFocusableElementsTabIndex('-1');\n }\n break;\n }\n case 'ArrowLeft': {\n if (!focusInsideNode && expanded) {\n onExpandCollapse?.(stepId);\n }\n break;\n }\n default:\n break;\n }\n };\n\n useEvent('keydown', onKeyDown, { target: ruleStepRef });\n\n // effect to focus the current step\n useEffect(() => {\n if (!focusInsideNode) {\n setFocusableElementsTabIndex('-1');\n if (focused) {\n ruleStepRef.current?.focus();\n }\n } else {\n const focusables = setFocusableElementsTabIndex('0');\n if (focused) {\n focusables[0]?.focus();\n }\n }\n }, [focused, focusedNodeId, focusInsideNode]);\n\n // effect to calculate tabIndex for step\n useEffect(() => {\n if (focusedNodeId) {\n setRuleStepTabIndex(stepId === focusedNodeId && !focusInsideNode ? 0 : -1);\n } else {\n setRuleStepTabIndex(stepId === firstNodeId ? 0 : -1);\n }\n }, [focusedNodeId, firstNodeId, focusInsideNode]);\n\n useEffect(() => {\n if (expanded) {\n setFocusableElementsTabIndex(focusInsideNode ? '0' : '-1');\n }\n if (!expanded && !focusInsideNode) {\n setFocusableElementsTabIndex('-1');\n }\n }, [expanded]);\n\n return (\n <Flex\n item={{ grow: 1 }}\n as={StyledContainer}\n data-testid={`${stepNumber}-${testIds.root}`}\n tabIndex={ruleStepTabIndex}\n ref={ruleStepRef}\n role='treeitem'\n aria-expanded={expanded}\n aria-describedby={stepId}\n aria-label={`${expanded ? t('expanded_step', [stepDetail]) : t('collapsed_step', [stepDetail])}`}\n {...restProps}\n >\n <Flex container={{ justify: 'between', pad: 1 }}>\n <Flex as={StyledStepHeader} container={{ direction: 'column' }}>\n <Flex\n item={{ shrink: 1, grow: 1, basis: 'auto' }}\n container={{ gap: 1, alignItems: 'center' }}\n >\n <Button\n icon\n variant='simple'\n compact\n onClick={() => onExpandCollapse?.(stepId)}\n data-testid={`${stepNumber}-${testIds.expandCollapseButton}`}\n aria-label={`${expanded ? t('collapse_step', [stepNumber]) : t('expand_step', [stepNumber])}`}\n aria-expanded={expanded}\n label={expanded ? t('collapse') : t('expand')}\n tabIndex={focusInsideNode ? 0 : -1}\n >\n <Icon name={expanded ? 'caret-down' : `caret-${rtl ? 'left' : 'right'}`} />\n </Button>\n\n <Text data-testid={`${stepNumber}-${testIds.stepNumber}`}>{stepNumber}</Text>\n\n {error && (\n <StyledErrorIcon\n data-testid={`${stepNumber}-${testIds.errorIcon}`}\n name='warn-solid'\n />\n )}\n\n <Flex item={{ shrink: 0 }}>{stepVisual && <IconTile {...stepVisual} />}</Flex>\n\n {switchMenu && !readOnly ? (\n <MenuButton\n testId={`${stepNumber}${testIds.switchMenu}`}\n {...switchMenu}\n tabIndex={focusInsideNode ? 0 : -1}\n variant='text'\n text={translatedStepName}\n menu={{\n ...switchMenu.menu,\n onItemClick: (id: string) => {\n if (isValidAutomationActionType(id)) {\n switchMenu?.menu.onItemClick?.(id, stepId, stepNumber);\n }\n }\n }}\n />\n ) : (\n translatedStepName\n )}\n\n {summary && (\n <>\n <StyledSummary\n data-testid={`${stepNumber}-${testIds.summary}`}\n variant='secondary'\n ref={setSummaryEl}\n >\n {summary}\n </StyledSummary>\n <Tooltip\n smart\n target={summaryEl}\n hideDelay='none'\n data-testid={`${stepNumber}-${testIds.summaryTooltip}`}\n >\n {summary}\n </Tooltip>\n </>\n )}\n </Flex>\n\n {comment && (\n <>\n <StyledComment\n ref={setCommentEl}\n data-testid={`${stepNumber}-${testIds.comment}`}\n variant='secondary'\n >\n {comment}\n </StyledComment>\n <Tooltip\n smart\n target={commentEl}\n hideDelay='none'\n data-testid={`${stepNumber}-${testIds.commentTooltip}`}\n >\n {comment}\n </Tooltip>\n </>\n )}\n </Flex>\n\n <Flex\n ref={ruleStepActionsRef}\n item={{ shrink: 0 }}\n container={{ justify: 'center', alignItems: 'center' }}\n >\n {addStepMenu && !readOnly && (\n <MenuButton\n testId={`${stepNumber}-${testIds.addStepMenu}`}\n {...addStepMenu}\n icon='plus'\n iconOnly\n compact\n text={t('add_step')}\n variant='simple'\n tabIndex={focusInsideNode ? 0 : -1}\n menu={{\n ...addStepMenu.menu,\n scrollAt: 20,\n mode: 'action',\n variant: 'drill-down',\n onItemClick: (id: string) => {\n if (isValidAutomationActionType(id)) {\n addStepMenu?.menu.onItemClick?.(id, stepId, stepNumber);\n }\n }\n }}\n />\n )}\n\n {stepActions && (\n <Actions\n data-testid={`${stepNumber}-${testIds.stepActions}`}\n compact\n contextualLabel={`step-${stepNumber}`}\n items={stepActions}\n tabIndex={focusInsideNode ? 0 : -1}\n />\n )}\n </Flex>\n </Flex>\n\n <VisuallyHiddenText id={stepId}>\n {error ? `Step name ${translatedStepName} has errors` : `Step name ${translatedStepName}`}\n </VisuallyHiddenText>\n\n {(content || loading) && (\n <ExpandCollapse transitionSpeed='0.1s' collapsed={!expanded}>\n <StyledContent data-testid={`${stepNumber}-${testIds.content}`}>\n {(expanded || mountContent) && content}\n\n {loading && (\n <Progress variant='ring' placement='local' focusOnVisible message={t('loading')} />\n )}\n </StyledContent>\n </ExpandCollapse>\n )}\n </Flex>\n );\n }\n);\n\nexport default withTestIds(RuleStep, getRuleStepTestIds);\n"]}
@@ -0,0 +1,5 @@
1
+ export { default } from './Automation';
2
+ export { default as RuleStep } from './RuleStep';
3
+ export { automationTreeHelpers } from './Automation.utils';
4
+ export type { RuleStepProps, AutomationProps, RuleStepTreeNode, AutomationActionType, AutomationActions } from './Automation.types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Automation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default } from './Automation';
2
+ export { default as RuleStep } from './RuleStep';
3
+ export { automationTreeHelpers } from './Automation.utils';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Automation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { default } from './Automation';\nexport { default as RuleStep } from './RuleStep';\nexport { automationTreeHelpers } from './Automation.utils';\nexport type {\n RuleStepProps,\n AutomationProps,\n RuleStepTreeNode,\n AutomationActionType,\n AutomationActions\n} from './Automation.types';\n"]}
@@ -0,0 +1,34 @@
1
+ import type { Ref } from 'react';
2
+ import type { ImageProps, LinkProps, MenuButtonProps, Action, TestIdProp, BaseProps, NoChildrenProp, ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
3
+ export interface EmptyRuleTemplateProps extends BaseProps, NoChildrenProp, TestIdProp {
4
+ /** The heading of the template */
5
+ title: string;
6
+ /** description of the template */
7
+ description?: string;
8
+ /** Image of the template */
9
+ image?: ImageProps;
10
+ /** Link pointing to external resource for more information */
11
+ moreInfo?: {
12
+ label: string;
13
+ href: LinkProps['href'];
14
+ };
15
+ /** Call to action in the template */
16
+ primaryAction?: Pick<Action, 'text' | 'onClick' | 'disabled'>;
17
+ /** Select menu to choose the first action to proceed further */
18
+ actionsMenu?: Pick<MenuButtonProps, 'text' | 'onClick' | 'onKeyDown' | 'menu'> & {
19
+ disabled?: boolean;
20
+ };
21
+ /** Ref to the template. */
22
+ ref?: Ref<HTMLDivElement>;
23
+ }
24
+ export declare const StyledEmptyRuleContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
25
+ export declare const StyledEmptyRuleContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
26
+ export declare const StyledImageContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
27
+ export declare const StyledButtonContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
28
+ isStacked: boolean;
29
+ }, never>;
30
+ declare const _default: ForwardRefForwardPropsComponent<EmptyRuleTemplateProps> & {
31
+ getTestIds: (testIdProp?: TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["title", "description", "image", "more-info", "action", "actions-menu"]>;
32
+ };
33
+ export default _default;
34
+ //# sourceMappingURL=EmptyRuleTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyRuleTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/EmptyRuleTemplate/EmptyRuleTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAC;AAiBlD,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,+BAA+B,EAChC,MAAM,yBAAyB,CAAC;AAKjC,MAAM,WAAW,sBAAuB,SAAQ,SAAS,EAAE,cAAc,EAAE,UAAU;IACnF,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;KACzB,CAAC;IACF,qCAAqC;IACrC,aAAa,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC;IAC9D,gEAAgE;IAChE,WAAW,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC,GAAG;QAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,2BAA2B;IAC3B,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,wBAAwB,yGAcpC,CAAC;AAIF,eAAO,MAAM,sBAAsB,yGAYlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAS/B,CAAC;AAIH,eAAO,MAAM,qBAAqB;eAA2C,OAAO;SASlF,CAAC;;;;AA8FH,wBAA2E"}
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Flex, Text, Image, Link, Button, MenuButton, ShowMoreLess, useTestIds, useBreakpoint, useConsolidatedRef, withTestIds, defaultThemeProp } from '@pega/cosmos-react-core';
5
+ import { StyledMenuButton } from '@pega/cosmos-react-core/lib/components/MenuButton/MenuButton';
6
+ import { getEmptyRuleTemplateTestIds } from './EmptyRuleTemplate.test-ids';
7
+ export const StyledEmptyRuleContainer = styled.div(({ theme: { base: { 'content-width': { sm } } } }) => {
8
+ return css `
9
+ min-width: ${sm};
10
+ height: 100%;
11
+ text-align: center;
12
+ `;
13
+ });
14
+ StyledEmptyRuleContainer.defaultProps = defaultThemeProp;
15
+ export const StyledEmptyRuleContent = styled.div(({ theme: { base: { 'content-width': { xl } } } }) => {
16
+ return css `
17
+ max-width: ${xl};
18
+ `;
19
+ });
20
+ StyledEmptyRuleContent.defaultProps = defaultThemeProp;
21
+ export const StyledImageContainer = styled.div(({ theme }) => {
22
+ return css `
23
+ width: calc(30 * ${theme.base.spacing});
24
+
25
+ img {
26
+ object-fit: contain;
27
+ min-width: 100%;
28
+ }
29
+ `;
30
+ });
31
+ StyledImageContainer.defaultProps = defaultThemeProp;
32
+ export const StyledButtonContainer = styled.div(({ isStacked }) => {
33
+ return (isStacked &&
34
+ css `
35
+ ${StyledMenuButton} {
36
+ margin-inline-start: 0;
37
+ }
38
+ `);
39
+ });
40
+ const EmptyRuleTemplate = forwardRef(function EmptyRuleTemplate({ testId, title, image, description, moreInfo, primaryAction, actionsMenu }, ref) {
41
+ const testIds = useTestIds(testId, getEmptyRuleTemplateTestIds);
42
+ const templateRef = useConsolidatedRef(ref);
43
+ const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: templateRef });
44
+ return (_jsx(Flex, { as: StyledEmptyRuleContainer, container: { justify: 'center', alignItems: 'center' }, ref: templateRef, children: _jsxs(Flex, { as: StyledEmptyRuleContent, container: {
45
+ direction: 'column',
46
+ alignItems: 'center',
47
+ rowGap: 2,
48
+ pad: [4, 2]
49
+ }, children: [image && (_jsx(StyledImageContainer, { children: _jsx(Image, { ...image, "data-testId": testIds.image }) })), _jsxs(Flex, { container: { direction: 'column', alignItems: 'center', rowGap: 1 }, children: [_jsx(Text, { "data-testId": testIds.title, variant: 'h2', children: title }), description && (_jsx(ShowMoreLess, { lines: 2, children: _jsx(Text, { "data-testId": testIds.description, variant: 'secondary', children: description }) })), moreInfo && (_jsx(Link, { testId: testIds.moreInfo, href: moreInfo.href, children: moreInfo.label })), (primaryAction || actionsMenu) && (_jsxs(Flex, { as: StyledButtonContainer, isStacked: !isSmallOrAbove, container: {
50
+ direction: isSmallOrAbove ? 'row' : 'column',
51
+ gap: isSmallOrAbove ? 0 : 1
52
+ }, children: [primaryAction && (_jsx(Button, { "data-testid": testIds.action, onClick: primaryAction.onClick, disabled: primaryAction.disabled, children: primaryAction.text })), actionsMenu && (_jsx(MenuButton, { testId: testIds.actionsMenu, ...actionsMenu, disabled: actionsMenu.disabled }))] }))] })] }) }));
53
+ });
54
+ export default withTestIds(EmptyRuleTemplate, getEmptyRuleTemplateTestIds);
55
+ //# sourceMappingURL=EmptyRuleTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyRuleTemplate.js","sourceRoot":"","sources":["../../../src/components/EmptyRuleTemplate/EmptyRuleTemplate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,EACN,UAAU,EACV,YAAY,EACZ,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAWjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAEhG,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAwB3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAChD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,eAAe,EAAE,EAAE,EAAE,EAAE,EACxB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;mBACK,EAAE;;;KAGhB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,wBAAwB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAC9C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,eAAe,EAAE,EAAE,EAAE,EAAE,EACxB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;mBACK,EAAE;KAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,sBAAsB,C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CACF,CAAC;AAEF,eAAe,WAAW,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { Ref, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Text,\n Image,\n Link,\n Button,\n MenuButton,\n ShowMoreLess,\n useTestIds,\n useBreakpoint,\n useConsolidatedRef,\n withTestIds,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\nimport type {\n ImageProps,\n LinkProps,\n MenuButtonProps,\n Action,\n TestIdProp,\n BaseProps,\n NoChildrenProp,\n ForwardRefForwardPropsComponent\n} from '@pega/cosmos-react-core';\nimport { StyledMenuButton } from '@pega/cosmos-react-core/lib/components/MenuButton/MenuButton';\n\nimport { getEmptyRuleTemplateTestIds } from './EmptyRuleTemplate.test-ids';\n\nexport interface EmptyRuleTemplateProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The heading of the template */\n title: string;\n /** description of the template */\n description?: string;\n /** Image of the template */\n image?: ImageProps;\n /** Link pointing to external resource for more information */\n moreInfo?: {\n label: string;\n href: LinkProps['href'];\n };\n /** Call to action in the template */\n primaryAction?: Pick<Action, 'text' | 'onClick' | 'disabled'>;\n /** Select menu to choose the first action to proceed further */\n actionsMenu?: Pick<MenuButtonProps, 'text' | 'onClick' | 'onKeyDown' | 'menu'> & {\n disabled?: boolean;\n };\n /** Ref to the template. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledEmptyRuleContainer = styled.div(\n ({\n theme: {\n base: {\n 'content-width': { sm }\n }\n }\n }) => {\n return css`\n min-width: ${sm};\n height: 100%;\n text-align: center;\n `;\n }\n);\n\nStyledEmptyRuleContainer.defaultProps = defaultThemeProp;\n\nexport const StyledEmptyRuleContent = styled.div(\n ({\n theme: {\n base: {\n 'content-width': { xl }\n }\n }\n }) => {\n return css`\n max-width: ${xl};\n `;\n }\n);\n\nStyledEmptyRuleContent.defaultProps = defaultThemeProp;\n\nexport const StyledImageContainer = styled.div(({ theme }) => {\n return css`\n width: calc(30 * ${theme.base.spacing});\n\n img {\n object-fit: contain;\n min-width: 100%;\n }\n `;\n});\n\nStyledImageContainer.defaultProps = defaultThemeProp;\n\nexport const StyledButtonContainer = styled.div(({ isStacked }: { isStacked: boolean }) => {\n return (\n isStacked &&\n css`\n ${StyledMenuButton} {\n margin-inline-start: 0;\n }\n `\n );\n});\n\nconst EmptyRuleTemplate: ForwardRefForwardPropsComponent<EmptyRuleTemplateProps> = forwardRef(\n function EmptyRuleTemplate(\n {\n testId,\n title,\n image,\n description,\n moreInfo,\n primaryAction,\n actionsMenu\n }: PropsWithoutRef<EmptyRuleTemplateProps>,\n ref: EmptyRuleTemplateProps['ref']\n ) {\n const testIds = useTestIds(testId, getEmptyRuleTemplateTestIds);\n const templateRef = useConsolidatedRef<HTMLDivElement>(ref);\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: templateRef });\n\n return (\n <Flex\n as={StyledEmptyRuleContainer}\n container={{ justify: 'center', alignItems: 'center' }}\n ref={templateRef}\n >\n <Flex\n as={StyledEmptyRuleContent}\n container={{\n direction: 'column',\n alignItems: 'center',\n rowGap: 2,\n pad: [4, 2]\n }}\n >\n {image && (\n <StyledImageContainer>\n <Image {...image} data-testId={testIds.image} />\n </StyledImageContainer>\n )}\n\n <Flex container={{ direction: 'column', alignItems: 'center', rowGap: 1 }}>\n <Text data-testId={testIds.title} variant='h2'>\n {title}\n </Text>\n\n {description && (\n <ShowMoreLess lines={2}>\n <Text data-testId={testIds.description} variant='secondary'>\n {description}\n </Text>\n </ShowMoreLess>\n )}\n\n {moreInfo && (\n <Link testId={testIds.moreInfo} href={moreInfo.href}>\n {moreInfo.label}\n </Link>\n )}\n\n {(primaryAction || actionsMenu) && (\n <Flex\n as={StyledButtonContainer}\n isStacked={!isSmallOrAbove}\n container={{\n direction: isSmallOrAbove ? 'row' : 'column',\n gap: isSmallOrAbove ? 0 : 1\n }}\n >\n {primaryAction && (\n <Button\n data-testid={testIds.action}\n onClick={primaryAction.onClick}\n disabled={primaryAction.disabled}\n >\n {primaryAction.text}\n </Button>\n )}\n\n {actionsMenu && (\n <MenuButton\n testId={testIds.actionsMenu}\n {...actionsMenu}\n disabled={actionsMenu.disabled}\n />\n )}\n </Flex>\n )}\n </Flex>\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default withTestIds(EmptyRuleTemplate, getEmptyRuleTemplateTestIds);\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getEmptyRuleTemplateTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["title", "description", "image", "more-info", "action", "actions-menu"]>;
2
+ //# sourceMappingURL=EmptyRuleTemplate.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyRuleTemplate.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/EmptyRuleTemplate/EmptyRuleTemplate.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,6MAO7B,CAAC"}