@micromag/editor 0.2.297 → 0.2.302
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 +61 -223
- package/lib/index.js +60 -225
- package/package.json +7 -7
package/es/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useResizeObserver, useParsedStory, useScreenSizeFromElement, useMediasP
|
|
|
17
17
|
import { Button, ScreenPreview, ScreenPlaceholder, Label, Modal, ModalDialog, Navbar, Empty, Tabs, BackButton, Breadcrumb as Breadcrumb$1, FieldForm, DropdownMenu, Modals } from '@micromag/core/components';
|
|
18
18
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
19
19
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
20
|
-
import { faPlus, faCogs
|
|
20
|
+
import { faPlus, faCogs } from '@fortawesome/free-solid-svg-icons';
|
|
21
21
|
import isString from 'lodash/isString';
|
|
22
22
|
import { v1 } from 'uuid';
|
|
23
23
|
import { getSizeWithinBounds } from '@folklore/size';
|
|
@@ -25,9 +25,9 @@ import { ReactSortable } from 'react-sortablejs';
|
|
|
25
25
|
import orderBy from 'lodash/orderBy';
|
|
26
26
|
import { Viewer } from '@micromag/viewer';
|
|
27
27
|
import { CSSTransitionGroup } from 'react-transition-group';
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
28
|
+
import 'lodash/isArray';
|
|
29
|
+
import 'lodash/get';
|
|
30
|
+
import 'lodash/set';
|
|
31
31
|
|
|
32
32
|
var routes = PropTypes.shape({
|
|
33
33
|
home: PropTypes.string.isRequired,
|
|
@@ -38,7 +38,7 @@ var routes = PropTypes.shape({
|
|
|
38
38
|
|
|
39
39
|
var styles$d = {"container":"micromag-editor-forms-settings-container","inner":"micromag-editor-forms-settings-inner"};
|
|
40
40
|
|
|
41
|
-
var propTypes$
|
|
41
|
+
var propTypes$j = {
|
|
42
42
|
name: PropTypes.string,
|
|
43
43
|
field: PropTypes$1.formField.isRequired,
|
|
44
44
|
value: PropTypes$1.component,
|
|
@@ -47,7 +47,7 @@ var propTypes$k = {
|
|
|
47
47
|
closeFieldForm: PropTypes.func.isRequired,
|
|
48
48
|
onChange: PropTypes.func
|
|
49
49
|
};
|
|
50
|
-
var defaultProps$
|
|
50
|
+
var defaultProps$j = {
|
|
51
51
|
name: null,
|
|
52
52
|
value: null,
|
|
53
53
|
className: null,
|
|
@@ -96,8 +96,8 @@ var SettingsForm = function SettingsForm(_ref) {
|
|
|
96
96
|
})));
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
SettingsForm.propTypes = propTypes$
|
|
100
|
-
SettingsForm.defaultProps = defaultProps$
|
|
99
|
+
SettingsForm.propTypes = propTypes$j;
|
|
100
|
+
SettingsForm.defaultProps = defaultProps$j;
|
|
101
101
|
|
|
102
102
|
// eslint-disable-next-line import/prefer-default-export
|
|
103
103
|
|
|
@@ -107,10 +107,10 @@ var FormsComponents = /*#__PURE__*/Object.freeze({
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
110
|
-
var propTypes$
|
|
110
|
+
var propTypes$i = {
|
|
111
111
|
children: PropTypes.node
|
|
112
112
|
};
|
|
113
|
-
var defaultProps$
|
|
113
|
+
var defaultProps$i = {
|
|
114
114
|
children: null
|
|
115
115
|
};
|
|
116
116
|
|
|
@@ -121,8 +121,8 @@ var FormsProvider = function FormsProvider(props) {
|
|
|
121
121
|
}, props));
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
FormsProvider.propTypes = propTypes$
|
|
125
|
-
FormsProvider.defaultProps = defaultProps$
|
|
124
|
+
FormsProvider.propTypes = propTypes$i;
|
|
125
|
+
FormsProvider.defaultProps = defaultProps$i;
|
|
126
126
|
|
|
127
127
|
var useRouteParams = function useRouteParams() {
|
|
128
128
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -212,7 +212,7 @@ var createScreen = function createScreen(definition) {
|
|
|
212
212
|
|
|
213
213
|
var styles$c = {"container":"micromag-editor-buttons-screen-container","button":"micromag-editor-buttons-screen-button","border":"micromag-editor-buttons-screen-border","screen":"micromag-editor-buttons-screen-screen","inner":"micromag-editor-buttons-screen-inner","icon":"micromag-editor-buttons-screen-icon","label":"micromag-editor-buttons-screen-label","active":"micromag-editor-buttons-screen-active"};
|
|
214
214
|
|
|
215
|
-
var propTypes$
|
|
215
|
+
var propTypes$h = {
|
|
216
216
|
active: PropTypes.bool,
|
|
217
217
|
id: PropTypes.string,
|
|
218
218
|
href: PropTypes.string,
|
|
@@ -227,7 +227,7 @@ var propTypes$i = {
|
|
|
227
227
|
}),
|
|
228
228
|
className: PropTypes.string
|
|
229
229
|
};
|
|
230
|
-
var defaultProps$
|
|
230
|
+
var defaultProps$h = {
|
|
231
231
|
active: false,
|
|
232
232
|
id: null,
|
|
233
233
|
href: null,
|
|
@@ -276,8 +276,8 @@ var ScreenButton = function ScreenButton(_ref) {
|
|
|
276
276
|
})));
|
|
277
277
|
};
|
|
278
278
|
|
|
279
|
-
ScreenButton.propTypes = propTypes$
|
|
280
|
-
ScreenButton.defaultProps = defaultProps$
|
|
279
|
+
ScreenButton.propTypes = propTypes$h;
|
|
280
|
+
ScreenButton.defaultProps = defaultProps$h;
|
|
281
281
|
var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
282
282
|
return /*#__PURE__*/React.createElement(ScreenButton, Object.assign({}, props, {
|
|
283
283
|
refButton: ref
|
|
@@ -286,7 +286,7 @@ var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
286
286
|
|
|
287
287
|
var styles$b = {"container":"micromag-editor-menus-screens-container","placeholder":"micromag-editor-menus-screens-placeholder","preview":"micromag-editor-menus-screens-preview","screen":"micromag-editor-menus-screens-screen","item":"micromag-editor-menus-screens-item","items":"micromag-editor-menus-screens-items","button":"micromag-editor-menus-screens-button","settings":"micromag-editor-menus-screens-settings","isVertical":"micromag-editor-menus-screens-isVertical","noWrap":"micromag-editor-menus-screens-noWrap","withPlaceholder":"micromag-editor-menus-screens-withPlaceholder"};
|
|
288
288
|
|
|
289
|
-
var propTypes$
|
|
289
|
+
var propTypes$g = {
|
|
290
290
|
items: PropTypes$1.menuItems,
|
|
291
291
|
withPreview: PropTypes.bool,
|
|
292
292
|
withPlaceholder: PropTypes.bool,
|
|
@@ -302,7 +302,7 @@ var propTypes$h = {
|
|
|
302
302
|
onClickItem: PropTypes.func,
|
|
303
303
|
onOrderChange: PropTypes.func
|
|
304
304
|
};
|
|
305
|
-
var defaultProps$
|
|
305
|
+
var defaultProps$g = {
|
|
306
306
|
items: [],
|
|
307
307
|
withPreview: false,
|
|
308
308
|
withPlaceholder: false,
|
|
@@ -431,18 +431,18 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
431
431
|
}, itemsElements));
|
|
432
432
|
};
|
|
433
433
|
|
|
434
|
-
ScreensMenu.propTypes = propTypes$
|
|
435
|
-
ScreensMenu.defaultProps = defaultProps$
|
|
434
|
+
ScreensMenu.propTypes = propTypes$g;
|
|
435
|
+
ScreensMenu.defaultProps = defaultProps$g;
|
|
436
436
|
|
|
437
437
|
var styles$a = {"container":"micromag-editor-menus-screen-types-container","row":"micromag-editor-menus-screen-types-row","title":"micromag-editor-menus-screen-types-title"};
|
|
438
438
|
|
|
439
|
-
var propTypes$
|
|
439
|
+
var propTypes$f = {
|
|
440
440
|
screens: PropTypes$1.screenDefinitions,
|
|
441
441
|
selectedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
442
442
|
className: PropTypes.string,
|
|
443
443
|
onClickItem: PropTypes.func
|
|
444
444
|
};
|
|
445
|
-
var defaultProps$
|
|
445
|
+
var defaultProps$f = {
|
|
446
446
|
screens: null,
|
|
447
447
|
selectedTypes: null,
|
|
448
448
|
className: null,
|
|
@@ -542,18 +542,18 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
542
542
|
})));
|
|
543
543
|
};
|
|
544
544
|
|
|
545
|
-
ScreenTypes.propTypes = propTypes$
|
|
546
|
-
ScreenTypes.defaultProps = defaultProps$
|
|
545
|
+
ScreenTypes.propTypes = propTypes$f;
|
|
546
|
+
ScreenTypes.defaultProps = defaultProps$f;
|
|
547
547
|
|
|
548
548
|
var styles$9 = {"container":"micromag-editor-modals-screen-types-container","selected":"micromag-editor-modals-screen-types-selected"};
|
|
549
549
|
|
|
550
|
-
var propTypes$
|
|
550
|
+
var propTypes$e = {
|
|
551
551
|
selectedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
552
552
|
className: PropTypes.string,
|
|
553
553
|
onRequestClose: PropTypes.func,
|
|
554
554
|
onClickScreenType: PropTypes.func
|
|
555
555
|
};
|
|
556
|
-
var defaultProps$
|
|
556
|
+
var defaultProps$e = {
|
|
557
557
|
selectedTypes: null,
|
|
558
558
|
className: null,
|
|
559
559
|
onRequestClose: null,
|
|
@@ -582,12 +582,12 @@ var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
|
582
582
|
})));
|
|
583
583
|
};
|
|
584
584
|
|
|
585
|
-
ScreenTypesModal.propTypes = propTypes$
|
|
586
|
-
ScreenTypesModal.defaultProps = defaultProps$
|
|
585
|
+
ScreenTypesModal.propTypes = propTypes$e;
|
|
586
|
+
ScreenTypesModal.defaultProps = defaultProps$e;
|
|
587
587
|
|
|
588
588
|
var styles$8 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
589
589
|
|
|
590
|
-
var propTypes$
|
|
590
|
+
var propTypes$d = {
|
|
591
591
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
592
592
|
isTheme: PropTypes.bool,
|
|
593
593
|
isVertical: PropTypes.bool,
|
|
@@ -597,7 +597,7 @@ var propTypes$e = {
|
|
|
597
597
|
onChange: PropTypes.func,
|
|
598
598
|
className: PropTypes.string
|
|
599
599
|
};
|
|
600
|
-
var defaultProps$
|
|
600
|
+
var defaultProps$d = {
|
|
601
601
|
value: null,
|
|
602
602
|
isTheme: false,
|
|
603
603
|
isVertical: false,
|
|
@@ -804,15 +804,15 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
804
804
|
}) : null);
|
|
805
805
|
};
|
|
806
806
|
|
|
807
|
-
EditorScreens.propTypes = propTypes$
|
|
808
|
-
EditorScreens.defaultProps = defaultProps$
|
|
807
|
+
EditorScreens.propTypes = propTypes$d;
|
|
808
|
+
EditorScreens.defaultProps = defaultProps$d;
|
|
809
809
|
|
|
810
810
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
811
|
-
var propTypes$
|
|
811
|
+
var propTypes$c = {
|
|
812
812
|
color: PropTypes.string,
|
|
813
813
|
className: PropTypes.string
|
|
814
814
|
};
|
|
815
|
-
var defaultProps$
|
|
815
|
+
var defaultProps$c = {
|
|
816
816
|
color: 'currentColor',
|
|
817
817
|
className: null
|
|
818
818
|
};
|
|
@@ -837,15 +837,15 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
837
837
|
}));
|
|
838
838
|
};
|
|
839
839
|
|
|
840
|
-
DesktopIcon.propTypes = propTypes$
|
|
841
|
-
DesktopIcon.defaultProps = defaultProps$
|
|
840
|
+
DesktopIcon.propTypes = propTypes$c;
|
|
841
|
+
DesktopIcon.defaultProps = defaultProps$c;
|
|
842
842
|
|
|
843
843
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
844
|
-
var propTypes$
|
|
844
|
+
var propTypes$b = {
|
|
845
845
|
color: PropTypes.string,
|
|
846
846
|
className: PropTypes.string
|
|
847
847
|
};
|
|
848
|
-
var defaultProps$
|
|
848
|
+
var defaultProps$b = {
|
|
849
849
|
color: 'currentColor',
|
|
850
850
|
className: null
|
|
851
851
|
};
|
|
@@ -870,8 +870,8 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
870
870
|
}));
|
|
871
871
|
};
|
|
872
872
|
|
|
873
|
-
MobileIcon.propTypes = propTypes$
|
|
874
|
-
MobileIcon.defaultProps = defaultProps$
|
|
873
|
+
MobileIcon.propTypes = propTypes$b;
|
|
874
|
+
MobileIcon.defaultProps = defaultProps$b;
|
|
875
875
|
|
|
876
876
|
var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
877
877
|
__proto__: null,
|
|
@@ -881,12 +881,12 @@ var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
|
881
881
|
|
|
882
882
|
var styles$7 = {"container":"micromag-editor-buttons-device-container","icon":"micromag-editor-buttons-device-icon"};
|
|
883
883
|
|
|
884
|
-
var propTypes$
|
|
884
|
+
var propTypes$a = {
|
|
885
885
|
device: PropTypes.string.isRequired,
|
|
886
886
|
iconComponents: PropTypes$1.components,
|
|
887
887
|
className: PropTypes.string
|
|
888
888
|
};
|
|
889
|
-
var defaultProps$
|
|
889
|
+
var defaultProps$a = {
|
|
890
890
|
iconComponents: DeviceIcons,
|
|
891
891
|
className: null
|
|
892
892
|
};
|
|
@@ -905,17 +905,17 @@ var DeviceButton = function DeviceButton(_ref) {
|
|
|
905
905
|
}));
|
|
906
906
|
};
|
|
907
907
|
|
|
908
|
-
DeviceButton.propTypes = propTypes$
|
|
909
|
-
DeviceButton.defaultProps = defaultProps$
|
|
908
|
+
DeviceButton.propTypes = propTypes$a;
|
|
909
|
+
DeviceButton.defaultProps = defaultProps$a;
|
|
910
910
|
|
|
911
911
|
var styles$6 = {"container":"micromag-editor-menus-devices-container","button":"micromag-editor-menus-devices-button"};
|
|
912
912
|
|
|
913
|
-
var propTypes$
|
|
913
|
+
var propTypes$9 = {
|
|
914
914
|
items: PropTypes$1.menuItems,
|
|
915
915
|
className: PropTypes.string,
|
|
916
916
|
onClickItem: PropTypes.func
|
|
917
917
|
};
|
|
918
|
-
var defaultProps$
|
|
918
|
+
var defaultProps$9 = {
|
|
919
919
|
items: [],
|
|
920
920
|
className: null,
|
|
921
921
|
onClickItem: null
|
|
@@ -945,12 +945,12 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
945
945
|
});
|
|
946
946
|
};
|
|
947
947
|
|
|
948
|
-
DevicesMenu.propTypes = propTypes$
|
|
949
|
-
DevicesMenu.defaultProps = defaultProps$
|
|
948
|
+
DevicesMenu.propTypes = propTypes$9;
|
|
949
|
+
DevicesMenu.defaultProps = defaultProps$9;
|
|
950
950
|
|
|
951
951
|
var styles$5 = {"container":"micromag-editor-preview-container","noStory":"micromag-editor-preview-noStory","story":"micromag-editor-preview-story","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","screen-medium":"micromag-editor-preview-screen-medium","withoutDevicesSizes":"micromag-editor-preview-withoutDevicesSizes"};
|
|
952
952
|
|
|
953
|
-
var propTypes$
|
|
953
|
+
var propTypes$8 = {
|
|
954
954
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
955
955
|
devices: PropTypes$1.devices,
|
|
956
956
|
device: PropTypes.string,
|
|
@@ -960,7 +960,7 @@ var propTypes$9 = {
|
|
|
960
960
|
onScreenChange: PropTypes.func,
|
|
961
961
|
withoutDevicesSizes: PropTypes.bool
|
|
962
962
|
};
|
|
963
|
-
var defaultProps$
|
|
963
|
+
var defaultProps$8 = {
|
|
964
964
|
value: null,
|
|
965
965
|
devices: [{
|
|
966
966
|
id: 'mobile',
|
|
@@ -1093,8 +1093,8 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1093
1093
|
}))))));
|
|
1094
1094
|
};
|
|
1095
1095
|
|
|
1096
|
-
EditorPreview.propTypes = propTypes$
|
|
1097
|
-
EditorPreview.defaultProps = defaultProps$
|
|
1096
|
+
EditorPreview.propTypes = propTypes$8;
|
|
1097
|
+
EditorPreview.defaultProps = defaultProps$8;
|
|
1098
1098
|
|
|
1099
1099
|
var deleteScreen = function deleteScreen(story, screenId) {
|
|
1100
1100
|
var _ref = story || {},
|
|
@@ -1161,95 +1161,6 @@ var getFieldByName = function getFieldByName(fields, name) {
|
|
|
1161
1161
|
}, null);
|
|
1162
1162
|
};
|
|
1163
1163
|
|
|
1164
|
-
var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
|
|
1165
|
-
return (isArray(path) ? path : [path]).reduce(function (foundField, key) {
|
|
1166
|
-
if (foundField === null) {
|
|
1167
|
-
return null;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
var _foundField$type = foundField.type,
|
|
1171
|
-
type = _foundField$type === void 0 ? null : _foundField$type;
|
|
1172
|
-
|
|
1173
|
-
var _ref = type !== null ? fieldManager.getDefinition(type) : foundField,
|
|
1174
|
-
_ref$fields = _ref.fields,
|
|
1175
|
-
subFields = _ref$fields === void 0 ? null : _ref$fields,
|
|
1176
|
-
_ref$settings = _ref.settings,
|
|
1177
|
-
settings = _ref$settings === void 0 ? null : _ref$settings,
|
|
1178
|
-
_ref$itemsField = _ref.itemsField,
|
|
1179
|
-
itemsField = _ref$itemsField === void 0 ? null : _ref$itemsField;
|
|
1180
|
-
|
|
1181
|
-
if (itemsField !== null && key.match(/^[0-9]+$/)) {
|
|
1182
|
-
return _objectSpread(_objectSpread({}, itemsField), {}, {
|
|
1183
|
-
name: path.join('/'),
|
|
1184
|
-
listItems: true
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
return getFieldByName([].concat(_toConsumableArray(subFields || []), _toConsumableArray(settings || [])), key);
|
|
1189
|
-
}, {
|
|
1190
|
-
fields: fields
|
|
1191
|
-
});
|
|
1192
|
-
};
|
|
1193
|
-
|
|
1194
|
-
var getListItemFromScreen = function getListItemFromScreen(fieldParams, screen) {
|
|
1195
|
-
var path = fieldParams.split('/');
|
|
1196
|
-
var listKey = path.filter(function (_, i) {
|
|
1197
|
-
return i < path.length - 1;
|
|
1198
|
-
}).join('.');
|
|
1199
|
-
var itemIndex = path.length > 0 ? parseInt(path[path.length - 1], 10) : null;
|
|
1200
|
-
var list = get(screen, listKey, null);
|
|
1201
|
-
var item = list !== null ? list[itemIndex] : null;
|
|
1202
|
-
return {
|
|
1203
|
-
listKey: listKey,
|
|
1204
|
-
itemIndex: itemIndex,
|
|
1205
|
-
list: list,
|
|
1206
|
-
item: item
|
|
1207
|
-
};
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
|
-
var duplicateListItem = function duplicateListItem(fieldParams, story, screenIndex) {
|
|
1211
|
-
var _ref = story || {},
|
|
1212
|
-
_ref$components = _ref.components,
|
|
1213
|
-
screens = _ref$components === void 0 ? [] : _ref$components;
|
|
1214
|
-
|
|
1215
|
-
var screen = screens.length > screenIndex ? screens[screenIndex] : null;
|
|
1216
|
-
|
|
1217
|
-
var _getListItemFromScree = getListItemFromScreen(fieldParams, screen),
|
|
1218
|
-
listKey = _getListItemFromScree.listKey,
|
|
1219
|
-
list = _getListItemFromScree.list,
|
|
1220
|
-
item = _getListItemFromScree.item;
|
|
1221
|
-
|
|
1222
|
-
var newScreen = _objectSpread(_objectSpread({}, screen), {}, _defineProperty({}, listKey, [].concat(_toConsumableArray(list), [item])));
|
|
1223
|
-
|
|
1224
|
-
return _objectSpread(_objectSpread({}, story), {}, {
|
|
1225
|
-
components: screens.map(function (scr, index) {
|
|
1226
|
-
return index === screenIndex ? newScreen : scr;
|
|
1227
|
-
})
|
|
1228
|
-
});
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
|
-
var deleteListItem = function deleteListItem(fieldParams, story, screenIndex) {
|
|
1232
|
-
var _ref = story || {},
|
|
1233
|
-
_ref$components = _ref.components,
|
|
1234
|
-
screens = _ref$components === void 0 ? [] : _ref$components;
|
|
1235
|
-
|
|
1236
|
-
var screen = screens.length > screenIndex ? screens[screenIndex] : null;
|
|
1237
|
-
|
|
1238
|
-
var _getListItemFromScree = getListItemFromScreen(fieldParams, screen),
|
|
1239
|
-
listKey = _getListItemFromScree.listKey,
|
|
1240
|
-
list = _getListItemFromScree.list,
|
|
1241
|
-
itemIndex = _getListItemFromScree.itemIndex;
|
|
1242
|
-
|
|
1243
|
-
var newScreen = set(_objectSpread({}, screen), listKey, list.filter(function (it, index) {
|
|
1244
|
-
return itemIndex !== index;
|
|
1245
|
-
}));
|
|
1246
|
-
return _objectSpread(_objectSpread({}, story), {}, {
|
|
1247
|
-
components: screens.map(function (scr, index) {
|
|
1248
|
-
return index === screenIndex ? newScreen : scr;
|
|
1249
|
-
})
|
|
1250
|
-
});
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
1164
|
var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
1254
1165
|
var lastPageRef = useRef({
|
|
1255
1166
|
url: url,
|
|
@@ -1294,10 +1205,10 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
1294
1205
|
};
|
|
1295
1206
|
};
|
|
1296
1207
|
|
|
1297
|
-
var propTypes$
|
|
1208
|
+
var propTypes$7 = {
|
|
1298
1209
|
className: PropTypes.string
|
|
1299
1210
|
};
|
|
1300
|
-
var defaultProps$
|
|
1211
|
+
var defaultProps$7 = {
|
|
1301
1212
|
className: null
|
|
1302
1213
|
};
|
|
1303
1214
|
|
|
@@ -1315,36 +1226,8 @@ var SettingsButton = function SettingsButton(_ref) {
|
|
|
1315
1226
|
}, props));
|
|
1316
1227
|
};
|
|
1317
1228
|
|
|
1318
|
-
SettingsButton.propTypes = propTypes$
|
|
1319
|
-
SettingsButton.defaultProps = defaultProps$
|
|
1320
|
-
|
|
1321
|
-
var propTypes$7 = {
|
|
1322
|
-
className: PropTypes.string
|
|
1323
|
-
};
|
|
1324
|
-
var defaultProps$7 = {
|
|
1325
|
-
className: null
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
|
-
var DeleteButton = function DeleteButton(_ref) {
|
|
1329
|
-
var className = _ref.className,
|
|
1330
|
-
props = _objectWithoutProperties(_ref, ["className"]);
|
|
1331
|
-
|
|
1332
|
-
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
1333
|
-
className: className,
|
|
1334
|
-
theme: "danger",
|
|
1335
|
-
size: "sm",
|
|
1336
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1337
|
-
icon: faTrash
|
|
1338
|
-
})
|
|
1339
|
-
}, props));
|
|
1340
|
-
};
|
|
1341
|
-
|
|
1342
|
-
DeleteButton.propTypes = propTypes$7;
|
|
1343
|
-
DeleteButton.defaultProps = defaultProps$7;
|
|
1344
|
-
|
|
1345
|
-
({
|
|
1346
|
-
className: PropTypes.string
|
|
1347
|
-
});
|
|
1229
|
+
SettingsButton.propTypes = propTypes$7;
|
|
1230
|
+
SettingsButton.defaultProps = defaultProps$7;
|
|
1348
1231
|
|
|
1349
1232
|
var styles$4 = {"container":"micromag-editor-menus-breadcrumb-container"};
|
|
1350
1233
|
|
|
@@ -1688,27 +1571,7 @@ var EditForm = function EditForm(_ref) {
|
|
|
1688
1571
|
var screenIndex = screens.findIndex(function (it) {
|
|
1689
1572
|
return it.id === screenId;
|
|
1690
1573
|
});
|
|
1691
|
-
var screen = screenIndex !== -1 ? screens[screenIndex] : null;
|
|
1692
|
-
|
|
1693
|
-
var _ref3 = screen || {},
|
|
1694
|
-
_ref3$type = _ref3.type,
|
|
1695
|
-
type = _ref3$type === void 0 ? null : _ref3$type;
|
|
1696
|
-
|
|
1697
|
-
var screensManager = useScreensManager();
|
|
1698
|
-
var fieldsManager = useFieldsManager();
|
|
1699
|
-
|
|
1700
|
-
var _ref4 = type !== null ? screensManager.getDefinition(type) : {},
|
|
1701
|
-
_ref4$fields = _ref4.fields,
|
|
1702
|
-
fields = _ref4$fields === void 0 ? [] : _ref4$fields;
|
|
1703
|
-
|
|
1704
|
-
var currentField = useMemo(function () {
|
|
1705
|
-
return fieldParams !== null ? getFieldFromPath(fieldParams.split('/'), fields, fieldsManager) : null;
|
|
1706
|
-
}, [fieldParams, fields]);
|
|
1707
|
-
|
|
1708
|
-
var _ref5 = currentField || {},
|
|
1709
|
-
_ref5$listItems = _ref5.listItems,
|
|
1710
|
-
currentFieldListItems = _ref5$listItems === void 0 ? false : _ref5$listItems; // Get transition value
|
|
1711
|
-
|
|
1574
|
+
var screen = screenIndex !== -1 ? screens[screenIndex] : null; // Get transition value
|
|
1712
1575
|
|
|
1713
1576
|
var _useFormTransition = useFormTransition(url, screenIndex, styles$1),
|
|
1714
1577
|
transitionName = _useFormTransition.name,
|
|
@@ -1793,21 +1656,6 @@ var EditForm = function EditForm(_ref) {
|
|
|
1793
1656
|
var onDeleteScreenCancel = useCallback(function () {
|
|
1794
1657
|
setDeleteScreenModalOpened(false);
|
|
1795
1658
|
}, [setDeleteScreenModalOpened]);
|
|
1796
|
-
/* List item */
|
|
1797
|
-
|
|
1798
|
-
var onDeleteItemClick = useCallback(function () {
|
|
1799
|
-
triggerOnChange(deleteListItem(fieldParams, value, screenIndex));
|
|
1800
|
-
gotoFieldForm();
|
|
1801
|
-
}, [fieldParams, value, screenIndex]); // eslint-disable-next-line no-unused-vars
|
|
1802
|
-
|
|
1803
|
-
useCallback(function () {
|
|
1804
|
-
var path = fieldParams.split('/');
|
|
1805
|
-
var listKey = path.length ? path[0] : null;
|
|
1806
|
-
var field = typeof screen[listKey] !== 'undefined' ? screen[listKey] : null;
|
|
1807
|
-
var fieldItemsCount = field !== null ? field.length : 0;
|
|
1808
|
-
triggerOnChange(duplicateListItem(fieldParams, value, screenIndex));
|
|
1809
|
-
gotoFieldForm("".concat(listKey, ".").concat(fieldItemsCount));
|
|
1810
|
-
}, [fieldParams, screen, value, screenIndex]);
|
|
1811
1659
|
var dropdownItems = [!isTheme ? {
|
|
1812
1660
|
id: 'duplicate',
|
|
1813
1661
|
type: 'button',
|
|
@@ -1877,19 +1725,7 @@ var EditForm = function EditForm(_ref) {
|
|
|
1877
1725
|
closeFieldForm: closeFieldForm,
|
|
1878
1726
|
fieldContext: fieldContext,
|
|
1879
1727
|
onChange: onScreenFormChange
|
|
1880
|
-
})
|
|
1881
|
-
className: "m-2"
|
|
1882
|
-
}, /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement("div", {
|
|
1883
|
-
className: "text-right"
|
|
1884
|
-
}, /*#__PURE__*/React.createElement(DeleteButton, {
|
|
1885
|
-
onClick: onDeleteItemClick
|
|
1886
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1887
|
-
id: "CQ7Wmr",
|
|
1888
|
-
defaultMessage: [{
|
|
1889
|
-
"type": 0,
|
|
1890
|
-
"value": "Delete item"
|
|
1891
|
-
}]
|
|
1892
|
-
})))) : null)) : /*#__PURE__*/React.createElement("div", {
|
|
1728
|
+
}))) : /*#__PURE__*/React.createElement("div", {
|
|
1893
1729
|
className: classNames(['w-100', styles$1.panel]),
|
|
1894
1730
|
key: "screen-".concat(screen.id)
|
|
1895
1731
|
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
@@ -2170,7 +2006,9 @@ var EditorContainer = function EditorContainer(_ref) {
|
|
|
2170
2006
|
var Router = memoryRouter ? MemoryRouter : BrowserRouter;
|
|
2171
2007
|
|
|
2172
2008
|
var _useIntl = useIntl(),
|
|
2173
|
-
locale = _useIntl.locale;
|
|
2009
|
+
locale = _useIntl.locale; // const { metadata } = value || {};
|
|
2010
|
+
// const { language:finalLocale = locale } = metadata || {};
|
|
2011
|
+
|
|
2174
2012
|
|
|
2175
2013
|
return /*#__PURE__*/React.createElement(Router, {
|
|
2176
2014
|
basename: !memoryRouter ? basePath : null
|
package/lib/index.js
CHANGED
|
@@ -29,9 +29,9 @@ var reactSortablejs = require('react-sortablejs');
|
|
|
29
29
|
var orderBy = require('lodash/orderBy');
|
|
30
30
|
var viewer = require('@micromag/viewer');
|
|
31
31
|
var reactTransitionGroup = require('react-transition-group');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
require('lodash/isArray');
|
|
33
|
+
require('lodash/get');
|
|
34
|
+
require('lodash/set');
|
|
35
35
|
|
|
36
36
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
37
37
|
|
|
@@ -45,9 +45,6 @@ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray)
|
|
|
45
45
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
46
46
|
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
47
47
|
var orderBy__default = /*#__PURE__*/_interopDefaultLegacy(orderBy);
|
|
48
|
-
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
49
|
-
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
50
|
-
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
51
48
|
|
|
52
49
|
var routes = PropTypes__default['default'].shape({
|
|
53
50
|
home: PropTypes__default['default'].string.isRequired,
|
|
@@ -58,7 +55,7 @@ var routes = PropTypes__default['default'].shape({
|
|
|
58
55
|
|
|
59
56
|
var styles$d = {"container":"micromag-editor-forms-settings-container","inner":"micromag-editor-forms-settings-inner"};
|
|
60
57
|
|
|
61
|
-
var propTypes$
|
|
58
|
+
var propTypes$j = {
|
|
62
59
|
name: PropTypes__default['default'].string,
|
|
63
60
|
field: core.PropTypes.formField.isRequired,
|
|
64
61
|
value: core.PropTypes.component,
|
|
@@ -67,7 +64,7 @@ var propTypes$k = {
|
|
|
67
64
|
closeFieldForm: PropTypes__default['default'].func.isRequired,
|
|
68
65
|
onChange: PropTypes__default['default'].func
|
|
69
66
|
};
|
|
70
|
-
var defaultProps$
|
|
67
|
+
var defaultProps$j = {
|
|
71
68
|
name: null,
|
|
72
69
|
value: null,
|
|
73
70
|
className: null,
|
|
@@ -116,8 +113,8 @@ var SettingsForm = function SettingsForm(_ref) {
|
|
|
116
113
|
})));
|
|
117
114
|
};
|
|
118
115
|
|
|
119
|
-
SettingsForm.propTypes = propTypes$
|
|
120
|
-
SettingsForm.defaultProps = defaultProps$
|
|
116
|
+
SettingsForm.propTypes = propTypes$j;
|
|
117
|
+
SettingsForm.defaultProps = defaultProps$j;
|
|
121
118
|
|
|
122
119
|
// eslint-disable-next-line import/prefer-default-export
|
|
123
120
|
|
|
@@ -127,10 +124,10 @@ var FormsComponents = /*#__PURE__*/Object.freeze({
|
|
|
127
124
|
});
|
|
128
125
|
|
|
129
126
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
130
|
-
var propTypes$
|
|
127
|
+
var propTypes$i = {
|
|
131
128
|
children: PropTypes__default['default'].node
|
|
132
129
|
};
|
|
133
|
-
var defaultProps$
|
|
130
|
+
var defaultProps$i = {
|
|
134
131
|
children: null
|
|
135
132
|
};
|
|
136
133
|
|
|
@@ -141,8 +138,8 @@ var FormsProvider = function FormsProvider(props) {
|
|
|
141
138
|
}, props));
|
|
142
139
|
};
|
|
143
140
|
|
|
144
|
-
FormsProvider.propTypes = propTypes$
|
|
145
|
-
FormsProvider.defaultProps = defaultProps$
|
|
141
|
+
FormsProvider.propTypes = propTypes$i;
|
|
142
|
+
FormsProvider.defaultProps = defaultProps$i;
|
|
146
143
|
|
|
147
144
|
var useRouteParams = function useRouteParams() {
|
|
148
145
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -232,7 +229,7 @@ var createScreen = function createScreen(definition) {
|
|
|
232
229
|
|
|
233
230
|
var styles$c = {"container":"micromag-editor-buttons-screen-container","button":"micromag-editor-buttons-screen-button","border":"micromag-editor-buttons-screen-border","screen":"micromag-editor-buttons-screen-screen","inner":"micromag-editor-buttons-screen-inner","icon":"micromag-editor-buttons-screen-icon","label":"micromag-editor-buttons-screen-label","active":"micromag-editor-buttons-screen-active"};
|
|
234
231
|
|
|
235
|
-
var propTypes$
|
|
232
|
+
var propTypes$h = {
|
|
236
233
|
active: PropTypes__default['default'].bool,
|
|
237
234
|
id: PropTypes__default['default'].string,
|
|
238
235
|
href: PropTypes__default['default'].string,
|
|
@@ -247,7 +244,7 @@ var propTypes$i = {
|
|
|
247
244
|
}),
|
|
248
245
|
className: PropTypes__default['default'].string
|
|
249
246
|
};
|
|
250
|
-
var defaultProps$
|
|
247
|
+
var defaultProps$h = {
|
|
251
248
|
active: false,
|
|
252
249
|
id: null,
|
|
253
250
|
href: null,
|
|
@@ -296,8 +293,8 @@ var ScreenButton = function ScreenButton(_ref) {
|
|
|
296
293
|
})));
|
|
297
294
|
};
|
|
298
295
|
|
|
299
|
-
ScreenButton.propTypes = propTypes$
|
|
300
|
-
ScreenButton.defaultProps = defaultProps$
|
|
296
|
+
ScreenButton.propTypes = propTypes$h;
|
|
297
|
+
ScreenButton.defaultProps = defaultProps$h;
|
|
301
298
|
var ScreenButton$1 = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
302
299
|
return /*#__PURE__*/React__default['default'].createElement(ScreenButton, Object.assign({}, props, {
|
|
303
300
|
refButton: ref
|
|
@@ -306,7 +303,7 @@ var ScreenButton$1 = /*#__PURE__*/React__default['default'].forwardRef(function
|
|
|
306
303
|
|
|
307
304
|
var styles$b = {"container":"micromag-editor-menus-screens-container","placeholder":"micromag-editor-menus-screens-placeholder","preview":"micromag-editor-menus-screens-preview","screen":"micromag-editor-menus-screens-screen","item":"micromag-editor-menus-screens-item","items":"micromag-editor-menus-screens-items","button":"micromag-editor-menus-screens-button","settings":"micromag-editor-menus-screens-settings","isVertical":"micromag-editor-menus-screens-isVertical","noWrap":"micromag-editor-menus-screens-noWrap","withPlaceholder":"micromag-editor-menus-screens-withPlaceholder"};
|
|
308
305
|
|
|
309
|
-
var propTypes$
|
|
306
|
+
var propTypes$g = {
|
|
310
307
|
items: core.PropTypes.menuItems,
|
|
311
308
|
withPreview: PropTypes__default['default'].bool,
|
|
312
309
|
withPlaceholder: PropTypes__default['default'].bool,
|
|
@@ -322,7 +319,7 @@ var propTypes$h = {
|
|
|
322
319
|
onClickItem: PropTypes__default['default'].func,
|
|
323
320
|
onOrderChange: PropTypes__default['default'].func
|
|
324
321
|
};
|
|
325
|
-
var defaultProps$
|
|
322
|
+
var defaultProps$g = {
|
|
326
323
|
items: [],
|
|
327
324
|
withPreview: false,
|
|
328
325
|
withPlaceholder: false,
|
|
@@ -451,18 +448,18 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
451
448
|
}, itemsElements));
|
|
452
449
|
};
|
|
453
450
|
|
|
454
|
-
ScreensMenu.propTypes = propTypes$
|
|
455
|
-
ScreensMenu.defaultProps = defaultProps$
|
|
451
|
+
ScreensMenu.propTypes = propTypes$g;
|
|
452
|
+
ScreensMenu.defaultProps = defaultProps$g;
|
|
456
453
|
|
|
457
454
|
var styles$a = {"container":"micromag-editor-menus-screen-types-container","row":"micromag-editor-menus-screen-types-row","title":"micromag-editor-menus-screen-types-title"};
|
|
458
455
|
|
|
459
|
-
var propTypes$
|
|
456
|
+
var propTypes$f = {
|
|
460
457
|
screens: core.PropTypes.screenDefinitions,
|
|
461
458
|
selectedTypes: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
462
459
|
className: PropTypes__default['default'].string,
|
|
463
460
|
onClickItem: PropTypes__default['default'].func
|
|
464
461
|
};
|
|
465
|
-
var defaultProps$
|
|
462
|
+
var defaultProps$f = {
|
|
466
463
|
screens: null,
|
|
467
464
|
selectedTypes: null,
|
|
468
465
|
className: null,
|
|
@@ -562,18 +559,18 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
562
559
|
})));
|
|
563
560
|
};
|
|
564
561
|
|
|
565
|
-
ScreenTypes.propTypes = propTypes$
|
|
566
|
-
ScreenTypes.defaultProps = defaultProps$
|
|
562
|
+
ScreenTypes.propTypes = propTypes$f;
|
|
563
|
+
ScreenTypes.defaultProps = defaultProps$f;
|
|
567
564
|
|
|
568
565
|
var styles$9 = {"container":"micromag-editor-modals-screen-types-container","selected":"micromag-editor-modals-screen-types-selected"};
|
|
569
566
|
|
|
570
|
-
var propTypes$
|
|
567
|
+
var propTypes$e = {
|
|
571
568
|
selectedTypes: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
572
569
|
className: PropTypes__default['default'].string,
|
|
573
570
|
onRequestClose: PropTypes__default['default'].func,
|
|
574
571
|
onClickScreenType: PropTypes__default['default'].func
|
|
575
572
|
};
|
|
576
|
-
var defaultProps$
|
|
573
|
+
var defaultProps$e = {
|
|
577
574
|
selectedTypes: null,
|
|
578
575
|
className: null,
|
|
579
576
|
onRequestClose: null,
|
|
@@ -602,12 +599,12 @@ var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
|
602
599
|
})));
|
|
603
600
|
};
|
|
604
601
|
|
|
605
|
-
ScreenTypesModal.propTypes = propTypes$
|
|
606
|
-
ScreenTypesModal.defaultProps = defaultProps$
|
|
602
|
+
ScreenTypesModal.propTypes = propTypes$e;
|
|
603
|
+
ScreenTypesModal.defaultProps = defaultProps$e;
|
|
607
604
|
|
|
608
605
|
var styles$8 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
609
606
|
|
|
610
|
-
var propTypes$
|
|
607
|
+
var propTypes$d = {
|
|
611
608
|
value: PropTypes__default['default'].oneOfType([core.PropTypes.story, core.PropTypes.theme]),
|
|
612
609
|
isTheme: PropTypes__default['default'].bool,
|
|
613
610
|
isVertical: PropTypes__default['default'].bool,
|
|
@@ -617,7 +614,7 @@ var propTypes$e = {
|
|
|
617
614
|
onChange: PropTypes__default['default'].func,
|
|
618
615
|
className: PropTypes__default['default'].string
|
|
619
616
|
};
|
|
620
|
-
var defaultProps$
|
|
617
|
+
var defaultProps$d = {
|
|
621
618
|
value: null,
|
|
622
619
|
isTheme: false,
|
|
623
620
|
isVertical: false,
|
|
@@ -824,15 +821,15 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
824
821
|
}) : null);
|
|
825
822
|
};
|
|
826
823
|
|
|
827
|
-
EditorScreens.propTypes = propTypes$
|
|
828
|
-
EditorScreens.defaultProps = defaultProps$
|
|
824
|
+
EditorScreens.propTypes = propTypes$d;
|
|
825
|
+
EditorScreens.defaultProps = defaultProps$d;
|
|
829
826
|
|
|
830
827
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
831
|
-
var propTypes$
|
|
828
|
+
var propTypes$c = {
|
|
832
829
|
color: PropTypes__default['default'].string,
|
|
833
830
|
className: PropTypes__default['default'].string
|
|
834
831
|
};
|
|
835
|
-
var defaultProps$
|
|
832
|
+
var defaultProps$c = {
|
|
836
833
|
color: 'currentColor',
|
|
837
834
|
className: null
|
|
838
835
|
};
|
|
@@ -857,15 +854,15 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
857
854
|
}));
|
|
858
855
|
};
|
|
859
856
|
|
|
860
|
-
DesktopIcon.propTypes = propTypes$
|
|
861
|
-
DesktopIcon.defaultProps = defaultProps$
|
|
857
|
+
DesktopIcon.propTypes = propTypes$c;
|
|
858
|
+
DesktopIcon.defaultProps = defaultProps$c;
|
|
862
859
|
|
|
863
860
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
864
|
-
var propTypes$
|
|
861
|
+
var propTypes$b = {
|
|
865
862
|
color: PropTypes__default['default'].string,
|
|
866
863
|
className: PropTypes__default['default'].string
|
|
867
864
|
};
|
|
868
|
-
var defaultProps$
|
|
865
|
+
var defaultProps$b = {
|
|
869
866
|
color: 'currentColor',
|
|
870
867
|
className: null
|
|
871
868
|
};
|
|
@@ -890,8 +887,8 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
890
887
|
}));
|
|
891
888
|
};
|
|
892
889
|
|
|
893
|
-
MobileIcon.propTypes = propTypes$
|
|
894
|
-
MobileIcon.defaultProps = defaultProps$
|
|
890
|
+
MobileIcon.propTypes = propTypes$b;
|
|
891
|
+
MobileIcon.defaultProps = defaultProps$b;
|
|
895
892
|
|
|
896
893
|
var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
897
894
|
__proto__: null,
|
|
@@ -901,12 +898,12 @@ var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
|
901
898
|
|
|
902
899
|
var styles$7 = {"container":"micromag-editor-buttons-device-container","icon":"micromag-editor-buttons-device-icon"};
|
|
903
900
|
|
|
904
|
-
var propTypes$
|
|
901
|
+
var propTypes$a = {
|
|
905
902
|
device: PropTypes__default['default'].string.isRequired,
|
|
906
903
|
iconComponents: core.PropTypes.components,
|
|
907
904
|
className: PropTypes__default['default'].string
|
|
908
905
|
};
|
|
909
|
-
var defaultProps$
|
|
906
|
+
var defaultProps$a = {
|
|
910
907
|
iconComponents: DeviceIcons,
|
|
911
908
|
className: null
|
|
912
909
|
};
|
|
@@ -925,17 +922,17 @@ var DeviceButton = function DeviceButton(_ref) {
|
|
|
925
922
|
}));
|
|
926
923
|
};
|
|
927
924
|
|
|
928
|
-
DeviceButton.propTypes = propTypes$
|
|
929
|
-
DeviceButton.defaultProps = defaultProps$
|
|
925
|
+
DeviceButton.propTypes = propTypes$a;
|
|
926
|
+
DeviceButton.defaultProps = defaultProps$a;
|
|
930
927
|
|
|
931
928
|
var styles$6 = {"container":"micromag-editor-menus-devices-container","button":"micromag-editor-menus-devices-button"};
|
|
932
929
|
|
|
933
|
-
var propTypes$
|
|
930
|
+
var propTypes$9 = {
|
|
934
931
|
items: core.PropTypes.menuItems,
|
|
935
932
|
className: PropTypes__default['default'].string,
|
|
936
933
|
onClickItem: PropTypes__default['default'].func
|
|
937
934
|
};
|
|
938
|
-
var defaultProps$
|
|
935
|
+
var defaultProps$9 = {
|
|
939
936
|
items: [],
|
|
940
937
|
className: null,
|
|
941
938
|
onClickItem: null
|
|
@@ -965,12 +962,12 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
965
962
|
});
|
|
966
963
|
};
|
|
967
964
|
|
|
968
|
-
DevicesMenu.propTypes = propTypes$
|
|
969
|
-
DevicesMenu.defaultProps = defaultProps$
|
|
965
|
+
DevicesMenu.propTypes = propTypes$9;
|
|
966
|
+
DevicesMenu.defaultProps = defaultProps$9;
|
|
970
967
|
|
|
971
968
|
var styles$5 = {"container":"micromag-editor-preview-container","noStory":"micromag-editor-preview-noStory","story":"micromag-editor-preview-story","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","screen-medium":"micromag-editor-preview-screen-medium","withoutDevicesSizes":"micromag-editor-preview-withoutDevicesSizes"};
|
|
972
969
|
|
|
973
|
-
var propTypes$
|
|
970
|
+
var propTypes$8 = {
|
|
974
971
|
value: PropTypes__default['default'].oneOfType([core.PropTypes.story, core.PropTypes.theme]),
|
|
975
972
|
devices: core.PropTypes.devices,
|
|
976
973
|
device: PropTypes__default['default'].string,
|
|
@@ -980,7 +977,7 @@ var propTypes$9 = {
|
|
|
980
977
|
onScreenChange: PropTypes__default['default'].func,
|
|
981
978
|
withoutDevicesSizes: PropTypes__default['default'].bool
|
|
982
979
|
};
|
|
983
|
-
var defaultProps$
|
|
980
|
+
var defaultProps$8 = {
|
|
984
981
|
value: null,
|
|
985
982
|
devices: [{
|
|
986
983
|
id: 'mobile',
|
|
@@ -1113,8 +1110,8 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1113
1110
|
}))))));
|
|
1114
1111
|
};
|
|
1115
1112
|
|
|
1116
|
-
EditorPreview.propTypes = propTypes$
|
|
1117
|
-
EditorPreview.defaultProps = defaultProps$
|
|
1113
|
+
EditorPreview.propTypes = propTypes$8;
|
|
1114
|
+
EditorPreview.defaultProps = defaultProps$8;
|
|
1118
1115
|
|
|
1119
1116
|
var deleteScreen = function deleteScreen(story, screenId) {
|
|
1120
1117
|
var _ref = story || {},
|
|
@@ -1181,95 +1178,6 @@ var getFieldByName = function getFieldByName(fields, name) {
|
|
|
1181
1178
|
}, null);
|
|
1182
1179
|
};
|
|
1183
1180
|
|
|
1184
|
-
var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
|
|
1185
|
-
return (isArray__default['default'](path) ? path : [path]).reduce(function (foundField, key) {
|
|
1186
|
-
if (foundField === null) {
|
|
1187
|
-
return null;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
var _foundField$type = foundField.type,
|
|
1191
|
-
type = _foundField$type === void 0 ? null : _foundField$type;
|
|
1192
|
-
|
|
1193
|
-
var _ref = type !== null ? fieldManager.getDefinition(type) : foundField,
|
|
1194
|
-
_ref$fields = _ref.fields,
|
|
1195
|
-
subFields = _ref$fields === void 0 ? null : _ref$fields,
|
|
1196
|
-
_ref$settings = _ref.settings,
|
|
1197
|
-
settings = _ref$settings === void 0 ? null : _ref$settings,
|
|
1198
|
-
_ref$itemsField = _ref.itemsField,
|
|
1199
|
-
itemsField = _ref$itemsField === void 0 ? null : _ref$itemsField;
|
|
1200
|
-
|
|
1201
|
-
if (itemsField !== null && key.match(/^[0-9]+$/)) {
|
|
1202
|
-
return _objectSpread__default['default'](_objectSpread__default['default']({}, itemsField), {}, {
|
|
1203
|
-
name: path.join('/'),
|
|
1204
|
-
listItems: true
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
return getFieldByName([].concat(_toConsumableArray__default['default'](subFields || []), _toConsumableArray__default['default'](settings || [])), key);
|
|
1209
|
-
}, {
|
|
1210
|
-
fields: fields
|
|
1211
|
-
});
|
|
1212
|
-
};
|
|
1213
|
-
|
|
1214
|
-
var getListItemFromScreen = function getListItemFromScreen(fieldParams, screen) {
|
|
1215
|
-
var path = fieldParams.split('/');
|
|
1216
|
-
var listKey = path.filter(function (_, i) {
|
|
1217
|
-
return i < path.length - 1;
|
|
1218
|
-
}).join('.');
|
|
1219
|
-
var itemIndex = path.length > 0 ? parseInt(path[path.length - 1], 10) : null;
|
|
1220
|
-
var list = get__default['default'](screen, listKey, null);
|
|
1221
|
-
var item = list !== null ? list[itemIndex] : null;
|
|
1222
|
-
return {
|
|
1223
|
-
listKey: listKey,
|
|
1224
|
-
itemIndex: itemIndex,
|
|
1225
|
-
list: list,
|
|
1226
|
-
item: item
|
|
1227
|
-
};
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
|
-
var duplicateListItem = function duplicateListItem(fieldParams, story, screenIndex) {
|
|
1231
|
-
var _ref = story || {},
|
|
1232
|
-
_ref$components = _ref.components,
|
|
1233
|
-
screens = _ref$components === void 0 ? [] : _ref$components;
|
|
1234
|
-
|
|
1235
|
-
var screen = screens.length > screenIndex ? screens[screenIndex] : null;
|
|
1236
|
-
|
|
1237
|
-
var _getListItemFromScree = getListItemFromScreen(fieldParams, screen),
|
|
1238
|
-
listKey = _getListItemFromScree.listKey,
|
|
1239
|
-
list = _getListItemFromScree.list,
|
|
1240
|
-
item = _getListItemFromScree.item;
|
|
1241
|
-
|
|
1242
|
-
var newScreen = _objectSpread__default['default'](_objectSpread__default['default']({}, screen), {}, _defineProperty__default['default']({}, listKey, [].concat(_toConsumableArray__default['default'](list), [item])));
|
|
1243
|
-
|
|
1244
|
-
return _objectSpread__default['default'](_objectSpread__default['default']({}, story), {}, {
|
|
1245
|
-
components: screens.map(function (scr, index) {
|
|
1246
|
-
return index === screenIndex ? newScreen : scr;
|
|
1247
|
-
})
|
|
1248
|
-
});
|
|
1249
|
-
};
|
|
1250
|
-
|
|
1251
|
-
var deleteListItem = function deleteListItem(fieldParams, story, screenIndex) {
|
|
1252
|
-
var _ref = story || {},
|
|
1253
|
-
_ref$components = _ref.components,
|
|
1254
|
-
screens = _ref$components === void 0 ? [] : _ref$components;
|
|
1255
|
-
|
|
1256
|
-
var screen = screens.length > screenIndex ? screens[screenIndex] : null;
|
|
1257
|
-
|
|
1258
|
-
var _getListItemFromScree = getListItemFromScreen(fieldParams, screen),
|
|
1259
|
-
listKey = _getListItemFromScree.listKey,
|
|
1260
|
-
list = _getListItemFromScree.list,
|
|
1261
|
-
itemIndex = _getListItemFromScree.itemIndex;
|
|
1262
|
-
|
|
1263
|
-
var newScreen = set__default['default'](_objectSpread__default['default']({}, screen), listKey, list.filter(function (it, index) {
|
|
1264
|
-
return itemIndex !== index;
|
|
1265
|
-
}));
|
|
1266
|
-
return _objectSpread__default['default'](_objectSpread__default['default']({}, story), {}, {
|
|
1267
|
-
components: screens.map(function (scr, index) {
|
|
1268
|
-
return index === screenIndex ? newScreen : scr;
|
|
1269
|
-
})
|
|
1270
|
-
});
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
1181
|
var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
1274
1182
|
var lastPageRef = React.useRef({
|
|
1275
1183
|
url: url,
|
|
@@ -1314,10 +1222,10 @@ var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
|
1314
1222
|
};
|
|
1315
1223
|
};
|
|
1316
1224
|
|
|
1317
|
-
var propTypes$
|
|
1225
|
+
var propTypes$7 = {
|
|
1318
1226
|
className: PropTypes__default['default'].string
|
|
1319
1227
|
};
|
|
1320
|
-
var defaultProps$
|
|
1228
|
+
var defaultProps$7 = {
|
|
1321
1229
|
className: null
|
|
1322
1230
|
};
|
|
1323
1231
|
|
|
@@ -1335,36 +1243,8 @@ var SettingsButton = function SettingsButton(_ref) {
|
|
|
1335
1243
|
}, props));
|
|
1336
1244
|
};
|
|
1337
1245
|
|
|
1338
|
-
SettingsButton.propTypes = propTypes$
|
|
1339
|
-
SettingsButton.defaultProps = defaultProps$
|
|
1340
|
-
|
|
1341
|
-
var propTypes$7 = {
|
|
1342
|
-
className: PropTypes__default['default'].string
|
|
1343
|
-
};
|
|
1344
|
-
var defaultProps$7 = {
|
|
1345
|
-
className: null
|
|
1346
|
-
};
|
|
1347
|
-
|
|
1348
|
-
var DeleteButton = function DeleteButton(_ref) {
|
|
1349
|
-
var className = _ref.className,
|
|
1350
|
-
props = _objectWithoutProperties__default['default'](_ref, ["className"]);
|
|
1351
|
-
|
|
1352
|
-
return /*#__PURE__*/React__default['default'].createElement(components.Button, Object.assign({
|
|
1353
|
-
className: className,
|
|
1354
|
-
theme: "danger",
|
|
1355
|
-
size: "sm",
|
|
1356
|
-
icon: /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
1357
|
-
icon: freeSolidSvgIcons.faTrash
|
|
1358
|
-
})
|
|
1359
|
-
}, props));
|
|
1360
|
-
};
|
|
1361
|
-
|
|
1362
|
-
DeleteButton.propTypes = propTypes$7;
|
|
1363
|
-
DeleteButton.defaultProps = defaultProps$7;
|
|
1364
|
-
|
|
1365
|
-
({
|
|
1366
|
-
className: PropTypes__default['default'].string
|
|
1367
|
-
});
|
|
1246
|
+
SettingsButton.propTypes = propTypes$7;
|
|
1247
|
+
SettingsButton.defaultProps = defaultProps$7;
|
|
1368
1248
|
|
|
1369
1249
|
var styles$4 = {"container":"micromag-editor-menus-breadcrumb-container"};
|
|
1370
1250
|
|
|
@@ -1708,27 +1588,7 @@ var EditForm = function EditForm(_ref) {
|
|
|
1708
1588
|
var screenIndex = screens.findIndex(function (it) {
|
|
1709
1589
|
return it.id === screenId;
|
|
1710
1590
|
});
|
|
1711
|
-
var screen = screenIndex !== -1 ? screens[screenIndex] : null;
|
|
1712
|
-
|
|
1713
|
-
var _ref3 = screen || {},
|
|
1714
|
-
_ref3$type = _ref3.type,
|
|
1715
|
-
type = _ref3$type === void 0 ? null : _ref3$type;
|
|
1716
|
-
|
|
1717
|
-
var screensManager = contexts.useScreensManager();
|
|
1718
|
-
var fieldsManager = contexts.useFieldsManager();
|
|
1719
|
-
|
|
1720
|
-
var _ref4 = type !== null ? screensManager.getDefinition(type) : {},
|
|
1721
|
-
_ref4$fields = _ref4.fields,
|
|
1722
|
-
fields = _ref4$fields === void 0 ? [] : _ref4$fields;
|
|
1723
|
-
|
|
1724
|
-
var currentField = React.useMemo(function () {
|
|
1725
|
-
return fieldParams !== null ? getFieldFromPath(fieldParams.split('/'), fields, fieldsManager) : null;
|
|
1726
|
-
}, [fieldParams, fields]);
|
|
1727
|
-
|
|
1728
|
-
var _ref5 = currentField || {},
|
|
1729
|
-
_ref5$listItems = _ref5.listItems,
|
|
1730
|
-
currentFieldListItems = _ref5$listItems === void 0 ? false : _ref5$listItems; // Get transition value
|
|
1731
|
-
|
|
1591
|
+
var screen = screenIndex !== -1 ? screens[screenIndex] : null; // Get transition value
|
|
1732
1592
|
|
|
1733
1593
|
var _useFormTransition = useFormTransition(url, screenIndex, styles$1),
|
|
1734
1594
|
transitionName = _useFormTransition.name,
|
|
@@ -1813,21 +1673,6 @@ var EditForm = function EditForm(_ref) {
|
|
|
1813
1673
|
var onDeleteScreenCancel = React.useCallback(function () {
|
|
1814
1674
|
setDeleteScreenModalOpened(false);
|
|
1815
1675
|
}, [setDeleteScreenModalOpened]);
|
|
1816
|
-
/* List item */
|
|
1817
|
-
|
|
1818
|
-
var onDeleteItemClick = React.useCallback(function () {
|
|
1819
|
-
triggerOnChange(deleteListItem(fieldParams, value, screenIndex));
|
|
1820
|
-
gotoFieldForm();
|
|
1821
|
-
}, [fieldParams, value, screenIndex]); // eslint-disable-next-line no-unused-vars
|
|
1822
|
-
|
|
1823
|
-
React.useCallback(function () {
|
|
1824
|
-
var path = fieldParams.split('/');
|
|
1825
|
-
var listKey = path.length ? path[0] : null;
|
|
1826
|
-
var field = typeof screen[listKey] !== 'undefined' ? screen[listKey] : null;
|
|
1827
|
-
var fieldItemsCount = field !== null ? field.length : 0;
|
|
1828
|
-
triggerOnChange(duplicateListItem(fieldParams, value, screenIndex));
|
|
1829
|
-
gotoFieldForm("".concat(listKey, ".").concat(fieldItemsCount));
|
|
1830
|
-
}, [fieldParams, screen, value, screenIndex]);
|
|
1831
1676
|
var dropdownItems = [!isTheme ? {
|
|
1832
1677
|
id: 'duplicate',
|
|
1833
1678
|
type: 'button',
|
|
@@ -1897,19 +1742,7 @@ var EditForm = function EditForm(_ref) {
|
|
|
1897
1742
|
closeFieldForm: closeFieldForm,
|
|
1898
1743
|
fieldContext: fieldContext,
|
|
1899
1744
|
onChange: onScreenFormChange
|
|
1900
|
-
})
|
|
1901
|
-
className: "m-2"
|
|
1902
|
-
}, /*#__PURE__*/React__default['default'].createElement("hr", null), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1903
|
-
className: "text-right"
|
|
1904
|
-
}, /*#__PURE__*/React__default['default'].createElement(DeleteButton, {
|
|
1905
|
-
onClick: onDeleteItemClick
|
|
1906
|
-
}, /*#__PURE__*/React__default['default'].createElement(reactIntl.FormattedMessage, {
|
|
1907
|
-
id: "CQ7Wmr",
|
|
1908
|
-
defaultMessage: [{
|
|
1909
|
-
"type": 0,
|
|
1910
|
-
"value": "Delete item"
|
|
1911
|
-
}]
|
|
1912
|
-
})))) : null)) : /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1745
|
+
}))) : /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1913
1746
|
className: classNames__default['default'](['w-100', styles$1.panel]),
|
|
1914
1747
|
key: "screen-".concat(screen.id)
|
|
1915
1748
|
}, /*#__PURE__*/React__default['default'].createElement(contexts.ScreenProvider, {
|
|
@@ -2190,7 +2023,9 @@ var EditorContainer = function EditorContainer(_ref) {
|
|
|
2190
2023
|
var Router = memoryRouter ? reactRouter.MemoryRouter : reactRouterDom.BrowserRouter;
|
|
2191
2024
|
|
|
2192
2025
|
var _useIntl = reactIntl.useIntl(),
|
|
2193
|
-
locale = _useIntl.locale;
|
|
2026
|
+
locale = _useIntl.locale; // const { metadata } = value || {};
|
|
2027
|
+
// const { language:finalLocale = locale } = metadata || {};
|
|
2028
|
+
|
|
2194
2029
|
|
|
2195
2030
|
return /*#__PURE__*/React__default['default'].createElement(Router, {
|
|
2196
2031
|
basename: !memoryRouter ? basePath : null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.302",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
56
56
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
57
57
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
58
|
-
"@micromag/core": "^0.2.
|
|
59
|
-
"@micromag/elements": "^0.2.
|
|
60
|
-
"@micromag/fields": "^0.2.
|
|
61
|
-
"@micromag/screens": "^0.2.
|
|
62
|
-
"@micromag/viewer": "^0.2.
|
|
58
|
+
"@micromag/core": "^0.2.301",
|
|
59
|
+
"@micromag/elements": "^0.2.301",
|
|
60
|
+
"@micromag/fields": "^0.2.302",
|
|
61
|
+
"@micromag/screens": "^0.2.302",
|
|
62
|
+
"@micromag/viewer": "^0.2.302",
|
|
63
63
|
"classnames": "^2.2.6",
|
|
64
64
|
"lodash": "^4.17.20",
|
|
65
65
|
"prop-types": "^15.7.2",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "fadee1a6c357d259ca3d95ff89283c8813e08ded"
|
|
78
78
|
}
|