@agile-team/mach-table 0.39.1 → 0.40.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 (44) hide show
  1. package/README.md +7 -7
  2. package/dist/adapter.cjs +1 -1
  3. package/dist/adapter.d.cts +11 -3
  4. package/dist/adapter.d.ts +11 -3
  5. package/dist/adapter.js +1 -1
  6. package/dist/analysis.d.cts +2 -2
  7. package/dist/analysis.d.ts +2 -2
  8. package/dist/business.cjs +1 -1
  9. package/dist/business.js +1 -1
  10. package/dist/{api-ChEKWrvH.d.cts → colDef-BiwNRXwf.d.cts} +256 -256
  11. package/dist/{api-ChEKWrvH.d.ts → colDef-BiwNRXwf.d.ts} +256 -256
  12. package/dist/{configuration-CZm-aiTf.d.cts → configuration-D57x5Ovu.d.cts} +3 -3
  13. package/dist/{configuration-BPj5MIUw.d.ts → configuration-ZGE-MtGs.d.ts} +3 -3
  14. package/dist/import.cjs +1 -1
  15. package/dist/import.d.cts +1 -1
  16. package/dist/import.d.ts +1 -1
  17. package/dist/import.js +1 -1
  18. package/dist/index.cjs +6 -6
  19. package/dist/index.d.cts +6 -5
  20. package/dist/index.d.ts +6 -5
  21. package/dist/index.js +6 -6
  22. package/dist/multi-range.d.cts +1 -1
  23. package/dist/multi-range.d.ts +1 -1
  24. package/dist/ordering.d.cts +1 -1
  25. package/dist/ordering.d.ts +1 -1
  26. package/dist/preferences.cjs +1 -1
  27. package/dist/preferences.d.cts +1 -1
  28. package/dist/preferences.d.ts +1 -1
  29. package/dist/preferences.js +1 -1
  30. package/dist/server-side.cjs +1 -1
  31. package/dist/server-side.d.cts +1 -1
  32. package/dist/server-side.d.ts +1 -1
  33. package/dist/server-side.js +1 -1
  34. package/dist/{shared-BIBSfPcs.d.cts → shared-C9SPn-Hh.d.ts} +1 -1
  35. package/dist/{shared-Qnznvth3.d.ts → shared-TcluaEBe.d.cts} +1 -1
  36. package/dist/workbench.cjs +1 -1
  37. package/dist/workbench.d.cts +3 -3
  38. package/dist/workbench.d.ts +3 -3
  39. package/dist/workbench.js +1 -1
  40. package/dist/worker.cjs +1 -1
  41. package/dist/worker.d.cts +2 -2
  42. package/dist/worker.d.ts +2 -2
  43. package/dist/worker.js +1 -1
  44. package/package.json +2 -2
@@ -60,261 +60,6 @@ interface RowNode<TData = any> {
60
60
  treeLoadError?: unknown;
61
61
  }
62
62
 
63
- interface ValueGetterParams<TData = any, TValue = any> {
64
- data: TData | null;
65
- node: RowNode<TData>;
66
- colDef: ColDef<TData, TValue>;
67
- column: Column<TData>;
68
- api: GridApi<TData>;
69
- }
70
- interface ValueFormatterParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
71
- value: TValue;
72
- }
73
- interface CellRendererParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
74
- value: TValue;
75
- formatted: string;
76
- rowIndex: number;
77
- rendererParams?: Record<string, any>;
78
- }
79
- interface CellClassParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
80
- value: TValue;
81
- rowIndex: number;
82
- }
83
- interface EditableParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
84
- value: TValue;
85
- rowIndex: number;
86
- }
87
- interface CellEditorParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
88
- value: TValue;
89
- rowIndex: number;
90
- keyPress?: string | null;
91
- }
92
- interface ValueSetterParams<TData = any, TValue = any> {
93
- oldValue: TValue;
94
- newValue: TValue;
95
- data: TData;
96
- node: RowNode<TData>;
97
- colDef: ColDef<TData, TValue>;
98
- column: Column<TData>;
99
- api: GridApi<TData>;
100
- }
101
- interface GetRowIdParams<TData = any> {
102
- data: TData;
103
- index: number;
104
- api: GridApi<TData>;
105
- }
106
- interface GetRowHeightParams<TData = any> {
107
- data: TData | null;
108
- node: RowNode<TData>;
109
- api: GridApi<TData>;
110
- }
111
- interface TooltipParams<TData = any> {
112
- data: TData | null;
113
- node: RowNode<TData>;
114
- api: GridApi<TData>;
115
- colId: string;
116
- value: any;
117
- formatted: string;
118
- rowIndex: number;
119
- }
120
- interface ContextMenuParams<TData = any> {
121
- data: TData | null;
122
- node: RowNode<TData>;
123
- api: GridApi<TData>;
124
- colId: string;
125
- value: any;
126
- rowIndex: number;
127
- }
128
- interface ContextMenuItem {
129
- label?: string;
130
- action?: () => void;
131
- danger?: boolean;
132
- disabled?: boolean;
133
- separator?: boolean;
134
- }
135
- interface HeaderComponentParams<TData = any> {
136
- colDef: ColDef<TData>;
137
- column: Column<TData>;
138
- api: GridApi<TData>;
139
- }
140
- interface ICellRendererResult {
141
- el: HTMLElement;
142
- /** Reuses the mounted renderer for an update. Return false to request recreation. */
143
- refresh?(params: CellRendererParams): boolean | void;
144
- destroy?: () => void;
145
- }
146
- type CellRendererOutput = string | HTMLElement | ICellRendererResult | null | undefined;
147
- interface ICellEditor<TValue = any> {
148
- el: HTMLElement;
149
- getValue(): TValue | null | undefined;
150
- focus?(): void;
151
- destroy?(): void;
152
- isCancelBeforeStart?(): boolean;
153
- isCancelAfterEnd?(value: TValue | null | undefined): boolean;
154
- }
155
-
156
- type SortDirection = "asc" | "desc";
157
- type PinnedDirection = "left" | "right";
158
- type FilterType = "text" | "number" | "date" | "set";
159
- type CellAlign = "left" | "center" | "right";
160
- type ValueInputSource = "editor" | "clipboard" | "import";
161
- type ValueOutputTarget = "clipboard" | "csv" | "xlsx";
162
- interface ValueParserParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
163
- value: unknown;
164
- oldValue: TValue | undefined;
165
- source: ValueInputSource;
166
- }
167
- interface ValueSerializerParams<TData = any, TValue = any> extends ValueFormatterParams<TData, TValue> {
168
- target: ValueOutputTarget;
169
- }
170
- type TextFilterMatch = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "blank" | "notBlank";
171
- type NumberFilterMatch = "equals" | "notEquals" | "lessThan" | "lessThanOrEqual" | "greaterThan" | "greaterThanOrEqual" | "inRange" | "blank" | "notBlank";
172
- type DateFilterMatch = "equals" | "notEquals" | "lessThan" | "greaterThan" | "inRange" | "blank" | "notBlank";
173
- interface TextFilterCondition {
174
- match: TextFilterMatch;
175
- value?: string;
176
- }
177
- interface NumberFilterCondition {
178
- match: NumberFilterMatch;
179
- value?: number;
180
- value2?: number;
181
- }
182
- interface DateFilterCondition {
183
- match: DateFilterMatch;
184
- value?: string;
185
- value2?: string;
186
- }
187
- interface SetFilterCondition {
188
- values: (string | number | null)[];
189
- }
190
- interface TextColumnFilter {
191
- type: "text";
192
- operator?: "and" | "or";
193
- conditions: TextFilterCondition[];
194
- }
195
- interface NumberColumnFilter {
196
- type: "number";
197
- operator?: "and" | "or";
198
- conditions: NumberFilterCondition[];
199
- }
200
- interface DateColumnFilter {
201
- type: "date";
202
- operator?: "and" | "or";
203
- conditions: DateFilterCondition[];
204
- }
205
- interface SetColumnFilter {
206
- type: "set";
207
- values: (string | number | null)[];
208
- }
209
- type ColumnFilter = TextColumnFilter | NumberColumnFilter | DateColumnFilter | SetColumnFilter;
210
- type FilterModel = Record<string, ColumnFilter>;
211
- interface SortModelItem {
212
- colId: string;
213
- direction: SortDirection;
214
- }
215
- type SortModel = SortModelItem[];
216
- interface SelectEditorOption {
217
- label: string;
218
- value: string | number;
219
- disabled?: boolean;
220
- }
221
- interface SelectEditorParams {
222
- /** Primitive options kept for concise same-label/same-value selects. */
223
- values?: readonly (string | number)[];
224
- /** Label/value options when the stored value differs from its display text. */
225
- options?: readonly SelectEditorOption[];
226
- }
227
- interface SetFilterParams {
228
- values?: (string | number | null)[];
229
- maxValues?: number;
230
- }
231
- type CellEditorFactory = (params: CellEditorParams) => ICellEditor;
232
- type CellRendererFn = (params: CellRendererParams) => string | HTMLElement | ICellRendererResult | null | undefined;
233
- type CellClassRule = string | string[] | ((params: CellClassParams) => string | string[] | null | undefined);
234
- type CellStyleRule = Partial<CSSStyleDeclaration> | ((params: CellClassParams<any, any>) => Partial<CSSStyleDeclaration> | null | undefined);
235
- interface ColDef<TData = any, TValue = any> {
236
- colId?: string;
237
- field?: string;
238
- headerName?: string;
239
- align?: CellAlign;
240
- headerAlign?: CellAlign;
241
- headerClass?: string | string[];
242
- headerTooltip?: string;
243
- headerComponent?: (params: HeaderComponentParams<TData>) => string | HTMLElement | ICellRendererResult | null | undefined;
244
- /** 未声明 width 时默认按内容测宽;false 保留默认宽度。maxWidth 可覆盖自动测宽的 360px 上限。 */
245
- autoWidth?: boolean;
246
- width?: number;
247
- minWidth?: number;
248
- maxWidth?: number;
249
- flex?: number;
250
- /** Excludes the column from `columnLayout: "fit"` scaling. */
251
- suppressSizeToFit?: boolean;
252
- /** Hides the per-column tools trigger while keeping the global column workbench available. */
253
- suppressColumnMenu?: boolean;
254
- hide?: boolean;
255
- pinned?: PinnedDirection | boolean;
256
- sortable?: boolean;
257
- resizable?: boolean;
258
- movable?: boolean;
259
- filter?: boolean | FilterType;
260
- filterParams?: SetFilterParams;
261
- editable?: boolean | ((params: EditableParams<TData, TValue>) => boolean);
262
- cellEditor?: "text" | "number" | "date" | "select" | CellEditorFactory | string;
263
- cellEditorParams?: SelectEditorParams;
264
- wrapText?: boolean;
265
- checkboxSelection?: boolean;
266
- rowGroup?: boolean;
267
- aggFunc?: string;
268
- cellStyle?: CellStyleRule;
269
- selectable?: (params: CellClassParams<TData, TValue>) => boolean;
270
- singleClickEdit?: boolean;
271
- tooltipValueGetter?: (params: ValueFormatterParams<TData, TValue>) => string | null | undefined;
272
- rowSpan?: (params: CellClassParams<TData, TValue>) => number;
273
- autoRowSpan?: boolean;
274
- colSpan?: (params: CellClassParams<TData, TValue>) => number;
275
- autoHeight?: boolean;
276
- validate?: (newValue: TValue, params: ValueSetterParams<TData, TValue>) => string | true | null | undefined | Promise<string | true | null | undefined>;
277
- rowDrag?: boolean;
278
- valueGetter?: (params: ValueGetterParams<TData, TValue>) => TValue;
279
- valueSetter?: (params: ValueSetterParams<TData, TValue>) => boolean;
280
- /** Synchronous user-input normalization. Not called by trusted transactions or undo replay. */
281
- valueParser?: (params: ValueParserParams<TData, TValue>) => TValue;
282
- /** Clipboard/file output; display formatting and sort/filter continue to use stored values. */
283
- valueSerializer?: (params: ValueSerializerParams<TData, TValue>) => unknown;
284
- valueFormatter?: (params: ValueFormatterParams<TData, TValue>) => any;
285
- /** true 使用默认状态色;映射值为颜色,或 { label, color }。自定义 renderer 优先。 */
286
- status?: ColumnStatus;
287
- cellRenderer?: CellRendererFn | string;
288
- cellRendererParams?: Record<string, any>;
289
- cellClass?: CellClassRule;
290
- comparator?: (valueA: any, valueB: any, nodeA: RowNode<TData>, nodeB: RowNode<TData>) => number;
291
- /** Named column type(s), resolved left-to-right before this column definition. */
292
- type?: string | readonly string[];
293
- initialSort?: SortDirection;
294
- onCellClick?: (event: CellClickEvent<TData, TValue>) => void;
295
- onCellDoubleClick?: (event: CellDoubleClickEvent<TData, TValue>) => void;
296
- }
297
- interface ColDefGroup<TData = any> {
298
- groupId?: string;
299
- headerName?: string;
300
- headerClass?: string | string[];
301
- children: (ColDefGroup<TData> | ColDef<TData>)[];
302
- }
303
- type ColDefOrGroup<TData = any> = ColDefGroup<TData> | ColDef<TData>;
304
- declare function isColDefGroup<TData = any>(def: ColDefOrGroup<TData>): def is ColDefGroup<TData>;
305
- interface ColumnState {
306
- colId: string;
307
- hide?: boolean;
308
- width?: number;
309
- /** Active flex weight. A resize clears flex and turns width into a manual override. */
310
- flex?: number | null;
311
- /** Distinguishes responsive/definition width from an explicit user or API override. */
312
- widthMode?: "auto" | "manual";
313
- /** Measured content basis for responsive fit sizing; independent of the rendered width. */
314
- contentWidth?: number;
315
- pinned?: "left" | "right" | null;
316
- }
317
-
318
63
  interface AdvancedFilterCondition {
319
64
  kind: "condition";
320
65
  colId: string;
@@ -1445,4 +1190,259 @@ interface GridApi<TData = any> {
1445
1190
  isDestroyed(): boolean;
1446
1191
  }
1447
1192
 
1448
- export { type ContextMenuItem as $, type AdvancedFilterModel as A, type ApplyGridStateOptions as B, type ColDef as C, type CellAlign as D, type CellClassParams as E, type FilterType as F, type GridFeature as G, type CellClassRule as H, type ImportMatrixOptions as I, type CellClickEvent as J, type CellContextMenuEvent as K, type CellDoubleClickEvent as L, type CellEditingStartedEvent as M, type CellEditingStoppedEvent as N, type CellEditorFactory as O, type CellEditorParams as P, type CellRendererOutput as Q, type CellStyleRule as R, type SortModel as S, type CellValueChangedEvent as T, type ColDefOrGroup as U, type ColumnLayoutMode as V, type ColumnMovedEvent as W, type ColumnResizedEvent as X, type ColumnStatus as Y, type ColumnVisibilityChangedEvent as Z, type ColumnWorkbenchItem as _, type GridCellRange as a, type PaginationChangedEvent as a$, type ContextMenuParams as a0, type CsvExportParams as a1, DEFAULT_LOCALE as a2, type DatasourceMode as a3, type DateFilterCondition as a4, type DateFilterMatch as a5, type DetailRowRendererParams as a6, type DetailToggledEvent as a7, type DirtyStateChangedEvent as a8, type DomLayoutMode as a9, type GridHierarchyApi as aA, type GridIoApi as aB, type GridPaginationApi as aC, type GridPerformanceSnapshot as aD, type GridPersistenceOptions as aE, type GridReadyEvent as aF, type GridRowsApi as aG, type GridSelectionApi as aH, type GridSortingApi as aI, type GridStateApi as aJ, type GridStateSection as aK, type GridUpdateSchedulerSnapshot as aL, type GridViewApi as aM, type HeaderComponentParams as aN, type ICellEditor as aO, type ICellRendererResult as aP, type ImportCsvOptions as aQ, type InfiniteGetRowsParams as aR, LOCALE_EN as aS, type MachTableLocale as aT, type MachTableLocaleKey as aU, type MatrixExportParams as aV, type ModelUpdatedEvent as aW, type NumberFilterCondition as aX, type NumberFilterMatch as aY, type OverlayContent as aZ, type OverlayTemplate as a_, EVENT_TYPES as aa, type EditableIndicator as ab, type EditableParams as ac, type EventHandlers as ad, type FilterChangedEvent as ae, type GetRowHeightParams as af, type GridAsyncOptions as ag, type GridBatchSaveResult as ah, type GridCellChange as ai, type GridColumnsApi as aj, type GridDataProcessorColumn as ak, type GridDataProcessorRequest as al, type GridDataProcessorResult as am, type GridDataProcessorRow as an, type GridDatasource as ao, type GridDiagnosticError as ap, type GridDiagnostics as aq, type GridDiagnosticsApi as ar, type GridEditType as as, type GridEditingApi as at, type GridErrorCode as au, type GridErrorEvent as av, type GridEventBase as aw, type GridEventMap as ax, type GridFeatureContext as ay, type GridFilteringApi as az, type GridApi as b, type PaginationConfig as b0, type PinnedDirection as b1, type PrintOptions as b2, type RangeSelectionChangedEvent as b3, type RefreshCellsParams as b4, type RemoteBlockCacheSnapshot as b5, type ResolvedGridOptions as b6, type RowClickEvent as b7, type RowDragEndEvent as b8, type RowDragIntent as b9, type ThemeMode as bA, type TooltipParams as bB, type TreeChildrenLoadFailedEvent as bC, type TreeChildrenLoadedEvent as bD, type TreeDataLoadParams as bE, type ValueFormatterParams as bF, type ValueGetterParams as bG, type ValueInputSource as bH, type ValueOutputTarget as bI, type ValueParserParams as bJ, type ValueSerializerParams as bK, type ValueSetterParams as bL, type WatermarkConfig as bM, formatText as bN, formatTwo as bO, isColDefGroup as bP, matchLocaleKey as bQ, type RowDragPolicy as ba, type RowEditChange as bb, type RowEditValidationParams as bc, type RowEditValidationResult as bd, type RowEditingStartedEvent as be, type RowEditingStoppedEvent as bf, type RowNode as bg, type RowSelectionMode as bh, type RowStyleParams as bi, type RowStyleRule as bj, type RowTone as bk, type RowTransaction as bl, type SaveChangeIssue as bm, type SaveChangesResult as bn, type SelectEditorOption as bo, type SelectEditorParams as bp, type SelectionChangedEvent as bq, type SetFilterCondition as br, type SetFilterParams as bs, type SortChangedEvent as bt, type SortDirection as bu, type SortModelItem as bv, type StatusBarConfig as bw, type StatusBarPanel as bx, type TextFilterCondition as by, type TextFilterMatch as bz, type GridOptions as c, type GridDataProcessor as d, type GridComponents as e, type GridState as f, type GridStateStore as g, type FilterModel as h, type FieldPath as i, type GridEventType as j, type SaveChangesHandler as k, type ColumnFilter as l, type AdvancedFilterCondition as m, type AdvancedFilterNode as n, type AdvancedFilterGroup as o, type ColDefGroup as p, type GridStateInput as q, type GridSize as r, type CellRendererParams as s, type GridChange as t, type CellRendererFn as u, type FieldPathValue as v, type SaveChangeConflict as w, type ColumnState as x, type ActionPolicy as y, type ActionPolicyContext as z };
1193
+ interface ValueGetterParams<TData = any, TValue = any> {
1194
+ data: TData | null;
1195
+ node: RowNode<TData>;
1196
+ colDef: ColDef<TData, TValue>;
1197
+ column: Column<TData>;
1198
+ api: GridApi<TData>;
1199
+ }
1200
+ interface ValueFormatterParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
1201
+ value: TValue;
1202
+ }
1203
+ interface CellRendererParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
1204
+ value: TValue;
1205
+ formatted: string;
1206
+ rowIndex: number;
1207
+ rendererParams?: Record<string, any>;
1208
+ }
1209
+ interface CellClassParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
1210
+ value: TValue;
1211
+ rowIndex: number;
1212
+ }
1213
+ interface EditableParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
1214
+ value: TValue;
1215
+ rowIndex: number;
1216
+ }
1217
+ interface CellEditorParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
1218
+ value: TValue;
1219
+ rowIndex: number;
1220
+ keyPress?: string | null;
1221
+ }
1222
+ interface ValueSetterParams<TData = any, TValue = any> {
1223
+ oldValue: TValue;
1224
+ newValue: TValue;
1225
+ data: TData;
1226
+ node: RowNode<TData>;
1227
+ colDef: ColDef<TData, TValue>;
1228
+ column: Column<TData>;
1229
+ api: GridApi<TData>;
1230
+ }
1231
+ interface GetRowIdParams<TData = any> {
1232
+ data: TData;
1233
+ index: number;
1234
+ api: GridApi<TData>;
1235
+ }
1236
+ interface GetRowHeightParams<TData = any> {
1237
+ data: TData | null;
1238
+ node: RowNode<TData>;
1239
+ api: GridApi<TData>;
1240
+ }
1241
+ interface TooltipParams<TData = any> {
1242
+ data: TData | null;
1243
+ node: RowNode<TData>;
1244
+ api: GridApi<TData>;
1245
+ colId: string;
1246
+ value: any;
1247
+ formatted: string;
1248
+ rowIndex: number;
1249
+ }
1250
+ interface ContextMenuParams<TData = any> {
1251
+ data: TData | null;
1252
+ node: RowNode<TData>;
1253
+ api: GridApi<TData>;
1254
+ colId: string;
1255
+ value: any;
1256
+ rowIndex: number;
1257
+ }
1258
+ interface ContextMenuItem {
1259
+ label?: string;
1260
+ action?: () => void;
1261
+ danger?: boolean;
1262
+ disabled?: boolean;
1263
+ separator?: boolean;
1264
+ }
1265
+ interface HeaderComponentParams<TData = any> {
1266
+ colDef: ColDef<TData>;
1267
+ column: Column<TData>;
1268
+ api: GridApi<TData>;
1269
+ }
1270
+ interface ICellRendererResult {
1271
+ el: HTMLElement;
1272
+ /** Reuses the mounted renderer for an update. Return false to request recreation. */
1273
+ refresh?(params: CellRendererParams): boolean | void;
1274
+ destroy?: () => void;
1275
+ }
1276
+ type CellRendererOutput = string | HTMLElement | ICellRendererResult | null | undefined;
1277
+ interface ICellEditor<TValue = any> {
1278
+ el: HTMLElement;
1279
+ getValue(): TValue | null | undefined;
1280
+ focus?(): void;
1281
+ destroy?(): void;
1282
+ isCancelBeforeStart?(): boolean;
1283
+ isCancelAfterEnd?(value: TValue | null | undefined): boolean;
1284
+ }
1285
+
1286
+ type SortDirection = "asc" | "desc";
1287
+ type PinnedDirection = "left" | "right";
1288
+ type FilterType = "text" | "number" | "date" | "set";
1289
+ type CellAlign = "left" | "center" | "right";
1290
+ type ValueInputSource = "editor" | "clipboard" | "import";
1291
+ type ValueOutputTarget = "clipboard" | "csv" | "xlsx";
1292
+ interface ValueParserParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
1293
+ value: unknown;
1294
+ oldValue: TValue | undefined;
1295
+ source: ValueInputSource;
1296
+ }
1297
+ interface ValueSerializerParams<TData = any, TValue = any> extends ValueFormatterParams<TData, TValue> {
1298
+ target: ValueOutputTarget;
1299
+ }
1300
+ type TextFilterMatch = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "blank" | "notBlank";
1301
+ type NumberFilterMatch = "equals" | "notEquals" | "lessThan" | "lessThanOrEqual" | "greaterThan" | "greaterThanOrEqual" | "inRange" | "blank" | "notBlank";
1302
+ type DateFilterMatch = "equals" | "notEquals" | "lessThan" | "greaterThan" | "inRange" | "blank" | "notBlank";
1303
+ interface TextFilterCondition {
1304
+ match: TextFilterMatch;
1305
+ value?: string;
1306
+ }
1307
+ interface NumberFilterCondition {
1308
+ match: NumberFilterMatch;
1309
+ value?: number;
1310
+ value2?: number;
1311
+ }
1312
+ interface DateFilterCondition {
1313
+ match: DateFilterMatch;
1314
+ value?: string;
1315
+ value2?: string;
1316
+ }
1317
+ interface SetFilterCondition {
1318
+ values: (string | number | null)[];
1319
+ }
1320
+ interface TextColumnFilter {
1321
+ type: "text";
1322
+ operator?: "and" | "or";
1323
+ conditions: TextFilterCondition[];
1324
+ }
1325
+ interface NumberColumnFilter {
1326
+ type: "number";
1327
+ operator?: "and" | "or";
1328
+ conditions: NumberFilterCondition[];
1329
+ }
1330
+ interface DateColumnFilter {
1331
+ type: "date";
1332
+ operator?: "and" | "or";
1333
+ conditions: DateFilterCondition[];
1334
+ }
1335
+ interface SetColumnFilter {
1336
+ type: "set";
1337
+ values: (string | number | null)[];
1338
+ }
1339
+ type ColumnFilter = TextColumnFilter | NumberColumnFilter | DateColumnFilter | SetColumnFilter;
1340
+ type FilterModel = Record<string, ColumnFilter>;
1341
+ interface SortModelItem {
1342
+ colId: string;
1343
+ direction: SortDirection;
1344
+ }
1345
+ type SortModel = SortModelItem[];
1346
+ interface SelectEditorOption {
1347
+ label: string;
1348
+ value: string | number;
1349
+ disabled?: boolean;
1350
+ }
1351
+ interface SelectEditorParams {
1352
+ /** Primitive options kept for concise same-label/same-value selects. */
1353
+ values?: readonly (string | number)[];
1354
+ /** Label/value options when the stored value differs from its display text. */
1355
+ options?: readonly SelectEditorOption[];
1356
+ }
1357
+ interface SetFilterParams {
1358
+ values?: (string | number | null)[];
1359
+ maxValues?: number;
1360
+ }
1361
+ type CellEditorFactory = (params: CellEditorParams) => ICellEditor;
1362
+ type CellRendererFn = (params: CellRendererParams) => string | HTMLElement | ICellRendererResult | null | undefined;
1363
+ type CellClassRule = string | string[] | ((params: CellClassParams) => string | string[] | null | undefined);
1364
+ type CellStyleRule = Partial<CSSStyleDeclaration> | ((params: CellClassParams<any, any>) => Partial<CSSStyleDeclaration> | null | undefined);
1365
+ interface ColDef<TData = any, TValue = any> {
1366
+ colId?: string;
1367
+ field?: string;
1368
+ headerName?: string;
1369
+ align?: CellAlign;
1370
+ headerAlign?: CellAlign;
1371
+ headerClass?: string | string[];
1372
+ headerTooltip?: string;
1373
+ headerComponent?: (params: HeaderComponentParams<TData>) => string | HTMLElement | ICellRendererResult | null | undefined;
1374
+ /** 未声明 width 时默认按内容测宽;false 保留默认宽度。maxWidth 可覆盖自动测宽的 360px 上限。 */
1375
+ autoWidth?: boolean;
1376
+ width?: number;
1377
+ minWidth?: number;
1378
+ maxWidth?: number;
1379
+ flex?: number;
1380
+ /** Excludes the column from `columnLayout: "fit"` scaling. */
1381
+ suppressSizeToFit?: boolean;
1382
+ /** Hides the per-column tools trigger while keeping the global column workbench available. */
1383
+ suppressColumnMenu?: boolean;
1384
+ hide?: boolean;
1385
+ pinned?: PinnedDirection | boolean;
1386
+ sortable?: boolean;
1387
+ resizable?: boolean;
1388
+ movable?: boolean;
1389
+ filter?: boolean | FilterType;
1390
+ filterParams?: SetFilterParams;
1391
+ editable?: boolean | ((params: EditableParams<TData, TValue>) => boolean);
1392
+ cellEditor?: "text" | "number" | "date" | "select" | CellEditorFactory | string;
1393
+ cellEditorParams?: SelectEditorParams;
1394
+ wrapText?: boolean;
1395
+ checkboxSelection?: boolean;
1396
+ rowGroup?: boolean;
1397
+ aggFunc?: string;
1398
+ cellStyle?: CellStyleRule;
1399
+ selectable?: (params: CellClassParams<TData, TValue>) => boolean;
1400
+ singleClickEdit?: boolean;
1401
+ tooltipValueGetter?: (params: ValueFormatterParams<TData, TValue>) => string | null | undefined;
1402
+ rowSpan?: (params: CellClassParams<TData, TValue>) => number;
1403
+ autoRowSpan?: boolean;
1404
+ colSpan?: (params: CellClassParams<TData, TValue>) => number;
1405
+ autoHeight?: boolean;
1406
+ validate?: (newValue: TValue, params: ValueSetterParams<TData, TValue>) => string | true | null | undefined | Promise<string | true | null | undefined>;
1407
+ rowDrag?: boolean;
1408
+ valueGetter?: (params: ValueGetterParams<TData, TValue>) => TValue;
1409
+ valueSetter?: (params: ValueSetterParams<TData, TValue>) => boolean;
1410
+ /** Synchronous user-input normalization. Not called by trusted transactions or undo replay. */
1411
+ valueParser?: (params: ValueParserParams<TData, TValue>) => TValue;
1412
+ /** Clipboard/file output; display formatting and sort/filter continue to use stored values. */
1413
+ valueSerializer?: (params: ValueSerializerParams<TData, TValue>) => unknown;
1414
+ valueFormatter?: (params: ValueFormatterParams<TData, TValue>) => any;
1415
+ /** true 使用默认状态色;映射值为颜色,或 { label, color }。自定义 renderer 优先。 */
1416
+ status?: ColumnStatus;
1417
+ cellRenderer?: CellRendererFn | string;
1418
+ cellRendererParams?: Record<string, any>;
1419
+ cellClass?: CellClassRule;
1420
+ comparator?: (valueA: any, valueB: any, nodeA: RowNode<TData>, nodeB: RowNode<TData>) => number;
1421
+ /** Named column type(s), resolved left-to-right before this column definition. */
1422
+ type?: string | readonly string[];
1423
+ initialSort?: SortDirection;
1424
+ onCellClick?: (event: CellClickEvent<TData, TValue>) => void;
1425
+ onCellDoubleClick?: (event: CellDoubleClickEvent<TData, TValue>) => void;
1426
+ }
1427
+ interface ColDefGroup<TData = any> {
1428
+ groupId?: string;
1429
+ headerName?: string;
1430
+ headerClass?: string | string[];
1431
+ children: (ColDefGroup<TData> | ColDef<TData>)[];
1432
+ }
1433
+ type ColDefOrGroup<TData = any> = ColDefGroup<TData> | ColDef<TData>;
1434
+ declare function isColDefGroup<TData = any>(def: ColDefOrGroup<TData>): def is ColDefGroup<TData>;
1435
+ interface ColumnState {
1436
+ colId: string;
1437
+ hide?: boolean;
1438
+ width?: number;
1439
+ /** Active flex weight. A resize clears flex and turns width into a manual override. */
1440
+ flex?: number | null;
1441
+ /** Distinguishes responsive/definition width from an explicit user or API override. */
1442
+ widthMode?: "auto" | "manual";
1443
+ /** Measured content basis for responsive fit sizing; independent of the rendered width. */
1444
+ contentWidth?: number;
1445
+ pinned?: "left" | "right" | null;
1446
+ }
1447
+
1448
+ export { type ContextMenuItem as $, type AdvancedFilterModel as A, type ApplyGridStateOptions as B, type ColDef as C, type CellAlign as D, type CellClassParams as E, type FilterType as F, type GridFeature as G, type CellClassRule as H, type ImportMatrixOptions as I, type CellClickEvent as J, type CellContextMenuEvent as K, type CellDoubleClickEvent as L, type CellEditingStartedEvent as M, type CellEditingStoppedEvent as N, type CellEditorFactory as O, type CellEditorParams as P, type CellRendererOutput as Q, type CellStyleRule as R, type SortModel as S, type CellValueChangedEvent as T, type ColDefOrGroup as U, type ColumnLayoutMode as V, type ColumnMovedEvent as W, type ColumnResizedEvent as X, type ColumnStatus as Y, type ColumnVisibilityChangedEvent as Z, type ColumnWorkbenchItem as _, type GridCellRange as a, type PaginationChangedEvent as a$, type ContextMenuParams as a0, type CsvExportParams as a1, DEFAULT_LOCALE as a2, type DatasourceMode as a3, type DateFilterCondition as a4, type DateFilterMatch as a5, type DetailRowRendererParams as a6, type DetailToggledEvent as a7, type DirtyStateChangedEvent as a8, type DomLayoutMode as a9, type GridHierarchyApi as aA, type GridIoApi as aB, type GridPaginationApi as aC, type GridPerformanceSnapshot as aD, type GridPersistenceOptions as aE, type GridReadyEvent as aF, type GridRowsApi as aG, type GridSelectionApi as aH, type GridSortingApi as aI, type GridStateApi as aJ, type GridStateSection as aK, type GridUpdateSchedulerSnapshot as aL, type GridViewApi as aM, type HeaderComponentParams as aN, type ICellEditor as aO, type ICellRendererResult as aP, type ImportCsvOptions as aQ, type InfiniteGetRowsParams as aR, LOCALE_EN as aS, type MachTableLocale as aT, type MachTableLocaleKey as aU, type MatrixExportParams as aV, type ModelUpdatedEvent as aW, type NumberFilterCondition as aX, type NumberFilterMatch as aY, type OverlayContent as aZ, type OverlayTemplate as a_, EVENT_TYPES as aa, type EditableIndicator as ab, type EditableParams as ac, type EventHandlers as ad, type FilterChangedEvent as ae, type GetRowHeightParams as af, type GridAsyncOptions as ag, type GridBatchSaveResult as ah, type GridCellChange as ai, type GridColumnsApi as aj, type GridDataProcessorColumn as ak, type GridDataProcessorRequest as al, type GridDataProcessorResult as am, type GridDataProcessorRow as an, type GridDatasource as ao, type GridDiagnosticError as ap, type GridDiagnostics as aq, type GridDiagnosticsApi as ar, type GridEditType as as, type GridEditingApi as at, type GridErrorCode as au, type GridErrorEvent as av, type GridEventBase as aw, type GridEventMap as ax, type GridFeatureContext as ay, type GridFilteringApi as az, type GridApi as b, type PaginationConfig as b0, type PinnedDirection as b1, type PrintOptions as b2, type RangeSelectionChangedEvent as b3, type RefreshCellsParams as b4, type RemoteBlockCacheSnapshot as b5, type ResolvedGridOptions as b6, type RowClickEvent as b7, type RowDragEndEvent as b8, type RowDragIntent as b9, type ThemeMode as bA, type TooltipParams as bB, type TreeChildrenLoadFailedEvent as bC, type TreeChildrenLoadedEvent as bD, type TreeDataLoadParams as bE, type ValueFormatterParams as bF, type ValueGetterParams as bG, type ValueInputSource as bH, type ValueOutputTarget as bI, type ValueParserParams as bJ, type ValueSerializerParams as bK, type ValueSetterParams as bL, type WatermarkConfig as bM, formatText as bN, formatTwo as bO, isColDefGroup as bP, matchLocaleKey as bQ, type RowDragPolicy as ba, type RowEditChange as bb, type RowEditValidationParams as bc, type RowEditValidationResult as bd, type RowEditingStartedEvent as be, type RowEditingStoppedEvent as bf, type RowNode as bg, type RowSelectionMode as bh, type RowStyleParams as bi, type RowStyleRule as bj, type RowTone as bk, type RowTransaction as bl, type SaveChangeIssue as bm, type SaveChangesResult as bn, type SelectEditorOption as bo, type SelectEditorParams as bp, type SelectionChangedEvent as bq, type SetFilterCondition as br, type SetFilterParams as bs, type SortChangedEvent as bt, type SortDirection as bu, type SortModelItem as bv, type StatusBarConfig as bw, type StatusBarPanel as bx, type TextFilterCondition as by, type TextFilterMatch as bz, type GridOptions as c, type GridDataProcessor as d, type GridComponents as e, type GridState as f, type GridStateStore as g, type FilterModel as h, type FieldPath as i, type SaveChangesHandler as j, type GridEventType as k, type ColumnFilter as l, type AdvancedFilterCondition as m, type AdvancedFilterNode as n, type AdvancedFilterGroup as o, type ColDefGroup as p, type GridStateInput as q, type GridSize as r, type CellRendererParams as s, type GridChange as t, type CellRendererFn as u, type FieldPathValue as v, type SaveChangeConflict as w, type ColumnState as x, type ActionPolicy as y, type ActionPolicyContext as z };
@@ -1,4 +1,4 @@
1
- import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-ChEKWrvH.cjs';
1
+ import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './colDef-BiwNRXwf.cjs';
2
2
 
3
3
  type MachTablePresetSelection = string | readonly string[] | false;
4
4
  type MachTableInstanceOptionKey = "rowData" | "columnDefs" | "datasource" | "loading" | "error" | "initialState" | "persistence" | "components" | "columnTypes";
@@ -22,9 +22,9 @@ interface MachTableRuntimeConfig {
22
22
  columnTypes?: Readonly<Record<string, Partial<ColDef<any>>>>;
23
23
  /** Application-wide renderer/editor registry. Per-table components can override it. */
24
24
  components?: GridComponents;
25
- /** Named, reusable behavior profiles such as `list`, `crud` or `picker`. */
25
+ /** Custom presets replace same-name built-ins; use createMachTablePreset(name, overrides) to extend one. */
26
26
  presets?: Readonly<Record<string, MachTablePreset>>;
27
- /** Preset used when a table does not declare its own preset. Set false to disable. */
27
+ /** Defaults to the built-in `list` scene. Set false to skip preset defaults. */
28
28
  defaultPreset?: MachTablePresetSelection;
29
29
  /** Throw on unsafe config-center keys. Defaults to true. */
30
30
  strict?: boolean;
@@ -1,4 +1,4 @@
1
- import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-ChEKWrvH.js';
1
+ import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './colDef-BiwNRXwf.js';
2
2
 
3
3
  type MachTablePresetSelection = string | readonly string[] | false;
4
4
  type MachTableInstanceOptionKey = "rowData" | "columnDefs" | "datasource" | "loading" | "error" | "initialState" | "persistence" | "components" | "columnTypes";
@@ -22,9 +22,9 @@ interface MachTableRuntimeConfig {
22
22
  columnTypes?: Readonly<Record<string, Partial<ColDef<any>>>>;
23
23
  /** Application-wide renderer/editor registry. Per-table components can override it. */
24
24
  components?: GridComponents;
25
- /** Named, reusable behavior profiles such as `list`, `crud` or `picker`. */
25
+ /** Custom presets replace same-name built-ins; use createMachTablePreset(name, overrides) to extend one. */
26
26
  presets?: Readonly<Record<string, MachTablePreset>>;
27
- /** Preset used when a table does not declare its own preset. Set false to disable. */
27
+ /** Defaults to the built-in `list` scene. Set false to skip preset defaults. */
28
28
  defaultPreset?: MachTablePresetSelection;
29
29
  /** Throw on unsafe config-center keys. Defaults to true. */
30
30
  strict?: boolean;
package/dist/import.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var re=(e,r)=>{for(var o in r)M(e,o,{get:r[o],enumerable:!0})},te=(e,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of Z(r))!ee.call(e,t)&&t!==o&&M(e,t,{get:()=>r[t],enumerable:!(n=Y(r,t))||n.enumerable});return e};var oe=e=>te(M({},"__esModule",{value:!0}),e);var we={};re(we,{createImportPlan:()=>K});module.exports=oe(we);var ne=Symbol.for("mach-table.import.v1");function _(e){let r=e[ne];if(!r)throw new TypeError("Import plans require a MachTable GridApi");return r}function se(e){return Object.entries(Object.getOwnPropertyDescriptors(e)).filter(([r,o])=>{if(r==="length"&&Array.isArray(e)||!o.enumerable)return!1;if(o.get||o.set||["__proto__","prototype","constructor"].includes(r))throw new TypeError("Unsafe import property");return!0})}function N(e){let r=new Set,o=0,n=(t,s)=>{if(++o>2e5||s>32)throw new RangeError("Import snapshot exceeds its value/depth limit");if(t==null||["string","number","boolean","bigint","undefined"].includes(typeof t))return t;if(t instanceof Date)return new Date(t.getTime());if(typeof t!="object"||r.has(t))throw new TypeError("Import values must be acyclic data");let i=Object.getPrototypeOf(t);if(!Array.isArray(t)&&i!==Object.prototype&&i!==null)throw new TypeError("Import records must contain plain data");r.add(t);let m=Array.isArray(t)?[]:{};for(let[l,d]of se(t))m[l]=n(d.value,s+1);return r.delete(t),m};return n(e,0)}var ie=new Set(["__proto__","prototype","constructor"]),A=new Map;function B(e){if(typeof e!="string"||e.length===0)return null;let r=A.get(e);if(r!==void 0)return r;let o=e.split("."),n=o.every(t=>t.length>0&&!ie.has(t))?o:null;return e.length<=1024&&(A.size>=256&&A.delete(A.keys().next().value),A.set(e,n)),n}function U(e,r){if(e==null)return;let o=B(r);if(!o)return;let n=e;for(let t of o){if(n==null)return;n=n[t]}return n}function j(e,r,o){if(e==null)return!1;let n=B(r);if(!n)return!1;let t=e;for(let s=0;s<n.length-1;s++){if(typeof t!="object"&&typeof t!="function"||t===null)return!1;t[n[s]]==null&&(t[n[s]]={}),t=t[n[s]]}return typeof t!="object"&&typeof t!="function"||t===null?!1:(t[n[n.length-1]]=o,!0)}var ae=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function L(e,r=!0){if(e==="")return null;if(!r||typeof e!="string"||!ae.test(e)||/^[+-]?0\d/.test(e))return e;let o=Number(e);return Number.isFinite(o)&&(!Number.isInteger(o)||Number.isSafeInteger(o))?o:e}function pe(e,r,o,n){let t=e.columns().filter(a=>a.colDef.field),s=o.columns??r,i=new Map(t.map(a=>[a.id,a])),m=new Map,l=new Map;for(let a of t){let u=a.colDef.field;m.set(u,m.has(u)?null:a);let f=a.colDef.headerName;f&&l.set(f,l.has(f)?null:a)}let d=[],c=new Set;return s.forEach((a,u)=>{let f=(typeof a=="string"||typeof a=="number"?String(a):"").replace(/^\uFEFF/,"").trim(),P=i.get(f)??(m.has(f)?m.get(f):l.get(f));if(!P){if(n||o.columns||m.has(f)||l.has(f))throw new TypeError(`Unknown or ambiguous import column: ${f}`);return}if(c.has(P.colDef.field))throw new TypeError(`Duplicate import column: ${P.id}`);c.add(P.colDef.field),d.push({column:P,index:u})}),d.length?d:e.visibleColumns().filter(a=>a.colDef.field).map((a,u)=>({column:a,index:u}))}function ue(e,r){if(!Array.isArray(e)||e.some(o=>!Array.isArray(o)))throw new TypeError("Import requires an array of rows");if(!Number.isInteger(r)||r<-1||r>=e.length)throw new RangeError("Invalid import header row");if(e.length-r-1>1e4||e.reduce((o,n)=>o+n.length,0)>1e5)throw new RangeError("Import supports 10000 data rows and 100000 cells")}function le(e,r,o,n,t,s){let i=o.colDef.field,m=e.read(r.node,o),l=s.parseValue?s.parseValue({value:t,field:i,rowIndex:r.rowIndex,columnIndex:n}):o.colDef.valueParser?e.parse(r.node,o,t,m):L(t,s.coerceNumbers!==!1);if(l!=null&&typeof l.then=="function")throw new TypeError("Import parsers must return synchronous values");if(!j(r.data,i,l))throw new TypeError(`Unsafe import field: ${i}`);r.changes.push({node:r.node,column:o,oldValue:m,newValue:l})}function de(e,r,o,n,t,s,i,m){let l=m?.[o]??{},d=i?.[o]??{id:`import:${o}`,rowIndex:o,data:l,selected:!1},c={data:l,node:d,changes:[],rowIndex:o};for(let{column:a,index:u}of n)if(!(r[u]===void 0||i&&!e.editable(d,a)))try{le(e,c,a,u,r[u],t)}catch(f){s.issues.push({rowIndex:o,columnIndex:u,colId:a.id,code:"PARSE",message:f instanceof Error?f.message:String(f)})}s.rows.push(c)}function q(e,r,o={},n,t=!1,s){let i=o.headerRowIndex??(o.columns?-1:0);ue(r,i);let m=pe(e,i<0?[]:r[i],o,t);if(!m.length)throw new TypeError("Import requires a writable field column");let l={rows:[],issues:[]};for(let d=i+1;d<r.length;d++){let c=r[d];c.some(a=>a!==""&&a!==void 0)&&de(e,c,d-i-1,m,o,l,n,s)}return l}function F(e,r,o,n){if(e.rows.isRemote())throw new TypeError("Import plans require local records");if(n.mode!=="paste"&&e.getOption("treeData"))throw new TypeError("Import plans require a flat-record model for replace/append");if(r.isEditing())throw new TypeError("Finish active editing before importing");if(n.mode!=="paste"&&e.editing.getDirtyRowIds().length)throw new TypeError("Save or roll back pending changes before loading records");let t=N(o),s=n.mode==="paste"?r.pasteRows(t.rows.length):void 0,i,m;if(t.kind==="rows"){m=t.rows;let d=n.columns??r.columns().filter(u=>u.colDef.field).map(u=>u.id),c=new Map(r.columns().map(u=>[u.id,u.colDef.field])),a=d.map(u=>c.get(u)??u);i=t.rows.map(u=>a.map(f=>U(u,f))),n={...n,columns:d,headerRowIndex:-1}}else i=t.rows;let l=q(r,i,n,s,!0,m);if(!s&&l.rows.some(d=>d.changes.some(c=>c.column.colDef.valueGetter||c.column.colDef.valueSetter)))throw new TypeError("New records require ordinary field columns; custom getters/setters are ambiguous");return l}var b=(e,r="UNSUPPORTED",o=-1)=>({rowIndex:o,code:r,message:e}),z=e=>e instanceof Error?e.message:String(e);function me(e,r,o,n){let t=new Set;for(let s of o.rows){if(n==="paste"){e.rows.getById(s.node.id)!==s.node&&o.issues.push(b("Paste target is not loaded","MAPPING",s.rowIndex));continue}try{let i=r.resolveId(s.data,s.rowIndex);if(i===void 0)continue;(!i||t.has(i)||n==="append"&&e.rows.getById(i))&&o.issues.push(b(`Missing or duplicate row key: ${i}`,"MAPPING",s.rowIndex)),t.add(i),s.node.id=i}catch(i){o.issues.push(b(z(i),"MAPPING",s.rowIndex))}}}function ce(e,r,o,n){let t=F(e,r,o,n);if(n.mode==="paste")for(let s of t.rows)s.changes.length||t.issues.push(b("Paste row has no editable destination cells","VALIDATION",s.rowIndex)),s.changes=s.changes.filter(i=>i.newValue!==void 0&&!Object.is(i.oldValue,i.newValue));return t.rows.length||t.issues.push(b("Import contains no data rows","MAPPING")),me(e,r,t,n.mode),t}function $(e,r){return r.map(o=>({rowIndex:e.rowIndex,colId:o.colId,code:"VALIDATION",message:o.message}))}function fe(e){let r=e.rows.flatMap(n=>n.changes.map(t=>({rowIndex:n.rowIndex,colId:t.column.id,value:t.newValue}))),o=N(r.map(n=>n.value));return r.map((n,t)=>({...n,value:o[t]}))}function Ie(e){let r=new Map;for(let o of e){let n=r.get(o.rowIndex)??[];n.push(o),r.set(o.rowIndex,n)}return r}function K(e,r,o={}){let n=_(e),t={...o,columns:o.columns?[...o.columns]:void 0},s=!1,i=0,m=0,l=!1,d,c,a,u,f=[e.on("modelUpdated",()=>i++),e.on("cellValueChanged",()=>i++)],P=()=>s||e.isDestroyed()?"destroyed":"stale",T=(p,y=[])=>({status:p,rowCount:0,cells:[],issues:y}),k=()=>{s||(s=!0,m++,d=void 0,f.forEach(p=>p()))};f.push(e.on("gridDestroyed",k));async function H(){let p=++m;if(d=void 0,s||e.isDestroyed())return T("destroyed");if(l)return T("stale",[b("This import plan has already committed","STALE")]);let y=n.begin(),x=n.revision(),v=n.columns(),D=i,E=e.getOption("rowEditValidator"),R=e.getOption("rowKey"),O=()=>!s&&p===m&&y()&&n.revision()===x&&n.columns()===v&&e.getOption("rowEditValidator")===E&&e.getOption("rowKey")===R,w=()=>O()&&i===D;try{let I=ce(e,n,r,t),h=I.rows.map(g=>t.mode==="paste"&&g.changes.length?n.guard(g.changes):()=>!0),S=I.rows.map((g,V)=>({changes:g.changes,current:()=>w()&&h[V]()})),C=await Promise.all(S.map(g=>Promise.resolve(g.changes.length?n.validate(g.changes,g.current):[])));if(!w())return T(P(),[b("Grid, columns or input changed during validation","STALE")]);I.rows.forEach((g,V)=>I.issues.push(...$(g,C[V])));let W=fe(I);return d={prepared:I,rows:S,guards:h,errors:C,current:w,intent:O},{status:I.issues.length?"invalid":"ready",rowCount:I.rows.length,cells:W,issues:I.issues.map(g=>({...g}))}}catch(I){return T(w()?"invalid":P(),[b(z(I))])}}async function X(){c?await c:!d&&!a&&await G()}async function J(){if(await X(),s||e.isDestroyed())return{status:"destroyed",importedRowCount:0,issues:[]};let p=d;if(!p&&a?.status==="invalid")return{status:"invalid",importedRowCount:0,issues:a.issues.map(v=>({...v}))};if(!p?.current()||l)return{status:"stale",importedRowCount:0,issues:[b("Import preview is no longer current","STALE")]};let{prepared:y}=p;if(y.issues.length&&t.mode!=="paste")return{status:"invalid",importedRowCount:0,issues:y.issues.map(v=>({...v}))};if(l=!0,t.mode==="paste")return Q(p);let x=y.rows.map(v=>v.data);return t.mode==="append"?e.rows.transact({add:x}):e.rows.setData(x),{status:"applied",importedRowCount:x.length,issues:[]}}function Q(p){let y=Ie(p.prepared.issues),x=p.errors.map((w,I)=>[...w,...(y.get(p.prepared.rows[I].rowIndex)??[]).filter(h=>h.code!=="VALIDATION").map(h=>({colId:h.colId??"",message:h.message}))]),v=p.rows.map((w,I)=>({...w,current:()=>p.intent()&&p.guards[I]()})),D=n.commitRows(v,x,p.intent),E=[...p.prepared.issues,...D.flatMap((w,I)=>{let h=p.prepared.rows[I],S=new Set((y.get(h.rowIndex)??[]).map(C=>C.message));return $(h,w.errors).filter(C=>!S.has(C.message))})],R=D.filter(w=>w.applied).length;return p.intent()?{status:E.length>0||R<p.rows.filter(w=>w.changes.length).length?R?"partial":"invalid":"applied",importedRowCount:R,issues:E}:{status:P(),importedRowCount:R,issues:[...E,b("Input scope changed during commit","STALE")]}}function G(){let p=H();return c=p,a=void 0,p.then(y=>{c===p&&(a=y)}),p.finally(()=>{c===p&&(c=void 0)}),p}return{preview:G,commit:()=>u??(u=J().finally(()=>{u=void 0})),destroy:k}}0&&(module.exports={createImportPlan});
1
+ "use strict";var M=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var te=(e,r)=>{for(var o in r)M(e,o,{get:r[o],enumerable:!0})},oe=(e,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of ee(r))!re.call(e,t)&&t!==o&&M(e,t,{get:()=>r[t],enumerable:!(n=Z(r,t))||n.enumerable});return e};var ne=e=>oe(M({},"__esModule",{value:!0}),e);var ye={};te(ye,{createImportPlan:()=>H});module.exports=ne(ye);function _(e){return e!=null&&typeof e.then=="function"}var se=Symbol.for("mach-table.import.v1");function L(e){let r=e[se];if(!r)throw new TypeError("Import plans require a MachTable GridApi");return r}function ie(e){return Object.entries(Object.getOwnPropertyDescriptors(e)).filter(([r,o])=>{if(r==="length"&&Array.isArray(e)||!o.enumerable)return!1;if(o.get||o.set||["__proto__","prototype","constructor"].includes(r))throw new TypeError("Unsafe import property");return!0})}function N(e){let r=new Set,o=0,n=(t,s)=>{if(++o>2e5||s>32)throw new RangeError("Import snapshot exceeds its value/depth limit");if(t==null||["string","number","boolean","bigint","undefined"].includes(typeof t))return t;if(t instanceof Date)return new Date(t.getTime());if(typeof t!="object"||r.has(t))throw new TypeError("Import values must be acyclic data");let i=Object.getPrototypeOf(t);if(!Array.isArray(t)&&i!==Object.prototype&&i!==null)throw new TypeError("Import records must contain plain data");r.add(t);let d=Array.isArray(t)?[]:{};for(let[m,l]of ie(t))d[m]=n(l.value,s+1);return r.delete(t),d};return n(e,0)}var ae=new Set(["__proto__","prototype","constructor"]),A=new Map;function B(e){if(typeof e!="string"||e.length===0)return null;let r=A.get(e);if(r!==void 0)return r;let o=e.split("."),n=o.every(t=>t.length>0&&!ae.has(t))?o:null;return e.length<=1024&&(A.size>=256&&A.delete(A.keys().next().value),A.set(e,n)),n}function U(e,r){if(e==null)return;let o=B(r);if(!o)return;let n=e;for(let t of o){if(n==null)return;n=n[t]}return n}function j(e,r,o){if(e==null)return!1;let n=B(r);if(!n)return!1;let t=e;for(let s=0;s<n.length-1;s++){if(typeof t!="object"&&typeof t!="function"||t===null)return!1;t[n[s]]==null&&(t[n[s]]={}),t=t[n[s]]}return typeof t!="object"&&typeof t!="function"||t===null?!1:(t[n[n.length-1]]=o,!0)}var pe=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function q(e,r=!0){if(e==="")return null;if(!r||typeof e!="string"||!pe.test(e)||/^[+-]?0\d/.test(e))return e;let o=Number(e);return Number.isFinite(o)&&(!Number.isInteger(o)||Number.isSafeInteger(o))?o:e}function ue(e,r,o,n){let t=e.columns().filter(a=>a.colDef.field),s=o.columns??r,i=new Map(t.map(a=>[a.id,a])),d=new Map,m=new Map;for(let a of t){let u=a.colDef.field;d.set(u,d.has(u)?null:a);let f=a.colDef.headerName;f&&m.set(f,m.has(f)?null:a)}let l=[],c=new Set;return s.forEach((a,u)=>{let f=(typeof a=="string"||typeof a=="number"?String(a):"").replace(/^\uFEFF/,"").trim(),P=i.get(f)??(d.has(f)?d.get(f):m.get(f));if(!P){if(n||o.columns||d.has(f)||m.has(f))throw new TypeError(`Unknown or ambiguous import column: ${f}`);return}if(c.has(P.colDef.field))throw new TypeError(`Duplicate import column: ${P.id}`);c.add(P.colDef.field),l.push({column:P,index:u})}),l.length?l:e.visibleColumns().filter(a=>a.colDef.field).map((a,u)=>({column:a,index:u}))}function le(e,r){if(!Array.isArray(e)||e.some(o=>!Array.isArray(o)))throw new TypeError("Import requires an array of rows");if(!Number.isInteger(r)||r<-1||r>=e.length)throw new RangeError("Invalid import header row");if(e.length-r-1>1e4||e.reduce((o,n)=>o+n.length,0)>1e5)throw new RangeError("Import supports 10000 data rows and 100000 cells")}function de(e,r,o,n,t,s){let i=o.colDef.field,d=e.read(r.node,o),m=s.parseValue?s.parseValue({value:t,field:i,rowIndex:r.rowIndex,columnIndex:n}):o.colDef.valueParser?e.parse(r.node,o,t,d):q(t,s.coerceNumbers!==!1);if(_(m))throw new TypeError("Import parsers must return synchronous values");if(!j(r.data,i,m))throw new TypeError(`Unsafe import field: ${i}`);r.changes.push({node:r.node,column:o,oldValue:d,newValue:m})}function me(e,r,o,n,t,s,i,d){let m=d?.[o]??{},l=i?.[o]??{id:`import:${o}`,rowIndex:o,data:m,selected:!1},c={data:m,node:l,changes:[],rowIndex:o};for(let{column:a,index:u}of n)if(!(r[u]===void 0||i&&!e.editable(l,a)))try{de(e,c,a,u,r[u],t)}catch(f){s.issues.push({rowIndex:o,columnIndex:u,colId:a.id,code:"PARSE",message:f instanceof Error?f.message:String(f)})}s.rows.push(c)}function F(e,r,o={},n,t=!1,s){let i=o.headerRowIndex??(o.columns?-1:0);le(r,i);let d=ue(e,i<0?[]:r[i],o,t);if(!d.length)throw new TypeError("Import requires a writable field column");let m={rows:[],issues:[]};for(let l=i+1;l<r.length;l++){let c=r[l];c.some(a=>a!==""&&a!==void 0)&&me(e,c,l-i-1,d,o,m,n,s)}return m}function $(e,r,o,n){if(e.rows.isRemote())throw new TypeError("Import plans require local records");if(n.mode!=="paste"&&e.getOption("treeData"))throw new TypeError("Import plans require a flat-record model for replace/append");if(r.isEditing())throw new TypeError("Finish active editing before importing");if(n.mode!=="paste"&&e.editing.getDirtyRowIds().length)throw new TypeError("Save or roll back pending changes before loading records");let t=N(o),s=n.mode==="paste"?r.pasteRows(t.rows.length):void 0,i,d;if(t.kind==="rows"){d=t.rows;let l=n.columns??r.columns().filter(u=>u.colDef.field).map(u=>u.id),c=new Map(r.columns().map(u=>[u.id,u.colDef.field])),a=l.map(u=>c.get(u)??u);i=t.rows.map(u=>a.map(f=>U(u,f))),n={...n,columns:l,headerRowIndex:-1}}else i=t.rows;let m=F(r,i,n,s,!0,d);if(!s&&m.rows.some(l=>l.changes.some(c=>c.column.colDef.valueGetter||c.column.colDef.valueSetter)))throw new TypeError("New records require ordinary field columns; custom getters/setters are ambiguous");return m}var b=(e,r="UNSUPPORTED",o=-1)=>({rowIndex:o,code:r,message:e}),K=e=>e instanceof Error?e.message:String(e);function ce(e,r,o,n){let t=new Set;for(let s of o.rows){if(n==="paste"){e.rows.getById(s.node.id)!==s.node&&o.issues.push(b("Paste target is not loaded","MAPPING",s.rowIndex));continue}try{let i=r.resolveId(s.data,s.rowIndex);if(i===void 0)continue;(!i||t.has(i)||n==="append"&&e.rows.getById(i))&&o.issues.push(b(`Missing or duplicate row key: ${i}`,"MAPPING",s.rowIndex)),t.add(i),s.node.id=i}catch(i){o.issues.push(b(K(i),"MAPPING",s.rowIndex))}}}function fe(e,r,o,n){let t=$(e,r,o,n);if(n.mode==="paste")for(let s of t.rows)s.changes.length||t.issues.push(b("Paste row has no editable destination cells","VALIDATION",s.rowIndex)),s.changes=s.changes.filter(i=>i.newValue!==void 0&&!Object.is(i.oldValue,i.newValue));return t.rows.length||t.issues.push(b("Import contains no data rows","MAPPING")),ce(e,r,t,n.mode),t}function z(e,r){return r.map(o=>({rowIndex:e.rowIndex,colId:o.colId,code:"VALIDATION",message:o.message}))}function Ie(e){let r=e.rows.flatMap(n=>n.changes.map(t=>({rowIndex:n.rowIndex,colId:t.column.id,value:t.newValue}))),o=N(r.map(n=>n.value));return r.map((n,t)=>({...n,value:o[t]}))}function we(e){let r=new Map;for(let o of e){let n=r.get(o.rowIndex)??[];n.push(o),r.set(o.rowIndex,n)}return r}function H(e,r,o={}){let n=L(e),t={...o,columns:o.columns?[...o.columns]:void 0},s=!1,i=0,d=0,m=!1,l,c,a,u,f=[e.on("modelUpdated",()=>i++),e.on("cellValueChanged",()=>i++)],P=()=>s||e.isDestroyed()?"destroyed":"stale",T=(p,y=[])=>({status:p,rowCount:0,cells:[],issues:y}),k=()=>{s||(s=!0,d++,l=void 0,f.forEach(p=>p()))};f.push(e.on("gridDestroyed",k));async function X(){let p=++d;if(l=void 0,s||e.isDestroyed())return T("destroyed");if(m)return T("stale",[b("This import plan has already committed","STALE")]);let y=n.begin(),x=n.revision(),v=n.columns(),D=i,C=e.getOption("rowEditValidator"),R=e.getOption("rowKey"),O=()=>!s&&p===d&&y()&&n.revision()===x&&n.columns()===v&&e.getOption("rowEditValidator")===C&&e.getOption("rowKey")===R,w=()=>O()&&i===D;try{let I=fe(e,n,r,t),h=I.rows.map(g=>t.mode==="paste"&&g.changes.length?n.guard(g.changes):()=>!0),S=I.rows.map((g,V)=>({changes:g.changes,current:()=>w()&&h[V]()})),E=await Promise.all(S.map(g=>Promise.resolve(g.changes.length?n.validate(g.changes,g.current):[])));if(!w())return T(P(),[b("Grid, columns or input changed during validation","STALE")]);I.rows.forEach((g,V)=>I.issues.push(...z(g,E[V])));let Y=Ie(I);return l={prepared:I,rows:S,guards:h,errors:E,current:w,intent:O},{status:I.issues.length?"invalid":"ready",rowCount:I.rows.length,cells:Y,issues:I.issues.map(g=>({...g}))}}catch(I){return T(w()?"invalid":P(),[b(K(I))])}}async function J(){c?await c:!l&&!a&&await G()}async function Q(){if(await J(),s||e.isDestroyed())return{status:"destroyed",importedRowCount:0,issues:[]};let p=l;if(!p&&a?.status==="invalid")return{status:"invalid",importedRowCount:0,issues:a.issues.map(v=>({...v}))};if(!p?.current()||m)return{status:"stale",importedRowCount:0,issues:[b("Import preview is no longer current","STALE")]};let{prepared:y}=p;if(y.issues.length&&t.mode!=="paste")return{status:"invalid",importedRowCount:0,issues:y.issues.map(v=>({...v}))};if(m=!0,t.mode==="paste")return W(p);let x=y.rows.map(v=>v.data);return t.mode==="append"?e.rows.transact({add:x}):e.rows.setData(x),{status:"applied",importedRowCount:x.length,issues:[]}}function W(p){let y=we(p.prepared.issues),x=p.errors.map((w,I)=>[...w,...(y.get(p.prepared.rows[I].rowIndex)??[]).filter(h=>h.code!=="VALIDATION").map(h=>({colId:h.colId??"",message:h.message}))]),v=p.rows.map((w,I)=>({...w,current:()=>p.intent()&&p.guards[I]()})),D=n.commitRows(v,x,p.intent),C=[...p.prepared.issues,...D.flatMap((w,I)=>{let h=p.prepared.rows[I],S=new Set((y.get(h.rowIndex)??[]).map(E=>E.message));return z(h,w.errors).filter(E=>!S.has(E.message))})],R=D.filter(w=>w.applied).length;return p.intent()?{status:C.length>0||R<p.rows.filter(w=>w.changes.length).length?R?"partial":"invalid":"applied",importedRowCount:R,issues:C}:{status:P(),importedRowCount:R,issues:[...C,b("Input scope changed during commit","STALE")]}}function G(){let p=X();return c=p,a=void 0,p.then(y=>{c===p&&(a=y)}),p.finally(()=>{c===p&&(c=void 0)}),p}return{preview:G,commit:()=>u??(u=Q().finally(()=>{u=void 0})),destroy:k}}0&&(module.exports={createImportPlan});
package/dist/import.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as ImportMatrixOptions, b as GridApi } from './api-ChEKWrvH.cjs';
1
+ import { I as ImportMatrixOptions, b as GridApi } from './colDef-BiwNRXwf.cjs';
2
2
 
3
3
  interface ImportIssue {
4
4
  /** Zero-based data-row index, excluding the header. -1 denotes the complete plan. */
package/dist/import.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as ImportMatrixOptions, b as GridApi } from './api-ChEKWrvH.js';
1
+ import { I as ImportMatrixOptions, b as GridApi } from './colDef-BiwNRXwf.js';
2
2
 
3
3
  interface ImportIssue {
4
4
  /** Zero-based data-row index, excluding the header. -1 denotes the complete plan. */