@carto/ps-react-ui 5.4.0 → 5.5.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 (67) hide show
  1. package/dist/{actions-Dhlz_adK.js → actions-CwjqEm8Y.js} +56 -46
  2. package/dist/actions-CwjqEm8Y.js.map +1 -0
  3. package/dist/item-color-ZYxH3NM5.js +20 -0
  4. package/dist/item-color-ZYxH3NM5.js.map +1 -0
  5. package/dist/types/widgets-v2/bar/types.d.ts +6 -0
  6. package/dist/types/widgets-v2/histogram/bins.d.ts +7 -0
  7. package/dist/types/widgets-v2/histogram/download.d.ts +2 -2
  8. package/dist/types/widgets-v2/histogram/index.d.ts +2 -1
  9. package/dist/types/widgets-v2/histogram/options.d.ts +1 -1
  10. package/dist/types/widgets-v2/histogram/transforms.d.ts +5 -4
  11. package/dist/types/widgets-v2/histogram/types.d.ts +22 -5
  12. package/dist/types/widgets-v2/index.d.ts +1 -1
  13. package/dist/types/widgets-v2/pie/types.d.ts +6 -0
  14. package/dist/types/widgets-v2/scatterplot/download.d.ts +2 -2
  15. package/dist/types/widgets-v2/scatterplot/index.d.ts +2 -1
  16. package/dist/types/widgets-v2/scatterplot/points.d.ts +7 -0
  17. package/dist/types/widgets-v2/scatterplot/transforms.d.ts +4 -3
  18. package/dist/types/widgets-v2/scatterplot/types.d.ts +21 -2
  19. package/dist/types/widgets-v2/timeseries/types.d.ts +6 -0
  20. package/dist/types/widgets-v2/utils/item-color.d.ts +26 -0
  21. package/dist/widgets-v2/actions.js +1 -1
  22. package/dist/widgets-v2/bar.js +66 -57
  23. package/dist/widgets-v2/bar.js.map +1 -1
  24. package/dist/widgets-v2/histogram.js +103 -71
  25. package/dist/widgets-v2/histogram.js.map +1 -1
  26. package/dist/widgets-v2/pie.js +98 -78
  27. package/dist/widgets-v2/pie.js.map +1 -1
  28. package/dist/widgets-v2/scatterplot.js +119 -79
  29. package/dist/widgets-v2/scatterplot.js.map +1 -1
  30. package/dist/widgets-v2/timeseries.js +70 -61
  31. package/dist/widgets-v2/timeseries.js.map +1 -1
  32. package/dist/widgets-v2.js +1 -1
  33. package/dist/widgets-v2.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/widgets-v2/actions/fullscreen/fullscreen-store.test.tsx +77 -13
  36. package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +48 -5
  37. package/src/widgets-v2/bar/options.test.ts +106 -0
  38. package/src/widgets-v2/bar/options.ts +25 -14
  39. package/src/widgets-v2/bar/types.ts +6 -0
  40. package/src/widgets-v2/histogram/bins.ts +22 -0
  41. package/src/widgets-v2/histogram/download.test.ts +10 -0
  42. package/src/widgets-v2/histogram/download.ts +7 -3
  43. package/src/widgets-v2/histogram/index.ts +3 -0
  44. package/src/widgets-v2/histogram/options.test.ts +62 -0
  45. package/src/widgets-v2/histogram/options.ts +38 -17
  46. package/src/widgets-v2/histogram/transforms.test.ts +21 -7
  47. package/src/widgets-v2/histogram/transforms.ts +26 -12
  48. package/src/widgets-v2/histogram/types.ts +25 -5
  49. package/src/widgets-v2/index.ts +6 -1
  50. package/src/widgets-v2/pie/options.test.ts +91 -0
  51. package/src/widgets-v2/pie/options.ts +50 -20
  52. package/src/widgets-v2/pie/types.ts +6 -0
  53. package/src/widgets-v2/scatterplot/download.test.ts +9 -0
  54. package/src/widgets-v2/scatterplot/download.ts +5 -3
  55. package/src/widgets-v2/scatterplot/index.ts +3 -0
  56. package/src/widgets-v2/scatterplot/options.test.ts +78 -0
  57. package/src/widgets-v2/scatterplot/options.ts +35 -11
  58. package/src/widgets-v2/scatterplot/points.ts +35 -0
  59. package/src/widgets-v2/scatterplot/transforms.test.ts +19 -0
  60. package/src/widgets-v2/scatterplot/transforms.ts +23 -18
  61. package/src/widgets-v2/scatterplot/types.ts +25 -2
  62. package/src/widgets-v2/timeseries/options.test.ts +65 -0
  63. package/src/widgets-v2/timeseries/options.ts +31 -14
  64. package/src/widgets-v2/timeseries/types.ts +6 -0
  65. package/src/widgets-v2/utils/item-color.test.ts +74 -0
  66. package/src/widgets-v2/utils/item-color.ts +55 -0
  67. package/dist/actions-Dhlz_adK.js.map +0 -1
@@ -0,0 +1,20 @@
1
+ import { t as e } from "./utils-Dr6gf3vD.js";
2
+ //#region src/widgets-v2/utils/item-color.ts
3
+ function t({ theme: t, datums: r, template: i, fallback: a }) {
4
+ let o = i?.itemStyle?.color;
5
+ return (i) => {
6
+ let s = n(r[i.dataIndex]);
7
+ if (s) return e(t, s);
8
+ let c = typeof o == "function" ? o(i) : o;
9
+ return typeof c == "string" && c !== "" ? e(t, c) : a(i);
10
+ };
11
+ }
12
+ function n(e) {
13
+ if (typeof e != "object" || !e) return;
14
+ let t = e.color;
15
+ return typeof t == "string" && t !== "" ? t : void 0;
16
+ }
17
+ //#endregion
18
+ export { t };
19
+
20
+ //# sourceMappingURL=item-color-ZYxH3NM5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-color-ZYxH3NM5.js","names":[],"sources":["../src/widgets-v2/utils/item-color.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport { resolveThemeColor } from './resolve-theme-color'\n\n/** ECharts `itemStyle.color` callback, as emitted by the chart widgets. */\nexport type ItemColorCallback = (params: CallbackDataParams) => string\n\n/**\n * Builds the callback that resolves the **base** colour of every item of one\n * series, before any selection dimming. Priority:\n *\n * 1. the datum's own `color` (`datums[params.dataIndex].color`);\n * 2. the consumer's `template.itemStyle.color` (from `optionsOverride`):\n * a string is used as is, a function is called with the ECharts params;\n * 3. `fallback` — the widget's default (series colour / palette).\n *\n * The datum is looked up by `params.dataIndex` in the widget's own data\n * rather than read off `params.data`, so it works whatever the dataset row\n * shape is (object rows, `[label, count]` tuples, `[x, y]` tuples).\n *\n * Datum and template colours go through {@link resolveThemeColor}, same as\n * per-series colours, so palette paths such as `'primary.main'` work.\n */\nexport function createItemColorResolver({\n theme,\n datums,\n template,\n fallback,\n}: {\n theme: Theme\n datums: readonly unknown[]\n template: unknown\n fallback: ItemColorCallback\n}): ItemColorCallback {\n const templateColor = (template as { itemStyle?: { color?: unknown } })\n ?.itemStyle?.color\n return (params) => {\n const datumColor = readColor(datums[params.dataIndex])\n if (datumColor) return resolveThemeColor(theme, datumColor)!\n const custom =\n typeof templateColor === 'function'\n ? (templateColor as (p: CallbackDataParams) => unknown)(params)\n : templateColor\n if (typeof custom === 'string' && custom !== '') {\n return resolveThemeColor(theme, custom)!\n }\n return fallback(params)\n }\n}\n\nfunction readColor(datum: unknown): string | undefined {\n if (datum == null || typeof datum !== 'object') return undefined\n const color = (datum as { color?: unknown }).color\n return typeof color === 'string' && color !== '' ? color : undefined\n}\n"],"mappings":";;AAuBA,SAAgB,EAAwB,EACtC,UACA,WACA,aACA,eAMoB;CACpB,IAAM,IAAiB,GACnB,WAAW;CACf,QAAQ,MAAW;EACjB,IAAM,IAAa,EAAU,EAAO,EAAO,UAAU;EACrD,IAAI,GAAY,OAAO,EAAkB,GAAO,CAAU;EAC1D,IAAM,IACJ,OAAO,KAAkB,aACpB,EAAqD,CAAM,IAC5D;EAIN,OAHI,OAAO,KAAW,YAAY,MAAW,KACpC,EAAkB,GAAO,CAAM,IAEjC,EAAS,CAAM;CACxB;AACF;AAEA,SAAS,EAAU,GAAoC;CACrD,IAAqB,OAAO,KAAU,aAAlC,GAA4C;CAChD,IAAM,IAAS,EAA8B;CAC7C,OAAO,OAAO,KAAU,YAAY,MAAU,KAAK,IAAQ,KAAA;AAC7D"}
@@ -5,6 +5,12 @@ import { WidgetSeries } from '../types.js';
5
5
  export interface BarDatum {
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
  /** v2 bar widget data shape: array of series, each a flat list of `{name, value}`. */
10
16
  export type BarWidgetData = readonly (readonly BarDatum[])[];
@@ -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,5 +1,5 @@
1
1
  import { DownloadContext, DownloadItem } 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
@@ -8,7 +8,7 @@ import { HistogramWidgetData } from './types.js';
8
8
  */
9
9
  export declare function createHistogramDownloadConfig(args: {
10
10
  filename: string;
11
- getData: (ctx: DownloadContext) => HistogramWidgetData;
11
+ getData: (ctx: DownloadContext) => HistogramWidgetData<HistogramBin>;
12
12
  getTicks: () => readonly number[];
13
13
  seriesNames?: readonly string[];
14
14
  getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null;
@@ -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,5 +1,5 @@
1
1
  import { DownloadContext, DownloadItem } 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
5
5
  * item with `series, x, y` columns (one row per point). When
@@ -8,7 +8,7 @@ import { ScatterplotWidgetData } from './types.js';
8
8
  */
9
9
  export declare function createScatterplotDownloadConfig(args: {
10
10
  filename: string;
11
- getData: (ctx: DownloadContext) => ScatterplotWidgetData;
11
+ getData: (ctx: DownloadContext) => ScatterplotWidgetData<ScatterplotItem>;
12
12
  seriesNames?: readonly string[];
13
13
  getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null;
14
14
  pngPixelRatio?: number;
@@ -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,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-Dhlz_adK.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-CwjqEm8Y.js";
2
2
  import { a as E, i as D, n as O, r as k, t as A } from "../zoom-toggle-IsF8BnAp.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, r as z, s as B, t as V, u as H } from "../download-DGgFOaXj.js";
4
4
  export { l as BrushToggle, F as CSVIcon, b as ChangeColumn, _ as DEFAULT_BRUSH_TOGGLE_LABELS, h as DEFAULT_CHANGE_COLUMN_LABELS, M 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, z as DOWNLOAD_ITEM_IDS, B as Download, g as FullScreen, v as LockSelection, j as MarkdownIcon, R 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, V as buildCsvDownloadItem, L as buildPngDownloadItem, E as createAddZoom, x as createPercentFormatter, I as downloadDOMToPNG, H as downloadToCSV, a as filterByLockedItems, t as filterBySearchText, C as setSearcherText, i as setShowAll, N as toCsvString, c as toRelativeData, P as triggerLinkDownload };
@@ -2,12 +2,13 @@ import { r as e } from "../zoom-toggle-IsF8BnAp.js";
2
2
  import { n as t, t as n } from "../download-DGgFOaXj.js";
3
3
  import { n as r, r as i, t as a } from "../utils-Dr6gf3vD.js";
4
4
  import { a as o, d as s, f as c, i as l, s as u, u as d } from "../chart-config-B_fdIcD3.js";
5
- import { c as f } from "react/compiler-runtime";
6
- import { Box as p, Skeleton as m } from "@mui/material";
7
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
- import * as _ from "echarts";
5
+ import { t as f } from "../item-color-ZYxH3NM5.js";
6
+ import { c as p } from "react/compiler-runtime";
7
+ import { Box as m, Skeleton as h } from "@mui/material";
8
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
9
+ import * as v from "echarts";
9
10
  //#region src/widgets-v2/bar/options.ts
10
- function v({ theme: e, formatter: t, labelFormatter: n }) {
11
+ function y({ theme: e, formatter: t, labelFormatter: n }) {
11
12
  let r = 0, i = 1;
12
13
  return {
13
14
  grid: {
@@ -29,7 +30,7 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
29
30
  },
30
31
  axisPointer: { type: "line" },
31
32
  position: s(e),
32
- formatter: b(t, n)
33
+ formatter: x(t, n)
33
34
  },
34
35
  legend: { ...u({
35
36
  hasLegend: !1,
@@ -78,34 +79,42 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
78
79
  }
79
80
  };
80
81
  }
81
- function y(t) {
82
- let { theme: n, formatter: o, labelFormatter: s, optionsOverride: l } = t, u = t.series, d = t.selection, f = d && d.length > 0 ? new Set(d) : null;
83
- return (t, d, p) => {
82
+ function b(t) {
83
+ let { theme: n, formatter: o, labelFormatter: s, optionsOverride: l } = t, u = t.series, d = t.selection, p = d && d.length > 0 ? new Set(d) : null;
84
+ return (t, d, m) => {
84
85
  if (t == null) {
85
- let e = v({
86
+ let e = y({
86
87
  theme: n,
87
88
  formatter: o,
88
89
  labelFormatter: s
89
90
  });
90
91
  return l ? i(e, l) : e;
91
92
  }
92
- let m = Array.isArray(d) ? d : [];
93
- if (m.length === 0) return {
93
+ let h = Array.isArray(d) ? d : [];
94
+ if (h.length === 0) return {
94
95
  ...t,
95
96
  dataset: [],
96
97
  series: []
97
98
  };
98
- let h = m.length > 1, g = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, y = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, x = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, S = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, C = Array.isArray(t.series) ? t.series : [], w = C[0] ?? {}, T = p?.formatter, E = p?.labelFormatter, D = 0, O = 1, k = r(t.dataZoom, h), A = typeof y.bottom == "number" ? y.bottom : 24, j = h ? 56 : A, M = k ? j + e.sliderHeight + e.sliderGap : j, N = { color: (e) => {
99
- let t = e.color;
100
- if (!f) return t;
101
- let n = e.value?.name ?? e.name;
102
- return n != null && f.has(n) ? t : _.color.modifyAlpha(t, .15);
103
- } };
99
+ let g = h.length > 1, _ = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, b = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, S = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, C = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, w = Array.isArray(t.series) ? t.series : [], T = w[0] ?? {}, E = m?.formatter, D = m?.labelFormatter, O = 0, k = 1, A = r(t.dataZoom, g), j = typeof b.bottom == "number" ? b.bottom : 24, M = g ? 56 : j, N = A ? M + e.sliderHeight + e.sliderGap : M, P = (e, t) => {
100
+ let r = f({
101
+ theme: n,
102
+ datums: e,
103
+ template: t,
104
+ fallback: (e) => e.color
105
+ });
106
+ return { color: (e) => {
107
+ let t = r(e);
108
+ if (!p) return t;
109
+ let n = e.value?.name ?? e.name;
110
+ return n != null && p.has(n) ? t : v.color.modifyAlpha(t, .15);
111
+ } };
112
+ };
104
113
  return {
105
114
  ...t,
106
- dataset: m.map((e) => ({ source: e })),
107
- series: m.map((e, t) => {
108
- let r = C[t] ?? w, i = a(n, u?.[t]?.color);
115
+ dataset: h.map((e) => ({ source: e })),
116
+ series: h.map((e, t) => {
117
+ let r = w[t] ?? T, i = a(n, u?.[t]?.color);
109
118
  return {
110
119
  ...typeof r == "object" ? r : {},
111
120
  type: "bar",
@@ -117,36 +126,36 @@ function y(t) {
117
126
  },
118
127
  barMaxWidth: 100,
119
128
  emphasis: { focus: "series" },
120
- itemStyle: N,
129
+ itemStyle: P(e, r),
121
130
  ...i ? { color: i } : {}
122
131
  };
123
132
  }),
124
133
  legend: {
125
- ...g,
126
- show: h
134
+ ..._,
135
+ show: g
127
136
  },
128
137
  grid: {
129
- ...y,
130
- bottom: M
138
+ ...b,
139
+ bottom: N
131
140
  },
132
- ...k ? { dataZoom: k } : {},
141
+ ...A ? { dataZoom: A } : {},
133
142
  yAxis: {
134
- ...S,
135
- min: (e) => (D = e.min < 0 ? c(e.min) : 0, D),
136
- max: (e) => (O = e.max <= 0 ? 1 : c(e.max), O),
143
+ ...C,
144
+ min: (e) => (O = e.min < 0 ? c(e.min) : 0, O),
145
+ max: (e) => (k = e.max <= 0 ? 1 : c(e.max), k),
137
146
  axisLabel: {
138
- ...S.axisLabel ?? {},
139
- formatter: (e) => e !== O && e !== D || e === 0 ? "" : T ? T(e) : String(e)
147
+ ...C.axisLabel ?? {},
148
+ formatter: (e) => e !== k && e !== O || e === 0 ? "" : E ? E(e) : String(e)
140
149
  }
141
150
  },
142
151
  tooltip: {
143
- ...x,
144
- formatter: b(T, E)
152
+ ...S,
153
+ formatter: x(E, D)
145
154
  }
146
155
  };
147
156
  };
148
157
  }
149
- function b(e, t) {
158
+ function x(e, t) {
150
159
  return d((n) => {
151
160
  let r = n.value?.value, i = typeof r == "number" && e ? e(r) : r ?? "", a = typeof n.marker == "string" ? n.marker : "", o = n.seriesName ? `${n.seriesName}: ` : "", s = t ? String(t(n.name ?? "")) : n.name ?? "";
152
161
  return {
@@ -159,7 +168,7 @@ function b(e, t) {
159
168
  }
160
169
  //#endregion
161
170
  //#region src/widgets-v2/bar/skeleton.tsx
162
- var x = {
171
+ var S = {
163
172
  container: {
164
173
  display: "flex",
165
174
  alignItems: "center",
@@ -191,51 +200,51 @@ var x = {
191
200
  alignItems: "center",
192
201
  gap: ({ spacing: e }) => e(1.5)
193
202
  }
194
- }, S = [
203
+ }, C = [
195
204
  "20%",
196
205
  "40%",
197
206
  "60%",
198
207
  "20%",
199
208
  "80%"
200
209
  ];
201
- function C() {
202
- let e = f(2), t;
203
- e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ h(p, {
204
- sx: x.grid,
205
- children: S.map(T)
210
+ function w() {
211
+ let e = p(2), t;
212
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ g(m, {
213
+ sx: S.grid,
214
+ children: C.map(E)
206
215
  }), e[0] = t) : t = e[0];
207
216
  let n;
208
- return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ g(p, {
209
- sx: x.container,
210
- children: [t, /* @__PURE__ */ h(p, {
211
- sx: x.legend,
212
- children: [0, 1].map(w)
217
+ return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ _(m, {
218
+ sx: S.container,
219
+ children: [t, /* @__PURE__ */ g(m, {
220
+ sx: S.legend,
221
+ children: [0, 1].map(T)
213
222
  })]
214
223
  }), e[1] = n) : n = e[1], n;
215
224
  }
216
- function w(e) {
217
- return /* @__PURE__ */ g(p, {
218
- sx: x.legendItem,
219
- children: [/* @__PURE__ */ h(m, {
225
+ function T(e) {
226
+ return /* @__PURE__ */ _(m, {
227
+ sx: S.legendItem,
228
+ children: [/* @__PURE__ */ g(h, {
220
229
  variant: "circular",
221
230
  width: 8,
222
231
  height: 8
223
- }), /* @__PURE__ */ h(m, {
232
+ }), /* @__PURE__ */ g(h, {
224
233
  width: 48,
225
234
  height: 8
226
235
  })]
227
236
  }, `legend-${e}`);
228
237
  }
229
- function T(e, t) {
230
- return /* @__PURE__ */ h(m, {
231
- sx: x.bar,
238
+ function E(e, t) {
239
+ return /* @__PURE__ */ g(h, {
240
+ sx: S.bar,
232
241
  variant: "rectangular",
233
242
  height: e
234
243
  }, `bar-${t}`);
235
244
  }
236
245
  //#endregion
237
246
  //#region src/widgets-v2/bar/download.tsx
238
- function E(e) {
247
+ function D(e) {
239
248
  let r = [];
240
249
  return e.getCaptureEl && r.push(t({
241
250
  filename: e.filename,
@@ -255,6 +264,6 @@ function E(e) {
255
264
  })), r;
256
265
  }
257
266
  //#endregion
258
- export { C as BarSkeleton, v as barOptions, E as createBarDownloadConfig, y as createBarOptionFactory };
267
+ export { w as BarSkeleton, y as barOptions, D as createBarDownloadConfig, b as createBarOptionFactory };
259
268
 
260
269
  //# sourceMappingURL=bar.js.map