@panneau/core 4.0.2 → 4.0.5
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/contexts.js +103 -81
- package/lib/contexts.js +163 -142
- package/package.json +2 -10
package/es/contexts.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import isString from 'lodash-es/isString';
|
|
3
|
-
import
|
|
3
|
+
import { createContext, useContext, useMemo, useState, useEffect, useRef, useCallback } from 'react';
|
|
4
4
|
import { ComponentsManager, FieldsManager, Tracking } from '@panneau/core';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
6
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
6
7
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
7
8
|
import uniqBy from 'lodash-es/uniqBy';
|
|
@@ -29,7 +30,7 @@ var BUTTONS_NAMESPACE = 'buttons';
|
|
|
29
30
|
var PAGES_NAMESPACE = 'pages';
|
|
30
31
|
var PREVIEWS_NAMESPACE = 'previews';
|
|
31
32
|
var APP_NAMESPACE = 'app';
|
|
32
|
-
var ComponentsContext = /*#__PURE__*/
|
|
33
|
+
var ComponentsContext = /*#__PURE__*/createContext(null);
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Hooks
|
|
@@ -242,12 +243,13 @@ function ComponentsProvider(_ref) {
|
|
|
242
243
|
var finalManager = useMemo(function () {
|
|
243
244
|
return new ComponentsManager(_objectSpread(_objectSpread(_objectSpread({}, previousManager !== null ? previousManager.getComponents() : null), manager !== null ? manager.getComponents() : null), new ComponentsManager(components).addNamespace(namespace).getComponents()));
|
|
244
245
|
}, [previousManager, manager, components, namespace]);
|
|
245
|
-
return /*#__PURE__*/
|
|
246
|
-
value: finalManager
|
|
247
|
-
|
|
246
|
+
return /*#__PURE__*/jsx(ComponentsContext, {
|
|
247
|
+
value: finalManager,
|
|
248
|
+
children: children
|
|
249
|
+
});
|
|
248
250
|
}
|
|
249
251
|
|
|
250
|
-
var DefinitionContext = /*#__PURE__*/
|
|
252
|
+
var DefinitionContext = /*#__PURE__*/createContext(null);
|
|
251
253
|
var useDefinitionContext = function useDefinitionContext() {
|
|
252
254
|
return useContext(DefinitionContext);
|
|
253
255
|
};
|
|
@@ -258,12 +260,13 @@ var useDefinition = function useDefinition() {
|
|
|
258
260
|
function DefinitionProvider(_ref) {
|
|
259
261
|
var definition = _ref.definition,
|
|
260
262
|
children = _ref.children;
|
|
261
|
-
return /*#__PURE__*/
|
|
262
|
-
value: definition
|
|
263
|
-
|
|
263
|
+
return /*#__PURE__*/jsx(DefinitionContext, {
|
|
264
|
+
value: definition,
|
|
265
|
+
children: children
|
|
266
|
+
});
|
|
264
267
|
}
|
|
265
268
|
|
|
266
|
-
var FieldsContext = /*#__PURE__*/
|
|
269
|
+
var FieldsContext = /*#__PURE__*/createContext(null);
|
|
267
270
|
var useFieldsManager = function useFieldsManager() {
|
|
268
271
|
return useContext(FieldsContext);
|
|
269
272
|
};
|
|
@@ -296,15 +299,17 @@ function FieldsProvider(_ref) {
|
|
|
296
299
|
return isString(component) ? map : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, component));
|
|
297
300
|
}, {});
|
|
298
301
|
}, [finalManager]);
|
|
299
|
-
return /*#__PURE__*/
|
|
300
|
-
value: finalManager
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
return /*#__PURE__*/jsx(FieldsContext, {
|
|
303
|
+
value: finalManager,
|
|
304
|
+
children: /*#__PURE__*/jsx(ComponentsProvider, {
|
|
305
|
+
namespace: FIELDS_NAMESPACE,
|
|
306
|
+
components: components,
|
|
307
|
+
children: children
|
|
308
|
+
})
|
|
309
|
+
});
|
|
305
310
|
}
|
|
306
311
|
|
|
307
|
-
var GoogleKeysContext = /*#__PURE__*/
|
|
312
|
+
var GoogleKeysContext = /*#__PURE__*/createContext({
|
|
308
313
|
apiKey: null
|
|
309
314
|
});
|
|
310
315
|
var useGoogleKeys = function useGoogleKeys() {
|
|
@@ -321,12 +326,13 @@ function GoogleKeysProvider(_ref) {
|
|
|
321
326
|
apiKey: apiKey || previousApiKey
|
|
322
327
|
};
|
|
323
328
|
}, [previousApiKey, apiKey]);
|
|
324
|
-
return /*#__PURE__*/
|
|
325
|
-
value: value
|
|
326
|
-
|
|
329
|
+
return /*#__PURE__*/jsx(GoogleKeysContext, {
|
|
330
|
+
value: value,
|
|
331
|
+
children: children
|
|
332
|
+
});
|
|
327
333
|
}
|
|
328
334
|
|
|
329
|
-
var FontsContext = /*#__PURE__*/
|
|
335
|
+
var FontsContext = /*#__PURE__*/createContext({
|
|
330
336
|
systemFonts: null,
|
|
331
337
|
googleFonts: null,
|
|
332
338
|
customFonts: null
|
|
@@ -429,12 +435,13 @@ function FontsProvider(_ref4) {
|
|
|
429
435
|
setGoogleFonts: setGoogleFonts
|
|
430
436
|
};
|
|
431
437
|
}, [previousSystemFonts, previousGoogleFonts, previousCustomFonts, customFonts, systemFonts, googleFonts, setGoogleFonts]);
|
|
432
|
-
return /*#__PURE__*/
|
|
433
|
-
value: fonts
|
|
434
|
-
|
|
438
|
+
return /*#__PURE__*/jsx(FontsContext, {
|
|
439
|
+
value: fonts,
|
|
440
|
+
children: children
|
|
441
|
+
});
|
|
435
442
|
}
|
|
436
443
|
|
|
437
|
-
var FormContext = /*#__PURE__*/
|
|
444
|
+
var FormContext = /*#__PURE__*/createContext(null);
|
|
438
445
|
var useForm = function useForm() {
|
|
439
446
|
return useContext(FormContext);
|
|
440
447
|
};
|
|
@@ -458,12 +465,13 @@ function FormProvider(_ref) {
|
|
|
458
465
|
setValue: setValue
|
|
459
466
|
};
|
|
460
467
|
}, [value, setValue]);
|
|
461
|
-
return /*#__PURE__*/
|
|
462
|
-
value: values
|
|
463
|
-
|
|
468
|
+
return /*#__PURE__*/jsx(FormContext, {
|
|
469
|
+
value: values,
|
|
470
|
+
children: children
|
|
471
|
+
});
|
|
464
472
|
}
|
|
465
473
|
|
|
466
|
-
var GoogleApiClientContext = /*#__PURE__*/
|
|
474
|
+
var GoogleApiClientContext = /*#__PURE__*/createContext(null);
|
|
467
475
|
var useGoogleApiClient = function useGoogleApiClient() {
|
|
468
476
|
return useContext(GoogleApiClientContext);
|
|
469
477
|
};
|
|
@@ -476,10 +484,12 @@ var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
|
476
484
|
return displayName || name || 'Component';
|
|
477
485
|
};
|
|
478
486
|
var WithGoogleApiClientComponent = function WithGoogleApiClientComponent(props) {
|
|
479
|
-
return /*#__PURE__*/
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
487
|
+
return /*#__PURE__*/jsx(GoogleApiClientContext.Consumer, {
|
|
488
|
+
children: function children(client) {
|
|
489
|
+
return /*#__PURE__*/jsx(WrappedComponent, _objectSpread({
|
|
490
|
+
googleApiClient: client
|
|
491
|
+
}, props));
|
|
492
|
+
}
|
|
483
493
|
});
|
|
484
494
|
};
|
|
485
495
|
WithGoogleApiClientComponent.displayName = "WithGoogleApiClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -504,12 +514,13 @@ function GoogleApiClientProvider(_ref2) {
|
|
|
504
514
|
return setClient(gapi);
|
|
505
515
|
});
|
|
506
516
|
}, [apiKey, setClient]);
|
|
507
|
-
return /*#__PURE__*/
|
|
508
|
-
value: client
|
|
509
|
-
|
|
517
|
+
return /*#__PURE__*/jsx(GoogleApiClientContext, {
|
|
518
|
+
value: client,
|
|
519
|
+
children: children
|
|
520
|
+
});
|
|
510
521
|
}
|
|
511
522
|
|
|
512
|
-
var GoogleMapsClientContext = /*#__PURE__*/
|
|
523
|
+
var GoogleMapsClientContext = /*#__PURE__*/createContext(null);
|
|
513
524
|
var useGoogleMapsClient = function useGoogleMapsClient() {
|
|
514
525
|
return useContext(GoogleMapsClientContext);
|
|
515
526
|
};
|
|
@@ -522,10 +533,12 @@ var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
|
522
533
|
return displayName || name || 'Component';
|
|
523
534
|
};
|
|
524
535
|
var WithGoogleMapsClientComponent = function WithGoogleMapsClientComponent(props) {
|
|
525
|
-
return /*#__PURE__*/
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
536
|
+
return /*#__PURE__*/jsx(GoogleMapsClientContext.Consumer, {
|
|
537
|
+
children: function children(client) {
|
|
538
|
+
return /*#__PURE__*/jsx(WrappedComponent, _objectSpread({
|
|
539
|
+
googleApiClient: client
|
|
540
|
+
}, props));
|
|
541
|
+
}
|
|
529
542
|
});
|
|
530
543
|
};
|
|
531
544
|
WithGoogleMapsClientComponent.displayName = "WithGoogleMapsClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -555,13 +568,14 @@ function GoogleMapsClientProvider(_ref2) {
|
|
|
555
568
|
});
|
|
556
569
|
}
|
|
557
570
|
}, [apiKey, locale, libraries, setClient, exisitingClient]);
|
|
558
|
-
return /*#__PURE__*/
|
|
559
|
-
value: client
|
|
560
|
-
|
|
571
|
+
return /*#__PURE__*/jsx(GoogleMapsClientContext, {
|
|
572
|
+
value: client,
|
|
573
|
+
children: children
|
|
574
|
+
});
|
|
561
575
|
}
|
|
562
576
|
|
|
563
577
|
var defaultLocales = ['en', 'fr'];
|
|
564
|
-
var LocalesContext = /*#__PURE__*/
|
|
578
|
+
var LocalesContext = /*#__PURE__*/createContext({
|
|
565
579
|
locales: defaultLocales
|
|
566
580
|
});
|
|
567
581
|
var useLocalesContext = function useLocalesContext() {
|
|
@@ -595,12 +609,13 @@ function LocalesProvider(_ref) {
|
|
|
595
609
|
locales: locales
|
|
596
610
|
};
|
|
597
611
|
}, [locales]);
|
|
598
|
-
return /*#__PURE__*/
|
|
599
|
-
value: value
|
|
600
|
-
|
|
612
|
+
return /*#__PURE__*/jsx(LocalesContext, {
|
|
613
|
+
value: value,
|
|
614
|
+
children: children
|
|
615
|
+
});
|
|
601
616
|
}
|
|
602
617
|
|
|
603
|
-
var ModalContext = /*#__PURE__*/
|
|
618
|
+
var ModalContext = /*#__PURE__*/createContext(null);
|
|
604
619
|
var useModal = function useModal() {
|
|
605
620
|
return useContext(ModalContext) || {};
|
|
606
621
|
};
|
|
@@ -687,12 +702,13 @@ function ModalProvider(_ref) {
|
|
|
687
702
|
getModalById: getModalById
|
|
688
703
|
};
|
|
689
704
|
}, [modals, container, setContainer, register, unregister, closeLastModal, getModalById]);
|
|
690
|
-
return /*#__PURE__*/
|
|
691
|
-
value: value
|
|
692
|
-
|
|
705
|
+
return /*#__PURE__*/jsx(ModalContext, {
|
|
706
|
+
value: value,
|
|
707
|
+
children: children
|
|
708
|
+
});
|
|
693
709
|
}
|
|
694
710
|
|
|
695
|
-
var PanelsContext = /*#__PURE__*/
|
|
711
|
+
var PanelsContext = /*#__PURE__*/createContext({
|
|
696
712
|
panels: [],
|
|
697
713
|
container: null,
|
|
698
714
|
setContainer: function setContainer() {},
|
|
@@ -704,19 +720,21 @@ var usePanels = function usePanels() {
|
|
|
704
720
|
};
|
|
705
721
|
var withPanels = function withPanels(WrappedComponent) {
|
|
706
722
|
var WithPanelsComponent = function WithPanelsComponent(props) {
|
|
707
|
-
return /*#__PURE__*/
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
723
|
+
return /*#__PURE__*/jsx(PanelsContext.Consumer, {
|
|
724
|
+
children: function children(_ref) {
|
|
725
|
+
var panels = _ref.panels,
|
|
726
|
+
setContainer = _ref.setContainer,
|
|
727
|
+
container = _ref.container,
|
|
728
|
+
register = _ref.register,
|
|
729
|
+
unregister = _ref.unregister;
|
|
730
|
+
return /*#__PURE__*/jsx(WrappedComponent, _objectSpread({
|
|
731
|
+
panelsContainer: container,
|
|
732
|
+
setPanelsContainer: setContainer,
|
|
733
|
+
panels: panels,
|
|
734
|
+
registerPanel: register,
|
|
735
|
+
unregisterPanel: unregister
|
|
736
|
+
}, props));
|
|
737
|
+
}
|
|
720
738
|
});
|
|
721
739
|
};
|
|
722
740
|
WithPanelsComponent.displayName = "WithPanels(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -768,13 +786,14 @@ function PanelsProvider(_ref2) {
|
|
|
768
786
|
unregister: unregister
|
|
769
787
|
};
|
|
770
788
|
}, [panels, setContainer, container, register, unregister]);
|
|
771
|
-
return /*#__PURE__*/
|
|
772
|
-
value: value
|
|
773
|
-
|
|
789
|
+
return /*#__PURE__*/jsx(PanelsContext, {
|
|
790
|
+
value: value,
|
|
791
|
+
children: children
|
|
792
|
+
});
|
|
774
793
|
}
|
|
775
794
|
|
|
776
795
|
var _excluded = ["component"];
|
|
777
|
-
var PanneauContext = /*#__PURE__*/
|
|
796
|
+
var PanneauContext = /*#__PURE__*/createContext(null);
|
|
778
797
|
var usePanneau = function usePanneau() {
|
|
779
798
|
return useContext(PanneauContext);
|
|
780
799
|
};
|
|
@@ -794,7 +813,7 @@ var usePanneauResource = function usePanneauResource(id) {
|
|
|
794
813
|
var usePanneauColorScheme = function usePanneauColorScheme() {
|
|
795
814
|
var _ref2 = usePanneau() || {},
|
|
796
815
|
_ref2$theme = _ref2.theme,
|
|
797
|
-
theme = _ref2$theme === void 0 ?
|
|
816
|
+
theme = _ref2$theme === void 0 ? null : _ref2$theme;
|
|
798
817
|
var _ref3 = theme || {},
|
|
799
818
|
_ref3$colorScheme = _ref3.colorScheme,
|
|
800
819
|
colorScheme = _ref3$colorScheme === void 0 ? 'light' : _ref3$colorScheme;
|
|
@@ -853,21 +872,23 @@ var usePanneauSettings = function usePanneauSettings() {
|
|
|
853
872
|
function PanneauProvider(_ref8) {
|
|
854
873
|
var definition = _ref8.definition,
|
|
855
874
|
children = _ref8.children;
|
|
856
|
-
return /*#__PURE__*/
|
|
857
|
-
value: definition
|
|
858
|
-
|
|
875
|
+
return /*#__PURE__*/jsx(PanneauContext, {
|
|
876
|
+
value: definition,
|
|
877
|
+
children: children
|
|
878
|
+
});
|
|
859
879
|
}
|
|
860
880
|
|
|
861
|
-
var ResourceContext = /*#__PURE__*/
|
|
881
|
+
var ResourceContext = /*#__PURE__*/createContext(null);
|
|
862
882
|
var useResource = function useResource() {
|
|
863
883
|
return useContext(ResourceContext);
|
|
864
884
|
};
|
|
865
885
|
function ResourceProvider(_ref) {
|
|
866
886
|
var resource = _ref.resource,
|
|
867
887
|
children = _ref.children;
|
|
868
|
-
return /*#__PURE__*/
|
|
869
|
-
value: resource
|
|
870
|
-
|
|
888
|
+
return /*#__PURE__*/jsx(ResourceContext, {
|
|
889
|
+
value: resource,
|
|
890
|
+
children: children
|
|
891
|
+
});
|
|
871
892
|
}
|
|
872
893
|
|
|
873
894
|
var useRoutePush = function useRoutePush() {
|
|
@@ -920,9 +941,10 @@ function TrackingProvider(_ref) {
|
|
|
920
941
|
variables: variables
|
|
921
942
|
});
|
|
922
943
|
}, [contextTracking, variables]);
|
|
923
|
-
return /*#__PURE__*/
|
|
924
|
-
tracking: tracking
|
|
925
|
-
|
|
944
|
+
return /*#__PURE__*/jsx(TrackingContainer, {
|
|
945
|
+
tracking: tracking,
|
|
946
|
+
children: children
|
|
947
|
+
});
|
|
926
948
|
}
|
|
927
949
|
|
|
928
950
|
export { ACTIONS_NAMESPACE, APP_NAMESPACE, BUTTONS_NAMESPACE, ComponentsContext, ComponentsProvider, DISPLAYS_NAMESPACE, DefinitionProvider, FIELDS_NAMESPACE, FILTERS_NAMESPACE, FORMS_NAMESPACE, FieldsContext, FieldsProvider, FontsContext, FontsProvider, FormProvider, GoogleApiClientContext, GoogleApiClientProvider, GoogleKeysContext, GoogleKeysProvider, GoogleMapsClientContext, GoogleMapsClientProvider, LISTS_NAMESPACE, LocalesContext, LocalesProvider, MODALS_NAMESPACE, ModalContext, ModalProvider, PAGES_NAMESPACE, PREVIEWS_NAMESPACE, PanelsContext, PanelsProvider, PanneauProvider, ResourceProvider, TrackingProvider, useActionComponent, useActionsComponents, useActionsComponentsManager, useAppComponent, useAppComponents, useAppComponentsManager, useButtonComponent, useButtonsComponents, useButtonsComponentsManager, useComponent, useComponents, useComponentsManager, useDefinition, useDefinitionContext, useDisplayComponent, useDisplaysComponents, useDisplaysComponentsManager, useField, useFieldComponent, useFields, useFieldsComponents, useFieldsComponentsManager, useFieldsManager, useFilterComponent, useFiltersComponents, useFiltersComponentsManager, useFonts, useForm, useFormComponent, useFormSetValue, useFormValue, useFormsComponents, useFormsComponentsManager, useGoogleApiClient, useGoogleFonts, useGoogleKeys, useGoogleMapsClient, useListComponent, useListsComponents, useListsComponentsManager, useLocales, useLocalesContext, useModal, useModalComponent, useModalsComponents, useModalsComponentsManager, useOtherLocales, usePageComponent, usePagesComponents, usePagesComponentsManager, usePanels, usePanneau, usePanneauAuth, usePanneauColorScheme, usePanneauComponent, usePanneauComponents, usePanneauResource, usePanneauResources, usePanneauSettings, usePreviewComponent, usePreviewsComponents, usePreviewsComponentsManager, useResource, useRouteBack, useRoutePush, useTracking, withGoogleApiClient, withGoogleMapsClient, withPanels };
|
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-es/isString');
|
|
5
|
-
var React
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var core = require('@panneau/core');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
8
9
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
9
10
|
var uniqBy = require('lodash-es/uniqBy');
|
|
@@ -15,7 +16,6 @@ var reactIntl = require('react-intl');
|
|
|
15
16
|
var utils = require('@panneau/core/utils');
|
|
16
17
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
17
18
|
var PropTypes = require('prop-types');
|
|
18
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
19
19
|
var pathToRegexp = require('path-to-regexp');
|
|
20
20
|
var regexparam = require('regexparam');
|
|
21
21
|
var index_js = require('use-sync-external-store/shim/index.js');
|
|
@@ -38,7 +38,7 @@ function _interopNamespaceDefault(e) {
|
|
|
38
38
|
return Object.freeze(n);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React
|
|
41
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
42
42
|
|
|
43
43
|
var MODALS_NAMESPACE = 'modals';
|
|
44
44
|
var FIELDS_NAMESPACE = 'fields';
|
|
@@ -51,15 +51,15 @@ var BUTTONS_NAMESPACE = 'buttons';
|
|
|
51
51
|
var PAGES_NAMESPACE = 'pages';
|
|
52
52
|
var PREVIEWS_NAMESPACE = 'previews';
|
|
53
53
|
var APP_NAMESPACE = 'app';
|
|
54
|
-
var ComponentsContext = /*#__PURE__*/React
|
|
54
|
+
var ComponentsContext = /*#__PURE__*/React.createContext(null);
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Hooks
|
|
58
58
|
*/
|
|
59
59
|
var useComponentsManager = function useComponentsManager() {
|
|
60
60
|
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
61
|
-
var manager = React
|
|
62
|
-
var finalManager = React
|
|
61
|
+
var manager = React.useContext(ComponentsContext);
|
|
62
|
+
var finalManager = React.useMemo(function () {
|
|
63
63
|
return namespace !== null ? new core.ComponentsManager(manager.getComponents(namespace)) : manager;
|
|
64
64
|
}, [manager, namespace]);
|
|
65
65
|
return finalManager;
|
|
@@ -74,7 +74,7 @@ var useComponent = function useComponent(name) {
|
|
|
74
74
|
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
75
75
|
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
76
76
|
var manager = useComponentsManager(namespace);
|
|
77
|
-
return React
|
|
77
|
+
return React.useMemo(function () {
|
|
78
78
|
if (!isString(name)) {
|
|
79
79
|
return name || defaultComponent;
|
|
80
80
|
}
|
|
@@ -261,17 +261,18 @@ function ComponentsProvider(_ref) {
|
|
|
261
261
|
namespace = _ref$namespace === void 0 ? null : _ref$namespace,
|
|
262
262
|
children = _ref.children;
|
|
263
263
|
var previousManager = useComponentsManager() || null;
|
|
264
|
-
var finalManager = React
|
|
264
|
+
var finalManager = React.useMemo(function () {
|
|
265
265
|
return new core.ComponentsManager(_objectSpread(_objectSpread(_objectSpread({}, previousManager !== null ? previousManager.getComponents() : null), manager !== null ? manager.getComponents() : null), new core.ComponentsManager(components).addNamespace(namespace).getComponents()));
|
|
266
266
|
}, [previousManager, manager, components, namespace]);
|
|
267
|
-
return /*#__PURE__*/
|
|
268
|
-
value: finalManager
|
|
269
|
-
|
|
267
|
+
return /*#__PURE__*/jsxRuntime.jsx(ComponentsContext, {
|
|
268
|
+
value: finalManager,
|
|
269
|
+
children: children
|
|
270
|
+
});
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
var DefinitionContext = /*#__PURE__*/React
|
|
273
|
+
var DefinitionContext = /*#__PURE__*/React.createContext(null);
|
|
273
274
|
var useDefinitionContext = function useDefinitionContext() {
|
|
274
|
-
return React
|
|
275
|
+
return React.useContext(DefinitionContext);
|
|
275
276
|
};
|
|
276
277
|
var useDefinition = function useDefinition() {
|
|
277
278
|
var definition = useDefinitionContext();
|
|
@@ -280,14 +281,15 @@ var useDefinition = function useDefinition() {
|
|
|
280
281
|
function DefinitionProvider(_ref) {
|
|
281
282
|
var definition = _ref.definition,
|
|
282
283
|
children = _ref.children;
|
|
283
|
-
return /*#__PURE__*/
|
|
284
|
-
value: definition
|
|
285
|
-
|
|
284
|
+
return /*#__PURE__*/jsxRuntime.jsx(DefinitionContext, {
|
|
285
|
+
value: definition,
|
|
286
|
+
children: children
|
|
287
|
+
});
|
|
286
288
|
}
|
|
287
289
|
|
|
288
|
-
var FieldsContext = /*#__PURE__*/React
|
|
290
|
+
var FieldsContext = /*#__PURE__*/React.createContext(null);
|
|
289
291
|
var useFieldsManager = function useFieldsManager() {
|
|
290
|
-
return React
|
|
292
|
+
return React.useContext(FieldsContext);
|
|
291
293
|
};
|
|
292
294
|
var useField = function useField(id) {
|
|
293
295
|
var manager = useFieldsManager();
|
|
@@ -304,33 +306,35 @@ function FieldsProvider(_ref) {
|
|
|
304
306
|
manager = _ref$manager === void 0 ? null : _ref$manager,
|
|
305
307
|
children = _ref.children;
|
|
306
308
|
var previousManager = useFieldsManager() || null;
|
|
307
|
-
var finalManager = React
|
|
309
|
+
var finalManager = React.useMemo(function () {
|
|
308
310
|
var newFields = uniqBy([].concat(_toConsumableArray(fields || []), _toConsumableArray(manager !== null ? manager.getDefinitions() : []), _toConsumableArray(previousManager !== null ? previousManager.getDefinitions() : [])), function (_ref2) {
|
|
309
311
|
var id = _ref2.id;
|
|
310
312
|
return id;
|
|
311
313
|
}).reverse();
|
|
312
314
|
return new core.FieldsManager(newFields);
|
|
313
315
|
}, [previousManager, manager, fields]);
|
|
314
|
-
var components = React
|
|
316
|
+
var components = React.useMemo(function () {
|
|
315
317
|
var newComponents = finalManager.getComponents();
|
|
316
318
|
return Object.keys(newComponents).reduce(function (map, id) {
|
|
317
319
|
var component = newComponents[id];
|
|
318
320
|
return isString(component) ? map : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, component));
|
|
319
321
|
}, {});
|
|
320
322
|
}, [finalManager]);
|
|
321
|
-
return /*#__PURE__*/
|
|
322
|
-
value: finalManager
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
return /*#__PURE__*/jsxRuntime.jsx(FieldsContext, {
|
|
324
|
+
value: finalManager,
|
|
325
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ComponentsProvider, {
|
|
326
|
+
namespace: FIELDS_NAMESPACE,
|
|
327
|
+
components: components,
|
|
328
|
+
children: children
|
|
329
|
+
})
|
|
330
|
+
});
|
|
327
331
|
}
|
|
328
332
|
|
|
329
|
-
var GoogleKeysContext = /*#__PURE__*/React
|
|
333
|
+
var GoogleKeysContext = /*#__PURE__*/React.createContext({
|
|
330
334
|
apiKey: null
|
|
331
335
|
});
|
|
332
336
|
var useGoogleKeys = function useGoogleKeys() {
|
|
333
|
-
return React
|
|
337
|
+
return React.useContext(GoogleKeysContext);
|
|
334
338
|
};
|
|
335
339
|
function GoogleKeysProvider(_ref) {
|
|
336
340
|
var children = _ref.children,
|
|
@@ -338,17 +342,18 @@ function GoogleKeysProvider(_ref) {
|
|
|
338
342
|
apiKey = _ref$apiKey === void 0 ? null : _ref$apiKey;
|
|
339
343
|
var _useGoogleKeys = useGoogleKeys(),
|
|
340
344
|
previousApiKey = _useGoogleKeys.apiKey;
|
|
341
|
-
var value = React
|
|
345
|
+
var value = React.useMemo(function () {
|
|
342
346
|
return {
|
|
343
347
|
apiKey: apiKey || previousApiKey
|
|
344
348
|
};
|
|
345
349
|
}, [previousApiKey, apiKey]);
|
|
346
|
-
return /*#__PURE__*/
|
|
347
|
-
value: value
|
|
348
|
-
|
|
350
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleKeysContext, {
|
|
351
|
+
value: value,
|
|
352
|
+
children: children
|
|
353
|
+
});
|
|
349
354
|
}
|
|
350
355
|
|
|
351
|
-
var FontsContext = /*#__PURE__*/React
|
|
356
|
+
var FontsContext = /*#__PURE__*/React.createContext({
|
|
352
357
|
systemFonts: null,
|
|
353
358
|
googleFonts: null,
|
|
354
359
|
customFonts: null
|
|
@@ -361,11 +366,11 @@ var useGoogleFonts = function useGoogleFonts() {
|
|
|
361
366
|
setFonts = _ref$setFonts === void 0 ? null : _ref$setFonts;
|
|
362
367
|
var _useGoogleKeys = useGoogleKeys(),
|
|
363
368
|
apiKey = _useGoogleKeys.apiKey;
|
|
364
|
-
var _useState = React
|
|
369
|
+
var _useState = React.useState(null),
|
|
365
370
|
_useState2 = _slicedToArray(_useState, 2),
|
|
366
371
|
googleFonts = _useState2[0],
|
|
367
372
|
setGoogleFonts = _useState2[1];
|
|
368
|
-
React
|
|
373
|
+
React.useEffect(function () {
|
|
369
374
|
var canceled = false;
|
|
370
375
|
if (apiKey !== null && !disabled) {
|
|
371
376
|
fetch.getJSON("https://www.googleapis.com/webfonts/v1/webfonts?key=".concat(apiKey, "&sort=popularity")).then(function (_ref2) {
|
|
@@ -397,7 +402,7 @@ var useFonts = function useFonts() {
|
|
|
397
402
|
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
398
403
|
_ref3$withoutGoogleFo = _ref3.withoutGoogleFonts,
|
|
399
404
|
withoutGoogleFonts = _ref3$withoutGoogleFo === void 0 ? false : _ref3$withoutGoogleFo;
|
|
400
|
-
var _useContext = React
|
|
405
|
+
var _useContext = React.useContext(FontsContext),
|
|
401
406
|
_useContext$setGoogle = _useContext.setGoogleFonts,
|
|
402
407
|
setGoogleFonts = _useContext$setGoogle === void 0 ? null : _useContext$setGoogle,
|
|
403
408
|
_useContext$systemFon = _useContext.systemFonts,
|
|
@@ -410,7 +415,7 @@ var useFonts = function useFonts() {
|
|
|
410
415
|
disabled: withoutGoogleFonts || googleFonts !== null && googleFonts.length > 0,
|
|
411
416
|
setFonts: setGoogleFonts
|
|
412
417
|
});
|
|
413
|
-
var fonts = React
|
|
418
|
+
var fonts = React.useMemo(function () {
|
|
414
419
|
return {
|
|
415
420
|
systemFonts: systemFonts,
|
|
416
421
|
googleFonts: googleFonts,
|
|
@@ -433,11 +438,11 @@ function FontsProvider(_ref4) {
|
|
|
433
438
|
previousGoogleFonts = _useFonts$googleFonts === void 0 ? null : _useFonts$googleFonts,
|
|
434
439
|
_useFonts$customFonts = _useFonts.customFonts,
|
|
435
440
|
previousCustomFonts = _useFonts$customFonts === void 0 ? null : _useFonts$customFonts;
|
|
436
|
-
var _useState3 = React
|
|
441
|
+
var _useState3 = React.useState(null),
|
|
437
442
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
438
443
|
googleFonts = _useState4[0],
|
|
439
444
|
setGoogleFonts = _useState4[1];
|
|
440
|
-
var fonts = React
|
|
445
|
+
var fonts = React.useMemo(function () {
|
|
441
446
|
return {
|
|
442
447
|
systemFonts: uniqBy([].concat(_toConsumableArray(previousSystemFonts || []), _toConsumableArray(systemFonts || [])), function (font) {
|
|
443
448
|
return isObject(font) ? font.name : font;
|
|
@@ -451,14 +456,15 @@ function FontsProvider(_ref4) {
|
|
|
451
456
|
setGoogleFonts: setGoogleFonts
|
|
452
457
|
};
|
|
453
458
|
}, [previousSystemFonts, previousGoogleFonts, previousCustomFonts, customFonts, systemFonts, googleFonts, setGoogleFonts]);
|
|
454
|
-
return /*#__PURE__*/
|
|
455
|
-
value: fonts
|
|
456
|
-
|
|
459
|
+
return /*#__PURE__*/jsxRuntime.jsx(FontsContext, {
|
|
460
|
+
value: fonts,
|
|
461
|
+
children: children
|
|
462
|
+
});
|
|
457
463
|
}
|
|
458
464
|
|
|
459
|
-
var FormContext = /*#__PURE__*/React
|
|
465
|
+
var FormContext = /*#__PURE__*/React.createContext(null);
|
|
460
466
|
var useForm = function useForm() {
|
|
461
|
-
return React
|
|
467
|
+
return React.useContext(FormContext);
|
|
462
468
|
};
|
|
463
469
|
var useFormValue = function useFormValue() {
|
|
464
470
|
var _useForm = useForm(),
|
|
@@ -474,20 +480,21 @@ function FormProvider(_ref) {
|
|
|
474
480
|
var value = _ref.value,
|
|
475
481
|
setValue = _ref.setValue,
|
|
476
482
|
children = _ref.children;
|
|
477
|
-
var values = React
|
|
483
|
+
var values = React.useMemo(function () {
|
|
478
484
|
return {
|
|
479
485
|
value: value,
|
|
480
486
|
setValue: setValue
|
|
481
487
|
};
|
|
482
488
|
}, [value, setValue]);
|
|
483
|
-
return /*#__PURE__*/
|
|
484
|
-
value: values
|
|
485
|
-
|
|
489
|
+
return /*#__PURE__*/jsxRuntime.jsx(FormContext, {
|
|
490
|
+
value: values,
|
|
491
|
+
children: children
|
|
492
|
+
});
|
|
486
493
|
}
|
|
487
494
|
|
|
488
|
-
var GoogleApiClientContext = /*#__PURE__*/React
|
|
495
|
+
var GoogleApiClientContext = /*#__PURE__*/React.createContext(null);
|
|
489
496
|
var useGoogleApiClient = function useGoogleApiClient() {
|
|
490
|
-
return React
|
|
497
|
+
return React.useContext(GoogleApiClientContext);
|
|
491
498
|
};
|
|
492
499
|
var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
493
500
|
var getDisplayName = function getDisplayName(_ref) {
|
|
@@ -498,10 +505,12 @@ var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
|
498
505
|
return displayName || name || 'Component';
|
|
499
506
|
};
|
|
500
507
|
var WithGoogleApiClientComponent = function WithGoogleApiClientComponent(props) {
|
|
501
|
-
return /*#__PURE__*/
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
508
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleApiClientContext.Consumer, {
|
|
509
|
+
children: function children(client) {
|
|
510
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
511
|
+
googleApiClient: client
|
|
512
|
+
}, props));
|
|
513
|
+
}
|
|
505
514
|
});
|
|
506
515
|
};
|
|
507
516
|
WithGoogleApiClientComponent.displayName = "WithGoogleApiClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -511,11 +520,11 @@ function GoogleApiClientProvider(_ref2) {
|
|
|
511
520
|
var children = _ref2.children;
|
|
512
521
|
var _useGoogleKeys = useGoogleKeys(),
|
|
513
522
|
apiKey = _useGoogleKeys.apiKey;
|
|
514
|
-
var _useState = React
|
|
523
|
+
var _useState = React.useState(null),
|
|
515
524
|
_useState2 = _slicedToArray(_useState, 2),
|
|
516
525
|
client = _useState2[0],
|
|
517
526
|
setClient = _useState2[1];
|
|
518
|
-
React
|
|
527
|
+
React.useEffect(function () {
|
|
519
528
|
services.loadGoogleApi().then(function (gapi) {
|
|
520
529
|
return gapi.client.init({
|
|
521
530
|
apiKey: apiKey
|
|
@@ -526,14 +535,15 @@ function GoogleApiClientProvider(_ref2) {
|
|
|
526
535
|
return setClient(gapi);
|
|
527
536
|
});
|
|
528
537
|
}, [apiKey, setClient]);
|
|
529
|
-
return /*#__PURE__*/
|
|
530
|
-
value: client
|
|
531
|
-
|
|
538
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleApiClientContext, {
|
|
539
|
+
value: client,
|
|
540
|
+
children: children
|
|
541
|
+
});
|
|
532
542
|
}
|
|
533
543
|
|
|
534
|
-
var GoogleMapsClientContext = /*#__PURE__*/React
|
|
544
|
+
var GoogleMapsClientContext = /*#__PURE__*/React.createContext(null);
|
|
535
545
|
var useGoogleMapsClient = function useGoogleMapsClient() {
|
|
536
|
-
return React
|
|
546
|
+
return React.useContext(GoogleMapsClientContext);
|
|
537
547
|
};
|
|
538
548
|
var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
539
549
|
var getDisplayName = function getDisplayName(_ref) {
|
|
@@ -544,10 +554,12 @@ var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
|
544
554
|
return displayName || name || 'Component';
|
|
545
555
|
};
|
|
546
556
|
var WithGoogleMapsClientComponent = function WithGoogleMapsClientComponent(props) {
|
|
547
|
-
return /*#__PURE__*/
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
557
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleMapsClientContext.Consumer, {
|
|
558
|
+
children: function children(client) {
|
|
559
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
560
|
+
googleApiClient: client
|
|
561
|
+
}, props));
|
|
562
|
+
}
|
|
551
563
|
});
|
|
552
564
|
};
|
|
553
565
|
WithGoogleMapsClientComponent.displayName = "WithGoogleMapsClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
@@ -562,11 +574,11 @@ function GoogleMapsClientProvider(_ref2) {
|
|
|
562
574
|
var _useGoogleKeys = useGoogleKeys(),
|
|
563
575
|
apiKey = _useGoogleKeys.apiKey;
|
|
564
576
|
var exisitingClient = useGoogleMapsClient();
|
|
565
|
-
var _useState = React
|
|
577
|
+
var _useState = React.useState(exisitingClient),
|
|
566
578
|
_useState2 = _slicedToArray(_useState, 2),
|
|
567
579
|
client = _useState2[0],
|
|
568
580
|
setClient = _useState2[1];
|
|
569
|
-
React
|
|
581
|
+
React.useEffect(function () {
|
|
570
582
|
if (exisitingClient === null) {
|
|
571
583
|
services.loadGoogleMaps({
|
|
572
584
|
apiKey: apiKey,
|
|
@@ -577,17 +589,18 @@ function GoogleMapsClientProvider(_ref2) {
|
|
|
577
589
|
});
|
|
578
590
|
}
|
|
579
591
|
}, [apiKey, locale, libraries, setClient, exisitingClient]);
|
|
580
|
-
return /*#__PURE__*/
|
|
581
|
-
value: client
|
|
582
|
-
|
|
592
|
+
return /*#__PURE__*/jsxRuntime.jsx(GoogleMapsClientContext, {
|
|
593
|
+
value: client,
|
|
594
|
+
children: children
|
|
595
|
+
});
|
|
583
596
|
}
|
|
584
597
|
|
|
585
598
|
var defaultLocales = ['en', 'fr'];
|
|
586
|
-
var LocalesContext = /*#__PURE__*/React
|
|
599
|
+
var LocalesContext = /*#__PURE__*/React.createContext({
|
|
587
600
|
locales: defaultLocales
|
|
588
601
|
});
|
|
589
602
|
var useLocalesContext = function useLocalesContext() {
|
|
590
|
-
var context = React
|
|
603
|
+
var context = React.useContext(LocalesContext);
|
|
591
604
|
return context;
|
|
592
605
|
};
|
|
593
606
|
var useLocales = function useLocales() {
|
|
@@ -600,7 +613,7 @@ var useOtherLocales = function useOtherLocales() {
|
|
|
600
613
|
locales = _useLocalesContext2.locales;
|
|
601
614
|
var _useIntl = reactIntl.useIntl(),
|
|
602
615
|
locale = _useIntl.locale;
|
|
603
|
-
var otherLocales = React
|
|
616
|
+
var otherLocales = React.useMemo(function () {
|
|
604
617
|
return locales.filter(function (it) {
|
|
605
618
|
return it !== locale;
|
|
606
619
|
});
|
|
@@ -612,35 +625,36 @@ function LocalesProvider(_ref) {
|
|
|
612
625
|
var _ref$locales = _ref.locales,
|
|
613
626
|
locales = _ref$locales === void 0 ? DEFAULT_LOCALES : _ref$locales,
|
|
614
627
|
children = _ref.children;
|
|
615
|
-
var value = React
|
|
628
|
+
var value = React.useMemo(function () {
|
|
616
629
|
return {
|
|
617
630
|
locales: locales
|
|
618
631
|
};
|
|
619
632
|
}, [locales]);
|
|
620
|
-
return /*#__PURE__*/
|
|
621
|
-
value: value
|
|
622
|
-
|
|
633
|
+
return /*#__PURE__*/jsxRuntime.jsx(LocalesContext, {
|
|
634
|
+
value: value,
|
|
635
|
+
children: children
|
|
636
|
+
});
|
|
623
637
|
}
|
|
624
638
|
|
|
625
|
-
var ModalContext = /*#__PURE__*/React
|
|
639
|
+
var ModalContext = /*#__PURE__*/React.createContext(null);
|
|
626
640
|
var useModal = function useModal() {
|
|
627
|
-
return React
|
|
641
|
+
return React.useContext(ModalContext) || {};
|
|
628
642
|
};
|
|
629
643
|
var DEFAULT_MODALS = [];
|
|
630
644
|
function ModalProvider(_ref) {
|
|
631
645
|
var children = _ref.children,
|
|
632
646
|
_ref$container = _ref.container,
|
|
633
647
|
initialContainer = _ref$container === void 0 ? null : _ref$container;
|
|
634
|
-
var _useState = React
|
|
648
|
+
var _useState = React.useState(initialContainer),
|
|
635
649
|
_useState2 = _slicedToArray(_useState, 2),
|
|
636
650
|
container = _useState2[0],
|
|
637
651
|
setContainer = _useState2[1];
|
|
638
|
-
var _useState3 = React
|
|
652
|
+
var _useState3 = React.useState(DEFAULT_MODALS),
|
|
639
653
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
640
654
|
modals = _useState4[0],
|
|
641
655
|
setModals = _useState4[1];
|
|
642
|
-
var modalsRef = React
|
|
643
|
-
var register = React
|
|
656
|
+
var modalsRef = React.useRef(modals);
|
|
657
|
+
var register = React.useCallback(function (id) {
|
|
644
658
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
645
659
|
var _modalsRef$current = modalsRef.current,
|
|
646
660
|
currentModals = _modalsRef$current === void 0 ? [] : _modalsRef$current;
|
|
@@ -650,7 +664,7 @@ function ModalProvider(_ref) {
|
|
|
650
664
|
setModals(newModals);
|
|
651
665
|
modalsRef.current = newModals;
|
|
652
666
|
}, [setModals]);
|
|
653
|
-
var unregister = React
|
|
667
|
+
var unregister = React.useCallback(function () {
|
|
654
668
|
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
655
669
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
656
670
|
var _modalsRef$current2 = modalsRef.current,
|
|
@@ -674,7 +688,7 @@ function ModalProvider(_ref) {
|
|
|
674
688
|
modalsRef.current = newModals;
|
|
675
689
|
}
|
|
676
690
|
}, [setModals]);
|
|
677
|
-
var closeLastModal = React
|
|
691
|
+
var closeLastModal = React.useCallback(function () {
|
|
678
692
|
var lastModal = modals.pop() || null;
|
|
679
693
|
if (lastModal !== null) {
|
|
680
694
|
var _ref5 = lastModal || {},
|
|
@@ -693,12 +707,12 @@ function ModalProvider(_ref) {
|
|
|
693
707
|
modalsRef.current = newModals;
|
|
694
708
|
}
|
|
695
709
|
}, [modals, setModals]);
|
|
696
|
-
var getModalById = React
|
|
710
|
+
var getModalById = React.useCallback(function (modalId) {
|
|
697
711
|
return (modals || []).find(function (modal) {
|
|
698
712
|
return (modal === null || modal === void 0 ? void 0 : modal.id) === modalId;
|
|
699
713
|
}) || null;
|
|
700
714
|
}, [modals]);
|
|
701
|
-
var value = React
|
|
715
|
+
var value = React.useMemo(function () {
|
|
702
716
|
return {
|
|
703
717
|
modals: modals,
|
|
704
718
|
container: container,
|
|
@@ -709,12 +723,13 @@ function ModalProvider(_ref) {
|
|
|
709
723
|
getModalById: getModalById
|
|
710
724
|
};
|
|
711
725
|
}, [modals, container, setContainer, register, unregister, closeLastModal, getModalById]);
|
|
712
|
-
return /*#__PURE__*/
|
|
713
|
-
value: value
|
|
714
|
-
|
|
726
|
+
return /*#__PURE__*/jsxRuntime.jsx(ModalContext, {
|
|
727
|
+
value: value,
|
|
728
|
+
children: children
|
|
729
|
+
});
|
|
715
730
|
}
|
|
716
731
|
|
|
717
|
-
var PanelsContext = /*#__PURE__*/React
|
|
732
|
+
var PanelsContext = /*#__PURE__*/React.createContext({
|
|
718
733
|
panels: [],
|
|
719
734
|
container: null,
|
|
720
735
|
setContainer: function setContainer() {},
|
|
@@ -722,23 +737,25 @@ var PanelsContext = /*#__PURE__*/React$1.createContext({
|
|
|
722
737
|
unregister: function unregister() {}
|
|
723
738
|
});
|
|
724
739
|
var usePanels = function usePanels() {
|
|
725
|
-
return React
|
|
740
|
+
return React.useContext(PanelsContext) || {};
|
|
726
741
|
};
|
|
727
742
|
var withPanels = function withPanels(WrappedComponent) {
|
|
728
743
|
var WithPanelsComponent = function WithPanelsComponent(props) {
|
|
729
|
-
return /*#__PURE__*/
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
744
|
+
return /*#__PURE__*/jsxRuntime.jsx(PanelsContext.Consumer, {
|
|
745
|
+
children: function children(_ref) {
|
|
746
|
+
var panels = _ref.panels,
|
|
747
|
+
setContainer = _ref.setContainer,
|
|
748
|
+
container = _ref.container,
|
|
749
|
+
register = _ref.register,
|
|
750
|
+
unregister = _ref.unregister;
|
|
751
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread({
|
|
752
|
+
panelsContainer: container,
|
|
753
|
+
setPanelsContainer: setContainer,
|
|
754
|
+
panels: panels,
|
|
755
|
+
registerPanel: register,
|
|
756
|
+
unregisterPanel: unregister
|
|
757
|
+
}, props));
|
|
758
|
+
}
|
|
742
759
|
});
|
|
743
760
|
};
|
|
744
761
|
WithPanelsComponent.displayName = "WithPanels(".concat(utils.getDisplayName(WrappedComponent), ")");
|
|
@@ -748,16 +765,16 @@ function PanelsProvider(_ref2) {
|
|
|
748
765
|
var children = _ref2.children,
|
|
749
766
|
_ref2$container = _ref2.container,
|
|
750
767
|
initialContainer = _ref2$container === void 0 ? null : _ref2$container;
|
|
751
|
-
var _useState = React
|
|
768
|
+
var _useState = React.useState(initialContainer),
|
|
752
769
|
_useState2 = _slicedToArray(_useState, 2),
|
|
753
770
|
container = _useState2[0],
|
|
754
771
|
setContainer = _useState2[1];
|
|
755
|
-
var _useState3 = React
|
|
772
|
+
var _useState3 = React.useState([]),
|
|
756
773
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
757
774
|
panels = _useState4[0],
|
|
758
775
|
setPanels = _useState4[1];
|
|
759
|
-
var panelsRef = React
|
|
760
|
-
var register = React
|
|
776
|
+
var panelsRef = React.useRef(panels);
|
|
777
|
+
var register = React.useCallback(function (id) {
|
|
761
778
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
762
779
|
var currentPanels = panelsRef.current;
|
|
763
780
|
var newPanels = [].concat(_toConsumableArray(currentPanels), [_objectSpread({
|
|
@@ -766,7 +783,7 @@ function PanelsProvider(_ref2) {
|
|
|
766
783
|
setPanels(newPanels);
|
|
767
784
|
panelsRef.current = newPanels;
|
|
768
785
|
}, [panels, setPanels]);
|
|
769
|
-
var unregister = React
|
|
786
|
+
var unregister = React.useCallback(function (id) {
|
|
770
787
|
var currentPanels = panelsRef.current;
|
|
771
788
|
var foundIndex = currentPanels.findIndex(function (_ref3) {
|
|
772
789
|
var modalId = _ref3.id;
|
|
@@ -781,7 +798,7 @@ function PanelsProvider(_ref2) {
|
|
|
781
798
|
panelsRef.current = newPanels;
|
|
782
799
|
}
|
|
783
800
|
}, [panels, setPanels]);
|
|
784
|
-
var value = React
|
|
801
|
+
var value = React.useMemo(function () {
|
|
785
802
|
return {
|
|
786
803
|
panels: panels,
|
|
787
804
|
setContainer: setContainer,
|
|
@@ -790,15 +807,16 @@ function PanelsProvider(_ref2) {
|
|
|
790
807
|
unregister: unregister
|
|
791
808
|
};
|
|
792
809
|
}, [panels, setContainer, container, register, unregister]);
|
|
793
|
-
return /*#__PURE__*/
|
|
794
|
-
value: value
|
|
795
|
-
|
|
810
|
+
return /*#__PURE__*/jsxRuntime.jsx(PanelsContext, {
|
|
811
|
+
value: value,
|
|
812
|
+
children: children
|
|
813
|
+
});
|
|
796
814
|
}
|
|
797
815
|
|
|
798
816
|
var _excluded = ["component"];
|
|
799
|
-
var PanneauContext = /*#__PURE__*/React
|
|
817
|
+
var PanneauContext = /*#__PURE__*/React.createContext(null);
|
|
800
818
|
var usePanneau = function usePanneau() {
|
|
801
|
-
return React
|
|
819
|
+
return React.useContext(PanneauContext);
|
|
802
820
|
};
|
|
803
821
|
var DEFAULT_RESOURCES = [];
|
|
804
822
|
var usePanneauResources = function usePanneauResources() {
|
|
@@ -816,7 +834,7 @@ var usePanneauResource = function usePanneauResource(id) {
|
|
|
816
834
|
var usePanneauColorScheme = function usePanneauColorScheme() {
|
|
817
835
|
var _ref2 = usePanneau() || {},
|
|
818
836
|
_ref2$theme = _ref2.theme,
|
|
819
|
-
theme = _ref2$theme === void 0 ?
|
|
837
|
+
theme = _ref2$theme === void 0 ? null : _ref2$theme;
|
|
820
838
|
var _ref3 = theme || {},
|
|
821
839
|
_ref3$colorScheme = _ref3.colorScheme,
|
|
822
840
|
colorScheme = _ref3$colorScheme === void 0 ? 'light' : _ref3$colorScheme;
|
|
@@ -875,21 +893,23 @@ var usePanneauSettings = function usePanneauSettings() {
|
|
|
875
893
|
function PanneauProvider(_ref8) {
|
|
876
894
|
var definition = _ref8.definition,
|
|
877
895
|
children = _ref8.children;
|
|
878
|
-
return /*#__PURE__*/
|
|
879
|
-
value: definition
|
|
880
|
-
|
|
896
|
+
return /*#__PURE__*/jsxRuntime.jsx(PanneauContext, {
|
|
897
|
+
value: definition,
|
|
898
|
+
children: children
|
|
899
|
+
});
|
|
881
900
|
}
|
|
882
901
|
|
|
883
|
-
var ResourceContext = /*#__PURE__*/React
|
|
902
|
+
var ResourceContext = /*#__PURE__*/React.createContext(null);
|
|
884
903
|
var useResource = function useResource() {
|
|
885
|
-
return React
|
|
904
|
+
return React.useContext(ResourceContext);
|
|
886
905
|
};
|
|
887
906
|
function ResourceProvider(_ref) {
|
|
888
907
|
var resource = _ref.resource,
|
|
889
908
|
children = _ref.children;
|
|
890
|
-
return /*#__PURE__*/
|
|
891
|
-
value: resource
|
|
892
|
-
|
|
909
|
+
return /*#__PURE__*/jsxRuntime.jsx(ResourceContext, {
|
|
910
|
+
value: resource,
|
|
911
|
+
children: children
|
|
912
|
+
});
|
|
893
913
|
}
|
|
894
914
|
|
|
895
915
|
// React.useInsertionEffect is not available in React <18
|
|
@@ -1083,11 +1103,11 @@ var defaultRouter = {
|
|
|
1083
1103
|
return x;
|
|
1084
1104
|
}
|
|
1085
1105
|
};
|
|
1086
|
-
var RouterCtx = React
|
|
1106
|
+
var RouterCtx = React.createContext(defaultRouter);
|
|
1087
1107
|
|
|
1088
1108
|
// gets the closest parent router from the context
|
|
1089
1109
|
var useRouter = function useRouter() {
|
|
1090
|
-
return React
|
|
1110
|
+
return React.useContext(RouterCtx);
|
|
1091
1111
|
};
|
|
1092
1112
|
|
|
1093
1113
|
/**
|
|
@@ -1096,7 +1116,7 @@ var useRouter = function useRouter() {
|
|
|
1096
1116
|
*/
|
|
1097
1117
|
|
|
1098
1118
|
var Params0 = {};
|
|
1099
|
-
React
|
|
1119
|
+
React.createContext(Params0);
|
|
1100
1120
|
|
|
1101
1121
|
/*
|
|
1102
1122
|
* Part 1, Hooks API: useRoute and useLocation
|
|
@@ -1120,7 +1140,7 @@ var useLocationFromRouter = function useLocationFromRouter(router) {
|
|
|
1120
1140
|
var useLocation = function useLocation() {
|
|
1121
1141
|
return useLocationFromRouter(useRouter());
|
|
1122
1142
|
};
|
|
1123
|
-
React
|
|
1143
|
+
React.forwardRef(function (props, ref) {
|
|
1124
1144
|
var router = useRouter();
|
|
1125
1145
|
var _useLocationFromRoute3 = useLocationFromRouter(router),
|
|
1126
1146
|
_useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
|
|
@@ -1151,10 +1171,10 @@ React$1.forwardRef(function (props, ref) {
|
|
|
1151
1171
|
// handle nested routers and absolute paths
|
|
1152
1172
|
var href = router.hrefs(targetPath[0] === "~" ? targetPath.slice(1) : router.base + targetPath, router // pass router as a second argument for convinience
|
|
1153
1173
|
);
|
|
1154
|
-
return asChild && React
|
|
1174
|
+
return asChild && React.isValidElement(children) ? React.cloneElement(children, {
|
|
1155
1175
|
onClick: onClick,
|
|
1156
1176
|
href: href
|
|
1157
|
-
}) : React
|
|
1177
|
+
}) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
1158
1178
|
onClick: onClick,
|
|
1159
1179
|
href: href,
|
|
1160
1180
|
// `className` can be a function to apply the class if this link is active
|
|
@@ -1165,9 +1185,9 @@ React$1.forwardRef(function (props, ref) {
|
|
|
1165
1185
|
});
|
|
1166
1186
|
|
|
1167
1187
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
1168
|
-
var RoutesContext = /*#__PURE__*/React
|
|
1188
|
+
var RoutesContext = /*#__PURE__*/React.createContext(null);
|
|
1169
1189
|
var useRoutesContext = function useRoutesContext() {
|
|
1170
|
-
return React
|
|
1190
|
+
return React.useContext(RoutesContext);
|
|
1171
1191
|
};
|
|
1172
1192
|
var propTypes$1 = {
|
|
1173
1193
|
children: PropTypes.node.isRequired,
|
|
@@ -1181,7 +1201,7 @@ function RoutesProvider(_ref) {
|
|
|
1181
1201
|
var routes = _ref.routes,
|
|
1182
1202
|
basePath = _ref.basePath,
|
|
1183
1203
|
children = _ref.children;
|
|
1184
|
-
var value = React
|
|
1204
|
+
var value = React.useMemo(function () {
|
|
1185
1205
|
return {
|
|
1186
1206
|
routes: routes,
|
|
1187
1207
|
basePath: basePath
|
|
@@ -1210,7 +1230,7 @@ var useUrlGeneratorPathToRepexp = function useUrlGeneratorPathToRepexp() {
|
|
|
1210
1230
|
routes = _ref2$routes === void 0 ? null : _ref2$routes,
|
|
1211
1231
|
_ref2$basePath = _ref2.basePath,
|
|
1212
1232
|
basePath = _ref2$basePath === void 0 ? null : _ref2$basePath;
|
|
1213
|
-
var urlGenerator = React
|
|
1233
|
+
var urlGenerator = React.useCallback(function (key, data, opts) {
|
|
1214
1234
|
var path = routes !== null ? routes[key] || null : null;
|
|
1215
1235
|
if (path === null) {
|
|
1216
1236
|
return null;
|
|
@@ -1236,7 +1256,7 @@ var useRoutePush = function useRoutePush() {
|
|
|
1236
1256
|
var _useLocation = useLocation(),
|
|
1237
1257
|
_useLocation2 = _slicedToArray(_useLocation, 2),
|
|
1238
1258
|
navigate = _useLocation2[1];
|
|
1239
|
-
var push = React
|
|
1259
|
+
var push = React.useCallback(function (route, data) {
|
|
1240
1260
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1241
1261
|
args[_key - 2] = arguments[_key];
|
|
1242
1262
|
}
|
|
@@ -1258,21 +1278,21 @@ var useRouteBack = function useRouteBack() {
|
|
|
1258
1278
|
var _useLocation3 = useLocation(),
|
|
1259
1279
|
_useLocation4 = _slicedToArray(_useLocation3, 2),
|
|
1260
1280
|
navigate = _useLocation4[1];
|
|
1261
|
-
var back = React
|
|
1281
|
+
var back = React.useCallback(function () {
|
|
1262
1282
|
return navigate(-1);
|
|
1263
1283
|
}, [navigate, url]);
|
|
1264
1284
|
return back;
|
|
1265
1285
|
};
|
|
1266
1286
|
|
|
1267
1287
|
var useTracking = function useTracking() {
|
|
1268
|
-
return React
|
|
1288
|
+
return React.useContext(tracking.TrackingContext);
|
|
1269
1289
|
};
|
|
1270
1290
|
function TrackingProvider(_ref) {
|
|
1271
1291
|
var _ref$variables = _ref.variables,
|
|
1272
1292
|
variables = _ref$variables === void 0 ? null : _ref$variables,
|
|
1273
1293
|
children = _ref.children;
|
|
1274
1294
|
var contextTracking = useTracking() || null;
|
|
1275
|
-
var tracking$1 = React
|
|
1295
|
+
var tracking$1 = React.useMemo(function () {
|
|
1276
1296
|
if (contextTracking !== null) {
|
|
1277
1297
|
contextTracking.setVariables(variables);
|
|
1278
1298
|
return contextTracking;
|
|
@@ -1281,9 +1301,10 @@ function TrackingProvider(_ref) {
|
|
|
1281
1301
|
variables: variables
|
|
1282
1302
|
});
|
|
1283
1303
|
}, [contextTracking, variables]);
|
|
1284
|
-
return /*#__PURE__*/
|
|
1285
|
-
tracking: tracking$1
|
|
1286
|
-
|
|
1304
|
+
return /*#__PURE__*/jsxRuntime.jsx(tracking.TrackingContainer, {
|
|
1305
|
+
tracking: tracking$1,
|
|
1306
|
+
children: children
|
|
1307
|
+
});
|
|
1287
1308
|
}
|
|
1288
1309
|
|
|
1289
1310
|
Object.defineProperty(exports, "TrackingContext", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -22,14 +22,6 @@
|
|
|
22
22
|
{
|
|
23
23
|
"name": "Nicolas Roy-Bourdages",
|
|
24
24
|
"email": "nrb@folklore.email"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"name": "Julien Carignan",
|
|
28
|
-
"email": "jc@folklore.email"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"name": "Théo Gjini",
|
|
32
|
-
"email": "tg@folklore.email"
|
|
33
25
|
}
|
|
34
26
|
],
|
|
35
27
|
"license": "ISC",
|
|
@@ -120,5 +112,5 @@
|
|
|
120
112
|
"publishConfig": {
|
|
121
113
|
"access": "public"
|
|
122
114
|
},
|
|
123
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "ac8b065e8c7ada1d176d15eff1c0fa53599ad31f"
|
|
124
116
|
}
|