sgiant-ai-widget 1.1.0 → 1.2.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 +49 -0
- package/dist/charts.d.ts +78 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +252 -0
- package/dist/charts.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -3
- package/dist/index.js.map +1 -1
- package/dist/sgiant-ai-widget-charts.global.js +3 -0
- package/dist/sgiant-ai-widget-charts.global.js.map +7 -0
- package/dist/sgiant-ai-widget.global.js +27 -15
- package/dist/sgiant-ai-widget.global.js.map +3 -3
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +14 -2
- package/dist/styles.js.map +1 -1
- package/dist/ui-render.d.ts.map +1 -1
- package/dist/ui-render.js +4 -0
- package/dist/ui-render.js.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -19,6 +19,19 @@ npm install sgiant-ai-widget
|
|
|
19
19
|
confirm-gated write, suggestion chips, a form the model designed, a card with
|
|
20
20
|
its own actions, and a renderer you register yourself. Every demo runs a real
|
|
21
21
|
turn and shows the JSON that produced it.
|
|
22
|
+
- **[The chrome →](https://vedatugur.github.io/sgiant-ai-widget/ui.html)** —
|
|
23
|
+
launcher states (`resting`, `unread`, `working`, `offline`, `parked`) driven
|
|
24
|
+
live, what the user can do to the panel, and an animated robot avatar that is
|
|
25
|
+
one inline SVG with its own `prefers-reduced-motion` guard.
|
|
26
|
+
- **[Advanced mode →](https://vedatugur.github.io/sgiant-ai-widget/advanced.html)**
|
|
27
|
+
— the assistant highlighting, filling and clicking inside a real app in an
|
|
28
|
+
iframe, driven over
|
|
29
|
+
[`sgiant-ai-agent-bridge`](https://www.npmjs.com/package/sgiant-ai-agent-bridge).
|
|
30
|
+
Selectors never cross the wire; only ids the page opted in with
|
|
31
|
+
`data-ai-target`.
|
|
32
|
+
- **[Real charts →](https://vedatugur.github.io/sgiant-ai-widget/charts.html)**
|
|
33
|
+
— animated bars, an animated line with a comparison overlay, and a donut,
|
|
34
|
+
drawn with no chart library at all.
|
|
22
35
|
- **[Theming →](https://vedatugur.github.io/sgiant-ai-widget/theming.html)** —
|
|
23
36
|
launcher geometry as custom properties, and an inline SVG brand mark.
|
|
24
37
|
|
|
@@ -51,6 +64,42 @@ The global build bundles its one dependency, so it is a single file. If your
|
|
|
51
64
|
page already uses a bundler, prefer the module build — it shares that dependency
|
|
52
65
|
instead of carrying a second copy.
|
|
53
66
|
|
|
67
|
+
## Charts, if you have no chart library
|
|
68
|
+
|
|
69
|
+
The widget draws a stat tile for a `kpi` and a table for anything else. That is
|
|
70
|
+
deliberate: a host with real chart components should mount those through
|
|
71
|
+
`renderDataWidget`, and a core carrying a second implementation would charge
|
|
72
|
+
every consumer for one they do not use.
|
|
73
|
+
|
|
74
|
+
For surfaces with neither — a WordPress admin page, a plain embed — there is an
|
|
75
|
+
**opt-in** renderer:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { createChartFallback } from "sgiant-ai-widget/charts";
|
|
79
|
+
createAiChatWidget({ renderChartFallback: createChartFallback() });
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<!-- or with no build step at all: a separate 3.8 kB bundle -->
|
|
84
|
+
<script src="https://unpkg.com/sgiant-ai-widget/dist/sgiant-ai-widget-charts.global.js"></script>
|
|
85
|
+
<script>
|
|
86
|
+
SgiantAiWidget.createAiChatWidget({
|
|
87
|
+
renderChartFallback: SgiantAiWidgetCharts.createChartFallback(),
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
It draws `time_series`, `breakdown` and `donut`, reading your `--aiw-*` tokens
|
|
93
|
+
so a chart follows the theme, and it plots the column your spec **names** in
|
|
94
|
+
`metrics` / `dimension` rather than guessing at one — so the same frame renders
|
|
95
|
+
the same numbers here and in a full dashboard renderer. It **throws** for `kpi`, `table`, `pivot_grid`,
|
|
96
|
+
`heatmap`, `scatter` and `content` — which the widget catches and renders with
|
|
97
|
+
its built-in instead. A bad heatmap made of rectangles is worse than a readable
|
|
98
|
+
table of the same numbers.
|
|
99
|
+
|
|
100
|
+
It is a floor, not a charting library. Nothing in the main entry point
|
|
101
|
+
references it, so it costs zero bytes unless you ask for it.
|
|
102
|
+
|
|
54
103
|
## The backend
|
|
55
104
|
|
|
56
105
|
One POST endpoint that streams newline-delimited JSON. Four frame types matter:
|
package/dist/charts.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An optional, dependency-free chart renderer for `renderChartFallback`.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS IS A SEPARATE ENTRY POINT. The widget core deliberately contains no
|
|
5
|
+
* chart code: hosts that have a real charting stack (ours mounts the same
|
|
6
|
+
* component its dashboards use) should render with it, and a core that carried
|
|
7
|
+
* a second implementation would make every consumer pay for one they do not
|
|
8
|
+
* use. This is opt-in, imported from `sgiant-ai-widget/charts`, and nothing in
|
|
9
|
+
* the main entry references it — so it costs zero bytes unless you ask.
|
|
10
|
+
*
|
|
11
|
+
* WHO IT IS FOR. Surfaces with no charting stack and no build step: a WordPress
|
|
12
|
+
* admin page loading the global bundle, a third-party embed, a documentation
|
|
13
|
+
* example. It exists so those three do not each write their own — which is the
|
|
14
|
+
* drift this package has spent its short life avoiding elsewhere.
|
|
15
|
+
*
|
|
16
|
+
* WHO IT IS NOT FOR. A React app that already has charts. Use those instead:
|
|
17
|
+
* they will be better than this, and they are already in your bundle.
|
|
18
|
+
*
|
|
19
|
+
* It draws with inline SVG and reads the widget's own `--aiw-*` custom
|
|
20
|
+
* properties, so a chart follows whatever theme the host set rather than
|
|
21
|
+
* carrying a palette of its own.
|
|
22
|
+
*/
|
|
23
|
+
/** One row of a `widget` frame. Values are whatever the backend sent. */
|
|
24
|
+
export type ChartRow = Record<string, unknown>;
|
|
25
|
+
/** The `spec` half of a `widget` frame. */
|
|
26
|
+
export interface ChartSpec {
|
|
27
|
+
title?: string;
|
|
28
|
+
chartType?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Which columns hold the numbers, named by the model that asked for the
|
|
31
|
+
* chart. The first is drawn.
|
|
32
|
+
*
|
|
33
|
+
* HONOURED RATHER THAN GUESSED, and the difference is a wrong chart. The
|
|
34
|
+
* dashboard renderer this stands in for takes `metrics` and `dimension` from
|
|
35
|
+
* the spec; an earlier version of this file took "the last numeric field",
|
|
36
|
+
* so `{period, revenue, bookings}` plotted BOOKINGS while the same data on a
|
|
37
|
+
* dashboard plotted revenue. No error, no warning, two different pictures of
|
|
38
|
+
* one number — which is the exact failure this codebase already has a page of
|
|
39
|
+
* rules about.
|
|
40
|
+
*/
|
|
41
|
+
metrics?: string[];
|
|
42
|
+
/** Which column is the axis / label. */
|
|
43
|
+
dimension?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ChartFallbackOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Animate on first paint. Default true.
|
|
48
|
+
*
|
|
49
|
+
* Animation is also disabled automatically when the reader has asked for
|
|
50
|
+
* reduced motion — this option is for hosts that want it off regardless, such
|
|
51
|
+
* as a print view or a dense dashboard where six charts arriving at once is
|
|
52
|
+
* noise rather than delight.
|
|
53
|
+
*/
|
|
54
|
+
animate?: boolean;
|
|
55
|
+
/** Height of the drawing area in px. Default 140. */
|
|
56
|
+
height?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build a `renderChartFallback` implementation.
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { createChartFallback } from "sgiant-ai-widget/charts";
|
|
63
|
+
* createAiChatWidget({ renderChartFallback: createChartFallback() });
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* IT REFUSES WHAT IT CANNOT DRAW WELL, and that is the important part. `kpi`,
|
|
67
|
+
* `table`, `pivot_grid`, `heatmap`, `scatter` and `content` throw, which the
|
|
68
|
+
* widget catches and falls through to its own built-in — a stat tile for a kpi,
|
|
69
|
+
* a readable table for the rest. A bad heatmap made of rectangles is worse than
|
|
70
|
+
* a table of the same numbers, and a `kpi` is already better served by the
|
|
71
|
+
* built-in stat than by a chart of one bar.
|
|
72
|
+
*
|
|
73
|
+
* This is a FLOOR for surfaces with no charting stack. A host with real chart
|
|
74
|
+
* components should mount those through `renderDataWidget` instead — eight
|
|
75
|
+
* dashboard widget types exist and this draws three of them.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createChartFallback(options?: ChartFallbackOptions): (host: HTMLElement, spec: unknown, rows: unknown, comparisonRows?: unknown) => void;
|
|
78
|
+
//# sourceMappingURL=charts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../src/charts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA6MD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,IAIlE,MAAM,WAAW,EACjB,MAAM,OAAO,EACb,MAAM,OAAO,EACb,iBAAiB,OAAO,KACvB,IAAI,CA2CR"}
|
package/dist/charts.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An optional, dependency-free chart renderer for `renderChartFallback`.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS IS A SEPARATE ENTRY POINT. The widget core deliberately contains no
|
|
5
|
+
* chart code: hosts that have a real charting stack (ours mounts the same
|
|
6
|
+
* component its dashboards use) should render with it, and a core that carried
|
|
7
|
+
* a second implementation would make every consumer pay for one they do not
|
|
8
|
+
* use. This is opt-in, imported from `sgiant-ai-widget/charts`, and nothing in
|
|
9
|
+
* the main entry references it — so it costs zero bytes unless you ask.
|
|
10
|
+
*
|
|
11
|
+
* WHO IT IS FOR. Surfaces with no charting stack and no build step: a WordPress
|
|
12
|
+
* admin page loading the global bundle, a third-party embed, a documentation
|
|
13
|
+
* example. It exists so those three do not each write their own — which is the
|
|
14
|
+
* drift this package has spent its short life avoiding elsewhere.
|
|
15
|
+
*
|
|
16
|
+
* WHO IT IS NOT FOR. A React app that already has charts. Use those instead:
|
|
17
|
+
* they will be better than this, and they are already in your bundle.
|
|
18
|
+
*
|
|
19
|
+
* It draws with inline SVG and reads the widget's own `--aiw-*` custom
|
|
20
|
+
* properties, so a chart follows whatever theme the host set rather than
|
|
21
|
+
* carrying a palette of its own.
|
|
22
|
+
*/
|
|
23
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
24
|
+
function el(name, attrs = {}) {
|
|
25
|
+
const node = document.createElementNS(NS, name);
|
|
26
|
+
for (const [k, v] of Object.entries(attrs))
|
|
27
|
+
node.setAttribute(k, String(v));
|
|
28
|
+
return node;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The numeric value of a row.
|
|
32
|
+
*
|
|
33
|
+
* The LAST numeric field, matching what the widget's own built-in stat does, so
|
|
34
|
+
* a backend that works with one works with the other. A row of
|
|
35
|
+
* `{period, revenue}` measures revenue; `{label, value}` measures value.
|
|
36
|
+
*/
|
|
37
|
+
function valueOf(row, metric) {
|
|
38
|
+
if (metric && typeof row[metric] === "number")
|
|
39
|
+
return Number(row[metric]);
|
|
40
|
+
const keys = Object.keys(row).filter((k) => typeof row[k] === "number");
|
|
41
|
+
return keys.length ? Number(row[keys[keys.length - 1]]) : 0;
|
|
42
|
+
}
|
|
43
|
+
/** The label of a row: an explicit `label`, else the first field. */
|
|
44
|
+
function labelOf(row, dimension) {
|
|
45
|
+
const v = (dimension !== undefined && row[dimension] !== undefined
|
|
46
|
+
? row[dimension]
|
|
47
|
+
: undefined) ??
|
|
48
|
+
row.label ??
|
|
49
|
+
Object.values(row)[0];
|
|
50
|
+
return v == null ? "" : String(v);
|
|
51
|
+
}
|
|
52
|
+
function prefersReducedMotion() {
|
|
53
|
+
try {
|
|
54
|
+
return matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// A host without matchMedia is not a reason to refuse to draw.
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function animateAttr(target, attributeName, from, to, begin) {
|
|
62
|
+
target.appendChild(el("animate", {
|
|
63
|
+
attributeName,
|
|
64
|
+
from,
|
|
65
|
+
to,
|
|
66
|
+
dur: "0.6s",
|
|
67
|
+
begin: `${begin}s`,
|
|
68
|
+
fill: "freeze",
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
function drawBars(rows, H, animate, metric, dim) {
|
|
72
|
+
const W = 320;
|
|
73
|
+
const pad = 22;
|
|
74
|
+
const max = Math.max(...rows.map((r) => valueOf(r, metric)), 1);
|
|
75
|
+
const svg = el("svg", { viewBox: `0 0 ${W} ${H}`, width: "100%", role: "img" });
|
|
76
|
+
const slot = (W - pad * 2) / Math.max(rows.length, 1);
|
|
77
|
+
rows.forEach((row, i) => {
|
|
78
|
+
const h = ((H - pad * 2) * valueOf(row, metric)) / max;
|
|
79
|
+
const x = pad + i * slot + 4;
|
|
80
|
+
const w = Math.max(slot - 8, 2);
|
|
81
|
+
const bar = el("rect", {
|
|
82
|
+
x,
|
|
83
|
+
y: animate ? H - pad : H - pad - h,
|
|
84
|
+
width: w,
|
|
85
|
+
height: animate ? 0 : h,
|
|
86
|
+
rx: 3,
|
|
87
|
+
fill: "var(--aiw-accent)",
|
|
88
|
+
});
|
|
89
|
+
if (animate) {
|
|
90
|
+
animateAttr(bar, "height", 0, h, i * 0.07);
|
|
91
|
+
animateAttr(bar, "y", H - pad, H - pad - h, i * 0.07);
|
|
92
|
+
}
|
|
93
|
+
svg.appendChild(bar);
|
|
94
|
+
const text = el("text", {
|
|
95
|
+
x: x + w / 2,
|
|
96
|
+
y: H - 6,
|
|
97
|
+
"text-anchor": "middle",
|
|
98
|
+
"font-size": 9,
|
|
99
|
+
fill: "var(--aiw-muted)",
|
|
100
|
+
});
|
|
101
|
+
text.textContent = labelOf(row, dim).slice(0, 9);
|
|
102
|
+
svg.appendChild(text);
|
|
103
|
+
});
|
|
104
|
+
return svg;
|
|
105
|
+
}
|
|
106
|
+
function points(rows, W, H, pad, max, metric) {
|
|
107
|
+
return rows
|
|
108
|
+
.map((row, i) => {
|
|
109
|
+
const x = pad + (i * (W - pad * 2)) / Math.max(rows.length - 1, 1);
|
|
110
|
+
const y = H - pad - ((H - pad * 2) * valueOf(row, metric)) / max;
|
|
111
|
+
return `${x},${y}`;
|
|
112
|
+
})
|
|
113
|
+
.join(" ");
|
|
114
|
+
}
|
|
115
|
+
function drawLine(rows, comparison, H, animate, metric) {
|
|
116
|
+
const W = 320;
|
|
117
|
+
const pad = 22;
|
|
118
|
+
const max = Math.max(...[...rows, ...(comparison ?? [])].map((r) => valueOf(r, metric)), 1);
|
|
119
|
+
const svg = el("svg", { viewBox: `0 0 ${W} ${H}`, width: "100%", role: "img" });
|
|
120
|
+
if (comparison?.length)
|
|
121
|
+
svg.appendChild(el("polyline", {
|
|
122
|
+
points: points(comparison, W, H, pad, max, metric),
|
|
123
|
+
fill: "none",
|
|
124
|
+
stroke: "var(--aiw-muted)",
|
|
125
|
+
"stroke-width": 1.5,
|
|
126
|
+
"stroke-dasharray": "4 4",
|
|
127
|
+
opacity: 0.7,
|
|
128
|
+
}));
|
|
129
|
+
const line = el("polyline", {
|
|
130
|
+
points: points(rows, W, H, pad, max, metric),
|
|
131
|
+
fill: "none",
|
|
132
|
+
stroke: "var(--aiw-accent)",
|
|
133
|
+
"stroke-width": 2.5,
|
|
134
|
+
"stroke-linecap": "round",
|
|
135
|
+
"stroke-linejoin": "round",
|
|
136
|
+
});
|
|
137
|
+
svg.appendChild(line);
|
|
138
|
+
if (animate)
|
|
139
|
+
// The length can only be measured once the node is in a document, so this
|
|
140
|
+
// waits a frame rather than guessing — a guessed length either clips the
|
|
141
|
+
// line or leaves it visibly finishing late.
|
|
142
|
+
requestAnimationFrame(() => {
|
|
143
|
+
const len = typeof line.getTotalLength === "function" ? line.getTotalLength() : 0;
|
|
144
|
+
if (!len)
|
|
145
|
+
return;
|
|
146
|
+
line.setAttribute("stroke-dasharray", String(len));
|
|
147
|
+
line.setAttribute("stroke-dashoffset", String(len));
|
|
148
|
+
animateAttr(line, "stroke-dashoffset", len, 0, 0);
|
|
149
|
+
});
|
|
150
|
+
return svg;
|
|
151
|
+
}
|
|
152
|
+
function drawDonut(rows, animate, metric) {
|
|
153
|
+
const S = 140;
|
|
154
|
+
const r = 46;
|
|
155
|
+
const C = 2 * Math.PI * r;
|
|
156
|
+
const total = rows.reduce((sum, row) => sum + valueOf(row, metric), 0) || 1;
|
|
157
|
+
const svg = el("svg", { viewBox: `0 0 ${S} ${S}`, width: "100%", height: S + 10, role: "img" });
|
|
158
|
+
let acc = 0;
|
|
159
|
+
rows.forEach((row, i) => {
|
|
160
|
+
const frac = valueOf(row, metric) / total;
|
|
161
|
+
const arc = el("circle", {
|
|
162
|
+
cx: S / 2,
|
|
163
|
+
cy: S / 2,
|
|
164
|
+
r,
|
|
165
|
+
fill: "none",
|
|
166
|
+
stroke: i === 0 ? "var(--aiw-accent)" : "var(--aiw-muted)",
|
|
167
|
+
opacity: i === 0 ? 1 : Math.max(0.8 - i * 0.22, 0.25),
|
|
168
|
+
"stroke-width": 16,
|
|
169
|
+
"stroke-dasharray": animate ? `0 ${C}` : `${C * frac} ${C}`,
|
|
170
|
+
"stroke-dashoffset": -C * acc,
|
|
171
|
+
transform: `rotate(-90 ${S / 2} ${S / 2})`,
|
|
172
|
+
});
|
|
173
|
+
if (animate)
|
|
174
|
+
animateAttr(arc, "stroke-dasharray", `0 ${C}`, `${C * frac} ${C}`, i * 0.12);
|
|
175
|
+
svg.appendChild(arc);
|
|
176
|
+
acc += frac;
|
|
177
|
+
});
|
|
178
|
+
return svg;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Chart types this renderer draws WELL, mapped from the vocabulary a backend
|
|
182
|
+
* already speaks.
|
|
183
|
+
*
|
|
184
|
+
* The names on the left are the dashboard widget types — `time_series`,
|
|
185
|
+
* `breakdown`, `kpi`, `table`, `pivot_grid`, `heatmap`, `scatter`, `content` —
|
|
186
|
+
* because that is what a `widget` frame's `spec.chartType` carries. A renderer
|
|
187
|
+
* that invented its own names would draw bars for a time series, which is not a
|
|
188
|
+
* styling difference but a wrong chart.
|
|
189
|
+
*
|
|
190
|
+
* `line` / `bar` / `donut` / `pie` are accepted too, for hosts whose backend
|
|
191
|
+
* speaks in shapes rather than in dashboard types.
|
|
192
|
+
*/
|
|
193
|
+
const DRAWS = {
|
|
194
|
+
time_series: "line",
|
|
195
|
+
line: "line",
|
|
196
|
+
breakdown: "bars",
|
|
197
|
+
bar: "bars",
|
|
198
|
+
donut: "donut",
|
|
199
|
+
pie: "donut",
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Build a `renderChartFallback` implementation.
|
|
203
|
+
*
|
|
204
|
+
* ```ts
|
|
205
|
+
* import { createChartFallback } from "sgiant-ai-widget/charts";
|
|
206
|
+
* createAiChatWidget({ renderChartFallback: createChartFallback() });
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* IT REFUSES WHAT IT CANNOT DRAW WELL, and that is the important part. `kpi`,
|
|
210
|
+
* `table`, `pivot_grid`, `heatmap`, `scatter` and `content` throw, which the
|
|
211
|
+
* widget catches and falls through to its own built-in — a stat tile for a kpi,
|
|
212
|
+
* a readable table for the rest. A bad heatmap made of rectangles is worse than
|
|
213
|
+
* a table of the same numbers, and a `kpi` is already better served by the
|
|
214
|
+
* built-in stat than by a chart of one bar.
|
|
215
|
+
*
|
|
216
|
+
* This is a FLOOR for surfaces with no charting stack. A host with real chart
|
|
217
|
+
* components should mount those through `renderDataWidget` instead — eight
|
|
218
|
+
* dashboard widget types exist and this draws three of them.
|
|
219
|
+
*/
|
|
220
|
+
export function createChartFallback(options = {}) {
|
|
221
|
+
const { animate = true, height = 140 } = options;
|
|
222
|
+
return function renderChartFallback(host, spec, rows, comparisonRows) {
|
|
223
|
+
const s = (spec ?? {});
|
|
224
|
+
const data = Array.isArray(rows) ? rows : [];
|
|
225
|
+
const draw = DRAWS[String(s.chartType ?? "")];
|
|
226
|
+
// Throwing is how this seam says "not mine" — the widget catches it and
|
|
227
|
+
// renders its built-in instead. Returning quietly would leave an empty box.
|
|
228
|
+
if (!draw || !data.length)
|
|
229
|
+
throw new Error(`sgiant-ai-widget/charts does not draw "${String(s.chartType)}" — ` +
|
|
230
|
+
`falling through to the built-in renderer.`);
|
|
231
|
+
// The model NAMED these. Guessing is what produces a chart of the wrong
|
|
232
|
+
// column, drawn confidently.
|
|
233
|
+
const metric = s.metrics?.[0];
|
|
234
|
+
const moving = animate && !prefersReducedMotion();
|
|
235
|
+
const wrap = document.createElement("div");
|
|
236
|
+
if (s.title) {
|
|
237
|
+
const title = document.createElement("div");
|
|
238
|
+
title.textContent = s.title;
|
|
239
|
+
title.style.cssText =
|
|
240
|
+
"font-size:var(--aiw-font-xs,11px);font-weight:700;text-transform:uppercase;" +
|
|
241
|
+
"letter-spacing:.05em;color:var(--aiw-muted,#6e6e6e);margin-bottom:6px";
|
|
242
|
+
wrap.appendChild(title);
|
|
243
|
+
}
|
|
244
|
+
wrap.appendChild(draw === "line"
|
|
245
|
+
? drawLine(data, Array.isArray(comparisonRows) ? comparisonRows : undefined, height, moving, metric)
|
|
246
|
+
: draw === "donut"
|
|
247
|
+
? drawDonut(data, moving, metric)
|
|
248
|
+
: drawBars(data, height, moving, metric, s.dimension));
|
|
249
|
+
host.appendChild(wrap);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=charts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.js","sourceRoot":"","sources":["../src/charts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,EAAE,GAAG,4BAA4B,CAAC;AAwCxC,SAAS,EAAE,CACT,IAAO,EACP,QAAyC,EAAE;IAE3C,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAChD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,GAAa,EAAE,MAAe;IAC7C,IAAI,MAAM,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IACxE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,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CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,WAAW,CACd,IAAI,KAAK,MAAM;YACb,CAAC,CAAC,QAAQ,CACN,IAAI,EACJ,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAE,cAA6B,CAAC,CAAC,CAAC,SAAS,EAC1E,MAAM,EACN,MAAM,EACN,MAAM,CACP;YACH,CAAC,CAAC,IAAI,KAAK,OAAO;gBAChB,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC;gBACjC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAC1D,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -224,6 +224,12 @@ export interface AiChatWidgetOptions {
|
|
|
224
224
|
* the bubble looks like itself — which is why a bitmap was never enough for a
|
|
225
225
|
* package other companies brand.
|
|
226
226
|
*
|
|
227
|
+
* Ids inside the mark are made unique per copy, because the widget draws it
|
|
228
|
+
* in both the launcher and the panel header — so a gradient, filter, mask or
|
|
229
|
+
* clip path works in both rather than one of them resolving into the other's
|
|
230
|
+
* hidden subtree. You do not need to prefix them for THAT reason. Prefix them
|
|
231
|
+
* anyway if the host page has its own SVG defs, since ids remain global.
|
|
232
|
+
*
|
|
227
233
|
* THIS IS MARKUP AND IT IS INSERTED AS MARKUP. Pass a mark YOU authored, the
|
|
228
234
|
* same way you would write it into your own page. Never build this string
|
|
229
235
|
* from user input, a URL parameter, or anything a model produced. The only
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EACL,eAAe,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EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,EAAE,CACJ,CAAC;CACH;AA8BD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,OAAO,KACV,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAChE,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB;6DACyD;IACzD,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnE,+EAA+E;IAC7E,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;CACxC;AAqHD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,mBAAmB,GACxB,kBAAkB,CAk/JpB"}
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,42 @@ function warnOnce(reason, message) {
|
|
|
102
102
|
/* a host that has replaced console is not a reason to break the turn */
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Make the ids inside one copy of an SVG unique.
|
|
107
|
+
*
|
|
108
|
+
* THE WIDGET DRAWS THE HOST'S MARK TWICE — once in the launcher, once in the
|
|
109
|
+
* panel header — and `innerHTML` of the same string twice puts two elements
|
|
110
|
+
* with the same `id` in the document. `url(#g)` then resolves to the FIRST
|
|
111
|
+
* match, which is inside the launcher; while the panel is open the launcher is
|
|
112
|
+
* `display:none`, so the header's gradient resolves into a hidden subtree and
|
|
113
|
+
* paints nothing. Reported as "the avatar comes out white", and it is: the
|
|
114
|
+
* shape is there, filled with nothing.
|
|
115
|
+
*
|
|
116
|
+
* Anything a mark defines and refers to internally hits this — gradients,
|
|
117
|
+
* filters, masks, clip paths, patterns. So each copy gets its own suffix.
|
|
118
|
+
*
|
|
119
|
+
* Only ids DEFINED in this markup are rewritten, and only references that point
|
|
120
|
+
* at them, so a mark referring to something the host page defines elsewhere
|
|
121
|
+
* still works.
|
|
122
|
+
*/
|
|
123
|
+
let markCopy = 0;
|
|
124
|
+
function uniquifySvgIds(markup) {
|
|
125
|
+
const defined = [...markup.matchAll(/\bid="([^"]+)"/g)].map((m) => m[1]);
|
|
126
|
+
if (!defined.length)
|
|
127
|
+
return markup;
|
|
128
|
+
const suffix = `-aiw${++markCopy}`;
|
|
129
|
+
let out = markup;
|
|
130
|
+
for (const id of defined) {
|
|
131
|
+
// Escape the id for use in a RegExp — an id may legally contain characters
|
|
132
|
+
// that mean something in a pattern.
|
|
133
|
+
const e = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
134
|
+
out = out
|
|
135
|
+
.replace(new RegExp(`\\bid="${e}"`, "g"), `id="${id}${suffix}"`)
|
|
136
|
+
.replace(new RegExp(`url\\(#${e}\\)`, "g"), `url(#${id}${suffix})`)
|
|
137
|
+
.replace(new RegExp(`([\\s:]href)="#${e}"`, "g"), `$1="#${id}${suffix}"`);
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
105
141
|
/**
|
|
106
142
|
* Choose the brand mark: an inline SVG the host authored, a bitmap URL, or the
|
|
107
143
|
* built-in crescent.
|
|
@@ -273,7 +309,7 @@ export function createAiChatWidget(opts) {
|
|
|
273
309
|
const bubble = el("button", `${PREFIX}-bubble`);
|
|
274
310
|
bubble.setAttribute("aria-label", L("openBubble", { name }));
|
|
275
311
|
bubble.innerHTML =
|
|
276
|
-
`<span class="${PREFIX}-bubble-av">${avatarInner}</span>` +
|
|
312
|
+
`<span class="${PREFIX}-bubble-av">${uniquifySvgIds(avatarInner)}</span>` +
|
|
277
313
|
`<span class="${PREFIX}-bubble-label"></span>` +
|
|
278
314
|
`<span class="${PREFIX}-bubble-dot" hidden></span>`;
|
|
279
315
|
/**
|
|
@@ -607,8 +643,10 @@ export function createAiChatWidget(opts) {
|
|
|
607
643
|
};
|
|
608
644
|
window.addEventListener("resize", onResize);
|
|
609
645
|
applyPos(readPos());
|
|
610
|
-
const avatar = el("div",
|
|
611
|
-
|
|
646
|
+
const avatar = el("div",
|
|
647
|
+
// A mark the host supplied presents itself — see the -own rule.
|
|
648
|
+
`${PREFIX}-avatar${opts.avatarSvg || opts.avatarUrl ? ` ${PREFIX}-avatar-own` : ""}`);
|
|
649
|
+
avatar.innerHTML = uniquifySvgIds(avatarInner);
|
|
612
650
|
const hName = el("div", `${PREFIX}-hname`);
|
|
613
651
|
const titleEl = el("span", `${PREFIX}-title`);
|
|
614
652
|
titleEl.textContent = name;
|