@blueprint-chart/lib 2.17.1 → 2.18.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,4 +1,4 @@
1
- import { s as e } from "./runtime-xftta_35.js";
1
+ import { s as e } from "./runtime-BTUG9Tha.js";
2
2
  import * as t from "d3";
3
3
  import "d3-transition";
4
4
  import { D3Blueprint as n } from "d3-blueprint";
@@ -3,3 +3,5 @@ export { initBlueprint };
3
3
  export { renderBpc } from '../render/render-bpc';
4
4
  export { createSceneController, createStepController } from './scenes';
5
5
  export type { SceneDefinition, SceneController, StepDefinition, StepController } from './scenes';
6
+ export { mountScenePlayer } from './player';
7
+ export type { PlayerConfig, PlayerPosition, PlayerType } from './player';
@@ -0,0 +1 @@
1
+ export declare const PLAYER_CSS: string;
@@ -0,0 +1,15 @@
1
+ export type PlayerType = 'buttons' | 'progress-bar' | 'dot-stepper' | 'minimal-arrows';
2
+ export type PlayerPosition = 'left' | 'center' | 'right';
3
+ export interface PlayerState {
4
+ current: number;
5
+ total: number;
6
+ playing: boolean;
7
+ position: PlayerPosition;
8
+ }
9
+ export interface PlayerConfig {
10
+ type: PlayerType;
11
+ position: PlayerPosition;
12
+ total: number;
13
+ }
14
+ export declare function scenePlayerHtml(type: PlayerType, state: PlayerState): string;
15
+ export declare function mountScenePlayer(chart: HTMLElement, config: PlayerConfig, onStep: (step: number) => void): void;
@@ -180,7 +180,7 @@ var o = class extends SyntaxError {
180
180
  };
181
181
  function s(e, t) {
182
182
  t = t === void 0 ? {} : t;
183
- let n = {}, s = t.grammarSource, c = { Chart: Wt }, l = Wt, u = "chart", d = "data", f = "colorize", p = "highlight", m = "area-fill", h = "annotation", g = "range", _ = "note", v = "series", ee = "scene", te = "transform", y = /^[ \t]/, ne = /^[^\t\n\r{}=]/, re = /^[a-zA-Z_#]/, ie = /^[a-zA-Z0-9_#\-]/, b = /^[0-9]/, ae = /^[eE]/, oe = /^[+\-]/, se = /^[^"\\]/, x = /^[0-9a-fA-F]/, S = /^[^\n]/, C = /^[ \t\n\r]/, ce = V("chart", !1), w = V("{", !1), T = V("}", !1), E = H([" ", " "], !1, !1, !1), le = V("data", !1), ue = V("=", !1), de = V(",", !1), fe = V(" ", !1), pe = H([
183
+ let n = {}, s = t.grammarSource, c = { Chart: Wt }, l = Wt, u = "chart", d = "data", f = "colorize", p = "highlight", m = "area-fill", h = "annotation", ee = "range", g = "note", _ = "series", te = "scene", ne = "transform", v = /^[ \t]/, re = /^[^\t\n\r{}=]/, ie = /^[a-zA-Z_#]/, ae = /^[a-zA-Z0-9_#\-]/, y = /^[0-9]/, oe = /^[eE]/, b = /^[+\-]/, se = /^[^"\\]/, x = /^[0-9a-fA-F]/, S = /^[^\n]/, C = /^[ \t\n\r]/, ce = V("chart", !1), w = V("{", !1), T = V("}", !1), E = H([" ", " "], !1, !1, !1), le = V("data", !1), ue = V("=", !1), de = V(",", !1), fe = V(" ", !1), pe = H([
184
184
  " ",
185
185
  "\n",
186
186
  "\r",
@@ -572,7 +572,7 @@ function s(e, t) {
572
572
  function Gt() {
573
573
  let t, r, i, a, o;
574
574
  if (t = N, r = X(), i = Kt(), i === n && (i = Qt(), i === n && (i = $t(), i === n && (i = en(), i === n && (i = nn(), i === n && (i = rn(), i === n && (i = tn(), i === n && (i = an(), i === n && (i = on(), i === n && (i = sn(), i === n && (i = ln())))))))))), i !== n) {
575
- for (a = [], o = e.charAt(N), y.test(o) ? N++ : (o = n, R === 0 && U(E)); o !== n;) a.push(o), o = e.charAt(N), y.test(o) ? N++ : (o = n, R === 0 && U(E));
575
+ for (a = [], o = e.charAt(N), v.test(o) ? N++ : (o = n, R === 0 && U(E)); o !== n;) a.push(o), o = e.charAt(N), v.test(o) ? N++ : (o = n, R === 0 && U(E));
576
576
  o = Z(), o === n && (o = null), Y(), P = t, t = Ue(r, i, o);
577
577
  } else N = t, t = n;
578
578
  return t;
@@ -590,7 +590,7 @@ function s(e, t) {
590
590
  function qt() {
591
591
  let t, r, i, a, o;
592
592
  if (t = N, r = X(), i = Xt(), i === n && (i = Jt()), i !== n) {
593
- for (a = [], o = e.charAt(N), y.test(o) ? N++ : (o = n, R === 0 && U(E)); o !== n;) a.push(o), o = e.charAt(N), y.test(o) ? N++ : (o = n, R === 0 && U(E));
593
+ for (a = [], o = e.charAt(N), v.test(o) ? N++ : (o = n, R === 0 && U(E)); o !== n;) a.push(o), o = e.charAt(N), v.test(o) ? N++ : (o = n, R === 0 && U(E));
594
594
  o = Z(), o === n && (o = null), Y(), P = t, t = Ge(r, i, o);
595
595
  } else N = t, t = n;
596
596
  return t;
@@ -618,7 +618,7 @@ function s(e, t) {
618
618
  }
619
619
  function Zt() {
620
620
  let t, r, i, a;
621
- if (t = N, r = N, i = [], a = e.charAt(N), ne.test(a) ? N++ : (a = n, R === 0 && U(pe)), a !== n) for (; a !== n;) i.push(a), a = e.charAt(N), ne.test(a) ? N++ : (a = n, R === 0 && U(pe));
621
+ if (t = N, r = N, i = [], a = e.charAt(N), re.test(a) ? N++ : (a = n, R === 0 && U(pe)), a !== n) for (; a !== n;) i.push(a), a = e.charAt(N), re.test(a) ? N++ : (a = n, R === 0 && U(pe));
622
622
  else i = n;
623
623
  return r = i === n ? i : e.substring(r, N), r !== n && (P = t, r = Qe(r)), t = r, t;
624
624
  }
@@ -684,7 +684,7 @@ function s(e, t) {
684
684
  }
685
685
  function nn() {
686
686
  let t, r, i, a, o, s;
687
- if (t = N, e.substr(N, 5) === g ? (r = g, N += 5) : (r = n, R === 0 && U(ve)), r !== n) {
687
+ if (t = N, e.substr(N, 5) === ee ? (r = ee, N += 5) : (r = n, R === 0 && U(ve)), r !== n) {
688
688
  if ($(), e.charCodeAt(N) === 123 ? (i = "{", N++) : (i = n, R === 0 && U(w)), i !== n) {
689
689
  for (a = [], o = W(); o !== n;) a.push(o), o = W();
690
690
  o = X(), e.charCodeAt(N) === 125 ? (s = "}", N++) : (s = n, R === 0 && U(T)), s === n ? (N = t, t = n) : (P = t, t = lt(a, o));
@@ -694,7 +694,7 @@ function s(e, t) {
694
694
  }
695
695
  function rn() {
696
696
  let t, r, i, a, o, s;
697
- if (t = N, e.substr(N, 4) === _ ? (r = _, N += 4) : (r = n, R === 0 && U(ye)), r !== n) {
697
+ if (t = N, e.substr(N, 4) === g ? (r = g, N += 4) : (r = n, R === 0 && U(ye)), r !== n) {
698
698
  if ($(), e.charCodeAt(N) === 123 ? (i = "{", N++) : (i = n, R === 0 && U(w)), i !== n) {
699
699
  for (a = [], o = W(); o !== n;) a.push(o), o = W();
700
700
  o = X(), e.charCodeAt(N) === 125 ? (s = "}", N++) : (s = n, R === 0 && U(T)), s === n ? (N = t, t = n) : (P = t, t = ut(a, o));
@@ -704,7 +704,7 @@ function s(e, t) {
704
704
  }
705
705
  function an() {
706
706
  let t, r, i, a, o, s, c, l;
707
- if (t = N, e.substr(N, 6) === v ? (r = v, N += 6) : (r = n, R === 0 && U(be)), r !== n) {
707
+ if (t = N, e.substr(N, 6) === _ ? (r = _, N += 6) : (r = n, R === 0 && U(be)), r !== n) {
708
708
  if (i = Q(), i !== n) {
709
709
  if (a = q(), a !== n) {
710
710
  if ($(), e.charCodeAt(N) === 123 ? (o = "{", N++) : (o = n, R === 0 && U(w)), o !== n) {
@@ -714,11 +714,11 @@ function s(e, t) {
714
714
  } else N = t, t = n;
715
715
  } else N = t, t = n;
716
716
  } else N = t, t = n;
717
- return t === n && (t = N, e.substr(N, 6) === v ? (r = v, N += 6) : (r = n, R === 0 && U(be)), r === n ? (N = t, t = n) : (i = $(), e.charCodeAt(N) === 123 ? (a = "{", N++) : (a = n, R === 0 && U(w)), a === n ? (N = t, t = n) : (P = t, t = ft()))), t;
717
+ return t === n && (t = N, e.substr(N, 6) === _ ? (r = _, N += 6) : (r = n, R === 0 && U(be)), r === n ? (N = t, t = n) : (i = $(), e.charCodeAt(N) === 123 ? (a = "{", N++) : (a = n, R === 0 && U(w)), a === n ? (N = t, t = n) : (P = t, t = ft()))), t;
718
718
  }
719
719
  function on() {
720
720
  let t, r, i, a, o, s, c, l;
721
- if (t = N, e.substr(N, 5) === ee ? (r = ee, N += 5) : (r = n, R === 0 && U(xe)), r !== n) {
721
+ if (t = N, e.substr(N, 5) === te ? (r = te, N += 5) : (r = n, R === 0 && U(xe)), r !== n) {
722
722
  if (i = Q(), i !== n) {
723
723
  if (a = q(), a === n && (a = null), $(), e.charCodeAt(N) === 123 ? (o = "{", N++) : (o = n, R === 0 && U(w)), o !== n) {
724
724
  for (s = [], c = cn(); c !== n;) s.push(c), c = cn();
@@ -730,7 +730,7 @@ function s(e, t) {
730
730
  }
731
731
  function sn() {
732
732
  let t, r, i, a, o, s, c, l;
733
- if (t = N, e.substr(N, 9) === te ? (r = te, N += 9) : (r = n, R === 0 && U(Se)), r !== n) {
733
+ if (t = N, e.substr(N, 9) === ne ? (r = ne, N += 9) : (r = n, R === 0 && U(Se)), r !== n) {
734
734
  if (i = Q(), i !== n) {
735
735
  if (a = K(), a !== n) {
736
736
  if ($(), e.charCodeAt(N) === 123 ? (o = "{", N++) : (o = n, R === 0 && U(w)), o !== n) {
@@ -745,7 +745,7 @@ function s(e, t) {
745
745
  function cn() {
746
746
  let t, r, i, a, o;
747
747
  if (t = N, r = X(), i = Kt(), i === n && (i = Qt(), i === n && (i = $t(), i === n && (i = en(), i === n && (i = nn(), i === n && (i = rn(), i === n && (i = tn(), i === n && (i = an(), i === n && (i = sn(), i === n && (i = ln()))))))))), i !== n) {
748
- for (a = [], o = e.charAt(N), y.test(o) ? N++ : (o = n, R === 0 && U(E)); o !== n;) a.push(o), o = e.charAt(N), y.test(o) ? N++ : (o = n, R === 0 && U(E));
748
+ for (a = [], o = e.charAt(N), v.test(o) ? N++ : (o = n, R === 0 && U(E)); o !== n;) a.push(o), o = e.charAt(N), v.test(o) ? N++ : (o = n, R === 0 && U(E));
749
749
  o = Z(), o === n && (o = null), Y(), P = t, t = ht(r, i, o);
750
750
  } else N = t, t = n;
751
751
  return t;
@@ -753,7 +753,7 @@ function s(e, t) {
753
753
  function W() {
754
754
  let t, r, i, a;
755
755
  if (t = N, $(), r = ln(), r !== n) {
756
- for (i = [], a = e.charAt(N), y.test(a) ? N++ : (a = n, R === 0 && U(E)); a !== n;) i.push(a), a = e.charAt(N), y.test(a) ? N++ : (a = n, R === 0 && U(E));
756
+ for (i = [], a = e.charAt(N), v.test(a) ? N++ : (a = n, R === 0 && U(E)); a !== n;) i.push(a), a = e.charAt(N), v.test(a) ? N++ : (a = n, R === 0 && U(E));
757
757
  a = Z(), a === n && (a = null), Y(), P = t, t = gt(r, a);
758
758
  } else N = t, t = n;
759
759
  return t;
@@ -772,8 +772,8 @@ function s(e, t) {
772
772
  }
773
773
  function K() {
774
774
  let t, r, i, a, o;
775
- if (R++, t = N, r = N, i = e.charAt(N), re.test(i) ? N++ : (i = n, R === 0 && U(Te)), i !== n) {
776
- for (a = [], o = e.charAt(N), ie.test(o) ? N++ : (o = n, R === 0 && U(Ee)); o !== n;) a.push(o), o = e.charAt(N), ie.test(o) ? N++ : (o = n, R === 0 && U(Ee));
775
+ if (R++, t = N, r = N, i = e.charAt(N), ie.test(i) ? N++ : (i = n, R === 0 && U(Te)), i !== n) {
776
+ for (a = [], o = e.charAt(N), ae.test(o) ? N++ : (o = n, R === 0 && U(Ee)); o !== n;) a.push(o), o = e.charAt(N), ae.test(o) ? N++ : (o = n, R === 0 && U(Ee));
777
777
  i = [i, a], r = i;
778
778
  } else N = r, r = n;
779
779
  return t = r === n ? r : e.substring(t, N), R--, t === n && (r = n, R === 0 && U(we)), t;
@@ -781,24 +781,24 @@ function s(e, t) {
781
781
  function dn() {
782
782
  let t, r, i, a, o, s, c, l, u, d;
783
783
  if (t = N, r = N, i = N, e.charCodeAt(N) === 45 ? (a = "-", N++) : (a = n, R === 0 && U(De)), a === n && (a = null), o = N, e.charCodeAt(N) === 46 ? (s = ".", N++) : (s = n, R === 0 && U(Oe)), s !== n) {
784
- if (c = [], l = e.charAt(N), b.test(l) ? N++ : (l = n, R === 0 && U(D)), l !== n) for (; l !== n;) c.push(l), l = e.charAt(N), b.test(l) ? N++ : (l = n, R === 0 && U(D));
784
+ if (c = [], l = e.charAt(N), y.test(l) ? N++ : (l = n, R === 0 && U(D)), l !== n) for (; l !== n;) c.push(l), l = e.charAt(N), y.test(l) ? N++ : (l = n, R === 0 && U(D));
785
785
  else c = n;
786
786
  c === n ? (N = o, o = n) : (s = [s, c], o = s);
787
787
  } else N = o, o = n;
788
788
  if (o === n) {
789
- if (o = N, s = [], c = e.charAt(N), b.test(c) ? N++ : (c = n, R === 0 && U(D)), c !== n) for (; c !== n;) s.push(c), c = e.charAt(N), b.test(c) ? N++ : (c = n, R === 0 && U(D));
789
+ if (o = N, s = [], c = e.charAt(N), y.test(c) ? N++ : (c = n, R === 0 && U(D)), c !== n) for (; c !== n;) s.push(c), c = e.charAt(N), y.test(c) ? N++ : (c = n, R === 0 && U(D));
790
790
  else s = n;
791
791
  if (s !== n) {
792
792
  if (c = N, e.charCodeAt(N) === 46 ? (l = ".", N++) : (l = n, R === 0 && U(Oe)), l !== n) {
793
- for (u = [], d = e.charAt(N), b.test(d) ? N++ : (d = n, R === 0 && U(D)); d !== n;) u.push(d), d = e.charAt(N), b.test(d) ? N++ : (d = n, R === 0 && U(D));
793
+ for (u = [], d = e.charAt(N), y.test(d) ? N++ : (d = n, R === 0 && U(D)); d !== n;) u.push(d), d = e.charAt(N), y.test(d) ? N++ : (d = n, R === 0 && U(D));
794
794
  l = [l, u], c = l;
795
795
  } else N = c, c = n;
796
796
  c === n && (c = null), s = [s, c], o = s;
797
797
  } else N = o, o = n;
798
798
  }
799
799
  if (o !== n) {
800
- if (s = N, c = e.charAt(N), ae.test(c) ? N++ : (c = n, R === 0 && U(ke)), c !== n) {
801
- if (l = e.charAt(N), oe.test(l) ? N++ : (l = n, R === 0 && U(Ae)), l === n && (l = null), u = [], d = e.charAt(N), b.test(d) ? N++ : (d = n, R === 0 && U(D)), d !== n) for (; d !== n;) u.push(d), d = e.charAt(N), b.test(d) ? N++ : (d = n, R === 0 && U(D));
800
+ if (s = N, c = e.charAt(N), oe.test(c) ? N++ : (c = n, R === 0 && U(ke)), c !== n) {
801
+ if (l = e.charAt(N), b.test(l) ? N++ : (l = n, R === 0 && U(Ae)), l === n && (l = null), u = [], d = e.charAt(N), y.test(d) ? N++ : (d = n, R === 0 && U(D)), d !== n) for (; d !== n;) u.push(d), d = e.charAt(N), y.test(d) ? N++ : (d = n, R === 0 && U(D));
802
802
  else u = n;
803
803
  u === n ? (N = s, s = n) : (c = [
804
804
  c,
@@ -934,9 +934,9 @@ function p(e) {
934
934
  return typeof e == "object" && !!e && e.type === "blueprint-chart-error";
935
935
  }
936
936
  //#endregion
937
- //#region src/runtime/runtime.ts
938
- var m = h();
939
- function h() {
937
+ //#region src/runtime/player-css.ts
938
+ var m = "/* Blueprint Chart — Scene player styles, shared by the editor and the embed.\n Light colors live in var() fallbacks; only dark mode defines the tokens. */\n\n[data-bs-theme=\"dark\"] .bc-frame:not([data-bs-theme=\"dark\"] [data-bs-theme=\"light\"] *),\n.bc-frame.bc-theme-dark {\n --bc-scene-player-text: #e6e6e6;\n --bc-scene-player-muted: #a8a5a0;\n --bc-scene-player-border: #6b6966;\n --bc-scene-player-border-hover: #a8a5a0;\n --bc-scene-player-background-hover: rgba(255, 255, 255, 0.06);\n --bc-scene-player-track: #6b6966;\n --bc-scene-player-accent: #4a7fd0;\n --bc-scene-player-accent-hover: #5b8fdc;\n}\n\n.bc-scene-player--buttons {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 0.25rem 0 0;\n width: 100%;\n}\n\n.bc-scene-player--buttons.bc-scene-player--left {\n justify-content: flex-start;\n gap: 16px;\n}\n\n.bc-scene-player--buttons.bc-scene-player--left .bc-scene-player__counter {\n margin-left: auto;\n}\n\n.bc-scene-player--buttons.bc-scene-player--center {\n justify-content: center;\n gap: 16px;\n}\n\n.bc-scene-player--buttons.bc-scene-player--right {\n justify-content: flex-end;\n gap: 16px;\n}\n\n.bc-scene-player--dot-stepper,\n.bc-scene-player--minimal-arrows {\n display: flex;\n align-items: center;\n padding: 0.25rem 0 0;\n width: 100%;\n}\n\n.bc-scene-player--dot-stepper {\n gap: 0.375rem;\n}\n\n.bc-scene-player--minimal-arrows {\n gap: 4px;\n}\n\n.bc-scene-player--dot-stepper.bc-scene-player--left,\n.bc-scene-player--minimal-arrows.bc-scene-player--left {\n justify-content: flex-start;\n}\n\n.bc-scene-player--dot-stepper.bc-scene-player--center,\n.bc-scene-player--minimal-arrows.bc-scene-player--center {\n justify-content: center;\n}\n\n.bc-scene-player--dot-stepper.bc-scene-player--right,\n.bc-scene-player--minimal-arrows.bc-scene-player--right {\n justify-content: flex-end;\n}\n\n.bc-scene-player--progress-bar {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.25rem 0 0;\n width: 100%;\n}\n\n.bc-scene-player__btn-group {\n display: flex;\n gap: 6px;\n}\n\n.bc-scene-player__btn-group__btn {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 14px;\n border-radius: 6px;\n border: 1px solid var(--bc-scene-player-border, currentColor);\n background: none;\n color: var(--bc-scene-player-muted);\n font-size: var(--bs-font-size-sm, 0.875rem);\n font-weight: 500;\n cursor: pointer;\n transition: border-color var(--bc-duration-base, 150ms), color var(--bc-duration-base, 150ms);\n line-height: 1.4;\n}\n\n.bc-scene-player__btn-group__btn:hover:not(:disabled) {\n border-color: var(--bc-scene-player-border-hover);\n background: var(--bc-scene-player-background-hover, rgba(0, 0, 0, 0.04));\n color: var(--bc-scene-player-text);\n}\n\n.bc-scene-player__btn-group__btn--next {\n color: var(--bc-scene-player-text);\n font-weight: 600;\n}\n\n.bc-scene-player__btn-group__btn--disabled {\n opacity: 0.35;\n cursor: default;\n}\n\n.bc-scene-player__nav-btn {\n width: 24px;\n height: 24px;\n border-radius: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: 1px solid var(--bc-scene-player-border, #e2e0db);\n color: var(--bc-scene-player-muted, #9b9893);\n cursor: pointer;\n flex-shrink: 0;\n padding: 0;\n}\n\n.bc-scene-player__nav-btn:hover:not(:disabled) {\n border-color: var(--bc-scene-player-border-hover, #6b6966);\n color: var(--bc-scene-player-text, #1a1a1a);\n}\n\n.bc-scene-player__nav-btn:disabled {\n opacity: 0.3;\n cursor: default;\n}\n\n.bc-scene-player__play-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--bc-scene-player-accent, #2c5aa0);\n border: none;\n color: #fff;\n cursor: pointer;\n flex-shrink: 0;\n padding: 0;\n transition: background var(--bc-duration-base, 150ms) ease;\n}\n\n.bc-scene-player__play-btn:hover {\n background: var(--bc-scene-player-accent-hover, #1e4888);\n}\n\n.bc-scene-player--dot-stepper .bc-scene-player__play-btn {\n width: 30px;\n height: 30px;\n border-radius: 50%;\n}\n\n.bc-scene-player--minimal-arrows .bc-scene-player__play-btn {\n width: 26px;\n height: 26px;\n border-radius: 7px;\n}\n\n.bc-scene-player--progress-bar .bc-scene-player__play-btn {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n}\n\n.bc-scene-player__dots {\n display: flex;\n gap: 6px;\n align-items: center;\n}\n\n.bc-scene-player__dots__dot {\n width: 8px;\n height: 8px;\n border-radius: 4px;\n border: none;\n padding: 0;\n cursor: pointer;\n background: var(--bc-scene-player-track, #e2e0db);\n opacity: 0.4;\n transition: width var(--bc-duration-slow, 250ms) ease, background var(--bc-duration-slow, 250ms) ease, opacity var(--bc-duration-slow, 250ms) ease;\n}\n\n.bc-scene-player__dots__dot--completed {\n background: var(--bc-scene-player-accent, #2c5aa0);\n opacity: 1;\n}\n\n.bc-scene-player__dots__dot--active {\n width: 20px;\n background: var(--bc-scene-player-accent, #2c5aa0);\n opacity: 1;\n}\n\n.bc-scene-player__dots__dot:hover {\n opacity: 0.8;\n}\n\n.bc-scene-player__segments {\n flex: 1;\n display: flex;\n gap: 3px;\n align-items: center;\n}\n\n.bc-scene-player__segments__segment {\n flex: 1;\n height: 4px;\n border-radius: 2px;\n border: none;\n padding: 0;\n cursor: pointer;\n background: var(--bc-scene-player-track, #e2e0db);\n opacity: 0.45;\n transition: height var(--bc-duration-slow, 250ms) ease, background var(--bc-duration-slow, 250ms) ease, opacity var(--bc-duration-slow, 250ms) ease;\n}\n\n.bc-scene-player__segments__segment--completed {\n background: var(--bc-scene-player-accent, #2c5aa0);\n opacity: 1;\n}\n\n.bc-scene-player__segments__segment--active {\n height: 6px;\n background: var(--bc-scene-player-accent, #2c5aa0);\n opacity: 1;\n}\n\n.bc-scene-player__segments__segment:hover {\n opacity: 0.8;\n}\n\n.bc-scene-player__counter {\n font-weight: 500;\n color: var(--bc-scene-player-muted, #9b9893);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n}\n\n.bc-scene-player--buttons .bc-scene-player__counter {\n font-size: var(--bs-font-size-sm, 0.875rem);\n}\n\n.bc-scene-player--minimal-arrows .bc-scene-player__counter {\n font-size: var(--bs-font-size-xs, 0.75rem);\n margin-right: 4px;\n}\n\n.bc-scene-player--minimal-arrows .bc-scene-player__counter--end {\n margin-right: 0;\n margin-left: 4px;\n}\n\n.bc-scene-player--progress-bar .bc-scene-player__counter {\n font-size: var(--bs-font-size-xs, 0.75rem);\n flex-shrink: 0;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .bc-scene-player,\n .bc-scene-player * {\n transition: none;\n }\n}\n", h = ee();
939
+ function ee() {
940
940
  try {
941
941
  if (typeof globalThis < "u") {
942
942
  let e = globalThis.BLUEPRINT_CHART_RUNTIME_URL;
@@ -947,8 +947,8 @@ function h() {
947
947
  return "";
948
948
  }
949
949
  }
950
- var g = /* @__PURE__ */ new Map(), _ = null, v = [];
951
- function ee() {
950
+ var g = /* @__PURE__ */ new Map(), _ = null, te = [];
951
+ function ne() {
952
952
  _ || (_ = (e) => {
953
953
  for (let [t, n] of g) if (e.source === t.contentWindow) {
954
954
  n(e);
@@ -956,21 +956,21 @@ function ee() {
956
956
  }
957
957
  }, window.addEventListener("message", _));
958
958
  }
959
- function te() {
960
- ee(), document.querySelectorAll("script[type=\"application/blueprint-chart\"]").forEach(y);
959
+ function v() {
960
+ ne(), document.querySelectorAll("script[type=\"application/blueprint-chart\"]").forEach(re);
961
961
  }
962
- function y(e) {
962
+ function re(e) {
963
963
  let t = e.textContent?.trim();
964
964
  if (!t) return;
965
965
  let r = document.createElement("iframe");
966
966
  r.className = "blueprint-chart-iframe", r.style.cssText = "border: none; width: 100%; display: block;", r.setAttribute("sandbox", "allow-scripts"), r.setAttribute("title", "Blueprint Chart"), e.parentNode?.insertBefore(r, e);
967
967
  let i = e.closest("[data-bs-theme]")?.getAttribute("data-bs-theme");
968
- if (i === "light" || i === "dark") r.srcdoc = re(t, m, i);
968
+ if (i === "light" || i === "dark") r.srcdoc = b(t, h, i);
969
969
  else {
970
970
  let e = n(), i = () => {
971
- r.srcdoc = re(t, m, e?.matches ? "dark" : "light");
971
+ r.srcdoc = b(t, h, e?.matches ? "dark" : "light");
972
972
  };
973
- i(), e && (e.addEventListener("change", i), v.push(() => e.removeEventListener("change", i)));
973
+ i(), e && (e.addEventListener("change", i), te.push(() => e.removeEventListener("change", i)));
974
974
  }
975
975
  g.set(r, (e) => {
976
976
  let t = f(e.data);
@@ -981,38 +981,76 @@ function y(e) {
981
981
  p(e.data) && console.warn("Blueprint Chart: could not render embed.", e.data.message);
982
982
  });
983
983
  }
984
- function ne(e) {
984
+ var ie = [
985
+ "buttons",
986
+ "progress-bar",
987
+ "dot-stepper",
988
+ "minimal-arrows"
989
+ ], ae = [
990
+ "left",
991
+ "center",
992
+ "right"
993
+ ];
994
+ function y(e, t, n) {
995
+ return t.find((t) => t === e) ?? n;
996
+ }
997
+ function oe(e) {
998
+ let t;
985
999
  try {
986
- return c(e).scenes.length;
1000
+ t = c(e);
987
1001
  } catch {
988
- return 0;
1002
+ return null;
989
1003
  }
1004
+ let n = new Map(t.properties.map((e) => [e.key, e.value])), r = n.get("player");
1005
+ return !t.scenes.length || r === "none" ? null : {
1006
+ type: y(r, ie, "buttons"),
1007
+ position: y(n.get("playerPosition"), ae, "left"),
1008
+ total: t.scenes.length + 1
1009
+ };
990
1010
  }
991
- function re(e, t, n) {
992
- let r = t ? `<script src="${b(t)}"><\/script>` : "", i = n === "dark" ? "<html data-bs-theme=\"dark\">" : "<html>", a = t ? [
1011
+ function b(e, t, n) {
1012
+ let r = t ? `<script src="${x(t)}"><\/script>` : "", i = n === "dark" ? "<html data-bs-theme=\"dark\">" : "<html>", a = t ? [
1013
+ "var chart = document.getElementById(\"chart\");",
1014
+ "function reportError(e) {",
1015
+ ` parent.postMessage({ type: "${d}", message: String(e) }, "*");`,
1016
+ "}",
1017
+ "// Constrained frames size the plot from the footer height measured in the",
1018
+ "// previous render's animation frame, so render again once the player is in.",
1019
+ "function rerenderConstrained() {",
1020
+ " if (!chart.querySelector(\".bc-frame--constrained\")) {",
1021
+ " return;",
1022
+ " }",
1023
+ " try {",
1024
+ " window.BlueprintChart.renderBpc(chart, __BPC_SRC__);",
1025
+ " }",
1026
+ " catch (e) {",
1027
+ " reportError(e);",
1028
+ " }",
1029
+ "}",
993
1030
  "try {",
994
- " var chart = document.getElementById(\"chart\");",
995
1031
  " window.BlueprintChart.renderBpc(chart, __BPC_SRC__);",
996
- " if (__BPC_SCENES__) {",
997
- " window.BlueprintChart.createSceneController(document.body, new Array(__BPC_SCENES__ + 1).fill({ name: \"\" }), function (_scene, i) {",
998
- " window.BlueprintChart.renderBpc(chart, __BPC_SRC__, { sceneIndex: i ? i - 1 : undefined, transition: true });",
1032
+ " if (__BPC_PLAYER__) {",
1033
+ " window.BlueprintChart.mountScenePlayer(chart, __BPC_PLAYER__, function (step) {",
1034
+ " window.BlueprintChart.renderBpc(chart, __BPC_SRC__, { sceneIndex: step > 1 ? step - 2 : undefined, transition: true });",
999
1035
  " });",
1036
+ " requestAnimationFrame(rerenderConstrained);",
1000
1037
  " }",
1001
1038
  "}",
1002
1039
  "catch (e) {",
1003
- ` parent.postMessage({ type: "${d}", message: String(e) }, "*");`,
1040
+ " reportError(e);",
1004
1041
  "}"
1005
1042
  ] : [`parent.postMessage({ type: "${d}", message: "Blueprint Chart runtime URL unavailable" }, "*");`];
1006
1043
  return [
1007
1044
  "<!DOCTYPE html>",
1008
1045
  `${i}<head>`,
1009
1046
  `<style>${l}</style>`,
1047
+ `<style>${m}</style>`,
1010
1048
  "</head><body>",
1011
1049
  "<div id=\"chart\" class=\"blueprint-chart-container\"></div>",
1012
1050
  r,
1013
1051
  "<script>",
1014
- `var __BPC_SRC__ = ${ie(e)};`,
1015
- `var __BPC_SCENES__ = ${ne(e)};`,
1052
+ `var __BPC_SRC__ = ${se(e)};`,
1053
+ `var __BPC_PLAYER__ = ${JSON.stringify(oe(e))};`,
1016
1054
  "function notifySize() {",
1017
1055
  " var h = document.documentElement.scrollHeight;",
1018
1056
  ` parent.postMessage({ type: "${u}", height: h }, "*");`,
@@ -1024,11 +1062,11 @@ function re(e, t, n) {
1024
1062
  "</body></html>"
1025
1063
  ].filter(Boolean).join("\n");
1026
1064
  }
1027
- function ie(e) {
1065
+ function se(e) {
1028
1066
  return JSON.stringify(e).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
1029
1067
  }
1030
- function b(e) {
1068
+ function x(e) {
1031
1069
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1032
1070
  }
1033
1071
  //#endregion
1034
- export { p as a, n as c, u as i, t as l, te as n, f as o, d as r, c as s, re as t };
1072
+ export { p as a, n as c, u as i, t as l, v as n, f as o, d as r, c as s, b as t };
package/dist/runtime.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as e } from "./render-bpc-DZF2uugG.js";
2
- import { n as t } from "./runtime-xftta_35.js";
1
+ import { t as e } from "./render-bpc-jhkrsEsh.js";
2
+ import { n as t } from "./runtime-BTUG9Tha.js";
3
3
  //#region src/runtime/scenes.ts
4
4
  function n(e, t, n) {
5
5
  let r = 0, i = !1, a = document.createElement("nav");
@@ -41,9 +41,125 @@ function n(e, t, n) {
41
41
  }
42
42
  };
43
43
  }
44
- var r = n;
44
+ var r = n, i = 3e3, a = ".bc-scene-player__dots__dot, .bc-scene-player__segments__segment", o = "<svg width=\"8\" height=\"12\" viewBox=\"0 0 8 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M5.5 1.5L1.5 6l4 4.5\" /></svg>", s = "<svg width=\"8\" height=\"12\" viewBox=\"0 0 8 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2.5 1.5L6.5 6l-4 4.5\" /></svg>", c = "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6.5 2L3.5 5l3 3\" /></svg>", l = "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3.5 2L6.5 5l-3 3\" /></svg>";
45
+ function u(e, t) {
46
+ return `<svg width="${e}" height="${e}" viewBox="0 0 12 12" fill="currentColor">${t ? "<rect x=\"1.5\" y=\"1\" width=\"3\" height=\"10\" rx=\"0.8\" /><rect x=\"7.5\" y=\"1\" width=\"3\" height=\"10\" rx=\"0.8\" />" : "<path d=\"M2.5 1v10l8-5z\" />"}</svg>`;
47
+ }
48
+ function d(e) {
49
+ return e ? " disabled" : "";
50
+ }
51
+ function f(e, t) {
52
+ return `<button type="button" class="bc-scene-player__play-btn" aria-label="${t ? "Pause" : "Play"}">${u(e, t)}</button>`;
53
+ }
54
+ function p(e, t, n, r) {
55
+ return `<button type="button" class="bc-scene-player__nav-btn"${d(r)} aria-label="${t}" data-action="${e}">${n}</button>`;
56
+ }
57
+ function m(e, { current: t, total: n }) {
58
+ let r = [];
59
+ for (let i = 1; i <= n; i++) {
60
+ let a = i === t ? ` ${e}--active` : "", o = i < t ? ` ${e}--completed` : "", s = i === t ? " aria-current=\"step\"" : "";
61
+ r.push(`<button type="button" class="${e}${a}${o}" aria-label="Scene ${i} of ${n}"${s}></button>`);
62
+ }
63
+ return r.join("");
64
+ }
65
+ function h(e) {
66
+ let t = e.current <= 1, n = e.current >= e.total, r = t ? " bc-scene-player__btn-group__btn--disabled" : "", i = n ? " bc-scene-player__btn-group__btn--disabled" : "";
67
+ return `<div class="bc-scene-player bc-scene-player--buttons bc-scene-player--${e.position}" data-scene-player><div class="bc-scene-player__btn-group"><button type="button" class="bc-scene-player__btn-group__btn${r}"${d(t)} aria-label="Previous scene" data-action="previous">${o} Back</button><button type="button" class="bc-scene-player__btn-group__btn bc-scene-player__btn-group__btn--next${i}"${d(n)} aria-label="Next scene" data-action="next">Next ${s}</button></div><span class="bc-scene-player__counter">${e.current} / ${e.total}</span></div>`;
68
+ }
69
+ function g(e) {
70
+ return `<div class="bc-scene-player bc-scene-player--dot-stepper bc-scene-player--${e.position}" data-scene-player>` + p("previous", "Previous scene", c, e.current <= 1) + f(11, e.playing) + `<div class="bc-scene-player__dots">${m("bc-scene-player__dots__dot", e)}</div>` + p("next", "Next scene", l, e.current >= e.total) + "</div>";
71
+ }
72
+ function _(e) {
73
+ return `<div class="bc-scene-player bc-scene-player--minimal-arrows bc-scene-player--${e.position}" data-scene-player><span class="bc-scene-player__counter">${e.current}/${e.total}</span>` + p("previous", "Previous scene", c, e.current <= 1) + f(9, e.playing) + p("next", "Next scene", l, e.current >= e.total) + "</div>";
74
+ }
75
+ function v(e) {
76
+ return "<div class=\"bc-scene-player bc-scene-player--progress-bar\" data-scene-player>" + f(10, e.playing) + `<div class="bc-scene-player__segments">${m("bc-scene-player__segments__segment", e)}</div><span class="bc-scene-player__counter">${e.current}/${e.total}</span></div>`;
77
+ }
78
+ var y = {
79
+ buttons: h,
80
+ "dot-stepper": g,
81
+ "minimal-arrows": _,
82
+ "progress-bar": v
83
+ };
84
+ function b(e, t) {
85
+ return y[e](t);
86
+ }
87
+ function x(e) {
88
+ let t = document.createElement("template");
89
+ return t.innerHTML = e, t.content.firstElementChild;
90
+ }
91
+ function S(e, t) {
92
+ for (let { name: n } of Array.from(e.attributes)) t.hasAttribute(n) || e.removeAttribute(n);
93
+ for (let { name: n, value: r } of Array.from(t.attributes)) e.getAttribute(n) !== r && e.setAttribute(n, r);
94
+ }
95
+ function C(e, t) {
96
+ let n = e.childNodes, r = t.childNodes;
97
+ return n.length === r.length && Array.from(n).every((e, t) => e.nodeName === r[t].nodeName);
98
+ }
99
+ function w(e, t) {
100
+ if (S(e, t), !C(e, t)) {
101
+ e.replaceChildren(...Array.from(t.childNodes));
102
+ return;
103
+ }
104
+ e.childNodes.forEach((e, n) => {
105
+ let r = t.childNodes[n];
106
+ e instanceof Element ? w(e, r) : e.nodeValue !== r.nodeValue && (e.nodeValue = r.nodeValue);
107
+ });
108
+ }
109
+ function T(e, t, n) {
110
+ let r = {
111
+ current: 1,
112
+ total: t.total,
113
+ playing: !1,
114
+ position: t.position
115
+ }, o = x(b(t.type, r)), s;
116
+ function c() {
117
+ let e = x(b(t.type, r));
118
+ w(o, e);
119
+ }
120
+ function l(e) {
121
+ if (e < 1 || e > r.total || e === r.current) return;
122
+ let t = d();
123
+ r.current = e, n(e), v(), c(), u(t);
124
+ }
125
+ function u(e) {
126
+ if (!e) return;
127
+ let t = o.querySelector("button:not(:disabled)");
128
+ (e.matches(":disabled") ? t : e)?.focus();
129
+ }
130
+ function d() {
131
+ let e = document.activeElement;
132
+ return e instanceof HTMLElement && o.contains(e) ? e : null;
133
+ }
134
+ function f() {
135
+ r.playing ? h() : p();
136
+ }
137
+ function p() {
138
+ r.playing || (r.playing = !0, c(), l(1), s = setInterval(m, i));
139
+ }
140
+ function m() {
141
+ r.current < r.total ? l(r.current + 1) : h();
142
+ }
143
+ function h() {
144
+ r.playing = !1, clearInterval(s), c();
145
+ }
146
+ function g(e) {
147
+ return Array.from(e.parentElement?.children ?? []).indexOf(e) + 1;
148
+ }
149
+ function _(e) {
150
+ let t = e.target.closest("button");
151
+ if (!t) return;
152
+ let n = t.dataset.action;
153
+ t.classList.contains("bc-scene-player__play-btn") ? f() : n === "previous" ? l(r.current - 1) : n === "next" ? l(r.current + 1) : t.matches(a) && l(g(t));
154
+ }
155
+ function v() {
156
+ let t = e.querySelector(".bc-frame-footer");
157
+ t && o.parentElement !== t && t.appendChild(o);
158
+ }
159
+ o.addEventListener("click", _), v(), new MutationObserver(v).observe(e, { childList: !0 });
160
+ }
45
161
  //#endregion
46
162
  //#region src/runtime/index.ts
47
163
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t();
48
164
  //#endregion
49
- export { n as createSceneController, r as createStepController, t as initBlueprint, e as renderBpc };
165
+ export { n as createSceneController, r as createStepController, t as initBlueprint, T as mountScenePlayer, e as renderBpc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueprint-chart/lib",
3
- "version": "2.17.1",
3
+ "version": "2.18.0",
4
4
  "description": "DSL-driven charting library built on D3. Define charts as text, render them anywhere.",
5
5
  "keywords": [
6
6
  "chart",
@@ -48,12 +48,14 @@
48
48
  "default": "./dist/runtime.js"
49
49
  },
50
50
  "./charts.scss": "./src/charts/chart.scss",
51
+ "./player.css": "./src/runtime/player.css",
51
52
  "./src/charts/chart.scss": "./src/charts/chart.scss",
52
53
  "./embed-runtime.js": "./dist/lib/lib.iife.js"
53
54
  },
54
55
  "files": [
55
56
  "dist",
56
57
  "src/charts/chart.scss",
58
+ "src/runtime/player.css",
57
59
  "README.md",
58
60
  "LICENSE"
59
61
  ],