@gisce/ooui 2.26.0-alpha.1 → 2.26.0-alpha.2
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/ColorPicker.d.ts +6 -0
- package/dist/ColorPicker.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 +115 -106
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/ColorPicker.ts +9 -0
- package/src/WidgetFactory.ts +4 -0
- package/src/index.ts +2 -0
- package/src/spec/ColorPicker.spec.ts +64 -0
package/package.json
CHANGED
package/src/WidgetFactory.ts
CHANGED
|
@@ -42,6 +42,7 @@ import JSONField from "./JSONField";
|
|
|
42
42
|
import Email from "./Email";
|
|
43
43
|
import Spinner from "./Spinner";
|
|
44
44
|
import Carousel from "./Carousel";
|
|
45
|
+
import ColorPicker from "./ColorPicker";
|
|
45
46
|
|
|
46
47
|
class WidgetFactory {
|
|
47
48
|
/**
|
|
@@ -188,6 +189,9 @@ class WidgetFactory {
|
|
|
188
189
|
case "carousel":
|
|
189
190
|
this._widgetClass = Carousel;
|
|
190
191
|
break;
|
|
192
|
+
case "colorPicker":
|
|
193
|
+
this._widgetClass = ColorPicker;
|
|
194
|
+
break;
|
|
191
195
|
default:
|
|
192
196
|
break;
|
|
193
197
|
}
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ import Comments from "./Comments";
|
|
|
54
54
|
import Email from "./Email";
|
|
55
55
|
import Spinner from "./Spinner";
|
|
56
56
|
import Carousel from "./Carousel";
|
|
57
|
+
import ColorPicker from "./ColorPicker";
|
|
57
58
|
|
|
58
59
|
import {
|
|
59
60
|
Graph,
|
|
@@ -144,4 +145,5 @@ export {
|
|
|
144
145
|
Email,
|
|
145
146
|
Spinner,
|
|
146
147
|
Carousel,
|
|
148
|
+
ColorPicker,
|
|
147
149
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/spec/ColorPicker.spec.ts
|
|
2
|
+
import WidgetFactory from "../WidgetFactory";
|
|
3
|
+
import ColorPicker from "../ColorPicker";
|
|
4
|
+
import { it, expect, describe } from "vitest";
|
|
5
|
+
|
|
6
|
+
describe("A ColorPicker", () => {
|
|
7
|
+
it("should have an id corresponding to field name", () => {
|
|
8
|
+
const widgetFactory = new WidgetFactory();
|
|
9
|
+
const props = {
|
|
10
|
+
name: "colorPicker",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
14
|
+
expect(widget).toBeInstanceOf(ColorPicker);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should properly set label", () => {
|
|
18
|
+
const widgetFactory = new WidgetFactory();
|
|
19
|
+
const props = {
|
|
20
|
+
name: "colorPicker",
|
|
21
|
+
string: "colorPicker caption",
|
|
22
|
+
};
|
|
23
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
24
|
+
|
|
25
|
+
expect(widget.label).toBe("colorPicker caption");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("showText property", () => {
|
|
29
|
+
it("should show text by default", () => {
|
|
30
|
+
const widgetFactory = new WidgetFactory();
|
|
31
|
+
const props = {
|
|
32
|
+
name: "colorPicker",
|
|
33
|
+
};
|
|
34
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
35
|
+
|
|
36
|
+
expect(widget.showText).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
it("should show text when widget_props.showText is true", () => {
|
|
39
|
+
const widgetFactory = new WidgetFactory();
|
|
40
|
+
const props = {
|
|
41
|
+
name: "colorPicker",
|
|
42
|
+
widget_props: {
|
|
43
|
+
show_text: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
47
|
+
|
|
48
|
+
expect(widget.showText).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should not show text when widget_props.showText is false", () => {
|
|
52
|
+
const widgetFactory = new WidgetFactory();
|
|
53
|
+
const props = {
|
|
54
|
+
name: "colorPicker",
|
|
55
|
+
widget_props: {
|
|
56
|
+
show_text: false,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
60
|
+
|
|
61
|
+
expect(widget.showText).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|