@progress/kendo-vue-tooltip 2.7.1-dev.202112201049

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.
@@ -0,0 +1,416 @@
1
+ "use strict";
2
+
3
+ var __assign = undefined && undefined.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ Object.defineProperty(exports, "__esModule", {
20
+ value: true
21
+ });
22
+ exports.TooltipVue3 = exports.Tooltip = void 0; // @ts-ignore
23
+
24
+ var Vue = require("vue");
25
+
26
+ var allVue = Vue;
27
+ var gh = allVue.h;
28
+
29
+ var kendo_vue_common_1 = require("@progress/kendo-vue-common");
30
+
31
+ var utils_1 = require("./utils");
32
+
33
+ var package_metadata_1 = require("./package-metadata");
34
+
35
+ var DEFAULT_TOOLTIP_ZINDEX = 100; // tslint:enable:max-line-length
36
+
37
+ var Tooltip = {
38
+ name: 'KendoTooltip',
39
+ inheritAttrs: false,
40
+ props: {
41
+ anchorElement: {
42
+ type: String,
43
+ default: 'pointer',
44
+ validator: function validator(value) {
45
+ return ['pointer', 'target'].includes(value);
46
+ }
47
+ },
48
+ content: [String, Object, Function],
49
+ filter: Function,
50
+ openDelay: {
51
+ type: Number,
52
+ default: 400
53
+ },
54
+ open: {
55
+ type: Boolean,
56
+ default: undefined
57
+ },
58
+ position: {
59
+ type: String,
60
+ default: 'auto',
61
+ validator: function validator(value) {
62
+ return ['right', 'left', 'top', 'bottom', 'auto'].includes(value);
63
+ }
64
+ },
65
+ updateInterval: Number,
66
+ className: String,
67
+ wrapperStyle: Object,
68
+ tooltipClassName: String,
69
+ tooltipStyle: Object,
70
+ parentTitle: {
71
+ type: Boolean,
72
+ default: false
73
+ }
74
+ },
75
+ data: function data() {
76
+ return {
77
+ top: 0,
78
+ left: 0,
79
+ targetElement: null,
80
+ currentOpen: false,
81
+ title: ''
82
+ };
83
+ },
84
+ computed: {
85
+ wrapperClass: function wrapperClass() {
86
+ var _a;
87
+
88
+ return _a = {
89
+ 'k-animation-container': true,
90
+ 'k-animation-container-fixed': true,
91
+ 'k-animation-container-shown': true
92
+ }, _a[this.$props.className] = true, _a;
93
+ }
94
+ },
95
+ created: function created() {
96
+ kendo_vue_common_1.validatePackage(package_metadata_1.packageMetadata);
97
+ this.top = 0;
98
+ this.left = 0;
99
+ this.willOpen = false;
100
+ },
101
+ mounted: function mounted() {
102
+ if (document) {
103
+ document.body.addEventListener('mousemove', this.handleBodyMousemove);
104
+ }
105
+ },
106
+ destroyed: function destroyed() {
107
+ clearTimeout(this.openTimeoutId);
108
+ clearInterval(this.updateIntervalId);
109
+
110
+ if (document) {
111
+ document.body.removeEventListener('mousemove', this.handleBodyMousemove);
112
+ }
113
+
114
+ if (this.element) {
115
+ this.element.remove();
116
+ }
117
+ },
118
+ updated: function updated() {
119
+ if (this.$props.targetElement) {
120
+ this.showToolTip({
121
+ target: this.$props.targetElement
122
+ });
123
+ }
124
+
125
+ this.element = this.v3 ? this.elementRef : this.$refs.element;
126
+
127
+ if (!this.element) {
128
+ return;
129
+ }
130
+
131
+ var position;
132
+
133
+ if (this.$props.onPosition) {
134
+ position = this.$props.onPosition.call(undefined, {
135
+ element: this.element,
136
+ targetElement: this.state.targetElement,
137
+ mouseTop: this.top,
138
+ mouseLeft: this.left,
139
+ anchorElement: this.$props.anchorElement,
140
+ position: this.$props.position,
141
+ target: this
142
+ });
143
+ } else {
144
+ position = this.setPosition(this.element);
145
+ }
146
+
147
+ this.element.style.left = position.left + 'px';
148
+ this.element.style.top = position.top + 'px';
149
+
150
+ if (this.targetElement) {
151
+ var appendToElement = this.$props.appendTo ? this.$props.appendTo : this.targetElement.ownerDocument.body;
152
+
153
+ if (this.element.parentElement !== appendToElement) {
154
+ this.targetElement.ownerDocument.body.append(this.element);
155
+ }
156
+ }
157
+
158
+ this.callout = this.v3 ? this.calloutRef : this.$refs.callout;
159
+
160
+ if (!this.callout) {
161
+ return;
162
+ }
163
+
164
+ this.callout.className = this.calloutClassName();
165
+
166
+ if (this.$props.position === 'auto') {
167
+ this.left < window.screen.availWidth / 2 ? this.callout.style.left = this.$props.setCalloutOnPositionAuto || '25%' : this.callout.style.left = this.$props.setCalloutOnPositionAuto || '75%';
168
+ }
169
+ },
170
+ // @ts-ignore
171
+ setup: !gh ? undefined : function () {
172
+ var v3 = !!gh;
173
+ return {
174
+ v3: v3
175
+ };
176
+ },
177
+ // @ts-ignore
178
+ render: function render(createElement) {
179
+ var _this = this;
180
+
181
+ var h = gh || createElement;
182
+ var defaultSlot = kendo_vue_common_1.getDefaultSlots(this);
183
+
184
+ if (this.$props.open === false) {
185
+ return null;
186
+ }
187
+
188
+ var currentZIndex = this.getCurrentZIndex();
189
+ var content = this.$props.content ? kendo_vue_common_1.templateRendering.call(this, this.$props.content, kendo_vue_common_1.getListeners.call(this)) : undefined;
190
+ var contentDefaultRendering = this.title;
191
+ var contentRendering = kendo_vue_common_1.getTemplate.call(this, {
192
+ h: h,
193
+ template: content,
194
+ defaultRendering: contentDefaultRendering,
195
+ additionalProps: {
196
+ title: this.title,
197
+ target: this.targetElement
198
+ }
199
+ });
200
+ var innerToolTip = h("div", {
201
+ "class": kendo_vue_common_1.classNames('k-tooltip', this.$props.tooltipClassName),
202
+ style: __assign({
203
+ position: 'relative'
204
+ }, this.$props.tooltipStyle)
205
+ }, [h("div", {
206
+ "class": "k-tooltip-content"
207
+ }, [contentRendering]), this.$props.showCallout && h("div", {
208
+ ref: this.v3 ? function (el) {
209
+ _this.calloutRef = el;
210
+ } : 'callout'
211
+ })]);
212
+ var tooltip = this.targetElement && this.title && this.targetElement.ownerDocument && h("div", {
213
+ ref: this.v3 ? function (el) {
214
+ _this.elementRef = el;
215
+ } : 'element',
216
+ "class": this.wrapperClass,
217
+ style: __assign({
218
+ zIndex: currentZIndex
219
+ }, this.$props.wrapperStyle),
220
+ tabIndex: 0,
221
+ attrs: this.v3 ? undefined : {
222
+ tabIndex: 0
223
+ }
224
+ }, [innerToolTip]);
225
+
226
+ if (defaultSlot) {
227
+ return h("div", {
228
+ onMouseover: this.handleMouseOver,
229
+ on: this.v3 ? undefined : {
230
+ "mouseover": this.handleMouseOver,
231
+ "mouseout": this.handleMouseOut
232
+ },
233
+ onMouseout: this.handleMouseOut
234
+ }, [tooltip, defaultSlot]);
235
+ } else {
236
+ return {
237
+ tooltip: tooltip
238
+ };
239
+ }
240
+ },
241
+ methods: {
242
+ handleMouseOut: function handleMouseOut(event) {
243
+ var currentDocument = this.targetElement ? this.targetElement.ownerDocument : document;
244
+ var element = currentDocument && currentDocument.elementFromPoint(event.clientX, event.clientY);
245
+
246
+ if (utils_1.isTooltipElement(element)) {
247
+ return;
248
+ }
249
+
250
+ if (this.$props.open) {
251
+ return;
252
+ }
253
+
254
+ clearInterval(this.updateIntervalId);
255
+ this.willOpen = false;
256
+ this.onClose(event);
257
+ },
258
+ handleMouseOver: function handleMouseOver(event) {
259
+ var target = event.target;
260
+
261
+ if (!this.isVisible(target) || utils_1.isTooltipElement(target) || target === this.targetElement) {
262
+ return;
263
+ }
264
+
265
+ this.showToolTip(event);
266
+ },
267
+ handleBodyMousemove: function handleBodyMousemove(event) {
268
+ this.top = event.clientY;
269
+ this.left = event.clientX;
270
+ },
271
+ onClose: function onClose(event) {
272
+ this.$emit('close', {
273
+ event: event,
274
+ component: this
275
+ });
276
+ this.targetElement = null;
277
+ this.currentOpen = false;
278
+ this.title = '';
279
+ },
280
+ showToolTip: function showToolTip(event) {
281
+ var _this = this;
282
+
283
+ clearTimeout(this.openTimeoutId);
284
+ clearInterval(this.updateIntervalId);
285
+
286
+ if (event.target.hasChildNodes()) {
287
+ event.target.childNodes.forEach(function (childElement) {
288
+ if (childElement.nodeName === 'title') {
289
+ event.target.titleExpando = childElement.innerHTML;
290
+ childElement.remove();
291
+ }
292
+ });
293
+ }
294
+
295
+ var target = this.$props.targetElement || event.target;
296
+ var titleResult = this.getTitle(target);
297
+
298
+ if (!titleResult.title) {
299
+ if (this.currentOpen) {
300
+ this.onClose(event);
301
+ }
302
+
303
+ return;
304
+ }
305
+
306
+ if (titleResult.element) {
307
+ titleResult.element.titleExpando = titleResult.title;
308
+ titleResult.element.title = '';
309
+ }
310
+
311
+ this.willOpen = true;
312
+
313
+ if (!this.$props.openDelay) {
314
+ this.targetElement = target;
315
+ this.currentOpen = true;
316
+ this.title = titleResult.title;
317
+ this.setUpdateInterval();
318
+ } else {
319
+ this.openTimeoutId = window.setTimeout(function () {
320
+ if (_this.willOpen) {
321
+ _this.targetElement = target;
322
+ _this.currentOpen = true;
323
+ _this.title = titleResult.title;
324
+
325
+ _this.setUpdateInterval();
326
+ }
327
+ }, this.$props.openDelay);
328
+ }
329
+
330
+ if (this.title !== titleResult.title) {
331
+ this.$emit('open', {
332
+ event: event,
333
+ compoponent: this
334
+ });
335
+ }
336
+ },
337
+ setUpdateInterval: function setUpdateInterval() {
338
+ if (this.$props.updateInterval) {
339
+ this.updateIntervalId = setInterval(this.onIntervalUpdate, this.$props.updateInterval);
340
+ }
341
+ },
342
+ onIntervalUpdate: function onIntervalUpdate() {
343
+ var target = this.targetElement;
344
+
345
+ if (!target) {
346
+ return;
347
+ }
348
+
349
+ if (target.parentElement === null) {
350
+ // Getting element from previous target coordinates will cause reflow which is performance hit.
351
+ // Also remount case can be avoided easily
352
+ this.onClose({
353
+ target: target
354
+ });
355
+ } else {
356
+ this.showToolTip({
357
+ target: target
358
+ });
359
+ }
360
+ },
361
+ isVisible: function isVisible(element) {
362
+ return !this.$props.filter || this.$props.filter(element);
363
+ },
364
+ setPosition: function setPosition(element) {
365
+ var domRect = utils_1.getDomRect(this.targetElement);
366
+ var left = utils_1.getLeftPosition(this.left, element.offsetWidth, domRect, this.$props.anchorElement, this.$props.position);
367
+ var top = utils_1.getTopPosition(this.top, domRect, element.offsetHeight, this.$props.anchorElement, this.$props.position);
368
+ return {
369
+ left: left,
370
+ top: top
371
+ };
372
+ },
373
+ getTitle: function getTitle(element) {
374
+ while (element) {
375
+ if (element.getAttribute('title') !== null || element.titleExpando) {
376
+ var title = element.getAttribute('title') || element.titleExpando;
377
+ return {
378
+ title: title,
379
+ element: element
380
+ };
381
+ }
382
+
383
+ element = this.$props.parentTitle && element.parentElement || null;
384
+ }
385
+
386
+ return {
387
+ title: '',
388
+ element: element
389
+ };
390
+ },
391
+ calloutClassName: function calloutClassName() {
392
+ switch (this.$props.position) {
393
+ case 'bottom':
394
+ return 'k-callout k-callout-n';
395
+
396
+ case 'left':
397
+ return 'k-callout k-callout-e';
398
+
399
+ case 'right':
400
+ return 'k-callout k-callout-w';
401
+
402
+ case 'top':
403
+ return 'k-callout k-callout-s';
404
+
405
+ default:
406
+ return this.top < window.innerHeight / 2 ? 'k-callout k-callout-n' : 'k-callout k-callout-s';
407
+ }
408
+ },
409
+ getCurrentZIndex: function getCurrentZIndex() {
410
+ return this.context ? this.context : DEFAULT_TOOLTIP_ZINDEX;
411
+ }
412
+ }
413
+ };
414
+ exports.Tooltip = Tooltip;
415
+ var TooltipVue3 = Tooltip;
416
+ exports.TooltipVue3 = TooltipVue3;
@@ -0,0 +1,100 @@
1
+ import { TooltipEvent, TooltipPositionEvent } from './events';
2
+ import { TooltipPosition } from './utils';
3
+ /**
4
+ * Represents the props of the [Kendo UI for Vue Tooltip component]({% slug overview_tooltip %}).
5
+ */
6
+ export interface TooltipProps {
7
+ /**
8
+ * Sets the anchor element of the Tooltip.
9
+ *
10
+ * The available options are:
11
+ * - (Default) `pointer`&mdash;Shows a Tooltip where the cursor is located.
12
+ * - `target`&mdash;Positions the Tooltip based on the anchor element.
13
+ */
14
+ anchorElement?: string;
15
+ /**
16
+ * Defines the container to which the Tooltip will be appended. Defaults to [`body`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body).
17
+ */
18
+ appendTo?: HTMLElement | null;
19
+ /**
20
+ * Sets the position of the Tooltip ([see example]({% slug positioning_tooltip %})).
21
+ *
22
+ * The available options are:
23
+ * - (Default) `auto`&mdash;Positions the Tooltip depending on the available space.
24
+ * - `right`&mdash;Positions the Tooltip to the right side of the element.
25
+ * - `left`&mdash;Positions the Tooltip to the left side of the element.
26
+ * - `bottom`&mdash;Positions the Tooltip at the bottom of the element.
27
+ * - `top`&mdash;Positions the Tooltip at the top of the element.
28
+ */
29
+ position?: TooltipPosition | String;
30
+ /**
31
+ * Sets a class of the Tooltip animation container.
32
+ */
33
+ className?: string;
34
+ /**
35
+ * Sets a class of the Tooltip animation container.
36
+ */
37
+ wrapperStyle?: object;
38
+ /**
39
+ * Sets the content of the Tooltip ([see example]({% slug templates_tooltip %})).
40
+ */
41
+ content?: any;
42
+ /**
43
+ * Specifies if the Tooltip will be open.
44
+ * Sets the Tooltip in its controlled mode ([see example]({% slug controlledmode_tooltip %})).
45
+ * Requires you to set the `targetElement` property.
46
+ */
47
+ open?: boolean;
48
+ /**
49
+ * Sets a delay in milliseconds.
50
+ */
51
+ openDelay?: number;
52
+ /**
53
+ * If any of the parent elements has a title, displays a Tooltip.
54
+ */
55
+ parentTitle?: boolean;
56
+ /**
57
+ * Specifies if the Tooltip callout will be displayed.
58
+ */
59
+ showCallout?: boolean;
60
+ /**
61
+ * When the position is set to `auto`, sets the start point of the Tooltip callout (in pixels).
62
+ */
63
+ setCalloutOnPositionAuto?: any;
64
+ /**
65
+ * Sets the Tooltip target element. You have to use it with the `open` property.
66
+ */
67
+ targetElement?: any;
68
+ /**
69
+ * Specifies the CSS class names which are set to the Tooltip DOM element.
70
+ */
71
+ tooltipClassName?: string;
72
+ /**
73
+ * Specifies the styles which are set to the Tooltip DOM element.
74
+ */
75
+ tooltipStyle?: any;
76
+ /**
77
+ * Fires when the Tooltip is shown.
78
+ */
79
+ onOpen?: (event: TooltipEvent) => void;
80
+ /**
81
+ * Fires when the Tooltip is hidden.
82
+ */
83
+ onClose?: (event: TooltipEvent) => void;
84
+ /**
85
+ * Callback called when the Tooltip calculates it's position. Useful to modify the default position behavior.
86
+ * Require to return the `top` and `left` position of the Tooltip.
87
+ */
88
+ onPosition?: (event: TooltipPositionEvent) => {
89
+ top: number;
90
+ left: number;
91
+ };
92
+ /**
93
+ * Represents a callback function which determines if a Tooltip will be displayed ([see example]({% slug filter_elements_tooltip %})).
94
+ */
95
+ filter?: (target: HTMLElement) => void;
96
+ /**
97
+ * The milliseconds interval on which the Tooltip will check for title change. By default the Tooltip does not track for title updates.
98
+ */
99
+ updateInterval?: number;
100
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // tslint:enable:max-line-length
@@ -0,0 +1,3 @@
1
+ // @ts-ignore
2
+ import { DefineComponent } from 'vue';
3
+ export { DefineComponent };
@@ -0,0 +1,29 @@
1
+ import { TooltipPosition } from './utils';
2
+ export interface TooltipEvent {
3
+ }
4
+ export interface TooltipPositionEvent {
5
+ /**
6
+ * The Tooltip element. Useful to get the actual `width` and `height` of rendered Tooltip.
7
+ */
8
+ element: HTMLDivElement;
9
+ /**
10
+ * The current target element. Useful to calculate `top` and `left` position of the Tooltip element.
11
+ */
12
+ targetElement: HTMLElement | null;
13
+ /**
14
+ * The current mouse `top` position;
15
+ */
16
+ mouseTop: number;
17
+ /**
18
+ * The current mouse `left` position.
19
+ */
20
+ mouseLeft: number;
21
+ /**
22
+ * The Tooltip anchor element prop.
23
+ */
24
+ anchorElement?: string;
25
+ /**
26
+ * The Tooltip position prop.
27
+ */
28
+ position?: TooltipPosition;
29
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { Tooltip } from './Tooltip';
2
+ import { TooltipProps } from './TooltipProps';
3
+ import { TooltipEvent, TooltipPositionEvent } from './events';
4
+ import { TooltipPosition } from './utils';
5
+ export { Tooltip, TooltipEvent, TooltipPositionEvent, TooltipProps, TooltipPosition };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tooltip = void 0;
4
+ var Tooltip_1 = require("./Tooltip");
5
+ Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return Tooltip_1.Tooltip; } });
@@ -0,0 +1,5 @@
1
+ import { PackageMetadata } from '@progress/kendo-licensing';
2
+ /**
3
+ * @hidden
4
+ */
5
+ export declare const packageMetadata: PackageMetadata;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageMetadata = void 0;
4
+ /**
5
+ * @hidden
6
+ */
7
+ exports.packageMetadata = {
8
+ name: '@progress/kendo-vue-tooltip',
9
+ productName: 'Kendo UI for Vue',
10
+ productCodes: ['KENDOUIVUE', 'KENDOUICOMPLETE'],
11
+ publishDate: 1639997199,
12
+ version: '',
13
+ licensingDocsUrl: 'https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning'
14
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @hidden
3
+ */
4
+ export declare type TooltipPosition = 'right' | 'left' | 'bottom' | 'top' | 'auto';
5
+ /**
6
+ * @hidden
7
+ */
8
+ export declare const getLeftPosition: (left: any, elementWidth: any, targetElement: any, anchorElement: any, position: any) => any;
9
+ /**
10
+ * @hidden
11
+ */
12
+ export declare const getTopPosition: (top: any, targetElement: any, elementHeight: any, anchorElement: any, position: any) => any;
13
+ /**
14
+ * @hidden
15
+ */
16
+ export declare const getDomRect: (currentTarget: any) => any;
17
+ /**
18
+ * @hidden
19
+ */
20
+ export declare const toolTipSelectors: string[];
21
+ /**
22
+ * @hidden
23
+ */
24
+ export declare const isTooltipElement: (element: any) => boolean;