@databrainhq/plugin 0.17.9-beta.3 → 0.17.9-beta.5
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/{Accordion-DCasHru9.mjs → Accordion-CmJ7ynND.mjs} +1 -1
- package/dist/{Chart-ByXFFZy8.mjs → Chart-BLj8fNfE.mjs} +3 -3
- package/dist/{CreateMetricV2-DoVIO13H.mjs → CreateMetricV2-CuPL106U.mjs} +4 -4
- package/dist/{MetricCardV2-ByrVVtRI.mjs → MetricCardV2-19G_jM-2.mjs} +3 -3
- package/dist/{NoDataState-o16v7iqs.mjs → NoDataState-DM2rpwFj.mjs} +1 -1
- package/dist/{TextAreaField-FdHerMAh.mjs → TextAreaField-DYwwQZtp.mjs} +1 -1
- package/dist/{chevron-down-jsrQKWvU.mjs → chevron-down-BJbeiVpM.mjs} +0 -0
- package/dist/{echarts-BXxWfANU.mjs → echarts-B_wP4U0w.mjs} +1 -1
- package/dist/{renderer-n_juUev3.mjs → renderer-Dz2BDxSA.mjs} +121 -121
- package/dist/webcomponents.es.js +5 -5
- package/dist/webcomponents.umd.js +37 -37
- package/package.json +1 -2
|
@@ -9,45 +9,45 @@ import { n as p, r as m } from "./theme-rUI0UkLh.mjs";
|
|
|
9
9
|
import { useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
|
|
10
10
|
import { createRoot as y } from "react-dom/client";
|
|
11
11
|
//#region src/sandbox/sandbox.css?inline
|
|
12
|
-
var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/, x = /^#[0-9a-fA-F]{6}$/,
|
|
12
|
+
var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/, x = /^#[0-9a-fA-F]{6}$/, te = /^[a-z]{2}(-[A-Z]{2})?$/, ne = [
|
|
13
13
|
"string",
|
|
14
14
|
"number",
|
|
15
15
|
"boolean"
|
|
16
|
-
],
|
|
16
|
+
], S = [
|
|
17
17
|
"schemaVersion",
|
|
18
18
|
"id",
|
|
19
19
|
"name",
|
|
20
20
|
"slots",
|
|
21
21
|
"options"
|
|
22
|
-
],
|
|
23
|
-
...
|
|
22
|
+
], re = [
|
|
23
|
+
...S,
|
|
24
24
|
"version",
|
|
25
25
|
"description",
|
|
26
26
|
"translations"
|
|
27
|
-
],
|
|
27
|
+
], C = [
|
|
28
28
|
"id",
|
|
29
29
|
"label",
|
|
30
30
|
"role",
|
|
31
31
|
"types",
|
|
32
32
|
"required"
|
|
33
|
-
],
|
|
33
|
+
], ie = [...C, "description"], ae = [
|
|
34
34
|
"id",
|
|
35
35
|
"label",
|
|
36
36
|
"type",
|
|
37
37
|
"default"
|
|
38
|
-
],
|
|
38
|
+
], w = {
|
|
39
39
|
boolean: [],
|
|
40
40
|
number: ["min", "max"],
|
|
41
41
|
string: ["maxLength"],
|
|
42
42
|
select: ["choices"],
|
|
43
43
|
color: []
|
|
44
|
-
},
|
|
44
|
+
}, oe = {
|
|
45
45
|
boolean: ["group"],
|
|
46
46
|
number: ["group", "step"],
|
|
47
47
|
string: ["group"],
|
|
48
48
|
select: ["group"],
|
|
49
49
|
color: ["group"]
|
|
50
|
-
},
|
|
50
|
+
}, T = (e) => typeof e == "number" && Number.isFinite(e), E = (e) => typeof e == "string" && e.length <= 256, se = class {
|
|
51
51
|
list = [];
|
|
52
52
|
add(e, t, n) {
|
|
53
53
|
this.list.push({
|
|
@@ -56,23 +56,23 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
56
56
|
message: n
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
},
|
|
59
|
+
}, D = (e, t, n, r, i, a, o = (e) => `${r}.${e}`) => {
|
|
60
60
|
let s = /* @__PURE__ */ new Set([...i, ...a]), c = !0;
|
|
61
61
|
for (let i of Object.keys(t)) s.has(i) || (e.add(`${r}.unknownKey`, `${n}/${i}`, `Remove "${i}". It is not a known key here.`), c = !1);
|
|
62
62
|
for (let r of i) Object.hasOwn(t, r) || (e.add(o(r), `${n}/${r}`, `Add the required key "${r}".`), c = !1);
|
|
63
63
|
return c;
|
|
64
|
-
},
|
|
64
|
+
}, ce = (e, t, n, r) => {
|
|
65
65
|
if (!l(t)) {
|
|
66
66
|
e.add("manifest.slot.invalid", n, "A slot must be an object.");
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
if (!
|
|
69
|
+
if (!D(e, t, n, "manifest.slot", C, r ? ie.slice(C.length) : [])) return;
|
|
70
70
|
i(t.id) || e.add("manifest.slot.id", `${n}/id`, "Use a slot id that starts with a letter and has only lowercase letters, digits, \"_\" or \"-\" (max 64)."), d(t.label) || e.add("manifest.slot.label", `${n}/label`, "Give the slot a label of 1 to 256 characters.");
|
|
71
71
|
let a = t.role;
|
|
72
72
|
a !== "dimension" && a !== "measure" && e.add("manifest.slot.role", `${n}/role`, "Set role to \"dimension\" or \"measure\"."), typeof t.required != "boolean" && e.add("manifest.slot.required", `${n}/required`, "Set required to true or false.");
|
|
73
73
|
let o = t.types;
|
|
74
|
-
Array.isArray(o) && o.length > 0 && o.length <= 3 && new Set(o).size === o.length && o.every((e) =>
|
|
75
|
-
},
|
|
74
|
+
Array.isArray(o) && o.length > 0 && o.length <= 3 && new Set(o).size === o.length && o.every((e) => ne.includes(e)) ? a === "measure" && (o.length !== 1 || o[0] !== "number") && e.add("manifest.slot.types", `${n}/types`, "A measure slot accepts only [\"number\"].") : e.add("manifest.slot.types", `${n}/types`, "List 1 to 3 unique types from \"string\", \"number\" and \"boolean\"."), Object.hasOwn(t, "description") && !d(t.description, 256) && e.add("manifest.slot.description", `${n}/description`, "A slot description is 1 to 256 characters.");
|
|
75
|
+
}, le = (e, t, n, r) => {
|
|
76
76
|
if (!l(t)) {
|
|
77
77
|
e.add("manifest.option.invalid", n, "An option must be an object.");
|
|
78
78
|
return;
|
|
@@ -82,27 +82,27 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
82
82
|
e.add("manifest.option.reserved", `${n}/id`, "The option id \"theme\" is reserved for the host theme. Choose another id.");
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
|
-
let o = typeof t.type == "string" ? t.type : "", s = Object.hasOwn(
|
|
85
|
+
let o = typeof t.type == "string" ? t.type : "", s = Object.hasOwn(w, o) ? w[o] : void 0;
|
|
86
86
|
if (!s || o === "color" && !r) {
|
|
87
87
|
e.add("manifest.option.type", `${n}/type`, r ? "Set type to \"boolean\", \"number\", \"string\", \"select\" or \"color\"." : "Set type to \"boolean\", \"number\", \"string\" or \"select\". \"color\" needs schemaVersion 2.");
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
if (
|
|
90
|
+
if (D(e, t, n, "manifest.option", [...ae, ...s], r ? oe[o] : [])) switch (i(a) || e.add("manifest.option.id", `${n}/id`, "Use an option id that starts with a letter and has only lowercase letters, digits, \"_\" or \"-\" (max 64)."), d(t.label) || e.add("manifest.option.label", `${n}/label`, "Give the option a label of 1 to 256 characters."), Object.hasOwn(t, "group") && !d(t.group, 64) && e.add("manifest.option.group", `${n}/group`, "A group label is 1 to 64 characters."), o) {
|
|
91
91
|
case "boolean":
|
|
92
92
|
typeof t.default != "boolean" && e.add("manifest.option.default", `${n}/default`, "A boolean option needs a true or false default.");
|
|
93
93
|
break;
|
|
94
94
|
case "number": {
|
|
95
|
-
if (!(
|
|
95
|
+
if (!(T(t.min) && T(t.max) && t.min <= t.max)) {
|
|
96
96
|
e.add("manifest.option.range", `${n}/min`, "Set finite min and max with min <= max.");
|
|
97
97
|
break;
|
|
98
98
|
}
|
|
99
99
|
let r = t.min, i = t.max;
|
|
100
|
-
(!
|
|
100
|
+
(!T(t.default) || t.default < r || t.default > i) && e.add("manifest.option.default", `${n}/default`, "The default must be a finite number between min and max."), Object.hasOwn(t, "step") && (!T(t.step) || t.step <= 0 || t.step > i - r) && e.add("manifest.option.step", `${n}/step`, "A step must be a positive number no larger than max - min.");
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
103
103
|
case "string": {
|
|
104
104
|
let r = t.maxLength;
|
|
105
|
-
if (!
|
|
105
|
+
if (!T(r) || !Number.isInteger(r) || r < 1 || r > 1024) {
|
|
106
106
|
e.add("manifest.option.maxLength", `${n}/maxLength`, "Set maxLength to an integer from 1 to 1024.");
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
@@ -120,7 +120,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
120
120
|
}
|
|
121
121
|
case "color": (typeof t.default != "string" || !x.test(t.default)) && e.add("manifest.option.color", `${n}/default`, "A color default is a six-digit hex string such as \"#3366cc\".");
|
|
122
122
|
}
|
|
123
|
-
},
|
|
123
|
+
}, ue = (e, t, n, r) => {
|
|
124
124
|
let i = "/translations";
|
|
125
125
|
if (!l(t)) {
|
|
126
126
|
e.add("manifest.translations.invalid", i, "translations must be an object keyed by language code.");
|
|
@@ -128,7 +128,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
128
128
|
}
|
|
129
129
|
for (let [a, o] of Object.entries(t)) {
|
|
130
130
|
let t = `${i}/${a}`;
|
|
131
|
-
if (!
|
|
131
|
+
if (!te.test(a)) {
|
|
132
132
|
e.add("manifest.translations.language", t, "Use a language code such as \"fr\" or \"pt-BR\".");
|
|
133
133
|
continue;
|
|
134
134
|
}
|
|
@@ -136,13 +136,13 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
136
136
|
e.add("manifest.translations.invalid", t, "A translation must be an object.");
|
|
137
137
|
continue;
|
|
138
138
|
}
|
|
139
|
-
if (
|
|
139
|
+
if (D(e, o, t, "manifest.translations", [], [
|
|
140
140
|
"name",
|
|
141
141
|
"description",
|
|
142
142
|
"slots",
|
|
143
143
|
"options"
|
|
144
144
|
])) {
|
|
145
|
-
for (let n of ["name", "description"]) Object.hasOwn(o, n) && !
|
|
145
|
+
for (let n of ["name", "description"]) Object.hasOwn(o, n) && !E(o[n]) && e.add("manifest.translations.text", `${t}/${n}`, "A translated string is at most 256 characters.");
|
|
146
146
|
if (Object.hasOwn(o, "slots")) {
|
|
147
147
|
let r = o.slots;
|
|
148
148
|
if (!l(r)) e.add("manifest.translations.invalid", `${t}/slots`, "slots must be an object keyed by slot id.");
|
|
@@ -152,11 +152,11 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
152
152
|
e.add("manifest.translations.slot", r, `There is no slot "${i}" to translate.`);
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
|
-
if (!l(a) || !
|
|
155
|
+
if (!l(a) || !D(e, a, r, "manifest.translations", [], ["label", "description"])) {
|
|
156
156
|
l(a) || e.add("manifest.translations.invalid", r, "A slot translation must be an object.");
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
|
-
for (let t of ["label", "description"]) Object.hasOwn(a, t) && !
|
|
159
|
+
for (let t of ["label", "description"]) Object.hasOwn(a, t) && !E(a[t]) && e.add("manifest.translations.text", `${r}/${t}`, "A translated string is at most 256 characters.");
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
if (Object.hasOwn(o, "options")) {
|
|
@@ -168,7 +168,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
168
168
|
e.add("manifest.translations.option", n, `There is no option "${i}" to translate.`);
|
|
169
169
|
continue;
|
|
170
170
|
}
|
|
171
|
-
if (!l(a) || !
|
|
171
|
+
if (!l(a) || !D(e, a, n, "manifest.translations", [], [
|
|
172
172
|
"label",
|
|
173
173
|
"group",
|
|
174
174
|
"choices"
|
|
@@ -176,7 +176,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
176
176
|
l(a) || e.add("manifest.translations.invalid", n, "An option translation must be an object.");
|
|
177
177
|
continue;
|
|
178
178
|
}
|
|
179
|
-
for (let t of ["label", "group"]) Object.hasOwn(a, t) && !
|
|
179
|
+
for (let t of ["label", "group"]) Object.hasOwn(a, t) && !E(a[t]) && e.add("manifest.translations.text", `${n}/${t}`, "A translated string is at most 256 characters.");
|
|
180
180
|
if (Object.hasOwn(a, "choices")) {
|
|
181
181
|
let t = a.choices;
|
|
182
182
|
if (!l(t)) {
|
|
@@ -185,27 +185,27 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
185
185
|
}
|
|
186
186
|
for (let [r, a] of Object.entries(t)) {
|
|
187
187
|
let t = `${n}/choices/${r}`;
|
|
188
|
-
o.type !== "select" || !o.choices.some((e) => e.value === r) ? e.add("manifest.translations.choice", t, `There is no choice "${r}" on option "${i}".`) :
|
|
188
|
+
o.type !== "select" || !o.choices.some((e) => e.value === r) ? e.add("manifest.translations.choice", t, `There is no choice "${r}" on option "${i}".`) : E(a) || e.add("manifest.translations.text", t, "A translated string is at most 256 characters.");
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
},
|
|
196
|
-
let t = new
|
|
195
|
+
}, de = (e) => {
|
|
196
|
+
let t = new se();
|
|
197
197
|
if (!l(e)) return t.add("manifest.invalid", "", "The manifest must be a JSON object."), t.list;
|
|
198
198
|
let n = e.schemaVersion;
|
|
199
199
|
if (n !== 1 && n !== 2) return t.add("manifest.schemaVersion.unsupported", "/schemaVersion", "Set schemaVersion to 1 or 2."), t.list;
|
|
200
200
|
let r = n === 2;
|
|
201
|
-
if (!
|
|
201
|
+
if (!D(t, e, "", "manifest", S, r ? re.slice(S.length) : [], (e) => `manifest.${e}.required`)) return t.list;
|
|
202
202
|
i(e.id) || t.add("manifest.id.invalid", "/id", "Use an id that starts with a letter and has only lowercase letters, digits, \"_\" or \"-\" (max 64). The chart type becomes \"custom:<id>\"."), d(e.name) || t.add("manifest.name.invalid", "/name", "Give the chart a name of 1 to 256 characters."), Object.hasOwn(e, "version") && (typeof e.version != "string" || !ee.test(e.version)) && t.add("manifest.version.invalid", "/version", "version must be a semver string such as \"1.2.0\"."), Object.hasOwn(e, "description") && !d(e.description, 500) && t.add("manifest.description.invalid", "/description", "description is 1 to 500 characters.");
|
|
203
203
|
let a = e.slots;
|
|
204
204
|
if (!Array.isArray(a)) t.add("manifest.slots.invalid", "/slots", "slots must be an array.");
|
|
205
205
|
else if (a.length === 0) t.add("manifest.slots.empty", "/slots", "Declare at least one slot.");
|
|
206
206
|
else if (a.length > 16) t.add("manifest.slots.tooMany", "/slots", "Declare at most 16 slots.");
|
|
207
207
|
else {
|
|
208
|
-
for (let [e, n] of a.entries())
|
|
208
|
+
for (let [e, n] of a.entries()) ce(t, n, `/slots/${e}`, r);
|
|
209
209
|
let e = /* @__PURE__ */ new Set();
|
|
210
210
|
a.forEach((n, r) => {
|
|
211
211
|
!l(n) || typeof n.id != "string" || (e.has(n.id) && t.add("manifest.slot.duplicate", `/slots/${r}/id`, `Slot id "${n.id}" is used more than once.`), e.add(n.id));
|
|
@@ -215,15 +215,15 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
215
215
|
if (!Array.isArray(o)) t.add("manifest.options.invalid", "/options", "options must be an array (it may be empty).");
|
|
216
216
|
else if (o.length > 32) t.add("manifest.options.tooMany", "/options", "Declare at most 32 options.");
|
|
217
217
|
else {
|
|
218
|
-
for (let [e, n] of o.entries())
|
|
218
|
+
for (let [e, n] of o.entries()) le(t, n, `/options/${e}`, r);
|
|
219
219
|
let e = /* @__PURE__ */ new Set();
|
|
220
220
|
o.forEach((n, r) => {
|
|
221
221
|
!l(n) || typeof n.id != "string" || (e.has(n.id) && t.add("manifest.option.duplicate", `/options/${r}/id`, `Option id "${n.id}" is used more than once.`), e.add(n.id));
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
return t.list.length === 0 && Object.hasOwn(e, "translations") &&
|
|
225
|
-
},
|
|
226
|
-
if (!
|
|
224
|
+
return t.list.length === 0 && Object.hasOwn(e, "translations") && ue(t, e.translations, a, o), t.list.length === 0 && s(e) > 32768 && t.add("manifest.size", "", "The manifest must be 32 KiB or smaller as JSON."), t.list;
|
|
225
|
+
}, O = (e) => de(e).length === 0 ? e : null, k = (e, t) => {
|
|
226
|
+
if (!O(e) || !l(t) || Object.keys(t).some((t) => !e.options.some((e) => e.id === t))) return null;
|
|
227
227
|
let n = {};
|
|
228
228
|
for (let r of e.options) {
|
|
229
229
|
let e = Object.hasOwn(t, r.id) ? t[r.id] : r.default, i = !1;
|
|
@@ -246,11 +246,11 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
246
246
|
n[r.id] = e;
|
|
247
247
|
}
|
|
248
248
|
return n;
|
|
249
|
-
},
|
|
250
|
-
if (!
|
|
249
|
+
}, A = "allow-scripts", j = "camera 'none'; microphone 'none'; geolocation 'none'; payment 'none'; usb 'none'; clipboard-read 'none'; clipboard-write 'none'; display-capture 'none'; fullscreen 'none'", M = (e) => {
|
|
250
|
+
if (!O(e.manifest)) throw Error("Invalid chart manifest. Check schema version 1.");
|
|
251
251
|
if (typeof e.javascript != "string" || e.javascript.trim().length === 0 || e.javascript.length > 2097152 || new TextEncoder().encode(e.javascript).byteLength > 2097152) throw Error("Chart bundle must contain JavaScript and be no larger than 2 MiB.");
|
|
252
252
|
if (e.css !== void 0 && (typeof e.css != "string" || e.css.length > 262144 || new TextEncoder().encode(e.css).byteLength > 262144)) throw Error("Chart stylesheet must be text no larger than 256 KiB.");
|
|
253
|
-
},
|
|
253
|
+
}, fe = (e) => `<style>${e.replace(/<\/(style)/gi, "<\\/$1")}</style>`, pe = (e) => [
|
|
254
254
|
"default-src 'none'",
|
|
255
255
|
"script-src 'unsafe-inline' data:",
|
|
256
256
|
"script-src-attr 'none'",
|
|
@@ -265,11 +265,11 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
265
265
|
"base-uri 'none'",
|
|
266
266
|
"form-action 'none'",
|
|
267
267
|
`frame-src ${e ? "blob:" : "'none'"}`
|
|
268
|
-
].join("; "),
|
|
268
|
+
].join("; "), me = (e) => {
|
|
269
269
|
let t = new TextEncoder().encode(e), n = "";
|
|
270
270
|
for (let e of t) n += String.fromCharCode(e);
|
|
271
271
|
return btoa(n);
|
|
272
|
-
},
|
|
272
|
+
}, he = (e) => e.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--"), N = (e, t) => `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${pe(t)}"><meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off"><title>Custom chart</title><style>html,body{margin:0;width:100%;height:100%;overflow:hidden}body{font:14px system-ui;color:CanvasText;background:Canvas}iframe{border:0;width:100%;height:100%}</style></head><body>${e}</body></html>`, ge = (e) => `(() => {
|
|
273
273
|
'use strict';
|
|
274
274
|
const channel = ${JSON.stringify(e)};
|
|
275
275
|
const send = (payload) => parent.postMessage({protocol:'dbn-chart-sandbox',version:1,channel,...payload}, '*');
|
|
@@ -292,19 +292,19 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
292
292
|
revision = m.revision; latest = m.data;
|
|
293
293
|
if (listener) listener(latest);
|
|
294
294
|
});
|
|
295
|
-
})();`,
|
|
296
|
-
if (
|
|
295
|
+
})();`, _e = (e, t, n) => {
|
|
296
|
+
if (M(e), !/^[a-zA-Z0-9-]{16,80}$/.test(t)) throw Error("Invalid sandbox channel.");
|
|
297
297
|
let r = new URL(n);
|
|
298
298
|
if (!["http:", "https:"].includes(r.protocol) || r.origin !== n) throw Error("Sandbox host must have an HTTP origin.");
|
|
299
|
-
let i =
|
|
300
|
-
return
|
|
299
|
+
let i = N(`${e.css ? fe(e.css) : ""}<div id="chart" role="img" aria-label="Custom chart"></div><script>${ge(t)}<\/script><script>${he(e.javascript)}<\/script>`, !1);
|
|
300
|
+
return N(`<script>${`(() => {
|
|
301
301
|
'use strict';
|
|
302
302
|
const channel = ${JSON.stringify(t)};
|
|
303
303
|
const hostOrigin = ${JSON.stringify(n)};
|
|
304
|
-
const childHtml = new TextDecoder().decode(Uint8Array.from(atob('${
|
|
304
|
+
const childHtml = new TextDecoder().decode(Uint8Array.from(atob('${me(i)}'), c => c.charCodeAt(0)));
|
|
305
305
|
const frame = document.createElement('iframe');
|
|
306
|
-
frame.setAttribute('sandbox', '${
|
|
307
|
-
frame.setAttribute('allow', ${JSON.stringify(
|
|
306
|
+
frame.setAttribute('sandbox', '${A}');
|
|
307
|
+
frame.setAttribute('allow', ${JSON.stringify(j)});
|
|
308
308
|
frame.referrerPolicy = 'no-referrer';
|
|
309
309
|
frame.title = 'Custom chart content';
|
|
310
310
|
const url = URL.createObjectURL(new Blob([childHtml], {type:'text/html'}));
|
|
@@ -336,7 +336,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
336
336
|
frame.src = url;
|
|
337
337
|
document.body.append(frame);
|
|
338
338
|
})();`}<\/script>`, !0);
|
|
339
|
-
},
|
|
339
|
+
}, ve = "dbn-chart-sandbox", P = 1048576, F = 5e3, I = [
|
|
340
340
|
"fontFamily",
|
|
341
341
|
"textColor",
|
|
342
342
|
"textSecondaryColor",
|
|
@@ -344,19 +344,19 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
344
344
|
"surfaceColor",
|
|
345
345
|
"borderColor",
|
|
346
346
|
"primaryColor"
|
|
347
|
-
], L = ["fontSize", "borderRadius"],
|
|
347
|
+
], L = ["fontSize", "borderRadius"], ye = /^[a-z]{2}(-[A-Z]{2})?$/, be = (e) => !l(e) || !o(e, [
|
|
348
348
|
...I,
|
|
349
349
|
...L,
|
|
350
350
|
"palette"
|
|
351
|
-
]) ? !1 : I.every((t) => typeof e[t] == "string" && e[t].length <= 256) && L.every((t) => typeof e[t] == "number" && Number.isFinite(e[t])) && Array.isArray(e.palette) && e.palette.length <= 32 && e.palette.every((e) => typeof e == "string" && e.length <= 256),
|
|
352
|
-
let t = Object.keys(e), n =
|
|
351
|
+
]) ? !1 : I.every((t) => typeof e[t] == "string" && e[t].length <= 256) && L.every((t) => typeof e[t] == "number" && Number.isFinite(e[t])) && Array.isArray(e.palette) && e.palette.length <= 32 && e.palette.every((e) => typeof e == "string" && e.length <= 256), xe = ["theme", "language"], Se = (e) => {
|
|
352
|
+
let t = Object.keys(e), n = xe.filter((t) => Object.hasOwn(e, t)).length;
|
|
353
353
|
return t.length === 3 + n && [
|
|
354
354
|
"columns",
|
|
355
355
|
"rows",
|
|
356
356
|
"options"
|
|
357
357
|
].every((t) => Object.hasOwn(e, t));
|
|
358
358
|
}, R = (e) => {
|
|
359
|
-
if (!l(e) || !
|
|
359
|
+
if (!l(e) || !Se(e) || Object.hasOwn(e, "theme") && !be(e.theme) || Object.hasOwn(e, "language") && !(typeof e.language == "string" && ye.test(e.language)) || !Array.isArray(e.columns) || e.columns.length < 1 || e.columns.length > 64 || !Array.isArray(e.rows) || e.rows.length > 5e3 || !l(e.options) || Object.keys(e.options).length > 32) return !1;
|
|
360
360
|
let t = e.columns;
|
|
361
361
|
return !t.every((e) => l(e) && (o(e, [
|
|
362
362
|
"id",
|
|
@@ -373,8 +373,8 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
373
373
|
"string",
|
|
374
374
|
"number",
|
|
375
375
|
"boolean"
|
|
376
|
-
].includes(e.type) && typeof e.filterable == "boolean") || new Set(t.map(({ id: e }) => e)).size !== t.length || !e.rows.every((e) => Array.isArray(e) && e.length === t.length && e.every((e, n) => a(e) && (e === null || typeof e === t[n].type))) || !Object.entries(e.options).every(([e, t]) => i(e) && t !== null && a(t)) ? !1 : s(e) <=
|
|
377
|
-
},
|
|
376
|
+
].includes(e.type) && typeof e.filterable == "boolean") || new Set(t.map(({ id: e }) => e)).size !== t.length || !e.rows.every((e) => Array.isArray(e) && e.length === t.length && e.every((e, n) => a(e) && (e === null || typeof e === t[n].type))) || !Object.entries(e.options).every(([e, t]) => i(e) && t !== null && a(t)) ? !1 : s(e) <= P;
|
|
377
|
+
}, Ce = (e, t) => {
|
|
378
378
|
if (!t.source || e.source !== t.source || e.origin !== "null") return null;
|
|
379
379
|
let n = e.data;
|
|
380
380
|
if (!l(n) || n.protocol !== "dbn-chart-sandbox" || n.version !== 1 || n.channel !== t.channel) return null;
|
|
@@ -401,20 +401,20 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
401
401
|
"values"
|
|
402
402
|
]) && t.data.columns[i].filterable && Array.isArray(n.values) && n.values.length <= 100 && n.values.every((e) => a(e) && t.data.rows.some((t) => t[i] === e)) && s(n) <= 32768 ? n : null;
|
|
403
403
|
}, z = (e, t, n) => ({
|
|
404
|
-
protocol:
|
|
404
|
+
protocol: ve,
|
|
405
405
|
version: 1,
|
|
406
406
|
channel: e,
|
|
407
407
|
type: "data",
|
|
408
408
|
revision: t,
|
|
409
409
|
data: n
|
|
410
|
-
}),
|
|
410
|
+
}), we = () => {
|
|
411
411
|
let e = globalThis.crypto;
|
|
412
412
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
413
413
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
414
414
|
if (e && typeof e.getRandomValues == "function") e.getRandomValues(t);
|
|
415
415
|
else for (let e = 0; e < t.length; e += 1) t[e] = Math.floor(Math.random() * 256);
|
|
416
416
|
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
417
|
-
},
|
|
417
|
+
}, Te = ({ bundle: e, data: t, onEvent: n }) => {
|
|
418
418
|
let r = _(null), i = _(n), a = _(null), [o, s] = v("loading");
|
|
419
419
|
return h(() => {
|
|
420
420
|
i.current = n;
|
|
@@ -424,15 +424,15 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
424
424
|
let n = t.ownerDocument.defaultView;
|
|
425
425
|
if (!n) return;
|
|
426
426
|
s("loading");
|
|
427
|
-
let o = t.ownerDocument.createElement("iframe"), c =
|
|
427
|
+
let o = t.ownerDocument.createElement("iframe"), c = we(), l;
|
|
428
428
|
try {
|
|
429
|
-
let t =
|
|
429
|
+
let t = _e(e, c, n.location.origin);
|
|
430
430
|
l = URL.createObjectURL(new Blob([t], { type: "text/html" }));
|
|
431
431
|
} catch {
|
|
432
432
|
s("error");
|
|
433
433
|
return;
|
|
434
434
|
}
|
|
435
|
-
o.className = "dbn-sandbox-frame", o.title = e.manifest.name, o.setAttribute("sandbox",
|
|
435
|
+
o.className = "dbn-sandbox-frame", o.title = e.manifest.name, o.setAttribute("sandbox", A), o.setAttribute("allow", j), o.referrerPolicy = "no-referrer", o.height = "320";
|
|
436
436
|
let u = !1, d = !0, f = 0, p = null, m = 0, h, g = () => {
|
|
437
437
|
d = !1, n.clearTimeout(h), o.remove(), URL.revokeObjectURL(l), s("error");
|
|
438
438
|
};
|
|
@@ -442,7 +442,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
442
442
|
g();
|
|
443
443
|
return;
|
|
444
444
|
}
|
|
445
|
-
let n =
|
|
445
|
+
let n = k(e.manifest, t.options);
|
|
446
446
|
if (!n || !R({
|
|
447
447
|
...t,
|
|
448
448
|
options: n
|
|
@@ -457,7 +457,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
457
457
|
};
|
|
458
458
|
let _ = (e) => {
|
|
459
459
|
if (!d || !p) return;
|
|
460
|
-
let t =
|
|
460
|
+
let t = Ce(e, {
|
|
461
461
|
source: o.contentWindow,
|
|
462
462
|
channel: c,
|
|
463
463
|
revision: f,
|
|
@@ -485,8 +485,8 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
485
485
|
containerRef: r,
|
|
486
486
|
status: o
|
|
487
487
|
};
|
|
488
|
-
}, B = n(),
|
|
489
|
-
let { containerRef: t, status: n } =
|
|
488
|
+
}, B = n(), Ee = (e) => {
|
|
489
|
+
let { containerRef: t, status: n } = Te(e);
|
|
490
490
|
return /* @__PURE__ */ (0, B.jsxs)("div", {
|
|
491
491
|
className: "dbn-sandbox-tile",
|
|
492
492
|
"data-sandbox-status": n,
|
|
@@ -505,37 +505,37 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
505
505
|
constructor(e, t, n) {
|
|
506
506
|
super(t), this.name = "CustomChartFetchError", this.code = e, this.status = n;
|
|
507
507
|
}
|
|
508
|
-
},
|
|
508
|
+
}, De = 3e5, Oe = /^[a-z][a-z0-9_-]{0,63}$/, H = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), ke = (e, t) => {
|
|
509
509
|
let n = U.get(e) ?? /* @__PURE__ */ new Set();
|
|
510
510
|
return n.add(t), U.set(e, n), () => {
|
|
511
511
|
n.delete(t), n.size === 0 && U.delete(e);
|
|
512
512
|
};
|
|
513
|
-
},
|
|
513
|
+
}, Ae = (e) => {
|
|
514
514
|
let t = U.get(e.key);
|
|
515
515
|
if (t) for (let n of [...t]) try {
|
|
516
516
|
n(e);
|
|
517
517
|
} catch {}
|
|
518
|
-
}, W = () => !!(typeof window < "u" && window.dbn?.isEnableProxyAuth),
|
|
518
|
+
}, W = () => !!(typeof window < "u" && window.dbn?.isEnableProxyAuth), je = (e) => {
|
|
519
519
|
let n = typeof window > "u" ? void 0 : window.dbn, r = e || n?.proxyAuthUrl || n?.baseUrl || t;
|
|
520
520
|
return String(r).replace(/\/+$/, "");
|
|
521
|
-
},
|
|
521
|
+
}, Me = (e, t) => `${je(t)}/api/v2/embed/custom-charts/${encodeURIComponent(e)}`, Ne = (t, n) => {
|
|
522
522
|
let r = {
|
|
523
523
|
Accept: "application/json",
|
|
524
524
|
...W() ? {} : { "X-Plugin-Token": t ?? "" },
|
|
525
525
|
...e() ?? {}
|
|
526
526
|
};
|
|
527
527
|
return typeof window < "u" && window.location?.host && (r["X-Plugin-Origin"] = window.location.host), n && (r["If-None-Match"] = n), r;
|
|
528
|
-
},
|
|
528
|
+
}, Pe = (e, t) => {
|
|
529
529
|
let n = (t) => new V("invalid", `The custom chart "${e}" response is not usable: ${t}.`);
|
|
530
530
|
if (!l(t)) throw n("not an object");
|
|
531
|
-
let r =
|
|
531
|
+
let r = O(t.manifest);
|
|
532
532
|
if (!r) throw n("the manifest does not validate");
|
|
533
533
|
if (r.id !== e) throw n("the manifest id does not match");
|
|
534
534
|
if (typeof t.bundleJs != "string") throw n("bundleJs is missing");
|
|
535
535
|
let i = t.bundleCss === void 0 || t.bundleCss === null ? void 0 : t.bundleCss;
|
|
536
536
|
if (i !== void 0 && typeof i != "string") throw n("bundleCss is not text");
|
|
537
537
|
try {
|
|
538
|
-
|
|
538
|
+
M({
|
|
539
539
|
manifest: r,
|
|
540
540
|
javascript: t.bundleJs,
|
|
541
541
|
...i === void 0 ? {} : { css: i }
|
|
@@ -554,7 +554,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
554
554
|
contentHash: t.contentHash,
|
|
555
555
|
versionNumber: typeof t.versionNumber == "number" && Number.isInteger(t.versionNumber) ? t.versionNumber : 0
|
|
556
556
|
};
|
|
557
|
-
},
|
|
557
|
+
}, Fe = async (e) => {
|
|
558
558
|
try {
|
|
559
559
|
let t = await e.json();
|
|
560
560
|
if (l(t) && l(t.error)) return {
|
|
@@ -566,12 +566,12 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
566
566
|
code: "",
|
|
567
567
|
message: ""
|
|
568
568
|
};
|
|
569
|
-
},
|
|
569
|
+
}, Ie = async (e, t, n) => {
|
|
570
570
|
let i = t.token ?? r(), a;
|
|
571
571
|
try {
|
|
572
|
-
a = await fetch(
|
|
572
|
+
a = await fetch(Me(e, t.baseUrl), {
|
|
573
573
|
method: "GET",
|
|
574
|
-
headers:
|
|
574
|
+
headers: Ne(i, n?.bundle ? n.etag : void 0),
|
|
575
575
|
signal: t.signal
|
|
576
576
|
});
|
|
577
577
|
} catch (e) {
|
|
@@ -582,7 +582,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
582
582
|
etag: n.etag
|
|
583
583
|
};
|
|
584
584
|
if (!a.ok) {
|
|
585
|
-
let { code: t, message: n } = await
|
|
585
|
+
let { code: t, message: n } = await Fe(a);
|
|
586
586
|
throw a.status === 404 || t === "custom_chart.not_published" ? new V("not_published", n || `The custom chart "${e}" is not published.`, a.status) : a.status === 401 || a.status === 403 ? new V("unauthorized", n || "The custom chart request was refused.", a.status) : new V("network", n || `The custom chart request failed with status ${a.status}.`, a.status);
|
|
587
587
|
}
|
|
588
588
|
let o;
|
|
@@ -591,15 +591,15 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
591
591
|
} catch {
|
|
592
592
|
throw new V("invalid", `The custom chart "${e}" response is not JSON.`, a.status);
|
|
593
593
|
}
|
|
594
|
-
let s =
|
|
594
|
+
let s = Pe(e, o);
|
|
595
595
|
return {
|
|
596
596
|
bundle: s,
|
|
597
597
|
etag: a.headers.get("ETag") ?? `"${s.contentHash}"`
|
|
598
598
|
};
|
|
599
|
-
},
|
|
600
|
-
if (!
|
|
599
|
+
}, Le = (e, t = {}) => {
|
|
600
|
+
if (!Oe.test(e)) return Promise.reject(new V("invalid", `"${e}" is not a chart key.`));
|
|
601
601
|
let n = H.get(e), i = Date.now();
|
|
602
|
-
if (n && (!n.bundle || i - n.fetchedAt <
|
|
602
|
+
if (n && (!n.bundle || i - n.fetchedAt < De)) return n.promise;
|
|
603
603
|
if (!t.token && !r() && !W()) return Promise.reject(new V("no_token", `No guest token is registered, so the custom chart "${e}" was not requested. The host must prime the bundle.`));
|
|
604
604
|
let a = {
|
|
605
605
|
promise: Promise.resolve(void 0),
|
|
@@ -607,10 +607,10 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
607
607
|
etag: n?.etag,
|
|
608
608
|
fetchedAt: n?.fetchedAt ?? 0
|
|
609
609
|
};
|
|
610
|
-
return a.promise =
|
|
610
|
+
return a.promise = Ie(e, t, n).then(({ bundle: e, etag: t }) => (a.bundle = e, a.etag = t, a.fetchedAt = Date.now(), Ae(e), e), (t) => {
|
|
611
611
|
throw H.get(e) === a && (n?.bundle ? H.set(e, n) : H.delete(e)), t;
|
|
612
612
|
}), H.set(e, a), a.promise;
|
|
613
|
-
}, G = (e) => H.get(e)?.bundle, K = 4096,
|
|
613
|
+
}, G = (e) => H.get(e)?.bundle, K = 4096, Re = (e, t) => {
|
|
614
614
|
let n = e.toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^[^a-z]+|_+$/g, "").slice(0, 48);
|
|
615
615
|
return n ? `${n}_${t}` : `col_${t}`;
|
|
616
616
|
}, q = (e) => {
|
|
@@ -621,28 +621,28 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
621
621
|
return Number.isFinite(t) ? t : null;
|
|
622
622
|
}
|
|
623
623
|
return null;
|
|
624
|
-
},
|
|
624
|
+
}, ze = (e) => {
|
|
625
625
|
if (e == null) return null;
|
|
626
626
|
if (e instanceof Date) return Number.isNaN(e.getTime()) ? null : e.toISOString();
|
|
627
627
|
let t = typeof e == "string" ? e : String(e);
|
|
628
628
|
return t.length > K ? t.slice(0, K) : t;
|
|
629
|
-
},
|
|
629
|
+
}, Be = (e) => typeof e == "boolean" ? e : e === "true" ? !0 : e === "false" ? !1 : e === 1 || e === 0 ? e === 1 : null, Ve = (e, t) => {
|
|
630
630
|
if (e.types.length === 1) return e.types[0];
|
|
631
631
|
let n = t.filter((e) => e != null);
|
|
632
632
|
return e.types.includes("boolean") && n.length > 0 && n.every((e) => typeof e == "boolean") ? "boolean" : e.types.includes("number") && n.length > 0 && n.every((e) => q(e) !== null) ? "number" : e.types.includes("string") ? "string" : e.types[0];
|
|
633
|
-
},
|
|
633
|
+
}, He = (e, t) => {
|
|
634
634
|
switch (e) {
|
|
635
635
|
case "number": return q(t);
|
|
636
|
-
case "boolean": return
|
|
637
|
-
default: return
|
|
636
|
+
case "boolean": return Be(t);
|
|
637
|
+
default: return ze(t);
|
|
638
638
|
}
|
|
639
|
-
},
|
|
640
|
-
let n =
|
|
639
|
+
}, Ue = (e, t) => {
|
|
640
|
+
let n = k(e, t);
|
|
641
641
|
if (n) return n;
|
|
642
642
|
let r = {};
|
|
643
|
-
for (let [n, i] of Object.entries(t))
|
|
644
|
-
return
|
|
645
|
-
},
|
|
643
|
+
for (let [n, i] of Object.entries(t)) k(e, { [n]: i }) && (r[n] = i);
|
|
644
|
+
return k(e, r) ?? {};
|
|
645
|
+
}, We = ({ manifest: e, config: t, rows: n, columns: r, theme: a, language: o }) => {
|
|
646
646
|
let c = /* @__PURE__ */ new Map();
|
|
647
647
|
if (r) for (let e of r) c.set(e.key, e.label);
|
|
648
648
|
if (c.size === 0 && n[0]) for (let e of Object.keys(n[0])) c.set(e, e);
|
|
@@ -651,21 +651,21 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
651
651
|
let e = (t.bindings[r.id] ?? []).filter((e) => c.has(e));
|
|
652
652
|
e.length === 0 && r.required && f.push(r);
|
|
653
653
|
for (let t of e) {
|
|
654
|
-
let e =
|
|
654
|
+
let e = Re(t, d.length);
|
|
655
655
|
for (; l.has(e) || !i(e);) e = `col_${d.length}_${l.size}`;
|
|
656
656
|
l.add(e), u[e] = t;
|
|
657
657
|
let a = n.slice(0, 200).map((e) => e[t]);
|
|
658
658
|
d.push({
|
|
659
659
|
id: e,
|
|
660
660
|
label: (c.get(t) || t).slice(0, 256) || e,
|
|
661
|
-
type:
|
|
661
|
+
type: Ve(r, a),
|
|
662
662
|
filterable: r.role === "dimension",
|
|
663
663
|
slotId: r.id,
|
|
664
664
|
source: t
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
let p = n.length, m = Math.min(p,
|
|
668
|
+
let p = n.length, m = Math.min(p, F), h = (r) => ({
|
|
669
669
|
columns: d.map(({ id: e, label: t, type: n, filterable: r, slotId: i }) => ({
|
|
670
670
|
id: e,
|
|
671
671
|
label: t,
|
|
@@ -673,8 +673,8 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
673
673
|
filterable: r,
|
|
674
674
|
slotId: i
|
|
675
675
|
})),
|
|
676
|
-
rows: n.slice(0, r).map((e) => d.map((t) =>
|
|
677
|
-
options:
|
|
676
|
+
rows: n.slice(0, r).map((e) => d.map((t) => He(t.type, e[t.source]))),
|
|
677
|
+
options: Ue(e, t.options),
|
|
678
678
|
...a ? { theme: a } : {},
|
|
679
679
|
...o ? { language: o } : {}
|
|
680
680
|
}), g = h(m);
|
|
@@ -692,7 +692,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
692
692
|
sources: u,
|
|
693
693
|
missingSlots: f
|
|
694
694
|
});
|
|
695
|
-
}, J = (e) => `This tile uses a custom chart (${c(e)}) that is not published.`,
|
|
695
|
+
}, J = (e) => `This tile uses a custom chart (${c(e)}) that is not published.`, Ge = (e) => e ? `Could not load the chart (HTTP ${e}).` : "Could not load the chart.", Y = "Showing first 5,000 rows", Ke = 8e3, qe = ".dbn-custom-chart{display:flex;flex-direction:column;width:100%;min-height:80px}\n.dbn-custom-chart__body{flex:1 1 auto;min-height:0}\n.dbn-custom-chart__state{display:flex;align-items:center;justify-content:center;min-height:80px;padding:12px;font:13px/1.4 system-ui,sans-serif;color:GrayText;text-align:center}\n.dbn-custom-chart__note{padding:4px 8px;font:12px/1.4 system-ui,sans-serif;color:GrayText;text-align:right}", Je = (e, t, n) => {
|
|
696
696
|
let [r, i] = v(() => {
|
|
697
697
|
let n = t ?? G(e);
|
|
698
698
|
return n ? {
|
|
@@ -708,7 +708,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
708
708
|
});
|
|
709
709
|
return;
|
|
710
710
|
}
|
|
711
|
-
let n = !0, r = new AbortController(), s, c =
|
|
711
|
+
let n = !0, r = new AbortController(), s, c = ke(e, (e) => {
|
|
712
712
|
n && (clearTimeout(s), i({
|
|
713
713
|
status: "ready",
|
|
714
714
|
bundle: e
|
|
@@ -717,7 +717,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
717
717
|
return l ? i({
|
|
718
718
|
status: "ready",
|
|
719
719
|
bundle: l
|
|
720
|
-
}) : (i({ status: "loading" }),
|
|
720
|
+
}) : (i({ status: "loading" }), Le(e, {
|
|
721
721
|
token: a,
|
|
722
722
|
baseUrl: o,
|
|
723
723
|
signal: r.signal
|
|
@@ -731,7 +731,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
731
731
|
let t = e instanceof V ? e.code : "network";
|
|
732
732
|
t === "not_published" ? i({ status: "unavailable" }) : t === "no_token" ? s = setTimeout(() => {
|
|
733
733
|
n && i({ status: "error" });
|
|
734
|
-
},
|
|
734
|
+
}, Ke) : i({
|
|
735
735
|
status: "error",
|
|
736
736
|
...e instanceof V && e.status ? { httpStatus: e.status } : {}
|
|
737
737
|
});
|
|
@@ -744,7 +744,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
744
744
|
a,
|
|
745
745
|
o
|
|
746
746
|
]), r;
|
|
747
|
-
},
|
|
747
|
+
}, Ye = (e, t, n) => {
|
|
748
748
|
let r = {}, i = {};
|
|
749
749
|
return t.forEach((t, a) => {
|
|
750
750
|
let o = e[a] ?? null;
|
|
@@ -756,12 +756,12 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
756
756
|
slotValues: r,
|
|
757
757
|
row: i
|
|
758
758
|
};
|
|
759
|
-
},
|
|
760
|
-
let f =
|
|
759
|
+
}, Xe = ({ chartKey: e, config: t, rows: n, columns: r, bundle: i, auth: a, theme: o, language: s, className: c, onClick: l, onFilter: u, onResize: d }) => {
|
|
760
|
+
let f = Je(e, i, a), p = f.status === "ready" ? f.bundle : void 0, m = g(() => p ? {
|
|
761
761
|
manifest: p.manifest,
|
|
762
762
|
javascript: p.bundleJs,
|
|
763
763
|
...p.bundleCss ? { css: p.bundleCss } : {}
|
|
764
|
-
} : null, [p]), h = g(() => p ?
|
|
764
|
+
} : null, [p]), h = g(() => p ? We({
|
|
765
765
|
manifest: p.manifest,
|
|
766
766
|
config: t,
|
|
767
767
|
rows: n,
|
|
@@ -783,7 +783,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
783
783
|
l?.({
|
|
784
784
|
rowIndex: e.rowIndex,
|
|
785
785
|
columnId: e.columnId,
|
|
786
|
-
...
|
|
786
|
+
...Ye(t, h.data.columns, h.sources)
|
|
787
787
|
});
|
|
788
788
|
} else if (e.type === "filter") {
|
|
789
789
|
let t = h.sources[e.columnId];
|
|
@@ -807,7 +807,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
807
807
|
else if (f.status === "error") y = /* @__PURE__ */ (0, B.jsx)("div", {
|
|
808
808
|
className: "dbn-custom-chart__state",
|
|
809
809
|
role: "status",
|
|
810
|
-
children:
|
|
810
|
+
children: Ge(f.httpStatus)
|
|
811
811
|
});
|
|
812
812
|
else if (f.status === "unavailable" || !m || !h) y = /* @__PURE__ */ (0, B.jsx)("div", {
|
|
813
813
|
className: "dbn-custom-chart__state",
|
|
@@ -821,21 +821,21 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
821
821
|
role: "status",
|
|
822
822
|
children: e ? `This custom chart needs the "${e.label}" slot bound.` : "This custom chart has no columns bound."
|
|
823
823
|
});
|
|
824
|
-
} else y = /* @__PURE__ */ (0, B.jsx)(
|
|
824
|
+
} else y = /* @__PURE__ */ (0, B.jsx)(Ee, {
|
|
825
825
|
bundle: m,
|
|
826
826
|
data: h.data,
|
|
827
827
|
onEvent: _
|
|
828
828
|
}), h.truncated && (b = /* @__PURE__ */ (0, B.jsx)("div", {
|
|
829
829
|
className: "dbn-custom-chart__note",
|
|
830
830
|
role: "note",
|
|
831
|
-
children:
|
|
831
|
+
children: Y
|
|
832
832
|
}));
|
|
833
833
|
return /* @__PURE__ */ (0, B.jsxs)("div", {
|
|
834
834
|
className: v,
|
|
835
835
|
"data-custom-chart": e,
|
|
836
836
|
"data-custom-chart-status": f.status,
|
|
837
837
|
children: [
|
|
838
|
-
/* @__PURE__ */ (0, B.jsx)("style", { children:
|
|
838
|
+
/* @__PURE__ */ (0, B.jsx)("style", { children: qe }),
|
|
839
839
|
/* @__PURE__ */ (0, B.jsx)("div", {
|
|
840
840
|
className: "dbn-custom-chart__body",
|
|
841
841
|
children: y
|
|
@@ -846,7 +846,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
846
846
|
}, X = (e, t) => {
|
|
847
847
|
let n = (e ?? "").trim() || t;
|
|
848
848
|
return n.length > 256 ? n.slice(0, 256) : n;
|
|
849
|
-
},
|
|
849
|
+
}, Ze = (e, t) => {
|
|
850
850
|
let n = Number.parseFloat(e);
|
|
851
851
|
return Number.isFinite(n) ? n : t;
|
|
852
852
|
}, Z = (e, t) => {
|
|
@@ -855,7 +855,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
855
855
|
if (t) return t;
|
|
856
856
|
}
|
|
857
857
|
return "";
|
|
858
|
-
},
|
|
858
|
+
}, Qe = (e, t = {}) => {
|
|
859
859
|
let n = m(e, t), r = X(Z(e, ["--dbn-color-background", "--background"]), n.surface);
|
|
860
860
|
return {
|
|
861
861
|
fontFamily: X(n.text.fontFamily, "system-ui, sans-serif"),
|
|
@@ -865,17 +865,17 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
865
865
|
background: r,
|
|
866
866
|
surfaceColor: X(Z(e, ["--card"]), n.surface || r),
|
|
867
867
|
borderColor: X(Z(e, ["--dbn-border-color", "--border"]), n.splitLine),
|
|
868
|
-
borderRadius:
|
|
868
|
+
borderRadius: Ze(Z(e, ["--dbn-border-radius", "--radius"]), 8),
|
|
869
869
|
primaryColor: X(Z(e, ["--dbn-color-primary", "--primary"]), n.palette[0] ?? "Highlight"),
|
|
870
870
|
palette: n.palette.slice(0, 32).map((e) => X(e, ""))
|
|
871
871
|
};
|
|
872
|
-
},
|
|
872
|
+
}, $e = (e) => {
|
|
873
873
|
for (let t of Object.values(e.slotValues)) {
|
|
874
874
|
let e = t[0];
|
|
875
875
|
if (typeof e == "string" || typeof e == "number") return e;
|
|
876
876
|
}
|
|
877
877
|
return "";
|
|
878
|
-
}, Q = (e) => typeof e == "number" ? e : null,
|
|
878
|
+
}, Q = (e) => typeof e == "number" ? e : null, et = (e) => e.closest("[lang]")?.getAttribute("lang")?.trim() || void 0, tt = (e, t) => {
|
|
879
879
|
let n = f(e.type) ?? "", r = e.data, i = r.customChart ?? u({ chartType: e.type }) ?? {
|
|
880
880
|
key: n,
|
|
881
881
|
bindings: {},
|
|
@@ -883,24 +883,24 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
883
883
|
}, a = Array.isArray(r.rows) ? r.rows : [], o = Array.isArray(r.columns) ? r.columns.map(({ key: e, label: t }) => ({
|
|
884
884
|
key: e,
|
|
885
885
|
label: t
|
|
886
|
-
})) : void 0, s =
|
|
886
|
+
})) : void 0, s = Qe(t.host, {
|
|
887
887
|
appearance: e.appearance,
|
|
888
888
|
adminTheme: e.adminTheme,
|
|
889
889
|
chartColors: e.chartColors
|
|
890
890
|
}), c = typeof e.onEvents?.click == "function" ? e.onEvents.click : void 0;
|
|
891
|
-
return /* @__PURE__ */ (0, B.jsx)(
|
|
891
|
+
return /* @__PURE__ */ (0, B.jsx)(Xe, {
|
|
892
892
|
chartKey: n,
|
|
893
893
|
config: i,
|
|
894
894
|
rows: a,
|
|
895
895
|
columns: o,
|
|
896
896
|
theme: s,
|
|
897
|
-
language:
|
|
897
|
+
language: et(t.host),
|
|
898
898
|
className: e.className,
|
|
899
899
|
onClick: (e) => {
|
|
900
900
|
let n = e.row[e.columnId], r = Object.values(e.slotValues).flat().find((e) => typeof e == "number");
|
|
901
901
|
t.onDataPointClick({
|
|
902
902
|
seriesName: e.columnId,
|
|
903
|
-
category:
|
|
903
|
+
category: $e(e),
|
|
904
904
|
value: Q(n) ?? Q(r) ?? null
|
|
905
905
|
});
|
|
906
906
|
let i = Object.entries(e.row).map(([e, t]) => ({
|
|
@@ -920,7 +920,7 @@ var b = ".dbn-sandbox-frame{border:0;width:100%;display:block}", ee = /^(0|[1-9]
|
|
|
920
920
|
let { host: t } = e, n = t.ownerDocument.createElement("div");
|
|
921
921
|
n.className = "dbn-custom-chart-mount", n.style.width = "100%", t.append(n);
|
|
922
922
|
let r = f(e.props.type), i = y(n), a = (t) => {
|
|
923
|
-
i && i.render(r ?
|
|
923
|
+
i && i.render(r ? tt(t, e) : /* @__PURE__ */ (0, B.jsx)("div", {
|
|
924
924
|
role: "status",
|
|
925
925
|
children: J(String(t.type).replace(/^custom:/, ""))
|
|
926
926
|
}));
|