@leafer-ui/display 1.0.0-rc.22 → 1.0.0-rc.23

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.0-rc.22",
3
+ "version": "1.0.0-rc.23",
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.0-rc.22",
26
- "@leafer-ui/data": "1.0.0-rc.22",
27
- "@leafer-ui/display-module": "1.0.0-rc.22",
28
- "@leafer-ui/decorator": "1.0.0-rc.22",
29
- "@leafer-ui/external": "1.0.0-rc.22"
25
+ "@leafer/core": "1.0.0-rc.23",
26
+ "@leafer-ui/data": "1.0.0-rc.23",
27
+ "@leafer-ui/display-module": "1.0.0-rc.23",
28
+ "@leafer-ui/decorator": "1.0.0-rc.23",
29
+ "@leafer-ui/external": "1.0.0-rc.23"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.0.0-rc.22",
33
- "@leafer-ui/interface": "1.0.0-rc.22"
32
+ "@leafer/interface": "1.0.0-rc.23",
33
+ "@leafer-ui/interface": "1.0.0-rc.23"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -49,6 +49,7 @@ export class Box extends Group implements IBox {
49
49
 
50
50
  public __updateBoxBounds(): void {
51
51
  const data = this.__
52
+
52
53
  if (data.__autoSide && this.children.length) {
53
54
  if (this.leafer) this.leafer.layouter.addExtra(this)
54
55
  super.__updateBoxBounds()
@@ -60,6 +61,8 @@ export class Box extends Group implements IBox {
60
61
  } else {
61
62
  this.__updateRectBoxBounds()
62
63
  }
64
+
65
+ if (data.flow) this.__updateContentBounds()
63
66
  }
64
67
 
65
68
  @rewrite(rect.__updateStrokeBounds)
package/src/Leafer.ts CHANGED
@@ -195,10 +195,6 @@ export class Leafer extends Group implements ILeafer {
195
195
  Object.keys(data).forEach(key => (this as any)[key] = data[key])
196
196
  }
197
197
 
198
- public forceFullRender(): void {
199
- this.forceRender()
200
- }
201
-
202
198
  public forceRender(bounds?: IBoundsData): void {
203
199
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds)
204
200
  if (this.viewReady) this.renderer.update()
@@ -280,7 +276,7 @@ export class Leafer extends Group implements ILeafer {
280
276
  if (this.canvas.allowBackgroundColor) {
281
277
  this.canvas.backgroundColor = newValue as string
282
278
  } else {
283
- this.forceFullRender()
279
+ this.forceRender()
284
280
  }
285
281
  }
286
282
 
package/src/Text.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData, IFourNumber } from '@leafer/interface'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData, IUnitData } from '@leafer/interface'
2
2
  import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, hitType, MathHelper } from '@leafer/core'
3
3
 
4
- import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IUnitData, IStrokeAlign, IHitType, ITextWrap } from '@leafer-ui/interface'
4
+ import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IStrokeAlign, IHitType, ITextWrap } from '@leafer-ui/interface'
5
5
  import { TextData, UnitConvert } from '@leafer-ui/data'
6
6
 
7
7
  import { TextConvert } from '@leafer-ui/external'
@@ -9,7 +9,7 @@ import { TextConvert } from '@leafer-ui/external'
9
9
  import { UI } from './UI'
10
10
 
11
11
 
12
- const { copyAndSpread, includes, spread, setList } = BoundsHelper
12
+ const { copyAndSpread, includes, isSame, spread, setList } = BoundsHelper
13
13
 
14
14
  @registerUI()
15
15
  export class Text extends UI implements IText {
@@ -26,9 +26,6 @@ export class Text extends UI implements IText {
26
26
  @boundsType(0)
27
27
  declare public height: INumber
28
28
 
29
- @boundsType(0)
30
- public padding: IFourNumber
31
-
32
29
  @surfaceType('#000000')
33
30
  declare public fill: IFill
34
31
 
@@ -172,7 +169,7 @@ export class Text extends UI implements IText {
172
169
  if (italic) b.width += fontSize * 0.16
173
170
 
174
171
  const contentBounds = includes(b, bounds) ? b : bounds
175
- if (contentBounds !== layout.contentBounds) {
172
+ if (!isSame(contentBounds, layout.contentBounds)) {
176
173
  layout.contentBounds = contentBounds
177
174
  layout.renderChanged = true
178
175
  setList(data.__textBoxBounds = {} as IBoundsData, [b, bounds])
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IAround, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData } from '@leafer/interface'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData } from '@leafer/interface'
2
2
  import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType } 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, IEditSize, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction } 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 } from '@leafer-ui/interface'
5
5
  import { arrowType, effectType, stateType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -72,13 +72,13 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
72
72
 
73
73
 
74
74
  @maskType(false)
75
- public mask: IBoolean
75
+ public mask: IMaskType
76
76
 
77
- @surfaceType('pixel')
77
+ @surfaceType('pixel') // will remove
78
78
  public maskType: IMaskType
79
79
 
80
80
  @eraserType(false)
81
- public eraser: IBoolean
81
+ public eraser: IEraserType
82
82
 
83
83
 
84
84
  // position
@@ -114,12 +114,91 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
114
114
  public skewY: INumber
115
115
 
116
116
 
117
+ // offset
118
+ @positionType(0, true)
119
+ public offsetX: INumber
120
+
121
+ @positionType(0, true)
122
+ public offsetY: INumber
123
+
124
+ // scroll
125
+ @positionType(0, true)
126
+ public scrollX: INumber
127
+
128
+ @positionType(0, true)
129
+ public scrollY: INumber
130
+
131
+
132
+ // center
117
133
  @autoLayoutType()
118
- public around: IAround
134
+ public origin: IAlign | IUnitPointData
135
+
136
+ @autoLayoutType()
137
+ public around: IAlign | IUnitPointData
119
138
 
120
139
 
140
+ // image
121
141
  @dataType(false)
122
- public draggable: IBoolean | 'x' | 'y'
142
+ public lazy: IBoolean // load image / compute paint
143
+
144
+ @naturalBoundsType(1)
145
+ public pixelRatio: INumber
146
+
147
+
148
+ // path
149
+ @pathInputType()
150
+ public path: IPathCommandData | IPathString
151
+
152
+ @pathType()
153
+ public windingRule: IWindingRule
154
+
155
+ @pathType(true)
156
+ public closed: boolean
157
+
158
+
159
+ // auto layout
160
+ @autoLayoutType(false)
161
+ public flow: IFlowType
162
+
163
+ @boundsType(0)
164
+ public padding: IFourNumber
165
+
166
+ @boundsType(0)
167
+ public gap: IGap | IPointGap
168
+
169
+ @boundsType('top-left')
170
+ public align: IFlowAlign | IFlowAxisAlign
171
+
172
+ @boundsType(false)
173
+ public wrap: IWrap
174
+
175
+ @boundsType('box')
176
+ public itemBox: IFlowBoxType
177
+
178
+
179
+ @boundsType(true)
180
+ public inFlow: IBoolean
181
+
182
+ @boundsType() // rewrite in flow
183
+ public autoWidth: IAutoSize
184
+
185
+ @boundsType() // rewrite in flow
186
+ public autoHeight: IAutoSize
187
+
188
+ @boundsType()
189
+ public autoBox: IAutoBoxData | IConstraint
190
+
191
+
192
+ @boundsType()
193
+ public widthRange: IRangeSize
194
+
195
+ @boundsType()
196
+ public heightRange: IRangeSize
197
+
198
+
199
+ // drag
200
+ @dataType(false)
201
+ public draggable: IBoolean | IAxis
123
202
 
124
203
  @dataType()
125
204
  public dragBounds?: IBoundsData | 'parent'
@@ -128,9 +207,6 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
128
207
  @dataType(false)
129
208
  public editable: IBoolean
130
209
 
131
- @dataType('size')
132
- public editSize?: IEditSize
133
-
134
210
 
135
211
  // hit
136
212
  @hitType(true)
@@ -194,25 +270,6 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
194
270
  @strokeType(10)
195
271
  public miterLimit: INumber
196
272
 
197
- // image
198
-
199
- @dataType(false)
200
- public lazy: IBoolean // load image / compute paint
201
-
202
- @naturalBoundsType(1)
203
- public pixelRatio: INumber
204
-
205
- // path
206
-
207
- @pathInputType()
208
- public path: IPathCommandData | IPathString
209
-
210
- @pathType()
211
- public windingRule: IWindingRule
212
-
213
- @pathType(true)
214
- public closed: boolean
215
-
216
273
 
217
274
  // arrow
218
275
 
@@ -322,9 +379,13 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
322
379
 
323
380
  // hit rewrite
324
381
 
325
- public find(_condition: number | string | IFindUIMethod, _options?: any): IUI[] { return undefined }
382
+ public find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[] { return undefined }
383
+
384
+ public findTag(tag: string | string[]): IUI[] { return this.find({ tag }) }
385
+
386
+ public findOne(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI { return undefined }
326
387
 
327
- public findOne(_condition: number | string | IFindUIMethod, _options?: any): IUI { return undefined }
388
+ public findId(id: number | string): IUI { return this.findOne({ id }) }
328
389
 
329
390
 
330
391
  // path
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IString, INumber, IBoolean, IMaskType, IAround, IBoundsData, IHitType, ICursorType, IFourNumber, IPathCommandData, IPathString, IWindingRule, IPointData, IPathCreator, IValue, ILeaferCanvas, IPathDrawer, IExportFileType, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IObject, IZoomType, IRenderOptions, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
1
+ import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, IExportFileType, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IObject, IZoomType, IRenderOptions, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D, IUnitData } from '@leafer/interface';
2
2
  import { Leaf, LeafList } 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, IEditorConfig, IFindUIMethod, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, 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, 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, IEditorConfig, IFindUIMethod, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, 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, 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;
@@ -22,9 +22,9 @@ declare class UI extends Leaf implements IUI {
22
22
  disabled: IBoolean;
23
23
  locked: IBoolean;
24
24
  zIndex: INumber;
25
- mask: IBoolean;
25
+ mask: IMaskType;
26
26
  maskType: IMaskType;
27
- eraser: IBoolean;
27
+ eraser: IEraserType;
28
28
  x: INumber;
29
29
  y: INumber;
30
30
  width: INumber;
@@ -34,11 +34,32 @@ declare class UI extends Leaf implements IUI {
34
34
  rotation: INumber;
35
35
  skewX: INumber;
36
36
  skewY: INumber;
37
- around: IAround;
38
- draggable: IBoolean | 'x' | 'y';
37
+ offsetX: INumber;
38
+ offsetY: INumber;
39
+ scrollX: INumber;
40
+ scrollY: INumber;
41
+ origin: IAlign | IUnitPointData;
42
+ around: IAlign | IUnitPointData;
43
+ lazy: IBoolean;
44
+ pixelRatio: INumber;
45
+ path: IPathCommandData | IPathString;
46
+ windingRule: IWindingRule;
47
+ closed: boolean;
48
+ flow: IFlowType;
49
+ padding: IFourNumber;
50
+ gap: IGap | IPointGap;
51
+ align: IFlowAlign | IFlowAxisAlign;
52
+ wrap: IWrap;
53
+ itemBox: IFlowBoxType;
54
+ inFlow: IBoolean;
55
+ autoWidth: IAutoSize;
56
+ autoHeight: IAutoSize;
57
+ autoBox: IAutoBoxData | IConstraint;
58
+ widthRange: IRangeSize;
59
+ heightRange: IRangeSize;
60
+ draggable: IBoolean | IAxis;
39
61
  dragBounds?: IBoundsData | 'parent';
40
62
  editable: IBoolean;
41
- editSize?: IEditSize;
42
63
  hittable: IBoolean;
43
64
  hitFill: IHitType;
44
65
  hitStroke: IHitType;
@@ -57,11 +78,6 @@ declare class UI extends Leaf implements IUI {
57
78
  dashPattern: INumber[] | IDashPatternString;
58
79
  dashOffset: INumber;
59
80
  miterLimit: INumber;
60
- lazy: IBoolean;
61
- pixelRatio: INumber;
62
- path: IPathCommandData | IPathString;
63
- windingRule: IWindingRule;
64
- closed: boolean;
65
81
  startArrow: IArrowType;
66
82
  endArrow: IArrowType;
67
83
  cornerRadius: IFourNumber | ICornerRadiusString;
@@ -88,8 +104,10 @@ declare class UI extends Leaf implements IUI {
88
104
  set(data: IUIInputData): void;
89
105
  get(name?: string | string[] | IUIInputData): IUIInputData | IValue;
90
106
  createProxyData(): IUIInputData;
91
- find(_condition: number | string | IFindUIMethod, _options?: any): IUI[];
92
- findOne(_condition: number | string | IFindUIMethod, _options?: any): IUI;
107
+ find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[];
108
+ findTag(tag: string | string[]): IUI[];
109
+ findOne(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI;
110
+ findId(id: number | string): IUI;
93
111
  getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
94
112
  getPathString(curve?: boolean, pathForRender?: boolean): IPathString;
95
113
  __onUpdateSize(): void;
@@ -182,7 +200,6 @@ declare class Leafer extends Group implements ILeafer {
182
200
  unlockLayout(): void;
183
201
  lockLayout(): void;
184
202
  resize(size: IScreenSizeData): void;
185
- forceFullRender(): void;
186
203
  forceRender(bounds?: IBoundsData): void;
187
204
  updateCursor(cursor?: ICursorType): void;
188
205
  updateLazyBounds(): void;
@@ -335,7 +352,6 @@ declare class Text extends UI implements IText {
335
352
  __: ITextData;
336
353
  width: INumber;
337
354
  height: INumber;
338
- padding: IFourNumber;
339
355
  fill: IFill;
340
356
  strokeAlign: IStrokeAlign;
341
357
  hitFill: IHitType$1;