microboard-ui-temp 0.1.15 → 0.1.17

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 +37 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -230160,6 +230160,14 @@ class BaseItem extends Mbr {
230160
230160
  this.apply(operation);
230161
230161
  }
230162
230162
  }
230163
+ emitForManyItems(operation) {
230164
+ if (!this.board.events) {
230165
+ return;
230166
+ }
230167
+ const command = createCommand(this.board, operation);
230168
+ command.apply();
230169
+ this.board.events.emit(operation, command);
230170
+ }
230163
230171
  apply(op) {
230164
230172
  op = op;
230165
230173
  switch (op.class) {
@@ -255956,14 +255964,34 @@ class Card extends BaseItem {
255956
255964
  this.subject.publish(this);
255957
255965
  return this;
255958
255966
  }
255959
- toggleIsOpen() {
255960
- this.emit({
255961
- class: "Card",
255962
- method: "setIsOpen",
255963
- item: [this.getId()],
255964
- newData: { isOpen: !this.isOpen },
255965
- prevData: { isOpen: this.isOpen }
255966
- });
255967
+ toggleIsOpen(cards) {
255968
+ const openedCardIds = [];
255969
+ const closedCardIds = [];
255970
+ for (const card of cards) {
255971
+ if (card.isOpen) {
255972
+ openedCardIds.push(card.getId());
255973
+ } else {
255974
+ closedCardIds.push(card.getId());
255975
+ }
255976
+ }
255977
+ if (openedCardIds.length) {
255978
+ this.emitForManyItems({
255979
+ class: "Card",
255980
+ method: "setIsOpen",
255981
+ item: openedCardIds,
255982
+ newData: { isOpen: false },
255983
+ prevData: { isOpen: true }
255984
+ });
255985
+ }
255986
+ if (closedCardIds.length) {
255987
+ this.emitForManyItems({
255988
+ class: "Card",
255989
+ method: "setIsOpen",
255990
+ item: closedCardIds,
255991
+ newData: { isOpen: true },
255992
+ prevData: { isOpen: false }
255993
+ });
255994
+ }
255967
255995
  }
255968
255996
  apply(op) {
255969
255997
  super.apply(op);
@@ -356000,9 +356028,7 @@ function FlipCard({ rounded = "none" }) {
356000
356028
  const { t: t10 } = useTranslation();
356001
356029
  const handleClick = () => {
356002
356030
  const cards = board.selection.items.list();
356003
- cards.forEach((card) => {
356004
- card.toggleIsOpen();
356005
- });
356031
+ cards[0].toggleIsOpen(cards);
356006
356032
  };
356007
356033
  return /* @__PURE__ */ import_react284.default.createElement(UiButton, {
356008
356034
  className: ContextPanelButton_module_default.contextPanelButton,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-ui-temp",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
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.5.0",
54
+ "microboard-temp": "^0.5.2",
55
55
  "nanoid": "^5.1.5",
56
56
  "prop-types": "^15.8.1",
57
57
  "react-hot-toast": "2.4.1",