@leafer-ui/display 1.0.3 → 1.0.5

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.3",
3
+ "version": "1.0.5",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -13,23 +13,23 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/leaferjs/ui.git"
16
+ "url": "https://github.com/leaferjs/leafer-ui.git"
17
17
  },
18
- "homepage": "https://github.com/leaferjs/ui/tree/main/packages/display",
19
- "bugs": "https://github.com/leaferjs/ui/issues",
18
+ "homepage": "https://github.com/leaferjs/leafer-ui/tree/main/packages/display",
19
+ "bugs": "https://github.com/leaferjs/leafer-ui/issues",
20
20
  "keywords": [
21
21
  "leafer-ui",
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
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"
25
+ "@leafer/core": "1.0.5",
26
+ "@leafer-ui/data": "1.0.5",
27
+ "@leafer-ui/display-module": "1.0.5",
28
+ "@leafer-ui/decorator": "1.0.5",
29
+ "@leafer-ui/external": "1.0.5"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.0.3",
33
- "@leafer-ui/interface": "1.0.3"
32
+ "@leafer/interface": "1.0.5",
33
+ "@leafer-ui/interface": "1.0.5"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -7,10 +7,10 @@ import { BoxData } from '@leafer-ui/data'
7
7
  import { Group } from './Group'
8
8
  import { Rect } from './Rect'
9
9
 
10
- const rect = Rect.prototype
11
- const group = Group.prototype
10
+
11
+ const { copy, add, includes } = BoundsHelper
12
+ const rect = Rect.prototype, group = Group.prototype
12
13
  const childrenRenderBounds = {} as IBoundsData
13
- const { copy, add, includes, copyAndSpread } = BoundsHelper
14
14
 
15
15
  @rewriteAble()
16
16
  @registerUI()
@@ -26,6 +26,9 @@ export class Box extends Group implements IBox {
26
26
  @dataType(false)
27
27
  public resizeChildren?: IBoolean
28
28
 
29
+ @dataType(false)
30
+ public textBox?: IBoolean
31
+
29
32
  @affectRenderBoundsType('show')
30
33
  declare public overflow?: IOverflow
31
34
 
@@ -50,32 +53,35 @@ export class Box extends Group implements IBox {
50
53
  @rewrite(rect.__updateBoxBounds)
51
54
  public __updateRectBoxBounds(): void { }
52
55
 
53
- public __updateBoxBounds(secondLayout?: boolean): void {
56
+
57
+ // @leafer-in/flow will rewrite
58
+ public __updateBoxBounds(_secondLayout?: boolean): void {
54
59
  const data = this.__
55
60
 
56
61
  if (this.children.length) {
62
+
57
63
  if (data.__autoSide) {
58
64
 
59
- if (this.leafer && this.leafer.ready) this.leafer.layouter.addExtra(this)
60
65
  super.__updateBoxBounds()
61
66
 
62
67
  const { boxBounds } = this.__layout
63
68
 
64
69
  if (!data.__autoSize) {
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
70
+ if (data.__autoWidth) {
71
+ boxBounds.width += boxBounds.x, boxBounds.x = 0
72
+ boxBounds.height = data.height, boxBounds.y = 0
73
+ } else {
74
+ boxBounds.height += boxBounds.y, boxBounds.y = 0
75
+ boxBounds.width = data.width, boxBounds.x = 0
76
+ }
67
77
  }
68
78
 
69
- if (secondLayout && data.flow && data.padding) copyAndSpread(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'))
70
-
71
79
  this.__updateNaturalSize()
72
80
 
73
81
  } else {
74
82
  this.__updateRectBoxBounds()
75
83
  }
76
84
 
77
- if (data.flow) this.__updateContentBounds()
78
-
79
85
  } else {
80
86
  this.__updateRectBoxBounds()
81
87
  }
package/src/Group.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { IJSONOptions, IPickOptions, IPickResult, IPointData } from '@leafer/interface'
2
2
  import { Branch, useModule, dataProcessor, registerUI, UICreator } from '@leafer/core'
3
3
 
4
- import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData, IUIJSONData } from '@leafer-ui/interface'
4
+ import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData, IUIJSONData, IFindCondition, IFindUIMethod } from '@leafer-ui/interface'
5
5
  import { GroupData } from '@leafer-ui/data'
6
6
 
7
7
  import { UI } from './UI'
@@ -76,25 +76,25 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
76
76
 
77
77
  // add
78
78
 
79
- public addAt(child: IUI, index: number): void {
79
+ public addAt(child: IUI | IUIInputData, index: number): void {
80
80
  this.add(child, index)
81
81
  }
82
82
 
83
- public addAfter(child: IUI, after: IUI): void {
83
+ public addAfter(child: IUI | IUIInputData, after: IUI): void {
84
84
  this.add(child, this.children.indexOf(after) + 1)
85
85
  }
86
86
 
87
- public addBefore(child: IUI, before: IUI): void {
87
+ public addBefore(child: IUI | IUIInputData, before: IUI): void {
88
88
  this.add(child, this.children.indexOf(before))
89
89
  }
90
90
 
91
91
  // Branch rewrite
92
92
 
93
- public add(_child: IUI, _index?: number): void { }
93
+ public add(_child: IUI | IUIInputData, _index?: number): void { }
94
94
 
95
- public addMany(..._children: IUI[]): void { }
95
+ public addMany(..._children: IUI[] | IUIInputData[]): void { }
96
96
 
97
- public remove(_child?: IUI, _destroy?: boolean): void { }
97
+ public remove(_child?: IUI | number | string | IFindCondition | IFindUIMethod, _destroy?: boolean): void { }
98
98
 
99
99
  public removeAll(_destroy?: boolean): void { }
100
100
 
package/src/Text.ts CHANGED
@@ -77,6 +77,9 @@ export class Text extends UI implements IText {
77
77
  @boundsType('top')
78
78
  public verticalAlign?: IVerticalAlign
79
79
 
80
+ @boundsType(true)
81
+ public autoSizeAlign?: IBoolean
82
+
80
83
  @boundsType('normal')
81
84
  public textWrap?: ITextWrap
82
85
 
package/src/UI.ts CHANGED
@@ -444,11 +444,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
444
444
  }
445
445
 
446
446
  public __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void {
447
- if (data) {
448
- PathDrawer.drawPathByData(drawer, data)
449
- } else {
450
- this.__drawPathByBox(drawer)
451
- }
447
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer)
452
448
  }
453
449
 
454
450
  public __drawPathByBox(drawer: IPathDrawer): void {
@@ -456,9 +452,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
456
452
  if (this.__.cornerRadius) {
457
453
  const { cornerRadius } = this.__
458
454
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius) // 修复微信浏览器bug, 后续需进一步优化
459
- } else {
460
- drawer.rect(x, y, width, height)
461
- }
455
+ } else drawer.rect(x, y, width, height)
462
456
  }
463
457
 
464
458
  // @leafer-in/animate rewrite
@@ -476,9 +470,9 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
476
470
  return Export.export(this, filename, options)
477
471
  }
478
472
 
479
- public clone(newData?: IUIInputData): IUI {
473
+ public clone(data?: IUIInputData): IUI {
480
474
  const json = this.toJSON()
481
- if (newData) Object.assign(json, newData)
475
+ if (data) Object.assign(json, data)
482
476
  return UI.one(json)
483
477
  }
484
478
 
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
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, 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';
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, 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, 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;
@@ -132,7 +132,7 @@ declare class UI extends Leaf implements IUI {
132
132
  animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation, _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
133
133
  killAnimate(_type?: IAnimateType): void;
134
134
  export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
135
- clone(newData?: IUIInputData): IUI;
135
+ clone(data?: IUIInputData): IUI;
136
136
  static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
137
137
  static registerUI(): void;
138
138
  static registerData(data: IUIData): void;
@@ -153,12 +153,12 @@ declare class Group extends UI implements IGroup {
153
153
  set(data: IUIInputData, isTemp?: boolean): void;
154
154
  toJSON(options?: IJSONOptions): IUIJSONData;
155
155
  pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult;
156
- addAt(child: IUI, index: number): void;
157
- addAfter(child: IUI, after: IUI): void;
158
- addBefore(child: IUI, before: IUI): void;
159
- add(_child: IUI, _index?: number): void;
160
- addMany(..._children: IUI[]): void;
161
- remove(_child?: IUI, _destroy?: boolean): void;
156
+ addAt(child: IUI | IUIInputData, index: number): void;
157
+ addAfter(child: IUI | IUIInputData, after: IUI): void;
158
+ addBefore(child: IUI | IUIInputData, before: IUI): void;
159
+ add(_child: IUI | IUIInputData, _index?: number): void;
160
+ addMany(..._children: IUI[] | IUIInputData[]): void;
161
+ remove(_child?: IUI | number | string | IFindCondition$1 | IFindUIMethod, _destroy?: boolean): void;
162
162
  removeAll(_destroy?: boolean): void;
163
163
  clear(): void;
164
164
  }
@@ -259,6 +259,7 @@ declare class Box extends Group implements IBox {
259
259
  get isBranchLeaf(): boolean;
260
260
  __: IBoxData;
261
261
  resizeChildren?: IBoolean;
262
+ textBox?: IBoolean;
262
263
  overflow?: IOverflow;
263
264
  isOverflow: boolean;
264
265
  constructor(data?: IBoxInputData);
@@ -266,7 +267,7 @@ declare class Box extends Group implements IBox {
266
267
  __updateRectRenderSpread(): number;
267
268
  __updateRenderSpread(): number;
268
269
  __updateRectBoxBounds(): void;
269
- __updateBoxBounds(secondLayout?: boolean): void;
270
+ __updateBoxBounds(_secondLayout?: boolean): void;
270
271
  __updateStrokeBounds(): void;
271
272
  __updateRenderBounds(): void;
272
273
  __updateRectRenderBounds(): void;
@@ -394,6 +395,7 @@ declare class Text extends UI implements IText {
394
395
  paraSpacing?: INumber;
395
396
  textAlign?: ITextAlign;
396
397
  verticalAlign?: IVerticalAlign;
398
+ autoSizeAlign?: IBoolean;
397
399
  textWrap?: ITextWrap;
398
400
  textOverflow?: IOverflow | string;
399
401
  get editInner(): string;