@carto/ps-react-ui 6.1.1 → 6.3.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.
Files changed (119) hide show
  1. package/dist/{actions-BWlS5tpP.js → actions-CkxKe8-J.js} +57 -47
  2. package/dist/actions-CkxKe8-J.js.map +1 -0
  3. package/dist/category-DULnoxvk.js +933 -0
  4. package/dist/category-DULnoxvk.js.map +1 -0
  5. package/dist/chat.js +1 -1
  6. package/dist/chat.js.map +1 -1
  7. package/dist/components-CTUpdQuj.js.map +1 -1
  8. package/dist/download-B4sykOFm.js.map +1 -1
  9. package/dist/{echart-CV8F50gn.js → echart-ysYFLa_T.js} +2 -2
  10. package/dist/echart-ysYFLa_T.js.map +1 -0
  11. package/dist/formula-DJS-JLpk.js.map +1 -1
  12. package/dist/{option-builders-DQivvvbb.js → item-color-B7xkIpDZ.js} +26 -9
  13. package/dist/item-color-B7xkIpDZ.js.map +1 -0
  14. package/dist/legend.js.map +1 -1
  15. package/dist/{markdown-Bn2nKCbn.js → markdown-DmvLi3vx.js} +2 -2
  16. package/dist/markdown-DmvLi3vx.js.map +1 -0
  17. package/dist/{markdown-content-kYNLOX0T.js → markdown-content-BpAH_V6S.js} +5 -4
  18. package/dist/markdown-content-BpAH_V6S.js.map +1 -0
  19. package/dist/range-BpU2zBmq.js.map +1 -1
  20. package/dist/smart-tooltip-Dc_rHhyI.js.map +1 -1
  21. package/dist/spread-CQwFIwuz.js.map +1 -1
  22. package/dist/stores-DcBOZlU3.js.map +1 -1
  23. package/dist/stores-mad-9yFn.js.map +1 -1
  24. package/dist/styles-BCEBm7xh.js.map +1 -1
  25. package/dist/table-DEdW_fDj.js.map +1 -1
  26. package/dist/types/widgets/bar/types.d.ts +6 -0
  27. package/dist/types/widgets/category/category-ui.d.ts +10 -2
  28. package/dist/types/widgets/category/category.d.ts +7 -1
  29. package/dist/types/widgets/category/components/category-bar-stacked.d.ts +8 -1
  30. package/dist/types/widgets/category/components/category-bar.d.ts +24 -2
  31. package/dist/types/widgets/category/components/category-row-multi.d.ts +3 -1
  32. package/dist/types/widgets/category/components/category-row-single.d.ts +3 -1
  33. package/dist/types/widgets/category/components/category-row-stacked.d.ts +10 -1
  34. package/dist/types/widgets/category/style.d.ts +33 -6
  35. package/dist/types/widgets/histogram/bins.d.ts +7 -0
  36. package/dist/types/widgets/histogram/download.d.ts +2 -2
  37. package/dist/types/widgets/histogram/index.d.ts +2 -1
  38. package/dist/types/widgets/histogram/options.d.ts +1 -1
  39. package/dist/types/widgets/histogram/transforms.d.ts +5 -4
  40. package/dist/types/widgets/histogram/types.d.ts +22 -5
  41. package/dist/types/widgets/index.d.ts +1 -1
  42. package/dist/types/widgets/pie/types.d.ts +6 -0
  43. package/dist/types/widgets/scatterplot/download.d.ts +2 -2
  44. package/dist/types/widgets/scatterplot/index.d.ts +2 -1
  45. package/dist/types/widgets/scatterplot/points.d.ts +7 -0
  46. package/dist/types/widgets/scatterplot/transforms.d.ts +4 -3
  47. package/dist/types/widgets/scatterplot/types.d.ts +21 -2
  48. package/dist/types/widgets/timeseries/types.d.ts +6 -0
  49. package/dist/types/widgets/utils/item-color.d.ts +26 -0
  50. package/dist/utils-C-eWwOhE.js.map +1 -1
  51. package/dist/widgets/actions.js +1 -1
  52. package/dist/widgets/bar.js +78 -70
  53. package/dist/widgets/bar.js.map +1 -1
  54. package/dist/widgets/category.js +1 -1
  55. package/dist/widgets/echart.js +1 -1
  56. package/dist/widgets/histogram.js +116 -85
  57. package/dist/widgets/histogram.js.map +1 -1
  58. package/dist/widgets/markdown.js +2 -2
  59. package/dist/widgets/pie.js +109 -90
  60. package/dist/widgets/pie.js.map +1 -1
  61. package/dist/widgets/scatterplot.js +131 -92
  62. package/dist/widgets/scatterplot.js.map +1 -1
  63. package/dist/widgets/timeseries.js +82 -74
  64. package/dist/widgets/timeseries.js.map +1 -1
  65. package/dist/widgets.js +5 -5
  66. package/dist/widgets.js.map +1 -1
  67. package/dist/zoom-toggle-MmLjMTEw.js.map +1 -1
  68. package/package.json +2 -2
  69. package/src/widgets/actions/fullscreen/fullscreen-store.test.tsx +77 -13
  70. package/src/widgets/actions/fullscreen/fullscreen.tsx +48 -5
  71. package/src/widgets/bar/options.test.ts +106 -0
  72. package/src/widgets/bar/options.ts +25 -14
  73. package/src/widgets/bar/types.ts +6 -0
  74. package/src/widgets/category/category-ui.test.tsx +139 -0
  75. package/src/widgets/category/category-ui.tsx +64 -11
  76. package/src/widgets/category/category.test.tsx +67 -0
  77. package/src/widgets/category/category.tsx +32 -15
  78. package/src/widgets/category/components/category-bar-stacked.test.tsx +18 -0
  79. package/src/widgets/category/components/category-bar-stacked.tsx +42 -29
  80. package/src/widgets/category/components/category-bar.test.tsx +66 -0
  81. package/src/widgets/category/components/category-bar.tsx +65 -9
  82. package/src/widgets/category/components/category-row-multi.tsx +21 -0
  83. package/src/widgets/category/components/category-row-single.tsx +4 -0
  84. package/src/widgets/category/components/category-row-stacked.tsx +24 -1
  85. package/src/widgets/category/style.ts +58 -14
  86. package/src/widgets/histogram/bins.ts +22 -0
  87. package/src/widgets/histogram/download.test.ts +10 -0
  88. package/src/widgets/histogram/download.ts +7 -3
  89. package/src/widgets/histogram/index.ts +3 -0
  90. package/src/widgets/histogram/options.test.ts +62 -0
  91. package/src/widgets/histogram/options.ts +38 -17
  92. package/src/widgets/histogram/transforms.test.ts +21 -7
  93. package/src/widgets/histogram/transforms.ts +26 -12
  94. package/src/widgets/histogram/types.ts +25 -5
  95. package/src/widgets/index.ts +6 -1
  96. package/src/widgets/pie/options.test.ts +91 -0
  97. package/src/widgets/pie/options.ts +50 -20
  98. package/src/widgets/pie/types.ts +6 -0
  99. package/src/widgets/scatterplot/download.test.ts +9 -0
  100. package/src/widgets/scatterplot/download.ts +5 -3
  101. package/src/widgets/scatterplot/index.ts +3 -0
  102. package/src/widgets/scatterplot/options.test.ts +78 -0
  103. package/src/widgets/scatterplot/options.ts +35 -11
  104. package/src/widgets/scatterplot/points.ts +35 -0
  105. package/src/widgets/scatterplot/transforms.test.ts +19 -0
  106. package/src/widgets/scatterplot/transforms.ts +23 -18
  107. package/src/widgets/scatterplot/types.ts +25 -2
  108. package/src/widgets/timeseries/options.test.ts +65 -0
  109. package/src/widgets/timeseries/options.ts +31 -14
  110. package/src/widgets/timeseries/types.ts +6 -0
  111. package/src/widgets/utils/item-color.test.ts +74 -0
  112. package/src/widgets/utils/item-color.ts +55 -0
  113. package/dist/actions-BWlS5tpP.js.map +0 -1
  114. package/dist/category-alzjKzvQ.js +0 -839
  115. package/dist/category-alzjKzvQ.js.map +0 -1
  116. package/dist/echart-CV8F50gn.js.map +0 -1
  117. package/dist/markdown-Bn2nKCbn.js.map +0 -1
  118. package/dist/markdown-content-kYNLOX0T.js.map +0 -1
  119. package/dist/option-builders-DQivvvbb.js.map +0 -1
@@ -8,15 +8,38 @@ export declare const styles: {
8
8
  width: string;
9
9
  };
10
10
  list: {
11
+ position: string;
11
12
  display: string;
12
- flexDirection: string;
13
+ gridTemplateColumns: string;
13
14
  gap: number;
14
15
  py: number;
15
16
  };
17
+ listMulti: {
18
+ gridTemplateColumns: string;
19
+ };
20
+ barWrap: {
21
+ position: string;
22
+ };
23
+ multiZeroArea: {
24
+ position: string;
25
+ inset: number;
26
+ gridColumn: string;
27
+ pointerEvents: string;
28
+ };
29
+ zeroTick: {
30
+ position: string;
31
+ top: number;
32
+ bottom: number;
33
+ width: string;
34
+ transform: string;
35
+ bgcolor: string;
36
+ pointerEvents: string;
37
+ };
16
38
  listScroll: {
17
39
  pr: number;
18
40
  };
19
41
  rowSingle: {
42
+ gridColumn: string;
20
43
  display: string;
21
44
  flexDirection: string;
22
45
  gap: number;
@@ -39,9 +62,11 @@ export declare const styles: {
39
62
  gap: number;
40
63
  };
41
64
  rowMulti: {
65
+ position: string;
66
+ gridColumn: string;
42
67
  display: string;
43
- flexDirection: string;
44
- gap: number;
68
+ gridTemplateColumns: string;
69
+ rowGap: number;
45
70
  cursor: string;
46
71
  userSelect: string;
47
72
  transition: string;
@@ -62,6 +87,7 @@ export declare const styles: {
62
87
  fontWeight: string;
63
88
  };
64
89
  multiName: {
90
+ gridColumn: string;
65
91
  overflow: string;
66
92
  whiteSpace: string;
67
93
  textOverflow: string;
@@ -73,19 +99,19 @@ export declare const styles: {
73
99
  fontVariantNumeric: string;
74
100
  minWidth: number;
75
101
  textAlign: string;
102
+ alignSelf: string;
76
103
  };
77
104
  bar: Record<CategorySize, SxProps<Theme>>;
78
105
  barFill: Record<CategorySize, SxProps<Theme>>;
79
106
  stackedSegment: Record<CategorySize, SxProps<Theme>>;
80
107
  multiBarRow: {
81
108
  display: string;
82
- alignItems: string;
83
- gap: number;
84
109
  };
85
110
  multiBarContainer: {
86
- flex: number;
111
+ alignSelf: string;
87
112
  };
88
113
  rowStacked: {
114
+ gridColumn: string;
89
115
  display: string;
90
116
  flexDirection: string;
91
117
  gap: number;
@@ -160,6 +186,7 @@ export declare const styles: {
160
186
  fontWeight: string;
161
187
  };
162
188
  otherRow: {
189
+ gridColumn: string;
163
190
  display: string;
164
191
  alignItems: string;
165
192
  gap: number;
@@ -0,0 +1,7 @@
1
+ import { HistogramBin } from './types.js';
2
+ /** Count of a {@link HistogramBin}, whichever form it takes. */
3
+ export declare function getHistogramBinValue(bin: HistogramBin): number;
4
+ /** Whether `v` is a valid {@link HistogramBin} with a finite count. */
5
+ export declare function isHistogramBin(v: unknown): v is HistogramBin;
6
+ /** Same bin with its count replaced; keeps the object form (and `color`). */
7
+ export declare function withHistogramBinValue(bin: HistogramBin, value: number): HistogramBin;
@@ -1,12 +1,12 @@
1
1
  import { DownloadItem, WidgetDownloadArgs } from '../actions/download/index.js';
2
- import { HistogramWidgetData } from './types.js';
2
+ import { HistogramBin, HistogramWidgetData } from './types.js';
3
3
  /**
4
4
  * Download menu items for histograms. Always includes a CSV item with
5
5
  * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row
6
6
  * per bin). When `getCaptureEl` is given, prepends a PNG item that
7
7
  * rasterises the captured element via `html2canvas`.
8
8
  */
9
- export declare function createHistogramDownloadConfig(args: WidgetDownloadArgs<HistogramWidgetData> & {
9
+ export declare function createHistogramDownloadConfig(args: WidgetDownloadArgs<HistogramWidgetData<HistogramBin>> & {
10
10
  getTicks: () => readonly number[];
11
11
  seriesNames?: readonly string[];
12
12
  }): DownloadItem[];
@@ -2,4 +2,5 @@ export { histogramOptions, createHistogramOptionFactory } from './options.js';
2
2
  export { HistogramSkeleton, type HistogramSkeletonProps } from './skeleton.js';
3
3
  export { createHistogramDownloadConfig } from './download.js';
4
4
  export { toRelativeHistogramData, filterHistogramByLockedBins, } from './transforms.js';
5
- export type { HistogramWidgetData, HistogramOptionsInput, HistogramOptionFactoryInput, HistogramEChartsOption, } from './types.js';
5
+ export { getHistogramBinValue } from './bins.js';
6
+ export type { HistogramBin, HistogramBinObject, HistogramWidgetData, HistogramOptionsInput, HistogramOptionFactoryInput, HistogramEChartsOption, } from './types.js';
@@ -31,7 +31,7 @@ export declare function histogramOptions({ theme, formatter, }: HistogramOptions
31
31
  * the consumer-supplied `optionsOverride`. Called once by Provider to
32
32
  * seed `rawOptions` in the store.
33
33
  * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`
34
- * (`HistogramWidgetData` — `number[][]`) into the option via the
34
+ * (`HistogramWidgetData` — `HistogramBin[][]`) into the option via the
35
35
  * dataset API. Each series gets its own dataset of `[binLabel, count]`
36
36
  * pairs derived from `ticks`; series reference their dataset by
37
37
  * `datasetIndex` and are encoded by column position. Reactive
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Histogram-specific `RelativeData` transform. Histogram data is
3
- * `number[][]` — each series is a flat list of bin counts. This
3
+ * `HistogramBin[][]` — each series is a flat list of bin counts (plain
4
+ * numbers or `{ value, color? }`, whose shape is kept). This
4
5
  * rewrites each count to its share of the series total (0–100), so
5
6
  * pairing with `createPercentFormatter` renders the y-axis as
6
7
  * percentages.
@@ -11,13 +12,13 @@
11
12
  * inputs produce sane signed shares-of-magnitude. A series whose total
12
13
  * magnitude is zero (all-zero or empty input) is returned unchanged so
13
14
  * a stalled or empty data set doesn't show misleading 0% values. Inputs
14
- * whose shape isn't `number[][]` fall through untouched (same defensive
15
+ * whose shape isn't `HistogramBin[][]` fall through untouched (same defensive
15
16
  * shape-check pattern as the default transform).
16
17
  */
17
18
  export declare const toRelativeHistogramData: (input: unknown) => unknown;
18
19
  /**
19
- * `LockSelection` filter for Histogram. Data is `number[][]` — a flat list
20
- * of bin counts per series, positionally paired with `ticks` (bin `i` covers
20
+ * `LockSelection` filter for Histogram. Data is `HistogramBin[][]` — a flat
21
+ * list of bin counts per series, positionally paired with `ticks` (bin `i` covers
21
22
  * `[ticks[i], ticks[i+1])`). Unlike name-keyed widgets, locked-out bins can't
22
23
  * be REMOVED — that would shift every later bin's index and desync it from
23
24
  * its `ticks` range. Zeroing them out instead preserves array length/position,
@@ -2,12 +2,29 @@ import { Theme } from '@mui/material';
2
2
  import { EChartsOption } from 'echarts';
3
3
  import { WidgetSeries } from '../types.js';
4
4
  /**
5
- * Histogram widget data — array of series, each a flat array of bin counts.
6
- * The option factory's merge phase (see {@link createHistogramOptionFactory})
7
- * combines this with `ticks` to produce a 2-column dataset (`[binLabel, count]`)
8
- * for ECharts.
5
+ * One histogram bin: either its count, or `{ value, color? }` to give the
6
+ * bar its own colour (CSS colour or theme palette path such as
7
+ * `'primary.main'`). A bin `color` wins over the template's
8
+ * `itemStyle.color` and the series colour; selection dimming still applies.
9
9
  */
10
- export type HistogramWidgetData = readonly (readonly number[])[];
10
+ export type HistogramBin = number | HistogramBinObject;
11
+ /** Object form of a {@link HistogramBin}. */
12
+ export interface HistogramBinObject {
13
+ value: number;
14
+ color?: string;
15
+ }
16
+ /**
17
+ * Histogram widget data — array of series, each a flat array of bins. The
18
+ * option factory's merge phase (see {@link createHistogramOptionFactory})
19
+ * combines this with `ticks` to produce a 2-column dataset
20
+ * (`[binLabel, count]`) for ECharts.
21
+ *
22
+ * Defaults to plain counts (`number[][]`) so existing code that reads bins
23
+ * as numbers keeps type-checking; use `HistogramWidgetData<HistogramBin>`
24
+ * to also accept `{ value, color? }` bins. Every histogram API (option
25
+ * factory, transforms, download) accepts both forms.
26
+ */
27
+ export type HistogramWidgetData<B extends HistogramBin = number> = readonly (readonly B[])[];
11
28
  /** Inputs to the structural-only {@link histogramOptions} builder. */
12
29
  export interface HistogramOptionsInput {
13
30
  theme: Theme;
@@ -101,7 +101,7 @@ export type { FormulaUIProps, FormulaDataItem, FormulaWidgetData, } from './form
101
101
  export type { MarkdownUIProps, MarkdownWidgetData } from './markdown/index.js';
102
102
  export type { PieDatum, PieWidgetData } from './pie/index.js';
103
103
  export type { TimeseriesDatum, TimeseriesWidgetData } from './timeseries/index.js';
104
- export type { ScatterplotDatum, ScatterplotWidgetData } from './scatterplot/index.js';
104
+ export type { ScatterplotDatum, ScatterplotPoint, ScatterplotItem, ScatterplotWidgetData, } from './scatterplot/index.js';
105
105
  export type { SpreadUIProps, SpreadDataItem, SpreadWidgetData, SpreadVariant, } from './spread/index.js';
106
106
  export type { RangeProps, RangeUIProps, RangeDataItem, RangeWidgetData, RangeItemValue, } from './range/index.js';
107
107
  export type { CategoryProps, CategoryUIProps, CategoryDataItem, CategoryWidgetData, CategoryKey, CategorySeriesConfig, CategoryLabels, } from './category/index.js';
@@ -5,6 +5,12 @@ import { WidgetSeries } from '../types.js';
5
5
  export interface PieDatum {
6
6
  name: string | number;
7
7
  value: number;
8
+ /**
9
+ * Optional colour for this item (CSS colour or theme palette path such as
10
+ * `'primary.main'`). Wins over the template's `itemStyle.color` and the
11
+ * series colour; selection dimming still applies on top.
12
+ */
13
+ color?: string;
8
14
  }
9
15
  /** Pie widget data — one slice array per series (rendered as side-by-side donuts). */
10
16
  export type PieWidgetData = readonly (readonly PieDatum[])[];
@@ -1,11 +1,11 @@
1
1
  import { DownloadItem, WidgetDownloadArgs } from '../actions/download/index.js';
2
- import { ScatterplotWidgetData } from './types.js';
2
+ import { ScatterplotItem, ScatterplotWidgetData } from './types.js';
3
3
  /**
4
4
  * Download menu items for the Scatterplot widget. Always includes a CSV item
5
5
  * with `series, x, y` columns (one row per point). When `getCaptureEl` is
6
6
  * given, prepends a PNG item that rasterises the captured element via
7
7
  * `html2canvas`.
8
8
  */
9
- export declare function createScatterplotDownloadConfig(args: WidgetDownloadArgs<ScatterplotWidgetData> & {
9
+ export declare function createScatterplotDownloadConfig(args: WidgetDownloadArgs<ScatterplotWidgetData<ScatterplotItem>> & {
10
10
  seriesNames?: readonly string[];
11
11
  }): DownloadItem[];
@@ -2,4 +2,5 @@ export { scatterplotOptions, createScatterplotOptionFactory } from './options.js
2
2
  export { ScatterplotSkeleton, type ScatterplotSkeletonProps } from './skeleton.js';
3
3
  export { createScatterplotDownloadConfig } from './download.js';
4
4
  export { toRelativeScatterplotData, filterScatterplotByLockedPoints, } from './transforms.js';
5
- export type { ScatterplotDatum, ScatterplotWidgetData, ScatterplotOptionsInput, ScatterplotOptionFactoryInput, ScatterplotEChartsOption, } from './types.js';
5
+ export { getScatterplotXY } from './points.js';
6
+ export type { ScatterplotDatum, ScatterplotPoint, ScatterplotItem, ScatterplotWidgetData, ScatterplotOptionsInput, ScatterplotOptionFactoryInput, ScatterplotEChartsOption, } from './types.js';
@@ -0,0 +1,7 @@
1
+ import { ScatterplotItem } from './types.js';
2
+ /** `[x, y]` of a {@link ScatterplotItem}, whichever form it takes. */
3
+ export declare function getScatterplotXY(point: ScatterplotItem): readonly [number, number];
4
+ /** Whether `v` is a valid {@link ScatterplotItem} with finite coordinates. */
5
+ export declare function isScatterplotDatum(v: unknown): v is ScatterplotItem;
6
+ /** Same point with new coordinates; keeps the object form (and `color`). */
7
+ export declare function withScatterplotXY(point: ScatterplotItem, x: number, y: number): ScatterplotItem;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Scatterplot-specific `RelativeData` transform. Scatter data is
3
- * `[number, number][]` — each series is a list of `[x, y]` tuples.
3
+ * `ScatterplotItem[][]` — each series is a list of `[x, y]` tuples or
4
+ * `{ x, y, color? }` points (whose shape is kept).
4
5
  * Relative is a values-axis concept, so this rewrites `y` to its
5
6
  * share of the series's total `y` (0–100) and leaves `x` raw — x is
6
7
  * coordinate space, not part of the cohort total.
@@ -11,12 +12,12 @@
11
12
  * y values produce sane signed shares-of-magnitude. A series whose
12
13
  * total y-magnitude is zero (all-zero or empty input) is returned
13
14
  * unchanged so a stalled or empty data set doesn't show misleading 0%
14
- * values. Inputs whose shape isn't `[number, number][]` fall through
15
+ * values. Inputs whose shape isn't `ScatterplotItem[]` fall through
15
16
  * untouched.
16
17
  */
17
18
  export declare const toRelativeScatterplotData: (input: unknown) => unknown;
18
19
  /**
19
- * `LockSelection` filter for Scatterplot. Data is `[number, number][][]` —
20
+ * `LockSelection` filter for Scatterplot. Data is `ScatterplotItem[][]` —
20
21
  * points have no `name`, so selection (and locking) is keyed on a synthetic
21
22
  * `${seriesIndex}:${dataIndex}` string (same format `useChartSelection`'s
22
23
  * `keyFromClick`/`keysFromBrush` produce for this widget). Unlike Histogram,
@@ -3,8 +3,27 @@ import { EChartsOption } from 'echarts';
3
3
  import { WidgetSeries } from '../types.js';
4
4
  /** A single point — `[x, y]` tuple. */
5
5
  export type ScatterplotDatum = readonly [number, number];
6
- /** Scatterplot widget data — array of series, each a list of `[x, y]` tuples. */
7
- export type ScatterplotWidgetData = readonly (readonly ScatterplotDatum[])[];
6
+ /**
7
+ * Object form of a point, to give it its own colour. `color` (CSS colour or
8
+ * theme palette path such as `'primary.main'`) wins over the template's
9
+ * `itemStyle.color` and the series colour; selection dimming still applies.
10
+ */
11
+ export interface ScatterplotPoint {
12
+ x: number;
13
+ y: number;
14
+ color?: string;
15
+ }
16
+ /** Any accepted point: an `[x, y]` tuple or a {@link ScatterplotPoint}. */
17
+ export type ScatterplotItem = ScatterplotDatum | ScatterplotPoint;
18
+ /**
19
+ * Scatterplot widget data — array of series, each a list of points.
20
+ *
21
+ * Defaults to `[x, y]` tuples so existing code that destructures points
22
+ * keeps type-checking; use `ScatterplotWidgetData<ScatterplotItem>` to also
23
+ * accept `{ x, y, color? }` points. Every scatterplot API (option factory,
24
+ * transforms, download) accepts both forms.
25
+ */
26
+ export type ScatterplotWidgetData<P extends ScatterplotItem = ScatterplotDatum> = readonly (readonly P[])[];
8
27
  /** Inputs to the structural-only {@link scatterplotOptions} builder. */
9
28
  export interface ScatterplotOptionsInput {
10
29
  theme: Theme;
@@ -9,6 +9,12 @@ import { WidgetSeries } from '../types.js';
9
9
  export interface TimeseriesDatum {
10
10
  name: Date | number | string;
11
11
  value: number;
12
+ /**
13
+ * Optional colour for this item (CSS colour or theme palette path such as
14
+ * `'primary.main'`). Wins over the template's `itemStyle.color` and the
15
+ * series colour; selection dimming still applies on top.
16
+ */
17
+ color?: string;
12
18
  }
13
19
  /** Timeseries widget data — one array of points per series. */
14
20
  export type TimeseriesWidgetData = readonly (readonly TimeseriesDatum[])[];
@@ -0,0 +1,26 @@
1
+ import { Theme } from '@mui/material';
2
+ import { CallbackDataParams } from 'echarts/types/dist/shared';
3
+ /** ECharts `itemStyle.color` callback, as emitted by the chart widgets. */
4
+ export type ItemColorCallback = (params: CallbackDataParams) => string;
5
+ /**
6
+ * Builds the callback that resolves the **base** colour of every item of one
7
+ * series, before any selection dimming. Priority:
8
+ *
9
+ * 1. the datum's own `color` (`datums[params.dataIndex].color`);
10
+ * 2. the consumer's `template.itemStyle.color` (from `optionsOverride`):
11
+ * a string is used as is, a function is called with the ECharts params;
12
+ * 3. `fallback` — the widget's default (series colour / palette).
13
+ *
14
+ * The datum is looked up by `params.dataIndex` in the widget's own data
15
+ * rather than read off `params.data`, so it works whatever the dataset row
16
+ * shape is (object rows, `[label, count]` tuples, `[x, y]` tuples).
17
+ *
18
+ * Datum and template colours go through {@link resolveThemeColor}, same as
19
+ * per-series colours, so palette paths such as `'primary.main'` work.
20
+ */
21
+ export declare function createItemColorResolver({ theme, datums, template, fallback, }: {
22
+ theme: Theme;
23
+ datums: readonly unknown[];
24
+ template: unknown;
25
+ fallback: ItemColorCallback;
26
+ }): ItemColorCallback;
@@ -1 +1 @@
1
- {"version":3,"file":"utils-C-eWwOhE.js","names":[],"sources":["../src/widgets/utils/merge-options.ts","../src/widgets/utils/data-zoom-layout.ts","../src/widgets/utils/resolve-theme-color.ts"],"sourcesContent":["/**\n * Shallow-merges two ECharts option objects:\n * - Top-level keys from both are combined.\n * - Arrays are merged by index (element-wise shallow merge, primitive override).\n * - Plain objects are shallow-merged.\n * - Primitives are overridden by the override value.\n *\n * Designed for the two-stage memoization pattern: first build a base option\n * object from data + theme + formatters, then call `mergeOptions(base, override)`\n * inside a second `useMemo` keyed on `[base, override]`.\n */\nexport function mergeOptions<T extends Record<string, unknown>>(\n base: T,\n override?: Partial<T>,\n): T {\n if (!override) return base\n const out: Record<string, unknown> = { ...base }\n for (const key of Object.keys(override) as (keyof T)[]) {\n const a = base[key]\n const b = override[key]\n if (b === undefined) continue\n out[key as string] = mergeValue(a, b)\n }\n return out as T\n}\n\nfunction mergeValue(a: unknown, b: unknown): unknown {\n if (Array.isArray(a) && Array.isArray(b)) {\n const len = Math.max(a.length, b.length)\n const result = new Array<unknown>(len)\n for (let i = 0; i < len; i++) {\n const av: unknown = a[i]\n const bv: unknown = b[i]\n if (bv === undefined) result[i] = av\n else if (av === undefined) result[i] = bv\n else result[i] = mergeValue(av, bv)\n }\n return result\n }\n if (isPlainObject(a) && isPlainObject(b)) {\n return { ...a, ...b }\n }\n return b\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n if (v === null || typeof v !== 'object') return false\n const proto = Object.getPrototypeOf(v) as unknown\n return proto === Object.prototype || proto === null\n}\n","import { ZOOM_LAYOUT } from '../actions/zoom-toggle'\n\n/**\n * If the option includes a `dataZoom` array (from ZoomToggle's transform),\n * lift any slider entries above the legend row so they don't overlap.\n * Returns `null` when there is no `dataZoom` — caller skips the layout\n * adjustment entirely.\n *\n * Shared between bar, histogram, and timeseries — every widget with a\n * horizontal x-axis dataZoom slider needs the same offset when a legend\n * is rendered below the plot.\n */\nexport function positionDataZoomForLegend(\n dataZoom: unknown,\n hasLegend: boolean,\n): unknown[] | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n return dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as { type?: string; bottom?: number }\n if (dz.type === 'slider' && hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n}\n","import type { Theme } from '@mui/material'\n\n/**\n * Resolve a colour string against the MUI theme palette.\n *\n * - `'primary.main'`, `'secondary.dark'`, `'success.contrastText'`, … →\n * walks `theme.palette` along the dot-separated path and returns the\n * resolved string when traversal succeeds.\n * - `'#ff0000'`, `'rgb(255, 0, 0)'`, `'red'` → returned as-is (assumed\n * raw CSS; ECharts consumes them directly).\n * - `undefined` → `undefined` (callers fall back to ECharts' palette).\n *\n * Used by the echart option factories (Bar, Pie, Histogram, Scatterplot,\n * Timeseries) so per-series colours specified as theme paths in the\n * unified `WidgetSeries` shape paint correctly. Category, Formula, and\n * Spread render colours through MUI's `sx` resolver, which already\n * handles theme paths — they don't need this helper.\n */\nexport function resolveThemeColor(\n theme: Theme,\n raw: string | undefined,\n): string | undefined {\n if (raw == null) return undefined\n if (!raw.includes('.')) return raw\n const parts = raw.split('.')\n let cursor: unknown = theme.palette\n for (const part of parts) {\n if (cursor == null || typeof cursor !== 'object') {\n return raw\n }\n cursor = (cursor as Record<string, unknown>)[part]\n }\n return typeof cursor === 'string' ? cursor : raw\n}\n"],"mappings":";;AAWA,SAAgB,EACd,GACA,GACG;CACH,IAAI,CAAC,GAAU,OAAO;CACtB,IAAM,IAA+B,EAAE,GAAG,EAAK;CAC/C,KAAK,IAAM,KAAO,OAAO,KAAK,CAAQ,GAAkB;EACtD,IAAM,IAAI,EAAK,IACT,IAAI,EAAS;EACf,MAAM,KAAA,MACV,EAAI,KAAiB,EAAW,GAAG,CAAC;CACtC;CACA,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C/C"}
1
+ {"version":3,"file":"utils-C-eWwOhE.js","names":["ZOOM_LAYOUT","mergeOptions","override","base","out","key","b","mergeValue","a","len","result","i","av","bv","isPlainObject","v","proto","positionDataZoomForLegend","dataZoom","entry","dz","hasLegend","resolveThemeColor","raw","parts","cursor","theme","part"],"sources":["../src/widgets/utils/merge-options.ts","../src/widgets/utils/data-zoom-layout.ts","../src/widgets/utils/resolve-theme-color.ts"],"sourcesContent":["/**\n * Shallow-merges two ECharts option objects:\n * - Top-level keys from both are combined.\n * - Arrays are merged by index (element-wise shallow merge, primitive override).\n * - Plain objects are shallow-merged.\n * - Primitives are overridden by the override value.\n *\n * Designed for the two-stage memoization pattern: first build a base option\n * object from data + theme + formatters, then call `mergeOptions(base, override)`\n * inside a second `useMemo` keyed on `[base, override]`.\n */\nexport function mergeOptions<T extends Record<string, unknown>>(\n base: T,\n override?: Partial<T>,\n): T {\n if (!override) return base\n const out: Record<string, unknown> = { ...base }\n for (const key of Object.keys(override) as (keyof T)[]) {\n const a = base[key]\n const b = override[key]\n if (b === undefined) continue\n out[key as string] = mergeValue(a, b)\n }\n return out as T\n}\n\nfunction mergeValue(a: unknown, b: unknown): unknown {\n if (Array.isArray(a) && Array.isArray(b)) {\n const len = Math.max(a.length, b.length)\n const result = new Array<unknown>(len)\n for (let i = 0; i < len; i++) {\n const av: unknown = a[i]\n const bv: unknown = b[i]\n if (bv === undefined) result[i] = av\n else if (av === undefined) result[i] = bv\n else result[i] = mergeValue(av, bv)\n }\n return result\n }\n if (isPlainObject(a) && isPlainObject(b)) {\n return { ...a, ...b }\n }\n return b\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n if (v === null || typeof v !== 'object') return false\n const proto = Object.getPrototypeOf(v) as unknown\n return proto === Object.prototype || proto === null\n}\n","import { ZOOM_LAYOUT } from '../actions/zoom-toggle'\n\n/**\n * If the option includes a `dataZoom` array (from ZoomToggle's transform),\n * lift any slider entries above the legend row so they don't overlap.\n * Returns `null` when there is no `dataZoom` — caller skips the layout\n * adjustment entirely.\n *\n * Shared between bar, histogram, and timeseries — every widget with a\n * horizontal x-axis dataZoom slider needs the same offset when a legend\n * is rendered below the plot.\n */\nexport function positionDataZoomForLegend(\n dataZoom: unknown,\n hasLegend: boolean,\n): unknown[] | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n return dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as { type?: string; bottom?: number }\n if (dz.type === 'slider' && hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n}\n","import type { Theme } from '@mui/material'\n\n/**\n * Resolve a colour string against the MUI theme palette.\n *\n * - `'primary.main'`, `'secondary.dark'`, `'success.contrastText'`, … →\n * walks `theme.palette` along the dot-separated path and returns the\n * resolved string when traversal succeeds.\n * - `'#ff0000'`, `'rgb(255, 0, 0)'`, `'red'` → returned as-is (assumed\n * raw CSS; ECharts consumes them directly).\n * - `undefined` → `undefined` (callers fall back to ECharts' palette).\n *\n * Used by the echart option factories (Bar, Pie, Histogram, Scatterplot,\n * Timeseries) so per-series colours specified as theme paths in the\n * unified `WidgetSeries` shape paint correctly. Category, Formula, and\n * Spread render colours through MUI's `sx` resolver, which already\n * handles theme paths — they don't need this helper.\n */\nexport function resolveThemeColor(\n theme: Theme,\n raw: string | undefined,\n): string | undefined {\n if (raw == null) return undefined\n if (!raw.includes('.')) return raw\n const parts = raw.split('.')\n let cursor: unknown = theme.palette\n for (const part of parts) {\n if (cursor == null || typeof cursor !== 'object') {\n return raw\n }\n cursor = (cursor as Record<string, unknown>)[part]\n }\n return typeof cursor === 'string' ? cursor : raw\n}\n"],"mappings":";;AAWA,SAAgBC,EACd,GACA,GACG;CACH,IAAI,CAACC,GAAU,OAAOC;CACtB,IAAMC,IAA+B,EAAE,GAAGD,EAAK;CAC/C,KAAK,IAAME,KAAO,OAAO,KAAKH,CAAQ,GAAkB;EACtD,IAAM,IAAIC,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I,MAAM,GAAG,GACvBE,IAAkBC,EAAM;CAC5B,KAAK,IAAMC,KAAQH,GAAO;EACxB,IAAsB,OAAOC,KAAW,aAApCA,GACF,OAAOF;EAET,IAAUE,EAAmCE;CAC/C;CACA,OAAO,OAAOF,KAAW,WAAWA,IAASF;AAC/C"}
@@ -1,4 +1,4 @@
1
- import { C as e, E as t, S as n, T as r, _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as v, s as y, t as b, u as x, v as S, w as C, x as w, y as T } from "../actions-BWlS5tpP.js";
1
+ import { C as e, E as t, S as n, T as r, _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as v, s as y, t as b, u as x, v as S, w as C, x as w, y as T } from "../actions-CkxKe8-J.js";
2
2
  import { a as E, i as D, n as O, r as k, t as A } from "../zoom-toggle-MmLjMTEw.js";
3
3
  import { a as j, c as M, d as N, f as P, i as F, l as I, n as L, o as R, p as z, r as B, s as V, t as H, u as U } from "../download-B4sykOFm.js";
4
4
  export { l as BrushToggle, j as CSVIcon, b as ChangeColumn, _ as DEFAULT_BRUSH_TOGGLE_LABELS, h as DEFAULT_CHANGE_COLUMN_LABELS, I as DEFAULT_DOWNLOAD_LABELS, y as DEFAULT_FULLSCREEN_LABELS, f as DEFAULT_LOCK_SELECTION_LABELS, p as DEFAULT_RELATIVE_DATA_LABELS, r as DEFAULT_SEARCHER_LABELS, S as DEFAULT_SHOW_ALL_LABELS, o as DEFAULT_STACK_TOGGLE_LABELS, O as DEFAULT_ZOOM_TOGGLE_LABELS, F as DOWNLOAD_ITEM_IDS, M as Download, g as FullScreen, v as LockSelection, R as MarkdownIcon, V as PNGIcon, s as RelativeData, d as SHOW_ALL_ID, n as Searcher, e as SearcherToggle, u as ShowAllToggle, T as StackToggle, k as ZOOM_LAYOUT, A as ZoomToggle, m as addBrush, w as addStack, D as addZoom, L as buildCsvDownloadItem, B as buildPngDownloadItem, E as createAddZoom, x as createPercentFormatter, U as downloadDOMToPNG, N as downloadToCSV, a as filterByLockedItems, t as filterBySearchText, C as setSearcherText, i as setShowAll, P as toCsvString, c as toRelativeData, z as triggerLinkDownload, H as withPngItem };