@gisce/ooui 2.18.0-alpha.4 → 2.18.0-rc.1

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.18.0-alpha.4",
3
+ "version": "2.18.0-rc.1",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
package/src/Spinner.ts ADDED
@@ -0,0 +1,23 @@
1
+ import ContainerWidget from "./ContainerWidget";
2
+
3
+ class Spinner extends ContainerWidget {
4
+ _loading = false;
5
+ get loading(): boolean {
6
+ return this._loading;
7
+ }
8
+
9
+ set loading(value: boolean) {
10
+ this._loading = value;
11
+ }
12
+
13
+ constructor(props?: any) {
14
+ super(props);
15
+ if (props) {
16
+ if (props.loading) {
17
+ this._loading = props.loading;
18
+ }
19
+ }
20
+ }
21
+ }
22
+
23
+ export default Spinner;
@@ -40,6 +40,7 @@ import Alert from "./Alert";
40
40
  import Comments from "./Comments";
41
41
  import JSONField from "./JSONField";
42
42
  import Email from "./Email";
43
+ import Spinner from "./Spinner";
43
44
 
44
45
  class WidgetFactory {
45
46
  /**
@@ -180,6 +181,9 @@ class WidgetFactory {
180
181
  case "arrow_steps":
181
182
  this._widgetClass = JSONField;
182
183
  break;
184
+ case "spinner":
185
+ this._widgetClass = Spinner;
186
+ break;
183
187
  default:
184
188
  break;
185
189
  }
package/src/index.ts CHANGED
@@ -52,6 +52,7 @@ import Alert from "./Alert";
52
52
  import JSONField from "./JSONField";
53
53
  import Comments from "./Comments";
54
54
  import Email from "./Email";
55
+ import Spinner from "./Spinner";
55
56
 
56
57
  import {
57
58
  Graph,
@@ -140,4 +141,5 @@ export {
140
141
  Comments,
141
142
  JSONField,
142
143
  Email,
144
+ Spinner,
143
145
  };
@@ -0,0 +1,35 @@
1
+ import WidgetFactory from "../WidgetFactory";
2
+ import Spinner from "../Spinner";
3
+ import { it, expect, describe } from "vitest";
4
+
5
+ describe("A Spinner", () => {
6
+ it("should have an id corresponding to field name", () => {
7
+ const widgetFactory = new WidgetFactory();
8
+ const props = {
9
+ name: "spinner",
10
+ };
11
+
12
+ const widget = widgetFactory.createWidget("spinner", props);
13
+ expect(widget).toBeInstanceOf(Spinner);
14
+ });
15
+
16
+ it("should properly set label", () => {
17
+ const widgetFactory = new WidgetFactory();
18
+ const props = {
19
+ name: "spinner",
20
+ string: "spinner caption",
21
+ };
22
+ const widget = widgetFactory.createWidget("spinner", props);
23
+
24
+ expect(widget.label).toBe("spinner caption");
25
+ });
26
+
27
+ it("should have loading as false by default", () => {
28
+ const widgetFactory = new WidgetFactory();
29
+ const props = {
30
+ name: "spinner",
31
+ };
32
+ const widget = widgetFactory.createWidget("spinner", props);
33
+ expect(widget.loading).toBe(false);
34
+ });
35
+ });