@nyaruka/temba-components 0.138.4 → 0.139.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/locales/es.js +5 -5
  3. package/dist/locales/es.js.map +1 -1
  4. package/dist/locales/fr.js +5 -5
  5. package/dist/locales/fr.js.map +1 -1
  6. package/dist/locales/locale-codes.js +2 -11
  7. package/dist/locales/locale-codes.js.map +1 -1
  8. package/dist/locales/pt.js +5 -5
  9. package/dist/locales/pt.js.map +1 -1
  10. package/dist/temba-components.js +816 -852
  11. package/dist/temba-components.js.map +1 -1
  12. package/out-tsc/src/display/FloatingTab.js +23 -30
  13. package/out-tsc/src/display/FloatingTab.js.map +1 -1
  14. package/out-tsc/src/flow/CanvasMenu.js +5 -3
  15. package/out-tsc/src/flow/CanvasMenu.js.map +1 -1
  16. package/out-tsc/src/flow/CanvasNode.js +6 -7
  17. package/out-tsc/src/flow/CanvasNode.js.map +1 -1
  18. package/out-tsc/src/flow/Editor.js +152 -235
  19. package/out-tsc/src/flow/Editor.js.map +1 -1
  20. package/out-tsc/src/flow/Plumber.js +757 -403
  21. package/out-tsc/src/flow/Plumber.js.map +1 -1
  22. package/out-tsc/src/flow/utils.js +138 -66
  23. package/out-tsc/src/flow/utils.js.map +1 -1
  24. package/out-tsc/src/interfaces.js +1 -0
  25. package/out-tsc/src/interfaces.js.map +1 -1
  26. package/out-tsc/src/list/TicketList.js +4 -1
  27. package/out-tsc/src/list/TicketList.js.map +1 -1
  28. package/out-tsc/src/live/ContactChat.js +18 -1
  29. package/out-tsc/src/live/ContactChat.js.map +1 -1
  30. package/out-tsc/src/locales/es.js +5 -5
  31. package/out-tsc/src/locales/es.js.map +1 -1
  32. package/out-tsc/src/locales/fr.js +5 -5
  33. package/out-tsc/src/locales/fr.js.map +1 -1
  34. package/out-tsc/src/locales/locale-codes.js +2 -11
  35. package/out-tsc/src/locales/locale-codes.js.map +1 -1
  36. package/out-tsc/src/locales/pt.js +5 -5
  37. package/out-tsc/src/locales/pt.js.map +1 -1
  38. package/out-tsc/src/simulator/Simulator.js +1 -0
  39. package/out-tsc/src/simulator/Simulator.js.map +1 -1
  40. package/out-tsc/test/temba-floating-tab.test.js +4 -6
  41. package/out-tsc/test/temba-floating-tab.test.js.map +1 -1
  42. package/out-tsc/test/temba-flow-collision.test.js +221 -223
  43. package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
  44. package/out-tsc/test/temba-flow-editor.test.js +0 -2
  45. package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
  46. package/out-tsc/test/temba-flow-plumber-connections.test.js +83 -84
  47. package/out-tsc/test/temba-flow-plumber-connections.test.js.map +1 -1
  48. package/out-tsc/test/temba-flow-plumber.test.js +102 -93
  49. package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/display/FloatingTab.ts +22 -31
  52. package/src/flow/CanvasMenu.ts +8 -3
  53. package/src/flow/CanvasNode.ts +6 -7
  54. package/src/flow/Editor.ts +184 -279
  55. package/src/flow/Plumber.ts +1011 -457
  56. package/src/flow/utils.ts +162 -84
  57. package/src/interfaces.ts +2 -1
  58. package/src/list/TicketList.ts +4 -1
  59. package/src/live/ContactChat.ts +19 -1
  60. package/src/locales/es.ts +13 -18
  61. package/src/locales/fr.ts +13 -18
  62. package/src/locales/locale-codes.ts +2 -11
  63. package/src/locales/pt.ts +13 -18
  64. package/src/simulator/Simulator.ts +1 -0
  65. package/test/temba-floating-tab.test.ts +4 -6
  66. package/test/temba-flow-collision.test.ts +225 -303
  67. package/test/temba-flow-editor.test.ts +0 -2
  68. package/test/temba-flow-plumber-connections.test.ts +97 -97
  69. package/test/temba-flow-plumber.test.ts +116 -103
@@ -1,5 +1,5 @@
1
1
  import { css, html, PropertyValueMap, TemplateResult } from 'lit';
2
- import { property } from 'lit/decorators.js';
2
+ import { property, state } from 'lit/decorators.js';
3
3
  import { RapidElement } from '../RapidElement';
4
4
  import { CustomEventType } from '../interfaces';
5
5
  import { getClasses } from '../utils';
@@ -14,7 +14,6 @@ export class FloatingTab extends RapidElement {
14
14
  position: fixed;
15
15
  right: 0;
16
16
  z-index: 4998;
17
- transition: transform var(--transition-duration, 300ms) ease-in-out;
18
17
  display: flex;
19
18
  align-items: center;
20
19
  padding: 12px;
@@ -22,8 +21,11 @@ export class FloatingTab extends RapidElement {
22
21
  border-bottom-left-radius: 8px;
23
22
  cursor: pointer;
24
23
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
25
- transition: all calc(var(--transition-duration, 300ms) * 0.7)
26
- ease-in-out;
24
+ transition: transform calc(var(--transition-duration, 300ms) * 0.7)
25
+ ease-in-out,
26
+ padding-right calc(var(--transition-duration, 300ms) * 0.7)
27
+ ease-in-out,
28
+ box-shadow calc(var(--transition-duration, 300ms) * 0.7) ease-in-out;
27
29
  user-select: none;
28
30
  }
29
31
 
@@ -64,7 +66,9 @@ export class FloatingTab extends RapidElement {
64
66
  `;
65
67
  }
66
68
 
67
- static TAB_HEIGHT = 50; // height of tab for auto-stacking
69
+ static TAB_HEIGHT = 50;
70
+ static TAB_GAP = 10;
71
+ static START_TOP = 100;
68
72
  static allTabs: FloatingTab[] = [];
69
73
 
70
74
  @property({ type: String })
@@ -77,24 +81,18 @@ export class FloatingTab extends RapidElement {
77
81
  color = '#6B7280';
78
82
 
79
83
  @property({ type: Number })
80
- top = -1; // -1 means auto-calculate position
84
+ order = 0;
85
+
86
+ @state()
87
+ top = 100;
81
88
 
82
89
  @property({ type: Boolean })
83
90
  hidden = false;
84
91
 
85
- private autoPositioned = false;
86
-
87
92
  connectedCallback() {
88
93
  super.connectedCallback();
89
94
  FloatingTab.allTabs.push(this);
90
- }
91
-
92
- protected firstUpdated(): void {
93
- // only auto-calculate position if no top was provided (still at default -1)
94
- if (this.top === -1) {
95
- this.autoPositioned = true;
96
- this.updatePosition();
97
- }
95
+ FloatingTab.updateAllPositions();
98
96
  }
99
97
 
100
98
  disconnectedCallback() {
@@ -103,23 +101,16 @@ export class FloatingTab extends RapidElement {
103
101
  if (index > -1) {
104
102
  FloatingTab.allTabs.splice(index, 1);
105
103
  }
106
- // update positions of remaining tabs that use auto-positioning
107
- FloatingTab.allTabs.forEach((tab) => {
108
- if (tab.autoPositioned) {
109
- tab.updatePosition();
110
- }
111
- });
104
+ FloatingTab.updateAllPositions();
112
105
  }
113
106
 
114
- private updatePosition() {
115
- // auto-calculate position based on index
116
- const index = FloatingTab.allTabs.indexOf(this);
117
- if (index === -1) {
118
- this.top = 100; // default fallback
119
- } else {
120
- // start at 150px and stack with TAB_HEIGHT gap between tabs
121
- this.top = 150 + index * (FloatingTab.TAB_HEIGHT + 0);
122
- }
107
+ private static updateAllPositions() {
108
+ const sorted = [...FloatingTab.allTabs].sort((a, b) => a.order - b.order);
109
+ sorted.forEach((tab, index) => {
110
+ tab.top =
111
+ FloatingTab.START_TOP +
112
+ index * (FloatingTab.TAB_HEIGHT + FloatingTab.TAB_GAP);
113
+ });
123
114
  }
124
115
 
125
116
  public updated(
@@ -98,14 +98,16 @@ export class CanvasMenu extends RapidElement {
98
98
  ): void {
99
99
  super.firstUpdated(_changedProperties);
100
100
 
101
- // Close menu when clicking outside
101
+ // Close menu when clicking outside — use mousedown instead of click
102
+ // to avoid being triggered by the click synthesized from a drag-and-drop
103
+ // (mousedown on exit + mouseup on canvas = click on common ancestor)
102
104
  const handleClickOutside = (e: MouseEvent) => {
103
105
  if (this.open && !this.contains(e.target as Node)) {
104
106
  this.close();
105
107
  }
106
108
  };
107
109
 
108
- document.addEventListener('click', handleClickOutside);
110
+ document.addEventListener('mousedown', handleClickOutside);
109
111
 
110
112
  // Store cleanup function
111
113
  (this as any)._clickOutsideHandler = handleClickOutside;
@@ -114,7 +116,10 @@ export class CanvasMenu extends RapidElement {
114
116
  disconnectedCallback(): void {
115
117
  super.disconnectedCallback();
116
118
  if ((this as any)._clickOutsideHandler) {
117
- document.removeEventListener('click', (this as any)._clickOutsideHandler);
119
+ document.removeEventListener(
120
+ 'mousedown',
121
+ (this as any)._clickOutsideHandler
122
+ );
118
123
  }
119
124
  }
120
125
 
@@ -360,11 +360,7 @@ export class CanvasNode extends RapidElement {
360
360
  position: relative;
361
361
  box-shadow: 0 2px 2px rgba(0, 0, 0, .1);
362
362
  cursor: pointer;
363
- pointer-events: none;
364
- }
365
-
366
- .exit.jtk-connected {
367
- background: var(--color-connectors, #e6e6e6);
363
+ pointer-events: all;
368
364
  }
369
365
 
370
366
  .exit.connected {
@@ -376,11 +372,14 @@ export class CanvasNode extends RapidElement {
376
372
  background-color: var(--color-connectors, #e6e6e6);
377
373
  }
378
374
 
379
- .exit.connected.read-only, .exit.connected.read-only:hover {
380
- background-color: #fff;
375
+ .exit.read-only, .exit.read-only:hover {
381
376
  pointer-events: none !important;
382
377
  cursor: default;
383
378
  }
379
+
380
+ .exit.connected.read-only, .exit.connected.read-only:hover {
381
+ background-color: #fff;
382
+ }
384
383
 
385
384
  .exit.removing, .exit.removing:hover {
386
385
  background-color: var(--color-error);