@leafer-ui/data 1.0.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023-present, Chao (Leafer) Wan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @leafer-ui/data
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@leafer-ui/data",
3
+ "version": "1.0.0-alpha.1",
4
+ "description": "@leafer-ui/data",
5
+ "author": "Chao (Leafer) Wan",
6
+ "license": "MIT",
7
+ "main": "src/index.ts",
8
+ "files": ["src"],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/leaferjs/ui.git"
12
+ },
13
+ "homepage": "https://github.com/leaferjs/ui/tree/main/packages/data",
14
+ "bugs": "https://github.com/leaferjs/ui/issues",
15
+ "keywords": [
16
+ "leaferui",
17
+ "leafer-ui",
18
+ "leaferjs"
19
+ ],
20
+ "dependencies": {
21
+ "@leafer/core": "1.0.0-alpha.1"
22
+ },
23
+ "devDependencies": {
24
+ "@leafer/interface": "1.0.0-alpha.1",
25
+ "@leafer-ui/interface": "1.0.0-alpha.1"
26
+ }
27
+ }
@@ -0,0 +1,8 @@
1
+ import { IEllipseData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class EllipseData extends UIData implements IEllipseData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { IFrameData } from '@leafer-ui/interface'
2
+
3
+ import { GroupData } from "./GroupData"
4
+
5
+
6
+ export class FrameData extends GroupData implements IFrameData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { IGroupData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class GroupData extends UIData implements IGroupData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { IImageData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class ImageData extends UIData implements IImageData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { ILineData } from "@leafer-ui/interface"
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class LineData extends UIData implements ILineData {
7
+
8
+ }
@@ -0,0 +1,18 @@
1
+ import { IPathCommandData } from '@leafer/interface'
2
+ import { PathConvert } from '@leafer/core'
3
+
4
+ import { IPathString } from '@leafer-ui/interface'
5
+ import { UIData } from "./UIData"
6
+
7
+
8
+ const { parse } = PathConvert
9
+
10
+ export class PathData extends UIData {
11
+
12
+ protected _path: IPathCommandData
13
+
14
+ protected setPath(value: IPathCommandData | IPathString) {
15
+ this._path = (typeof value === 'string') ? parse(value) : value
16
+ }
17
+
18
+ }
@@ -0,0 +1,8 @@
1
+ import { IPolygonData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class PolygonData extends UIData implements IPolygonData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { IRectData } from "@leafer-ui/interface"
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class RectData extends UIData implements IRectData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { IStarData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class StarData extends UIData implements IStarData {
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ import { ITextData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class TextData extends UIData implements ITextData {
7
+
8
+ }
package/src/UIData.ts ADDED
@@ -0,0 +1,74 @@
1
+ import { __Value } from '@leafer/interface'
2
+ import { LeafData } from '@leafer/core'
3
+
4
+ import { IUIData } from '@leafer-ui/interface'
5
+
6
+
7
+ export class UIData extends LeafData implements IUIData {
8
+
9
+ public __isFills?: boolean
10
+ public __isStrokes?: boolean
11
+
12
+ protected _fill?: __Value
13
+ protected _stroke?: __Value
14
+
15
+ protected _borderWidth?: __Value
16
+ protected _strokeWidth?: number
17
+
18
+ protected _shadow?: __Value
19
+ protected _innerShadow?: __Value
20
+
21
+ protected setBorderWidth(value: __Value) {
22
+ if (typeof value === 'number') this._strokeWidth = value
23
+ this._borderWidth = value
24
+ }
25
+
26
+ protected setFill(value: __Value) {
27
+ if (typeof value === 'string') {
28
+ this._fill = value
29
+ if (this.__isFills) this.__isFills = false
30
+ } else if (value instanceof Array) {
31
+ this._fill = value
32
+ this.__isFills = true
33
+ } else if (typeof value === 'object') {
34
+ this._fill = [value]
35
+ this.__isFills = true
36
+ } else {
37
+ this._fill = value
38
+ if (this.__isFills) this.__isFills = false
39
+ }
40
+ }
41
+
42
+ protected setStroke(value: __Value) {
43
+ if (typeof value === 'string') {
44
+ this._stroke = value
45
+ if (this.__isStrokes) this.__isStrokes = false
46
+ } else if (value instanceof Array) {
47
+ this._stroke = value
48
+ this.__isStrokes = true
49
+ } else if (typeof value === 'object') {
50
+ this._stroke = [value]
51
+ this.__isStrokes = true
52
+ } else {
53
+ this._stroke = value
54
+ if (this.__isStrokes) this.__isStrokes = false
55
+ }
56
+ }
57
+
58
+ protected setShadow(value: __Value) {
59
+ if (value instanceof Array) {
60
+ this._shadow = value
61
+ } else {
62
+ this._shadow = [value]
63
+ }
64
+ }
65
+
66
+ protected setInnerShadow(value: __Value) {
67
+ if (value instanceof Array) {
68
+ this._innerShadow = value
69
+ } else {
70
+ this._innerShadow = [value]
71
+ }
72
+ }
73
+
74
+ }
@@ -0,0 +1,8 @@
1
+ import { IVectorData } from '@leafer-ui/interface'
2
+
3
+ import { UIData } from "./UIData"
4
+
5
+
6
+ export class VectorData extends UIData implements IVectorData {
7
+
8
+ }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+
2
+ export { UIData } from './UIData'
3
+ export { GroupData } from './GroupData'
4
+
5
+ export { FrameData } from './FrameData'
6
+
7
+ export { LineData } from './LineData'
8
+ export { RectData } from './RectData'
9
+ export { EllipseData } from './EllipseData'
10
+ export { PolygonData } from './PolygonData'
11
+ export { StarData } from './StarData'
12
+ export { PathData } from './PathData'
13
+ export { VectorData } from './VectorData'
14
+ export { TextData } from './TextData'
15
+ export { ImageData } from './ImageData'
16
+
17
+