@pie-element/hotspot 11.1.2-next.0 → 11.1.2-next.1
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/author/hotspot-drawable.js +119 -119
- package/dist/author/utils.js +9 -9
- package/dist/browser/author/index.js +6215 -6866
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/browser-CfnAFove.js +13 -4
- package/dist/browser/controller/index.js +1 -1
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/dist-C78LDz6R.js +96 -0
- package/dist/browser/dist-C78LDz6R.js.map +1 -0
- package/dist/controller/index.js +24 -24
- package/dist/controller/utils.d.ts +1 -1
- package/dist/controller/utils.js +1 -2
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +10 -6
- package/dist/browser/isEqual-D3CTSc6W.js +0 -601
- package/dist/browser/isEqual-D3CTSc6W.js.map +0 -1
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_SetCache.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arraySome.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +0 -57
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqual.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqualDeep.js +0 -30
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalArrays.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalByTag.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalObjects.js +0 -32
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +0 -23
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +0 -33
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheAdd.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +0 -21
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEqual.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +0 -6
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import c from "./hotspot-
|
|
8
|
-
import l from "./hotspot-
|
|
9
|
-
import u from "
|
|
10
|
-
import
|
|
11
|
-
import p from "
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
1
|
+
import { CircleShape as e } from "./shapes/circle.js";
|
|
2
|
+
import { RectangleShape as t } from "./shapes/rectagle.js";
|
|
3
|
+
import { PolygonShape as n } from "./shapes/polygon.js";
|
|
4
|
+
import { SHAPE_GROUPS as r, SUPPORTED_SHAPES as i } from "./shapes/utils.js";
|
|
5
|
+
import { getUpdatedShapes as a, updateImageDimensions as o } from "./utils.js";
|
|
6
|
+
import s from "./hotspot-rectangle.js";
|
|
7
|
+
import c from "./hotspot-polygon.js";
|
|
8
|
+
import l from "./hotspot-circle.js";
|
|
9
|
+
import u, { createElement as d } from "react";
|
|
10
|
+
import f from "prop-types";
|
|
11
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
12
|
+
import { styled as h } from "@mui/material/styles";
|
|
13
|
+
import { Layer as g, Stage as _ } from "react-konva";
|
|
14
|
+
import { cloneDeep as v } from "@pie-element/shared-lodash";
|
|
15
15
|
//#region src/author/hotspot-drawable.tsx
|
|
16
16
|
function y(e) {
|
|
17
17
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
@@ -19,14 +19,14 @@ function y(e) {
|
|
|
19
19
|
function b(e, t) {
|
|
20
20
|
return !e || y(e) ? e : y(e.default) ? e.default : t && y(e[t]) ? e[t] : t && y(e[t]?.default) ? e[t].default : e;
|
|
21
21
|
}
|
|
22
|
-
var x = b(
|
|
22
|
+
var x = b(_, "Stage"), S = b(g, "Layer"), C = h("div")({ position: "relative" }), w = h("div")({
|
|
23
23
|
position: "relative",
|
|
24
24
|
width: "fit-content"
|
|
25
|
-
}), T =
|
|
25
|
+
}), T = h("img")({
|
|
26
26
|
alignItems: "center",
|
|
27
27
|
display: "flex",
|
|
28
28
|
justifyContent: "center"
|
|
29
|
-
}), E =
|
|
29
|
+
}), E = h("div")({
|
|
30
30
|
borderBottom: "1px solid #727272",
|
|
31
31
|
borderRight: "1px solid #727272",
|
|
32
32
|
bottom: "-10px",
|
|
@@ -35,11 +35,11 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
35
35
|
position: "absolute",
|
|
36
36
|
right: "-10px",
|
|
37
37
|
width: "10px"
|
|
38
|
-
}), D =
|
|
38
|
+
}), D = h(x)({
|
|
39
39
|
left: 0,
|
|
40
40
|
top: 0,
|
|
41
41
|
position: "absolute"
|
|
42
|
-
}), O = 800, k = class extends
|
|
42
|
+
}), O = 800, k = class extends u.Component {
|
|
43
43
|
static getDerivedStateFromProps(e, t) {
|
|
44
44
|
return e.shapes === t.shapes ? null : { shapes: e.shapes };
|
|
45
45
|
}
|
|
@@ -56,25 +56,25 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
handleOnMouseDown = (
|
|
60
|
-
let { shapeType:
|
|
61
|
-
if (
|
|
62
|
-
switch (
|
|
63
|
-
case
|
|
64
|
-
c =
|
|
59
|
+
handleOnMouseDown = (r) => {
|
|
60
|
+
let { shapeType: a, onUpdateShapes: o, shapes: s } = this.props, c, l;
|
|
61
|
+
if (r.target === r.currentTarget && Object.values(i).includes(a)) {
|
|
62
|
+
switch (a) {
|
|
63
|
+
case i.RECTANGLE:
|
|
64
|
+
c = t.create(s, r);
|
|
65
65
|
break;
|
|
66
|
-
case
|
|
67
|
-
c =
|
|
66
|
+
case i.CIRCLE:
|
|
67
|
+
c = e.create(s, r);
|
|
68
68
|
break;
|
|
69
|
-
case
|
|
69
|
+
case i.POLYGON:
|
|
70
70
|
if (l = this.state.isDrawingShapeId, l) {
|
|
71
|
-
let
|
|
71
|
+
let e = this.addPolygonPoint(r);
|
|
72
72
|
c = {
|
|
73
73
|
isDrawing: !0,
|
|
74
74
|
isDrawingShapeId: l,
|
|
75
|
-
shapes:
|
|
75
|
+
shapes: e
|
|
76
76
|
};
|
|
77
|
-
} else c =
|
|
77
|
+
} else c = n.create(s, r);
|
|
78
78
|
break;
|
|
79
79
|
default: return;
|
|
80
80
|
}
|
|
@@ -82,7 +82,7 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
addPolygonPoint(e) {
|
|
85
|
-
let { shapes: t } =
|
|
85
|
+
let { shapes: t } = n.addPoint(this.state, e, (e) => {
|
|
86
86
|
this.setState({
|
|
87
87
|
isDrawing: !1,
|
|
88
88
|
shapes: e,
|
|
@@ -92,35 +92,35 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
92
92
|
return t;
|
|
93
93
|
}
|
|
94
94
|
handleOnMouseUp = () => {
|
|
95
|
-
let { shapeType:
|
|
96
|
-
if (
|
|
97
|
-
switch (
|
|
98
|
-
case
|
|
99
|
-
|
|
95
|
+
let { shapeType: n, onUpdateShapes: r } = this.props, a;
|
|
96
|
+
if (n !== i.POLYGON) {
|
|
97
|
+
switch (n) {
|
|
98
|
+
case i.RECTANGLE:
|
|
99
|
+
a = t.finalizeCreation(this.state, this.props);
|
|
100
100
|
break;
|
|
101
|
-
case
|
|
102
|
-
|
|
101
|
+
case i.CIRCLE:
|
|
102
|
+
a = e.finalizeCreation(this.state, this.props);
|
|
103
103
|
break;
|
|
104
104
|
default: return;
|
|
105
105
|
}
|
|
106
106
|
this.setState({
|
|
107
|
-
...
|
|
107
|
+
...a,
|
|
108
108
|
isDrawing: !1
|
|
109
|
-
}), r(
|
|
109
|
+
}), r(a.shapes);
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
handleMouseMove = (
|
|
113
|
-
let { shapeType:
|
|
114
|
-
if (!(!this.state.isDrawing || !Object.values(
|
|
115
|
-
switch (
|
|
116
|
-
case
|
|
117
|
-
s =
|
|
112
|
+
handleMouseMove = (r) => {
|
|
113
|
+
let { shapeType: a, onUpdateShapes: o } = this.props, s;
|
|
114
|
+
if (!(!this.state.isDrawing || !Object.values(i).includes(a))) {
|
|
115
|
+
switch (a) {
|
|
116
|
+
case i.RECTANGLE:
|
|
117
|
+
s = t.handleMouseMove(this.state, r);
|
|
118
118
|
break;
|
|
119
|
-
case
|
|
120
|
-
s =
|
|
119
|
+
case i.CIRCLE:
|
|
120
|
+
s = e.handleMouseMove(this.state, r);
|
|
121
121
|
break;
|
|
122
|
-
case
|
|
123
|
-
s =
|
|
122
|
+
case i.POLYGON:
|
|
123
|
+
s = n.handleMouseMove(this.state, r);
|
|
124
124
|
break;
|
|
125
125
|
default: return;
|
|
126
126
|
}
|
|
@@ -130,45 +130,45 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
130
130
|
handleOnMouseOutOrLeave = (e) => {
|
|
131
131
|
this.state.isDrawing && this.handleOnMouseUp(e);
|
|
132
132
|
};
|
|
133
|
-
handleOnDragEnd = (
|
|
134
|
-
let { shapes:
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
let r =
|
|
138
|
-
if (
|
|
139
|
-
...
|
|
140
|
-
...
|
|
133
|
+
handleOnDragEnd = (e, t) => {
|
|
134
|
+
let { shapes: n, onUpdateShapes: r, dimensions: i } = this.props, { width: a, height: o } = i;
|
|
135
|
+
r(v(n.map((n) => {
|
|
136
|
+
if (n.id !== e) return n;
|
|
137
|
+
let r = t.x, i = t.y;
|
|
138
|
+
if (n.group === "rectangles") return r + n.width < 0 || r > a || i + n.height < 0 || i > o ? null : {
|
|
139
|
+
...n,
|
|
140
|
+
...t
|
|
141
141
|
};
|
|
142
|
-
if (
|
|
143
|
-
let
|
|
144
|
-
return r +
|
|
145
|
-
...
|
|
146
|
-
...
|
|
142
|
+
if (n.group === "circles") {
|
|
143
|
+
let e = n.radius;
|
|
144
|
+
return r + e < 0 || r - e > a || i + e < 0 || i - e > o ? null : {
|
|
145
|
+
...n,
|
|
146
|
+
...t
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
if (
|
|
150
|
-
let
|
|
151
|
-
return
|
|
152
|
-
...
|
|
153
|
-
...
|
|
149
|
+
if (n.group === "polygons") {
|
|
150
|
+
let e = n.points, r = e.map((e) => e.x), i = e.map((e) => e.y), s = Math.min(...r), c = Math.min(...i), l = Math.max(...r), u = Math.max(...i), d = t.points[0].x - e[0].x, f = t.points[0].y - e[0].y;
|
|
151
|
+
return s += d, l += d, c += f, u += f, l < 0 || s > a || u < 0 || c > o ? null : {
|
|
152
|
+
...n,
|
|
153
|
+
...t
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
return
|
|
156
|
+
return n;
|
|
157
157
|
}).filter((e) => e !== null)));
|
|
158
158
|
};
|
|
159
|
-
closeInProgressPolygons = (
|
|
160
|
-
let { shapes:
|
|
161
|
-
(
|
|
159
|
+
closeInProgressPolygons = (e) => {
|
|
160
|
+
let { shapes: t, onUpdateShapes: r } = this.props, i = (t || []).find((e) => e.id === "newPolygon");
|
|
161
|
+
(e === "newPolygon" || i && this.state.isDrawing) && n.finalizeCreation(this.state, (e) => {
|
|
162
162
|
this.setState({
|
|
163
163
|
isDrawing: !1,
|
|
164
|
-
shapes:
|
|
164
|
+
shapes: e,
|
|
165
165
|
isDrawingShapeId: void 0
|
|
166
|
-
}),
|
|
166
|
+
}), r(v(e));
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
|
-
handleOnSetAsCorrect = (
|
|
170
|
-
let { id:
|
|
171
|
-
|
|
169
|
+
handleOnSetAsCorrect = (e) => {
|
|
170
|
+
let { id: t } = e, { multipleCorrect: n, shapes: r, onUpdateShapes: i } = this.props, a;
|
|
171
|
+
a = n ? r.map((e) => (e.id === t && (e.correct = !e.correct), e)) : r.map((e) => (e.correct = e.id === t, e)), i(v(a)), this.closeInProgressPolygons(t);
|
|
172
172
|
};
|
|
173
173
|
handleOnImageLoad = ({ target: e }) => {
|
|
174
174
|
let { onUpdateImageDimension: t } = this.props, n = this.resize, r = getComputedStyle(e), i = parseFloat(r.height), a = parseFloat(r.width), o = a / O, s = a > O ? {
|
|
@@ -191,7 +191,7 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
191
191
|
}), r;
|
|
192
192
|
}
|
|
193
193
|
startResizing = (e) => {
|
|
194
|
-
let t = e.target.getBoundingClientRect(), n = this.image, { disableDrag: r, preserveAspectRatioEnabled: i, dimensions:
|
|
194
|
+
let t = e.target.getBoundingClientRect(), n = this.image, { disableDrag: r, preserveAspectRatioEnabled: i, dimensions: s, shapes: c } = this.props, { width: l, height: u } = o(s, {
|
|
195
195
|
width: e.clientX - t.left,
|
|
196
196
|
height: e.clientY - t.top
|
|
197
197
|
}, i);
|
|
@@ -201,15 +201,15 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
201
201
|
height: u,
|
|
202
202
|
width: l
|
|
203
203
|
},
|
|
204
|
-
stateShapes:
|
|
204
|
+
stateShapes: a(s, {
|
|
205
205
|
width: l,
|
|
206
206
|
height: u
|
|
207
207
|
}, c)
|
|
208
208
|
})), r();
|
|
209
209
|
};
|
|
210
210
|
stopResizing = () => {
|
|
211
|
-
let { enableDrag:
|
|
212
|
-
|
|
211
|
+
let { enableDrag: e, onUpdateImageDimension: t, onUpdateShapes: n } = this.props, { dimensions: r, stateShapes: i } = this.state;
|
|
212
|
+
e(), i && n(v(i)), t(r), window.removeEventListener("mousemove", this.startResizing, !1), window.removeEventListener("mouseup", this.stopResizing, !1), this.setState({
|
|
213
213
|
resizing: !1,
|
|
214
214
|
stateShapes: !1
|
|
215
215
|
});
|
|
@@ -221,8 +221,8 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
221
221
|
}), this.props.onDeleteShape(e);
|
|
222
222
|
};
|
|
223
223
|
render() {
|
|
224
|
-
let { imageUrl: e, dimensions: { height: t, width: n }, hotspotColor:
|
|
225
|
-
return /* @__PURE__ */
|
|
224
|
+
let { imageUrl: e, dimensions: { height: t, width: n }, hotspotColor: i, outlineColor: a, shapes: o, strokeWidth: u, hoverOutlineColor: f, selectedHotspotColor: h } = this.props, { stateShapes: g, isDrawing: _, dimensions: { height: v, width: y } } = this.state, b = g || o;
|
|
225
|
+
return /* @__PURE__ */ m(C, { children: [e && /* @__PURE__ */ m(w, { children: [/* @__PURE__ */ p(T, {
|
|
226
226
|
onLoad: this.handleOnImageLoad,
|
|
227
227
|
ref: (e) => {
|
|
228
228
|
this.image = e;
|
|
@@ -232,9 +232,9 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
232
232
|
height: t,
|
|
233
233
|
width: n
|
|
234
234
|
} } : {}
|
|
235
|
-
}), /* @__PURE__ */
|
|
235
|
+
}), /* @__PURE__ */ p(E, { ref: (e) => {
|
|
236
236
|
this.resize = e;
|
|
237
|
-
} })] }), /* @__PURE__ */
|
|
237
|
+
} })] }), /* @__PURE__ */ p(D, {
|
|
238
238
|
height: v || t,
|
|
239
239
|
width: y || n,
|
|
240
240
|
onMouseDown: this.handleOnMouseDown,
|
|
@@ -242,35 +242,35 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
242
242
|
onMouseMove: this.handleMouseMove,
|
|
243
243
|
onContentMouseOut: this.handleOnMouseOutOrLeave,
|
|
244
244
|
onContentMouseLeave: this.handleOnMouseOutOrLeave,
|
|
245
|
-
children: /* @__PURE__ */
|
|
246
|
-
let
|
|
245
|
+
children: /* @__PURE__ */ p(S, { children: b.map((e, o) => {
|
|
246
|
+
let p;
|
|
247
247
|
switch (e.group) {
|
|
248
|
-
case
|
|
249
|
-
|
|
248
|
+
case r.RECTANGLES:
|
|
249
|
+
p = s;
|
|
250
250
|
break;
|
|
251
|
-
case
|
|
252
|
-
|
|
251
|
+
case r.CIRCLES:
|
|
252
|
+
p = l;
|
|
253
253
|
break;
|
|
254
|
-
case
|
|
255
|
-
|
|
254
|
+
case r.POLYGONS:
|
|
255
|
+
p = c;
|
|
256
256
|
break;
|
|
257
257
|
default: return null;
|
|
258
258
|
}
|
|
259
|
-
return /* @__PURE__ */
|
|
260
|
-
...e.group ===
|
|
261
|
-
...e.group ===
|
|
259
|
+
return /* @__PURE__ */ d(p, {
|
|
260
|
+
...e.group === r.CIRCLES ? { radius: e.radius } : {},
|
|
261
|
+
...e.group === r.RECTANGLES ? {
|
|
262
262
|
height: e.height,
|
|
263
263
|
width: e.width
|
|
264
264
|
} : {},
|
|
265
|
-
...e.group ===
|
|
265
|
+
...e.group === r.POLYGONS ? {
|
|
266
266
|
points: e.points,
|
|
267
267
|
addPolygonPoint: (e) => this.addPolygonPoint(e)
|
|
268
268
|
} : {},
|
|
269
269
|
correct: e.correct,
|
|
270
270
|
isDrawing: _,
|
|
271
|
-
hotspotColor:
|
|
272
|
-
hoverOutlineColor:
|
|
273
|
-
selectedHotspotColor:
|
|
271
|
+
hotspotColor: i,
|
|
272
|
+
hoverOutlineColor: f,
|
|
273
|
+
selectedHotspotColor: h,
|
|
274
274
|
id: e.id,
|
|
275
275
|
key: o,
|
|
276
276
|
onClick: () => this.handleOnSetAsCorrect(e),
|
|
@@ -280,7 +280,7 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
280
280
|
width: e.width,
|
|
281
281
|
x: e.x,
|
|
282
282
|
y: e.y,
|
|
283
|
-
strokeWidth:
|
|
283
|
+
strokeWidth: u,
|
|
284
284
|
imageHeight: v || t,
|
|
285
285
|
imageWidth: y || n,
|
|
286
286
|
...e.group === "polygons" ? { addPolygonPoint: (e) => this.addPolygonPoint(e) } : {}
|
|
@@ -290,23 +290,23 @@ var x = b(v, "Stage"), S = b(_, "Layer"), C = g("div")({ position: "relative" })
|
|
|
290
290
|
}
|
|
291
291
|
};
|
|
292
292
|
k.propTypes = {
|
|
293
|
-
disableDrag:
|
|
294
|
-
dimensions:
|
|
295
|
-
enableDrag:
|
|
296
|
-
shapeType:
|
|
297
|
-
imageUrl:
|
|
298
|
-
handleFinishDrawing:
|
|
299
|
-
hotspotColor:
|
|
300
|
-
selectedHotspotColor:
|
|
301
|
-
hoverOutlineColor:
|
|
302
|
-
multipleCorrect:
|
|
303
|
-
onUpdateImageDimension:
|
|
304
|
-
onUpdateShapes:
|
|
305
|
-
onDeleteShape:
|
|
306
|
-
outlineColor:
|
|
307
|
-
shapes:
|
|
308
|
-
strokeWidth:
|
|
309
|
-
preserveAspectRatioEnabled:
|
|
293
|
+
disableDrag: f.func.isRequired,
|
|
294
|
+
dimensions: f.object.isRequired,
|
|
295
|
+
enableDrag: f.func.isRequired,
|
|
296
|
+
shapeType: f.oneOf(Object.values(i)),
|
|
297
|
+
imageUrl: f.string.isRequired,
|
|
298
|
+
handleFinishDrawing: f.func.isRequired,
|
|
299
|
+
hotspotColor: f.string.isRequired,
|
|
300
|
+
selectedHotspotColor: f.string,
|
|
301
|
+
hoverOutlineColor: f.string,
|
|
302
|
+
multipleCorrect: f.bool.isRequired,
|
|
303
|
+
onUpdateImageDimension: f.func.isRequired,
|
|
304
|
+
onUpdateShapes: f.func.isRequired,
|
|
305
|
+
onDeleteShape: f.func.isRequired,
|
|
306
|
+
outlineColor: f.string.isRequired,
|
|
307
|
+
shapes: f.array.isRequired,
|
|
308
|
+
strokeWidth: f.number,
|
|
309
|
+
preserveAspectRatioEnabled: f.bool
|
|
310
310
|
};
|
|
311
311
|
//#endregion
|
|
312
312
|
export { k as default };
|
package/dist/author/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
1
|
+
import { SHAPE_GROUPS as e } from "./shapes/utils.js";
|
|
2
|
+
import { cloneDeep as t } from "@pie-element/shared-lodash";
|
|
3
3
|
//#region src/author/utils.ts
|
|
4
4
|
var n = (e, t, n, r) => {
|
|
5
5
|
if (n) {
|
|
@@ -33,10 +33,10 @@ var n = (e, t, n, r) => {
|
|
|
33
33
|
x: r(e.width, t.width, n.x),
|
|
34
34
|
y: r(e.height, t.height, n.y)
|
|
35
35
|
}))
|
|
36
|
-
}), s = (
|
|
37
|
-
if (r.group ===
|
|
38
|
-
if (r.group ===
|
|
39
|
-
if (r.group ===
|
|
36
|
+
}), s = (t, n, r) => r.map((r) => {
|
|
37
|
+
if (r.group === e.RECTANGLES) return i(t, n, r);
|
|
38
|
+
if (r.group === e.POLYGONS) return o(t, n, r);
|
|
39
|
+
if (r.group === e.CIRCLES) return a(t, n, r);
|
|
40
40
|
}), c = (e) => {
|
|
41
41
|
e ||= {};
|
|
42
42
|
let t = [], n = Object.keys(e);
|
|
@@ -45,14 +45,14 @@ var n = (e, t, n, r) => {
|
|
|
45
45
|
group: n,
|
|
46
46
|
index: e.index || t.length + r
|
|
47
47
|
})) : []), t) : t;
|
|
48
|
-
}, l = (
|
|
49
|
-
|
|
48
|
+
}, l = (e) => {
|
|
49
|
+
e ||= [];
|
|
50
50
|
let n = {
|
|
51
51
|
rectangles: [],
|
|
52
52
|
polygons: [],
|
|
53
53
|
circles: []
|
|
54
54
|
};
|
|
55
|
-
return
|
|
55
|
+
return e.length ? e.reduce((e, { group: t, ...n }) => (e[t] = [...e[t] || [], n], e), n) : t(n);
|
|
56
56
|
}, u = (e, t, n) => {
|
|
57
57
|
let r = !1;
|
|
58
58
|
if (!e || e.length <= 0) return r;
|