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