@gisce/ooui 2.40.0-alpha.1 → 2.40.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/dist/Image.d.ts +7 -0
- package/dist/Image.d.ts.map +1 -1
- package/dist/ooui.es.js +78 -51
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Image.ts +34 -0
- package/src/spec/Image.spec.ts +28 -0
package/package.json
CHANGED
package/src/Image.ts
CHANGED
|
@@ -4,9 +4,43 @@ import Field from "./Field";
|
|
|
4
4
|
* Image base64 field
|
|
5
5
|
*/
|
|
6
6
|
class Image extends Field {
|
|
7
|
+
_width?: number;
|
|
8
|
+
get width(): number | undefined {
|
|
9
|
+
return this._width;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
set width(value: number | undefined) {
|
|
13
|
+
this._width = value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_height?: number;
|
|
17
|
+
get height(): number | undefined {
|
|
18
|
+
return this._height;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
set height(value: number | undefined) {
|
|
22
|
+
this._height = value;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
get showControls(): boolean {
|
|
8
26
|
return this.parsedWidgetProps?.showControls ?? true;
|
|
9
27
|
}
|
|
28
|
+
|
|
29
|
+
constructor(props: any) {
|
|
30
|
+
super(props);
|
|
31
|
+
|
|
32
|
+
if (props) {
|
|
33
|
+
if (props.width) {
|
|
34
|
+
const parsedWidth = parseInt(props.width);
|
|
35
|
+
this._width = isNaN(parsedWidth) ? undefined : parsedWidth;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (props.height) {
|
|
39
|
+
const parsedHeight = parseInt(props.height);
|
|
40
|
+
this._height = isNaN(parsedHeight) ? undefined : parsedHeight;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
10
44
|
}
|
|
11
45
|
|
|
12
46
|
export default Image;
|
package/src/spec/Image.spec.ts
CHANGED
|
@@ -16,4 +16,32 @@ describe("Image", () => {
|
|
|
16
16
|
const image = new Image(props);
|
|
17
17
|
expect(image.showControls).toBe(false);
|
|
18
18
|
});
|
|
19
|
+
it("should parse width property", () => {
|
|
20
|
+
const props = { width: "100" };
|
|
21
|
+
const image = new Image(props);
|
|
22
|
+
expect(image.width).toBe(100);
|
|
23
|
+
});
|
|
24
|
+
it("should parse height property", () => {
|
|
25
|
+
const props = { height: "50" };
|
|
26
|
+
const image = new Image(props);
|
|
27
|
+
expect(image.height).toBe(50);
|
|
28
|
+
});
|
|
29
|
+
it("should parse both width and height properties", () => {
|
|
30
|
+
const props = { width: "200", height: "150" };
|
|
31
|
+
const image = new Image(props);
|
|
32
|
+
expect(image.width).toBe(200);
|
|
33
|
+
expect(image.height).toBe(150);
|
|
34
|
+
});
|
|
35
|
+
it("should handle undefined width and height", () => {
|
|
36
|
+
const props = {};
|
|
37
|
+
const image = new Image(props);
|
|
38
|
+
expect(image.width).toBeUndefined();
|
|
39
|
+
expect(image.height).toBeUndefined();
|
|
40
|
+
});
|
|
41
|
+
it("should handle invalid width and height", () => {
|
|
42
|
+
const props = { width: "invalid", height: "invalid" };
|
|
43
|
+
const image = new Image(props);
|
|
44
|
+
expect(image.width).toBeUndefined();
|
|
45
|
+
expect(image.height).toBeUndefined();
|
|
46
|
+
});
|
|
19
47
|
});
|