@object-ui/plugin-charts 17.3.0 → 17.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -120,17 +120,6 @@ By using lazy loading, the main application bundle stays lean:
120
120
 
121
121
  This results in significantly faster initial page loads for applications that don't use charts on every page.
122
122
 
123
- <!-- release-metadata:v3.3.0 -->
124
-
125
- ## Compatibility
126
-
127
- - **React:** 18.x or 19.x
128
- - **Node.js:** ≥ 18
129
- - **TypeScript:** ≥ 5.0 (strict mode)
130
- - **`@objectstack/spec`:** ^3.3.0
131
- - **`@objectstack/client`:** ^3.3.0
132
- - **Tailwind CSS:** ≥ 3.4 (for packages with UI)
133
-
134
123
  ## Links
135
124
 
136
125
  - 📚 [Documentation](https://www.objectui.org/docs/plugins/plugin-charts)
@@ -1,5 +1,6 @@
1
1
  import { ChartContainerConfig } from './ChartContainerImpl';
2
2
  import { NormalizedAxis, NormalizedSeries } from './normalizeChartSchema';
3
+ import { ChartSegmentClickEvent } from '@object-ui/core';
3
4
  /**
4
5
  * ObjectUI
5
6
  * Copyright (c) 2024-present ObjectStack Inc.
@@ -52,14 +53,34 @@ export interface AdvancedChartImplProps {
52
53
  categoryOrder?: string[];
53
54
  /**
54
55
  * Optional drill-down click handler. Fires when a chart segment is clicked
55
- * with `{ category, series, value }`. Wired for bar/horizontal-bar/line/
56
- * area/pie/donut. Other chart types are no-ops in L1.
56
+ * with `{ category, categoryId, series, value }`. Wired for
57
+ * bar/horizontal-bar/line/area/pie/donut/funnel/scatter/treemap/sankey —
58
+ * each has its own click handler attached to its mark(s) below — and for
59
+ * `combo`, whose `Bar`/`Line`/`Area` marks are the same components the plain
60
+ * cartesian branch renders and now emit the same event with the same
61
+ * semantics (ruled on objectui#4692).
62
+ *
63
+ * `combo` differs from the plain cartesian branch in exactly ONE way, and
64
+ * deliberately: **only its marks drill.** A click on the plot surface or an
65
+ * axis stays silent there, where the plain branch would fall back to its
66
+ * axis-level answer. A combo plots several measures on one plot, so a
67
+ * surface click has no single series answer to give — the same reasoning
68
+ * objectui#4672's ruling used for the pivoted case. The plain branch keeps
69
+ * that fallback because its own marks share one measure, so its axis answer
70
+ * is either unambiguous or explicitly named by recharts.
71
+ *
72
+ * That combo drills at all is what keeps its DERIVATION from costing an
73
+ * interaction. The branch is reachable without authoring
74
+ * `chartType: 'combo'`: `effectiveChartFamily` derives it whenever a series'
75
+ * own family disagrees with the chart's own (see its doc comment), so giving
76
+ * one series of a drillable chart a different `type` used to turn that
77
+ * chart's drill off with nothing in the authored spec saying drill was
78
+ * touched. It now changes the mark and nothing else.
79
+ *
80
+ * Radar is the one remaining no-op in L1 — its branch attaches no click
81
+ * handler anywhere.
57
82
  */
58
- onChartClick?: (event: {
59
- category?: string;
60
- series?: string;
61
- value?: number;
62
- }) => void;
83
+ onChartClick?: (event: ChartSegmentClickEvent) => void;
63
84
  /**
64
85
  * Spec `ChartAxis` presentation for the category axis — `format` (tick
65
86
  * formatter), `title`, `showGridLines`. Its `field` already arrived as
@@ -39,7 +39,7 @@ export type ChartContainerConfig = {
39
39
  theme: Record<keyof typeof THEMES, string>;
40
40
  });
41
41
  };
42
- declare function ChartContainer({ id, className, children, config, disableSettleRemount, ...props }: React.ComponentProps<"div"> & {
42
+ declare function ChartContainer({ id, className, children, config, disableSettleRemount, style, ...props }: React.ComponentProps<"div"> & {
43
43
  config: ChartContainerConfig;
44
44
  children: React.ComponentProps<typeof ResponsiveContainer>["children"];
45
45
  /**
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { ChartSegmentClickEvent } from '@object-ui/core';
2
3
  export interface ChartBarRendererProps {
3
4
  schema: {
4
5
  type: string;
@@ -88,11 +89,7 @@ export interface ChartRendererProps {
88
89
  isAnimationActive?: boolean;
89
90
  };
90
91
  /** Drill-down click handler — wired by ObjectChart when drillDown is enabled. */
91
- onChartClick?: (event: {
92
- category?: string;
93
- series?: string;
94
- value?: number;
95
- }) => void;
92
+ onChartClick?: (event: ChartSegmentClickEvent) => void;
96
93
  }
97
94
  /**
98
95
  * ChartRenderer - The public API for the advanced chart component
@@ -1,9 +1,19 @@
1
1
  import { default as React } from 'react';
2
+ import { humanizeLabel } from '@object-ui/core';
2
3
  /**
3
4
  * Humanize a snake_case or kebab-case string into Title Case.
4
- * Local implementation to avoid a dependency on @object-ui/fields.
5
+ *
6
+ * Was a local implementation here "to avoid a dependency on
7
+ * `@object-ui/fields`" — byte-identical to that package's export, which
8
+ * `plugin-grid` / `plugin-gantt` / `plugin-detail` read, so the two could drift
9
+ * into a live disagreement (one dashboard can hold a chart and a grid over the
10
+ * same stored value). objectui#5444 moved the single implementation to
11
+ * `@object-ui/core`, which this package already depends on: the dependency the
12
+ * copy existed to avoid is still avoided, and there is now one function rather
13
+ * than two. Re-exported at module scope because that is the surface this file
14
+ * has always offered.
5
15
  */
6
- export declare function humanizeLabel(value: string): string;
16
+ export { humanizeLabel };
7
17
  /**
8
18
  * The result column an object-bound `aggregate` projects its value under
9
19
  * (framework#3701, `chartAggregateValueKey` in `@objectstack/spec/ui`).
@@ -46,3 +56,16 @@ export declare function aggregateRecords(records: any[], aggregate: {
46
56
  export declare function resolveGroupByLabels(data: any[], groupByField: string, objectSchema: any, dataSource?: any, translateOption?: (value: string, fallbackLabel: string) => string): Promise<any[]>;
47
57
  export { extractRecords } from '@object-ui/core';
48
58
  export declare const ObjectChart: (props: any) => React.JSX.Element;
59
+ /**
60
+ * Registry shell for `object-chart` — maps the spec's
61
+ * `PageComponentSchema.dataSource` binding onto the keys {@link ObjectChart}
62
+ * reads (objectstack#6953).
63
+ *
64
+ * Nothing used to map `dataSource.object` onto `objectName`, and this block gates
65
+ * BOTH its fetch and its loading state on that key (`!schema.objectName &&
66
+ * !schema.dataset` returns early) — so a chart authored with the binding the
67
+ * spec documents rendered an empty frame with no error and no request. Lives
68
+ * here, beside the registration, rather than in `ChartContainerImpl` — the
69
+ * binding is a registry-boundary concern, not a rendering one.
70
+ */
71
+ export declare const ObjectChartBlock: (props: any) => React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ChartBarRenderer, ChartRenderer } from './ChartRenderer';
2
2
  export type { BarChartSchema } from './types';
3
3
  export { ChartBarRenderer, ChartRenderer };
4
- export { ObjectChart } from './ObjectChart';
4
+ export { ObjectChart, ObjectChartBlock } from './ObjectChart';
5
+ export { normalizeChartSchema } from './normalizeChartSchema';
6
+ export type { NormalizedChartSchema } from './normalizeChartSchema';
5
7
  export declare const chartComponents: {
6
8
  'bar-chart': import('react').FC<import('./ChartRenderer').ChartBarRendererProps>;
7
9
  chart: import('react').FC<import('./ChartRenderer').ChartRendererProps>;