@leafer-ui/display 1.3.1 → 1.3.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.3.1",
3
+ "version": "1.3.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.3.1",
26
- "@leafer-ui/data": "1.3.1",
27
- "@leafer-ui/display-module": "1.3.1",
28
- "@leafer-ui/decorator": "1.3.1",
29
- "@leafer-ui/external": "1.3.1"
25
+ "@leafer/core": "1.3.3",
26
+ "@leafer-ui/data": "1.3.3",
27
+ "@leafer-ui/display-module": "1.3.3",
28
+ "@leafer-ui/decorator": "1.3.3",
29
+ "@leafer-ui/external": "1.3.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.3.1",
33
- "@leafer-ui/interface": "1.3.1"
32
+ "@leafer/interface": "1.3.3",
33
+ "@leafer-ui/interface": "1.3.3"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -60,6 +60,8 @@ export class Box extends Group implements IBox {
60
60
 
61
61
  if (data.__autoSide) {
62
62
 
63
+ if (data.__hasSurface) this.__extraUpdate() // Box自身存在样式,需要额外更新
64
+
63
65
  super.__updateBoxBounds()
64
66
 
65
67
  const { boxBounds } = this.__layout
package/src/Leafer.ts CHANGED
@@ -256,7 +256,7 @@ export class Leafer extends Group implements ILeafer {
256
256
  override __setAttr(attrName: string, newValue: IValue): boolean {
257
257
  if (this.canvas) {
258
258
  if (canvasSizeAttrs.includes(attrName)) {
259
- if (!newValue) debug.warn(attrName + ' is 0')
259
+ // if (!newValue) debug.warn(attrName + ' is 0')
260
260
  this.__changeCanvasSize(attrName, newValue as number)
261
261
  } else if (attrName === 'fill') {
262
262
  this.__changeFill(newValue as string)
@@ -293,7 +293,6 @@ export class Leafer extends Group implements ILeafer {
293
293
  }
294
294
 
295
295
  protected __onReady(): void {
296
- if (this.ready) return
297
296
  this.ready = true
298
297
  this.emitLeafer(LeaferEvent.BEFORE_READY)
299
298
  this.emitLeafer(LeaferEvent.READY)
@@ -308,6 +307,19 @@ export class Leafer extends Group implements ILeafer {
308
307
  WaitHelper.run(this.__viewReadyWait)
309
308
  }
310
309
 
310
+ protected __onLayoutEnd(): void {
311
+ const { grow, growWidth, growHeight } = this.config
312
+ if (grow) {
313
+ let { width, height, pixelRatio } = this
314
+ const bounds = grow === 'box' ? this.worldBoxBounds : this.__world
315
+ if (growWidth !== false) width = Math.max(1, bounds.x + bounds.width)
316
+ if (growHeight !== false) height = Math.max(1, bounds.y + bounds.height)
317
+ this.__doResize({ width, height, pixelRatio })
318
+ }
319
+
320
+ if (!this.ready) this.__onReady()
321
+ }
322
+
311
323
  protected __onNextRender(): void {
312
324
  if (this.viewReady) {
313
325
  WaitHelper.run(this.__nextRenderWait)
@@ -405,11 +417,11 @@ export class Leafer extends Group implements ILeafer {
405
417
  const runId = Run.start('FirstCreate ' + this.innerName)
406
418
  this.once(LeaferEvent.START, () => Run.end(runId))
407
419
  this.once(LayoutEvent.START, () => this.updateLazyBounds())
408
- this.once(LayoutEvent.END, () => this.__onReady())
409
420
  this.once(RenderEvent.START, () => this.__onCreated())
410
421
  this.once(RenderEvent.END, () => this.__onViewReady())
411
422
  this.__eventIds.push(
412
423
  this.on_(WatchEvent.DATA, this.__onWatchData, this),
424
+ this.on_(LayoutEvent.END, this.__onLayoutEnd, this),
413
425
  this.on_(RenderEvent.NEXT, this.__onNextRender, this),
414
426
  )
415
427
  }
package/src/Text.ts CHANGED
@@ -41,7 +41,7 @@ export class Text extends UI implements IText {
41
41
  @boundsType('')
42
42
  public text?: IString | INumber
43
43
 
44
- @boundsType('L')
44
+ @boundsType('caption')
45
45
  public fontFamily?: IString
46
46
 
47
47
  @boundsType(12)
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
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 } from '@leafer/interface'
2
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'
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, IKeyframe, IAnimation, IAnimate, IStates, IStateName, ITransition, IAnimateType, IEffect } from '@leafer-ui/interface'
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, IEffect, IStateStyle } from '@leafer-ui/interface'
5
5
  import { effectType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -326,17 +326,19 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
326
326
  public disabled?: IBoolean
327
327
 
328
328
 
329
- public normalStyle?: IUIInputData
329
+ public normalStyle?: IStateStyle
330
330
 
331
- public hoverStyle?: IUIInputData
331
+ public hoverStyle?: IStateStyle
332
332
 
333
- public pressStyle?: IUIInputData
333
+ public pressStyle?: IStateStyle
334
334
 
335
- public focusStyle?: IUIInputData
335
+ public focusStyle?: IStateStyle
336
336
 
337
- public selectedStyle?: IUIInputData
337
+ public selectedStyle?: IStateStyle
338
338
 
339
- public disabledStyle?: IUIInputData
339
+ public disabledStyle?: IStateStyle
340
+
341
+ public placeholderStyle?: IStateStyle
340
342
 
341
343
 
342
344
  public button?: IBoolean
@@ -471,7 +473,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
471
473
  return Plugin.need('animate')
472
474
  }
473
475
 
474
- public killAnimate(_type?: IAnimateType, _killStyle?: IUIInputData): void { }
476
+ public killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void { }
475
477
 
476
478
 
477
479
  // create
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, 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, IEffect, IAnimation, ITransition, IStates, IStateName, 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, IEffect, IAnimation, ITransition, 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';
4
4
 
5
5
  declare class UI extends Leaf implements IUI {
6
6
  __: IUIData;
@@ -98,12 +98,13 @@ declare class UI extends Leaf implements IUI {
98
98
  state?: IStateName;
99
99
  selected?: IBoolean;
100
100
  disabled?: IBoolean;
101
- normalStyle?: IUIInputData;
102
- hoverStyle?: IUIInputData;
103
- pressStyle?: IUIInputData;
104
- focusStyle?: IUIInputData;
105
- selectedStyle?: IUIInputData;
106
- disabledStyle?: IUIInputData;
101
+ normalStyle?: IStateStyle;
102
+ hoverStyle?: IStateStyle;
103
+ pressStyle?: IStateStyle;
104
+ focusStyle?: IStateStyle;
105
+ selectedStyle?: IStateStyle;
106
+ disabledStyle?: IStateStyle;
107
+ placeholderStyle?: IStateStyle;
107
108
  button?: IBoolean;
108
109
  data: IObject;
109
110
  set scale(value: INumber | IPointData);
@@ -132,7 +133,7 @@ declare class UI extends Leaf implements IUI {
132
133
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
133
134
  __drawPathByBox(drawer: IPathDrawer): void;
134
135
  animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
135
- killAnimate(_type?: IAnimateType, _killStyle?: IUIInputData): void;
136
+ killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void;
136
137
  export(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): Promise<IExportResult>;
137
138
  clone(data?: IUIInputData): IUI;
138
139
  static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
@@ -236,6 +237,7 @@ declare class Leafer extends Group implements ILeafer {
236
237
  protected __onCreated(): void;
237
238
  protected __onReady(): void;
238
239
  protected __onViewReady(): void;
240
+ protected __onLayoutEnd(): void;
239
241
  protected __onNextRender(): void;
240
242
  protected __checkViewCompleted(emit?: boolean): void;
241
243
  protected __onWatchData(): void;