microboard-ui-temp 0.1.86 → 0.1.87

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/dist/index.js CHANGED
@@ -215914,7 +215914,7 @@ var conf = {
215914
215914
  FALLBACK_LNG: "en",
215915
215915
  cursorsMap,
215916
215916
  DECK_HORIZONTAL_OFFSET: 2,
215917
- DECK_VERTICAL_OFFSET: 0,
215917
+ DECK_VERTICAL_OFFSET: 2,
215918
215918
  CARD_DIMENSIONS: { width: 250, height: 400 }
215919
215919
  };
215920
215920
  initDefaultI18N();
@@ -250302,6 +250302,14 @@ class ImageItem extends BaseItem {
250302
250302
  const ctx = context.ctx;
250303
250303
  ctx.save();
250304
250304
  this.transformation.matrix.applyToContext(ctx);
250305
+ const rotation = this.transformation.getRotation();
250306
+ if (rotation !== 0) {
250307
+ const imgWidth = this.image.width || 0;
250308
+ const imgHeight = this.image.height || 0;
250309
+ ctx.translate(imgWidth / 2, imgHeight / 2);
250310
+ ctx.rotate(rotation * Math.PI / 180);
250311
+ ctx.translate(-imgWidth / 2, -imgHeight / 2);
250312
+ }
250305
250313
  ctx.drawImage(this.image, 0, 0);
250306
250314
  ctx.restore();
250307
250315
  if (this.getLinkTo()) {
@@ -255904,6 +255912,9 @@ class Card extends BaseItem {
255904
255912
  getImage() {
255905
255913
  return this.imageToRender;
255906
255914
  }
255915
+ getIsRotatedPerpendicular() {
255916
+ return Boolean(this.transformation.getRotation() % 180);
255917
+ }
255907
255918
  render(context, left, top) {
255908
255919
  if (this.transformationRenderBlock) {
255909
255920
  return;
@@ -255916,7 +255927,7 @@ class Card extends BaseItem {
255916
255927
  const height3 = this.getHeight();
255917
255928
  if (typeof left === "number" && typeof top === "number") {
255918
255929
  centerX = left + width2 / 2;
255919
- centerX = top + height3 / 2;
255930
+ centerY = top + height3 / 2;
255920
255931
  }
255921
255932
  ctx.translate(centerX, centerY);
255922
255933
  ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
@@ -256041,6 +256052,7 @@ class Deck extends BaseItem {
256041
256052
  isCacheDirty = true;
256042
256053
  enableResize = false;
256043
256054
  path = null;
256055
+ isPerpendicular = undefined;
256044
256056
  constructor(board, id = "") {
256045
256057
  super(board, id, defaultDeckData, true);
256046
256058
  this.index.getUnderPoint = () => [];
@@ -256052,6 +256064,9 @@ class Deck extends BaseItem {
256052
256064
  });
256053
256065
  this.updateMbr();
256054
256066
  }
256067
+ getIsPerpendicular() {
256068
+ return this.isPerpendicular;
256069
+ }
256055
256070
  applyAddChildren(childIds) {
256056
256071
  if (!this.index) {
256057
256072
  return;
@@ -256059,13 +256074,15 @@ class Deck extends BaseItem {
256059
256074
  childIds.forEach((childId) => {
256060
256075
  const foundItem = this.board.items.getById(childId);
256061
256076
  if (this.parent !== childId && this.getId() !== childId) {
256062
- if (!this.index?.getById(childId) && foundItem?.itemType === "Card") {
256077
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
256078
+ if (canAddItem) {
256079
+ this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
256063
256080
  foundItem.transformation.apply({
256064
256081
  class: "Transformation",
256065
256082
  method: "translateTo",
256066
256083
  item: [this.id],
256067
- x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
256068
- y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
256084
+ x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
256085
+ y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
256069
256086
  });
256070
256087
  this.board.items.index.remove(foundItem);
256071
256088
  foundItem.parent = this.getId();
@@ -374910,20 +374927,20 @@ function FlipDeck({ rounded = "none" }) {
374910
374927
  }));
374911
374928
  }
374912
374929
 
374913
- // src/features/ContextPanel/Buttons/CardGame/Card/RotateCard.tsx
374930
+ // src/features/ContextPanel/Buttons/RotateItem.tsx
374914
374931
  var import_react290 = __toESM(require_react(), 1);
374915
- function RotateCard({ clockwise, rounded = "none" }) {
374932
+ function RotateItem({ clockwise, rounded = "none" }) {
374916
374933
  const { board } = useAppContext();
374917
374934
  const { t: t10 } = useTranslation();
374918
374935
  const handleClick = () => {
374919
- const cards = board.selection.items.list();
374920
- cards.forEach((card) => {
374921
- card.rotate(clockwise);
374936
+ const items = board.selection.items.list();
374937
+ items.forEach((item) => {
374938
+ item.rotate(clockwise);
374922
374939
  });
374923
374940
  };
374924
374941
  return /* @__PURE__ */ import_react290.default.createElement(UiButton, {
374925
374942
  className: ContextPanelButton_module_default.contextPanelButton,
374926
- id: "rotate-card",
374943
+ id: "rotate-item",
374927
374944
  tooltip: t10("contextPanel.gameItems.card.flip"),
374928
374945
  tooltipPosition: "top",
374929
374946
  onClick: handleClick,
@@ -375071,6 +375088,10 @@ function ContextPanel() {
375071
375088
  vertical: true
375072
375089
  }), /* @__PURE__ */ import_react291.default.createElement(RestOptionsMenu, null, /* @__PURE__ */ import_react291.default.createElement(BringToFront, null), /* @__PURE__ */ import_react291.default.createElement(SendToBack, null), /* @__PURE__ */ import_react291.default.createElement(CopyItemLink, null), /* @__PURE__ */ import_react291.default.createElement(SetLinkTo, null), /* @__PURE__ */ import_react291.default.createElement(Duplicate, null))), isImage && !isSelectUnderPointer && !isLocked && /* @__PURE__ */ import_react291.default.createElement(import_react291.default.Fragment, null, /* @__PURE__ */ import_react291.default.createElement(Lock, {
375073
375090
  rounded: "left"
375091
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375092
+ clockwise: false
375093
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375094
+ clockwise: true
375074
375095
  }), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
375075
375096
  vertical: true
375076
375097
  }), /* @__PURE__ */ import_react291.default.createElement(Delete, null), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
@@ -375144,9 +375165,9 @@ function ContextPanel() {
375144
375165
  }), /* @__PURE__ */ import_react291.default.createElement(CreateDeck, {
375145
375166
  onlyCards: true,
375146
375167
  rounded: "right"
375147
- }), /* @__PURE__ */ import_react291.default.createElement(RotateCard, {
375168
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375148
375169
  clockwise: false
375149
- }), /* @__PURE__ */ import_react291.default.createElement(RotateCard, {
375170
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375150
375171
  clockwise: true
375151
375172
  }), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
375152
375173
  vertical: true
package/dist/spa.js CHANGED
@@ -215914,7 +215914,7 @@ var conf = {
215914
215914
  FALLBACK_LNG: "en",
215915
215915
  cursorsMap,
215916
215916
  DECK_HORIZONTAL_OFFSET: 2,
215917
- DECK_VERTICAL_OFFSET: 0,
215917
+ DECK_VERTICAL_OFFSET: 2,
215918
215918
  CARD_DIMENSIONS: { width: 250, height: 400 }
215919
215919
  };
215920
215920
  initDefaultI18N();
@@ -250302,6 +250302,14 @@ class ImageItem extends BaseItem {
250302
250302
  const ctx = context.ctx;
250303
250303
  ctx.save();
250304
250304
  this.transformation.matrix.applyToContext(ctx);
250305
+ const rotation = this.transformation.getRotation();
250306
+ if (rotation !== 0) {
250307
+ const imgWidth = this.image.width || 0;
250308
+ const imgHeight = this.image.height || 0;
250309
+ ctx.translate(imgWidth / 2, imgHeight / 2);
250310
+ ctx.rotate(rotation * Math.PI / 180);
250311
+ ctx.translate(-imgWidth / 2, -imgHeight / 2);
250312
+ }
250305
250313
  ctx.drawImage(this.image, 0, 0);
250306
250314
  ctx.restore();
250307
250315
  if (this.getLinkTo()) {
@@ -255904,6 +255912,9 @@ class Card extends BaseItem {
255904
255912
  getImage() {
255905
255913
  return this.imageToRender;
255906
255914
  }
255915
+ getIsRotatedPerpendicular() {
255916
+ return Boolean(this.transformation.getRotation() % 180);
255917
+ }
255907
255918
  render(context, left, top) {
255908
255919
  if (this.transformationRenderBlock) {
255909
255920
  return;
@@ -255916,7 +255927,7 @@ class Card extends BaseItem {
255916
255927
  const height3 = this.getHeight();
255917
255928
  if (typeof left === "number" && typeof top === "number") {
255918
255929
  centerX = left + width2 / 2;
255919
- centerX = top + height3 / 2;
255930
+ centerY = top + height3 / 2;
255920
255931
  }
255921
255932
  ctx.translate(centerX, centerY);
255922
255933
  ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
@@ -256041,6 +256052,7 @@ class Deck extends BaseItem {
256041
256052
  isCacheDirty = true;
256042
256053
  enableResize = false;
256043
256054
  path = null;
256055
+ isPerpendicular = undefined;
256044
256056
  constructor(board, id = "") {
256045
256057
  super(board, id, defaultDeckData, true);
256046
256058
  this.index.getUnderPoint = () => [];
@@ -256052,6 +256064,9 @@ class Deck extends BaseItem {
256052
256064
  });
256053
256065
  this.updateMbr();
256054
256066
  }
256067
+ getIsPerpendicular() {
256068
+ return this.isPerpendicular;
256069
+ }
256055
256070
  applyAddChildren(childIds) {
256056
256071
  if (!this.index) {
256057
256072
  return;
@@ -256059,13 +256074,15 @@ class Deck extends BaseItem {
256059
256074
  childIds.forEach((childId) => {
256060
256075
  const foundItem = this.board.items.getById(childId);
256061
256076
  if (this.parent !== childId && this.getId() !== childId) {
256062
- if (!this.index?.getById(childId) && foundItem?.itemType === "Card") {
256077
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
256078
+ if (canAddItem) {
256079
+ this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
256063
256080
  foundItem.transformation.apply({
256064
256081
  class: "Transformation",
256065
256082
  method: "translateTo",
256066
256083
  item: [this.id],
256067
- x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
256068
- y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
256084
+ x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
256085
+ y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
256069
256086
  });
256070
256087
  this.board.items.index.remove(foundItem);
256071
256088
  foundItem.parent = this.getId();
@@ -374910,20 +374927,20 @@ function FlipDeck({ rounded = "none" }) {
374910
374927
  }));
374911
374928
  }
374912
374929
 
374913
- // src/features/ContextPanel/Buttons/CardGame/Card/RotateCard.tsx
374930
+ // src/features/ContextPanel/Buttons/RotateItem.tsx
374914
374931
  var import_react290 = __toESM(require_react(), 1);
374915
- function RotateCard({ clockwise, rounded = "none" }) {
374932
+ function RotateItem({ clockwise, rounded = "none" }) {
374916
374933
  const { board } = useAppContext();
374917
374934
  const { t: t10 } = useTranslation();
374918
374935
  const handleClick = () => {
374919
- const cards = board.selection.items.list();
374920
- cards.forEach((card) => {
374921
- card.rotate(clockwise);
374936
+ const items = board.selection.items.list();
374937
+ items.forEach((item) => {
374938
+ item.rotate(clockwise);
374922
374939
  });
374923
374940
  };
374924
374941
  return /* @__PURE__ */ import_react290.default.createElement(UiButton, {
374925
374942
  className: ContextPanelButton_module_default.contextPanelButton,
374926
- id: "rotate-card",
374943
+ id: "rotate-item",
374927
374944
  tooltip: t10("contextPanel.gameItems.card.flip"),
374928
374945
  tooltipPosition: "top",
374929
374946
  onClick: handleClick,
@@ -375071,6 +375088,10 @@ function ContextPanel() {
375071
375088
  vertical: true
375072
375089
  }), /* @__PURE__ */ import_react291.default.createElement(RestOptionsMenu, null, /* @__PURE__ */ import_react291.default.createElement(BringToFront, null), /* @__PURE__ */ import_react291.default.createElement(SendToBack, null), /* @__PURE__ */ import_react291.default.createElement(CopyItemLink, null), /* @__PURE__ */ import_react291.default.createElement(SetLinkTo, null), /* @__PURE__ */ import_react291.default.createElement(Duplicate, null))), isImage && !isSelectUnderPointer && !isLocked && /* @__PURE__ */ import_react291.default.createElement(import_react291.default.Fragment, null, /* @__PURE__ */ import_react291.default.createElement(Lock, {
375073
375090
  rounded: "left"
375091
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375092
+ clockwise: false
375093
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375094
+ clockwise: true
375074
375095
  }), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
375075
375096
  vertical: true
375076
375097
  }), /* @__PURE__ */ import_react291.default.createElement(Delete, null), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
@@ -375144,9 +375165,9 @@ function ContextPanel() {
375144
375165
  }), /* @__PURE__ */ import_react291.default.createElement(CreateDeck, {
375145
375166
  onlyCards: true,
375146
375167
  rounded: "right"
375147
- }), /* @__PURE__ */ import_react291.default.createElement(RotateCard, {
375168
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375148
375169
  clockwise: false
375149
- }), /* @__PURE__ */ import_react291.default.createElement(RotateCard, {
375170
+ }), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
375150
375171
  clockwise: true
375151
375172
  }), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
375152
375173
  vertical: true
@@ -2,5 +2,5 @@ interface Props {
2
2
  clockwise: boolean;
3
3
  rounded?: string;
4
4
  }
5
- export declare function RotateCard({ clockwise, rounded }: Props): import("react/jsx-runtime").JSX.Element;
5
+ export declare function RotateItem({ clockwise, rounded }: Props): import("react/jsx-runtime").JSX.Element;
6
6
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-ui-temp",
3
- "version": "0.1.86",
3
+ "version": "0.1.87",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "type": "module",
@@ -60,7 +60,7 @@
60
60
  "i18next-browser-languagedetector": "^8.2.0",
61
61
  "js-cookie": "^3.0.5",
62
62
  "jwt-decode": "^4.0.0",
63
- "microboard-temp": "^0.5.27",
63
+ "microboard-temp": "^0.5.28",
64
64
  "nanoid": "^5.1.5",
65
65
  "prop-types": "^15.8.1",
66
66
  "react-hot-toast": "2.4.1",