@kanunilabs/pivotgrid 1.0.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/LICENSE +56 -0
- package/README.md +101 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +241 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +3 -0
- package/dist/pivotgrid.umd.js +59 -0
- package/dist/styles.css +2310 -0
- package/package.json +90 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { PivotField, PivotCell, PivotEngineResult, PivotLayoutState, PivotTheme, PivotLocale, PivotDictionary, PivotStateStoringConfig, PivotToolbarConfig, PivotControllerOptions, PivotController } from '@kanunilabs/pivotgrid-core';
|
|
2
|
+
export { ExportFormat, ExportOptions, FilterCondition, FilterGroup, FilterOperator, PivotArea, PivotController, PivotControllerOptions, PivotControllerState, PivotDictionary, PivotEngineResult, PivotField, PivotGroupInterval, PivotLayoutState, PivotLocale, PivotPrefilter, PivotStateStoringConfig, PivotSummaryDisplayMode, PivotSummaryType, PivotTheme, PivotToolbarConfig, defaultPivotLayout, getAdvancedExporter, registerAdvancedExporter } from '@kanunilabs/pivotgrid-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A themed portal host: carries the grid root's classes, inline theme vars,
|
|
6
|
+
* data-theme and dir so the shared stylesheet re-applies wholesale. Used by
|
|
7
|
+
* the one-at-a-time popup layer below AND by long-lived surfaces (the field
|
|
8
|
+
* chooser) that must coexist with transient popups.
|
|
9
|
+
*/
|
|
10
|
+
declare function createThemedHost(gridRoot: HTMLElement): HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Where a popup host must be appended so that it is actually PAINTED.
|
|
13
|
+
*
|
|
14
|
+
* Under the native Fullscreen API only the fullscreen element's subtree is
|
|
15
|
+
* rendered: a host appended to <body> exists, receives events, and is
|
|
16
|
+
* invisible. That is what made every menu, dialog and the field chooser
|
|
17
|
+
* "not open" while the grid was fullscreen — they opened, behind the one
|
|
18
|
+
* element the browser was drawing. So while something is fullscreen, hosts go
|
|
19
|
+
* INSIDE it. The CSS-emulated fallback (`.pivot-is-fullscreen`, a fixed
|
|
20
|
+
* z-index 9990 layer) gets the same treatment, for the same reason.
|
|
21
|
+
*/
|
|
22
|
+
declare function portalParent(): HTMLElement;
|
|
23
|
+
interface PortalLayer {
|
|
24
|
+
/**
|
|
25
|
+
* Mount a popup. `build` fills the portal root and may return extra
|
|
26
|
+
* cleanup (timers, observers). Any previous popup closes first.
|
|
27
|
+
*/
|
|
28
|
+
openPopup(build: (portalRoot: HTMLElement) => (() => void) | void): HTMLElement;
|
|
29
|
+
closePopup(): void;
|
|
30
|
+
isOpen(): boolean;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
}
|
|
33
|
+
declare function createPortalLayer(gridRoot: HTMLElement): PortalLayer;
|
|
34
|
+
|
|
35
|
+
interface VanillaContextMenuItem {
|
|
36
|
+
label: string;
|
|
37
|
+
action: () => void;
|
|
38
|
+
/** Inline SVG (or any node) — the lucide component slot, rebound. */
|
|
39
|
+
icon?: () => Node;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Intl.NumberFormat cache keyed by format OBJECT identity — recreated per locale. */
|
|
43
|
+
declare function createValueFormatter(locale: string): (val: unknown, df: PivotField<any>) => string;
|
|
44
|
+
|
|
45
|
+
interface VanillaCellClickEvent {
|
|
46
|
+
/** The NATIVE event — the React layer carries a SyntheticEvent here. */
|
|
47
|
+
event: MouseEvent;
|
|
48
|
+
cellType: 'data' | 'grandTotal';
|
|
49
|
+
value: unknown;
|
|
50
|
+
rowPath: string[];
|
|
51
|
+
colPath: string[];
|
|
52
|
+
/**
|
|
53
|
+
* The source rows behind the cell — resolved by the controller, exactly as
|
|
54
|
+
* React does it (BasePivotGrid routes every click through
|
|
55
|
+
* `controller.resolveCellClick`). Undefined only when no controller
|
|
56
|
+
* resolver is wired.
|
|
57
|
+
*/
|
|
58
|
+
records?: unknown[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** …and the width React's grip starts its drag from. Ported quirk, see below. */
|
|
62
|
+
/** The vanilla cell-prepared contract: text is a string or a Node, never JSX. */
|
|
63
|
+
interface VanillaCellConfig {
|
|
64
|
+
text: string | Node | null;
|
|
65
|
+
style: Record<string, string | number>;
|
|
66
|
+
className: string;
|
|
67
|
+
}
|
|
68
|
+
/** onCellPrepared payload — the React event with cellConfig re-typed to string|Node. */
|
|
69
|
+
interface VanillaCellPreparedEvent {
|
|
70
|
+
area: 'data' | 'row' | 'column';
|
|
71
|
+
cell: unknown;
|
|
72
|
+
rowIndex: number;
|
|
73
|
+
columnIndex: number;
|
|
74
|
+
cellConfig: VanillaCellConfig;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface ChartSeriesDef {
|
|
78
|
+
dataKey: string;
|
|
79
|
+
name: string;
|
|
80
|
+
color: string;
|
|
81
|
+
yAxisId?: string;
|
|
82
|
+
}
|
|
83
|
+
interface ChartSyncResult {
|
|
84
|
+
chartData: unknown[];
|
|
85
|
+
chartSeries: ChartSeriesDef[];
|
|
86
|
+
/**
|
|
87
|
+
* True when `maxPoints` dropped categories.
|
|
88
|
+
*
|
|
89
|
+
* The transformer has always returned this and the bridge has always passed
|
|
90
|
+
* it through — but the type stopped short of declaring it, so a TypeScript
|
|
91
|
+
* consumer could not read the one flag that says the picture is partial. A
|
|
92
|
+
* chart showing the first 100 of 5,000 categories with nothing saying so is
|
|
93
|
+
* a lie told in a picture (#213).
|
|
94
|
+
*/
|
|
95
|
+
isSampled?: boolean;
|
|
96
|
+
/** Categories BEFORE sampling, so a caller can show "100 of 5,000". */
|
|
97
|
+
totalArgs?: number;
|
|
98
|
+
}
|
|
99
|
+
interface VanillaChartIntegrationOptions {
|
|
100
|
+
inverted?: boolean;
|
|
101
|
+
hideTotals?: boolean;
|
|
102
|
+
maxPoints?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Cap on SERIES, which `maxPoints` never covered: it slices the argument
|
|
105
|
+
* side only, so a wide column tree asked a renderer for one element per
|
|
106
|
+
* visible column leaf, uncapped (#213).
|
|
107
|
+
*/
|
|
108
|
+
maxSeries?: number;
|
|
109
|
+
dataFieldsDisplayMode?: 'singleAxis' | 'splitAxes';
|
|
110
|
+
/**
|
|
111
|
+
* Drop a cell from the chart. React has carried this since the hook was
|
|
112
|
+
* written (usePivotChartSync PivotChartIntegrationOptions) and its
|
|
113
|
+
* transformer honours it; the vanilla options type simply never declared
|
|
114
|
+
* it, so the hook existed and was unreachable from here (#213).
|
|
115
|
+
*/
|
|
116
|
+
processCell?: (cell: PivotCell) => boolean;
|
|
117
|
+
transformer?: (engineResult: PivotEngineResult, fields: PivotField<never>[], expandedPaths: Set<string>, locale: string, options: VanillaChartIntegrationOptions) => ChartSyncResult;
|
|
118
|
+
}
|
|
119
|
+
interface ChartSyncControllerLike {
|
|
120
|
+
subscribe(listener: () => void): () => void;
|
|
121
|
+
getState(): {
|
|
122
|
+
engineResult: PivotEngineResult | null;
|
|
123
|
+
fields: unknown[];
|
|
124
|
+
expandedPaths: Set<string>;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface ChartSync {
|
|
128
|
+
/** Re-evaluate the gate now — the setLocale path, which the store misses. */
|
|
129
|
+
refresh(): void;
|
|
130
|
+
stop(): void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Subscribe a chart to the pivot. Fires `onSync` with the transformed
|
|
134
|
+
* result 150ms after the engine result, the expansion set or the LOCALE
|
|
135
|
+
* changes (and once on start).
|
|
136
|
+
*/
|
|
137
|
+
declare function createChartSync(controller: ChartSyncControllerLike, getLocale: () => string, options: VanillaChartIntegrationOptions, onSync: (result: ChartSyncResult) => void): ChartSync;
|
|
138
|
+
|
|
139
|
+
/** `t()` and its inputs, rebuilt whenever locale/dictionary change. */
|
|
140
|
+
interface ResolvedI18n {
|
|
141
|
+
locale: PivotLocale;
|
|
142
|
+
rtl: boolean;
|
|
143
|
+
dictionary: PivotDictionary;
|
|
144
|
+
t: (key: string) => string;
|
|
145
|
+
}
|
|
146
|
+
declare function resolveI18n(locale?: PivotLocale, dictionary?: Partial<PivotDictionary>, rtl?: boolean): ResolvedI18n;
|
|
147
|
+
/**
|
|
148
|
+
* The vanilla configuration surface.
|
|
149
|
+
*
|
|
150
|
+
* Mirrors `BasePivotGridProps` minus the React mechanics: no render props, no
|
|
151
|
+
* ref — the returned instance IS the ref. Core's generics are deliberately
|
|
152
|
+
* re-bindable (that is why they exist); the vanilla layer binds templates to
|
|
153
|
+
* `string | Node` and events to native `MouseEvent` in M2 when the painters
|
|
154
|
+
* land.
|
|
155
|
+
*/
|
|
156
|
+
interface PivotGridVanillaConfig<TRow = unknown> {
|
|
157
|
+
gridId?: string;
|
|
158
|
+
data: TRow[];
|
|
159
|
+
initialFields?: PivotField<TRow>[];
|
|
160
|
+
/** Controlled fields — same semantics as the React `fields` prop. */
|
|
161
|
+
fields?: PivotField<TRow>[];
|
|
162
|
+
/** Controlled layout — same semantics as the React `layout` prop. */
|
|
163
|
+
layout?: PivotLayoutState;
|
|
164
|
+
theme?: PivotTheme;
|
|
165
|
+
striped?: boolean;
|
|
166
|
+
locale?: PivotLocale;
|
|
167
|
+
rtl?: boolean;
|
|
168
|
+
dictionary?: Partial<PivotDictionary>;
|
|
169
|
+
stateStoring?: PivotStateStoringConfig;
|
|
170
|
+
toolbar?: PivotToolbarConfig;
|
|
171
|
+
workerUrl?: string | URL;
|
|
172
|
+
previewImport?: boolean;
|
|
173
|
+
registry?: PivotControllerOptions<TRow>['registry'];
|
|
174
|
+
keyboardNavigation?: {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
};
|
|
177
|
+
disabled?: boolean;
|
|
178
|
+
/** Extra class on the root element. */
|
|
179
|
+
className?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Enterprise slots (K3): the Community renderer opens the sockets, the
|
|
182
|
+
* Enterprise package fills them. `advancedExport` also seeds the core
|
|
183
|
+
* edition gate, exactly like the React `advancedExport` prop.
|
|
184
|
+
*/
|
|
185
|
+
advancedExport?: boolean;
|
|
186
|
+
upgradeUrl?: string;
|
|
187
|
+
/**
|
|
188
|
+
* The Enterprise sockets themselves, as plain callbacks — the vanilla shape
|
|
189
|
+
* of React's `renderCalculatedFieldModal` / `renderPrefilterBuilder` render
|
|
190
|
+
* props and its `onToggleChart`. Each one, when present, makes the footer
|
|
191
|
+
* draw the matching button (the designer's, the prefilter's, the chart's)
|
|
192
|
+
* and the field menu offer "Edit calculation" on calculated fields; absent,
|
|
193
|
+
* nothing is drawn, so a Community grid stays exactly as it was.
|
|
194
|
+
* `@kanunilabs/pivotgrid-enterprise` fills all four; an app may fill any.
|
|
195
|
+
*/
|
|
196
|
+
onAddCalculatedField?: () => void;
|
|
197
|
+
onEditCalculatedField?: (field: PivotField<TRow>) => void;
|
|
198
|
+
onOpenPrefilter?: () => void;
|
|
199
|
+
onToggleChart?: () => void;
|
|
200
|
+
/** Chart bridge (the React usePivotChartSync contract, subscription-shaped). */
|
|
201
|
+
chartIntegrationOptions?: VanillaChartIntegrationOptions;
|
|
202
|
+
onChartSync?: (result: ChartSyncResult) => void;
|
|
203
|
+
onCellClick?: (e: VanillaCellClickEvent) => void;
|
|
204
|
+
/** Right-click on data cells / non-expandable row cells (viewport coords). */
|
|
205
|
+
onGlobalContextMenu?: (x: number, y: number) => void;
|
|
206
|
+
/** Per-cell hook before a data/header cell hits the DOM — mutate `cellConfig`. */
|
|
207
|
+
onCellPrepared?: (e: VanillaCellPreparedEvent) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Extra items appended to a field's context menu (the React
|
|
210
|
+
* `customContextMenuItems` prop). The React `icon` is a ReactNode; here it
|
|
211
|
+
* is a factory returning a DOM node, so `icon: () => icon('star', 14)`.
|
|
212
|
+
*/
|
|
213
|
+
customContextMenuItems?: (field: PivotField<TRow>) => VanillaContextMenuItem[] | undefined;
|
|
214
|
+
onRefresh?: () => void;
|
|
215
|
+
onImportData?: (data: TRow[]) => void;
|
|
216
|
+
onFieldsChange?: (fields: PivotField<TRow>[]) => void;
|
|
217
|
+
onLayoutChange?: (layout: PivotLayoutState) => void;
|
|
218
|
+
onFieldMove?: PivotControllerOptions<TRow>['onFieldMove'];
|
|
219
|
+
onBeforePivotCalculate?: () => void;
|
|
220
|
+
onAfterPivotCalculate?: PivotControllerOptions<TRow>['onAfterPivotCalculate'];
|
|
221
|
+
onExporting?: PivotControllerOptions<TRow>['onExporting'];
|
|
222
|
+
onError?: (error: Error) => void;
|
|
223
|
+
onChartStateLoaded?: PivotControllerOptions<TRow>['onChartStateLoaded'];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The instance handle. `controller` is the full engine — same object the React `onReady` hands out. */
|
|
227
|
+
interface PivotGridApi<TRow = unknown> {
|
|
228
|
+
controller: PivotController<TRow>;
|
|
229
|
+
element: HTMLElement;
|
|
230
|
+
destroy(): void;
|
|
231
|
+
setData(data: TRow[]): void;
|
|
232
|
+
setFields(fields: PivotField<TRow>[]): void;
|
|
233
|
+
setLocale(locale: PivotLocale, dictionary?: Partial<PivotDictionary>, rtl?: boolean): void;
|
|
234
|
+
}
|
|
235
|
+
declare function createPivotGrid<TRow = unknown>(container: HTMLElement, config: PivotGridVanillaConfig<TRow>): PivotGridApi<TRow>;
|
|
236
|
+
|
|
237
|
+
declare function icon(name: string, size?: number, color?: string): SVGSVGElement;
|
|
238
|
+
/** The lucide `fill` prop (filled funnel/star when active). */
|
|
239
|
+
declare function filledIcon(name: string, size?: number, color?: string): SVGSVGElement;
|
|
240
|
+
|
|
241
|
+
export { type ChartSeriesDef, type ChartSyncResult, type PivotGridApi, type PivotGridVanillaConfig, type PortalLayer, type ResolvedI18n, type VanillaCellClickEvent, type VanillaCellConfig, type VanillaCellPreparedEvent, type VanillaChartIntegrationOptions, createChartSync, createPivotGrid, createPortalLayer, createThemedHost, createValueFormatter, filledIcon, icon, portalParent, resolveI18n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { PivotField, PivotCell, PivotEngineResult, PivotLayoutState, PivotTheme, PivotLocale, PivotDictionary, PivotStateStoringConfig, PivotToolbarConfig, PivotControllerOptions, PivotController } from '@kanunilabs/pivotgrid-core';
|
|
2
|
+
export { ExportFormat, ExportOptions, FilterCondition, FilterGroup, FilterOperator, PivotArea, PivotController, PivotControllerOptions, PivotControllerState, PivotDictionary, PivotEngineResult, PivotField, PivotGroupInterval, PivotLayoutState, PivotLocale, PivotPrefilter, PivotStateStoringConfig, PivotSummaryDisplayMode, PivotSummaryType, PivotTheme, PivotToolbarConfig, defaultPivotLayout, getAdvancedExporter, registerAdvancedExporter } from '@kanunilabs/pivotgrid-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A themed portal host: carries the grid root's classes, inline theme vars,
|
|
6
|
+
* data-theme and dir so the shared stylesheet re-applies wholesale. Used by
|
|
7
|
+
* the one-at-a-time popup layer below AND by long-lived surfaces (the field
|
|
8
|
+
* chooser) that must coexist with transient popups.
|
|
9
|
+
*/
|
|
10
|
+
declare function createThemedHost(gridRoot: HTMLElement): HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Where a popup host must be appended so that it is actually PAINTED.
|
|
13
|
+
*
|
|
14
|
+
* Under the native Fullscreen API only the fullscreen element's subtree is
|
|
15
|
+
* rendered: a host appended to <body> exists, receives events, and is
|
|
16
|
+
* invisible. That is what made every menu, dialog and the field chooser
|
|
17
|
+
* "not open" while the grid was fullscreen — they opened, behind the one
|
|
18
|
+
* element the browser was drawing. So while something is fullscreen, hosts go
|
|
19
|
+
* INSIDE it. The CSS-emulated fallback (`.pivot-is-fullscreen`, a fixed
|
|
20
|
+
* z-index 9990 layer) gets the same treatment, for the same reason.
|
|
21
|
+
*/
|
|
22
|
+
declare function portalParent(): HTMLElement;
|
|
23
|
+
interface PortalLayer {
|
|
24
|
+
/**
|
|
25
|
+
* Mount a popup. `build` fills the portal root and may return extra
|
|
26
|
+
* cleanup (timers, observers). Any previous popup closes first.
|
|
27
|
+
*/
|
|
28
|
+
openPopup(build: (portalRoot: HTMLElement) => (() => void) | void): HTMLElement;
|
|
29
|
+
closePopup(): void;
|
|
30
|
+
isOpen(): boolean;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
}
|
|
33
|
+
declare function createPortalLayer(gridRoot: HTMLElement): PortalLayer;
|
|
34
|
+
|
|
35
|
+
interface VanillaContextMenuItem {
|
|
36
|
+
label: string;
|
|
37
|
+
action: () => void;
|
|
38
|
+
/** Inline SVG (or any node) — the lucide component slot, rebound. */
|
|
39
|
+
icon?: () => Node;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Intl.NumberFormat cache keyed by format OBJECT identity — recreated per locale. */
|
|
43
|
+
declare function createValueFormatter(locale: string): (val: unknown, df: PivotField<any>) => string;
|
|
44
|
+
|
|
45
|
+
interface VanillaCellClickEvent {
|
|
46
|
+
/** The NATIVE event — the React layer carries a SyntheticEvent here. */
|
|
47
|
+
event: MouseEvent;
|
|
48
|
+
cellType: 'data' | 'grandTotal';
|
|
49
|
+
value: unknown;
|
|
50
|
+
rowPath: string[];
|
|
51
|
+
colPath: string[];
|
|
52
|
+
/**
|
|
53
|
+
* The source rows behind the cell — resolved by the controller, exactly as
|
|
54
|
+
* React does it (BasePivotGrid routes every click through
|
|
55
|
+
* `controller.resolveCellClick`). Undefined only when no controller
|
|
56
|
+
* resolver is wired.
|
|
57
|
+
*/
|
|
58
|
+
records?: unknown[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** …and the width React's grip starts its drag from. Ported quirk, see below. */
|
|
62
|
+
/** The vanilla cell-prepared contract: text is a string or a Node, never JSX. */
|
|
63
|
+
interface VanillaCellConfig {
|
|
64
|
+
text: string | Node | null;
|
|
65
|
+
style: Record<string, string | number>;
|
|
66
|
+
className: string;
|
|
67
|
+
}
|
|
68
|
+
/** onCellPrepared payload — the React event with cellConfig re-typed to string|Node. */
|
|
69
|
+
interface VanillaCellPreparedEvent {
|
|
70
|
+
area: 'data' | 'row' | 'column';
|
|
71
|
+
cell: unknown;
|
|
72
|
+
rowIndex: number;
|
|
73
|
+
columnIndex: number;
|
|
74
|
+
cellConfig: VanillaCellConfig;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface ChartSeriesDef {
|
|
78
|
+
dataKey: string;
|
|
79
|
+
name: string;
|
|
80
|
+
color: string;
|
|
81
|
+
yAxisId?: string;
|
|
82
|
+
}
|
|
83
|
+
interface ChartSyncResult {
|
|
84
|
+
chartData: unknown[];
|
|
85
|
+
chartSeries: ChartSeriesDef[];
|
|
86
|
+
/**
|
|
87
|
+
* True when `maxPoints` dropped categories.
|
|
88
|
+
*
|
|
89
|
+
* The transformer has always returned this and the bridge has always passed
|
|
90
|
+
* it through — but the type stopped short of declaring it, so a TypeScript
|
|
91
|
+
* consumer could not read the one flag that says the picture is partial. A
|
|
92
|
+
* chart showing the first 100 of 5,000 categories with nothing saying so is
|
|
93
|
+
* a lie told in a picture (#213).
|
|
94
|
+
*/
|
|
95
|
+
isSampled?: boolean;
|
|
96
|
+
/** Categories BEFORE sampling, so a caller can show "100 of 5,000". */
|
|
97
|
+
totalArgs?: number;
|
|
98
|
+
}
|
|
99
|
+
interface VanillaChartIntegrationOptions {
|
|
100
|
+
inverted?: boolean;
|
|
101
|
+
hideTotals?: boolean;
|
|
102
|
+
maxPoints?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Cap on SERIES, which `maxPoints` never covered: it slices the argument
|
|
105
|
+
* side only, so a wide column tree asked a renderer for one element per
|
|
106
|
+
* visible column leaf, uncapped (#213).
|
|
107
|
+
*/
|
|
108
|
+
maxSeries?: number;
|
|
109
|
+
dataFieldsDisplayMode?: 'singleAxis' | 'splitAxes';
|
|
110
|
+
/**
|
|
111
|
+
* Drop a cell from the chart. React has carried this since the hook was
|
|
112
|
+
* written (usePivotChartSync PivotChartIntegrationOptions) and its
|
|
113
|
+
* transformer honours it; the vanilla options type simply never declared
|
|
114
|
+
* it, so the hook existed and was unreachable from here (#213).
|
|
115
|
+
*/
|
|
116
|
+
processCell?: (cell: PivotCell) => boolean;
|
|
117
|
+
transformer?: (engineResult: PivotEngineResult, fields: PivotField<never>[], expandedPaths: Set<string>, locale: string, options: VanillaChartIntegrationOptions) => ChartSyncResult;
|
|
118
|
+
}
|
|
119
|
+
interface ChartSyncControllerLike {
|
|
120
|
+
subscribe(listener: () => void): () => void;
|
|
121
|
+
getState(): {
|
|
122
|
+
engineResult: PivotEngineResult | null;
|
|
123
|
+
fields: unknown[];
|
|
124
|
+
expandedPaths: Set<string>;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface ChartSync {
|
|
128
|
+
/** Re-evaluate the gate now — the setLocale path, which the store misses. */
|
|
129
|
+
refresh(): void;
|
|
130
|
+
stop(): void;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Subscribe a chart to the pivot. Fires `onSync` with the transformed
|
|
134
|
+
* result 150ms after the engine result, the expansion set or the LOCALE
|
|
135
|
+
* changes (and once on start).
|
|
136
|
+
*/
|
|
137
|
+
declare function createChartSync(controller: ChartSyncControllerLike, getLocale: () => string, options: VanillaChartIntegrationOptions, onSync: (result: ChartSyncResult) => void): ChartSync;
|
|
138
|
+
|
|
139
|
+
/** `t()` and its inputs, rebuilt whenever locale/dictionary change. */
|
|
140
|
+
interface ResolvedI18n {
|
|
141
|
+
locale: PivotLocale;
|
|
142
|
+
rtl: boolean;
|
|
143
|
+
dictionary: PivotDictionary;
|
|
144
|
+
t: (key: string) => string;
|
|
145
|
+
}
|
|
146
|
+
declare function resolveI18n(locale?: PivotLocale, dictionary?: Partial<PivotDictionary>, rtl?: boolean): ResolvedI18n;
|
|
147
|
+
/**
|
|
148
|
+
* The vanilla configuration surface.
|
|
149
|
+
*
|
|
150
|
+
* Mirrors `BasePivotGridProps` minus the React mechanics: no render props, no
|
|
151
|
+
* ref — the returned instance IS the ref. Core's generics are deliberately
|
|
152
|
+
* re-bindable (that is why they exist); the vanilla layer binds templates to
|
|
153
|
+
* `string | Node` and events to native `MouseEvent` in M2 when the painters
|
|
154
|
+
* land.
|
|
155
|
+
*/
|
|
156
|
+
interface PivotGridVanillaConfig<TRow = unknown> {
|
|
157
|
+
gridId?: string;
|
|
158
|
+
data: TRow[];
|
|
159
|
+
initialFields?: PivotField<TRow>[];
|
|
160
|
+
/** Controlled fields — same semantics as the React `fields` prop. */
|
|
161
|
+
fields?: PivotField<TRow>[];
|
|
162
|
+
/** Controlled layout — same semantics as the React `layout` prop. */
|
|
163
|
+
layout?: PivotLayoutState;
|
|
164
|
+
theme?: PivotTheme;
|
|
165
|
+
striped?: boolean;
|
|
166
|
+
locale?: PivotLocale;
|
|
167
|
+
rtl?: boolean;
|
|
168
|
+
dictionary?: Partial<PivotDictionary>;
|
|
169
|
+
stateStoring?: PivotStateStoringConfig;
|
|
170
|
+
toolbar?: PivotToolbarConfig;
|
|
171
|
+
workerUrl?: string | URL;
|
|
172
|
+
previewImport?: boolean;
|
|
173
|
+
registry?: PivotControllerOptions<TRow>['registry'];
|
|
174
|
+
keyboardNavigation?: {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
};
|
|
177
|
+
disabled?: boolean;
|
|
178
|
+
/** Extra class on the root element. */
|
|
179
|
+
className?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Enterprise slots (K3): the Community renderer opens the sockets, the
|
|
182
|
+
* Enterprise package fills them. `advancedExport` also seeds the core
|
|
183
|
+
* edition gate, exactly like the React `advancedExport` prop.
|
|
184
|
+
*/
|
|
185
|
+
advancedExport?: boolean;
|
|
186
|
+
upgradeUrl?: string;
|
|
187
|
+
/**
|
|
188
|
+
* The Enterprise sockets themselves, as plain callbacks — the vanilla shape
|
|
189
|
+
* of React's `renderCalculatedFieldModal` / `renderPrefilterBuilder` render
|
|
190
|
+
* props and its `onToggleChart`. Each one, when present, makes the footer
|
|
191
|
+
* draw the matching button (the designer's, the prefilter's, the chart's)
|
|
192
|
+
* and the field menu offer "Edit calculation" on calculated fields; absent,
|
|
193
|
+
* nothing is drawn, so a Community grid stays exactly as it was.
|
|
194
|
+
* `@kanunilabs/pivotgrid-enterprise` fills all four; an app may fill any.
|
|
195
|
+
*/
|
|
196
|
+
onAddCalculatedField?: () => void;
|
|
197
|
+
onEditCalculatedField?: (field: PivotField<TRow>) => void;
|
|
198
|
+
onOpenPrefilter?: () => void;
|
|
199
|
+
onToggleChart?: () => void;
|
|
200
|
+
/** Chart bridge (the React usePivotChartSync contract, subscription-shaped). */
|
|
201
|
+
chartIntegrationOptions?: VanillaChartIntegrationOptions;
|
|
202
|
+
onChartSync?: (result: ChartSyncResult) => void;
|
|
203
|
+
onCellClick?: (e: VanillaCellClickEvent) => void;
|
|
204
|
+
/** Right-click on data cells / non-expandable row cells (viewport coords). */
|
|
205
|
+
onGlobalContextMenu?: (x: number, y: number) => void;
|
|
206
|
+
/** Per-cell hook before a data/header cell hits the DOM — mutate `cellConfig`. */
|
|
207
|
+
onCellPrepared?: (e: VanillaCellPreparedEvent) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Extra items appended to a field's context menu (the React
|
|
210
|
+
* `customContextMenuItems` prop). The React `icon` is a ReactNode; here it
|
|
211
|
+
* is a factory returning a DOM node, so `icon: () => icon('star', 14)`.
|
|
212
|
+
*/
|
|
213
|
+
customContextMenuItems?: (field: PivotField<TRow>) => VanillaContextMenuItem[] | undefined;
|
|
214
|
+
onRefresh?: () => void;
|
|
215
|
+
onImportData?: (data: TRow[]) => void;
|
|
216
|
+
onFieldsChange?: (fields: PivotField<TRow>[]) => void;
|
|
217
|
+
onLayoutChange?: (layout: PivotLayoutState) => void;
|
|
218
|
+
onFieldMove?: PivotControllerOptions<TRow>['onFieldMove'];
|
|
219
|
+
onBeforePivotCalculate?: () => void;
|
|
220
|
+
onAfterPivotCalculate?: PivotControllerOptions<TRow>['onAfterPivotCalculate'];
|
|
221
|
+
onExporting?: PivotControllerOptions<TRow>['onExporting'];
|
|
222
|
+
onError?: (error: Error) => void;
|
|
223
|
+
onChartStateLoaded?: PivotControllerOptions<TRow>['onChartStateLoaded'];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The instance handle. `controller` is the full engine — same object the React `onReady` hands out. */
|
|
227
|
+
interface PivotGridApi<TRow = unknown> {
|
|
228
|
+
controller: PivotController<TRow>;
|
|
229
|
+
element: HTMLElement;
|
|
230
|
+
destroy(): void;
|
|
231
|
+
setData(data: TRow[]): void;
|
|
232
|
+
setFields(fields: PivotField<TRow>[]): void;
|
|
233
|
+
setLocale(locale: PivotLocale, dictionary?: Partial<PivotDictionary>, rtl?: boolean): void;
|
|
234
|
+
}
|
|
235
|
+
declare function createPivotGrid<TRow = unknown>(container: HTMLElement, config: PivotGridVanillaConfig<TRow>): PivotGridApi<TRow>;
|
|
236
|
+
|
|
237
|
+
declare function icon(name: string, size?: number, color?: string): SVGSVGElement;
|
|
238
|
+
/** The lucide `fill` prop (filled funnel/star when active). */
|
|
239
|
+
declare function filledIcon(name: string, size?: number, color?: string): SVGSVGElement;
|
|
240
|
+
|
|
241
|
+
export { type ChartSeriesDef, type ChartSyncResult, type PivotGridApi, type PivotGridVanillaConfig, type PortalLayer, type ResolvedI18n, type VanillaCellClickEvent, type VanillaCellConfig, type VanillaCellPreparedEvent, type VanillaChartIntegrationOptions, createChartSync, createPivotGrid, createPortalLayer, createThemedHost, createValueFormatter, filledIcon, icon, portalParent, resolveI18n };
|