@leafer-ui/display 1.0.0-rc.2 → 1.0.0-rc.21

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/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { UI } from './UI'
2
2
 
3
+ export { Leafer } from './Leafer'
3
4
  export { Group } from './Group'
4
5
  export { Box } from './Box'
5
6
  export { Frame } from './Frame'
package/types/index.d.ts CHANGED
@@ -1,83 +1,119 @@
1
- import { __String, __Number, __Boolean, IAround, IHitType, ICursorType, IPointData, IPathCommandData, IPathString, ILeaferCanvas, IPathDrawer, IExportFileType, IRenderOptions, ILeaferImage, ICanvasContext2D, IWindingRule } from '@leafer/interface';
2
- import { Leaf } from '@leafer/core';
3
- import { IUI, IUIData, IGroup, IBlendMode, IPaint, IPaintString, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IUIBaseInputData, IUIInputData, IExportOptions, IExportResult, IGroupData, IGroupInputData, 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, IFontWeight, ITextCase, ITextDecoration, IUnitData, ITextAlign, IVerticalAlign, ITextDrawData, ITextInputData, IPath, IPathData, IPathString as IPathString$1, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
1
+ import { IString, INumber, IBoolean, IMaskType, IAround, IHitType, ICursorType, IPathCommandData, IPathString, IWindingRule, IPointData, IPathCreator, IValue, ILeaferCanvas, IPathDrawer, IExportFileType, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IBoundsData, IResizeEvent, IObject, IZoomType, IFourNumber, IRenderOptions, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
+ import { Leaf, LeafList } from '@leafer/core';
3
+ import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IEditSize, IEditorConfig, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IFindUIMethod, IExportOptions, IExportResult, IGroupData, IGroupInputData, 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, IUnitData, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UI extends Leaf implements IUI {
6
6
  __: IUIData;
7
+ proxyData: IUIInputData;
8
+ __proxyData?: IUIInputData;
9
+ get app(): ILeafer;
10
+ leafer?: ILeafer;
7
11
  parent?: IGroup;
8
- id: __String;
9
- name: __String;
10
- className: __String;
12
+ zoomLayer: IGroup;
13
+ get isFrame(): boolean;
14
+ children?: IUI[];
15
+ id: IString;
16
+ name: IString;
17
+ className: IString;
11
18
  blendMode: IBlendMode;
12
- opacity: __Number;
13
- visible: __Boolean;
14
- isMask: __Boolean;
15
- isEraser?: __Boolean;
16
- zIndex: __Number;
17
- locked: __Boolean;
18
- x: __Number;
19
- y: __Number;
20
- width: __Number;
21
- height: __Number;
22
- scaleX: __Number;
23
- scaleY: __Number;
24
- rotation: __Number;
25
- skewX: __Number;
26
- skewY: __Number;
19
+ opacity: INumber;
20
+ visible: IBoolean;
21
+ selected: IBoolean;
22
+ disabled: IBoolean;
23
+ locked: IBoolean;
24
+ zIndex: INumber;
25
+ mask: IBoolean;
26
+ maskType: IMaskType;
27
+ eraser: IBoolean;
28
+ x: INumber;
29
+ y: INumber;
30
+ width: INumber;
31
+ height: INumber;
32
+ scaleX: INumber;
33
+ scaleY: INumber;
34
+ rotation: INumber;
35
+ skewX: INumber;
36
+ skewY: INumber;
27
37
  around: IAround;
28
- draggable: __Boolean;
29
- hittable: __Boolean;
38
+ draggable: IBoolean;
39
+ editable: IBoolean;
40
+ editSize?: IEditSize;
41
+ editorStyle: IEditorConfig;
42
+ hittable: IBoolean;
30
43
  hitFill: IHitType;
31
44
  hitStroke: IHitType;
32
- hitChildren: __Boolean;
33
- hitSelf: __Boolean;
34
- hitRadius: __Number;
45
+ hitBox: IBoolean;
46
+ hitChildren: IBoolean;
47
+ hitSelf: IBoolean;
48
+ hitRadius: INumber;
35
49
  cursor: ICursorType | ICursorType[];
36
- fill: IPaint | IPaint[] | IPaintString;
37
- stroke: IPaint | IPaint[] | IPaintString;
50
+ fill: IFill;
51
+ stroke: IStroke;
38
52
  strokeAlign: IStrokeAlign;
39
- strokeWidth: number | number[] | IStrokeWidthString;
53
+ strokeWidth: INumber | INumber[] | IStrokeWidthString;
54
+ strokeWidthFixed: IBoolean;
40
55
  strokeCap: IStrokeCap;
41
56
  strokeJoin: IStrokeJoin;
42
- dashPattern: __Number[] | IDashPatternString;
43
- dashOffset: __Number;
44
- miterLimit: __Number;
57
+ dashPattern: INumber[] | IDashPatternString;
58
+ dashOffset: INumber;
59
+ miterLimit: INumber;
60
+ lazy: IBoolean;
61
+ pixelRatio: INumber;
62
+ path: IPathCommandData | IPathString;
63
+ windingRule: IWindingRule;
64
+ closed: boolean;
65
+ startArrow: IArrowType;
66
+ endArrow: IArrowType;
45
67
  cornerRadius: number | number[] | ICornerRadiusString;
46
- cornerSmoothing: __Number;
68
+ cornerSmoothing: INumber;
47
69
  shadow: IShadowEffect | IShadowEffect[] | IShadowString;
48
70
  innerShadow: IShadowEffect | IShadowEffect[] | IShadowString;
49
- blur: __Number | IBlurEffect;
50
- backgroundBlur: __Number | IBlurEffect;
51
- grayscale: __Number | IGrayscaleEffect;
52
- set scale(value: __Number | IPointData);
53
- get scale(): __Number | IPointData;
54
- constructor(data?: IUIBaseInputData);
71
+ blur: INumber | IBlurEffect;
72
+ backgroundBlur: INumber | IBlurEffect;
73
+ grayscale: INumber | IGrayscaleEffect;
74
+ normalStyle: IUIInputData;
75
+ hoverStyle: IUIInputData;
76
+ pressStyle: IUIInputData;
77
+ focusStyle: IUIInputData;
78
+ selectedStyle: IUIInputData;
79
+ disabledStyle: IUIInputData;
80
+ set scale(value: INumber | IPointData);
81
+ get scale(): INumber | IPointData;
82
+ get pen(): IPathCreator;
83
+ constructor(data?: IUIInputData);
84
+ reset(_data?: IUIInputData): void;
55
85
  set(data: IUIInputData): void;
56
- get(): IUIInputData;
57
- getPath(curve?: boolean): IPathCommandData;
58
- getPathString(curve?: boolean): IPathString;
86
+ get(name?: string | string[] | IUIInputData): IUIInputData | IValue;
87
+ createProxyData(): IUIInputData;
88
+ find(_condition: number | string | IFindUIMethod, _options?: any): IUI[];
89
+ findOne(_condition: number | string | IFindUIMethod, _options?: any): IUI;
90
+ getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
91
+ getPathString(curve?: boolean, pathForRender?: boolean): IPathString;
59
92
  __onUpdateSize(): void;
60
93
  __updateRenderPath(): void;
61
94
  __drawRenderPath(canvas: ILeaferCanvas): void;
62
95
  __drawPath(canvas: ILeaferCanvas): void;
63
- __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void;
96
+ __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
97
+ __drawPathByBox(drawer: IPathDrawer): void;
64
98
  export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
65
99
  clone(): IUI;
66
100
  static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
101
+ static registerUI(): void;
102
+ static registerData(data: IUIData): void;
67
103
  destroy(): void;
68
104
  }
69
105
 
70
106
  declare class Group extends UI implements IGroup {
71
107
  get __tag(): string;
108
+ get isBranch(): boolean;
72
109
  __: IGroupData;
73
110
  children: IUI[];
74
- get resizeable(): boolean;
75
- set mask(child: IUI);
76
- get mask(): IUI;
77
111
  constructor(data?: IGroupInputData);
112
+ reset(data?: IGroupInputData): void;
78
113
  __setBranch(): void;
79
114
  set(data: IUIInputData): void;
80
115
  toJSON(): IUIInputData;
116
+ pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult;
81
117
  addAt(child: IUI, index: number): void;
82
118
  addAfter(child: IUI, after: IUI): void;
83
119
  addBefore(child: UI, before: IUI): void;
@@ -85,24 +121,113 @@ declare class Group extends UI implements IGroup {
85
121
  addMany(..._children: IUI[]): void;
86
122
  remove(_child?: IUI, _destroy?: boolean): void;
87
123
  removeAll(_destroy?: boolean): void;
124
+ clear(): void;
125
+ }
126
+
127
+ declare class Leafer extends Group implements ILeafer {
128
+ static get version(): string;
129
+ static list: LeafList;
130
+ get __tag(): string;
131
+ __: ILeaferData;
132
+ pixelRatio: INumber;
133
+ get isApp(): boolean;
134
+ get app(): ILeafer;
135
+ get isLeafer(): boolean;
136
+ parent?: IApp;
137
+ running: boolean;
138
+ created: boolean;
139
+ ready: boolean;
140
+ viewReady: boolean;
141
+ viewCompleted: boolean;
142
+ get imageReady(): boolean;
143
+ get layoutLocked(): boolean;
144
+ transforming: boolean;
145
+ view: unknown;
146
+ canvas: ILeaferCanvas;
147
+ renderer: IRenderer;
148
+ watcher: IWatcher;
149
+ layouter: ILayouter;
150
+ selector?: ISelector;
151
+ interaction?: IInteraction;
152
+ canvasManager: ICanvasManager;
153
+ hitCanvasManager?: IHitCanvasManager;
154
+ editor: IEditorBase;
155
+ userConfig: ILeaferConfig;
156
+ config: ILeaferConfig;
157
+ autoLayout?: IAutoBounds;
158
+ lazyBounds: IBounds;
159
+ get FPS(): number;
160
+ get cursorPoint(): IPointData;
161
+ leafs: number;
162
+ __eventIds: IEventListenerId[];
163
+ protected __startTimer: ITimer;
164
+ protected __controllers: IControl[];
165
+ protected __initWait: IFunction[];
166
+ protected __readyWait: IFunction[];
167
+ protected __viewReadyWait: IFunction[];
168
+ protected __viewCompletedWait: IFunction[];
169
+ __nextRenderWait: IFunction[];
170
+ constructor(userConfig?: ILeaferConfig, data?: ILeaferInputData);
171
+ init(userConfig?: ILeaferConfig, parentApp?: IApp): void;
172
+ onInit(): void;
173
+ initType(_type: ILeaferType): void;
174
+ set(data: IUIInputData): void;
175
+ start(): void;
176
+ stop(): void;
177
+ unlockLayout(): void;
178
+ lockLayout(): void;
179
+ resize(size: IScreenSizeData): void;
180
+ forceFullRender(): void;
181
+ forceRender(bounds?: IBoundsData): void;
182
+ updateCursor(cursor?: ICursorType): void;
183
+ updateLazyBounds(): void;
184
+ protected __doResize(size: IScreenSizeData): void;
185
+ protected __onResize(event: IResizeEvent): void;
186
+ protected __setApp(): void;
187
+ protected __bindApp(app: IApp): void;
188
+ __setLeafer(leafer: ILeafer): void;
189
+ protected __checkAutoLayout(config: ILeaferConfig): void;
190
+ __setAttr(attrName: string, newValue: IValue): boolean;
191
+ __getAttr(attrName: string): IValue;
192
+ protected __changeCanvasSize(attrName: string, newValue: number): void;
193
+ protected __changeFill(newValue: string): void;
194
+ protected __onCreated(): void;
195
+ protected __onReady(): void;
196
+ protected __onViewReady(): void;
197
+ protected __onNextRender(): void;
198
+ protected __checkViewCompleted(emit?: boolean): void;
199
+ protected __onWatchData(): void;
200
+ waitInit(item: IFunction, bind?: IObject): void;
201
+ waitReady(item: IFunction, bind?: IObject): void;
202
+ waitViewReady(item: IFunction, bind?: IObject): void;
203
+ waitViewCompleted(item: IFunction, bind?: IObject): void;
204
+ nextRender(item: IFunction, bind?: IObject, off?: 'off'): void;
205
+ zoom(_zoomType: IZoomType, _padding?: IFourNumber, _fixedScale?: boolean): IBoundsData;
206
+ getValidMove(moveX: number, moveY: number): IPointData;
207
+ getValidScale(changeScale: number): number;
208
+ protected __checkUpdateLayout(): void;
209
+ protected emitLeafer(type: string): void;
210
+ protected __listenEvents(): void;
211
+ protected __removeListenEvents(): void;
212
+ destroy(sync?: boolean): void;
88
213
  }
89
214
 
90
215
  declare class Box extends Group implements IBox {
91
216
  get __tag(): string;
217
+ get isBranchLeaf(): boolean;
92
218
  __: IBoxData;
93
219
  overflow: IOverflow;
94
- get resizeable(): boolean;
95
220
  constructor(data?: IBoxInputData);
96
221
  __updateStrokeSpread(): number;
97
222
  __updateRectRenderSpread(): number;
98
223
  __updateRenderSpread(): number;
224
+ __updateRectBoxBounds(): void;
99
225
  __updateBoxBounds(): void;
100
226
  __updateStrokeBounds(): void;
101
227
  __updateRenderBounds(): void;
102
228
  __updateRectRenderBounds(): void;
103
229
  __updateRectChange(): void;
104
230
  __updateChange(): void;
105
- __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void;
106
231
  __renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
107
232
  __renderGroup(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
108
233
  __render(canvas: ILeaferCanvas, options: IRenderOptions): void;
@@ -111,7 +236,9 @@ declare class Box extends Group implements IBox {
111
236
 
112
237
  declare class Frame extends Box implements IFrame {
113
238
  get __tag(): string;
239
+ get isFrame(): boolean;
114
240
  __: IFrameData;
241
+ fill: IFill;
115
242
  overflow: IOverflow;
116
243
  constructor(data?: IFrameInputData);
117
244
  }
@@ -120,15 +247,14 @@ declare class Rect extends UI implements IRect {
120
247
  get __tag(): string;
121
248
  __: IRectData;
122
249
  constructor(data?: IRectInputData);
123
- __drawPathByData(drawer: IPathDrawer, _data: IPathCommandData): void;
124
250
  }
125
251
 
126
252
  declare class Ellipse extends UI implements IEllipse {
127
253
  get __tag(): string;
128
254
  __: IEllipseData;
129
- innerRadius: __Number;
130
- startAngle: __Number;
131
- endAngle: __Number;
255
+ innerRadius: INumber;
256
+ startAngle: INumber;
257
+ endAngle: INumber;
132
258
  constructor(data?: IEllipseInputData);
133
259
  __updatePath(): void;
134
260
  }
@@ -136,10 +262,9 @@ declare class Ellipse extends UI implements IEllipse {
136
262
  declare class Polygon extends UI implements IPolygon {
137
263
  get __tag(): string;
138
264
  __: IPolygonData;
139
- sides: number;
265
+ sides: INumber;
140
266
  points: number[];
141
267
  curve: boolean | number;
142
- get resizeable(): boolean;
143
268
  constructor(data?: IPolygonInputData);
144
269
  __updatePath(): void;
145
270
  __updateRenderPath(): void;
@@ -149,8 +274,8 @@ declare class Polygon extends UI implements IPolygon {
149
274
  declare class Star extends UI implements IStar {
150
275
  get __tag(): string;
151
276
  __: IStarData;
152
- corners: __Number;
153
- innerRadius: __Number;
277
+ corners: INumber;
278
+ innerRadius: INumber;
154
279
  constructor(data?: IStarInputData);
155
280
  __updatePath(): void;
156
281
  }
@@ -159,10 +284,10 @@ declare class Line extends UI implements ILine {
159
284
  get __tag(): string;
160
285
  __: ILineData;
161
286
  strokeAlign: IStrokeAlign;
162
- height: __Number;
287
+ height: INumber;
163
288
  points: number[];
164
289
  curve: boolean | number;
165
- get resizeable(): boolean;
290
+ closed: boolean;
166
291
  get toPoint(): IPointData;
167
292
  set toPoint(value: IPointData);
168
293
  constructor(data?: ILineInputData);
@@ -174,21 +299,21 @@ declare class Line extends UI implements ILine {
174
299
  declare class Image extends Rect implements IImage {
175
300
  get __tag(): string;
176
301
  __: IImageData;
177
- url: __String;
302
+ url: IString;
178
303
  get ready(): boolean;
179
304
  image: ILeaferImage;
180
305
  constructor(data?: IImageInputData);
181
- __updateBoxBounds(): void;
182
306
  destroy(): void;
183
307
  }
184
308
 
185
309
  declare class Canvas extends Rect implements ICanvas {
186
310
  get __tag(): string;
187
311
  __: ICanvasData;
188
- width: __Number;
189
- height: __Number;
190
- pixelRatio: __Number;
312
+ width: INumber;
313
+ height: INumber;
314
+ pixelRatio: INumber;
191
315
  smooth: boolean;
316
+ contextSettings: ICanvasContext2DSettings;
192
317
  hitFill: IHitType;
193
318
  canvas: ILeaferCanvas;
194
319
  context: ICanvasContext2D;
@@ -203,23 +328,26 @@ declare class Canvas extends Rect implements ICanvas {
203
328
  declare class Text extends UI implements IText {
204
329
  get __tag(): string;
205
330
  __: ITextData;
206
- width: __Number;
207
- height: __Number;
331
+ width: INumber;
332
+ height: INumber;
208
333
  padding: number | number[];
334
+ fill: IFill;
209
335
  strokeAlign: IStrokeAlign;
210
- text: __String;
211
- fontFamily: __String;
212
- fontSize: __Number;
336
+ hitFill: IHitType$1;
337
+ text: IString;
338
+ fontFamily: IString;
339
+ fontSize: INumber;
213
340
  fontWeight: IFontWeight;
214
- italic: __Boolean;
341
+ italic: IBoolean;
215
342
  textCase: ITextCase;
216
343
  textDecoration: ITextDecoration;
217
- letterSpacing: __Number | IUnitData;
218
- lineHeight: __Number | IUnitData;
219
- paraIndent: __Number;
220
- paraSpacing: __Number;
344
+ letterSpacing: INumber | IUnitData;
345
+ lineHeight: INumber | IUnitData;
346
+ paraIndent: INumber;
347
+ paraSpacing: INumber;
221
348
  textAlign: ITextAlign;
222
349
  verticalAlign: IVerticalAlign;
350
+ textWrap: ITextWrap;
223
351
  textOverflow: IOverflow | string;
224
352
  get textDrawData(): ITextDrawData;
225
353
  constructor(data?: ITextInputData);
@@ -235,12 +363,8 @@ declare class Text extends UI implements IText {
235
363
  declare class Path extends UI implements IPath {
236
364
  get __tag(): string;
237
365
  __: IPathData;
238
- path: IPathCommandData | IPathString$1;
239
- windingRule: IWindingRule;
240
366
  strokeAlign: IStrokeAlign;
241
- get resizeable(): boolean;
242
367
  constructor(data?: IPathInputData);
243
- __updateBoxBounds(): void;
244
368
  }
245
369
 
246
370
  declare class Pen extends Group implements IPen {
@@ -249,6 +373,7 @@ declare class Pen extends Group implements IPen {
249
373
  pathElement: IPath;
250
374
  pathStyle: IPathInputData;
251
375
  path: IPathCommandData$1;
376
+ __path: IPathCommandData$1;
252
377
  constructor(data?: IPenInputData);
253
378
  setStyle(data: IPathInputData): Pen;
254
379
  beginPath(): Pen;
@@ -265,8 +390,8 @@ declare class Pen extends Group implements IPen {
265
390
  drawEllipse(_x: number, _y: number, _radiusX: number, _radiusY: number, _rotation?: number, _startAngle?: number, _endAngle?: number, _anticlockwise?: boolean): Pen;
266
391
  drawArc(_x: number, _y: number, _radius: number, _startAngle?: number, _endAngle?: number, _anticlockwise?: boolean): Pen;
267
392
  drawPoints(_points: number[], _curve?: boolean | number, _close?: boolean): Pen;
393
+ clearPath(): Pen;
268
394
  paint(): void;
269
- clear(): void;
270
395
  }
271
396
 
272
- export { Box, Canvas, Ellipse, Frame, Group, Image, Line, Path, Pen, Polygon, Rect, Star, Text, UI };
397
+ export { Box, Canvas, Ellipse, Frame, Group, Image, Leafer, Line, Path, Pen, Polygon, Rect, Star, Text, UI };