@micromag/editor 0.2.412 → 0.3.1
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 -9
- package/es/index.js +1259 -833
- package/lib/index.js +1256 -829
- package/package.json +8 -8
package/es/index.js
CHANGED
|
@@ -2,28 +2,29 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
4
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
5
|
-
import { Button, BackButton, Breadcrumb as Breadcrumb$1,
|
|
6
|
-
import { useRoutes, useScreensManager, useFieldsManager,
|
|
7
|
-
import {
|
|
5
|
+
import { Button, FieldForm, BackButton, Breadcrumb as Breadcrumb$1, Modal, ModalDialog, Label, Navbar, DropdownMenu, Empty, Tabs, ScreenPlaceholder, ScreenPreview, Modals } from '@micromag/core/components';
|
|
6
|
+
import { useRoutes, useScreenDefinition, useFormsComponents, useScreensManager, useFieldsManager, useUrlGenerator, useRoutePush, ScreenProvider, useScreenSize, ModalsProvider, PanelsProvider, ScreenSizeProvider, useFieldComponent, ComponentsProvider, FORMS_NAMESPACE, UppyProvider, StoryProvider, GoogleKeysProvider, GoogleMapsClientProvider, FontsProvider, EditorProvider, ComponentsContext, RoutesProvider } from '@micromag/core/contexts';
|
|
7
|
+
import { useResizeObserver, useParsedStory, useScreenSizeFromElement, useMediasParser } from '@micromag/core/hooks';
|
|
8
8
|
import { getScreenExtraField, isMessage, slug, getComponentFromName, getDeviceScreens } from '@micromag/core/utils';
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React, { useMemo, useRef, useCallback, useState, forwardRef, useEffect } from 'react';
|
|
12
12
|
import { useIntl, FormattedMessage } from 'react-intl';
|
|
13
13
|
import { useRouteMatch, useHistory, Route, MemoryRouter } from 'react-router';
|
|
14
|
-
import
|
|
14
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
15
|
+
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
15
16
|
import { v1 } from 'uuid';
|
|
16
17
|
import isString from 'lodash/isString';
|
|
17
18
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
18
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
19
19
|
import 'lodash/isArray';
|
|
20
20
|
import 'lodash/get';
|
|
21
21
|
import 'lodash/set';
|
|
22
22
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
23
|
-
import { faCogs, faGripLines, faTimes, faAngleDown
|
|
23
|
+
import { faEllipsisV, faCogs, faPlus, faGripLines, faTimes, faAngleDown } from '@fortawesome/free-solid-svg-icons';
|
|
24
24
|
import { Fields, FieldsProvider } from '@micromag/fields';
|
|
25
25
|
import { getSizeWithinBounds } from '@folklore/size';
|
|
26
26
|
import { Viewer } from '@micromag/viewer';
|
|
27
|
+
import _toArray from '@babel/runtime/helpers/toArray';
|
|
27
28
|
import isFunction from 'lodash/isFunction';
|
|
28
29
|
import { ReactSortable } from 'react-sortablejs';
|
|
29
30
|
import { KeyboardCode, closestCorners, getFirstCollision, getClientRect, MeasuringStrategy, defaultDropAnimation, useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, DragOverlay } from '@dnd-kit/core';
|
|
@@ -71,24 +72,110 @@ var useRouteParams = function useRouteParams() {
|
|
|
71
72
|
return routeParams;
|
|
72
73
|
};
|
|
73
74
|
|
|
74
|
-
var styles$
|
|
75
|
+
var styles$i = {"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"};
|
|
75
76
|
|
|
76
|
-
var
|
|
77
|
-
var
|
|
77
|
+
var useFormTransition = function useFormTransition(url, screenIndex, styles) {
|
|
78
|
+
var lastPageRef = useRef({
|
|
79
|
+
url: url,
|
|
80
|
+
screenIndex: screenIndex
|
|
81
|
+
});
|
|
82
|
+
var direction = useMemo(function () {
|
|
83
|
+
var _lastPageRef$current = lastPageRef.current,
|
|
84
|
+
lastScreenIndex = _lastPageRef$current.screenIndex,
|
|
85
|
+
lastUrl = _lastPageRef$current.url;
|
|
86
|
+
lastPageRef.current.url = url;
|
|
87
|
+
lastPageRef.current.screenIndex = screenIndex;
|
|
78
88
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
if (screenIndex !== lastScreenIndex) {
|
|
90
|
+
// return screenIndex > lastScreenIndex ? 'bottom' : 'top';
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var urlSplit = url.split('/');
|
|
95
|
+
var lastUrlSplit = lastUrl.split('/');
|
|
96
|
+
var currentPartsCount = urlSplit.length;
|
|
97
|
+
var previousPartsCount = lastUrlSplit.length;
|
|
98
|
+
var isSettings = urlSplit[currentPartsCount - 1] === 'settings';
|
|
99
|
+
var wasSettings = lastUrlSplit[previousPartsCount - 1] === 'settings';
|
|
100
|
+
currentPartsCount -= isSettings ? 1 : 0;
|
|
101
|
+
previousPartsCount -= wasSettings ? 1 : 0;
|
|
102
|
+
return currentPartsCount >= previousPartsCount ? 'right' : 'left';
|
|
103
|
+
}, [url, screenIndex]);
|
|
104
|
+
var transitionClassNames = useMemo(function () {
|
|
105
|
+
var _classNames, _classNames2, _classNames3;
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
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',
|
|
109
|
+
enterActive: classNames((_classNames2 = {}, _defineProperty(_classNames2, styles.enterActiveHorizontal, direction === 'left' || direction === 'right'), _defineProperty(_classNames2, styles.enterActiveVertical, direction === 'top' || direction === 'bottom'), _classNames2)) || 'none',
|
|
110
|
+
exit: styles.exit || 'none',
|
|
111
|
+
exitActive: classNames((_classNames3 = {}, _defineProperty(_classNames3, styles.exitActiveRight, direction === 'right'), _defineProperty(_classNames3, styles.exitActiveLeft, direction === 'left'), _defineProperty(_classNames3, styles.exitActiveTop, direction === 'top'), _defineProperty(_classNames3, styles.exitActiveBottom, direction === 'bottom'), _classNames3)) || 'none'
|
|
112
|
+
};
|
|
113
|
+
}, [direction, screenIndex]);
|
|
114
|
+
return {
|
|
115
|
+
direction: direction,
|
|
116
|
+
classNames: transitionClassNames,
|
|
117
|
+
timeout: direction === 'left' || direction === 'right' ? 300 : 10
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
var styles$h = {"panel":"micromag-editor-form-panel","exit":"micromag-editor-form-exit","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","exitActiveLeft":"micromag-editor-form-exitActiveLeft","exitActiveRight":"micromag-editor-form-exitActiveRight","exitActiveBottom":"micromag-editor-form-exitActiveBottom","exitActiveTop":"micromag-editor-form-exitActiveTop"};
|
|
122
|
+
|
|
123
|
+
function getScreenFieldsWithStates(definition) {
|
|
124
|
+
var _ref = definition || {},
|
|
83
125
|
_ref$fields = _ref.fields,
|
|
84
|
-
|
|
126
|
+
screenFields = _ref$fields === void 0 ? [] : _ref$fields,
|
|
127
|
+
_ref$states = _ref.states,
|
|
128
|
+
states = _ref$states === void 0 ? null : _ref$states;
|
|
129
|
+
|
|
130
|
+
if (states === null) {
|
|
131
|
+
return screenFields;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return [].concat(_toConsumableArray(states.reduce(function (statesFields, _ref2) {
|
|
135
|
+
var id = _ref2.id,
|
|
136
|
+
_ref2$fields = _ref2.fields,
|
|
137
|
+
fields = _ref2$fields === void 0 ? [] : _ref2$fields,
|
|
138
|
+
_ref2$repeatable = _ref2.repeatable,
|
|
139
|
+
repeatable = _ref2$repeatable === void 0 ? false : _ref2$repeatable,
|
|
140
|
+
_ref2$fieldName = _ref2.fieldName,
|
|
141
|
+
fieldName = _ref2$fieldName === void 0 ? null : _ref2$fieldName,
|
|
142
|
+
label = _ref2.label;
|
|
143
|
+
return [].concat(_toConsumableArray(statesFields), _toConsumableArray(repeatable ? [{
|
|
144
|
+
type: 'items',
|
|
145
|
+
name: fieldName || id,
|
|
146
|
+
label: label,
|
|
147
|
+
stateId: id,
|
|
148
|
+
itemsField: {
|
|
149
|
+
label: label,
|
|
150
|
+
type: 'fields',
|
|
151
|
+
fields: fields
|
|
152
|
+
}
|
|
153
|
+
}] : []), _toConsumableArray(!repeatable && fieldName !== null ? [{
|
|
154
|
+
type: 'fields',
|
|
155
|
+
name: fieldName,
|
|
156
|
+
stateId: id,
|
|
157
|
+
fields: fields
|
|
158
|
+
}] : []), _toConsumableArray(!repeatable && fieldName === null ? fields.map(function (it) {
|
|
159
|
+
return _objectSpread(_objectSpread({}, it), {}, {
|
|
160
|
+
stateId: id
|
|
161
|
+
});
|
|
162
|
+
}) : []));
|
|
163
|
+
}, [])), _toConsumableArray(screenFields));
|
|
164
|
+
}
|
|
85
165
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
166
|
+
var createScreen = function createScreen(definition) {
|
|
167
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
168
|
+
var finalDefinition = isString(definition) ? {
|
|
169
|
+
id: definition
|
|
170
|
+
} : definition;
|
|
171
|
+
var id = finalDefinition.id;
|
|
172
|
+
var screenFields = getScreenFieldsWithStates(finalDefinition);
|
|
173
|
+
var defaultValueFields = screenFields.reduce(function (all, curr) {
|
|
174
|
+
var _ref = curr || {},
|
|
175
|
+
_ref$name = _ref.name,
|
|
176
|
+
name = _ref$name === void 0 ? null : _ref$name,
|
|
177
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
178
|
+
defaultValue = _ref$defaultValue === void 0 ? null : _ref$defaultValue;
|
|
92
179
|
|
|
93
180
|
var newAll = _objectSpread({}, all);
|
|
94
181
|
|
|
@@ -105,13 +192,13 @@ var createScreen = function createScreen(definition) {
|
|
|
105
192
|
});
|
|
106
193
|
};
|
|
107
194
|
|
|
108
|
-
var _excluded$
|
|
195
|
+
var _excluded$c = ["components"];
|
|
109
196
|
|
|
110
197
|
var deleteScreen = function deleteScreen(story, screenId) {
|
|
111
198
|
var _ref = story || {},
|
|
112
199
|
_ref$components = _ref.components,
|
|
113
200
|
components = _ref$components === void 0 ? [] : _ref$components,
|
|
114
|
-
currentValue = _objectWithoutProperties(_ref, _excluded$
|
|
201
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$c);
|
|
115
202
|
|
|
116
203
|
return _objectSpread(_objectSpread({}, currentValue), {}, {
|
|
117
204
|
components: components.filter(function (_ref2) {
|
|
@@ -121,13 +208,13 @@ var deleteScreen = function deleteScreen(story, screenId) {
|
|
|
121
208
|
});
|
|
122
209
|
};
|
|
123
210
|
|
|
124
|
-
var _excluded$
|
|
211
|
+
var _excluded$b = ["components"];
|
|
125
212
|
|
|
126
213
|
var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
127
214
|
var _ref = story || {},
|
|
128
215
|
_ref$components = _ref.components,
|
|
129
216
|
components = _ref$components === void 0 ? [] : _ref$components,
|
|
130
|
-
currentValue = _objectWithoutProperties(_ref, _excluded$
|
|
217
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$b);
|
|
131
218
|
|
|
132
219
|
var screen = components.find(function (it) {
|
|
133
220
|
return it.id === screenId;
|
|
@@ -139,7 +226,7 @@ var duplicateScreen = function duplicateScreen(story, screenId) {
|
|
|
139
226
|
});
|
|
140
227
|
};
|
|
141
228
|
|
|
142
|
-
var _excluded$
|
|
229
|
+
var _excluded$a = ["components"];
|
|
143
230
|
|
|
144
231
|
var updateScreen = function updateScreen(story, newScreenValue) {
|
|
145
232
|
var newScreenId = newScreenValue.id;
|
|
@@ -147,7 +234,7 @@ var updateScreen = function updateScreen(story, newScreenValue) {
|
|
|
147
234
|
var _ref = story || {},
|
|
148
235
|
_ref$components = _ref.components,
|
|
149
236
|
components = _ref$components === void 0 ? [] : _ref$components,
|
|
150
|
-
currentValue = _objectWithoutProperties(_ref, _excluded$
|
|
237
|
+
currentValue = _objectWithoutProperties(_ref, _excluded$a);
|
|
151
238
|
|
|
152
239
|
var index = components.findIndex(function (it) {
|
|
153
240
|
return it.id === newScreenId;
|
|
@@ -176,78 +263,179 @@ var getFieldByName = function getFieldByName(fields, name) {
|
|
|
176
263
|
}, null);
|
|
177
264
|
};
|
|
178
265
|
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
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;
|
|
208
|
-
|
|
209
|
-
return {
|
|
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'
|
|
214
|
-
};
|
|
215
|
-
}, [direction, screenIndex]);
|
|
216
|
-
return {
|
|
217
|
-
direction: direction,
|
|
218
|
-
name: name,
|
|
219
|
-
timeout: direction === 'left' || direction === 'right' ? 300 : 10
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
var _excluded$8 = ["className"];
|
|
224
|
-
var propTypes$n = {
|
|
266
|
+
var _excluded$9 = ["className", "dots"];
|
|
267
|
+
var propTypes$o = {
|
|
268
|
+
dots: PropTypes.bool,
|
|
225
269
|
className: PropTypes.string
|
|
226
270
|
};
|
|
227
|
-
var defaultProps$
|
|
271
|
+
var defaultProps$o = {
|
|
272
|
+
dots: false,
|
|
228
273
|
className: null
|
|
229
274
|
};
|
|
230
275
|
|
|
231
276
|
var SettingsButton = function SettingsButton(_ref) {
|
|
232
277
|
var className = _ref.className,
|
|
233
|
-
|
|
278
|
+
dots = _ref.dots,
|
|
279
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
234
280
|
|
|
235
281
|
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
236
282
|
className: className,
|
|
237
283
|
theme: "secondary",
|
|
238
284
|
size: "sm",
|
|
239
285
|
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
240
|
-
icon: faCogs
|
|
286
|
+
icon: dots ? faEllipsisV : faCogs
|
|
241
287
|
})
|
|
242
288
|
}, props));
|
|
243
289
|
};
|
|
244
290
|
|
|
245
|
-
SettingsButton.propTypes = propTypes$
|
|
246
|
-
SettingsButton.defaultProps = defaultProps$
|
|
291
|
+
SettingsButton.propTypes = propTypes$o;
|
|
292
|
+
SettingsButton.defaultProps = defaultProps$o;
|
|
293
|
+
|
|
294
|
+
var _excluded$8 = ["name", "form"];
|
|
295
|
+
var propTypes$n = {
|
|
296
|
+
name: PropTypes.string,
|
|
297
|
+
form: PropTypes.string,
|
|
298
|
+
children: PropTypes.node
|
|
299
|
+
};
|
|
300
|
+
var defaultProps$n = {
|
|
301
|
+
name: null,
|
|
302
|
+
form: null,
|
|
303
|
+
children: null
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
var FieldWithContexts = function FieldWithContexts(_ref) {
|
|
307
|
+
var name = _ref.name,
|
|
308
|
+
form = _ref.form,
|
|
309
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
310
|
+
|
|
311
|
+
// Get definitions
|
|
312
|
+
var definition = useScreenDefinition();
|
|
313
|
+
var _definition$states = definition.states,
|
|
314
|
+
states = _definition$states === void 0 ? null : _definition$states;
|
|
315
|
+
var screenFields = getScreenFieldsWithStates(definition); // const [stateId = null] = name.split('.');
|
|
316
|
+
// const currentState = states !== null ? states.find(({ id }) => id === stateId) || null : null;
|
|
317
|
+
|
|
318
|
+
var nameParts = name.split('.');
|
|
319
|
+
|
|
320
|
+
var _nameParts = _slicedToArray(nameParts, 1),
|
|
321
|
+
_nameParts$ = _nameParts[0],
|
|
322
|
+
stateId = _nameParts$ === void 0 ? null : _nameParts$;
|
|
323
|
+
|
|
324
|
+
var currentState = states !== null ? states.find(function (_ref2) {
|
|
325
|
+
var id = _ref2.id;
|
|
326
|
+
return id === stateId;
|
|
327
|
+
}) || null : null;
|
|
328
|
+
var finalNameParts = nameParts;
|
|
329
|
+
|
|
330
|
+
var _ref3 = currentState || {},
|
|
331
|
+
_ref3$repeatable = _ref3.repeatable,
|
|
332
|
+
repeatable = _ref3$repeatable === void 0 ? false : _ref3$repeatable,
|
|
333
|
+
_ref3$fieldName = _ref3.fieldName,
|
|
334
|
+
fieldName = _ref3$fieldName === void 0 ? null : _ref3$fieldName,
|
|
335
|
+
_ref3$fields = _ref3.fields,
|
|
336
|
+
stateFields = _ref3$fields === void 0 ? [] : _ref3$fields;
|
|
337
|
+
|
|
338
|
+
if (currentState !== null) {
|
|
339
|
+
finalNameParts = (repeatable || fieldName !== null) && nameParts.length <= (repeatable ? 2 : 1) ? [fieldName || stateId].concat(_toConsumableArray(nameParts.slice(1))) : nameParts.slice(1);
|
|
340
|
+
}
|
|
247
341
|
|
|
248
|
-
var
|
|
342
|
+
var formComponents = useFormsComponents(); // if (currentState !== null && !repeatable && stateFieldName === null) {
|
|
343
|
+
// return (
|
|
344
|
+
// <div className="p-2">
|
|
345
|
+
// <Fields fields={stateFields} {...props} />
|
|
346
|
+
// </div>
|
|
347
|
+
// );
|
|
348
|
+
// }
|
|
349
|
+
// const finalFields =
|
|
350
|
+
// repeatable || stateFieldName !== null
|
|
351
|
+
// ? [{
|
|
352
|
+
// name: stateFieldName || stateId,
|
|
353
|
+
// itemsField: {
|
|
354
|
+
// type: 'fields',
|
|
355
|
+
// fields: stateFields,
|
|
356
|
+
// className: 'p-2'
|
|
357
|
+
// },
|
|
358
|
+
// }]
|
|
359
|
+
// : fields;
|
|
360
|
+
|
|
361
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
362
|
+
className: classNames({
|
|
363
|
+
'p-2': form === null
|
|
364
|
+
})
|
|
365
|
+
}, finalNameParts.length > 0 ? /*#__PURE__*/React.createElement(FieldForm, Object.assign({
|
|
366
|
+
fields: screenFields,
|
|
367
|
+
formComponents: formComponents,
|
|
368
|
+
name: finalNameParts.join('.'),
|
|
369
|
+
form: form
|
|
370
|
+
}, props)) : /*#__PURE__*/React.createElement(Fields, Object.assign({
|
|
371
|
+
fields: stateFields
|
|
372
|
+
}, props)));
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
FieldWithContexts.propTypes = propTypes$n;
|
|
376
|
+
FieldWithContexts.defaultProps = defaultProps$n;
|
|
377
|
+
|
|
378
|
+
var styles$g = {"container":"micromag-editor-forms-screen-container","inner":"micromag-editor-forms-screen-inner"};
|
|
249
379
|
|
|
250
380
|
var propTypes$m = {
|
|
381
|
+
value: PropTypes$1.component,
|
|
382
|
+
className: PropTypes.string,
|
|
383
|
+
gotoFieldForm: PropTypes.func.isRequired,
|
|
384
|
+
closeFieldForm: PropTypes.func.isRequired,
|
|
385
|
+
onChange: PropTypes.func // onClickDelete: PropTypes.func,
|
|
386
|
+
|
|
387
|
+
};
|
|
388
|
+
var defaultProps$m = {
|
|
389
|
+
value: null,
|
|
390
|
+
className: null,
|
|
391
|
+
onChange: null // onClickDelete: null,
|
|
392
|
+
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
var ScreenForm = function ScreenForm(_ref) {
|
|
396
|
+
var value = _ref.value,
|
|
397
|
+
className = _ref.className,
|
|
398
|
+
gotoFieldForm = _ref.gotoFieldForm,
|
|
399
|
+
closeFieldForm = _ref.closeFieldForm,
|
|
400
|
+
onChange = _ref.onChange;
|
|
401
|
+
|
|
402
|
+
var _useScreenDefinition = useScreenDefinition(),
|
|
403
|
+
_useScreenDefinition$ = _useScreenDefinition.fields,
|
|
404
|
+
fields = _useScreenDefinition$ === void 0 ? [] : _useScreenDefinition$; // const intl = useIntl();
|
|
405
|
+
// const finalOnClickDelete = useCallback(() => {
|
|
406
|
+
// if (
|
|
407
|
+
// onClickDelete !== null &&
|
|
408
|
+
// window.confirm(
|
|
409
|
+
// intl.formatMessage({
|
|
410
|
+
// defaultMessage: 'Are you sure you want to delete this screen?',
|
|
411
|
+
// description: 'Confirm message when deleting a screen',
|
|
412
|
+
// }),
|
|
413
|
+
// )
|
|
414
|
+
// ) {
|
|
415
|
+
// onClickDelete(value);
|
|
416
|
+
// }
|
|
417
|
+
// }, [intl, onClickDelete, value]);
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
421
|
+
className: classNames([styles$g.container, _defineProperty({}, className, className)])
|
|
422
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
423
|
+
className: styles$g.inner
|
|
424
|
+
}, /*#__PURE__*/React.createElement(Fields, {
|
|
425
|
+
fields: fields,
|
|
426
|
+
value: value,
|
|
427
|
+
onChange: onChange,
|
|
428
|
+
gotoFieldForm: gotoFieldForm,
|
|
429
|
+
closeFieldForm: closeFieldForm
|
|
430
|
+
})));
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
ScreenForm.propTypes = propTypes$m;
|
|
434
|
+
ScreenForm.defaultProps = defaultProps$m;
|
|
435
|
+
|
|
436
|
+
var styles$f = {"container":"micromag-editor-menus-breadcrumb-container"};
|
|
437
|
+
|
|
438
|
+
var propTypes$l = {
|
|
251
439
|
story: PropTypes$1.story,
|
|
252
440
|
screenId: PropTypes.string,
|
|
253
441
|
field: PropTypes.string,
|
|
@@ -255,7 +443,7 @@ var propTypes$m = {
|
|
|
255
443
|
url: PropTypes.string.isRequired,
|
|
256
444
|
className: PropTypes.string
|
|
257
445
|
};
|
|
258
|
-
var defaultProps$
|
|
446
|
+
var defaultProps$l = {
|
|
259
447
|
story: null,
|
|
260
448
|
screenId: null,
|
|
261
449
|
field: null,
|
|
@@ -279,44 +467,87 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
279
467
|
var history = useHistory();
|
|
280
468
|
var screensManager = useScreensManager();
|
|
281
469
|
var fieldsManager = useFieldsManager();
|
|
282
|
-
var
|
|
470
|
+
var route = useUrlGenerator();
|
|
471
|
+
|
|
472
|
+
var _useMemo = useMemo(function () {
|
|
283
473
|
var screenIndex = screens.findIndex(function (it) {
|
|
284
474
|
return it.id === screenId;
|
|
285
475
|
});
|
|
286
476
|
|
|
287
477
|
if (!screens[screenIndex]) {
|
|
288
|
-
return
|
|
478
|
+
return {};
|
|
289
479
|
}
|
|
290
480
|
|
|
291
481
|
var type = screens[screenIndex].type;
|
|
482
|
+
var definition = screensManager.getDefinition(type);
|
|
483
|
+
var states = definition.states;
|
|
484
|
+
return {
|
|
485
|
+
fields: [].concat(_toConsumableArray(getScreenFieldsWithStates(definition)), [getScreenExtraField(intl)]),
|
|
486
|
+
states: states
|
|
487
|
+
};
|
|
488
|
+
}, [screens, screenId, screensManager, intl]),
|
|
489
|
+
_useMemo$fields = _useMemo.fields,
|
|
490
|
+
screenFields = _useMemo$fields === void 0 ? [] : _useMemo$fields,
|
|
491
|
+
_useMemo$states = _useMemo.states,
|
|
492
|
+
screenStates = _useMemo$states === void 0 ? null : _useMemo$states;
|
|
493
|
+
|
|
494
|
+
var items = useMemo(function () {
|
|
292
495
|
var fieldItems = [];
|
|
496
|
+
var currentState = null;
|
|
293
497
|
|
|
294
498
|
if (field !== null) {
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
499
|
+
var fieldPath = field.split('/'); // Get state and remove it from path. Replace it with field name if necessary (repeatable or fieldName present)
|
|
500
|
+
|
|
501
|
+
var _fieldPath = _slicedToArray(fieldPath, 1),
|
|
502
|
+
_fieldPath$ = _fieldPath[0],
|
|
503
|
+
stateId = _fieldPath$ === void 0 ? null : _fieldPath$;
|
|
504
|
+
|
|
505
|
+
currentState = screenStates !== null ? screenStates.find(function (_ref3) {
|
|
506
|
+
var id = _ref3.id;
|
|
507
|
+
return id === stateId;
|
|
508
|
+
}) || null : null;
|
|
509
|
+
var finalFieldPath = fieldPath;
|
|
510
|
+
|
|
511
|
+
if (currentState !== null) {
|
|
512
|
+
var _ref4 = currentState || {},
|
|
513
|
+
_ref4$repeatable = _ref4.repeatable,
|
|
514
|
+
repeatable = _ref4$repeatable === void 0 ? false : _ref4$repeatable,
|
|
515
|
+
_ref4$fieldName = _ref4.fieldName,
|
|
516
|
+
fieldName = _ref4$fieldName === void 0 ? null : _ref4$fieldName;
|
|
517
|
+
|
|
518
|
+
finalFieldPath = (repeatable || fieldName !== null) && fieldPath.length <= (repeatable ? 2 : 1) ? [fieldName || stateId].concat(_toConsumableArray(fieldPath.slice(1))) : fieldPath.slice(1);
|
|
519
|
+
}
|
|
298
520
|
|
|
299
|
-
var
|
|
300
|
-
var fieldPath = field.split('/');
|
|
301
|
-
var lastKeyIndex = fieldPath.length - 1;
|
|
521
|
+
var lastKeyIndex = finalFieldPath.length - 1;
|
|
302
522
|
var parentItem = null;
|
|
303
|
-
|
|
523
|
+
finalFieldPath.reduce(function (currentFields, key, keyIndex) {
|
|
304
524
|
var _currentFields$type = currentFields.type,
|
|
305
|
-
fieldType = _currentFields$type === void 0 ? null : _currentFields$type
|
|
525
|
+
fieldType = _currentFields$type === void 0 ? null : _currentFields$type,
|
|
526
|
+
_currentFields$fields = currentFields.fields,
|
|
527
|
+
currentSubFields = _currentFields$fields === void 0 ? null : _currentFields$fields,
|
|
528
|
+
_currentFields$itemsF = currentFields.itemsField,
|
|
529
|
+
currentItemsField = _currentFields$itemsF === void 0 ? null : _currentFields$itemsF;
|
|
306
530
|
var fieldsDef = fieldType !== null ? fieldsManager.getDefinition(fieldType) : currentFields;
|
|
307
531
|
var _fieldsDef$fields = fieldsDef.fields,
|
|
308
|
-
|
|
532
|
+
defSubFields = _fieldsDef$fields === void 0 ? null : _fieldsDef$fields,
|
|
309
533
|
_fieldsDef$settings = fieldsDef.settings,
|
|
310
534
|
settings = _fieldsDef$settings === void 0 ? null : _fieldsDef$settings,
|
|
311
535
|
_fieldsDef$itemsField = fieldsDef.itemsField,
|
|
312
|
-
|
|
536
|
+
defItemsField = _fieldsDef$itemsField === void 0 ? null : _fieldsDef$itemsField;
|
|
537
|
+
var itemsField = currentItemsField || defItemsField;
|
|
538
|
+
var subFields = currentSubFields || defSubFields;
|
|
313
539
|
var currentSubfields = subFields !== null ? getFieldByName(subFields, key) : null;
|
|
314
540
|
var currentSettings = settings !== null ? getFieldByName(settings, key) : null;
|
|
315
541
|
var isCurrentSubfields = currentSubfields !== null;
|
|
316
542
|
var isCurrentSettings = currentSettings !== null;
|
|
317
543
|
var isListItems = itemsField !== null && !!key.match(/^[0-9]+$/);
|
|
318
544
|
var isLastIndex = keyIndex === lastKeyIndex;
|
|
319
|
-
var pathPrefix =
|
|
545
|
+
var pathPrefix = route('screen.field', {
|
|
546
|
+
screen: screenId,
|
|
547
|
+
field: [currentState !== null ? currentState.id : null].concat(_toConsumableArray(finalFieldPath.slice(0, keyIndex + 1))).filter(function (it) {
|
|
548
|
+
return it !== null;
|
|
549
|
+
})
|
|
550
|
+
});
|
|
320
551
|
var pathSuffix = isLastIndex && form !== null ? "/".concat(form) : '';
|
|
321
552
|
var addNewItem = isLastIndex || isListItems;
|
|
322
553
|
var itemPath = "".concat(pathPrefix).concat(pathSuffix);
|
|
@@ -329,7 +560,13 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
329
560
|
|
|
330
561
|
if (parentItem !== null) {
|
|
331
562
|
fieldItems.push(_objectSpread(_objectSpread({}, parentItem), {}, {
|
|
332
|
-
url:
|
|
563
|
+
url: route('screen.field.form', {
|
|
564
|
+
screen: screenId,
|
|
565
|
+
field: [currentState !== null ? currentState.id : null].concat(_toConsumableArray(finalFieldPath.slice(0, keyIndex))).filter(function (it) {
|
|
566
|
+
return it !== null;
|
|
567
|
+
}),
|
|
568
|
+
form: 'settings'
|
|
569
|
+
})
|
|
333
570
|
}));
|
|
334
571
|
}
|
|
335
572
|
} else if (isListItems) {
|
|
@@ -339,9 +576,9 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
339
576
|
var fieldLabel = nextFields ? nextFields.breadcrumbLabel || nextFields.label : null;
|
|
340
577
|
var itemLabel = isMessage(fieldLabel) ? intl.formatMessage(fieldLabel) : fieldLabel;
|
|
341
578
|
|
|
342
|
-
var
|
|
343
|
-
|
|
344
|
-
parentItemLabel =
|
|
579
|
+
var _ref5 = parentItem || {},
|
|
580
|
+
_ref5$label = _ref5.label,
|
|
581
|
+
parentItemLabel = _ref5$label === void 0 ? null : _ref5$label;
|
|
345
582
|
|
|
346
583
|
var finalItemLabel = isListItems ? "".concat(itemLabel, " #").concat(parseInt(key, 10) + 1) : itemLabel || parentItemLabel;
|
|
347
584
|
var item = {
|
|
@@ -357,21 +594,26 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
357
594
|
parentItem = item;
|
|
358
595
|
return nextFields;
|
|
359
596
|
}, {
|
|
360
|
-
fields:
|
|
597
|
+
fields: screenFields
|
|
361
598
|
});
|
|
362
599
|
}
|
|
363
600
|
|
|
364
|
-
var finalItems = [{
|
|
365
|
-
label: intl.formatMessage({
|
|
601
|
+
var finalItems = [currentState === null || (currentState.repeatable || false) === false ? {
|
|
602
|
+
label: currentState !== null ? currentState.label : intl.formatMessage({
|
|
366
603
|
id: "AHvHaY",
|
|
367
604
|
defaultMessage: [{
|
|
368
605
|
"type": 0,
|
|
369
606
|
"value": "Parameters"
|
|
370
607
|
}]
|
|
371
608
|
}),
|
|
372
|
-
url:
|
|
609
|
+
url: currentState !== null ? route('screen.field', {
|
|
610
|
+
screen: screenId,
|
|
611
|
+
field: currentState.id
|
|
612
|
+
}) : route('screen', {
|
|
613
|
+
screen: screenId
|
|
614
|
+
}),
|
|
373
615
|
active: false
|
|
374
|
-
}].concat(fieldItems).filter(function (it) {
|
|
616
|
+
} : null].concat(fieldItems).filter(function (it) {
|
|
375
617
|
return it !== null;
|
|
376
618
|
});
|
|
377
619
|
var lastItemsIndex = finalItems.length - 1;
|
|
@@ -381,7 +623,7 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
381
623
|
active: true
|
|
382
624
|
}) : it;
|
|
383
625
|
});
|
|
384
|
-
}, [intl,
|
|
626
|
+
}, [intl, route, screenId, field, form, url, screenFields, screenStates, fieldsManager]);
|
|
385
627
|
var itemsLength = items.length;
|
|
386
628
|
var onClickBack = useCallback(function () {
|
|
387
629
|
history.push(items[itemsLength - 2].url);
|
|
@@ -389,110 +631,27 @@ var Breadcrumb = function Breadcrumb(_ref) {
|
|
|
389
631
|
var withBack = itemsLength > 1;
|
|
390
632
|
return /*#__PURE__*/React.createElement(React.Fragment, null, withBack ? /*#__PURE__*/React.createElement(BackButton, {
|
|
391
633
|
onClick: onClickBack,
|
|
392
|
-
className: "
|
|
634
|
+
className: "me-2 py-0"
|
|
393
635
|
}) : null, /*#__PURE__*/React.createElement(Breadcrumb$1, {
|
|
394
636
|
items: items,
|
|
395
637
|
theme: "secondary",
|
|
396
638
|
withoutBar: true,
|
|
397
639
|
noWrap: true,
|
|
398
|
-
className: classNames([styles$
|
|
640
|
+
className: classNames([styles$f.container, 'text-truncate', _defineProperty({}, className, className !== null)])
|
|
399
641
|
}));
|
|
400
642
|
};
|
|
401
643
|
|
|
402
|
-
Breadcrumb.propTypes = propTypes$
|
|
403
|
-
Breadcrumb.defaultProps = defaultProps$
|
|
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
|
-
};
|
|
644
|
+
Breadcrumb.propTypes = propTypes$l;
|
|
645
|
+
Breadcrumb.defaultProps = defaultProps$l;
|
|
421
646
|
|
|
422
|
-
var
|
|
423
|
-
var value = _ref.value,
|
|
424
|
-
className = _ref.className,
|
|
425
|
-
gotoFieldForm = _ref.gotoFieldForm,
|
|
426
|
-
closeFieldForm = _ref.closeFieldForm,
|
|
427
|
-
onChange = _ref.onChange;
|
|
647
|
+
var styles$e = {"container":"micromag-editor-modals-delete-screen-container","description":"micromag-editor-modals-delete-screen-description","actions":"micromag-editor-modals-delete-screen-actions"};
|
|
428
648
|
|
|
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]);
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
448
|
-
className: classNames([styles$d.container, _defineProperty({}, className, className)])
|
|
449
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
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
|
|
457
|
-
})));
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
ScreenForm.propTypes = propTypes$l;
|
|
461
|
-
ScreenForm.defaultProps = defaultProps$l;
|
|
462
|
-
|
|
463
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
464
649
|
var propTypes$k = {
|
|
465
|
-
children: PropTypes.node
|
|
466
|
-
};
|
|
467
|
-
var defaultProps$k = {
|
|
468
|
-
children: null
|
|
469
|
-
};
|
|
470
|
-
|
|
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 = {
|
|
491
650
|
className: PropTypes.string,
|
|
492
651
|
onConfirm: PropTypes.func,
|
|
493
652
|
onCancel: PropTypes.func
|
|
494
653
|
};
|
|
495
|
-
var defaultProps$
|
|
654
|
+
var defaultProps$k = {
|
|
496
655
|
className: null,
|
|
497
656
|
onConfirm: null,
|
|
498
657
|
onCancel: null
|
|
@@ -510,10 +669,10 @@ var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
|
510
669
|
"value": "Delete screen"
|
|
511
670
|
}]
|
|
512
671
|
}),
|
|
513
|
-
className: classNames([styles$
|
|
672
|
+
className: classNames([styles$e.container, _defineProperty({}, className, className)]),
|
|
514
673
|
onClickClose: onCancel
|
|
515
674
|
}, /*#__PURE__*/React.createElement("div", {
|
|
516
|
-
className: styles$
|
|
675
|
+
className: styles$e.description
|
|
517
676
|
}, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
518
677
|
id: "q/tLk0",
|
|
519
678
|
defaultMessage: [{
|
|
@@ -521,10 +680,10 @@ var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
|
521
680
|
"value": "Are you sure you want to delete this screen?"
|
|
522
681
|
}]
|
|
523
682
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
524
|
-
className: styles$
|
|
683
|
+
className: styles$e.actions
|
|
525
684
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
526
685
|
onClick: onCancel,
|
|
527
|
-
className: "btn-outline-secondary
|
|
686
|
+
className: "btn-outline-secondary me-2"
|
|
528
687
|
}, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
529
688
|
id: "0GT0SI",
|
|
530
689
|
defaultMessage: [{
|
|
@@ -544,18 +703,16 @@ var DeleteScreenModal = function DeleteScreenModal(_ref) {
|
|
|
544
703
|
}))));
|
|
545
704
|
};
|
|
546
705
|
|
|
547
|
-
DeleteScreenModal.propTypes = propTypes$
|
|
548
|
-
DeleteScreenModal.defaultProps = defaultProps$
|
|
706
|
+
DeleteScreenModal.propTypes = propTypes$k;
|
|
707
|
+
DeleteScreenModal.defaultProps = defaultProps$k;
|
|
549
708
|
|
|
550
|
-
var
|
|
551
|
-
|
|
552
|
-
var propTypes$i = {
|
|
709
|
+
var propTypes$j = {
|
|
553
710
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
554
711
|
isTheme: PropTypes.bool,
|
|
555
712
|
className: PropTypes.string,
|
|
556
713
|
onChange: PropTypes.func
|
|
557
714
|
};
|
|
558
|
-
var defaultProps$
|
|
715
|
+
var defaultProps$j = {
|
|
559
716
|
value: null,
|
|
560
717
|
isTheme: false,
|
|
561
718
|
className: null,
|
|
@@ -588,10 +745,18 @@ var EditForm = function EditForm(_ref) {
|
|
|
588
745
|
var screenIndex = screens.findIndex(function (it) {
|
|
589
746
|
return it.id === screenId;
|
|
590
747
|
});
|
|
591
|
-
var screen = screenIndex !== -1 ? screens[screenIndex] : null;
|
|
748
|
+
var screen = screenIndex !== -1 ? screens[screenIndex] : null;
|
|
749
|
+
var screensManager = useScreensManager();
|
|
750
|
+
var screenFields = useMemo(function () {
|
|
751
|
+
var _ref3 = screen || {},
|
|
752
|
+
type = _ref3.type;
|
|
753
|
+
|
|
754
|
+
var definition = type !== null ? screensManager.getDefinition(type) : null;
|
|
755
|
+
return definition != null ? getScreenFieldsWithStates(definition) : [];
|
|
756
|
+
}, [screensManager, screen]); // Get transition value
|
|
592
757
|
|
|
593
|
-
var _useFormTransition = useFormTransition(url, screenIndex, styles$
|
|
594
|
-
|
|
758
|
+
var _useFormTransition = useFormTransition(url, screenIndex, styles$h),
|
|
759
|
+
transitionClassNames = _useFormTransition.classNames,
|
|
595
760
|
transitionTimeout = _useFormTransition.timeout;
|
|
596
761
|
|
|
597
762
|
var _useState = useState(false),
|
|
@@ -621,14 +786,29 @@ var EditForm = function EditForm(_ref) {
|
|
|
621
786
|
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
622
787
|
var hasField = field !== null;
|
|
623
788
|
var fieldRoute = formName !== null ? 'screen.field.form' : 'screen.field';
|
|
789
|
+
|
|
790
|
+
var _ref4 = field !== null ? field.split('.') : [],
|
|
791
|
+
_ref5 = _slicedToArray(_ref4, 1),
|
|
792
|
+
_ref5$ = _ref5[0],
|
|
793
|
+
rootFieldName = _ref5$ === void 0 ? null : _ref5$;
|
|
794
|
+
|
|
795
|
+
var _ref6 = (rootFieldName !== null ? screenFields.find(function (_ref7) {
|
|
796
|
+
var name = _ref7.name;
|
|
797
|
+
return name === rootFieldName;
|
|
798
|
+
}) || null : null) || {},
|
|
799
|
+
_ref6$stateId = _ref6.stateId,
|
|
800
|
+
stateId = _ref6$stateId === void 0 ? null : _ref6$stateId;
|
|
801
|
+
|
|
624
802
|
routePush(hasField ? fieldRoute : 'screen', {
|
|
625
803
|
screen: screenId,
|
|
626
|
-
field: field !== null ? field.split('.')
|
|
804
|
+
field: field !== null ? [stateId].concat(_toConsumableArray(field.split('.'))).filter(function (it) {
|
|
805
|
+
return it !== null;
|
|
806
|
+
}) : null,
|
|
627
807
|
form: formName !== null ? slug(formName) : null
|
|
628
808
|
});
|
|
629
809
|
setFieldForms(_objectSpread(_objectSpread({}, fieldForms), {}, _defineProperty({}, "".concat(field).concat(formName !== null ? ":".concat(formName) : ''), url)));
|
|
630
810
|
setFieldContext(context);
|
|
631
|
-
}, [routePush, screenId, url, fieldForms, setFieldForms, fieldContext, setFieldContext]);
|
|
811
|
+
}, [routePush, screenId, screenFields, url, fieldForms, setFieldForms, fieldContext, setFieldContext]);
|
|
632
812
|
var closeFieldForm = useCallback(function (field) {
|
|
633
813
|
var formName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
634
814
|
var fieldKey = "".concat(field).concat(formName !== null ? ":".concat(formName) : '');
|
|
@@ -676,7 +856,6 @@ var EditForm = function EditForm(_ref) {
|
|
|
676
856
|
var dropdownItems = [!isTheme ? {
|
|
677
857
|
id: 'duplicate',
|
|
678
858
|
type: 'button',
|
|
679
|
-
className: 'text-left text-info',
|
|
680
859
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
681
860
|
id: "IBjY5r",
|
|
682
861
|
defaultMessage: [{
|
|
@@ -688,7 +867,6 @@ var EditForm = function EditForm(_ref) {
|
|
|
688
867
|
} : null, {
|
|
689
868
|
id: 'delete',
|
|
690
869
|
type: 'button',
|
|
691
|
-
className: 'text-left text-danger',
|
|
692
870
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
693
871
|
id: "hpiKce",
|
|
694
872
|
defaultMessage: [{
|
|
@@ -706,54 +884,67 @@ var EditForm = function EditForm(_ref) {
|
|
|
706
884
|
compact: true,
|
|
707
885
|
noWrap: true,
|
|
708
886
|
withoutCollapse: true,
|
|
709
|
-
className: classNames(['sticky-top', 'border-bottom', 'border-dark', styles$
|
|
887
|
+
className: classNames(['sticky-top', 'border-bottom', 'border-dark', styles$h.navbar])
|
|
710
888
|
}, /*#__PURE__*/React.createElement(Breadcrumb, {
|
|
711
889
|
story: value,
|
|
712
890
|
url: url,
|
|
713
891
|
screenId: screenId,
|
|
714
892
|
field: fieldParams,
|
|
715
893
|
form: formParams,
|
|
716
|
-
className: "
|
|
717
|
-
}), fieldParams === null ? /*#__PURE__*/React.createElement(
|
|
718
|
-
|
|
894
|
+
className: "me-auto"
|
|
895
|
+
}), fieldParams === null ? /*#__PURE__*/React.createElement("div", {
|
|
896
|
+
className: "dropdown"
|
|
897
|
+
}, /*#__PURE__*/React.createElement(SettingsButton, {
|
|
898
|
+
onClick: onSettingsClick,
|
|
899
|
+
dots: true,
|
|
900
|
+
className: "py-0",
|
|
901
|
+
theme: "default"
|
|
719
902
|
}), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
903
|
+
align: "end",
|
|
720
904
|
items: dropdownItems,
|
|
721
905
|
visible: screenSettingsOpened,
|
|
722
|
-
align: "right",
|
|
723
906
|
onClickOutside: onDropdownClickOutside
|
|
724
907
|
})) : null) : null, /*#__PURE__*/React.createElement("div", {
|
|
725
|
-
className: classNames(['flex-grow-1', 'd-flex', 'w-100', styles$
|
|
726
|
-
}, screen !== null ? /*#__PURE__*/React.createElement(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
908
|
+
className: classNames(['flex-grow-1', 'd-flex', 'w-100', styles$h.content])
|
|
909
|
+
}, screen !== null ? /*#__PURE__*/React.createElement(TransitionGroup, {
|
|
910
|
+
className: "w-100 flex-grow-1",
|
|
911
|
+
childFactory: function childFactory(child) {
|
|
912
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
913
|
+
classNames: transitionClassNames
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
}, fieldParams !== null ? /*#__PURE__*/React.createElement(CSSTransition, {
|
|
917
|
+
timeout: transitionTimeout,
|
|
733
918
|
key: "field-".concat(fieldParams, "-").concat(formParams)
|
|
919
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
920
|
+
className: classNames(['w-100', styles$h.panel])
|
|
734
921
|
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
735
922
|
data: screen
|
|
736
923
|
}, /*#__PURE__*/React.createElement(FieldWithContexts, {
|
|
737
924
|
name: fieldParams.replace(/\//g, '.'),
|
|
738
925
|
value: screen,
|
|
739
926
|
form: formParams,
|
|
740
|
-
className: styles$
|
|
927
|
+
className: styles$h.form,
|
|
741
928
|
gotoFieldForm: gotoFieldForm,
|
|
742
929
|
closeFieldForm: closeFieldForm,
|
|
743
930
|
fieldContext: fieldContext,
|
|
744
931
|
onChange: onScreenFormChange
|
|
745
|
-
}))) : /*#__PURE__*/React.createElement(
|
|
746
|
-
|
|
932
|
+
})))) : /*#__PURE__*/React.createElement(CSSTransition, {
|
|
933
|
+
classNames: transitionClassNames,
|
|
934
|
+
timeout: transitionTimeout,
|
|
935
|
+
key: "screen-".concat(screen.id)
|
|
936
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
937
|
+
className: classNames(['w-100', styles$h.panel]),
|
|
747
938
|
key: "screen-".concat(screen.id)
|
|
748
939
|
}, /*#__PURE__*/React.createElement(ScreenProvider, {
|
|
749
940
|
data: screen
|
|
750
941
|
}, /*#__PURE__*/React.createElement(ScreenForm, {
|
|
751
942
|
value: screen,
|
|
752
|
-
className: styles$
|
|
943
|
+
className: styles$h.form,
|
|
753
944
|
onChange: onScreenFormChange,
|
|
754
945
|
gotoFieldForm: gotoFieldForm,
|
|
755
946
|
closeFieldForm: closeFieldForm
|
|
756
|
-
})))) : /*#__PURE__*/React.createElement(Empty, {
|
|
947
|
+
}))))) : /*#__PURE__*/React.createElement(Empty, {
|
|
757
948
|
className: "w-100 m-2"
|
|
758
949
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
759
950
|
id: "QfpTKK",
|
|
@@ -768,8 +959,25 @@ var EditForm = function EditForm(_ref) {
|
|
|
768
959
|
}) : null);
|
|
769
960
|
};
|
|
770
961
|
|
|
771
|
-
EditForm.propTypes = propTypes$
|
|
772
|
-
EditForm.defaultProps = defaultProps$
|
|
962
|
+
EditForm.propTypes = propTypes$j;
|
|
963
|
+
EditForm.defaultProps = defaultProps$j;
|
|
964
|
+
|
|
965
|
+
function useScreenStates(screen) {
|
|
966
|
+
var _ref = screen || {},
|
|
967
|
+
type = _ref.type;
|
|
968
|
+
|
|
969
|
+
var screensManager = useScreensManager();
|
|
970
|
+
var states = useMemo(function () {
|
|
971
|
+
var definition = screensManager.getDefinition(type) || null;
|
|
972
|
+
|
|
973
|
+
var _ref2 = definition || {},
|
|
974
|
+
_ref2$states = _ref2.states,
|
|
975
|
+
screenStates = _ref2$states === void 0 ? null : _ref2$states;
|
|
976
|
+
|
|
977
|
+
return screenStates;
|
|
978
|
+
}, [screensManager, type]);
|
|
979
|
+
return states;
|
|
980
|
+
}
|
|
773
981
|
|
|
774
982
|
var _excluded$7 = ["components"];
|
|
775
983
|
|
|
@@ -791,14 +999,16 @@ var useThemeValue = function useThemeValue(value) {
|
|
|
791
999
|
return valueWithTheme;
|
|
792
1000
|
};
|
|
793
1001
|
|
|
794
|
-
var styles$
|
|
1002
|
+
var styles$d = {"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"};
|
|
1003
|
+
|
|
1004
|
+
var styles$c = {"container":"micromag-editor-menus-devices-container","button":"micromag-editor-menus-devices-button"};
|
|
795
1005
|
|
|
796
1006
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
797
|
-
var propTypes$
|
|
1007
|
+
var propTypes$i = {
|
|
798
1008
|
color: PropTypes.string,
|
|
799
1009
|
className: PropTypes.string
|
|
800
1010
|
};
|
|
801
|
-
var defaultProps$
|
|
1011
|
+
var defaultProps$i = {
|
|
802
1012
|
color: 'currentColor',
|
|
803
1013
|
className: null
|
|
804
1014
|
};
|
|
@@ -823,15 +1033,15 @@ var DesktopIcon = function DesktopIcon(_ref) {
|
|
|
823
1033
|
}));
|
|
824
1034
|
};
|
|
825
1035
|
|
|
826
|
-
DesktopIcon.propTypes = propTypes$
|
|
827
|
-
DesktopIcon.defaultProps = defaultProps$
|
|
1036
|
+
DesktopIcon.propTypes = propTypes$i;
|
|
1037
|
+
DesktopIcon.defaultProps = defaultProps$i;
|
|
828
1038
|
|
|
829
1039
|
/* eslint-disable react/button-has-type, react/jsx-props-no-spreading */
|
|
830
|
-
var propTypes$
|
|
1040
|
+
var propTypes$h = {
|
|
831
1041
|
color: PropTypes.string,
|
|
832
1042
|
className: PropTypes.string
|
|
833
1043
|
};
|
|
834
|
-
var defaultProps$
|
|
1044
|
+
var defaultProps$h = {
|
|
835
1045
|
color: 'currentColor',
|
|
836
1046
|
className: null
|
|
837
1047
|
};
|
|
@@ -856,8 +1066,8 @@ var MobileIcon = function MobileIcon(_ref) {
|
|
|
856
1066
|
}));
|
|
857
1067
|
};
|
|
858
1068
|
|
|
859
|
-
MobileIcon.propTypes = propTypes$
|
|
860
|
-
MobileIcon.defaultProps = defaultProps$
|
|
1069
|
+
MobileIcon.propTypes = propTypes$h;
|
|
1070
|
+
MobileIcon.defaultProps = defaultProps$h;
|
|
861
1071
|
|
|
862
1072
|
var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
863
1073
|
__proto__: null,
|
|
@@ -865,78 +1075,418 @@ var DeviceIcons = /*#__PURE__*/Object.freeze({
|
|
|
865
1075
|
Mobile: MobileIcon
|
|
866
1076
|
});
|
|
867
1077
|
|
|
868
|
-
var styles$
|
|
1078
|
+
var styles$b = {"container":"micromag-editor-buttons-device-container","icon":"micromag-editor-buttons-device-icon"};
|
|
869
1079
|
|
|
870
1080
|
var _excluded$6 = ["device", "className", "iconComponents"];
|
|
871
|
-
var propTypes$
|
|
1081
|
+
var propTypes$g = {
|
|
872
1082
|
device: PropTypes.string.isRequired,
|
|
873
1083
|
iconComponents: PropTypes$1.components,
|
|
874
1084
|
className: PropTypes.string
|
|
875
1085
|
};
|
|
876
|
-
var defaultProps$
|
|
1086
|
+
var defaultProps$g = {
|
|
877
1087
|
iconComponents: DeviceIcons,
|
|
878
1088
|
className: null
|
|
879
1089
|
};
|
|
880
1090
|
|
|
881
|
-
var DeviceButton = function DeviceButton(_ref) {
|
|
882
|
-
var device = _ref.device,
|
|
883
|
-
className = _ref.className,
|
|
884
|
-
iconComponents = _ref.iconComponents,
|
|
885
|
-
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
1091
|
+
var DeviceButton = function DeviceButton(_ref) {
|
|
1092
|
+
var device = _ref.device,
|
|
1093
|
+
className = _ref.className,
|
|
1094
|
+
iconComponents = _ref.iconComponents,
|
|
1095
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
1096
|
+
|
|
1097
|
+
var DeviceIcon = getComponentFromName(device, iconComponents, DesktopIcon);
|
|
1098
|
+
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
1099
|
+
className: classNames([styles$b.container, _defineProperty({}, className, className !== null)])
|
|
1100
|
+
}, props), /*#__PURE__*/React.createElement(DeviceIcon, {
|
|
1101
|
+
className: styles$b.icon
|
|
1102
|
+
}));
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
DeviceButton.propTypes = propTypes$g;
|
|
1106
|
+
DeviceButton.defaultProps = defaultProps$g;
|
|
1107
|
+
|
|
1108
|
+
var _excluded$5 = ["id"];
|
|
1109
|
+
var propTypes$f = {
|
|
1110
|
+
items: PropTypes$1.menuItems,
|
|
1111
|
+
className: PropTypes.string,
|
|
1112
|
+
onClickItem: PropTypes.func
|
|
1113
|
+
};
|
|
1114
|
+
var defaultProps$f = {
|
|
1115
|
+
items: [],
|
|
1116
|
+
className: null,
|
|
1117
|
+
onClickItem: null
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
var DevicesMenu = function DevicesMenu(_ref) {
|
|
1121
|
+
var items = _ref.items,
|
|
1122
|
+
className = _ref.className,
|
|
1123
|
+
onClickItem = _ref.onClickItem;
|
|
1124
|
+
return /*#__PURE__*/React.createElement(Tabs, {
|
|
1125
|
+
items: items,
|
|
1126
|
+
theme: "outline-secondary",
|
|
1127
|
+
className: classNames([styles$c.container, _defineProperty({}, className, className !== null)]),
|
|
1128
|
+
renderItemButton: function renderItemButton(item, index, props) {
|
|
1129
|
+
var id = item.id,
|
|
1130
|
+
itemProps = _objectWithoutProperties(item, _excluded$5);
|
|
1131
|
+
|
|
1132
|
+
return /*#__PURE__*/React.createElement(DeviceButton, Object.assign({
|
|
1133
|
+
device: id
|
|
1134
|
+
}, props, itemProps, {
|
|
1135
|
+
className: styles$c.button,
|
|
1136
|
+
onClick: function onClick(e) {
|
|
1137
|
+
return onClickItem !== null ? onClickItem(e, item, index) : null;
|
|
1138
|
+
}
|
|
1139
|
+
}));
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
DevicesMenu.propTypes = propTypes$f;
|
|
1145
|
+
DevicesMenu.defaultProps = defaultProps$f;
|
|
1146
|
+
|
|
1147
|
+
var styles$a = {"button":"micromag-editor-partials-screen-states-button","addButton":"micromag-editor-partials-screen-states-addButton","title":"micromag-editor-partials-screen-states-title"};
|
|
1148
|
+
|
|
1149
|
+
var styles$9 = {"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","frame":"micromag-editor-buttons-screen-with-preview-frame"};
|
|
1150
|
+
|
|
1151
|
+
var styles$8 = {"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"};
|
|
1152
|
+
|
|
1153
|
+
var propTypes$e = {
|
|
1154
|
+
active: PropTypes.bool,
|
|
1155
|
+
id: PropTypes.string,
|
|
1156
|
+
href: PropTypes.string,
|
|
1157
|
+
label: PropTypes$1.label,
|
|
1158
|
+
icon: PropTypes.node,
|
|
1159
|
+
title: PropTypes.string,
|
|
1160
|
+
onClick: PropTypes.func,
|
|
1161
|
+
children: PropTypes.node,
|
|
1162
|
+
refButton: PropTypes.shape({
|
|
1163
|
+
current: PropTypes.any // eslint-disable-line
|
|
1164
|
+
|
|
1165
|
+
}),
|
|
1166
|
+
className: PropTypes.string
|
|
1167
|
+
};
|
|
1168
|
+
var defaultProps$e = {
|
|
1169
|
+
active: false,
|
|
1170
|
+
id: null,
|
|
1171
|
+
href: null,
|
|
1172
|
+
label: null,
|
|
1173
|
+
icon: null,
|
|
1174
|
+
title: null,
|
|
1175
|
+
onClick: null,
|
|
1176
|
+
children: null,
|
|
1177
|
+
refButton: null,
|
|
1178
|
+
className: null
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
var ScreenButton = function ScreenButton(_ref) {
|
|
1182
|
+
var _ref2;
|
|
1183
|
+
|
|
1184
|
+
var active = _ref.active,
|
|
1185
|
+
id = _ref.id,
|
|
1186
|
+
href = _ref.href,
|
|
1187
|
+
className = _ref.className,
|
|
1188
|
+
label = _ref.label,
|
|
1189
|
+
icon = _ref.icon,
|
|
1190
|
+
children = _ref.children,
|
|
1191
|
+
title = _ref.title,
|
|
1192
|
+
onClick = _ref.onClick,
|
|
1193
|
+
refButton = _ref.refButton;
|
|
1194
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1195
|
+
className: classNames([styles$8.container, 'rounded', (_ref2 = {}, _defineProperty(_ref2, styles$8.active, active), _defineProperty(_ref2, className, className !== null), _ref2)])
|
|
1196
|
+
}, children !== null ? children : /*#__PURE__*/React.createElement("div", {
|
|
1197
|
+
className: styles$8.screen
|
|
1198
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1199
|
+
className: styles$8.inner
|
|
1200
|
+
}, icon !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1201
|
+
className: styles$8.icon
|
|
1202
|
+
}, icon) : null, label !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1203
|
+
className: styles$8.label
|
|
1204
|
+
}, label) : null)), /*#__PURE__*/React.createElement(Button, {
|
|
1205
|
+
className: styles$8.button,
|
|
1206
|
+
withoutStyle: true,
|
|
1207
|
+
id: id,
|
|
1208
|
+
href: href,
|
|
1209
|
+
title: title,
|
|
1210
|
+
onClick: onClick,
|
|
1211
|
+
refButton: refButton
|
|
1212
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1213
|
+
className: classNames([styles$8.border, 'rounded'])
|
|
1214
|
+
})));
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
ScreenButton.propTypes = propTypes$e;
|
|
1218
|
+
ScreenButton.defaultProps = defaultProps$e;
|
|
1219
|
+
var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
1220
|
+
return /*#__PURE__*/React.createElement(ScreenButton, Object.assign({}, props, {
|
|
1221
|
+
refButton: ref
|
|
1222
|
+
}));
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
var propTypes$d = {
|
|
1226
|
+
screen: PropTypes$1.screenComponent,
|
|
1227
|
+
screenState: PropTypes.string,
|
|
1228
|
+
index: PropTypes.number.isRequired,
|
|
1229
|
+
href: PropTypes.string,
|
|
1230
|
+
title: PropTypes.string,
|
|
1231
|
+
active: PropTypes.bool,
|
|
1232
|
+
previewWidth: PropTypes.number,
|
|
1233
|
+
previewHeight: PropTypes.number,
|
|
1234
|
+
withPreview: PropTypes.bool,
|
|
1235
|
+
withPlaceholder: PropTypes.bool,
|
|
1236
|
+
onClick: PropTypes.func,
|
|
1237
|
+
onClickItem: PropTypes.func,
|
|
1238
|
+
className: PropTypes.string
|
|
1239
|
+
};
|
|
1240
|
+
var defaultProps$d = {
|
|
1241
|
+
screen: null,
|
|
1242
|
+
screenState: null,
|
|
1243
|
+
title: null,
|
|
1244
|
+
href: null,
|
|
1245
|
+
active: false,
|
|
1246
|
+
previewWidth: 320,
|
|
1247
|
+
previewHeight: 480,
|
|
1248
|
+
withPreview: true,
|
|
1249
|
+
withPlaceholder: false,
|
|
1250
|
+
onClick: null,
|
|
1251
|
+
onClickItem: null,
|
|
1252
|
+
className: null
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
var ScreenWithPreview = function ScreenWithPreview(_ref) {
|
|
1256
|
+
var _classNames;
|
|
1257
|
+
|
|
1258
|
+
var screen = _ref.screen,
|
|
1259
|
+
screenState = _ref.screenState,
|
|
1260
|
+
index = _ref.index,
|
|
1261
|
+
title = _ref.title,
|
|
1262
|
+
href = _ref.href,
|
|
1263
|
+
active = _ref.active,
|
|
1264
|
+
className = _ref.className,
|
|
1265
|
+
previewWidth = _ref.previewWidth,
|
|
1266
|
+
previewHeight = _ref.previewHeight,
|
|
1267
|
+
_onClick = _ref.onClick,
|
|
1268
|
+
onClickItem = _ref.onClickItem,
|
|
1269
|
+
withPreview = _ref.withPreview,
|
|
1270
|
+
withPlaceholder = _ref.withPlaceholder;
|
|
1271
|
+
var intl = useIntl();
|
|
1272
|
+
|
|
1273
|
+
var _useResizeObserver = useResizeObserver(),
|
|
1274
|
+
refResize = _useResizeObserver.ref,
|
|
1275
|
+
contentRect = _useResizeObserver.entry.contentRect;
|
|
1276
|
+
|
|
1277
|
+
var _useMemo = useMemo(function () {
|
|
1278
|
+
var _ref2 = contentRect || {},
|
|
1279
|
+
_ref2$width = _ref2.width,
|
|
1280
|
+
itemWidth = _ref2$width === void 0 ? 0 : _ref2$width;
|
|
886
1281
|
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1282
|
+
var ratio = 3 / 4;
|
|
1283
|
+
var finalWidth = previewWidth;
|
|
1284
|
+
var finalHeight = previewHeight !== null ? previewHeight : previewWidth * ratio;
|
|
1285
|
+
var previewScale = itemWidth / previewWidth;
|
|
1286
|
+
return {
|
|
1287
|
+
width: itemWidth,
|
|
1288
|
+
height: finalHeight * previewScale,
|
|
1289
|
+
screenWidth: finalWidth,
|
|
1290
|
+
screenHeight: finalHeight,
|
|
1291
|
+
scale: previewScale
|
|
1292
|
+
};
|
|
1293
|
+
}, [withPlaceholder, previewWidth, previewHeight, contentRect]),
|
|
1294
|
+
width = _useMemo.width,
|
|
1295
|
+
height = _useMemo.height,
|
|
1296
|
+
screenWidth = _useMemo.screenWidth,
|
|
1297
|
+
screenHeight = _useMemo.screenHeight,
|
|
1298
|
+
scale = _useMemo.scale;
|
|
1299
|
+
|
|
1300
|
+
var ScreenComponent = withPlaceholder ? ScreenPlaceholder : ScreenPreview;
|
|
1301
|
+
return /*#__PURE__*/React.createElement(ScreenButton$1, {
|
|
1302
|
+
href: href,
|
|
1303
|
+
ref: refResize,
|
|
1304
|
+
active: active,
|
|
1305
|
+
className: classNames([styles$9.button, _defineProperty({}, className, className !== null)]),
|
|
1306
|
+
title: isMessage(title) ? intl.formatMessage(title) : null,
|
|
1307
|
+
onClick: function onClick() {
|
|
1308
|
+
if (_onClick !== null) {
|
|
1309
|
+
_onClick(screen, index);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
if (onClickItem !== null) {
|
|
1313
|
+
onClickItem(screen, index);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1317
|
+
className: styles$9.frame,
|
|
1318
|
+
style: {
|
|
1319
|
+
width: width,
|
|
1320
|
+
height: height
|
|
1321
|
+
}
|
|
1322
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1323
|
+
className: classNames((_classNames = {}, _defineProperty(_classNames, styles$9.preview, withPreview && !withPlaceholder), _defineProperty(_classNames, styles$9.placeholder, withPlaceholder && !withPreview), _classNames)),
|
|
1324
|
+
style: {
|
|
1325
|
+
width: withPlaceholder ? width : screenWidth,
|
|
1326
|
+
height: withPlaceholder ? height : screenHeight,
|
|
1327
|
+
transform: withPlaceholder ? null : "scale(".concat(scale, ")")
|
|
1328
|
+
}
|
|
1329
|
+
}, /*#__PURE__*/React.createElement(ScreenComponent, {
|
|
1330
|
+
screen: screen,
|
|
1331
|
+
screenState: screenState,
|
|
1332
|
+
width: withPlaceholder ? width : screenWidth,
|
|
1333
|
+
height: withPlaceholder ? height : screenHeight,
|
|
1334
|
+
className: styles$9.screen
|
|
1335
|
+
}))));
|
|
893
1336
|
};
|
|
894
1337
|
|
|
895
|
-
|
|
896
|
-
|
|
1338
|
+
ScreenWithPreview.propTypes = propTypes$d;
|
|
1339
|
+
ScreenWithPreview.defaultProps = defaultProps$d;
|
|
897
1340
|
|
|
898
|
-
var
|
|
899
|
-
|
|
900
|
-
|
|
1341
|
+
var propTypes$c = {
|
|
1342
|
+
screen: PropTypes$1.screen.isRequired,
|
|
1343
|
+
screenState: PropTypes.string,
|
|
1344
|
+
value: PropTypes$1.story.isRequired,
|
|
901
1345
|
className: PropTypes.string,
|
|
902
|
-
|
|
1346
|
+
onChange: PropTypes.func
|
|
903
1347
|
};
|
|
904
|
-
var defaultProps$
|
|
905
|
-
|
|
1348
|
+
var defaultProps$c = {
|
|
1349
|
+
screenState: null,
|
|
906
1350
|
className: null,
|
|
907
|
-
|
|
1351
|
+
onChange: null
|
|
908
1352
|
};
|
|
909
1353
|
|
|
910
|
-
|
|
911
|
-
var
|
|
1354
|
+
function ScreenStates(_ref) {
|
|
1355
|
+
var screen = _ref.screen,
|
|
1356
|
+
value = _ref.value,
|
|
912
1357
|
className = _ref.className,
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
theme: "outline-secondary",
|
|
917
|
-
className: classNames([styles$a.container, _defineProperty({}, className, className !== null)]),
|
|
918
|
-
renderItemButton: function renderItemButton(item, index, props) {
|
|
919
|
-
var id = item.id,
|
|
920
|
-
itemProps = _objectWithoutProperties(item, _excluded$5);
|
|
1358
|
+
onChange = _ref.onChange;
|
|
1359
|
+
var url = useUrlGenerator();
|
|
1360
|
+
var push = useRoutePush();
|
|
921
1361
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1362
|
+
var _useRouteParams = useRouteParams(),
|
|
1363
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
1364
|
+
screenParam = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
1365
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
1366
|
+
field = _useRouteParams$field === void 0 ? null : _useRouteParams$field;
|
|
1367
|
+
|
|
1368
|
+
var states = useScreenStates(screen);
|
|
1369
|
+
|
|
1370
|
+
var _ref2 = field !== null ? field.split('/') : [],
|
|
1371
|
+
_ref3 = _toArray(_ref2),
|
|
1372
|
+
_ref3$ = _ref3[0],
|
|
1373
|
+
stateParam = _ref3$ === void 0 ? null : _ref3$,
|
|
1374
|
+
stateIndexes = _ref3.slice(1);
|
|
1375
|
+
|
|
1376
|
+
var stateIndex = stateIndexes.find(function (it) {
|
|
1377
|
+
return it.match(/^[0-9]+$/) !== null;
|
|
1378
|
+
}) || null;
|
|
1379
|
+
var currentState = stateParam !== null && states.findIndex(function (_ref4) {
|
|
1380
|
+
var id = _ref4.id;
|
|
1381
|
+
return id === stateParam;
|
|
1382
|
+
}) !== -1 ? stateParam : null;
|
|
1383
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1384
|
+
className: classNames([styles$a.container, _defineProperty({}, className, className !== null)])
|
|
1385
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1386
|
+
className: "d-flex align-items-end flex-wrap m-n1"
|
|
1387
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1388
|
+
className: "p-1 align-self-stretch d-flex flex-column"
|
|
1389
|
+
}, /*#__PURE__*/React.createElement("h6", {
|
|
1390
|
+
className: classNames(['fw-normal', 'invisible', styles$a.title])
|
|
1391
|
+
}, "Settings"), /*#__PURE__*/React.createElement(Button, {
|
|
1392
|
+
className: classNames([styles$a.button, 'p-0', 'flex-grow-1', 'justify-content-center']),
|
|
1393
|
+
theme: screenParam !== null && field === null ? 'primary' : 'secondary',
|
|
1394
|
+
outline: screenParam === null || field !== null,
|
|
1395
|
+
size: "lg",
|
|
1396
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1397
|
+
icon: faCogs
|
|
1398
|
+
}),
|
|
1399
|
+
href: url('screen', {
|
|
1400
|
+
screen: screen.id
|
|
1401
|
+
})
|
|
1402
|
+
})), states.map(function (state) {
|
|
1403
|
+
var id = state.id,
|
|
1404
|
+
_state$label = state.label,
|
|
1405
|
+
label = _state$label === void 0 ? null : _state$label,
|
|
1406
|
+
_state$repeatable = state.repeatable,
|
|
1407
|
+
repeatable = _state$repeatable === void 0 ? false : _state$repeatable,
|
|
1408
|
+
_state$fieldName = state.fieldName,
|
|
1409
|
+
fieldName = _state$fieldName === void 0 ? null : _state$fieldName;
|
|
1410
|
+
var repeatableItems = repeatable ? screen[fieldName || id] || [] : null;
|
|
1411
|
+
|
|
1412
|
+
var onClickAdd = function onClickAdd() {
|
|
1413
|
+
var _ref6 = value || {},
|
|
1414
|
+
_ref6$components = _ref6.components,
|
|
1415
|
+
currentComponentsValue = _ref6$components === void 0 ? [] : _ref6$components;
|
|
1416
|
+
|
|
1417
|
+
var currentScreenIndex = currentComponentsValue.findIndex(function (_ref7) {
|
|
1418
|
+
var screenId = _ref7.id;
|
|
1419
|
+
return screen.id === screenId;
|
|
1420
|
+
});
|
|
1421
|
+
var currentScreenValue = currentComponentsValue[currentScreenIndex] || {};
|
|
1422
|
+
var currentFieldValue = currentScreenValue[fieldName || id] || [];
|
|
1423
|
+
|
|
1424
|
+
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
1425
|
+
components: [].concat(_toConsumableArray(currentComponentsValue.slice(0, currentScreenIndex)), [_objectSpread(_objectSpread({}, currentScreenValue), {}, _defineProperty({}, fieldName || id, [].concat(_toConsumableArray(currentFieldValue), [{}])))], _toConsumableArray(currentComponentsValue.slice(currentScreenIndex + 1)))
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
if (onChange !== null) {
|
|
1429
|
+
onChange(newValue);
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
push('screen.field', {
|
|
1433
|
+
screen: screen.id,
|
|
1434
|
+
field: [id, currentFieldValue.length]
|
|
1435
|
+
});
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1439
|
+
className: "p-1 align-self-stretch d-flex flex-column"
|
|
1440
|
+
}, /*#__PURE__*/React.createElement("h6", {
|
|
1441
|
+
className: classNames(['fw-normal', 'text-muted', styles$a.title])
|
|
1442
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, label)), repeatable ? /*#__PURE__*/React.createElement("ul", {
|
|
1443
|
+
className: "d-flex list-unstyled flex-wrap m-n1 flex-grow-1"
|
|
1444
|
+
}, repeatableItems.map(function (item, index) {
|
|
1445
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
1446
|
+
className: "p-1"
|
|
1447
|
+
}, /*#__PURE__*/React.createElement(ScreenWithPreview, {
|
|
1448
|
+
screen: screen,
|
|
1449
|
+
screenState: "".concat(id, ".").concat(index),
|
|
925
1450
|
className: styles$a.button,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1451
|
+
active: currentState !== null && id === currentState.split('.')[0] && stateIndex !== null && parseInt(stateIndex, 10) === index,
|
|
1452
|
+
href: url('screen.field', {
|
|
1453
|
+
screen: screen.id,
|
|
1454
|
+
field: [id, index]
|
|
1455
|
+
})
|
|
929
1456
|
}));
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1457
|
+
}), /*#__PURE__*/React.createElement("li", {
|
|
1458
|
+
className: "p-1"
|
|
1459
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1460
|
+
className: classNames([styles$a.button, styles$a.addButton, 'h-100', 'p-0', 'justify-content-center']),
|
|
1461
|
+
theme: "secondary",
|
|
1462
|
+
outline: true,
|
|
1463
|
+
size: "lg",
|
|
1464
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1465
|
+
icon: faPlus
|
|
1466
|
+
}),
|
|
1467
|
+
onClick: onClickAdd
|
|
1468
|
+
}))) : /*#__PURE__*/React.createElement(ScreenWithPreview, {
|
|
1469
|
+
screen: screen,
|
|
1470
|
+
screenState: id,
|
|
1471
|
+
className: styles$a.button,
|
|
1472
|
+
active: id === currentState,
|
|
1473
|
+
href: url('screen.field', {
|
|
1474
|
+
screen: screen.id,
|
|
1475
|
+
field: id
|
|
1476
|
+
}) // onClick={() => {
|
|
1477
|
+
// if (onStateChange !== null) {
|
|
1478
|
+
// onStateChange(id);
|
|
1479
|
+
// }
|
|
1480
|
+
// }}
|
|
1481
|
+
|
|
1482
|
+
}));
|
|
1483
|
+
})));
|
|
1484
|
+
}
|
|
936
1485
|
|
|
937
|
-
|
|
1486
|
+
ScreenStates.propTypes = propTypes$c;
|
|
1487
|
+
ScreenStates.defaultProps = defaultProps$c;
|
|
938
1488
|
|
|
939
|
-
var propTypes$
|
|
1489
|
+
var propTypes$b = {
|
|
940
1490
|
value: PropTypes.oneOfType([PropTypes$1.story, PropTypes$1.theme]),
|
|
941
1491
|
devices: PropTypes$1.devices,
|
|
942
1492
|
device: PropTypes.string,
|
|
@@ -944,9 +1494,10 @@ var propTypes$d = {
|
|
|
944
1494
|
isTheme: PropTypes.bool,
|
|
945
1495
|
className: PropTypes.string,
|
|
946
1496
|
onScreenChange: PropTypes.func,
|
|
1497
|
+
onChange: PropTypes.func,
|
|
947
1498
|
withoutDevicesSizes: PropTypes.bool
|
|
948
1499
|
};
|
|
949
|
-
var defaultProps$
|
|
1500
|
+
var defaultProps$b = {
|
|
950
1501
|
value: null,
|
|
951
1502
|
devices: [{
|
|
952
1503
|
id: 'mobile',
|
|
@@ -957,16 +1508,17 @@ var defaultProps$d = {
|
|
|
957
1508
|
width: 1200,
|
|
958
1509
|
height: 900
|
|
959
1510
|
}],
|
|
960
|
-
device:
|
|
1511
|
+
device: 'mobile',
|
|
961
1512
|
viewerTheme: null,
|
|
962
1513
|
isTheme: false,
|
|
963
1514
|
className: null,
|
|
964
1515
|
onScreenChange: null,
|
|
965
|
-
|
|
1516
|
+
onChange: null,
|
|
1517
|
+
withoutDevicesSizes: true
|
|
966
1518
|
};
|
|
967
1519
|
|
|
968
1520
|
var EditorPreview = function EditorPreview(_ref) {
|
|
969
|
-
var
|
|
1521
|
+
var _ref9;
|
|
970
1522
|
|
|
971
1523
|
var value = _ref.value,
|
|
972
1524
|
viewerTheme = _ref.viewerTheme,
|
|
@@ -975,8 +1527,14 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
975
1527
|
initialDevice = _ref.device,
|
|
976
1528
|
className = _ref.className,
|
|
977
1529
|
onScreenChange = _ref.onScreenChange,
|
|
1530
|
+
onChange = _ref.onChange,
|
|
978
1531
|
withoutDevicesSizes = _ref.withoutDevicesSizes;
|
|
979
|
-
|
|
1532
|
+
|
|
1533
|
+
var _useRouteParams = useRouteParams(),
|
|
1534
|
+
_useRouteParams$scree = _useRouteParams.screen,
|
|
1535
|
+
screenId = _useRouteParams$scree === void 0 ? null : _useRouteParams$scree,
|
|
1536
|
+
_useRouteParams$field = _useRouteParams.field,
|
|
1537
|
+
fieldParam = _useRouteParams$field === void 0 ? null : _useRouteParams$field;
|
|
980
1538
|
|
|
981
1539
|
var _useScreenSize = useScreenSize(),
|
|
982
1540
|
_useScreenSize$screen = _useScreenSize.screen,
|
|
@@ -1010,7 +1568,7 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1010
1568
|
contentRect = _useResizeObserver.entry.contentRect;
|
|
1011
1569
|
|
|
1012
1570
|
var previewStyle = useMemo(function () {
|
|
1013
|
-
if (withoutDevicesSizes) {
|
|
1571
|
+
if (withoutDevicesSizes && initialDevice === null) {
|
|
1014
1572
|
return {};
|
|
1015
1573
|
}
|
|
1016
1574
|
|
|
@@ -1034,215 +1592,90 @@ var EditorPreview = function EditorPreview(_ref) {
|
|
|
1034
1592
|
height: maxHeight,
|
|
1035
1593
|
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")")
|
|
1036
1594
|
};
|
|
1037
|
-
}, [device, contentRect, screen, withoutDevicesSizes]);
|
|
1595
|
+
}, [device, contentRect, screen, withoutDevicesSizes, initialDevice]);
|
|
1596
|
+
var currentScreen = useMemo(function () {
|
|
1597
|
+
var _ref3 = valueParsed || {},
|
|
1598
|
+
_ref3$components = _ref3.components,
|
|
1599
|
+
components = _ref3$components === void 0 ? [] : _ref3$components;
|
|
1600
|
+
|
|
1601
|
+
return (screenId !== null ? components.find(function (_ref4) {
|
|
1602
|
+
var id = _ref4.id;
|
|
1603
|
+
return id === screenId;
|
|
1604
|
+
}) : components[0]) || null;
|
|
1605
|
+
}, [valueParsed, screenId]);
|
|
1606
|
+
var currentScreenStates = useScreenStates(currentScreen);
|
|
1607
|
+
|
|
1608
|
+
var _ref5 = fieldParam !== null && currentScreenStates !== null ? fieldParam.split('/') : [],
|
|
1609
|
+
_ref6 = _slicedToArray(_ref5, 1),
|
|
1610
|
+
_ref6$ = _ref6[0],
|
|
1611
|
+
screenStateParam = _ref6$ === void 0 ? null : _ref6$;
|
|
1612
|
+
|
|
1613
|
+
var currentScreenState = screenStateParam !== null ? currentScreenStates.find(function (_ref7) {
|
|
1614
|
+
var id = _ref7.id;
|
|
1615
|
+
return id === screenStateParam;
|
|
1616
|
+
}) || null : null;
|
|
1617
|
+
|
|
1618
|
+
var _ref8 = currentScreenState || {},
|
|
1619
|
+
_ref8$id = _ref8.id,
|
|
1620
|
+
screenStateId = _ref8$id === void 0 ? null : _ref8$id,
|
|
1621
|
+
_ref8$repeatable = _ref8.repeatable,
|
|
1622
|
+
repeatable = _ref8$repeatable === void 0 ? false : _ref8$repeatable;
|
|
1623
|
+
|
|
1624
|
+
var currentScreenStateId = currentScreenState !== null && repeatable ? "".concat(screenStateId, ".").concat(fieldParam.split('/').find(function (it) {
|
|
1625
|
+
return it.match(/^[0-9]+$/) !== null;
|
|
1626
|
+
}) || 0) : screenStateId;
|
|
1038
1627
|
return /*#__PURE__*/React.createElement("div", {
|
|
1039
|
-
className: classNames([styles$
|
|
1040
|
-
return styles$
|
|
1041
|
-
}), (
|
|
1628
|
+
className: classNames([styles$d.container, screens.map(function (screenName) {
|
|
1629
|
+
return styles$d["screen-".concat(screenName)];
|
|
1630
|
+
}), (_ref9 = {}, _defineProperty(_ref9, className, className), _defineProperty(_ref9, styles$d.withoutDevicesSizes, withoutDevicesSizes), _ref9)])
|
|
1042
1631
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1043
|
-
className: styles$
|
|
1632
|
+
className: styles$d.inner
|
|
1044
1633
|
}, !withoutDevicesSizes ? /*#__PURE__*/React.createElement("div", {
|
|
1045
|
-
className: styles$
|
|
1634
|
+
className: styles$d.top
|
|
1046
1635
|
}, /*#__PURE__*/React.createElement(DevicesMenu, {
|
|
1047
1636
|
items: devices.map(function (it) {
|
|
1048
1637
|
return _objectSpread(_objectSpread({}, it), {}, {
|
|
1049
1638
|
active: it.id === deviceId
|
|
1050
1639
|
});
|
|
1051
1640
|
}),
|
|
1052
|
-
onClickItem: onClickDeviceItem
|
|
1641
|
+
onClickItem: onClickDeviceItem,
|
|
1642
|
+
className: styles$d.devices
|
|
1643
|
+
})) : null, currentScreenStates !== null && currentScreen !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1644
|
+
className: classNames([styles$d.top, 'px-1'])
|
|
1645
|
+
}, /*#__PURE__*/React.createElement(ScreenStates, {
|
|
1646
|
+
screen: currentScreen,
|
|
1647
|
+
screenState: currentScreenStateId,
|
|
1648
|
+
value: value,
|
|
1649
|
+
onChange: onChange
|
|
1053
1650
|
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
1054
|
-
className: styles$
|
|
1651
|
+
className: styles$d.bottom
|
|
1055
1652
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1056
|
-
className: styles$
|
|
1653
|
+
className: styles$d.inner,
|
|
1057
1654
|
ref: bottomRef
|
|
1058
1655
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1059
|
-
className: styles$
|
|
1656
|
+
className: styles$d.preview,
|
|
1060
1657
|
style: previewStyle
|
|
1061
|
-
}, /*#__PURE__*/React.createElement(Route, {
|
|
1062
|
-
path: [routes.screen, routes.home],
|
|
1063
|
-
render: function render(_ref4) {
|
|
1064
|
-
var _ref4$match$params$sc = _ref4.match.params.screen,
|
|
1065
|
-
screenId = _ref4$match$params$sc === void 0 ? null : _ref4$match$params$sc;
|
|
1066
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1067
|
-
className: styles$8.viewerContainer
|
|
1068
|
-
}, /*#__PURE__*/React.createElement(Viewer, {
|
|
1069
|
-
story: valueParsed,
|
|
1070
|
-
storyIsParsed: true,
|
|
1071
|
-
screen: screenId,
|
|
1072
|
-
className: styles$8.story,
|
|
1073
|
-
theme: viewerTheme,
|
|
1074
|
-
interactions: null,
|
|
1075
|
-
renderContext: "edit",
|
|
1076
|
-
onScreenChange: onScreenChange
|
|
1077
|
-
}));
|
|
1078
|
-
}
|
|
1079
|
-
}))))));
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
EditorPreview.propTypes = propTypes$d;
|
|
1083
|
-
EditorPreview.defaultProps = defaultProps$d;
|
|
1084
|
-
|
|
1085
|
-
var styles$7 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
1086
|
-
|
|
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"};
|
|
1088
|
-
|
|
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
1658
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1137
|
-
className: styles$
|
|
1138
|
-
},
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
className: styles$
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
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
|
-
}
|
|
1659
|
+
className: styles$d.viewerContainer
|
|
1660
|
+
}, /*#__PURE__*/React.createElement(Viewer, {
|
|
1661
|
+
story: valueParsed,
|
|
1662
|
+
storyIsParsed: true,
|
|
1663
|
+
screen: screenId,
|
|
1664
|
+
screenState: currentScreenStateId,
|
|
1665
|
+
className: styles$d.story,
|
|
1666
|
+
theme: viewerTheme,
|
|
1667
|
+
interactions: null,
|
|
1668
|
+
renderContext: "edit",
|
|
1669
|
+
onScreenChange: onScreenChange
|
|
1670
|
+
})))))));
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
EditorPreview.propTypes = propTypes$b;
|
|
1674
|
+
EditorPreview.defaultProps = defaultProps$b;
|
|
1220
1675
|
|
|
1221
|
-
|
|
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
|
-
};
|
|
1676
|
+
var styles$7 = {"container":"micromag-editor-screens-container","navbar":"micromag-editor-screens-navbar"};
|
|
1243
1677
|
|
|
1244
|
-
|
|
1245
|
-
ScreenWithPreview.defaultProps = defaultProps$b;
|
|
1678
|
+
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","noWrap":"micromag-editor-menus-screens-noWrap","isVertical":"micromag-editor-menus-screens-isVertical","withPlaceholder":"micromag-editor-menus-screens-withPlaceholder"};
|
|
1246
1679
|
|
|
1247
1680
|
var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
1248
1681
|
function getDragDepth(offset, indentationWidth) {
|
|
@@ -1642,9 +2075,13 @@ var sortableTreeKeyboardCoordinates = function sortableTreeKeyboardCoordinates(c
|
|
|
1642
2075
|
};
|
|
1643
2076
|
};
|
|
1644
2077
|
|
|
1645
|
-
var styles$
|
|
2078
|
+
var styles$5 = {"item":"micromag-editor-sortable-sortable-tree-item","parent":"micromag-editor-sortable-sortable-tree-parent","group":"micromag-editor-sortable-sortable-tree-group","isLastChild":"micromag-editor-sortable-sortable-tree-isLastChild"};
|
|
2079
|
+
|
|
2080
|
+
var styles$4 = {"container":"micromag-editor-sortable-sortable-tree-item-container","parent":"micromag-editor-sortable-sortable-tree-item-parent","child":"micromag-editor-sortable-sortable-tree-item-child"};
|
|
2081
|
+
|
|
2082
|
+
var styles$3 = {"wrapper":"micromag-editor-sortable-sortable-tree-item-actions-wrapper","inner":"micromag-editor-sortable-sortable-tree-item-actions-inner","button":"micromag-editor-sortable-sortable-tree-item-actions-button","handle":"micromag-editor-sortable-sortable-tree-item-actions-handle","icon":"micromag-editor-sortable-sortable-tree-item-actions-icon","text":"micromag-editor-sortable-sortable-tree-item-actions-text","collapsedCount":"micromag-editor-sortable-sortable-tree-item-actions-collapsedCount","count":"micromag-editor-sortable-sortable-tree-item-actions-count","disableInteraction":"micromag-editor-sortable-sortable-tree-item-actions-disableInteraction","clone":"micromag-editor-sortable-sortable-tree-item-actions-clone","disableSelection":"micromag-editor-sortable-sortable-tree-item-actions-disableSelection","collapse":"micromag-editor-sortable-sortable-tree-item-actions-collapse","collapsed":"micromag-editor-sortable-sortable-tree-item-actions-collapsed","children":"micromag-editor-sortable-sortable-tree-item-actions-children","withChildren":"micromag-editor-sortable-sortable-tree-item-actions-withChildren","ghost":"micromag-editor-sortable-sortable-tree-item-actions-ghost","indicator":"micromag-editor-sortable-sortable-tree-item-actions-indicator"};
|
|
1646
2083
|
|
|
1647
|
-
var _excluded$4 = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "onClick", "style", "value", "wrapperRef", "showId", "children"];
|
|
2084
|
+
var _excluded$4 = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "onClick", "style", "value", "wrapperRef", "showId", "showCount", "showCollapsedCount", "children"];
|
|
1648
2085
|
var propTypes$a = {
|
|
1649
2086
|
childCount: PropTypes.number,
|
|
1650
2087
|
clone: PropTypes.bool,
|
|
@@ -1669,6 +2106,8 @@ var propTypes$a = {
|
|
|
1669
2106
|
transform: PropTypes.string.isRequired
|
|
1670
2107
|
}),
|
|
1671
2108
|
showId: PropTypes.bool,
|
|
2109
|
+
showCount: PropTypes.bool,
|
|
2110
|
+
showCollapsedCount: PropTypes.bool,
|
|
1672
2111
|
children: PropTypes.node
|
|
1673
2112
|
};
|
|
1674
2113
|
var defaultProps$a = {
|
|
@@ -1687,6 +2126,8 @@ var defaultProps$a = {
|
|
|
1687
2126
|
wrapperRef: null,
|
|
1688
2127
|
style: null,
|
|
1689
2128
|
showId: false,
|
|
2129
|
+
showCount: false,
|
|
2130
|
+
showCollapsedCount: false,
|
|
1690
2131
|
children: null
|
|
1691
2132
|
};
|
|
1692
2133
|
var SortableTreeItemActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
@@ -1709,22 +2150,22 @@ var SortableTreeItemActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
1709
2150
|
_ref.value;
|
|
1710
2151
|
var wrapperRef = _ref.wrapperRef;
|
|
1711
2152
|
_ref.showId;
|
|
1712
|
-
var
|
|
2153
|
+
var showCount = _ref.showCount,
|
|
2154
|
+
showCollapsedCount = _ref.showCollapsedCount,
|
|
2155
|
+
children = _ref.children,
|
|
1713
2156
|
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
1714
2157
|
|
|
1715
|
-
return /*#__PURE__*/React.createElement("
|
|
2158
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
1716
2159
|
className: classNames([styles$3.wrapper, (_ref2 = {}, _defineProperty(_ref2, styles$3.clone, clone), _defineProperty(_ref2, styles$3.ghost, ghost), _defineProperty(_ref2, styles$3.indicator, indicator), _defineProperty(_ref2, styles$3.disableSelection, disableSelection), _defineProperty(_ref2, styles$3.disableInteraction, disableInteraction), _defineProperty(_ref2, styles$3.withChildren, onCollapse !== null), _ref2)]),
|
|
1717
2160
|
ref: wrapperRef,
|
|
1718
|
-
style:
|
|
1719
|
-
marginLeft: "".concat(indentationWidth * depth, "px")
|
|
1720
|
-
|
|
2161
|
+
style: {
|
|
2162
|
+
marginLeft: "".concat(indentationWidth * depth, "px"),
|
|
2163
|
+
marginRight: "".concat(5 * depth, "px")
|
|
2164
|
+
}
|
|
1721
2165
|
}, props), /*#__PURE__*/React.createElement("div", {
|
|
1722
2166
|
className: styles$3.inner,
|
|
1723
2167
|
ref: ref,
|
|
1724
|
-
style:
|
|
1725
|
-
width: style.width,
|
|
1726
|
-
height: style.height
|
|
1727
|
-
}
|
|
2168
|
+
style: style
|
|
1728
2169
|
}, /*#__PURE__*/React.createElement("button", Object.assign({
|
|
1729
2170
|
className: classNames([styles$3.button, styles$3.handle]),
|
|
1730
2171
|
type: "button"
|
|
@@ -1736,27 +2177,24 @@ var SortableTreeItemActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
1736
2177
|
onClick: onRemove
|
|
1737
2178
|
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1738
2179
|
icon: faTimes
|
|
1739
|
-
})) : null, clone && childCount && childCount > 1 ? /*#__PURE__*/React.createElement("span", {
|
|
2180
|
+
})) : null, clone && showCount && childCount && childCount > 1 ? /*#__PURE__*/React.createElement("span", {
|
|
1740
2181
|
className: styles$3.count
|
|
1741
|
-
}, childCount) : null, onCollapse && childCount !== null && childCount > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
2182
|
+
}, childCount) : null, showCollapsedCount && onCollapse && collapsed && childCount !== null && childCount > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
1742
2183
|
className: styles$3.collapsedCount
|
|
1743
2184
|
}, childCount) : null, onCollapse && depth === 0 ? /*#__PURE__*/React.createElement("button", {
|
|
1744
2185
|
type: "button",
|
|
1745
|
-
onClick: onCollapse,
|
|
1746
|
-
className: classNames(styles$3.button, styles$3.collapse, collapsed && styles$3.collapsed)
|
|
1747
|
-
style: {
|
|
1748
|
-
width: style.width
|
|
1749
|
-
}
|
|
2186
|
+
onClick: onCollapse,
|
|
2187
|
+
className: classNames(styles$3.button, styles$3.collapse, collapsed && styles$3.collapsed)
|
|
1750
2188
|
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1751
2189
|
icon: faAngleDown
|
|
1752
|
-
})) : null
|
|
2190
|
+
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
1753
2191
|
className: styles$3.children
|
|
1754
|
-
}, children));
|
|
2192
|
+
}, children)));
|
|
1755
2193
|
});
|
|
1756
2194
|
SortableTreeItemActions.propTypes = propTypes$a;
|
|
1757
2195
|
SortableTreeItemActions.defaultProps = defaultProps$a;
|
|
1758
2196
|
|
|
1759
|
-
var _excluded$3 = ["id", "index", "depth", "component", "value", "style", "smallScale", "onCollapse", "onClickItem"];
|
|
2197
|
+
var _excluded$3 = ["id", "index", "depth", "component", "value", "style", "smallScale", "collapsed", "onCollapse", "onClickItem", "childValue", "isLastChild"];
|
|
1760
2198
|
var propTypes$9 = {
|
|
1761
2199
|
id: PropTypes.string.isRequired,
|
|
1762
2200
|
index: PropTypes.number.isRequired,
|
|
@@ -1773,16 +2211,23 @@ var propTypes$9 = {
|
|
|
1773
2211
|
scale: PropTypes.number.isRequired
|
|
1774
2212
|
}),
|
|
1775
2213
|
smallScale: PropTypes.number,
|
|
2214
|
+
collapsed: PropTypes.bool,
|
|
1776
2215
|
onCollapse: PropTypes.func,
|
|
1777
|
-
onClickItem: PropTypes.func
|
|
2216
|
+
onClickItem: PropTypes.func,
|
|
2217
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
2218
|
+
childValue: PropTypes.object,
|
|
2219
|
+
isLastChild: PropTypes.bool
|
|
1778
2220
|
};
|
|
1779
2221
|
var defaultProps$9 = {
|
|
1780
2222
|
component: null,
|
|
1781
2223
|
value: null,
|
|
1782
2224
|
style: null,
|
|
1783
2225
|
smallScale: 0.75,
|
|
2226
|
+
collapsed: false,
|
|
1784
2227
|
onCollapse: null,
|
|
1785
|
-
onClickItem: null
|
|
2228
|
+
onClickItem: null,
|
|
2229
|
+
childValue: null,
|
|
2230
|
+
isLastChild: false
|
|
1786
2231
|
};
|
|
1787
2232
|
|
|
1788
2233
|
var animateLayoutChanges = function animateLayoutChanges(_ref) {
|
|
@@ -1796,12 +2241,15 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
1796
2241
|
index = _ref2.index,
|
|
1797
2242
|
depth = _ref2.depth,
|
|
1798
2243
|
Component = _ref2.component,
|
|
1799
|
-
value = _ref2.value
|
|
1800
|
-
|
|
1801
|
-
|
|
2244
|
+
value = _ref2.value;
|
|
2245
|
+
_ref2.style;
|
|
2246
|
+
_ref2.smallScale;
|
|
2247
|
+
var collapsed = _ref2.collapsed,
|
|
1802
2248
|
onCollapse = _ref2.onCollapse,
|
|
1803
2249
|
onClickItem = _ref2.onClickItem,
|
|
1804
|
-
|
|
2250
|
+
childValue = _ref2.childValue;
|
|
2251
|
+
_ref2.isLastChild;
|
|
2252
|
+
var props = _objectWithoutProperties(_ref2, _excluded$3);
|
|
1805
2253
|
|
|
1806
2254
|
var _useSortable = useSortable({
|
|
1807
2255
|
id: id,
|
|
@@ -1816,28 +2264,17 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
1816
2264
|
transform = _useSortable.transform,
|
|
1817
2265
|
transition = _useSortable.transition;
|
|
1818
2266
|
|
|
1819
|
-
var
|
|
1820
|
-
var _itemStyle$scaledWidt = itemStyle.scaledWidth,
|
|
1821
|
-
scaledWidth = _itemStyle$scaledWidt === void 0 ? 100 : _itemStyle$scaledWidt,
|
|
1822
|
-
_itemStyle$scaledHeig = itemStyle.scaledHeight,
|
|
1823
|
-
scaledHeight = _itemStyle$scaledHeig === void 0 ? 66 : _itemStyle$scaledHeig,
|
|
1824
|
-
_itemStyle$scale = itemStyle.scale,
|
|
1825
|
-
scale = _itemStyle$scale === void 0 ? 1 : _itemStyle$scale;
|
|
1826
|
-
var extraHeight = hasCollapse ? 30 : 0;
|
|
2267
|
+
var timeout = useRef(null);
|
|
1827
2268
|
var actionsStyle = {
|
|
1828
|
-
width: depth === 0 ? scaledWidth : scaledWidth * smallScale,
|
|
1829
|
-
height: depth === 0 ? scaledHeight + extraHeight : scaledHeight * smallScale,
|
|
1830
2269
|
transform: CSS.Translate.toString(transform),
|
|
1831
2270
|
transition: transition
|
|
1832
2271
|
};
|
|
1833
|
-
var previewStyle = {
|
|
1834
|
-
width: itemStyle.width,
|
|
1835
|
-
height: itemStyle.height,
|
|
1836
|
-
transform: depth === 0 ? itemStyle.transform : "scale(".concat(scale * smallScale, ", ").concat(scale * smallScale, ")")
|
|
1837
|
-
};
|
|
1838
2272
|
|
|
1839
2273
|
var _ref3 = listeners || {},
|
|
1840
|
-
onPointerDown = _ref3.onPointerDown
|
|
2274
|
+
_ref3$onPointerDown = _ref3.onPointerDown,
|
|
2275
|
+
onPointerDown = _ref3$onPointerDown === void 0 ? null : _ref3$onPointerDown,
|
|
2276
|
+
_ref3$onPointerUp = _ref3.onPointerUp,
|
|
2277
|
+
onPointerUp = _ref3$onPointerUp === void 0 ? null : _ref3$onPointerUp;
|
|
1841
2278
|
|
|
1842
2279
|
var onClickAction = useCallback(function (e) {
|
|
1843
2280
|
if (onClickItem !== null) {
|
|
@@ -1845,10 +2282,28 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
1845
2282
|
}
|
|
1846
2283
|
|
|
1847
2284
|
if (onPointerDown !== null) {
|
|
1848
|
-
|
|
2285
|
+
e.persist();
|
|
2286
|
+
timeout.current = setTimeout(function () {
|
|
2287
|
+
if (onPointerDown !== null) {
|
|
2288
|
+
onPointerDown(e);
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
timeout.current = null;
|
|
2292
|
+
}, 200);
|
|
1849
2293
|
}
|
|
1850
2294
|
}, [value, index, onClickItem, onPointerDown]);
|
|
1851
|
-
|
|
2295
|
+
var cancellingPointerUp = useCallback(function (e) {
|
|
2296
|
+
if (timeout.current !== null) {
|
|
2297
|
+
clearTimeout(timeout.current);
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
if (onPointerUp !== null) {
|
|
2301
|
+
onPointerUp(e);
|
|
2302
|
+
}
|
|
2303
|
+
}, [onPointerUp]);
|
|
2304
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2305
|
+
className: classNames([styles$4.container])
|
|
2306
|
+
}, /*#__PURE__*/React.createElement(SortableTreeItemActions, Object.assign({
|
|
1852
2307
|
ref: setDraggableNodeRef,
|
|
1853
2308
|
wrapperRef: setDroppableNodeRef,
|
|
1854
2309
|
style: actionsStyle,
|
|
@@ -1857,13 +2312,18 @@ var SortableTreeItem = function SortableTreeItem(_ref2) {
|
|
|
1857
2312
|
disableSelection: iOS,
|
|
1858
2313
|
disableInteraction: isSorting,
|
|
1859
2314
|
handleProps: _objectSpread(_objectSpread(_objectSpread({}, attributes), listeners), {}, {
|
|
1860
|
-
onPointerDown: onClickAction
|
|
2315
|
+
onPointerDown: onClickAction,
|
|
2316
|
+
onPointerUp: cancellingPointerUp
|
|
1861
2317
|
}),
|
|
2318
|
+
collapsed: collapsed,
|
|
1862
2319
|
onCollapse: onCollapse
|
|
1863
|
-
}, props), Component !== null ? /*#__PURE__*/React.createElement(
|
|
1864
|
-
|
|
1865
|
-
})) : null
|
|
2320
|
+
}, props), Component !== null ? /*#__PURE__*/React.createElement("div", {
|
|
2321
|
+
className: styles$4.parent
|
|
2322
|
+
}, /*#__PURE__*/React.createElement(Component, value)) : null, childValue !== null ? /*#__PURE__*/React.createElement("div", {
|
|
2323
|
+
className: styles$4.child
|
|
2324
|
+
}, /*#__PURE__*/React.createElement(Component, childValue)) : null));
|
|
1866
2325
|
};
|
|
2326
|
+
|
|
1867
2327
|
SortableTreeItem.propTypes = propTypes$9;
|
|
1868
2328
|
SortableTreeItem.defaultProps = defaultProps$9;
|
|
1869
2329
|
|
|
@@ -1885,18 +2345,6 @@ var initialItems = [{
|
|
|
1885
2345
|
id: 'Winter',
|
|
1886
2346
|
children: []
|
|
1887
2347
|
}]
|
|
1888
|
-
}, {
|
|
1889
|
-
id: 'About Us',
|
|
1890
|
-
children: []
|
|
1891
|
-
}, {
|
|
1892
|
-
id: 'My Account',
|
|
1893
|
-
children: [{
|
|
1894
|
-
id: 'Addresses',
|
|
1895
|
-
children: []
|
|
1896
|
-
}, {
|
|
1897
|
-
id: 'Order History',
|
|
1898
|
-
children: []
|
|
1899
|
-
}]
|
|
1900
2348
|
}];
|
|
1901
2349
|
var measuring = {
|
|
1902
2350
|
droppable: {
|
|
@@ -1923,7 +2371,6 @@ var propTypes$8 = {
|
|
|
1923
2371
|
indicator: PropTypes.bool,
|
|
1924
2372
|
removable: PropTypes.bool,
|
|
1925
2373
|
component: PropTypes.func,
|
|
1926
|
-
itemStyle: PropTypes.shape({}),
|
|
1927
2374
|
onClickItem: PropTypes.func,
|
|
1928
2375
|
onChange: PropTypes.func
|
|
1929
2376
|
};
|
|
@@ -1934,10 +2381,10 @@ var defaultProps$8 = {
|
|
|
1934
2381
|
indicator: false,
|
|
1935
2382
|
removable: false,
|
|
1936
2383
|
component: null,
|
|
1937
|
-
itemStyle: null,
|
|
1938
2384
|
onClickItem: null,
|
|
1939
2385
|
onChange: null
|
|
1940
2386
|
};
|
|
2387
|
+
|
|
1941
2388
|
var SortableTree = function SortableTree(_ref2) {
|
|
1942
2389
|
var collapsible = _ref2.collapsible,
|
|
1943
2390
|
defaultItems = _ref2.items,
|
|
@@ -1945,12 +2392,11 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
1945
2392
|
indentationWidth = _ref2.indentationWidth,
|
|
1946
2393
|
removable = _ref2.removable,
|
|
1947
2394
|
component = _ref2.component,
|
|
1948
|
-
itemStyle = _ref2.itemStyle,
|
|
1949
2395
|
onClickItem = _ref2.onClickItem,
|
|
1950
2396
|
onChange = _ref2.onChange;
|
|
1951
2397
|
|
|
1952
2398
|
var _useState = useState(function () {
|
|
1953
|
-
return defaultItems;
|
|
2399
|
+
return buildTree(defaultItems);
|
|
1954
2400
|
}),
|
|
1955
2401
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1956
2402
|
items = _useState2[0],
|
|
@@ -1974,11 +2420,20 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
1974
2420
|
var _useState9 = useState(null),
|
|
1975
2421
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
1976
2422
|
currentPosition = _useState10[0],
|
|
1977
|
-
setCurrentPosition = _useState10[1];
|
|
2423
|
+
setCurrentPosition = _useState10[1]; // Tree setup from list
|
|
1978
2424
|
|
|
1979
|
-
var flattenedItems = useMemo(function () {
|
|
1980
|
-
var flattenedTree = flattenTree(items); // console.log('yo', items, flattenedTree);
|
|
1981
2425
|
|
|
2426
|
+
useEffect(function () {
|
|
2427
|
+
var flat = flattenTree(items);
|
|
2428
|
+
var merged = defaultItems.map(function (t1) {
|
|
2429
|
+
return _objectSpread(_objectSpread({}, flat.find(function (t2) {
|
|
2430
|
+
return t2.id === t1.id;
|
|
2431
|
+
})), t1);
|
|
2432
|
+
});
|
|
2433
|
+
setItems(buildTree(merged));
|
|
2434
|
+
}, [defaultItems.length]);
|
|
2435
|
+
var flattenedItems = useMemo(function () {
|
|
2436
|
+
var flattenedTree = flattenTree(items);
|
|
1982
2437
|
var collapsedItems = flattenedTree.reduce(function (acc, _ref3) {
|
|
1983
2438
|
var _ref3$children = _ref3.children,
|
|
1984
2439
|
children = _ref3$children === void 0 ? [] : _ref3$children,
|
|
@@ -1987,7 +2442,7 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
1987
2442
|
return collapsed && children.length ? [].concat(_toConsumableArray(acc), [id]) : acc;
|
|
1988
2443
|
}, []) || null;
|
|
1989
2444
|
return removeChildrenOf(flattenedTree, activeId ? [activeId].concat(_toConsumableArray(collapsedItems)) : collapsedItems);
|
|
1990
|
-
}, [activeId, items]);
|
|
2445
|
+
}, [activeId, items, items.length]);
|
|
1991
2446
|
var projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth) : null;
|
|
1992
2447
|
var sensorContext = useRef({
|
|
1993
2448
|
items: flattenedItems,
|
|
@@ -2019,6 +2474,69 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2019
2474
|
offset: offsetLeft
|
|
2020
2475
|
};
|
|
2021
2476
|
}, [flattenedItems, offsetLeft]);
|
|
2477
|
+
|
|
2478
|
+
function getMovementAnnouncement(eventName, currentActiveId, currentOverId) {
|
|
2479
|
+
if (currentOverId && projected) {
|
|
2480
|
+
if (eventName !== 'onDragEnd') {
|
|
2481
|
+
if (currentPosition && projected.parentId === currentPosition.parentId && currentOverId === currentPosition.overId) {
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
setCurrentPosition({
|
|
2486
|
+
parentId: projected.parentId,
|
|
2487
|
+
overId: currentOverId
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2492
|
+
var overIndex = clonedItems.findIndex(function (_ref6) {
|
|
2493
|
+
var id = _ref6.id;
|
|
2494
|
+
return id === currentOverId;
|
|
2495
|
+
});
|
|
2496
|
+
var activeIndex = clonedItems.findIndex(function (_ref7) {
|
|
2497
|
+
var id = _ref7.id;
|
|
2498
|
+
return id === currentActiveId;
|
|
2499
|
+
});
|
|
2500
|
+
var sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
2501
|
+
var previousItem = sortedItems[overIndex - 1];
|
|
2502
|
+
var newAnnouncement;
|
|
2503
|
+
var movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
2504
|
+
var nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
2505
|
+
|
|
2506
|
+
if (!previousItem) {
|
|
2507
|
+
var nextItem = typeof sortedItems[overIndex + 1] !== 'undefined' ? sortedItems[overIndex + 1] : null;
|
|
2508
|
+
|
|
2509
|
+
if (nextItem !== null) {
|
|
2510
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " before ").concat(nextItem.id, ".");
|
|
2511
|
+
}
|
|
2512
|
+
} else if (projected.depth > previousItem.depth) {
|
|
2513
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(nestedVerb, " under ").concat(previousItem.id, ".");
|
|
2514
|
+
} else {
|
|
2515
|
+
var previousSibling = previousItem;
|
|
2516
|
+
|
|
2517
|
+
var _loop = function _loop() {
|
|
2518
|
+
var _previousSibling = previousSibling,
|
|
2519
|
+
parentId = _previousSibling.parentId;
|
|
2520
|
+
previousSibling = sortedItems.find(function (_ref8) {
|
|
2521
|
+
var id = _ref8.id;
|
|
2522
|
+
return id === parentId;
|
|
2523
|
+
});
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
2527
|
+
_loop();
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
if (previousSibling) {
|
|
2531
|
+
newAnnouncement = "".concat(currentActiveId, " was ").concat(movedVerb, " after ").concat(previousSibling.id, ".");
|
|
2532
|
+
}
|
|
2533
|
+
} // eslint-disable-next-line consistent-return
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
return newAnnouncement;
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2022
2540
|
var announcements = useMemo(function () {
|
|
2023
2541
|
return {
|
|
2024
2542
|
onDragStart: function onDragStart(id) {
|
|
@@ -2031,16 +2549,17 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2031
2549
|
return getMovementAnnouncement('onDragOver', id, currentOverId);
|
|
2032
2550
|
},
|
|
2033
2551
|
onDragEnd: function onDragEnd(id, currentOverId) {
|
|
2034
|
-
|
|
2552
|
+
var flat = flattenTree(items);
|
|
2553
|
+
|
|
2035
2554
|
if (onChange !== null) {
|
|
2036
|
-
onChange((
|
|
2037
|
-
var itemId =
|
|
2038
|
-
|
|
2039
|
-
children =
|
|
2040
|
-
|
|
2041
|
-
parentId =
|
|
2042
|
-
|
|
2043
|
-
collapsed =
|
|
2555
|
+
onChange((flat || []).map(function (_ref9) {
|
|
2556
|
+
var itemId = _ref9.id,
|
|
2557
|
+
_ref9$children = _ref9.children,
|
|
2558
|
+
children = _ref9$children === void 0 ? [] : _ref9$children,
|
|
2559
|
+
_ref9$parentId = _ref9.parentId,
|
|
2560
|
+
parentId = _ref9$parentId === void 0 ? null : _ref9$parentId,
|
|
2561
|
+
_ref9$collapsed = _ref9.collapsed,
|
|
2562
|
+
collapsed = _ref9$collapsed === void 0 ? false : _ref9$collapsed;
|
|
2044
2563
|
return {
|
|
2045
2564
|
id: itemId,
|
|
2046
2565
|
props: _objectSpread(_objectSpread({}, (children || []).length > 0 ? {
|
|
@@ -2065,78 +2584,18 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2065
2584
|
return "Moving was cancelled. ".concat(id, " was dropped in its original position.");
|
|
2066
2585
|
}
|
|
2067
2586
|
};
|
|
2068
|
-
}, [flattenedItems, onChange]);
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
sensors: sensors,
|
|
2077
|
-
collisionDetection: closestCenter,
|
|
2078
|
-
measuring: measuring,
|
|
2079
|
-
onDragStart: handleDragStart,
|
|
2080
|
-
onDragMove: handleDragMove,
|
|
2081
|
-
onDragOver: handleDragOver,
|
|
2082
|
-
onDragEnd: handleDragEnd,
|
|
2083
|
-
onDragCancel: handleDragCancel
|
|
2084
|
-
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
2085
|
-
items: sortedIds,
|
|
2086
|
-
strategy: verticalListSortingStrategy
|
|
2087
|
-
}, flattenedItems.map(function (_ref7, idx) {
|
|
2088
|
-
var id = _ref7.id,
|
|
2089
|
-
_ref7$children = _ref7.children,
|
|
2090
|
-
children = _ref7$children === void 0 ? [] : _ref7$children,
|
|
2091
|
-
collapsed = _ref7.collapsed,
|
|
2092
|
-
depth = _ref7.depth,
|
|
2093
|
-
_ref7$value = _ref7.value,
|
|
2094
|
-
value = _ref7$value === void 0 ? null : _ref7$value;
|
|
2095
|
-
return /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2096
|
-
key: id,
|
|
2097
|
-
id: id,
|
|
2098
|
-
depth: id === activeId && projected ? projected.depth : depth,
|
|
2099
|
-
indentationWidth: indentationWidth,
|
|
2100
|
-
indicator: indicator,
|
|
2101
|
-
collapsed: Boolean(collapsed && children.length),
|
|
2102
|
-
onCollapse: collapsible && children.length ? function () {
|
|
2103
|
-
return handleCollapse(id);
|
|
2104
|
-
} : undefined,
|
|
2105
|
-
onRemove: removable ? function () {
|
|
2106
|
-
return handleRemove(id);
|
|
2107
|
-
} : undefined,
|
|
2108
|
-
childCount: getChildCount(items, id),
|
|
2109
|
-
component: component,
|
|
2110
|
-
value: value,
|
|
2111
|
-
style: itemStyle,
|
|
2112
|
-
onClickItem: onClickItem,
|
|
2113
|
-
index: idx
|
|
2114
|
-
});
|
|
2115
|
-
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(DragOverlay, {
|
|
2116
|
-
dropAnimation: dropAnimation,
|
|
2117
|
-
modifiers: indicator ? [adjustTranslate] : undefined
|
|
2118
|
-
}, activeId && activeItem ? /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2119
|
-
id: activeId,
|
|
2120
|
-
depth: activeItem.depth,
|
|
2121
|
-
clone: true,
|
|
2122
|
-
childCount: getChildCount(items, activeId) + 1,
|
|
2123
|
-
indentationWidth: indentationWidth,
|
|
2124
|
-
component: component,
|
|
2125
|
-
value: activeItem === null || activeItem === void 0 ? void 0 : activeItem.value,
|
|
2126
|
-
onClickItem: onClickItem,
|
|
2127
|
-
index: flattenedItems.findIndex(function (_ref8) {
|
|
2128
|
-
var id = _ref8.id;
|
|
2129
|
-
return activeId === id;
|
|
2130
|
-
}),
|
|
2131
|
-
style: itemStyle
|
|
2132
|
-
}) : null), document.body)));
|
|
2133
|
-
|
|
2134
|
-
function handleDragStart(_ref9) {
|
|
2135
|
-
var newActiveId = _ref9.active.id;
|
|
2587
|
+
}, [flattenedItems, onChange, getMovementAnnouncement]);
|
|
2588
|
+
var activeValue = defaultItems.find(function (_ref10) {
|
|
2589
|
+
var _ref10$id = _ref10.id,
|
|
2590
|
+
defaultId = _ref10$id === void 0 ? null : _ref10$id;
|
|
2591
|
+
return defaultId === activeId;
|
|
2592
|
+
});
|
|
2593
|
+
var handleDragStart = useCallback(function (_ref11) {
|
|
2594
|
+
var newActiveId = _ref11.active.id;
|
|
2136
2595
|
setActiveId(newActiveId);
|
|
2137
2596
|
setOverId(newActiveId);
|
|
2138
|
-
var newActiveItem = flattenedItems.find(function (
|
|
2139
|
-
var id =
|
|
2597
|
+
var newActiveItem = flattenedItems.find(function (_ref12) {
|
|
2598
|
+
var id = _ref12.id;
|
|
2140
2599
|
return id === newActiveId;
|
|
2141
2600
|
});
|
|
2142
2601
|
|
|
@@ -2148,53 +2607,49 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2148
2607
|
}
|
|
2149
2608
|
|
|
2150
2609
|
document.body.style.setProperty('cursor', 'grabbing');
|
|
2151
|
-
}
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
var delta = _ref11.delta;
|
|
2610
|
+
}, [flattenedItems, setActiveId, setOverId, setCurrentPosition]);
|
|
2611
|
+
var handleDragMove = useCallback(function (_ref13) {
|
|
2612
|
+
var delta = _ref13.delta;
|
|
2155
2613
|
setOffsetLeft(delta.x);
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
function handleDragOver(_ref12) {
|
|
2614
|
+
}, [setOffsetLeft]);
|
|
2615
|
+
var handleDragOver = useCallback(function (_ref14) {
|
|
2159
2616
|
var _over$id;
|
|
2160
2617
|
|
|
2161
|
-
var over =
|
|
2618
|
+
var over = _ref14.over;
|
|
2162
2619
|
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
|
-
function resetState() {
|
|
2620
|
+
}, [setOverId]);
|
|
2621
|
+
var resetState = useCallback(function () {
|
|
2166
2622
|
setOverId(null);
|
|
2167
2623
|
setActiveId(null);
|
|
2168
2624
|
setOffsetLeft(0);
|
|
2169
2625
|
setCurrentPosition(null);
|
|
2170
2626
|
document.body.style.setProperty('cursor', '');
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
over = _ref13.over;
|
|
2627
|
+
}, [setOverId, setActiveId, setOffsetLeft, setCurrentPosition]);
|
|
2628
|
+
var handleDragEnd = useCallback(function (_ref15) {
|
|
2629
|
+
var active = _ref15.active,
|
|
2630
|
+
over = _ref15.over;
|
|
2176
2631
|
resetState();
|
|
2177
2632
|
|
|
2178
2633
|
if (projected && over) {
|
|
2179
2634
|
var depth = projected.depth,
|
|
2180
2635
|
parentId = projected.parentId;
|
|
2181
2636
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
2182
|
-
var overIndex = clonedItems.findIndex(function (
|
|
2183
|
-
var id =
|
|
2637
|
+
var overIndex = clonedItems.findIndex(function (_ref16) {
|
|
2638
|
+
var id = _ref16.id;
|
|
2184
2639
|
return id === over.id;
|
|
2185
2640
|
});
|
|
2186
|
-
var activeIndex = clonedItems.findIndex(function (
|
|
2187
|
-
var id =
|
|
2641
|
+
var activeIndex = clonedItems.findIndex(function (_ref17) {
|
|
2642
|
+
var id = _ref17.id;
|
|
2188
2643
|
return id === active.id;
|
|
2189
2644
|
});
|
|
2190
2645
|
var activeTreeItem = clonedItems[activeIndex];
|
|
2191
2646
|
var maxDepth = getMaxDepth(activeTreeItem); // Un-merge and flatten
|
|
2192
2647
|
|
|
2193
2648
|
if (depth > 0 && depth >= maxDepth && (activeTreeItem === null || activeTreeItem === void 0 ? void 0 : activeTreeItem.children) !== null && activeTreeItem.children.length > 0) {
|
|
2194
|
-
var
|
|
2649
|
+
var _loop2 = function _loop2(i) {
|
|
2195
2650
|
var childId = activeTreeItem.children[i].id;
|
|
2196
|
-
var childIndex = clonedItems.findIndex(function (
|
|
2197
|
-
var id =
|
|
2651
|
+
var childIndex = clonedItems.findIndex(function (_ref18) {
|
|
2652
|
+
var id = _ref18.id;
|
|
2198
2653
|
return id === childId;
|
|
2199
2654
|
});
|
|
2200
2655
|
clonedItems[childIndex].parentId = parentId;
|
|
@@ -2202,7 +2657,7 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2202
2657
|
};
|
|
2203
2658
|
|
|
2204
2659
|
for (var i = 0; i < activeTreeItem.children.length; i += 1) {
|
|
2205
|
-
|
|
2660
|
+
_loop2(i);
|
|
2206
2661
|
}
|
|
2207
2662
|
|
|
2208
2663
|
activeTreeItem.children = [];
|
|
@@ -2216,96 +2671,113 @@ var SortableTree = function SortableTree(_ref2) {
|
|
|
2216
2671
|
var newItems = buildTree(sortedItems);
|
|
2217
2672
|
setItems(newItems);
|
|
2218
2673
|
}
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
|
-
function handleDragCancel() {
|
|
2674
|
+
}, [projected, items, resetState, arrayMove, buildTree, setItems]);
|
|
2675
|
+
var handleDragCancel = useCallback(function () {
|
|
2222
2676
|
resetState();
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
function handleRemove(id) {
|
|
2677
|
+
}, [resetState]);
|
|
2678
|
+
var handleRemove = useCallback(function (id) {
|
|
2226
2679
|
setItems(function (newItems) {
|
|
2227
2680
|
return removeItem(newItems, id);
|
|
2228
2681
|
});
|
|
2229
|
-
}
|
|
2230
|
-
|
|
2231
|
-
function handleCollapse(id) {
|
|
2682
|
+
}, [setItems, removeItem]);
|
|
2683
|
+
var handleCollapse = useCallback(function (id) {
|
|
2232
2684
|
setItems(function (newItems) {
|
|
2233
2685
|
return setProperty(newItems, id, 'collapsed', function (value) {
|
|
2234
2686
|
return !value;
|
|
2235
2687
|
});
|
|
2236
2688
|
});
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2689
|
+
}, [setItems, setProperty]);
|
|
2690
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
2691
|
+
announcements: announcements,
|
|
2692
|
+
sensors: sensors,
|
|
2693
|
+
collisionDetection: closestCenter,
|
|
2694
|
+
measuring: measuring,
|
|
2695
|
+
onDragStart: handleDragStart,
|
|
2696
|
+
onDragMove: handleDragMove,
|
|
2697
|
+
onDragOver: handleDragOver,
|
|
2698
|
+
onDragEnd: handleDragEnd,
|
|
2699
|
+
onDragCancel: handleDragCancel
|
|
2700
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
2701
|
+
items: sortedIds,
|
|
2702
|
+
strategy: verticalListSortingStrategy
|
|
2703
|
+
}, flattenedItems.map(function (_ref19, idx) {
|
|
2704
|
+
var _flattenedItems, _ref22;
|
|
2705
|
+
|
|
2706
|
+
var id = _ref19.id,
|
|
2707
|
+
_ref19$children = _ref19.children,
|
|
2708
|
+
children = _ref19$children === void 0 ? [] : _ref19$children,
|
|
2709
|
+
collapsed = _ref19.collapsed,
|
|
2710
|
+
depth = _ref19.depth;
|
|
2711
|
+
var screenValue = defaultItems.find(function (_ref20) {
|
|
2712
|
+
var _ref20$id = _ref20.id,
|
|
2713
|
+
defaultId = _ref20$id === void 0 ? null : _ref20$id;
|
|
2714
|
+
return defaultId === id;
|
|
2715
|
+
});
|
|
2716
|
+
var next = ((_flattenedItems = flattenedItems[idx + 1]) === null || _flattenedItems === void 0 ? void 0 : _flattenedItems.parentId) || null;
|
|
2717
|
+
var isCollapsed = collapsed && children.length > 0;
|
|
2718
|
+
var onCollapse = collapsible && children.length ? function () {
|
|
2719
|
+
return handleCollapse(id);
|
|
2720
|
+
} : null;
|
|
2721
|
+
var currentDepth = id === activeId && projected ? projected.depth : depth;
|
|
2722
|
+
var childCount = getChildCount(items, id);
|
|
2723
|
+
var childValue = childCount > 0 && collapsed ? defaultItems.slice().reverse().find(function (_ref21) {
|
|
2724
|
+
var _ref21$parentId = _ref21.parentId,
|
|
2725
|
+
parentId = _ref21$parentId === void 0 ? null : _ref21$parentId;
|
|
2726
|
+
return parentId === id;
|
|
2727
|
+
}) : null;
|
|
2728
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2729
|
+
className: classNames([styles$5.item, (_ref22 = {}, _defineProperty(_ref22, styles$5.parent, onCollapse !== null && !collapsed), _defineProperty(_ref22, styles$5.group, depth === 1), _defineProperty(_ref22, styles$5.isLastChild, next === null), _ref22)]),
|
|
2730
|
+
key: id
|
|
2731
|
+
}, /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2732
|
+
key: id,
|
|
2733
|
+
id: id,
|
|
2734
|
+
depth: currentDepth,
|
|
2735
|
+
indentationWidth: indentationWidth,
|
|
2736
|
+
indicator: indicator,
|
|
2737
|
+
collapsed: isCollapsed,
|
|
2738
|
+
onCollapse: onCollapse,
|
|
2739
|
+
onRemove: removable ? function () {
|
|
2740
|
+
return handleRemove(id);
|
|
2741
|
+
} : undefined,
|
|
2742
|
+
childCount: childCount,
|
|
2743
|
+
component: component,
|
|
2744
|
+
value: (screenValue === null || screenValue === void 0 ? void 0 : screenValue.value) || null,
|
|
2745
|
+
onClickItem: onClickItem,
|
|
2746
|
+
index: idx,
|
|
2747
|
+
childValue: (childValue === null || childValue === void 0 ? void 0 : childValue.value) || null
|
|
2748
|
+
}));
|
|
2749
|
+
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(DragOverlay, {
|
|
2750
|
+
dropAnimation: dropAnimation,
|
|
2751
|
+
modifiers: indicator ? [adjustTranslate] : undefined
|
|
2752
|
+
}, activeId && activeItem ? /*#__PURE__*/React.createElement("div", {
|
|
2753
|
+
className: styles$5.item,
|
|
2754
|
+
key: activeId
|
|
2755
|
+
}, /*#__PURE__*/React.createElement(SortableTreeItem, {
|
|
2756
|
+
id: activeId,
|
|
2757
|
+
depth: activeItem.depth,
|
|
2758
|
+
clone: true,
|
|
2759
|
+
childCount: getChildCount(items, activeId) + 1,
|
|
2760
|
+
indentationWidth: indentationWidth,
|
|
2761
|
+
component: component,
|
|
2762
|
+
value: activeValue === null || activeValue === void 0 ? void 0 : activeValue.value,
|
|
2763
|
+
onClickItem: onClickItem,
|
|
2764
|
+
index: flattenedItems.findIndex(function (_ref23) {
|
|
2765
|
+
var id = _ref23.id;
|
|
2766
|
+
return activeId === id;
|
|
2767
|
+
})
|
|
2768
|
+
})) : null), document.body)));
|
|
2297
2769
|
};
|
|
2770
|
+
|
|
2298
2771
|
SortableTree.propTypes = propTypes$8;
|
|
2299
2772
|
SortableTree.defaultProps = defaultProps$8;
|
|
2300
2773
|
|
|
2301
|
-
var _excluded$2 = ["className", "screen", "type", "onClick"],
|
|
2302
|
-
_excluded2 = ["id", "screen"];
|
|
2774
|
+
var _excluded$2 = ["className", "screen", "type", "onClick", "active", "href"],
|
|
2775
|
+
_excluded2 = ["id", "screen", "href"];
|
|
2303
2776
|
var propTypes$7 = {
|
|
2304
2777
|
items: PropTypes$1.menuItems,
|
|
2305
2778
|
withPreview: PropTypes.bool,
|
|
2306
2779
|
withPlaceholder: PropTypes.bool,
|
|
2307
|
-
settings: PropTypes.node,
|
|
2308
|
-
previewMinWidth: PropTypes.number,
|
|
2780
|
+
settings: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
2309
2781
|
sortable: PropTypes.bool,
|
|
2310
2782
|
isTree: PropTypes.bool,
|
|
2311
2783
|
isVertical: PropTypes.bool,
|
|
@@ -2322,7 +2794,6 @@ var defaultProps$7 = {
|
|
|
2322
2794
|
withPreview: false,
|
|
2323
2795
|
withPlaceholder: false,
|
|
2324
2796
|
settings: null,
|
|
2325
|
-
previewMinWidth: 320,
|
|
2326
2797
|
sortable: false,
|
|
2327
2798
|
isTree: false,
|
|
2328
2799
|
isVertical: false,
|
|
@@ -2336,13 +2807,12 @@ var defaultProps$7 = {
|
|
|
2336
2807
|
};
|
|
2337
2808
|
|
|
2338
2809
|
var ScreensMenu = function ScreensMenu(_ref) {
|
|
2339
|
-
var
|
|
2810
|
+
var _ref8;
|
|
2340
2811
|
|
|
2341
2812
|
var items = _ref.items,
|
|
2342
2813
|
withPreview = _ref.withPreview,
|
|
2343
2814
|
withPlaceholder = _ref.withPlaceholder,
|
|
2344
2815
|
settings = _ref.settings,
|
|
2345
|
-
previewMinWidth = _ref.previewMinWidth,
|
|
2346
2816
|
isVertical = _ref.isVertical,
|
|
2347
2817
|
noWrap = _ref.noWrap,
|
|
2348
2818
|
className = _ref.className,
|
|
@@ -2353,78 +2823,31 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2353
2823
|
isTree = _ref.isTree,
|
|
2354
2824
|
onClickItem = _ref.onClickItem,
|
|
2355
2825
|
onOrderChange = _ref.onOrderChange;
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
itemWidth = _ref2$width === void 0 ? 0 : _ref2$width,
|
|
2369
|
-
_ref2$height = _ref2.height,
|
|
2370
|
-
itemHeight = _ref2$height === void 0 ? 0 : _ref2$height;
|
|
2371
|
-
|
|
2372
|
-
var ratio = itemHeight !== 0 && itemWidth !== 0 ? itemHeight / itemWidth : 2 / 3;
|
|
2373
|
-
|
|
2374
|
-
var _getSizeWithinBounds = getSizeWithinBounds(previewMinWidth, previewMinWidth * ratio, itemWidth, itemHeight),
|
|
2375
|
-
previewScale = _getSizeWithinBounds.scale;
|
|
2376
|
-
|
|
2377
|
-
return {
|
|
2378
|
-
width: previewMinWidth,
|
|
2379
|
-
height: previewMinWidth * ratio,
|
|
2380
|
-
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")")
|
|
2381
|
-
};
|
|
2382
|
-
}, [previewMinWidth, contentRect]);
|
|
2383
|
-
var treeStyle = useMemo(function () {
|
|
2384
|
-
var _ref3 = columnRect || {},
|
|
2385
|
-
_ref3$width = _ref3.width,
|
|
2386
|
-
itemWidth = _ref3$width === void 0 ? 0 : _ref3$width;
|
|
2387
|
-
|
|
2388
|
-
var itemHeight = itemWidth * 3 / 2;
|
|
2389
|
-
var ratio = itemHeight !== 0 && itemWidth !== 0 ? itemHeight / itemWidth : 0;
|
|
2390
|
-
|
|
2391
|
-
var _getSizeWithinBounds2 = getSizeWithinBounds(previewMinWidth, previewMinWidth * ratio, itemWidth, itemHeight),
|
|
2392
|
-
scaledWidth = _getSizeWithinBounds2.width,
|
|
2393
|
-
scaledHeight = _getSizeWithinBounds2.height,
|
|
2394
|
-
previewScale = _getSizeWithinBounds2.scale;
|
|
2395
|
-
|
|
2396
|
-
return {
|
|
2397
|
-
width: previewMinWidth,
|
|
2398
|
-
height: previewMinWidth * ratio,
|
|
2399
|
-
transform: "scale(".concat(previewScale, ", ").concat(previewScale, ")"),
|
|
2400
|
-
scale: previewScale,
|
|
2401
|
-
scaledWidth: scaledWidth,
|
|
2402
|
-
scaledHeight: scaledHeight
|
|
2403
|
-
};
|
|
2404
|
-
}, [previewMinWidth, columnRect]);
|
|
2405
|
-
var itemsElements = !isTree ? items.map(function (_ref4, index) {
|
|
2406
|
-
var _ref5;
|
|
2407
|
-
|
|
2408
|
-
var _ref4$className = _ref4.className,
|
|
2409
|
-
itemCustomClassName = _ref4$className === void 0 ? null : _ref4$className,
|
|
2410
|
-
screen = _ref4.screen,
|
|
2411
|
-
type = _ref4.type,
|
|
2412
|
-
_ref4$onClick = _ref4.onClick,
|
|
2413
|
-
onClick = _ref4$onClick === void 0 ? null : _ref4$onClick,
|
|
2414
|
-
item = _objectWithoutProperties(_ref4, _excluded$2);
|
|
2826
|
+
var itemsElements = !isTree ? items.map(function (_ref2, index) {
|
|
2827
|
+
var _ref3;
|
|
2828
|
+
|
|
2829
|
+
var _ref2$className = _ref2.className,
|
|
2830
|
+
itemCustomClassName = _ref2$className === void 0 ? null : _ref2$className,
|
|
2831
|
+
screen = _ref2.screen,
|
|
2832
|
+
type = _ref2.type,
|
|
2833
|
+
_ref2$onClick = _ref2.onClick,
|
|
2834
|
+
onClick = _ref2$onClick === void 0 ? null : _ref2$onClick,
|
|
2835
|
+
active = _ref2.active,
|
|
2836
|
+
href = _ref2.href,
|
|
2837
|
+
item = _objectWithoutProperties(_ref2, _excluded$2);
|
|
2415
2838
|
|
|
2416
2839
|
return /*#__PURE__*/React.createElement("li", {
|
|
2417
2840
|
key: item.id,
|
|
2418
|
-
className: classNames([styles$6.item, (
|
|
2419
|
-
"data-screen-id": item.id
|
|
2420
|
-
ref: index === 0 ? containerRef : null
|
|
2841
|
+
className: classNames([styles$6.item, (_ref3 = {}, _defineProperty(_ref3, itemClassName, itemClassName !== null), _defineProperty(_ref3, itemCustomClassName, itemCustomClassName !== null), _ref3)]),
|
|
2842
|
+
"data-screen-id": item.id
|
|
2421
2843
|
}, /*#__PURE__*/React.createElement(ScreenWithPreview, {
|
|
2422
2844
|
index: index,
|
|
2423
|
-
screen: _objectSpread(_objectSpread({}, screen),
|
|
2845
|
+
screen: withPlaceholder ? _objectSpread(_objectSpread({}, screen), {}, {
|
|
2424
2846
|
type: type
|
|
2425
|
-
} :
|
|
2426
|
-
|
|
2427
|
-
|
|
2847
|
+
}) : screen,
|
|
2848
|
+
href: href,
|
|
2849
|
+
className: buttonClassName,
|
|
2850
|
+
active: active,
|
|
2428
2851
|
withPreview: withPreview,
|
|
2429
2852
|
withPlaceholder: withPlaceholder,
|
|
2430
2853
|
onClick: onClick,
|
|
@@ -2434,44 +2857,44 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2434
2857
|
}, isFunction(settings) ? settings(index) : settings) : null);
|
|
2435
2858
|
}) : [];
|
|
2436
2859
|
var sortableItems = useMemo(function () {
|
|
2437
|
-
return isTree ? items.map(function (
|
|
2438
|
-
var id =
|
|
2439
|
-
|
|
2440
|
-
screen =
|
|
2441
|
-
|
|
2860
|
+
return isTree ? items.map(function (_ref5) {
|
|
2861
|
+
var id = _ref5.id,
|
|
2862
|
+
_ref5$screen = _ref5.screen,
|
|
2863
|
+
screen = _ref5$screen === void 0 ? {} : _ref5$screen,
|
|
2864
|
+
href = _ref5.href,
|
|
2865
|
+
props = _objectWithoutProperties(_ref5, _excluded2);
|
|
2442
2866
|
|
|
2443
2867
|
var _screen$parentId = screen.parentId,
|
|
2444
2868
|
parentId = _screen$parentId === void 0 ? null : _screen$parentId,
|
|
2445
2869
|
_screen$group = screen.group,
|
|
2446
2870
|
group = _screen$group === void 0 ? {} : _screen$group;
|
|
2447
2871
|
|
|
2448
|
-
var
|
|
2449
|
-
|
|
2450
|
-
collapsed =
|
|
2872
|
+
var _ref6 = group || {},
|
|
2873
|
+
_ref6$collapsed = _ref6.collapsed,
|
|
2874
|
+
collapsed = _ref6$collapsed === void 0 ? true : _ref6$collapsed;
|
|
2451
2875
|
|
|
2452
|
-
return
|
|
2876
|
+
return {
|
|
2453
2877
|
id: id,
|
|
2454
2878
|
parentId: parentId,
|
|
2455
2879
|
collapsed: collapsed,
|
|
2456
|
-
value: {
|
|
2880
|
+
value: _objectSpread({
|
|
2457
2881
|
id: id,
|
|
2458
|
-
screen: screen
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2882
|
+
screen: screen,
|
|
2883
|
+
href: href
|
|
2884
|
+
}, props)
|
|
2885
|
+
};
|
|
2886
|
+
}, []) : items.map(function (_ref7) {
|
|
2887
|
+
var id = _ref7.id;
|
|
2463
2888
|
return {
|
|
2464
2889
|
id: id
|
|
2465
2890
|
};
|
|
2466
2891
|
});
|
|
2467
|
-
}, [items, isTree]);
|
|
2892
|
+
}, [items, isTree, items.length]);
|
|
2468
2893
|
return /*#__PURE__*/React.createElement("div", {
|
|
2469
|
-
className: classNames([styles$6.container, (
|
|
2470
|
-
ref: columnRef
|
|
2894
|
+
className: classNames([styles$6.container, (_ref8 = {}, _defineProperty(_ref8, styles$6.noWrap, noWrap), _defineProperty(_ref8, styles$6.isVertical, isVertical), _defineProperty(_ref8, styles$6.isTree, isTree), _defineProperty(_ref8, styles$6.withPlaceholder, withPlaceholder), _defineProperty(_ref8, className, className), _ref8)])
|
|
2471
2895
|
}, isTree && !sortable ? /*#__PURE__*/React.createElement(SortableTree, {
|
|
2472
2896
|
items: sortableItems,
|
|
2473
2897
|
component: ScreenWithPreview,
|
|
2474
|
-
itemStyle: treeStyle,
|
|
2475
2898
|
onClickItem: onClickItem,
|
|
2476
2899
|
onChange: onOrderChange
|
|
2477
2900
|
}) : null, !isTree && sortable && items.length > 1 ? /*#__PURE__*/React.createElement(ReactSortable, {
|
|
@@ -2490,7 +2913,7 @@ var ScreensMenu = function ScreensMenu(_ref) {
|
|
|
2490
2913
|
ScreensMenu.propTypes = propTypes$7;
|
|
2491
2914
|
ScreensMenu.defaultProps = defaultProps$7;
|
|
2492
2915
|
|
|
2493
|
-
var styles$2 = {"container":"micromag-editor-menus-screen-types-container","row":"micromag-editor-menus-screen-types-row","title":"micromag-editor-menus-screen-types-title"};
|
|
2916
|
+
var styles$2 = {"container":"micromag-editor-menus-screen-types-container","row":"micromag-editor-menus-screen-types-row","title":"micromag-editor-menus-screen-types-title","screen":"micromag-editor-menus-screen-types-screen"};
|
|
2494
2917
|
|
|
2495
2918
|
var propTypes$6 = {
|
|
2496
2919
|
screens: PropTypes$1.screenDefinitions,
|
|
@@ -2586,13 +3009,12 @@ var ScreenTypes = function ScreenTypes(_ref) {
|
|
|
2586
3009
|
}, /*#__PURE__*/React.createElement(ScreensMenu, {
|
|
2587
3010
|
items: items,
|
|
2588
3011
|
withPlaceholder: true,
|
|
2589
|
-
itemClassName: classNames(['border', 'rounded', {
|
|
3012
|
+
itemClassName: classNames([styles$2.screen, 'border', 'rounded', {
|
|
2590
3013
|
'border-secondary': selectedTypes === null,
|
|
2591
3014
|
'border-dark': selectedTypes !== null,
|
|
2592
3015
|
'bg-secondary': selectedTypes === null,
|
|
2593
3016
|
'text-secondary': selectedTypes !== null
|
|
2594
3017
|
}]),
|
|
2595
|
-
previewMinWidth: 100,
|
|
2596
3018
|
onClickItem: onClickItem
|
|
2597
3019
|
})));
|
|
2598
3020
|
})));
|
|
@@ -2768,6 +3190,8 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
2768
3190
|
}, true);
|
|
2769
3191
|
|
|
2770
3192
|
if (!sameOrder || hasScreenProps) {
|
|
3193
|
+
console.log('order', ids);
|
|
3194
|
+
|
|
2771
3195
|
var newValue = _objectSpread(_objectSpread({}, value), {}, {
|
|
2772
3196
|
components: _toConsumableArray(currentScreens).sort(function (_ref13, _ref14) {
|
|
2773
3197
|
var idA = _ref13.id;
|
|
@@ -2821,7 +3245,8 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
2821
3245
|
}, [setCreateModalOpened]);
|
|
2822
3246
|
var onCreateModalRequestClose = useCallback(function () {
|
|
2823
3247
|
return setCreateModalOpened(false);
|
|
2824
|
-
}, [setCreateModalOpened]);
|
|
3248
|
+
}, [setCreateModalOpened]); // console.log(screens);
|
|
3249
|
+
|
|
2825
3250
|
return /*#__PURE__*/React.createElement("div", {
|
|
2826
3251
|
className: classNames(['d-flex', 'flex-column', styles$7.container, className])
|
|
2827
3252
|
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
@@ -2830,7 +3255,7 @@ var EditorScreens = function EditorScreens(_ref) {
|
|
|
2830
3255
|
withoutCollapse: true,
|
|
2831
3256
|
className: classNames(['sticky-top', styles$7.navbar])
|
|
2832
3257
|
}, /*#__PURE__*/React.createElement("strong", {
|
|
2833
|
-
className: "mb-0
|
|
3258
|
+
className: "mb-0 me-auto"
|
|
2834
3259
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
2835
3260
|
id: "jf+4Hq",
|
|
2836
3261
|
defaultMessage: [{
|
|
@@ -3030,21 +3455,21 @@ var Editor = function Editor(_ref) {
|
|
|
3030
3455
|
return /*#__PURE__*/React.createElement(ModalsProvider, null, /*#__PURE__*/React.createElement(PanelsProvider, null, /*#__PURE__*/React.createElement(ScreenSizeProvider, {
|
|
3031
3456
|
size: screenSize
|
|
3032
3457
|
}, /*#__PURE__*/React.createElement("div", {
|
|
3033
|
-
className: classNames([styles$
|
|
3034
|
-
return styles$
|
|
3035
|
-
}) : null, (_ref5 = {}, _defineProperty(_ref5, styles$
|
|
3458
|
+
className: classNames([styles$i.container, screenSize !== null ? screenSize.screens.map(function (screenName) {
|
|
3459
|
+
return styles$i["screen-".concat(screenName)];
|
|
3460
|
+
}) : null, (_ref5 = {}, _defineProperty(_ref5, styles$i.fullscreen, fullscreen), _defineProperty(_ref5, className, className), _ref5)]),
|
|
3036
3461
|
ref: refContainer
|
|
3037
3462
|
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
3038
3463
|
theme: "light",
|
|
3039
3464
|
compact: true,
|
|
3040
3465
|
noWrap: true,
|
|
3041
3466
|
withoutCollapse: true,
|
|
3042
|
-
className: styles$
|
|
3467
|
+
className: styles$i.top
|
|
3043
3468
|
}, mobileView !== 'screens' ? /*#__PURE__*/React.createElement(Button, {
|
|
3044
3469
|
size: "sm",
|
|
3045
3470
|
theme: "secondary",
|
|
3046
3471
|
onClick: onClickScreens,
|
|
3047
|
-
className: "
|
|
3472
|
+
className: "me-auto"
|
|
3048
3473
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
3049
3474
|
id: "wkysUu",
|
|
3050
3475
|
defaultMessage: [{
|
|
@@ -3072,9 +3497,9 @@ var Editor = function Editor(_ref) {
|
|
|
3072
3497
|
"value": "View screen"
|
|
3073
3498
|
}]
|
|
3074
3499
|
})) : null), /*#__PURE__*/React.createElement("div", {
|
|
3075
|
-
className: styles$
|
|
3500
|
+
className: styles$i.inner
|
|
3076
3501
|
}, /*#__PURE__*/React.createElement("div", {
|
|
3077
|
-
className: classNames([styles$
|
|
3502
|
+
className: classNames([styles$i.left, _defineProperty({}, styles$i.visible, !isMobile || mobileView === 'screens')]),
|
|
3078
3503
|
ref: refScreensContainer
|
|
3079
3504
|
}, /*#__PURE__*/React.createElement(EditorScreens, {
|
|
3080
3505
|
value: story,
|
|
@@ -3084,24 +3509,25 @@ var Editor = function Editor(_ref) {
|
|
|
3084
3509
|
onChange: onStoryChange,
|
|
3085
3510
|
onClickScreen: onClickScreen,
|
|
3086
3511
|
isVertical: !isMobile,
|
|
3087
|
-
className: styles$
|
|
3512
|
+
className: styles$i.inner,
|
|
3088
3513
|
isTree: true
|
|
3089
3514
|
})), /*#__PURE__*/React.createElement("div", {
|
|
3090
|
-
className: classNames([styles$
|
|
3515
|
+
className: classNames([styles$i.center, _defineProperty({}, styles$i.visible, !isMobile || mobileView === 'preview')])
|
|
3091
3516
|
}, /*#__PURE__*/React.createElement(EditorPreview, {
|
|
3092
3517
|
value: story,
|
|
3093
3518
|
isTheme: isTheme,
|
|
3094
3519
|
viewerTheme: viewerTheme,
|
|
3095
|
-
className: styles$
|
|
3096
|
-
onScreenChange: onPreviewScreenChange
|
|
3520
|
+
className: styles$i.preview,
|
|
3521
|
+
onScreenChange: onPreviewScreenChange,
|
|
3522
|
+
onChange: onStoryChange
|
|
3097
3523
|
})), /*#__PURE__*/React.createElement("div", {
|
|
3098
|
-
className: classNames([styles$
|
|
3524
|
+
className: classNames([styles$i.right, _defineProperty({}, styles$i.visible, !isMobile || mobileView === 'form')])
|
|
3099
3525
|
}, /*#__PURE__*/React.createElement(EditForm, {
|
|
3100
3526
|
key: screenId,
|
|
3101
3527
|
value: story,
|
|
3102
3528
|
isTheme: isTheme,
|
|
3103
3529
|
onChange: onStoryChange,
|
|
3104
|
-
className: styles$
|
|
3530
|
+
className: styles$i.inner
|
|
3105
3531
|
}))), /*#__PURE__*/React.createElement(Modals, null)))));
|
|
3106
3532
|
};
|
|
3107
3533
|
|