@leafer-ui/interface 1.0.0-rc.9 → 1.0.0

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/interface",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.0",
4
4
  "description": "@leafer-ui/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,6 +22,6 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/interface": "1.0.0-rc.9"
25
+ "@leafer/interface": "1.0.0"
26
26
  }
27
27
  }
@@ -1,15 +1,17 @@
1
- import { IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign, IOverflow, IUnitData, ITextWrap, IStroke, IFill, IArrowType } from './type/IType'
1
+ import { INumber, IBoolean, IString, IFourNumber, IUnitData } from '@leafer/interface'
2
+ import { IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign, IOverflow, ITextWrap, IStroke, IFill, IArrowType } from './type/IType'
2
3
  import { ILeafStrokePaint, ILeafShadowEffect, ILeafPaint } from './type/IComputedType'
3
4
  import { IDashPatternString, IShadowString, IColorString, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
4
5
 
6
+
5
7
  // corner---
6
8
  export interface ICornerRadiusAttrData {
7
- cornerRadius: number | number[] | ICornerRadiusString
8
- cornerSmoothing: number
9
+ cornerRadius?: IFourNumber | ICornerRadiusString
10
+ cornerSmoothing?: INumber
9
11
  }
10
12
  export interface ICornerRadiusInputData {
11
- cornerRadius?: number | number[] | ICornerRadiusString
12
- cornerSmoothing?: number
13
+ cornerRadius?: IFourNumber | ICornerRadiusString
14
+ cornerSmoothing?: INumber
13
15
  }
14
16
  export interface ICornerRadiusComputedData {
15
17
  cornerRadius?: number
@@ -18,7 +20,7 @@ export interface ICornerRadiusComputedData {
18
20
 
19
21
  // fill---
20
22
  export interface IFillAttrData {
21
- fill: IFill
23
+ fill?: IFill
22
24
  }
23
25
  export interface IFillInputData {
24
26
  fill?: IFill
@@ -35,29 +37,31 @@ export interface IBorderComputedData {
35
37
 
36
38
  // stroke---
37
39
  export interface IStrokeAttrData {
38
- stroke: IStroke
40
+ stroke?: IStroke
39
41
 
40
- strokeAlign: IStrokeAlign
41
- strokeWidth: number | number[] | IStrokeWidthString
42
- strokeCap: IStrokeCap
43
- strokeJoin: IStrokeJoin
44
- dashPattern: number[] | IDashPatternString
45
- dashOffset: number
46
- miterLimit: number
42
+ strokeAlign?: IStrokeAlign
43
+ strokeWidth?: IFourNumber | IStrokeWidthString
44
+ strokeWidthFixed?: IBoolean
45
+ strokeCap?: IStrokeCap
46
+ strokeJoin?: IStrokeJoin
47
+ dashPattern?: INumber[] | IDashPatternString
48
+ dashOffset?: INumber
49
+ miterLimit?: INumber
47
50
 
48
- startArrow: IArrowType
49
- endArrow: IArrowType
51
+ startArrow?: IArrowType
52
+ endArrow?: IArrowType
50
53
  }
51
54
  export interface IStrokeInputData {
52
55
  stroke?: IStroke
53
56
 
54
57
  strokeAlign?: IStrokeAlign
55
- strokeWidth?: number | number[] | IStrokeWidthString
58
+ strokeWidth?: IFourNumber | IStrokeWidthString
59
+ strokeWidthFixed?: IBoolean
56
60
  strokeCap?: IStrokeCap
57
61
  strokeJoin?: IStrokeJoin
58
- dashPattern?: number[] | IDashPatternString
59
- dashOffset?: number
60
- miterLimit?: number
62
+ dashPattern?: INumber[] | IDashPatternString
63
+ dashOffset?: INumber
64
+ miterLimit?: INumber
61
65
 
62
66
  startArrow?: IArrowType
63
67
  endArrow?: IArrowType
@@ -68,45 +72,49 @@ export interface IStrokeComputedData {
68
72
  strokeAlign?: IStrokeAlign
69
73
  strokeWidth?: number
70
74
  strokeWidths?: number[]
75
+ strokeWidthFixed?: boolean
71
76
  strokeCap?: IStrokeCap
72
77
  strokeJoin?: IStrokeJoin
73
78
  dashPattern?: number[]
74
79
  dashOffset?: number
75
80
  miterLimit?: number
81
+
82
+ startArrow?: IArrowType
83
+ endArrow?: IArrowType
76
84
  }
77
85
 
78
86
  // text---
79
87
  export interface ITextStyleAttrData {
80
- fontFamily: string
81
- fontSize: number
82
- fontWeight: IFontWeight
83
- italic: boolean
84
- textCase: ITextCase
85
- textDecoration: ITextDecoration
86
- letterSpacing: number | IUnitData
87
- lineHeight: number | IUnitData
88
+ fontFamily?: IString
89
+ fontSize?: INumber
90
+ fontWeight?: IFontWeight
91
+ italic?: IBoolean
92
+ textCase?: ITextCase
93
+ textDecoration?: ITextDecoration
94
+ letterSpacing?: INumber | IUnitData
95
+ lineHeight?: INumber | IUnitData
88
96
 
89
- paraIndent: number
90
- paraSpacing: number
97
+ paraIndent?: INumber
98
+ paraSpacing?: INumber
91
99
 
92
- textAlign: ITextAlign
93
- verticalAlign: IVerticalAlign
100
+ textAlign?: ITextAlign
101
+ verticalAlign?: IVerticalAlign
94
102
 
95
- textWrap: ITextWrap
96
- textOverflow: IOverflow | string
103
+ textWrap?: ITextWrap
104
+ textOverflow?: IOverflow | string
97
105
  }
98
106
  export interface ITextStyleInputData {
99
- fontFamily?: string
100
- fontSize?: number
107
+ fontFamily?: IString
108
+ fontSize?: INumber
101
109
  fontWeight?: IFontWeight
102
- italic?: boolean
110
+ italic?: IBoolean
103
111
  textCase?: ITextCase
104
112
  textDecoration?: ITextDecoration
105
- letterSpacing?: number | IUnitData
106
- lineHeight?: number | IUnitData
113
+ letterSpacing?: INumber | IUnitData
114
+ lineHeight?: INumber | IUnitData
107
115
 
108
- paraIndent?: number
109
- paraSpacing?: number
116
+ paraIndent?: INumber
117
+ paraSpacing?: INumber
110
118
 
111
119
  textAlign?: ITextAlign
112
120
  verticalAlign?: IVerticalAlign
@@ -136,18 +144,18 @@ export interface ITextStyleComputedData {
136
144
 
137
145
  // effect---
138
146
  export interface IEffectAttrData {
139
- shadow: IShadowEffect | IShadowEffect[] | IShadowString
140
- innerShadow: IShadowEffect | IShadowEffect[] | IShadowString
141
- blur: number | IBlurEffect
142
- backgroundBlur: number | IBlurEffect
143
- grayscale: number | IGrayscaleEffect
147
+ shadow?: IShadowEffect | IShadowEffect[] | IShadowString
148
+ innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString
149
+ blur?: INumber | IBlurEffect
150
+ backgroundBlur?: INumber | IBlurEffect
151
+ grayscale?: INumber | IGrayscaleEffect
144
152
  }
145
153
  export interface IEffectInputData {
146
154
  shadow?: IShadowEffect | IShadowEffect[] | IShadowString
147
155
  innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString
148
- blur?: number | IBlurEffect
149
- backgroundBlur?: number | IBlurEffect
150
- grayscale?: number | IGrayscaleEffect
156
+ blur?: INumber | IBlurEffect
157
+ backgroundBlur?: INumber | IBlurEffect
158
+ grayscale?: INumber | IGrayscaleEffect
151
159
  }
152
160
  export interface IEffectComputedData {
153
161
  shadow?: ILeafShadowEffect[]
package/src/IUI.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IBlob, IPathCreator, AnswerType } from '@leafer/interface'
1
+ import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IExportOptions, IExportResult, IPathDrawer, IPointData, IPathCommandData, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IPathCreator, IAnswer, IPickOptions, IPickResult, IValue, ICanvasContext2DSettings, IFourNumber, IFindCondition, IBoolean, ICanvasContext2D, IJSONOptions, IMatrixData } from '@leafer/interface'
2
2
 
3
3
  import {
4
4
  IFillAttrData, IFillInputData, IFillComputedData,
@@ -9,16 +9,15 @@ import {
9
9
  ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData
10
10
  } from './ICommonAttr'
11
11
  import { IOverflow } from './type/IType'
12
- import { IExportOptions } from './module/IExport'
13
12
  import { ILeafer } from './app/ILeafer'
14
-
13
+ import { IEditorConfig } from './editor/IEditor'
15
14
 
16
15
  // Line
17
16
  export interface ILine extends IUI {
18
17
  __: ILineData
19
- toPoint: IPointData
20
- points: number[]
21
- curve: boolean | number
18
+ toPoint?: IPointData
19
+ points?: number[]
20
+ curve?: boolean | number
22
21
  }
23
22
 
24
23
  interface ILineAttrData {
@@ -39,7 +38,18 @@ interface IArrowAttrData {
39
38
 
40
39
  }
41
40
  export interface IArrowData extends IArrowAttrData, ILineData { }
42
- export interface IArrowInputData extends IArrowAttrData, IUIBaseInputData { }
41
+ export interface IArrowInputData extends IArrowAttrData, ILineInputData { }
42
+
43
+ // Flow
44
+ export interface IFlow extends IBox {
45
+ __: IFlowData
46
+ }
47
+
48
+ interface IFlowAttrData {
49
+
50
+ }
51
+ export interface IFlowData extends IFlowAttrData, IBoxData { }
52
+ export interface IFlowInputData extends IFlowAttrData, IBoxInputData { }
43
53
 
44
54
 
45
55
  // Rect
@@ -53,9 +63,9 @@ export interface IRectInputData extends IUIBaseInputData { }
53
63
  // Ellipse
54
64
  export interface IEllipse extends IUI {
55
65
  __: IEllipseData
56
- startAngle: number
57
- endAngle: number
58
- innerRadius: number
66
+ startAngle?: number
67
+ endAngle?: number
68
+ innerRadius?: number
59
69
  }
60
70
  interface IEllipseAttrData {
61
71
  startAngle?: number
@@ -69,9 +79,9 @@ export interface IEllipseInputData extends IEllipseAttrData, IUIBaseInputData {
69
79
  // Polygon
70
80
  export interface IPolygon extends IUI {
71
81
  __: IPolygonData
72
- sides: number
73
- points: number[]
74
- curve: boolean | number
82
+ sides?: number
83
+ points?: number[]
84
+ curve?: boolean | number
75
85
  }
76
86
  interface IPolygonAttrData {
77
87
  sides?: number
@@ -85,8 +95,8 @@ export interface IPolygonInputData extends IPolygonAttrData, IUIBaseInputData {
85
95
  // Star
86
96
  export interface IStar extends IUI {
87
97
  __: IStarData
88
- corners: number
89
- innerRadius: number
98
+ corners?: number
99
+ innerRadius?: number
90
100
  }
91
101
  interface IStarAttrData {
92
102
  corners?: number
@@ -99,16 +109,10 @@ export interface IStarInputData extends IStarAttrData, IUIBaseInputData { }
99
109
  // Path
100
110
  export interface IPath extends IUI {
101
111
  __: IPathData
102
- path: IPathCommandData | IPathString
103
- windingRule: IWindingRule
104
112
  }
105
113
  export interface IPathData extends IUIData {
106
- path?: IPathCommandData
107
- windingRule?: IWindingRule
108
114
  }
109
115
  export interface IPathInputData extends IUIBaseInputData {
110
- path?: IPathCommandData | IPathString
111
- windingRule?: IWindingRule
112
116
  }
113
117
 
114
118
  // Pen
@@ -119,7 +123,6 @@ export interface IPen extends IGroup, IPathCreator {
119
123
  pathStyle: IPathInputData
120
124
  path: IPathCommandData
121
125
  paint(): void
122
- clear(): void
123
126
  }
124
127
 
125
128
  export interface IPenData extends IGroupData { }
@@ -129,10 +132,14 @@ export interface IPenInputData extends IGroupInputData { }
129
132
  // Text
130
133
  export interface IText extends ITextStyleAttrData, IUI {
131
134
  __: ITextData
132
- text: string
135
+ text?: string
136
+ padding?: IFourNumber
137
+ resizeFontSize?: IBoolean
133
138
  }
134
139
  interface ITextAttrData {
135
140
  text?: string
141
+ padding?: IFourNumber
142
+ resizeFontSize?: boolean
136
143
  }
137
144
 
138
145
  export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
@@ -208,14 +215,15 @@ export interface IImageInputData extends IImageAttrData, IUIBaseInputData { }
208
215
 
209
216
  export interface ICanvas extends IRect {
210
217
  __: ICanvasData
211
- pixelRatio: number
212
- smooth: boolean
213
- canvas: ILeaferCanvas
218
+ smooth?: boolean
219
+ contextSettings?: ICanvasContext2DSettings
220
+ canvas?: ILeaferCanvas
221
+ context?: ICanvasContext2D
214
222
  __updateSize(): void
215
223
  }
216
224
  interface ICanvasAttrData {
217
- pixelRatio?: number
218
225
  smooth?: boolean
226
+ contextSettings?: ICanvasContext2DSettings
219
227
  }
220
228
  export interface ICanvasData extends ICanvasAttrData, IRectData { }
221
229
  export interface ICanvasInputData extends ICanvasAttrData, IUIBaseInputData { }
@@ -223,11 +231,11 @@ export interface ICanvasInputData extends ICanvasAttrData, IUIBaseInputData { }
223
231
 
224
232
  // Leafer
225
233
  export interface ILeaferData extends IGroupData {
226
- pixelRatio?: number
234
+
227
235
  }
228
236
 
229
237
  export interface ILeaferInputData extends IGroupInputData {
230
- pixelRatio?: number
238
+
231
239
  }
232
240
 
233
241
  export interface IAppData extends ILeaferData {
@@ -252,14 +260,17 @@ export interface IFrameInputData extends IBoxInputData {
252
260
  // Box
253
261
  export interface IBox extends IGroup {
254
262
  __: IBoxData
255
- overflow: IOverflow
263
+ resizeChildren?: IBoolean
264
+ overflow?: IOverflow
256
265
  __updateRectRenderBounds(): void
257
266
  __renderGroup(canvas: ILeaferCanvas, options: IRenderOptions): void
258
267
  }
259
268
  export interface IBoxData extends IGroupData {
269
+ resizeChildren?: boolean
260
270
  overflow?: IOverflow
261
271
  }
262
272
  export interface IBoxInputData extends IGroupInputData {
273
+ resizeChildren?: boolean
263
274
  overflow?: IOverflow
264
275
  }
265
276
 
@@ -268,7 +279,7 @@ export interface IBoxInputData extends IGroupInputData {
268
279
  export interface IGroup extends IUI {
269
280
  __: IGroupData
270
281
  children: IUI[]
271
- mask?: IUI
282
+ pick(hitPoint: IPointData, options?: IPickOptions): IPickResult
272
283
  add(child: IUI, index?: number): void
273
284
  addAt(child: IUI, index: number): void
274
285
  addAfter(child: IUI, after: IUI): void
@@ -276,6 +287,7 @@ export interface IGroup extends IUI {
276
287
  addMany(...children: ILeaf[]): void
277
288
  remove(child?: IUI): void
278
289
  removeAll(): void
290
+ clear(): void
279
291
  }
280
292
  export interface IGroupData extends IUIData { }
281
293
  export interface IGroupInputData extends IUIBaseInputData { }
@@ -287,51 +299,80 @@ export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrDa
287
299
  readonly app: ILeafer
288
300
  leafer?: ILeafer
289
301
  parent?: IGroup
290
- isFrame?: boolean
302
+ zoomLayer?: IGroup
303
+ readonly isFrame?: boolean
291
304
 
292
- proxyData: IUIInputData
305
+ proxyData?: IUIInputData
293
306
  __proxyData?: IUIInputData
294
307
 
308
+ normalStyle?: IUIInputData
309
+ hoverStyle?: IUIInputData
310
+ pressStyle?: IUIInputData
311
+ focusStyle?: IUIInputData
312
+ selectedStyle?: IUIInputData
313
+ disabledStyle?: IUIInputData
314
+
315
+ editConfig?: IEditorConfig
316
+ editOuter: string
317
+ editInner: string
318
+
295
319
  children?: IUI[]
296
320
 
321
+ readonly pen: IPathCreator
322
+
297
323
  reset(data?: IUIInputData): void
298
324
 
299
325
  set(data: IUIInputData): void
300
- toJSON(): IUIInputData
326
+ toJSON(options?: IJSONOptions): IUIJSONData
301
327
 
302
- get(): IUIInputData
328
+ get(name?: string | string[] | IUIInputData): IUIInputData | IValue
303
329
  createProxyData(): IUIInputData
304
330
 
305
- find(condition: number | string | IFindUIMethod, options?: any): IUI[]
306
- findOne(condition: number | string | IFindUIMethod, options?: any): IUI
331
+ find(condition: number | string | IFindCondition | IFindUIMethod, options?: any): IUI[]
332
+ findTag(tag: string | string[]): IUI[]
333
+ findOne(condition: number | string | IFindCondition | IFindUIMethod, options?: any): IUI | undefined
334
+ findId(id: number | string): IUI | undefined
307
335
 
308
336
  getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData
309
337
  getPathString(curve?: boolean, pathForRender?: boolean): IPathString
310
338
 
339
+ load(): void
340
+
311
341
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
312
342
  __drawPathByBox(drawer: IPathDrawer): void
313
343
  __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
314
344
 
315
- export(filename: string, options?: IExportOptions | number): Promise<IBlob | string | boolean>
345
+ export(filename: string, options?: IExportOptions | number | boolean): Promise<IExportResult>
316
346
  clone(): IUI
317
347
  }
318
348
 
319
349
  export interface IFindUIMethod {
320
- (leaf: IUI, options?: any): AnswerType
350
+ (leaf: IUI, options?: any): IAnswer
321
351
  }
322
352
 
323
353
  export interface IUIData extends IUIComputedData, ILeafData {
324
354
 
325
355
  padding?: number | number[]
326
- locked?: boolean
356
+
357
+ normalStyle?: IUIInputData
358
+ hoverStyle?: IUIInputData
359
+ pressStyle?: IUIInputData
360
+ focusStyle?: IUIInputData
361
+ selectedStyle?: IUIInputData
362
+ disabledStyle?: IUIInputData
327
363
 
328
364
  // 非数据属性, 自动计算的缓存数据
329
365
  __isFills?: boolean
330
366
  __isStrokes?: boolean
331
367
 
368
+ readonly __strokeWidth: number
369
+
332
370
  __pixelFill?: boolean // png / svg / webp
333
371
  __pixelStroke?: boolean
334
372
 
373
+ __isHitPixel?: boolean
374
+ __isCanvas?: boolean // canvas 等需单独绘制的元素
375
+
335
376
  __opacityFill?: boolean // 半透明的
336
377
  __opacityStroke?: boolean
337
378
 
@@ -339,35 +380,30 @@ export interface IUIData extends IUIComputedData, ILeafData {
339
380
  __isOverflow?: boolean
340
381
  __blendLayer?: boolean
341
382
 
342
- __useEffect?: boolean
343
-
344
- __autoWidth: boolean
345
- __autoHeight: boolean
346
- __autoBounds: boolean
347
-
348
- // path
349
- path?: IPathCommandData
350
- windingRule?: IWindingRule
351
-
352
- __pathForRender?: IPathCommandData
353
- __path2DForRender?: IPath2D
354
-
355
383
  __boxStroke?: boolean
356
384
 
357
385
  // text
358
386
  __font?: string
359
387
  __textDrawData?: ITextDrawData
360
388
 
389
+ __needComputePaint: boolean
390
+ __computePaint(): void
391
+
361
392
  }
362
393
  export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
363
394
  padding?: number | number[]
364
-
365
- locked?: boolean
366
395
  }
367
396
 
368
397
  export interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
369
398
  padding?: number | number[]
370
- locked?: boolean
399
+
400
+ normalStyle?: IUIInputData
401
+ hoverStyle?: IUIInputData
402
+ pressStyle?: IUIInputData
403
+ focusStyle?: IUIInputData
404
+ selectedStyle?: IUIInputData
405
+ disabledStyle?: IUIInputData
406
+
371
407
  children?: IUIInputData[]
372
408
  }
373
409
 
@@ -392,4 +428,8 @@ export type IUITag =
392
428
 
393
429
  export interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
394
430
  children?: IUIInputData[]
431
+ }
432
+
433
+ export interface IUIJSONData extends IUIInputData {
434
+ matrix?: IMatrixData
395
435
  }
@@ -1,4 +1,4 @@
1
- import { IControl, ILeaferAttrData, ILeaferConfig } from '@leafer/interface'
1
+ import { IControl, ILeaferAttrData, ILeaferConfig, ILeaferType } from '@leafer/interface'
2
2
  import { IApp } from './IApp'
3
3
  import { IGroup } from '../IUI'
4
4
  import { IEditorBase } from '../editor/IEditor'
@@ -15,4 +15,8 @@ export interface ILeafer extends IGroup, ILeaferAttrData, IControl {
15
15
  sky?: ILeafer
16
16
 
17
17
  userConfig?: ILeaferConfig
18
+
19
+ onInit(): void
20
+ initType(type: ILeaferType): void
21
+ destroy(sync?: boolean): void
18
22
  }