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