@carto/ps-react-ui 4.11.0 → 4.11.1

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.
Files changed (53) hide show
  1. package/dist/{change-column-BiuuHCDN.js → change-column-DjjwoPt1.js} +256 -269
  2. package/dist/change-column-DjjwoPt1.js.map +1 -0
  3. package/dist/{data-zoom-layout--YiY6ko_.js → data-zoom-layout-CkVnm6ej.js} +4 -5
  4. package/dist/{data-zoom-layout--YiY6ko_.js.map → data-zoom-layout-CkVnm6ej.js.map} +1 -1
  5. package/dist/{png-item-CS4z1iSH.js → png-item-BE9uEqlD.js} +2 -2
  6. package/dist/png-item-BE9uEqlD.js.map +1 -0
  7. package/dist/{spread-CPis22AE.js → spread-DYNpzgh_.js} +9 -11
  8. package/dist/{spread-CPis22AE.js.map → spread-DYNpzgh_.js.map} +1 -1
  9. package/dist/{table-CQCAnDLb.js → table-C9IMbTr0.js} +50 -53
  10. package/dist/table-C9IMbTr0.js.map +1 -0
  11. package/dist/widgets-v2/actions.js +2 -2
  12. package/dist/widgets-v2/bar.js +8 -10
  13. package/dist/widgets-v2/bar.js.map +1 -1
  14. package/dist/widgets-v2/category.js +27 -29
  15. package/dist/widgets-v2/category.js.map +1 -1
  16. package/dist/widgets-v2/formula.js +24 -25
  17. package/dist/widgets-v2/formula.js.map +1 -1
  18. package/dist/widgets-v2/histogram.js +10 -13
  19. package/dist/widgets-v2/histogram.js.map +1 -1
  20. package/dist/widgets-v2/markdown.js +25 -27
  21. package/dist/widgets-v2/markdown.js.map +1 -1
  22. package/dist/widgets-v2/pie.js +7 -10
  23. package/dist/widgets-v2/pie.js.map +1 -1
  24. package/dist/widgets-v2/scatterplot.js +9 -12
  25. package/dist/widgets-v2/scatterplot.js.map +1 -1
  26. package/dist/widgets-v2/spread.js +14 -16
  27. package/dist/widgets-v2/spread.js.map +1 -1
  28. package/dist/widgets-v2/table.js +38 -40
  29. package/dist/widgets-v2/table.js.map +1 -1
  30. package/dist/widgets-v2/timeseries.js +8 -11
  31. package/dist/widgets-v2/timeseries.js.map +1 -1
  32. package/dist/widgets-v2/utils.js +1 -1
  33. package/dist/widgets-v2.js +42 -45
  34. package/dist/widgets-v2.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/widgets-v2/actions/brush-toggle/brush-toggle.tsx +1 -1
  37. package/src/widgets-v2/actions/change-column/sortable-column-item.tsx +1 -1
  38. package/src/widgets-v2/actions/download/download.tsx +1 -1
  39. package/src/widgets-v2/actions/download/icons.tsx +1 -1
  40. package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +3 -3
  41. package/src/widgets-v2/actions/lock-selection/lock-selection.tsx +2 -2
  42. package/src/widgets-v2/actions/relative-data/relative-data.tsx +1 -1
  43. package/src/widgets-v2/actions/searcher/searcher-toggle.tsx +1 -1
  44. package/src/widgets-v2/actions/searcher/searcher.tsx +2 -2
  45. package/src/widgets-v2/actions/show-all/show-all.tsx +1 -1
  46. package/src/widgets-v2/actions/stack-toggle/stack-toggle.tsx +1 -1
  47. package/src/widgets-v2/actions/zoom-toggle/zoom-toggle.tsx +1 -1
  48. package/src/widgets-v2/table/table-ui.tsx +4 -4
  49. package/src/widgets-v2/toolbox/toolbox.tsx +1 -1
  50. package/src/widgets-v2/wrapper/widget-wrapper.tsx +1 -1
  51. package/dist/change-column-BiuuHCDN.js.map +0 -1
  52. package/dist/png-item-CS4z1iSH.js.map +0 -1
  53. package/dist/table-CQCAnDLb.js.map +0 -1
@@ -1,17 +1,15 @@
1
- import { C as A, a as N, b as z, c as V, d as G, e as L, f as M } from "../category-Dnd2_j0x.js";
1
+ import { C as $, a as j, b as A, c as N, d as z, e as V, f as G } from "../category-Dnd2_j0x.js";
2
2
  import { jsx as m, jsxs as d } from "react/jsx-runtime";
3
3
  import { c as h } from "react/compiler-runtime";
4
4
  import { Box as p, Skeleton as f } from "@mui/material";
5
5
  import "react";
6
- import "@mui/icons-material/FileDownload";
6
+ import "@mui/icons-material";
7
7
  import "../lasso-tool-CDFj4zKY.js";
8
8
  import "../cjs-D4KH3azB.js";
9
- import "@mui/icons-material";
10
9
  import "@carto/ps-utils";
11
10
  import { a as w } from "../exports-Cx-f6m6U.js";
12
- import "@mui/icons-material/ImageOutlined";
13
- import { b as C } from "../png-item-CS4z1iSH.js";
14
- const s = {
11
+ import { b as C } from "../png-item-BE9uEqlD.js";
12
+ const i = {
15
13
  root: {
16
14
  display: "flex",
17
15
  flexDirection: "column",
@@ -44,28 +42,28 @@ const s = {
44
42
  small: 4,
45
43
  medium: 12
46
44
  }, g = ["95%", "80%", "55%", "75%", "60%"];
47
- function P(o) {
45
+ function T(o) {
48
46
  const e = h(5), {
49
47
  rows: l,
50
- size: n
51
- } = o, r = l === void 0 ? 5 : l, a = n === void 0 ? "small" : n;
48
+ size: s
49
+ } = o, r = l === void 0 ? 5 : l, a = s === void 0 ? "small" : s;
52
50
  let t;
53
51
  e[0] !== r ? (t = Array.from({
54
52
  length: r
55
53
  }), e[0] = r, e[1] = t) : t = e[1];
56
- let i;
57
- return e[2] !== a || e[3] !== t ? (i = /* @__PURE__ */ m(p, { sx: s.root, children: t.map((c, u) => /* @__PURE__ */ d(p, { sx: s.row, children: [
58
- /* @__PURE__ */ d(p, { sx: s.rowHeader, children: [
59
- /* @__PURE__ */ m(f, { variant: "rectangular", sx: s.name }),
60
- /* @__PURE__ */ m(f, { variant: "rectangular", sx: s.value })
54
+ let n;
55
+ return e[2] !== a || e[3] !== t ? (n = /* @__PURE__ */ m(p, { sx: i.root, children: t.map((c, u) => /* @__PURE__ */ d(p, { sx: i.row, children: [
56
+ /* @__PURE__ */ d(p, { sx: i.rowHeader, children: [
57
+ /* @__PURE__ */ m(f, { variant: "rectangular", sx: i.name }),
58
+ /* @__PURE__ */ m(f, { variant: "rectangular", sx: i.value })
61
59
  ] }),
62
60
  /* @__PURE__ */ m(f, { variant: "rectangular", sx: {
63
61
  height: x[a],
64
62
  width: g[u % g.length]
65
63
  } })
66
- ] }, `row-${u}`)) }), e[2] = a, e[3] = t, e[4] = i) : i = e[4], i;
64
+ ] }, `row-${u}`)) }), e[2] = a, e[3] = t, e[4] = n) : n = e[4], n;
67
65
  }
68
- function _(o) {
66
+ function B(o) {
69
67
  const e = [];
70
68
  return o.getCaptureEl && e.push(C({
71
69
  filename: o.filename,
@@ -76,13 +74,13 @@ function _(o) {
76
74
  id: "csv",
77
75
  label: "Download as CSV",
78
76
  resolve: () => {
79
- const l = o.getData(), n = [["series", "name", "value"]];
77
+ const l = o.getData(), s = [["series", "name", "value"]];
80
78
  for (const [a, t] of l.entries()) {
81
- const i = o.seriesNames?.[a] ?? `series_${a + 1}`;
79
+ const n = o.seriesNames?.[a] ?? `series_${a + 1}`;
82
80
  for (const c of t)
83
- n.push([i, c.name, c.value]);
81
+ s.push([n, c.name, c.value]);
84
82
  }
85
- const r = w(n);
83
+ const r = w(s);
86
84
  return Promise.resolve({
87
85
  url: r.url,
88
86
  filename: `${o.filename}.csv`,
@@ -92,14 +90,14 @@ function _(o) {
92
90
  }), e;
93
91
  }
94
92
  export {
95
- A as Category,
96
- N as CategoryBar,
97
- z as CategoryLegend,
98
- V as CategoryRowMulti,
99
- G as CategoryRowOther,
100
- L as CategoryRowSingle,
101
- P as CategorySkeleton,
102
- M as CategoryUI,
103
- _ as createCategoryDownloadConfig
93
+ $ as Category,
94
+ j as CategoryBar,
95
+ A as CategoryLegend,
96
+ N as CategoryRowMulti,
97
+ z as CategoryRowOther,
98
+ V as CategoryRowSingle,
99
+ T as CategorySkeleton,
100
+ G as CategoryUI,
101
+ B as createCategoryDownloadConfig
104
102
  };
105
103
  //# sourceMappingURL=category.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"category.js","sources":["../../src/widgets-v2/category/skeleton.tsx","../../src/widgets-v2/category/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\nimport type { CategorySize } from './types'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 0.5,\n },\n // Mirror the real row layout: label + value on top, bar below.\n row: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n },\n rowHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // Small fixed-width shimmer pills — matches the visual density of the\n // real label / value cells without claiming the full row width.\n name: { height: 14, width: 80 },\n value: { height: 14, width: 48 },\n} satisfies Record<string, SxProps<Theme>>\n\n// Bar shimmer height matches the live bar track for each size variant so\n// the skeleton doesn't visibly resize the row on data settle.\nconst BAR_HEIGHT: Record<CategorySize, number> = {\n small: 4,\n medium: 12,\n}\n\n// Varied widths give the bar shimmer a more realistic, less uniform feel.\n// Cycles when `rows > WIDTH_PATTERNS.length`.\nconst WIDTH_PATTERNS = ['95%', '80%', '55%', '75%', '60%']\n\nexport interface CategorySkeletonProps {\n rows?: number\n /**\n * Visual density. Mirrors the live widget's `size` prop so the loading\n * shimmer's bar height matches what's about to render — no row jump\n * on data settle.\n */\n size?: CategorySize\n}\n\nexport function CategorySkeleton({\n rows = 5,\n size = 'small',\n}: CategorySkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: rows }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Box sx={styles.rowHeader}>\n <Skeleton variant='rectangular' sx={styles.name} />\n <Skeleton variant='rectangular' sx={styles.value} />\n </Box>\n <Skeleton\n variant='rectangular'\n sx={{\n height: BAR_HEIGHT[size],\n width: WIDTH_PATTERNS[i % WIDTH_PATTERNS.length],\n }}\n />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { CategoryWidgetData } from './types'\n\n/**\n * Download menu items for the Category widget. Always includes a CSV item\n * with `series, name, value` columns (one row per item). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createCategoryDownloadConfig(args: {\n filename: string\n getData: () => CategoryWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const item of series) {\n rows.push([seriesName, item.name, item.value])\n }\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["styles","root","display","flexDirection","gap","py","row","rowHeader","justifyContent","alignItems","name","height","width","value","BAR_HEIGHT","small","medium","WIDTH_PATTERNS","CategorySkeleton","t0","$","_c","rows","t1","size","t2","undefined","t3","Array","from","length","t4","Box","map","_","i","jsxs","jsx","Skeleton","createCategoryDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","resolve","data","getData","series","entries","seriesName","seriesNames","item","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;AAIA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EAAA;AAAA;AAAA,EAGNC,KAAK;AAAA,IACHJ,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,EAAA;AAAA,EAEPG,WAAW;AAAA,IACTL,SAAS;AAAA,IACTM,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZL,KAAK;AAAA,EAAA;AAA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,OAAOK,CAAC,EAYlB,CACD,EAAA,CACH,GAAMf,OAAAI,GAAAJ,OAAAO,GAAAP,OAAAW,KAAAA,IAAAX,EAAA,CAAA,GAhBNW;AAgBM;AC1DH,SAASQ,EAA6BC,GAO1B;AACjB,QAAMC,IAAwB,CAAA;AAC9B,SAAID,EAAKE,gBACPD,EAAME,KACJC,EAAqB;AAAA,IACnBC,UAAUL,EAAKK;AAAAA,IACfH,cAAcF,EAAKE;AAAAA,IACnBI,YAAYN,EAAKO;AAAAA,IACjBC,iBAAiBR,EAAKS;AAAAA,EAAAA,CACvB,CACH,GAEFR,EAAME,KAAK;AAAA,IACTO,IAAI;AAAA,IACJC,OAAO;AAAA,IACPC,SAASA,MAAM;AACb,YAAMC,IAAOb,EAAKc,QAAAA,GACZhC,IAAoB,CAAC,CAAC,UAAU,QAAQ,OAAO,CAAC;AACtD,iBAAW,CAACa,GAAGoB,CAAM,KAAKF,EAAKG,WAAW;AACxC,cAAMC,IAAajB,EAAKkB,cAAcvB,CAAC,KAAK,UAAUA,IAAI,CAAC;AAC3D,mBAAWwB,KAAQJ;AACjBjC,UAAAA,EAAKqB,KAAK,CAACc,GAAYE,EAAKjD,MAAMiD,EAAK9C,KAAK,CAAC;AAAA,MAEjD;AACA,YAAM+C,IAASC,EAAcvC,CAAI;AACjC,aAAOwC,QAAQV,QAAQ;AAAA,QACrBW,KAAKH,EAAOG;AAAAA,QACZlB,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1BmB,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACMvB;AACT;"}
1
+ {"version":3,"file":"category.js","sources":["../../src/widgets-v2/category/skeleton.tsx","../../src/widgets-v2/category/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\nimport type { CategorySize } from './types'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 0.5,\n },\n // Mirror the real row layout: label + value on top, bar below.\n row: {\n display: 'flex',\n flexDirection: 'column',\n gap: 0.5,\n },\n rowHeader: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n gap: 1,\n },\n // Small fixed-width shimmer pills — matches the visual density of the\n // real label / value cells without claiming the full row width.\n name: { height: 14, width: 80 },\n value: { height: 14, width: 48 },\n} satisfies Record<string, SxProps<Theme>>\n\n// Bar shimmer height matches the live bar track for each size variant so\n// the skeleton doesn't visibly resize the row on data settle.\nconst BAR_HEIGHT: Record<CategorySize, number> = {\n small: 4,\n medium: 12,\n}\n\n// Varied widths give the bar shimmer a more realistic, less uniform feel.\n// Cycles when `rows > WIDTH_PATTERNS.length`.\nconst WIDTH_PATTERNS = ['95%', '80%', '55%', '75%', '60%']\n\nexport interface CategorySkeletonProps {\n rows?: number\n /**\n * Visual density. Mirrors the live widget's `size` prop so the loading\n * shimmer's bar height matches what's about to render — no row jump\n * on data settle.\n */\n size?: CategorySize\n}\n\nexport function CategorySkeleton({\n rows = 5,\n size = 'small',\n}: CategorySkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: rows }).map((_, i) => (\n <Box key={`row-${i}`} sx={styles.row}>\n <Box sx={styles.rowHeader}>\n <Skeleton variant='rectangular' sx={styles.name} />\n <Skeleton variant='rectangular' sx={styles.value} />\n </Box>\n <Skeleton\n variant='rectangular'\n sx={{\n height: BAR_HEIGHT[size],\n width: WIDTH_PATTERNS[i % WIDTH_PATTERNS.length],\n }}\n />\n </Box>\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { CategoryWidgetData } from './types'\n\n/**\n * Download menu items for the Category widget. Always includes a CSV item\n * with `series, name, value` columns (one row per item). When\n * `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createCategoryDownloadConfig(args: {\n filename: string\n getData: () => CategoryWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const item of series) {\n rows.push([seriesName, item.name, item.value])\n }\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["styles","root","display","flexDirection","gap","py","row","rowHeader","justifyContent","alignItems","name","height","width","value","BAR_HEIGHT","small","medium","WIDTH_PATTERNS","CategorySkeleton","t0","$","_c","rows","t1","size","t2","undefined","t3","Array","from","length","t4","Box","map","_","i","jsxs","jsx","Skeleton","createCategoryDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","resolve","data","getData","series","entries","seriesName","seriesNames","item","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;AAIA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EAAA;AAAA;AAAA,EAGNC,KAAK;AAAA,IACHJ,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,EAAA;AAAA,EAEPG,WAAW;AAAA,IACTL,SAAS;AAAA,IACTM,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZL,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA,EAIPM,MAAM;AA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A,CACH,GAAMf,OAAAI,GAAAJ,OAAAO,GAAAP,OAAAW,KAAAA,IAAAX,EAAA,CAAA,GAhBNW;AAgBM;AC1DH,SAASQ,EAA6BC,GAO1B;AACjB,QAAMC,IAAwB,CAAA;AAC9B,SAAID,EAAKE,gBACPD,EAAME,KACJC,EAAqB;AAAA,IACnBC,UAAUL,EAAKK;AAAAA,IACfH,cAAcF,EAAKE;AAAAA,IACnBI,YAAYN,EAAKO;AAAAA,IACjBC,iBAAiBR,EAAKS;AAAAA,EAAAA,CACvB,CACH,GAEFR,EAAME,KAAK;AAAA,IACTO,IAAI;AAAA,IACJC,OAAO;AAAA,IACPC,SAASA,MAAM;AACb,YAAMC,IAAOb,EAAKc,QAAAA,GACZhC,IAAoB,CAAC,CAAC,UAAU,QAAQ,OAAO,CAAC;AACtD,iBAAW,CAACa,GAAGoB,CAAM,KAAKF,EAAKG,WAAW;AACxC,cAAMC,IAAajB,EAAKkB,cAAcvB,CAAC,KAAK,UAAUA,IAAI,CAAC;AAC3D,mBAAWwB,KAAQJ;AACjBjC,UAAAA,EAAKqB,KAAK,CAACc,GAAYE,EAAKjD,MAAMiD,EAAK9C,KAAK,CAAC;AAAA,MAEjD;AACA,YAAM+C,IAASC,EAAcvC,CAAI;AACjC,aAAOwC,QAAQV,QAAQ;AAAA,QACrBW,KAAKH,EAAOG;AAAAA,QACZlB,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1BmB,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACMvB;AACT;"}
@@ -1,16 +1,15 @@
1
- import { D as E, F as $, a as B } from "../formula-DuC0NQLH.js";
2
- import { N as R, P as _, S as j, a as z, V as A } from "../style-DVnT6HC1.js";
3
- import { jsx as n } from "react/jsx-runtime";
1
+ import { D as I, F as E, a as $ } from "../formula-DuC0NQLH.js";
2
+ import { N, P as R, S as _, a as j, V as z } from "../style-DVnT6HC1.js";
3
+ import { jsx as i } from "react/jsx-runtime";
4
4
  import { c as s } from "react/compiler-runtime";
5
5
  import { Box as m, Skeleton as u } from "@mui/material";
6
6
  import "react";
7
- import "@mui/icons-material/FileDownload";
7
+ import "@mui/icons-material";
8
8
  import "../lasso-tool-CDFj4zKY.js";
9
9
  import "../cjs-D4KH3azB.js";
10
- import "@mui/icons-material";
11
10
  import "@carto/ps-utils";
12
11
  import { a as f } from "../exports-Cx-f6m6U.js";
13
- import { b as p, C as c } from "../png-item-CS4z1iSH.js";
12
+ import { b as p, C as c } from "../png-item-BE9uEqlD.js";
14
13
  const l = {
15
14
  root: {
16
15
  display: "flex",
@@ -24,19 +23,19 @@ const l = {
24
23
  height: 36
25
24
  }
26
25
  };
27
- function P(o) {
26
+ function F(o) {
28
27
  const e = s(2), {
29
- count: i
30
- } = o, r = i === void 0 ? 1 : i;
28
+ count: n
29
+ } = o, r = n === void 0 ? 1 : n;
31
30
  let t;
32
- return e[0] !== r ? (t = /* @__PURE__ */ n(m, { sx: l.root, children: Array.from({
31
+ return e[0] !== r ? (t = /* @__PURE__ */ i(m, { sx: l.root, children: Array.from({
33
32
  length: r
34
33
  }).map(d) }), e[0] = r, e[1] = t) : t = e[1], t;
35
34
  }
36
35
  function d(o, e) {
37
- return /* @__PURE__ */ n(u, { variant: "rectangular", sx: l.block }, `row-${e}`);
36
+ return /* @__PURE__ */ i(u, { variant: "rectangular", sx: l.block }, `row-${e}`);
38
37
  }
39
- function V(o) {
38
+ function P(o) {
40
39
  const e = [];
41
40
  return o.getCaptureEl && e.push(p({
42
41
  filename: o.filename,
@@ -46,10 +45,10 @@ function V(o) {
46
45
  })), e.push({
47
46
  id: "csv",
48
47
  label: "CSV",
49
- icon: /* @__PURE__ */ n(c, { fontSize: "small" }),
48
+ icon: /* @__PURE__ */ i(c, { fontSize: "small" }),
50
49
  resolve: () => {
51
- const i = o.getData(), r = [["series", "prefix", "value", "suffix", "note", "delta"]];
52
- for (const a of i)
50
+ const n = o.getData(), r = [["series", "prefix", "value", "suffix", "note", "delta"]];
51
+ for (const a of n)
53
52
  r.push([a.series?.name ?? "", a.prefix ?? "", a.value, a.suffix ?? "", a.note ?? "", a.delta?.value ?? ""]);
54
53
  const t = f(r);
55
54
  return Promise.resolve({
@@ -61,15 +60,15 @@ function V(o) {
61
60
  }), e;
62
61
  }
63
62
  export {
64
- E as Delta,
65
- $ as Formula,
66
- P as FormulaSkeleton,
67
- B as FormulaUI,
68
- R as Note,
69
- _ as Prefix,
70
- j as Series,
71
- z as Suffix,
72
- A as Value,
73
- V as createFormulaDownloadConfig
63
+ I as Delta,
64
+ E as Formula,
65
+ F as FormulaSkeleton,
66
+ $ as FormulaUI,
67
+ N as Note,
68
+ R as Prefix,
69
+ _ as Series,
70
+ j as Suffix,
71
+ z as Value,
72
+ P as createFormulaDownloadConfig
74
73
  };
75
74
  //# sourceMappingURL=formula.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formula.js","sources":["../../src/widgets-v2/formula/skeleton.tsx","../../src/widgets-v2/formula/download.tsx"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n gap: 3,\n alignItems: 'baseline',\n minHeight: 64,\n py: 1,\n },\n block: { width: 120, height: 36 },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface FormulaSkeletonProps {\n count?: number\n}\n\nexport function FormulaSkeleton({ count = 1 }: FormulaSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n ))}\n </Box>\n )\n}\n","import {\n CSVIcon,\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { FormulaWidgetData } from './types'\n\nexport interface FormulaDownloadConfigArgs {\n filename: string\n getData: () => FormulaWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State`). When provided, a PNG item is prepended.\n */\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Formula widget. Always includes a CSV item\n * with one row per KPI (`prefix`, `value`, `suffix`, `note`, `delta`).\n * When `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createFormulaDownloadConfig(\n args: FormulaDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'CSV',\n icon: <CSVIcon fontSize='small' />,\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [\n ['series', 'prefix', 'value', 'suffix', 'note', 'delta'],\n ]\n for (const d of data) {\n rows.push([\n d.series?.name ?? '',\n d.prefix ?? '',\n d.value,\n d.suffix ?? '',\n d.note ?? '',\n d.delta?.value ?? '',\n ])\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["styles","root","display","gap","alignItems","minHeight","py","block","width","height","FormulaSkeleton","t0","$","_c","count","t1","undefined","t2","Box","Array","from","length","map","_temp","_","i","jsx","Skeleton","createFormulaDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","icon","CSVIcon","resolve","data","getData","rows","d","series","name","prefix","value","suffix","note","delta","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,KAAK;AAAA,IACLC,YAAY;AAAA,IACZC,WAAW;AAAA,IACXC,IAAI;AAAA,EAAA;AAAA,EAENC,OAAO;AAAA,IAAEC,OAAO;AA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AAEH,YAAMI,IAASC,EAAcV,CAAI;AACjC,aAAOW,QAAQd,QAAQ;AAAA,QACrBe,KAAKH,EAAOG;AAAAA,QACZxB,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1ByB,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACM7B;AACT;"}
1
+ {"version":3,"file":"formula.js","sources":["../../src/widgets-v2/formula/skeleton.tsx","../../src/widgets-v2/formula/download.tsx"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n gap: 3,\n alignItems: 'baseline',\n minHeight: 64,\n py: 1,\n },\n block: { width: 120, height: 36 },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface FormulaSkeletonProps {\n count?: number\n}\n\nexport function FormulaSkeleton({ count = 1 }: FormulaSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`row-${i}`} variant='rectangular' sx={styles.block} />\n ))}\n </Box>\n )\n}\n","import {\n CSVIcon,\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { FormulaWidgetData } from './types'\n\nexport interface FormulaDownloadConfigArgs {\n filename: string\n getData: () => FormulaWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State`). When provided, a PNG item is prepended.\n */\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Formula widget. Always includes a CSV item\n * with one row per KPI (`prefix`, `value`, `suffix`, `note`, `delta`).\n * When `getCaptureEl` is supplied, prepends a PNG item that rasterises the\n * captured element via `html2canvas`.\n */\nexport function createFormulaDownloadConfig(\n args: FormulaDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'CSV',\n icon: <CSVIcon fontSize='small' />,\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [\n ['series', 'prefix', 'value', 'suffix', 'note', 'delta'],\n ]\n for (const d of data) {\n rows.push([\n d.series?.name ?? '',\n d.prefix ?? '',\n d.value,\n d.suffix ?? '',\n d.note ?? '',\n d.delta?.value ?? '',\n ])\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["styles","root","display","gap","alignItems","minHeight","py","block","width","height","FormulaSkeleton","t0","$","_c","count","t1","undefined","t2","Box","Array","from","length","map","_temp","_","i","jsx","Skeleton","createFormulaDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","icon","CSVIcon","resolve","data","getData","rows","d","series","name","prefix","value","suffix","note","delta","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,KAAK;AAAA,IACLC,YAAY;AAAA,IACZC,WAAW;AAAA,IACXC,IAAI;AAAA,EAAA;AAAA,EAENC,OAAO;AAAA,IAAEC,OAAO;AAAA,IAAKC,QAAQ;AAAA,EAAA;AAC/B;AAMO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAyB;AAAA,IAAAC,OAAAC;AAAAA,EAAAA,IAAAJ,GAAEG,IAAAC,MAAAC,SAAA,IAAAD;AAAS,MAAAE;AAAA,SAAAL,SAAAE,KAEvCG,sBAACC,GAAA,EAAQ,IAAAlB,EAAMC,MACZkB,gBAAKC,KAAM;AAAA,IAAAC,QAAUP;AAAAA,EAAAA,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react-dom";
18
- import "@mui/icons-material/ZoomIn";
19
18
  import "../widget-context-DTGO0Yta.js";
20
19
  import "zustand";
21
20
  import "zustand/vanilla";
@@ -23,11 +22,9 @@ import "zustand/middleware";
23
22
  import "zustand/react/shallow";
24
23
  import { Z as O } from "../transforms-Cdx4fkU5.js";
25
24
  import { m as q, r as U } from "../resolve-theme-color-BdojIw0K.js";
26
- import { p as J } from "../data-zoom-layout--YiY6ko_.js";
27
- import "@mui/icons-material/FileDownload";
25
+ import { p as J } from "../data-zoom-layout-CkVnm6ej.js";
28
26
  import { a as K } from "../exports-Cx-f6m6U.js";
29
- import "@mui/icons-material/ImageOutlined";
30
- import { b as Q } from "../png-item-CS4z1iSH.js";
27
+ import { b as Q } from "../png-item-BE9uEqlD.js";
31
28
  function X({
32
29
  theme: e,
33
30
  formatter: t
@@ -117,7 +114,7 @@ function X({
117
114
  }
118
115
  };
119
116
  }
120
- function $e(e) {
117
+ function Ne(e) {
121
118
  const {
122
119
  theme: t,
123
120
  formatter: a,
@@ -273,7 +270,7 @@ const w = {
273
270
  height: `${e}%`,
274
271
  minWidth: 8
275
272
  });
276
- function je(e) {
273
+ function Oe(e) {
277
274
  const t = Y(15), {
278
275
  bins: a
279
276
  } = e, o = a === void 0 ? 12 : a;
@@ -307,7 +304,7 @@ function re(e) {
307
304
  function oe(e, t) {
308
305
  return /* @__PURE__ */ b(k, { variant: "rectangular", sx: te(e) }, `bar-${t}`);
309
306
  }
310
- function De(e) {
307
+ function _e(e) {
311
308
  const t = [];
312
309
  return e.getCaptureEl && t.push(Q({
313
310
  filename: e.filename,
@@ -336,7 +333,7 @@ function De(e) {
336
333
  }
337
334
  }), t;
338
335
  }
339
- const He = (e) => Array.isArray(e) ? e.map((t) => {
336
+ const $e = (e) => Array.isArray(e) ? e.map((t) => {
340
337
  if (!ie(t)) return t;
341
338
  const a = t.reduce((o, i) => o + Math.abs(i), 0);
342
339
  return a <= 0 ? t : t.map((o) => o / a * 100);
@@ -345,10 +342,10 @@ function ie(e) {
345
342
  return Array.isArray(e) ? e.every((t) => typeof t == "number" && Number.isFinite(t)) : !1;
346
343
  }
347
344
  export {
348
- je as HistogramSkeleton,
349
- De as createHistogramDownloadConfig,
350
- $e as createHistogramOptionFactory,
345
+ Oe as HistogramSkeleton,
346
+ _e as createHistogramDownloadConfig,
347
+ Ne as createHistogramOptionFactory,
351
348
  X as histogramOptions,
352
- He as toRelativeHistogramData
349
+ $e as toRelativeHistogramData
353
350
  };
354
351
  //# sourceMappingURL=histogram.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"histogram.js","sources":["../../src/widgets-v2/histogram/options.ts","../../src/widgets-v2/histogram/skeleton.tsx","../../src/widgets-v2/histogram/download.ts","../../src/widgets-v2/histogram/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n HistogramEChartsOption,\n HistogramOptionFactoryInput,\n HistogramOptionsInput,\n HistogramWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a histogram widget — axes,\n * grid, tooltip, value-axis label formatter, themed legend. Mirrors\n * {@link import('../bar/options').barOptions} so the two widgets share v1\n * look-and-feel: themed dark tooltip with positioner, CARTO color palette,\n * structural legend (`show` toggled by the merger based on series count),\n * y-axis labels rendered inside the plot via the `niceNum` closure pattern.\n *\n * Intentional deviations from bar (histogram-specific):\n * - **No `xAxis.axisLabel.formatter`.** Bin labels are pre-formatted in\n * the merger via `formatNumber(lo)–formatNumber(hi)` and optionally\n * the consumer's `labelFormatter`. The strings on the axis are\n * already display-ready, so there's nothing to post-format here.\n * - **Tooltip formatter reads the array-tuple row shape.** The dataset\n * uses positional `encode: { x: 0, y: 1 }`, so `item.value` comes in\n * as `[binLabel, count]` rather than bar's `{ name, value }` object.\n *\n * Intentionally data-agnostic: no series, no dataset, no x-axis category\n * data (those depend on data + ticks and are added by the option factory's\n * merge phase via {@link createHistogramOptionFactory}).\n */\nexport function histogramOptions({\n theme,\n formatter,\n}: HistogramOptionsInput): HistogramEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildHistogramTooltipFormatter(formatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count. Histogram doesn't accept `labelFormatter` at the\n // options layer (bin labels are pre-formatted in the merger), so we\n // skip the legend `labelFormatter` argument too.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as HistogramEChartsOption\n}\n\n/**\n * Returns the histogram widget's {@link OptionFactory} — one closure that\n * owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link histogramOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`HistogramWidgetData` — `number[][]`) into the option via the\n * dataset API. Each series gets its own dataset of `[binLabel, count]`\n * pairs derived from `ticks`; series reference their dataset by\n * `datasetIndex` and are encoded by column position. Reactive\n * `ctx.formatter` (driven by RelativeData → `%`) plus `niceMin`/`niceMax`\n * are re-derived here so the y-axis label formatter and the tooltip\n * pick up live store values, mirroring bar.\n */\nexport function createHistogramOptionFactory(\n options: HistogramOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, ticks, series, labelFormatter, selection } = options\n const optionsOverride = options.optionsOverride\n const selectionSet =\n selection && selection.length > 0 ? new Set<number>(selection) : null\n\n const binLabels: string[] = []\n for (let i = 0; i < ticks.length - 1; i++) {\n const lo = ticks[i]!\n const hi = ticks[i + 1]!\n const raw = `${formatNumber(lo)}–${formatNumber(hi)}`\n binLabels.push(labelFormatter ? labelFormatter(raw) : raw)\n }\n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = histogramOptions({ theme, formatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr: HistogramWidgetData = Array.isArray(data)\n ? (data as HistogramWidgetData)\n : []\n if (seriesArr.length === 0 || binLabels.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up.\n const liveFormatter = ctx?.formatter\n\n const { niceMinVal, niceMaxVal } = computeHistogramNiceBounds(seriesArr)\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push\n // the slider above the legend (if any) and reserve room in the grid.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected bins via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset sources is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bins would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n return selectionSet.has(params.dataIndex)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((counts) => ({\n source: binLabels.map(\n (label, i) => [label, counts[i] ?? 0] as [string, number],\n ),\n })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n barCategoryGap: '0%',\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: niceMinVal,\n max: niceMaxVal,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildHistogramTooltipFormatter(liveFormatter),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the histogram's positional `[binLabel, count]`\n * row shape. ECharts surfaces the x-axis category through `item.name`\n * (already pre-formatted by the bin-label generator), and `item.value`\n * comes in as the array tuple — distinct from bar's `{ name, value }`\n * object row.\n */\nfunction buildHistogramTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as [string, number] | undefined\n const raw = row?.[1]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: String(item.name ?? ''),\n seriesName,\n marker,\n value: formattedValue,\n }\n })\n}\n\nfunction computeHistogramNiceBounds(seriesArr: HistogramWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let max = -Infinity\n for (const counts of seriesArr) {\n for (const v of counts) {\n if (typeof v !== 'number' || !Number.isFinite(v)) continue\n if (v > max) max = v\n }\n }\n return {\n niceMinVal: 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\nfunction formatNumber(n: number): string {\n if (Number.isInteger(n)) return String(n)\n return Number(n.toFixed(2)).toString()\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n alignItems: 'flex-end',\n flex: '1 1 auto',\n gap: 0.5,\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst barSx = (height: number): SxProps<Theme> => ({\n flex: 1,\n height: `${height}%`,\n minWidth: 8,\n})\n\nexport interface HistogramSkeletonProps {\n bins?: number\n}\n\n/**\n * Loading state for the Histogram widget. Mirrors Bar's skeleton structure\n * — a grid of bars (bin-shaped silhouette, anchored to the bottom) plus a\n * legend stub — so the placeholder reads consistently with Bar.\n */\nexport function HistogramSkeleton({ bins = 12 }: HistogramSkeletonProps) {\n // Sample heights mimicking a typical bell-shaped distribution.\n const heights = Array.from({ length: bins }, (_, i) => {\n const t = i / Math.max(1, bins - 1)\n return Math.round(20 + 80 * Math.exp(-((t - 0.5) ** 2) * 8))\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { HistogramWidgetData } from './types'\n\n/**\n * Download menu items for histograms. Always includes a CSV item with\n * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row\n * per bin). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createHistogramDownloadConfig(args: {\n filename: string\n getData: () => HistogramWidgetData\n getTicks: () => readonly number[]\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const ticks = args.getTicks()\n const seriesCount = data.length\n const header: unknown[] = ['bin_low', 'bin_high']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (let bin = 0; bin < Math.max(0, ticks.length - 1); bin++) {\n const row: unknown[] = [ticks[bin], ticks[bin + 1]]\n for (let s = 0; s < seriesCount; s++) row.push(data[s]?.[bin] ?? 0)\n rows.push(row)\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n","/**\n * Histogram-specific `RelativeData` transform. Histogram data is\n * `number[][]` — each series is a flat list of bin counts. This\n * rewrites each count to its share of the series total (0–100), so\n * pairing with `createPercentFormatter` renders the y-axis as\n * percentages.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeHistogramData} />`.\n *\n * The denominator is the sum of |value| across the series so mixed-sign\n * inputs produce sane signed shares-of-magnitude. A series whose total\n * magnitude is zero (all-zero or empty input) is returned unchanged so\n * a stalled or empty data set doesn't show misleading 0% values. Inputs\n * whose shape isn't `number[][]` fall through untouched (same defensive\n * shape-check pattern as the default transform).\n */\nexport const toRelativeHistogramData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n const total = series.reduce((acc, v) => acc + Math.abs(v), 0)\n if (total <= 0) return series\n return series.map((v) => (v / total) * 100)\n })\n}\n\nfunction isFlatNumberArray(v: unknown): v is number[] {\n if (!Array.isArray(v)) return false\n return v.every((item) => typeof item === 'number' && Number.isFinite(item))\n}\n"],"names":["histogramOptions","theme","formatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildHistogramTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","String","createHistogramOptionFactory","options","ticks","series","labelFormatter","selection","optionsOverride","selectionSet","length","Set","binLabels","i","lo","hi","raw","formatNumber","push","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","seriesTemplates","broadcastTemplate","baseYAxis","baseGrid","baseTooltip","baseLegend","liveFormatter","niceMinVal","niceMaxVal","computeHistogramNiceBounds","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","has","dataIndex","echarts","modifyAlpha","map","counts","source","label","_","template","overrideColor","resolveThemeColor","datasetIndex","name","encode","x","y","barCategoryGap","emphasis","focus","itemStyle","createTooltipFormatter","item","formattedValue","marker","seriesName","v","Number","isFinite","n","isInteger","toFixed","toString","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","legendItem","barSx","minWidth","HistogramSkeleton","t0","$","_c","bins","t1","undefined","T0","T1","t2","t3","t4","heights","from","t","Math","round","exp","Box","_temp","t5","jsx","t6","Symbol","for","_temp2","t7","i_1","jsxs","Skeleton","h","i_0","createHistogramDownloadConfig","args","items","getCaptureEl","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","resolve","getData","getTicks","seriesCount","header","seriesNames","rows","bin","row","s","handle","downloadToCSV","Promise","url","revoke","toRelativeHistogramData","input","isFlatNumberArray","total","reduce","acc","abs","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,SAASA,EAAiB;AAAA,EAC/BC,OAAAA;AAAAA,EACAC,WAAAA;AACqB,GAA2B;AAGhD,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASN,EAAMO,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASN,EAAMO,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASN,EAAMO,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOV,CA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CAAC,IANiCF;AASpC,SAASC,GAAkB/E,GAA2B;AACpD,SAAKpD,MAAMC,QAAQmD,CAAC,IACbA,EAAEoF,MAAOxF,CAAAA,MAAS,OAAOA,KAAS,YAAYK,OAAOC,SAASN,CAAI,CAAC,IAD5C;AAEhC;"}
1
+ {"version":3,"file":"histogram.js","sources":["../../src/widgets-v2/histogram/options.ts","../../src/widgets-v2/histogram/skeleton.tsx","../../src/widgets-v2/histogram/download.ts","../../src/widgets-v2/histogram/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n HistogramEChartsOption,\n HistogramOptionFactoryInput,\n HistogramOptionsInput,\n HistogramWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a histogram widget — axes,\n * grid, tooltip, value-axis label formatter, themed legend. Mirrors\n * {@link import('../bar/options').barOptions} so the two widgets share v1\n * look-and-feel: themed dark tooltip with positioner, CARTO color palette,\n * structural legend (`show` toggled by the merger based on series count),\n * y-axis labels rendered inside the plot via the `niceNum` closure pattern.\n *\n * Intentional deviations from bar (histogram-specific):\n * - **No `xAxis.axisLabel.formatter`.** Bin labels are pre-formatted in\n * the merger via `formatNumber(lo)–formatNumber(hi)` and optionally\n * the consumer's `labelFormatter`. The strings on the axis are\n * already display-ready, so there's nothing to post-format here.\n * - **Tooltip formatter reads the array-tuple row shape.** The dataset\n * uses positional `encode: { x: 0, y: 1 }`, so `item.value` comes in\n * as `[binLabel, count]` rather than bar's `{ name, value }` object.\n *\n * Intentionally data-agnostic: no series, no dataset, no x-axis category\n * data (those depend on data + ticks and are added by the option factory's\n * merge phase via {@link createHistogramOptionFactory}).\n */\nexport function histogramOptions({\n theme,\n formatter,\n}: HistogramOptionsInput): HistogramEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildHistogramTooltipFormatter(formatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count. Histogram doesn't accept `labelFormatter` at the\n // options layer (bin labels are pre-formatted in the merger), so we\n // skip the legend `labelFormatter` argument too.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as HistogramEChartsOption\n}\n\n/**\n * Returns the histogram widget's {@link OptionFactory} — one closure that\n * owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link histogramOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`HistogramWidgetData` — `number[][]`) into the option via the\n * dataset API. Each series gets its own dataset of `[binLabel, count]`\n * pairs derived from `ticks`; series reference their dataset by\n * `datasetIndex` and are encoded by column position. Reactive\n * `ctx.formatter` (driven by RelativeData → `%`) plus `niceMin`/`niceMax`\n * are re-derived here so the y-axis label formatter and the tooltip\n * pick up live store values, mirroring bar.\n */\nexport function createHistogramOptionFactory(\n options: HistogramOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, ticks, series, labelFormatter, selection } = options\n const optionsOverride = options.optionsOverride\n const selectionSet =\n selection && selection.length > 0 ? new Set<number>(selection) : null\n\n const binLabels: string[] = []\n for (let i = 0; i < ticks.length - 1; i++) {\n const lo = ticks[i]!\n const hi = ticks[i + 1]!\n const raw = `${formatNumber(lo)}–${formatNumber(hi)}`\n binLabels.push(labelFormatter ? labelFormatter(raw) : raw)\n }\n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = histogramOptions({ theme, formatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr: HistogramWidgetData = Array.isArray(data)\n ? (data as HistogramWidgetData)\n : []\n if (seriesArr.length === 0 || binLabels.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up.\n const liveFormatter = ctx?.formatter\n\n const { niceMinVal, niceMaxVal } = computeHistogramNiceBounds(seriesArr)\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push\n // the slider above the legend (if any) and reserve room in the grid.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected bins via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset sources is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bins would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n return selectionSet.has(params.dataIndex)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((counts) => ({\n source: binLabels.map(\n (label, i) => [label, counts[i] ?? 0] as [string, number],\n ),\n })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n barCategoryGap: '0%',\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: niceMinVal,\n max: niceMaxVal,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildHistogramTooltipFormatter(liveFormatter),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the histogram's positional `[binLabel, count]`\n * row shape. ECharts surfaces the x-axis category through `item.name`\n * (already pre-formatted by the bin-label generator), and `item.value`\n * comes in as the array tuple — distinct from bar's `{ name, value }`\n * object row.\n */\nfunction buildHistogramTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as [string, number] | undefined\n const raw = row?.[1]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: String(item.name ?? ''),\n seriesName,\n marker,\n value: formattedValue,\n }\n })\n}\n\nfunction computeHistogramNiceBounds(seriesArr: HistogramWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let max = -Infinity\n for (const counts of seriesArr) {\n for (const v of counts) {\n if (typeof v !== 'number' || !Number.isFinite(v)) continue\n if (v > max) max = v\n }\n }\n return {\n niceMinVal: 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\nfunction formatNumber(n: number): string {\n if (Number.isInteger(n)) return String(n)\n return Number(n.toFixed(2)).toString()\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n alignItems: 'flex-end',\n flex: '1 1 auto',\n gap: 0.5,\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst barSx = (height: number): SxProps<Theme> => ({\n flex: 1,\n height: `${height}%`,\n minWidth: 8,\n})\n\nexport interface HistogramSkeletonProps {\n bins?: number\n}\n\n/**\n * Loading state for the Histogram widget. Mirrors Bar's skeleton structure\n * — a grid of bars (bin-shaped silhouette, anchored to the bottom) plus a\n * legend stub — so the placeholder reads consistently with Bar.\n */\nexport function HistogramSkeleton({ bins = 12 }: HistogramSkeletonProps) {\n // Sample heights mimicking a typical bell-shaped distribution.\n const heights = Array.from({ length: bins }, (_, i) => {\n const t = i / Math.max(1, bins - 1)\n return Math.round(20 + 80 * Math.exp(-((t - 0.5) ** 2) * 8))\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { HistogramWidgetData } from './types'\n\n/**\n * Download menu items for histograms. Always includes a CSV item with\n * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row\n * per bin). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createHistogramDownloadConfig(args: {\n filename: string\n getData: () => HistogramWidgetData\n getTicks: () => readonly number[]\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const ticks = args.getTicks()\n const seriesCount = data.length\n const header: unknown[] = ['bin_low', 'bin_high']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (let bin = 0; bin < Math.max(0, ticks.length - 1); bin++) {\n const row: unknown[] = [ticks[bin], ticks[bin + 1]]\n for (let s = 0; s < seriesCount; s++) row.push(data[s]?.[bin] ?? 0)\n rows.push(row)\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n","/**\n * Histogram-specific `RelativeData` transform. Histogram data is\n * `number[][]` — each series is a flat list of bin counts. This\n * rewrites each count to its share of the series total (0–100), so\n * pairing with `createPercentFormatter` renders the y-axis as\n * percentages.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeHistogramData} />`.\n *\n * The denominator is the sum of |value| across the series so mixed-sign\n * inputs produce sane signed shares-of-magnitude. A series whose total\n * magnitude is zero (all-zero or empty input) is returned unchanged so\n * a stalled or empty data set doesn't show misleading 0% values. Inputs\n * whose shape isn't `number[][]` fall through untouched (same defensive\n * shape-check pattern as the default transform).\n */\nexport const toRelativeHistogramData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n const total = series.reduce((acc, v) => acc + Math.abs(v), 0)\n if (total <= 0) return series\n return series.map((v) => (v / total) * 100)\n })\n}\n\nfunction isFlatNumberArray(v: unknown): v is number[] {\n if (!Array.isArray(v)) return false\n return v.every((item) => typeof item === 'number' && Number.isFinite(item))\n}\n"],"names":["histogramOptions","theme","formatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildHistogramTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","String","createHistogramOptionFactory","options","ticks","series","labelFormatter","selection","optionsOverride","selectionSet","length","Set","binLabels","i","lo","hi","raw","formatNumber","push","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","seriesTemplates","broadcastTemplate","baseYAxis","baseGrid","baseTooltip","baseLegend","liveFormatter","niceMinVal","niceMaxVal","computeHistogramNiceBounds","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","has","dataIndex","echarts","modifyAlpha","map","counts","source","label","_","template","overrideColor","resolveThemeColor","datasetIndex","name","encode","x","y","barCategoryGap","emphasis","focus","itemStyle","createTooltipFormatter","item","formattedValue","marker","seriesName","v","Number","isFinite","n","isInteger","toFixed","toString","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","legendItem","barSx","minWidth","HistogramSkeleton","t0","$","_c","bins","t1","undefined","T0","T1","t2","t3","t4","heights","from","t","Math","round","exp","Box","_temp","t5","jsx","t6","Symbol","for","_temp2","t7","i_1","jsxs","Skeleton","h","i_0","createHistogramDownloadConfig","args","items","getCaptureEl","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","resolve","getData","getTicks","seriesCount","header","seriesNames","rows","bin","row","s","handle","downloadToCSV","Promise","url","revoke","toRelativeHistogramData","input","isFlatNumberArray","total","reduce","acc","abs","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,SAASA,EAAiB;AAAA,EAC/BC,OAAAA;AAAAA,EACAC,WAAAA;AACqB,GAA2B;AAGhD,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO;AAAA,IACLC,MAAM;AAAA,MACJC,MAAMC,SAASN,EAAMO,QAAQ,CAAC,CAAC;AAAA,MAC/BC,KAAKF,SAASN,EAAMO,QAAQ,CAAC,CAAC;AAAA,MAC9BE,OAAOH,SAASN,EAAMO,QAAQ,CAAC,CAAC;AAAA;AAAA,MAEhC,GAAGG,EAAgB,IAAOV,CAAK;AAAA,MAC/BW,cAAc;AAAA,IAAA;AAAA,IAEhBC,SAAS;AAAA,MACPC,SAAS;AAAA,MACTC,iBAAiBd,EAAMe,QAAQC,KAAK,GAAG;AAAA,MACvCC,aAAa;AAAA,MACbC,SAAS,CA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D5C;AAEhC;"}
@@ -1,16 +1,14 @@
1
- import { M as B, a as E, b as P } from "../markdown-BD1jcknS.js";
1
+ import { M as L, a as j, b as B } from "../markdown-BD1jcknS.js";
2
2
  import { jsx as a } from "react/jsx-runtime";
3
3
  import { c as p } from "react/compiler-runtime";
4
4
  import { Box as s, Skeleton as c } from "@mui/material";
5
5
  import "react";
6
- import "@mui/icons-material/FileDownload";
6
+ import "@mui/icons-material";
7
7
  import "../lasso-tool-CDFj4zKY.js";
8
8
  import "../cjs-D4KH3azB.js";
9
- import "@mui/icons-material";
10
9
  import "@carto/ps-utils";
11
10
  import "html2canvas";
12
- import "@mui/icons-material/ImageOutlined";
13
- import { b as d } from "../png-item-CS4z1iSH.js";
11
+ import { b as d } from "../png-item-BE9uEqlD.js";
14
12
  const m = {
15
13
  root: {
16
14
  display: "flex",
@@ -23,47 +21,47 @@ const m = {
23
21
  height: 18
24
22
  })
25
23
  };
26
- function D(o) {
27
- const t = p(2), {
24
+ function R(o) {
25
+ const e = p(2), {
28
26
  lines: r
29
27
  } = o, n = r === void 0 ? 5 : r;
30
- let e;
31
- if (t[0] !== n) {
32
- const i = ["100%", "95%", "90%", "85%", "70%"];
33
- e = /* @__PURE__ */ a(s, { sx: m.root, children: Array.from({
28
+ let t;
29
+ if (e[0] !== n) {
30
+ const l = ["100%", "95%", "90%", "85%", "70%"];
31
+ t = /* @__PURE__ */ a(s, { sx: m.root, children: Array.from({
34
32
  length: n
35
- }).map((f, l) => /* @__PURE__ */ a(c, { variant: "rectangular", sx: m.line(i[l % i.length] ?? "85%") }, `line-${l}`)) }), t[0] = n, t[1] = e;
33
+ }).map((f, i) => /* @__PURE__ */ a(c, { variant: "rectangular", sx: m.line(l[i % l.length] ?? "85%") }, `line-${i}`)) }), e[0] = n, e[1] = t;
36
34
  } else
37
- e = t[1];
38
- return e;
35
+ t = e[1];
36
+ return t;
39
37
  }
40
- function U(o) {
41
- const t = [];
42
- return o.getCaptureEl && t.push(d({
38
+ function y(o) {
39
+ const e = [];
40
+ return o.getCaptureEl && e.push(d({
43
41
  filename: o.filename,
44
42
  getCaptureEl: o.getCaptureEl,
45
43
  pixelRatio: o.pngPixelRatio,
46
44
  backgroundColor: o.pngBackgroundColor
47
- })), t.push({
45
+ })), e.push({
48
46
  id: "md",
49
47
  label: "Download as Markdown",
50
48
  resolve: () => {
51
49
  const r = o.getData(), n = new Blob([r.content ?? ""], {
52
50
  type: "text/markdown;charset=utf-8;"
53
- }), e = URL.createObjectURL(n);
51
+ }), t = URL.createObjectURL(n);
54
52
  return Promise.resolve({
55
- url: e,
53
+ url: t,
56
54
  filename: `${o.filename}.md`,
57
- revoke: () => URL.revokeObjectURL(e)
55
+ revoke: () => URL.revokeObjectURL(t)
58
56
  });
59
57
  }
60
- }), t;
58
+ }), e;
61
59
  }
62
60
  export {
63
- B as Markdown,
64
- E as MarkdownContent,
65
- D as MarkdownSkeleton,
66
- P as MarkdownUI,
67
- U as createMarkdownDownloadConfig
61
+ L as Markdown,
62
+ j as MarkdownContent,
63
+ R as MarkdownSkeleton,
64
+ B as MarkdownUI,
65
+ y as createMarkdownDownloadConfig
68
66
  };
69
67
  //# sourceMappingURL=markdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.js","sources":["../../src/widgets-v2/markdown/skeleton.tsx","../../src/widgets-v2/markdown/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 1,\n },\n line: (width: string): SxProps<Theme> => ({ width, height: 18 }),\n} as const\n\nexport interface MarkdownSkeletonProps {\n lines?: number\n}\n\nexport function MarkdownSkeleton({ lines = 5 }: MarkdownSkeletonProps) {\n // Vary widths to mimic prose.\n const widths = ['100%', '95%', '90%', '85%', '70%']\n return (\n <Box sx={styles.root}>\n {Array.from({ length: lines }).map((_, i) => (\n <Skeleton\n key={`line-${i}`}\n variant='rectangular'\n sx={styles.line(widths[i % widths.length] ?? '85%')}\n />\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n toCsvString,\n triggerLinkDownload,\n type DownloadItem,\n} from '../actions/download'\nimport type { MarkdownWidgetData } from './types'\n\n/**\n * Download menu items for the Markdown widget. Always includes a `.md`\n * item that saves the markdown source verbatim. When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createMarkdownDownloadConfig(args: {\n filename: string\n getData: () => MarkdownWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'md',\n label: 'Download as Markdown',\n resolve: () => {\n const data = args.getData()\n const blob = new Blob([data.content ?? ''], {\n type: 'text/markdown;charset=utf-8;',\n })\n const url = URL.createObjectURL(blob)\n return Promise.resolve({\n url,\n filename: `${args.filename}.md`,\n revoke: () => URL.revokeObjectURL(url),\n })\n },\n })\n return items\n}\n\n// Re-export pure helpers consumers may want when building a custom Download item.\nexport { toCsvString, triggerLinkDownload }\n"],"names":["styles","root","display","flexDirection","gap","py","line","width","height","MarkdownSkeleton","t0","$","_c","lines","t1","undefined","t2","widths","Box","Array","from","length","map","_","i","jsx","Skeleton","createMarkdownDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","resolve","data","getData","blob","Blob","content","type","url","URL","createObjectURL","Promise","revoke","revokeObjectURL"],"mappings":";;;;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EA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,QAAQ;AAAA,QACrBO,KAAAA;AAAAA,QACAd,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1BkB,QAAQA,MAAMH,IAAII,gBAAgBL,CAAG;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EAAA,CACD,GACMlB;AACT;"}
1
+ {"version":3,"file":"markdown.js","sources":["../../src/widgets-v2/markdown/skeleton.tsx","../../src/widgets-v2/markdown/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 1,\n },\n line: (width: string): SxProps<Theme> => ({ width, height: 18 }),\n} as const\n\nexport interface MarkdownSkeletonProps {\n lines?: number\n}\n\nexport function MarkdownSkeleton({ lines = 5 }: MarkdownSkeletonProps) {\n // Vary widths to mimic prose.\n const widths = ['100%', '95%', '90%', '85%', '70%']\n return (\n <Box sx={styles.root}>\n {Array.from({ length: lines }).map((_, i) => (\n <Skeleton\n key={`line-${i}`}\n variant='rectangular'\n sx={styles.line(widths[i % widths.length] ?? '85%')}\n />\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n toCsvString,\n triggerLinkDownload,\n type DownloadItem,\n} from '../actions/download'\nimport type { MarkdownWidgetData } from './types'\n\n/**\n * Download menu items for the Markdown widget. Always includes a `.md`\n * item that saves the markdown source verbatim. When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createMarkdownDownloadConfig(args: {\n filename: string\n getData: () => MarkdownWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'md',\n label: 'Download as Markdown',\n resolve: () => {\n const data = args.getData()\n const blob = new Blob([data.content ?? ''], {\n type: 'text/markdown;charset=utf-8;',\n })\n const url = URL.createObjectURL(blob)\n return Promise.resolve({\n url,\n filename: `${args.filename}.md`,\n revoke: () => URL.revokeObjectURL(url),\n })\n },\n })\n return items\n}\n\n// Re-export pure helpers consumers may want when building a custom Download item.\nexport { toCsvString, triggerLinkDownload }\n"],"names":["styles","root","display","flexDirection","gap","py","line","width","height","MarkdownSkeleton","t0","$","_c","lines","t1","undefined","t2","widths","Box","Array","from","length","map","_","i","jsx","Skeleton","createMarkdownDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","resolve","data","getData","blob","Blob","content","type","url","URL","createObjectURL","Promise","revoke","revokeObjectURL"],"mappings":";;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EAAA;AAAA,EAENC,MAAMA,CAACC,OAAmC;AAAA,IAAEA,OAAAA;AAAAA,IAAOC,QAAQ;AAAA,EAAA;AAC7D;AAMO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAA0B;AAAA,IAAAC,OAAAC;AAAAA,EAAAA,IAAAJ,GAAEG,IAAAC,MAAAC,SAAA,IAAAD;AAAS,MAAAE;AAAA,MAAAL,SAAAE,GAAA;AAE1C,UAAAI,IAAe,CAAC,QAAQ,OAAO,OAAO,OAAO,KAAK;AAEhDD,IAAAA,sBAACE,GAAA,EAAQ,IAAAlB,EAAMC,MACZkB,gBAAKC,KAAM;AAAA,MAAAC,QAAUR;AAAAA,IAAAA,CAAO,EAACS,IAAK,CAAAC,GAAAC,MACjC,gBAAAC,EAACC,GAAA,EAES,SAAA,eACJ,IAAA1B,EAAMM,KAAMW,EAAOO,IAAIP,EAAMI,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