@gisce/ooui 2.36.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "2.36.0",
3
+ "version": "2.37.0-alpha.2",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
@@ -0,0 +1,5 @@
1
+ import Field from "./Field";
2
+
3
+ class ActionButtons extends Field {}
4
+
5
+ export default ActionButtons;
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;
@@ -3,6 +3,7 @@ import Page from "./Page";
3
3
  import Group from "./Group";
4
4
  import Button from "./Button";
5
5
  import ButtonGroup from "./ButtonGroup";
6
+ import ActionButtons from "./ActionButtons";
6
7
  import Label from "./Label";
7
8
  import Char from "./Char";
8
9
  import Text from "./Text";
@@ -43,6 +44,7 @@ import Email from "./Email";
43
44
  import Spinner from "./Spinner";
44
45
  import Carousel from "./Carousel";
45
46
  import ColorPicker from "./ColorPicker";
47
+ import QRCode from "./QRCode";
46
48
 
47
49
  class WidgetFactory {
48
50
  /**
@@ -76,6 +78,9 @@ class WidgetFactory {
76
78
  case "buttonGroup":
77
79
  this._widgetClass = ButtonGroup;
78
80
  break;
81
+ case "action_buttons":
82
+ this._widgetClass = ActionButtons;
83
+ break;
79
84
  case "selection":
80
85
  this._widgetClass = Selection;
81
86
  break;
@@ -192,6 +197,9 @@ class WidgetFactory {
192
197
  case "colorPicker":
193
198
  this._widgetClass = ColorPicker;
194
199
  break;
200
+ case "qrcode":
201
+ this._widgetClass = QRCode;
202
+ break;
195
203
  default:
196
204
  break;
197
205
  }
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ import Page from "./Page";
27
27
  import Separator from "./Separator";
28
28
  import Button from "./Button";
29
29
  import ButtonGroup from "./ButtonGroup";
30
+ import ActionButtons from "./ActionButtons";
30
31
  import Reference from "./Reference";
31
32
  import Binary from "./Binary";
32
33
  import Image from "./Image";
@@ -55,6 +56,7 @@ import Email from "./Email";
55
56
  import Spinner from "./Spinner";
56
57
  import Carousel from "./Carousel";
57
58
  import ColorPicker from "./ColorPicker";
59
+ import QRCode from "./QRCode";
58
60
 
59
61
  import {
60
62
  Graph,
@@ -104,6 +106,7 @@ export {
104
106
  Separator,
105
107
  Button,
106
108
  ButtonGroup,
109
+ ActionButtons,
107
110
  Reference,
108
111
  Binary,
109
112
  Image,
@@ -146,4 +149,5 @@ export {
146
149
  Spinner,
147
150
  Carousel,
148
151
  ColorPicker,
152
+ QRCode,
149
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
+ });