@micromag/core 0.4.49 → 0.4.50
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/components.js +1157 -977
- package/es/contexts.js +154 -122
- package/lib/components.js +1157 -977
- package/lib/contexts.js +259 -227
- package/package.json +2 -2
package/lib/contexts.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
4
|
var isString = require('lodash/isString');
|
|
5
|
-
var React
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var core = require('@micromag/core');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
8
9
|
var JSCookie = require('js-cookie');
|
|
9
10
|
var reactIntl = require('react-intl');
|
|
@@ -24,7 +25,7 @@ var FIELDS_NAMESPACE = 'fields';
|
|
|
24
25
|
var FORMS_NAMESPACE = 'forms';
|
|
25
26
|
var SCREENS_NAMESPACE = 'screens';
|
|
26
27
|
var ELEMENTS_NAMESPACE = 'elements';
|
|
27
|
-
var ComponentsContext = /*#__PURE__*/React
|
|
28
|
+
var ComponentsContext = /*#__PURE__*/React.createContext(null);
|
|
28
29
|
var emptyComponents = {};
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -32,8 +33,8 @@ var emptyComponents = {};
|
|
|
32
33
|
*/
|
|
33
34
|
var useComponentsManager = function useComponentsManager() {
|
|
34
35
|
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
35
|
-
var manager = React
|
|
36
|
-
var finalManager = React
|
|
36
|
+
var manager = React.useContext(ComponentsContext);
|
|
37
|
+
var finalManager = React.useMemo(function () {
|
|
37
38
|
return namespace !== null ? new core.ComponentsManager(manager.getComponents(namespace)) : manager;
|
|
38
39
|
}, [manager, namespace]);
|
|
39
40
|
return finalManager;
|
|
@@ -48,7 +49,7 @@ var useComponent = function useComponent(name) {
|
|
|
48
49
|
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
49
50
|
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
50
51
|
var manager = useComponentsManager(namespace);
|
|
51
|
-
return React
|
|
52
|
+
return React.useMemo(function () {
|
|
52
53
|
if (!isString(name)) {
|
|
53
54
|
return name || defaultComponent;
|
|
54
55
|
}
|
|
@@ -144,12 +145,13 @@ function ComponentsProvider(_ref) {
|
|
|
144
145
|
namespace = _ref$namespace === void 0 ? null : _ref$namespace,
|
|
145
146
|
children = _ref.children;
|
|
146
147
|
var previousManager = useComponentsManager() || null;
|
|
147
|
-
var finalManager = React
|
|
148
|
+
var finalManager = React.useMemo(function () {
|
|
148
149
|
return new core.ComponentsManager(_objectSpread(_objectSpread(_objectSpread({}, previousManager !== null ? previousManager.getComponents() : null), manager !== null ? manager.getComponents() : null), new core.ComponentsManager(components).addNamespace(namespace).getComponents()));
|
|
149
150
|
}, [previousManager, manager, components, namespace]);
|
|
150
|
-
return /*#__PURE__*/
|
|
151
|
-
value: finalManager
|
|
152
|
-
|
|
151
|
+
return /*#__PURE__*/jsxRuntime.jsx(ComponentsContext.Provider, {
|
|
152
|
+
value: finalManager,
|
|
153
|
+
children: children
|
|
154
|
+
});
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
var messages = reactIntl.defineMessages({
|
|
@@ -289,12 +291,12 @@ var consentStates = [{
|
|
|
289
291
|
description: messages.ad_user_data_description,
|
|
290
292
|
value: false
|
|
291
293
|
}];
|
|
292
|
-
var ConsentContext = /*#__PURE__*/React
|
|
294
|
+
var ConsentContext = /*#__PURE__*/React.createContext({
|
|
293
295
|
consent: null,
|
|
294
296
|
setConsent: function setConsent() {}
|
|
295
297
|
});
|
|
296
298
|
var useConsent = function useConsent() {
|
|
297
|
-
return React
|
|
299
|
+
return React.useContext(ConsentContext);
|
|
298
300
|
};
|
|
299
301
|
var defaultValues = ['functionality_storage', 'analytics_storage', 'ad_storage', 'ad_personalization', 'ad_user_data'];
|
|
300
302
|
function ConsentProvider(_ref) {
|
|
@@ -308,11 +310,11 @@ function ConsentProvider(_ref) {
|
|
|
308
310
|
// Has consented or not to cookies
|
|
309
311
|
var initialCookieConsented = JSCookie.get('has_consented') === 'true';
|
|
310
312
|
var baseConsented = initialConsented || initialCookieConsented;
|
|
311
|
-
var _useState = React
|
|
313
|
+
var _useState = React.useState(baseConsented),
|
|
312
314
|
_useState2 = _slicedToArray(_useState, 2),
|
|
313
315
|
consented = _useState2[0],
|
|
314
316
|
setConsentedState = _useState2[1];
|
|
315
|
-
var setConsented = React
|
|
317
|
+
var setConsented = React.useCallback(function () {
|
|
316
318
|
var accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
317
319
|
var hasConsented = accept || false;
|
|
318
320
|
JSCookie.set('has_consented', hasConsented, {
|
|
@@ -321,14 +323,14 @@ function ConsentProvider(_ref) {
|
|
|
321
323
|
});
|
|
322
324
|
setConsentedState(hasConsented);
|
|
323
325
|
}, [expiration, setConsentedState]);
|
|
324
|
-
React
|
|
326
|
+
React.useEffect(function () {
|
|
325
327
|
if (initialConsented === true || initialConsented === false) {
|
|
326
328
|
setConsented(initialConsented);
|
|
327
329
|
}
|
|
328
330
|
}, [initialConsented, setConsented]);
|
|
329
331
|
|
|
330
332
|
// The consent state itself
|
|
331
|
-
var baseConsent = React
|
|
333
|
+
var baseConsent = React.useMemo(function () {
|
|
332
334
|
return (providedConsent || consentStates || []).map(function (item) {
|
|
333
335
|
if (isString(item)) {
|
|
334
336
|
return (consentStates || []).find(function (it) {
|
|
@@ -346,11 +348,11 @@ function ConsentProvider(_ref) {
|
|
|
346
348
|
});
|
|
347
349
|
});
|
|
348
350
|
}, [providedConsent]);
|
|
349
|
-
var _useState3 = React
|
|
351
|
+
var _useState3 = React.useState(null),
|
|
350
352
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
351
353
|
consent = _useState4[0],
|
|
352
354
|
setConsentState = _useState4[1];
|
|
353
|
-
var setConsent = React
|
|
355
|
+
var setConsent = React.useCallback(function () {
|
|
354
356
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
355
357
|
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
356
358
|
var tagManagerConsent = (values || []).reduce(function (acc, it) {
|
|
@@ -379,12 +381,12 @@ function ConsentProvider(_ref) {
|
|
|
379
381
|
}
|
|
380
382
|
setConsentState(values);
|
|
381
383
|
}, [setConsentState, expiration]);
|
|
382
|
-
React
|
|
384
|
+
React.useEffect(function () {
|
|
383
385
|
if (baseConsent !== null && baseConsent.length > 0) {
|
|
384
386
|
setConsent(baseConsent);
|
|
385
387
|
}
|
|
386
388
|
}, [baseConsent, setConsent]);
|
|
387
|
-
var value = React
|
|
389
|
+
var value = React.useMemo(function () {
|
|
388
390
|
return {
|
|
389
391
|
consent: consent,
|
|
390
392
|
setConsent: setConsent,
|
|
@@ -392,14 +394,15 @@ function ConsentProvider(_ref) {
|
|
|
392
394
|
setConsented: setConsented
|
|
393
395
|
};
|
|
394
396
|
}, [consent, setConsent, consented, setConsented]);
|
|
395
|
-
return /*#__PURE__*/
|
|
396
|
-
value: value
|
|
397
|
-
|
|
397
|
+
return /*#__PURE__*/jsxRuntime.jsx(ConsentContext.Provider, {
|
|
398
|
+
value: value,
|
|
399
|
+
children: children
|
|
400
|
+
});
|
|
398
401
|
}
|
|
399
402
|
|
|
400
|
-
var FieldsContext = /*#__PURE__*/React
|
|
403
|
+
var FieldsContext = /*#__PURE__*/React.createContext(null);
|
|
401
404
|
var useFieldsManager = function useFieldsManager() {
|
|
402
|
-
return React
|
|
405
|
+
return React.useContext(FieldsContext);
|
|
403
406
|
};
|
|
404
407
|
var useFieldDefinition = function useFieldDefinition(id) {
|
|
405
408
|
var manager = useFieldsManager();
|
|
@@ -412,31 +415,33 @@ function FieldsProvider(_ref) {
|
|
|
412
415
|
manager = _ref$manager === void 0 ? null : _ref$manager,
|
|
413
416
|
children = _ref.children;
|
|
414
417
|
var previousManager = useFieldsManager() || null;
|
|
415
|
-
var finalManager = React
|
|
418
|
+
var finalManager = React.useMemo(function () {
|
|
416
419
|
var newFields = uniqBy([].concat(_toConsumableArray(fields || []), _toConsumableArray(manager !== null ? manager.getDefinitions() : []), _toConsumableArray(previousManager !== null ? previousManager.getDefinitions() : [])), function (_ref2) {
|
|
417
420
|
var id = _ref2.id;
|
|
418
421
|
return id;
|
|
419
422
|
}).reverse();
|
|
420
423
|
return new core.FieldsManager(newFields);
|
|
421
424
|
}, [previousManager, manager, fields]);
|
|
422
|
-
var components = React
|
|
425
|
+
var components = React.useMemo(function () {
|
|
423
426
|
var newComponents = finalManager.getComponents();
|
|
424
427
|
return Object.keys(newComponents).reduce(function (map, id) {
|
|
425
428
|
var component = newComponents[id];
|
|
426
429
|
return isString(component) ? map : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, component));
|
|
427
430
|
}, {});
|
|
428
431
|
}, [finalManager]);
|
|
429
|
-
return /*#__PURE__*/
|
|
430
|
-
value: finalManager
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
432
|
+
return /*#__PURE__*/jsxRuntime.jsx(FieldsContext.Provider, {
|
|
433
|
+
value: finalManager,
|
|
434
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ComponentsProvider, {
|
|
435
|
+
namespace: FIELDS_NAMESPACE,
|
|
436
|
+
components: components,
|
|
437
|
+
children: children
|
|
438
|
+
})
|
|
439
|
+
});
|
|
435
440
|
}
|
|
436
441
|
|
|
437
|
-
var ScreensContext = /*#__PURE__*/React
|
|
442
|
+
var ScreensContext = /*#__PURE__*/React.createContext(new core.ScreensManager());
|
|
438
443
|
var useScreensManager = function useScreensManager() {
|
|
439
|
-
return React
|
|
444
|
+
return React.useContext(ScreensContext);
|
|
440
445
|
};
|
|
441
446
|
function ScreensProvider(_ref) {
|
|
442
447
|
var _ref$screens = _ref.screens,
|
|
@@ -449,7 +454,7 @@ function ScreensProvider(_ref) {
|
|
|
449
454
|
manager = _ref$manager === void 0 ? null : _ref$manager,
|
|
450
455
|
children = _ref.children;
|
|
451
456
|
var previousManager = useScreensManager();
|
|
452
|
-
var finalManager = React
|
|
457
|
+
var finalManager = React.useMemo(function () {
|
|
453
458
|
var newManager = manager !== null ? manager : new core.ScreensManager(screens);
|
|
454
459
|
if ((previousManager || null) !== null) {
|
|
455
460
|
newManager = previousManager.merge(newManager);
|
|
@@ -465,14 +470,14 @@ function ScreensProvider(_ref) {
|
|
|
465
470
|
}
|
|
466
471
|
return newManager;
|
|
467
472
|
}, [manager, screens, namespaces, filterNamespaces, previousManager]);
|
|
468
|
-
var initialComponents = React
|
|
473
|
+
var initialComponents = React.useMemo(function () {
|
|
469
474
|
return finalManager.getComponents();
|
|
470
475
|
}, [finalManager]);
|
|
471
|
-
var _useState = React
|
|
476
|
+
var _useState = React.useState(initialComponents),
|
|
472
477
|
_useState2 = _slicedToArray(_useState, 2),
|
|
473
478
|
components = _useState2[0],
|
|
474
479
|
setComponents = _useState2[1];
|
|
475
|
-
React
|
|
480
|
+
React.useEffect(function () {
|
|
476
481
|
var onChange = function onChange() {
|
|
477
482
|
return setComponents(finalManager.getComponents());
|
|
478
483
|
};
|
|
@@ -481,17 +486,19 @@ function ScreensProvider(_ref) {
|
|
|
481
486
|
finalManager.off('change', onChange);
|
|
482
487
|
};
|
|
483
488
|
}, [finalManager, setComponents]);
|
|
484
|
-
return /*#__PURE__*/
|
|
485
|
-
value: finalManager
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
489
|
+
return /*#__PURE__*/jsxRuntime.jsx(ScreensContext.Provider, {
|
|
490
|
+
value: finalManager,
|
|
491
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ComponentsProvider, {
|
|
492
|
+
namespace: SCREENS_NAMESPACE,
|
|
493
|
+
components: components,
|
|
494
|
+
children: children
|
|
495
|
+
})
|
|
496
|
+
});
|
|
490
497
|
}
|
|
491
498
|
|
|
492
|
-
var StoryContext = /*#__PURE__*/React
|
|
499
|
+
var StoryContext = /*#__PURE__*/React.createContext(null);
|
|
493
500
|
var useStoryContext = function useStoryContext() {
|
|
494
|
-
return React
|
|
501
|
+
return React.useContext(StoryContext);
|
|
495
502
|
};
|
|
496
503
|
var useStory = function useStory() {
|
|
497
504
|
var story = useStoryContext();
|
|
@@ -501,14 +508,15 @@ function StoryProvider(_ref) {
|
|
|
501
508
|
var _ref$story = _ref.story,
|
|
502
509
|
story = _ref$story === void 0 ? null : _ref$story,
|
|
503
510
|
children = _ref.children;
|
|
504
|
-
return /*#__PURE__*/
|
|
505
|
-
value: story
|
|
506
|
-
|
|
511
|
+
return /*#__PURE__*/jsxRuntime.jsx(StoryContext.Provider, {
|
|
512
|
+
value: story,
|
|
513
|
+
children: children
|
|
514
|
+
});
|
|
507
515
|
}
|
|
508
516
|
|
|
509
|
-
var EditorContext = /*#__PURE__*/React
|
|
517
|
+
var EditorContext = /*#__PURE__*/React.createContext(null);
|
|
510
518
|
var useEditor = function useEditor() {
|
|
511
|
-
return React
|
|
519
|
+
return React.useContext(EditorContext);
|
|
512
520
|
};
|
|
513
521
|
var useGetColors = function useGetColors() {
|
|
514
522
|
var _ref = useEditor() || {},
|
|
@@ -523,58 +531,61 @@ function EditorProvider(_ref2) {
|
|
|
523
531
|
var story = useStory();
|
|
524
532
|
var screensManager = useScreensManager();
|
|
525
533
|
var fieldsManager = useFieldsManager();
|
|
526
|
-
var parser = React
|
|
534
|
+
var parser = React.useMemo(function () {
|
|
527
535
|
return new core.ColorsParser({
|
|
528
536
|
screensManager: screensManager,
|
|
529
537
|
fieldsManager: fieldsManager
|
|
530
538
|
});
|
|
531
539
|
}, [screensManager, fieldsManager]);
|
|
532
|
-
var parse = React
|
|
540
|
+
var parse = React.useCallback(function (currentStory) {
|
|
533
541
|
return parser.parse(currentStory);
|
|
534
542
|
}, [parser]);
|
|
535
|
-
var getColors = React
|
|
543
|
+
var getColors = React.useCallback(function () {
|
|
536
544
|
return parse(story);
|
|
537
545
|
}, [parse, story]);
|
|
538
546
|
|
|
539
547
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
540
|
-
return /*#__PURE__*/
|
|
548
|
+
return /*#__PURE__*/jsxRuntime.jsx(EditorContext.Provider, {
|
|
541
549
|
value: {
|
|
542
550
|
getColors: getColors
|
|
543
|
-
}
|
|
544
|
-
|
|
551
|
+
},
|
|
552
|
+
children: children
|
|
553
|
+
});
|
|
545
554
|
}
|
|
546
555
|
|
|
547
556
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
548
|
-
var FieldsValueContext = /*#__PURE__*/React
|
|
557
|
+
var FieldsValueContext = /*#__PURE__*/React.createContext(null);
|
|
549
558
|
var useFieldsValue = function useFieldsValue() {
|
|
550
|
-
return React
|
|
559
|
+
return React.useContext(FieldsValueContext);
|
|
551
560
|
};
|
|
552
561
|
function FieldsValueContextProvider(_ref) {
|
|
553
562
|
var _ref$value = _ref.value,
|
|
554
563
|
value = _ref$value === void 0 ? null : _ref$value,
|
|
555
564
|
children = _ref.children;
|
|
556
|
-
return /*#__PURE__*/
|
|
557
|
-
value: value
|
|
558
|
-
|
|
565
|
+
return /*#__PURE__*/jsxRuntime.jsx(FieldsValueContext.Provider, {
|
|
566
|
+
value: value,
|
|
567
|
+
children: children
|
|
568
|
+
});
|
|
559
569
|
}
|
|
560
570
|
|
|
561
571
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
562
|
-
var FieldContext = /*#__PURE__*/React
|
|
572
|
+
var FieldContext = /*#__PURE__*/React.createContext(null);
|
|
563
573
|
var useFieldContext = function useFieldContext() {
|
|
564
|
-
return React
|
|
574
|
+
return React.useContext(FieldContext);
|
|
565
575
|
};
|
|
566
576
|
function FieldContextProvider(_ref) {
|
|
567
577
|
var _ref$context = _ref.context,
|
|
568
578
|
context = _ref$context === void 0 ? null : _ref$context,
|
|
569
579
|
children = _ref.children;
|
|
570
|
-
return /*#__PURE__*/
|
|
571
|
-
value: context
|
|
572
|
-
|
|
580
|
+
return /*#__PURE__*/jsxRuntime.jsx(FieldContext.Provider, {
|
|
581
|
+
value: context,
|
|
582
|
+
children: children
|
|
583
|
+
});
|
|
573
584
|
}
|
|
574
585
|
|
|
575
|
-
var SettingsContext = /*#__PURE__*/React
|
|
586
|
+
var SettingsContext = /*#__PURE__*/React.createContext({});
|
|
576
587
|
var useSettings = function useSettings() {
|
|
577
|
-
return React
|
|
588
|
+
return React.useContext(SettingsContext);
|
|
578
589
|
};
|
|
579
590
|
var useSetting = function useSetting(key) {
|
|
580
591
|
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
@@ -589,20 +600,21 @@ function SettingsProvider(_ref2) {
|
|
|
589
600
|
_ref2$settings = _ref2.settings,
|
|
590
601
|
settings = _ref2$settings === void 0 ? null : _ref2$settings;
|
|
591
602
|
var previousSettings = useSettings();
|
|
592
|
-
var value = React
|
|
603
|
+
var value = React.useMemo(function () {
|
|
593
604
|
return _objectSpread(_objectSpread({}, previousSettings), settings);
|
|
594
605
|
}, [settings, previousSettings]);
|
|
595
|
-
return /*#__PURE__*/
|
|
596
|
-
value: value
|
|
597
|
-
|
|
606
|
+
return /*#__PURE__*/jsxRuntime.jsx(SettingsContext.Provider, {
|
|
607
|
+
value: value,
|
|
608
|
+
children: children
|
|
609
|
+
});
|
|
598
610
|
}
|
|
599
611
|
|
|
600
612
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
601
|
-
var GoogleKeysContext = /*#__PURE__*/React
|
|
613
|
+
var GoogleKeysContext = /*#__PURE__*/React.createContext({
|
|
602
614
|
apiKey: null
|
|
603
615
|
});
|
|
604
616
|
var useGoogleKeys = function useGoogleKeys() {
|
|
605
|
-
return React
|
|
617
|
+
return React.useContext(GoogleKeysContext);
|
|
606
618
|
};
|
|
607
619
|
function GoogleKeysProvider(_ref) {
|
|
608
620
|
var children = _ref.children,
|
|
@@ -611,17 +623,18 @@ function GoogleKeysProvider(_ref) {
|
|
|
611
623
|
var _useGoogleKeys = useGoogleKeys(),
|
|
612
624
|
previousApiKey = _useGoogleKeys.apiKey;
|
|
613
625
|
var settingApiKey = useSetting('googleApiKey');
|
|
614
|
-
var value = React
|
|
626
|
+
var value = React.useMemo(function () {
|
|
615
627
|
return {
|
|
616
628
|
apiKey: apiKey || previousApiKey || settingApiKey
|
|
617
629
|
};
|
|
618
630
|
}, [apiKey, previousApiKey, settingApiKey]);
|
|
619
|
-
return /*#__PURE__*/
|
|
620
|
-
value: value
|
|
621
|
-
|
|
631
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleKeysContext.Provider, {
|
|
632
|
+
value: value,
|
|
633
|
+
children: children
|
|
634
|
+
});
|
|
622
635
|
}
|
|
623
636
|
|
|
624
|
-
var FontsContext = /*#__PURE__*/React
|
|
637
|
+
var FontsContext = /*#__PURE__*/React.createContext({
|
|
625
638
|
systemFonts: null,
|
|
626
639
|
googleFonts: null,
|
|
627
640
|
customFonts: null
|
|
@@ -634,11 +647,11 @@ var useGoogleFonts = function useGoogleFonts() {
|
|
|
634
647
|
setFonts = _ref$setFonts === void 0 ? null : _ref$setFonts;
|
|
635
648
|
var _useGoogleKeys = useGoogleKeys(),
|
|
636
649
|
apiKey = _useGoogleKeys.apiKey;
|
|
637
|
-
var _useState = React
|
|
650
|
+
var _useState = React.useState(null),
|
|
638
651
|
_useState2 = _slicedToArray(_useState, 2),
|
|
639
652
|
googleFonts = _useState2[0],
|
|
640
653
|
setGoogleFonts = _useState2[1];
|
|
641
|
-
React
|
|
654
|
+
React.useEffect(function () {
|
|
642
655
|
var canceled = false;
|
|
643
656
|
if (apiKey !== null && !disabled) {
|
|
644
657
|
fetch.getJSON("https://www.googleapis.com/webfonts/v1/webfonts?key=".concat(apiKey, "&sort=popularity")).then(function (_ref2) {
|
|
@@ -670,7 +683,7 @@ var useFonts = function useFonts() {
|
|
|
670
683
|
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
671
684
|
_ref3$withoutGoogleFo = _ref3.withoutGoogleFonts,
|
|
672
685
|
withoutGoogleFonts = _ref3$withoutGoogleFo === void 0 ? false : _ref3$withoutGoogleFo;
|
|
673
|
-
var _useContext = React
|
|
686
|
+
var _useContext = React.useContext(FontsContext),
|
|
674
687
|
_useContext$setGoogle = _useContext.setGoogleFonts,
|
|
675
688
|
setGoogleFonts = _useContext$setGoogle === void 0 ? null : _useContext$setGoogle,
|
|
676
689
|
_useContext$systemFon = _useContext.systemFonts,
|
|
@@ -683,7 +696,7 @@ var useFonts = function useFonts() {
|
|
|
683
696
|
disabled: withoutGoogleFonts || googleFonts !== null && googleFonts.length > 0,
|
|
684
697
|
setFonts: setGoogleFonts
|
|
685
698
|
});
|
|
686
|
-
var fonts = React
|
|
699
|
+
var fonts = React.useMemo(function () {
|
|
687
700
|
return {
|
|
688
701
|
systemFonts: systemFonts,
|
|
689
702
|
googleFonts: googleFonts,
|
|
@@ -704,11 +717,11 @@ function FontsProvider(_ref4) {
|
|
|
704
717
|
_useFonts$googleFonts = _useFonts.googleFonts,
|
|
705
718
|
previousGoogleFonts = _useFonts$googleFonts === void 0 ? null : _useFonts$googleFonts,
|
|
706
719
|
previousCustomFonts = _useFonts.customFonts;
|
|
707
|
-
var _useState3 = React
|
|
720
|
+
var _useState3 = React.useState(null),
|
|
708
721
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
709
722
|
googleFonts = _useState4[0],
|
|
710
723
|
setGoogleFonts = _useState4[1];
|
|
711
|
-
var fonts = React
|
|
724
|
+
var fonts = React.useMemo(function () {
|
|
712
725
|
return {
|
|
713
726
|
systemFonts: uniqBy([].concat(_toConsumableArray(previousSystemFonts || []), _toConsumableArray(systemFonts || [])), function (font) {
|
|
714
727
|
return isObject(font) ? font.name : font;
|
|
@@ -722,14 +735,15 @@ function FontsProvider(_ref4) {
|
|
|
722
735
|
setGoogleFonts: setGoogleFonts
|
|
723
736
|
};
|
|
724
737
|
}, [previousSystemFonts, previousGoogleFonts, previousCustomFonts, customFonts, systemFonts, googleFonts, setGoogleFonts]);
|
|
725
|
-
return /*#__PURE__*/
|
|
726
|
-
value: fonts
|
|
727
|
-
|
|
738
|
+
return /*#__PURE__*/jsxRuntime.jsx(FontsContext.Provider, {
|
|
739
|
+
value: fonts,
|
|
740
|
+
children: children
|
|
741
|
+
});
|
|
728
742
|
}
|
|
729
743
|
|
|
730
|
-
var GoogleApiClientContext = /*#__PURE__*/React
|
|
744
|
+
var GoogleApiClientContext = /*#__PURE__*/React.createContext(null);
|
|
731
745
|
var useGoogleApiClient = function useGoogleApiClient() {
|
|
732
|
-
return React
|
|
746
|
+
return React.useContext(GoogleApiClientContext);
|
|
733
747
|
};
|
|
734
748
|
var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
735
749
|
var getDisplayName = function getDisplayName(_ref) {
|
|
@@ -740,10 +754,12 @@ var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
|
740
754
|
return displayName || name || 'Component';
|
|
741
755
|
};
|
|
742
756
|
function WithGoogleApiClientComponent(props) {
|
|
743
|
-
return /*#__PURE__*/
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
757
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleApiClientContext.Consumer, {
|
|
758
|
+
children: function children(client) {
|
|
759
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
760
|
+
googleApiClient: client
|
|
761
|
+
}, props));
|
|
762
|
+
}
|
|
747
763
|
});
|
|
748
764
|
}
|
|
749
765
|
WithGoogleApiClientComponent.displayName = "WithGoogleApiClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -753,11 +769,11 @@ function GoogleApiClientProvider(_ref2) {
|
|
|
753
769
|
var children = _ref2.children;
|
|
754
770
|
var _useGoogleKeys = useGoogleKeys(),
|
|
755
771
|
apiKey = _useGoogleKeys.apiKey;
|
|
756
|
-
var _useState = React
|
|
772
|
+
var _useState = React.useState(null),
|
|
757
773
|
_useState2 = _slicedToArray(_useState, 2),
|
|
758
774
|
client = _useState2[0],
|
|
759
775
|
setClient = _useState2[1];
|
|
760
|
-
React
|
|
776
|
+
React.useEffect(function () {
|
|
761
777
|
services.loadGoogleApi().then(function (gapi) {
|
|
762
778
|
return gapi.client.init({
|
|
763
779
|
apiKey: apiKey
|
|
@@ -768,14 +784,15 @@ function GoogleApiClientProvider(_ref2) {
|
|
|
768
784
|
return setClient(gapi);
|
|
769
785
|
});
|
|
770
786
|
}, [apiKey, setClient]);
|
|
771
|
-
return /*#__PURE__*/
|
|
772
|
-
value: client
|
|
773
|
-
|
|
787
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleApiClientContext.Provider, {
|
|
788
|
+
value: client,
|
|
789
|
+
children: children
|
|
790
|
+
});
|
|
774
791
|
}
|
|
775
792
|
|
|
776
|
-
var GoogleMapsClientContext = /*#__PURE__*/React
|
|
793
|
+
var GoogleMapsClientContext = /*#__PURE__*/React.createContext(null);
|
|
777
794
|
var useGoogleMapsClient = function useGoogleMapsClient() {
|
|
778
|
-
return React
|
|
795
|
+
return React.useContext(GoogleMapsClientContext);
|
|
779
796
|
};
|
|
780
797
|
var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
781
798
|
var getDisplayName = function getDisplayName(_ref) {
|
|
@@ -786,10 +803,12 @@ var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
|
786
803
|
return displayName || name || 'Component';
|
|
787
804
|
};
|
|
788
805
|
function WithGoogleMapsClientComponent(props) {
|
|
789
|
-
return /*#__PURE__*/
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
806
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleMapsClientContext.Consumer, {
|
|
807
|
+
children: function children(client) {
|
|
808
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
809
|
+
googleApiClient: client
|
|
810
|
+
}, props));
|
|
811
|
+
}
|
|
793
812
|
});
|
|
794
813
|
}
|
|
795
814
|
WithGoogleMapsClientComponent.displayName = "WithGoogleMapsClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -804,11 +823,11 @@ function GoogleMapsClientProvider(_ref2) {
|
|
|
804
823
|
var _useGoogleKeys = useGoogleKeys(),
|
|
805
824
|
apiKey = _useGoogleKeys.apiKey;
|
|
806
825
|
var exisitingClient = useGoogleMapsClient();
|
|
807
|
-
var _useState = React
|
|
826
|
+
var _useState = React.useState(exisitingClient),
|
|
808
827
|
_useState2 = _slicedToArray(_useState, 2),
|
|
809
828
|
client = _useState2[0],
|
|
810
829
|
setClient = _useState2[1];
|
|
811
|
-
React
|
|
830
|
+
React.useEffect(function () {
|
|
812
831
|
if (exisitingClient === null) {
|
|
813
832
|
services.loadGoogleMaps({
|
|
814
833
|
apiKey: apiKey,
|
|
@@ -819,32 +838,35 @@ function GoogleMapsClientProvider(_ref2) {
|
|
|
819
838
|
});
|
|
820
839
|
}
|
|
821
840
|
}, [apiKey, locale, libraries, setClient, exisitingClient]);
|
|
822
|
-
return /*#__PURE__*/
|
|
823
|
-
value: client
|
|
824
|
-
|
|
841
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleMapsClientContext.Provider, {
|
|
842
|
+
value: client,
|
|
843
|
+
children: children
|
|
844
|
+
});
|
|
825
845
|
}
|
|
826
846
|
|
|
827
|
-
var ModalsContext = /*#__PURE__*/React
|
|
847
|
+
var ModalsContext = /*#__PURE__*/React.createContext({
|
|
828
848
|
container: null
|
|
829
849
|
});
|
|
830
850
|
var useModals = function useModals() {
|
|
831
|
-
return React
|
|
851
|
+
return React.useContext(ModalsContext) || {};
|
|
832
852
|
};
|
|
833
853
|
var withModals = function withModals(WrappedComponent) {
|
|
834
854
|
function WithModalsComponent(props) {
|
|
835
|
-
return /*#__PURE__*/
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
855
|
+
return /*#__PURE__*/jsxRuntime.jsx(ModalsContext.Consumer, {
|
|
856
|
+
children: function children(_ref) {
|
|
857
|
+
var modals = _ref.modals,
|
|
858
|
+
container = _ref.container,
|
|
859
|
+
setContainer = _ref.setContainer,
|
|
860
|
+
register = _ref.register,
|
|
861
|
+
unregister = _ref.unregister;
|
|
862
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
863
|
+
modalsContainer: container,
|
|
864
|
+
setModalsContainer: setContainer,
|
|
865
|
+
modals: modals,
|
|
866
|
+
registerModal: register,
|
|
867
|
+
unregisterModal: unregister
|
|
868
|
+
}, props));
|
|
869
|
+
}
|
|
848
870
|
});
|
|
849
871
|
}
|
|
850
872
|
WithModalsComponent.displayName = "WithModals(".concat(utils.getDisplayName(WrappedComponent), ")");
|
|
@@ -854,16 +876,16 @@ function ModalsProvider(_ref2) {
|
|
|
854
876
|
var children = _ref2.children,
|
|
855
877
|
_ref2$container = _ref2.container,
|
|
856
878
|
initialContainer = _ref2$container === void 0 ? null : _ref2$container;
|
|
857
|
-
var _useState = React
|
|
879
|
+
var _useState = React.useState(initialContainer),
|
|
858
880
|
_useState2 = _slicedToArray(_useState, 2),
|
|
859
881
|
container = _useState2[0],
|
|
860
882
|
setContainer = _useState2[1];
|
|
861
|
-
var _useState3 = React
|
|
883
|
+
var _useState3 = React.useState([]),
|
|
862
884
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
863
885
|
modals = _useState4[0],
|
|
864
886
|
setModals = _useState4[1];
|
|
865
|
-
var modalsRef = React
|
|
866
|
-
var register = React
|
|
887
|
+
var modalsRef = React.useRef(modals);
|
|
888
|
+
var register = React.useCallback(function (id) {
|
|
867
889
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
868
890
|
var currentModals = modalsRef.current;
|
|
869
891
|
var newModals = [].concat(_toConsumableArray(currentModals), [_objectSpread({
|
|
@@ -872,7 +894,7 @@ function ModalsProvider(_ref2) {
|
|
|
872
894
|
setModals(newModals);
|
|
873
895
|
modalsRef.current = newModals;
|
|
874
896
|
}, [modals, setModals]);
|
|
875
|
-
var unregister = React
|
|
897
|
+
var unregister = React.useCallback(function (id) {
|
|
876
898
|
var currentModals = modalsRef.current;
|
|
877
899
|
var foundIndex = currentModals.findIndex(function (_ref3) {
|
|
878
900
|
var modalId = _ref3.id;
|
|
@@ -887,7 +909,7 @@ function ModalsProvider(_ref2) {
|
|
|
887
909
|
modalsRef.current = newModals;
|
|
888
910
|
}
|
|
889
911
|
}, [modals, setModals]);
|
|
890
|
-
var value = React
|
|
912
|
+
var value = React.useMemo(function () {
|
|
891
913
|
return {
|
|
892
914
|
modals: modals,
|
|
893
915
|
container: container,
|
|
@@ -896,32 +918,35 @@ function ModalsProvider(_ref2) {
|
|
|
896
918
|
unregister: unregister
|
|
897
919
|
};
|
|
898
920
|
}, [modals, container, setContainer, register, unregister]);
|
|
899
|
-
return /*#__PURE__*/
|
|
900
|
-
value: value
|
|
901
|
-
|
|
921
|
+
return /*#__PURE__*/jsxRuntime.jsx(ModalsContext.Provider, {
|
|
922
|
+
value: value,
|
|
923
|
+
children: children
|
|
924
|
+
});
|
|
902
925
|
}
|
|
903
926
|
|
|
904
|
-
var PanelsContext = /*#__PURE__*/React
|
|
927
|
+
var PanelsContext = /*#__PURE__*/React.createContext({
|
|
905
928
|
container: null
|
|
906
929
|
});
|
|
907
930
|
var usePanels = function usePanels() {
|
|
908
|
-
return React
|
|
931
|
+
return React.useContext(PanelsContext) || {};
|
|
909
932
|
};
|
|
910
933
|
var withPanels = function withPanels(WrappedComponent) {
|
|
911
934
|
function WithPanelsComponent(props) {
|
|
912
|
-
return /*#__PURE__*/
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
935
|
+
return /*#__PURE__*/jsxRuntime.jsx(PanelsContext.Consumer, {
|
|
936
|
+
children: function children(_ref) {
|
|
937
|
+
var panels = _ref.panels,
|
|
938
|
+
setContainer = _ref.setContainer,
|
|
939
|
+
container = _ref.container,
|
|
940
|
+
register = _ref.register,
|
|
941
|
+
unregister = _ref.unregister;
|
|
942
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
943
|
+
panelsContainer: container,
|
|
944
|
+
setPanelsContainer: setContainer,
|
|
945
|
+
panels: panels,
|
|
946
|
+
registerPanel: register,
|
|
947
|
+
unregisterPanel: unregister
|
|
948
|
+
}, props));
|
|
949
|
+
}
|
|
925
950
|
});
|
|
926
951
|
}
|
|
927
952
|
WithPanelsComponent.displayName = "WithPanels(".concat(utils.getDisplayName(WrappedComponent), ")");
|
|
@@ -931,16 +956,16 @@ function PanelsProvider(_ref2) {
|
|
|
931
956
|
var children = _ref2.children,
|
|
932
957
|
_ref2$container = _ref2.container,
|
|
933
958
|
initialContainer = _ref2$container === void 0 ? null : _ref2$container;
|
|
934
|
-
var _useState = React
|
|
959
|
+
var _useState = React.useState(initialContainer),
|
|
935
960
|
_useState2 = _slicedToArray(_useState, 2),
|
|
936
961
|
container = _useState2[0],
|
|
937
962
|
setContainer = _useState2[1];
|
|
938
|
-
var _useState3 = React
|
|
963
|
+
var _useState3 = React.useState([]),
|
|
939
964
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
940
965
|
panels = _useState4[0],
|
|
941
966
|
setPanels = _useState4[1];
|
|
942
|
-
var panelsRef = React
|
|
943
|
-
var register = React
|
|
967
|
+
var panelsRef = React.useRef(panels);
|
|
968
|
+
var register = React.useCallback(function (id) {
|
|
944
969
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
945
970
|
var currentPanels = panelsRef.current;
|
|
946
971
|
var newPanels = [].concat(_toConsumableArray(currentPanels), [_objectSpread({
|
|
@@ -949,7 +974,7 @@ function PanelsProvider(_ref2) {
|
|
|
949
974
|
setPanels(newPanels);
|
|
950
975
|
panelsRef.current = newPanels;
|
|
951
976
|
}, [panels, setPanels]);
|
|
952
|
-
var unregister = React
|
|
977
|
+
var unregister = React.useCallback(function (id) {
|
|
953
978
|
var currentPanels = panelsRef.current;
|
|
954
979
|
var foundIndex = currentPanels.findIndex(function (_ref3) {
|
|
955
980
|
var modalId = _ref3.id;
|
|
@@ -964,7 +989,7 @@ function PanelsProvider(_ref2) {
|
|
|
964
989
|
panelsRef.current = newPanels;
|
|
965
990
|
}
|
|
966
991
|
}, [panels, setPanels]);
|
|
967
|
-
var value = React
|
|
992
|
+
var value = React.useMemo(function () {
|
|
968
993
|
return {
|
|
969
994
|
panels: panels,
|
|
970
995
|
setContainer: setContainer,
|
|
@@ -973,9 +998,10 @@ function PanelsProvider(_ref2) {
|
|
|
973
998
|
unregister: unregister
|
|
974
999
|
};
|
|
975
1000
|
}, [panels, setContainer, container, register, unregister]);
|
|
976
|
-
return /*#__PURE__*/
|
|
977
|
-
value: value
|
|
978
|
-
|
|
1001
|
+
return /*#__PURE__*/jsxRuntime.jsx(PanelsContext.Provider, {
|
|
1002
|
+
value: value,
|
|
1003
|
+
children: children
|
|
1004
|
+
});
|
|
979
1005
|
}
|
|
980
1006
|
|
|
981
1007
|
var defaultControlsThemeValue = {
|
|
@@ -995,7 +1021,7 @@ var defaultValue$1 = {
|
|
|
995
1021
|
controlsTheme: defaultControlsThemeValue,
|
|
996
1022
|
currentQualityLevel: null
|
|
997
1023
|
};
|
|
998
|
-
var PlaybackContext = /*#__PURE__*/React
|
|
1024
|
+
var PlaybackContext = /*#__PURE__*/React.createContext(_objectSpread(_objectSpread({}, defaultValue$1), {}, {
|
|
999
1025
|
setMuted: function setMuted() {},
|
|
1000
1026
|
setPlaying: function setPlaying() {},
|
|
1001
1027
|
setControls: function setControls() {},
|
|
@@ -1008,7 +1034,7 @@ var PlaybackContext = /*#__PURE__*/React$1.createContext(_objectSpread(_objectSp
|
|
|
1008
1034
|
setIsBackground: function setIsBackground() {}
|
|
1009
1035
|
}));
|
|
1010
1036
|
var usePlaybackContext = function usePlaybackContext() {
|
|
1011
|
-
return React
|
|
1037
|
+
return React.useContext(PlaybackContext);
|
|
1012
1038
|
};
|
|
1013
1039
|
var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
1014
1040
|
var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
@@ -1018,12 +1044,12 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1018
1044
|
setMedia = _usePlaybackContext.setMedia,
|
|
1019
1045
|
setIsBackground = _usePlaybackContext.setIsBackground,
|
|
1020
1046
|
media = _usePlaybackContext.media;
|
|
1021
|
-
var mediaRef = React
|
|
1047
|
+
var mediaRef = React.useRef(null);
|
|
1022
1048
|
|
|
1023
1049
|
// Cleanup: clear media registration when this screen deactivates or unmounts.
|
|
1024
1050
|
// Note: we cannot check mediaRef.current here because React clears callback refs
|
|
1025
1051
|
// before running effect cleanups, so mediaRef.current is always null at this point.
|
|
1026
|
-
React
|
|
1052
|
+
React.useEffect(function () {
|
|
1027
1053
|
return function () {
|
|
1028
1054
|
if (active) {
|
|
1029
1055
|
setMedia(null);
|
|
@@ -1033,7 +1059,7 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1033
1059
|
}, [active, setMedia, setIsBackground, updateKey]);
|
|
1034
1060
|
|
|
1035
1061
|
// Register media with context when active and no media is registered
|
|
1036
|
-
React
|
|
1062
|
+
React.useEffect(function () {
|
|
1037
1063
|
if (!active || mediaRef.current === null || media !== null) {
|
|
1038
1064
|
return;
|
|
1039
1065
|
}
|
|
@@ -1063,43 +1089,43 @@ function PlaybackProvider(_ref) {
|
|
|
1063
1089
|
_ref$currentQualityLe = _ref.currentQualityLevel,
|
|
1064
1090
|
initialCurrentQualityLevel = _ref$currentQualityLe === void 0 ? null : _ref$currentQualityLe,
|
|
1065
1091
|
children = _ref.children;
|
|
1066
|
-
var _useState = React
|
|
1092
|
+
var _useState = React.useState(initialMuted),
|
|
1067
1093
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1068
1094
|
muted = _useState2[0],
|
|
1069
1095
|
setMuted = _useState2[1];
|
|
1070
|
-
var _useState3 = React
|
|
1096
|
+
var _useState3 = React.useState(initialPlaying),
|
|
1071
1097
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
1072
1098
|
playing = _useState4[0],
|
|
1073
1099
|
setPlaying = _useState4[1];
|
|
1074
|
-
var _useState5 = React
|
|
1100
|
+
var _useState5 = React.useState(null),
|
|
1075
1101
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1076
1102
|
media = _useState6[0],
|
|
1077
1103
|
setMedia = _useState6[1];
|
|
1078
|
-
var _useState7 = React
|
|
1104
|
+
var _useState7 = React.useState(false),
|
|
1079
1105
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
1080
1106
|
isBackground = _useState8[0],
|
|
1081
1107
|
setIsBackground = _useState8[1];
|
|
1082
|
-
var _useState9 = React
|
|
1108
|
+
var _useState9 = React.useState(initialControls),
|
|
1083
1109
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
1084
1110
|
controls = _useState0[0],
|
|
1085
1111
|
setControls = _useState0[1];
|
|
1086
|
-
var _useState1 = React
|
|
1112
|
+
var _useState1 = React.useState(initialControlsSuggestPlay),
|
|
1087
1113
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
1088
1114
|
controlsSuggestPlay = _useState10[0],
|
|
1089
1115
|
setControlsSuggestPlay = _useState10[1];
|
|
1090
|
-
var _useState11 = React
|
|
1116
|
+
var _useState11 = React.useState(initialControlsVisible),
|
|
1091
1117
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
1092
1118
|
controlsVisible = _useState12[0],
|
|
1093
1119
|
setControlsVisible = _useState12[1];
|
|
1094
|
-
var _useState13 = React
|
|
1120
|
+
var _useState13 = React.useState(initialControlsTheme),
|
|
1095
1121
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
1096
1122
|
controlsTheme = _useState14[0],
|
|
1097
1123
|
setControlsTheme = _useState14[1];
|
|
1098
|
-
var _useState15 = React
|
|
1124
|
+
var _useState15 = React.useState(initialCurrentQualityLevel),
|
|
1099
1125
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
1100
1126
|
currentQualityLevel = _useState16[0],
|
|
1101
1127
|
setCurrentQualityLevel = _useState16[1];
|
|
1102
|
-
var finalSetControls = React
|
|
1128
|
+
var finalSetControls = React.useCallback(function (newControls) {
|
|
1103
1129
|
if (newControls) {
|
|
1104
1130
|
setControls(true);
|
|
1105
1131
|
setControlsVisible(true);
|
|
@@ -1110,10 +1136,10 @@ function PlaybackProvider(_ref) {
|
|
|
1110
1136
|
setControlsSuggestPlay(false);
|
|
1111
1137
|
}
|
|
1112
1138
|
}, [setControls, setControlsVisible, setControlsSuggestPlay]);
|
|
1113
|
-
var finalSetControlsTheme = React
|
|
1139
|
+
var finalSetControlsTheme = React.useCallback(function (newTheme) {
|
|
1114
1140
|
setControlsTheme(_objectSpread(_objectSpread({}, defaultControlsThemeValue), newTheme));
|
|
1115
1141
|
}, [setControlsTheme]);
|
|
1116
|
-
var finalSetPlaying = React
|
|
1142
|
+
var finalSetPlaying = React.useCallback(function (value) {
|
|
1117
1143
|
if (value) {
|
|
1118
1144
|
setControlsSuggestPlay(false);
|
|
1119
1145
|
}
|
|
@@ -1121,19 +1147,19 @@ function PlaybackProvider(_ref) {
|
|
|
1121
1147
|
}, [setPlaying, setControlsSuggestPlay]);
|
|
1122
1148
|
|
|
1123
1149
|
// Reset on media change
|
|
1124
|
-
React
|
|
1150
|
+
React.useEffect(function () {
|
|
1125
1151
|
setControlsSuggestPlay(false);
|
|
1126
1152
|
}, [media, setControlsSuggestPlay]);
|
|
1127
1153
|
|
|
1128
1154
|
// Handle media ended
|
|
1129
|
-
var _useState17 = React
|
|
1155
|
+
var _useState17 = React.useState(false),
|
|
1130
1156
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
1131
1157
|
completed = _useState18[0],
|
|
1132
1158
|
setCompleted = _useState18[1];
|
|
1133
|
-
var onMediaCompleted = React
|
|
1159
|
+
var onMediaCompleted = React.useCallback(function () {
|
|
1134
1160
|
return setCompleted(true);
|
|
1135
1161
|
}, [setCompleted]);
|
|
1136
|
-
React
|
|
1162
|
+
React.useEffect(function () {
|
|
1137
1163
|
if (media !== null) {
|
|
1138
1164
|
media.addEventListener('ended', onMediaCompleted);
|
|
1139
1165
|
}
|
|
@@ -1144,13 +1170,13 @@ function PlaybackProvider(_ref) {
|
|
|
1144
1170
|
setCompleted(false);
|
|
1145
1171
|
};
|
|
1146
1172
|
}, [media, onMediaCompleted, setCompleted]);
|
|
1147
|
-
var showControls = React
|
|
1173
|
+
var showControls = React.useCallback(function () {
|
|
1148
1174
|
return setControlsVisible(true);
|
|
1149
1175
|
}, [setControlsVisible]);
|
|
1150
|
-
var hideControls = React
|
|
1176
|
+
var hideControls = React.useCallback(function () {
|
|
1151
1177
|
setControlsVisible(false);
|
|
1152
1178
|
}, [setControlsVisible]);
|
|
1153
|
-
var hasAudio = React
|
|
1179
|
+
var hasAudio = React.useMemo(function () {
|
|
1154
1180
|
if (media === null || media.tagName.toLowerCase() !== 'video') {
|
|
1155
1181
|
return false;
|
|
1156
1182
|
}
|
|
@@ -1162,13 +1188,13 @@ function PlaybackProvider(_ref) {
|
|
|
1162
1188
|
}
|
|
1163
1189
|
return media.dataset.hasAudio === 'true' || media.dataset.hasAudio === true;
|
|
1164
1190
|
}, [media]);
|
|
1165
|
-
var finalSetCurrentQualityLevel = React
|
|
1191
|
+
var finalSetCurrentQualityLevel = React.useCallback(function (level) {
|
|
1166
1192
|
var fromRef = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1167
1193
|
if (fromRef === null || media === null || fromRef === media) {
|
|
1168
1194
|
setCurrentQualityLevel(level);
|
|
1169
1195
|
}
|
|
1170
1196
|
}, [media, setCurrentQualityLevel]);
|
|
1171
|
-
var value = React
|
|
1197
|
+
var value = React.useMemo(function () {
|
|
1172
1198
|
return {
|
|
1173
1199
|
muted: muted,
|
|
1174
1200
|
playing: playing && !paused,
|
|
@@ -1194,9 +1220,10 @@ function PlaybackProvider(_ref) {
|
|
|
1194
1220
|
setCurrentQualityLevel: finalSetCurrentQualityLevel
|
|
1195
1221
|
};
|
|
1196
1222
|
}, [muted, playing, completed, paused, controls, controlsSuggestPlay, controlsVisible, controlsTheme, media, hasAudio, currentQualityLevel, setMuted, setIsBackground, isBackground, finalSetPlaying, finalSetControls, finalSetControlsTheme, setControlsSuggestPlay, setControlsVisible, showControls, hideControls, setMedia, finalSetCurrentQualityLevel]);
|
|
1197
|
-
return /*#__PURE__*/
|
|
1198
|
-
value: value
|
|
1199
|
-
|
|
1223
|
+
return /*#__PURE__*/jsxRuntime.jsx(PlaybackContext.Provider, {
|
|
1224
|
+
value: value,
|
|
1225
|
+
children: children
|
|
1226
|
+
});
|
|
1200
1227
|
}
|
|
1201
1228
|
|
|
1202
1229
|
var useRoutePush = function useRoutePush() {
|
|
@@ -1204,7 +1231,7 @@ var useRoutePush = function useRoutePush() {
|
|
|
1204
1231
|
var _useLocation = wouter.useLocation(),
|
|
1205
1232
|
_useLocation2 = _slicedToArray(_useLocation, 2),
|
|
1206
1233
|
navigate = _useLocation2[1];
|
|
1207
|
-
var push = React
|
|
1234
|
+
var push = React.useCallback(function (route, data) {
|
|
1208
1235
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1209
1236
|
args[_key - 2] = arguments[_key];
|
|
1210
1237
|
}
|
|
@@ -1226,19 +1253,19 @@ var useRouteBack = function useRouteBack() {
|
|
|
1226
1253
|
var _useLocation3 = wouter.useLocation(),
|
|
1227
1254
|
_useLocation4 = _slicedToArray(_useLocation3, 2),
|
|
1228
1255
|
navigate = _useLocation4[1];
|
|
1229
|
-
var back = React
|
|
1256
|
+
var back = React.useCallback(function () {
|
|
1230
1257
|
return navigate(-1);
|
|
1231
1258
|
}, [navigate, url]);
|
|
1232
1259
|
return back;
|
|
1233
1260
|
};
|
|
1234
1261
|
|
|
1235
|
-
var ScreenContext = /*#__PURE__*/React
|
|
1262
|
+
var ScreenContext = /*#__PURE__*/React.createContext({
|
|
1236
1263
|
data: null,
|
|
1237
1264
|
definition: null,
|
|
1238
1265
|
renderContext: null
|
|
1239
1266
|
});
|
|
1240
1267
|
var useScreen = function useScreen() {
|
|
1241
|
-
return React
|
|
1268
|
+
return React.useContext(ScreenContext);
|
|
1242
1269
|
};
|
|
1243
1270
|
var useScreenDefinition = function useScreenDefinition() {
|
|
1244
1271
|
var intl = reactIntl.useIntl();
|
|
@@ -1248,7 +1275,7 @@ var useScreenDefinition = function useScreenDefinition() {
|
|
|
1248
1275
|
var _ref2 = definition || {},
|
|
1249
1276
|
_ref2$fields = _ref2.fields,
|
|
1250
1277
|
fields = _ref2$fields === void 0 ? null : _ref2$fields;
|
|
1251
|
-
var finalFields = React
|
|
1278
|
+
var finalFields = React.useMemo(function () {
|
|
1252
1279
|
return fields !== null ? [].concat(_toConsumableArray(fields), [utils.getScreenExtraField(intl)]) : null;
|
|
1253
1280
|
}, [fields]);
|
|
1254
1281
|
return _objectSpread(_objectSpread({}, definition), {}, {
|
|
@@ -1313,7 +1340,7 @@ function ScreenProvider(_ref6) {
|
|
|
1313
1340
|
var finalDefinition = definition || contextDefinition || previousDefinition;
|
|
1314
1341
|
var finalRenderContext = renderContext || previousContext || 'view';
|
|
1315
1342
|
var finalScreenState = screenState || previousScreenState || null;
|
|
1316
|
-
var value = React
|
|
1343
|
+
var value = React.useMemo(function () {
|
|
1317
1344
|
return {
|
|
1318
1345
|
data: finalData,
|
|
1319
1346
|
definition: finalDefinition,
|
|
@@ -1321,13 +1348,14 @@ function ScreenProvider(_ref6) {
|
|
|
1321
1348
|
screenState: finalScreenState
|
|
1322
1349
|
};
|
|
1323
1350
|
}, [finalData, finalDefinition, finalRenderContext, finalScreenState]);
|
|
1324
|
-
return /*#__PURE__*/
|
|
1325
|
-
value: value
|
|
1326
|
-
|
|
1351
|
+
return /*#__PURE__*/jsxRuntime.jsx(ScreenContext.Provider, {
|
|
1352
|
+
value: value,
|
|
1353
|
+
children: children
|
|
1354
|
+
});
|
|
1327
1355
|
}
|
|
1328
1356
|
|
|
1329
1357
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
1330
|
-
var ScreenSizeContext = /*#__PURE__*/React
|
|
1358
|
+
var ScreenSizeContext = /*#__PURE__*/React.createContext({
|
|
1331
1359
|
screen: null,
|
|
1332
1360
|
screens: [],
|
|
1333
1361
|
width: 0,
|
|
@@ -1336,7 +1364,7 @@ var ScreenSizeContext = /*#__PURE__*/React$1.createContext({
|
|
|
1336
1364
|
landscape: false
|
|
1337
1365
|
});
|
|
1338
1366
|
var useScreenSize = function useScreenSize() {
|
|
1339
|
-
return React
|
|
1367
|
+
return React.useContext(ScreenSizeContext);
|
|
1340
1368
|
};
|
|
1341
1369
|
|
|
1342
1370
|
// Note: this is done to avoid excessive renders on the screens that use the context
|
|
@@ -1349,16 +1377,17 @@ function ScreenSizeProvider(_ref) {
|
|
|
1349
1377
|
nextWidth = size.width,
|
|
1350
1378
|
nextHeight = size.height,
|
|
1351
1379
|
nextResolution = size.resolution;
|
|
1352
|
-
var currentSize = React
|
|
1380
|
+
var currentSize = React.useMemo(function () {
|
|
1353
1381
|
return size;
|
|
1354
1382
|
}, [nextScreen, nextWidth, nextHeight, nextResolution]);
|
|
1355
|
-
return /*#__PURE__*/
|
|
1356
|
-
value: currentSize
|
|
1357
|
-
|
|
1383
|
+
return /*#__PURE__*/jsxRuntime.jsx(ScreenSizeContext.Provider, {
|
|
1384
|
+
value: currentSize,
|
|
1385
|
+
children: children
|
|
1386
|
+
});
|
|
1358
1387
|
}
|
|
1359
1388
|
|
|
1360
1389
|
var useTracking = function useTracking() {
|
|
1361
|
-
return React
|
|
1390
|
+
return React.useContext(tracking.TrackingContext);
|
|
1362
1391
|
};
|
|
1363
1392
|
function TrackingProvider(_ref) {
|
|
1364
1393
|
var _ref$variables = _ref.variables,
|
|
@@ -1369,8 +1398,8 @@ function TrackingProvider(_ref) {
|
|
|
1369
1398
|
paused = _ref$paused === void 0 ? false : _ref$paused,
|
|
1370
1399
|
children = _ref.children;
|
|
1371
1400
|
var contextTracking = useTracking() || null;
|
|
1372
|
-
var refTracking = React
|
|
1373
|
-
var tracking$1 = React
|
|
1401
|
+
var refTracking = React.useRef(null);
|
|
1402
|
+
var tracking$1 = React.useMemo(function () {
|
|
1374
1403
|
if (refTracking.current === null) {
|
|
1375
1404
|
refTracking.current = new core.Tracking({
|
|
1376
1405
|
variables: _objectSpread(_objectSpread({}, contextTracking !== null ? contextTracking.getVariables() : null), variables),
|
|
@@ -1384,9 +1413,10 @@ function TrackingProvider(_ref) {
|
|
|
1384
1413
|
}
|
|
1385
1414
|
return refTracking.current;
|
|
1386
1415
|
}, [contextTracking, variables, disabled, paused]);
|
|
1387
|
-
return /*#__PURE__*/
|
|
1388
|
-
tracking: tracking$1
|
|
1389
|
-
|
|
1416
|
+
return /*#__PURE__*/jsxRuntime.jsx(tracking.TrackingContainer, {
|
|
1417
|
+
tracking: tracking$1,
|
|
1418
|
+
children: children
|
|
1419
|
+
});
|
|
1390
1420
|
}
|
|
1391
1421
|
|
|
1392
1422
|
var defaultValue = {
|
|
@@ -1401,12 +1431,12 @@ var defaultValue = {
|
|
|
1401
1431
|
disableInteraction: function disableInteraction() {},
|
|
1402
1432
|
enableInteraction: function enableInteraction() {}
|
|
1403
1433
|
};
|
|
1404
|
-
var ViewerContext = /*#__PURE__*/React
|
|
1434
|
+
var ViewerContext = /*#__PURE__*/React.createContext(_objectSpread(_objectSpread({}, defaultValue), {}, {
|
|
1405
1435
|
webView: null,
|
|
1406
1436
|
setWebView: function setWebView() {}
|
|
1407
1437
|
}));
|
|
1408
1438
|
var useViewerContext = function useViewerContext() {
|
|
1409
|
-
return React
|
|
1439
|
+
return React.useContext(ViewerContext);
|
|
1410
1440
|
};
|
|
1411
1441
|
var useViewerSize = function useViewerSize() {
|
|
1412
1442
|
var _useViewerContext = useViewerContext(),
|
|
@@ -1450,7 +1480,7 @@ var useViewerWebView = function useViewerWebView() {
|
|
|
1450
1480
|
var _useViewerContext6 = useViewerContext(),
|
|
1451
1481
|
webView = _useViewerContext6.webView,
|
|
1452
1482
|
setWebView = _useViewerContext6.setWebView;
|
|
1453
|
-
var value = React
|
|
1483
|
+
var value = React.useMemo(function () {
|
|
1454
1484
|
return _objectSpread(_objectSpread({}, webView), {}, {
|
|
1455
1485
|
opened: webView !== null,
|
|
1456
1486
|
open: function open(newWebView) {
|
|
@@ -1493,11 +1523,11 @@ function ViewerProvider(_ref) {
|
|
|
1493
1523
|
disableInteraction = _ref$disableInteracti === void 0 ? function () {} : _ref$disableInteracti,
|
|
1494
1524
|
_ref$enableInteractio = _ref.enableInteraction,
|
|
1495
1525
|
enableInteraction = _ref$enableInteractio === void 0 ? function () {} : _ref$enableInteractio;
|
|
1496
|
-
var _useState = React
|
|
1526
|
+
var _useState = React.useState(null),
|
|
1497
1527
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1498
1528
|
webView = _useState2[0],
|
|
1499
1529
|
setWebView = _useState2[1];
|
|
1500
|
-
var value = React
|
|
1530
|
+
var value = React.useMemo(function () {
|
|
1501
1531
|
return {
|
|
1502
1532
|
containerRef: containerRef,
|
|
1503
1533
|
events: events,
|
|
@@ -1516,17 +1546,18 @@ function ViewerProvider(_ref) {
|
|
|
1516
1546
|
setWebView: setWebView
|
|
1517
1547
|
};
|
|
1518
1548
|
}, [containerRef, events, menuVisible, menuOverScreen, width, height, topHeight, bottomHeight, bottomSidesWidth, gotoNextScreen, gotoPreviousScreen, disableInteraction, enableInteraction, webView, setWebView]);
|
|
1519
|
-
return /*#__PURE__*/
|
|
1520
|
-
value: value
|
|
1521
|
-
|
|
1549
|
+
return /*#__PURE__*/jsxRuntime.jsx(ViewerContext.Provider, {
|
|
1550
|
+
value: value,
|
|
1551
|
+
children: children
|
|
1552
|
+
});
|
|
1522
1553
|
}
|
|
1523
1554
|
|
|
1524
|
-
var VisitorContext = /*#__PURE__*/React
|
|
1555
|
+
var VisitorContext = /*#__PURE__*/React.createContext({
|
|
1525
1556
|
visitor: null,
|
|
1526
1557
|
setVisitor: function setVisitor() {}
|
|
1527
1558
|
});
|
|
1528
1559
|
function useVisitorContext() {
|
|
1529
|
-
var _useContext = React
|
|
1560
|
+
var _useContext = React.useContext(VisitorContext),
|
|
1530
1561
|
visitor = _useContext.visitor,
|
|
1531
1562
|
setVisitor = _useContext.setVisitor;
|
|
1532
1563
|
return {
|
|
@@ -1535,12 +1566,12 @@ function useVisitorContext() {
|
|
|
1535
1566
|
};
|
|
1536
1567
|
}
|
|
1537
1568
|
function useVisitor() {
|
|
1538
|
-
var _useContext2 = React
|
|
1569
|
+
var _useContext2 = React.useContext(VisitorContext),
|
|
1539
1570
|
visitor = _useContext2.visitor;
|
|
1540
1571
|
return visitor;
|
|
1541
1572
|
}
|
|
1542
1573
|
function useSetVisitor() {
|
|
1543
|
-
var _useContext3 = React
|
|
1574
|
+
var _useContext3 = React.useContext(VisitorContext),
|
|
1544
1575
|
setVisitor = _useContext3.setVisitor;
|
|
1545
1576
|
return setVisitor;
|
|
1546
1577
|
}
|
|
@@ -1548,20 +1579,20 @@ function VisitorProvider(_ref) {
|
|
|
1548
1579
|
var _ref$visitor = _ref.visitor,
|
|
1549
1580
|
providedVisitor = _ref$visitor === void 0 ? null : _ref$visitor,
|
|
1550
1581
|
children = _ref.children;
|
|
1551
|
-
var _useState = React
|
|
1582
|
+
var _useState = React.useState(isString(providedVisitor) ? {
|
|
1552
1583
|
id: providedVisitor
|
|
1553
1584
|
} : providedVisitor),
|
|
1554
1585
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1555
1586
|
visitor = _useState2[0],
|
|
1556
1587
|
_setVisitor = _useState2[1];
|
|
1557
|
-
React
|
|
1588
|
+
React.useEffect(function () {
|
|
1558
1589
|
if (providedVisitor !== visitor) {
|
|
1559
1590
|
_setVisitor(isString(providedVisitor) ? {
|
|
1560
1591
|
id: providedVisitor
|
|
1561
1592
|
} : providedVisitor);
|
|
1562
1593
|
}
|
|
1563
1594
|
}, [providedVisitor, _setVisitor]);
|
|
1564
|
-
var value = React
|
|
1595
|
+
var value = React.useMemo(function () {
|
|
1565
1596
|
return {
|
|
1566
1597
|
visitor: visitor,
|
|
1567
1598
|
setVisitor: function setVisitor(newVisitor) {
|
|
@@ -1571,9 +1602,10 @@ function VisitorProvider(_ref) {
|
|
|
1571
1602
|
}
|
|
1572
1603
|
};
|
|
1573
1604
|
}, [visitor, _setVisitor]);
|
|
1574
|
-
return /*#__PURE__*/
|
|
1575
|
-
value: value
|
|
1576
|
-
|
|
1605
|
+
return /*#__PURE__*/jsxRuntime.jsx(VisitorContext.Provider, {
|
|
1606
|
+
value: value,
|
|
1607
|
+
children: children
|
|
1608
|
+
});
|
|
1577
1609
|
}
|
|
1578
1610
|
|
|
1579
1611
|
Object.defineProperty(exports, "RoutesContext", {
|