@glodon-aiot/react-components 3.2.2-beta.2 → 3.2.2-beta.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.
- package/dist/es/Button/index.mjs +48 -0
- package/dist/es/Button/style.less.mjs +4 -0
- package/dist/es/ConfirmableButton/index.mjs +59 -0
- package/dist/es/Drawable/Drawable.mjs +220 -0
- package/dist/es/Drawable/LineElement.mjs +27 -0
- package/dist/es/Drawable/MarkerElement.mjs +39 -0
- package/dist/es/Drawable/PolygonElement.mjs +88 -0
- package/dist/es/Drawable/index.mjs +16 -0
- package/dist/es/Drawable/state.mjs +134 -0
- package/dist/es/ExpandablePannel/index.mjs +94 -0
- package/dist/es/ExpandablePannel/style.less.mjs +4 -0
- package/dist/es/GOSImageMap/DrawableImageMap.mjs +49 -0
- package/dist/es/GOSImageMap/ImageMap.mjs +39 -0
- package/dist/es/IconButton/index.mjs +23 -0
- package/dist/es/IconButton/style.less.mjs +4 -0
- package/dist/es/Iconfont/index.mjs +8 -0
- package/dist/es/ImageMap/index.mjs +297 -0
- package/dist/es/ImageMap/style.less.mjs +4 -0
- package/dist/es/MouseTip/constant.mjs +9 -0
- package/dist/es/MouseTip/index.mjs +54 -0
- package/dist/es/MouseTip/style.less.mjs +4 -0
- package/dist/es/MouseTip/utils.mjs +70 -0
- package/dist/es/PanoramaRecordPlayer/index.mjs +84 -0
- package/dist/es/PassMap/index.mjs +43 -0
- package/dist/es/PassMap/style.less.mjs +4 -0
- package/dist/es/TrackMap/PointTooltip.mjs +86 -0
- package/dist/es/TrackMap/TrackPoint.mjs +57 -0
- package/dist/es/TrackMap/index.mjs +375 -0
- package/dist/es/TrackMap/style.less.mjs +4 -0
- package/dist/es/Zoom/index.mjs +48 -0
- package/dist/es/index.mjs +29 -0
- package/dist/es/style.css +1 -0
- package/dist/es/useBimface/index.mjs +148 -0
- package/dist/es/utils/JSAsyncLoader.mjs +7 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/style.css +1 -0
- package/dist/src/Button/index.d.ts +2 -3
- package/dist/src/ConfirmableButton/index.d.ts +1 -1
- package/dist/src/Drawable/LineElement.d.ts +0 -1
- package/dist/src/Drawable/MarkersMap.d.ts +0 -1
- package/dist/src/Drawable/PolygonElement.d.ts +0 -1
- package/dist/src/Drawable/index.d.ts +1 -2
- package/dist/src/Drawable/state.d.ts +1 -1
- package/dist/src/ExpandablePannel/index.d.ts +1 -2
- package/dist/src/GOSImageMap/DrawableImageMap.d.ts +0 -1
- package/dist/src/GOSImageMap/ImageMap.d.ts +0 -1
- package/dist/src/IconButton/index.d.ts +1 -2
- package/dist/src/Iconfont/CloudIconfont.d.ts +1 -2
- package/dist/src/Iconfont/EdgeIconfont.d.ts +1 -2
- package/dist/src/Iconfont/font_3929209_z3fhml098hr.d.ts +0 -0
- package/dist/src/Iconfont/font_edge.d.ts +0 -0
- package/dist/src/Iconfont/index.d.ts +2 -3
- package/dist/src/ImageMap/index.d.ts +2 -3
- package/dist/src/MouseTip/index.d.ts +1 -2
- package/dist/src/PanoramaRecordPlayer/index.d.ts +1 -1
- package/dist/src/PassMap/index.d.ts +2 -3
- package/dist/src/TrackMap/index.d.ts +2 -3
- package/dist/src/Zoom/index.d.ts +1 -1
- package/dist/src/index.d.ts +10 -10
- package/dist/src/useBimface/example.d.ts +0 -1
- package/dist/src/useBimface/index.d.ts +2 -2
- package/package.json +12 -9
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var d = Object.defineProperty, k = Object.defineProperties;
|
|
2
|
+
var f = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var n = Object.getOwnPropertySymbols;
|
|
4
|
+
var u = Object.prototype.hasOwnProperty, m = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var b = (o, t, r) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r, y = (o, t) => {
|
|
6
|
+
for (var r in t || (t = {}))
|
|
7
|
+
u.call(t, r) && b(o, r, t[r]);
|
|
8
|
+
if (n)
|
|
9
|
+
for (var r of n(t))
|
|
10
|
+
m.call(t, r) && b(o, r, t[r]);
|
|
11
|
+
return o;
|
|
12
|
+
}, a = (o, t) => k(o, f(t));
|
|
13
|
+
var i = (o, t) => {
|
|
14
|
+
var r = {};
|
|
15
|
+
for (var s in o)
|
|
16
|
+
u.call(o, s) && t.indexOf(s) < 0 && (r[s] = o[s]);
|
|
17
|
+
if (o != null && n)
|
|
18
|
+
for (var s of n(o))
|
|
19
|
+
t.indexOf(s) < 0 && m.call(o, s) && (r[s] = o[s]);
|
|
20
|
+
return r;
|
|
21
|
+
};
|
|
22
|
+
import { jsx as j } from "react/jsx-runtime";
|
|
23
|
+
import "./style.less.mjs";
|
|
24
|
+
const z = (o) => {
|
|
25
|
+
const e = o, {
|
|
26
|
+
primary: t = !1,
|
|
27
|
+
size: r = "medium",
|
|
28
|
+
backgroundColor: s,
|
|
29
|
+
label: c
|
|
30
|
+
} = e, l = i(e, [
|
|
31
|
+
"primary",
|
|
32
|
+
"size",
|
|
33
|
+
"backgroundColor",
|
|
34
|
+
"label"
|
|
35
|
+
]), p = t ? "storybook-button--primary" : "storybook-button--secondary";
|
|
36
|
+
return /* @__PURE__ */ j("button", a(y({
|
|
37
|
+
type: "button",
|
|
38
|
+
className: ["storybook-button", `storybook-button--${r}`, p].join(" "),
|
|
39
|
+
style: {
|
|
40
|
+
backgroundColor: s
|
|
41
|
+
}
|
|
42
|
+
}, l), {
|
|
43
|
+
children: c
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
z as Button
|
|
48
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var l = Object.getOwnPropertySymbols;
|
|
3
|
+
var C = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var a = (r, t, e) => t in r ? d(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, u = (r, t) => {
|
|
5
|
+
for (var e in t || (t = {}))
|
|
6
|
+
C.call(t, e) && a(r, e, t[e]);
|
|
7
|
+
if (l)
|
|
8
|
+
for (var e of l(t))
|
|
9
|
+
h.call(t, e) && a(r, e, t[e]);
|
|
10
|
+
return r;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
13
|
+
import { useState as k, useEffect as y } from "react";
|
|
14
|
+
import s from "antd/es/button";
|
|
15
|
+
import g from "antd/es/popconfirm";
|
|
16
|
+
const j = (r) => {
|
|
17
|
+
const {
|
|
18
|
+
name: t,
|
|
19
|
+
type: e,
|
|
20
|
+
style: x,
|
|
21
|
+
className: i,
|
|
22
|
+
children: c,
|
|
23
|
+
onConfirm: m
|
|
24
|
+
} = r, [f, n] = k(null);
|
|
25
|
+
return y(() => {
|
|
26
|
+
if (!r.confirm) {
|
|
27
|
+
n(null);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (r.confirm === !0) {
|
|
31
|
+
n({
|
|
32
|
+
text: `确认${t}吗?`
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
n(r.confirm);
|
|
37
|
+
}, [r.confirm]), f ? /* @__PURE__ */ o(g, {
|
|
38
|
+
rootClassName: "track-map-popconfirm",
|
|
39
|
+
okText: "确定",
|
|
40
|
+
cancelText: "取消",
|
|
41
|
+
title: f.text,
|
|
42
|
+
trigger: "click",
|
|
43
|
+
onConfirm: m,
|
|
44
|
+
children: /* @__PURE__ */ o(s, {
|
|
45
|
+
className: i,
|
|
46
|
+
type: e,
|
|
47
|
+
style: u({}, x),
|
|
48
|
+
children: c || t
|
|
49
|
+
})
|
|
50
|
+
}) : /* @__PURE__ */ o(s, {
|
|
51
|
+
className: i,
|
|
52
|
+
type: e,
|
|
53
|
+
onClick: m,
|
|
54
|
+
children: c || t
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
j as default
|
|
59
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
var $ = Object.defineProperty, H = Object.defineProperties;
|
|
2
|
+
var U = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var b = Object.getOwnPropertySymbols;
|
|
4
|
+
var V = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var x = (o, n, i) => n in o ? $(o, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : o[n] = i, R = (o, n) => {
|
|
6
|
+
for (var i in n || (n = {}))
|
|
7
|
+
V.call(n, i) && x(o, i, n[i]);
|
|
8
|
+
if (b)
|
|
9
|
+
for (var i of b(n))
|
|
10
|
+
q.call(n, i) && x(o, i, n[i]);
|
|
11
|
+
return o;
|
|
12
|
+
}, C = (o, n) => H(o, U(n));
|
|
13
|
+
import { jsx as d, jsxs as F } from "react/jsx-runtime";
|
|
14
|
+
import { useSize as J } from "ahooks";
|
|
15
|
+
import { useMachine as Q } from "@xstate/react";
|
|
16
|
+
import Z from "lodash/size";
|
|
17
|
+
import { useState as _, useRef as ee, useEffect as f } from "react";
|
|
18
|
+
import { assign as w } from "xstate";
|
|
19
|
+
import { DrawableContext as te } from "./index.mjs";
|
|
20
|
+
import Y from "./LineElement.mjs";
|
|
21
|
+
import I from "./MarkerElement.mjs";
|
|
22
|
+
import W from "./PolygonElement.mjs";
|
|
23
|
+
import { drawableMachine as ne } from "./state.mjs";
|
|
24
|
+
function ve(o) {
|
|
25
|
+
const {
|
|
26
|
+
state: n,
|
|
27
|
+
scale: i,
|
|
28
|
+
width: B,
|
|
29
|
+
height: G,
|
|
30
|
+
drawOptions: A,
|
|
31
|
+
lines: p,
|
|
32
|
+
polygons: u,
|
|
33
|
+
markers: g,
|
|
34
|
+
markRenderer: j,
|
|
35
|
+
onAddLine: L,
|
|
36
|
+
onAddPolygon: S,
|
|
37
|
+
onAddMarker: k,
|
|
38
|
+
onStateChange: y
|
|
39
|
+
} = o, [E, z] = _([]), [P, K] = _([]), [D, X] = _([]), c = ee(null), {
|
|
40
|
+
width: O,
|
|
41
|
+
height: N
|
|
42
|
+
} = J(c) || {};
|
|
43
|
+
function v({
|
|
44
|
+
x: e,
|
|
45
|
+
y: t
|
|
46
|
+
}) {
|
|
47
|
+
return {
|
|
48
|
+
x: e / i,
|
|
49
|
+
y: t / i
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function h({
|
|
53
|
+
x: e,
|
|
54
|
+
y: t
|
|
55
|
+
}) {
|
|
56
|
+
return {
|
|
57
|
+
x: e * i,
|
|
58
|
+
y: t * i
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const [l, a] = Q(ne, {
|
|
62
|
+
actions: {
|
|
63
|
+
onAddMarker: w(({
|
|
64
|
+
markerPoint: e
|
|
65
|
+
}) => (k && e && k(v(e)), {
|
|
66
|
+
markerPoint: void 0,
|
|
67
|
+
movingPoint: void 0
|
|
68
|
+
})),
|
|
69
|
+
onAddLine: w((e) => (e.lineStart && e.lineEnd && L && L(v(e.lineStart), v(e.lineEnd)), {
|
|
70
|
+
lineEnd: void 0,
|
|
71
|
+
lineStart: void 0,
|
|
72
|
+
movingPoint: void 0
|
|
73
|
+
})),
|
|
74
|
+
onAddPolygon: w(({
|
|
75
|
+
polygonPoints: e
|
|
76
|
+
}) => (S && e && e.length > 2 && S(e.map(v)), {
|
|
77
|
+
polygonPoints: void 0,
|
|
78
|
+
movingPoint: void 0
|
|
79
|
+
}))
|
|
80
|
+
},
|
|
81
|
+
services: {}
|
|
82
|
+
});
|
|
83
|
+
f(() => {
|
|
84
|
+
var e;
|
|
85
|
+
z((e = p == null ? void 0 : p.map(({
|
|
86
|
+
id: t,
|
|
87
|
+
start: s,
|
|
88
|
+
end: r
|
|
89
|
+
}) => ({
|
|
90
|
+
id: t,
|
|
91
|
+
start: h(s),
|
|
92
|
+
end: h(r)
|
|
93
|
+
}))) != null ? e : []);
|
|
94
|
+
}, [p]), f(() => {
|
|
95
|
+
var e;
|
|
96
|
+
X((e = g == null ? void 0 : g.map((t) => C(R({}, t), {
|
|
97
|
+
point: h(t.point)
|
|
98
|
+
}))) != null ? e : []);
|
|
99
|
+
}, [g]), f(() => {
|
|
100
|
+
var e;
|
|
101
|
+
K((e = u == null ? void 0 : u.map(({
|
|
102
|
+
id: t,
|
|
103
|
+
points: s,
|
|
104
|
+
options: r
|
|
105
|
+
}) => ({
|
|
106
|
+
id: t,
|
|
107
|
+
points: s.map(h),
|
|
108
|
+
options: r
|
|
109
|
+
}))) != null ? e : []);
|
|
110
|
+
}, [u, i]), f(() => {
|
|
111
|
+
y && l.matches("idle") && y("viewOnly");
|
|
112
|
+
}, [l.value]), f(() => {
|
|
113
|
+
if (y)
|
|
114
|
+
switch (n) {
|
|
115
|
+
case "drawingLine":
|
|
116
|
+
a("START_DRAW_LINE");
|
|
117
|
+
break;
|
|
118
|
+
case "drawingPolygon":
|
|
119
|
+
a("START_DRAW_POLYGON");
|
|
120
|
+
break;
|
|
121
|
+
case "addingMarker":
|
|
122
|
+
a("START_ADD_MARKER");
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}, [n]);
|
|
126
|
+
const {
|
|
127
|
+
lineStart: M,
|
|
128
|
+
lineEnd: ie,
|
|
129
|
+
polygonPoints: T,
|
|
130
|
+
movingPoint: m
|
|
131
|
+
} = l.context;
|
|
132
|
+
return /* @__PURE__ */ d(te.Provider, {
|
|
133
|
+
value: {
|
|
134
|
+
options: A != null ? A : {}
|
|
135
|
+
},
|
|
136
|
+
children: /* @__PURE__ */ d("div", {
|
|
137
|
+
ref: c,
|
|
138
|
+
className: "w-full h-full absolute left-0 top-0",
|
|
139
|
+
style: {
|
|
140
|
+
cursor: n === "viewOnly" ? void 0 : "crosshair",
|
|
141
|
+
width: B,
|
|
142
|
+
height: G
|
|
143
|
+
},
|
|
144
|
+
children: O && N && /* @__PURE__ */ F("svg", {
|
|
145
|
+
viewBox: `0 0 ${O} ${N}`,
|
|
146
|
+
version: "1.1",
|
|
147
|
+
className: "absolute inset-0",
|
|
148
|
+
onClick: (e) => {
|
|
149
|
+
if (!c.current)
|
|
150
|
+
return;
|
|
151
|
+
const {
|
|
152
|
+
top: t,
|
|
153
|
+
left: s
|
|
154
|
+
} = c.current.getBoundingClientRect(), r = {
|
|
155
|
+
x: e.clientX - s,
|
|
156
|
+
y: e.clientY - t
|
|
157
|
+
};
|
|
158
|
+
l.matches("drawingLine") ? a(M === void 0 ? {
|
|
159
|
+
type: "ADD_LINE_START",
|
|
160
|
+
point: r
|
|
161
|
+
} : {
|
|
162
|
+
type: "ADD_LINE_END",
|
|
163
|
+
point: r
|
|
164
|
+
}) : l.matches("drawingPolygon") ? a({
|
|
165
|
+
type: "ADD_POLYGON_POINT",
|
|
166
|
+
point: r
|
|
167
|
+
}) : l.matches("addingMarker") && a({
|
|
168
|
+
type: "ADD_MARKER",
|
|
169
|
+
point: r
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
onMouseMove: (e) => {
|
|
173
|
+
if (!c.current)
|
|
174
|
+
return;
|
|
175
|
+
const {
|
|
176
|
+
top: t,
|
|
177
|
+
left: s
|
|
178
|
+
} = c.current.getBoundingClientRect(), r = {
|
|
179
|
+
x: e.clientX - s,
|
|
180
|
+
y: e.clientY - t
|
|
181
|
+
};
|
|
182
|
+
a({
|
|
183
|
+
type: "MOUSE_MOVE",
|
|
184
|
+
point: r
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
children: [E == null ? void 0 : E.map((e, t) => /* @__PURE__ */ d(Y, R({}, e), t)), M && m && /* @__PURE__ */ d(Y, {
|
|
188
|
+
start: M,
|
|
189
|
+
end: m
|
|
190
|
+
}), P == null ? void 0 : P.map(({
|
|
191
|
+
points: e,
|
|
192
|
+
options: t
|
|
193
|
+
}, s) => /* @__PURE__ */ d(W, {
|
|
194
|
+
editing: !1,
|
|
195
|
+
points: e,
|
|
196
|
+
options: t
|
|
197
|
+
}, s)), Z(T) > 0 && m && /* @__PURE__ */ d(W, {
|
|
198
|
+
editing: !0,
|
|
199
|
+
points: [...T, m],
|
|
200
|
+
onClose: (e) => {
|
|
201
|
+
a({
|
|
202
|
+
type: "DRAW_POLYGON_COMPLETE"
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}), D == null ? void 0 : D.map((e) => /* @__PURE__ */ d(I, {
|
|
206
|
+
marker: e,
|
|
207
|
+
markRenderer: j
|
|
208
|
+
})), l.matches("addingMarker") && m && /* @__PURE__ */ d(I, {
|
|
209
|
+
marker: {
|
|
210
|
+
id: "addingMarker",
|
|
211
|
+
point: m
|
|
212
|
+
}
|
|
213
|
+
})]
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
ve as default
|
|
220
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as n, Fragment as m } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as x } from "react";
|
|
3
|
+
import { DrawableContext as a } from "./index.mjs";
|
|
4
|
+
function c(s) {
|
|
5
|
+
const {
|
|
6
|
+
start: o,
|
|
7
|
+
end: r
|
|
8
|
+
} = s, {
|
|
9
|
+
options: {
|
|
10
|
+
lineColor: t,
|
|
11
|
+
lineWidth: e
|
|
12
|
+
}
|
|
13
|
+
} = x(a);
|
|
14
|
+
return /* @__PURE__ */ n(m, {
|
|
15
|
+
children: /* @__PURE__ */ n("line", {
|
|
16
|
+
x1: o.x,
|
|
17
|
+
y1: o.y,
|
|
18
|
+
x2: r.x,
|
|
19
|
+
y2: r.y,
|
|
20
|
+
stroke: t != null ? t : "#FF5500",
|
|
21
|
+
strokeWidth: e != null ? e : 2
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
c as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
function o(t) {
|
|
3
|
+
const {
|
|
4
|
+
markRenderer: r,
|
|
5
|
+
marker: n
|
|
6
|
+
} = t, {
|
|
7
|
+
point: {
|
|
8
|
+
x: l,
|
|
9
|
+
y: i
|
|
10
|
+
}
|
|
11
|
+
} = n;
|
|
12
|
+
return /* @__PURE__ */ a("g", {
|
|
13
|
+
children: [/* @__PURE__ */ e("line", {}), /* @__PURE__ */ e("line", {}), /* @__PURE__ */ e("circle", {
|
|
14
|
+
cx: l,
|
|
15
|
+
cy: i,
|
|
16
|
+
r: 1,
|
|
17
|
+
fill: "transparent"
|
|
18
|
+
}), /* @__PURE__ */ e("foreignObject", {
|
|
19
|
+
x: l,
|
|
20
|
+
y: i,
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
fill: "green",
|
|
24
|
+
className: "relative overflow-visible",
|
|
25
|
+
children: /* @__PURE__ */ e("div", {
|
|
26
|
+
className: "inline-flex absolute",
|
|
27
|
+
draggable: !0,
|
|
28
|
+
onDragStart: () => {
|
|
29
|
+
},
|
|
30
|
+
onDragEnd: () => {
|
|
31
|
+
},
|
|
32
|
+
children: r && r(n)
|
|
33
|
+
})
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
o as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsxs as $, Fragment as v, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import D from "lodash/first";
|
|
3
|
+
import F from "lodash/size";
|
|
4
|
+
import { useState as j, useContext as w } from "react";
|
|
5
|
+
import { DrawableContext as z } from "./index.mjs";
|
|
6
|
+
function N(S) {
|
|
7
|
+
const {
|
|
8
|
+
points: e,
|
|
9
|
+
editing: i,
|
|
10
|
+
options: l,
|
|
11
|
+
onClose: g
|
|
12
|
+
} = S, [b, x] = j(!1), {
|
|
13
|
+
options: {
|
|
14
|
+
polygon: c
|
|
15
|
+
}
|
|
16
|
+
} = w(z);
|
|
17
|
+
if (!i && F(e) <= 2)
|
|
18
|
+
return null;
|
|
19
|
+
const a = D(e), p = e.map(({
|
|
20
|
+
x: n,
|
|
21
|
+
y: r
|
|
22
|
+
}) => `${n},${r}`).join(" "), y = a ? `${p} ${a.x},${a.y}` : p, {
|
|
23
|
+
showVertexIndex: d,
|
|
24
|
+
vertexBgColor: f,
|
|
25
|
+
vertexTextColor: m
|
|
26
|
+
} = c != null ? c : {}, k = d ? 10 : 5, A = i || d, {
|
|
27
|
+
hideBorder: P,
|
|
28
|
+
backgroundColor: u
|
|
29
|
+
} = l != null ? l : {};
|
|
30
|
+
return /* @__PURE__ */ $(v, {
|
|
31
|
+
children: [/* @__PURE__ */ o("polygon", {
|
|
32
|
+
points: `${y}`,
|
|
33
|
+
fill: u != null ? u : "rgba(255, 66, 66, 0.15)"
|
|
34
|
+
}), !P && /* @__PURE__ */ o("polyline", {
|
|
35
|
+
points: i ? p : y,
|
|
36
|
+
fill: "transparent",
|
|
37
|
+
stroke: "#FF5500",
|
|
38
|
+
strokeDasharray: "6 4",
|
|
39
|
+
strokeWidth: "2"
|
|
40
|
+
}), !P && (e == null ? void 0 : e.map(({
|
|
41
|
+
x: n,
|
|
42
|
+
y: r
|
|
43
|
+
}, h) => {
|
|
44
|
+
const s = h === F(e) - 1;
|
|
45
|
+
return /* @__PURE__ */ o("g", {
|
|
46
|
+
style: {
|
|
47
|
+
zIndex: s ? 1 : 100,
|
|
48
|
+
cursor: "pointer",
|
|
49
|
+
pointerEvents: s ? "none" : "bounding-box"
|
|
50
|
+
},
|
|
51
|
+
onMouseEnter: (t) => {
|
|
52
|
+
s || x(!0);
|
|
53
|
+
},
|
|
54
|
+
onMouseLeave: (t) => {
|
|
55
|
+
x(!1);
|
|
56
|
+
},
|
|
57
|
+
onClick: (t) => {
|
|
58
|
+
t.stopPropagation();
|
|
59
|
+
},
|
|
60
|
+
onDoubleClick: (t) => {
|
|
61
|
+
t.stopPropagation(), g && g(h);
|
|
62
|
+
},
|
|
63
|
+
children: A && (!s || !b) && /* @__PURE__ */ $(v, {
|
|
64
|
+
children: [/* @__PURE__ */ o("circle", {
|
|
65
|
+
cx: n,
|
|
66
|
+
cy: r,
|
|
67
|
+
r: k,
|
|
68
|
+
fill: f != null ? f : "#FF5500"
|
|
69
|
+
}), d && /* @__PURE__ */ o("text", {
|
|
70
|
+
x: n,
|
|
71
|
+
y: r,
|
|
72
|
+
"text-anchor": "middle",
|
|
73
|
+
fill: m != null ? m : "#fff",
|
|
74
|
+
dy: ".3em",
|
|
75
|
+
style: {
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
userSelect: "none"
|
|
78
|
+
},
|
|
79
|
+
children: h + 1
|
|
80
|
+
})]
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}))]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
N as default
|
|
88
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext as o } from "react";
|
|
2
|
+
function r(t, a, e) {
|
|
3
|
+
if (e)
|
|
4
|
+
return Math.abs(r(t, e) - r(a, e));
|
|
5
|
+
for (var n = Math.atan2(a.y - t.y, a.x - t.x); n < 0; )
|
|
6
|
+
n += 2 * Math.PI;
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
const l = o({
|
|
10
|
+
options: {}
|
|
11
|
+
});
|
|
12
|
+
l.displayName = "DrawableContext";
|
|
13
|
+
export {
|
|
14
|
+
l as DrawableContext,
|
|
15
|
+
r as calAngle
|
|
16
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { assign as o } from "@xstate/immer";
|
|
2
|
+
import { createMachine as e } from "xstate";
|
|
3
|
+
const d = e({
|
|
4
|
+
initial: "idle",
|
|
5
|
+
context: {},
|
|
6
|
+
states: {
|
|
7
|
+
idle: {
|
|
8
|
+
on: {
|
|
9
|
+
START_ADD_MARKER: {
|
|
10
|
+
target: "addingMarker"
|
|
11
|
+
},
|
|
12
|
+
START_DRAW_LINE: {
|
|
13
|
+
target: "drawingLine"
|
|
14
|
+
},
|
|
15
|
+
START_DRAW_POLYGON: {
|
|
16
|
+
target: "drawingPolygon"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
addingMarker: {
|
|
21
|
+
on: {
|
|
22
|
+
RESET: {
|
|
23
|
+
target: "idle",
|
|
24
|
+
actions: o((t) => {
|
|
25
|
+
t.markerPoint = void 0;
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
ADD_MARKER: {
|
|
29
|
+
target: "drawCompleted",
|
|
30
|
+
actions: [o((t, {
|
|
31
|
+
point: n
|
|
32
|
+
}) => {
|
|
33
|
+
t.markerPoint = n;
|
|
34
|
+
}), "onAddMarker"]
|
|
35
|
+
},
|
|
36
|
+
MOUSE_MOVE: {
|
|
37
|
+
target: "addingMarker",
|
|
38
|
+
actions: o((t, {
|
|
39
|
+
point: n
|
|
40
|
+
}) => {
|
|
41
|
+
t.movingPoint = n;
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
drawingLine: {
|
|
47
|
+
on: {
|
|
48
|
+
ADD_LINE_START: {
|
|
49
|
+
target: "drawingLine",
|
|
50
|
+
actions: o((t, n) => {
|
|
51
|
+
t.lineStart = n.point;
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
ADD_LINE_END: {
|
|
55
|
+
target: "drawCompleted",
|
|
56
|
+
actions: [o((t, n) => {
|
|
57
|
+
t.lineEnd = n.point;
|
|
58
|
+
}), "onAddLine"]
|
|
59
|
+
},
|
|
60
|
+
MOUSE_MOVE: {
|
|
61
|
+
target: "drawingLine",
|
|
62
|
+
actions: o((t, {
|
|
63
|
+
point: n
|
|
64
|
+
}) => {
|
|
65
|
+
t.movingPoint = n;
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
RESET: {
|
|
69
|
+
target: "drawCompleted"
|
|
70
|
+
},
|
|
71
|
+
CANCEL: {
|
|
72
|
+
target: "drawCompleted"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// exit: assign((ctx) => {
|
|
76
|
+
// ctx.lineEnd = undefined
|
|
77
|
+
// ctx.lineStart = undefined
|
|
78
|
+
// }),
|
|
79
|
+
},
|
|
80
|
+
drawingPolygon: {
|
|
81
|
+
on: {
|
|
82
|
+
CANCEL: {
|
|
83
|
+
target: "canceled"
|
|
84
|
+
},
|
|
85
|
+
RESET: {
|
|
86
|
+
target: "idle",
|
|
87
|
+
actions: o((t) => {
|
|
88
|
+
t.polygonPoints = void 0;
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
ADD_POLYGON_POINT: {
|
|
92
|
+
target: "drawingPolygon",
|
|
93
|
+
actions: o((t, {
|
|
94
|
+
point: n
|
|
95
|
+
}) => {
|
|
96
|
+
var a;
|
|
97
|
+
t.polygonPoints = (a = t.polygonPoints) != null ? a : [], t.polygonPoints.push(n);
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
MOUSE_MOVE: {
|
|
101
|
+
target: "drawingPolygon",
|
|
102
|
+
actions: o((t, {
|
|
103
|
+
point: n
|
|
104
|
+
}) => {
|
|
105
|
+
t.movingPoint = n;
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
DRAW_POLYGON_COMPLETE: {
|
|
109
|
+
target: "drawCompleted",
|
|
110
|
+
actions: ["onAddPolygon"]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
drawCompleted: {
|
|
115
|
+
always: {
|
|
116
|
+
target: "idle"
|
|
117
|
+
// actions: ['reset'],
|
|
118
|
+
// actions: assign((ctx) => {
|
|
119
|
+
// console.log('reset is done')
|
|
120
|
+
// // setTimeout(() => {
|
|
121
|
+
// // ctx.lineEnd = undefined
|
|
122
|
+
// // ctx.lineStart = undefined
|
|
123
|
+
// // ctx.markerPoint = undefined
|
|
124
|
+
// // ctx.polygonPoints = undefined
|
|
125
|
+
// // })
|
|
126
|
+
// }),
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
canceled: {}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
export {
|
|
133
|
+
d as drawableMachine
|
|
134
|
+
};
|