@aivex/ui 1.2.0-dev.57 → 1.2.0-dev.59
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/DESIGN.md +1 -1
- package/dist/components/Coachmark/Coachmark.cjs.map +1 -1
- package/dist/components/Coachmark/Coachmark.d.cts +2 -1
- package/dist/components/Coachmark/Coachmark.d.ts +2 -1
- package/dist/components/Coachmark/Coachmark.js.map +1 -1
- package/dist/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/components/Dialog/Dialog.d.cts +2 -1
- package/dist/components/Dialog/Dialog.d.ts +2 -1
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.cjs.map +1 -1
- package/dist/components/Icon/index.d.cts +28 -0
- package/dist/components/Icon/index.d.ts +28 -0
- package/dist/components/Icon/index.js +280 -250
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.cts +4 -5
- package/dist/components/Modal/Modal.d.ts +4 -5
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/ShapeEditor/ShapeEditor.cjs +1 -1
- package/dist/components/ShapeEditor/ShapeEditor.cjs.map +1 -1
- package/dist/components/ShapeEditor/ShapeEditor.js +406 -428
- package/dist/components/ShapeEditor/ShapeEditor.js.map +1 -1
- package/dist/components/ShapeEditor/_components/OverlayMarkers.cjs +2 -0
- package/dist/components/ShapeEditor/_components/OverlayMarkers.cjs.map +1 -0
- package/dist/components/ShapeEditor/_components/OverlayMarkers.d.cts +16 -0
- package/dist/components/ShapeEditor/_components/OverlayMarkers.d.ts +16 -0
- package/dist/components/ShapeEditor/_components/OverlayMarkers.js +41 -0
- package/dist/components/ShapeEditor/_components/OverlayMarkers.js.map +1 -0
- package/dist/components/ShapeEditor/_model/types/props.d.cts +3 -1
- package/dist/components/ShapeEditor/_model/types/props.d.ts +3 -1
- package/dist/components/ShapeEditor/_state/createInteractionController.cjs +1 -1
- package/dist/components/ShapeEditor/_state/createInteractionController.cjs.map +1 -1
- package/dist/components/ShapeEditor/_state/createInteractionController.js +4 -2
- package/dist/components/ShapeEditor/_state/createInteractionController.js.map +1 -1
- package/dist/components/ShapeEditor/_state/useAssistant.cjs +1 -1
- package/dist/components/ShapeEditor/_state/useAssistant.cjs.map +1 -1
- package/dist/components/ShapeEditor/_state/useAssistant.d.cts +1 -0
- package/dist/components/ShapeEditor/_state/useAssistant.d.ts +1 -0
- package/dist/components/ShapeEditor/_state/useAssistant.js +81 -74
- package/dist/components/ShapeEditor/_state/useAssistant.js.map +1 -1
- package/dist/components/ShapeEditor/_state/useDrawSession.cjs +1 -1
- package/dist/components/ShapeEditor/_state/useDrawSession.cjs.map +1 -1
- package/dist/components/ShapeEditor/_state/useDrawSession.d.cts +4 -1
- package/dist/components/ShapeEditor/_state/useDrawSession.d.ts +4 -1
- package/dist/components/ShapeEditor/_state/useDrawSession.js +184 -164
- package/dist/components/ShapeEditor/_state/useDrawSession.js.map +1 -1
- package/dist/components/ShapeEditor/_state/useEditorDocument.cjs +1 -1
- package/dist/components/ShapeEditor/_state/useEditorDocument.cjs.map +1 -1
- package/dist/components/ShapeEditor/_state/useEditorDocument.d.cts +7 -0
- package/dist/components/ShapeEditor/_state/useEditorDocument.d.ts +7 -0
- package/dist/components/ShapeEditor/_state/useEditorDocument.js +61 -31
- package/dist/components/ShapeEditor/_state/useEditorDocument.js.map +1 -1
- package/dist/components/ShapeEditor/_state/useSelectionModel.cjs +1 -1
- package/dist/components/ShapeEditor/_state/useSelectionModel.cjs.map +1 -1
- package/dist/components/ShapeEditor/_state/useSelectionModel.js +10 -3
- package/dist/components/ShapeEditor/_state/useSelectionModel.js.map +1 -1
- package/dist/components/Toast/Toast.cjs.map +1 -1
- package/dist/components/Toast/Toast.d.cts +2 -1
- package/dist/components/Toast/Toast.d.ts +2 -1
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +53 -53
- package/dist/llms-full.txt +11 -11
- package/dist/llms.txt +2 -2
- package/dist/utils/dataAttributes.d.cts +7 -0
- package/dist/utils/dataAttributes.d.ts +7 -0
- package/package.json +1 -1
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
import { SHAPE_TYPE as e, generateId as t, isShapeEditable as n } from "../_model/geometry.js";
|
|
3
3
|
import { TOOL as r } from "../_model/tools.js";
|
|
4
4
|
import { simplifyPath as i } from "../_model/brush.js";
|
|
5
|
-
import { buildScalarMaskRaster as a, polygonArea as o, scalarMaskToPolygons as
|
|
6
|
-
import { clonePoints as
|
|
7
|
-
import { useLatestRef as
|
|
8
|
-
import { useCallback as
|
|
5
|
+
import { buildScalarMaskRaster as a, polygonArea as o, scalarMaskToPolygons as ee, shapesToFilledPolygons as s } from "../_model/scalarMask.js";
|
|
6
|
+
import { clonePoints as c, cloneScalarStrokes as l, pointsEqual as u, scalarStrokesEqual as d } from "./drawSessionState.js";
|
|
7
|
+
import { useLatestRef as f } from "./useLatestRef.js";
|
|
8
|
+
import { useCallback as p, useRef as m } from "react";
|
|
9
9
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
10
|
-
var
|
|
11
|
-
function
|
|
10
|
+
var te = 10;
|
|
11
|
+
function ne(e, t) {
|
|
12
12
|
if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
|
|
13
13
|
let n = e.brush, r = t.brush;
|
|
14
14
|
return !n || !r ? n === r : n.mode === r.mode && n.editing === r.editing && n.editTargetIds.length === r.editTargetIds.length && n.editTargetIds.every((e, t) => e === r.editTargetIds[t]);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
let
|
|
18
|
-
let e =
|
|
16
|
+
function h({ toolRef: h, selRef: g, docRef: _, readOnlyRef: v, draftRef: y, brushSizeRef: b, simplifyEpsilonRef: x, draftMeta: S, engineRef: C, onDrawSessionChange: re, onDraftShapeChange: ie, changeSelection: w, createShape: ae, onDrawAttemptWithoutDraft: oe }) {
|
|
17
|
+
let se = f(re), T = f(ie), ce = f(S), E = f(ae), le = f(oe), D = p(() => y.current ? !0 : (le.current?.(), !1), [y]), ue = m(null), O = m([]), k = m(null), A = m(/* @__PURE__ */ new Set()), j = m([[]]), M = m(0), N = m(null), P = m([]), F = m([]), I = m([]), L = m([[]]), R = m(0), z = m("draw"), B = p(() => z.current === "erase" ? "erase" : "add", []), V = p(() => I.current.length > 0 || P.current.length > 0 || h.current === r.BRUSH && O.current.length > 0, [h]), H = p(() => {
|
|
18
|
+
let e = h.current;
|
|
19
19
|
return e === r.BRUSH && V() ? "brush" : e === r.POLYGON && O.current.length > 0 ? "polygon" : e === r.PATH && O.current.length > 0 ? "path" : "none";
|
|
20
|
-
}, [V,
|
|
21
|
-
let e =
|
|
20
|
+
}, [V, h]), U = p(() => {
|
|
21
|
+
let e = h.current;
|
|
22
22
|
return e === r.BRUSH ? O.current.length > 0 || R.current > 0 : e === r.POLYGON || e === r.PATH ? M.current > 0 : !1;
|
|
23
|
-
}, [
|
|
24
|
-
let e =
|
|
23
|
+
}, [h]), W = p(() => {
|
|
24
|
+
let e = h.current;
|
|
25
25
|
return e === r.BRUSH ? O.current.length === 0 && R.current < L.current.length - 1 : e === r.POLYGON || e === r.PATH ? M.current < j.current.length - 1 : !1;
|
|
26
|
-
}, [
|
|
26
|
+
}, [h]), de = p(() => H() !== "none", [H]), fe = p(() => z.current, []), G = p(() => {
|
|
27
27
|
let e = H(), t = {
|
|
28
28
|
active: e !== "none",
|
|
29
29
|
kind: e,
|
|
@@ -34,18 +34,18 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
|
|
|
34
34
|
editing: I.current.length > 0,
|
|
35
35
|
editTargetIds: [...I.current]
|
|
36
36
|
} : void 0
|
|
37
|
-
}, n =
|
|
38
|
-
n &&
|
|
37
|
+
}, n = ue.current;
|
|
38
|
+
n && ne(n, t) || (ue.current = t, se.current?.(t));
|
|
39
39
|
}, [
|
|
40
40
|
W,
|
|
41
41
|
U,
|
|
42
42
|
H
|
|
43
|
-
]), K =
|
|
43
|
+
]), K = p(() => {
|
|
44
44
|
L.current = [[]], R.current = 0;
|
|
45
|
-
}, []), q =
|
|
46
|
-
let t =
|
|
45
|
+
}, []), q = p(() => {
|
|
46
|
+
let t = C.current;
|
|
47
47
|
if (!t) return;
|
|
48
|
-
let n =
|
|
48
|
+
let n = h.current;
|
|
49
49
|
if (n === r.BRUSH) {
|
|
50
50
|
let e = [...P.current];
|
|
51
51
|
if (O.current.length && e.push({
|
|
@@ -55,264 +55,284 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
|
|
|
55
55
|
t.clearPreview();
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
let n = a(e,
|
|
58
|
+
let n = a(e, b.current, F.current);
|
|
59
59
|
if (!n) {
|
|
60
60
|
t.clearPreview();
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
let r =
|
|
63
|
+
let r = y.current?.color ?? "#00e5ff";
|
|
64
64
|
t.previewScalarMask(n, r);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
let i = O.current;
|
|
68
68
|
if (!i.length) {
|
|
69
|
-
t.clearPreview(), N.current && (N.current = null,
|
|
69
|
+
t.clearPreview(), N.current && (N.current = null, T.current?.(null));
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
let o = {
|
|
73
|
-
...
|
|
74
|
-
color:
|
|
75
|
-
},
|
|
76
|
-
if (t.previewPoly(i, k.current, o, !1,
|
|
77
|
-
let t =
|
|
73
|
+
...y.current,
|
|
74
|
+
color: y.current?.color ?? "#00e5ff"
|
|
75
|
+
}, ee = Array.from(A.current), s = n !== r.PATH;
|
|
76
|
+
if (t.previewPoly(i, k.current, o, !1, ee, s), n === r.POLYGON || n === r.PATH) {
|
|
77
|
+
let t = T.current;
|
|
78
78
|
t && i !== N.current && (N.current = i, t({
|
|
79
79
|
type: e.POLYGON,
|
|
80
|
-
points:
|
|
81
|
-
meta:
|
|
80
|
+
points: c(i),
|
|
81
|
+
meta: ce.current
|
|
82
82
|
}));
|
|
83
83
|
}
|
|
84
84
|
}, [
|
|
85
|
-
x,
|
|
86
|
-
B,
|
|
87
85
|
b,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
B,
|
|
87
|
+
y,
|
|
88
|
+
C,
|
|
89
|
+
h
|
|
90
|
+
]), pe = p((e) => {
|
|
91
|
+
let t = l(e), n = L.current, r = R.current, i = n[r];
|
|
92
|
+
i && d(i, t) || (L.current = [...n.slice(0, r + 1), t], R.current += 1, G());
|
|
93
|
+
}, [G]), J = p((e) => {
|
|
94
94
|
let t = j.current, n = M.current, r = t[n];
|
|
95
|
-
r &&
|
|
96
|
-
}, []), Y =
|
|
97
|
-
O.current = [], P.current = [], F.current = [], I.current = [], k.current = null, A.current = /* @__PURE__ */ new Set(), j.current = [[]], M.current = 0, N.current = null, K(),
|
|
95
|
+
r && u(r, e) || (j.current = [...t.slice(0, n + 1), c(e)], M.current += 1);
|
|
96
|
+
}, []), Y = p(() => {
|
|
97
|
+
O.current = [], P.current = [], F.current = [], I.current = [], k.current = null, A.current = /* @__PURE__ */ new Set(), j.current = [[]], M.current = 0, N.current = null, K(), C.current?.clearPreview(), T.current?.(null), G();
|
|
98
98
|
}, [
|
|
99
|
-
|
|
99
|
+
C,
|
|
100
100
|
G,
|
|
101
101
|
K
|
|
102
|
-
]), X =
|
|
102
|
+
]), X = p((e, t) => {
|
|
103
103
|
O.current = e, A.current = new Set(Array.from(A.current).filter((t) => t >= 0 && t < e.length)), t && J(e), q(), G();
|
|
104
104
|
}, [
|
|
105
105
|
G,
|
|
106
106
|
J,
|
|
107
107
|
q
|
|
108
|
-
]),
|
|
109
|
-
if (
|
|
108
|
+
]), me = p(() => c(O.current), []), he = p(() => O.current.length > 0, []), ge = p((t, n) => {
|
|
109
|
+
if (h.current !== r.POLYGON) return !1;
|
|
110
110
|
let i = O.current;
|
|
111
111
|
if (i.length < 3) return !1;
|
|
112
112
|
let a = i[0];
|
|
113
|
-
return Math.hypot(t.x - a.x, t.y - a.y) > n ? !1 : (
|
|
114
|
-
}, [
|
|
113
|
+
return Math.hypot(t.x - a.x, t.y - a.y) > n ? !1 : D() ? (E.current(e.POLYGON, i), Y(), !0) : !0;
|
|
114
|
+
}, [
|
|
115
|
+
D,
|
|
116
|
+
Y,
|
|
117
|
+
h
|
|
118
|
+
]), _e = p((e) => {
|
|
115
119
|
let t = O.current;
|
|
116
120
|
return e < 0 || e >= t.length ? !1 : (X(t.filter((t, n) => n !== e), !0), !0);
|
|
117
|
-
}, [X]),
|
|
121
|
+
}, [X]), ve = p((e, t) => {
|
|
118
122
|
let n = O.current;
|
|
119
123
|
if (e < 0 || e >= n.length) return null;
|
|
120
124
|
let r = new Set(A.current);
|
|
121
125
|
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), A.current = r, k.current = null, q(), G(), {
|
|
122
|
-
base:
|
|
126
|
+
base: c(n),
|
|
123
127
|
indices: Array.from(r)
|
|
124
128
|
};
|
|
125
|
-
}, [G, q]),
|
|
129
|
+
}, [G, q]), ye = p((e) => {
|
|
126
130
|
A.current = /* @__PURE__ */ new Set(), k.current = e, X([...O.current, e], !0);
|
|
127
|
-
}, [X]),
|
|
131
|
+
}, [X]), be = p((e) => {
|
|
128
132
|
k.current = null, A.current = /* @__PURE__ */ new Set(), O.current = [{ ...e }], q(), G();
|
|
129
|
-
}, [G, q]),
|
|
133
|
+
}, [G, q]), xe = p((e, t) => {
|
|
130
134
|
let n = O.current[O.current.length - 1];
|
|
131
135
|
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (O.current = [...O.current, { ...e }], k.current = null, q(), G(), !0);
|
|
132
|
-
}, [G, q]),
|
|
136
|
+
}, [G, q]), Se = p((e, t, n, r) => {
|
|
133
137
|
let i = new Set(t);
|
|
134
138
|
O.current = e.map((e, t) => i.has(t) ? {
|
|
135
139
|
x: e.x + n,
|
|
136
140
|
y: e.y + r
|
|
137
141
|
} : { ...e }), k.current = null, q(), G();
|
|
138
|
-
}, [G, q]),
|
|
142
|
+
}, [G, q]), Ce = p((e) => {
|
|
139
143
|
e && (J(O.current), q(), G());
|
|
140
144
|
}, [
|
|
141
145
|
G,
|
|
142
146
|
J,
|
|
143
147
|
q
|
|
144
|
-
]),
|
|
148
|
+
]), we = p((e) => {
|
|
145
149
|
k.current = e ? { ...e } : null, q();
|
|
146
|
-
}, [q]),
|
|
147
|
-
let e =
|
|
148
|
-
return e === r.BRUSH ?
|
|
150
|
+
}, [q]), Te = p(() => O.current.length > 0 ? (O.current = [], q(), G(), !0) : R.current <= 0 ? !1 : (--R.current, P.current = l(L.current[R.current]), q(), G(), !0), [G, q]), Ee = p(() => O.current.length > 0 || R.current >= L.current.length - 1 ? !1 : (R.current += 1, P.current = l(L.current[R.current]), q(), G(), !0), [G, q]), Z = p(() => M.current <= 0 ? !1 : (--M.current, O.current = c(j.current[M.current]), A.current = /* @__PURE__ */ new Set(), q(), G(), !0), [G, q]), De = p(() => M.current >= j.current.length - 1 ? !1 : (M.current += 1, O.current = c(j.current[M.current]), A.current = /* @__PURE__ */ new Set(), q(), G(), !0), [G, q]), Oe = p(() => {
|
|
151
|
+
let e = h.current;
|
|
152
|
+
return e === r.BRUSH ? Te() : e === r.POLYGON || e === r.PATH ? Z() : !1;
|
|
149
153
|
}, [
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
]),
|
|
154
|
-
let e =
|
|
155
|
-
return e === r.BRUSH ?
|
|
154
|
+
h,
|
|
155
|
+
Te,
|
|
156
|
+
Z
|
|
157
|
+
]), ke = p(() => {
|
|
158
|
+
let e = h.current;
|
|
159
|
+
return e === r.BRUSH ? Ee() : e === r.POLYGON || e === r.PATH ? De() : !1;
|
|
156
160
|
}, [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
]), Q =
|
|
161
|
-
let e =
|
|
161
|
+
Ee,
|
|
162
|
+
De,
|
|
163
|
+
h
|
|
164
|
+
]), Q = p(() => {
|
|
165
|
+
let e = g.current;
|
|
162
166
|
if (!e.length) return I.current.length > 0;
|
|
163
|
-
let t =
|
|
167
|
+
let t = _.current.getShapes().filter((t) => e.includes(t.id) && n(t)), r = s(t);
|
|
164
168
|
return r.length ? (I.current = t.map((e) => e.id), F.current = r, !0) : (I.current = [], F.current = [], !1);
|
|
165
|
-
}, [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
}, [_, g]), Ae = p(() => {
|
|
170
|
+
let e = I.current;
|
|
171
|
+
if (!e.length) return;
|
|
172
|
+
let t = _.current.getShapes().filter((t) => e.includes(t.id) && n(t)), i = t.length ? s(t) : [];
|
|
173
|
+
I.current = i.length ? t.map((e) => e.id) : [], F.current = i, h.current === r.BRUSH && q(), G();
|
|
174
|
+
}, [
|
|
175
|
+
_,
|
|
176
|
+
G,
|
|
177
|
+
q,
|
|
178
|
+
h
|
|
179
|
+
]), $ = p(() => {
|
|
180
|
+
if (v.current) return !1;
|
|
181
|
+
let r = [...P.current];
|
|
182
|
+
O.current.length && r.push({
|
|
183
|
+
points: c(O.current),
|
|
170
184
|
mode: B()
|
|
171
185
|
});
|
|
172
|
-
let
|
|
173
|
-
if (!
|
|
174
|
-
let
|
|
175
|
-
if (!
|
|
176
|
-
let
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
r.push({
|
|
186
|
+
let i = I.current, l = i.length ? _.current.getShapes().filter((e) => i.includes(e.id) && n(e)) : [], u = l.length ? s(l) : [];
|
|
187
|
+
if (!r.length && !u.length) return i.length && Y(), !1;
|
|
188
|
+
let d = a(r, b.current, u);
|
|
189
|
+
if (!d) return Y(), !1;
|
|
190
|
+
let f = ee(d, x.current);
|
|
191
|
+
if (l.length) {
|
|
192
|
+
if (!f.length) return _.current.remove(l.map((e) => e.id)), Y(), w([]), !0;
|
|
193
|
+
f.sort((e, t) => o(t) - o(e));
|
|
194
|
+
let n = [], r = [], i = [];
|
|
195
|
+
for (let a = 0; a < f.length; a++) {
|
|
196
|
+
let o = f[a];
|
|
197
|
+
if (a < l.length) {
|
|
198
|
+
let t = l[a];
|
|
199
|
+
n.push({
|
|
187
200
|
...t,
|
|
188
201
|
type: e.POLYGON,
|
|
189
202
|
points: o
|
|
190
|
-
}),
|
|
203
|
+
}), i.push(t.id);
|
|
191
204
|
} else {
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
...
|
|
195
|
-
id:
|
|
205
|
+
let n = l[0], a = t();
|
|
206
|
+
r.push({
|
|
207
|
+
...n,
|
|
208
|
+
id: a,
|
|
196
209
|
type: e.POLYGON,
|
|
197
210
|
points: o
|
|
198
|
-
}),
|
|
211
|
+
}), i.push(a);
|
|
199
212
|
}
|
|
200
213
|
}
|
|
201
|
-
let
|
|
202
|
-
return
|
|
214
|
+
let a = l.slice(f.length).map((e) => e.id);
|
|
215
|
+
return _.current.commit({
|
|
216
|
+
update: n,
|
|
217
|
+
create: r,
|
|
218
|
+
remove: a
|
|
219
|
+
}), Y(), w(i), !0;
|
|
203
220
|
}
|
|
204
|
-
if (!
|
|
205
|
-
let
|
|
206
|
-
if (!
|
|
207
|
-
let
|
|
221
|
+
if (!f.length) return Y(), !1;
|
|
222
|
+
let p = y.current;
|
|
223
|
+
if (!p) return le.current?.(), !1;
|
|
224
|
+
let m = f.map((n) => ({
|
|
208
225
|
id: t(),
|
|
209
226
|
type: e.POLYGON,
|
|
210
227
|
points: n,
|
|
211
|
-
style:
|
|
212
|
-
meta:
|
|
228
|
+
style: p,
|
|
229
|
+
meta: S
|
|
213
230
|
}));
|
|
214
|
-
return
|
|
231
|
+
return _.current.create(m), w(m.map((e) => e.id)), Y(), !0;
|
|
215
232
|
}, [
|
|
216
|
-
x,
|
|
217
|
-
B,
|
|
218
|
-
T,
|
|
219
|
-
v,
|
|
220
|
-
C,
|
|
221
233
|
b,
|
|
234
|
+
B,
|
|
235
|
+
w,
|
|
236
|
+
_,
|
|
237
|
+
S,
|
|
222
238
|
y,
|
|
239
|
+
v,
|
|
223
240
|
Y,
|
|
224
|
-
|
|
225
|
-
]),
|
|
226
|
-
let t =
|
|
241
|
+
x
|
|
242
|
+
]), je = p(() => {
|
|
243
|
+
let t = h.current;
|
|
227
244
|
if (t === r.BRUSH) return $();
|
|
228
245
|
let n = O.current;
|
|
229
|
-
return t === r.POLYGON && n.length >= 3 ? (
|
|
246
|
+
return t === r.POLYGON && n.length >= 3 && D() ? (E.current(e.POLYGON, n), Y(), !0) : !1;
|
|
230
247
|
}, [
|
|
231
248
|
$,
|
|
249
|
+
D,
|
|
232
250
|
Y,
|
|
233
|
-
|
|
234
|
-
]),
|
|
251
|
+
h
|
|
252
|
+
]), Me = p(() => {
|
|
235
253
|
let t = O.current;
|
|
236
|
-
if (
|
|
237
|
-
let n = i(t,
|
|
238
|
-
n.length >= 3 && D.current(e.POLYGON, n);
|
|
254
|
+
if (h.current === r.PATH && t.length >= 3) {
|
|
255
|
+
let n = i(t, x.current);
|
|
256
|
+
n.length >= 3 && D() && E.current(e.POLYGON, n);
|
|
239
257
|
}
|
|
240
258
|
Y();
|
|
241
259
|
}, [
|
|
260
|
+
D,
|
|
242
261
|
Y,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
]),
|
|
262
|
+
x,
|
|
263
|
+
h
|
|
264
|
+
]), Ne = p((e) => {
|
|
246
265
|
z.current = e, G(), q();
|
|
247
|
-
}, [G, q]),
|
|
248
|
-
if (
|
|
266
|
+
}, [G, q]), Pe = p(() => {
|
|
267
|
+
if (v.current || h.current !== r.BRUSH) return !1;
|
|
249
268
|
P.current = [], O.current = [], K();
|
|
250
269
|
let e = Q();
|
|
251
270
|
return G(), q(), e;
|
|
252
271
|
}, [
|
|
253
272
|
G,
|
|
254
|
-
|
|
273
|
+
v,
|
|
255
274
|
q,
|
|
256
275
|
K,
|
|
257
276
|
Q,
|
|
258
|
-
|
|
259
|
-
]),
|
|
277
|
+
h
|
|
278
|
+
]), Fe = p(() => {
|
|
260
279
|
let e = A.current;
|
|
261
280
|
if (!e.size) return !1;
|
|
262
281
|
let t = O.current.filter((t, n) => !e.has(n));
|
|
263
282
|
return A.current = /* @__PURE__ */ new Set(), X(t, !0), !0;
|
|
264
|
-
}, [X]),
|
|
265
|
-
let t =
|
|
283
|
+
}, [X]), Ie = p((e) => {
|
|
284
|
+
let t = C.current, n = O.current;
|
|
266
285
|
if (!t || !n.length) return -1;
|
|
267
|
-
let r =
|
|
286
|
+
let r = te / (t.viewport.scale || 1);
|
|
268
287
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
269
288
|
let i = n[t];
|
|
270
289
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
271
290
|
}
|
|
272
291
|
return -1;
|
|
273
|
-
}, [
|
|
292
|
+
}, [C]), Le = p(() => {
|
|
274
293
|
O.current.length >= 1 && (P.current.push({
|
|
275
|
-
points:
|
|
294
|
+
points: c(O.current),
|
|
276
295
|
mode: B()
|
|
277
|
-
}), O.current = [],
|
|
296
|
+
}), O.current = [], pe(P.current)), q(), G();
|
|
278
297
|
}, [
|
|
279
298
|
B,
|
|
280
299
|
G,
|
|
281
|
-
|
|
300
|
+
pe,
|
|
282
301
|
q
|
|
283
302
|
]);
|
|
284
303
|
return {
|
|
285
304
|
reset: Y,
|
|
286
|
-
undoSession:
|
|
287
|
-
redoSession:
|
|
305
|
+
undoSession: Oe,
|
|
306
|
+
redoSession: ke,
|
|
288
307
|
canUndoSession: U,
|
|
289
308
|
canRedoSession: W,
|
|
290
|
-
hasDraftSession:
|
|
291
|
-
hasDraftPoints:
|
|
292
|
-
commitDraftSession:
|
|
293
|
-
completeFreehandStroke:
|
|
294
|
-
setBrushScalarMode:
|
|
295
|
-
getBrushScalarMode:
|
|
309
|
+
hasDraftSession: de,
|
|
310
|
+
hasDraftPoints: he,
|
|
311
|
+
commitDraftSession: je,
|
|
312
|
+
completeFreehandStroke: Me,
|
|
313
|
+
setBrushScalarMode: Ne,
|
|
314
|
+
getBrushScalarMode: fe,
|
|
296
315
|
hasBrushSession: V,
|
|
297
316
|
commitBrush: $,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
syncBrushTargets: Ae,
|
|
318
|
+
cancelBrush: p(() => {
|
|
319
|
+
h.current === r.BRUSH && Y();
|
|
320
|
+
}, [Y, h]),
|
|
321
|
+
beginBrushEditFromSelection: Pe,
|
|
322
|
+
deleteDraftSelectedPoints: Fe,
|
|
323
|
+
hitDraftPoint: Ie,
|
|
324
|
+
getDraftPointsSnapshot: me,
|
|
325
|
+
tryClosePolygon: ge,
|
|
326
|
+
removeDraftPoint: _e,
|
|
327
|
+
selectDraftPointForDrag: ve,
|
|
328
|
+
appendPolygonPoint: ye,
|
|
329
|
+
beginStroke: be,
|
|
330
|
+
appendStrokePoint: xe,
|
|
331
|
+
moveDraftPoints: Se,
|
|
332
|
+
commitDraftPointDrag: Ce,
|
|
333
|
+
setDraftCursor: we,
|
|
334
|
+
finishScalarStroke: Le,
|
|
335
|
+
handleToolChange: p((e, t) => {
|
|
316
336
|
if (t) {
|
|
317
337
|
Y(), z.current = "draw";
|
|
318
338
|
return;
|
|
@@ -329,8 +349,8 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
|
|
|
329
349
|
K,
|
|
330
350
|
Q
|
|
331
351
|
]),
|
|
332
|
-
handleBrushSelectionChange:
|
|
333
|
-
if (!(
|
|
352
|
+
handleBrushSelectionChange: p((e, t) => {
|
|
353
|
+
if (!(h.current !== r.BRUSH || t)) {
|
|
334
354
|
if (!e.length) {
|
|
335
355
|
G();
|
|
336
356
|
return;
|
|
@@ -342,11 +362,11 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
|
|
|
342
362
|
q,
|
|
343
363
|
K,
|
|
344
364
|
Q,
|
|
345
|
-
|
|
365
|
+
h
|
|
346
366
|
])
|
|
347
367
|
};
|
|
348
368
|
}
|
|
349
369
|
//#endregion
|
|
350
|
-
export {
|
|
370
|
+
export { h as useDrawSession };
|
|
351
371
|
|
|
352
372
|
//# sourceMappingURL=useDrawSession.js.map
|