@gisce/ooui 2.6.4 → 2.7.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/dist/Char.d.ts +1 -0
- package/dist/Char.d.ts.map +1 -1
- package/dist/Text.d.ts +7 -0
- package/dist/Text.d.ts.map +1 -1
- package/dist/ooui.es.js +48 -32
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Char.ts +4 -0
- package/src/Text.ts +19 -0
- package/src/spec/Char.spec.ts +31 -0
- package/src/spec/Text.spec.ts +67 -0
package/package.json
CHANGED
package/src/Char.ts
CHANGED
package/src/Text.ts
CHANGED
|
@@ -17,6 +17,22 @@ class Text extends Field {
|
|
|
17
17
|
this._placeholder = value;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
get showCount(): boolean {
|
|
21
|
+
return this.parsedWidgetProps.showCount || false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Field size
|
|
26
|
+
*/
|
|
27
|
+
_size: number | undefined;
|
|
28
|
+
get size(): number | undefined {
|
|
29
|
+
return this._size;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
set size(value: number | undefined) {
|
|
33
|
+
this._size = value;
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
/**
|
|
21
37
|
* Must expand widget
|
|
22
38
|
*/
|
|
@@ -75,6 +91,9 @@ class Text extends Field {
|
|
|
75
91
|
props.translate === "True" || props.translate === true
|
|
76
92
|
);
|
|
77
93
|
}
|
|
94
|
+
if (props.size) {
|
|
95
|
+
this.size = parseInt(props.size);
|
|
96
|
+
}
|
|
78
97
|
}
|
|
79
98
|
}
|
|
80
99
|
}
|
package/src/spec/Char.spec.ts
CHANGED
|
@@ -77,4 +77,35 @@ describe("A Char", () => {
|
|
|
77
77
|
|
|
78
78
|
expect(widget.tooltip).toBe("This is a help field");
|
|
79
79
|
});
|
|
80
|
+
describe("shouCount property", () => {
|
|
81
|
+
it("shoud default to false if is not defined", () => {
|
|
82
|
+
const widgetFactory = new WidgetFactory();
|
|
83
|
+
const props = {
|
|
84
|
+
name: "char1",
|
|
85
|
+
};
|
|
86
|
+
const widget = widgetFactory.createWidget("char", props);
|
|
87
|
+
|
|
88
|
+
expect(widget.showCount).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
it("should be true if is defined as true", () => {
|
|
91
|
+
const widgetFactory = new WidgetFactory();
|
|
92
|
+
const props = {
|
|
93
|
+
name: "char1",
|
|
94
|
+
widget_props: "{'showCount': true}",
|
|
95
|
+
};
|
|
96
|
+
const widget = widgetFactory.createWidget("char", props);
|
|
97
|
+
|
|
98
|
+
expect(widget.showCount).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
it("should be false if is defined as false", () => {
|
|
101
|
+
const widgetFactory = new WidgetFactory();
|
|
102
|
+
const props = {
|
|
103
|
+
name: "char1",
|
|
104
|
+
widget_props: "{'showCount': false}",
|
|
105
|
+
};
|
|
106
|
+
const widget = widgetFactory.createWidget("char", props);
|
|
107
|
+
|
|
108
|
+
expect(widget.showCount).toBe(false);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
80
111
|
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import WidgetFactory from "../WidgetFactory";
|
|
2
|
+
import { it, expect, describe } from "vitest";
|
|
3
|
+
|
|
4
|
+
describe("A Text field", () => {
|
|
5
|
+
describe("show count properly", () => {
|
|
6
|
+
it("should be false as default", () => {
|
|
7
|
+
const widgetFactory = new WidgetFactory();
|
|
8
|
+
const props = {
|
|
9
|
+
name: "text1",
|
|
10
|
+
};
|
|
11
|
+
const widget = widgetFactory.createWidget("text", props);
|
|
12
|
+
|
|
13
|
+
expect(widget.showCount).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
it("should be true when set", () => {
|
|
16
|
+
const widgetFactory = new WidgetFactory();
|
|
17
|
+
const props = {
|
|
18
|
+
name: "text1",
|
|
19
|
+
widget_props: "{'showCount': true}",
|
|
20
|
+
};
|
|
21
|
+
const widget = widgetFactory.createWidget("text", props);
|
|
22
|
+
|
|
23
|
+
expect(widget.showCount).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it("should be false when set", () => {
|
|
26
|
+
const widgetFactory = new WidgetFactory();
|
|
27
|
+
const props = {
|
|
28
|
+
name: "text1",
|
|
29
|
+
widget_props: "{'showCount': false}",
|
|
30
|
+
};
|
|
31
|
+
const widget = widgetFactory.createWidget("text", props);
|
|
32
|
+
|
|
33
|
+
expect(widget.showCount).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe("size property", () => {
|
|
37
|
+
it("should be undefined as default", () => {
|
|
38
|
+
const widgetFactory = new WidgetFactory();
|
|
39
|
+
const props = {
|
|
40
|
+
name: "text1",
|
|
41
|
+
};
|
|
42
|
+
const widget = widgetFactory.createWidget("text", props);
|
|
43
|
+
|
|
44
|
+
expect(widget.size).toBe(undefined);
|
|
45
|
+
});
|
|
46
|
+
it("should be set if is an string", () => {
|
|
47
|
+
const widgetFactory = new WidgetFactory();
|
|
48
|
+
const props = {
|
|
49
|
+
name: "text1",
|
|
50
|
+
size: "256",
|
|
51
|
+
};
|
|
52
|
+
const widget = widgetFactory.createWidget("text", props);
|
|
53
|
+
|
|
54
|
+
expect(widget.size).toBe(256);
|
|
55
|
+
});
|
|
56
|
+
it("should be set if is a number", () => {
|
|
57
|
+
const widgetFactory = new WidgetFactory();
|
|
58
|
+
const props = {
|
|
59
|
+
name: "text1",
|
|
60
|
+
size: 256,
|
|
61
|
+
};
|
|
62
|
+
const widget = widgetFactory.createWidget("text", props);
|
|
63
|
+
|
|
64
|
+
expect(widget.size).toBe(256);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|