@leafer-ui/interface 1.0.0-rc.3 → 1.0.0-rc.30

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.
@@ -0,0 +1,163 @@
1
+ import { IGroup, IUI, IBox, IRectInputData, ISelectorProxy, IEditSize, ICursorType, IAlign, IUnitPointData, IDragEvent, IRotateEvent, IStroke, IFill, ILeaf, ILeafList, IObject, IBoxInputData, IGroupInputData, IImageCursor, IRect, IBoundsData, IKeyEvent, IUIInputData, IZoomEvent, IColorString } from '@leafer-ui/interface'
2
+
3
+ export interface IEditorBase extends IGroup, ISelectorProxy {
4
+ config: IEditorConfig
5
+ readonly mergeConfig: IEditorConfig // 实际使用,合并了选中元素上的editConfig
6
+
7
+ hoverTarget?: IUI
8
+ target?: IUI | IUI[]
9
+
10
+ readonly list: IUI[]
11
+ leafList: ILeafList
12
+ openedGroupList: ILeafList
13
+
14
+ readonly editing: boolean
15
+ innerEditing: boolean
16
+ readonly groupOpening: boolean
17
+
18
+ readonly multiple: boolean
19
+ readonly single: boolean
20
+
21
+ readonly dragging: boolean
22
+
23
+ element?: IUI
24
+ buttons: IGroup
25
+
26
+ selector: IGroup
27
+ editBox: IEditBoxBase
28
+ editTool?: IObject
29
+ innerEditor?: IObject
30
+
31
+ select(target: IUI | IUI[]): void
32
+ cancel(): void
33
+
34
+ hasItem(item: IUI): boolean
35
+ shiftItem(item: IUI): void
36
+ addItem(item: IUI): void
37
+ removeItem(item: IUI): void
38
+
39
+ update(): void
40
+ updateEditBox(): void
41
+ updateEditTool(): void
42
+
43
+ getEditSize(ui: ILeaf): IEditSize
44
+
45
+ onMove(e: IDragEvent): void
46
+ onScale(e: IDragEvent | IZoomEvent): void
47
+ onRotate(e: IDragEvent | IRotateEvent): void
48
+ onSkew(e: IDragEvent): void
49
+
50
+ group(group?: IGroup | IGroupInputData): IGroup
51
+ ungroup(): IUI[]
52
+ openGroup(group: IGroup): void
53
+ closeGroup(group: IGroup): void
54
+
55
+ openInnerEditor(target?: IUI): void
56
+ closeInnerEditor(): void
57
+
58
+ lock(): void
59
+ unlock(): void
60
+
61
+ toTop(): void
62
+ toBottom(): void
63
+ }
64
+
65
+ export interface IEditorConfig {
66
+ editSize?: IEditSize
67
+ dualEvent?: boolean
68
+ keyEvent?: boolean
69
+
70
+ stroke?: IStroke
71
+ strokeWidth?: number
72
+
73
+ pointFill?: IFill
74
+ pointSize?: number
75
+ pointRadius?: number
76
+
77
+ point?: IBoxInputData | IBoxInputData[]
78
+ middlePoint?: IBoxInputData | IBoxInputData[]
79
+ rotatePoint?: IBoxInputData
80
+
81
+ rect?: IBoxInputData
82
+ area?: IRectInputData
83
+ mask?: IColorString
84
+
85
+ buttonsDirection?: 'top' | 'right' | 'bottom' | 'left'
86
+ buttonsFixed?: boolean
87
+ buttonsMargin?: number
88
+
89
+ hideOnMove?: boolean
90
+ hideOnSmall?: boolean | number
91
+
92
+ moveCursor?: ICursorType
93
+ resizeCursor?: IImageCursor
94
+ rotateCursor?: IImageCursor
95
+ skewCursor?: IImageCursor
96
+
97
+ around?: IAlign | IUnitPointData
98
+ lockRatio?: boolean | 'corner'
99
+ rotateGap?: number
100
+
101
+ selector?: boolean
102
+ hover?: boolean
103
+ hoverStyle?: IUIInputData
104
+ select?: 'press' | 'tap'
105
+ boxSelect?: boolean
106
+ continuousSelect?: boolean // 点击可以连续选择
107
+ openInner?: 'double' | 'long' // 双击/长按打开内部
108
+
109
+ moveable?: boolean
110
+ rotateable?: boolean | 'rotate'
111
+ resizeable?: boolean | 'zoom'
112
+ skewable?: boolean
113
+ }
114
+
115
+ export interface IEditPoint extends IBox {
116
+ direction: number
117
+ pointType: IEditPointType
118
+ }
119
+
120
+ export type IEditPointType = 'rotate' | 'resize'
121
+
122
+ export interface IEditBoxBase extends IGroup {
123
+ editor: IEditorBase
124
+ dragging: boolean
125
+ moving: boolean
126
+
127
+ view: IGroup // 放置默认编辑工具控制点
128
+
129
+ circle: IEditPoint
130
+ rect: IRect
131
+
132
+ buttons: IGroup
133
+
134
+ resizePoints: IEditPoint[]
135
+ rotatePoints: IEditPoint[]
136
+ resizeLines: IEditPoint[]
137
+
138
+ readonly flipped: boolean
139
+ readonly flippedX: boolean
140
+ readonly flippedY: boolean
141
+ readonly flippedOne: boolean
142
+
143
+ enterPoint: IEditPoint
144
+
145
+ getPointStyle(userStyle?: IBoxInputData): IBoxInputData
146
+ getPointsStyle(): IBoxInputData[]
147
+ getMiddlePointsStyle(): IBoxInputData[]
148
+
149
+ load(): void
150
+ update(bounds: IBoundsData): void
151
+ unload(): void
152
+
153
+ onArrow(e: IKeyEvent): void
154
+
155
+ }
156
+
157
+ export interface IEditorConfigFunction {
158
+ (ui: any): IEditorConfig
159
+ }
160
+
161
+ export interface IEditToolFunction {
162
+ (ui: any): string
163
+ }
package/src/index.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  export * from '@leafer/interface'
2
2
 
3
+ export { IApp, IAppConfig } from './app/IApp'
4
+ export { ILeafer } from './app/ILeafer'
5
+
3
6
  export {
4
7
  ILine, ILineInputData, ILineData,
8
+ IArrow, IArrowInputData, IArrowData,
5
9
  IRect, IRectInputData, IRectData,
6
10
  IEllipse, IEllipseInputData, IEllipseData,
7
11
  IPolygon, IPolygonInputData, IPolygonData,
@@ -12,24 +16,31 @@ export {
12
16
  IImage, IImageInputData, IImageData,
13
17
  ICanvas, ICanvasInputData, ICanvasData,
14
18
  IFrame, IFrameInputData, IFrameData,
19
+ IFlow, IFlowInputData, IFlowData,
15
20
  IBox, IBoxInputData, IBoxData,
16
21
  IGroup, IGroupInputData, IGroupData,
17
22
  ILeaferInputData, ILeaferData,
18
- IUI, IUIBaseInputData, IUIData,
19
- IUITag, IUIInputData
23
+ IAppInputData, IAppData,
24
+ IUI, IUIBaseInputData, IUIData, IFindUIMethod,
25
+ IUITag, IUIInputData, IUIJSONData
20
26
  } from './IUI'
21
- export { IUnitData, IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IRGB, IRGBA, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, IOverflow } from './type/IType'
22
- export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString as IStringColor } from './type/IStringType'
27
+
28
+ export { IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IFill, IStroke, IPaintAttr, IStrokeAlign, IStrokeJoin, IStrokeCap, IArrowType, IPathDataArrow, IPathDataArrowMap, IRGB, IRGBA, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, IOverflow, ITextWrap, IRepeat } from './type/IType'
29
+ export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString } from './type/IStringType'
23
30
  export { ILeafFill, ILeafPaint, ILeafPaintPatternData, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
31
+ export { IStrokeAttrData, IStrokeInputData, IStrokeComputedData, ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData, IEffectAttrData, IEffectInputData, IEffectComputedData } from './ICommonAttr'
24
32
 
25
33
  export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
26
34
  export { IUIBoundsModule } from './module/IUIBounds'
27
35
  export { IUIHitModule } from './module/IUIHit'
36
+ export { IPathArrowModule } from './module/IPathArrow'
28
37
  export { ITextConvertModule } from './module/ITextConvert'
29
38
  export { IColorConvertModule } from './module/IColorConvert'
30
- export { IExportModule, IExportOptions, IExportResult, IExportResultFunction } from './module/IExport'
39
+ export { IExportModule } from './module/IExport'
40
+ export { IStateModule } from './module/IState'
31
41
 
32
-
33
- export { IPaintModule } from './module/IPaint'
42
+ export { IPaintModule, IPaintImageModule, IPaintGradientModule } from './module/IPaint'
34
43
  export { IEffectModule } from './module/IEffect'
35
- export { ICachedShape } from './ICachedShape'
44
+ export { ICachedShape } from './ICachedShape'
45
+
46
+ export { IEditorBase, IEditorConfig, IEditBoxBase, IEditPoint, IEditPointType, IEditToolFunction, IEditorConfigFunction } from './editor/IEditor'
@@ -1,5 +1,5 @@
1
1
  import { IColor } from '../type/IType'
2
2
 
3
3
  export interface IColorConvertModule {
4
- string?(color: IColor, opacity?: number): string
4
+ string(color: IColor, opacity?: number): string
5
5
  }
@@ -1,12 +1,12 @@
1
- import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
1
+ import { ILeaferCanvas } from '@leafer/interface'
2
2
 
3
3
  import { IUI } from '../IUI'
4
4
  import { ICachedShape } from '../ICachedShape'
5
5
 
6
6
 
7
7
  export interface IEffectModule {
8
- shadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void
9
- innerShadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void
10
- blur?(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas, options: IRenderOptions): void
11
- backgroundBlur?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void
8
+ shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
9
+ innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
10
+ blur(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas): void
11
+ backgroundBlur(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
12
12
  }
@@ -1,19 +1,7 @@
1
- import { ILeaf, IExportFileType, IBlob } from '@leafer/interface'
2
-
3
- export interface IExportOptions {
4
- quality?: number
5
- blob?: boolean
6
- }
7
-
8
- export interface IExportResult {
9
- data: IBlob | string | boolean
10
- }
11
-
12
- export interface IExportResultFunction {
13
- (data: IExportResult): void
14
- }
1
+ import { ILeaf, IExportFileType, IExportOptions, IExportResult } from '@leafer/interface'
15
2
 
16
3
 
17
4
  export interface IExportModule {
18
- export?(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
5
+ running?: boolean
6
+ export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
19
7
  }
@@ -1,26 +1,45 @@
1
- import { ILeaferCanvas, IRenderOptions, IBooleanMap } from '@leafer/interface'
1
+ import { ILeaferCanvas, IRenderOptions, IBooleanMap, IBoundsData, ILeaferImage, IAround, IPointData, IMatrixData } from '@leafer/interface'
2
2
 
3
- import { ILeafPaint } from '../type/IComputedType'
3
+ import { ILeafPaint, ILeafPaintPatternData } from '../type/IComputedType'
4
4
  import { IUI, IUIData } from '../IUI'
5
5
  import { ICachedShape } from '../ICachedShape'
6
+ import { IGradientPaint, IImagePaint, IPaintAttr } from '../type/IType'
7
+
6
8
 
7
9
  export interface IPaintModule {
8
- compute?(ui: IUI, attrName: 'fill' | 'stroke'): void
10
+ compute(attrName: IPaintAttr, ui: IUI): void
11
+
12
+ fill(fill: string, ui: IUI, canvas: ILeaferCanvas,): void
13
+ fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
9
14
 
10
- fill?(ui: IUI, canvas: ILeaferCanvas, fill: string): void
11
- fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void
15
+ fillText(ui: IUI, canvas: ILeaferCanvas): void
12
16
 
13
- fillText?(ui: IUI, canvas: ILeaferCanvas): void
17
+ stroke(stroke: string, ui: IUI, canvas: ILeaferCanvas): void
18
+ strokes(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
14
19
 
15
- stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void
16
- strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
20
+ strokeText(stroke: string | ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
21
+ drawTextStroke(ui: IUI, canvas: ILeaferCanvas): void
17
22
 
18
- strokeText?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void
19
- strokesText?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
23
+ shape(ui: IUI, current: ILeaferCanvas, renderOptions: IRenderOptions): ICachedShape
24
+ }
20
25
 
21
- drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void
22
26
 
23
- shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape
27
+ export interface IPaintImageModule {
28
+ image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds: IBoundsData, firstUse: boolean): ILeafPaint
29
+ checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, allowPaint?: boolean): boolean
30
+ createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): boolean
31
+ recycleImage(attrName: IPaintAttr, data: IUIData): IBooleanMap
24
32
 
25
- recycleImage?(data: IUIData, attrName: string): IBooleanMap
33
+ createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void
34
+ getPatternData(paint: IImagePaint, box: IBoundsData, image: ILeaferImage): ILeafPaintPatternData
35
+ fillOrFitMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void
36
+ clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void
37
+ repeatMode(data: ILeafPaintPatternData, box: IBoundsData, width: number, height: number, x: number, y: number, scaleX: number, scaleY: number, rotation: number, around: IAround): void
26
38
  }
39
+
40
+ export interface IPaintGradientModule {
41
+ linearGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
42
+ radialGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
43
+ conicGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
44
+ getTransform(box: IBoundsData, from: IPointData, to: IPointData, stretch: number, rotate90: boolean): IMatrixData
45
+ }
@@ -0,0 +1,8 @@
1
+ import { IPathDataArrowMap } from '../type/IType'
2
+ import { IUI } from '../IUI'
3
+
4
+
5
+ export interface IPathArrowModule {
6
+ list: IPathDataArrowMap
7
+ addArrows(ui: IUI, changeRenderPath?: boolean): void
8
+ }
@@ -0,0 +1,11 @@
1
+ import { ILeaf, IStateStyleType } from '@leafer/interface'
2
+
3
+ export interface IStateModule {
4
+ isHover(leaf: ILeaf): boolean
5
+ isPress(leaf: ILeaf): boolean
6
+ isFocus(leaf: ILeaf): boolean
7
+ isDrag(leaf: ILeaf): boolean
8
+
9
+ setStyle(leaf: ILeaf, stateType: IStateStyleType, value: boolean): void
10
+ updateEventStyle(leaf: ILeaf, eventType: string): void
11
+ }
@@ -1,5 +1,5 @@
1
1
  import { ITextData, ITextDrawData } from '../IUI'
2
2
 
3
3
  export interface ITextConvertModule {
4
- getDrawData?(content: string, style: ITextData): ITextDrawData
4
+ getDrawData(content: string, style: ITextData): ITextDrawData
5
5
  }
@@ -1,4 +1,4 @@
1
- import { IBlendMode, ILeaferImage, IMatrixData } from '@leafer/interface'
1
+ import { IBlendMode, ILeaferImage, IMatrixData, ITaskItem } from '@leafer/interface'
2
2
 
3
3
  import { IColorString } from './IStringType'
4
4
  import { IStrokeAlign, IStrokeJoin, IStrokeCap, IImagePaintMode } from './IType'
@@ -15,6 +15,7 @@ export interface ILeafPaint {
15
15
  image?: ILeaferImage
16
16
  loadId?: number
17
17
  patternId?: string
18
+ patternTask?: ITaskItem
18
19
  data?: ILeafPaintPatternData
19
20
  }
20
21
 
@@ -26,6 +27,7 @@ export interface ILeafPaintPatternData {
26
27
  opacity?: number
27
28
  transform?: IMatrixData
28
29
  mode?: IImagePaintMode
30
+ repeat?: 'repeat' | 'repeat-x' | 'repeat-y'
29
31
  }
30
32
 
31
33
  export type ILeafFill = ILeafPaint
package/src/type/IType.ts CHANGED
@@ -1,13 +1,14 @@
1
- import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType } from '@leafer/interface'
2
- import { IColorString } from './IStringType'
3
-
4
- export interface IUnitData {
5
- type: 'percent' | 'px'
6
- value: number
7
- }
1
+ import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData, IFourNumber, IAlign, IUnitPointData } from '@leafer/interface'
2
+ import { IColorString, IPaintString } from './IStringType'
8
3
 
9
4
  export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
10
5
 
6
+ export type IFill = IPaint | IPaint[] | IPaintString
7
+
8
+ export type IStroke = IPaint | IPaint[] | IPaintString
9
+
10
+ export type IPaintAttr = 'fill' | 'stroke'
11
+
11
12
  export interface IPaintBase {
12
13
  type: IPaintType
13
14
  blendMode?: IBlendMode
@@ -46,10 +47,10 @@ export interface IRGBA extends IRGB {
46
47
  // ---
47
48
  export interface IGradientPaint extends IPaintBase {
48
49
  type: IGradientType
49
- from?: IPointData
50
- to?: IPointData
50
+ from?: IAlign | IUnitPointData
51
+ to?: IAlign | IUnitPointData
51
52
  stretch?: number
52
- stops: IColorStop[]
53
+ stops: IColorStop[] | IColorString[]
53
54
  }
54
55
  export interface IColorStop {
55
56
  offset: number
@@ -65,9 +66,16 @@ export interface IImagePaint extends IPaintBase {
65
66
 
66
67
  filters?: IImageFilters
67
68
 
69
+ padding?: IFourNumber
70
+
71
+ align?: IAlign
68
72
  offset?: IPointData
73
+
74
+ size?: number | ISizeData
69
75
  scale?: number | IPointData
70
76
  rotation?: number
77
+
78
+ repeat?: IRepeat
71
79
  }
72
80
  export interface IImageFilters {
73
81
  exposure?: number // 曝光
@@ -78,13 +86,33 @@ export interface IImageFilters {
78
86
  highlights?: number // 高光
79
87
  shadows?: number // 阴影
80
88
  }
81
- export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
89
+ export type IImagePaintMode = 'normal' | 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
90
+ export type IRepeat = boolean | 'x' | 'y'
82
91
 
83
92
  // 描边
84
93
  export type IStrokeAlign = 'inside' | 'outside' | 'center'
85
- export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral'
94
+ export type IStrokeCap = 'none' | 'round' | 'square'
86
95
  export type IStrokeJoin = 'bevel' | 'round' | 'miter'
87
96
 
97
+ // 箭头
98
+ export type IArrowType = IPathDataArrow | 'none' | 'angle' | 'angle-side' | 'arrow' | 'triangle' | 'triangle-flip' | 'circle' | 'circle-line' | 'square' | 'square-line' | 'diamond' | 'diamond-line' | 'mark'
99
+
100
+ export interface IPathDataArrowMap {
101
+ [name: string]: IPathDataArrow
102
+ }
103
+
104
+ export interface IPathDataArrow {
105
+ connect?: IPathDataArrowOffset // 箭头与线条的连接点位置
106
+ offset?: IPathDataArrowOffset // 箭头偏移距离,与末端对齐
107
+ path: IPathCommandData
108
+ }
109
+
110
+ export interface IPathDataArrowOffset {
111
+ x?: number // 偏移距离(x轴)
112
+ bevelJoin?: number // strokeJoin 为 bevel 时增加的偏移距离(x轴)
113
+ roundJoin?: number // strokeJoin 为 round 时增加的偏移距离(x轴)
114
+ }
115
+
88
116
  // 文本
89
117
  export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
90
118
  export type IVerticalAlign = 'top' | 'middle' | 'bottom'
@@ -102,6 +130,7 @@ export type IFontWeightString =
102
130
  | 'extra-bold'
103
131
  | 'black'
104
132
  export type ITextDecoration = 'none' | 'under' | 'delete'
133
+ export type ITextWrap = 'normal' | 'none' | 'break'
105
134
 
106
135
  // 路径
107
136
  export interface IVectorPath {