hc-basic 1.5.1 → 1.5.4

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 (39) hide show
  1. package/lib/hc-basic.common.js +85193 -55
  2. package/lib/hc-basic.umd.js +85204 -56
  3. package/lib/hc-basic.umd.min.js +41 -1
  4. package/package.json +10 -9
  5. package/lib/css/hc-basic.umd.596515ce.css +0 -1
  6. package/lib/css/hc-basic.umd.min.596515ce.css +0 -1
  7. package/lib/hc-basic.common.async-validator1680231905970.js +0 -984
  8. package/lib/hc-basic.common.axios1680231905971.js +0 -1644
  9. package/lib/hc-basic.common.babel-runtime1680231905970.js +0 -1242
  10. package/lib/hc-basic.common.crypto-js1680231905971.js +0 -6194
  11. package/lib/hc-basic.common.element-ui1680231905967.js +0 -43880
  12. package/lib/hc-basic.common.element-ui1680231905968.js +0 -5784
  13. package/lib/hc-basic.common.element-ui1680231905969.js +0 -14978
  14. package/lib/hc-basic.common.element-ui1680231905970.js +0 -3453
  15. package/lib/hc-basic.common.hc-basic.common.js +0 -3812
  16. package/lib/hc-basic.common.resize-observer-polyfill1680231905969.js +0 -941
  17. package/lib/hc-basic.common.vendors~hc-basic.common.js +0 -2203
  18. package/lib/hc-basic.umd.axios1680231905278.js +0 -1712
  19. package/lib/hc-basic.umd.babel-runtime1680231905277.js +0 -1411
  20. package/lib/hc-basic.umd.crypto-js1680231905278.js +0 -6194
  21. package/lib/hc-basic.umd.element-ui1680231905273.js +0 -43880
  22. package/lib/hc-basic.umd.element-ui1680231905274.js +0 -695
  23. package/lib/hc-basic.umd.element-ui1680231905275.js +0 -5158
  24. package/lib/hc-basic.umd.element-ui1680231905276.js +0 -14912
  25. package/lib/hc-basic.umd.element-ui1680231905278.js +0 -3453
  26. package/lib/hc-basic.umd.hc-basic.umd.js +0 -3822
  27. package/lib/hc-basic.umd.min.async-validator1680231905116.js +0 -1
  28. package/lib/hc-basic.umd.min.axios1680231905116.js +0 -1
  29. package/lib/hc-basic.umd.min.babel-runtime1680231905115.js +0 -1
  30. package/lib/hc-basic.umd.min.crypto-js1680231905116.js +0 -18
  31. package/lib/hc-basic.umd.min.element-ui1680231905113.js +0 -1
  32. package/lib/hc-basic.umd.min.element-ui1680231905114.js +0 -9
  33. package/lib/hc-basic.umd.min.element-ui1680231905116.js +0 -1
  34. package/lib/hc-basic.umd.min.hc-basic.umd.min.js +0 -1
  35. package/lib/hc-basic.umd.min.resize-observer-polyfill1680231905114.js +0 -1
  36. package/lib/hc-basic.umd.min.vendors~hc-basic.umd.min.js +0 -16
  37. package/lib/hc-basic.umd.resize-observer-polyfill1680231905275.js +0 -941
  38. package/lib/hc-basic.umd.vendors~hc-basic.umd.js +0 -2911
  39. /package/lib/{css/hc-basic.common.596515ce.css → hc-basic.css} +0 -0
@@ -1,941 +0,0 @@
1
- ((typeof self !== 'undefined' ? self : this)["webpackJsonphc_basic"] = (typeof self !== 'undefined' ? self : this)["webpackJsonphc_basic"] || []).push([[9],{
2
-
3
- /***/ "6dd8":
4
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
5
-
6
- "use strict";
7
- __webpack_require__.r(__webpack_exports__);
8
- /* WEBPACK VAR INJECTION */(function(global) {/**
9
- * A collection of shims that provide minimal functionality of the ES6 collections.
10
- *
11
- * These implementations are not meant to be used outside of the ResizeObserver
12
- * modules as they cover only a limited range of use cases.
13
- */
14
- /* eslint-disable require-jsdoc, valid-jsdoc */
15
- var MapShim = (function () {
16
- if (typeof Map !== 'undefined') {
17
- return Map;
18
- }
19
- /**
20
- * Returns index in provided array that matches the specified key.
21
- *
22
- * @param {Array<Array>} arr
23
- * @param {*} key
24
- * @returns {number}
25
- */
26
- function getIndex(arr, key) {
27
- var result = -1;
28
- arr.some(function (entry, index) {
29
- if (entry[0] === key) {
30
- result = index;
31
- return true;
32
- }
33
- return false;
34
- });
35
- return result;
36
- }
37
- return /** @class */ (function () {
38
- function class_1() {
39
- this.__entries__ = [];
40
- }
41
- Object.defineProperty(class_1.prototype, "size", {
42
- /**
43
- * @returns {boolean}
44
- */
45
- get: function () {
46
- return this.__entries__.length;
47
- },
48
- enumerable: true,
49
- configurable: true
50
- });
51
- /**
52
- * @param {*} key
53
- * @returns {*}
54
- */
55
- class_1.prototype.get = function (key) {
56
- var index = getIndex(this.__entries__, key);
57
- var entry = this.__entries__[index];
58
- return entry && entry[1];
59
- };
60
- /**
61
- * @param {*} key
62
- * @param {*} value
63
- * @returns {void}
64
- */
65
- class_1.prototype.set = function (key, value) {
66
- var index = getIndex(this.__entries__, key);
67
- if (~index) {
68
- this.__entries__[index][1] = value;
69
- }
70
- else {
71
- this.__entries__.push([key, value]);
72
- }
73
- };
74
- /**
75
- * @param {*} key
76
- * @returns {void}
77
- */
78
- class_1.prototype.delete = function (key) {
79
- var entries = this.__entries__;
80
- var index = getIndex(entries, key);
81
- if (~index) {
82
- entries.splice(index, 1);
83
- }
84
- };
85
- /**
86
- * @param {*} key
87
- * @returns {void}
88
- */
89
- class_1.prototype.has = function (key) {
90
- return !!~getIndex(this.__entries__, key);
91
- };
92
- /**
93
- * @returns {void}
94
- */
95
- class_1.prototype.clear = function () {
96
- this.__entries__.splice(0);
97
- };
98
- /**
99
- * @param {Function} callback
100
- * @param {*} [ctx=null]
101
- * @returns {void}
102
- */
103
- class_1.prototype.forEach = function (callback, ctx) {
104
- if (ctx === void 0) { ctx = null; }
105
- for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
106
- var entry = _a[_i];
107
- callback.call(ctx, entry[1], entry[0]);
108
- }
109
- };
110
- return class_1;
111
- }());
112
- })();
113
-
114
- /**
115
- * Detects whether window and document objects are available in current environment.
116
- */
117
- var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
118
-
119
- // Returns global object of a current environment.
120
- var global$1 = (function () {
121
- if (typeof global !== 'undefined' && global.Math === Math) {
122
- return global;
123
- }
124
- if (typeof self !== 'undefined' && self.Math === Math) {
125
- return self;
126
- }
127
- if (typeof window !== 'undefined' && window.Math === Math) {
128
- return window;
129
- }
130
- // eslint-disable-next-line no-new-func
131
- return Function('return this')();
132
- })();
133
-
134
- /**
135
- * A shim for the requestAnimationFrame which falls back to the setTimeout if
136
- * first one is not supported.
137
- *
138
- * @returns {number} Requests' identifier.
139
- */
140
- var requestAnimationFrame$1 = (function () {
141
- if (typeof requestAnimationFrame === 'function') {
142
- // It's required to use a bounded function because IE sometimes throws
143
- // an "Invalid calling object" error if rAF is invoked without the global
144
- // object on the left hand side.
145
- return requestAnimationFrame.bind(global$1);
146
- }
147
- return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
148
- })();
149
-
150
- // Defines minimum timeout before adding a trailing call.
151
- var trailingTimeout = 2;
152
- /**
153
- * Creates a wrapper function which ensures that provided callback will be
154
- * invoked only once during the specified delay period.
155
- *
156
- * @param {Function} callback - Function to be invoked after the delay period.
157
- * @param {number} delay - Delay after which to invoke callback.
158
- * @returns {Function}
159
- */
160
- function throttle (callback, delay) {
161
- var leadingCall = false, trailingCall = false, lastCallTime = 0;
162
- /**
163
- * Invokes the original callback function and schedules new invocation if
164
- * the "proxy" was called during current request.
165
- *
166
- * @returns {void}
167
- */
168
- function resolvePending() {
169
- if (leadingCall) {
170
- leadingCall = false;
171
- callback();
172
- }
173
- if (trailingCall) {
174
- proxy();
175
- }
176
- }
177
- /**
178
- * Callback invoked after the specified delay. It will further postpone
179
- * invocation of the original function delegating it to the
180
- * requestAnimationFrame.
181
- *
182
- * @returns {void}
183
- */
184
- function timeoutCallback() {
185
- requestAnimationFrame$1(resolvePending);
186
- }
187
- /**
188
- * Schedules invocation of the original function.
189
- *
190
- * @returns {void}
191
- */
192
- function proxy() {
193
- var timeStamp = Date.now();
194
- if (leadingCall) {
195
- // Reject immediately following calls.
196
- if (timeStamp - lastCallTime < trailingTimeout) {
197
- return;
198
- }
199
- // Schedule new call to be in invoked when the pending one is resolved.
200
- // This is important for "transitions" which never actually start
201
- // immediately so there is a chance that we might miss one if change
202
- // happens amids the pending invocation.
203
- trailingCall = true;
204
- }
205
- else {
206
- leadingCall = true;
207
- trailingCall = false;
208
- setTimeout(timeoutCallback, delay);
209
- }
210
- lastCallTime = timeStamp;
211
- }
212
- return proxy;
213
- }
214
-
215
- // Minimum delay before invoking the update of observers.
216
- var REFRESH_DELAY = 20;
217
- // A list of substrings of CSS properties used to find transition events that
218
- // might affect dimensions of observed elements.
219
- var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
220
- // Check if MutationObserver is available.
221
- var mutationObserverSupported = typeof MutationObserver !== 'undefined';
222
- /**
223
- * Singleton controller class which handles updates of ResizeObserver instances.
224
- */
225
- var ResizeObserverController = /** @class */ (function () {
226
- /**
227
- * Creates a new instance of ResizeObserverController.
228
- *
229
- * @private
230
- */
231
- function ResizeObserverController() {
232
- /**
233
- * Indicates whether DOM listeners have been added.
234
- *
235
- * @private {boolean}
236
- */
237
- this.connected_ = false;
238
- /**
239
- * Tells that controller has subscribed for Mutation Events.
240
- *
241
- * @private {boolean}
242
- */
243
- this.mutationEventsAdded_ = false;
244
- /**
245
- * Keeps reference to the instance of MutationObserver.
246
- *
247
- * @private {MutationObserver}
248
- */
249
- this.mutationsObserver_ = null;
250
- /**
251
- * A list of connected observers.
252
- *
253
- * @private {Array<ResizeObserverSPI>}
254
- */
255
- this.observers_ = [];
256
- this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
257
- this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
258
- }
259
- /**
260
- * Adds observer to observers list.
261
- *
262
- * @param {ResizeObserverSPI} observer - Observer to be added.
263
- * @returns {void}
264
- */
265
- ResizeObserverController.prototype.addObserver = function (observer) {
266
- if (!~this.observers_.indexOf(observer)) {
267
- this.observers_.push(observer);
268
- }
269
- // Add listeners if they haven't been added yet.
270
- if (!this.connected_) {
271
- this.connect_();
272
- }
273
- };
274
- /**
275
- * Removes observer from observers list.
276
- *
277
- * @param {ResizeObserverSPI} observer - Observer to be removed.
278
- * @returns {void}
279
- */
280
- ResizeObserverController.prototype.removeObserver = function (observer) {
281
- var observers = this.observers_;
282
- var index = observers.indexOf(observer);
283
- // Remove observer if it's present in registry.
284
- if (~index) {
285
- observers.splice(index, 1);
286
- }
287
- // Remove listeners if controller has no connected observers.
288
- if (!observers.length && this.connected_) {
289
- this.disconnect_();
290
- }
291
- };
292
- /**
293
- * Invokes the update of observers. It will continue running updates insofar
294
- * it detects changes.
295
- *
296
- * @returns {void}
297
- */
298
- ResizeObserverController.prototype.refresh = function () {
299
- var changesDetected = this.updateObservers_();
300
- // Continue running updates if changes have been detected as there might
301
- // be future ones caused by CSS transitions.
302
- if (changesDetected) {
303
- this.refresh();
304
- }
305
- };
306
- /**
307
- * Updates every observer from observers list and notifies them of queued
308
- * entries.
309
- *
310
- * @private
311
- * @returns {boolean} Returns "true" if any observer has detected changes in
312
- * dimensions of it's elements.
313
- */
314
- ResizeObserverController.prototype.updateObservers_ = function () {
315
- // Collect observers that have active observations.
316
- var activeObservers = this.observers_.filter(function (observer) {
317
- return observer.gatherActive(), observer.hasActive();
318
- });
319
- // Deliver notifications in a separate cycle in order to avoid any
320
- // collisions between observers, e.g. when multiple instances of
321
- // ResizeObserver are tracking the same element and the callback of one
322
- // of them changes content dimensions of the observed target. Sometimes
323
- // this may result in notifications being blocked for the rest of observers.
324
- activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
325
- return activeObservers.length > 0;
326
- };
327
- /**
328
- * Initializes DOM listeners.
329
- *
330
- * @private
331
- * @returns {void}
332
- */
333
- ResizeObserverController.prototype.connect_ = function () {
334
- // Do nothing if running in a non-browser environment or if listeners
335
- // have been already added.
336
- if (!isBrowser || this.connected_) {
337
- return;
338
- }
339
- // Subscription to the "Transitionend" event is used as a workaround for
340
- // delayed transitions. This way it's possible to capture at least the
341
- // final state of an element.
342
- document.addEventListener('transitionend', this.onTransitionEnd_);
343
- window.addEventListener('resize', this.refresh);
344
- if (mutationObserverSupported) {
345
- this.mutationsObserver_ = new MutationObserver(this.refresh);
346
- this.mutationsObserver_.observe(document, {
347
- attributes: true,
348
- childList: true,
349
- characterData: true,
350
- subtree: true
351
- });
352
- }
353
- else {
354
- document.addEventListener('DOMSubtreeModified', this.refresh);
355
- this.mutationEventsAdded_ = true;
356
- }
357
- this.connected_ = true;
358
- };
359
- /**
360
- * Removes DOM listeners.
361
- *
362
- * @private
363
- * @returns {void}
364
- */
365
- ResizeObserverController.prototype.disconnect_ = function () {
366
- // Do nothing if running in a non-browser environment or if listeners
367
- // have been already removed.
368
- if (!isBrowser || !this.connected_) {
369
- return;
370
- }
371
- document.removeEventListener('transitionend', this.onTransitionEnd_);
372
- window.removeEventListener('resize', this.refresh);
373
- if (this.mutationsObserver_) {
374
- this.mutationsObserver_.disconnect();
375
- }
376
- if (this.mutationEventsAdded_) {
377
- document.removeEventListener('DOMSubtreeModified', this.refresh);
378
- }
379
- this.mutationsObserver_ = null;
380
- this.mutationEventsAdded_ = false;
381
- this.connected_ = false;
382
- };
383
- /**
384
- * "Transitionend" event handler.
385
- *
386
- * @private
387
- * @param {TransitionEvent} event
388
- * @returns {void}
389
- */
390
- ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
391
- var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
392
- // Detect whether transition may affect dimensions of an element.
393
- var isReflowProperty = transitionKeys.some(function (key) {
394
- return !!~propertyName.indexOf(key);
395
- });
396
- if (isReflowProperty) {
397
- this.refresh();
398
- }
399
- };
400
- /**
401
- * Returns instance of the ResizeObserverController.
402
- *
403
- * @returns {ResizeObserverController}
404
- */
405
- ResizeObserverController.getInstance = function () {
406
- if (!this.instance_) {
407
- this.instance_ = new ResizeObserverController();
408
- }
409
- return this.instance_;
410
- };
411
- /**
412
- * Holds reference to the controller's instance.
413
- *
414
- * @private {ResizeObserverController}
415
- */
416
- ResizeObserverController.instance_ = null;
417
- return ResizeObserverController;
418
- }());
419
-
420
- /**
421
- * Defines non-writable/enumerable properties of the provided target object.
422
- *
423
- * @param {Object} target - Object for which to define properties.
424
- * @param {Object} props - Properties to be defined.
425
- * @returns {Object} Target object.
426
- */
427
- var defineConfigurable = (function (target, props) {
428
- for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
429
- var key = _a[_i];
430
- Object.defineProperty(target, key, {
431
- value: props[key],
432
- enumerable: false,
433
- writable: false,
434
- configurable: true
435
- });
436
- }
437
- return target;
438
- });
439
-
440
- /**
441
- * Returns the global object associated with provided element.
442
- *
443
- * @param {Object} target
444
- * @returns {Object}
445
- */
446
- var getWindowOf = (function (target) {
447
- // Assume that the element is an instance of Node, which means that it
448
- // has the "ownerDocument" property from which we can retrieve a
449
- // corresponding global object.
450
- var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
451
- // Return the local global object if it's not possible extract one from
452
- // provided element.
453
- return ownerGlobal || global$1;
454
- });
455
-
456
- // Placeholder of an empty content rectangle.
457
- var emptyRect = createRectInit(0, 0, 0, 0);
458
- /**
459
- * Converts provided string to a number.
460
- *
461
- * @param {number|string} value
462
- * @returns {number}
463
- */
464
- function toFloat(value) {
465
- return parseFloat(value) || 0;
466
- }
467
- /**
468
- * Extracts borders size from provided styles.
469
- *
470
- * @param {CSSStyleDeclaration} styles
471
- * @param {...string} positions - Borders positions (top, right, ...)
472
- * @returns {number}
473
- */
474
- function getBordersSize(styles) {
475
- var positions = [];
476
- for (var _i = 1; _i < arguments.length; _i++) {
477
- positions[_i - 1] = arguments[_i];
478
- }
479
- return positions.reduce(function (size, position) {
480
- var value = styles['border-' + position + '-width'];
481
- return size + toFloat(value);
482
- }, 0);
483
- }
484
- /**
485
- * Extracts paddings sizes from provided styles.
486
- *
487
- * @param {CSSStyleDeclaration} styles
488
- * @returns {Object} Paddings box.
489
- */
490
- function getPaddings(styles) {
491
- var positions = ['top', 'right', 'bottom', 'left'];
492
- var paddings = {};
493
- for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
494
- var position = positions_1[_i];
495
- var value = styles['padding-' + position];
496
- paddings[position] = toFloat(value);
497
- }
498
- return paddings;
499
- }
500
- /**
501
- * Calculates content rectangle of provided SVG element.
502
- *
503
- * @param {SVGGraphicsElement} target - Element content rectangle of which needs
504
- * to be calculated.
505
- * @returns {DOMRectInit}
506
- */
507
- function getSVGContentRect(target) {
508
- var bbox = target.getBBox();
509
- return createRectInit(0, 0, bbox.width, bbox.height);
510
- }
511
- /**
512
- * Calculates content rectangle of provided HTMLElement.
513
- *
514
- * @param {HTMLElement} target - Element for which to calculate the content rectangle.
515
- * @returns {DOMRectInit}
516
- */
517
- function getHTMLElementContentRect(target) {
518
- // Client width & height properties can't be
519
- // used exclusively as they provide rounded values.
520
- var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
521
- // By this condition we can catch all non-replaced inline, hidden and
522
- // detached elements. Though elements with width & height properties less
523
- // than 0.5 will be discarded as well.
524
- //
525
- // Without it we would need to implement separate methods for each of
526
- // those cases and it's not possible to perform a precise and performance
527
- // effective test for hidden elements. E.g. even jQuery's ':visible' filter
528
- // gives wrong results for elements with width & height less than 0.5.
529
- if (!clientWidth && !clientHeight) {
530
- return emptyRect;
531
- }
532
- var styles = getWindowOf(target).getComputedStyle(target);
533
- var paddings = getPaddings(styles);
534
- var horizPad = paddings.left + paddings.right;
535
- var vertPad = paddings.top + paddings.bottom;
536
- // Computed styles of width & height are being used because they are the
537
- // only dimensions available to JS that contain non-rounded values. It could
538
- // be possible to utilize the getBoundingClientRect if only it's data wasn't
539
- // affected by CSS transformations let alone paddings, borders and scroll bars.
540
- var width = toFloat(styles.width), height = toFloat(styles.height);
541
- // Width & height include paddings and borders when the 'border-box' box
542
- // model is applied (except for IE).
543
- if (styles.boxSizing === 'border-box') {
544
- // Following conditions are required to handle Internet Explorer which
545
- // doesn't include paddings and borders to computed CSS dimensions.
546
- //
547
- // We can say that if CSS dimensions + paddings are equal to the "client"
548
- // properties then it's either IE, and thus we don't need to subtract
549
- // anything, or an element merely doesn't have paddings/borders styles.
550
- if (Math.round(width + horizPad) !== clientWidth) {
551
- width -= getBordersSize(styles, 'left', 'right') + horizPad;
552
- }
553
- if (Math.round(height + vertPad) !== clientHeight) {
554
- height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
555
- }
556
- }
557
- // Following steps can't be applied to the document's root element as its
558
- // client[Width/Height] properties represent viewport area of the window.
559
- // Besides, it's as well not necessary as the <html> itself neither has
560
- // rendered scroll bars nor it can be clipped.
561
- if (!isDocumentElement(target)) {
562
- // In some browsers (only in Firefox, actually) CSS width & height
563
- // include scroll bars size which can be removed at this step as scroll
564
- // bars are the only difference between rounded dimensions + paddings
565
- // and "client" properties, though that is not always true in Chrome.
566
- var vertScrollbar = Math.round(width + horizPad) - clientWidth;
567
- var horizScrollbar = Math.round(height + vertPad) - clientHeight;
568
- // Chrome has a rather weird rounding of "client" properties.
569
- // E.g. for an element with content width of 314.2px it sometimes gives
570
- // the client width of 315px and for the width of 314.7px it may give
571
- // 314px. And it doesn't happen all the time. So just ignore this delta
572
- // as a non-relevant.
573
- if (Math.abs(vertScrollbar) !== 1) {
574
- width -= vertScrollbar;
575
- }
576
- if (Math.abs(horizScrollbar) !== 1) {
577
- height -= horizScrollbar;
578
- }
579
- }
580
- return createRectInit(paddings.left, paddings.top, width, height);
581
- }
582
- /**
583
- * Checks whether provided element is an instance of the SVGGraphicsElement.
584
- *
585
- * @param {Element} target - Element to be checked.
586
- * @returns {boolean}
587
- */
588
- var isSVGGraphicsElement = (function () {
589
- // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
590
- // interface.
591
- if (typeof SVGGraphicsElement !== 'undefined') {
592
- return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
593
- }
594
- // If it's so, then check that element is at least an instance of the
595
- // SVGElement and that it has the "getBBox" method.
596
- // eslint-disable-next-line no-extra-parens
597
- return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
598
- typeof target.getBBox === 'function'); };
599
- })();
600
- /**
601
- * Checks whether provided element is a document element (<html>).
602
- *
603
- * @param {Element} target - Element to be checked.
604
- * @returns {boolean}
605
- */
606
- function isDocumentElement(target) {
607
- return target === getWindowOf(target).document.documentElement;
608
- }
609
- /**
610
- * Calculates an appropriate content rectangle for provided html or svg element.
611
- *
612
- * @param {Element} target - Element content rectangle of which needs to be calculated.
613
- * @returns {DOMRectInit}
614
- */
615
- function getContentRect(target) {
616
- if (!isBrowser) {
617
- return emptyRect;
618
- }
619
- if (isSVGGraphicsElement(target)) {
620
- return getSVGContentRect(target);
621
- }
622
- return getHTMLElementContentRect(target);
623
- }
624
- /**
625
- * Creates rectangle with an interface of the DOMRectReadOnly.
626
- * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
627
- *
628
- * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
629
- * @returns {DOMRectReadOnly}
630
- */
631
- function createReadOnlyRect(_a) {
632
- var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
633
- // If DOMRectReadOnly is available use it as a prototype for the rectangle.
634
- var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
635
- var rect = Object.create(Constr.prototype);
636
- // Rectangle's properties are not writable and non-enumerable.
637
- defineConfigurable(rect, {
638
- x: x, y: y, width: width, height: height,
639
- top: y,
640
- right: x + width,
641
- bottom: height + y,
642
- left: x
643
- });
644
- return rect;
645
- }
646
- /**
647
- * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
648
- * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
649
- *
650
- * @param {number} x - X coordinate.
651
- * @param {number} y - Y coordinate.
652
- * @param {number} width - Rectangle's width.
653
- * @param {number} height - Rectangle's height.
654
- * @returns {DOMRectInit}
655
- */
656
- function createRectInit(x, y, width, height) {
657
- return { x: x, y: y, width: width, height: height };
658
- }
659
-
660
- /**
661
- * Class that is responsible for computations of the content rectangle of
662
- * provided DOM element and for keeping track of it's changes.
663
- */
664
- var ResizeObservation = /** @class */ (function () {
665
- /**
666
- * Creates an instance of ResizeObservation.
667
- *
668
- * @param {Element} target - Element to be observed.
669
- */
670
- function ResizeObservation(target) {
671
- /**
672
- * Broadcasted width of content rectangle.
673
- *
674
- * @type {number}
675
- */
676
- this.broadcastWidth = 0;
677
- /**
678
- * Broadcasted height of content rectangle.
679
- *
680
- * @type {number}
681
- */
682
- this.broadcastHeight = 0;
683
- /**
684
- * Reference to the last observed content rectangle.
685
- *
686
- * @private {DOMRectInit}
687
- */
688
- this.contentRect_ = createRectInit(0, 0, 0, 0);
689
- this.target = target;
690
- }
691
- /**
692
- * Updates content rectangle and tells whether it's width or height properties
693
- * have changed since the last broadcast.
694
- *
695
- * @returns {boolean}
696
- */
697
- ResizeObservation.prototype.isActive = function () {
698
- var rect = getContentRect(this.target);
699
- this.contentRect_ = rect;
700
- return (rect.width !== this.broadcastWidth ||
701
- rect.height !== this.broadcastHeight);
702
- };
703
- /**
704
- * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
705
- * from the corresponding properties of the last observed content rectangle.
706
- *
707
- * @returns {DOMRectInit} Last observed content rectangle.
708
- */
709
- ResizeObservation.prototype.broadcastRect = function () {
710
- var rect = this.contentRect_;
711
- this.broadcastWidth = rect.width;
712
- this.broadcastHeight = rect.height;
713
- return rect;
714
- };
715
- return ResizeObservation;
716
- }());
717
-
718
- var ResizeObserverEntry = /** @class */ (function () {
719
- /**
720
- * Creates an instance of ResizeObserverEntry.
721
- *
722
- * @param {Element} target - Element that is being observed.
723
- * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
724
- */
725
- function ResizeObserverEntry(target, rectInit) {
726
- var contentRect = createReadOnlyRect(rectInit);
727
- // According to the specification following properties are not writable
728
- // and are also not enumerable in the native implementation.
729
- //
730
- // Property accessors are not being used as they'd require to define a
731
- // private WeakMap storage which may cause memory leaks in browsers that
732
- // don't support this type of collections.
733
- defineConfigurable(this, { target: target, contentRect: contentRect });
734
- }
735
- return ResizeObserverEntry;
736
- }());
737
-
738
- var ResizeObserverSPI = /** @class */ (function () {
739
- /**
740
- * Creates a new instance of ResizeObserver.
741
- *
742
- * @param {ResizeObserverCallback} callback - Callback function that is invoked
743
- * when one of the observed elements changes it's content dimensions.
744
- * @param {ResizeObserverController} controller - Controller instance which
745
- * is responsible for the updates of observer.
746
- * @param {ResizeObserver} callbackCtx - Reference to the public
747
- * ResizeObserver instance which will be passed to callback function.
748
- */
749
- function ResizeObserverSPI(callback, controller, callbackCtx) {
750
- /**
751
- * Collection of resize observations that have detected changes in dimensions
752
- * of elements.
753
- *
754
- * @private {Array<ResizeObservation>}
755
- */
756
- this.activeObservations_ = [];
757
- /**
758
- * Registry of the ResizeObservation instances.
759
- *
760
- * @private {Map<Element, ResizeObservation>}
761
- */
762
- this.observations_ = new MapShim();
763
- if (typeof callback !== 'function') {
764
- throw new TypeError('The callback provided as parameter 1 is not a function.');
765
- }
766
- this.callback_ = callback;
767
- this.controller_ = controller;
768
- this.callbackCtx_ = callbackCtx;
769
- }
770
- /**
771
- * Starts observing provided element.
772
- *
773
- * @param {Element} target - Element to be observed.
774
- * @returns {void}
775
- */
776
- ResizeObserverSPI.prototype.observe = function (target) {
777
- if (!arguments.length) {
778
- throw new TypeError('1 argument required, but only 0 present.');
779
- }
780
- // Do nothing if current environment doesn't have the Element interface.
781
- if (typeof Element === 'undefined' || !(Element instanceof Object)) {
782
- return;
783
- }
784
- if (!(target instanceof getWindowOf(target).Element)) {
785
- throw new TypeError('parameter 1 is not of type "Element".');
786
- }
787
- var observations = this.observations_;
788
- // Do nothing if element is already being observed.
789
- if (observations.has(target)) {
790
- return;
791
- }
792
- observations.set(target, new ResizeObservation(target));
793
- this.controller_.addObserver(this);
794
- // Force the update of observations.
795
- this.controller_.refresh();
796
- };
797
- /**
798
- * Stops observing provided element.
799
- *
800
- * @param {Element} target - Element to stop observing.
801
- * @returns {void}
802
- */
803
- ResizeObserverSPI.prototype.unobserve = function (target) {
804
- if (!arguments.length) {
805
- throw new TypeError('1 argument required, but only 0 present.');
806
- }
807
- // Do nothing if current environment doesn't have the Element interface.
808
- if (typeof Element === 'undefined' || !(Element instanceof Object)) {
809
- return;
810
- }
811
- if (!(target instanceof getWindowOf(target).Element)) {
812
- throw new TypeError('parameter 1 is not of type "Element".');
813
- }
814
- var observations = this.observations_;
815
- // Do nothing if element is not being observed.
816
- if (!observations.has(target)) {
817
- return;
818
- }
819
- observations.delete(target);
820
- if (!observations.size) {
821
- this.controller_.removeObserver(this);
822
- }
823
- };
824
- /**
825
- * Stops observing all elements.
826
- *
827
- * @returns {void}
828
- */
829
- ResizeObserverSPI.prototype.disconnect = function () {
830
- this.clearActive();
831
- this.observations_.clear();
832
- this.controller_.removeObserver(this);
833
- };
834
- /**
835
- * Collects observation instances the associated element of which has changed
836
- * it's content rectangle.
837
- *
838
- * @returns {void}
839
- */
840
- ResizeObserverSPI.prototype.gatherActive = function () {
841
- var _this = this;
842
- this.clearActive();
843
- this.observations_.forEach(function (observation) {
844
- if (observation.isActive()) {
845
- _this.activeObservations_.push(observation);
846
- }
847
- });
848
- };
849
- /**
850
- * Invokes initial callback function with a list of ResizeObserverEntry
851
- * instances collected from active resize observations.
852
- *
853
- * @returns {void}
854
- */
855
- ResizeObserverSPI.prototype.broadcastActive = function () {
856
- // Do nothing if observer doesn't have active observations.
857
- if (!this.hasActive()) {
858
- return;
859
- }
860
- var ctx = this.callbackCtx_;
861
- // Create ResizeObserverEntry instance for every active observation.
862
- var entries = this.activeObservations_.map(function (observation) {
863
- return new ResizeObserverEntry(observation.target, observation.broadcastRect());
864
- });
865
- this.callback_.call(ctx, entries, ctx);
866
- this.clearActive();
867
- };
868
- /**
869
- * Clears the collection of active observations.
870
- *
871
- * @returns {void}
872
- */
873
- ResizeObserverSPI.prototype.clearActive = function () {
874
- this.activeObservations_.splice(0);
875
- };
876
- /**
877
- * Tells whether observer has active observations.
878
- *
879
- * @returns {boolean}
880
- */
881
- ResizeObserverSPI.prototype.hasActive = function () {
882
- return this.activeObservations_.length > 0;
883
- };
884
- return ResizeObserverSPI;
885
- }());
886
-
887
- // Registry of internal observers. If WeakMap is not available use current shim
888
- // for the Map collection as it has all required methods and because WeakMap
889
- // can't be fully polyfilled anyway.
890
- var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
891
- /**
892
- * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
893
- * exposing only those methods and properties that are defined in the spec.
894
- */
895
- var ResizeObserver = /** @class */ (function () {
896
- /**
897
- * Creates a new instance of ResizeObserver.
898
- *
899
- * @param {ResizeObserverCallback} callback - Callback that is invoked when
900
- * dimensions of the observed elements change.
901
- */
902
- function ResizeObserver(callback) {
903
- if (!(this instanceof ResizeObserver)) {
904
- throw new TypeError('Cannot call a class as a function.');
905
- }
906
- if (!arguments.length) {
907
- throw new TypeError('1 argument required, but only 0 present.');
908
- }
909
- var controller = ResizeObserverController.getInstance();
910
- var observer = new ResizeObserverSPI(callback, controller, this);
911
- observers.set(this, observer);
912
- }
913
- return ResizeObserver;
914
- }());
915
- // Expose public methods of ResizeObserver.
916
- [
917
- 'observe',
918
- 'unobserve',
919
- 'disconnect'
920
- ].forEach(function (method) {
921
- ResizeObserver.prototype[method] = function () {
922
- var _a;
923
- return (_a = observers.get(this))[method].apply(_a, arguments);
924
- };
925
- });
926
-
927
- var index = (function () {
928
- // Export existing implementation if available.
929
- if (typeof global$1.ResizeObserver !== 'undefined') {
930
- return global$1.ResizeObserver;
931
- }
932
- return ResizeObserver;
933
- })();
934
-
935
- /* harmony default export */ __webpack_exports__["default"] = (index);
936
-
937
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("c8ba")))
938
-
939
- /***/ })
940
-
941
- }]);