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