@micromag/editor 0.3.316 → 0.3.318
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/es/index.js
CHANGED
|
@@ -43,26 +43,23 @@ import { ScreensProvider } from '@micromag/screens';
|
|
|
43
43
|
|
|
44
44
|
var useRouteParams = function useRouteParams() {
|
|
45
45
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
_ref$screenOnly = _ref.screenOnly,
|
|
47
|
+
screenOnly = _ref$screenOnly === void 0 ? false : _ref$screenOnly;
|
|
49
48
|
var routes = useRoutes();
|
|
50
49
|
var path = useMemo(function () {
|
|
51
50
|
return screenOnly ? [routes.screen, '*'] : [routes['screen.field.form'], routes['screen.field'], routes.screen, '*'];
|
|
52
51
|
}, [routes, screenOnly]);
|
|
53
|
-
|
|
54
52
|
var _useRouteMatch = useRouteMatch({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
path: path
|
|
54
|
+
}),
|
|
55
|
+
url = _useRouteMatch.url,
|
|
56
|
+
_useRouteMatch$params = _useRouteMatch.params,
|
|
57
|
+
_useRouteMatch$params2 = _useRouteMatch$params.screen,
|
|
58
|
+
screen = _useRouteMatch$params2 === void 0 ? null : _useRouteMatch$params2,
|
|
59
|
+
_useRouteMatch$params3 = _useRouteMatch$params.field,
|
|
60
|
+
field = _useRouteMatch$params3 === void 0 ? null : _useRouteMatch$params3,
|
|
61
|
+
_useRouteMatch$params4 = _useRouteMatch$params.form,
|
|
62
|
+
form = _useRouteMatch$params4 === void 0 ? null : _useRouteMatch$params4;
|
|
66
63
|
var routeParams = useMemo(function () {
|
|
67
64
|
return screenOnly ? {
|
|
68
65
|
url: url,
|
|
@@ -77,7 +74,7 @@ var useRouteParams = function useRouteParams() {
|
|
|
77
74
|
return routeParams;
|
|
78
75
|
};
|
|
79
76
|
|
|
80
|
-
var styles$i = {"container":"micromag-editor-container","left":"micromag-editor-left","right":"micromag-editor-right","
|
|
77
|
+
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"};
|
|
81
78
|
|
|
82
79
|
var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
83
80
|
var lastPageRef = useRef({
|
|
@@ -86,16 +83,14 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
86
83
|
});
|
|
87
84
|
var direction = useMemo(function () {
|
|
88
85
|
var _lastPageRef$current = lastPageRef.current,
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
lastScreenIndex = _lastPageRef$current.screenIndex,
|
|
87
|
+
lastUrl = _lastPageRef$current.url;
|
|
91
88
|
lastPageRef.current.url = url;
|
|
92
89
|
lastPageRef.current.screenIndex = screenIndex;
|
|
93
|
-
|
|
94
90
|
if (screenIndex !== lastScreenIndex) {
|
|
95
91
|
// return screenIndex > lastScreenIndex ? 'bottom' : 'top';
|
|
96
92
|
return null;
|
|
97
93
|
}
|
|
98
|
-
|
|
99
94
|
var urlSplit = url.split('/');
|
|
100
95
|
var lastUrlSplit = lastUrl.split('/');
|
|
101
96
|
var currentPartsCount = urlSplit.length;
|
|
@@ -108,7 +103,6 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
108
103
|
}, [url, screenIndex]);
|
|
109
104
|
var transitionClassNames = useMemo(function () {
|
|
110
105
|
var _classNames, _classNames2, _classNames3;
|
|
111
|
-
|
|
112
106
|
return {
|
|
113
107
|
enter: classNames((_classNames = {}, _defineProperty(_classNames, styles.enterRight, direction === 'right'), _defineProperty(_classNames, styles.enterLeft, direction === 'left'), _defineProperty(_classNames, styles.enterTop, direction === 'top'), _defineProperty(_classNames, styles.enterBottom, direction === 'bottom'), _classNames)) || 'none',
|
|
114
108
|
enterActive: classNames((_classNames2 = {}, _defineProperty(_classNames2, styles.enterActiveHorizontal, direction === 'left' || direction === 'right'), _defineProperty(_classNames2, styles.enterActiveVertical, direction === 'top' || direction === 'bottom'), _classNames2)) || 'none',
|
|
@@ -125,28 +119,25 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
125
119
|
|
|
126
120
|
function getScreenFieldsWithStates(definition) {
|
|
127
121
|
var _ref = definition || {},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
_ref$fields = _ref.fields,
|
|
123
|
+
screenFields = _ref$fields === void 0 ? null : _ref$fields,
|
|
124
|
+
_ref$states = _ref.states,
|
|
125
|
+
states = _ref$states === void 0 ? null : _ref$states;
|
|
133
126
|
if (states === null) {
|
|
134
127
|
return screenFields;
|
|
135
128
|
}
|
|
136
|
-
|
|
137
129
|
var extraFields = states.reduce(function (statesFields, current) {
|
|
138
130
|
var _ref2 = current || {},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
id = _ref2.id,
|
|
132
|
+
_ref2$fields = _ref2.fields,
|
|
133
|
+
fields = _ref2$fields === void 0 ? [] : _ref2$fields,
|
|
134
|
+
_ref2$repeatable = _ref2.repeatable,
|
|
135
|
+
repeatable = _ref2$repeatable === void 0 ? false : _ref2$repeatable,
|
|
136
|
+
_ref2$fieldName = _ref2.fieldName,
|
|
137
|
+
fieldName = _ref2$fieldName === void 0 ? null : _ref2$fieldName,
|
|
138
|
+
label = _ref2.label,
|
|
139
|
+
_ref2$defaultValue = _ref2.defaultValue,
|
|
140
|
+
defaultValue = _ref2$defaultValue === void 0 ? null : _ref2$defaultValue;
|
|
150
141
|
return [].concat(_toConsumableArray(statesFields), _toConsumableArray(repeatable ? [{
|
|
151
142
|
type: 'items',
|
|
152
143
|
name: fieldName || id,
|
|
@@ -181,17 +172,14 @@ var createScreen = function createScreen(definition) {
|
|
|
181
172
|
var screenFields = getScreenFieldsWithStates(finalDefinition);
|
|
182
173
|
var defaultValueFields = screenFields.reduce(function (all, curr) {
|
|
183
174
|
var _ref = curr || {},
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
_ref$name = _ref.name,
|
|
176
|
+
name = _ref$name === void 0 ? null : _ref$name,
|
|
177
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
178
|
+
defaultValue = _ref$defaultValue === void 0 ? null : _ref$defaultValue;
|
|
189
179
|
var newAll = _objectSpread({}, all);
|
|
190
|
-
|
|
191
180
|
if (name !== null && defaultValue !== null) {
|
|
192
181
|
newAll[name] = defaultValue;
|
|
193
182
|
}
|
|
194
|
-
|
|
195
183
|
return newAll;
|
|
196
184
|
}, {});
|
|
197
185
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
@@ -202,13 +190,11 @@ var createScreen = function createScreen(definition) {
|
|
|
202
190
|
};
|
|
203
191
|
|
|
204
192
|
var _excluded$c = ["components"];
|
|
205
|
-
|
|
206
193
|
var deleteScreen = function deleteScreen(story, screenId) {
|
|
207
194
|
var _ref = story || {},
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
195
|
+
_ref$components = _ref.components,
|
|
196
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
197
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$c);
|
|
212
198
|
return _objectSpread(_objectSpread({}, currentValue), {}, {
|
|
213
199
|
components: components.filter(function (_ref2) {
|
|
214
200
|
var id = _ref2.id;
|
|
@@ -218,13 +204,11 @@ var deleteScreen = function deleteScreen(story, screenId) {
|
|
|
218
204
|
};
|
|
219
205
|
|
|
220
206
|
var _excluded$b = ["components"];
|
|
221
|
-
|
|
222
207
|
var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
223
208
|
var _ref = story || {},
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
209
|
+
_ref$components = _ref.components,
|
|
210
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
211
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$b);
|
|
228
212
|
var screen = components.find(function (it) {
|
|
229
213
|
return it.id === screenId;
|
|
230
214
|
}) || null;
|
|
@@ -236,15 +220,12 @@ var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
|
236
220
|
};
|
|
237
221
|
|
|
238
222
|
var _excluded$a = ["components"];
|
|
239
|
-
|
|
240
223
|
var updateScreen = function updateScreen(story, newScreenValue) {
|
|
241
224
|
var newScreenId = newScreenValue.id;
|
|
242
|
-
|
|
243
225
|
var _ref = story || {},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
226
|
+
_ref$components = _ref.components,
|
|
227
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
228
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$a);
|
|
248
229
|
var index = components.findIndex(function (it) {
|
|
249
230
|
return it.id === newScreenId;
|
|
250
231
|
});
|
|
@@ -258,16 +239,13 @@ var getFieldByName = function getFieldByName(fields, name) {
|
|
|
258
239
|
if (foundField !== null) {
|
|
259
240
|
return foundField;
|
|
260
241
|
}
|
|
261
|
-
|
|
262
242
|
var _it$name = it.name,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
243
|
+
fieldName = _it$name === void 0 ? null : _it$name,
|
|
244
|
+
_it$fields = it.fields,
|
|
245
|
+
subFields = _it$fields === void 0 ? [] : _it$fields;
|
|
267
246
|
if (name !== null && fieldName === name) {
|
|
268
247
|
return it;
|
|
269
248
|
}
|
|
270
|
-
|
|
271
249
|
return getFieldByName(subFields, name);
|
|
272
250
|
}, null);
|
|
273
251
|
};
|
|
@@ -281,12 +259,10 @@ var defaultProps$o = {
|
|
|
281
259
|
dots: false,
|
|
282
260
|
className: null
|
|
283
261
|
};
|
|
284
|
-
|
|
285
262
|
var SettingsButton = function SettingsButton(_ref) {
|
|
286
263
|
var className = _ref.className,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
264
|
+
dots = _ref.dots,
|
|
265
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
290
266
|
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
291
267
|
className: className,
|
|
292
268
|
theme: "secondary",
|
|
@@ -296,7 +272,6 @@ var SettingsButton = function SettingsButton(_ref) {
|
|
|
296
272
|
})
|
|
297
273
|
}, props));
|
|
298
274
|
};
|
|
299
|
-
|
|
300
275
|
SettingsButton.propTypes = propTypes$o;
|
|
301
276
|
SettingsButton.defaultProps = defaultProps$o;
|
|
302
277
|
|
|
@@ -311,46 +286,38 @@ var defaultProps$n = {
|
|
|
311
286
|
form: null,
|
|
312
287
|
children: null
|
|
313
288
|
};
|
|
314
|
-
|
|
315
289
|
var FieldWithContexts = function FieldWithContexts(_ref) {
|
|
316
290
|
var name = _ref.name,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
291
|
+
form = _ref.form,
|
|
292
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
320
293
|
var definition = useScreenDefinition() || null;
|
|
321
294
|
var _definition$states = definition.states,
|
|
322
|
-
|
|
295
|
+
states = _definition$states === void 0 ? null : _definition$states;
|
|
323
296
|
var screenFields = getScreenFieldsWithStates(definition);
|
|
324
297
|
var nameParts = name.split('.');
|
|
325
|
-
|
|
326
298
|
var _nameParts = _slicedToArray(nameParts, 1),
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
299
|
+
_nameParts$ = _nameParts[0],
|
|
300
|
+
stateId = _nameParts$ === void 0 ? null : _nameParts$;
|
|
330
301
|
var currentState = states !== null ? states.find(function (_ref2) {
|
|
331
302
|
var id = _ref2.id;
|
|
332
303
|
return id === stateId;
|
|
333
304
|
}) || null : null;
|
|
334
305
|
var finalNameParts = nameParts;
|
|
335
|
-
|
|
336
306
|
var _ref3 = currentState || {},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
307
|
+
_ref3$repeatable = _ref3.repeatable,
|
|
308
|
+
repeatable = _ref3$repeatable === void 0 ? false : _ref3$repeatable,
|
|
309
|
+
_ref3$fieldName = _ref3.fieldName,
|
|
310
|
+
fieldName = _ref3$fieldName === void 0 ? null : _ref3$fieldName,
|
|
311
|
+
_ref3$fields = _ref3.fields,
|
|
312
|
+
stateFields = _ref3$fields === void 0 ? [] : _ref3$fields;
|
|
344
313
|
var finalScreenFields = fieldName !== null && stateId !== null ? screenFields.filter(function (_ref4) {
|
|
345
314
|
var itemName = _ref4.name,
|
|
346
|
-
|
|
315
|
+
fieldStateId = _ref4.stateId;
|
|
347
316
|
return fieldName !== itemName || stateId === fieldStateId || fieldStateId === null;
|
|
348
317
|
}) : screenFields;
|
|
349
|
-
|
|
350
318
|
if (currentState !== null) {
|
|
351
319
|
finalNameParts = (repeatable || fieldName !== null) && nameParts.length <= (repeatable ? 2 : 1) ? [fieldName || stateId].concat(_toConsumableArray(nameParts.slice(1))) : nameParts.slice(1);
|
|
352
320
|
}
|
|
353
|
-
|
|
354
321
|
var formComponents = useFormsComponents();
|
|
355
322
|
return definition !== null ? /*#__PURE__*/React.createElement("div", {
|
|
356
323
|
className: classNames({
|
|
@@ -365,7 +332,6 @@ var FieldWithContexts = function FieldWithContexts(_ref) {
|
|
|
365
332
|
fields: stateFields
|
|
366
333
|
}, props))) : null;
|
|
367
334
|
};
|
|
368
|
-
|
|
369
335
|
FieldWithContexts.propTypes = propTypes$n;
|
|
370
336
|
FieldWithContexts.defaultProps = defaultProps$n;
|
|
371
337
|
|
|
@@ -376,26 +342,27 @@ var propTypes$m = {
|
|
|
376
342
|
className: PropTypes.string,
|
|
377
343
|
gotoFieldForm: PropTypes.func.isRequired,
|
|
378
344
|
closeFieldForm: PropTypes.func.isRequired,
|
|
379
|
-
onChange: PropTypes.func
|
|
380
|
-
|
|
345
|
+
onChange: PropTypes.func
|
|
346
|
+
// onClickDelete: PropTypes.func,
|
|
381
347
|
};
|
|
348
|
+
|
|
382
349
|
var defaultProps$m = {
|
|
383
350
|
value: null,
|
|
384
351
|
className: null,
|
|
385
|
-
onChange: null
|
|
386
|
-
|
|
352
|
+
onChange: null
|
|
353
|
+
// onClickDelete: null,
|
|
387
354
|
};
|
|
388
355
|
|
|
389
356
|
var ScreenForm = function ScreenForm(_ref) {
|
|
390
357
|
var value = _ref.value,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
358
|
+
className = _ref.className,
|
|
359
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
360
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
361
|
+
onChange = _ref.onChange;
|
|
396
362
|
var _useScreenDefinition = useScreenDefinition(),
|
|
397
|
-
|
|
398
|
-
|
|
363
|
+
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
364
|
+
fields = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$;
|
|
365
|
+
// const intl = useIntl();
|
|
399
366
|
// const finalOnClickDelete = useCallback(() => {
|
|
400
367
|
// if (
|
|
401
368
|
// onClickDelete !== null &&
|
|
@@ -409,8 +376,6 @@ var ScreenForm = function ScreenForm(_ref) {
|
|
|
409
376
|
// onClickDelete(value);
|
|
410
377
|
// }
|
|
411
378
|
// }, [intl, onClickDelete, value]);
|
|
412
|
-
|
|
413
|
-
|
|
414
379
|
return /*#__PURE__*/React.createElement("div", {
|
|
415
380
|
className: classNames([styles$h.container, _defineProperty({}, className, className)])
|
|
416
381
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -423,7 +388,6 @@ var ScreenForm = function ScreenForm(_ref) {
|
|
|
423
388
|
closeFieldForm: closeFieldForm
|
|
424
389
|
}) : null));
|
|
425
390
|
};
|
|
426
|
-
|
|
427
391
|
ScreenForm.propTypes = propTypes$m;
|
|
428
392
|
ScreenForm.defaultProps = defaultProps$m;
|
|
429
393
|
|
|
@@ -444,110 +408,94 @@ var defaultProps$l = {
|
|
|
444
408
|
form: null,
|
|
445
409
|
className: null
|
|
446
410
|
};
|
|
447
|
-
|
|
448
411
|
var Breadcrumb = function Breadcrumb(_ref) {
|
|
449
412
|
var story = _ref.story,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
413
|
+
screenId = _ref.screenId,
|
|
414
|
+
field = _ref.field,
|
|
415
|
+
form = _ref.form,
|
|
416
|
+
url = _ref.url,
|
|
417
|
+
className = _ref.className;
|
|
455
418
|
var intl = useIntl();
|
|
456
|
-
|
|
457
419
|
var _ref2 = story || {},
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
420
|
+
_ref2$components = _ref2.components,
|
|
421
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
461
422
|
var history = useHistory();
|
|
462
423
|
var screensManager = useScreensManager();
|
|
463
424
|
var fieldsManager = useFieldsManager();
|
|
464
425
|
var route = useUrlGenerator();
|
|
465
|
-
|
|
466
426
|
var _useMemo = useMemo(function () {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
var _screens$screenIndex = screens[screenIndex],
|
|
427
|
+
var screenIndex = screens.findIndex(function (it) {
|
|
428
|
+
return it.id === screenId;
|
|
429
|
+
});
|
|
430
|
+
if (!screens[screenIndex]) {
|
|
431
|
+
return {};
|
|
432
|
+
}
|
|
433
|
+
var _screens$screenIndex = screens[screenIndex],
|
|
476
434
|
type = _screens$screenIndex.type,
|
|
477
435
|
_screens$screenIndex$ = _screens$screenIndex.parameters,
|
|
478
436
|
parameters = _screens$screenIndex$ === void 0 ? null : _screens$screenIndex$;
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
var _ref3 = definition || {},
|
|
437
|
+
var definition = screensManager.getDefinition(type);
|
|
438
|
+
var _ref3 = definition || {},
|
|
482
439
|
_ref3$states = _ref3.states,
|
|
483
440
|
states = _ref3$states === void 0 ? null : _ref3$states,
|
|
484
441
|
_ref3$title = _ref3.title,
|
|
485
442
|
definitionTitle = _ref3$title === void 0 ? null : _ref3$title;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
screenParameters = _useMemo$parameters === void 0 ? null : _useMemo$parameters;
|
|
502
|
-
|
|
443
|
+
return {
|
|
444
|
+
title: definitionTitle,
|
|
445
|
+
fields: definition !== null ? [].concat(_toConsumableArray(getScreenFieldsWithStates(definition)), [getScreenExtraField(intl)]) : null,
|
|
446
|
+
states: states,
|
|
447
|
+
parameters: parameters
|
|
448
|
+
};
|
|
449
|
+
}, [screens, screenId, screensManager, intl]),
|
|
450
|
+
_useMemo$title = _useMemo.title,
|
|
451
|
+
screenTitle = _useMemo$title === void 0 ? null : _useMemo$title,
|
|
452
|
+
_useMemo$fields = _useMemo.fields,
|
|
453
|
+
screenFields = _useMemo$fields === void 0 ? [] : _useMemo$fields,
|
|
454
|
+
_useMemo$states = _useMemo.states,
|
|
455
|
+
screenStates = _useMemo$states === void 0 ? null : _useMemo$states,
|
|
456
|
+
_useMemo$parameters = _useMemo.parameters,
|
|
457
|
+
screenParameters = _useMemo$parameters === void 0 ? null : _useMemo$parameters;
|
|
503
458
|
var items = useMemo(function () {
|
|
504
459
|
var fieldItems = [];
|
|
505
460
|
var currentState = null;
|
|
506
|
-
|
|
507
461
|
if (field !== null) {
|
|
508
|
-
var fieldPath = field.split('/');
|
|
462
|
+
var fieldPath = field.split('/');
|
|
509
463
|
|
|
464
|
+
// Get state and remove it from path. Replace it with field name if necessary (repeatable or fieldName present)
|
|
510
465
|
var _fieldPath = _slicedToArray(fieldPath, 1),
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
466
|
+
_fieldPath$ = _fieldPath[0],
|
|
467
|
+
stateId = _fieldPath$ === void 0 ? null : _fieldPath$;
|
|
514
468
|
currentState = screenStates !== null ? screenStates.find(function (_ref4) {
|
|
515
469
|
var id = _ref4.id;
|
|
516
470
|
return id === stateId;
|
|
517
471
|
}) || null : null;
|
|
518
472
|
var finalFieldPath = fieldPath;
|
|
519
|
-
|
|
520
473
|
if (currentState !== null) {
|
|
521
474
|
var _ref5 = currentState || {},
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
475
|
+
_ref5$repeatable = _ref5.repeatable,
|
|
476
|
+
repeatable = _ref5$repeatable === void 0 ? false : _ref5$repeatable,
|
|
477
|
+
_ref5$fieldName = _ref5.fieldName,
|
|
478
|
+
fieldName = _ref5$fieldName === void 0 ? null : _ref5$fieldName;
|
|
527
479
|
finalFieldPath = (repeatable || fieldName !== null) && fieldPath.length <= (repeatable ? 2 : 1) ? [fieldName || stateId].concat(_toConsumableArray(fieldPath.slice(1))) : fieldPath.slice(1);
|
|
528
480
|
}
|
|
529
|
-
|
|
530
481
|
var lastKeyIndex = finalFieldPath.length - 1;
|
|
531
482
|
var parentItem = null;
|
|
532
483
|
finalFieldPath.reduce(function (currentFields, key, keyIndex) {
|
|
533
484
|
var _ref6 = currentFields || {},
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
485
|
+
_ref6$type = _ref6.type,
|
|
486
|
+
fieldType = _ref6$type === void 0 ? null : _ref6$type,
|
|
487
|
+
_ref6$fields = _ref6.fields,
|
|
488
|
+
currentSubFields = _ref6$fields === void 0 ? null : _ref6$fields,
|
|
489
|
+
_ref6$itemsField = _ref6.itemsField,
|
|
490
|
+
currentItemsField = _ref6$itemsField === void 0 ? null : _ref6$itemsField;
|
|
541
491
|
var fieldsDef = fieldType !== null ? fieldsManager.getDefinition(fieldType) : currentFields;
|
|
542
|
-
|
|
543
492
|
var _ref7 = fieldsDef || {},
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
493
|
+
_ref7$fields = _ref7.fields,
|
|
494
|
+
defSubFields = _ref7$fields === void 0 ? null : _ref7$fields,
|
|
495
|
+
_ref7$settings = _ref7.settings,
|
|
496
|
+
settings = _ref7$settings === void 0 ? null : _ref7$settings,
|
|
497
|
+
_ref7$itemsField = _ref7.itemsField,
|
|
498
|
+
defItemsField = _ref7$itemsField === void 0 ? null : _ref7$itemsField;
|
|
551
499
|
var itemsField = currentItemsField || defItemsField;
|
|
552
500
|
var subFields = currentSubFields || defSubFields;
|
|
553
501
|
var currentSubfields = subFields !== null ? getFieldByName(subFields, key) : null;
|
|
@@ -566,12 +514,10 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
566
514
|
var addNewItem = isLastIndex || isListItems;
|
|
567
515
|
var itemPath = "".concat(pathPrefix).concat(pathSuffix);
|
|
568
516
|
var nextFields = null;
|
|
569
|
-
|
|
570
517
|
if (isCurrentSubfields) {
|
|
571
518
|
nextFields = currentSubfields;
|
|
572
519
|
} else if (isCurrentSettings) {
|
|
573
520
|
nextFields = currentSettings;
|
|
574
|
-
|
|
575
521
|
if (parentItem !== null) {
|
|
576
522
|
fieldItems.push(_objectSpread(_objectSpread({}, parentItem), {}, {
|
|
577
523
|
url: route('screen.field.form', {
|
|
@@ -586,44 +532,36 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
586
532
|
} else if (isListItems) {
|
|
587
533
|
nextFields = itemsField;
|
|
588
534
|
}
|
|
589
|
-
|
|
590
535
|
var fieldLabel = nextFields ? nextFields.breadcrumbLabel || nextFields.label : null;
|
|
591
536
|
var itemLabel = isMessage(fieldLabel) ? intl.formatMessage(fieldLabel) : fieldLabel;
|
|
592
|
-
|
|
593
537
|
var _ref8 = parentItem || {},
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
538
|
+
_ref8$label = _ref8.label,
|
|
539
|
+
parentItemLabel = _ref8$label === void 0 ? null : _ref8$label;
|
|
597
540
|
var finalItemLabel = isListItems ? "".concat(itemLabel, " #").concat(parseInt(key, 10) + 1) : itemLabel || parentItemLabel;
|
|
598
541
|
var item = {
|
|
599
542
|
url: itemPath,
|
|
600
543
|
label: finalItemLabel || '',
|
|
601
544
|
active: false
|
|
602
545
|
};
|
|
603
|
-
|
|
604
546
|
if (addNewItem) {
|
|
605
547
|
fieldItems.push(item);
|
|
606
548
|
}
|
|
607
|
-
|
|
608
549
|
parentItem = item;
|
|
609
550
|
return nextFields;
|
|
610
551
|
}, {
|
|
611
552
|
fields: stateId === null ? screenFields : screenFields.filter(function (_ref9) {
|
|
612
553
|
var _ref9$stateId = _ref9.stateId,
|
|
613
|
-
|
|
554
|
+
fieldStateId = _ref9$stateId === void 0 ? null : _ref9$stateId;
|
|
614
555
|
return fieldStateId === null || fieldStateId === stateId;
|
|
615
556
|
})
|
|
616
557
|
});
|
|
617
558
|
}
|
|
618
|
-
|
|
619
559
|
var _ref10 = screenParameters || {},
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
560
|
+
_ref10$metadata = _ref10.metadata,
|
|
561
|
+
metadata = _ref10$metadata === void 0 ? null : _ref10$metadata;
|
|
623
562
|
var _ref11 = metadata || {},
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
563
|
+
_ref11$title = _ref11.title,
|
|
564
|
+
title = _ref11$title === void 0 ? null : _ref11$title;
|
|
627
565
|
var typeTitle = screenTitle !== null ? /*#__PURE__*/React.createElement(FormattedMessage, screenTitle) : null;
|
|
628
566
|
var parametersMessage = intl.formatMessage({
|
|
629
567
|
id: "AHvHaY",
|
|
@@ -669,7 +607,6 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
669
607
|
className: classNames([styles$g.container, 'text-truncate', _defineProperty({}, className, className !== null)])
|
|
670
608
|
}));
|
|
671
609
|
};
|
|
672
|
-
|
|
673
610
|
Breadcrumb.propTypes = propTypes$l;
|
|
674
611
|
Breadcrumb.defaultProps = defaultProps$l;
|
|
675
612
|
|
|
@@ -685,11 +622,10 @@ var defaultProps$k = {
|
|
|
685
622
|
onConfirm: null,
|
|
686
623
|
onCancel: null
|
|
687
624
|
};
|
|
688
|
-
|
|
689
625
|
var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
690
626
|
var className = _ref.className,
|
|
691
|
-
|
|
692
|
-
|
|
627
|
+
onConfirm = _ref.onConfirm,
|
|
628
|
+
onCancel = _ref.onCancel;
|
|
693
629
|
return /*#__PURE__*/React.createElement(Modal, null, /*#__PURE__*/React.createElement(ModalDialog, {
|
|
694
630
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
695
631
|
id: "p6q/+/",
|
|
@@ -731,11 +667,10 @@ var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
|
731
667
|
})
|
|
732
668
|
}))));
|
|
733
669
|
};
|
|
734
|
-
|
|
735
670
|
DeleteScreenModal.propTypes = propTypes$k;
|
|
736
671
|
DeleteScreenModal.defaultProps = defaultProps$k;
|
|
737
672
|
|
|
738
|
-
var styles$e = {"panel":"micromag-editor-form-panel","exit":"micromag-editor-form-exit","content":"micromag-editor-form-content","navbar":"micromag-editor-form-navbar","
|
|
673
|
+
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"};
|
|
739
674
|
|
|
740
675
|
var propTypes$j = {
|
|
741
676
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
@@ -749,30 +684,27 @@ var defaultProps$j = {
|
|
|
749
684
|
className: null,
|
|
750
685
|
onChange: null
|
|
751
686
|
};
|
|
752
|
-
|
|
753
687
|
var EditForm = function EditForm(_ref) {
|
|
754
688
|
var value = _ref.value,
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
689
|
+
isTheme = _ref.isTheme,
|
|
690
|
+
className = _ref.className,
|
|
691
|
+
onChange = _ref.onChange;
|
|
758
692
|
// Match routes
|
|
759
693
|
var history = useHistory();
|
|
760
694
|
var routePush = useRoutePush();
|
|
761
|
-
|
|
762
695
|
var _useRouteParams = useRouteParams(),
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
696
|
+
url = _useRouteParams.url,
|
|
697
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
698
|
+
screenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
699
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
700
|
+
fieldParams = _useRouteParams$field === void 0 ? null : _useRouteParams$field,
|
|
701
|
+
_useRouteParams$form = _useRouteParams.form,
|
|
702
|
+
formParams = _useRouteParams$form === void 0 ? null : _useRouteParams$form;
|
|
703
|
+
|
|
704
|
+
// Get screen
|
|
772
705
|
var _ref2 = value || {},
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
706
|
+
_ref2$components = _ref2.components,
|
|
707
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
776
708
|
var screenIndex = screens.findIndex(function (it) {
|
|
777
709
|
return it.id === screenId;
|
|
778
710
|
});
|
|
@@ -780,62 +712,54 @@ var EditForm = function EditForm(_ref) {
|
|
|
780
712
|
var screensManager = useScreensManager();
|
|
781
713
|
var screenFields = useMemo(function () {
|
|
782
714
|
var _ref3 = screen || {},
|
|
783
|
-
|
|
784
|
-
|
|
715
|
+
type = _ref3.type;
|
|
785
716
|
var definition = type !== null ? screensManager.getDefinition(type) : null;
|
|
786
717
|
return definition != null ? getScreenFieldsWithStates(definition) : [];
|
|
787
|
-
}, [screensManager, screen]);
|
|
718
|
+
}, [screensManager, screen]);
|
|
788
719
|
|
|
720
|
+
// Get transition value
|
|
789
721
|
var _useFormTransition = useFormTransition(url, screenIndex, styles$e),
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
722
|
+
transitionClassNames = _useFormTransition.classNames,
|
|
723
|
+
transitionTimeout = _useFormTransition.timeout;
|
|
793
724
|
var _useState = useState(false),
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
725
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
726
|
+
screenSettingsOpened = _useState2[0],
|
|
727
|
+
setScreenSettingsOpened = _useState2[1];
|
|
798
728
|
var _useState3 = useState(false),
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
729
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
730
|
+
deleteScreenModalOpened = _useState4[0],
|
|
731
|
+
setDeleteScreenModalOpened = _useState4[1];
|
|
803
732
|
var _useState5 = useState({}),
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
733
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
734
|
+
fieldForms = _useState6[0],
|
|
735
|
+
setFieldForms = _useState6[1];
|
|
808
736
|
var _useState7 = useState(null),
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
737
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
738
|
+
fieldContext = _useState8[0],
|
|
739
|
+
setFieldContext = _useState8[1];
|
|
813
740
|
|
|
741
|
+
// Callbacks
|
|
814
742
|
var gotoFieldForm = useCallback(function () {
|
|
815
743
|
var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
816
744
|
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
817
745
|
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
818
746
|
var hasField = field !== null;
|
|
819
747
|
var fieldRoute = formName !== null ? 'screen.field.form' : 'screen.field';
|
|
820
|
-
|
|
821
748
|
var _ref4 = field !== null ? field.split('.') : [],
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
749
|
+
_ref5 = _slicedToArray(_ref4, 1),
|
|
750
|
+
_ref5$ = _ref5[0],
|
|
751
|
+
rootFieldName = _ref5$ === void 0 ? null : _ref5$;
|
|
826
752
|
var _ref6 = fieldParams !== null ? fieldParams.split('/') : [],
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
753
|
+
_ref7 = _slicedToArray(_ref6, 1),
|
|
754
|
+
_ref7$ = _ref7[0],
|
|
755
|
+
currentStateId = _ref7$ === void 0 ? null : _ref7$;
|
|
831
756
|
var _ref8 = (rootFieldName !== null ? screenFields.find(function (_ref9) {
|
|
832
|
-
|
|
757
|
+
var name = _ref9.name,
|
|
833
758
|
fieldStateId = _ref9.stateId;
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
759
|
+
return name === rootFieldName && currentStateId === fieldStateId;
|
|
760
|
+
}) || null : null) || {},
|
|
761
|
+
_ref8$stateId = _ref8.stateId,
|
|
762
|
+
stateId = _ref8$stateId === void 0 ? null : _ref8$stateId;
|
|
839
763
|
routePush(hasField ? fieldRoute : 'screen', {
|
|
840
764
|
screen: screenId,
|
|
841
765
|
field: field !== null ? [stateId].concat(_toConsumableArray(field.split('.'))).filter(function (it) {
|
|
@@ -850,11 +774,9 @@ var EditForm = function EditForm(_ref) {
|
|
|
850
774
|
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
851
775
|
var fieldKey = "".concat(field).concat(formName !== null ? ":".concat(formName) : '');
|
|
852
776
|
var pastUrl = fieldForms[fieldKey] || null;
|
|
853
|
-
|
|
854
777
|
if (pastUrl !== null) {
|
|
855
778
|
history.push(pastUrl);
|
|
856
779
|
}
|
|
857
|
-
|
|
858
780
|
setFieldForms(Object.keys(fieldForms).reduce(function (map, key) {
|
|
859
781
|
return key !== fieldKey ? _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, fieldForms[key])) : map;
|
|
860
782
|
}, {}));
|
|
@@ -884,25 +806,22 @@ var EditForm = function EditForm(_ref) {
|
|
|
884
806
|
var onDeleteScreenConfirm = useCallback(function () {
|
|
885
807
|
var current = screens.findIndex(function (_ref10) {
|
|
886
808
|
var _ref10$id = _ref10.id,
|
|
887
|
-
|
|
809
|
+
scrId = _ref10$id === void 0 ? null : _ref10$id;
|
|
888
810
|
return scrId === screenId;
|
|
889
811
|
}) || 0;
|
|
890
812
|
var previous = screens.find(function (_ref11, i) {
|
|
891
813
|
var _ref11$id = _ref11.id,
|
|
892
|
-
|
|
814
|
+
scrId = _ref11$id === void 0 ? null : _ref11$id;
|
|
893
815
|
return scrId !== screenId && (i === current - 1 || current === 0);
|
|
894
816
|
}) || null;
|
|
895
|
-
|
|
896
817
|
if (previous !== null) {
|
|
897
818
|
var _ref12 = previous || {},
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
819
|
+
_ref12$id = _ref12.id,
|
|
820
|
+
firstScreenId = _ref12$id === void 0 ? null : _ref12$id;
|
|
901
821
|
routePush('screen', {
|
|
902
822
|
screen: firstScreenId
|
|
903
823
|
});
|
|
904
824
|
}
|
|
905
|
-
|
|
906
825
|
triggerOnChange(deleteScreen(value, screenId));
|
|
907
826
|
setDeleteScreenModalOpened(false);
|
|
908
827
|
}, [value, triggerOnChange, screenId, setScreenSettingsOpened, routePush, screens]);
|
|
@@ -1014,40 +933,33 @@ var EditForm = function EditForm(_ref) {
|
|
|
1014
933
|
onCancel: onDeleteScreenCancel
|
|
1015
934
|
}) : null);
|
|
1016
935
|
};
|
|
1017
|
-
|
|
1018
936
|
EditForm.propTypes = propTypes$j;
|
|
1019
937
|
EditForm.defaultProps = defaultProps$j;
|
|
1020
938
|
|
|
1021
939
|
function useScreenStates(screen) {
|
|
1022
940
|
var _ref = screen || {},
|
|
1023
|
-
|
|
1024
|
-
|
|
941
|
+
type = _ref.type;
|
|
1025
942
|
var screensManager = useScreensManager();
|
|
1026
943
|
var states = useMemo(function () {
|
|
1027
944
|
var definition = screensManager.getDefinition(type) || null;
|
|
1028
|
-
|
|
1029
945
|
var _ref2 = definition || {},
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
946
|
+
_ref2$states = _ref2.states,
|
|
947
|
+
screenStates = _ref2$states === void 0 ? null : _ref2$states;
|
|
1033
948
|
return screenStates;
|
|
1034
949
|
}, [screensManager, type]);
|
|
1035
950
|
return states;
|
|
1036
951
|
}
|
|
1037
952
|
|
|
1038
953
|
var _excluded$7 = ["components"];
|
|
1039
|
-
|
|
1040
954
|
var useThemeValue = function useThemeValue(value) {
|
|
1041
955
|
var isTheme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1042
956
|
var valueWithTheme = useMemo(function () {
|
|
1043
957
|
if (!isTheme) {
|
|
1044
958
|
return value;
|
|
1045
959
|
}
|
|
1046
|
-
|
|
1047
960
|
var _ref = value || {};
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
961
|
+
_ref.components;
|
|
962
|
+
var themeValue = _objectWithoutProperties(_ref, _excluded$7);
|
|
1051
963
|
return value !== null ? _objectSpread({
|
|
1052
964
|
theme: themeValue
|
|
1053
965
|
}, value) : value;
|
|
@@ -1066,10 +978,9 @@ var defaultProps$i = {
|
|
|
1066
978
|
color: 'currentColor',
|
|
1067
979
|
className: null
|
|
1068
980
|
};
|
|
1069
|
-
|
|
1070
981
|
var DesktopIcon = function DesktopIcon(_ref) {
|
|
1071
982
|
var color = _ref.color,
|
|
1072
|
-
|
|
983
|
+
className = _ref.className;
|
|
1073
984
|
return /*#__PURE__*/React.createElement("svg", {
|
|
1074
985
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1075
986
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
@@ -1086,7 +997,6 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
1086
997
|
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"
|
|
1087
998
|
}));
|
|
1088
999
|
};
|
|
1089
|
-
|
|
1090
1000
|
DesktopIcon.propTypes = propTypes$i;
|
|
1091
1001
|
DesktopIcon.defaultProps = defaultProps$i;
|
|
1092
1002
|
|
|
@@ -1099,10 +1009,9 @@ var defaultProps$h = {
|
|
|
1099
1009
|
color: 'currentColor',
|
|
1100
1010
|
className: null
|
|
1101
1011
|
};
|
|
1102
|
-
|
|
1103
1012
|
var MobileIcon = function MobileIcon(_ref) {
|
|
1104
1013
|
var color = _ref.color,
|
|
1105
|
-
|
|
1014
|
+
className = _ref.className;
|
|
1106
1015
|
return /*#__PURE__*/React.createElement("svg", {
|
|
1107
1016
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1108
1017
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
@@ -1119,7 +1028,6 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
1119
1028
|
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"
|
|
1120
1029
|
}));
|
|
1121
1030
|
};
|
|
1122
|
-
|
|
1123
1031
|
MobileIcon.propTypes = propTypes$h;
|
|
1124
1032
|
MobileIcon.defaultProps = defaultProps$h;
|
|
1125
1033
|
|
|
@@ -1141,13 +1049,11 @@ var defaultProps$g = {
|
|
|
1141
1049
|
iconComponents: DeviceIcons,
|
|
1142
1050
|
className: null
|
|
1143
1051
|
};
|
|
1144
|
-
|
|
1145
1052
|
var DeviceButton = function DeviceButton(_ref) {
|
|
1146
1053
|
var device = _ref.device,
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1054
|
+
className = _ref.className,
|
|
1055
|
+
iconComponents = _ref.iconComponents,
|
|
1056
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
1151
1057
|
var DeviceIcon = getComponentFromName(device, iconComponents, DesktopIcon);
|
|
1152
1058
|
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
1153
1059
|
className: classNames([styles$c.container, _defineProperty({}, className, className !== null)])
|
|
@@ -1155,7 +1061,6 @@ var DeviceButton = function DeviceButton(_ref) {
|
|
|
1155
1061
|
className: styles$c.icon
|
|
1156
1062
|
}));
|
|
1157
1063
|
};
|
|
1158
|
-
|
|
1159
1064
|
DeviceButton.propTypes = propTypes$g;
|
|
1160
1065
|
DeviceButton.defaultProps = defaultProps$g;
|
|
1161
1066
|
|
|
@@ -1170,19 +1075,17 @@ var defaultProps$f = {
|
|
|
1170
1075
|
className: null,
|
|
1171
1076
|
onClickItem: null
|
|
1172
1077
|
};
|
|
1173
|
-
|
|
1174
1078
|
var DevicesMenu = function DevicesMenu(_ref) {
|
|
1175
1079
|
var items = _ref.items,
|
|
1176
|
-
|
|
1177
|
-
|
|
1080
|
+
className = _ref.className,
|
|
1081
|
+
onClickItem = _ref.onClickItem;
|
|
1178
1082
|
return /*#__PURE__*/React.createElement(Tabs, {
|
|
1179
1083
|
items: items,
|
|
1180
1084
|
theme: "outline-secondary",
|
|
1181
1085
|
className: classNames([styles$d.container, _defineProperty({}, className, className !== null)]),
|
|
1182
1086
|
renderItemButton: function renderItemButton(item, index, props) {
|
|
1183
1087
|
var id = item.id,
|
|
1184
|
-
|
|
1185
|
-
|
|
1088
|
+
itemProps = _objectWithoutProperties(item, _excluded$5);
|
|
1186
1089
|
return /*#__PURE__*/React.createElement(DeviceButton, Object.assign({
|
|
1187
1090
|
device: id
|
|
1188
1091
|
}, props, itemProps, {
|
|
@@ -1194,13 +1097,12 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
1194
1097
|
}
|
|
1195
1098
|
});
|
|
1196
1099
|
};
|
|
1197
|
-
|
|
1198
1100
|
DevicesMenu.propTypes = propTypes$f;
|
|
1199
1101
|
DevicesMenu.defaultProps = defaultProps$f;
|
|
1200
1102
|
|
|
1201
1103
|
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"};
|
|
1202
1104
|
|
|
1203
|
-
var styles$a = {"container":"micromag-editor-buttons-screen-container","button":"micromag-editor-buttons-screen-button","
|
|
1105
|
+
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"};
|
|
1204
1106
|
|
|
1205
1107
|
var propTypes$e = {
|
|
1206
1108
|
active: PropTypes.bool,
|
|
@@ -1213,8 +1115,8 @@ var propTypes$e = {
|
|
|
1213
1115
|
children: PropTypes.node,
|
|
1214
1116
|
refButton: PropTypes.shape({
|
|
1215
1117
|
current: PropTypes.any // eslint-disable-line
|
|
1216
|
-
|
|
1217
1118
|
}),
|
|
1119
|
+
|
|
1218
1120
|
className: PropTypes.string
|
|
1219
1121
|
};
|
|
1220
1122
|
var defaultProps$e = {
|
|
@@ -1229,20 +1131,18 @@ var defaultProps$e = {
|
|
|
1229
1131
|
refButton: null,
|
|
1230
1132
|
className: null
|
|
1231
1133
|
};
|
|
1232
|
-
|
|
1233
1134
|
var ScreenButton = function ScreenButton(_ref) {
|
|
1234
1135
|
var _ref2;
|
|
1235
|
-
|
|
1236
1136
|
var active = _ref.active,
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1137
|
+
id = _ref.id,
|
|
1138
|
+
href = _ref.href,
|
|
1139
|
+
className = _ref.className,
|
|
1140
|
+
label = _ref.label,
|
|
1141
|
+
icon = _ref.icon,
|
|
1142
|
+
children = _ref.children,
|
|
1143
|
+
title = _ref.title,
|
|
1144
|
+
onClick = _ref.onClick,
|
|
1145
|
+
refButton = _ref.refButton;
|
|
1246
1146
|
return /*#__PURE__*/React.createElement("div", {
|
|
1247
1147
|
className: classNames([styles$a.container, 'rounded', (_ref2 = {}, _defineProperty(_ref2, styles$a.active, active), _defineProperty(_ref2, className, className !== null), _ref2)])
|
|
1248
1148
|
}, children !== null ? children : /*#__PURE__*/React.createElement("div", {
|
|
@@ -1265,7 +1165,6 @@ var ScreenButton = function ScreenButton(_ref) {
|
|
|
1265
1165
|
className: classNames([styles$a.border, 'rounded'])
|
|
1266
1166
|
})));
|
|
1267
1167
|
};
|
|
1268
|
-
|
|
1269
1168
|
ScreenButton.propTypes = propTypes$e;
|
|
1270
1169
|
ScreenButton.defaultProps = defaultProps$e;
|
|
1271
1170
|
var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -1299,18 +1198,17 @@ var defaultProps$d = {
|
|
|
1299
1198
|
onClickItem: null,
|
|
1300
1199
|
className: null
|
|
1301
1200
|
};
|
|
1302
|
-
|
|
1303
1201
|
var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
1304
1202
|
var screen = _ref.screen,
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1203
|
+
screenState = _ref.screenState,
|
|
1204
|
+
index = _ref.index,
|
|
1205
|
+
title = _ref.title,
|
|
1206
|
+
href = _ref.href,
|
|
1207
|
+
active = _ref.active,
|
|
1208
|
+
className = _ref.className,
|
|
1209
|
+
_onClick = _ref.onClick,
|
|
1210
|
+
onClickItem = _ref.onClickItem,
|
|
1211
|
+
withPlaceholder = _ref.withPlaceholder;
|
|
1314
1212
|
var intl = useIntl();
|
|
1315
1213
|
var ScreenComponent = withPlaceholder ? ScreenPlaceholder : ScreenPreview;
|
|
1316
1214
|
return /*#__PURE__*/React.createElement(ScreenButton$1, {
|
|
@@ -1322,7 +1220,6 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
|
1322
1220
|
if (_onClick !== null) {
|
|
1323
1221
|
_onClick(screen, index);
|
|
1324
1222
|
}
|
|
1325
|
-
|
|
1326
1223
|
if (onClickItem !== null) {
|
|
1327
1224
|
onClickItem(screen, index);
|
|
1328
1225
|
}
|
|
@@ -1334,7 +1231,6 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
|
1334
1231
|
withSize: true
|
|
1335
1232
|
}));
|
|
1336
1233
|
};
|
|
1337
|
-
|
|
1338
1234
|
ScreenWithPreview.propTypes = propTypes$d;
|
|
1339
1235
|
ScreenWithPreview.defaultProps = defaultProps$d;
|
|
1340
1236
|
|
|
@@ -1350,29 +1246,24 @@ var defaultProps$c = {
|
|
|
1350
1246
|
className: null,
|
|
1351
1247
|
onChange: null
|
|
1352
1248
|
};
|
|
1353
|
-
|
|
1354
1249
|
function ScreenStates(_ref) {
|
|
1355
1250
|
var screen = _ref.screen,
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1251
|
+
value = _ref.value,
|
|
1252
|
+
className = _ref.className,
|
|
1253
|
+
onChange = _ref.onChange;
|
|
1359
1254
|
var url = useUrlGenerator();
|
|
1360
1255
|
var push = useRoutePush();
|
|
1361
|
-
|
|
1362
1256
|
var _useRouteParams = useRouteParams(),
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1257
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
1258
|
+
screenParam = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
1259
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
1260
|
+
field = _useRouteParams$field === void 0 ? null : _useRouteParams$field;
|
|
1368
1261
|
var states = useScreenStates(screen);
|
|
1369
|
-
|
|
1370
1262
|
var _ref2 = field !== null ? field.split('/') : [],
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1263
|
+
_ref3 = _toArray(_ref2),
|
|
1264
|
+
_ref3$ = _ref3[0],
|
|
1265
|
+
stateParam = _ref3$ === void 0 ? null : _ref3$,
|
|
1266
|
+
stateIndexes = _ref3.slice(1);
|
|
1376
1267
|
var stateIndex = stateIndexes.find(function (it) {
|
|
1377
1268
|
return it.match(/^[0-9]+$/) !== null;
|
|
1378
1269
|
}) || null;
|
|
@@ -1401,42 +1292,36 @@ function ScreenStates(_ref) {
|
|
|
1401
1292
|
})
|
|
1402
1293
|
})), states.map(function (state) {
|
|
1403
1294
|
var id = state.id,
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1295
|
+
_state$label = state.label,
|
|
1296
|
+
label = _state$label === void 0 ? null : _state$label,
|
|
1297
|
+
_state$repeatable = state.repeatable,
|
|
1298
|
+
repeatable = _state$repeatable === void 0 ? false : _state$repeatable,
|
|
1299
|
+
_state$withoutCreate = state.withoutCreate,
|
|
1300
|
+
withoutCreate = _state$withoutCreate === void 0 ? false : _state$withoutCreate,
|
|
1301
|
+
_state$fieldName = state.fieldName,
|
|
1302
|
+
fieldName = _state$fieldName === void 0 ? null : _state$fieldName;
|
|
1412
1303
|
var repeatableItems = repeatable ? screen[fieldName || id] || [] : null;
|
|
1413
|
-
|
|
1414
1304
|
var onClickAdd = function onClickAdd() {
|
|
1415
1305
|
var _ref6 = value || {},
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1306
|
+
_ref6$components = _ref6.components,
|
|
1307
|
+
currentComponentsValue = _ref6$components === void 0 ? [] : _ref6$components;
|
|
1419
1308
|
var currentScreenIndex = currentComponentsValue.findIndex(function (_ref7) {
|
|
1420
1309
|
var screenId = _ref7.id;
|
|
1421
1310
|
return screen.id === screenId;
|
|
1422
1311
|
});
|
|
1423
1312
|
var currentScreenValue = currentComponentsValue[currentScreenIndex] || {};
|
|
1424
1313
|
var currentFieldValue = currentScreenValue[fieldName || id] || [];
|
|
1425
|
-
|
|
1426
1314
|
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
1427
1315
|
components: [].concat(_toConsumableArray(currentComponentsValue.slice(0, currentScreenIndex)), [_objectSpread(_objectSpread({}, currentScreenValue), {}, _defineProperty({}, fieldName || id, [].concat(_toConsumableArray(currentFieldValue), [{}])))], _toConsumableArray(currentComponentsValue.slice(currentScreenIndex + 1)))
|
|
1428
1316
|
});
|
|
1429
|
-
|
|
1430
1317
|
if (onChange !== null) {
|
|
1431
1318
|
onChange(newValue);
|
|
1432
1319
|
}
|
|
1433
|
-
|
|
1434
1320
|
push('screen.field', {
|
|
1435
1321
|
screen: screen.id,
|
|
1436
1322
|
field: [id, currentFieldValue.length]
|
|
1437
1323
|
});
|
|
1438
1324
|
};
|
|
1439
|
-
|
|
1440
1325
|
return /*#__PURE__*/React.createElement("div", {
|
|
1441
1326
|
className: "p-1 align-self-stretch d-flex flex-column"
|
|
1442
1327
|
}, /*#__PURE__*/React.createElement("h6", {
|
|
@@ -1476,12 +1361,12 @@ function ScreenStates(_ref) {
|
|
|
1476
1361
|
href: url('screen.field', {
|
|
1477
1362
|
screen: screen.id,
|
|
1478
1363
|
field: id
|
|
1479
|
-
})
|
|
1364
|
+
})
|
|
1365
|
+
// onClick={() => {
|
|
1480
1366
|
// if (onStateChange !== null) {
|
|
1481
1367
|
// onStateChange(id);
|
|
1482
1368
|
// }
|
|
1483
1369
|
// }}
|
|
1484
|
-
|
|
1485
1370
|
}));
|
|
1486
1371
|
})));
|
|
1487
1372
|
}
|
|
@@ -1489,7 +1374,7 @@ function ScreenStates(_ref) {
|
|
|
1489
1374
|
ScreenStates.propTypes = propTypes$c;
|
|
1490
1375
|
ScreenStates.defaultProps = defaultProps$c;
|
|
1491
1376
|
|
|
1492
|
-
var styles$8 = {"container":"micromag-editor-preview-container","
|
|
1377
|
+
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"};
|
|
1493
1378
|
|
|
1494
1379
|
var propTypes$b = {
|
|
1495
1380
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
@@ -1521,44 +1406,39 @@ var defaultProps$b = {
|
|
|
1521
1406
|
onChange: null,
|
|
1522
1407
|
withoutDevicesSizes: true
|
|
1523
1408
|
};
|
|
1524
|
-
|
|
1525
1409
|
var EditorPreview = function EditorPreview(_ref) {
|
|
1526
1410
|
var _ref8;
|
|
1527
|
-
|
|
1528
1411
|
var value = _ref.value,
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1412
|
+
viewerTheme = _ref.viewerTheme,
|
|
1413
|
+
isTheme = _ref.isTheme,
|
|
1414
|
+
devices = _ref.devices,
|
|
1415
|
+
initialDevice = _ref.device,
|
|
1416
|
+
className = _ref.className,
|
|
1417
|
+
onScreenChange = _ref.onScreenChange,
|
|
1418
|
+
onChange = _ref.onChange,
|
|
1419
|
+
withoutDevicesSizes = _ref.withoutDevicesSizes;
|
|
1538
1420
|
var _useRouteParams = useRouteParams(),
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1421
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
1422
|
+
screenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
1423
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
1424
|
+
fieldParam = _useRouteParams$field === void 0 ? null : _useRouteParams$field;
|
|
1544
1425
|
var _useScreenSize = useScreenSize(),
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1426
|
+
_useScreenSize$screen = _useScreenSize.screen,
|
|
1427
|
+
screen = _useScreenSize$screen === void 0 ? null : _useScreenSize$screen,
|
|
1428
|
+
_useScreenSize$screen2 = _useScreenSize.screens,
|
|
1429
|
+
screens = _useScreenSize$screen2 === void 0 ? [] : _useScreenSize$screen2;
|
|
1430
|
+
var valueWithTheme = useThemeValue(value, isTheme);
|
|
1431
|
+
// const valueParsed = valueWithTheme;
|
|
1552
1432
|
var valueParsed = useParsedStory(valueWithTheme, {
|
|
1553
1433
|
withTheme: isTheme,
|
|
1554
1434
|
withMedias: false
|
|
1555
|
-
});
|
|
1435
|
+
});
|
|
1556
1436
|
|
|
1437
|
+
// Get device
|
|
1557
1438
|
var _useState = useState(initialDevice || devices[0].id),
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1439
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1440
|
+
deviceId = _useState2[0],
|
|
1441
|
+
setDeviceId = _useState2[1];
|
|
1562
1442
|
var onClickDeviceItem = useCallback(function (e, it) {
|
|
1563
1443
|
return setDeviceId(it.id);
|
|
1564
1444
|
}, [setDeviceId]);
|
|
@@ -1566,62 +1446,54 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1566
1446
|
return devices.find(function (it) {
|
|
1567
1447
|
return it.id === deviceId;
|
|
1568
1448
|
});
|
|
1569
|
-
}, [devices, deviceId]);
|
|
1449
|
+
}, [devices, deviceId]);
|
|
1570
1450
|
|
|
1451
|
+
// Calculate preview style
|
|
1571
1452
|
var _useDimensionObserver = useDimensionObserver(),
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1453
|
+
bottomRef = _useDimensionObserver.ref,
|
|
1454
|
+
_useDimensionObserver2 = _useDimensionObserver.width,
|
|
1455
|
+
bottomWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2,
|
|
1456
|
+
_useDimensionObserver3 = _useDimensionObserver.height,
|
|
1457
|
+
bottomHeight = _useDimensionObserver3 === void 0 ? 0 : _useDimensionObserver3;
|
|
1578
1458
|
var previewStyle = useMemo(function () {
|
|
1579
1459
|
if (withoutDevicesSizes && initialDevice === null) {
|
|
1580
1460
|
return {};
|
|
1581
1461
|
}
|
|
1582
|
-
|
|
1583
1462
|
var deviceWidth = device.width,
|
|
1584
|
-
|
|
1463
|
+
deviceHeight = device.height;
|
|
1585
1464
|
var maxWidth = screen === 'mobile' ? bottomWidth : deviceWidth;
|
|
1586
1465
|
var maxHeight = screen === 'mobile' ? bottomHeight : deviceHeight;
|
|
1587
|
-
|
|
1588
1466
|
var _getSizeWithinBounds = getSizeWithinBounds(maxWidth, maxHeight, bottomWidth, bottomHeight),
|
|
1589
|
-
|
|
1590
|
-
|
|
1467
|
+
previewScale = _getSizeWithinBounds.scale;
|
|
1591
1468
|
return {
|
|
1592
1469
|
width: maxWidth * previewScale,
|
|
1593
|
-
height: maxHeight * previewScale
|
|
1594
|
-
|
|
1470
|
+
height: maxHeight * previewScale
|
|
1471
|
+
// transform: `scale(${previewScale}, ${previewScale})`,
|
|
1595
1472
|
};
|
|
1596
1473
|
}, [device, bottomWidth, bottomHeight, screen, withoutDevicesSizes, initialDevice]);
|
|
1597
1474
|
var currentScreen = useMemo(function () {
|
|
1598
1475
|
var _ref2 = valueParsed || {},
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1476
|
+
_ref2$components = _ref2.components,
|
|
1477
|
+
components = _ref2$components === void 0 ? [] : _ref2$components;
|
|
1602
1478
|
return (screenId !== null ? components.find(function (_ref3) {
|
|
1603
1479
|
var id = _ref3.id;
|
|
1604
1480
|
return id === screenId;
|
|
1605
1481
|
}) : components[0]) || null;
|
|
1606
1482
|
}, [valueParsed, screenId]);
|
|
1607
1483
|
var currentScreenStates = useScreenStates(currentScreen);
|
|
1608
|
-
|
|
1609
1484
|
var _ref4 = fieldParam !== null && currentScreenStates !== null ? fieldParam.split('/') : [],
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1485
|
+
_ref5 = _slicedToArray(_ref4, 1),
|
|
1486
|
+
_ref5$ = _ref5[0],
|
|
1487
|
+
screenStateParam = _ref5$ === void 0 ? null : _ref5$;
|
|
1614
1488
|
var currentScreenState = screenStateParam !== null ? currentScreenStates.find(function (_ref6) {
|
|
1615
1489
|
var id = _ref6.id;
|
|
1616
1490
|
return id === screenStateParam;
|
|
1617
1491
|
}) || null : null;
|
|
1618
|
-
|
|
1619
1492
|
var _ref7 = currentScreenState || {},
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1493
|
+
_ref7$id = _ref7.id,
|
|
1494
|
+
screenStateId = _ref7$id === void 0 ? null : _ref7$id,
|
|
1495
|
+
_ref7$repeatable = _ref7.repeatable,
|
|
1496
|
+
repeatable = _ref7$repeatable === void 0 ? false : _ref7$repeatable;
|
|
1625
1497
|
var currentScreenStateId = currentScreenState !== null && repeatable ? "".concat(screenStateId, ".").concat(fieldParam.split('/').find(function (it) {
|
|
1626
1498
|
return it.match(/^[0-9]+$/) !== null;
|
|
1627
1499
|
}) || 0) : screenStateId;
|
|
@@ -1674,13 +1546,12 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1674
1546
|
className: styles$8.devices
|
|
1675
1547
|
})) : null));
|
|
1676
1548
|
};
|
|
1677
|
-
|
|
1678
1549
|
EditorPreview.propTypes = propTypes$b;
|
|
1679
1550
|
EditorPreview.defaultProps = defaultProps$b;
|
|
1680
1551
|
|
|
1681
1552
|
var styles$7 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
1682
1553
|
|
|
1683
|
-
var styles$6 = {"container":"micromag-editor-menus-screens-container","
|
|
1554
|
+
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"};
|
|
1684
1555
|
|
|
1685
1556
|
var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
1686
1557
|
function getDragDepth(offset, indentationWidth) {
|
|
@@ -1688,22 +1559,18 @@ function getDragDepth(offset, indentationWidth) {
|
|
|
1688
1559
|
}
|
|
1689
1560
|
function getMaxDepth(_ref) {
|
|
1690
1561
|
var previousItem = _ref.previousItem;
|
|
1691
|
-
|
|
1692
1562
|
if (previousItem) {
|
|
1693
1563
|
// return previousItem.depth + 1;
|
|
1694
1564
|
return 1;
|
|
1695
1565
|
}
|
|
1696
|
-
|
|
1697
1566
|
return 0;
|
|
1698
1567
|
}
|
|
1699
1568
|
function getMinDepth(_ref2) {
|
|
1700
1569
|
var nextItem = _ref2.nextItem;
|
|
1701
|
-
|
|
1702
1570
|
if (nextItem) {
|
|
1703
1571
|
// return nextItem.depth;
|
|
1704
1572
|
return 0;
|
|
1705
1573
|
}
|
|
1706
|
-
|
|
1707
1574
|
return 0;
|
|
1708
1575
|
}
|
|
1709
1576
|
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
@@ -1728,34 +1595,27 @@ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
|
1728
1595
|
nextItem: nextItem
|
|
1729
1596
|
});
|
|
1730
1597
|
var depth = projectedDepth;
|
|
1731
|
-
|
|
1732
1598
|
if (projectedDepth >= maxDepth) {
|
|
1733
1599
|
depth = maxDepth;
|
|
1734
1600
|
} else if (projectedDepth < minDepth) {
|
|
1735
1601
|
depth = minDepth;
|
|
1736
1602
|
}
|
|
1737
|
-
|
|
1738
1603
|
function getParentId() {
|
|
1739
1604
|
var _newItems$slice$rever;
|
|
1740
|
-
|
|
1741
1605
|
if (depth === 0 || !previousItem) {
|
|
1742
1606
|
return null;
|
|
1743
1607
|
}
|
|
1744
|
-
|
|
1745
1608
|
if (depth === previousItem.depth) {
|
|
1746
1609
|
return previousItem.parentId;
|
|
1747
1610
|
}
|
|
1748
|
-
|
|
1749
1611
|
if (depth > previousItem.depth) {
|
|
1750
1612
|
return previousItem.id;
|
|
1751
1613
|
}
|
|
1752
|
-
|
|
1753
1614
|
var newParent = (_newItems$slice$rever = newItems.slice(0, overItemIndex).reverse().find(function (item) {
|
|
1754
1615
|
return item.depth === depth;
|
|
1755
1616
|
})) === null || _newItems$slice$rever === void 0 ? void 0 : _newItems$slice$rever.parentId;
|
|
1756
1617
|
return newParent !== null && newParent !== void 0 ? newParent : null;
|
|
1757
1618
|
}
|
|
1758
|
-
|
|
1759
1619
|
return {
|
|
1760
1620
|
depth: depth,
|
|
1761
1621
|
maxDepth: maxDepth,
|
|
@@ -1763,7 +1623,6 @@ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
|
1763
1623
|
parentId: getParentId()
|
|
1764
1624
|
};
|
|
1765
1625
|
}
|
|
1766
|
-
|
|
1767
1626
|
function flatten(items) {
|
|
1768
1627
|
var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1769
1628
|
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -1772,11 +1631,9 @@ function flatten(items) {
|
|
|
1772
1631
|
parentId: item.parentId || parentId,
|
|
1773
1632
|
depth: item.parentId ? 1 : 0,
|
|
1774
1633
|
index: index // For some reason this aint enough
|
|
1775
|
-
|
|
1776
1634
|
})], _toConsumableArray(flatten(item.children || [], item.id, depth + 1)));
|
|
1777
1635
|
}, []);
|
|
1778
1636
|
}
|
|
1779
|
-
|
|
1780
1637
|
function flattenTree(items) {
|
|
1781
1638
|
return flatten(items);
|
|
1782
1639
|
}
|
|
@@ -1791,36 +1648,30 @@ function buildTree(flattenedItems) {
|
|
|
1791
1648
|
id: 'root',
|
|
1792
1649
|
children: []
|
|
1793
1650
|
};
|
|
1794
|
-
|
|
1795
1651
|
var nodes = _defineProperty({}, root.id, root);
|
|
1796
|
-
|
|
1797
1652
|
var items = flattenedItems.map(function (item) {
|
|
1798
1653
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1799
1654
|
children: []
|
|
1800
1655
|
});
|
|
1801
|
-
});
|
|
1802
|
-
|
|
1803
|
-
var indexes = {};
|
|
1804
|
-
|
|
1656
|
+
});
|
|
1657
|
+
// console.log('BUILD');
|
|
1658
|
+
var indexes = {};
|
|
1659
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1805
1660
|
var _iterator = _createForOfIteratorHelper(items),
|
|
1806
|
-
|
|
1807
|
-
|
|
1661
|
+
_step;
|
|
1808
1662
|
try {
|
|
1809
1663
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1810
1664
|
var _item$parentId, _nodes$parentId;
|
|
1811
|
-
|
|
1812
1665
|
var item = _step.value;
|
|
1813
1666
|
var id = item.id,
|
|
1814
|
-
|
|
1667
|
+
children = item.children;
|
|
1815
1668
|
var parentId = (_item$parentId = item.parentId) !== null && _item$parentId !== void 0 ? _item$parentId : root.id;
|
|
1816
1669
|
var parent = (_nodes$parentId = nodes[parentId]) !== null && _nodes$parentId !== void 0 ? _nodes$parentId : findItem(items, parentId);
|
|
1817
|
-
|
|
1818
1670
|
if (typeof indexes[parentId] !== 'undefined') {
|
|
1819
1671
|
indexes[parentId] += 1;
|
|
1820
1672
|
} else {
|
|
1821
1673
|
indexes[parentId] = 0;
|
|
1822
1674
|
}
|
|
1823
|
-
|
|
1824
1675
|
nodes[id] = {
|
|
1825
1676
|
id: id,
|
|
1826
1677
|
children: children,
|
|
@@ -1835,50 +1686,42 @@ function buildTree(flattenedItems) {
|
|
|
1835
1686
|
} finally {
|
|
1836
1687
|
_iterator.f();
|
|
1837
1688
|
}
|
|
1838
|
-
|
|
1839
1689
|
return root.children;
|
|
1840
1690
|
}
|
|
1841
1691
|
function findItemDeep(items, itemId) {
|
|
1842
1692
|
for (var i = 0; i < items.length; i += 1) {
|
|
1843
1693
|
var item = items[i] || {};
|
|
1844
1694
|
var id = item.id,
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1695
|
+
_item$children = item.children,
|
|
1696
|
+
children = _item$children === void 0 ? [] : _item$children;
|
|
1848
1697
|
if (id === itemId) {
|
|
1849
1698
|
return item;
|
|
1850
1699
|
}
|
|
1851
|
-
|
|
1852
1700
|
if (children.length > 0) {
|
|
1853
1701
|
var child = findItemDeep(children, itemId);
|
|
1854
|
-
|
|
1855
1702
|
if (child) {
|
|
1856
1703
|
return child;
|
|
1857
1704
|
}
|
|
1858
1705
|
}
|
|
1859
1706
|
}
|
|
1860
|
-
|
|
1861
1707
|
return undefined;
|
|
1862
1708
|
}
|
|
1863
1709
|
function removeItem(items, id) {
|
|
1864
|
-
var newItems = [];
|
|
1710
|
+
var newItems = [];
|
|
1865
1711
|
|
|
1712
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1866
1713
|
var _iterator2 = _createForOfIteratorHelper(items),
|
|
1867
|
-
|
|
1868
|
-
|
|
1714
|
+
_step2;
|
|
1869
1715
|
try {
|
|
1870
1716
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1871
1717
|
var item = _step2.value;
|
|
1872
|
-
|
|
1873
1718
|
if (item.id === id) {
|
|
1874
1719
|
// eslint-disable-next-line no-continue
|
|
1875
1720
|
continue;
|
|
1876
1721
|
}
|
|
1877
|
-
|
|
1878
1722
|
if (item.children.length) {
|
|
1879
1723
|
item.children = removeItem(item.children, id);
|
|
1880
1724
|
}
|
|
1881
|
-
|
|
1882
1725
|
newItems.push(item);
|
|
1883
1726
|
}
|
|
1884
1727
|
} catch (err) {
|
|
@@ -1886,24 +1729,20 @@ function removeItem(items, id) {
|
|
|
1886
1729
|
} finally {
|
|
1887
1730
|
_iterator2.f();
|
|
1888
1731
|
}
|
|
1889
|
-
|
|
1890
1732
|
return newItems;
|
|
1891
1733
|
}
|
|
1892
1734
|
function setProperty(items, id, property, setter) {
|
|
1893
1735
|
// eslint-disable-next-line no-restricted-syntax
|
|
1894
1736
|
var _iterator3 = _createForOfIteratorHelper(items),
|
|
1895
|
-
|
|
1896
|
-
|
|
1737
|
+
_step3;
|
|
1897
1738
|
try {
|
|
1898
1739
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1899
1740
|
var item = _step3.value;
|
|
1900
|
-
|
|
1901
1741
|
if (item.id === id) {
|
|
1902
|
-
item[property] = setter(item[property]);
|
|
1903
|
-
|
|
1742
|
+
item[property] = setter(item[property]);
|
|
1743
|
+
// eslint-disable-next-line no-continue
|
|
1904
1744
|
continue;
|
|
1905
1745
|
}
|
|
1906
|
-
|
|
1907
1746
|
if (item.children.length) {
|
|
1908
1747
|
item.children = setProperty(item.children, id, property, setter);
|
|
1909
1748
|
}
|
|
@@ -1913,47 +1752,37 @@ function setProperty(items, id, property, setter) {
|
|
|
1913
1752
|
} finally {
|
|
1914
1753
|
_iterator3.f();
|
|
1915
1754
|
}
|
|
1916
|
-
|
|
1917
1755
|
return _toConsumableArray(items);
|
|
1918
1756
|
}
|
|
1919
|
-
|
|
1920
1757
|
function countChildren(items) {
|
|
1921
1758
|
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1922
1759
|
return items.reduce(function (acc, _ref6) {
|
|
1923
1760
|
var _ref6$children = _ref6.children,
|
|
1924
|
-
|
|
1925
|
-
|
|
1761
|
+
children = _ref6$children === void 0 ? [] : _ref6$children;
|
|
1926
1762
|
if (children.length) {
|
|
1927
1763
|
return countChildren(children, acc + 1);
|
|
1928
1764
|
}
|
|
1929
|
-
|
|
1930
1765
|
return acc + 1;
|
|
1931
1766
|
}, count);
|
|
1932
1767
|
}
|
|
1933
|
-
|
|
1934
1768
|
function getChildCount(items, id) {
|
|
1935
1769
|
if (!id) {
|
|
1936
1770
|
return 0;
|
|
1937
1771
|
}
|
|
1938
|
-
|
|
1939
1772
|
var item = findItemDeep(items, id);
|
|
1940
1773
|
return item ? countChildren(item.children || []) : 0;
|
|
1941
1774
|
}
|
|
1942
1775
|
function removeChildrenOf(items, ids) {
|
|
1943
1776
|
var excludeParentIds = _toConsumableArray(ids);
|
|
1944
|
-
|
|
1945
1777
|
return items.filter(function (item) {
|
|
1946
1778
|
if (item.parentId && excludeParentIds.includes(item.parentId)) {
|
|
1947
1779
|
var _item$children2 = item.children,
|
|
1948
|
-
|
|
1949
|
-
|
|
1780
|
+
children = _item$children2 === void 0 ? [] : _item$children2;
|
|
1950
1781
|
if (children.length) {
|
|
1951
1782
|
excludeParentIds.push(item.id);
|
|
1952
1783
|
}
|
|
1953
|
-
|
|
1954
1784
|
return false;
|
|
1955
1785
|
}
|
|
1956
|
-
|
|
1957
1786
|
return true;
|
|
1958
1787
|
});
|
|
1959
1788
|
}
|
|
@@ -1963,30 +1792,25 @@ var horizontal = [KeyboardCode.Left, KeyboardCode.Right];
|
|
|
1963
1792
|
var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(context, indentationWidth) {
|
|
1964
1793
|
return function (event, _ref) {
|
|
1965
1794
|
var currentCoordinates = _ref.currentCoordinates,
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1795
|
+
_ref$context = _ref.context,
|
|
1796
|
+
active = _ref$context.active,
|
|
1797
|
+
over = _ref$context.over,
|
|
1798
|
+
collisionRect = _ref$context.collisionRect,
|
|
1799
|
+
droppableContainers = _ref$context.droppableContainers;
|
|
1972
1800
|
if (directions.includes(event.code)) {
|
|
1973
1801
|
var _droppableContainers$;
|
|
1974
|
-
|
|
1975
1802
|
if (!active || !collisionRect) {
|
|
1976
1803
|
return;
|
|
1977
1804
|
}
|
|
1978
|
-
|
|
1979
1805
|
event.preventDefault();
|
|
1980
1806
|
var _context$current = context.current,
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1807
|
+
items = _context$current.items,
|
|
1808
|
+
offset = _context$current.offset;
|
|
1984
1809
|
if (horizontal.includes(event.code) && over !== null && over !== void 0 && over.id) {
|
|
1985
1810
|
var _getProjection = getProjection(items, active.id, over.id, offset, indentationWidth),
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1811
|
+
depth = _getProjection.depth,
|
|
1812
|
+
maxDepth = _getProjection.maxDepth,
|
|
1813
|
+
minDepth = _getProjection.minDepth;
|
|
1990
1814
|
switch (event.code) {
|
|
1991
1815
|
case KeyboardCode.Left:
|
|
1992
1816
|
if (depth > minDepth) {
|
|
@@ -1994,55 +1818,42 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
1994
1818
|
x: currentCoordinates.x - indentationWidth
|
|
1995
1819
|
});
|
|
1996
1820
|
}
|
|
1997
|
-
|
|
1998
1821
|
break;
|
|
1999
|
-
|
|
2000
1822
|
case KeyboardCode.Right:
|
|
2001
1823
|
if (depth < maxDepth) {
|
|
2002
1824
|
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
2003
1825
|
x: currentCoordinates.x + indentationWidth
|
|
2004
1826
|
});
|
|
2005
1827
|
}
|
|
2006
|
-
|
|
2007
1828
|
break;
|
|
2008
|
-
|
|
2009
1829
|
default:
|
|
2010
1830
|
return undefined;
|
|
2011
1831
|
}
|
|
2012
|
-
|
|
2013
1832
|
return undefined;
|
|
2014
1833
|
}
|
|
2015
|
-
|
|
2016
1834
|
var containers = [];
|
|
2017
1835
|
var overRect = over !== null && over !== void 0 && over.id ? (_droppableContainers$ = droppableContainers.get(over.id)) === null || _droppableContainers$ === void 0 ? void 0 : _droppableContainers$.rect.current : undefined;
|
|
2018
|
-
|
|
2019
1836
|
if (overRect) {
|
|
2020
1837
|
droppableContainers.forEach(function (container) {
|
|
2021
1838
|
if (container !== null && container !== void 0 && container.disabled) {
|
|
2022
1839
|
return;
|
|
2023
1840
|
}
|
|
2024
|
-
|
|
2025
1841
|
var rect = container === null || container === void 0 ? void 0 : container.rect.current;
|
|
2026
|
-
|
|
2027
1842
|
if (!rect) {
|
|
2028
1843
|
return;
|
|
2029
1844
|
}
|
|
2030
|
-
|
|
2031
1845
|
switch (event.code) {
|
|
2032
1846
|
case KeyboardCode.Down:
|
|
2033
1847
|
if (overRect.top < rect.top) {
|
|
2034
1848
|
containers.push(container);
|
|
2035
1849
|
}
|
|
2036
|
-
|
|
2037
1850
|
break;
|
|
2038
|
-
|
|
2039
1851
|
case KeyboardCode.Up:
|
|
2040
1852
|
if (overRect.top > rect.top) {
|
|
2041
1853
|
containers.push(container);
|
|
2042
1854
|
}
|
|
2043
|
-
|
|
2044
1855
|
break;
|
|
2045
|
-
|
|
1856
|
+
//
|
|
2046
1857
|
}
|
|
2047
1858
|
});
|
|
2048
1859
|
}
|
|
@@ -2054,13 +1865,10 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2054
1865
|
droppableContainers: containers
|
|
2055
1866
|
});
|
|
2056
1867
|
var closestId = getFirstCollision(collisions, 'id');
|
|
2057
|
-
|
|
2058
1868
|
if (closestId && over !== null && over !== void 0 && over.id) {
|
|
2059
1869
|
var _droppableContainers$2, _droppableContainers$3;
|
|
2060
|
-
|
|
2061
1870
|
var newNode = (_droppableContainers$2 = droppableContainers.get(closestId)) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.node.current;
|
|
2062
1871
|
var activeNodeRect = (_droppableContainers$3 = droppableContainers.get(active.id)) === null || _droppableContainers$3 === void 0 ? void 0 : _droppableContainers$3.rect.current;
|
|
2063
|
-
|
|
2064
1872
|
if (newNode && activeNodeRect) {
|
|
2065
1873
|
var newRect = getClientRect(newNode, {
|
|
2066
1874
|
ignoreTransform: true
|
|
@@ -2073,11 +1881,9 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2073
1881
|
var id = _ref3.id;
|
|
2074
1882
|
return id === active.id;
|
|
2075
1883
|
});
|
|
2076
|
-
|
|
2077
1884
|
if (newItem && activeItem) {
|
|
2078
1885
|
var _getProjection2 = getProjection(items, active.id, closestId, (newItem.depth - activeItem.depth) * indentationWidth, indentationWidth),
|
|
2079
|
-
|
|
2080
|
-
|
|
1886
|
+
_depth = _getProjection2.depth;
|
|
2081
1887
|
var topOffset = newRect.top > activeNodeRect.top ? Math.abs(activeNodeRect.height - newRect.height) : 0;
|
|
2082
1888
|
var newCoordinates = {
|
|
2083
1889
|
x: newRect.left + _depth * indentationWidth,
|
|
@@ -2088,14 +1894,13 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
2088
1894
|
}
|
|
2089
1895
|
}
|
|
2090
1896
|
}
|
|
2091
|
-
|
|
2092
1897
|
return undefined;
|
|
2093
1898
|
};
|
|
2094
1899
|
};
|
|
2095
1900
|
|
|
2096
1901
|
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"};
|
|
2097
1902
|
|
|
2098
|
-
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","
|
|
1903
|
+
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"};
|
|
2099
1904
|
|
|
2100
1905
|
var _excluded$4 = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "onClick", "style", "value", "wrapperRef", "showId", "showCount", "showCollapsedCount", "children"];
|
|
2101
1906
|
var propTypes$a = {
|
|
@@ -2148,29 +1953,27 @@ var defaultProps$a = {
|
|
|
2148
1953
|
};
|
|
2149
1954
|
var SortableTreeItemActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
2150
1955
|
var _ref2;
|
|
2151
|
-
|
|
2152
1956
|
var childCount = _ref.childCount,
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
1957
|
+
clone = _ref.clone,
|
|
1958
|
+
depth = _ref.depth,
|
|
1959
|
+
disableSelection = _ref.disableSelection,
|
|
1960
|
+
disableInteraction = _ref.disableInteraction,
|
|
1961
|
+
ghost = _ref.ghost,
|
|
1962
|
+
handleProps = _ref.handleProps,
|
|
1963
|
+
indentationWidth = _ref.indentationWidth,
|
|
1964
|
+
indicator = _ref.indicator,
|
|
1965
|
+
collapsed = _ref.collapsed,
|
|
1966
|
+
onCollapse = _ref.onCollapse,
|
|
1967
|
+
onRemove = _ref.onRemove;
|
|
1968
|
+
_ref.onClick;
|
|
1969
|
+
var style = _ref.style;
|
|
1970
|
+
_ref.value;
|
|
1971
|
+
var wrapperRef = _ref.wrapperRef;
|
|
1972
|
+
_ref.showId;
|
|
1973
|
+
var showCount = _ref.showCount,
|
|
1974
|
+
showCollapsedCount = _ref.showCollapsedCount,
|
|
1975
|
+
children = _ref.children,
|
|
1976
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
2174
1977
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
2175
1978
|
className: classNames([styles$4.wrapper, (_ref2 = {}, _defineProperty(_ref2, styles$4.clone, clone), _defineProperty(_ref2, styles$4.ghost, ghost), _defineProperty(_ref2, styles$4.indicator, indicator), _defineProperty(_ref2, styles$4.disableSelection, disableSelection), _defineProperty(_ref2, styles$4.disableInteraction, disableInteraction), _defineProperty(_ref2, styles$4.withChildren, onCollapse !== null), _ref2)]),
|
|
2176
1979
|
ref: wrapperRef,
|
|
@@ -2245,65 +2048,57 @@ var defaultProps$9 = {
|
|
|
2245
2048
|
childValue: null,
|
|
2246
2049
|
isLastChild: false
|
|
2247
2050
|
};
|
|
2248
|
-
|
|
2249
2051
|
var animateLayoutChanges = function animateLayoutChanges(_ref) {
|
|
2250
2052
|
var isSorting = _ref.isSorting,
|
|
2251
|
-
|
|
2053
|
+
wasDragging = _ref.wasDragging;
|
|
2252
2054
|
return !(isSorting || wasDragging);
|
|
2253
2055
|
};
|
|
2254
|
-
|
|
2255
2056
|
var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
2256
2057
|
var id = _ref2.id,
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2058
|
+
index = _ref2.index,
|
|
2059
|
+
depth = _ref2.depth,
|
|
2060
|
+
Component = _ref2.component,
|
|
2061
|
+
value = _ref2.value;
|
|
2062
|
+
_ref2.style;
|
|
2063
|
+
_ref2.smallScale;
|
|
2064
|
+
var collapsed = _ref2.collapsed,
|
|
2065
|
+
onCollapse = _ref2.onCollapse,
|
|
2066
|
+
onClickItem = _ref2.onClickItem,
|
|
2067
|
+
childValue = _ref2.childValue;
|
|
2068
|
+
_ref2.isLastChild;
|
|
2069
|
+
var props = _objectWithoutProperties(_ref2, _excluded$3);
|
|
2270
2070
|
var _useSortable = useSortable({
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2071
|
+
id: id,
|
|
2072
|
+
animateLayoutChanges: animateLayoutChanges
|
|
2073
|
+
}),
|
|
2074
|
+
attributes = _useSortable.attributes,
|
|
2075
|
+
isDragging = _useSortable.isDragging,
|
|
2076
|
+
isSorting = _useSortable.isSorting,
|
|
2077
|
+
listeners = _useSortable.listeners,
|
|
2078
|
+
setDraggableNodeRef = _useSortable.setDraggableNodeRef,
|
|
2079
|
+
setDroppableNodeRef = _useSortable.setDroppableNodeRef,
|
|
2080
|
+
transform = _useSortable.transform,
|
|
2081
|
+
transition = _useSortable.transition;
|
|
2283
2082
|
var timeout = useRef(null);
|
|
2284
2083
|
var actionsStyle = {
|
|
2285
2084
|
transform: CSS.Translate.toString(transform),
|
|
2286
2085
|
transition: transition
|
|
2287
2086
|
};
|
|
2288
|
-
|
|
2289
2087
|
var _ref3 = listeners || {},
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2088
|
+
_ref3$onPointerDown = _ref3.onPointerDown,
|
|
2089
|
+
onPointerDown = _ref3$onPointerDown === void 0 ? null : _ref3$onPointerDown,
|
|
2090
|
+
_ref3$onPointerUp = _ref3.onPointerUp,
|
|
2091
|
+
onPointerUp = _ref3$onPointerUp === void 0 ? null : _ref3$onPointerUp;
|
|
2295
2092
|
var onClickAction = useCallback(function (e) {
|
|
2296
2093
|
if (onClickItem !== null) {
|
|
2297
2094
|
onClickItem(value, index);
|
|
2298
2095
|
}
|
|
2299
|
-
|
|
2300
2096
|
if (onPointerDown !== null) {
|
|
2301
2097
|
e.persist();
|
|
2302
2098
|
timeout.current = setTimeout(function () {
|
|
2303
2099
|
if (onPointerDown !== null) {
|
|
2304
2100
|
onPointerDown(e);
|
|
2305
2101
|
}
|
|
2306
|
-
|
|
2307
2102
|
timeout.current = null;
|
|
2308
2103
|
}, 200);
|
|
2309
2104
|
}
|
|
@@ -2312,7 +2107,6 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
2312
2107
|
if (timeout.current !== null) {
|
|
2313
2108
|
clearTimeout(timeout.current);
|
|
2314
2109
|
}
|
|
2315
|
-
|
|
2316
2110
|
if (onPointerUp !== null) {
|
|
2317
2111
|
onPointerUp(e);
|
|
2318
2112
|
}
|
|
@@ -2339,7 +2133,6 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
2339
2133
|
className: styles$5.child
|
|
2340
2134
|
}, /*#__PURE__*/React.createElement(Component, childValue)) : null));
|
|
2341
2135
|
};
|
|
2342
|
-
|
|
2343
2136
|
SortableTreeItem.propTypes = propTypes$9;
|
|
2344
2137
|
SortableTreeItem.defaultProps = defaultProps$9;
|
|
2345
2138
|
|
|
@@ -2369,18 +2162,15 @@ var measuring = {
|
|
|
2369
2162
|
strategy: MeasuringStrategy.Always
|
|
2370
2163
|
}
|
|
2371
2164
|
};
|
|
2372
|
-
|
|
2373
2165
|
var dropAnimation = _objectSpread(_objectSpread({}, defaultDropAnimation), {}, {
|
|
2374
2166
|
dragSourceOpacity: 0.5
|
|
2375
2167
|
});
|
|
2376
|
-
|
|
2377
2168
|
var adjustTranslate = function adjustTranslate(_ref) {
|
|
2378
2169
|
var transform = _ref.transform;
|
|
2379
2170
|
return _objectSpread(_objectSpread({}, transform), {}, {
|
|
2380
2171
|
y: transform.y - 25
|
|
2381
2172
|
});
|
|
2382
2173
|
};
|
|
2383
|
-
|
|
2384
2174
|
var propTypes$8 = {
|
|
2385
2175
|
collapsible: PropTypes.bool,
|
|
2386
2176
|
// eslint-disable-next-line react/forbid-prop-types
|
|
@@ -2402,45 +2192,39 @@ var defaultProps$8 = {
|
|
|
2402
2192
|
onClickItem: null,
|
|
2403
2193
|
onChange: null
|
|
2404
2194
|
};
|
|
2405
|
-
|
|
2406
2195
|
var SortableTree = function SortableTree(_ref2) {
|
|
2407
2196
|
var collapsible = _ref2.collapsible,
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2197
|
+
defaultItems = _ref2.items,
|
|
2198
|
+
indicator = _ref2.indicator,
|
|
2199
|
+
indentationWidth = _ref2.indentationWidth,
|
|
2200
|
+
removable = _ref2.removable,
|
|
2201
|
+
component = _ref2.component,
|
|
2202
|
+
onClickItem = _ref2.onClickItem,
|
|
2203
|
+
onChange = _ref2.onChange;
|
|
2416
2204
|
var _useState = useState(function () {
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2205
|
+
return buildTree(defaultItems);
|
|
2206
|
+
}),
|
|
2207
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2208
|
+
items = _useState2[0],
|
|
2209
|
+
setItems = _useState2[1];
|
|
2423
2210
|
var _useState3 = useState(null),
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2211
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2212
|
+
activeId = _useState4[0],
|
|
2213
|
+
setActiveId = _useState4[1];
|
|
2428
2214
|
var _useState5 = useState(null),
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2215
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2216
|
+
overId = _useState6[0],
|
|
2217
|
+
setOverId = _useState6[1];
|
|
2433
2218
|
var _useState7 = useState(0),
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2219
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2220
|
+
offsetLeft = _useState8[0],
|
|
2221
|
+
setOffsetLeft = _useState8[1];
|
|
2438
2222
|
var _useState9 = useState(null),
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2223
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
2224
|
+
currentPosition = _useState10[0],
|
|
2225
|
+
setCurrentPosition = _useState10[1];
|
|
2443
2226
|
|
|
2227
|
+
// Tree setup from list
|
|
2444
2228
|
useEffect(function () {
|
|
2445
2229
|
var flat = flattenTree(items);
|
|
2446
2230
|
var merged = defaultItems.map(function (t1) {
|
|
@@ -2454,9 +2238,9 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2454
2238
|
var flattenedTree = flattenTree(items);
|
|
2455
2239
|
var collapsedItems = flattenedTree.reduce(function (acc, _ref3) {
|
|
2456
2240
|
var _ref3$children = _ref3.children,
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2241
|
+
children = _ref3$children === void 0 ? [] : _ref3$children,
|
|
2242
|
+
collapsed = _ref3.collapsed,
|
|
2243
|
+
id = _ref3.id;
|
|
2460
2244
|
return collapsed && children.length ? [].concat(_toConsumableArray(acc), [id]) : acc;
|
|
2461
2245
|
}, []) || null;
|
|
2462
2246
|
return removeChildrenOf(flattenedTree, activeId ? [activeId].concat(_toConsumableArray(collapsedItems)) : collapsedItems);
|
|
@@ -2466,13 +2250,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2466
2250
|
items: flattenedItems,
|
|
2467
2251
|
offset: offsetLeft
|
|
2468
2252
|
});
|
|
2469
|
-
|
|
2470
2253
|
var _useState11 = useState(function () {
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2254
|
+
return sortableTreeKeyboardCoordinates(sensorContext, indentationWidth);
|
|
2255
|
+
}),
|
|
2256
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
2257
|
+
coordinateGetter = _useState12[0];
|
|
2476
2258
|
var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
2477
2259
|
coordinateGetter: coordinateGetter
|
|
2478
2260
|
}));
|
|
@@ -2492,20 +2274,17 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2492
2274
|
offset: offsetLeft
|
|
2493
2275
|
};
|
|
2494
2276
|
}, [flattenedItems, offsetLeft]);
|
|
2495
|
-
|
|
2496
2277
|
function getMovementAnnouncement(eventName, currentActiveId, currentOverId) {
|
|
2497
2278
|
if (currentOverId && projected) {
|
|
2498
2279
|
if (eventName !== 'onDragEnd') {
|
|
2499
2280
|
if (currentPosition && projected.parentId === currentPosition.parentId && currentOverId === currentPosition.overId) {
|
|
2500
2281
|
return;
|
|
2501
2282
|
}
|
|
2502
|
-
|
|
2503
2283
|
setCurrentPosition({
|
|
2504
2284
|
parentId: projected.parentId,
|
|
2505
2285
|
overId: currentOverId
|
|
2506
2286
|
});
|
|
2507
2287
|
}
|
|
2508
|
-
|
|
2509
2288
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2510
2289
|
var overIndex = clonedItems.findIndex(function (_ref6) {
|
|
2511
2290
|
var id = _ref6.id;
|
|
@@ -2520,10 +2299,8 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2520
2299
|
var newAnnouncement;
|
|
2521
2300
|
var movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
2522
2301
|
var nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
2523
|
-
|
|
2524
2302
|
if (!previousItem) {
|
|
2525
2303
|
var nextItem = typeof sortedItems[overIndex + 1] !== 'undefined' ? sortedItems[overIndex + 1] : null;
|
|
2526
|
-
|
|
2527
2304
|
if (nextItem !== null) {
|
|
2528
2305
|
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " before ").concat(nextItem.id, ".");
|
|
2529
2306
|
}
|
|
@@ -2531,30 +2308,26 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2531
2308
|
newAnnouncement = "".concat(currentActiveId, " was ").concat(nestedVerb, " under ").concat(previousItem.id, ".");
|
|
2532
2309
|
} else {
|
|
2533
2310
|
var previousSibling = previousItem;
|
|
2534
|
-
|
|
2535
2311
|
var _loop = function _loop() {
|
|
2536
2312
|
var _previousSibling = previousSibling,
|
|
2537
|
-
|
|
2313
|
+
parentId = _previousSibling.parentId;
|
|
2538
2314
|
previousSibling = sortedItems.find(function (_ref8) {
|
|
2539
2315
|
var id = _ref8.id;
|
|
2540
2316
|
return id === parentId;
|
|
2541
2317
|
});
|
|
2542
2318
|
};
|
|
2543
|
-
|
|
2544
2319
|
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
2545
2320
|
_loop();
|
|
2546
2321
|
}
|
|
2547
|
-
|
|
2548
2322
|
if (previousSibling) {
|
|
2549
2323
|
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " after ").concat(previousSibling.id, ".");
|
|
2550
2324
|
}
|
|
2551
|
-
}
|
|
2552
|
-
|
|
2325
|
+
}
|
|
2553
2326
|
|
|
2327
|
+
// eslint-disable-next-line consistent-return
|
|
2554
2328
|
return newAnnouncement;
|
|
2555
2329
|
}
|
|
2556
2330
|
}
|
|
2557
|
-
|
|
2558
2331
|
var announcements = useMemo(function () {
|
|
2559
2332
|
return {
|
|
2560
2333
|
onDragStart: function onDragStart(id) {
|
|
@@ -2576,7 +2349,7 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2576
2349
|
}, [getMovementAnnouncement]);
|
|
2577
2350
|
var activeValue = defaultItems.find(function (_ref9) {
|
|
2578
2351
|
var _ref9$id = _ref9.id,
|
|
2579
|
-
|
|
2352
|
+
defaultId = _ref9$id === void 0 ? null : _ref9$id;
|
|
2580
2353
|
return defaultId === activeId;
|
|
2581
2354
|
});
|
|
2582
2355
|
var handleDragStart = useCallback(function (_ref10) {
|
|
@@ -2587,14 +2360,12 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2587
2360
|
var id = _ref11.id;
|
|
2588
2361
|
return id === newActiveId;
|
|
2589
2362
|
});
|
|
2590
|
-
|
|
2591
2363
|
if (newActiveItem) {
|
|
2592
2364
|
setCurrentPosition({
|
|
2593
2365
|
parentId: newActiveItem.parentId,
|
|
2594
2366
|
overId: activeId
|
|
2595
2367
|
});
|
|
2596
2368
|
}
|
|
2597
|
-
|
|
2598
2369
|
document.body.style.setProperty('cursor', 'grabbing');
|
|
2599
2370
|
}, [flattenedItems, setActiveId, setOverId, setCurrentPosition]);
|
|
2600
2371
|
var handleDragMove = useCallback(function (_ref12) {
|
|
@@ -2603,7 +2374,6 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2603
2374
|
}, [setOffsetLeft]);
|
|
2604
2375
|
var handleDragOver = useCallback(function (_ref13) {
|
|
2605
2376
|
var _over$id;
|
|
2606
|
-
|
|
2607
2377
|
var over = _ref13.over;
|
|
2608
2378
|
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
2609
2379
|
}, [setOverId]);
|
|
@@ -2616,12 +2386,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2616
2386
|
}, [setOverId, setActiveId, setOffsetLeft, setCurrentPosition]);
|
|
2617
2387
|
var handleDragEnd = useCallback(function (_ref14) {
|
|
2618
2388
|
var active = _ref14.active,
|
|
2619
|
-
|
|
2389
|
+
over = _ref14.over;
|
|
2620
2390
|
resetState();
|
|
2621
|
-
|
|
2622
2391
|
if (projected && over) {
|
|
2623
2392
|
var depth = projected.depth,
|
|
2624
|
-
|
|
2393
|
+
parentId = projected.parentId;
|
|
2625
2394
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2626
2395
|
var overIndex = clonedItems.findIndex(function (_ref15) {
|
|
2627
2396
|
var id = _ref15.id;
|
|
@@ -2632,10 +2401,10 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2632
2401
|
return id === active.id;
|
|
2633
2402
|
});
|
|
2634
2403
|
var activeTreeItem = clonedItems[activeIndex];
|
|
2635
|
-
var maxDepth = getMaxDepth(activeTreeItem);
|
|
2636
|
-
|
|
2404
|
+
var maxDepth = getMaxDepth(activeTreeItem);
|
|
2405
|
+
// Un-merge and flatten
|
|
2637
2406
|
if (depth > 0 && depth >= maxDepth && (activeTreeItem === null || activeTreeItem === void 0 ? void 0 : activeTreeItem.children) !== null && activeTreeItem.children.length > 0) {
|
|
2638
|
-
var _loop2 = function _loop2(
|
|
2407
|
+
var _loop2 = function _loop2() {
|
|
2639
2408
|
var childId = activeTreeItem.children[i].id;
|
|
2640
2409
|
var childIndex = clonedItems.findIndex(function (_ref17) {
|
|
2641
2410
|
var id = _ref17.id;
|
|
@@ -2644,33 +2413,32 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2644
2413
|
clonedItems[childIndex].parentId = parentId;
|
|
2645
2414
|
clonedItems[childIndex].depth = depth;
|
|
2646
2415
|
};
|
|
2647
|
-
|
|
2648
2416
|
for (var i = 0; i < activeTreeItem.children.length; i += 1) {
|
|
2649
|
-
_loop2(
|
|
2417
|
+
_loop2();
|
|
2650
2418
|
}
|
|
2651
|
-
|
|
2652
2419
|
activeTreeItem.children = [];
|
|
2653
2420
|
}
|
|
2654
|
-
|
|
2655
2421
|
clonedItems[activeIndex] = _objectSpread(_objectSpread({}, activeTreeItem), {}, {
|
|
2656
2422
|
depth: depth,
|
|
2657
2423
|
parentId: parentId
|
|
2658
2424
|
});
|
|
2659
2425
|
var sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
2660
|
-
var newItems = buildTree(sortedItems);
|
|
2426
|
+
var newItems = buildTree(sortedItems);
|
|
2661
2427
|
|
|
2662
|
-
|
|
2428
|
+
// console.log('drag endd', sortedItems, newItems);
|
|
2663
2429
|
|
|
2430
|
+
setItems(newItems);
|
|
2664
2431
|
if (onChange !== null) {
|
|
2665
2432
|
// console.log('hell is flatss', newItems);
|
|
2433
|
+
|
|
2666
2434
|
onChange((newItems || []).map(function (_ref18) {
|
|
2667
2435
|
var itemId = _ref18.id,
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2436
|
+
_ref18$children = _ref18.children,
|
|
2437
|
+
children = _ref18$children === void 0 ? [] : _ref18$children,
|
|
2438
|
+
_ref18$parentId = _ref18.parentId,
|
|
2439
|
+
itParentId = _ref18$parentId === void 0 ? null : _ref18$parentId,
|
|
2440
|
+
_ref18$collapsed = _ref18.collapsed,
|
|
2441
|
+
collapsed = _ref18$collapsed === void 0 ? false : _ref18$collapsed;
|
|
2674
2442
|
return {
|
|
2675
2443
|
id: itemId,
|
|
2676
2444
|
props: _objectSpread(_objectSpread({}, (children || []).length > 0 ? {
|
|
@@ -2708,7 +2476,8 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2708
2476
|
return /*#__PURE__*/React.createElement(DndContext, {
|
|
2709
2477
|
accessibility: {
|
|
2710
2478
|
announcements: announcements
|
|
2711
|
-
}
|
|
2479
|
+
}
|
|
2480
|
+
// announcements={announcements}
|
|
2712
2481
|
,
|
|
2713
2482
|
sensors: sensors,
|
|
2714
2483
|
collisionDetection: closestCenter,
|
|
@@ -2723,15 +2492,14 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2723
2492
|
strategy: verticalListSortingStrategy
|
|
2724
2493
|
}, flattenedItems.map(function (_ref19, idx) {
|
|
2725
2494
|
var _flattenedItems, _ref22;
|
|
2726
|
-
|
|
2727
2495
|
var id = _ref19.id,
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2496
|
+
_ref19$children = _ref19.children,
|
|
2497
|
+
children = _ref19$children === void 0 ? [] : _ref19$children,
|
|
2498
|
+
collapsed = _ref19.collapsed,
|
|
2499
|
+
depth = _ref19.depth;
|
|
2732
2500
|
var screenValue = defaultItems.find(function (_ref20) {
|
|
2733
2501
|
var _ref20$id = _ref20.id,
|
|
2734
|
-
|
|
2502
|
+
defaultId = _ref20$id === void 0 ? null : _ref20$id;
|
|
2735
2503
|
return defaultId === id;
|
|
2736
2504
|
});
|
|
2737
2505
|
var next = ((_flattenedItems = flattenedItems[idx + 1]) === null || _flattenedItems === void 0 ? void 0 : _flattenedItems.parentId) || null;
|
|
@@ -2743,7 +2511,7 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2743
2511
|
var childCount = getChildCount(items, id);
|
|
2744
2512
|
var childValue = childCount > 0 && collapsed ? defaultItems.slice().reverse().find(function (_ref21) {
|
|
2745
2513
|
var _ref21$parentId = _ref21.parentId,
|
|
2746
|
-
|
|
2514
|
+
parentId = _ref21$parentId === void 0 ? null : _ref21$parentId;
|
|
2747
2515
|
return parentId === id;
|
|
2748
2516
|
}) : null;
|
|
2749
2517
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -2788,12 +2556,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2788
2556
|
})
|
|
2789
2557
|
})) : null), document.body)));
|
|
2790
2558
|
};
|
|
2791
|
-
|
|
2792
2559
|
SortableTree.propTypes = propTypes$8;
|
|
2793
2560
|
SortableTree.defaultProps = defaultProps$8;
|
|
2794
2561
|
|
|
2795
2562
|
var _excluded$2 = ["className", "screen", "type", "onClick", "active", "href"],
|
|
2796
|
-
|
|
2563
|
+
_excluded2 = ["id", "screen", "href"];
|
|
2797
2564
|
var propTypes$7 = {
|
|
2798
2565
|
items: PropTypes$1.menuItems,
|
|
2799
2566
|
withPreview: PropTypes.bool,
|
|
@@ -2826,37 +2593,33 @@ var defaultProps$7 = {
|
|
|
2826
2593
|
onClickItem: null,
|
|
2827
2594
|
onOrderChange: null
|
|
2828
2595
|
};
|
|
2829
|
-
|
|
2830
2596
|
var ScreensMenu = function ScreensMenu(_ref) {
|
|
2831
2597
|
var _ref8;
|
|
2832
|
-
|
|
2833
2598
|
var items = _ref.items,
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2599
|
+
withPreview = _ref.withPreview,
|
|
2600
|
+
withPlaceholder = _ref.withPlaceholder,
|
|
2601
|
+
settings = _ref.settings,
|
|
2602
|
+
isVertical = _ref.isVertical,
|
|
2603
|
+
noWrap = _ref.noWrap,
|
|
2604
|
+
className = _ref.className,
|
|
2605
|
+
itemClassName = _ref.itemClassName,
|
|
2606
|
+
buttonClassName = _ref.buttonClassName,
|
|
2607
|
+
settingsClassName = _ref.settingsClassName,
|
|
2608
|
+
sortable = _ref.sortable,
|
|
2609
|
+
isTree = _ref.isTree,
|
|
2610
|
+
onClickItem = _ref.onClickItem,
|
|
2611
|
+
onOrderChange = _ref.onOrderChange;
|
|
2847
2612
|
var itemsElements = !isTree ? items.map(function (_ref2, index) {
|
|
2848
2613
|
var _ref3;
|
|
2849
|
-
|
|
2850
2614
|
var _ref2$className = _ref2.className,
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2615
|
+
itemCustomClassName = _ref2$className === void 0 ? null : _ref2$className,
|
|
2616
|
+
screen = _ref2.screen,
|
|
2617
|
+
type = _ref2.type,
|
|
2618
|
+
_ref2$onClick = _ref2.onClick,
|
|
2619
|
+
onClick = _ref2$onClick === void 0 ? null : _ref2$onClick,
|
|
2620
|
+
active = _ref2.active,
|
|
2621
|
+
href = _ref2.href,
|
|
2622
|
+
item = _objectWithoutProperties(_ref2, _excluded$2);
|
|
2860
2623
|
return /*#__PURE__*/React.createElement("li", {
|
|
2861
2624
|
key: item.id,
|
|
2862
2625
|
className: classNames([styles$6.item, (_ref3 = {}, _defineProperty(_ref3, itemClassName, itemClassName !== null), _defineProperty(_ref3, itemCustomClassName, itemCustomClassName !== null), _ref3)]),
|
|
@@ -2880,20 +2643,17 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2880
2643
|
var sortableItems = useMemo(function () {
|
|
2881
2644
|
return isTree ? items.map(function (_ref5) {
|
|
2882
2645
|
var id = _ref5.id,
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2646
|
+
_ref5$screen = _ref5.screen,
|
|
2647
|
+
screen = _ref5$screen === void 0 ? {} : _ref5$screen,
|
|
2648
|
+
href = _ref5.href,
|
|
2649
|
+
props = _objectWithoutProperties(_ref5, _excluded2);
|
|
2888
2650
|
var _screen$parentId = screen.parentId,
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2651
|
+
parentId = _screen$parentId === void 0 ? null : _screen$parentId,
|
|
2652
|
+
_screen$group = screen.group,
|
|
2653
|
+
group = _screen$group === void 0 ? {} : _screen$group;
|
|
2893
2654
|
var _ref6 = group || {},
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2655
|
+
_ref6$collapsed = _ref6.collapsed,
|
|
2656
|
+
collapsed = _ref6$collapsed === void 0 ? true : _ref6$collapsed;
|
|
2897
2657
|
return {
|
|
2898
2658
|
id: id,
|
|
2899
2659
|
parentId: parentId,
|
|
@@ -2930,7 +2690,6 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2930
2690
|
className: styles$6.items
|
|
2931
2691
|
}, itemsElements) : null);
|
|
2932
2692
|
};
|
|
2933
|
-
|
|
2934
2693
|
ScreensMenu.propTypes = propTypes$7;
|
|
2935
2694
|
ScreensMenu.defaultProps = defaultProps$7;
|
|
2936
2695
|
|
|
@@ -2948,12 +2707,11 @@ var defaultProps$6 = {
|
|
|
2948
2707
|
className: null,
|
|
2949
2708
|
onClickItem: null
|
|
2950
2709
|
};
|
|
2951
|
-
|
|
2952
2710
|
var ScreenTypes = function ScreenTypes(_ref) {
|
|
2953
2711
|
var screens = _ref.screens,
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2712
|
+
selectedTypes = _ref.selectedTypes,
|
|
2713
|
+
className = _ref.className,
|
|
2714
|
+
onClickItem = _ref.onClickItem;
|
|
2957
2715
|
var intl = useIntl();
|
|
2958
2716
|
var screensManager = useScreensManager();
|
|
2959
2717
|
var screenDefinitions = screens || screensManager.getDefinitions();
|
|
@@ -2963,36 +2721,31 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
2963
2721
|
var groups = useMemo(function () {
|
|
2964
2722
|
var groupItems = finalDefinitions.reduce(function (allGroups, definition) {
|
|
2965
2723
|
var id = definition.id,
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2724
|
+
title = definition.title,
|
|
2725
|
+
_definition$group = definition.group,
|
|
2726
|
+
group = _definition$group === void 0 ? {} : _definition$group;
|
|
2970
2727
|
var _ref2 = group || {},
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2728
|
+
_ref2$order = _ref2.order,
|
|
2729
|
+
order = _ref2$order === void 0 ? 0 : _ref2$order,
|
|
2730
|
+
_ref2$label = _ref2.label,
|
|
2731
|
+
label = _ref2$label === void 0 ? {} : _ref2$label,
|
|
2732
|
+
_ref2$hidden = _ref2.hidden,
|
|
2733
|
+
hidden = _ref2$hidden === void 0 ? false : _ref2$hidden;
|
|
2978
2734
|
var _ref3 = label || {},
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2735
|
+
_ref3$id = _ref3.id,
|
|
2736
|
+
messageId = _ref3$id === void 0 ? null : _ref3$id;
|
|
2982
2737
|
if (hidden) {
|
|
2983
2738
|
return allGroups;
|
|
2984
2739
|
}
|
|
2985
|
-
|
|
2986
2740
|
var _ref4 = isMessage(label) ? {
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2741
|
+
id: messageId || id,
|
|
2742
|
+
name: group
|
|
2743
|
+
} : {
|
|
2744
|
+
id: messageId || id,
|
|
2745
|
+
name: title
|
|
2746
|
+
},
|
|
2747
|
+
groupId = _ref4.id,
|
|
2748
|
+
groupName = _ref4.name;
|
|
2996
2749
|
var groupIndex = allGroups.findIndex(function (it) {
|
|
2997
2750
|
return it.id === groupId;
|
|
2998
2751
|
});
|
|
@@ -3023,8 +2776,8 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
3023
2776
|
className: styles$2.rows
|
|
3024
2777
|
}, groups.map(function (_ref6) {
|
|
3025
2778
|
var id = _ref6.id,
|
|
3026
|
-
|
|
3027
|
-
|
|
2779
|
+
name = _ref6.name,
|
|
2780
|
+
items = _ref6.items;
|
|
3028
2781
|
return /*#__PURE__*/React.createElement("div", {
|
|
3029
2782
|
key: "group-".concat(id),
|
|
3030
2783
|
className: styles$2.row
|
|
@@ -3044,7 +2797,6 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
3044
2797
|
})));
|
|
3045
2798
|
})));
|
|
3046
2799
|
};
|
|
3047
|
-
|
|
3048
2800
|
ScreenTypes.propTypes = propTypes$6;
|
|
3049
2801
|
ScreenTypes.defaultProps = defaultProps$6;
|
|
3050
2802
|
|
|
@@ -3062,12 +2814,11 @@ var defaultProps$5 = {
|
|
|
3062
2814
|
onRequestClose: null,
|
|
3063
2815
|
onClickScreenType: null
|
|
3064
2816
|
};
|
|
3065
|
-
|
|
3066
2817
|
var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
3067
2818
|
var selectedTypes = _ref.selectedTypes,
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
2819
|
+
className = _ref.className,
|
|
2820
|
+
onRequestClose = _ref.onRequestClose,
|
|
2821
|
+
onClickScreenType = _ref.onClickScreenType;
|
|
3071
2822
|
return /*#__PURE__*/React.createElement(Modal, null, /*#__PURE__*/React.createElement(ModalDialog, {
|
|
3072
2823
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
3073
2824
|
id: "QBaiO0",
|
|
@@ -3084,7 +2835,6 @@ var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
|
3084
2835
|
onClickItem: onClickScreenType
|
|
3085
2836
|
})));
|
|
3086
2837
|
};
|
|
3087
|
-
|
|
3088
2838
|
ScreenTypesModal.propTypes = propTypes$5;
|
|
3089
2839
|
ScreenTypesModal.defaultProps = defaultProps$5;
|
|
3090
2840
|
|
|
@@ -3111,57 +2861,48 @@ var defaultProps$4 = {
|
|
|
3111
2861
|
onChange: null,
|
|
3112
2862
|
className: null
|
|
3113
2863
|
};
|
|
3114
|
-
|
|
3115
2864
|
var EditorScreens = function EditorScreens(_ref) {
|
|
3116
2865
|
var unparsedValue = _ref.value,
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
2866
|
+
isTheme = _ref.isTheme,
|
|
2867
|
+
isVertical = _ref.isVertical,
|
|
2868
|
+
isCreateOpened = _ref.isCreateOpened,
|
|
2869
|
+
isParsed = _ref.isParsed,
|
|
2870
|
+
isTree = _ref.isTree,
|
|
2871
|
+
onClickScreen = _ref.onClickScreen,
|
|
2872
|
+
onChange = _ref.onChange,
|
|
2873
|
+
className = _ref.className;
|
|
3125
2874
|
var valueWithTheme = useThemeValue(unparsedValue, isTheme);
|
|
3126
2875
|
var value = isParsed ? unparsedValue : useParsedStory(valueWithTheme, {
|
|
3127
2876
|
withMedias: false
|
|
3128
2877
|
});
|
|
3129
|
-
|
|
3130
2878
|
var _ref2 = value || {},
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
2879
|
+
_ref2$components = _ref2.components,
|
|
2880
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
3134
2881
|
var _useState = useState(isCreateOpened),
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
2882
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2883
|
+
createModalOpened = _useState2[0],
|
|
2884
|
+
setCreateModalOpened = _useState2[1];
|
|
3139
2885
|
var routes = useRoutes();
|
|
3140
2886
|
var push = useRoutePush();
|
|
3141
2887
|
var url = useUrlGenerator();
|
|
3142
|
-
|
|
3143
2888
|
var _useRouteParams = useRouteParams({
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
2889
|
+
screenOnly: true
|
|
2890
|
+
}),
|
|
2891
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
2892
|
+
currentScreenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree;
|
|
3149
2893
|
var createScreenFromDefinition = useCallback(function (definition) {
|
|
3150
2894
|
var _ref3 = value || {},
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
2895
|
+
_ref3$components = _ref3.components,
|
|
2896
|
+
currentScreens = _ref3$components === void 0 ? [] : _ref3$components,
|
|
2897
|
+
_ref3$theme = _ref3.theme,
|
|
2898
|
+
theme = _ref3$theme === void 0 ? {} : _ref3$theme;
|
|
3156
2899
|
var _ref4 = isString(definition) ? {
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
2900
|
+
id: definition
|
|
2901
|
+
} : definition,
|
|
2902
|
+
newScreenType = _ref4.id;
|
|
3161
2903
|
var _ref5 = theme || {},
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
2904
|
+
_ref5$components = _ref5.components,
|
|
2905
|
+
themeComponents = _ref5$components === void 0 ? null : _ref5$components;
|
|
3165
2906
|
var themeScreen = themeComponents !== null ? themeComponents.find(function (it) {
|
|
3166
2907
|
return it.type === newScreenType;
|
|
3167
2908
|
}) || null : null;
|
|
@@ -3171,15 +2912,12 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3171
2912
|
return id === currentScreenId;
|
|
3172
2913
|
});
|
|
3173
2914
|
var currentScreenIndex = !isTheme && foundIndex >= 0 ? foundIndex + 1 : null;
|
|
3174
|
-
|
|
3175
2915
|
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
3176
2916
|
components: [].concat(_toConsumableArray(currentScreens.slice(0, currentScreenIndex)), [newScreen], _toConsumableArray(currentScreens.slice(currentScreenIndex)))
|
|
3177
2917
|
});
|
|
3178
|
-
|
|
3179
2918
|
if (onChange !== null) {
|
|
3180
2919
|
onChange(newValue);
|
|
3181
2920
|
}
|
|
3182
|
-
|
|
3183
2921
|
return newScreen;
|
|
3184
2922
|
}, [value, onChange, isTheme, screens, currentScreenId, setCreateModalOpened]);
|
|
3185
2923
|
var onOrderChange = useCallback(function (listItems) {
|
|
@@ -3189,8 +2927,8 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3189
2927
|
});
|
|
3190
2928
|
var screenProps = listItems.map(function (_ref8) {
|
|
3191
2929
|
var id = _ref8.id,
|
|
3192
|
-
|
|
3193
|
-
|
|
2930
|
+
_ref8$props = _ref8.props,
|
|
2931
|
+
props = _ref8$props === void 0 ? null : _ref8$props;
|
|
3194
2932
|
return {
|
|
3195
2933
|
id: id,
|
|
3196
2934
|
props: props
|
|
@@ -3200,11 +2938,9 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3200
2938
|
var props = _ref9.props;
|
|
3201
2939
|
return props !== null;
|
|
3202
2940
|
}) || []).length > 0;
|
|
3203
|
-
|
|
3204
2941
|
var _ref10 = value || {},
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
2942
|
+
_ref10$components = _ref10.components,
|
|
2943
|
+
currentScreens = _ref10$components === void 0 ? [] : _ref10$components;
|
|
3208
2944
|
var currentIds = currentScreens.map(function (_ref11) {
|
|
3209
2945
|
var id = _ref11.id;
|
|
3210
2946
|
return id;
|
|
@@ -3213,7 +2949,6 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3213
2949
|
var id = _ref12.id;
|
|
3214
2950
|
return same && id === currentIds[index];
|
|
3215
2951
|
}, true);
|
|
3216
|
-
|
|
3217
2952
|
if (!sameOrder || hasScreenProps) {
|
|
3218
2953
|
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
3219
2954
|
components: _toConsumableArray(currentScreens).sort(function (_ref13, _ref14) {
|
|
@@ -3221,18 +2956,14 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3221
2956
|
var idB = _ref14.id;
|
|
3222
2957
|
var indexA = ids.indexOf(idA);
|
|
3223
2958
|
var indexB = ids.indexOf(idB);
|
|
3224
|
-
|
|
3225
2959
|
if (indexA === indexB) {
|
|
3226
2960
|
return 0;
|
|
3227
2961
|
}
|
|
3228
|
-
|
|
3229
2962
|
return indexA > indexB ? 1 : -1;
|
|
3230
2963
|
}).map(function (_ref15) {
|
|
3231
2964
|
var _screenProps$find;
|
|
3232
|
-
|
|
3233
2965
|
var id = _ref15.id,
|
|
3234
|
-
|
|
3235
|
-
|
|
2966
|
+
props = _objectWithoutProperties(_ref15, _excluded$1);
|
|
3236
2967
|
return _objectSpread(_objectSpread({
|
|
3237
2968
|
id: id
|
|
3238
2969
|
}, props), (_screenProps$find = screenProps.find(function (_ref16) {
|
|
@@ -3241,7 +2972,6 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3241
2972
|
})) === null || _screenProps$find === void 0 ? void 0 : _screenProps$find.props);
|
|
3242
2973
|
})
|
|
3243
2974
|
});
|
|
3244
|
-
|
|
3245
2975
|
if (onChange !== null) {
|
|
3246
2976
|
onChange(newValue);
|
|
3247
2977
|
}
|
|
@@ -3253,11 +2983,9 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3253
2983
|
var type = _ref17.type;
|
|
3254
2984
|
return type === definition.id;
|
|
3255
2985
|
}) || null : null;
|
|
3256
|
-
|
|
3257
2986
|
if (!isTheme || currentScreen === null) {
|
|
3258
2987
|
currentScreen = createScreenFromDefinition(definition);
|
|
3259
2988
|
}
|
|
3260
|
-
|
|
3261
2989
|
push('screen', {
|
|
3262
2990
|
screen: currentScreen.id
|
|
3263
2991
|
});
|
|
@@ -3297,7 +3025,7 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3297
3025
|
path: [routes.screen, routes.home],
|
|
3298
3026
|
render: function render(_ref18) {
|
|
3299
3027
|
var _ref18$match$params$s = _ref18.match.params.screen,
|
|
3300
|
-
|
|
3028
|
+
screenId = _ref18$match$params$s === void 0 ? null : _ref18$match$params$s;
|
|
3301
3029
|
return screens.length > 0 ? /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
3302
3030
|
items: screens.map(function (it) {
|
|
3303
3031
|
return {
|
|
@@ -3338,7 +3066,6 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3338
3066
|
onRequestClose: onCreateModalRequestClose
|
|
3339
3067
|
}) : null);
|
|
3340
3068
|
};
|
|
3341
|
-
|
|
3342
3069
|
EditorScreens.propTypes = propTypes$4;
|
|
3343
3070
|
EditorScreens.defaultProps = defaultProps$4;
|
|
3344
3071
|
|
|
@@ -3364,43 +3091,39 @@ var defaultProps$3 = {
|
|
|
3364
3091
|
onChange: null,
|
|
3365
3092
|
className: null
|
|
3366
3093
|
};
|
|
3367
|
-
|
|
3368
3094
|
var Editor = function Editor(_ref) {
|
|
3369
3095
|
var _ref5;
|
|
3370
|
-
|
|
3371
3096
|
var value = _ref.value,
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3097
|
+
viewerTheme = _ref.viewerTheme,
|
|
3098
|
+
isTheme = _ref.isTheme,
|
|
3099
|
+
isCreateOpened = _ref.isCreateOpened,
|
|
3100
|
+
deviceScreens = _ref.deviceScreens,
|
|
3101
|
+
initialMobileView = _ref.mobileView,
|
|
3102
|
+
onChange = _ref.onChange,
|
|
3103
|
+
fullscreen = _ref.fullscreen,
|
|
3104
|
+
className = _ref.className;
|
|
3380
3105
|
var push = useRoutePush();
|
|
3381
3106
|
var refScreensContainer = useRef(null);
|
|
3382
|
-
|
|
3383
3107
|
var _useRouteParams = useRouteParams({
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3108
|
+
screenOnly: true
|
|
3109
|
+
}),
|
|
3110
|
+
screenId = _useRouteParams.screen;
|
|
3388
3111
|
|
|
3112
|
+
// Screen size
|
|
3389
3113
|
var _useScreenSizeFromEle = useScreenSizeFromElement({
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
var isMobile = screenSize !== null && screenSize.screens.indexOf('medium') === -1; // Mobile view
|
|
3114
|
+
screens: deviceScreens,
|
|
3115
|
+
withoutMaxSize: true,
|
|
3116
|
+
withoutScale: true
|
|
3117
|
+
}),
|
|
3118
|
+
refContainer = _useScreenSizeFromEle.ref,
|
|
3119
|
+
screenSize = _useScreenSizeFromEle.screenSize;
|
|
3120
|
+
var isMobile = screenSize !== null && screenSize.screens.indexOf('medium') === -1;
|
|
3398
3121
|
|
|
3122
|
+
// Mobile view
|
|
3399
3123
|
var _useState = useState(initialMobileView),
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3124
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3125
|
+
mobileView = _useState2[0],
|
|
3126
|
+
setMobileView = _useState2[1];
|
|
3404
3127
|
var onClickScreens = useCallback(function () {
|
|
3405
3128
|
return setMobileView('screens');
|
|
3406
3129
|
}, [mobileView, setMobileView]);
|
|
@@ -3409,18 +3132,18 @@ var Editor = function Editor(_ref) {
|
|
|
3409
3132
|
}, [setMobileView]);
|
|
3410
3133
|
var onClickViewScreen = useCallback(function () {
|
|
3411
3134
|
return setMobileView('preview');
|
|
3412
|
-
}, [setMobileView]);
|
|
3135
|
+
}, [setMobileView]);
|
|
3413
3136
|
|
|
3137
|
+
// Apply base theme values to it's own components
|
|
3414
3138
|
var _ref2 = value || {},
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3139
|
+
_ref2$background = _ref2.background,
|
|
3140
|
+
background = _ref2$background === void 0 ? null : _ref2$background,
|
|
3141
|
+
_ref2$colors = _ref2.colors,
|
|
3142
|
+
colors = _ref2$colors === void 0 ? null : _ref2$colors,
|
|
3143
|
+
_ref2$textStyles = _ref2.textStyles,
|
|
3144
|
+
textStyles = _ref2$textStyles === void 0 ? null : _ref2$textStyles,
|
|
3145
|
+
_ref2$boxStyles = _ref2.boxStyles,
|
|
3146
|
+
boxStyles = _ref2$boxStyles === void 0 ? null : _ref2$boxStyles;
|
|
3424
3147
|
var baseValue = isTheme ? _objectSpread(_objectSpread({}, value), {}, {
|
|
3425
3148
|
theme: {
|
|
3426
3149
|
background: background,
|
|
@@ -3430,13 +3153,10 @@ var Editor = function Editor(_ref) {
|
|
|
3430
3153
|
}
|
|
3431
3154
|
}) : value;
|
|
3432
3155
|
var story = useParsedStory(baseValue);
|
|
3433
|
-
|
|
3434
3156
|
var _useMediasParser = useMediasParser(),
|
|
3435
|
-
|
|
3436
|
-
|
|
3157
|
+
parseMediasToPath = _useMediasParser.toPath;
|
|
3437
3158
|
var onStoryChange = useCallback(function (newStory) {
|
|
3438
3159
|
var storyWithMedias = parseMediasToPath(newStory);
|
|
3439
|
-
|
|
3440
3160
|
if (onChange !== null) {
|
|
3441
3161
|
onChange(storyWithMedias);
|
|
3442
3162
|
}
|
|
@@ -3445,11 +3165,9 @@ var Editor = function Editor(_ref) {
|
|
|
3445
3165
|
var onClickScreen = useCallback(function (_ref3) {
|
|
3446
3166
|
var id = _ref3.id;
|
|
3447
3167
|
clickedScreenId.current = id;
|
|
3448
|
-
|
|
3449
3168
|
if (screenSize.screen) {
|
|
3450
3169
|
setMobileView('preview');
|
|
3451
3170
|
}
|
|
3452
|
-
|
|
3453
3171
|
push('screen', {
|
|
3454
3172
|
screen: clickedScreenId.current
|
|
3455
3173
|
});
|
|
@@ -3459,17 +3177,16 @@ var Editor = function Editor(_ref) {
|
|
|
3459
3177
|
push('screen', {
|
|
3460
3178
|
screen: newScreenId
|
|
3461
3179
|
});
|
|
3462
|
-
}, [push]);
|
|
3180
|
+
}, [push]);
|
|
3463
3181
|
|
|
3182
|
+
// Auto-scroll to current screen except when manually clicking one
|
|
3464
3183
|
useEffect(function () {
|
|
3465
3184
|
if (screenId === null || clickedScreenId.current === screenId) {
|
|
3466
3185
|
return;
|
|
3467
3186
|
}
|
|
3468
|
-
|
|
3469
3187
|
clickedScreenId.current = null;
|
|
3470
3188
|
var screens = refScreensContainer.current;
|
|
3471
3189
|
var items = screens.querySelectorAll("[data-screen-id=\"".concat(screenId, "\"]"));
|
|
3472
|
-
|
|
3473
3190
|
if (items !== null && items.length > 0) {
|
|
3474
3191
|
var item = items[0];
|
|
3475
3192
|
var cnt = item.parentNode.parentNode.parentNode;
|
|
@@ -3554,10 +3271,10 @@ var Editor = function Editor(_ref) {
|
|
|
3554
3271
|
className: styles$i.inner
|
|
3555
3272
|
}))), /*#__PURE__*/React.createElement(Modals, null)))));
|
|
3556
3273
|
};
|
|
3557
|
-
|
|
3558
3274
|
Editor.propTypes = propTypes$3;
|
|
3559
3275
|
Editor.defaultProps = defaultProps$3;
|
|
3560
3276
|
|
|
3277
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3561
3278
|
var routes = PropTypes.shape({
|
|
3562
3279
|
home: PropTypes.string.isRequired,
|
|
3563
3280
|
screen: PropTypes.string.isRequired,
|
|
@@ -3583,34 +3300,28 @@ var defaultProps$2 = {
|
|
|
3583
3300
|
className: null,
|
|
3584
3301
|
onChange: null
|
|
3585
3302
|
};
|
|
3586
|
-
|
|
3587
3303
|
var SettingsForm = function SettingsForm(_ref) {
|
|
3588
3304
|
var name = _ref.name,
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3305
|
+
field = _ref.field,
|
|
3306
|
+
value = _ref.value,
|
|
3307
|
+
className = _ref.className,
|
|
3308
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
3309
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
3310
|
+
onChange = _ref.onChange;
|
|
3595
3311
|
if (field === null) return false;
|
|
3596
|
-
|
|
3597
3312
|
var _ref2 = field || {},
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3313
|
+
_ref2$type = _ref2.type,
|
|
3314
|
+
type = _ref2$type === void 0 ? null : _ref2$type;
|
|
3601
3315
|
var fieldsManager = useFieldsManager();
|
|
3602
|
-
|
|
3603
3316
|
var _ref3 = type !== null ? fieldsManager.getDefinition(type) : field,
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3317
|
+
_ref3$component = _ref3.component,
|
|
3318
|
+
fieldComponent = _ref3$component === void 0 ? null : _ref3$component,
|
|
3319
|
+
settings = _ref3.settings;
|
|
3608
3320
|
var FieldComponent = useFieldComponent(fieldComponent);
|
|
3609
3321
|
var FieldsComponent = useFieldComponent('fields');
|
|
3610
3322
|
var SettingsComponent = FieldComponent !== null ? FieldComponent.settingsComponent || FieldsComponent : FieldsComponent;
|
|
3611
3323
|
var onSettingsChange = useCallback(function (newSettingsValue) {
|
|
3612
3324
|
var newValue = _objectSpread(_objectSpread({}, value), newSettingsValue);
|
|
3613
|
-
|
|
3614
3325
|
if (onChange !== null) {
|
|
3615
3326
|
onChange(newValue);
|
|
3616
3327
|
}
|
|
@@ -3629,7 +3340,6 @@ var SettingsForm = function SettingsForm(_ref) {
|
|
|
3629
3340
|
closeFieldForm: closeFieldForm
|
|
3630
3341
|
})));
|
|
3631
3342
|
};
|
|
3632
|
-
|
|
3633
3343
|
SettingsForm.propTypes = propTypes$2;
|
|
3634
3344
|
SettingsForm.defaultProps = defaultProps$2;
|
|
3635
3345
|
|
|
@@ -3647,14 +3357,12 @@ var propTypes$1 = {
|
|
|
3647
3357
|
var defaultProps$1 = {
|
|
3648
3358
|
children: null
|
|
3649
3359
|
};
|
|
3650
|
-
|
|
3651
3360
|
var FormsProvider = function FormsProvider(props) {
|
|
3652
3361
|
return /*#__PURE__*/React.createElement(ComponentsProvider, Object.assign({
|
|
3653
3362
|
namespace: FORMS_NAMESPACE,
|
|
3654
3363
|
components: FormsComponents
|
|
3655
3364
|
}, props));
|
|
3656
3365
|
};
|
|
3657
|
-
|
|
3658
3366
|
FormsProvider.propTypes = propTypes$1;
|
|
3659
3367
|
FormsProvider.defaultProps = defaultProps$1;
|
|
3660
3368
|
|
|
@@ -3690,24 +3398,22 @@ var defaultProps = {
|
|
|
3690
3398
|
googleMapsLibraries: ['places'],
|
|
3691
3399
|
screenNamespaces: null
|
|
3692
3400
|
};
|
|
3693
|
-
|
|
3694
3401
|
var EditorContainer = function EditorContainer(_ref) {
|
|
3695
3402
|
var value = _ref.value,
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3403
|
+
memoryRouter = _ref.memoryRouter,
|
|
3404
|
+
routes = _ref.routes,
|
|
3405
|
+
basePath = _ref.basePath,
|
|
3406
|
+
uppy = _ref.uppy,
|
|
3407
|
+
googleApiKey = _ref.googleApiKey,
|
|
3408
|
+
googleMapsLibraries = _ref.googleMapsLibraries,
|
|
3409
|
+
screenNamespaces = _ref.screenNamespaces,
|
|
3410
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
3705
3411
|
var Router = memoryRouter ? MemoryRouter : BrowserRouter;
|
|
3706
|
-
|
|
3707
3412
|
var _useIntl = useIntl(),
|
|
3708
|
-
|
|
3709
|
-
// const { language:finalLocale = locale } = metadata || {};
|
|
3413
|
+
locale = _useIntl.locale;
|
|
3710
3414
|
|
|
3415
|
+
// const { metadata } = value || {};
|
|
3416
|
+
// const { language:finalLocale = locale } = metadata || {};
|
|
3711
3417
|
|
|
3712
3418
|
return /*#__PURE__*/React.createElement(Router, {
|
|
3713
3419
|
basename: !memoryRouter ? basePath : null
|
|
@@ -3737,7 +3443,6 @@ var EditorContainer = function EditorContainer(_ref) {
|
|
|
3737
3443
|
}, props)));
|
|
3738
3444
|
}))))))))))));
|
|
3739
3445
|
};
|
|
3740
|
-
|
|
3741
3446
|
EditorContainer.propTypes = propTypes;
|
|
3742
3447
|
EditorContainer.defaultProps = defaultProps;
|
|
3743
3448
|
|