@micromag/core 0.3.531 → 0.3.547
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/assets/css/vendor.css +1 -1
- package/es/components.js +27 -30
- package/package.json +3 -4
- package/lib/components.js +0 -5370
- package/lib/contexts.js +0 -1848
- package/lib/hooks.js +0 -2402
- package/lib/index.js +0 -2387
- package/lib/utils.js +0 -1409
package/lib/contexts.js
DELETED
|
@@ -1,1848 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
-
var isString = require('lodash/isString');
|
|
5
|
-
var PropTypes = require('prop-types');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var core = require('@micromag/core');
|
|
8
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
9
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
10
|
-
var uniqBy = require('lodash/uniqBy');
|
|
11
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
12
|
-
var fetch = require('@folklore/fetch');
|
|
13
|
-
var isObject = require('lodash/isObject');
|
|
14
|
-
var services = require('@folklore/services');
|
|
15
|
-
var utils = require('@micromag/core/utils');
|
|
16
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
17
|
-
var pathToRegexp = require('path-to-regexp');
|
|
18
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
19
|
-
var regexparam = require('regexparam');
|
|
20
|
-
var index_js = require('use-sync-external-store/shim/index.js');
|
|
21
|
-
var reactIntl = require('react-intl');
|
|
22
|
-
var tracking = require('@folklore/tracking');
|
|
23
|
-
var EventEmitter = require('wolfy87-eventemitter');
|
|
24
|
-
|
|
25
|
-
function _interopNamespaceDefault(e) {
|
|
26
|
-
var n = Object.create(null);
|
|
27
|
-
if (e) {
|
|
28
|
-
Object.keys(e).forEach(function (k) {
|
|
29
|
-
if (k !== 'default') {
|
|
30
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return e[k]; }
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
n.default = e;
|
|
39
|
-
return Object.freeze(n);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
43
|
-
|
|
44
|
-
var MODALS_NAMESPACE = 'modals';
|
|
45
|
-
var FIELDS_NAMESPACE = 'fields';
|
|
46
|
-
var FORMS_NAMESPACE = 'forms';
|
|
47
|
-
var SCREENS_NAMESPACE = 'screens';
|
|
48
|
-
var ELEMENTS_NAMESPACE = 'elements';
|
|
49
|
-
var ComponentsContext = /*#__PURE__*/React.createContext(null);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Hooks
|
|
53
|
-
*/
|
|
54
|
-
var useComponentsManager = function useComponentsManager() {
|
|
55
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
56
|
-
var manager = React.useContext(ComponentsContext);
|
|
57
|
-
var finalManager = React.useMemo(function () {
|
|
58
|
-
return namespace !== null ? new core.ComponentsManager(manager.getComponents(namespace)) : manager;
|
|
59
|
-
}, [manager, namespace]);
|
|
60
|
-
return finalManager;
|
|
61
|
-
};
|
|
62
|
-
var useComponents = function useComponents() {
|
|
63
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
64
|
-
var defaultComponents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
65
|
-
var manager = useComponentsManager();
|
|
66
|
-
return manager.getComponents(namespace) || defaultComponents;
|
|
67
|
-
};
|
|
68
|
-
var useComponent = function useComponent(name) {
|
|
69
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
70
|
-
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
71
|
-
var manager = useComponentsManager(namespace);
|
|
72
|
-
return React.useMemo(function () {
|
|
73
|
-
if (!isString(name)) {
|
|
74
|
-
return name || defaultComponent;
|
|
75
|
-
}
|
|
76
|
-
return manager.getComponent(name) || defaultComponent;
|
|
77
|
-
}, [manager, name, defaultComponent]);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Fields hooks
|
|
82
|
-
*/
|
|
83
|
-
var useFieldsComponentsManager = function useFieldsComponentsManager() {
|
|
84
|
-
return useComponentsManager(FIELDS_NAMESPACE);
|
|
85
|
-
};
|
|
86
|
-
var useFieldsComponents = function useFieldsComponents() {
|
|
87
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
88
|
-
return useComponents(FIELDS_NAMESPACE, defaultComponents);
|
|
89
|
-
};
|
|
90
|
-
var useFieldComponent = function useFieldComponent(name) {
|
|
91
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
92
|
-
return useComponent(name, defaultComponent, FIELDS_NAMESPACE);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Screens hooks
|
|
97
|
-
*/
|
|
98
|
-
var useScreensComponentsManager = function useScreensComponentsManager() {
|
|
99
|
-
return useComponentsManager(SCREENS_NAMESPACE);
|
|
100
|
-
};
|
|
101
|
-
var useScreensComponents = function useScreensComponents() {
|
|
102
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
103
|
-
return useComponents(SCREENS_NAMESPACE, defaultComponents);
|
|
104
|
-
};
|
|
105
|
-
var useScreenComponent = function useScreenComponent(name) {
|
|
106
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
107
|
-
return useComponent(name, defaultComponent, SCREENS_NAMESPACE);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Forms hooks
|
|
112
|
-
*/
|
|
113
|
-
var useFormsComponentsManager = function useFormsComponentsManager() {
|
|
114
|
-
return useComponentsManager(FORMS_NAMESPACE);
|
|
115
|
-
};
|
|
116
|
-
var useFormsComponents = function useFormsComponents() {
|
|
117
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
118
|
-
return useComponents(FORMS_NAMESPACE, defaultComponents);
|
|
119
|
-
};
|
|
120
|
-
var useFormComponent = function useFormComponent(name) {
|
|
121
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
122
|
-
return useComponent(name, defaultComponent, FORMS_NAMESPACE);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Modals hooks
|
|
127
|
-
*/
|
|
128
|
-
var useModalsComponentsManager = function useModalsComponentsManager() {
|
|
129
|
-
return useComponentsManager(MODALS_NAMESPACE);
|
|
130
|
-
};
|
|
131
|
-
var useModalsComponents = function useModalsComponents() {
|
|
132
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
133
|
-
return useComponents(MODALS_NAMESPACE, defaultComponents);
|
|
134
|
-
};
|
|
135
|
-
var useModalComponent = function useModalComponent(name) {
|
|
136
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
137
|
-
return useComponent(name, defaultComponent, MODALS_NAMESPACE);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Elements hooks
|
|
142
|
-
*/
|
|
143
|
-
var useElementsComponentsManager = function useElementsComponentsManager() {
|
|
144
|
-
return useComponentsManager(ELEMENTS_NAMESPACE);
|
|
145
|
-
};
|
|
146
|
-
var useElementsComponents = function useElementsComponents() {
|
|
147
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
148
|
-
return useComponents(ELEMENTS_NAMESPACE, defaultComponents);
|
|
149
|
-
};
|
|
150
|
-
var useElementComponent = function useElementComponent(name) {
|
|
151
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
152
|
-
return useComponent(name, defaultComponent, ELEMENTS_NAMESPACE);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Provider
|
|
157
|
-
*/
|
|
158
|
-
var propTypes$j = {
|
|
159
|
-
children: PropTypes.node.isRequired,
|
|
160
|
-
namespace: PropTypes.string,
|
|
161
|
-
manager: PropTypes.instanceOf(core.ComponentsManager),
|
|
162
|
-
components: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.object, PropTypes.func]))
|
|
163
|
-
};
|
|
164
|
-
var defaultProps$j = {
|
|
165
|
-
namespace: null,
|
|
166
|
-
components: {},
|
|
167
|
-
manager: null
|
|
168
|
-
};
|
|
169
|
-
var ComponentsProvider = function ComponentsProvider(_ref) {
|
|
170
|
-
var components = _ref.components,
|
|
171
|
-
manager = _ref.manager,
|
|
172
|
-
namespace = _ref.namespace,
|
|
173
|
-
children = _ref.children;
|
|
174
|
-
var previousManager = useComponentsManager() || null;
|
|
175
|
-
var finalManager = React.useMemo(function () {
|
|
176
|
-
return new core.ComponentsManager(_objectSpread(_objectSpread(_objectSpread({}, previousManager !== null ? previousManager.getComponents() : null), manager !== null ? manager.getComponents() : null), new core.ComponentsManager(components).addNamespace(namespace).getComponents()));
|
|
177
|
-
}, [previousManager, manager, components, namespace]);
|
|
178
|
-
return /*#__PURE__*/React.createElement(ComponentsContext.Provider, {
|
|
179
|
-
value: finalManager
|
|
180
|
-
}, children);
|
|
181
|
-
};
|
|
182
|
-
ComponentsProvider.propTypes = propTypes$j;
|
|
183
|
-
ComponentsProvider.defaultProps = defaultProps$j;
|
|
184
|
-
|
|
185
|
-
var FieldsContext = /*#__PURE__*/React.createContext(null);
|
|
186
|
-
var useFieldsManager = function useFieldsManager() {
|
|
187
|
-
return React.useContext(FieldsContext);
|
|
188
|
-
};
|
|
189
|
-
var useFieldDefinition = function useFieldDefinition(id) {
|
|
190
|
-
var manager = useFieldsManager();
|
|
191
|
-
return manager.getDefinition(id);
|
|
192
|
-
};
|
|
193
|
-
var propTypes$i = {
|
|
194
|
-
fields: core.PropTypes.fieldDefinitions,
|
|
195
|
-
manager: PropTypes.instanceOf(core.FieldsManager),
|
|
196
|
-
children: PropTypes.node.isRequired
|
|
197
|
-
};
|
|
198
|
-
var defaultProps$i = {
|
|
199
|
-
fields: null,
|
|
200
|
-
manager: null
|
|
201
|
-
};
|
|
202
|
-
var FieldsProvider = function FieldsProvider(_ref) {
|
|
203
|
-
var fields = _ref.fields,
|
|
204
|
-
manager = _ref.manager,
|
|
205
|
-
children = _ref.children;
|
|
206
|
-
var previousManager = useFieldsManager() || null;
|
|
207
|
-
var finalManager = React.useMemo(function () {
|
|
208
|
-
var newFields = uniqBy([].concat(_toConsumableArray(fields || []), _toConsumableArray(manager !== null ? manager.getDefinitions() : []), _toConsumableArray(previousManager !== null ? previousManager.getDefinitions() : [])), function (_ref2) {
|
|
209
|
-
var id = _ref2.id;
|
|
210
|
-
return id;
|
|
211
|
-
}).reverse();
|
|
212
|
-
return new core.FieldsManager(newFields);
|
|
213
|
-
}, [previousManager, manager, fields]);
|
|
214
|
-
var components = React.useMemo(function () {
|
|
215
|
-
var newComponents = finalManager.getComponents();
|
|
216
|
-
return Object.keys(newComponents).reduce(function (map, id) {
|
|
217
|
-
var component = newComponents[id];
|
|
218
|
-
return isString(component) ? map : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, component));
|
|
219
|
-
}, {});
|
|
220
|
-
}, [finalManager]);
|
|
221
|
-
return /*#__PURE__*/React.createElement(FieldsContext.Provider, {
|
|
222
|
-
value: finalManager
|
|
223
|
-
}, /*#__PURE__*/React.createElement(ComponentsProvider, {
|
|
224
|
-
namespace: FIELDS_NAMESPACE,
|
|
225
|
-
components: components
|
|
226
|
-
}, children));
|
|
227
|
-
};
|
|
228
|
-
FieldsProvider.propTypes = propTypes$i;
|
|
229
|
-
FieldsProvider.defaultProps = defaultProps$i;
|
|
230
|
-
|
|
231
|
-
var ScreensContext = /*#__PURE__*/React.createContext(new core.ScreensManager());
|
|
232
|
-
var useScreensManager = function useScreensManager() {
|
|
233
|
-
return React.useContext(ScreensContext);
|
|
234
|
-
};
|
|
235
|
-
var propTypes$h = {
|
|
236
|
-
screens: core.PropTypes.screenDefinitions,
|
|
237
|
-
namespaces: PropTypes.arrayOf(PropTypes.string),
|
|
238
|
-
filterNamespaces: PropTypes.bool,
|
|
239
|
-
manager: PropTypes.instanceOf(core.ScreensManager),
|
|
240
|
-
children: PropTypes.node.isRequired
|
|
241
|
-
};
|
|
242
|
-
var defaultProps$h = {
|
|
243
|
-
screens: null,
|
|
244
|
-
namespaces: null,
|
|
245
|
-
filterNamespaces: false,
|
|
246
|
-
manager: null
|
|
247
|
-
};
|
|
248
|
-
var ScreensProvider = function ScreensProvider(_ref) {
|
|
249
|
-
var screens = _ref.screens,
|
|
250
|
-
namespaces = _ref.namespaces,
|
|
251
|
-
filterNamespaces = _ref.filterNamespaces,
|
|
252
|
-
manager = _ref.manager,
|
|
253
|
-
children = _ref.children;
|
|
254
|
-
var previousManager = useScreensManager();
|
|
255
|
-
var finalManager = React.useMemo(function () {
|
|
256
|
-
var newManager = manager !== null ? manager : new core.ScreensManager(screens);
|
|
257
|
-
if ((previousManager || null) !== null) {
|
|
258
|
-
newManager = previousManager.merge(newManager);
|
|
259
|
-
}
|
|
260
|
-
if (filterNamespaces) {
|
|
261
|
-
newManager = previousManager.filter(function (_ref2) {
|
|
262
|
-
var _ref2$namespaces = _ref2.namespaces,
|
|
263
|
-
screenGroups = _ref2$namespaces === void 0 ? null : _ref2$namespaces;
|
|
264
|
-
return screenGroups === null || namespaces !== null && screenGroups.reduce(function (acc, id) {
|
|
265
|
-
return acc || namespaces.indexOf(id) !== -1;
|
|
266
|
-
}, false);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return newManager;
|
|
270
|
-
}, [manager, screens, namespaces, filterNamespaces, previousManager]);
|
|
271
|
-
var initialComponents = React.useMemo(function () {
|
|
272
|
-
return finalManager.getComponents();
|
|
273
|
-
}, [finalManager]);
|
|
274
|
-
var _useState = React.useState(initialComponents),
|
|
275
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
276
|
-
components = _useState2[0],
|
|
277
|
-
setComponents = _useState2[1];
|
|
278
|
-
React.useEffect(function () {
|
|
279
|
-
var onChange = function onChange() {
|
|
280
|
-
return setComponents(finalManager.getComponents());
|
|
281
|
-
};
|
|
282
|
-
finalManager.on('change', onChange);
|
|
283
|
-
return function () {
|
|
284
|
-
finalManager.off('change', onChange);
|
|
285
|
-
};
|
|
286
|
-
}, [finalManager, setComponents]);
|
|
287
|
-
return /*#__PURE__*/React.createElement(ScreensContext.Provider, {
|
|
288
|
-
value: finalManager
|
|
289
|
-
}, /*#__PURE__*/React.createElement(ComponentsProvider, {
|
|
290
|
-
namespace: SCREENS_NAMESPACE,
|
|
291
|
-
components: components
|
|
292
|
-
}, children));
|
|
293
|
-
};
|
|
294
|
-
ScreensProvider.propTypes = propTypes$h;
|
|
295
|
-
ScreensProvider.defaultProps = defaultProps$h;
|
|
296
|
-
|
|
297
|
-
var StoryContext = /*#__PURE__*/React.createContext(null);
|
|
298
|
-
var useStoryContext = function useStoryContext() {
|
|
299
|
-
return React.useContext(StoryContext);
|
|
300
|
-
};
|
|
301
|
-
var useStory = function useStory() {
|
|
302
|
-
var story = useStoryContext();
|
|
303
|
-
return story;
|
|
304
|
-
};
|
|
305
|
-
var propTypes$g = {
|
|
306
|
-
story: PropTypes.oneOfType([core.PropTypes.story, core.PropTypes.theme]),
|
|
307
|
-
children: PropTypes.node.isRequired
|
|
308
|
-
};
|
|
309
|
-
var defaultProps$g = {
|
|
310
|
-
story: null
|
|
311
|
-
};
|
|
312
|
-
var StoryProvider = function StoryProvider(_ref) {
|
|
313
|
-
var story = _ref.story,
|
|
314
|
-
children = _ref.children;
|
|
315
|
-
return /*#__PURE__*/React.createElement(StoryContext.Provider, {
|
|
316
|
-
value: story
|
|
317
|
-
}, children);
|
|
318
|
-
};
|
|
319
|
-
StoryProvider.propTypes = propTypes$g;
|
|
320
|
-
StoryProvider.defaultProps = defaultProps$g;
|
|
321
|
-
|
|
322
|
-
var EditorContext = /*#__PURE__*/React.createContext(null);
|
|
323
|
-
var useEditor = function useEditor() {
|
|
324
|
-
return React.useContext(EditorContext);
|
|
325
|
-
};
|
|
326
|
-
var useGetColors = function useGetColors() {
|
|
327
|
-
var _ref = useEditor() || {},
|
|
328
|
-
_ref$getColors = _ref.getColors,
|
|
329
|
-
getColors = _ref$getColors === void 0 ? function () {
|
|
330
|
-
return [];
|
|
331
|
-
} : _ref$getColors;
|
|
332
|
-
return getColors;
|
|
333
|
-
};
|
|
334
|
-
var propTypes$f = {
|
|
335
|
-
children: PropTypes.node.isRequired
|
|
336
|
-
};
|
|
337
|
-
var defaultProps$f = {};
|
|
338
|
-
var EditorProvider = function EditorProvider(_ref2) {
|
|
339
|
-
var children = _ref2.children;
|
|
340
|
-
var story = useStory();
|
|
341
|
-
var screensManager = useScreensManager();
|
|
342
|
-
var fieldsManager = useFieldsManager();
|
|
343
|
-
var parser = React.useMemo(function () {
|
|
344
|
-
return new core.ColorsParser({
|
|
345
|
-
screensManager: screensManager,
|
|
346
|
-
fieldsManager: fieldsManager
|
|
347
|
-
});
|
|
348
|
-
}, [screensManager, fieldsManager]);
|
|
349
|
-
var parse = React.useCallback(function (currentStory) {
|
|
350
|
-
return parser.parse(currentStory);
|
|
351
|
-
}, [parser]);
|
|
352
|
-
var getColors = React.useCallback(function () {
|
|
353
|
-
return parse(story);
|
|
354
|
-
}, [parse, story]);
|
|
355
|
-
|
|
356
|
-
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
357
|
-
return /*#__PURE__*/React.createElement(EditorContext.Provider, {
|
|
358
|
-
value: {
|
|
359
|
-
getColors: getColors
|
|
360
|
-
}
|
|
361
|
-
}, children);
|
|
362
|
-
};
|
|
363
|
-
EditorProvider.propTypes = propTypes$f;
|
|
364
|
-
EditorProvider.defaultProps = defaultProps$f;
|
|
365
|
-
|
|
366
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
367
|
-
var FieldsValueContext = /*#__PURE__*/React.createContext(null);
|
|
368
|
-
var useFieldsValue = function useFieldsValue() {
|
|
369
|
-
return React.useContext(FieldsValueContext);
|
|
370
|
-
};
|
|
371
|
-
var propTypes$e = {
|
|
372
|
-
value: PropTypes.any,
|
|
373
|
-
// eslint-disable-line react/forbid-prop-types
|
|
374
|
-
children: PropTypes.node.isRequired
|
|
375
|
-
};
|
|
376
|
-
var defaultProps$e = {
|
|
377
|
-
value: null
|
|
378
|
-
};
|
|
379
|
-
var FieldsValueContextProvider = function FieldsValueContextProvider(_ref) {
|
|
380
|
-
var value = _ref.value,
|
|
381
|
-
children = _ref.children;
|
|
382
|
-
return /*#__PURE__*/React.createElement(FieldsValueContext.Provider, {
|
|
383
|
-
value: value
|
|
384
|
-
}, children);
|
|
385
|
-
};
|
|
386
|
-
FieldsValueContextProvider.propTypes = propTypes$e;
|
|
387
|
-
FieldsValueContextProvider.defaultProps = defaultProps$e;
|
|
388
|
-
|
|
389
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
390
|
-
var FieldContext = /*#__PURE__*/React.createContext(null);
|
|
391
|
-
var useFieldContext = function useFieldContext() {
|
|
392
|
-
return React.useContext(FieldContext);
|
|
393
|
-
};
|
|
394
|
-
var propTypes$d = {
|
|
395
|
-
context: PropTypes.any,
|
|
396
|
-
// eslint-disable-line react/forbid-prop-types
|
|
397
|
-
children: PropTypes.node.isRequired
|
|
398
|
-
};
|
|
399
|
-
var defaultProps$d = {
|
|
400
|
-
context: null
|
|
401
|
-
};
|
|
402
|
-
var FieldContextProvider = function FieldContextProvider(_ref) {
|
|
403
|
-
var context = _ref.context,
|
|
404
|
-
children = _ref.children;
|
|
405
|
-
return /*#__PURE__*/React.createElement(FieldContext.Provider, {
|
|
406
|
-
value: context
|
|
407
|
-
}, children);
|
|
408
|
-
};
|
|
409
|
-
FieldContextProvider.propTypes = propTypes$d;
|
|
410
|
-
FieldContextProvider.defaultProps = defaultProps$d;
|
|
411
|
-
|
|
412
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
413
|
-
var GoogleKeysContext = /*#__PURE__*/React.createContext({
|
|
414
|
-
apiKey: null
|
|
415
|
-
});
|
|
416
|
-
var useGoogleKeys = function useGoogleKeys() {
|
|
417
|
-
return React.useContext(GoogleKeysContext);
|
|
418
|
-
};
|
|
419
|
-
var propTypes$c = {
|
|
420
|
-
children: PropTypes.node.isRequired,
|
|
421
|
-
apiKey: PropTypes.string // .isRequired,
|
|
422
|
-
};
|
|
423
|
-
var defaultProps$c = {
|
|
424
|
-
apiKey: null
|
|
425
|
-
};
|
|
426
|
-
var GoogleKeysProvider = function GoogleKeysProvider(_ref) {
|
|
427
|
-
var children = _ref.children,
|
|
428
|
-
apiKey = _ref.apiKey;
|
|
429
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
430
|
-
previousApiKey = _useGoogleKeys.apiKey;
|
|
431
|
-
var value = React.useMemo(function () {
|
|
432
|
-
return {
|
|
433
|
-
apiKey: apiKey || previousApiKey
|
|
434
|
-
};
|
|
435
|
-
}, [apiKey, previousApiKey]);
|
|
436
|
-
return /*#__PURE__*/React.createElement(GoogleKeysContext.Provider, {
|
|
437
|
-
value: value
|
|
438
|
-
}, children);
|
|
439
|
-
};
|
|
440
|
-
GoogleKeysProvider.propTypes = propTypes$c;
|
|
441
|
-
GoogleKeysProvider.defaultProps = defaultProps$c;
|
|
442
|
-
|
|
443
|
-
var FontsContext = /*#__PURE__*/React.createContext({
|
|
444
|
-
systemFonts: null,
|
|
445
|
-
googleFonts: null,
|
|
446
|
-
customFonts: null
|
|
447
|
-
});
|
|
448
|
-
var useGoogleFonts = function useGoogleFonts() {
|
|
449
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
450
|
-
_ref$disabled = _ref.disabled,
|
|
451
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
452
|
-
_ref$setFonts = _ref.setFonts,
|
|
453
|
-
setFonts = _ref$setFonts === void 0 ? null : _ref$setFonts;
|
|
454
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
455
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
456
|
-
var _useState = React.useState(null),
|
|
457
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
458
|
-
googleFonts = _useState2[0],
|
|
459
|
-
setGoogleFonts = _useState2[1];
|
|
460
|
-
React.useEffect(function () {
|
|
461
|
-
var canceled = false;
|
|
462
|
-
if (apiKey !== null && !disabled) {
|
|
463
|
-
fetch.getJSON("https://www.googleapis.com/webfonts/v1/webfonts?key=".concat(apiKey, "&sort=popularity")).then(function (_ref2) {
|
|
464
|
-
var _ref2$items = _ref2.items,
|
|
465
|
-
items = _ref2$items === void 0 ? [] : _ref2$items;
|
|
466
|
-
if (!canceled) {
|
|
467
|
-
var newFonts = items.map(function (it) {
|
|
468
|
-
return {
|
|
469
|
-
type: 'google',
|
|
470
|
-
name: it.family,
|
|
471
|
-
variants: it.variants
|
|
472
|
-
};
|
|
473
|
-
});
|
|
474
|
-
if (setFonts !== null) {
|
|
475
|
-
setFonts(newFonts);
|
|
476
|
-
} else {
|
|
477
|
-
setGoogleFonts(newFonts);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
return function () {
|
|
483
|
-
canceled = true;
|
|
484
|
-
};
|
|
485
|
-
}, [apiKey, disabled, setFonts, setGoogleFonts]);
|
|
486
|
-
return googleFonts;
|
|
487
|
-
};
|
|
488
|
-
var useFonts = function useFonts() {
|
|
489
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
490
|
-
_ref3$withoutGoogleFo = _ref3.withoutGoogleFonts,
|
|
491
|
-
withoutGoogleFonts = _ref3$withoutGoogleFo === void 0 ? false : _ref3$withoutGoogleFo;
|
|
492
|
-
var _useContext = React.useContext(FontsContext),
|
|
493
|
-
_useContext$setGoogle = _useContext.setGoogleFonts,
|
|
494
|
-
setGoogleFonts = _useContext$setGoogle === void 0 ? null : _useContext$setGoogle,
|
|
495
|
-
_useContext$systemFon = _useContext.systemFonts,
|
|
496
|
-
systemFonts = _useContext$systemFon === void 0 ? null : _useContext$systemFon,
|
|
497
|
-
_useContext$googleFon = _useContext.googleFonts,
|
|
498
|
-
googleFonts = _useContext$googleFon === void 0 ? null : _useContext$googleFon,
|
|
499
|
-
_useContext$customFon = _useContext.customFonts,
|
|
500
|
-
customFonts = _useContext$customFon === void 0 ? null : _useContext$customFon;
|
|
501
|
-
useGoogleFonts({
|
|
502
|
-
disabled: withoutGoogleFonts || googleFonts !== null && googleFonts.length > 0,
|
|
503
|
-
setFonts: setGoogleFonts
|
|
504
|
-
});
|
|
505
|
-
var fonts = React.useMemo(function () {
|
|
506
|
-
return {
|
|
507
|
-
systemFonts: systemFonts,
|
|
508
|
-
googleFonts: googleFonts,
|
|
509
|
-
customFonts: customFonts
|
|
510
|
-
};
|
|
511
|
-
}, [systemFonts, googleFonts, customFonts]);
|
|
512
|
-
return fonts;
|
|
513
|
-
};
|
|
514
|
-
var propTypes$b = {
|
|
515
|
-
children: PropTypes.node.isRequired,
|
|
516
|
-
systemFonts: core.PropTypes.fonts,
|
|
517
|
-
customFonts: core.PropTypes.fonts
|
|
518
|
-
};
|
|
519
|
-
var defaultProps$b = {
|
|
520
|
-
systemFonts: ['Arial', 'Courier New', 'Georgia', 'Times New Roman', 'Verdana'],
|
|
521
|
-
customFonts: null
|
|
522
|
-
};
|
|
523
|
-
var FontsProvider = function FontsProvider(_ref4) {
|
|
524
|
-
var systemFonts = _ref4.systemFonts,
|
|
525
|
-
customFonts = _ref4.customFonts,
|
|
526
|
-
children = _ref4.children;
|
|
527
|
-
var _useFonts = useFonts(),
|
|
528
|
-
_useFonts$systemFonts = _useFonts.systemFonts,
|
|
529
|
-
previousSystemFonts = _useFonts$systemFonts === void 0 ? null : _useFonts$systemFonts,
|
|
530
|
-
_useFonts$googleFonts = _useFonts.googleFonts,
|
|
531
|
-
previousGoogleFonts = _useFonts$googleFonts === void 0 ? null : _useFonts$googleFonts,
|
|
532
|
-
previousCustomFonts = _useFonts.customFonts;
|
|
533
|
-
var _useState3 = React.useState(null),
|
|
534
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
535
|
-
googleFonts = _useState4[0],
|
|
536
|
-
setGoogleFonts = _useState4[1];
|
|
537
|
-
var fonts = React.useMemo(function () {
|
|
538
|
-
return {
|
|
539
|
-
systemFonts: uniqBy([].concat(_toConsumableArray(previousSystemFonts || []), _toConsumableArray(systemFonts || [])), function (font) {
|
|
540
|
-
return isObject(font) ? font.name : font;
|
|
541
|
-
}),
|
|
542
|
-
googleFonts: uniqBy([].concat(_toConsumableArray(previousGoogleFonts || []), _toConsumableArray(googleFonts || [])), function (font) {
|
|
543
|
-
return isObject(font) ? font.name : font;
|
|
544
|
-
}),
|
|
545
|
-
customFonts: uniqBy([].concat(_toConsumableArray(previousCustomFonts || []), _toConsumableArray(customFonts || [])), function (font) {
|
|
546
|
-
return isObject(font) ? font.name : font;
|
|
547
|
-
}),
|
|
548
|
-
setGoogleFonts: setGoogleFonts
|
|
549
|
-
};
|
|
550
|
-
}, [previousSystemFonts, previousGoogleFonts, previousCustomFonts, customFonts, systemFonts, googleFonts, setGoogleFonts]);
|
|
551
|
-
return /*#__PURE__*/React.createElement(FontsContext.Provider, {
|
|
552
|
-
value: fonts
|
|
553
|
-
}, children);
|
|
554
|
-
};
|
|
555
|
-
FontsProvider.propTypes = propTypes$b;
|
|
556
|
-
FontsProvider.defaultProps = defaultProps$b;
|
|
557
|
-
|
|
558
|
-
var GoogleApiClientContext = /*#__PURE__*/React.createContext(null);
|
|
559
|
-
var useGoogleApiClient = function useGoogleApiClient() {
|
|
560
|
-
return React.useContext(GoogleApiClientContext);
|
|
561
|
-
};
|
|
562
|
-
var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
563
|
-
var getDisplayName = function getDisplayName(_ref) {
|
|
564
|
-
var _ref$displayName = _ref.displayName,
|
|
565
|
-
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
566
|
-
_ref$name = _ref.name,
|
|
567
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
568
|
-
return displayName || name || 'Component';
|
|
569
|
-
};
|
|
570
|
-
var WithGoogleApiClientComponent = function WithGoogleApiClientComponent(props) {
|
|
571
|
-
return /*#__PURE__*/React.createElement(GoogleApiClientContext.Consumer, null, function (client) {
|
|
572
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
573
|
-
googleApiClient: client
|
|
574
|
-
}, props));
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
WithGoogleApiClientComponent.displayName = "WithGoogleApiClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
578
|
-
return WithGoogleApiClientComponent;
|
|
579
|
-
};
|
|
580
|
-
var propTypes$a = {
|
|
581
|
-
children: PropTypes.node.isRequired
|
|
582
|
-
};
|
|
583
|
-
var defaultProps$a = {};
|
|
584
|
-
var GoogleApiClientProvider = function GoogleApiClientProvider(_ref2) {
|
|
585
|
-
var children = _ref2.children;
|
|
586
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
587
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
588
|
-
var _useState = React.useState(null),
|
|
589
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
590
|
-
client = _useState2[0],
|
|
591
|
-
setClient = _useState2[1];
|
|
592
|
-
React.useEffect(function () {
|
|
593
|
-
services.loadGoogleApi().then(function (gapi) {
|
|
594
|
-
return gapi.client.init({
|
|
595
|
-
apiKey: apiKey
|
|
596
|
-
}).then(function () {
|
|
597
|
-
return gapi;
|
|
598
|
-
});
|
|
599
|
-
}).then(function (gapi) {
|
|
600
|
-
return setClient(gapi);
|
|
601
|
-
});
|
|
602
|
-
}, [apiKey, setClient]);
|
|
603
|
-
return /*#__PURE__*/React.createElement(GoogleApiClientContext.Provider, {
|
|
604
|
-
value: client
|
|
605
|
-
}, children);
|
|
606
|
-
};
|
|
607
|
-
GoogleApiClientProvider.propTypes = propTypes$a;
|
|
608
|
-
GoogleApiClientProvider.defaultProps = defaultProps$a;
|
|
609
|
-
|
|
610
|
-
var GoogleMapsClientContext = /*#__PURE__*/React.createContext(null);
|
|
611
|
-
var useGoogleMapsClient = function useGoogleMapsClient() {
|
|
612
|
-
return React.useContext(GoogleMapsClientContext);
|
|
613
|
-
};
|
|
614
|
-
var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
615
|
-
var getDisplayName = function getDisplayName(_ref) {
|
|
616
|
-
var _ref$displayName = _ref.displayName,
|
|
617
|
-
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
618
|
-
_ref$name = _ref.name,
|
|
619
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
620
|
-
return displayName || name || 'Component';
|
|
621
|
-
};
|
|
622
|
-
var WithGoogleMapsClientComponent = function WithGoogleMapsClientComponent(props) {
|
|
623
|
-
return /*#__PURE__*/React.createElement(GoogleMapsClientContext.Consumer, null, function (client) {
|
|
624
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
625
|
-
googleApiClient: client
|
|
626
|
-
}, props));
|
|
627
|
-
});
|
|
628
|
-
};
|
|
629
|
-
WithGoogleMapsClientComponent.displayName = "WithGoogleMapsClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
630
|
-
return WithGoogleMapsClientComponent;
|
|
631
|
-
};
|
|
632
|
-
var propTypes$9 = {
|
|
633
|
-
children: PropTypes.node.isRequired,
|
|
634
|
-
locale: PropTypes.string,
|
|
635
|
-
libraries: PropTypes.arrayOf(PropTypes.string)
|
|
636
|
-
};
|
|
637
|
-
var defaultProps$9 = {
|
|
638
|
-
locale: 'fr',
|
|
639
|
-
libraries: null
|
|
640
|
-
};
|
|
641
|
-
var GoogleMapsClientProvider = function GoogleMapsClientProvider(_ref2) {
|
|
642
|
-
var children = _ref2.children,
|
|
643
|
-
locale = _ref2.locale,
|
|
644
|
-
libraries = _ref2.libraries;
|
|
645
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
646
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
647
|
-
var exisitingClient = useGoogleMapsClient();
|
|
648
|
-
var _useState = React.useState(exisitingClient),
|
|
649
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
650
|
-
client = _useState2[0],
|
|
651
|
-
setClient = _useState2[1];
|
|
652
|
-
React.useEffect(function () {
|
|
653
|
-
if (exisitingClient === null) {
|
|
654
|
-
services.loadGoogleMaps({
|
|
655
|
-
apiKey: apiKey,
|
|
656
|
-
locale: locale,
|
|
657
|
-
libraries: libraries
|
|
658
|
-
}).then(function (newClient) {
|
|
659
|
-
setClient(newClient);
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
}, [apiKey, locale, libraries, setClient, exisitingClient]);
|
|
663
|
-
return /*#__PURE__*/React.createElement(GoogleMapsClientContext.Provider, {
|
|
664
|
-
value: client
|
|
665
|
-
}, children);
|
|
666
|
-
};
|
|
667
|
-
GoogleMapsClientProvider.propTypes = propTypes$9;
|
|
668
|
-
GoogleMapsClientProvider.defaultProps = defaultProps$9;
|
|
669
|
-
|
|
670
|
-
var ModalsContext = /*#__PURE__*/React.createContext({
|
|
671
|
-
container: null
|
|
672
|
-
});
|
|
673
|
-
var useModals = function useModals() {
|
|
674
|
-
return React.useContext(ModalsContext) || {};
|
|
675
|
-
};
|
|
676
|
-
var withModals = function withModals(WrappedComponent) {
|
|
677
|
-
var WithModalsComponent = function WithModalsComponent(props) {
|
|
678
|
-
return /*#__PURE__*/React.createElement(ModalsContext.Consumer, null, function (_ref) {
|
|
679
|
-
var modals = _ref.modals,
|
|
680
|
-
container = _ref.container,
|
|
681
|
-
setContainer = _ref.setContainer,
|
|
682
|
-
register = _ref.register,
|
|
683
|
-
unregister = _ref.unregister;
|
|
684
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
685
|
-
modalsContainer: container,
|
|
686
|
-
setModalsContainer: setContainer,
|
|
687
|
-
modals: modals,
|
|
688
|
-
registerModal: register,
|
|
689
|
-
unregisterModal: unregister
|
|
690
|
-
}, props));
|
|
691
|
-
});
|
|
692
|
-
};
|
|
693
|
-
WithModalsComponent.displayName = "WithModals(".concat(utils.getDisplayName(WrappedComponent), ")");
|
|
694
|
-
return WithModalsComponent;
|
|
695
|
-
};
|
|
696
|
-
var propTypes$8 = {
|
|
697
|
-
children: PropTypes.node.isRequired,
|
|
698
|
-
container: PropTypes.object // eslint-disable-line
|
|
699
|
-
};
|
|
700
|
-
var defaultProps$8 = {
|
|
701
|
-
container: null
|
|
702
|
-
};
|
|
703
|
-
var ModalsProvider = function ModalsProvider(_ref2) {
|
|
704
|
-
var children = _ref2.children,
|
|
705
|
-
initialContainer = _ref2.container;
|
|
706
|
-
var _useState = React.useState(initialContainer),
|
|
707
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
708
|
-
container = _useState2[0],
|
|
709
|
-
setContainer = _useState2[1];
|
|
710
|
-
var _useState3 = React.useState([]),
|
|
711
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
712
|
-
modals = _useState4[0],
|
|
713
|
-
setModals = _useState4[1];
|
|
714
|
-
var modalsRef = React.useRef(modals);
|
|
715
|
-
var register = React.useCallback(function (id) {
|
|
716
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
717
|
-
var currentModals = modalsRef.current;
|
|
718
|
-
var newModals = [].concat(_toConsumableArray(currentModals), [_objectSpread({
|
|
719
|
-
id: id
|
|
720
|
-
}, data)]);
|
|
721
|
-
setModals(newModals);
|
|
722
|
-
modalsRef.current = newModals;
|
|
723
|
-
}, [modals, setModals]);
|
|
724
|
-
var unregister = React.useCallback(function (id) {
|
|
725
|
-
var currentModals = modalsRef.current;
|
|
726
|
-
var foundIndex = currentModals.findIndex(function (_ref3) {
|
|
727
|
-
var modalId = _ref3.id;
|
|
728
|
-
return modalId === id;
|
|
729
|
-
});
|
|
730
|
-
if (foundIndex !== -1) {
|
|
731
|
-
var newModals = currentModals.filter(function (_ref4) {
|
|
732
|
-
var modalId = _ref4.id;
|
|
733
|
-
return modalId !== id;
|
|
734
|
-
});
|
|
735
|
-
setModals(newModals);
|
|
736
|
-
modalsRef.current = newModals;
|
|
737
|
-
}
|
|
738
|
-
}, [modals, setModals]);
|
|
739
|
-
var value = React.useMemo(function () {
|
|
740
|
-
return {
|
|
741
|
-
modals: modals,
|
|
742
|
-
container: container,
|
|
743
|
-
setContainer: setContainer,
|
|
744
|
-
register: register,
|
|
745
|
-
unregister: unregister
|
|
746
|
-
};
|
|
747
|
-
}, [modals, container, setContainer, register, unregister]);
|
|
748
|
-
return /*#__PURE__*/React.createElement(ModalsContext.Provider, {
|
|
749
|
-
value: value
|
|
750
|
-
}, children);
|
|
751
|
-
};
|
|
752
|
-
ModalsProvider.propTypes = propTypes$8;
|
|
753
|
-
ModalsProvider.defaultProps = defaultProps$8;
|
|
754
|
-
|
|
755
|
-
var PanelsContext = /*#__PURE__*/React.createContext({
|
|
756
|
-
container: null
|
|
757
|
-
});
|
|
758
|
-
var usePanels = function usePanels() {
|
|
759
|
-
return React.useContext(PanelsContext) || {};
|
|
760
|
-
};
|
|
761
|
-
var withPanels = function withPanels(WrappedComponent) {
|
|
762
|
-
var WithPanelsComponent = function WithPanelsComponent(props) {
|
|
763
|
-
return /*#__PURE__*/React.createElement(PanelsContext.Consumer, null, function (_ref) {
|
|
764
|
-
var panels = _ref.panels,
|
|
765
|
-
setContainer = _ref.setContainer,
|
|
766
|
-
container = _ref.container,
|
|
767
|
-
register = _ref.register,
|
|
768
|
-
unregister = _ref.unregister;
|
|
769
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
770
|
-
panelsContainer: container,
|
|
771
|
-
setPanelsContainer: setContainer,
|
|
772
|
-
panels: panels,
|
|
773
|
-
registerPanel: register,
|
|
774
|
-
unregisterPanel: unregister
|
|
775
|
-
}, props));
|
|
776
|
-
});
|
|
777
|
-
};
|
|
778
|
-
WithPanelsComponent.displayName = "WithPanels(".concat(utils.getDisplayName(WrappedComponent), ")");
|
|
779
|
-
return WithPanelsComponent;
|
|
780
|
-
};
|
|
781
|
-
var propTypes$7 = {
|
|
782
|
-
children: PropTypes.node.isRequired,
|
|
783
|
-
container: PropTypes.object // eslint-disable-line
|
|
784
|
-
};
|
|
785
|
-
var defaultProps$7 = {
|
|
786
|
-
container: null
|
|
787
|
-
};
|
|
788
|
-
var PanelsProvider = function PanelsProvider(_ref2) {
|
|
789
|
-
var children = _ref2.children,
|
|
790
|
-
initialContainer = _ref2.container;
|
|
791
|
-
var _useState = React.useState(initialContainer),
|
|
792
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
793
|
-
container = _useState2[0],
|
|
794
|
-
setContainer = _useState2[1];
|
|
795
|
-
var _useState3 = React.useState([]),
|
|
796
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
797
|
-
panels = _useState4[0],
|
|
798
|
-
setPanels = _useState4[1];
|
|
799
|
-
var panelsRef = React.useRef(panels);
|
|
800
|
-
var register = React.useCallback(function (id) {
|
|
801
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
802
|
-
var currentPanels = panelsRef.current;
|
|
803
|
-
var newPanels = [].concat(_toConsumableArray(currentPanels), [_objectSpread({
|
|
804
|
-
id: id
|
|
805
|
-
}, data)]);
|
|
806
|
-
setPanels(newPanels);
|
|
807
|
-
panelsRef.current = newPanels;
|
|
808
|
-
}, [panels, setPanels]);
|
|
809
|
-
var unregister = React.useCallback(function (id) {
|
|
810
|
-
var currentPanels = panelsRef.current;
|
|
811
|
-
var foundIndex = currentPanels.findIndex(function (_ref3) {
|
|
812
|
-
var modalId = _ref3.id;
|
|
813
|
-
return modalId === id;
|
|
814
|
-
});
|
|
815
|
-
if (foundIndex !== -1) {
|
|
816
|
-
var newPanels = currentPanels.filter(function (_ref4) {
|
|
817
|
-
var modalId = _ref4.id;
|
|
818
|
-
return modalId !== id;
|
|
819
|
-
});
|
|
820
|
-
setPanels(newPanels);
|
|
821
|
-
panelsRef.current = newPanels;
|
|
822
|
-
}
|
|
823
|
-
}, [panels, setPanels]);
|
|
824
|
-
var value = React.useMemo(function () {
|
|
825
|
-
return {
|
|
826
|
-
panels: panels,
|
|
827
|
-
setContainer: setContainer,
|
|
828
|
-
container: container,
|
|
829
|
-
register: register,
|
|
830
|
-
unregister: unregister
|
|
831
|
-
};
|
|
832
|
-
}, [panels, setContainer, container, register, unregister]);
|
|
833
|
-
return /*#__PURE__*/React.createElement(PanelsContext.Provider, {
|
|
834
|
-
value: value
|
|
835
|
-
}, children);
|
|
836
|
-
};
|
|
837
|
-
PanelsProvider.propTypes = propTypes$7;
|
|
838
|
-
PanelsProvider.defaultProps = defaultProps$7;
|
|
839
|
-
|
|
840
|
-
var defaultControlsThemeValue = {
|
|
841
|
-
seekBarOnly: false,
|
|
842
|
-
color: null,
|
|
843
|
-
progressColor: null
|
|
844
|
-
};
|
|
845
|
-
var defaultValue$1 = {
|
|
846
|
-
playing: false,
|
|
847
|
-
paused: false,
|
|
848
|
-
muted: true,
|
|
849
|
-
controls: false,
|
|
850
|
-
controlsSuggestPlay: false,
|
|
851
|
-
controlsVisible: false,
|
|
852
|
-
media: null,
|
|
853
|
-
controlsTheme: defaultControlsThemeValue
|
|
854
|
-
};
|
|
855
|
-
var PlaybackContext = /*#__PURE__*/React.createContext(_objectSpread(_objectSpread({}, defaultValue$1), {}, {
|
|
856
|
-
setMuted: function setMuted() {},
|
|
857
|
-
setPlaying: function setPlaying() {},
|
|
858
|
-
setControls: function setControls() {},
|
|
859
|
-
setControlsVisible: function setControlsVisible() {},
|
|
860
|
-
setControlsTheme: function setControlsTheme() {},
|
|
861
|
-
showControls: function showControls() {},
|
|
862
|
-
hideControls: function hideControls() {},
|
|
863
|
-
setMedia: function setMedia() {}
|
|
864
|
-
}));
|
|
865
|
-
var usePlaybackContext = function usePlaybackContext() {
|
|
866
|
-
return React.useContext(PlaybackContext);
|
|
867
|
-
};
|
|
868
|
-
var usePlaybackMediaRef = function usePlaybackMediaRef(active) {
|
|
869
|
-
var _usePlaybackContext = usePlaybackContext(),
|
|
870
|
-
setMedia = _usePlaybackContext.setMedia;
|
|
871
|
-
var mediaRef = React.useRef(null);
|
|
872
|
-
React.useEffect(function () {
|
|
873
|
-
if (!active) {
|
|
874
|
-
return function () {};
|
|
875
|
-
}
|
|
876
|
-
if (mediaRef.current !== null) {
|
|
877
|
-
setMedia(mediaRef.current);
|
|
878
|
-
}
|
|
879
|
-
return function () {
|
|
880
|
-
setMedia(null);
|
|
881
|
-
};
|
|
882
|
-
}, [setMedia, active]);
|
|
883
|
-
return mediaRef;
|
|
884
|
-
};
|
|
885
|
-
var propTypes$6 = {
|
|
886
|
-
children: PropTypes.node.isRequired,
|
|
887
|
-
controls: PropTypes.bool,
|
|
888
|
-
controlsSuggestPlay: PropTypes.bool,
|
|
889
|
-
controlsVisible: PropTypes.bool,
|
|
890
|
-
controlsTheme: PropTypes.shape({
|
|
891
|
-
seekBarOnly: PropTypes.bool,
|
|
892
|
-
color: PropTypes.any,
|
|
893
|
-
progressColor: PropTypes.any
|
|
894
|
-
}),
|
|
895
|
-
muted: PropTypes.bool,
|
|
896
|
-
playing: PropTypes.bool,
|
|
897
|
-
paused: PropTypes.bool
|
|
898
|
-
};
|
|
899
|
-
var defaultProps$6 = _objectSpread({}, defaultValue$1);
|
|
900
|
-
var PlaybackProvider = function PlaybackProvider(_ref) {
|
|
901
|
-
var initialMuted = _ref.muted,
|
|
902
|
-
initialPlaying = _ref.playing,
|
|
903
|
-
paused = _ref.paused,
|
|
904
|
-
initialControls = _ref.controls,
|
|
905
|
-
initialControlsSuggestPlay = _ref.controlsSuggestPlay,
|
|
906
|
-
initialControlsVisible = _ref.controlsVisible,
|
|
907
|
-
initialControlsTheme = _ref.controlsTheme,
|
|
908
|
-
children = _ref.children;
|
|
909
|
-
var _useState = React.useState(initialMuted),
|
|
910
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
911
|
-
muted = _useState2[0],
|
|
912
|
-
setMuted = _useState2[1];
|
|
913
|
-
var _useState3 = React.useState(initialPlaying),
|
|
914
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
915
|
-
playing = _useState4[0],
|
|
916
|
-
setPlaying = _useState4[1];
|
|
917
|
-
var _useState5 = React.useState(null),
|
|
918
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
919
|
-
media = _useState6[0],
|
|
920
|
-
setMedia = _useState6[1];
|
|
921
|
-
var _useState7 = React.useState(initialControls),
|
|
922
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
923
|
-
controls = _useState8[0],
|
|
924
|
-
setControls = _useState8[1];
|
|
925
|
-
var _useState9 = React.useState(initialControlsSuggestPlay),
|
|
926
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
927
|
-
controlsSuggestPlay = _useState10[0],
|
|
928
|
-
setControlsSuggestPlay = _useState10[1];
|
|
929
|
-
var _useState11 = React.useState(initialControlsVisible),
|
|
930
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
931
|
-
controlsVisible = _useState12[0],
|
|
932
|
-
setControlsVisible = _useState12[1];
|
|
933
|
-
var _useState13 = React.useState(initialControlsTheme),
|
|
934
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
935
|
-
controlsTheme = _useState14[0],
|
|
936
|
-
setControlsTheme = _useState14[1];
|
|
937
|
-
var finalSetControls = React.useCallback(function (newControls) {
|
|
938
|
-
if (newControls) {
|
|
939
|
-
setControls(true);
|
|
940
|
-
setControlsVisible(true);
|
|
941
|
-
setControlsSuggestPlay(false);
|
|
942
|
-
} else {
|
|
943
|
-
setControls(false);
|
|
944
|
-
setControlsVisible(false);
|
|
945
|
-
setControlsSuggestPlay(false);
|
|
946
|
-
}
|
|
947
|
-
}, [setControls, setControlsVisible, setControlsSuggestPlay]);
|
|
948
|
-
var finalSetControlsTheme = React.useCallback(function (newTheme) {
|
|
949
|
-
setControlsTheme(_objectSpread(_objectSpread({}, defaultControlsThemeValue), newTheme));
|
|
950
|
-
}, [setControlsTheme]);
|
|
951
|
-
var finalSetPlaying = React.useCallback(function (value) {
|
|
952
|
-
if (value) {
|
|
953
|
-
setControlsSuggestPlay(false);
|
|
954
|
-
}
|
|
955
|
-
setPlaying(value);
|
|
956
|
-
}, [setPlaying, setControlsSuggestPlay]);
|
|
957
|
-
|
|
958
|
-
// Reset on media change
|
|
959
|
-
React.useEffect(function () {
|
|
960
|
-
setControlsSuggestPlay(false);
|
|
961
|
-
}, [media, setControlsSuggestPlay]);
|
|
962
|
-
var showControls = React.useCallback(function () {
|
|
963
|
-
return setControlsVisible(true);
|
|
964
|
-
}, [setControlsVisible]);
|
|
965
|
-
var hideControls = React.useCallback(function () {
|
|
966
|
-
setControlsVisible(false);
|
|
967
|
-
}, [setControlsVisible]);
|
|
968
|
-
var hasAudio = React.useMemo(function () {
|
|
969
|
-
if (media === null || media.tagName.toLowerCase() !== 'video') {
|
|
970
|
-
return false;
|
|
971
|
-
}
|
|
972
|
-
if (media.tagName.toLowerCase() === 'audio') {
|
|
973
|
-
return true;
|
|
974
|
-
}
|
|
975
|
-
if (typeof media.dataset.hasAudio === 'undefined') {
|
|
976
|
-
return null;
|
|
977
|
-
}
|
|
978
|
-
return media.dataset.hasAudio === 'true' || media.dataset.hasAudio === true;
|
|
979
|
-
}, [media]);
|
|
980
|
-
var value = React.useMemo(function () {
|
|
981
|
-
return {
|
|
982
|
-
muted: muted,
|
|
983
|
-
playing: playing && !paused,
|
|
984
|
-
controls: controls,
|
|
985
|
-
controlsSuggestPlay: controlsSuggestPlay,
|
|
986
|
-
controlsVisible: controlsVisible,
|
|
987
|
-
media: media,
|
|
988
|
-
hasAudio: hasAudio,
|
|
989
|
-
controlsTheme: controlsTheme,
|
|
990
|
-
setMuted: setMuted,
|
|
991
|
-
setPlaying: finalSetPlaying,
|
|
992
|
-
setControls: finalSetControls,
|
|
993
|
-
setControlsSuggestPlay: setControlsSuggestPlay,
|
|
994
|
-
setControlsVisible: setControlsVisible,
|
|
995
|
-
setControlsTheme: finalSetControlsTheme,
|
|
996
|
-
showControls: showControls,
|
|
997
|
-
hideControls: hideControls,
|
|
998
|
-
setMedia: setMedia
|
|
999
|
-
};
|
|
1000
|
-
}, [muted, playing, paused, controls, controlsSuggestPlay, controlsVisible, controlsTheme, media, hasAudio, setMuted, finalSetPlaying, finalSetControls, finalSetControlsTheme, setControlsSuggestPlay, setControlsVisible, setControlsTheme, showControls, hideControls, setMedia]);
|
|
1001
|
-
return /*#__PURE__*/React.createElement(PlaybackContext.Provider, {
|
|
1002
|
-
value: value
|
|
1003
|
-
}, children);
|
|
1004
|
-
};
|
|
1005
|
-
PlaybackProvider.propTypes = propTypes$6;
|
|
1006
|
-
PlaybackProvider.defaultProps = defaultProps$6;
|
|
1007
|
-
|
|
1008
|
-
var useEffect = React__namespace.useEffect,
|
|
1009
|
-
useLayoutEffect = React__namespace.useLayoutEffect,
|
|
1010
|
-
useRef = React__namespace.useRef;
|
|
1011
|
-
|
|
1012
|
-
// React.useInsertionEffect is not available in React <18
|
|
1013
|
-
// This hack fixes a transpilation issue on some apps
|
|
1014
|
-
var useBuiltinInsertionEffect = React__namespace['useInsertion' + 'Effect'];
|
|
1015
|
-
|
|
1016
|
-
// Copied from:
|
|
1017
|
-
// https://github.com/facebook/react/blob/main/packages/shared/ExecutionEnvironment.js
|
|
1018
|
-
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
1019
|
-
|
|
1020
|
-
// Copied from:
|
|
1021
|
-
// https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.ts
|
|
1022
|
-
// "React currently throws a warning when using useLayoutEffect on the server.
|
|
1023
|
-
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
1024
|
-
// useLayoutEffect in the browser."
|
|
1025
|
-
var useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
|
1026
|
-
|
|
1027
|
-
// useInsertionEffect is already a noop on the server.
|
|
1028
|
-
// See: https://github.com/facebook/react/blob/main/packages/react-server/src/ReactFizzHooks.js
|
|
1029
|
-
var useInsertionEffect = useBuiltinInsertionEffect || useIsomorphicLayoutEffect;
|
|
1030
|
-
|
|
1031
|
-
// Userland polyfill while we wait for the forthcoming
|
|
1032
|
-
// https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
|
1033
|
-
// Note: "A high-fidelity polyfill for useEvent is not possible because
|
|
1034
|
-
// there is no lifecycle or Hook in React that we can use to switch
|
|
1035
|
-
// .current at the right timing."
|
|
1036
|
-
// So we will have to make do with this "close enough" approach for now.
|
|
1037
|
-
var useEvent = function useEvent(fn) {
|
|
1038
|
-
var ref = useRef([fn, function () {
|
|
1039
|
-
return ref[0].apply(ref, arguments);
|
|
1040
|
-
}]).current;
|
|
1041
|
-
// Per Dan Abramov: useInsertionEffect executes marginally closer to the
|
|
1042
|
-
// correct timing for ref synchronization than useLayoutEffect on React 18.
|
|
1043
|
-
// See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
|
|
1044
|
-
useInsertionEffect(function () {
|
|
1045
|
-
ref[0] = fn;
|
|
1046
|
-
});
|
|
1047
|
-
return ref[1];
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
/**
|
|
1051
|
-
* History API docs @see https://developer.mozilla.org/en-US/docs/Web/API/History
|
|
1052
|
-
*/
|
|
1053
|
-
var eventPopstate = "popstate";
|
|
1054
|
-
var eventPushState = "pushState";
|
|
1055
|
-
var eventReplaceState = "replaceState";
|
|
1056
|
-
var eventHashchange = "hashchange";
|
|
1057
|
-
var events = [eventPopstate, eventPushState, eventReplaceState, eventHashchange];
|
|
1058
|
-
var subscribeToLocationUpdates = function subscribeToLocationUpdates(callback) {
|
|
1059
|
-
for (var _i = 0, _events = events; _i < _events.length; _i++) {
|
|
1060
|
-
var event = _events[_i];
|
|
1061
|
-
addEventListener(event, callback);
|
|
1062
|
-
}
|
|
1063
|
-
return function () {
|
|
1064
|
-
for (var _i2 = 0, _events2 = events; _i2 < _events2.length; _i2++) {
|
|
1065
|
-
var _event = _events2[_i2];
|
|
1066
|
-
removeEventListener(_event, callback);
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
};
|
|
1070
|
-
var useLocationProperty = function useLocationProperty(fn, ssrFn) {
|
|
1071
|
-
return index_js.useSyncExternalStore(subscribeToLocationUpdates, fn, ssrFn);
|
|
1072
|
-
};
|
|
1073
|
-
var currentSearch = function currentSearch() {
|
|
1074
|
-
return location.search;
|
|
1075
|
-
};
|
|
1076
|
-
var useSearch = function useSearch() {
|
|
1077
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1078
|
-
_ref$ssrSearch = _ref.ssrSearch,
|
|
1079
|
-
ssrSearch = _ref$ssrSearch === void 0 ? "" : _ref$ssrSearch;
|
|
1080
|
-
return useLocationProperty(currentSearch, function () {
|
|
1081
|
-
return ssrSearch;
|
|
1082
|
-
});
|
|
1083
|
-
};
|
|
1084
|
-
var currentPathname = function currentPathname() {
|
|
1085
|
-
return location.pathname;
|
|
1086
|
-
};
|
|
1087
|
-
var usePathname = function usePathname() {
|
|
1088
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1089
|
-
ssrPath = _ref2.ssrPath;
|
|
1090
|
-
return useLocationProperty(currentPathname, ssrPath ? function () {
|
|
1091
|
-
return ssrPath;
|
|
1092
|
-
} : currentPathname);
|
|
1093
|
-
};
|
|
1094
|
-
var navigate = function navigate(to) {
|
|
1095
|
-
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1096
|
-
_ref3$replace = _ref3.replace,
|
|
1097
|
-
replace = _ref3$replace === void 0 ? false : _ref3$replace,
|
|
1098
|
-
_ref3$state = _ref3.state,
|
|
1099
|
-
state = _ref3$state === void 0 ? null : _ref3$state;
|
|
1100
|
-
return history[replace ? eventReplaceState : eventPushState](state, "", to);
|
|
1101
|
-
};
|
|
1102
|
-
|
|
1103
|
-
// the 2nd argument of the `useBrowserLocation` return value is a function
|
|
1104
|
-
// that allows to perform a navigation.
|
|
1105
|
-
var useBrowserLocation = function useBrowserLocation() {
|
|
1106
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1107
|
-
return [usePathname(opts), navigate];
|
|
1108
|
-
};
|
|
1109
|
-
var patchKey = Symbol["for"]("wouter_v3");
|
|
1110
|
-
|
|
1111
|
-
// While History API does have `popstate` event, the only
|
|
1112
|
-
// proper way to listen to changes via `push/replaceState`
|
|
1113
|
-
// is to monkey-patch these methods.
|
|
1114
|
-
//
|
|
1115
|
-
// See https://stackoverflow.com/a/4585031
|
|
1116
|
-
if (typeof history !== "undefined" && typeof window[patchKey] === "undefined") {
|
|
1117
|
-
var _loop = function _loop() {
|
|
1118
|
-
var type = _arr[_i3];
|
|
1119
|
-
var original = history[type];
|
|
1120
|
-
// TODO: we should be using unstable_batchedUpdates to avoid multiple re-renders,
|
|
1121
|
-
// however that will require an additional peer dependency on react-dom.
|
|
1122
|
-
// See: https://github.com/reactwg/react-18/discussions/86#discussioncomment-1567149
|
|
1123
|
-
history[type] = function () {
|
|
1124
|
-
var result = original.apply(this, arguments);
|
|
1125
|
-
var event = new Event(type);
|
|
1126
|
-
event.arguments = arguments;
|
|
1127
|
-
dispatchEvent(event);
|
|
1128
|
-
return result;
|
|
1129
|
-
};
|
|
1130
|
-
};
|
|
1131
|
-
for (var _i3 = 0, _arr = [eventPushState, eventReplaceState]; _i3 < _arr.length; _i3++) {
|
|
1132
|
-
_loop();
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
// patch history object only once
|
|
1136
|
-
// See: https://github.com/molefrog/wouter/issues/167
|
|
1137
|
-
Object.defineProperty(window, patchKey, {
|
|
1138
|
-
value: true
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
var _excluded3 = ["to", "href", "onClick", "asChild", "children", "className", "replace", "state"];
|
|
1143
|
-
|
|
1144
|
-
/*
|
|
1145
|
-
* Transforms `path` into its relative `base` version
|
|
1146
|
-
* If base isn't part of the path provided returns absolute path e.g. `~/app`
|
|
1147
|
-
*/
|
|
1148
|
-
var relativePath = function relativePath() {
|
|
1149
|
-
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
1150
|
-
var path = arguments.length > 1 ? arguments[1] : undefined;
|
|
1151
|
-
return !path.toLowerCase().indexOf(base.toLowerCase()) ? path.slice(base.length) || "/" : "~" + path;
|
|
1152
|
-
};
|
|
1153
|
-
var absolutePath = function absolutePath(to) {
|
|
1154
|
-
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
1155
|
-
return to[0] === "~" ? to.slice(1) : base + to;
|
|
1156
|
-
};
|
|
1157
|
-
|
|
1158
|
-
/*
|
|
1159
|
-
* decodes escape sequences such as %20
|
|
1160
|
-
*/
|
|
1161
|
-
var unescape = function unescape(str) {
|
|
1162
|
-
try {
|
|
1163
|
-
return decodeURI(str);
|
|
1164
|
-
} catch (_e) {
|
|
1165
|
-
// fail-safe mode: if string can't be decoded do nothing
|
|
1166
|
-
return str;
|
|
1167
|
-
}
|
|
1168
|
-
};
|
|
1169
|
-
|
|
1170
|
-
/*
|
|
1171
|
-
* Router and router context. Router is a lightweight object that represents the current
|
|
1172
|
-
* routing options: how location is managed, base path etc.
|
|
1173
|
-
*
|
|
1174
|
-
* There is a default router present for most of the use cases, however it can be overridden
|
|
1175
|
-
* via the <Router /> component.
|
|
1176
|
-
*/
|
|
1177
|
-
|
|
1178
|
-
var defaultRouter = {
|
|
1179
|
-
hook: useBrowserLocation,
|
|
1180
|
-
searchHook: useSearch,
|
|
1181
|
-
parser: regexparam.parse,
|
|
1182
|
-
base: "",
|
|
1183
|
-
// this option is used to override the current location during SSR
|
|
1184
|
-
ssrPath: undefined,
|
|
1185
|
-
ssrSearch: undefined,
|
|
1186
|
-
// customizes how `href` props are transformed for <Link />
|
|
1187
|
-
hrefs: function hrefs(x) {
|
|
1188
|
-
return x;
|
|
1189
|
-
}
|
|
1190
|
-
};
|
|
1191
|
-
var RouterCtx = React.createContext(defaultRouter);
|
|
1192
|
-
|
|
1193
|
-
// gets the closest parent router from the context
|
|
1194
|
-
var useRouter = function useRouter() {
|
|
1195
|
-
return React.useContext(RouterCtx);
|
|
1196
|
-
};
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Parameters context. Used by `useParams()` to get the
|
|
1200
|
-
* matched params from the innermost `Route` component.
|
|
1201
|
-
*/
|
|
1202
|
-
|
|
1203
|
-
React.createContext({});
|
|
1204
|
-
|
|
1205
|
-
/*
|
|
1206
|
-
* Part 1, Hooks API: useRoute and useLocation
|
|
1207
|
-
*/
|
|
1208
|
-
|
|
1209
|
-
// Internal version of useLocation to avoid redundant useRouter calls
|
|
1210
|
-
|
|
1211
|
-
var useLocationFromRouter = function useLocationFromRouter(router) {
|
|
1212
|
-
var _router$hook = router.hook(router),
|
|
1213
|
-
_router$hook2 = _slicedToArray(_router$hook, 2),
|
|
1214
|
-
location = _router$hook2[0],
|
|
1215
|
-
navigate = _router$hook2[1];
|
|
1216
|
-
|
|
1217
|
-
// the function reference should stay the same between re-renders, so that
|
|
1218
|
-
// it can be passed down as an element prop without any performance concerns.
|
|
1219
|
-
// (This is achieved via `useEvent`.)
|
|
1220
|
-
return [unescape(relativePath(router.base, location)), useEvent(function (to, navOpts) {
|
|
1221
|
-
return navigate(absolutePath(to, router.base), navOpts);
|
|
1222
|
-
})];
|
|
1223
|
-
};
|
|
1224
|
-
var useLocation = function useLocation() {
|
|
1225
|
-
return useLocationFromRouter(useRouter());
|
|
1226
|
-
};
|
|
1227
|
-
React.forwardRef(function (props, ref) {
|
|
1228
|
-
var router = useRouter();
|
|
1229
|
-
var _useLocationFromRoute3 = useLocationFromRouter(router),
|
|
1230
|
-
_useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
|
|
1231
|
-
path = _useLocationFromRoute4[0],
|
|
1232
|
-
navigate = _useLocationFromRoute4[1];
|
|
1233
|
-
var to = props.to,
|
|
1234
|
-
_props$href = props.href,
|
|
1235
|
-
_href = _props$href === void 0 ? to : _props$href,
|
|
1236
|
-
_onClick = props.onClick,
|
|
1237
|
-
asChild = props.asChild,
|
|
1238
|
-
children = props.children,
|
|
1239
|
-
cls = props.className;
|
|
1240
|
-
props.replace;
|
|
1241
|
-
props.state;
|
|
1242
|
-
var restProps = _objectWithoutProperties(props, _excluded3);
|
|
1243
|
-
var onClick = useEvent(function (event) {
|
|
1244
|
-
// ignores the navigation when clicked using right mouse button or
|
|
1245
|
-
// by holding a special modifier key: ctrl, command, win, alt, shift
|
|
1246
|
-
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) return;
|
|
1247
|
-
_onClick === null || _onClick === void 0 || _onClick(event);
|
|
1248
|
-
if (!event.defaultPrevented) {
|
|
1249
|
-
event.preventDefault();
|
|
1250
|
-
navigate(_href, props);
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
|
|
1254
|
-
// handle nested routers and absolute paths
|
|
1255
|
-
var href = router.hrefs(_href[0] === "~" ? _href.slice(1) : router.base + _href, router // pass router as a second argument for convinience
|
|
1256
|
-
);
|
|
1257
|
-
return asChild && React.isValidElement(children) ? React.cloneElement(children, {
|
|
1258
|
-
onClick: onClick,
|
|
1259
|
-
href: href
|
|
1260
|
-
}) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
1261
|
-
onClick: onClick,
|
|
1262
|
-
href: href,
|
|
1263
|
-
// `className` can be a function to apply the class if this link is active
|
|
1264
|
-
className: cls !== null && cls !== void 0 && cls.call ? cls(path === href) : cls,
|
|
1265
|
-
children: children,
|
|
1266
|
-
ref: ref
|
|
1267
|
-
}));
|
|
1268
|
-
});
|
|
1269
|
-
|
|
1270
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1271
|
-
var RoutesContext = /*#__PURE__*/React.createContext(null);
|
|
1272
|
-
var useRoutesContext = function useRoutesContext() {
|
|
1273
|
-
return React.useContext(RoutesContext);
|
|
1274
|
-
};
|
|
1275
|
-
var propTypes$5 = {
|
|
1276
|
-
children: PropTypes.node.isRequired,
|
|
1277
|
-
routes: PropTypes.objectOf(PropTypes.string).isRequired,
|
|
1278
|
-
basePath: PropTypes.string
|
|
1279
|
-
};
|
|
1280
|
-
var defaultProps$5 = {
|
|
1281
|
-
basePath: null
|
|
1282
|
-
};
|
|
1283
|
-
function RoutesProvider(_ref) {
|
|
1284
|
-
var routes = _ref.routes,
|
|
1285
|
-
basePath = _ref.basePath,
|
|
1286
|
-
children = _ref.children;
|
|
1287
|
-
var value = React.useMemo(function () {
|
|
1288
|
-
return {
|
|
1289
|
-
routes: routes,
|
|
1290
|
-
basePath: basePath
|
|
1291
|
-
};
|
|
1292
|
-
}, [routes, basePath]);
|
|
1293
|
-
return /*#__PURE__*/jsxRuntime.jsx(RoutesContext.Provider, {
|
|
1294
|
-
value: value,
|
|
1295
|
-
children: children
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
RoutesProvider.propTypes = propTypes$5;
|
|
1299
|
-
RoutesProvider.defaultProps = defaultProps$5;
|
|
1300
|
-
var compilers = {};
|
|
1301
|
-
function generatePath(fullPath, data) {
|
|
1302
|
-
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1303
|
-
var fullUrlMatches = fullPath.match(/^(https?:\/\/)/);
|
|
1304
|
-
if (typeof compilers[fullPath] === 'undefined') {
|
|
1305
|
-
compilers[fullPath] = pathToRegexp.compile(fullPath.replace(/^(https?:\/\/)/, ''), opts);
|
|
1306
|
-
}
|
|
1307
|
-
var compiler = compilers[fullPath];
|
|
1308
|
-
return fullUrlMatches !== null ? "".concat(fullUrlMatches[1]).concat(compiler(data)) : compiler(data);
|
|
1309
|
-
}
|
|
1310
|
-
var useUrlGeneratorPathToRepexp = function useUrlGeneratorPathToRepexp() {
|
|
1311
|
-
var _ref2 = useRoutesContext() || {},
|
|
1312
|
-
_ref2$routes = _ref2.routes,
|
|
1313
|
-
routes = _ref2$routes === void 0 ? null : _ref2$routes,
|
|
1314
|
-
_ref2$basePath = _ref2.basePath,
|
|
1315
|
-
basePath = _ref2$basePath === void 0 ? null : _ref2$basePath;
|
|
1316
|
-
var urlGenerator = React.useCallback(function (key, data, opts) {
|
|
1317
|
-
var path = routes !== null ? routes[key] || null : null;
|
|
1318
|
-
if (path === null) {
|
|
1319
|
-
return null;
|
|
1320
|
-
}
|
|
1321
|
-
var url = generatePath(path, data, opts);
|
|
1322
|
-
return basePath !== null ? "".concat(basePath.replace(/\/$/, ''), "/").concat(url.replace(/^\//, '')) : url;
|
|
1323
|
-
}, [routes, basePath]);
|
|
1324
|
-
return urlGenerator;
|
|
1325
|
-
};
|
|
1326
|
-
var useUrlGeneratorPathToRegexp = useUrlGeneratorPathToRepexp;
|
|
1327
|
-
var useRoutes = function useRoutes() {
|
|
1328
|
-
var _useRoutesContext = useRoutesContext(),
|
|
1329
|
-
routes = _useRoutesContext.routes;
|
|
1330
|
-
return routes;
|
|
1331
|
-
};
|
|
1332
|
-
var useRoutes$1 = useRoutes;
|
|
1333
|
-
|
|
1334
|
-
var useRoutePush = function useRoutePush() {
|
|
1335
|
-
var url = useUrlGeneratorPathToRegexp();
|
|
1336
|
-
var _useLocation = useLocation(),
|
|
1337
|
-
_useLocation2 = _slicedToArray(_useLocation, 2),
|
|
1338
|
-
navigate = _useLocation2[1];
|
|
1339
|
-
var push = React.useCallback(function (route, data) {
|
|
1340
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1341
|
-
args[_key - 2] = arguments[_key];
|
|
1342
|
-
}
|
|
1343
|
-
if (isString(route)) {
|
|
1344
|
-
navigate.apply(void 0, [url(route, data)].concat(args));
|
|
1345
|
-
} else {
|
|
1346
|
-
var _ref = route || {},
|
|
1347
|
-
_ref$pathname = _ref.pathname,
|
|
1348
|
-
pathname = _ref$pathname === void 0 ? null : _ref$pathname,
|
|
1349
|
-
_ref$search = _ref.search,
|
|
1350
|
-
search = _ref$search === void 0 ? null : _ref$search;
|
|
1351
|
-
navigate.apply(void 0, ["".concat(url(pathname, data)).concat(search !== null ? "?".concat(search) : '')].concat(args));
|
|
1352
|
-
}
|
|
1353
|
-
}, [navigate, url]);
|
|
1354
|
-
return push;
|
|
1355
|
-
};
|
|
1356
|
-
var useRouteBack = function useRouteBack() {
|
|
1357
|
-
var url = useUrlGeneratorPathToRegexp();
|
|
1358
|
-
var _useLocation3 = useLocation(),
|
|
1359
|
-
_useLocation4 = _slicedToArray(_useLocation3, 2),
|
|
1360
|
-
navigate = _useLocation4[1];
|
|
1361
|
-
var back = React.useCallback(function () {
|
|
1362
|
-
return navigate(-1);
|
|
1363
|
-
}, [navigate, url]);
|
|
1364
|
-
return back;
|
|
1365
|
-
};
|
|
1366
|
-
|
|
1367
|
-
var ScreenContext = /*#__PURE__*/React.createContext({
|
|
1368
|
-
data: null,
|
|
1369
|
-
definition: null,
|
|
1370
|
-
renderContext: null
|
|
1371
|
-
});
|
|
1372
|
-
var useScreen = function useScreen() {
|
|
1373
|
-
return React.useContext(ScreenContext);
|
|
1374
|
-
};
|
|
1375
|
-
var useScreenDefinition = function useScreenDefinition() {
|
|
1376
|
-
var intl = reactIntl.useIntl();
|
|
1377
|
-
var _ref = useScreen() || {},
|
|
1378
|
-
_ref$definition = _ref.definition,
|
|
1379
|
-
definition = _ref$definition === void 0 ? null : _ref$definition;
|
|
1380
|
-
var _ref2 = definition || {},
|
|
1381
|
-
_ref2$fields = _ref2.fields,
|
|
1382
|
-
fields = _ref2$fields === void 0 ? null : _ref2$fields;
|
|
1383
|
-
var finalFields = React.useMemo(function () {
|
|
1384
|
-
return fields !== null ? [].concat(_toConsumableArray(fields), [utils.getScreenExtraField(intl)]) : null;
|
|
1385
|
-
}, [fields]);
|
|
1386
|
-
return _objectSpread(_objectSpread({}, definition), {}, {
|
|
1387
|
-
fields: finalFields
|
|
1388
|
-
});
|
|
1389
|
-
};
|
|
1390
|
-
var useScreenData = function useScreenData() {
|
|
1391
|
-
var _ref3 = useScreen() || {},
|
|
1392
|
-
data = _ref3.data;
|
|
1393
|
-
return data;
|
|
1394
|
-
};
|
|
1395
|
-
var useScreenRenderContext = function useScreenRenderContext() {
|
|
1396
|
-
var _ref4 = useScreen() || {},
|
|
1397
|
-
_ref4$renderContext = _ref4.renderContext,
|
|
1398
|
-
renderContext = _ref4$renderContext === void 0 ? 'view' : _ref4$renderContext;
|
|
1399
|
-
var isPlaceholder = renderContext === 'placeholder';
|
|
1400
|
-
var isPreview = renderContext === 'preview';
|
|
1401
|
-
var isEdit = renderContext === 'edit';
|
|
1402
|
-
var isView = renderContext === 'view';
|
|
1403
|
-
var isStatic = renderContext === 'static';
|
|
1404
|
-
var isCapture = renderContext === 'capture';
|
|
1405
|
-
return {
|
|
1406
|
-
renderContext: renderContext,
|
|
1407
|
-
isPlaceholder: isPlaceholder,
|
|
1408
|
-
isPreview: isPreview,
|
|
1409
|
-
isEdit: isEdit,
|
|
1410
|
-
isView: isView || isStatic || isCapture,
|
|
1411
|
-
isStatic: isStatic,
|
|
1412
|
-
isCapture: isCapture
|
|
1413
|
-
};
|
|
1414
|
-
};
|
|
1415
|
-
var useScreenState = function useScreenState() {
|
|
1416
|
-
var _ref5 = useScreen() || {},
|
|
1417
|
-
screenState = _ref5.screenState;
|
|
1418
|
-
return screenState;
|
|
1419
|
-
};
|
|
1420
|
-
var propTypes$4 = {
|
|
1421
|
-
children: PropTypes.node.isRequired,
|
|
1422
|
-
data: core.PropTypes.screen,
|
|
1423
|
-
definition: core.PropTypes.screenDefinition,
|
|
1424
|
-
renderContext: core.PropTypes.renderContext,
|
|
1425
|
-
screenState: PropTypes.string
|
|
1426
|
-
};
|
|
1427
|
-
var defaultProps$4 = {
|
|
1428
|
-
data: null,
|
|
1429
|
-
definition: null,
|
|
1430
|
-
renderContext: null,
|
|
1431
|
-
screenState: null
|
|
1432
|
-
};
|
|
1433
|
-
var ScreenProvider = function ScreenProvider(_ref6) {
|
|
1434
|
-
var data = _ref6.data,
|
|
1435
|
-
definition = _ref6.definition,
|
|
1436
|
-
renderContext = _ref6.renderContext,
|
|
1437
|
-
screenState = _ref6.screenState,
|
|
1438
|
-
children = _ref6.children;
|
|
1439
|
-
var _ref7 = useScreen() || {},
|
|
1440
|
-
_ref7$data = _ref7.data,
|
|
1441
|
-
previousData = _ref7$data === void 0 ? null : _ref7$data,
|
|
1442
|
-
_ref7$definition = _ref7.definition,
|
|
1443
|
-
previousDefinition = _ref7$definition === void 0 ? null : _ref7$definition,
|
|
1444
|
-
_ref7$renderContext = _ref7.renderContext,
|
|
1445
|
-
previousContext = _ref7$renderContext === void 0 ? null : _ref7$renderContext,
|
|
1446
|
-
_ref7$screenState = _ref7.screenState,
|
|
1447
|
-
previousScreenState = _ref7$screenState === void 0 ? null : _ref7$screenState;
|
|
1448
|
-
var finalData = data || previousData || null;
|
|
1449
|
-
var _ref8 = finalData || {},
|
|
1450
|
-
_ref8$type = _ref8.type,
|
|
1451
|
-
type = _ref8$type === void 0 ? null : _ref8$type;
|
|
1452
|
-
var screensManager = useScreensManager();
|
|
1453
|
-
var contextDefinition = screensManager !== null ? screensManager.getDefinition(type) : null;
|
|
1454
|
-
var finalDefinition = definition || contextDefinition || previousDefinition;
|
|
1455
|
-
var finalRenderContext = renderContext || previousContext || 'view';
|
|
1456
|
-
var finalScreenState = screenState || previousScreenState || null;
|
|
1457
|
-
var value = React.useMemo(function () {
|
|
1458
|
-
return {
|
|
1459
|
-
data: finalData,
|
|
1460
|
-
definition: finalDefinition,
|
|
1461
|
-
renderContext: finalRenderContext,
|
|
1462
|
-
screenState: finalScreenState
|
|
1463
|
-
};
|
|
1464
|
-
}, [finalData, finalDefinition, finalRenderContext, finalScreenState]);
|
|
1465
|
-
return /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
|
1466
|
-
value: value
|
|
1467
|
-
}, children);
|
|
1468
|
-
};
|
|
1469
|
-
ScreenProvider.propTypes = propTypes$4;
|
|
1470
|
-
ScreenProvider.defaultProps = defaultProps$4;
|
|
1471
|
-
|
|
1472
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1473
|
-
var ScreenSizeContext = /*#__PURE__*/React.createContext({
|
|
1474
|
-
screen: null,
|
|
1475
|
-
screens: [],
|
|
1476
|
-
width: 0,
|
|
1477
|
-
height: 0,
|
|
1478
|
-
resolution: 1,
|
|
1479
|
-
landscape: false
|
|
1480
|
-
});
|
|
1481
|
-
var useScreenSize = function useScreenSize() {
|
|
1482
|
-
return React.useContext(ScreenSizeContext);
|
|
1483
|
-
};
|
|
1484
|
-
var propTypes$3 = {
|
|
1485
|
-
children: PropTypes.node.isRequired,
|
|
1486
|
-
size: core.PropTypes.screenSize
|
|
1487
|
-
};
|
|
1488
|
-
var defaultProps$3 = {
|
|
1489
|
-
size: {}
|
|
1490
|
-
};
|
|
1491
|
-
|
|
1492
|
-
// Note: this is done to avoid excessive renders on the screens that use the context
|
|
1493
|
-
|
|
1494
|
-
var ScreenSizeProvider = function ScreenSizeProvider(_ref) {
|
|
1495
|
-
var size = _ref.size,
|
|
1496
|
-
children = _ref.children;
|
|
1497
|
-
var nextScreen = size.screen,
|
|
1498
|
-
nextWidth = size.width,
|
|
1499
|
-
nextHeight = size.height,
|
|
1500
|
-
nextResolution = size.resolution;
|
|
1501
|
-
var currentSize = React.useMemo(function () {
|
|
1502
|
-
return size;
|
|
1503
|
-
}, [nextScreen, nextWidth, nextHeight, nextResolution]);
|
|
1504
|
-
return /*#__PURE__*/React.createElement(ScreenSizeContext.Provider, {
|
|
1505
|
-
value: currentSize
|
|
1506
|
-
}, children);
|
|
1507
|
-
};
|
|
1508
|
-
ScreenSizeProvider.propTypes = propTypes$3;
|
|
1509
|
-
ScreenSizeProvider.defaultProps = defaultProps$3;
|
|
1510
|
-
|
|
1511
|
-
var useTracking = function useTracking() {
|
|
1512
|
-
return React.useContext(tracking.TrackingContext);
|
|
1513
|
-
};
|
|
1514
|
-
var propTypes$2 = {
|
|
1515
|
-
children: PropTypes.node.isRequired,
|
|
1516
|
-
variables: core.PropTypes.trackingVariables
|
|
1517
|
-
};
|
|
1518
|
-
var defaultProps$2 = {
|
|
1519
|
-
variables: null
|
|
1520
|
-
};
|
|
1521
|
-
var TrackingProvider = function TrackingProvider(_ref) {
|
|
1522
|
-
var variables = _ref.variables,
|
|
1523
|
-
children = _ref.children;
|
|
1524
|
-
var contextTracking = useTracking() || null;
|
|
1525
|
-
var tracking$1 = React.useMemo(function () {
|
|
1526
|
-
return new core.Tracking({
|
|
1527
|
-
variables: _objectSpread(_objectSpread({}, contextTracking !== null ? contextTracking.getVariables() : null), variables)
|
|
1528
|
-
});
|
|
1529
|
-
}, [contextTracking, variables]);
|
|
1530
|
-
return /*#__PURE__*/React.createElement(tracking.TrackingContainer, {
|
|
1531
|
-
tracking: tracking$1
|
|
1532
|
-
}, children);
|
|
1533
|
-
};
|
|
1534
|
-
TrackingProvider.propTypes = propTypes$2;
|
|
1535
|
-
TrackingProvider.defaultProps = defaultProps$2;
|
|
1536
|
-
|
|
1537
|
-
var defaultValue = {
|
|
1538
|
-
events: new EventEmitter(),
|
|
1539
|
-
menuVisible: false,
|
|
1540
|
-
menuOverScreen: false,
|
|
1541
|
-
topHeight: 0,
|
|
1542
|
-
bottomHeight: 0,
|
|
1543
|
-
bottomSidesWidth: 0,
|
|
1544
|
-
gotoNextScreen: function gotoNextScreen() {},
|
|
1545
|
-
gotoPreviousScreen: function gotoPreviousScreen() {},
|
|
1546
|
-
disableInteraction: function disableInteraction() {},
|
|
1547
|
-
enableInteraction: function enableInteraction() {}
|
|
1548
|
-
};
|
|
1549
|
-
var ViewerContext = /*#__PURE__*/React.createContext(_objectSpread(_objectSpread({}, defaultValue), {}, {
|
|
1550
|
-
webView: null,
|
|
1551
|
-
setWebView: function setWebView() {}
|
|
1552
|
-
}));
|
|
1553
|
-
var useViewerContext = function useViewerContext() {
|
|
1554
|
-
return React.useContext(ViewerContext);
|
|
1555
|
-
};
|
|
1556
|
-
var useViewerSize = function useViewerSize() {
|
|
1557
|
-
var _useViewerContext = useViewerContext(),
|
|
1558
|
-
width = _useViewerContext.width,
|
|
1559
|
-
height = _useViewerContext.height;
|
|
1560
|
-
return {
|
|
1561
|
-
width: width,
|
|
1562
|
-
height: height
|
|
1563
|
-
};
|
|
1564
|
-
};
|
|
1565
|
-
var useViewerNavigation = function useViewerNavigation() {
|
|
1566
|
-
var _useViewerContext2 = useViewerContext(),
|
|
1567
|
-
gotoNextScreen = _useViewerContext2.gotoNextScreen,
|
|
1568
|
-
gotoPreviousScreen = _useViewerContext2.gotoPreviousScreen;
|
|
1569
|
-
return {
|
|
1570
|
-
gotoNextScreen: gotoNextScreen,
|
|
1571
|
-
gotoPreviousScreen: gotoPreviousScreen
|
|
1572
|
-
};
|
|
1573
|
-
};
|
|
1574
|
-
var useViewerEvents = function useViewerEvents() {
|
|
1575
|
-
var _useViewerContext3 = useViewerContext(),
|
|
1576
|
-
events = _useViewerContext3.events;
|
|
1577
|
-
return events;
|
|
1578
|
-
};
|
|
1579
|
-
var useViewerContainer = function useViewerContainer() {
|
|
1580
|
-
var _useViewerContext4 = useViewerContext(),
|
|
1581
|
-
_useViewerContext4$co = _useViewerContext4.containerRef,
|
|
1582
|
-
containerRef = _useViewerContext4$co === void 0 ? null : _useViewerContext4$co;
|
|
1583
|
-
return containerRef !== null ? containerRef.current : null;
|
|
1584
|
-
};
|
|
1585
|
-
var useViewerInteraction = function useViewerInteraction() {
|
|
1586
|
-
var _useViewerContext5 = useViewerContext(),
|
|
1587
|
-
disableInteraction = _useViewerContext5.disableInteraction,
|
|
1588
|
-
enableInteraction = _useViewerContext5.enableInteraction;
|
|
1589
|
-
return {
|
|
1590
|
-
disableInteraction: disableInteraction,
|
|
1591
|
-
enableInteraction: enableInteraction
|
|
1592
|
-
};
|
|
1593
|
-
};
|
|
1594
|
-
var useViewerWebView = function useViewerWebView() {
|
|
1595
|
-
var _useViewerContext6 = useViewerContext(),
|
|
1596
|
-
webView = _useViewerContext6.webView,
|
|
1597
|
-
setWebView = _useViewerContext6.setWebView;
|
|
1598
|
-
var value = React.useMemo(function () {
|
|
1599
|
-
return _objectSpread(_objectSpread({}, webView), {}, {
|
|
1600
|
-
opened: webView !== null,
|
|
1601
|
-
open: function open(newWebView) {
|
|
1602
|
-
return setWebView(isString(newWebView) ? {
|
|
1603
|
-
url: newWebView
|
|
1604
|
-
} : newWebView);
|
|
1605
|
-
},
|
|
1606
|
-
close: function close() {
|
|
1607
|
-
return setWebView(null);
|
|
1608
|
-
},
|
|
1609
|
-
update: function update(newWebView) {
|
|
1610
|
-
return setWebView(_objectSpread(_objectSpread({}, webView), newWebView));
|
|
1611
|
-
}
|
|
1612
|
-
});
|
|
1613
|
-
}, [webView, setWebView]);
|
|
1614
|
-
return value;
|
|
1615
|
-
};
|
|
1616
|
-
var propTypes$1 = {
|
|
1617
|
-
children: PropTypes.node.isRequired,
|
|
1618
|
-
events: PropTypes.instanceOf(EventEmitter),
|
|
1619
|
-
containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1620
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
1621
|
-
current: PropTypes.any
|
|
1622
|
-
})]),
|
|
1623
|
-
menuVisible: PropTypes.bool,
|
|
1624
|
-
menuOverScreen: PropTypes.bool,
|
|
1625
|
-
width: PropTypes.number,
|
|
1626
|
-
height: PropTypes.number,
|
|
1627
|
-
topHeight: PropTypes.number,
|
|
1628
|
-
bottomHeight: PropTypes.number,
|
|
1629
|
-
bottomSidesWidth: PropTypes.number,
|
|
1630
|
-
gotoNextScreen: PropTypes.func,
|
|
1631
|
-
gotoPreviousScreen: PropTypes.func,
|
|
1632
|
-
disableInteraction: PropTypes.func,
|
|
1633
|
-
enableInteraction: PropTypes.func
|
|
1634
|
-
};
|
|
1635
|
-
var defaultProps$1 = _objectSpread({}, defaultValue);
|
|
1636
|
-
var ViewerProvider = function ViewerProvider(_ref) {
|
|
1637
|
-
var children = _ref.children,
|
|
1638
|
-
containerRef = _ref.containerRef,
|
|
1639
|
-
events = _ref.events,
|
|
1640
|
-
menuVisible = _ref.menuVisible,
|
|
1641
|
-
menuOverScreen = _ref.menuOverScreen,
|
|
1642
|
-
width = _ref.width,
|
|
1643
|
-
height = _ref.height,
|
|
1644
|
-
topHeight = _ref.topHeight,
|
|
1645
|
-
bottomHeight = _ref.bottomHeight,
|
|
1646
|
-
bottomSidesWidth = _ref.bottomSidesWidth,
|
|
1647
|
-
gotoNextScreen = _ref.gotoNextScreen,
|
|
1648
|
-
gotoPreviousScreen = _ref.gotoPreviousScreen,
|
|
1649
|
-
disableInteraction = _ref.disableInteraction,
|
|
1650
|
-
enableInteraction = _ref.enableInteraction;
|
|
1651
|
-
var _useState = React.useState(null),
|
|
1652
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1653
|
-
webView = _useState2[0],
|
|
1654
|
-
setWebView = _useState2[1];
|
|
1655
|
-
var value = React.useMemo(function () {
|
|
1656
|
-
return {
|
|
1657
|
-
containerRef: containerRef,
|
|
1658
|
-
events: events,
|
|
1659
|
-
menuVisible: menuVisible,
|
|
1660
|
-
menuOverScreen: menuOverScreen,
|
|
1661
|
-
width: width,
|
|
1662
|
-
height: height,
|
|
1663
|
-
topHeight: topHeight,
|
|
1664
|
-
bottomHeight: bottomHeight,
|
|
1665
|
-
bottomSidesWidth: bottomSidesWidth,
|
|
1666
|
-
gotoNextScreen: gotoNextScreen,
|
|
1667
|
-
gotoPreviousScreen: gotoPreviousScreen,
|
|
1668
|
-
disableInteraction: disableInteraction,
|
|
1669
|
-
enableInteraction: enableInteraction,
|
|
1670
|
-
webView: webView,
|
|
1671
|
-
setWebView: setWebView
|
|
1672
|
-
};
|
|
1673
|
-
}, [containerRef, events, menuVisible, menuOverScreen, width, height, topHeight, bottomHeight, bottomSidesWidth, gotoNextScreen, gotoPreviousScreen, disableInteraction, enableInteraction, webView, setWebView]);
|
|
1674
|
-
return /*#__PURE__*/React.createElement(ViewerContext.Provider, {
|
|
1675
|
-
value: value
|
|
1676
|
-
}, children);
|
|
1677
|
-
};
|
|
1678
|
-
ViewerProvider.propTypes = propTypes$1;
|
|
1679
|
-
ViewerProvider.defaultProps = defaultProps$1;
|
|
1680
|
-
|
|
1681
|
-
var VisitorContext = /*#__PURE__*/React.createContext({
|
|
1682
|
-
visitor: null,
|
|
1683
|
-
setVisitor: function setVisitor() {}
|
|
1684
|
-
});
|
|
1685
|
-
var useVisitorContext = function useVisitorContext() {
|
|
1686
|
-
var _useContext = React.useContext(VisitorContext),
|
|
1687
|
-
visitor = _useContext.visitor,
|
|
1688
|
-
setVisitor = _useContext.setVisitor;
|
|
1689
|
-
return {
|
|
1690
|
-
visitor: visitor,
|
|
1691
|
-
setVisitor: setVisitor
|
|
1692
|
-
};
|
|
1693
|
-
};
|
|
1694
|
-
var useVisitor = function useVisitor() {
|
|
1695
|
-
var _useContext2 = React.useContext(VisitorContext),
|
|
1696
|
-
visitor = _useContext2.visitor;
|
|
1697
|
-
return visitor;
|
|
1698
|
-
};
|
|
1699
|
-
var useSetVisitor = function useSetVisitor() {
|
|
1700
|
-
var _useContext3 = React.useContext(VisitorContext),
|
|
1701
|
-
setVisitor = _useContext3.setVisitor;
|
|
1702
|
-
return setVisitor;
|
|
1703
|
-
};
|
|
1704
|
-
var propTypes = {
|
|
1705
|
-
children: PropTypes.node.isRequired,
|
|
1706
|
-
visitor: core.PropTypes.visitor
|
|
1707
|
-
};
|
|
1708
|
-
var defaultProps = {
|
|
1709
|
-
visitor: null
|
|
1710
|
-
};
|
|
1711
|
-
var VisitorProvider = function VisitorProvider(_ref) {
|
|
1712
|
-
var providedVisitor = _ref.visitor,
|
|
1713
|
-
children = _ref.children;
|
|
1714
|
-
var _useState = React.useState(providedVisitor),
|
|
1715
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1716
|
-
visitor = _useState2[0],
|
|
1717
|
-
setVisitor = _useState2[1];
|
|
1718
|
-
React.useEffect(function () {
|
|
1719
|
-
if (providedVisitor !== visitor) {
|
|
1720
|
-
setVisitor(providedVisitor);
|
|
1721
|
-
}
|
|
1722
|
-
}, [providedVisitor, setVisitor]);
|
|
1723
|
-
var value = React.useMemo(function () {
|
|
1724
|
-
return {
|
|
1725
|
-
visitor: visitor,
|
|
1726
|
-
setVisitor: function setVisitor(newVisitor) {
|
|
1727
|
-
return isString(newVisitor) ? {
|
|
1728
|
-
id: newVisitor
|
|
1729
|
-
} : newVisitor;
|
|
1730
|
-
}
|
|
1731
|
-
};
|
|
1732
|
-
}, [visitor, setVisitor]);
|
|
1733
|
-
return /*#__PURE__*/React.createElement(VisitorContext.Provider, {
|
|
1734
|
-
value: value
|
|
1735
|
-
}, children);
|
|
1736
|
-
};
|
|
1737
|
-
VisitorProvider.propTypes = propTypes;
|
|
1738
|
-
VisitorProvider.defaultProps = defaultProps;
|
|
1739
|
-
|
|
1740
|
-
Object.defineProperty(exports, "TrackingContext", {
|
|
1741
|
-
enumerable: true,
|
|
1742
|
-
get: function () { return tracking.TrackingContext; }
|
|
1743
|
-
});
|
|
1744
|
-
exports.ComponentsContext = ComponentsContext;
|
|
1745
|
-
exports.ComponentsProvider = ComponentsProvider;
|
|
1746
|
-
exports.ELEMENTS_NAMESPACE = ELEMENTS_NAMESPACE;
|
|
1747
|
-
exports.EditorContext = EditorContext;
|
|
1748
|
-
exports.EditorProvider = EditorProvider;
|
|
1749
|
-
exports.FIELDS_NAMESPACE = FIELDS_NAMESPACE;
|
|
1750
|
-
exports.FORMS_NAMESPACE = FORMS_NAMESPACE;
|
|
1751
|
-
exports.FieldContext = FieldContext;
|
|
1752
|
-
exports.FieldContextProvider = FieldContextProvider;
|
|
1753
|
-
exports.FieldsContext = FieldsContext;
|
|
1754
|
-
exports.FieldsProvider = FieldsProvider;
|
|
1755
|
-
exports.FieldsValueContext = FieldsValueContext;
|
|
1756
|
-
exports.FieldsValueContextProvider = FieldsValueContextProvider;
|
|
1757
|
-
exports.FontsContext = FontsContext;
|
|
1758
|
-
exports.FontsProvider = FontsProvider;
|
|
1759
|
-
exports.GoogleApiClientContext = GoogleApiClientContext;
|
|
1760
|
-
exports.GoogleApiClientProvider = GoogleApiClientProvider;
|
|
1761
|
-
exports.GoogleKeysContext = GoogleKeysContext;
|
|
1762
|
-
exports.GoogleKeysProvider = GoogleKeysProvider;
|
|
1763
|
-
exports.GoogleMapsClientContext = GoogleMapsClientContext;
|
|
1764
|
-
exports.GoogleMapsClientProvider = GoogleMapsClientProvider;
|
|
1765
|
-
exports.MODALS_NAMESPACE = MODALS_NAMESPACE;
|
|
1766
|
-
exports.ModalsContext = ModalsContext;
|
|
1767
|
-
exports.ModalsProvider = ModalsProvider;
|
|
1768
|
-
exports.PanelsContext = PanelsContext;
|
|
1769
|
-
exports.PanelsProvider = PanelsProvider;
|
|
1770
|
-
exports.PlaybackContext = PlaybackContext;
|
|
1771
|
-
exports.PlaybackProvider = PlaybackProvider;
|
|
1772
|
-
exports.RoutesContext = RoutesContext;
|
|
1773
|
-
exports.RoutesProvider = RoutesProvider;
|
|
1774
|
-
exports.SCREENS_NAMESPACE = SCREENS_NAMESPACE;
|
|
1775
|
-
exports.ScreenContext = ScreenContext;
|
|
1776
|
-
exports.ScreenProvider = ScreenProvider;
|
|
1777
|
-
exports.ScreenSizeContext = ScreenSizeContext;
|
|
1778
|
-
exports.ScreenSizeProvider = ScreenSizeProvider;
|
|
1779
|
-
exports.ScreensContext = ScreensContext;
|
|
1780
|
-
exports.ScreensProvider = ScreensProvider;
|
|
1781
|
-
exports.StoryContext = StoryContext;
|
|
1782
|
-
exports.StoryProvider = StoryProvider;
|
|
1783
|
-
exports.TrackingProvider = TrackingProvider;
|
|
1784
|
-
exports.ViewerContext = ViewerContext;
|
|
1785
|
-
exports.ViewerProvider = ViewerProvider;
|
|
1786
|
-
exports.VisitorContext = VisitorContext;
|
|
1787
|
-
exports.VisitorProvider = VisitorProvider;
|
|
1788
|
-
exports.useComponent = useComponent;
|
|
1789
|
-
exports.useComponents = useComponents;
|
|
1790
|
-
exports.useComponentsManager = useComponentsManager;
|
|
1791
|
-
exports.useEditor = useEditor;
|
|
1792
|
-
exports.useElementComponent = useElementComponent;
|
|
1793
|
-
exports.useElementsComponents = useElementsComponents;
|
|
1794
|
-
exports.useElementsComponentsManager = useElementsComponentsManager;
|
|
1795
|
-
exports.useFieldComponent = useFieldComponent;
|
|
1796
|
-
exports.useFieldContext = useFieldContext;
|
|
1797
|
-
exports.useFieldDefinition = useFieldDefinition;
|
|
1798
|
-
exports.useFieldsComponents = useFieldsComponents;
|
|
1799
|
-
exports.useFieldsComponentsManager = useFieldsComponentsManager;
|
|
1800
|
-
exports.useFieldsManager = useFieldsManager;
|
|
1801
|
-
exports.useFieldsValue = useFieldsValue;
|
|
1802
|
-
exports.useFonts = useFonts;
|
|
1803
|
-
exports.useFormComponent = useFormComponent;
|
|
1804
|
-
exports.useFormsComponents = useFormsComponents;
|
|
1805
|
-
exports.useFormsComponentsManager = useFormsComponentsManager;
|
|
1806
|
-
exports.useGetColors = useGetColors;
|
|
1807
|
-
exports.useGoogleApiClient = useGoogleApiClient;
|
|
1808
|
-
exports.useGoogleFonts = useGoogleFonts;
|
|
1809
|
-
exports.useGoogleKeys = useGoogleKeys;
|
|
1810
|
-
exports.useGoogleMapsClient = useGoogleMapsClient;
|
|
1811
|
-
exports.useModalComponent = useModalComponent;
|
|
1812
|
-
exports.useModals = useModals;
|
|
1813
|
-
exports.useModalsComponents = useModalsComponents;
|
|
1814
|
-
exports.useModalsComponentsManager = useModalsComponentsManager;
|
|
1815
|
-
exports.usePanels = usePanels;
|
|
1816
|
-
exports.usePlaybackContext = usePlaybackContext;
|
|
1817
|
-
exports.usePlaybackMediaRef = usePlaybackMediaRef;
|
|
1818
|
-
exports.useRouteBack = useRouteBack;
|
|
1819
|
-
exports.useRoutePush = useRoutePush;
|
|
1820
|
-
exports.useRoutes = useRoutes$1;
|
|
1821
|
-
exports.useScreen = useScreen;
|
|
1822
|
-
exports.useScreenComponent = useScreenComponent;
|
|
1823
|
-
exports.useScreenData = useScreenData;
|
|
1824
|
-
exports.useScreenDefinition = useScreenDefinition;
|
|
1825
|
-
exports.useScreenRenderContext = useScreenRenderContext;
|
|
1826
|
-
exports.useScreenSize = useScreenSize;
|
|
1827
|
-
exports.useScreenState = useScreenState;
|
|
1828
|
-
exports.useScreensComponents = useScreensComponents;
|
|
1829
|
-
exports.useScreensComponentsManager = useScreensComponentsManager;
|
|
1830
|
-
exports.useScreensManager = useScreensManager;
|
|
1831
|
-
exports.useSetVisitor = useSetVisitor;
|
|
1832
|
-
exports.useStory = useStory;
|
|
1833
|
-
exports.useStoryContext = useStoryContext;
|
|
1834
|
-
exports.useTracking = useTracking;
|
|
1835
|
-
exports.useUrlGenerator = useUrlGeneratorPathToRegexp;
|
|
1836
|
-
exports.useViewerContainer = useViewerContainer;
|
|
1837
|
-
exports.useViewerContext = useViewerContext;
|
|
1838
|
-
exports.useViewerEvents = useViewerEvents;
|
|
1839
|
-
exports.useViewerInteraction = useViewerInteraction;
|
|
1840
|
-
exports.useViewerNavigation = useViewerNavigation;
|
|
1841
|
-
exports.useViewerSize = useViewerSize;
|
|
1842
|
-
exports.useViewerWebView = useViewerWebView;
|
|
1843
|
-
exports.useVisitor = useVisitor;
|
|
1844
|
-
exports.useVisitorContext = useVisitorContext;
|
|
1845
|
-
exports.withGoogleApiClient = withGoogleApiClient;
|
|
1846
|
-
exports.withGoogleMapsClient = withGoogleMapsClient;
|
|
1847
|
-
exports.withModals = withModals;
|
|
1848
|
-
exports.withPanels = withPanels;
|