@jobber/components 6.90.3 → 6.91.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 (214) hide show
  1. package/dist/AtlantisThemeContext-es.js +1 -1
  2. package/dist/Autocomplete/index.cjs +12 -15
  3. package/dist/Autocomplete/index.mjs +13 -16
  4. package/dist/Banner/index.cjs +1 -6
  5. package/dist/Banner/index.mjs +1 -6
  6. package/dist/Banner-cjs.js +2 -2
  7. package/dist/Banner-es.js +2 -2
  8. package/dist/Card/index.cjs +1 -4
  9. package/dist/Card/index.mjs +1 -4
  10. package/dist/Chip/index.cjs +1 -3
  11. package/dist/Chip/index.mjs +1 -3
  12. package/dist/Chip-cjs.js +3 -3
  13. package/dist/Chip-es.js +3 -3
  14. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +1 -0
  15. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +1 -0
  16. package/dist/Chips/InternalChipDismissible/index.cjs +1 -3
  17. package/dist/Chips/InternalChipDismissible/index.mjs +1 -3
  18. package/dist/Chips/index.cjs +1 -3
  19. package/dist/Chips/index.mjs +1 -3
  20. package/dist/Combobox/components/ComboboxActivator/index.cjs +1 -3
  21. package/dist/Combobox/components/ComboboxActivator/index.mjs +1 -3
  22. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.cjs +1 -1
  23. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.mjs +1 -1
  24. package/dist/Combobox/components/ComboboxContent/ComboboxLoadMore/index.cjs +1 -1
  25. package/dist/Combobox/components/ComboboxContent/ComboboxLoadMore/index.mjs +1 -1
  26. package/dist/Combobox/components/ComboboxContent/index.cjs +1 -3
  27. package/dist/Combobox/components/ComboboxContent/index.mjs +1 -3
  28. package/dist/Combobox/components/ComboboxTrigger/index.cjs +1 -3
  29. package/dist/Combobox/components/ComboboxTrigger/index.mjs +1 -3
  30. package/dist/Combobox/index.cjs +1 -6
  31. package/dist/Combobox/index.mjs +1 -6
  32. package/dist/Combobox-cjs.js +2 -2
  33. package/dist/Combobox-es.js +2 -2
  34. package/dist/ComboboxContent-cjs.js +3 -4
  35. package/dist/ComboboxContent-es.js +4 -5
  36. package/dist/ComboboxLoadMore-cjs.js +2 -2
  37. package/dist/ComboboxLoadMore-es.js +2 -2
  38. package/dist/ConfirmationModal/index.cjs +1 -3
  39. package/dist/ConfirmationModal/index.mjs +1 -3
  40. package/dist/ConfirmationModal-cjs.js +2 -2
  41. package/dist/ConfirmationModal-es.js +2 -2
  42. package/dist/ContentBlock/index.cjs +1 -6
  43. package/dist/ContentBlock/index.mjs +1 -6
  44. package/dist/ContentBlock-cjs.js +2 -2
  45. package/dist/ContentBlock-es.js +2 -2
  46. package/dist/DataDump/index.cjs +1 -4
  47. package/dist/DataDump/index.mjs +1 -4
  48. package/dist/DataList/components/DataListActions/index.cjs +1 -5
  49. package/dist/DataList/components/DataListActions/index.mjs +1 -5
  50. package/dist/DataList/components/DataListActionsMenu/index.cjs +1 -5
  51. package/dist/DataList/components/DataListActionsMenu/index.mjs +1 -5
  52. package/dist/DataList/components/DataListBulkActions/index.cjs +1 -5
  53. package/dist/DataList/components/DataListBulkActions/index.mjs +1 -5
  54. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +1 -6
  55. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +1 -6
  56. package/dist/DataList/components/DataListFilters/index.cjs +1 -7
  57. package/dist/DataList/components/DataListFilters/index.mjs +1 -7
  58. package/dist/DataList/components/DataListHeader/index.cjs +1 -5
  59. package/dist/DataList/components/DataListHeader/index.mjs +1 -5
  60. package/dist/DataList/components/DataListHeaderTile/components/index.cjs +1 -2
  61. package/dist/DataList/components/DataListHeaderTile/components/index.mjs +1 -2
  62. package/dist/DataList/components/DataListHeaderTile/index.cjs +1 -3
  63. package/dist/DataList/components/DataListHeaderTile/index.mjs +1 -3
  64. package/dist/DataList/components/DataListItem/index.cjs +1 -5
  65. package/dist/DataList/components/DataListItem/index.mjs +1 -5
  66. package/dist/DataList/components/DataListItemActions/index.cjs +1 -5
  67. package/dist/DataList/components/DataListItemActions/index.mjs +1 -5
  68. package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +1 -5
  69. package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +1 -5
  70. package/dist/DataList/components/DataListItems/index.cjs +1 -5
  71. package/dist/DataList/components/DataListItems/index.mjs +1 -5
  72. package/dist/DataList/components/DataListLayout/index.cjs +1 -5
  73. package/dist/DataList/components/DataListLayout/index.mjs +1 -5
  74. package/dist/DataList/components/DataListLayoutActions/index.cjs +1 -5
  75. package/dist/DataList/components/DataListLayoutActions/index.mjs +1 -5
  76. package/dist/DataList/components/DataListLoadMore/index.cjs +1 -1
  77. package/dist/DataList/components/DataListLoadMore/index.mjs +1 -1
  78. package/dist/DataList/components/DataListOverflowFade/index.cjs +1 -1
  79. package/dist/DataList/components/DataListOverflowFade/index.mjs +1 -1
  80. package/dist/DataList/components/DataListSearch/index.cjs +1 -2
  81. package/dist/DataList/components/DataListSearch/index.mjs +1 -2
  82. package/dist/DataList/components/DataListStatusBar/index.cjs +1 -3
  83. package/dist/DataList/components/DataListStatusBar/index.mjs +1 -3
  84. package/dist/DataList/index.cjs +1 -7
  85. package/dist/DataList/index.mjs +1 -7
  86. package/dist/DataListActionsMenu-cjs.js +5 -8
  87. package/dist/DataListActionsMenu-es.js +5 -8
  88. package/dist/DataListHeaderTile-cjs.js +2 -2
  89. package/dist/DataListHeaderTile-es.js +2 -2
  90. package/dist/DataListLoadMore-cjs.js +2 -2
  91. package/dist/DataListLoadMore-es.js +2 -2
  92. package/dist/DataListOverflowFade-cjs.js +3 -3
  93. package/dist/DataListOverflowFade-es.js +3 -3
  94. package/dist/DataListSearch-cjs.js +2 -2
  95. package/dist/DataListSearch-es.js +2 -2
  96. package/dist/DataListSortingOptions-cjs.js +3 -4
  97. package/dist/DataListSortingOptions-es.js +3 -4
  98. package/dist/DataTable/index.cjs +4 -6
  99. package/dist/DataTable/index.mjs +4 -6
  100. package/dist/DataTable/test-utilities/index.cjs +1 -7
  101. package/dist/DataTable/test-utilities/index.mjs +1 -7
  102. package/dist/DataTable-cjs.js +4 -4
  103. package/dist/DataTable-es.js +4 -4
  104. package/dist/DatePicker/index.cjs +1 -1
  105. package/dist/DatePicker/index.mjs +1 -1
  106. package/dist/DatePicker-cjs.js +2 -2
  107. package/dist/DatePicker-es.js +3 -3
  108. package/dist/Disclosure/index.cjs +1 -6
  109. package/dist/Disclosure/index.mjs +1 -6
  110. package/dist/Disclosure-cjs.js +3 -3
  111. package/dist/Disclosure-es.js +3 -3
  112. package/dist/FormField/FormFieldWrapper.d.ts +1 -1
  113. package/dist/FormField/index.cjs +1 -0
  114. package/dist/FormField/index.mjs +1 -0
  115. package/dist/FormField-cjs.js +2 -21
  116. package/dist/FormField-es.js +2 -21
  117. package/dist/FormatFile/index.cjs +1 -3
  118. package/dist/FormatFile/index.mjs +1 -3
  119. package/dist/Gallery/index.cjs +1 -6
  120. package/dist/Gallery/index.mjs +1 -6
  121. package/dist/InputDate/index.cjs +1 -2
  122. package/dist/InputDate/index.mjs +1 -2
  123. package/dist/InputEmail/index.cjs +1 -0
  124. package/dist/InputEmail/index.mjs +1 -0
  125. package/dist/InputNumber/index.cjs +1 -0
  126. package/dist/InputNumber/index.mjs +1 -0
  127. package/dist/InputPassword/index.cjs +1 -0
  128. package/dist/InputPassword/index.mjs +1 -0
  129. package/dist/InputPassword-cjs.js +1 -0
  130. package/dist/InputPassword-es.js +1 -0
  131. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +1 -1
  132. package/dist/InputPhoneNumber/index.cjs +1 -0
  133. package/dist/InputPhoneNumber/index.mjs +1 -0
  134. package/dist/InputText/InputText.d.ts +2 -2
  135. package/dist/InputText/index.cjs +3 -3
  136. package/dist/InputText/index.mjs +3 -3
  137. package/dist/InputTime/index.cjs +1 -0
  138. package/dist/InputTime/index.mjs +2 -1
  139. package/dist/InternalChipDismissible-cjs.js +1 -0
  140. package/dist/InternalChipDismissible-es.js +1 -0
  141. package/dist/LightBox/index.cjs +1 -6
  142. package/dist/LightBox/index.mjs +1 -6
  143. package/dist/LightBox-cjs.js +12 -74
  144. package/dist/LightBox-es.js +12 -74
  145. package/dist/Menu/index.cjs +1 -4
  146. package/dist/Menu/index.mjs +1 -4
  147. package/dist/Menu-cjs.js +5 -37
  148. package/dist/Menu-es.js +6 -38
  149. package/dist/Modal/Modal.rebuilt.d.ts +1 -1
  150. package/dist/Modal/index.cjs +24 -22
  151. package/dist/Modal/index.mjs +25 -23
  152. package/dist/Page/index.cjs +2 -10
  153. package/dist/Page/index.mjs +2 -10
  154. package/dist/Page-cjs.js +5 -5
  155. package/dist/Page-es.js +5 -5
  156. package/dist/Popover/index.cjs +1 -1
  157. package/dist/Popover/index.mjs +1 -1
  158. package/dist/Popover-cjs.js +2 -2
  159. package/dist/Popover-es.js +3 -3
  160. package/dist/RecurringSelect/index.cjs +1 -0
  161. package/dist/RecurringSelect/index.mjs +1 -0
  162. package/dist/Select/index.cjs +1 -0
  163. package/dist/Select/index.mjs +1 -0
  164. package/dist/SideDrawer/index.cjs +1 -5
  165. package/dist/SideDrawer/index.mjs +1 -5
  166. package/dist/SideDrawer-cjs.js +7 -10
  167. package/dist/SideDrawer-es.js +7 -10
  168. package/dist/Tabs/index.cjs +0 -1
  169. package/dist/Tabs/index.mjs +0 -1
  170. package/dist/Tabs-cjs.js +76 -2
  171. package/dist/Tabs-es.js +76 -2
  172. package/dist/Tooltip/index.cjs +1 -2
  173. package/dist/Tooltip/index.mjs +1 -2
  174. package/dist/Tooltip-cjs.js +3 -4
  175. package/dist/Tooltip-es.js +4 -5
  176. package/dist/_baseEach-es.js +1 -1
  177. package/dist/_commonjsHelpers-cjs.js +0 -26
  178. package/dist/_commonjsHelpers-es.js +1 -26
  179. package/dist/_isIterateeCall-es.js +1 -1
  180. package/dist/debounce-es.js +2 -2
  181. package/dist/floating-ui.react-cjs.js +0 -118
  182. package/dist/floating-ui.react-es.js +1 -118
  183. package/dist/helpers-cjs.js +21 -2
  184. package/dist/helpers-es.js +1 -1
  185. package/dist/index.cjs +1 -9
  186. package/dist/index.mjs +1 -9
  187. package/dist/isObjectLike-es.js +1 -1
  188. package/dist/isSymbol-es.js +1 -1
  189. package/dist/isTypedArray-es.js +1 -1
  190. package/dist/keysIn-es.js +1 -1
  191. package/dist/omit-es.js +1 -1
  192. package/dist/styles.css +8 -7
  193. package/dist/useScrollToActive-cjs.js +3 -45
  194. package/dist/useScrollToActive-es.js +5 -47
  195. package/package.json +3 -3
  196. package/rollup.config.mjs +0 -15
  197. package/dist/throttle-cjs.js +0 -80
  198. package/dist/throttle-es.js +0 -77
  199. package/dist/useDebounce-cjs.js +0 -4416
  200. package/dist/useDebounce-es.js +0 -4413
  201. package/dist/useFocusTrap-cjs.js +0 -75
  202. package/dist/useFocusTrap-es.js +0 -73
  203. package/dist/useInView-cjs.js +0 -26
  204. package/dist/useInView-es.js +0 -24
  205. package/dist/useIsMounted-cjs.js +0 -51
  206. package/dist/useIsMounted-es.js +0 -49
  207. package/dist/useOnKeyDown-cjs.js +0 -41
  208. package/dist/useOnKeyDown-es.js +0 -39
  209. package/dist/useRefocusOnActivator-cjs.js +0 -33
  210. package/dist/useRefocusOnActivator-es.js +0 -31
  211. package/dist/useResizeObserver-cjs.js +0 -1131
  212. package/dist/useResizeObserver-es.js +0 -1128
  213. package/dist/useSafeLayoutEffect-cjs.js +0 -14
  214. package/dist/useSafeLayoutEffect-es.js +0 -12
@@ -1,1128 +0,0 @@
1
- import { a as getAugmentedNamespace, c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-es.js';
2
- import React__default from 'react';
3
- import { a as throttle_1 } from './throttle-es.js';
4
-
5
- function _mergeNamespaces(n, m) {
6
- m.forEach(function (e) {
7
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
8
- if (k !== 'default' && !(k in n)) {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () { return e[k]; }
13
- });
14
- }
15
- });
16
- });
17
- return Object.freeze(n);
18
- }
19
-
20
- var useResizeObserver$2 = {};
21
-
22
- /**
23
- * A collection of shims that provide minimal functionality of the ES6 collections.
24
- *
25
- * These implementations are not meant to be used outside of the ResizeObserver
26
- * modules as they cover only a limited range of use cases.
27
- */
28
- /* eslint-disable require-jsdoc, valid-jsdoc */
29
- var MapShim = (function () {
30
- if (typeof Map !== 'undefined') {
31
- return Map;
32
- }
33
- /**
34
- * Returns index in provided array that matches the specified key.
35
- *
36
- * @param {Array<Array>} arr
37
- * @param {*} key
38
- * @returns {number}
39
- */
40
- function getIndex(arr, key) {
41
- var result = -1;
42
- arr.some(function (entry, index) {
43
- if (entry[0] === key) {
44
- result = index;
45
- return true;
46
- }
47
- return false;
48
- });
49
- return result;
50
- }
51
- return /** @class */ (function () {
52
- function class_1() {
53
- this.__entries__ = [];
54
- }
55
- Object.defineProperty(class_1.prototype, "size", {
56
- /**
57
- * @returns {boolean}
58
- */
59
- get: function () {
60
- return this.__entries__.length;
61
- },
62
- enumerable: true,
63
- configurable: true
64
- });
65
- /**
66
- * @param {*} key
67
- * @returns {*}
68
- */
69
- class_1.prototype.get = function (key) {
70
- var index = getIndex(this.__entries__, key);
71
- var entry = this.__entries__[index];
72
- return entry && entry[1];
73
- };
74
- /**
75
- * @param {*} key
76
- * @param {*} value
77
- * @returns {void}
78
- */
79
- class_1.prototype.set = function (key, value) {
80
- var index = getIndex(this.__entries__, key);
81
- if (~index) {
82
- this.__entries__[index][1] = value;
83
- }
84
- else {
85
- this.__entries__.push([key, value]);
86
- }
87
- };
88
- /**
89
- * @param {*} key
90
- * @returns {void}
91
- */
92
- class_1.prototype.delete = function (key) {
93
- var entries = this.__entries__;
94
- var index = getIndex(entries, key);
95
- if (~index) {
96
- entries.splice(index, 1);
97
- }
98
- };
99
- /**
100
- * @param {*} key
101
- * @returns {void}
102
- */
103
- class_1.prototype.has = function (key) {
104
- return !!~getIndex(this.__entries__, key);
105
- };
106
- /**
107
- * @returns {void}
108
- */
109
- class_1.prototype.clear = function () {
110
- this.__entries__.splice(0);
111
- };
112
- /**
113
- * @param {Function} callback
114
- * @param {*} [ctx=null]
115
- * @returns {void}
116
- */
117
- class_1.prototype.forEach = function (callback, ctx) {
118
- if (ctx === void 0) { ctx = null; }
119
- for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
120
- var entry = _a[_i];
121
- callback.call(ctx, entry[1], entry[0]);
122
- }
123
- };
124
- return class_1;
125
- }());
126
- })();
127
-
128
- /**
129
- * Detects whether window and document objects are available in current environment.
130
- */
131
- var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
132
-
133
- // Returns global object of a current environment.
134
- var global$1 = (function () {
135
- if (typeof global !== 'undefined' && global.Math === Math) {
136
- return global;
137
- }
138
- if (typeof self !== 'undefined' && self.Math === Math) {
139
- return self;
140
- }
141
- if (typeof window !== 'undefined' && window.Math === Math) {
142
- return window;
143
- }
144
- // eslint-disable-next-line no-new-func
145
- return Function('return this')();
146
- })();
147
-
148
- /**
149
- * A shim for the requestAnimationFrame which falls back to the setTimeout if
150
- * first one is not supported.
151
- *
152
- * @returns {number} Requests' identifier.
153
- */
154
- var requestAnimationFrame$1 = (function () {
155
- if (typeof requestAnimationFrame === 'function') {
156
- // It's required to use a bounded function because IE sometimes throws
157
- // an "Invalid calling object" error if rAF is invoked without the global
158
- // object on the left hand side.
159
- return requestAnimationFrame.bind(global$1);
160
- }
161
- return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
162
- })();
163
-
164
- // Defines minimum timeout before adding a trailing call.
165
- var trailingTimeout = 2;
166
- /**
167
- * Creates a wrapper function which ensures that provided callback will be
168
- * invoked only once during the specified delay period.
169
- *
170
- * @param {Function} callback - Function to be invoked after the delay period.
171
- * @param {number} delay - Delay after which to invoke callback.
172
- * @returns {Function}
173
- */
174
- function throttle (callback, delay) {
175
- var leadingCall = false, trailingCall = false, lastCallTime = 0;
176
- /**
177
- * Invokes the original callback function and schedules new invocation if
178
- * the "proxy" was called during current request.
179
- *
180
- * @returns {void}
181
- */
182
- function resolvePending() {
183
- if (leadingCall) {
184
- leadingCall = false;
185
- callback();
186
- }
187
- if (trailingCall) {
188
- proxy();
189
- }
190
- }
191
- /**
192
- * Callback invoked after the specified delay. It will further postpone
193
- * invocation of the original function delegating it to the
194
- * requestAnimationFrame.
195
- *
196
- * @returns {void}
197
- */
198
- function timeoutCallback() {
199
- requestAnimationFrame$1(resolvePending);
200
- }
201
- /**
202
- * Schedules invocation of the original function.
203
- *
204
- * @returns {void}
205
- */
206
- function proxy() {
207
- var timeStamp = Date.now();
208
- if (leadingCall) {
209
- // Reject immediately following calls.
210
- if (timeStamp - lastCallTime < trailingTimeout) {
211
- return;
212
- }
213
- // Schedule new call to be in invoked when the pending one is resolved.
214
- // This is important for "transitions" which never actually start
215
- // immediately so there is a chance that we might miss one if change
216
- // happens amids the pending invocation.
217
- trailingCall = true;
218
- }
219
- else {
220
- leadingCall = true;
221
- trailingCall = false;
222
- setTimeout(timeoutCallback, delay);
223
- }
224
- lastCallTime = timeStamp;
225
- }
226
- return proxy;
227
- }
228
-
229
- // Minimum delay before invoking the update of observers.
230
- var REFRESH_DELAY = 20;
231
- // A list of substrings of CSS properties used to find transition events that
232
- // might affect dimensions of observed elements.
233
- var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
234
- // Check if MutationObserver is available.
235
- var mutationObserverSupported = typeof MutationObserver !== 'undefined';
236
- /**
237
- * Singleton controller class which handles updates of ResizeObserver instances.
238
- */
239
- var ResizeObserverController = /** @class */ (function () {
240
- /**
241
- * Creates a new instance of ResizeObserverController.
242
- *
243
- * @private
244
- */
245
- function ResizeObserverController() {
246
- /**
247
- * Indicates whether DOM listeners have been added.
248
- *
249
- * @private {boolean}
250
- */
251
- this.connected_ = false;
252
- /**
253
- * Tells that controller has subscribed for Mutation Events.
254
- *
255
- * @private {boolean}
256
- */
257
- this.mutationEventsAdded_ = false;
258
- /**
259
- * Keeps reference to the instance of MutationObserver.
260
- *
261
- * @private {MutationObserver}
262
- */
263
- this.mutationsObserver_ = null;
264
- /**
265
- * A list of connected observers.
266
- *
267
- * @private {Array<ResizeObserverSPI>}
268
- */
269
- this.observers_ = [];
270
- this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
271
- this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
272
- }
273
- /**
274
- * Adds observer to observers list.
275
- *
276
- * @param {ResizeObserverSPI} observer - Observer to be added.
277
- * @returns {void}
278
- */
279
- ResizeObserverController.prototype.addObserver = function (observer) {
280
- if (!~this.observers_.indexOf(observer)) {
281
- this.observers_.push(observer);
282
- }
283
- // Add listeners if they haven't been added yet.
284
- if (!this.connected_) {
285
- this.connect_();
286
- }
287
- };
288
- /**
289
- * Removes observer from observers list.
290
- *
291
- * @param {ResizeObserverSPI} observer - Observer to be removed.
292
- * @returns {void}
293
- */
294
- ResizeObserverController.prototype.removeObserver = function (observer) {
295
- var observers = this.observers_;
296
- var index = observers.indexOf(observer);
297
- // Remove observer if it's present in registry.
298
- if (~index) {
299
- observers.splice(index, 1);
300
- }
301
- // Remove listeners if controller has no connected observers.
302
- if (!observers.length && this.connected_) {
303
- this.disconnect_();
304
- }
305
- };
306
- /**
307
- * Invokes the update of observers. It will continue running updates insofar
308
- * it detects changes.
309
- *
310
- * @returns {void}
311
- */
312
- ResizeObserverController.prototype.refresh = function () {
313
- var changesDetected = this.updateObservers_();
314
- // Continue running updates if changes have been detected as there might
315
- // be future ones caused by CSS transitions.
316
- if (changesDetected) {
317
- this.refresh();
318
- }
319
- };
320
- /**
321
- * Updates every observer from observers list and notifies them of queued
322
- * entries.
323
- *
324
- * @private
325
- * @returns {boolean} Returns "true" if any observer has detected changes in
326
- * dimensions of it's elements.
327
- */
328
- ResizeObserverController.prototype.updateObservers_ = function () {
329
- // Collect observers that have active observations.
330
- var activeObservers = this.observers_.filter(function (observer) {
331
- return observer.gatherActive(), observer.hasActive();
332
- });
333
- // Deliver notifications in a separate cycle in order to avoid any
334
- // collisions between observers, e.g. when multiple instances of
335
- // ResizeObserver are tracking the same element and the callback of one
336
- // of them changes content dimensions of the observed target. Sometimes
337
- // this may result in notifications being blocked for the rest of observers.
338
- activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
339
- return activeObservers.length > 0;
340
- };
341
- /**
342
- * Initializes DOM listeners.
343
- *
344
- * @private
345
- * @returns {void}
346
- */
347
- ResizeObserverController.prototype.connect_ = function () {
348
- // Do nothing if running in a non-browser environment or if listeners
349
- // have been already added.
350
- if (!isBrowser || this.connected_) {
351
- return;
352
- }
353
- // Subscription to the "Transitionend" event is used as a workaround for
354
- // delayed transitions. This way it's possible to capture at least the
355
- // final state of an element.
356
- document.addEventListener('transitionend', this.onTransitionEnd_);
357
- window.addEventListener('resize', this.refresh);
358
- if (mutationObserverSupported) {
359
- this.mutationsObserver_ = new MutationObserver(this.refresh);
360
- this.mutationsObserver_.observe(document, {
361
- attributes: true,
362
- childList: true,
363
- characterData: true,
364
- subtree: true
365
- });
366
- }
367
- else {
368
- document.addEventListener('DOMSubtreeModified', this.refresh);
369
- this.mutationEventsAdded_ = true;
370
- }
371
- this.connected_ = true;
372
- };
373
- /**
374
- * Removes DOM listeners.
375
- *
376
- * @private
377
- * @returns {void}
378
- */
379
- ResizeObserverController.prototype.disconnect_ = function () {
380
- // Do nothing if running in a non-browser environment or if listeners
381
- // have been already removed.
382
- if (!isBrowser || !this.connected_) {
383
- return;
384
- }
385
- document.removeEventListener('transitionend', this.onTransitionEnd_);
386
- window.removeEventListener('resize', this.refresh);
387
- if (this.mutationsObserver_) {
388
- this.mutationsObserver_.disconnect();
389
- }
390
- if (this.mutationEventsAdded_) {
391
- document.removeEventListener('DOMSubtreeModified', this.refresh);
392
- }
393
- this.mutationsObserver_ = null;
394
- this.mutationEventsAdded_ = false;
395
- this.connected_ = false;
396
- };
397
- /**
398
- * "Transitionend" event handler.
399
- *
400
- * @private
401
- * @param {TransitionEvent} event
402
- * @returns {void}
403
- */
404
- ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
405
- var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
406
- // Detect whether transition may affect dimensions of an element.
407
- var isReflowProperty = transitionKeys.some(function (key) {
408
- return !!~propertyName.indexOf(key);
409
- });
410
- if (isReflowProperty) {
411
- this.refresh();
412
- }
413
- };
414
- /**
415
- * Returns instance of the ResizeObserverController.
416
- *
417
- * @returns {ResizeObserverController}
418
- */
419
- ResizeObserverController.getInstance = function () {
420
- if (!this.instance_) {
421
- this.instance_ = new ResizeObserverController();
422
- }
423
- return this.instance_;
424
- };
425
- /**
426
- * Holds reference to the controller's instance.
427
- *
428
- * @private {ResizeObserverController}
429
- */
430
- ResizeObserverController.instance_ = null;
431
- return ResizeObserverController;
432
- }());
433
-
434
- /**
435
- * Defines non-writable/enumerable properties of the provided target object.
436
- *
437
- * @param {Object} target - Object for which to define properties.
438
- * @param {Object} props - Properties to be defined.
439
- * @returns {Object} Target object.
440
- */
441
- var defineConfigurable = (function (target, props) {
442
- for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
443
- var key = _a[_i];
444
- Object.defineProperty(target, key, {
445
- value: props[key],
446
- enumerable: false,
447
- writable: false,
448
- configurable: true
449
- });
450
- }
451
- return target;
452
- });
453
-
454
- /**
455
- * Returns the global object associated with provided element.
456
- *
457
- * @param {Object} target
458
- * @returns {Object}
459
- */
460
- var getWindowOf = (function (target) {
461
- // Assume that the element is an instance of Node, which means that it
462
- // has the "ownerDocument" property from which we can retrieve a
463
- // corresponding global object.
464
- var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
465
- // Return the local global object if it's not possible extract one from
466
- // provided element.
467
- return ownerGlobal || global$1;
468
- });
469
-
470
- // Placeholder of an empty content rectangle.
471
- var emptyRect = createRectInit(0, 0, 0, 0);
472
- /**
473
- * Converts provided string to a number.
474
- *
475
- * @param {number|string} value
476
- * @returns {number}
477
- */
478
- function toFloat(value) {
479
- return parseFloat(value) || 0;
480
- }
481
- /**
482
- * Extracts borders size from provided styles.
483
- *
484
- * @param {CSSStyleDeclaration} styles
485
- * @param {...string} positions - Borders positions (top, right, ...)
486
- * @returns {number}
487
- */
488
- function getBordersSize(styles) {
489
- var positions = [];
490
- for (var _i = 1; _i < arguments.length; _i++) {
491
- positions[_i - 1] = arguments[_i];
492
- }
493
- return positions.reduce(function (size, position) {
494
- var value = styles['border-' + position + '-width'];
495
- return size + toFloat(value);
496
- }, 0);
497
- }
498
- /**
499
- * Extracts paddings sizes from provided styles.
500
- *
501
- * @param {CSSStyleDeclaration} styles
502
- * @returns {Object} Paddings box.
503
- */
504
- function getPaddings(styles) {
505
- var positions = ['top', 'right', 'bottom', 'left'];
506
- var paddings = {};
507
- for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
508
- var position = positions_1[_i];
509
- var value = styles['padding-' + position];
510
- paddings[position] = toFloat(value);
511
- }
512
- return paddings;
513
- }
514
- /**
515
- * Calculates content rectangle of provided SVG element.
516
- *
517
- * @param {SVGGraphicsElement} target - Element content rectangle of which needs
518
- * to be calculated.
519
- * @returns {DOMRectInit}
520
- */
521
- function getSVGContentRect(target) {
522
- var bbox = target.getBBox();
523
- return createRectInit(0, 0, bbox.width, bbox.height);
524
- }
525
- /**
526
- * Calculates content rectangle of provided HTMLElement.
527
- *
528
- * @param {HTMLElement} target - Element for which to calculate the content rectangle.
529
- * @returns {DOMRectInit}
530
- */
531
- function getHTMLElementContentRect(target) {
532
- // Client width & height properties can't be
533
- // used exclusively as they provide rounded values.
534
- var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
535
- // By this condition we can catch all non-replaced inline, hidden and
536
- // detached elements. Though elements with width & height properties less
537
- // than 0.5 will be discarded as well.
538
- //
539
- // Without it we would need to implement separate methods for each of
540
- // those cases and it's not possible to perform a precise and performance
541
- // effective test for hidden elements. E.g. even jQuery's ':visible' filter
542
- // gives wrong results for elements with width & height less than 0.5.
543
- if (!clientWidth && !clientHeight) {
544
- return emptyRect;
545
- }
546
- var styles = getWindowOf(target).getComputedStyle(target);
547
- var paddings = getPaddings(styles);
548
- var horizPad = paddings.left + paddings.right;
549
- var vertPad = paddings.top + paddings.bottom;
550
- // Computed styles of width & height are being used because they are the
551
- // only dimensions available to JS that contain non-rounded values. It could
552
- // be possible to utilize the getBoundingClientRect if only it's data wasn't
553
- // affected by CSS transformations let alone paddings, borders and scroll bars.
554
- var width = toFloat(styles.width), height = toFloat(styles.height);
555
- // Width & height include paddings and borders when the 'border-box' box
556
- // model is applied (except for IE).
557
- if (styles.boxSizing === 'border-box') {
558
- // Following conditions are required to handle Internet Explorer which
559
- // doesn't include paddings and borders to computed CSS dimensions.
560
- //
561
- // We can say that if CSS dimensions + paddings are equal to the "client"
562
- // properties then it's either IE, and thus we don't need to subtract
563
- // anything, or an element merely doesn't have paddings/borders styles.
564
- if (Math.round(width + horizPad) !== clientWidth) {
565
- width -= getBordersSize(styles, 'left', 'right') + horizPad;
566
- }
567
- if (Math.round(height + vertPad) !== clientHeight) {
568
- height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
569
- }
570
- }
571
- // Following steps can't be applied to the document's root element as its
572
- // client[Width/Height] properties represent viewport area of the window.
573
- // Besides, it's as well not necessary as the <html> itself neither has
574
- // rendered scroll bars nor it can be clipped.
575
- if (!isDocumentElement(target)) {
576
- // In some browsers (only in Firefox, actually) CSS width & height
577
- // include scroll bars size which can be removed at this step as scroll
578
- // bars are the only difference between rounded dimensions + paddings
579
- // and "client" properties, though that is not always true in Chrome.
580
- var vertScrollbar = Math.round(width + horizPad) - clientWidth;
581
- var horizScrollbar = Math.round(height + vertPad) - clientHeight;
582
- // Chrome has a rather weird rounding of "client" properties.
583
- // E.g. for an element with content width of 314.2px it sometimes gives
584
- // the client width of 315px and for the width of 314.7px it may give
585
- // 314px. And it doesn't happen all the time. So just ignore this delta
586
- // as a non-relevant.
587
- if (Math.abs(vertScrollbar) !== 1) {
588
- width -= vertScrollbar;
589
- }
590
- if (Math.abs(horizScrollbar) !== 1) {
591
- height -= horizScrollbar;
592
- }
593
- }
594
- return createRectInit(paddings.left, paddings.top, width, height);
595
- }
596
- /**
597
- * Checks whether provided element is an instance of the SVGGraphicsElement.
598
- *
599
- * @param {Element} target - Element to be checked.
600
- * @returns {boolean}
601
- */
602
- var isSVGGraphicsElement = (function () {
603
- // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
604
- // interface.
605
- if (typeof SVGGraphicsElement !== 'undefined') {
606
- return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
607
- }
608
- // If it's so, then check that element is at least an instance of the
609
- // SVGElement and that it has the "getBBox" method.
610
- // eslint-disable-next-line no-extra-parens
611
- return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
612
- typeof target.getBBox === 'function'); };
613
- })();
614
- /**
615
- * Checks whether provided element is a document element (<html>).
616
- *
617
- * @param {Element} target - Element to be checked.
618
- * @returns {boolean}
619
- */
620
- function isDocumentElement(target) {
621
- return target === getWindowOf(target).document.documentElement;
622
- }
623
- /**
624
- * Calculates an appropriate content rectangle for provided html or svg element.
625
- *
626
- * @param {Element} target - Element content rectangle of which needs to be calculated.
627
- * @returns {DOMRectInit}
628
- */
629
- function getContentRect(target) {
630
- if (!isBrowser) {
631
- return emptyRect;
632
- }
633
- if (isSVGGraphicsElement(target)) {
634
- return getSVGContentRect(target);
635
- }
636
- return getHTMLElementContentRect(target);
637
- }
638
- /**
639
- * Creates rectangle with an interface of the DOMRectReadOnly.
640
- * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
641
- *
642
- * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
643
- * @returns {DOMRectReadOnly}
644
- */
645
- function createReadOnlyRect(_a) {
646
- var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
647
- // If DOMRectReadOnly is available use it as a prototype for the rectangle.
648
- var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
649
- var rect = Object.create(Constr.prototype);
650
- // Rectangle's properties are not writable and non-enumerable.
651
- defineConfigurable(rect, {
652
- x: x, y: y, width: width, height: height,
653
- top: y,
654
- right: x + width,
655
- bottom: height + y,
656
- left: x
657
- });
658
- return rect;
659
- }
660
- /**
661
- * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
662
- * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
663
- *
664
- * @param {number} x - X coordinate.
665
- * @param {number} y - Y coordinate.
666
- * @param {number} width - Rectangle's width.
667
- * @param {number} height - Rectangle's height.
668
- * @returns {DOMRectInit}
669
- */
670
- function createRectInit(x, y, width, height) {
671
- return { x: x, y: y, width: width, height: height };
672
- }
673
-
674
- /**
675
- * Class that is responsible for computations of the content rectangle of
676
- * provided DOM element and for keeping track of it's changes.
677
- */
678
- var ResizeObservation = /** @class */ (function () {
679
- /**
680
- * Creates an instance of ResizeObservation.
681
- *
682
- * @param {Element} target - Element to be observed.
683
- */
684
- function ResizeObservation(target) {
685
- /**
686
- * Broadcasted width of content rectangle.
687
- *
688
- * @type {number}
689
- */
690
- this.broadcastWidth = 0;
691
- /**
692
- * Broadcasted height of content rectangle.
693
- *
694
- * @type {number}
695
- */
696
- this.broadcastHeight = 0;
697
- /**
698
- * Reference to the last observed content rectangle.
699
- *
700
- * @private {DOMRectInit}
701
- */
702
- this.contentRect_ = createRectInit(0, 0, 0, 0);
703
- this.target = target;
704
- }
705
- /**
706
- * Updates content rectangle and tells whether it's width or height properties
707
- * have changed since the last broadcast.
708
- *
709
- * @returns {boolean}
710
- */
711
- ResizeObservation.prototype.isActive = function () {
712
- var rect = getContentRect(this.target);
713
- this.contentRect_ = rect;
714
- return (rect.width !== this.broadcastWidth ||
715
- rect.height !== this.broadcastHeight);
716
- };
717
- /**
718
- * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
719
- * from the corresponding properties of the last observed content rectangle.
720
- *
721
- * @returns {DOMRectInit} Last observed content rectangle.
722
- */
723
- ResizeObservation.prototype.broadcastRect = function () {
724
- var rect = this.contentRect_;
725
- this.broadcastWidth = rect.width;
726
- this.broadcastHeight = rect.height;
727
- return rect;
728
- };
729
- return ResizeObservation;
730
- }());
731
-
732
- var ResizeObserverEntry = /** @class */ (function () {
733
- /**
734
- * Creates an instance of ResizeObserverEntry.
735
- *
736
- * @param {Element} target - Element that is being observed.
737
- * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
738
- */
739
- function ResizeObserverEntry(target, rectInit) {
740
- var contentRect = createReadOnlyRect(rectInit);
741
- // According to the specification following properties are not writable
742
- // and are also not enumerable in the native implementation.
743
- //
744
- // Property accessors are not being used as they'd require to define a
745
- // private WeakMap storage which may cause memory leaks in browsers that
746
- // don't support this type of collections.
747
- defineConfigurable(this, { target: target, contentRect: contentRect });
748
- }
749
- return ResizeObserverEntry;
750
- }());
751
-
752
- var ResizeObserverSPI = /** @class */ (function () {
753
- /**
754
- * Creates a new instance of ResizeObserver.
755
- *
756
- * @param {ResizeObserverCallback} callback - Callback function that is invoked
757
- * when one of the observed elements changes it's content dimensions.
758
- * @param {ResizeObserverController} controller - Controller instance which
759
- * is responsible for the updates of observer.
760
- * @param {ResizeObserver} callbackCtx - Reference to the public
761
- * ResizeObserver instance which will be passed to callback function.
762
- */
763
- function ResizeObserverSPI(callback, controller, callbackCtx) {
764
- /**
765
- * Collection of resize observations that have detected changes in dimensions
766
- * of elements.
767
- *
768
- * @private {Array<ResizeObservation>}
769
- */
770
- this.activeObservations_ = [];
771
- /**
772
- * Registry of the ResizeObservation instances.
773
- *
774
- * @private {Map<Element, ResizeObservation>}
775
- */
776
- this.observations_ = new MapShim();
777
- if (typeof callback !== 'function') {
778
- throw new TypeError('The callback provided as parameter 1 is not a function.');
779
- }
780
- this.callback_ = callback;
781
- this.controller_ = controller;
782
- this.callbackCtx_ = callbackCtx;
783
- }
784
- /**
785
- * Starts observing provided element.
786
- *
787
- * @param {Element} target - Element to be observed.
788
- * @returns {void}
789
- */
790
- ResizeObserverSPI.prototype.observe = function (target) {
791
- if (!arguments.length) {
792
- throw new TypeError('1 argument required, but only 0 present.');
793
- }
794
- // Do nothing if current environment doesn't have the Element interface.
795
- if (typeof Element === 'undefined' || !(Element instanceof Object)) {
796
- return;
797
- }
798
- if (!(target instanceof getWindowOf(target).Element)) {
799
- throw new TypeError('parameter 1 is not of type "Element".');
800
- }
801
- var observations = this.observations_;
802
- // Do nothing if element is already being observed.
803
- if (observations.has(target)) {
804
- return;
805
- }
806
- observations.set(target, new ResizeObservation(target));
807
- this.controller_.addObserver(this);
808
- // Force the update of observations.
809
- this.controller_.refresh();
810
- };
811
- /**
812
- * Stops observing provided element.
813
- *
814
- * @param {Element} target - Element to stop observing.
815
- * @returns {void}
816
- */
817
- ResizeObserverSPI.prototype.unobserve = function (target) {
818
- if (!arguments.length) {
819
- throw new TypeError('1 argument required, but only 0 present.');
820
- }
821
- // Do nothing if current environment doesn't have the Element interface.
822
- if (typeof Element === 'undefined' || !(Element instanceof Object)) {
823
- return;
824
- }
825
- if (!(target instanceof getWindowOf(target).Element)) {
826
- throw new TypeError('parameter 1 is not of type "Element".');
827
- }
828
- var observations = this.observations_;
829
- // Do nothing if element is not being observed.
830
- if (!observations.has(target)) {
831
- return;
832
- }
833
- observations.delete(target);
834
- if (!observations.size) {
835
- this.controller_.removeObserver(this);
836
- }
837
- };
838
- /**
839
- * Stops observing all elements.
840
- *
841
- * @returns {void}
842
- */
843
- ResizeObserverSPI.prototype.disconnect = function () {
844
- this.clearActive();
845
- this.observations_.clear();
846
- this.controller_.removeObserver(this);
847
- };
848
- /**
849
- * Collects observation instances the associated element of which has changed
850
- * it's content rectangle.
851
- *
852
- * @returns {void}
853
- */
854
- ResizeObserverSPI.prototype.gatherActive = function () {
855
- var _this = this;
856
- this.clearActive();
857
- this.observations_.forEach(function (observation) {
858
- if (observation.isActive()) {
859
- _this.activeObservations_.push(observation);
860
- }
861
- });
862
- };
863
- /**
864
- * Invokes initial callback function with a list of ResizeObserverEntry
865
- * instances collected from active resize observations.
866
- *
867
- * @returns {void}
868
- */
869
- ResizeObserverSPI.prototype.broadcastActive = function () {
870
- // Do nothing if observer doesn't have active observations.
871
- if (!this.hasActive()) {
872
- return;
873
- }
874
- var ctx = this.callbackCtx_;
875
- // Create ResizeObserverEntry instance for every active observation.
876
- var entries = this.activeObservations_.map(function (observation) {
877
- return new ResizeObserverEntry(observation.target, observation.broadcastRect());
878
- });
879
- this.callback_.call(ctx, entries, ctx);
880
- this.clearActive();
881
- };
882
- /**
883
- * Clears the collection of active observations.
884
- *
885
- * @returns {void}
886
- */
887
- ResizeObserverSPI.prototype.clearActive = function () {
888
- this.activeObservations_.splice(0);
889
- };
890
- /**
891
- * Tells whether observer has active observations.
892
- *
893
- * @returns {boolean}
894
- */
895
- ResizeObserverSPI.prototype.hasActive = function () {
896
- return this.activeObservations_.length > 0;
897
- };
898
- return ResizeObserverSPI;
899
- }());
900
-
901
- // Registry of internal observers. If WeakMap is not available use current shim
902
- // for the Map collection as it has all required methods and because WeakMap
903
- // can't be fully polyfilled anyway.
904
- var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
905
- /**
906
- * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
907
- * exposing only those methods and properties that are defined in the spec.
908
- */
909
- var ResizeObserver$1 = /** @class */ (function () {
910
- /**
911
- * Creates a new instance of ResizeObserver.
912
- *
913
- * @param {ResizeObserverCallback} callback - Callback that is invoked when
914
- * dimensions of the observed elements change.
915
- */
916
- function ResizeObserver(callback) {
917
- if (!(this instanceof ResizeObserver)) {
918
- throw new TypeError('Cannot call a class as a function.');
919
- }
920
- if (!arguments.length) {
921
- throw new TypeError('1 argument required, but only 0 present.');
922
- }
923
- var controller = ResizeObserverController.getInstance();
924
- var observer = new ResizeObserverSPI(callback, controller, this);
925
- observers.set(this, observer);
926
- }
927
- return ResizeObserver;
928
- }());
929
- // Expose public methods of ResizeObserver.
930
- [
931
- 'observe',
932
- 'unobserve',
933
- 'disconnect'
934
- ].forEach(function (method) {
935
- ResizeObserver$1.prototype[method] = function () {
936
- var _a;
937
- return (_a = observers.get(this))[method].apply(_a, arguments);
938
- };
939
- });
940
-
941
- var index = (function () {
942
- // Export existing implementation if available.
943
- if (typeof global$1.ResizeObserver !== 'undefined') {
944
- return global$1.ResizeObserver;
945
- }
946
- return ResizeObserver$1;
947
- })();
948
-
949
- var ResizeObserver_es = /*#__PURE__*/Object.freeze({
950
- __proto__: null,
951
- default: index
952
- });
953
-
954
- var require$$0 = /*@__PURE__*/getAugmentedNamespace(ResizeObserver_es);
955
-
956
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
957
-
958
- var ResizeObserver = _interopDefault(require$$0);
959
- var react = React__default;
960
-
961
- function useResizeObserver$1(opts) {
962
- if (opts === void 0) {
963
- opts = {};
964
- }
965
-
966
- // `defaultRef` Has to be non-conditionally declared here whether or not it'll
967
- // be used as that's how hooks work.
968
- // @see https://reactjs.org/docs/hooks-rules.html#explanation
969
- var defaultRef = react.useRef(null); // Saving the callback as a ref. With this, I don't need to put onResize in the
970
- // effect dep array, and just passing in an anonymous function without memoising
971
- // will not reinstantiate the hook's ResizeObserver
972
-
973
- var onResize = opts.onResize;
974
- var onResizeRef = react.useRef(undefined);
975
- onResizeRef.current = onResize; // Using a single instance throughought the hook's lifetime
976
-
977
- var resizeObserverRef = react.useRef();
978
- var ref = opts.ref || defaultRef;
979
-
980
- var _useState = react.useState({
981
- width: undefined,
982
- height: undefined
983
- }),
984
- size = _useState[0],
985
- setSize = _useState[1]; // Using a ref to track the previous width / height to avoid unnecessary renders
986
-
987
-
988
- var previous = react.useRef({
989
- width: undefined,
990
- height: undefined
991
- });
992
- react.useEffect(function () {
993
- if (resizeObserverRef.current) {
994
- return;
995
- }
996
-
997
- resizeObserverRef.current = new ResizeObserver(function (entries) {
998
- if (!Array.isArray(entries)) {
999
- return;
1000
- } // Since we only observe the one element, we don't need to loop over the
1001
- // array
1002
-
1003
-
1004
- if (!entries.length) {
1005
- return;
1006
- }
1007
-
1008
- var entry = entries[0]; // `Math.round` is in line with how CSS resolves sub-pixel values
1009
-
1010
- var newWidth = Math.round(entry.contentRect.width);
1011
- var newHeight = Math.round(entry.contentRect.height);
1012
-
1013
- if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
1014
- var newSize = {
1015
- width: newWidth,
1016
- height: newHeight
1017
- };
1018
-
1019
- if (onResizeRef.current) {
1020
- onResizeRef.current(newSize);
1021
- } else {
1022
- previous.current.width = newWidth;
1023
- previous.current.height = newHeight;
1024
- setSize(newSize);
1025
- }
1026
- }
1027
- });
1028
- }, []);
1029
- react.useEffect(function () {
1030
- if (typeof ref !== "object" || ref === null || !(ref.current instanceof Element)) {
1031
- return;
1032
- }
1033
-
1034
- var element = ref.current;
1035
- resizeObserverRef.current.observe(element);
1036
- return function () {
1037
- return resizeObserverRef.current.unobserve(element);
1038
- };
1039
- }, [ref]);
1040
- return react.useMemo(function () {
1041
- return {
1042
- ref: ref,
1043
- width: size.width,
1044
- height: size.height
1045
- };
1046
- }, [ref, size ? size.width : null, size ? size.height : null]);
1047
- }
1048
-
1049
- var polyfilled = useResizeObserver$1;
1050
-
1051
- (function (exports) {
1052
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1053
- return (mod && mod.__esModule) ? mod : { "default": mod };
1054
- };
1055
- Object.defineProperty(exports, "__esModule", { value: true });
1056
- exports.Breakpoints = void 0;
1057
- exports.useResizeObserver = useResizeObserver;
1058
- const react_1 = React__default;
1059
- // Importing the polyfilled version of ResizeObserver
1060
- // eslint-disable-next-line import/no-internal-modules
1061
- const polyfilled_1 = __importDefault(polyfilled);
1062
- const throttle_1$1 = __importDefault(throttle_1);
1063
- exports.Breakpoints = {
1064
- base: 640,
1065
- small: 500,
1066
- smaller: 265,
1067
- large: 750,
1068
- larger: 1024,
1069
- };
1070
- const wait = 100;
1071
- function useResizeObserver({ widths = exports.Breakpoints, heights = exports.Breakpoints, } = {}) {
1072
- const [exactSize, setSize] = (0, react_1.useState)({
1073
- width: undefined,
1074
- height: undefined,
1075
- });
1076
- const onResize = (0, react_1.useMemo)(() => {
1077
- return (0, throttle_1$1.default)(({ width, height }) => {
1078
- if (!width || width <= 1) {
1079
- // Ignore invalid values. ResizeObserver is unexpectedly looping between 1 and the actual
1080
- // width of the element. This is only happening in playwright chromium.
1081
- // Soon we need to replace this unmaintained package with a more reliable one.
1082
- return;
1083
- }
1084
- setSize({ width, height });
1085
- }, wait);
1086
- }, []);
1087
- const { ref } = (0, polyfilled_1.default)({
1088
- onResize,
1089
- });
1090
- const exactWidth = exactSize.width;
1091
- const exactHeight = exactSize.height;
1092
- const sizes = {
1093
- width: getSize(widths, exactSize.width),
1094
- height: getSize(heights, exactSize.height),
1095
- exactWidth,
1096
- exactHeight,
1097
- };
1098
- return [ref, sizes];
1099
- }
1100
- /**
1101
- * To get the proper size we want to make sure that our value is greater
1102
- * then the comparable, but less then the next largest number in our
1103
- * object.
1104
- */
1105
- function getSize(sizes, comparable) {
1106
- if (!comparable || !sizes) {
1107
- return undefined;
1108
- }
1109
- /**
1110
- * Sort the values of our object so that we know they are in proper
1111
- * order to be compared by
1112
- */
1113
- const sortedSizes = Object.values(sizes)
1114
- .sort((a, b) => a - b)
1115
- .reverse();
1116
- return (sortedSizes.find(value => value <= comparable) ||
1117
- sortedSizes[sortedSizes.length - 1]);
1118
- }
1119
- } (useResizeObserver$2));
1120
-
1121
- var useResizeObserver = /*@__PURE__*/getDefaultExportFromCjs(useResizeObserver$2);
1122
-
1123
- var jobberHooks = /*#__PURE__*/_mergeNamespaces({
1124
- __proto__: null,
1125
- default: useResizeObserver
1126
- }, [useResizeObserver$2]);
1127
-
1128
- export { jobberHooks as j, useResizeObserver$2 as u };