@pacem/pacem-ui 1.0.0-abel
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-ui.js +6343 -0
- package/dist/browser/pacem-ui.js.map +1 -0
- package/dist/browser/pacem-ui.min.js +2 -0
- package/dist/browser/pacem-ui.min.js.map +1 -0
- package/dist/bundle/pacem-ui.min.mjs +168 -0
- package/dist/bundle/pacem-ui.mjs +6276 -0
- package/dist/bundle/pacem-ui.mjs.map +7 -0
- package/dist/esm/adapter.js +360 -0
- package/dist/esm/anchor.js +149 -0
- package/dist/esm/balloon.js +583 -0
- package/dist/esm/binder.js +678 -0
- package/dist/esm/blade.js +31 -0
- package/dist/esm/bottom-sheet.js +277 -0
- package/dist/esm/button.js +100 -0
- package/dist/esm/buttonset.js +41 -0
- package/dist/esm/calendar.js +662 -0
- package/dist/esm/collapse.js +72 -0
- package/dist/esm/dialog-abstractions.js +61 -0
- package/dist/esm/dialog.js +102 -0
- package/dist/esm/divider.js +48 -0
- package/dist/esm/icon.js +131 -0
- package/dist/esm/image.js +109 -0
- package/dist/esm/index-components-ui.js +41 -0
- package/dist/esm/index-components.js +1 -0
- package/dist/esm/index-iife.js +3 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/infinite-scroller.js +137 -0
- package/dist/esm/iterative.js +45 -0
- package/dist/esm/lightbox-abstractions.js +6 -0
- package/dist/esm/lightbox.js +203 -0
- package/dist/esm/loader.js +100 -0
- package/dist/esm/markdown-svc.js +235 -0
- package/dist/esm/markdown.js +35 -0
- package/dist/esm/marquee.js +87 -0
- package/dist/esm/media-query.js +85 -0
- package/dist/esm/menu.js +165 -0
- package/dist/esm/pager.js +111 -0
- package/dist/esm/picture.js +157 -0
- package/dist/esm/progressbar.js +54 -0
- package/dist/esm/sidebar.js +60 -0
- package/dist/esm/slideshow.js +27 -0
- package/dist/esm/social-twitter.js +39 -0
- package/dist/esm/sticky-header.js +113 -0
- package/dist/esm/tabs.js +187 -0
- package/dist/esm/ticker.js +78 -0
- package/dist/esm/toast.js +171 -0
- package/dist/esm/toc.js +171 -0
- package/dist/esm/tuner.js +200 -0
- package/dist/esm/types.js +7 -0
- package/dist/esm/vibration.js +33 -0
- package/dist/esm/view.js +206 -0
- package/dist/esm/window.js +181 -0
- package/package.json +38 -0
- package/typings/index.d.ts +1165 -0
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { P, PCSS, CustomElement, Watch, Utils, PropertyConverters, Components, PropertyChangeEvent, ViewChild, stopPropagationHandler, preventDefaultHandler } from '@pacem/pacem-core';
|
|
8
|
+
import { ElementOrPointPropertyConverter } from './types';
|
|
9
|
+
//namespace Pacem.Components.UI {
|
|
10
|
+
export var BalloonBehavior;
|
|
11
|
+
(function (BalloonBehavior) {
|
|
12
|
+
BalloonBehavior["Menu"] = "menu";
|
|
13
|
+
BalloonBehavior["Tooltip"] = "tooltip";
|
|
14
|
+
BalloonBehavior["Inert"] = "inert";
|
|
15
|
+
})(BalloonBehavior || (BalloonBehavior = {}));
|
|
16
|
+
export var BalloonTrigger;
|
|
17
|
+
(function (BalloonTrigger) {
|
|
18
|
+
BalloonTrigger["Hover"] = "hover";
|
|
19
|
+
BalloonTrigger["Click"] = "click";
|
|
20
|
+
BalloonTrigger["ContextMenu"] = "contextmenu";
|
|
21
|
+
BalloonTrigger["Focus"] = "focus";
|
|
22
|
+
})(BalloonTrigger || (BalloonTrigger = {}));
|
|
23
|
+
export var BalloonAlignment;
|
|
24
|
+
(function (BalloonAlignment) {
|
|
25
|
+
BalloonAlignment["Start"] = "start";
|
|
26
|
+
BalloonAlignment["Center"] = "center";
|
|
27
|
+
BalloonAlignment["End"] = "end";
|
|
28
|
+
BalloonAlignment["Auto"] = "auto";
|
|
29
|
+
})(BalloonAlignment || (BalloonAlignment = {}));
|
|
30
|
+
export var BalloonPosition;
|
|
31
|
+
(function (BalloonPosition) {
|
|
32
|
+
BalloonPosition["Top"] = "top";
|
|
33
|
+
BalloonPosition["Left"] = "left";
|
|
34
|
+
BalloonPosition["Bottom"] = "bottom";
|
|
35
|
+
BalloonPosition["Right"] = "right";
|
|
36
|
+
BalloonPosition["Auto"] = "auto";
|
|
37
|
+
BalloonPosition["HorizontalAuto"] = "x";
|
|
38
|
+
BalloonPosition["VerticalAuto"] = "y";
|
|
39
|
+
})(BalloonPosition || (BalloonPosition = {}));
|
|
40
|
+
export var BalloonSizing;
|
|
41
|
+
(function (BalloonSizing) {
|
|
42
|
+
BalloonSizing["Auto"] = "auto";
|
|
43
|
+
BalloonSizing["Match"] = "match";
|
|
44
|
+
})(BalloonSizing || (BalloonSizing = {}));
|
|
45
|
+
export const BalloonPopupEventName = 'popup';
|
|
46
|
+
export const BalloonPopoutEventName = 'popout';
|
|
47
|
+
const BalloonConsts = {
|
|
48
|
+
Defaults: {
|
|
49
|
+
'trigger': BalloonTrigger.Hover,
|
|
50
|
+
'position': BalloonPosition.Auto,
|
|
51
|
+
'size': BalloonSizing.Auto,
|
|
52
|
+
'behavior': BalloonBehavior.Menu,
|
|
53
|
+
'verticalOffset': 0,
|
|
54
|
+
'horizontalOffset': 0,
|
|
55
|
+
'hoverDelay': 250,
|
|
56
|
+
'hoverTimeout': 500,
|
|
57
|
+
'align': BalloonAlignment.Center,
|
|
58
|
+
'track': true
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const positioningStyles = 'balloon-right balloon-left balloon-bottom balloon-top balloon-start balloon-center balloon-end';
|
|
62
|
+
const allStyles = PCSS + '-balloon ' + positioningStyles + ' balloon-out balloon-in balloon-on';
|
|
63
|
+
let PacemBalloonElement = class PacemBalloonElement extends Components.PacemElement {
|
|
64
|
+
constructor() {
|
|
65
|
+
super(...arguments);
|
|
66
|
+
this._options = BalloonConsts.Defaults;
|
|
67
|
+
this._originalNeighborhood = null;
|
|
68
|
+
this._popoutDelegate = (_) => {
|
|
69
|
+
this.popout();
|
|
70
|
+
};
|
|
71
|
+
this._hoverDelegate = (evt) => {
|
|
72
|
+
// window.clearTimeout(this._timer);
|
|
73
|
+
if (!this.disabled) {
|
|
74
|
+
this.popup(this._options.hoverDelay);
|
|
75
|
+
// this._timer = window.setTimeout(this._popupDelegate, this._options.hoverDelay);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
this._outConditionalDelegate = (evt) => {
|
|
79
|
+
if ((evt.srcElement || evt.target) != this) {
|
|
80
|
+
this._outDelegate(evt);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
this._mousedownConditionalDelegate = (evt) => {
|
|
84
|
+
preventDefaultHandler(evt);
|
|
85
|
+
if (this._visible) {
|
|
86
|
+
stopPropagationHandler(evt);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this._outDelegate = (_) => {
|
|
90
|
+
this.popout(this._options.hoverTimeout);
|
|
91
|
+
};
|
|
92
|
+
this._toggleDelegate = (evt) => {
|
|
93
|
+
evt.preventDefault();
|
|
94
|
+
if (this._visible) {
|
|
95
|
+
this._outDelegate(evt);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this._hoverDelegate(evt);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
}
|
|
103
|
+
/** Gets whether the balloon is open and visible. */
|
|
104
|
+
get visible() {
|
|
105
|
+
return this._visible;
|
|
106
|
+
}
|
|
107
|
+
// #region LIFECYCLE
|
|
108
|
+
propertyChangedCallback(name, old, val, first) {
|
|
109
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
110
|
+
if (name === 'target') {
|
|
111
|
+
if (old instanceof Element) {
|
|
112
|
+
this._removeHandlers(old);
|
|
113
|
+
}
|
|
114
|
+
if (!(val instanceof Element)) {
|
|
115
|
+
this._adjust();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (name === 'options') {
|
|
119
|
+
if (this.target instanceof Element) {
|
|
120
|
+
this._removeHandlers(this.target);
|
|
121
|
+
}
|
|
122
|
+
this._options = Utils.extend({}, Utils.clone(BalloonConsts.Defaults), val);
|
|
123
|
+
this._synchronizeOptions();
|
|
124
|
+
}
|
|
125
|
+
else if (name === 'disabled') {
|
|
126
|
+
//this.container.style.visibility = val ? 'hidden' : 'visible';
|
|
127
|
+
if (val) {
|
|
128
|
+
this.popout();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (this.target instanceof Element && name !== 'disabled') {
|
|
132
|
+
this._setHandlers(this.target);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
viewActivatedCallback() {
|
|
136
|
+
super.viewActivatedCallback();
|
|
137
|
+
this._ensurePopup();
|
|
138
|
+
this.target = this.target || this.parentElement;
|
|
139
|
+
this._synchronizeOptions();
|
|
140
|
+
}
|
|
141
|
+
disconnectedCallback() {
|
|
142
|
+
super.disconnectedCallback();
|
|
143
|
+
this._destroyPopup();
|
|
144
|
+
if (this.target instanceof Element) {
|
|
145
|
+
this._removeHandlers(this.target);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// #endregion
|
|
149
|
+
//#region METHODS
|
|
150
|
+
_synchronizeOptions() {
|
|
151
|
+
const popup = this, options = popup.options || {};
|
|
152
|
+
// moveToRoot
|
|
153
|
+
if (!!options.moveToRoot && Utils.isNull(this._originalNeighborhood)) {
|
|
154
|
+
this._originalNeighborhood = { parent: popup.parentElement, nextSibling: popup.nextElementSibling };
|
|
155
|
+
document.body.appendChild(popup);
|
|
156
|
+
}
|
|
157
|
+
else if (!options.moveToRoot && !Utils.isNull(this._originalNeighborhood)) {
|
|
158
|
+
const parent = this._originalNeighborhood.parent;
|
|
159
|
+
// has something changed in the neighborhood?...
|
|
160
|
+
if (!Utils.isNull(parent)) {
|
|
161
|
+
parent.appendChild(popup);
|
|
162
|
+
}
|
|
163
|
+
this._originalNeighborhood = null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
_ensurePopup() {
|
|
167
|
+
const popup = this, container = popup._container;
|
|
168
|
+
//
|
|
169
|
+
if (popup && container && !Utils.hasClass(popup, PCSS + '-balloon')) {
|
|
170
|
+
Utils.addClass(popup, PCSS + '-balloon');
|
|
171
|
+
popup.style.position = 'absolute';
|
|
172
|
+
container.style.position = 'relative';
|
|
173
|
+
container.style.zIndex = '1';
|
|
174
|
+
popup.style.visibility = 'hidden';
|
|
175
|
+
}
|
|
176
|
+
return popup;
|
|
177
|
+
}
|
|
178
|
+
_destroyPopup() {
|
|
179
|
+
var popup = this, container = popup._container;
|
|
180
|
+
Utils.removeClass(popup, allStyles);
|
|
181
|
+
popup.style.position = '';
|
|
182
|
+
if (!Utils.isNull(container)) {
|
|
183
|
+
container.style.position = '';
|
|
184
|
+
container.style.zIndex = '';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
_registerEvents() {
|
|
188
|
+
const popup = this._ensurePopup(), options = this._options;
|
|
189
|
+
switch (options.behavior) {
|
|
190
|
+
case BalloonBehavior.Menu:
|
|
191
|
+
switch (options.trigger) {
|
|
192
|
+
case BalloonTrigger.Focus:
|
|
193
|
+
popup.addEventListener('mousedown', stopPropagationHandler, false);
|
|
194
|
+
popup.addEventListener('focus', this._hoverDelegate, false);
|
|
195
|
+
// do nothing else: only the blur event will pop the balloon out
|
|
196
|
+
break;
|
|
197
|
+
case BalloonTrigger.Click:
|
|
198
|
+
case BalloonTrigger.ContextMenu:
|
|
199
|
+
popup.addEventListener('mousedown', stopPropagationHandler, false);
|
|
200
|
+
window.document.body.addEventListener('mousedown', this._outConditionalDelegate, false);
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
popup.addEventListener('mouseenter', this._hoverDelegate, false);
|
|
204
|
+
popup.addEventListener('mouseleave', this._outDelegate, false);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
case BalloonBehavior.Tooltip:
|
|
209
|
+
switch (options.trigger) {
|
|
210
|
+
case BalloonTrigger.Focus:
|
|
211
|
+
case BalloonTrigger.Click:
|
|
212
|
+
case BalloonTrigger.ContextMenu:
|
|
213
|
+
window.document.body.addEventListener('mousedown', this._outConditionalDelegate, false);
|
|
214
|
+
break;
|
|
215
|
+
default:
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
_unregisterEvents() {
|
|
222
|
+
var popup = this._ensurePopup();
|
|
223
|
+
var opts = this._options;
|
|
224
|
+
switch (opts.behavior) {
|
|
225
|
+
case BalloonBehavior.Menu:
|
|
226
|
+
switch (opts.trigger) {
|
|
227
|
+
case BalloonTrigger.Focus:
|
|
228
|
+
popup.removeEventListener('mousedown', stopPropagationHandler, false);
|
|
229
|
+
popup.removeEventListener('focus', this._hoverDelegate, false);
|
|
230
|
+
// do nothing else: only the blur event will pop the balloon out
|
|
231
|
+
break;
|
|
232
|
+
case BalloonTrigger.Click:
|
|
233
|
+
case BalloonTrigger.ContextMenu:
|
|
234
|
+
popup.removeEventListener('mousedown', stopPropagationHandler, false);
|
|
235
|
+
window.document.body.removeEventListener('mousedown', this._outConditionalDelegate, false);
|
|
236
|
+
break;
|
|
237
|
+
default:
|
|
238
|
+
popup.removeEventListener('mouseenter', this._hoverDelegate, false);
|
|
239
|
+
popup.removeEventListener('mouseleave', this._outDelegate, false);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
case BalloonBehavior.Tooltip:
|
|
244
|
+
switch (opts.trigger) {
|
|
245
|
+
case BalloonTrigger.Click:
|
|
246
|
+
case BalloonTrigger.ContextMenu:
|
|
247
|
+
window.document.body.removeEventListener('mousedown', this._outConditionalDelegate, false);
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
_onLayoutChange(evt) {
|
|
254
|
+
if (this._visible) {
|
|
255
|
+
this._adjust();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
_adjust() {
|
|
259
|
+
const popup = this, el = popup.target;
|
|
260
|
+
if (Utils.isNull(el)) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const coords = el instanceof Element ? Utils.offset(el) : { top: el.y, left: el.x, width: 0, height: 0 };
|
|
264
|
+
const vieportSize = Utils.windowSize;
|
|
265
|
+
var opts = this._options;
|
|
266
|
+
var chosenPosition = opts.position, chosenAlignment = opts.align;
|
|
267
|
+
if (chosenPosition != BalloonPosition.Top &&
|
|
268
|
+
chosenPosition != BalloonPosition.Bottom && chosenPosition != BalloonPosition.Left && chosenPosition != BalloonPosition.Right) {
|
|
269
|
+
let viewportHeight = vieportSize.height;
|
|
270
|
+
let viewportWidth = vieportSize.width;
|
|
271
|
+
const offsetLeft = coords.left - Utils.scrollLeft;
|
|
272
|
+
const offsetTop = coords.top - Utils.scrollTop;
|
|
273
|
+
const offsetBottom = viewportHeight - (offsetTop + coords.height);
|
|
274
|
+
const offsetRight = viewportWidth - (offsetLeft + coords.width);
|
|
275
|
+
switch (chosenPosition) {
|
|
276
|
+
case BalloonPosition.HorizontalAuto:
|
|
277
|
+
chosenPosition = offsetLeft > offsetRight ? BalloonPosition.Left : BalloonPosition.Right;
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
// (!) exclude 'left' and 'right' also when position is simply set to 'auto'
|
|
281
|
+
chosenPosition = offsetTop > offsetBottom ? BalloonPosition.Top : BalloonPosition.Bottom;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (opts.size === BalloonSizing.Match) {
|
|
286
|
+
switch (chosenPosition) {
|
|
287
|
+
case BalloonPosition.Bottom:
|
|
288
|
+
case BalloonPosition.Top:
|
|
289
|
+
popup.style.minWidth = coords.width + 'px';
|
|
290
|
+
popup.style.minHeight = '';
|
|
291
|
+
break;
|
|
292
|
+
case BalloonPosition.Left:
|
|
293
|
+
case BalloonPosition.Right:
|
|
294
|
+
popup.style.minHeight = coords.height + 'px';
|
|
295
|
+
popup.style.minWidth = '';
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
popup.style.minWidth = popup.style.minHeight = '';
|
|
301
|
+
}
|
|
302
|
+
const popupSize = { width: popup.offsetWidth, height: popup.offsetHeight };
|
|
303
|
+
const fullOffsetWidth = coords.width - popupSize.width, halfOffsetWidth = fullOffsetWidth * .5, fullOffsetHeight = coords.height - popupSize.height, halfOffsetHeight = fullOffsetHeight * .5;
|
|
304
|
+
switch (chosenAlignment) {
|
|
305
|
+
case BalloonAlignment.Center:
|
|
306
|
+
case BalloonAlignment.Start:
|
|
307
|
+
case BalloonAlignment.End:
|
|
308
|
+
break;
|
|
309
|
+
case BalloonAlignment.Auto:
|
|
310
|
+
chosenAlignment = BalloonAlignment.Center;
|
|
311
|
+
switch (chosenPosition) {
|
|
312
|
+
case BalloonPosition.Right:
|
|
313
|
+
case BalloonPosition.Left:
|
|
314
|
+
const halfHeight = Utils.scrollTop + vieportSize.height / 2;
|
|
315
|
+
if /* completely inside the first half of the screen */ ((coords.top + coords.height) < halfHeight) {
|
|
316
|
+
chosenAlignment = BalloonAlignment.Start;
|
|
317
|
+
}
|
|
318
|
+
else if /* completely beyond the half line of the screen */ (coords.top > halfHeight) {
|
|
319
|
+
chosenAlignment = BalloonAlignment.End;
|
|
320
|
+
}
|
|
321
|
+
break;
|
|
322
|
+
case BalloonPosition.Top:
|
|
323
|
+
case BalloonPosition.Bottom:
|
|
324
|
+
const halfWidth = Utils.scrollLeft + vieportSize.width / 2;
|
|
325
|
+
if /* completely inside the first half of the screen */ ((coords.left + coords.width) < halfWidth) {
|
|
326
|
+
chosenAlignment = BalloonAlignment.Start;
|
|
327
|
+
}
|
|
328
|
+
else if /* completely beyond the half line of the screen */ (coords.left > halfWidth) {
|
|
329
|
+
chosenAlignment = BalloonAlignment.End;
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
chosenAlignment = BalloonConsts.Defaults.align;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
Utils.removeClass(popup, positioningStyles);
|
|
339
|
+
Utils.addClass(popup, 'balloon-' + chosenPosition);
|
|
340
|
+
Utils.addClass(popup, 'balloon-' + chosenAlignment);
|
|
341
|
+
const tailSize = Utils.Css.getVariableValue(`--${PCSS}-balloon-tail-size`), tailInset = Utils.Css.getVariableValue(`--${PCSS}-balloon-tail-inset`);
|
|
342
|
+
const inset = parseInt(tailInset) + .5 * parseInt(tailSize);
|
|
343
|
+
const threshold = { width: coords.width / 2, height: coords.height / 2 };
|
|
344
|
+
const adjustX = opts.autoAdjust && inset > threshold.width;
|
|
345
|
+
const adjustY = opts.autoAdjust && inset > threshold.height;
|
|
346
|
+
switch (chosenPosition) {
|
|
347
|
+
case BalloonPosition.Top:
|
|
348
|
+
coords.top -= popupSize.height;
|
|
349
|
+
switch (chosenAlignment) {
|
|
350
|
+
case BalloonAlignment.Center:
|
|
351
|
+
coords.left += halfOffsetWidth;
|
|
352
|
+
break;
|
|
353
|
+
case BalloonAlignment.End:
|
|
354
|
+
coords.left += fullOffsetWidth;
|
|
355
|
+
if (adjustX) {
|
|
356
|
+
coords.left += (inset - threshold.width);
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case BalloonAlignment.Start:
|
|
360
|
+
if (adjustX) {
|
|
361
|
+
coords.left -= (inset - threshold.width);
|
|
362
|
+
}
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
break;
|
|
366
|
+
case BalloonPosition.Left:
|
|
367
|
+
coords.left -= popupSize.width;
|
|
368
|
+
switch (chosenAlignment) {
|
|
369
|
+
case BalloonAlignment.Center:
|
|
370
|
+
coords.top += halfOffsetHeight;
|
|
371
|
+
break;
|
|
372
|
+
case BalloonAlignment.End:
|
|
373
|
+
coords.top += fullOffsetHeight;
|
|
374
|
+
if (adjustY) {
|
|
375
|
+
coords.top += (inset - threshold.height);
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
case BalloonAlignment.Start:
|
|
379
|
+
if (adjustY) {
|
|
380
|
+
coords.top -= (inset - threshold.height);
|
|
381
|
+
}
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
break;
|
|
385
|
+
case BalloonPosition.Right:
|
|
386
|
+
coords.left += coords.width;
|
|
387
|
+
switch (chosenAlignment) {
|
|
388
|
+
case BalloonAlignment.Center:
|
|
389
|
+
coords.top += halfOffsetHeight;
|
|
390
|
+
break;
|
|
391
|
+
case BalloonAlignment.End:
|
|
392
|
+
coords.top += fullOffsetHeight;
|
|
393
|
+
if (adjustY) {
|
|
394
|
+
coords.top += (inset - threshold.height);
|
|
395
|
+
}
|
|
396
|
+
break;
|
|
397
|
+
case BalloonAlignment.Start:
|
|
398
|
+
if (adjustY) {
|
|
399
|
+
coords.top -= (inset - threshold.height);
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
default:
|
|
405
|
+
// bottom
|
|
406
|
+
coords.top += coords.height;
|
|
407
|
+
switch (chosenAlignment) {
|
|
408
|
+
case BalloonAlignment.Center:
|
|
409
|
+
coords.left += halfOffsetWidth;
|
|
410
|
+
break;
|
|
411
|
+
case BalloonAlignment.End:
|
|
412
|
+
coords.left += fullOffsetWidth;
|
|
413
|
+
if (adjustX) {
|
|
414
|
+
coords.left += (inset - threshold.width);
|
|
415
|
+
}
|
|
416
|
+
break;
|
|
417
|
+
case BalloonAlignment.Start:
|
|
418
|
+
if (adjustX) {
|
|
419
|
+
coords.left -= (inset - threshold.width);
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
coords.left = Math.min(vieportSize.width - popupSize.width, Math.max(0, coords.left));
|
|
426
|
+
//coords.top = Math.max(0, coords.top);
|
|
427
|
+
// coords for balloon positioning
|
|
428
|
+
coords.top += opts.verticalOffset;
|
|
429
|
+
coords.left += opts.horizontalOffset;
|
|
430
|
+
popup.style.top = Math.round(coords.top) + 'px';
|
|
431
|
+
popup.style.left = Math.round(coords.left) + 'px';
|
|
432
|
+
// popup.style.transform = `translateX(${Math.round(coords.left)}px) translateY(${Math.round(coords.top)}px) translateZ(0)`;
|
|
433
|
+
//popup.style.visibility = 'visible';
|
|
434
|
+
}
|
|
435
|
+
_adjustWatchers(visible) {
|
|
436
|
+
const options = this.options || {};
|
|
437
|
+
if (!Utils.isNull(this._resize)) {
|
|
438
|
+
// track position and size
|
|
439
|
+
this._resize.disabled = !visible;
|
|
440
|
+
this._position.disabled = !visible || !(options.track || options.trackPosition);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Shows the balloon, if hidden.
|
|
445
|
+
*/
|
|
446
|
+
popup(delay = 0) {
|
|
447
|
+
clearTimeout(this._timer);
|
|
448
|
+
if (delay > 0) {
|
|
449
|
+
this._timer = setTimeout(() => this.popup(), delay);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const popup = this, isVisible = Utils.isVisible(popup);
|
|
453
|
+
this._adjustWatchers(true);
|
|
454
|
+
if (isVisible || this.disabled) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
// attach closured behavior to popup
|
|
458
|
+
//if (!sameTrigger) {
|
|
459
|
+
this._registerEvents(); // $popup.on('mouseenter', obj.methods.hover).on('mouseleave', obj.methods.out).data(vars.TRIGGER, obj);
|
|
460
|
+
//}
|
|
461
|
+
//
|
|
462
|
+
popup.style.pointerEvents = 'none';
|
|
463
|
+
this._visible = true;
|
|
464
|
+
popup.style.visibility = 'visible';
|
|
465
|
+
this._adjust();
|
|
466
|
+
//requestAnimationFrame(() => {
|
|
467
|
+
Utils.addClass(popup, 'balloon-in');
|
|
468
|
+
Utils.addAnimationEndCallback(popup, () => {
|
|
469
|
+
Utils.addClass(popup, 'balloon-on');
|
|
470
|
+
popup.dispatchEvent(new PropertyChangeEvent({ propertyName: 'visible', oldValue: false, currentValue: true }));
|
|
471
|
+
popup.dispatchEvent(new Event(BalloonPopupEventName));
|
|
472
|
+
popup.style.pointerEvents = 'auto';
|
|
473
|
+
}, 500);
|
|
474
|
+
//});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Hides the balloon, if visible.
|
|
478
|
+
*/
|
|
479
|
+
popout(delay = 0) {
|
|
480
|
+
clearTimeout(this._timer);
|
|
481
|
+
if (delay > 0) {
|
|
482
|
+
this._timer = setTimeout(() => this.popout(), delay);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
var popup = this;
|
|
486
|
+
const isVisible = Utils.isVisible(popup);
|
|
487
|
+
this._adjustWatchers(false);
|
|
488
|
+
if (!isVisible) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
// detach closured behavior from popup
|
|
492
|
+
this._unregisterEvents();
|
|
493
|
+
//
|
|
494
|
+
popup.style.pointerEvents = 'none';
|
|
495
|
+
Utils.removeClass(popup, 'balloon-in balloon-on');
|
|
496
|
+
Utils.addClass(popup, 'balloon-out');
|
|
497
|
+
Utils.addAnimationEndCallback(popup, () => {
|
|
498
|
+
popup.style.visibility = 'hidden';
|
|
499
|
+
this._visible = false;
|
|
500
|
+
Utils.removeClass(popup, allStyles);
|
|
501
|
+
popup.dispatchEvent(new Event(BalloonPopoutEventName));
|
|
502
|
+
popup.dispatchEvent(new PropertyChangeEvent({ propertyName: 'visible', oldValue: true, currentValue: false }));
|
|
503
|
+
}, 500);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Shows the balloon, if hidden. Otherwise hides it.
|
|
507
|
+
*/
|
|
508
|
+
toggle(delay = 0) {
|
|
509
|
+
if (!Utils.isVisible(this) && !this.disabled) {
|
|
510
|
+
this.popup(delay);
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
this.popout(delay);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
_removeHandlers(el) {
|
|
517
|
+
if (Utils.isNull(el)) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
el.removeEventListener('mouseenter', this._hoverDelegate, false);
|
|
521
|
+
el.removeEventListener('mouseleave', this._outDelegate, false);
|
|
522
|
+
el.removeEventListener('mousedown', this._popoutDelegate, false);
|
|
523
|
+
el.removeEventListener('mousedown', this._mousedownConditionalDelegate, false);
|
|
524
|
+
el.removeEventListener('click', this._toggleDelegate, false);
|
|
525
|
+
el.removeEventListener('focus', this._hoverDelegate, false);
|
|
526
|
+
el.removeEventListener('blur', this._outDelegate, false);
|
|
527
|
+
el.removeEventListener('contextmenu', this._toggleDelegate, false);
|
|
528
|
+
}
|
|
529
|
+
_setHandlers(el) {
|
|
530
|
+
this.popout();
|
|
531
|
+
// regenerate opts popup
|
|
532
|
+
var opts = this._options;
|
|
533
|
+
if (opts.behavior == BalloonBehavior.Inert) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
switch (opts.trigger) {
|
|
537
|
+
case BalloonTrigger.Hover:
|
|
538
|
+
el.addEventListener('mouseenter', this._hoverDelegate, false);
|
|
539
|
+
el.addEventListener('mouseleave', this._outDelegate, false);
|
|
540
|
+
el.addEventListener('mousedown', this._popoutDelegate, false);
|
|
541
|
+
break;
|
|
542
|
+
case BalloonTrigger.Focus:
|
|
543
|
+
el.addEventListener('focus', this._hoverDelegate, false);
|
|
544
|
+
el.addEventListener('blur', this._outDelegate, false);
|
|
545
|
+
break;
|
|
546
|
+
case BalloonTrigger.Click:
|
|
547
|
+
opts.hoverDelay = opts.hoverTimeout = 0;
|
|
548
|
+
el.addEventListener('mousedown', this._mousedownConditionalDelegate, false);
|
|
549
|
+
el.addEventListener('click', this._toggleDelegate, false) /*.blur(obj.methods.out)*/;
|
|
550
|
+
break;
|
|
551
|
+
case BalloonTrigger.ContextMenu:
|
|
552
|
+
opts.hoverDelay = opts.hoverTimeout = 0;
|
|
553
|
+
el.addEventListener('contextmenu', this._toggleDelegate, false);
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
__decorate([
|
|
559
|
+
ViewChild(`.${PCSS}-balloon`)
|
|
560
|
+
], PacemBalloonElement.prototype, "_container", void 0);
|
|
561
|
+
__decorate([
|
|
562
|
+
ViewChild(P + '-resize[content]')
|
|
563
|
+
], PacemBalloonElement.prototype, "_resize", void 0);
|
|
564
|
+
__decorate([
|
|
565
|
+
ViewChild(P + '-resize[watch-position=true]')
|
|
566
|
+
], PacemBalloonElement.prototype, "_position", void 0);
|
|
567
|
+
__decorate([
|
|
568
|
+
Watch({ converter: ElementOrPointPropertyConverter })
|
|
569
|
+
], PacemBalloonElement.prototype, "target", void 0);
|
|
570
|
+
__decorate([
|
|
571
|
+
Watch({ emit: false, converter: PropertyConverters.Json })
|
|
572
|
+
], PacemBalloonElement.prototype, "options", void 0);
|
|
573
|
+
PacemBalloonElement = __decorate([
|
|
574
|
+
CustomElement({
|
|
575
|
+
tagName: P + '-balloon',
|
|
576
|
+
shadow: true,
|
|
577
|
+
template: `<${P}-resize target="{{ :host.target }}" disabled="true" watch-position="true" on-${Components.ResizeEventName}=":host._onLayoutChange($event)"></${P}-resize>
|
|
578
|
+
<div class="${PCSS}-balloon"><${P}-resize on-${Components.ResizeEventName}=":host._onLayoutChange($event)" disabled="true" content><slot></slot></${P}-resize></div>
|
|
579
|
+
<div class="corner top-left" part="corner-topleft"></div><div class="corner bottom-left" part="corner-bottomleft"></div><div class="corner top-right" part="corner-topright"></div><div class="corner bottom-right" part="corner-bottomright"></div>`
|
|
580
|
+
})
|
|
581
|
+
], PacemBalloonElement);
|
|
582
|
+
export { PacemBalloonElement };
|
|
583
|
+
//}
|