@activecollab/components 2.0.591 → 2.0.592
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/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/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/package.json +1 -1
|
@@ -11,7 +11,9 @@ var _elementToolbars = require("./elementToolbars");
|
|
|
11
11
|
var _lineModel = require("./lineModel");
|
|
12
12
|
var _palette = require("./palette");
|
|
13
13
|
var _EditableText = require("../../components/EditableText");
|
|
14
|
+
var _ToastMessage = require("../../components/ToastMessage");
|
|
14
15
|
var _Typography = require("../../components/Typography");
|
|
16
|
+
var _shared = require("../shared");
|
|
15
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
17
19
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
@@ -38,10 +40,7 @@ var SEEDED_LINES = exports.SEEDED_LINES = [{
|
|
|
38
40
|
x: 256,
|
|
39
41
|
y: 232
|
|
40
42
|
},
|
|
41
|
-
waypoints:
|
|
42
|
-
curved: [],
|
|
43
|
-
elbow: []
|
|
44
|
-
},
|
|
43
|
+
waypoints: [],
|
|
45
44
|
style: _objectSpread(_objectSpread({}, _lineModel.DEFAULT_LINE_STYLE), {}, {
|
|
46
45
|
arrow_end: "arrow"
|
|
47
46
|
}),
|
|
@@ -59,10 +58,7 @@ var SEEDED_LINES = exports.SEEDED_LINES = [{
|
|
|
59
58
|
x: 256,
|
|
60
59
|
y: 312
|
|
61
60
|
},
|
|
62
|
-
waypoints:
|
|
63
|
-
curved: [],
|
|
64
|
-
elbow: []
|
|
65
|
-
},
|
|
61
|
+
waypoints: [],
|
|
66
62
|
style: _objectSpread(_objectSpread({}, _lineModel.DEFAULT_LINE_STYLE), {}, {
|
|
67
63
|
stroke: "purple",
|
|
68
64
|
stroke_pattern: "dashed"
|
|
@@ -81,13 +77,13 @@ var SEEDED_LINES = exports.SEEDED_LINES = [{
|
|
|
81
77
|
x: 304,
|
|
82
78
|
y: 608
|
|
83
79
|
},
|
|
84
|
-
waypoints: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
},
|
|
80
|
+
waypoints: [{
|
|
81
|
+
x: 200,
|
|
82
|
+
y: 400
|
|
83
|
+
}, {
|
|
84
|
+
x: 200,
|
|
85
|
+
y: 608
|
|
86
|
+
}],
|
|
91
87
|
style: _objectSpread(_objectSpread({}, _lineModel.DEFAULT_LINE_STYLE), {}, {
|
|
92
88
|
stroke: "blueSky",
|
|
93
89
|
arrow_end: "arrow",
|
|
@@ -110,16 +106,13 @@ var SEEDED_LINES = exports.SEEDED_LINES = [{
|
|
|
110
106
|
x: 888,
|
|
111
107
|
y: 472
|
|
112
108
|
},
|
|
113
|
-
waypoints: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}],
|
|
121
|
-
elbow: []
|
|
122
|
-
},
|
|
109
|
+
waypoints: [{
|
|
110
|
+
x: 704,
|
|
111
|
+
y: 416
|
|
112
|
+
}, {
|
|
113
|
+
x: 800,
|
|
114
|
+
y: 544
|
|
115
|
+
}],
|
|
123
116
|
style: _objectSpread(_objectSpread({}, _lineModel.DEFAULT_LINE_STYLE), {}, {
|
|
124
117
|
stroke: "coral",
|
|
125
118
|
arrow_start: "dot",
|
|
@@ -143,13 +136,10 @@ var SEEDED_LINES = exports.SEEDED_LINES = [{
|
|
|
143
136
|
end_element_id: "shape-rounded",
|
|
144
137
|
start_anchor: "right",
|
|
145
138
|
end_anchor: "left",
|
|
146
|
-
waypoints: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}],
|
|
151
|
-
elbow: []
|
|
152
|
-
},
|
|
139
|
+
waypoints: [{
|
|
140
|
+
x: 488,
|
|
141
|
+
y: 232
|
|
142
|
+
}],
|
|
153
143
|
style: _objectSpread(_objectSpread({}, _lineModel.DEFAULT_LINE_STYLE), {}, {
|
|
154
144
|
arrow_end: "arrow"
|
|
155
145
|
}),
|
|
@@ -163,17 +153,23 @@ var StyledLineLayer = _styledComponents.default.div.withConfig({
|
|
|
163
153
|
componentId: "sc-8q987b-0"
|
|
164
154
|
})(["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;}"], _elements.SELECTION_BLUE, _elements.SELECTION_BLUE, _elements.SELECTION_BLUE, _elements.SELECTION_BLUE);
|
|
165
155
|
var GUIDE_REACH = 6;
|
|
156
|
+
var LIMIT_MESSAGE = "Unable to add the point: a line can have up to ".concat(_lineModel.MAX_WAYPOINTS, " points.");
|
|
166
157
|
var offset = function offset(point, dx, dy) {
|
|
167
158
|
return {
|
|
168
159
|
x: point.x + dx,
|
|
169
160
|
y: point.y + dy
|
|
170
161
|
};
|
|
171
162
|
};
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
163
|
+
var moveHandle = function moveHandle(frame, handle, base, point) {
|
|
164
|
+
if (handle.kind === "corner") {
|
|
165
|
+
return (0, _lineModel.dragElbowCorner)(frame, base, handle.index, point);
|
|
166
|
+
}
|
|
167
|
+
if (handle.kind === "segment") {
|
|
168
|
+
return (0, _lineModel.dragElbowSegment)(frame, base, handle.index, point);
|
|
169
|
+
}
|
|
170
|
+
return base.map(function (waypoint, at) {
|
|
171
|
+
return at === handle.index ? point : waypoint;
|
|
172
|
+
});
|
|
177
173
|
};
|
|
178
174
|
var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
179
175
|
var _lines$find;
|
|
@@ -195,26 +191,33 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
195
191
|
_useState2 = _slicedToArray(_useState, 2),
|
|
196
192
|
waypointSelection = _useState2[0],
|
|
197
193
|
setWaypointSelection = _useState2[1];
|
|
198
|
-
var _useState3 = (0, _react.useState)(
|
|
194
|
+
var _useState3 = (0, _react.useState)(false),
|
|
199
195
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
limitReached = _useState4[0],
|
|
197
|
+
setLimitReached = _useState4[1];
|
|
202
198
|
var _useState5 = (0, _react.useState)(null),
|
|
203
199
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
labelFor = _useState6[0],
|
|
201
|
+
setLabelFor = _useState6[1];
|
|
206
202
|
var _useState7 = (0, _react.useState)(null),
|
|
207
203
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
editingFor = _useState8[0],
|
|
205
|
+
setEditingFor = _useState8[1];
|
|
210
206
|
var _useState9 = (0, _react.useState)(null),
|
|
211
207
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
draft = _useState0[0],
|
|
209
|
+
setDraft = _useState0[1];
|
|
210
|
+
var _useState1 = (0, _react.useState)(null),
|
|
211
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
212
|
+
guides = _useState10[0],
|
|
213
|
+
setGuides = _useState10[1];
|
|
214
214
|
var selectedLine = (_lines$find = lines.find(function (line) {
|
|
215
215
|
return line.id === selectedId;
|
|
216
216
|
})) !== null && _lines$find !== void 0 ? _lines$find : null;
|
|
217
|
-
var selectedWaypoint = waypointSelection && waypointSelection.lineId === selectedId ?
|
|
217
|
+
var selectedWaypoint = waypointSelection && waypointSelection.lineId === selectedId ? {
|
|
218
|
+
kind: waypointSelection.kind,
|
|
219
|
+
index: waypointSelection.index
|
|
220
|
+
} : null;
|
|
218
221
|
var labelSelected = labelFor !== null && labelFor === selectedId;
|
|
219
222
|
var editing = editingFor !== null && editingFor === selectedId;
|
|
220
223
|
var canvasPoint = (0, _react.useCallback)(function (clientX, clientY) {
|
|
@@ -264,16 +267,16 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
264
267
|
setLabelFor(line.id);
|
|
265
268
|
setEditingFor(line.id);
|
|
266
269
|
};
|
|
267
|
-
var snapWithGuides = function snapWithGuides(point, others) {
|
|
270
|
+
var snapWithGuides = function snapWithGuides(point, others, only) {
|
|
268
271
|
var x = (0, _elements.snapValue)(point.x, snapStep);
|
|
269
272
|
var y = (0, _elements.snapValue)(point.y, snapStep);
|
|
270
273
|
var found = {};
|
|
271
274
|
others.forEach(function (other) {
|
|
272
|
-
if (found.x === undefined && Math.abs(other.x - point.x) <= GUIDE_REACH) {
|
|
275
|
+
if (only !== "y" && found.x === undefined && Math.abs(other.x - point.x) <= GUIDE_REACH) {
|
|
273
276
|
x = other.x;
|
|
274
277
|
found.x = other.x;
|
|
275
278
|
}
|
|
276
|
-
if (found.y === undefined && Math.abs(other.y - point.y) <= GUIDE_REACH) {
|
|
279
|
+
if (only !== "x" && found.y === undefined && Math.abs(other.y - point.y) <= GUIDE_REACH) {
|
|
277
280
|
y = other.y;
|
|
278
281
|
found.y = other.y;
|
|
279
282
|
}
|
|
@@ -298,109 +301,68 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
298
301
|
window.addEventListener("mousemove", handleMove);
|
|
299
302
|
window.addEventListener("mouseup", _handleUp);
|
|
300
303
|
};
|
|
301
|
-
var
|
|
304
|
+
var handleBase = function handleBase(line, start, end) {
|
|
305
|
+
return line.type === "elbow" ? (0, _lineModel.elbowCorners)(line, start, end) : line.type === "curved" ? line.waypoints : [];
|
|
306
|
+
};
|
|
307
|
+
var frameOf = function frameOf(line) {
|
|
302
308
|
var _resolveEndpoints = (0, _lineModel.resolveEndpoints)(line, boxOf),
|
|
303
309
|
start = _resolveEndpoints.start,
|
|
304
310
|
end = _resolveEndpoints.end;
|
|
305
|
-
return
|
|
311
|
+
return {
|
|
312
|
+
start,
|
|
313
|
+
end,
|
|
314
|
+
anchor: line.start_anchor
|
|
315
|
+
};
|
|
306
316
|
};
|
|
307
|
-
var
|
|
317
|
+
var pointsOf = function pointsOf(line) {
|
|
308
318
|
var _resolveEndpoints2 = (0, _lineModel.resolveEndpoints)(line, boxOf),
|
|
309
319
|
start = _resolveEndpoints2.start,
|
|
310
320
|
end = _resolveEndpoints2.end;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
})
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
setWaypointSelection({
|
|
326
|
-
lineId: line.id,
|
|
327
|
-
index: _projection.segment
|
|
328
|
-
});
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
var bars = elbowBars(line, start, end);
|
|
332
|
-
if (bars.length + 2 > _lineModel.MAX_WAYPOINTS) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
var segment = (0, _lineModel.elbowSegmentIndex)(geometry.route, point);
|
|
336
|
-
var at = Math.min(segment, bars.length);
|
|
337
|
-
var projection = (0, _lineModel.projectOnSamples)([geometry.route[segment], geometry.route[segment + 1]], [segment, segment], point).point;
|
|
338
|
-
var elbow = [...bars];
|
|
339
|
-
elbow.splice(at, 0, projection, projection);
|
|
340
|
-
updateLine(line.id, function (current) {
|
|
321
|
+
return [start, end, ...handleBase(line, start, end)];
|
|
322
|
+
};
|
|
323
|
+
var guidePoints = function guidePoints(line, skip) {
|
|
324
|
+
return [...lines.filter(function (entry) {
|
|
325
|
+
return entry.id !== line.id;
|
|
326
|
+
}).flatMap(pointsOf), ...pointsOf(line).filter(function (_, at) {
|
|
327
|
+
return !skip.includes(at);
|
|
328
|
+
})];
|
|
329
|
+
};
|
|
330
|
+
var setWaypoints = function setWaypoints(id, waypoints) {
|
|
331
|
+
return updateLine(id, function (current) {
|
|
341
332
|
return _objectSpread(_objectSpread({}, current), {}, {
|
|
342
|
-
waypoints
|
|
343
|
-
elbow
|
|
344
|
-
})
|
|
333
|
+
waypoints
|
|
345
334
|
});
|
|
346
335
|
});
|
|
336
|
+
};
|
|
337
|
+
var insertWaypoint = function insertWaypoint(line, point) {
|
|
338
|
+
var frame = frameOf(line);
|
|
339
|
+
var added = line.type === "curved" ? (0, _lineModel.addCurvedWaypoint)(frame.start, frame.end, line.waypoints, point) : (0, _lineModel.addElbowStep)(frame, (0, _lineModel.elbowCorners)(line, frame.start, frame.end), point);
|
|
340
|
+
if (!added) {
|
|
341
|
+
setLimitReached(true);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
setWaypoints(line.id, "corners" in added ? added.corners : added.waypoints);
|
|
347
345
|
setWaypointSelection({
|
|
348
346
|
lineId: line.id,
|
|
349
|
-
|
|
347
|
+
kind: line.type === "curved" ? "waypoint" : "corner",
|
|
348
|
+
index: added.selected
|
|
350
349
|
});
|
|
351
350
|
};
|
|
352
|
-
var removeWaypoint = function removeWaypoint(line,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return at !== index;
|
|
359
|
-
})
|
|
360
|
-
})
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
} else if (line.type === "elbow") {
|
|
364
|
-
var bars = line.waypoints.elbow;
|
|
365
|
-
var partner = index + 1 < bars.length ? index + 1 : index - 1;
|
|
366
|
-
updateLine(line.id, function (current) {
|
|
367
|
-
return _objectSpread(_objectSpread({}, current), {}, {
|
|
368
|
-
waypoints: _objectSpread(_objectSpread({}, current.waypoints), {}, {
|
|
369
|
-
elbow: bars.filter(function (_, at) {
|
|
370
|
-
return at !== index && (bars.length < 2 || at !== partner);
|
|
371
|
-
})
|
|
372
|
-
})
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
}
|
|
351
|
+
var removeWaypoint = function removeWaypoint(line, handle) {
|
|
352
|
+
var frame = frameOf(line);
|
|
353
|
+
var base = handleBase(line, frame.start, frame.end);
|
|
354
|
+
setWaypoints(line.id, handle.kind === "corner" ? (0, _lineModel.removeElbowCorner)(frame, base, handle.index) : handle.kind === "segment" ? (0, _lineModel.removeElbowSegment)(frame, base, handle.index) : base.filter(function (_, at) {
|
|
355
|
+
return at !== handle.index;
|
|
356
|
+
}));
|
|
376
357
|
setWaypointSelection(null);
|
|
377
358
|
};
|
|
378
|
-
var nudgeWaypoint = function nudgeWaypoint(line,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
curved: current.waypoints.curved.map(function (point, at) {
|
|
384
|
-
return at === index ? offset(point, dx, dy) : point;
|
|
385
|
-
})
|
|
386
|
-
})
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
} else if (line.type === "elbow") {
|
|
390
|
-
var _resolveEndpoints3 = (0, _lineModel.resolveEndpoints)(line, boxOf),
|
|
391
|
-
start = _resolveEndpoints3.start,
|
|
392
|
-
end = _resolveEndpoints3.end;
|
|
393
|
-
var vertical = (0, _lineModel.barIsVertical)(index, (0, _lineModel.elbowAxis)(start, end, line.start_anchor));
|
|
394
|
-
updateLine(line.id, function (current) {
|
|
395
|
-
return _objectSpread(_objectSpread({}, current), {}, {
|
|
396
|
-
waypoints: _objectSpread(_objectSpread({}, current.waypoints), {}, {
|
|
397
|
-
elbow: current.waypoints.elbow.map(function (point, at) {
|
|
398
|
-
return at === index ? offset(point, vertical ? dx : 0, vertical ? 0 : dy) : point;
|
|
399
|
-
})
|
|
400
|
-
})
|
|
401
|
-
});
|
|
402
|
-
});
|
|
359
|
+
var nudgeWaypoint = function nudgeWaypoint(line, handle, dx, dy) {
|
|
360
|
+
var frame = frameOf(line);
|
|
361
|
+
var base = handleBase(line, frame.start, frame.end);
|
|
362
|
+
if (!base[handle.index]) {
|
|
363
|
+
return;
|
|
403
364
|
}
|
|
365
|
+
setWaypoints(line.id, moveHandle(frame, handle, base, offset(base[handle.index], dx, dy)));
|
|
404
366
|
};
|
|
405
367
|
var deleteLine = function deleteLine(id) {
|
|
406
368
|
setLines(function (current) {
|
|
@@ -544,10 +506,7 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
544
506
|
type: "line",
|
|
545
507
|
start: from,
|
|
546
508
|
end,
|
|
547
|
-
waypoints:
|
|
548
|
-
curved: [],
|
|
549
|
-
elbow: []
|
|
550
|
-
},
|
|
509
|
+
waypoints: [],
|
|
551
510
|
style: _lineModel.DEFAULT_LINE_STYLE,
|
|
552
511
|
label: null
|
|
553
512
|
}];
|
|
@@ -561,9 +520,9 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
561
520
|
};
|
|
562
521
|
var renderLine = function renderLine(line) {
|
|
563
522
|
var _locks$line$id2;
|
|
564
|
-
var
|
|
565
|
-
start =
|
|
566
|
-
end =
|
|
523
|
+
var _resolveEndpoints3 = (0, _lineModel.resolveEndpoints)(line, boxOf),
|
|
524
|
+
start = _resolveEndpoints3.start,
|
|
525
|
+
end = _resolveEndpoints3.end;
|
|
567
526
|
var geometry = (0, _lineModel.lineGeometry)(line, start, end);
|
|
568
527
|
var selected = line.id === selectedId;
|
|
569
528
|
var locked = (_locks$line$id2 = locks[line.id]) !== null && _locks$line$id2 !== void 0 ? _locks$line$id2 : false;
|
|
@@ -589,14 +548,9 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
589
548
|
return _objectSpread(_objectSpread({}, snapshot), {}, {
|
|
590
549
|
start: offset(snapshot.start, dx, dy),
|
|
591
550
|
end: offset(snapshot.end, dx, dy),
|
|
592
|
-
waypoints: {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}),
|
|
596
|
-
elbow: snapshot.waypoints.elbow.map(function (p) {
|
|
597
|
-
return offset(p, dx, dy);
|
|
598
|
-
})
|
|
599
|
-
}
|
|
551
|
+
waypoints: snapshot.waypoints.map(function (p) {
|
|
552
|
+
return offset(p, dx, dy);
|
|
553
|
+
})
|
|
600
554
|
});
|
|
601
555
|
});
|
|
602
556
|
});
|
|
@@ -611,7 +565,7 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
611
565
|
var _line$label$position2, _line$label2;
|
|
612
566
|
startLabelEdit(line, (_line$label$position2 = (_line$label2 = line.label) === null || _line$label2 === void 0 ? void 0 : _line$label2.position) !== null && _line$label$position2 !== void 0 ? _line$label$position2 : (0, _lineModel.projectOnSamples)(geometry.samples, geometry.sampleSegments, point).fraction);
|
|
613
567
|
} else {
|
|
614
|
-
insertWaypoint(line,
|
|
568
|
+
insertWaypoint(line, point);
|
|
615
569
|
}
|
|
616
570
|
};
|
|
617
571
|
return /*#__PURE__*/_react.default.createElement("g", {
|
|
@@ -652,18 +606,20 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
652
606
|
};
|
|
653
607
|
var renderHandles = function renderHandles(line) {
|
|
654
608
|
var _locks$line$id3;
|
|
655
|
-
var
|
|
656
|
-
start =
|
|
657
|
-
end =
|
|
658
|
-
var
|
|
609
|
+
var _resolveEndpoints4 = (0, _lineModel.resolveEndpoints)(line, boxOf),
|
|
610
|
+
start = _resolveEndpoints4.start,
|
|
611
|
+
end = _resolveEndpoints4.end;
|
|
612
|
+
var frame = {
|
|
613
|
+
start,
|
|
614
|
+
end,
|
|
615
|
+
anchor: line.start_anchor
|
|
616
|
+
};
|
|
617
|
+
var base = handleBase(line, start, end);
|
|
618
|
+
var axes = line.type === "elbow" ? (0, _lineModel.elbowSegmentAxes)(frame, base) : [];
|
|
659
619
|
var locked = (_locks$line$id3 = locks[line.id]) !== null && _locks$line$id3 !== void 0 ? _locks$line$id3 : false;
|
|
660
620
|
var anchored = line.kind === "connector";
|
|
661
|
-
var
|
|
662
|
-
return
|
|
663
|
-
return pointsOf(entry);
|
|
664
|
-
}).filter(function (point) {
|
|
665
|
-
return point !== except;
|
|
666
|
-
});
|
|
621
|
+
var isActive = function isActive(handle) {
|
|
622
|
+
return (selectedWaypoint === null || selectedWaypoint === void 0 ? void 0 : selectedWaypoint.kind) === handle.kind && selectedWaypoint.index === handle.index;
|
|
667
623
|
};
|
|
668
624
|
var dragEnd = function dragEnd(side) {
|
|
669
625
|
return function (event) {
|
|
@@ -673,9 +629,9 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
673
629
|
return;
|
|
674
630
|
}
|
|
675
631
|
var fixed = side === "start" ? line.end : line.start;
|
|
676
|
-
var
|
|
632
|
+
var others = guidePoints(line, [side === "start" ? 0 : 1]);
|
|
677
633
|
beginDrag(event, function (point, move) {
|
|
678
|
-
var next = move.shiftKey ? (0, _lineModel.constrainAngle)(fixed, point) : snapWithGuides(point, others
|
|
634
|
+
var next = move.shiftKey ? (0, _lineModel.constrainAngle)(fixed, point) : snapWithGuides(point, others);
|
|
679
635
|
updateLine(line.id, function (current) {
|
|
680
636
|
return _objectSpread(_objectSpread({}, current), {}, {
|
|
681
637
|
[side]: next
|
|
@@ -684,75 +640,64 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
684
640
|
});
|
|
685
641
|
};
|
|
686
642
|
};
|
|
687
|
-
var
|
|
643
|
+
var dragHandle = function dragHandle(handle) {
|
|
688
644
|
return function (event) {
|
|
689
|
-
setWaypointSelection({
|
|
690
|
-
lineId: line.id
|
|
691
|
-
|
|
692
|
-
});
|
|
645
|
+
setWaypointSelection(_objectSpread({
|
|
646
|
+
lineId: line.id
|
|
647
|
+
}, handle));
|
|
693
648
|
setLabelFor(null);
|
|
694
649
|
if (locked) {
|
|
695
650
|
event.stopPropagation();
|
|
696
651
|
return;
|
|
697
652
|
}
|
|
698
|
-
var
|
|
699
|
-
var
|
|
653
|
+
var moving = handle.kind === "corner" ? [handle.index - 1, handle.index, handle.index + 1] : handle.kind === "segment" ? [handle.index, handle.index + 1] : [handle.index];
|
|
654
|
+
var others = guidePoints(line, moving.map(function (at) {
|
|
655
|
+
return at + 2;
|
|
656
|
+
}));
|
|
657
|
+
var only = handle.kind === "segment" ? axes[handle.index + 1] === "v" ? "x" : "y" : undefined;
|
|
700
658
|
beginDrag(event, function (point) {
|
|
701
|
-
|
|
702
|
-
updateLine(line.id, function (current) {
|
|
703
|
-
if (current.type === "elbow") {
|
|
704
|
-
return _objectSpread(_objectSpread({}, current), {}, {
|
|
705
|
-
waypoints: _objectSpread(_objectSpread({}, current.waypoints), {}, {
|
|
706
|
-
elbow: current.waypoints.elbow.map(function (bar, at) {
|
|
707
|
-
return at === index ? vertical ? _objectSpread(_objectSpread({}, bar), {}, {
|
|
708
|
-
x: snapped.x
|
|
709
|
-
}) : _objectSpread(_objectSpread({}, bar), {}, {
|
|
710
|
-
y: snapped.y
|
|
711
|
-
}) : bar;
|
|
712
|
-
})
|
|
713
|
-
})
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
return _objectSpread(_objectSpread({}, current), {}, {
|
|
717
|
-
waypoints: _objectSpread(_objectSpread({}, current.waypoints), {}, {
|
|
718
|
-
curved: current.waypoints.curved.map(function (waypoint, at) {
|
|
719
|
-
return at === index ? snapped : waypoint;
|
|
720
|
-
})
|
|
721
|
-
})
|
|
722
|
-
});
|
|
723
|
-
});
|
|
659
|
+
return setWaypoints(line.id, moveHandle(frame, handle, base, snapWithGuides(point, others, only)));
|
|
724
660
|
});
|
|
725
661
|
};
|
|
726
662
|
};
|
|
727
|
-
var
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
return /*#__PURE__*/_react.default.createElement("g", null, line.type === "
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
}) : null, bars.map(function (_, index) {
|
|
743
|
-
var from = route[index + 1];
|
|
744
|
-
var to = route[index + 2];
|
|
745
|
-
var vertical = (0, _lineModel.barIsVertical)(index, axis);
|
|
746
|
-
var active = selectedWaypoint === index;
|
|
663
|
+
var handleClass = function handleClass(handle, extra) {
|
|
664
|
+
return ["wb-handle", extra, isActive(handle) ? "is-active" : ""].filter(Boolean).join(" ");
|
|
665
|
+
};
|
|
666
|
+
return /*#__PURE__*/_react.default.createElement("g", null, line.type === "elbow" ? base.slice(0, -1).map(function (from, index) {
|
|
667
|
+
var to = base[index + 1];
|
|
668
|
+
if (from.x === to.x && from.y === to.y) {
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
var vertical = axes[index + 1] === "v";
|
|
672
|
+
var handle = {
|
|
673
|
+
kind: "segment",
|
|
674
|
+
index
|
|
675
|
+
};
|
|
747
676
|
return /*#__PURE__*/_react.default.createElement("rect", {
|
|
748
677
|
key: "segment-".concat(index),
|
|
749
|
-
className:
|
|
678
|
+
className: handleClass(handle, vertical ? "is-ew" : "is-ns"),
|
|
750
679
|
x: (from.x + to.x) / 2 - (vertical ? 3 : 8),
|
|
751
680
|
y: (from.y + to.y) / 2 - (vertical ? 8 : 3),
|
|
752
681
|
width: vertical ? 6 : 16,
|
|
753
682
|
height: vertical ? 16 : 6,
|
|
754
683
|
rx: 3,
|
|
755
|
-
onMouseDown:
|
|
684
|
+
onMouseDown: dragHandle(handle),
|
|
685
|
+
onClick: function onClick(event) {
|
|
686
|
+
return event.stopPropagation();
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
}) : null, base.map(function (point, index) {
|
|
690
|
+
var handle = {
|
|
691
|
+
kind: line.type === "elbow" ? "corner" : "waypoint",
|
|
692
|
+
index
|
|
693
|
+
};
|
|
694
|
+
return /*#__PURE__*/_react.default.createElement("circle", {
|
|
695
|
+
key: "".concat(handle.kind, "-").concat(index),
|
|
696
|
+
className: handleClass(handle),
|
|
697
|
+
cx: point.x,
|
|
698
|
+
cy: point.y,
|
|
699
|
+
r: 4,
|
|
700
|
+
onMouseDown: dragHandle(handle),
|
|
756
701
|
onClick: function onClick(event) {
|
|
757
702
|
return event.stopPropagation();
|
|
758
703
|
}
|
|
@@ -783,9 +728,9 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
783
728
|
if (!line.label) {
|
|
784
729
|
return null;
|
|
785
730
|
}
|
|
786
|
-
var
|
|
787
|
-
start =
|
|
788
|
-
end =
|
|
731
|
+
var _resolveEndpoints5 = (0, _lineModel.resolveEndpoints)(line, boxOf),
|
|
732
|
+
start = _resolveEndpoints5.start,
|
|
733
|
+
end = _resolveEndpoints5.end;
|
|
789
734
|
var geometry = (0, _lineModel.lineGeometry)(line, start, end);
|
|
790
735
|
var at = (0, _lineModel.pointAtFraction)(geometry.samples, line.label.position);
|
|
791
736
|
var selected = labelSelected && line.id === selectedId;
|
|
@@ -873,9 +818,9 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
873
818
|
if (!selectedLine || draft) {
|
|
874
819
|
return null;
|
|
875
820
|
}
|
|
876
|
-
var
|
|
877
|
-
start =
|
|
878
|
-
end =
|
|
821
|
+
var _resolveEndpoints6 = (0, _lineModel.resolveEndpoints)(selectedLine, boxOf),
|
|
822
|
+
start = _resolveEndpoints6.start,
|
|
823
|
+
end = _resolveEndpoints6.end;
|
|
879
824
|
var geometry = (0, _lineModel.lineGeometry)(selectedLine, start, end);
|
|
880
825
|
var xs = geometry.samples.map(function (point) {
|
|
881
826
|
return point.x;
|
|
@@ -917,7 +862,12 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
917
862
|
onTypeChange: function onTypeChange(type) {
|
|
918
863
|
setWaypointSelection(null);
|
|
919
864
|
updateLine(selectedLine.id, function (current) {
|
|
920
|
-
return (0, _lineModel.withLineType)(current, type, start, end)
|
|
865
|
+
return (0, _lineModel.withLineType)(current, type, start, end, function (point) {
|
|
866
|
+
return {
|
|
867
|
+
x: (0, _elements.snapValue)(point.x, snapStep),
|
|
868
|
+
y: (0, _elements.snapValue)(point.y, snapStep)
|
|
869
|
+
};
|
|
870
|
+
});
|
|
921
871
|
});
|
|
922
872
|
},
|
|
923
873
|
onStyleChange: function onStyleChange(partial) {
|
|
@@ -977,6 +927,14 @@ var LineLayer = exports.LineLayer = function LineLayer(_ref) {
|
|
|
977
927
|
}
|
|
978
928
|
}) : null), ordered.map(renderLabel), /*#__PURE__*/_react.default.createElement("div", {
|
|
979
929
|
className: "wb-toolbar-host"
|
|
980
|
-
}, renderToolbar())
|
|
930
|
+
}, renderToolbar()), limitReached ? /*#__PURE__*/_react.default.createElement(_shared.ToastHost, null, /*#__PURE__*/_react.default.createElement(_ToastMessage.ToastMessage, {
|
|
931
|
+
type: "error",
|
|
932
|
+
text: LIMIT_MESSAGE,
|
|
933
|
+
dismissible: true,
|
|
934
|
+
timeout: 3500,
|
|
935
|
+
onClose: function onClose() {
|
|
936
|
+
return setLimitReached(false);
|
|
937
|
+
}
|
|
938
|
+
})) : null);
|
|
981
939
|
};
|
|
982
940
|
//# sourceMappingURL=lineElements.js.map
|