@micromag/editor 0.3.454 → 0.3.457

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.
@@ -5,7 +5,7 @@
5
5
  .micromag-editor-menus-devices-container{display:inline-block;position:relative}.micromag-editor-menus-devices-container .micromag-editor-menus-devices-button{display:block;height:30px;padding:5px;width:40px}
6
6
  .micromag-editor-buttons-device-container .micromag-editor-buttons-device-icon{display:block;height:auto;max-height:100%;width:100%}
7
7
  .micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;font-family:inherit;padding:0;position:relative}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-border,.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-button,.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-screen .micromag-editor-buttons-screen-inner{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-editor-buttons-screen-container{overflow:hidden;position:relative}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-button{display:inline-block;position:absolute!important}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-border{display:block}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-screen{display:block;height:0;padding-bottom:150%;pointer-events:none;position:relative;width:100%}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-screen .micromag-editor-buttons-screen-inner{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;justify-content:center}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-screen .micromag-editor-buttons-screen-icon{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;position:relative;width:100%}.micromag-editor-buttons-screen-container .micromag-editor-buttons-screen-screen .micromag-editor-buttons-screen-label{font-size:.75rem;font-weight:700;padding:5px 0}.micromag-editor-buttons-screen-container.micromag-editor-buttons-screen-active .micromag-editor-buttons-screen-border{border:3px solid #a13dff;z-index:2}
8
- .micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-index,.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-name{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-editor-buttons-screen-with-preview-button{display:block;position:relative;-webkit-transition:-webkit-filter .2s ease;transition:-webkit-filter .2s ease;transition:filter .2s ease;transition:filter .2s ease,-webkit-filter .2s ease}.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-index{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:rgba(0,0,0,.4);color:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:1.25rem;justify-content:center;opacity:0;pointer-events:none;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;z-index:1}.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-name{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:hsla(0,0%,100%,.6);color:#000!important;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:.8rem;justify-content:center;opacity:0;padding:5px;pointer-events:none;text-align:center;text-shadow:1px solid #000;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;word-break:break-word;z-index:1}.micromag-editor-buttons-screen-with-preview-button:hover{-webkit-filter:grayscale(.5);filter:grayscale(.5)}.micromag-editor-buttons-screen-with-preview-button.micromag-editor-buttons-screen-with-preview-withIndex:hover .micromag-editor-buttons-screen-with-preview-index,.micromag-editor-buttons-screen-with-preview-button.micromag-editor-buttons-screen-with-preview-withIndex:hover .micromag-editor-buttons-screen-with-preview-name{opacity:1}
8
+ .micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-index,.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-name{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-editor-buttons-screen-with-preview-button{display:block;position:relative;-webkit-transition:-webkit-filter .2s ease;transition:-webkit-filter .2s ease;transition:filter .2s ease;transition:filter .2s ease,-webkit-filter .2s ease}.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-index{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:rgba(0,0,0,.4);color:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:1.25rem;justify-content:center;opacity:0;pointer-events:none;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;z-index:1}.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-name{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:hsla(0,0%,100%,.6);color:#000!important;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:.8rem;justify-content:center;opacity:0;padding:5px;pointer-events:none;text-align:center;text-shadow:1px solid #000;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;word-break:break-word;z-index:1}.micromag-editor-buttons-screen-with-preview-button .micromag-editor-buttons-screen-with-preview-deleteButton{cursor:pointer;font-size:.9em;font-weight:600;opacity:0;position:absolute;right:11%;top:4%;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;z-index:3}.micromag-editor-buttons-screen-with-preview-button:hover{-webkit-filter:grayscale(.5);filter:grayscale(.5)}.micromag-editor-buttons-screen-with-preview-button.micromag-editor-buttons-screen-with-preview-withIndex:hover .micromag-editor-buttons-screen-with-preview-deleteButton,.micromag-editor-buttons-screen-with-preview-button.micromag-editor-buttons-screen-with-preview-withIndex:hover .micromag-editor-buttons-screen-with-preview-index,.micromag-editor-buttons-screen-with-preview-button.micromag-editor-buttons-screen-with-preview-withIndex:hover .micromag-editor-buttons-screen-with-preview-name{opacity:1}
9
9
  .micromag-editor-partials-screen-states-container{display:inline-block}.micromag-editor-partials-screen-states-button{min-height:75px;width:50px}.micromag-editor-partials-screen-states-button.btn-outline-secondary{border-color:#6c6c6c;color:#6c6c6c}.micromag-editor-partials-screen-states-button.btn-outline-secondary:hover{background:transparent;border-color:#e9e9e9;color:#e9e9e9}.micromag-editor-partials-screen-states-addButton{border-style:dashed}.micromag-editor-partials-screen-states-title{font-size:.75em;padding:0 .2em;text-align:left}
10
10
  .micromag-editor-preview-container .micromag-editor-preview-noStory,.micromag-editor-preview-container .micromag-editor-preview-story{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-editor-preview-container{position:relative}.micromag-editor-preview-container>.micromag-editor-preview-inner{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;height:100%}.micromag-editor-preview-container .micromag-editor-preview-top{display:none;padding:20px 0;width:100%}.micromag-editor-preview-container .micromag-editor-preview-bottom{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-flex:1;-ms-flex-positive:1;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;flex-grow:1;max-width:100%;overflow:hidden;padding:0;width:100%}.micromag-editor-preview-container .micromag-editor-preview-bottom>.micromag-editor-preview-inner{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-flex:1;-ms-flex-positive:1;-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;flex-grow:1;justify-content:center;margin:0 auto;overflow:hidden;width:100%}.micromag-editor-preview-container .micromag-editor-preview-preview{height:100%;position:relative;-webkit-transform-origin:50% 50%;-ms-transform-origin:50% 50%;transform-origin:50% 50%;width:100%}.micromag-editor-preview-container .micromag-editor-preview-viewerContainer{height:100%;position:relative}.micromag-editor-preview-container .micromag-editor-preview-devices{bottom:10px;position:absolute;right:10px}.micromag-editor-preview-screen-medium .micromag-editor-preview-top{display:block;overflow-x:auto;text-align:center;width:100%}.micromag-editor-preview-screen-medium .micromag-editor-preview-bottom{padding:50px 20px}
11
11
  .micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;position:relative}.micromag-editor-sortable-sortable-tree-item-actions-wrapper{border-radius:4px;-webkit-box-sizing:border-box;box-sizing:border-box;list-style:none}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner{-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:#222;display:-webkit-box;display:-ms-flexbox;display:flex;height:100%;position:relative;width:100%;z-index:1}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-button{background-color:transparent;color:#fff}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-handle{border-radius:10px;height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-handle .micromag-editor-sortable-sortable-tree-item-actions-icon{display:none;left:10px;position:absolute;top:10px;visibility:hidden}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-text{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;overflow:hidden;padding-left:.5rem;text-overflow:ellipsis;white-space:nowrap}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-collapsedCount,.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-count{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:#a13dff;border-radius:50%;color:#fff;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:.8rem;font-weight:600;height:24px;justify-content:center;position:absolute;right:-10px;top:-10px;width:24px}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-collapsedCount{background-color:transparent;bottom:2px;right:3px;top:auto}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-disableInteraction{pointer-events:none}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-clone .micromag-editor-sortable-sortable-tree-item-actions-count,.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-clone .micromag-editor-sortable-sortable-tree-item-actions-text,.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-disableSelection .micromag-editor-sortable-sortable-tree-item-actions-count,.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-disableSelection .micromag-editor-sortable-sortable-tree-item-actions-text{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-collapse{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:justify;-ms-flex-pack:justify;align-items:center;bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;height:30px;justify-content:space-between;left:0;position:absolute;width:100%;z-index:1}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-collapse svg{margin-left:10px;-webkit-transition:-webkit-transform .25s ease;transition:-webkit-transform .25s ease;transition:transform .25s ease;transition:transform .25s ease,-webkit-transform .25s ease}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-inner .micromag-editor-sortable-sortable-tree-item-actions-collapse.micromag-editor-sortable-sortable-tree-item-actions-collapsed svg{-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.micromag-editor-sortable-sortable-tree-item-actions-wrapper .micromag-editor-sortable-sortable-tree-item-actions-children{position:relative;width:100%;z-index:0}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-withChildren{background-color:#494949}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-withChildren .micromag-editor-sortable-sortable-tree-item-actions-inner{padding-bottom:30px}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-clone{display:block;margin-left:10px;margin-top:5px;padding:0;pointer-events:none;width:100%}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-clone .micromag-editor-sortable-sortable-tree-item-actions-inner{border-radius:10px;-webkit-box-shadow:0 15px 15px 0 rgba(34,33,81,.1);box-shadow:0 15px 15px 0 rgba(34,33,81,.1);padding-right:24px}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-ghost:not(.micromag-editor-sortable-sortable-tree-item-actions-indicator){-webkit-filter:opacity(.6);filter:opacity(.6)}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-ghost .micromag-editor-sortable-sortable-tree-item-actions-inner>*{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-ghost .micromag-editor-sortable-sortable-tree-item-actions-inner{border:1px solid #a13dff;border-radius:4px}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-ghost.micromag-editor-sortable-sortable-tree-item-actions-indicator{margin-bottom:-1px;opacity:1;position:relative;z-index:1}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-ghost.micromag-editor-sortable-sortable-tree-item-actions-indicator .micromag-editor-sortable-sortable-tree-item-actions-inner{background-color:#a13dff;border:1px solid #a13dff;border-radius:10px;height:8px;padding:0;position:relative}.micromag-editor-sortable-sortable-tree-item-actions-wrapper.micromag-editor-sortable-sortable-tree-item-actions-ghost.micromag-editor-sortable-sortable-tree-item-actions-indicator .micromag-editor-sortable-sortable-tree-item-actions-inner>*{height:0;opacity:0}
package/es/index.js CHANGED
@@ -27,6 +27,7 @@ import { getSizeWithinBounds } from '@folklore/size';
27
27
  import { Viewer } from '@micromag/viewer';
28
28
  import _toArray from '@babel/runtime/helpers/toArray';
29
29
  import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
30
+ import { faTimesCircle } from '@fortawesome/free-solid-svg-icons/faTimesCircle';
30
31
  import isFunction from 'lodash/isFunction';
31
32
  import { ReactSortable } from 'react-sortablejs';
32
33
  import { KeyboardCode, closestCorners, getFirstCollision, getClientRect, MeasuringStrategy, defaultDropAnimation, useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, DragOverlay } from '@dnd-kit/core';
@@ -1175,7 +1176,7 @@ var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
1175
1176
  }));
1176
1177
  });
1177
1178
 
1178
- var styles$b = {"button":"micromag-editor-buttons-screen-with-preview-button","name":"micromag-editor-buttons-screen-with-preview-name","index":"micromag-editor-buttons-screen-with-preview-index","withIndex":"micromag-editor-buttons-screen-with-preview-withIndex"};
1179
+ var styles$b = {"button":"micromag-editor-buttons-screen-with-preview-button","name":"micromag-editor-buttons-screen-with-preview-name","index":"micromag-editor-buttons-screen-with-preview-index","deleteButton":"micromag-editor-buttons-screen-with-preview-deleteButton","withIndex":"micromag-editor-buttons-screen-with-preview-withIndex"};
1179
1180
 
1180
1181
  var propTypes$d = {
1181
1182
  screen: PropTypes$1.screenComponent,
@@ -1187,8 +1188,10 @@ var propTypes$d = {
1187
1188
  withPlaceholder: PropTypes.bool,
1188
1189
  withIndexIndicator: PropTypes.bool,
1189
1190
  withName: PropTypes.bool,
1191
+ withDeleteButtonOnRepeatables: PropTypes.bool,
1190
1192
  onClick: PropTypes.func,
1191
1193
  onClickItem: PropTypes.func,
1194
+ onDeleteButtonClick: PropTypes.func,
1192
1195
  className: PropTypes.string
1193
1196
  };
1194
1197
  var defaultProps$d = {
@@ -1200,8 +1203,10 @@ var defaultProps$d = {
1200
1203
  withPlaceholder: false,
1201
1204
  withIndexIndicator: false,
1202
1205
  withName: false,
1206
+ withDeleteButtonOnRepeatables: false,
1203
1207
  onClick: null,
1204
1208
  onClickItem: null,
1209
+ onDeleteButtonClick: null,
1205
1210
  className: null
1206
1211
  };
1207
1212
  var ScreenWithPreview = function ScreenWithPreview(_ref) {
@@ -1216,7 +1221,9 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
1216
1221
  onClickItem = _ref.onClickItem,
1217
1222
  withName = _ref.withName,
1218
1223
  withPlaceholder = _ref.withPlaceholder,
1219
- withIndexIndicator = _ref.withIndexIndicator;
1224
+ withIndexIndicator = _ref.withIndexIndicator,
1225
+ withDeleteButtonOnRepeatables = _ref.withDeleteButtonOnRepeatables,
1226
+ onDeleteButtonClick = _ref.onDeleteButtonClick;
1220
1227
  var intl = useIntl();
1221
1228
  var _useIsVisible = useIsVisible({
1222
1229
  threshold: 0.1
@@ -1250,7 +1257,12 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
1250
1257
  className: styles$b.index
1251
1258
  }, index + 1) : null, withName && !withIndexIndicator ? /*#__PURE__*/React.createElement("div", {
1252
1259
  className: styles$b.name
1253
- }, finalTitle || null) : null));
1260
+ }, finalTitle || null) : null, withDeleteButtonOnRepeatables ? /*#__PURE__*/React.createElement("div", {
1261
+ className: styles$b.deleteButton,
1262
+ onClick: onDeleteButtonClick
1263
+ }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
1264
+ icon: faTimesCircle
1265
+ })) : null));
1254
1266
  };
1255
1267
  ScreenWithPreview.propTypes = propTypes$d;
1256
1268
  ScreenWithPreview.defaultProps = defaultProps$d;
@@ -1345,6 +1357,28 @@ function ScreenStates(_ref) {
1345
1357
  field: [id, currentFieldValue.length]
1346
1358
  });
1347
1359
  };
1360
+ var onClickDelete = function onClickDelete(indexToDelete) {
1361
+ var _ref8 = value || {},
1362
+ _ref8$components = _ref8.components,
1363
+ currentComponentsValue = _ref8$components === void 0 ? [] : _ref8$components;
1364
+ var currentScreenIndex = currentComponentsValue.findIndex(function (_ref9) {
1365
+ var screenId = _ref9.id;
1366
+ return screen.id === screenId;
1367
+ });
1368
+ var currentScreenValue = currentComponentsValue[currentScreenIndex] || {};
1369
+ currentScreenValue[fieldName || id] || [];
1370
+ var newValue = _objectSpread(_objectSpread({}, value), {}, {
1371
+ components: [].concat(_toConsumableArray(currentComponentsValue.slice(0, currentScreenIndex)), [_objectSpread(_objectSpread({}, currentScreenValue), {}, _defineProperty({}, fieldName || id, (currentScreenValue[fieldName || id] || []).filter(function (_, index) {
1372
+ return index !== indexToDelete;
1373
+ })))], _toConsumableArray(currentComponentsValue.slice(currentScreenIndex + 1)))
1374
+ });
1375
+ if (onChange !== null) {
1376
+ onChange(newValue);
1377
+ }
1378
+ push('screen', {
1379
+ screen: screen.id
1380
+ });
1381
+ };
1348
1382
  return /*#__PURE__*/React.createElement("div", {
1349
1383
  className: "p-1 align-self-stretch d-flex flex-column"
1350
1384
  }, /*#__PURE__*/React.createElement("h6", {
@@ -1357,6 +1391,7 @@ function ScreenStates(_ref) {
1357
1391
  }, /*#__PURE__*/React.createElement(ScreenWithPreview, {
1358
1392
  index: index,
1359
1393
  withIndexIndicator: true,
1394
+ withDeleteButtonOnRepeatables: true,
1360
1395
  screen: screen,
1361
1396
  screenState: "".concat(id, ".").concat(index),
1362
1397
  className: styles$a.button,
@@ -1364,7 +1399,10 @@ function ScreenStates(_ref) {
1364
1399
  href: url('screen.field', {
1365
1400
  screen: screen.id,
1366
1401
  field: [id, index]
1367
- })
1402
+ }),
1403
+ onDeleteButtonClick: function onDeleteButtonClick() {
1404
+ return onClickDelete(index);
1405
+ }
1368
1406
  }));
1369
1407
  }), !withoutCreate ? /*#__PURE__*/React.createElement("li", {
1370
1408
  className: "p-1"
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ var size = require('@folklore/size');
31
31
  var viewer = require('@micromag/viewer');
32
32
  var _toArray = require('@babel/runtime/helpers/toArray');
33
33
  var faPlus = require('@fortawesome/free-solid-svg-icons/faPlus');
34
+ var faTimesCircle = require('@fortawesome/free-solid-svg-icons/faTimesCircle');
34
35
  var isFunction = require('lodash/isFunction');
35
36
  var reactSortablejs = require('react-sortablejs');
36
37
  var core$1 = require('@dnd-kit/core');
@@ -1179,7 +1180,7 @@ var ScreenButton$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
1179
1180
  }));
1180
1181
  });
1181
1182
 
1182
- var styles$b = {"button":"micromag-editor-buttons-screen-with-preview-button","name":"micromag-editor-buttons-screen-with-preview-name","index":"micromag-editor-buttons-screen-with-preview-index","withIndex":"micromag-editor-buttons-screen-with-preview-withIndex"};
1183
+ var styles$b = {"button":"micromag-editor-buttons-screen-with-preview-button","name":"micromag-editor-buttons-screen-with-preview-name","index":"micromag-editor-buttons-screen-with-preview-index","deleteButton":"micromag-editor-buttons-screen-with-preview-deleteButton","withIndex":"micromag-editor-buttons-screen-with-preview-withIndex"};
1183
1184
 
1184
1185
  var propTypes$d = {
1185
1186
  screen: core.PropTypes.screenComponent,
@@ -1191,8 +1192,10 @@ var propTypes$d = {
1191
1192
  withPlaceholder: PropTypes.bool,
1192
1193
  withIndexIndicator: PropTypes.bool,
1193
1194
  withName: PropTypes.bool,
1195
+ withDeleteButtonOnRepeatables: PropTypes.bool,
1194
1196
  onClick: PropTypes.func,
1195
1197
  onClickItem: PropTypes.func,
1198
+ onDeleteButtonClick: PropTypes.func,
1196
1199
  className: PropTypes.string
1197
1200
  };
1198
1201
  var defaultProps$d = {
@@ -1204,8 +1207,10 @@ var defaultProps$d = {
1204
1207
  withPlaceholder: false,
1205
1208
  withIndexIndicator: false,
1206
1209
  withName: false,
1210
+ withDeleteButtonOnRepeatables: false,
1207
1211
  onClick: null,
1208
1212
  onClickItem: null,
1213
+ onDeleteButtonClick: null,
1209
1214
  className: null
1210
1215
  };
1211
1216
  var ScreenWithPreview = function ScreenWithPreview(_ref) {
@@ -1220,7 +1225,9 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
1220
1225
  onClickItem = _ref.onClickItem,
1221
1226
  withName = _ref.withName,
1222
1227
  withPlaceholder = _ref.withPlaceholder,
1223
- withIndexIndicator = _ref.withIndexIndicator;
1228
+ withIndexIndicator = _ref.withIndexIndicator,
1229
+ withDeleteButtonOnRepeatables = _ref.withDeleteButtonOnRepeatables,
1230
+ onDeleteButtonClick = _ref.onDeleteButtonClick;
1224
1231
  var intl = reactIntl.useIntl();
1225
1232
  var _useIsVisible = hooks.useIsVisible({
1226
1233
  threshold: 0.1
@@ -1254,7 +1261,12 @@ var ScreenWithPreview = function ScreenWithPreview(_ref) {
1254
1261
  className: styles$b.index
1255
1262
  }, index + 1) : null, withName && !withIndexIndicator ? /*#__PURE__*/React.createElement("div", {
1256
1263
  className: styles$b.name
1257
- }, finalTitle || null) : null));
1264
+ }, finalTitle || null) : null, withDeleteButtonOnRepeatables ? /*#__PURE__*/React.createElement("div", {
1265
+ className: styles$b.deleteButton,
1266
+ onClick: onDeleteButtonClick
1267
+ }, /*#__PURE__*/React.createElement(reactFontawesome.FontAwesomeIcon, {
1268
+ icon: faTimesCircle.faTimesCircle
1269
+ })) : null));
1258
1270
  };
1259
1271
  ScreenWithPreview.propTypes = propTypes$d;
1260
1272
  ScreenWithPreview.defaultProps = defaultProps$d;
@@ -1349,6 +1361,28 @@ function ScreenStates(_ref) {
1349
1361
  field: [id, currentFieldValue.length]
1350
1362
  });
1351
1363
  };
1364
+ var onClickDelete = function onClickDelete(indexToDelete) {
1365
+ var _ref8 = value || {},
1366
+ _ref8$components = _ref8.components,
1367
+ currentComponentsValue = _ref8$components === void 0 ? [] : _ref8$components;
1368
+ var currentScreenIndex = currentComponentsValue.findIndex(function (_ref9) {
1369
+ var screenId = _ref9.id;
1370
+ return screen.id === screenId;
1371
+ });
1372
+ var currentScreenValue = currentComponentsValue[currentScreenIndex] || {};
1373
+ currentScreenValue[fieldName || id] || [];
1374
+ var newValue = _objectSpread(_objectSpread({}, value), {}, {
1375
+ components: [].concat(_toConsumableArray(currentComponentsValue.slice(0, currentScreenIndex)), [_objectSpread(_objectSpread({}, currentScreenValue), {}, _defineProperty({}, fieldName || id, (currentScreenValue[fieldName || id] || []).filter(function (_, index) {
1376
+ return index !== indexToDelete;
1377
+ })))], _toConsumableArray(currentComponentsValue.slice(currentScreenIndex + 1)))
1378
+ });
1379
+ if (onChange !== null) {
1380
+ onChange(newValue);
1381
+ }
1382
+ push('screen', {
1383
+ screen: screen.id
1384
+ });
1385
+ };
1352
1386
  return /*#__PURE__*/React.createElement("div", {
1353
1387
  className: "p-1 align-self-stretch d-flex flex-column"
1354
1388
  }, /*#__PURE__*/React.createElement("h6", {
@@ -1361,6 +1395,7 @@ function ScreenStates(_ref) {
1361
1395
  }, /*#__PURE__*/React.createElement(ScreenWithPreview, {
1362
1396
  index: index,
1363
1397
  withIndexIndicator: true,
1398
+ withDeleteButtonOnRepeatables: true,
1364
1399
  screen: screen,
1365
1400
  screenState: "".concat(id, ".").concat(index),
1366
1401
  className: styles$a.button,
@@ -1368,7 +1403,10 @@ function ScreenStates(_ref) {
1368
1403
  href: url('screen.field', {
1369
1404
  screen: screen.id,
1370
1405
  field: [id, index]
1371
- })
1406
+ }),
1407
+ onDeleteButtonClick: function onDeleteButtonClick() {
1408
+ return onClickDelete(index);
1409
+ }
1372
1410
  }));
1373
1411
  }), !withoutCreate ? /*#__PURE__*/React.createElement("li", {
1374
1412
  className: "p-1"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/editor",
3
- "version": "0.3.454",
3
+ "version": "0.3.457",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -69,11 +69,11 @@
69
69
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
70
70
  "@fortawesome/free-solid-svg-icons": "^5.15.1",
71
71
  "@fortawesome/react-fontawesome": "^0.1.13",
72
- "@micromag/core": "^0.3.454",
73
- "@micromag/elements": "^0.3.454",
74
- "@micromag/fields": "^0.3.454",
75
- "@micromag/screens": "^0.3.454",
76
- "@micromag/viewer": "^0.3.454",
72
+ "@micromag/core": "^0.3.456",
73
+ "@micromag/elements": "^0.3.456",
74
+ "@micromag/fields": "^0.3.457",
75
+ "@micromag/screens": "^0.3.457",
76
+ "@micromag/viewer": "^0.3.457",
77
77
  "classnames": "^2.2.6",
78
78
  "lodash": "^4.17.21",
79
79
  "prop-types": "^15.7.2",
@@ -89,5 +89,5 @@
89
89
  "access": "public",
90
90
  "registry": "https://registry.npmjs.org/"
91
91
  },
92
- "gitHead": "f5cd283e3d266f5c970ae53b9df9bcd4b425985d"
92
+ "gitHead": "260b51e232a7be8655e03ebb53fa1c31cf74db78"
93
93
  }