@omnitend/dashboard-for-laravel 0.35.0 → 0.36.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/dist/charts.js CHANGED
@@ -1,18 +1,18 @@
1
- import { computed as m, defineComponent as f, openBlock as p, createElementBlock as h, createVNode as g, unref as u } from "vue";
2
- import { Bar as V, Line as P, Doughnut as R } from "vue-chartjs";
3
- import { Chart as X, registerables as E } from "chart.js";
4
- const D = (o) => !!o && typeof o == "object" && !Array.isArray(o);
5
- function b(o, e) {
1
+ import { ref as p, getCurrentScope as I, onScopeDispose as j, computed as h, defineComponent as v, openBlock as y, createElementBlock as C, createVNode as _, unref as d } from "vue";
2
+ import { Bar as T, Line as W, Doughnut as Z } from "vue-chartjs";
3
+ import { Chart as q, registerables as z } from "chart.js";
4
+ const F = (o) => !!o && typeof o == "object" && !Array.isArray(o);
5
+ function x(o, e) {
6
6
  const t = { ...o };
7
7
  for (const [r, n] of Object.entries(e))
8
- D(n) && D(t[r]) ? t[r] = b(t[r], n) : t[r] = n;
8
+ F(n) && F(t[r]) ? t[r] = x(t[r], n) : t[r] = n;
9
9
  return t;
10
10
  }
11
- let S = !1;
12
- function y() {
13
- S || (X.register(...E), S = !0);
11
+ let L = !1;
12
+ function $() {
13
+ L || (q.register(...z), L = !0);
14
14
  }
15
- const w = [
15
+ const V = [
16
16
  ["--dx-chart-1", "#2563eb"],
17
17
  // blue
18
18
  ["--dx-chart-2", "#65a30d"],
@@ -30,42 +30,64 @@ const w = [
30
30
  ["--dx-chart-8", "#db2777"]
31
31
  // pink
32
32
  ];
33
- function N() {
34
- if (typeof document > "u" || typeof getComputedStyle > "u")
35
- return w.map(([, e]) => e);
36
- const o = getComputedStyle(document.documentElement);
37
- return w.map(([e, t]) => o.getPropertyValue(e).trim() || t);
33
+ function M(o) {
34
+ return typeof document > "u" || typeof getComputedStyle > "u" ? null : o ?? document.documentElement;
38
35
  }
39
- function k(o, e) {
40
- return typeof document > "u" || typeof getComputedStyle > "u" ? e : getComputedStyle(document.documentElement).getPropertyValue(o).trim() || e;
36
+ function G(o) {
37
+ const e = M(o);
38
+ if (e === null)
39
+ return V.map(([, r]) => r);
40
+ const t = getComputedStyle(e);
41
+ return V.map(([r, n]) => t.getPropertyValue(r).trim() || n);
41
42
  }
42
- function L(o, e) {
43
+ function O(o, e, t) {
44
+ const r = M(t);
45
+ return r === null ? e : getComputedStyle(r).getPropertyValue(o).trim() || e;
46
+ }
47
+ const b = p(0);
48
+ let m = null, g = 0;
49
+ function P() {
50
+ return typeof document > "u" || typeof MutationObserver > "u" || I() === void 0 || (g += 1, m === null && (m = new MutationObserver(() => {
51
+ b.value += 1;
52
+ }), m.observe(document.documentElement, {
53
+ attributes: !0,
54
+ attributeFilter: ["data-bs-theme"],
55
+ subtree: !0
56
+ })), j(() => {
57
+ g -= 1, g === 0 && m !== null && (m.disconnect(), m = null);
58
+ })), b;
59
+ }
60
+ function R(o, e) {
43
61
  const t = o.replace(/^#/, "");
44
62
  if (/^[0-9a-f]{6}$/i.test(t)) {
45
- const n = parseInt(t.slice(0, 2), 16), s = parseInt(t.slice(2, 4), 16), l = parseInt(t.slice(4, 6), 16);
46
- return `rgba(${n}, ${s}, ${l}, ${e})`;
63
+ const n = parseInt(t.slice(0, 2), 16), l = parseInt(t.slice(2, 4), 16), s = parseInt(t.slice(4, 6), 16);
64
+ return `rgba(${n}, ${l}, ${s}, ${e})`;
47
65
  }
48
66
  const r = o.match(/^rgba?\(([^)]+)\)$/);
49
67
  if (r) {
50
- const [n, s, l] = r[1].split(",").map((a) => a.trim());
51
- return `rgba(${n}, ${s}, ${l}, ${e})`;
68
+ const [n, l, s] = r[1].split(",").map((u) => u.trim());
69
+ return `rgba(${n}, ${l}, ${s}, ${e})`;
52
70
  }
53
71
  return o;
54
72
  }
55
- function A(o, e, t, r) {
73
+ function B(o, e, t, r) {
56
74
  const n = new Intl.NumberFormat(r, {
57
75
  maximumFractionDigits: 2
58
76
  }).format(o);
59
77
  return e === "currency" ? `${t}${n}` : e === "percent" ? `${n}%` : n;
60
78
  }
61
- function F(o) {
79
+ function X(o) {
62
80
  const {
63
81
  valueFormat: e,
64
82
  currencySymbol: t = "£",
65
83
  locale: r,
66
84
  showLegend: n = !1,
67
- hasValueAxis: s = !0
68
- } = o, l = L(k("--bs-border-color", "#dee2e6"), 0.6), a = k("--bs-secondary-color", "#6c757d"), i = {
85
+ hasValueAxis: l = !0,
86
+ scope: s
87
+ } = o, u = R(
88
+ O("--bs-border-color", "#dee2e6", s),
89
+ 0.6
90
+ ), a = O("--bs-secondary-color", "#6c757d", s), i = {
69
91
  responsive: !0,
70
92
  maintainAspectRatio: !1,
71
93
  plugins: {
@@ -73,62 +95,64 @@ function F(o) {
73
95
  tooltip: {
74
96
  callbacks: {
75
97
  label: (c) => {
76
- var $, x;
77
- const d = (($ = c.parsed) == null ? void 0 : $.y) ?? c.parsed ?? c.raw, v = typeof d == "number" ? d : Number(d), _ = Number.isFinite(v) ? A(v, e, t, r) : String(d), C = ((x = c.dataset) == null ? void 0 : x.label) ?? c.label ?? "";
78
- return C ? `${C}: ${_}` : _;
98
+ var w, A;
99
+ const f = ((w = c.parsed) == null ? void 0 : w.y) ?? c.parsed ?? c.raw, D = typeof f == "number" ? f : Number(f), S = Number.isFinite(D) ? B(D, e, t, r) : String(f), k = ((A = c.dataset) == null ? void 0 : A.label) ?? c.label ?? "";
100
+ return k ? `${k}: ${S}` : S;
79
101
  }
80
102
  }
81
103
  }
82
104
  }
83
105
  };
84
- return s && (i.scales = {
106
+ return l && (i.scales = {
85
107
  x: {
86
108
  grid: { display: !1 },
87
- border: { color: l },
109
+ border: { color: u },
88
110
  ticks: { color: a }
89
111
  },
90
112
  y: {
91
113
  beginAtZero: !0,
92
- grid: { color: l, drawBorder: !1 },
114
+ grid: { color: u, drawBorder: !1 },
93
115
  border: { display: !1 },
94
116
  ticks: {
95
117
  color: a,
96
- callback: (c) => A(Number(c), e, t, r)
118
+ callback: (c) => B(Number(c), e, t, r)
97
119
  }
98
120
  }
99
121
  }), i;
100
122
  }
101
- function B(o, e, t) {
102
- const r = N(), n = o.length === 1;
103
- return o.map((s, l) => {
104
- const a = { ...s }, i = r[l % r.length];
123
+ function E(o, e, t, r) {
124
+ const n = G(r), l = o.length === 1;
125
+ return o.map((s, u) => {
126
+ const a = { ...s }, i = n[u % n.length];
105
127
  return e === "doughnut" ? (a.backgroundColor === void 0 && (a.backgroundColor = Array.from(
106
128
  { length: t },
107
- (c, d) => r[d % r.length]
108
- )), a) : e === "line" ? (a.borderColor === void 0 && (a.borderColor = i), a.backgroundColor === void 0 && (a.backgroundColor = L(i, 0.15)), a.tension === void 0 && (a.tension = 0.3), a.fill === void 0 && (a.fill = !0), a.pointRadius === void 0 && (a.pointRadius = 2), a) : (a.backgroundColor === void 0 && (a.backgroundColor = n && t > 1 ? Array.from({ length: t }, () => i) : i), a.borderRadius === void 0 && (a.borderRadius = 4), a);
129
+ (c, f) => n[f % n.length]
130
+ )), a) : e === "line" ? (a.borderColor === void 0 && (a.borderColor = i), a.backgroundColor === void 0 && (a.backgroundColor = R(i, 0.15)), a.tension === void 0 && (a.tension = 0.3), a.fill === void 0 && (a.fill = !0), a.pointRadius === void 0 && (a.pointRadius = 2), a) : (a.backgroundColor === void 0 && (a.backgroundColor = l && t > 1 ? Array.from({ length: t }, () => i) : i), a.borderRadius === void 0 && (a.borderRadius = 4), a);
109
131
  });
110
132
  }
111
- function O(o, e) {
112
- const t = m(
113
- () => ({
114
- labels: e.labels,
115
- datasets: B(e.datasets, o, e.labels.length)
116
- })
117
- ), r = m(
118
- () => b(
119
- F({
120
- valueFormat: e.valueFormat,
121
- currencySymbol: e.currencySymbol,
122
- locale: e.locale,
123
- showLegend: e.showLegend ?? e.datasets.length > 1,
124
- hasValueAxis: !0
125
- }),
126
- e.options ?? {}
133
+ function N(o, e, t) {
134
+ const r = P(), n = h(() => (r.value, {
135
+ labels: e.labels,
136
+ datasets: E(
137
+ e.datasets,
138
+ o,
139
+ e.labels.length,
140
+ t.value
127
141
  )
128
- );
129
- return { chartData: t, mergedOptions: r };
142
+ })), l = h(() => (r.value, x(
143
+ X({
144
+ valueFormat: e.valueFormat,
145
+ currencySymbol: e.currencySymbol,
146
+ locale: e.locale,
147
+ showLegend: e.showLegend ?? e.datasets.length > 1,
148
+ hasValueAxis: !0,
149
+ scope: t.value
150
+ }),
151
+ e.options ?? {}
152
+ )));
153
+ return { chartData: n, mergedOptions: l };
130
154
  }
131
- const I = { class: "dx-chart" }, z = /* @__PURE__ */ f({
155
+ const Q = /* @__PURE__ */ v({
132
156
  __name: "DXBarChart",
133
157
  props: {
134
158
  labels: {},
@@ -140,16 +164,20 @@ const I = { class: "dx-chart" }, z = /* @__PURE__ */ f({
140
164
  showLegend: { type: Boolean, default: void 0 }
141
165
  },
142
166
  setup(o) {
143
- y();
144
- const e = o, { chartData: t, mergedOptions: r } = O("bar", e);
145
- return (n, s) => (p(), h("div", I, [
146
- g(u(V), {
147
- data: u(t),
148
- options: u(r)
167
+ $();
168
+ const e = o, t = p(null), { chartData: r, mergedOptions: n } = N("bar", e, t);
169
+ return (l, s) => (y(), C("div", {
170
+ ref_key: "host",
171
+ ref: t,
172
+ class: "dx-chart"
173
+ }, [
174
+ _(d(T), {
175
+ data: d(r),
176
+ options: d(n)
149
177
  }, null, 8, ["data", "options"])
150
- ]));
178
+ ], 512));
151
179
  }
152
- }), j = { class: "dx-chart" }, G = /* @__PURE__ */ f({
180
+ }), U = /* @__PURE__ */ v({
153
181
  __name: "DXLineChart",
154
182
  props: {
155
183
  labels: {},
@@ -161,16 +189,20 @@ const I = { class: "dx-chart" }, z = /* @__PURE__ */ f({
161
189
  showLegend: { type: Boolean, default: void 0 }
162
190
  },
163
191
  setup(o) {
164
- y();
165
- const e = o, { chartData: t, mergedOptions: r } = O("line", e);
166
- return (n, s) => (p(), h("div", j, [
167
- g(u(P), {
168
- data: u(t),
169
- options: u(r)
192
+ $();
193
+ const e = o, t = p(null), { chartData: r, mergedOptions: n } = N("line", e, t);
194
+ return (l, s) => (y(), C("div", {
195
+ ref_key: "host",
196
+ ref: t,
197
+ class: "dx-chart"
198
+ }, [
199
+ _(d(W), {
200
+ data: d(r),
201
+ options: d(n)
170
202
  }, null, 8, ["data", "options"])
171
- ]));
203
+ ], 512));
172
204
  }
173
- }), T = { class: "dx-chart" }, H = /* @__PURE__ */ f({
205
+ }), Y = /* @__PURE__ */ v({
174
206
  __name: "DXDoughnutChart",
175
207
  props: {
176
208
  labels: {},
@@ -183,35 +215,43 @@ const I = { class: "dx-chart" }, z = /* @__PURE__ */ f({
183
215
  showLegend: { type: Boolean, default: void 0 }
184
216
  },
185
217
  setup(o) {
186
- y();
187
- const e = o, t = m(
218
+ $();
219
+ const e = o, t = p(null), r = P(), n = h(
188
220
  () => e.datasets ?? [{ data: e.data ?? [] }]
189
- ), r = m(() => ({
221
+ ), l = h(() => (r.value, {
190
222
  labels: e.labels,
191
- datasets: B(t.value, "doughnut", e.labels.length)
192
- })), n = m(
193
- () => b(
194
- F({
195
- valueFormat: e.valueFormat,
196
- currencySymbol: e.currencySymbol,
197
- locale: e.locale,
198
- showLegend: e.showLegend ?? !0,
199
- hasValueAxis: !1
200
- }),
201
- e.options ?? {}
223
+ datasets: E(
224
+ n.value,
225
+ "doughnut",
226
+ e.labels.length,
227
+ t.value
202
228
  )
203
- );
204
- return (s, l) => (p(), h("div", T, [
205
- g(u(R), {
206
- data: r.value,
207
- options: n.value
229
+ })), s = h(() => (r.value, x(
230
+ X({
231
+ valueFormat: e.valueFormat,
232
+ currencySymbol: e.currencySymbol,
233
+ locale: e.locale,
234
+ showLegend: e.showLegend ?? !0,
235
+ hasValueAxis: !1,
236
+ scope: t.value
237
+ }),
238
+ e.options ?? {}
239
+ )));
240
+ return (u, a) => (y(), C("div", {
241
+ ref_key: "host",
242
+ ref: t,
243
+ class: "dx-chart"
244
+ }, [
245
+ _(d(Z), {
246
+ data: l.value,
247
+ options: s.value
208
248
  }, null, 8, ["data", "options"])
209
- ]));
249
+ ], 512));
210
250
  }
211
251
  });
212
252
  export {
213
- z as DXBarChart,
214
- H as DXDoughnutChart,
215
- G as DXLineChart
253
+ Q as DXBarChart,
254
+ Y as DXDoughnutChart,
255
+ U as DXLineChart
216
256
  };
217
257
  //# sourceMappingURL=charts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"charts.js","sources":["../resources/js/components/charts/chartTheme.ts","../resources/js/components/charts/useThemedChart.ts","../resources/js/components/charts/DXBarChart.vue","../resources/js/components/charts/DXLineChart.vue","../resources/js/components/charts/DXDoughnutChart.vue"],"sourcesContent":["/**\n * Shared theming for the DX*Chart wrappers: the dedicated categorical chart\n * palette (--dx-chart-* from the live theme), dashboard-friendly default options (no gridlines /\n * legend clutter, responsive, formatted ticks), and a one-time Chart.js\n * registration. chart.js / vue-chartjs are OPTIONAL peer deps.\n */\nimport { Chart, registerables } from \"chart.js\";\n\nexport type ChartValueFormat = \"number\" | \"currency\" | \"percent\";\n\nconst isPlainObject = (value: unknown): value is Record<string, any> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\n\n/** Deep-merge consumer `options` over the themed defaults (arrays replace). */\nexport function mergeOptions(\n base: Record<string, any>,\n override: Record<string, any>,\n): Record<string, any> {\n const result: Record<string, any> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (isPlainObject(value) && isPlainObject(result[key])) {\n result[key] = mergeOptions(result[key], value);\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\nlet registered = false;\n\n/**\n * Register Chart.js (idempotent). Uses the full `registerables` set so every\n * controller / scale / element / plugin (incl. Legend, Tooltip, Filler) is\n * available — chart.js is an external peer dep, so this adds no bundle weight.\n */\nexport function registerCharts(): void {\n if (registered) return;\n Chart.register(...registerables);\n registered = true;\n}\n\n// The dedicated data-viz palette (`$dx-chart-palette` in theme.scss) — eight\n// vivid hues in a fixed, CVD-validated order, published as --dx-chart-1..8.\n// Deliberately NOT the semantic --bs-* colours (#141): the base theme colours\n// are dark AA \"emphasis\" shades (too muted for series), and status colours\n// shouldn't impersonate \"series 2\". Fallbacks mirror the shipped theme so\n// charts still render without the CSS (SSR / tests / a consumer who didn't\n// import it). Sync with theme.scss's $dx-chart-palette is enforced by a test\n// that parses the Sass source (charts.test.ts), which is why this is exported.\nexport const PALETTE_VARS: Array<[string, string]> = [\n [\"--dx-chart-1\", \"#2563eb\"], // blue\n [\"--dx-chart-2\", \"#65a30d\"], // lime\n [\"--dx-chart-3\", \"#7c3aed\"], // violet\n [\"--dx-chart-4\", \"#0d9488\"], // teal\n [\"--dx-chart-5\", \"#ea580c\"], // orange\n [\"--dx-chart-6\", \"#0891b2\"], // cyan\n [\"--dx-chart-7\", \"#d97706\"], // amber\n [\"--dx-chart-8\", \"#db2777\"], // pink\n];\n\n/** Resolve the themed categorical palette from the document root. */\nexport function getPalette(): string[] {\n if (typeof document === \"undefined\" || typeof getComputedStyle === \"undefined\") {\n return PALETTE_VARS.map(([, fallback]) => fallback);\n }\n const styles = getComputedStyle(document.documentElement);\n return PALETTE_VARS.map(([name, fallback]) => {\n const value = styles.getPropertyValue(name).trim();\n return value || fallback;\n });\n}\n\n/** Read a single theme colour (e.g. the body text colour) with a fallback. */\nfunction themeColor(name: string, fallback: string): string {\n if (typeof document === \"undefined\" || typeof getComputedStyle === \"undefined\") {\n return fallback;\n }\n const value = getComputedStyle(document.documentElement)\n .getPropertyValue(name)\n .trim();\n return value || fallback;\n}\n\n/** Add an alpha channel to a hex or rgb() colour (best-effort). */\nexport function withAlpha(color: string, alpha: number): string {\n const hex = color.replace(/^#/, \"\");\n if (/^[0-9a-f]{6}$/i.test(hex)) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n }\n const rgbMatch = color.match(/^rgba?\\(([^)]+)\\)$/);\n if (rgbMatch) {\n const [r, g, b] = rgbMatch[1].split(\",\").map((n) => n.trim());\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n }\n return color;\n}\n\n/** Format a numeric value per the chart's value format (for tick/tooltips). */\nexport function formatValue(\n value: number,\n format: ChartValueFormat | undefined,\n currencySymbol: string,\n locale?: string,\n): string {\n const num = new Intl.NumberFormat(locale, {\n maximumFractionDigits: 2,\n }).format(value);\n if (format === \"currency\") return `${currencySymbol}${num}`;\n if (format === \"percent\") return `${num}%`;\n return num;\n}\n\nexport interface BaseOptionArgs {\n valueFormat?: ChartValueFormat;\n currencySymbol?: string;\n locale?: string;\n /** Show the legend (default: false for a single dataset, true for many). */\n showLegend?: boolean;\n /** Whether the chart has value axes (bar/line) vs none (doughnut). */\n hasValueAxis?: boolean;\n}\n\n/** Dashboard default Chart.js options merged under any consumer `options`. */\nexport function baseOptions(args: BaseOptionArgs): Record<string, any> {\n const {\n valueFormat,\n currencySymbol = \"£\",\n locale,\n showLegend = false,\n hasValueAxis = true,\n } = args;\n\n const gridColor = withAlpha(themeColor(\"--bs-border-color\", \"#dee2e6\"), 0.6);\n const tickColor = themeColor(\"--bs-secondary-color\", \"#6c757d\");\n\n const options: Record<string, any> = {\n responsive: true,\n maintainAspectRatio: false,\n plugins: {\n legend: { display: showLegend, labels: { color: tickColor } },\n tooltip: {\n callbacks: {\n label: (ctx: any) => {\n const raw = ctx.parsed?.y ?? ctx.parsed ?? ctx.raw;\n const value = typeof raw === \"number\" ? raw : Number(raw);\n const formatted = Number.isFinite(value)\n ? formatValue(value, valueFormat, currencySymbol, locale)\n : String(raw);\n const label = ctx.dataset?.label ?? ctx.label ?? \"\";\n return label ? `${label}: ${formatted}` : formatted;\n },\n },\n },\n },\n };\n\n if (hasValueAxis) {\n options.scales = {\n x: {\n grid: { display: false },\n border: { color: gridColor },\n ticks: { color: tickColor },\n },\n y: {\n beginAtZero: true,\n grid: { color: gridColor, drawBorder: false },\n border: { display: false },\n ticks: {\n color: tickColor,\n callback: (value: number | string) =>\n formatValue(Number(value), valueFormat, currencySymbol, locale),\n },\n },\n };\n }\n\n return options;\n}\n\n/**\n * Apply the themed palette to any dataset that doesn't set its own colours.\n * Bar: one colour per dataset (or per bar for a single dataset). Line: a themed\n * stroke + translucent fill. Doughnut/pie: one colour per slice.\n */\nexport function applyPalette(\n datasets: any[],\n kind: \"bar\" | \"line\" | \"doughnut\",\n labelsCount: number,\n): any[] {\n const palette = getPalette();\n const single = datasets.length === 1;\n\n return datasets.map((dataset, index) => {\n const next = { ...dataset };\n const color = palette[index % palette.length];\n\n if (kind === \"doughnut\") {\n if (next.backgroundColor === undefined) {\n next.backgroundColor = Array.from(\n { length: labelsCount },\n (_, i) => palette[i % palette.length],\n );\n }\n return next;\n }\n\n if (kind === \"line\") {\n if (next.borderColor === undefined) next.borderColor = color;\n if (next.backgroundColor === undefined) {\n next.backgroundColor = withAlpha(color, 0.15);\n }\n if (next.tension === undefined) next.tension = 0.3;\n if (next.fill === undefined) next.fill = true;\n if (next.pointRadius === undefined) next.pointRadius = 2;\n return next;\n }\n\n // bar\n if (next.backgroundColor === undefined) {\n next.backgroundColor =\n single && labelsCount > 1\n ? Array.from({ length: labelsCount }, () => color)\n : color;\n }\n if (next.borderRadius === undefined) next.borderRadius = 4;\n return next;\n });\n}\n","import { computed, type ComputedRef } from \"vue\";\nimport type { ChartData, ChartDataset, ChartOptions } from \"chart.js\";\nimport {\n baseOptions,\n applyPalette,\n mergeOptions,\n type ChartValueFormat,\n} from \"./chartTheme\";\n\n/**\n * Shared props for the value-axis chart wrappers (`DXBarChart`, `DXLineChart`).\n * `DXBarChart` and `DXLineChart` differ ONLY in the chart.js component they\n * render and the palette kind — everything else (theming, option-merge,\n * legend-default) is identical, and lived duplicated in both SFCs (#135).\n */\nexport interface ThemedChartProps<TType extends \"bar\" | \"line\"> {\n /** X-axis category labels. */\n labels: string[];\n /** Chart.js datasets. Colours are themed when a dataset omits them. */\n datasets: ChartDataset<TType>[];\n /** Chart.js options; deep-merged over the themed defaults. */\n options?: ChartOptions<TType>;\n /** Format value-axis ticks and tooltips. */\n valueFormat?: ChartValueFormat;\n /** Currency symbol for valueFormat: \"currency\" (default \"£\"). */\n currencySymbol?: string;\n /** Locale for number formatting. */\n locale?: string;\n /** Show the legend (default: only when there is more than one dataset). */\n showLegend?: boolean;\n}\n\n/**\n * The themed-chart body shared by `DXBarChart` and `DXLineChart`: applies the\n * data-viz palette to un-coloured datasets and deep-merges the consumer's\n * `options` over the dashboard-friendly defaults. Pass the reactive `props`\n * object (property access stays reactive inside the computeds).\n */\nexport function useThemedChart<TType extends \"bar\" | \"line\">(\n type: TType,\n props: ThemedChartProps<TType>,\n): {\n chartData: ComputedRef<ChartData<TType>>;\n mergedOptions: ComputedRef<ChartOptions<TType>>;\n} {\n const chartData = computed(\n () =>\n ({\n labels: props.labels,\n datasets: applyPalette(props.datasets, type, props.labels.length),\n }) as ChartData<TType>,\n );\n\n const mergedOptions = computed(\n () =>\n mergeOptions(\n baseOptions({\n valueFormat: props.valueFormat,\n currencySymbol: props.currencySymbol,\n locale: props.locale,\n showLegend: props.showLegend ?? props.datasets.length > 1,\n hasValueAxis: true,\n }),\n props.options ?? {},\n ) as ChartOptions<TType>,\n );\n\n return { chartData, mergedOptions };\n}\n","<!--\n @component\n A themed bar chart. Thin wrapper around vue-chartjs (chart.js) with the\n theme's dedicated chart palette (--dx-chart-1..8) applied and dashboard-friendly defaults (no x gridlines,\n formatted value ticks, responsive, legend hidden for a single series). Pass\n `labels` + `datasets`; `options` deep-merges over the defaults.\n\n Requires the optional peer deps `chart.js` and `vue-chartjs`.\n-->\n<template>\n <div class=\"dx-chart\">\n <Bar :data=\"chartData\" :options=\"mergedOptions\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { Bar } from \"vue-chartjs\";\nimport { registerCharts } from \"./chartTheme\";\nimport { useThemedChart, type ThemedChartProps } from \"./useThemedChart\";\n\nregisterCharts();\n\n// `showLegend` defaults to `undefined` (not Vue's Boolean-cast `false`) so the\n// `?? datasets.length > 1` default can actually fire when it isn't passed.\nconst props = withDefaults(defineProps<ThemedChartProps<\"bar\">>(), {\n currencySymbol: \"£\",\n showLegend: undefined,\n});\n\nconst { chartData, mergedOptions } = useThemedChart(\"bar\", props);\n</script>\n","<!--\n @component\n A themed line chart. Thin wrapper around vue-chartjs (chart.js) with the\n theme's dedicated chart palette applied (--dx-chart-1..8 stroke + translucent fill, smoothed line)\n and dashboard-friendly defaults. Pass `labels` + `datasets`; `options`\n deep-merges over the defaults.\n\n Requires the optional peer deps `chart.js` and `vue-chartjs`.\n-->\n<template>\n <div class=\"dx-chart\">\n <Line :data=\"chartData\" :options=\"mergedOptions\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { Line } from \"vue-chartjs\";\nimport { registerCharts } from \"./chartTheme\";\nimport { useThemedChart, type ThemedChartProps } from \"./useThemedChart\";\n\nregisterCharts();\n\n// `showLegend` defaults to `undefined` (not Vue's Boolean-cast `false`) so the\n// `?? datasets.length > 1` default can actually fire when it isn't passed.\nconst props = withDefaults(defineProps<ThemedChartProps<\"line\">>(), {\n currencySymbol: \"£\",\n showLegend: undefined,\n});\n\nconst { chartData, mergedOptions } = useThemedChart(\"line\", props);\n</script>\n","<!--\n @component\n A themed doughnut chart. Thin wrapper around vue-chartjs (chart.js) with one\n chart-palette colour (--dx-chart-1..8) per slice and dashboard-friendly defaults. Pass\n `labels` + either `data` (a number array) or full `datasets`; `options`\n deep-merges over the defaults.\n\n Requires the optional peer deps `chart.js` and `vue-chartjs`.\n-->\n<template>\n <div class=\"dx-chart\">\n <Doughnut :data=\"chartData\" :options=\"mergedOptions\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { Doughnut } from \"vue-chartjs\";\nimport {\n registerCharts,\n baseOptions,\n applyPalette,\n mergeOptions,\n type ChartValueFormat,\n} from \"./chartTheme\";\n\nregisterCharts();\n\ninterface Props {\n /** Slice labels. */\n labels: string[];\n /** Convenience: a single number array (one value per label). */\n data?: number[];\n /** Full Chart.js datasets (alternative to `data`). */\n datasets?: any[];\n /** Chart.js options; deep-merged over the themed defaults. */\n options?: Record<string, any>;\n /** Format tooltip values. */\n valueFormat?: ChartValueFormat;\n /** Currency symbol for valueFormat: \"currency\" (default \"£\"). */\n currencySymbol?: string;\n /** Locale for number formatting. */\n locale?: string;\n /** Show the legend (default: true — slices need identifying). */\n showLegend?: boolean;\n}\n\n// `showLegend` defaults to `undefined` (not Vue's Boolean-cast `false`) so the\n// `?? true` default can actually fire when it isn't passed.\nconst props = withDefaults(defineProps<Props>(), {\n currencySymbol: \"£\",\n showLegend: undefined,\n});\n\nconst resolvedDatasets = computed(() =>\n props.datasets ?? [{ data: props.data ?? [] }],\n);\n\nconst chartData = computed(() => ({\n labels: props.labels,\n datasets: applyPalette(resolvedDatasets.value, \"doughnut\", props.labels.length),\n}));\n\nconst mergedOptions = computed(() =>\n mergeOptions(\n baseOptions({\n valueFormat: props.valueFormat,\n currencySymbol: props.currencySymbol,\n locale: props.locale,\n showLegend: props.showLegend ?? true,\n hasValueAxis: false,\n }),\n props.options ?? {},\n ),\n);\n</script>\n"],"names":["isPlainObject","value","mergeOptions","base","override","result","key","registered","registerCharts","Chart","registerables","PALETTE_VARS","getPalette","fallback","styles","name","themeColor","withAlpha","color","alpha","hex","r","g","b","rgbMatch","n","formatValue","format","currencySymbol","locale","num","baseOptions","args","valueFormat","showLegend","hasValueAxis","gridColor","tickColor","options","ctx","raw","_a","formatted","label","_b","applyPalette","datasets","kind","labelsCount","palette","single","dataset","index","next","_","i","useThemedChart","type","props","chartData","computed","mergedOptions","__props","_openBlock","_createElementBlock","_hoisted_1","_createVNode","_unref","Bar","Line","resolvedDatasets","Doughnut"],"mappings":";;;AAUA,MAAMA,IAAgB,CAACC,MACnB,CAAC,CAACA,KAAS,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK;AAGzD,SAASC,EACZC,GACAC,GACmB;AACnB,QAAMC,IAA8B,EAAE,GAAGF,EAAA;AACzC,a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A,QAAY,SAASQ,EAAAN,CAAA;AAAA,MAAA;;;;;;;;;;;;;;;ACSrC,IAAArD,EAAA;AAIA,UAAMkD,IAAQI,GAKR,EAAE,WAAAH,GAAW,eAAAE,EAAA,IAAkBL,EAAe,QAAQE,CAAK;sBAnB/DK,EAAA,GAAAC,EAEM,OAFNC,GAEM;AAAA,MADJC,EAAmDC,EAAAE,CAAA,GAAA;AAAA,QAA5C,MAAMF,EAAAR,CAAA;AAAA,QAAY,SAASQ,EAAAN,CAAA;AAAA,MAAA;;;;;;;;;;;;;;;;ACetC,IAAArD,EAAA;AAuBA,UAAMkD,IAAQI,GAKRQ,IAAmBV;AAAA,MAAS,MAChCF,EAAM,YAAY,CAAC,EAAE,MAAMA,EAAM,QAAQ,GAAC,CAAG;AAAA,IAAA,GAGzCC,IAAYC,EAAS,OAAO;AAAA,MAChC,QAAQF,EAAM;AAAA,MACd,UAAUb,EAAayB,EAAiB,OAAO,YAAYZ,EAAM,OAAO,MAAM;AAAA,IAAA,EAC9E,GAEIG,IAAgBD;AAAA,MAAS,MAC7B1D;AAAA,QACE6B,EAAY;AAAA,UACV,aAAa2B,EAAM;AAAA,UACnB,gBAAgBA,EAAM;AAAA,UACtB,QAAQA,EAAM;AAAA,UACd,YAAYA,EAAM,cAAc;AAAA,UAChC,cAAc;AAAA,QAAA,CACf;AAAA,QACDA,EAAM,WAAW,CAAA;AAAA,MAAC;AAAA,IACpB;sBA/DAK,EAAA,GAAAC,EAEM,OAFNC,GAEM;AAAA,MADJC,EAAuDC,EAAAI,CAAA,GAAA;AAAA,QAA5C,MAAMZ,EAAA;AAAA,QAAY,SAASE,EAAA;AAAA,MAAA;;;;"}
1
+ {"version":3,"file":"charts.js","sources":["../resources/js/components/charts/chartTheme.ts","../resources/js/components/charts/useThemedChart.ts","../resources/js/components/charts/DXBarChart.vue","../resources/js/components/charts/DXLineChart.vue","../resources/js/components/charts/DXDoughnutChart.vue"],"sourcesContent":["/**\n * Shared theming for the DX*Chart wrappers: the dedicated categorical chart\n * palette (--dx-chart-* from the live theme), dashboard-friendly default options (no gridlines /\n * legend clutter, responsive, formatted ticks), and a one-time Chart.js\n * registration. chart.js / vue-chartjs are OPTIONAL peer deps.\n */\nimport { Chart, registerables } from \"chart.js\";\nimport { getCurrentScope, onScopeDispose, ref, type Ref } from \"vue\";\n\nexport type ChartValueFormat = \"number\" | \"currency\" | \"percent\";\n\nconst isPlainObject = (value: unknown): value is Record<string, any> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\n\n/** Deep-merge consumer `options` over the themed defaults (arrays replace). */\nexport function mergeOptions(\n base: Record<string, any>,\n override: Record<string, any>,\n): Record<string, any> {\n const result: Record<string, any> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (isPlainObject(value) && isPlainObject(result[key])) {\n result[key] = mergeOptions(result[key], value);\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\nlet registered = false;\n\n/**\n * Register Chart.js (idempotent). Uses the full `registerables` set so every\n * controller / scale / element / plugin (incl. Legend, Tooltip, Filler) is\n * available — chart.js is an external peer dep, so this adds no bundle weight.\n */\nexport function registerCharts(): void {\n if (registered) return;\n Chart.register(...registerables);\n registered = true;\n}\n\n// The dedicated data-viz palette (`$dx-chart-palette` in theme.scss) — eight\n// vivid hues in a fixed, CVD-validated order, published as --dx-chart-1..8.\n// Deliberately NOT the semantic --bs-* colours (#141): the base theme colours\n// are dark AA \"emphasis\" shades (too muted for series), and status colours\n// shouldn't impersonate \"series 2\". Fallbacks mirror the shipped theme so\n// charts still render without the CSS (SSR / tests / a consumer who didn't\n// import it). Sync with theme.scss's $dx-chart-palette is enforced by a test\n// that parses the Sass source (charts.test.ts), which is why this is exported.\nexport const PALETTE_VARS: Array<[string, string]> = [\n [\"--dx-chart-1\", \"#2563eb\"], // blue\n [\"--dx-chart-2\", \"#65a30d\"], // lime\n [\"--dx-chart-3\", \"#7c3aed\"], // violet\n [\"--dx-chart-4\", \"#0d9488\"], // teal\n [\"--dx-chart-5\", \"#ea580c\"], // orange\n [\"--dx-chart-6\", \"#0891b2\"], // cyan\n [\"--dx-chart-7\", \"#d97706\"], // amber\n [\"--dx-chart-8\", \"#db2777\"], // pink\n];\n\n/**\n * The element whose computed style the theme variables are read from.\n *\n * Bootstrap 5.3 allows `data-bs-theme` on ANY container, not just `<html>` — a\n * dark card on a light page is a supported pattern. Reading the variables off\n * `document.documentElement` therefore gives a *nested* scope the wrong palette\n * (#161), so every resolver takes the chart's own container and only falls back\n * to the root when it has none (SSR, a caller outside a component).\n */\nfunction themeScope(scope?: Element | null): Element | null {\n if (typeof document === \"undefined\" || typeof getComputedStyle === \"undefined\") {\n return null;\n }\n if (scope !== undefined && scope !== null) return scope;\n return document.documentElement;\n}\n\n/**\n * Resolve the themed categorical palette.\n *\n * @param scope The chart's container element; its computed style decides which\n * `data-bs-theme` scope applies. Omit (or pass null) to read the document\n * root — the pre-#161 behaviour, kept so the exported signature stays\n * backward compatible.\n */\nexport function getPalette(scope?: Element | null): string[] {\n const host = themeScope(scope);\n if (host === null) {\n return PALETTE_VARS.map(([, fallback]) => fallback);\n }\n const styles = getComputedStyle(host);\n return PALETTE_VARS.map(([name, fallback]) => {\n const value = styles.getPropertyValue(name).trim();\n return value || fallback;\n });\n}\n\n/** Read a single theme colour (e.g. the body text colour) with a fallback. */\nfunction themeColor(name: string, fallback: string, scope?: Element | null): string {\n const host = themeScope(scope);\n if (host === null) {\n return fallback;\n }\n const value = getComputedStyle(host).getPropertyValue(name).trim();\n return value || fallback;\n}\n\n// ---------------------------------------------------------------------------\n// Colour-mode reactivity (#161)\n//\n// The palette lives in CSS variables, which Vue cannot track: a computed that\n// calls getPalette() depends only on the props it also reads, so flipping\n// `data-bs-theme` repaints the page but leaves every MOUNTED chart on the old\n// palette until a prop changes or it remounts. One shared MutationObserver\n// bumps a version ref that the chart computeds read, which re-resolves the\n// variables. `subtree: true` because the attribute can sit on any container,\n// and `attributeFilter` keeps the observer from firing on unrelated mutations.\n// ---------------------------------------------------------------------------\n\nconst colorModeVersion = ref(0);\nlet colorModeObserver: MutationObserver | null = null;\nlet colorModeWatchers = 0;\n\n/**\n * A version ref that increments whenever a `data-bs-theme` attribute changes\n * anywhere in the document. Read it inside a computed that resolves theme\n * variables to make that computed re-run on a colour-mode switch.\n *\n * The observer is started on first use and disconnected when the last consumer's\n * effect scope is disposed, so nothing leaks after the charts unmount. Called\n * outside an effect scope (or without a DOM) it is a no-op returning a static\n * ref — there would be no teardown hook to disconnect the observer.\n */\nexport function useColorModeVersion(): Ref<number> {\n if (\n typeof document === \"undefined\" ||\n typeof MutationObserver === \"undefined\" ||\n getCurrentScope() === undefined\n ) {\n return colorModeVersion;\n }\n\n colorModeWatchers += 1;\n if (colorModeObserver === null) {\n colorModeObserver = new MutationObserver(() => {\n colorModeVersion.value += 1;\n });\n colorModeObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"data-bs-theme\"],\n subtree: true,\n });\n }\n\n onScopeDispose(() => {\n colorModeWatchers -= 1;\n if (colorModeWatchers === 0 && colorModeObserver !== null) {\n colorModeObserver.disconnect();\n colorModeObserver = null;\n }\n });\n\n return colorModeVersion;\n}\n\n/** Add an alpha channel to a hex or rgb() colour (best-effort). */\nexport function withAlpha(color: string, alpha: number): string {\n const hex = color.replace(/^#/, \"\");\n if (/^[0-9a-f]{6}$/i.test(hex)) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n }\n const rgbMatch = color.match(/^rgba?\\(([^)]+)\\)$/);\n if (rgbMatch) {\n const [r, g, b] = rgbMatch[1].split(\",\").map((n) => n.trim());\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n }\n return color;\n}\n\n/** Format a numeric value per the chart's value format (for tick/tooltips). */\nexport function formatValue(\n value: number,\n format: ChartValueFormat | undefined,\n currencySymbol: string,\n locale?: string,\n): string {\n const num = new Intl.NumberFormat(locale, {\n maximumFractionDigits: 2,\n }).format(value);\n if (format === \"currency\") return `${currencySymbol}${num}`;\n if (format === \"percent\") return `${num}%`;\n return num;\n}\n\nexport interface BaseOptionArgs {\n valueFormat?: ChartValueFormat;\n currencySymbol?: string;\n locale?: string;\n /** Show the legend (default: false for a single dataset, true for many). */\n showLegend?: boolean;\n /** Whether the chart has value axes (bar/line) vs none (doughnut). */\n hasValueAxis?: boolean;\n /** The chart's container element — decides which `data-bs-theme` scope the\n * grid/tick colours resolve against (#161). Defaults to the document root. */\n scope?: Element | null;\n}\n\n/** Dashboard default Chart.js options merged under any consumer `options`. */\nexport function baseOptions(args: BaseOptionArgs): Record<string, any> {\n const {\n valueFormat,\n currencySymbol = \"£\",\n locale,\n showLegend = false,\n hasValueAxis = true,\n scope,\n } = args;\n\n const gridColor = withAlpha(\n themeColor(\"--bs-border-color\", \"#dee2e6\", scope),\n 0.6,\n );\n const tickColor = themeColor(\"--bs-secondary-color\", \"#6c757d\", scope);\n\n const options: Record<string, any> = {\n responsive: true,\n maintainAspectRatio: false,\n plugins: {\n legend: { display: showLegend, labels: { color: tickColor } },\n tooltip: {\n callbacks: {\n label: (ctx: any) => {\n const raw = ctx.parsed?.y ?? ctx.parsed ?? ctx.raw;\n const value = typeof raw === \"number\" ? raw : Number(raw);\n const formatted = Number.isFinite(value)\n ? formatValue(value, valueFormat, currencySymbol, locale)\n : String(raw);\n const label = ctx.dataset?.label ?? ctx.label ?? \"\";\n return label ? `${label}: ${formatted}` : formatted;\n },\n },\n },\n },\n };\n\n if (hasValueAxis) {\n options.scales = {\n x: {\n grid: { display: false },\n border: { color: gridColor },\n ticks: { color: tickColor },\n },\n y: {\n beginAtZero: true,\n grid: { color: gridColor, drawBorder: false },\n border: { display: false },\n ticks: {\n color: tickColor,\n callback: (value: number | string) =>\n formatValue(Number(value), valueFormat, currencySymbol, locale),\n },\n },\n };\n }\n\n return options;\n}\n\n/**\n * Apply the themed palette to any dataset that doesn't set its own colours.\n * Bar: one colour per dataset (or per bar for a single dataset). Line: a themed\n * stroke + translucent fill. Doughnut/pie: one colour per slice.\n *\n * `scope` is the chart's container element; the palette is resolved from its\n * computed style so a nested `data-bs-theme` container themes correctly (#161).\n * Omit it to resolve against the document root.\n */\nexport function applyPalette(\n datasets: any[],\n kind: \"bar\" | \"line\" | \"doughnut\",\n labelsCount: number,\n scope?: Element | null,\n): any[] {\n const palette = getPalette(scope);\n const single = datasets.length === 1;\n\n return datasets.map((dataset, index) => {\n const next = { ...dataset };\n const color = palette[index % palette.length];\n\n if (kind === \"doughnut\") {\n if (next.backgroundColor === undefined) {\n next.backgroundColor = Array.from(\n { length: labelsCount },\n (_, i) => palette[i % palette.length],\n );\n }\n return next;\n }\n\n if (kind === \"line\") {\n if (next.borderColor === undefined) next.borderColor = color;\n if (next.backgroundColor === undefined) {\n next.backgroundColor = withAlpha(color, 0.15);\n }\n if (next.tension === undefined) next.tension = 0.3;\n if (next.fill === undefined) next.fill = true;\n if (next.pointRadius === undefined) next.pointRadius = 2;\n return next;\n }\n\n // bar\n if (next.backgroundColor === undefined) {\n next.backgroundColor =\n single && labelsCount > 1\n ? Array.from({ length: labelsCount }, () => color)\n : color;\n }\n if (next.borderRadius === undefined) next.borderRadius = 4;\n return next;\n });\n}\n","import { computed, type ComputedRef, type Ref } from \"vue\";\nimport type { ChartData, ChartDataset, ChartOptions } from \"chart.js\";\nimport {\n baseOptions,\n applyPalette,\n mergeOptions,\n useColorModeVersion,\n type ChartValueFormat,\n} from \"./chartTheme\";\n\n/**\n * Shared props for the value-axis chart wrappers (`DXBarChart`, `DXLineChart`).\n * `DXBarChart` and `DXLineChart` differ ONLY in the chart.js component they\n * render and the palette kind — everything else (theming, option-merge,\n * legend-default) is identical, and lived duplicated in both SFCs (#135).\n */\nexport interface ThemedChartProps<TType extends \"bar\" | \"line\"> {\n /** X-axis category labels. */\n labels: string[];\n /** Chart.js datasets. Colours are themed when a dataset omits them. */\n datasets: ChartDataset<TType>[];\n /** Chart.js options; deep-merged over the themed defaults. */\n options?: ChartOptions<TType>;\n /** Format value-axis ticks and tooltips. */\n valueFormat?: ChartValueFormat;\n /** Currency symbol for valueFormat: \"currency\" (default \"£\"). */\n currencySymbol?: string;\n /** Locale for number formatting. */\n locale?: string;\n /** Show the legend (default: only when there is more than one dataset). */\n showLegend?: boolean;\n}\n\n/**\n * The themed-chart body shared by `DXBarChart` and `DXLineChart`: applies the\n * data-viz palette to un-coloured datasets and deep-merges the consumer's\n * `options` over the dashboard-friendly defaults. Pass the reactive `props`\n * object (property access stays reactive inside the computeds).\n *\n * `host` is the chart's own container element (a template ref). It is BOTH the\n * `data-bs-theme` scope the palette resolves against and — being a ref read\n * inside the computeds — the trigger that re-themes once it is populated on\n * mount, since the first render happens before a template ref exists (#161).\n */\nexport function useThemedChart<TType extends \"bar\" | \"line\">(\n type: TType,\n props: ThemedChartProps<TType>,\n host: Ref<HTMLElement | null>,\n): {\n chartData: ComputedRef<ChartData<TType>>;\n mergedOptions: ComputedRef<ChartOptions<TType>>;\n} {\n // Bumped by a MutationObserver on every `data-bs-theme` change; read below\n // so the CSS-variable palette — invisible to Vue's reactivity — is\n // re-resolved when the colour mode flips under a mounted chart.\n const colorModeVersion = useColorModeVersion();\n\n const chartData = computed(() => {\n void colorModeVersion.value;\n return {\n labels: props.labels,\n datasets: applyPalette(\n props.datasets,\n type,\n props.labels.length,\n host.value,\n ),\n } as ChartData<TType>;\n });\n\n const mergedOptions = computed(() => {\n void colorModeVersion.value;\n return mergeOptions(\n baseOptions({\n valueFormat: props.valueFormat,\n currencySymbol: props.currencySymbol,\n locale: props.locale,\n showLegend: props.showLegend ?? props.datasets.length > 1,\n hasValueAxis: true,\n scope: host.value,\n }),\n props.options ?? {},\n ) as ChartOptions<TType>;\n });\n\n return { chartData, mergedOptions };\n}\n","<!--\n @component\n A themed bar chart. Thin wrapper around vue-chartjs (chart.js) with the\n theme's dedicated chart palette (--dx-chart-1..8) applied and dashboard-friendly defaults (no x gridlines,\n formatted value ticks, responsive, legend hidden for a single series). Pass\n `labels` + `datasets`; `options` deep-merges over the defaults.\n\n Requires the optional peer deps `chart.js` and `vue-chartjs`.\n-->\n<template>\n <div ref=\"host\" class=\"dx-chart\">\n <Bar :data=\"chartData\" :options=\"mergedOptions\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nimport { Bar } from \"vue-chartjs\";\nimport { registerCharts } from \"./chartTheme\";\nimport { useThemedChart, type ThemedChartProps } from \"./useThemedChart\";\n\nregisterCharts();\n\n// `showLegend` defaults to `undefined` (not Vue's Boolean-cast `false`) so the\n// `?? datasets.length > 1` default can actually fire when it isn't passed.\nconst props = withDefaults(defineProps<ThemedChartProps<\"bar\">>(), {\n currencySymbol: \"£\",\n showLegend: undefined,\n});\n\n// The container is the `data-bs-theme` scope the palette resolves against, so a\n// chart inside a dark card on a light page themes from the card (#161).\nconst host = ref<HTMLElement | null>(null);\n\nconst { chartData, mergedOptions } = useThemedChart(\"bar\", props, host);\n</script>\n","<!--\n @component\n A themed line chart. Thin wrapper around vue-chartjs (chart.js) with the\n theme's dedicated chart palette applied (--dx-chart-1..8 stroke + translucent fill, smoothed line)\n and dashboard-friendly defaults. Pass `labels` + `datasets`; `options`\n deep-merges over the defaults.\n\n Requires the optional peer deps `chart.js` and `vue-chartjs`.\n-->\n<template>\n <div ref=\"host\" class=\"dx-chart\">\n <Line :data=\"chartData\" :options=\"mergedOptions\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nimport { Line } from \"vue-chartjs\";\nimport { registerCharts } from \"./chartTheme\";\nimport { useThemedChart, type ThemedChartProps } from \"./useThemedChart\";\n\nregisterCharts();\n\n// `showLegend` defaults to `undefined` (not Vue's Boolean-cast `false`) so the\n// `?? datasets.length > 1` default can actually fire when it isn't passed.\nconst props = withDefaults(defineProps<ThemedChartProps<\"line\">>(), {\n currencySymbol: \"£\",\n showLegend: undefined,\n});\n\n// The container is the `data-bs-theme` scope the palette resolves against, so a\n// chart inside a dark card on a light page themes from the card (#161).\nconst host = ref<HTMLElement | null>(null);\n\nconst { chartData, mergedOptions } = useThemedChart(\"line\", props, host);\n</script>\n","<!--\n @component\n A themed doughnut chart. Thin wrapper around vue-chartjs (chart.js) with one\n chart-palette colour (--dx-chart-1..8) per slice and dashboard-friendly defaults. Pass\n `labels` + either `data` (a number array) or full `datasets`; `options`\n deep-merges over the defaults.\n\n Requires the optional peer deps `chart.js` and `vue-chartjs`.\n-->\n<template>\n <div ref=\"host\" class=\"dx-chart\">\n <Doughnut :data=\"chartData\" :options=\"mergedOptions\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport { Doughnut } from \"vue-chartjs\";\nimport {\n registerCharts,\n baseOptions,\n applyPalette,\n mergeOptions,\n useColorModeVersion,\n type ChartValueFormat,\n} from \"./chartTheme\";\n\nregisterCharts();\n\ninterface Props {\n /** Slice labels. */\n labels: string[];\n /** Convenience: a single number array (one value per label). */\n data?: number[];\n /** Full Chart.js datasets (alternative to `data`). */\n datasets?: any[];\n /** Chart.js options; deep-merged over the themed defaults. */\n options?: Record<string, any>;\n /** Format tooltip values. */\n valueFormat?: ChartValueFormat;\n /** Currency symbol for valueFormat: \"currency\" (default \"£\"). */\n currencySymbol?: string;\n /** Locale for number formatting. */\n locale?: string;\n /** Show the legend (default: true — slices need identifying). */\n showLegend?: boolean;\n}\n\n// `showLegend` defaults to `undefined` (not Vue's Boolean-cast `false`) so the\n// `?? true` default can actually fire when it isn't passed.\nconst props = withDefaults(defineProps<Props>(), {\n currencySymbol: \"£\",\n showLegend: undefined,\n});\n\n// The container is the `data-bs-theme` scope the palette resolves against, so a\n// chart inside a dark card on a light page themes from the card. Reading the ref\n// inside the computeds also re-themes on mount, when the first (pre-ref) render\n// had to fall back to the document root (#161). DXDoughnutChart doesn't share\n// `useThemedChart` (its data shape differs), so the wiring is repeated here.\nconst host = ref<HTMLElement | null>(null);\n\n// Bumped by a MutationObserver on every `data-bs-theme` change; read below so\n// the CSS-variable palette — invisible to Vue's reactivity — is re-resolved\n// when the colour mode flips under a mounted chart.\nconst colorModeVersion = useColorModeVersion();\n\nconst resolvedDatasets = computed(() =>\n props.datasets ?? [{ data: props.data ?? [] }],\n);\n\nconst chartData = computed(() => {\n void colorModeVersion.value;\n return {\n labels: props.labels,\n datasets: applyPalette(\n resolvedDatasets.value,\n \"doughnut\",\n props.labels.length,\n host.value,\n ),\n };\n});\n\nconst mergedOptions = computed(() => {\n void colorModeVersion.value;\n return mergeOptions(\n baseOptions({\n valueFormat: props.valueFormat,\n currencySymbol: props.currencySymbol,\n locale: props.locale,\n showLegend: props.showLegend ?? true,\n hasValueAxis: false,\n scope: host.value,\n }),\n props.options ?? {},\n );\n});\n</script>\n"],"names":["isPlainObject","value","mergeOptions","base","override","result","key","registered","registerCharts","Chart","registerables","PALETTE_VARS","themeScope","scope","getPalette","host","fallback","styles","name","themeColor","colorModeVersion","ref","colorModeObserver","colorModeWatchers","useColorModeVersion","getCurrentScope","onScopeDispose","withAlpha","color","alpha","hex","r","g","b","rgbMatch","n","formatValue","format","currencySymbol","locale","num","baseOptions","args","valueFormat","showLegend","hasValueAxis","gridColor","tickColor","options","ctx","raw","_a","formatted","label","_b","applyPalette","datasets","kind","labelsCount","palette","single","dataset","index","next","_","i","useThemedChart","type","props","chartData","computed","mergedOptions","__props","_createElementBlock","_createVNode","_unref","Bar","Line","resolvedDatasets","Doughnut"],"mappings":";;;AAWA,MAAMA,IAAgB,CAACC,MACnB,CAAC,CAACA,KAAS,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK;AAGzD,SAASC,EACZC,GACAC,GACmB;AACnB,QAAMC,IAA8B,EAAE,GAAGF,EAAA;AACzC,aAAW,CAACG,GAAKL,CAAK,KAAK,OAAO,QAAQG,CAAQ;AAC9C,IAAIJ,EAAcC,CAAK,KAAKD,EAAcK,EAAOC,CAAG,CAAC,IACjDD,EAAOC,CAAG,IAAIJ,E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IAAQI,GAURzD,IAAOM,EAAwB,IAAI,GAKnCD,IAAmBI,EAAA,GAEnBsD,IAAmBR;AAAA,MAAS,MAChCF,EAAM,YAAY,CAAC,EAAE,MAAMA,EAAM,QAAQ,GAAC,CAAG;AAAA,IAAA,GAGzCC,IAAYC,EAAS,OACpBlD,EAAiB,OACf;AAAA,MACL,QAAQgD,EAAM;AAAA,MACd,UAAUb;AAAA,QACRuB,EAAiB;AAAA,QACjB;AAAA,QACAV,EAAM,OAAO;AAAA,QACbrD,EAAK;AAAA,MAAA;AAAA,IACP,EAEH,GAEKwD,IAAgBD,EAAS,OACxBlD,EAAiB,OACflB;AAAA,MACLuC,EAAY;AAAA,QACV,aAAa2B,EAAM;AAAA,QACnB,gBAAgBA,EAAM;AAAA,QACtB,QAAQA,EAAM;AAAA,QACd,YAAYA,EAAM,cAAc;AAAA,QAChC,cAAc;AAAA,QACd,OAAOrD,EAAK;AAAA,MAAA,CACb;AAAA,MACDqD,EAAM,WAAW,CAAA;AAAA,IAAC,EAErB;2BAvFCK,EAEM,OAAA;AAAA,eAFG;AAAA,MAAJ,KAAI1D;AAAA,MAAO,OAAM;AAAA,IAAA;MACpB2D,EAAuDC,EAAAI,CAAA,GAAA;AAAA,QAA5C,MAAMV,EAAA;AAAA,QAAY,SAASE,EAAA;AAAA,MAAA;;;;"}
@@ -1,2 +1,2 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("vue-chartjs"),require("chart.js")):typeof define=="function"&&define.amd?define(["exports","vue","vue-chartjs","chart.js"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.DashboardForLaravelCharts={},c.Vue,c.VueChartjs,c.Chart))})(this,(function(c,o,m,b){"use strict";const g=r=>!!r&&typeof r=="object"&&!Array.isArray(r);function p(r,e){const t={...r};for(const[n,s]of Object.entries(e))g(s)&&g(t[n])?t[n]=p(t[n],s):t[n]=s;return t}let y=!1;function h(){y||(b.Chart.register(...b.registerables),y=!0)}const C=[["--dx-chart-1","#2563eb"],["--dx-chart-2","#65a30d"],["--dx-chart-3","#7c3aed"],["--dx-chart-4","#0d9488"],["--dx-chart-5","#ea580c"],["--dx-chart-6","#0891b2"],["--dx-chart-7","#d97706"],["--dx-chart-8","#db2777"]];function F(){if(typeof document>"u"||typeof getComputedStyle>"u")return C.map(([,e])=>e);const r=getComputedStyle(document.documentElement);return C.map(([e,t])=>r.getPropertyValue(e).trim()||t)}function _(r,e){return typeof document>"u"||typeof getComputedStyle>"u"?e:getComputedStyle(document.documentElement).getPropertyValue(r).trim()||e}function $(r,e){const t=r.replace(/^#/,"");if(/^[0-9a-f]{6}$/i.test(t)){const s=parseInt(t.slice(0,2),16),l=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);return`rgba(${s}, ${l}, ${i}, ${e})`}const n=r.match(/^rgba?\(([^)]+)\)$/);if(n){const[s,l,i]=n[1].split(",").map(a=>a.trim());return`rgba(${s}, ${l}, ${i}, ${e})`}return r}function x(r,e,t,n){const s=new Intl.NumberFormat(n,{maximumFractionDigits:2}).format(r);return e==="currency"?`${t}${s}`:e==="percent"?`${s}%`:s}function k(r){const{valueFormat:e,currencySymbol:t="£",locale:n,showLegend:s=!1,hasValueAxis:l=!0}=r,i=$(_("--bs-border-color","#dee2e6"),.6),a=_("--bs-secondary-color","#6c757d"),u={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:s,labels:{color:a}},tooltip:{callbacks:{label:d=>{var v,A;const f=((v=d.parsed)==null?void 0:v.y)??d.parsed??d.raw,w=typeof f=="number"?f:Number(f),B=Number.isFinite(w)?x(w,e,t,n):String(f),L=((A=d.dataset)==null?void 0:A.label)??d.label??"";return L?`${L}: ${B}`:B}}}}};return l&&(u.scales={x:{grid:{display:!1},border:{color:i},ticks:{color:a}},y:{beginAtZero:!0,grid:{color:i,drawBorder:!1},border:{display:!1},ticks:{color:a,callback:d=>x(Number(d),e,t,n)}}}),u}function D(r,e,t){const n=F(),s=r.length===1;return r.map((l,i)=>{const a={...l},u=n[i%n.length];return e==="doughnut"?(a.backgroundColor===void 0&&(a.backgroundColor=Array.from({length:t},(d,f)=>n[f%n.length])),a):e==="line"?(a.borderColor===void 0&&(a.borderColor=u),a.backgroundColor===void 0&&(a.backgroundColor=$(u,.15)),a.tension===void 0&&(a.tension=.3),a.fill===void 0&&(a.fill=!0),a.pointRadius===void 0&&(a.pointRadius=2),a):(a.backgroundColor===void 0&&(a.backgroundColor=s&&t>1?Array.from({length:t},()=>u):u),a.borderRadius===void 0&&(a.borderRadius=4),a)})}function S(r,e){const t=o.computed(()=>({labels:e.labels,datasets:D(e.datasets,r,e.labels.length)})),n=o.computed(()=>p(k({valueFormat:e.valueFormat,currencySymbol:e.currencySymbol,locale:e.locale,showLegend:e.showLegend??e.datasets.length>1,hasValueAxis:!0}),e.options??{}));return{chartData:t,mergedOptions:n}}const V={class:"dx-chart"},O=o.defineComponent({__name:"DXBarChart",props:{labels:{},datasets:{},options:{},valueFormat:{},currencySymbol:{default:"£"},locale:{},showLegend:{type:Boolean,default:void 0}},setup(r){h();const e=r,{chartData:t,mergedOptions:n}=S("bar",e);return(s,l)=>(o.openBlock(),o.createElementBlock("div",V,[o.createVNode(o.unref(m.Bar),{data:o.unref(t),options:o.unref(n)},null,8,["data","options"])]))}}),j={class:"dx-chart"},E=o.defineComponent({__name:"DXLineChart",props:{labels:{},datasets:{},options:{},valueFormat:{},currencySymbol:{default:"£"},locale:{},showLegend:{type:Boolean,default:void 0}},setup(r){h();const e=r,{chartData:t,mergedOptions:n}=S("line",e);return(s,l)=>(o.openBlock(),o.createElementBlock("div",j,[o.createVNode(o.unref(m.Line),{data:o.unref(t),options:o.unref(n)},null,8,["data","options"])]))}}),N={class:"dx-chart"},P=o.defineComponent({__name:"DXDoughnutChart",props:{labels:{},data:{},datasets:{},options:{},valueFormat:{},currencySymbol:{default:"£"},locale:{},showLegend:{type:Boolean,default:void 0}},setup(r){h();const e=r,t=o.computed(()=>e.datasets??[{data:e.data??[]}]),n=o.computed(()=>({labels:e.labels,datasets:D(t.value,"doughnut",e.labels.length)})),s=o.computed(()=>p(k({valueFormat:e.valueFormat,currencySymbol:e.currencySymbol,locale:e.locale,showLegend:e.showLegend??!0,hasValueAxis:!1}),e.options??{}));return(l,i)=>(o.openBlock(),o.createElementBlock("div",N,[o.createVNode(o.unref(m.Doughnut),{data:n.value,options:s.value},null,8,["data","options"])]))}});c.DXBarChart=O,c.DXDoughnutChart=P,c.DXLineChart=E,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("vue-chartjs"),require("chart.js")):typeof define=="function"&&define.amd?define(["exports","vue","vue-chartjs","chart.js"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i.DashboardForLaravelCharts={},i.Vue,i.VueChartjs,i.Chart))})(this,(function(i,o,h,v){"use strict";const _=r=>!!r&&typeof r=="object"&&!Array.isArray(r);function b(r,e){const t={...r};for(const[n,a]of Object.entries(e))_(a)&&_(t[n])?t[n]=b(t[n],a):t[n]=a;return t}let k=!1;function g(){k||(v.Chart.register(...v.registerables),k=!0)}const S=[["--dx-chart-1","#2563eb"],["--dx-chart-2","#65a30d"],["--dx-chart-3","#7c3aed"],["--dx-chart-4","#0d9488"],["--dx-chart-5","#ea580c"],["--dx-chart-6","#0891b2"],["--dx-chart-7","#d97706"],["--dx-chart-8","#db2777"]];function x(r){return typeof document>"u"||typeof getComputedStyle>"u"?null:r??document.documentElement}function N(r){const e=x(r);if(e===null)return S.map(([,n])=>n);const t=getComputedStyle(e);return S.map(([n,a])=>t.getPropertyValue(n).trim()||a)}function D(r,e,t){const n=x(t);return n===null?e:getComputedStyle(n).getPropertyValue(r).trim()||e}const y=o.ref(0);let m=null,C=0;function $(){return typeof document>"u"||typeof MutationObserver>"u"||o.getCurrentScope()===void 0||(C+=1,m===null&&(m=new MutationObserver(()=>{y.value+=1}),m.observe(document.documentElement,{attributes:!0,attributeFilter:["data-bs-theme"],subtree:!0})),o.onScopeDispose(()=>{C-=1,C===0&&m!==null&&(m.disconnect(),m=null)})),y}function V(r,e){const t=r.replace(/^#/,"");if(/^[0-9a-f]{6}$/i.test(t)){const a=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),c=parseInt(t.slice(4,6),16);return`rgba(${a}, ${s}, ${c}, ${e})`}const n=r.match(/^rgba?\(([^)]+)\)$/);if(n){const[a,s,c]=n[1].split(",").map(d=>d.trim());return`rgba(${a}, ${s}, ${c}, ${e})`}return r}function w(r,e,t,n){const a=new Intl.NumberFormat(n,{maximumFractionDigits:2}).format(r);return e==="currency"?`${t}${a}`:e==="percent"?`${a}%`:a}function B(r){const{valueFormat:e,currencySymbol:t="£",locale:n,showLegend:a=!1,hasValueAxis:s=!0,scope:c}=r,d=V(D("--bs-border-color","#dee2e6",c),.6),l=D("--bs-secondary-color","#6c757d",c),f={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:a,labels:{color:l}},tooltip:{callbacks:{label:u=>{var j,E;const p=((j=u.parsed)==null?void 0:j.y)??u.parsed??u.raw,A=typeof p=="number"?p:Number(p),O=Number.isFinite(A)?w(A,e,t,n):String(p),M=((E=u.dataset)==null?void 0:E.label)??u.label??"";return M?`${M}: ${O}`:O}}}}};return s&&(f.scales={x:{grid:{display:!1},border:{color:d},ticks:{color:l}},y:{beginAtZero:!0,grid:{color:d,drawBorder:!1},border:{display:!1},ticks:{color:l,callback:u=>w(Number(u),e,t,n)}}}),f}function F(r,e,t,n){const a=N(n),s=r.length===1;return r.map((c,d)=>{const l={...c},f=a[d%a.length];return e==="doughnut"?(l.backgroundColor===void 0&&(l.backgroundColor=Array.from({length:t},(u,p)=>a[p%a.length])),l):e==="line"?(l.borderColor===void 0&&(l.borderColor=f),l.backgroundColor===void 0&&(l.backgroundColor=V(f,.15)),l.tension===void 0&&(l.tension=.3),l.fill===void 0&&(l.fill=!0),l.pointRadius===void 0&&(l.pointRadius=2),l):(l.backgroundColor===void 0&&(l.backgroundColor=s&&t>1?Array.from({length:t},()=>f):f),l.borderRadius===void 0&&(l.borderRadius=4),l)})}function L(r,e,t){const n=$(),a=o.computed(()=>(n.value,{labels:e.labels,datasets:F(e.datasets,r,e.labels.length,t.value)})),s=o.computed(()=>(n.value,b(B({valueFormat:e.valueFormat,currencySymbol:e.currencySymbol,locale:e.locale,showLegend:e.showLegend??e.datasets.length>1,hasValueAxis:!0,scope:t.value}),e.options??{})));return{chartData:a,mergedOptions:s}}const P=o.defineComponent({__name:"DXBarChart",props:{labels:{},datasets:{},options:{},valueFormat:{},currencySymbol:{default:"£"},locale:{},showLegend:{type:Boolean,default:void 0}},setup(r){g();const e=r,t=o.ref(null),{chartData:n,mergedOptions:a}=L("bar",e,t);return(s,c)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"host",ref:t,class:"dx-chart"},[o.createVNode(o.unref(h.Bar),{data:o.unref(n),options:o.unref(a)},null,8,["data","options"])],512))}}),R=o.defineComponent({__name:"DXLineChart",props:{labels:{},datasets:{},options:{},valueFormat:{},currencySymbol:{default:"£"},locale:{},showLegend:{type:Boolean,default:void 0}},setup(r){g();const e=r,t=o.ref(null),{chartData:n,mergedOptions:a}=L("line",e,t);return(s,c)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"host",ref:t,class:"dx-chart"},[o.createVNode(o.unref(h.Line),{data:o.unref(n),options:o.unref(a)},null,8,["data","options"])],512))}}),T=o.defineComponent({__name:"DXDoughnutChart",props:{labels:{},data:{},datasets:{},options:{},valueFormat:{},currencySymbol:{default:"£"},locale:{},showLegend:{type:Boolean,default:void 0}},setup(r){g();const e=r,t=o.ref(null),n=$(),a=o.computed(()=>e.datasets??[{data:e.data??[]}]),s=o.computed(()=>(n.value,{labels:e.labels,datasets:F(a.value,"doughnut",e.labels.length,t.value)})),c=o.computed(()=>(n.value,b(B({valueFormat:e.valueFormat,currencySymbol:e.currencySymbol,locale:e.locale,showLegend:e.showLegend??!0,hasValueAxis:!1,scope:t.value}),e.options??{})));return(d,l)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"host",ref:t,class:"dx-chart"},[o.createVNode(o.unref(h.Doughnut),{data:s.value,options:c.value},null,8,["data","options"])],512))}});i.DXBarChart=P,i.DXDoughnutChart=T,i.DXLineChart=R,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=charts.umd.cjs.map