microboard-ui-temp 0.1.86 → 0.1.88
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:
|
|
215917
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
215918
215918
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
215919
215919
|
};
|
|
215920
215920
|
initDefaultI18N();
|
|
@@ -250194,10 +250194,22 @@ class ImageItem extends BaseItem {
|
|
|
250194
250194
|
};
|
|
250195
250195
|
updateMbr() {
|
|
250196
250196
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
250197
|
-
|
|
250198
|
-
this.
|
|
250199
|
-
|
|
250200
|
-
|
|
250197
|
+
const rotation = this.transformation.getRotation();
|
|
250198
|
+
const width2 = this.image.width * scaleX;
|
|
250199
|
+
const height2 = this.image.height * scaleY;
|
|
250200
|
+
if (rotation % 180 === 0) {
|
|
250201
|
+
this.left = translateX;
|
|
250202
|
+
this.top = translateY;
|
|
250203
|
+
this.right = this.left + width2;
|
|
250204
|
+
this.bottom = this.top + height2;
|
|
250205
|
+
} else {
|
|
250206
|
+
const centerX = translateX + width2 / 2;
|
|
250207
|
+
const centerY = translateY + height2 / 2;
|
|
250208
|
+
this.left = centerX - height2 / 2;
|
|
250209
|
+
this.top = centerY - width2 / 2;
|
|
250210
|
+
this.right = this.left + height2;
|
|
250211
|
+
this.bottom = this.top + width2;
|
|
250212
|
+
}
|
|
250201
250213
|
}
|
|
250202
250214
|
doOnceBeforeOnLoad = (callback) => {
|
|
250203
250215
|
this.loadCallbacks.push(callback);
|
|
@@ -250302,6 +250314,14 @@ class ImageItem extends BaseItem {
|
|
|
250302
250314
|
const ctx = context.ctx;
|
|
250303
250315
|
ctx.save();
|
|
250304
250316
|
this.transformation.matrix.applyToContext(ctx);
|
|
250317
|
+
const rotation = this.transformation.getRotation();
|
|
250318
|
+
if (rotation !== 0) {
|
|
250319
|
+
const imgWidth = this.image.width || 0;
|
|
250320
|
+
const imgHeight = this.image.height || 0;
|
|
250321
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
250322
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
250323
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
250324
|
+
}
|
|
250305
250325
|
ctx.drawImage(this.image, 0, 0);
|
|
250306
250326
|
ctx.restore();
|
|
250307
250327
|
if (this.getLinkTo()) {
|
|
@@ -255904,6 +255924,9 @@ class Card extends BaseItem {
|
|
|
255904
255924
|
getImage() {
|
|
255905
255925
|
return this.imageToRender;
|
|
255906
255926
|
}
|
|
255927
|
+
getIsRotatedPerpendicular() {
|
|
255928
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
255929
|
+
}
|
|
255907
255930
|
render(context, left, top) {
|
|
255908
255931
|
if (this.transformationRenderBlock) {
|
|
255909
255932
|
return;
|
|
@@ -255916,7 +255939,7 @@ class Card extends BaseItem {
|
|
|
255916
255939
|
const height3 = this.getHeight();
|
|
255917
255940
|
if (typeof left === "number" && typeof top === "number") {
|
|
255918
255941
|
centerX = left + width2 / 2;
|
|
255919
|
-
|
|
255942
|
+
centerY = top + height3 / 2;
|
|
255920
255943
|
}
|
|
255921
255944
|
ctx.translate(centerX, centerY);
|
|
255922
255945
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -256041,6 +256064,7 @@ class Deck extends BaseItem {
|
|
|
256041
256064
|
isCacheDirty = true;
|
|
256042
256065
|
enableResize = false;
|
|
256043
256066
|
path = null;
|
|
256067
|
+
isPerpendicular = undefined;
|
|
256044
256068
|
constructor(board, id = "") {
|
|
256045
256069
|
super(board, id, defaultDeckData, true);
|
|
256046
256070
|
this.index.getUnderPoint = () => [];
|
|
@@ -256052,6 +256076,9 @@ class Deck extends BaseItem {
|
|
|
256052
256076
|
});
|
|
256053
256077
|
this.updateMbr();
|
|
256054
256078
|
}
|
|
256079
|
+
getIsPerpendicular() {
|
|
256080
|
+
return this.isPerpendicular;
|
|
256081
|
+
}
|
|
256055
256082
|
applyAddChildren(childIds) {
|
|
256056
256083
|
if (!this.index) {
|
|
256057
256084
|
return;
|
|
@@ -256059,13 +256086,15 @@ class Deck extends BaseItem {
|
|
|
256059
256086
|
childIds.forEach((childId) => {
|
|
256060
256087
|
const foundItem = this.board.items.getById(childId);
|
|
256061
256088
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
256062
|
-
|
|
256089
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
256090
|
+
if (canAddItem) {
|
|
256091
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
256063
256092
|
foundItem.transformation.apply({
|
|
256064
256093
|
class: "Transformation",
|
|
256065
256094
|
method: "translateTo",
|
|
256066
256095
|
item: [this.id],
|
|
256067
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
256068
|
-
y: this.top
|
|
256096
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
256097
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
256069
256098
|
});
|
|
256070
256099
|
this.board.items.index.remove(foundItem);
|
|
256071
256100
|
foundItem.parent = this.getId();
|
|
@@ -374910,20 +374939,20 @@ function FlipDeck({ rounded = "none" }) {
|
|
|
374910
374939
|
}));
|
|
374911
374940
|
}
|
|
374912
374941
|
|
|
374913
|
-
// src/features/ContextPanel/Buttons/
|
|
374942
|
+
// src/features/ContextPanel/Buttons/RotateItem.tsx
|
|
374914
374943
|
var import_react290 = __toESM(require_react(), 1);
|
|
374915
|
-
function
|
|
374944
|
+
function RotateItem({ clockwise, rounded = "none" }) {
|
|
374916
374945
|
const { board } = useAppContext();
|
|
374917
374946
|
const { t: t10 } = useTranslation();
|
|
374918
374947
|
const handleClick = () => {
|
|
374919
|
-
const
|
|
374920
|
-
|
|
374921
|
-
|
|
374948
|
+
const items = board.selection.items.list();
|
|
374949
|
+
items.forEach((item) => {
|
|
374950
|
+
item.rotate(clockwise);
|
|
374922
374951
|
});
|
|
374923
374952
|
};
|
|
374924
374953
|
return /* @__PURE__ */ import_react290.default.createElement(UiButton, {
|
|
374925
374954
|
className: ContextPanelButton_module_default.contextPanelButton,
|
|
374926
|
-
id: "rotate-
|
|
374955
|
+
id: "rotate-item",
|
|
374927
374956
|
tooltip: t10("contextPanel.gameItems.card.flip"),
|
|
374928
374957
|
tooltipPosition: "top",
|
|
374929
374958
|
onClick: handleClick,
|
|
@@ -375071,6 +375100,10 @@ function ContextPanel() {
|
|
|
375071
375100
|
vertical: true
|
|
375072
375101
|
}), /* @__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
375102
|
rounded: "left"
|
|
375103
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375104
|
+
clockwise: false
|
|
375105
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375106
|
+
clockwise: true
|
|
375074
375107
|
}), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
|
|
375075
375108
|
vertical: true
|
|
375076
375109
|
}), /* @__PURE__ */ import_react291.default.createElement(Delete, null), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
|
|
@@ -375144,9 +375177,9 @@ function ContextPanel() {
|
|
|
375144
375177
|
}), /* @__PURE__ */ import_react291.default.createElement(CreateDeck, {
|
|
375145
375178
|
onlyCards: true,
|
|
375146
375179
|
rounded: "right"
|
|
375147
|
-
}), /* @__PURE__ */ import_react291.default.createElement(
|
|
375180
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375148
375181
|
clockwise: false
|
|
375149
|
-
}), /* @__PURE__ */ import_react291.default.createElement(
|
|
375182
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375150
375183
|
clockwise: true
|
|
375151
375184
|
}), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
|
|
375152
375185
|
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:
|
|
215917
|
+
DECK_VERTICAL_OFFSET: 2,
|
|
215918
215918
|
CARD_DIMENSIONS: { width: 250, height: 400 }
|
|
215919
215919
|
};
|
|
215920
215920
|
initDefaultI18N();
|
|
@@ -250194,10 +250194,22 @@ class ImageItem extends BaseItem {
|
|
|
250194
250194
|
};
|
|
250195
250195
|
updateMbr() {
|
|
250196
250196
|
const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
|
|
250197
|
-
|
|
250198
|
-
this.
|
|
250199
|
-
|
|
250200
|
-
|
|
250197
|
+
const rotation = this.transformation.getRotation();
|
|
250198
|
+
const width2 = this.image.width * scaleX;
|
|
250199
|
+
const height2 = this.image.height * scaleY;
|
|
250200
|
+
if (rotation % 180 === 0) {
|
|
250201
|
+
this.left = translateX;
|
|
250202
|
+
this.top = translateY;
|
|
250203
|
+
this.right = this.left + width2;
|
|
250204
|
+
this.bottom = this.top + height2;
|
|
250205
|
+
} else {
|
|
250206
|
+
const centerX = translateX + width2 / 2;
|
|
250207
|
+
const centerY = translateY + height2 / 2;
|
|
250208
|
+
this.left = centerX - height2 / 2;
|
|
250209
|
+
this.top = centerY - width2 / 2;
|
|
250210
|
+
this.right = this.left + height2;
|
|
250211
|
+
this.bottom = this.top + width2;
|
|
250212
|
+
}
|
|
250201
250213
|
}
|
|
250202
250214
|
doOnceBeforeOnLoad = (callback) => {
|
|
250203
250215
|
this.loadCallbacks.push(callback);
|
|
@@ -250302,6 +250314,14 @@ class ImageItem extends BaseItem {
|
|
|
250302
250314
|
const ctx = context.ctx;
|
|
250303
250315
|
ctx.save();
|
|
250304
250316
|
this.transformation.matrix.applyToContext(ctx);
|
|
250317
|
+
const rotation = this.transformation.getRotation();
|
|
250318
|
+
if (rotation !== 0) {
|
|
250319
|
+
const imgWidth = this.image.width || 0;
|
|
250320
|
+
const imgHeight = this.image.height || 0;
|
|
250321
|
+
ctx.translate(imgWidth / 2, imgHeight / 2);
|
|
250322
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
250323
|
+
ctx.translate(-imgWidth / 2, -imgHeight / 2);
|
|
250324
|
+
}
|
|
250305
250325
|
ctx.drawImage(this.image, 0, 0);
|
|
250306
250326
|
ctx.restore();
|
|
250307
250327
|
if (this.getLinkTo()) {
|
|
@@ -255904,6 +255924,9 @@ class Card extends BaseItem {
|
|
|
255904
255924
|
getImage() {
|
|
255905
255925
|
return this.imageToRender;
|
|
255906
255926
|
}
|
|
255927
|
+
getIsRotatedPerpendicular() {
|
|
255928
|
+
return Boolean(this.transformation.getRotation() % 180);
|
|
255929
|
+
}
|
|
255907
255930
|
render(context, left, top) {
|
|
255908
255931
|
if (this.transformationRenderBlock) {
|
|
255909
255932
|
return;
|
|
@@ -255916,7 +255939,7 @@ class Card extends BaseItem {
|
|
|
255916
255939
|
const height3 = this.getHeight();
|
|
255917
255940
|
if (typeof left === "number" && typeof top === "number") {
|
|
255918
255941
|
centerX = left + width2 / 2;
|
|
255919
|
-
|
|
255942
|
+
centerY = top + height3 / 2;
|
|
255920
255943
|
}
|
|
255921
255944
|
ctx.translate(centerX, centerY);
|
|
255922
255945
|
ctx.rotate(this.transformation.getRotation() * Math.PI / 180);
|
|
@@ -256041,6 +256064,7 @@ class Deck extends BaseItem {
|
|
|
256041
256064
|
isCacheDirty = true;
|
|
256042
256065
|
enableResize = false;
|
|
256043
256066
|
path = null;
|
|
256067
|
+
isPerpendicular = undefined;
|
|
256044
256068
|
constructor(board, id = "") {
|
|
256045
256069
|
super(board, id, defaultDeckData, true);
|
|
256046
256070
|
this.index.getUnderPoint = () => [];
|
|
@@ -256052,6 +256076,9 @@ class Deck extends BaseItem {
|
|
|
256052
256076
|
});
|
|
256053
256077
|
this.updateMbr();
|
|
256054
256078
|
}
|
|
256079
|
+
getIsPerpendicular() {
|
|
256080
|
+
return this.isPerpendicular;
|
|
256081
|
+
}
|
|
256055
256082
|
applyAddChildren(childIds) {
|
|
256056
256083
|
if (!this.index) {
|
|
256057
256084
|
return;
|
|
@@ -256059,13 +256086,15 @@ class Deck extends BaseItem {
|
|
|
256059
256086
|
childIds.forEach((childId) => {
|
|
256060
256087
|
const foundItem = this.board.items.getById(childId);
|
|
256061
256088
|
if (this.parent !== childId && this.getId() !== childId) {
|
|
256062
|
-
|
|
256089
|
+
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
|
|
256090
|
+
if (canAddItem) {
|
|
256091
|
+
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
256063
256092
|
foundItem.transformation.apply({
|
|
256064
256093
|
class: "Transformation",
|
|
256065
256094
|
method: "translateTo",
|
|
256066
256095
|
item: [this.id],
|
|
256067
|
-
x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
|
|
256068
|
-
y: this.top
|
|
256096
|
+
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
256097
|
+
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
256069
256098
|
});
|
|
256070
256099
|
this.board.items.index.remove(foundItem);
|
|
256071
256100
|
foundItem.parent = this.getId();
|
|
@@ -374910,20 +374939,20 @@ function FlipDeck({ rounded = "none" }) {
|
|
|
374910
374939
|
}));
|
|
374911
374940
|
}
|
|
374912
374941
|
|
|
374913
|
-
// src/features/ContextPanel/Buttons/
|
|
374942
|
+
// src/features/ContextPanel/Buttons/RotateItem.tsx
|
|
374914
374943
|
var import_react290 = __toESM(require_react(), 1);
|
|
374915
|
-
function
|
|
374944
|
+
function RotateItem({ clockwise, rounded = "none" }) {
|
|
374916
374945
|
const { board } = useAppContext();
|
|
374917
374946
|
const { t: t10 } = useTranslation();
|
|
374918
374947
|
const handleClick = () => {
|
|
374919
|
-
const
|
|
374920
|
-
|
|
374921
|
-
|
|
374948
|
+
const items = board.selection.items.list();
|
|
374949
|
+
items.forEach((item) => {
|
|
374950
|
+
item.rotate(clockwise);
|
|
374922
374951
|
});
|
|
374923
374952
|
};
|
|
374924
374953
|
return /* @__PURE__ */ import_react290.default.createElement(UiButton, {
|
|
374925
374954
|
className: ContextPanelButton_module_default.contextPanelButton,
|
|
374926
|
-
id: "rotate-
|
|
374955
|
+
id: "rotate-item",
|
|
374927
374956
|
tooltip: t10("contextPanel.gameItems.card.flip"),
|
|
374928
374957
|
tooltipPosition: "top",
|
|
374929
374958
|
onClick: handleClick,
|
|
@@ -375071,6 +375100,10 @@ function ContextPanel() {
|
|
|
375071
375100
|
vertical: true
|
|
375072
375101
|
}), /* @__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
375102
|
rounded: "left"
|
|
375103
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375104
|
+
clockwise: false
|
|
375105
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375106
|
+
clockwise: true
|
|
375074
375107
|
}), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
|
|
375075
375108
|
vertical: true
|
|
375076
375109
|
}), /* @__PURE__ */ import_react291.default.createElement(Delete, null), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
|
|
@@ -375144,9 +375177,9 @@ function ContextPanel() {
|
|
|
375144
375177
|
}), /* @__PURE__ */ import_react291.default.createElement(CreateDeck, {
|
|
375145
375178
|
onlyCards: true,
|
|
375146
375179
|
rounded: "right"
|
|
375147
|
-
}), /* @__PURE__ */ import_react291.default.createElement(
|
|
375180
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375148
375181
|
clockwise: false
|
|
375149
|
-
}), /* @__PURE__ */ import_react291.default.createElement(
|
|
375182
|
+
}), /* @__PURE__ */ import_react291.default.createElement(RotateItem, {
|
|
375150
375183
|
clockwise: true
|
|
375151
375184
|
}), /* @__PURE__ */ import_react291.default.createElement(UiSeparator, {
|
|
375152
375185
|
vertical: true
|
package/dist/types/features/ContextPanel/Buttons/{CardGame/Card/RotateCard.d.ts → RotateItem.d.ts}
RENAMED
|
@@ -2,5 +2,5 @@ interface Props {
|
|
|
2
2
|
clockwise: boolean;
|
|
3
3
|
rounded?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function
|
|
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.
|
|
3
|
+
"version": "0.1.88",
|
|
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.
|
|
63
|
+
"microboard-temp": "^0.5.29",
|
|
64
64
|
"nanoid": "^5.1.5",
|
|
65
65
|
"prop-types": "^15.8.1",
|
|
66
66
|
"react-hot-toast": "2.4.1",
|