@panneau/core 3.0.142 → 3.0.145
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/index.js +10 -16
- package/package.json +6 -6
- package/es/contexts.js +0 -1143
- package/es/hooks.js +0 -1224
- package/es/utils.js +0 -488
- package/lib/contexts.js +0 -1593
- package/lib/hooks.js +0 -1245
- package/lib/index.js +0 -985
- package/lib/utils.js +0 -604
package/lib/contexts.js
DELETED
|
@@ -1,1593 +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('@panneau/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 reactIntl = require('react-intl');
|
|
16
|
-
var utils = require('@panneau/core/utils');
|
|
17
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
18
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
19
|
-
var pathToRegexp = require('path-to-regexp');
|
|
20
|
-
var regexparam = require('regexparam');
|
|
21
|
-
var index_js = require('use-sync-external-store/shim/index.js');
|
|
22
|
-
var tracking = require('@folklore/tracking');
|
|
23
|
-
|
|
24
|
-
function _interopNamespaceDefault(e) {
|
|
25
|
-
var n = Object.create(null);
|
|
26
|
-
if (e) {
|
|
27
|
-
Object.keys(e).forEach(function (k) {
|
|
28
|
-
if (k !== 'default') {
|
|
29
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () { return e[k]; }
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
n.default = e;
|
|
38
|
-
return Object.freeze(n);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
42
|
-
|
|
43
|
-
var MODALS_NAMESPACE = 'modals';
|
|
44
|
-
var FIELDS_NAMESPACE = 'fields';
|
|
45
|
-
var FORMS_NAMESPACE = 'forms';
|
|
46
|
-
var FILTERS_NAMESPACE = 'filters';
|
|
47
|
-
var LISTS_NAMESPACE = 'lists';
|
|
48
|
-
var DISPLAYS_NAMESPACE = 'displays';
|
|
49
|
-
var ACTIONS_NAMESPACE = 'actions';
|
|
50
|
-
var BUTTONS_NAMESPACE = 'buttons';
|
|
51
|
-
var PAGES_NAMESPACE = 'pages';
|
|
52
|
-
var APP_NAMESPACE = 'app';
|
|
53
|
-
var ComponentsContext = /*#__PURE__*/React.createContext(null);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Hooks
|
|
57
|
-
*/
|
|
58
|
-
var useComponentsManager = function useComponentsManager() {
|
|
59
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
60
|
-
var manager = React.useContext(ComponentsContext);
|
|
61
|
-
var finalManager = React.useMemo(function () {
|
|
62
|
-
return namespace !== null ? new core.ComponentsManager(manager.getComponents(namespace)) : manager;
|
|
63
|
-
}, [manager, namespace]);
|
|
64
|
-
return finalManager;
|
|
65
|
-
};
|
|
66
|
-
var useComponents = function useComponents() {
|
|
67
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
68
|
-
var defaultComponents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
-
var manager = useComponentsManager();
|
|
70
|
-
return manager.getComponents(namespace) || defaultComponents;
|
|
71
|
-
};
|
|
72
|
-
var useComponent = function useComponent(name) {
|
|
73
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
74
|
-
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
75
|
-
var manager = useComponentsManager(namespace);
|
|
76
|
-
return React.useMemo(function () {
|
|
77
|
-
if (!isString(name)) {
|
|
78
|
-
return name || defaultComponent;
|
|
79
|
-
}
|
|
80
|
-
return manager.getComponent(name) || defaultComponent;
|
|
81
|
-
}, [manager, name, defaultComponent]);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Fields hooks
|
|
86
|
-
*/
|
|
87
|
-
var useFieldsComponentsManager = function useFieldsComponentsManager() {
|
|
88
|
-
return useComponentsManager(FIELDS_NAMESPACE);
|
|
89
|
-
};
|
|
90
|
-
var useFieldsComponents = function useFieldsComponents() {
|
|
91
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
92
|
-
return useComponents(FIELDS_NAMESPACE, defaultComponents);
|
|
93
|
-
};
|
|
94
|
-
var useFieldComponent = function useFieldComponent(name) {
|
|
95
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
96
|
-
return useComponent(name, defaultComponent, FIELDS_NAMESPACE);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Forms hooks
|
|
101
|
-
*/
|
|
102
|
-
var useFormsComponentsManager = function useFormsComponentsManager() {
|
|
103
|
-
return useComponentsManager(FORMS_NAMESPACE);
|
|
104
|
-
};
|
|
105
|
-
var useFormsComponents = function useFormsComponents() {
|
|
106
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
107
|
-
return useComponents(FORMS_NAMESPACE, defaultComponents);
|
|
108
|
-
};
|
|
109
|
-
var useFormComponent = function useFormComponent(name) {
|
|
110
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
111
|
-
return useComponent(name, defaultComponent, FORMS_NAMESPACE);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Modals hooks
|
|
116
|
-
*/
|
|
117
|
-
var useModalsComponentsManager = function useModalsComponentsManager() {
|
|
118
|
-
return useComponentsManager(MODALS_NAMESPACE);
|
|
119
|
-
};
|
|
120
|
-
var useModalsComponents = function useModalsComponents() {
|
|
121
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
122
|
-
return useComponents(MODALS_NAMESPACE, defaultComponents);
|
|
123
|
-
};
|
|
124
|
-
var useModalComponent = function useModalComponent(name) {
|
|
125
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
126
|
-
return useComponent(name, defaultComponent, MODALS_NAMESPACE);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Filters hooks
|
|
131
|
-
*/
|
|
132
|
-
var useFiltersComponentsManager = function useFiltersComponentsManager() {
|
|
133
|
-
return useComponentsManager(FILTERS_NAMESPACE);
|
|
134
|
-
};
|
|
135
|
-
var useFiltersComponents = function useFiltersComponents() {
|
|
136
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
137
|
-
return useComponents(FILTERS_NAMESPACE, defaultComponents);
|
|
138
|
-
};
|
|
139
|
-
var useFilterComponent = function useFilterComponent(name) {
|
|
140
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
141
|
-
return useComponent(name, defaultComponent, FILTERS_NAMESPACE);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Lists hooks
|
|
146
|
-
*/
|
|
147
|
-
var useListsComponentsManager = function useListsComponentsManager() {
|
|
148
|
-
return useComponentsManager(LISTS_NAMESPACE);
|
|
149
|
-
};
|
|
150
|
-
var useListsComponents = function useListsComponents() {
|
|
151
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
152
|
-
return useComponents(LISTS_NAMESPACE, defaultComponents);
|
|
153
|
-
};
|
|
154
|
-
var useListComponent = function useListComponent(name) {
|
|
155
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
156
|
-
return useComponent(name, defaultComponent, LISTS_NAMESPACE);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Displays hooks
|
|
161
|
-
*/
|
|
162
|
-
var useDisplaysComponentsManager = function useDisplaysComponentsManager() {
|
|
163
|
-
return useComponentsManager(DISPLAYS_NAMESPACE);
|
|
164
|
-
};
|
|
165
|
-
var useDisplaysComponents = function useDisplaysComponents() {
|
|
166
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
167
|
-
return useComponents(DISPLAYS_NAMESPACE, defaultComponents);
|
|
168
|
-
};
|
|
169
|
-
var useDisplayComponent = function useDisplayComponent(name) {
|
|
170
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
171
|
-
return useComponent(name, defaultComponent, DISPLAYS_NAMESPACE);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Actions hooks
|
|
176
|
-
*/
|
|
177
|
-
var useActionsComponentsManager = function useActionsComponentsManager() {
|
|
178
|
-
return useComponentsManager(ACTIONS_NAMESPACE);
|
|
179
|
-
};
|
|
180
|
-
var useActionsComponents = function useActionsComponents() {
|
|
181
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
182
|
-
return useComponents(ACTIONS_NAMESPACE, defaultComponents);
|
|
183
|
-
};
|
|
184
|
-
var useActionComponent = function useActionComponent(name) {
|
|
185
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
186
|
-
return useComponent(name, defaultComponent, ACTIONS_NAMESPACE);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Buttons hooks
|
|
191
|
-
*/
|
|
192
|
-
var useButtonsComponentsManager = function useButtonsComponentsManager() {
|
|
193
|
-
return useComponentsManager(BUTTONS_NAMESPACE);
|
|
194
|
-
};
|
|
195
|
-
var useButtonsComponents = function useButtonsComponents() {
|
|
196
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
197
|
-
return useComponents(BUTTONS_NAMESPACE, defaultComponents);
|
|
198
|
-
};
|
|
199
|
-
var useButtonComponent = function useButtonComponent(name) {
|
|
200
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
201
|
-
return useComponent(name, defaultComponent, BUTTONS_NAMESPACE);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Pages hooks
|
|
206
|
-
*/
|
|
207
|
-
var usePagesComponentsManager = function usePagesComponentsManager() {
|
|
208
|
-
return useComponentsManager(PAGES_NAMESPACE);
|
|
209
|
-
};
|
|
210
|
-
var usePagesComponents = function usePagesComponents() {
|
|
211
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
212
|
-
return useComponents(PAGES_NAMESPACE, defaultComponents);
|
|
213
|
-
};
|
|
214
|
-
var usePageComponent = function usePageComponent(name) {
|
|
215
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
216
|
-
return useComponent(name, defaultComponent, PAGES_NAMESPACE);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* App hooks
|
|
221
|
-
*/
|
|
222
|
-
var useAppComponentsManager = function useAppComponentsManager() {
|
|
223
|
-
return useComponentsManager(APP_NAMESPACE);
|
|
224
|
-
};
|
|
225
|
-
var useAppComponents = function useAppComponents() {
|
|
226
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
227
|
-
return useComponents(APP_NAMESPACE, defaultComponents);
|
|
228
|
-
};
|
|
229
|
-
var useAppComponent = function useAppComponent(name) {
|
|
230
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
231
|
-
return useComponent(name, defaultComponent, APP_NAMESPACE);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Provider
|
|
236
|
-
*/
|
|
237
|
-
var propTypes$e = {
|
|
238
|
-
children: PropTypes.node.isRequired,
|
|
239
|
-
namespace: PropTypes.string,
|
|
240
|
-
manager: PropTypes.instanceOf(core.ComponentsManager),
|
|
241
|
-
components: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.object, PropTypes.func]))
|
|
242
|
-
};
|
|
243
|
-
var defaultProps$e = {
|
|
244
|
-
namespace: null,
|
|
245
|
-
components: {},
|
|
246
|
-
manager: null
|
|
247
|
-
};
|
|
248
|
-
var ComponentsProvider = function ComponentsProvider(_ref) {
|
|
249
|
-
var components = _ref.components,
|
|
250
|
-
manager = _ref.manager,
|
|
251
|
-
namespace = _ref.namespace,
|
|
252
|
-
children = _ref.children;
|
|
253
|
-
var previousManager = useComponentsManager() || null;
|
|
254
|
-
var finalManager = React.useMemo(function () {
|
|
255
|
-
return new core.ComponentsManager(_objectSpread(_objectSpread(_objectSpread({}, previousManager !== null ? previousManager.getComponents() : null), manager !== null ? manager.getComponents() : null), new core.ComponentsManager(components).addNamespace(namespace).getComponents()));
|
|
256
|
-
}, [previousManager, manager, components, namespace]);
|
|
257
|
-
return /*#__PURE__*/React.createElement(ComponentsContext.Provider, {
|
|
258
|
-
value: finalManager
|
|
259
|
-
}, children);
|
|
260
|
-
};
|
|
261
|
-
ComponentsProvider.propTypes = propTypes$e;
|
|
262
|
-
ComponentsProvider.defaultProps = defaultProps$e;
|
|
263
|
-
|
|
264
|
-
var message = PropTypes.shape({
|
|
265
|
-
id: PropTypes.string.isRequired,
|
|
266
|
-
defaultMessage: PropTypes.string
|
|
267
|
-
});
|
|
268
|
-
var label = PropTypes.oneOfType([message, PropTypes.node]);
|
|
269
|
-
PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Core
|
|
273
|
-
*/
|
|
274
|
-
var menuItem = PropTypes.shape({
|
|
275
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
276
|
-
label: label,
|
|
277
|
-
url: PropTypes.string,
|
|
278
|
-
external: PropTypes.bool,
|
|
279
|
-
active: PropTypes.bool
|
|
280
|
-
});
|
|
281
|
-
PropTypes.arrayOf(menuItem);
|
|
282
|
-
var button = PropTypes.shape({
|
|
283
|
-
id: PropTypes.string,
|
|
284
|
-
label: label,
|
|
285
|
-
onClick: PropTypes.func
|
|
286
|
-
});
|
|
287
|
-
PropTypes.arrayOf(button);
|
|
288
|
-
PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', null]);
|
|
289
|
-
PropTypes.oneOf(['lg', 'md', 'sm', null]);
|
|
290
|
-
PropTypes.oneOf(['button', 'submit']);
|
|
291
|
-
PropTypes.oneOf(['start', 'end']);
|
|
292
|
-
PropTypes.oneOf(['lg', 'sm', null]);
|
|
293
|
-
PropTypes.oneOf(['loading', 'success', 'error', null]);
|
|
294
|
-
var fieldOption = PropTypes.shape({
|
|
295
|
-
value: PropTypes.string,
|
|
296
|
-
label: PropTypes.string
|
|
297
|
-
});
|
|
298
|
-
PropTypes.arrayOf(fieldOption);
|
|
299
|
-
var toggle = PropTypes.shape({
|
|
300
|
-
key: PropTypes.string,
|
|
301
|
-
label: PropTypes.string
|
|
302
|
-
});
|
|
303
|
-
PropTypes.arrayOf(toggle);
|
|
304
|
-
var tableColumn = PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
305
|
-
id: PropTypes.string,
|
|
306
|
-
component: PropTypes.string,
|
|
307
|
-
path: PropTypes.string,
|
|
308
|
-
field: PropTypes.string,
|
|
309
|
-
columnClassName: PropTypes.string
|
|
310
|
-
})]);
|
|
311
|
-
PropTypes.arrayOf(tableColumn);
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Panneau Definitions
|
|
315
|
-
*/
|
|
316
|
-
var routes = PropTypes.shape({
|
|
317
|
-
'resources.index': PropTypes.string.isRequired,
|
|
318
|
-
'resources.create': PropTypes.string.isRequired,
|
|
319
|
-
'resources.store': PropTypes.string.isRequired,
|
|
320
|
-
'resources.show': PropTypes.string.isRequired,
|
|
321
|
-
'resources.edit': PropTypes.string.isRequired,
|
|
322
|
-
'resources.update': PropTypes.string.isRequired,
|
|
323
|
-
'resources.delete': PropTypes.string.isRequired,
|
|
324
|
-
'resources.destroy': PropTypes.string.isRequired
|
|
325
|
-
});
|
|
326
|
-
var intl = PropTypes.shape({
|
|
327
|
-
locale: PropTypes.string,
|
|
328
|
-
messages: PropTypes.objectOf(PropTypes.string),
|
|
329
|
-
values: PropTypes.objectOf(PropTypes.string)
|
|
330
|
-
});
|
|
331
|
-
var page = PropTypes.shape({
|
|
332
|
-
component: PropTypes.string.isRequired
|
|
333
|
-
});
|
|
334
|
-
var pages = PropTypes.objectOf(page);
|
|
335
|
-
var field = PropTypes.shape({
|
|
336
|
-
name: PropTypes.string,
|
|
337
|
-
// Not required on localized fields
|
|
338
|
-
type: PropTypes.string,
|
|
339
|
-
component: PropTypes.string,
|
|
340
|
-
label: PropTypes.node
|
|
341
|
-
});
|
|
342
|
-
var fields = PropTypes.arrayOf(field);
|
|
343
|
-
var form = PropTypes.shape({
|
|
344
|
-
// type: PropTypes.string.isRequired,
|
|
345
|
-
title: PropTypes.isRequired,
|
|
346
|
-
fields: fields
|
|
347
|
-
});
|
|
348
|
-
PropTypes.arrayOf(form);
|
|
349
|
-
var resource = PropTypes.shape({
|
|
350
|
-
id: PropTypes.string.isRequired,
|
|
351
|
-
name: PropTypes.string.isRequired,
|
|
352
|
-
intl: intl,
|
|
353
|
-
fields: fields,
|
|
354
|
-
forms: PropTypes.shape({}),
|
|
355
|
-
shows_in_navbar: PropTypes.bool
|
|
356
|
-
});
|
|
357
|
-
var resources = PropTypes.arrayOf(resource);
|
|
358
|
-
var panneauDefinition = PropTypes.shape({
|
|
359
|
-
name: PropTypes.string,
|
|
360
|
-
resources: resources,
|
|
361
|
-
routes: routes,
|
|
362
|
-
pages: pages,
|
|
363
|
-
intl: intl
|
|
364
|
-
// intl,
|
|
365
|
-
});
|
|
366
|
-
var definition = PropTypes.shape({
|
|
367
|
-
name: PropTypes.string
|
|
368
|
-
// resources,
|
|
369
|
-
// routes,
|
|
370
|
-
// intl,
|
|
371
|
-
});
|
|
372
|
-
var item = PropTypes.shape({
|
|
373
|
-
id: PropTypes.string.isRequired
|
|
374
|
-
});
|
|
375
|
-
PropTypes.arrayOf(item);
|
|
376
|
-
var user = PropTypes.shape({
|
|
377
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
378
|
-
});
|
|
379
|
-
PropTypes.arrayOf(user);
|
|
380
|
-
var selectOption = PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.shape({
|
|
381
|
-
value: PropTypes.any,
|
|
382
|
-
// eslint-disable-line
|
|
383
|
-
label: label
|
|
384
|
-
}), PropTypes.object]);
|
|
385
|
-
PropTypes.arrayOf(selectOption);
|
|
386
|
-
PropTypes.oneOf(['valid', 'invalid', 'loading', null]);
|
|
387
|
-
var formError = PropTypes.shape({
|
|
388
|
-
message: PropTypes.string
|
|
389
|
-
});
|
|
390
|
-
PropTypes.arrayOf(formError);
|
|
391
|
-
PropTypes.shape({
|
|
392
|
-
tus: PropTypes.object
|
|
393
|
-
}); // eslint-disable-line
|
|
394
|
-
|
|
395
|
-
PropTypes.string;
|
|
396
|
-
var breadcrumb = PropTypes.shape({
|
|
397
|
-
url: PropTypes.string
|
|
398
|
-
});
|
|
399
|
-
PropTypes.arrayOf(breadcrumb);
|
|
400
|
-
var font = PropTypes.shape({
|
|
401
|
-
// url: PropTypes.string,
|
|
402
|
-
});
|
|
403
|
-
PropTypes.arrayOf(font);
|
|
404
|
-
PropTypes.shape({});
|
|
405
|
-
var modal = PropTypes.shape({
|
|
406
|
-
name: PropTypes.string
|
|
407
|
-
});
|
|
408
|
-
PropTypes.arrayOf(modal);
|
|
409
|
-
var filter = PropTypes.shape({
|
|
410
|
-
id: PropTypes.string,
|
|
411
|
-
component: PropTypes.string
|
|
412
|
-
});
|
|
413
|
-
PropTypes.arrayOf(filter);
|
|
414
|
-
var media = PropTypes.shape({
|
|
415
|
-
id: PropTypes.string.isRequired,
|
|
416
|
-
name: PropTypes.string.isRequired,
|
|
417
|
-
type: PropTypes.string.isRequired,
|
|
418
|
-
thumbnail_url: PropTypes.string
|
|
419
|
-
});
|
|
420
|
-
PropTypes.arrayOf(media);
|
|
421
|
-
|
|
422
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
423
|
-
var DefinitionContext = /*#__PURE__*/React.createContext(null);
|
|
424
|
-
var useDefinitionContext = function useDefinitionContext() {
|
|
425
|
-
return React.useContext(DefinitionContext);
|
|
426
|
-
};
|
|
427
|
-
var useDefinition = function useDefinition() {
|
|
428
|
-
var _useDefinitionContext = useDefinitionContext(),
|
|
429
|
-
_useDefinitionContext2 = _useDefinitionContext.definition,
|
|
430
|
-
definition = _useDefinitionContext2 === void 0 ? null : _useDefinitionContext2;
|
|
431
|
-
return definition;
|
|
432
|
-
};
|
|
433
|
-
var propTypes$d = {
|
|
434
|
-
definition: definition.isRequired,
|
|
435
|
-
children: PropTypes.node.isRequired
|
|
436
|
-
};
|
|
437
|
-
var defaultProps$d = {};
|
|
438
|
-
var DefinitionProvider = function DefinitionProvider(_ref) {
|
|
439
|
-
var definition = _ref.definition,
|
|
440
|
-
children = _ref.children;
|
|
441
|
-
return /*#__PURE__*/React.createElement(DefinitionContext.Provider, {
|
|
442
|
-
value: definition
|
|
443
|
-
}, children);
|
|
444
|
-
};
|
|
445
|
-
DefinitionProvider.propTypes = propTypes$d;
|
|
446
|
-
DefinitionProvider.defaultProps = defaultProps$d;
|
|
447
|
-
|
|
448
|
-
var FieldsContext = /*#__PURE__*/React.createContext(null);
|
|
449
|
-
var useFieldsManager = function useFieldsManager() {
|
|
450
|
-
return React.useContext(FieldsContext);
|
|
451
|
-
};
|
|
452
|
-
var useField = function useField(id) {
|
|
453
|
-
var manager = useFieldsManager();
|
|
454
|
-
return manager.getDefinition(id);
|
|
455
|
-
};
|
|
456
|
-
var useFields = function useFields() {
|
|
457
|
-
var manager = useFieldsManager();
|
|
458
|
-
return manager.getDefinitions();
|
|
459
|
-
};
|
|
460
|
-
var propTypes$c = {
|
|
461
|
-
fields: core.PropTypes.fields,
|
|
462
|
-
manager: PropTypes.instanceOf(core.FieldsManager),
|
|
463
|
-
children: PropTypes.node.isRequired
|
|
464
|
-
};
|
|
465
|
-
var defaultProps$c = {
|
|
466
|
-
fields: null,
|
|
467
|
-
manager: null
|
|
468
|
-
};
|
|
469
|
-
var FieldsProvider = function FieldsProvider(_ref) {
|
|
470
|
-
var fields = _ref.fields,
|
|
471
|
-
manager = _ref.manager,
|
|
472
|
-
children = _ref.children;
|
|
473
|
-
var previousManager = useFieldsManager() || null;
|
|
474
|
-
var finalManager = React.useMemo(function () {
|
|
475
|
-
var newFields = uniqBy([].concat(_toConsumableArray(fields || []), _toConsumableArray(manager !== null ? manager.getDefinitions() : []), _toConsumableArray(previousManager !== null ? previousManager.getDefinitions() : [])), function (_ref2) {
|
|
476
|
-
var id = _ref2.id;
|
|
477
|
-
return id;
|
|
478
|
-
}).reverse();
|
|
479
|
-
return new core.FieldsManager(newFields);
|
|
480
|
-
}, [previousManager, manager, fields]);
|
|
481
|
-
var components = React.useMemo(function () {
|
|
482
|
-
var newComponents = finalManager.getComponents();
|
|
483
|
-
return Object.keys(newComponents).reduce(function (map, id) {
|
|
484
|
-
var component = newComponents[id];
|
|
485
|
-
return isString(component) ? map : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, component));
|
|
486
|
-
}, {});
|
|
487
|
-
}, [finalManager]);
|
|
488
|
-
return /*#__PURE__*/React.createElement(FieldsContext.Provider, {
|
|
489
|
-
value: finalManager
|
|
490
|
-
}, /*#__PURE__*/React.createElement(ComponentsProvider, {
|
|
491
|
-
namespace: FIELDS_NAMESPACE,
|
|
492
|
-
components: components
|
|
493
|
-
}, children));
|
|
494
|
-
};
|
|
495
|
-
FieldsProvider.propTypes = propTypes$c;
|
|
496
|
-
FieldsProvider.defaultProps = defaultProps$c;
|
|
497
|
-
|
|
498
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
499
|
-
var GoogleKeysContext = /*#__PURE__*/React.createContext({
|
|
500
|
-
apiKey: null
|
|
501
|
-
});
|
|
502
|
-
var useGoogleKeys = function useGoogleKeys() {
|
|
503
|
-
return React.useContext(GoogleKeysContext);
|
|
504
|
-
};
|
|
505
|
-
var propTypes$b = {
|
|
506
|
-
children: PropTypes.node.isRequired,
|
|
507
|
-
apiKey: PropTypes.string // .isRequired,
|
|
508
|
-
};
|
|
509
|
-
var defaultProps$b = {
|
|
510
|
-
apiKey: null
|
|
511
|
-
};
|
|
512
|
-
var GoogleKeysProvider = function GoogleKeysProvider(_ref) {
|
|
513
|
-
var children = _ref.children,
|
|
514
|
-
apiKey = _ref.apiKey;
|
|
515
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
516
|
-
previousApiKey = _useGoogleKeys.apiKey;
|
|
517
|
-
var value = React.useMemo(function () {
|
|
518
|
-
return {
|
|
519
|
-
apiKey: apiKey || previousApiKey
|
|
520
|
-
};
|
|
521
|
-
}, [previousApiKey, apiKey]);
|
|
522
|
-
return /*#__PURE__*/React.createElement(GoogleKeysContext.Provider, {
|
|
523
|
-
value: value
|
|
524
|
-
}, children);
|
|
525
|
-
};
|
|
526
|
-
GoogleKeysProvider.propTypes = propTypes$b;
|
|
527
|
-
GoogleKeysProvider.defaultProps = defaultProps$b;
|
|
528
|
-
|
|
529
|
-
var FontsContext = /*#__PURE__*/React.createContext({
|
|
530
|
-
systemFonts: null,
|
|
531
|
-
googleFonts: null,
|
|
532
|
-
customFonts: null
|
|
533
|
-
});
|
|
534
|
-
var useGoogleFonts = function useGoogleFonts() {
|
|
535
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
536
|
-
_ref$disabled = _ref.disabled,
|
|
537
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
538
|
-
_ref$setFonts = _ref.setFonts,
|
|
539
|
-
setFonts = _ref$setFonts === void 0 ? null : _ref$setFonts;
|
|
540
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
541
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
542
|
-
var _useState = React.useState(null),
|
|
543
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
544
|
-
googleFonts = _useState2[0],
|
|
545
|
-
setGoogleFonts = _useState2[1];
|
|
546
|
-
React.useEffect(function () {
|
|
547
|
-
var canceled = false;
|
|
548
|
-
if (apiKey !== null && !disabled) {
|
|
549
|
-
fetch.getJSON("https://www.googleapis.com/webfonts/v1/webfonts?key=".concat(apiKey, "&sort=popularity")).then(function (_ref2) {
|
|
550
|
-
var _ref2$items = _ref2.items,
|
|
551
|
-
items = _ref2$items === void 0 ? [] : _ref2$items;
|
|
552
|
-
if (!canceled) {
|
|
553
|
-
var newFonts = items.map(function (it) {
|
|
554
|
-
return {
|
|
555
|
-
type: 'google',
|
|
556
|
-
name: it.family,
|
|
557
|
-
variants: it.variants
|
|
558
|
-
};
|
|
559
|
-
});
|
|
560
|
-
if (setFonts !== null) {
|
|
561
|
-
setFonts(newFonts);
|
|
562
|
-
} else {
|
|
563
|
-
setGoogleFonts(newFonts);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
return function () {
|
|
569
|
-
canceled = true;
|
|
570
|
-
};
|
|
571
|
-
}, [apiKey, disabled, setFonts, setGoogleFonts]);
|
|
572
|
-
return googleFonts;
|
|
573
|
-
};
|
|
574
|
-
var useFonts = function useFonts() {
|
|
575
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
576
|
-
_ref3$withoutGoogleFo = _ref3.withoutGoogleFonts,
|
|
577
|
-
withoutGoogleFonts = _ref3$withoutGoogleFo === void 0 ? false : _ref3$withoutGoogleFo;
|
|
578
|
-
var _useContext = React.useContext(FontsContext),
|
|
579
|
-
_useContext$setGoogle = _useContext.setGoogleFonts,
|
|
580
|
-
setGoogleFonts = _useContext$setGoogle === void 0 ? null : _useContext$setGoogle,
|
|
581
|
-
_useContext$systemFon = _useContext.systemFonts,
|
|
582
|
-
systemFonts = _useContext$systemFon === void 0 ? null : _useContext$systemFon,
|
|
583
|
-
_useContext$googleFon = _useContext.googleFonts,
|
|
584
|
-
googleFonts = _useContext$googleFon === void 0 ? null : _useContext$googleFon,
|
|
585
|
-
_useContext$customFon = _useContext.customFonts,
|
|
586
|
-
customFonts = _useContext$customFon === void 0 ? null : _useContext$customFon;
|
|
587
|
-
useGoogleFonts({
|
|
588
|
-
disabled: withoutGoogleFonts || googleFonts !== null && googleFonts.length > 0,
|
|
589
|
-
setFonts: setGoogleFonts
|
|
590
|
-
});
|
|
591
|
-
var fonts = React.useMemo(function () {
|
|
592
|
-
return {
|
|
593
|
-
systemFonts: systemFonts,
|
|
594
|
-
googleFonts: googleFonts,
|
|
595
|
-
customFonts: customFonts
|
|
596
|
-
};
|
|
597
|
-
}, [systemFonts, googleFonts, customFonts]);
|
|
598
|
-
return fonts;
|
|
599
|
-
};
|
|
600
|
-
var propTypes$a = {
|
|
601
|
-
children: PropTypes.node.isRequired,
|
|
602
|
-
systemFonts: core.PropTypes.fonts,
|
|
603
|
-
customFonts: core.PropTypes.fonts
|
|
604
|
-
};
|
|
605
|
-
var defaultProps$a = {
|
|
606
|
-
systemFonts: ['Arial', 'Courier', 'Georgia', 'Times New Roman', 'Verdana'],
|
|
607
|
-
customFonts: null
|
|
608
|
-
};
|
|
609
|
-
var FontsProvider = function FontsProvider(_ref4) {
|
|
610
|
-
var systemFonts = _ref4.systemFonts,
|
|
611
|
-
customFonts = _ref4.customFonts,
|
|
612
|
-
children = _ref4.children;
|
|
613
|
-
var _useFonts = useFonts(),
|
|
614
|
-
_useFonts$systemFonts = _useFonts.systemFonts,
|
|
615
|
-
previousSystemFonts = _useFonts$systemFonts === void 0 ? null : _useFonts$systemFonts,
|
|
616
|
-
_useFonts$googleFonts = _useFonts.googleFonts,
|
|
617
|
-
previousGoogleFonts = _useFonts$googleFonts === void 0 ? null : _useFonts$googleFonts,
|
|
618
|
-
previousCustomFonts = _useFonts.customFonts;
|
|
619
|
-
var _useState3 = React.useState(null),
|
|
620
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
621
|
-
googleFonts = _useState4[0],
|
|
622
|
-
setGoogleFonts = _useState4[1];
|
|
623
|
-
var fonts = React.useMemo(function () {
|
|
624
|
-
return {
|
|
625
|
-
systemFonts: uniqBy([].concat(_toConsumableArray(previousSystemFonts || []), _toConsumableArray(systemFonts || [])), function (font) {
|
|
626
|
-
return isObject(font) ? font.name : font;
|
|
627
|
-
}),
|
|
628
|
-
googleFonts: uniqBy([].concat(_toConsumableArray(previousGoogleFonts || []), _toConsumableArray(googleFonts || [])), function (font) {
|
|
629
|
-
return isObject(font) ? font.name : font;
|
|
630
|
-
}),
|
|
631
|
-
customFonts: uniqBy([].concat(_toConsumableArray(previousCustomFonts || []), _toConsumableArray(customFonts || [])), function (font) {
|
|
632
|
-
return isObject(font) ? font.name : font;
|
|
633
|
-
}),
|
|
634
|
-
setGoogleFonts: setGoogleFonts
|
|
635
|
-
};
|
|
636
|
-
}, [previousSystemFonts, previousGoogleFonts, previousCustomFonts, customFonts, systemFonts, googleFonts, setGoogleFonts]);
|
|
637
|
-
return /*#__PURE__*/React.createElement(FontsContext.Provider, {
|
|
638
|
-
value: fonts
|
|
639
|
-
}, children);
|
|
640
|
-
};
|
|
641
|
-
FontsProvider.propTypes = propTypes$a;
|
|
642
|
-
FontsProvider.defaultProps = defaultProps$a;
|
|
643
|
-
|
|
644
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
645
|
-
var FormContext = /*#__PURE__*/React.createContext(null);
|
|
646
|
-
var useForm = function useForm() {
|
|
647
|
-
return React.useContext(FormContext);
|
|
648
|
-
};
|
|
649
|
-
var useFormValue = function useFormValue() {
|
|
650
|
-
var _useForm = useForm(),
|
|
651
|
-
value = _useForm.value;
|
|
652
|
-
return value;
|
|
653
|
-
};
|
|
654
|
-
var useFormSetValue = function useFormSetValue() {
|
|
655
|
-
var _useForm2 = useForm(),
|
|
656
|
-
setValue = _useForm2.setValue;
|
|
657
|
-
return setValue;
|
|
658
|
-
};
|
|
659
|
-
var propTypes$9 = {
|
|
660
|
-
value: PropTypes.object.isRequired,
|
|
661
|
-
// eslint-disable-line react/forbid-prop-types
|
|
662
|
-
setValue: PropTypes.func.isRequired,
|
|
663
|
-
children: PropTypes.node.isRequired
|
|
664
|
-
};
|
|
665
|
-
var defaultProps$9 = {};
|
|
666
|
-
var FormProvider = function FormProvider(_ref) {
|
|
667
|
-
var value = _ref.value,
|
|
668
|
-
setValue = _ref.setValue,
|
|
669
|
-
children = _ref.children;
|
|
670
|
-
var values = React.useMemo(function () {
|
|
671
|
-
return {
|
|
672
|
-
value: value,
|
|
673
|
-
setValue: setValue
|
|
674
|
-
};
|
|
675
|
-
}, [value, setValue]);
|
|
676
|
-
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
677
|
-
value: values
|
|
678
|
-
}, children);
|
|
679
|
-
};
|
|
680
|
-
FormProvider.propTypes = propTypes$9;
|
|
681
|
-
FormProvider.defaultProps = defaultProps$9;
|
|
682
|
-
|
|
683
|
-
var GoogleApiClientContext = /*#__PURE__*/React.createContext(null);
|
|
684
|
-
var useGoogleApiClient = function useGoogleApiClient() {
|
|
685
|
-
return React.useContext(GoogleApiClientContext);
|
|
686
|
-
};
|
|
687
|
-
var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
688
|
-
var getDisplayName = function getDisplayName(_ref) {
|
|
689
|
-
var _ref$displayName = _ref.displayName,
|
|
690
|
-
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
691
|
-
_ref$name = _ref.name,
|
|
692
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
693
|
-
return displayName || name || 'Component';
|
|
694
|
-
};
|
|
695
|
-
var WithGoogleApiClientComponent = function WithGoogleApiClientComponent(props) {
|
|
696
|
-
return /*#__PURE__*/React.createElement(GoogleApiClientContext.Consumer, null, function (client) {
|
|
697
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
698
|
-
googleApiClient: client
|
|
699
|
-
}, props));
|
|
700
|
-
});
|
|
701
|
-
};
|
|
702
|
-
WithGoogleApiClientComponent.displayName = "WithGoogleApiClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
703
|
-
return WithGoogleApiClientComponent;
|
|
704
|
-
};
|
|
705
|
-
var propTypes$8 = {
|
|
706
|
-
children: PropTypes.node.isRequired
|
|
707
|
-
};
|
|
708
|
-
var defaultProps$8 = {};
|
|
709
|
-
var GoogleApiClientProvider = function GoogleApiClientProvider(_ref2) {
|
|
710
|
-
var children = _ref2.children;
|
|
711
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
712
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
713
|
-
var _useState = React.useState(null),
|
|
714
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
715
|
-
client = _useState2[0],
|
|
716
|
-
setClient = _useState2[1];
|
|
717
|
-
React.useEffect(function () {
|
|
718
|
-
services.loadGoogleApi().then(function (gapi) {
|
|
719
|
-
return gapi.client.init({
|
|
720
|
-
apiKey: apiKey
|
|
721
|
-
}).then(function () {
|
|
722
|
-
return gapi;
|
|
723
|
-
});
|
|
724
|
-
}).then(function (gapi) {
|
|
725
|
-
return setClient(gapi);
|
|
726
|
-
});
|
|
727
|
-
}, [apiKey, setClient]);
|
|
728
|
-
return /*#__PURE__*/React.createElement(GoogleApiClientContext.Provider, {
|
|
729
|
-
value: client
|
|
730
|
-
}, children);
|
|
731
|
-
};
|
|
732
|
-
GoogleApiClientProvider.propTypes = propTypes$8;
|
|
733
|
-
GoogleApiClientProvider.defaultProps = defaultProps$8;
|
|
734
|
-
|
|
735
|
-
var GoogleMapsClientContext = /*#__PURE__*/React.createContext(null);
|
|
736
|
-
var useGoogleMapsClient = function useGoogleMapsClient() {
|
|
737
|
-
return React.useContext(GoogleMapsClientContext);
|
|
738
|
-
};
|
|
739
|
-
var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
740
|
-
var getDisplayName = function getDisplayName(_ref) {
|
|
741
|
-
var _ref$displayName = _ref.displayName,
|
|
742
|
-
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
743
|
-
_ref$name = _ref.name,
|
|
744
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
745
|
-
return displayName || name || 'Component';
|
|
746
|
-
};
|
|
747
|
-
var WithGoogleMapsClientComponent = function WithGoogleMapsClientComponent(props) {
|
|
748
|
-
return /*#__PURE__*/React.createElement(GoogleMapsClientContext.Consumer, null, function (client) {
|
|
749
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
750
|
-
googleApiClient: client
|
|
751
|
-
}, props));
|
|
752
|
-
});
|
|
753
|
-
};
|
|
754
|
-
WithGoogleMapsClientComponent.displayName = "WithGoogleMapsClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
755
|
-
return WithGoogleMapsClientComponent;
|
|
756
|
-
};
|
|
757
|
-
var propTypes$7 = {
|
|
758
|
-
children: PropTypes.node.isRequired,
|
|
759
|
-
locale: PropTypes.string,
|
|
760
|
-
libraries: PropTypes.arrayOf(PropTypes.string)
|
|
761
|
-
};
|
|
762
|
-
var defaultProps$7 = {
|
|
763
|
-
locale: 'fr',
|
|
764
|
-
libraries: null
|
|
765
|
-
};
|
|
766
|
-
var GoogleMapsClientProvider = function GoogleMapsClientProvider(_ref2) {
|
|
767
|
-
var children = _ref2.children,
|
|
768
|
-
locale = _ref2.locale,
|
|
769
|
-
libraries = _ref2.libraries;
|
|
770
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
771
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
772
|
-
var exisitingClient = useGoogleMapsClient();
|
|
773
|
-
var _useState = React.useState(exisitingClient),
|
|
774
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
775
|
-
client = _useState2[0],
|
|
776
|
-
setClient = _useState2[1];
|
|
777
|
-
React.useEffect(function () {
|
|
778
|
-
if (exisitingClient === null) {
|
|
779
|
-
services.loadGoogleMaps({
|
|
780
|
-
apiKey: apiKey,
|
|
781
|
-
locale: locale,
|
|
782
|
-
libraries: libraries
|
|
783
|
-
}).then(function (newClient) {
|
|
784
|
-
setClient(newClient);
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
}, [apiKey, locale, libraries, setClient, exisitingClient]);
|
|
788
|
-
return /*#__PURE__*/React.createElement(GoogleMapsClientContext.Provider, {
|
|
789
|
-
value: client
|
|
790
|
-
}, children);
|
|
791
|
-
};
|
|
792
|
-
GoogleMapsClientProvider.propTypes = propTypes$7;
|
|
793
|
-
GoogleMapsClientProvider.defaultProps = defaultProps$7;
|
|
794
|
-
|
|
795
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
796
|
-
var defaultLocales = ['en', 'fr'];
|
|
797
|
-
var LocalesContext = /*#__PURE__*/React.createContext({
|
|
798
|
-
locales: defaultLocales
|
|
799
|
-
});
|
|
800
|
-
var useLocales = function useLocales() {
|
|
801
|
-
var _useContext = React.useContext(LocalesContext),
|
|
802
|
-
locales = _useContext.locales;
|
|
803
|
-
return locales;
|
|
804
|
-
};
|
|
805
|
-
var useOtherLocales = function useOtherLocales() {
|
|
806
|
-
var _useLocales = useLocales(),
|
|
807
|
-
locales = _useLocales.locales;
|
|
808
|
-
var _useIntl = reactIntl.useIntl(),
|
|
809
|
-
locale = _useIntl.locale;
|
|
810
|
-
var otherLocales = React.useMemo(function () {
|
|
811
|
-
return locales.filter(function (it) {
|
|
812
|
-
return it !== locale;
|
|
813
|
-
});
|
|
814
|
-
}, [locales, locale]);
|
|
815
|
-
return otherLocales;
|
|
816
|
-
};
|
|
817
|
-
var propTypes$6 = {
|
|
818
|
-
locales: PropTypes.arrayOf(PropTypes.string),
|
|
819
|
-
children: PropTypes.node.isRequired
|
|
820
|
-
};
|
|
821
|
-
var defaultProps$6 = {
|
|
822
|
-
locales: []
|
|
823
|
-
};
|
|
824
|
-
var LocalesProvider = function LocalesProvider(_ref) {
|
|
825
|
-
var locales = _ref.locales,
|
|
826
|
-
children = _ref.children;
|
|
827
|
-
var value = React.useMemo(function () {
|
|
828
|
-
return {
|
|
829
|
-
locales: locales
|
|
830
|
-
};
|
|
831
|
-
}, [locales]);
|
|
832
|
-
return /*#__PURE__*/React.createElement(LocalesContext.Provider, {
|
|
833
|
-
value: value
|
|
834
|
-
}, children);
|
|
835
|
-
};
|
|
836
|
-
LocalesProvider.propTypes = propTypes$6;
|
|
837
|
-
LocalesProvider.defaultProps = defaultProps$6;
|
|
838
|
-
|
|
839
|
-
// import { getDisplayName } from '../utils';
|
|
840
|
-
|
|
841
|
-
var ModalContext = /*#__PURE__*/React.createContext(null);
|
|
842
|
-
var useModal = function useModal() {
|
|
843
|
-
return React.useContext(ModalContext) || {};
|
|
844
|
-
};
|
|
845
|
-
var propTypes$5 = {
|
|
846
|
-
children: PropTypes.node.isRequired,
|
|
847
|
-
container: PropTypes.object // eslint-disable-line
|
|
848
|
-
};
|
|
849
|
-
var defaultProps$5 = {
|
|
850
|
-
container: null
|
|
851
|
-
};
|
|
852
|
-
var ModalProvider = function ModalProvider(_ref) {
|
|
853
|
-
var children = _ref.children,
|
|
854
|
-
initialContainer = _ref.container;
|
|
855
|
-
var _useState = React.useState(initialContainer),
|
|
856
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
857
|
-
container = _useState2[0],
|
|
858
|
-
setContainer = _useState2[1];
|
|
859
|
-
var _useState3 = React.useState([]),
|
|
860
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
861
|
-
modals = _useState4[0],
|
|
862
|
-
setModals = _useState4[1];
|
|
863
|
-
var modalsRef = React.useRef(modals);
|
|
864
|
-
var register = React.useCallback(function (id) {
|
|
865
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
866
|
-
var currentModals = modalsRef.current;
|
|
867
|
-
var newModals = [].concat(_toConsumableArray(currentModals), [_objectSpread({
|
|
868
|
-
id: id
|
|
869
|
-
}, data)]);
|
|
870
|
-
setModals(newModals);
|
|
871
|
-
modalsRef.current = newModals;
|
|
872
|
-
}, [modals, setModals]);
|
|
873
|
-
var unregister = React.useCallback(function (id) {
|
|
874
|
-
var currentModals = modalsRef.current;
|
|
875
|
-
var foundIndex = currentModals.findIndex(function (_ref2) {
|
|
876
|
-
var modalId = _ref2.id;
|
|
877
|
-
return modalId === id;
|
|
878
|
-
});
|
|
879
|
-
if (foundIndex !== -1) {
|
|
880
|
-
var newModals = currentModals.filter(function (_ref3) {
|
|
881
|
-
var modalId = _ref3.id;
|
|
882
|
-
return modalId !== id;
|
|
883
|
-
});
|
|
884
|
-
setModals(newModals);
|
|
885
|
-
modalsRef.current = newModals;
|
|
886
|
-
}
|
|
887
|
-
}, [modals, setModals]);
|
|
888
|
-
var value = React.useMemo(function () {
|
|
889
|
-
return {
|
|
890
|
-
modals: modals,
|
|
891
|
-
container: container,
|
|
892
|
-
setContainer: setContainer,
|
|
893
|
-
register: register,
|
|
894
|
-
unregister: unregister
|
|
895
|
-
};
|
|
896
|
-
}, [modals, container, setContainer, register, unregister]);
|
|
897
|
-
return /*#__PURE__*/React.createElement(ModalContext.Provider, {
|
|
898
|
-
value: value
|
|
899
|
-
}, children);
|
|
900
|
-
};
|
|
901
|
-
ModalProvider.propTypes = propTypes$5;
|
|
902
|
-
ModalProvider.defaultProps = defaultProps$5;
|
|
903
|
-
|
|
904
|
-
var PanelsContext = /*#__PURE__*/React.createContext({
|
|
905
|
-
container: null
|
|
906
|
-
});
|
|
907
|
-
var usePanels = function usePanels() {
|
|
908
|
-
return React.useContext(PanelsContext) || {};
|
|
909
|
-
};
|
|
910
|
-
var withPanels = function withPanels(WrappedComponent) {
|
|
911
|
-
var WithPanelsComponent = function WithPanelsComponent(props) {
|
|
912
|
-
return /*#__PURE__*/React.createElement(PanelsContext.Consumer, null, function (_ref) {
|
|
913
|
-
var panels = _ref.panels,
|
|
914
|
-
setContainer = _ref.setContainer,
|
|
915
|
-
container = _ref.container,
|
|
916
|
-
register = _ref.register,
|
|
917
|
-
unregister = _ref.unregister;
|
|
918
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
919
|
-
panelsContainer: container,
|
|
920
|
-
setPanelsContainer: setContainer,
|
|
921
|
-
panels: panels,
|
|
922
|
-
registerPanel: register,
|
|
923
|
-
unregisterPanel: unregister
|
|
924
|
-
}, props));
|
|
925
|
-
});
|
|
926
|
-
};
|
|
927
|
-
WithPanelsComponent.displayName = "WithPanels(".concat(utils.getDisplayName(WrappedComponent), ")");
|
|
928
|
-
return WithPanelsComponent;
|
|
929
|
-
};
|
|
930
|
-
var propTypes$4 = {
|
|
931
|
-
children: PropTypes.node.isRequired,
|
|
932
|
-
container: PropTypes.object // eslint-disable-line
|
|
933
|
-
};
|
|
934
|
-
var defaultProps$4 = {
|
|
935
|
-
container: null
|
|
936
|
-
};
|
|
937
|
-
var PanelsProvider = function PanelsProvider(_ref2) {
|
|
938
|
-
var children = _ref2.children,
|
|
939
|
-
initialContainer = _ref2.container;
|
|
940
|
-
var _useState = React.useState(initialContainer),
|
|
941
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
942
|
-
container = _useState2[0],
|
|
943
|
-
setContainer = _useState2[1];
|
|
944
|
-
var _useState3 = React.useState([]),
|
|
945
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
946
|
-
panels = _useState4[0],
|
|
947
|
-
setPanels = _useState4[1];
|
|
948
|
-
var panelsRef = React.useRef(panels);
|
|
949
|
-
var register = React.useCallback(function (id) {
|
|
950
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
951
|
-
var currentPanels = panelsRef.current;
|
|
952
|
-
var newPanels = [].concat(_toConsumableArray(currentPanels), [_objectSpread({
|
|
953
|
-
id: id
|
|
954
|
-
}, data)]);
|
|
955
|
-
setPanels(newPanels);
|
|
956
|
-
panelsRef.current = newPanels;
|
|
957
|
-
}, [panels, setPanels]);
|
|
958
|
-
var unregister = React.useCallback(function (id) {
|
|
959
|
-
var currentPanels = panelsRef.current;
|
|
960
|
-
var foundIndex = currentPanels.findIndex(function (_ref3) {
|
|
961
|
-
var modalId = _ref3.id;
|
|
962
|
-
return modalId === id;
|
|
963
|
-
});
|
|
964
|
-
if (foundIndex !== -1) {
|
|
965
|
-
var newPanels = currentPanels.filter(function (_ref4) {
|
|
966
|
-
var modalId = _ref4.id;
|
|
967
|
-
return modalId !== id;
|
|
968
|
-
});
|
|
969
|
-
setPanels(newPanels);
|
|
970
|
-
panelsRef.current = newPanels;
|
|
971
|
-
}
|
|
972
|
-
}, [panels, setPanels]);
|
|
973
|
-
var value = React.useMemo(function () {
|
|
974
|
-
return {
|
|
975
|
-
panels: panels,
|
|
976
|
-
setContainer: setContainer,
|
|
977
|
-
container: container,
|
|
978
|
-
register: register,
|
|
979
|
-
unregister: unregister
|
|
980
|
-
};
|
|
981
|
-
}, [panels, setContainer, container, register, unregister]);
|
|
982
|
-
return /*#__PURE__*/React.createElement(PanelsContext.Provider, {
|
|
983
|
-
value: value
|
|
984
|
-
}, children);
|
|
985
|
-
};
|
|
986
|
-
PanelsProvider.propTypes = propTypes$4;
|
|
987
|
-
PanelsProvider.defaultProps = defaultProps$4;
|
|
988
|
-
|
|
989
|
-
var _excluded = ["component"];
|
|
990
|
-
var PanneauContext = /*#__PURE__*/React.createContext(null);
|
|
991
|
-
var usePanneau = function usePanneau() {
|
|
992
|
-
return React.useContext(PanneauContext);
|
|
993
|
-
};
|
|
994
|
-
var usePanneauResources = function usePanneauResources() {
|
|
995
|
-
var _ref = usePanneau() || {},
|
|
996
|
-
_ref$resources = _ref.resources,
|
|
997
|
-
resources = _ref$resources === void 0 ? [] : _ref$resources;
|
|
998
|
-
return resources;
|
|
999
|
-
};
|
|
1000
|
-
var usePanneauResource = function usePanneauResource(id) {
|
|
1001
|
-
var resources = usePanneauResources();
|
|
1002
|
-
return resources.find(function (it) {
|
|
1003
|
-
return it.id === id;
|
|
1004
|
-
}) || null;
|
|
1005
|
-
};
|
|
1006
|
-
var usePanneauColorScheme = function usePanneauColorScheme() {
|
|
1007
|
-
var _ref2 = usePanneau() || {},
|
|
1008
|
-
_ref2$theme = _ref2.theme,
|
|
1009
|
-
theme = _ref2$theme === void 0 ? {} : _ref2$theme;
|
|
1010
|
-
var _ref3 = theme || {},
|
|
1011
|
-
_ref3$colorScheme = _ref3.colorScheme,
|
|
1012
|
-
colorScheme = _ref3$colorScheme === void 0 ? 'light' : _ref3$colorScheme;
|
|
1013
|
-
if (colorScheme === null || colorScheme === 'light' || colorScheme === 'dark') {
|
|
1014
|
-
return colorScheme === 'dark' ? {
|
|
1015
|
-
theme: 'dark',
|
|
1016
|
-
background: 'dark',
|
|
1017
|
-
text: 'light'
|
|
1018
|
-
} : {
|
|
1019
|
-
theme: 'light',
|
|
1020
|
-
background: 'light',
|
|
1021
|
-
text: 'dark'
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
return {
|
|
1025
|
-
theme: colorScheme,
|
|
1026
|
-
background: null,
|
|
1027
|
-
text: null
|
|
1028
|
-
};
|
|
1029
|
-
};
|
|
1030
|
-
var usePanneauComponents = function usePanneauComponents() {
|
|
1031
|
-
var _ref4 = usePanneau() || {},
|
|
1032
|
-
_ref4$components = _ref4.components,
|
|
1033
|
-
components = _ref4$components === void 0 ? {} : _ref4$components;
|
|
1034
|
-
return components;
|
|
1035
|
-
};
|
|
1036
|
-
var usePanneauComponent = function usePanneauComponent(namespace, name) {
|
|
1037
|
-
var _ref5 = usePanneau() || {},
|
|
1038
|
-
_ref5$components = _ref5.components,
|
|
1039
|
-
components = _ref5$components === void 0 ? {} : _ref5$components;
|
|
1040
|
-
var path = namespace !== null ? "".concat(namespace, ".").concat(name) : name || null;
|
|
1041
|
-
var component = components[path] || null;
|
|
1042
|
-
if (isString(component)) {
|
|
1043
|
-
return component;
|
|
1044
|
-
}
|
|
1045
|
-
if (isObject(component) && isString(component === null || component === void 0 ? void 0 : component.componnent)) {
|
|
1046
|
-
// eslint-disable-next-line no-unused-vars
|
|
1047
|
-
component.component;
|
|
1048
|
-
_objectWithoutProperties(component, _excluded);
|
|
1049
|
-
return component.component;
|
|
1050
|
-
}
|
|
1051
|
-
return null;
|
|
1052
|
-
};
|
|
1053
|
-
var usePanneauAuth = function usePanneauAuth() {
|
|
1054
|
-
var _ref6 = usePanneau() || {},
|
|
1055
|
-
_ref6$auth = _ref6.auth,
|
|
1056
|
-
auth = _ref6$auth === void 0 ? {} : _ref6$auth;
|
|
1057
|
-
return auth;
|
|
1058
|
-
};
|
|
1059
|
-
var usePanneauSettings = function usePanneauSettings() {
|
|
1060
|
-
var _ref7 = usePanneau() || {},
|
|
1061
|
-
_ref7$settings = _ref7.settings,
|
|
1062
|
-
settings = _ref7$settings === void 0 ? {} : _ref7$settings;
|
|
1063
|
-
return settings;
|
|
1064
|
-
};
|
|
1065
|
-
var propTypes$3 = {
|
|
1066
|
-
definition: panneauDefinition.isRequired,
|
|
1067
|
-
children: PropTypes.node.isRequired
|
|
1068
|
-
};
|
|
1069
|
-
var defaultProps$3 = {};
|
|
1070
|
-
var PanneauProvider = function PanneauProvider(_ref8) {
|
|
1071
|
-
var definition = _ref8.definition,
|
|
1072
|
-
children = _ref8.children;
|
|
1073
|
-
return /*#__PURE__*/React.createElement(PanneauContext.Provider, {
|
|
1074
|
-
value: definition
|
|
1075
|
-
}, children);
|
|
1076
|
-
};
|
|
1077
|
-
PanneauProvider.propTypes = propTypes$3;
|
|
1078
|
-
PanneauProvider.defaultProps = defaultProps$3;
|
|
1079
|
-
|
|
1080
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1081
|
-
var ResourceContext = /*#__PURE__*/React.createContext(null);
|
|
1082
|
-
var useResource = function useResource() {
|
|
1083
|
-
return React.useContext(ResourceContext);
|
|
1084
|
-
};
|
|
1085
|
-
var propTypes$2 = {
|
|
1086
|
-
resource: resource.isRequired,
|
|
1087
|
-
children: PropTypes.node.isRequired
|
|
1088
|
-
};
|
|
1089
|
-
var defaultProps$2 = {};
|
|
1090
|
-
var ResourceProvider = function ResourceProvider(_ref) {
|
|
1091
|
-
var resource = _ref.resource,
|
|
1092
|
-
children = _ref.children;
|
|
1093
|
-
return /*#__PURE__*/React.createElement(ResourceContext.Provider, {
|
|
1094
|
-
value: resource
|
|
1095
|
-
}, children);
|
|
1096
|
-
};
|
|
1097
|
-
ResourceProvider.propTypes = propTypes$2;
|
|
1098
|
-
ResourceProvider.defaultProps = defaultProps$2;
|
|
1099
|
-
|
|
1100
|
-
// React.useInsertionEffect is not available in React <18
|
|
1101
|
-
var useEffect = React__namespace.useEffect,
|
|
1102
|
-
useLayoutEffect = React__namespace.useLayoutEffect,
|
|
1103
|
-
useRef = React__namespace.useRef,
|
|
1104
|
-
useBuiltinInsertionEffect = React__namespace.useInsertionEffect;
|
|
1105
|
-
|
|
1106
|
-
// Copied from:
|
|
1107
|
-
// https://github.com/facebook/react/blob/main/packages/shared/ExecutionEnvironment.js
|
|
1108
|
-
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
1109
|
-
|
|
1110
|
-
// Copied from:
|
|
1111
|
-
// https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.ts
|
|
1112
|
-
// "React currently throws a warning when using useLayoutEffect on the server.
|
|
1113
|
-
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
1114
|
-
// useLayoutEffect in the browser."
|
|
1115
|
-
var useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
|
1116
|
-
|
|
1117
|
-
// useInsertionEffect is already a noop on the server.
|
|
1118
|
-
// See: https://github.com/facebook/react/blob/main/packages/react-server/src/ReactFizzHooks.js
|
|
1119
|
-
var useInsertionEffect = useBuiltinInsertionEffect || useIsomorphicLayoutEffect;
|
|
1120
|
-
|
|
1121
|
-
// Userland polyfill while we wait for the forthcoming
|
|
1122
|
-
// https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
|
1123
|
-
// Note: "A high-fidelity polyfill for useEvent is not possible because
|
|
1124
|
-
// there is no lifecycle or Hook in React that we can use to switch
|
|
1125
|
-
// .current at the right timing."
|
|
1126
|
-
// So we will have to make do with this "close enough" approach for now.
|
|
1127
|
-
var useEvent = function useEvent(fn) {
|
|
1128
|
-
var ref = useRef([fn, function () {
|
|
1129
|
-
return ref[0].apply(ref, arguments);
|
|
1130
|
-
}]).current;
|
|
1131
|
-
// Per Dan Abramov: useInsertionEffect executes marginally closer to the
|
|
1132
|
-
// correct timing for ref synchronization than useLayoutEffect on React 18.
|
|
1133
|
-
// See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
|
|
1134
|
-
useInsertionEffect(function () {
|
|
1135
|
-
ref[0] = fn;
|
|
1136
|
-
});
|
|
1137
|
-
return ref[1];
|
|
1138
|
-
};
|
|
1139
|
-
|
|
1140
|
-
/**
|
|
1141
|
-
* History API docs @see https://developer.mozilla.org/en-US/docs/Web/API/History
|
|
1142
|
-
*/
|
|
1143
|
-
var eventPopstate = "popstate";
|
|
1144
|
-
var eventPushState = "pushState";
|
|
1145
|
-
var eventReplaceState = "replaceState";
|
|
1146
|
-
var eventHashchange = "hashchange";
|
|
1147
|
-
var events = [eventPopstate, eventPushState, eventReplaceState, eventHashchange];
|
|
1148
|
-
var subscribeToLocationUpdates = function subscribeToLocationUpdates(callback) {
|
|
1149
|
-
for (var _i = 0, _events = events; _i < _events.length; _i++) {
|
|
1150
|
-
var event = _events[_i];
|
|
1151
|
-
addEventListener(event, callback);
|
|
1152
|
-
}
|
|
1153
|
-
return function () {
|
|
1154
|
-
for (var _i2 = 0, _events2 = events; _i2 < _events2.length; _i2++) {
|
|
1155
|
-
var _event = _events2[_i2];
|
|
1156
|
-
removeEventListener(_event, callback);
|
|
1157
|
-
}
|
|
1158
|
-
};
|
|
1159
|
-
};
|
|
1160
|
-
var useLocationProperty = function useLocationProperty(fn, ssrFn) {
|
|
1161
|
-
return index_js.useSyncExternalStore(subscribeToLocationUpdates, fn, ssrFn);
|
|
1162
|
-
};
|
|
1163
|
-
var currentSearch = function currentSearch() {
|
|
1164
|
-
return location.search;
|
|
1165
|
-
};
|
|
1166
|
-
var useSearch = function useSearch() {
|
|
1167
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1168
|
-
_ref$ssrSearch = _ref.ssrSearch,
|
|
1169
|
-
ssrSearch = _ref$ssrSearch === void 0 ? "" : _ref$ssrSearch;
|
|
1170
|
-
return useLocationProperty(currentSearch, function () {
|
|
1171
|
-
return ssrSearch;
|
|
1172
|
-
});
|
|
1173
|
-
};
|
|
1174
|
-
var currentPathname = function currentPathname() {
|
|
1175
|
-
return location.pathname;
|
|
1176
|
-
};
|
|
1177
|
-
var usePathname = function usePathname() {
|
|
1178
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1179
|
-
ssrPath = _ref2.ssrPath;
|
|
1180
|
-
return useLocationProperty(currentPathname, ssrPath ? function () {
|
|
1181
|
-
return ssrPath;
|
|
1182
|
-
} : currentPathname);
|
|
1183
|
-
};
|
|
1184
|
-
var navigate = function navigate(to) {
|
|
1185
|
-
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1186
|
-
_ref3$replace = _ref3.replace,
|
|
1187
|
-
replace = _ref3$replace === void 0 ? false : _ref3$replace,
|
|
1188
|
-
_ref3$state = _ref3.state,
|
|
1189
|
-
state = _ref3$state === void 0 ? null : _ref3$state;
|
|
1190
|
-
return history[replace ? eventReplaceState : eventPushState](state, "", to);
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
// the 2nd argument of the `useBrowserLocation` return value is a function
|
|
1194
|
-
// that allows to perform a navigation.
|
|
1195
|
-
var useBrowserLocation = function useBrowserLocation() {
|
|
1196
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1197
|
-
return [usePathname(opts), navigate];
|
|
1198
|
-
};
|
|
1199
|
-
var patchKey = Symbol["for"]("wouter_v3");
|
|
1200
|
-
|
|
1201
|
-
// While History API does have `popstate` event, the only
|
|
1202
|
-
// proper way to listen to changes via `push/replaceState`
|
|
1203
|
-
// is to monkey-patch these methods.
|
|
1204
|
-
//
|
|
1205
|
-
// See https://stackoverflow.com/a/4585031
|
|
1206
|
-
if (typeof history !== "undefined" && typeof window[patchKey] === "undefined") {
|
|
1207
|
-
var _loop = function _loop() {
|
|
1208
|
-
var type = _arr[_i3];
|
|
1209
|
-
var original = history[type];
|
|
1210
|
-
// TODO: we should be using unstable_batchedUpdates to avoid multiple re-renders,
|
|
1211
|
-
// however that will require an additional peer dependency on react-dom.
|
|
1212
|
-
// See: https://github.com/reactwg/react-18/discussions/86#discussioncomment-1567149
|
|
1213
|
-
history[type] = function () {
|
|
1214
|
-
var result = original.apply(this, arguments);
|
|
1215
|
-
var event = new Event(type);
|
|
1216
|
-
event.arguments = arguments;
|
|
1217
|
-
dispatchEvent(event);
|
|
1218
|
-
return result;
|
|
1219
|
-
};
|
|
1220
|
-
};
|
|
1221
|
-
for (var _i3 = 0, _arr = [eventPushState, eventReplaceState]; _i3 < _arr.length; _i3++) {
|
|
1222
|
-
_loop();
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
// patch history object only once
|
|
1226
|
-
// See: https://github.com/molefrog/wouter/issues/167
|
|
1227
|
-
Object.defineProperty(window, patchKey, {
|
|
1228
|
-
value: true
|
|
1229
|
-
});
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
var _excluded3 = ["to", "href", "onClick", "asChild", "children", "className", "replace", "state"];
|
|
1233
|
-
|
|
1234
|
-
/*
|
|
1235
|
-
* Transforms `path` into its relative `base` version
|
|
1236
|
-
* If base isn't part of the path provided returns absolute path e.g. `~/app`
|
|
1237
|
-
*/
|
|
1238
|
-
var relativePath = function relativePath() {
|
|
1239
|
-
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
1240
|
-
var path = arguments.length > 1 ? arguments[1] : undefined;
|
|
1241
|
-
return !path.toLowerCase().indexOf(base.toLowerCase()) ? path.slice(base.length) || "/" : "~" + path;
|
|
1242
|
-
};
|
|
1243
|
-
var absolutePath = function absolutePath(to) {
|
|
1244
|
-
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
1245
|
-
return to[0] === "~" ? to.slice(1) : base + to;
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
/*
|
|
1249
|
-
* decodes escape sequences such as %20
|
|
1250
|
-
*/
|
|
1251
|
-
var unescape = function unescape(str) {
|
|
1252
|
-
try {
|
|
1253
|
-
return decodeURI(str);
|
|
1254
|
-
} catch (_e) {
|
|
1255
|
-
// fail-safe mode: if string can't be decoded do nothing
|
|
1256
|
-
return str;
|
|
1257
|
-
}
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
|
-
/*
|
|
1261
|
-
* Router and router context. Router is a lightweight object that represents the current
|
|
1262
|
-
* routing options: how location is managed, base path etc.
|
|
1263
|
-
*
|
|
1264
|
-
* There is a default router present for most of the use cases, however it can be overridden
|
|
1265
|
-
* via the <Router /> component.
|
|
1266
|
-
*/
|
|
1267
|
-
|
|
1268
|
-
var defaultRouter = {
|
|
1269
|
-
hook: useBrowserLocation,
|
|
1270
|
-
searchHook: useSearch,
|
|
1271
|
-
parser: regexparam.parse,
|
|
1272
|
-
base: "",
|
|
1273
|
-
// this option is used to override the current location during SSR
|
|
1274
|
-
ssrPath: undefined,
|
|
1275
|
-
ssrSearch: undefined,
|
|
1276
|
-
// customizes how `href` props are transformed for <Link />
|
|
1277
|
-
hrefs: function hrefs(x) {
|
|
1278
|
-
return x;
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
var RouterCtx = React.createContext(defaultRouter);
|
|
1282
|
-
|
|
1283
|
-
// gets the closest parent router from the context
|
|
1284
|
-
var useRouter = function useRouter() {
|
|
1285
|
-
return React.useContext(RouterCtx);
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
/**
|
|
1289
|
-
* Parameters context. Used by `useParams()` to get the
|
|
1290
|
-
* matched params from the innermost `Route` component.
|
|
1291
|
-
*/
|
|
1292
|
-
|
|
1293
|
-
React.createContext({});
|
|
1294
|
-
|
|
1295
|
-
/*
|
|
1296
|
-
* Part 1, Hooks API: useRoute and useLocation
|
|
1297
|
-
*/
|
|
1298
|
-
|
|
1299
|
-
// Internal version of useLocation to avoid redundant useRouter calls
|
|
1300
|
-
|
|
1301
|
-
var useLocationFromRouter = function useLocationFromRouter(router) {
|
|
1302
|
-
var _router$hook = router.hook(router),
|
|
1303
|
-
_router$hook2 = _slicedToArray(_router$hook, 2),
|
|
1304
|
-
location = _router$hook2[0],
|
|
1305
|
-
navigate = _router$hook2[1];
|
|
1306
|
-
|
|
1307
|
-
// the function reference should stay the same between re-renders, so that
|
|
1308
|
-
// it can be passed down as an element prop without any performance concerns.
|
|
1309
|
-
// (This is achieved via `useEvent`.)
|
|
1310
|
-
return [unescape(relativePath(router.base, location)), useEvent(function (to, navOpts) {
|
|
1311
|
-
return navigate(absolutePath(to, router.base), navOpts);
|
|
1312
|
-
})];
|
|
1313
|
-
};
|
|
1314
|
-
var useLocation = function useLocation() {
|
|
1315
|
-
return useLocationFromRouter(useRouter());
|
|
1316
|
-
};
|
|
1317
|
-
React.forwardRef(function (props, ref) {
|
|
1318
|
-
var router = useRouter();
|
|
1319
|
-
var _useLocationFromRoute3 = useLocationFromRouter(router),
|
|
1320
|
-
_useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
|
|
1321
|
-
path = _useLocationFromRoute4[0],
|
|
1322
|
-
navigate = _useLocationFromRoute4[1];
|
|
1323
|
-
var to = props.to,
|
|
1324
|
-
_props$href = props.href,
|
|
1325
|
-
_href = _props$href === void 0 ? to : _props$href,
|
|
1326
|
-
_onClick = props.onClick,
|
|
1327
|
-
asChild = props.asChild,
|
|
1328
|
-
children = props.children,
|
|
1329
|
-
cls = props.className;
|
|
1330
|
-
props.replace;
|
|
1331
|
-
props.state;
|
|
1332
|
-
var restProps = _objectWithoutProperties(props, _excluded3);
|
|
1333
|
-
var onClick = useEvent(function (event) {
|
|
1334
|
-
// ignores the navigation when clicked using right mouse button or
|
|
1335
|
-
// by holding a special modifier key: ctrl, command, win, alt, shift
|
|
1336
|
-
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) return;
|
|
1337
|
-
_onClick === null || _onClick === void 0 || _onClick(event);
|
|
1338
|
-
if (!event.defaultPrevented) {
|
|
1339
|
-
event.preventDefault();
|
|
1340
|
-
navigate(_href, props);
|
|
1341
|
-
}
|
|
1342
|
-
});
|
|
1343
|
-
|
|
1344
|
-
// handle nested routers and absolute paths
|
|
1345
|
-
var href = router.hrefs(_href[0] === "~" ? _href.slice(1) : router.base + _href, router // pass router as a second argument for convinience
|
|
1346
|
-
);
|
|
1347
|
-
return asChild && React.isValidElement(children) ? React.cloneElement(children, {
|
|
1348
|
-
onClick: onClick,
|
|
1349
|
-
href: href
|
|
1350
|
-
}) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
1351
|
-
onClick: onClick,
|
|
1352
|
-
href: href,
|
|
1353
|
-
// `className` can be a function to apply the class if this link is active
|
|
1354
|
-
className: cls !== null && cls !== void 0 && cls.call ? cls(path === href) : cls,
|
|
1355
|
-
children: children,
|
|
1356
|
-
ref: ref
|
|
1357
|
-
}));
|
|
1358
|
-
});
|
|
1359
|
-
|
|
1360
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1361
|
-
var RoutesContext = /*#__PURE__*/React.createContext(null);
|
|
1362
|
-
var useRoutesContext = function useRoutesContext() {
|
|
1363
|
-
return React.useContext(RoutesContext);
|
|
1364
|
-
};
|
|
1365
|
-
var propTypes$1 = {
|
|
1366
|
-
children: PropTypes.node.isRequired,
|
|
1367
|
-
routes: PropTypes.objectOf(PropTypes.string).isRequired,
|
|
1368
|
-
basePath: PropTypes.string
|
|
1369
|
-
};
|
|
1370
|
-
var defaultProps$1 = {
|
|
1371
|
-
basePath: null
|
|
1372
|
-
};
|
|
1373
|
-
function RoutesProvider(_ref) {
|
|
1374
|
-
var routes = _ref.routes,
|
|
1375
|
-
basePath = _ref.basePath,
|
|
1376
|
-
children = _ref.children;
|
|
1377
|
-
var value = React.useMemo(function () {
|
|
1378
|
-
return {
|
|
1379
|
-
routes: routes,
|
|
1380
|
-
basePath: basePath
|
|
1381
|
-
};
|
|
1382
|
-
}, [routes, basePath]);
|
|
1383
|
-
return /*#__PURE__*/jsxRuntime.jsx(RoutesContext.Provider, {
|
|
1384
|
-
value: value,
|
|
1385
|
-
children: children
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
|
-
RoutesProvider.propTypes = propTypes$1;
|
|
1389
|
-
RoutesProvider.defaultProps = defaultProps$1;
|
|
1390
|
-
var compilers = {};
|
|
1391
|
-
function generatePath(fullPath, data) {
|
|
1392
|
-
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1393
|
-
var fullUrlMatches = fullPath.match(/^(https?:\/\/[^/]+)\//);
|
|
1394
|
-
if (typeof compilers[fullPath] === 'undefined') {
|
|
1395
|
-
compilers[fullPath] = pathToRegexp.compile(fullPath.replace(/^(https?:\/\/[^/]+)\//, '/'), opts);
|
|
1396
|
-
}
|
|
1397
|
-
var compiler = compilers[fullPath];
|
|
1398
|
-
return fullUrlMatches !== null ? "".concat(fullUrlMatches[1].substr(0, -1)).concat(compiler(data)) : compiler(data);
|
|
1399
|
-
}
|
|
1400
|
-
var useUrlGeneratorPathToRepexp = function useUrlGeneratorPathToRepexp() {
|
|
1401
|
-
var _ref2 = useRoutesContext() || {},
|
|
1402
|
-
_ref2$routes = _ref2.routes,
|
|
1403
|
-
routes = _ref2$routes === void 0 ? null : _ref2$routes,
|
|
1404
|
-
_ref2$basePath = _ref2.basePath,
|
|
1405
|
-
basePath = _ref2$basePath === void 0 ? null : _ref2$basePath;
|
|
1406
|
-
var urlGenerator = React.useCallback(function (key, data, opts) {
|
|
1407
|
-
var path = routes !== null ? routes[key] || null : null;
|
|
1408
|
-
if (path === null) {
|
|
1409
|
-
return null;
|
|
1410
|
-
}
|
|
1411
|
-
var url = generatePath(path, data, opts);
|
|
1412
|
-
return basePath !== null ? "".concat(basePath.replace(/\/$/, ''), "/").concat(url.replace(/^\//, '')) : url;
|
|
1413
|
-
}, [routes, basePath]);
|
|
1414
|
-
return urlGenerator;
|
|
1415
|
-
};
|
|
1416
|
-
var useUrlGeneratorPathToRegexp = useUrlGeneratorPathToRepexp;
|
|
1417
|
-
var useRoutes = function useRoutes() {
|
|
1418
|
-
var _useRoutesContext = useRoutesContext(),
|
|
1419
|
-
routes = _useRoutesContext.routes;
|
|
1420
|
-
return routes;
|
|
1421
|
-
};
|
|
1422
|
-
var useRoutes$1 = useRoutes;
|
|
1423
|
-
|
|
1424
|
-
var useRoutePush = function useRoutePush() {
|
|
1425
|
-
var url = useUrlGeneratorPathToRegexp();
|
|
1426
|
-
var _useLocation = useLocation(),
|
|
1427
|
-
_useLocation2 = _slicedToArray(_useLocation, 2),
|
|
1428
|
-
navigate = _useLocation2[1];
|
|
1429
|
-
var push = React.useCallback(function (route, data) {
|
|
1430
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1431
|
-
args[_key - 2] = arguments[_key];
|
|
1432
|
-
}
|
|
1433
|
-
if (isString(route)) {
|
|
1434
|
-
navigate.apply(void 0, [url(route, data)].concat(args));
|
|
1435
|
-
} else {
|
|
1436
|
-
var _ref = route || {},
|
|
1437
|
-
_ref$pathname = _ref.pathname,
|
|
1438
|
-
pathname = _ref$pathname === void 0 ? null : _ref$pathname,
|
|
1439
|
-
_ref$search = _ref.search,
|
|
1440
|
-
search = _ref$search === void 0 ? null : _ref$search;
|
|
1441
|
-
navigate.apply(void 0, ["".concat(url(pathname, data)).concat(search !== null ? "?".concat(search) : '')].concat(args));
|
|
1442
|
-
}
|
|
1443
|
-
}, [navigate, url]);
|
|
1444
|
-
return push;
|
|
1445
|
-
};
|
|
1446
|
-
var useRouteBack = function useRouteBack() {
|
|
1447
|
-
var url = useUrlGeneratorPathToRegexp();
|
|
1448
|
-
var _useLocation3 = useLocation(),
|
|
1449
|
-
_useLocation4 = _slicedToArray(_useLocation3, 2),
|
|
1450
|
-
navigate = _useLocation4[1];
|
|
1451
|
-
var back = React.useCallback(function () {
|
|
1452
|
-
return navigate(-1);
|
|
1453
|
-
}, [navigate, url]);
|
|
1454
|
-
return back;
|
|
1455
|
-
};
|
|
1456
|
-
|
|
1457
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1458
|
-
var useTracking = function useTracking() {
|
|
1459
|
-
return React.useContext(tracking.TrackingContext);
|
|
1460
|
-
};
|
|
1461
|
-
var propTypes = {
|
|
1462
|
-
children: PropTypes.node.isRequired,
|
|
1463
|
-
variables: core.PropTypes.trackingVariables
|
|
1464
|
-
};
|
|
1465
|
-
var defaultProps = {
|
|
1466
|
-
variables: null
|
|
1467
|
-
};
|
|
1468
|
-
var TrackingProvider = function TrackingProvider(_ref) {
|
|
1469
|
-
var variables = _ref.variables,
|
|
1470
|
-
children = _ref.children;
|
|
1471
|
-
var contextTracking = useTracking() || null;
|
|
1472
|
-
var tracking$1 = React.useMemo(function () {
|
|
1473
|
-
if (contextTracking !== null) {
|
|
1474
|
-
contextTracking.setVariables(variables);
|
|
1475
|
-
return contextTracking;
|
|
1476
|
-
}
|
|
1477
|
-
return new core.Tracking({
|
|
1478
|
-
variables: variables
|
|
1479
|
-
});
|
|
1480
|
-
}, [contextTracking, variables]);
|
|
1481
|
-
return /*#__PURE__*/React.createElement(tracking.TrackingContainer, {
|
|
1482
|
-
tracking: tracking$1
|
|
1483
|
-
}, children);
|
|
1484
|
-
};
|
|
1485
|
-
TrackingProvider.propTypes = propTypes;
|
|
1486
|
-
TrackingProvider.defaultProps = defaultProps;
|
|
1487
|
-
|
|
1488
|
-
Object.defineProperty(exports, "TrackingContext", {
|
|
1489
|
-
enumerable: true,
|
|
1490
|
-
get: function () { return tracking.TrackingContext; }
|
|
1491
|
-
});
|
|
1492
|
-
exports.ACTIONS_NAMESPACE = ACTIONS_NAMESPACE;
|
|
1493
|
-
exports.APP_NAMESPACE = APP_NAMESPACE;
|
|
1494
|
-
exports.BUTTONS_NAMESPACE = BUTTONS_NAMESPACE;
|
|
1495
|
-
exports.ComponentsContext = ComponentsContext;
|
|
1496
|
-
exports.ComponentsProvider = ComponentsProvider;
|
|
1497
|
-
exports.DISPLAYS_NAMESPACE = DISPLAYS_NAMESPACE;
|
|
1498
|
-
exports.DefinitionProvider = DefinitionProvider;
|
|
1499
|
-
exports.FIELDS_NAMESPACE = FIELDS_NAMESPACE;
|
|
1500
|
-
exports.FILTERS_NAMESPACE = FILTERS_NAMESPACE;
|
|
1501
|
-
exports.FORMS_NAMESPACE = FORMS_NAMESPACE;
|
|
1502
|
-
exports.FieldsContext = FieldsContext;
|
|
1503
|
-
exports.FieldsProvider = FieldsProvider;
|
|
1504
|
-
exports.FontsContext = FontsContext;
|
|
1505
|
-
exports.FontsProvider = FontsProvider;
|
|
1506
|
-
exports.FormProvider = FormProvider;
|
|
1507
|
-
exports.GoogleApiClientContext = GoogleApiClientContext;
|
|
1508
|
-
exports.GoogleApiClientProvider = GoogleApiClientProvider;
|
|
1509
|
-
exports.GoogleKeysContext = GoogleKeysContext;
|
|
1510
|
-
exports.GoogleKeysProvider = GoogleKeysProvider;
|
|
1511
|
-
exports.GoogleMapsClientContext = GoogleMapsClientContext;
|
|
1512
|
-
exports.GoogleMapsClientProvider = GoogleMapsClientProvider;
|
|
1513
|
-
exports.LISTS_NAMESPACE = LISTS_NAMESPACE;
|
|
1514
|
-
exports.LocalesContext = LocalesContext;
|
|
1515
|
-
exports.LocalesProvider = LocalesProvider;
|
|
1516
|
-
exports.MODALS_NAMESPACE = MODALS_NAMESPACE;
|
|
1517
|
-
exports.ModalContext = ModalContext;
|
|
1518
|
-
exports.ModalProvider = ModalProvider;
|
|
1519
|
-
exports.PAGES_NAMESPACE = PAGES_NAMESPACE;
|
|
1520
|
-
exports.PanelsContext = PanelsContext;
|
|
1521
|
-
exports.PanelsProvider = PanelsProvider;
|
|
1522
|
-
exports.PanneauProvider = PanneauProvider;
|
|
1523
|
-
exports.ResourceProvider = ResourceProvider;
|
|
1524
|
-
exports.RoutesContext = RoutesContext;
|
|
1525
|
-
exports.RoutesProvider = RoutesProvider;
|
|
1526
|
-
exports.TrackingProvider = TrackingProvider;
|
|
1527
|
-
exports.useActionComponent = useActionComponent;
|
|
1528
|
-
exports.useActionsComponents = useActionsComponents;
|
|
1529
|
-
exports.useActionsComponentsManager = useActionsComponentsManager;
|
|
1530
|
-
exports.useAppComponent = useAppComponent;
|
|
1531
|
-
exports.useAppComponents = useAppComponents;
|
|
1532
|
-
exports.useAppComponentsManager = useAppComponentsManager;
|
|
1533
|
-
exports.useButtonComponent = useButtonComponent;
|
|
1534
|
-
exports.useButtonsComponents = useButtonsComponents;
|
|
1535
|
-
exports.useButtonsComponentsManager = useButtonsComponentsManager;
|
|
1536
|
-
exports.useComponent = useComponent;
|
|
1537
|
-
exports.useComponents = useComponents;
|
|
1538
|
-
exports.useComponentsManager = useComponentsManager;
|
|
1539
|
-
exports.useDefinition = useDefinition;
|
|
1540
|
-
exports.useDefinitionContext = useDefinitionContext;
|
|
1541
|
-
exports.useDisplayComponent = useDisplayComponent;
|
|
1542
|
-
exports.useDisplaysComponents = useDisplaysComponents;
|
|
1543
|
-
exports.useDisplaysComponentsManager = useDisplaysComponentsManager;
|
|
1544
|
-
exports.useField = useField;
|
|
1545
|
-
exports.useFieldComponent = useFieldComponent;
|
|
1546
|
-
exports.useFields = useFields;
|
|
1547
|
-
exports.useFieldsComponents = useFieldsComponents;
|
|
1548
|
-
exports.useFieldsComponentsManager = useFieldsComponentsManager;
|
|
1549
|
-
exports.useFieldsManager = useFieldsManager;
|
|
1550
|
-
exports.useFilterComponent = useFilterComponent;
|
|
1551
|
-
exports.useFiltersComponents = useFiltersComponents;
|
|
1552
|
-
exports.useFiltersComponentsManager = useFiltersComponentsManager;
|
|
1553
|
-
exports.useFonts = useFonts;
|
|
1554
|
-
exports.useForm = useForm;
|
|
1555
|
-
exports.useFormComponent = useFormComponent;
|
|
1556
|
-
exports.useFormSetValue = useFormSetValue;
|
|
1557
|
-
exports.useFormValue = useFormValue;
|
|
1558
|
-
exports.useFormsComponents = useFormsComponents;
|
|
1559
|
-
exports.useFormsComponentsManager = useFormsComponentsManager;
|
|
1560
|
-
exports.useGoogleApiClient = useGoogleApiClient;
|
|
1561
|
-
exports.useGoogleFonts = useGoogleFonts;
|
|
1562
|
-
exports.useGoogleKeys = useGoogleKeys;
|
|
1563
|
-
exports.useGoogleMapsClient = useGoogleMapsClient;
|
|
1564
|
-
exports.useListComponent = useListComponent;
|
|
1565
|
-
exports.useListsComponents = useListsComponents;
|
|
1566
|
-
exports.useListsComponentsManager = useListsComponentsManager;
|
|
1567
|
-
exports.useLocales = useLocales;
|
|
1568
|
-
exports.useModal = useModal;
|
|
1569
|
-
exports.useModalComponent = useModalComponent;
|
|
1570
|
-
exports.useModalsComponents = useModalsComponents;
|
|
1571
|
-
exports.useModalsComponentsManager = useModalsComponentsManager;
|
|
1572
|
-
exports.useOtherLocales = useOtherLocales;
|
|
1573
|
-
exports.usePageComponent = usePageComponent;
|
|
1574
|
-
exports.usePagesComponents = usePagesComponents;
|
|
1575
|
-
exports.usePagesComponentsManager = usePagesComponentsManager;
|
|
1576
|
-
exports.usePanels = usePanels;
|
|
1577
|
-
exports.usePanneau = usePanneau;
|
|
1578
|
-
exports.usePanneauAuth = usePanneauAuth;
|
|
1579
|
-
exports.usePanneauColorScheme = usePanneauColorScheme;
|
|
1580
|
-
exports.usePanneauComponent = usePanneauComponent;
|
|
1581
|
-
exports.usePanneauComponents = usePanneauComponents;
|
|
1582
|
-
exports.usePanneauResource = usePanneauResource;
|
|
1583
|
-
exports.usePanneauResources = usePanneauResources;
|
|
1584
|
-
exports.usePanneauSettings = usePanneauSettings;
|
|
1585
|
-
exports.useResource = useResource;
|
|
1586
|
-
exports.useRouteBack = useRouteBack;
|
|
1587
|
-
exports.useRoutePush = useRoutePush;
|
|
1588
|
-
exports.useRoutes = useRoutes$1;
|
|
1589
|
-
exports.useTracking = useTracking;
|
|
1590
|
-
exports.useUrlGenerator = useUrlGeneratorPathToRegexp;
|
|
1591
|
-
exports.withGoogleApiClient = withGoogleApiClient;
|
|
1592
|
-
exports.withGoogleMapsClient = withGoogleMapsClient;
|
|
1593
|
-
exports.withPanels = withPanels;
|