@nyaruka/temba-components 0.130.3 → 0.130.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/demo/sortable-rules-demo.html +155 -0
- package/dist/temba-components.js +133 -143
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +13 -7
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/actions/send_msg.js +1 -0
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_groups.js +149 -1
- package/out-tsc/src/flow/nodes/split_by_groups.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +1 -0
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js +81 -75
- package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +106 -28
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/select/Select.js +21 -25
- package/out-tsc/src/form/select/Select.js.map +1 -1
- package/out-tsc/src/list/SortableList.js +214 -140
- package/out-tsc/src/list/SortableList.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +18 -13
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/test/nodes/split_by_groups.test.js +130 -0
- package/out-tsc/test/nodes/split_by_groups.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_response.test.js +149 -0
- package/out-tsc/test/nodes/wait_for_response.test.js.map +1 -1
- package/out-tsc/test/temba-field-config.test.js +56 -0
- package/out-tsc/test/temba-field-config.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
- package/screenshots/truth/contacts/chat-failure.png +0 -0
- package/screenshots/truth/contacts/chat-for-archived-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-blocked-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-stopped-contact.png +0 -0
- package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/field-renderer/select-with-label.png +0 -0
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/sortable-dragging.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/select/search-enabled.png +0 -0
- package/screenshots/truth/select/search-selected-focus.png +0 -0
- package/screenshots/truth/select/search-selected.png +0 -0
- package/screenshots/truth/templates/default.png +0 -0
- package/screenshots/truth/templates/unapproved.png +0 -0
- package/src/events.ts +6 -6
- package/src/flow/CanvasNode.ts +15 -13
- package/src/flow/actions/send_msg.ts +1 -0
- package/src/flow/nodes/split_by_groups.ts +190 -1
- package/src/flow/nodes/split_by_llm_categorize.ts +1 -0
- package/src/flow/nodes/wait_for_response.ts +98 -74
- package/src/form/ArrayEditor.ts +112 -28
- package/src/form/select/Select.ts +24 -25
- package/src/list/SortableList.ts +250 -149
- package/src/live/ContactChat.ts +20 -13
- package/test/nodes/split_by_groups.test.ts +165 -0
- package/test/nodes/wait_for_response.test.ts +182 -0
- package/test/temba-field-config.test.ts +69 -0
- package/test-assets/contacts/history.json +37 -35
- package/screenshots/truth/contacts/chat-for-active-contact.png +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"","sourcesContent":["import { Msg, ObjectReference, User } from './interfaces';\n\nexport interface EventGroup {\n type: string;\n events: ContactEvent[];\n open: boolean;\n}\n\nexport interface ContactEvent {\n uuid?: string;\n type: string;\n created_on: string;\n created_by?: User; // deprecated\n _user?: ObjectReference;\n}\n\nexport interface ChannelEvent extends ContactEvent {\n channel_event_type: string;\n duration: number;\n\n event: {\n type: string;\n channel: { uuid: string; name: string };\n duration?: number;\n optin?: {\n uuid: string;\n name: string;\n };\n };\n}\n\nexport interface ContactLanguageChangedEvent extends ContactEvent {\n language: string;\n}\n\nexport interface ContactStatusChangedEvent extends ContactEvent {\n status: string;\n}\n\nexport interface OptInEvent extends ContactEvent {\n optin: {\n uuid: string;\n name: string;\n };\n}\n\nexport interface CallEvent extends ContactEvent {\n call?: {\n uuid: string;\n urn: string;\n };\n}\n\nexport interface ChatStartedEvent extends ContactEvent {\n params?: object;\n}\n\nexport interface MsgEvent extends ContactEvent {\n msg: Msg;\n
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"","sourcesContent":["import { Msg, ObjectReference, User } from './interfaces';\n\nexport interface EventGroup {\n type: string;\n events: ContactEvent[];\n open: boolean;\n}\n\nexport interface ContactEvent {\n uuid?: string;\n type: string;\n created_on: string;\n created_by?: User; // deprecated\n _user?: ObjectReference;\n}\n\nexport interface ChannelEvent extends ContactEvent {\n channel_event_type: string;\n duration: number;\n\n event: {\n type: string;\n channel: { uuid: string; name: string };\n duration?: number;\n optin?: {\n uuid: string;\n name: string;\n };\n };\n}\n\nexport interface ContactLanguageChangedEvent extends ContactEvent {\n language: string;\n}\n\nexport interface ContactStatusChangedEvent extends ContactEvent {\n status: string;\n}\n\nexport interface OptInEvent extends ContactEvent {\n optin: {\n uuid: string;\n name: string;\n };\n}\n\nexport interface CallEvent extends ContactEvent {\n call?: {\n uuid: string;\n urn: string;\n };\n}\n\nexport interface ChatStartedEvent extends ContactEvent {\n params?: object;\n}\n\nexport interface MsgEvent extends ContactEvent {\n msg: Msg;\n optin?: ObjectReference;\n _status?: string;\n _failed_reason?: string;\n _logs_url?: string;\n status?: string; // deprecated\n failed_reason_display?: string; // deprecated\n logs_url?: string; // deprecated\n}\n\nexport interface RunEvent extends ContactEvent {\n flow: ObjectReference;\n status: string;\n}\n\nexport interface URNsChangedEvent extends ContactEvent {\n urns: string[];\n}\n\nexport interface TicketEvent extends ContactEvent {\n ticket: {\n // ticket_opened\n uuid: string;\n topic?: ObjectReference;\n };\n ticket_uuid?: string; // all other event types\n assignee?: User;\n note?: string;\n topic?: ObjectReference;\n}\n\nexport interface NameChangedEvent extends ContactEvent {\n name: string;\n}\n\nexport interface UpdateFieldEvent extends ContactEvent {\n field: { key: string; name: string };\n value: { text: string };\n}\n\nexport interface ContactGroupsEvent extends ContactEvent {\n groups_added: ObjectReference[];\n groups_removed: ObjectReference[];\n}\n\nexport interface AirtimeTransferredEvent extends ContactEvent {\n sender: string;\n recipient: string;\n currency: string;\n amount: string;\n}\n\nexport type CallStartedEvent = ContactEvent;\n\nexport interface ContactHistoryPage {\n has_older: boolean;\n recent_only: boolean;\n next_before: number;\n next_after: number;\n start_date: Date;\n events: ContactEvent[];\n}\n"]}
|
|
@@ -32,8 +32,14 @@ export class CanvasNode extends RapidElement {
|
|
|
32
32
|
max-width: 200px;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.node:
|
|
36
|
-
|
|
35
|
+
.node .action:last-child {
|
|
36
|
+
border-bottom-left-radius: var(--curvature);
|
|
37
|
+
border-bottom-right-radius: var(--curvature);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.node .action:first-child {
|
|
41
|
+
border-top-left-radius: var(--curvature);
|
|
42
|
+
border-top-right-radius: var(--curvature);
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
.node.dragging {
|
|
@@ -192,8 +198,8 @@ export class CanvasNode extends RapidElement {
|
|
|
192
198
|
}
|
|
193
199
|
|
|
194
200
|
.action-exits {
|
|
195
|
-
padding-bottom: 0.
|
|
196
|
-
margin-top: -0.
|
|
201
|
+
padding-bottom: 0.7em;
|
|
202
|
+
margin-top: -0.7em;
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
.category .cn-title {
|
|
@@ -729,7 +735,7 @@ export class CanvasNode extends RapidElement {
|
|
|
729
735
|
class="action-content"
|
|
730
736
|
@mousedown=${(e) => this.handleActionMouseDown(e, action)}
|
|
731
737
|
@mouseup=${(e) => this.handleActionMouseUp(e, action)}
|
|
732
|
-
style="cursor: pointer;"
|
|
738
|
+
style="cursor: pointer; background: #fff"
|
|
733
739
|
>
|
|
734
740
|
${this.renderTitle(config, action, index, isRemoving)}
|
|
735
741
|
<div class="body">
|
|
@@ -834,9 +840,9 @@ export class CanvasNode extends RapidElement {
|
|
|
834
840
|
dragHandle="drag-handle"
|
|
835
841
|
@temba-order-changed="${this.handleActionOrderChanged}"
|
|
836
842
|
>
|
|
837
|
-
${
|
|
843
|
+
${this.node.actions.map((action, index) => this.renderAction(this.node, action, index))}
|
|
838
844
|
</temba-sortable-list>`
|
|
839
|
-
: html `${
|
|
845
|
+
: html `${this.node.actions.map((action, index) => this.renderAction(this.node, action, index))}`
|
|
840
846
|
: ''}
|
|
841
847
|
${this.node.router
|
|
842
848
|
? html ` ${this.renderRouter(this.node.router, this.ui)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasNode.js","sourceRoot":"","sources":["../../../src/flow/CanvasNode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoC,MAAM,KAAK,CAA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AY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAC/D;qCACoB;oBACzB,CAAC,CAAC,IAAI,CAAA,GAAG,MAAM,CACX,IAAI,CAAC,IAAI,CAAC,OAAO,EACjB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EACvB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAC/D,EAAE;gBACP,CAAC,CAAC,EAAE;UACJ,IAAI,CAAC,IAAI,CAAC,MAAM;YAChB,CAAC,CAAC,IAAI,CAAA,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;cAClD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACtC,CAAC,CAAC,IAAI,CAAA;gBACA,MAAM,CACN,IAAI,CAAC,IAAI,CAAC,KAAK,EACf,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EACnB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAChC;mBACI;;KAEd,CAAC;IACJ,CAAC;CACF;AA/9BS;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACF;AAGjB;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACR;AAGX;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACR","sourcesContent":["import { css, html, PropertyValueMap, TemplateResult } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { ACTION_CONFIG, ActionConfig, NODE_CONFIG, NodeConfig } from './config';\nimport { Action, Exit, Node, NodeUI, Router } from '../store/flow-definition';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { Plumber } from './Plumber';\nimport { getStore } from '../store/Store';\nimport { CustomEventType } from '../interfaces';\n\nconst DRAG_THRESHOLD = 5;\n\nexport class CanvasNode extends RapidElement {\n createRenderRoot() {\n return this;\n }\n\n @property({ type: Object })\n private plumber: Plumber;\n\n @property({ type: Object })\n private node: Node;\n\n @property({ type: Object })\n private ui: NodeUI;\n\n // Track exits that are in \"removing\" state\n private exitRemovalTimeouts: Map<string, number> = new Map();\n\n // Set of exit UUIDs that are in the removing state\n private exitRemovingState: Set<string> = new Set();\n\n // Track actions that are in \"removing\" state\n private actionRemovalTimeouts: Map<string, number> = new Map();\n\n // Set of action UUIDs that are in the removing state\n private actionRemovingState: Set<string> = new Set();\n\n // Track action click state to distinguish from drag\n private actionClickStartPos: { x: number; y: number } | null = null;\n private pendingActionClick: { action: Action; event: MouseEvent } | null =\n null;\n\n // Track node click state to distinguish from drag\n private nodeClickStartPos: { x: number; y: number } | null = null;\n private pendingNodeClick: { event: MouseEvent } | null = null;\n\n static get styles() {\n return css`\n\n .node {\n background-color: #fff;\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n min-width: 200px;\n border-radius: var(--curvature);\n \n color: #333;\n cursor: move;\n user-select: none;\n\n }\n\n /* Cap width for execute_actions nodes */\n .node.execute-actions {\n max-width: 200px;\n }\n\n .node:hover {\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);\n }\n\n .node.dragging {\n box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);\n transform: scale(1.02);\n z-index: 1000;\n }\n\n .action {\n position: relative;\n }\n\n\n .action .cn-title:hover .remove-button,\n .router:hover .remove-button {\n opacity: 0.7;\n }\n\n .action.removing .cn-title,\n .router .cn-title.removing {\n background-color: var(--color-error, #dc3545) !important;\n }\n\n .action.removing .cn-title .name,\n .router .cn-title.removing .name {\n color: white;\n }\n\n .remove-button {\n background: transparent;\n color: white;\n opacity: 0;\n cursor: pointer;\n font-size: 1em;\n font-weight: 600;\n line-height: 1;\n z-index: 10;\n transition: all 100ms ease-in-out;\n align-self: center;\n padding:0.25em;\n border: 0px solid red;\n width: 1em;\n pointer-events: auto; /* Ensure remove button can receive events */\n }\n\n .remove-button:hover {\n opacity: 1;\n }\n\n .action.sortable {\n display: flex;\n align-items: stretch;\n }\n\n .action .action-content {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n min-width: 0; /* Allow flex item to shrink below its content size */\n overflow: hidden;\n }\n\n .action .body {\n padding: 0.75em;\n word-wrap: break-word;\n overflow-wrap: break-word;\n hyphens: auto;\n white-space: normal;\n overflow: hidden;\n }\n\n .node.execute-actions temba-sortable-list .action:last-child .body {\n padding-bottom: 1.5em;\n } \n\n .action .drag-handle {\n opacity: 0;\n transition: all 200ms ease-in-out;\n cursor: move;\n background: rgba(0, 0, 0, 0.02);\n width: 1em;\n padding: 0.25em;\n border: 0px solid red;\n pointer-events: auto; /* Ensure drag handle can receive events */\n }\n .title-spacer {\n width: 2em;\n \n }\n\n .action:hover .drag-handle {\n opacity: 0.7;\n \n \n }\n\n strong {\n font-weight: 500;\n }\n\n .action .drag-handle:hover {\n opacity: 1;\n \n }\n\n .action .cn-title,\n .router .cn-title {\n display: flex;\n color: #fff;\n text-align: center;\n font-size: 1em;\n font-weight: 500;\n }\n\n .cn-title .name {\n padding: 0.3em 0;\n\n }\n\n .router .cn-title {\n\n }\n\n .cn-title .name {\n flex-grow: 1;\n }\n\n .quick-replies {\n margin-top: 0.5em;\n }\n\n .quick-reply {\n background-color: #f0f0f0;\n border: 1px solid #e0e0e0;\n border-radius: calc(var(--curvature) * 1.5);\n padding: 0.2em 1em;\n display: inline-block;\n font-size: 0.8em;\n margin: 0.2em;\n }\n\n .categories {\n display: flex;\n flex-direction: row;\n\n }\n\n .category {\n margin:-1px -0.5px;\n border: 1px solid #f3f3f3;\n padding: 0.75em;\n flex-grow:1;\n text-align: center;\n display: flex;\n flex-direction: column;\n }\n\n .action-exits {\n padding-bottom: 0.6em;\n margin-top: -0.8em;\n }\n\n .category .cn-title {\n font-weight: normal;\n font-size: 1em;\n max-width: 150px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .router .body {\n padding: 0.75em;\n }\n\n .result-name {\n font-weight: 500;\n display: inline-block;\n }\n \n .exit-wrapper {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n margin-bottom: -1.2em;\n padding-top:0.2em;\n }\n\n .exit {\n width: 12px;\n height: 12px;\n border-radius: 50%;\n background-color: tomato;\n position: relative;\n box-shadow: 0 2px 2px rgba(0, 0, 0, .1);\n cursor: pointer;\n pointer-events: none;\n }\n\n .exit.jtk-connected {\n background: var(--color-connectors, #e6e6e6);\n }\n\n .exit.connected {\n background-color: #fff;\n pointer-events: all;\n }\n\n .exit.connected:hover {\n background-color: var(--color-connectors, #e6e6e6);\n }\n \n .exit.removing, .exit.removing:hover {\n background-color: var(--color-error);\n pointer-events: all;\n }\n \n .exit.removing::before {\n content: '✕';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 8px;\n color: white;\n line-height: 1;\n }\n \n /* Connector in removing state */\n :host {\n --color-connector-removing: var(--color-error);\n }\n \n body svg.plumb-connector.removing path {\n stroke: var(--color-connector-removing, tomato) !important;\n stroke-width: 3px;\n }\n \n body .plumb-connector.removing .plumb-arrow {\n fill: var(--color-connector-removing, tomato) !important;\n stroke: var(--color-connector-removing, transparent) !important;\n }\n\n .category:first-child {\n border-bottom-left-radius: var(--curvature);\n }\n\n .category:last-child {\n border-bottom-right-radius: var(--curvature);\n }\n\n .router .cn-title {\n border-top-left-radius: var(--curvature);\n border-top-right-radius: var(--curvature);\n }\n\n .action{\n overflow: hidden;\n }\n\n .action:first-child .cn-title {\n border-top-left-radius: var(--curvature);\n border-top-right-radius: var(--curvature);\n }\n }`;\n }\n\n constructor() {\n super();\n this.handleActionOrderChanged = this.handleActionOrderChanged.bind(this);\n }\n\n protected updated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.updated(changes);\n if (changes.has('node')) {\n // Only proceed if plumber is available (for tests that don't set it up)\n if (this.plumber) {\n this.plumber.removeNodeConnections(this.node.uuid);\n // make our initial connections\n for (const exit of this.node.exits) {\n if (!exit.destination_uuid) {\n // if we have no destination, then we are a source\n // so make our source endpoint\n this.plumber.makeSource(exit.uuid);\n } else {\n this.plumber.connectIds(\n this.node.uuid,\n exit.uuid,\n exit.destination_uuid\n );\n }\n }\n\n this.plumber.revalidate([this.node.uuid]);\n }\n\n const ele = this.parentElement;\n if (ele) {\n const rect = ele.getBoundingClientRect();\n\n getStore()\n ?.getState()\n .expandCanvas(\n this.ui.position.left + rect.width,\n this.ui.position.top + rect.height\n );\n }\n }\n }\n\n disconnectedCallback() {\n // Remove the event listener when the component is removed\n super.disconnectedCallback();\n\n // Clear any pending exit removal timeouts\n this.exitRemovalTimeouts.forEach((timeoutId) => {\n clearTimeout(timeoutId);\n });\n this.exitRemovalTimeouts.clear();\n\n // Clear any pending action removal timeouts\n this.actionRemovalTimeouts.forEach((timeoutId) => {\n clearTimeout(timeoutId);\n });\n this.actionRemovalTimeouts.clear();\n\n // Clear the removing state\n this.exitRemovingState.clear();\n this.actionRemovingState.clear();\n }\n\n private handleExitClick(event: MouseEvent, exit: Exit) {\n event.preventDefault();\n event.stopPropagation();\n\n const exitId = exit.uuid;\n\n // If exit is not connected, do nothing\n if (!exit.destination_uuid) return;\n\n // If the exit is already in removing state, perform the disconnect\n if (this.exitRemovingState.has(exitId)) {\n this.disconnectExit(exit);\n return;\n }\n\n // Start removal UI state\n this.exitRemovingState.add(exitId);\n this.requestUpdate();\n\n // Set the connection to removing state\n this.plumber.setConnectionRemovingState(exitId, true);\n\n // Clear any existing timeout for this exit\n if (this.exitRemovalTimeouts.has(exitId)) {\n clearTimeout(this.exitRemovalTimeouts.get(exitId));\n }\n\n // Set timeout to reset UI if user doesn't click\n const timeoutId = window.setTimeout(() => {\n this.exitRemovingState.delete(exitId);\n this.exitRemovalTimeouts.delete(exitId);\n\n // Reset the connection to normal state\n this.plumber.setConnectionRemovingState(exitId, false);\n\n this.requestUpdate();\n }, 1500);\n\n this.exitRemovalTimeouts.set(exitId, timeoutId);\n }\n\n private disconnectExit(exit: Exit) {\n const exitId = exit.uuid;\n\n // Clear the UI state\n this.exitRemovingState.delete(exitId);\n\n // Reset the connection to normal state (this will be redundant as we're about to remove it,\n // but it's safer to do this in case there's any timing issue)\n this.plumber.setConnectionRemovingState(exitId, false);\n\n // Clear any timeout\n if (this.exitRemovalTimeouts.has(exitId)) {\n clearTimeout(this.exitRemovalTimeouts.get(exitId));\n this.exitRemovalTimeouts.delete(exitId);\n }\n\n // Remove the JSPlumb connection\n this.plumber.removeExitConnection(exitId);\n\n // Update the flow definition\n const updatedExit = { ...exit, destination_uuid: null };\n const updatedExits = this.node.exits.map((e) =>\n e.uuid === exitId ? updatedExit : e\n );\n\n // Update the node\n const updatedNode = { ...this.node, exits: updatedExits };\n getStore()?.getState().updateNode(this.node.uuid, updatedNode);\n\n // Request update to reflect changes\n this.requestUpdate();\n }\n\n private handleActionRemoveClick(\n event: MouseEvent,\n action: Action,\n index: number\n ) {\n event.preventDefault();\n event.stopPropagation();\n\n const actionId = action.uuid;\n\n // If the action is already in removing state, perform the removal\n if (this.actionRemovingState.has(actionId)) {\n this.removeAction(action, index);\n return;\n }\n\n // Start removal UI state\n this.actionRemovingState.add(actionId);\n this.requestUpdate();\n\n // Clear any existing timeout for this action\n if (this.actionRemovalTimeouts.has(actionId)) {\n clearTimeout(this.actionRemovalTimeouts.get(actionId));\n }\n\n // Set timeout to reset UI if user doesn't click\n const timeoutId = window.setTimeout(() => {\n this.actionRemovingState.delete(actionId);\n this.actionRemovalTimeouts.delete(actionId);\n this.requestUpdate();\n }, 1000); // 1 second as per requirements\n\n this.actionRemovalTimeouts.set(actionId, timeoutId);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private removeAction(action: Action, _index: number) {\n const actionId = action.uuid;\n\n // Clear the UI state\n this.actionRemovingState.delete(actionId);\n\n // Clear any timeout\n if (this.actionRemovalTimeouts.has(actionId)) {\n clearTimeout(this.actionRemovalTimeouts.get(actionId));\n this.actionRemovalTimeouts.delete(actionId);\n }\n\n // Remove the action from the node\n const updatedActions = this.node.actions.filter((a) => a.uuid !== actionId);\n\n // If no actions remain, remove the entire node\n if (updatedActions.length === 0) {\n this.fireCustomEvent(CustomEventType.NodeDeleted, {\n uuid: this.node.uuid\n });\n } else {\n // Update the node with remaining actions\n const updatedNode = { ...this.node, actions: updatedActions };\n getStore()?.getState().updateNode(this.node.uuid, updatedNode);\n\n // Request update to reflect changes\n this.requestUpdate();\n }\n }\n\n private handleNodeRemoveClick(event: MouseEvent) {\n event.preventDefault();\n event.stopPropagation();\n\n const nodeId = this.node.uuid;\n\n // If the node is already in removing state, perform the removal\n if (this.actionRemovingState.has(nodeId)) {\n this.removeNode();\n return;\n }\n\n // Start removal UI state\n this.actionRemovingState.add(nodeId);\n this.requestUpdate();\n\n // Clear any existing timeout for this node\n if (this.actionRemovalTimeouts.has(nodeId)) {\n clearTimeout(this.actionRemovalTimeouts.get(nodeId));\n }\n\n // Set timeout to reset UI if user doesn't click\n const timeoutId = window.setTimeout(() => {\n this.actionRemovingState.delete(nodeId);\n this.actionRemovalTimeouts.delete(nodeId);\n this.requestUpdate();\n }, 1000); // 1 second as per requirements\n\n this.actionRemovalTimeouts.set(nodeId, timeoutId);\n }\n\n private removeNode() {\n const nodeId = this.node.uuid;\n\n // Clear the UI state\n this.actionRemovingState.delete(nodeId);\n\n // Clear any timeout\n if (this.actionRemovalTimeouts.has(nodeId)) {\n clearTimeout(this.actionRemovalTimeouts.get(nodeId));\n this.actionRemovalTimeouts.delete(nodeId);\n }\n\n // Fire the node deleted event\n this.fireCustomEvent(CustomEventType.NodeDeleted, {\n uuid: this.node.uuid\n });\n }\n\n private handleActionOrderChanged(event: CustomEvent) {\n const [fromIdx, toIdx] = event.detail.swap;\n\n // swap our actions\n const newActions = [...this.node.actions];\n const movedAction = newActions.splice(fromIdx, 1)[0];\n newActions.splice(toIdx, 0, movedAction);\n\n // udate our internal reprensentation, this isn't strictly necessary\n // since the editor will update us from it's definition subscription\n // but it makes testing a lot easier\n this.node = { ...this.node, actions: newActions };\n\n getStore()\n ?.getState()\n .updateNode(this.node.uuid, { ...this.node, actions: newActions });\n }\n\n private handleActionMouseDown(event: MouseEvent, action: Action): void {\n // Don't handle clicks on the remove button, drag handle, or when action is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(action.uuid)\n ) {\n return;\n }\n\n // Store the starting position and action for later comparison\n // Don't prevent default - let the Editor's drag system work normally\n this.actionClickStartPos = { x: event.clientX, y: event.clientY };\n this.pendingActionClick = { action, event };\n }\n\n private handleActionMouseUp(event: MouseEvent, action: Action): void {\n // Don't handle if we don't have a pending click or if it's not the same action\n if (\n !this.pendingActionClick ||\n this.pendingActionClick.action.uuid !== action.uuid\n ) {\n this.actionClickStartPos = null;\n this.pendingActionClick = null;\n return;\n }\n\n // Don't handle clicks on the remove button, drag handle, or when action is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(action.uuid)\n ) {\n this.actionClickStartPos = null;\n this.pendingActionClick = null;\n return;\n }\n\n // Check if the mouse moved beyond the drag threshold\n if (this.actionClickStartPos) {\n const deltaX = event.clientX - this.actionClickStartPos.x;\n const deltaY = event.clientY - this.actionClickStartPos.y;\n const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n\n // Check if the Editor is currently in dragging mode\n const editor = this.closest('temba-flow-editor') as any;\n const editorWasDragging = editor?.dragging;\n\n // Only fire the action edit event if we haven't dragged beyond the threshold\n // AND either there's no Editor parent (test case) or the Editor didn't drag the node\n if (distance <= DRAG_THRESHOLD && (!editor || !editorWasDragging)) {\n // Fire event to request action editing\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action,\n nodeUuid: this.node.uuid\n });\n }\n }\n\n // Clean up\n this.actionClickStartPos = null;\n this.pendingActionClick = null;\n }\n\n private handleActionClick(event: MouseEvent, action: Action): void {\n // This method is kept for backward compatibility but should not be used\n // The new mousedown/mouseup approach handles click vs drag properly\n event.preventDefault();\n event.stopPropagation();\n\n // Don't handle clicks on the remove button or when action is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n this.actionRemovingState.has(action.uuid)\n ) {\n return;\n }\n\n // Fire event to request action editing\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action,\n nodeUuid: this.node.uuid\n });\n }\n\n private handleNodeEditClick(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n\n // Don't handle clicks on the remove button or when node is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n this.actionRemovingState.has(this.node.uuid)\n ) {\n return;\n }\n\n // Fire node edit requested event if the node has a router\n if (this.node.router) {\n // If router node has exactly one action, open the action editor directly\n if (this.node.actions && this.node.actions.length === 1) {\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action: this.node.actions[0],\n nodeUuid: this.node.uuid\n });\n } else {\n // Otherwise open the node editor as before\n this.fireCustomEvent(CustomEventType.NodeEditRequested, {\n node: this.node,\n nodeUI: this.ui\n });\n }\n }\n }\n\n private handleNodeMouseDown(event: MouseEvent): void {\n // Don't handle clicks on the remove button, exits, drag handle, or when node is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.exit') ||\n target.closest('.exit-wrapper') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(this.node.uuid)\n ) {\n return;\n }\n\n // Store the starting position for later comparison\n // Don't prevent default - let the Editor's drag system work normally\n this.nodeClickStartPos = { x: event.clientX, y: event.clientY };\n this.pendingNodeClick = { event };\n }\n\n private handleNodeMouseUp(event: MouseEvent): void {\n // Don't handle if we don't have a pending click\n if (!this.pendingNodeClick) {\n this.nodeClickStartPos = null;\n this.pendingNodeClick = null;\n return;\n }\n\n // Don't handle clicks on the remove button, exits, drag handle, or when node is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.exit') ||\n target.closest('.exit-wrapper') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(this.node.uuid)\n ) {\n this.nodeClickStartPos = null;\n this.pendingNodeClick = null;\n return;\n }\n\n // Check if the mouse moved beyond the drag threshold\n if (this.nodeClickStartPos) {\n const deltaX = event.clientX - this.nodeClickStartPos.x;\n const deltaY = event.clientY - this.nodeClickStartPos.y;\n const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n\n // Check if the Editor is currently in dragging mode\n const editor = this.closest('temba-flow-editor') as any;\n const editorWasDragging = editor?.dragging;\n\n // Only fire the node edit event if we haven't dragged beyond the threshold\n // AND either there's no Editor parent (test case) or the Editor didn't drag the node\n if (distance <= 5 && (!editor || !editorWasDragging)) {\n // Using literal 5 instead of DRAG_THRESHOLD since it's not imported\n // Fire event to request node editing if the node has a router\n if (this.node.router) {\n // If router node has exactly one action, open the action editor directly\n if (this.node.actions && this.node.actions.length === 1) {\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action: this.node.actions[0],\n nodeUuid: this.node.uuid\n });\n } else {\n // Otherwise open the node editor as before\n this.fireCustomEvent(CustomEventType.NodeEditRequested, {\n node: this.node,\n nodeUI: this.ui\n });\n }\n }\n }\n }\n\n // Clean up\n this.nodeClickStartPos = null;\n this.pendingNodeClick = null;\n }\n\n private renderTitle(\n config: ActionConfig,\n action: Action,\n index: number,\n isRemoving: boolean = false\n ) {\n return html`<div class=\"cn-title\" style=\"background:${config.color}\">\n ${this.node?.actions?.length > 1\n ? html`<temba-icon class=\"drag-handle\" name=\"sort\"></temba-icon>`\n : null}\n\n <div class=\"name\">${isRemoving ? 'Remove?' : config.name}</div>\n <div\n class=\"remove-button\"\n @click=${(e: MouseEvent) =>\n this.handleActionRemoveClick(e, action, index)}\n title=\"Remove action\"\n >\n ✕\n </div>\n </div>`;\n }\n\n private renderNodeTitle(config: NodeConfig, isRemoving: boolean = false) {\n return html`<div\n class=\"cn-title ${isRemoving ? 'removing' : ''}\"\n style=\"background:${config.color}\"\n >\n <div class=\"title-spacer\"></div>\n <div class=\"name\">${isRemoving ? 'Remove?' : config.name}</div>\n <div\n class=\"remove-button\"\n @click=${(e: MouseEvent) => this.handleNodeRemoveClick(e)}\n title=\"Remove node\"\n >\n ✕\n </div>\n </div>`;\n }\n\n private renderAction(node: Node, action: Action, index: number) {\n const config = ACTION_CONFIG[action.type];\n const isRemoving = this.actionRemovingState.has(action.uuid);\n\n if (config) {\n return html`<div\n class=\"action sortable ${action.type} ${isRemoving ? 'removing' : ''}\"\n id=\"action-${index}\"\n >\n <div\n class=\"action-content\"\n @mousedown=${(e: MouseEvent) => this.handleActionMouseDown(e, action)}\n @mouseup=${(e: MouseEvent) => this.handleActionMouseUp(e, action)}\n style=\"cursor: pointer;\"\n >\n ${this.renderTitle(config, action, index, isRemoving)}\n <div class=\"body\">\n ${config.render\n ? config.render(node, action)\n : html`<pre>${action.type}</pre>`}\n </div>\n </div>\n </div>`;\n }\n return html`<div\n class=\"action sortable ${isRemoving ? 'removing' : ''}\"\n id=\"action-${index}\"\n >\n <div\n class=\"remove-button\"\n @click=${(e: MouseEvent) =>\n this.handleActionRemoveClick(e, action, index)}\n title=\"Remove action\"\n >\n ✕\n </div>\n ${action.type}\n </div>`;\n }\n\n private renderRouter(router: Router, ui: NodeUI) {\n const nodeConfig = NODE_CONFIG[ui.type];\n if (nodeConfig) {\n return html`<div class=\"router\" style=\"position: relative;\">\n ${router.result_name\n ? html`<div\n class=\"body\"\n @mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}\n @mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}\n style=\"cursor: pointer;\"\n >\n Save as\n <div class=\"result-name\">${router.result_name}</div>\n </div>`\n : null}\n </div>`;\n }\n }\n\n private renderCategories(node: Node) {\n if (!node.router || !node.router.categories) {\n return null;\n }\n\n return html`<div class=\"categories\">\n ${repeat(\n node.router.categories,\n (category) => category.uuid,\n (category) => {\n const exit = node.exits.find(\n (exit: Exit) => exit.uuid == category.exit_uuid\n );\n\n return html`<div\n class=\"category\"\n @mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}\n @mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}\n style=\"cursor: pointer;\"\n >\n <div class=\"cn-title\">${category.name}</div>\n ${this.renderExit(exit)}\n </div>`;\n }\n )}\n </div>`;\n }\n\n private renderExit(exit: Exit): TemplateResult {\n return html`<div class=\"exit-wrapper\">\n <div\n id=\"${exit.uuid}\"\n class=${getClasses({\n exit: true,\n connected: !!exit.destination_uuid,\n removing: this.exitRemovingState.has(exit.uuid)\n })}\n @click=${(e: MouseEvent) => this.handleExitClick(e, exit)}\n ></div>\n </div>`;\n }\n\n public render() {\n if (!this.node || !this.ui) {\n return html`<div class=\"node\">Loading...</div>`;\n }\n\n const nodeConfig = NODE_CONFIG[this.ui.type];\n\n return html`\n <div\n id=\"${this.node.uuid}\"\n class=\"node ${this.ui.type === 'execute_actions'\n ? 'execute-actions'\n : ''}\"\n style=\"left:${this.ui.position.left}px;top:${this.ui.position.top}px\"\n >\n ${nodeConfig && nodeConfig.type !== 'execute_actions'\n ? html`<div class=\"router\" style=\"position: relative;\">\n <div\n @mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}\n @mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}\n style=\"cursor: pointer;\"\n >\n ${this.renderNodeTitle(\n nodeConfig,\n this.actionRemovingState.has(this.node.uuid)\n )}\n ${nodeConfig.render ? nodeConfig.render(this.node) : null}\n </div>\n </div>`\n : this.node.actions.length > 0\n ? this.ui.type === 'execute_actions'\n ? html`<temba-sortable-list\n dragHandle=\"drag-handle\"\n @temba-order-changed=\"${this.handleActionOrderChanged}\"\n >\n ${repeat(\n this.node.actions,\n (action) => action.uuid,\n (action, index) => this.renderAction(this.node, action, index)\n )}\n </temba-sortable-list>`\n : html`${repeat(\n this.node.actions,\n (action) => action.uuid,\n (action, index) => this.renderAction(this.node, action, index)\n )}`\n : ''}\n ${this.node.router\n ? html` ${this.renderRouter(this.node.router, this.ui)}\n ${this.renderCategories(this.node)}`\n : html`<div class=\"action-exits\">\n ${repeat(\n this.node.exits,\n (exit) => exit.uuid,\n (exit) => this.renderExit(exit)\n )}\n </div>`}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CanvasNode.js","sourceRoot":"","sources":["../../../src/flow/CanvasNode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoC,MAAM,KAAK,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAgB,WAAW,EAAc,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAM,OAAO,UAAW,SAAQ,YAAY;IAC1C,gBAAgB;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAgCD,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Q,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACF;AAGjB;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACR;AAGX;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACR","sourcesContent":["import { css, html, PropertyValueMap, TemplateResult } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { ACTION_CONFIG, ActionConfig, NODE_CONFIG, NodeConfig } from './config';\nimport { Action, Exit, Node, NodeUI, Router } from '../store/flow-definition';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { Plumber } from './Plumber';\nimport { getStore } from '../store/Store';\nimport { CustomEventType } from '../interfaces';\n\nconst DRAG_THRESHOLD = 5;\n\nexport class CanvasNode extends RapidElement {\n createRenderRoot() {\n return this;\n }\n\n @property({ type: Object })\n private plumber: Plumber;\n\n @property({ type: Object })\n private node: Node;\n\n @property({ type: Object })\n private ui: NodeUI;\n\n // Track exits that are in \"removing\" state\n private exitRemovalTimeouts: Map<string, number> = new Map();\n\n // Set of exit UUIDs that are in the removing state\n private exitRemovingState: Set<string> = new Set();\n\n // Track actions that are in \"removing\" state\n private actionRemovalTimeouts: Map<string, number> = new Map();\n\n // Set of action UUIDs that are in the removing state\n private actionRemovingState: Set<string> = new Set();\n\n // Track action click state to distinguish from drag\n private actionClickStartPos: { x: number; y: number } | null = null;\n private pendingActionClick: { action: Action; event: MouseEvent } | null =\n null;\n\n // Track node click state to distinguish from drag\n private nodeClickStartPos: { x: number; y: number } | null = null;\n private pendingNodeClick: { event: MouseEvent } | null = null;\n\n static get styles() {\n return css`\n\n .node {\n background-color: #fff;\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n min-width: 200px;\n border-radius: var(--curvature);\n \n color: #333;\n cursor: move;\n user-select: none;\n\n }\n\n /* Cap width for execute_actions nodes */\n .node.execute-actions {\n max-width: 200px;\n }\n\n .node .action:last-child {\n border-bottom-left-radius: var(--curvature);\n border-bottom-right-radius: var(--curvature);\n }\n\n .node .action:first-child {\n border-top-left-radius: var(--curvature);\n border-top-right-radius: var(--curvature);\n }\n\n .node.dragging {\n box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);\n transform: scale(1.02);\n z-index: 1000;\n }\n\n .action {\n position: relative;\n }\n\n\n .action .cn-title:hover .remove-button,\n .router:hover .remove-button {\n opacity: 0.7;\n }\n\n .action.removing .cn-title,\n .router .cn-title.removing {\n background-color: var(--color-error, #dc3545) !important;\n }\n\n .action.removing .cn-title .name,\n .router .cn-title.removing .name {\n color: white;\n }\n\n .remove-button {\n background: transparent;\n color: white;\n opacity: 0;\n cursor: pointer;\n font-size: 1em;\n font-weight: 600;\n line-height: 1;\n z-index: 10;\n transition: all 100ms ease-in-out;\n align-self: center;\n padding:0.25em;\n border: 0px solid red;\n width: 1em;\n pointer-events: auto; /* Ensure remove button can receive events */\n }\n\n .remove-button:hover {\n opacity: 1;\n }\n\n .action.sortable {\n display: flex;\n align-items: stretch;\n }\n\n .action .action-content {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n min-width: 0; /* Allow flex item to shrink below its content size */\n overflow: hidden;\n }\n\n .action .body {\n padding: 0.75em;\n word-wrap: break-word;\n overflow-wrap: break-word;\n hyphens: auto;\n white-space: normal;\n overflow: hidden;\n }\n\n .node.execute-actions temba-sortable-list .action:last-child .body {\n padding-bottom: 1.5em;\n } \n\n .action .drag-handle {\n opacity: 0;\n transition: all 200ms ease-in-out;\n cursor: move;\n background: rgba(0, 0, 0, 0.02);\n width: 1em;\n padding: 0.25em;\n border: 0px solid red;\n pointer-events: auto; /* Ensure drag handle can receive events */\n }\n .title-spacer {\n width: 2em;\n \n }\n\n .action:hover .drag-handle {\n opacity: 0.7;\n \n \n }\n\n strong {\n font-weight: 500;\n }\n\n .action .drag-handle:hover {\n opacity: 1;\n \n }\n\n .action .cn-title,\n .router .cn-title {\n display: flex;\n color: #fff;\n text-align: center;\n font-size: 1em;\n font-weight: 500;\n }\n\n .cn-title .name {\n padding: 0.3em 0;\n\n }\n\n .router .cn-title {\n\n }\n\n .cn-title .name {\n flex-grow: 1;\n }\n\n .quick-replies {\n margin-top: 0.5em;\n }\n\n .quick-reply {\n background-color: #f0f0f0;\n border: 1px solid #e0e0e0;\n border-radius: calc(var(--curvature) * 1.5);\n padding: 0.2em 1em;\n display: inline-block;\n font-size: 0.8em;\n margin: 0.2em;\n }\n\n .categories {\n display: flex;\n flex-direction: row;\n\n }\n\n .category {\n margin:-1px -0.5px;\n border: 1px solid #f3f3f3;\n padding: 0.75em;\n flex-grow:1;\n text-align: center;\n display: flex;\n flex-direction: column;\n }\n\n .action-exits {\n padding-bottom: 0.7em;\n margin-top: -0.7em;\n }\n\n .category .cn-title {\n font-weight: normal;\n font-size: 1em;\n max-width: 150px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .router .body {\n padding: 0.75em;\n }\n\n .result-name {\n font-weight: 500;\n display: inline-block;\n }\n \n .exit-wrapper {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n margin-bottom: -1.2em;\n padding-top:0.2em;\n }\n\n .exit {\n width: 12px;\n height: 12px;\n border-radius: 50%;\n background-color: tomato;\n position: relative;\n box-shadow: 0 2px 2px rgba(0, 0, 0, .1);\n cursor: pointer;\n pointer-events: none;\n }\n\n .exit.jtk-connected {\n background: var(--color-connectors, #e6e6e6);\n }\n\n .exit.connected {\n background-color: #fff;\n pointer-events: all;\n }\n\n .exit.connected:hover {\n background-color: var(--color-connectors, #e6e6e6);\n }\n \n .exit.removing, .exit.removing:hover {\n background-color: var(--color-error);\n pointer-events: all;\n }\n \n .exit.removing::before {\n content: '✕';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 8px;\n color: white;\n line-height: 1;\n }\n \n /* Connector in removing state */\n :host {\n --color-connector-removing: var(--color-error);\n }\n \n body svg.plumb-connector.removing path {\n stroke: var(--color-connector-removing, tomato) !important;\n stroke-width: 3px;\n }\n \n body .plumb-connector.removing .plumb-arrow {\n fill: var(--color-connector-removing, tomato) !important;\n stroke: var(--color-connector-removing, transparent) !important;\n }\n\n .category:first-child {\n border-bottom-left-radius: var(--curvature);\n }\n\n .category:last-child {\n border-bottom-right-radius: var(--curvature);\n }\n\n .router .cn-title {\n border-top-left-radius: var(--curvature);\n border-top-right-radius: var(--curvature);\n }\n\n .action{\n overflow: hidden;\n }\n\n .action:first-child .cn-title {\n border-top-left-radius: var(--curvature);\n border-top-right-radius: var(--curvature);\n }\n }`;\n }\n\n constructor() {\n super();\n this.handleActionOrderChanged = this.handleActionOrderChanged.bind(this);\n }\n\n protected updated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.updated(changes);\n if (changes.has('node')) {\n // Only proceed if plumber is available (for tests that don't set it up)\n if (this.plumber) {\n this.plumber.removeNodeConnections(this.node.uuid);\n // make our initial connections\n for (const exit of this.node.exits) {\n if (!exit.destination_uuid) {\n // if we have no destination, then we are a source\n // so make our source endpoint\n this.plumber.makeSource(exit.uuid);\n } else {\n this.plumber.connectIds(\n this.node.uuid,\n exit.uuid,\n exit.destination_uuid\n );\n }\n }\n\n this.plumber.revalidate([this.node.uuid]);\n }\n\n const ele = this.parentElement;\n if (ele) {\n const rect = ele.getBoundingClientRect();\n\n getStore()\n ?.getState()\n .expandCanvas(\n this.ui.position.left + rect.width,\n this.ui.position.top + rect.height\n );\n }\n }\n }\n\n disconnectedCallback() {\n // Remove the event listener when the component is removed\n super.disconnectedCallback();\n\n // Clear any pending exit removal timeouts\n this.exitRemovalTimeouts.forEach((timeoutId) => {\n clearTimeout(timeoutId);\n });\n this.exitRemovalTimeouts.clear();\n\n // Clear any pending action removal timeouts\n this.actionRemovalTimeouts.forEach((timeoutId) => {\n clearTimeout(timeoutId);\n });\n this.actionRemovalTimeouts.clear();\n\n // Clear the removing state\n this.exitRemovingState.clear();\n this.actionRemovingState.clear();\n }\n\n private handleExitClick(event: MouseEvent, exit: Exit) {\n event.preventDefault();\n event.stopPropagation();\n\n const exitId = exit.uuid;\n\n // If exit is not connected, do nothing\n if (!exit.destination_uuid) return;\n\n // If the exit is already in removing state, perform the disconnect\n if (this.exitRemovingState.has(exitId)) {\n this.disconnectExit(exit);\n return;\n }\n\n // Start removal UI state\n this.exitRemovingState.add(exitId);\n this.requestUpdate();\n\n // Set the connection to removing state\n this.plumber.setConnectionRemovingState(exitId, true);\n\n // Clear any existing timeout for this exit\n if (this.exitRemovalTimeouts.has(exitId)) {\n clearTimeout(this.exitRemovalTimeouts.get(exitId));\n }\n\n // Set timeout to reset UI if user doesn't click\n const timeoutId = window.setTimeout(() => {\n this.exitRemovingState.delete(exitId);\n this.exitRemovalTimeouts.delete(exitId);\n\n // Reset the connection to normal state\n this.plumber.setConnectionRemovingState(exitId, false);\n\n this.requestUpdate();\n }, 1500);\n\n this.exitRemovalTimeouts.set(exitId, timeoutId);\n }\n\n private disconnectExit(exit: Exit) {\n const exitId = exit.uuid;\n\n // Clear the UI state\n this.exitRemovingState.delete(exitId);\n\n // Reset the connection to normal state (this will be redundant as we're about to remove it,\n // but it's safer to do this in case there's any timing issue)\n this.plumber.setConnectionRemovingState(exitId, false);\n\n // Clear any timeout\n if (this.exitRemovalTimeouts.has(exitId)) {\n clearTimeout(this.exitRemovalTimeouts.get(exitId));\n this.exitRemovalTimeouts.delete(exitId);\n }\n\n // Remove the JSPlumb connection\n this.plumber.removeExitConnection(exitId);\n\n // Update the flow definition\n const updatedExit = { ...exit, destination_uuid: null };\n const updatedExits = this.node.exits.map((e) =>\n e.uuid === exitId ? updatedExit : e\n );\n\n // Update the node\n const updatedNode = { ...this.node, exits: updatedExits };\n getStore()?.getState().updateNode(this.node.uuid, updatedNode);\n\n // Request update to reflect changes\n this.requestUpdate();\n }\n\n private handleActionRemoveClick(\n event: MouseEvent,\n action: Action,\n index: number\n ) {\n event.preventDefault();\n event.stopPropagation();\n\n const actionId = action.uuid;\n\n // If the action is already in removing state, perform the removal\n if (this.actionRemovingState.has(actionId)) {\n this.removeAction(action, index);\n return;\n }\n\n // Start removal UI state\n this.actionRemovingState.add(actionId);\n this.requestUpdate();\n\n // Clear any existing timeout for this action\n if (this.actionRemovalTimeouts.has(actionId)) {\n clearTimeout(this.actionRemovalTimeouts.get(actionId));\n }\n\n // Set timeout to reset UI if user doesn't click\n const timeoutId = window.setTimeout(() => {\n this.actionRemovingState.delete(actionId);\n this.actionRemovalTimeouts.delete(actionId);\n this.requestUpdate();\n }, 1000); // 1 second as per requirements\n\n this.actionRemovalTimeouts.set(actionId, timeoutId);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private removeAction(action: Action, _index: number) {\n const actionId = action.uuid;\n\n // Clear the UI state\n this.actionRemovingState.delete(actionId);\n\n // Clear any timeout\n if (this.actionRemovalTimeouts.has(actionId)) {\n clearTimeout(this.actionRemovalTimeouts.get(actionId));\n this.actionRemovalTimeouts.delete(actionId);\n }\n\n // Remove the action from the node\n const updatedActions = this.node.actions.filter((a) => a.uuid !== actionId);\n\n // If no actions remain, remove the entire node\n if (updatedActions.length === 0) {\n this.fireCustomEvent(CustomEventType.NodeDeleted, {\n uuid: this.node.uuid\n });\n } else {\n // Update the node with remaining actions\n const updatedNode = { ...this.node, actions: updatedActions };\n getStore()?.getState().updateNode(this.node.uuid, updatedNode);\n\n // Request update to reflect changes\n this.requestUpdate();\n }\n }\n\n private handleNodeRemoveClick(event: MouseEvent) {\n event.preventDefault();\n event.stopPropagation();\n\n const nodeId = this.node.uuid;\n\n // If the node is already in removing state, perform the removal\n if (this.actionRemovingState.has(nodeId)) {\n this.removeNode();\n return;\n }\n\n // Start removal UI state\n this.actionRemovingState.add(nodeId);\n this.requestUpdate();\n\n // Clear any existing timeout for this node\n if (this.actionRemovalTimeouts.has(nodeId)) {\n clearTimeout(this.actionRemovalTimeouts.get(nodeId));\n }\n\n // Set timeout to reset UI if user doesn't click\n const timeoutId = window.setTimeout(() => {\n this.actionRemovingState.delete(nodeId);\n this.actionRemovalTimeouts.delete(nodeId);\n this.requestUpdate();\n }, 1000); // 1 second as per requirements\n\n this.actionRemovalTimeouts.set(nodeId, timeoutId);\n }\n\n private removeNode() {\n const nodeId = this.node.uuid;\n\n // Clear the UI state\n this.actionRemovingState.delete(nodeId);\n\n // Clear any timeout\n if (this.actionRemovalTimeouts.has(nodeId)) {\n clearTimeout(this.actionRemovalTimeouts.get(nodeId));\n this.actionRemovalTimeouts.delete(nodeId);\n }\n\n // Fire the node deleted event\n this.fireCustomEvent(CustomEventType.NodeDeleted, {\n uuid: this.node.uuid\n });\n }\n\n private handleActionOrderChanged(event: CustomEvent) {\n const [fromIdx, toIdx] = event.detail.swap;\n\n // swap our actions\n const newActions = [...this.node.actions];\n const movedAction = newActions.splice(fromIdx, 1)[0];\n newActions.splice(toIdx, 0, movedAction);\n\n // udate our internal reprensentation, this isn't strictly necessary\n // since the editor will update us from it's definition subscription\n // but it makes testing a lot easier\n this.node = { ...this.node, actions: newActions };\n\n getStore()\n ?.getState()\n .updateNode(this.node.uuid, { ...this.node, actions: newActions });\n }\n\n private handleActionMouseDown(event: MouseEvent, action: Action): void {\n // Don't handle clicks on the remove button, drag handle, or when action is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(action.uuid)\n ) {\n return;\n }\n\n // Store the starting position and action for later comparison\n // Don't prevent default - let the Editor's drag system work normally\n this.actionClickStartPos = { x: event.clientX, y: event.clientY };\n this.pendingActionClick = { action, event };\n }\n\n private handleActionMouseUp(event: MouseEvent, action: Action): void {\n // Don't handle if we don't have a pending click or if it's not the same action\n if (\n !this.pendingActionClick ||\n this.pendingActionClick.action.uuid !== action.uuid\n ) {\n this.actionClickStartPos = null;\n this.pendingActionClick = null;\n return;\n }\n\n // Don't handle clicks on the remove button, drag handle, or when action is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(action.uuid)\n ) {\n this.actionClickStartPos = null;\n this.pendingActionClick = null;\n return;\n }\n\n // Check if the mouse moved beyond the drag threshold\n if (this.actionClickStartPos) {\n const deltaX = event.clientX - this.actionClickStartPos.x;\n const deltaY = event.clientY - this.actionClickStartPos.y;\n const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n\n // Check if the Editor is currently in dragging mode\n const editor = this.closest('temba-flow-editor') as any;\n const editorWasDragging = editor?.dragging;\n\n // Only fire the action edit event if we haven't dragged beyond the threshold\n // AND either there's no Editor parent (test case) or the Editor didn't drag the node\n if (distance <= DRAG_THRESHOLD && (!editor || !editorWasDragging)) {\n // Fire event to request action editing\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action,\n nodeUuid: this.node.uuid\n });\n }\n }\n\n // Clean up\n this.actionClickStartPos = null;\n this.pendingActionClick = null;\n }\n\n private handleActionClick(event: MouseEvent, action: Action): void {\n // This method is kept for backward compatibility but should not be used\n // The new mousedown/mouseup approach handles click vs drag properly\n event.preventDefault();\n event.stopPropagation();\n\n // Don't handle clicks on the remove button or when action is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n this.actionRemovingState.has(action.uuid)\n ) {\n return;\n }\n\n // Fire event to request action editing\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action,\n nodeUuid: this.node.uuid\n });\n }\n\n private handleNodeEditClick(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n\n // Don't handle clicks on the remove button or when node is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n this.actionRemovingState.has(this.node.uuid)\n ) {\n return;\n }\n\n // Fire node edit requested event if the node has a router\n if (this.node.router) {\n // If router node has exactly one action, open the action editor directly\n if (this.node.actions && this.node.actions.length === 1) {\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action: this.node.actions[0],\n nodeUuid: this.node.uuid\n });\n } else {\n // Otherwise open the node editor as before\n this.fireCustomEvent(CustomEventType.NodeEditRequested, {\n node: this.node,\n nodeUI: this.ui\n });\n }\n }\n }\n\n private handleNodeMouseDown(event: MouseEvent): void {\n // Don't handle clicks on the remove button, exits, drag handle, or when node is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.exit') ||\n target.closest('.exit-wrapper') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(this.node.uuid)\n ) {\n return;\n }\n\n // Store the starting position for later comparison\n // Don't prevent default - let the Editor's drag system work normally\n this.nodeClickStartPos = { x: event.clientX, y: event.clientY };\n this.pendingNodeClick = { event };\n }\n\n private handleNodeMouseUp(event: MouseEvent): void {\n // Don't handle if we don't have a pending click\n if (!this.pendingNodeClick) {\n this.nodeClickStartPos = null;\n this.pendingNodeClick = null;\n return;\n }\n\n // Don't handle clicks on the remove button, exits, drag handle, or when node is in removing state\n const target = event.target as HTMLElement;\n if (\n target.closest('.remove-button') ||\n target.closest('.exit') ||\n target.closest('.exit-wrapper') ||\n target.closest('.drag-handle') ||\n this.actionRemovingState.has(this.node.uuid)\n ) {\n this.nodeClickStartPos = null;\n this.pendingNodeClick = null;\n return;\n }\n\n // Check if the mouse moved beyond the drag threshold\n if (this.nodeClickStartPos) {\n const deltaX = event.clientX - this.nodeClickStartPos.x;\n const deltaY = event.clientY - this.nodeClickStartPos.y;\n const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n\n // Check if the Editor is currently in dragging mode\n const editor = this.closest('temba-flow-editor') as any;\n const editorWasDragging = editor?.dragging;\n\n // Only fire the node edit event if we haven't dragged beyond the threshold\n // AND either there's no Editor parent (test case) or the Editor didn't drag the node\n if (distance <= 5 && (!editor || !editorWasDragging)) {\n // Using literal 5 instead of DRAG_THRESHOLD since it's not imported\n // Fire event to request node editing if the node has a router\n if (this.node.router) {\n // If router node has exactly one action, open the action editor directly\n if (this.node.actions && this.node.actions.length === 1) {\n this.fireCustomEvent(CustomEventType.ActionEditRequested, {\n action: this.node.actions[0],\n nodeUuid: this.node.uuid\n });\n } else {\n // Otherwise open the node editor as before\n this.fireCustomEvent(CustomEventType.NodeEditRequested, {\n node: this.node,\n nodeUI: this.ui\n });\n }\n }\n }\n }\n\n // Clean up\n this.nodeClickStartPos = null;\n this.pendingNodeClick = null;\n }\n\n private renderTitle(\n config: ActionConfig,\n action: Action,\n index: number,\n isRemoving: boolean = false\n ) {\n return html`<div class=\"cn-title\" style=\"background:${config.color}\">\n ${this.node?.actions?.length > 1\n ? html`<temba-icon class=\"drag-handle\" name=\"sort\"></temba-icon>`\n : null}\n\n <div class=\"name\">${isRemoving ? 'Remove?' : config.name}</div>\n <div\n class=\"remove-button\"\n @click=${(e: MouseEvent) =>\n this.handleActionRemoveClick(e, action, index)}\n title=\"Remove action\"\n >\n ✕\n </div>\n </div>`;\n }\n\n private renderNodeTitle(config: NodeConfig, isRemoving: boolean = false) {\n return html`<div\n class=\"cn-title ${isRemoving ? 'removing' : ''}\"\n style=\"background:${config.color}\"\n >\n <div class=\"title-spacer\"></div>\n <div class=\"name\">${isRemoving ? 'Remove?' : config.name}</div>\n <div\n class=\"remove-button\"\n @click=${(e: MouseEvent) => this.handleNodeRemoveClick(e)}\n title=\"Remove node\"\n >\n ✕\n </div>\n </div>`;\n }\n\n private renderAction(node: Node, action: Action, index: number) {\n const config = ACTION_CONFIG[action.type];\n const isRemoving = this.actionRemovingState.has(action.uuid);\n\n if (config) {\n return html`<div\n class=\"action sortable ${action.type} ${isRemoving ? 'removing' : ''}\"\n id=\"action-${index}\"\n >\n <div\n class=\"action-content\"\n @mousedown=${(e: MouseEvent) => this.handleActionMouseDown(e, action)}\n @mouseup=${(e: MouseEvent) => this.handleActionMouseUp(e, action)}\n style=\"cursor: pointer; background: #fff\"\n >\n ${this.renderTitle(config, action, index, isRemoving)}\n <div class=\"body\">\n ${config.render\n ? config.render(node, action)\n : html`<pre>${action.type}</pre>`}\n </div>\n </div>\n </div>`;\n }\n return html`<div\n class=\"action sortable ${isRemoving ? 'removing' : ''}\"\n id=\"action-${index}\"\n >\n <div\n class=\"remove-button\"\n @click=${(e: MouseEvent) =>\n this.handleActionRemoveClick(e, action, index)}\n title=\"Remove action\"\n >\n ✕\n </div>\n ${action.type}\n </div>`;\n }\n\n private renderRouter(router: Router, ui: NodeUI) {\n const nodeConfig = NODE_CONFIG[ui.type];\n if (nodeConfig) {\n return html`<div class=\"router\" style=\"position: relative;\">\n ${router.result_name\n ? html`<div\n class=\"body\"\n @mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}\n @mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}\n style=\"cursor: pointer;\"\n >\n Save as\n <div class=\"result-name\">${router.result_name}</div>\n </div>`\n : null}\n </div>`;\n }\n }\n\n private renderCategories(node: Node) {\n if (!node.router || !node.router.categories) {\n return null;\n }\n\n return html`<div class=\"categories\">\n ${repeat(\n node.router.categories,\n (category) => category.uuid,\n (category) => {\n const exit = node.exits.find(\n (exit: Exit) => exit.uuid == category.exit_uuid\n );\n\n return html`<div\n class=\"category\"\n @mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}\n @mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}\n style=\"cursor: pointer;\"\n >\n <div class=\"cn-title\">${category.name}</div>\n ${this.renderExit(exit)}\n </div>`;\n }\n )}\n </div>`;\n }\n\n private renderExit(exit: Exit): TemplateResult {\n return html`<div class=\"exit-wrapper\">\n <div\n id=\"${exit.uuid}\"\n class=${getClasses({\n exit: true,\n connected: !!exit.destination_uuid,\n removing: this.exitRemovingState.has(exit.uuid)\n })}\n @click=${(e: MouseEvent) => this.handleExitClick(e, exit)}\n ></div>\n </div>`;\n }\n\n public render() {\n if (!this.node || !this.ui) {\n return html`<div class=\"node\">Loading...</div>`;\n }\n\n const nodeConfig = NODE_CONFIG[this.ui.type];\n\n return html`\n <div\n id=\"${this.node.uuid}\"\n class=\"node ${this.ui.type === 'execute_actions'\n ? 'execute-actions'\n : ''}\"\n style=\"left:${this.ui.position.left}px;top:${this.ui.position.top}px\"\n >\n ${nodeConfig && nodeConfig.type !== 'execute_actions'\n ? html`<div class=\"router\" style=\"position: relative;\">\n <div\n @mousedown=${(e: MouseEvent) => this.handleNodeMouseDown(e)}\n @mouseup=${(e: MouseEvent) => this.handleNodeMouseUp(e)}\n style=\"cursor: pointer;\"\n >\n ${this.renderNodeTitle(\n nodeConfig,\n this.actionRemovingState.has(this.node.uuid)\n )}\n ${nodeConfig.render ? nodeConfig.render(this.node) : null}\n </div>\n </div>`\n : this.node.actions.length > 0\n ? this.ui.type === 'execute_actions'\n ? html`<temba-sortable-list\n dragHandle=\"drag-handle\"\n @temba-order-changed=\"${this.handleActionOrderChanged}\"\n >\n ${this.node.actions.map((action, index) =>\n this.renderAction(this.node, action, index)\n )}\n </temba-sortable-list>`\n : html`${this.node.actions.map((action, index) =>\n this.renderAction(this.node, action, index)\n )}`\n : ''}\n ${this.node.router\n ? html` ${this.renderRouter(this.node.router, this.ui)}\n ${this.renderCategories(this.node)}`\n : html`<div class=\"action-exits\">\n ${repeat(\n this.node.exits,\n (exit) => exit.uuid,\n (exit) => this.renderExit(exit)\n )}\n </div>`}\n </div>\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send_msg.js","sourceRoot":"","sources":["../../../../src/flow/actions/send_msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAgB,MAAM,EAAoB,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAe,EAAE,EAAE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UAAU,EAAE,EAAE,CACb,OAAO,UAAU,KAAK,QAAQ;gBAC9B,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAClE,CAAC;YAEF,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAM,CAAC,mBAAmB;oBACxB,iDAAiD,CAAC;YACtD,CAAC;YAED,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjC,MAAM,OAAO,GAAG,uDAAuD,CAAC;gBACxE,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;oBAChB,MAAM,CAAC,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { ActionConfig, COLORS, ValidationResult } from '../types';\nimport { Node, SendMsg } from '../../store/flow-definition';\nimport { titleCase } from '../../utils';\n\nexport const send_msg: ActionConfig = {\n name: 'Send Message',\n color: COLORS.send,\n render: (_node: Node, action: SendMsg) => {\n const text = action.text.replace(/\\n/g, '<br>');\n return html`\n ${unsafeHTML(text)}\n ${action.quick_replies?.length > 0\n ? html`<div class=\"quick-replies\">\n ${action.quick_replies.map((reply) => {\n return html`<div class=\"quick-reply\">${reply}</div>`;\n })}\n ${action.template\n ? html`<div\n style=\"border: 1px solid var(--color-widget-border);padding: 0.5em;margin-top: 1em;border-radius: var(--curvature); display:flex;background: rgba(0,0,0,.03);\"\n >\n <temba-icon name=\"channel_wac\"></temba-icon>\n <div style=\"margin-left:0.5em\">${action.template.name}</div>\n </div>`\n : null}\n </div>`\n : null}\n `;\n },\n form: {\n text: {\n type: 'message-editor',\n label: 'Message',\n helpText:\n 'Enter the message to send with optional attachments. You can use expressions like @contact.name',\n required: true,\n evaluated: true,\n placeholder: 'Type your message here...',\n maxAttachments: 10,\n accept: '',\n endpoint: '/api/v2/media.json',\n counter: 'temba-charcount',\n gsm: true,\n autogrow: true\n },\n quick_replies: {\n type: 'select',\n options: [],\n multi: true,\n tags: true,\n searchable: true,\n placeholder: 'Add quick replies...',\n maxItems: 10,\n evaluated: true\n },\n runtime_attachments: {\n type: 'array',\n helpText: 'Add dynamic attachments using expressions',\n itemLabel: 'Attachment',\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.expression || item.expression.trim() === '';\n },\n itemConfig: {\n type: {\n type: 'select',\n options: [\n { value: 'image', name: 'Image' },\n { value: 'audio', name: 'Audio' },\n { value: 'video', name: 'Video' },\n { value: 'document', name: 'Document' }\n ],\n required: true,\n searchable: false\n },\n expression: {\n type: 'text',\n placeholder: 'Expression (e.g. @contact.photo)',\n required: true,\n evaluated: true\n }\n }\n }\n },\n layout: [\n 'text',\n {\n type: 'group',\n label: 'Quick Replies',\n items: ['quick_replies'],\n collapsible: true,\n collapsed: (formData: any) => {\n // Collapse only if there are no quick replies\n return !formData.quick_replies || formData.quick_replies.length === 0;\n },\n getGroupValueCount: (formData: any) => {\n return formData.quick_replies?.length || 0;\n }\n },\n {\n type: 'group',\n label: 'Runtime Attachments',\n items: ['runtime_attachments'],\n collapsible: true,\n collapsed: true,\n helpText: 'Add dynamic attachments that are evaluated at runtime',\n getGroupValueCount: (formData: any) => {\n return (\n formData.runtime_attachments?.filter(\n (item: any) =>\n item && item.expression && item.expression.trim() !== ''\n ).length || 0\n );\n }\n }\n ],\n toFormData: (action: SendMsg) => {\n // Extract runtime attachments from the text field attachments\n const runtimeAttachments: {\n type: { name: string; value: string };\n expression: string;\n }[] = [];\n const staticAttachments: string[] = [];\n\n if (action.attachments && Array.isArray(action.attachments)) {\n action.attachments.forEach((attachment) => {\n if (typeof attachment === 'string' && attachment.includes(':')) {\n const colonIndex = attachment.indexOf(':');\n const contentType = attachment.substring(0, colonIndex);\n const value = attachment.substring(colonIndex + 1);\n\n if (!contentType.includes('/')) {\n runtimeAttachments.push({\n type: { name: titleCase(contentType), value: contentType },\n expression: value\n });\n } else {\n staticAttachments.push(attachment);\n }\n }\n });\n }\n\n return {\n uuid: action.uuid,\n text: action.text || '',\n attachments: staticAttachments,\n runtime_attachments: runtimeAttachments,\n quick_replies: (action.quick_replies || []).map((reply) => ({\n name: reply,\n value: reply\n }))\n };\n },\n fromFormData: (data: Record<string, any>) => {\n const result = {\n uuid: data.uuid,\n type: 'send_msg',\n text: data.text || '',\n attachments: [],\n quick_replies: (data.quick_replies || []).map((reply: any) =>\n typeof reply === 'string' ? reply : reply.value || reply.name || reply\n )\n };\n\n // Combine static attachments from text field with runtime attachments\n const staticAttachments = data.attachments || [];\n const runtimeAttachments = (data.runtime_attachments || [])\n .filter(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => item && item.type && item.expression\n ) // Filter out invalid items\n .map(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => `${item.type[0].value}:${item.expression}`\n );\n\n result.attachments = [...staticAttachments, ...runtimeAttachments];\n\n // Remove quick_replies if empty to match original format\n if (result.quick_replies.length === 0) {\n delete (result as any).quick_replies;\n }\n\n return result as SendMsg;\n },\n sanitize: (formData: any): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n },\n validate: (action: SendMsg): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!action.text || action.text.trim() === '') {\n errors.text = 'Message text is required';\n }\n\n const attachments = action.attachments || [];\n if (attachments.length > 10) {\n const staticAttachments = attachments.filter(\n (attachment) =>\n typeof attachment === 'string' &&\n attachment.substring(0, attachment.indexOf(':')).includes('/')\n );\n\n const runtimeAttachments = attachments.filter(\n (attachment) =>\n typeof attachment === 'string' &&\n !attachment.substring(0, attachment.indexOf(':')).includes('/')\n );\n\n if (runtimeAttachments.length > 0) {\n errors.runtime_attachments =\n 'Each message can only have up to 10 attachments';\n }\n\n if (staticAttachments.length > 0) {\n const message = 'Each message can only have up to 10 total attachments';\n if (errors.text) {\n errors.text += ` ${message}`;\n } else {\n errors.text = message;\n }\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"send_msg.js","sourceRoot":"","sources":["../../../../src/flow/actions/send_msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAgB,MAAM,EAAoB,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,MAAM,EAAE,CAAC,KAAW,EAAE,MAAe,EAAE,EAAE;;QACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChD,OAAO,IAAI,CAAA;QACP,UAAU,CAAC,IAAI,CAAC;QAChB,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,MAAM,IAAG,CAAC;YAChC,CAAC,CAAC,IAAI,CAAA;cACA,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACnC,OAAO,IAAI,CAAA,4BAA4B,KAAK,QAAQ,CAAC;YACvD,CAAC,CAAC;cACA,MAAM,CAAC,QAAQ;gBACf,CAAC,CAAC,IAAI,CAAA;;;;mDAI+B,MAAM,CAAC,QAAQ,CAAC,I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BAChB,MAAM,CAAC,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YACvC,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit-html';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\nimport { ActionConfig, COLORS, ValidationResult } from '../types';\nimport { Node, SendMsg } from '../../store/flow-definition';\nimport { titleCase } from '../../utils';\n\nexport const send_msg: ActionConfig = {\n name: 'Send Message',\n color: COLORS.send,\n render: (_node: Node, action: SendMsg) => {\n const text = action.text.replace(/\\n/g, '<br>');\n return html`\n ${unsafeHTML(text)}\n ${action.quick_replies?.length > 0\n ? html`<div class=\"quick-replies\">\n ${action.quick_replies.map((reply) => {\n return html`<div class=\"quick-reply\">${reply}</div>`;\n })}\n ${action.template\n ? html`<div\n style=\"border: 1px solid var(--color-widget-border);padding: 0.5em;margin-top: 1em;border-radius: var(--curvature); display:flex;background: rgba(0,0,0,.03);\"\n >\n <temba-icon name=\"channel_wac\"></temba-icon>\n <div style=\"margin-left:0.5em\">${action.template.name}</div>\n </div>`\n : null}\n </div>`\n : null}\n `;\n },\n form: {\n text: {\n type: 'message-editor',\n label: 'Message',\n helpText:\n 'Enter the message to send with optional attachments. You can use expressions like @contact.name',\n required: true,\n evaluated: true,\n placeholder: 'Type your message here...',\n maxAttachments: 10,\n accept: '',\n endpoint: '/api/v2/media.json',\n counter: 'temba-charcount',\n gsm: true,\n autogrow: true\n },\n quick_replies: {\n type: 'select',\n options: [],\n multi: true,\n tags: true,\n searchable: true,\n placeholder: 'Add quick replies...',\n maxItems: 10,\n evaluated: true\n },\n runtime_attachments: {\n type: 'array',\n helpText: 'Add dynamic attachments using expressions',\n itemLabel: 'Attachment',\n sortable: true,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.expression || item.expression.trim() === '';\n },\n itemConfig: {\n type: {\n type: 'select',\n options: [\n { value: 'image', name: 'Image' },\n { value: 'audio', name: 'Audio' },\n { value: 'video', name: 'Video' },\n { value: 'document', name: 'Document' }\n ],\n required: true,\n searchable: false\n },\n expression: {\n type: 'text',\n placeholder: 'Expression (e.g. @contact.photo)',\n required: true,\n evaluated: true\n }\n }\n }\n },\n layout: [\n 'text',\n {\n type: 'group',\n label: 'Quick Replies',\n items: ['quick_replies'],\n collapsible: true,\n collapsed: (formData: any) => {\n // Collapse only if there are no quick replies\n return !formData.quick_replies || formData.quick_replies.length === 0;\n },\n getGroupValueCount: (formData: any) => {\n return formData.quick_replies?.length || 0;\n }\n },\n {\n type: 'group',\n label: 'Runtime Attachments',\n items: ['runtime_attachments'],\n collapsible: true,\n collapsed: true,\n helpText: 'Add dynamic attachments that are evaluated at runtime',\n getGroupValueCount: (formData: any) => {\n return (\n formData.runtime_attachments?.filter(\n (item: any) =>\n item && item.expression && item.expression.trim() !== ''\n ).length || 0\n );\n }\n }\n ],\n toFormData: (action: SendMsg) => {\n // Extract runtime attachments from the text field attachments\n const runtimeAttachments: {\n type: { name: string; value: string };\n expression: string;\n }[] = [];\n const staticAttachments: string[] = [];\n\n if (action.attachments && Array.isArray(action.attachments)) {\n action.attachments.forEach((attachment) => {\n if (typeof attachment === 'string' && attachment.includes(':')) {\n const colonIndex = attachment.indexOf(':');\n const contentType = attachment.substring(0, colonIndex);\n const value = attachment.substring(colonIndex + 1);\n\n if (!contentType.includes('/')) {\n runtimeAttachments.push({\n type: { name: titleCase(contentType), value: contentType },\n expression: value\n });\n } else {\n staticAttachments.push(attachment);\n }\n }\n });\n }\n\n return {\n uuid: action.uuid,\n text: action.text || '',\n attachments: staticAttachments,\n runtime_attachments: runtimeAttachments,\n quick_replies: (action.quick_replies || []).map((reply) => ({\n name: reply,\n value: reply\n }))\n };\n },\n fromFormData: (data: Record<string, any>) => {\n const result = {\n uuid: data.uuid,\n type: 'send_msg',\n text: data.text || '',\n attachments: [],\n quick_replies: (data.quick_replies || []).map((reply: any) =>\n typeof reply === 'string' ? reply : reply.value || reply.name || reply\n )\n };\n\n // Combine static attachments from text field with runtime attachments\n const staticAttachments = data.attachments || [];\n const runtimeAttachments = (data.runtime_attachments || [])\n .filter(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => item && item.type && item.expression\n ) // Filter out invalid items\n .map(\n (item: {\n type: [{ name: string; value: string }];\n expression: string;\n }) => `${item.type[0].value}:${item.expression}`\n );\n\n result.attachments = [...staticAttachments, ...runtimeAttachments];\n\n // Remove quick_replies if empty to match original format\n if (result.quick_replies.length === 0) {\n delete (result as any).quick_replies;\n }\n\n return result as SendMsg;\n },\n sanitize: (formData: any): void => {\n if (formData.text && typeof formData.text === 'string') {\n formData.text = formData.text.trim();\n }\n },\n validate: (action: SendMsg): ValidationResult => {\n const errors: { [key: string]: string } = {};\n\n if (!action.text || action.text.trim() === '') {\n errors.text = 'Message text is required';\n }\n\n const attachments = action.attachments || [];\n if (attachments.length > 10) {\n const staticAttachments = attachments.filter(\n (attachment) =>\n typeof attachment === 'string' &&\n attachment.substring(0, attachment.indexOf(':')).includes('/')\n );\n\n const runtimeAttachments = attachments.filter(\n (attachment) =>\n typeof attachment === 'string' &&\n !attachment.substring(0, attachment.indexOf(':')).includes('/')\n );\n\n if (runtimeAttachments.length > 0) {\n errors.runtime_attachments =\n 'Each message can only have up to 10 attachments';\n }\n\n if (staticAttachments.length > 0) {\n const message = 'Each message can only have up to 10 total attachments';\n if (errors.text) {\n errors.text += ` ${message}`;\n } else {\n errors.text = message;\n }\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n }\n};\n"]}
|
|
@@ -1,7 +1,155 @@
|
|
|
1
1
|
import { COLORS } from '../types';
|
|
2
|
+
import { generateUUID } from '../../utils';
|
|
3
|
+
// Helper function to create a switch router with group cases
|
|
4
|
+
const createGroupRouter = (userGroups, existingCategories = [], existingExits = [], existingCases = []) => {
|
|
5
|
+
const categories = [];
|
|
6
|
+
const exits = [];
|
|
7
|
+
const cases = [];
|
|
8
|
+
// Create categories, exits, and cases for each selected group
|
|
9
|
+
userGroups.forEach((group) => {
|
|
10
|
+
// Try to find existing category by group name
|
|
11
|
+
const existingCategory = existingCategories.find((cat) => cat.name === group.name);
|
|
12
|
+
const existingExit = existingCategory
|
|
13
|
+
? existingExits.find((exit) => exit.uuid === existingCategory.exit_uuid)
|
|
14
|
+
: null;
|
|
15
|
+
const existingCase = existingCases.find((c) => { var _a; return ((_a = c.arguments) === null || _a === void 0 ? void 0 : _a[0]) === group.uuid; });
|
|
16
|
+
const exitUuid = (existingExit === null || existingExit === void 0 ? void 0 : existingExit.uuid) || generateUUID();
|
|
17
|
+
const categoryUuid = (existingCategory === null || existingCategory === void 0 ? void 0 : existingCategory.uuid) || generateUUID();
|
|
18
|
+
const caseUuid = (existingCase === null || existingCase === void 0 ? void 0 : existingCase.uuid) || generateUUID();
|
|
19
|
+
categories.push({
|
|
20
|
+
uuid: categoryUuid,
|
|
21
|
+
name: group.name,
|
|
22
|
+
exit_uuid: exitUuid
|
|
23
|
+
});
|
|
24
|
+
exits.push({
|
|
25
|
+
uuid: exitUuid,
|
|
26
|
+
destination_uuid: (existingExit === null || existingExit === void 0 ? void 0 : existingExit.destination_uuid) || null
|
|
27
|
+
});
|
|
28
|
+
cases.push({
|
|
29
|
+
uuid: caseUuid,
|
|
30
|
+
type: 'has_group',
|
|
31
|
+
arguments: [group.uuid, group.name],
|
|
32
|
+
category_uuid: categoryUuid
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
// Add default "Other" category for contacts not in any selected group
|
|
36
|
+
const existingOtherCategory = existingCategories.find((cat) => cat.name === 'Other' &&
|
|
37
|
+
!userGroups.some((group) => group.name === cat.name));
|
|
38
|
+
const existingOtherExit = existingOtherCategory
|
|
39
|
+
? existingExits.find((exit) => exit.uuid === existingOtherCategory.exit_uuid)
|
|
40
|
+
: null;
|
|
41
|
+
const otherExitUuid = (existingOtherExit === null || existingOtherExit === void 0 ? void 0 : existingOtherExit.uuid) || generateUUID();
|
|
42
|
+
const otherCategoryUuid = (existingOtherCategory === null || existingOtherCategory === void 0 ? void 0 : existingOtherCategory.uuid) || generateUUID();
|
|
43
|
+
categories.push({
|
|
44
|
+
uuid: otherCategoryUuid,
|
|
45
|
+
name: 'Other',
|
|
46
|
+
exit_uuid: otherExitUuid
|
|
47
|
+
});
|
|
48
|
+
exits.push({
|
|
49
|
+
uuid: otherExitUuid,
|
|
50
|
+
destination_uuid: (existingOtherExit === null || existingOtherExit === void 0 ? void 0 : existingOtherExit.destination_uuid) || null
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
router: {
|
|
54
|
+
type: 'switch',
|
|
55
|
+
cases: cases,
|
|
56
|
+
categories: categories,
|
|
57
|
+
default_category_uuid: otherCategoryUuid,
|
|
58
|
+
operand: '@contact.groups',
|
|
59
|
+
result_name: ''
|
|
60
|
+
},
|
|
61
|
+
exits: exits
|
|
62
|
+
};
|
|
63
|
+
};
|
|
2
64
|
export const split_by_groups = {
|
|
3
65
|
type: 'split_by_groups',
|
|
4
66
|
name: 'Split by Group',
|
|
5
|
-
color: COLORS.split
|
|
67
|
+
color: COLORS.split,
|
|
68
|
+
form: {
|
|
69
|
+
groups: {
|
|
70
|
+
type: 'select',
|
|
71
|
+
label: 'Groups',
|
|
72
|
+
helpText: 'Select the groups to split contacts by. Contacts will be routed based on their group membership.',
|
|
73
|
+
required: true,
|
|
74
|
+
options: [],
|
|
75
|
+
multi: true,
|
|
76
|
+
searchable: true,
|
|
77
|
+
endpoint: '/api/v2/groups.json',
|
|
78
|
+
valueKey: 'uuid',
|
|
79
|
+
nameKey: 'name',
|
|
80
|
+
placeholder: 'Search for groups...',
|
|
81
|
+
allowCreate: true,
|
|
82
|
+
createArbitraryOption: (input, options) => {
|
|
83
|
+
// Check if a group with this name already exists
|
|
84
|
+
const existing = options.find((option) => option.name.toLowerCase().trim() === input.toLowerCase().trim());
|
|
85
|
+
if (!existing && input.trim()) {
|
|
86
|
+
return {
|
|
87
|
+
name: input.trim(),
|
|
88
|
+
arbitrary: true
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
layout: ['groups'],
|
|
96
|
+
validate: (formData) => {
|
|
97
|
+
const errors = {};
|
|
98
|
+
if (!formData.groups ||
|
|
99
|
+
!Array.isArray(formData.groups) ||
|
|
100
|
+
formData.groups.length === 0) {
|
|
101
|
+
errors.groups = 'At least one group is required';
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
valid: Object.keys(errors).length === 0,
|
|
105
|
+
errors
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
toFormData: (node) => {
|
|
109
|
+
var _a;
|
|
110
|
+
// Extract groups from the existing node structure
|
|
111
|
+
const groups = [];
|
|
112
|
+
if ((_a = node.router) === null || _a === void 0 ? void 0 : _a.cases) {
|
|
113
|
+
node.router.cases.forEach((c) => {
|
|
114
|
+
var _a;
|
|
115
|
+
if (c.type === 'has_group' && ((_a = c.arguments) === null || _a === void 0 ? void 0 : _a.length) >= 2) {
|
|
116
|
+
groups.push({
|
|
117
|
+
uuid: c.arguments[0],
|
|
118
|
+
name: c.arguments[1]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
uuid: node.uuid,
|
|
125
|
+
groups: groups
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
fromFormData: (formData, originalNode) => {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
// Get selected groups
|
|
131
|
+
const selectedGroups = (formData.groups || [])
|
|
132
|
+
.filter((group) => (group === null || group === void 0 ? void 0 : group.uuid) || (group === null || group === void 0 ? void 0 : group.arbitrary))
|
|
133
|
+
.map((group) => ({
|
|
134
|
+
uuid: group.uuid || generateUUID(), // Generate UUID for arbitrary groups
|
|
135
|
+
name: group.name
|
|
136
|
+
}));
|
|
137
|
+
// Create router and exits using existing data when possible
|
|
138
|
+
const existingCategories = ((_a = originalNode.router) === null || _a === void 0 ? void 0 : _a.categories) || [];
|
|
139
|
+
const existingExits = originalNode.exits || [];
|
|
140
|
+
const existingCases = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.cases) || [];
|
|
141
|
+
const { router, exits } = createGroupRouter(selectedGroups, existingCategories, existingExits, existingCases);
|
|
142
|
+
// Return the complete node
|
|
143
|
+
return {
|
|
144
|
+
uuid: originalNode.uuid,
|
|
145
|
+
actions: originalNode.actions || [],
|
|
146
|
+
router: router,
|
|
147
|
+
exits: exits
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
router: {
|
|
151
|
+
type: 'switch',
|
|
152
|
+
operand: '@contact.groups'
|
|
153
|
+
}
|
|
6
154
|
};
|
|
7
155
|
//# sourceMappingURL=split_by_groups.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_groups.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAe;IACzC,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,MAAM,CAAC,KAAK;CACpB,CAAC","sourcesContent":["import { COLORS, NodeConfig } from '../types';\n\nexport const split_by_groups: NodeConfig = {\n type: 'split_by_groups',\n name: 'Split by Group',\n color: COLORS.split\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_groups.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAE9C,O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,EAAE,CAAC,QAAa,EAAE,YAAkB,EAAQ,EAAE;;QACxD,sBAAsB;QACtB,MAAM,cAAc,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;aAC3C,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAA,CAAC;aACvD,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,YAAY,EAAE,EAAE,qCAAqC;YACzE,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC,CAAC;QAEN,4DAA4D;QAC5D,MAAM,kBAAkB,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,UAAU,KAAI,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB,CACzC,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,iBAAiB;KAC3B;CACF,CAAC","sourcesContent":["import { COLORS, NodeConfig } from '../types';\nimport { Node, Category, Exit, Case } from '../../store/flow-definition.d';\nimport { generateUUID } from '../../utils';\n\n// Helper function to create a switch router with group cases\nconst createGroupRouter = (\n userGroups: { uuid: string; name: string }[],\n existingCategories: Category[] = [],\n existingExits: Exit[] = [],\n existingCases: Case[] = []\n) => {\n const categories: Category[] = [];\n const exits: Exit[] = [];\n const cases: Case[] = [];\n\n // Create categories, exits, and cases for each selected group\n userGroups.forEach((group) => {\n // Try to find existing category by group name\n const existingCategory = existingCategories.find(\n (cat) => cat.name === group.name\n );\n const existingExit = existingCategory\n ? existingExits.find((exit) => exit.uuid === existingCategory.exit_uuid)\n : null;\n const existingCase = existingCases.find(\n (c) => c.arguments?.[0] === group.uuid\n );\n\n const exitUuid = existingExit?.uuid || generateUUID();\n const categoryUuid = existingCategory?.uuid || generateUUID();\n const caseUuid = existingCase?.uuid || generateUUID();\n\n categories.push({\n uuid: categoryUuid,\n name: group.name,\n exit_uuid: exitUuid\n });\n\n exits.push({\n uuid: exitUuid,\n destination_uuid: existingExit?.destination_uuid || null\n });\n\n cases.push({\n uuid: caseUuid,\n type: 'has_group',\n arguments: [group.uuid, group.name],\n category_uuid: categoryUuid\n });\n });\n\n // Add default \"Other\" category for contacts not in any selected group\n const existingOtherCategory = existingCategories.find(\n (cat) =>\n cat.name === 'Other' &&\n !userGroups.some((group) => group.name === cat.name)\n );\n const existingOtherExit = existingOtherCategory\n ? existingExits.find(\n (exit) => exit.uuid === existingOtherCategory.exit_uuid\n )\n : null;\n\n const otherExitUuid = existingOtherExit?.uuid || generateUUID();\n const otherCategoryUuid = existingOtherCategory?.uuid || generateUUID();\n\n categories.push({\n uuid: otherCategoryUuid,\n name: 'Other',\n exit_uuid: otherExitUuid\n });\n\n exits.push({\n uuid: otherExitUuid,\n destination_uuid: existingOtherExit?.destination_uuid || null\n });\n\n return {\n router: {\n type: 'switch' as const,\n cases: cases,\n categories: categories,\n default_category_uuid: otherCategoryUuid,\n operand: '@contact.groups',\n result_name: ''\n },\n exits: exits\n };\n};\n\nexport const split_by_groups: NodeConfig = {\n type: 'split_by_groups',\n name: 'Split by Group',\n color: COLORS.split,\n form: {\n groups: {\n type: 'select',\n label: 'Groups',\n helpText:\n 'Select the groups to split contacts by. Contacts will be routed based on their group membership.',\n required: true,\n options: [],\n multi: true,\n searchable: true,\n endpoint: '/api/v2/groups.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Search for groups...',\n allowCreate: true,\n createArbitraryOption: (input: string, options: any[]) => {\n // Check if a group with this name already exists\n const existing = options.find(\n (option) =>\n option.name.toLowerCase().trim() === input.toLowerCase().trim()\n );\n if (!existing && input.trim()) {\n return {\n name: input.trim(),\n arbitrary: true\n };\n }\n return null;\n }\n }\n },\n layout: ['groups'],\n validate: (formData: any) => {\n const errors: { [key: string]: string } = {};\n\n if (\n !formData.groups ||\n !Array.isArray(formData.groups) ||\n formData.groups.length === 0\n ) {\n errors.groups = 'At least one group is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node) => {\n // Extract groups from the existing node structure\n const groups: { uuid: string; name: string }[] = [];\n\n if (node.router?.cases) {\n node.router.cases.forEach((c: Case) => {\n if (c.type === 'has_group' && c.arguments?.length >= 2) {\n groups.push({\n uuid: c.arguments[0],\n name: c.arguments[1]\n });\n }\n });\n }\n\n return {\n uuid: node.uuid,\n groups: groups\n };\n },\n fromFormData: (formData: any, originalNode: Node): Node => {\n // Get selected groups\n const selectedGroups = (formData.groups || [])\n .filter((group: any) => group?.uuid || group?.arbitrary)\n .map((group: any) => ({\n uuid: group.uuid || generateUUID(), // Generate UUID for arbitrary groups\n name: group.name\n }));\n\n // Create router and exits using existing data when possible\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createGroupRouter(\n selectedGroups,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: originalNode.actions || [],\n router: router,\n exits: exits\n };\n },\n router: {\n type: 'switch',\n operand: '@contact.groups'\n }\n};\n"]}
|