@leafer-ui/display 1.0.0-rc.5 → 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.5",
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.5",
26
- "@leafer-ui/data": "1.0.0-rc.5",
27
- "@leafer-ui/display-module": "1.0.0-rc.5",
28
- "@leafer-ui/decorator": "1.0.0-rc.5",
29
- "@leafer-ui/external": "1.0.0-rc.5"
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.5",
33
- "@leafer-ui/interface": "1.0.0-rc.5"
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
@@ -52,7 +52,7 @@ export class Ellipse extends UI implements IEllipse {
52
52
  }
53
53
 
54
54
  // fix node
55
- if (Platform.name === 'node') this.__.path = PathConvert.toCanvasData(path, true)
55
+ if (Platform.ellipseToCurve) this.__.path = PathConvert.toCanvasData(path, true)
56
56
 
57
57
  } else {
58
58
 
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,4 +1,4 @@
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
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'
@@ -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,6 +200,8 @@ export class UI extends Leaf implements IUI {
195
200
  }
196
201
 
197
202
 
203
+ // data
204
+
198
205
  @rewrite(Leaf.prototype.reset)
199
206
  public reset(_data?: IUIInputData): void { }
200
207
 
@@ -203,11 +210,26 @@ export class UI extends Leaf implements IUI {
203
210
  Object.assign(this, data)
204
211
  }
205
212
 
206
- public get(): IUIInputData {
207
- return this.__.__getInputData()
213
+ public get(options?: ILeafDataOptions): IUIInputData {
214
+ return this.__.__getInputData(options)
215
+ }
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
208
228
  }
209
229
 
210
230
 
231
+ // path
232
+
211
233
  public getPath(curve?: boolean): IPathCommandData {
212
234
  const path = this.__.path
213
235
  if (!path) return []
@@ -247,6 +269,9 @@ export class UI extends Leaf implements IUI {
247
269
  @rewrite(PathDrawer.drawPathByData)
248
270
  public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
249
271
 
272
+
273
+ // create
274
+
250
275
  public export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult> {
251
276
  return Export.export(this, filename, options)
252
277
  }
@@ -259,6 +284,7 @@ export class UI extends Leaf implements IUI {
259
284
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as IUI
260
285
  }
261
286
 
287
+
262
288
  public destroy(): void {
263
289
  this.fill = this.stroke = null
264
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, 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;
@@ -53,7 +55,10 @@ declare class UI extends Leaf implements IUI {
53
55
  get scale(): __Number | IPointData;
54
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);