@micromag/editor 0.2.408 → 0.2.412
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 +12 -10
- package/es/index.js +2473 -1251
- package/lib/index.js +2488 -1265
- package/package.json +10 -7
package/es/index.js
CHANGED
|
@@ -1,129 +1,39 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import
|
|
3
|
-
import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { useRouteMatch, Route, useHistory, MemoryRouter } from 'react-router';
|
|
6
|
-
import { BrowserRouter } from 'react-router-dom';
|
|
7
|
-
import { useIntl, FormattedMessage } from 'react-intl';
|
|
8
|
-
import { useFieldsManager, useFieldComponent, ComponentsProvider, FORMS_NAMESPACE, useRoutes, useScreensManager, useRoutePush, useUrlGenerator, useScreenSize, useScreenDefinition, useFormsComponents, ScreenProvider, ModalsProvider, PanelsProvider, ScreenSizeProvider, UppyProvider, StoryProvider, GoogleKeysProvider, GoogleMapsClientProvider, FontsProvider, EditorProvider, ComponentsContext, RoutesProvider } from '@micromag/core/contexts';
|
|
9
|
-
import { isMessage, getComponentFromName, getScreenExtraField, slug, getDeviceScreens } from '@micromag/core/utils';
|
|
10
|
-
import { ScreensProvider } from '@micromag/screens';
|
|
11
|
-
import { Fields, FieldsProvider } from '@micromag/fields';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
12
4
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
13
|
-
import
|
|
5
|
+
import { Button, BackButton, Breadcrumb as Breadcrumb$1, FieldForm, Modal, ModalDialog, Label, Navbar, DropdownMenu, Empty, Tabs, ScreenPreview, ScreenPlaceholder, Modals } from '@micromag/core/components';
|
|
6
|
+
import { useRoutes, useScreensManager, useFieldsManager, useScreenDefinition, useFormsComponents, useRoutePush, ScreenProvider, useScreenSize, useUrlGenerator, ModalsProvider, PanelsProvider, ScreenSizeProvider, useFieldComponent, ComponentsProvider, FORMS_NAMESPACE, UppyProvider, StoryProvider, GoogleKeysProvider, GoogleMapsClientProvider, FontsProvider, EditorProvider, ComponentsContext, RoutesProvider } from '@micromag/core/contexts';
|
|
7
|
+
import { useParsedStory, useResizeObserver, useScreenSizeFromElement, useMediasParser } from '@micromag/core/hooks';
|
|
8
|
+
import { getScreenExtraField, isMessage, slug, getComponentFromName, getDeviceScreens } from '@micromag/core/utils';
|
|
14
9
|
import classNames from 'classnames';
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import React, { useMemo, useRef, useCallback, useState, forwardRef, useEffect } from 'react';
|
|
12
|
+
import { useIntl, FormattedMessage } from 'react-intl';
|
|
13
|
+
import { useRouteMatch, useHistory, Route, MemoryRouter } from 'react-router';
|
|
14
|
+
import { CSSTransitionGroup } from 'react-transition-group';
|
|
15
|
+
import { v1 } from 'uuid';
|
|
16
|
+
import isString from 'lodash/isString';
|
|
17
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
18
18
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
19
|
+
import 'lodash/isArray';
|
|
20
|
+
import 'lodash/get';
|
|
21
|
+
import 'lodash/set';
|
|
19
22
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import { v1 } from 'uuid';
|
|
23
|
+
import { faCogs, faGripLines, faTimes, faAngleDown, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
24
|
+
import { Fields, FieldsProvider } from '@micromag/fields';
|
|
23
25
|
import { getSizeWithinBounds } from '@folklore/size';
|
|
24
|
-
import {
|
|
26
|
+
import { Viewer } from '@micromag/viewer';
|
|
25
27
|
import isFunction from 'lodash/isFunction';
|
|
28
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
29
|
+
import { KeyboardCode, closestCorners, getFirstCollision, getClientRect, MeasuringStrategy, defaultDropAnimation, useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, DragOverlay } from '@dnd-kit/core';
|
|
30
|
+
import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
31
|
+
import { createPortal } from 'react-dom';
|
|
32
|
+
import _createForOfIteratorHelper from '@babel/runtime/helpers/createForOfIteratorHelper';
|
|
33
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
26
34
|
import orderBy from 'lodash/orderBy';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import 'lodash/isArray';
|
|
30
|
-
import 'lodash/get';
|
|
31
|
-
import 'lodash/set';
|
|
32
|
-
|
|
33
|
-
var routes = PropTypes.shape({
|
|
34
|
-
home: PropTypes.string.isRequired,
|
|
35
|
-
screen: PropTypes.string.isRequired,
|
|
36
|
-
'screen.field': PropTypes.string.isRequired,
|
|
37
|
-
'screen.field.form': PropTypes.string.isRequired
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
var styles$d = {"container":"micromag-editor-forms-settings-container","inner":"micromag-editor-forms-settings-inner"};
|
|
41
|
-
|
|
42
|
-
var propTypes$j = {
|
|
43
|
-
name: PropTypes.string,
|
|
44
|
-
field: PropTypes$1.formField.isRequired,
|
|
45
|
-
value: PropTypes$1.component,
|
|
46
|
-
className: PropTypes.string,
|
|
47
|
-
gotoFieldForm: PropTypes.func.isRequired,
|
|
48
|
-
closeFieldForm: PropTypes.func.isRequired,
|
|
49
|
-
onChange: PropTypes.func
|
|
50
|
-
};
|
|
51
|
-
var defaultProps$j = {
|
|
52
|
-
name: null,
|
|
53
|
-
value: null,
|
|
54
|
-
className: null,
|
|
55
|
-
onChange: null
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
var SettingsForm = function SettingsForm(_ref) {
|
|
59
|
-
var name = _ref.name,
|
|
60
|
-
field = _ref.field,
|
|
61
|
-
value = _ref.value,
|
|
62
|
-
className = _ref.className,
|
|
63
|
-
gotoFieldForm = _ref.gotoFieldForm,
|
|
64
|
-
closeFieldForm = _ref.closeFieldForm,
|
|
65
|
-
onChange = _ref.onChange;
|
|
66
|
-
var _field$type = field.type,
|
|
67
|
-
type = _field$type === void 0 ? null : _field$type;
|
|
68
|
-
var fieldsManager = useFieldsManager();
|
|
69
|
-
|
|
70
|
-
var _ref2 = type !== null ? fieldsManager.getDefinition(type) : field,
|
|
71
|
-
_ref2$component = _ref2.component,
|
|
72
|
-
fieldComponent = _ref2$component === void 0 ? null : _ref2$component,
|
|
73
|
-
settings = _ref2.settings;
|
|
74
|
-
|
|
75
|
-
var FieldComponent = useFieldComponent(fieldComponent);
|
|
76
|
-
var FieldsComponent = useFieldComponent('fields');
|
|
77
|
-
var SettingsComponent = FieldComponent !== null ? FieldComponent.settingsComponent || FieldsComponent : FieldsComponent;
|
|
78
|
-
var onSettingsChange = useCallback(function (newSettingsValue) {
|
|
79
|
-
var newValue = _objectSpread(_objectSpread({}, value), newSettingsValue);
|
|
80
|
-
|
|
81
|
-
if (onChange !== null) {
|
|
82
|
-
onChange(newValue);
|
|
83
|
-
}
|
|
84
|
-
}, [value, onChange]);
|
|
85
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
86
|
-
className: classNames([styles$d.container, _defineProperty({}, className, className)])
|
|
87
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
88
|
-
className: styles$d.inner
|
|
89
|
-
}, /*#__PURE__*/React.createElement(SettingsComponent, {
|
|
90
|
-
name: name,
|
|
91
|
-
field: field,
|
|
92
|
-
fields: settings,
|
|
93
|
-
value: value,
|
|
94
|
-
onChange: onSettingsChange,
|
|
95
|
-
gotoFieldForm: gotoFieldForm,
|
|
96
|
-
closeFieldForm: closeFieldForm
|
|
97
|
-
})));
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
SettingsForm.propTypes = propTypes$j;
|
|
101
|
-
SettingsForm.defaultProps = defaultProps$j;
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
104
|
-
|
|
105
|
-
var FormsComponents = /*#__PURE__*/Object.freeze({
|
|
106
|
-
__proto__: null,
|
|
107
|
-
Settings: SettingsForm
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
111
|
-
var propTypes$i = {
|
|
112
|
-
children: PropTypes.node
|
|
113
|
-
};
|
|
114
|
-
var defaultProps$i = {
|
|
115
|
-
children: null
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
var FormsProvider = function FormsProvider(props) {
|
|
119
|
-
return /*#__PURE__*/React.createElement(ComponentsProvider, Object.assign({
|
|
120
|
-
namespace: FORMS_NAMESPACE,
|
|
121
|
-
components: FormsComponents
|
|
122
|
-
}, props));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
FormsProvider.propTypes = propTypes$i;
|
|
126
|
-
FormsProvider.defaultProps = defaultProps$i;
|
|
35
|
+
import { ScreensProvider } from '@micromag/screens';
|
|
36
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
127
37
|
|
|
128
38
|
var useRouteParams = function useRouteParams() {
|
|
129
39
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -161,25 +71,7 @@ var useRouteParams = function useRouteParams() {
|
|
|
161
71
|
return routeParams;
|
|
162
72
|
};
|
|
163
73
|
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
var useThemeValue = function useThemeValue(value) {
|
|
167
|
-
var isTheme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
168
|
-
var valueWithTheme = useMemo(function () {
|
|
169
|
-
if (!isTheme) {
|
|
170
|
-
return value;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
var _ref = value || {};
|
|
174
|
-
_ref.components;
|
|
175
|
-
var themeValue = _objectWithoutProperties(_ref, _excluded$8);
|
|
176
|
-
|
|
177
|
-
return value !== null ? _objectSpread({
|
|
178
|
-
theme: themeValue
|
|
179
|
-
}, value) : value;
|
|
180
|
-
}, [value, isTheme]);
|
|
181
|
-
return valueWithTheme;
|
|
182
|
-
};
|
|
74
|
+
var styles$f = {"container":"micromag-editor-container","left":"micromag-editor-left","right":"micromag-editor-right","center":"micromag-editor-center","fullscreen":"micromag-editor-fullscreen","preview":"micromag-editor-preview","inner":"micromag-editor-inner","visible":"micromag-editor-visible","screen-medium":"micromag-editor-screen-medium","top":"micromag-editor-top"};
|
|
183
75
|
|
|
184
76
|
var createScreen = function createScreen(definition) {
|
|
185
77
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -213,614 +105,700 @@ var createScreen = function createScreen(definition) {
|
|
|
213
105
|
});
|
|
214
106
|
};
|
|
215
107
|
|
|
216
|
-
var
|
|
108
|
+
var _excluded$b = ["components"];
|
|
217
109
|
|
|
218
|
-
var
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
icon: PropTypes.node,
|
|
224
|
-
title: PropTypes.string,
|
|
225
|
-
onClick: PropTypes.func,
|
|
226
|
-
children: PropTypes.node,
|
|
227
|
-
refButton: PropTypes.shape({
|
|
228
|
-
current: PropTypes.any // eslint-disable-line
|
|
110
|
+
var deleteScreen = function deleteScreen(story, screenId) {
|
|
111
|
+
var _ref = story || {},
|
|
112
|
+
_ref$components = _ref.components,
|
|
113
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
114
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$b);
|
|
229
115
|
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
href: null,
|
|
237
|
-
label: null,
|
|
238
|
-
icon: null,
|
|
239
|
-
title: null,
|
|
240
|
-
onClick: null,
|
|
241
|
-
children: null,
|
|
242
|
-
refButton: null,
|
|
243
|
-
className: null
|
|
116
|
+
return _objectSpread(_objectSpread({}, currentValue), {}, {
|
|
117
|
+
components: components.filter(function (_ref2) {
|
|
118
|
+
var id = _ref2.id;
|
|
119
|
+
return id !== screenId;
|
|
120
|
+
})
|
|
121
|
+
});
|
|
244
122
|
};
|
|
245
123
|
|
|
246
|
-
var
|
|
247
|
-
var _ref2;
|
|
124
|
+
var _excluded$a = ["components"];
|
|
248
125
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}, children !== null ? children : /*#__PURE__*/React.createElement("div", {
|
|
264
|
-
className: styles$c.inner
|
|
265
|
-
}, icon !== null ? /*#__PURE__*/React.createElement("div", {
|
|
266
|
-
className: styles$c.icon
|
|
267
|
-
}, icon) : null, label !== null ? /*#__PURE__*/React.createElement("div", {
|
|
268
|
-
className: styles$c.label
|
|
269
|
-
}, label) : null)), /*#__PURE__*/React.createElement(Button, {
|
|
270
|
-
className: styles$c.button,
|
|
271
|
-
withoutStyle: true,
|
|
272
|
-
id: id,
|
|
273
|
-
href: href,
|
|
274
|
-
title: title,
|
|
275
|
-
onClick: onClick,
|
|
276
|
-
refButton: refButton
|
|
277
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
278
|
-
className: classNames([styles$c.border, 'rounded'])
|
|
279
|
-
})));
|
|
126
|
+
var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
127
|
+
var _ref = story || {},
|
|
128
|
+
_ref$components = _ref.components,
|
|
129
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
130
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$a);
|
|
131
|
+
|
|
132
|
+
var screen = components.find(function (it) {
|
|
133
|
+
return it.id === screenId;
|
|
134
|
+
}) || null;
|
|
135
|
+
return _objectSpread(_objectSpread({}, currentValue), {}, {
|
|
136
|
+
components: screen !== null ? [].concat(_toConsumableArray(components), [_objectSpread(_objectSpread({}, screen), {}, {
|
|
137
|
+
id: v1()
|
|
138
|
+
})]) : components
|
|
139
|
+
});
|
|
280
140
|
};
|
|
281
141
|
|
|
282
|
-
|
|
283
|
-
ScreenButton.defaultProps = defaultProps$h;
|
|
284
|
-
var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
285
|
-
return /*#__PURE__*/React.createElement(ScreenButton, Object.assign({}, props, {
|
|
286
|
-
refButton: ref
|
|
287
|
-
}));
|
|
288
|
-
});
|
|
142
|
+
var _excluded$9 = ["components"];
|
|
289
143
|
|
|
290
|
-
var
|
|
144
|
+
var updateScreen = function updateScreen(story, newScreenValue) {
|
|
145
|
+
var newScreenId = newScreenValue.id;
|
|
291
146
|
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
withPlaceholder: PropTypes.bool,
|
|
297
|
-
settings: PropTypes.node,
|
|
298
|
-
previewMinWidth: PropTypes.number,
|
|
299
|
-
sortable: PropTypes.bool,
|
|
300
|
-
isVertical: PropTypes.bool,
|
|
301
|
-
noWrap: PropTypes.bool,
|
|
302
|
-
className: PropTypes.string,
|
|
303
|
-
itemClassName: PropTypes.string,
|
|
304
|
-
buttonClassName: PropTypes.string,
|
|
305
|
-
settingsClassName: PropTypes.string,
|
|
306
|
-
onClickItem: PropTypes.func,
|
|
307
|
-
onOrderChange: PropTypes.func
|
|
308
|
-
};
|
|
309
|
-
var defaultProps$g = {
|
|
310
|
-
items: [],
|
|
311
|
-
withPreview: false,
|
|
312
|
-
withPlaceholder: false,
|
|
313
|
-
settings: null,
|
|
314
|
-
previewMinWidth: 320,
|
|
315
|
-
sortable: false,
|
|
316
|
-
isVertical: false,
|
|
317
|
-
noWrap: false,
|
|
318
|
-
className: null,
|
|
319
|
-
itemClassName: null,
|
|
320
|
-
buttonClassName: null,
|
|
321
|
-
settingsClassName: null,
|
|
322
|
-
onClickItem: null,
|
|
323
|
-
onOrderChange: null
|
|
324
|
-
};
|
|
147
|
+
var _ref = story || {},
|
|
148
|
+
_ref$components = _ref.components,
|
|
149
|
+
components = _ref$components === void 0 ? [] : _ref$components,
|
|
150
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$9);
|
|
325
151
|
|
|
326
|
-
var
|
|
327
|
-
|
|
152
|
+
var index = components.findIndex(function (it) {
|
|
153
|
+
return it.id === newScreenId;
|
|
154
|
+
});
|
|
155
|
+
return _objectSpread(_objectSpread({}, currentValue), {}, {
|
|
156
|
+
components: [].concat(_toConsumableArray(components.slice(0, index)), [_objectSpread(_objectSpread({}, components[index]), newScreenValue)], _toConsumableArray(components.slice(index + 1)))
|
|
157
|
+
});
|
|
158
|
+
};
|
|
328
159
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
isVertical = _ref.isVertical,
|
|
335
|
-
noWrap = _ref.noWrap,
|
|
336
|
-
className = _ref.className,
|
|
337
|
-
itemClassName = _ref.itemClassName,
|
|
338
|
-
buttonClassName = _ref.buttonClassName,
|
|
339
|
-
settingsClassName = _ref.settingsClassName,
|
|
340
|
-
sortable = _ref.sortable,
|
|
341
|
-
onClickItem = _ref.onClickItem,
|
|
342
|
-
onOrderChange = _ref.onOrderChange;
|
|
343
|
-
var intl = useIntl();
|
|
160
|
+
var getFieldByName = function getFieldByName(fields, name) {
|
|
161
|
+
return fields.reduce(function (foundField, it) {
|
|
162
|
+
if (foundField !== null) {
|
|
163
|
+
return foundField;
|
|
164
|
+
}
|
|
344
165
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
166
|
+
var _it$name = it.name,
|
|
167
|
+
fieldName = _it$name === void 0 ? null : _it$name,
|
|
168
|
+
_it$fields = it.fields,
|
|
169
|
+
subFields = _it$fields === void 0 ? [] : _it$fields;
|
|
348
170
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
itemWidth = _ref2$width === void 0 ? 0 : _ref2$width,
|
|
353
|
-
_ref2$height = _ref2.height,
|
|
354
|
-
itemHeight = _ref2$height === void 0 ? 0 : _ref2$height;
|
|
171
|
+
if (name !== null && fieldName === name) {
|
|
172
|
+
return it;
|
|
173
|
+
}
|
|
355
174
|
|
|
356
|
-
|
|
175
|
+
return getFieldByName(subFields, name);
|
|
176
|
+
}, null);
|
|
177
|
+
};
|
|
357
178
|
|
|
358
|
-
|
|
359
|
-
|
|
179
|
+
var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
180
|
+
var lastPageRef = useRef({
|
|
181
|
+
url: url,
|
|
182
|
+
screenIndex: screenIndex
|
|
183
|
+
});
|
|
184
|
+
var direction = useMemo(function () {
|
|
185
|
+
var _lastPageRef$current = lastPageRef.current,
|
|
186
|
+
lastScreenIndex = _lastPageRef$current.screenIndex,
|
|
187
|
+
lastUrl = _lastPageRef$current.url;
|
|
188
|
+
lastPageRef.current.url = url;
|
|
189
|
+
lastPageRef.current.screenIndex = screenIndex;
|
|
190
|
+
|
|
191
|
+
if (screenIndex !== lastScreenIndex) {
|
|
192
|
+
// return screenIndex > lastScreenIndex ? 'bottom' : 'top';
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var urlSplit = url.split('/');
|
|
197
|
+
var lastUrlSplit = lastUrl.split('/');
|
|
198
|
+
var currentPartsCount = urlSplit.length;
|
|
199
|
+
var previousPartsCount = lastUrlSplit.length;
|
|
200
|
+
var isSettings = urlSplit[currentPartsCount - 1] === 'settings';
|
|
201
|
+
var wasSettings = lastUrlSplit[previousPartsCount - 1] === 'settings';
|
|
202
|
+
currentPartsCount -= isSettings ? 1 : 0;
|
|
203
|
+
previousPartsCount -= wasSettings ? 1 : 0;
|
|
204
|
+
return currentPartsCount >= previousPartsCount ? 'right' : 'left';
|
|
205
|
+
}, [url, screenIndex]);
|
|
206
|
+
var name = useMemo(function () {
|
|
207
|
+
var _classNames, _classNames2, _classNames3;
|
|
360
208
|
|
|
361
209
|
return {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
210
|
+
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',
|
|
211
|
+
enterActive: classNames((_classNames2 = {}, _defineProperty(_classNames2, styles.enterActiveHorizontal, direction === 'left' || direction === 'right'), _defineProperty(_classNames2, styles.enterActiveVertical, direction === 'top' || direction === 'bottom'), _classNames2)) || 'none',
|
|
212
|
+
leave: styles.leave || 'none',
|
|
213
|
+
leaveActive: classNames((_classNames3 = {}, _defineProperty(_classNames3, styles.leaveActiveRight, direction === 'right'), _defineProperty(_classNames3, styles.leaveActiveLeft, direction === 'left'), _defineProperty(_classNames3, styles.leaveActiveTop, direction === 'top'), _defineProperty(_classNames3, styles.leaveActiveBottom, direction === 'bottom'), _classNames3)) || 'none'
|
|
365
214
|
};
|
|
366
|
-
}, [
|
|
367
|
-
|
|
368
|
-
|
|
215
|
+
}, [direction, screenIndex]);
|
|
216
|
+
return {
|
|
217
|
+
direction: direction,
|
|
218
|
+
name: name,
|
|
219
|
+
timeout: direction === 'left' || direction === 'right' ? 300 : 10
|
|
220
|
+
};
|
|
221
|
+
};
|
|
369
222
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
223
|
+
var _excluded$8 = ["className"];
|
|
224
|
+
var propTypes$n = {
|
|
225
|
+
className: PropTypes.string
|
|
226
|
+
};
|
|
227
|
+
var defaultProps$n = {
|
|
228
|
+
className: null
|
|
229
|
+
};
|
|
377
230
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"data-screen-id": item.id,
|
|
382
|
-
ref: index === 0 ? containerRef : null
|
|
383
|
-
}, /*#__PURE__*/React.createElement(ScreenButton$1, Object.assign({}, item, {
|
|
384
|
-
className: classNames([styles$b.button, _defineProperty({}, buttonClassName, buttonClassName !== null)]),
|
|
385
|
-
title: isMessage(title) ? intl.formatMessage(title) : null,
|
|
386
|
-
onClick: function onClick() {
|
|
387
|
-
if (_onClick !== null) {
|
|
388
|
-
_onClick(screen, index);
|
|
389
|
-
}
|
|
231
|
+
var SettingsButton = function SettingsButton(_ref) {
|
|
232
|
+
var className = _ref.className,
|
|
233
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
390
234
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
screen: screen,
|
|
400
|
-
width: previewStyle.width,
|
|
401
|
-
height: previewStyle.height,
|
|
402
|
-
className: styles$b.screen
|
|
403
|
-
})) : null, withPlaceholder ? /*#__PURE__*/React.createElement("div", {
|
|
404
|
-
className: styles$b.placeholder,
|
|
405
|
-
style: previewStyle
|
|
406
|
-
}, /*#__PURE__*/React.createElement(ScreenPlaceholder, {
|
|
407
|
-
screen: item,
|
|
408
|
-
width: previewStyle.width,
|
|
409
|
-
height: previewStyle.height,
|
|
410
|
-
className: styles$b.screen
|
|
411
|
-
})) : null), settings !== null ? /*#__PURE__*/React.createElement("div", {
|
|
412
|
-
className: classNames([_defineProperty({}, settingsClassName, settingsClassName !== null), styles$b.settings, 'p-2'])
|
|
413
|
-
}, isFunction(settings) ? settings(index) : settings) : null);
|
|
414
|
-
});
|
|
415
|
-
var sortableItems = useMemo(function () {
|
|
416
|
-
return items.map(function (_ref7) {
|
|
417
|
-
var id = _ref7.id;
|
|
418
|
-
return {
|
|
419
|
-
id: id
|
|
420
|
-
};
|
|
421
|
-
});
|
|
422
|
-
}, [items]);
|
|
423
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
424
|
-
className: classNames([styles$b.container, (_ref8 = {}, _defineProperty(_ref8, styles$b.noWrap, noWrap), _defineProperty(_ref8, styles$b.isVertical, isVertical), _defineProperty(_ref8, styles$b.withPlaceholder, withPlaceholder), _defineProperty(_ref8, className, className), _ref8)])
|
|
425
|
-
}, sortable && items.length > 1 ? /*#__PURE__*/React.createElement(ReactSortable, {
|
|
426
|
-
list: sortableItems,
|
|
427
|
-
setList: onOrderChange,
|
|
428
|
-
animation: 200,
|
|
429
|
-
delayOnTouchStart: true,
|
|
430
|
-
delay: 2,
|
|
431
|
-
tag: "ul",
|
|
432
|
-
className: styles$b.items
|
|
433
|
-
}, itemsElements) : /*#__PURE__*/React.createElement("ul", {
|
|
434
|
-
className: styles$b.items
|
|
435
|
-
}, itemsElements));
|
|
235
|
+
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
236
|
+
className: className,
|
|
237
|
+
theme: "secondary",
|
|
238
|
+
size: "sm",
|
|
239
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
240
|
+
icon: faCogs
|
|
241
|
+
})
|
|
242
|
+
}, props));
|
|
436
243
|
};
|
|
437
244
|
|
|
438
|
-
|
|
439
|
-
|
|
245
|
+
SettingsButton.propTypes = propTypes$n;
|
|
246
|
+
SettingsButton.defaultProps = defaultProps$n;
|
|
440
247
|
|
|
441
|
-
var styles$
|
|
248
|
+
var styles$e = {"container":"micromag-editor-menus-breadcrumb-container"};
|
|
442
249
|
|
|
443
|
-
var propTypes$
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
250
|
+
var propTypes$m = {
|
|
251
|
+
story: PropTypes$1.story,
|
|
252
|
+
screenId: PropTypes.string,
|
|
253
|
+
field: PropTypes.string,
|
|
254
|
+
form: PropTypes.string,
|
|
255
|
+
url: PropTypes.string.isRequired,
|
|
256
|
+
className: PropTypes.string
|
|
448
257
|
};
|
|
449
|
-
var defaultProps$
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
258
|
+
var defaultProps$m = {
|
|
259
|
+
story: null,
|
|
260
|
+
screenId: null,
|
|
261
|
+
field: null,
|
|
262
|
+
form: null,
|
|
263
|
+
className: null
|
|
454
264
|
};
|
|
455
265
|
|
|
456
|
-
var
|
|
457
|
-
var
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
266
|
+
var Breadcrumb = function Breadcrumb(_ref) {
|
|
267
|
+
var story = _ref.story,
|
|
268
|
+
screenId = _ref.screenId,
|
|
269
|
+
field = _ref.field,
|
|
270
|
+
form = _ref.form,
|
|
271
|
+
url = _ref.url,
|
|
272
|
+
className = _ref.className;
|
|
461
273
|
var intl = useIntl();
|
|
274
|
+
|
|
275
|
+
var _ref2 = story || {},
|
|
276
|
+
_ref2$components = _ref2.components,
|
|
277
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
278
|
+
|
|
279
|
+
var history = useHistory();
|
|
462
280
|
var screensManager = useScreensManager();
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
_definition$group = definition.group,
|
|
469
|
-
group = _definition$group === void 0 ? {} : _definition$group;
|
|
281
|
+
var fieldsManager = useFieldsManager();
|
|
282
|
+
var items = useMemo(function () {
|
|
283
|
+
var screenIndex = screens.findIndex(function (it) {
|
|
284
|
+
return it.id === screenId;
|
|
285
|
+
});
|
|
470
286
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
_ref2$label = _ref2.label,
|
|
475
|
-
label = _ref2$label === void 0 ? {} : _ref2$label,
|
|
476
|
-
_ref2$hidden = _ref2.hidden,
|
|
477
|
-
hidden = _ref2$hidden === void 0 ? false : _ref2$hidden;
|
|
287
|
+
if (!screens[screenIndex]) {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
478
290
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
messageId = _ref3$id === void 0 ? null : _ref3$id;
|
|
291
|
+
var type = screens[screenIndex].type;
|
|
292
|
+
var fieldItems = [];
|
|
482
293
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
294
|
+
if (field !== null) {
|
|
295
|
+
var _screensManager$getDe = screensManager.getDefinition(type),
|
|
296
|
+
_screensManager$getDe2 = _screensManager$getDe.fields,
|
|
297
|
+
screenFields = _screensManager$getDe2 === void 0 ? [] : _screensManager$getDe2;
|
|
298
|
+
|
|
299
|
+
var fields = [].concat(_toConsumableArray(screenFields), [getScreenExtraField(intl)]);
|
|
300
|
+
var fieldPath = field.split('/');
|
|
301
|
+
var lastKeyIndex = fieldPath.length - 1;
|
|
302
|
+
var parentItem = null;
|
|
303
|
+
fieldPath.reduce(function (currentFields, key, keyIndex) {
|
|
304
|
+
var _currentFields$type = currentFields.type,
|
|
305
|
+
fieldType = _currentFields$type === void 0 ? null : _currentFields$type;
|
|
306
|
+
var fieldsDef = fieldType !== null ? fieldsManager.getDefinition(fieldType) : currentFields;
|
|
307
|
+
var _fieldsDef$fields = fieldsDef.fields,
|
|
308
|
+
subFields = _fieldsDef$fields === void 0 ? null : _fieldsDef$fields,
|
|
309
|
+
_fieldsDef$settings = fieldsDef.settings,
|
|
310
|
+
settings = _fieldsDef$settings === void 0 ? null : _fieldsDef$settings,
|
|
311
|
+
_fieldsDef$itemsField = fieldsDef.itemsField,
|
|
312
|
+
itemsField = _fieldsDef$itemsField === void 0 ? null : _fieldsDef$itemsField;
|
|
313
|
+
var currentSubfields = subFields !== null ? getFieldByName(subFields, key) : null;
|
|
314
|
+
var currentSettings = settings !== null ? getFieldByName(settings, key) : null;
|
|
315
|
+
var isCurrentSubfields = currentSubfields !== null;
|
|
316
|
+
var isCurrentSettings = currentSettings !== null;
|
|
317
|
+
var isListItems = itemsField !== null && !!key.match(/^[0-9]+$/);
|
|
318
|
+
var isLastIndex = keyIndex === lastKeyIndex;
|
|
319
|
+
var pathPrefix = "/".concat(screenId, "/").concat(fieldPath.slice(0, keyIndex + 1).join('/'));
|
|
320
|
+
var pathSuffix = isLastIndex && form !== null ? "/".concat(form) : '';
|
|
321
|
+
var addNewItem = isLastIndex || isListItems;
|
|
322
|
+
var itemPath = "".concat(pathPrefix).concat(pathSuffix);
|
|
323
|
+
var nextFields = null;
|
|
324
|
+
|
|
325
|
+
if (isCurrentSubfields) {
|
|
326
|
+
nextFields = currentSubfields;
|
|
327
|
+
} else if (isCurrentSettings) {
|
|
328
|
+
nextFields = currentSettings;
|
|
329
|
+
|
|
330
|
+
if (parentItem !== null) {
|
|
331
|
+
fieldItems.push(_objectSpread(_objectSpread({}, parentItem), {}, {
|
|
332
|
+
url: "/".concat(screenId, "/").concat(fieldPath.slice(0, keyIndex).join('/'), "/settings")
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
} else if (isListItems) {
|
|
336
|
+
nextFields = itemsField;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
var fieldLabel = nextFields ? nextFields.breadcrumbLabel || nextFields.label : null;
|
|
340
|
+
var itemLabel = isMessage(fieldLabel) ? intl.formatMessage(fieldLabel) : fieldLabel;
|
|
341
|
+
|
|
342
|
+
var _ref3 = parentItem || {},
|
|
343
|
+
_ref3$label = _ref3.label,
|
|
344
|
+
parentItemLabel = _ref3$label === void 0 ? null : _ref3$label;
|
|
345
|
+
|
|
346
|
+
var finalItemLabel = isListItems ? "".concat(itemLabel, " #").concat(parseInt(key, 10) + 1) : itemLabel || parentItemLabel;
|
|
347
|
+
var item = {
|
|
348
|
+
url: itemPath,
|
|
349
|
+
label: finalItemLabel || '',
|
|
350
|
+
active: false
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
if (addNewItem) {
|
|
354
|
+
fieldItems.push(item);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
parentItem = item;
|
|
358
|
+
return nextFields;
|
|
359
|
+
}, {
|
|
360
|
+
fields: fields
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
var finalItems = [{
|
|
365
|
+
label: intl.formatMessage({
|
|
366
|
+
id: "AHvHaY",
|
|
367
|
+
defaultMessage: [{
|
|
368
|
+
"type": 0,
|
|
369
|
+
"value": "Parameters"
|
|
370
|
+
}]
|
|
371
|
+
}),
|
|
372
|
+
url: "/".concat(screenId),
|
|
373
|
+
active: false
|
|
374
|
+
}].concat(fieldItems).filter(function (it) {
|
|
375
|
+
return it !== null;
|
|
376
|
+
});
|
|
377
|
+
var lastItemsIndex = finalItems.length - 1;
|
|
378
|
+
return finalItems.map(function (it, index) {
|
|
379
|
+
return index === lastItemsIndex ? _objectSpread(_objectSpread({}, it), {}, {
|
|
380
|
+
url: url,
|
|
381
|
+
active: true
|
|
382
|
+
}) : it;
|
|
383
|
+
});
|
|
384
|
+
}, [intl, screens, screenId, field, form, url, screensManager, fieldsManager]);
|
|
385
|
+
var itemsLength = items.length;
|
|
386
|
+
var onClickBack = useCallback(function () {
|
|
387
|
+
history.push(items[itemsLength - 2].url);
|
|
388
|
+
}, [items]);
|
|
389
|
+
var withBack = itemsLength > 1;
|
|
390
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, withBack ? /*#__PURE__*/React.createElement(BackButton, {
|
|
391
|
+
onClick: onClickBack,
|
|
392
|
+
className: "mr-2"
|
|
393
|
+
}) : null, /*#__PURE__*/React.createElement(Breadcrumb$1, {
|
|
394
|
+
items: items,
|
|
395
|
+
theme: "secondary",
|
|
396
|
+
withoutBar: true,
|
|
397
|
+
noWrap: true,
|
|
398
|
+
className: classNames([styles$e.container, 'text-truncate', _defineProperty({}, className, className !== null)])
|
|
399
|
+
}));
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
Breadcrumb.propTypes = propTypes$m;
|
|
403
|
+
Breadcrumb.defaultProps = defaultProps$m;
|
|
404
|
+
|
|
405
|
+
var styles$d = {"container":"micromag-editor-forms-screen-container","inner":"micromag-editor-forms-screen-inner"};
|
|
406
|
+
|
|
407
|
+
var propTypes$l = {
|
|
408
|
+
value: PropTypes$1.component,
|
|
409
|
+
className: PropTypes.string,
|
|
410
|
+
gotoFieldForm: PropTypes.func.isRequired,
|
|
411
|
+
closeFieldForm: PropTypes.func.isRequired,
|
|
412
|
+
onChange: PropTypes.func // onClickDelete: PropTypes.func,
|
|
413
|
+
|
|
414
|
+
};
|
|
415
|
+
var defaultProps$l = {
|
|
416
|
+
value: null,
|
|
417
|
+
className: null,
|
|
418
|
+
onChange: null // onClickDelete: null,
|
|
419
|
+
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
var ScreenForm = function ScreenForm(_ref) {
|
|
423
|
+
var value = _ref.value,
|
|
424
|
+
className = _ref.className,
|
|
425
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
426
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
427
|
+
onChange = _ref.onChange;
|
|
428
|
+
|
|
429
|
+
var _useScreenDefinition = useScreenDefinition(),
|
|
430
|
+
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
431
|
+
fields = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$; // const intl = useIntl();
|
|
432
|
+
// const finalOnClickDelete = useCallback(() => {
|
|
433
|
+
// if (
|
|
434
|
+
// onClickDelete !== null &&
|
|
435
|
+
// window.confirm(
|
|
436
|
+
// intl.formatMessage({
|
|
437
|
+
// defaultMessage: 'Are you sure you want to delete this screen?',
|
|
438
|
+
// description: 'Confirm message when deleting a screen',
|
|
439
|
+
// }),
|
|
440
|
+
// )
|
|
441
|
+
// ) {
|
|
442
|
+
// onClickDelete(value);
|
|
443
|
+
// }
|
|
444
|
+
// }, [intl, onClickDelete, value]);
|
|
486
445
|
|
|
487
|
-
var _ref4 = isMessage(label) ? {
|
|
488
|
-
id: messageId || id,
|
|
489
|
-
name: group
|
|
490
|
-
} : {
|
|
491
|
-
id: messageId || id,
|
|
492
|
-
name: title
|
|
493
|
-
},
|
|
494
|
-
groupId = _ref4.id,
|
|
495
|
-
groupName = _ref4.name;
|
|
496
446
|
|
|
497
|
-
var groupIndex = allGroups.findIndex(function (it) {
|
|
498
|
-
return it.id === groupId;
|
|
499
|
-
});
|
|
500
|
-
var selected = selectedTypes !== null && selectedTypes.indexOf(id) !== -1;
|
|
501
|
-
var item = {
|
|
502
|
-
id: id,
|
|
503
|
-
type: id,
|
|
504
|
-
screen: definition,
|
|
505
|
-
className: classNames(_defineProperty({
|
|
506
|
-
'bg-secondary': !selected,
|
|
507
|
-
'bg-primary': selected
|
|
508
|
-
}, styles$a.selected, selected))
|
|
509
|
-
};
|
|
510
|
-
return groupIndex !== -1 ? [].concat(_toConsumableArray(allGroups.slice(0, groupIndex)), [_objectSpread(_objectSpread({}, allGroups[groupIndex]), {}, {
|
|
511
|
-
items: [].concat(_toConsumableArray(allGroups[groupIndex].items), [item])
|
|
512
|
-
})], _toConsumableArray(allGroups.slice(groupIndex + 1))) : [].concat(_toConsumableArray(allGroups), [{
|
|
513
|
-
id: groupId,
|
|
514
|
-
name: isMessage(label) ? intl.formatMessage(label) : groupName,
|
|
515
|
-
order: order,
|
|
516
|
-
items: [item]
|
|
517
|
-
}]);
|
|
518
|
-
}, []);
|
|
519
|
-
return orderBy(groupItems, ['order', 'name'], ['asc', 'asc']);
|
|
520
|
-
}, [finalDefinitions, selectedTypes]);
|
|
521
447
|
return /*#__PURE__*/React.createElement("div", {
|
|
522
|
-
className: classNames([styles$
|
|
448
|
+
className: classNames([styles$d.container, _defineProperty({}, className, className)])
|
|
523
449
|
}, /*#__PURE__*/React.createElement("div", {
|
|
524
|
-
className: styles$
|
|
525
|
-
},
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
className: styles$a.row
|
|
532
|
-
}, /*#__PURE__*/React.createElement(Label, null, name), /*#__PURE__*/React.createElement("div", {
|
|
533
|
-
className: styles$a.layouts
|
|
534
|
-
}, /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
535
|
-
items: items,
|
|
536
|
-
withPlaceholder: true,
|
|
537
|
-
itemClassName: classNames(['border', 'rounded', {
|
|
538
|
-
'border-secondary': selectedTypes === null,
|
|
539
|
-
'border-dark': selectedTypes !== null,
|
|
540
|
-
'bg-secondary': selectedTypes === null,
|
|
541
|
-
'text-secondary': selectedTypes !== null
|
|
542
|
-
}]),
|
|
543
|
-
previewMinWidth: 100,
|
|
544
|
-
onClickItem: onClickItem
|
|
545
|
-
})));
|
|
450
|
+
className: styles$d.inner
|
|
451
|
+
}, /*#__PURE__*/React.createElement(Fields, {
|
|
452
|
+
fields: fields,
|
|
453
|
+
value: value,
|
|
454
|
+
onChange: onChange,
|
|
455
|
+
gotoFieldForm: gotoFieldForm,
|
|
456
|
+
closeFieldForm: closeFieldForm
|
|
546
457
|
})));
|
|
547
458
|
};
|
|
548
459
|
|
|
549
|
-
|
|
550
|
-
|
|
460
|
+
ScreenForm.propTypes = propTypes$l;
|
|
461
|
+
ScreenForm.defaultProps = defaultProps$l;
|
|
551
462
|
|
|
552
|
-
|
|
463
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
464
|
+
var propTypes$k = {
|
|
465
|
+
children: PropTypes.node
|
|
466
|
+
};
|
|
467
|
+
var defaultProps$k = {
|
|
468
|
+
children: null
|
|
469
|
+
};
|
|
553
470
|
|
|
554
|
-
var
|
|
555
|
-
|
|
471
|
+
var FieldWithContexts = function FieldWithContexts(props) {
|
|
472
|
+
// Get definitions
|
|
473
|
+
var _useScreenDefinition = useScreenDefinition(),
|
|
474
|
+
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
475
|
+
fields = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$; // To use a specific form component
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
var formComponents = useFormsComponents();
|
|
479
|
+
return /*#__PURE__*/React.createElement(FieldForm, Object.assign({
|
|
480
|
+
fields: fields,
|
|
481
|
+
formComponents: formComponents
|
|
482
|
+
}, props));
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
FieldWithContexts.propTypes = propTypes$k;
|
|
486
|
+
FieldWithContexts.defaultProps = defaultProps$k;
|
|
487
|
+
|
|
488
|
+
var styles$c = {"container":"micromag-editor-modals-delete-screen-container","description":"micromag-editor-modals-delete-screen-description","actions":"micromag-editor-modals-delete-screen-actions"};
|
|
489
|
+
|
|
490
|
+
var propTypes$j = {
|
|
556
491
|
className: PropTypes.string,
|
|
557
|
-
|
|
558
|
-
|
|
492
|
+
onConfirm: PropTypes.func,
|
|
493
|
+
onCancel: PropTypes.func
|
|
559
494
|
};
|
|
560
|
-
var defaultProps$
|
|
561
|
-
selectedTypes: null,
|
|
495
|
+
var defaultProps$j = {
|
|
562
496
|
className: null,
|
|
563
|
-
|
|
564
|
-
|
|
497
|
+
onConfirm: null,
|
|
498
|
+
onCancel: null
|
|
565
499
|
};
|
|
566
500
|
|
|
567
|
-
var
|
|
568
|
-
var
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
onClickScreenType = _ref.onClickScreenType;
|
|
501
|
+
var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
502
|
+
var className = _ref.className,
|
|
503
|
+
onConfirm = _ref.onConfirm,
|
|
504
|
+
onCancel = _ref.onCancel;
|
|
572
505
|
return /*#__PURE__*/React.createElement(Modal, null, /*#__PURE__*/React.createElement(ModalDialog, {
|
|
573
506
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
574
|
-
id: "
|
|
507
|
+
id: "p6q/+/",
|
|
575
508
|
defaultMessage: [{
|
|
576
509
|
"type": 0,
|
|
577
|
-
"value": "
|
|
510
|
+
"value": "Delete screen"
|
|
578
511
|
}]
|
|
579
512
|
}),
|
|
580
|
-
className: classNames([styles$
|
|
581
|
-
onClickClose:
|
|
582
|
-
}, /*#__PURE__*/React.createElement(
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
513
|
+
className: classNames([styles$c.container, _defineProperty({}, className, className)]),
|
|
514
|
+
onClickClose: onCancel
|
|
515
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
516
|
+
className: styles$c.description
|
|
517
|
+
}, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
518
|
+
id: "q/tLk0",
|
|
519
|
+
defaultMessage: [{
|
|
520
|
+
"type": 0,
|
|
521
|
+
"value": "Are you sure you want to delete this screen?"
|
|
522
|
+
}]
|
|
523
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
524
|
+
className: styles$c.actions
|
|
525
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
526
|
+
onClick: onCancel,
|
|
527
|
+
className: "btn-outline-secondary mr-2"
|
|
528
|
+
}, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
529
|
+
id: "0GT0SI",
|
|
530
|
+
defaultMessage: [{
|
|
531
|
+
"type": 0,
|
|
532
|
+
"value": "Cancel"
|
|
533
|
+
}]
|
|
534
|
+
}))), /*#__PURE__*/React.createElement(Button, {
|
|
535
|
+
onClick: onConfirm,
|
|
536
|
+
theme: "danger",
|
|
537
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
538
|
+
id: "gRxcTc",
|
|
539
|
+
defaultMessage: [{
|
|
540
|
+
"type": 0,
|
|
541
|
+
"value": "Delete screen"
|
|
542
|
+
}]
|
|
543
|
+
})
|
|
544
|
+
}))));
|
|
587
545
|
};
|
|
588
546
|
|
|
589
|
-
|
|
590
|
-
|
|
547
|
+
DeleteScreenModal.propTypes = propTypes$j;
|
|
548
|
+
DeleteScreenModal.defaultProps = defaultProps$j;
|
|
591
549
|
|
|
592
|
-
var styles$
|
|
550
|
+
var styles$b = {"panel":"micromag-editor-form-panel","leave":"micromag-editor-form-leave","content":"micromag-editor-form-content","navbar":"micromag-editor-form-navbar","enterBottom":"micromag-editor-form-enterBottom","enterLeft":"micromag-editor-form-enterLeft","enterRight":"micromag-editor-form-enterRight","enterTop":"micromag-editor-form-enterTop","enterActiveHorizontal":"micromag-editor-form-enterActiveHorizontal","enterActiveVertical":"micromag-editor-form-enterActiveVertical","leaveActiveLeft":"micromag-editor-form-leaveActiveLeft","leaveActiveRight":"micromag-editor-form-leaveActiveRight","leaveActiveBottom":"micromag-editor-form-leaveActiveBottom","leaveActiveTop":"micromag-editor-form-leaveActiveTop"};
|
|
593
551
|
|
|
594
|
-
var propTypes$
|
|
552
|
+
var propTypes$i = {
|
|
595
553
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
596
554
|
isTheme: PropTypes.bool,
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
isParsed: PropTypes.bool,
|
|
600
|
-
onClickScreen: PropTypes.func,
|
|
601
|
-
onChange: PropTypes.func,
|
|
602
|
-
className: PropTypes.string
|
|
555
|
+
className: PropTypes.string,
|
|
556
|
+
onChange: PropTypes.func
|
|
603
557
|
};
|
|
604
|
-
var defaultProps$
|
|
558
|
+
var defaultProps$i = {
|
|
605
559
|
value: null,
|
|
606
560
|
isTheme: false,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
isParsed: false,
|
|
610
|
-
onClickScreen: null,
|
|
611
|
-
onChange: null,
|
|
612
|
-
className: null
|
|
561
|
+
className: null,
|
|
562
|
+
onChange: null
|
|
613
563
|
};
|
|
614
564
|
|
|
615
|
-
var
|
|
616
|
-
var
|
|
565
|
+
var EditForm = function EditForm(_ref) {
|
|
566
|
+
var value = _ref.value,
|
|
617
567
|
isTheme = _ref.isTheme,
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
var
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
568
|
+
className = _ref.className,
|
|
569
|
+
onChange = _ref.onChange;
|
|
570
|
+
// Match routes
|
|
571
|
+
var history = useHistory();
|
|
572
|
+
var routePush = useRoutePush();
|
|
573
|
+
|
|
574
|
+
var _useRouteParams = useRouteParams(),
|
|
575
|
+
url = _useRouteParams.url,
|
|
576
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
577
|
+
screenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
578
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
579
|
+
fieldParams = _useRouteParams$field === void 0 ? null : _useRouteParams$field,
|
|
580
|
+
_useRouteParams$form = _useRouteParams.form,
|
|
581
|
+
formParams = _useRouteParams$form === void 0 ? null : _useRouteParams$form; // Get screen
|
|
582
|
+
|
|
628
583
|
|
|
629
584
|
var _ref2 = value || {},
|
|
630
585
|
_ref2$components = _ref2.components,
|
|
631
586
|
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
632
587
|
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
var routes = useRoutes();
|
|
639
|
-
var push = useRoutePush();
|
|
640
|
-
var url = useUrlGenerator();
|
|
641
|
-
|
|
642
|
-
var _useRouteParams = useRouteParams({
|
|
643
|
-
screenOnly: true
|
|
644
|
-
}),
|
|
645
|
-
_useRouteParams$scree = _useRouteParams.screen,
|
|
646
|
-
currentScreenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree;
|
|
647
|
-
|
|
648
|
-
var createScreenFromDefinition = useCallback(function (definition) {
|
|
649
|
-
var _ref3 = value || {},
|
|
650
|
-
_ref3$components = _ref3.components,
|
|
651
|
-
currentScreens = _ref3$components === void 0 ? [] : _ref3$components,
|
|
652
|
-
_ref3$theme = _ref3.theme,
|
|
653
|
-
theme = _ref3$theme === void 0 ? {} : _ref3$theme;
|
|
654
|
-
|
|
655
|
-
var _ref4 = isString(definition) ? {
|
|
656
|
-
id: definition
|
|
657
|
-
} : definition,
|
|
658
|
-
newScreenType = _ref4.id;
|
|
588
|
+
var screenIndex = screens.findIndex(function (it) {
|
|
589
|
+
return it.id === screenId;
|
|
590
|
+
});
|
|
591
|
+
var screen = screenIndex !== -1 ? screens[screenIndex] : null; // Get transition value
|
|
659
592
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
593
|
+
var _useFormTransition = useFormTransition(url, screenIndex, styles$b),
|
|
594
|
+
transitionName = _useFormTransition.name,
|
|
595
|
+
transitionTimeout = _useFormTransition.timeout;
|
|
663
596
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
var foundIndex = screens.findIndex(function (_ref6) {
|
|
669
|
-
var id = _ref6.id;
|
|
670
|
-
return id === currentScreenId;
|
|
671
|
-
});
|
|
672
|
-
var currentScreenIndex = !isTheme && foundIndex >= 0 ? foundIndex + 1 : null;
|
|
597
|
+
var _useState = useState(false),
|
|
598
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
599
|
+
screenSettingsOpened = _useState2[0],
|
|
600
|
+
setScreenSettingsOpened = _useState2[1];
|
|
673
601
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
602
|
+
var _useState3 = useState(false),
|
|
603
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
604
|
+
deleteScreenModalOpened = _useState4[0],
|
|
605
|
+
setDeleteScreenModalOpened = _useState4[1];
|
|
677
606
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
607
|
+
var _useState5 = useState({}),
|
|
608
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
609
|
+
fieldForms = _useState6[0],
|
|
610
|
+
setFieldForms = _useState6[1];
|
|
681
611
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
var id = _ref7.id;
|
|
687
|
-
return id;
|
|
688
|
-
});
|
|
612
|
+
var _useState7 = useState(null),
|
|
613
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
614
|
+
fieldContext = _useState8[0],
|
|
615
|
+
setFieldContext = _useState8[1]; // Callbacks
|
|
689
616
|
|
|
690
|
-
var _ref8 = value || {},
|
|
691
|
-
_ref8$components = _ref8.components,
|
|
692
|
-
currentScreens = _ref8$components === void 0 ? [] : _ref8$components;
|
|
693
617
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
618
|
+
var gotoFieldForm = useCallback(function () {
|
|
619
|
+
var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
620
|
+
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
621
|
+
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
622
|
+
var hasField = field !== null;
|
|
623
|
+
var fieldRoute = formName !== null ? 'screen.field.form' : 'screen.field';
|
|
624
|
+
routePush(hasField ? fieldRoute : 'screen', {
|
|
625
|
+
screen: screenId,
|
|
626
|
+
field: field !== null ? field.split('.') : null,
|
|
627
|
+
form: formName !== null ? slug(formName) : null
|
|
697
628
|
});
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
components: _toConsumableArray(currentScreens).sort(function (_ref11, _ref12) {
|
|
706
|
-
var idA = _ref11.id;
|
|
707
|
-
var idB = _ref12.id;
|
|
708
|
-
var indexA = ids.indexOf(idA);
|
|
709
|
-
var indexB = ids.indexOf(idB);
|
|
710
|
-
|
|
711
|
-
if (indexA === indexB) {
|
|
712
|
-
return 0;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
return indexA > indexB ? 1 : -1;
|
|
716
|
-
})
|
|
717
|
-
});
|
|
629
|
+
setFieldForms(_objectSpread(_objectSpread({}, fieldForms), {}, _defineProperty({}, "".concat(field).concat(formName !== null ? ":".concat(formName) : ''), url)));
|
|
630
|
+
setFieldContext(context);
|
|
631
|
+
}, [routePush, screenId, url, fieldForms, setFieldForms, fieldContext, setFieldContext]);
|
|
632
|
+
var closeFieldForm = useCallback(function (field) {
|
|
633
|
+
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
634
|
+
var fieldKey = "".concat(field).concat(formName !== null ? ":".concat(formName) : '');
|
|
635
|
+
var pastUrl = fieldForms[fieldKey] || null;
|
|
718
636
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
637
|
+
if (pastUrl !== null) {
|
|
638
|
+
history.push(pastUrl);
|
|
722
639
|
}
|
|
723
|
-
}, [value, onChange]);
|
|
724
|
-
var onClickScreenType = useCallback(function (definition) {
|
|
725
|
-
setCreateModalOpened(false);
|
|
726
|
-
var currentScreen = isTheme ? screens.find(function (_ref13) {
|
|
727
|
-
var type = _ref13.type;
|
|
728
|
-
return type === definition.id;
|
|
729
|
-
}) || null : null;
|
|
730
640
|
|
|
731
|
-
|
|
732
|
-
|
|
641
|
+
setFieldForms(Object.keys(fieldForms).reduce(function (map, key) {
|
|
642
|
+
return key !== fieldKey ? _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, fieldForms[key])) : map;
|
|
643
|
+
}, {}));
|
|
644
|
+
}, [history, screenId, fieldForms, setFieldForms]);
|
|
645
|
+
var triggerOnChange = useCallback(function (newValue) {
|
|
646
|
+
if (onChange !== null) {
|
|
647
|
+
onChange(newValue);
|
|
733
648
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
649
|
+
}, [onChange]);
|
|
650
|
+
var onScreenFormChange = useCallback(function (newScreenValue) {
|
|
651
|
+
triggerOnChange(updateScreen(value, newScreenValue));
|
|
652
|
+
}, [value, triggerOnChange]);
|
|
653
|
+
var onClickDuplicate = useCallback(function () {
|
|
654
|
+
triggerOnChange(duplicateScreen(value, screenId));
|
|
655
|
+
setScreenSettingsOpened(false);
|
|
656
|
+
}, [value, screenId, triggerOnChange, setScreenSettingsOpened]);
|
|
657
|
+
var onClickDelete = useCallback(function () {
|
|
658
|
+
setDeleteScreenModalOpened(true);
|
|
659
|
+
setScreenSettingsOpened(false);
|
|
660
|
+
}, [setScreenSettingsOpened, setDeleteScreenModalOpened]);
|
|
661
|
+
var onSettingsClick = useCallback(function () {
|
|
662
|
+
setScreenSettingsOpened(function (opened) {
|
|
663
|
+
return !opened;
|
|
737
664
|
});
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}, [
|
|
665
|
+
}, [setScreenSettingsOpened]);
|
|
666
|
+
var onDropdownClickOutside = useCallback(function () {
|
|
667
|
+
setScreenSettingsOpened(false);
|
|
668
|
+
}, [setScreenSettingsOpened]);
|
|
669
|
+
var onDeleteScreenConfirm = useCallback(function () {
|
|
670
|
+
triggerOnChange(deleteScreen(value, screenId));
|
|
671
|
+
setDeleteScreenModalOpened(false);
|
|
672
|
+
}, [value, triggerOnChange, screenId, setScreenSettingsOpened]);
|
|
673
|
+
var onDeleteScreenCancel = useCallback(function () {
|
|
674
|
+
setDeleteScreenModalOpened(false);
|
|
675
|
+
}, [setDeleteScreenModalOpened]);
|
|
676
|
+
var dropdownItems = [!isTheme ? {
|
|
677
|
+
id: 'duplicate',
|
|
678
|
+
type: 'button',
|
|
679
|
+
className: 'text-left text-info',
|
|
680
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
681
|
+
id: "IBjY5r",
|
|
682
|
+
defaultMessage: [{
|
|
683
|
+
"type": 0,
|
|
684
|
+
"value": "Duplicate screen"
|
|
685
|
+
}]
|
|
686
|
+
}),
|
|
687
|
+
onClick: onClickDuplicate
|
|
688
|
+
} : null, {
|
|
689
|
+
id: 'delete',
|
|
690
|
+
type: 'button',
|
|
691
|
+
className: 'text-left text-danger',
|
|
692
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
693
|
+
id: "hpiKce",
|
|
694
|
+
defaultMessage: [{
|
|
695
|
+
"type": 0,
|
|
696
|
+
"value": "Delete screen"
|
|
697
|
+
}]
|
|
698
|
+
}),
|
|
699
|
+
onClick: onClickDelete
|
|
700
|
+
}].filter(function (it) {
|
|
701
|
+
return it !== null;
|
|
702
|
+
});
|
|
746
703
|
return /*#__PURE__*/React.createElement("div", {
|
|
747
|
-
className: classNames(['d-flex', 'flex-column',
|
|
748
|
-
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
704
|
+
className: classNames(['d-flex', 'flex-column', className])
|
|
705
|
+
}, screenId !== null ? /*#__PURE__*/React.createElement(Navbar, {
|
|
749
706
|
compact: true,
|
|
750
707
|
noWrap: true,
|
|
751
708
|
withoutCollapse: true,
|
|
752
|
-
className: classNames(['sticky-top', styles$
|
|
753
|
-
}, /*#__PURE__*/React.createElement(
|
|
754
|
-
|
|
709
|
+
className: classNames(['sticky-top', 'border-bottom', 'border-dark', styles$b.navbar])
|
|
710
|
+
}, /*#__PURE__*/React.createElement(Breadcrumb, {
|
|
711
|
+
story: value,
|
|
712
|
+
url: url,
|
|
713
|
+
screenId: screenId,
|
|
714
|
+
field: fieldParams,
|
|
715
|
+
form: formParams,
|
|
716
|
+
className: "mr-auto"
|
|
717
|
+
}), fieldParams === null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SettingsButton, {
|
|
718
|
+
onClick: onSettingsClick
|
|
719
|
+
}), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
720
|
+
items: dropdownItems,
|
|
721
|
+
visible: screenSettingsOpened,
|
|
722
|
+
align: "right",
|
|
723
|
+
onClickOutside: onDropdownClickOutside
|
|
724
|
+
})) : null) : null, /*#__PURE__*/React.createElement("div", {
|
|
725
|
+
className: classNames(['flex-grow-1', 'd-flex', 'w-100', styles$b.content])
|
|
726
|
+
}, screen !== null ? /*#__PURE__*/React.createElement(CSSTransitionGroup, {
|
|
727
|
+
transitionName: transitionName,
|
|
728
|
+
transitionEnterTimeout: transitionTimeout,
|
|
729
|
+
transitionLeaveTimeout: transitionTimeout,
|
|
730
|
+
className: "w-100 flex-grow-1"
|
|
731
|
+
}, fieldParams !== null ? /*#__PURE__*/React.createElement("div", {
|
|
732
|
+
className: classNames(['w-100', styles$b.panel]),
|
|
733
|
+
key: "field-".concat(fieldParams, "-").concat(formParams)
|
|
734
|
+
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
735
|
+
data: screen
|
|
736
|
+
}, /*#__PURE__*/React.createElement(FieldWithContexts, {
|
|
737
|
+
name: fieldParams.replace(/\//g, '.'),
|
|
738
|
+
value: screen,
|
|
739
|
+
form: formParams,
|
|
740
|
+
className: styles$b.form,
|
|
741
|
+
gotoFieldForm: gotoFieldForm,
|
|
742
|
+
closeFieldForm: closeFieldForm,
|
|
743
|
+
fieldContext: fieldContext,
|
|
744
|
+
onChange: onScreenFormChange
|
|
745
|
+
}))) : /*#__PURE__*/React.createElement("div", {
|
|
746
|
+
className: classNames(['w-100', styles$b.panel]),
|
|
747
|
+
key: "screen-".concat(screen.id)
|
|
748
|
+
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
749
|
+
data: screen
|
|
750
|
+
}, /*#__PURE__*/React.createElement(ScreenForm, {
|
|
751
|
+
value: screen,
|
|
752
|
+
className: styles$b.form,
|
|
753
|
+
onChange: onScreenFormChange,
|
|
754
|
+
gotoFieldForm: gotoFieldForm,
|
|
755
|
+
closeFieldForm: closeFieldForm
|
|
756
|
+
})))) : /*#__PURE__*/React.createElement(Empty, {
|
|
757
|
+
className: "w-100 m-2"
|
|
755
758
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
756
|
-
id: "
|
|
759
|
+
id: "QfpTKK",
|
|
757
760
|
defaultMessage: [{
|
|
758
761
|
"type": 0,
|
|
759
|
-
"value": "
|
|
760
|
-
}]
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
766
|
-
icon: faPlus
|
|
767
|
-
})
|
|
768
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
769
|
-
className: "flex-grow-1 d-flex w-100 p-2"
|
|
770
|
-
}, /*#__PURE__*/React.createElement(Route, {
|
|
771
|
-
path: [routes.screen, routes.home],
|
|
772
|
-
render: function render(_ref14) {
|
|
773
|
-
var _ref14$match$params$s = _ref14.match.params.screen,
|
|
774
|
-
screenId = _ref14$match$params$s === void 0 ? null : _ref14$match$params$s;
|
|
775
|
-
return screens.length > 0 ? /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
776
|
-
items: screens.map(function (it) {
|
|
777
|
-
return {
|
|
778
|
-
id: it.id,
|
|
779
|
-
screen: it,
|
|
780
|
-
href: url('screen', {
|
|
781
|
-
screen: it.id
|
|
782
|
-
}),
|
|
783
|
-
active: it.id === screenId
|
|
784
|
-
};
|
|
785
|
-
}),
|
|
786
|
-
isVertical: isVertical,
|
|
787
|
-
withPreview: true,
|
|
788
|
-
sortable: true,
|
|
789
|
-
className: "w-100",
|
|
790
|
-
onClickItem: onClickScreen,
|
|
791
|
-
onOrderChange: onOrderChange
|
|
792
|
-
}) : /*#__PURE__*/React.createElement(Empty, {
|
|
793
|
-
className: "flex-grow-1 p-2"
|
|
794
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
795
|
-
theme: "primary",
|
|
796
|
-
onClick: onClickAdd
|
|
797
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
798
|
-
id: "JoWKee",
|
|
799
|
-
defaultMessage: [{
|
|
800
|
-
"type": 0,
|
|
801
|
-
"value": "Create your first screen"
|
|
802
|
-
}]
|
|
803
|
-
})));
|
|
804
|
-
}
|
|
805
|
-
})), createModalOpened ? /*#__PURE__*/React.createElement(ScreenTypesModal, {
|
|
806
|
-
selectedTypes: isTheme ? screens.map(function (_ref15) {
|
|
807
|
-
var type = _ref15.type;
|
|
808
|
-
return type;
|
|
809
|
-
}) : [],
|
|
810
|
-
onClickScreenType: onClickScreenType,
|
|
811
|
-
onRequestClose: onCreateModalRequestClose
|
|
762
|
+
"value": "Select a screen..."
|
|
763
|
+
}],
|
|
764
|
+
decription: "Indication to select a screen to view the form"
|
|
765
|
+
}))), deleteScreenModalOpened ? /*#__PURE__*/React.createElement(DeleteScreenModal, {
|
|
766
|
+
onConfirm: onDeleteScreenConfirm,
|
|
767
|
+
onCancel: onDeleteScreenCancel
|
|
812
768
|
}) : null);
|
|
813
769
|
};
|
|
814
770
|
|
|
815
|
-
|
|
816
|
-
|
|
771
|
+
EditForm.propTypes = propTypes$i;
|
|
772
|
+
EditForm.defaultProps = defaultProps$i;
|
|
773
|
+
|
|
774
|
+
var _excluded$7 = ["components"];
|
|
775
|
+
|
|
776
|
+
var useThemeValue = function useThemeValue(value) {
|
|
777
|
+
var isTheme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
778
|
+
var valueWithTheme = useMemo(function () {
|
|
779
|
+
if (!isTheme) {
|
|
780
|
+
return value;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
var _ref = value || {};
|
|
784
|
+
_ref.components;
|
|
785
|
+
var themeValue = _objectWithoutProperties(_ref, _excluded$7);
|
|
786
|
+
|
|
787
|
+
return value !== null ? _objectSpread({
|
|
788
|
+
theme: themeValue
|
|
789
|
+
}, value) : value;
|
|
790
|
+
}, [value, isTheme]);
|
|
791
|
+
return valueWithTheme;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
var styles$a = {"container":"micromag-editor-menus-devices-container","button":"micromag-editor-menus-devices-button"};
|
|
817
795
|
|
|
818
796
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
819
|
-
var propTypes$
|
|
797
|
+
var propTypes$h = {
|
|
820
798
|
color: PropTypes.string,
|
|
821
799
|
className: PropTypes.string
|
|
822
800
|
};
|
|
823
|
-
var defaultProps$
|
|
801
|
+
var defaultProps$h = {
|
|
824
802
|
color: 'currentColor',
|
|
825
803
|
className: null
|
|
826
804
|
};
|
|
@@ -845,15 +823,15 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
845
823
|
}));
|
|
846
824
|
};
|
|
847
825
|
|
|
848
|
-
DesktopIcon.propTypes = propTypes$
|
|
849
|
-
DesktopIcon.defaultProps = defaultProps$
|
|
826
|
+
DesktopIcon.propTypes = propTypes$h;
|
|
827
|
+
DesktopIcon.defaultProps = defaultProps$h;
|
|
850
828
|
|
|
851
829
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
852
|
-
var propTypes$
|
|
830
|
+
var propTypes$g = {
|
|
853
831
|
color: PropTypes.string,
|
|
854
832
|
className: PropTypes.string
|
|
855
833
|
};
|
|
856
|
-
var defaultProps$
|
|
834
|
+
var defaultProps$g = {
|
|
857
835
|
color: 'currentColor',
|
|
858
836
|
className: null
|
|
859
837
|
};
|
|
@@ -878,8 +856,8 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
878
856
|
}));
|
|
879
857
|
};
|
|
880
858
|
|
|
881
|
-
MobileIcon.propTypes = propTypes$
|
|
882
|
-
MobileIcon.defaultProps = defaultProps$
|
|
859
|
+
MobileIcon.propTypes = propTypes$g;
|
|
860
|
+
MobileIcon.defaultProps = defaultProps$g;
|
|
883
861
|
|
|
884
862
|
var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
885
863
|
__proto__: null,
|
|
@@ -887,15 +865,15 @@ var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
|
887
865
|
Mobile: MobileIcon
|
|
888
866
|
});
|
|
889
867
|
|
|
890
|
-
var styles$
|
|
868
|
+
var styles$9 = {"container":"micromag-editor-buttons-device-container","icon":"micromag-editor-buttons-device-icon"};
|
|
891
869
|
|
|
892
870
|
var _excluded$6 = ["device", "className", "iconComponents"];
|
|
893
|
-
var propTypes$
|
|
871
|
+
var propTypes$f = {
|
|
894
872
|
device: PropTypes.string.isRequired,
|
|
895
873
|
iconComponents: PropTypes$1.components,
|
|
896
874
|
className: PropTypes.string
|
|
897
875
|
};
|
|
898
|
-
var defaultProps$
|
|
876
|
+
var defaultProps$f = {
|
|
899
877
|
iconComponents: DeviceIcons,
|
|
900
878
|
className: null
|
|
901
879
|
};
|
|
@@ -908,24 +886,22 @@ var DeviceButton = function DeviceButton(_ref) {
|
|
|
908
886
|
|
|
909
887
|
var DeviceIcon = getComponentFromName(device, iconComponents, DesktopIcon);
|
|
910
888
|
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
911
|
-
className: classNames([styles$
|
|
889
|
+
className: classNames([styles$9.container, _defineProperty({}, className, className !== null)])
|
|
912
890
|
}, props), /*#__PURE__*/React.createElement(DeviceIcon, {
|
|
913
|
-
className: styles$
|
|
891
|
+
className: styles$9.icon
|
|
914
892
|
}));
|
|
915
893
|
};
|
|
916
894
|
|
|
917
|
-
DeviceButton.propTypes = propTypes$
|
|
918
|
-
DeviceButton.defaultProps = defaultProps$
|
|
919
|
-
|
|
920
|
-
var styles$6 = {"container":"micromag-editor-menus-devices-container","button":"micromag-editor-menus-devices-button"};
|
|
895
|
+
DeviceButton.propTypes = propTypes$f;
|
|
896
|
+
DeviceButton.defaultProps = defaultProps$f;
|
|
921
897
|
|
|
922
898
|
var _excluded$5 = ["id"];
|
|
923
|
-
var propTypes$
|
|
899
|
+
var propTypes$e = {
|
|
924
900
|
items: PropTypes$1.menuItems,
|
|
925
901
|
className: PropTypes.string,
|
|
926
902
|
onClickItem: PropTypes.func
|
|
927
903
|
};
|
|
928
|
-
var defaultProps$
|
|
904
|
+
var defaultProps$e = {
|
|
929
905
|
items: [],
|
|
930
906
|
className: null,
|
|
931
907
|
onClickItem: null
|
|
@@ -938,7 +914,7 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
938
914
|
return /*#__PURE__*/React.createElement(Tabs, {
|
|
939
915
|
items: items,
|
|
940
916
|
theme: "outline-secondary",
|
|
941
|
-
className: classNames([styles$
|
|
917
|
+
className: classNames([styles$a.container, _defineProperty({}, className, className !== null)]),
|
|
942
918
|
renderItemButton: function renderItemButton(item, index, props) {
|
|
943
919
|
var id = item.id,
|
|
944
920
|
itemProps = _objectWithoutProperties(item, _excluded$5);
|
|
@@ -946,7 +922,7 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
946
922
|
return /*#__PURE__*/React.createElement(DeviceButton, Object.assign({
|
|
947
923
|
device: id
|
|
948
924
|
}, props, itemProps, {
|
|
949
|
-
className: styles$
|
|
925
|
+
className: styles$a.button,
|
|
950
926
|
onClick: function onClick(e) {
|
|
951
927
|
return onClickItem !== null ? onClickItem(e, item, index) : null;
|
|
952
928
|
}
|
|
@@ -955,12 +931,12 @@ var DevicesMenu = function DevicesMenu(_ref) {
|
|
|
955
931
|
});
|
|
956
932
|
};
|
|
957
933
|
|
|
958
|
-
DevicesMenu.propTypes = propTypes$
|
|
959
|
-
DevicesMenu.defaultProps = defaultProps$
|
|
934
|
+
DevicesMenu.propTypes = propTypes$e;
|
|
935
|
+
DevicesMenu.defaultProps = defaultProps$e;
|
|
960
936
|
|
|
961
|
-
var styles$
|
|
937
|
+
var styles$8 = {"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"};
|
|
962
938
|
|
|
963
|
-
var propTypes$
|
|
939
|
+
var propTypes$d = {
|
|
964
940
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
965
941
|
devices: PropTypes$1.devices,
|
|
966
942
|
device: PropTypes.string,
|
|
@@ -970,7 +946,7 @@ var propTypes$8 = {
|
|
|
970
946
|
onScreenChange: PropTypes.func,
|
|
971
947
|
withoutDevicesSizes: PropTypes.bool
|
|
972
948
|
};
|
|
973
|
-
var defaultProps$
|
|
949
|
+
var defaultProps$d = {
|
|
974
950
|
value: null,
|
|
975
951
|
devices: [{
|
|
976
952
|
id: 'mobile',
|
|
@@ -1060,13 +1036,13 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1060
1036
|
};
|
|
1061
1037
|
}, [device, contentRect, screen, withoutDevicesSizes]);
|
|
1062
1038
|
return /*#__PURE__*/React.createElement("div", {
|
|
1063
|
-
className: classNames([styles$
|
|
1064
|
-
return styles$
|
|
1065
|
-
}), (_ref3 = {}, _defineProperty(_ref3, className, className), _defineProperty(_ref3, styles$
|
|
1039
|
+
className: classNames([styles$8.container, screens.map(function (screenName) {
|
|
1040
|
+
return styles$8["screen-".concat(screenName)];
|
|
1041
|
+
}), (_ref3 = {}, _defineProperty(_ref3, className, className), _defineProperty(_ref3, styles$8.withoutDevicesSizes, withoutDevicesSizes), _ref3)])
|
|
1066
1042
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1067
|
-
className: styles$
|
|
1043
|
+
className: styles$8.inner
|
|
1068
1044
|
}, !withoutDevicesSizes ? /*#__PURE__*/React.createElement("div", {
|
|
1069
|
-
className: styles$
|
|
1045
|
+
className: styles$8.top
|
|
1070
1046
|
}, /*#__PURE__*/React.createElement(DevicesMenu, {
|
|
1071
1047
|
items: devices.map(function (it) {
|
|
1072
1048
|
return _objectSpread(_objectSpread({}, it), {}, {
|
|
@@ -1075,12 +1051,12 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1075
1051
|
}),
|
|
1076
1052
|
onClickItem: onClickDeviceItem
|
|
1077
1053
|
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
1078
|
-
className: styles$
|
|
1054
|
+
className: styles$8.bottom
|
|
1079
1055
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1080
|
-
className: styles$
|
|
1056
|
+
className: styles$8.inner,
|
|
1081
1057
|
ref: bottomRef
|
|
1082
1058
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1083
|
-
className: styles$
|
|
1059
|
+
className: styles$8.preview,
|
|
1084
1060
|
style: previewStyle
|
|
1085
1061
|
}, /*#__PURE__*/React.createElement(Route, {
|
|
1086
1062
|
path: [routes.screen, routes.home],
|
|
@@ -1088,12 +1064,12 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1088
1064
|
var _ref4$match$params$sc = _ref4.match.params.screen,
|
|
1089
1065
|
screenId = _ref4$match$params$sc === void 0 ? null : _ref4$match$params$sc;
|
|
1090
1066
|
return /*#__PURE__*/React.createElement("div", {
|
|
1091
|
-
className: styles$
|
|
1067
|
+
className: styles$8.viewerContainer
|
|
1092
1068
|
}, /*#__PURE__*/React.createElement(Viewer, {
|
|
1093
1069
|
story: valueParsed,
|
|
1094
1070
|
storyIsParsed: true,
|
|
1095
1071
|
screen: screenId,
|
|
1096
|
-
className: styles$
|
|
1072
|
+
className: styles$8.story,
|
|
1097
1073
|
theme: viewerTheme,
|
|
1098
1074
|
interactions: null,
|
|
1099
1075
|
renderContext: "edit",
|
|
@@ -1103,678 +1079,1823 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1103
1079
|
}))))));
|
|
1104
1080
|
};
|
|
1105
1081
|
|
|
1106
|
-
EditorPreview.propTypes = propTypes$
|
|
1107
|
-
EditorPreview.defaultProps = defaultProps$
|
|
1082
|
+
EditorPreview.propTypes = propTypes$d;
|
|
1083
|
+
EditorPreview.defaultProps = defaultProps$d;
|
|
1108
1084
|
|
|
1109
|
-
var
|
|
1085
|
+
var styles$7 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
1110
1086
|
|
|
1111
|
-
var
|
|
1112
|
-
var _ref = story || {},
|
|
1113
|
-
_ref$components = _ref.components,
|
|
1114
|
-
components = _ref$components === void 0 ? [] : _ref$components,
|
|
1115
|
-
currentValue = _objectWithoutProperties(_ref, _excluded$4);
|
|
1087
|
+
var styles$6 = {"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"};
|
|
1116
1088
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1089
|
+
var styles$5 = {"button":"micromag-editor-buttons-screen-with-preview-button","placeholder":"micromag-editor-buttons-screen-with-preview-placeholder","preview":"micromag-editor-buttons-screen-with-preview-preview","screen":"micromag-editor-buttons-screen-with-preview-screen"};
|
|
1090
|
+
|
|
1091
|
+
var styles$4 = {"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"};
|
|
1092
|
+
|
|
1093
|
+
var propTypes$c = {
|
|
1094
|
+
active: PropTypes.bool,
|
|
1095
|
+
id: PropTypes.string,
|
|
1096
|
+
href: PropTypes.string,
|
|
1097
|
+
label: PropTypes$1.label,
|
|
1098
|
+
icon: PropTypes.node,
|
|
1099
|
+
title: PropTypes.string,
|
|
1100
|
+
onClick: PropTypes.func,
|
|
1101
|
+
children: PropTypes.node,
|
|
1102
|
+
refButton: PropTypes.shape({
|
|
1103
|
+
current: PropTypes.any // eslint-disable-line
|
|
1104
|
+
|
|
1105
|
+
}),
|
|
1106
|
+
className: PropTypes.string
|
|
1107
|
+
};
|
|
1108
|
+
var defaultProps$c = {
|
|
1109
|
+
active: false,
|
|
1110
|
+
id: null,
|
|
1111
|
+
href: null,
|
|
1112
|
+
label: null,
|
|
1113
|
+
icon: null,
|
|
1114
|
+
title: null,
|
|
1115
|
+
onClick: null,
|
|
1116
|
+
children: null,
|
|
1117
|
+
refButton: null,
|
|
1118
|
+
className: null
|
|
1123
1119
|
};
|
|
1124
1120
|
|
|
1125
|
-
var
|
|
1121
|
+
var ScreenButton = function ScreenButton(_ref) {
|
|
1122
|
+
var _ref2;
|
|
1126
1123
|
|
|
1127
|
-
var
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1124
|
+
var active = _ref.active,
|
|
1125
|
+
id = _ref.id,
|
|
1126
|
+
href = _ref.href,
|
|
1127
|
+
className = _ref.className,
|
|
1128
|
+
label = _ref.label,
|
|
1129
|
+
icon = _ref.icon,
|
|
1130
|
+
children = _ref.children,
|
|
1131
|
+
title = _ref.title,
|
|
1132
|
+
onClick = _ref.onClick,
|
|
1133
|
+
refButton = _ref.refButton;
|
|
1134
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1135
|
+
className: classNames([styles$4.container, 'rounded', (_ref2 = {}, _defineProperty(_ref2, styles$4.active, active), _defineProperty(_ref2, className, className !== null), _ref2)])
|
|
1136
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1137
|
+
className: styles$4.screen
|
|
1138
|
+
}, children !== null ? children : /*#__PURE__*/React.createElement("div", {
|
|
1139
|
+
className: styles$4.inner
|
|
1140
|
+
}, icon !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1141
|
+
className: styles$4.icon
|
|
1142
|
+
}, icon) : null, label !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1143
|
+
className: styles$4.label
|
|
1144
|
+
}, label) : null)), /*#__PURE__*/React.createElement(Button, {
|
|
1145
|
+
className: styles$4.button,
|
|
1146
|
+
withoutStyle: true,
|
|
1147
|
+
id: id,
|
|
1148
|
+
href: href,
|
|
1149
|
+
title: title,
|
|
1150
|
+
onClick: onClick,
|
|
1151
|
+
refButton: refButton
|
|
1152
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1153
|
+
className: classNames([styles$4.border, 'rounded'])
|
|
1154
|
+
})));
|
|
1155
|
+
};
|
|
1132
1156
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
return
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1157
|
+
ScreenButton.propTypes = propTypes$c;
|
|
1158
|
+
ScreenButton.defaultProps = defaultProps$c;
|
|
1159
|
+
var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
1160
|
+
return /*#__PURE__*/React.createElement(ScreenButton, Object.assign({}, props, {
|
|
1161
|
+
refButton: ref
|
|
1162
|
+
}));
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
var propTypes$b = {
|
|
1166
|
+
screen: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
1167
|
+
index: PropTypes.number.isRequired,
|
|
1168
|
+
title: PropTypes.string,
|
|
1169
|
+
previewStyle: PropTypes.shape({
|
|
1170
|
+
width: PropTypes.number,
|
|
1171
|
+
height: PropTypes.number
|
|
1172
|
+
}),
|
|
1173
|
+
withPreview: PropTypes.bool,
|
|
1174
|
+
withPlaceholder: PropTypes.bool,
|
|
1175
|
+
onClick: PropTypes.func,
|
|
1176
|
+
onClickItem: PropTypes.func,
|
|
1177
|
+
buttonClassName: PropTypes.string,
|
|
1178
|
+
className: PropTypes.string
|
|
1179
|
+
};
|
|
1180
|
+
var defaultProps$b = {
|
|
1181
|
+
screen: null,
|
|
1182
|
+
title: null,
|
|
1183
|
+
previewStyle: null,
|
|
1184
|
+
withPreview: true,
|
|
1185
|
+
withPlaceholder: false,
|
|
1186
|
+
onClick: null,
|
|
1187
|
+
onClickItem: null,
|
|
1188
|
+
buttonClassName: null,
|
|
1189
|
+
className: null
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
1193
|
+
var _ref3;
|
|
1194
|
+
|
|
1195
|
+
var screen = _ref.screen,
|
|
1196
|
+
index = _ref.index,
|
|
1197
|
+
title = _ref.title,
|
|
1198
|
+
className = _ref.className,
|
|
1199
|
+
buttonClassName = _ref.buttonClassName,
|
|
1200
|
+
previewStyle = _ref.previewStyle,
|
|
1201
|
+
_onClick = _ref.onClick,
|
|
1202
|
+
onClickItem = _ref.onClickItem,
|
|
1203
|
+
withPreview = _ref.withPreview,
|
|
1204
|
+
withPlaceholder = _ref.withPlaceholder;
|
|
1205
|
+
var intl = useIntl();
|
|
1206
|
+
|
|
1207
|
+
var _ref2 = previewStyle || {},
|
|
1208
|
+
_ref2$width = _ref2.width,
|
|
1209
|
+
width = _ref2$width === void 0 ? null : _ref2$width,
|
|
1210
|
+
_ref2$height = _ref2.height,
|
|
1211
|
+
height = _ref2$height === void 0 ? null : _ref2$height;
|
|
1212
|
+
|
|
1213
|
+
return /*#__PURE__*/React.createElement(ScreenButton$1, Object.assign({}, screen, {
|
|
1214
|
+
className: classNames([styles$5.button, (_ref3 = {}, _defineProperty(_ref3, buttonClassName, buttonClassName !== null), _defineProperty(_ref3, className, className !== null), _ref3)]),
|
|
1215
|
+
title: isMessage(title) ? intl.formatMessage(title) : null,
|
|
1216
|
+
onClick: function onClick() {
|
|
1217
|
+
if (_onClick !== null) {
|
|
1218
|
+
_onClick(screen, index);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
if (onClickItem !== null) {
|
|
1222
|
+
onClickItem(screen, index);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}), withPreview && !withPlaceholder ? /*#__PURE__*/React.createElement("div", {
|
|
1226
|
+
className: styles$5.preview,
|
|
1227
|
+
style: previewStyle
|
|
1228
|
+
}, /*#__PURE__*/React.createElement(ScreenPreview, {
|
|
1229
|
+
screen: screen,
|
|
1230
|
+
width: width,
|
|
1231
|
+
height: height,
|
|
1232
|
+
className: styles$5.screen
|
|
1233
|
+
})) : null, withPlaceholder && !withPreview ? /*#__PURE__*/React.createElement("div", {
|
|
1234
|
+
className: styles$5.placeholder,
|
|
1235
|
+
style: previewStyle
|
|
1236
|
+
}, /*#__PURE__*/React.createElement(ScreenPlaceholder, {
|
|
1237
|
+
screen: screen,
|
|
1238
|
+
width: width,
|
|
1239
|
+
height: height,
|
|
1240
|
+
className: styles$5.screen
|
|
1241
|
+
})) : null);
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
ScreenWithPreview.propTypes = propTypes$b;
|
|
1245
|
+
ScreenWithPreview.defaultProps = defaultProps$b;
|
|
1246
|
+
|
|
1247
|
+
var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
1248
|
+
function getDragDepth(offset, indentationWidth) {
|
|
1249
|
+
return Math.round(offset / indentationWidth);
|
|
1250
|
+
}
|
|
1251
|
+
function getMaxDepth(_ref) {
|
|
1252
|
+
var previousItem = _ref.previousItem;
|
|
1253
|
+
|
|
1254
|
+
if (previousItem) {
|
|
1255
|
+
// return previousItem.depth + 1;
|
|
1256
|
+
return 1;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
return 0;
|
|
1260
|
+
}
|
|
1261
|
+
function getMinDepth(_ref2) {
|
|
1262
|
+
var nextItem = _ref2.nextItem;
|
|
1263
|
+
|
|
1264
|
+
if (nextItem) {
|
|
1265
|
+
// return nextItem.depth;
|
|
1266
|
+
return 0;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
return 0;
|
|
1270
|
+
}
|
|
1271
|
+
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
1272
|
+
var overItemIndex = items.findIndex(function (_ref3) {
|
|
1273
|
+
var id = _ref3.id;
|
|
1274
|
+
return id === overId;
|
|
1275
|
+
});
|
|
1276
|
+
var activeItemIndex = items.findIndex(function (_ref4) {
|
|
1277
|
+
var id = _ref4.id;
|
|
1278
|
+
return id === activeId;
|
|
1279
|
+
});
|
|
1280
|
+
var activeItem = items[activeItemIndex];
|
|
1281
|
+
var newItems = arrayMove(items, activeItemIndex, overItemIndex);
|
|
1282
|
+
var previousItem = newItems[overItemIndex - 1];
|
|
1283
|
+
var nextItem = newItems[overItemIndex + 1];
|
|
1284
|
+
var dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
1285
|
+
var projectedDepth = activeItem.depth + dragDepth;
|
|
1286
|
+
var maxDepth = getMaxDepth({
|
|
1287
|
+
previousItem: previousItem
|
|
1288
|
+
});
|
|
1289
|
+
var minDepth = getMinDepth({
|
|
1290
|
+
nextItem: nextItem
|
|
1291
|
+
});
|
|
1292
|
+
var depth = projectedDepth;
|
|
1293
|
+
|
|
1294
|
+
if (projectedDepth >= maxDepth) {
|
|
1295
|
+
depth = maxDepth;
|
|
1296
|
+
} else if (projectedDepth < minDepth) {
|
|
1297
|
+
depth = minDepth;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
function getParentId() {
|
|
1301
|
+
var _newItems$slice$rever;
|
|
1302
|
+
|
|
1303
|
+
if (depth === 0 || !previousItem) {
|
|
1304
|
+
return null;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
if (depth === previousItem.depth) {
|
|
1308
|
+
return previousItem.parentId;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
if (depth > previousItem.depth) {
|
|
1312
|
+
return previousItem.id;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
var newParent = (_newItems$slice$rever = newItems.slice(0, overItemIndex).reverse().find(function (item) {
|
|
1316
|
+
return item.depth === depth;
|
|
1317
|
+
})) === null || _newItems$slice$rever === void 0 ? void 0 : _newItems$slice$rever.parentId;
|
|
1318
|
+
return newParent !== null && newParent !== void 0 ? newParent : null;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
return {
|
|
1322
|
+
depth: depth,
|
|
1323
|
+
maxDepth: maxDepth,
|
|
1324
|
+
minDepth: minDepth,
|
|
1325
|
+
parentId: getParentId()
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function flatten(items) {
|
|
1330
|
+
var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1331
|
+
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1332
|
+
return items.reduce(function (acc, item, index) {
|
|
1333
|
+
return [].concat(_toConsumableArray(acc), [_objectSpread(_objectSpread({}, item), {}, {
|
|
1334
|
+
parentId: item.parentId || parentId,
|
|
1335
|
+
depth: item.parentId ? 1 : 0,
|
|
1336
|
+
index: index
|
|
1337
|
+
})], _toConsumableArray(flatten(item.children || [], item.id, depth + 1)));
|
|
1338
|
+
}, []);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
function flattenTree(items) {
|
|
1342
|
+
return flatten(items);
|
|
1343
|
+
}
|
|
1344
|
+
function findItem(items, itemId) {
|
|
1345
|
+
return items.find(function (_ref5) {
|
|
1346
|
+
var id = _ref5.id;
|
|
1347
|
+
return id === itemId;
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
function buildTree(flattenedItems) {
|
|
1351
|
+
var root = {
|
|
1352
|
+
id: 'root',
|
|
1353
|
+
children: []
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
var nodes = _defineProperty({}, root.id, root);
|
|
1357
|
+
|
|
1358
|
+
var items = flattenedItems.map(function (item) {
|
|
1359
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1360
|
+
children: []
|
|
1361
|
+
});
|
|
1362
|
+
}); // eslint-disable-next-line no-restricted-syntax
|
|
1363
|
+
|
|
1364
|
+
var _iterator = _createForOfIteratorHelper(items),
|
|
1365
|
+
_step;
|
|
1366
|
+
|
|
1367
|
+
try {
|
|
1368
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1369
|
+
var _item$parentId, _nodes$parentId;
|
|
1370
|
+
|
|
1371
|
+
var item = _step.value;
|
|
1372
|
+
var id = item.id,
|
|
1373
|
+
children = item.children;
|
|
1374
|
+
var parentId = (_item$parentId = item.parentId) !== null && _item$parentId !== void 0 ? _item$parentId : root.id;
|
|
1375
|
+
var parent = (_nodes$parentId = nodes[parentId]) !== null && _nodes$parentId !== void 0 ? _nodes$parentId : findItem(items, parentId);
|
|
1376
|
+
nodes[id] = {
|
|
1377
|
+
id: id,
|
|
1378
|
+
children: children
|
|
1379
|
+
};
|
|
1380
|
+
parent.children.push(item);
|
|
1381
|
+
}
|
|
1382
|
+
} catch (err) {
|
|
1383
|
+
_iterator.e(err);
|
|
1384
|
+
} finally {
|
|
1385
|
+
_iterator.f();
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
return root.children;
|
|
1389
|
+
}
|
|
1390
|
+
function findItemDeep(items, itemId) {
|
|
1391
|
+
for (var i = 0; i < items.length; i += 1) {
|
|
1392
|
+
var item = items[i] || {};
|
|
1393
|
+
var id = item.id,
|
|
1394
|
+
_item$children = item.children,
|
|
1395
|
+
children = _item$children === void 0 ? [] : _item$children;
|
|
1396
|
+
|
|
1397
|
+
if (id === itemId) {
|
|
1398
|
+
return item;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
if (children.length > 0) {
|
|
1402
|
+
var child = findItemDeep(children, itemId);
|
|
1403
|
+
|
|
1404
|
+
if (child) {
|
|
1405
|
+
return child;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
return undefined;
|
|
1411
|
+
}
|
|
1412
|
+
function removeItem(items, id) {
|
|
1413
|
+
var newItems = []; // eslint-disable-next-line no-restricted-syntax
|
|
1414
|
+
|
|
1415
|
+
var _iterator2 = _createForOfIteratorHelper(items),
|
|
1416
|
+
_step2;
|
|
1417
|
+
|
|
1418
|
+
try {
|
|
1419
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1420
|
+
var item = _step2.value;
|
|
1421
|
+
|
|
1422
|
+
if (item.id === id) {
|
|
1423
|
+
// eslint-disable-next-line no-continue
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
if (item.children.length) {
|
|
1428
|
+
item.children = removeItem(item.children, id);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
newItems.push(item);
|
|
1432
|
+
}
|
|
1433
|
+
} catch (err) {
|
|
1434
|
+
_iterator2.e(err);
|
|
1435
|
+
} finally {
|
|
1436
|
+
_iterator2.f();
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
return newItems;
|
|
1440
|
+
}
|
|
1441
|
+
function setProperty(items, id, property, setter) {
|
|
1442
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1443
|
+
var _iterator3 = _createForOfIteratorHelper(items),
|
|
1444
|
+
_step3;
|
|
1445
|
+
|
|
1446
|
+
try {
|
|
1447
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1448
|
+
var item = _step3.value;
|
|
1449
|
+
|
|
1450
|
+
if (item.id === id) {
|
|
1451
|
+
item[property] = setter(item[property]); // eslint-disable-next-line no-continue
|
|
1452
|
+
|
|
1453
|
+
continue;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
if (item.children.length) {
|
|
1457
|
+
item.children = setProperty(item.children, id, property, setter);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
} catch (err) {
|
|
1461
|
+
_iterator3.e(err);
|
|
1462
|
+
} finally {
|
|
1463
|
+
_iterator3.f();
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
return _toConsumableArray(items);
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
function countChildren(items) {
|
|
1470
|
+
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1471
|
+
return items.reduce(function (acc, _ref6) {
|
|
1472
|
+
var _ref6$children = _ref6.children,
|
|
1473
|
+
children = _ref6$children === void 0 ? [] : _ref6$children;
|
|
1474
|
+
|
|
1475
|
+
if (children.length) {
|
|
1476
|
+
return countChildren(children, acc + 1);
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
return acc + 1;
|
|
1480
|
+
}, count);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
function getChildCount(items, id) {
|
|
1484
|
+
if (!id) {
|
|
1485
|
+
return 0;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
var item = findItemDeep(items, id);
|
|
1489
|
+
return item ? countChildren(item.children || []) : 0;
|
|
1490
|
+
}
|
|
1491
|
+
function removeChildrenOf(items, ids) {
|
|
1492
|
+
var excludeParentIds = _toConsumableArray(ids);
|
|
1493
|
+
|
|
1494
|
+
return items.filter(function (item) {
|
|
1495
|
+
if (item.parentId && excludeParentIds.includes(item.parentId)) {
|
|
1496
|
+
var _item$children2 = item.children,
|
|
1497
|
+
children = _item$children2 === void 0 ? [] : _item$children2;
|
|
1498
|
+
|
|
1499
|
+
if (children.length) {
|
|
1500
|
+
excludeParentIds.push(item.id);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
return false;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
return true;
|
|
1140
1507
|
});
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
var directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
|
|
1511
|
+
var horizontal = [KeyboardCode.Left, KeyboardCode.Right];
|
|
1512
|
+
var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(context, indentationWidth) {
|
|
1513
|
+
return function (event, _ref) {
|
|
1514
|
+
var currentCoordinates = _ref.currentCoordinates,
|
|
1515
|
+
_ref$context = _ref.context,
|
|
1516
|
+
active = _ref$context.active,
|
|
1517
|
+
over = _ref$context.over,
|
|
1518
|
+
collisionRect = _ref$context.collisionRect,
|
|
1519
|
+
droppableContainers = _ref$context.droppableContainers;
|
|
1520
|
+
|
|
1521
|
+
if (directions.includes(event.code)) {
|
|
1522
|
+
var _droppableContainers$;
|
|
1523
|
+
|
|
1524
|
+
if (!active || !collisionRect) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
event.preventDefault();
|
|
1529
|
+
var _context$current = context.current,
|
|
1530
|
+
items = _context$current.items,
|
|
1531
|
+
offset = _context$current.offset;
|
|
1532
|
+
|
|
1533
|
+
if (horizontal.includes(event.code) && over !== null && over !== void 0 && over.id) {
|
|
1534
|
+
var _getProjection = getProjection(items, active.id, over.id, offset, indentationWidth),
|
|
1535
|
+
depth = _getProjection.depth,
|
|
1536
|
+
maxDepth = _getProjection.maxDepth,
|
|
1537
|
+
minDepth = _getProjection.minDepth;
|
|
1538
|
+
|
|
1539
|
+
switch (event.code) {
|
|
1540
|
+
case KeyboardCode.Left:
|
|
1541
|
+
if (depth > minDepth) {
|
|
1542
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
1543
|
+
x: currentCoordinates.x - indentationWidth
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
break;
|
|
1548
|
+
|
|
1549
|
+
case KeyboardCode.Right:
|
|
1550
|
+
if (depth < maxDepth) {
|
|
1551
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
1552
|
+
x: currentCoordinates.x + indentationWidth
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
break;
|
|
1557
|
+
|
|
1558
|
+
default:
|
|
1559
|
+
return undefined;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
return undefined;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
var containers = [];
|
|
1566
|
+
var overRect = over !== null && over !== void 0 && over.id ? (_droppableContainers$ = droppableContainers.get(over.id)) === null || _droppableContainers$ === void 0 ? void 0 : _droppableContainers$.rect.current : undefined;
|
|
1567
|
+
|
|
1568
|
+
if (overRect) {
|
|
1569
|
+
droppableContainers.forEach(function (container) {
|
|
1570
|
+
if (container !== null && container !== void 0 && container.disabled) {
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
var rect = container === null || container === void 0 ? void 0 : container.rect.current;
|
|
1575
|
+
|
|
1576
|
+
if (!rect) {
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
switch (event.code) {
|
|
1581
|
+
case KeyboardCode.Down:
|
|
1582
|
+
if (overRect.top < rect.top) {
|
|
1583
|
+
containers.push(container);
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
break;
|
|
1587
|
+
|
|
1588
|
+
case KeyboardCode.Up:
|
|
1589
|
+
if (overRect.top > rect.top) {
|
|
1590
|
+
containers.push(container);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
break;
|
|
1594
|
+
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
var collisions = closestCorners({
|
|
1600
|
+
active: active,
|
|
1601
|
+
collisionRect: collisionRect,
|
|
1602
|
+
pointerCoordinates: null,
|
|
1603
|
+
droppableContainers: containers
|
|
1604
|
+
});
|
|
1605
|
+
var closestId = getFirstCollision(collisions, 'id');
|
|
1606
|
+
|
|
1607
|
+
if (closestId && over !== null && over !== void 0 && over.id) {
|
|
1608
|
+
var _droppableContainers$2, _droppableContainers$3;
|
|
1609
|
+
|
|
1610
|
+
var newNode = (_droppableContainers$2 = droppableContainers.get(closestId)) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.node.current;
|
|
1611
|
+
var activeNodeRect = (_droppableContainers$3 = droppableContainers.get(active.id)) === null || _droppableContainers$3 === void 0 ? void 0 : _droppableContainers$3.rect.current;
|
|
1612
|
+
|
|
1613
|
+
if (newNode && activeNodeRect) {
|
|
1614
|
+
var newRect = getClientRect(newNode, {
|
|
1615
|
+
ignoreTransform: true
|
|
1616
|
+
});
|
|
1617
|
+
var newItem = items.find(function (_ref2) {
|
|
1618
|
+
var id = _ref2.id;
|
|
1619
|
+
return id === closestId;
|
|
1620
|
+
});
|
|
1621
|
+
var activeItem = items.find(function (_ref3) {
|
|
1622
|
+
var id = _ref3.id;
|
|
1623
|
+
return id === active.id;
|
|
1624
|
+
});
|
|
1625
|
+
|
|
1626
|
+
if (newItem && activeItem) {
|
|
1627
|
+
var _getProjection2 = getProjection(items, active.id, closestId, (newItem.depth - activeItem.depth) * indentationWidth, indentationWidth),
|
|
1628
|
+
_depth = _getProjection2.depth;
|
|
1629
|
+
|
|
1630
|
+
var topOffset = newRect.top > activeNodeRect.top ? Math.abs(activeNodeRect.height - newRect.height) : 0;
|
|
1631
|
+
var newCoordinates = {
|
|
1632
|
+
x: newRect.left + _depth * indentationWidth,
|
|
1633
|
+
y: newRect.top + topOffset
|
|
1634
|
+
};
|
|
1635
|
+
return newCoordinates;
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
return undefined;
|
|
1642
|
+
};
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1645
|
+
var styles$3 = {"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","withChildren":"micromag-editor-sortable-sortable-tree-item-actions-withChildren","clone":"micromag-editor-sortable-sortable-tree-item-actions-clone","ghost":"micromag-editor-sortable-sortable-tree-item-actions-ghost","indicator":"micromag-editor-sortable-sortable-tree-item-actions-indicator","text":"micromag-editor-sortable-sortable-tree-item-actions-text","collapsedCount":"micromag-editor-sortable-sortable-tree-item-actions-collapsedCount","count":"micromag-editor-sortable-sortable-tree-item-actions-count","disableInteraction":"micromag-editor-sortable-sortable-tree-item-actions-disableInteraction","Count":"micromag-editor-sortable-sortable-tree-item-actions-Count","Text":"micromag-editor-sortable-sortable-tree-item-actions-Text","disableSelection":"micromag-editor-sortable-sortable-tree-item-actions-disableSelection","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"};
|
|
1646
|
+
|
|
1647
|
+
var _excluded$4 = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "onClick", "style", "value", "wrapperRef", "showId", "children"];
|
|
1648
|
+
var propTypes$a = {
|
|
1649
|
+
childCount: PropTypes.number,
|
|
1650
|
+
clone: PropTypes.bool,
|
|
1651
|
+
collapsed: PropTypes.bool,
|
|
1652
|
+
depth: PropTypes.number.isRequired,
|
|
1653
|
+
disableInteraction: PropTypes.bool,
|
|
1654
|
+
disableSelection: PropTypes.bool,
|
|
1655
|
+
ghost: PropTypes.bool,
|
|
1656
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1657
|
+
handleProps: PropTypes.any,
|
|
1658
|
+
indicator: PropTypes.bool,
|
|
1659
|
+
indentationWidth: PropTypes.number.isRequired,
|
|
1660
|
+
value: PropTypes.string,
|
|
1661
|
+
onCollapse: PropTypes.func,
|
|
1662
|
+
onRemove: PropTypes.func,
|
|
1663
|
+
onClick: PropTypes.func,
|
|
1664
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1665
|
+
wrapperRef: PropTypes.any,
|
|
1666
|
+
style: PropTypes.shape({
|
|
1667
|
+
width: PropTypes.number.isRequired,
|
|
1668
|
+
height: PropTypes.number.isRequired,
|
|
1669
|
+
transform: PropTypes.string.isRequired
|
|
1670
|
+
}),
|
|
1671
|
+
showId: PropTypes.bool,
|
|
1672
|
+
children: PropTypes.node
|
|
1673
|
+
};
|
|
1674
|
+
var defaultProps$a = {
|
|
1675
|
+
childCount: null,
|
|
1676
|
+
clone: false,
|
|
1677
|
+
collapsed: false,
|
|
1678
|
+
disableInteraction: false,
|
|
1679
|
+
disableSelection: false,
|
|
1680
|
+
ghost: false,
|
|
1681
|
+
handleProps: null,
|
|
1682
|
+
indicator: false,
|
|
1683
|
+
value: null,
|
|
1684
|
+
onCollapse: null,
|
|
1685
|
+
onRemove: null,
|
|
1686
|
+
onClick: null,
|
|
1687
|
+
wrapperRef: null,
|
|
1688
|
+
style: null,
|
|
1689
|
+
showId: false,
|
|
1690
|
+
children: null
|
|
1691
|
+
};
|
|
1692
|
+
var SortableTreeItemActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
1693
|
+
var _ref2;
|
|
1694
|
+
|
|
1695
|
+
var childCount = _ref.childCount,
|
|
1696
|
+
clone = _ref.clone,
|
|
1697
|
+
depth = _ref.depth,
|
|
1698
|
+
disableSelection = _ref.disableSelection,
|
|
1699
|
+
disableInteraction = _ref.disableInteraction,
|
|
1700
|
+
ghost = _ref.ghost,
|
|
1701
|
+
handleProps = _ref.handleProps,
|
|
1702
|
+
indentationWidth = _ref.indentationWidth,
|
|
1703
|
+
indicator = _ref.indicator,
|
|
1704
|
+
collapsed = _ref.collapsed,
|
|
1705
|
+
onCollapse = _ref.onCollapse,
|
|
1706
|
+
onRemove = _ref.onRemove;
|
|
1707
|
+
_ref.onClick;
|
|
1708
|
+
var style = _ref.style;
|
|
1709
|
+
_ref.value;
|
|
1710
|
+
var wrapperRef = _ref.wrapperRef;
|
|
1711
|
+
_ref.showId;
|
|
1712
|
+
var children = _ref.children,
|
|
1713
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
1714
|
+
|
|
1715
|
+
return /*#__PURE__*/React.createElement("li", Object.assign({
|
|
1716
|
+
className: classNames([styles$3.wrapper, (_ref2 = {}, _defineProperty(_ref2, styles$3.clone, clone), _defineProperty(_ref2, styles$3.ghost, ghost), _defineProperty(_ref2, styles$3.indicator, indicator), _defineProperty(_ref2, styles$3.disableSelection, disableSelection), _defineProperty(_ref2, styles$3.disableInteraction, disableInteraction), _defineProperty(_ref2, styles$3.withChildren, onCollapse !== null), _ref2)]),
|
|
1717
|
+
ref: wrapperRef,
|
|
1718
|
+
style: _objectSpread({
|
|
1719
|
+
marginLeft: "".concat(indentationWidth * depth, "px")
|
|
1720
|
+
}, style)
|
|
1721
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
1722
|
+
className: styles$3.inner,
|
|
1723
|
+
ref: ref,
|
|
1724
|
+
style: {
|
|
1725
|
+
width: style.width,
|
|
1726
|
+
height: style.height
|
|
1727
|
+
}
|
|
1728
|
+
}, /*#__PURE__*/React.createElement("button", Object.assign({
|
|
1729
|
+
className: classNames([styles$3.button, styles$3.handle]),
|
|
1730
|
+
type: "button"
|
|
1731
|
+
}, handleProps), /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1732
|
+
className: styles$3.icon,
|
|
1733
|
+
icon: faGripLines
|
|
1734
|
+
})), !clone && onRemove ? /*#__PURE__*/React.createElement("button", {
|
|
1735
|
+
type: "button",
|
|
1736
|
+
onClick: onRemove
|
|
1737
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1738
|
+
icon: faTimes
|
|
1739
|
+
})) : null, clone && childCount && childCount > 1 ? /*#__PURE__*/React.createElement("span", {
|
|
1740
|
+
className: styles$3.count
|
|
1741
|
+
}, childCount) : null, onCollapse && childCount !== null && childCount > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
1742
|
+
className: styles$3.collapsedCount
|
|
1743
|
+
}, childCount) : null, onCollapse && depth === 0 ? /*#__PURE__*/React.createElement("button", {
|
|
1744
|
+
type: "button",
|
|
1745
|
+
onClick: onCollapse,
|
|
1746
|
+
className: classNames(styles$3.button, styles$3.collapse, collapsed && styles$3.collapsed),
|
|
1747
|
+
style: {
|
|
1748
|
+
width: style.width
|
|
1749
|
+
}
|
|
1750
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1751
|
+
icon: faAngleDown
|
|
1752
|
+
})) : null), /*#__PURE__*/React.createElement("div", {
|
|
1753
|
+
className: styles$3.children
|
|
1754
|
+
}, children));
|
|
1755
|
+
});
|
|
1756
|
+
SortableTreeItemActions.propTypes = propTypes$a;
|
|
1757
|
+
SortableTreeItemActions.defaultProps = defaultProps$a;
|
|
1758
|
+
|
|
1759
|
+
var _excluded$3 = ["id", "index", "depth", "component", "value", "style", "smallScale", "onCollapse", "onClickItem"];
|
|
1760
|
+
var propTypes$9 = {
|
|
1761
|
+
id: PropTypes.string.isRequired,
|
|
1762
|
+
index: PropTypes.number.isRequired,
|
|
1763
|
+
depth: PropTypes.number.isRequired,
|
|
1764
|
+
component: PropTypes.func,
|
|
1765
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1766
|
+
value: PropTypes.object,
|
|
1767
|
+
style: PropTypes.shape({
|
|
1768
|
+
width: PropTypes.number.isRequired,
|
|
1769
|
+
height: PropTypes.number.isRequired,
|
|
1770
|
+
scaledWidth: PropTypes.number.isRequired,
|
|
1771
|
+
scaledHeight: PropTypes.number.isRequired,
|
|
1772
|
+
transform: PropTypes.string.isRequired,
|
|
1773
|
+
scale: PropTypes.number.isRequired
|
|
1774
|
+
}),
|
|
1775
|
+
smallScale: PropTypes.number,
|
|
1776
|
+
onCollapse: PropTypes.func,
|
|
1777
|
+
onClickItem: PropTypes.func
|
|
1778
|
+
};
|
|
1779
|
+
var defaultProps$9 = {
|
|
1780
|
+
component: null,
|
|
1781
|
+
value: null,
|
|
1782
|
+
style: null,
|
|
1783
|
+
smallScale: 0.75,
|
|
1784
|
+
onCollapse: null,
|
|
1785
|
+
onClickItem: null
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
var animateLayoutChanges = function animateLayoutChanges(_ref) {
|
|
1789
|
+
var isSorting = _ref.isSorting,
|
|
1790
|
+
wasDragging = _ref.wasDragging;
|
|
1791
|
+
return !(isSorting || wasDragging);
|
|
1141
1792
|
};
|
|
1142
1793
|
|
|
1143
|
-
var
|
|
1794
|
+
var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
1795
|
+
var id = _ref2.id,
|
|
1796
|
+
index = _ref2.index,
|
|
1797
|
+
depth = _ref2.depth,
|
|
1798
|
+
Component = _ref2.component,
|
|
1799
|
+
value = _ref2.value,
|
|
1800
|
+
itemStyle = _ref2.style,
|
|
1801
|
+
smallScale = _ref2.smallScale,
|
|
1802
|
+
onCollapse = _ref2.onCollapse,
|
|
1803
|
+
onClickItem = _ref2.onClickItem,
|
|
1804
|
+
props = _objectWithoutProperties(_ref2, _excluded$3);
|
|
1805
|
+
|
|
1806
|
+
var _useSortable = useSortable({
|
|
1807
|
+
id: id,
|
|
1808
|
+
animateLayoutChanges: animateLayoutChanges
|
|
1809
|
+
}),
|
|
1810
|
+
attributes = _useSortable.attributes,
|
|
1811
|
+
isDragging = _useSortable.isDragging,
|
|
1812
|
+
isSorting = _useSortable.isSorting,
|
|
1813
|
+
listeners = _useSortable.listeners,
|
|
1814
|
+
setDraggableNodeRef = _useSortable.setDraggableNodeRef,
|
|
1815
|
+
setDroppableNodeRef = _useSortable.setDroppableNodeRef,
|
|
1816
|
+
transform = _useSortable.transform,
|
|
1817
|
+
transition = _useSortable.transition;
|
|
1818
|
+
|
|
1819
|
+
var hasCollapse = onCollapse !== null;
|
|
1820
|
+
var _itemStyle$scaledWidt = itemStyle.scaledWidth,
|
|
1821
|
+
scaledWidth = _itemStyle$scaledWidt === void 0 ? 100 : _itemStyle$scaledWidt,
|
|
1822
|
+
_itemStyle$scaledHeig = itemStyle.scaledHeight,
|
|
1823
|
+
scaledHeight = _itemStyle$scaledHeig === void 0 ? 66 : _itemStyle$scaledHeig,
|
|
1824
|
+
_itemStyle$scale = itemStyle.scale,
|
|
1825
|
+
scale = _itemStyle$scale === void 0 ? 1 : _itemStyle$scale;
|
|
1826
|
+
var extraHeight = hasCollapse ? 30 : 0;
|
|
1827
|
+
var actionsStyle = {
|
|
1828
|
+
width: depth === 0 ? scaledWidth : scaledWidth * smallScale,
|
|
1829
|
+
height: depth === 0 ? scaledHeight + extraHeight : scaledHeight * smallScale,
|
|
1830
|
+
transform: CSS.Translate.toString(transform),
|
|
1831
|
+
transition: transition
|
|
1832
|
+
};
|
|
1833
|
+
var previewStyle = {
|
|
1834
|
+
width: itemStyle.width,
|
|
1835
|
+
height: itemStyle.height,
|
|
1836
|
+
transform: depth === 0 ? itemStyle.transform : "scale(".concat(scale * smallScale, ", ").concat(scale * smallScale, ")")
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
var _ref3 = listeners || {},
|
|
1840
|
+
onPointerDown = _ref3.onPointerDown;
|
|
1144
1841
|
|
|
1145
|
-
var
|
|
1146
|
-
|
|
1842
|
+
var onClickAction = useCallback(function (e) {
|
|
1843
|
+
if (onClickItem !== null) {
|
|
1844
|
+
onClickItem(value, index);
|
|
1845
|
+
}
|
|
1147
1846
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1847
|
+
if (onPointerDown !== null) {
|
|
1848
|
+
onPointerDown(e);
|
|
1849
|
+
}
|
|
1850
|
+
}, [value, index, onClickItem, onPointerDown]);
|
|
1851
|
+
return /*#__PURE__*/React.createElement(SortableTreeItemActions, Object.assign({
|
|
1852
|
+
ref: setDraggableNodeRef,
|
|
1853
|
+
wrapperRef: setDroppableNodeRef,
|
|
1854
|
+
style: actionsStyle,
|
|
1855
|
+
depth: depth,
|
|
1856
|
+
ghost: isDragging,
|
|
1857
|
+
disableSelection: iOS,
|
|
1858
|
+
disableInteraction: isSorting,
|
|
1859
|
+
handleProps: _objectSpread(_objectSpread(_objectSpread({}, attributes), listeners), {}, {
|
|
1860
|
+
onPointerDown: onClickAction
|
|
1861
|
+
}),
|
|
1862
|
+
onCollapse: onCollapse
|
|
1863
|
+
}, props), Component !== null ? /*#__PURE__*/React.createElement(Component, Object.assign({}, value, {
|
|
1864
|
+
previewStyle: previewStyle
|
|
1865
|
+
})) : null);
|
|
1866
|
+
};
|
|
1867
|
+
SortableTreeItem.propTypes = propTypes$9;
|
|
1868
|
+
SortableTreeItem.defaultProps = defaultProps$9;
|
|
1869
|
+
|
|
1870
|
+
var initialItems = [{
|
|
1871
|
+
id: 'Home',
|
|
1872
|
+
children: []
|
|
1873
|
+
}, {
|
|
1874
|
+
id: 'Collections',
|
|
1875
|
+
children: [{
|
|
1876
|
+
id: 'Spring',
|
|
1877
|
+
children: []
|
|
1878
|
+
}, {
|
|
1879
|
+
id: 'Summer',
|
|
1880
|
+
children: []
|
|
1881
|
+
}, {
|
|
1882
|
+
id: 'Fall',
|
|
1883
|
+
children: []
|
|
1884
|
+
}, {
|
|
1885
|
+
id: 'Winter',
|
|
1886
|
+
children: []
|
|
1887
|
+
}]
|
|
1888
|
+
}, {
|
|
1889
|
+
id: 'About Us',
|
|
1890
|
+
children: []
|
|
1891
|
+
}, {
|
|
1892
|
+
id: 'My Account',
|
|
1893
|
+
children: [{
|
|
1894
|
+
id: 'Addresses',
|
|
1895
|
+
children: []
|
|
1896
|
+
}, {
|
|
1897
|
+
id: 'Order History',
|
|
1898
|
+
children: []
|
|
1899
|
+
}]
|
|
1900
|
+
}];
|
|
1901
|
+
var measuring = {
|
|
1902
|
+
droppable: {
|
|
1903
|
+
strategy: MeasuringStrategy.Always
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
var dropAnimation = _objectSpread(_objectSpread({}, defaultDropAnimation), {}, {
|
|
1908
|
+
dragSourceOpacity: 0.5
|
|
1909
|
+
});
|
|
1152
1910
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
})
|
|
1156
|
-
|
|
1157
|
-
components: [].concat(_toConsumableArray(components.slice(0, index)), [_objectSpread(_objectSpread({}, components[index]), newScreenValue)], _toConsumableArray(components.slice(index + 1)))
|
|
1911
|
+
var adjustTranslate = function adjustTranslate(_ref) {
|
|
1912
|
+
var transform = _ref.transform;
|
|
1913
|
+
return _objectSpread(_objectSpread({}, transform), {}, {
|
|
1914
|
+
y: transform.y - 25
|
|
1158
1915
|
});
|
|
1159
1916
|
};
|
|
1160
1917
|
|
|
1161
|
-
var
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1918
|
+
var propTypes$8 = {
|
|
1919
|
+
collapsible: PropTypes.bool,
|
|
1920
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1921
|
+
items: PropTypes.array,
|
|
1922
|
+
indentationWidth: PropTypes.number,
|
|
1923
|
+
indicator: PropTypes.bool,
|
|
1924
|
+
removable: PropTypes.bool,
|
|
1925
|
+
component: PropTypes.func,
|
|
1926
|
+
itemStyle: PropTypes.shape({}),
|
|
1927
|
+
onClickItem: PropTypes.func,
|
|
1928
|
+
onChange: PropTypes.func
|
|
1929
|
+
};
|
|
1930
|
+
var defaultProps$8 = {
|
|
1931
|
+
collapsible: true,
|
|
1932
|
+
items: initialItems,
|
|
1933
|
+
indentationWidth: 30,
|
|
1934
|
+
indicator: false,
|
|
1935
|
+
removable: false,
|
|
1936
|
+
component: null,
|
|
1937
|
+
itemStyle: null,
|
|
1938
|
+
onClickItem: null,
|
|
1939
|
+
onChange: null
|
|
1940
|
+
};
|
|
1941
|
+
var SortableTree = function SortableTree(_ref2) {
|
|
1942
|
+
var collapsible = _ref2.collapsible,
|
|
1943
|
+
defaultItems = _ref2.items,
|
|
1944
|
+
indicator = _ref2.indicator,
|
|
1945
|
+
indentationWidth = _ref2.indentationWidth,
|
|
1946
|
+
removable = _ref2.removable,
|
|
1947
|
+
component = _ref2.component,
|
|
1948
|
+
itemStyle = _ref2.itemStyle,
|
|
1949
|
+
onClickItem = _ref2.onClickItem,
|
|
1950
|
+
onChange = _ref2.onChange;
|
|
1951
|
+
|
|
1952
|
+
var _useState = useState(function () {
|
|
1953
|
+
return defaultItems;
|
|
1954
|
+
}),
|
|
1955
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1956
|
+
items = _useState2[0],
|
|
1957
|
+
setItems = _useState2[1];
|
|
1171
1958
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1959
|
+
var _useState3 = useState(null),
|
|
1960
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1961
|
+
activeId = _useState4[0],
|
|
1962
|
+
setActiveId = _useState4[1];
|
|
1175
1963
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1964
|
+
var _useState5 = useState(null),
|
|
1965
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1966
|
+
overId = _useState6[0],
|
|
1967
|
+
setOverId = _useState6[1];
|
|
1179
1968
|
|
|
1180
|
-
var
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1969
|
+
var _useState7 = useState(0),
|
|
1970
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1971
|
+
offsetLeft = _useState8[0],
|
|
1972
|
+
setOffsetLeft = _useState8[1];
|
|
1973
|
+
|
|
1974
|
+
var _useState9 = useState(null),
|
|
1975
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
1976
|
+
currentPosition = _useState10[0],
|
|
1977
|
+
setCurrentPosition = _useState10[1];
|
|
1978
|
+
|
|
1979
|
+
var flattenedItems = useMemo(function () {
|
|
1980
|
+
var flattenedTree = flattenTree(items); // console.log('yo', items, flattenedTree);
|
|
1981
|
+
|
|
1982
|
+
var collapsedItems = flattenedTree.reduce(function (acc, _ref3) {
|
|
1983
|
+
var _ref3$children = _ref3.children,
|
|
1984
|
+
children = _ref3$children === void 0 ? [] : _ref3$children,
|
|
1985
|
+
collapsed = _ref3.collapsed,
|
|
1986
|
+
id = _ref3.id;
|
|
1987
|
+
return collapsed && children.length ? [].concat(_toConsumableArray(acc), [id]) : acc;
|
|
1988
|
+
}, []) || null;
|
|
1989
|
+
return removeChildrenOf(flattenedTree, activeId ? [activeId].concat(_toConsumableArray(collapsedItems)) : collapsedItems);
|
|
1990
|
+
}, [activeId, items]);
|
|
1991
|
+
var projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth) : null;
|
|
1992
|
+
var sensorContext = useRef({
|
|
1993
|
+
items: flattenedItems,
|
|
1994
|
+
offset: offsetLeft
|
|
1184
1995
|
});
|
|
1185
|
-
var direction = useMemo(function () {
|
|
1186
|
-
var _lastPageRef$current = lastPageRef.current,
|
|
1187
|
-
lastScreenIndex = _lastPageRef$current.screenIndex,
|
|
1188
|
-
lastUrl = _lastPageRef$current.url;
|
|
1189
|
-
lastPageRef.current.url = url;
|
|
1190
|
-
lastPageRef.current.screenIndex = screenIndex;
|
|
1191
|
-
|
|
1192
|
-
if (screenIndex !== lastScreenIndex) {
|
|
1193
|
-
// return screenIndex > lastScreenIndex ? 'bottom' : 'top';
|
|
1194
|
-
return null;
|
|
1195
|
-
}
|
|
1196
1996
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
var wasSettings = lastUrlSplit[previousPartsCount - 1] === 'settings';
|
|
1203
|
-
currentPartsCount -= isSettings ? 1 : 0;
|
|
1204
|
-
previousPartsCount -= wasSettings ? 1 : 0;
|
|
1205
|
-
return currentPartsCount >= previousPartsCount ? 'right' : 'left';
|
|
1206
|
-
}, [url, screenIndex]);
|
|
1207
|
-
var name = useMemo(function () {
|
|
1208
|
-
var _classNames, _classNames2, _classNames3;
|
|
1997
|
+
var _useState11 = useState(function () {
|
|
1998
|
+
return sortableTreeKeyboardCoordinates(sensorContext, indentationWidth);
|
|
1999
|
+
}),
|
|
2000
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
2001
|
+
coordinateGetter = _useState12[0];
|
|
1209
2002
|
|
|
2003
|
+
var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
2004
|
+
coordinateGetter: coordinateGetter
|
|
2005
|
+
}));
|
|
2006
|
+
var sortedIds = useMemo(function () {
|
|
2007
|
+
return flattenedItems.map(function (_ref4) {
|
|
2008
|
+
var id = _ref4.id;
|
|
2009
|
+
return id;
|
|
2010
|
+
});
|
|
2011
|
+
}, [flattenedItems]);
|
|
2012
|
+
var activeItem = activeId ? flattenedItems.find(function (_ref5) {
|
|
2013
|
+
var id = _ref5.id;
|
|
2014
|
+
return id === activeId;
|
|
2015
|
+
}) : null;
|
|
2016
|
+
useEffect(function () {
|
|
2017
|
+
sensorContext.current = {
|
|
2018
|
+
items: flattenedItems,
|
|
2019
|
+
offset: offsetLeft
|
|
2020
|
+
};
|
|
2021
|
+
}, [flattenedItems, offsetLeft]);
|
|
2022
|
+
var announcements = useMemo(function () {
|
|
1210
2023
|
return {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
2024
|
+
onDragStart: function onDragStart(id) {
|
|
2025
|
+
return "Picked up ".concat(id, ".");
|
|
2026
|
+
},
|
|
2027
|
+
onDragMove: function onDragMove(id, currentOverId) {
|
|
2028
|
+
return getMovementAnnouncement('onDragMove', id, currentOverId);
|
|
2029
|
+
},
|
|
2030
|
+
onDragOver: function onDragOver(id, currentOverId) {
|
|
2031
|
+
return getMovementAnnouncement('onDragOver', id, currentOverId);
|
|
2032
|
+
},
|
|
2033
|
+
onDragEnd: function onDragEnd(id, currentOverId) {
|
|
2034
|
+
// console.log('drag end', flattenedItems);
|
|
2035
|
+
if (onChange !== null) {
|
|
2036
|
+
onChange((flattenedItems || []).map(function (_ref6) {
|
|
2037
|
+
var itemId = _ref6.id,
|
|
2038
|
+
_ref6$children = _ref6.children,
|
|
2039
|
+
children = _ref6$children === void 0 ? [] : _ref6$children,
|
|
2040
|
+
_ref6$parentId = _ref6.parentId,
|
|
2041
|
+
parentId = _ref6$parentId === void 0 ? null : _ref6$parentId,
|
|
2042
|
+
_ref6$collapsed = _ref6.collapsed,
|
|
2043
|
+
collapsed = _ref6$collapsed === void 0 ? false : _ref6$collapsed;
|
|
2044
|
+
return {
|
|
2045
|
+
id: itemId,
|
|
2046
|
+
props: _objectSpread(_objectSpread({}, (children || []).length > 0 ? {
|
|
2047
|
+
group: {
|
|
2048
|
+
collapsed: collapsed,
|
|
2049
|
+
mergeNavItems: true
|
|
2050
|
+
}
|
|
2051
|
+
} : {
|
|
2052
|
+
group: null
|
|
2053
|
+
}), parentId !== null ? {
|
|
2054
|
+
parentId: parentId
|
|
2055
|
+
} : {
|
|
2056
|
+
parentId: null
|
|
2057
|
+
})
|
|
2058
|
+
};
|
|
2059
|
+
}));
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
return getMovementAnnouncement('onDragEnd', id, currentOverId);
|
|
2063
|
+
},
|
|
2064
|
+
onDragCancel: function onDragCancel(id) {
|
|
2065
|
+
return "Moving was cancelled. ".concat(id, " was dropped in its original position.");
|
|
2066
|
+
}
|
|
1215
2067
|
};
|
|
1216
|
-
}, [
|
|
1217
|
-
return {
|
|
1218
|
-
direction: direction,
|
|
1219
|
-
name: name,
|
|
1220
|
-
timeout: direction === 'left' || direction === 'right' ? 300 : 10
|
|
1221
|
-
};
|
|
1222
|
-
};
|
|
2068
|
+
}, [flattenedItems, onChange]); // Initial tree setup from list
|
|
1223
2069
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
2070
|
+
useEffect(function () {
|
|
2071
|
+
// console.log('fuck off');
|
|
2072
|
+
setItems(buildTree(defaultItems));
|
|
2073
|
+
}, []);
|
|
2074
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
2075
|
+
announcements: announcements,
|
|
2076
|
+
sensors: sensors,
|
|
2077
|
+
collisionDetection: closestCenter,
|
|
2078
|
+
measuring: measuring,
|
|
2079
|
+
onDragStart: handleDragStart,
|
|
2080
|
+
onDragMove: handleDragMove,
|
|
2081
|
+
onDragOver: handleDragOver,
|
|
2082
|
+
onDragEnd: handleDragEnd,
|
|
2083
|
+
onDragCancel: handleDragCancel
|
|
2084
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
2085
|
+
items: sortedIds,
|
|
2086
|
+
strategy: verticalListSortingStrategy
|
|
2087
|
+
}, flattenedItems.map(function (_ref7, idx) {
|
|
2088
|
+
var id = _ref7.id,
|
|
2089
|
+
_ref7$children = _ref7.children,
|
|
2090
|
+
children = _ref7$children === void 0 ? [] : _ref7$children,
|
|
2091
|
+
collapsed = _ref7.collapsed,
|
|
2092
|
+
depth = _ref7.depth,
|
|
2093
|
+
_ref7$value = _ref7.value,
|
|
2094
|
+
value = _ref7$value === void 0 ? null : _ref7$value;
|
|
2095
|
+
return /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2096
|
+
key: id,
|
|
2097
|
+
id: id,
|
|
2098
|
+
depth: id === activeId && projected ? projected.depth : depth,
|
|
2099
|
+
indentationWidth: indentationWidth,
|
|
2100
|
+
indicator: indicator,
|
|
2101
|
+
collapsed: Boolean(collapsed && children.length),
|
|
2102
|
+
onCollapse: collapsible && children.length ? function () {
|
|
2103
|
+
return handleCollapse(id);
|
|
2104
|
+
} : undefined,
|
|
2105
|
+
onRemove: removable ? function () {
|
|
2106
|
+
return handleRemove(id);
|
|
2107
|
+
} : undefined,
|
|
2108
|
+
childCount: getChildCount(items, id),
|
|
2109
|
+
component: component,
|
|
2110
|
+
value: value,
|
|
2111
|
+
style: itemStyle,
|
|
2112
|
+
onClickItem: onClickItem,
|
|
2113
|
+
index: idx
|
|
2114
|
+
});
|
|
2115
|
+
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(DragOverlay, {
|
|
2116
|
+
dropAnimation: dropAnimation,
|
|
2117
|
+
modifiers: indicator ? [adjustTranslate] : undefined
|
|
2118
|
+
}, activeId && activeItem ? /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2119
|
+
id: activeId,
|
|
2120
|
+
depth: activeItem.depth,
|
|
2121
|
+
clone: true,
|
|
2122
|
+
childCount: getChildCount(items, activeId) + 1,
|
|
2123
|
+
indentationWidth: indentationWidth,
|
|
2124
|
+
component: component,
|
|
2125
|
+
value: activeItem === null || activeItem === void 0 ? void 0 : activeItem.value,
|
|
2126
|
+
onClickItem: onClickItem,
|
|
2127
|
+
index: flattenedItems.findIndex(function (_ref8) {
|
|
2128
|
+
var id = _ref8.id;
|
|
2129
|
+
return activeId === id;
|
|
2130
|
+
}),
|
|
2131
|
+
style: itemStyle
|
|
2132
|
+
}) : null), document.body)));
|
|
2133
|
+
|
|
2134
|
+
function handleDragStart(_ref9) {
|
|
2135
|
+
var newActiveId = _ref9.active.id;
|
|
2136
|
+
setActiveId(newActiveId);
|
|
2137
|
+
setOverId(newActiveId);
|
|
2138
|
+
var newActiveItem = flattenedItems.find(function (_ref10) {
|
|
2139
|
+
var id = _ref10.id;
|
|
2140
|
+
return id === newActiveId;
|
|
2141
|
+
});
|
|
1231
2142
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
2143
|
+
if (newActiveItem) {
|
|
2144
|
+
setCurrentPosition({
|
|
2145
|
+
parentId: newActiveItem.parentId,
|
|
2146
|
+
overId: activeId
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
1235
2149
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
2150
|
+
document.body.style.setProperty('cursor', 'grabbing');
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
function handleDragMove(_ref11) {
|
|
2154
|
+
var delta = _ref11.delta;
|
|
2155
|
+
setOffsetLeft(delta.x);
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
function handleDragOver(_ref12) {
|
|
2159
|
+
var _over$id;
|
|
2160
|
+
|
|
2161
|
+
var over = _ref12.over;
|
|
2162
|
+
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
function resetState() {
|
|
2166
|
+
setOverId(null);
|
|
2167
|
+
setActiveId(null);
|
|
2168
|
+
setOffsetLeft(0);
|
|
2169
|
+
setCurrentPosition(null);
|
|
2170
|
+
document.body.style.setProperty('cursor', '');
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
function handleDragEnd(_ref13) {
|
|
2174
|
+
var active = _ref13.active,
|
|
2175
|
+
over = _ref13.over;
|
|
2176
|
+
resetState();
|
|
2177
|
+
|
|
2178
|
+
if (projected && over) {
|
|
2179
|
+
var depth = projected.depth,
|
|
2180
|
+
parentId = projected.parentId;
|
|
2181
|
+
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2182
|
+
var overIndex = clonedItems.findIndex(function (_ref14) {
|
|
2183
|
+
var id = _ref14.id;
|
|
2184
|
+
return id === over.id;
|
|
2185
|
+
});
|
|
2186
|
+
var activeIndex = clonedItems.findIndex(function (_ref15) {
|
|
2187
|
+
var id = _ref15.id;
|
|
2188
|
+
return id === active.id;
|
|
2189
|
+
});
|
|
2190
|
+
var activeTreeItem = clonedItems[activeIndex];
|
|
2191
|
+
var maxDepth = getMaxDepth(activeTreeItem); // Un-merge and flatten
|
|
2192
|
+
|
|
2193
|
+
if (depth > 0 && depth >= maxDepth && (activeTreeItem === null || activeTreeItem === void 0 ? void 0 : activeTreeItem.children) !== null && activeTreeItem.children.length > 0) {
|
|
2194
|
+
var _loop = function _loop(i) {
|
|
2195
|
+
var childId = activeTreeItem.children[i].id;
|
|
2196
|
+
var childIndex = clonedItems.findIndex(function (_ref16) {
|
|
2197
|
+
var id = _ref16.id;
|
|
2198
|
+
return id === childId;
|
|
2199
|
+
});
|
|
2200
|
+
clonedItems[childIndex].parentId = parentId;
|
|
2201
|
+
clonedItems[childIndex].depth = depth;
|
|
2202
|
+
};
|
|
1245
2203
|
|
|
1246
|
-
|
|
1247
|
-
|
|
2204
|
+
for (var i = 0; i < activeTreeItem.children.length; i += 1) {
|
|
2205
|
+
_loop(i);
|
|
2206
|
+
}
|
|
1248
2207
|
|
|
1249
|
-
|
|
2208
|
+
activeTreeItem.children = [];
|
|
2209
|
+
}
|
|
1250
2210
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
story: null,
|
|
1261
|
-
screenId: null,
|
|
1262
|
-
field: null,
|
|
1263
|
-
form: null,
|
|
1264
|
-
className: null
|
|
1265
|
-
};
|
|
2211
|
+
clonedItems[activeIndex] = _objectSpread(_objectSpread({}, activeTreeItem), {}, {
|
|
2212
|
+
depth: depth,
|
|
2213
|
+
parentId: parentId
|
|
2214
|
+
});
|
|
2215
|
+
var sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
2216
|
+
var newItems = buildTree(sortedItems);
|
|
2217
|
+
setItems(newItems);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
1266
2220
|
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
field = _ref.field,
|
|
1271
|
-
form = _ref.form,
|
|
1272
|
-
url = _ref.url,
|
|
1273
|
-
className = _ref.className;
|
|
1274
|
-
var intl = useIntl();
|
|
2221
|
+
function handleDragCancel() {
|
|
2222
|
+
resetState();
|
|
2223
|
+
}
|
|
1275
2224
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
2225
|
+
function handleRemove(id) {
|
|
2226
|
+
setItems(function (newItems) {
|
|
2227
|
+
return removeItem(newItems, id);
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
1279
2230
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
return it.id === screenId;
|
|
2231
|
+
function handleCollapse(id) {
|
|
2232
|
+
setItems(function (newItems) {
|
|
2233
|
+
return setProperty(newItems, id, 'collapsed', function (value) {
|
|
2234
|
+
return !value;
|
|
2235
|
+
});
|
|
1286
2236
|
});
|
|
2237
|
+
}
|
|
1287
2238
|
|
|
1288
|
-
|
|
1289
|
-
|
|
2239
|
+
function getMovementAnnouncement(eventName, currentActiveId, currentOverId) {
|
|
2240
|
+
if (currentOverId && projected) {
|
|
2241
|
+
if (eventName !== 'onDragEnd') {
|
|
2242
|
+
if (currentPosition && projected.parentId === currentPosition.parentId && currentOverId === currentPosition.overId) {
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
setCurrentPosition({
|
|
2247
|
+
parentId: projected.parentId,
|
|
2248
|
+
overId: currentOverId
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2253
|
+
var overIndex = clonedItems.findIndex(function (_ref17) {
|
|
2254
|
+
var id = _ref17.id;
|
|
2255
|
+
return id === currentOverId;
|
|
2256
|
+
});
|
|
2257
|
+
var activeIndex = clonedItems.findIndex(function (_ref18) {
|
|
2258
|
+
var id = _ref18.id;
|
|
2259
|
+
return id === currentActiveId;
|
|
2260
|
+
});
|
|
2261
|
+
var sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
2262
|
+
var previousItem = sortedItems[overIndex - 1];
|
|
2263
|
+
var newAnnouncement;
|
|
2264
|
+
var movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
2265
|
+
var nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
2266
|
+
|
|
2267
|
+
if (!previousItem) {
|
|
2268
|
+
var nextItem = sortedItems[overIndex + 1];
|
|
2269
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " before ").concat(nextItem.id, ".");
|
|
2270
|
+
} else if (projected.depth > previousItem.depth) {
|
|
2271
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(nestedVerb, " under ").concat(previousItem.id, ".");
|
|
2272
|
+
} else {
|
|
2273
|
+
var previousSibling = previousItem;
|
|
2274
|
+
|
|
2275
|
+
var _loop2 = function _loop2() {
|
|
2276
|
+
var _previousSibling = previousSibling,
|
|
2277
|
+
parentId = _previousSibling.parentId;
|
|
2278
|
+
previousSibling = sortedItems.find(function (_ref19) {
|
|
2279
|
+
var id = _ref19.id;
|
|
2280
|
+
return id === parentId;
|
|
2281
|
+
});
|
|
2282
|
+
};
|
|
2283
|
+
|
|
2284
|
+
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
2285
|
+
_loop2();
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
if (previousSibling) {
|
|
2289
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " after ").concat(previousSibling.id, ".");
|
|
2290
|
+
}
|
|
2291
|
+
} // eslint-disable-next-line consistent-return
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
return newAnnouncement;
|
|
1290
2295
|
}
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
SortableTree.propTypes = propTypes$8;
|
|
2299
|
+
SortableTree.defaultProps = defaultProps$8;
|
|
1291
2300
|
|
|
1292
|
-
|
|
1293
|
-
|
|
2301
|
+
var _excluded$2 = ["className", "screen", "type", "onClick"],
|
|
2302
|
+
_excluded2 = ["id", "screen"];
|
|
2303
|
+
var propTypes$7 = {
|
|
2304
|
+
items: PropTypes$1.menuItems,
|
|
2305
|
+
withPreview: PropTypes.bool,
|
|
2306
|
+
withPlaceholder: PropTypes.bool,
|
|
2307
|
+
settings: PropTypes.node,
|
|
2308
|
+
previewMinWidth: PropTypes.number,
|
|
2309
|
+
sortable: PropTypes.bool,
|
|
2310
|
+
isTree: PropTypes.bool,
|
|
2311
|
+
isVertical: PropTypes.bool,
|
|
2312
|
+
noWrap: PropTypes.bool,
|
|
2313
|
+
className: PropTypes.string,
|
|
2314
|
+
itemClassName: PropTypes.string,
|
|
2315
|
+
buttonClassName: PropTypes.string,
|
|
2316
|
+
settingsClassName: PropTypes.string,
|
|
2317
|
+
onClickItem: PropTypes.func,
|
|
2318
|
+
onOrderChange: PropTypes.func
|
|
2319
|
+
};
|
|
2320
|
+
var defaultProps$7 = {
|
|
2321
|
+
items: [],
|
|
2322
|
+
withPreview: false,
|
|
2323
|
+
withPlaceholder: false,
|
|
2324
|
+
settings: null,
|
|
2325
|
+
previewMinWidth: 320,
|
|
2326
|
+
sortable: false,
|
|
2327
|
+
isTree: false,
|
|
2328
|
+
isVertical: false,
|
|
2329
|
+
noWrap: false,
|
|
2330
|
+
className: null,
|
|
2331
|
+
itemClassName: null,
|
|
2332
|
+
buttonClassName: null,
|
|
2333
|
+
settingsClassName: null,
|
|
2334
|
+
onClickItem: null,
|
|
2335
|
+
onOrderChange: null
|
|
2336
|
+
};
|
|
1294
2337
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
_screensManager$getDe2 = _screensManager$getDe.fields,
|
|
1298
|
-
screenFields = _screensManager$getDe2 === void 0 ? [] : _screensManager$getDe2;
|
|
2338
|
+
var ScreensMenu = function ScreensMenu(_ref) {
|
|
2339
|
+
var _ref10;
|
|
1299
2340
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
var currentSettings = settings !== null ? getFieldByName(settings, key) : null;
|
|
1316
|
-
var isCurrentSubfields = currentSubfields !== null;
|
|
1317
|
-
var isCurrentSettings = currentSettings !== null;
|
|
1318
|
-
var isListItems = itemsField !== null && !!key.match(/^[0-9]+$/);
|
|
1319
|
-
var isLastIndex = keyIndex === lastKeyIndex;
|
|
1320
|
-
var pathPrefix = "/".concat(screenId, "/").concat(fieldPath.slice(0, keyIndex + 1).join('/'));
|
|
1321
|
-
var pathSuffix = isLastIndex && form !== null ? "/".concat(form) : '';
|
|
1322
|
-
var addNewItem = isLastIndex || isListItems;
|
|
1323
|
-
var itemPath = "".concat(pathPrefix).concat(pathSuffix);
|
|
1324
|
-
var nextFields = null;
|
|
2341
|
+
var items = _ref.items,
|
|
2342
|
+
withPreview = _ref.withPreview,
|
|
2343
|
+
withPlaceholder = _ref.withPlaceholder,
|
|
2344
|
+
settings = _ref.settings,
|
|
2345
|
+
previewMinWidth = _ref.previewMinWidth,
|
|
2346
|
+
isVertical = _ref.isVertical,
|
|
2347
|
+
noWrap = _ref.noWrap,
|
|
2348
|
+
className = _ref.className,
|
|
2349
|
+
itemClassName = _ref.itemClassName,
|
|
2350
|
+
buttonClassName = _ref.buttonClassName,
|
|
2351
|
+
settingsClassName = _ref.settingsClassName,
|
|
2352
|
+
sortable = _ref.sortable,
|
|
2353
|
+
isTree = _ref.isTree,
|
|
2354
|
+
onClickItem = _ref.onClickItem,
|
|
2355
|
+
onOrderChange = _ref.onOrderChange;
|
|
1325
2356
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
nextFields = currentSettings;
|
|
2357
|
+
var _useResizeObserver = useResizeObserver({}, [items]),
|
|
2358
|
+
containerRef = _useResizeObserver.ref,
|
|
2359
|
+
contentRect = _useResizeObserver.entry.contentRect;
|
|
1330
2360
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
}));
|
|
1335
|
-
}
|
|
1336
|
-
} else if (isListItems) {
|
|
1337
|
-
nextFields = itemsField;
|
|
1338
|
-
}
|
|
2361
|
+
var _useResizeObserver2 = useResizeObserver({}, [items]),
|
|
2362
|
+
columnRef = _useResizeObserver2.ref,
|
|
2363
|
+
columnRect = _useResizeObserver2.entry.contentRect;
|
|
1339
2364
|
|
|
1340
|
-
|
|
1341
|
-
|
|
2365
|
+
var previewStyle = useMemo(function () {
|
|
2366
|
+
var _ref2 = contentRect || {},
|
|
2367
|
+
_ref2$width = _ref2.width,
|
|
2368
|
+
itemWidth = _ref2$width === void 0 ? 0 : _ref2$width,
|
|
2369
|
+
_ref2$height = _ref2.height,
|
|
2370
|
+
itemHeight = _ref2$height === void 0 ? 0 : _ref2$height;
|
|
1342
2371
|
|
|
1343
|
-
|
|
1344
|
-
_ref3$label = _ref3.label,
|
|
1345
|
-
parentItemLabel = _ref3$label === void 0 ? null : _ref3$label;
|
|
2372
|
+
var ratio = itemHeight !== 0 && itemWidth !== 0 ? itemHeight / itemWidth : 2 / 3;
|
|
1346
2373
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
url: itemPath,
|
|
1350
|
-
label: finalItemLabel || '',
|
|
1351
|
-
active: false
|
|
1352
|
-
};
|
|
2374
|
+
var _getSizeWithinBounds = getSizeWithinBounds(previewMinWidth, previewMinWidth * ratio, itemWidth, itemHeight),
|
|
2375
|
+
previewScale = _getSizeWithinBounds.scale;
|
|
1353
2376
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
2377
|
+
return {
|
|
2378
|
+
width: previewMinWidth,
|
|
2379
|
+
height: previewMinWidth * ratio,
|
|
2380
|
+
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")")
|
|
2381
|
+
};
|
|
2382
|
+
}, [previewMinWidth, contentRect]);
|
|
2383
|
+
var treeStyle = useMemo(function () {
|
|
2384
|
+
var _ref3 = columnRect || {},
|
|
2385
|
+
_ref3$width = _ref3.width,
|
|
2386
|
+
itemWidth = _ref3$width === void 0 ? 0 : _ref3$width;
|
|
1357
2387
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}, {
|
|
1361
|
-
fields: fields
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
2388
|
+
var itemHeight = itemWidth * 3 / 2;
|
|
2389
|
+
var ratio = itemHeight !== 0 && itemWidth !== 0 ? itemHeight / itemWidth : 0;
|
|
1364
2390
|
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
2391
|
+
var _getSizeWithinBounds2 = getSizeWithinBounds(previewMinWidth, previewMinWidth * ratio, itemWidth, itemHeight),
|
|
2392
|
+
scaledWidth = _getSizeWithinBounds2.width,
|
|
2393
|
+
scaledHeight = _getSizeWithinBounds2.height,
|
|
2394
|
+
previewScale = _getSizeWithinBounds2.scale;
|
|
2395
|
+
|
|
2396
|
+
return {
|
|
2397
|
+
width: previewMinWidth,
|
|
2398
|
+
height: previewMinWidth * ratio,
|
|
2399
|
+
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")"),
|
|
2400
|
+
scale: previewScale,
|
|
2401
|
+
scaledWidth: scaledWidth,
|
|
2402
|
+
scaledHeight: scaledHeight
|
|
2403
|
+
};
|
|
2404
|
+
}, [previewMinWidth, columnRect]);
|
|
2405
|
+
var itemsElements = !isTree ? items.map(function (_ref4, index) {
|
|
2406
|
+
var _ref5;
|
|
2407
|
+
|
|
2408
|
+
var _ref4$className = _ref4.className,
|
|
2409
|
+
itemCustomClassName = _ref4$className === void 0 ? null : _ref4$className,
|
|
2410
|
+
screen = _ref4.screen,
|
|
2411
|
+
type = _ref4.type,
|
|
2412
|
+
_ref4$onClick = _ref4.onClick,
|
|
2413
|
+
onClick = _ref4$onClick === void 0 ? null : _ref4$onClick,
|
|
2414
|
+
item = _objectWithoutProperties(_ref4, _excluded$2);
|
|
2415
|
+
|
|
2416
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
2417
|
+
key: item.id,
|
|
2418
|
+
className: classNames([styles$6.item, (_ref5 = {}, _defineProperty(_ref5, itemClassName, itemClassName !== null), _defineProperty(_ref5, itemCustomClassName, itemCustomClassName !== null), _ref5)]),
|
|
2419
|
+
"data-screen-id": item.id,
|
|
2420
|
+
ref: index === 0 ? containerRef : null
|
|
2421
|
+
}, /*#__PURE__*/React.createElement(ScreenWithPreview, {
|
|
2422
|
+
index: index,
|
|
2423
|
+
screen: _objectSpread(_objectSpread({}, screen), withPlaceholder ? {
|
|
2424
|
+
type: type
|
|
2425
|
+
} : null),
|
|
2426
|
+
buttonClassName: buttonClassName,
|
|
2427
|
+
previewStyle: previewStyle,
|
|
2428
|
+
withPreview: withPreview,
|
|
2429
|
+
withPlaceholder: withPlaceholder,
|
|
2430
|
+
onClick: onClick,
|
|
2431
|
+
onClickItem: onClickItem
|
|
2432
|
+
}), settings !== null ? /*#__PURE__*/React.createElement("div", {
|
|
2433
|
+
className: classNames([_defineProperty({}, settingsClassName, settingsClassName !== null), styles$6.settings, 'p-2'])
|
|
2434
|
+
}, isFunction(settings) ? settings(index) : settings) : null);
|
|
2435
|
+
}) : [];
|
|
2436
|
+
var sortableItems = useMemo(function () {
|
|
2437
|
+
return isTree ? items.map(function (_ref7) {
|
|
2438
|
+
var id = _ref7.id,
|
|
2439
|
+
_ref7$screen = _ref7.screen,
|
|
2440
|
+
screen = _ref7$screen === void 0 ? {} : _ref7$screen,
|
|
2441
|
+
props = _objectWithoutProperties(_ref7, _excluded2);
|
|
2442
|
+
|
|
2443
|
+
var _screen$parentId = screen.parentId,
|
|
2444
|
+
parentId = _screen$parentId === void 0 ? null : _screen$parentId,
|
|
2445
|
+
_screen$group = screen.group,
|
|
2446
|
+
group = _screen$group === void 0 ? {} : _screen$group;
|
|
2447
|
+
|
|
2448
|
+
var _ref8 = group || {},
|
|
2449
|
+
_ref8$collapsed = _ref8.collapsed,
|
|
2450
|
+
collapsed = _ref8$collapsed === void 0 ? true : _ref8$collapsed;
|
|
2451
|
+
|
|
2452
|
+
return _objectSpread({
|
|
2453
|
+
id: id,
|
|
2454
|
+
parentId: parentId,
|
|
2455
|
+
collapsed: collapsed,
|
|
2456
|
+
value: {
|
|
2457
|
+
id: id,
|
|
2458
|
+
screen: screen
|
|
2459
|
+
}
|
|
2460
|
+
}, props);
|
|
2461
|
+
}, []) : items.map(function (_ref9) {
|
|
2462
|
+
var id = _ref9.id;
|
|
2463
|
+
return {
|
|
2464
|
+
id: id
|
|
2465
|
+
};
|
|
1384
2466
|
});
|
|
1385
|
-
}, [
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
},
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
2467
|
+
}, [items, isTree]);
|
|
2468
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2469
|
+
className: classNames([styles$6.container, (_ref10 = {}, _defineProperty(_ref10, styles$6.noWrap, noWrap), _defineProperty(_ref10, styles$6.isVertical, isVertical), _defineProperty(_ref10, styles$6.isTree, isTree), _defineProperty(_ref10, styles$6.withPlaceholder, withPlaceholder), _defineProperty(_ref10, className, className), _ref10)]),
|
|
2470
|
+
ref: columnRef
|
|
2471
|
+
}, isTree && !sortable ? /*#__PURE__*/React.createElement(SortableTree, {
|
|
2472
|
+
items: sortableItems,
|
|
2473
|
+
component: ScreenWithPreview,
|
|
2474
|
+
itemStyle: treeStyle,
|
|
2475
|
+
onClickItem: onClickItem,
|
|
2476
|
+
onChange: onOrderChange
|
|
2477
|
+
}) : null, !isTree && sortable && items.length > 1 ? /*#__PURE__*/React.createElement(ReactSortable, {
|
|
2478
|
+
list: sortableItems,
|
|
2479
|
+
setList: onOrderChange,
|
|
2480
|
+
animation: 200,
|
|
2481
|
+
delayOnTouchStart: true,
|
|
2482
|
+
delay: 2,
|
|
2483
|
+
tag: "ul",
|
|
2484
|
+
className: styles$6.items
|
|
2485
|
+
}, itemsElements) : null, !isTree && (!sortable || items.length < 1) ? /*#__PURE__*/React.createElement("ul", {
|
|
2486
|
+
className: styles$6.items
|
|
2487
|
+
}, itemsElements) : null);
|
|
1401
2488
|
};
|
|
1402
2489
|
|
|
1403
|
-
|
|
1404
|
-
|
|
2490
|
+
ScreensMenu.propTypes = propTypes$7;
|
|
2491
|
+
ScreensMenu.defaultProps = defaultProps$7;
|
|
1405
2492
|
|
|
1406
|
-
var styles$
|
|
2493
|
+
var styles$2 = {"container":"micromag-editor-menus-screen-types-container","row":"micromag-editor-menus-screen-types-row","title":"micromag-editor-menus-screen-types-title"};
|
|
1407
2494
|
|
|
1408
|
-
var propTypes$
|
|
1409
|
-
|
|
2495
|
+
var propTypes$6 = {
|
|
2496
|
+
screens: PropTypes$1.screenDefinitions,
|
|
2497
|
+
selectedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
1410
2498
|
className: PropTypes.string,
|
|
1411
|
-
|
|
1412
|
-
closeFieldForm: PropTypes.func.isRequired,
|
|
1413
|
-
onChange: PropTypes.func // onClickDelete: PropTypes.func,
|
|
1414
|
-
|
|
2499
|
+
onClickItem: PropTypes.func
|
|
1415
2500
|
};
|
|
1416
|
-
var defaultProps$
|
|
1417
|
-
|
|
2501
|
+
var defaultProps$6 = {
|
|
2502
|
+
screens: null,
|
|
2503
|
+
selectedTypes: null,
|
|
1418
2504
|
className: null,
|
|
1419
|
-
|
|
1420
|
-
|
|
2505
|
+
onClickItem: null
|
|
1421
2506
|
};
|
|
1422
2507
|
|
|
1423
|
-
var
|
|
1424
|
-
var
|
|
2508
|
+
var ScreenTypes = function ScreenTypes(_ref) {
|
|
2509
|
+
var screens = _ref.screens,
|
|
2510
|
+
selectedTypes = _ref.selectedTypes,
|
|
1425
2511
|
className = _ref.className,
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
var
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
// window.confirm(
|
|
1437
|
-
// intl.formatMessage({
|
|
1438
|
-
// defaultMessage: 'Are you sure you want to delete this screen?',
|
|
1439
|
-
// description: 'Confirm message when deleting a screen',
|
|
1440
|
-
// }),
|
|
1441
|
-
// )
|
|
1442
|
-
// ) {
|
|
1443
|
-
// onClickDelete(value);
|
|
1444
|
-
// }
|
|
1445
|
-
// }, [intl, onClickDelete, value]);
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1449
|
-
className: classNames([styles$3.container, _defineProperty({}, className, className)])
|
|
1450
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1451
|
-
className: styles$3.inner
|
|
1452
|
-
}, /*#__PURE__*/React.createElement(Fields, {
|
|
1453
|
-
fields: fields,
|
|
1454
|
-
value: value,
|
|
1455
|
-
onChange: onChange,
|
|
1456
|
-
gotoFieldForm: gotoFieldForm,
|
|
1457
|
-
closeFieldForm: closeFieldForm
|
|
1458
|
-
})));
|
|
1459
|
-
};
|
|
2512
|
+
onClickItem = _ref.onClickItem;
|
|
2513
|
+
var intl = useIntl();
|
|
2514
|
+
var screensManager = useScreensManager();
|
|
2515
|
+
var finalDefinitions = screens || screensManager.getDefinitions();
|
|
2516
|
+
var groups = useMemo(function () {
|
|
2517
|
+
var groupItems = finalDefinitions.reduce(function (allGroups, definition) {
|
|
2518
|
+
var id = definition.id,
|
|
2519
|
+
title = definition.title,
|
|
2520
|
+
_definition$group = definition.group,
|
|
2521
|
+
group = _definition$group === void 0 ? {} : _definition$group;
|
|
1460
2522
|
|
|
1461
|
-
|
|
1462
|
-
|
|
2523
|
+
var _ref2 = group || {},
|
|
2524
|
+
_ref2$order = _ref2.order,
|
|
2525
|
+
order = _ref2$order === void 0 ? 0 : _ref2$order,
|
|
2526
|
+
_ref2$label = _ref2.label,
|
|
2527
|
+
label = _ref2$label === void 0 ? {} : _ref2$label,
|
|
2528
|
+
_ref2$hidden = _ref2.hidden,
|
|
2529
|
+
hidden = _ref2$hidden === void 0 ? false : _ref2$hidden;
|
|
1463
2530
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
};
|
|
1468
|
-
var defaultProps$4 = {
|
|
1469
|
-
children: null
|
|
1470
|
-
};
|
|
2531
|
+
var _ref3 = label || {},
|
|
2532
|
+
_ref3$id = _ref3.id,
|
|
2533
|
+
messageId = _ref3$id === void 0 ? null : _ref3$id;
|
|
1471
2534
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
1476
|
-
fields = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$; // To use a specific form component
|
|
2535
|
+
if (hidden) {
|
|
2536
|
+
return allGroups;
|
|
2537
|
+
}
|
|
1477
2538
|
|
|
2539
|
+
var _ref4 = isMessage(label) ? {
|
|
2540
|
+
id: messageId || id,
|
|
2541
|
+
name: group
|
|
2542
|
+
} : {
|
|
2543
|
+
id: messageId || id,
|
|
2544
|
+
name: title
|
|
2545
|
+
},
|
|
2546
|
+
groupId = _ref4.id,
|
|
2547
|
+
groupName = _ref4.name;
|
|
1478
2548
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
2549
|
+
var groupIndex = allGroups.findIndex(function (it) {
|
|
2550
|
+
return it.id === groupId;
|
|
2551
|
+
});
|
|
2552
|
+
var selected = selectedTypes !== null && selectedTypes.indexOf(id) !== -1;
|
|
2553
|
+
var item = {
|
|
2554
|
+
id: id,
|
|
2555
|
+
type: id,
|
|
2556
|
+
screen: definition,
|
|
2557
|
+
className: classNames(_defineProperty({
|
|
2558
|
+
'bg-secondary': !selected,
|
|
2559
|
+
'bg-primary': selected
|
|
2560
|
+
}, styles$2.selected, selected))
|
|
2561
|
+
};
|
|
2562
|
+
return groupIndex !== -1 ? [].concat(_toConsumableArray(allGroups.slice(0, groupIndex)), [_objectSpread(_objectSpread({}, allGroups[groupIndex]), {}, {
|
|
2563
|
+
items: [].concat(_toConsumableArray(allGroups[groupIndex].items), [item])
|
|
2564
|
+
})], _toConsumableArray(allGroups.slice(groupIndex + 1))) : [].concat(_toConsumableArray(allGroups), [{
|
|
2565
|
+
id: groupId,
|
|
2566
|
+
name: isMessage(label) ? intl.formatMessage(label) : groupName,
|
|
2567
|
+
order: order,
|
|
2568
|
+
items: [item]
|
|
2569
|
+
}]);
|
|
2570
|
+
}, []);
|
|
2571
|
+
return orderBy(groupItems, ['order', 'name'], ['asc', 'asc']);
|
|
2572
|
+
}, [finalDefinitions, selectedTypes]);
|
|
2573
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2574
|
+
className: classNames([styles$2.container, _defineProperty({}, className, className)])
|
|
2575
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2576
|
+
className: styles$2.rows
|
|
2577
|
+
}, groups.map(function (_ref6) {
|
|
2578
|
+
var id = _ref6.id,
|
|
2579
|
+
name = _ref6.name,
|
|
2580
|
+
items = _ref6.items;
|
|
2581
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2582
|
+
key: "group-".concat(id),
|
|
2583
|
+
className: styles$2.row
|
|
2584
|
+
}, /*#__PURE__*/React.createElement(Label, null, name), /*#__PURE__*/React.createElement("div", {
|
|
2585
|
+
className: styles$2.layouts
|
|
2586
|
+
}, /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
2587
|
+
items: items,
|
|
2588
|
+
withPlaceholder: true,
|
|
2589
|
+
itemClassName: classNames(['border', 'rounded', {
|
|
2590
|
+
'border-secondary': selectedTypes === null,
|
|
2591
|
+
'border-dark': selectedTypes !== null,
|
|
2592
|
+
'bg-secondary': selectedTypes === null,
|
|
2593
|
+
'text-secondary': selectedTypes !== null
|
|
2594
|
+
}]),
|
|
2595
|
+
previewMinWidth: 100,
|
|
2596
|
+
onClickItem: onClickItem
|
|
2597
|
+
})));
|
|
2598
|
+
})));
|
|
1484
2599
|
};
|
|
1485
2600
|
|
|
1486
|
-
|
|
1487
|
-
|
|
2601
|
+
ScreenTypes.propTypes = propTypes$6;
|
|
2602
|
+
ScreenTypes.defaultProps = defaultProps$6;
|
|
1488
2603
|
|
|
1489
|
-
var styles$
|
|
2604
|
+
var styles$1 = {"container":"micromag-editor-modals-screen-types-container","selected":"micromag-editor-modals-screen-types-selected"};
|
|
1490
2605
|
|
|
1491
|
-
var propTypes$
|
|
2606
|
+
var propTypes$5 = {
|
|
2607
|
+
selectedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
1492
2608
|
className: PropTypes.string,
|
|
1493
|
-
|
|
1494
|
-
|
|
2609
|
+
onRequestClose: PropTypes.func,
|
|
2610
|
+
onClickScreenType: PropTypes.func
|
|
1495
2611
|
};
|
|
1496
|
-
var defaultProps$
|
|
2612
|
+
var defaultProps$5 = {
|
|
2613
|
+
selectedTypes: null,
|
|
1497
2614
|
className: null,
|
|
1498
|
-
|
|
1499
|
-
|
|
2615
|
+
onRequestClose: null,
|
|
2616
|
+
onClickScreenType: null
|
|
1500
2617
|
};
|
|
1501
2618
|
|
|
1502
|
-
var
|
|
1503
|
-
var
|
|
1504
|
-
|
|
1505
|
-
|
|
2619
|
+
var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
2620
|
+
var selectedTypes = _ref.selectedTypes,
|
|
2621
|
+
className = _ref.className,
|
|
2622
|
+
onRequestClose = _ref.onRequestClose,
|
|
2623
|
+
onClickScreenType = _ref.onClickScreenType;
|
|
1506
2624
|
return /*#__PURE__*/React.createElement(Modal, null, /*#__PURE__*/React.createElement(ModalDialog, {
|
|
1507
2625
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1508
|
-
id: "
|
|
2626
|
+
id: "QBaiO0",
|
|
1509
2627
|
defaultMessage: [{
|
|
1510
2628
|
"type": 0,
|
|
1511
|
-
"value": "
|
|
2629
|
+
"value": "Add a screen"
|
|
1512
2630
|
}]
|
|
1513
2631
|
}),
|
|
1514
|
-
className: classNames([styles$
|
|
1515
|
-
onClickClose:
|
|
1516
|
-
}, /*#__PURE__*/React.createElement(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
"type": 0,
|
|
1522
|
-
"value": "Are you sure you want to delete this screen?"
|
|
1523
|
-
}]
|
|
1524
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
1525
|
-
className: styles$2.actions
|
|
1526
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
1527
|
-
onClick: onCancel,
|
|
1528
|
-
className: "btn-outline-secondary mr-2"
|
|
1529
|
-
}, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1530
|
-
id: "0GT0SI",
|
|
1531
|
-
defaultMessage: [{
|
|
1532
|
-
"type": 0,
|
|
1533
|
-
"value": "Cancel"
|
|
1534
|
-
}]
|
|
1535
|
-
}))), /*#__PURE__*/React.createElement(Button, {
|
|
1536
|
-
onClick: onConfirm,
|
|
1537
|
-
theme: "danger",
|
|
1538
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1539
|
-
id: "gRxcTc",
|
|
1540
|
-
defaultMessage: [{
|
|
1541
|
-
"type": 0,
|
|
1542
|
-
"value": "Delete screen"
|
|
1543
|
-
}]
|
|
1544
|
-
})
|
|
1545
|
-
}))));
|
|
2632
|
+
className: classNames([styles$1.container, _defineProperty({}, className, className)]),
|
|
2633
|
+
onClickClose: onRequestClose
|
|
2634
|
+
}, /*#__PURE__*/React.createElement(ScreenTypes, {
|
|
2635
|
+
selectedTypes: selectedTypes,
|
|
2636
|
+
className: styles$1.menu,
|
|
2637
|
+
onClickItem: onClickScreenType
|
|
2638
|
+
})));
|
|
1546
2639
|
};
|
|
1547
2640
|
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
var styles$1 = {"panel":"micromag-editor-form-panel","leave":"micromag-editor-form-leave","content":"micromag-editor-form-content","navbar":"micromag-editor-form-navbar","enterBottom":"micromag-editor-form-enterBottom","enterLeft":"micromag-editor-form-enterLeft","enterRight":"micromag-editor-form-enterRight","enterTop":"micromag-editor-form-enterTop","enterActiveHorizontal":"micromag-editor-form-enterActiveHorizontal","enterActiveVertical":"micromag-editor-form-enterActiveVertical","leaveActiveLeft":"micromag-editor-form-leaveActiveLeft","leaveActiveRight":"micromag-editor-form-leaveActiveRight","leaveActiveBottom":"micromag-editor-form-leaveActiveBottom","leaveActiveTop":"micromag-editor-form-leaveActiveTop"};
|
|
2641
|
+
ScreenTypesModal.propTypes = propTypes$5;
|
|
2642
|
+
ScreenTypesModal.defaultProps = defaultProps$5;
|
|
1552
2643
|
|
|
1553
|
-
var
|
|
2644
|
+
var _excluded$1 = ["id"];
|
|
2645
|
+
var propTypes$4 = {
|
|
1554
2646
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
1555
2647
|
isTheme: PropTypes.bool,
|
|
1556
|
-
|
|
1557
|
-
|
|
2648
|
+
isVertical: PropTypes.bool,
|
|
2649
|
+
isCreateOpened: PropTypes.bool,
|
|
2650
|
+
isParsed: PropTypes.bool,
|
|
2651
|
+
isTree: PropTypes.bool,
|
|
2652
|
+
onClickScreen: PropTypes.func,
|
|
2653
|
+
onChange: PropTypes.func,
|
|
2654
|
+
className: PropTypes.string
|
|
1558
2655
|
};
|
|
1559
|
-
var defaultProps$
|
|
2656
|
+
var defaultProps$4 = {
|
|
1560
2657
|
value: null,
|
|
1561
2658
|
isTheme: false,
|
|
1562
|
-
|
|
1563
|
-
|
|
2659
|
+
isVertical: false,
|
|
2660
|
+
isCreateOpened: false,
|
|
2661
|
+
isParsed: false,
|
|
2662
|
+
isTree: false,
|
|
2663
|
+
onClickScreen: null,
|
|
2664
|
+
onChange: null,
|
|
2665
|
+
className: null
|
|
1564
2666
|
};
|
|
1565
2667
|
|
|
1566
|
-
var
|
|
1567
|
-
var
|
|
2668
|
+
var EditorScreens = function EditorScreens(_ref) {
|
|
2669
|
+
var unparsedValue = _ref.value,
|
|
1568
2670
|
isTheme = _ref.isTheme,
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
fieldParams = _useRouteParams$field === void 0 ? null : _useRouteParams$field,
|
|
1581
|
-
_useRouteParams$form = _useRouteParams.form,
|
|
1582
|
-
formParams = _useRouteParams$form === void 0 ? null : _useRouteParams$form; // Get screen
|
|
1583
|
-
|
|
2671
|
+
isVertical = _ref.isVertical,
|
|
2672
|
+
isCreateOpened = _ref.isCreateOpened,
|
|
2673
|
+
isParsed = _ref.isParsed,
|
|
2674
|
+
isTree = _ref.isTree,
|
|
2675
|
+
onClickScreen = _ref.onClickScreen,
|
|
2676
|
+
onChange = _ref.onChange,
|
|
2677
|
+
className = _ref.className;
|
|
2678
|
+
var valueWithTheme = useThemeValue(unparsedValue, isTheme);
|
|
2679
|
+
var value = isParsed ? unparsedValue : useParsedStory(valueWithTheme, {
|
|
2680
|
+
withMedias: false
|
|
2681
|
+
});
|
|
1584
2682
|
|
|
1585
2683
|
var _ref2 = value || {},
|
|
1586
2684
|
_ref2$components = _ref2.components,
|
|
1587
2685
|
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
1588
2686
|
|
|
1589
|
-
var
|
|
1590
|
-
return it.id === screenId;
|
|
1591
|
-
});
|
|
1592
|
-
var screen = screenIndex !== -1 ? screens[screenIndex] : null; // Get transition value
|
|
1593
|
-
|
|
1594
|
-
var _useFormTransition = useFormTransition(url, screenIndex, styles$1),
|
|
1595
|
-
transitionName = _useFormTransition.name,
|
|
1596
|
-
transitionTimeout = _useFormTransition.timeout;
|
|
1597
|
-
|
|
1598
|
-
var _useState = useState(false),
|
|
2687
|
+
var _useState = useState(isCreateOpened),
|
|
1599
2688
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1600
|
-
|
|
1601
|
-
|
|
2689
|
+
createModalOpened = _useState2[0],
|
|
2690
|
+
setCreateModalOpened = _useState2[1];
|
|
1602
2691
|
|
|
1603
|
-
var
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
setDeleteScreenModalOpened = _useState4[1];
|
|
2692
|
+
var routes = useRoutes();
|
|
2693
|
+
var push = useRoutePush();
|
|
2694
|
+
var url = useUrlGenerator();
|
|
1607
2695
|
|
|
1608
|
-
var
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
2696
|
+
var _useRouteParams = useRouteParams({
|
|
2697
|
+
screenOnly: true
|
|
2698
|
+
}),
|
|
2699
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
2700
|
+
currentScreenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree;
|
|
1612
2701
|
|
|
1613
|
-
var
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
2702
|
+
var createScreenFromDefinition = useCallback(function (definition) {
|
|
2703
|
+
var _ref3 = value || {},
|
|
2704
|
+
_ref3$components = _ref3.components,
|
|
2705
|
+
currentScreens = _ref3$components === void 0 ? [] : _ref3$components,
|
|
2706
|
+
_ref3$theme = _ref3.theme,
|
|
2707
|
+
theme = _ref3$theme === void 0 ? {} : _ref3$theme;
|
|
2708
|
+
|
|
2709
|
+
var _ref4 = isString(definition) ? {
|
|
2710
|
+
id: definition
|
|
2711
|
+
} : definition,
|
|
2712
|
+
newScreenType = _ref4.id;
|
|
1617
2713
|
|
|
2714
|
+
var _ref5 = theme || {},
|
|
2715
|
+
_ref5$components = _ref5.components,
|
|
2716
|
+
themeComponents = _ref5$components === void 0 ? null : _ref5$components;
|
|
1618
2717
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
var
|
|
1623
|
-
var
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
screen: screenId,
|
|
1627
|
-
field: field !== null ? field.split('.') : null,
|
|
1628
|
-
form: formName !== null ? slug(formName) : null
|
|
2718
|
+
var themeScreen = themeComponents !== null ? themeComponents.find(function (it) {
|
|
2719
|
+
return it.type === newScreenType;
|
|
2720
|
+
}) || null : null;
|
|
2721
|
+
var newScreen = createScreen(definition, themeScreen);
|
|
2722
|
+
var foundIndex = screens.findIndex(function (_ref6) {
|
|
2723
|
+
var id = _ref6.id;
|
|
2724
|
+
return id === currentScreenId;
|
|
1629
2725
|
});
|
|
1630
|
-
|
|
1631
|
-
setFieldContext(context);
|
|
1632
|
-
}, [routePush, screenId, url, fieldForms, setFieldForms, fieldContext, setFieldContext]);
|
|
1633
|
-
var closeFieldForm = useCallback(function (field) {
|
|
1634
|
-
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1635
|
-
var fieldKey = "".concat(field).concat(formName !== null ? ":".concat(formName) : '');
|
|
1636
|
-
var pastUrl = fieldForms[fieldKey] || null;
|
|
2726
|
+
var currentScreenIndex = !isTheme && foundIndex >= 0 ? foundIndex + 1 : null;
|
|
1637
2727
|
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
2728
|
+
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
2729
|
+
components: [].concat(_toConsumableArray(currentScreens.slice(0, currentScreenIndex)), [newScreen], _toConsumableArray(currentScreens.slice(currentScreenIndex)))
|
|
2730
|
+
});
|
|
1641
2731
|
|
|
1642
|
-
setFieldForms(Object.keys(fieldForms).reduce(function (map, key) {
|
|
1643
|
-
return key !== fieldKey ? _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, fieldForms[key])) : map;
|
|
1644
|
-
}, {}));
|
|
1645
|
-
}, [history, screenId, fieldForms, setFieldForms]);
|
|
1646
|
-
var triggerOnChange = useCallback(function (newValue) {
|
|
1647
2732
|
if (onChange !== null) {
|
|
1648
2733
|
onChange(newValue);
|
|
1649
2734
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
2735
|
+
|
|
2736
|
+
return newScreen;
|
|
2737
|
+
}, [value, onChange, isTheme, screens, currentScreenId, setCreateModalOpened]);
|
|
2738
|
+
var onOrderChange = useCallback(function (listItems) {
|
|
2739
|
+
var ids = listItems.map(function (_ref7) {
|
|
2740
|
+
var id = _ref7.id;
|
|
2741
|
+
return id;
|
|
2742
|
+
});
|
|
2743
|
+
var screenProps = listItems.map(function (_ref8) {
|
|
2744
|
+
var id = _ref8.id,
|
|
2745
|
+
_ref8$props = _ref8.props,
|
|
2746
|
+
props = _ref8$props === void 0 ? null : _ref8$props;
|
|
2747
|
+
return {
|
|
2748
|
+
id: id,
|
|
2749
|
+
props: props
|
|
2750
|
+
};
|
|
2751
|
+
});
|
|
2752
|
+
var hasScreenProps = (screenProps.filter(function (_ref9) {
|
|
2753
|
+
var props = _ref9.props;
|
|
2754
|
+
return props !== null;
|
|
2755
|
+
}) || []).length > 0;
|
|
2756
|
+
|
|
2757
|
+
var _ref10 = value || {},
|
|
2758
|
+
_ref10$components = _ref10.components,
|
|
2759
|
+
currentScreens = _ref10$components === void 0 ? [] : _ref10$components;
|
|
2760
|
+
|
|
2761
|
+
var currentIds = currentScreens.map(function (_ref11) {
|
|
2762
|
+
var id = _ref11.id;
|
|
2763
|
+
return id;
|
|
2764
|
+
});
|
|
2765
|
+
var sameOrder = listItems.reduce(function (same, _ref12, index) {
|
|
2766
|
+
var id = _ref12.id;
|
|
2767
|
+
return same && id === currentIds[index];
|
|
2768
|
+
}, true);
|
|
2769
|
+
|
|
2770
|
+
if (!sameOrder || hasScreenProps) {
|
|
2771
|
+
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
2772
|
+
components: _toConsumableArray(currentScreens).sort(function (_ref13, _ref14) {
|
|
2773
|
+
var idA = _ref13.id;
|
|
2774
|
+
var idB = _ref14.id;
|
|
2775
|
+
var indexA = ids.indexOf(idA);
|
|
2776
|
+
var indexB = ids.indexOf(idB);
|
|
2777
|
+
|
|
2778
|
+
if (indexA === indexB) {
|
|
2779
|
+
return 0;
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
return indexA > indexB ? 1 : -1;
|
|
2783
|
+
}).map(function (_ref15) {
|
|
2784
|
+
var _screenProps$find;
|
|
2785
|
+
|
|
2786
|
+
var id = _ref15.id,
|
|
2787
|
+
props = _objectWithoutProperties(_ref15, _excluded$1);
|
|
2788
|
+
|
|
2789
|
+
return _objectSpread(_objectSpread({
|
|
2790
|
+
id: id
|
|
2791
|
+
}, props), (_screenProps$find = screenProps.find(function (_ref16) {
|
|
2792
|
+
var propsId = _ref16.id;
|
|
2793
|
+
return propsId === id;
|
|
2794
|
+
})) === null || _screenProps$find === void 0 ? void 0 : _screenProps$find.props);
|
|
2795
|
+
})
|
|
2796
|
+
});
|
|
2797
|
+
|
|
2798
|
+
if (onChange !== null) {
|
|
2799
|
+
onChange(newValue);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}, [value, onChange]);
|
|
2803
|
+
var onClickScreenType = useCallback(function (definition) {
|
|
2804
|
+
setCreateModalOpened(false);
|
|
2805
|
+
var currentScreen = isTheme ? screens.find(function (_ref17) {
|
|
2806
|
+
var type = _ref17.type;
|
|
2807
|
+
return type === definition.id;
|
|
2808
|
+
}) || null : null;
|
|
2809
|
+
|
|
2810
|
+
if (!isTheme || currentScreen === null) {
|
|
2811
|
+
currentScreen = createScreenFromDefinition(definition);
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
push('screen', {
|
|
2815
|
+
screen: currentScreen.id
|
|
1665
2816
|
});
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
}, [
|
|
1674
|
-
var onDeleteScreenCancel = useCallback(function () {
|
|
1675
|
-
setDeleteScreenModalOpened(false);
|
|
1676
|
-
}, [setDeleteScreenModalOpened]);
|
|
1677
|
-
var dropdownItems = [!isTheme ? {
|
|
1678
|
-
id: 'duplicate',
|
|
1679
|
-
type: 'button',
|
|
1680
|
-
className: 'text-left text-info',
|
|
1681
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1682
|
-
id: "IBjY5r",
|
|
1683
|
-
defaultMessage: [{
|
|
1684
|
-
"type": 0,
|
|
1685
|
-
"value": "Duplicate screen"
|
|
1686
|
-
}]
|
|
1687
|
-
}),
|
|
1688
|
-
onClick: onClickDuplicate
|
|
1689
|
-
} : null, {
|
|
1690
|
-
id: 'delete',
|
|
1691
|
-
type: 'button',
|
|
1692
|
-
className: 'text-left text-danger',
|
|
1693
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1694
|
-
id: "hpiKce",
|
|
1695
|
-
defaultMessage: [{
|
|
1696
|
-
"type": 0,
|
|
1697
|
-
"value": "Delete screen"
|
|
1698
|
-
}]
|
|
1699
|
-
}),
|
|
1700
|
-
onClick: onClickDelete
|
|
1701
|
-
}].filter(function (it) {
|
|
1702
|
-
return it !== null;
|
|
1703
|
-
});
|
|
2817
|
+
onClickScreen(currentScreen);
|
|
2818
|
+
}, [screens, isTheme, createScreenFromDefinition, push, onClickScreen]);
|
|
2819
|
+
var onClickAdd = useCallback(function () {
|
|
2820
|
+
return setCreateModalOpened(true);
|
|
2821
|
+
}, [setCreateModalOpened]);
|
|
2822
|
+
var onCreateModalRequestClose = useCallback(function () {
|
|
2823
|
+
return setCreateModalOpened(false);
|
|
2824
|
+
}, [setCreateModalOpened]);
|
|
1704
2825
|
return /*#__PURE__*/React.createElement("div", {
|
|
1705
|
-
className: classNames(['d-flex', 'flex-column', className])
|
|
1706
|
-
},
|
|
2826
|
+
className: classNames(['d-flex', 'flex-column', styles$7.container, className])
|
|
2827
|
+
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
1707
2828
|
compact: true,
|
|
1708
2829
|
noWrap: true,
|
|
1709
2830
|
withoutCollapse: true,
|
|
1710
|
-
className: classNames(['sticky-top',
|
|
1711
|
-
}, /*#__PURE__*/React.createElement(
|
|
1712
|
-
|
|
1713
|
-
url: url,
|
|
1714
|
-
screenId: screenId,
|
|
1715
|
-
field: fieldParams,
|
|
1716
|
-
form: formParams,
|
|
1717
|
-
className: "mr-auto"
|
|
1718
|
-
}), fieldParams === null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SettingsButton, {
|
|
1719
|
-
onClick: onSettingsClick
|
|
1720
|
-
}), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
1721
|
-
items: dropdownItems,
|
|
1722
|
-
visible: screenSettingsOpened,
|
|
1723
|
-
align: "right",
|
|
1724
|
-
onClickOutside: onDropdownClickOutside
|
|
1725
|
-
})) : null) : null, /*#__PURE__*/React.createElement("div", {
|
|
1726
|
-
className: classNames(['flex-grow-1', 'd-flex', 'w-100', styles$1.content])
|
|
1727
|
-
}, screen !== null ? /*#__PURE__*/React.createElement(CSSTransitionGroup, {
|
|
1728
|
-
transitionName: transitionName,
|
|
1729
|
-
transitionEnterTimeout: transitionTimeout,
|
|
1730
|
-
transitionLeaveTimeout: transitionTimeout,
|
|
1731
|
-
className: "w-100 flex-grow-1"
|
|
1732
|
-
}, fieldParams !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1733
|
-
className: classNames(['w-100', styles$1.panel]),
|
|
1734
|
-
key: "field-".concat(fieldParams, "-").concat(formParams)
|
|
1735
|
-
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
1736
|
-
data: screen
|
|
1737
|
-
}, /*#__PURE__*/React.createElement(FieldWithContexts, {
|
|
1738
|
-
name: fieldParams.replace(/\//g, '.'),
|
|
1739
|
-
value: screen,
|
|
1740
|
-
form: formParams,
|
|
1741
|
-
className: styles$1.form,
|
|
1742
|
-
gotoFieldForm: gotoFieldForm,
|
|
1743
|
-
closeFieldForm: closeFieldForm,
|
|
1744
|
-
fieldContext: fieldContext,
|
|
1745
|
-
onChange: onScreenFormChange
|
|
1746
|
-
}))) : /*#__PURE__*/React.createElement("div", {
|
|
1747
|
-
className: classNames(['w-100', styles$1.panel]),
|
|
1748
|
-
key: "screen-".concat(screen.id)
|
|
1749
|
-
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
1750
|
-
data: screen
|
|
1751
|
-
}, /*#__PURE__*/React.createElement(ScreenForm, {
|
|
1752
|
-
value: screen,
|
|
1753
|
-
className: styles$1.form,
|
|
1754
|
-
onChange: onScreenFormChange,
|
|
1755
|
-
gotoFieldForm: gotoFieldForm,
|
|
1756
|
-
closeFieldForm: closeFieldForm
|
|
1757
|
-
})))) : /*#__PURE__*/React.createElement(Empty, {
|
|
1758
|
-
className: "w-100 m-2"
|
|
2831
|
+
className: classNames(['sticky-top', styles$7.navbar])
|
|
2832
|
+
}, /*#__PURE__*/React.createElement("strong", {
|
|
2833
|
+
className: "mb-0 mr-auto"
|
|
1759
2834
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1760
|
-
id: "
|
|
2835
|
+
id: "jf+4Hq",
|
|
1761
2836
|
defaultMessage: [{
|
|
1762
2837
|
"type": 0,
|
|
1763
|
-
"value": "
|
|
1764
|
-
}]
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2838
|
+
"value": "Screens"
|
|
2839
|
+
}]
|
|
2840
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
2841
|
+
theme: "primary",
|
|
2842
|
+
size: "sm",
|
|
2843
|
+
onClick: onClickAdd,
|
|
2844
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
2845
|
+
icon: faPlus
|
|
2846
|
+
})
|
|
2847
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
2848
|
+
className: "flex-grow-1 d-flex w-100 p-2"
|
|
2849
|
+
}, /*#__PURE__*/React.createElement(Route, {
|
|
2850
|
+
path: [routes.screen, routes.home],
|
|
2851
|
+
render: function render(_ref18) {
|
|
2852
|
+
var _ref18$match$params$s = _ref18.match.params.screen,
|
|
2853
|
+
screenId = _ref18$match$params$s === void 0 ? null : _ref18$match$params$s;
|
|
2854
|
+
return screens.length > 0 ? /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
2855
|
+
items: screens.map(function (it) {
|
|
2856
|
+
return {
|
|
2857
|
+
id: it.id,
|
|
2858
|
+
screen: it,
|
|
2859
|
+
href: url('screen', {
|
|
2860
|
+
screen: it.id
|
|
2861
|
+
}),
|
|
2862
|
+
active: it.id === screenId
|
|
2863
|
+
};
|
|
2864
|
+
}),
|
|
2865
|
+
isVertical: isVertical,
|
|
2866
|
+
withPreview: true,
|
|
2867
|
+
sortable: !isTree,
|
|
2868
|
+
className: "w-100",
|
|
2869
|
+
onClickItem: onClickScreen,
|
|
2870
|
+
onOrderChange: onOrderChange,
|
|
2871
|
+
isTree: isTree
|
|
2872
|
+
}) : /*#__PURE__*/React.createElement(Empty, {
|
|
2873
|
+
className: "flex-grow-1 p-2"
|
|
2874
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
2875
|
+
theme: "primary",
|
|
2876
|
+
onClick: onClickAdd
|
|
2877
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
2878
|
+
id: "JoWKee",
|
|
2879
|
+
defaultMessage: [{
|
|
2880
|
+
"type": 0,
|
|
2881
|
+
"value": "Create your first screen"
|
|
2882
|
+
}]
|
|
2883
|
+
})));
|
|
2884
|
+
}
|
|
2885
|
+
})), createModalOpened ? /*#__PURE__*/React.createElement(ScreenTypesModal, {
|
|
2886
|
+
selectedTypes: isTheme ? screens.map(function (_ref19) {
|
|
2887
|
+
var type = _ref19.type;
|
|
2888
|
+
return type;
|
|
2889
|
+
}) : [],
|
|
2890
|
+
onClickScreenType: onClickScreenType,
|
|
2891
|
+
onRequestClose: onCreateModalRequestClose
|
|
1769
2892
|
}) : null);
|
|
1770
2893
|
};
|
|
1771
2894
|
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
var styles = {"container":"micromag-editor-container","left":"micromag-editor-left","right":"micromag-editor-right","center":"micromag-editor-center","fullscreen":"micromag-editor-fullscreen","preview":"micromag-editor-preview","inner":"micromag-editor-inner","visible":"micromag-editor-visible","screen-medium":"micromag-editor-screen-medium","top":"micromag-editor-top"};
|
|
2895
|
+
EditorScreens.propTypes = propTypes$4;
|
|
2896
|
+
EditorScreens.defaultProps = defaultProps$4;
|
|
1776
2897
|
|
|
1777
|
-
var propTypes$
|
|
2898
|
+
var propTypes$3 = {
|
|
1778
2899
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
1779
2900
|
deviceScreens: PropTypes$1.deviceScreens,
|
|
1780
2901
|
viewerTheme: PropTypes$1.viewerTheme,
|
|
@@ -1785,7 +2906,7 @@ var propTypes$1 = {
|
|
|
1785
2906
|
onChange: PropTypes.func,
|
|
1786
2907
|
className: PropTypes.string
|
|
1787
2908
|
};
|
|
1788
|
-
var defaultProps$
|
|
2909
|
+
var defaultProps$3 = {
|
|
1789
2910
|
value: null,
|
|
1790
2911
|
deviceScreens: getDeviceScreens(),
|
|
1791
2912
|
viewerTheme: null,
|
|
@@ -1878,7 +2999,11 @@ var Editor = function Editor(_ref) {
|
|
|
1878
2999
|
if (screenSize.screen) {
|
|
1879
3000
|
setMobileView('preview');
|
|
1880
3001
|
}
|
|
1881
|
-
|
|
3002
|
+
|
|
3003
|
+
push('screen', {
|
|
3004
|
+
screen: clickedScreenId.current
|
|
3005
|
+
});
|
|
3006
|
+
}, [screenSize.screen, push]);
|
|
1882
3007
|
var onPreviewScreenChange = useCallback(function (_ref4) {
|
|
1883
3008
|
var newScreenId = _ref4.id;
|
|
1884
3009
|
push('screen', {
|
|
@@ -1900,20 +3025,21 @@ var Editor = function Editor(_ref) {
|
|
|
1900
3025
|
var cnt = item.parentNode.parentNode.parentNode;
|
|
1901
3026
|
screens.scrollTop = cnt.offsetTop + item.offsetTop + item.offsetHeight / 2 - screens.clientHeight / 2;
|
|
1902
3027
|
}
|
|
1903
|
-
}, [screenId]);
|
|
3028
|
+
}, [screenId]); // console.log('editor level value', value);
|
|
3029
|
+
|
|
1904
3030
|
return /*#__PURE__*/React.createElement(ModalsProvider, null, /*#__PURE__*/React.createElement(PanelsProvider, null, /*#__PURE__*/React.createElement(ScreenSizeProvider, {
|
|
1905
3031
|
size: screenSize
|
|
1906
3032
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1907
|
-
className: classNames([styles.container, screenSize !== null ? screenSize.screens.map(function (screenName) {
|
|
1908
|
-
return styles["screen-".concat(screenName)];
|
|
1909
|
-
}) : null, (_ref5 = {}, _defineProperty(_ref5, styles.fullscreen, fullscreen), _defineProperty(_ref5, className, className), _ref5)]),
|
|
3033
|
+
className: classNames([styles$f.container, screenSize !== null ? screenSize.screens.map(function (screenName) {
|
|
3034
|
+
return styles$f["screen-".concat(screenName)];
|
|
3035
|
+
}) : null, (_ref5 = {}, _defineProperty(_ref5, styles$f.fullscreen, fullscreen), _defineProperty(_ref5, className, className), _ref5)]),
|
|
1910
3036
|
ref: refContainer
|
|
1911
3037
|
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
1912
3038
|
theme: "light",
|
|
1913
3039
|
compact: true,
|
|
1914
3040
|
noWrap: true,
|
|
1915
3041
|
withoutCollapse: true,
|
|
1916
|
-
className: styles.top
|
|
3042
|
+
className: styles$f.top
|
|
1917
3043
|
}, mobileView !== 'screens' ? /*#__PURE__*/React.createElement(Button, {
|
|
1918
3044
|
size: "sm",
|
|
1919
3045
|
theme: "secondary",
|
|
@@ -1946,9 +3072,9 @@ var Editor = function Editor(_ref) {
|
|
|
1946
3072
|
"value": "View screen"
|
|
1947
3073
|
}]
|
|
1948
3074
|
})) : null), /*#__PURE__*/React.createElement("div", {
|
|
1949
|
-
className: styles.inner
|
|
3075
|
+
className: styles$f.inner
|
|
1950
3076
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1951
|
-
className: classNames([styles.left, _defineProperty({}, styles.visible, !isMobile || mobileView === 'screens')]),
|
|
3077
|
+
className: classNames([styles$f.left, _defineProperty({}, styles$f.visible, !isMobile || mobileView === 'screens')]),
|
|
1952
3078
|
ref: refScreensContainer
|
|
1953
3079
|
}, /*#__PURE__*/React.createElement(EditorScreens, {
|
|
1954
3080
|
value: story,
|
|
@@ -1958,28 +3084,29 @@ var Editor = function Editor(_ref) {
|
|
|
1958
3084
|
onChange: onStoryChange,
|
|
1959
3085
|
onClickScreen: onClickScreen,
|
|
1960
3086
|
isVertical: !isMobile,
|
|
1961
|
-
className: styles.inner
|
|
3087
|
+
className: styles$f.inner,
|
|
3088
|
+
isTree: true
|
|
1962
3089
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1963
|
-
className: classNames([styles.center, _defineProperty({}, styles.visible, !isMobile || mobileView === 'preview')])
|
|
3090
|
+
className: classNames([styles$f.center, _defineProperty({}, styles$f.visible, !isMobile || mobileView === 'preview')])
|
|
1964
3091
|
}, /*#__PURE__*/React.createElement(EditorPreview, {
|
|
1965
3092
|
value: story,
|
|
1966
3093
|
isTheme: isTheme,
|
|
1967
3094
|
viewerTheme: viewerTheme,
|
|
1968
|
-
className: styles.preview,
|
|
3095
|
+
className: styles$f.preview,
|
|
1969
3096
|
onScreenChange: onPreviewScreenChange
|
|
1970
3097
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1971
|
-
className: classNames([styles.right, _defineProperty({}, styles.visible, !isMobile || mobileView === 'form')])
|
|
3098
|
+
className: classNames([styles$f.right, _defineProperty({}, styles$f.visible, !isMobile || mobileView === 'form')])
|
|
1972
3099
|
}, /*#__PURE__*/React.createElement(EditForm, {
|
|
1973
3100
|
key: screenId,
|
|
1974
3101
|
value: story,
|
|
1975
3102
|
isTheme: isTheme,
|
|
1976
3103
|
onChange: onStoryChange,
|
|
1977
|
-
className: styles.inner
|
|
3104
|
+
className: styles$f.inner
|
|
1978
3105
|
}))), /*#__PURE__*/React.createElement(Modals, null)))));
|
|
1979
3106
|
};
|
|
1980
3107
|
|
|
1981
|
-
Editor.propTypes = propTypes$
|
|
1982
|
-
Editor.defaultProps = defaultProps$
|
|
3108
|
+
Editor.propTypes = propTypes$3;
|
|
3109
|
+
Editor.defaultProps = defaultProps$3;
|
|
1983
3110
|
|
|
1984
3111
|
var home = "/";
|
|
1985
3112
|
var screen = "/:screen";
|
|
@@ -1990,6 +3117,101 @@ var defaultRoutes = {
|
|
|
1990
3117
|
"screen.field.form": "/:screen/:field+/:form"
|
|
1991
3118
|
};
|
|
1992
3119
|
|
|
3120
|
+
var routes = PropTypes.shape({
|
|
3121
|
+
home: PropTypes.string.isRequired,
|
|
3122
|
+
screen: PropTypes.string.isRequired,
|
|
3123
|
+
'screen.field': PropTypes.string.isRequired,
|
|
3124
|
+
'screen.field.form': PropTypes.string.isRequired
|
|
3125
|
+
});
|
|
3126
|
+
|
|
3127
|
+
var styles = {"container":"micromag-editor-forms-settings-container","inner":"micromag-editor-forms-settings-inner"};
|
|
3128
|
+
|
|
3129
|
+
var propTypes$2 = {
|
|
3130
|
+
name: PropTypes.string,
|
|
3131
|
+
field: PropTypes$1.formField.isRequired,
|
|
3132
|
+
value: PropTypes$1.component,
|
|
3133
|
+
className: PropTypes.string,
|
|
3134
|
+
gotoFieldForm: PropTypes.func.isRequired,
|
|
3135
|
+
closeFieldForm: PropTypes.func.isRequired,
|
|
3136
|
+
onChange: PropTypes.func
|
|
3137
|
+
};
|
|
3138
|
+
var defaultProps$2 = {
|
|
3139
|
+
name: null,
|
|
3140
|
+
value: null,
|
|
3141
|
+
className: null,
|
|
3142
|
+
onChange: null
|
|
3143
|
+
};
|
|
3144
|
+
|
|
3145
|
+
var SettingsForm = function SettingsForm(_ref) {
|
|
3146
|
+
var name = _ref.name,
|
|
3147
|
+
field = _ref.field,
|
|
3148
|
+
value = _ref.value,
|
|
3149
|
+
className = _ref.className,
|
|
3150
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
3151
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
3152
|
+
onChange = _ref.onChange;
|
|
3153
|
+
var _field$type = field.type,
|
|
3154
|
+
type = _field$type === void 0 ? null : _field$type;
|
|
3155
|
+
var fieldsManager = useFieldsManager();
|
|
3156
|
+
|
|
3157
|
+
var _ref2 = type !== null ? fieldsManager.getDefinition(type) : field,
|
|
3158
|
+
_ref2$component = _ref2.component,
|
|
3159
|
+
fieldComponent = _ref2$component === void 0 ? null : _ref2$component,
|
|
3160
|
+
settings = _ref2.settings;
|
|
3161
|
+
|
|
3162
|
+
var FieldComponent = useFieldComponent(fieldComponent);
|
|
3163
|
+
var FieldsComponent = useFieldComponent('fields');
|
|
3164
|
+
var SettingsComponent = FieldComponent !== null ? FieldComponent.settingsComponent || FieldsComponent : FieldsComponent;
|
|
3165
|
+
var onSettingsChange = useCallback(function (newSettingsValue) {
|
|
3166
|
+
var newValue = _objectSpread(_objectSpread({}, value), newSettingsValue);
|
|
3167
|
+
|
|
3168
|
+
if (onChange !== null) {
|
|
3169
|
+
onChange(newValue);
|
|
3170
|
+
}
|
|
3171
|
+
}, [value, onChange]);
|
|
3172
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3173
|
+
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
3174
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3175
|
+
className: styles.inner
|
|
3176
|
+
}, /*#__PURE__*/React.createElement(SettingsComponent, {
|
|
3177
|
+
name: name,
|
|
3178
|
+
field: field,
|
|
3179
|
+
fields: settings,
|
|
3180
|
+
value: value,
|
|
3181
|
+
onChange: onSettingsChange,
|
|
3182
|
+
gotoFieldForm: gotoFieldForm,
|
|
3183
|
+
closeFieldForm: closeFieldForm
|
|
3184
|
+
})));
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
SettingsForm.propTypes = propTypes$2;
|
|
3188
|
+
SettingsForm.defaultProps = defaultProps$2;
|
|
3189
|
+
|
|
3190
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3191
|
+
|
|
3192
|
+
var FormsComponents = /*#__PURE__*/Object.freeze({
|
|
3193
|
+
__proto__: null,
|
|
3194
|
+
Settings: SettingsForm
|
|
3195
|
+
});
|
|
3196
|
+
|
|
3197
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
3198
|
+
var propTypes$1 = {
|
|
3199
|
+
children: PropTypes.node
|
|
3200
|
+
};
|
|
3201
|
+
var defaultProps$1 = {
|
|
3202
|
+
children: null
|
|
3203
|
+
};
|
|
3204
|
+
|
|
3205
|
+
var FormsProvider = function FormsProvider(props) {
|
|
3206
|
+
return /*#__PURE__*/React.createElement(ComponentsProvider, Object.assign({
|
|
3207
|
+
namespace: FORMS_NAMESPACE,
|
|
3208
|
+
components: FormsComponents
|
|
3209
|
+
}, props));
|
|
3210
|
+
};
|
|
3211
|
+
|
|
3212
|
+
FormsProvider.propTypes = propTypes$1;
|
|
3213
|
+
FormsProvider.defaultProps = defaultProps$1;
|
|
3214
|
+
|
|
1993
3215
|
var _excluded = ["value", "memoryRouter", "routes", "basePath", "uppy", "googleApiKey", "googleMapsLibraries"];
|
|
1994
3216
|
var propTypes = {
|
|
1995
3217
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|