@leafer-ui/display 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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.0.1",
26
- "@leafer-ui/data": "1.0.1",
27
- "@leafer-ui/display-module": "1.0.1",
28
- "@leafer-ui/decorator": "1.0.1",
29
- "@leafer-ui/external": "1.0.1"
25
+ "@leafer/core": "1.0.3",
26
+ "@leafer-ui/data": "1.0.3",
27
+ "@leafer-ui/display-module": "1.0.3",
28
+ "@leafer-ui/decorator": "1.0.3",
29
+ "@leafer-ui/external": "1.0.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.0.1",
33
- "@leafer-ui/interface": "1.0.1"
32
+ "@leafer/interface": "1.0.3",
33
+ "@leafer-ui/interface": "1.0.3"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -10,7 +10,7 @@ import { Rect } from './Rect'
10
10
  const rect = Rect.prototype
11
11
  const group = Group.prototype
12
12
  const childrenRenderBounds = {} as IBoundsData
13
- const { copy, add, includes } = BoundsHelper
13
+ const { copy, add, includes, copyAndSpread } = BoundsHelper
14
14
 
15
15
  @rewriteAble()
16
16
  @registerUI()
@@ -50,18 +50,26 @@ export class Box extends Group implements IBox {
50
50
  @rewrite(rect.__updateBoxBounds)
51
51
  public __updateRectBoxBounds(): void { }
52
52
 
53
- public __updateBoxBounds(): void {
53
+ public __updateBoxBounds(secondLayout?: boolean): void {
54
54
  const data = this.__
55
55
 
56
56
  if (this.children.length) {
57
57
  if (data.__autoSide) {
58
+
58
59
  if (this.leafer && this.leafer.ready) this.leafer.layouter.addExtra(this)
59
60
  super.__updateBoxBounds()
61
+
62
+ const { boxBounds } = this.__layout
63
+
60
64
  if (!data.__autoSize) {
61
- const b = this.__layout.boxBounds
62
- if (!data.__autoWidth) b.height += b.y, b.width = data.width, b.x = b.y = 0
63
- if (!data.__autoHeight) b.width += b.x, b.height = data.height, b.y = b.x = 0
65
+ if (data.__autoWidth) boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0
66
+ else boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0
64
67
  }
68
+
69
+ if (secondLayout && data.flow && data.padding) copyAndSpread(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'))
70
+
71
+ this.__updateNaturalSize()
72
+
65
73
  } else {
66
74
  this.__updateRectBoxBounds()
67
75
  }
@@ -85,13 +93,13 @@ export class Box extends Group implements IBox {
85
93
  copy(childrenRenderBounds, renderBounds)
86
94
  this.__updateRectRenderBounds()
87
95
 
88
- isOverflow = !includes(renderBounds, childrenRenderBounds) || undefined
96
+ isOverflow = !includes(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius // 路径与圆角直接当溢出处理
89
97
  } else {
90
98
  this.__updateRectRenderBounds()
91
99
  }
92
100
 
93
101
  this.isOverflow !== isOverflow && (this.isOverflow = isOverflow)
94
- if (isOverflow && !(this.__.__drawAfterFill = this.__.overflow === 'hide')) add(renderBounds, childrenRenderBounds)
102
+ if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow) add(renderBounds, childrenRenderBounds)
95
103
  }
96
104
 
97
105
  @rewrite(rect.__updateRenderBounds)
package/src/Canvas.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ILeaferCanvas, ILeaferCanvasConfig, INumber, IRenderOptions, IPointData, ICanvasContext2D, ICanvasContext2DSettings, IScreenSizeData, ISizeData } from '@leafer/interface'
2
- import { Creator, Matrix, Platform, dataProcessor, registerUI } from '@leafer/core'
1
+ import { ILeaferCanvas, ILeaferCanvasConfig, INumber, IRenderOptions, IPointData, ICanvasContext2D, ICanvasContext2DSettings, IScreenSizeData } from '@leafer/interface'
2
+ import { Creator, ImageEvent, LeaferImage, Matrix, dataProcessor, registerUI } from '@leafer/core'
3
3
 
4
4
  import { ICanvas, ICanvasData, ICanvasInputData, IUI } from '@leafer-ui/interface'
5
5
  import { CanvasData } from '@leafer-ui/data'
@@ -22,7 +22,7 @@ export class Canvas extends Rect implements ICanvas {
22
22
  @resizeType(100)
23
23
  declare public height?: INumber
24
24
 
25
- @resizeType(Platform.devicePixelRatio)
25
+ @resizeType(1)
26
26
  declare public pixelRatio?: INumber
27
27
 
28
28
  @resizeType(true)
@@ -35,11 +35,25 @@ export class Canvas extends Rect implements ICanvas {
35
35
 
36
36
  public context?: ICanvasContext2D
37
37
 
38
+ public get ready(): boolean { return !this.url }
39
+
40
+ public url?: string // 用于临时加载canvas的base64数据,完成后会置空
41
+
38
42
  constructor(data?: ICanvasInputData) {
39
43
  super(data)
40
44
  this.canvas = Creator.canvas(this.__ as ILeaferCanvasConfig)
41
45
  this.context = this.canvas.context
42
46
  this.__.__isCanvas = this.__.__drawAfterFill = true
47
+ if (data && data.url) this.drawImage(data.url)
48
+ }
49
+
50
+ public drawImage(url: string): void {
51
+ new LeaferImage({ url }).load((image: LeaferImage) => {
52
+ this.context.drawImage(image.view, 0, 0)
53
+ this.url = undefined
54
+ this.paint()
55
+ this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }))
56
+ })
43
57
  }
44
58
 
45
59
  public draw(ui: IUI, offset?: IPointData, scale?: number | IPointData, rotation?: number): void {
@@ -58,19 +72,18 @@ export class Canvas extends Rect implements ICanvas {
58
72
  }
59
73
 
60
74
  public paint(): void {
61
- this.forceUpdate('fill')
75
+ this.forceRender()
62
76
  }
63
77
 
64
78
  public __drawAfterFill(canvas: ILeaferCanvas, _options: IRenderOptions): void {
65
- const origin = this.canvas.view as ISizeData
66
- const { width, height } = this
67
- if (this.__.cornerRadius || this.pathInputed) {
79
+ const { width, height, cornerRadius } = this.__, { view } = this.canvas
80
+ if (cornerRadius || this.pathInputed) {
68
81
  canvas.save()
69
82
  canvas.clip()
70
- canvas.drawImage(this.canvas.view as any, 0, 0, origin.width, origin.height, 0, 0, width, height)
83
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height)
71
84
  canvas.restore()
72
85
  } else {
73
- canvas.drawImage(this.canvas.view as any, 0, 0, origin.width, origin.height, 0, 0, width, height)
86
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height)
74
87
  }
75
88
  }
76
89
 
package/src/Group.ts CHANGED
@@ -36,7 +36,7 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
36
36
 
37
37
  // data
38
38
 
39
- public set(data: IUIInputData): void {
39
+ public set(data: IUIInputData, isTemp?: boolean): void {
40
40
  if (data.children) {
41
41
  const { children } = data
42
42
  delete data.children
@@ -47,7 +47,7 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
47
47
  this.clear()
48
48
  }
49
49
 
50
- super.set(data)
50
+ super.set(data, isTemp)
51
51
 
52
52
  let child: IUI
53
53
  children.forEach(childData => {
@@ -58,7 +58,7 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
58
58
  data.children = children
59
59
 
60
60
  } else {
61
- super.set(data)
61
+ super.set(data, isTemp)
62
62
  }
63
63
  }
64
64
 
package/src/Image.ts CHANGED
@@ -34,4 +34,6 @@ export class Image extends Rect implements IImage {
34
34
  super.destroy()
35
35
  }
36
36
 
37
- }
37
+ }
38
+
39
+ export const MyImage = Image
package/src/Leafer.ts CHANGED
@@ -1,8 +1,9 @@
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 } from '@leafer/interface'
2
- import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList } from '@leafer/core'
2
+ import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList, needPlugin } 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'
6
+
6
7
  import { Group } from './Group'
7
8
 
8
9
 
@@ -372,9 +373,10 @@ export class Leafer extends Group implements ILeafer {
372
373
 
373
374
  // need view plugin
374
375
  public zoom(_zoomType: IZoomType, _padding?: IFourNumber, _fixedScale?: boolean): IBoundsData {
375
- return debug.error('need @leafer-in/view') as undefined
376
+ return needPlugin('view')
376
377
  }
377
378
 
379
+
378
380
  // interaction window rewrite
379
381
  public getValidMove(moveX: number, moveY: number): IPointData { return { x: moveX, y: moveY } }
380
382
  public getValidScale(changeScale: number): number { return changeScale }
@@ -384,6 +386,18 @@ export class Leafer extends Group implements ILeafer {
384
386
  return this.interaction && this.interaction.getLocal(clientPoint, updateClient)
385
387
  }
386
388
 
389
+ public getPagePointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData {
390
+ return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient))
391
+ }
392
+
393
+ public updateClientBounds(): void {
394
+ this.canvas && this.canvas.updateClientBounds()
395
+ }
396
+
397
+ // miniapp rewrite
398
+ public receiveEvent(_event: any): void { }
399
+
400
+
387
401
  protected __checkUpdateLayout(): void {
388
402
  this.__layout.update()
389
403
  }
package/src/Pen.ts CHANGED
@@ -6,8 +6,7 @@ import { PenData } from '@leafer-ui/data'
6
6
  import { Group } from './Group'
7
7
  import { Path } from './Path'
8
8
 
9
-
10
- @useModule(PathCreator, ['set', 'beginPath', 'path'])
9
+ @useModule(PathCreator, ['set', 'beginPath', 'path', 'paint'])
11
10
  @registerUI()
12
11
  export class Pen extends Group implements IPen {
13
12
 
@@ -79,10 +78,9 @@ export class Pen extends Group implements IPen {
79
78
  public clearPath(): Pen { return this }
80
79
 
81
80
  public paint(): void {
82
- this.pathElement.forceUpdate('path')
81
+ if (!this.pathElement.__layout.boxChanged) this.pathElement.forceUpdate('path')
83
82
  }
84
83
 
85
-
86
84
  }
87
85
 
88
86
  function penPathType() {
package/src/Text.ts CHANGED
@@ -96,14 +96,14 @@ export class Text extends UI implements IText {
96
96
  }
97
97
 
98
98
  public __drawHitPath(canvas: ILeaferCanvas): void {
99
- const { __lineHeight, __baseLine, __textDrawData: data } = this.__
99
+ const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__
100
100
 
101
101
  canvas.beginPath()
102
102
 
103
103
  if (this.__.__letterSpacing < 0) {
104
104
  this.__drawPathByData(canvas)
105
105
  } else {
106
- data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight))
106
+ data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight))
107
107
  }
108
108
  }
109
109
 
package/src/UI.ts CHANGED
@@ -1,8 +1,8 @@
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 } 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 } from '@leafer/core'
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 } 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, needPlugin } from '@leafer/core'
3
3
 
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 } from '@leafer-ui/interface'
5
- import { arrowType, effectType, stateType, zoomLayerType } from '@leafer-ui/decorator'
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, ITransition, IAnimateType } from '@leafer-ui/interface'
5
+ import { effectType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
8
8
  import { UIBounds, UIRender } from '@leafer-ui/display-module'
@@ -57,12 +57,6 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
57
57
  public visible?: IBoolean | 0
58
58
 
59
59
 
60
- @stateType(false)
61
- public selected?: IBoolean
62
-
63
- @stateType(false)
64
- public disabled?: IBoolean
65
-
66
60
  @surfaceType(false)
67
61
  public locked?: IBoolean
68
62
 
@@ -153,46 +147,34 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
153
147
  public closed?: boolean
154
148
 
155
149
 
156
- // auto layout
157
- @autoLayoutType(false)
150
+ // @leafer-in/flow rewrite
158
151
  public flow?: IFlowType
159
152
 
160
153
  @boundsType(0)
161
154
  public padding?: IFourNumber
162
155
 
163
- @boundsType(0)
164
156
  public gap?: IGap | IPointGap
165
157
 
166
- @boundsType('top-left')
167
158
  public flowAlign?: IFlowAlign | IFlowAxisAlign
168
159
 
169
- @boundsType(false)
170
160
  public flowWrap?: IFlowWrap
171
161
 
172
- @boundsType('box')
173
- public itemBox?: IFlowBoxType
174
162
 
163
+ public itemBox?: IFlowBoxType
175
164
 
176
- @boundsType(true)
177
165
  public inFlow?: IBoolean
178
166
 
179
- @boundsType() // rewrite in flow
167
+
180
168
  public autoWidth?: IAutoSize
181
169
 
182
- @boundsType() // rewrite in flow
183
170
  public autoHeight?: IAutoSize
184
171
 
185
- @boundsType()
186
172
  public lockRatio?: IBoolean
187
173
 
188
- @boundsType()
189
174
  public autoBox?: IAutoBoxData | IConstraint
190
175
 
191
-
192
- @boundsType()
193
176
  public widthRange?: IRangeSize
194
177
 
195
- @boundsType()
196
178
  public heightRange?: IRangeSize
197
179
 
198
180
 
@@ -271,12 +253,10 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
271
253
  public miterLimit?: INumber
272
254
 
273
255
 
274
- // arrow
256
+ // @leafer-in/arrow rewrite
275
257
 
276
- @arrowType('none')
277
258
  public startArrow?: IArrowType
278
259
 
279
- @arrowType('none')
280
260
  public endArrow?: IArrowType
281
261
 
282
262
  // corner
@@ -305,45 +285,64 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
305
285
  public grayscale?: INumber | IGrayscaleEffect
306
286
 
307
287
 
308
- // states
288
+ // @leafer-in/animate rewrite
309
289
 
310
- @dataType()
311
- public normalStyle?: IUIInputData // auto restore hover / press / focus / selected / disabled style
290
+ public animation?: IAnimation
291
+
292
+ public animationOut?: IAnimation
293
+
294
+
295
+ public transition?: ITransition
296
+
297
+ public transitionOut?: ITransition
298
+
299
+
300
+ // @leafer-in/motion-path rewrite
301
+
302
+ public motionPath?: boolean
303
+
304
+ public motion?: INumber | IUnitData
305
+
306
+ public motionRotation?: INumber | IBoolean
307
+
308
+
309
+ // @leafer-in/state rewrite
310
+
311
+ public states?: IStates
312
+
313
+ public state?: IStateName
314
+
315
+
316
+ public selected?: IBoolean
317
+
318
+ public disabled?: IBoolean
319
+
320
+
321
+ public normalStyle?: IUIInputData
312
322
 
313
- @dataType()
314
323
  public hoverStyle?: IUIInputData
315
324
 
316
- @dataType()
317
325
  public pressStyle?: IUIInputData
318
326
 
319
- @dataType()
320
327
  public focusStyle?: IUIInputData
321
328
 
322
- @dataType()
323
329
  public selectedStyle?: IUIInputData
324
330
 
325
- @dataType()
326
331
  public disabledStyle?: IUIInputData
327
332
 
328
333
 
334
+ public button?: IBoolean
335
+
336
+
329
337
  // 预留给用户使用的数据对象
330
338
  @dataType({})
331
339
  public data: IObject
332
340
 
333
341
 
334
- public set scale(value: INumber | IPointData) {
335
- if (typeof value === 'number') {
336
- this.scaleX = this.scaleY = value
337
- } else {
338
- this.scaleX = value.x
339
- this.scaleY = value.y
340
- }
341
- }
342
+ public set scale(value: INumber | IPointData) { MathHelper.assignScale(this as IScaleData, value) }
343
+ public get scale(): INumber | IPointData { return this.__.scale }
342
344
 
343
- public get scale(): INumber | IPointData {
344
- const { scaleX, scaleY } = this
345
- return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX
346
- }
345
+ public __animate?: IAnimate
347
346
 
348
347
  public get pen(): IPathCreator {
349
348
  const { path } = this.__
@@ -373,8 +372,14 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
373
372
  public reset(_data?: IUIInputData): void { }
374
373
 
375
374
 
376
- public set(data: IUIInputData): void {
377
- Object.assign(this, data)
375
+ public set(data: IUIInputData, isTemp?: boolean): void {
376
+ if (isTemp) {
377
+ this.lockNormalStyle = true
378
+ Object.assign(this, data)
379
+ this.lockNormalStyle = false
380
+ } else {
381
+ Object.assign(this, data)
382
+ }
378
383
  }
379
384
 
380
385
  public get(name?: string | string[] | IUIInputData): IUIInputData | IValue {
@@ -456,6 +461,14 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
456
461
  }
457
462
  }
458
463
 
464
+ // @leafer-in/animate rewrite
465
+
466
+ public animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation, _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate {
467
+ return needPlugin('animate')
468
+ }
469
+
470
+ public killAnimate(_type?: IAnimateType): void { }
471
+
459
472
 
460
473
  // create
461
474
 
@@ -463,8 +476,10 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
463
476
  return Export.export(this, filename, options)
464
477
  }
465
478
 
466
- public clone(): IUI {
467
- return UI.one(this.toJSON())
479
+ public clone(newData?: IUIInputData): IUI {
480
+ const json = this.toJSON()
481
+ if (newData) Object.assign(json, newData)
482
+ return UI.one(json)
468
483
  }
469
484
 
470
485
  static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI {
@@ -491,6 +506,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
491
506
 
492
507
  public destroy(): void {
493
508
  this.fill = this.stroke = null
509
+ if (this.__animate) this.killAnimate()
494
510
  super.destroy()
495
511
  }
496
512
 
package/src/index.ts CHANGED
@@ -11,7 +11,7 @@ export { Polygon } from './Polygon'
11
11
  export { Star } from './Star'
12
12
  export { Line } from './Line'
13
13
 
14
- export { Image } from './Image'
14
+ export { Image, MyImage } from './Image'
15
15
  export { Canvas } from './Canvas'
16
16
 
17
17
  export { Text } from './Text'
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, 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, IUnitData } from '@leafer/interface';
1
+ import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, 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, IEditorConfig, IFindUIMethod, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, 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, 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, ITransition, IStates, IStateName, IAnimate, IEditorConfig, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, 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, 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;
@@ -18,8 +18,6 @@ declare class UI extends Leaf implements IUI {
18
18
  blendMode?: IBlendMode;
19
19
  opacity?: INumber;
20
20
  visible?: IBoolean | 0;
21
- selected?: IBoolean;
22
- disabled?: IBoolean;
23
21
  locked?: IBoolean;
24
22
  zIndex?: INumber;
25
23
  mask?: IBoolean | IMaskType;
@@ -87,22 +85,35 @@ declare class UI extends Leaf implements IUI {
87
85
  blur?: INumber | IBlurEffect;
88
86
  backgroundBlur?: INumber | IBlurEffect;
89
87
  grayscale?: INumber | IGrayscaleEffect;
88
+ animation?: IAnimation;
89
+ animationOut?: IAnimation;
90
+ transition?: ITransition;
91
+ transitionOut?: ITransition;
92
+ motionPath?: boolean;
93
+ motion?: INumber | IUnitData;
94
+ motionRotation?: INumber | IBoolean;
95
+ states?: IStates;
96
+ state?: IStateName;
97
+ selected?: IBoolean;
98
+ disabled?: IBoolean;
90
99
  normalStyle?: IUIInputData;
91
100
  hoverStyle?: IUIInputData;
92
101
  pressStyle?: IUIInputData;
93
102
  focusStyle?: IUIInputData;
94
103
  selectedStyle?: IUIInputData;
95
104
  disabledStyle?: IUIInputData;
105
+ button?: IBoolean;
96
106
  data: IObject;
97
107
  set scale(value: INumber | IPointData);
98
108
  get scale(): INumber | IPointData;
109
+ __animate?: IAnimate;
99
110
  get pen(): IPathCreator;
100
111
  get editConfig(): IEditorConfig;
101
112
  get editOuter(): string;
102
113
  get editInner(): string;
103
114
  constructor(data?: IUIInputData);
104
115
  reset(_data?: IUIInputData): void;
105
- set(data: IUIInputData): void;
116
+ set(data: IUIInputData, isTemp?: boolean): void;
106
117
  get(name?: string | string[] | IUIInputData): IUIInputData | IValue;
107
118
  createProxyData(): IUIInputData;
108
119
  find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[];
@@ -118,8 +129,10 @@ declare class UI extends Leaf implements IUI {
118
129
  __drawPath(canvas: ILeaferCanvas): void;
119
130
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
120
131
  __drawPathByBox(drawer: IPathDrawer): void;
132
+ animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation, _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
133
+ killAnimate(_type?: IAnimateType): void;
121
134
  export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
122
- clone(): IUI;
135
+ clone(newData?: IUIInputData): IUI;
123
136
  static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
124
137
  static registerUI(): void;
125
138
  static registerData(data: IUIData): void;
@@ -137,7 +150,7 @@ declare class Group extends UI implements IGroup {
137
150
  constructor(data?: IGroupInputData);
138
151
  reset(data?: IGroupInputData): void;
139
152
  __setBranch(): void;
140
- set(data: IUIInputData): void;
153
+ set(data: IUIInputData, isTemp?: boolean): void;
141
154
  toJSON(options?: IJSONOptions): IUIJSONData;
142
155
  pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult;
143
156
  addAt(child: IUI, index: number): void;
@@ -231,6 +244,9 @@ declare class Leafer extends Group implements ILeafer {
231
244
  getValidMove(moveX: number, moveY: number): IPointData;
232
245
  getValidScale(changeScale: number): number;
233
246
  getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
247
+ getPagePointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
248
+ updateClientBounds(): void;
249
+ receiveEvent(_event: any): void;
234
250
  protected __checkUpdateLayout(): void;
235
251
  protected emitLeafer(type: string): void;
236
252
  protected __listenEvents(): void;
@@ -250,7 +266,7 @@ declare class Box extends Group implements IBox {
250
266
  __updateRectRenderSpread(): number;
251
267
  __updateRenderSpread(): number;
252
268
  __updateRectBoxBounds(): void;
253
- __updateBoxBounds(): void;
269
+ __updateBoxBounds(secondLayout?: boolean): void;
254
270
  __updateStrokeBounds(): void;
255
271
  __updateRenderBounds(): void;
256
272
  __updateRectRenderBounds(): void;
@@ -333,6 +349,7 @@ declare class Image extends Rect implements IImage {
333
349
  constructor(data?: IImageInputData);
334
350
  destroy(): void;
335
351
  }
352
+ declare const MyImage: typeof Image;
336
353
 
337
354
  declare class Canvas extends Rect implements ICanvas {
338
355
  get __tag(): string;
@@ -344,7 +361,10 @@ declare class Canvas extends Rect implements ICanvas {
344
361
  contextSettings?: ICanvasContext2DSettings;
345
362
  canvas?: ILeaferCanvas;
346
363
  context?: ICanvasContext2D;
364
+ get ready(): boolean;
365
+ url?: string;
347
366
  constructor(data?: ICanvasInputData);
367
+ drawImage(url: string): void;
348
368
  draw(ui: IUI, offset?: IPointData, scale?: number | IPointData, rotation?: number): void;
349
369
  paint(): void;
350
370
  __drawAfterFill(canvas: ILeaferCanvas, _options: IRenderOptions): void;
@@ -422,4 +442,4 @@ declare class Pen extends Group implements IPen {
422
442
  paint(): void;
423
443
  }
424
444
 
425
- export { Box, Canvas, Ellipse, Frame, Group, Image, Leafer, Line, Path, Pen, Polygon, Rect, Star, Text, UI };
445
+ export { Box, Canvas, Ellipse, Frame, Group, Image, Leafer, Line, MyImage, Path, Pen, Polygon, Rect, Star, Text, UI };