@leafer-in/arrow 1.0.1 → 1.0.3

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.cjs CHANGED
@@ -273,8 +273,24 @@ function setPoint(data, point, startIndex) {
273
273
  data[startIndex + 1] = point.y;
274
274
  }
275
275
 
276
+ function arrowType(defaultValue) {
277
+ return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
278
+ set(value) {
279
+ if (this.__setAttr(key, value)) {
280
+ const data = this.__;
281
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
282
+ draw.doStrokeType(this);
283
+ }
284
+ }
285
+ }));
286
+ }
287
+
288
+ const ui = draw.UI.prototype;
289
+ arrowType('none')(ui, 'startArrow');
290
+ arrowType('none')(ui, 'endArrow');
276
291
  Object.assign(draw.PathArrow, PathArrowModule);
277
292
 
278
293
  exports.ArrowData = ArrowData;
279
294
  exports.PathArrowModule = PathArrowModule;
280
295
  exports.PathMatrixHelper = PathMatrixHelper;
296
+ exports.arrowType = arrowType;
package/dist/arrow.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LineData, dataProcessor, strokeType, registerUI, Line, PathCommandMap, PointHelper, DataHelper, PathArrow } from '@leafer-ui/draw';
1
+ import { LineData, dataProcessor, strokeType, registerUI, Line, PathCommandMap, PointHelper, DataHelper, decorateLeafAttr, attr, doStrokeType, UI, PathArrow } from '@leafer-ui/draw';
2
2
 
3
3
  /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -271,6 +271,21 @@ function setPoint(data, point, startIndex) {
271
271
  data[startIndex + 1] = point.y;
272
272
  }
273
273
 
274
+ function arrowType(defaultValue) {
275
+ return decorateLeafAttr(defaultValue, (key) => attr({
276
+ set(value) {
277
+ if (this.__setAttr(key, value)) {
278
+ const data = this.__;
279
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
280
+ doStrokeType(this);
281
+ }
282
+ }
283
+ }));
284
+ }
285
+
286
+ const ui = UI.prototype;
287
+ arrowType('none')(ui, 'startArrow');
288
+ arrowType('none')(ui, 'endArrow');
274
289
  Object.assign(PathArrow, PathArrowModule);
275
290
 
276
- export { Arrow, ArrowData, PathArrowModule, PathMatrixHelper };
291
+ export { Arrow, ArrowData, PathArrowModule, PathMatrixHelper, arrowType };
@@ -1 +1 @@
1
- import{LineData as e,dataProcessor as t,strokeType as o,registerUI as n,Line as r,PathCommandMap as a,PointHelper as c,DataHelper as s,PathArrow as i}from"@leafer-ui/draw";function l(e,t,o,n){var r,a=arguments.length,c=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(a<3?r(c):a>3?r(t,o,c):r(t,o))||c);return a>3&&c&&Object.defineProperty(t,o,c),c}"function"==typeof SuppressedError&&SuppressedError;class p extends e{}let f=class extends r{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}};l([t(p)],f.prototype,"__",void 0),l([o("angle")],f.prototype,"endArrow",void 0),f=l([n()],f);const{M:u,L:h,C:d,Q:b,O:x}=a,{rotate:k,copyFrom:y,scale:_}=c,g={},J={layout(e,t,o,n,r,a,c){let s,i,l=0,p=e.length;for(;l<p;)switch(s=e[l],s){case u:case h:w(e,l+1,t,o,n,r,a,c),l+=3;break;case d:for(i=1;i<6;i+=2)w(e,l+i,t,o,n,r,a,c);l+=7;break;case b:for(i=1;i<4;i+=2)w(e,l+i,t,o,n,r,a,c);l+=5;break;case x:e[l+1]+=t,e[l+2]+=o,n&&(e[l+3]*=n),a&&(e[l+4]+=a,e[l+5]+=a),l+=7}},rotate(e,t,o){J.layout(e,0,0,1,1,t,o)}};function w(e,t,o,n,r,a,c,s){y(g,e[t],e[t+1]),c&&k(g,c,s),r&&_(g,r,a),e[t]=o+g.x,e[t+1]=n+g.y}const{layout:v,rotate:m}=J,{getAngle:A}=c,O={x:-.5},j={connect:O,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},F={connect:O,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},R={connect:O,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]},P={connect:O,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]},C={offset:O,path:[...R.path]};m(C.path,180,{x:-1.5,y:0});const D={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},q={connect:{x:.5},path:[...D.path,1,0,0,26,0,0,1,0,360,0]},E={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]},L={path:[...E.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},M=s.clone(E),Q=s.clone(L);m(M.path,45),m(Q.path,45);const S={angle:j,"angle-side":F,arrow:P,triangle:R,"triangle-flip":C,circle:q,"circle-line":D,square:L,"square-line":E,diamond:Q,"diamond-line":M,mark:{offset:O,path:[1,0,-2,2,0,2]}};function G(e,t,o,n,r,a){const{strokeCap:c,strokeJoin:s}=e.__,{offset:i,connect:l,path:p}="object"==typeof t?t:S[t];let f=l?l.x:0,u=i?i.x:0;const h=[...p];return"none"!==c&&(f-=.5),i&&("round"===s&&i.roundJoin?u+=i.roundJoin:"bevel"===s&&i.bevelJoin&&(u+=i.bevelJoin)),u&&v(h,u,0),v(h,n.x,n.y,r,r,A(o,n)),a.x=(f+u)*r,h}const{M:N,L:U,C:W,Q:X,Z:Z,N:z,D:B,X:H,G:I,F:K,O:T,P:V,U:Y}=a,{copy:$,copyFrom:ee,getDistancePoint:te}=c,oe={},ne={},re={},ae={},ce={},se={list:S,addArrows(e,t){const{startArrow:o,endArrow:n,strokeWidth:r,__pathForRender:a}=e.__;let c,s=0,i=a.length,l=0,p=o&&"none"!==o;for(;s<i;){switch(c=a[s],c){case N:case U:(l<2||s+6>=i)&&(ee(ce,a[s+1],a[s+2]),!l&&p&&$(ne,ce)),s+=3;break;case W:1!==l&&s+7!==i||ie(a,ae,ce,s+3),s+=7;break;case X:1!==l&&s+5!==i||ie(a,ae,ce,s+1),s+=5;break;case Z:return;case z:s+=5;break;case B:s+=9;break;case H:s+=6;break;case I:s+=9;break;case K:s+=5;break;case T:s+=7;break;case V:s+=4;break;case Y:1!==l&&s+6!==i||ie(a,ae,ce,s+1),s+=6}if(l++,1===l&&c!==N)return;if(2===l&&p&&$(re,c===U?ce:ae),s===i){const i=e.__.__pathForRender=t?[...a]:a;if(p&&(i.push(...G(e,o,re,ne,r,oe)),oe.x&&(te(ne,re,-oe.x,!0),i[1]=re.x,i[2]=re.y)),n&&"none"!==n&&(i.push(...G(e,n,ae,ce,r,oe)),oe.x)){let e;switch(te(ce,ae,-oe.x,!0),c){case U:e=s-3+1;break;case W:e=s-7+5;break;case X:e=s-5+3;break;case Y:e=s-6+3}e&&le(i,ae,e)}}else $(ae,ce)}}};function ie(e,t,o,n){ee(t,e[n],e[n+1]),ee(o,e[n+2],e[n+3])}function le(e,t,o){e[o]=t.x,e[o+1]=t.y}Object.assign(i,se);export{f as Arrow,p as ArrowData,se as PathArrowModule,J as PathMatrixHelper};
1
+ import{LineData as e,dataProcessor as t,strokeType as o,registerUI as r,Line as n,PathCommandMap as a,PointHelper as c,DataHelper as s,decorateLeafAttr as i,attr as p,doStrokeType as l,UI as f,PathArrow as u}from"@leafer-ui/draw";function h(e,t,o,r){var n,a=arguments.length,c=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(c=(a<3?n(c):a>3?n(t,o,c):n(t,o))||c);return a>3&&c&&Object.defineProperty(t,o,c),c}"function"==typeof SuppressedError&&SuppressedError;class d extends e{}let b=class extends n{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}};h([t(d)],b.prototype,"__",void 0),h([o("angle")],b.prototype,"endArrow",void 0),b=h([r()],b);const{M:_,L:x,C:k,Q:y,O:w}=a,{rotate:g,copyFrom:A,scale:J}=c,v={},m={layout(e,t,o,r,n,a,c){let s,i,p=0,l=e.length;for(;p<l;)switch(s=e[p],s){case _:case x:O(e,p+1,t,o,r,n,a,c),p+=3;break;case k:for(i=1;i<6;i+=2)O(e,p+i,t,o,r,n,a,c);p+=7;break;case y:for(i=1;i<4;i+=2)O(e,p+i,t,o,r,n,a,c);p+=5;break;case w:e[p+1]+=t,e[p+2]+=o,r&&(e[p+3]*=r),a&&(e[p+4]+=a,e[p+5]+=a),p+=7}},rotate(e,t,o){m.layout(e,0,0,1,1,t,o)}};function O(e,t,o,r,n,a,c,s){A(v,e[t],e[t+1]),c&&g(v,c,s),n&&J(v,n,a),e[t]=o+v.x,e[t+1]=r+v.y}const{layout:j,rotate:F}=m,{getAngle:R}=c,P={x:-.5},C={connect:P,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},D={connect:P,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},q={connect:P,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]},E={connect:P,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]},L={offset:P,path:[...q.path]};F(L.path,180,{x:-1.5,y:0});const M={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},Q={connect:{x:.5},path:[...M.path,1,0,0,26,0,0,1,0,360,0]},S={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]},G={path:[...S.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},N=s.clone(S),U=s.clone(G);F(N.path,45),F(U.path,45);const W={angle:C,"angle-side":D,arrow:E,triangle:q,"triangle-flip":L,circle:Q,"circle-line":M,square:G,"square-line":S,diamond:U,"diamond-line":N,mark:{offset:P,path:[1,0,-2,2,0,2]}};function X(e,t,o,r,n,a){const{strokeCap:c,strokeJoin:s}=e.__,{offset:i,connect:p,path:l}="object"==typeof t?t:W[t];let f=p?p.x:0,u=i?i.x:0;const h=[...l];return"none"!==c&&(f-=.5),i&&("round"===s&&i.roundJoin?u+=i.roundJoin:"bevel"===s&&i.bevelJoin&&(u+=i.bevelJoin)),u&&j(h,u,0),j(h,r.x,r.y,n,n,R(o,r)),a.x=(f+u)*n,h}const{M:Z,L:z,C:B,Q:H,Z:I,N:K,D:T,X:V,G:Y,F:$,O:ee,P:te,U:oe}=a,{copy:re,copyFrom:ne,getDistancePoint:ae}=c,ce={},se={},ie={},pe={},le={},fe={list:W,addArrows(e,t){const{startArrow:o,endArrow:r,strokeWidth:n,__pathForRender:a}=e.__;let c,s=0,i=a.length,p=0,l=o&&"none"!==o;for(;s<i;){switch(c=a[s],c){case Z:case z:(p<2||s+6>=i)&&(ne(le,a[s+1],a[s+2]),!p&&l&&re(se,le)),s+=3;break;case B:1!==p&&s+7!==i||ue(a,pe,le,s+3),s+=7;break;case H:1!==p&&s+5!==i||ue(a,pe,le,s+1),s+=5;break;case I:return;case K:s+=5;break;case T:s+=9;break;case V:s+=6;break;case Y:s+=9;break;case $:s+=5;break;case ee:s+=7;break;case te:s+=4;break;case oe:1!==p&&s+6!==i||ue(a,pe,le,s+1),s+=6}if(p++,1===p&&c!==Z)return;if(2===p&&l&&re(ie,c===z?le:pe),s===i){const i=e.__.__pathForRender=t?[...a]:a;if(l&&(i.push(...X(e,o,ie,se,n,ce)),ce.x&&(ae(se,ie,-ce.x,!0),i[1]=ie.x,i[2]=ie.y)),r&&"none"!==r&&(i.push(...X(e,r,pe,le,n,ce)),ce.x)){let e;switch(ae(le,pe,-ce.x,!0),c){case z:e=s-3+1;break;case B:e=s-7+5;break;case H:e=s-5+3;break;case oe:e=s-6+3}e&&he(i,pe,e)}}else re(pe,le)}}};function ue(e,t,o,r){ne(t,e[r],e[r+1]),ne(o,e[r+2],e[r+3])}function he(e,t,o){e[o]=t.x,e[o+1]=t.y}function de(e){return i(e,(e=>p({set(t){if(this.__setAttr(e,t)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,l(this)}}})))}const be=f.prototype;de("none")(be,"startArrow"),de("none")(be,"endArrow"),Object.assign(u,fe);export{b as Arrow,d as ArrowData,fe as PathArrowModule,m as PathMatrixHelper,de as arrowType};
package/dist/arrow.js CHANGED
@@ -273,11 +273,27 @@ this.LeaferIN.arrow = (function (exports, draw) {
273
273
  data[startIndex + 1] = point.y;
274
274
  }
275
275
 
276
+ function arrowType(defaultValue) {
277
+ return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
278
+ set(value) {
279
+ if (this.__setAttr(key, value)) {
280
+ const data = this.__;
281
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
282
+ draw.doStrokeType(this);
283
+ }
284
+ }
285
+ }));
286
+ }
287
+
288
+ const ui = draw.UI.prototype;
289
+ arrowType('none')(ui, 'startArrow');
290
+ arrowType('none')(ui, 'endArrow');
276
291
  Object.assign(draw.PathArrow, PathArrowModule);
277
292
 
278
293
  exports.ArrowData = ArrowData;
279
294
  exports.PathArrowModule = PathArrowModule;
280
295
  exports.PathMatrixHelper = PathMatrixHelper;
296
+ exports.arrowType = arrowType;
281
297
 
282
298
  return exports;
283
299
 
@@ -1 +1 @@
1
- "use strict";var e=require("@leafer-ui/draw");function t(e,t,r,o){var a,n=arguments.length,s=n<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--)(a=e[c])&&(s=(n<3?a(s):n>3?a(t,r,s):a(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class r extends e.LineData{}exports.Arrow=class extends e.Line{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}},t([e.dataProcessor(r)],exports.Arrow.prototype,"__",void 0),t([e.strokeType("angle")],exports.Arrow.prototype,"endArrow",void 0),exports.Arrow=t([e.registerUI()],exports.Arrow);const{M:o,L:a,C:n,Q:s,O:c}=e.PathCommandMap,{rotate:p,copyFrom:i,scale:l}=e.PointHelper,f={},u={layout(e,t,r,p,i,l,f){let u,d,x=0,b=e.length;for(;x<b;)switch(u=e[x],u){case o:case a:h(e,x+1,t,r,p,i,l,f),x+=3;break;case n:for(d=1;d<6;d+=2)h(e,x+d,t,r,p,i,l,f);x+=7;break;case s:for(d=1;d<4;d+=2)h(e,x+d,t,r,p,i,l,f);x+=5;break;case c:e[x+1]+=t,e[x+2]+=r,p&&(e[x+3]*=p),l&&(e[x+4]+=l,e[x+5]+=l),x+=7}},rotate(e,t,r){u.layout(e,0,0,1,1,t,r)}};function h(e,t,r,o,a,n,s,c){i(f,e[t],e[t+1]),s&&p(f,s,c),a&&l(f,a,n),e[t]=r+f.x,e[t+1]=o+f.y}const{layout:d,rotate:x}=u,{getAngle:b}=e.PointHelper,k={x:-.5},w={connect:k,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},y={connect:k,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},_={connect:k,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]},g={connect:k,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]},A={offset:k,path:[..._.path]};x(A.path,180,{x:-1.5,y:0});const J={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},P={connect:{x:.5},path:[...J.path,1,0,0,26,0,0,1,0,360,0]},v={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]},m={path:[...v.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},D=e.DataHelper.clone(v),H=e.DataHelper.clone(m);x(D.path,45),x(H.path,45);const M={angle:w,"angle-side":y,arrow:g,triangle:_,"triangle-flip":A,circle:P,"circle-line":J,square:m,"square-line":v,diamond:H,"diamond-line":D,mark:{offset:k,path:[1,0,-2,2,0,2]}};function O(e,t,r,o,a,n){const{strokeCap:s,strokeJoin:c}=e.__,{offset:p,connect:i,path:l}="object"==typeof t?t:M[t];let f=i?i.x:0,u=p?p.x:0;const h=[...l];return"none"!==s&&(f-=.5),p&&("round"===c&&p.roundJoin?u+=p.roundJoin:"bevel"===c&&p.bevelJoin&&(u+=p.bevelJoin)),u&&d(h,u,0),d(h,o.x,o.y,a,a,b(r,o)),n.x=(f+u)*a,h}const{M:j,L:C,C:F,Q:R,Z:L,N:q,D:E,X:Q,G:S,F:U,O:G,P:I,U:N}=e.PathCommandMap,{copy:T,copyFrom:W,getDistancePoint:X}=e.PointHelper,Z={},z={},B={},K={},V={},Y={list:M,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:a,__pathForRender:n}=e.__;let s,c=0,p=n.length,i=0,l=r&&"none"!==r;for(;c<p;){switch(s=n[c],s){case j:case C:(i<2||c+6>=p)&&(W(V,n[c+1],n[c+2]),!i&&l&&T(z,V)),c+=3;break;case F:1!==i&&c+7!==p||$(n,K,V,c+3),c+=7;break;case R:1!==i&&c+5!==p||$(n,K,V,c+1),c+=5;break;case L:return;case q:c+=5;break;case E:c+=9;break;case Q:c+=6;break;case S:c+=9;break;case U:c+=5;break;case G:c+=7;break;case I:c+=4;break;case N:1!==i&&c+6!==p||$(n,K,V,c+1),c+=6}if(i++,1===i&&s!==j)return;if(2===i&&l&&T(B,s===C?V:K),c===p){const p=e.__.__pathForRender=t?[...n]:n;if(l&&(p.push(...O(e,r,B,z,a,Z)),Z.x&&(X(z,B,-Z.x,!0),p[1]=B.x,p[2]=B.y)),o&&"none"!==o&&(p.push(...O(e,o,K,V,a,Z)),Z.x)){let e;switch(X(V,K,-Z.x,!0),s){case C:e=c-3+1;break;case F:e=c-7+5;break;case R:e=c-5+3;break;case N:e=c-6+3}e&&ee(p,K,e)}}else T(K,V)}}};function $(e,t,r,o){W(t,e[o],e[o+1]),W(r,e[o+2],e[o+3])}function ee(e,t,r){e[r]=t.x,e[r+1]=t.y}Object.assign(e.PathArrow,Y),exports.ArrowData=r,exports.PathArrowModule=Y,exports.PathMatrixHelper=u;
1
+ "use strict";var e=require("@leafer-ui/draw");function t(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 r extends e.LineData{}exports.Arrow=class extends e.Line{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}},t([e.dataProcessor(r)],exports.Arrow.prototype,"__",void 0),t([e.strokeType("angle")],exports.Arrow.prototype,"endArrow",void 0),exports.Arrow=t([e.registerUI()],exports.Arrow);const{M:o,L:n,C:a,Q:s,O:c}=e.PathCommandMap,{rotate:p,copyFrom:i,scale:l}=e.PointHelper,f={},u={layout(e,t,r,p,i,l,f){let u,d,x=0,b=e.length;for(;x<b;)switch(u=e[x],u){case o:case n:h(e,x+1,t,r,p,i,l,f),x+=3;break;case a:for(d=1;d<6;d+=2)h(e,x+d,t,r,p,i,l,f);x+=7;break;case s:for(d=1;d<4;d+=2)h(e,x+d,t,r,p,i,l,f);x+=5;break;case c:e[x+1]+=t,e[x+2]+=r,p&&(e[x+3]*=p),l&&(e[x+4]+=l,e[x+5]+=l),x+=7}},rotate(e,t,r){u.layout(e,0,0,1,1,t,r)}};function h(e,t,r,o,n,a,s,c){i(f,e[t],e[t+1]),s&&p(f,s,c),n&&l(f,n,a),e[t]=r+f.x,e[t+1]=o+f.y}const{layout:d,rotate:x}=u,{getAngle:b}=e.PointHelper,w={x:-.5},_={connect:w,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},y={connect:w,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},k={connect:w,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]},A={connect:w,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]},g={offset:w,path:[...k.path]};x(g.path,180,{x:-1.5,y:0});const J={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},P={connect:{x:.5},path:[...J.path,1,0,0,26,0,0,1,0,360,0]},v={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]},m={path:[...v.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},D=e.DataHelper.clone(v),H=e.DataHelper.clone(m);x(D.path,45),x(H.path,45);const M={angle:_,"angle-side":y,arrow:A,triangle:k,"triangle-flip":g,circle:P,"circle-line":J,square:m,"square-line":v,diamond:H,"diamond-line":D,mark:{offset:w,path:[1,0,-2,2,0,2]}};function O(e,t,r,o,n,a){const{strokeCap:s,strokeJoin:c}=e.__,{offset:p,connect:i,path:l}="object"==typeof t?t:M[t];let f=i?i.x:0,u=p?p.x:0;const h=[...l];return"none"!==s&&(f-=.5),p&&("round"===c&&p.roundJoin?u+=p.roundJoin:"bevel"===c&&p.bevelJoin&&(u+=p.bevelJoin)),u&&d(h,u,0),d(h,o.x,o.y,n,n,b(r,o)),a.x=(f+u)*n,h}const{M:j,L:C,C:F,Q:L,Z:R,N:q,D:S,X:T,G:U,F:E,O:I,P:Q,U:G}=e.PathCommandMap,{copy:N,copyFrom:W,getDistancePoint:X}=e.PointHelper,Z={},z={},B={},K={},V={},Y={list:M,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:n,__pathForRender:a}=e.__;let s,c=0,p=a.length,i=0,l=r&&"none"!==r;for(;c<p;){switch(s=a[c],s){case j:case C:(i<2||c+6>=p)&&(W(V,a[c+1],a[c+2]),!i&&l&&N(z,V)),c+=3;break;case F:1!==i&&c+7!==p||$(a,K,V,c+3),c+=7;break;case L:1!==i&&c+5!==p||$(a,K,V,c+1),c+=5;break;case R:return;case q:c+=5;break;case S:c+=9;break;case T:c+=6;break;case U:c+=9;break;case E:c+=5;break;case I:c+=7;break;case Q:c+=4;break;case G:1!==i&&c+6!==p||$(a,K,V,c+1),c+=6}if(i++,1===i&&s!==j)return;if(2===i&&l&&N(B,s===C?V:K),c===p){const p=e.__.__pathForRender=t?[...a]:a;if(l&&(p.push(...O(e,r,B,z,n,Z)),Z.x&&(X(z,B,-Z.x,!0),p[1]=B.x,p[2]=B.y)),o&&"none"!==o&&(p.push(...O(e,o,K,V,n,Z)),Z.x)){let e;switch(X(V,K,-Z.x,!0),s){case C:e=c-3+1;break;case F:e=c-7+5;break;case L:e=c-5+3;break;case G:e=c-6+3}e&&ee(p,K,e)}}else N(K,V)}}};function $(e,t,r,o){W(t,e[o],e[o+1]),W(r,e[o+2],e[o+3])}function ee(e,t,r){e[r]=t.x,e[r+1]=t.y}function te(t){return e.decorateLeafAttr(t,(t=>e.attr({set(r){if(this.__setAttr(t,r)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,e.doStrokeType(this)}}})))}const re=e.UI.prototype;te("none")(re,"startArrow"),te("none")(re,"endArrow"),Object.assign(e.PathArrow,Y),exports.ArrowData=r,exports.PathArrowModule=Y,exports.PathMatrixHelper=u,exports.arrowType=te;
package/dist/arrow.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.arrow=function(e,t){"use strict";function r(e,t,r,o){var a,n=arguments.length,c=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(c=(n<3?a(c):n>3?a(t,r,c):a(t,r))||c);return n>3&&c&&Object.defineProperty(t,r,c),c}"function"==typeof SuppressedError&&SuppressedError;class o extends t.LineData{}e.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}},r([t.dataProcessor(o)],e.Arrow.prototype,"__",void 0),r([t.strokeType("angle")],e.Arrow.prototype,"endArrow",void 0),e.Arrow=r([t.registerUI()],e.Arrow);const{M:a,L:n,C:c,Q:s,O:i}=t.PathCommandMap,{rotate:p,copyFrom:l,scale:f}=t.PointHelper,h={},u={layout(e,t,r,o,p,l,f){let h,u,b=0,x=e.length;for(;b<x;)switch(h=e[b],h){case a:case n:d(e,b+1,t,r,o,p,l,f),b+=3;break;case c:for(u=1;u<6;u+=2)d(e,b+u,t,r,o,p,l,f);b+=7;break;case s:for(u=1;u<4;u+=2)d(e,b+u,t,r,o,p,l,f);b+=5;break;case i:e[b+1]+=t,e[b+2]+=r,o&&(e[b+3]*=o),l&&(e[b+4]+=l,e[b+5]+=l),b+=7}},rotate(e,t,r){u.layout(e,0,0,1,1,t,r)}};function d(e,t,r,o,a,n,c,s){l(h,e[t],e[t+1]),c&&p(h,c,s),a&&f(h,a,n),e[t]=r+h.x,e[t+1]=o+h.y}const{layout:b,rotate:x}=u,{getAngle:k}=t.PointHelper,w={x:-.5},y={connect:w,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},_={connect:w,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},g={connect:w,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]},A={connect:w,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]},J={offset:w,path:[...g.path]};x(J.path,180,{x:-1.5,y:0});const P={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},v={connect:{x:.5},path:[...P.path,1,0,0,26,0,0,1,0,360,0]},m={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]},L={path:[...m.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},D=t.DataHelper.clone(m),H=t.DataHelper.clone(L);x(D.path,45),x(H.path,45);const M={angle:y,"angle-side":_,arrow:A,triangle:g,"triangle-flip":J,circle:v,"circle-line":P,square:L,"square-line":m,diamond:H,"diamond-line":D,mark:{offset:w,path:[1,0,-2,2,0,2]}};function O(e,t,r,o,a,n){const{strokeCap:c,strokeJoin:s}=e.__,{offset:i,connect:p,path:l}="object"==typeof t?t:M[t];let f=p?p.x:0,h=i?i.x:0;const u=[...l];return"none"!==c&&(f-=.5),i&&("round"===s&&i.roundJoin?h+=i.roundJoin:"bevel"===s&&i.bevelJoin&&(h+=i.bevelJoin)),h&&b(u,h,0),b(u,o.x,o.y,a,a,k(r,o)),n.x=(f+h)*a,u}const{M:j,L:C,C:F,Q:I,Z:R,N:N,D:U,X:q,G:E,F:Q,O:S,P:G,U:T}=t.PathCommandMap,{copy:W,copyFrom:X,getDistancePoint:Z}=t.PointHelper,z={},B={},K={},V={},Y={},$={list:M,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:a,__pathForRender:n}=e.__;let c,s=0,i=n.length,p=0,l=r&&"none"!==r;for(;s<i;){switch(c=n[s],c){case j:case C:(p<2||s+6>=i)&&(X(Y,n[s+1],n[s+2]),!p&&l&&W(B,Y)),s+=3;break;case F:1!==p&&s+7!==i||ee(n,V,Y,s+3),s+=7;break;case I:1!==p&&s+5!==i||ee(n,V,Y,s+1),s+=5;break;case R:return;case N:s+=5;break;case U:s+=9;break;case q:s+=6;break;case E:s+=9;break;case Q:s+=5;break;case S:s+=7;break;case G:s+=4;break;case T:1!==p&&s+6!==i||ee(n,V,Y,s+1),s+=6}if(p++,1===p&&c!==j)return;if(2===p&&l&&W(K,c===C?Y:V),s===i){const i=e.__.__pathForRender=t?[...n]:n;if(l&&(i.push(...O(e,r,K,B,a,z)),z.x&&(Z(B,K,-z.x,!0),i[1]=K.x,i[2]=K.y)),o&&"none"!==o&&(i.push(...O(e,o,V,Y,a,z)),z.x)){let e;switch(Z(Y,V,-z.x,!0),c){case C:e=s-3+1;break;case F:e=s-7+5;break;case I:e=s-5+3;break;case T:e=s-6+3}e&&te(i,V,e)}}else W(V,Y)}}};function ee(e,t,r,o){X(t,e[o],e[o+1]),X(r,e[o+2],e[o+3])}function te(e,t,r){e[r]=t.x,e[r+1]=t.y}return Object.assign(t.PathArrow,$),e.ArrowData=o,e.PathArrowModule=$,e.PathMatrixHelper=u,e}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.arrow=function(e,t){"use strict";function r(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 o extends t.LineData{}e.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}},r([t.dataProcessor(o)],e.Arrow.prototype,"__",void 0),r([t.strokeType("angle")],e.Arrow.prototype,"endArrow",void 0),e.Arrow=r([t.registerUI()],e.Arrow);const{M:n,L:a,C:s,Q:c,O:i}=t.PathCommandMap,{rotate:p,copyFrom:l,scale:f}=t.PointHelper,h={},u={layout(e,t,r,o,p,l,f){let h,u,b=0,w=e.length;for(;b<w;)switch(h=e[b],h){case n:case a:d(e,b+1,t,r,o,p,l,f),b+=3;break;case s:for(u=1;u<6;u+=2)d(e,b+u,t,r,o,p,l,f);b+=7;break;case c:for(u=1;u<4;u+=2)d(e,b+u,t,r,o,p,l,f);b+=5;break;case i:e[b+1]+=t,e[b+2]+=r,o&&(e[b+3]*=o),l&&(e[b+4]+=l,e[b+5]+=l),b+=7}},rotate(e,t,r){u.layout(e,0,0,1,1,t,r)}};function d(e,t,r,o,n,a,s,c){l(h,e[t],e[t+1]),s&&p(h,s,c),n&&f(h,n,a),e[t]=r+h.x,e[t+1]=o+h.y}const{layout:b,rotate:w}=u,{getAngle:_}=t.PointHelper,x={x:-.5},y={connect:x,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},k={connect:x,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},A={connect:x,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]},g={connect:x,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]},J={offset:x,path:[...A.path]};w(J.path,180,{x:-1.5,y:0});const P={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},v={connect:{x:.5},path:[...P.path,1,0,0,26,0,0,1,0,360,0]},m={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]},L={path:[...m.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},D=t.DataHelper.clone(m),H=t.DataHelper.clone(L);w(D.path,45),w(H.path,45);const I={angle:y,"angle-side":k,arrow:g,triangle:A,"triangle-flip":J,circle:v,"circle-line":P,square:L,"square-line":m,diamond:H,"diamond-line":D,mark:{offset:x,path:[1,0,-2,2,0,2]}};function M(e,t,r,o,n,a){const{strokeCap:s,strokeJoin:c}=e.__,{offset:i,connect:p,path:l}="object"==typeof t?t:I[t];let f=p?p.x:0,h=i?i.x:0;const u=[...l];return"none"!==s&&(f-=.5),i&&("round"===c&&i.roundJoin?h+=i.roundJoin:"bevel"===c&&i.bevelJoin&&(h+=i.bevelJoin)),h&&b(u,h,0),b(u,o.x,o.y,n,n,_(r,o)),a.x=(f+h)*n,u}const{M:O,L:j,C:C,Q:F,Z:R,N:N,D:U,X:S,G:T,F:q,O:E,P:Q,U:G}=t.PathCommandMap,{copy:W,copyFrom:X,getDistancePoint:Z}=t.PointHelper,z={},B={},K={},V={},Y={},$={list:I,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:n,__pathForRender:a}=e.__;let s,c=0,i=a.length,p=0,l=r&&"none"!==r;for(;c<i;){switch(s=a[c],s){case O:case j:(p<2||c+6>=i)&&(X(Y,a[c+1],a[c+2]),!p&&l&&W(B,Y)),c+=3;break;case C:1!==p&&c+7!==i||ee(a,V,Y,c+3),c+=7;break;case F:1!==p&&c+5!==i||ee(a,V,Y,c+1),c+=5;break;case R:return;case N:c+=5;break;case U:c+=9;break;case S:c+=6;break;case T:c+=9;break;case q:c+=5;break;case E:c+=7;break;case Q:c+=4;break;case G:1!==p&&c+6!==i||ee(a,V,Y,c+1),c+=6}if(p++,1===p&&s!==O)return;if(2===p&&l&&W(K,s===j?Y:V),c===i){const i=e.__.__pathForRender=t?[...a]:a;if(l&&(i.push(...M(e,r,K,B,n,z)),z.x&&(Z(B,K,-z.x,!0),i[1]=K.x,i[2]=K.y)),o&&"none"!==o&&(i.push(...M(e,o,V,Y,n,z)),z.x)){let e;switch(Z(Y,V,-z.x,!0),s){case j:e=c-3+1;break;case C:e=c-7+5;break;case F:e=c-5+3;break;case G:e=c-6+3}e&&te(i,V,e)}}else W(V,Y)}}};function ee(e,t,r,o){X(t,e[o],e[o+1]),X(r,e[o+2],e[o+3])}function te(e,t,r){e[r]=t.x,e[r+1]=t.y}function re(e){return t.decorateLeafAttr(e,(e=>t.attr({set(r){if(this.__setAttr(e,r)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,t.doStrokeType(this)}}})))}const oe=t.UI.prototype;return re("none")(oe,"startArrow"),re("none")(oe,"endArrow"),Object.assign(t.PathArrow,$),e.ArrowData=o,e.PathArrowModule=$,e.PathMatrixHelper=u,e.arrowType=re,e}({},LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/arrow",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "@leafer-in/arrow",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@leafer-ui/draw": "1.0.1",
38
- "@leafer-ui/interface": "1.0.1",
39
- "@leafer-in/interface": "1.0.1"
37
+ "@leafer-ui/draw": "^1.0.3",
38
+ "@leafer-ui/interface": "^1.0.3",
39
+ "@leafer-in/interface": "^1.0.3"
40
40
  }
41
41
  }
@@ -0,0 +1,14 @@
1
+ import { IValue, IUI } from '@leafer-ui/interface'
2
+ import { decorateLeafAttr, attr, doStrokeType } from '@leafer-ui/draw'
3
+
4
+ export function arrowType(defaultValue?: IValue) {
5
+ return decorateLeafAttr(defaultValue, (key: string) => attr({
6
+ set(value: IValue) {
7
+ if (this.__setAttr(key, value)) {
8
+ const data = (this as IUI).__
9
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none'
10
+ doStrokeType(this)
11
+ }
12
+ }
13
+ }))
14
+ }
package/src/index.ts CHANGED
@@ -2,9 +2,17 @@ export { Arrow } from './Arrow'
2
2
  export { ArrowData } from './data/ArrowData'
3
3
  export { PathArrowModule } from './PathArrowModule'
4
4
  export { PathMatrixHelper } from './PathMatrixHelper'
5
+ export { arrowType } from './decorator'
5
6
 
6
- import { PathArrow } from '@leafer-ui/draw'
7
+ import { PathArrow, UI } from '@leafer-ui/draw'
7
8
  import { PathArrowModule } from './PathArrowModule'
9
+ import { arrowType } from './decorator'
8
10
 
9
11
 
12
+ const ui = UI.prototype
13
+
14
+ // addAttr
15
+ arrowType('none')(ui, 'startArrow')
16
+ arrowType('none')(ui, 'endArrow')
17
+
10
18
  Object.assign(PathArrow, PathArrowModule)
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { IArrow, IArrowData, IArrowType, IArrowInputData, IPathArrowModule, IPathCommandData, IPointData } from '@leafer-ui/interface';
1
+ import * as _leafer_ui_interface from '@leafer-ui/interface';
2
+ import { IArrow, IArrowData, IArrowType, IArrowInputData, IPathArrowModule, IPathCommandData, IPointData, IValue } from '@leafer-ui/interface';
2
3
  import { Line, LineData } from '@leafer-ui/draw';
3
4
 
4
5
  declare class Arrow extends Line implements IArrow {
@@ -18,4 +19,6 @@ declare const PathMatrixHelper: {
18
19
  rotate(data: IPathCommandData, rotation?: number, center?: IPointData): void;
19
20
  };
20
21
 
21
- export { Arrow, ArrowData, PathArrowModule, PathMatrixHelper };
22
+ declare function arrowType(defaultValue?: IValue): (target: _leafer_ui_interface.ILeaf, key: string) => void;
23
+
24
+ export { Arrow, ArrowData, PathArrowModule, PathMatrixHelper, arrowType };