@nyaruka/temba-components 0.131.3 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/demo/components/flow/example.html +1 -0
- package/demo/static/css/tailwind.css +30019 -0
- package/dist/temba-components.js +449 -417
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/display/Chat.js +26 -6
- package/out-tsc/src/display/Chat.js.map +1 -1
- package/out-tsc/src/display/FloatingTab.js +4 -4
- package/out-tsc/src/display/FloatingTab.js.map +1 -1
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +124 -58
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +89 -40
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeTypeSelector.js +8 -2
- package/out-tsc/src/flow/NodeTypeSelector.js.map +1 -1
- package/out-tsc/src/flow/config.js +17 -4
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +2 -2
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_run_result.js +6 -0
- package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/layout/FloatingWindow.js +1 -2
- package/out-tsc/src/layout/FloatingWindow.js.map +1 -1
- package/out-tsc/src/list/ContentMenu.js +1 -0
- package/out-tsc/src/list/ContentMenu.js.map +1 -1
- package/out-tsc/src/list/SortableList.js +3 -2
- package/out-tsc/src/list/SortableList.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +105 -69
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/src/store/AppState.js +39 -1
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/src/utils.js +3 -3
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/test/ActionHelper.js +6 -5
- package/out-tsc/test/ActionHelper.js.map +1 -1
- package/out-tsc/test/actions/send_broadcast.test.js +1 -1
- package/out-tsc/test/actions/send_broadcast.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_run_result.test.js +83 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -1
- package/out-tsc/test/temba-backwards-compatibility.test.js +30 -0
- package/out-tsc/test/temba-backwards-compatibility.test.js.map +1 -0
- package/out-tsc/test/temba-contact-chat.test.js +28 -13
- package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
- package/out-tsc/test/temba-floating-window.test.js +0 -2
- package/out-tsc/test/temba-floating-window.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor-node.test.js +109 -0
- package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
- package/out-tsc/test/temba-localization.test.js +24 -5
- package/out-tsc/test/temba-localization.test.js.map +1 -1
- package/out-tsc/test/temba-node-type-selector.test.js +70 -3
- package/out-tsc/test/temba-node-type-selector.test.js.map +1 -1
- package/out-tsc/test/temba-utils-uuid.test.js +45 -1
- package/out-tsc/test/temba-utils-uuid.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +3 -3
- package/out-tsc/test/utils.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/add_contact_urn/render/expression-facebook.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/whatsapp.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_broadcast/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/with-attachments.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/long-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/actions/start_session/render/contact-query.png +0 -0
- package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/many-recipients.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/floating-tab/default.png +0 -0
- package/screenshots/truth/floating-tab/gray.png +0 -0
- package/screenshots/truth/floating-tab/green.png +0 -0
- package/screenshots/truth/floating-tab/hover.png +0 -0
- package/screenshots/truth/floating-tab/purple.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/translation-task.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/render/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
- package/src/display/Chat.ts +29 -7
- package/src/display/FloatingTab.ts +4 -4
- package/src/events.ts +1 -4
- package/src/flow/CanvasNode.ts +130 -57
- package/src/flow/Editor.ts +107 -40
- package/src/flow/NodeTypeSelector.ts +7 -1
- package/src/flow/config.ts +22 -4
- package/src/flow/nodes/split_by_llm_categorize.ts +2 -8
- package/src/flow/nodes/split_by_run_result.ts +7 -0
- package/src/flow/types.ts +2 -0
- package/src/layout/FloatingWindow.ts +1 -3
- package/src/list/ContentMenu.ts +1 -0
- package/src/list/SortableList.ts +3 -2
- package/src/live/ContactChat.ts +112 -78
- package/src/store/AppState.ts +53 -1
- package/src/utils.ts +3 -3
- package/test/ActionHelper.ts +13 -5
- package/test/actions/send_broadcast.test.ts +2 -1
- package/test/nodes/split_by_run_result.test.ts +99 -0
- package/test/temba-backwards-compatibility.test.ts +37 -0
- package/test/temba-contact-chat.test.ts +28 -13
- package/test/temba-floating-window.test.ts +0 -2
- package/test/temba-flow-editor-node.test.ts +129 -0
- package/test/temba-localization.test.ts +29 -5
- package/test/temba-node-type-selector.test.ts +89 -3
- package/test/temba-utils-uuid.test.ts +61 -1
- package/test/utils.test.ts +8 -3
- package/test-assets/contacts/history.json +22 -9
- package/web-test-runner.config.mjs +3 -3
|
@@ -267,8 +267,11 @@ export class NodeTypeSelector extends RapidElement {
|
|
|
267
267
|
const splitsByGroup = new Map();
|
|
268
268
|
// Collect regular actions (from ACTION_CONFIG, unless hideFromActions is true)
|
|
269
269
|
Object.entries(ACTION_CONFIG)
|
|
270
|
-
.filter(([
|
|
271
|
-
|
|
270
|
+
.filter(([type, config]) => {
|
|
271
|
+
// exclude aliases - if config has aliases, check if this type is an alias
|
|
272
|
+
const isAlias = config.aliases && config.aliases.includes(type);
|
|
273
|
+
return (!isAlias &&
|
|
274
|
+
config.name &&
|
|
272
275
|
!config.hideFromActions &&
|
|
273
276
|
config.group &&
|
|
274
277
|
this.isConfigAvailable(config));
|
|
@@ -286,6 +289,7 @@ export class NodeTypeSelector extends RapidElement {
|
|
|
286
289
|
Object.entries(NODE_CONFIG)
|
|
287
290
|
.filter(([type, config]) => {
|
|
288
291
|
return (type !== 'execute_actions' &&
|
|
292
|
+
type === config.type && // exclude aliases (type won't match config.type for aliases)
|
|
289
293
|
config.name &&
|
|
290
294
|
config.showAsAction &&
|
|
291
295
|
config.group &&
|
|
@@ -361,7 +365,9 @@ export class NodeTypeSelector extends RapidElement {
|
|
|
361
365
|
.filter(([type, config]) => {
|
|
362
366
|
// exclude execute_actions (it's the default action-only node)
|
|
363
367
|
// exclude nodes that have showAsAction=true (they appear in action mode)
|
|
368
|
+
// exclude aliases (type won't match config.type for aliases)
|
|
364
369
|
return (type !== 'execute_actions' &&
|
|
370
|
+
type === config.type &&
|
|
365
371
|
config.name &&
|
|
366
372
|
!config.showAsAction &&
|
|
367
373
|
this.isConfigAvailable(config));
|
|
@@ -1 +1 @@
|
|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ACvB;AAGb;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACwC;AAG5D;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACS;AAG7B;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDACK;AAGvB;IADP,KAAK,EAAE;uDAC+B","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { CustomEventType } from '../interfaces';\nimport { NODE_CONFIG, ACTION_CONFIG } from './config';\nimport {\n NodeConfig,\n ActionConfig,\n ACTION_GROUPS,\n SPLIT_GROUPS,\n ACTION_GROUP_METADATA,\n SPLIT_GROUP_METADATA\n} from './types';\n\n/**\n * Event detail for node type selection\n */\nexport interface NodeTypeSelection {\n nodeType: string;\n position: { x: number; y: number };\n}\n\n/**\n * Categorizes node types for display\n */\ninterface NodeCategory {\n name: string;\n description: string;\n color: string;\n items: Array<{ type: string; config: NodeConfig | ActionConfig }>;\n isBranching?: boolean; // true if this category contains actions that branch/split\n}\n\n/**\n * NodeTypeSelector - A dialog for selecting which type of node to create\n * Shows categorized lists of available actions and splits\n */\nexport class NodeTypeSelector extends RapidElement {\n static get styles() {\n return css`\n :host {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10001;\n display: none;\n }\n\n :host([open]) {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n }\n\n .dialog {\n position: relative;\n background: white;\n border-radius: var(--curvature);\n box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);\n max-width: 700px;\n max-height: 80vh;\n width: 90%;\n display: flex;\n flex-direction: column;\n }\n\n .header {\n padding: 1.5em;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n }\n\n .header h2 {\n margin: 0;\n font-size: 1.5rem;\n font-weight: 600;\n color: var(--color-text-dark);\n }\n\n .content {\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n padding: 0;\n }\n\n .section-regular {\n padding: 1.5em;\n }\n\n .section-branching {\n background: linear-gradient(\n 135deg,\n rgba(170, 170, 170, 0.12),\n rgba(170, 170, 170, 0.08)\n );\n padding: 1.5em;\n margin: 0 -1.5em;\n padding-left: 3em;\n padding-right: 3em;\n }\n\n .section-header {\n margin-bottom: 1.5em;\n padding-top: 1em;\n }\n\n .section-title {\n font-weight: 700;\n font-size: 1.1rem;\n color: var(--color-text-dark);\n margin-bottom: 0.35em;\n display: flex;\n align-items: center;\n }\n\n .section-title::before {\n content: '';\n display: inline-block;\n height: 1.2em;\n background: linear-gradient(\n 135deg,\n var(--color-primary-dark),\n var(--color-primary)\n );\n border-radius: 2px;\n }\n\n .section-description {\n font-size: 0.9rem;\n color: var(--color-text);\n opacity: 0.7;\n margin-left: 0em;\n padding-bottom: 1em;\n }\n\n .category {\n margin-bottom: 2em;\n }\n\n .category:last-child {\n margin-bottom: 0;\n }\n\n .category-title {\n font-weight: 600;\n color: var(--color-text-dark);\n margin-bottom: 0.5em;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n font-size: 0.9rem;\n opacity: 0.7;\n }\n\n .category-description {\n font-size: 0.85rem;\n color: var(--color-text);\n opacity: 0.6;\n margin-bottom: 0.75em;\n line-height: 1.4;\n }\n\n .items-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\n gap: 0.75em;\n }\n\n .node-item {\n padding: 1em;\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: calc(var(--curvature) * 0.75);\n cursor: pointer;\n transition: all 0.15s ease;\n background: white;\n position: relative;\n overflow: hidden;\n }\n\n .node-item::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 4px;\n height: 100%;\n background: var(--item-color, rgba(0, 0, 0, 0.1));\n }\n\n .node-item:hover {\n border-color: var(--item-color, var(--color-primary));\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n transform: translateY(-1px);\n }\n\n .node-item:hover::before {\n width: 6px;\n }\n\n .node-item-title {\n font-weight: 500;\n font-size: 1rem;\n color: var(--color-text-dark);\n margin-bottom: 0.25em;\n }\n\n .node-item-type {\n font-size: 0.75rem;\n color: var(--color-text);\n opacity: 0.6;\n font-family: monospace;\n }\n\n .footer {\n padding: 1em 1.5em;\n border-top: 1px solid rgba(0, 0, 0, 0.1);\n display: flex;\n justify-content: flex-end;\n }\n\n temba-button {\n --button-y: 0.5em;\n --button-x: 1.25em;\n }\n `;\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String })\n public mode: 'action' | 'split' | 'action-no-branching' = 'action';\n\n @property({ type: String })\n public flowType: string = 'message';\n\n @property({ type: Array })\n public features: string[] = [];\n\n @state()\n private clickPosition = { x: 0, y: 0 };\n\n public show(\n mode: 'action' | 'split' | 'action-no-branching',\n position: { x: number; y: number }\n ) {\n this.mode = mode;\n this.clickPosition = position;\n this.open = true;\n }\n\n public close() {\n this.open = false;\n }\n\n /**\n * Check if a config is available for the current flow type and features\n */\n private isConfigAvailable(config: NodeConfig | ActionConfig): boolean {\n // Check flow type filter\n if (config.flowTypes !== undefined) {\n // Empty array means not available for any flow type in selector\n if (config.flowTypes.length === 0) {\n return false;\n }\n // Non-empty array means check if current flow type is included\n if (!config.flowTypes.includes(this.flowType as any)) {\n return false;\n }\n }\n // undefined/null flowTypes means available for all flow types\n\n // Check features filter - all required features must be present\n if (config.features && config.features.length > 0) {\n for (const requiredFeature of config.features) {\n if (!this.features.includes(requiredFeature)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n private handleNodeTypeClick(nodeType: string) {\n this.fireCustomEvent(CustomEventType.Selection, {\n nodeType,\n position: this.clickPosition\n } as NodeTypeSelection);\n this.close();\n }\n\n private handleOverlayClick() {\n this.close();\n }\n\n private getCategories(): NodeCategory[] {\n if (this.mode === 'action' || this.mode === 'action-no-branching') {\n // Group actions by group\n const actionsByGroup = new Map<\n string,\n Array<{ type: string; config: ActionConfig }>\n >();\n const splitsByGroup = new Map<\n string,\n Array<{ type: string; config: NodeConfig }>\n >();\n\n // Collect regular actions (from ACTION_CONFIG, unless hideFromActions is true)\n Object.entries(ACTION_CONFIG)\n .filter(([_, config]) => {\n return (\n config.name &&\n !config.hideFromActions &&\n config.group &&\n this.isConfigAvailable(config)\n );\n })\n .forEach(([type, config]) => {\n const group = config.group;\n if (!actionsByGroup.has(group)) {\n actionsByGroup.set(group, []);\n }\n actionsByGroup.get(group)!.push({ type, config });\n });\n\n // Collect nodes that have showAsAction=true (these appear as \"with split\" actions)\n // Only if we're not in 'action-no-branching' mode\n if (this.mode === 'action') {\n Object.entries(NODE_CONFIG)\n .filter(([type, config]) => {\n return (\n type !== 'execute_actions' &&\n config.name &&\n config.showAsAction &&\n config.group &&\n this.isConfigAvailable(config)\n );\n })\n .forEach(([type, config]) => {\n const group = config.group!;\n if (!splitsByGroup.has(group)) {\n splitsByGroup.set(group, []);\n }\n splitsByGroup.get(group)!.push({ type, config });\n });\n }\n\n // Build categories - first regular actions, then splitting actions\n const categories: NodeCategory[] = [];\n\n // Get the implicit order from ACTION_GROUPS object\n const actionGroupOrder = Object.keys(ACTION_GROUPS);\n // Get the implicit order of actions from ACTION_CONFIG\n const actionConfigOrder = Object.keys(ACTION_CONFIG);\n\n // Add regular action categories sorted by implicit order\n const sortedActionCategories = Array.from(actionsByGroup.entries()).sort(\n ([groupA], [groupB]) => {\n const orderA = actionGroupOrder.indexOf(groupA);\n const orderB = actionGroupOrder.indexOf(groupB);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n }\n );\n\n sortedActionCategories.forEach(([group, items]) => {\n const metadata = ACTION_GROUP_METADATA[group];\n // Sort items within the category by their order in ACTION_CONFIG\n const sortedItems = items.sort((a, b) => {\n const orderA = actionConfigOrder.indexOf(a.type);\n const orderB = actionConfigOrder.indexOf(b.type);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n categories.push({\n name: metadata.title,\n description: metadata.description,\n color: metadata.color,\n items: sortedItems,\n isBranching: false\n });\n });\n\n // Add splitting action categories (with modified description to indicate they split)\n // Also sorted by implicit order\n // Get the implicit order of nodes from NODE_CONFIG\n const nodeConfigOrder = Object.keys(NODE_CONFIG);\n\n const sortedSplitCategories = Array.from(splitsByGroup.entries()).sort(\n ([groupA], [groupB]) => {\n const orderA = actionGroupOrder.indexOf(groupA);\n const orderB = actionGroupOrder.indexOf(groupB);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n }\n );\n\n sortedSplitCategories.forEach(([group, items]) => {\n const metadata = ACTION_GROUP_METADATA[group];\n // Sort items within the category by their order in NODE_CONFIG\n const sortedItems = items.sort((a, b) => {\n const orderA = nodeConfigOrder.indexOf(a.type);\n const orderB = nodeConfigOrder.indexOf(b.type);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n categories.push({\n name: metadata.title,\n description: metadata.description,\n color: metadata.color,\n items: sortedItems,\n isBranching: true\n });\n });\n\n return categories;\n } else {\n // Group splits by group\n const itemsByGroup = new Map<\n string,\n Array<{ type: string; config: NodeConfig }>\n >();\n\n Object.entries(NODE_CONFIG)\n .filter(([type, config]) => {\n // exclude execute_actions (it's the default action-only node)\n // exclude nodes that have showAsAction=true (they appear in action mode)\n return (\n type !== 'execute_actions' &&\n config.name &&\n !config.showAsAction &&\n this.isConfigAvailable(config)\n );\n })\n .forEach(([type, config]) => {\n const group = config.group || SPLIT_GROUPS.split;\n if (!itemsByGroup.has(group)) {\n itemsByGroup.set(group, []);\n }\n itemsByGroup.get(group)!.push({ type, config });\n });\n\n // Convert to categories using group metadata, sorted by implicit order from SPLIT_GROUPS\n const splitGroupOrder = Object.keys(SPLIT_GROUPS);\n // Get the implicit order of nodes from NODE_CONFIG\n const nodeConfigOrder = Object.keys(NODE_CONFIG);\n\n return Array.from(itemsByGroup.entries())\n .map(([group, items]) => {\n const metadata =\n SPLIT_GROUP_METADATA[group] || ACTION_GROUP_METADATA[group];\n // Sort items within the category by their order in NODE_CONFIG\n const sortedItems = items.sort((a, b) => {\n const orderA = nodeConfigOrder.indexOf(a.type);\n const orderB = nodeConfigOrder.indexOf(b.type);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n return {\n name: metadata.title,\n description: metadata.description,\n color: metadata.color,\n items: sortedItems\n };\n })\n .sort((a, b) => {\n // Find the group key by looking up metadata by title\n const groupA = Object.keys(SPLIT_GROUP_METADATA).find(\n (key) => SPLIT_GROUP_METADATA[key].title === a.name\n )!;\n const groupB = Object.keys(SPLIT_GROUP_METADATA).find(\n (key) => SPLIT_GROUP_METADATA[key].title === b.name\n )!;\n const orderA = splitGroupOrder.indexOf(groupA);\n const orderB = splitGroupOrder.indexOf(groupB);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n }\n }\n\n public render(): TemplateResult {\n if (!this.open) {\n return html``;\n }\n\n const categories = this.getCategories();\n const title =\n this.mode === 'split'\n ? 'Select a Split'\n : this.mode === 'action-no-branching'\n ? 'Add Action'\n : 'Select an Action';\n\n // Separate regular and branching categories for action mode\n const regularCategories = categories.filter((c) => !c.isBranching);\n const branchingCategories = categories.filter((c) => c.isBranching);\n const hasBranchingSection = branchingCategories.length > 0;\n\n return html`\n <div class=\"overlay\" @click=${this.handleOverlayClick}></div>\n <div class=\"dialog\" @click=${(e: Event) => e.stopPropagation()}>\n <div class=\"header\">\n <h2>${title}</h2>\n </div>\n <div class=\"content\">\n ${this.mode === 'action' || this.mode === 'action-no-branching'\n ? html`\n <div class=\"section-regular\">\n ${regularCategories.map(\n (category) => html`\n <div class=\"category\">\n <div class=\"category-title\">${category.name}</div>\n <div class=\"category-description\">\n ${category.description}\n </div>\n <div class=\"items-grid\">\n ${category.items.map(\n (item) => html`\n <div\n class=\"node-item\"\n style=\"--item-color: ${category.color}\"\n @click=${() =>\n this.handleNodeTypeClick(item.type)}\n >\n <div class=\"node-item-title\">\n ${item.config.name}\n </div>\n <div class=\"node-item-type\">${item.type}</div>\n </div>\n `\n )}\n </div>\n </div>\n `\n )}\n </div>\n ${hasBranchingSection\n ? html`\n <div class=\"section-branching\">\n <div class=\"section-header\">\n <div class=\"section-title\">Actions that Branch</div>\n <div class=\"section-description\">\n These actions also split the flow based on their\n outcome\n </div>\n </div>\n ${branchingCategories.map(\n (category) => html`\n <div class=\"category\">\n <div class=\"category-title\">${category.name}</div>\n <div class=\"category-description\">\n ${category.description}\n </div>\n <div class=\"items-grid\">\n ${category.items.map(\n (item) => html`\n <div\n class=\"node-item\"\n style=\"--item-color: ${category.color}\"\n @click=${() =>\n this.handleNodeTypeClick(item.type)}\n >\n <div class=\"node-item-title\">\n ${item.config.name}\n </div>\n <div class=\"node-item-type\">\n ${item.type}\n </div>\n </div>\n `\n )}\n </div>\n </div>\n `\n )}\n </div>\n `\n : ''}\n `\n : html`\n <div class=\"section-regular\">\n ${categories.map(\n (category) => html`\n <div class=\"category\">\n <div class=\"category-title\">${category.name}</div>\n <div class=\"category-description\">\n ${category.description}\n </div>\n <div class=\"items-grid\">\n ${category.items.map(\n (item) => html`\n <div\n class=\"node-item\"\n style=\"--item-color: ${category.color}\"\n @click=${() =>\n this.handleNodeTypeClick(item.type)}\n >\n <div class=\"node-item-title\">\n ${item.config.name}\n </div>\n <div class=\"node-item-type\">${item.type}</div>\n </div>\n `\n )}\n </div>\n </div>\n `\n )}\n </div>\n `}\n </div>\n <div class=\"footer\">\n <temba-button @click=${this.close} secondary>Cancel</temba-button>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NodeTypeSelector.js","sourceRoot":"","sources":["../../../src/flow/NodeTypeSelector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,E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,KAAK;;;KAGtC,CAAC;IACJ,CAAC;CACF;AAnZQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACvB;AAGb;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACwC;AAG5D;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACS;AAG7B;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDACK;AAGvB;IADP,KAAK,EAAE;uDAC+B","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { CustomEventType } from '../interfaces';\nimport { NODE_CONFIG, ACTION_CONFIG } from './config';\nimport {\n NodeConfig,\n ActionConfig,\n ACTION_GROUPS,\n SPLIT_GROUPS,\n ACTION_GROUP_METADATA,\n SPLIT_GROUP_METADATA\n} from './types';\n\n/**\n * Event detail for node type selection\n */\nexport interface NodeTypeSelection {\n nodeType: string;\n position: { x: number; y: number };\n}\n\n/**\n * Categorizes node types for display\n */\ninterface NodeCategory {\n name: string;\n description: string;\n color: string;\n items: Array<{ type: string; config: NodeConfig | ActionConfig }>;\n isBranching?: boolean; // true if this category contains actions that branch/split\n}\n\n/**\n * NodeTypeSelector - A dialog for selecting which type of node to create\n * Shows categorized lists of available actions and splits\n */\nexport class NodeTypeSelector extends RapidElement {\n static get styles() {\n return css`\n :host {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10001;\n display: none;\n }\n\n :host([open]) {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n }\n\n .dialog {\n position: relative;\n background: white;\n border-radius: var(--curvature);\n box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);\n max-width: 700px;\n max-height: 80vh;\n width: 90%;\n display: flex;\n flex-direction: column;\n }\n\n .header {\n padding: 1.5em;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n }\n\n .header h2 {\n margin: 0;\n font-size: 1.5rem;\n font-weight: 600;\n color: var(--color-text-dark);\n }\n\n .content {\n overflow-y: auto;\n overflow-x: hidden;\n flex: 1;\n padding: 0;\n }\n\n .section-regular {\n padding: 1.5em;\n }\n\n .section-branching {\n background: linear-gradient(\n 135deg,\n rgba(170, 170, 170, 0.12),\n rgba(170, 170, 170, 0.08)\n );\n padding: 1.5em;\n margin: 0 -1.5em;\n padding-left: 3em;\n padding-right: 3em;\n }\n\n .section-header {\n margin-bottom: 1.5em;\n padding-top: 1em;\n }\n\n .section-title {\n font-weight: 700;\n font-size: 1.1rem;\n color: var(--color-text-dark);\n margin-bottom: 0.35em;\n display: flex;\n align-items: center;\n }\n\n .section-title::before {\n content: '';\n display: inline-block;\n height: 1.2em;\n background: linear-gradient(\n 135deg,\n var(--color-primary-dark),\n var(--color-primary)\n );\n border-radius: 2px;\n }\n\n .section-description {\n font-size: 0.9rem;\n color: var(--color-text);\n opacity: 0.7;\n margin-left: 0em;\n padding-bottom: 1em;\n }\n\n .category {\n margin-bottom: 2em;\n }\n\n .category:last-child {\n margin-bottom: 0;\n }\n\n .category-title {\n font-weight: 600;\n color: var(--color-text-dark);\n margin-bottom: 0.5em;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n font-size: 0.9rem;\n opacity: 0.7;\n }\n\n .category-description {\n font-size: 0.85rem;\n color: var(--color-text);\n opacity: 0.6;\n margin-bottom: 0.75em;\n line-height: 1.4;\n }\n\n .items-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\n gap: 0.75em;\n }\n\n .node-item {\n padding: 1em;\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: calc(var(--curvature) * 0.75);\n cursor: pointer;\n transition: all 0.15s ease;\n background: white;\n position: relative;\n overflow: hidden;\n }\n\n .node-item::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 4px;\n height: 100%;\n background: var(--item-color, rgba(0, 0, 0, 0.1));\n }\n\n .node-item:hover {\n border-color: var(--item-color, var(--color-primary));\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n transform: translateY(-1px);\n }\n\n .node-item:hover::before {\n width: 6px;\n }\n\n .node-item-title {\n font-weight: 500;\n font-size: 1rem;\n color: var(--color-text-dark);\n margin-bottom: 0.25em;\n }\n\n .node-item-type {\n font-size: 0.75rem;\n color: var(--color-text);\n opacity: 0.6;\n font-family: monospace;\n }\n\n .footer {\n padding: 1em 1.5em;\n border-top: 1px solid rgba(0, 0, 0, 0.1);\n display: flex;\n justify-content: flex-end;\n }\n\n temba-button {\n --button-y: 0.5em;\n --button-x: 1.25em;\n }\n `;\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n @property({ type: String })\n public mode: 'action' | 'split' | 'action-no-branching' = 'action';\n\n @property({ type: String })\n public flowType: string = 'message';\n\n @property({ type: Array })\n public features: string[] = [];\n\n @state()\n private clickPosition = { x: 0, y: 0 };\n\n public show(\n mode: 'action' | 'split' | 'action-no-branching',\n position: { x: number; y: number }\n ) {\n this.mode = mode;\n this.clickPosition = position;\n this.open = true;\n }\n\n public close() {\n this.open = false;\n }\n\n /**\n * Check if a config is available for the current flow type and features\n */\n private isConfigAvailable(config: NodeConfig | ActionConfig): boolean {\n // Check flow type filter\n if (config.flowTypes !== undefined) {\n // Empty array means not available for any flow type in selector\n if (config.flowTypes.length === 0) {\n return false;\n }\n // Non-empty array means check if current flow type is included\n if (!config.flowTypes.includes(this.flowType as any)) {\n return false;\n }\n }\n // undefined/null flowTypes means available for all flow types\n\n // Check features filter - all required features must be present\n if (config.features && config.features.length > 0) {\n for (const requiredFeature of config.features) {\n if (!this.features.includes(requiredFeature)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n private handleNodeTypeClick(nodeType: string) {\n this.fireCustomEvent(CustomEventType.Selection, {\n nodeType,\n position: this.clickPosition\n } as NodeTypeSelection);\n this.close();\n }\n\n private handleOverlayClick() {\n this.close();\n }\n\n private getCategories(): NodeCategory[] {\n if (this.mode === 'action' || this.mode === 'action-no-branching') {\n // Group actions by group\n const actionsByGroup = new Map<\n string,\n Array<{ type: string; config: ActionConfig }>\n >();\n const splitsByGroup = new Map<\n string,\n Array<{ type: string; config: NodeConfig }>\n >();\n\n // Collect regular actions (from ACTION_CONFIG, unless hideFromActions is true)\n Object.entries(ACTION_CONFIG)\n .filter(([type, config]) => {\n // exclude aliases - if config has aliases, check if this type is an alias\n const isAlias = config.aliases && config.aliases.includes(type);\n return (\n !isAlias &&\n config.name &&\n !config.hideFromActions &&\n config.group &&\n this.isConfigAvailable(config)\n );\n })\n .forEach(([type, config]) => {\n const group = config.group;\n if (!actionsByGroup.has(group)) {\n actionsByGroup.set(group, []);\n }\n actionsByGroup.get(group)!.push({ type, config });\n });\n\n // Collect nodes that have showAsAction=true (these appear as \"with split\" actions)\n // Only if we're not in 'action-no-branching' mode\n if (this.mode === 'action') {\n Object.entries(NODE_CONFIG)\n .filter(([type, config]) => {\n return (\n type !== 'execute_actions' &&\n type === config.type && // exclude aliases (type won't match config.type for aliases)\n config.name &&\n config.showAsAction &&\n config.group &&\n this.isConfigAvailable(config)\n );\n })\n .forEach(([type, config]) => {\n const group = config.group!;\n if (!splitsByGroup.has(group)) {\n splitsByGroup.set(group, []);\n }\n splitsByGroup.get(group)!.push({ type, config });\n });\n }\n\n // Build categories - first regular actions, then splitting actions\n const categories: NodeCategory[] = [];\n\n // Get the implicit order from ACTION_GROUPS object\n const actionGroupOrder = Object.keys(ACTION_GROUPS);\n // Get the implicit order of actions from ACTION_CONFIG\n const actionConfigOrder = Object.keys(ACTION_CONFIG);\n\n // Add regular action categories sorted by implicit order\n const sortedActionCategories = Array.from(actionsByGroup.entries()).sort(\n ([groupA], [groupB]) => {\n const orderA = actionGroupOrder.indexOf(groupA);\n const orderB = actionGroupOrder.indexOf(groupB);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n }\n );\n\n sortedActionCategories.forEach(([group, items]) => {\n const metadata = ACTION_GROUP_METADATA[group];\n // Sort items within the category by their order in ACTION_CONFIG\n const sortedItems = items.sort((a, b) => {\n const orderA = actionConfigOrder.indexOf(a.type);\n const orderB = actionConfigOrder.indexOf(b.type);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n categories.push({\n name: metadata.title,\n description: metadata.description,\n color: metadata.color,\n items: sortedItems,\n isBranching: false\n });\n });\n\n // Add splitting action categories (with modified description to indicate they split)\n // Also sorted by implicit order\n // Get the implicit order of nodes from NODE_CONFIG\n const nodeConfigOrder = Object.keys(NODE_CONFIG);\n\n const sortedSplitCategories = Array.from(splitsByGroup.entries()).sort(\n ([groupA], [groupB]) => {\n const orderA = actionGroupOrder.indexOf(groupA);\n const orderB = actionGroupOrder.indexOf(groupB);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n }\n );\n\n sortedSplitCategories.forEach(([group, items]) => {\n const metadata = ACTION_GROUP_METADATA[group];\n // Sort items within the category by their order in NODE_CONFIG\n const sortedItems = items.sort((a, b) => {\n const orderA = nodeConfigOrder.indexOf(a.type);\n const orderB = nodeConfigOrder.indexOf(b.type);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n categories.push({\n name: metadata.title,\n description: metadata.description,\n color: metadata.color,\n items: sortedItems,\n isBranching: true\n });\n });\n\n return categories;\n } else {\n // Group splits by group\n const itemsByGroup = new Map<\n string,\n Array<{ type: string; config: NodeConfig }>\n >();\n\n Object.entries(NODE_CONFIG)\n .filter(([type, config]) => {\n // exclude execute_actions (it's the default action-only node)\n // exclude nodes that have showAsAction=true (they appear in action mode)\n // exclude aliases (type won't match config.type for aliases)\n return (\n type !== 'execute_actions' &&\n type === config.type &&\n config.name &&\n !config.showAsAction &&\n this.isConfigAvailable(config)\n );\n })\n .forEach(([type, config]) => {\n const group = config.group || SPLIT_GROUPS.split;\n if (!itemsByGroup.has(group)) {\n itemsByGroup.set(group, []);\n }\n itemsByGroup.get(group)!.push({ type, config });\n });\n\n // Convert to categories using group metadata, sorted by implicit order from SPLIT_GROUPS\n const splitGroupOrder = Object.keys(SPLIT_GROUPS);\n // Get the implicit order of nodes from NODE_CONFIG\n const nodeConfigOrder = Object.keys(NODE_CONFIG);\n\n return Array.from(itemsByGroup.entries())\n .map(([group, items]) => {\n const metadata =\n SPLIT_GROUP_METADATA[group] || ACTION_GROUP_METADATA[group];\n // Sort items within the category by their order in NODE_CONFIG\n const sortedItems = items.sort((a, b) => {\n const orderA = nodeConfigOrder.indexOf(a.type);\n const orderB = nodeConfigOrder.indexOf(b.type);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n return {\n name: metadata.title,\n description: metadata.description,\n color: metadata.color,\n items: sortedItems\n };\n })\n .sort((a, b) => {\n // Find the group key by looking up metadata by title\n const groupA = Object.keys(SPLIT_GROUP_METADATA).find(\n (key) => SPLIT_GROUP_METADATA[key].title === a.name\n )!;\n const groupB = Object.keys(SPLIT_GROUP_METADATA).find(\n (key) => SPLIT_GROUP_METADATA[key].title === b.name\n )!;\n const orderA = splitGroupOrder.indexOf(groupA);\n const orderB = splitGroupOrder.indexOf(groupB);\n return (\n (orderA === -1 ? 999 : orderA) - (orderB === -1 ? 999 : orderB)\n );\n });\n }\n }\n\n public render(): TemplateResult {\n if (!this.open) {\n return html``;\n }\n\n const categories = this.getCategories();\n const title =\n this.mode === 'split'\n ? 'Select a Split'\n : this.mode === 'action-no-branching'\n ? 'Add Action'\n : 'Select an Action';\n\n // Separate regular and branching categories for action mode\n const regularCategories = categories.filter((c) => !c.isBranching);\n const branchingCategories = categories.filter((c) => c.isBranching);\n const hasBranchingSection = branchingCategories.length > 0;\n\n return html`\n <div class=\"overlay\" @click=${this.handleOverlayClick}></div>\n <div class=\"dialog\" @click=${(e: Event) => e.stopPropagation()}>\n <div class=\"header\">\n <h2>${title}</h2>\n </div>\n <div class=\"content\">\n ${this.mode === 'action' || this.mode === 'action-no-branching'\n ? html`\n <div class=\"section-regular\">\n ${regularCategories.map(\n (category) => html`\n <div class=\"category\">\n <div class=\"category-title\">${category.name}</div>\n <div class=\"category-description\">\n ${category.description}\n </div>\n <div class=\"items-grid\">\n ${category.items.map(\n (item) => html`\n <div\n class=\"node-item\"\n style=\"--item-color: ${category.color}\"\n @click=${() =>\n this.handleNodeTypeClick(item.type)}\n >\n <div class=\"node-item-title\">\n ${item.config.name}\n </div>\n <div class=\"node-item-type\">${item.type}</div>\n </div>\n `\n )}\n </div>\n </div>\n `\n )}\n </div>\n ${hasBranchingSection\n ? html`\n <div class=\"section-branching\">\n <div class=\"section-header\">\n <div class=\"section-title\">Actions that Branch</div>\n <div class=\"section-description\">\n These actions also split the flow based on their\n outcome\n </div>\n </div>\n ${branchingCategories.map(\n (category) => html`\n <div class=\"category\">\n <div class=\"category-title\">${category.name}</div>\n <div class=\"category-description\">\n ${category.description}\n </div>\n <div class=\"items-grid\">\n ${category.items.map(\n (item) => html`\n <div\n class=\"node-item\"\n style=\"--item-color: ${category.color}\"\n @click=${() =>\n this.handleNodeTypeClick(item.type)}\n >\n <div class=\"node-item-title\">\n ${item.config.name}\n </div>\n <div class=\"node-item-type\">\n ${item.type}\n </div>\n </div>\n `\n )}\n </div>\n </div>\n `\n )}\n </div>\n `\n : ''}\n `\n : html`\n <div class=\"section-regular\">\n ${categories.map(\n (category) => html`\n <div class=\"category\">\n <div class=\"category-title\">${category.name}</div>\n <div class=\"category-description\">\n ${category.description}\n </div>\n <div class=\"items-grid\">\n ${category.items.map(\n (item) => html`\n <div\n class=\"node-item\"\n style=\"--item-color: ${category.color}\"\n @click=${() =>\n this.handleNodeTypeClick(item.type)}\n >\n <div class=\"node-item-title\">\n ${item.config.name}\n </div>\n <div class=\"node-item-type\">${item.type}</div>\n </div>\n `\n )}\n </div>\n </div>\n `\n )}\n </div>\n `}\n </div>\n <div class=\"footer\">\n <temba-button @click=${this.close} secondary>Cancel</temba-button>\n </div>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -36,7 +36,7 @@ import { split_by_llm_categorize } from './nodes/split_by_llm_categorize';
|
|
|
36
36
|
import { wait_for_digits } from './nodes/wait_for_digits';
|
|
37
37
|
import { wait_for_menu } from './nodes/wait_for_menu';
|
|
38
38
|
import { wait_for_response } from './nodes/wait_for_response';
|
|
39
|
-
export const ACTION_CONFIG = {
|
|
39
|
+
export const ACTION_CONFIG = registerConfigWithAliases({
|
|
40
40
|
say_msg,
|
|
41
41
|
play_audio,
|
|
42
42
|
set_contact_field,
|
|
@@ -54,8 +54,21 @@ export const ACTION_CONFIG = {
|
|
|
54
54
|
add_contact_urn,
|
|
55
55
|
add_input_labels,
|
|
56
56
|
request_optin
|
|
57
|
-
};
|
|
58
|
-
|
|
57
|
+
});
|
|
58
|
+
// Helper to register a config and its aliases
|
|
59
|
+
function registerConfigWithAliases(config) {
|
|
60
|
+
const result = { ...config };
|
|
61
|
+
// Register aliases for each config
|
|
62
|
+
Object.values(config).forEach((cfg) => {
|
|
63
|
+
if (cfg.aliases) {
|
|
64
|
+
cfg.aliases.forEach((alias) => {
|
|
65
|
+
result[alias] = cfg;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
export const NODE_CONFIG = registerConfigWithAliases({
|
|
59
72
|
execute_actions,
|
|
60
73
|
split_by_contact_field,
|
|
61
74
|
split_by_expression,
|
|
@@ -73,5 +86,5 @@ export const NODE_CONFIG = {
|
|
|
73
86
|
wait_for_menu,
|
|
74
87
|
wait_for_response,
|
|
75
88
|
split_by_airtime
|
|
76
|
-
};
|
|
89
|
+
});
|
|
77
90
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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utilities\nexport * from './types';\nimport type { ActionConfig, NodeConfig } from './types';\n\n// Import all action configurations\nimport { add_input_labels } from './actions/add_input_labels';\nimport { add_contact_urn } from './actions/add_contact_urn';\nimport { set_contact_field } from './actions/set_contact_field';\nimport { set_contact_channel } from './actions/set_contact_channel';\nimport { set_contact_language } from './actions/set_contact_language';\nimport { set_contact_status } from './actions/set_contact_status';\nimport { send_broadcast } from './actions/send_broadcast';\nimport { set_run_result } from './actions/set_run_result';\nimport { send_msg } from './actions/send_msg';\nimport { send_email } from './actions/send_email';\nimport { start_session } from './actions/start_session';\nimport { set_contact_name } from './actions/set_contact_name';\nimport { add_contact_groups } from './actions/add_contact_groups';\nimport { remove_contact_groups } from './actions/remove_contact_groups';\nimport { request_optin } from './actions/request_optin';\nimport { say_msg } from './actions/say_msg';\nimport { play_audio } from './actions/play_audio';\n\n// Import all node configurations\nimport { execute_actions } from './nodes/execute_actions';\nimport { split_by_airtime } from './nodes/split_by_airtime';\nimport { split_by_contact_field } from './nodes/split_by_contact_field';\nimport { split_by_expression } from './nodes/split_by_expression';\nimport { split_by_groups } from './nodes/split_by_groups';\nimport { split_by_random } from './nodes/split_by_random';\nimport { split_by_run_result } from './nodes/split_by_run_result';\nimport { split_by_scheme } from './nodes/split_by_scheme';\nimport { split_by_subflow } from './nodes/split_by_subflow';\nimport { split_by_ticket } from './nodes/split_by_ticket';\nimport { split_by_webhook } from './nodes/split_by_webhook';\nimport { split_by_resthook } from './nodes/split_by_resthook';\nimport { split_by_llm } from './nodes/split_by_llm';\nimport { split_by_llm_categorize } from './nodes/split_by_llm_categorize';\nimport { wait_for_digits } from './nodes/wait_for_digits';\nimport { wait_for_menu } from './nodes/wait_for_menu';\nimport { wait_for_response } from './nodes/wait_for_response';\n\nexport const ACTION_CONFIG: {\n [key: string]: ActionConfig;\n} = registerConfigWithAliases({\n say_msg,\n play_audio,\n set_contact_field,\n send_broadcast,\n set_run_result,\n send_msg,\n send_email,\n start_session,\n set_contact_name,\n add_contact_groups,\n remove_contact_groups,\n set_contact_channel,\n set_contact_language,\n set_contact_status,\n add_contact_urn,\n add_input_labels,\n request_optin\n});\n\n// Helper to register a config and its aliases\nfunction registerConfigWithAliases<T extends NodeConfig | ActionConfig>(\n config: Record<string, T>\n): Record<string, T> {\n const result = { ...config };\n\n // Register aliases for each config\n Object.values(config).forEach((cfg) => {\n if (cfg.aliases) {\n cfg.aliases.forEach((alias) => {\n result[alias] = cfg;\n });\n }\n });\n\n return result;\n}\n\nexport const NODE_CONFIG: {\n [key: string]: NodeConfig;\n} = registerConfigWithAliases({\n execute_actions,\n split_by_contact_field,\n split_by_expression,\n split_by_groups,\n split_by_llm,\n split_by_llm_categorize,\n split_by_random,\n split_by_run_result,\n split_by_scheme,\n split_by_subflow,\n split_by_ticket,\n split_by_webhook,\n split_by_resthook,\n wait_for_digits,\n wait_for_menu,\n wait_for_response,\n split_by_airtime\n});\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION_GROUPS,
|
|
1
|
+
import { ACTION_GROUPS, Features } from '../types';
|
|
2
2
|
import { generateUUID, createMultiCategoryRouter } from '../../utils';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
import { categoriesToLocalizationFormData, localizationFormDataToCategories } from './shared';
|
|
@@ -6,7 +6,7 @@ export const split_by_llm_categorize = {
|
|
|
6
6
|
type: 'split_by_llm_categorize',
|
|
7
7
|
name: 'Split by AI',
|
|
8
8
|
group: ACTION_GROUPS.services,
|
|
9
|
-
flowTypes: [
|
|
9
|
+
flowTypes: [],
|
|
10
10
|
features: [Features.AI],
|
|
11
11
|
form: {
|
|
12
12
|
llm: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_llm_categorize.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm_categorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,SAAS,EACT,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YA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cesContent":["import {\n FormData,\n NodeConfig,\n ACTION_GROUPS,\n FlowTypes,\n Features\n} from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createMultiCategoryRouter } from '../../utils';\nimport { html } from 'lit';\nimport {\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_llm_categorize',\n name: 'Split by AI',\n group: ACTION_GROUPS.services,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n features: [Features.AI],\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n helpText: 'Select the LLM to use for categorization',\n required: true,\n endpoint: '/test-assets/select/llms.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input to categorize (usually @input)',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n categories: {\n type: 'array',\n label: 'Categories',\n helpText: 'Define the categories for classification',\n required: true,\n sortable: true,\n itemLabel: 'Category',\n minItems: 1,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Category name',\n required: true\n }\n }\n }\n },\n layout: ['llm', 'input', 'categories'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate category names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div class=\"body\">Categorize with ${callLlmAction.llm.name}</div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as any;\n const categories =\n node.router?.categories\n ?.filter((cat) => cat.name !== 'Other' && cat.name !== 'Failure')\n .map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n categories: categories\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action (using any type to match the example format)\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: `@(prompt(\"categorize\", slice(node.categories, 0, -2)))`,\n input: formData.input || '@input',\n output_local: '_llm_output'\n };\n\n // Create categories and exits\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createMultiCategoryRouter(\n '@locals._llm_output',\n userCategories,\n (categoryName) => ({\n type: 'has_only_text',\n arguments: [categoryName]\n }),\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_llm_categorize.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_llm_categorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa,CAAC,QAAQ;IAC7B,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;IACvB,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,+BAA+B;YACzC,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,kBAAkB;SAChC;QACD,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,0CAA0C;YACpD,QAAQ,EAAE,IAAI;YACd,SAAS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AC,YAAY,EAAE,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,YAAY,CAAC;SAC1B,CAAC,EACF,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { FormData, NodeConfig, ACTION_GROUPS, Features } from '../types';\nimport { CallLLM, Node } from '../../store/flow-definition';\nimport { generateUUID, createMultiCategoryRouter } from '../../utils';\nimport { html } from 'lit';\nimport {\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\n\nexport const split_by_llm_categorize: NodeConfig = {\n type: 'split_by_llm_categorize',\n name: 'Split by AI',\n group: ACTION_GROUPS.services,\n flowTypes: [],\n features: [Features.AI],\n form: {\n llm: {\n type: 'select',\n label: 'LLM',\n helpText: 'Select the LLM to use for categorization',\n required: true,\n endpoint: '/test-assets/select/llms.json',\n valueKey: 'uuid',\n nameKey: 'name',\n placeholder: 'Select an LLM...'\n },\n input: {\n type: 'text',\n label: 'Input',\n helpText: 'The input to categorize (usually @input)',\n required: true,\n evaluated: true,\n placeholder: '@input'\n },\n categories: {\n type: 'array',\n label: 'Categories',\n helpText: 'Define the categories for classification',\n required: true,\n sortable: true,\n itemLabel: 'Category',\n minItems: 1,\n maxItems: 10,\n isEmptyItem: (item: any) => {\n return !item.name || item.name.trim() === '';\n },\n itemConfig: {\n name: {\n type: 'text',\n placeholder: 'Category name',\n required: true\n }\n }\n }\n },\n layout: ['llm', 'input', 'categories'],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Check for duplicate category names\n if (formData.categories && Array.isArray(formData.categories)) {\n const categories = formData.categories.filter(\n (item: any) => item?.name && item.name.trim() !== ''\n );\n\n // Find all categories that have duplicates (case-insensitive)\n const duplicateCategories = [];\n const lowerCaseMap = new Map();\n\n // First pass: map lowercase names to all original cases\n categories.forEach((category) => {\n const lowerName = category.name.trim().toLowerCase();\n if (!lowerCaseMap.has(lowerName)) {\n lowerCaseMap.set(lowerName, []);\n }\n lowerCaseMap.get(lowerName).push(category.name.trim());\n });\n\n // Second pass: collect all names that appear more than once\n lowerCaseMap.forEach((originalNames) => {\n if (originalNames.length > 1) {\n duplicateCategories.push(...originalNames);\n }\n });\n\n if (duplicateCategories.length > 0) {\n const uniqueDuplicates = [...new Set(duplicateCategories)];\n errors.categories = `Duplicate category names found: ${uniqueDuplicates.join(\n ', '\n )}`;\n }\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n render: (node: Node) => {\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as CallLLM;\n return html`\n <div class=\"body\">Categorize with ${callLlmAction.llm.name}</div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callLlmAction = node.actions?.find(\n (action) => action.type === 'call_llm'\n ) as any;\n const categories =\n node.router?.categories\n ?.filter((cat) => cat.name !== 'Other' && cat.name !== 'Failure')\n .map((cat) => ({ name: cat.name })) || [];\n\n return {\n uuid: node.uuid,\n llm: callLlmAction?.llm\n ? [{ value: callLlmAction.llm.uuid, name: callLlmAction.llm.name }]\n : [],\n input: callLlmAction?.input || '@input',\n categories: categories\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get LLM selection\n const llmSelection =\n Array.isArray(formData.llm) && formData.llm.length > 0\n ? formData.llm[0]\n : null;\n\n // Get user categories\n const userCategories = (formData.categories || [])\n .filter((item: any) => item?.name?.trim())\n .map((item: any) => item.name.trim());\n\n // Find existing call_llm action to preserve its UUID\n const existingCallLlmAction = originalNode.actions?.find(\n (action) => action.type === 'call_llm'\n );\n const callLlmUuid = existingCallLlmAction?.uuid || generateUUID();\n\n // Create call_llm action (using any type to match the example format)\n const callLlmAction: CallLLM = {\n type: 'call_llm',\n uuid: callLlmUuid,\n llm: llmSelection\n ? { uuid: llmSelection.value, name: llmSelection.name }\n : { uuid: '', name: '' },\n instructions: `@(prompt(\"categorize\", slice(node.categories, 0, -2)))`,\n input: formData.input || '@input',\n output_local: '_llm_output'\n };\n\n // Create categories and exits\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createMultiCategoryRouter(\n '@locals._llm_output',\n userCategories,\n (categoryName) => ({\n type: 'has_only_text',\n arguments: [categoryName]\n }),\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callLlmAction],\n router: router,\n exits: exits\n };\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
@@ -37,6 +37,7 @@ const DELIMIT_BY_OPTIONS = [
|
|
|
37
37
|
export const split_by_run_result = {
|
|
38
38
|
type: 'split_by_run_result',
|
|
39
39
|
name: 'Split by Result',
|
|
40
|
+
aliases: ['split_by_run_result_delimited'], // backwards compatibility with old flow editor
|
|
40
41
|
group: SPLIT_GROUPS.split,
|
|
41
42
|
flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],
|
|
42
43
|
dialogSize: 'large',
|
|
@@ -205,6 +206,11 @@ export const split_by_run_result = {
|
|
|
205
206
|
config.index = parseInt((_f = (_e = (_d = formData.delimit_index) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : '0', 10);
|
|
206
207
|
config.delimiter = delimitBy;
|
|
207
208
|
}
|
|
209
|
+
// Set the type based on whether delimiter is configured
|
|
210
|
+
// Use split_by_run_result_delimited for backward compatibility with old editor
|
|
211
|
+
config.type = hasDelimiter
|
|
212
|
+
? 'split_by_run_result_delimited'
|
|
213
|
+
: 'split_by_run_result';
|
|
208
214
|
return config;
|
|
209
215
|
},
|
|
210
216
|
// Localization support for categories
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_run_result.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_run_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,6CAA6C;AAC7C,MAAM,qBAAqB,GAAG;IAC5B,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACtC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAA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YACL,GAAG,YAAY;YACf,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IACD,UAAU,EAAE,CAAC,QAAkB,EAAE,EAAE;;QACjC,gEAAgE;QAChE,MAAM,cAAc,GAAG,MAAA,QAAQ,CAAC,MAAM,0CAAG,CAAC,CAAC,CAAC;QAE5C,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,2CAA2C;QAC3C,MAAM,MAAM,GAAQ;YAClB,OAAO,EAAE;gBACP,EAAE,EAAE,cAAc,CAAC,KAAK;gBACxB,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,IAAI,EAAE,QAAQ;aACf;SACF,CAAC;QAEF,0CAA0C;QAC1C,MAAM,SAAS,GAAG,MAAA,MAAA,QAAQ,CAAC,UAAU,0CAAG,CAAC,CAAC,0CAAE,KAAK,CAAC;QAClD,MAAM,YAAY,GAAG,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,EAAE,CAAC;QAEjE,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAA,MAAA,MAAA,QAAQ,CAAC,aAAa,0CAAG,CAAC,CAAC,0CAAE,KAAK,mCAAI,GAAG,EAAE,EAAE,CAAC,CAAC;YACvE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAC/B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\nimport { getStore } from '../../store/Store';\n\n// delimit index options (first through 20th)\nconst DELIMIT_INDEX_OPTIONS = [\n { value: '0', name: 'first result' },\n { value: '1', name: 'second result' },\n { value: '2', name: 'third result' },\n { value: '3', name: 'fourth result' },\n { value: '4', name: 'fifth result' },\n { value: '5', name: 'sixth result' },\n { value: '6', name: 'seventh result' },\n { value: '7', name: 'eighth result' },\n { value: '8', name: 'ninth result' },\n { value: '9', name: 'tenth result' },\n { value: '10', name: '11th result' },\n { value: '11', name: '12th result' },\n { value: '12', name: '13th result' },\n { value: '13', name: '14th result' },\n { value: '14', name: '15th result' },\n { value: '15', name: '16th result' },\n { value: '16', name: '17th result' },\n { value: '17', name: '18th result' },\n { value: '18', name: '19th result' },\n { value: '19', name: '20th result' }\n];\n\n// delimit by options - includes \"don't delimit\" and delimiter characters\nconst DELIMIT_BY_OPTIONS = [\n { value: '', name: \"Don't delimit result\" },\n { value: ' ', name: 'Delimited by spaces' },\n { value: '.', name: 'Delimited by periods' },\n { value: '+', name: 'Delimited by plusses' }\n];\n\nexport const split_by_run_result: NodeConfig = {\n type: 'split_by_run_result',\n name: 'Split by Result',\n group: SPLIT_GROUPS.split,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n dialogSize: 'large',\n form: {\n result: {\n type: 'select',\n\n required: true,\n searchable: false,\n clearable: false,\n placeholder: 'Select a result...',\n getDynamicOptions: () => {\n const store = getStore();\n return store\n ? store\n .getState()\n .getFlowResults()\n .map((r) => ({ value: r.key, name: r.name }))\n : [];\n },\n valueKey: 'value',\n nameKey: 'name'\n },\n delimit_by: {\n type: 'select',\n required: false,\n searchable: false,\n clearable: false,\n options: DELIMIT_BY_OPTIONS,\n valueKey: 'value',\n nameKey: 'name',\n maxWidth: '180px'\n },\n delimit_index: {\n type: 'select',\n required: false,\n searchable: false,\n clearable: false,\n options: DELIMIT_INDEX_OPTIONS,\n valueKey: 'value',\n nameKey: 'name',\n maxWidth: '140px',\n conditions: {\n visible: (formData: FormData) => {\n const delimitBy = formData.delimit_by?.[0]?.value;\n return delimitBy !== undefined && delimitBy !== '';\n }\n }\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to categorize the result'\n ),\n result_name: resultNameField\n },\n layout: [\n {\n type: 'row',\n label: 'Flow Result',\n helpText:\n 'Select a flow result and optionally delimit it to split on a specific part',\n items: ['result', 'delimit_by', 'delimit_index']\n },\n 'rules',\n 'result_name'\n ],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Validate result is provided\n if (!formData.result || formData.result.length === 0) {\n errors.result = 'A flow result is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node, nodeUI?: any) => {\n // Get the result from the UI config operand (source of truth)\n const result = nodeUI?.config?.operand;\n\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n // Extract delimiter configuration by checking the actual operand string\n // If operand contains field() function, we have a delimiter\n const operand = node.router?.operand || '';\n const fieldFunctionMatch = operand.match(\n /field\\(results\\.[\\w]+,\\s*(\\d+),\\s*\"(.+?)\"\\)/\n );\n\n const hasDelimiter = fieldFunctionMatch !== null;\n const delimitIndex = hasDelimiter\n ? parseInt(fieldFunctionMatch![1], 10)\n : 0;\n const delimiter = hasDelimiter ? fieldFunctionMatch![2] : '';\n\n return {\n uuid: node.uuid,\n result: result ? [result] : [],\n delimit_by: hasDelimiter\n ? [DELIMIT_BY_OPTIONS.find((opt) => opt.value === delimiter)]\n : [DELIMIT_BY_OPTIONS[0]],\n delimit_index: hasDelimiter\n ? [\n DELIMIT_INDEX_OPTIONS.find(\n (opt) => opt.value === String(delimitIndex)\n )\n ]\n : [DELIMIT_INDEX_OPTIONS[0]],\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get selected result (it's an array from the select component)\n const selectedResult = formData.result?.[0];\n\n if (!selectedResult) {\n return originalNode;\n }\n\n // Build operand based on whether delimiter is selected\n let operand: string;\n const delimitBy = formData.delimit_by?.[0]?.value;\n const hasDelimiter = delimitBy !== undefined && delimitBy !== '';\n\n if (hasDelimiter) {\n // Get delimiter configuration\n const delimitIndex = formData.delimit_index?.[0]?.value ?? '0';\n\n // Build operand with field() function\n operand = `@(field(results.${selectedResult.value}, ${delimitIndex}, \"${delimitBy}\"))`;\n } else {\n // Standard operand without delimiter\n operand = `@results.${selectedResult.value}`;\n }\n\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n toUIConfig: (formData: FormData) => {\n // Get selected result (it's an array from the select component)\n const selectedResult = formData.result?.[0];\n\n if (!selectedResult) {\n return {};\n }\n\n // Build UI config with operand information\n const config: any = {\n operand: {\n id: selectedResult.value,\n name: selectedResult.name,\n type: 'result'\n }\n };\n\n // Add delimiter configuration if selected\n const delimitBy = formData.delimit_by?.[0]?.value;\n const hasDelimiter = delimitBy !== undefined && delimitBy !== '';\n\n if (hasDelimiter) {\n config.index = parseInt(formData.delimit_index?.[0]?.value ?? '0', 10);\n config.delimiter = delimitBy;\n }\n\n return config;\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_run_result.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_run_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,6CAA6C;AAC7C,MAAM,qBAAqB,GAAG;IAC5B,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACtC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE;IACrC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACpC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE;IACpC,EAAE,KAAK,EAAE,IA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,cAAc,GAAG,MAAA,QAAQ,CAAC,MAAM,0CAAG,CAAC,CAAC,CAAC;QAE5C,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,2CAA2C;QAC3C,MAAM,MAAM,GAAQ;YAClB,OAAO,EAAE;gBACP,EAAE,EAAE,cAAc,CAAC,KAAK;gBACxB,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,IAAI,EAAE,QAAQ;aACf;SACF,CAAC;QAEF,0CAA0C;QAC1C,MAAM,SAAS,GAAG,MAAA,MAAA,QAAQ,CAAC,UAAU,0CAAG,CAAC,CAAC,0CAAE,KAAK,CAAC;QAClD,MAAM,YAAY,GAAG,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,EAAE,CAAC;QAEjE,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAA,MAAA,MAAA,QAAQ,CAAC,aAAa,0CAAG,CAAC,CAAC,0CAAE,KAAK,mCAAI,GAAG,EAAE,EAAE,CAAC,CAAC;YACvE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAC/B,CAAC;QAED,wDAAwD;QACxD,+EAA+E;QAC/E,MAAM,CAAC,IAAI,GAAG,YAAY;YACxB,CAAC,CAAC,+BAA+B;YACjC,CAAC,CAAC,qBAAqB,CAAC;QAE1B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,sCAAsC;IACtC,WAAW,EAAE,YAAY;IACzB,sBAAsB,EAAE,gCAAgC;IACxD,wBAAwB,EAAE,gCAAgC;CAC3D,CAAC","sourcesContent":["import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';\nimport { Node } from '../../store/flow-definition';\nimport { createRulesRouter } from '../../utils';\nimport {\n getWaitForResponseOperators,\n operatorsToSelectOptions,\n getOperatorConfig\n} from '../operators';\nimport {\n resultNameField,\n categoriesToLocalizationFormData,\n localizationFormDataToCategories\n} from './shared';\nimport {\n createRulesArrayConfig,\n extractUserRules,\n casesToFormRules\n} from './shared-rules';\nimport { getStore } from '../../store/Store';\n\n// delimit index options (first through 20th)\nconst DELIMIT_INDEX_OPTIONS = [\n { value: '0', name: 'first result' },\n { value: '1', name: 'second result' },\n { value: '2', name: 'third result' },\n { value: '3', name: 'fourth result' },\n { value: '4', name: 'fifth result' },\n { value: '5', name: 'sixth result' },\n { value: '6', name: 'seventh result' },\n { value: '7', name: 'eighth result' },\n { value: '8', name: 'ninth result' },\n { value: '9', name: 'tenth result' },\n { value: '10', name: '11th result' },\n { value: '11', name: '12th result' },\n { value: '12', name: '13th result' },\n { value: '13', name: '14th result' },\n { value: '14', name: '15th result' },\n { value: '15', name: '16th result' },\n { value: '16', name: '17th result' },\n { value: '17', name: '18th result' },\n { value: '18', name: '19th result' },\n { value: '19', name: '20th result' }\n];\n\n// delimit by options - includes \"don't delimit\" and delimiter characters\nconst DELIMIT_BY_OPTIONS = [\n { value: '', name: \"Don't delimit result\" },\n { value: ' ', name: 'Delimited by spaces' },\n { value: '.', name: 'Delimited by periods' },\n { value: '+', name: 'Delimited by plusses' }\n];\n\nexport const split_by_run_result: NodeConfig = {\n type: 'split_by_run_result',\n name: 'Split by Result',\n aliases: ['split_by_run_result_delimited'], // backwards compatibility with old flow editor\n group: SPLIT_GROUPS.split,\n flowTypes: [FlowTypes.VOICE, FlowTypes.MESSAGE, FlowTypes.BACKGROUND],\n dialogSize: 'large',\n form: {\n result: {\n type: 'select',\n\n required: true,\n searchable: false,\n clearable: false,\n placeholder: 'Select a result...',\n getDynamicOptions: () => {\n const store = getStore();\n return store\n ? store\n .getState()\n .getFlowResults()\n .map((r) => ({ value: r.key, name: r.name }))\n : [];\n },\n valueKey: 'value',\n nameKey: 'name'\n },\n delimit_by: {\n type: 'select',\n required: false,\n searchable: false,\n clearable: false,\n options: DELIMIT_BY_OPTIONS,\n valueKey: 'value',\n nameKey: 'name',\n maxWidth: '180px'\n },\n delimit_index: {\n type: 'select',\n required: false,\n searchable: false,\n clearable: false,\n options: DELIMIT_INDEX_OPTIONS,\n valueKey: 'value',\n nameKey: 'name',\n maxWidth: '140px',\n conditions: {\n visible: (formData: FormData) => {\n const delimitBy = formData.delimit_by?.[0]?.value;\n return delimitBy !== undefined && delimitBy !== '';\n }\n }\n },\n rules: createRulesArrayConfig(\n operatorsToSelectOptions(getWaitForResponseOperators()),\n 'Define rules to categorize the result'\n ),\n result_name: resultNameField\n },\n layout: [\n {\n type: 'row',\n label: 'Flow Result',\n helpText:\n 'Select a flow result and optionally delimit it to split on a specific part',\n items: ['result', 'delimit_by', 'delimit_index']\n },\n 'rules',\n 'result_name'\n ],\n validate: (formData: FormData) => {\n const errors: { [key: string]: string } = {};\n\n // Validate result is provided\n if (!formData.result || formData.result.length === 0) {\n errors.result = 'A flow result is required';\n }\n\n return {\n valid: Object.keys(errors).length === 0,\n errors\n };\n },\n toFormData: (node: Node, nodeUI?: any) => {\n // Get the result from the UI config operand (source of truth)\n const result = nodeUI?.config?.operand;\n\n // Extract rules from router cases using shared function\n const rules = casesToFormRules(node);\n\n // Extract delimiter configuration by checking the actual operand string\n // If operand contains field() function, we have a delimiter\n const operand = node.router?.operand || '';\n const fieldFunctionMatch = operand.match(\n /field\\(results\\.[\\w]+,\\s*(\\d+),\\s*\"(.+?)\"\\)/\n );\n\n const hasDelimiter = fieldFunctionMatch !== null;\n const delimitIndex = hasDelimiter\n ? parseInt(fieldFunctionMatch![1], 10)\n : 0;\n const delimiter = hasDelimiter ? fieldFunctionMatch![2] : '';\n\n return {\n uuid: node.uuid,\n result: result ? [result] : [],\n delimit_by: hasDelimiter\n ? [DELIMIT_BY_OPTIONS.find((opt) => opt.value === delimiter)]\n : [DELIMIT_BY_OPTIONS[0]],\n delimit_index: hasDelimiter\n ? [\n DELIMIT_INDEX_OPTIONS.find(\n (opt) => opt.value === String(delimitIndex)\n )\n ]\n : [DELIMIT_INDEX_OPTIONS[0]],\n rules: rules,\n result_name: node.router?.result_name || ''\n };\n },\n fromFormData: (formData: FormData, originalNode: Node): Node => {\n // Get selected result (it's an array from the select component)\n const selectedResult = formData.result?.[0];\n\n if (!selectedResult) {\n return originalNode;\n }\n\n // Build operand based on whether delimiter is selected\n let operand: string;\n const delimitBy = formData.delimit_by?.[0]?.value;\n const hasDelimiter = delimitBy !== undefined && delimitBy !== '';\n\n if (hasDelimiter) {\n // Get delimiter configuration\n const delimitIndex = formData.delimit_index?.[0]?.value ?? '0';\n\n // Build operand with field() function\n operand = `@(field(results.${selectedResult.value}, ${delimitIndex}, \"${delimitBy}\"))`;\n } else {\n // Standard operand without delimiter\n operand = `@results.${selectedResult.value}`;\n }\n\n // Get user rules using shared extraction function\n const userRules = extractUserRules(formData);\n\n // Get existing router data for preservation\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n // Create router and exits using existing data when possible\n const { router, exits } = createRulesRouter(\n operand,\n userRules,\n getOperatorConfig,\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Build final router with result_name\n const finalRouter: any = {\n ...router\n };\n\n // Only set result_name if provided\n if (formData.result_name && formData.result_name.trim() !== '') {\n finalRouter.result_name = formData.result_name.trim();\n }\n\n return {\n ...originalNode,\n router: finalRouter,\n exits: exits\n };\n },\n toUIConfig: (formData: FormData) => {\n // Get selected result (it's an array from the select component)\n const selectedResult = formData.result?.[0];\n\n if (!selectedResult) {\n return {};\n }\n\n // Build UI config with operand information\n const config: any = {\n operand: {\n id: selectedResult.value,\n name: selectedResult.name,\n type: 'result'\n }\n };\n\n // Add delimiter configuration if selected\n const delimitBy = formData.delimit_by?.[0]?.value;\n const hasDelimiter = delimitBy !== undefined && delimitBy !== '';\n\n if (hasDelimiter) {\n config.index = parseInt(formData.delimit_index?.[0]?.value ?? '0', 10);\n config.delimiter = delimitBy;\n }\n\n // Set the type based on whether delimiter is configured\n // Use split_by_run_result_delimited for backward compatibility with old editor\n config.type = hasDelimiter\n ? 'split_by_run_result_delimited'\n : 'split_by_run_result';\n\n return config;\n },\n\n // Localization support for categories\n localizable: 'categories',\n toLocalizationFormData: categoriesToLocalizationFormData,\n fromLocalizationFormData: localizationFormDataToCategories\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/flow/types.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;CAChB,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,SAAS;CACV,CAAC;AA8QX;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACN,CAAC;AAeX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAuC;IACvE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,mDAAmD;KACjE;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,yCAAyC;KACvD;IACD,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,iCAAiC;KAC/C;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,iCAAiC;KAC/C;IACD,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;QACzB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,qDAAqD;KACnE;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,qCAAqC;KACnD;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsC;IACrE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACnB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,2CAA2C;KACzD;IACD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,oCAAoC;KAClD;CACF,CAAC","sourcesContent":["import { TemplateResult } from 'lit-html';\nimport { Action, Node, NodeUI } from '../store/flow-definition';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: { [key: string]: string };\n}\n\n/**\n * Flow types - defines the type of flow being edited\n */\nexport const FlowTypes = {\n MESSAGE: 'message',\n VOICE: 'voice',\n BACKGROUND: 'background'\n} as const;\n\nexport type FlowType = (typeof FlowTypes)[keyof typeof FlowTypes];\n\n/**\n * Features - defines the features available in the account\n */\nexport const Features = {\n AI: 'ai',\n AIRTIME: 'airtime'\n} as const;\n\nexport type Feature = (typeof Features)[keyof typeof Features];\n\n// Component attribute interfaces - these define what's allowed for each component type\nexport interface TextInputAttributes {\n type?: 'text' | 'email' | 'number' | 'url' | 'tel';\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n submitOnEnter?: boolean;\n}\n\nexport interface CompletionAttributes {\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n expressions?: string;\n counter?: string;\n minHeight?: number;\n}\n\nexport interface SelectAttributes {\n placeholder?: string;\n multi?: boolean;\n searchable?: boolean;\n tags?: boolean;\n emails?: boolean;\n clearable?: boolean;\n endpoint?: string;\n valueKey?: string;\n nameKey?: string;\n queryParam?: string;\n maxItems?: number;\n maxItemsText?: string;\n expressions?: string;\n options?: Array<{ name: string; value: any }>;\n sorted?: boolean;\n allowCreate?: boolean;\n jsonValue?: boolean;\n spaceSelect?: boolean;\n infoText?: string;\n}\n\nexport interface CheckboxAttributes {\n label?: string;\n size?: number;\n disabled?: boolean;\n animateChange?: string;\n}\n\nexport interface SliderAttributes {\n min?: number;\n max?: number;\n range?: boolean;\n}\n\nexport interface FormData extends Record<string, any> {}\n\nexport interface FormConfig {\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[];\n gutter?: LayoutItem[];\n sanitize?: (formData: FormData) => void;\n validate?: (formData: FormData) => ValidationResult;\n}\n\nexport interface NodeConfig extends FormConfig {\n type: string;\n name?: string;\n group?: ActionGroup | SplitGroup; // Nodes can use either when showAsAction is true\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n action?: ActionConfig;\n showAsAction?: boolean; // if true, show in action dialog instead of splits (default: false - nodes show in splits)\n flowTypes?: FlowType[]; // which flow types this node is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this node (all must be present)\n router?: {\n type: 'switch' | 'random';\n defaultCategory?: string;\n operand?: string;\n configurable?: boolean; // can the rules be configured in the UI\n rules?: {\n type:\n | 'has_number_between'\n | 'has_string'\n | 'has_value'\n | 'has_not_value'\n | 'has_text';\n arguments: string[];\n categoryName: string;\n }[];\n };\n\n toFormData?: (node: Node, nodeUI?: any) => FormData;\n fromFormData?: (formData: FormData, originalNode: Node) => Node;\n toUIConfig?: (formData: FormData) => Record<string, any>;\n render?: (node: Node, nodeUI?: any) => TemplateResult;\n renderTitle?: (node: Node, nodeUI?: NodeUI) => TemplateResult;\n\n // Localization support for router categories\n localizable?: 'categories'; // Only categories are localizable for routers\n toLocalizationFormData?: (\n node: Node,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n node: Node\n ) => Record<string, any>;\n}\n\n// New field configuration system for generic form generation\nexport interface BaseFieldConfig {\n label?: string | ((formData: Record<string, any>) => string);\n required?: boolean;\n evaluated?: boolean;\n dependsOn?: string[];\n computeValue?: (\n values: Record<string, any>,\n currentValue: any,\n originalValues?: Record<string, any>\n ) => any;\n\n // Validation properties\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n helpText?: string;\n\n // Layout properties\n maxWidth?: string;\n width?: string;\n\n // Conditional rendering\n conditions?: {\n visible?: (formData: Record<string, any>) => boolean;\n disabled?: (formData: Record<string, any>) => boolean;\n };\n\n // Optional field with reveal link\n // When set, the field is hidden by default and a link with this text is shown\n // Clicking the link reveals the field permanently (can't be hidden again)\n optionalLink?: string;\n}\n\nexport interface TextFieldConfig extends BaseFieldConfig {\n type: 'text';\n placeholder?: string;\n flavor?: 'xsmall' | 'small' | 'large';\n}\n\nexport interface TextareaFieldConfig extends BaseFieldConfig {\n type: 'textarea';\n placeholder?: string;\n rows?: number;\n minHeight?: number;\n}\n\nexport interface SelectFieldConfig extends BaseFieldConfig {\n type: 'select';\n options?: string[] | { value: string; name: string }[];\n multi?: boolean;\n clearable?: boolean;\n searchable?: boolean;\n tags?: boolean;\n placeholder?: string;\n maxItems?: number;\n valueKey?: string;\n nameKey?: string;\n endpoint?: string;\n emails?: boolean;\n getName?: (item: any) => string;\n flavor?: 'xsmall' | 'small' | 'large';\n createArbitraryOption?: (input: string, options: any[]) => any;\n allowCreate?: boolean;\n getDynamicOptions?: () => Array<{ value: string; name: string }>;\n}\n\nexport interface KeyValueFieldConfig extends BaseFieldConfig {\n type: 'key-value';\n sortable?: boolean;\n keyPlaceholder?: string;\n valuePlaceholder?: string;\n minRows?: number;\n}\n\nexport interface ArrayFieldConfig extends BaseFieldConfig {\n type: 'array';\n itemConfig: Record<string, FieldConfig>;\n sortable?: boolean;\n minItems?: number;\n maxItems?: number;\n itemLabel?: string;\n maintainEmptyItem?: boolean;\n onItemChange?: (\n itemIndex: number,\n field: string,\n value: any,\n allItems: any[]\n ) => any[];\n isEmptyItem?: (item: any) => boolean;\n}\n\nexport interface CheckboxFieldConfig extends BaseFieldConfig {\n type: 'checkbox';\n size?: number;\n animateChange?: string;\n labelPadding?: string;\n}\n\nexport interface MessageEditorFieldConfig extends BaseFieldConfig {\n type: 'message-editor';\n placeholder?: string;\n minHeight?: number;\n maxAttachments?: number;\n accept?: string;\n endpoint?: string;\n counter?: string;\n gsm?: boolean;\n autogrow?: boolean;\n disableCompletion?: boolean;\n}\n\nexport type FieldConfig =\n | TextFieldConfig\n | TextareaFieldConfig\n | SelectFieldConfig\n | KeyValueFieldConfig\n | ArrayFieldConfig\n | CheckboxFieldConfig\n | MessageEditorFieldConfig;\n\n// Layout configurations for better form organization\n// Recursive layout system - any layout item can contain other layout items\n\nexport interface FieldItemConfig {\n type: 'field';\n field: string; // field name to render\n}\n\nexport interface RowLayoutConfig {\n type: 'row';\n items: LayoutItem[]; // can contain fields, groups, or other rows\n gap?: string; // CSS gap value, defaults to '1rem'\n label?: string; // optional label for the entire row\n helpText?: string; // optional help text for the entire row\n}\n\nexport interface GroupLayoutConfig {\n type: 'group';\n label: string;\n items: LayoutItem[]; // can contain fields, rows, or other groups\n collapsible?: boolean;\n collapsed?: boolean | ((formData: FormData) => boolean); // initial state if collapsible - can be a function\n helpText?: string;\n getGroupValueCount?: (formData: FormData) => number; // optional function to get count for bubble display\n}\n\nexport type LayoutItem =\n | FieldItemConfig\n | RowLayoutConfig\n | GroupLayoutConfig\n | string; // string is shorthand for field\n\n/**\n * Action group constants - single source of truth for action categorization\n * Use as const for compile-time type checking\n */\nexport const ACTION_GROUPS = {\n send: 'send',\n contacts: 'contacts',\n save: 'save',\n services: 'services',\n broadcast: 'broadcast',\n trigger: 'trigger'\n} as const;\n\n/**\n * Split group constants - single source of truth for split categorization\n * Use as const for compile-time type checking\n */\nexport const SPLIT_GROUPS = {\n wait: 'wait',\n split: 'split'\n} as const;\n\n// Extract types from const objects for compile-time checking\nexport type ActionGroup = (typeof ACTION_GROUPS)[keyof typeof ACTION_GROUPS];\nexport type SplitGroup = (typeof SPLIT_GROUPS)[keyof typeof SPLIT_GROUPS];\n\n/**\n * Metadata for group display\n */\nexport interface GroupMetadata {\n color: string;\n title: string;\n description: string;\n}\n\n/**\n * Action group metadata - defines display properties for each action group\n * Order in this object determines display order in action selector (top to bottom)\n */\nexport const ACTION_GROUP_METADATA: Record<ActionGroup, GroupMetadata> = {\n [ACTION_GROUPS.send]: {\n color: '#3498db',\n title: 'Send',\n description: 'Actions that send messages or content to contacts'\n },\n [ACTION_GROUPS.contacts]: {\n color: '#01c1af',\n title: 'Contact',\n description: 'Actions that update contact information'\n },\n [ACTION_GROUPS.save]: {\n color: '#1a777c',\n title: 'Save',\n description: 'Actions that save or store data'\n },\n [ACTION_GROUPS.services]: {\n color: '#f79035ff',\n title: 'Services',\n description: 'Call external services and APIs'\n },\n [ACTION_GROUPS.broadcast]: {\n color: '#8e5ea7',\n title: 'Other People',\n description: 'Actions that apply to others instead of the contact'\n },\n [ACTION_GROUPS.trigger]: {\n color: '#df419f',\n title: 'Trigger',\n description: 'Actions that trigger other behavior'\n }\n};\n\n/**\n * Split group metadata - defines display properties for each split group\n * Order in this object determines display order in split selector (top to bottom)\n */\nexport const SPLIT_GROUP_METADATA: Record<SplitGroup, GroupMetadata> = {\n [SPLIT_GROUPS.wait]: {\n color: '#4d7dad',\n title: 'Wait',\n description: 'Wait for user and split on their response'\n },\n [SPLIT_GROUPS.split]: {\n color: '#aaaaaa',\n title: 'Split',\n description: 'Split the flow based on conditions'\n }\n};\n\nexport interface ActionConfig extends FormConfig {\n name: string;\n group: ActionGroup;\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n evaluated?: string[];\n hideFromActions?: boolean; // if true, don't show in action dialog (default: false - actions show in actions)\n flowTypes?: FlowType[]; // which flow types this action is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this action (all must be present)\n render?: (node: any, action: any) => TemplateResult;\n\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[]; // optional layout configuration - array of layout items\n gutter?: LayoutItem[]; // fields to render in the dialog gutter (left side of buttons)\n\n toFormData?: (action: Action) => FormData;\n fromFormData?: (formData: FormData) => Action;\n\n // Localization support\n localizable?: string[]; // array of field names that can be localized\n toLocalizationFormData?: (\n action: Action,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n action: Action\n ) => Record<string, any>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/flow/types.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;CAChB,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,SAAS;CACV,CAAC;AA+QX;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACN,CAAC;AAeX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAuC;IACvE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,mDAAmD;KACjE;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,yCAAyC;KACvD;IACD,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,iCAAiC;KAC/C;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,iCAAiC;KAC/C;IACD,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;QACzB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,qDAAqD;KACnE;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,qCAAqC;KACnD;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsC;IACrE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACnB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,2CAA2C;KACzD;IACD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QACpB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,oCAAoC;KAClD;CACF,CAAC","sourcesContent":["import { TemplateResult } from 'lit-html';\nimport { Action, Node, NodeUI } from '../store/flow-definition';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: { [key: string]: string };\n}\n\n/**\n * Flow types - defines the type of flow being edited\n */\nexport const FlowTypes = {\n MESSAGE: 'message',\n VOICE: 'voice',\n BACKGROUND: 'background'\n} as const;\n\nexport type FlowType = (typeof FlowTypes)[keyof typeof FlowTypes];\n\n/**\n * Features - defines the features available in the account\n */\nexport const Features = {\n AI: 'ai',\n AIRTIME: 'airtime'\n} as const;\n\nexport type Feature = (typeof Features)[keyof typeof Features];\n\n// Component attribute interfaces - these define what's allowed for each component type\nexport interface TextInputAttributes {\n type?: 'text' | 'email' | 'number' | 'url' | 'tel';\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n submitOnEnter?: boolean;\n}\n\nexport interface CompletionAttributes {\n placeholder?: string;\n clearable?: boolean;\n maxlength?: number;\n gsm?: boolean;\n autogrow?: boolean;\n textarea?: boolean;\n expressions?: string;\n counter?: string;\n minHeight?: number;\n}\n\nexport interface SelectAttributes {\n placeholder?: string;\n multi?: boolean;\n searchable?: boolean;\n tags?: boolean;\n emails?: boolean;\n clearable?: boolean;\n endpoint?: string;\n valueKey?: string;\n nameKey?: string;\n queryParam?: string;\n maxItems?: number;\n maxItemsText?: string;\n expressions?: string;\n options?: Array<{ name: string; value: any }>;\n sorted?: boolean;\n allowCreate?: boolean;\n jsonValue?: boolean;\n spaceSelect?: boolean;\n infoText?: string;\n}\n\nexport interface CheckboxAttributes {\n label?: string;\n size?: number;\n disabled?: boolean;\n animateChange?: string;\n}\n\nexport interface SliderAttributes {\n min?: number;\n max?: number;\n range?: boolean;\n}\n\nexport interface FormData extends Record<string, any> {}\n\nexport interface FormConfig {\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[];\n gutter?: LayoutItem[];\n sanitize?: (formData: FormData) => void;\n validate?: (formData: FormData) => ValidationResult;\n}\n\nexport interface NodeConfig extends FormConfig {\n type: string;\n name?: string;\n aliases?: string[]; // alternate type names for backwards compatibility (won't show in selector)\n group?: ActionGroup | SplitGroup; // Nodes can use either when showAsAction is true\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n action?: ActionConfig;\n showAsAction?: boolean; // if true, show in action dialog instead of splits (default: false - nodes show in splits)\n flowTypes?: FlowType[]; // which flow types this node is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this node (all must be present)\n router?: {\n type: 'switch' | 'random';\n defaultCategory?: string;\n operand?: string;\n configurable?: boolean; // can the rules be configured in the UI\n rules?: {\n type:\n | 'has_number_between'\n | 'has_string'\n | 'has_value'\n | 'has_not_value'\n | 'has_text';\n arguments: string[];\n categoryName: string;\n }[];\n };\n\n toFormData?: (node: Node, nodeUI?: any) => FormData;\n fromFormData?: (formData: FormData, originalNode: Node) => Node;\n toUIConfig?: (formData: FormData) => Record<string, any>;\n render?: (node: Node, nodeUI?: any) => TemplateResult;\n renderTitle?: (node: Node, nodeUI?: NodeUI) => TemplateResult;\n\n // Localization support for router categories\n localizable?: 'categories'; // Only categories are localizable for routers\n toLocalizationFormData?: (\n node: Node,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n node: Node\n ) => Record<string, any>;\n}\n\n// New field configuration system for generic form generation\nexport interface BaseFieldConfig {\n label?: string | ((formData: Record<string, any>) => string);\n required?: boolean;\n evaluated?: boolean;\n dependsOn?: string[];\n computeValue?: (\n values: Record<string, any>,\n currentValue: any,\n originalValues?: Record<string, any>\n ) => any;\n\n // Validation properties\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n helpText?: string;\n\n // Layout properties\n maxWidth?: string;\n width?: string;\n\n // Conditional rendering\n conditions?: {\n visible?: (formData: Record<string, any>) => boolean;\n disabled?: (formData: Record<string, any>) => boolean;\n };\n\n // Optional field with reveal link\n // When set, the field is hidden by default and a link with this text is shown\n // Clicking the link reveals the field permanently (can't be hidden again)\n optionalLink?: string;\n}\n\nexport interface TextFieldConfig extends BaseFieldConfig {\n type: 'text';\n placeholder?: string;\n flavor?: 'xsmall' | 'small' | 'large';\n}\n\nexport interface TextareaFieldConfig extends BaseFieldConfig {\n type: 'textarea';\n placeholder?: string;\n rows?: number;\n minHeight?: number;\n}\n\nexport interface SelectFieldConfig extends BaseFieldConfig {\n type: 'select';\n options?: string[] | { value: string; name: string }[];\n multi?: boolean;\n clearable?: boolean;\n searchable?: boolean;\n tags?: boolean;\n placeholder?: string;\n maxItems?: number;\n valueKey?: string;\n nameKey?: string;\n endpoint?: string;\n emails?: boolean;\n getName?: (item: any) => string;\n flavor?: 'xsmall' | 'small' | 'large';\n createArbitraryOption?: (input: string, options: any[]) => any;\n allowCreate?: boolean;\n getDynamicOptions?: () => Array<{ value: string; name: string }>;\n}\n\nexport interface KeyValueFieldConfig extends BaseFieldConfig {\n type: 'key-value';\n sortable?: boolean;\n keyPlaceholder?: string;\n valuePlaceholder?: string;\n minRows?: number;\n}\n\nexport interface ArrayFieldConfig extends BaseFieldConfig {\n type: 'array';\n itemConfig: Record<string, FieldConfig>;\n sortable?: boolean;\n minItems?: number;\n maxItems?: number;\n itemLabel?: string;\n maintainEmptyItem?: boolean;\n onItemChange?: (\n itemIndex: number,\n field: string,\n value: any,\n allItems: any[]\n ) => any[];\n isEmptyItem?: (item: any) => boolean;\n}\n\nexport interface CheckboxFieldConfig extends BaseFieldConfig {\n type: 'checkbox';\n size?: number;\n animateChange?: string;\n labelPadding?: string;\n}\n\nexport interface MessageEditorFieldConfig extends BaseFieldConfig {\n type: 'message-editor';\n placeholder?: string;\n minHeight?: number;\n maxAttachments?: number;\n accept?: string;\n endpoint?: string;\n counter?: string;\n gsm?: boolean;\n autogrow?: boolean;\n disableCompletion?: boolean;\n}\n\nexport type FieldConfig =\n | TextFieldConfig\n | TextareaFieldConfig\n | SelectFieldConfig\n | KeyValueFieldConfig\n | ArrayFieldConfig\n | CheckboxFieldConfig\n | MessageEditorFieldConfig;\n\n// Layout configurations for better form organization\n// Recursive layout system - any layout item can contain other layout items\n\nexport interface FieldItemConfig {\n type: 'field';\n field: string; // field name to render\n}\n\nexport interface RowLayoutConfig {\n type: 'row';\n items: LayoutItem[]; // can contain fields, groups, or other rows\n gap?: string; // CSS gap value, defaults to '1rem'\n label?: string; // optional label for the entire row\n helpText?: string; // optional help text for the entire row\n}\n\nexport interface GroupLayoutConfig {\n type: 'group';\n label: string;\n items: LayoutItem[]; // can contain fields, rows, or other groups\n collapsible?: boolean;\n collapsed?: boolean | ((formData: FormData) => boolean); // initial state if collapsible - can be a function\n helpText?: string;\n getGroupValueCount?: (formData: FormData) => number; // optional function to get count for bubble display\n}\n\nexport type LayoutItem =\n | FieldItemConfig\n | RowLayoutConfig\n | GroupLayoutConfig\n | string; // string is shorthand for field\n\n/**\n * Action group constants - single source of truth for action categorization\n * Use as const for compile-time type checking\n */\nexport const ACTION_GROUPS = {\n send: 'send',\n contacts: 'contacts',\n save: 'save',\n services: 'services',\n broadcast: 'broadcast',\n trigger: 'trigger'\n} as const;\n\n/**\n * Split group constants - single source of truth for split categorization\n * Use as const for compile-time type checking\n */\nexport const SPLIT_GROUPS = {\n wait: 'wait',\n split: 'split'\n} as const;\n\n// Extract types from const objects for compile-time checking\nexport type ActionGroup = (typeof ACTION_GROUPS)[keyof typeof ACTION_GROUPS];\nexport type SplitGroup = (typeof SPLIT_GROUPS)[keyof typeof SPLIT_GROUPS];\n\n/**\n * Metadata for group display\n */\nexport interface GroupMetadata {\n color: string;\n title: string;\n description: string;\n}\n\n/**\n * Action group metadata - defines display properties for each action group\n * Order in this object determines display order in action selector (top to bottom)\n */\nexport const ACTION_GROUP_METADATA: Record<ActionGroup, GroupMetadata> = {\n [ACTION_GROUPS.send]: {\n color: '#3498db',\n title: 'Send',\n description: 'Actions that send messages or content to contacts'\n },\n [ACTION_GROUPS.contacts]: {\n color: '#01c1af',\n title: 'Contact',\n description: 'Actions that update contact information'\n },\n [ACTION_GROUPS.save]: {\n color: '#1a777c',\n title: 'Save',\n description: 'Actions that save or store data'\n },\n [ACTION_GROUPS.services]: {\n color: '#f79035ff',\n title: 'Services',\n description: 'Call external services and APIs'\n },\n [ACTION_GROUPS.broadcast]: {\n color: '#8e5ea7',\n title: 'Other People',\n description: 'Actions that apply to others instead of the contact'\n },\n [ACTION_GROUPS.trigger]: {\n color: '#df419f',\n title: 'Trigger',\n description: 'Actions that trigger other behavior'\n }\n};\n\n/**\n * Split group metadata - defines display properties for each split group\n * Order in this object determines display order in split selector (top to bottom)\n */\nexport const SPLIT_GROUP_METADATA: Record<SplitGroup, GroupMetadata> = {\n [SPLIT_GROUPS.wait]: {\n color: '#4d7dad',\n title: 'Wait',\n description: 'Wait for user and split on their response'\n },\n [SPLIT_GROUPS.split]: {\n color: '#aaaaaa',\n title: 'Split',\n description: 'Split the flow based on conditions'\n }\n};\n\nexport interface ActionConfig extends FormConfig {\n name: string;\n aliases?: string[]; // alternate type names for backwards compatibility (won't show in selector)\n group: ActionGroup;\n dialogSize?: 'small' | 'medium' | 'large' | 'xlarge';\n evaluated?: string[];\n hideFromActions?: boolean; // if true, don't show in action dialog (default: false - actions show in actions)\n flowTypes?: FlowType[]; // which flow types this action is available for (defaults to all if not specified)\n features?: Feature[]; // which features are required for this action (all must be present)\n render?: (node: any, action: any) => TemplateResult;\n\n form?: Record<string, FieldConfig>;\n layout?: LayoutItem[]; // optional layout configuration - array of layout items\n gutter?: LayoutItem[]; // fields to render in the dialog gutter (left side of buttons)\n\n toFormData?: (action: Action) => FormData;\n fromFormData?: (formData: FormData) => Action;\n\n // Localization support\n localizable?: string[]; // array of field names that can be localized\n toLocalizationFormData?: (\n action: Action,\n localization: Record<string, any>\n ) => FormData;\n fromLocalizationFormData?: (\n formData: FormData,\n action: Action\n ) => Record<string, any>;\n}\n"]}
|
|
@@ -111,7 +111,7 @@ export class FloatingWindow extends RapidElement {
|
|
|
111
111
|
transition: transform var(--transition-duration, 300ms) ease-in-out,
|
|
112
112
|
opacity var(--transition-duration, 300ms) ease-in-out;
|
|
113
113
|
position: fixed;
|
|
114
|
-
z-index:
|
|
114
|
+
z-index: 5000;
|
|
115
115
|
top: 100px;
|
|
116
116
|
background: white;
|
|
117
117
|
border-radius: 8px;
|
|
@@ -215,7 +215,6 @@ export class FloatingWindow extends RapidElement {
|
|
|
215
215
|
updated(changes) {
|
|
216
216
|
super.updated(changes);
|
|
217
217
|
if (changes.has('hidden')) {
|
|
218
|
-
this.classList.toggle('hidden', this.hidden);
|
|
219
218
|
// when hiding, reset positioning behavior to original
|
|
220
219
|
if (this.hidden && !changes.get('hidden')) {
|
|
221
220
|
if (this.defaultLeft === -1) {
|