@micromag/editor 0.2.405 → 0.2.409
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 +2446 -1254
- package/lib/index.js +2454 -1261
- 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,698 @@ 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
|
+
};
|
|
817
793
|
|
|
818
794
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
819
|
-
var propTypes$
|
|
795
|
+
var propTypes$h = {
|
|
820
796
|
color: PropTypes.string,
|
|
821
797
|
className: PropTypes.string
|
|
822
798
|
};
|
|
823
|
-
var defaultProps$
|
|
799
|
+
var defaultProps$h = {
|
|
824
800
|
color: 'currentColor',
|
|
825
801
|
className: null
|
|
826
802
|
};
|
|
@@ -845,15 +821,15 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
845
821
|
}));
|
|
846
822
|
};
|
|
847
823
|
|
|
848
|
-
DesktopIcon.propTypes = propTypes$
|
|
849
|
-
DesktopIcon.defaultProps = defaultProps$
|
|
824
|
+
DesktopIcon.propTypes = propTypes$h;
|
|
825
|
+
DesktopIcon.defaultProps = defaultProps$h;
|
|
850
826
|
|
|
851
827
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
852
|
-
var propTypes$
|
|
828
|
+
var propTypes$g = {
|
|
853
829
|
color: PropTypes.string,
|
|
854
830
|
className: PropTypes.string
|
|
855
831
|
};
|
|
856
|
-
var defaultProps$
|
|
832
|
+
var defaultProps$g = {
|
|
857
833
|
color: 'currentColor',
|
|
858
834
|
className: null
|
|
859
835
|
};
|
|
@@ -878,8 +854,8 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
878
854
|
}));
|
|
879
855
|
};
|
|
880
856
|
|
|
881
|
-
MobileIcon.propTypes = propTypes$
|
|
882
|
-
MobileIcon.defaultProps = defaultProps$
|
|
857
|
+
MobileIcon.propTypes = propTypes$g;
|
|
858
|
+
MobileIcon.defaultProps = defaultProps$g;
|
|
883
859
|
|
|
884
860
|
var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
885
861
|
__proto__: null,
|
|
@@ -887,15 +863,15 @@ var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
|
887
863
|
Mobile: MobileIcon
|
|
888
864
|
});
|
|
889
865
|
|
|
890
|
-
var styles$
|
|
866
|
+
var styles$a = {"container":"micromag-editor-buttons-device-container","icon":"micromag-editor-buttons-device-icon"};
|
|
891
867
|
|
|
892
868
|
var _excluded$6 = ["device", "className", "iconComponents"];
|
|
893
|
-
var propTypes$
|
|
869
|
+
var propTypes$f = {
|
|
894
870
|
device: PropTypes.string.isRequired,
|
|
895
871
|
iconComponents: PropTypes$1.components,
|
|
896
872
|
className: PropTypes.string
|
|
897
873
|
};
|
|
898
|
-
var defaultProps$
|
|
874
|
+
var defaultProps$f = {
|
|
899
875
|
iconComponents: DeviceIcons,
|
|
900
876
|
className: null
|
|
901
877
|
};
|
|
@@ -908,24 +884,24 @@ var DeviceButton = function DeviceButton(_ref) {
|
|
|
908
884
|
|
|
909
885
|
var DeviceIcon = getComponentFromName(device, iconComponents, DesktopIcon);
|
|
910
886
|
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
911
|
-
className: classNames([styles$
|
|
887
|
+
className: classNames([styles$a.container, _defineProperty({}, className, className !== null)])
|
|
912
888
|
}, props), /*#__PURE__*/React.createElement(DeviceIcon, {
|
|
913
|
-
className: styles$
|
|
889
|
+
className: styles$a.icon
|
|
914
890
|
}));
|
|
915
891
|
};
|
|
916
892
|
|
|
917
|
-
DeviceButton.propTypes = propTypes$
|
|
918
|
-
DeviceButton.defaultProps = defaultProps$
|
|
893
|
+
DeviceButton.propTypes = propTypes$f;
|
|
894
|
+
DeviceButton.defaultProps = defaultProps$f;
|
|
919
895
|
|
|
920
|
-
var styles$
|
|
896
|
+
var styles$9 = {"container":"micromag-editor-menus-devices-container","button":"micromag-editor-menus-devices-button"};
|
|
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$9.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$9.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,1794 @@ 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
|
-
|
|
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
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
var ScreenButton = function ScreenButton(_ref) {
|
|
1122
|
+
var _ref2;
|
|
1123
|
+
|
|
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
|
+
};
|
|
1156
|
+
|
|
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
|
+
|
|
1249
|
+
function getDragDepth(offset, indentationWidth) {
|
|
1250
|
+
return Math.round(offset / indentationWidth);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function getMaxDepth(_ref) {
|
|
1254
|
+
var previousItem = _ref.previousItem;
|
|
1255
|
+
|
|
1256
|
+
if (previousItem) {
|
|
1257
|
+
// return previousItem.depth + 1;
|
|
1258
|
+
return 1;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
return 0;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
function getMinDepth(_ref2) {
|
|
1265
|
+
var nextItem = _ref2.nextItem;
|
|
1266
|
+
|
|
1267
|
+
if (nextItem) {
|
|
1268
|
+
// return nextItem.depth;
|
|
1269
|
+
return 0;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
return 0;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
1276
|
+
var overItemIndex = items.findIndex(function (_ref3) {
|
|
1277
|
+
var id = _ref3.id;
|
|
1278
|
+
return id === overId;
|
|
1279
|
+
});
|
|
1280
|
+
var activeItemIndex = items.findIndex(function (_ref4) {
|
|
1281
|
+
var id = _ref4.id;
|
|
1282
|
+
return id === activeId;
|
|
1283
|
+
});
|
|
1284
|
+
var activeItem = items[activeItemIndex];
|
|
1285
|
+
var newItems = arrayMove(items, activeItemIndex, overItemIndex);
|
|
1286
|
+
var previousItem = newItems[overItemIndex - 1];
|
|
1287
|
+
var nextItem = newItems[overItemIndex + 1];
|
|
1288
|
+
var dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
1289
|
+
var projectedDepth = activeItem.depth + dragDepth;
|
|
1290
|
+
var maxDepth = getMaxDepth({
|
|
1291
|
+
previousItem: previousItem
|
|
1292
|
+
});
|
|
1293
|
+
var minDepth = getMinDepth({
|
|
1294
|
+
nextItem: nextItem
|
|
1295
|
+
});
|
|
1296
|
+
var depth = projectedDepth;
|
|
1297
|
+
|
|
1298
|
+
if (projectedDepth >= maxDepth) {
|
|
1299
|
+
depth = maxDepth;
|
|
1300
|
+
} else if (projectedDepth < minDepth) {
|
|
1301
|
+
depth = minDepth;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function getParentId() {
|
|
1305
|
+
var _newItems$slice$rever;
|
|
1306
|
+
|
|
1307
|
+
if (depth === 0 || !previousItem) {
|
|
1308
|
+
return null;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
if (depth === previousItem.depth) {
|
|
1312
|
+
return previousItem.parentId;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
if (depth > previousItem.depth) {
|
|
1316
|
+
return previousItem.id;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
var newParent = (_newItems$slice$rever = newItems.slice(0, overItemIndex).reverse().find(function (item) {
|
|
1320
|
+
return item.depth === depth;
|
|
1321
|
+
})) === null || _newItems$slice$rever === void 0 ? void 0 : _newItems$slice$rever.parentId;
|
|
1322
|
+
return newParent !== null && newParent !== void 0 ? newParent : null;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
return {
|
|
1326
|
+
depth: depth,
|
|
1327
|
+
maxDepth: maxDepth,
|
|
1328
|
+
minDepth: minDepth,
|
|
1329
|
+
parentId: getParentId()
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
function flatten(items) {
|
|
1334
|
+
var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1335
|
+
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1336
|
+
return items.reduce(function (acc, item, index) {
|
|
1337
|
+
return [].concat(_toConsumableArray(acc), [_objectSpread(_objectSpread({}, item), {}, {
|
|
1338
|
+
parentId: item.parentId || parentId,
|
|
1339
|
+
depth: item.parentId ? 1 : 0,
|
|
1340
|
+
index: index
|
|
1341
|
+
})], _toConsumableArray(flatten(item.children || [], item.id, depth + 1)));
|
|
1342
|
+
}, []);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
function flattenTree(items) {
|
|
1346
|
+
return flatten(items);
|
|
1347
|
+
}
|
|
1348
|
+
function buildTree(flattenedItems) {
|
|
1349
|
+
var items = flattenedItems.map(function (item) {
|
|
1350
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1351
|
+
children: []
|
|
1352
|
+
});
|
|
1353
|
+
});
|
|
1354
|
+
var nodeList = items.reduce(function (acc, item) {
|
|
1355
|
+
var _item$parentId = item.parentId,
|
|
1356
|
+
parentId = _item$parentId === void 0 ? null : _item$parentId;
|
|
1357
|
+
|
|
1358
|
+
if (parentId) {
|
|
1359
|
+
var found = false;
|
|
1360
|
+
var newList = acc.map(function (it) {
|
|
1361
|
+
if (it.id === parentId) {
|
|
1362
|
+
found = true;
|
|
1363
|
+
return _objectSpread(_objectSpread({}, it), {}, {
|
|
1364
|
+
children: [].concat(_toConsumableArray(it.children), [_objectSpread({}, item)])
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
return it;
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
if (found) {
|
|
1372
|
+
return newList;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
acc.push(_objectSpread(_objectSpread({}, items.find(function (_ref5) {
|
|
1376
|
+
var id = _ref5.id;
|
|
1377
|
+
return id === parentId;
|
|
1378
|
+
}) || null), {}, {
|
|
1379
|
+
children: [item]
|
|
1380
|
+
}));
|
|
1381
|
+
return acc;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
acc.push(item);
|
|
1385
|
+
return acc;
|
|
1386
|
+
}, []);
|
|
1387
|
+
return nodeList;
|
|
1388
|
+
}
|
|
1389
|
+
function findItemDeep(items, itemId) {
|
|
1390
|
+
for (var i = 0; i < items.length - 1; i += 1) {
|
|
1391
|
+
var item = items[i] || {};
|
|
1392
|
+
var id = item.id,
|
|
1393
|
+
_item$children = item.children,
|
|
1394
|
+
children = _item$children === void 0 ? [] : _item$children;
|
|
1395
|
+
|
|
1396
|
+
if (id === itemId) {
|
|
1397
|
+
return item;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
if (children.length) {
|
|
1401
|
+
var child = findItemDeep(children, itemId);
|
|
1402
|
+
|
|
1403
|
+
if (child) {
|
|
1404
|
+
return child;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
return undefined;
|
|
1410
|
+
}
|
|
1411
|
+
function removeItem(items, id) {
|
|
1412
|
+
var newItems = [];
|
|
1413
|
+
|
|
1414
|
+
for (var i = 0; i < items.length - 1; i += 1) {
|
|
1415
|
+
var item = items[i] || {};
|
|
1416
|
+
|
|
1417
|
+
if (item.id === id) {
|
|
1418
|
+
// eslint-disable-next-line no-continue
|
|
1419
|
+
continue;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
if (item.children.length) {
|
|
1423
|
+
item.children = removeItem(item.children || [], id);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
newItems.push(item);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
return newItems;
|
|
1430
|
+
}
|
|
1431
|
+
function setProperty(items, id, property, setter) {
|
|
1432
|
+
// const item = items[i];
|
|
1433
|
+
// if (item.id === id) {
|
|
1434
|
+
// item[property] = setter(item[property]);
|
|
1435
|
+
// newItems.push({ ...item });
|
|
1436
|
+
// } else {
|
|
1437
|
+
// const { children = [] } = item;
|
|
1438
|
+
// let newChildren = [];
|
|
1439
|
+
// if (children.length > 0) {
|
|
1440
|
+
// newChildren = setProperty(children, id, property, setter);
|
|
1441
|
+
// }
|
|
1442
|
+
// newItems.push({ ...item, children: newChildren });
|
|
1443
|
+
// }
|
|
1444
|
+
// }
|
|
1445
|
+
|
|
1446
|
+
var _iterator = _createForOfIteratorHelper(items),
|
|
1447
|
+
_step;
|
|
1448
|
+
|
|
1449
|
+
try {
|
|
1450
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1451
|
+
var item = _step.value;
|
|
1452
|
+
|
|
1453
|
+
if (item.id === id) {
|
|
1454
|
+
item[property] = setter(item[property]);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
var _item$children2 = item.children,
|
|
1459
|
+
children = _item$children2 === void 0 ? [] : _item$children2;
|
|
1460
|
+
|
|
1461
|
+
if (children.length) {
|
|
1462
|
+
children = setProperty(children, id, property, setter);
|
|
1463
|
+
}
|
|
1464
|
+
} // console.log('fubar', items, newItems);
|
|
1465
|
+
// return newItems;
|
|
1466
|
+
|
|
1467
|
+
} catch (err) {
|
|
1468
|
+
_iterator.e(err);
|
|
1469
|
+
} finally {
|
|
1470
|
+
_iterator.f();
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
return _toConsumableArray(items);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
function countChildren(items) {
|
|
1477
|
+
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1478
|
+
return items.reduce(function (acc, _ref7) {
|
|
1479
|
+
var _ref7$children = _ref7.children,
|
|
1480
|
+
children = _ref7$children === void 0 ? [] : _ref7$children;
|
|
1481
|
+
|
|
1482
|
+
if (children.length) {
|
|
1483
|
+
return countChildren(children, acc + 1);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
return acc + 1;
|
|
1487
|
+
}, count);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
function getChildCount(items, id) {
|
|
1491
|
+
if (!id) {
|
|
1492
|
+
return 0;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
var item = findItemDeep(items, id);
|
|
1496
|
+
return item ? countChildren(item.children || []) : 0;
|
|
1497
|
+
}
|
|
1498
|
+
function removeChildrenOf(items, ids) {
|
|
1499
|
+
var excludeParentIds = _toConsumableArray(ids);
|
|
1500
|
+
|
|
1501
|
+
return items.filter(function (item) {
|
|
1502
|
+
if (item.parentId && excludeParentIds.includes(item.parentId)) {
|
|
1503
|
+
var _item$children3 = item.children,
|
|
1504
|
+
children = _item$children3 === void 0 ? [] : _item$children3;
|
|
1505
|
+
|
|
1506
|
+
if (children.length) {
|
|
1507
|
+
excludeParentIds.push(item.id);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
return false;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
return true;
|
|
1122
1514
|
});
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
var directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
|
|
1518
|
+
var horizontal = [KeyboardCode.Left, KeyboardCode.Right];
|
|
1519
|
+
var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(context, indentationWidth) {
|
|
1520
|
+
return function (event, _ref) {
|
|
1521
|
+
var currentCoordinates = _ref.currentCoordinates,
|
|
1522
|
+
_ref$context = _ref.context,
|
|
1523
|
+
active = _ref$context.active,
|
|
1524
|
+
over = _ref$context.over,
|
|
1525
|
+
collisionRect = _ref$context.collisionRect,
|
|
1526
|
+
droppableContainers = _ref$context.droppableContainers;
|
|
1527
|
+
|
|
1528
|
+
if (directions.includes(event.code)) {
|
|
1529
|
+
var _droppableContainers$;
|
|
1530
|
+
|
|
1531
|
+
if (!active || !collisionRect) {
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
event.preventDefault();
|
|
1536
|
+
var _context$current = context.current,
|
|
1537
|
+
items = _context$current.items,
|
|
1538
|
+
offset = _context$current.offset;
|
|
1539
|
+
|
|
1540
|
+
if (horizontal.includes(event.code) && over !== null && over !== void 0 && over.id) {
|
|
1541
|
+
var _getProjection = getProjection(items, active.id, over.id, offset, indentationWidth),
|
|
1542
|
+
depth = _getProjection.depth,
|
|
1543
|
+
maxDepth = _getProjection.maxDepth,
|
|
1544
|
+
minDepth = _getProjection.minDepth;
|
|
1545
|
+
|
|
1546
|
+
switch (event.code) {
|
|
1547
|
+
case KeyboardCode.Left:
|
|
1548
|
+
if (depth > minDepth) {
|
|
1549
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
1550
|
+
x: currentCoordinates.x - indentationWidth
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
break;
|
|
1555
|
+
|
|
1556
|
+
case KeyboardCode.Right:
|
|
1557
|
+
if (depth < maxDepth) {
|
|
1558
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
1559
|
+
x: currentCoordinates.x + indentationWidth
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
break;
|
|
1564
|
+
|
|
1565
|
+
default:
|
|
1566
|
+
return undefined;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
return undefined;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
var containers = [];
|
|
1573
|
+
var overRect = over !== null && over !== void 0 && over.id ? (_droppableContainers$ = droppableContainers.get(over.id)) === null || _droppableContainers$ === void 0 ? void 0 : _droppableContainers$.rect.current : undefined;
|
|
1574
|
+
|
|
1575
|
+
if (overRect) {
|
|
1576
|
+
droppableContainers.forEach(function (container) {
|
|
1577
|
+
if (container !== null && container !== void 0 && container.disabled) {
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
var rect = container === null || container === void 0 ? void 0 : container.rect.current;
|
|
1582
|
+
|
|
1583
|
+
if (!rect) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
switch (event.code) {
|
|
1588
|
+
case KeyboardCode.Down:
|
|
1589
|
+
if (overRect.top < rect.top) {
|
|
1590
|
+
containers.push(container);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
break;
|
|
1594
|
+
|
|
1595
|
+
case KeyboardCode.Up:
|
|
1596
|
+
if (overRect.top > rect.top) {
|
|
1597
|
+
containers.push(container);
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
break;
|
|
1601
|
+
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
var collisions = closestCorners({
|
|
1607
|
+
active: active,
|
|
1608
|
+
collisionRect: collisionRect,
|
|
1609
|
+
pointerCoordinates: null,
|
|
1610
|
+
droppableContainers: containers
|
|
1611
|
+
});
|
|
1612
|
+
var closestId = getFirstCollision(collisions, 'id');
|
|
1613
|
+
|
|
1614
|
+
if (closestId && over !== null && over !== void 0 && over.id) {
|
|
1615
|
+
var _droppableContainers$2, _droppableContainers$3;
|
|
1616
|
+
|
|
1617
|
+
var newNode = (_droppableContainers$2 = droppableContainers.get(closestId)) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.node.current;
|
|
1618
|
+
var activeNodeRect = (_droppableContainers$3 = droppableContainers.get(active.id)) === null || _droppableContainers$3 === void 0 ? void 0 : _droppableContainers$3.rect.current;
|
|
1619
|
+
|
|
1620
|
+
if (newNode && activeNodeRect) {
|
|
1621
|
+
var newRect = getClientRect(newNode, {
|
|
1622
|
+
ignoreTransform: true
|
|
1623
|
+
});
|
|
1624
|
+
var newItem = items.find(function (_ref2) {
|
|
1625
|
+
var id = _ref2.id;
|
|
1626
|
+
return id === closestId;
|
|
1627
|
+
});
|
|
1628
|
+
var activeItem = items.find(function (_ref3) {
|
|
1629
|
+
var id = _ref3.id;
|
|
1630
|
+
return id === active.id;
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
if (newItem && activeItem) {
|
|
1634
|
+
var _getProjection2 = getProjection(items, active.id, closestId, (newItem.depth - activeItem.depth) * indentationWidth, indentationWidth),
|
|
1635
|
+
_depth = _getProjection2.depth;
|
|
1636
|
+
|
|
1637
|
+
var topOffset = newRect.top > activeNodeRect.top ? Math.abs(activeNodeRect.height - newRect.height) : 0;
|
|
1638
|
+
var newCoordinates = {
|
|
1639
|
+
x: newRect.left + _depth * indentationWidth,
|
|
1640
|
+
y: newRect.top + topOffset
|
|
1641
|
+
};
|
|
1642
|
+
return newCoordinates;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
return undefined;
|
|
1649
|
+
};
|
|
1123
1650
|
};
|
|
1124
1651
|
|
|
1125
|
-
var
|
|
1652
|
+
var styles$3 = {"wrapper":"micromag-editor-sortable-tree-item-actions-wrapper","inner":"micromag-editor-sortable-tree-item-actions-inner","button":"micromag-editor-sortable-tree-item-actions-button","withChildren":"micromag-editor-sortable-tree-item-actions-withChildren","clone":"micromag-editor-sortable-tree-item-actions-clone","ghost":"micromag-editor-sortable-tree-item-actions-ghost","indicator":"micromag-editor-sortable-tree-item-actions-indicator","handle":"micromag-editor-sortable-tree-item-actions-handle","text":"micromag-editor-sortable-tree-item-actions-text","collapsedCount":"micromag-editor-sortable-tree-item-actions-collapsedCount","count":"micromag-editor-sortable-tree-item-actions-count","disableInteraction":"micromag-editor-sortable-tree-item-actions-disableInteraction","Count":"micromag-editor-sortable-tree-item-actions-Count","Text":"micromag-editor-sortable-tree-item-actions-Text","disableSelection":"micromag-editor-sortable-tree-item-actions-disableSelection","collapse":"micromag-editor-sortable-tree-item-actions-collapse","collapsed":"micromag-editor-sortable-tree-item-actions-collapsed","children":"micromag-editor-sortable-tree-item-actions-children"};
|
|
1126
1653
|
|
|
1127
|
-
var
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1654
|
+
var _excluded$4 = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "onClick", "style", "value", "wrapperRef", "showId", "children"];
|
|
1655
|
+
var propTypes$a = {
|
|
1656
|
+
childCount: PropTypes.number,
|
|
1657
|
+
clone: PropTypes.bool,
|
|
1658
|
+
collapsed: PropTypes.bool,
|
|
1659
|
+
depth: PropTypes.number.isRequired,
|
|
1660
|
+
disableInteraction: PropTypes.bool,
|
|
1661
|
+
disableSelection: PropTypes.bool,
|
|
1662
|
+
ghost: PropTypes.bool,
|
|
1663
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1664
|
+
handleProps: PropTypes.any,
|
|
1665
|
+
indicator: PropTypes.bool,
|
|
1666
|
+
indentationWidth: PropTypes.number.isRequired,
|
|
1667
|
+
value: PropTypes.string,
|
|
1668
|
+
onCollapse: PropTypes.func,
|
|
1669
|
+
onRemove: PropTypes.func,
|
|
1670
|
+
onClick: PropTypes.func,
|
|
1671
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1672
|
+
wrapperRef: PropTypes.any,
|
|
1673
|
+
style: PropTypes.shape({
|
|
1674
|
+
width: PropTypes.number.isRequired,
|
|
1675
|
+
height: PropTypes.number.isRequired,
|
|
1676
|
+
transform: PropTypes.string.isRequired
|
|
1677
|
+
}),
|
|
1678
|
+
showId: PropTypes.bool,
|
|
1679
|
+
children: PropTypes.node
|
|
1680
|
+
};
|
|
1681
|
+
var defaultProps$a = {
|
|
1682
|
+
childCount: null,
|
|
1683
|
+
clone: false,
|
|
1684
|
+
collapsed: false,
|
|
1685
|
+
disableInteraction: false,
|
|
1686
|
+
disableSelection: false,
|
|
1687
|
+
ghost: false,
|
|
1688
|
+
handleProps: null,
|
|
1689
|
+
indicator: false,
|
|
1690
|
+
value: null,
|
|
1691
|
+
onCollapse: null,
|
|
1692
|
+
onRemove: null,
|
|
1693
|
+
onClick: null,
|
|
1694
|
+
wrapperRef: null,
|
|
1695
|
+
style: null,
|
|
1696
|
+
showId: false,
|
|
1697
|
+
children: null
|
|
1698
|
+
};
|
|
1699
|
+
var SortableTreeItemActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
1700
|
+
var _ref2;
|
|
1701
|
+
|
|
1702
|
+
var childCount = _ref.childCount,
|
|
1703
|
+
clone = _ref.clone,
|
|
1704
|
+
depth = _ref.depth,
|
|
1705
|
+
disableSelection = _ref.disableSelection,
|
|
1706
|
+
disableInteraction = _ref.disableInteraction,
|
|
1707
|
+
ghost = _ref.ghost,
|
|
1708
|
+
handleProps = _ref.handleProps,
|
|
1709
|
+
indentationWidth = _ref.indentationWidth,
|
|
1710
|
+
indicator = _ref.indicator,
|
|
1711
|
+
collapsed = _ref.collapsed,
|
|
1712
|
+
onCollapse = _ref.onCollapse,
|
|
1713
|
+
onRemove = _ref.onRemove,
|
|
1714
|
+
onClick = _ref.onClick,
|
|
1715
|
+
style = _ref.style,
|
|
1716
|
+
value = _ref.value,
|
|
1717
|
+
wrapperRef = _ref.wrapperRef,
|
|
1718
|
+
showId = _ref.showId,
|
|
1719
|
+
children = _ref.children,
|
|
1720
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
1721
|
+
|
|
1722
|
+
return /*#__PURE__*/React.createElement("li", Object.assign({
|
|
1723
|
+
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)]),
|
|
1724
|
+
ref: wrapperRef,
|
|
1725
|
+
style: _objectSpread({
|
|
1726
|
+
marginLeft: "".concat(indentationWidth * depth, "px")
|
|
1727
|
+
}, style)
|
|
1728
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
1729
|
+
className: styles$3.inner,
|
|
1730
|
+
ref: ref,
|
|
1731
|
+
style: {
|
|
1732
|
+
width: style.width,
|
|
1733
|
+
height: style.height
|
|
1734
|
+
}
|
|
1735
|
+
}, /*#__PURE__*/React.createElement("button", Object.assign({
|
|
1736
|
+
className: classNames([styles$3.button, styles$3.handle]),
|
|
1737
|
+
type: "button"
|
|
1738
|
+
}, handleProps), /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1739
|
+
icon: faGripLines
|
|
1740
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
1741
|
+
className: classNames([styles$3.button, styles$3.full]),
|
|
1742
|
+
type: "button",
|
|
1743
|
+
onClick: onClick,
|
|
1744
|
+
style: {
|
|
1745
|
+
width: style.width,
|
|
1746
|
+
height: style.height
|
|
1747
|
+
}
|
|
1748
|
+
}), showId ? /*#__PURE__*/React.createElement("span", {
|
|
1749
|
+
className: styles$3.text
|
|
1750
|
+
}, value) : null, !clone && onRemove ? /*#__PURE__*/React.createElement("button", {
|
|
1751
|
+
type: "button",
|
|
1752
|
+
onClick: onRemove
|
|
1753
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1754
|
+
icon: faTimes
|
|
1755
|
+
})) : null, clone && childCount && childCount > 1 ? /*#__PURE__*/React.createElement("span", {
|
|
1756
|
+
className: styles$3.count
|
|
1757
|
+
}, childCount) : null, onCollapse && childCount !== null && childCount > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
1758
|
+
className: styles$3.collapsedCount
|
|
1759
|
+
}, childCount) : null, onCollapse && depth === 0 ? /*#__PURE__*/React.createElement("button", {
|
|
1760
|
+
type: "button",
|
|
1761
|
+
onClick: onCollapse,
|
|
1762
|
+
className: classNames(styles$3.button, styles$3.collapse, collapsed && styles$3.collapsed),
|
|
1763
|
+
style: {
|
|
1764
|
+
width: style.width
|
|
1765
|
+
}
|
|
1766
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1767
|
+
icon: faAngleDown
|
|
1768
|
+
})) : null), /*#__PURE__*/React.createElement("div", {
|
|
1769
|
+
className: styles$3.children
|
|
1770
|
+
}, children));
|
|
1771
|
+
});
|
|
1772
|
+
SortableTreeItemActions.propTypes = propTypes$a;
|
|
1773
|
+
SortableTreeItemActions.defaultProps = defaultProps$a;
|
|
1774
|
+
|
|
1775
|
+
var _excluded$3 = ["id", "depth", "component", "screenValue", "style", "onCollapse", "onClick"];
|
|
1776
|
+
var propTypes$9 = {
|
|
1777
|
+
id: PropTypes.string.isRequired,
|
|
1778
|
+
depth: PropTypes.number.isRequired,
|
|
1779
|
+
component: PropTypes.func,
|
|
1780
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1781
|
+
screenValue: PropTypes.object,
|
|
1782
|
+
style: PropTypes.shape({
|
|
1783
|
+
width: PropTypes.number.isRequired,
|
|
1784
|
+
height: PropTypes.number.isRequired,
|
|
1785
|
+
scaledWidth: PropTypes.number.isRequired,
|
|
1786
|
+
scaledHeight: PropTypes.number.isRequired,
|
|
1787
|
+
transform: PropTypes.string.isRequired,
|
|
1788
|
+
scale: PropTypes.number.isRequired
|
|
1789
|
+
}),
|
|
1790
|
+
onCollapse: PropTypes.func,
|
|
1791
|
+
onClick: PropTypes.func
|
|
1792
|
+
};
|
|
1793
|
+
var defaultProps$9 = {
|
|
1794
|
+
component: null,
|
|
1795
|
+
screenValue: null,
|
|
1796
|
+
style: null,
|
|
1797
|
+
onCollapse: null,
|
|
1798
|
+
onClick: null
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
var animateLayoutChanges = function animateLayoutChanges(_ref) {
|
|
1802
|
+
var isSorting = _ref.isSorting,
|
|
1803
|
+
wasDragging = _ref.wasDragging;
|
|
1804
|
+
return !(isSorting || wasDragging);
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1807
|
+
var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
1808
|
+
var id = _ref2.id,
|
|
1809
|
+
depth = _ref2.depth,
|
|
1810
|
+
Component = _ref2.component,
|
|
1811
|
+
screenValue = _ref2.screenValue,
|
|
1812
|
+
itemStyle = _ref2.style,
|
|
1813
|
+
onCollapse = _ref2.onCollapse,
|
|
1814
|
+
onClick = _ref2.onClick,
|
|
1815
|
+
props = _objectWithoutProperties(_ref2, _excluded$3);
|
|
1816
|
+
|
|
1817
|
+
var _useSortable = useSortable({
|
|
1818
|
+
id: id,
|
|
1819
|
+
animateLayoutChanges: animateLayoutChanges
|
|
1820
|
+
}),
|
|
1821
|
+
attributes = _useSortable.attributes,
|
|
1822
|
+
isDragging = _useSortable.isDragging,
|
|
1823
|
+
isSorting = _useSortable.isSorting,
|
|
1824
|
+
listeners = _useSortable.listeners,
|
|
1825
|
+
setDraggableNodeRef = _useSortable.setDraggableNodeRef,
|
|
1826
|
+
setDroppableNodeRef = _useSortable.setDroppableNodeRef,
|
|
1827
|
+
transform = _useSortable.transform,
|
|
1828
|
+
transition = _useSortable.transition;
|
|
1829
|
+
|
|
1830
|
+
var hasCollapse = onCollapse !== null;
|
|
1831
|
+
var _itemStyle$scaledWidt = itemStyle.scaledWidth,
|
|
1832
|
+
scaledWidth = _itemStyle$scaledWidt === void 0 ? 100 : _itemStyle$scaledWidt,
|
|
1833
|
+
_itemStyle$scaledHeig = itemStyle.scaledHeight,
|
|
1834
|
+
scaledHeight = _itemStyle$scaledHeig === void 0 ? 66 : _itemStyle$scaledHeig,
|
|
1835
|
+
_itemStyle$scale = itemStyle.scale,
|
|
1836
|
+
scale = _itemStyle$scale === void 0 ? 1 : _itemStyle$scale;
|
|
1837
|
+
var extraHeight = hasCollapse ? 30 : 0;
|
|
1838
|
+
var actionsStyle = {
|
|
1839
|
+
width: depth === 0 ? scaledWidth : scaledWidth * 0.75,
|
|
1840
|
+
height: depth === 0 ? scaledHeight + extraHeight : scaledHeight * 0.75,
|
|
1841
|
+
transform: CSS.Translate.toString(transform),
|
|
1842
|
+
transition: transition
|
|
1843
|
+
};
|
|
1844
|
+
var previewStyle = {
|
|
1845
|
+
width: itemStyle.width,
|
|
1846
|
+
height: itemStyle.height,
|
|
1847
|
+
transform: depth === 0 ? itemStyle.transform : "scale(".concat(scale * 0.75, ", ").concat(scale * 0.75, ")"),
|
|
1848
|
+
transformOrigin: 'top left'
|
|
1849
|
+
};
|
|
1850
|
+
return /*#__PURE__*/React.createElement(SortableTreeItemActions, Object.assign({
|
|
1851
|
+
ref: setDraggableNodeRef,
|
|
1852
|
+
wrapperRef: setDroppableNodeRef,
|
|
1853
|
+
style: actionsStyle,
|
|
1854
|
+
depth: depth,
|
|
1855
|
+
ghost: isDragging,
|
|
1856
|
+
disableSelection: iOS,
|
|
1857
|
+
disableInteraction: isSorting,
|
|
1858
|
+
handleProps: _objectSpread(_objectSpread({}, attributes), listeners),
|
|
1859
|
+
onCollapse: onCollapse,
|
|
1860
|
+
onClick: onClick
|
|
1861
|
+
}, props), Component !== null ? /*#__PURE__*/React.createElement(Component, Object.assign({}, screenValue, {
|
|
1862
|
+
previewStyle: previewStyle
|
|
1863
|
+
})) : null);
|
|
1864
|
+
};
|
|
1865
|
+
SortableTreeItem.propTypes = propTypes$9;
|
|
1866
|
+
SortableTreeItem.defaultProps = defaultProps$9;
|
|
1867
|
+
|
|
1868
|
+
var initialItems = [{
|
|
1869
|
+
id: 'Home',
|
|
1870
|
+
children: []
|
|
1871
|
+
}, {
|
|
1872
|
+
id: 'Collections',
|
|
1873
|
+
children: [{
|
|
1874
|
+
id: 'Spring',
|
|
1875
|
+
children: []
|
|
1876
|
+
}, {
|
|
1877
|
+
id: 'Summer',
|
|
1878
|
+
children: []
|
|
1879
|
+
}, {
|
|
1880
|
+
id: 'Fall',
|
|
1881
|
+
children: []
|
|
1882
|
+
}, {
|
|
1883
|
+
id: 'Winter',
|
|
1884
|
+
children: []
|
|
1885
|
+
}]
|
|
1886
|
+
}, {
|
|
1887
|
+
id: 'About Us',
|
|
1888
|
+
children: []
|
|
1889
|
+
}, {
|
|
1890
|
+
id: 'My Account',
|
|
1891
|
+
children: [{
|
|
1892
|
+
id: 'Addresses',
|
|
1893
|
+
children: []
|
|
1894
|
+
}, {
|
|
1895
|
+
id: 'Order History',
|
|
1896
|
+
children: []
|
|
1897
|
+
}]
|
|
1898
|
+
}];
|
|
1899
|
+
var measuring = {
|
|
1900
|
+
droppable: {
|
|
1901
|
+
strategy: MeasuringStrategy.Always
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
var dropAnimation = _objectSpread(_objectSpread({}, defaultDropAnimation), {}, {
|
|
1906
|
+
dragSourceOpacity: 0.5
|
|
1907
|
+
});
|
|
1132
1908
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
})
|
|
1136
|
-
|
|
1137
|
-
components: screen !== null ? [].concat(_toConsumableArray(components), [_objectSpread(_objectSpread({}, screen), {}, {
|
|
1138
|
-
id: v1()
|
|
1139
|
-
})]) : components
|
|
1909
|
+
var adjustTranslate = function adjustTranslate(_ref) {
|
|
1910
|
+
var transform = _ref.transform;
|
|
1911
|
+
return _objectSpread(_objectSpread({}, transform), {}, {
|
|
1912
|
+
y: transform.y - 25
|
|
1140
1913
|
});
|
|
1141
1914
|
};
|
|
1142
1915
|
|
|
1143
|
-
var
|
|
1916
|
+
var propTypes$8 = {
|
|
1917
|
+
collapsible: PropTypes.bool,
|
|
1918
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
1919
|
+
items: PropTypes.array,
|
|
1920
|
+
indentationWidth: PropTypes.number,
|
|
1921
|
+
indicator: PropTypes.bool,
|
|
1922
|
+
removable: PropTypes.bool,
|
|
1923
|
+
component: PropTypes.func,
|
|
1924
|
+
itemStyle: PropTypes.shape({}),
|
|
1925
|
+
onClickItem: PropTypes.func,
|
|
1926
|
+
onChange: PropTypes.func
|
|
1927
|
+
};
|
|
1928
|
+
var defaultProps$8 = {
|
|
1929
|
+
collapsible: true,
|
|
1930
|
+
items: initialItems,
|
|
1931
|
+
indentationWidth: 30,
|
|
1932
|
+
indicator: false,
|
|
1933
|
+
removable: false,
|
|
1934
|
+
component: null,
|
|
1935
|
+
itemStyle: null,
|
|
1936
|
+
onClickItem: null,
|
|
1937
|
+
onChange: null
|
|
1938
|
+
};
|
|
1939
|
+
var SortableTree = function SortableTree(_ref2) {
|
|
1940
|
+
var collapsible = _ref2.collapsible,
|
|
1941
|
+
defaultItems = _ref2.items,
|
|
1942
|
+
indicator = _ref2.indicator,
|
|
1943
|
+
indentationWidth = _ref2.indentationWidth,
|
|
1944
|
+
removable = _ref2.removable,
|
|
1945
|
+
component = _ref2.component,
|
|
1946
|
+
itemStyle = _ref2.itemStyle,
|
|
1947
|
+
onClickItem = _ref2.onClickItem,
|
|
1948
|
+
onChange = _ref2.onChange;
|
|
1949
|
+
|
|
1950
|
+
var _useState = useState(function () {
|
|
1951
|
+
return defaultItems;
|
|
1952
|
+
}),
|
|
1953
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1954
|
+
items = _useState2[0],
|
|
1955
|
+
setItems = _useState2[1];
|
|
1144
1956
|
|
|
1145
|
-
var
|
|
1146
|
-
|
|
1957
|
+
var _useState3 = useState(null),
|
|
1958
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1959
|
+
activeId = _useState4[0],
|
|
1960
|
+
setActiveId = _useState4[1];
|
|
1147
1961
|
|
|
1148
|
-
var
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1962
|
+
var _useState5 = useState(null),
|
|
1963
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1964
|
+
overId = _useState6[0],
|
|
1965
|
+
setOverId = _useState6[1];
|
|
1152
1966
|
|
|
1153
|
-
var
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1967
|
+
var _useState7 = useState(0),
|
|
1968
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1969
|
+
offsetLeft = _useState8[0],
|
|
1970
|
+
setOffsetLeft = _useState8[1];
|
|
1971
|
+
|
|
1972
|
+
var _useState9 = useState(null),
|
|
1973
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
1974
|
+
currentPosition = _useState10[0],
|
|
1975
|
+
setCurrentPosition = _useState10[1];
|
|
1976
|
+
|
|
1977
|
+
var flattenedItems = useMemo(function () {
|
|
1978
|
+
var flattenedTree = flattenTree(items); // console.log('yo', items, flattenedTree);
|
|
1979
|
+
|
|
1980
|
+
var collapsedItems = flattenedTree.reduce(function (acc, _ref3) {
|
|
1981
|
+
var children = _ref3.children,
|
|
1982
|
+
collapsed = _ref3.collapsed,
|
|
1983
|
+
id = _ref3.id;
|
|
1984
|
+
return collapsed && children.length ? [].concat(_toConsumableArray(acc), [id]) : acc;
|
|
1985
|
+
}, []) || null;
|
|
1986
|
+
return removeChildrenOf(flattenedTree, activeId ? [activeId].concat(_toConsumableArray(collapsedItems)) : collapsedItems);
|
|
1987
|
+
}, [activeId, items]);
|
|
1988
|
+
var projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth) : null;
|
|
1989
|
+
var sensorContext = useRef({
|
|
1990
|
+
items: flattenedItems,
|
|
1991
|
+
offset: offsetLeft
|
|
1158
1992
|
});
|
|
1159
|
-
};
|
|
1160
|
-
|
|
1161
|
-
var getFieldByName = function getFieldByName(fields, name) {
|
|
1162
|
-
return fields.reduce(function (foundField, it) {
|
|
1163
|
-
if (foundField !== null) {
|
|
1164
|
-
return foundField;
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
var _it$name = it.name,
|
|
1168
|
-
fieldName = _it$name === void 0 ? null : _it$name,
|
|
1169
|
-
_it$fields = it.fields,
|
|
1170
|
-
subFields = _it$fields === void 0 ? [] : _it$fields;
|
|
1171
1993
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1994
|
+
var _useState11 = useState(function () {
|
|
1995
|
+
return sortableTreeKeyboardCoordinates(sensorContext, indentationWidth);
|
|
1996
|
+
}),
|
|
1997
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
1998
|
+
coordinateGetter = _useState12[0];
|
|
1175
1999
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
};
|
|
2000
|
+
var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
2001
|
+
coordinateGetter: coordinateGetter
|
|
2002
|
+
}));
|
|
2003
|
+
var sortedIds = useMemo(function () {
|
|
2004
|
+
return flattenedItems.map(function (_ref4) {
|
|
2005
|
+
var id = _ref4.id;
|
|
2006
|
+
return id;
|
|
2007
|
+
});
|
|
2008
|
+
}, [flattenedItems]);
|
|
2009
|
+
var activeItem = activeId ? flattenedItems.find(function (_ref5) {
|
|
2010
|
+
var id = _ref5.id;
|
|
2011
|
+
return id === activeId;
|
|
2012
|
+
}) : null;
|
|
2013
|
+
useEffect(function () {
|
|
2014
|
+
sensorContext.current = {
|
|
2015
|
+
items: flattenedItems,
|
|
2016
|
+
offset: offsetLeft
|
|
2017
|
+
};
|
|
2018
|
+
}, [flattenedItems, offsetLeft]);
|
|
2019
|
+
var announcements = useMemo(function () {
|
|
2020
|
+
return {
|
|
2021
|
+
onDragStart: function onDragStart(id) {
|
|
2022
|
+
return "Picked up ".concat(id, ".");
|
|
2023
|
+
},
|
|
2024
|
+
onDragMove: function onDragMove(id, currentOverId) {
|
|
2025
|
+
return getMovementAnnouncement('onDragMove', id, currentOverId);
|
|
2026
|
+
},
|
|
2027
|
+
onDragOver: function onDragOver(id, currentOverId) {
|
|
2028
|
+
return getMovementAnnouncement('onDragOver', id, currentOverId);
|
|
2029
|
+
},
|
|
2030
|
+
onDragEnd: function onDragEnd(id, currentOverId) {
|
|
2031
|
+
// console.log('drag end', flattenedItems);
|
|
2032
|
+
if (onChange !== null) {
|
|
2033
|
+
onChange((flattenedItems || []).map(function (_ref6) {
|
|
2034
|
+
var itemId = _ref6.id,
|
|
2035
|
+
_ref6$children = _ref6.children,
|
|
2036
|
+
children = _ref6$children === void 0 ? [] : _ref6$children,
|
|
2037
|
+
_ref6$parentId = _ref6.parentId,
|
|
2038
|
+
parentId = _ref6$parentId === void 0 ? null : _ref6$parentId;
|
|
2039
|
+
return {
|
|
2040
|
+
id: itemId,
|
|
2041
|
+
props: _objectSpread(_objectSpread({}, (children || []).length > 0 ? {
|
|
2042
|
+
group: {
|
|
2043
|
+
mergeNavItems: true
|
|
2044
|
+
}
|
|
2045
|
+
} : {
|
|
2046
|
+
group: null
|
|
2047
|
+
}), parentId !== null ? {
|
|
2048
|
+
parentId: parentId
|
|
2049
|
+
} : {
|
|
2050
|
+
parentId: null
|
|
2051
|
+
})
|
|
2052
|
+
};
|
|
2053
|
+
}));
|
|
2054
|
+
}
|
|
1179
2055
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
2056
|
+
return getMovementAnnouncement('onDragEnd', id, currentOverId);
|
|
2057
|
+
},
|
|
2058
|
+
onDragCancel: function onDragCancel(id) {
|
|
2059
|
+
return "Moving was cancelled. ".concat(id, " was dropped in its original position.");
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
}, [flattenedItems, onChange]); // Note: this is quite brutal for perf
|
|
2063
|
+
|
|
2064
|
+
useEffect(function () {// setItems(defaultItems);
|
|
2065
|
+
}, [defaultItems, setItems]); // console.log('render: current id', activeId);
|
|
2066
|
+
|
|
2067
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
2068
|
+
announcements: announcements,
|
|
2069
|
+
sensors: sensors,
|
|
2070
|
+
collisionDetection: closestCenter,
|
|
2071
|
+
measuring: measuring,
|
|
2072
|
+
onDragStart: handleDragStart,
|
|
2073
|
+
onDragMove: handleDragMove,
|
|
2074
|
+
onDragOver: handleDragOver,
|
|
2075
|
+
onDragEnd: handleDragEnd,
|
|
2076
|
+
onDragCancel: handleDragCancel
|
|
2077
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
2078
|
+
items: sortedIds,
|
|
2079
|
+
strategy: verticalListSortingStrategy
|
|
2080
|
+
}, flattenedItems.map(function (_ref7, idx) {
|
|
2081
|
+
var id = _ref7.id,
|
|
2082
|
+
_ref7$children = _ref7.children,
|
|
2083
|
+
children = _ref7$children === void 0 ? [] : _ref7$children,
|
|
2084
|
+
collapsed = _ref7.collapsed,
|
|
2085
|
+
depth = _ref7.depth,
|
|
2086
|
+
_ref7$screenValue = _ref7.screenValue,
|
|
2087
|
+
screenValue = _ref7$screenValue === void 0 ? null : _ref7$screenValue;
|
|
2088
|
+
return /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2089
|
+
key: id,
|
|
2090
|
+
id: id,
|
|
2091
|
+
value: id,
|
|
2092
|
+
depth: id === activeId && projected ? projected.depth : depth,
|
|
2093
|
+
indentationWidth: indentationWidth,
|
|
2094
|
+
indicator: indicator,
|
|
2095
|
+
collapsed: Boolean(collapsed && children.length),
|
|
2096
|
+
onCollapse: collapsible && children.length ? function () {
|
|
2097
|
+
return handleCollapse(id);
|
|
2098
|
+
} : undefined,
|
|
2099
|
+
onRemove: removable ? function () {
|
|
2100
|
+
return handleRemove(id);
|
|
2101
|
+
} : undefined,
|
|
2102
|
+
childCount: getChildCount(items, id),
|
|
2103
|
+
component: component,
|
|
2104
|
+
screenValue: screenValue,
|
|
2105
|
+
style: itemStyle,
|
|
2106
|
+
onClick: function onClick() {
|
|
2107
|
+
if (onClickItem !== null) {
|
|
2108
|
+
onClickItem({
|
|
2109
|
+
id: id
|
|
2110
|
+
}, idx);
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
});
|
|
2114
|
+
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(DragOverlay, {
|
|
2115
|
+
dropAnimation: dropAnimation,
|
|
2116
|
+
modifiers: indicator ? [adjustTranslate] : undefined
|
|
2117
|
+
}, activeId && activeItem ? /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2118
|
+
id: activeId,
|
|
2119
|
+
depth: activeItem.depth,
|
|
2120
|
+
clone: true,
|
|
2121
|
+
childCount: getChildCount(items, activeId) + 1,
|
|
2122
|
+
value: activeId,
|
|
2123
|
+
indentationWidth: indentationWidth,
|
|
2124
|
+
component: component,
|
|
2125
|
+
screenValue: activeItem === null || activeItem === void 0 ? void 0 : activeItem.screenValue,
|
|
2126
|
+
style: itemStyle
|
|
2127
|
+
}) : null), document.body)));
|
|
2128
|
+
|
|
2129
|
+
function handleDragStart(_ref8) {
|
|
2130
|
+
var newActiveId = _ref8.active.id;
|
|
2131
|
+
setActiveId(newActiveId);
|
|
2132
|
+
setOverId(newActiveId);
|
|
2133
|
+
var newActiveItem = flattenedItems.find(function (_ref9) {
|
|
2134
|
+
var id = _ref9.id;
|
|
2135
|
+
return id === newActiveId;
|
|
2136
|
+
});
|
|
1191
2137
|
|
|
1192
|
-
if (
|
|
1193
|
-
|
|
1194
|
-
|
|
2138
|
+
if (newActiveItem) {
|
|
2139
|
+
setCurrentPosition({
|
|
2140
|
+
parentId: newActiveItem.parentId,
|
|
2141
|
+
overId: activeId
|
|
2142
|
+
});
|
|
1195
2143
|
}
|
|
1196
2144
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
var
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
var
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
2145
|
+
document.body.style.setProperty('cursor', 'grabbing');
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
function handleDragMove(_ref10) {
|
|
2149
|
+
var delta = _ref10.delta;
|
|
2150
|
+
setOffsetLeft(delta.x);
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
function handleDragOver(_ref11) {
|
|
2154
|
+
var _over$id;
|
|
2155
|
+
|
|
2156
|
+
var over = _ref11.over;
|
|
2157
|
+
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
function resetState() {
|
|
2161
|
+
setOverId(null);
|
|
2162
|
+
setActiveId(null);
|
|
2163
|
+
setOffsetLeft(0);
|
|
2164
|
+
setCurrentPosition(null);
|
|
2165
|
+
document.body.style.setProperty('cursor', '');
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
function handleDragEnd(_ref12) {
|
|
2169
|
+
var active = _ref12.active,
|
|
2170
|
+
over = _ref12.over;
|
|
2171
|
+
resetState();
|
|
2172
|
+
|
|
2173
|
+
if (projected && over) {
|
|
2174
|
+
var depth = projected.depth,
|
|
2175
|
+
parentId = projected.parentId;
|
|
2176
|
+
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2177
|
+
var overIndex = clonedItems.findIndex(function (_ref13) {
|
|
2178
|
+
var id = _ref13.id;
|
|
2179
|
+
return id === over.id;
|
|
2180
|
+
});
|
|
2181
|
+
var activeIndex = clonedItems.findIndex(function (_ref14) {
|
|
2182
|
+
var id = _ref14.id;
|
|
2183
|
+
return id === active.id;
|
|
2184
|
+
});
|
|
2185
|
+
var activeTreeItem = clonedItems[activeIndex];
|
|
2186
|
+
clonedItems[activeIndex] = _objectSpread(_objectSpread({}, activeTreeItem), {}, {
|
|
2187
|
+
depth: depth,
|
|
2188
|
+
parentId: parentId
|
|
2189
|
+
});
|
|
2190
|
+
var sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
2191
|
+
var newItems = buildTree(sortedItems);
|
|
2192
|
+
setItems(newItems);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
1223
2195
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
};
|
|
1228
|
-
var defaultProps$7 = {
|
|
1229
|
-
className: null
|
|
1230
|
-
};
|
|
2196
|
+
function handleDragCancel() {
|
|
2197
|
+
resetState();
|
|
2198
|
+
}
|
|
1231
2199
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
2200
|
+
function handleRemove(id) {
|
|
2201
|
+
setItems(function (newItems) {
|
|
2202
|
+
return removeItem(newItems, id);
|
|
2203
|
+
});
|
|
2204
|
+
}
|
|
1235
2205
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}, props));
|
|
1244
|
-
};
|
|
2206
|
+
function handleCollapse(id) {
|
|
2207
|
+
setItems(function (newItems) {
|
|
2208
|
+
return setProperty(newItems, id, 'collapsed', function (value) {
|
|
2209
|
+
return !value;
|
|
2210
|
+
});
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
1245
2213
|
|
|
1246
|
-
|
|
1247
|
-
|
|
2214
|
+
function getMovementAnnouncement(eventName, currentActiveId, currentOverId) {
|
|
2215
|
+
if (currentOverId && projected) {
|
|
2216
|
+
if (eventName !== 'onDragEnd') {
|
|
2217
|
+
if (currentPosition && projected.parentId === currentPosition.parentId && currentOverId === currentPosition.overId) {
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
1248
2220
|
|
|
1249
|
-
|
|
2221
|
+
setCurrentPosition({
|
|
2222
|
+
parentId: projected.parentId,
|
|
2223
|
+
overId: currentOverId
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
1250
2226
|
|
|
1251
|
-
var
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
2227
|
+
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2228
|
+
var overIndex = clonedItems.findIndex(function (_ref15) {
|
|
2229
|
+
var id = _ref15.id;
|
|
2230
|
+
return id === currentOverId;
|
|
2231
|
+
});
|
|
2232
|
+
var activeIndex = clonedItems.findIndex(function (_ref16) {
|
|
2233
|
+
var id = _ref16.id;
|
|
2234
|
+
return id === currentActiveId;
|
|
2235
|
+
});
|
|
2236
|
+
var sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
2237
|
+
var previousItem = sortedItems[overIndex - 1];
|
|
2238
|
+
var newAnnouncement;
|
|
2239
|
+
var movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
2240
|
+
var nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
2241
|
+
|
|
2242
|
+
if (!previousItem) {
|
|
2243
|
+
var nextItem = sortedItems[overIndex + 1];
|
|
2244
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " before ").concat(nextItem.id, ".");
|
|
2245
|
+
} else if (projected.depth > previousItem.depth) {
|
|
2246
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(nestedVerb, " under ").concat(previousItem.id, ".");
|
|
2247
|
+
} else {
|
|
2248
|
+
var previousSibling = previousItem;
|
|
2249
|
+
|
|
2250
|
+
var _loop = function _loop() {
|
|
2251
|
+
var _previousSibling = previousSibling,
|
|
2252
|
+
parentId = _previousSibling.parentId;
|
|
2253
|
+
previousSibling = sortedItems.find(function (_ref17) {
|
|
2254
|
+
var id = _ref17.id;
|
|
2255
|
+
return id === parentId;
|
|
2256
|
+
});
|
|
2257
|
+
};
|
|
1266
2258
|
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
field = _ref.field,
|
|
1271
|
-
form = _ref.form,
|
|
1272
|
-
url = _ref.url,
|
|
1273
|
-
className = _ref.className;
|
|
1274
|
-
var intl = useIntl();
|
|
2259
|
+
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
2260
|
+
_loop();
|
|
2261
|
+
}
|
|
1275
2262
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
2263
|
+
if (previousSibling) {
|
|
2264
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " after ").concat(previousSibling.id, ".");
|
|
2265
|
+
}
|
|
2266
|
+
} // eslint-disable-next-line consistent-return
|
|
1279
2267
|
|
|
1280
|
-
var history = useHistory();
|
|
1281
|
-
var screensManager = useScreensManager();
|
|
1282
|
-
var fieldsManager = useFieldsManager();
|
|
1283
|
-
var items = useMemo(function () {
|
|
1284
|
-
var screenIndex = screens.findIndex(function (it) {
|
|
1285
|
-
return it.id === screenId;
|
|
1286
|
-
});
|
|
1287
2268
|
|
|
1288
|
-
|
|
1289
|
-
return [];
|
|
2269
|
+
return newAnnouncement;
|
|
1290
2270
|
}
|
|
2271
|
+
}
|
|
2272
|
+
};
|
|
2273
|
+
SortableTree.propTypes = propTypes$8;
|
|
2274
|
+
SortableTree.defaultProps = defaultProps$8;
|
|
1291
2275
|
|
|
1292
|
-
|
|
1293
|
-
|
|
2276
|
+
var _excluded$2 = ["className", "screen", "type"],
|
|
2277
|
+
_excluded2 = ["id", "screen"];
|
|
2278
|
+
var propTypes$7 = {
|
|
2279
|
+
items: PropTypes$1.menuItems,
|
|
2280
|
+
withPreview: PropTypes.bool,
|
|
2281
|
+
withPlaceholder: PropTypes.bool,
|
|
2282
|
+
settings: PropTypes.node,
|
|
2283
|
+
previewMinWidth: PropTypes.number,
|
|
2284
|
+
sortable: PropTypes.bool,
|
|
2285
|
+
isTree: PropTypes.bool,
|
|
2286
|
+
isVertical: PropTypes.bool,
|
|
2287
|
+
noWrap: PropTypes.bool,
|
|
2288
|
+
className: PropTypes.string,
|
|
2289
|
+
itemClassName: PropTypes.string,
|
|
2290
|
+
buttonClassName: PropTypes.string,
|
|
2291
|
+
settingsClassName: PropTypes.string,
|
|
2292
|
+
onClickItem: PropTypes.func,
|
|
2293
|
+
onOrderChange: PropTypes.func
|
|
2294
|
+
};
|
|
2295
|
+
var defaultProps$7 = {
|
|
2296
|
+
items: [],
|
|
2297
|
+
withPreview: false,
|
|
2298
|
+
withPlaceholder: false,
|
|
2299
|
+
settings: null,
|
|
2300
|
+
previewMinWidth: 320,
|
|
2301
|
+
sortable: false,
|
|
2302
|
+
isTree: false,
|
|
2303
|
+
isVertical: false,
|
|
2304
|
+
noWrap: false,
|
|
2305
|
+
className: null,
|
|
2306
|
+
itemClassName: null,
|
|
2307
|
+
buttonClassName: null,
|
|
2308
|
+
settingsClassName: null,
|
|
2309
|
+
onClickItem: null,
|
|
2310
|
+
onOrderChange: null
|
|
2311
|
+
};
|
|
1294
2312
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
_screensManager$getDe2 = _screensManager$getDe.fields,
|
|
1298
|
-
screenFields = _screensManager$getDe2 === void 0 ? [] : _screensManager$getDe2;
|
|
2313
|
+
var ScreensMenu = function ScreensMenu(_ref) {
|
|
2314
|
+
var _ref9;
|
|
1299
2315
|
|
|
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;
|
|
2316
|
+
var items = _ref.items,
|
|
2317
|
+
withPreview = _ref.withPreview,
|
|
2318
|
+
withPlaceholder = _ref.withPlaceholder,
|
|
2319
|
+
settings = _ref.settings,
|
|
2320
|
+
previewMinWidth = _ref.previewMinWidth,
|
|
2321
|
+
isVertical = _ref.isVertical,
|
|
2322
|
+
noWrap = _ref.noWrap,
|
|
2323
|
+
className = _ref.className,
|
|
2324
|
+
itemClassName = _ref.itemClassName,
|
|
2325
|
+
buttonClassName = _ref.buttonClassName,
|
|
2326
|
+
settingsClassName = _ref.settingsClassName,
|
|
2327
|
+
sortable = _ref.sortable,
|
|
2328
|
+
isTree = _ref.isTree,
|
|
2329
|
+
onClickItem = _ref.onClickItem,
|
|
2330
|
+
onOrderChange = _ref.onOrderChange;
|
|
1325
2331
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
nextFields = currentSettings;
|
|
2332
|
+
var _useResizeObserver = useResizeObserver({}, [items]),
|
|
2333
|
+
containerRef = _useResizeObserver.ref,
|
|
2334
|
+
contentRect = _useResizeObserver.entry.contentRect;
|
|
1330
2335
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
}));
|
|
1335
|
-
}
|
|
1336
|
-
} else if (isListItems) {
|
|
1337
|
-
nextFields = itemsField;
|
|
1338
|
-
}
|
|
2336
|
+
var _useResizeObserver2 = useResizeObserver({}, [items]),
|
|
2337
|
+
columnRef = _useResizeObserver2.ref,
|
|
2338
|
+
columnRect = _useResizeObserver2.entry.contentRect;
|
|
1339
2339
|
|
|
1340
|
-
|
|
1341
|
-
|
|
2340
|
+
var previewStyle = useMemo(function () {
|
|
2341
|
+
var _ref2 = contentRect || {},
|
|
2342
|
+
_ref2$width = _ref2.width,
|
|
2343
|
+
itemWidth = _ref2$width === void 0 ? 0 : _ref2$width,
|
|
2344
|
+
_ref2$height = _ref2.height,
|
|
2345
|
+
itemHeight = _ref2$height === void 0 ? 0 : _ref2$height;
|
|
1342
2346
|
|
|
1343
|
-
|
|
1344
|
-
_ref3$label = _ref3.label,
|
|
1345
|
-
parentItemLabel = _ref3$label === void 0 ? null : _ref3$label;
|
|
2347
|
+
var ratio = itemHeight !== 0 && itemWidth !== 0 ? itemHeight / itemWidth : 2 / 3;
|
|
1346
2348
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
url: itemPath,
|
|
1350
|
-
label: finalItemLabel || '',
|
|
1351
|
-
active: false
|
|
1352
|
-
};
|
|
2349
|
+
var _getSizeWithinBounds = getSizeWithinBounds(previewMinWidth, previewMinWidth * ratio, itemWidth, itemHeight),
|
|
2350
|
+
previewScale = _getSizeWithinBounds.scale;
|
|
1353
2351
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
2352
|
+
return {
|
|
2353
|
+
width: previewMinWidth,
|
|
2354
|
+
height: previewMinWidth * ratio,
|
|
2355
|
+
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")")
|
|
2356
|
+
};
|
|
2357
|
+
}, [previewMinWidth, contentRect]);
|
|
2358
|
+
var treeStyle = useMemo(function () {
|
|
2359
|
+
var _ref3 = columnRect || {},
|
|
2360
|
+
_ref3$width = _ref3.width,
|
|
2361
|
+
itemWidth = _ref3$width === void 0 ? 0 : _ref3$width;
|
|
1357
2362
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}, {
|
|
1361
|
-
fields: fields
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
2363
|
+
var itemHeight = itemWidth * 3 / 2;
|
|
2364
|
+
var ratio = itemHeight !== 0 && itemWidth !== 0 ? itemHeight / itemWidth : 0;
|
|
1364
2365
|
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
2366
|
+
var _getSizeWithinBounds2 = getSizeWithinBounds(previewMinWidth, previewMinWidth * ratio, itemWidth, itemHeight),
|
|
2367
|
+
scaledWidth = _getSizeWithinBounds2.width,
|
|
2368
|
+
scaledHeight = _getSizeWithinBounds2.height,
|
|
2369
|
+
previewScale = _getSizeWithinBounds2.scale;
|
|
2370
|
+
|
|
2371
|
+
return {
|
|
2372
|
+
width: previewMinWidth,
|
|
2373
|
+
height: previewMinWidth * ratio,
|
|
2374
|
+
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")"),
|
|
2375
|
+
scale: previewScale,
|
|
2376
|
+
scaledWidth: scaledWidth,
|
|
2377
|
+
scaledHeight: scaledHeight
|
|
2378
|
+
};
|
|
2379
|
+
}, [previewMinWidth, columnRect]);
|
|
2380
|
+
var itemsElements = !isTree ? items.map(function (_ref4, index) {
|
|
2381
|
+
var _ref5;
|
|
2382
|
+
|
|
2383
|
+
var _ref4$className = _ref4.className,
|
|
2384
|
+
itemCustomClassName = _ref4$className === void 0 ? null : _ref4$className,
|
|
2385
|
+
screen = _ref4.screen,
|
|
2386
|
+
type = _ref4.type,
|
|
2387
|
+
item = _objectWithoutProperties(_ref4, _excluded$2);
|
|
2388
|
+
|
|
2389
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
2390
|
+
key: item.id,
|
|
2391
|
+
className: classNames([styles$6.item, (_ref5 = {}, _defineProperty(_ref5, itemClassName, itemClassName !== null), _defineProperty(_ref5, itemCustomClassName, itemCustomClassName !== null), _ref5)]),
|
|
2392
|
+
"data-screen-id": item.id,
|
|
2393
|
+
ref: index === 0 ? containerRef : null
|
|
2394
|
+
}, /*#__PURE__*/React.createElement(ScreenWithPreview, {
|
|
2395
|
+
index: index,
|
|
2396
|
+
screen: _objectSpread(_objectSpread({}, screen), withPlaceholder ? {
|
|
2397
|
+
type: type
|
|
2398
|
+
} : null),
|
|
2399
|
+
buttonClassName: buttonClassName,
|
|
2400
|
+
previewStyle: previewStyle,
|
|
2401
|
+
withPreview: withPreview,
|
|
2402
|
+
withPlaceholder: withPlaceholder,
|
|
2403
|
+
onClick: onClickItem
|
|
2404
|
+
}), settings !== null ? /*#__PURE__*/React.createElement("div", {
|
|
2405
|
+
className: classNames([_defineProperty({}, settingsClassName, settingsClassName !== null), styles$6.settings, 'p-2'])
|
|
2406
|
+
}, isFunction(settings) ? settings(index) : settings) : null);
|
|
2407
|
+
}) : [];
|
|
2408
|
+
var sortableItems = useMemo(function () {
|
|
2409
|
+
return isTree ? items.reduce(function (acc, _ref7) {
|
|
2410
|
+
var id = _ref7.id,
|
|
2411
|
+
_ref7$screen = _ref7.screen,
|
|
2412
|
+
screen = _ref7$screen === void 0 ? {} : _ref7$screen,
|
|
2413
|
+
props = _objectWithoutProperties(_ref7, _excluded2);
|
|
2414
|
+
|
|
2415
|
+
var _screen$parentId = screen.parentId,
|
|
2416
|
+
parentId = _screen$parentId === void 0 ? null : _screen$parentId; // console.log('hey', id, screen, parentId, props);
|
|
2417
|
+
// const children =
|
|
2418
|
+
// items.filter(({ screen: { parentId: cpid = null } }) => cpid === id) ||
|
|
2419
|
+
// [];
|
|
2420
|
+
// console.log('children', children);
|
|
2421
|
+
|
|
2422
|
+
acc.push(_objectSpread({
|
|
2423
|
+
id: id,
|
|
2424
|
+
parentId: parentId,
|
|
2425
|
+
screenValue: {
|
|
2426
|
+
id: id,
|
|
2427
|
+
screen: screen
|
|
2428
|
+
}
|
|
2429
|
+
}, props));
|
|
2430
|
+
return acc;
|
|
2431
|
+
}, []) : items.map(function (_ref8) {
|
|
2432
|
+
var id = _ref8.id;
|
|
2433
|
+
return {
|
|
2434
|
+
id: id
|
|
2435
|
+
};
|
|
1384
2436
|
});
|
|
1385
|
-
}, [
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
2437
|
+
}, [items, isTree]); // console.log('screens menu items/sitems', items, sortableItems);
|
|
2438
|
+
|
|
2439
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2440
|
+
className: classNames([styles$6.container, (_ref9 = {}, _defineProperty(_ref9, styles$6.noWrap, noWrap), _defineProperty(_ref9, styles$6.isVertical, isVertical), _defineProperty(_ref9, styles$6.isTree, isTree), _defineProperty(_ref9, styles$6.withPlaceholder, withPlaceholder), _defineProperty(_ref9, className, className), _ref9)]),
|
|
2441
|
+
ref: columnRef
|
|
2442
|
+
}, isTree && !sortable ? /*#__PURE__*/React.createElement(SortableTree, {
|
|
2443
|
+
items: sortableItems,
|
|
2444
|
+
component: ScreenWithPreview,
|
|
2445
|
+
itemStyle: treeStyle,
|
|
2446
|
+
onClickItem: onClickItem,
|
|
2447
|
+
onChange: onOrderChange
|
|
2448
|
+
}) : null, !isTree && sortable && items.length > 1 ? /*#__PURE__*/React.createElement(ReactSortable, {
|
|
2449
|
+
list: sortableItems,
|
|
2450
|
+
setList: onOrderChange,
|
|
2451
|
+
animation: 200,
|
|
2452
|
+
delayOnTouchStart: true,
|
|
2453
|
+
delay: 2,
|
|
2454
|
+
tag: "ul",
|
|
2455
|
+
className: styles$6.items
|
|
2456
|
+
}, itemsElements) : null, !isTree && (!sortable || items.length < 1) ? /*#__PURE__*/React.createElement("ul", {
|
|
2457
|
+
className: styles$6.items
|
|
2458
|
+
}, itemsElements) : null);
|
|
1401
2459
|
};
|
|
1402
2460
|
|
|
1403
|
-
|
|
1404
|
-
|
|
2461
|
+
ScreensMenu.propTypes = propTypes$7;
|
|
2462
|
+
ScreensMenu.defaultProps = defaultProps$7;
|
|
1405
2463
|
|
|
1406
|
-
var styles$
|
|
2464
|
+
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
2465
|
|
|
1408
|
-
var propTypes$
|
|
1409
|
-
|
|
2466
|
+
var propTypes$6 = {
|
|
2467
|
+
screens: PropTypes$1.screenDefinitions,
|
|
2468
|
+
selectedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
1410
2469
|
className: PropTypes.string,
|
|
1411
|
-
|
|
1412
|
-
closeFieldForm: PropTypes.func.isRequired,
|
|
1413
|
-
onChange: PropTypes.func // onClickDelete: PropTypes.func,
|
|
1414
|
-
|
|
2470
|
+
onClickItem: PropTypes.func
|
|
1415
2471
|
};
|
|
1416
|
-
var defaultProps$
|
|
1417
|
-
|
|
2472
|
+
var defaultProps$6 = {
|
|
2473
|
+
screens: null,
|
|
2474
|
+
selectedTypes: null,
|
|
1418
2475
|
className: null,
|
|
1419
|
-
|
|
1420
|
-
|
|
2476
|
+
onClickItem: null
|
|
1421
2477
|
};
|
|
1422
2478
|
|
|
1423
|
-
var
|
|
1424
|
-
var
|
|
2479
|
+
var ScreenTypes = function ScreenTypes(_ref) {
|
|
2480
|
+
var screens = _ref.screens,
|
|
2481
|
+
selectedTypes = _ref.selectedTypes,
|
|
1425
2482
|
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
|
-
};
|
|
2483
|
+
onClickItem = _ref.onClickItem;
|
|
2484
|
+
var intl = useIntl();
|
|
2485
|
+
var screensManager = useScreensManager();
|
|
2486
|
+
var finalDefinitions = screens || screensManager.getDefinitions();
|
|
2487
|
+
var groups = useMemo(function () {
|
|
2488
|
+
var groupItems = finalDefinitions.reduce(function (allGroups, definition) {
|
|
2489
|
+
var id = definition.id,
|
|
2490
|
+
title = definition.title,
|
|
2491
|
+
_definition$group = definition.group,
|
|
2492
|
+
group = _definition$group === void 0 ? {} : _definition$group;
|
|
1460
2493
|
|
|
1461
|
-
|
|
1462
|
-
|
|
2494
|
+
var _ref2 = group || {},
|
|
2495
|
+
_ref2$order = _ref2.order,
|
|
2496
|
+
order = _ref2$order === void 0 ? 0 : _ref2$order,
|
|
2497
|
+
_ref2$label = _ref2.label,
|
|
2498
|
+
label = _ref2$label === void 0 ? {} : _ref2$label,
|
|
2499
|
+
_ref2$hidden = _ref2.hidden,
|
|
2500
|
+
hidden = _ref2$hidden === void 0 ? false : _ref2$hidden;
|
|
1463
2501
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
};
|
|
1468
|
-
var defaultProps$4 = {
|
|
1469
|
-
children: null
|
|
1470
|
-
};
|
|
2502
|
+
var _ref3 = label || {},
|
|
2503
|
+
_ref3$id = _ref3.id,
|
|
2504
|
+
messageId = _ref3$id === void 0 ? null : _ref3$id;
|
|
1471
2505
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
1476
|
-
fields = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$; // To use a specific form component
|
|
2506
|
+
if (hidden) {
|
|
2507
|
+
return allGroups;
|
|
2508
|
+
}
|
|
1477
2509
|
|
|
2510
|
+
var _ref4 = isMessage(label) ? {
|
|
2511
|
+
id: messageId || id,
|
|
2512
|
+
name: group
|
|
2513
|
+
} : {
|
|
2514
|
+
id: messageId || id,
|
|
2515
|
+
name: title
|
|
2516
|
+
},
|
|
2517
|
+
groupId = _ref4.id,
|
|
2518
|
+
groupName = _ref4.name;
|
|
1478
2519
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
2520
|
+
var groupIndex = allGroups.findIndex(function (it) {
|
|
2521
|
+
return it.id === groupId;
|
|
2522
|
+
});
|
|
2523
|
+
var selected = selectedTypes !== null && selectedTypes.indexOf(id) !== -1;
|
|
2524
|
+
var item = {
|
|
2525
|
+
id: id,
|
|
2526
|
+
type: id,
|
|
2527
|
+
screen: definition,
|
|
2528
|
+
className: classNames(_defineProperty({
|
|
2529
|
+
'bg-secondary': !selected,
|
|
2530
|
+
'bg-primary': selected
|
|
2531
|
+
}, styles$2.selected, selected))
|
|
2532
|
+
};
|
|
2533
|
+
return groupIndex !== -1 ? [].concat(_toConsumableArray(allGroups.slice(0, groupIndex)), [_objectSpread(_objectSpread({}, allGroups[groupIndex]), {}, {
|
|
2534
|
+
items: [].concat(_toConsumableArray(allGroups[groupIndex].items), [item])
|
|
2535
|
+
})], _toConsumableArray(allGroups.slice(groupIndex + 1))) : [].concat(_toConsumableArray(allGroups), [{
|
|
2536
|
+
id: groupId,
|
|
2537
|
+
name: isMessage(label) ? intl.formatMessage(label) : groupName,
|
|
2538
|
+
order: order,
|
|
2539
|
+
items: [item]
|
|
2540
|
+
}]);
|
|
2541
|
+
}, []);
|
|
2542
|
+
return orderBy(groupItems, ['order', 'name'], ['asc', 'asc']);
|
|
2543
|
+
}, [finalDefinitions, selectedTypes]);
|
|
2544
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2545
|
+
className: classNames([styles$2.container, _defineProperty({}, className, className)])
|
|
2546
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2547
|
+
className: styles$2.rows
|
|
2548
|
+
}, groups.map(function (_ref6) {
|
|
2549
|
+
var id = _ref6.id,
|
|
2550
|
+
name = _ref6.name,
|
|
2551
|
+
items = _ref6.items;
|
|
2552
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2553
|
+
key: "group-".concat(id),
|
|
2554
|
+
className: styles$2.row
|
|
2555
|
+
}, /*#__PURE__*/React.createElement(Label, null, name), /*#__PURE__*/React.createElement("div", {
|
|
2556
|
+
className: styles$2.layouts
|
|
2557
|
+
}, /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
2558
|
+
items: items,
|
|
2559
|
+
withPlaceholder: true,
|
|
2560
|
+
itemClassName: classNames(['border', 'rounded', {
|
|
2561
|
+
'border-secondary': selectedTypes === null,
|
|
2562
|
+
'border-dark': selectedTypes !== null,
|
|
2563
|
+
'bg-secondary': selectedTypes === null,
|
|
2564
|
+
'text-secondary': selectedTypes !== null
|
|
2565
|
+
}]),
|
|
2566
|
+
previewMinWidth: 100,
|
|
2567
|
+
onClickItem: onClickItem
|
|
2568
|
+
})));
|
|
2569
|
+
})));
|
|
1484
2570
|
};
|
|
1485
2571
|
|
|
1486
|
-
|
|
1487
|
-
|
|
2572
|
+
ScreenTypes.propTypes = propTypes$6;
|
|
2573
|
+
ScreenTypes.defaultProps = defaultProps$6;
|
|
1488
2574
|
|
|
1489
|
-
var styles$
|
|
2575
|
+
var styles$1 = {"container":"micromag-editor-modals-screen-types-container","selected":"micromag-editor-modals-screen-types-selected"};
|
|
1490
2576
|
|
|
1491
|
-
var propTypes$
|
|
2577
|
+
var propTypes$5 = {
|
|
2578
|
+
selectedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
1492
2579
|
className: PropTypes.string,
|
|
1493
|
-
|
|
1494
|
-
|
|
2580
|
+
onRequestClose: PropTypes.func,
|
|
2581
|
+
onClickScreenType: PropTypes.func
|
|
1495
2582
|
};
|
|
1496
|
-
var defaultProps$
|
|
2583
|
+
var defaultProps$5 = {
|
|
2584
|
+
selectedTypes: null,
|
|
1497
2585
|
className: null,
|
|
1498
|
-
|
|
1499
|
-
|
|
2586
|
+
onRequestClose: null,
|
|
2587
|
+
onClickScreenType: null
|
|
1500
2588
|
};
|
|
1501
2589
|
|
|
1502
|
-
var
|
|
1503
|
-
var
|
|
1504
|
-
|
|
1505
|
-
|
|
2590
|
+
var ScreenTypesModal = function ScreenTypesModal(_ref) {
|
|
2591
|
+
var selectedTypes = _ref.selectedTypes,
|
|
2592
|
+
className = _ref.className,
|
|
2593
|
+
onRequestClose = _ref.onRequestClose,
|
|
2594
|
+
onClickScreenType = _ref.onClickScreenType;
|
|
1506
2595
|
return /*#__PURE__*/React.createElement(Modal, null, /*#__PURE__*/React.createElement(ModalDialog, {
|
|
1507
2596
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1508
|
-
id: "
|
|
2597
|
+
id: "QBaiO0",
|
|
1509
2598
|
defaultMessage: [{
|
|
1510
2599
|
"type": 0,
|
|
1511
|
-
"value": "
|
|
2600
|
+
"value": "Add a screen"
|
|
1512
2601
|
}]
|
|
1513
2602
|
}),
|
|
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
|
-
}))));
|
|
2603
|
+
className: classNames([styles$1.container, _defineProperty({}, className, className)]),
|
|
2604
|
+
onClickClose: onRequestClose
|
|
2605
|
+
}, /*#__PURE__*/React.createElement(ScreenTypes, {
|
|
2606
|
+
selectedTypes: selectedTypes,
|
|
2607
|
+
className: styles$1.menu,
|
|
2608
|
+
onClickItem: onClickScreenType
|
|
2609
|
+
})));
|
|
1546
2610
|
};
|
|
1547
2611
|
|
|
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"};
|
|
2612
|
+
ScreenTypesModal.propTypes = propTypes$5;
|
|
2613
|
+
ScreenTypesModal.defaultProps = defaultProps$5;
|
|
1552
2614
|
|
|
1553
|
-
var
|
|
2615
|
+
var _excluded$1 = ["id"];
|
|
2616
|
+
var propTypes$4 = {
|
|
1554
2617
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
1555
2618
|
isTheme: PropTypes.bool,
|
|
1556
|
-
|
|
1557
|
-
|
|
2619
|
+
isVertical: PropTypes.bool,
|
|
2620
|
+
isCreateOpened: PropTypes.bool,
|
|
2621
|
+
isParsed: PropTypes.bool,
|
|
2622
|
+
isTree: PropTypes.bool,
|
|
2623
|
+
onClickScreen: PropTypes.func,
|
|
2624
|
+
onChange: PropTypes.func,
|
|
2625
|
+
className: PropTypes.string
|
|
1558
2626
|
};
|
|
1559
|
-
var defaultProps$
|
|
2627
|
+
var defaultProps$4 = {
|
|
1560
2628
|
value: null,
|
|
1561
2629
|
isTheme: false,
|
|
1562
|
-
|
|
1563
|
-
|
|
2630
|
+
isVertical: false,
|
|
2631
|
+
isCreateOpened: false,
|
|
2632
|
+
isParsed: false,
|
|
2633
|
+
isTree: false,
|
|
2634
|
+
onClickScreen: null,
|
|
2635
|
+
onChange: null,
|
|
2636
|
+
className: null
|
|
1564
2637
|
};
|
|
1565
2638
|
|
|
1566
|
-
var
|
|
1567
|
-
var
|
|
2639
|
+
var EditorScreens = function EditorScreens(_ref) {
|
|
2640
|
+
var unparsedValue = _ref.value,
|
|
1568
2641
|
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
|
-
|
|
2642
|
+
isVertical = _ref.isVertical,
|
|
2643
|
+
isCreateOpened = _ref.isCreateOpened,
|
|
2644
|
+
isParsed = _ref.isParsed,
|
|
2645
|
+
isTree = _ref.isTree,
|
|
2646
|
+
onClickScreen = _ref.onClickScreen,
|
|
2647
|
+
onChange = _ref.onChange,
|
|
2648
|
+
className = _ref.className;
|
|
2649
|
+
var valueWithTheme = useThemeValue(unparsedValue, isTheme);
|
|
2650
|
+
var value = isParsed ? unparsedValue : useParsedStory(valueWithTheme, {
|
|
2651
|
+
withMedias: false
|
|
2652
|
+
});
|
|
1584
2653
|
|
|
1585
2654
|
var _ref2 = value || {},
|
|
1586
2655
|
_ref2$components = _ref2.components,
|
|
1587
2656
|
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
1588
2657
|
|
|
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),
|
|
2658
|
+
var _useState = useState(isCreateOpened),
|
|
1599
2659
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1600
|
-
|
|
1601
|
-
|
|
2660
|
+
createModalOpened = _useState2[0],
|
|
2661
|
+
setCreateModalOpened = _useState2[1];
|
|
1602
2662
|
|
|
1603
|
-
var
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
setDeleteScreenModalOpened = _useState4[1];
|
|
2663
|
+
var routes = useRoutes();
|
|
2664
|
+
var push = useRoutePush();
|
|
2665
|
+
var url = useUrlGenerator();
|
|
1607
2666
|
|
|
1608
|
-
var
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
2667
|
+
var _useRouteParams = useRouteParams({
|
|
2668
|
+
screenOnly: true
|
|
2669
|
+
}),
|
|
2670
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
2671
|
+
currentScreenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree;
|
|
1612
2672
|
|
|
1613
|
-
var
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
2673
|
+
var createScreenFromDefinition = useCallback(function (definition) {
|
|
2674
|
+
var _ref3 = value || {},
|
|
2675
|
+
_ref3$components = _ref3.components,
|
|
2676
|
+
currentScreens = _ref3$components === void 0 ? [] : _ref3$components,
|
|
2677
|
+
_ref3$theme = _ref3.theme,
|
|
2678
|
+
theme = _ref3$theme === void 0 ? {} : _ref3$theme;
|
|
2679
|
+
|
|
2680
|
+
var _ref4 = isString(definition) ? {
|
|
2681
|
+
id: definition
|
|
2682
|
+
} : definition,
|
|
2683
|
+
newScreenType = _ref4.id;
|
|
1617
2684
|
|
|
2685
|
+
var _ref5 = theme || {},
|
|
2686
|
+
_ref5$components = _ref5.components,
|
|
2687
|
+
themeComponents = _ref5$components === void 0 ? null : _ref5$components;
|
|
1618
2688
|
|
|
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
|
|
2689
|
+
var themeScreen = themeComponents !== null ? themeComponents.find(function (it) {
|
|
2690
|
+
return it.type === newScreenType;
|
|
2691
|
+
}) || null : null;
|
|
2692
|
+
var newScreen = createScreen(definition, themeScreen);
|
|
2693
|
+
var foundIndex = screens.findIndex(function (_ref6) {
|
|
2694
|
+
var id = _ref6.id;
|
|
2695
|
+
return id === currentScreenId;
|
|
1629
2696
|
});
|
|
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;
|
|
2697
|
+
var currentScreenIndex = !isTheme && foundIndex >= 0 ? foundIndex + 1 : null;
|
|
1637
2698
|
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
2699
|
+
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
2700
|
+
components: [].concat(_toConsumableArray(currentScreens.slice(0, currentScreenIndex)), [newScreen], _toConsumableArray(currentScreens.slice(currentScreenIndex)))
|
|
2701
|
+
});
|
|
1641
2702
|
|
|
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
2703
|
if (onChange !== null) {
|
|
1648
2704
|
onChange(newValue);
|
|
1649
2705
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
2706
|
+
|
|
2707
|
+
return newScreen;
|
|
2708
|
+
}, [value, onChange, isTheme, screens, currentScreenId, setCreateModalOpened]);
|
|
2709
|
+
var onOrderChange = useCallback(function (listItems) {
|
|
2710
|
+
var ids = listItems.map(function (_ref7) {
|
|
2711
|
+
var id = _ref7.id;
|
|
2712
|
+
return id;
|
|
2713
|
+
});
|
|
2714
|
+
var screenProps = listItems.map(function (_ref8) {
|
|
2715
|
+
var id = _ref8.id,
|
|
2716
|
+
_ref8$props = _ref8.props,
|
|
2717
|
+
props = _ref8$props === void 0 ? null : _ref8$props;
|
|
2718
|
+
return {
|
|
2719
|
+
id: id,
|
|
2720
|
+
props: props
|
|
2721
|
+
};
|
|
2722
|
+
});
|
|
2723
|
+
var hasScreenProps = (screenProps.filter(function (_ref9) {
|
|
2724
|
+
var props = _ref9.props;
|
|
2725
|
+
return props !== null;
|
|
2726
|
+
}) || []).length > 0;
|
|
2727
|
+
|
|
2728
|
+
var _ref10 = value || {},
|
|
2729
|
+
_ref10$components = _ref10.components,
|
|
2730
|
+
currentScreens = _ref10$components === void 0 ? [] : _ref10$components;
|
|
2731
|
+
|
|
2732
|
+
var currentIds = currentScreens.map(function (_ref11) {
|
|
2733
|
+
var id = _ref11.id;
|
|
2734
|
+
return id;
|
|
2735
|
+
});
|
|
2736
|
+
var sameOrder = listItems.reduce(function (same, _ref12, index) {
|
|
2737
|
+
var id = _ref12.id;
|
|
2738
|
+
return same && id === currentIds[index];
|
|
2739
|
+
}, true);
|
|
2740
|
+
|
|
2741
|
+
if (!sameOrder || hasScreenProps) {
|
|
2742
|
+
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
2743
|
+
components: _toConsumableArray(currentScreens).sort(function (_ref13, _ref14) {
|
|
2744
|
+
var idA = _ref13.id;
|
|
2745
|
+
var idB = _ref14.id;
|
|
2746
|
+
var indexA = ids.indexOf(idA);
|
|
2747
|
+
var indexB = ids.indexOf(idB);
|
|
2748
|
+
|
|
2749
|
+
if (indexA === indexB) {
|
|
2750
|
+
return 0;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
return indexA > indexB ? 1 : -1;
|
|
2754
|
+
}).map(function (_ref15) {
|
|
2755
|
+
var _screenProps$find;
|
|
2756
|
+
|
|
2757
|
+
var id = _ref15.id,
|
|
2758
|
+
props = _objectWithoutProperties(_ref15, _excluded$1);
|
|
2759
|
+
|
|
2760
|
+
return _objectSpread(_objectSpread({
|
|
2761
|
+
id: id
|
|
2762
|
+
}, props), (_screenProps$find = screenProps.find(function (_ref16) {
|
|
2763
|
+
var propsId = _ref16.id;
|
|
2764
|
+
return propsId === id;
|
|
2765
|
+
})) === null || _screenProps$find === void 0 ? void 0 : _screenProps$find.props);
|
|
2766
|
+
})
|
|
2767
|
+
});
|
|
2768
|
+
|
|
2769
|
+
if (onChange !== null) {
|
|
2770
|
+
onChange(newValue);
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
}, [value, onChange]);
|
|
2774
|
+
var onClickScreenType = useCallback(function (definition) {
|
|
2775
|
+
setCreateModalOpened(false);
|
|
2776
|
+
var currentScreen = isTheme ? screens.find(function (_ref17) {
|
|
2777
|
+
var type = _ref17.type;
|
|
2778
|
+
return type === definition.id;
|
|
2779
|
+
}) || null : null;
|
|
2780
|
+
|
|
2781
|
+
if (!isTheme || currentScreen === null) {
|
|
2782
|
+
currentScreen = createScreenFromDefinition(definition);
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
push('screen', {
|
|
2786
|
+
screen: currentScreen.id
|
|
1665
2787
|
});
|
|
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
|
-
});
|
|
2788
|
+
onClickScreen(currentScreen);
|
|
2789
|
+
}, [screens, isTheme, createScreenFromDefinition, push, onClickScreen]);
|
|
2790
|
+
var onClickAdd = useCallback(function () {
|
|
2791
|
+
return setCreateModalOpened(true);
|
|
2792
|
+
}, [setCreateModalOpened]);
|
|
2793
|
+
var onCreateModalRequestClose = useCallback(function () {
|
|
2794
|
+
return setCreateModalOpened(false);
|
|
2795
|
+
}, [setCreateModalOpened]);
|
|
1704
2796
|
return /*#__PURE__*/React.createElement("div", {
|
|
1705
|
-
className: classNames(['d-flex', 'flex-column', className])
|
|
1706
|
-
},
|
|
2797
|
+
className: classNames(['d-flex', 'flex-column', styles$7.container, className])
|
|
2798
|
+
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
1707
2799
|
compact: true,
|
|
1708
2800
|
noWrap: true,
|
|
1709
2801
|
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"
|
|
2802
|
+
className: classNames(['sticky-top', styles$7.navbar])
|
|
2803
|
+
}, /*#__PURE__*/React.createElement("strong", {
|
|
2804
|
+
className: "mb-0 mr-auto"
|
|
1759
2805
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1760
|
-
id: "
|
|
2806
|
+
id: "jf+4Hq",
|
|
1761
2807
|
defaultMessage: [{
|
|
1762
2808
|
"type": 0,
|
|
1763
|
-
"value": "
|
|
1764
|
-
}]
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2809
|
+
"value": "Screens"
|
|
2810
|
+
}]
|
|
2811
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
2812
|
+
theme: "primary",
|
|
2813
|
+
size: "sm",
|
|
2814
|
+
onClick: onClickAdd,
|
|
2815
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
2816
|
+
icon: faPlus
|
|
2817
|
+
})
|
|
2818
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
2819
|
+
className: "flex-grow-1 d-flex w-100 p-2"
|
|
2820
|
+
}, /*#__PURE__*/React.createElement(Route, {
|
|
2821
|
+
path: [routes.screen, routes.home],
|
|
2822
|
+
render: function render(_ref18) {
|
|
2823
|
+
var _ref18$match$params$s = _ref18.match.params.screen,
|
|
2824
|
+
screenId = _ref18$match$params$s === void 0 ? null : _ref18$match$params$s;
|
|
2825
|
+
return screens.length > 0 ? /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
2826
|
+
items: screens.map(function (it) {
|
|
2827
|
+
return {
|
|
2828
|
+
id: it.id,
|
|
2829
|
+
screen: it,
|
|
2830
|
+
href: url('screen', {
|
|
2831
|
+
screen: it.id
|
|
2832
|
+
}),
|
|
2833
|
+
active: it.id === screenId
|
|
2834
|
+
};
|
|
2835
|
+
}),
|
|
2836
|
+
isVertical: isVertical,
|
|
2837
|
+
withPreview: true,
|
|
2838
|
+
sortable: !isTree,
|
|
2839
|
+
className: "w-100",
|
|
2840
|
+
onClickItem: onClickScreen,
|
|
2841
|
+
onOrderChange: onOrderChange,
|
|
2842
|
+
isTree: isTree
|
|
2843
|
+
}) : /*#__PURE__*/React.createElement(Empty, {
|
|
2844
|
+
className: "flex-grow-1 p-2"
|
|
2845
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
2846
|
+
theme: "primary",
|
|
2847
|
+
onClick: onClickAdd
|
|
2848
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
2849
|
+
id: "JoWKee",
|
|
2850
|
+
defaultMessage: [{
|
|
2851
|
+
"type": 0,
|
|
2852
|
+
"value": "Create your first screen"
|
|
2853
|
+
}]
|
|
2854
|
+
})));
|
|
2855
|
+
}
|
|
2856
|
+
})), createModalOpened ? /*#__PURE__*/React.createElement(ScreenTypesModal, {
|
|
2857
|
+
selectedTypes: isTheme ? screens.map(function (_ref19) {
|
|
2858
|
+
var type = _ref19.type;
|
|
2859
|
+
return type;
|
|
2860
|
+
}) : [],
|
|
2861
|
+
onClickScreenType: onClickScreenType,
|
|
2862
|
+
onRequestClose: onCreateModalRequestClose
|
|
1769
2863
|
}) : null);
|
|
1770
2864
|
};
|
|
1771
2865
|
|
|
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"};
|
|
2866
|
+
EditorScreens.propTypes = propTypes$4;
|
|
2867
|
+
EditorScreens.defaultProps = defaultProps$4;
|
|
1776
2868
|
|
|
1777
|
-
var propTypes$
|
|
2869
|
+
var propTypes$3 = {
|
|
1778
2870
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
1779
2871
|
deviceScreens: PropTypes$1.deviceScreens,
|
|
1780
2872
|
viewerTheme: PropTypes$1.viewerTheme,
|
|
@@ -1785,7 +2877,7 @@ var propTypes$1 = {
|
|
|
1785
2877
|
onChange: PropTypes.func,
|
|
1786
2878
|
className: PropTypes.string
|
|
1787
2879
|
};
|
|
1788
|
-
var defaultProps$
|
|
2880
|
+
var defaultProps$3 = {
|
|
1789
2881
|
value: null,
|
|
1790
2882
|
deviceScreens: getDeviceScreens(),
|
|
1791
2883
|
viewerTheme: null,
|
|
@@ -1878,7 +2970,11 @@ var Editor = function Editor(_ref) {
|
|
|
1878
2970
|
if (screenSize.screen) {
|
|
1879
2971
|
setMobileView('preview');
|
|
1880
2972
|
}
|
|
1881
|
-
|
|
2973
|
+
|
|
2974
|
+
push('screen', {
|
|
2975
|
+
screen: clickedScreenId.current
|
|
2976
|
+
});
|
|
2977
|
+
}, [screenSize.screen, push]);
|
|
1882
2978
|
var onPreviewScreenChange = useCallback(function (_ref4) {
|
|
1883
2979
|
var newScreenId = _ref4.id;
|
|
1884
2980
|
push('screen', {
|
|
@@ -1900,20 +2996,21 @@ var Editor = function Editor(_ref) {
|
|
|
1900
2996
|
var cnt = item.parentNode.parentNode.parentNode;
|
|
1901
2997
|
screens.scrollTop = cnt.offsetTop + item.offsetTop + item.offsetHeight / 2 - screens.clientHeight / 2;
|
|
1902
2998
|
}
|
|
1903
|
-
}, [screenId]);
|
|
2999
|
+
}, [screenId]); // console.log('editor level value', value);
|
|
3000
|
+
|
|
1904
3001
|
return /*#__PURE__*/React.createElement(ModalsProvider, null, /*#__PURE__*/React.createElement(PanelsProvider, null, /*#__PURE__*/React.createElement(ScreenSizeProvider, {
|
|
1905
3002
|
size: screenSize
|
|
1906
3003
|
}, /*#__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)]),
|
|
3004
|
+
className: classNames([styles$f.container, screenSize !== null ? screenSize.screens.map(function (screenName) {
|
|
3005
|
+
return styles$f["screen-".concat(screenName)];
|
|
3006
|
+
}) : null, (_ref5 = {}, _defineProperty(_ref5, styles$f.fullscreen, fullscreen), _defineProperty(_ref5, className, className), _ref5)]),
|
|
1910
3007
|
ref: refContainer
|
|
1911
3008
|
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
1912
3009
|
theme: "light",
|
|
1913
3010
|
compact: true,
|
|
1914
3011
|
noWrap: true,
|
|
1915
3012
|
withoutCollapse: true,
|
|
1916
|
-
className: styles.top
|
|
3013
|
+
className: styles$f.top
|
|
1917
3014
|
}, mobileView !== 'screens' ? /*#__PURE__*/React.createElement(Button, {
|
|
1918
3015
|
size: "sm",
|
|
1919
3016
|
theme: "secondary",
|
|
@@ -1946,9 +3043,9 @@ var Editor = function Editor(_ref) {
|
|
|
1946
3043
|
"value": "View screen"
|
|
1947
3044
|
}]
|
|
1948
3045
|
})) : null), /*#__PURE__*/React.createElement("div", {
|
|
1949
|
-
className: styles.inner
|
|
3046
|
+
className: styles$f.inner
|
|
1950
3047
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1951
|
-
className: classNames([styles.left, _defineProperty({}, styles.visible, !isMobile || mobileView === 'screens')]),
|
|
3048
|
+
className: classNames([styles$f.left, _defineProperty({}, styles$f.visible, !isMobile || mobileView === 'screens')]),
|
|
1952
3049
|
ref: refScreensContainer
|
|
1953
3050
|
}, /*#__PURE__*/React.createElement(EditorScreens, {
|
|
1954
3051
|
value: story,
|
|
@@ -1958,28 +3055,28 @@ var Editor = function Editor(_ref) {
|
|
|
1958
3055
|
onChange: onStoryChange,
|
|
1959
3056
|
onClickScreen: onClickScreen,
|
|
1960
3057
|
isVertical: !isMobile,
|
|
1961
|
-
className: styles.inner
|
|
3058
|
+
className: styles$f.inner
|
|
1962
3059
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1963
|
-
className: classNames([styles.center, _defineProperty({}, styles.visible, !isMobile || mobileView === 'preview')])
|
|
3060
|
+
className: classNames([styles$f.center, _defineProperty({}, styles$f.visible, !isMobile || mobileView === 'preview')])
|
|
1964
3061
|
}, /*#__PURE__*/React.createElement(EditorPreview, {
|
|
1965
3062
|
value: story,
|
|
1966
3063
|
isTheme: isTheme,
|
|
1967
3064
|
viewerTheme: viewerTheme,
|
|
1968
|
-
className: styles.preview,
|
|
3065
|
+
className: styles$f.preview,
|
|
1969
3066
|
onScreenChange: onPreviewScreenChange
|
|
1970
3067
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1971
|
-
className: classNames([styles.right, _defineProperty({}, styles.visible, !isMobile || mobileView === 'form')])
|
|
3068
|
+
className: classNames([styles$f.right, _defineProperty({}, styles$f.visible, !isMobile || mobileView === 'form')])
|
|
1972
3069
|
}, /*#__PURE__*/React.createElement(EditForm, {
|
|
1973
3070
|
key: screenId,
|
|
1974
3071
|
value: story,
|
|
1975
3072
|
isTheme: isTheme,
|
|
1976
3073
|
onChange: onStoryChange,
|
|
1977
|
-
className: styles.inner
|
|
3074
|
+
className: styles$f.inner
|
|
1978
3075
|
}))), /*#__PURE__*/React.createElement(Modals, null)))));
|
|
1979
3076
|
};
|
|
1980
3077
|
|
|
1981
|
-
Editor.propTypes = propTypes$
|
|
1982
|
-
Editor.defaultProps = defaultProps$
|
|
3078
|
+
Editor.propTypes = propTypes$3;
|
|
3079
|
+
Editor.defaultProps = defaultProps$3;
|
|
1983
3080
|
|
|
1984
3081
|
var home = "/";
|
|
1985
3082
|
var screen = "/:screen";
|
|
@@ -1990,6 +3087,101 @@ var defaultRoutes = {
|
|
|
1990
3087
|
"screen.field.form": "/:screen/:field+/:form"
|
|
1991
3088
|
};
|
|
1992
3089
|
|
|
3090
|
+
var routes = PropTypes.shape({
|
|
3091
|
+
home: PropTypes.string.isRequired,
|
|
3092
|
+
screen: PropTypes.string.isRequired,
|
|
3093
|
+
'screen.field': PropTypes.string.isRequired,
|
|
3094
|
+
'screen.field.form': PropTypes.string.isRequired
|
|
3095
|
+
});
|
|
3096
|
+
|
|
3097
|
+
var styles = {"container":"micromag-editor-forms-settings-container","inner":"micromag-editor-forms-settings-inner"};
|
|
3098
|
+
|
|
3099
|
+
var propTypes$2 = {
|
|
3100
|
+
name: PropTypes.string,
|
|
3101
|
+
field: PropTypes$1.formField.isRequired,
|
|
3102
|
+
value: PropTypes$1.component,
|
|
3103
|
+
className: PropTypes.string,
|
|
3104
|
+
gotoFieldForm: PropTypes.func.isRequired,
|
|
3105
|
+
closeFieldForm: PropTypes.func.isRequired,
|
|
3106
|
+
onChange: PropTypes.func
|
|
3107
|
+
};
|
|
3108
|
+
var defaultProps$2 = {
|
|
3109
|
+
name: null,
|
|
3110
|
+
value: null,
|
|
3111
|
+
className: null,
|
|
3112
|
+
onChange: null
|
|
3113
|
+
};
|
|
3114
|
+
|
|
3115
|
+
var SettingsForm = function SettingsForm(_ref) {
|
|
3116
|
+
var name = _ref.name,
|
|
3117
|
+
field = _ref.field,
|
|
3118
|
+
value = _ref.value,
|
|
3119
|
+
className = _ref.className,
|
|
3120
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
3121
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
3122
|
+
onChange = _ref.onChange;
|
|
3123
|
+
var _field$type = field.type,
|
|
3124
|
+
type = _field$type === void 0 ? null : _field$type;
|
|
3125
|
+
var fieldsManager = useFieldsManager();
|
|
3126
|
+
|
|
3127
|
+
var _ref2 = type !== null ? fieldsManager.getDefinition(type) : field,
|
|
3128
|
+
_ref2$component = _ref2.component,
|
|
3129
|
+
fieldComponent = _ref2$component === void 0 ? null : _ref2$component,
|
|
3130
|
+
settings = _ref2.settings;
|
|
3131
|
+
|
|
3132
|
+
var FieldComponent = useFieldComponent(fieldComponent);
|
|
3133
|
+
var FieldsComponent = useFieldComponent('fields');
|
|
3134
|
+
var SettingsComponent = FieldComponent !== null ? FieldComponent.settingsComponent || FieldsComponent : FieldsComponent;
|
|
3135
|
+
var onSettingsChange = useCallback(function (newSettingsValue) {
|
|
3136
|
+
var newValue = _objectSpread(_objectSpread({}, value), newSettingsValue);
|
|
3137
|
+
|
|
3138
|
+
if (onChange !== null) {
|
|
3139
|
+
onChange(newValue);
|
|
3140
|
+
}
|
|
3141
|
+
}, [value, onChange]);
|
|
3142
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3143
|
+
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
3144
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3145
|
+
className: styles.inner
|
|
3146
|
+
}, /*#__PURE__*/React.createElement(SettingsComponent, {
|
|
3147
|
+
name: name,
|
|
3148
|
+
field: field,
|
|
3149
|
+
fields: settings,
|
|
3150
|
+
value: value,
|
|
3151
|
+
onChange: onSettingsChange,
|
|
3152
|
+
gotoFieldForm: gotoFieldForm,
|
|
3153
|
+
closeFieldForm: closeFieldForm
|
|
3154
|
+
})));
|
|
3155
|
+
};
|
|
3156
|
+
|
|
3157
|
+
SettingsForm.propTypes = propTypes$2;
|
|
3158
|
+
SettingsForm.defaultProps = defaultProps$2;
|
|
3159
|
+
|
|
3160
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3161
|
+
|
|
3162
|
+
var FormsComponents = /*#__PURE__*/Object.freeze({
|
|
3163
|
+
__proto__: null,
|
|
3164
|
+
Settings: SettingsForm
|
|
3165
|
+
});
|
|
3166
|
+
|
|
3167
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
3168
|
+
var propTypes$1 = {
|
|
3169
|
+
children: PropTypes.node
|
|
3170
|
+
};
|
|
3171
|
+
var defaultProps$1 = {
|
|
3172
|
+
children: null
|
|
3173
|
+
};
|
|
3174
|
+
|
|
3175
|
+
var FormsProvider = function FormsProvider(props) {
|
|
3176
|
+
return /*#__PURE__*/React.createElement(ComponentsProvider, Object.assign({
|
|
3177
|
+
namespace: FORMS_NAMESPACE,
|
|
3178
|
+
components: FormsComponents
|
|
3179
|
+
}, props));
|
|
3180
|
+
};
|
|
3181
|
+
|
|
3182
|
+
FormsProvider.propTypes = propTypes$1;
|
|
3183
|
+
FormsProvider.defaultProps = defaultProps$1;
|
|
3184
|
+
|
|
1993
3185
|
var _excluded = ["value", "memoryRouter", "routes", "basePath", "uppy", "googleApiKey", "googleMapsLibraries"];
|
|
1994
3186
|
var propTypes = {
|
|
1995
3187
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|