@gisce/ooui 2.40.0-alpha.2 → 2.40.0-alpha.3
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/dist/Icon.d.ts +24 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/WidgetFactory.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/ooui.es.js +183 -143
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Icon.ts +59 -0
- package/src/WidgetFactory.ts +4 -0
- package/src/index.ts +2 -0
- package/src/spec/Icon.spec.ts +93 -0
package/package.json
CHANGED
package/src/Icon.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
class Icon extends Field {
|
|
4
|
+
/**
|
|
5
|
+
* Icon name
|
|
6
|
+
*/
|
|
7
|
+
_name: string = "";
|
|
8
|
+
get name(): string {
|
|
9
|
+
return this._name;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
set name(value: string) {
|
|
13
|
+
this._name = value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Icon size
|
|
18
|
+
*/
|
|
19
|
+
_size: number = 16;
|
|
20
|
+
get size(): number {
|
|
21
|
+
return this._size;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set size(value: number) {
|
|
25
|
+
this._size = value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Icon color
|
|
30
|
+
*/
|
|
31
|
+
_color: string = "";
|
|
32
|
+
get color(): string {
|
|
33
|
+
return this._color;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
set color(value: string) {
|
|
37
|
+
this._color = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
constructor(props?: any) {
|
|
41
|
+
super({ ...props, nolabel: true });
|
|
42
|
+
|
|
43
|
+
if (props) {
|
|
44
|
+
if (props.name) {
|
|
45
|
+
this._name = props.name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (props.size) {
|
|
49
|
+
this._size = props.size;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (props.color) {
|
|
53
|
+
this._color = props.color;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default Icon;
|
package/src/WidgetFactory.ts
CHANGED
|
@@ -25,6 +25,7 @@ import Separator from "./Separator";
|
|
|
25
25
|
import Reference from "./Reference";
|
|
26
26
|
import Binary from "./Binary";
|
|
27
27
|
import Image from "./Image";
|
|
28
|
+
import Icon from "./Icon";
|
|
28
29
|
import FiberGrid from "./FiberGrid";
|
|
29
30
|
import Timeline from "./Timeline";
|
|
30
31
|
import Indicator from "./Indicator";
|
|
@@ -141,6 +142,9 @@ class WidgetFactory {
|
|
|
141
142
|
case "image":
|
|
142
143
|
this._widgetClass = Image;
|
|
143
144
|
break;
|
|
145
|
+
case "icon":
|
|
146
|
+
this._widgetClass = Icon;
|
|
147
|
+
break;
|
|
144
148
|
case "fiber_grid":
|
|
145
149
|
this._widgetClass = FiberGrid;
|
|
146
150
|
break;
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ import ActionButtons from "./ActionButtons";
|
|
|
32
32
|
import Reference from "./Reference";
|
|
33
33
|
import Binary from "./Binary";
|
|
34
34
|
import Image from "./Image";
|
|
35
|
+
import Icon from "./Icon";
|
|
35
36
|
import { parseContext, parseContextFields } from "./helpers/contextParser";
|
|
36
37
|
import {
|
|
37
38
|
transformDomainForChildWidget,
|
|
@@ -113,6 +114,7 @@ export {
|
|
|
113
114
|
Reference,
|
|
114
115
|
Binary,
|
|
115
116
|
Image,
|
|
117
|
+
Icon,
|
|
116
118
|
parseContext,
|
|
117
119
|
parseContextFields,
|
|
118
120
|
transformDomainForChildWidget,
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import WidgetFactory from "../WidgetFactory";
|
|
2
|
+
import { it, expect, describe } from "vitest";
|
|
3
|
+
|
|
4
|
+
describe("An Icon", () => {
|
|
5
|
+
it("should have an id corresponding to field name", () => {
|
|
6
|
+
const widgetFactory = new WidgetFactory();
|
|
7
|
+
const props = {
|
|
8
|
+
name: "icon1",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
12
|
+
|
|
13
|
+
expect(widget.id).toBe("icon1");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should properly have nolabel as true by default", () => {
|
|
17
|
+
const widgetFactory = new WidgetFactory();
|
|
18
|
+
const props = {
|
|
19
|
+
name: "icon1",
|
|
20
|
+
};
|
|
21
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
22
|
+
|
|
23
|
+
expect(widget.nolabel).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should properly set name", () => {
|
|
27
|
+
const widgetFactory = new WidgetFactory();
|
|
28
|
+
const props = {
|
|
29
|
+
name: "icon1",
|
|
30
|
+
};
|
|
31
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
32
|
+
|
|
33
|
+
widget.name = "home";
|
|
34
|
+
expect(widget.name).toBe("home");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should properly set size", () => {
|
|
38
|
+
const widgetFactory = new WidgetFactory();
|
|
39
|
+
const props = {
|
|
40
|
+
name: "icon1",
|
|
41
|
+
size: 24,
|
|
42
|
+
};
|
|
43
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
44
|
+
|
|
45
|
+
expect(widget.size).toBe(24);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should have default size of 16", () => {
|
|
49
|
+
const widgetFactory = new WidgetFactory();
|
|
50
|
+
const props = {
|
|
51
|
+
name: "icon1",
|
|
52
|
+
};
|
|
53
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
54
|
+
|
|
55
|
+
expect(widget.size).toBe(16);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should properly set color", () => {
|
|
59
|
+
const widgetFactory = new WidgetFactory();
|
|
60
|
+
const props = {
|
|
61
|
+
name: "icon1",
|
|
62
|
+
color: "#FF0000",
|
|
63
|
+
};
|
|
64
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
65
|
+
|
|
66
|
+
expect(widget.color).toBe("#FF0000");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should have empty color by default", () => {
|
|
70
|
+
const widgetFactory = new WidgetFactory();
|
|
71
|
+
const props = {
|
|
72
|
+
name: "icon1",
|
|
73
|
+
};
|
|
74
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
75
|
+
|
|
76
|
+
expect(widget.color).toBe("");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should properly parse all props together", () => {
|
|
80
|
+
const widgetFactory = new WidgetFactory();
|
|
81
|
+
const props = {
|
|
82
|
+
name: "icon1",
|
|
83
|
+
size: 32,
|
|
84
|
+
color: "blue",
|
|
85
|
+
};
|
|
86
|
+
const widget = widgetFactory.createWidget("icon", props);
|
|
87
|
+
|
|
88
|
+
widget.name = "star";
|
|
89
|
+
expect(widget.name).toBe("star");
|
|
90
|
+
expect(widget.size).toBe(32);
|
|
91
|
+
expect(widget.color).toBe("blue");
|
|
92
|
+
});
|
|
93
|
+
});
|