@componyx/ui 0.0.0-stage → 1.0.3

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 (169) hide show
  1. package/AppSkin/AppSkin.css +1268 -0
  2. package/AppSkin/AppSkin.js +2748 -0
  3. package/AppSkin/Themes/Default.css +241 -0
  4. package/Base/Base.js +3407 -0
  5. package/Base/ComponentIcons.css +66 -0
  6. package/Base/Font/ComponentIcons.woff +0 -0
  7. package/Base/Font/UI.woff +0 -0
  8. package/Base/Library.js +8432 -0
  9. package/Base/NavigationManager.js +462 -0
  10. package/Base/ResponsiveTemplates.js +371 -0
  11. package/Base/Sanitizer.js +288 -0
  12. package/Base/Themes/Default.css +255 -0
  13. package/Base/UI.css +618 -0
  14. package/Base/UIResourcePath.js +6 -0
  15. package/Bindary/Bindary.js +2011 -0
  16. package/Bindary/Modules/Connection.js +216 -0
  17. package/Bindary/Modules/Core.js +854 -0
  18. package/Bindary/Modules/DataUpdater.js +351 -0
  19. package/Bindary/Modules/ExpressionEngine.js +347 -0
  20. package/Bindary/Modules/ProxyManager.js +482 -0
  21. package/Bindary/Modules/Renderer.js +605 -0
  22. package/Bindary/Modules/Router.js +291 -0
  23. package/Bindary/Modules/Scroller.js +89 -0
  24. package/Bindary/Modules/Template.js +1273 -0
  25. package/BookmarkSpy/BookmarkSpy.js +430 -0
  26. package/Box/Box.css +36 -0
  27. package/Box/Box.js +1685 -0
  28. package/Button/Button.css +470 -0
  29. package/Button/Button.js +1398 -0
  30. package/Button/Themes/Default.css +200 -0
  31. package/Carousel/Carousel.css +273 -0
  32. package/Carousel/Carousel.js +607 -0
  33. package/ColorButton/ColorButton.css +39 -0
  34. package/ColorButton/ColorButton.js +336 -0
  35. package/ColorPicker/ColorPicker.css +359 -0
  36. package/ColorPicker/ColorPicker.js +972 -0
  37. package/ComboBox/ComboBox.css +357 -0
  38. package/ComboBox/ComboBox.js +2342 -0
  39. package/ComboBox/Themes/Default.css +23 -0
  40. package/DataPager/DataPager.css +72 -0
  41. package/DataPager/DataPager.js +674 -0
  42. package/DatePicker/DatePicker.css +227 -0
  43. package/DatePicker/DatePicker.js +1531 -0
  44. package/DatePicker/Themes/Default.css +26 -0
  45. package/Dialog/Dialog.css +106 -0
  46. package/Dialog/Dialog.js +572 -0
  47. package/Dialog/Themes/Default.css +10 -0
  48. package/Editor/Data/Emoji.json +8285 -0
  49. package/Editor/Data/Special.json +1042 -0
  50. package/Editor/Editor.css +1562 -0
  51. package/Editor/Editor.js +4058 -0
  52. package/Editor/Font/Editor.woff +0 -0
  53. package/Editor/Modules/ComponentFactory.js +565 -0
  54. package/Editor/Modules/ContentManager.js +748 -0
  55. package/Editor/Modules/DialogManager.js +1234 -0
  56. package/Editor/Modules/EventManager.js +458 -0
  57. package/Editor/Modules/Format.js +950 -0
  58. package/Editor/Modules/History.js +191 -0
  59. package/Editor/Modules/LayoutState.js +379 -0
  60. package/Editor/Modules/ListManager.js +296 -0
  61. package/Editor/Modules/MenuManager.js +388 -0
  62. package/Editor/Modules/NodeManager.js +681 -0
  63. package/Editor/Modules/ParagraphButtons.js +122 -0
  64. package/Editor/Modules/Resizer.js +176 -0
  65. package/Editor/Modules/SelectionRange.js +564 -0
  66. package/Editor/Modules/SourceViewBuilder.js +212 -0
  67. package/Editor/Modules/SymbolPicker.js +208 -0
  68. package/Editor/Modules/Table.js +2327 -0
  69. package/Editor/Modules/TableDialog.js +757 -0
  70. package/Editor/Modules/Toolbar.js +375 -0
  71. package/Editor/Modules/TooltipMenu.js +125 -0
  72. package/Editor/Modules/Utility.js +131 -0
  73. package/Editor/Themes/Default.css +204 -0
  74. package/FileUpload/FileUpload.css +156 -0
  75. package/FileUpload/FileUpload.js +898 -0
  76. package/FileUpload/Themes/Default.css +17 -0
  77. package/Form/Form.css +1934 -0
  78. package/Form/Form.js +4943 -0
  79. package/Form/Modules/ActionManager.js +368 -0
  80. package/Form/Modules/BuildPanelManager.js +319 -0
  81. package/Form/Modules/ComponentFactory.js +468 -0
  82. package/Form/Modules/ComponentPanel.js +265 -0
  83. package/Form/Modules/ConfigPanelManager.js +685 -0
  84. package/Form/Modules/DataObserver.js +717 -0
  85. package/Form/Modules/Databinder.js +602 -0
  86. package/Form/Modules/Draggable.js +756 -0
  87. package/Form/Modules/OptionsPanel.js +342 -0
  88. package/Form/Modules/Renderer.js +1889 -0
  89. package/Form/Modules/RuleEngine.js +585 -0
  90. package/Form/Modules/RulesPanel.js +1158 -0
  91. package/Form/Modules/Types.js +1709 -0
  92. package/Form/Modules/ValidationManager.js +194 -0
  93. package/Form/Themes/Default.css +216 -0
  94. package/FormField/FormField.css +468 -0
  95. package/FormField/FormField.js +576 -0
  96. package/FormField/Themes/Default.css +99 -0
  97. package/Grid/Grid.css +544 -0
  98. package/Grid/Grid.js +3761 -0
  99. package/Grid/Themes/Default.css +43 -0
  100. package/LICENSE +126 -0
  101. package/MaskedTextBox/MaskedTextBox.css +28 -0
  102. package/MaskedTextBox/MaskedTextBox.js +642 -0
  103. package/MaskedTextBox/Themes/Default.css +6 -0
  104. package/Menu/Menu.css +328 -0
  105. package/Menu/Menu.js +2386 -0
  106. package/Menu/Themes/Default.css +24 -0
  107. package/NumericBox/NumericBox.css +120 -0
  108. package/NumericBox/NumericBox.js +984 -0
  109. package/PanelBar/PanelBar.css +123 -0
  110. package/PanelBar/PanelBar.js +505 -0
  111. package/PanelBar/Themes/Default.css +51 -0
  112. package/PieChart/PieChart.css +95 -0
  113. package/PieChart/PieChart.js +820 -0
  114. package/PieChart/Themes/Default.css +9 -0
  115. package/README.md +178 -3
  116. package/Slider/Slider.css +348 -0
  117. package/Slider/Slider.js +1306 -0
  118. package/Slider/Themes/Default.css +44 -0
  119. package/TabStrip/TabStrip.css +52 -0
  120. package/TabStrip/TabStrip.js +362 -0
  121. package/TabStrip/Themes/Default.css +35 -0
  122. package/TimePicker/Themes/Default.css +30 -0
  123. package/TimePicker/TimePicker.css +253 -0
  124. package/TimePicker/TimePicker.js +1485 -0
  125. package/TooltipManager/Themes/Default.css +21 -0
  126. package/TooltipManager/TooltipManager.css +227 -0
  127. package/TooltipManager/TooltipManager.js +791 -0
  128. package/Validator/Validator.css +54 -0
  129. package/Validator/Validator.js +2508 -0
  130. package/componyx.html-data.json +619 -0
  131. package/index.js +27 -0
  132. package/package.json +43 -4
  133. package/types/AppSkin.d.ts +842 -0
  134. package/types/Base.d.ts +1034 -0
  135. package/types/Bindary.d.ts +1196 -0
  136. package/types/BookmarkSpy.d.ts +112 -0
  137. package/types/Box.d.ts +374 -0
  138. package/types/Button.d.ts +455 -0
  139. package/types/Carousel.d.ts +136 -0
  140. package/types/ColorButton.d.ts +120 -0
  141. package/types/ColorPicker.d.ts +225 -0
  142. package/types/ComboBox.d.ts +507 -0
  143. package/types/DataPager.d.ts +152 -0
  144. package/types/DatePicker.d.ts +354 -0
  145. package/types/Dialog.d.ts +160 -0
  146. package/types/Editor.d.ts +1289 -0
  147. package/types/FileUpload.d.ts +206 -0
  148. package/types/Form.d.ts +3078 -0
  149. package/types/FormField.d.ts +204 -0
  150. package/types/Grid.d.ts +911 -0
  151. package/types/Library.d.ts +1899 -0
  152. package/types/MaskedTextBox.d.ts +91 -0
  153. package/types/Menu.d.ts +577 -0
  154. package/types/NumericBox.d.ts +310 -0
  155. package/types/PanelBar.d.ts +223 -0
  156. package/types/PieChart.d.ts +224 -0
  157. package/types/ResponsiveTemplates.d.ts +108 -0
  158. package/types/Slider.d.ts +227 -0
  159. package/types/TabStrip.d.ts +185 -0
  160. package/types/TimePicker.d.ts +265 -0
  161. package/types/TooltipManager.d.ts +178 -0
  162. package/types/UI.d.ts +29 -0
  163. package/types/Validator.d.ts +653 -0
  164. package/types/index.d.ts +59 -0
  165. package/ui.css +11783 -0
  166. package/ui.js +79477 -0
  167. package/ui.min.css +138 -0
  168. package/ui.min.js +264 -0
  169. package/ui.min.js.map +1 -0
@@ -0,0 +1,791 @@
1
+ /*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
2
+ import '../Base/Base.js';
3
+ import '../Base/Library.js';
4
+ import '../Box/Box.js';
5
+
6
+ (function (window)
7
+ {
8
+ /**
9
+ * TooltipManager class.
10
+ * @class
11
+ * @memberof componyx.UI
12
+ * @augments componyx.UI.base.Component
13
+ * @mixes componyx.UI.base.methods
14
+ * @param {String} id The id of the component.
15
+ * @param {Object|HTMLElement} properties The properties used to initialize the component or the container element.
16
+ * @returns {Object} An instance of the component.
17
+ */
18
+ componyx.UI.TooltipManager = function TooltipManager(id, properties)
19
+ {
20
+ var _instance = this;
21
+ $base.static.ThemeOption;
22
+ var _allowHide = true, _hideBlock, _boxDown, _hasFocus = new Map(), _box, _boxes = {}, _tooltipRefreshed = {}, _blurTimerId,
23
+ _pointerEventOption = componyx.UI.TooltipManager.PointerEventOption,
24
+ _triggers = new Map();
25
+
26
+ // define public properties
27
+ /**
28
+ * Gets or sets the css class of the tooltip box.
29
+ * @type {String}
30
+ */
31
+ this.cssClassBox = '';
32
+
33
+ /**
34
+ * Gets or sets the time in ms that tooltips remains visible (0 to keep visible).
35
+ * @type {Number|null}
36
+ */
37
+ this.visibleDuration = null;
38
+
39
+ /**
40
+ * Gets or sets a value which defines on which pointer event the tooltip is shown.
41
+ * @type {componyx.UI.TooltipManager.PointerEventOption}
42
+ */
43
+ this.showOnPointerEvent = _pointerEventOption.ENTER;
44
+
45
+ /**
46
+ * Gets or sets a value indicating if the tooltip is shown on a focus event.
47
+ * @type {Boolean}
48
+ */
49
+ this.showOnFocus = true;
50
+
51
+ /**
52
+ * Gets or sets a value indicating if the tooltip is shown on a blur event.
53
+ * @type {Boolean}
54
+ */
55
+ this.showOnBlur = false;
56
+
57
+ /**
58
+ * Gets or sets a value indicating if tooltip content is selectable, which means that the tooltip will remain visible on a pointer enter/click event.
59
+ * @type {Boolean}
60
+ */
61
+ this.selectableTooltipContent = false;
62
+
63
+ /**
64
+ * Gets or sets the time in ms before the tooltip is displayed.
65
+ * @type {Number}
66
+ */
67
+ this.showDelay = 200;
68
+
69
+ /**
70
+ * Gets or sets the time in ms before the tooltip is hidden.
71
+ * @type {Number}
72
+ */
73
+ this.hideDelay = 200;
74
+
75
+ /**
76
+ * Gets or sets a value indicating if the direction arrow styles should be applied.
77
+ * @type {Boolean}
78
+ */
79
+ this.arrowless = false;
80
+
81
+ /**
82
+ * Gets or sets a value indicating if a single box instance is used to display tooltips (defaults to true). When set to false multiple tooltips can be visible at the same time. Only set to false when required because a single instance has less overhead.
83
+ * @type {Boolean}
84
+ */
85
+ this.singleBoxInstance = true;
86
+
87
+ /**
88
+ * Gets or sets the list of tooltip triggers.
89
+ * @type {componyx.UI.TooltipManager.Trigger[]|object|Map}
90
+ */
91
+ Object.defineProperty(this, 'triggers', {
92
+ get: function ()
93
+ {
94
+ return _triggers;
95
+ },
96
+ set: function (value)
97
+ {
98
+ if (value instanceof Map)
99
+ {
100
+ _triggers = value;
101
+ return;
102
+ }
103
+
104
+ var map = new Map();
105
+
106
+ if (Array.isArray(value))
107
+ {
108
+ value.forEach(function (trigger)
109
+ {
110
+ map.set(trigger.triggerId, trigger);
111
+ });
112
+ }
113
+ else
114
+ {
115
+ $lib.each(value, function (trigger, triggerId)
116
+ {
117
+ map.set(triggerId, trigger);
118
+ });
119
+ }
120
+
121
+ _triggers = map;
122
+ },
123
+ enumerable: true,
124
+ configurable: true
125
+ });
126
+
127
+ /**
128
+ * Gets or sets the clientid of the tooltip box.
129
+ * @type {String|null}
130
+ */
131
+ this.boxId = null;
132
+
133
+
134
+ // inherit base instance members
135
+ $base.Component.apply(this, [id, properties]);
136
+
137
+ /**
138
+ * Gets the instance of the Box component used to display the tooltips.
139
+ * @param {String} [tooltipId] Id of the tooltip template.
140
+ * @returns {componyx.UI.Box} The Box component used to display the tooltips.
141
+ */
142
+ this.getBox = function (tooltipId)
143
+ {
144
+ return getBox(tooltipId);
145
+ };
146
+
147
+ /**
148
+ * Gets the active trigger id.
149
+ * @param {String} [tooltipId] Id of the tooltip template.
150
+ * @returns {String|HTMLElement} The active trigger id.
151
+ */
152
+ this.activeTriggerId = function (tooltipId)
153
+ {
154
+ return getBox(tooltipId).__currentTriggerId;
155
+ };
156
+
157
+ /**
158
+ * Adds a tooltip template.
159
+ * @param {String} id Id of the tooltip template.
160
+ * @param {HTMLElement|HTMLElement[]|DocumentFragment|String} content Template content.
161
+ * @param {Boolean} cloneable Defines if the template can be cloned for multiple views.
162
+ */
163
+ this.addTooltip = function (id, content, clonable)
164
+ {
165
+ _instance.addTemplate(id, content, clonable);
166
+ _tooltipRefreshed[id] = true;
167
+
168
+ if (!_instance.singleBoxInstance && !_boxes[id])
169
+ createBox(id);
170
+ };
171
+
172
+ /**
173
+ * Removes a tooltip template.
174
+ * @param {String} id Id of the tooltip template.
175
+ * @param {Boolean} keepTriggers=false A value indicating if the tooltip triggers should be kept.
176
+ */
177
+ this.removeTooltip = function (id, keepTriggers = false)
178
+ {
179
+ var index,
180
+ clearTriggers = [], box = getBox(id);
181
+
182
+ _instance.addTemplate(id, null);
183
+ _tooltipRefreshed[id] = true;
184
+
185
+ if (!keepTriggers)
186
+ {
187
+ _instance.triggers.forEach(function (trigger, triggerId)
188
+ {
189
+ if (trigger.tooltipId === id)
190
+ clearTriggers.push(triggerId);
191
+ });
192
+
193
+ for (index = 0; index < clearTriggers.length; ++index)
194
+ {
195
+ _instance.removeTrigger(clearTriggers[index]);
196
+ }
197
+ }
198
+
199
+ if (!$lib.isEmpty(box.__currentTriggerId))
200
+ {
201
+ clearTimeout(box.__timerId);
202
+ box.hide(true);
203
+ box.__currentTriggerId = null;
204
+ }
205
+
206
+ if (!_instance.singleBoxInstance)
207
+ {
208
+ box.destroy();
209
+ delete _boxes[id];
210
+ }
211
+ else if (box.__tooltipId === id)
212
+ box.contentElement.innerHTML = ''; // clear content when active tooltip is removed
213
+ };
214
+
215
+ /**
216
+ * Adds a tooltip trigger.
217
+ * @param {String|HTMLElement} triggerId The trigger element or element id that triggers the tooltip display.
218
+ * @param {String} tooltipId The id of the tooltip template.
219
+ * @param {componyx.UI.TooltipManager.PointerEventOption} showOnPointerEvent Gets or sets a value which defines on which pointer event the tooltip is shown.
220
+ * @param {Boolean} showOnFocus Sets a value indicating if the tooltip is shown on a focus event.
221
+ * @param {Boolean} showOnBlur Sets a value indicating if the tooltip is shown on a blur event.
222
+ */
223
+ this.addTrigger = function (triggerId, tooltipId, showOnPointerEvent, showOnFocus, showOnBlur)
224
+ {
225
+ _instance.triggers.set(triggerId, { tooltipId: tooltipId, showOnFocus: showOnFocus, showOnBlur: showOnBlur, showOnPointerEvent: showOnPointerEvent });
226
+
227
+ if (_instance.renderState == $base.static.RenderState.RENDERED)
228
+ bindTriggerEvents(triggerId);
229
+ };
230
+
231
+ /**
232
+ * Removes a tooltip trigger.
233
+ * @param {String|HTMLElement} triggerId The trigger element or element id that triggers the tooltip display.
234
+ */
235
+ this.removeTrigger = function (triggerId)
236
+ {
237
+ if (_instance.renderState == $base.static.RenderState.RENDERED)
238
+ removeEvent(triggerId);
239
+
240
+ _instance.triggers.delete(triggerId);
241
+ };
242
+
243
+ /**
244
+ * Shows the tooltip with the specified triggerId.
245
+ * @param {String|HTMLElement} triggerId The trigger element or element id that triggers the tooltip display.
246
+ * @param {Boolean} [fromPointerDown=false] Set to true when called from a pointerdown handler, so the tooltip is not hidden by the pointerdown on the document that follows.
247
+ */
248
+ this.showTooltip = function (triggerId, fromPointerDown = false)
249
+ {
250
+ if (fromPointerDown)
251
+ _allowHide = false; // same as triggerClick: the document pointerdown handler skips this one hide
252
+
253
+ showTooltip(triggerId);
254
+ };
255
+
256
+ /**
257
+ * Hides the tooltip with the specified triggerId.
258
+ * @param {String} [triggerId] The trigger element or element id that triggered the tooltip. When a value is provided the tooltip is hidden only if current trigger id matches the specified value.
259
+ * @param {Boolean} [instant] A value indicating if the tooltip should be hidden instantly without animation.
260
+ */
261
+ this.hideTooltip = function (triggerId, instant)
262
+ {
263
+ hideTooltip(triggerId, instant);
264
+ };
265
+
266
+ /**
267
+ * Hides all tooltips.
268
+ * @param {Boolean} [instant] A value indicating if the tooltip should be hidden instantly without animation.
269
+ */
270
+ this.hideAllTooltips = function (instant)
271
+ {
272
+ hideAllTooltips(instant);
273
+ };
274
+
275
+ /**
276
+ * Sets a value indicating if tooltip hiding is allowed.
277
+ * @param {Boolean} [value] A value indicating if tooltip hiding is allowed.
278
+ */
279
+ this.allowHide = function (value)
280
+ {
281
+ _hideBlock = !value;
282
+ };
283
+
284
+ /**
285
+ * Renders the component.
286
+ */
287
+ this.render = function ()
288
+ {
289
+ if (_instance.renderState != $base.static.RenderState.RENDERING)
290
+ {
291
+ // call base render and return
292
+ $base.methods.render.call(_instance, preRender, 'tooltip-manager');
293
+ return;
294
+ }
295
+
296
+ // render logic after loading resources
297
+ if (_instance.singleBoxInstance)
298
+ createBox();
299
+ else
300
+ {
301
+ var ready = true;
302
+
303
+ $lib.each(_instance.templates, function (template, id)
304
+ {
305
+ if (!_boxes[id])
306
+ {
307
+ ready = false;
308
+ createBox(id);
309
+ }
310
+ });
311
+
312
+ if (ready)
313
+ postRender();
314
+ }
315
+ };
316
+
317
+ /**
318
+ * Destroys the component.
319
+ * @see {@link componyx.UI.base.methods#destroy}
320
+ */
321
+ this.destroy = function (...args)
322
+ {
323
+ dispose();
324
+ $base.methods.destroy.call(this, ...args);
325
+ };
326
+
327
+ function preRender()
328
+ {
329
+ // initialize script and css
330
+ return ['TooltipManager', ['Box']];
331
+ }
332
+
333
+ function postRender()
334
+ {
335
+ if (_instance.renderState == $base.static.RenderState.RENDERED)
336
+ return;
337
+
338
+ bindEvents();
339
+ $base.methods.postRender.call(_instance);
340
+ }
341
+
342
+ function createBox(tooltipId)
343
+ {
344
+ var id = _instance.id + '_Box',
345
+ arrowless = (_instance.arrowless) ? ' arrowless' : '';
346
+
347
+ if (tooltipId)
348
+ id += tooltipId;
349
+
350
+ _box = $UI.createComponent(componyx.UI.Box, { id: id, containerElement: _instance.element });
351
+ _box.clone($UI.store[_instance.boxId], _instance);
352
+ _box.cssClass = (_box.cssClass || _instance.cssClassBox || 'box tooltip') + arrowless;
353
+ _box.theme = $base.static.ThemeOption.NONE;
354
+ _box.autoPosition = (_box.autoPosition != null && _box.autoPosition != componyx.UI.Box.AutoPositionOption.NONE) ? _box.autoPosition : componyx.UI.Box.AutoPositionOption.POINTER;
355
+ _box.style = (!_instance.selectableTooltipContent) ? "pointer-events: none" : "";
356
+ _box.__timerId = null;
357
+ _box.__currentTriggerId = null;
358
+ _box.events.onPostRender.priorityAdd(postRender, null);
359
+
360
+ _box.events.onHideComplete.priorityAdd(hideTooltipComplete, tooltipId);
361
+ _box.render();
362
+
363
+ if (tooltipId)
364
+ _boxes[tooltipId] = _box;
365
+ }
366
+
367
+ function bindEvents()
368
+ {
369
+ _instance.triggers.forEach(function (trigger, triggerId)
370
+ {
371
+ bindTriggerEvents(triggerId);
372
+ });
373
+
374
+ if (_instance.singleBoxInstance)
375
+ bindBoxEvents();
376
+
377
+ $lib.on(document, 'pointerdown', hideAllTooltips, false);
378
+ }
379
+
380
+ function bindTriggerEvents(triggerId)
381
+ {
382
+ var eventType = null,
383
+ trigger = _instance.triggers.get(triggerId),
384
+ showOnFocus = _instance.showOnFocus,
385
+ showOnBlur = _instance.showOnBlur,
386
+ element = ($lib.isElement(triggerId)) ? triggerId : $lib('#' + triggerId.toString()),
387
+ tooltipId = trigger.tooltipId,
388
+ fn = showTooltipDelayed;
389
+
390
+ removeEvent(triggerId);
391
+
392
+ if (_instance.showOnPointerEvent != _pointerEventOption.NONE)
393
+ eventType = getPointerEventType(_instance.showOnPointerEvent);
394
+
395
+ if (!$lib.isEmpty(trigger.showOnPointerEvent) && trigger.showOnPointerEvent != _instance.showOnPointerEvent)
396
+ {
397
+ if (trigger.showOnPointerEvent == _pointerEventOption.NONE)
398
+ eventType = null;
399
+ else
400
+ eventType = getPointerEventType(trigger.showOnPointerEvent);
401
+ }
402
+
403
+ if (!$lib.isEmpty(trigger.showOnFocus) && trigger.showOnFocus != showOnFocus)
404
+ showOnFocus = trigger.showOnFocus;
405
+
406
+ if (!$lib.isEmpty(trigger.showOnBlur) && trigger.showOnBlur != showOnBlur)
407
+ showOnBlur = trigger.showOnBlur;
408
+
409
+ if ((eventType && $lib.has(element, eventType, showTooltipDelayed)) || (!eventType && $lib.has(element, 'focus', triggerFocus)))
410
+ return;
411
+
412
+ if (eventType == 'pointerdown')
413
+ fn = triggerClick;
414
+
415
+ if (eventType)
416
+ $lib.on(element, eventType, fn, triggerId);
417
+
418
+ if (eventType == 'pointerenter')
419
+ $lib.on(element, 'pointerleave', hideTooltipDelayed, triggerId);
420
+
421
+ if (showOnFocus)
422
+ {
423
+ $lib.on(element, 'focus', triggerFocus, triggerId);
424
+ $lib.on(element, 'blur', triggerBlurDelayed, [triggerId, false]);
425
+ }
426
+
427
+ if (showOnBlur)
428
+ $lib.on(element, 'blur', triggerBlur, [triggerId, true]);
429
+
430
+ if (!_instance.singleBoxInstance)
431
+ bindBoxEvents(tooltipId);
432
+ }
433
+
434
+ function bindBoxEvents(tooltipId)
435
+ {
436
+ var box = getBox(tooltipId);
437
+
438
+ if (!box || !_instance.selectableTooltipContent)
439
+ return;
440
+
441
+ if (!box.trackPointer && !$lib.has(box.element, 'pointerenter', boxEnter))
442
+ {
443
+ $lib.on(box.element, 'pointerenter', boxEnter, [tooltipId]);
444
+
445
+ $lib.on(box.element, 'pointerleave', function (tooltipId)
446
+ {
447
+ if ($lib.isEmpty(getBox(tooltipId).__currentTriggerId))
448
+ return;
449
+
450
+ var event = getPointerEvent(getBox(tooltipId).__currentTriggerId);
451
+
452
+ if (event == _pointerEventOption.ENTER)
453
+ {
454
+ var now = new Date().getTime();
455
+ box.__extraHideDelay = null;
456
+
457
+ if (_instance.visibleDuration > 0 && (now - box.__visibleStart) < _instance.visibleDuration)
458
+ box.__extraHideDelay = _instance.visibleDuration - (now - box.__visibleStart);
459
+
460
+ hideTooltipDelayed(getBox(tooltipId).__currentTriggerId);
461
+ }
462
+
463
+
464
+ }, [tooltipId]);
465
+
466
+ $lib.on(box.element, 'pointerdown', function ()
467
+ {
468
+ _boxDown = true;
469
+ _allowHide = false;
470
+ });
471
+ }
472
+ }
473
+
474
+ function boxEnter(tooltipId)
475
+ {
476
+ clearTimeout(getBox(tooltipId).__timerId);
477
+ }
478
+
479
+ function getPointerEvent(triggerId)
480
+ {
481
+ var trigger = _instance.triggers.get(triggerId);
482
+ return (!$lib.isEmpty(trigger.showOnPointerEvent)) ? trigger.showOnPointerEvent : _instance.showOnPointerEvent;
483
+ }
484
+
485
+ function getPointerEventType(pointerEvent)
486
+ {
487
+ return (pointerEvent == _pointerEventOption.DOWN) ? 'pointerdown' : (pointerEvent == _pointerEventOption.ENTER) ? 'pointerenter' : 'contextmenu';
488
+ }
489
+
490
+ function removeEvent(triggerId)
491
+ {
492
+ var element = ($lib.isElement(triggerId)) ? triggerId : $lib('#' + triggerId.toString());
493
+
494
+ if (!element)
495
+ return;
496
+
497
+ $lib.off(element, 'pointerdown', triggerClick);
498
+ $lib.off(element, 'pointerenter contextmenu', showTooltipDelayed);
499
+ $lib.off(element, 'pointerleave', hideTooltipDelayed);
500
+ $lib.off(element, 'focus', triggerFocus);
501
+ $lib.off(element, 'blur', triggerBlur);
502
+ $lib.off(element, 'blur', triggerBlurDelayed);
503
+ }
504
+
505
+ function triggerFocus(triggerId, e)
506
+ {
507
+ clearTimeout(_blurTimerId);
508
+ _hasFocus.set(triggerId, true);
509
+ showTooltipDelayed(triggerId);
510
+ }
511
+
512
+ function triggerBlurDelayed(triggerId, showOnBlur)
513
+ {
514
+ _blurTimerId = setTimeout(triggerBlur.bind(_instance, triggerId, showOnBlur), 0);
515
+ }
516
+
517
+ function triggerBlur(triggerId, showOnBlur, e)
518
+ {
519
+ if (_boxDown) // selectableTooltipContent is true and blur is caused by pointer down on box
520
+ _allowHide = false;
521
+ else
522
+ _allowHide = true;
523
+
524
+ _boxDown = false;
525
+ _hasFocus.set(triggerId, false);
526
+
527
+ if (showOnBlur)
528
+ showTooltipDelayed(triggerId);
529
+ else
530
+ hideTooltipDelayed(triggerId);
531
+
532
+ _allowHide = true;
533
+ }
534
+
535
+ function triggerClick(triggerId)
536
+ {
537
+ _allowHide = false;
538
+ showTooltipDelayed(triggerId);
539
+ }
540
+
541
+ function setVisibleTime(triggerId)
542
+ {
543
+ if (_instance.visibleDuration > 0)
544
+ {
545
+ var box = getBox(getTooltipId(triggerId));
546
+ box.__extraHideDelay = null;
547
+ box.__visibleStart = new Date().getTime();
548
+ box.__timerId = setTimeout(function () { hideTooltip(triggerId); }, _instance.visibleDuration);
549
+ }
550
+ }
551
+
552
+ function showTooltipDelayed(triggerId)
553
+ {
554
+ var tooltipId = getTooltipId(triggerId),
555
+ box = getBox(tooltipId);
556
+
557
+ if ($lib.event.type == 'contextmenu')
558
+ $lib.event.preventDefault(); // cancel default browser menu
559
+
560
+ clearTimeout(box.__timerId);
561
+
562
+ if (!_instance.showDelay || (triggerId == box.__currentTriggerId && box.showing))
563
+ {
564
+ box.__currentTriggerId = triggerId;
565
+ showTooltip(triggerId);
566
+ }
567
+ else
568
+ {
569
+ box.hide(true);
570
+ box.__currentTriggerId = triggerId;
571
+ box.__timerId = setTimeout(function () { showTooltip(triggerId); }, _instance.showDelay);
572
+ }
573
+ }
574
+
575
+ function showTooltip(triggerId)
576
+ {
577
+ var tooltipId = _instance.triggers.get(triggerId)?.tooltipId,
578
+ box = (tooltipId) ? getBox(tooltipId) : null,
579
+ boxAutoPos = box.autoPosition, trigger;
580
+
581
+ if (!box || !_instance.hasTemplate(tooltipId))
582
+ return;
583
+
584
+ clearTimeout(box.__timerId);
585
+
586
+ if (box.showing)
587
+ {
588
+ trigger = (typeof triggerId === 'string') ? $lib('#' + triggerId) : triggerId;
589
+
590
+ if (box.expander && box.expander != trigger)
591
+ box.expander = triggerId;
592
+
593
+ box.__currentTriggerId = triggerId;
594
+ updateBox(tooltipId, triggerId);
595
+ return;
596
+ }
597
+
598
+ box.hide(true);
599
+ box.__currentTriggerId = triggerId;
600
+
601
+ if (boxAutoPos == componyx.UI.Box.AutoPositionOption.POINTER && $lib.event && $lib.event.type === 'focus')
602
+ box.autoPosition = componyx.UI.Box.AutoPositionOption.EXPAND; // focus event does not work on mouse cursor since clientX and clientY are undefined
603
+
604
+ if (box.autoPosition == componyx.UI.Box.AutoPositionOption.EXPAND)
605
+ box.expander = triggerId;
606
+
607
+ updateBox(tooltipId, triggerId);
608
+ box.autoPosition = boxAutoPos; // restore original setting
609
+ }
610
+
611
+ function hideAllTooltips(instant)
612
+ {
613
+ if (!_allowHide || _hideBlock)
614
+ {
615
+ _allowHide = true;
616
+ return;
617
+ }
618
+
619
+ if (_instance.singleBoxInstance)
620
+ {
621
+ let box = getBox();
622
+
623
+ if (!box)
624
+ return;
625
+
626
+ if (instant || (!_instance.hideDelay && !box.__extraHideDelay))
627
+ {
628
+ clearTimeout(box.__timerId);
629
+ box.hide(instant);
630
+ }
631
+ else
632
+ {
633
+ box.__timerId = setTimeout(function ()
634
+ {
635
+ clearTimeout(box.__timerId);
636
+ box.hide();
637
+ }, (_instance.hideDelay || 0) + box.__extraHideDelay || 0);
638
+
639
+ box.__extraHideDelay = null;
640
+ }
641
+ }
642
+ else
643
+ {
644
+ _instance.triggers.forEach(function (trigger, triggerId)
645
+ {
646
+ if (instant)
647
+ hideTooltip(triggerId, true);
648
+ else
649
+ hideTooltipDelayed(triggerId);
650
+ });
651
+ }
652
+
653
+ _allowHide = true;
654
+ }
655
+
656
+ function hideTooltipDelayed(triggerId)
657
+ {
658
+ if ($lib.isEmpty(triggerId))
659
+ return;
660
+
661
+ var tooltipId = getTooltipId(triggerId),
662
+ box = (tooltipId) ? getBox(tooltipId) : null;
663
+
664
+ if ($lib.isEmpty(tooltipId) || box.__currentTriggerId != triggerId || _hasFocus.get(triggerId))
665
+ return;
666
+
667
+ if (!_allowHide || _hideBlock)
668
+ return;
669
+
670
+ clearTimeout(box.__timerId);
671
+
672
+ if (!_instance.hideDelay && !box.__extraHideDelay)
673
+ hideTooltip(triggerId);
674
+ else
675
+ box.__timerId = setTimeout(function () { hideTooltip(triggerId); }, (_instance.hideDelay || 0) + box.__extraHideDelay || 0);
676
+
677
+ box.__extraHideDelay = null;
678
+ }
679
+
680
+ function hideTooltip(triggerId, instant)
681
+ {
682
+ if (_hideBlock)
683
+ return;
684
+
685
+ var tooltipId = getTooltipId(triggerId),
686
+ box = getBox(tooltipId);
687
+
688
+ if ($lib.isEmpty(tooltipId) || box.__currentTriggerId != triggerId)
689
+ return;
690
+
691
+ clearTimeout(box.__timerId);
692
+ box.hide(instant);
693
+ }
694
+
695
+ function hideTooltipComplete(tooltipId)
696
+ {
697
+ getBox(tooltipId).__currentTriggerId = null;
698
+ }
699
+
700
+ function updateBox(tooltipId, triggerId)
701
+ {
702
+ var box = getBox(tooltipId), content;
703
+
704
+ if (!_tooltipRefreshed[tooltipId] && (content = extractBoxContent(tooltipId)) && content.childNodes.length > 0)
705
+ _instance.addTemplate(box.__tooltipId, content, _instance.templates.get(box.__tooltipId).cloneable); // reset template content and use current active tooltipId to set correct template when singleBoxInstance is enabled
706
+
707
+ box.contentElement.innerHTML = '';
708
+ _instance.applyTemplate(box.contentElement, tooltipId);
709
+ _tooltipRefreshed[tooltipId] = false;
710
+ box.__tooltipId = tooltipId;
711
+ box.update(null, true);
712
+ setVisibleTime(triggerId);
713
+ }
714
+
715
+ function getTooltipId(triggerId)
716
+ {
717
+ var trigger = _instance.triggers.get(triggerId);
718
+
719
+ if (trigger)
720
+ return trigger.tooltipId;
721
+ }
722
+
723
+ function getBox(tooltipId)
724
+ {
725
+ if (_instance.singleBoxInstance)
726
+ return _box;
727
+ else
728
+ return _boxes[tooltipId];
729
+ }
730
+
731
+ function extractBoxContent(tooltipId)
732
+ {
733
+ return $lib.extract(getBox(tooltipId).contentElement);
734
+ }
735
+
736
+ function dispose()
737
+ {
738
+ $lib.off(document, 'pointerdown', hideAllTooltips);
739
+
740
+ _instance.triggers.forEach(function (trigger, triggerId)
741
+ {
742
+ removeEvent(triggerId);
743
+ });
744
+
745
+ _boxDown = false;
746
+ _allowHide = true;
747
+ }
748
+ };
749
+
750
+ /**
751
+ * @see {@link componyx.UI.base.methods}
752
+ */
753
+ componyx.UI.TooltipManager.prototype = Object.create($base.methods);
754
+ componyx.UI.TooltipManager.prototype.constructor = componyx.UI.TooltipManager;
755
+
756
+ /**
757
+ * PointerEventOption
758
+ * @readonly
759
+ * @enum {number}
760
+ */
761
+ componyx.UI.TooltipManager.PointerEventOption =
762
+ {
763
+ NONE: 0,
764
+ ENTER: 1,
765
+ DOWN: 2,
766
+ CONTEXT: 3
767
+ };
768
+
769
+
770
+ /**
771
+ * Creates an instance of the Trigger.
772
+ * @class
773
+ * @property {String} triggerId Gets or sets the id of the trigger element.
774
+ * @property {String} tooltipId Gets or sets the id of the tooltip template.
775
+ * @property {PointerEventOption} showOnPointerEvent Gets or sets a value which defines on which pointer event the tooltip is shown.
776
+ * @property {boolean} showOnFocus Gets or sets a value indicating if the tooltip is shown on a focus event.
777
+ * @property {boolean} showOnBlur Gets or sets a value indicating if the tooltip is shown on a blur event.
778
+ */
779
+ componyx.UI.TooltipManager.Trigger = function ()
780
+ {
781
+ this.triggerId = null;
782
+ this.tooltipId = null;
783
+ this.showOnPointerEvent = null;
784
+ this.showOnFocus = null;
785
+ this.showOnBlur = null;
786
+ };
787
+ })();
788
+
789
+ const TooltipManager = componyx.UI.TooltipManager;
790
+
791
+ export { TooltipManager };