@squadico/chatbot 1.6.0 → 1.8.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/README.md +4 -4
- package/dist/{answer-Bi8GWLyA.cjs → answer-C3IUYu5f.cjs} +3 -3
- package/dist/answer-C3IUYu5f.cjs.map +1 -0
- package/dist/{answer-BDuY6oLY.js → answer-CQWAgbwL.js} +17 -5
- package/dist/answer-CQWAgbwL.js.map +1 -0
- package/dist/chatbot-widgets.global.js +3 -3
- package/dist/chatbot-widgets.global.js.map +1 -1
- package/dist/chatbot.global.js +11 -11
- package/dist/chatbot.global.js.map +1 -1
- package/dist/extras-CFSQMYPh.cjs +4 -0
- package/dist/extras-CFSQMYPh.cjs.map +1 -0
- package/dist/{extras-BSCTuiit.js → extras-DP27_4bx.js} +178 -115
- package/dist/extras-DP27_4bx.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/client.d.ts +2 -0
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/i18n.d.ts +5 -0
- package/dist/lib/i18n.d.ts.map +1 -1
- package/dist/lib/useChat.d.ts.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/src-BXQdw_Q7.cjs +7 -0
- package/dist/src-BXQdw_Q7.cjs.map +1 -0
- package/dist/{src-9RHZ3YFb.js → src-CwY6PP_H.js} +233 -219
- package/dist/src-CwY6PP_H.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/widgets/approval/SqcApproval.d.ts.map +1 -1
- package/dist/widgets/extras-loader.d.ts +1 -1
- package/dist/widgets/parse/confirm.d.ts +1 -1
- package/dist/widgets.cjs +1 -1
- package/dist/widgets.js +2 -2
- package/package.json +1 -1
- package/dist/answer-BDuY6oLY.js.map +0 -1
- package/dist/answer-Bi8GWLyA.cjs.map +0 -1
- package/dist/extras-BAqWS9pU.cjs +0 -4
- package/dist/extras-BAqWS9pU.cjs.map +0 -1
- package/dist/extras-BSCTuiit.js.map +0 -1
- package/dist/src-9RHZ3YFb.js.map +0 -1
- package/dist/src-BaM2DlJ3.cjs +0 -7
- package/dist/src-BaM2DlJ3.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as e, D as t, b as n, c as r, g as i, i as a, l as o, o as s, u as c, w as l, x as u } from "./answer-
|
|
1
|
+
import { C as e, D as t, b as n, c as r, g as i, i as a, l as o, o as s, u as c, w as l, x as u } from "./answer-CQWAgbwL.js";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var d = Object.defineProperty, f = (e, t) => {
|
|
4
4
|
let n = {};
|
|
@@ -7,15 +7,79 @@ var d = Object.defineProperty, f = (e, t) => {
|
|
|
7
7
|
enumerable: !0
|
|
8
8
|
});
|
|
9
9
|
return t || d(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
10
|
-
}, p = ".approval{flex-direction:column;gap:8px;margin:11px 0 2px;display:flex}.actions{flex-wrap:wrap;gap:8px;display:flex}.request{color:var(--w-text);margin:0;font-size:13px}.args{border:1px solid var(--w-border);background:var(--w-surface);border-radius:12px;flex-direction:column;
|
|
11
|
-
|
|
12
|
-
//#region src/widgets/approval/SqcApproval.tsx
|
|
13
|
-
function m(e, t) {
|
|
10
|
+
}, p = ".approval{flex-direction:column;gap:8px;margin:11px 0 2px;display:flex}.actions{flex-wrap:wrap;gap:8px;display:flex}.request{color:var(--w-text);margin:0;font-size:13px}.args{border:1px solid var(--w-border);background:var(--w-surface);border-radius:12px;flex-direction:column;margin:0;padding:2px 10px;font-size:12px;display:flex}.args .args{background:0 0;border:0;border-radius:0;padding:0}.arg{grid-template-columns:minmax(0,2fr) minmax(0,3fr);gap:8px;padding:6px 0;display:grid}.arg+.arg{border-top:1px solid var(--w-border)}.args .args .arg:first-child{padding-top:0}.args .args .arg:last-child{padding-bottom:0}.arg dt{color:var(--w-muted);overflow-wrap:anywhere;font-weight:500}.arg dd{overflow-wrap:anywhere;min-width:0;color:var(--w-text);margin:0}.approval button{border:1px solid var(--w-border);background:var(--w-bg);height:32px;color:var(--w-text);cursor:pointer;border-radius:12px;flex:auto;padding:0 12px;font-size:13px;font-weight:500}.approval .yes:not(:disabled){background:var(--w-accent);color:var(--w-on-accent);border-color:#0000;font-weight:600}.approval button:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.approval .yes:hover:not(:disabled){background:var(--w-accent-hover);border-color:#0000}.approval button:disabled{cursor:default}.approval button:disabled[aria-pressed=false]{opacity:.45}.approval button[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected);color:var(--w-text);font-weight:600}.arg.total{font-weight:600}", m = (e) => typeof e == "object" && !!e && !Array.isArray(e);
|
|
11
|
+
function h(e, t) {
|
|
14
12
|
let { confirm: n } = r(t);
|
|
15
13
|
return e === !0 ? n.yes : e === !1 ? n.no : typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
16
14
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
15
|
+
function g({ entries: e, labels: t, language: n }) {
|
|
16
|
+
return /* @__PURE__ */ i("dl", {
|
|
17
|
+
class: "args",
|
|
18
|
+
children: e.map(([e, r]) => {
|
|
19
|
+
let o = typeof r == "string" ? t[r] : void 0;
|
|
20
|
+
return /* @__PURE__ */ i("div", {
|
|
21
|
+
class: "arg",
|
|
22
|
+
children: [/* @__PURE__ */ i("dt", { children: o ? a(e).replace(/ id$/, "") : a(e) }), /* @__PURE__ */ i("dd", {
|
|
23
|
+
class: "value",
|
|
24
|
+
children: o ?? /* @__PURE__ */ i(_, {
|
|
25
|
+
value: r,
|
|
26
|
+
labels: t,
|
|
27
|
+
language: n
|
|
28
|
+
})
|
|
29
|
+
})]
|
|
30
|
+
}, e);
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function _({ value: e, labels: n, language: r }) {
|
|
35
|
+
return m(e) ? /* @__PURE__ */ i(g, {
|
|
36
|
+
entries: Object.entries(e),
|
|
37
|
+
labels: n,
|
|
38
|
+
language: r
|
|
39
|
+
}) : Array.isArray(e) && e.some(m) ? /* @__PURE__ */ i(t, { children: e.map((e, t) => /* @__PURE__ */ i(_, {
|
|
40
|
+
value: e,
|
|
41
|
+
labels: n,
|
|
42
|
+
language: r
|
|
43
|
+
}, t)) }) : Array.isArray(e) ? /* @__PURE__ */ i(t, { children: e.map((e) => h(e, r)).join(", ") }) : /* @__PURE__ */ i(t, { children: h(e, r) });
|
|
44
|
+
}
|
|
45
|
+
function v({ consent: e, language: n }) {
|
|
46
|
+
let { approval: a } = r(n);
|
|
47
|
+
return /* @__PURE__ */ i(t, { children: [/* @__PURE__ */ i("p", {
|
|
48
|
+
class: "request",
|
|
49
|
+
children: a.payTo.replace("{merchant}", e.merchant)
|
|
50
|
+
}), /* @__PURE__ */ i("dl", {
|
|
51
|
+
class: "args",
|
|
52
|
+
children: [
|
|
53
|
+
e.lines.map((e, t) => /* @__PURE__ */ i("div", {
|
|
54
|
+
class: "arg",
|
|
55
|
+
children: [/* @__PURE__ */ i("dt", { children: [
|
|
56
|
+
e.quantity,
|
|
57
|
+
" × ",
|
|
58
|
+
e.title
|
|
59
|
+
] }), /* @__PURE__ */ i("dd", {
|
|
60
|
+
class: "value",
|
|
61
|
+
children: e.amount
|
|
62
|
+
})]
|
|
63
|
+
}, t)),
|
|
64
|
+
/* @__PURE__ */ i("div", {
|
|
65
|
+
class: "arg total",
|
|
66
|
+
children: [/* @__PURE__ */ i("dt", { children: a.total }), /* @__PURE__ */ i("dd", {
|
|
67
|
+
class: "value",
|
|
68
|
+
children: e.total
|
|
69
|
+
})]
|
|
70
|
+
}),
|
|
71
|
+
e.instrument && /* @__PURE__ */ i("div", {
|
|
72
|
+
class: "arg",
|
|
73
|
+
children: [/* @__PURE__ */ i("dt", { children: a.paidWith }), /* @__PURE__ */ i("dd", {
|
|
74
|
+
class: "value",
|
|
75
|
+
children: e.instrument
|
|
76
|
+
})]
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
})] });
|
|
80
|
+
}
|
|
81
|
+
function y({ call: t, locked: o, language: s }) {
|
|
82
|
+
let { approval: c } = r(s), [l, u] = e(null), d = n(!1), f = !o && l === null, p = t?.consent, m = t && !p ? Object.entries(t.arguments) : [], h = (e, t) => {
|
|
19
83
|
o || d.current || (d.current = !0, u(e), t.currentTarget?.dispatchEvent(new CustomEvent("sqc-decision", {
|
|
20
84
|
detail: { approved: e },
|
|
21
85
|
bubbles: !0,
|
|
@@ -27,19 +91,18 @@ function h({ call: t, locked: o, language: s }) {
|
|
|
27
91
|
role: "group",
|
|
28
92
|
"aria-label": c.group,
|
|
29
93
|
children: [
|
|
30
|
-
|
|
94
|
+
p && /* @__PURE__ */ i(v, {
|
|
95
|
+
consent: p,
|
|
96
|
+
language: s
|
|
97
|
+
}),
|
|
98
|
+
t && !p && /* @__PURE__ */ i("p", {
|
|
31
99
|
class: "request",
|
|
32
100
|
children: c.request.replace("{tool}", a(t.tool))
|
|
33
101
|
}),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children: [/* @__PURE__ */ i("dt", { children: a(e) }), /* @__PURE__ */ i("dd", {
|
|
39
|
-
class: "value",
|
|
40
|
-
children: m(t, s)
|
|
41
|
-
})]
|
|
42
|
-
}, e))
|
|
102
|
+
m.length > 0 && /* @__PURE__ */ i(g, {
|
|
103
|
+
entries: m,
|
|
104
|
+
labels: t?.labels ?? {},
|
|
105
|
+
language: s
|
|
43
106
|
}),
|
|
44
107
|
/* @__PURE__ */ i("div", {
|
|
45
108
|
class: "actions",
|
|
@@ -49,7 +112,7 @@ function h({ call: t, locked: o, language: s }) {
|
|
|
49
112
|
"aria-pressed": l === !0,
|
|
50
113
|
disabled: !f,
|
|
51
114
|
onClick: (e) => h(!0, e),
|
|
52
|
-
children: c.approve
|
|
115
|
+
children: p ? c.pay.replace("{total}", p.total) : c.approve
|
|
53
116
|
}), /* @__PURE__ */ i("button", {
|
|
54
117
|
type: "button",
|
|
55
118
|
class: "no",
|
|
@@ -64,7 +127,7 @@ function h({ call: t, locked: o, language: s }) {
|
|
|
64
127
|
}
|
|
65
128
|
//#endregion
|
|
66
129
|
//#region src/widgets/chart/chart.css?inline
|
|
67
|
-
var
|
|
130
|
+
var b = ".name{color:var(--w-muted);font-size:12px}.chart{color:var(--w-text);background:var(--w-surface);border:1px solid var(--w-border);border-radius:12px;flex-direction:column;gap:8px;margin:0;padding:12px;font-size:13px;display:flex}.head{justify-content:space-between;align-items:flex-start;gap:8px;display:flex}figcaption{overflow-wrap:anywhere;font-weight:600}.download,.toggle{background:var(--w-bg);border:1px solid var(--w-border-strong);cursor:pointer;border-radius:8px;flex-shrink:0;padding:2px 8px;font-size:12px}.toggle{color:var(--w-muted);align-self:flex-start}.legend{color:var(--w-muted);flex-wrap:wrap;gap:4px 12px;margin:0;padding:0;font-size:12px;list-style:none;display:flex}.legend li{align-items:center;gap:4px;display:flex}.legend i{border-radius:2px;width:10px;height:10px}.plot{position:relative}svg{width:100%;height:auto;display:block}.tip{white-space:nowrap;pointer-events:none;color:var(--w-bg);background:var(--w-text);border-radius:6px;flex-direction:column;padding:4px 8px;font-size:12px;display:flex;position:absolute;transform:translate(-50%,calc(-100% - 8px))}.data{border:1px solid var(--w-border);border-radius:8px;max-height:192px;overflow:auto}table{border-collapse:collapse;width:100%;font-size:12px}th,td{text-align:left;font-variant-numeric:tabular-nums;padding:4px 8px}th{color:var(--w-muted);background:var(--w-bg);font-weight:500}tbody tr{border-top:1px solid var(--w-border)}", x = [
|
|
68
131
|
"#2448cc",
|
|
69
132
|
"#0d7f78",
|
|
70
133
|
"#b86e00",
|
|
@@ -72,15 +135,15 @@ var g = ".name{color:var(--w-muted);font-size:12px}.chart{color:var(--w-text);ba
|
|
|
72
135
|
"#557c00",
|
|
73
136
|
"#5a6a80"
|
|
74
137
|
];
|
|
75
|
-
function
|
|
76
|
-
let t = Math.min(e,
|
|
77
|
-
return `var(--sqc-series-${t + 1}, ${
|
|
138
|
+
function S(e) {
|
|
139
|
+
let t = Math.min(e, x.length - 1);
|
|
140
|
+
return `var(--sqc-series-${t + 1}, ${x[t]})`;
|
|
78
141
|
}
|
|
79
|
-
function
|
|
142
|
+
function C(e, t, n, r) {
|
|
80
143
|
let i = t === e ? 0 : (r - n) / (t - e);
|
|
81
144
|
return (t) => n + (t - e) * i;
|
|
82
145
|
}
|
|
83
|
-
function
|
|
146
|
+
function w(e, t) {
|
|
84
147
|
e === t && (--e, t += 1);
|
|
85
148
|
let n = (t - e) / 5, r = 10 ** Math.floor(Math.log10(n)), i = [
|
|
86
149
|
1,
|
|
@@ -91,8 +154,8 @@ function b(e, t) {
|
|
|
91
154
|
for (let n = Math.floor(e / i) * i; n <= t + i / 2 && (a.push(Number(n.toPrecision(12))), !(n >= t)); n += i);
|
|
92
155
|
return a;
|
|
93
156
|
}
|
|
94
|
-
var
|
|
95
|
-
function
|
|
157
|
+
var T = (e) => e.length > 14 ? `${e.slice(0, 13)}…` : e, E = "fill:var(--w-muted);font-size:11px", D = "stroke:var(--w-border)";
|
|
158
|
+
function O(e) {
|
|
96
159
|
let { values: t, scale: n, axis: r, from: a, to: o, format: s } = e;
|
|
97
160
|
return /* @__PURE__ */ i("g", { children: t.map((e) => {
|
|
98
161
|
let t = n(e);
|
|
@@ -101,31 +164,31 @@ function w(e) {
|
|
|
101
164
|
x2: o,
|
|
102
165
|
y1: t,
|
|
103
166
|
y2: t,
|
|
104
|
-
style:
|
|
167
|
+
style: D
|
|
105
168
|
}), /* @__PURE__ */ i("text", {
|
|
106
169
|
x: a - 6,
|
|
107
170
|
y: t + 4,
|
|
108
171
|
"text-anchor": "end",
|
|
109
|
-
style:
|
|
172
|
+
style: E,
|
|
110
173
|
children: s(e)
|
|
111
174
|
})] }, e) : /* @__PURE__ */ i("g", { children: [/* @__PURE__ */ i("line", {
|
|
112
175
|
y1: a,
|
|
113
176
|
y2: o,
|
|
114
177
|
x1: t,
|
|
115
178
|
x2: t,
|
|
116
|
-
style:
|
|
179
|
+
style: D
|
|
117
180
|
}), /* @__PURE__ */ i("text", {
|
|
118
181
|
y: o + 16,
|
|
119
182
|
x: t,
|
|
120
183
|
"text-anchor": "middle",
|
|
121
|
-
style:
|
|
184
|
+
style: E,
|
|
122
185
|
children: s(e)
|
|
123
186
|
})] }, e);
|
|
124
187
|
}) });
|
|
125
188
|
}
|
|
126
|
-
function
|
|
189
|
+
function k({ bottom: e, left: t }) {
|
|
127
190
|
return /* @__PURE__ */ i("g", {
|
|
128
|
-
style:
|
|
191
|
+
style: E,
|
|
129
192
|
children: [e && /* @__PURE__ */ i("text", {
|
|
130
193
|
x: 280,
|
|
131
194
|
y: 276,
|
|
@@ -138,11 +201,11 @@ function T({ bottom: e, left: t }) {
|
|
|
138
201
|
})]
|
|
139
202
|
});
|
|
140
203
|
}
|
|
141
|
-
function
|
|
204
|
+
function A(e, t, n, r, i, a) {
|
|
142
205
|
let o = Math.min(a - i, Math.PI * 2 - 1e-4), s = i + o, c = +(o > Math.PI), l = (n, r) => `${(e + n * Math.cos(r)).toFixed(2)} ${(t + n * Math.sin(r)).toFixed(2)}`, u = `M${l(n, i)}A${n} ${n} 0 ${c} 1 ${l(n, s)}`;
|
|
143
206
|
return r > 0 ? `${u}L${l(r, s)}A${r} ${r} 0 ${c} 0 ${l(r, i)}Z` : `${u}L${e} ${t}Z`;
|
|
144
207
|
}
|
|
145
|
-
function
|
|
208
|
+
function j({ chart: e, format: n, onTip: r }) {
|
|
146
209
|
let a = 280 - (e.xLabel ? 44 : 28), o = (e, t) => (e ? `${e}: ` : "") + n(t), s;
|
|
147
210
|
if (e.type === "pie") {
|
|
148
211
|
let t = e.series[0].values, n = t.reduce((e, t) => e + Math.max(t, 0), 0) || 1, a = -Math.PI / 2;
|
|
@@ -154,8 +217,8 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
154
217
|
a += Math.max(t[c], 0) / n * Math.PI * 2;
|
|
155
218
|
let u = (l + a) / 2;
|
|
156
219
|
return /* @__PURE__ */ i("path", {
|
|
157
|
-
d:
|
|
158
|
-
style: `fill:${
|
|
220
|
+
d: A(280, 140, 130, e.donut ? 71.5 : 0, l, a),
|
|
221
|
+
style: `fill:${S(c)}`,
|
|
159
222
|
onMouseEnter: () => r({
|
|
160
223
|
x: 280 + 65 * Math.cos(u),
|
|
161
224
|
y: 140 + 65 * Math.sin(u),
|
|
@@ -166,9 +229,9 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
166
229
|
})
|
|
167
230
|
});
|
|
168
231
|
} else if (e.type === "scatter") {
|
|
169
|
-
let o = e.series.flatMap((e) => e.points), c =
|
|
232
|
+
let o = e.series.flatMap((e) => e.points), c = w(Math.min(...o.map((e) => e.x)), Math.max(...o.map((e) => e.x))), l = w(Math.min(...o.map((e) => e.y)), Math.max(...o.map((e) => e.y))), u = e.yLabel ? 60 : 44, d = C(c[0], c[c.length - 1], u, 548), f = C(l[0], l[l.length - 1], a, 10);
|
|
170
233
|
s = /* @__PURE__ */ i(t, { children: [
|
|
171
|
-
/* @__PURE__ */ i(
|
|
234
|
+
/* @__PURE__ */ i(O, {
|
|
172
235
|
values: l,
|
|
173
236
|
scale: f,
|
|
174
237
|
axis: "y",
|
|
@@ -176,7 +239,7 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
176
239
|
to: 548,
|
|
177
240
|
format: n
|
|
178
241
|
}),
|
|
179
|
-
/* @__PURE__ */ i(
|
|
242
|
+
/* @__PURE__ */ i(O, {
|
|
180
243
|
values: c,
|
|
181
244
|
scale: d,
|
|
182
245
|
axis: "x",
|
|
@@ -186,7 +249,7 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
186
249
|
}),
|
|
187
250
|
e.series.map((t, a) => /* @__PURE__ */ i("g", {
|
|
188
251
|
class: "series",
|
|
189
|
-
style: `fill:${
|
|
252
|
+
style: `fill:${S(a)}`,
|
|
190
253
|
children: t.points.map((a, o) => /* @__PURE__ */ i("circle", {
|
|
191
254
|
cx: d(a.x),
|
|
192
255
|
cy: f(a.y),
|
|
@@ -199,7 +262,7 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
199
262
|
})
|
|
200
263
|
}, o))
|
|
201
264
|
}, a)),
|
|
202
|
-
/* @__PURE__ */ i(
|
|
265
|
+
/* @__PURE__ */ i(k, {
|
|
203
266
|
bottom: e.xLabel,
|
|
204
267
|
left: e.yLabel
|
|
205
268
|
})
|
|
@@ -211,19 +274,19 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
211
274
|
return n[t] += e, [r, n[t]];
|
|
212
275
|
})), h = m.flat().map(([, e]) => e);
|
|
213
276
|
e.type !== "line" && h.push(0);
|
|
214
|
-
let g =
|
|
277
|
+
let g = w(Math.min(...h), Math.max(...h)), _ = g[0], v = g[g.length - 1], y = d ? e.xLabel ? 112 : 96 : e.yLabel ? 60 : 44, b = d ? [10, a] : [y, 548], x = (b[1] - b[0]) / c.length, D = (e) => b[0] + x * (e + .5), A = d ? C(_, v, y, 548) : C(_, v, a, 10), j = Math.ceil(c.length / 12), M = (e, t, n, i) => () => r({
|
|
215
278
|
x: n,
|
|
216
279
|
y: i,
|
|
217
280
|
title: c[t],
|
|
218
281
|
line: o(l[e].name, l[e].values[t])
|
|
219
282
|
}), N;
|
|
220
283
|
if (e.type === "bar") {
|
|
221
|
-
let e =
|
|
284
|
+
let e = x * .8, t = u ? e : e / l.length;
|
|
222
285
|
N = l.map((e, n) => /* @__PURE__ */ i("g", {
|
|
223
286
|
class: "series",
|
|
224
|
-
style: `fill:${
|
|
287
|
+
style: `fill:${S(n)}`,
|
|
225
288
|
children: m[n].map(([e, r], a) => {
|
|
226
|
-
let o =
|
|
289
|
+
let o = b[0] + x * a + x * .1 + (u ? 0 : t * n), s = A(Math.min(e, r)), c = A(Math.max(e, r)), l = d ? {
|
|
227
290
|
x: s,
|
|
228
291
|
y: o,
|
|
229
292
|
width: c - s,
|
|
@@ -241,7 +304,7 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
241
304
|
})
|
|
242
305
|
}, n));
|
|
243
306
|
} else N = l.map((t, n) => {
|
|
244
|
-
let r =
|
|
307
|
+
let r = S(n), a = m[n].map(([, e], t) => [D(t), A(e)]), o = a.map(([e, t], n) => `${n ? "L" : "M"}${e} ${t}`).join(""), s = a.map(([e], t) => `L${e} ${A(m[n][t][0])}`).reverse().join("");
|
|
245
308
|
return /* @__PURE__ */ i("g", {
|
|
246
309
|
class: "series",
|
|
247
310
|
style: `stroke:${r};fill:${r}`,
|
|
@@ -264,30 +327,30 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
264
327
|
}, n);
|
|
265
328
|
});
|
|
266
329
|
s = /* @__PURE__ */ i(t, { children: [
|
|
267
|
-
/* @__PURE__ */ i(
|
|
330
|
+
/* @__PURE__ */ i(O, {
|
|
268
331
|
values: g,
|
|
269
332
|
scale: A,
|
|
270
333
|
axis: d ? "x" : "y",
|
|
271
|
-
from: d ? 10 :
|
|
334
|
+
from: d ? 10 : y,
|
|
272
335
|
to: d ? a : 548,
|
|
273
336
|
format: n
|
|
274
337
|
}),
|
|
275
338
|
/* @__PURE__ */ i("g", {
|
|
276
|
-
style:
|
|
339
|
+
style: E,
|
|
277
340
|
children: c.map((e, t) => t % j ? null : d ? /* @__PURE__ */ i("text", {
|
|
278
|
-
x:
|
|
279
|
-
y:
|
|
341
|
+
x: y - 6,
|
|
342
|
+
y: D(t) + 4,
|
|
280
343
|
"text-anchor": "end",
|
|
281
|
-
children:
|
|
344
|
+
children: T(e)
|
|
282
345
|
}, t) : /* @__PURE__ */ i("text", {
|
|
283
|
-
x:
|
|
346
|
+
x: D(t),
|
|
284
347
|
y: a + 16,
|
|
285
348
|
"text-anchor": "middle",
|
|
286
|
-
children:
|
|
349
|
+
children: T(e)
|
|
287
350
|
}, t))
|
|
288
351
|
}),
|
|
289
352
|
N,
|
|
290
|
-
/* @__PURE__ */ i(
|
|
353
|
+
/* @__PURE__ */ i(k, {
|
|
291
354
|
bottom: d ? e.yLabel : e.xLabel,
|
|
292
355
|
left: d ? e.xLabel : e.yLabel
|
|
293
356
|
})
|
|
@@ -304,16 +367,16 @@ function D({ chart: e, format: n, onTip: r }) {
|
|
|
304
367
|
}
|
|
305
368
|
//#endregion
|
|
306
369
|
//#region src/widgets/chart/png.ts
|
|
307
|
-
var
|
|
308
|
-
function
|
|
370
|
+
var M = 2;
|
|
371
|
+
function N(e, t, n) {
|
|
309
372
|
let r = getComputedStyle(t), i = e.cloneNode(!0);
|
|
310
373
|
i.setAttribute("xmlns", "http://www.w3.org/2000/svg"), i.setAttribute("width", "560"), i.setAttribute("height", "280");
|
|
311
374
|
let a = new XMLSerializer().serializeToString(i).replace(/var\((--[\w-]+)(?:,\s*([^()]*))?\)/g, (e, t, n) => r.getPropertyValue(t).trim() || n?.trim() || e), o = new Image();
|
|
312
375
|
o.onload = () => {
|
|
313
376
|
let e = document.createElement("canvas");
|
|
314
|
-
e.width = 560 *
|
|
377
|
+
e.width = 560 * M, e.height = 280 * M;
|
|
315
378
|
let t = e.getContext("2d");
|
|
316
|
-
t && (t.scale(
|
|
379
|
+
t && (t.scale(M, M), t.fillStyle = r.getPropertyValue("--w-bg").trim() || "#fff", t.fillRect(0, 0, 560, 280), t.drawImage(o, 0, 0, 560, 280), e.toBlob((e) => {
|
|
317
380
|
if (!e) return;
|
|
318
381
|
let t = URL.createObjectURL(e), r = document.createElement("a");
|
|
319
382
|
r.href = t, r.download = n, r.click(), URL.revokeObjectURL(t);
|
|
@@ -322,65 +385,65 @@ function k(e, t, n) {
|
|
|
322
385
|
}
|
|
323
386
|
//#endregion
|
|
324
387
|
//#region src/widgets/types.ts
|
|
325
|
-
var
|
|
388
|
+
var P = [
|
|
326
389
|
"bar",
|
|
327
390
|
"line",
|
|
328
391
|
"area",
|
|
329
392
|
"pie",
|
|
330
393
|
"scatter"
|
|
331
|
-
],
|
|
332
|
-
function
|
|
394
|
+
], F = (e) => typeof e == "number" && Number.isFinite(e), I = (e) => typeof e == "string" ? e : "", L = (e, t) => typeof e == "object" && e ? e[t] : void 0;
|
|
395
|
+
function R(e, t) {
|
|
333
396
|
let n = [];
|
|
334
397
|
for (let r of e) {
|
|
335
|
-
let e =
|
|
336
|
-
if (!Array.isArray(e) || e.length !== t || !e.every(
|
|
398
|
+
let e = L(r, "values");
|
|
399
|
+
if (!Array.isArray(e) || e.length !== t || !e.every(F)) return null;
|
|
337
400
|
n.push({
|
|
338
|
-
name:
|
|
401
|
+
name: I(L(r, "name")),
|
|
339
402
|
values: e
|
|
340
403
|
});
|
|
341
404
|
}
|
|
342
405
|
return n;
|
|
343
406
|
}
|
|
344
|
-
function
|
|
407
|
+
function z(e) {
|
|
345
408
|
let t = [];
|
|
346
409
|
for (let n of e) {
|
|
347
|
-
let e =
|
|
348
|
-
if (!Array.isArray(e) || !e.every((e) =>
|
|
410
|
+
let e = L(n, "points");
|
|
411
|
+
if (!Array.isArray(e) || !e.every((e) => F(L(e, "x")) && F(L(e, "y")))) return null;
|
|
349
412
|
t.push({
|
|
350
|
-
name:
|
|
413
|
+
name: I(L(n, "name")),
|
|
351
414
|
points: e
|
|
352
415
|
});
|
|
353
416
|
}
|
|
354
417
|
return t;
|
|
355
418
|
}
|
|
356
|
-
function
|
|
419
|
+
function B(e) {
|
|
357
420
|
let t;
|
|
358
421
|
try {
|
|
359
422
|
t = JSON.parse(e);
|
|
360
423
|
} catch {
|
|
361
424
|
return null;
|
|
362
425
|
}
|
|
363
|
-
let n =
|
|
364
|
-
if (!
|
|
426
|
+
let n = L(t, "type"), r = L(t, "series");
|
|
427
|
+
if (!P.includes(n) || !Array.isArray(r) || !r.length) return null;
|
|
365
428
|
let i = {
|
|
366
|
-
title:
|
|
367
|
-
xLabel:
|
|
368
|
-
yLabel:
|
|
369
|
-
stacked:
|
|
370
|
-
horizontal:
|
|
371
|
-
donut:
|
|
429
|
+
title: I(L(t, "title")),
|
|
430
|
+
xLabel: I(L(t, "x_label")),
|
|
431
|
+
yLabel: I(L(t, "y_label")),
|
|
432
|
+
stacked: L(t, "stacked") === !0,
|
|
433
|
+
horizontal: L(t, "horizontal") === !0,
|
|
434
|
+
donut: L(t, "donut") === !0
|
|
372
435
|
};
|
|
373
436
|
if (n === "scatter") {
|
|
374
|
-
let e =
|
|
437
|
+
let e = z(r);
|
|
375
438
|
return e && {
|
|
376
439
|
...i,
|
|
377
440
|
type: n,
|
|
378
441
|
series: e
|
|
379
442
|
};
|
|
380
443
|
}
|
|
381
|
-
let a =
|
|
444
|
+
let a = L(t, "categories");
|
|
382
445
|
if (!Array.isArray(a)) return null;
|
|
383
|
-
let o = a.map(String), s =
|
|
446
|
+
let o = a.map(String), s = R(r, o.length);
|
|
384
447
|
return s && {
|
|
385
448
|
...i,
|
|
386
449
|
type: n,
|
|
@@ -390,7 +453,7 @@ function I(e) {
|
|
|
390
453
|
}
|
|
391
454
|
//#endregion
|
|
392
455
|
//#region src/widgets/chart/strings.ts
|
|
393
|
-
var
|
|
456
|
+
var V = {
|
|
394
457
|
en: {
|
|
395
458
|
download: "Download PNG",
|
|
396
459
|
show: "Show data",
|
|
@@ -413,12 +476,12 @@ var L = {
|
|
|
413
476
|
series: "Serie"
|
|
414
477
|
}
|
|
415
478
|
};
|
|
416
|
-
function
|
|
417
|
-
return
|
|
479
|
+
function H(e) {
|
|
480
|
+
return V[e] ?? V.en;
|
|
418
481
|
}
|
|
419
482
|
//#endregion
|
|
420
483
|
//#region src/widgets/chart/SqcChart.tsx
|
|
421
|
-
function
|
|
484
|
+
function U(e) {
|
|
422
485
|
let { chart: t, t: n, format: r } = e;
|
|
423
486
|
return /* @__PURE__ */ i("div", {
|
|
424
487
|
class: "data",
|
|
@@ -433,46 +496,46 @@ function z(e) {
|
|
|
433
496
|
] }, `${t}-${a}`))) : t.categories.map((e, n) => /* @__PURE__ */ i("tr", { children: [/* @__PURE__ */ i("td", { children: e }), t.series.map((e, t) => /* @__PURE__ */ i("td", { children: r(e.values[n]) }, t))] }, n)) })] })
|
|
434
497
|
});
|
|
435
498
|
}
|
|
436
|
-
function
|
|
437
|
-
let { chart: r, body: a, filename: o = "", language: s } = t, c =
|
|
499
|
+
function W(t) {
|
|
500
|
+
let { chart: r, body: a, filename: o = "", language: s } = t, c = H(s), [d, f] = e(null), [p, m] = e(null), [h, g] = e(!1), _ = n(null), v = u(() => new Intl.NumberFormat(s), [s]), y = (e) => v.format(e);
|
|
438
501
|
l(() => {
|
|
439
502
|
if (r || !a) return;
|
|
440
503
|
let e = !0;
|
|
441
|
-
return Promise.resolve(a).then((t) => e && f(
|
|
504
|
+
return Promise.resolve(a).then((t) => e && f(B(t)), () => e && f(null)), () => {
|
|
442
505
|
e = !1;
|
|
443
506
|
};
|
|
444
507
|
}, [r, a]);
|
|
445
|
-
let
|
|
446
|
-
if (!
|
|
508
|
+
let b = r ?? d;
|
|
509
|
+
if (!b) return /* @__PURE__ */ i("span", {
|
|
447
510
|
class: "name",
|
|
448
511
|
children: o
|
|
449
512
|
});
|
|
450
|
-
let
|
|
513
|
+
let x = b.title || o, C = b.type === "pie" ? b.categories : b.series.length > 1 ? b.series.map((e) => e.name) : [];
|
|
451
514
|
return /* @__PURE__ */ i("figure", {
|
|
452
515
|
class: "chart",
|
|
453
516
|
children: [
|
|
454
517
|
/* @__PURE__ */ i("div", {
|
|
455
518
|
class: "head",
|
|
456
|
-
children: [/* @__PURE__ */ i("figcaption", { children:
|
|
519
|
+
children: [/* @__PURE__ */ i("figcaption", { children: x }), /* @__PURE__ */ i("button", {
|
|
457
520
|
type: "button",
|
|
458
521
|
class: "download",
|
|
459
522
|
onClick: () => {
|
|
460
523
|
let e = _.current?.querySelector("svg"), t = _.current?.getRootNode()?.host;
|
|
461
|
-
e && t &&
|
|
524
|
+
e && t && N(e, t, `${x}.png`);
|
|
462
525
|
},
|
|
463
526
|
children: c.download
|
|
464
527
|
})]
|
|
465
528
|
}),
|
|
466
529
|
C.length > 0 && /* @__PURE__ */ i("ul", {
|
|
467
530
|
class: "legend",
|
|
468
|
-
children: C.map((e, t) => /* @__PURE__ */ i("li", { children: [/* @__PURE__ */ i("i", { style: `background:${
|
|
531
|
+
children: C.map((e, t) => /* @__PURE__ */ i("li", { children: [/* @__PURE__ */ i("i", { style: `background:${S(t)}` }), e] }, t))
|
|
469
532
|
}),
|
|
470
533
|
/* @__PURE__ */ i("div", {
|
|
471
534
|
class: "plot",
|
|
472
535
|
ref: _,
|
|
473
|
-
children: [/* @__PURE__ */ i(
|
|
474
|
-
chart:
|
|
475
|
-
format:
|
|
536
|
+
children: [/* @__PURE__ */ i(j, {
|
|
537
|
+
chart: b,
|
|
538
|
+
format: y,
|
|
476
539
|
onTip: m
|
|
477
540
|
}), p && /* @__PURE__ */ i("div", {
|
|
478
541
|
class: "tip",
|
|
@@ -488,27 +551,27 @@ function B(t) {
|
|
|
488
551
|
onClick: () => g(!h),
|
|
489
552
|
children: h ? c.hide : c.show
|
|
490
553
|
}),
|
|
491
|
-
h && /* @__PURE__ */ i(
|
|
492
|
-
chart:
|
|
554
|
+
h && /* @__PURE__ */ i(U, {
|
|
555
|
+
chart: b,
|
|
493
556
|
t: c,
|
|
494
|
-
format:
|
|
557
|
+
format: y
|
|
495
558
|
})
|
|
496
559
|
]
|
|
497
560
|
});
|
|
498
561
|
}
|
|
499
562
|
//#endregion
|
|
500
563
|
//#region src/widgets/form/reply.ts
|
|
501
|
-
function
|
|
564
|
+
function G(e, t) {
|
|
502
565
|
return e.fields.map((e) => [e.label, (t[e.name] ?? "").trim()]).filter(([, e]) => e).map(([e, t]) => `${e} : ${t}`).join("\n");
|
|
503
566
|
}
|
|
504
567
|
//#endregion
|
|
505
568
|
//#region src/widgets/form/SqcForm.tsx
|
|
506
|
-
var
|
|
507
|
-
function
|
|
569
|
+
var K = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
570
|
+
function q(e, t, n) {
|
|
508
571
|
let r = t.trim();
|
|
509
|
-
return r ? e.type === "email" && !
|
|
572
|
+
return r ? e.type === "email" && !K.test(r) ? n.email : e.type === "number" && !Number.isFinite(Number(r)) ? n.number : null : e.required ? n.required : null;
|
|
510
573
|
}
|
|
511
|
-
function
|
|
574
|
+
function J({ form: t, locked: n, language: a, reply: o }) {
|
|
512
575
|
let s = r(a).form, [c, l] = e({}), u = t?.fields ?? [], d = (e) => {
|
|
513
576
|
l((t) => {
|
|
514
577
|
if (!(e in t)) return t;
|
|
@@ -525,10 +588,10 @@ function W({ form: t, locked: n, language: a, reply: o }) {
|
|
|
525
588
|
for (let e of u) {
|
|
526
589
|
let t = r.get(e.name);
|
|
527
590
|
i[e.name] = typeof t == "string" ? t : "";
|
|
528
|
-
let n =
|
|
591
|
+
let n = q(e, i[e.name], s);
|
|
529
592
|
n && (a[e.name] = n);
|
|
530
593
|
}
|
|
531
|
-
l(a), Object.keys(a).length === 0 && o(
|
|
594
|
+
l(a), Object.keys(a).length === 0 && o(G(t, i));
|
|
532
595
|
},
|
|
533
596
|
children: [
|
|
534
597
|
t?.title && /* @__PURE__ */ i("p", {
|
|
@@ -585,20 +648,20 @@ function W({ form: t, locked: n, language: a, reply: o }) {
|
|
|
585
648
|
}
|
|
586
649
|
//#endregion
|
|
587
650
|
//#region src/widgets/form/form.css?inline
|
|
588
|
-
var
|
|
651
|
+
var Y = ".form{color:var(--w-text);background:var(--w-surface);border:1px solid var(--w-border);border-radius:12px;flex-direction:column;gap:10px;margin:10px 0 2px;padding:12px;font-size:13px;display:flex}.title{margin:0;font-weight:600}.field{flex-direction:column;gap:4px;display:flex}label{color:var(--w-muted);overflow-wrap:anywhere;font-size:12px}input,select{height:32px;font:inherit;color:var(--w-text);background:var(--w-bg);border:1px solid var(--w-border-strong);border-radius:8px;padding:0 9px}input:focus-visible{box-shadow:var(--w-focus);outline:none}select:focus-visible{box-shadow:var(--w-focus);outline:none}[aria-invalid=true]{border-color:#b42318}.error{color:#b42318;font-size:11.5px}input:disabled,select:disabled{opacity:.7}.submit{background:var(--w-accent);height:32px;color:var(--w-on-accent);cursor:pointer;border:0;border-radius:12px;align-self:flex-end;padding:0 14px;font-size:13px;font-weight:600}.submit:hover:not(:disabled){background:var(--w-accent-hover)}.submit:disabled{opacity:.4;cursor:default}", X = /* @__PURE__ */ f({ defineWidgetExtras: () => Q }), Z = [
|
|
589
652
|
s,
|
|
590
|
-
|
|
591
|
-
|
|
653
|
+
Y,
|
|
654
|
+
b,
|
|
592
655
|
p
|
|
593
656
|
].join("\n");
|
|
594
|
-
function
|
|
595
|
-
typeof customElements > "u" || (customElements.get(o.form) || customElements.define(o.form, c(
|
|
657
|
+
function Q() {
|
|
658
|
+
typeof customElements > "u" || (customElements.get(o.form) || customElements.define(o.form, c(J, ["form"], Z)), customElements.get(o.chart) || customElements.define(o.chart, c(W, [
|
|
596
659
|
"chart",
|
|
597
660
|
"body",
|
|
598
661
|
"filename"
|
|
599
|
-
],
|
|
662
|
+
], Z)), customElements.get(o.approval) || customElements.define(o.approval, c(y, ["call"], Z)));
|
|
600
663
|
}
|
|
601
664
|
//#endregion
|
|
602
|
-
export {
|
|
665
|
+
export { X as n, B as r, Q as t };
|
|
603
666
|
|
|
604
|
-
//# sourceMappingURL=extras-
|
|
667
|
+
//# sourceMappingURL=extras-DP27_4bx.js.map
|