@leafer-ui/display 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 +8 -8
- package/src/Box.ts +58 -37
- package/src/Canvas.ts +17 -18
- package/src/Ellipse.ts +3 -3
- package/src/Frame.ts +8 -5
- package/src/Group.ts +24 -31
- package/src/Image.ts +1 -1
- package/src/Leafer.ts +447 -0
- package/src/Line.ts +19 -30
- package/src/Path.ts +4 -21
- package/src/Pen.ts +18 -8
- package/src/Polygon.ts +3 -6
- package/src/Rect.ts +2 -6
- package/src/Star.ts +2 -2
- package/src/Text.ts +34 -29
- package/src/UI.ts +258 -92
- package/src/index.ts +1 -0
- package/types/index.d.ts +252 -118
- package/src/Arrow.ts +0 -24
package/src/Rect.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dataProcessor, registerUI, rewrite, rewriteAble, useModule } from '@leafer/core'
|
|
1
|
+
import { dataProcessor, registerUI, rewriteAble, useModule } from '@leafer/core'
|
|
3
2
|
|
|
4
3
|
import { IRect, IRectInputData, IRectData } from '@leafer-ui/interface'
|
|
5
4
|
import { RectData } from '@leafer-ui/data'
|
|
@@ -11,7 +10,7 @@ import { UI } from './UI'
|
|
|
11
10
|
@useModule(RectRender)
|
|
12
11
|
@rewriteAble()
|
|
13
12
|
@registerUI()
|
|
14
|
-
export class Rect extends UI implements IRect {
|
|
13
|
+
export class Rect extends UI implements IRect { // tip: rewrited Box
|
|
15
14
|
|
|
16
15
|
public get __tag() { return 'Rect' }
|
|
17
16
|
|
|
@@ -22,7 +21,4 @@ export class Rect extends UI implements IRect {
|
|
|
22
21
|
super(data)
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
@rewrite(UI.prototype.__drawPathByBox)
|
|
26
|
-
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }
|
|
27
|
-
|
|
28
24
|
}
|
package/src/Star.ts
CHANGED
|
@@ -20,10 +20,10 @@ export class Star extends UI implements IStar {
|
|
|
20
20
|
declare public __: IStarData
|
|
21
21
|
|
|
22
22
|
@pathType(5)
|
|
23
|
-
public corners
|
|
23
|
+
public corners?: INumber
|
|
24
24
|
|
|
25
25
|
@pathType(0.382)
|
|
26
|
-
public innerRadius
|
|
26
|
+
public innerRadius?: INumber
|
|
27
27
|
|
|
28
28
|
constructor(data?: IStarInputData) {
|
|
29
29
|
super(data)
|
package/src/Text.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData } from '@leafer/interface'
|
|
2
|
-
import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, hitType, MathHelper } from '@leafer/core'
|
|
1
|
+
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IBoolean, INumber, IString, IBoundsData, IUnitData } from '@leafer/interface'
|
|
2
|
+
import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, dataType, hitType, MathHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow,
|
|
4
|
+
import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, 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, setList } = BoundsHelper
|
|
12
|
+
const { copyAndSpread, includes, isSame, spread, setList } = BoundsHelper
|
|
13
13
|
|
|
14
14
|
@registerUI()
|
|
15
15
|
export class Text extends UI implements IText {
|
|
@@ -21,73 +21,76 @@ export class Text extends UI implements IText {
|
|
|
21
21
|
|
|
22
22
|
// size
|
|
23
23
|
@boundsType(0)
|
|
24
|
-
declare public width
|
|
24
|
+
declare public width?: INumber
|
|
25
25
|
|
|
26
26
|
@boundsType(0)
|
|
27
|
-
declare public height
|
|
27
|
+
declare public height?: INumber
|
|
28
28
|
|
|
29
|
-
@
|
|
30
|
-
public
|
|
29
|
+
@dataType(false)
|
|
30
|
+
public resizeFontSize?: IBoolean
|
|
31
31
|
|
|
32
32
|
@surfaceType('#000000')
|
|
33
|
-
declare public fill
|
|
33
|
+
declare public fill?: IFill
|
|
34
34
|
|
|
35
35
|
@affectStrokeBoundsType('outside')
|
|
36
|
-
declare public strokeAlign
|
|
36
|
+
declare public strokeAlign?: IStrokeAlign
|
|
37
37
|
|
|
38
38
|
@hitType('all')
|
|
39
|
-
declare public hitFill
|
|
39
|
+
declare public hitFill?: IHitType
|
|
40
40
|
|
|
41
41
|
@boundsType('')
|
|
42
|
-
public text
|
|
42
|
+
public text?: IString
|
|
43
43
|
|
|
44
44
|
@boundsType('L')
|
|
45
|
-
public fontFamily
|
|
45
|
+
public fontFamily?: IString
|
|
46
46
|
|
|
47
47
|
@boundsType(12)
|
|
48
|
-
public fontSize
|
|
48
|
+
public fontSize?: INumber
|
|
49
49
|
|
|
50
50
|
@boundsType('normal')
|
|
51
|
-
public fontWeight
|
|
51
|
+
public fontWeight?: IFontWeight
|
|
52
52
|
|
|
53
53
|
@boundsType(false)
|
|
54
|
-
public italic
|
|
54
|
+
public italic?: IBoolean
|
|
55
55
|
|
|
56
56
|
@boundsType('none')
|
|
57
|
-
public textCase
|
|
57
|
+
public textCase?: ITextCase
|
|
58
58
|
|
|
59
59
|
@boundsType('none')
|
|
60
|
-
public textDecoration
|
|
60
|
+
public textDecoration?: ITextDecoration
|
|
61
61
|
|
|
62
62
|
@boundsType(0)
|
|
63
|
-
public letterSpacing
|
|
63
|
+
public letterSpacing?: INumber | IUnitData
|
|
64
64
|
|
|
65
|
-
@boundsType({ type: 'percent', value:
|
|
66
|
-
public lineHeight
|
|
65
|
+
@boundsType({ type: 'percent', value: 1.5 } as IUnitData)
|
|
66
|
+
public lineHeight?: INumber | IUnitData
|
|
67
67
|
|
|
68
68
|
@boundsType(0)
|
|
69
|
-
public paraIndent
|
|
69
|
+
public paraIndent?: INumber
|
|
70
70
|
|
|
71
71
|
@boundsType(0)
|
|
72
|
-
public paraSpacing
|
|
72
|
+
public paraSpacing?: INumber
|
|
73
73
|
|
|
74
74
|
@boundsType('left')
|
|
75
|
-
public textAlign
|
|
75
|
+
public textAlign?: ITextAlign
|
|
76
76
|
|
|
77
77
|
@boundsType('top')
|
|
78
|
-
public verticalAlign
|
|
78
|
+
public verticalAlign?: IVerticalAlign
|
|
79
79
|
|
|
80
80
|
@boundsType('normal')
|
|
81
|
-
public textWrap
|
|
81
|
+
public textWrap?: ITextWrap
|
|
82
82
|
|
|
83
83
|
@boundsType('show')
|
|
84
|
-
public textOverflow
|
|
84
|
+
public textOverflow?: IOverflow | string
|
|
85
|
+
|
|
86
|
+
public get editInner(): string { return 'TextEditor' }
|
|
85
87
|
|
|
86
88
|
public get textDrawData(): ITextDrawData {
|
|
87
89
|
this.__layout.update()
|
|
88
90
|
return this.__.__textDrawData
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
|
|
91
94
|
constructor(data?: ITextInputData) {
|
|
92
95
|
super(data)
|
|
93
96
|
}
|
|
@@ -135,7 +138,7 @@ export class Text extends UI implements IText {
|
|
|
135
138
|
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined
|
|
136
139
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2
|
|
137
140
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`
|
|
138
|
-
data.__clipText = textOverflow !== 'show' && !data.
|
|
141
|
+
data.__clipText = textOverflow !== 'show' && !data.__autoSize
|
|
139
142
|
|
|
140
143
|
this.__updateTextDrawData()
|
|
141
144
|
|
|
@@ -166,8 +169,10 @@ export class Text extends UI implements IText {
|
|
|
166
169
|
super.__updateBoxBounds()
|
|
167
170
|
}
|
|
168
171
|
|
|
172
|
+
if (italic) b.width += fontSize * 0.16
|
|
173
|
+
|
|
169
174
|
const contentBounds = includes(b, bounds) ? b : bounds
|
|
170
|
-
if (contentBounds
|
|
175
|
+
if (!isSame(contentBounds, layout.contentBounds)) {
|
|
171
176
|
layout.contentBounds = contentBounds
|
|
172
177
|
layout.renderChanged = true
|
|
173
178
|
setList(data.__textBoxBounds = {} as IBoundsData, [b, bounds])
|