@gisce/ooui 2.23.0-alpha.2 → 2.23.0-alpha.4
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/Carousel.d.ts +11 -0
- package/dist/Carousel.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 +206 -186
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Carousel.ts +30 -0
- package/src/WidgetFactory.ts +4 -0
- package/src/index.ts +2 -0
- package/src/spec/Carousel.spec.ts +75 -0
package/package.json
CHANGED
package/src/Carousel.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import ContainerWidget from "./ContainerWidget";
|
|
2
|
+
import Group from "./Group";
|
|
3
|
+
import { parseBoolAttribute } from "./helpers/nodeParser";
|
|
4
|
+
|
|
5
|
+
class Carousel extends ContainerWidget {
|
|
6
|
+
_autoPlay = true;
|
|
7
|
+
|
|
8
|
+
get autoPlay(): boolean {
|
|
9
|
+
return this._autoPlay;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
set autoPlay(value: boolean) {
|
|
13
|
+
this._autoPlay = value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get items(): Group[] {
|
|
17
|
+
return this._container.rows.flat().filter((g) => !g.invisible) as Group[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
constructor(props?: any) {
|
|
21
|
+
super(props);
|
|
22
|
+
if (props) {
|
|
23
|
+
if ("auto_play" in props) {
|
|
24
|
+
this._autoPlay = parseBoolAttribute(props.auto_play);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Carousel;
|
package/src/WidgetFactory.ts
CHANGED
|
@@ -41,6 +41,7 @@ import Comments from "./Comments";
|
|
|
41
41
|
import JSONField from "./JSONField";
|
|
42
42
|
import Email from "./Email";
|
|
43
43
|
import Spinner from "./Spinner";
|
|
44
|
+
import Carousel from "./Carousel";
|
|
44
45
|
|
|
45
46
|
class WidgetFactory {
|
|
46
47
|
/**
|
|
@@ -184,6 +185,9 @@ class WidgetFactory {
|
|
|
184
185
|
case "spinner":
|
|
185
186
|
this._widgetClass = Spinner;
|
|
186
187
|
break;
|
|
188
|
+
case "carousel":
|
|
189
|
+
this._widgetClass = Carousel;
|
|
190
|
+
break;
|
|
187
191
|
default:
|
|
188
192
|
break;
|
|
189
193
|
}
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ import JSONField from "./JSONField";
|
|
|
53
53
|
import Comments from "./Comments";
|
|
54
54
|
import Email from "./Email";
|
|
55
55
|
import Spinner from "./Spinner";
|
|
56
|
+
import Carousel from "./Carousel";
|
|
56
57
|
|
|
57
58
|
import {
|
|
58
59
|
Graph,
|
|
@@ -142,4 +143,5 @@ export {
|
|
|
142
143
|
JSONField,
|
|
143
144
|
Email,
|
|
144
145
|
Spinner,
|
|
146
|
+
Carousel,
|
|
145
147
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import WidgetFactory from "../WidgetFactory";
|
|
2
|
+
import Form from "../Form";
|
|
3
|
+
import Carousel from "../Carousel";
|
|
4
|
+
import { it, expect, describe } from "vitest";
|
|
5
|
+
|
|
6
|
+
describe("A Carousel", () => {
|
|
7
|
+
it("should have an id corresponding to field name", () => {
|
|
8
|
+
const widgetFactory = new WidgetFactory();
|
|
9
|
+
const props = {
|
|
10
|
+
name: "carousel",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const widget = widgetFactory.createWidget("carousel", props);
|
|
14
|
+
expect(widget).toBeInstanceOf(Carousel);
|
|
15
|
+
});
|
|
16
|
+
it("should have autoPlay as true by default", () => {
|
|
17
|
+
const widgetFactory = new WidgetFactory();
|
|
18
|
+
const props = {
|
|
19
|
+
name: "carousel",
|
|
20
|
+
};
|
|
21
|
+
const widget = widgetFactory.createWidget("carousel", props);
|
|
22
|
+
expect(widget.autoPlay).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it("should allow autoPlay to be set", () => {
|
|
25
|
+
const widgetFactory = new WidgetFactory();
|
|
26
|
+
const props = {
|
|
27
|
+
name: "carousel",
|
|
28
|
+
auto_play: false,
|
|
29
|
+
};
|
|
30
|
+
const widget = widgetFactory.createWidget("carousel", props);
|
|
31
|
+
expect(widget.autoPlay).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
it("should have items with the first childs group items", () => {
|
|
34
|
+
const xml = `
|
|
35
|
+
<form>
|
|
36
|
+
<carousel name="carousel">
|
|
37
|
+
<group string="Group 1">
|
|
38
|
+
<field name="field1" string="Field 1" />
|
|
39
|
+
</group>
|
|
40
|
+
<group string="Group 2">
|
|
41
|
+
<field name="field2" string="Field 2" />
|
|
42
|
+
<group string="Group 3">
|
|
43
|
+
<field name="field3" string="Field 3" />
|
|
44
|
+
</group>
|
|
45
|
+
</group>
|
|
46
|
+
</carousel>
|
|
47
|
+
</form>
|
|
48
|
+
`;
|
|
49
|
+
const fields = {
|
|
50
|
+
field1: {
|
|
51
|
+
string: "Field 1",
|
|
52
|
+
type: "char",
|
|
53
|
+
size: 10,
|
|
54
|
+
},
|
|
55
|
+
field2: {
|
|
56
|
+
string: "Field 2",
|
|
57
|
+
type: "char",
|
|
58
|
+
size: 10,
|
|
59
|
+
},
|
|
60
|
+
field3: {
|
|
61
|
+
string: "Field 3",
|
|
62
|
+
type: "char",
|
|
63
|
+
size: 10,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const form = new Form(fields);
|
|
68
|
+
form.parse(xml);
|
|
69
|
+
const carousel = form.findById("carousel") as Carousel;
|
|
70
|
+
expect(carousel).toBeInstanceOf(Carousel);
|
|
71
|
+
expect(carousel.items.length).toBe(2);
|
|
72
|
+
expect(carousel.items[0].label).toBe("Group 1");
|
|
73
|
+
expect(carousel.items[1].label).toBe("Group 2");
|
|
74
|
+
});
|
|
75
|
+
});
|