@panneau/core 3.0.140 → 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 +11 -17
- package/package.json +8 -8
- package/es/contexts.js +0 -1143
- package/es/hooks.js +0 -1224
- package/es/utils.js +0 -488
- package/lib/contexts.js +0 -1584
- package/lib/hooks.js +0 -1245
- package/lib/index.js +0 -985
- package/lib/utils.js +0 -604
package/es/contexts.js
DELETED
|
@@ -1,1143 +0,0 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import isString from 'lodash/isString';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import React, { useContext, useMemo, useState, useEffect, useRef, useCallback } from 'react';
|
|
5
|
-
import { ComponentsManager, PropTypes as PropTypes$1, FieldsManager, Tracking } from '@panneau/core';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
7
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
8
|
-
import uniqBy from 'lodash/uniqBy';
|
|
9
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
10
|
-
import { getJSON } from '@folklore/fetch';
|
|
11
|
-
import isObject from 'lodash/isObject';
|
|
12
|
-
import { loadGoogleApi, loadGoogleMaps } from '@folklore/services';
|
|
13
|
-
import { useIntl } from 'react-intl';
|
|
14
|
-
import { getDisplayName } from '@panneau/core/utils';
|
|
15
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
16
|
-
import { useUrlGenerator } from '@folklore/routes';
|
|
17
|
-
export { RoutesContext, RoutesProvider, useRoutes, useUrlGenerator } from '@folklore/routes';
|
|
18
|
-
import { useLocation } from 'wouter';
|
|
19
|
-
import { TrackingContext, TrackingContainer } from '@folklore/tracking';
|
|
20
|
-
export { TrackingContext } from '@folklore/tracking';
|
|
21
|
-
|
|
22
|
-
var MODALS_NAMESPACE = 'modals';
|
|
23
|
-
var FIELDS_NAMESPACE = 'fields';
|
|
24
|
-
var FORMS_NAMESPACE = 'forms';
|
|
25
|
-
var FILTERS_NAMESPACE = 'filters';
|
|
26
|
-
var LISTS_NAMESPACE = 'lists';
|
|
27
|
-
var DISPLAYS_NAMESPACE = 'displays';
|
|
28
|
-
var ACTIONS_NAMESPACE = 'actions';
|
|
29
|
-
var BUTTONS_NAMESPACE = 'buttons';
|
|
30
|
-
var PAGES_NAMESPACE = 'pages';
|
|
31
|
-
var APP_NAMESPACE = 'app';
|
|
32
|
-
var ComponentsContext = /*#__PURE__*/React.createContext(null);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Hooks
|
|
36
|
-
*/
|
|
37
|
-
var useComponentsManager = function useComponentsManager() {
|
|
38
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
39
|
-
var manager = useContext(ComponentsContext);
|
|
40
|
-
var finalManager = useMemo(function () {
|
|
41
|
-
return namespace !== null ? new ComponentsManager(manager.getComponents(namespace)) : manager;
|
|
42
|
-
}, [manager, namespace]);
|
|
43
|
-
return finalManager;
|
|
44
|
-
};
|
|
45
|
-
var useComponents = function useComponents() {
|
|
46
|
-
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
47
|
-
var defaultComponents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
48
|
-
var manager = useComponentsManager();
|
|
49
|
-
return manager.getComponents(namespace) || defaultComponents;
|
|
50
|
-
};
|
|
51
|
-
var useComponent = function useComponent(name) {
|
|
52
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
53
|
-
var namespace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
54
|
-
var manager = useComponentsManager(namespace);
|
|
55
|
-
return useMemo(function () {
|
|
56
|
-
if (!isString(name)) {
|
|
57
|
-
return name || defaultComponent;
|
|
58
|
-
}
|
|
59
|
-
return manager.getComponent(name) || defaultComponent;
|
|
60
|
-
}, [manager, name, defaultComponent]);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Fields hooks
|
|
65
|
-
*/
|
|
66
|
-
var useFieldsComponentsManager = function useFieldsComponentsManager() {
|
|
67
|
-
return useComponentsManager(FIELDS_NAMESPACE);
|
|
68
|
-
};
|
|
69
|
-
var useFieldsComponents = function useFieldsComponents() {
|
|
70
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
71
|
-
return useComponents(FIELDS_NAMESPACE, defaultComponents);
|
|
72
|
-
};
|
|
73
|
-
var useFieldComponent = function useFieldComponent(name) {
|
|
74
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
75
|
-
return useComponent(name, defaultComponent, FIELDS_NAMESPACE);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Forms hooks
|
|
80
|
-
*/
|
|
81
|
-
var useFormsComponentsManager = function useFormsComponentsManager() {
|
|
82
|
-
return useComponentsManager(FORMS_NAMESPACE);
|
|
83
|
-
};
|
|
84
|
-
var useFormsComponents = function useFormsComponents() {
|
|
85
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
86
|
-
return useComponents(FORMS_NAMESPACE, defaultComponents);
|
|
87
|
-
};
|
|
88
|
-
var useFormComponent = function useFormComponent(name) {
|
|
89
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
90
|
-
return useComponent(name, defaultComponent, FORMS_NAMESPACE);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Modals hooks
|
|
95
|
-
*/
|
|
96
|
-
var useModalsComponentsManager = function useModalsComponentsManager() {
|
|
97
|
-
return useComponentsManager(MODALS_NAMESPACE);
|
|
98
|
-
};
|
|
99
|
-
var useModalsComponents = function useModalsComponents() {
|
|
100
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
101
|
-
return useComponents(MODALS_NAMESPACE, defaultComponents);
|
|
102
|
-
};
|
|
103
|
-
var useModalComponent = function useModalComponent(name) {
|
|
104
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
105
|
-
return useComponent(name, defaultComponent, MODALS_NAMESPACE);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Filters hooks
|
|
110
|
-
*/
|
|
111
|
-
var useFiltersComponentsManager = function useFiltersComponentsManager() {
|
|
112
|
-
return useComponentsManager(FILTERS_NAMESPACE);
|
|
113
|
-
};
|
|
114
|
-
var useFiltersComponents = function useFiltersComponents() {
|
|
115
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
116
|
-
return useComponents(FILTERS_NAMESPACE, defaultComponents);
|
|
117
|
-
};
|
|
118
|
-
var useFilterComponent = function useFilterComponent(name) {
|
|
119
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
120
|
-
return useComponent(name, defaultComponent, FILTERS_NAMESPACE);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Lists hooks
|
|
125
|
-
*/
|
|
126
|
-
var useListsComponentsManager = function useListsComponentsManager() {
|
|
127
|
-
return useComponentsManager(LISTS_NAMESPACE);
|
|
128
|
-
};
|
|
129
|
-
var useListsComponents = function useListsComponents() {
|
|
130
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
131
|
-
return useComponents(LISTS_NAMESPACE, defaultComponents);
|
|
132
|
-
};
|
|
133
|
-
var useListComponent = function useListComponent(name) {
|
|
134
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
135
|
-
return useComponent(name, defaultComponent, LISTS_NAMESPACE);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Displays hooks
|
|
140
|
-
*/
|
|
141
|
-
var useDisplaysComponentsManager = function useDisplaysComponentsManager() {
|
|
142
|
-
return useComponentsManager(DISPLAYS_NAMESPACE);
|
|
143
|
-
};
|
|
144
|
-
var useDisplaysComponents = function useDisplaysComponents() {
|
|
145
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
146
|
-
return useComponents(DISPLAYS_NAMESPACE, defaultComponents);
|
|
147
|
-
};
|
|
148
|
-
var useDisplayComponent = function useDisplayComponent(name) {
|
|
149
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
150
|
-
return useComponent(name, defaultComponent, DISPLAYS_NAMESPACE);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Actions hooks
|
|
155
|
-
*/
|
|
156
|
-
var useActionsComponentsManager = function useActionsComponentsManager() {
|
|
157
|
-
return useComponentsManager(ACTIONS_NAMESPACE);
|
|
158
|
-
};
|
|
159
|
-
var useActionsComponents = function useActionsComponents() {
|
|
160
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
161
|
-
return useComponents(ACTIONS_NAMESPACE, defaultComponents);
|
|
162
|
-
};
|
|
163
|
-
var useActionComponent = function useActionComponent(name) {
|
|
164
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
165
|
-
return useComponent(name, defaultComponent, ACTIONS_NAMESPACE);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Buttons hooks
|
|
170
|
-
*/
|
|
171
|
-
var useButtonsComponentsManager = function useButtonsComponentsManager() {
|
|
172
|
-
return useComponentsManager(BUTTONS_NAMESPACE);
|
|
173
|
-
};
|
|
174
|
-
var useButtonsComponents = function useButtonsComponents() {
|
|
175
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
176
|
-
return useComponents(BUTTONS_NAMESPACE, defaultComponents);
|
|
177
|
-
};
|
|
178
|
-
var useButtonComponent = function useButtonComponent(name) {
|
|
179
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
180
|
-
return useComponent(name, defaultComponent, BUTTONS_NAMESPACE);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Pages hooks
|
|
185
|
-
*/
|
|
186
|
-
var usePagesComponentsManager = function usePagesComponentsManager() {
|
|
187
|
-
return useComponentsManager(PAGES_NAMESPACE);
|
|
188
|
-
};
|
|
189
|
-
var usePagesComponents = function usePagesComponents() {
|
|
190
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
191
|
-
return useComponents(PAGES_NAMESPACE, defaultComponents);
|
|
192
|
-
};
|
|
193
|
-
var usePageComponent = function usePageComponent(name) {
|
|
194
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
195
|
-
return useComponent(name, defaultComponent, PAGES_NAMESPACE);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* App hooks
|
|
200
|
-
*/
|
|
201
|
-
var useAppComponentsManager = function useAppComponentsManager() {
|
|
202
|
-
return useComponentsManager(APP_NAMESPACE);
|
|
203
|
-
};
|
|
204
|
-
var useAppComponents = function useAppComponents() {
|
|
205
|
-
var defaultComponents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
206
|
-
return useComponents(APP_NAMESPACE, defaultComponents);
|
|
207
|
-
};
|
|
208
|
-
var useAppComponent = function useAppComponent(name) {
|
|
209
|
-
var defaultComponent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
210
|
-
return useComponent(name, defaultComponent, APP_NAMESPACE);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Provider
|
|
215
|
-
*/
|
|
216
|
-
var propTypes$d = {
|
|
217
|
-
children: PropTypes.node.isRequired,
|
|
218
|
-
namespace: PropTypes.string,
|
|
219
|
-
manager: PropTypes.instanceOf(ComponentsManager),
|
|
220
|
-
components: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.object, PropTypes.func]))
|
|
221
|
-
};
|
|
222
|
-
var defaultProps$d = {
|
|
223
|
-
namespace: null,
|
|
224
|
-
components: {},
|
|
225
|
-
manager: null
|
|
226
|
-
};
|
|
227
|
-
var ComponentsProvider = function ComponentsProvider(_ref) {
|
|
228
|
-
var components = _ref.components,
|
|
229
|
-
manager = _ref.manager,
|
|
230
|
-
namespace = _ref.namespace,
|
|
231
|
-
children = _ref.children;
|
|
232
|
-
var previousManager = useComponentsManager() || null;
|
|
233
|
-
var finalManager = useMemo(function () {
|
|
234
|
-
return new ComponentsManager(_objectSpread(_objectSpread(_objectSpread({}, previousManager !== null ? previousManager.getComponents() : null), manager !== null ? manager.getComponents() : null), new ComponentsManager(components).addNamespace(namespace).getComponents()));
|
|
235
|
-
}, [previousManager, manager, components, namespace]);
|
|
236
|
-
return /*#__PURE__*/React.createElement(ComponentsContext.Provider, {
|
|
237
|
-
value: finalManager
|
|
238
|
-
}, children);
|
|
239
|
-
};
|
|
240
|
-
ComponentsProvider.propTypes = propTypes$d;
|
|
241
|
-
ComponentsProvider.defaultProps = defaultProps$d;
|
|
242
|
-
|
|
243
|
-
var message = PropTypes.shape({
|
|
244
|
-
id: PropTypes.string.isRequired,
|
|
245
|
-
defaultMessage: PropTypes.string
|
|
246
|
-
});
|
|
247
|
-
var label = PropTypes.oneOfType([message, PropTypes.node]);
|
|
248
|
-
PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Core
|
|
252
|
-
*/
|
|
253
|
-
var menuItem = PropTypes.shape({
|
|
254
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
255
|
-
label: label,
|
|
256
|
-
url: PropTypes.string,
|
|
257
|
-
external: PropTypes.bool,
|
|
258
|
-
active: PropTypes.bool
|
|
259
|
-
});
|
|
260
|
-
PropTypes.arrayOf(menuItem);
|
|
261
|
-
var button = PropTypes.shape({
|
|
262
|
-
id: PropTypes.string,
|
|
263
|
-
label: label,
|
|
264
|
-
onClick: PropTypes.func
|
|
265
|
-
});
|
|
266
|
-
PropTypes.arrayOf(button);
|
|
267
|
-
PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', null]);
|
|
268
|
-
PropTypes.oneOf(['lg', 'sm', null]);
|
|
269
|
-
PropTypes.oneOf(['button', 'submit']);
|
|
270
|
-
PropTypes.oneOf(['start', 'end']);
|
|
271
|
-
PropTypes.oneOf(['lg', 'sm', null]);
|
|
272
|
-
PropTypes.oneOf(['loading', 'success', 'error', null]);
|
|
273
|
-
var fieldOption = PropTypes.shape({
|
|
274
|
-
value: PropTypes.string,
|
|
275
|
-
label: PropTypes.string
|
|
276
|
-
});
|
|
277
|
-
PropTypes.arrayOf(fieldOption);
|
|
278
|
-
var toggle = PropTypes.shape({
|
|
279
|
-
key: PropTypes.string,
|
|
280
|
-
label: PropTypes.string
|
|
281
|
-
});
|
|
282
|
-
PropTypes.arrayOf(toggle);
|
|
283
|
-
var tableColumn = PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
284
|
-
id: PropTypes.string,
|
|
285
|
-
component: PropTypes.string,
|
|
286
|
-
path: PropTypes.string,
|
|
287
|
-
field: PropTypes.string,
|
|
288
|
-
columnClassName: PropTypes.string
|
|
289
|
-
})]);
|
|
290
|
-
PropTypes.arrayOf(tableColumn);
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Panneau Definitions
|
|
294
|
-
*/
|
|
295
|
-
var routes = PropTypes.shape({
|
|
296
|
-
'resources.index': PropTypes.string.isRequired,
|
|
297
|
-
'resources.create': PropTypes.string.isRequired,
|
|
298
|
-
'resources.store': PropTypes.string.isRequired,
|
|
299
|
-
'resources.show': PropTypes.string.isRequired,
|
|
300
|
-
'resources.edit': PropTypes.string.isRequired,
|
|
301
|
-
'resources.update': PropTypes.string.isRequired,
|
|
302
|
-
'resources.delete': PropTypes.string.isRequired,
|
|
303
|
-
'resources.destroy': PropTypes.string.isRequired
|
|
304
|
-
});
|
|
305
|
-
var intl = PropTypes.shape({
|
|
306
|
-
locale: PropTypes.string,
|
|
307
|
-
messages: PropTypes.objectOf(PropTypes.string),
|
|
308
|
-
values: PropTypes.objectOf(PropTypes.string)
|
|
309
|
-
});
|
|
310
|
-
var page = PropTypes.shape({
|
|
311
|
-
component: PropTypes.string.isRequired
|
|
312
|
-
});
|
|
313
|
-
var pages = PropTypes.objectOf(page);
|
|
314
|
-
var field = PropTypes.shape({
|
|
315
|
-
name: PropTypes.string,
|
|
316
|
-
// Not required on localized fields
|
|
317
|
-
type: PropTypes.string,
|
|
318
|
-
component: PropTypes.string,
|
|
319
|
-
label: PropTypes.node
|
|
320
|
-
});
|
|
321
|
-
var fields = PropTypes.arrayOf(field);
|
|
322
|
-
var form = PropTypes.shape({
|
|
323
|
-
// type: PropTypes.string.isRequired,
|
|
324
|
-
title: PropTypes.isRequired,
|
|
325
|
-
fields: fields
|
|
326
|
-
});
|
|
327
|
-
PropTypes.arrayOf(form);
|
|
328
|
-
var resource = PropTypes.shape({
|
|
329
|
-
id: PropTypes.string.isRequired,
|
|
330
|
-
name: PropTypes.string.isRequired,
|
|
331
|
-
intl: intl,
|
|
332
|
-
fields: fields,
|
|
333
|
-
forms: PropTypes.shape({}),
|
|
334
|
-
shows_in_navbar: PropTypes.bool
|
|
335
|
-
});
|
|
336
|
-
var resources = PropTypes.arrayOf(resource);
|
|
337
|
-
var panneauDefinition = PropTypes.shape({
|
|
338
|
-
name: PropTypes.string,
|
|
339
|
-
resources: resources,
|
|
340
|
-
routes: routes,
|
|
341
|
-
pages: pages,
|
|
342
|
-
intl: intl
|
|
343
|
-
// intl,
|
|
344
|
-
});
|
|
345
|
-
var definition = PropTypes.shape({
|
|
346
|
-
name: PropTypes.string
|
|
347
|
-
// resources,
|
|
348
|
-
// routes,
|
|
349
|
-
// intl,
|
|
350
|
-
});
|
|
351
|
-
var item = PropTypes.shape({
|
|
352
|
-
id: PropTypes.string.isRequired
|
|
353
|
-
});
|
|
354
|
-
PropTypes.arrayOf(item);
|
|
355
|
-
var user = PropTypes.shape({
|
|
356
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
357
|
-
});
|
|
358
|
-
PropTypes.arrayOf(user);
|
|
359
|
-
var selectOption = PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.shape({
|
|
360
|
-
value: PropTypes.any,
|
|
361
|
-
// eslint-disable-line
|
|
362
|
-
label: label
|
|
363
|
-
}), PropTypes.object]);
|
|
364
|
-
PropTypes.arrayOf(selectOption);
|
|
365
|
-
PropTypes.oneOf(['valid', 'invalid', 'loading', null]);
|
|
366
|
-
var formError = PropTypes.shape({
|
|
367
|
-
message: PropTypes.string
|
|
368
|
-
});
|
|
369
|
-
PropTypes.arrayOf(formError);
|
|
370
|
-
PropTypes.shape({
|
|
371
|
-
tus: PropTypes.object
|
|
372
|
-
}); // eslint-disable-line
|
|
373
|
-
|
|
374
|
-
PropTypes.string;
|
|
375
|
-
var breadcrumb = PropTypes.shape({
|
|
376
|
-
url: PropTypes.string
|
|
377
|
-
});
|
|
378
|
-
PropTypes.arrayOf(breadcrumb);
|
|
379
|
-
var font = PropTypes.shape({
|
|
380
|
-
// url: PropTypes.string,
|
|
381
|
-
});
|
|
382
|
-
PropTypes.arrayOf(font);
|
|
383
|
-
PropTypes.shape({});
|
|
384
|
-
var modal = PropTypes.shape({
|
|
385
|
-
name: PropTypes.string
|
|
386
|
-
});
|
|
387
|
-
PropTypes.arrayOf(modal);
|
|
388
|
-
var filter = PropTypes.shape({
|
|
389
|
-
id: PropTypes.string,
|
|
390
|
-
component: PropTypes.string
|
|
391
|
-
});
|
|
392
|
-
PropTypes.arrayOf(filter);
|
|
393
|
-
var media = PropTypes.shape({
|
|
394
|
-
id: PropTypes.string.isRequired,
|
|
395
|
-
name: PropTypes.string.isRequired,
|
|
396
|
-
type: PropTypes.string.isRequired,
|
|
397
|
-
thumbnail_url: PropTypes.string
|
|
398
|
-
});
|
|
399
|
-
PropTypes.arrayOf(media);
|
|
400
|
-
|
|
401
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
402
|
-
var DefinitionContext = /*#__PURE__*/React.createContext(null);
|
|
403
|
-
var useDefinitionContext = function useDefinitionContext() {
|
|
404
|
-
return useContext(DefinitionContext);
|
|
405
|
-
};
|
|
406
|
-
var useDefinition = function useDefinition() {
|
|
407
|
-
var _useDefinitionContext = useDefinitionContext(),
|
|
408
|
-
_useDefinitionContext2 = _useDefinitionContext.definition,
|
|
409
|
-
definition = _useDefinitionContext2 === void 0 ? null : _useDefinitionContext2;
|
|
410
|
-
return definition;
|
|
411
|
-
};
|
|
412
|
-
var propTypes$c = {
|
|
413
|
-
definition: definition.isRequired,
|
|
414
|
-
children: PropTypes.node.isRequired
|
|
415
|
-
};
|
|
416
|
-
var defaultProps$c = {};
|
|
417
|
-
var DefinitionProvider = function DefinitionProvider(_ref) {
|
|
418
|
-
var definition = _ref.definition,
|
|
419
|
-
children = _ref.children;
|
|
420
|
-
return /*#__PURE__*/React.createElement(DefinitionContext.Provider, {
|
|
421
|
-
value: definition
|
|
422
|
-
}, children);
|
|
423
|
-
};
|
|
424
|
-
DefinitionProvider.propTypes = propTypes$c;
|
|
425
|
-
DefinitionProvider.defaultProps = defaultProps$c;
|
|
426
|
-
|
|
427
|
-
var FieldsContext = /*#__PURE__*/React.createContext(null);
|
|
428
|
-
var useFieldsManager = function useFieldsManager() {
|
|
429
|
-
return useContext(FieldsContext);
|
|
430
|
-
};
|
|
431
|
-
var useField = function useField(id) {
|
|
432
|
-
var manager = useFieldsManager();
|
|
433
|
-
return manager.getDefinition(id);
|
|
434
|
-
};
|
|
435
|
-
var useFields = function useFields() {
|
|
436
|
-
var manager = useFieldsManager();
|
|
437
|
-
return manager.getDefinitions();
|
|
438
|
-
};
|
|
439
|
-
var propTypes$b = {
|
|
440
|
-
fields: PropTypes$1.fields,
|
|
441
|
-
manager: PropTypes.instanceOf(FieldsManager),
|
|
442
|
-
children: PropTypes.node.isRequired
|
|
443
|
-
};
|
|
444
|
-
var defaultProps$b = {
|
|
445
|
-
fields: null,
|
|
446
|
-
manager: null
|
|
447
|
-
};
|
|
448
|
-
var FieldsProvider = function FieldsProvider(_ref) {
|
|
449
|
-
var fields = _ref.fields,
|
|
450
|
-
manager = _ref.manager,
|
|
451
|
-
children = _ref.children;
|
|
452
|
-
var previousManager = useFieldsManager() || null;
|
|
453
|
-
var finalManager = useMemo(function () {
|
|
454
|
-
var newFields = uniqBy([].concat(_toConsumableArray(fields || []), _toConsumableArray(manager !== null ? manager.getDefinitions() : []), _toConsumableArray(previousManager !== null ? previousManager.getDefinitions() : [])), function (_ref2) {
|
|
455
|
-
var id = _ref2.id;
|
|
456
|
-
return id;
|
|
457
|
-
}).reverse();
|
|
458
|
-
return new FieldsManager(newFields);
|
|
459
|
-
}, [previousManager, manager, fields]);
|
|
460
|
-
var components = useMemo(function () {
|
|
461
|
-
var newComponents = finalManager.getComponents();
|
|
462
|
-
return Object.keys(newComponents).reduce(function (map, id) {
|
|
463
|
-
var component = newComponents[id];
|
|
464
|
-
return isString(component) ? map : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, component));
|
|
465
|
-
}, {});
|
|
466
|
-
}, [finalManager]);
|
|
467
|
-
return /*#__PURE__*/React.createElement(FieldsContext.Provider, {
|
|
468
|
-
value: finalManager
|
|
469
|
-
}, /*#__PURE__*/React.createElement(ComponentsProvider, {
|
|
470
|
-
namespace: FIELDS_NAMESPACE,
|
|
471
|
-
components: components
|
|
472
|
-
}, children));
|
|
473
|
-
};
|
|
474
|
-
FieldsProvider.propTypes = propTypes$b;
|
|
475
|
-
FieldsProvider.defaultProps = defaultProps$b;
|
|
476
|
-
|
|
477
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
478
|
-
var GoogleKeysContext = /*#__PURE__*/React.createContext({
|
|
479
|
-
apiKey: null
|
|
480
|
-
});
|
|
481
|
-
var useGoogleKeys = function useGoogleKeys() {
|
|
482
|
-
return useContext(GoogleKeysContext);
|
|
483
|
-
};
|
|
484
|
-
var propTypes$a = {
|
|
485
|
-
children: PropTypes.node.isRequired,
|
|
486
|
-
apiKey: PropTypes.string // .isRequired,
|
|
487
|
-
};
|
|
488
|
-
var defaultProps$a = {
|
|
489
|
-
apiKey: null
|
|
490
|
-
};
|
|
491
|
-
var GoogleKeysProvider = function GoogleKeysProvider(_ref) {
|
|
492
|
-
var children = _ref.children,
|
|
493
|
-
apiKey = _ref.apiKey;
|
|
494
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
495
|
-
previousApiKey = _useGoogleKeys.apiKey;
|
|
496
|
-
var value = useMemo(function () {
|
|
497
|
-
return {
|
|
498
|
-
apiKey: apiKey || previousApiKey
|
|
499
|
-
};
|
|
500
|
-
}, [previousApiKey, apiKey]);
|
|
501
|
-
return /*#__PURE__*/React.createElement(GoogleKeysContext.Provider, {
|
|
502
|
-
value: value
|
|
503
|
-
}, children);
|
|
504
|
-
};
|
|
505
|
-
GoogleKeysProvider.propTypes = propTypes$a;
|
|
506
|
-
GoogleKeysProvider.defaultProps = defaultProps$a;
|
|
507
|
-
|
|
508
|
-
var FontsContext = /*#__PURE__*/React.createContext({
|
|
509
|
-
systemFonts: null,
|
|
510
|
-
googleFonts: null,
|
|
511
|
-
customFonts: null
|
|
512
|
-
});
|
|
513
|
-
var useGoogleFonts = function useGoogleFonts() {
|
|
514
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
515
|
-
_ref$disabled = _ref.disabled,
|
|
516
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
517
|
-
_ref$setFonts = _ref.setFonts,
|
|
518
|
-
setFonts = _ref$setFonts === void 0 ? null : _ref$setFonts;
|
|
519
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
520
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
521
|
-
var _useState = useState(null),
|
|
522
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
523
|
-
googleFonts = _useState2[0],
|
|
524
|
-
setGoogleFonts = _useState2[1];
|
|
525
|
-
useEffect(function () {
|
|
526
|
-
var canceled = false;
|
|
527
|
-
if (apiKey !== null && !disabled) {
|
|
528
|
-
getJSON("https://www.googleapis.com/webfonts/v1/webfonts?key=".concat(apiKey, "&sort=popularity")).then(function (_ref2) {
|
|
529
|
-
var _ref2$items = _ref2.items,
|
|
530
|
-
items = _ref2$items === void 0 ? [] : _ref2$items;
|
|
531
|
-
if (!canceled) {
|
|
532
|
-
var newFonts = items.map(function (it) {
|
|
533
|
-
return {
|
|
534
|
-
type: 'google',
|
|
535
|
-
name: it.family,
|
|
536
|
-
variants: it.variants
|
|
537
|
-
};
|
|
538
|
-
});
|
|
539
|
-
if (setFonts !== null) {
|
|
540
|
-
setFonts(newFonts);
|
|
541
|
-
} else {
|
|
542
|
-
setGoogleFonts(newFonts);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
return function () {
|
|
548
|
-
canceled = true;
|
|
549
|
-
};
|
|
550
|
-
}, [apiKey, disabled, setFonts, setGoogleFonts]);
|
|
551
|
-
return googleFonts;
|
|
552
|
-
};
|
|
553
|
-
var useFonts = function useFonts() {
|
|
554
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
555
|
-
_ref3$withoutGoogleFo = _ref3.withoutGoogleFonts,
|
|
556
|
-
withoutGoogleFonts = _ref3$withoutGoogleFo === void 0 ? false : _ref3$withoutGoogleFo;
|
|
557
|
-
var _useContext = useContext(FontsContext),
|
|
558
|
-
_useContext$setGoogle = _useContext.setGoogleFonts,
|
|
559
|
-
setGoogleFonts = _useContext$setGoogle === void 0 ? null : _useContext$setGoogle,
|
|
560
|
-
_useContext$systemFon = _useContext.systemFonts,
|
|
561
|
-
systemFonts = _useContext$systemFon === void 0 ? null : _useContext$systemFon,
|
|
562
|
-
_useContext$googleFon = _useContext.googleFonts,
|
|
563
|
-
googleFonts = _useContext$googleFon === void 0 ? null : _useContext$googleFon,
|
|
564
|
-
_useContext$customFon = _useContext.customFonts,
|
|
565
|
-
customFonts = _useContext$customFon === void 0 ? null : _useContext$customFon;
|
|
566
|
-
useGoogleFonts({
|
|
567
|
-
disabled: withoutGoogleFonts || googleFonts !== null && googleFonts.length > 0,
|
|
568
|
-
setFonts: setGoogleFonts
|
|
569
|
-
});
|
|
570
|
-
var fonts = useMemo(function () {
|
|
571
|
-
return {
|
|
572
|
-
systemFonts: systemFonts,
|
|
573
|
-
googleFonts: googleFonts,
|
|
574
|
-
customFonts: customFonts
|
|
575
|
-
};
|
|
576
|
-
}, [systemFonts, googleFonts, customFonts]);
|
|
577
|
-
return fonts;
|
|
578
|
-
};
|
|
579
|
-
var propTypes$9 = {
|
|
580
|
-
children: PropTypes.node.isRequired,
|
|
581
|
-
systemFonts: PropTypes$1.fonts,
|
|
582
|
-
customFonts: PropTypes$1.fonts
|
|
583
|
-
};
|
|
584
|
-
var defaultProps$9 = {
|
|
585
|
-
systemFonts: ['Arial', 'Courier', 'Georgia', 'Times New Roman', 'Verdana'],
|
|
586
|
-
customFonts: null
|
|
587
|
-
};
|
|
588
|
-
var FontsProvider = function FontsProvider(_ref4) {
|
|
589
|
-
var systemFonts = _ref4.systemFonts,
|
|
590
|
-
customFonts = _ref4.customFonts,
|
|
591
|
-
children = _ref4.children;
|
|
592
|
-
var _useFonts = useFonts(),
|
|
593
|
-
_useFonts$systemFonts = _useFonts.systemFonts,
|
|
594
|
-
previousSystemFonts = _useFonts$systemFonts === void 0 ? null : _useFonts$systemFonts,
|
|
595
|
-
_useFonts$googleFonts = _useFonts.googleFonts,
|
|
596
|
-
previousGoogleFonts = _useFonts$googleFonts === void 0 ? null : _useFonts$googleFonts,
|
|
597
|
-
previousCustomFonts = _useFonts.customFonts;
|
|
598
|
-
var _useState3 = useState(null),
|
|
599
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
600
|
-
googleFonts = _useState4[0],
|
|
601
|
-
setGoogleFonts = _useState4[1];
|
|
602
|
-
var fonts = useMemo(function () {
|
|
603
|
-
return {
|
|
604
|
-
systemFonts: uniqBy([].concat(_toConsumableArray(previousSystemFonts || []), _toConsumableArray(systemFonts || [])), function (font) {
|
|
605
|
-
return isObject(font) ? font.name : font;
|
|
606
|
-
}),
|
|
607
|
-
googleFonts: uniqBy([].concat(_toConsumableArray(previousGoogleFonts || []), _toConsumableArray(googleFonts || [])), function (font) {
|
|
608
|
-
return isObject(font) ? font.name : font;
|
|
609
|
-
}),
|
|
610
|
-
customFonts: uniqBy([].concat(_toConsumableArray(previousCustomFonts || []), _toConsumableArray(customFonts || [])), function (font) {
|
|
611
|
-
return isObject(font) ? font.name : font;
|
|
612
|
-
}),
|
|
613
|
-
setGoogleFonts: setGoogleFonts
|
|
614
|
-
};
|
|
615
|
-
}, [previousSystemFonts, previousGoogleFonts, previousCustomFonts, customFonts, systemFonts, googleFonts, setGoogleFonts]);
|
|
616
|
-
return /*#__PURE__*/React.createElement(FontsContext.Provider, {
|
|
617
|
-
value: fonts
|
|
618
|
-
}, children);
|
|
619
|
-
};
|
|
620
|
-
FontsProvider.propTypes = propTypes$9;
|
|
621
|
-
FontsProvider.defaultProps = defaultProps$9;
|
|
622
|
-
|
|
623
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
624
|
-
var FormContext = /*#__PURE__*/React.createContext(null);
|
|
625
|
-
var useForm = function useForm() {
|
|
626
|
-
return useContext(FormContext);
|
|
627
|
-
};
|
|
628
|
-
var useFormValue = function useFormValue() {
|
|
629
|
-
var _useForm = useForm(),
|
|
630
|
-
value = _useForm.value;
|
|
631
|
-
return value;
|
|
632
|
-
};
|
|
633
|
-
var useFormSetValue = function useFormSetValue() {
|
|
634
|
-
var _useForm2 = useForm(),
|
|
635
|
-
setValue = _useForm2.setValue;
|
|
636
|
-
return setValue;
|
|
637
|
-
};
|
|
638
|
-
var propTypes$8 = {
|
|
639
|
-
value: PropTypes.object.isRequired,
|
|
640
|
-
// eslint-disable-line react/forbid-prop-types
|
|
641
|
-
setValue: PropTypes.func.isRequired,
|
|
642
|
-
children: PropTypes.node.isRequired
|
|
643
|
-
};
|
|
644
|
-
var defaultProps$8 = {};
|
|
645
|
-
var FormProvider = function FormProvider(_ref) {
|
|
646
|
-
var value = _ref.value,
|
|
647
|
-
setValue = _ref.setValue,
|
|
648
|
-
children = _ref.children;
|
|
649
|
-
var values = useMemo(function () {
|
|
650
|
-
return {
|
|
651
|
-
value: value,
|
|
652
|
-
setValue: setValue
|
|
653
|
-
};
|
|
654
|
-
}, [value, setValue]);
|
|
655
|
-
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
656
|
-
value: values
|
|
657
|
-
}, children);
|
|
658
|
-
};
|
|
659
|
-
FormProvider.propTypes = propTypes$8;
|
|
660
|
-
FormProvider.defaultProps = defaultProps$8;
|
|
661
|
-
|
|
662
|
-
var GoogleApiClientContext = /*#__PURE__*/React.createContext(null);
|
|
663
|
-
var useGoogleApiClient = function useGoogleApiClient() {
|
|
664
|
-
return useContext(GoogleApiClientContext);
|
|
665
|
-
};
|
|
666
|
-
var withGoogleApiClient = function withGoogleApiClient(WrappedComponent) {
|
|
667
|
-
var getDisplayName = function getDisplayName(_ref) {
|
|
668
|
-
var _ref$displayName = _ref.displayName,
|
|
669
|
-
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
670
|
-
_ref$name = _ref.name,
|
|
671
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
672
|
-
return displayName || name || 'Component';
|
|
673
|
-
};
|
|
674
|
-
var WithGoogleApiClientComponent = function WithGoogleApiClientComponent(props) {
|
|
675
|
-
return /*#__PURE__*/React.createElement(GoogleApiClientContext.Consumer, null, function (client) {
|
|
676
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
677
|
-
googleApiClient: client
|
|
678
|
-
}, props));
|
|
679
|
-
});
|
|
680
|
-
};
|
|
681
|
-
WithGoogleApiClientComponent.displayName = "WithGoogleApiClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
682
|
-
return WithGoogleApiClientComponent;
|
|
683
|
-
};
|
|
684
|
-
var propTypes$7 = {
|
|
685
|
-
children: PropTypes.node.isRequired
|
|
686
|
-
};
|
|
687
|
-
var defaultProps$7 = {};
|
|
688
|
-
var GoogleApiClientProvider = function GoogleApiClientProvider(_ref2) {
|
|
689
|
-
var children = _ref2.children;
|
|
690
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
691
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
692
|
-
var _useState = useState(null),
|
|
693
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
694
|
-
client = _useState2[0],
|
|
695
|
-
setClient = _useState2[1];
|
|
696
|
-
useEffect(function () {
|
|
697
|
-
loadGoogleApi().then(function (gapi) {
|
|
698
|
-
return gapi.client.init({
|
|
699
|
-
apiKey: apiKey
|
|
700
|
-
}).then(function () {
|
|
701
|
-
return gapi;
|
|
702
|
-
});
|
|
703
|
-
}).then(function (gapi) {
|
|
704
|
-
return setClient(gapi);
|
|
705
|
-
});
|
|
706
|
-
}, [apiKey, setClient]);
|
|
707
|
-
return /*#__PURE__*/React.createElement(GoogleApiClientContext.Provider, {
|
|
708
|
-
value: client
|
|
709
|
-
}, children);
|
|
710
|
-
};
|
|
711
|
-
GoogleApiClientProvider.propTypes = propTypes$7;
|
|
712
|
-
GoogleApiClientProvider.defaultProps = defaultProps$7;
|
|
713
|
-
|
|
714
|
-
var GoogleMapsClientContext = /*#__PURE__*/React.createContext(null);
|
|
715
|
-
var useGoogleMapsClient = function useGoogleMapsClient() {
|
|
716
|
-
return useContext(GoogleMapsClientContext);
|
|
717
|
-
};
|
|
718
|
-
var withGoogleMapsClient = function withGoogleMapsClient(WrappedComponent) {
|
|
719
|
-
var getDisplayName = function getDisplayName(_ref) {
|
|
720
|
-
var _ref$displayName = _ref.displayName,
|
|
721
|
-
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
722
|
-
_ref$name = _ref.name,
|
|
723
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
724
|
-
return displayName || name || 'Component';
|
|
725
|
-
};
|
|
726
|
-
var WithGoogleMapsClientComponent = function WithGoogleMapsClientComponent(props) {
|
|
727
|
-
return /*#__PURE__*/React.createElement(GoogleMapsClientContext.Consumer, null, function (client) {
|
|
728
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
729
|
-
googleApiClient: client
|
|
730
|
-
}, props));
|
|
731
|
-
});
|
|
732
|
-
};
|
|
733
|
-
WithGoogleMapsClientComponent.displayName = "WithGoogleMapsClient(".concat(getDisplayName(WrappedComponent), ")");
|
|
734
|
-
return WithGoogleMapsClientComponent;
|
|
735
|
-
};
|
|
736
|
-
var propTypes$6 = {
|
|
737
|
-
children: PropTypes.node.isRequired,
|
|
738
|
-
locale: PropTypes.string,
|
|
739
|
-
libraries: PropTypes.arrayOf(PropTypes.string)
|
|
740
|
-
};
|
|
741
|
-
var defaultProps$6 = {
|
|
742
|
-
locale: 'fr',
|
|
743
|
-
libraries: null
|
|
744
|
-
};
|
|
745
|
-
var GoogleMapsClientProvider = function GoogleMapsClientProvider(_ref2) {
|
|
746
|
-
var children = _ref2.children,
|
|
747
|
-
locale = _ref2.locale,
|
|
748
|
-
libraries = _ref2.libraries;
|
|
749
|
-
var _useGoogleKeys = useGoogleKeys(),
|
|
750
|
-
apiKey = _useGoogleKeys.apiKey;
|
|
751
|
-
var exisitingClient = useGoogleMapsClient();
|
|
752
|
-
var _useState = useState(exisitingClient),
|
|
753
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
754
|
-
client = _useState2[0],
|
|
755
|
-
setClient = _useState2[1];
|
|
756
|
-
useEffect(function () {
|
|
757
|
-
if (exisitingClient === null) {
|
|
758
|
-
loadGoogleMaps({
|
|
759
|
-
apiKey: apiKey,
|
|
760
|
-
locale: locale,
|
|
761
|
-
libraries: libraries
|
|
762
|
-
}).then(function (newClient) {
|
|
763
|
-
setClient(newClient);
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
}, [apiKey, locale, libraries, setClient, exisitingClient]);
|
|
767
|
-
return /*#__PURE__*/React.createElement(GoogleMapsClientContext.Provider, {
|
|
768
|
-
value: client
|
|
769
|
-
}, children);
|
|
770
|
-
};
|
|
771
|
-
GoogleMapsClientProvider.propTypes = propTypes$6;
|
|
772
|
-
GoogleMapsClientProvider.defaultProps = defaultProps$6;
|
|
773
|
-
|
|
774
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
775
|
-
var defaultLocales = ['en', 'fr'];
|
|
776
|
-
var LocalesContext = /*#__PURE__*/React.createContext({
|
|
777
|
-
locales: defaultLocales
|
|
778
|
-
});
|
|
779
|
-
var useLocales = function useLocales() {
|
|
780
|
-
var _useContext = useContext(LocalesContext),
|
|
781
|
-
locales = _useContext.locales;
|
|
782
|
-
return locales;
|
|
783
|
-
};
|
|
784
|
-
var useOtherLocales = function useOtherLocales() {
|
|
785
|
-
var _useLocales = useLocales(),
|
|
786
|
-
locales = _useLocales.locales;
|
|
787
|
-
var _useIntl = useIntl(),
|
|
788
|
-
locale = _useIntl.locale;
|
|
789
|
-
var otherLocales = useMemo(function () {
|
|
790
|
-
return locales.filter(function (it) {
|
|
791
|
-
return it !== locale;
|
|
792
|
-
});
|
|
793
|
-
}, [locales, locale]);
|
|
794
|
-
return otherLocales;
|
|
795
|
-
};
|
|
796
|
-
var propTypes$5 = {
|
|
797
|
-
locales: PropTypes.arrayOf(PropTypes.string),
|
|
798
|
-
children: PropTypes.node.isRequired
|
|
799
|
-
};
|
|
800
|
-
var defaultProps$5 = {
|
|
801
|
-
locales: []
|
|
802
|
-
};
|
|
803
|
-
var LocalesProvider = function LocalesProvider(_ref) {
|
|
804
|
-
var locales = _ref.locales,
|
|
805
|
-
children = _ref.children;
|
|
806
|
-
var value = useMemo(function () {
|
|
807
|
-
return {
|
|
808
|
-
locales: locales
|
|
809
|
-
};
|
|
810
|
-
}, [locales]);
|
|
811
|
-
return /*#__PURE__*/React.createElement(LocalesContext.Provider, {
|
|
812
|
-
value: value
|
|
813
|
-
}, children);
|
|
814
|
-
};
|
|
815
|
-
LocalesProvider.propTypes = propTypes$5;
|
|
816
|
-
LocalesProvider.defaultProps = defaultProps$5;
|
|
817
|
-
|
|
818
|
-
// import { getDisplayName } from '../utils';
|
|
819
|
-
|
|
820
|
-
var ModalContext = /*#__PURE__*/React.createContext(null);
|
|
821
|
-
var useModal = function useModal() {
|
|
822
|
-
return useContext(ModalContext) || {};
|
|
823
|
-
};
|
|
824
|
-
var propTypes$4 = {
|
|
825
|
-
children: PropTypes.node.isRequired,
|
|
826
|
-
container: PropTypes.object // eslint-disable-line
|
|
827
|
-
};
|
|
828
|
-
var defaultProps$4 = {
|
|
829
|
-
container: null
|
|
830
|
-
};
|
|
831
|
-
var ModalProvider = function ModalProvider(_ref) {
|
|
832
|
-
var children = _ref.children,
|
|
833
|
-
initialContainer = _ref.container;
|
|
834
|
-
var _useState = useState(initialContainer),
|
|
835
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
836
|
-
container = _useState2[0],
|
|
837
|
-
setContainer = _useState2[1];
|
|
838
|
-
var _useState3 = useState([]),
|
|
839
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
840
|
-
modals = _useState4[0],
|
|
841
|
-
setModals = _useState4[1];
|
|
842
|
-
var modalsRef = useRef(modals);
|
|
843
|
-
var register = useCallback(function (id) {
|
|
844
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
845
|
-
var currentModals = modalsRef.current;
|
|
846
|
-
var newModals = [].concat(_toConsumableArray(currentModals), [_objectSpread({
|
|
847
|
-
id: id
|
|
848
|
-
}, data)]);
|
|
849
|
-
setModals(newModals);
|
|
850
|
-
modalsRef.current = newModals;
|
|
851
|
-
}, [modals, setModals]);
|
|
852
|
-
var unregister = useCallback(function (id) {
|
|
853
|
-
var currentModals = modalsRef.current;
|
|
854
|
-
var foundIndex = currentModals.findIndex(function (_ref2) {
|
|
855
|
-
var modalId = _ref2.id;
|
|
856
|
-
return modalId === id;
|
|
857
|
-
});
|
|
858
|
-
if (foundIndex !== -1) {
|
|
859
|
-
var newModals = currentModals.filter(function (_ref3) {
|
|
860
|
-
var modalId = _ref3.id;
|
|
861
|
-
return modalId !== id;
|
|
862
|
-
});
|
|
863
|
-
setModals(newModals);
|
|
864
|
-
modalsRef.current = newModals;
|
|
865
|
-
}
|
|
866
|
-
}, [modals, setModals]);
|
|
867
|
-
var value = useMemo(function () {
|
|
868
|
-
return {
|
|
869
|
-
modals: modals,
|
|
870
|
-
container: container,
|
|
871
|
-
setContainer: setContainer,
|
|
872
|
-
register: register,
|
|
873
|
-
unregister: unregister
|
|
874
|
-
};
|
|
875
|
-
}, [modals, container, setContainer, register, unregister]);
|
|
876
|
-
return /*#__PURE__*/React.createElement(ModalContext.Provider, {
|
|
877
|
-
value: value
|
|
878
|
-
}, children);
|
|
879
|
-
};
|
|
880
|
-
ModalProvider.propTypes = propTypes$4;
|
|
881
|
-
ModalProvider.defaultProps = defaultProps$4;
|
|
882
|
-
|
|
883
|
-
var PanelsContext = /*#__PURE__*/React.createContext({
|
|
884
|
-
container: null
|
|
885
|
-
});
|
|
886
|
-
var usePanels = function usePanels() {
|
|
887
|
-
return useContext(PanelsContext) || {};
|
|
888
|
-
};
|
|
889
|
-
var withPanels = function withPanels(WrappedComponent) {
|
|
890
|
-
var WithPanelsComponent = function WithPanelsComponent(props) {
|
|
891
|
-
return /*#__PURE__*/React.createElement(PanelsContext.Consumer, null, function (_ref) {
|
|
892
|
-
var panels = _ref.panels,
|
|
893
|
-
setContainer = _ref.setContainer,
|
|
894
|
-
container = _ref.container,
|
|
895
|
-
register = _ref.register,
|
|
896
|
-
unregister = _ref.unregister;
|
|
897
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({
|
|
898
|
-
panelsContainer: container,
|
|
899
|
-
setPanelsContainer: setContainer,
|
|
900
|
-
panels: panels,
|
|
901
|
-
registerPanel: register,
|
|
902
|
-
unregisterPanel: unregister
|
|
903
|
-
}, props));
|
|
904
|
-
});
|
|
905
|
-
};
|
|
906
|
-
WithPanelsComponent.displayName = "WithPanels(".concat(getDisplayName(WrappedComponent), ")");
|
|
907
|
-
return WithPanelsComponent;
|
|
908
|
-
};
|
|
909
|
-
var propTypes$3 = {
|
|
910
|
-
children: PropTypes.node.isRequired,
|
|
911
|
-
container: PropTypes.object // eslint-disable-line
|
|
912
|
-
};
|
|
913
|
-
var defaultProps$3 = {
|
|
914
|
-
container: null
|
|
915
|
-
};
|
|
916
|
-
var PanelsProvider = function PanelsProvider(_ref2) {
|
|
917
|
-
var children = _ref2.children,
|
|
918
|
-
initialContainer = _ref2.container;
|
|
919
|
-
var _useState = useState(initialContainer),
|
|
920
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
921
|
-
container = _useState2[0],
|
|
922
|
-
setContainer = _useState2[1];
|
|
923
|
-
var _useState3 = useState([]),
|
|
924
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
925
|
-
panels = _useState4[0],
|
|
926
|
-
setPanels = _useState4[1];
|
|
927
|
-
var panelsRef = useRef(panels);
|
|
928
|
-
var register = useCallback(function (id) {
|
|
929
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
930
|
-
var currentPanels = panelsRef.current;
|
|
931
|
-
var newPanels = [].concat(_toConsumableArray(currentPanels), [_objectSpread({
|
|
932
|
-
id: id
|
|
933
|
-
}, data)]);
|
|
934
|
-
setPanels(newPanels);
|
|
935
|
-
panelsRef.current = newPanels;
|
|
936
|
-
}, [panels, setPanels]);
|
|
937
|
-
var unregister = useCallback(function (id) {
|
|
938
|
-
var currentPanels = panelsRef.current;
|
|
939
|
-
var foundIndex = currentPanels.findIndex(function (_ref3) {
|
|
940
|
-
var modalId = _ref3.id;
|
|
941
|
-
return modalId === id;
|
|
942
|
-
});
|
|
943
|
-
if (foundIndex !== -1) {
|
|
944
|
-
var newPanels = currentPanels.filter(function (_ref4) {
|
|
945
|
-
var modalId = _ref4.id;
|
|
946
|
-
return modalId !== id;
|
|
947
|
-
});
|
|
948
|
-
setPanels(newPanels);
|
|
949
|
-
panelsRef.current = newPanels;
|
|
950
|
-
}
|
|
951
|
-
}, [panels, setPanels]);
|
|
952
|
-
var value = useMemo(function () {
|
|
953
|
-
return {
|
|
954
|
-
panels: panels,
|
|
955
|
-
setContainer: setContainer,
|
|
956
|
-
container: container,
|
|
957
|
-
register: register,
|
|
958
|
-
unregister: unregister
|
|
959
|
-
};
|
|
960
|
-
}, [panels, setContainer, container, register, unregister]);
|
|
961
|
-
return /*#__PURE__*/React.createElement(PanelsContext.Provider, {
|
|
962
|
-
value: value
|
|
963
|
-
}, children);
|
|
964
|
-
};
|
|
965
|
-
PanelsProvider.propTypes = propTypes$3;
|
|
966
|
-
PanelsProvider.defaultProps = defaultProps$3;
|
|
967
|
-
|
|
968
|
-
var _excluded = ["component"];
|
|
969
|
-
var PanneauContext = /*#__PURE__*/React.createContext(null);
|
|
970
|
-
var usePanneau = function usePanneau() {
|
|
971
|
-
return useContext(PanneauContext);
|
|
972
|
-
};
|
|
973
|
-
var usePanneauResources = function usePanneauResources() {
|
|
974
|
-
var _ref = usePanneau() || {},
|
|
975
|
-
_ref$resources = _ref.resources,
|
|
976
|
-
resources = _ref$resources === void 0 ? [] : _ref$resources;
|
|
977
|
-
return resources;
|
|
978
|
-
};
|
|
979
|
-
var usePanneauResource = function usePanneauResource(id) {
|
|
980
|
-
var resources = usePanneauResources();
|
|
981
|
-
return resources.find(function (it) {
|
|
982
|
-
return it.id === id;
|
|
983
|
-
}) || null;
|
|
984
|
-
};
|
|
985
|
-
var usePanneauColorScheme = function usePanneauColorScheme() {
|
|
986
|
-
var _ref2 = usePanneau() || {},
|
|
987
|
-
_ref2$theme = _ref2.theme,
|
|
988
|
-
theme = _ref2$theme === void 0 ? {} : _ref2$theme;
|
|
989
|
-
var _ref3 = theme || {},
|
|
990
|
-
_ref3$colorScheme = _ref3.colorScheme,
|
|
991
|
-
colorScheme = _ref3$colorScheme === void 0 ? 'light' : _ref3$colorScheme;
|
|
992
|
-
if (colorScheme === null || colorScheme === 'light' || colorScheme === 'dark') {
|
|
993
|
-
return colorScheme === 'dark' ? {
|
|
994
|
-
theme: 'dark',
|
|
995
|
-
background: 'dark',
|
|
996
|
-
text: 'light'
|
|
997
|
-
} : {
|
|
998
|
-
theme: 'light',
|
|
999
|
-
background: 'light',
|
|
1000
|
-
text: 'dark'
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
return {
|
|
1004
|
-
theme: colorScheme,
|
|
1005
|
-
background: null,
|
|
1006
|
-
text: null
|
|
1007
|
-
};
|
|
1008
|
-
};
|
|
1009
|
-
var usePanneauComponents = function usePanneauComponents() {
|
|
1010
|
-
var _ref4 = usePanneau() || {},
|
|
1011
|
-
_ref4$components = _ref4.components,
|
|
1012
|
-
components = _ref4$components === void 0 ? {} : _ref4$components;
|
|
1013
|
-
return components;
|
|
1014
|
-
};
|
|
1015
|
-
var usePanneauComponent = function usePanneauComponent(namespace, name) {
|
|
1016
|
-
var _ref5 = usePanneau() || {},
|
|
1017
|
-
_ref5$components = _ref5.components,
|
|
1018
|
-
components = _ref5$components === void 0 ? {} : _ref5$components;
|
|
1019
|
-
var path = namespace !== null ? "".concat(namespace, ".").concat(name) : name || null;
|
|
1020
|
-
var component = components[path] || null;
|
|
1021
|
-
if (isString(component)) {
|
|
1022
|
-
return component;
|
|
1023
|
-
}
|
|
1024
|
-
if (isObject(component) && isString(component === null || component === void 0 ? void 0 : component.componnent)) {
|
|
1025
|
-
// eslint-disable-next-line no-unused-vars
|
|
1026
|
-
component.component;
|
|
1027
|
-
_objectWithoutProperties(component, _excluded);
|
|
1028
|
-
return component.component;
|
|
1029
|
-
}
|
|
1030
|
-
return null;
|
|
1031
|
-
};
|
|
1032
|
-
var usePanneauAuth = function usePanneauAuth() {
|
|
1033
|
-
var _ref6 = usePanneau() || {},
|
|
1034
|
-
_ref6$auth = _ref6.auth,
|
|
1035
|
-
auth = _ref6$auth === void 0 ? {} : _ref6$auth;
|
|
1036
|
-
return auth;
|
|
1037
|
-
};
|
|
1038
|
-
var usePanneauSettings = function usePanneauSettings() {
|
|
1039
|
-
var _ref7 = usePanneau() || {},
|
|
1040
|
-
_ref7$settings = _ref7.settings,
|
|
1041
|
-
settings = _ref7$settings === void 0 ? {} : _ref7$settings;
|
|
1042
|
-
return settings;
|
|
1043
|
-
};
|
|
1044
|
-
var propTypes$2 = {
|
|
1045
|
-
definition: panneauDefinition.isRequired,
|
|
1046
|
-
children: PropTypes.node.isRequired
|
|
1047
|
-
};
|
|
1048
|
-
var defaultProps$2 = {};
|
|
1049
|
-
var PanneauProvider = function PanneauProvider(_ref8) {
|
|
1050
|
-
var definition = _ref8.definition,
|
|
1051
|
-
children = _ref8.children;
|
|
1052
|
-
return /*#__PURE__*/React.createElement(PanneauContext.Provider, {
|
|
1053
|
-
value: definition
|
|
1054
|
-
}, children);
|
|
1055
|
-
};
|
|
1056
|
-
PanneauProvider.propTypes = propTypes$2;
|
|
1057
|
-
PanneauProvider.defaultProps = defaultProps$2;
|
|
1058
|
-
|
|
1059
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1060
|
-
var ResourceContext = /*#__PURE__*/React.createContext(null);
|
|
1061
|
-
var useResource = function useResource() {
|
|
1062
|
-
return useContext(ResourceContext);
|
|
1063
|
-
};
|
|
1064
|
-
var propTypes$1 = {
|
|
1065
|
-
resource: resource.isRequired,
|
|
1066
|
-
children: PropTypes.node.isRequired
|
|
1067
|
-
};
|
|
1068
|
-
var defaultProps$1 = {};
|
|
1069
|
-
var ResourceProvider = function ResourceProvider(_ref) {
|
|
1070
|
-
var resource = _ref.resource,
|
|
1071
|
-
children = _ref.children;
|
|
1072
|
-
return /*#__PURE__*/React.createElement(ResourceContext.Provider, {
|
|
1073
|
-
value: resource
|
|
1074
|
-
}, children);
|
|
1075
|
-
};
|
|
1076
|
-
ResourceProvider.propTypes = propTypes$1;
|
|
1077
|
-
ResourceProvider.defaultProps = defaultProps$1;
|
|
1078
|
-
|
|
1079
|
-
var useRoutePush = function useRoutePush() {
|
|
1080
|
-
var url = useUrlGenerator();
|
|
1081
|
-
var _useLocation = useLocation(),
|
|
1082
|
-
_useLocation2 = _slicedToArray(_useLocation, 2),
|
|
1083
|
-
navigate = _useLocation2[1];
|
|
1084
|
-
var push = useCallback(function (route, data) {
|
|
1085
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1086
|
-
args[_key - 2] = arguments[_key];
|
|
1087
|
-
}
|
|
1088
|
-
if (isString(route)) {
|
|
1089
|
-
navigate.apply(void 0, [url(route, data)].concat(args));
|
|
1090
|
-
} else {
|
|
1091
|
-
var _ref = route || {},
|
|
1092
|
-
_ref$pathname = _ref.pathname,
|
|
1093
|
-
pathname = _ref$pathname === void 0 ? null : _ref$pathname,
|
|
1094
|
-
_ref$search = _ref.search,
|
|
1095
|
-
search = _ref$search === void 0 ? null : _ref$search;
|
|
1096
|
-
navigate.apply(void 0, ["".concat(url(pathname, data)).concat(search !== null ? "?".concat(search) : '')].concat(args));
|
|
1097
|
-
}
|
|
1098
|
-
}, [navigate, url]);
|
|
1099
|
-
return push;
|
|
1100
|
-
};
|
|
1101
|
-
var useRouteBack = function useRouteBack() {
|
|
1102
|
-
var url = useUrlGenerator();
|
|
1103
|
-
var _useLocation3 = useLocation(),
|
|
1104
|
-
_useLocation4 = _slicedToArray(_useLocation3, 2),
|
|
1105
|
-
navigate = _useLocation4[1];
|
|
1106
|
-
var back = useCallback(function () {
|
|
1107
|
-
return navigate(-1);
|
|
1108
|
-
}, [navigate, url]);
|
|
1109
|
-
return back;
|
|
1110
|
-
};
|
|
1111
|
-
|
|
1112
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
1113
|
-
var useTracking = function useTracking() {
|
|
1114
|
-
return useContext(TrackingContext);
|
|
1115
|
-
};
|
|
1116
|
-
var propTypes = {
|
|
1117
|
-
children: PropTypes.node.isRequired,
|
|
1118
|
-
variables: PropTypes$1.trackingVariables
|
|
1119
|
-
};
|
|
1120
|
-
var defaultProps = {
|
|
1121
|
-
variables: null
|
|
1122
|
-
};
|
|
1123
|
-
var TrackingProvider = function TrackingProvider(_ref) {
|
|
1124
|
-
var variables = _ref.variables,
|
|
1125
|
-
children = _ref.children;
|
|
1126
|
-
var contextTracking = useTracking() || null;
|
|
1127
|
-
var tracking = useMemo(function () {
|
|
1128
|
-
if (contextTracking !== null) {
|
|
1129
|
-
contextTracking.setVariables(variables);
|
|
1130
|
-
return contextTracking;
|
|
1131
|
-
}
|
|
1132
|
-
return new Tracking({
|
|
1133
|
-
variables: variables
|
|
1134
|
-
});
|
|
1135
|
-
}, [contextTracking, variables]);
|
|
1136
|
-
return /*#__PURE__*/React.createElement(TrackingContainer, {
|
|
1137
|
-
tracking: tracking
|
|
1138
|
-
}, children);
|
|
1139
|
-
};
|
|
1140
|
-
TrackingProvider.propTypes = propTypes;
|
|
1141
|
-
TrackingProvider.defaultProps = defaultProps;
|
|
1142
|
-
|
|
1143
|
-
export { ACTIONS_NAMESPACE, APP_NAMESPACE, BUTTONS_NAMESPACE, ComponentsContext, ComponentsProvider, DISPLAYS_NAMESPACE, DefinitionProvider, FIELDS_NAMESPACE, FILTERS_NAMESPACE, FORMS_NAMESPACE, FieldsContext, FieldsProvider, FontsContext, FontsProvider, FormProvider, GoogleApiClientContext, GoogleApiClientProvider, GoogleKeysContext, GoogleKeysProvider, GoogleMapsClientContext, GoogleMapsClientProvider, LISTS_NAMESPACE, LocalesContext, LocalesProvider, MODALS_NAMESPACE, ModalContext, ModalProvider, PAGES_NAMESPACE, PanelsContext, PanelsProvider, PanneauProvider, ResourceProvider, TrackingProvider, useActionComponent, useActionsComponents, useActionsComponentsManager, useAppComponent, useAppComponents, useAppComponentsManager, useButtonComponent, useButtonsComponents, useButtonsComponentsManager, useComponent, useComponents, useComponentsManager, useDefinition, useDefinitionContext, useDisplayComponent, useDisplaysComponents, useDisplaysComponentsManager, useField, useFieldComponent, useFields, useFieldsComponents, useFieldsComponentsManager, useFieldsManager, useFilterComponent, useFiltersComponents, useFiltersComponentsManager, useFonts, useForm, useFormComponent, useFormSetValue, useFormValue, useFormsComponents, useFormsComponentsManager, useGoogleApiClient, useGoogleFonts, useGoogleKeys, useGoogleMapsClient, useListComponent, useListsComponents, useListsComponentsManager, useLocales, useModal, useModalComponent, useModalsComponents, useModalsComponentsManager, useOtherLocales, usePageComponent, usePagesComponents, usePagesComponentsManager, usePanels, usePanneau, usePanneauAuth, usePanneauColorScheme, usePanneauComponent, usePanneauComponents, usePanneauResource, usePanneauResources, usePanneauSettings, useResource, useRouteBack, useRoutePush, useTracking, withGoogleApiClient, withGoogleMapsClient, withPanels };
|