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