@leafer-ui/display 1.6.2 → 1.6.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.6.2",
3
+ "version": "1.6.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.6.2",
26
- "@leafer-ui/data": "1.6.2",
27
- "@leafer-ui/display-module": "1.6.2",
28
- "@leafer-ui/decorator": "1.6.2",
29
- "@leafer-ui/external": "1.6.2"
25
+ "@leafer/core": "1.6.3",
26
+ "@leafer-ui/data": "1.6.3",
27
+ "@leafer-ui/display-module": "1.6.3",
28
+ "@leafer-ui/decorator": "1.6.3",
29
+ "@leafer-ui/external": "1.6.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.6.2",
33
- "@leafer-ui/interface": "1.6.2"
32
+ "@leafer/interface": "1.6.3",
33
+ "@leafer-ui/interface": "1.6.3"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeaferCanvas, IRenderOptions, IBoundsData, IBoolean, INumber } from '@leafer/interface'
2
- import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType, dataType, boundsType } from '@leafer/core'
2
+ import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType, dataType, boundsType, DataHelper } from '@leafer/core'
3
3
 
4
4
  import { IBox, IBoxData, IBoxInputData, IOverflow } from '@leafer-ui/interface'
5
5
  import { BoxData } from '@leafer-ui/data'
@@ -102,11 +102,11 @@ export class Box extends Group implements IBox {
102
102
  copy(childrenRenderBounds, renderBounds)
103
103
  this.__updateRectRenderBounds()
104
104
 
105
- isOverflow = !includes(renderBounds, childrenRenderBounds) || undefined
105
+ isOverflow = !includes(renderBounds, childrenRenderBounds)
106
106
  if (isOverflow && this.__.overflow !== 'hide') add(renderBounds, childrenRenderBounds)
107
107
  } else this.__updateRectRenderBounds()
108
108
 
109
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow) // 节省赋值
109
+ DataHelper.stintSet(this, 'isOverflow', isOverflow)
110
110
  }
111
111
 
112
112
  @rewrite(rect.__updateRenderBounds)
package/src/Canvas.ts CHANGED
@@ -36,7 +36,7 @@ export class Canvas extends Rect implements ICanvas {
36
36
 
37
37
  public canvas?: ILeaferCanvas
38
38
 
39
- public context?: ICanvasContext2D
39
+ public get context(): ICanvasContext2D { return this.canvas.context }
40
40
 
41
41
  public get ready(): boolean { return !this.url }
42
42
 
@@ -45,7 +45,6 @@ export class Canvas extends Rect implements ICanvas {
45
45
  constructor(data?: ICanvasInputData) {
46
46
  super(data)
47
47
  this.canvas = Creator.canvas(this.__ as ILeaferCanvasConfig)
48
- this.context = this.canvas.context
49
48
  if (data && data.url) this.drawImage(data.url)
50
49
  }
51
50
 
@@ -93,7 +92,7 @@ export class Canvas extends Rect implements ICanvas {
93
92
  public destroy(): void {
94
93
  if (this.canvas) {
95
94
  this.canvas.destroy()
96
- this.canvas = this.context = null
95
+ this.canvas = null
97
96
  }
98
97
  super.destroy()
99
98
  }
package/src/Image.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeaferImage, IString } from '@leafer/interface'
2
- import { ImageEvent, boundsType, dataProcessor, registerUI } from '@leafer/core'
2
+ import { boundsType, dataProcessor, registerUI } from '@leafer/core'
3
3
 
4
4
  import { IImage, IImageInputData, IImageData } from '@leafer-ui/interface'
5
5
  import { ImageData } from '@leafer-ui/data'
@@ -18,22 +18,12 @@ export class Image extends Rect implements IImage {
18
18
  @boundsType('')
19
19
  public url: IString
20
20
 
21
- public get ready(): boolean { return this.image ? this.image.ready : false }
21
+ public get ready(): boolean { const { image } = this; return image && image.ready }
22
22
 
23
- public image?: ILeaferImage
23
+ public get image(): ILeaferImage { const { fill } = this.__; return fill instanceof Array && fill[0].image }
24
24
 
25
25
  constructor(data?: IImageInputData) {
26
26
  super(data)
27
- this.on_(ImageEvent.LOADED, this.__onLoaded, this)
28
- }
29
-
30
- public __onLoaded(e: ImageEvent): void {
31
- if (e.attrName === 'fill' && e.attrValue.url === this.url) this.image = e.image
32
- }
33
-
34
- public destroy(): void {
35
- this.image = null
36
- super.destroy()
37
27
  }
38
28
 
39
29
  }
package/src/Leafer.ts CHANGED
@@ -421,20 +421,23 @@ export class Leafer extends Group implements ILeafer {
421
421
 
422
422
  protected __listenEvents(): void {
423
423
  const runId = Run.start('FirstCreate ' + this.innerName)
424
- this.once(LeaferEvent.START, () => Run.end(runId))
425
- this.once(LayoutEvent.START, () => this.updateLazyBounds())
426
- this.once(RenderEvent.START, () => this.__onCreated())
427
- this.once(RenderEvent.END, () => this.__onViewReady())
424
+ this.once([
425
+ [LeaferEvent.START, () => Run.end(runId)],
426
+ [LayoutEvent.START, this.updateLazyBounds, this],
427
+ [RenderEvent.START, this.__onCreated, this],
428
+ [RenderEvent.END, this.__onViewReady, this]
429
+ ])
428
430
  this.__eventIds.push(
429
- this.on_(WatchEvent.DATA, this.__onWatchData, this),
430
- this.on_(LayoutEvent.END, this.__onLayoutEnd, this),
431
- this.on_(RenderEvent.NEXT, this.__onNextRender, this),
431
+ this.on_([
432
+ [WatchEvent.DATA, this.__onWatchData, this],
433
+ [LayoutEvent.END, this.__onLayoutEnd, this],
434
+ [RenderEvent.NEXT, this.__onNextRender, this]
435
+ ])
432
436
  )
433
437
  }
434
438
 
435
439
  protected __removeListenEvents(): void {
436
440
  this.off_(this.__eventIds)
437
- this.__eventIds.length = 0
438
441
  }
439
442
 
440
443
  override destroy(sync?: boolean): void {
package/src/Text.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeaferCanvas, IBoolean, INumber, IString, IBoundsData, IUnitData, IRenderOptions } from '@leafer/interface'
2
- import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, dataType, hitType, MathHelper } from '@leafer/core'
2
+ import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, dataType, hitType, MathHelper, DataHelper } from '@leafer/core'
3
3
 
4
4
  import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IStrokeAlign, IHitType, ITextWrap, IWritingMode, IBackgroundBoxStyle } from '@leafer-ui/interface'
5
5
  import { TextData } from '@leafer-ui/data'
@@ -152,11 +152,10 @@ export class Text extends UI implements IText {
152
152
 
153
153
  if (italic) b.width += fontSize * 0.16 // 倾斜会导致文本的bounds增大
154
154
 
155
- const isOverflow = !includes(b, contentBounds) || undefined
156
- if (isOverflow) setList(data.__textBoxBounds = {} as IBoundsData, [b, contentBounds]), layout.renderChanged = true
157
- else data.__textBoxBounds = b
155
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds))
158
156
 
159
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow) // 节省赋值
157
+ if (this.isOverflow) setList(data.__textBoxBounds = {} as IBoundsData, [b, contentBounds]), layout.renderChanged = true
158
+ else data.__textBoxBounds = b
160
159
  }
161
160
 
162
161
  override __onUpdateSize(): void {
package/src/UI.ts CHANGED
@@ -346,15 +346,28 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
346
346
 
347
347
  public disabledStyle?: IStateStyle
348
348
 
349
+
349
350
  public placeholderStyle?: IStateStyle
350
351
 
351
352
  @surfaceType()
352
353
  public placeholderColor?: IColorString
353
354
 
355
+ @dataType(100)
356
+ public placeholderDelay?: INumber
357
+
354
358
 
355
359
  public button?: IBoolean
356
360
 
357
361
 
362
+ // @leafer-in/editor rewrite
363
+
364
+ public editConfig: IEditorConfig
365
+
366
+ public editOuter: string
367
+
368
+ public editInner: string
369
+
370
+
358
371
  // 预留给用户使用的数据对象
359
372
  @dataType({})
360
373
  public data: IObject
@@ -363,6 +376,8 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
363
376
  public set scale(value: INumber | IPointData) { MathHelper.assignScale(this as IScaleData, value) }
364
377
  public get scale(): INumber | IPointData { return this.__.scale }
365
378
 
379
+ public useFastShadow?: boolean // 将忽略 stroke 产生的阴影,只对单个 fill 有效
380
+
366
381
  public __box?: IUI // 背景box, 一般用于文本背景框
367
382
  public __animate?: IAnimate
368
383
 
@@ -374,15 +389,6 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
374
389
  }
375
390
 
376
391
 
377
- // @leafer-in/editor rewrite
378
-
379
- public editConfig: IEditorConfig
380
-
381
- public editOuter: string
382
-
383
- public editInner: string
384
-
385
-
386
392
  constructor(data?: IUIInputData) {
387
393
  super(data)
388
394
  }
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, ILeaferImage, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IZoomType, IClientPointData, IRenderOptions, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
- import { Leaf, LeafList, ImageEvent } 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, IColorString, 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, IBackgroundBoxStyle, 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';
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, IColorString, IEditorConfig, IAnimate, 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, IBackgroundBoxStyle, 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;
@@ -108,16 +108,18 @@ declare class UI extends Leaf implements IUI {
108
108
  disabledStyle?: IStateStyle;
109
109
  placeholderStyle?: IStateStyle;
110
110
  placeholderColor?: IColorString;
111
+ placeholderDelay?: INumber;
111
112
  button?: IBoolean;
113
+ editConfig: IEditorConfig;
114
+ editOuter: string;
115
+ editInner: string;
112
116
  data: IObject;
113
117
  set scale(value: INumber | IPointData);
114
118
  get scale(): INumber | IPointData;
119
+ useFastShadow?: boolean;
115
120
  __box?: IUI;
116
121
  __animate?: IAnimate;
117
122
  get pen(): IPathCreator;
118
- editConfig: IEditorConfig;
119
- editOuter: string;
120
- editInner: string;
121
123
  constructor(data?: IUIInputData);
122
124
  reset(_data?: IUIInputData): void;
123
125
  set(data: IUIInputData, transition?: ITransition | 'temp'): void;
@@ -362,10 +364,8 @@ declare class Image extends Rect implements IImage {
362
364
  __: IImageData;
363
365
  url: IString;
364
366
  get ready(): boolean;
365
- image?: ILeaferImage;
367
+ get image(): ILeaferImage;
366
368
  constructor(data?: IImageInputData);
367
- __onLoaded(e: ImageEvent): void;
368
- destroy(): void;
369
369
  }
370
370
  declare const MyImage: typeof Image;
371
371
 
@@ -379,7 +379,7 @@ declare class Canvas extends Rect implements ICanvas {
379
379
  safeResize?: boolean;
380
380
  contextSettings?: ICanvasContext2DSettings;
381
381
  canvas?: ILeaferCanvas;
382
- context?: ICanvasContext2D;
382
+ get context(): ICanvasContext2D;
383
383
  get ready(): boolean;
384
384
  url?: string;
385
385
  constructor(data?: ICanvasInputData);