@leafer-ui/interface 1.0.0-rc.2 → 1.0.0-rc.20
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 +2 -2
- package/src/ICommonAttr.ts +57 -39
- package/src/IUI.ts +115 -38
- package/src/app/IApp.ts +16 -0
- package/src/app/ILeafer.ts +22 -0
- package/src/editor/IEditor.ts +95 -0
- package/src/index.ts +16 -7
- package/src/module/IColorConvert.ts +1 -1
- package/src/module/IEffect.ts +5 -5
- package/src/module/IExport.ts +3 -15
- package/src/module/IPaint.ts +29 -13
- package/src/module/IPathArrow.ts +8 -0
- package/src/module/IState.ts +11 -0
- package/src/module/ITextConvert.ts +1 -1
- package/src/type/IComputedType.ts +3 -1
- package/src/type/IType.ts +34 -3
- package/types/index.d.ts +306 -100
package/src/module/IEffect.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ILeaferCanvas
|
|
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
|
|
9
|
-
innerShadow
|
|
10
|
-
blur
|
|
11
|
-
backgroundBlur
|
|
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
|
}
|
package/src/module/IExport.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { ILeaf, IExportFileType,
|
|
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
|
|
6
|
+
export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
|
|
19
7
|
}
|
package/src/module/IPaint.ts
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions, IBooleanMap } from '@leafer/interface'
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions, IBooleanMap, IBoundsData, ILeaferImage } 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, IImagePaintMode, IPaintAttr } from '../type/IType'
|
|
6
7
|
|
|
7
8
|
export interface IPaintModule {
|
|
8
|
-
compute
|
|
9
|
+
compute(attrName: IPaintAttr, ui: IUI): void
|
|
9
10
|
|
|
10
|
-
fill
|
|
11
|
-
fills
|
|
11
|
+
fill(fill: string, ui: IUI, canvas: ILeaferCanvas,): void
|
|
12
|
+
fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
|
|
12
13
|
|
|
13
|
-
fillText
|
|
14
|
+
fillText(ui: IUI, canvas: ILeaferCanvas): void
|
|
14
15
|
|
|
15
|
-
stroke
|
|
16
|
-
strokes
|
|
16
|
+
stroke(stroke: string, ui: IUI, canvas: ILeaferCanvas): void
|
|
17
|
+
strokes(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
|
|
17
18
|
|
|
18
|
-
strokeText
|
|
19
|
-
|
|
19
|
+
strokeText(stroke: string | ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
|
|
20
|
+
drawTextStroke(ui: IUI, canvas: ILeaferCanvas): void
|
|
21
|
+
|
|
22
|
+
shape(ui: IUI, current: ILeaferCanvas, renderOptions: IRenderOptions): ICachedShape
|
|
23
|
+
}
|
|
20
24
|
|
|
21
|
-
drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
export interface IPaintImageModule {
|
|
27
|
+
image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds: IBoundsData, firstUse: boolean): ILeafPaint
|
|
28
|
+
checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, allowPaint?: boolean): boolean
|
|
29
|
+
createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): boolean
|
|
30
|
+
recycleImage(attrName: IPaintAttr, data: IUIData): IBooleanMap
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void
|
|
33
|
+
fillOrFitMode(data: ILeafPaintPatternData, mode: IImagePaintMode, box: IBoundsData, width: number, height: number, rotation: number): void
|
|
34
|
+
clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void
|
|
35
|
+
repeatMode(data: ILeafPaintPatternData, box: IBoundsData, width: number, height: number, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void
|
|
26
36
|
}
|
|
37
|
+
|
|
38
|
+
export interface IPaintGradientModule {
|
|
39
|
+
linearGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
|
|
40
|
+
radialGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
|
|
41
|
+
conicGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
|
|
42
|
+
}
|
|
@@ -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,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,5 +1,5 @@
|
|
|
1
|
-
import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType } from '@leafer/interface'
|
|
2
|
-
import { IColorString } from './IStringType'
|
|
1
|
+
import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData, IFourNumber } from '@leafer/interface'
|
|
2
|
+
import { IColorString, IPaintString } from './IStringType'
|
|
3
3
|
|
|
4
4
|
export interface IUnitData {
|
|
5
5
|
type: 'percent' | 'px'
|
|
@@ -8,6 +8,12 @@ export interface IUnitData {
|
|
|
8
8
|
|
|
9
9
|
export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
|
|
10
10
|
|
|
11
|
+
export type IFill = IPaint | IPaint[] | IPaintString
|
|
12
|
+
|
|
13
|
+
export type IStroke = IPaint | IPaint[] | IPaintString
|
|
14
|
+
|
|
15
|
+
export type IPaintAttr = 'fill' | 'stroke'
|
|
16
|
+
|
|
11
17
|
export interface IPaintBase {
|
|
12
18
|
type: IPaintType
|
|
13
19
|
blendMode?: IBlendMode
|
|
@@ -65,9 +71,13 @@ export interface IImagePaint extends IPaintBase {
|
|
|
65
71
|
|
|
66
72
|
filters?: IImageFilters
|
|
67
73
|
|
|
74
|
+
padding?: IFourNumber
|
|
68
75
|
offset?: IPointData
|
|
76
|
+
size?: number | ISizeData
|
|
69
77
|
scale?: number | IPointData
|
|
70
78
|
rotation?: number
|
|
79
|
+
|
|
80
|
+
repeat?: IRepeat
|
|
71
81
|
}
|
|
72
82
|
export interface IImageFilters {
|
|
73
83
|
exposure?: number // 曝光
|
|
@@ -79,12 +89,32 @@ export interface IImageFilters {
|
|
|
79
89
|
shadows?: number // 阴影
|
|
80
90
|
}
|
|
81
91
|
export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
|
|
92
|
+
export type IRepeat = boolean | 'x' | 'y'
|
|
82
93
|
|
|
83
94
|
// 描边
|
|
84
95
|
export type IStrokeAlign = 'inside' | 'outside' | 'center'
|
|
85
|
-
export type IStrokeCap = 'none' | 'round' | 'square'
|
|
96
|
+
export type IStrokeCap = 'none' | 'round' | 'square'
|
|
86
97
|
export type IStrokeJoin = 'bevel' | 'round' | 'miter'
|
|
87
98
|
|
|
99
|
+
// 箭头
|
|
100
|
+
export type IArrowType = IPathDataArrow | 'none' | 'angle' | 'angle-side' | 'arrow' | 'triangle' | 'triangle-flip' | 'circle' | 'circle-line' | 'square' | 'square-line' | 'diamond' | 'diamond-line' | 'mark'
|
|
101
|
+
|
|
102
|
+
export interface IPathDataArrowMap {
|
|
103
|
+
[name: string]: IPathDataArrow
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface IPathDataArrow {
|
|
107
|
+
connect?: IPathDataArrowOffset // 箭头与线条的连接点位置
|
|
108
|
+
offset?: IPathDataArrowOffset // 箭头偏移距离,与末端对齐
|
|
109
|
+
path: IPathCommandData
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface IPathDataArrowOffset {
|
|
113
|
+
x?: number // 偏移距离(x轴)
|
|
114
|
+
bevelJoin?: number // strokeJoin 为 bevel 时增加的偏移距离(x轴)
|
|
115
|
+
roundJoin?: number // strokeJoin 为 round 时增加的偏移距离(x轴)
|
|
116
|
+
}
|
|
117
|
+
|
|
88
118
|
// 文本
|
|
89
119
|
export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
|
|
90
120
|
export type IVerticalAlign = 'top' | 'middle' | 'bottom'
|
|
@@ -102,6 +132,7 @@ export type IFontWeightString =
|
|
|
102
132
|
| 'extra-bold'
|
|
103
133
|
| 'black'
|
|
104
134
|
export type ITextDecoration = 'none' | 'under' | 'delete'
|
|
135
|
+
export type ITextWrap = 'normal' | 'none' | 'break'
|
|
105
136
|
|
|
106
137
|
// 路径
|
|
107
138
|
export interface IVectorPath {
|