@object-ui/plugin-report 17.5.0 → 17.7.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/CHANGELOG.md +2084 -0
- package/README.md +470 -129
- package/dist/DatasetReportRenderer.d.ts +19 -3
- package/dist/LiveReportExporter.d.ts +19 -0
- package/dist/ReportExportEngine.d.ts +18 -3
- package/dist/ReportRenderer.d.ts +2 -2
- package/dist/displayLocale.d.ts +70 -0
- package/dist/formatValue.d.ts +19 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +501 -452
- package/dist/index.umd.cjs +22 -22
- package/dist/useDatasetDimensionLabels.d.ts +12 -1
- package/package.json +13 -16
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* so an older server that returns no `totals` renders the plain cross-tab
|
|
25
25
|
* with no totals row/column. A matrix without `columns` degrades to the
|
|
26
26
|
* flat grouped table.
|
|
27
|
+
* - `chart` (any non-joined type) → the embedded chart, its own
|
|
28
|
+
* `chart.xAxis` × `chart.yAxis` dataset query: above the grouped / flat
|
|
29
|
+
* table, below the matrix cross-tab (objectui#10964).
|
|
27
30
|
* - `joined` → a vertical stack of blocks, each its own dataset-bound table,
|
|
28
31
|
* with the report-level `runtimeFilter` merged into every block.
|
|
29
32
|
*
|
|
@@ -84,6 +87,17 @@ interface DatasetReportLike {
|
|
|
84
87
|
columns?: string[];
|
|
85
88
|
values?: string[];
|
|
86
89
|
runtimeFilter?: Record<string, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* ⛔ NOT an authorable key, and NEVER applied as a filter (objectui#5137).
|
|
92
|
+
*
|
|
93
|
+
* `ReportSchema` (`@objectstack/spec`) is `z.core.$strict` and rejects
|
|
94
|
+
* `filter` outright, naming the replacement itself
|
|
95
|
+
* (`Did you mean … → runtimeFilter?`) — so a document carrying it did not
|
|
96
|
+
* arrive through the validated path. It stays declared for exactly one reason:
|
|
97
|
+
* so {@link warnOnRejectedFilterAlias} can SEE it on a stored document and
|
|
98
|
+
* say out loud that no filter was applied. Reading it AS a scope filter is
|
|
99
|
+
* the consumer tolerance this card removed. Author `runtimeFilter`.
|
|
100
|
+
*/
|
|
87
101
|
filter?: Record<string, unknown>;
|
|
88
102
|
/**
|
|
89
103
|
* Result ordering, most significant key first (framework#3916). Each `by`
|
|
@@ -117,6 +131,8 @@ export interface DatasetReportRendererProps {
|
|
|
117
131
|
}
|
|
118
132
|
/** `true` when this report should render through the dataset path. */
|
|
119
133
|
export declare function isDatasetReport(value: unknown): value is DatasetReportLike;
|
|
134
|
+
/** Reset the warn-once memo. Exported for tests. */
|
|
135
|
+
export declare function resetReportFilterAliasWarnings(): void;
|
|
120
136
|
/**
|
|
121
137
|
* Resolve a report's declared `type` — the spec's `ReportType`
|
|
122
138
|
* (`ui/report.zod.ts`: `tabular | summary | matrix | joined`) — to the
|
|
@@ -142,7 +158,7 @@ export type ReportChartPlan =
|
|
|
142
158
|
| {
|
|
143
159
|
kind: 'single_value';
|
|
144
160
|
}
|
|
145
|
-
/** Tabular family — the
|
|
161
|
+
/** Tabular family — the report's own table beside it IS the rendering; no duplicate chart. */
|
|
146
162
|
| {
|
|
147
163
|
kind: 'tabular';
|
|
148
164
|
}
|
|
@@ -163,8 +179,8 @@ export type ReportChartPlan =
|
|
|
163
179
|
* - the single-value families (`gauge` / `solid-gauge` / `metric` / `kpi` /
|
|
164
180
|
* `bullet`) render the measure as a number — the spec's own comment calls
|
|
165
181
|
* them "honest single-value variants pending a real dial/target renderer";
|
|
166
|
-
* - `table` / `pivot` add no duplicate chart: the
|
|
167
|
-
*
|
|
182
|
+
* - `table` / `pivot` add no duplicate chart: the table that always renders
|
|
183
|
+
* beside the chart slot is exactly the tabular presentation;
|
|
168
184
|
* - anything else is out-of-spec and gets a visible notice.
|
|
169
185
|
*
|
|
170
186
|
* `combo` joined `ChartTypeSchema` in spec 17.0.0-rc.1 and routes as a series
|
|
@@ -13,6 +13,13 @@ export interface LiveExportOptions {
|
|
|
13
13
|
format?: ReportExportFormat;
|
|
14
14
|
/** Export config override */
|
|
15
15
|
exportConfig?: ReportExportConfig;
|
|
16
|
+
/**
|
|
17
|
+
* BCP-47 display tag for the HTML / PDF "Generated:" time — in React,
|
|
18
|
+
* whatever `useDisplayLocale()` (`@object-ui/i18n`) returned for the session.
|
|
19
|
+
* Omitted, `exportReport` falls back to the display channel's own last
|
|
20
|
+
* resort, never to the machine's locale (objectui#9909).
|
|
21
|
+
*/
|
|
22
|
+
locale?: string;
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
25
|
* Excel column configuration for formatted export
|
|
@@ -83,6 +90,18 @@ export declare function exportExcelWithFormulas(report: ReportComponentSchema, d
|
|
|
83
90
|
columns?: ExcelColumnConfig[];
|
|
84
91
|
filename?: string;
|
|
85
92
|
includeAggregationRow?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* BCP-47 tag the numeric cells are formatted in — in React, whatever
|
|
95
|
+
* `useDisplayLocale()` (`@object-ui/i18n`) returned for the session.
|
|
96
|
+
*
|
|
97
|
+
* It lives on the OPTIONS BAG because this module is not a component and
|
|
98
|
+
* has no hook to read: a locale can only reach it from its caller, and a
|
|
99
|
+
* report schema is the wrong carrier for it (a display locale is a property
|
|
100
|
+
* of the session, not of the authored report). Omitted, it falls back to
|
|
101
|
+
* the display channel's own last resort — never to `'en-US'`, and never to
|
|
102
|
+
* a dropped tag, which would mean the MACHINE's locale (objectui#10020).
|
|
103
|
+
*/
|
|
104
|
+
locale?: string;
|
|
86
105
|
}): void;
|
|
87
106
|
/**
|
|
88
107
|
* Create a schedule trigger that can be invoked by workflow engines.
|
|
@@ -2,6 +2,21 @@ import { ReportComponentSchema, ReportExportConfig, ReportExportFormat } from '@
|
|
|
2
2
|
/**
|
|
3
3
|
* Report Export Engine
|
|
4
4
|
* Handles exporting report data to various formats using browser-native APIs.
|
|
5
|
+
*
|
|
6
|
+
* ## The export's display locale (objectui#9909)
|
|
7
|
+
*
|
|
8
|
+
* The HTML and PDF exports stamp a "Generated:" time into a file the reader
|
|
9
|
+
* downloads and keeps. That time used to be `new Date().toLocaleString()` —
|
|
10
|
+
* no tag, i.e. the MACHINE's locale, which is neither of the repo's two
|
|
11
|
+
* locale channels. The functions below take the tag as a trailing, OPTIONAL
|
|
12
|
+
* `locale` parameter — the same additive shape `formatValue` took in
|
|
13
|
+
* objectui#10020, and for the same reason: they are published exports, so a
|
|
14
|
+
* required parameter would break every existing caller. Omitted, it falls back
|
|
15
|
+
* to {@link DISPLAY_LOCALE_LAST_RESORT}, the display channel's own last resort
|
|
16
|
+
* — never to a dropped tag. In React the caller passes `useDisplayLocale()`;
|
|
17
|
+
* `ReportViewer` does. ⚠️ A display locale is a property of the SESSION, not
|
|
18
|
+
* of the authored report, so it is deliberately NOT a `ReportExportConfig`
|
|
19
|
+
* member: that type is authored metadata (`exportConfigs` on the schema).
|
|
5
20
|
*/
|
|
6
21
|
/**
|
|
7
22
|
* Export report data as CSV
|
|
@@ -14,11 +29,11 @@ export declare function exportAsJSON(report: ReportComponentSchema, data: any[],
|
|
|
14
29
|
/**
|
|
15
30
|
* Export report as HTML (printable format)
|
|
16
31
|
*/
|
|
17
|
-
export declare function exportAsHTML(report: ReportComponentSchema, data: any[], config?: ReportExportConfig): void;
|
|
32
|
+
export declare function exportAsHTML(report: ReportComponentSchema, data: any[], config?: ReportExportConfig, locale?: string): void;
|
|
18
33
|
/**
|
|
19
34
|
* Export report as PDF using browser print
|
|
20
35
|
*/
|
|
21
|
-
export declare function exportAsPDF(report: ReportComponentSchema, data: any[], config?: ReportExportConfig): void;
|
|
36
|
+
export declare function exportAsPDF(report: ReportComponentSchema, data: any[], config?: ReportExportConfig, locale?: string): void;
|
|
22
37
|
/**
|
|
23
38
|
* Export report as Excel-compatible CSV (with BOM for proper UTF-8 in Excel)
|
|
24
39
|
*/
|
|
@@ -26,4 +41,4 @@ export declare function exportAsExcel(report: ReportComponentSchema, data: any[]
|
|
|
26
41
|
/**
|
|
27
42
|
* Main export function - routes to correct format handler
|
|
28
43
|
*/
|
|
29
|
-
export declare function exportReport(format: ReportExportFormat, report: ReportComponentSchema, data: any[], config?: ReportExportConfig): void;
|
|
44
|
+
export declare function exportReport(format: ReportExportFormat, report: ReportComponentSchema, data: any[], config?: ReportExportConfig, locale?: string): void;
|
package/dist/ReportRenderer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpecReport, DataSource } from '@object-ui/types';
|
|
2
|
-
import { LegacyReportRendererProps } from './LegacyReportRenderer';
|
|
3
|
-
import { DatasetDrillArgs } from './DatasetReportRenderer';
|
|
2
|
+
import { LegacyReportRendererProps } from './LegacyReportRenderer.js';
|
|
3
|
+
import { DatasetDrillArgs } from './DatasetReportRenderer.js';
|
|
4
4
|
/**
|
|
5
5
|
* ReportRenderer
|
|
6
6
|
*
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* displayLocale — the one place this package spells the display locale's LAST
|
|
10
|
+
* RESORT, and the one place it formats a number with a THREADED tag.
|
|
11
|
+
*
|
|
12
|
+
* Two module-private copies of both used to be the alternative (`formatValue`
|
|
13
|
+
* and `LiveReportExporter` each hard-coded `'en-US'`), which is how the
|
|
14
|
+
* divergence objectui#10020 records happened in the first place: a package can
|
|
15
|
+
* only contradict a contract it states in more than one place.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* `'en'` — the tag `useDisplayLocale` (`@object-ui/i18n`) itself falls back to
|
|
19
|
+
* when neither the tenant's regional default nor the active UI language
|
|
20
|
+
* answers. Quoted from that hook's contract, which names BOTH alternatives as
|
|
21
|
+
* wrong answers:
|
|
22
|
+
*
|
|
23
|
+
* > `'en'` — a concrete last resort rather than `undefined`. `undefined`
|
|
24
|
+
* > would hand `Intl` the *machine's* locale, which is invisible in review
|
|
25
|
+
* > and non-deterministic in CI; `'en'` at least fails the same way
|
|
26
|
+
* > everywhere. Note this is `'en'`, not `'en-US'`: the point of
|
|
27
|
+
* > objectui#4033 is that `en-US` is not the world's default.
|
|
28
|
+
*
|
|
29
|
+
* So this constant may become neither `'en-US'` (the tag objectui#10020 removed
|
|
30
|
+
* from five display sites in this package) nor `undefined` (objectui#9909's
|
|
31
|
+
* separate defect shape, which `ReportExportEngine.ts`'s "Generated:" time
|
|
32
|
+
* carried until that card threaded a locale there, defaulting to this same
|
|
33
|
+
* constant).
|
|
34
|
+
*
|
|
35
|
+
* ⚠️ It is a local re-spelling of that literal, not an import of it:
|
|
36
|
+
* `@object-ui/i18n` exports the HOOK but no constant for the tag inside it, and
|
|
37
|
+
* a plain formatter cannot call a hook. Anything that moves the contract's last
|
|
38
|
+
* resort has to move this line too — pinned from the behavioural side by
|
|
39
|
+
* `__tests__/reportDisplayLocale-10020.test.tsx`, which asserts the omitted
|
|
40
|
+
* argument agrees with an explicit `'en'`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DISPLAY_LOCALE_LAST_RESORT = "en";
|
|
43
|
+
/**
|
|
44
|
+
* `Number.prototype.toLocaleString` with a tag that came from OUTSIDE this
|
|
45
|
+
* module.
|
|
46
|
+
*
|
|
47
|
+
* The retry is load-bearing rather than defensive, and it is the threading
|
|
48
|
+
* itself that makes it so: a hard-coded literal can never be malformed, while a
|
|
49
|
+
* threaded tag originates in tenant configuration (ADR-0053) and reaches here
|
|
50
|
+
* verbatim. `Intl` throws `RangeError` on a malformed tag — measured on
|
|
51
|
+
* `'en_US'`, underscore instead of hyphen, the likeliest such typo — and these
|
|
52
|
+
* call sites are inside a cell render, so an uncaught throw takes the whole
|
|
53
|
+
* report down rather than misformatting one number.
|
|
54
|
+
*
|
|
55
|
+
* ⚠️ The degradation is to {@link DISPLAY_LOCALE_LAST_RESORT}, NOT to a dropped
|
|
56
|
+
* tag, because this package's display tags follow `useDisplayLocale`'s
|
|
57
|
+
* contract: in React the tag IS that hook's value, and an omitted one defaults
|
|
58
|
+
* to the hook's own last resort. Under that contract, dropping the tag hands
|
|
59
|
+
* `Intl` the machine's locale — the other answer the contract quoted above
|
|
60
|
+
* rules out, non-deterministic in CI and invisible in review.
|
|
61
|
+
*
|
|
62
|
+
* `@object-ui/core`'s sibling retry (`formatNumberInLocale`, through
|
|
63
|
+
* `formatDisplayNumber`) drops the tag instead. That is a deliberate
|
|
64
|
+
* difference, not an oversight, and not a wrong answer: `core` is the
|
|
65
|
+
* React-free formatter, and where its retry lands is what its own declared
|
|
66
|
+
* contract (`DisplayNumberFormatOptions.locale`) gives a caller with no tag in
|
|
67
|
+
* hand — the runtime default, the viewer's own environment. Each retry follows
|
|
68
|
+
* its own package's declared contract (objectui#10098).
|
|
69
|
+
*/
|
|
70
|
+
export declare function formatNumberInDisplayLocale(value: number, locale: string, options?: Intl.NumberFormatOptions): string;
|
package/dist/formatValue.d.ts
CHANGED
|
@@ -2,5 +2,23 @@ import { ReportField } from '@object-ui/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Format a cell value based on the field definition.
|
|
4
4
|
* Handles number (with thousand separators), currency, percent, and date formatting.
|
|
5
|
+
*
|
|
6
|
+
* `locale` is the BCP-47 DISPLAY tag the numeric branches below format in —
|
|
7
|
+
* in React, whatever `useDisplayLocale()` returned for the session. It is
|
|
8
|
+
* OPTIONAL, and that is a deliberate contract decision rather than convenience
|
|
9
|
+
* (objectui#10020): this function is a published export of
|
|
10
|
+
* `@object-ui/plugin-report`, so a REQUIRED third parameter would be a breaking
|
|
11
|
+
* change to a public signature. Optional is purely additive — everything that
|
|
12
|
+
* compiled before compiles after.
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ The cost of that choice, named rather than hidden: an OPTIONAL locale
|
|
15
|
+
* leaves a leg that is still wrong when nobody passes one. Closing it is the
|
|
16
|
+
* caller's job, and inside this repo every caller does — `ReportViewer` is a
|
|
17
|
+
* component and resolves `useDisplayLocale()` itself at all three of its call
|
|
18
|
+
* sites, pinned in `__tests__/reportDisplayLocale-10020.test.tsx`. An OPTIONAL
|
|
19
|
+
* parameter nobody passes is the same defect with a longer signature.
|
|
20
|
+
*
|
|
21
|
+
* The default is {@link DISPLAY_LOCALE_LAST_RESORT} — the contract's own last
|
|
22
|
+
* resort, which is neither the `'en-US'` this card removed nor an absent tag.
|
|
5
23
|
*/
|
|
6
|
-
export declare function formatValue(value: any, field?: ReportField): string;
|
|
24
|
+
export declare function formatValue(value: any, field?: ReportField, locale?: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ReportRenderer } from './ReportRenderer';
|
|
2
|
-
import { LegacyReportRenderer } from './LegacyReportRenderer';
|
|
3
|
-
import { ReportViewer } from './ReportViewer';
|
|
4
|
-
import { DatasetReportRenderer, isDatasetReport } from './DatasetReportRenderer';
|
|
1
|
+
import { ReportRenderer } from './ReportRenderer.js';
|
|
2
|
+
import { LegacyReportRenderer } from './LegacyReportRenderer.js';
|
|
3
|
+
import { ReportViewer } from './ReportViewer.js';
|
|
4
|
+
import { DatasetReportRenderer, isDatasetReport } from './DatasetReportRenderer.js';
|
|
5
5
|
export { ReportRenderer, LegacyReportRenderer, ReportViewer, DatasetReportRenderer, isDatasetReport };
|
|
6
|
-
export type { ReportRendererProps, ReportRendererSchema } from './ReportRenderer';
|
|
7
|
-
export type { LegacyReportRendererProps } from './LegacyReportRenderer';
|
|
8
|
-
export type { DatasetReportRendererProps, DatasetDrillArgs } from './DatasetReportRenderer';
|
|
9
|
-
export { formatValue } from './formatValue';
|
|
10
|
-
export { exportReport, exportAsCSV, exportAsJSON, exportAsHTML, exportAsPDF, exportAsExcel } from './ReportExportEngine';
|
|
11
|
-
export { exportWithLiveData, exportExcelWithFormulas, createScheduleTrigger, } from './LiveReportExporter';
|
|
12
|
-
export type { LiveExportOptions, LiveExportResult, ExcelColumnConfig, ScheduleTriggerCallback, } from './LiveReportExporter';
|
|
13
|
-
export { mergeFilters } from './mergeFilters';
|
|
6
|
+
export type { ReportRendererProps, ReportRendererSchema } from './ReportRenderer.js';
|
|
7
|
+
export type { LegacyReportRendererProps } from './LegacyReportRenderer.js';
|
|
8
|
+
export type { DatasetReportRendererProps, DatasetDrillArgs } from './DatasetReportRenderer.js';
|
|
9
|
+
export { formatValue } from './formatValue.js';
|
|
10
|
+
export { exportReport, exportAsCSV, exportAsJSON, exportAsHTML, exportAsPDF, exportAsExcel } from './ReportExportEngine.js';
|
|
11
|
+
export { exportWithLiveData, exportExcelWithFormulas, createScheduleTrigger, } from './LiveReportExporter.js';
|
|
12
|
+
export type { LiveExportOptions, LiveExportResult, ExcelColumnConfig, ScheduleTriggerCallback, } from './LiveReportExporter.js';
|
|
13
|
+
export { mergeFilters } from './mergeFilters.js';
|