@sme.up/ketchup 4.0.0 → 4.1.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 (186) hide show
  1. package/dist/cjs/{cell-utils-1f89a299.js → cell-utils-841a7769.js} +2 -2
  2. package/dist/cjs/{f-chip-2d58c8f7.js → f-chip-b9f489ff.js} +7 -5
  3. package/dist/cjs/{f-image-5f4f29ca.js → f-image-0c3e6aa7.js} +3 -4
  4. package/dist/cjs/{index-3c471303.js → index-0416afab.js} +73 -64
  5. package/dist/cjs/ketchup.cjs.js +3 -3
  6. package/dist/cjs/kup-accordion.cjs.entry.js +5 -5
  7. package/dist/cjs/kup-autocomplete_29.cjs.entry.js +1014 -1103
  8. package/dist/cjs/kup-calendar.cjs.entry.js +8 -8
  9. package/dist/cjs/kup-dash-list.cjs.entry.js +6 -6
  10. package/dist/cjs/kup-dash_2.cjs.entry.js +106 -62
  11. package/dist/cjs/kup-drawer.cjs.entry.js +4 -4
  12. package/dist/cjs/kup-field.cjs.entry.js +3 -3
  13. package/dist/cjs/kup-iframe.cjs.entry.js +4 -4
  14. package/dist/cjs/kup-lazy.cjs.entry.js +4 -4
  15. package/dist/cjs/kup-magic-box.cjs.entry.js +21 -30
  16. package/dist/cjs/{kup-manager-59ad8bdc.js → kup-manager-828bd598.js} +599 -519
  17. package/dist/cjs/kup-nav-bar.cjs.entry.js +4 -4
  18. package/dist/cjs/{kup-objects-59ea949c.js → kup-objects-89f38d6a.js} +7 -29
  19. package/dist/cjs/kup-probe.cjs.entry.js +3 -3
  20. package/dist/cjs/kup-qlik.cjs.entry.js +3 -3
  21. package/dist/cjs/loader.cjs.js +3 -3
  22. package/dist/cjs/{utils-2af73538.js → utils-5192ee20.js} +1 -1
  23. package/dist/collection/assets/data-table.js +1 -0
  24. package/dist/collection/collection-manifest.json +2 -3
  25. package/dist/collection/components/kup-accordion/kup-accordion.js +14 -14
  26. package/dist/collection/components/kup-autocomplete/kup-autocomplete.css +9 -0
  27. package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +20 -23
  28. package/dist/collection/components/kup-badge/kup-badge.js +12 -12
  29. package/dist/collection/components/kup-box/kup-box.css +30 -30
  30. package/dist/collection/components/kup-box/kup-box.js +181 -171
  31. package/dist/collection/components/kup-button/kup-button.css +8 -5
  32. package/dist/collection/components/kup-button/kup-button.js +26 -26
  33. package/dist/collection/components/kup-button-list/kup-button-list.css +8 -5
  34. package/dist/collection/components/kup-button-list/kup-button-list.js +18 -18
  35. package/dist/collection/components/kup-calendar/kup-calendar.css +8 -6
  36. package/dist/collection/components/kup-calendar/kup-calendar.js +30 -30
  37. package/dist/collection/components/kup-card/kup-card-helper.js +2 -1
  38. package/dist/collection/components/kup-card/kup-card.css +20 -1
  39. package/dist/collection/components/kup-card/kup-card.js +26 -26
  40. package/dist/collection/components/kup-chart/kup-chart.js +40 -40
  41. package/dist/collection/components/kup-checkbox/kup-checkbox.js +18 -18
  42. package/dist/collection/components/kup-chip/kup-chip.css +0 -1
  43. package/dist/collection/components/kup-chip/kup-chip.js +14 -14
  44. package/dist/collection/components/kup-color-picker/kup-color-picker.css +6 -9
  45. package/dist/collection/components/kup-color-picker/kup-color-picker.js +32 -40
  46. package/dist/collection/components/kup-combobox/kup-combobox.css +9 -0
  47. package/dist/collection/components/kup-combobox/kup-combobox.js +20 -23
  48. package/dist/collection/components/kup-dash-list/kup-dash-list.js +2 -2
  49. package/dist/collection/components/kup-data-table/kup-data-table-declarations.js +1 -0
  50. package/dist/collection/components/kup-data-table/kup-data-table-helper.js +25 -46
  51. package/dist/collection/components/kup-data-table/kup-data-table.css +83 -87
  52. package/dist/collection/components/kup-data-table/kup-data-table.js +364 -531
  53. package/dist/collection/components/kup-date-picker/kup-date-picker.css +2373 -5
  54. package/dist/collection/components/kup-date-picker/kup-date-picker.js +72 -104
  55. package/dist/collection/components/kup-drawer/kup-drawer.js +8 -8
  56. package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.css +13 -5
  57. package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.js +38 -43
  58. package/dist/collection/components/kup-field/kup-field.js +20 -20
  59. package/dist/collection/components/kup-gauge/kup-gauge.js +16 -16
  60. package/dist/collection/components/kup-grid/kup-grid.css +2 -1
  61. package/dist/collection/components/kup-grid/kup-grid.js +12 -12
  62. package/dist/collection/components/kup-iframe/kup-iframe.js +4 -4
  63. package/dist/collection/components/kup-image/kup-image.js +24 -24
  64. package/dist/collection/components/kup-lazy/kup-lazy.js +16 -16
  65. package/dist/collection/components/kup-list/kup-list-declarations.js +1 -1
  66. package/dist/collection/components/kup-list/kup-list.css +4 -0
  67. package/dist/collection/components/kup-list/kup-list.js +38 -47
  68. package/dist/collection/components/kup-magic-box/kup-magic-box.css +11 -6
  69. package/dist/collection/components/kup-magic-box/kup-magic-box.js +27 -36
  70. package/dist/collection/components/kup-nav-bar/kup-nav-bar.js +10 -10
  71. package/dist/collection/components/kup-paginator/kup-paginator.css +8 -5
  72. package/dist/collection/components/kup-probe/kup-probe.js +8 -8
  73. package/dist/collection/components/kup-progress-bar/kup-progress-bar.js +20 -20
  74. package/dist/collection/components/kup-radio/kup-radio.js +16 -16
  75. package/dist/collection/components/kup-rating/kup-rating.js +14 -14
  76. package/dist/collection/components/kup-spinner/kup-spinner.js +22 -22
  77. package/dist/collection/components/kup-switch/kup-switch.js +16 -16
  78. package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +12 -12
  79. package/dist/collection/components/kup-text-field/kup-text-field.js +48 -48
  80. package/dist/collection/components/kup-time-picker/kup-time-picker.css +2376 -0
  81. package/dist/collection/components/kup-time-picker/kup-time-picker.js +50 -83
  82. package/dist/collection/components/kup-tooltip/kup-tooltip.js +18 -12
  83. package/dist/collection/components/kup-tree/kup-tree.css +10 -10
  84. package/dist/collection/components/kup-tree/kup-tree.js +96 -66
  85. package/dist/collection/f-components/f-button/f-button.js +4 -2
  86. package/dist/collection/f-components/f-image/f-image.js +1 -2
  87. package/dist/collection/f-components/f-text-field/f-text-field.js +8 -6
  88. package/dist/collection/utils/kup-column-menu/kup-column-menu.js +11 -3
  89. package/dist/collection/utils/kup-debug/kup-debug.js +25 -27
  90. package/dist/collection/utils/kup-dynamic-position/kup-dynamic-position.js +3 -5
  91. package/dist/collection/utils/kup-interact/kup-interact-declarations.js +48 -0
  92. package/dist/collection/utils/kup-interact/kup-interact.js +362 -0
  93. package/dist/collection/utils/kup-manager/kup-manager.js +18 -6
  94. package/dist/collection/utils/kup-objects/kup-objects.js +7 -29
  95. package/dist/collection/utils/kup-scroll-on-hover/kup-scroll-on-hover.js +60 -62
  96. package/dist/collection/utils/kup-toolbar/kup-toolbar.js +16 -18
  97. package/dist/esm/{cell-utils-cb612463.js → cell-utils-de384721.js} +2 -2
  98. package/dist/esm/{f-chip-125d5dd6.js → f-chip-d585b63e.js} +7 -5
  99. package/dist/esm/{f-image-68b34fab.js → f-image-23548d00.js} +3 -4
  100. package/dist/esm/{index-bf2824a6.js → index-51694018.js} +73 -64
  101. package/dist/esm/ketchup.js +3 -3
  102. package/dist/esm/kup-accordion.entry.js +5 -5
  103. package/dist/esm/kup-autocomplete_29.entry.js +818 -907
  104. package/dist/esm/kup-calendar.entry.js +8 -8
  105. package/dist/esm/kup-dash-list.entry.js +6 -6
  106. package/dist/esm/kup-dash_2.entry.js +106 -62
  107. package/dist/esm/kup-drawer.entry.js +4 -4
  108. package/dist/esm/kup-field.entry.js +3 -3
  109. package/dist/esm/kup-iframe.entry.js +4 -4
  110. package/dist/esm/kup-lazy.entry.js +4 -4
  111. package/dist/esm/kup-magic-box.entry.js +21 -30
  112. package/dist/esm/{kup-manager-e7d7b353.js → kup-manager-583f2815.js} +595 -520
  113. package/dist/esm/kup-nav-bar.entry.js +4 -4
  114. package/dist/esm/{kup-objects-d38d2fa2.js → kup-objects-5968aefd.js} +7 -29
  115. package/dist/esm/kup-probe.entry.js +3 -3
  116. package/dist/esm/kup-qlik.entry.js +3 -3
  117. package/dist/esm/loader.js +3 -3
  118. package/dist/esm/{utils-13dd007a.js → utils-a1dd14c3.js} +1 -1
  119. package/dist/ketchup/ketchup.esm.js +1 -1
  120. package/dist/ketchup/{p-64ea7e37.entry.js → p-0e91c9c9.entry.js} +1 -1
  121. package/dist/ketchup/{p-0320e24e.entry.js → p-0f2b6a24.entry.js} +1 -1
  122. package/dist/ketchup/{p-a5424073.js → p-361d9431.js} +1 -1
  123. package/dist/ketchup/p-565785ce.js +1 -0
  124. package/dist/ketchup/{p-7896031c.entry.js → p-57eb45ac.entry.js} +1 -1
  125. package/dist/ketchup/{p-08c7a092.js → p-6f5d8830.js} +1 -1
  126. package/dist/ketchup/{p-9c858a38.entry.js → p-802d8906.entry.js} +1 -1
  127. package/dist/ketchup/p-850b9e67.entry.js +1 -0
  128. package/dist/ketchup/{p-a12a5690.entry.js → p-88a5787a.entry.js} +1 -1
  129. package/dist/ketchup/p-8ed2b7bf.entry.js +1 -0
  130. package/dist/ketchup/{p-ee89966f.entry.js → p-90a0c2b7.entry.js} +2 -2
  131. package/dist/ketchup/{p-876da4c2.entry.js → p-94c0dd8c.entry.js} +1 -1
  132. package/dist/ketchup/p-9ec3c377.entry.js +45 -0
  133. package/dist/ketchup/p-b30f34d8.js +1 -0
  134. package/dist/ketchup/p-b6a47512.entry.js +1 -0
  135. package/dist/ketchup/p-bfaf8a82.js +1 -0
  136. package/dist/ketchup/{p-940ab57a.entry.js → p-ca0ebdcc.entry.js} +1 -1
  137. package/dist/ketchup/p-d5a3a4ed.js +1 -0
  138. package/dist/ketchup/{p-c7ee1fbc.js → p-ee7b190c.js} +1 -1
  139. package/dist/ketchup/{p-b0724035.entry.js → p-f6b54fa1.entry.js} +1 -1
  140. package/dist/types/components/kup-box/kup-box-declarations.d.ts +11 -2
  141. package/dist/types/components/kup-box/kup-box.d.ts +8 -4
  142. package/dist/types/components/kup-color-picker/kup-color-picker.d.ts +0 -1
  143. package/dist/types/components/kup-data-table/kup-data-table-declarations.d.ts +12 -4
  144. package/dist/types/components/kup-data-table/kup-data-table-helper.d.ts +0 -2
  145. package/dist/types/components/kup-data-table/kup-data-table.d.ts +16 -49
  146. package/dist/types/components/kup-date-picker/kup-date-picker.d.ts +11 -14
  147. package/dist/types/components/kup-dropdown-button/kup-dropdown-button.d.ts +0 -4
  148. package/dist/types/components/kup-list/kup-list-declarations.d.ts +1 -1
  149. package/dist/types/components/kup-list/kup-list.d.ts +2 -3
  150. package/dist/types/components/kup-magic-box/kup-magic-box.d.ts +1 -0
  151. package/dist/types/components/kup-time-picker/kup-time-picker.d.ts +7 -11
  152. package/dist/types/components/kup-tree/kup-tree-declarations.d.ts +4 -4
  153. package/dist/types/components/kup-tree/kup-tree.d.ts +3 -0
  154. package/dist/types/components.d.ts +84 -121
  155. package/dist/types/utils/kup-dynamic-position/kup-dynamic-position.d.ts +2 -2
  156. package/dist/types/utils/kup-interact/kup-interact-declarations.d.ts +127 -0
  157. package/dist/types/utils/kup-interact/kup-interact.d.ts +93 -0
  158. package/dist/types/utils/kup-manager/kup-manager-declarations.d.ts +21 -4
  159. package/dist/types/utils/kup-manager/kup-manager.d.ts +2 -2
  160. package/dist/types/utils/kup-objects/kup-objects.d.ts +1 -7
  161. package/package.json +3 -3
  162. package/dist/cjs/drag-and-drop-4787ff6f.js +0 -281
  163. package/dist/cjs/kup-grid.cjs.entry.js +0 -130
  164. package/dist/collection/assets/images/drag-multiple.js +0 -1
  165. package/dist/collection/components/kup-layout/kup-layout.css +0 -53
  166. package/dist/collection/components/kup-layout/kup-layout.js +0 -156
  167. package/dist/collection/utils/drag-and-drop.js +0 -109
  168. package/dist/collection/utils/kup-dialog/kup-dialog-declarations.js +0 -36
  169. package/dist/collection/utils/kup-dialog/kup-dialog.js +0 -310
  170. package/dist/esm/drag-and-drop-321cb4ca.js +0 -265
  171. package/dist/esm/kup-grid.entry.js +0 -126
  172. package/dist/ketchup/p-00fe1e3e.js +0 -1
  173. package/dist/ketchup/p-1165f4ea.entry.js +0 -1
  174. package/dist/ketchup/p-170d3cba.js +0 -1
  175. package/dist/ketchup/p-18cb3ba3.js +0 -1
  176. package/dist/ketchup/p-23541a97.entry.js +0 -45
  177. package/dist/ketchup/p-8fb9d9b2.entry.js +0 -1
  178. package/dist/ketchup/p-b14e77f0.js +0 -1
  179. package/dist/ketchup/p-d24cfdea.entry.js +0 -1
  180. package/dist/ketchup/p-fcd2fd8f.js +0 -1
  181. package/dist/ketchup/p-fce3b9d8.entry.js +0 -1
  182. package/dist/types/assets/images/drag-multiple.d.ts +0 -1
  183. package/dist/types/components/kup-layout/kup-layout.d.ts +0 -25
  184. package/dist/types/utils/drag-and-drop.d.ts +0 -53
  185. package/dist/types/utils/kup-dialog/kup-dialog-declarations.d.ts +0 -43
  186. package/dist/types/utils/kup-dialog/kup-dialog.d.ts +0 -50
@@ -0,0 +1,362 @@
1
+ import interact from 'interactjs';
2
+ import { kupDialogAttribute, kupDialogResizableClass, KupDragEffect, kupDraggableAttr, kupDraggableCellAttr, kupDraggableColumnAttr, kupDraggableRowAttr, kupDragOverAttr, kupDropEvent, } from './kup-interact-declarations';
3
+ const dom = document.documentElement;
4
+ /**
5
+ * This class handles elements as dialogs, making them resizable and movable.
6
+ * @module KupInteract
7
+ */
8
+ export class KupInteract {
9
+ /**
10
+ * Initializes KupInteract.
11
+ * @param {number} zIndex - The starting z-index assigned to dialogs.
12
+ * @param {RectResolvable<[number, number, Interaction<keyof ActionMap>]>} restrictContainer - The container setting the restriction's boundary.
13
+ */
14
+ constructor(zIndex, restrictContainer) {
15
+ interact.dynamicDrop(true);
16
+ this.container = document.createElement('div');
17
+ this.container.setAttribute('kup-interact', '');
18
+ document.body.appendChild(this.container);
19
+ this.managedElements = new Set();
20
+ this.zIndex = zIndex ? zIndex : 200;
21
+ this.restrictContainer = restrictContainer ? restrictContainer : null;
22
+ }
23
+ /**
24
+ * Sets up a new draggable element.
25
+ * @param {HTMLElement} el - The draggable element.
26
+ * @param {Partial<DraggableOptions>} options - Options of the draggable element.
27
+ * @param {KupDragEventData} eventData - Property used to transfer data for the drop event. The callback is used to return information of the starting item - such as cell, column and row info.
28
+ * @param {KupDragEffect} effect - Visual effect of the drag action.
29
+ * @param {KupDragCallbacks} callbacks - Additional callbacks to invoke.
30
+ * @see https://interactjs.io/docs/action-options/ For more options
31
+ */
32
+ draggable(el, options, eventData, effect, callbacks) {
33
+ el.style.touchAction = 'none';
34
+ el.style.userSelect = 'none';
35
+ if (!options) {
36
+ options = {};
37
+ }
38
+ if (!effect) {
39
+ effect = KupDragEffect.MOVE;
40
+ }
41
+ options.listeners = {
42
+ move(e) {
43
+ if (callbacks && callbacks.move) {
44
+ callbacks.move(e);
45
+ }
46
+ if (effect.toLowerCase() !== KupDragEffect.NONE) {
47
+ const draggable = e.target;
48
+ const ghostImage = draggable.kupDragDrop &&
49
+ draggable.kupDragDrop.ghostImage
50
+ ? draggable.kupDragDrop.ghostImage
51
+ : e.target;
52
+ const oldTransform = ghostImage.style.transform;
53
+ let x = parseFloat(ghostImage.getAttribute('data-x')) || 0;
54
+ let y = parseFloat(ghostImage.getAttribute('data-y')) || 0;
55
+ x = x + e.dx;
56
+ y = y + e.dy;
57
+ ghostImage.style.transform = `translate(${x}px, ${y}px)`;
58
+ if (dom.ketchup.interact.isInViewport(el, oldTransform, e.delta)) {
59
+ ghostImage.setAttribute('data-x', x.toString());
60
+ ghostImage.setAttribute('data-y', y.toString());
61
+ }
62
+ }
63
+ },
64
+ start(e) {
65
+ if (callbacks && callbacks.start) {
66
+ callbacks.start(e);
67
+ }
68
+ const draggable = e.target;
69
+ const draggableDetails = eventData && eventData.callback
70
+ ? eventData.callback(e)
71
+ : {};
72
+ draggable.kupDragDrop = draggableDetails;
73
+ draggable.setAttribute(kupDraggableAttr, '');
74
+ if (draggableDetails.cell) {
75
+ draggable.setAttribute(kupDraggableCellAttr, '');
76
+ }
77
+ if (draggableDetails.column) {
78
+ draggable.setAttribute(kupDraggableColumnAttr, '');
79
+ }
80
+ if (draggableDetails.row) {
81
+ draggable.setAttribute(kupDraggableRowAttr, '');
82
+ }
83
+ let ghostImage = null;
84
+ switch (effect) {
85
+ case KupDragEffect.BADGE:
86
+ ghostImage = document.createElement('kup-badge');
87
+ if (draggable.kupDragDrop.multiple) {
88
+ ghostImage.text = draggable.kupDragDrop.selectedRows
89
+ ? draggable.kupDragDrop.selectedRows.length.toString()
90
+ : '0';
91
+ }
92
+ else {
93
+ ghostImage.text = '1';
94
+ }
95
+ ghostImage.style.left =
96
+ e.clientX - ghostImage.clientWidth / 2 + 'px';
97
+ ghostImage.style.pointerEvents = 'none';
98
+ ghostImage.style.position = 'fixed';
99
+ ghostImage.style.top =
100
+ e.clientY - ghostImage.clientHeight / 2 + 'px';
101
+ ghostImage.style.transition = 'none';
102
+ ghostImage.style.zIndex =
103
+ 'calc(var(--kup-navbar-zindex) + 1)';
104
+ dom.ketchup.interact.container.appendChild(ghostImage);
105
+ draggable.kupDragDrop.ghostImage = ghostImage;
106
+ break;
107
+ case KupDragEffect.CLONE:
108
+ ghostImage = draggable.cloneNode(true);
109
+ ghostImage.style.cursor = 'grabbing';
110
+ ghostImage.style.height = draggable.clientHeight + 'px';
111
+ ghostImage.style.left =
112
+ e.clientX - draggable.clientWidth / 2 + 'px';
113
+ ghostImage.style.opacity = '0.75';
114
+ ghostImage.style.position = 'fixed';
115
+ ghostImage.style.top =
116
+ e.clientY - draggable.clientHeight / 2 + 'px';
117
+ ghostImage.style.width = draggable.clientWidth + 'px';
118
+ ghostImage.style.zIndex =
119
+ 'calc(var(--kup-navbar-zindex) + 1)';
120
+ if (draggable.parentElement) {
121
+ draggable.parentElement.appendChild(ghostImage);
122
+ }
123
+ else {
124
+ dom.ketchup.interact.container.appendChild(ghostImage);
125
+ }
126
+ draggable.kupDragDrop.ghostImage = ghostImage;
127
+ break;
128
+ }
129
+ },
130
+ end(e) {
131
+ if (callbacks && callbacks.end) {
132
+ callbacks.end(e);
133
+ }
134
+ const draggable = e.target;
135
+ const ghostImage = draggable.kupDragDrop
136
+ ? draggable.kupDragDrop.ghostImage
137
+ : null;
138
+ if (ghostImage) {
139
+ ghostImage.remove();
140
+ }
141
+ draggable.removeAttribute(kupDraggableAttr);
142
+ draggable.removeAttribute(kupDraggableCellAttr);
143
+ draggable.removeAttribute(kupDraggableColumnAttr);
144
+ draggable.removeAttribute(kupDraggableRowAttr);
145
+ },
146
+ };
147
+ interact(el).draggable(options);
148
+ this.managedElements.add(el);
149
+ }
150
+ /**
151
+ * Sets up a new dropzone.
152
+ * @param {HTMLElement} el - The dropzone element.
153
+ * @param {DropzoneOptions} options - Options of the dropzone.
154
+ * @param {KupDropEventData} eventData - Argument used to transfer data for the drop event. The callback is used to return information of the receiving item - such as cell, column and row info.
155
+ * @param {KupDropCallbacks} callbacks - Additional callbacks to invoke.
156
+ * @see https://interactjs.io/docs/action-options/ For more options
157
+ */
158
+ dropzone(el, options, eventData, callbacks) {
159
+ if (!options) {
160
+ options = {};
161
+ }
162
+ options.listeners = {
163
+ drop(e) {
164
+ if (callbacks && callbacks.drop) {
165
+ callbacks.drop(e);
166
+ }
167
+ if (eventData) {
168
+ const draggableDetails = e.relatedTarget.kupDragDrop ||
169
+ {};
170
+ const dropzoneDetails = eventData.callback
171
+ ? eventData.callback()
172
+ : {};
173
+ const ketchupDropEvent = new CustomEvent(kupDropEvent, {
174
+ bubbles: true,
175
+ cancelable: true,
176
+ detail: {
177
+ dataType: eventData.type,
178
+ sourceElement: {
179
+ id: draggableDetails.id
180
+ ? draggableDetails.id
181
+ : '',
182
+ row: draggableDetails.row
183
+ ? draggableDetails.row
184
+ : null,
185
+ selectedRows: draggableDetails.selectedRows
186
+ ? draggableDetails.selectedRows
187
+ : null,
188
+ cell: draggableDetails.cell
189
+ ? draggableDetails.cell
190
+ : null,
191
+ column: draggableDetails.column
192
+ ? draggableDetails.column
193
+ : null,
194
+ },
195
+ targetElement: {
196
+ id: dropzoneDetails.id
197
+ ? dropzoneDetails.id
198
+ : '',
199
+ row: dropzoneDetails.row
200
+ ? dropzoneDetails.row
201
+ : null,
202
+ cell: dropzoneDetails.cell
203
+ ? dropzoneDetails.cell
204
+ : null,
205
+ column: dropzoneDetails.column
206
+ ? dropzoneDetails.column
207
+ : null,
208
+ },
209
+ },
210
+ });
211
+ e.currentTarget.removeAttribute(kupDragOverAttr);
212
+ eventData.dispatcher.dispatchEvent(ketchupDropEvent);
213
+ }
214
+ e.currentTarget.removeAttribute(kupDragOverAttr);
215
+ },
216
+ enter(e) {
217
+ if (callbacks && callbacks.enter) {
218
+ callbacks.enter(e);
219
+ }
220
+ e.currentTarget.setAttribute(kupDragOverAttr, '');
221
+ },
222
+ leave(e) {
223
+ if (callbacks && callbacks.leave) {
224
+ callbacks.leave(e);
225
+ }
226
+ e.currentTarget.removeAttribute(kupDragOverAttr);
227
+ },
228
+ };
229
+ interact(el).dropzone(options);
230
+ this.managedElements.add(el);
231
+ }
232
+ /**
233
+ * Sets up a new resizable element.
234
+ * @param {HTMLElement} el - The resizable element.
235
+ * @param {Partial<ResizableOptions>} options - Options of the resize action.
236
+ * @param {KupResizeCallbacks} callbacks - Additional callbacks to invoke.
237
+ * @param {boolean} moveOnResize - When true, the element will be moved when resizing in order to keep its position.
238
+ * @see https://interactjs.io/docs/action-options/ For more options
239
+ */
240
+ resizable(el, options, callbacks, moveOnResize) {
241
+ if (!options) {
242
+ options = {};
243
+ }
244
+ options.listeners = {
245
+ move(e) {
246
+ if (callbacks && callbacks.move) {
247
+ callbacks.move(e);
248
+ }
249
+ if (moveOnResize) {
250
+ const el = e.target;
251
+ const oldTransform = e.target.style.transform;
252
+ let x = parseFloat(el.getAttribute('data-x')) || 0;
253
+ let y = parseFloat(el.getAttribute('data-y')) || 0;
254
+ el.style.width = e.rect.width + 'px';
255
+ el.style.height = e.rect.height + 'px';
256
+ x += e.deltaRect.left;
257
+ y += e.deltaRect.top;
258
+ el.style.transform = 'translate(' + x + 'px,' + y + 'px)';
259
+ if (dom.ketchup.interact.isInViewport(el, oldTransform, e.delta)) {
260
+ el.setAttribute('data-x', x.toString());
261
+ el.setAttribute('data-y', y.toString());
262
+ }
263
+ }
264
+ },
265
+ };
266
+ interact(el).resizable(options);
267
+ this.managedElements.add(el);
268
+ }
269
+ /**
270
+ * Adds a new interact.js event listener to the given argument.
271
+ * @param {HTMLElement} el - The element on which the event listener will be added.
272
+ * @param {KupPointerEventTypes} event - Supported events.
273
+ * @param {KupResizeCallbacks} callback - Callback to invoke when the event fires.
274
+ */
275
+ on(el, event, callback) {
276
+ interact(el).on(event, callback);
277
+ this.managedElements.add(el);
278
+ }
279
+ /**
280
+ * This method checks whether the element is breaking the viewport boundaries.
281
+ * @param {HTMLElement} el - Element to check.
282
+ * @param {string} oldTransform - Previously set transform, used to rollback in case element breaks viewport boundaries.
283
+ * @param {Point} delta - X and Y delta values of the last movement.
284
+ */
285
+ isInViewport(el, oldTransform, delta) {
286
+ const style = window.getComputedStyle(el);
287
+ const isFixed = !!(style.position === 'fixed');
288
+ const rect = el.getBoundingClientRect();
289
+ if (rect.left < 0 ||
290
+ rect.top < 0 ||
291
+ (isFixed && rect.right > window.innerWidth && delta.x >= 0) ||
292
+ (isFixed && rect.bottom > window.innerHeight && delta.y >= 0)) {
293
+ el.style.transform = oldTransform;
294
+ return false;
295
+ }
296
+ return true;
297
+ }
298
+ /**
299
+ * This method treats the given element as a dialog, by activating moving-on-drag and, optionally, its resize.
300
+ * @param {HTMLElement} el - Dialog element.
301
+ * @param {HTMLElement} handleEl - Element that must be dragged in order to trigger movement. When not provided, dragging anywhere on "el" will move it.
302
+ * @param {boolean} unresizable - When true, the dialog can't be resized.
303
+ * @param {RectResolvable<[number, number, Interaction<keyof ActionMap>]>} restrictContainer - When present, it will set the constraint of "el": it can't be moved outside this container.
304
+ */
305
+ dialogify(el, handleEl, unresizable, restrictContainer) {
306
+ el.setAttribute(kupDialogAttribute, '');
307
+ el.style.zIndex = (this.zIndex++).toString();
308
+ const callbacks = {
309
+ start(e) {
310
+ const el = e.currentTarget;
311
+ el.style.zIndex = (dom.ketchup.interact.zIndex++).toString();
312
+ },
313
+ };
314
+ this.draggable(el, {
315
+ allowFrom: handleEl ? handleEl : null,
316
+ modifiers: [
317
+ interact.modifiers.restrictRect({
318
+ restriction: restrictContainer
319
+ ? restrictContainer
320
+ : dom.ketchup.interact.restrictContainer,
321
+ endOnly: true,
322
+ }),
323
+ ],
324
+ }, null, KupDragEffect.MOVE, callbacks);
325
+ if (!unresizable) {
326
+ el.classList.add(kupDialogResizableClass);
327
+ this.resizable(el, {
328
+ edges: {
329
+ left: true,
330
+ right: true,
331
+ bottom: true,
332
+ top: false,
333
+ },
334
+ modifiers: [
335
+ interact.modifiers.restrictSize({
336
+ min: { width: 100, height: 100 },
337
+ }),
338
+ ],
339
+ }, null, true);
340
+ }
341
+ }
342
+ /**
343
+ * Removes the elements from the MoveOnDrag class watchlist.
344
+ * @param {HTMLElement[]} elements - Elements to remove.
345
+ */
346
+ unregister(elements) {
347
+ if (this.managedElements) {
348
+ for (let index = 0; index < elements.length; index++) {
349
+ this.managedElements.delete(elements[index]);
350
+ interact(elements[index]).unset();
351
+ }
352
+ }
353
+ }
354
+ /**
355
+ * Returns whether an element was previously registered or not.
356
+ * @param {HTMLElement} el - Element to test.
357
+ * @returns {boolean} True if the element was registered.
358
+ */
359
+ isRegistered(el) {
360
+ return !this.managedElements ? false : this.managedElements.has(el);
361
+ }
362
+ }
@@ -1,6 +1,6 @@
1
1
  import { KupDebug } from '../kup-debug/kup-debug';
2
- import { KupDialog } from '../kup-dialog/kup-dialog';
3
2
  import { KupDynamicPosition } from '../kup-dynamic-position/kup-dynamic-position';
3
+ import { KupInteract } from '../kup-interact/kup-interact';
4
4
  import { KupLanguage } from '../kup-language/kup-language';
5
5
  import { KupObjects } from '../kup-objects/kup-objects';
6
6
  import { KupScrollOnHover } from '../kup-scroll-on-hover/kup-scroll-on-hover';
@@ -21,11 +21,11 @@ export class KupManager {
21
21
  * Initializes KupManager.
22
22
  */
23
23
  constructor(overrides) {
24
- let datesLocale = null, debugActive = null, debugAutoprint = null, debugLogLimit = null, dialogZIndex = null, languageList = null, languageName = null, objectsList = null, scrollOnHoverDelay = null, scrollOnHoverStep = null, themeList = null, themeName = null;
24
+ let datesLocale = null, debugActive = null, debugAutoprint = null, debugLogLimit = null, dialogRestrictContainer = null, dialogZIndex = null, languageList = null, languageName = null, objectsList = null, scrollOnHoverDelay = null, scrollOnHoverStep = null, themeList = null, themeName = null;
25
25
  if (overrides) {
26
26
  const dates = overrides.dates;
27
27
  const debug = overrides.debug;
28
- const dialog = overrides.dialog;
28
+ const interact = overrides.interact;
29
29
  const language = overrides.language;
30
30
  const objects = overrides.objects;
31
31
  const scrollOnHover = overrides.scrollOnHover;
@@ -38,8 +38,11 @@ export class KupManager {
38
38
  debugAutoprint = debug.autoPrint ? debug.autoPrint : null;
39
39
  debugLogLimit = debug.logLimit ? debug.logLimit : null;
40
40
  }
41
- if (dialog) {
42
- dialogZIndex = dialog.zIndex ? dialog.zIndex : null;
41
+ if (interact) {
42
+ dialogRestrictContainer = interact.restrictContainer
43
+ ? dialogRestrictContainer
44
+ : null;
45
+ dialogZIndex = interact.zIndex ? interact.zIndex : null;
43
46
  }
44
47
  if (language) {
45
48
  languageList = language.list ? language.list : null;
@@ -63,8 +66,8 @@ export class KupManager {
63
66
  }
64
67
  this.dates = new KupDates(datesLocale);
65
68
  this.debug = new KupDebug(debugActive, debugAutoprint, debugLogLimit);
66
- this.dialog = new KupDialog(dialogZIndex);
67
69
  this.dynamicPosition = new KupDynamicPosition();
70
+ this.interact = new KupInteract(dialogZIndex, dialogRestrictContainer);
68
71
  this.language = new KupLanguage(languageList, languageName);
69
72
  this.magicBox = null;
70
73
  this.overrides = overrides ? overrides : null;
@@ -89,6 +92,7 @@ export class KupManager {
89
92
  this.utilities = {
90
93
  lastPointerDownPath: null,
91
94
  lastPointerDownString: null,
95
+ pointerDownCallbacks: new Set(),
92
96
  };
93
97
  this.theme = new KupTheme(themeList, themeName);
94
98
  this.toolbar = new KupToolbar();
@@ -97,6 +101,14 @@ export class KupManager {
97
101
  const lastString = paths[0].innerText || paths[0].value;
98
102
  this.utilities.lastPointerDownPath = paths;
99
103
  this.utilities.lastPointerDownString = lastString;
104
+ this.utilities.pointerDownCallbacks.forEach((obj) => {
105
+ if (obj.el.isConnected && !paths.includes(obj.el)) {
106
+ obj.cb();
107
+ if (obj.onlyOnce) {
108
+ this.utilities.pointerDownCallbacks.delete(obj);
109
+ }
110
+ }
111
+ });
100
112
  if (lastString) {
101
113
  document.dispatchEvent(new CustomEvent('kup-manager-stringfinder', {
102
114
  bubbles: true,
@@ -48,42 +48,18 @@ export class KupObjects {
48
48
  * @returns {boolean} True when the object has extra columns.
49
49
  */
50
50
  canObjHaveExtraColumns(obj) {
51
- if (!obj)
52
- return false;
53
- if (!obj.t ||
54
- obj.t.trim() == '' ||
55
- obj.t.trim() == '**') {
51
+ if (this.isEmptyKupObj(obj)) {
56
52
  return false;
57
53
  }
58
- return (!this.isBar(obj) &&
59
- !this.isButton(obj) &&
60
- !this.isCheckbox(obj) &&
61
- !this.isIcon(obj) &&
62
- !this.isImage(obj) &&
63
- !this.isLink(obj) &&
64
- !this.isProgressBar(obj) &&
65
- !this.isRadio(obj) &&
66
- !this.isVoCodver(obj) &&
67
- !this.isChart(obj));
68
- }
69
- /**
70
- * Checks whether the object can have a related tooltip or not.
71
- * @param {KupObj} obj - Object to check.
72
- * @returns {boolean} True when the object can have a related tooltip.
73
- */
74
- hasTooltip(obj) {
75
- if (!obj)
76
- return false;
77
- if (obj.t == null || obj.t.trim() == '')
54
+ if (obj.t.trim() == '**') {
78
55
  return false;
56
+ }
79
57
  return (!this.isBar(obj) &&
80
58
  !this.isButton(obj) &&
81
59
  !this.isCheckbox(obj) &&
82
60
  !this.isIcon(obj) &&
83
61
  !this.isImage(obj) &&
84
62
  !this.isLink(obj) &&
85
- !this.isNumber(obj) &&
86
- !this.isPercentage(obj) &&
87
63
  !this.isProgressBar(obj) &&
88
64
  !this.isRadio(obj) &&
89
65
  !this.isVoCodver(obj) &&
@@ -310,10 +286,12 @@ export class KupObjects {
310
286
  * @param {KupObj} obj - Object to check.
311
287
  * @returns {boolean} True when the object is null or empty.
312
288
  */
313
- isEmptySmeupObject(obj) {
289
+ isEmptyKupObj(obj) {
314
290
  if (!obj)
315
291
  return true;
316
- return obj.t.trim() == '' && obj.p.trim() == '' && obj.k.trim() == '';
292
+ return ((!obj.t || obj.t.trim() == '') &&
293
+ (!obj.p || obj.p.trim() == '') &&
294
+ (!obj.k || obj.k.trim() == ''));
317
295
  }
318
296
  /**
319
297
  * Parses a date depending on the object's type.