@gisce/ooui 2.37.0-alpha.1 → 2.37.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/QRCode.d.ts +11 -0
- package/dist/QRCode.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 +190 -172
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/QRCode.ts +21 -0
- package/src/WidgetFactory.ts +4 -0
- package/src/index.ts +2 -0
- package/src/spec/QRCode.spec.ts +127 -0
package/package.json
CHANGED
package/src/QRCode.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Field from "./Field";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* QRCode widget
|
|
5
|
+
*/
|
|
6
|
+
class QRCode extends Field {
|
|
7
|
+
get width(): number | undefined {
|
|
8
|
+
return this.parsedWidgetProps?.width;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get border(): boolean {
|
|
12
|
+
return this.parsedWidgetProps?.border ?? false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get showValue(): boolean {
|
|
16
|
+
console.log(this.parsedWidgetProps);
|
|
17
|
+
return this.parsedWidgetProps?.showValue ?? false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default QRCode;
|
package/src/WidgetFactory.ts
CHANGED
|
@@ -44,6 +44,7 @@ import Email from "./Email";
|
|
|
44
44
|
import Spinner from "./Spinner";
|
|
45
45
|
import Carousel from "./Carousel";
|
|
46
46
|
import ColorPicker from "./ColorPicker";
|
|
47
|
+
import QRCode from "./QRCode";
|
|
47
48
|
|
|
48
49
|
class WidgetFactory {
|
|
49
50
|
/**
|
|
@@ -196,6 +197,9 @@ class WidgetFactory {
|
|
|
196
197
|
case "colorPicker":
|
|
197
198
|
this._widgetClass = ColorPicker;
|
|
198
199
|
break;
|
|
200
|
+
case "qrcode":
|
|
201
|
+
this._widgetClass = QRCode;
|
|
202
|
+
break;
|
|
199
203
|
default:
|
|
200
204
|
break;
|
|
201
205
|
}
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,7 @@ import Email from "./Email";
|
|
|
56
56
|
import Spinner from "./Spinner";
|
|
57
57
|
import Carousel from "./Carousel";
|
|
58
58
|
import ColorPicker from "./ColorPicker";
|
|
59
|
+
import QRCode from "./QRCode";
|
|
59
60
|
|
|
60
61
|
import {
|
|
61
62
|
Graph,
|
|
@@ -148,4 +149,5 @@ export {
|
|
|
148
149
|
Spinner,
|
|
149
150
|
Carousel,
|
|
150
151
|
ColorPicker,
|
|
152
|
+
QRCode,
|
|
151
153
|
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import WidgetFactory from "../WidgetFactory";
|
|
2
|
+
import QRCode from "../QRCode";
|
|
3
|
+
import { it, expect, describe } from "vitest";
|
|
4
|
+
|
|
5
|
+
describe("A QRCode", () => {
|
|
6
|
+
it("should have an id corresponding to field name", () => {
|
|
7
|
+
const widgetFactory = new WidgetFactory();
|
|
8
|
+
const props = {
|
|
9
|
+
name: "qrcode",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
13
|
+
expect(widget).toBeInstanceOf(QRCode);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should properly set label", () => {
|
|
17
|
+
const widgetFactory = new WidgetFactory();
|
|
18
|
+
const props = {
|
|
19
|
+
name: "qrcode",
|
|
20
|
+
string: "QR Code caption",
|
|
21
|
+
};
|
|
22
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
23
|
+
|
|
24
|
+
expect(widget.label).toBe("QR Code caption");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("width property", () => {
|
|
28
|
+
it("should be undefined by default", () => {
|
|
29
|
+
const widgetFactory = new WidgetFactory();
|
|
30
|
+
const props = {
|
|
31
|
+
name: "qrcode",
|
|
32
|
+
};
|
|
33
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
34
|
+
|
|
35
|
+
expect(widget.width).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should return width when widget_props.width is set", () => {
|
|
39
|
+
const widgetFactory = new WidgetFactory();
|
|
40
|
+
const props = {
|
|
41
|
+
name: "qrcode",
|
|
42
|
+
widget_props: {
|
|
43
|
+
width: 200,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
47
|
+
|
|
48
|
+
expect(widget.width).toBe(200);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("border property", () => {
|
|
53
|
+
it("should be false by default", () => {
|
|
54
|
+
const widgetFactory = new WidgetFactory();
|
|
55
|
+
const props = {
|
|
56
|
+
name: "qrcode",
|
|
57
|
+
};
|
|
58
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
59
|
+
|
|
60
|
+
expect(widget.border).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should be true when widget_props.border is true", () => {
|
|
64
|
+
const widgetFactory = new WidgetFactory();
|
|
65
|
+
const props = {
|
|
66
|
+
name: "qrcode",
|
|
67
|
+
widget_props: {
|
|
68
|
+
border: true,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
72
|
+
|
|
73
|
+
expect(widget.border).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should be false when widget_props.border is false", () => {
|
|
77
|
+
const widgetFactory = new WidgetFactory();
|
|
78
|
+
const props = {
|
|
79
|
+
name: "qrcode",
|
|
80
|
+
widget_props: {
|
|
81
|
+
border: false,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
85
|
+
|
|
86
|
+
expect(widget.border).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("showValue property", () => {
|
|
91
|
+
it("should be false by default", () => {
|
|
92
|
+
const widgetFactory = new WidgetFactory();
|
|
93
|
+
const props = {
|
|
94
|
+
name: "qrcode",
|
|
95
|
+
};
|
|
96
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
97
|
+
|
|
98
|
+
expect(widget.showValue).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should be true when widget_props.showValue is true", () => {
|
|
102
|
+
const widgetFactory = new WidgetFactory();
|
|
103
|
+
const props = {
|
|
104
|
+
name: "qrcode",
|
|
105
|
+
widget_props: {
|
|
106
|
+
showValue: true,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
110
|
+
|
|
111
|
+
expect(widget.showValue).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should be false when widget_props.showValue is false", () => {
|
|
115
|
+
const widgetFactory = new WidgetFactory();
|
|
116
|
+
const props = {
|
|
117
|
+
name: "qrcode",
|
|
118
|
+
widget_props: {
|
|
119
|
+
showValue: false,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const widget = widgetFactory.createWidget("qrcode", props);
|
|
123
|
+
|
|
124
|
+
expect(widget.showValue).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|