@leafer-ui/display 1.0.0-rc.4 → 1.0.0-rc.6

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.4",
3
+ "version": "1.0.0-rc.6",
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.4",
26
- "@leafer-ui/data": "1.0.0-rc.4",
27
- "@leafer-ui/display-module": "1.0.0-rc.4",
28
- "@leafer-ui/decorator": "1.0.0-rc.4",
29
- "@leafer-ui/external": "1.0.0-rc.4"
25
+ "@leafer/core": "1.0.0-rc.6",
26
+ "@leafer-ui/data": "1.0.0-rc.6",
27
+ "@leafer-ui/display-module": "1.0.0-rc.6",
28
+ "@leafer-ui/decorator": "1.0.0-rc.6",
29
+ "@leafer-ui/external": "1.0.0-rc.6"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.0.0-rc.4",
33
- "@leafer-ui/interface": "1.0.0-rc.4"
32
+ "@leafer/interface": "1.0.0-rc.6",
33
+ "@leafer-ui/interface": "1.0.0-rc.6"
34
34
  }
35
35
  }
package/src/Ellipse.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { __Number } from '@leafer/interface'
2
- import { PathCommandDataHelper, dataProcessor, pathType, registerUI } from '@leafer/core'
2
+ import { PathCommandDataHelper, PathConvert, Platform, dataProcessor, pathType, registerUI } from '@leafer/core'
3
3
 
4
4
  import { IEllipse, IEllipseInputData, IEllipseData } from '@leafer-ui/interface'
5
5
  import { EllipseData } from '@leafer-ui/data'
@@ -48,9 +48,12 @@ export class Ellipse extends UI implements IEllipse {
48
48
  ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius)
49
49
  moveTo(path, width, ry)
50
50
  }
51
- ellipse(path, rx, ry, rx, ry, 0, 0, 360, true)
51
+ ellipse(path, rx, ry, rx, ry, 0, 360, 0, true)
52
52
  }
53
53
 
54
+ // fix node
55
+ if (Platform.ellipseToCurve) this.__.path = PathConvert.toCanvasData(path, true)
56
+
54
57
  } else {
55
58
 
56
59
  if (startAngle || endAngle) {
package/src/Group.ts CHANGED
@@ -47,7 +47,11 @@ export class Group extends UI implements IGroup {
47
47
  const { children } = data
48
48
  delete data.children
49
49
 
50
- if (!this.children) this.__setBranch()
50
+ if (!this.children) {
51
+ this.__setBranch()
52
+ } else {
53
+ this.removeAll(true)
54
+ }
51
55
 
52
56
  super.set(data)
53
57
 
package/src/Text.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, __Boolean, __Number, __String } from '@leafer/interface'
2
- import { BoundsHelper, boundsType, dataProcessor, registerUI, affectStrokeBoundsType } from '@leafer/core'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, __Boolean, __Number, __String, IBoundsData } from '@leafer/interface'
2
+ import { BoundsHelper, boundsType, dataProcessor, registerUI, affectStrokeBoundsType, hitType } from '@leafer/core'
3
3
 
4
- import { IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IUnitData, IStrokeAlign } from '@leafer-ui/interface'
4
+ import { IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IUnitData, 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 } = BoundsHelper
12
+ const { copyAndSpread, includes, spread, setByList } = BoundsHelper
13
13
 
14
14
  @registerUI()
15
15
  export class Text extends UI implements IText {
@@ -32,6 +32,9 @@ export class Text extends UI implements IText {
32
32
  @affectStrokeBoundsType('outside')
33
33
  declare public strokeAlign: IStrokeAlign
34
34
 
35
+ @hitType('all')
36
+ declare public hitFill: IHitType
37
+
35
38
  @boundsType('')
36
39
  public text: __String
37
40
 
@@ -71,6 +74,9 @@ export class Text extends UI implements IText {
71
74
  @boundsType('top')
72
75
  public verticalAlign: IVerticalAlign
73
76
 
77
+ @boundsType('normal')
78
+ public textWrap: ITextWrap
79
+
74
80
  @boundsType('show')
75
81
  public textOverflow: IOverflow | string
76
82
 
@@ -114,7 +120,10 @@ export class Text extends UI implements IText {
114
120
 
115
121
  const data = this.__
116
122
  const layout = this.__layout
117
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data
123
+ const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data
124
+
125
+ const width = data.__getInput('width')
126
+ const height = data.__getInput('height')
118
127
 
119
128
  // compute
120
129
 
@@ -122,6 +131,7 @@ export class Text extends UI implements IText {
122
131
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize)
123
132
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2
124
133
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`
134
+ data.__clipText = textOverflow !== 'show' && (width || height)
125
135
 
126
136
  this.__updateTextDrawData()
127
137
 
@@ -130,9 +140,6 @@ export class Text extends UI implements IText {
130
140
 
131
141
  if (data.__lineHeight < fontSize) spread(bounds, fontSize / 2)
132
142
 
133
- const width = data.__getInput('width')
134
- const height = data.__getInput('height')
135
-
136
143
  if (width && height) {
137
144
  super.__updateBoxBounds()
138
145
  } else {
@@ -147,6 +154,9 @@ export class Text extends UI implements IText {
147
154
  if (contentBounds !== layout.contentBounds) {
148
155
  layout.contentBounds = contentBounds
149
156
  layout.renderChanged = true
157
+ setByList(data.__textBoxBounds = {} as IBoundsData, [b, bounds])
158
+ } else {
159
+ data.__textBoxBounds = contentBounds
150
160
  }
151
161
 
152
162
  }
@@ -158,7 +168,7 @@ export class Text extends UI implements IText {
158
168
  }
159
169
 
160
170
  public __updateRenderBounds(): void {
161
- copyAndSpread(this.__layout.renderBounds, this.__layout.contentBounds, this.__layout.renderSpread)
171
+ copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread)
162
172
  }
163
173
 
164
174
  }
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, __Number, __Boolean, __String, IPathString, IExportFileType, IPointData, ICursorType, IAround } from '@leafer/interface'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, __Number, __Boolean, __String, IPathString, IExportFileType, IPointData, ICursorType, IAround, ILeafDataOptions, IFindMethod } from '@leafer/interface'
2
2
  import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType } from '@leafer/core'
3
3
 
4
- import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IUIBaseInputData, IExportOptions, IExportResult } from '@leafer-ui/interface'
4
+ import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult } from '@leafer-ui/interface'
5
5
  import { effectType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -19,6 +19,8 @@ export class UI extends Leaf implements IUI {
19
19
  @dataProcessor(UIData)
20
20
  declare public __: IUIData
21
21
 
22
+ declare public proxyData?: IUIInputData
23
+
22
24
  declare public parent?: IGroup
23
25
 
24
26
  // ---
@@ -107,6 +109,9 @@ export class UI extends Leaf implements IUI {
107
109
  @strokeType('path')
108
110
  public hitStroke: IHitType
109
111
 
112
+ @hitType(false)
113
+ public hitBox: __Boolean
114
+
110
115
  @hitType(true)
111
116
  public hitChildren: __Boolean
112
117
 
@@ -195,19 +200,35 @@ export class UI extends Leaf implements IUI {
195
200
  }
196
201
 
197
202
 
198
- constructor(data?: IUIBaseInputData) {
199
- super(data)
200
- }
203
+ // data
204
+
205
+ @rewrite(Leaf.prototype.reset)
206
+ public reset(_data?: IUIInputData): void { }
201
207
 
202
208
 
203
209
  public set(data: IUIInputData): void {
204
210
  Object.assign(this, data)
205
211
  }
206
212
 
207
- public get(): IUIInputData {
208
- return this.__.__getInputData()
213
+ public get(options?: ILeafDataOptions): IUIInputData {
214
+ return this.__.__getInputData(options)
209
215
  }
210
216
 
217
+ public getProxyData(): IUIInputData { return undefined }
218
+
219
+
220
+ // find
221
+
222
+ public find(condition: number | string | IFindMethod): IUI[] {
223
+ return this.leafer ? this.leafer.selector.getBy(condition, this) as IUI[] : []
224
+ }
225
+
226
+ public findOne(condition: number | string | IFindMethod): IUI {
227
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true) as IUI : null
228
+ }
229
+
230
+
231
+ // path
211
232
 
212
233
  public getPath(curve?: boolean): IPathCommandData {
213
234
  const path = this.__.path
@@ -248,6 +269,9 @@ export class UI extends Leaf implements IUI {
248
269
  @rewrite(PathDrawer.drawPathByData)
249
270
  public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
250
271
 
272
+
273
+ // create
274
+
251
275
  public export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult> {
252
276
  return Export.export(this, filename, options)
253
277
  }
@@ -260,6 +284,7 @@ export class UI extends Leaf implements IUI {
260
284
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as IUI
261
285
  }
262
286
 
287
+
263
288
  public destroy(): void {
264
289
  this.fill = this.stroke = null
265
290
  super.destroy()
package/types/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { __String, __Number, __Boolean, IAround, IHitType, ICursorType, IPointData, IPathCommandData, IPathString, ILeaferCanvas, IPathDrawer, IExportFileType, IRenderOptions, ILeaferImage, ICanvasContext2D, IWindingRule } from '@leafer/interface';
1
+ import { __String, __Number, __Boolean, IAround, IHitType, ICursorType, IPointData, ILeafDataOptions, IFindMethod, IPathCommandData, IPathString, ILeaferCanvas, IPathDrawer, IExportFileType, IRenderOptions, ILeaferImage, ICanvasContext2D, IWindingRule } from '@leafer/interface';
2
2
  import { Leaf } from '@leafer/core';
3
- import { IUI, IUIData, IGroup, IBlendMode, IPaint, IPaintString, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IUIBaseInputData, IUIInputData, IExportOptions, IExportResult, IGroupData, IGroupInputData, 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, IFontWeight, ITextCase, ITextDecoration, IUnitData, ITextAlign, IVerticalAlign, ITextDrawData, ITextInputData, IPath, IPathData, IPathString as IPathString$1, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData } from '@leafer-ui/interface';
3
+ import { IUI, IUIData, IUIInputData, IGroup, IBlendMode, IPaint, IPaintString, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IExportOptions, IExportResult, IGroupData, IGroupInputData, 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, IPathString as IPathString$1, 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;
7
+ proxyData?: IUIInputData;
7
8
  parent?: IGroup;
8
9
  id: __String;
9
10
  name: __String;
@@ -29,6 +30,7 @@ declare class UI extends Leaf implements IUI {
29
30
  hittable: __Boolean;
30
31
  hitFill: IHitType;
31
32
  hitStroke: IHitType;
33
+ hitBox: __Boolean;
32
34
  hitChildren: __Boolean;
33
35
  hitSelf: __Boolean;
34
36
  hitRadius: __Number;
@@ -51,9 +53,12 @@ declare class UI extends Leaf implements IUI {
51
53
  grayscale: __Number | IGrayscaleEffect;
52
54
  set scale(value: __Number | IPointData);
53
55
  get scale(): __Number | IPointData;
54
- constructor(data?: IUIBaseInputData);
56
+ reset(_data?: IUIInputData): void;
55
57
  set(data: IUIInputData): void;
56
- get(): IUIInputData;
58
+ get(options?: ILeafDataOptions): IUIInputData;
59
+ getProxyData(): IUIInputData;
60
+ find(condition: number | string | IFindMethod): IUI[];
61
+ findOne(condition: number | string | IFindMethod): IUI;
57
62
  getPath(curve?: boolean): IPathCommandData;
58
63
  getPathString(curve?: boolean): IPathString;
59
64
  __onUpdateSize(): void;
@@ -207,6 +212,7 @@ declare class Text extends UI implements IText {
207
212
  height: __Number;
208
213
  padding: number | number[];
209
214
  strokeAlign: IStrokeAlign;
215
+ hitFill: IHitType$1;
210
216
  text: __String;
211
217
  fontFamily: __String;
212
218
  fontSize: __Number;
@@ -220,6 +226,7 @@ declare class Text extends UI implements IText {
220
226
  paraSpacing: __Number;
221
227
  textAlign: ITextAlign;
222
228
  verticalAlign: IVerticalAlign;
229
+ textWrap: ITextWrap;
223
230
  textOverflow: IOverflow | string;
224
231
  get textDrawData(): ITextDrawData;
225
232
  constructor(data?: ITextInputData);