@leafer-ui/display 1.4.2 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.4.2",
26
- "@leafer-ui/data": "1.4.2",
27
- "@leafer-ui/display-module": "1.4.2",
28
- "@leafer-ui/decorator": "1.4.2",
29
- "@leafer-ui/external": "1.4.2"
25
+ "@leafer/core": "1.5.1",
26
+ "@leafer-ui/data": "1.5.1",
27
+ "@leafer-ui/display-module": "1.5.1",
28
+ "@leafer-ui/decorator": "1.5.1",
29
+ "@leafer-ui/external": "1.5.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.4.2",
33
- "@leafer-ui/interface": "1.4.2"
32
+ "@leafer/interface": "1.5.1",
33
+ "@leafer-ui/interface": "1.5.1"
34
34
  }
35
35
  }
package/src/Leafer.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber, IZoomType, IFourNumber, IBounds, IClientPointData, ITransition } from '@leafer/interface'
2
- import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, Resource, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList, Plugin } from '@leafer/core'
2
+ import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, Resource, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList, Plugin, getBoundsData } from '@leafer/core'
3
3
 
4
4
  import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IApp, IEditorBase } from '@leafer-ui/interface'
5
5
  import { LeaferData } from '@leafer-ui/data'
@@ -72,7 +72,7 @@ export class Leafer extends Group implements ILeafer {
72
72
 
73
73
  public get FPS(): number { return this.renderer ? this.renderer.FPS : 60 }
74
74
  public get cursorPoint(): IPointData { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 } }
75
- public get clientBounds(): IBoundsData { return this.canvas && this.canvas.getClientBounds() }
75
+ public get clientBounds(): IBoundsData { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData() }
76
76
  public leafs = 0
77
77
 
78
78
  public __eventIds: IEventListenerId[] = []
@@ -402,6 +402,11 @@ export class Leafer extends Group implements ILeafer {
402
402
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient))
403
403
  }
404
404
 
405
+ public getClientPointByWorld(worldPoint: IPointData): IPointData {
406
+ const { x, y } = this.clientBounds
407
+ return { x: x + worldPoint.x, y: y + worldPoint.y }
408
+ }
409
+
405
410
  public updateClientBounds(): void {
406
411
  this.canvas && this.canvas.updateClientBounds()
407
412
  }
package/src/Pen.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PathCreator, dataProcessor, defineKey, registerUI, useModule } from '@leafer/core'
2
2
 
3
- import { IPenData, IPenInputData, IPathInputData, IPathCommandData, IPath, IPen } from '@leafer-ui/interface'
3
+ import { IPenData, IPenInputData, IPathInputData, IPathCommandData, IPath, IPen, IPointData } from '@leafer-ui/interface'
4
4
  import { PenData } from '@leafer-ui/data'
5
5
 
6
6
  import { Group } from './Group'
@@ -69,7 +69,7 @@ export class Pen extends Group implements IPen {
69
69
 
70
70
  public drawArc(_x: number, _y: number, _radius: number, _startAngle?: number, _endAngle?: number, _anticlockwise?: boolean): Pen { return this }
71
71
 
72
- public drawPoints(_points: number[], _curve?: boolean | number, _close?: boolean): Pen { return this }
72
+ public drawPoints(_points: number[] | IPointData[], _curve?: boolean | number, _close?: boolean): Pen { return this }
73
73
 
74
74
  public clearPath(): Pen { return this } // = beginPath()
75
75
 
package/src/UI.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData, IPathCommandObject, ITransition, IFilter } from '@leafer/interface'
2
- import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, Plugin } from '@leafer/core'
2
+ import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, Plugin, DataHelper } from '@leafer/core'
3
3
 
4
4
  import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, IAnimateType, IStateStyle } from '@leafer-ui/interface'
5
5
  import { effectType, zoomLayerType } from '@leafer-ui/decorator'
@@ -365,11 +365,11 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
365
365
 
366
366
  // @leafer-in/editor rewrite
367
367
 
368
- public get editConfig(): IEditorConfig { return undefined }
368
+ public editConfig: IEditorConfig
369
369
 
370
- public get editOuter(): string { return '' }
370
+ public editOuter: string
371
371
 
372
- public get editInner(): string { return '' }
372
+ public editInner: string
373
373
 
374
374
 
375
375
  constructor(data?: IUIInputData) {
@@ -484,8 +484,12 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
484
484
  return Plugin.need('export')
485
485
  }
486
486
 
487
+ public syncExport(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): IExportResult {
488
+ return Plugin.need('export')
489
+ }
490
+
487
491
  public clone(data?: IUIInputData): IUI {
488
- const json = this.toJSON()
492
+ const json = DataHelper.clone(this.toJSON())
489
493
  if (data) Object.assign(json, data)
490
494
  return UI.one(json)
491
495
  }
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathCommandObject, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, IFilter, ITransition, IUnitData, IObject, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IZoomType, IClientPointData, IRenderOptions, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
2
  import { Leaf, LeafList } from '@leafer/core';
3
- import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IAnimate, IEditorConfig, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
3
+ import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IAnimate, IEditorConfig, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData, IPointData as IPointData$1 } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UI extends Leaf implements IUI {
6
6
  __: IUIData;
@@ -111,9 +111,9 @@ declare class UI extends Leaf implements IUI {
111
111
  get scale(): INumber | IPointData;
112
112
  __animate?: IAnimate;
113
113
  get pen(): IPathCreator;
114
- get editConfig(): IEditorConfig;
115
- get editOuter(): string;
116
- get editInner(): string;
114
+ editConfig: IEditorConfig;
115
+ editOuter: string;
116
+ editInner: string;
117
117
  constructor(data?: IUIInputData);
118
118
  reset(_data?: IUIInputData): void;
119
119
  set(data: IUIInputData, transition?: ITransition | 'temp'): void;
@@ -135,6 +135,7 @@ declare class UI extends Leaf implements IUI {
135
135
  animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
136
136
  killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void;
137
137
  export(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): Promise<IExportResult>;
138
+ syncExport(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): IExportResult;
138
139
  clone(data?: IUIInputData): IUI;
139
140
  static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
140
141
  static registerUI(): void;
@@ -251,6 +252,7 @@ declare class Leafer extends Group implements ILeafer {
251
252
  getValidScale(changeScale: number): number;
252
253
  getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
253
254
  getPagePointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
255
+ getClientPointByWorld(worldPoint: IPointData): IPointData;
254
256
  updateClientBounds(): void;
255
257
  receiveEvent(_event: any): void;
256
258
  protected emitLeafer(type: string): void;
@@ -445,7 +447,7 @@ declare class Pen extends Group implements IPen {
445
447
  arcTo(_x1: number, _y1: number, _x2: number, _y2: number, _radius: number): Pen;
446
448
  drawEllipse(_x: number, _y: number, _radiusX: number, _radiusY: number, _rotation?: number, _startAngle?: number, _endAngle?: number, _anticlockwise?: boolean): Pen;
447
449
  drawArc(_x: number, _y: number, _radius: number, _startAngle?: number, _endAngle?: number, _anticlockwise?: boolean): Pen;
448
- drawPoints(_points: number[], _curve?: boolean | number, _close?: boolean): Pen;
450
+ drawPoints(_points: number[] | IPointData$1[], _curve?: boolean | number, _close?: boolean): Pen;
449
451
  clearPath(): Pen;
450
452
  paint(): void;
451
453
  }