@panneau/core 1.0.3-alpha.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/hooks.js CHANGED
@@ -4,7 +4,7 @@ import { useIntl } from 'react-intl';
4
4
  import isString from 'lodash/isString';
5
5
  import dayjs from 'dayjs';
6
6
  import { EventsManager, MediasParser } from '@panneau/core';
7
- import { createUseEvent } from '@panneau/core/utils';
7
+ import { createUseEvent, loadPackage } from '@panneau/core/utils';
8
8
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
9
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
10
10
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
@@ -18,27 +18,22 @@ import { match } from 'css-mediaquery';
18
18
 
19
19
  var useAnimationFrame = function useAnimationFrame(onFrame) {
20
20
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
21
- _ref$disabled = _ref.disabled,
22
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
23
-
21
+ _ref$disabled = _ref.disabled,
22
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
24
23
  var requestRef = useRef(null);
25
24
  var startTimeRef = useRef(null);
26
-
27
25
  var callback = function callback(time) {
28
26
  if (!startTimeRef.current) {
29
27
  startTimeRef.current = time;
30
28
  }
31
-
32
29
  var progress = time - startTimeRef.current;
33
30
  onFrame(progress);
34
31
  requestRef.current = requestAnimationFrame(callback);
35
32
  };
36
-
37
33
  useEffect(function () {
38
34
  if (!disabled) {
39
35
  requestRef.current = requestAnimationFrame(callback);
40
36
  }
41
-
42
37
  return function () {
43
38
  if (requestRef.current !== null) {
44
39
  cancelAnimationFrame(requestRef.current);
@@ -49,16 +44,14 @@ var useAnimationFrame = function useAnimationFrame(onFrame) {
49
44
 
50
45
  var useFormattedDate = function useFormattedDate() {
51
46
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
52
- _ref$format = _ref.format,
53
- format = _ref$format === void 0 ? null : _ref$format,
54
- _ref$showToday = _ref.showToday,
55
- showToday = _ref$showToday === void 0 ? true : _ref$showToday;
56
-
47
+ _ref$format = _ref.format,
48
+ format = _ref$format === void 0 ? null : _ref$format,
49
+ _ref$showToday = _ref.showToday,
50
+ showToday = _ref$showToday === void 0 ? true : _ref$showToday;
57
51
  var intl = useIntl();
58
52
  var today = dayjs();
59
53
  return useCallback(function (date) {
60
54
  var dateToFormat = isString(date) ? dayjs(date) : date;
61
-
62
55
  if (showToday && dateToFormat.format('YYYY-MM-DD') === today.format('YYYY-MM-DD')) {
63
56
  return intl.formatMessage({
64
57
  "id": "v4Qtl9",
@@ -68,7 +61,6 @@ var useFormattedDate = function useFormattedDate() {
68
61
  }]
69
62
  });
70
63
  }
71
-
72
64
  return intl.formatDate(dayjs(date).toDate(), _objectSpread({
73
65
  year: 'numeric',
74
66
  month: 'long',
@@ -78,18 +70,16 @@ var useFormattedDate = function useFormattedDate() {
78
70
  };
79
71
  var useFormattedTime = function useFormattedTime() {
80
72
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
81
- _ref2$format = _ref2.format,
82
- format = _ref2$format === void 0 ? null : _ref2$format,
83
- _ref2$showNow = _ref2.showNow,
84
- showNow = _ref2$showNow === void 0 ? true : _ref2$showNow,
85
- _ref2$timeGap = _ref2.timeGap,
86
- timeGap = _ref2$timeGap === void 0 ? 2 : _ref2$timeGap;
87
-
73
+ _ref2$format = _ref2.format,
74
+ format = _ref2$format === void 0 ? null : _ref2$format,
75
+ _ref2$showNow = _ref2.showNow,
76
+ showNow = _ref2$showNow === void 0 ? true : _ref2$showNow,
77
+ _ref2$timeGap = _ref2.timeGap,
78
+ timeGap = _ref2$timeGap === void 0 ? 2 : _ref2$timeGap;
88
79
  var intl = useIntl();
89
80
  var now = dayjs();
90
81
  return useCallback(function (date) {
91
82
  var dateToFormat = isString(date) ? dayjs(date) : date;
92
-
93
83
  if (showNow && dateToFormat.format('YYYY-MM-DD') === now.format('YYYY-MM-DD') && dateToFormat.hour() === now.hour() && dateToFormat.minute() > now.minute() - timeGap && dateToFormat.minute() < now.minute() + timeGap) {
94
84
  return intl.formatMessage({
95
85
  "id": "3na7F8",
@@ -99,7 +89,6 @@ var useFormattedTime = function useFormattedTime() {
99
89
  }]
100
90
  });
101
91
  }
102
-
103
92
  return intl.formatTime(dateToFormat.toDate(), _objectSpread({
104
93
  hour: 'numeric',
105
94
  minute: 'numeric'
@@ -112,20 +101,19 @@ var useDocumentEvent = createUseEvent(eventsManager$1);
112
101
 
113
102
  var _excluded$1 = ["value", "errors", "onChange"];
114
103
 
104
+ // prettier-ignore
115
105
  var getFieldsPropsFromFields = function getFieldsPropsFromFields(fields, _ref) {
116
106
  var value = _ref.value,
117
- errors = _ref.errors,
118
- _onChange = _ref.onChange,
119
- props = _objectWithoutProperties(_ref, _excluded$1);
120
-
107
+ errors = _ref.errors,
108
+ _onChange = _ref.onChange,
109
+ props = _objectWithoutProperties(_ref, _excluded$1);
121
110
  var locales = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
122
111
  return fields.reduce(function (allFields, field) {
123
112
  var _ref2 = isObject(field) ? field : {},
124
- _ref2$name = _ref2.name,
125
- name = _ref2$name === void 0 ? isString(field) ? field : null : _ref2$name,
126
- _ref2$component = _ref2.component,
127
- component = _ref2$component === void 0 ? null : _ref2$component;
128
-
113
+ _ref2$name = _ref2.name,
114
+ name = _ref2$name === void 0 ? isString(field) ? field : null : _ref2$name,
115
+ _ref2$component = _ref2.component,
116
+ component = _ref2$component === void 0 ? null : _ref2$component;
129
117
  var fieldErrors = errors !== null ? errors[name] || [] : [];
130
118
  var localizedErrors = component === 'localized' ? (locales || []).reduce(function (previousErrors, locale) {
131
119
  var items = errors !== null ? get(errors, "".concat(name, ".").concat(locale), []) || [] : [];
@@ -144,67 +132,60 @@ var getFieldsPropsFromFields = function getFieldsPropsFromFields(fields, _ref) {
144
132
  }, props)]);
145
133
  }, []);
146
134
  };
147
-
148
135
  var useForm = function useForm() {
149
136
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
150
137
  var _opts$fields = opts.fields,
151
- fields = _opts$fields === void 0 ? [] : _opts$fields,
152
- _opts$action = opts.action,
153
- action = _opts$action === void 0 ? null : _opts$action,
154
- _opts$postForm = opts.postForm,
155
- postForm = _opts$postForm === void 0 ? null : _opts$postForm,
156
- _opts$initialErrors = opts.initialErrors,
157
- initialErrors = _opts$initialErrors === void 0 ? null : _opts$initialErrors,
158
- _opts$errors = opts.errors,
159
- providedErrors = _opts$errors === void 0 ? null : _opts$errors,
160
- _opts$setErrors = opts.setErrors,
161
- setProvidedErrors = _opts$setErrors === void 0 ? null : _opts$setErrors,
162
- _opts$initialGeneralE = opts.initialGeneralError,
163
- initialGeneralError = _opts$initialGeneralE === void 0 ? null : _opts$initialGeneralE,
164
- _opts$generalError = opts.generalError,
165
- providedGeneralError = _opts$generalError === void 0 ? null : _opts$generalError,
166
- _opts$setGeneralError = opts.setGeneralError,
167
- setProvidedGeneralError = _opts$setGeneralError === void 0 ? null : _opts$setGeneralError,
168
- _opts$initialValue = opts.initialValue,
169
- initialValue = _opts$initialValue === void 0 ? null : _opts$initialValue,
170
- _opts$value = opts.value,
171
- providedValue = _opts$value === void 0 ? null : _opts$value,
172
- _opts$setValue = opts.setValue,
173
- setProvidedValue = _opts$setValue === void 0 ? null : _opts$setValue,
174
- _opts$onComplete = opts.onComplete,
175
- onComplete = _opts$onComplete === void 0 ? null : _opts$onComplete,
176
- _opts$locales = opts.locales,
177
- locales = _opts$locales === void 0 ? [] : _opts$locales;
178
-
138
+ fields = _opts$fields === void 0 ? [] : _opts$fields,
139
+ _opts$action = opts.action,
140
+ action = _opts$action === void 0 ? null : _opts$action,
141
+ _opts$postForm = opts.postForm,
142
+ postForm = _opts$postForm === void 0 ? null : _opts$postForm,
143
+ _opts$initialErrors = opts.initialErrors,
144
+ initialErrors = _opts$initialErrors === void 0 ? null : _opts$initialErrors,
145
+ _opts$errors = opts.errors,
146
+ providedErrors = _opts$errors === void 0 ? null : _opts$errors,
147
+ _opts$setErrors = opts.setErrors,
148
+ setProvidedErrors = _opts$setErrors === void 0 ? null : _opts$setErrors,
149
+ _opts$initialGeneralE = opts.initialGeneralError,
150
+ initialGeneralError = _opts$initialGeneralE === void 0 ? null : _opts$initialGeneralE,
151
+ _opts$generalError = opts.generalError,
152
+ providedGeneralError = _opts$generalError === void 0 ? null : _opts$generalError,
153
+ _opts$setGeneralError = opts.setGeneralError,
154
+ setProvidedGeneralError = _opts$setGeneralError === void 0 ? null : _opts$setGeneralError,
155
+ _opts$initialValue = opts.initialValue,
156
+ initialValue = _opts$initialValue === void 0 ? null : _opts$initialValue,
157
+ _opts$value = opts.value,
158
+ providedValue = _opts$value === void 0 ? null : _opts$value,
159
+ _opts$setValue = opts.setValue,
160
+ setProvidedValue = _opts$setValue === void 0 ? null : _opts$setValue,
161
+ _opts$onComplete = opts.onComplete,
162
+ onComplete = _opts$onComplete === void 0 ? null : _opts$onComplete,
163
+ _opts$locales = opts.locales,
164
+ locales = _opts$locales === void 0 ? [] : _opts$locales;
179
165
  var _useState = useState(initialValue || providedValue),
180
- _useState2 = _slicedToArray(_useState, 2),
181
- stateValue = _useState2[0],
182
- setStateValue = _useState2[1];
183
-
166
+ _useState2 = _slicedToArray(_useState, 2),
167
+ stateValue = _useState2[0],
168
+ setStateValue = _useState2[1];
184
169
  var _useState3 = useState(initialErrors || providedErrors),
185
- _useState4 = _slicedToArray(_useState3, 2),
186
- stateErrors = _useState4[0],
187
- setStateErrors = _useState4[1];
188
-
170
+ _useState4 = _slicedToArray(_useState3, 2),
171
+ stateErrors = _useState4[0],
172
+ setStateErrors = _useState4[1];
189
173
  var _useState5 = useState(initialGeneralError || providedGeneralError),
190
- _useState6 = _slicedToArray(_useState5, 2),
191
- stateGeneralError = _useState6[0],
192
- setStateGeneralError = _useState6[1];
193
-
174
+ _useState6 = _slicedToArray(_useState5, 2),
175
+ stateGeneralError = _useState6[0],
176
+ setStateGeneralError = _useState6[1];
194
177
  var _useState7 = useState({
195
- success: false,
196
- loading: false,
197
- error: false
198
- }),
199
- _useState8 = _slicedToArray(_useState7, 2),
200
- requestState = _useState8[0],
201
- setRequestState = _useState8[1];
202
-
178
+ success: false,
179
+ loading: false,
180
+ error: false
181
+ }),
182
+ _useState8 = _slicedToArray(_useState7, 2),
183
+ requestState = _useState8[0],
184
+ setRequestState = _useState8[1];
203
185
  var _useState9 = useState(null),
204
- _useState10 = _slicedToArray(_useState9, 2),
205
- response = _useState10[0],
206
- setResponse = _useState10[1];
207
-
186
+ _useState10 = _slicedToArray(_useState9, 2),
187
+ response = _useState10[0],
188
+ setResponse = _useState10[1];
208
189
  var hasProvidedValue = setProvidedValue !== null;
209
190
  var value = hasProvidedValue ? providedValue : stateValue;
210
191
  var setValue = hasProvidedValue ? setProvidedValue : setStateValue;
@@ -217,11 +198,9 @@ var useForm = function useForm() {
217
198
  var fieldsKey = [value, errors, locales].concat(fields);
218
199
  var onFieldChange = useCallback(function (fieldName, fieldValue) {
219
200
  var fieldErrors = errors !== null ? errors[fieldName] || null : null;
220
-
221
201
  if (fieldErrors !== null) {
222
202
  setErrors(_objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, fieldName, null)));
223
203
  }
224
-
225
204
  setValue(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, fieldName, fieldValue)));
226
205
  }, fieldsKey);
227
206
  var fieldsProps = useMemo(function () {
@@ -234,25 +213,21 @@ var useForm = function useForm() {
234
213
  var csrfToken = useMemo(function () {
235
214
  return getCsrfToken();
236
215
  }, []);
237
-
238
216
  var onSubmitError = function onSubmitError(error) {
239
217
  setRequestState({
240
218
  success: false,
241
219
  loading: false,
242
220
  error: true
243
221
  });
244
-
245
222
  if (error.name === 'ValidationError') {
246
223
  var _error$getResponseDat = error.getResponseData(),
247
- _error$getResponseDat2 = _error$getResponseDat.errors,
248
- validationErrors = _error$getResponseDat2 === void 0 ? null : _error$getResponseDat2;
249
-
224
+ _error$getResponseDat2 = _error$getResponseDat.errors,
225
+ validationErrors = _error$getResponseDat2 === void 0 ? null : _error$getResponseDat2;
250
226
  setErrors(validationErrors);
251
227
  } else {
252
228
  setGeneralError(error.message);
253
229
  }
254
230
  };
255
-
256
231
  var onSubmitSuccess = function onSubmitSuccess(resp) {
257
232
  setRequestState({
258
233
  success: true,
@@ -260,12 +235,10 @@ var useForm = function useForm() {
260
235
  error: false
261
236
  });
262
237
  setResponse(resp);
263
-
264
238
  if (onComplete !== null) {
265
239
  onComplete(resp);
266
240
  }
267
241
  };
268
-
269
242
  var finalPostForm = useCallback(function (postAction, postData) {
270
243
  return postForm !== null ? postForm(postAction, postData) : postJSON(postAction, postData, {
271
244
  credentials: 'include',
@@ -290,7 +263,6 @@ var useForm = function useForm() {
290
263
  submit();
291
264
  }, [submit]);
292
265
  var status = null;
293
-
294
266
  if (requestState.loading) {
295
267
  status = 'loading';
296
268
  } else if (requestState.success) {
@@ -298,7 +270,6 @@ var useForm = function useForm() {
298
270
  } else if (requestState.error) {
299
271
  status = 'error';
300
272
  }
301
-
302
273
  return _objectSpread(_objectSpread({
303
274
  value: value,
304
275
  setValue: setValue,
@@ -317,27 +288,22 @@ var useForm = function useForm() {
317
288
  var buildThresholdArray = function buildThresholdArray() {
318
289
  return [0, 1.0];
319
290
  };
320
-
321
291
  var observersCache = new Map();
322
-
323
292
  var getOptionsKey = function getOptionsKey(_ref) {
324
293
  var _ref$root = _ref.root,
325
- root = _ref$root === void 0 ? null : _ref$root,
326
- rootMargin = _ref.rootMargin,
327
- _ref$threshold = _ref.threshold,
328
- threshold = _ref$threshold === void 0 ? null : _ref$threshold;
294
+ root = _ref$root === void 0 ? null : _ref$root,
295
+ rootMargin = _ref.rootMargin,
296
+ _ref$threshold = _ref.threshold,
297
+ threshold = _ref$threshold === void 0 ? null : _ref$threshold;
329
298
  return "root_".concat(root, "_rootMargin_").concat(rootMargin || null, "_threshold_").concat(threshold);
330
299
  };
331
-
332
300
  var createObserver = function createObserver(Observer) {
333
301
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
334
302
  var subscribers = [];
335
-
336
303
  var addSubscriber = function addSubscriber(element, callback) {
337
304
  var currentSubscriber = subscribers.find(function (it) {
338
305
  return it.element === element;
339
306
  }) || null;
340
-
341
307
  if (currentSubscriber !== null) {
342
308
  return subscribers.map(function (it) {
343
309
  return it.element === element && it.callbacks.indexOf(callback) === -1 ? _objectSpread(_objectSpread({}, it), {}, {
@@ -347,13 +313,11 @@ var createObserver = function createObserver(Observer) {
347
313
  return it.callbacks.length > 0;
348
314
  });
349
315
  }
350
-
351
316
  return [].concat(_toConsumableArray(subscribers), [{
352
317
  element: element,
353
318
  callbacks: [callback]
354
319
  }]);
355
320
  };
356
-
357
321
  var removeSubscriber = function removeSubscriber(element, callback) {
358
322
  return subscribers.map(function (it) {
359
323
  return it.element === element ? _objectSpread(_objectSpread({}, it), {}, {
@@ -365,13 +329,11 @@ var createObserver = function createObserver(Observer) {
365
329
  return it.callbacks.length > 0;
366
330
  });
367
331
  };
368
-
369
332
  var onUpdate = function onUpdate(entries) {
370
333
  entries.forEach(function (entry) {
371
334
  subscribers.forEach(function (_ref2) {
372
335
  var element = _ref2.element,
373
- callbacks = _ref2.callbacks;
374
-
336
+ callbacks = _ref2.callbacks;
375
337
  if (element === entry.target) {
376
338
  callbacks.forEach(function (callback) {
377
339
  callback(entry);
@@ -380,13 +342,10 @@ var createObserver = function createObserver(Observer) {
380
342
  });
381
343
  });
382
344
  };
383
-
384
345
  var observer = new Observer(onUpdate, options);
385
-
386
346
  var unsubscribe = function unsubscribe(element) {
387
347
  var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
388
348
  subscribers = removeSubscriber(element, callback);
389
-
390
349
  if (typeof observer.unobserve === 'undefined') {
391
350
  observer.disconnect();
392
351
  subscribers.forEach(function (subscriber) {
@@ -394,103 +353,82 @@ var createObserver = function createObserver(Observer) {
394
353
  });
395
354
  return;
396
355
  }
397
-
398
356
  var currentSubscriber = subscribers.find(function (it) {
399
357
  return it.element === element;
400
358
  }) || null;
401
-
402
359
  if (currentSubscriber === null) {
403
360
  observer.unobserve(element);
404
361
  }
405
362
  };
406
-
407
363
  var subscribe = function subscribe(element, callback) {
408
364
  var currentSubscriber = subscribers.find(function (it) {
409
365
  return it.element === element;
410
366
  }) || null;
411
367
  subscribers = addSubscriber(element, callback);
412
-
413
368
  if (currentSubscriber === null) {
414
369
  observer.observe(element);
415
370
  }
416
371
  };
417
-
418
372
  return {
419
373
  subscribe: subscribe,
420
374
  unsubscribe: unsubscribe,
421
375
  observer: observer
422
376
  };
423
377
  };
424
-
425
378
  var getObserver = function getObserver(Observer) {
426
379
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
427
380
  var observerKey = getOptionsKey(options);
428
-
429
381
  if (!observersCache.has(Observer)) {
430
382
  observersCache.set(Observer, {});
431
383
  }
432
-
433
384
  var observers = observersCache.get(Observer);
434
-
435
385
  if (typeof observers[observerKey] === 'undefined') {
436
386
  observers[observerKey] = createObserver(Observer, options);
437
387
  observersCache.set(Observer, observers);
438
388
  }
439
-
440
389
  return observers[observerKey];
441
390
  };
442
391
  var useObserver = function useObserver(Observer) {
443
392
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
444
393
  var initialEntry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
445
394
  var _opts$root = opts.root,
446
- root = _opts$root === void 0 ? null : _opts$root,
447
- _opts$rootMargin = opts.rootMargin,
448
- rootMargin = _opts$rootMargin === void 0 ? null : _opts$rootMargin,
449
- _opts$threshold = opts.threshold,
450
- threshold = _opts$threshold === void 0 ? null : _opts$threshold,
451
- _opts$disabled = opts.disabled,
452
- disabled = _opts$disabled === void 0 ? false : _opts$disabled;
453
-
395
+ root = _opts$root === void 0 ? null : _opts$root,
396
+ _opts$rootMargin = opts.rootMargin,
397
+ rootMargin = _opts$rootMargin === void 0 ? null : _opts$rootMargin,
398
+ _opts$threshold = opts.threshold,
399
+ threshold = _opts$threshold === void 0 ? null : _opts$threshold,
400
+ _opts$disabled = opts.disabled,
401
+ disabled = _opts$disabled === void 0 ? false : _opts$disabled;
454
402
  var _useState = useState(initialEntry),
455
- _useState2 = _slicedToArray(_useState, 2),
456
- entry = _useState2[0],
457
- setEntry = _useState2[1];
458
-
403
+ _useState2 = _slicedToArray(_useState, 2),
404
+ entry = _useState2[0],
405
+ setEntry = _useState2[1];
459
406
  var nodeRef = useRef(null);
460
407
  var currentElement = useRef(null);
461
408
  var elementChanged = nodeRef.current !== currentElement.current;
462
409
  useEffect(function () {
463
410
  var nodeElement = nodeRef.current;
464
-
465
411
  var callback = function callback(newEntry) {
466
412
  return setEntry(newEntry);
467
413
  };
468
-
469
414
  var unsubscribe = null;
470
-
471
415
  if (nodeElement !== null) {
472
416
  var newOpts = {};
473
-
474
417
  if (root !== null) {
475
418
  newOpts.root = root;
476
419
  }
477
-
478
420
  if (rootMargin !== null) {
479
421
  newOpts.rootMargin = rootMargin;
480
422
  }
481
-
482
423
  if (threshold !== null) {
483
424
  newOpts.threshold = threshold;
484
425
  }
485
-
486
426
  var _getObserver = getObserver(Observer, newOpts),
487
- subscribe = _getObserver.subscribe,
488
- localUnsubscribe = _getObserver.unsubscribe;
489
-
427
+ subscribe = _getObserver.subscribe,
428
+ localUnsubscribe = _getObserver.unsubscribe;
490
429
  unsubscribe = localUnsubscribe;
491
430
  subscribe(nodeElement, callback);
492
431
  }
493
-
494
432
  currentElement.current = nodeElement;
495
433
  return function () {
496
434
  if (unsubscribe !== null) {
@@ -503,10 +441,10 @@ var useObserver = function useObserver(Observer) {
503
441
  entry: entry
504
442
  };
505
443
  };
444
+
506
445
  /**
507
446
  * Intersection Observer
508
447
  */
509
-
510
448
  var thresholdArray = buildThresholdArray();
511
449
  var intersectionObserverInitialEntry = {
512
450
  target: null,
@@ -520,15 +458,14 @@ var intersectionObserverInitialEntry = {
520
458
  };
521
459
  var useIntersectionObserver = function useIntersectionObserver() {
522
460
  var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
523
- _ref3$root = _ref3.root,
524
- root = _ref3$root === void 0 ? null : _ref3$root,
525
- _ref3$rootMargin = _ref3.rootMargin,
526
- rootMargin = _ref3$rootMargin === void 0 ? '0px' : _ref3$rootMargin,
527
- _ref3$threshold = _ref3.threshold,
528
- threshold = _ref3$threshold === void 0 ? thresholdArray : _ref3$threshold,
529
- _ref3$disabled = _ref3.disabled,
530
- disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
531
-
461
+ _ref3$root = _ref3.root,
462
+ root = _ref3$root === void 0 ? null : _ref3$root,
463
+ _ref3$rootMargin = _ref3.rootMargin,
464
+ rootMargin = _ref3$rootMargin === void 0 ? '0px' : _ref3$rootMargin,
465
+ _ref3$threshold = _ref3.threshold,
466
+ threshold = _ref3$threshold === void 0 ? thresholdArray : _ref3$threshold,
467
+ _ref3$disabled = _ref3.disabled,
468
+ disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
532
469
  return useObserver(typeof window !== 'undefined' ? IntersectionObserver : null, {
533
470
  root: root,
534
471
  rootMargin: rootMargin,
@@ -536,10 +473,10 @@ var useIntersectionObserver = function useIntersectionObserver() {
536
473
  disabled: disabled
537
474
  }, intersectionObserverInitialEntry);
538
475
  };
476
+
539
477
  /**
540
478
  * Resize Observer
541
479
  */
542
-
543
480
  var resizeObserverInitialEntry = {
544
481
  target: null,
545
482
  contentRect: null,
@@ -548,9 +485,8 @@ var resizeObserverInitialEntry = {
548
485
  };
549
486
  var useResizeObserver = function useResizeObserver() {
550
487
  var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
551
- _ref4$disabled = _ref4.disabled,
552
- disabled = _ref4$disabled === void 0 ? false : _ref4$disabled;
553
-
488
+ _ref4$disabled = _ref4.disabled,
489
+ disabled = _ref4$disabled === void 0 ? false : _ref4$disabled;
554
490
  return useObserver(typeof window !== 'undefined' ? ResizeObserver : null, {
555
491
  disabled: disabled
556
492
  }, resizeObserverInitialEntry);
@@ -558,25 +494,21 @@ var useResizeObserver = function useResizeObserver() {
558
494
 
559
495
  var useIsVisible = function useIsVisible() {
560
496
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
561
- rootMargin = _ref.rootMargin,
562
- _ref$threshold = _ref.threshold,
563
- threshold = _ref$threshold === void 0 ? 1 : _ref$threshold,
564
- _ref$persist = _ref.persist,
565
- persist = _ref$persist === void 0 ? false : _ref$persist;
566
-
497
+ rootMargin = _ref.rootMargin,
498
+ _ref$threshold = _ref.threshold,
499
+ threshold = _ref$threshold === void 0 ? 1 : _ref$threshold,
500
+ _ref$persist = _ref.persist,
501
+ persist = _ref$persist === void 0 ? false : _ref$persist;
567
502
  var _useIntersectionObser = useIntersectionObserver({
568
- rootMargin: rootMargin,
569
- threshold: threshold
570
- }),
571
- ref = _useIntersectionObser.ref,
572
- isIntersecting = _useIntersectionObser.entry.isIntersecting;
573
-
503
+ rootMargin: rootMargin,
504
+ threshold: threshold
505
+ }),
506
+ ref = _useIntersectionObser.ref,
507
+ isIntersecting = _useIntersectionObser.entry.isIntersecting;
574
508
  var wasIntersecting = useRef(isIntersecting);
575
-
576
509
  if (isIntersecting && !wasIntersecting.current) {
577
510
  wasIntersecting.current = isIntersecting;
578
511
  }
579
-
580
512
  var isVisible = !persist && isIntersecting || persist && wasIntersecting.current;
581
513
  return {
582
514
  ref: ref,
@@ -588,62 +520,54 @@ var fontsMap = {
588
520
  loading: [],
589
521
  active: []
590
522
  };
591
-
592
523
  var isFontLoading = function isFontLoading(name) {
593
524
  return fontsMap.loading.indexOf(name) !== -1;
594
525
  };
595
-
596
526
  var isFontActive = function isFontActive(name) {
597
527
  return fontsMap.active.indexOf(name) !== -1;
598
528
  };
599
-
600
529
  var addFontLoading = function addFontLoading(name) {
601
530
  fontsMap.active = fontsMap.active.filter(function (it) {
602
531
  return it !== name;
603
532
  });
604
533
  fontsMap.loading = [].concat(_toConsumableArray(fontsMap.loading), [name]);
605
534
  };
606
-
607
535
  var removeFontLoading = function removeFontLoading(name) {
608
536
  fontsMap.loading = fontsMap.loading.filter(function (it) {
609
537
  return it !== name;
610
538
  });
611
539
  };
612
-
613
540
  var addFontActive = function addFontActive(name) {
614
541
  fontsMap.loading = fontsMap.loading.filter(function (it) {
615
542
  return it !== name;
616
543
  });
617
544
  fontsMap.active = [].concat(_toConsumableArray(fontsMap.active), [name]);
618
545
  };
619
-
620
546
  var useLoadedFonts = function useLoadedFonts(fonts) {
621
547
  var _useState = useState(false),
622
- _useState2 = _slicedToArray(_useState, 2),
623
- loaded = _useState2[0],
624
- setLoaded = _useState2[1];
625
-
548
+ _useState2 = _slicedToArray(_useState, 2),
549
+ loaded = _useState2[0],
550
+ setLoaded = _useState2[1];
626
551
  useEffect(function () {
627
552
  var config = fonts.reduce(function (newConfig, font) {
628
553
  var _ref = isObject(font) ? font : {
629
- type: 'system',
630
- name: font
631
- },
632
- type = _ref.type,
633
- name = _ref.name;
634
-
554
+ type: 'system',
555
+ name: font
556
+ },
557
+ type = _ref.type,
558
+ name = _ref.name;
635
559
  if ((type === 'google' || type === 'custom') && !isFontLoading(name) && !isFontActive(name)) {
636
560
  return _objectSpread(_objectSpread({}, newConfig), {}, _defineProperty({}, type, {
637
561
  families: [].concat(_toConsumableArray(newConfig !== null ? (newConfig[type] || {}).families || [] : []), [name])
638
562
  }));
639
563
  }
640
-
641
564
  return newConfig;
642
565
  }, null);
643
566
  var hasConfig = config !== null;
644
-
645
567
  if (hasConfig && typeof window !== 'undefined') {
646
- import('webfontloader').then(function (_ref2) {
568
+ loadPackage('webfontloader', function () {
569
+ return import('webfontloader');
570
+ }).then(function (_ref2) {
647
571
  var WebFont = _ref2["default"];
648
572
  return WebFont.load(_objectSpread(_objectSpread({}, config), {}, {
649
573
  timeout: 3000,
@@ -671,86 +595,76 @@ var useLoadedFonts = function useLoadedFonts(fonts) {
671
595
  };
672
596
 
673
597
  var progressSteps = [0.1, 0.25, 0.5, 0.75, 0.9];
674
-
675
598
  var useMediaApi = function useMediaApi() {
676
599
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
677
- _ref$url = _ref.url,
678
- url = _ref$url === void 0 ? null : _ref$url,
679
- _ref$initialMuted = _ref.initialMuted,
680
- initialMuted = _ref$initialMuted === void 0 ? false : _ref$initialMuted,
681
- _ref$onTimeUpdate = _ref.onTimeUpdate,
682
- onTimeUpdate = _ref$onTimeUpdate === void 0 ? null : _ref$onTimeUpdate,
683
- _ref$onProgressStep = _ref.onProgressStep,
684
- onProgressStep = _ref$onProgressStep === void 0 ? null : _ref$onProgressStep,
685
- _ref$onDurationChange = _ref.onDurationChanged,
686
- onDurationChanged = _ref$onDurationChange === void 0 ? null : _ref$onDurationChange,
687
- _ref$onVolumeChanged = _ref.onVolumeChanged,
688
- onVolumeChanged = _ref$onVolumeChanged === void 0 ? null : _ref$onVolumeChanged,
689
- _ref$onPlay = _ref.onPlay,
690
- onPlay = _ref$onPlay === void 0 ? null : _ref$onPlay,
691
- _ref$onPause = _ref.onPause,
692
- onPause = _ref$onPause === void 0 ? null : _ref$onPause,
693
- _ref$onEnded = _ref.onEnded,
694
- onEnded = _ref$onEnded === void 0 ? null : _ref$onEnded,
695
- _ref$onSeeked = _ref.onSeeked,
696
- onSeeked = _ref$onSeeked === void 0 ? null : _ref$onSeeked,
697
- _ref$onLoadStart = _ref.onLoadStart,
698
- onLoadStart = _ref$onLoadStart === void 0 ? null : _ref$onLoadStart,
699
- _ref$onCanPlayThough = _ref.onCanPlayThough,
700
- onCanPlayThough = _ref$onCanPlayThough === void 0 ? null : _ref$onCanPlayThough;
701
-
600
+ _ref$url = _ref.url,
601
+ url = _ref$url === void 0 ? null : _ref$url,
602
+ _ref$initialMuted = _ref.initialMuted,
603
+ initialMuted = _ref$initialMuted === void 0 ? false : _ref$initialMuted,
604
+ _ref$onTimeUpdate = _ref.onTimeUpdate,
605
+ onTimeUpdate = _ref$onTimeUpdate === void 0 ? null : _ref$onTimeUpdate,
606
+ _ref$onProgressStep = _ref.onProgressStep,
607
+ onProgressStep = _ref$onProgressStep === void 0 ? null : _ref$onProgressStep,
608
+ _ref$onDurationChange = _ref.onDurationChanged,
609
+ onDurationChanged = _ref$onDurationChange === void 0 ? null : _ref$onDurationChange,
610
+ _ref$onVolumeChanged = _ref.onVolumeChanged,
611
+ onVolumeChanged = _ref$onVolumeChanged === void 0 ? null : _ref$onVolumeChanged,
612
+ _ref$onPlay = _ref.onPlay,
613
+ onPlay = _ref$onPlay === void 0 ? null : _ref$onPlay,
614
+ _ref$onPause = _ref.onPause,
615
+ onPause = _ref$onPause === void 0 ? null : _ref$onPause,
616
+ _ref$onEnded = _ref.onEnded,
617
+ onEnded = _ref$onEnded === void 0 ? null : _ref$onEnded,
618
+ _ref$onSeeked = _ref.onSeeked,
619
+ onSeeked = _ref$onSeeked === void 0 ? null : _ref$onSeeked,
620
+ _ref$onLoadStart = _ref.onLoadStart,
621
+ onLoadStart = _ref$onLoadStart === void 0 ? null : _ref$onLoadStart,
622
+ _ref$onCanPlayThough = _ref.onCanPlayThough,
623
+ onCanPlayThough = _ref$onCanPlayThough === void 0 ? null : _ref$onCanPlayThough;
702
624
  var ref = useRef(null);
703
-
704
625
  var _useState = useState(initialMuted),
705
- _useState2 = _slicedToArray(_useState, 2),
706
- muted = _useState2[0],
707
- setMuted = _useState2[1];
708
-
626
+ _useState2 = _slicedToArray(_useState, 2),
627
+ muted = _useState2[0],
628
+ setMuted = _useState2[1];
709
629
  var _useState3 = useState(null),
710
- _useState4 = _slicedToArray(_useState3, 2),
711
- currentTime = _useState4[0],
712
- setCurrentTime = _useState4[1];
713
-
630
+ _useState4 = _slicedToArray(_useState3, 2),
631
+ currentTime = _useState4[0],
632
+ setCurrentTime = _useState4[1];
714
633
  var _useState5 = useState(null),
715
- _useState6 = _slicedToArray(_useState5, 2),
716
- duration = _useState6[0],
717
- setDuration = _useState6[1];
718
-
634
+ _useState6 = _slicedToArray(_useState5, 2),
635
+ duration = _useState6[0],
636
+ setDuration = _useState6[1];
719
637
  var _useState7 = useState(false),
720
- _useState8 = _slicedToArray(_useState7, 2),
721
- playing = _useState8[0],
722
- setPlaying = _useState8[1];
723
-
638
+ _useState8 = _slicedToArray(_useState7, 2),
639
+ playing = _useState8[0],
640
+ setPlaying = _useState8[1];
724
641
  var _useState9 = useState(false),
725
- _useState10 = _slicedToArray(_useState9, 2),
726
- ready = _useState10[0],
727
- setReady = _useState10[1];
728
-
642
+ _useState10 = _slicedToArray(_useState9, 2),
643
+ ready = _useState10[0],
644
+ setReady = _useState10[1];
729
645
  var _useState11 = useState(true),
730
- _useState12 = _slicedToArray(_useState11, 2),
731
- initialPlay = _useState12[0],
732
- setInitialPlay = _useState12[1];
733
-
646
+ _useState12 = _slicedToArray(_useState11, 2),
647
+ initialPlay = _useState12[0],
648
+ setInitialPlay = _useState12[1];
734
649
  var progressStepsReached = useRef({});
735
- var paused = !playing; // Exposed methods
650
+ var paused = !playing;
651
+
652
+ // Exposed methods
736
653
 
737
654
  var play = useCallback(function () {
738
655
  var media = ref.current;
739
-
740
656
  if (media !== null) {
741
657
  media.play();
742
658
  }
743
659
  }, []);
744
660
  var pause = useCallback(function () {
745
661
  var media = ref.current;
746
-
747
662
  if (media !== null) {
748
663
  media.pause();
749
664
  }
750
665
  }, []);
751
666
  var togglePlay = useCallback(function () {
752
667
  var media = ref.current;
753
-
754
668
  if (media !== null) {
755
669
  if (playing) {
756
670
  media.pause();
@@ -761,7 +675,6 @@ var useMediaApi = function useMediaApi() {
761
675
  }, [playing]);
762
676
  var stop = useCallback(function () {
763
677
  var media = ref.current;
764
-
765
678
  if (media !== null) {
766
679
  media.pause();
767
680
  media.currentTime = 0;
@@ -769,32 +682,30 @@ var useMediaApi = function useMediaApi() {
769
682
  }, []);
770
683
  var seek = useCallback(function (time) {
771
684
  var media = ref.current;
772
-
773
685
  if (media !== null) {
774
686
  media.currentTime = time;
775
687
  }
776
688
  }, []);
777
689
  var mute = useCallback(function () {
778
690
  var media = ref.current;
779
-
780
691
  if (media !== null) {
781
692
  media.muted = true;
782
693
  }
783
694
  }, []);
784
695
  var unMute = useCallback(function () {
785
696
  var media = ref.current;
786
-
787
697
  if (media !== null) {
788
698
  media.muted = false;
789
699
  }
790
700
  }, []);
791
701
  var toggleMute = useCallback(function () {
792
702
  var media = ref.current;
793
-
794
703
  if (media !== null) {
795
704
  media.muted = !muted;
796
705
  }
797
- }, [muted]); // Media events callbacks
706
+ }, [muted]);
707
+
708
+ // Media events callbacks
798
709
 
799
710
  var onCustomPlay = useCallback(function () {
800
711
  if (onPlay !== null) {
@@ -802,17 +713,14 @@ var useMediaApi = function useMediaApi() {
802
713
  initial: initialPlay
803
714
  });
804
715
  }
805
-
806
716
  if (initialPlay) {
807
717
  setInitialPlay(false);
808
718
  }
809
-
810
719
  setPlaying(true);
811
720
  }, [initialPlay, setPlaying, onPlay]);
812
721
  var onCustomPause = useCallback(function () {
813
722
  var media = ref.current;
814
723
  setPlaying(false);
815
-
816
724
  if (onPause !== null) {
817
725
  onPause({
818
726
  midway: media.currentTime > 0 && media.currentTime < media.duration
@@ -822,21 +730,17 @@ var useMediaApi = function useMediaApi() {
822
730
  var onCustomEnded = useCallback(function () {
823
731
  var media = ref.current;
824
732
  media.currentTime = 0;
825
-
826
733
  if (onEnded !== null) {
827
734
  onEnded();
828
735
  }
829
-
830
736
  setInitialPlay(true);
831
737
  }, [setInitialPlay, onEnded]);
832
738
  var onCustomTimeUpdate = useCallback(function () {
833
739
  var media = ref.current;
834
740
  setCurrentTime(media.currentTime);
835
-
836
741
  if (onTimeUpdate !== null) {
837
742
  onTimeUpdate(media.currentTime);
838
743
  }
839
-
840
744
  var progress = media.currentTime / media.duration;
841
745
  var currentSteps = progressStepsReached.current;
842
746
  var stepsToTrack = progressSteps.filter(function (step) {
@@ -846,21 +750,18 @@ var useMediaApi = function useMediaApi() {
846
750
  if (onProgressStep !== null) {
847
751
  onProgressStep(step);
848
752
  }
849
-
850
753
  currentSteps[step] = true;
851
754
  });
852
755
  }, [setCurrentTime, onTimeUpdate, onProgressStep]);
853
756
  var onCustomDurationChange = useCallback(function () {
854
757
  var media = ref.current;
855
758
  setDuration(media.duration);
856
-
857
759
  if (onDurationChanged !== null) {
858
760
  onDurationChanged(media.duration);
859
761
  }
860
762
  }, [setDuration, onDurationChanged]);
861
763
  var onCustomSeeked = useCallback(function () {
862
764
  var media = ref.current;
863
-
864
765
  if (onSeeked !== null) {
865
766
  onSeeked(media.currentTime);
866
767
  }
@@ -868,28 +769,24 @@ var useMediaApi = function useMediaApi() {
868
769
  var onCustomVolumeChange = useCallback(function () {
869
770
  var media = ref.current;
870
771
  setMuted(media.muted);
871
-
872
772
  if (onVolumeChanged !== null) {
873
773
  onVolumeChanged(media.muted, media.volume);
874
774
  }
875
775
  }, [setMuted, onVolumeChanged]);
876
776
  var onCustomLoadStart = useCallback(function () {
877
777
  setReady(false);
878
-
879
778
  if (onLoadStart !== null) {
880
779
  onLoadStart();
881
780
  }
882
781
  }, [setReady, onLoadStart]);
883
782
  var onCustomCanPlayThrough = useCallback(function () {
884
783
  setReady(true);
885
-
886
784
  if (onCanPlayThough !== null) {
887
785
  onCanPlayThough();
888
786
  }
889
787
  }, [setReady, onCanPlayThough]);
890
788
  useEffect(function () {
891
789
  var media = ref.current;
892
-
893
790
  if (media !== null) {
894
791
  media.addEventListener('timeupdate', onCustomTimeUpdate);
895
792
  media.addEventListener('durationchange', onCustomDurationChange);
@@ -901,7 +798,6 @@ var useMediaApi = function useMediaApi() {
901
798
  media.addEventListener('loadstart', onCustomLoadStart);
902
799
  media.addEventListener('canplaythrough', onCustomCanPlayThrough);
903
800
  }
904
-
905
801
  return function () {
906
802
  if (media !== null) {
907
803
  media.removeEventListener('timeupdate', onCustomTimeUpdate);
@@ -937,8 +833,9 @@ var useMediaApi = function useMediaApi() {
937
833
 
938
834
  var useMediasParser = function useMediasParser() {
939
835
  // const screensManager = useScreensManager();
940
- var fieldsManager = useFieldsManager(); // Convert medias object to path
836
+ var fieldsManager = useFieldsManager();
941
837
 
838
+ // Convert medias object to path
942
839
  var parser = useMemo(function () {
943
840
  return new MediasParser({
944
841
  // screensManager,
@@ -963,7 +860,6 @@ var getResource = function getResource(resources, resourceId) {
963
860
  return it.id === resourceId;
964
861
  }) || null : resourceId;
965
862
  };
966
-
967
863
  var useResourceUrlGenerator = function useResourceUrlGenerator() {
968
864
  var resourceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
969
865
  var resources = usePanneauResources();
@@ -976,15 +872,13 @@ var useResourceUrlGenerator = function useResourceUrlGenerator() {
976
872
  var finalRouteName = resourceId !== null ? routeResourceId : routeName;
977
873
  var finalParams = resourceId !== null ? routeName : params;
978
874
  var finalResource = getResource(resources, routeResourceId) || resource;
979
-
980
875
  var _ref = finalResource || {},
981
- _ref$id = _ref.id,
982
- id = _ref$id === void 0 ? null : _ref$id; // console.log('gen', finalRouteName, route(`resources.${finalRouteName}`, {
876
+ _ref$id = _ref.id,
877
+ id = _ref$id === void 0 ? null : _ref$id;
878
+ // console.log('gen', finalRouteName, route(`resources.${finalRouteName}`, {
983
879
  // ...finalParams,
984
880
  // resource: id,
985
881
  // }));
986
-
987
-
988
882
  return id !== null ? route("resources.".concat(finalRouteName), _objectSpread(_objectSpread({}, finalParams), {}, {
989
883
  resource: id
990
884
  })) : null;
@@ -992,20 +886,19 @@ var useResourceUrlGenerator = function useResourceUrlGenerator() {
992
886
  };
993
887
 
994
888
  var _excluded = ["width", "height"];
995
-
996
889
  var useScreenSize = function useScreenSize(_ref) {
997
890
  var _ref$width = _ref.width,
998
- width = _ref$width === void 0 ? null : _ref$width,
999
- _ref$height = _ref.height,
1000
- height = _ref$height === void 0 ? null : _ref$height,
1001
- _ref$landscape = _ref.landscape,
1002
- landscape = _ref$landscape === void 0 ? false : _ref$landscape,
1003
- _ref$screens = _ref.screens,
1004
- screens = _ref$screens === void 0 ? [] : _ref$screens,
1005
- _ref$mediaType = _ref.mediaType,
1006
- mediaType = _ref$mediaType === void 0 ? 'screen' : _ref$mediaType,
1007
- _ref$media = _ref.media,
1008
- providedMedia = _ref$media === void 0 ? null : _ref$media;
891
+ width = _ref$width === void 0 ? null : _ref$width,
892
+ _ref$height = _ref.height,
893
+ height = _ref$height === void 0 ? null : _ref$height,
894
+ _ref$landscape = _ref.landscape,
895
+ landscape = _ref$landscape === void 0 ? false : _ref$landscape,
896
+ _ref$screens = _ref.screens,
897
+ screens = _ref$screens === void 0 ? [] : _ref$screens,
898
+ _ref$mediaType = _ref.mediaType,
899
+ mediaType = _ref$mediaType === void 0 ? 'screen' : _ref$mediaType,
900
+ _ref$media = _ref.media,
901
+ providedMedia = _ref$media === void 0 ? null : _ref$media;
1009
902
  // Get media
1010
903
  var media = useMemo(function () {
1011
904
  return providedMedia !== null ? providedMedia : {
@@ -1013,12 +906,13 @@ var useScreenSize = function useScreenSize(_ref) {
1013
906
  width: "".concat(width, "px"),
1014
907
  height: "".concat(height, "px")
1015
908
  };
1016
- }, [providedMedia, mediaType, width, height]); // Get matching screens
909
+ }, [providedMedia, mediaType, width, height]);
1017
910
 
911
+ // Get matching screens
1018
912
  var matchingScreens = useMemo(function () {
1019
913
  return _toConsumableArray(screens).reverse().filter(function (_ref2) {
1020
914
  var _ref2$mediaQuery = _ref2.mediaQuery,
1021
- mediaQuery = _ref2$mediaQuery === void 0 ? null : _ref2$mediaQuery;
915
+ mediaQuery = _ref2$mediaQuery === void 0 ? null : _ref2$mediaQuery;
1022
916
  return mediaQuery === null || match(mediaQuery, media);
1023
917
  });
1024
918
  }, [screens, media]);
@@ -1033,41 +927,34 @@ var useScreenSize = function useScreenSize(_ref) {
1033
927
  landscape: landscape
1034
928
  };
1035
929
  };
1036
-
1037
930
  var useScreenSizeFromElement = function useScreenSizeFromElement() {
1038
931
  var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1039
- _ref4$width = _ref4.width,
1040
- width = _ref4$width === void 0 ? null : _ref4$width,
1041
- _ref4$height = _ref4.height,
1042
- height = _ref4$height === void 0 ? null : _ref4$height,
1043
- opts = _objectWithoutProperties(_ref4, _excluded);
1044
-
932
+ _ref4$width = _ref4.width,
933
+ width = _ref4$width === void 0 ? null : _ref4$width,
934
+ _ref4$height = _ref4.height,
935
+ height = _ref4$height === void 0 ? null : _ref4$height,
936
+ opts = _objectWithoutProperties(_ref4, _excluded);
1045
937
  var _useResizeObserver = useResizeObserver(),
1046
- ref = _useResizeObserver.ref,
1047
- contentRect = _useResizeObserver.entry.contentRect;
1048
-
938
+ ref = _useResizeObserver.ref,
939
+ contentRect = _useResizeObserver.entry.contentRect;
1049
940
  var _ref5 = contentRect || {},
1050
- _ref5$width = _ref5.width,
1051
- calculatedWidth = _ref5$width === void 0 ? 0 : _ref5$width,
1052
- _ref5$height = _ref5.height,
1053
- calculatedHeight = _ref5$height === void 0 ? 0 : _ref5$height;
1054
-
941
+ _ref5$width = _ref5.width,
942
+ calculatedWidth = _ref5$width === void 0 ? 0 : _ref5$width,
943
+ _ref5$height = _ref5.height,
944
+ calculatedHeight = _ref5$height === void 0 ? 0 : _ref5$height;
1055
945
  var semiFinalWidth = width !== null ? width : calculatedWidth;
1056
946
  var semiFinalHeight = height !== null ? height : calculatedHeight;
1057
947
  var landscape = semiFinalHeight > 0 && semiFinalWidth > semiFinalHeight;
1058
948
  var _opts$withoutMaxSize = opts.withoutMaxSize,
1059
- withoutMaxSize = _opts$withoutMaxSize === void 0 ? false : _opts$withoutMaxSize;
949
+ withoutMaxSize = _opts$withoutMaxSize === void 0 ? false : _opts$withoutMaxSize;
1060
950
  var finalWidth = landscape && !withoutMaxSize ? Math.round(Math.max(320, 0.45 * semiFinalHeight)) : semiFinalWidth;
1061
951
  var finalHeight = landscape && !withoutMaxSize ? Math.round(Math.max(533, 0.75 * semiFinalHeight)) : semiFinalHeight;
1062
-
1063
952
  if (finalWidth % 2 === 1) {
1064
953
  finalWidth -= 1;
1065
954
  }
1066
-
1067
955
  if (finalHeight % 2 === 1) {
1068
956
  finalHeight -= 1;
1069
957
  }
1070
-
1071
958
  var screenSize = useScreenSize(_objectSpread({
1072
959
  width: finalWidth,
1073
960
  height: finalHeight,
@@ -1078,29 +965,24 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
1078
965
  screenSize: screenSize
1079
966
  };
1080
967
  };
1081
-
1082
968
  var getWindowSize = function getWindowSize() {
1083
969
  return {
1084
970
  width: typeof window !== 'undefined' ? window.innerWidth : null,
1085
971
  height: typeof window !== 'undefined' ? window.innerHæeight : null
1086
972
  };
1087
973
  };
1088
-
1089
974
  var useScreenSizeFromWindow = function useScreenSizeFromWindow(opts) {
1090
975
  var _useState = useState(getWindowSize()),
1091
- _useState2 = _slicedToArray(_useState, 2),
1092
- windowSize = _useState2[0],
1093
- setWindowSize = _useState2[1];
1094
-
976
+ _useState2 = _slicedToArray(_useState, 2),
977
+ windowSize = _useState2[0],
978
+ setWindowSize = _useState2[1];
1095
979
  useEffect(function () {
1096
980
  var onResize = function onResize() {
1097
981
  return setWindowSize(getWindowSize());
1098
982
  };
1099
-
1100
983
  if (typeof window !== 'undefined') {
1101
984
  window.addEventListener('resize', onResize);
1102
985
  }
1103
-
1104
986
  return function () {
1105
987
  if (typeof window !== 'undefined') {
1106
988
  window.removeEventListener('resize', onResize);