@micromag/editor 0.3.700 → 0.3.702
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +85 -85
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -523,19 +523,19 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
523
523
|
parentItem = !addNewItem ? item : null;
|
|
524
524
|
return nextField;
|
|
525
525
|
}, {
|
|
526
|
-
fields: stateId === null ? screenFields : screenFields.filter(function (
|
|
527
|
-
var
|
|
528
|
-
fieldStateId =
|
|
526
|
+
fields: stateId === null ? screenFields : screenFields.filter(function (_ref0) {
|
|
527
|
+
var _ref0$stateId = _ref0.stateId,
|
|
528
|
+
fieldStateId = _ref0$stateId === void 0 ? null : _ref0$stateId;
|
|
529
529
|
return fieldStateId === null || fieldStateId === stateId;
|
|
530
530
|
})
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
|
-
var
|
|
534
|
-
|
|
535
|
-
metadata =
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
title =
|
|
533
|
+
var _ref1 = screenParameters || {},
|
|
534
|
+
_ref1$metadata = _ref1.metadata,
|
|
535
|
+
metadata = _ref1$metadata === void 0 ? null : _ref1$metadata;
|
|
536
|
+
var _ref10 = metadata || {},
|
|
537
|
+
_ref10$title = _ref10.title,
|
|
538
|
+
title = _ref10$title === void 0 ? null : _ref10$title;
|
|
539
539
|
var typeTitle = screenTitle !== null ? /*#__PURE__*/React.createElement(FormattedMessage, screenTitle) : null;
|
|
540
540
|
var parametersMessage = intl.formatMessage({
|
|
541
541
|
id: "AHvHaY",
|
|
@@ -781,20 +781,20 @@ var EditForm = function EditForm(_ref) {
|
|
|
781
781
|
setScreenSettingsOpened(false);
|
|
782
782
|
}, [setScreenSettingsOpened]);
|
|
783
783
|
var onDeleteScreenConfirm = useCallback(function () {
|
|
784
|
-
var current = screens.findIndex(function (
|
|
785
|
-
var
|
|
786
|
-
scrId =
|
|
784
|
+
var current = screens.findIndex(function (_ref0) {
|
|
785
|
+
var _ref0$id = _ref0.id,
|
|
786
|
+
scrId = _ref0$id === void 0 ? null : _ref0$id;
|
|
787
787
|
return scrId === screenId;
|
|
788
788
|
}) || 0;
|
|
789
|
-
var previous = screens.find(function (
|
|
790
|
-
var
|
|
791
|
-
scrId =
|
|
789
|
+
var previous = screens.find(function (_ref1, i) {
|
|
790
|
+
var _ref1$id = _ref1.id,
|
|
791
|
+
scrId = _ref1$id === void 0 ? null : _ref1$id;
|
|
792
792
|
return scrId !== screenId && (i === current - 1 || current === 0);
|
|
793
793
|
}) || null;
|
|
794
794
|
if (previous !== null) {
|
|
795
|
-
var
|
|
796
|
-
|
|
797
|
-
firstScreenId =
|
|
795
|
+
var _ref10 = previous || {},
|
|
796
|
+
_ref10$id = _ref10.id,
|
|
797
|
+
firstScreenId = _ref10$id === void 0 ? null : _ref10$id;
|
|
798
798
|
routePush('screen', {
|
|
799
799
|
screen: firstScreenId
|
|
800
800
|
});
|
|
@@ -2258,9 +2258,9 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2258
2258
|
offsetLeft = _useState8[0],
|
|
2259
2259
|
setOffsetLeft = _useState8[1];
|
|
2260
2260
|
var _useState9 = useState(null),
|
|
2261
|
-
|
|
2262
|
-
currentPosition =
|
|
2263
|
-
setCurrentPosition =
|
|
2261
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
2262
|
+
currentPosition = _useState0[0],
|
|
2263
|
+
setCurrentPosition = _useState0[1];
|
|
2264
2264
|
|
|
2265
2265
|
// Tree setup from list
|
|
2266
2266
|
useEffect(function () {
|
|
@@ -2288,11 +2288,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2288
2288
|
items: flattenedItems,
|
|
2289
2289
|
offset: offsetLeft
|
|
2290
2290
|
});
|
|
2291
|
-
var
|
|
2291
|
+
var _useState1 = useState(function () {
|
|
2292
2292
|
return sortableTreeKeyboardCoordinates(sensorContext, indentationWidth);
|
|
2293
2293
|
}),
|
|
2294
|
-
|
|
2295
|
-
coordinateGetter =
|
|
2294
|
+
_useState10 = _slicedToArray(_useState1, 1),
|
|
2295
|
+
coordinateGetter = _useState10[0];
|
|
2296
2296
|
var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
2297
2297
|
coordinateGetter: coordinateGetter
|
|
2298
2298
|
}));
|
|
@@ -2390,12 +2390,12 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2390
2390
|
defaultId = _ref9$id === void 0 ? null : _ref9$id;
|
|
2391
2391
|
return defaultId === activeId;
|
|
2392
2392
|
});
|
|
2393
|
-
var handleDragStart = useCallback(function (
|
|
2394
|
-
var newActiveId =
|
|
2393
|
+
var handleDragStart = useCallback(function (_ref0) {
|
|
2394
|
+
var newActiveId = _ref0.active.id;
|
|
2395
2395
|
setActiveId(newActiveId);
|
|
2396
2396
|
setOverId(newActiveId);
|
|
2397
|
-
var newActiveItem = flattenedItems.find(function (
|
|
2398
|
-
var id =
|
|
2397
|
+
var newActiveItem = flattenedItems.find(function (_ref1) {
|
|
2398
|
+
var id = _ref1.id;
|
|
2399
2399
|
return id === newActiveId;
|
|
2400
2400
|
});
|
|
2401
2401
|
if (newActiveItem) {
|
|
@@ -2406,13 +2406,13 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2406
2406
|
}
|
|
2407
2407
|
document.body.style.setProperty('cursor', 'grabbing');
|
|
2408
2408
|
}, [flattenedItems, setActiveId, setOverId, setCurrentPosition]);
|
|
2409
|
-
var handleDragMove = useCallback(function (
|
|
2410
|
-
var delta =
|
|
2409
|
+
var handleDragMove = useCallback(function (_ref10) {
|
|
2410
|
+
var delta = _ref10.delta;
|
|
2411
2411
|
setOffsetLeft(delta.x);
|
|
2412
2412
|
}, [setOffsetLeft]);
|
|
2413
|
-
var handleDragOver = useCallback(function (
|
|
2413
|
+
var handleDragOver = useCallback(function (_ref11) {
|
|
2414
2414
|
var _over$id;
|
|
2415
|
-
var over =
|
|
2415
|
+
var over = _ref11.over;
|
|
2416
2416
|
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
2417
2417
|
}, [setOverId]);
|
|
2418
2418
|
var resetState = useCallback(function () {
|
|
@@ -2422,20 +2422,20 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2422
2422
|
setCurrentPosition(null);
|
|
2423
2423
|
document.body.style.setProperty('cursor', '');
|
|
2424
2424
|
}, [setOverId, setActiveId, setOffsetLeft, setCurrentPosition]);
|
|
2425
|
-
var handleDragEnd = useCallback(function (
|
|
2426
|
-
var active =
|
|
2427
|
-
over =
|
|
2425
|
+
var handleDragEnd = useCallback(function (_ref12) {
|
|
2426
|
+
var active = _ref12.active,
|
|
2427
|
+
over = _ref12.over;
|
|
2428
2428
|
resetState();
|
|
2429
2429
|
if (projected && over) {
|
|
2430
2430
|
var depth = projected.depth,
|
|
2431
2431
|
parentId = projected.parentId;
|
|
2432
2432
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2433
|
-
var overIndex = clonedItems.findIndex(function (
|
|
2434
|
-
var id =
|
|
2433
|
+
var overIndex = clonedItems.findIndex(function (_ref13) {
|
|
2434
|
+
var id = _ref13.id;
|
|
2435
2435
|
return id === over.id;
|
|
2436
2436
|
});
|
|
2437
|
-
var activeIndex = clonedItems.findIndex(function (
|
|
2438
|
-
var id =
|
|
2437
|
+
var activeIndex = clonedItems.findIndex(function (_ref14) {
|
|
2438
|
+
var id = _ref14.id;
|
|
2439
2439
|
return id === active.id;
|
|
2440
2440
|
});
|
|
2441
2441
|
var activeTreeItem = clonedItems[activeIndex];
|
|
@@ -2444,8 +2444,8 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2444
2444
|
if (depth > 0 && depth >= maxDepth && (activeTreeItem === null || activeTreeItem === void 0 ? void 0 : activeTreeItem.children) !== null && activeTreeItem.children.length > 0) {
|
|
2445
2445
|
var _loop2 = function _loop2() {
|
|
2446
2446
|
var childId = activeTreeItem.children[i].id;
|
|
2447
|
-
var childIndex = clonedItems.findIndex(function (
|
|
2448
|
-
var id =
|
|
2447
|
+
var childIndex = clonedItems.findIndex(function (_ref15) {
|
|
2448
|
+
var id = _ref15.id;
|
|
2449
2449
|
return id === childId;
|
|
2450
2450
|
});
|
|
2451
2451
|
clonedItems[childIndex].parentId = parentId;
|
|
@@ -2466,14 +2466,14 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2466
2466
|
if (onChange !== null) {
|
|
2467
2467
|
// console.log('hell is flat', sortedItems);
|
|
2468
2468
|
// console.log('hell is tree', newItems);
|
|
2469
|
-
onChange((sortedItems || []).map(function (
|
|
2470
|
-
var itemId =
|
|
2471
|
-
|
|
2472
|
-
children =
|
|
2473
|
-
|
|
2474
|
-
itParentId =
|
|
2475
|
-
|
|
2476
|
-
collapsed =
|
|
2469
|
+
onChange((sortedItems || []).map(function (_ref16) {
|
|
2470
|
+
var itemId = _ref16.id,
|
|
2471
|
+
_ref16$children = _ref16.children,
|
|
2472
|
+
children = _ref16$children === void 0 ? [] : _ref16$children,
|
|
2473
|
+
_ref16$parentId = _ref16.parentId,
|
|
2474
|
+
itParentId = _ref16$parentId === void 0 ? null : _ref16$parentId,
|
|
2475
|
+
_ref16$collapsed = _ref16.collapsed,
|
|
2476
|
+
collapsed = _ref16$collapsed === void 0 ? false : _ref16$collapsed;
|
|
2477
2477
|
return {
|
|
2478
2478
|
id: itemId,
|
|
2479
2479
|
props: _objectSpread(_objectSpread({}, (children || []).length > 0 ? {
|
|
@@ -2525,16 +2525,16 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2525
2525
|
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
2526
2526
|
items: sortedIds,
|
|
2527
2527
|
strategy: verticalListSortingStrategy
|
|
2528
|
-
}, flattenedItems.map(function (
|
|
2528
|
+
}, flattenedItems.map(function (_ref17, idx) {
|
|
2529
2529
|
var _flattenedItems;
|
|
2530
|
-
var id =
|
|
2531
|
-
|
|
2532
|
-
children =
|
|
2533
|
-
collapsed =
|
|
2534
|
-
depth =
|
|
2535
|
-
var screenValue = defaultItems.find(function (
|
|
2536
|
-
var
|
|
2537
|
-
defaultId =
|
|
2530
|
+
var id = _ref17.id,
|
|
2531
|
+
_ref17$children = _ref17.children,
|
|
2532
|
+
children = _ref17$children === void 0 ? [] : _ref17$children,
|
|
2533
|
+
collapsed = _ref17.collapsed,
|
|
2534
|
+
depth = _ref17.depth;
|
|
2535
|
+
var screenValue = defaultItems.find(function (_ref18) {
|
|
2536
|
+
var _ref18$id = _ref18.id,
|
|
2537
|
+
defaultId = _ref18$id === void 0 ? null : _ref18$id;
|
|
2538
2538
|
return defaultId === id;
|
|
2539
2539
|
});
|
|
2540
2540
|
var next = ((_flattenedItems = flattenedItems[idx + 1]) === null || _flattenedItems === void 0 ? void 0 : _flattenedItems.parentId) || null;
|
|
@@ -2544,9 +2544,9 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2544
2544
|
} : null;
|
|
2545
2545
|
var currentDepth = id === activeId && projected ? projected.depth : depth;
|
|
2546
2546
|
var childCount = getChildCount(items, id);
|
|
2547
|
-
var childValue = childCount > 0 && collapsed ? defaultItems.slice().reverse().find(function (
|
|
2548
|
-
var
|
|
2549
|
-
parentId =
|
|
2547
|
+
var childValue = childCount > 0 && collapsed ? defaultItems.slice().reverse().find(function (_ref19) {
|
|
2548
|
+
var _ref19$parentId = _ref19.parentId,
|
|
2549
|
+
parentId = _ref19$parentId === void 0 ? null : _ref19$parentId;
|
|
2550
2550
|
return parentId === id;
|
|
2551
2551
|
}) : null;
|
|
2552
2552
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -2585,8 +2585,8 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2585
2585
|
component: component,
|
|
2586
2586
|
value: activeValue === null || activeValue === void 0 ? void 0 : activeValue.value,
|
|
2587
2587
|
onClickItem: onClickItem,
|
|
2588
|
-
index: flattenedItems.findIndex(function (
|
|
2589
|
-
var id =
|
|
2588
|
+
index: flattenedItems.findIndex(function (_ref21) {
|
|
2589
|
+
var id = _ref21.id;
|
|
2590
2590
|
return activeId === id;
|
|
2591
2591
|
})
|
|
2592
2592
|
})) : null), document.body)));
|
|
@@ -2983,36 +2983,36 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
2983
2983
|
var props = _ref9.props;
|
|
2984
2984
|
return props !== null;
|
|
2985
2985
|
}) || []).length > 0;
|
|
2986
|
-
var
|
|
2987
|
-
|
|
2988
|
-
currentScreens =
|
|
2989
|
-
var currentIds = currentScreens.map(function (
|
|
2990
|
-
var id =
|
|
2986
|
+
var _ref0 = value || {},
|
|
2987
|
+
_ref0$components = _ref0.components,
|
|
2988
|
+
currentScreens = _ref0$components === void 0 ? [] : _ref0$components;
|
|
2989
|
+
var currentIds = currentScreens.map(function (_ref1) {
|
|
2990
|
+
var id = _ref1.id;
|
|
2991
2991
|
return id;
|
|
2992
2992
|
});
|
|
2993
|
-
var sameOrder = listItems.reduce(function (same,
|
|
2994
|
-
var id =
|
|
2993
|
+
var sameOrder = listItems.reduce(function (same, _ref10, index) {
|
|
2994
|
+
var id = _ref10.id;
|
|
2995
2995
|
return same && id === currentIds[index];
|
|
2996
2996
|
}, true);
|
|
2997
2997
|
if (!sameOrder || hasScreenProps) {
|
|
2998
2998
|
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
2999
|
-
components: _toConsumableArray(currentScreens).sort(function (
|
|
3000
|
-
var idA =
|
|
3001
|
-
var idB =
|
|
2999
|
+
components: _toConsumableArray(currentScreens).sort(function (_ref11, _ref12) {
|
|
3000
|
+
var idA = _ref11.id;
|
|
3001
|
+
var idB = _ref12.id;
|
|
3002
3002
|
var indexA = ids.indexOf(idA);
|
|
3003
3003
|
var indexB = ids.indexOf(idB);
|
|
3004
3004
|
if (indexA === indexB) {
|
|
3005
3005
|
return 0;
|
|
3006
3006
|
}
|
|
3007
3007
|
return indexA > indexB ? 1 : -1;
|
|
3008
|
-
}).map(function (
|
|
3008
|
+
}).map(function (_ref13) {
|
|
3009
3009
|
var _screenProps$find;
|
|
3010
|
-
var id =
|
|
3011
|
-
props = _objectWithoutProperties(
|
|
3010
|
+
var id = _ref13.id,
|
|
3011
|
+
props = _objectWithoutProperties(_ref13, _excluded$1);
|
|
3012
3012
|
return _objectSpread(_objectSpread({
|
|
3013
3013
|
id: id
|
|
3014
|
-
}, props), (_screenProps$find = screenProps.find(function (
|
|
3015
|
-
var propsId =
|
|
3014
|
+
}, props), (_screenProps$find = screenProps.find(function (_ref14) {
|
|
3015
|
+
var propsId = _ref14.id;
|
|
3016
3016
|
return propsId === id;
|
|
3017
3017
|
})) === null || _screenProps$find === void 0 ? void 0 : _screenProps$find.props);
|
|
3018
3018
|
})
|
|
@@ -3025,8 +3025,8 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3025
3025
|
}, [value, onChange]);
|
|
3026
3026
|
var onClickScreenType = useCallback(function (definition) {
|
|
3027
3027
|
setCreateModalOpened(false);
|
|
3028
|
-
var currentScreen = isTheme ? screens.find(function (
|
|
3029
|
-
var type =
|
|
3028
|
+
var currentScreen = isTheme ? screens.find(function (_ref15) {
|
|
3029
|
+
var type = _ref15.type;
|
|
3030
3030
|
return type === definition.id;
|
|
3031
3031
|
}) || null : null;
|
|
3032
3032
|
if (!isTheme || currentScreen === null) {
|
|
@@ -3069,9 +3069,9 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3069
3069
|
className: "flex-grow-1 d-flex w-100 p-2"
|
|
3070
3070
|
}, /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
|
|
3071
3071
|
path: "".concat(routes.screen, "/(.*)?")
|
|
3072
|
-
}, function (
|
|
3073
|
-
var
|
|
3074
|
-
screenId =
|
|
3072
|
+
}, function (_ref16) {
|
|
3073
|
+
var _ref16$screen = _ref16.screen,
|
|
3074
|
+
screenId = _ref16$screen === void 0 ? null : _ref16$screen;
|
|
3075
3075
|
return screens.length > 0 ? /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
3076
3076
|
items: screens.map(function (it) {
|
|
3077
3077
|
return {
|
|
@@ -3132,8 +3132,8 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
3132
3132
|
"value": "Create your first screen"
|
|
3133
3133
|
}]
|
|
3134
3134
|
})))))), createModalOpened ? /*#__PURE__*/React.createElement(ScreenTypesModal, {
|
|
3135
|
-
selectedTypes: isTheme ? screens.map(function (
|
|
3136
|
-
var type =
|
|
3135
|
+
selectedTypes: isTheme ? screens.map(function (_ref17) {
|
|
3136
|
+
var type = _ref17.type;
|
|
3137
3137
|
return type;
|
|
3138
3138
|
}) : [],
|
|
3139
3139
|
onClickScreenType: onClickScreenType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/editor",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.702",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@micromag/core": "^0.3.679",
|
|
75
75
|
"@micromag/elements": "^0.3.700",
|
|
76
76
|
"@micromag/fields": "^0.3.699",
|
|
77
|
-
"@micromag/screens": "^0.3.
|
|
78
|
-
"@micromag/viewer": "^0.3.
|
|
77
|
+
"@micromag/screens": "^0.3.702",
|
|
78
|
+
"@micromag/viewer": "^0.3.702",
|
|
79
79
|
"@panneau/uppy": "^3.0.162",
|
|
80
80
|
"classnames": "^2.2.6",
|
|
81
81
|
"lodash": "^4.17.21",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"access": "public",
|
|
92
92
|
"registry": "https://registry.npmjs.org/"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "32ebadd6d81e82991e0b70200c38c91d51ba357a"
|
|
95
95
|
}
|