@alfalab/core-components-select 10.3.0 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/Component.d.ts +1 -1
  3. package/dist/Component.js +1 -1
  4. package/dist/components/arrow/Component.js +1 -1
  5. package/dist/components/arrow/index.css +3 -3
  6. package/dist/components/base-select/Component.js +23 -22
  7. package/dist/components/base-select/index.css +7 -7
  8. package/dist/components/base-select/index.js +1 -1
  9. package/dist/components/checkmark/Component.js +2 -2
  10. package/dist/components/checkmark/index.css +7 -7
  11. package/dist/components/field/Component.d.ts +1 -1
  12. package/dist/components/field/Component.js +3 -3
  13. package/dist/components/field/index.css +9 -9
  14. package/dist/components/field/index.js +1 -1
  15. package/dist/components/index.js +1 -1
  16. package/dist/components/native-select/Component.js +1 -1
  17. package/dist/components/native-select/index.js +1 -1
  18. package/dist/components/optgroup/Component.js +1 -1
  19. package/dist/components/optgroup/index.css +6 -6
  20. package/dist/components/option/Component.js +2 -2
  21. package/dist/components/option/index.css +20 -20
  22. package/dist/components/option/index.js +1 -1
  23. package/dist/components/options-list/Component.js +13 -8
  24. package/dist/components/options-list/index.css +9 -5
  25. package/dist/components/options-list/index.js +1 -0
  26. package/dist/components/virtual-options-list/Component.d.ts +1 -1
  27. package/dist/components/virtual-options-list/Component.js +22 -18
  28. package/dist/components/virtual-options-list/index.css +15 -12
  29. package/dist/components/virtual-options-list/index.js +1 -0
  30. package/dist/cssm/Component.d.ts +1 -1
  31. package/dist/cssm/components/base-select/Component.js +21 -20
  32. package/dist/cssm/components/checkmark/Component.js +1 -1
  33. package/dist/cssm/components/field/Component.d.ts +1 -1
  34. package/dist/cssm/components/field/Component.js +1 -1
  35. package/dist/cssm/components/options-list/Component.js +12 -7
  36. package/dist/cssm/components/options-list/index.js +1 -0
  37. package/dist/cssm/components/options-list/index.module.css +4 -0
  38. package/dist/cssm/components/virtual-options-list/Component.d.ts +1 -1
  39. package/dist/cssm/components/virtual-options-list/Component.js +21 -17
  40. package/dist/cssm/components/virtual-options-list/index.js +1 -0
  41. package/dist/cssm/components/virtual-options-list/index.module.css +4 -1
  42. package/dist/cssm/hook-45e5f3a8.d.ts +12 -0
  43. package/dist/cssm/hook-45e5f3a8.js +147 -0
  44. package/dist/cssm/hook-f5b8fe4f.d.ts +61 -0
  45. package/dist/cssm/index.js +7 -1
  46. package/dist/cssm/intersection-observer-8c55e13a.d.ts +1 -0
  47. package/dist/cssm/intersection-observer-8c55e13a.js +893 -0
  48. package/dist/cssm/presets/index.d.ts +1 -0
  49. package/dist/cssm/presets/index.js +29 -1
  50. package/dist/cssm/presets/useLazyLoading/hook.js +1 -892
  51. package/dist/cssm/presets/useSelectWithApply/hook.d.ts +0 -0
  52. package/dist/cssm/presets/useSelectWithApply/hook.js +46 -0
  53. package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
  54. package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +45 -0
  55. package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
  56. package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +45 -0
  57. package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.module.css +38 -0
  58. package/dist/cssm/typings.d.ts +39 -6
  59. package/dist/esm/Component.d.ts +1 -1
  60. package/dist/esm/Component.js +1 -1
  61. package/dist/esm/components/arrow/Component.js +1 -1
  62. package/dist/esm/components/arrow/index.css +3 -3
  63. package/dist/esm/components/base-select/Component.js +23 -22
  64. package/dist/esm/components/base-select/index.css +7 -7
  65. package/dist/esm/components/base-select/index.js +1 -1
  66. package/dist/esm/components/checkmark/Component.js +2 -2
  67. package/dist/esm/components/checkmark/index.css +7 -7
  68. package/dist/esm/components/field/Component.d.ts +1 -1
  69. package/dist/esm/components/field/Component.js +3 -3
  70. package/dist/esm/components/field/index.css +9 -9
  71. package/dist/esm/components/field/index.js +1 -1
  72. package/dist/esm/components/index.js +1 -1
  73. package/dist/esm/components/native-select/Component.js +1 -1
  74. package/dist/esm/components/native-select/index.js +1 -1
  75. package/dist/esm/components/optgroup/Component.js +1 -1
  76. package/dist/esm/components/optgroup/index.css +6 -6
  77. package/dist/esm/components/option/Component.js +2 -2
  78. package/dist/esm/components/option/index.css +20 -20
  79. package/dist/esm/components/option/index.js +1 -1
  80. package/dist/esm/components/options-list/Component.js +14 -9
  81. package/dist/esm/components/options-list/index.css +9 -5
  82. package/dist/esm/components/options-list/index.js +1 -0
  83. package/dist/esm/components/virtual-options-list/Component.d.ts +1 -1
  84. package/dist/esm/components/virtual-options-list/Component.js +22 -18
  85. package/dist/esm/components/virtual-options-list/index.css +15 -12
  86. package/dist/esm/components/virtual-options-list/index.js +1 -0
  87. package/dist/esm/hook-a01ac265.d.ts +12 -0
  88. package/dist/esm/hook-a01ac265.js +131 -0
  89. package/dist/esm/hook-f5b8fe4f.d.ts +61 -0
  90. package/dist/esm/index.js +4 -1
  91. package/dist/esm/intersection-observer-2080f60e.d.ts +1 -0
  92. package/dist/esm/intersection-observer-2080f60e.js +891 -0
  93. package/dist/esm/presets/index.d.ts +1 -0
  94. package/dist/esm/presets/index.js +20 -1
  95. package/dist/esm/presets/useLazyLoading/hook.js +3 -894
  96. package/dist/esm/presets/useLazyLoading/index.css +2 -2
  97. package/dist/esm/presets/useSelectWithApply/hook.d.ts +0 -0
  98. package/dist/esm/presets/useSelectWithApply/hook.js +26 -0
  99. package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
  100. package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +26 -0
  101. package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
  102. package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
  103. package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.js +26 -0
  104. package/dist/esm/presets/useSelectWithLoading/hook.js +2 -2
  105. package/dist/esm/presets/useSelectWithLoading/index.css +2 -2
  106. package/dist/esm/{tslib.es6-5a8a0ede.d.ts → tslib.es6-11a0bbd3.d.ts} +0 -0
  107. package/dist/esm/{tslib.es6-5a8a0ede.js → tslib.es6-11a0bbd3.js} +0 -0
  108. package/dist/esm/typings.d.ts +39 -6
  109. package/dist/hook-4f9a90b8.d.ts +12 -0
  110. package/dist/hook-4f9a90b8.js +140 -0
  111. package/dist/hook-f5b8fe4f.d.ts +61 -0
  112. package/dist/index.js +6 -1
  113. package/dist/intersection-observer-c983b2d1.d.ts +1 -0
  114. package/dist/intersection-observer-c983b2d1.js +893 -0
  115. package/dist/modern/Component.d.ts +1 -1
  116. package/dist/modern/components/arrow/Component.js +1 -1
  117. package/dist/modern/components/arrow/index.css +3 -3
  118. package/dist/modern/components/base-select/Component.js +17 -14
  119. package/dist/modern/components/base-select/index.css +7 -7
  120. package/dist/modern/components/checkmark/Component.js +2 -2
  121. package/dist/modern/components/checkmark/index.css +7 -7
  122. package/dist/modern/components/field/Component.d.ts +1 -1
  123. package/dist/modern/components/field/Component.js +2 -2
  124. package/dist/modern/components/field/index.css +9 -9
  125. package/dist/modern/components/optgroup/Component.js +1 -1
  126. package/dist/modern/components/optgroup/index.css +6 -6
  127. package/dist/modern/components/option/Component.js +1 -1
  128. package/dist/modern/components/option/index.css +20 -20
  129. package/dist/modern/components/options-list/Component.js +11 -7
  130. package/dist/modern/components/options-list/index.css +9 -5
  131. package/dist/modern/components/virtual-options-list/Component.d.ts +1 -1
  132. package/dist/modern/components/virtual-options-list/Component.js +20 -17
  133. package/dist/modern/components/virtual-options-list/index.css +15 -12
  134. package/dist/modern/hook-cdda7a62.d.ts +12 -0
  135. package/dist/modern/hook-cdda7a62.js +132 -0
  136. package/dist/modern/hook-f5b8fe4f.d.ts +61 -0
  137. package/dist/modern/index.js +3 -0
  138. package/dist/modern/intersection-observer-2080f60e.d.ts +1 -0
  139. package/dist/modern/intersection-observer-2080f60e.js +891 -0
  140. package/dist/modern/presets/index.d.ts +1 -0
  141. package/dist/modern/presets/index.js +19 -0
  142. package/dist/modern/presets/useLazyLoading/hook.js +2 -893
  143. package/dist/modern/presets/useLazyLoading/index.css +2 -2
  144. package/dist/modern/presets/useSelectWithApply/hook.d.ts +0 -0
  145. package/dist/modern/presets/useSelectWithApply/hook.js +25 -0
  146. package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
  147. package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +25 -0
  148. package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
  149. package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
  150. package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.js +25 -0
  151. package/dist/modern/presets/useSelectWithLoading/hook.js +1 -1
  152. package/dist/modern/presets/useSelectWithLoading/index.css +2 -2
  153. package/dist/modern/typings.d.ts +39 -6
  154. package/dist/presets/index.d.ts +1 -0
  155. package/dist/presets/index.js +22 -1
  156. package/dist/presets/useLazyLoading/hook.js +3 -894
  157. package/dist/presets/useLazyLoading/index.css +2 -2
  158. package/dist/presets/useSelectWithApply/hook.d.ts +0 -0
  159. package/dist/presets/useSelectWithApply/hook.js +35 -0
  160. package/dist/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
  161. package/dist/presets/useSelectWithApply/options-list-with-apply/Component.js +34 -0
  162. package/dist/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
  163. package/dist/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
  164. package/dist/presets/useSelectWithApply/options-list-with-apply/index.js +34 -0
  165. package/dist/presets/useSelectWithLoading/hook.js +2 -2
  166. package/dist/presets/useSelectWithLoading/index.css +2 -2
  167. package/dist/{tslib.es6-f6070e97.d.ts → tslib.es6-edfcd771.d.ts} +0 -0
  168. package/dist/{tslib.es6-f6070e97.js → tslib.es6-edfcd771.js} +0 -0
  169. package/dist/typings.d.ts +39 -6
  170. package/package.json +3 -2
@@ -2,911 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../tslib.es6-f6070e97.js');
5
+ var tslib_es6 = require('../../tslib.es6-edfcd771.js');
6
6
  var React = require('react');
7
7
  require('classnames');
8
8
  require('@alfalab/core-components-checkbox');
9
9
  require('../../components/checkmark/Component.js');
10
10
  var components_option_Component = require('../../components/option/Component.js');
11
11
  var coreComponentsSkeleton = require('@alfalab/core-components-skeleton');
12
+ require('../../intersection-observer-c983b2d1.js');
12
13
 
13
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
15
 
15
16
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
16
17
 
17
- /**
18
- * Copyright 2016 Google Inc. All Rights Reserved.
19
- *
20
- * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.
21
- *
22
- * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
23
- *
24
- */
25
- (function () {
26
- // Exit early if we're not running in a browser.
27
- if (typeof window !== 'object') {
28
- return;
29
- }
30
- // Exit early if all IntersectionObserver and IntersectionObserverEntry
31
- // features are natively supported.
32
- if ('IntersectionObserver' in window &&
33
- 'IntersectionObserverEntry' in window &&
34
- 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
35
- // Minimal polyfill for Edge 15's lack of `isIntersecting`
36
- // See: https://github.com/w3c/IntersectionObserver/issues/211
37
- if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
38
- Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
39
- get: function () {
40
- return this.intersectionRatio > 0;
41
- }
42
- });
43
- }
44
- return;
45
- }
46
- /**
47
- * Returns the embedding frame element, if any.
48
- * @param {!Document} doc
49
- * @return {!Element}
50
- */
51
- function getFrameElement(doc) {
52
- try {
53
- return doc.defaultView && doc.defaultView.frameElement || null;
54
- }
55
- catch (e) {
56
- // Ignore the error.
57
- return null;
58
- }
59
- }
60
- /**
61
- * A local reference to the root document.
62
- */
63
- var document = (function (startDoc) {
64
- var doc = startDoc;
65
- var frame = getFrameElement(doc);
66
- while (frame) {
67
- doc = frame.ownerDocument;
68
- frame = getFrameElement(doc);
69
- }
70
- return doc;
71
- })(window.document);
72
- /**
73
- * An IntersectionObserver registry. This registry exists to hold a strong
74
- * reference to IntersectionObserver instances currently observing a target
75
- * element. Without this registry, instances without another reference may be
76
- * garbage collected.
77
- */
78
- var registry = [];
79
- /**
80
- * The signal updater for cross-origin intersection. When not null, it means
81
- * that the polyfill is configured to work in a cross-origin mode.
82
- * @type {function(DOMRect|ClientRect, DOMRect|ClientRect)}
83
- */
84
- var crossOriginUpdater = null;
85
- /**
86
- * The current cross-origin intersection. Only used in the cross-origin mode.
87
- * @type {DOMRect|ClientRect}
88
- */
89
- var crossOriginRect = null;
90
- /**
91
- * Creates the global IntersectionObserverEntry constructor.
92
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
93
- * @param {Object} entry A dictionary of instance properties.
94
- * @constructor
95
- */
96
- function IntersectionObserverEntry(entry) {
97
- this.time = entry.time;
98
- this.target = entry.target;
99
- this.rootBounds = ensureDOMRect(entry.rootBounds);
100
- this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
101
- this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect());
102
- this.isIntersecting = !!entry.intersectionRect;
103
- // Calculates the intersection ratio.
104
- var targetRect = this.boundingClientRect;
105
- var targetArea = targetRect.width * targetRect.height;
106
- var intersectionRect = this.intersectionRect;
107
- var intersectionArea = intersectionRect.width * intersectionRect.height;
108
- // Sets intersection ratio.
109
- if (targetArea) {
110
- // Round the intersection ratio to avoid floating point math issues:
111
- // https://github.com/w3c/IntersectionObserver/issues/324
112
- this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
113
- }
114
- else {
115
- // If area is zero and is intersecting, sets to 1, otherwise to 0
116
- this.intersectionRatio = this.isIntersecting ? 1 : 0;
117
- }
118
- }
119
- /**
120
- * Creates the global IntersectionObserver constructor.
121
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
122
- * @param {Function} callback The function to be invoked after intersection
123
- * changes have queued. The function is not invoked if the queue has
124
- * been emptied by calling the `takeRecords` method.
125
- * @param {Object=} opt_options Optional configuration options.
126
- * @constructor
127
- */
128
- function IntersectionObserver(callback, opt_options) {
129
- var options = opt_options || {};
130
- if (typeof callback != 'function') {
131
- throw new Error('callback must be a function');
132
- }
133
- if (options.root &&
134
- options.root.nodeType != 1 &&
135
- options.root.nodeType != 9) {
136
- throw new Error('root must be a Document or Element');
137
- }
138
- // Binds and throttles `this._checkForIntersections`.
139
- this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
140
- // Private properties.
141
- this._callback = callback;
142
- this._observationTargets = [];
143
- this._queuedEntries = [];
144
- this._rootMarginValues = this._parseRootMargin(options.rootMargin);
145
- // Public properties.
146
- this.thresholds = this._initThresholds(options.threshold);
147
- this.root = options.root || null;
148
- this.rootMargin = this._rootMarginValues.map(function (margin) {
149
- return margin.value + margin.unit;
150
- }).join(' ');
151
- /** @private @const {!Array<!Document>} */
152
- this._monitoringDocuments = [];
153
- /** @private @const {!Array<function()>} */
154
- this._monitoringUnsubscribes = [];
155
- }
156
- /**
157
- * The minimum interval within which the document will be checked for
158
- * intersection changes.
159
- */
160
- IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
161
- /**
162
- * The frequency in which the polyfill polls for intersection changes.
163
- * this can be updated on a per instance basis and must be set prior to
164
- * calling `observe` on the first target.
165
- */
166
- IntersectionObserver.prototype.POLL_INTERVAL = null;
167
- /**
168
- * Use a mutation observer on the root element
169
- * to detect intersection changes.
170
- */
171
- IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
172
- /**
173
- * Sets up the polyfill in the cross-origin mode. The result is the
174
- * updater function that accepts two arguments: `boundingClientRect` and
175
- * `intersectionRect` - just as these fields would be available to the
176
- * parent via `IntersectionObserverEntry`. This function should be called
177
- * each time the iframe receives intersection information from the parent
178
- * window, e.g. via messaging.
179
- * @return {function(DOMRect|ClientRect, DOMRect|ClientRect)}
180
- */
181
- IntersectionObserver._setupCrossOriginUpdater = function () {
182
- if (!crossOriginUpdater) {
183
- /**
184
- * @param {DOMRect|ClientRect} boundingClientRect
185
- * @param {DOMRect|ClientRect} intersectionRect
186
- */
187
- crossOriginUpdater = function (boundingClientRect, intersectionRect) {
188
- if (!boundingClientRect || !intersectionRect) {
189
- crossOriginRect = getEmptyRect();
190
- }
191
- else {
192
- crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect);
193
- }
194
- registry.forEach(function (observer) {
195
- observer._checkForIntersections();
196
- });
197
- };
198
- }
199
- return crossOriginUpdater;
200
- };
201
- /**
202
- * Resets the cross-origin mode.
203
- */
204
- IntersectionObserver._resetCrossOriginUpdater = function () {
205
- crossOriginUpdater = null;
206
- crossOriginRect = null;
207
- };
208
- /**
209
- * Starts observing a target element for intersection changes based on
210
- * the thresholds values.
211
- * @param {Element} target The DOM element to observe.
212
- */
213
- IntersectionObserver.prototype.observe = function (target) {
214
- var isTargetAlreadyObserved = this._observationTargets.some(function (item) {
215
- return item.element == target;
216
- });
217
- if (isTargetAlreadyObserved) {
218
- return;
219
- }
220
- if (!(target && target.nodeType == 1)) {
221
- throw new Error('target must be an Element');
222
- }
223
- this._registerInstance();
224
- this._observationTargets.push({ element: target, entry: null });
225
- this._monitorIntersections(target.ownerDocument);
226
- this._checkForIntersections();
227
- };
228
- /**
229
- * Stops observing a target element for intersection changes.
230
- * @param {Element} target The DOM element to observe.
231
- */
232
- IntersectionObserver.prototype.unobserve = function (target) {
233
- this._observationTargets =
234
- this._observationTargets.filter(function (item) {
235
- return item.element != target;
236
- });
237
- this._unmonitorIntersections(target.ownerDocument);
238
- if (this._observationTargets.length == 0) {
239
- this._unregisterInstance();
240
- }
241
- };
242
- /**
243
- * Stops observing all target elements for intersection changes.
244
- */
245
- IntersectionObserver.prototype.disconnect = function () {
246
- this._observationTargets = [];
247
- this._unmonitorAllIntersections();
248
- this._unregisterInstance();
249
- };
250
- /**
251
- * Returns any queue entries that have not yet been reported to the
252
- * callback and clears the queue. This can be used in conjunction with the
253
- * callback to obtain the absolute most up-to-date intersection information.
254
- * @return {Array} The currently queued entries.
255
- */
256
- IntersectionObserver.prototype.takeRecords = function () {
257
- var records = this._queuedEntries.slice();
258
- this._queuedEntries = [];
259
- return records;
260
- };
261
- /**
262
- * Accepts the threshold value from the user configuration object and
263
- * returns a sorted array of unique threshold values. If a value is not
264
- * between 0 and 1 and error is thrown.
265
- * @private
266
- * @param {Array|number=} opt_threshold An optional threshold value or
267
- * a list of threshold values, defaulting to [0].
268
- * @return {Array} A sorted list of unique and valid threshold values.
269
- */
270
- IntersectionObserver.prototype._initThresholds = function (opt_threshold) {
271
- var threshold = opt_threshold || [0];
272
- if (!Array.isArray(threshold))
273
- threshold = [threshold];
274
- return threshold.sort().filter(function (t, i, a) {
275
- if (typeof t != 'number' || isNaN(t) || t < 0 || t > 1) {
276
- throw new Error('threshold must be a number between 0 and 1 inclusively');
277
- }
278
- return t !== a[i - 1];
279
- });
280
- };
281
- /**
282
- * Accepts the rootMargin value from the user configuration object
283
- * and returns an array of the four margin values as an object containing
284
- * the value and unit properties. If any of the values are not properly
285
- * formatted or use a unit other than px or %, and error is thrown.
286
- * @private
287
- * @param {string=} opt_rootMargin An optional rootMargin value,
288
- * defaulting to '0px'.
289
- * @return {Array<Object>} An array of margin objects with the keys
290
- * value and unit.
291
- */
292
- IntersectionObserver.prototype._parseRootMargin = function (opt_rootMargin) {
293
- var marginString = opt_rootMargin || '0px';
294
- var margins = marginString.split(/\s+/).map(function (margin) {
295
- var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
296
- if (!parts) {
297
- throw new Error('rootMargin must be specified in pixels or percent');
298
- }
299
- return { value: parseFloat(parts[1]), unit: parts[2] };
300
- });
301
- // Handles shorthand.
302
- margins[1] = margins[1] || margins[0];
303
- margins[2] = margins[2] || margins[0];
304
- margins[3] = margins[3] || margins[1];
305
- return margins;
306
- };
307
- /**
308
- * Starts polling for intersection changes if the polling is not already
309
- * happening, and if the page's visibility state is visible.
310
- * @param {!Document} doc
311
- * @private
312
- */
313
- IntersectionObserver.prototype._monitorIntersections = function (doc) {
314
- var win = doc.defaultView;
315
- if (!win) {
316
- // Already destroyed.
317
- return;
318
- }
319
- if (this._monitoringDocuments.indexOf(doc) != -1) {
320
- // Already monitoring.
321
- return;
322
- }
323
- // Private state for monitoring.
324
- var callback = this._checkForIntersections;
325
- var monitoringInterval = null;
326
- var domObserver = null;
327
- // If a poll interval is set, use polling instead of listening to
328
- // resize and scroll events or DOM mutations.
329
- if (this.POLL_INTERVAL) {
330
- monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
331
- }
332
- else {
333
- addEvent(win, 'resize', callback, true);
334
- addEvent(doc, 'scroll', callback, true);
335
- if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in win) {
336
- domObserver = new win.MutationObserver(callback);
337
- domObserver.observe(doc, {
338
- attributes: true,
339
- childList: true,
340
- characterData: true,
341
- subtree: true
342
- });
343
- }
344
- }
345
- this._monitoringDocuments.push(doc);
346
- this._monitoringUnsubscribes.push(function () {
347
- // Get the window object again. When a friendly iframe is destroyed, it
348
- // will be null.
349
- var win = doc.defaultView;
350
- if (win) {
351
- if (monitoringInterval) {
352
- win.clearInterval(monitoringInterval);
353
- }
354
- removeEvent(win, 'resize', callback, true);
355
- }
356
- removeEvent(doc, 'scroll', callback, true);
357
- if (domObserver) {
358
- domObserver.disconnect();
359
- }
360
- });
361
- // Also monitor the parent.
362
- var rootDoc = (this.root && (this.root.ownerDocument || this.root)) || document;
363
- if (doc != rootDoc) {
364
- var frame = getFrameElement(doc);
365
- if (frame) {
366
- this._monitorIntersections(frame.ownerDocument);
367
- }
368
- }
369
- };
370
- /**
371
- * Stops polling for intersection changes.
372
- * @param {!Document} doc
373
- * @private
374
- */
375
- IntersectionObserver.prototype._unmonitorIntersections = function (doc) {
376
- var index = this._monitoringDocuments.indexOf(doc);
377
- if (index == -1) {
378
- return;
379
- }
380
- var rootDoc = (this.root && (this.root.ownerDocument || this.root)) || document;
381
- // Check if any dependent targets are still remaining.
382
- var hasDependentTargets = this._observationTargets.some(function (item) {
383
- var itemDoc = item.element.ownerDocument;
384
- // Target is in this context.
385
- if (itemDoc == doc) {
386
- return true;
387
- }
388
- // Target is nested in this context.
389
- while (itemDoc && itemDoc != rootDoc) {
390
- var frame = getFrameElement(itemDoc);
391
- itemDoc = frame && frame.ownerDocument;
392
- if (itemDoc == doc) {
393
- return true;
394
- }
395
- }
396
- return false;
397
- });
398
- if (hasDependentTargets) {
399
- return;
400
- }
401
- // Unsubscribe.
402
- var unsubscribe = this._monitoringUnsubscribes[index];
403
- this._monitoringDocuments.splice(index, 1);
404
- this._monitoringUnsubscribes.splice(index, 1);
405
- unsubscribe();
406
- // Also unmonitor the parent.
407
- if (doc != rootDoc) {
408
- var frame = getFrameElement(doc);
409
- if (frame) {
410
- this._unmonitorIntersections(frame.ownerDocument);
411
- }
412
- }
413
- };
414
- /**
415
- * Stops polling for intersection changes.
416
- * @param {!Document} doc
417
- * @private
418
- */
419
- IntersectionObserver.prototype._unmonitorAllIntersections = function () {
420
- var unsubscribes = this._monitoringUnsubscribes.slice(0);
421
- this._monitoringDocuments.length = 0;
422
- this._monitoringUnsubscribes.length = 0;
423
- for (var i = 0; i < unsubscribes.length; i++) {
424
- unsubscribes[i]();
425
- }
426
- };
427
- /**
428
- * Scans each observation target for intersection changes and adds them
429
- * to the internal entries queue. If new entries are found, it
430
- * schedules the callback to be invoked.
431
- * @private
432
- */
433
- IntersectionObserver.prototype._checkForIntersections = function () {
434
- if (!this.root && crossOriginUpdater && !crossOriginRect) {
435
- // Cross origin monitoring, but no initial data available yet.
436
- return;
437
- }
438
- var rootIsInDom = this._rootIsInDom();
439
- var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
440
- this._observationTargets.forEach(function (item) {
441
- var target = item.element;
442
- var targetRect = getBoundingClientRect(target);
443
- var rootContainsTarget = this._rootContainsTarget(target);
444
- var oldEntry = item.entry;
445
- var intersectionRect = rootIsInDom && rootContainsTarget &&
446
- this._computeTargetAndRootIntersection(target, targetRect, rootRect);
447
- var rootBounds = null;
448
- if (!this._rootContainsTarget(target)) {
449
- rootBounds = getEmptyRect();
450
- }
451
- else if (!crossOriginUpdater || this.root) {
452
- rootBounds = rootRect;
453
- }
454
- var newEntry = item.entry = new IntersectionObserverEntry({
455
- time: now(),
456
- target: target,
457
- boundingClientRect: targetRect,
458
- rootBounds: rootBounds,
459
- intersectionRect: intersectionRect
460
- });
461
- if (!oldEntry) {
462
- this._queuedEntries.push(newEntry);
463
- }
464
- else if (rootIsInDom && rootContainsTarget) {
465
- // If the new entry intersection ratio has crossed any of the
466
- // thresholds, add a new entry.
467
- if (this._hasCrossedThreshold(oldEntry, newEntry)) {
468
- this._queuedEntries.push(newEntry);
469
- }
470
- }
471
- else {
472
- // If the root is not in the DOM or target is not contained within
473
- // root but the previous entry for this target had an intersection,
474
- // add a new record indicating removal.
475
- if (oldEntry && oldEntry.isIntersecting) {
476
- this._queuedEntries.push(newEntry);
477
- }
478
- }
479
- }, this);
480
- if (this._queuedEntries.length) {
481
- this._callback(this.takeRecords(), this);
482
- }
483
- };
484
- /**
485
- * Accepts a target and root rect computes the intersection between then
486
- * following the algorithm in the spec.
487
- * TODO(philipwalton): at this time clip-path is not considered.
488
- * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
489
- * @param {Element} target The target DOM element
490
- * @param {Object} targetRect The bounding rect of the target.
491
- * @param {Object} rootRect The bounding rect of the root after being
492
- * expanded by the rootMargin value.
493
- * @return {?Object} The final intersection rect object or undefined if no
494
- * intersection is found.
495
- * @private
496
- */
497
- IntersectionObserver.prototype._computeTargetAndRootIntersection =
498
- function (target, targetRect, rootRect) {
499
- // If the element isn't displayed, an intersection can't happen.
500
- if (window.getComputedStyle(target).display == 'none')
501
- return;
502
- var intersectionRect = targetRect;
503
- var parent = getParentNode(target);
504
- var atRoot = false;
505
- while (!atRoot && parent) {
506
- var parentRect = null;
507
- var parentComputedStyle = parent.nodeType == 1 ?
508
- window.getComputedStyle(parent) : {};
509
- // If the parent isn't displayed, an intersection can't happen.
510
- if (parentComputedStyle.display == 'none')
511
- return null;
512
- if (parent == this.root || parent.nodeType == /* DOCUMENT */ 9) {
513
- atRoot = true;
514
- if (parent == this.root || parent == document) {
515
- if (crossOriginUpdater && !this.root) {
516
- if (!crossOriginRect ||
517
- crossOriginRect.width == 0 && crossOriginRect.height == 0) {
518
- // A 0-size cross-origin intersection means no-intersection.
519
- parent = null;
520
- parentRect = null;
521
- intersectionRect = null;
522
- }
523
- else {
524
- parentRect = crossOriginRect;
525
- }
526
- }
527
- else {
528
- parentRect = rootRect;
529
- }
530
- }
531
- else {
532
- // Check if there's a frame that can be navigated to.
533
- var frame = getParentNode(parent);
534
- var frameRect = frame && getBoundingClientRect(frame);
535
- var frameIntersect = frame &&
536
- this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
537
- if (frameRect && frameIntersect) {
538
- parent = frame;
539
- parentRect = convertFromParentRect(frameRect, frameIntersect);
540
- }
541
- else {
542
- parent = null;
543
- intersectionRect = null;
544
- }
545
- }
546
- }
547
- else {
548
- // If the element has a non-visible overflow, and it's not the <body>
549
- // or <html> element, update the intersection rect.
550
- // Note: <body> and <html> cannot be clipped to a rect that's not also
551
- // the document rect, so no need to compute a new intersection.
552
- var doc = parent.ownerDocument;
553
- if (parent != doc.body &&
554
- parent != doc.documentElement &&
555
- parentComputedStyle.overflow != 'visible') {
556
- parentRect = getBoundingClientRect(parent);
557
- }
558
- }
559
- // If either of the above conditionals set a new parentRect,
560
- // calculate new intersection data.
561
- if (parentRect) {
562
- intersectionRect = computeRectIntersection(parentRect, intersectionRect);
563
- }
564
- if (!intersectionRect)
565
- break;
566
- parent = parent && getParentNode(parent);
567
- }
568
- return intersectionRect;
569
- };
570
- /**
571
- * Returns the root rect after being expanded by the rootMargin value.
572
- * @return {ClientRect} The expanded root rect.
573
- * @private
574
- */
575
- IntersectionObserver.prototype._getRootRect = function () {
576
- var rootRect;
577
- if (this.root && !isDoc(this.root)) {
578
- rootRect = getBoundingClientRect(this.root);
579
- }
580
- else {
581
- // Use <html>/<body> instead of window since scroll bars affect size.
582
- var doc = isDoc(this.root) ? this.root : document;
583
- var html = doc.documentElement;
584
- var body = doc.body;
585
- rootRect = {
586
- top: 0,
587
- left: 0,
588
- right: html.clientWidth || body.clientWidth,
589
- width: html.clientWidth || body.clientWidth,
590
- bottom: html.clientHeight || body.clientHeight,
591
- height: html.clientHeight || body.clientHeight
592
- };
593
- }
594
- return this._expandRectByRootMargin(rootRect);
595
- };
596
- /**
597
- * Accepts a rect and expands it by the rootMargin value.
598
- * @param {DOMRect|ClientRect} rect The rect object to expand.
599
- * @return {ClientRect} The expanded rect.
600
- * @private
601
- */
602
- IntersectionObserver.prototype._expandRectByRootMargin = function (rect) {
603
- var margins = this._rootMarginValues.map(function (margin, i) {
604
- return margin.unit == 'px' ? margin.value :
605
- margin.value * (i % 2 ? rect.width : rect.height) / 100;
606
- });
607
- var newRect = {
608
- top: rect.top - margins[0],
609
- right: rect.right + margins[1],
610
- bottom: rect.bottom + margins[2],
611
- left: rect.left - margins[3]
612
- };
613
- newRect.width = newRect.right - newRect.left;
614
- newRect.height = newRect.bottom - newRect.top;
615
- return newRect;
616
- };
617
- /**
618
- * Accepts an old and new entry and returns true if at least one of the
619
- * threshold values has been crossed.
620
- * @param {?IntersectionObserverEntry} oldEntry The previous entry for a
621
- * particular target element or null if no previous entry exists.
622
- * @param {IntersectionObserverEntry} newEntry The current entry for a
623
- * particular target element.
624
- * @return {boolean} Returns true if a any threshold has been crossed.
625
- * @private
626
- */
627
- IntersectionObserver.prototype._hasCrossedThreshold =
628
- function (oldEntry, newEntry) {
629
- // To make comparing easier, an entry that has a ratio of 0
630
- // but does not actually intersect is given a value of -1
631
- var oldRatio = oldEntry && oldEntry.isIntersecting ?
632
- oldEntry.intersectionRatio || 0 : -1;
633
- var newRatio = newEntry.isIntersecting ?
634
- newEntry.intersectionRatio || 0 : -1;
635
- // Ignore unchanged ratios
636
- if (oldRatio === newRatio)
637
- return;
638
- for (var i = 0; i < this.thresholds.length; i++) {
639
- var threshold = this.thresholds[i];
640
- // Return true if an entry matches a threshold or if the new ratio
641
- // and the old ratio are on the opposite sides of a threshold.
642
- if (threshold == oldRatio || threshold == newRatio ||
643
- threshold < oldRatio !== threshold < newRatio) {
644
- return true;
645
- }
646
- }
647
- };
648
- /**
649
- * Returns whether or not the root element is an element and is in the DOM.
650
- * @return {boolean} True if the root element is an element and is in the DOM.
651
- * @private
652
- */
653
- IntersectionObserver.prototype._rootIsInDom = function () {
654
- return !this.root || containsDeep(document, this.root);
655
- };
656
- /**
657
- * Returns whether or not the target element is a child of root.
658
- * @param {Element} target The target element to check.
659
- * @return {boolean} True if the target element is a child of root.
660
- * @private
661
- */
662
- IntersectionObserver.prototype._rootContainsTarget = function (target) {
663
- var rootDoc = (this.root && (this.root.ownerDocument || this.root)) || document;
664
- return (containsDeep(rootDoc, target) &&
665
- (!this.root || rootDoc == target.ownerDocument));
666
- };
667
- /**
668
- * Adds the instance to the global IntersectionObserver registry if it isn't
669
- * already present.
670
- * @private
671
- */
672
- IntersectionObserver.prototype._registerInstance = function () {
673
- if (registry.indexOf(this) < 0) {
674
- registry.push(this);
675
- }
676
- };
677
- /**
678
- * Removes the instance from the global IntersectionObserver registry.
679
- * @private
680
- */
681
- IntersectionObserver.prototype._unregisterInstance = function () {
682
- var index = registry.indexOf(this);
683
- if (index != -1)
684
- registry.splice(index, 1);
685
- };
686
- /**
687
- * Returns the result of the performance.now() method or null in browsers
688
- * that don't support the API.
689
- * @return {number} The elapsed time since the page was requested.
690
- */
691
- function now() {
692
- return window.performance && performance.now && performance.now();
693
- }
694
- /**
695
- * Throttles a function and delays its execution, so it's only called at most
696
- * once within a given time period.
697
- * @param {Function} fn The function to throttle.
698
- * @param {number} timeout The amount of time that must pass before the
699
- * function can be called again.
700
- * @return {Function} The throttled function.
701
- */
702
- function throttle(fn, timeout) {
703
- var timer = null;
704
- return function () {
705
- if (!timer) {
706
- timer = setTimeout(function () {
707
- fn();
708
- timer = null;
709
- }, timeout);
710
- }
711
- };
712
- }
713
- /**
714
- * Adds an event handler to a DOM node ensuring cross-browser compatibility.
715
- * @param {Node} node The DOM node to add the event handler to.
716
- * @param {string} event The event name.
717
- * @param {Function} fn The event handler to add.
718
- * @param {boolean} opt_useCapture Optionally adds the even to the capture
719
- * phase. Note: this only works in modern browsers.
720
- */
721
- function addEvent(node, event, fn, opt_useCapture) {
722
- if (typeof node.addEventListener == 'function') {
723
- node.addEventListener(event, fn, opt_useCapture || false);
724
- }
725
- else if (typeof node.attachEvent == 'function') {
726
- node.attachEvent('on' + event, fn);
727
- }
728
- }
729
- /**
730
- * Removes a previously added event handler from a DOM node.
731
- * @param {Node} node The DOM node to remove the event handler from.
732
- * @param {string} event The event name.
733
- * @param {Function} fn The event handler to remove.
734
- * @param {boolean} opt_useCapture If the event handler was added with this
735
- * flag set to true, it should be set to true here in order to remove it.
736
- */
737
- function removeEvent(node, event, fn, opt_useCapture) {
738
- if (typeof node.removeEventListener == 'function') {
739
- node.removeEventListener(event, fn, opt_useCapture || false);
740
- }
741
- else if (typeof node.detatchEvent == 'function') {
742
- node.detatchEvent('on' + event, fn);
743
- }
744
- }
745
- /**
746
- * Returns the intersection between two rect objects.
747
- * @param {Object} rect1 The first rect.
748
- * @param {Object} rect2 The second rect.
749
- * @return {?Object|?ClientRect} The intersection rect or undefined if no
750
- * intersection is found.
751
- */
752
- function computeRectIntersection(rect1, rect2) {
753
- var top = Math.max(rect1.top, rect2.top);
754
- var bottom = Math.min(rect1.bottom, rect2.bottom);
755
- var left = Math.max(rect1.left, rect2.left);
756
- var right = Math.min(rect1.right, rect2.right);
757
- var width = right - left;
758
- var height = bottom - top;
759
- return (width >= 0 && height >= 0) && {
760
- top: top,
761
- bottom: bottom,
762
- left: left,
763
- right: right,
764
- width: width,
765
- height: height
766
- } || null;
767
- }
768
- /**
769
- * Shims the native getBoundingClientRect for compatibility with older IE.
770
- * @param {Element} el The element whose bounding rect to get.
771
- * @return {DOMRect|ClientRect} The (possibly shimmed) rect of the element.
772
- */
773
- function getBoundingClientRect(el) {
774
- var rect;
775
- try {
776
- rect = el.getBoundingClientRect();
777
- }
778
- catch (err) {
779
- // Ignore Windows 7 IE11 "Unspecified error"
780
- // https://github.com/w3c/IntersectionObserver/pull/205
781
- }
782
- if (!rect)
783
- return getEmptyRect();
784
- // Older IE
785
- if (!(rect.width && rect.height)) {
786
- rect = {
787
- top: rect.top,
788
- right: rect.right,
789
- bottom: rect.bottom,
790
- left: rect.left,
791
- width: rect.right - rect.left,
792
- height: rect.bottom - rect.top
793
- };
794
- }
795
- return rect;
796
- }
797
- /**
798
- * Returns an empty rect object. An empty rect is returned when an element
799
- * is not in the DOM.
800
- * @return {ClientRect} The empty rect.
801
- */
802
- function getEmptyRect() {
803
- return {
804
- top: 0,
805
- bottom: 0,
806
- left: 0,
807
- right: 0,
808
- width: 0,
809
- height: 0
810
- };
811
- }
812
- /**
813
- * Ensure that the result has all of the necessary fields of the DOMRect.
814
- * Specifically this ensures that `x` and `y` fields are set.
815
- *
816
- * @param {?DOMRect|?ClientRect} rect
817
- * @return {?DOMRect}
818
- */
819
- function ensureDOMRect(rect) {
820
- // A `DOMRect` object has `x` and `y` fields.
821
- if (!rect || 'x' in rect) {
822
- return rect;
823
- }
824
- // A IE's `ClientRect` type does not have `x` and `y`. The same is the case
825
- // for internally calculated Rect objects. For the purposes of
826
- // `IntersectionObserver`, it's sufficient to simply mirror `left` and `top`
827
- // for these fields.
828
- return {
829
- top: rect.top,
830
- y: rect.top,
831
- bottom: rect.bottom,
832
- left: rect.left,
833
- x: rect.left,
834
- right: rect.right,
835
- width: rect.width,
836
- height: rect.height
837
- };
838
- }
839
- /**
840
- * Inverts the intersection and bounding rect from the parent (frame) BCR to
841
- * the local BCR space.
842
- * @param {DOMRect|ClientRect} parentBoundingRect The parent's bound client rect.
843
- * @param {DOMRect|ClientRect} parentIntersectionRect The parent's own intersection rect.
844
- * @return {ClientRect} The local root bounding rect for the parent's children.
845
- */
846
- function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
847
- var top = parentIntersectionRect.top - parentBoundingRect.top;
848
- var left = parentIntersectionRect.left - parentBoundingRect.left;
849
- return {
850
- top: top,
851
- left: left,
852
- height: parentIntersectionRect.height,
853
- width: parentIntersectionRect.width,
854
- bottom: top + parentIntersectionRect.height,
855
- right: left + parentIntersectionRect.width
856
- };
857
- }
858
- /**
859
- * Checks to see if a parent element contains a child element (including inside
860
- * shadow DOM).
861
- * @param {Node} parent The parent element.
862
- * @param {Node} child The child element.
863
- * @return {boolean} True if the parent node contains the child node.
864
- */
865
- function containsDeep(parent, child) {
866
- var node = child;
867
- while (node) {
868
- if (node == parent)
869
- return true;
870
- node = getParentNode(node);
871
- }
872
- return false;
873
- }
874
- /**
875
- * Gets the parent node of an element or its host element if the parent node
876
- * is a shadow root.
877
- * @param {Node} node The node whose parent to get.
878
- * @return {Node|null} The parent node or null if no parent exists.
879
- */
880
- function getParentNode(node) {
881
- var parent = node.parentNode;
882
- if (node.nodeType == /* DOCUMENT */ 9 && node != document) {
883
- // If this node is a document node, look for the embedding frame.
884
- return getFrameElement(node);
885
- }
886
- // If the parent has element that is assigned through shadow root slot
887
- if (parent && parent.assignedSlot) {
888
- parent = parent.assignedSlot.parentNode;
889
- }
890
- if (parent && parent.nodeType == 11 && parent.host) {
891
- // If the parent is a shadow root, return the host element.
892
- return parent.host;
893
- }
894
- return parent;
895
- }
896
- /**
897
- * Returns true if `node` is a Document.
898
- * @param {!Node} node
899
- * @returns {boolean}
900
- */
901
- function isDoc(node) {
902
- return node && node.nodeType === 9;
903
- }
904
- // Exposes the constructors globally.
905
- window.IntersectionObserver = IntersectionObserver;
906
- window.IntersectionObserverEntry = IntersectionObserverEntry;
907
- }());
908
-
909
- var styles = {"skeleton":"select__skeleton_1mtny"};
18
+ var styles = {"skeleton":"select__skeleton_8v2uk"};
910
19
  require('./index.css')
911
20
 
912
21
  var DEBOUNCE_TIMEOUT = 300;