@micromag/editor 0.3.317 → 0.3.319
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/styles.css +17 -17
- package/es/index.js +566 -861
- package/lib/index.js +566 -861
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -63,26 +63,23 @@ var orderBy__default = /*#__PURE__*/_interopDefaultLegacy(orderBy);
|
|
|
63
63
|
|
|
64
64
|
var useRouteParams = function useRouteParams() {
|
|
65
65
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
_ref$screenOnly = _ref.screenOnly,
|
|
67
|
+
screenOnly = _ref$screenOnly === void 0 ? false : _ref$screenOnly;
|
|
69
68
|
var routes = contexts.useRoutes();
|
|
70
69
|
var path = React.useMemo(function () {
|
|
71
70
|
return screenOnly ? [routes.screen, '*'] : [routes['screen.field.form'], routes['screen.field'], routes.screen, '*'];
|
|
72
71
|
}, [routes, screenOnly]);
|
|
73
|
-
|
|
74
72
|
var _useRouteMatch = reactRouter.useRouteMatch({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
path: path
|
|
74
|
+
}),
|
|
75
|
+
url = _useRouteMatch.url,
|
|
76
|
+
_useRouteMatch$params = _useRouteMatch.params,
|
|
77
|
+
_useRouteMatch$params2 = _useRouteMatch$params.screen,
|
|
78
|
+
screen = _useRouteMatch$params2 === void 0 ? null : _useRouteMatch$params2,
|
|
79
|
+
_useRouteMatch$params3 = _useRouteMatch$params.field,
|
|
80
|
+
field = _useRouteMatch$params3 === void 0 ? null : _useRouteMatch$params3,
|
|
81
|
+
_useRouteMatch$params4 = _useRouteMatch$params.form,
|
|
82
|
+
form = _useRouteMatch$params4 === void 0 ? null : _useRouteMatch$params4;
|
|
86
83
|
var routeParams = React.useMemo(function () {
|
|
87
84
|
return screenOnly ? {
|
|
88
85
|
url: url,
|
|
@@ -97,7 +94,7 @@ var useRouteParams = function useRouteParams() {
|
|
|
97
94
|
return routeParams;
|
|
98
95
|
};
|
|
99
96
|
|
|
100
|
-
var styles$i = {"container":"micromag-editor-container","left":"micromag-editor-left","right":"micromag-editor-right","
|
|
97
|
+
var styles$i = {"container":"micromag-editor-container","left":"micromag-editor-left","right":"micromag-editor-right","fullscreen":"micromag-editor-fullscreen","preview":"micromag-editor-preview","center":"micromag-editor-center","inner":"micromag-editor-inner","visible":"micromag-editor-visible","screen-medium":"micromag-editor-screen-medium","top":"micromag-editor-top"};
|
|
101
98
|
|
|
102
99
|
var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
103
100
|
var lastPageRef = React.useRef({
|
|
@@ -106,16 +103,14 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
106
103
|
});
|
|
107
104
|
var direction = React.useMemo(function () {
|
|
108
105
|
var _lastPageRef$current = lastPageRef.current,
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
lastScreenIndex = _lastPageRef$current.screenIndex,
|
|
107
|
+
lastUrl = _lastPageRef$current.url;
|
|
111
108
|
lastPageRef.current.url = url;
|
|
112
109
|
lastPageRef.current.screenIndex = screenIndex;
|
|
113
|
-
|
|
114
110
|
if (screenIndex !== lastScreenIndex) {
|
|
115
111
|
// return screenIndex > lastScreenIndex ? 'bottom' : 'top';
|
|
116
112
|
return null;
|
|
117
113
|
}
|
|
118
|
-
|
|
119
114
|
var urlSplit = url.split('/');
|
|
120
115
|
var lastUrlSplit = lastUrl.split('/');
|
|
121
116
|
var currentPartsCount = urlSplit.length;
|
|
@@ -128,7 +123,6 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
128
123
|
}, [url, screenIndex]);
|
|
129
124
|
var transitionClassNames = React.useMemo(function () {
|
|
130
125
|
var _classNames, _classNames2, _classNames3;
|
|
131
|
-
|
|
132
126
|
return {
|
|
133
127
|
enter: classNames__default["default"]((_classNames = {}, _defineProperty__default["default"](_classNames, styles.enterRight, direction === 'right'), _defineProperty__default["default"](_classNames, styles.enterLeft, direction === 'left'), _defineProperty__default["default"](_classNames, styles.enterTop, direction === 'top'), _defineProperty__default["default"](_classNames, styles.enterBottom, direction === 'bottom'), _classNames)) || 'none',
|
|
134
128
|
enterActive: classNames__default["default"]((_classNames2 = {}, _defineProperty__default["default"](_classNames2, styles.enterActiveHorizontal, direction === 'left' || direction === 'right'), _defineProperty__default["default"](_classNames2, styles.enterActiveVertical, direction === 'top' || direction === 'bottom'), _classNames2)) || 'none',
|
|
@@ -145,28 +139,25 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
145
139
|
|
|
146
140
|
function getScreenFieldsWithStates(definition) {
|
|
147
141
|
var _ref = definition || {},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
_ref$fields = _ref.fields,
|
|
143
|
+
screenFields = _ref$fields === void 0 ? null : _ref$fields,
|
|
144
|
+
_ref$states = _ref.states,
|
|
145
|
+
states = _ref$states === void 0 ? null : _ref$states;
|
|
153
146
|
if (states === null) {
|
|
154
147
|
return screenFields;
|
|
155
148
|
}
|
|
156
|
-
|
|
157
149
|
var extraFields = states.reduce(function (statesFields, current) {
|
|
158
150
|
var _ref2 = current || {},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
id = _ref2.id,
|
|
152
|
+
_ref2$fields = _ref2.fields,
|
|
153
|
+
fields = _ref2$fields === void 0 ? [] : _ref2$fields,
|
|
154
|
+
_ref2$repeatable = _ref2.repeatable,
|
|
155
|
+
repeatable = _ref2$repeatable === void 0 ? false : _ref2$repeatable,
|
|
156
|
+
_ref2$fieldName = _ref2.fieldName,
|
|
157
|
+
fieldName = _ref2$fieldName === void 0 ? null : _ref2$fieldName,
|
|
158
|
+
label = _ref2.label,
|
|
159
|
+
_ref2$defaultValue = _ref2.defaultValue,
|
|
160
|
+
defaultValue = _ref2$defaultValue === void 0 ? null : _ref2$defaultValue;
|
|
170
161
|
return [].concat(_toConsumableArray__default["default"](statesFields), _toConsumableArray__default["default"](repeatable ? [{
|
|
171
162
|
type: 'items',
|
|
172
163
|
name: fieldName || id,
|
|
@@ -201,17 +192,14 @@ var createScreen = function createScreen(definition) {
|
|
|
201
192
|
var screenFields = getScreenFieldsWithStates(finalDefinition);
|
|
202
193
|
var defaultValueFields = screenFields.reduce(function (all, curr) {
|
|
203
194
|
var _ref = curr || {},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
195
|
+
_ref$name = _ref.name,
|
|
196
|
+
name = _ref$name === void 0 ? null : _ref$name,
|
|
197
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
198
|
+
defaultValue = _ref$defaultValue === void 0 ? null : _ref$defaultValue;
|
|
209
199
|
var newAll = _objectSpread__default["default"]({}, all);
|
|
210
|
-
|
|
211
200
|
if (name !== null && defaultValue !== null) {
|
|
212
201
|
newAll[name] = defaultValue;
|
|
213
202
|
}
|
|
214
|
-
|
|
215
203
|
return newAll;
|
|
216
204
|
}, {});
|
|
217
205
|
return _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({
|
|
@@ -222,13 +210,11 @@ var createScreen = function createScreen(definition) {
|
|
|
222
210
|
};
|
|
223
211
|
|
|
224
212
|
var _excluded$c = ["components"];
|
|
225
|
-
|
|
226
213
|
var deleteScreen = function deleteScreen(story, screenId) {
|
|
227
214
|
var _ref = story || {},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
215
|
+
_ref$components = _ref.components,
|
|
216
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
217
|
+
currentValue = _objectWithoutProperties__default["default"](_ref, _excluded$c);
|
|
232
218
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, currentValue), {}, {
|
|
233
219
|
components: components.filter(function (_ref2) {
|
|
234
220
|
var id = _ref2.id;
|
|
@@ -238,13 +224,11 @@ var deleteScreen = function deleteScreen(story, screenId) {
|
|
|
238
224
|
};
|
|
239
225
|
|
|
240
226
|
var _excluded$b = ["components"];
|
|
241
|
-
|
|
242
227
|
var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
243
228
|
var _ref = story || {},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
229
|
+
_ref$components = _ref.components,
|
|
230
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
231
|
+
currentValue = _objectWithoutProperties__default["default"](_ref, _excluded$b);
|
|
248
232
|
var screen = components.find(function (it) {
|
|
249
233
|
return it.id === screenId;
|
|
250
234
|
}) || null;
|
|
@@ -256,15 +240,12 @@ var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
|
256
240
|
};
|
|
257
241
|
|
|
258
242
|
var _excluded$a = ["components"];
|
|
259
|
-
|
|
260
243
|
var updateScreen = function updateScreen(story, newScreenValue) {
|
|
261
244
|
var newScreenId = newScreenValue.id;
|
|
262
|
-
|
|
263
245
|
var _ref = story || {},
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
246
|
+
_ref$components = _ref.components,
|
|
247
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
248
|
+
currentValue = _objectWithoutProperties__default["default"](_ref, _excluded$a);
|
|
268
249
|
var index = components.findIndex(function (it) {
|
|
269
250
|
return it.id === newScreenId;
|
|
270
251
|
});
|
|
@@ -278,16 +259,13 @@ var getFieldByName = function getFieldByName(fields, name) {
|
|
|
278
259
|
if (foundField !== null) {
|
|
279
260
|
return foundField;
|
|
280
261
|
}
|
|
281
|
-
|
|
282
262
|
var _it$name = it.name,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
263
|
+
fieldName = _it$name === void 0 ? null : _it$name,
|
|
264
|
+
_it$fields = it.fields,
|
|
265
|
+
subFields = _it$fields === void 0 ? [] : _it$fields;
|
|
287
266
|
if (name !== null && fieldName === name) {
|
|
288
267
|
return it;
|
|
289
268
|
}
|
|
290
|
-
|
|
291
269
|
return getFieldByName(subFields, name);
|
|
292
270
|
}, null);
|
|
293
271
|
};
|
|
@@ -301,12 +279,10 @@ var defaultProps$o = {
|
|
|
301
279
|
dots: false,
|
|
302
280
|
className: null
|
|
303
281
|
};
|
|
304
|
-
|
|
305
282
|
var SettingsButton = function SettingsButton(_ref) {
|
|
306
283
|
var className = _ref.className,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
284
|
+
dots = _ref.dots,
|
|
285
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$9);
|
|
310
286
|
return /*#__PURE__*/React__default["default"].createElement(components.Button, Object.assign({
|
|
311
287
|
className: className,
|
|
312
288
|
theme: "secondary",
|
|
@@ -316,7 +292,6 @@ var SettingsButton = function SettingsButton(_ref) {
|
|
|
316
292
|
})
|
|
317
293
|
}, props));
|
|
318
294
|
};
|
|
319
|
-
|
|
320
295
|
SettingsButton.propTypes = propTypes$o;
|
|
321
296
|
SettingsButton.defaultProps = defaultProps$o;
|
|
322
297
|
|
|
@@ -331,46 +306,38 @@ var defaultProps$n = {
|
|
|
331
306
|
form: null,
|
|
332
307
|
children: null
|
|
333
308
|
};
|
|
334
|
-
|
|
335
309
|
var FieldWithContexts = function FieldWithContexts(_ref) {
|
|
336
310
|
var name = _ref.name,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
311
|
+
form = _ref.form,
|
|
312
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$8);
|
|
340
313
|
var definition = contexts.useScreenDefinition() || null;
|
|
341
314
|
var _definition$states = definition.states,
|
|
342
|
-
|
|
315
|
+
states = _definition$states === void 0 ? null : _definition$states;
|
|
343
316
|
var screenFields = getScreenFieldsWithStates(definition);
|
|
344
317
|
var nameParts = name.split('.');
|
|
345
|
-
|
|
346
318
|
var _nameParts = _slicedToArray__default["default"](nameParts, 1),
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
319
|
+
_nameParts$ = _nameParts[0],
|
|
320
|
+
stateId = _nameParts$ === void 0 ? null : _nameParts$;
|
|
350
321
|
var currentState = states !== null ? states.find(function (_ref2) {
|
|
351
322
|
var id = _ref2.id;
|
|
352
323
|
return id === stateId;
|
|
353
324
|
}) || null : null;
|
|
354
325
|
var finalNameParts = nameParts;
|
|
355
|
-
|
|
356
326
|
var _ref3 = currentState || {},
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
327
|
+
_ref3$repeatable = _ref3.repeatable,
|
|
328
|
+
repeatable = _ref3$repeatable === void 0 ? false : _ref3$repeatable,
|
|
329
|
+
_ref3$fieldName = _ref3.fieldName,
|
|
330
|
+
fieldName = _ref3$fieldName === void 0 ? null : _ref3$fieldName,
|
|
331
|
+
_ref3$fields = _ref3.fields,
|
|
332
|
+
stateFields = _ref3$fields === void 0 ? [] : _ref3$fields;
|
|
364
333
|
var finalScreenFields = fieldName !== null && stateId !== null ? screenFields.filter(function (_ref4) {
|
|
365
334
|
var itemName = _ref4.name,
|
|
366
|
-
|
|
335
|
+
fieldStateId = _ref4.stateId;
|
|
367
336
|
return fieldName !== itemName || stateId === fieldStateId || fieldStateId === null;
|
|
368
337
|
}) : screenFields;
|
|
369
|
-
|
|
370
338
|
if (currentState !== null) {
|
|
371
339
|
finalNameParts = (repeatable || fieldName !== null) && nameParts.length <= (repeatable ? 2 : 1) ? [fieldName || stateId].concat(_toConsumableArray__default["default"](nameParts.slice(1))) : nameParts.slice(1);
|
|
372
340
|
}
|
|
373
|
-
|
|
374
341
|
var formComponents = contexts.useFormsComponents();
|
|
375
342
|
return definition !== null ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
376
343
|
className: classNames__default["default"]({
|
|
@@ -385,7 +352,6 @@ var FieldWithContexts = function FieldWithContexts(_ref) {
|
|
|
385
352
|
fields: stateFields
|
|
386
353
|
}, props))) : null;
|
|
387
354
|
};
|
|
388
|
-
|
|
389
355
|
FieldWithContexts.propTypes = propTypes$n;
|
|
390
356
|
FieldWithContexts.defaultProps = defaultProps$n;
|
|
391
357
|
|
|
@@ -396,26 +362,27 @@ var propTypes$m = {
|
|
|
396
362
|
className: PropTypes__default["default"].string,
|
|
397
363
|
gotoFieldForm: PropTypes__default["default"].func.isRequired,
|
|
398
364
|
closeFieldForm: PropTypes__default["default"].func.isRequired,
|
|
399
|
-
onChange: PropTypes__default["default"].func
|
|
400
|
-
|
|
365
|
+
onChange: PropTypes__default["default"].func
|
|
366
|
+
// onClickDelete: PropTypes.func,
|
|
401
367
|
};
|
|
368
|
+
|
|
402
369
|
var defaultProps$m = {
|
|
403
370
|
value: null,
|
|
404
371
|
className: null,
|
|
405
|
-
onChange: null
|
|
406
|
-
|
|
372
|
+
onChange: null
|
|
373
|
+
// onClickDelete: null,
|
|
407
374
|
};
|
|
408
375
|
|
|
409
376
|
var ScreenForm = function ScreenForm(_ref) {
|
|
410
377
|
var value = _ref.value,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
378
|
+
className = _ref.className,
|
|
379
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
380
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
381
|
+
onChange = _ref.onChange;
|
|
416
382
|
var _useScreenDefinition = contexts.useScreenDefinition(),
|
|
417
|
-
|
|
418
|
-
|
|
383
|
+
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
384
|
+
fields$1 = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$;
|
|
385
|
+
// const intl = useIntl();
|
|
419
386
|
// const finalOnClickDelete = useCallback(() => {
|
|
420
387
|
// if (
|
|
421
388
|
// onClickDelete !== null &&
|
|
@@ -429,8 +396,6 @@ var ScreenForm = function ScreenForm(_ref) {
|
|
|
429
396
|
// onClickDelete(value);
|
|
430
397
|
// }
|
|
431
398
|
// }, [intl, onClickDelete, value]);
|
|
432
|
-
|
|
433
|
-
|
|
434
399
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
435
400
|
className: classNames__default["default"]([styles$h.container, _defineProperty__default["default"]({}, className, className)])
|
|
436
401
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -443,7 +408,6 @@ var ScreenForm = function ScreenForm(_ref) {
|
|
|
443
408
|
closeFieldForm: closeFieldForm
|
|
444
409
|
}) : null));
|
|
445
410
|
};
|
|
446
|
-
|
|
447
411
|
ScreenForm.propTypes = propTypes$m;
|
|
448
412
|
ScreenForm.defaultProps = defaultProps$m;
|
|
449
413
|
|
|
@@ -464,110 +428,94 @@ var defaultProps$l = {
|
|
|
464
428
|
form: null,
|
|
465
429
|
className: null
|
|
466
430
|
};
|
|
467
|
-
|
|
468
431
|
var Breadcrumb = function Breadcrumb(_ref) {
|
|
469
432
|
var story = _ref.story,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
433
|
+
screenId = _ref.screenId,
|
|
434
|
+
field = _ref.field,
|
|
435
|
+
form = _ref.form,
|
|
436
|
+
url = _ref.url,
|
|
437
|
+
className = _ref.className;
|
|
475
438
|
var intl = reactIntl.useIntl();
|
|
476
|
-
|
|
477
439
|
var _ref2 = story || {},
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
440
|
+
_ref2$components = _ref2.components,
|
|
441
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
481
442
|
var history = reactRouter.useHistory();
|
|
482
443
|
var screensManager = contexts.useScreensManager();
|
|
483
444
|
var fieldsManager = contexts.useFieldsManager();
|
|
484
445
|
var route = contexts.useUrlGenerator();
|
|
485
|
-
|
|
486
446
|
var _useMemo = React.useMemo(function () {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
var _screens$screenIndex = screens[screenIndex],
|
|
447
|
+
var screenIndex = screens.findIndex(function (it) {
|
|
448
|
+
return it.id === screenId;
|
|
449
|
+
});
|
|
450
|
+
if (!screens[screenIndex]) {
|
|
451
|
+
return {};
|
|
452
|
+
}
|
|
453
|
+
var _screens$screenIndex = screens[screenIndex],
|
|
496
454
|
type = _screens$screenIndex.type,
|
|
497
455
|
_screens$screenIndex$ = _screens$screenIndex.parameters,
|
|
498
456
|
parameters = _screens$screenIndex$ === void 0 ? null : _screens$screenIndex$;
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
var _ref3 = definition || {},
|
|
457
|
+
var definition = screensManager.getDefinition(type);
|
|
458
|
+
var _ref3 = definition || {},
|
|
502
459
|
_ref3$states = _ref3.states,
|
|
503
460
|
states = _ref3$states === void 0 ? null : _ref3$states,
|
|
504
461
|
_ref3$title = _ref3.title,
|
|
505
462
|
definitionTitle = _ref3$title === void 0 ? null : _ref3$title;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
screenParameters = _useMemo$parameters === void 0 ? null : _useMemo$parameters;
|
|
522
|
-
|
|
463
|
+
return {
|
|
464
|
+
title: definitionTitle,
|
|
465
|
+
fields: definition !== null ? [].concat(_toConsumableArray__default["default"](getScreenFieldsWithStates(definition)), [utils.getScreenExtraField(intl)]) : null,
|
|
466
|
+
states: states,
|
|
467
|
+
parameters: parameters
|
|
468
|
+
};
|
|
469
|
+
}, [screens, screenId, screensManager, intl]),
|
|
470
|
+
_useMemo$title = _useMemo.title,
|
|
471
|
+
screenTitle = _useMemo$title === void 0 ? null : _useMemo$title,
|
|
472
|
+
_useMemo$fields = _useMemo.fields,
|
|
473
|
+
screenFields = _useMemo$fields === void 0 ? [] : _useMemo$fields,
|
|
474
|
+
_useMemo$states = _useMemo.states,
|
|
475
|
+
screenStates = _useMemo$states === void 0 ? null : _useMemo$states,
|
|
476
|
+
_useMemo$parameters = _useMemo.parameters,
|
|
477
|
+
screenParameters = _useMemo$parameters === void 0 ? null : _useMemo$parameters;
|
|
523
478
|
var items = React.useMemo(function () {
|
|
524
479
|
var fieldItems = [];
|
|
525
480
|
var currentState = null;
|
|
526
|
-
|
|
527
481
|
if (field !== null) {
|
|
528
|
-
var fieldPath = field.split('/');
|
|
482
|
+
var fieldPath = field.split('/');
|
|
529
483
|
|
|
484
|
+
// Get state and remove it from path. Replace it with field name if necessary (repeatable or fieldName present)
|
|
530
485
|
var _fieldPath = _slicedToArray__default["default"](fieldPath, 1),
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
486
|
+
_fieldPath$ = _fieldPath[0],
|
|
487
|
+
stateId = _fieldPath$ === void 0 ? null : _fieldPath$;
|
|
534
488
|
currentState = screenStates !== null ? screenStates.find(function (_ref4) {
|
|
535
489
|
var id = _ref4.id;
|
|
536
490
|
return id === stateId;
|
|
537
491
|
}) || null : null;
|
|
538
492
|
var finalFieldPath = fieldPath;
|
|
539
|
-
|
|
540
493
|
if (currentState !== null) {
|
|
541
494
|
var _ref5 = currentState || {},
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
495
|
+
_ref5$repeatable = _ref5.repeatable,
|
|
496
|
+
repeatable = _ref5$repeatable === void 0 ? false : _ref5$repeatable,
|
|
497
|
+
_ref5$fieldName = _ref5.fieldName,
|
|
498
|
+
fieldName = _ref5$fieldName === void 0 ? null : _ref5$fieldName;
|
|
547
499
|
finalFieldPath = (repeatable || fieldName !== null) && fieldPath.length <= (repeatable ? 2 : 1) ? [fieldName || stateId].concat(_toConsumableArray__default["default"](fieldPath.slice(1))) : fieldPath.slice(1);
|
|
548
500
|
}
|
|
549
|
-
|
|
550
501
|
var lastKeyIndex = finalFieldPath.length - 1;
|
|
551
502
|
var parentItem = null;
|
|
552
503
|
finalFieldPath.reduce(function (currentFields, key, keyIndex) {
|
|
553
504
|
var _ref6 = currentFields || {},
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
505
|
+
_ref6$type = _ref6.type,
|
|
506
|
+
fieldType = _ref6$type === void 0 ? null : _ref6$type,
|
|
507
|
+
_ref6$fields = _ref6.fields,
|
|
508
|
+
currentSubFields = _ref6$fields === void 0 ? null : _ref6$fields,
|
|
509
|
+
_ref6$itemsField = _ref6.itemsField,
|
|
510
|
+
currentItemsField = _ref6$itemsField === void 0 ? null : _ref6$itemsField;
|
|
561
511
|
var fieldsDef = fieldType !== null ? fieldsManager.getDefinition(fieldType) : currentFields;
|
|
562
|
-
|
|
563
512
|
var _ref7 = fieldsDef || {},
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
513
|
+
_ref7$fields = _ref7.fields,
|
|
514
|
+
defSubFields = _ref7$fields === void 0 ? null : _ref7$fields,
|
|
515
|
+
_ref7$settings = _ref7.settings,
|
|
516
|
+
settings = _ref7$settings === void 0 ? null : _ref7$settings,
|
|
517
|
+
_ref7$itemsField = _ref7.itemsField,
|
|
518
|
+
defItemsField = _ref7$itemsField === void 0 ? null : _ref7$itemsField;
|
|
571
519
|
var itemsField = currentItemsField || defItemsField;
|
|
572
520
|
var subFields = currentSubFields || defSubFields;
|
|
573
521
|
var currentSubfields = subFields !== null ? getFieldByName(subFields, key) : null;
|
|
@@ -586,12 +534,10 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
586
534
|
var addNewItem = isLastIndex || isListItems;
|
|
587
535
|
var itemPath = "".concat(pathPrefix).concat(pathSuffix);
|
|
588
536
|
var nextFields = null;
|
|
589
|
-
|
|
590
537
|
if (isCurrentSubfields) {
|
|
591
538
|
nextFields = currentSubfields;
|
|
592
539
|
} else if (isCurrentSettings) {
|
|
593
540
|
nextFields = currentSettings;
|
|
594
|
-
|
|
595
541
|
if (parentItem !== null) {
|
|
596
542
|
fieldItems.push(_objectSpread__default["default"](_objectSpread__default["default"]({}, parentItem), {}, {
|
|
597
543
|
url: route('screen.field.form', {
|
|
@@ -606,44 +552,36 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
606
552
|
} else if (isListItems) {
|
|
607
553
|
nextFields = itemsField;
|
|
608
554
|
}
|
|
609
|
-
|
|
610
555
|
var fieldLabel = nextFields ? nextFields.breadcrumbLabel || nextFields.label : null;
|
|
611
556
|
var itemLabel = utils.isMessage(fieldLabel) ? intl.formatMessage(fieldLabel) : fieldLabel;
|
|
612
|
-
|
|
613
557
|
var _ref8 = parentItem || {},
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
558
|
+
_ref8$label = _ref8.label,
|
|
559
|
+
parentItemLabel = _ref8$label === void 0 ? null : _ref8$label;
|
|
617
560
|
var finalItemLabel = isListItems ? "".concat(itemLabel, " #").concat(parseInt(key, 10) + 1) : itemLabel || parentItemLabel;
|
|
618
561
|
var item = {
|
|
619
562
|
url: itemPath,
|
|
620
563
|
label: finalItemLabel || '',
|
|
621
564
|
active: false
|
|
622
565
|
};
|
|
623
|
-
|
|
624
566
|
if (addNewItem) {
|
|
625
567
|
fieldItems.push(item);
|
|
626
568
|
}
|
|
627
|
-
|
|
628
569
|
parentItem = item;
|
|
629
570
|
return nextFields;
|
|
630
571
|
}, {
|
|
631
572
|
fields: stateId === null ? screenFields : screenFields.filter(function (_ref9) {
|
|
632
573
|
var _ref9$stateId = _ref9.stateId,
|
|
633
|
-
|
|
574
|
+
fieldStateId = _ref9$stateId === void 0 ? null : _ref9$stateId;
|
|
634
575
|
return fieldStateId === null || fieldStateId === stateId;
|
|
635
576
|
})
|
|
636
577
|
});
|
|
637
578
|
}
|
|
638
|
-
|
|
639
579
|
var _ref10 = screenParameters || {},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
580
|
+
_ref10$metadata = _ref10.metadata,
|
|
581
|
+
metadata = _ref10$metadata === void 0 ? null : _ref10$metadata;
|
|
643
582
|
var _ref11 = metadata || {},
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
583
|
+
_ref11$title = _ref11.title,
|
|
584
|
+
title = _ref11$title === void 0 ? null : _ref11$title;
|
|
647
585
|
var typeTitle = screenTitle !== null ? /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, screenTitle) : null;
|
|
648
586
|
var parametersMessage = intl.formatMessage({
|
|
649
587
|
id: "AHvHaY",
|
|
@@ -689,7 +627,6 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
689
627
|
className: classNames__default["default"]([styles$g.container, 'text-truncate', _defineProperty__default["default"]({}, className, className !== null)])
|
|
690
628
|
}));
|
|
691
629
|
};
|
|
692
|
-
|
|
693
630
|
Breadcrumb.propTypes = propTypes$l;
|
|
694
631
|
Breadcrumb.defaultProps = defaultProps$l;
|
|
695
632
|
|
|
@@ -705,11 +642,10 @@ var defaultProps$k = {
|
|
|
705
642
|
onConfirm: null,
|
|
706
643
|
onCancel: null
|
|
707
644
|
};
|
|
708
|
-
|
|
709
645
|
var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
710
646
|
var className = _ref.className,
|
|
711
|
-
|
|
712
|
-
|
|
647
|
+
onConfirm = _ref.onConfirm,
|
|
648
|
+
onCancel = _ref.onCancel;
|
|
713
649
|
return /*#__PURE__*/React__default["default"].createElement(components.Modal, null, /*#__PURE__*/React__default["default"].createElement(components.ModalDialog, {
|
|
714
650
|
title: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
715
651
|
id: "p6q/+/",
|
|
@@ -751,11 +687,10 @@ var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
|
751
687
|
})
|
|
752
688
|
}))));
|
|
753
689
|
};
|
|
754
|
-
|
|
755
690
|
DeleteScreenModal.propTypes = propTypes$k;
|
|
756
691
|
DeleteScreenModal.defaultProps = defaultProps$k;
|
|
757
692
|
|
|
758
|
-
var styles$e = {"panel":"micromag-editor-form-panel","exit":"micromag-editor-form-exit","content":"micromag-editor-form-content","navbar":"micromag-editor-form-navbar","
|
|
693
|
+
var styles$e = {"panel":"micromag-editor-form-panel","exit":"micromag-editor-form-exit","content":"micromag-editor-form-content","navbar":"micromag-editor-form-navbar","enterRight":"micromag-editor-form-enterRight","enterLeft":"micromag-editor-form-enterLeft","enterTop":"micromag-editor-form-enterTop","enterBottom":"micromag-editor-form-enterBottom","enterActiveHorizontal":"micromag-editor-form-enterActiveHorizontal","enterActiveVertical":"micromag-editor-form-enterActiveVertical","exitActiveRight":"micromag-editor-form-exitActiveRight","exitActiveLeft":"micromag-editor-form-exitActiveLeft","exitActiveTop":"micromag-editor-form-exitActiveTop","exitActiveBottom":"micromag-editor-form-exitActiveBottom"};
|
|
759
694
|
|
|
760
695
|
var propTypes$j = {
|
|
761
696
|
value: PropTypes__default["default"].oneOfType([core.PropTypes.story, core.PropTypes.theme]),
|
|
@@ -769,30 +704,27 @@ var defaultProps$j = {
|
|
|
769
704
|
className: null,
|
|
770
705
|
onChange: null
|
|
771
706
|
};
|
|
772
|
-
|
|
773
707
|
var EditForm = function EditForm(_ref) {
|
|
774
708
|
var value = _ref.value,
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
709
|
+
isTheme = _ref.isTheme,
|
|
710
|
+
className = _ref.className,
|
|
711
|
+
onChange = _ref.onChange;
|
|
778
712
|
// Match routes
|
|
779
713
|
var history = reactRouter.useHistory();
|
|
780
714
|
var routePush = contexts.useRoutePush();
|
|
781
|
-
|
|
782
715
|
var _useRouteParams = useRouteParams(),
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
716
|
+
url = _useRouteParams.url,
|
|
717
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
718
|
+
screenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
719
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
720
|
+
fieldParams = _useRouteParams$field === void 0 ? null : _useRouteParams$field,
|
|
721
|
+
_useRouteParams$form = _useRouteParams.form,
|
|
722
|
+
formParams = _useRouteParams$form === void 0 ? null : _useRouteParams$form;
|
|
723
|
+
|
|
724
|
+
// Get screen
|
|
792
725
|
var _ref2 = value || {},
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
726
|
+
_ref2$components = _ref2.components,
|
|
727
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
796
728
|
var screenIndex = screens.findIndex(function (it) {
|
|
797
729
|
return it.id === screenId;
|
|
798
730
|
});
|
|
@@ -800,62 +732,54 @@ var EditForm = function EditForm(_ref) {
|
|
|
800
732
|
var screensManager = contexts.useScreensManager();
|
|
801
733
|
var screenFields = React.useMemo(function () {
|
|
802
734
|
var _ref3 = screen || {},
|
|
803
|
-
|
|
804
|
-
|
|
735
|
+
type = _ref3.type;
|
|
805
736
|
var definition = type !== null ? screensManager.getDefinition(type) : null;
|
|
806
737
|
return definition != null ? getScreenFieldsWithStates(definition) : [];
|
|
807
|
-
}, [screensManager, screen]);
|
|
738
|
+
}, [screensManager, screen]);
|
|
808
739
|
|
|
740
|
+
// Get transition value
|
|
809
741
|
var _useFormTransition = useFormTransition(url, screenIndex, styles$e),
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
742
|
+
transitionClassNames = _useFormTransition.classNames,
|
|
743
|
+
transitionTimeout = _useFormTransition.timeout;
|
|
813
744
|
var _useState = React.useState(false),
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
745
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
746
|
+
screenSettingsOpened = _useState2[0],
|
|
747
|
+
setScreenSettingsOpened = _useState2[1];
|
|
818
748
|
var _useState3 = React.useState(false),
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
749
|
+
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
750
|
+
deleteScreenModalOpened = _useState4[0],
|
|
751
|
+
setDeleteScreenModalOpened = _useState4[1];
|
|
823
752
|
var _useState5 = React.useState({}),
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
753
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
754
|
+
fieldForms = _useState6[0],
|
|
755
|
+
setFieldForms = _useState6[1];
|
|
828
756
|
var _useState7 = React.useState(null),
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
757
|
+
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
758
|
+
fieldContext = _useState8[0],
|
|
759
|
+
setFieldContext = _useState8[1];
|
|
833
760
|
|
|
761
|
+
// Callbacks
|
|
834
762
|
var gotoFieldForm = React.useCallback(function () {
|
|
835
763
|
var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
836
764
|
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
837
765
|
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
838
766
|
var hasField = field !== null;
|
|
839
767
|
var fieldRoute = formName !== null ? 'screen.field.form' : 'screen.field';
|
|
840
|
-
|
|
841
768
|
var _ref4 = field !== null ? field.split('.') : [],
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
769
|
+
_ref5 = _slicedToArray__default["default"](_ref4, 1),
|
|
770
|
+
_ref5$ = _ref5[0],
|
|
771
|
+
rootFieldName = _ref5$ === void 0 ? null : _ref5$;
|
|
846
772
|
var _ref6 = fieldParams !== null ? fieldParams.split('/') : [],
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
773
|
+
_ref7 = _slicedToArray__default["default"](_ref6, 1),
|
|
774
|
+
_ref7$ = _ref7[0],
|
|
775
|
+
currentStateId = _ref7$ === void 0 ? null : _ref7$;
|
|
851
776
|
var _ref8 = (rootFieldName !== null ? screenFields.find(function (_ref9) {
|
|
852
|
-
|
|
777
|
+
var name = _ref9.name,
|
|
853
778
|
fieldStateId = _ref9.stateId;
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
779
|
+
return name === rootFieldName && currentStateId === fieldStateId;
|
|
780
|
+
}) || null : null) || {},
|
|
781
|
+
_ref8$stateId = _ref8.stateId,
|
|
782
|
+
stateId = _ref8$stateId === void 0 ? null : _ref8$stateId;
|
|
859
783
|
routePush(hasField ? fieldRoute : 'screen', {
|
|
860
784
|
screen: screenId,
|
|
861
785
|
field: field !== null ? [stateId].concat(_toConsumableArray__default["default"](field.split('.'))).filter(function (it) {
|
|
@@ -870,11 +794,9 @@ var EditForm = function EditForm(_ref) {
|
|
|
870
794
|
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
871
795
|
var fieldKey = "".concat(field).concat(formName !== null ? ":".concat(formName) : '');
|
|
872
796
|
var pastUrl = fieldForms[fieldKey] || null;
|
|
873
|
-
|
|
874
797
|
if (pastUrl !== null) {
|
|
875
798
|
history.push(pastUrl);
|
|
876
799
|
}
|
|
877
|
-
|
|
878
800
|
setFieldForms(Object.keys(fieldForms).reduce(function (map, key) {
|
|
879
801
|
return key !== fieldKey ? _objectSpread__default["default"](_objectSpread__default["default"]({}, map), {}, _defineProperty__default["default"]({}, key, fieldForms[key])) : map;
|
|
880
802
|
}, {}));
|
|
@@ -904,25 +826,22 @@ var EditForm = function EditForm(_ref) {
|
|
|
904
826
|
var onDeleteScreenConfirm = React.useCallback(function () {
|
|
905
827
|
var current = screens.findIndex(function (_ref10) {
|
|
906
828
|
var _ref10$id = _ref10.id,
|
|
907
|
-
|
|
829
|
+
scrId = _ref10$id === void 0 ? null : _ref10$id;
|
|
908
830
|
return scrId === screenId;
|
|
909
831
|
}) || 0;
|
|
910
832
|
var previous = screens.find(function (_ref11, i) {
|
|
911
833
|
var _ref11$id = _ref11.id,
|
|
912
|
-
|
|
834
|
+
scrId = _ref11$id === void 0 ? null : _ref11$id;
|
|
913
835
|
return scrId !== screenId && (i === current - 1 || current === 0);
|
|
914
836
|
}) || null;
|
|
915
|
-
|
|
916
837
|
if (previous !== null) {
|
|
917
838
|
var _ref12 = previous || {},
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
839
|
+
_ref12$id = _ref12.id,
|
|
840
|
+
firstScreenId = _ref12$id === void 0 ? null : _ref12$id;
|
|
921
841
|
routePush('screen', {
|
|
922
842
|
screen: firstScreenId
|
|
923
843
|
});
|
|
924
844
|
}
|
|
925
|
-
|
|
926
845
|
triggerOnChange(deleteScreen(value, screenId));
|
|
927
846
|
setDeleteScreenModalOpened(false);
|
|
928
847
|
}, [value, triggerOnChange, screenId, setScreenSettingsOpened, routePush, screens]);
|
|
@@ -1034,40 +953,33 @@ var EditForm = function EditForm(_ref) {
|
|
|
1034
953
|
onCancel: onDeleteScreenCancel
|
|
1035
954
|
}) : null);
|
|
1036
955
|
};
|
|
1037
|
-
|
|
1038
956
|
EditForm.propTypes = propTypes$j;
|
|
1039
957
|
EditForm.defaultProps = defaultProps$j;
|
|
1040
958
|
|
|
1041
959
|
function useScreenStates(screen) {
|
|
1042
960
|
var _ref = screen || {},
|
|
1043
|
-
|
|
1044
|
-
|
|
961
|
+
type = _ref.type;
|
|
1045
962
|
var screensManager = contexts.useScreensManager();
|
|
1046
963
|
var states = React.useMemo(function () {
|
|
1047
964
|
var definition = screensManager.getDefinition(type) || null;
|
|
1048
|
-
|
|
1049
965
|
var _ref2 = definition || {},
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
966
|
+
_ref2$states = _ref2.states,
|
|
967
|
+
screenStates = _ref2$states === void 0 ? null : _ref2$states;
|
|
1053
968
|
return screenStates;
|
|
1054
969
|
}, [screensManager, type]);
|
|
1055
970
|
return states;
|
|
1056
971
|
}
|
|
1057
972
|
|
|
1058
973
|
var _excluded$7 = ["components"];
|
|
1059
|
-
|
|
1060
974
|
var useThemeValue = function useThemeValue(value) {
|
|
1061
975
|
var isTheme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1062
976
|
var valueWithTheme = React.useMemo(function () {
|
|
1063
977
|
if (!isTheme) {
|
|
1064
978
|
return value;
|
|
1065
979
|
}
|
|
1066
|
-
|
|
1067
980
|
var _ref = value || {};
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
981
|
+
_ref.components;
|
|
982
|
+
var themeValue = _objectWithoutProperties__default["default"](_ref, _excluded$7);
|
|
1071
983
|
return value !== null ? _objectSpread__default["default"]({
|
|
1072
984
|
theme: themeValue
|
|
1073
985
|
}, value) : value;
|
|
@@ -1086,10 +998,9 @@ var defaultProps$i = {
|
|
|
1086
998
|
color: 'currentColor',
|
|
1087
999
|
className: null
|
|
1088
1000
|
};
|
|
1089
|
-
|
|
1090
1001
|
var DesktopIcon = function DesktopIcon(_ref) {
|
|
1091
1002
|
var color = _ref.color,
|
|
1092
|
-
|
|
1003
|
+
className = _ref.className;
|
|
1093
1004
|
return /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1094
1005
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1095
1006
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
@@ -1106,7 +1017,6 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
1106
1017
|
d: "M84 17H16c-3.3 0-6 2.7-6 6v42c0 3.3 2.7 6 6 6h22v4.2c-.1.4-.9 1.5-1.3 2-1.1 1.4-2.2 2.8-1.4 4.4.3.7 1.1 1.4 2.7 1.4h23c1 0 3.3 0 4.1-1.8.8-1.8-.6-3.2-1.8-4.5-.4-.5-1.1-1.2-1.3-1.6V71h22c3.3 0 6-2.7 6-6V23c0-3.3-2.7-6-6-6zM40.3 79c.9-1.1 1.7-2.4 1.7-3.8V71h16v4.2c0 1.4 1 2.7 2 3.8H40.3zM86 65c0 1.1-.9 2-2 2H16c-1.1 0-2-.9-2-2v-6h72v6zm0-10H14V23c0-1.1.9-2 2-2h68c1.1 0 2 .9 2 2v32z"
|
|
1107
1018
|
}));
|
|
1108
1019
|
};
|
|
1109
|
-
|
|
1110
1020
|
DesktopIcon.propTypes = propTypes$i;
|
|
1111
1021
|
DesktopIcon.defaultProps = defaultProps$i;
|
|
1112
1022
|
|
|
@@ -1119,10 +1029,9 @@ var defaultProps$h = {
|
|
|
1119
1029
|
color: 'currentColor',
|
|
1120
1030
|
className: null
|
|
1121
1031
|
};
|
|
1122
|
-
|
|
1123
1032
|
var MobileIcon = function MobileIcon(_ref) {
|
|
1124
1033
|
var color = _ref.color,
|
|
1125
|
-
|
|
1034
|
+
className = _ref.className;
|
|
1126
1035
|
return /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1127
1036
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1128
1037
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
@@ -1139,7 +1048,6 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
1139
1048
|
d: "M66 11H34c-3.3 0-6 2.7-6 6v66c0 3.3 2.7 6 6 6h32c3.3 0 6-2.7 6-6V17c0-3.3-2.7-6-6-6zm2 72c0 1.1-.9 2-2 2H34c-1.1 0-2-.9-2-2v-4h36v4zm0-8H32V25h36v50zm0-54H32v-4c0-1.1.9-2 2-2h32c1.1 0 2 .9 2 2v4z"
|
|
1140
1049
|
}));
|
|
1141
1050
|
};
|
|
1142
|
-
|
|
1143
1051
|
MobileIcon.propTypes = propTypes$h;
|
|
1144
1052
|
MobileIcon.defaultProps = defaultProps$h;
|
|
1145
1053
|
|
|
@@ -1161,13 +1069,11 @@ var defaultProps$g = {
|
|
|
1161
1069
|
iconComponents: DeviceIcons,
|
|
1162
1070
|
className: null
|
|
1163
1071
|
};
|
|
1164
|
-
|
|
1165
1072
|
var DeviceButton = function DeviceButton(_ref) {
|
|
1166
1073
|
var device = _ref.device,
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1074
|
+
className = _ref.className,
|
|
1075
|
+
iconComponents = _ref.iconComponents,
|
|
1076
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$6);
|
|
1171
1077
|
var DeviceIcon = utils.getComponentFromName(device, iconComponents, DesktopIcon);
|
|
1172
1078
|
return /*#__PURE__*/React__default["default"].createElement(components.Button, Object.assign({
|
|
1173
1079
|
className: classNames__default["default"]([styles$c.container, _defineProperty__default["default"]({}, className, className !== null)])
|
|
@@ -1175,7 +1081,6 @@ var DeviceButton = function DeviceButton(_ref) {
|
|
|
1175
1081
|
className: styles$c.icon
|
|
1176
1082
|
}));
|
|
1177
1083
|
};
|
|
1178
|
-
|
|
1179
1084
|
DeviceButton.propTypes = propTypes$g;
|
|
1180
1085
|
DeviceButton.defaultProps = defaultProps$g;
|
|
1181
1086
|
|
|
@@ -1190,19 +1095,17 @@ var defaultProps$f = {
|
|
|
1190
1095
|
className: null,
|
|
1191
1096
|
onClickItem: null
|
|
1192
1097
|
};
|
|
1193
|
-
|
|
1194
1098
|
var DevicesMenu = function DevicesMenu(_ref) {
|
|
1195
1099
|
var items = _ref.items,
|
|
1196
|
-
|
|
1197
|
-
|
|
1100
|
+
className = _ref.className,
|
|
1101
|
+
onClickItem = _ref.onClickItem;
|
|
1198
1102
|
return /*#__PURE__*/React__default["default"].createElement(components.Tabs, {
|
|
1199
1103
|
items: items,
|
|
1200
1104
|
theme: "outline-secondary",
|
|
1201
1105
|
className: classNames__default["default"]([styles$d.container, _defineProperty__default["default"]({}, className, className !== null)]),
|
|
1202
1106
|
renderItemButton: function renderItemButton(item, index, props) {
|
|
1203
1107
|
var id = item.id,
|
|
1204
|
-
|
|
1205
|
-
|
|
1108
|
+
itemProps = _objectWithoutProperties__default["default"](item, _excluded$5);
|
|
1206
1109
|
return /*#__PURE__*/React__default["default"].createElement(DeviceButton, Object.assign({
|
|
1207
1110
|
device: id
|
|
1208
1111
|
}, props, itemProps, {
|
|
@@ -1214,13 +1117,12 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
1214
1117
|
}
|
|
1215
1118
|
});
|
|
1216
1119
|
};
|
|
1217
|
-
|
|
1218
1120
|
DevicesMenu.propTypes = propTypes$f;
|
|
1219
1121
|
DevicesMenu.defaultProps = defaultProps$f;
|
|
1220
1122
|
|
|
1221
1123
|
var styles$b = {"container":"micromag-editor-partials-screen-states-container","button":"micromag-editor-partials-screen-states-button","addButton":"micromag-editor-partials-screen-states-addButton","title":"micromag-editor-partials-screen-states-title"};
|
|
1222
1124
|
|
|
1223
|
-
var styles$a = {"container":"micromag-editor-buttons-screen-container","button":"micromag-editor-buttons-screen-button","
|
|
1125
|
+
var styles$a = {"container":"micromag-editor-buttons-screen-container","button":"micromag-editor-buttons-screen-button","screen":"micromag-editor-buttons-screen-screen","inner":"micromag-editor-buttons-screen-inner","border":"micromag-editor-buttons-screen-border","icon":"micromag-editor-buttons-screen-icon","label":"micromag-editor-buttons-screen-label","active":"micromag-editor-buttons-screen-active"};
|
|
1224
1126
|
|
|
1225
1127
|
var propTypes$e = {
|
|
1226
1128
|
active: PropTypes__default["default"].bool,
|
|
@@ -1233,8 +1135,8 @@ var propTypes$e = {
|
|
|
1233
1135
|
children: PropTypes__default["default"].node,
|
|
1234
1136
|
refButton: PropTypes__default["default"].shape({
|
|
1235
1137
|
current: PropTypes__default["default"].any // eslint-disable-line
|
|
1236
|
-
|
|
1237
1138
|
}),
|
|
1139
|
+
|
|
1238
1140
|
className: PropTypes__default["default"].string
|
|
1239
1141
|
};
|
|
1240
1142
|
var defaultProps$e = {
|
|
@@ -1249,20 +1151,18 @@ var defaultProps$e = {
|
|
|
1249
1151
|
refButton: null,
|
|
1250
1152
|
className: null
|
|
1251
1153
|
};
|
|
1252
|
-
|
|
1253
1154
|
var ScreenButton = function ScreenButton(_ref) {
|
|
1254
1155
|
var _ref2;
|
|
1255
|
-
|
|
1256
1156
|
var active = _ref.active,
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1157
|
+
id = _ref.id,
|
|
1158
|
+
href = _ref.href,
|
|
1159
|
+
className = _ref.className,
|
|
1160
|
+
label = _ref.label,
|
|
1161
|
+
icon = _ref.icon,
|
|
1162
|
+
children = _ref.children,
|
|
1163
|
+
title = _ref.title,
|
|
1164
|
+
onClick = _ref.onClick,
|
|
1165
|
+
refButton = _ref.refButton;
|
|
1266
1166
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1267
1167
|
className: classNames__default["default"]([styles$a.container, 'rounded', (_ref2 = {}, _defineProperty__default["default"](_ref2, styles$a.active, active), _defineProperty__default["default"](_ref2, className, className !== null), _ref2)])
|
|
1268
1168
|
}, children !== null ? children : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1285,7 +1185,6 @@ var ScreenButton = function ScreenButton(_ref) {
|
|
|
1285
1185
|
className: classNames__default["default"]([styles$a.border, 'rounded'])
|
|
1286
1186
|
})));
|
|
1287
1187
|
};
|
|
1288
|
-
|
|
1289
1188
|
ScreenButton.propTypes = propTypes$e;
|
|
1290
1189
|
ScreenButton.defaultProps = defaultProps$e;
|
|
1291
1190
|
var ScreenButton$1 = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
|
|
@@ -1319,18 +1218,17 @@ var defaultProps$d = {
|
|
|
1319
1218
|
onClickItem: null,
|
|
1320
1219
|
className: null
|
|
1321
1220
|
};
|
|
1322
|
-
|
|
1323
1221
|
var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
1324
1222
|
var screen = _ref.screen,
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1223
|
+
screenState = _ref.screenState,
|
|
1224
|
+
index = _ref.index,
|
|
1225
|
+
title = _ref.title,
|
|
1226
|
+
href = _ref.href,
|
|
1227
|
+
active = _ref.active,
|
|
1228
|
+
className = _ref.className,
|
|
1229
|
+
_onClick = _ref.onClick,
|
|
1230
|
+
onClickItem = _ref.onClickItem,
|
|
1231
|
+
withPlaceholder = _ref.withPlaceholder;
|
|
1334
1232
|
var intl = reactIntl.useIntl();
|
|
1335
1233
|
var ScreenComponent = withPlaceholder ? components.ScreenPlaceholder : components.ScreenPreview;
|
|
1336
1234
|
return /*#__PURE__*/React__default["default"].createElement(ScreenButton$1, {
|
|
@@ -1342,7 +1240,6 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
|
1342
1240
|
if (_onClick !== null) {
|
|
1343
1241
|
_onClick(screen, index);
|
|
1344
1242
|
}
|
|
1345
|
-
|
|
1346
1243
|
if (onClickItem !== null) {
|
|
1347
1244
|
onClickItem(screen, index);
|
|
1348
1245
|
}
|
|
@@ -1354,7 +1251,6 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
|
1354
1251
|
withSize: true
|
|
1355
1252
|
}));
|
|
1356
1253
|
};
|
|
1357
|
-
|
|
1358
1254
|
ScreenWithPreview.propTypes = propTypes$d;
|
|
1359
1255
|
ScreenWithPreview.defaultProps = defaultProps$d;
|
|
1360
1256
|
|
|
@@ -1370,29 +1266,24 @@ var defaultProps$c = {
|
|
|
1370
1266
|
className: null,
|
|
1371
1267
|
onChange: null
|
|
1372
1268
|
};
|
|
1373
|
-
|
|
1374
1269
|
function ScreenStates(_ref) {
|
|
1375
1270
|
var screen = _ref.screen,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1271
|
+
value = _ref.value,
|
|
1272
|
+
className = _ref.className,
|
|
1273
|
+
onChange = _ref.onChange;
|
|
1379
1274
|
var url = contexts.useUrlGenerator();
|
|
1380
1275
|
var push = contexts.useRoutePush();
|
|
1381
|
-
|
|
1382
1276
|
var _useRouteParams = useRouteParams(),
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1277
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
1278
|
+
screenParam = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
1279
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
1280
|
+
field = _useRouteParams$field === void 0 ? null : _useRouteParams$field;
|
|
1388
1281
|
var states = useScreenStates(screen);
|
|
1389
|
-
|
|
1390
1282
|
var _ref2 = field !== null ? field.split('/') : [],
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1283
|
+
_ref3 = _toArray__default["default"](_ref2),
|
|
1284
|
+
_ref3$ = _ref3[0],
|
|
1285
|
+
stateParam = _ref3$ === void 0 ? null : _ref3$,
|
|
1286
|
+
stateIndexes = _ref3.slice(1);
|
|
1396
1287
|
var stateIndex = stateIndexes.find(function (it) {
|
|
1397
1288
|
return it.match(/^[0-9]+$/) !== null;
|
|
1398
1289
|
}) || null;
|
|
@@ -1421,42 +1312,36 @@ function ScreenStates(_ref) {
|
|
|
1421
1312
|
})
|
|
1422
1313
|
})), states.map(function (state) {
|
|
1423
1314
|
var id = state.id,
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1315
|
+
_state$label = state.label,
|
|
1316
|
+
label = _state$label === void 0 ? null : _state$label,
|
|
1317
|
+
_state$repeatable = state.repeatable,
|
|
1318
|
+
repeatable = _state$repeatable === void 0 ? false : _state$repeatable,
|
|
1319
|
+
_state$withoutCreate = state.withoutCreate,
|
|
1320
|
+
withoutCreate = _state$withoutCreate === void 0 ? false : _state$withoutCreate,
|
|
1321
|
+
_state$fieldName = state.fieldName,
|
|
1322
|
+
fieldName = _state$fieldName === void 0 ? null : _state$fieldName;
|
|
1432
1323
|
var repeatableItems = repeatable ? screen[fieldName || id] || [] : null;
|
|
1433
|
-
|
|
1434
1324
|
var onClickAdd = function onClickAdd() {
|
|
1435
1325
|
var _ref6 = value || {},
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1326
|
+
_ref6$components = _ref6.components,
|
|
1327
|
+
currentComponentsValue = _ref6$components === void 0 ? [] : _ref6$components;
|
|
1439
1328
|
var currentScreenIndex = currentComponentsValue.findIndex(function (_ref7) {
|
|
1440
1329
|
var screenId = _ref7.id;
|
|
1441
1330
|
return screen.id === screenId;
|
|
1442
1331
|
});
|
|
1443
1332
|
var currentScreenValue = currentComponentsValue[currentScreenIndex] || {};
|
|
1444
1333
|
var currentFieldValue = currentScreenValue[fieldName || id] || [];
|
|
1445
|
-
|
|
1446
1334
|
var newValue = _objectSpread__default["default"](_objectSpread__default["default"]({}, value), {}, {
|
|
1447
1335
|
components: [].concat(_toConsumableArray__default["default"](currentComponentsValue.slice(0, currentScreenIndex)), [_objectSpread__default["default"](_objectSpread__default["default"]({}, currentScreenValue), {}, _defineProperty__default["default"]({}, fieldName || id, [].concat(_toConsumableArray__default["default"](currentFieldValue), [{}])))], _toConsumableArray__default["default"](currentComponentsValue.slice(currentScreenIndex + 1)))
|
|
1448
1336
|
});
|
|
1449
|
-
|
|
1450
1337
|
if (onChange !== null) {
|
|
1451
1338
|
onChange(newValue);
|
|
1452
1339
|
}
|
|
1453
|
-
|
|
1454
1340
|
push('screen.field', {
|
|
1455
1341
|
screen: screen.id,
|
|
1456
1342
|
field: [id, currentFieldValue.length]
|
|
1457
1343
|
});
|
|
1458
1344
|
};
|
|
1459
|
-
|
|
1460
1345
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1461
1346
|
className: "p-1 align-self-stretch d-flex flex-column"
|
|
1462
1347
|
}, /*#__PURE__*/React__default["default"].createElement("h6", {
|
|
@@ -1496,12 +1381,12 @@ function ScreenStates(_ref) {
|
|
|
1496
1381
|
href: url('screen.field', {
|
|
1497
1382
|
screen: screen.id,
|
|
1498
1383
|
field: id
|
|
1499
|
-
})
|
|
1384
|
+
})
|
|
1385
|
+
// onClick={() => {
|
|
1500
1386
|
// if (onStateChange !== null) {
|
|
1501
1387
|
// onStateChange(id);
|
|
1502
1388
|
// }
|
|
1503
1389
|
// }}
|
|
1504
|
-
|
|
1505
1390
|
}));
|
|
1506
1391
|
})));
|
|
1507
1392
|
}
|
|
@@ -1509,7 +1394,7 @@ function ScreenStates(_ref) {
|
|
|
1509
1394
|
ScreenStates.propTypes = propTypes$c;
|
|
1510
1395
|
ScreenStates.defaultProps = defaultProps$c;
|
|
1511
1396
|
|
|
1512
|
-
var styles$8 = {"container":"micromag-editor-preview-container","
|
|
1397
|
+
var styles$8 = {"container":"micromag-editor-preview-container","story":"micromag-editor-preview-story","noStory":"micromag-editor-preview-noStory","inner":"micromag-editor-preview-inner","top":"micromag-editor-preview-top","bottom":"micromag-editor-preview-bottom","preview":"micromag-editor-preview-preview","viewerContainer":"micromag-editor-preview-viewerContainer","devices":"micromag-editor-preview-devices","screen-medium":"micromag-editor-preview-screen-medium"};
|
|
1513
1398
|
|
|
1514
1399
|
var propTypes$b = {
|
|
1515
1400
|
value: PropTypes__default["default"].oneOfType([core.PropTypes.story, core.PropTypes.theme]),
|
|
@@ -1541,44 +1426,39 @@ var defaultProps$b = {
|
|
|
1541
1426
|
onChange: null,
|
|
1542
1427
|
withoutDevicesSizes: true
|
|
1543
1428
|
};
|
|
1544
|
-
|
|
1545
1429
|
var EditorPreview = function EditorPreview(_ref) {
|
|
1546
1430
|
var _ref8;
|
|
1547
|
-
|
|
1548
1431
|
var value = _ref.value,
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1432
|
+
viewerTheme = _ref.viewerTheme,
|
|
1433
|
+
isTheme = _ref.isTheme,
|
|
1434
|
+
devices = _ref.devices,
|
|
1435
|
+
initialDevice = _ref.device,
|
|
1436
|
+
className = _ref.className,
|
|
1437
|
+
onScreenChange = _ref.onScreenChange,
|
|
1438
|
+
onChange = _ref.onChange,
|
|
1439
|
+
withoutDevicesSizes = _ref.withoutDevicesSizes;
|
|
1558
1440
|
var _useRouteParams = useRouteParams(),
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1441
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
1442
|
+
screenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
1443
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
1444
|
+
fieldParam = _useRouteParams$field === void 0 ? null : _useRouteParams$field;
|
|
1564
1445
|
var _useScreenSize = contexts.useScreenSize(),
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1446
|
+
_useScreenSize$screen = _useScreenSize.screen,
|
|
1447
|
+
screen = _useScreenSize$screen === void 0 ? null : _useScreenSize$screen,
|
|
1448
|
+
_useScreenSize$screen2 = _useScreenSize.screens,
|
|
1449
|
+
screens = _useScreenSize$screen2 === void 0 ? [] : _useScreenSize$screen2;
|
|
1450
|
+
var valueWithTheme = useThemeValue(value, isTheme);
|
|
1451
|
+
// const valueParsed = valueWithTheme;
|
|
1572
1452
|
var valueParsed = hooks.useParsedStory(valueWithTheme, {
|
|
1573
1453
|
withTheme: isTheme,
|
|
1574
1454
|
withMedias: false
|
|
1575
|
-
});
|
|
1455
|
+
});
|
|
1576
1456
|
|
|
1457
|
+
// Get device
|
|
1577
1458
|
var _useState = React.useState(initialDevice || devices[0].id),
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1459
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1460
|
+
deviceId = _useState2[0],
|
|
1461
|
+
setDeviceId = _useState2[1];
|
|
1582
1462
|
var onClickDeviceItem = React.useCallback(function (e, it) {
|
|
1583
1463
|
return setDeviceId(it.id);
|
|
1584
1464
|
}, [setDeviceId]);
|
|
@@ -1586,62 +1466,54 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1586
1466
|
return devices.find(function (it) {
|
|
1587
1467
|
return it.id === deviceId;
|
|
1588
1468
|
});
|
|
1589
|
-
}, [devices, deviceId]);
|
|
1469
|
+
}, [devices, deviceId]);
|
|
1590
1470
|
|
|
1471
|
+
// Calculate preview style
|
|
1591
1472
|
var _useDimensionObserver = hooks.useDimensionObserver(),
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1473
|
+
bottomRef = _useDimensionObserver.ref,
|
|
1474
|
+
_useDimensionObserver2 = _useDimensionObserver.width,
|
|
1475
|
+
bottomWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2,
|
|
1476
|
+
_useDimensionObserver3 = _useDimensionObserver.height,
|
|
1477
|
+
bottomHeight = _useDimensionObserver3 === void 0 ? 0 : _useDimensionObserver3;
|
|
1598
1478
|
var previewStyle = React.useMemo(function () {
|
|
1599
1479
|
if (withoutDevicesSizes && initialDevice === null) {
|
|
1600
1480
|
return {};
|
|
1601
1481
|
}
|
|
1602
|
-
|
|
1603
1482
|
var deviceWidth = device.width,
|
|
1604
|
-
|
|
1483
|
+
deviceHeight = device.height;
|
|
1605
1484
|
var maxWidth = screen === 'mobile' ? bottomWidth : deviceWidth;
|
|
1606
1485
|
var maxHeight = screen === 'mobile' ? bottomHeight : deviceHeight;
|
|
1607
|
-
|
|
1608
1486
|
var _getSizeWithinBounds = size.getSizeWithinBounds(maxWidth, maxHeight, bottomWidth, bottomHeight),
|
|
1609
|
-
|
|
1610
|
-
|
|
1487
|
+
previewScale = _getSizeWithinBounds.scale;
|
|
1611
1488
|
return {
|
|
1612
1489
|
width: maxWidth * previewScale,
|
|
1613
|
-
height: maxHeight * previewScale
|
|
1614
|
-
|
|
1490
|
+
height: maxHeight * previewScale
|
|
1491
|
+
// transform: `scale(${previewScale}, ${previewScale})`,
|
|
1615
1492
|
};
|
|
1616
1493
|
}, [device, bottomWidth, bottomHeight, screen, withoutDevicesSizes, initialDevice]);
|
|
1617
1494
|
var currentScreen = React.useMemo(function () {
|
|
1618
1495
|
var _ref2 = valueParsed || {},
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1496
|
+
_ref2$components = _ref2.components,
|
|
1497
|
+
components = _ref2$components === void 0 ? [] : _ref2$components;
|
|
1622
1498
|
return (screenId !== null ? components.find(function (_ref3) {
|
|
1623
1499
|
var id = _ref3.id;
|
|
1624
1500
|
return id === screenId;
|
|
1625
1501
|
}) : components[0]) || null;
|
|
1626
1502
|
}, [valueParsed, screenId]);
|
|
1627
1503
|
var currentScreenStates = useScreenStates(currentScreen);
|
|
1628
|
-
|
|
1629
1504
|
var _ref4 = fieldParam !== null && currentScreenStates !== null ? fieldParam.split('/') : [],
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1505
|
+
_ref5 = _slicedToArray__default["default"](_ref4, 1),
|
|
1506
|
+
_ref5$ = _ref5[0],
|
|
1507
|
+
screenStateParam = _ref5$ === void 0 ? null : _ref5$;
|
|
1634
1508
|
var currentScreenState = screenStateParam !== null ? currentScreenStates.find(function (_ref6) {
|
|
1635
1509
|
var id = _ref6.id;
|
|
1636
1510
|
return id === screenStateParam;
|
|
1637
1511
|
}) || null : null;
|
|
1638
|
-
|
|
1639
1512
|
var _ref7 = currentScreenState || {},
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1513
|
+
_ref7$id = _ref7.id,
|
|
1514
|
+
screenStateId = _ref7$id === void 0 ? null : _ref7$id,
|
|
1515
|
+
_ref7$repeatable = _ref7.repeatable,
|
|
1516
|
+
repeatable = _ref7$repeatable === void 0 ? false : _ref7$repeatable;
|
|
1645
1517
|
var currentScreenStateId = currentScreenState !== null && repeatable ? "".concat(screenStateId, ".").concat(fieldParam.split('/').find(function (it) {
|
|
1646
1518
|
return it.match(/^[0-9]+$/) !== null;
|
|
1647
1519
|
}) || 0) : screenStateId;
|
|
@@ -1694,13 +1566,12 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1694
1566
|
className: styles$8.devices
|
|
1695
1567
|
})) : null));
|
|
1696
1568
|
};
|
|
1697
|
-
|
|
1698
1569
|
EditorPreview.propTypes = propTypes$b;
|
|
1699
1570
|
EditorPreview.defaultProps = defaultProps$b;
|
|
1700
1571
|
|
|
1701
1572
|
var styles$7 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
1702
1573
|
|
|
1703
|
-
var styles$6 = {"container":"micromag-editor-menus-screens-container","
|
|
1574
|
+
var styles$6 = {"container":"micromag-editor-menus-screens-container","screen":"micromag-editor-menus-screens-screen","preview":"micromag-editor-menus-screens-preview","placeholder":"micromag-editor-menus-screens-placeholder","items":"micromag-editor-menus-screens-items","item":"micromag-editor-menus-screens-item","button":"micromag-editor-menus-screens-button","settings":"micromag-editor-menus-screens-settings","noWrap":"micromag-editor-menus-screens-noWrap","isVertical":"micromag-editor-menus-screens-isVertical","withPlaceholder":"micromag-editor-menus-screens-withPlaceholder"};
|
|
1704
1575
|
|
|
1705
1576
|
var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
1706
1577
|
function getDragDepth(offset, indentationWidth) {
|
|
@@ -1708,22 +1579,18 @@ function getDragDepth(offset, indentationWidth) {
|
|
|
1708
1579
|
}
|
|
1709
1580
|
function getMaxDepth(_ref) {
|
|
1710
1581
|
var previousItem = _ref.previousItem;
|
|
1711
|
-
|
|
1712
1582
|
if (previousItem) {
|
|
1713
1583
|
// return previousItem.depth + 1;
|
|
1714
1584
|
return 1;
|
|
1715
1585
|
}
|
|
1716
|
-
|
|
1717
1586
|
return 0;
|
|
1718
1587
|
}
|
|
1719
1588
|
function getMinDepth(_ref2) {
|
|
1720
1589
|
var nextItem = _ref2.nextItem;
|
|
1721
|
-
|
|
1722
1590
|
if (nextItem) {
|
|
1723
1591
|
// return nextItem.depth;
|
|
1724
1592
|
return 0;
|
|
1725
1593
|
}
|
|
1726
|
-
|
|
1727
1594
|
return 0;
|
|
1728
1595
|
}
|
|
1729
1596
|
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
@@ -1748,34 +1615,27 @@ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
|
1748
1615
|
nextItem: nextItem
|
|
1749
1616
|
});
|
|
1750
1617
|
var depth = projectedDepth;
|
|
1751
|
-
|
|
1752
1618
|
if (projectedDepth >= maxDepth) {
|
|
1753
1619
|
depth = maxDepth;
|
|
1754
1620
|
} else if (projectedDepth < minDepth) {
|
|
1755
1621
|
depth = minDepth;
|
|
1756
1622
|
}
|
|
1757
|
-
|
|
1758
1623
|
function getParentId() {
|
|
1759
1624
|
var _newItems$slice$rever;
|
|
1760
|
-
|
|
1761
1625
|
if (depth === 0 || !previousItem) {
|
|
1762
1626
|
return null;
|
|
1763
1627
|
}
|
|
1764
|
-
|
|
1765
1628
|
if (depth === previousItem.depth) {
|
|
1766
1629
|
return previousItem.parentId;
|
|
1767
1630
|
}
|
|
1768
|
-
|
|
1769
1631
|
if (depth > previousItem.depth) {
|
|
1770
1632
|
return previousItem.id;
|
|
1771
1633
|
}
|
|
1772
|
-
|
|
1773
1634
|
var newParent = (_newItems$slice$rever = newItems.slice(0, overItemIndex).reverse().find(function (item) {
|
|
1774
1635
|
return item.depth === depth;
|
|
1775
1636
|
})) === null || _newItems$slice$rever === void 0 ? void 0 : _newItems$slice$rever.parentId;
|
|
1776
1637
|
return newParent !== null && newParent !== void 0 ? newParent : null;
|
|
1777
1638
|
}
|
|
1778
|
-
|
|
1779
1639
|
return {
|
|
1780
1640
|
depth: depth,
|
|
1781
1641
|
maxDepth: maxDepth,
|
|
@@ -1783,7 +1643,6 @@ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
|
1783
1643
|
parentId: getParentId()
|
|
1784
1644
|
};
|
|
1785
1645
|
}
|
|
1786
|
-
|
|
1787
1646
|
function flatten(items) {
|
|
1788
1647
|
var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1789
1648
|
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -1792,11 +1651,9 @@ function flatten(items) {
|
|
|
1792
1651
|
parentId: item.parentId || parentId,
|
|
1793
1652
|
depth: item.parentId ? 1 : 0,
|
|
1794
1653
|
index: index // For some reason this aint enough
|
|
1795
|
-
|
|
1796
1654
|
})], _toConsumableArray__default["default"](flatten(item.children || [], item.id, depth + 1)));
|
|
1797
1655
|
}, []);
|
|
1798
1656
|
}
|
|
1799
|
-
|
|
1800
1657
|
function flattenTree(items) {
|
|
1801
1658
|
return flatten(items);
|
|
1802
1659
|
}
|
|
@@ -1811,36 +1668,30 @@ function buildTree(flattenedItems) {
|
|
|
1811
1668
|
id: 'root',
|
|
1812
1669
|
children: []
|
|
1813
1670
|
};
|
|
1814
|
-
|
|
1815
1671
|
var nodes = _defineProperty__default["default"]({}, root.id, root);
|
|
1816
|
-
|
|
1817
1672
|
var items = flattenedItems.map(function (item) {
|
|
1818
1673
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
|
|
1819
1674
|
children: []
|
|
1820
1675
|
});
|
|
1821
|
-
});
|
|
1822
|
-
|
|
1823
|
-
var indexes = {};
|
|
1824
|
-
|
|
1676
|
+
});
|
|
1677
|
+
// console.log('BUILD');
|
|
1678
|
+
var indexes = {};
|
|
1679
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1825
1680
|
var _iterator = _createForOfIteratorHelper__default["default"](items),
|
|
1826
|
-
|
|
1827
|
-
|
|
1681
|
+
_step;
|
|
1828
1682
|
try {
|
|
1829
1683
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1830
1684
|
var _item$parentId, _nodes$parentId;
|
|
1831
|
-
|
|
1832
1685
|
var item = _step.value;
|
|
1833
1686
|
var id = item.id,
|
|
1834
|
-
|
|
1687
|
+
children = item.children;
|
|
1835
1688
|
var parentId = (_item$parentId = item.parentId) !== null && _item$parentId !== void 0 ? _item$parentId : root.id;
|
|
1836
1689
|
var parent = (_nodes$parentId = nodes[parentId]) !== null && _nodes$parentId !== void 0 ? _nodes$parentId : findItem(items, parentId);
|
|
1837
|
-
|
|
1838
1690
|
if (typeof indexes[parentId] !== 'undefined') {
|
|
1839
1691
|
indexes[parentId] += 1;
|
|
1840
1692
|
} else {
|
|
1841
1693
|
indexes[parentId] = 0;
|
|
1842
1694
|
}
|
|
1843
|
-
|
|
1844
1695
|
nodes[id] = {
|
|
1845
1696
|
id: id,
|
|
1846
1697
|
children: children,
|
|
@@ -1855,50 +1706,42 @@ function buildTree(flattenedItems) {
|
|
|
1855
1706
|
} finally {
|
|
1856
1707
|
_iterator.f();
|
|
1857
1708
|
}
|
|
1858
|
-
|
|
1859
1709
|
return root.children;
|
|
1860
1710
|
}
|
|
1861
1711
|
function findItemDeep(items, itemId) {
|
|
1862
1712
|
for (var i = 0; i < items.length; i += 1) {
|
|
1863
1713
|
var item = items[i] || {};
|
|
1864
1714
|
var id = item.id,
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1715
|
+
_item$children = item.children,
|
|
1716
|
+
children = _item$children === void 0 ? [] : _item$children;
|
|
1868
1717
|
if (id === itemId) {
|
|
1869
1718
|
return item;
|
|
1870
1719
|
}
|
|
1871
|
-
|
|
1872
1720
|
if (children.length > 0) {
|
|
1873
1721
|
var child = findItemDeep(children, itemId);
|
|
1874
|
-
|
|
1875
1722
|
if (child) {
|
|
1876
1723
|
return child;
|
|
1877
1724
|
}
|
|
1878
1725
|
}
|
|
1879
1726
|
}
|
|
1880
|
-
|
|
1881
1727
|
return undefined;
|
|
1882
1728
|
}
|
|
1883
1729
|
function removeItem(items, id) {
|
|
1884
|
-
var newItems = [];
|
|
1730
|
+
var newItems = [];
|
|
1885
1731
|
|
|
1732
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1886
1733
|
var _iterator2 = _createForOfIteratorHelper__default["default"](items),
|
|
1887
|
-
|
|
1888
|
-
|
|
1734
|
+
_step2;
|
|
1889
1735
|
try {
|
|
1890
1736
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1891
1737
|
var item = _step2.value;
|
|
1892
|
-
|
|
1893
1738
|
if (item.id === id) {
|
|
1894
1739
|
// eslint-disable-next-line no-continue
|
|
1895
1740
|
continue;
|
|
1896
1741
|
}
|
|
1897
|
-
|
|
1898
1742
|
if (item.children.length) {
|
|
1899
1743
|
item.children = removeItem(item.children, id);
|
|
1900
1744
|
}
|
|
1901
|
-
|
|
1902
1745
|
newItems.push(item);
|
|
1903
1746
|
}
|
|
1904
1747
|
} catch (err) {
|
|
@@ -1906,24 +1749,20 @@ function removeItem(items, id) {
|
|
|
1906
1749
|
} finally {
|
|
1907
1750
|
_iterator2.f();
|
|
1908
1751
|
}
|
|
1909
|
-
|
|
1910
1752
|
return newItems;
|
|
1911
1753
|
}
|
|
1912
1754
|
function setProperty(items, id, property, setter) {
|
|
1913
1755
|
// eslint-disable-next-line no-restricted-syntax
|
|
1914
1756
|
var _iterator3 = _createForOfIteratorHelper__default["default"](items),
|
|
1915
|
-
|
|
1916
|
-
|
|
1757
|
+
_step3;
|
|
1917
1758
|
try {
|
|
1918
1759
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1919
1760
|
var item = _step3.value;
|
|
1920
|
-
|
|
1921
1761
|
if (item.id === id) {
|
|
1922
|
-
item[property] = setter(item[property]);
|
|
1923
|
-
|
|
1762
|
+
item[property] = setter(item[property]);
|
|
1763
|
+
// eslint-disable-next-line no-continue
|
|
1924
1764
|
continue;
|
|
1925
1765
|
}
|
|
1926
|
-
|
|
1927
1766
|
if (item.children.length) {
|
|
1928
1767
|
item.children = setProperty(item.children, id, property, setter);
|
|
1929
1768
|
}
|
|
@@ -1933,47 +1772,37 @@ function setProperty(items, id, property, setter) {
|
|
|
1933
1772
|
} finally {
|
|
1934
1773
|
_iterator3.f();
|
|
1935
1774
|
}
|
|
1936
|
-
|
|
1937
1775
|
return _toConsumableArray__default["default"](items);
|
|
1938
1776
|
}
|
|
1939
|
-
|
|
1940
1777
|
function countChildren(items) {
|
|
1941
1778
|
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1942
1779
|
return items.reduce(function (acc, _ref6) {
|
|
1943
1780
|
var _ref6$children = _ref6.children,
|
|
1944
|
-
|
|
1945
|
-
|
|
1781
|
+
children = _ref6$children === void 0 ? [] : _ref6$children;
|
|
1946
1782
|
if (children.length) {
|
|
1947
1783
|
return countChildren(children, acc + 1);
|
|
1948
1784
|
}
|
|
1949
|
-
|
|
1950
1785
|
return acc + 1;
|
|
1951
1786
|
}, count);
|
|
1952
1787
|
}
|
|
1953
|
-
|
|
1954
1788
|
function getChildCount(items, id) {
|
|
1955
1789
|
if (!id) {
|
|
1956
1790
|
return 0;
|
|
1957
1791
|
}
|
|
1958
|
-
|
|
1959
1792
|
var item = findItemDeep(items, id);
|
|
1960
1793
|
return item ? countChildren(item.children || []) : 0;
|
|
1961
1794
|
}
|
|
1962
1795
|
function removeChildrenOf(items, ids) {
|
|
1963
1796
|
var excludeParentIds = _toConsumableArray__default["default"](ids);
|
|
1964
|
-
|
|
1965
1797
|
return items.filter(function (item) {
|
|
1966
1798
|
if (item.parentId && excludeParentIds.includes(item.parentId)) {
|
|
1967
1799
|
var _item$children2 = item.children,
|
|
1968
|
-
|
|
1969
|
-
|
|
1800
|
+
children = _item$children2 === void 0 ? [] : _item$children2;
|
|
1970
1801
|
if (children.length) {
|
|
1971
1802
|
excludeParentIds.push(item.id);
|
|
1972
1803
|
}
|
|
1973
|
-
|
|
1974
1804
|
return false;
|
|
1975
1805
|
}
|
|
1976
|
-
|
|
1977
1806
|
return true;
|
|
1978
1807
|
});
|
|
1979
1808
|
}
|
|
@@ -1983,30 +1812,25 @@ var horizontal = [core$1.KeyboardCode.Left, core$1.KeyboardCode.Right];
|
|
|
1983
1812
|
var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(context, indentationWidth) {
|
|
1984
1813
|
return function (event, _ref) {
|
|
1985
1814
|
var currentCoordinates = _ref.currentCoordinates,
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1815
|
+
_ref$context = _ref.context,
|
|
1816
|
+
active = _ref$context.active,
|
|
1817
|
+
over = _ref$context.over,
|
|
1818
|
+
collisionRect = _ref$context.collisionRect,
|
|
1819
|
+
droppableContainers = _ref$context.droppableContainers;
|
|
1992
1820
|
if (directions.includes(event.code)) {
|
|
1993
1821
|
var _droppableContainers$;
|
|
1994
|
-
|
|
1995
1822
|
if (!active || !collisionRect) {
|
|
1996
1823
|
return;
|
|
1997
1824
|
}
|
|
1998
|
-
|
|
1999
1825
|
event.preventDefault();
|
|
2000
1826
|
var _context$current = context.current,
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
1827
|
+
items = _context$current.items,
|
|
1828
|
+
offset = _context$current.offset;
|
|
2004
1829
|
if (horizontal.includes(event.code) && over !== null && over !== void 0 && over.id) {
|
|
2005
1830
|
var _getProjection = getProjection(items, active.id, over.id, offset, indentationWidth),
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1831
|
+
depth = _getProjection.depth,
|
|
1832
|
+
maxDepth = _getProjection.maxDepth,
|
|
1833
|
+
minDepth = _getProjection.minDepth;
|
|
2010
1834
|
switch (event.code) {
|
|
2011
1835
|
case core$1.KeyboardCode.Left:
|
|
2012
1836
|
if (depth > minDepth) {
|
|
@@ -2014,55 +1838,42 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2014
1838
|
x: currentCoordinates.x - indentationWidth
|
|
2015
1839
|
});
|
|
2016
1840
|
}
|
|
2017
|
-
|
|
2018
1841
|
break;
|
|
2019
|
-
|
|
2020
1842
|
case core$1.KeyboardCode.Right:
|
|
2021
1843
|
if (depth < maxDepth) {
|
|
2022
1844
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, currentCoordinates), {}, {
|
|
2023
1845
|
x: currentCoordinates.x + indentationWidth
|
|
2024
1846
|
});
|
|
2025
1847
|
}
|
|
2026
|
-
|
|
2027
1848
|
break;
|
|
2028
|
-
|
|
2029
1849
|
default:
|
|
2030
1850
|
return undefined;
|
|
2031
1851
|
}
|
|
2032
|
-
|
|
2033
1852
|
return undefined;
|
|
2034
1853
|
}
|
|
2035
|
-
|
|
2036
1854
|
var containers = [];
|
|
2037
1855
|
var overRect = over !== null && over !== void 0 && over.id ? (_droppableContainers$ = droppableContainers.get(over.id)) === null || _droppableContainers$ === void 0 ? void 0 : _droppableContainers$.rect.current : undefined;
|
|
2038
|
-
|
|
2039
1856
|
if (overRect) {
|
|
2040
1857
|
droppableContainers.forEach(function (container) {
|
|
2041
1858
|
if (container !== null && container !== void 0 && container.disabled) {
|
|
2042
1859
|
return;
|
|
2043
1860
|
}
|
|
2044
|
-
|
|
2045
1861
|
var rect = container === null || container === void 0 ? void 0 : container.rect.current;
|
|
2046
|
-
|
|
2047
1862
|
if (!rect) {
|
|
2048
1863
|
return;
|
|
2049
1864
|
}
|
|
2050
|
-
|
|
2051
1865
|
switch (event.code) {
|
|
2052
1866
|
case core$1.KeyboardCode.Down:
|
|
2053
1867
|
if (overRect.top < rect.top) {
|
|
2054
1868
|
containers.push(container);
|
|
2055
1869
|
}
|
|
2056
|
-
|
|
2057
1870
|
break;
|
|
2058
|
-
|
|
2059
1871
|
case core$1.KeyboardCode.Up:
|
|
2060
1872
|
if (overRect.top > rect.top) {
|
|
2061
1873
|
containers.push(container);
|
|
2062
1874
|
}
|
|
2063
|
-
|
|
2064
1875
|
break;
|
|
2065
|
-
|
|
1876
|
+
//
|
|
2066
1877
|
}
|
|
2067
1878
|
});
|
|
2068
1879
|
}
|
|
@@ -2074,13 +1885,10 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2074
1885
|
droppableContainers: containers
|
|
2075
1886
|
});
|
|
2076
1887
|
var closestId = core$1.getFirstCollision(collisions, 'id');
|
|
2077
|
-
|
|
2078
1888
|
if (closestId && over !== null && over !== void 0 && over.id) {
|
|
2079
1889
|
var _droppableContainers$2, _droppableContainers$3;
|
|
2080
|
-
|
|
2081
1890
|
var newNode = (_droppableContainers$2 = droppableContainers.get(closestId)) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.node.current;
|
|
2082
1891
|
var activeNodeRect = (_droppableContainers$3 = droppableContainers.get(active.id)) === null || _droppableContainers$3 === void 0 ? void 0 : _droppableContainers$3.rect.current;
|
|
2083
|
-
|
|
2084
1892
|
if (newNode && activeNodeRect) {
|
|
2085
1893
|
var newRect = core$1.getClientRect(newNode, {
|
|
2086
1894
|
ignoreTransform: true
|
|
@@ -2093,11 +1901,9 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2093
1901
|
var id = _ref3.id;
|
|
2094
1902
|
return id === active.id;
|
|
2095
1903
|
});
|
|
2096
|
-
|
|
2097
1904
|
if (newItem && activeItem) {
|
|
2098
1905
|
var _getProjection2 = getProjection(items, active.id, closestId, (newItem.depth - activeItem.depth) * indentationWidth, indentationWidth),
|
|
2099
|
-
|
|
2100
|
-
|
|
1906
|
+
_depth = _getProjection2.depth;
|
|
2101
1907
|
var topOffset = newRect.top > activeNodeRect.top ? Math.abs(activeNodeRect.height - newRect.height) : 0;
|
|
2102
1908
|
var newCoordinates = {
|
|
2103
1909
|
x: newRect.left + _depth * indentationWidth,
|
|
@@ -2108,14 +1914,13 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2108
1914
|
}
|
|
2109
1915
|
}
|
|
2110
1916
|
}
|
|
2111
|
-
|
|
2112
1917
|
return undefined;
|
|
2113
1918
|
};
|
|
2114
1919
|
};
|
|
2115
1920
|
|
|
2116
1921
|
var styles$5 = {"container":"micromag-editor-sortable-sortable-tree-item-container","parent":"micromag-editor-sortable-sortable-tree-item-parent","child":"micromag-editor-sortable-sortable-tree-item-child"};
|
|
2117
1922
|
|
|
2118
|
-
var styles$4 = {"wrapper":"micromag-editor-sortable-sortable-tree-item-actions-wrapper","inner":"micromag-editor-sortable-sortable-tree-item-actions-inner","button":"micromag-editor-sortable-sortable-tree-item-actions-button","handle":"micromag-editor-sortable-sortable-tree-item-actions-handle","icon":"micromag-editor-sortable-sortable-tree-item-actions-icon","text":"micromag-editor-sortable-sortable-tree-item-actions-text","
|
|
1923
|
+
var styles$4 = {"wrapper":"micromag-editor-sortable-sortable-tree-item-actions-wrapper","inner":"micromag-editor-sortable-sortable-tree-item-actions-inner","button":"micromag-editor-sortable-sortable-tree-item-actions-button","handle":"micromag-editor-sortable-sortable-tree-item-actions-handle","icon":"micromag-editor-sortable-sortable-tree-item-actions-icon","text":"micromag-editor-sortable-sortable-tree-item-actions-text","count":"micromag-editor-sortable-sortable-tree-item-actions-count","collapsedCount":"micromag-editor-sortable-sortable-tree-item-actions-collapsedCount","disableInteraction":"micromag-editor-sortable-sortable-tree-item-actions-disableInteraction","disableSelection":"micromag-editor-sortable-sortable-tree-item-actions-disableSelection","clone":"micromag-editor-sortable-sortable-tree-item-actions-clone","collapse":"micromag-editor-sortable-sortable-tree-item-actions-collapse","collapsed":"micromag-editor-sortable-sortable-tree-item-actions-collapsed","children":"micromag-editor-sortable-sortable-tree-item-actions-children","withChildren":"micromag-editor-sortable-sortable-tree-item-actions-withChildren","ghost":"micromag-editor-sortable-sortable-tree-item-actions-ghost","indicator":"micromag-editor-sortable-sortable-tree-item-actions-indicator"};
|
|
2119
1924
|
|
|
2120
1925
|
var _excluded$4 = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "onClick", "style", "value", "wrapperRef", "showId", "showCount", "showCollapsedCount", "children"];
|
|
2121
1926
|
var propTypes$a = {
|
|
@@ -2168,29 +1973,27 @@ var defaultProps$a = {
|
|
|
2168
1973
|
};
|
|
2169
1974
|
var SortableTreeItemActions = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
2170
1975
|
var _ref2;
|
|
2171
|
-
|
|
2172
1976
|
var childCount = _ref.childCount,
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
1977
|
+
clone = _ref.clone,
|
|
1978
|
+
depth = _ref.depth,
|
|
1979
|
+
disableSelection = _ref.disableSelection,
|
|
1980
|
+
disableInteraction = _ref.disableInteraction,
|
|
1981
|
+
ghost = _ref.ghost,
|
|
1982
|
+
handleProps = _ref.handleProps,
|
|
1983
|
+
indentationWidth = _ref.indentationWidth,
|
|
1984
|
+
indicator = _ref.indicator,
|
|
1985
|
+
collapsed = _ref.collapsed,
|
|
1986
|
+
onCollapse = _ref.onCollapse,
|
|
1987
|
+
onRemove = _ref.onRemove;
|
|
1988
|
+
_ref.onClick;
|
|
1989
|
+
var style = _ref.style;
|
|
1990
|
+
_ref.value;
|
|
1991
|
+
var wrapperRef = _ref.wrapperRef;
|
|
1992
|
+
_ref.showId;
|
|
1993
|
+
var showCount = _ref.showCount,
|
|
1994
|
+
showCollapsedCount = _ref.showCollapsedCount,
|
|
1995
|
+
children = _ref.children,
|
|
1996
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
|
|
2194
1997
|
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
2195
1998
|
className: classNames__default["default"]([styles$4.wrapper, (_ref2 = {}, _defineProperty__default["default"](_ref2, styles$4.clone, clone), _defineProperty__default["default"](_ref2, styles$4.ghost, ghost), _defineProperty__default["default"](_ref2, styles$4.indicator, indicator), _defineProperty__default["default"](_ref2, styles$4.disableSelection, disableSelection), _defineProperty__default["default"](_ref2, styles$4.disableInteraction, disableInteraction), _defineProperty__default["default"](_ref2, styles$4.withChildren, onCollapse !== null), _ref2)]),
|
|
2196
1999
|
ref: wrapperRef,
|
|
@@ -2265,65 +2068,57 @@ var defaultProps$9 = {
|
|
|
2265
2068
|
childValue: null,
|
|
2266
2069
|
isLastChild: false
|
|
2267
2070
|
};
|
|
2268
|
-
|
|
2269
2071
|
var animateLayoutChanges = function animateLayoutChanges(_ref) {
|
|
2270
2072
|
var isSorting = _ref.isSorting,
|
|
2271
|
-
|
|
2073
|
+
wasDragging = _ref.wasDragging;
|
|
2272
2074
|
return !(isSorting || wasDragging);
|
|
2273
2075
|
};
|
|
2274
|
-
|
|
2275
2076
|
var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
2276
2077
|
var id = _ref2.id,
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2078
|
+
index = _ref2.index,
|
|
2079
|
+
depth = _ref2.depth,
|
|
2080
|
+
Component = _ref2.component,
|
|
2081
|
+
value = _ref2.value;
|
|
2082
|
+
_ref2.style;
|
|
2083
|
+
_ref2.smallScale;
|
|
2084
|
+
var collapsed = _ref2.collapsed,
|
|
2085
|
+
onCollapse = _ref2.onCollapse,
|
|
2086
|
+
onClickItem = _ref2.onClickItem,
|
|
2087
|
+
childValue = _ref2.childValue;
|
|
2088
|
+
_ref2.isLastChild;
|
|
2089
|
+
var props = _objectWithoutProperties__default["default"](_ref2, _excluded$3);
|
|
2290
2090
|
var _useSortable = sortable.useSortable({
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2091
|
+
id: id,
|
|
2092
|
+
animateLayoutChanges: animateLayoutChanges
|
|
2093
|
+
}),
|
|
2094
|
+
attributes = _useSortable.attributes,
|
|
2095
|
+
isDragging = _useSortable.isDragging,
|
|
2096
|
+
isSorting = _useSortable.isSorting,
|
|
2097
|
+
listeners = _useSortable.listeners,
|
|
2098
|
+
setDraggableNodeRef = _useSortable.setDraggableNodeRef,
|
|
2099
|
+
setDroppableNodeRef = _useSortable.setDroppableNodeRef,
|
|
2100
|
+
transform = _useSortable.transform,
|
|
2101
|
+
transition = _useSortable.transition;
|
|
2303
2102
|
var timeout = React.useRef(null);
|
|
2304
2103
|
var actionsStyle = {
|
|
2305
2104
|
transform: utilities.CSS.Translate.toString(transform),
|
|
2306
2105
|
transition: transition
|
|
2307
2106
|
};
|
|
2308
|
-
|
|
2309
2107
|
var _ref3 = listeners || {},
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2108
|
+
_ref3$onPointerDown = _ref3.onPointerDown,
|
|
2109
|
+
onPointerDown = _ref3$onPointerDown === void 0 ? null : _ref3$onPointerDown,
|
|
2110
|
+
_ref3$onPointerUp = _ref3.onPointerUp,
|
|
2111
|
+
onPointerUp = _ref3$onPointerUp === void 0 ? null : _ref3$onPointerUp;
|
|
2315
2112
|
var onClickAction = React.useCallback(function (e) {
|
|
2316
2113
|
if (onClickItem !== null) {
|
|
2317
2114
|
onClickItem(value, index);
|
|
2318
2115
|
}
|
|
2319
|
-
|
|
2320
2116
|
if (onPointerDown !== null) {
|
|
2321
2117
|
e.persist();
|
|
2322
2118
|
timeout.current = setTimeout(function () {
|
|
2323
2119
|
if (onPointerDown !== null) {
|
|
2324
2120
|
onPointerDown(e);
|
|
2325
2121
|
}
|
|
2326
|
-
|
|
2327
2122
|
timeout.current = null;
|
|
2328
2123
|
}, 200);
|
|
2329
2124
|
}
|
|
@@ -2332,7 +2127,6 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
2332
2127
|
if (timeout.current !== null) {
|
|
2333
2128
|
clearTimeout(timeout.current);
|
|
2334
2129
|
}
|
|
2335
|
-
|
|
2336
2130
|
if (onPointerUp !== null) {
|
|
2337
2131
|
onPointerUp(e);
|
|
2338
2132
|
}
|
|
@@ -2359,7 +2153,6 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
2359
2153
|
className: styles$5.child
|
|
2360
2154
|
}, /*#__PURE__*/React__default["default"].createElement(Component, childValue)) : null));
|
|
2361
2155
|
};
|
|
2362
|
-
|
|
2363
2156
|
SortableTreeItem.propTypes = propTypes$9;
|
|
2364
2157
|
SortableTreeItem.defaultProps = defaultProps$9;
|
|
2365
2158
|
|
|
@@ -2389,18 +2182,15 @@ var measuring = {
|
|
|
2389
2182
|
strategy: core$1.MeasuringStrategy.Always
|
|
2390
2183
|
}
|
|
2391
2184
|
};
|
|
2392
|
-
|
|
2393
2185
|
var dropAnimation = _objectSpread__default["default"](_objectSpread__default["default"]({}, core$1.defaultDropAnimation), {}, {
|
|
2394
2186
|
dragSourceOpacity: 0.5
|
|
2395
2187
|
});
|
|
2396
|
-
|
|
2397
2188
|
var adjustTranslate = function adjustTranslate(_ref) {
|
|
2398
2189
|
var transform = _ref.transform;
|
|
2399
2190
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, transform), {}, {
|
|
2400
2191
|
y: transform.y - 25
|
|
2401
2192
|
});
|
|
2402
2193
|
};
|
|
2403
|
-
|
|
2404
2194
|
var propTypes$8 = {
|
|
2405
2195
|
collapsible: PropTypes__default["default"].bool,
|
|
2406
2196
|
// eslint-disable-next-line react/forbid-prop-types
|
|
@@ -2422,45 +2212,39 @@ var defaultProps$8 = {
|
|
|
2422
2212
|
onClickItem: null,
|
|
2423
2213
|
onChange: null
|
|
2424
2214
|
};
|
|
2425
|
-
|
|
2426
2215
|
var SortableTree = function SortableTree(_ref2) {
|
|
2427
2216
|
var collapsible = _ref2.collapsible,
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2217
|
+
defaultItems = _ref2.items,
|
|
2218
|
+
indicator = _ref2.indicator,
|
|
2219
|
+
indentationWidth = _ref2.indentationWidth,
|
|
2220
|
+
removable = _ref2.removable,
|
|
2221
|
+
component = _ref2.component,
|
|
2222
|
+
onClickItem = _ref2.onClickItem,
|
|
2223
|
+
onChange = _ref2.onChange;
|
|
2436
2224
|
var _useState = React.useState(function () {
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2225
|
+
return buildTree(defaultItems);
|
|
2226
|
+
}),
|
|
2227
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
2228
|
+
items = _useState2[0],
|
|
2229
|
+
setItems = _useState2[1];
|
|
2443
2230
|
var _useState3 = React.useState(null),
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2231
|
+
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
2232
|
+
activeId = _useState4[0],
|
|
2233
|
+
setActiveId = _useState4[1];
|
|
2448
2234
|
var _useState5 = React.useState(null),
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2235
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
2236
|
+
overId = _useState6[0],
|
|
2237
|
+
setOverId = _useState6[1];
|
|
2453
2238
|
var _useState7 = React.useState(0),
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2239
|
+
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
2240
|
+
offsetLeft = _useState8[0],
|
|
2241
|
+
setOffsetLeft = _useState8[1];
|
|
2458
2242
|
var _useState9 = React.useState(null),
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2243
|
+
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
2244
|
+
currentPosition = _useState10[0],
|
|
2245
|
+
setCurrentPosition = _useState10[1];
|
|
2463
2246
|
|
|
2247
|
+
// Tree setup from list
|
|
2464
2248
|
React.useEffect(function () {
|
|
2465
2249
|
var flat = flattenTree(items);
|
|
2466
2250
|
var merged = defaultItems.map(function (t1) {
|
|
@@ -2474,9 +2258,9 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2474
2258
|
var flattenedTree = flattenTree(items);
|
|
2475
2259
|
var collapsedItems = flattenedTree.reduce(function (acc, _ref3) {
|
|
2476
2260
|
var _ref3$children = _ref3.children,
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2261
|
+
children = _ref3$children === void 0 ? [] : _ref3$children,
|
|
2262
|
+
collapsed = _ref3.collapsed,
|
|
2263
|
+
id = _ref3.id;
|
|
2480
2264
|
return collapsed && children.length ? [].concat(_toConsumableArray__default["default"](acc), [id]) : acc;
|
|
2481
2265
|
}, []) || null;
|
|
2482
2266
|
return removeChildrenOf(flattenedTree, activeId ? [activeId].concat(_toConsumableArray__default["default"](collapsedItems)) : collapsedItems);
|
|
@@ -2486,13 +2270,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2486
2270
|
items: flattenedItems,
|
|
2487
2271
|
offset: offsetLeft
|
|
2488
2272
|
});
|
|
2489
|
-
|
|
2490
2273
|
var _useState11 = React.useState(function () {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2274
|
+
return sortableTreeKeyboardCoordinates(sensorContext, indentationWidth);
|
|
2275
|
+
}),
|
|
2276
|
+
_useState12 = _slicedToArray__default["default"](_useState11, 1),
|
|
2277
|
+
coordinateGetter = _useState12[0];
|
|
2496
2278
|
var sensors = core$1.useSensors(core$1.useSensor(core$1.PointerSensor), core$1.useSensor(core$1.KeyboardSensor, {
|
|
2497
2279
|
coordinateGetter: coordinateGetter
|
|
2498
2280
|
}));
|
|
@@ -2512,20 +2294,17 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2512
2294
|
offset: offsetLeft
|
|
2513
2295
|
};
|
|
2514
2296
|
}, [flattenedItems, offsetLeft]);
|
|
2515
|
-
|
|
2516
2297
|
function getMovementAnnouncement(eventName, currentActiveId, currentOverId) {
|
|
2517
2298
|
if (currentOverId && projected) {
|
|
2518
2299
|
if (eventName !== 'onDragEnd') {
|
|
2519
2300
|
if (currentPosition && projected.parentId === currentPosition.parentId && currentOverId === currentPosition.overId) {
|
|
2520
2301
|
return;
|
|
2521
2302
|
}
|
|
2522
|
-
|
|
2523
2303
|
setCurrentPosition({
|
|
2524
2304
|
parentId: projected.parentId,
|
|
2525
2305
|
overId: currentOverId
|
|
2526
2306
|
});
|
|
2527
2307
|
}
|
|
2528
|
-
|
|
2529
2308
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2530
2309
|
var overIndex = clonedItems.findIndex(function (_ref6) {
|
|
2531
2310
|
var id = _ref6.id;
|
|
@@ -2540,10 +2319,8 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2540
2319
|
var newAnnouncement;
|
|
2541
2320
|
var movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
2542
2321
|
var nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
2543
|
-
|
|
2544
2322
|
if (!previousItem) {
|
|
2545
2323
|
var nextItem = typeof sortedItems[overIndex + 1] !== 'undefined' ? sortedItems[overIndex + 1] : null;
|
|
2546
|
-
|
|
2547
2324
|
if (nextItem !== null) {
|
|
2548
2325
|
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " before ").concat(nextItem.id, ".");
|
|
2549
2326
|
}
|
|
@@ -2551,30 +2328,26 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2551
2328
|
newAnnouncement = "".concat(currentActiveId, " was ").concat(nestedVerb, " under ").concat(previousItem.id, ".");
|
|
2552
2329
|
} else {
|
|
2553
2330
|
var previousSibling = previousItem;
|
|
2554
|
-
|
|
2555
2331
|
var _loop = function _loop() {
|
|
2556
2332
|
var _previousSibling = previousSibling,
|
|
2557
|
-
|
|
2333
|
+
parentId = _previousSibling.parentId;
|
|
2558
2334
|
previousSibling = sortedItems.find(function (_ref8) {
|
|
2559
2335
|
var id = _ref8.id;
|
|
2560
2336
|
return id === parentId;
|
|
2561
2337
|
});
|
|
2562
2338
|
};
|
|
2563
|
-
|
|
2564
2339
|
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
2565
2340
|
_loop();
|
|
2566
2341
|
}
|
|
2567
|
-
|
|
2568
2342
|
if (previousSibling) {
|
|
2569
2343
|
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " after ").concat(previousSibling.id, ".");
|
|
2570
2344
|
}
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2345
|
+
}
|
|
2573
2346
|
|
|
2347
|
+
// eslint-disable-next-line consistent-return
|
|
2574
2348
|
return newAnnouncement;
|
|
2575
2349
|
}
|
|
2576
2350
|
}
|
|
2577
|
-
|
|
2578
2351
|
var announcements = React.useMemo(function () {
|
|
2579
2352
|
return {
|
|
2580
2353
|
onDragStart: function onDragStart(id) {
|
|
@@ -2596,7 +2369,7 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2596
2369
|
}, [getMovementAnnouncement]);
|
|
2597
2370
|
var activeValue = defaultItems.find(function (_ref9) {
|
|
2598
2371
|
var _ref9$id = _ref9.id,
|
|
2599
|
-
|
|
2372
|
+
defaultId = _ref9$id === void 0 ? null : _ref9$id;
|
|
2600
2373
|
return defaultId === activeId;
|
|
2601
2374
|
});
|
|
2602
2375
|
var handleDragStart = React.useCallback(function (_ref10) {
|
|
@@ -2607,14 +2380,12 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2607
2380
|
var id = _ref11.id;
|
|
2608
2381
|
return id === newActiveId;
|
|
2609
2382
|
});
|
|
2610
|
-
|
|
2611
2383
|
if (newActiveItem) {
|
|
2612
2384
|
setCurrentPosition({
|
|
2613
2385
|
parentId: newActiveItem.parentId,
|
|
2614
2386
|
overId: activeId
|
|
2615
2387
|
});
|
|
2616
2388
|
}
|
|
2617
|
-
|
|
2618
2389
|
document.body.style.setProperty('cursor', 'grabbing');
|
|
2619
2390
|
}, [flattenedItems, setActiveId, setOverId, setCurrentPosition]);
|
|
2620
2391
|
var handleDragMove = React.useCallback(function (_ref12) {
|
|
@@ -2623,7 +2394,6 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2623
2394
|
}, [setOffsetLeft]);
|
|
2624
2395
|
var handleDragOver = React.useCallback(function (_ref13) {
|
|
2625
2396
|
var _over$id;
|
|
2626
|
-
|
|
2627
2397
|
var over = _ref13.over;
|
|
2628
2398
|
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
2629
2399
|
}, [setOverId]);
|
|
@@ -2636,12 +2406,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2636
2406
|
}, [setOverId, setActiveId, setOffsetLeft, setCurrentPosition]);
|
|
2637
2407
|
var handleDragEnd = React.useCallback(function (_ref14) {
|
|
2638
2408
|
var active = _ref14.active,
|
|
2639
|
-
|
|
2409
|
+
over = _ref14.over;
|
|
2640
2410
|
resetState();
|
|
2641
|
-
|
|
2642
2411
|
if (projected && over) {
|
|
2643
2412
|
var depth = projected.depth,
|
|
2644
|
-
|
|
2413
|
+
parentId = projected.parentId;
|
|
2645
2414
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2646
2415
|
var overIndex = clonedItems.findIndex(function (_ref15) {
|
|
2647
2416
|
var id = _ref15.id;
|
|
@@ -2652,10 +2421,10 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2652
2421
|
return id === active.id;
|
|
2653
2422
|
});
|
|
2654
2423
|
var activeTreeItem = clonedItems[activeIndex];
|
|
2655
|
-
var maxDepth = getMaxDepth(activeTreeItem);
|
|
2656
|
-
|
|
2424
|
+
var maxDepth = getMaxDepth(activeTreeItem);
|
|
2425
|
+
// Un-merge and flatten
|
|
2657
2426
|
if (depth > 0 && depth >= maxDepth && (activeTreeItem === null || activeTreeItem === void 0 ? void 0 : activeTreeItem.children) !== null && activeTreeItem.children.length > 0) {
|
|
2658
|
-
var _loop2 = function _loop2(
|
|
2427
|
+
var _loop2 = function _loop2() {
|
|
2659
2428
|
var childId = activeTreeItem.children[i].id;
|
|
2660
2429
|
var childIndex = clonedItems.findIndex(function (_ref17) {
|
|
2661
2430
|
var id = _ref17.id;
|
|
@@ -2664,33 +2433,32 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2664
2433
|
clonedItems[childIndex].parentId = parentId;
|
|
2665
2434
|
clonedItems[childIndex].depth = depth;
|
|
2666
2435
|
};
|
|
2667
|
-
|
|
2668
2436
|
for (var i = 0; i < activeTreeItem.children.length; i += 1) {
|
|
2669
|
-
_loop2(
|
|
2437
|
+
_loop2();
|
|
2670
2438
|
}
|
|
2671
|
-
|
|
2672
2439
|
activeTreeItem.children = [];
|
|
2673
2440
|
}
|
|
2674
|
-
|
|
2675
2441
|
clonedItems[activeIndex] = _objectSpread__default["default"](_objectSpread__default["default"]({}, activeTreeItem), {}, {
|
|
2676
2442
|
depth: depth,
|
|
2677
2443
|
parentId: parentId
|
|
2678
2444
|
});
|
|
2679
2445
|
var sortedItems = sortable.arrayMove(clonedItems, activeIndex, overIndex);
|
|
2680
|
-
var newItems = buildTree(sortedItems);
|
|
2446
|
+
var newItems = buildTree(sortedItems);
|
|
2681
2447
|
|
|
2682
|
-
|
|
2448
|
+
// console.log('drag endd', sortedItems, newItems);
|
|
2683
2449
|
|
|
2450
|
+
setItems(newItems);
|
|
2684
2451
|
if (onChange !== null) {
|
|
2685
2452
|
// console.log('hell is flatss', newItems);
|
|
2453
|
+
|
|
2686
2454
|
onChange((newItems || []).map(function (_ref18) {
|
|
2687
2455
|
var itemId = _ref18.id,
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2456
|
+
_ref18$children = _ref18.children,
|
|
2457
|
+
children = _ref18$children === void 0 ? [] : _ref18$children,
|
|
2458
|
+
_ref18$parentId = _ref18.parentId,
|
|
2459
|
+
itParentId = _ref18$parentId === void 0 ? null : _ref18$parentId,
|
|
2460
|
+
_ref18$collapsed = _ref18.collapsed,
|
|
2461
|
+
collapsed = _ref18$collapsed === void 0 ? false : _ref18$collapsed;
|
|
2694
2462
|
return {
|
|
2695
2463
|
id: itemId,
|
|
2696
2464
|
props: _objectSpread__default["default"](_objectSpread__default["default"]({}, (children || []).length > 0 ? {
|
|
@@ -2728,7 +2496,8 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2728
2496
|
return /*#__PURE__*/React__default["default"].createElement(core$1.DndContext, {
|
|
2729
2497
|
accessibility: {
|
|
2730
2498
|
announcements: announcements
|
|
2731
|
-
}
|
|
2499
|
+
}
|
|
2500
|
+
// announcements={announcements}
|
|
2732
2501
|
,
|
|
2733
2502
|
sensors: sensors,
|
|
2734
2503
|
collisionDetection: core$1.closestCenter,
|
|
@@ -2743,15 +2512,14 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2743
2512
|
strategy: sortable.verticalListSortingStrategy
|
|
2744
2513
|
}, flattenedItems.map(function (_ref19, idx) {
|
|
2745
2514
|
var _flattenedItems, _ref22;
|
|
2746
|
-
|
|
2747
2515
|
var id = _ref19.id,
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2516
|
+
_ref19$children = _ref19.children,
|
|
2517
|
+
children = _ref19$children === void 0 ? [] : _ref19$children,
|
|
2518
|
+
collapsed = _ref19.collapsed,
|
|
2519
|
+
depth = _ref19.depth;
|
|
2752
2520
|
var screenValue = defaultItems.find(function (_ref20) {
|
|
2753
2521
|
var _ref20$id = _ref20.id,
|
|
2754
|
-
|
|
2522
|
+
defaultId = _ref20$id === void 0 ? null : _ref20$id;
|
|
2755
2523
|
return defaultId === id;
|
|
2756
2524
|
});
|
|
2757
2525
|
var next = ((_flattenedItems = flattenedItems[idx + 1]) === null || _flattenedItems === void 0 ? void 0 : _flattenedItems.parentId) || null;
|
|
@@ -2763,7 +2531,7 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2763
2531
|
var childCount = getChildCount(items, id);
|
|
2764
2532
|
var childValue = childCount > 0 && collapsed ? defaultItems.slice().reverse().find(function (_ref21) {
|
|
2765
2533
|
var _ref21$parentId = _ref21.parentId,
|
|
2766
|
-
|
|
2534
|
+
parentId = _ref21$parentId === void 0 ? null : _ref21$parentId;
|
|
2767
2535
|
return parentId === id;
|
|
2768
2536
|
}) : null;
|
|
2769
2537
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -2808,12 +2576,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2808
2576
|
})
|
|
2809
2577
|
})) : null), document.body)));
|
|
2810
2578
|
};
|
|
2811
|
-
|
|
2812
2579
|
SortableTree.propTypes = propTypes$8;
|
|
2813
2580
|
SortableTree.defaultProps = defaultProps$8;
|
|
2814
2581
|
|
|
2815
2582
|
var _excluded$2 = ["className", "screen", "type", "onClick", "active", "href"],
|
|
2816
|
-
|
|
2583
|
+
_excluded2 = ["id", "screen", "href"];
|
|
2817
2584
|
var propTypes$7 = {
|
|
2818
2585
|
items: core.PropTypes.menuItems,
|
|
2819
2586
|
withPreview: PropTypes__default["default"].bool,
|
|
@@ -2846,37 +2613,33 @@ var defaultProps$7 = {
|
|
|
2846
2613
|
onClickItem: null,
|
|
2847
2614
|
onOrderChange: null
|
|
2848
2615
|
};
|
|
2849
|
-
|
|
2850
2616
|
var ScreensMenu = function ScreensMenu(_ref) {
|
|
2851
2617
|
var _ref8;
|
|
2852
|
-
|
|
2853
2618
|
var items = _ref.items,
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2619
|
+
withPreview = _ref.withPreview,
|
|
2620
|
+
withPlaceholder = _ref.withPlaceholder,
|
|
2621
|
+
settings = _ref.settings,
|
|
2622
|
+
isVertical = _ref.isVertical,
|
|
2623
|
+
noWrap = _ref.noWrap,
|
|
2624
|
+
className = _ref.className,
|
|
2625
|
+
itemClassName = _ref.itemClassName,
|
|
2626
|
+
buttonClassName = _ref.buttonClassName,
|
|
2627
|
+
settingsClassName = _ref.settingsClassName,
|
|
2628
|
+
sortable = _ref.sortable,
|
|
2629
|
+
isTree = _ref.isTree,
|
|
2630
|
+
onClickItem = _ref.onClickItem,
|
|
2631
|
+
onOrderChange = _ref.onOrderChange;
|
|
2867
2632
|
var itemsElements = !isTree ? items.map(function (_ref2, index) {
|
|
2868
2633
|
var _ref3;
|
|
2869
|
-
|
|
2870
2634
|
var _ref2$className = _ref2.className,
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2635
|
+
itemCustomClassName = _ref2$className === void 0 ? null : _ref2$className,
|
|
2636
|
+
screen = _ref2.screen,
|
|
2637
|
+
type = _ref2.type,
|
|
2638
|
+
_ref2$onClick = _ref2.onClick,
|
|
2639
|
+
onClick = _ref2$onClick === void 0 ? null : _ref2$onClick,
|
|
2640
|
+
active = _ref2.active,
|
|
2641
|
+
href = _ref2.href,
|
|
2642
|
+
item = _objectWithoutProperties__default["default"](_ref2, _excluded$2);
|
|
2880
2643
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2881
2644
|
key: item.id,
|
|
2882
2645
|
className: classNames__default["default"]([styles$6.item, (_ref3 = {}, _defineProperty__default["default"](_ref3, itemClassName, itemClassName !== null), _defineProperty__default["default"](_ref3, itemCustomClassName, itemCustomClassName !== null), _ref3)]),
|
|
@@ -2900,20 +2663,17 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2900
2663
|
var sortableItems = React.useMemo(function () {
|
|
2901
2664
|
return isTree ? items.map(function (_ref5) {
|
|
2902
2665
|
var id = _ref5.id,
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2666
|
+
_ref5$screen = _ref5.screen,
|
|
2667
|
+
screen = _ref5$screen === void 0 ? {} : _ref5$screen,
|
|
2668
|
+
href = _ref5.href,
|
|
2669
|
+
props = _objectWithoutProperties__default["default"](_ref5, _excluded2);
|
|
2908
2670
|
var _screen$parentId = screen.parentId,
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2671
|
+
parentId = _screen$parentId === void 0 ? null : _screen$parentId,
|
|
2672
|
+
_screen$group = screen.group,
|
|
2673
|
+
group = _screen$group === void 0 ? {} : _screen$group;
|
|
2913
2674
|
var _ref6 = group || {},
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2675
|
+
_ref6$collapsed = _ref6.collapsed,
|
|
2676
|
+
collapsed = _ref6$collapsed === void 0 ? true : _ref6$collapsed;
|
|
2917
2677
|
return {
|
|
2918
2678
|
id: id,
|
|
2919
2679
|
parentId: parentId,
|
|
@@ -2950,7 +2710,6 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2950
2710
|
className: styles$6.items
|
|
2951
2711
|
}, itemsElements) : null);
|
|
2952
2712
|
};
|
|
2953
|
-
|
|
2954
2713
|
ScreensMenu.propTypes = propTypes$7;
|
|
2955
2714
|
ScreensMenu.defaultProps = defaultProps$7;
|
|
2956
2715
|
|
|
@@ -2968,12 +2727,11 @@ var defaultProps$6 = {
|
|
|
2968
2727
|
className: null,
|
|
2969
2728
|
onClickItem: null
|
|
2970
2729
|
};
|
|
2971
|
-
|
|
2972
2730
|
var ScreenTypes = function ScreenTypes(_ref) {
|
|
2973
2731
|
var screens = _ref.screens,
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2732
|
+
selectedTypes = _ref.selectedTypes,
|
|
2733
|
+
className = _ref.className,
|
|
2734
|
+
onClickItem = _ref.onClickItem;
|
|
2977
2735
|
var intl = reactIntl.useIntl();
|
|
2978
2736
|
var screensManager = contexts.useScreensManager();
|
|
2979
2737
|
var screenDefinitions = screens || screensManager.getDefinitions();
|
|
@@ -2983,36 +2741,31 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
2983
2741
|
var groups = React.useMemo(function () {
|
|
2984
2742
|
var groupItems = finalDefinitions.reduce(function (allGroups, definition) {
|
|
2985
2743
|
var id = definition.id,
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2744
|
+
title = definition.title,
|
|
2745
|
+
_definition$group = definition.group,
|
|
2746
|
+
group = _definition$group === void 0 ? {} : _definition$group;
|
|
2990
2747
|
var _ref2 = group || {},
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2748
|
+
_ref2$order = _ref2.order,
|
|
2749
|
+
order = _ref2$order === void 0 ? 0 : _ref2$order,
|
|
2750
|
+
_ref2$label = _ref2.label,
|
|
2751
|
+
label = _ref2$label === void 0 ? {} : _ref2$label,
|
|
2752
|
+
_ref2$hidden = _ref2.hidden,
|
|
2753
|
+
hidden = _ref2$hidden === void 0 ? false : _ref2$hidden;
|
|
2998
2754
|
var _ref3 = label || {},
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
2755
|
+
_ref3$id = _ref3.id,
|
|
2756
|
+
messageId = _ref3$id === void 0 ? null : _ref3$id;
|
|
3002
2757
|
if (hidden) {
|
|
3003
2758
|
return allGroups;
|
|
3004
2759
|
}
|
|
3005
|
-
|
|
3006
2760
|
var _ref4 = utils.isMessage(label) ? {
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
2761
|
+
id: messageId || id,
|
|
2762
|
+
name: group
|
|
2763
|
+
} : {
|
|
2764
|
+
id: messageId || id,
|
|
2765
|
+
name: title
|
|
2766
|
+
},
|
|
2767
|
+
groupId = _ref4.id,
|
|
2768
|
+
groupName = _ref4.name;
|
|
3016
2769
|
var groupIndex = allGroups.findIndex(function (it) {
|
|
3017
2770
|
return it.id === groupId;
|
|
3018
2771
|
});
|
|
@@ -3043,8 +2796,8 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
3043
2796
|
className: styles$2.rows
|
|
3044
2797
|
}, groups.map(function (_ref6) {
|
|
3045
2798
|
var id = _ref6.id,
|
|
3046
|
-
|
|
3047
|
-
|
|
2799
|
+
name = _ref6.name,
|
|
2800
|
+
items = _ref6.items;
|
|
3048
2801
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3049
2802
|
key: "group-".concat(id),
|
|
3050
2803
|
className: styles$2.row
|
|
@@ -3064,7 +2817,6 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
3064
2817
|
})));
|
|
3065
2818
|
})));
|
|
3066
2819
|
};
|
|
3067
|
-
|
|
3068
2820
|
ScreenTypes.propTypes = propTypes$6;
|
|
3069
2821
|
ScreenTypes.defaultProps = defaultProps$6;
|
|
3070
2822
|
|
|
@@ -3082,12 +2834,11 @@ var defaultProps$5 = {
|
|
|
3082
2834
|
onRequestClose: null,
|
|
3083
2835
|
onClickScreenType: null
|
|
3084
2836
|
};
|
|
3085
|
-
|
|
3086
2837
|
var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
3087
2838
|
var selectedTypes = _ref.selectedTypes,
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
2839
|
+
className = _ref.className,
|
|
2840
|
+
onRequestClose = _ref.onRequestClose,
|
|
2841
|
+
onClickScreenType = _ref.onClickScreenType;
|
|
3091
2842
|
return /*#__PURE__*/React__default["default"].createElement(components.Modal, null, /*#__PURE__*/React__default["default"].createElement(components.ModalDialog, {
|
|
3092
2843
|
title: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
3093
2844
|
id: "QBaiO0",
|
|
@@ -3104,7 +2855,6 @@ var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
|
3104
2855
|
onClickItem: onClickScreenType
|
|
3105
2856
|
})));
|
|
3106
2857
|
};
|
|
3107
|
-
|
|
3108
2858
|
ScreenTypesModal.propTypes = propTypes$5;
|
|
3109
2859
|
ScreenTypesModal.defaultProps = defaultProps$5;
|
|
3110
2860
|
|
|
@@ -3131,57 +2881,48 @@ var defaultProps$4 = {
|
|
|
3131
2881
|
onChange: null,
|
|
3132
2882
|
className: null
|
|
3133
2883
|
};
|
|
3134
|
-
|
|
3135
2884
|
var EditorScreens = function EditorScreens(_ref) {
|
|
3136
2885
|
var unparsedValue = _ref.value,
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
2886
|
+
isTheme = _ref.isTheme,
|
|
2887
|
+
isVertical = _ref.isVertical,
|
|
2888
|
+
isCreateOpened = _ref.isCreateOpened,
|
|
2889
|
+
isParsed = _ref.isParsed,
|
|
2890
|
+
isTree = _ref.isTree,
|
|
2891
|
+
onClickScreen = _ref.onClickScreen,
|
|
2892
|
+
onChange = _ref.onChange,
|
|
2893
|
+
className = _ref.className;
|
|
3145
2894
|
var valueWithTheme = useThemeValue(unparsedValue, isTheme);
|
|
3146
2895
|
var value = isParsed ? unparsedValue : hooks.useParsedStory(valueWithTheme, {
|
|
3147
2896
|
withMedias: false
|
|
3148
2897
|
});
|
|
3149
|
-
|
|
3150
2898
|
var _ref2 = value || {},
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
2899
|
+
_ref2$components = _ref2.components,
|
|
2900
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
3154
2901
|
var _useState = React.useState(isCreateOpened),
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
2902
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
2903
|
+
createModalOpened = _useState2[0],
|
|
2904
|
+
setCreateModalOpened = _useState2[1];
|
|
3159
2905
|
var routes = contexts.useRoutes();
|
|
3160
2906
|
var push = contexts.useRoutePush();
|
|
3161
2907
|
var url = contexts.useUrlGenerator();
|
|
3162
|
-
|
|
3163
2908
|
var _useRouteParams = useRouteParams({
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
2909
|
+
screenOnly: true
|
|
2910
|
+
}),
|
|
2911
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
2912
|
+
currentScreenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree;
|
|
3169
2913
|
var createScreenFromDefinition = React.useCallback(function (definition) {
|
|
3170
2914
|
var _ref3 = value || {},
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
2915
|
+
_ref3$components = _ref3.components,
|
|
2916
|
+
currentScreens = _ref3$components === void 0 ? [] : _ref3$components,
|
|
2917
|
+
_ref3$theme = _ref3.theme,
|
|
2918
|
+
theme = _ref3$theme === void 0 ? {} : _ref3$theme;
|
|
3176
2919
|
var _ref4 = isString__default["default"](definition) ? {
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
2920
|
+
id: definition
|
|
2921
|
+
} : definition,
|
|
2922
|
+
newScreenType = _ref4.id;
|
|
3181
2923
|
var _ref5 = theme || {},
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
2924
|
+
_ref5$components = _ref5.components,
|
|
2925
|
+
themeComponents = _ref5$components === void 0 ? null : _ref5$components;
|
|
3185
2926
|
var themeScreen = themeComponents !== null ? themeComponents.find(function (it) {
|
|
3186
2927
|
return it.type === newScreenType;
|
|
3187
2928
|
}) || null : null;
|
|
@@ -3191,15 +2932,12 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3191
2932
|
return id === currentScreenId;
|
|
3192
2933
|
});
|
|
3193
2934
|
var currentScreenIndex = !isTheme && foundIndex >= 0 ? foundIndex + 1 : null;
|
|
3194
|
-
|
|
3195
2935
|
var newValue = _objectSpread__default["default"](_objectSpread__default["default"]({}, value), {}, {
|
|
3196
2936
|
components: [].concat(_toConsumableArray__default["default"](currentScreens.slice(0, currentScreenIndex)), [newScreen], _toConsumableArray__default["default"](currentScreens.slice(currentScreenIndex)))
|
|
3197
2937
|
});
|
|
3198
|
-
|
|
3199
2938
|
if (onChange !== null) {
|
|
3200
2939
|
onChange(newValue);
|
|
3201
2940
|
}
|
|
3202
|
-
|
|
3203
2941
|
return newScreen;
|
|
3204
2942
|
}, [value, onChange, isTheme, screens, currentScreenId, setCreateModalOpened]);
|
|
3205
2943
|
var onOrderChange = React.useCallback(function (listItems) {
|
|
@@ -3209,8 +2947,8 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3209
2947
|
});
|
|
3210
2948
|
var screenProps = listItems.map(function (_ref8) {
|
|
3211
2949
|
var id = _ref8.id,
|
|
3212
|
-
|
|
3213
|
-
|
|
2950
|
+
_ref8$props = _ref8.props,
|
|
2951
|
+
props = _ref8$props === void 0 ? null : _ref8$props;
|
|
3214
2952
|
return {
|
|
3215
2953
|
id: id,
|
|
3216
2954
|
props: props
|
|
@@ -3220,11 +2958,9 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3220
2958
|
var props = _ref9.props;
|
|
3221
2959
|
return props !== null;
|
|
3222
2960
|
}) || []).length > 0;
|
|
3223
|
-
|
|
3224
2961
|
var _ref10 = value || {},
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
2962
|
+
_ref10$components = _ref10.components,
|
|
2963
|
+
currentScreens = _ref10$components === void 0 ? [] : _ref10$components;
|
|
3228
2964
|
var currentIds = currentScreens.map(function (_ref11) {
|
|
3229
2965
|
var id = _ref11.id;
|
|
3230
2966
|
return id;
|
|
@@ -3233,7 +2969,6 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3233
2969
|
var id = _ref12.id;
|
|
3234
2970
|
return same && id === currentIds[index];
|
|
3235
2971
|
}, true);
|
|
3236
|
-
|
|
3237
2972
|
if (!sameOrder || hasScreenProps) {
|
|
3238
2973
|
var newValue = _objectSpread__default["default"](_objectSpread__default["default"]({}, value), {}, {
|
|
3239
2974
|
components: _toConsumableArray__default["default"](currentScreens).sort(function (_ref13, _ref14) {
|
|
@@ -3241,18 +2976,14 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3241
2976
|
var idB = _ref14.id;
|
|
3242
2977
|
var indexA = ids.indexOf(idA);
|
|
3243
2978
|
var indexB = ids.indexOf(idB);
|
|
3244
|
-
|
|
3245
2979
|
if (indexA === indexB) {
|
|
3246
2980
|
return 0;
|
|
3247
2981
|
}
|
|
3248
|
-
|
|
3249
2982
|
return indexA > indexB ? 1 : -1;
|
|
3250
2983
|
}).map(function (_ref15) {
|
|
3251
2984
|
var _screenProps$find;
|
|
3252
|
-
|
|
3253
2985
|
var id = _ref15.id,
|
|
3254
|
-
|
|
3255
|
-
|
|
2986
|
+
props = _objectWithoutProperties__default["default"](_ref15, _excluded$1);
|
|
3256
2987
|
return _objectSpread__default["default"](_objectSpread__default["default"]({
|
|
3257
2988
|
id: id
|
|
3258
2989
|
}, props), (_screenProps$find = screenProps.find(function (_ref16) {
|
|
@@ -3261,7 +2992,6 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3261
2992
|
})) === null || _screenProps$find === void 0 ? void 0 : _screenProps$find.props);
|
|
3262
2993
|
})
|
|
3263
2994
|
});
|
|
3264
|
-
|
|
3265
2995
|
if (onChange !== null) {
|
|
3266
2996
|
onChange(newValue);
|
|
3267
2997
|
}
|
|
@@ -3273,11 +3003,9 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3273
3003
|
var type = _ref17.type;
|
|
3274
3004
|
return type === definition.id;
|
|
3275
3005
|
}) || null : null;
|
|
3276
|
-
|
|
3277
3006
|
if (!isTheme || currentScreen === null) {
|
|
3278
3007
|
currentScreen = createScreenFromDefinition(definition);
|
|
3279
3008
|
}
|
|
3280
|
-
|
|
3281
3009
|
push('screen', {
|
|
3282
3010
|
screen: currentScreen.id
|
|
3283
3011
|
});
|
|
@@ -3317,7 +3045,7 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3317
3045
|
path: [routes.screen, routes.home],
|
|
3318
3046
|
render: function render(_ref18) {
|
|
3319
3047
|
var _ref18$match$params$s = _ref18.match.params.screen,
|
|
3320
|
-
|
|
3048
|
+
screenId = _ref18$match$params$s === void 0 ? null : _ref18$match$params$s;
|
|
3321
3049
|
return screens.length > 0 ? /*#__PURE__*/React__default["default"].createElement(ScreensMenu, {
|
|
3322
3050
|
items: screens.map(function (it) {
|
|
3323
3051
|
return {
|
|
@@ -3358,7 +3086,6 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3358
3086
|
onRequestClose: onCreateModalRequestClose
|
|
3359
3087
|
}) : null);
|
|
3360
3088
|
};
|
|
3361
|
-
|
|
3362
3089
|
EditorScreens.propTypes = propTypes$4;
|
|
3363
3090
|
EditorScreens.defaultProps = defaultProps$4;
|
|
3364
3091
|
|
|
@@ -3384,43 +3111,39 @@ var defaultProps$3 = {
|
|
|
3384
3111
|
onChange: null,
|
|
3385
3112
|
className: null
|
|
3386
3113
|
};
|
|
3387
|
-
|
|
3388
3114
|
var Editor = function Editor(_ref) {
|
|
3389
3115
|
var _ref5;
|
|
3390
|
-
|
|
3391
3116
|
var value = _ref.value,
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3117
|
+
viewerTheme = _ref.viewerTheme,
|
|
3118
|
+
isTheme = _ref.isTheme,
|
|
3119
|
+
isCreateOpened = _ref.isCreateOpened,
|
|
3120
|
+
deviceScreens = _ref.deviceScreens,
|
|
3121
|
+
initialMobileView = _ref.mobileView,
|
|
3122
|
+
onChange = _ref.onChange,
|
|
3123
|
+
fullscreen = _ref.fullscreen,
|
|
3124
|
+
className = _ref.className;
|
|
3400
3125
|
var push = contexts.useRoutePush();
|
|
3401
3126
|
var refScreensContainer = React.useRef(null);
|
|
3402
|
-
|
|
3403
3127
|
var _useRouteParams = useRouteParams({
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3128
|
+
screenOnly: true
|
|
3129
|
+
}),
|
|
3130
|
+
screenId = _useRouteParams.screen;
|
|
3408
3131
|
|
|
3132
|
+
// Screen size
|
|
3409
3133
|
var _useScreenSizeFromEle = hooks.useScreenSizeFromElement({
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
var isMobile = screenSize !== null && screenSize.screens.indexOf('medium') === -1; // Mobile view
|
|
3134
|
+
screens: deviceScreens,
|
|
3135
|
+
withoutMaxSize: true,
|
|
3136
|
+
withoutScale: true
|
|
3137
|
+
}),
|
|
3138
|
+
refContainer = _useScreenSizeFromEle.ref,
|
|
3139
|
+
screenSize = _useScreenSizeFromEle.screenSize;
|
|
3140
|
+
var isMobile = screenSize !== null && screenSize.screens.indexOf('medium') === -1;
|
|
3418
3141
|
|
|
3142
|
+
// Mobile view
|
|
3419
3143
|
var _useState = React.useState(initialMobileView),
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3144
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
3145
|
+
mobileView = _useState2[0],
|
|
3146
|
+
setMobileView = _useState2[1];
|
|
3424
3147
|
var onClickScreens = React.useCallback(function () {
|
|
3425
3148
|
return setMobileView('screens');
|
|
3426
3149
|
}, [mobileView, setMobileView]);
|
|
@@ -3429,18 +3152,18 @@ var Editor = function Editor(_ref) {
|
|
|
3429
3152
|
}, [setMobileView]);
|
|
3430
3153
|
var onClickViewScreen = React.useCallback(function () {
|
|
3431
3154
|
return setMobileView('preview');
|
|
3432
|
-
}, [setMobileView]);
|
|
3155
|
+
}, [setMobileView]);
|
|
3433
3156
|
|
|
3157
|
+
// Apply base theme values to it's own components
|
|
3434
3158
|
var _ref2 = value || {},
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3159
|
+
_ref2$background = _ref2.background,
|
|
3160
|
+
background = _ref2$background === void 0 ? null : _ref2$background,
|
|
3161
|
+
_ref2$colors = _ref2.colors,
|
|
3162
|
+
colors = _ref2$colors === void 0 ? null : _ref2$colors,
|
|
3163
|
+
_ref2$textStyles = _ref2.textStyles,
|
|
3164
|
+
textStyles = _ref2$textStyles === void 0 ? null : _ref2$textStyles,
|
|
3165
|
+
_ref2$boxStyles = _ref2.boxStyles,
|
|
3166
|
+
boxStyles = _ref2$boxStyles === void 0 ? null : _ref2$boxStyles;
|
|
3444
3167
|
var baseValue = isTheme ? _objectSpread__default["default"](_objectSpread__default["default"]({}, value), {}, {
|
|
3445
3168
|
theme: {
|
|
3446
3169
|
background: background,
|
|
@@ -3450,13 +3173,10 @@ var Editor = function Editor(_ref) {
|
|
|
3450
3173
|
}
|
|
3451
3174
|
}) : value;
|
|
3452
3175
|
var story = hooks.useParsedStory(baseValue);
|
|
3453
|
-
|
|
3454
3176
|
var _useMediasParser = hooks.useMediasParser(),
|
|
3455
|
-
|
|
3456
|
-
|
|
3177
|
+
parseMediasToPath = _useMediasParser.toPath;
|
|
3457
3178
|
var onStoryChange = React.useCallback(function (newStory) {
|
|
3458
3179
|
var storyWithMedias = parseMediasToPath(newStory);
|
|
3459
|
-
|
|
3460
3180
|
if (onChange !== null) {
|
|
3461
3181
|
onChange(storyWithMedias);
|
|
3462
3182
|
}
|
|
@@ -3465,11 +3185,9 @@ var Editor = function Editor(_ref) {
|
|
|
3465
3185
|
var onClickScreen = React.useCallback(function (_ref3) {
|
|
3466
3186
|
var id = _ref3.id;
|
|
3467
3187
|
clickedScreenId.current = id;
|
|
3468
|
-
|
|
3469
3188
|
if (screenSize.screen) {
|
|
3470
3189
|
setMobileView('preview');
|
|
3471
3190
|
}
|
|
3472
|
-
|
|
3473
3191
|
push('screen', {
|
|
3474
3192
|
screen: clickedScreenId.current
|
|
3475
3193
|
});
|
|
@@ -3479,17 +3197,16 @@ var Editor = function Editor(_ref) {
|
|
|
3479
3197
|
push('screen', {
|
|
3480
3198
|
screen: newScreenId
|
|
3481
3199
|
});
|
|
3482
|
-
}, [push]);
|
|
3200
|
+
}, [push]);
|
|
3483
3201
|
|
|
3202
|
+
// Auto-scroll to current screen except when manually clicking one
|
|
3484
3203
|
React.useEffect(function () {
|
|
3485
3204
|
if (screenId === null || clickedScreenId.current === screenId) {
|
|
3486
3205
|
return;
|
|
3487
3206
|
}
|
|
3488
|
-
|
|
3489
3207
|
clickedScreenId.current = null;
|
|
3490
3208
|
var screens = refScreensContainer.current;
|
|
3491
3209
|
var items = screens.querySelectorAll("[data-screen-id=\"".concat(screenId, "\"]"));
|
|
3492
|
-
|
|
3493
3210
|
if (items !== null && items.length > 0) {
|
|
3494
3211
|
var item = items[0];
|
|
3495
3212
|
var cnt = item.parentNode.parentNode.parentNode;
|
|
@@ -3574,10 +3291,10 @@ var Editor = function Editor(_ref) {
|
|
|
3574
3291
|
className: styles$i.inner
|
|
3575
3292
|
}))), /*#__PURE__*/React__default["default"].createElement(components.Modals, null)))));
|
|
3576
3293
|
};
|
|
3577
|
-
|
|
3578
3294
|
Editor.propTypes = propTypes$3;
|
|
3579
3295
|
Editor.defaultProps = defaultProps$3;
|
|
3580
3296
|
|
|
3297
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3581
3298
|
var routes = PropTypes__default["default"].shape({
|
|
3582
3299
|
home: PropTypes__default["default"].string.isRequired,
|
|
3583
3300
|
screen: PropTypes__default["default"].string.isRequired,
|
|
@@ -3603,34 +3320,28 @@ var defaultProps$2 = {
|
|
|
3603
3320
|
className: null,
|
|
3604
3321
|
onChange: null
|
|
3605
3322
|
};
|
|
3606
|
-
|
|
3607
3323
|
var SettingsForm = function SettingsForm(_ref) {
|
|
3608
3324
|
var name = _ref.name,
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3325
|
+
field = _ref.field,
|
|
3326
|
+
value = _ref.value,
|
|
3327
|
+
className = _ref.className,
|
|
3328
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
3329
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
3330
|
+
onChange = _ref.onChange;
|
|
3615
3331
|
if (field === null) return false;
|
|
3616
|
-
|
|
3617
3332
|
var _ref2 = field || {},
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3333
|
+
_ref2$type = _ref2.type,
|
|
3334
|
+
type = _ref2$type === void 0 ? null : _ref2$type;
|
|
3621
3335
|
var fieldsManager = contexts.useFieldsManager();
|
|
3622
|
-
|
|
3623
3336
|
var _ref3 = type !== null ? fieldsManager.getDefinition(type) : field,
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3337
|
+
_ref3$component = _ref3.component,
|
|
3338
|
+
fieldComponent = _ref3$component === void 0 ? null : _ref3$component,
|
|
3339
|
+
settings = _ref3.settings;
|
|
3628
3340
|
var FieldComponent = contexts.useFieldComponent(fieldComponent);
|
|
3629
3341
|
var FieldsComponent = contexts.useFieldComponent('fields');
|
|
3630
3342
|
var SettingsComponent = FieldComponent !== null ? FieldComponent.settingsComponent || FieldsComponent : FieldsComponent;
|
|
3631
3343
|
var onSettingsChange = React.useCallback(function (newSettingsValue) {
|
|
3632
3344
|
var newValue = _objectSpread__default["default"](_objectSpread__default["default"]({}, value), newSettingsValue);
|
|
3633
|
-
|
|
3634
3345
|
if (onChange !== null) {
|
|
3635
3346
|
onChange(newValue);
|
|
3636
3347
|
}
|
|
@@ -3649,7 +3360,6 @@ var SettingsForm = function SettingsForm(_ref) {
|
|
|
3649
3360
|
closeFieldForm: closeFieldForm
|
|
3650
3361
|
})));
|
|
3651
3362
|
};
|
|
3652
|
-
|
|
3653
3363
|
SettingsForm.propTypes = propTypes$2;
|
|
3654
3364
|
SettingsForm.defaultProps = defaultProps$2;
|
|
3655
3365
|
|
|
@@ -3667,14 +3377,12 @@ var propTypes$1 = {
|
|
|
3667
3377
|
var defaultProps$1 = {
|
|
3668
3378
|
children: null
|
|
3669
3379
|
};
|
|
3670
|
-
|
|
3671
3380
|
var FormsProvider = function FormsProvider(props) {
|
|
3672
3381
|
return /*#__PURE__*/React__default["default"].createElement(contexts.ComponentsProvider, Object.assign({
|
|
3673
3382
|
namespace: contexts.FORMS_NAMESPACE,
|
|
3674
3383
|
components: FormsComponents
|
|
3675
3384
|
}, props));
|
|
3676
3385
|
};
|
|
3677
|
-
|
|
3678
3386
|
FormsProvider.propTypes = propTypes$1;
|
|
3679
3387
|
FormsProvider.defaultProps = defaultProps$1;
|
|
3680
3388
|
|
|
@@ -3710,24 +3418,22 @@ var defaultProps = {
|
|
|
3710
3418
|
googleMapsLibraries: ['places'],
|
|
3711
3419
|
screenNamespaces: null
|
|
3712
3420
|
};
|
|
3713
|
-
|
|
3714
3421
|
var EditorContainer = function EditorContainer(_ref) {
|
|
3715
3422
|
var value = _ref.value,
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3423
|
+
memoryRouter = _ref.memoryRouter,
|
|
3424
|
+
routes = _ref.routes,
|
|
3425
|
+
basePath = _ref.basePath,
|
|
3426
|
+
uppy = _ref.uppy,
|
|
3427
|
+
googleApiKey = _ref.googleApiKey,
|
|
3428
|
+
googleMapsLibraries = _ref.googleMapsLibraries,
|
|
3429
|
+
screenNamespaces = _ref.screenNamespaces,
|
|
3430
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
3725
3431
|
var Router = memoryRouter ? reactRouter.MemoryRouter : reactRouterDom.BrowserRouter;
|
|
3726
|
-
|
|
3727
3432
|
var _useIntl = reactIntl.useIntl(),
|
|
3728
|
-
|
|
3729
|
-
// const { language:finalLocale = locale } = metadata || {};
|
|
3433
|
+
locale = _useIntl.locale;
|
|
3730
3434
|
|
|
3435
|
+
// const { metadata } = value || {};
|
|
3436
|
+
// const { language:finalLocale = locale } = metadata || {};
|
|
3731
3437
|
|
|
3732
3438
|
return /*#__PURE__*/React__default["default"].createElement(Router, {
|
|
3733
3439
|
basename: !memoryRouter ? basePath : null
|
|
@@ -3757,7 +3463,6 @@ var EditorContainer = function EditorContainer(_ref) {
|
|
|
3757
3463
|
}, props)));
|
|
3758
3464
|
}))))))))))));
|
|
3759
3465
|
};
|
|
3760
|
-
|
|
3761
3466
|
EditorContainer.propTypes = propTypes;
|
|
3762
3467
|
EditorContainer.defaultProps = defaultProps;
|
|
3763
3468
|
|