@gisce/ooui 2.37.0-alpha.1 → 2.37.0

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.37.0-alpha.1",
3
+ "version": "2.37.0",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
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,7 +3,6 @@ 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";
7
6
  import Label from "./Label";
8
7
  import Char from "./Char";
9
8
  import Text from "./Text";
@@ -44,6 +43,7 @@ import Email from "./Email";
44
43
  import Spinner from "./Spinner";
45
44
  import Carousel from "./Carousel";
46
45
  import ColorPicker from "./ColorPicker";
46
+ import QRCode from "./QRCode";
47
47
 
48
48
  class WidgetFactory {
49
49
  /**
@@ -77,9 +77,6 @@ class WidgetFactory {
77
77
  case "buttonGroup":
78
78
  this._widgetClass = ButtonGroup;
79
79
  break;
80
- case "action_buttons":
81
- this._widgetClass = ActionButtons;
82
- break;
83
80
  case "selection":
84
81
  this._widgetClass = Selection;
85
82
  break;
@@ -196,6 +193,9 @@ class WidgetFactory {
196
193
  case "colorPicker":
197
194
  this._widgetClass = ColorPicker;
198
195
  break;
196
+ case "qrcode":
197
+ this._widgetClass = QRCode;
198
+ break;
199
199
  default:
200
200
  break;
201
201
  }
package/src/index.ts CHANGED
@@ -27,7 +27,6 @@ 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";
31
30
  import Reference from "./Reference";
32
31
  import Binary from "./Binary";
33
32
  import Image from "./Image";
@@ -56,6 +55,7 @@ import Email from "./Email";
56
55
  import Spinner from "./Spinner";
57
56
  import Carousel from "./Carousel";
58
57
  import ColorPicker from "./ColorPicker";
58
+ import QRCode from "./QRCode";
59
59
 
60
60
  import {
61
61
  Graph,
@@ -105,7 +105,6 @@ export {
105
105
  Separator,
106
106
  Button,
107
107
  ButtonGroup,
108
- ActionButtons,
109
108
  Reference,
110
109
  Binary,
111
110
  Image,
@@ -148,4 +147,5 @@ export {
148
147
  Spinner,
149
148
  Carousel,
150
149
  ColorPicker,
150
+ QRCode,
151
151
  };
@@ -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
+ });
@@ -1,5 +0,0 @@
1
- import Field from "./Field";
2
- declare class ActionButtons extends Field {
3
- }
4
- export default ActionButtons;
5
- //# sourceMappingURL=ActionButtons.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ActionButtons.d.ts","sourceRoot":"","sources":["../src/ActionButtons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,cAAM,aAAc,SAAQ,KAAK;CAAG;AAEpC,eAAe,aAAa,CAAC"}
@@ -1,5 +0,0 @@
1
- import Field from "./Field";
2
-
3
- class ActionButtons extends Field {}
4
-
5
- export default ActionButtons;