@blueprint-chart/lib 1.5.0 → 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.
@@ -1 +1 @@
1
- export declare const CHART_CSS = "\n/* Blueprint Chart \u2014 Runtime Embed Styles\n CSS custom properties with baked-in defaults for standalone iframe usage. */\n\n.bc-frame {\n --bc-frame-font-family: system-ui, -apple-system, sans-serif;\n --bc-frame-padding: 0;\n --bc-frame-bg: #fff;\n --bc-text-color: #333;\n font-family: var(--bc-frame-font-family);\n background: var(--bc-frame-bg);\n}\n\n/* Keeps the SVG's baked-in background rect (applyCanvasBackground) in sync\n with the frame background; transparentBackground sets the var to\n transparent at runtime. */\n.bc-frame .bc-canvas-bg {\n fill: var(--bc-frame-bg, #fff);\n}\n\n.bc-frame-header {\n padding: var(--bc-frame-padding) var(--bc-frame-padding) 0;\n background: var(--bc-frame-header-bg, transparent);\n border-bottom: var(--bc-frame-header-border-bottom, none);\n margin-bottom: var(--bc-frame-header-margin-bottom, 0);\n}\n\n.bc-frame-body {\n padding: 0 var(--bc-frame-padding);\n}\n\n.bc-frame-title {\n --bc-frame-title-color: var(--bc-text-color, #333);\n --bc-frame-title-font-size: 1.25rem;\n color: var(--bc-frame-title-color);\n font-size: var(--bc-frame-title-font-size);\n font-weight: bold;\n margin: 0;\n}\n\n.bc-frame-description {\n --bc-frame-description-color: var(--bc-text-color, #555);\n --bc-frame-description-font-size: 0.875rem;\n color: var(--bc-frame-description-color);\n font-size: var(--bc-frame-description-font-size);\n margin: 0.25rem 0 0;\n}\n\n.bc-frame-footer {\n margin-top: 0.5rem;\n gap: 0.25rem 1rem;\n padding: var(--bc-frame-footer-padding-top, 0) var(--bc-frame-padding) var(--bc-frame-padding);\n background: var(--bc-frame-footer-bg, transparent);\n border-top: var(--bc-frame-footer-border-top, none);\n}\n\n.bc-frame-footer-left {\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n gap: 0.25rem 0.75rem;\n}\n\n.bc-frame-footer-left > :not(:first-child)::before {\n content: \"\\00B7\";\n margin-right: 0.5rem;\n color: var(--bc-text-color, #888);\n}\n\n.bc-frame-footer-right {\n display: flex;\n align-items: center;\n}\n\n.bc-frame-note {\n --bc-frame-note-color: var(--bc-text-color, #888);\n --bc-frame-note-font-size: 0.75rem;\n font-style: italic;\n color: var(--bc-frame-note-color);\n font-size: var(--bc-frame-note-font-size);\n margin: 0;\n padding: 0 var(--bc-frame-padding);\n}\n\n.bc-frame-byline,\n.bc-frame-source {\n --bc-frame-meta-color: var(--bc-text-color, #888);\n --bc-frame-meta-font-size: 0.75rem;\n color: var(--bc-frame-meta-color);\n font-size: var(--bc-frame-meta-font-size);\n}\n\n.bc-frame-credit {\n --bc-frame-credit-color: var(--bc-text-color, #666);\n --bc-frame-credit-font-size: 0.75rem;\n color: var(--bc-frame-credit-color);\n font-size: var(--bc-frame-credit-font-size);\n font-weight: 600;\n display: inline-flex;\n align-items: center;\n text-decoration: none;\n}\n\n.bc-frame-source-link {\n color: inherit;\n text-decoration: underline;\n}\n\n.bc-axis .domain {\n stroke: var(--bc-axis-color, #333);\n}\n\n.bc-axis .tick text {\n fill: var(--bc-axis-color, #333);\n font-size: 10px;\n}\n\n.bc-axis .tick line {\n stroke: var(--bc-axis-color, #333);\n}\n\n.bc-grid-line {\n stroke: var(--bc-grid-color, #e0e0e0);\n stroke-width: 1;\n}\n\n.bc-zero-baseline {\n stroke: #666;\n stroke-width: 1;\n}\n\n.bc-bar {\n /* fill is set via D3 .attr() from data-bound colors \u2014 do not override */\n}\n\n.bc-line {\n fill: none;\n stroke-width: 2;\n}\n\n.bc-value-label {\n font-size: 11px;\n /* fill is set via D3 .attr() \u2014 do not override */\n}\n\n.bc-direct-label {\n font-size: 12px;\n font-weight: 600;\n}\n\n.bc-tooltip {\n position: absolute;\n pointer-events: none;\n background: var(--bc-tooltip-bg, #fff);\n color: var(--bc-tooltip-color, #212529);\n border: 1px solid var(--bc-tooltip-border-color, #dee2e6);\n border-radius: 4px;\n padding: 6px 10px;\n font-size: 13px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.12);\n z-index: 9999;\n display: none;\n}\n\n.bc-crosshair {\n stroke: #999;\n stroke-width: 1;\n pointer-events: none;\n}\n\n.bc-arc-label-line {\n fill: none;\n stroke: #999;\n stroke-width: 1;\n}\n\n.bc-theme-blueprint-framed {\n --bc-frame-header-border-bottom: 1px solid #e0e0e0;\n --bc-frame-header-margin-bottom: 0.5rem;\n --bc-frame-footer-bg: #f8f8f8;\n --bc-frame-footer-border-top: 1px solid #e0e0e0;\n --bc-frame-footer-padding-top: 0.625rem;\n}\n\n.blueprint-chart-error {\n color: red;\n padding: 1em;\n border: 1px solid red;\n}\n\nbody {\n margin: 0;\n overflow: hidden;\n}\n\n/* Dark theme: activated by data-bs-theme=\"dark\" on the document (matching the\n editor's convention). The chart owns these colors; the dark frame background\n also drives the renderer's resolveBackgroundColor, so data-mark colors and\n contrast labels adapt at render time. Scoped to .bc-frame so these override\n the frame's own light --bc-frame-bg / --bc-text-color declarations (which are\n set on .bc-frame and would otherwise shadow a document-level override). */\n[data-bs-theme=\"dark\"] body {\n /* color themes above-bar value labels (fill: currentColor). */\n background: #1c1c1c;\n color: rgba(255, 255, 255, 0.9);\n}\n\n[data-bs-theme=\"dark\"] .bc-frame {\n --bc-frame-bg: #1c1c1c;\n --bc-text-color: rgba(255, 255, 255, 0.9);\n --bc-axis-color: rgba(255, 255, 255, 0.6);\n --bc-grid-color: #333;\n\n color: rgba(255, 255, 255, 0.9);\n}\n";
1
+ export declare const CHART_CSS = "\n/* Blueprint Chart \u2014 Runtime Embed Styles\n CSS custom properties with baked-in defaults for standalone iframe usage. */\n\n.bc-frame {\n --bc-frame-font-family: system-ui, -apple-system, sans-serif;\n --bc-frame-padding: 0;\n --bc-frame-bg: #fff;\n --bc-text-color: #333;\n font-family: var(--bc-frame-font-family);\n background: var(--bc-frame-bg);\n /* currentColor marks (e.g. above-bar value labels) follow the theme text\n colour, not the ambient document colour. */\n color: var(--bc-text-color, #333);\n}\n\n/* Keeps the SVG's baked-in background rect (applyCanvasBackground) in sync\n with the frame background; transparentBackground sets the var to\n transparent at runtime. */\n.bc-frame .bc-canvas-bg {\n fill: var(--bc-frame-bg, #fff);\n}\n\n.bc-frame-header {\n padding: var(--bc-frame-padding) var(--bc-frame-padding) 0;\n background: var(--bc-frame-header-bg, transparent);\n border-bottom: var(--bc-frame-header-border-bottom, none);\n margin-bottom: var(--bc-frame-header-margin-bottom, 0);\n}\n\n.bc-frame-body {\n padding: 0 var(--bc-frame-padding);\n}\n\n.bc-frame-title {\n --bc-frame-title-color: var(--bc-text-color, #333);\n --bc-frame-title-font-size: 1.25rem;\n color: var(--bc-frame-title-color);\n font-size: var(--bc-frame-title-font-size);\n font-weight: bold;\n margin: 0;\n}\n\n.bc-frame-description {\n --bc-frame-description-color: var(--bc-text-color, #555);\n --bc-frame-description-font-size: 0.875rem;\n color: var(--bc-frame-description-color);\n font-size: var(--bc-frame-description-font-size);\n margin: 0.25rem 0 0;\n}\n\n.bc-frame-footer {\n margin-top: 0.5rem;\n gap: 0.25rem 1rem;\n padding: var(--bc-frame-footer-padding-top, 0) var(--bc-frame-padding) var(--bc-frame-padding);\n background: var(--bc-frame-footer-bg, transparent);\n border-top: var(--bc-frame-footer-border-top, none);\n}\n\n.bc-frame-footer-left {\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n gap: 0.25rem 0.75rem;\n}\n\n.bc-frame-footer-left > :not(:first-child)::before {\n content: \"\\00B7\";\n margin-right: 0.5rem;\n color: var(--bc-text-color, #888);\n}\n\n.bc-frame-footer-right {\n display: flex;\n align-items: center;\n}\n\n.bc-frame-note {\n --bc-frame-note-color: var(--bc-text-color, #888);\n --bc-frame-note-font-size: 0.75rem;\n font-style: italic;\n color: var(--bc-frame-note-color);\n font-size: var(--bc-frame-note-font-size);\n margin: 0;\n padding: 0 var(--bc-frame-padding);\n}\n\n.bc-frame-byline,\n.bc-frame-source {\n --bc-frame-meta-color: var(--bc-text-color, #888);\n --bc-frame-meta-font-size: 0.75rem;\n color: var(--bc-frame-meta-color);\n font-size: var(--bc-frame-meta-font-size);\n}\n\n.bc-frame-credit {\n --bc-frame-credit-color: var(--bc-text-color, #666);\n --bc-frame-credit-font-size: 0.75rem;\n color: var(--bc-frame-credit-color);\n font-size: var(--bc-frame-credit-font-size);\n font-weight: 600;\n display: inline-flex;\n align-items: center;\n text-decoration: none;\n}\n\n.bc-frame-source-link {\n color: inherit;\n text-decoration: underline;\n}\n\n.bc-axis .domain {\n stroke: var(--bc-axis-color, #333);\n}\n\n.bc-axis .tick text {\n fill: var(--bc-axis-color, #333);\n font-size: 10px;\n}\n\n.bc-axis .tick line {\n stroke: var(--bc-axis-color, #333);\n}\n\n.bc-grid-line {\n stroke: var(--bc-grid-color, #e0e0e0);\n stroke-width: 1;\n}\n\n.bc-zero-baseline {\n stroke: #666;\n stroke-width: 1;\n}\n\n.bc-bar {\n /* fill is set via D3 .attr() from data-bound colors \u2014 do not override */\n}\n\n.bc-line {\n fill: none;\n stroke-width: 2;\n}\n\n.bc-value-label {\n font-size: 11px;\n /* fill is set via D3 .attr() \u2014 do not override */\n}\n\n.bc-direct-label {\n font-size: 12px;\n font-weight: 600;\n}\n\n.bc-tooltip {\n position: absolute;\n pointer-events: none;\n background: var(--bc-tooltip-bg, #fff);\n color: var(--bc-tooltip-color, #212529);\n border: 1px solid var(--bc-tooltip-border-color, #dee2e6);\n border-radius: 4px;\n padding: 6px 10px;\n font-size: 13px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.12);\n z-index: 9999;\n display: none;\n}\n\n.bc-crosshair {\n stroke: #999;\n stroke-width: 1;\n pointer-events: none;\n}\n\n.bc-arc-label-line {\n fill: none;\n stroke: #999;\n stroke-width: 1;\n}\n\n.bc-theme-blueprint-framed {\n --bc-frame-header-border-bottom: 1px solid #e0e0e0;\n --bc-frame-header-margin-bottom: 0.5rem;\n --bc-frame-footer-bg: #f8f8f8;\n --bc-frame-footer-border-top: 1px solid #e0e0e0;\n --bc-frame-footer-padding-top: 0.625rem;\n}\n\n[data-bs-theme=\"dark\"] .bc-frame.bc-theme-blueprint-bold {\n --bc-frame-bg: #000000;\n --bc-text-color: rgba(255, 255, 255, 0.95);\n --bc-axis-color: rgba(255, 255, 255, 0.7);\n --bc-grid-color: rgba(255, 255, 255, 0.12);\n}\n\n.blueprint-chart-error {\n color: red;\n padding: 1em;\n border: 1px solid red;\n}\n\nbody {\n margin: 0;\n overflow: hidden;\n}\n\n/* Dark theme: activated by data-bs-theme=\"dark\" on the document (matching the\n editor's convention). The chart owns these colors; the dark frame background\n also drives the renderer's resolveBackgroundColor, so data-mark colors and\n contrast labels adapt at render time. Scoped to .bc-frame so these override\n the frame's own light --bc-frame-bg / --bc-text-color declarations (which are\n set on .bc-frame and would otherwise shadow a document-level override). */\n[data-bs-theme=\"dark\"] body {\n /* color themes above-bar value labels (fill: currentColor). */\n background: #1c1c1c;\n color: rgba(255, 255, 255, 0.9);\n}\n\n[data-bs-theme=\"dark\"] .bc-frame {\n --bc-frame-bg: #1c1c1c;\n --bc-text-color: rgba(255, 255, 255, 0.9);\n --bc-axis-color: rgba(255, 255, 255, 0.6);\n --bc-grid-color: #333;\n\n color: rgba(255, 255, 255, 0.9);\n}\n";
@@ -0,0 +1,84 @@
1
+ //#region src/runtime/chart-css.ts
2
+ var e = "blueprint-chart-resize", t = "blueprint-chart-error";
3
+ function n(e) {
4
+ return typeof e == "object" && e && e.type === "blueprint-chart-resize" && typeof e.height == "number" ? e.height : null;
5
+ }
6
+ function r(e) {
7
+ return typeof e == "object" && !!e && e.type === "blueprint-chart-error";
8
+ }
9
+ //#endregion
10
+ //#region src/runtime/runtime.ts
11
+ var i = a();
12
+ function a() {
13
+ try {
14
+ if (typeof globalThis < "u") {
15
+ let e = globalThis.BLUEPRINT_CHART_RUNTIME_URL;
16
+ if (typeof e == "string" && e) return e;
17
+ }
18
+ return typeof document > "u" ? "" : document.currentScript?.src ?? "";
19
+ } catch {
20
+ return "";
21
+ }
22
+ }
23
+ var o = /* @__PURE__ */ new Map(), s = null;
24
+ function c() {
25
+ s || (s = (e) => {
26
+ for (let [t, n] of o) if (e.source === t.contentWindow) {
27
+ n(e);
28
+ return;
29
+ }
30
+ }, window.addEventListener("message", s));
31
+ }
32
+ function l() {
33
+ c(), document.querySelectorAll("script[type=\"application/blueprint-chart\"]").forEach(u);
34
+ }
35
+ function u(e) {
36
+ let t = e.textContent?.trim();
37
+ if (!t) return;
38
+ let a = document.createElement("iframe");
39
+ a.className = "blueprint-chart-iframe", a.style.cssText = "border: none; width: 100%; display: block;", a.setAttribute("sandbox", "allow-scripts"), a.setAttribute("title", "Blueprint Chart"), e.parentNode?.insertBefore(a, e), a.srcdoc = d(t, i), o.set(a, (e) => {
40
+ let t = n(e.data);
41
+ if (t !== null) {
42
+ a.style.height = `${t}px`;
43
+ return;
44
+ }
45
+ r(e.data) && console.warn("Blueprint Chart: could not render embed.", e.data.message);
46
+ });
47
+ }
48
+ function d(n, r, i) {
49
+ let a = r ? `<script src="${p(r)}"><\/script>` : "", o = i === "dark" ? "<html data-bs-theme=\"dark\">" : "<html>", s = r ? [
50
+ "try {",
51
+ " window.BlueprintChart.renderBpc(document.getElementById(\"chart\"), __BPC_SRC__);",
52
+ "}",
53
+ "catch (e) {",
54
+ ` parent.postMessage({ type: "${t}", message: String(e) }, "*");`,
55
+ "}"
56
+ ] : [`parent.postMessage({ type: "${t}", message: "Blueprint Chart runtime URL unavailable" }, "*");`];
57
+ return [
58
+ "<!DOCTYPE html>",
59
+ `${o}<head>`,
60
+ "<style>\n/* Blueprint Chart — Runtime Embed Styles\n CSS custom properties with baked-in defaults for standalone iframe usage. */\n\n.bc-frame {\n --bc-frame-font-family: system-ui, -apple-system, sans-serif;\n --bc-frame-padding: 0;\n --bc-frame-bg: #fff;\n --bc-text-color: #333;\n font-family: var(--bc-frame-font-family);\n background: var(--bc-frame-bg);\n /* currentColor marks (e.g. above-bar value labels) follow the theme text\n colour, not the ambient document colour. */\n color: var(--bc-text-color, #333);\n}\n\n/* Keeps the SVG's baked-in background rect (applyCanvasBackground) in sync\n with the frame background; transparentBackground sets the var to\n transparent at runtime. */\n.bc-frame .bc-canvas-bg {\n fill: var(--bc-frame-bg, #fff);\n}\n\n.bc-frame-header {\n padding: var(--bc-frame-padding) var(--bc-frame-padding) 0;\n background: var(--bc-frame-header-bg, transparent);\n border-bottom: var(--bc-frame-header-border-bottom, none);\n margin-bottom: var(--bc-frame-header-margin-bottom, 0);\n}\n\n.bc-frame-body {\n padding: 0 var(--bc-frame-padding);\n}\n\n.bc-frame-title {\n --bc-frame-title-color: var(--bc-text-color, #333);\n --bc-frame-title-font-size: 1.25rem;\n color: var(--bc-frame-title-color);\n font-size: var(--bc-frame-title-font-size);\n font-weight: bold;\n margin: 0;\n}\n\n.bc-frame-description {\n --bc-frame-description-color: var(--bc-text-color, #555);\n --bc-frame-description-font-size: 0.875rem;\n color: var(--bc-frame-description-color);\n font-size: var(--bc-frame-description-font-size);\n margin: 0.25rem 0 0;\n}\n\n.bc-frame-footer {\n margin-top: 0.5rem;\n gap: 0.25rem 1rem;\n padding: var(--bc-frame-footer-padding-top, 0) var(--bc-frame-padding) var(--bc-frame-padding);\n background: var(--bc-frame-footer-bg, transparent);\n border-top: var(--bc-frame-footer-border-top, none);\n}\n\n.bc-frame-footer-left {\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n gap: 0.25rem 0.75rem;\n}\n\n.bc-frame-footer-left > :not(:first-child)::before {\n content: \"\\00B7\";\n margin-right: 0.5rem;\n color: var(--bc-text-color, #888);\n}\n\n.bc-frame-footer-right {\n display: flex;\n align-items: center;\n}\n\n.bc-frame-note {\n --bc-frame-note-color: var(--bc-text-color, #888);\n --bc-frame-note-font-size: 0.75rem;\n font-style: italic;\n color: var(--bc-frame-note-color);\n font-size: var(--bc-frame-note-font-size);\n margin: 0;\n padding: 0 var(--bc-frame-padding);\n}\n\n.bc-frame-byline,\n.bc-frame-source {\n --bc-frame-meta-color: var(--bc-text-color, #888);\n --bc-frame-meta-font-size: 0.75rem;\n color: var(--bc-frame-meta-color);\n font-size: var(--bc-frame-meta-font-size);\n}\n\n.bc-frame-credit {\n --bc-frame-credit-color: var(--bc-text-color, #666);\n --bc-frame-credit-font-size: 0.75rem;\n color: var(--bc-frame-credit-color);\n font-size: var(--bc-frame-credit-font-size);\n font-weight: 600;\n display: inline-flex;\n align-items: center;\n text-decoration: none;\n}\n\n.bc-frame-source-link {\n color: inherit;\n text-decoration: underline;\n}\n\n.bc-axis .domain {\n stroke: var(--bc-axis-color, #333);\n}\n\n.bc-axis .tick text {\n fill: var(--bc-axis-color, #333);\n font-size: 10px;\n}\n\n.bc-axis .tick line {\n stroke: var(--bc-axis-color, #333);\n}\n\n.bc-grid-line {\n stroke: var(--bc-grid-color, #e0e0e0);\n stroke-width: 1;\n}\n\n.bc-zero-baseline {\n stroke: #666;\n stroke-width: 1;\n}\n\n.bc-bar {\n /* fill is set via D3 .attr() from data-bound colors — do not override */\n}\n\n.bc-line {\n fill: none;\n stroke-width: 2;\n}\n\n.bc-value-label {\n font-size: 11px;\n /* fill is set via D3 .attr() — do not override */\n}\n\n.bc-direct-label {\n font-size: 12px;\n font-weight: 600;\n}\n\n.bc-tooltip {\n position: absolute;\n pointer-events: none;\n background: var(--bc-tooltip-bg, #fff);\n color: var(--bc-tooltip-color, #212529);\n border: 1px solid var(--bc-tooltip-border-color, #dee2e6);\n border-radius: 4px;\n padding: 6px 10px;\n font-size: 13px;\n box-shadow: 0 2px 8px rgba(0,0,0,0.12);\n z-index: 9999;\n display: none;\n}\n\n.bc-crosshair {\n stroke: #999;\n stroke-width: 1;\n pointer-events: none;\n}\n\n.bc-arc-label-line {\n fill: none;\n stroke: #999;\n stroke-width: 1;\n}\n\n.bc-theme-blueprint-framed {\n --bc-frame-header-border-bottom: 1px solid #e0e0e0;\n --bc-frame-header-margin-bottom: 0.5rem;\n --bc-frame-footer-bg: #f8f8f8;\n --bc-frame-footer-border-top: 1px solid #e0e0e0;\n --bc-frame-footer-padding-top: 0.625rem;\n}\n\n[data-bs-theme=\"dark\"] .bc-frame.bc-theme-blueprint-bold {\n --bc-frame-bg: #000000;\n --bc-text-color: rgba(255, 255, 255, 0.95);\n --bc-axis-color: rgba(255, 255, 255, 0.7);\n --bc-grid-color: rgba(255, 255, 255, 0.12);\n}\n\n.blueprint-chart-error {\n color: red;\n padding: 1em;\n border: 1px solid red;\n}\n\nbody {\n margin: 0;\n overflow: hidden;\n}\n\n/* Dark theme: activated by data-bs-theme=\"dark\" on the document (matching the\n editor's convention). The chart owns these colors; the dark frame background\n also drives the renderer's resolveBackgroundColor, so data-mark colors and\n contrast labels adapt at render time. Scoped to .bc-frame so these override\n the frame's own light --bc-frame-bg / --bc-text-color declarations (which are\n set on .bc-frame and would otherwise shadow a document-level override). */\n[data-bs-theme=\"dark\"] body {\n /* color themes above-bar value labels (fill: currentColor). */\n background: #1c1c1c;\n color: rgba(255, 255, 255, 0.9);\n}\n\n[data-bs-theme=\"dark\"] .bc-frame {\n --bc-frame-bg: #1c1c1c;\n --bc-text-color: rgba(255, 255, 255, 0.9);\n --bc-axis-color: rgba(255, 255, 255, 0.6);\n --bc-grid-color: #333;\n\n color: rgba(255, 255, 255, 0.9);\n}\n</style>",
61
+ "</head><body>",
62
+ "<div id=\"chart\" class=\"blueprint-chart-container\"></div>",
63
+ a,
64
+ "<script>",
65
+ `var __BPC_SRC__ = ${f(n)};`,
66
+ "function notifySize() {",
67
+ " var h = document.documentElement.scrollHeight;",
68
+ ` parent.postMessage({ type: "${e}", height: h }, "*");`,
69
+ "}",
70
+ ...s,
71
+ "notifySize();",
72
+ "new ResizeObserver(notifySize).observe(document.body);",
73
+ "<\/script>",
74
+ "</body></html>"
75
+ ].filter(Boolean).join("\n");
76
+ }
77
+ function f(e) {
78
+ return JSON.stringify(e).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
79
+ }
80
+ function p(e) {
81
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
82
+ }
83
+ //#endregion
84
+ export { r as a, e as i, l as n, n as o, t as r, d as t };
package/dist/runtime.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './runtime/index'
1
+ export * from './runtime/index.js'
2
2
  export {}
package/dist/runtime.js CHANGED
@@ -1,52 +1,49 @@
1
- import { i as p } from "./embed-DxKuPk6P.js";
2
- import { r as b } from "./render-bpc-CnZB0sa5.js";
3
- function h(m, e, s) {
4
- let t = 0, c = !1;
5
- const n = document.createElement("nav");
6
- n.className = "blueprint-chart-scenes";
7
- const o = document.createElement("button");
8
- o.className = "blueprint-chart-scenes-prev", o.textContent = "Previous";
9
- const a = document.createElement("button");
10
- a.className = "blueprint-chart-scenes-next", a.textContent = "Next";
11
- const l = document.createElement("span");
12
- l.className = "blueprint-chart-scenes-counter", n.appendChild(o), n.appendChild(l), n.appendChild(a), e.length > 0 && m.appendChild(n);
13
- function u() {
14
- if (e.length === 0) {
15
- l.textContent = "";
16
- return;
17
- }
18
- l.textContent = `${t + 1} / ${e.length}`;
19
- }
20
- function r(d) {
21
- if (c || e.length === 0 || !Number.isFinite(d))
22
- return;
23
- const i = (Math.floor(d) % e.length + e.length) % e.length;
24
- t = i, u(), s(e[i], i);
25
- }
26
- return o.addEventListener("click", () => r(t - 1)), a.addEventListener("click", () => r(t + 1)), u(), {
27
- get currentScene() {
28
- return t;
29
- },
30
- get totalScenes() {
31
- return e.length;
32
- },
33
- next() {
34
- r(t + 1);
35
- },
36
- previous() {
37
- r(t - 1);
38
- },
39
- goTo: r,
40
- destroy() {
41
- c || (c = !0, n.remove());
42
- }
43
- };
1
+ import { t as e } from "./render-bpc-Bp2OTJmu.js";
2
+ import { n as t } from "./runtime-BnrDRLyH.js";
3
+ //#region src/runtime/scenes.ts
4
+ function n(e, t, n) {
5
+ let r = 0, i = !1, a = document.createElement("nav");
6
+ a.className = "blueprint-chart-scenes";
7
+ let o = document.createElement("button");
8
+ o.className = "blueprint-chart-scenes-prev", o.textContent = "Previous";
9
+ let s = document.createElement("button");
10
+ s.className = "blueprint-chart-scenes-next", s.textContent = "Next";
11
+ let c = document.createElement("span");
12
+ c.className = "blueprint-chart-scenes-counter", a.appendChild(o), a.appendChild(c), a.appendChild(s), t.length > 0 && e.appendChild(a);
13
+ function l() {
14
+ if (t.length === 0) {
15
+ c.textContent = "";
16
+ return;
17
+ }
18
+ c.textContent = `${r + 1} / ${t.length}`;
19
+ }
20
+ function u(e) {
21
+ if (i || t.length === 0 || !Number.isFinite(e)) return;
22
+ let a = (Math.floor(e) % t.length + t.length) % t.length;
23
+ r = a, l(), n(t[a], a);
24
+ }
25
+ return o.addEventListener("click", () => u(r - 1)), s.addEventListener("click", () => u(r + 1)), l(), {
26
+ get currentScene() {
27
+ return r;
28
+ },
29
+ get totalScenes() {
30
+ return t.length;
31
+ },
32
+ next() {
33
+ u(r + 1);
34
+ },
35
+ previous() {
36
+ u(r - 1);
37
+ },
38
+ goTo: u,
39
+ destroy() {
40
+ i || (i = !0, a.remove());
41
+ }
42
+ };
44
43
  }
45
- const C = h;
46
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", p) : p();
47
- export {
48
- h as createSceneController,
49
- C as createStepController,
50
- p as initBlueprint,
51
- b as renderBpc
52
- };
44
+ var r = n;
45
+ //#endregion
46
+ //#region src/runtime/index.ts
47
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
48
+ //#endregion
49
+ export { n as createSceneController, r as createStepController, t as initBlueprint, e as renderBpc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueprint-chart/lib",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "DSL-driven charting library built on D3. Define charts as text, render them anywhere.",
5
5
  "keywords": [
6
6
  "chart",
@@ -62,25 +62,25 @@
62
62
  "provenance": true
63
63
  },
64
64
  "dependencies": {
65
- "@floating-ui/dom": "^1.7.5",
65
+ "@floating-ui/dom": "^1.8.0",
66
66
  "chroma-js": "^3.2.0",
67
- "d3": "^7",
67
+ "d3": "^7.9.0",
68
68
  "d3-blueprint": "^0.1.7",
69
- "d3-transition": "^3",
70
- "dayjs": "^1.11.19"
69
+ "d3-transition": "^3.0.1",
70
+ "dayjs": "^1.11.21"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/chroma-js": "^3.1.2",
74
- "@types/d3": "^7",
74
+ "@types/d3": "^7.4.3",
75
75
  "@types/jsdom": "^21.1.7",
76
- "peggy": "^4",
77
- "typescript": "^5.7",
78
- "vite": "^6",
79
- "vite-plugin-dts": "^5.0.0",
80
- "vitest": "^3"
76
+ "peggy": "^5.1.0",
77
+ "typescript": "^5.9.3",
78
+ "vite": "^8.2.1",
79
+ "vite-plugin-dts": "^5.0.3",
80
+ "vitest": "^4.1.10"
81
81
  },
82
82
  "optionalDependencies": {
83
- "@napi-rs/canvas": "^0.1.100",
83
+ "@napi-rs/canvas": "^1.0.3",
84
84
  "@resvg/resvg-js": "^2.6.2",
85
85
  "jsdom": "^26.1.0"
86
86
  },
@@ -21,6 +21,7 @@
21
21
 
22
22
  @use "themes/blueprint";
23
23
  @use "themes/blueprint-framed";
24
+ @use "themes/blueprint-bold";
24
25
 
25
26
  // ---------------------------------------------------------------------------
26
27
  // Frame
@@ -33,6 +34,9 @@
33
34
 
34
35
  font-family: var(--bc-frame-font-family);
35
36
  background: var(--bc-frame-bg);
37
+ // currentColor marks (e.g. above-bar value labels) follow the theme text
38
+ // colour, not the ambient document colour.
39
+ color: var(--bc-text-color, #333);
36
40
  }
37
41
 
38
42
  // The chart SVG carries its own background rect (applyCanvasBackground in
@@ -87,8 +91,10 @@
87
91
  position: relative;
88
92
  z-index: 1;
89
93
  // Opaque background so the header covers SVG content behind it.
90
- // Uses the card/container background or white as fallback.
91
- background: var(--bc-frame-header-bg, var(--bs-card-bg, #fff));
94
+ // Falls back to the frame background (which themes such as blueprint-bold
95
+ // set) before the card/container background, so the cover matches the
96
+ // frame rather than flashing a light band over a dark themed canvas.
97
+ background: var(--bc-frame-header-bg, var(--bc-frame-bg, var(--bs-card-bg, #fff)));
92
98
  }
93
99
 
94
100
  .bc-frame-body {
@@ -1,315 +0,0 @@
1
- const f = `
2
- /* Blueprint Chart — Runtime Embed Styles
3
- CSS custom properties with baked-in defaults for standalone iframe usage. */
4
-
5
- .bc-frame {
6
- --bc-frame-font-family: system-ui, -apple-system, sans-serif;
7
- --bc-frame-padding: 0;
8
- --bc-frame-bg: #fff;
9
- --bc-text-color: #333;
10
- font-family: var(--bc-frame-font-family);
11
- background: var(--bc-frame-bg);
12
- }
13
-
14
- /* Keeps the SVG's baked-in background rect (applyCanvasBackground) in sync
15
- with the frame background; transparentBackground sets the var to
16
- transparent at runtime. */
17
- .bc-frame .bc-canvas-bg {
18
- fill: var(--bc-frame-bg, #fff);
19
- }
20
-
21
- .bc-frame-header {
22
- padding: var(--bc-frame-padding) var(--bc-frame-padding) 0;
23
- background: var(--bc-frame-header-bg, transparent);
24
- border-bottom: var(--bc-frame-header-border-bottom, none);
25
- margin-bottom: var(--bc-frame-header-margin-bottom, 0);
26
- }
27
-
28
- .bc-frame-body {
29
- padding: 0 var(--bc-frame-padding);
30
- }
31
-
32
- .bc-frame-title {
33
- --bc-frame-title-color: var(--bc-text-color, #333);
34
- --bc-frame-title-font-size: 1.25rem;
35
- color: var(--bc-frame-title-color);
36
- font-size: var(--bc-frame-title-font-size);
37
- font-weight: bold;
38
- margin: 0;
39
- }
40
-
41
- .bc-frame-description {
42
- --bc-frame-description-color: var(--bc-text-color, #555);
43
- --bc-frame-description-font-size: 0.875rem;
44
- color: var(--bc-frame-description-color);
45
- font-size: var(--bc-frame-description-font-size);
46
- margin: 0.25rem 0 0;
47
- }
48
-
49
- .bc-frame-footer {
50
- margin-top: 0.5rem;
51
- gap: 0.25rem 1rem;
52
- padding: var(--bc-frame-footer-padding-top, 0) var(--bc-frame-padding) var(--bc-frame-padding);
53
- background: var(--bc-frame-footer-bg, transparent);
54
- border-top: var(--bc-frame-footer-border-top, none);
55
- }
56
-
57
- .bc-frame-footer-left {
58
- display: flex;
59
- align-items: baseline;
60
- flex-wrap: wrap;
61
- gap: 0.25rem 0.75rem;
62
- }
63
-
64
- .bc-frame-footer-left > :not(:first-child)::before {
65
- content: "\\00B7";
66
- margin-right: 0.5rem;
67
- color: var(--bc-text-color, #888);
68
- }
69
-
70
- .bc-frame-footer-right {
71
- display: flex;
72
- align-items: center;
73
- }
74
-
75
- .bc-frame-note {
76
- --bc-frame-note-color: var(--bc-text-color, #888);
77
- --bc-frame-note-font-size: 0.75rem;
78
- font-style: italic;
79
- color: var(--bc-frame-note-color);
80
- font-size: var(--bc-frame-note-font-size);
81
- margin: 0;
82
- padding: 0 var(--bc-frame-padding);
83
- }
84
-
85
- .bc-frame-byline,
86
- .bc-frame-source {
87
- --bc-frame-meta-color: var(--bc-text-color, #888);
88
- --bc-frame-meta-font-size: 0.75rem;
89
- color: var(--bc-frame-meta-color);
90
- font-size: var(--bc-frame-meta-font-size);
91
- }
92
-
93
- .bc-frame-credit {
94
- --bc-frame-credit-color: var(--bc-text-color, #666);
95
- --bc-frame-credit-font-size: 0.75rem;
96
- color: var(--bc-frame-credit-color);
97
- font-size: var(--bc-frame-credit-font-size);
98
- font-weight: 600;
99
- display: inline-flex;
100
- align-items: center;
101
- text-decoration: none;
102
- }
103
-
104
- .bc-frame-source-link {
105
- color: inherit;
106
- text-decoration: underline;
107
- }
108
-
109
- .bc-axis .domain {
110
- stroke: var(--bc-axis-color, #333);
111
- }
112
-
113
- .bc-axis .tick text {
114
- fill: var(--bc-axis-color, #333);
115
- font-size: 10px;
116
- }
117
-
118
- .bc-axis .tick line {
119
- stroke: var(--bc-axis-color, #333);
120
- }
121
-
122
- .bc-grid-line {
123
- stroke: var(--bc-grid-color, #e0e0e0);
124
- stroke-width: 1;
125
- }
126
-
127
- .bc-zero-baseline {
128
- stroke: #666;
129
- stroke-width: 1;
130
- }
131
-
132
- .bc-bar {
133
- /* fill is set via D3 .attr() from data-bound colors — do not override */
134
- }
135
-
136
- .bc-line {
137
- fill: none;
138
- stroke-width: 2;
139
- }
140
-
141
- .bc-value-label {
142
- font-size: 11px;
143
- /* fill is set via D3 .attr() — do not override */
144
- }
145
-
146
- .bc-direct-label {
147
- font-size: 12px;
148
- font-weight: 600;
149
- }
150
-
151
- .bc-tooltip {
152
- position: absolute;
153
- pointer-events: none;
154
- background: var(--bc-tooltip-bg, #fff);
155
- color: var(--bc-tooltip-color, #212529);
156
- border: 1px solid var(--bc-tooltip-border-color, #dee2e6);
157
- border-radius: 4px;
158
- padding: 6px 10px;
159
- font-size: 13px;
160
- box-shadow: 0 2px 8px rgba(0,0,0,0.12);
161
- z-index: 9999;
162
- display: none;
163
- }
164
-
165
- .bc-crosshair {
166
- stroke: #999;
167
- stroke-width: 1;
168
- pointer-events: none;
169
- }
170
-
171
- .bc-arc-label-line {
172
- fill: none;
173
- stroke: #999;
174
- stroke-width: 1;
175
- }
176
-
177
- .bc-theme-blueprint-framed {
178
- --bc-frame-header-border-bottom: 1px solid #e0e0e0;
179
- --bc-frame-header-margin-bottom: 0.5rem;
180
- --bc-frame-footer-bg: #f8f8f8;
181
- --bc-frame-footer-border-top: 1px solid #e0e0e0;
182
- --bc-frame-footer-padding-top: 0.625rem;
183
- }
184
-
185
- .blueprint-chart-error {
186
- color: red;
187
- padding: 1em;
188
- border: 1px solid red;
189
- }
190
-
191
- body {
192
- margin: 0;
193
- overflow: hidden;
194
- }
195
-
196
- /* Dark theme: activated by data-bs-theme="dark" on the document (matching the
197
- editor's convention). The chart owns these colors; the dark frame background
198
- also drives the renderer's resolveBackgroundColor, so data-mark colors and
199
- contrast labels adapt at render time. Scoped to .bc-frame so these override
200
- the frame's own light --bc-frame-bg / --bc-text-color declarations (which are
201
- set on .bc-frame and would otherwise shadow a document-level override). */
202
- [data-bs-theme="dark"] body {
203
- /* color themes above-bar value labels (fill: currentColor). */
204
- background: #1c1c1c;
205
- color: rgba(255, 255, 255, 0.9);
206
- }
207
-
208
- [data-bs-theme="dark"] .bc-frame {
209
- --bc-frame-bg: #1c1c1c;
210
- --bc-text-color: rgba(255, 255, 255, 0.9);
211
- --bc-axis-color: rgba(255, 255, 255, 0.6);
212
- --bc-grid-color: #333;
213
-
214
- color: rgba(255, 255, 255, 0.9);
215
- }
216
- `, b = "blueprint-chart-resize", s = "blueprint-chart-error";
217
- function m(e) {
218
- return typeof e == "object" && e !== null && e.type === b && typeof e.height == "number" ? e.height : null;
219
- }
220
- function p(e) {
221
- return typeof e == "object" && e !== null && e.type === s;
222
- }
223
- const g = u();
224
- function u() {
225
- var e;
226
- try {
227
- if (typeof globalThis < "u") {
228
- const r = globalThis.BLUEPRINT_CHART_RUNTIME_URL;
229
- if (typeof r == "string" && r)
230
- return r;
231
- }
232
- return typeof document > "u" ? "" : ((e = document.currentScript) == null ? void 0 : e.src) ?? "";
233
- } catch {
234
- return "";
235
- }
236
- }
237
- const d = /* @__PURE__ */ new Map();
238
- let i = null;
239
- function h() {
240
- i || (i = (e) => {
241
- for (const [r, t] of d)
242
- if (e.source === r.contentWindow) {
243
- t(e);
244
- return;
245
- }
246
- }, window.addEventListener("message", i));
247
- }
248
- function w() {
249
- h(), document.querySelectorAll(
250
- 'script[type="application/blueprint-chart"]'
251
- ).forEach(v);
252
- }
253
- function v(e) {
254
- var o, a;
255
- const r = (o = e.textContent) == null ? void 0 : o.trim();
256
- if (!r)
257
- return;
258
- const t = document.createElement("iframe");
259
- t.className = "blueprint-chart-iframe", t.style.cssText = "border: none; width: 100%; display: block;", t.setAttribute("sandbox", "allow-scripts"), t.setAttribute("title", "Blueprint Chart"), (a = e.parentNode) == null || a.insertBefore(t, e), t.srcdoc = y(r, g);
260
- const n = (c) => {
261
- const l = m(c.data);
262
- if (l !== null) {
263
- t.style.height = `${l}px`;
264
- return;
265
- }
266
- p(c.data) && console.warn("Blueprint Chart: could not render embed.", c.data.message);
267
- };
268
- d.set(t, n);
269
- }
270
- function y(e, r, t) {
271
- const n = r ? `<script src="${k(r)}"><\/script>` : "", o = t === "dark" ? '<html data-bs-theme="dark">' : "<html>", a = r ? [
272
- "try {",
273
- ' window.BlueprintChart.renderBpc(document.getElementById("chart"), __BPC_SRC__);',
274
- "}",
275
- "catch (e) {",
276
- ` parent.postMessage({ type: "${s}", message: String(e) }, "*");`,
277
- "}"
278
- ] : [
279
- `parent.postMessage({ type: "${s}", message: "Blueprint Chart runtime URL unavailable" }, "*");`
280
- ];
281
- return [
282
- "<!DOCTYPE html>",
283
- `${o}<head>`,
284
- `<style>${f}</style>`,
285
- "</head><body>",
286
- '<div id="chart" class="blueprint-chart-container"></div>',
287
- n,
288
- "<script>",
289
- `var __BPC_SRC__ = ${x(e)};`,
290
- "function notifySize() {",
291
- " var h = document.documentElement.scrollHeight;",
292
- ` parent.postMessage({ type: "${b}", height: h }, "*");`,
293
- "}",
294
- ...a,
295
- "notifySize();",
296
- "new ResizeObserver(notifySize).observe(document.body);",
297
- "<\/script>",
298
- "</body></html>"
299
- ].filter(Boolean).join(`
300
- `);
301
- }
302
- function x(e) {
303
- return JSON.stringify(e).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
304
- }
305
- function k(e) {
306
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
307
- }
308
- export {
309
- s as E,
310
- b as R,
311
- p as a,
312
- y as b,
313
- w as i,
314
- m as r
315
- };
@@ -1,8 +0,0 @@
1
- class s extends Error {
2
- constructor(r) {
3
- super(r), this.name = "MissingNodeRenderDepsError";
4
- }
5
- }
6
- export {
7
- s as M
8
- };