@squadico/chatbot 1.7.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-BO2Hs9k1.cjs → answer-C3IUYu5f.cjs} +3 -3
- package/dist/answer-C3IUYu5f.cjs.map +1 -0
- package/dist/{answer-DF91dBOx.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-D94278IT.js → extras-DP27_4bx.js} +139 -99
- 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-Bm_aRvFA.js → src-CwY6PP_H.js} +231 -219
- package/dist/src-CwY6PP_H.js.map +1 -0
- package/dist/types.d.ts +18 -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-BO2Hs9k1.cjs.map +0 -1
- package/dist/answer-DF91dBOx.js.map +0 -1
- package/dist/extras-BeCZR-6X.cjs +0 -4
- package/dist/extras-BeCZR-6X.cjs.map +0 -1
- package/dist/extras-D94278IT.js.map +0 -1
- package/dist/src-Bm_aRvFA.js.map +0 -1
- package/dist/src-DcPZdalT.cjs +0 -7
- package/dist/src-DcPZdalT.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,7 +7,7 @@ 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;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}", m = (e) => typeof e == "object" && !!e && !Array.isArray(e);
|
|
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
11
|
function h(e, t) {
|
|
12
12
|
let { confirm: n } = r(t);
|
|
13
13
|
return e === !0 ? n.yes : e === !1 ? n.no : typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
@@ -42,8 +42,44 @@ function _({ value: e, labels: n, language: r }) {
|
|
|
42
42
|
language: r
|
|
43
43
|
}, t)) }) : Array.isArray(e) ? /* @__PURE__ */ i(t, { children: e.map((e) => h(e, r)).join(", ") }) : /* @__PURE__ */ i(t, { children: h(e, r) });
|
|
44
44
|
}
|
|
45
|
-
function v({
|
|
46
|
-
let { approval:
|
|
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) => {
|
|
47
83
|
o || d.current || (d.current = !0, u(e), t.currentTarget?.dispatchEvent(new CustomEvent("sqc-decision", {
|
|
48
84
|
detail: { approved: e },
|
|
49
85
|
bubbles: !0,
|
|
@@ -55,12 +91,16 @@ function v({ call: t, locked: o, language: s }) {
|
|
|
55
91
|
role: "group",
|
|
56
92
|
"aria-label": c.group,
|
|
57
93
|
children: [
|
|
58
|
-
|
|
94
|
+
p && /* @__PURE__ */ i(v, {
|
|
95
|
+
consent: p,
|
|
96
|
+
language: s
|
|
97
|
+
}),
|
|
98
|
+
t && !p && /* @__PURE__ */ i("p", {
|
|
59
99
|
class: "request",
|
|
60
100
|
children: c.request.replace("{tool}", a(t.tool))
|
|
61
101
|
}),
|
|
62
|
-
|
|
63
|
-
entries:
|
|
102
|
+
m.length > 0 && /* @__PURE__ */ i(g, {
|
|
103
|
+
entries: m,
|
|
64
104
|
labels: t?.labels ?? {},
|
|
65
105
|
language: s
|
|
66
106
|
}),
|
|
@@ -71,14 +111,14 @@ function v({ call: t, locked: o, language: s }) {
|
|
|
71
111
|
class: "yes",
|
|
72
112
|
"aria-pressed": l === !0,
|
|
73
113
|
disabled: !f,
|
|
74
|
-
onClick: (e) =>
|
|
75
|
-
children: c.approve
|
|
114
|
+
onClick: (e) => h(!0, e),
|
|
115
|
+
children: p ? c.pay.replace("{total}", p.total) : c.approve
|
|
76
116
|
}), /* @__PURE__ */ i("button", {
|
|
77
117
|
type: "button",
|
|
78
118
|
class: "no",
|
|
79
119
|
"aria-pressed": l === !1,
|
|
80
120
|
disabled: !f,
|
|
81
|
-
onClick: (e) =>
|
|
121
|
+
onClick: (e) => h(!1, e),
|
|
82
122
|
children: c.reject
|
|
83
123
|
})]
|
|
84
124
|
})
|
|
@@ -87,7 +127,7 @@ function v({ call: t, locked: o, language: s }) {
|
|
|
87
127
|
}
|
|
88
128
|
//#endregion
|
|
89
129
|
//#region src/widgets/chart/chart.css?inline
|
|
90
|
-
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 = [
|
|
91
131
|
"#2448cc",
|
|
92
132
|
"#0d7f78",
|
|
93
133
|
"#b86e00",
|
|
@@ -95,15 +135,15 @@ var y = ".name{color:var(--w-muted);font-size:12px}.chart{color:var(--w-text);ba
|
|
|
95
135
|
"#557c00",
|
|
96
136
|
"#5a6a80"
|
|
97
137
|
];
|
|
98
|
-
function
|
|
99
|
-
let t = Math.min(e,
|
|
100
|
-
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]})`;
|
|
101
141
|
}
|
|
102
|
-
function
|
|
142
|
+
function C(e, t, n, r) {
|
|
103
143
|
let i = t === e ? 0 : (r - n) / (t - e);
|
|
104
144
|
return (t) => n + (t - e) * i;
|
|
105
145
|
}
|
|
106
|
-
function
|
|
146
|
+
function w(e, t) {
|
|
107
147
|
e === t && (--e, t += 1);
|
|
108
148
|
let n = (t - e) / 5, r = 10 ** Math.floor(Math.log10(n)), i = [
|
|
109
149
|
1,
|
|
@@ -114,8 +154,8 @@ function C(e, t) {
|
|
|
114
154
|
for (let n = Math.floor(e / i) * i; n <= t + i / 2 && (a.push(Number(n.toPrecision(12))), !(n >= t)); n += i);
|
|
115
155
|
return a;
|
|
116
156
|
}
|
|
117
|
-
var
|
|
118
|
-
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) {
|
|
119
159
|
let { values: t, scale: n, axis: r, from: a, to: o, format: s } = e;
|
|
120
160
|
return /* @__PURE__ */ i("g", { children: t.map((e) => {
|
|
121
161
|
let t = n(e);
|
|
@@ -124,31 +164,31 @@ function D(e) {
|
|
|
124
164
|
x2: o,
|
|
125
165
|
y1: t,
|
|
126
166
|
y2: t,
|
|
127
|
-
style:
|
|
167
|
+
style: D
|
|
128
168
|
}), /* @__PURE__ */ i("text", {
|
|
129
169
|
x: a - 6,
|
|
130
170
|
y: t + 4,
|
|
131
171
|
"text-anchor": "end",
|
|
132
|
-
style:
|
|
172
|
+
style: E,
|
|
133
173
|
children: s(e)
|
|
134
174
|
})] }, e) : /* @__PURE__ */ i("g", { children: [/* @__PURE__ */ i("line", {
|
|
135
175
|
y1: a,
|
|
136
176
|
y2: o,
|
|
137
177
|
x1: t,
|
|
138
178
|
x2: t,
|
|
139
|
-
style:
|
|
179
|
+
style: D
|
|
140
180
|
}), /* @__PURE__ */ i("text", {
|
|
141
181
|
y: o + 16,
|
|
142
182
|
x: t,
|
|
143
183
|
"text-anchor": "middle",
|
|
144
|
-
style:
|
|
184
|
+
style: E,
|
|
145
185
|
children: s(e)
|
|
146
186
|
})] }, e);
|
|
147
187
|
}) });
|
|
148
188
|
}
|
|
149
|
-
function
|
|
189
|
+
function k({ bottom: e, left: t }) {
|
|
150
190
|
return /* @__PURE__ */ i("g", {
|
|
151
|
-
style:
|
|
191
|
+
style: E,
|
|
152
192
|
children: [e && /* @__PURE__ */ i("text", {
|
|
153
193
|
x: 280,
|
|
154
194
|
y: 276,
|
|
@@ -161,11 +201,11 @@ function O({ bottom: e, left: t }) {
|
|
|
161
201
|
})]
|
|
162
202
|
});
|
|
163
203
|
}
|
|
164
|
-
function
|
|
204
|
+
function A(e, t, n, r, i, a) {
|
|
165
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)}`;
|
|
166
206
|
return r > 0 ? `${u}L${l(r, s)}A${r} ${r} 0 ${c} 0 ${l(r, i)}Z` : `${u}L${e} ${t}Z`;
|
|
167
207
|
}
|
|
168
|
-
function
|
|
208
|
+
function j({ chart: e, format: n, onTip: r }) {
|
|
169
209
|
let a = 280 - (e.xLabel ? 44 : 28), o = (e, t) => (e ? `${e}: ` : "") + n(t), s;
|
|
170
210
|
if (e.type === "pie") {
|
|
171
211
|
let t = e.series[0].values, n = t.reduce((e, t) => e + Math.max(t, 0), 0) || 1, a = -Math.PI / 2;
|
|
@@ -177,8 +217,8 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
177
217
|
a += Math.max(t[c], 0) / n * Math.PI * 2;
|
|
178
218
|
let u = (l + a) / 2;
|
|
179
219
|
return /* @__PURE__ */ i("path", {
|
|
180
|
-
d:
|
|
181
|
-
style: `fill:${
|
|
220
|
+
d: A(280, 140, 130, e.donut ? 71.5 : 0, l, a),
|
|
221
|
+
style: `fill:${S(c)}`,
|
|
182
222
|
onMouseEnter: () => r({
|
|
183
223
|
x: 280 + 65 * Math.cos(u),
|
|
184
224
|
y: 140 + 65 * Math.sin(u),
|
|
@@ -189,9 +229,9 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
189
229
|
})
|
|
190
230
|
});
|
|
191
231
|
} else if (e.type === "scatter") {
|
|
192
|
-
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);
|
|
193
233
|
s = /* @__PURE__ */ i(t, { children: [
|
|
194
|
-
/* @__PURE__ */ i(
|
|
234
|
+
/* @__PURE__ */ i(O, {
|
|
195
235
|
values: l,
|
|
196
236
|
scale: f,
|
|
197
237
|
axis: "y",
|
|
@@ -199,7 +239,7 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
199
239
|
to: 548,
|
|
200
240
|
format: n
|
|
201
241
|
}),
|
|
202
|
-
/* @__PURE__ */ i(
|
|
242
|
+
/* @__PURE__ */ i(O, {
|
|
203
243
|
values: c,
|
|
204
244
|
scale: d,
|
|
205
245
|
axis: "x",
|
|
@@ -209,7 +249,7 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
209
249
|
}),
|
|
210
250
|
e.series.map((t, a) => /* @__PURE__ */ i("g", {
|
|
211
251
|
class: "series",
|
|
212
|
-
style: `fill:${
|
|
252
|
+
style: `fill:${S(a)}`,
|
|
213
253
|
children: t.points.map((a, o) => /* @__PURE__ */ i("circle", {
|
|
214
254
|
cx: d(a.x),
|
|
215
255
|
cy: f(a.y),
|
|
@@ -222,7 +262,7 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
222
262
|
})
|
|
223
263
|
}, o))
|
|
224
264
|
}, a)),
|
|
225
|
-
/* @__PURE__ */ i(
|
|
265
|
+
/* @__PURE__ */ i(k, {
|
|
226
266
|
bottom: e.xLabel,
|
|
227
267
|
left: e.yLabel
|
|
228
268
|
})
|
|
@@ -234,19 +274,19 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
234
274
|
return n[t] += e, [r, n[t]];
|
|
235
275
|
})), h = m.flat().map(([, e]) => e);
|
|
236
276
|
e.type !== "line" && h.push(0);
|
|
237
|
-
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({
|
|
238
278
|
x: n,
|
|
239
279
|
y: i,
|
|
240
280
|
title: c[t],
|
|
241
281
|
line: o(l[e].name, l[e].values[t])
|
|
242
282
|
}), N;
|
|
243
283
|
if (e.type === "bar") {
|
|
244
|
-
let e =
|
|
284
|
+
let e = x * .8, t = u ? e : e / l.length;
|
|
245
285
|
N = l.map((e, n) => /* @__PURE__ */ i("g", {
|
|
246
286
|
class: "series",
|
|
247
|
-
style: `fill:${
|
|
287
|
+
style: `fill:${S(n)}`,
|
|
248
288
|
children: m[n].map(([e, r], a) => {
|
|
249
|
-
let o = b[0] +
|
|
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 ? {
|
|
250
290
|
x: s,
|
|
251
291
|
y: o,
|
|
252
292
|
width: c - s,
|
|
@@ -264,7 +304,7 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
264
304
|
})
|
|
265
305
|
}, n));
|
|
266
306
|
} else N = l.map((t, n) => {
|
|
267
|
-
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("");
|
|
268
308
|
return /* @__PURE__ */ i("g", {
|
|
269
309
|
class: "series",
|
|
270
310
|
style: `stroke:${r};fill:${r}`,
|
|
@@ -287,7 +327,7 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
287
327
|
}, n);
|
|
288
328
|
});
|
|
289
329
|
s = /* @__PURE__ */ i(t, { children: [
|
|
290
|
-
/* @__PURE__ */ i(
|
|
330
|
+
/* @__PURE__ */ i(O, {
|
|
291
331
|
values: g,
|
|
292
332
|
scale: A,
|
|
293
333
|
axis: d ? "x" : "y",
|
|
@@ -296,21 +336,21 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
296
336
|
format: n
|
|
297
337
|
}),
|
|
298
338
|
/* @__PURE__ */ i("g", {
|
|
299
|
-
style:
|
|
339
|
+
style: E,
|
|
300
340
|
children: c.map((e, t) => t % j ? null : d ? /* @__PURE__ */ i("text", {
|
|
301
341
|
x: y - 6,
|
|
302
|
-
y:
|
|
342
|
+
y: D(t) + 4,
|
|
303
343
|
"text-anchor": "end",
|
|
304
|
-
children:
|
|
344
|
+
children: T(e)
|
|
305
345
|
}, t) : /* @__PURE__ */ i("text", {
|
|
306
|
-
x:
|
|
346
|
+
x: D(t),
|
|
307
347
|
y: a + 16,
|
|
308
348
|
"text-anchor": "middle",
|
|
309
|
-
children:
|
|
349
|
+
children: T(e)
|
|
310
350
|
}, t))
|
|
311
351
|
}),
|
|
312
352
|
N,
|
|
313
|
-
/* @__PURE__ */ i(
|
|
353
|
+
/* @__PURE__ */ i(k, {
|
|
314
354
|
bottom: d ? e.yLabel : e.xLabel,
|
|
315
355
|
left: d ? e.xLabel : e.yLabel
|
|
316
356
|
})
|
|
@@ -327,16 +367,16 @@ function A({ chart: e, format: n, onTip: r }) {
|
|
|
327
367
|
}
|
|
328
368
|
//#endregion
|
|
329
369
|
//#region src/widgets/chart/png.ts
|
|
330
|
-
var
|
|
331
|
-
function
|
|
370
|
+
var M = 2;
|
|
371
|
+
function N(e, t, n) {
|
|
332
372
|
let r = getComputedStyle(t), i = e.cloneNode(!0);
|
|
333
373
|
i.setAttribute("xmlns", "http://www.w3.org/2000/svg"), i.setAttribute("width", "560"), i.setAttribute("height", "280");
|
|
334
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();
|
|
335
375
|
o.onload = () => {
|
|
336
376
|
let e = document.createElement("canvas");
|
|
337
|
-
e.width = 560 *
|
|
377
|
+
e.width = 560 * M, e.height = 280 * M;
|
|
338
378
|
let t = e.getContext("2d");
|
|
339
|
-
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) => {
|
|
340
380
|
if (!e) return;
|
|
341
381
|
let t = URL.createObjectURL(e), r = document.createElement("a");
|
|
342
382
|
r.href = t, r.download = n, r.click(), URL.revokeObjectURL(t);
|
|
@@ -345,65 +385,65 @@ function M(e, t, n) {
|
|
|
345
385
|
}
|
|
346
386
|
//#endregion
|
|
347
387
|
//#region src/widgets/types.ts
|
|
348
|
-
var
|
|
388
|
+
var P = [
|
|
349
389
|
"bar",
|
|
350
390
|
"line",
|
|
351
391
|
"area",
|
|
352
392
|
"pie",
|
|
353
393
|
"scatter"
|
|
354
|
-
],
|
|
355
|
-
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) {
|
|
356
396
|
let n = [];
|
|
357
397
|
for (let r of e) {
|
|
358
|
-
let e =
|
|
359
|
-
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;
|
|
360
400
|
n.push({
|
|
361
|
-
name:
|
|
401
|
+
name: I(L(r, "name")),
|
|
362
402
|
values: e
|
|
363
403
|
});
|
|
364
404
|
}
|
|
365
405
|
return n;
|
|
366
406
|
}
|
|
367
|
-
function
|
|
407
|
+
function z(e) {
|
|
368
408
|
let t = [];
|
|
369
409
|
for (let n of e) {
|
|
370
|
-
let e =
|
|
371
|
-
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;
|
|
372
412
|
t.push({
|
|
373
|
-
name:
|
|
413
|
+
name: I(L(n, "name")),
|
|
374
414
|
points: e
|
|
375
415
|
});
|
|
376
416
|
}
|
|
377
417
|
return t;
|
|
378
418
|
}
|
|
379
|
-
function
|
|
419
|
+
function B(e) {
|
|
380
420
|
let t;
|
|
381
421
|
try {
|
|
382
422
|
t = JSON.parse(e);
|
|
383
423
|
} catch {
|
|
384
424
|
return null;
|
|
385
425
|
}
|
|
386
|
-
let n =
|
|
387
|
-
if (!
|
|
426
|
+
let n = L(t, "type"), r = L(t, "series");
|
|
427
|
+
if (!P.includes(n) || !Array.isArray(r) || !r.length) return null;
|
|
388
428
|
let i = {
|
|
389
|
-
title:
|
|
390
|
-
xLabel:
|
|
391
|
-
yLabel:
|
|
392
|
-
stacked:
|
|
393
|
-
horizontal:
|
|
394
|
-
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
|
|
395
435
|
};
|
|
396
436
|
if (n === "scatter") {
|
|
397
|
-
let e =
|
|
437
|
+
let e = z(r);
|
|
398
438
|
return e && {
|
|
399
439
|
...i,
|
|
400
440
|
type: n,
|
|
401
441
|
series: e
|
|
402
442
|
};
|
|
403
443
|
}
|
|
404
|
-
let a =
|
|
444
|
+
let a = L(t, "categories");
|
|
405
445
|
if (!Array.isArray(a)) return null;
|
|
406
|
-
let o = a.map(String), s =
|
|
446
|
+
let o = a.map(String), s = R(r, o.length);
|
|
407
447
|
return s && {
|
|
408
448
|
...i,
|
|
409
449
|
type: n,
|
|
@@ -413,7 +453,7 @@ function z(e) {
|
|
|
413
453
|
}
|
|
414
454
|
//#endregion
|
|
415
455
|
//#region src/widgets/chart/strings.ts
|
|
416
|
-
var
|
|
456
|
+
var V = {
|
|
417
457
|
en: {
|
|
418
458
|
download: "Download PNG",
|
|
419
459
|
show: "Show data",
|
|
@@ -436,12 +476,12 @@ var B = {
|
|
|
436
476
|
series: "Serie"
|
|
437
477
|
}
|
|
438
478
|
};
|
|
439
|
-
function
|
|
440
|
-
return
|
|
479
|
+
function H(e) {
|
|
480
|
+
return V[e] ?? V.en;
|
|
441
481
|
}
|
|
442
482
|
//#endregion
|
|
443
483
|
//#region src/widgets/chart/SqcChart.tsx
|
|
444
|
-
function
|
|
484
|
+
function U(e) {
|
|
445
485
|
let { chart: t, t: n, format: r } = e;
|
|
446
486
|
return /* @__PURE__ */ i("div", {
|
|
447
487
|
class: "data",
|
|
@@ -456,12 +496,12 @@ function H(e) {
|
|
|
456
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)) })] })
|
|
457
497
|
});
|
|
458
498
|
}
|
|
459
|
-
function
|
|
460
|
-
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);
|
|
461
501
|
l(() => {
|
|
462
502
|
if (r || !a) return;
|
|
463
503
|
let e = !0;
|
|
464
|
-
return Promise.resolve(a).then((t) => e && f(
|
|
504
|
+
return Promise.resolve(a).then((t) => e && f(B(t)), () => e && f(null)), () => {
|
|
465
505
|
e = !1;
|
|
466
506
|
};
|
|
467
507
|
}, [r, a]);
|
|
@@ -470,30 +510,30 @@ function U(t) {
|
|
|
470
510
|
class: "name",
|
|
471
511
|
children: o
|
|
472
512
|
});
|
|
473
|
-
let
|
|
513
|
+
let x = b.title || o, C = b.type === "pie" ? b.categories : b.series.length > 1 ? b.series.map((e) => e.name) : [];
|
|
474
514
|
return /* @__PURE__ */ i("figure", {
|
|
475
515
|
class: "chart",
|
|
476
516
|
children: [
|
|
477
517
|
/* @__PURE__ */ i("div", {
|
|
478
518
|
class: "head",
|
|
479
|
-
children: [/* @__PURE__ */ i("figcaption", { children:
|
|
519
|
+
children: [/* @__PURE__ */ i("figcaption", { children: x }), /* @__PURE__ */ i("button", {
|
|
480
520
|
type: "button",
|
|
481
521
|
class: "download",
|
|
482
522
|
onClick: () => {
|
|
483
523
|
let e = _.current?.querySelector("svg"), t = _.current?.getRootNode()?.host;
|
|
484
|
-
e && t &&
|
|
524
|
+
e && t && N(e, t, `${x}.png`);
|
|
485
525
|
},
|
|
486
526
|
children: c.download
|
|
487
527
|
})]
|
|
488
528
|
}),
|
|
489
529
|
C.length > 0 && /* @__PURE__ */ i("ul", {
|
|
490
530
|
class: "legend",
|
|
491
|
-
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))
|
|
492
532
|
}),
|
|
493
533
|
/* @__PURE__ */ i("div", {
|
|
494
534
|
class: "plot",
|
|
495
535
|
ref: _,
|
|
496
|
-
children: [/* @__PURE__ */ i(
|
|
536
|
+
children: [/* @__PURE__ */ i(j, {
|
|
497
537
|
chart: b,
|
|
498
538
|
format: y,
|
|
499
539
|
onTip: m
|
|
@@ -511,7 +551,7 @@ function U(t) {
|
|
|
511
551
|
onClick: () => g(!h),
|
|
512
552
|
children: h ? c.hide : c.show
|
|
513
553
|
}),
|
|
514
|
-
h && /* @__PURE__ */ i(
|
|
554
|
+
h && /* @__PURE__ */ i(U, {
|
|
515
555
|
chart: b,
|
|
516
556
|
t: c,
|
|
517
557
|
format: y
|
|
@@ -521,17 +561,17 @@ function U(t) {
|
|
|
521
561
|
}
|
|
522
562
|
//#endregion
|
|
523
563
|
//#region src/widgets/form/reply.ts
|
|
524
|
-
function
|
|
564
|
+
function G(e, t) {
|
|
525
565
|
return e.fields.map((e) => [e.label, (t[e.name] ?? "").trim()]).filter(([, e]) => e).map(([e, t]) => `${e} : ${t}`).join("\n");
|
|
526
566
|
}
|
|
527
567
|
//#endregion
|
|
528
568
|
//#region src/widgets/form/SqcForm.tsx
|
|
529
|
-
var
|
|
530
|
-
function
|
|
569
|
+
var K = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
570
|
+
function q(e, t, n) {
|
|
531
571
|
let r = t.trim();
|
|
532
|
-
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;
|
|
533
573
|
}
|
|
534
|
-
function
|
|
574
|
+
function J({ form: t, locked: n, language: a, reply: o }) {
|
|
535
575
|
let s = r(a).form, [c, l] = e({}), u = t?.fields ?? [], d = (e) => {
|
|
536
576
|
l((t) => {
|
|
537
577
|
if (!(e in t)) return t;
|
|
@@ -548,10 +588,10 @@ function q({ form: t, locked: n, language: a, reply: o }) {
|
|
|
548
588
|
for (let e of u) {
|
|
549
589
|
let t = r.get(e.name);
|
|
550
590
|
i[e.name] = typeof t == "string" ? t : "";
|
|
551
|
-
let n =
|
|
591
|
+
let n = q(e, i[e.name], s);
|
|
552
592
|
n && (a[e.name] = n);
|
|
553
593
|
}
|
|
554
|
-
l(a), Object.keys(a).length === 0 && o(
|
|
594
|
+
l(a), Object.keys(a).length === 0 && o(G(t, i));
|
|
555
595
|
},
|
|
556
596
|
children: [
|
|
557
597
|
t?.title && /* @__PURE__ */ i("p", {
|
|
@@ -608,20 +648,20 @@ function q({ form: t, locked: n, language: a, reply: o }) {
|
|
|
608
648
|
}
|
|
609
649
|
//#endregion
|
|
610
650
|
//#region src/widgets/form/form.css?inline
|
|
611
|
-
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 = [
|
|
612
652
|
s,
|
|
613
|
-
|
|
614
|
-
|
|
653
|
+
Y,
|
|
654
|
+
b,
|
|
615
655
|
p
|
|
616
656
|
].join("\n");
|
|
617
|
-
function
|
|
618
|
-
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, [
|
|
619
659
|
"chart",
|
|
620
660
|
"body",
|
|
621
661
|
"filename"
|
|
622
|
-
],
|
|
662
|
+
], Z)), customElements.get(o.approval) || customElements.define(o.approval, c(y, ["call"], Z)));
|
|
623
663
|
}
|
|
624
664
|
//#endregion
|
|
625
|
-
export {
|
|
665
|
+
export { X as n, B as r, Q as t };
|
|
626
666
|
|
|
627
|
-
//# sourceMappingURL=extras-
|
|
667
|
+
//# sourceMappingURL=extras-DP27_4bx.js.map
|