microboard-ui-temp 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -15
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -227976,11 +227976,13 @@ class AudioCommand {
227976
227976
  }
227977
227977
 
227978
227978
  class BaseCommand {
227979
- items;
227979
+ board;
227980
+ itemIds;
227980
227981
  operation;
227981
227982
  reverse;
227982
- constructor(items, operation) {
227983
- this.items = items;
227983
+ constructor(board, itemIds, operation) {
227984
+ this.board = board;
227985
+ this.itemIds = itemIds;
227984
227986
  this.operation = operation;
227985
227987
  this.reverse = this.getReverse();
227986
227988
  }
@@ -227989,49 +227991,57 @@ class BaseCommand {
227989
227991
  return this;
227990
227992
  }
227991
227993
  apply() {
227992
- for (const item of this.items) {
227994
+ for (const itemId of this.itemIds) {
227995
+ const item = this.board.items.getById(itemId);
227996
+ if (!item) {
227997
+ continue;
227998
+ }
227993
227999
  item.apply(this.operation);
227994
228000
  }
227995
228001
  }
227996
228002
  revert() {
227997
- for (const { item, operation } of this.reverse) {
228003
+ for (const { itemId, operation } of this.reverse) {
228004
+ const item = this.board.items.getById(itemId);
228005
+ if (!item) {
228006
+ continue;
228007
+ }
227998
228008
  item.apply(operation);
227999
228009
  }
228000
228010
  }
228001
228011
  getReverse() {
228002
- const items = this.items;
228003
228012
  switch (this.operation.method) {
228004
228013
  case "addChildren":
228005
- return items.map((item) => {
228006
- return { item, operation: {
228014
+ return this.itemIds.map((itemId) => {
228015
+ return { itemId, operation: {
228007
228016
  ...this.operation,
228008
228017
  method: "removeChildren"
228009
228018
  } };
228010
228019
  });
228011
228020
  case "removeChildren":
228012
- return items.map((item) => {
228013
- return { item, operation: {
228021
+ return this.itemIds.map((itemId) => {
228022
+ return { itemId, operation: {
228014
228023
  ...this.operation,
228015
228024
  method: "addChildren"
228016
228025
  } };
228017
228026
  });
228018
228027
  default:
228019
- return mapItemsByOperation(items, (item) => {
228028
+ return this.itemIds.map((itemId) => {
228020
228029
  const op = this.operation;
228021
228030
  let newData = {};
228022
228031
  if (op.prevData) {
228023
228032
  newData = { ...op.prevData };
228024
228033
  } else {
228034
+ const item = this.board.items.getById(itemId);
228025
228035
  Object.keys(op.newData).forEach((key) => {
228026
228036
  if (item[key]) {
228027
228037
  newData[key] = item[key];
228028
228038
  }
228029
228039
  });
228030
228040
  }
228031
- return {
228041
+ return { itemId, operation: {
228032
228042
  ...op,
228033
228043
  newData
228034
- };
228044
+ } };
228035
228045
  });
228036
228046
  }
228037
228047
  }
@@ -255532,8 +255542,8 @@ function createItemValidator(defaultData2) {
255532
255542
  };
255533
255543
  }
255534
255544
  function createItemCommandFactory(itemType) {
255535
- return function itemCommandFactory(items, operation) {
255536
- return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
255545
+ return function itemCommandFactory(items, operation, board) {
255546
+ return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
255537
255547
  };
255538
255548
  }
255539
255549
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-ui-temp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  "i18next-browser-languagedetector": "^8.2.0",
52
52
  "js-cookie": "^3.0.5",
53
53
  "jwt-decode": "^4.0.0",
54
- "microboard-temp": "^0.4.100",
54
+ "microboard-temp": "^0.4.101",
55
55
  "nanoid": "^5.1.5",
56
56
  "prop-types": "^15.8.1",
57
57
  "react-hot-toast": "2.4.1",