@soonspacejs/plugin-poi-renderer 2.13.16 → 2.14.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/index.d.ts +1 -2
- package/dist/index.esm.js +117 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import SoonSpace from 'soonspacejs';
|
|
2
|
-
import type { PoiNode, PoiNodeInfo } from 'soonspacejs';
|
|
1
|
+
import { default as SoonSpace, PoiNode, PoiNodeInfo } from 'soonspacejs';
|
|
3
2
|
import * as CSS from 'csstype';
|
|
4
3
|
export type PoiNodeBaseOption = Omit<PoiNodeInfo, 'element'>;
|
|
5
4
|
export interface PoiNodeCustomOptions extends PoiNodeBaseOption {
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1,117 @@
|
|
|
1
|
-
const
|
|
1
|
+
const m = {
|
|
2
|
+
width: "400px",
|
|
3
|
+
height: "300px",
|
|
4
|
+
backgroundColor: "black"
|
|
5
|
+
};
|
|
6
|
+
var f = /* @__PURE__ */ ((n) => (n.PANEL = "PANEL", n.VIDEO = "VIDEO", n.VIDEO_STREAM = "VIDEO_STREAM", n))(f || {});
|
|
7
|
+
class x {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
this.ssp = t, this.poiIdSet = /* @__PURE__ */ new Set();
|
|
10
|
+
}
|
|
11
|
+
poiIdSet;
|
|
12
|
+
resetStyleName(t) {
|
|
13
|
+
const e = [...t];
|
|
14
|
+
for (const s in e)
|
|
15
|
+
e[s] !== e[s].toLowerCase() && (e[s] = `-${e[s].toLowerCase()}`);
|
|
16
|
+
return e.join("");
|
|
17
|
+
}
|
|
18
|
+
mergeElementStyle(t) {
|
|
19
|
+
let e = "";
|
|
20
|
+
for (const s in t)
|
|
21
|
+
e += `${this.resetStyleName(s)}: ${t[s]};`;
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
renderCustom(t) {
|
|
25
|
+
const { tagName: e, style: s = m, innerHTML: r } = t, o = document.createElement(e);
|
|
26
|
+
return o.style.cssText = this.mergeElementStyle(s), r && (o.innerHTML = r), this.ssp.createPoiNode({
|
|
27
|
+
...t,
|
|
28
|
+
element: o
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
renderVideo(t) {
|
|
32
|
+
const {
|
|
33
|
+
src: e,
|
|
34
|
+
style: s = m,
|
|
35
|
+
isLoop: r = !0,
|
|
36
|
+
autoPlay: o = !0
|
|
37
|
+
} = t, l = document.createElement("video");
|
|
38
|
+
return l.style.cssText = this.mergeElementStyle(s), l.controls = !0, l.muted = !0, l.loop = r, l.autoplay = o, e && (l.src = e), this.ssp.createPoiNode({
|
|
39
|
+
...t,
|
|
40
|
+
element: l
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
renderPanel(t) {
|
|
44
|
+
const { dataSource: e, rowStyle: s, labelStyle: r, valueStyle: o } = t, l = e.map(
|
|
45
|
+
(i) => `<div style="${this.mergeElementStyle(s || {})}">
|
|
46
|
+
<span style="${this.mergeElementStyle(r || {})}">${i.label}</span>
|
|
47
|
+
<span style="${this.mergeElementStyle(o || {})}">${i.value}</span>
|
|
48
|
+
</div>`
|
|
49
|
+
).join("");
|
|
50
|
+
return this.renderCustom({
|
|
51
|
+
tagName: "div",
|
|
52
|
+
...t,
|
|
53
|
+
innerHTML: l
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
batchRender(t) {
|
|
57
|
+
const { dataSource: e } = t;
|
|
58
|
+
this.poiIdSet.forEach((r) => {
|
|
59
|
+
this.ssp.removeObjectById(r);
|
|
60
|
+
}), this.poiIdSet.clear();
|
|
61
|
+
const s = (r) => {
|
|
62
|
+
const { id: o, pid: l, width: i, height: d, dataSource: g, fileUrl: S, style: E, visible: b } = r;
|
|
63
|
+
let c = this.ssp.getObjectById(o);
|
|
64
|
+
const h = b;
|
|
65
|
+
if (this.poiIdSet.add(o), r.contentType === "VIDEO")
|
|
66
|
+
c = this.renderVideo({
|
|
67
|
+
...r,
|
|
68
|
+
src: S,
|
|
69
|
+
visible: h,
|
|
70
|
+
style: {
|
|
71
|
+
width: i + "px",
|
|
72
|
+
height: d + "px"
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
else if (r.contentType === "PANEL") {
|
|
76
|
+
const {
|
|
77
|
+
panel: { bodyStyle: a, rowStyle: y, labelStyle: p, valueStyle: u }
|
|
78
|
+
} = JSON.parse(E);
|
|
79
|
+
c = this.renderPanel({
|
|
80
|
+
...r,
|
|
81
|
+
visible: h,
|
|
82
|
+
style: {
|
|
83
|
+
width: i + "px",
|
|
84
|
+
height: d + "px",
|
|
85
|
+
backgroundImage: `url(${S})`,
|
|
86
|
+
overflow: "auto",
|
|
87
|
+
...a,
|
|
88
|
+
padding: a.padding + "px"
|
|
89
|
+
},
|
|
90
|
+
rowStyle: {
|
|
91
|
+
...y,
|
|
92
|
+
gap: y.gap + "px"
|
|
93
|
+
},
|
|
94
|
+
labelStyle: {
|
|
95
|
+
...p,
|
|
96
|
+
fontSize: p.fontSize + "px"
|
|
97
|
+
},
|
|
98
|
+
valueStyle: {
|
|
99
|
+
...u,
|
|
100
|
+
fontSize: u.fontSize + "px"
|
|
101
|
+
},
|
|
102
|
+
dataSource: g
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (c && l) {
|
|
106
|
+
const a = this.ssp.getObjectById(l);
|
|
107
|
+
a && this.ssp.addObject(c, a);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
e.forEach(s);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
m as DefaultStyle,
|
|
115
|
+
f as PoiContentTypeEnum,
|
|
116
|
+
x as default
|
|
117
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-poi-renderer",
|
|
3
3
|
"pluginName": "PoiRendererPlugin",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.14.0",
|
|
5
5
|
"description": "Poi-renderer plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xunwei",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "4c85e8b7b8ad24ccb9b42f3a1826bca377c42a6d",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.
|
|
18
|
+
"soonspacejs": "2.14.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"csstype": "^3.1.2"
|