@leafer-in/arrow 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/arrow.esm.js CHANGED
@@ -1,43 +1,24 @@
1
- import { LineData, decorateLeafAttr, attr, doStrokeType, dataProcessor, registerUI, Line, PathCommandMap, PointHelper, DataHelper, Plugin, UI, PathArrow, Paint } from '@leafer-ui/draw';
2
-
3
- /******************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
-
19
-
20
- function __decorate(decorators, target, key, desc) {
21
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
22
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
23
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24
- return c > 3 && r && Object.defineProperty(target, key, r), r;
25
- }
26
-
27
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
28
- var e = new Error(message);
29
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
30
- };
1
+ import { LineData, decorateLeafAttr, attr, doStrokeType, dataProcessor, registerUI, Line, PathCommandMap, PointHelper, DataHelper, isObject, Plugin, UI, PathArrow, Paint } from "@leafer-ui/draw";
31
2
 
32
- class ArrowData extends LineData {
3
+ function __decorate(decorators, target, key, desc) {
4
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
33
7
  }
34
8
 
9
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
10
+ var e = new Error(message);
11
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
12
+ };
13
+
14
+ class ArrowData extends LineData {}
15
+
35
16
  function arrowType(defaultValue) {
36
- return decorateLeafAttr(defaultValue, (key) => attr({
17
+ return decorateLeafAttr(defaultValue, key => attr({
37
18
  set(value) {
38
19
  if (this.__setAttr(key, value)) {
39
20
  const data = this.__;
40
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
21
+ data.__useArrow = data.startArrow !== "none" || data.endArrow !== "none";
41
22
  doStrokeType(this);
42
23
  }
43
24
  }
@@ -45,57 +26,59 @@ function arrowType(defaultValue) {
45
26
  }
46
27
 
47
28
  let Arrow = class Arrow extends Line {
48
- get __tag() { return 'Arrow'; }
29
+ get __tag() {
30
+ return "Arrow";
31
+ }
49
32
  constructor(data) {
50
33
  super(data);
51
34
  this.__.__useArrow = true;
52
35
  }
53
36
  };
54
- __decorate([
55
- dataProcessor(ArrowData)
56
- ], Arrow.prototype, "__", void 0);
57
- __decorate([
58
- arrowType('angle')
59
- ], Arrow.prototype, "endArrow", void 0);
60
- Arrow = __decorate([
61
- registerUI()
62
- ], Arrow);
63
-
64
- const { M: M$1, L: L$1, C: C$1, Q: Q$1, O: O$1 } = PathCommandMap;
65
- const { rotate: rotate$1, copyFrom: copyFrom$1, scale } = PointHelper;
37
+
38
+ __decorate([ dataProcessor(ArrowData) ], Arrow.prototype, "__", void 0);
39
+
40
+ __decorate([ arrowType("angle") ], Arrow.prototype, "endArrow", void 0);
41
+
42
+ Arrow = __decorate([ registerUI() ], Arrow);
43
+
44
+ const {M: M$1, L: L$1, C: C$1, Q: Q$1, O: O$1} = PathCommandMap;
45
+
46
+ const {rotate: rotate$1, copyFrom: copyFrom$1, scale: scale} = PointHelper;
47
+
66
48
  const point = {};
49
+
67
50
  const PathMatrixHelper = {
68
51
  layout(data, x, y, scaleX, scaleY, rotation, origin) {
69
52
  let command, i = 0, j, len = data.length;
70
53
  while (i < len) {
71
54
  command = data[i];
72
55
  switch (command) {
73
- case M$1:
74
- case L$1:
75
- setPoint$1(data, i + 1, x, y, scaleX, scaleY, rotation, origin);
76
- i += 3;
77
- break;
78
- case C$1:
79
- for (j = 1; j < 6; j += 2)
80
- setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
81
- i += 7;
82
- break;
83
- case Q$1:
84
- for (j = 1; j < 4; j += 2)
85
- setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
86
- i += 5;
87
- break;
88
- case O$1:
89
- data[i + 1] += x;
90
- data[i + 2] += y;
91
- if (scaleX)
92
- data[i + 3] *= scaleX;
93
- if (rotation) {
94
- data[i + 4] += rotation;
95
- data[i + 5] += rotation;
96
- }
97
- i += 7;
98
- break;
56
+ case M$1:
57
+ case L$1:
58
+ setPoint$1(data, i + 1, x, y, scaleX, scaleY, rotation, origin);
59
+ i += 3;
60
+ break;
61
+
62
+ case C$1:
63
+ for (j = 1; j < 6; j += 2) setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
64
+ i += 7;
65
+ break;
66
+
67
+ case Q$1:
68
+ for (j = 1; j < 4; j += 2) setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
69
+ i += 5;
70
+ break;
71
+
72
+ case O$1:
73
+ data[i + 1] += x;
74
+ data[i + 2] += y;
75
+ if (scaleX) data[i + 3] *= scaleX;
76
+ if (rotation) {
77
+ data[i + 4] += rotation;
78
+ data[i + 5] += rotation;
79
+ }
80
+ i += 7;
81
+ break;
99
82
  }
100
83
  }
101
84
  },
@@ -103,141 +86,229 @@ const PathMatrixHelper = {
103
86
  PathMatrixHelper.layout(data, 0, 0, 1, 1, rotation, center);
104
87
  }
105
88
  };
89
+
106
90
  function setPoint$1(data, startIndex, x, y, scaleX, scaleY, rotation, origin) {
107
91
  copyFrom$1(point, data[startIndex], data[startIndex + 1]);
108
- if (rotation)
109
- rotate$1(point, rotation, origin);
110
- if (scaleX)
111
- scale(point, scaleX, scaleY);
92
+ if (rotation) rotate$1(point, rotation, origin);
93
+ if (scaleX) scale(point, scaleX, scaleY);
112
94
  data[startIndex] = x + point.x;
113
95
  data[startIndex + 1] = y + point.y;
114
96
  }
115
97
 
116
- const { layout, rotate } = PathMatrixHelper;
117
- const { getAngle } = PointHelper;
118
- const half = { x: -0.5 };
119
- const angle = { connect: half, offset: { x: -0.71, bevelJoin: 0.36, roundJoin: 0.22 }, path: [1, -3, -3, 2, 0, 0, 2, -3, 3] };
120
- const angleSide = { connect: half, offset: { x: -1.207, bevelJoin: 0.854, roundJoin: 0.707 }, path: [1, -3, -3, 2, 0, 0, 2, -1, 0] };
121
- const triangleLinePath = [1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0];
122
- const triangle = { connect: half, offset: { x: -0.9, bevelJoin: 0.624, roundJoin: 0.4 }, path: [...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1], dashPath: [1, -2, 0, 2, -0.5, 0] };
123
- const arrowLinePath = [1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0];
124
- const arrow = { connect: half, offset: { x: -1.1, bevelJoin: 0.872, roundJoin: 0.6 }, path: [...arrowLinePath, 1, -2.25, 0.95, 2, -2.25, -0.95], dashPath: [1, -3, 0, 2, -0.5, 0] };
125
- const triangleFlip = { offset: half, path: [...triangle.path], dashPath: [1, -2.5, 0, 2, -1, 0] };
126
- rotate(triangleFlip.path, 180, { x: -1.5, y: 0 });
127
- const circleLine = { connect: { x: -1.3 }, path: [1, 1.8, -0.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0], };
128
- const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0], dashPath: [1, -0.5, 0, 2, 0.5, 0] };
129
- const squareLine = { connect: { x: -1.3 }, path: [1, -1.4, 0, 2, -1.4, -1.4, 2, 1.4, -1.4, 2, 1.4, 1.4, 2, -1.4, 1.4, 2, -1.4, 0] };
130
- const square = { path: [...squareLine.path, 2, -1.4, -0.49, 2, 1, -0.49, 1, -1.4, 0.49, 2, 1, 0.49] };
98
+ const {layout: layout, rotate: rotate} = PathMatrixHelper;
99
+
100
+ const {getAngle: getAngle} = PointHelper;
101
+
102
+ const half = {
103
+ x: -.5
104
+ };
105
+
106
+ const angle = {
107
+ connect: half,
108
+ offset: {
109
+ x: -.71,
110
+ bevelJoin: .36,
111
+ roundJoin: .22
112
+ },
113
+ path: [ 1, -3, -3, 2, 0, 0, 2, -3, 3 ]
114
+ };
115
+
116
+ const angleSide = {
117
+ connect: half,
118
+ offset: {
119
+ x: -1.207,
120
+ bevelJoin: .854,
121
+ roundJoin: .707
122
+ },
123
+ path: [ 1, -3, -3, 2, 0, 0, 2, -1, 0 ]
124
+ };
125
+
126
+ const triangleLinePath = [ 1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0 ];
127
+
128
+ const triangle = {
129
+ connect: half,
130
+ offset: {
131
+ x: -.9,
132
+ bevelJoin: .624,
133
+ roundJoin: .4
134
+ },
135
+ path: [ ...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1 ],
136
+ dashPath: [ 1, -2, 0, 2, -.5, 0 ]
137
+ };
138
+
139
+ const arrowLinePath = [ 1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0 ];
140
+
141
+ const arrow = {
142
+ connect: half,
143
+ offset: {
144
+ x: -1.1,
145
+ bevelJoin: .872,
146
+ roundJoin: .6
147
+ },
148
+ path: [ ...arrowLinePath, 1, -2.25, .95, 2, -2.25, -.95 ],
149
+ dashPath: [ 1, -3, 0, 2, -.5, 0 ]
150
+ };
151
+
152
+ const triangleFlip = {
153
+ offset: half,
154
+ path: [ ...triangle.path ],
155
+ dashPath: [ 1, -2.5, 0, 2, -1, 0 ]
156
+ };
157
+
158
+ rotate(triangleFlip.path, 180, {
159
+ x: -1.5,
160
+ y: 0
161
+ });
162
+
163
+ const circleLine = {
164
+ connect: {
165
+ x: -1.3
166
+ },
167
+ path: [ 1, 1.8, -.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0 ]
168
+ };
169
+
170
+ const circle = {
171
+ connect: {
172
+ x: .5
173
+ },
174
+ path: [ ...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0 ],
175
+ dashPath: [ 1, -.5, 0, 2, .5, 0 ]
176
+ };
177
+
178
+ const squareLine = {
179
+ connect: {
180
+ x: -1.3
181
+ },
182
+ path: [ 1, -1.4, 0, 2, -1.4, -1.4, 2, 1.4, -1.4, 2, 1.4, 1.4, 2, -1.4, 1.4, 2, -1.4, 0 ]
183
+ };
184
+
185
+ const square = {
186
+ path: [ ...squareLine.path, 2, -1.4, -.49, 2, 1, -.49, 1, -1.4, .49, 2, 1, .49 ]
187
+ };
188
+
131
189
  const diamondLine = DataHelper.clone(squareLine);
190
+
132
191
  const diamond = DataHelper.clone(square);
192
+
133
193
  rotate(diamondLine.path, 45);
194
+
134
195
  rotate(diamond.path, 45);
135
- const mark = { offset: half, path: [1, 0, -2, 2, 0, 2] };
196
+
197
+ const mark = {
198
+ offset: half,
199
+ path: [ 1, 0, -2, 2, 0, 2 ]
200
+ };
201
+
136
202
  const arrows = {
137
- angle,
138
- 'angle-side': angleSide,
139
- arrow,
140
- triangle,
141
- 'triangle-flip': triangleFlip,
142
- circle,
143
- 'circle-line': circleLine,
144
- square,
145
- 'square-line': squareLine,
146
- diamond,
147
- 'diamond-line': diamondLine,
148
- mark,
203
+ angle: angle,
204
+ "angle-side": angleSide,
205
+ arrow: arrow,
206
+ triangle: triangle,
207
+ "triangle-flip": triangleFlip,
208
+ circle: circle,
209
+ "circle-line": circleLine,
210
+ square: square,
211
+ "square-line": squareLine,
212
+ diamond: diamond,
213
+ "diamond-line": diamondLine,
214
+ mark: mark
149
215
  };
216
+
150
217
  function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
151
- const { strokeCap, strokeJoin } = ui.__;
152
- const { offset, connect, path, dashPath } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
218
+ const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
219
+ const {offset: offset, connect: connect, path: path, dashPath: dashPath} = isObject(arrow) ? arrow : arrows[arrow];
153
220
  let connectX = connect ? connect.x : 0;
154
221
  let offsetX = offset ? offset.x : 0;
155
- const data = [...path];
156
- if (hasDashPattern && dashPath)
157
- data.push(...dashPath);
158
- if (strokeCap !== 'none')
159
- connectX -= 0.5;
222
+ const data = [ ...path ];
223
+ if (hasDashPattern && dashPath) data.push(...dashPath);
224
+ if (strokeCap !== "none") connectX -= .5;
160
225
  if (offset) {
161
- if (strokeJoin === 'round' && offset.roundJoin)
162
- offsetX += offset.roundJoin;
163
- else if (strokeJoin === 'bevel' && offset.bevelJoin)
164
- offsetX += offset.bevelJoin;
226
+ if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
165
227
  }
166
- if (offsetX)
167
- layout(data, offsetX, 0);
228
+ if (offsetX) layout(data, offsetX, 0);
168
229
  layout(data, to.x, to.y, scale, scale, getAngle(from, to));
169
230
  connectOffset.x = (connectX + offsetX) * scale;
170
231
  return data;
171
232
  }
172
233
 
173
- const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = PathCommandMap;
174
- const { copy, copyFrom, getDistancePoint, } = PointHelper;
234
+ const {M: M, L: L, C: C, Q: Q, Z: Z, N: N, D: D, X: X, G: G, F: F, O: O, P: P, U: U} = PathCommandMap;
235
+
236
+ const {copy: copy, copyFrom: copyFrom, getDistancePoint: getDistancePoint} = PointHelper;
237
+
175
238
  const connectPoint = {};
239
+
176
240
  const first = {}, second = {};
241
+
177
242
  const last = {}, now = {};
243
+
178
244
  const PathArrowModule = {
179
245
  list: arrows,
180
246
  addArrows(ui, changeRenderPath) {
181
- const { startArrow, endArrow, strokeWidth, dashPattern, __pathForRender: data } = ui.__;
182
- let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== 'none';
247
+ const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
248
+ let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
183
249
  while (i < len) {
184
250
  command = data[i];
185
251
  switch (command) {
186
- case M:
187
- case L:
188
- if (count < 2 || i + 6 >= len) {
189
- copyFrom(now, data[i + 1], data[i + 2]);
190
- if (!count && useStartArrow)
191
- copy(first, now);
192
- }
193
- i += 3;
194
- break;
195
- case C:
196
- if (count === 1 || i + 7 === len)
197
- copyPoints(data, last, now, i + 3);
198
- i += 7;
199
- break;
200
- case Q:
201
- if (count === 1 || i + 5 === len)
202
- copyPoints(data, last, now, i + 1);
203
- i += 5;
204
- break;
205
- case Z:
206
- return;
207
- case N:
208
- i += 5;
209
- break;
210
- case D:
211
- i += 9;
212
- break;
213
- case X:
214
- i += 6;
215
- break;
216
- case G:
217
- i += 9;
218
- break;
219
- case F:
220
- i += 5;
221
- break;
222
- case O:
223
- i += 7;
224
- break;
225
- case P:
226
- i += 4;
227
- break;
228
- case U:
229
- if (count === 1 || i + 6 === len)
230
- copyPoints(data, last, now, i + 1);
231
- i += 6;
232
- break;
252
+ case M:
253
+ case L:
254
+ if (count < 2 || i + 6 >= len) {
255
+ copyFrom(now, data[i + 1], data[i + 2]);
256
+ if (!count && useStartArrow) copy(first, now);
257
+ }
258
+ i += 3;
259
+ break;
260
+
261
+ case C:
262
+ if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
263
+ i += 7;
264
+ break;
265
+
266
+ case Q:
267
+ if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
268
+ i += 5;
269
+ break;
270
+
271
+ case Z:
272
+ return;
273
+
274
+ case N:
275
+ i += 5;
276
+ break;
277
+
278
+ case D:
279
+ i += 9;
280
+ break;
281
+
282
+ case X:
283
+ i += 6;
284
+ break;
285
+
286
+ case G:
287
+ i += 9;
288
+ break;
289
+
290
+ case F:
291
+ i += 5;
292
+ break;
293
+
294
+ case O:
295
+ i += 7;
296
+ break;
297
+
298
+ case P:
299
+ i += 4;
300
+ break;
301
+
302
+ case U:
303
+ if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
304
+ i += 6;
305
+ break;
233
306
  }
234
307
  count++;
235
- if (count === 1 && command !== M)
236
- return;
237
- if (count === 2 && useStartArrow)
238
- copy(second, command === L ? now : last);
308
+ if (count === 1 && command !== M) return;
309
+ if (count === 2 && useStartArrow) copy(second, command === L ? now : last);
239
310
  if (i === len) {
240
- const path = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
311
+ const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
241
312
  const pathForArrow = ui.__.__pathForArrow = [];
242
313
  if (useStartArrow) {
243
314
  const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
@@ -248,50 +319,57 @@ const PathArrowModule = {
248
319
  path[2] = second.y;
249
320
  }
250
321
  }
251
- if (endArrow && endArrow !== 'none') {
322
+ if (endArrow && endArrow !== "none") {
252
323
  const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
253
324
  dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
254
325
  if (connectPoint.x) {
255
326
  getDistancePoint(now, last, -connectPoint.x, true);
256
327
  let index;
257
328
  switch (command) {
258
- case L:
259
- index = i - 3 + 1;
260
- break;
261
- case C:
262
- index = i - 7 + 5;
263
- break;
264
- case Q:
265
- index = i - 5 + 3;
266
- break;
267
- case U:
268
- index = i - 6 + 3;
269
- break;
329
+ case L:
330
+ index = i - 3 + 1;
331
+ break;
332
+
333
+ case C:
334
+ index = i - 7 + 5;
335
+ break;
336
+
337
+ case Q:
338
+ index = i - 5 + 3;
339
+ break;
340
+
341
+ case U:
342
+ index = i - 6 + 3;
343
+ break;
270
344
  }
271
- if (index)
272
- setPoint(path, last, index);
345
+ if (index) setPoint(path, last, index);
273
346
  }
274
347
  }
275
- }
276
- else {
348
+ } else {
277
349
  copy(last, now);
278
350
  }
279
351
  }
280
352
  }
281
353
  };
354
+
282
355
  function copyPoints(data, from, to, startIndex) {
283
356
  copyFrom(from, data[startIndex], data[startIndex + 1]);
284
357
  copyFrom(to, data[startIndex + 2], data[startIndex + 3]);
285
358
  }
359
+
286
360
  function setPoint(data, point, startIndex) {
287
361
  data[startIndex] = point.x;
288
362
  data[startIndex + 1] = point.y;
289
363
  }
290
364
 
291
- Plugin.add('arrow');
292
- UI.addAttr('startArrow', 'none', arrowType);
293
- UI.addAttr('endArrow', 'none', arrowType);
365
+ Plugin.add("arrow");
366
+
367
+ UI.addAttr("startArrow", "none", arrowType);
368
+
369
+ UI.addAttr("endArrow", "none", arrowType);
370
+
294
371
  Object.assign(PathArrow, PathArrowModule);
372
+
295
373
  Object.assign(Paint, {
296
374
  strokeArrow(_stroke, ui, canvas) {
297
375
  if (ui.__.dashPattern) {
@@ -1,2 +1,2 @@
1
- import{LineData as e,decorateLeafAttr as t,attr as r,doStrokeType as o,dataProcessor as n,registerUI as a,Line as s,PathCommandMap as c,PointHelper as i,DataHelper as h,Plugin as p,UI as l,PathArrow as d,Paint as f}from"@leafer-ui/draw";function u(e,t,r,o){var n,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(a<3?n(s):a>3?n(t,r,s):n(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class _ extends e{}function b(e){return t(e,(e=>r({set(t){if(this.__setAttr(e,t)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,o(this)}}})))}let x=class extends s{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}};u([n(_)],x.prototype,"__",void 0),u([b("angle")],x.prototype,"endArrow",void 0),x=u([a()],x);const{M:k,L:w,C:y,Q:g,O:A}=c,{rotate:P,copyFrom:J,scale:v}=i,m={},F={layout(e,t,r,o,n,a,s){let c,i,h=0,p=e.length;for(;h<p;)switch(c=e[h],c){case k:case w:O(e,h+1,t,r,o,n,a,s),h+=3;break;case y:for(i=1;i<6;i+=2)O(e,h+i,t,r,o,n,a,s);h+=7;break;case g:for(i=1;i<4;i+=2)O(e,h+i,t,r,o,n,a,s);h+=5;break;case A:e[h+1]+=t,e[h+2]+=r,o&&(e[h+3]*=o),a&&(e[h+4]+=a,e[h+5]+=a),h+=7}},rotate(e,t,r){F.layout(e,0,0,1,1,t,r)}};function O(e,t,r,o,n,a,s,c){J(m,e[t],e[t+1]),s&&P(m,s,c),n&&v(m,n,a),e[t]=r+m.x,e[t+1]=o+m.y}const{layout:j,rotate:R}=F,{getAngle:D}=i,C={x:-.5},q={connect:C,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},E={connect:C,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},L={connect:C,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},M={connect:C,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},Q={offset:C,path:[...L.path],dashPath:[1,-2.5,0,2,-1,0]};R(Q.path,180,{x:-1.5,y:0});const S={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},B={connect:{x:.5},path:[...S.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},G={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},N={path:[...G.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},U=h.clone(G),W=h.clone(N);R(U.path,45),R(W.path,45);const X={angle:q,"angle-side":E,arrow:M,triangle:L,"triangle-flip":Q,circle:B,"circle-line":S,square:N,"square-line":G,diamond:W,"diamond-line":U,mark:{offset:C,path:[1,0,-2,2,0,2]}};function Z(e,t,r,o,n,a,s){const{strokeCap:c,strokeJoin:i}=e.__,{offset:h,connect:p,path:l,dashPath:d}="object"==typeof t?t:X[t];let f=p?p.x:0,u=h?h.x:0;const _=[...l];return s&&d&&_.push(...d),"none"!==c&&(f-=.5),h&&("round"===i&&h.roundJoin?u+=h.roundJoin:"bevel"===i&&h.bevelJoin&&(u+=h.bevelJoin)),u&&j(_,u,0),j(_,o.x,o.y,n,n,D(r,o)),a.x=(f+u)*n,_}const{M:z,L:H,C:I,Q:K,Z:T,N:V,D:Y,X:$,G:ee,F:te,O:re,P:oe,U:ne}=c,{copy:ae,copyFrom:se,getDistancePoint:ce}=i,ie={},he={},pe={},le={},de={},fe={list:X,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:n,dashPattern:a,__pathForRender:s}=e.__;let c,i=0,h=s.length,p=0,l=r&&"none"!==r;for(;i<h;){switch(c=s[i],c){case z:case H:(p<2||i+6>=h)&&(se(de,s[i+1],s[i+2]),!p&&l&&ae(he,de)),i+=3;break;case I:1!==p&&i+7!==h||ue(s,le,de,i+3),i+=7;break;case K:1!==p&&i+5!==h||ue(s,le,de,i+1),i+=5;break;case T:return;case V:i+=5;break;case Y:i+=9;break;case $:i+=6;break;case ee:i+=9;break;case te:i+=5;break;case re:i+=7;break;case oe:i+=4;break;case ne:1!==p&&i+6!==h||ue(s,le,de,i+1),i+=6}if(p++,1===p&&c!==z)return;if(2===p&&l&&ae(pe,c===H?de:le),i===h){const h=e.__.__pathForRender=t?[...s]:s,p=e.__.__pathForArrow=[];if(l){const t=Z(e,r,pe,he,n,ie,!!a);a?p.push(...t):h.push(...t),ie.x&&(ce(he,pe,-ie.x,!0),h[1]=pe.x,h[2]=pe.y)}if(o&&"none"!==o){const t=Z(e,o,le,de,n,ie,!!a);if(a?p.push(...t):h.push(...t),ie.x){let e;switch(ce(de,le,-ie.x,!0),c){case H:e=i-3+1;break;case I:e=i-7+5;break;case K:e=i-5+3;break;case ne:e=i-6+3}e&&_e(h,le,e)}}}else ae(le,de)}}};function ue(e,t,r,o){se(t,e[o],e[o+1]),se(r,e[o+2],e[o+3])}function _e(e,t,r){e[r]=t.x,e[r+1]=t.y}p.add("arrow"),l.addAttr("startArrow","none",b),l.addAttr("endArrow","none",b),Object.assign(d,fe),Object.assign(f,{strokeArrow(e,t,r){t.__.dashPattern&&(r.beginPath(),t.__drawPathByData(r,t.__.__pathForArrow),r.dashPattern=null,r.stroke())}});export{x as Arrow,_ as ArrowData,fe as PathArrowModule,F as PathMatrixHelper,b as arrowType};
1
+ import{LineData as e,decorateLeafAttr as t,attr as r,doStrokeType as o,dataProcessor as n,registerUI as a,Line as s,PathCommandMap as c,PointHelper as i,DataHelper as h,isObject as p,Plugin as l,UI as d,PathArrow as f,Paint as u}from"@leafer-ui/draw";function _(e,t,r,o){var n,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(a<3?n(s):a>3?n(t,r,s):n(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class b extends e{}function x(e){return t(e,e=>r({set(t){if(this.__setAttr(e,t)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,o(this)}}}))}let k=class extends s{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}};_([n(b)],k.prototype,"__",void 0),_([x("angle")],k.prototype,"endArrow",void 0),k=_([a()],k);const{M:w,L:y,C:g,Q:A,O:P}=c,{rotate:J,copyFrom:v,scale:m}=i,F={},O={layout(e,t,r,o,n,a,s){let c,i,h=0,p=e.length;for(;h<p;)switch(c=e[h],c){case w:case y:j(e,h+1,t,r,o,n,a,s),h+=3;break;case g:for(i=1;i<6;i+=2)j(e,h+i,t,r,o,n,a,s);h+=7;break;case A:for(i=1;i<4;i+=2)j(e,h+i,t,r,o,n,a,s);h+=5;break;case P:e[h+1]+=t,e[h+2]+=r,o&&(e[h+3]*=o),a&&(e[h+4]+=a,e[h+5]+=a),h+=7}},rotate(e,t,r){O.layout(e,0,0,1,1,t,r)}};function j(e,t,r,o,n,a,s,c){v(F,e[t],e[t+1]),s&&J(F,s,c),n&&m(F,n,a),e[t]=r+F.x,e[t+1]=o+F.y}const{layout:R,rotate:D}=O,{getAngle:C}=i,q={x:-.5},E={connect:q,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},L={connect:q,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},M={connect:q,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},Q={connect:q,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},S={offset:q,path:[...M.path],dashPath:[1,-2.5,0,2,-1,0]};D(S.path,180,{x:-1.5,y:0});const B={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},G={connect:{x:.5},path:[...B.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},N={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},U={path:[...N.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},W=h.clone(N),X=h.clone(U);D(W.path,45),D(X.path,45);const Z={angle:E,"angle-side":L,arrow:Q,triangle:M,"triangle-flip":S,circle:G,"circle-line":B,square:U,"square-line":N,diamond:X,"diamond-line":W,mark:{offset:q,path:[1,0,-2,2,0,2]}};function z(e,t,r,o,n,a,s){const{strokeCap:c,strokeJoin:i}=e.__,{offset:h,connect:l,path:d,dashPath:f}=p(t)?t:Z[t];let u=l?l.x:0,_=h?h.x:0;const b=[...d];return s&&f&&b.push(...f),"none"!==c&&(u-=.5),h&&("round"===i&&h.roundJoin?_+=h.roundJoin:"bevel"===i&&h.bevelJoin&&(_+=h.bevelJoin)),_&&R(b,_,0),R(b,o.x,o.y,n,n,C(r,o)),a.x=(u+_)*n,b}const{M:H,L:I,C:K,Q:T,Z:V,N:Y,D:$,X:ee,G:te,F:re,O:oe,P:ne,U:ae}=c,{copy:se,copyFrom:ce,getDistancePoint:ie}=i,he={},pe={},le={},de={},fe={},ue={list:Z,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:n,dashPattern:a,__pathForRender:s}=e.__;let c,i=0,h=s.length,p=0,l=r&&"none"!==r;for(;i<h;){switch(c=s[i],c){case H:case I:(p<2||i+6>=h)&&(ce(fe,s[i+1],s[i+2]),!p&&l&&se(pe,fe)),i+=3;break;case K:1!==p&&i+7!==h||_e(s,de,fe,i+3),i+=7;break;case T:1!==p&&i+5!==h||_e(s,de,fe,i+1),i+=5;break;case V:return;case Y:i+=5;break;case $:i+=9;break;case ee:i+=6;break;case te:i+=9;break;case re:i+=5;break;case oe:i+=7;break;case ne:i+=4;break;case ae:1!==p&&i+6!==h||_e(s,de,fe,i+1),i+=6}if(p++,1===p&&c!==H)return;if(2===p&&l&&se(le,c===I?fe:de),i===h){const h=e.__.__pathForRender=t?[...s]:s,p=e.__.__pathForArrow=[];if(l){const t=z(e,r,le,pe,n,he,!!a);a?p.push(...t):h.push(...t),he.x&&(ie(pe,le,-he.x,!0),h[1]=le.x,h[2]=le.y)}if(o&&"none"!==o){const t=z(e,o,de,fe,n,he,!!a);if(a?p.push(...t):h.push(...t),he.x){let e;switch(ie(fe,de,-he.x,!0),c){case I:e=i-3+1;break;case K:e=i-7+5;break;case T:e=i-5+3;break;case ae:e=i-6+3}e&&be(h,de,e)}}}else se(de,fe)}}};function _e(e,t,r,o){ce(t,e[o],e[o+1]),ce(r,e[o+2],e[o+3])}function be(e,t,r){e[r]=t.x,e[r+1]=t.y}l.add("arrow"),d.addAttr("startArrow","none",x),d.addAttr("endArrow","none",x),Object.assign(f,ue),Object.assign(u,{strokeArrow(e,t,r){t.__.dashPattern&&(r.beginPath(),t.__drawPathByData(r,t.__.__pathForArrow),r.dashPattern=null,r.stroke())}});export{k as Arrow,b as ArrowData,ue as PathArrowModule,O as PathMatrixHelper,x as arrowType};
2
2
  //# sourceMappingURL=arrow.esm.min.js.map