@activecollab/components 2.0.591 → 2.0.593
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/cjs/components/BatchEdit/BatchEdit.js +164 -23
- package/dist/cjs/components/BatchEdit/BatchEdit.js.map +1 -1
- package/dist/cjs/components/BatchEdit/BatchProperties.js +19 -3
- package/dist/cjs/components/BatchEdit/BatchProperties.js.map +1 -1
- package/dist/cjs/components/BatchEdit/Styles.js +67 -1
- package/dist/cjs/components/BatchEdit/Styles.js.map +1 -1
- package/dist/cjs/components/PillButton/PillButton.js.map +1 -1
- package/dist/cjs/components/PillButton/Styles.js +1 -1
- package/dist/cjs/components/PillButton/Styles.js.map +1 -1
- package/dist/cjs/components/Popper/Popper.js +20 -2
- package/dist/cjs/components/Popper/Popper.js.map +1 -1
- package/dist/cjs/presentation/__tests__/WhiteboardElbow.test.js +55 -0
- package/dist/cjs/presentation/__tests__/WhiteboardElbow.test.js.map +1 -0
- package/dist/cjs/presentation/whiteboard/elementToolbars.js +18 -18
- package/dist/cjs/presentation/whiteboard/elementToolbars.js.map +1 -1
- package/dist/cjs/presentation/whiteboard/lineElements.js +182 -224
- package/dist/cjs/presentation/whiteboard/lineElements.js.map +1 -1
- package/dist/cjs/presentation/whiteboard/lineInspector.js +1 -1
- package/dist/cjs/presentation/whiteboard/lineInspector.js.map +1 -1
- package/dist/cjs/presentation/whiteboard/lineModel.js +322 -84
- package/dist/cjs/presentation/whiteboard/lineModel.js.map +1 -1
- package/dist/esm/components/BatchEdit/BatchEdit.d.ts +33 -2
- package/dist/esm/components/BatchEdit/BatchEdit.d.ts.map +1 -1
- package/dist/esm/components/BatchEdit/BatchEdit.js +149 -24
- package/dist/esm/components/BatchEdit/BatchEdit.js.map +1 -1
- package/dist/esm/components/BatchEdit/BatchProperties.d.ts +7 -1
- package/dist/esm/components/BatchEdit/BatchProperties.d.ts.map +1 -1
- package/dist/esm/components/BatchEdit/BatchProperties.js +20 -4
- package/dist/esm/components/BatchEdit/BatchProperties.js.map +1 -1
- package/dist/esm/components/BatchEdit/Styles.d.ts +18 -0
- package/dist/esm/components/BatchEdit/Styles.d.ts.map +1 -1
- package/dist/esm/components/BatchEdit/Styles.js +66 -0
- package/dist/esm/components/BatchEdit/Styles.js.map +1 -1
- package/dist/esm/components/PillButton/PillButton.d.ts +1 -1
- package/dist/esm/components/PillButton/PillButton.d.ts.map +1 -1
- package/dist/esm/components/PillButton/PillButton.js.map +1 -1
- package/dist/esm/components/PillButton/Styles.d.ts.map +1 -1
- package/dist/esm/components/PillButton/Styles.js +1 -1
- package/dist/esm/components/PillButton/Styles.js.map +1 -1
- package/dist/esm/components/Popper/Popper.d.ts.map +1 -1
- package/dist/esm/components/Popper/Popper.js +18 -2
- package/dist/esm/components/Popper/Popper.js.map +1 -1
- package/dist/esm/presentation/__tests__/WhiteboardElbow.test.d.ts +2 -0
- package/dist/esm/presentation/__tests__/WhiteboardElbow.test.d.ts.map +1 -0
- package/dist/esm/presentation/__tests__/WhiteboardElbow.test.js +46 -0
- package/dist/esm/presentation/__tests__/WhiteboardElbow.test.js.map +1 -0
- package/dist/esm/presentation/whiteboard/elementToolbars.d.ts.map +1 -1
- package/dist/esm/presentation/whiteboard/elementToolbars.js +8 -8
- package/dist/esm/presentation/whiteboard/elementToolbars.js.map +1 -1
- package/dist/esm/presentation/whiteboard/lineElements.d.ts +7 -4
- package/dist/esm/presentation/whiteboard/lineElements.d.ts.map +1 -1
- package/dist/esm/presentation/whiteboard/lineElements.js +155 -190
- package/dist/esm/presentation/whiteboard/lineElements.js.map +1 -1
- package/dist/esm/presentation/whiteboard/lineInspector.d.ts.map +1 -1
- package/dist/esm/presentation/whiteboard/lineInspector.js +1 -1
- package/dist/esm/presentation/whiteboard/lineInspector.js.map +1 -1
- package/dist/esm/presentation/whiteboard/lineModel.d.ts +29 -11
- package/dist/esm/presentation/whiteboard/lineModel.d.ts.map +1 -1
- package/dist/esm/presentation/whiteboard/lineModel.js +290 -82
- package/dist/esm/presentation/whiteboard/lineModel.js.map +1 -1
- package/dist/index.js +485 -255
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,10 +3,12 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
import { SELECTION_BLUE, snapValue, withOpacity } from "./elements";
|
|
5
5
|
import { LineFormattingToolbar, LineLabelToolbar } from "./elementToolbars";
|
|
6
|
-
import { DEFAULT_LABEL, DEFAULT_LINE_STYLE, LINE_DEFAULT_LENGTH, LINE_HIT_WIDTH, MAX_WAYPOINTS,
|
|
6
|
+
import { DEFAULT_LABEL, DEFAULT_LINE_STYLE, LINE_DEFAULT_LENGTH, LINE_HIT_WIDTH, MAX_WAYPOINTS, addCurvedWaypoint, addElbowStep, constrainAngle, dashArray, dragElbowCorner, dragElbowSegment, elbowCorners, elbowSegmentAxes, lineEndGlyph, lineGeometry, pointAtFraction, projectOnSamples, removeElbowCorner, removeElbowSegment, resolveEndpoints, withLineType } from "./lineModel";
|
|
7
7
|
import { GUIDE_COLOR, resolveBoardColor } from "./palette";
|
|
8
8
|
import { EditableText } from "../../components/EditableText";
|
|
9
|
+
import { ToastMessage } from "../../components/ToastMessage";
|
|
9
10
|
import { Body2 } from "../../components/Typography";
|
|
11
|
+
import { ToastHost } from "../shared";
|
|
10
12
|
export const SEEDED_LINES = [{
|
|
11
13
|
id: "line-scope-arrow",
|
|
12
14
|
kind: "line",
|
|
@@ -20,10 +22,7 @@ export const SEEDED_LINES = [{
|
|
|
20
22
|
x: 256,
|
|
21
23
|
y: 232
|
|
22
24
|
},
|
|
23
|
-
waypoints:
|
|
24
|
-
curved: [],
|
|
25
|
-
elbow: []
|
|
26
|
-
},
|
|
25
|
+
waypoints: [],
|
|
27
26
|
style: _extends({}, DEFAULT_LINE_STYLE, {
|
|
28
27
|
arrow_end: "arrow"
|
|
29
28
|
}),
|
|
@@ -41,10 +40,7 @@ export const SEEDED_LINES = [{
|
|
|
41
40
|
x: 256,
|
|
42
41
|
y: 312
|
|
43
42
|
},
|
|
44
|
-
waypoints:
|
|
45
|
-
curved: [],
|
|
46
|
-
elbow: []
|
|
47
|
-
},
|
|
43
|
+
waypoints: [],
|
|
48
44
|
style: _extends({}, DEFAULT_LINE_STYLE, {
|
|
49
45
|
stroke: "purple",
|
|
50
46
|
stroke_pattern: "dashed"
|
|
@@ -63,13 +59,13 @@ export const SEEDED_LINES = [{
|
|
|
63
59
|
x: 304,
|
|
64
60
|
y: 608
|
|
65
61
|
},
|
|
66
|
-
waypoints: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
62
|
+
waypoints: [{
|
|
63
|
+
x: 200,
|
|
64
|
+
y: 400
|
|
65
|
+
}, {
|
|
66
|
+
x: 200,
|
|
67
|
+
y: 608
|
|
68
|
+
}],
|
|
73
69
|
style: _extends({}, DEFAULT_LINE_STYLE, {
|
|
74
70
|
stroke: "blueSky",
|
|
75
71
|
arrow_end: "arrow",
|
|
@@ -92,16 +88,13 @@ export const SEEDED_LINES = [{
|
|
|
92
88
|
x: 888,
|
|
93
89
|
y: 472
|
|
94
90
|
},
|
|
95
|
-
waypoints: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}],
|
|
103
|
-
elbow: []
|
|
104
|
-
},
|
|
91
|
+
waypoints: [{
|
|
92
|
+
x: 704,
|
|
93
|
+
y: 416
|
|
94
|
+
}, {
|
|
95
|
+
x: 800,
|
|
96
|
+
y: 544
|
|
97
|
+
}],
|
|
105
98
|
style: _extends({}, DEFAULT_LINE_STYLE, {
|
|
106
99
|
stroke: "coral",
|
|
107
100
|
arrow_start: "dot",
|
|
@@ -125,13 +118,10 @@ export const SEEDED_LINES = [{
|
|
|
125
118
|
end_element_id: "shape-rounded",
|
|
126
119
|
start_anchor: "right",
|
|
127
120
|
end_anchor: "left",
|
|
128
|
-
waypoints: {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}],
|
|
133
|
-
elbow: []
|
|
134
|
-
},
|
|
121
|
+
waypoints: [{
|
|
122
|
+
x: 488,
|
|
123
|
+
y: 232
|
|
124
|
+
}],
|
|
135
125
|
style: _extends({}, DEFAULT_LINE_STYLE, {
|
|
136
126
|
arrow_end: "arrow"
|
|
137
127
|
}),
|
|
@@ -145,14 +135,20 @@ const StyledLineLayer = styled.div.withConfig({
|
|
|
145
135
|
componentId: "sc-8q987b-0"
|
|
146
136
|
})(["position:absolute;inset:0;z-index:30;pointer-events:none;.wb-lines{position:absolute;left:0;top:0;width:100%;height:100%;overflow:visible;pointer-events:none;}.wb-line-hit{pointer-events:stroke;cursor:pointer;}.wb-line-halo{opacity:0;transition:opacity 120ms ease;}.wb-line:hover .wb-line-halo{opacity:0.3;}.wb-line.is-selected .wb-line-halo{opacity:0.2;}.wb-handle{pointer-events:all;cursor:grab;fill:var(--only-white);stroke:", ";stroke-width:1.5;}.wb-handle.is-active{fill:", ";}.wb-handle.is-anchored{cursor:default;fill:", ";}.wb-handle.is-ns{cursor:ns-resize;}.wb-handle.is-ew{cursor:ew-resize;}.wb-draw-surface{position:absolute;inset:0;pointer-events:auto;cursor:crosshair;}.wb-line-label{position:absolute;transform:translate(-50%,-50%);padding:2px 6px;border-radius:4px;box-sizing:border-box;white-space:nowrap;background-color:var(--page-paper-main);pointer-events:auto;cursor:move;}.wb-line-label.is-selected{box-shadow:0 0 0 1.5px ", ";}.wb-line-label textarea,.wb-line-label .presentation{font-size:inherit;font-weight:inherit;font-style:inherit;color:inherit;}.wb-toolbar-host{position:absolute;left:0;top:0;}.wb-toolbar-host > *{pointer-events:auto;}"], SELECTION_BLUE, SELECTION_BLUE, SELECTION_BLUE, SELECTION_BLUE);
|
|
147
137
|
const GUIDE_REACH = 6;
|
|
138
|
+
const LIMIT_MESSAGE = "Unable to add the point: a line can have up to " + MAX_WAYPOINTS + " points.";
|
|
148
139
|
const offset = (point, dx, dy) => ({
|
|
149
140
|
x: point.x + dx,
|
|
150
141
|
y: point.y + dy
|
|
151
142
|
});
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
143
|
+
const moveHandle = (frame, handle, base, point) => {
|
|
144
|
+
if (handle.kind === "corner") {
|
|
145
|
+
return dragElbowCorner(frame, base, handle.index, point);
|
|
146
|
+
}
|
|
147
|
+
if (handle.kind === "segment") {
|
|
148
|
+
return dragElbowSegment(frame, base, handle.index, point);
|
|
149
|
+
}
|
|
150
|
+
return base.map((waypoint, at) => at === handle.index ? point : waypoint);
|
|
151
|
+
};
|
|
156
152
|
export const LineLayer = _ref => {
|
|
157
153
|
var _lines$find;
|
|
158
154
|
let lines = _ref.lines,
|
|
@@ -172,20 +168,26 @@ export const LineLayer = _ref => {
|
|
|
172
168
|
const _useState = useState(initialWaypoint),
|
|
173
169
|
waypointSelection = _useState[0],
|
|
174
170
|
setWaypointSelection = _useState[1];
|
|
175
|
-
const _useState2 = useState(
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
const _useState2 = useState(false),
|
|
172
|
+
limitReached = _useState2[0],
|
|
173
|
+
setLimitReached = _useState2[1];
|
|
178
174
|
const _useState3 = useState(null),
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
labelFor = _useState3[0],
|
|
176
|
+
setLabelFor = _useState3[1];
|
|
181
177
|
const _useState4 = useState(null),
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
editingFor = _useState4[0],
|
|
179
|
+
setEditingFor = _useState4[1];
|
|
184
180
|
const _useState5 = useState(null),
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
draft = _useState5[0],
|
|
182
|
+
setDraft = _useState5[1];
|
|
183
|
+
const _useState6 = useState(null),
|
|
184
|
+
guides = _useState6[0],
|
|
185
|
+
setGuides = _useState6[1];
|
|
187
186
|
const selectedLine = (_lines$find = lines.find(line => line.id === selectedId)) != null ? _lines$find : null;
|
|
188
|
-
const selectedWaypoint = waypointSelection && waypointSelection.lineId === selectedId ?
|
|
187
|
+
const selectedWaypoint = waypointSelection && waypointSelection.lineId === selectedId ? {
|
|
188
|
+
kind: waypointSelection.kind,
|
|
189
|
+
index: waypointSelection.index
|
|
190
|
+
} : null;
|
|
189
191
|
const labelSelected = labelFor !== null && labelFor === selectedId;
|
|
190
192
|
const editing = editingFor !== null && editingFor === selectedId;
|
|
191
193
|
const canvasPoint = useCallback((clientX, clientY) => {
|
|
@@ -223,16 +225,16 @@ export const LineLayer = _ref => {
|
|
|
223
225
|
setLabelFor(line.id);
|
|
224
226
|
setEditingFor(line.id);
|
|
225
227
|
};
|
|
226
|
-
const snapWithGuides = (point, others) => {
|
|
228
|
+
const snapWithGuides = (point, others, only) => {
|
|
227
229
|
let x = snapValue(point.x, snapStep);
|
|
228
230
|
let y = snapValue(point.y, snapStep);
|
|
229
231
|
const found = {};
|
|
230
232
|
others.forEach(other => {
|
|
231
|
-
if (found.x === undefined && Math.abs(other.x - point.x) <= GUIDE_REACH) {
|
|
233
|
+
if (only !== "y" && found.x === undefined && Math.abs(other.x - point.x) <= GUIDE_REACH) {
|
|
232
234
|
x = other.x;
|
|
233
235
|
found.x = other.x;
|
|
234
236
|
}
|
|
235
|
-
if (found.y === undefined && Math.abs(other.y - point.y) <= GUIDE_REACH) {
|
|
237
|
+
if (only !== "x" && found.y === undefined && Math.abs(other.y - point.y) <= GUIDE_REACH) {
|
|
236
238
|
y = other.y;
|
|
237
239
|
found.y = other.y;
|
|
238
240
|
}
|
|
@@ -255,89 +257,54 @@ export const LineLayer = _ref => {
|
|
|
255
257
|
window.addEventListener("mousemove", handleMove);
|
|
256
258
|
window.addEventListener("mouseup", handleUp);
|
|
257
259
|
};
|
|
258
|
-
const
|
|
260
|
+
const handleBase = (line, start, end) => line.type === "elbow" ? elbowCorners(line, start, end) : line.type === "curved" ? line.waypoints : [];
|
|
261
|
+
const frameOf = line => {
|
|
259
262
|
const _resolveEndpoints = resolveEndpoints(line, boxOf),
|
|
260
263
|
start = _resolveEndpoints.start,
|
|
261
264
|
end = _resolveEndpoints.end;
|
|
262
|
-
return
|
|
265
|
+
return {
|
|
266
|
+
start,
|
|
267
|
+
end,
|
|
268
|
+
anchor: line.start_anchor
|
|
269
|
+
};
|
|
263
270
|
};
|
|
264
|
-
const
|
|
271
|
+
const pointsOf = line => {
|
|
265
272
|
const _resolveEndpoints2 = resolveEndpoints(line, boxOf),
|
|
266
273
|
start = _resolveEndpoints2.start,
|
|
267
274
|
end = _resolveEndpoints2.end;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}));
|
|
280
|
-
setWaypointSelection({
|
|
281
|
-
lineId: line.id,
|
|
282
|
-
index: projection.segment
|
|
283
|
-
});
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const bars = elbowBars(line, start, end);
|
|
287
|
-
if (bars.length + 2 > MAX_WAYPOINTS) {
|
|
275
|
+
return [start, end, ...handleBase(line, start, end)];
|
|
276
|
+
};
|
|
277
|
+
const guidePoints = (line, skip) => [...lines.filter(entry => entry.id !== line.id).flatMap(pointsOf), ...pointsOf(line).filter((_, at) => !skip.includes(at))];
|
|
278
|
+
const setWaypoints = (id, waypoints) => updateLine(id, current => _extends({}, current, {
|
|
279
|
+
waypoints
|
|
280
|
+
}));
|
|
281
|
+
const insertWaypoint = (line, point) => {
|
|
282
|
+
const frame = frameOf(line);
|
|
283
|
+
const added = line.type === "curved" ? addCurvedWaypoint(frame.start, frame.end, line.waypoints, point) : addElbowStep(frame, elbowCorners(line, frame.start, frame.end), point);
|
|
284
|
+
if (!added) {
|
|
285
|
+
setLimitReached(true);
|
|
288
286
|
return;
|
|
289
287
|
}
|
|
290
|
-
|
|
291
|
-
const at = Math.min(segment, bars.length);
|
|
292
|
-
const projection = projectOnSamples([geometry.route[segment], geometry.route[segment + 1]], [segment, segment], point).point;
|
|
293
|
-
const elbow = [...bars];
|
|
294
|
-
elbow.splice(at, 0, projection, projection);
|
|
295
|
-
updateLine(line.id, current => _extends({}, current, {
|
|
296
|
-
waypoints: _extends({}, current.waypoints, {
|
|
297
|
-
elbow
|
|
298
|
-
})
|
|
299
|
-
}));
|
|
288
|
+
setWaypoints(line.id, "corners" in added ? added.corners : added.waypoints);
|
|
300
289
|
setWaypointSelection({
|
|
301
290
|
lineId: line.id,
|
|
302
|
-
|
|
291
|
+
kind: line.type === "curved" ? "waypoint" : "corner",
|
|
292
|
+
index: added.selected
|
|
303
293
|
});
|
|
304
294
|
};
|
|
305
|
-
const removeWaypoint = (line,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
curved: current.waypoints.curved.filter((_, at) => at !== index)
|
|
310
|
-
})
|
|
311
|
-
}));
|
|
312
|
-
} else if (line.type === "elbow") {
|
|
313
|
-
const bars = line.waypoints.elbow;
|
|
314
|
-
const partner = index + 1 < bars.length ? index + 1 : index - 1;
|
|
315
|
-
updateLine(line.id, current => _extends({}, current, {
|
|
316
|
-
waypoints: _extends({}, current.waypoints, {
|
|
317
|
-
elbow: bars.filter((_, at) => at !== index && (bars.length < 2 || at !== partner))
|
|
318
|
-
})
|
|
319
|
-
}));
|
|
320
|
-
}
|
|
295
|
+
const removeWaypoint = (line, handle) => {
|
|
296
|
+
const frame = frameOf(line);
|
|
297
|
+
const base = handleBase(line, frame.start, frame.end);
|
|
298
|
+
setWaypoints(line.id, handle.kind === "corner" ? removeElbowCorner(frame, base, handle.index) : handle.kind === "segment" ? removeElbowSegment(frame, base, handle.index) : base.filter((_, at) => at !== handle.index));
|
|
321
299
|
setWaypointSelection(null);
|
|
322
300
|
};
|
|
323
|
-
const nudgeWaypoint = (line,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
})
|
|
329
|
-
}));
|
|
330
|
-
} else if (line.type === "elbow") {
|
|
331
|
-
const _resolveEndpoints3 = resolveEndpoints(line, boxOf),
|
|
332
|
-
start = _resolveEndpoints3.start,
|
|
333
|
-
end = _resolveEndpoints3.end;
|
|
334
|
-
const vertical = barIsVertical(index, elbowAxis(start, end, line.start_anchor));
|
|
335
|
-
updateLine(line.id, current => _extends({}, current, {
|
|
336
|
-
waypoints: _extends({}, current.waypoints, {
|
|
337
|
-
elbow: current.waypoints.elbow.map((point, at) => at === index ? offset(point, vertical ? dx : 0, vertical ? 0 : dy) : point)
|
|
338
|
-
})
|
|
339
|
-
}));
|
|
301
|
+
const nudgeWaypoint = (line, handle, dx, dy) => {
|
|
302
|
+
const frame = frameOf(line);
|
|
303
|
+
const base = handleBase(line, frame.start, frame.end);
|
|
304
|
+
if (!base[handle.index]) {
|
|
305
|
+
return;
|
|
340
306
|
}
|
|
307
|
+
setWaypoints(line.id, moveHandle(frame, handle, base, offset(base[handle.index], dx, dy)));
|
|
341
308
|
};
|
|
342
309
|
const deleteLine = id => {
|
|
343
310
|
setLines(current => current.filter(line => line.id !== id));
|
|
@@ -474,10 +441,7 @@ export const LineLayer = _ref => {
|
|
|
474
441
|
type: "line",
|
|
475
442
|
start: from,
|
|
476
443
|
end,
|
|
477
|
-
waypoints:
|
|
478
|
-
curved: [],
|
|
479
|
-
elbow: []
|
|
480
|
-
},
|
|
444
|
+
waypoints: [],
|
|
481
445
|
style: DEFAULT_LINE_STYLE,
|
|
482
446
|
label: null
|
|
483
447
|
}]);
|
|
@@ -490,9 +454,9 @@ export const LineLayer = _ref => {
|
|
|
490
454
|
};
|
|
491
455
|
const renderLine = line => {
|
|
492
456
|
var _locks$line$id2;
|
|
493
|
-
const
|
|
494
|
-
start =
|
|
495
|
-
end =
|
|
457
|
+
const _resolveEndpoints3 = resolveEndpoints(line, boxOf),
|
|
458
|
+
start = _resolveEndpoints3.start,
|
|
459
|
+
end = _resolveEndpoints3.end;
|
|
496
460
|
const geometry = lineGeometry(line, start, end);
|
|
497
461
|
const selected = line.id === selectedId;
|
|
498
462
|
const locked = (_locks$line$id2 = locks[line.id]) != null ? _locks$line$id2 : false;
|
|
@@ -517,10 +481,7 @@ export const LineLayer = _ref => {
|
|
|
517
481
|
updateLine(line.id, () => _extends({}, snapshot, {
|
|
518
482
|
start: offset(snapshot.start, dx, dy),
|
|
519
483
|
end: offset(snapshot.end, dx, dy),
|
|
520
|
-
waypoints:
|
|
521
|
-
curved: snapshot.waypoints.curved.map(p => offset(p, dx, dy)),
|
|
522
|
-
elbow: snapshot.waypoints.elbow.map(p => offset(p, dx, dy))
|
|
523
|
-
}
|
|
484
|
+
waypoints: snapshot.waypoints.map(p => offset(p, dx, dy))
|
|
524
485
|
}));
|
|
525
486
|
});
|
|
526
487
|
};
|
|
@@ -534,7 +495,7 @@ export const LineLayer = _ref => {
|
|
|
534
495
|
var _line$label$position2, _line$label2;
|
|
535
496
|
startLabelEdit(line, (_line$label$position2 = (_line$label2 = line.label) == null ? void 0 : _line$label2.position) != null ? _line$label$position2 : projectOnSamples(geometry.samples, geometry.sampleSegments, point).fraction);
|
|
536
497
|
} else {
|
|
537
|
-
insertWaypoint(line,
|
|
498
|
+
insertWaypoint(line, point);
|
|
538
499
|
}
|
|
539
500
|
};
|
|
540
501
|
return /*#__PURE__*/React.createElement("g", {
|
|
@@ -573,13 +534,19 @@ export const LineLayer = _ref => {
|
|
|
573
534
|
};
|
|
574
535
|
const renderHandles = line => {
|
|
575
536
|
var _locks$line$id3;
|
|
576
|
-
const
|
|
577
|
-
start =
|
|
578
|
-
end =
|
|
579
|
-
const
|
|
537
|
+
const _resolveEndpoints4 = resolveEndpoints(line, boxOf),
|
|
538
|
+
start = _resolveEndpoints4.start,
|
|
539
|
+
end = _resolveEndpoints4.end;
|
|
540
|
+
const frame = {
|
|
541
|
+
start,
|
|
542
|
+
end,
|
|
543
|
+
anchor: line.start_anchor
|
|
544
|
+
};
|
|
545
|
+
const base = handleBase(line, start, end);
|
|
546
|
+
const axes = line.type === "elbow" ? elbowSegmentAxes(frame, base) : [];
|
|
580
547
|
const locked = (_locks$line$id3 = locks[line.id]) != null ? _locks$line$id3 : false;
|
|
581
548
|
const anchored = line.kind === "connector";
|
|
582
|
-
const
|
|
549
|
+
const isActive = handle => (selectedWaypoint == null ? void 0 : selectedWaypoint.kind) === handle.kind && selectedWaypoint.index === handle.index;
|
|
583
550
|
const dragEnd = side => event => {
|
|
584
551
|
setWaypointSelection(null);
|
|
585
552
|
if (anchored || locked) {
|
|
@@ -587,73 +554,62 @@ export const LineLayer = _ref => {
|
|
|
587
554
|
return;
|
|
588
555
|
}
|
|
589
556
|
const fixed = side === "start" ? line.end : line.start;
|
|
590
|
-
const
|
|
557
|
+
const others = guidePoints(line, [side === "start" ? 0 : 1]);
|
|
591
558
|
beginDrag(event, (point, move) => {
|
|
592
|
-
const next = move.shiftKey ? constrainAngle(fixed, point) : snapWithGuides(point, others
|
|
559
|
+
const next = move.shiftKey ? constrainAngle(fixed, point) : snapWithGuides(point, others);
|
|
593
560
|
updateLine(line.id, current => _extends({}, current, {
|
|
594
561
|
[side]: next
|
|
595
562
|
}));
|
|
596
563
|
});
|
|
597
564
|
};
|
|
598
|
-
const
|
|
599
|
-
setWaypointSelection({
|
|
600
|
-
lineId: line.id
|
|
601
|
-
|
|
602
|
-
});
|
|
565
|
+
const dragHandle = handle => event => {
|
|
566
|
+
setWaypointSelection(_extends({
|
|
567
|
+
lineId: line.id
|
|
568
|
+
}, handle));
|
|
603
569
|
setLabelFor(null);
|
|
604
570
|
if (locked) {
|
|
605
571
|
event.stopPropagation();
|
|
606
572
|
return;
|
|
607
573
|
}
|
|
608
|
-
const
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
updateLine(line.id, current => {
|
|
613
|
-
if (current.type === "elbow") {
|
|
614
|
-
return _extends({}, current, {
|
|
615
|
-
waypoints: _extends({}, current.waypoints, {
|
|
616
|
-
elbow: current.waypoints.elbow.map((bar, at) => at === index ? vertical ? _extends({}, bar, {
|
|
617
|
-
x: snapped.x
|
|
618
|
-
}) : _extends({}, bar, {
|
|
619
|
-
y: snapped.y
|
|
620
|
-
}) : bar)
|
|
621
|
-
})
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
return _extends({}, current, {
|
|
625
|
-
waypoints: _extends({}, current.waypoints, {
|
|
626
|
-
curved: current.waypoints.curved.map((waypoint, at) => at === index ? snapped : waypoint)
|
|
627
|
-
})
|
|
628
|
-
});
|
|
629
|
-
});
|
|
630
|
-
});
|
|
574
|
+
const moving = handle.kind === "corner" ? [handle.index - 1, handle.index, handle.index + 1] : handle.kind === "segment" ? [handle.index, handle.index + 1] : [handle.index];
|
|
575
|
+
const others = guidePoints(line, moving.map(at => at + 2));
|
|
576
|
+
const only = handle.kind === "segment" ? axes[handle.index + 1] === "v" ? "x" : "y" : undefined;
|
|
577
|
+
beginDrag(event, point => setWaypoints(line.id, moveHandle(frame, handle, base, snapWithGuides(point, others, only))));
|
|
631
578
|
};
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
})) : null, bars.map((_, index) => {
|
|
644
|
-
const from = route[index + 1];
|
|
645
|
-
const to = route[index + 2];
|
|
646
|
-
const vertical = barIsVertical(index, axis);
|
|
647
|
-
const active = selectedWaypoint === index;
|
|
579
|
+
const handleClass = (handle, extra) => ["wb-handle", extra, isActive(handle) ? "is-active" : ""].filter(Boolean).join(" ");
|
|
580
|
+
return /*#__PURE__*/React.createElement("g", null, line.type === "elbow" ? base.slice(0, -1).map((from, index) => {
|
|
581
|
+
const to = base[index + 1];
|
|
582
|
+
if (from.x === to.x && from.y === to.y) {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
const vertical = axes[index + 1] === "v";
|
|
586
|
+
const handle = {
|
|
587
|
+
kind: "segment",
|
|
588
|
+
index
|
|
589
|
+
};
|
|
648
590
|
return /*#__PURE__*/React.createElement("rect", {
|
|
649
591
|
key: "segment-" + index,
|
|
650
|
-
className:
|
|
592
|
+
className: handleClass(handle, vertical ? "is-ew" : "is-ns"),
|
|
651
593
|
x: (from.x + to.x) / 2 - (vertical ? 3 : 8),
|
|
652
594
|
y: (from.y + to.y) / 2 - (vertical ? 8 : 3),
|
|
653
595
|
width: vertical ? 6 : 16,
|
|
654
596
|
height: vertical ? 16 : 6,
|
|
655
597
|
rx: 3,
|
|
656
|
-
onMouseDown:
|
|
598
|
+
onMouseDown: dragHandle(handle),
|
|
599
|
+
onClick: event => event.stopPropagation()
|
|
600
|
+
});
|
|
601
|
+
}) : null, base.map((point, index) => {
|
|
602
|
+
const handle = {
|
|
603
|
+
kind: line.type === "elbow" ? "corner" : "waypoint",
|
|
604
|
+
index
|
|
605
|
+
};
|
|
606
|
+
return /*#__PURE__*/React.createElement("circle", {
|
|
607
|
+
key: handle.kind + "-" + index,
|
|
608
|
+
className: handleClass(handle),
|
|
609
|
+
cx: point.x,
|
|
610
|
+
cy: point.y,
|
|
611
|
+
r: 4,
|
|
612
|
+
onMouseDown: dragHandle(handle),
|
|
657
613
|
onClick: event => event.stopPropagation()
|
|
658
614
|
});
|
|
659
615
|
}), [{
|
|
@@ -680,9 +636,9 @@ export const LineLayer = _ref => {
|
|
|
680
636
|
if (!line.label) {
|
|
681
637
|
return null;
|
|
682
638
|
}
|
|
683
|
-
const
|
|
684
|
-
start =
|
|
685
|
-
end =
|
|
639
|
+
const _resolveEndpoints5 = resolveEndpoints(line, boxOf),
|
|
640
|
+
start = _resolveEndpoints5.start,
|
|
641
|
+
end = _resolveEndpoints5.end;
|
|
686
642
|
const geometry = lineGeometry(line, start, end);
|
|
687
643
|
const at = pointAtFraction(geometry.samples, line.label.position);
|
|
688
644
|
const selected = labelSelected && line.id === selectedId;
|
|
@@ -768,9 +724,9 @@ export const LineLayer = _ref => {
|
|
|
768
724
|
if (!selectedLine || draft) {
|
|
769
725
|
return null;
|
|
770
726
|
}
|
|
771
|
-
const
|
|
772
|
-
start =
|
|
773
|
-
end =
|
|
727
|
+
const _resolveEndpoints6 = resolveEndpoints(selectedLine, boxOf),
|
|
728
|
+
start = _resolveEndpoints6.start,
|
|
729
|
+
end = _resolveEndpoints6.end;
|
|
774
730
|
const geometry = lineGeometry(selectedLine, start, end);
|
|
775
731
|
const xs = geometry.samples.map(point => point.x);
|
|
776
732
|
const ys = geometry.samples.map(point => point.y);
|
|
@@ -799,7 +755,10 @@ export const LineLayer = _ref => {
|
|
|
799
755
|
},
|
|
800
756
|
onTypeChange: type => {
|
|
801
757
|
setWaypointSelection(null);
|
|
802
|
-
updateLine(selectedLine.id, current => withLineType(current, type, start, end
|
|
758
|
+
updateLine(selectedLine.id, current => withLineType(current, type, start, end, point => ({
|
|
759
|
+
x: snapValue(point.x, snapStep),
|
|
760
|
+
y: snapValue(point.y, snapStep)
|
|
761
|
+
})));
|
|
803
762
|
},
|
|
804
763
|
onStyleChange: partial => updateLine(selectedLine.id, current => _extends({}, current, {
|
|
805
764
|
style: _extends({}, current.style, partial)
|
|
@@ -846,6 +805,12 @@ export const LineLayer = _ref => {
|
|
|
846
805
|
}
|
|
847
806
|
}) : null), ordered.map(renderLabel), /*#__PURE__*/React.createElement("div", {
|
|
848
807
|
className: "wb-toolbar-host"
|
|
849
|
-
}, renderToolbar())
|
|
808
|
+
}, renderToolbar()), limitReached ? /*#__PURE__*/React.createElement(ToastHost, null, /*#__PURE__*/React.createElement(ToastMessage, {
|
|
809
|
+
type: "error",
|
|
810
|
+
text: LIMIT_MESSAGE,
|
|
811
|
+
dismissible: true,
|
|
812
|
+
timeout: 3500,
|
|
813
|
+
onClose: () => setLimitReached(false)
|
|
814
|
+
})) : null);
|
|
850
815
|
};
|
|
851
816
|
//# sourceMappingURL=lineElements.js.map
|