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

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.
@@ -1,25 +1,35 @@
1
- import { IGroup, IUI, IRectInputData, ISelectorProxy, IEditSize, ICursorType, IAround, IDragEvent, IRotateEvent, IStroke, IFill, ILeaf, IObject, IBoxInputData } from '@leafer-ui/interface'
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, IDirection4 } from '@leafer-ui/interface'
2
2
 
3
3
  export interface IEditorBase extends IGroup, ISelectorProxy {
4
4
  config: IEditorConfig
5
+ readonly mergeConfig: IEditorConfig // 实际使用,合并了选中元素上的editConfig
5
6
 
6
- hoverTarget: IUI
7
- target: IUI | IUI[]
7
+ hoverTarget?: IUI
8
+ target?: IUI | IUI[]
8
9
 
9
10
  readonly list: IUI[]
11
+ leafList: ILeafList
12
+ openedGroupList: ILeafList
13
+
14
+ readonly editing: boolean
15
+ innerEditing: boolean
16
+ readonly groupOpening: boolean
10
17
 
11
- readonly hasTarget: boolean
12
18
  readonly multiple: boolean
13
19
  readonly single: boolean
14
20
 
15
21
  readonly dragging: boolean
16
22
 
17
- element: IUI
23
+ element?: IUI
18
24
  buttons: IGroup
19
25
 
20
26
  selector: IGroup
21
- editBox: IGroup
22
- editTool: IObject
27
+ editBox: IEditBoxBase
28
+ editTool?: IObject
29
+ innerEditor?: IObject
30
+
31
+ select(target: IUI | IUI[]): void
32
+ cancel(): void
23
33
 
24
34
  hasItem(item: IUI): boolean
25
35
  shiftItem(item: IUI): void
@@ -27,17 +37,23 @@ export interface IEditorBase extends IGroup, ISelectorProxy {
27
37
  removeItem(item: IUI): void
28
38
 
29
39
  update(): void
40
+ updateEditBox(): void
30
41
  updateEditTool(): void
31
42
 
32
43
  getEditSize(ui: ILeaf): IEditSize
33
44
 
34
45
  onMove(e: IDragEvent): void
35
- onScale(e: IDragEvent): void
46
+ onScale(e: IDragEvent | IZoomEvent): void
36
47
  onRotate(e: IDragEvent | IRotateEvent): void
37
48
  onSkew(e: IDragEvent): void
38
49
 
39
- group(): void
40
- ungroup(): void
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
41
57
 
42
58
  lock(): void
43
59
  unlock(): void
@@ -47,7 +63,9 @@ export interface IEditorBase extends IGroup, ISelectorProxy {
47
63
  }
48
64
 
49
65
  export interface IEditorConfig {
50
- editSize?: 'auto' | IEditSize
66
+ editSize?: IEditSize
67
+ dualEvent?: boolean
68
+ keyEvent?: boolean
51
69
 
52
70
  stroke?: IStroke
53
71
  strokeWidth?: number
@@ -56,32 +74,99 @@ export interface IEditorConfig {
56
74
  pointSize?: number
57
75
  pointRadius?: number
58
76
 
59
- point?: IBoxInputData | IBoxInputData[]
60
- middlePoint?: IBoxInputData | IBoxInputData[]
61
- rotatePoint?: IBoxInputData
77
+ point?: IEditPointInputData | IEditPointInputData[]
78
+ middlePoint?: IEditPointInputData | IEditPointInputData[]
62
79
 
63
80
  rect?: IBoxInputData
64
81
  area?: IRectInputData
82
+ mask?: boolean | IColorString
83
+
84
+ circle?: IEditPointInputData
85
+ circleDirection?: IDirection4
86
+ circleMargin?: number
87
+ rotatePoint?: IEditPointInputData // 改用circle代替,后期可移除
65
88
 
66
- buttonsDirection?: 'top' | 'right' | 'bottom' | 'left'
67
- buttonsFixed?: boolean
89
+ buttonsDirection?: IDirection4
90
+ buttonsFixed?: boolean | 'AABB' | 'OBB'
68
91
  buttonsMargin?: number
69
92
 
70
93
  hideOnMove?: boolean
94
+ hideOnSmall?: boolean | number
71
95
 
72
96
  moveCursor?: ICursorType
73
- resizeCursor?: ICursorType[]
74
- rotateCursor?: ICursorType[]
97
+ resizeCursor?: IImageCursor
98
+ rotateCursor?: IImageCursor
99
+ skewCursor?: IImageCursor
75
100
 
76
- around?: IAround
77
- lockRatio?: boolean
101
+ around?: IAlign | IUnitPointData
102
+ lockRatio?: boolean | 'corner'
78
103
  rotateGap?: number
79
104
 
80
105
  selector?: boolean
81
106
  hover?: boolean
107
+ hoverStyle?: IUIInputData
108
+ select?: 'press' | 'tap'
82
109
  boxSelect?: boolean
110
+ continuousSelect?: boolean // 点击可以连续选择
111
+ openInner?: 'double' | 'long' // 双击/长按打开内部
83
112
 
84
- rotateable?: boolean
85
- resizeable?: boolean
113
+ moveable?: boolean | 'move'
114
+ resizeable?: boolean | 'zoom'
115
+ flipable?: boolean
116
+ rotateable?: boolean | 'rotate'
86
117
  skewable?: boolean
87
- }
118
+ }
119
+
120
+ export interface IEditPointInputData extends IBoxInputData {
121
+ direction?: number
122
+ pointType?: IEditPointType
123
+ }
124
+ export interface IEditPoint extends IBox {
125
+ direction: number
126
+ pointType: IEditPointType
127
+ }
128
+
129
+ export type IEditPointType = 'rotate' | 'resize' | 'button'
130
+
131
+ export interface IEditBoxBase extends IGroup {
132
+ editor: IEditorBase
133
+ dragging: boolean
134
+ moving: boolean
135
+
136
+ view: IGroup // 放置默认编辑工具控制点
137
+
138
+ circle: IEditPoint
139
+ rect: IRect
140
+
141
+ buttons: IGroup
142
+
143
+ resizePoints: IEditPoint[]
144
+ rotatePoints: IEditPoint[]
145
+ resizeLines: IEditPoint[]
146
+
147
+ readonly flipped: boolean
148
+ readonly flippedX: boolean
149
+ readonly flippedY: boolean
150
+ readonly flippedOne: boolean
151
+
152
+ enterPoint: IEditPoint
153
+
154
+ getPointStyle(userStyle?: IBoxInputData): IBoxInputData
155
+ getPointsStyle(): IBoxInputData[]
156
+ getMiddlePointsStyle(): IBoxInputData[]
157
+
158
+ load(): void
159
+ update(bounds: IBoundsData): void
160
+ unload(): void
161
+
162
+ onArrow(e: IKeyEvent): void
163
+
164
+ }
165
+
166
+ export interface IEditorConfigFunction {
167
+ (ui: any): IEditorConfig
168
+ }
169
+
170
+ export interface IEditToolFunction {
171
+ (ui: any): string
172
+ }
package/src/index.ts CHANGED
@@ -16,27 +16,31 @@ export {
16
16
  IImage, IImageInputData, IImageData,
17
17
  ICanvas, ICanvasInputData, ICanvasData,
18
18
  IFrame, IFrameInputData, IFrameData,
19
+ IFlow, IFlowInputData, IFlowData,
19
20
  IBox, IBoxInputData, IBoxData,
20
21
  IGroup, IGroupInputData, IGroupData,
21
22
  ILeaferInputData, ILeaferData,
22
23
  IAppInputData, IAppData,
23
24
  IUI, IUIBaseInputData, IUIData, IFindUIMethod,
24
- IUITag, IUIInputData
25
+ IUITag, IUIInputData, IUIJSONData
25
26
  } from './IUI'
26
27
 
27
- export { IUnitData, IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IFill, IStroke, IStrokeAlign, IStrokeJoin, IStrokeCap, IArrowType, IRGB, IRGBA, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, IOverflow, ITextWrap, IRepeat } from './type/IType'
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'
28
29
  export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString } from './type/IStringType'
29
30
  export { ILeafFill, ILeafPaint, ILeafPaintPatternData, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
31
+ export { IStrokeAttrData, IStrokeInputData, IStrokeComputedData, ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData, IEffectAttrData, IEffectInputData, IEffectComputedData } from './ICommonAttr'
30
32
 
31
33
  export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
32
34
  export { IUIBoundsModule } from './module/IUIBounds'
33
35
  export { IUIHitModule } from './module/IUIHit'
36
+ export { IPathArrowModule } from './module/IPathArrow'
34
37
  export { ITextConvertModule } from './module/ITextConvert'
35
38
  export { IColorConvertModule } from './module/IColorConvert'
36
- export { IExportModule, IExportOptions, IExportResult, IExportResultFunction } from './module/IExport'
39
+ export { IExportModule } from './module/IExport'
40
+ export { IStateModule } from './module/IState'
37
41
 
38
- export { IPaintModule } from './module/IPaint'
42
+ export { IPaintModule, IPaintImageModule, IPaintGradientModule } from './module/IPaint'
39
43
  export { IEffectModule } from './module/IEffect'
40
44
  export { ICachedShape } from './ICachedShape'
41
45
 
42
- export { IEditorBase, IEditorConfig } from './editor/IEditor'
46
+ export { IEditorBase, IEditorConfig, IEditBoxBase, IEditPoint, IEditPointInputData, 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, renderOptions: IRenderOptions): void
9
- innerShadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, renderOptions: IRenderOptions): void
10
- blur?(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas, renderOptions: IRenderOptions): void
11
- backgroundBlur?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, renderOptions: 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,20 +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
5
  running?: boolean
19
- export?(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
6
+ export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
20
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?(attrName: 'fill' | 'stroke', ui: IUI): 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?(fill: string, ui: IUI, canvas: ILeaferCanvas,): void
11
- fills?(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): 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?(stroke: string, ui: IUI, canvas: ILeaferCanvas, renderOptions: IRenderOptions): void
16
- strokes?(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas, renderOptions: IRenderOptions): void
20
+ strokeText(stroke: string | ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
21
+ drawTextStroke(ui: IUI, canvas: ILeaferCanvas): void
17
22
 
18
- strokeText?(stroke: string, ui: IUI, canvas: ILeaferCanvas, renderOptions: IRenderOptions): void
19
- strokesText?(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas, renderOptions: IRenderOptions): 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, renderOptions: 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?(attrName: 'fill' | 'stroke', data: IUIData): 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
  }
package/src/type/IType.ts CHANGED
@@ -1,17 +1,14 @@
1
- import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData } from '@leafer/interface'
1
+ import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData, IFourNumber, IAlign, IUnitPointData } from '@leafer/interface'
2
2
  import { IColorString, IPaintString } from './IStringType'
3
3
 
4
- export interface IUnitData {
5
- type: 'percent' | 'px'
6
- value: number
7
- }
8
-
9
4
  export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
10
5
 
11
6
  export type IFill = IPaint | IPaint[] | IPaintString
12
7
 
13
8
  export type IStroke = IPaint | IPaint[] | IPaintString
14
9
 
10
+ export type IPaintAttr = 'fill' | 'stroke'
11
+
15
12
  export interface IPaintBase {
16
13
  type: IPaintType
17
14
  blendMode?: IBlendMode
@@ -50,10 +47,10 @@ export interface IRGBA extends IRGB {
50
47
  // ---
51
48
  export interface IGradientPaint extends IPaintBase {
52
49
  type: IGradientType
53
- from?: IPointData
54
- to?: IPointData
50
+ from?: IAlign | IUnitPointData
51
+ to?: IAlign | IUnitPointData
55
52
  stretch?: number
56
- stops: IColorStop[]
53
+ stops: IColorStop[] | IColorString[]
57
54
  }
58
55
  export interface IColorStop {
59
56
  offset: number
@@ -69,7 +66,11 @@ export interface IImagePaint extends IPaintBase {
69
66
 
70
67
  filters?: IImageFilters
71
68
 
69
+ padding?: IFourNumber
70
+
71
+ align?: IAlign
72
72
  offset?: IPointData
73
+
73
74
  size?: number | ISizeData
74
75
  scale?: number | IPointData
75
76
  rotation?: number
@@ -85,16 +86,32 @@ export interface IImageFilters {
85
86
  highlights?: number // 高光
86
87
  shadows?: number // 阴影
87
88
  }
88
- export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
89
+ export type IImagePaintMode = 'normal' | 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
89
90
  export type IRepeat = boolean | 'x' | 'y'
90
91
 
91
92
  // 描边
92
93
  export type IStrokeAlign = 'inside' | 'outside' | 'center'
93
- export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral'
94
+ export type IStrokeCap = 'none' | 'round' | 'square'
94
95
  export type IStrokeJoin = 'bevel' | 'round' | 'miter'
95
96
 
96
97
  // 箭头
97
- export type IArrowType = 'none' | 'line' | 'triangle' | 'circle'
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
+ }
98
115
 
99
116
  // 文本
100
117
  export type ITextAlign = 'left' | 'center' | 'right' | 'justify'