@object-ui/plugin-aggrid 0.4.1 → 2.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/.turbo/turbo-build.log +99 -0
- package/CHANGELOG.md +16 -0
- package/OBJECT_AGGRID_CN.md +483 -0
- package/QUICKSTART.md +186 -0
- package/README.md +221 -1
- package/dist/AddressField-Bntpynvd.js +95 -0
- package/dist/AgGridImpl-3Mmf2qrR.js +229 -0
- package/dist/AutoNumberField-C1kBJaxh.js +8 -0
- package/dist/FileField-BDwbJvor.js +101 -0
- package/dist/FormulaField-BXNiyGoh.js +9 -0
- package/dist/GeolocationField-Df3yYcM9.js +141 -0
- package/dist/GridField-CcjQp4WM.js +29 -0
- package/dist/LocationField-BIfN5QIq.js +33 -0
- package/dist/MasterDetailField-CAEmxbIT.js +117 -0
- package/dist/ObjectAgGridImpl-EjifM4aY.js +28727 -0
- package/dist/ObjectField-BpkQpIF-.js +51 -0
- package/dist/QRCodeField-VCBewTDG.js +96 -0
- package/dist/RichTextField-CyQwSi2C.js +37 -0
- package/dist/SignatureField-Cr4tsEbj.js +96 -0
- package/dist/SummaryField-CnEJ_GZI.js +9 -0
- package/dist/UserField-DJjaVyrV.js +49 -0
- package/dist/VectorField-cPYmcKnV.js +25 -0
- package/dist/{index-B6NPAFZx.js → index-B87wd1E0.js} +301 -143
- package/dist/index.css +1 -1
- package/dist/index.js +4 -3
- package/dist/index.umd.cjs +225 -2
- package/dist/src/AgGridImpl.d.ts +5 -2
- package/dist/src/ObjectAgGridImpl.d.ts +6 -0
- package/dist/src/VirtualScrolling.d.ts +72 -0
- package/dist/src/field-renderers.d.ts +67 -0
- package/dist/src/index.d.ts +47 -2
- package/dist/src/object-aggrid.types.d.ts +74 -0
- package/dist/src/types.d.ts +48 -1
- package/package.json +11 -9
- package/src/AgGridImpl.tsx +100 -11
- package/src/ObjectAgGridImpl.tsx +501 -0
- package/src/VirtualScrolling.ts +74 -0
- package/src/field-renderers.test.tsx +383 -0
- package/src/field-renderers.tsx +224 -0
- package/src/index.test.ts +1 -1
- package/src/index.tsx +211 -2
- package/src/object-aggrid.test.ts +99 -0
- package/src/object-aggrid.types.ts +123 -0
- package/src/types.ts +57 -1
- package/vite.config.ts +13 -0
- package/dist/AgGridImpl-DKkq6v1B.js +0 -171
package/src/index.tsx
CHANGED
|
@@ -19,13 +19,16 @@ import 'ag-grid-community/styles/ag-theme-balham.css';
|
|
|
19
19
|
import 'ag-grid-community/styles/ag-theme-material.css';
|
|
20
20
|
|
|
21
21
|
// Export types for external use
|
|
22
|
-
export type { AgGridSchema, SimpleColumnDef, AgGridCallbacks, ExportConfig, StatusBarConfig, ColumnConfig, ContextMenuConfig } from './types';
|
|
22
|
+
export type { AgGridSchema, SimpleColumnDef, AgGridCallbacks, ExportConfig, StatusBarConfig, ColumnConfig, ContextMenuConfig, TreeDataConfig, RowGroupingConfig, ExcelExportConfig } from './types';
|
|
23
|
+
export type { ObjectAgGridSchema } from './object-aggrid.types';
|
|
23
24
|
|
|
24
|
-
import type { AgGridCallbacks, ExportConfig, StatusBarConfig, ColumnConfig, ContextMenuConfig } from './types';
|
|
25
|
+
import type { AgGridCallbacks, ExportConfig, StatusBarConfig, ColumnConfig, ContextMenuConfig, TreeDataConfig, RowGroupingConfig, ExcelExportConfig } from './types';
|
|
26
|
+
import type { DataSource } from '@object-ui/types';
|
|
25
27
|
|
|
26
28
|
// 🚀 Lazy load the implementation file
|
|
27
29
|
// This ensures AG Grid is only loaded when the component is actually rendered
|
|
28
30
|
const LazyAgGrid = React.lazy(() => import('./AgGridImpl'));
|
|
31
|
+
const LazyObjectAgGrid = React.lazy(() => import('./ObjectAgGridImpl'));
|
|
29
32
|
|
|
30
33
|
export interface AgGridRendererProps {
|
|
31
34
|
schema: {
|
|
@@ -53,6 +56,9 @@ export interface AgGridRendererProps {
|
|
|
53
56
|
enableRangeSelection?: boolean;
|
|
54
57
|
enableCharts?: boolean;
|
|
55
58
|
contextMenu?: ContextMenuConfig;
|
|
59
|
+
treeData?: TreeDataConfig;
|
|
60
|
+
rowGrouping?: RowGroupingConfig;
|
|
61
|
+
excelExport?: ExcelExportConfig;
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
64
|
|
|
@@ -86,6 +92,9 @@ export const AgGridRenderer: React.FC<AgGridRendererProps> = ({ schema }) => {
|
|
|
86
92
|
enableRangeSelection={schema.enableRangeSelection}
|
|
87
93
|
enableCharts={schema.enableCharts}
|
|
88
94
|
contextMenu={schema.contextMenu}
|
|
95
|
+
treeData={schema.treeData}
|
|
96
|
+
rowGrouping={schema.rowGrouping}
|
|
97
|
+
excelExport={schema.excelExport}
|
|
89
98
|
/>
|
|
90
99
|
</Suspense>
|
|
91
100
|
);
|
|
@@ -96,6 +105,7 @@ ComponentRegistry.register(
|
|
|
96
105
|
'aggrid',
|
|
97
106
|
AgGridRenderer,
|
|
98
107
|
{
|
|
108
|
+
namespace: 'plugin-aggrid',
|
|
99
109
|
label: 'AG Grid',
|
|
100
110
|
icon: 'Table',
|
|
101
111
|
category: 'plugin',
|
|
@@ -243,6 +253,27 @@ ComponentRegistry.register(
|
|
|
243
253
|
description: 'Configure right-click menu: { enabled: true, items: ["copy", "export"] }',
|
|
244
254
|
advanced: true
|
|
245
255
|
},
|
|
256
|
+
{
|
|
257
|
+
name: 'treeData',
|
|
258
|
+
type: 'code',
|
|
259
|
+
label: 'Tree Data Config (JSON)',
|
|
260
|
+
description: 'Configure tree data: { enabled: true, pathField: "orgHierarchy" }',
|
|
261
|
+
advanced: true
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'rowGrouping',
|
|
265
|
+
type: 'code',
|
|
266
|
+
label: 'Row Grouping Config (JSON)',
|
|
267
|
+
description: 'Configure row grouping: { enabled: true, groupByFields: ["category"] }',
|
|
268
|
+
advanced: true
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'excelExport',
|
|
272
|
+
type: 'code',
|
|
273
|
+
label: 'Excel Export Config (JSON)',
|
|
274
|
+
description: 'Configure Excel export: { enabled: true, fileName: "data.xlsx" }',
|
|
275
|
+
advanced: true
|
|
276
|
+
},
|
|
246
277
|
{
|
|
247
278
|
name: 'gridOptions',
|
|
248
279
|
type: 'code',
|
|
@@ -299,7 +330,185 @@ ComponentRegistry.register(
|
|
|
299
330
|
}
|
|
300
331
|
);
|
|
301
332
|
|
|
333
|
+
/**
|
|
334
|
+
* ObjectAgGridRenderer - The public API for the metadata-driven AG Grid component
|
|
335
|
+
* This wrapper handles lazy loading internally using React.Suspense
|
|
336
|
+
*/
|
|
337
|
+
export interface ObjectAgGridRendererProps {
|
|
338
|
+
schema: {
|
|
339
|
+
type: string;
|
|
340
|
+
id?: string;
|
|
341
|
+
className?: string;
|
|
342
|
+
objectName: string;
|
|
343
|
+
dataSource?: DataSource;
|
|
344
|
+
fields?: any[];
|
|
345
|
+
fieldNames?: string[];
|
|
346
|
+
filters?: Record<string, any>;
|
|
347
|
+
sort?: Record<string, 'asc' | 'desc'>;
|
|
348
|
+
pageSize?: number;
|
|
349
|
+
pagination?: boolean;
|
|
350
|
+
domLayout?: 'normal' | 'autoHeight' | 'print';
|
|
351
|
+
animateRows?: boolean;
|
|
352
|
+
rowSelection?: 'single' | 'multiple';
|
|
353
|
+
theme?: 'alpine' | 'balham' | 'material' | 'quartz';
|
|
354
|
+
height?: number | string;
|
|
355
|
+
editable?: boolean;
|
|
356
|
+
editType?: 'fullRow';
|
|
357
|
+
singleClickEdit?: boolean;
|
|
358
|
+
stopEditingWhenCellsLoseFocus?: boolean;
|
|
359
|
+
exportConfig?: ExportConfig;
|
|
360
|
+
statusBar?: StatusBarConfig;
|
|
361
|
+
callbacks?: AgGridCallbacks & {
|
|
362
|
+
onDataLoaded?: (data: any[]) => void;
|
|
363
|
+
onDataError?: (error: Error) => void;
|
|
364
|
+
};
|
|
365
|
+
columnConfig?: ColumnConfig;
|
|
366
|
+
enableRangeSelection?: boolean;
|
|
367
|
+
enableCharts?: boolean;
|
|
368
|
+
contextMenu?: ContextMenuConfig;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export const ObjectAgGridRenderer: React.FC<ObjectAgGridRendererProps> = ({ schema }) => {
|
|
373
|
+
return (
|
|
374
|
+
<Suspense fallback={<Skeleton className="w-full h-[500px]" />}>
|
|
375
|
+
<LazyObjectAgGrid
|
|
376
|
+
objectName={schema.objectName}
|
|
377
|
+
dataSource={schema.dataSource}
|
|
378
|
+
fields={schema.fields}
|
|
379
|
+
fieldNames={schema.fieldNames}
|
|
380
|
+
filters={schema.filters}
|
|
381
|
+
sort={schema.sort}
|
|
382
|
+
pageSize={schema.pageSize}
|
|
383
|
+
pagination={schema.pagination}
|
|
384
|
+
domLayout={schema.domLayout}
|
|
385
|
+
animateRows={schema.animateRows}
|
|
386
|
+
rowSelection={schema.rowSelection}
|
|
387
|
+
theme={schema.theme}
|
|
388
|
+
height={schema.height}
|
|
389
|
+
className={schema.className}
|
|
390
|
+
editable={schema.editable}
|
|
391
|
+
editType={schema.editType}
|
|
392
|
+
singleClickEdit={schema.singleClickEdit}
|
|
393
|
+
stopEditingWhenCellsLoseFocus={schema.stopEditingWhenCellsLoseFocus}
|
|
394
|
+
exportConfig={schema.exportConfig}
|
|
395
|
+
statusBar={schema.statusBar}
|
|
396
|
+
callbacks={schema.callbacks}
|
|
397
|
+
columnConfig={schema.columnConfig}
|
|
398
|
+
enableRangeSelection={schema.enableRangeSelection}
|
|
399
|
+
enableCharts={schema.enableCharts}
|
|
400
|
+
contextMenu={schema.contextMenu}
|
|
401
|
+
/>
|
|
402
|
+
</Suspense>
|
|
403
|
+
);
|
|
404
|
+
};
|
|
405
|
+
|
|
302
406
|
// Standard Export Protocol - for manual integration
|
|
303
407
|
export const aggridComponents = {
|
|
304
408
|
'aggrid': AgGridRenderer,
|
|
409
|
+
'object-aggrid': ObjectAgGridRenderer,
|
|
305
410
|
};
|
|
411
|
+
|
|
412
|
+
// Register the ObjectAgGrid component with the ComponentRegistry
|
|
413
|
+
ComponentRegistry.register(
|
|
414
|
+
'object-aggrid',
|
|
415
|
+
ObjectAgGridRenderer,
|
|
416
|
+
{
|
|
417
|
+
namespace: 'plugin-aggrid',
|
|
418
|
+
label: 'Object AG Grid',
|
|
419
|
+
icon: 'Table',
|
|
420
|
+
category: 'view',
|
|
421
|
+
inputs: [
|
|
422
|
+
{
|
|
423
|
+
name: 'objectName',
|
|
424
|
+
type: 'string',
|
|
425
|
+
label: 'Object Name',
|
|
426
|
+
description: 'Name of the object to fetch metadata and data from',
|
|
427
|
+
required: true
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: 'dataSource',
|
|
431
|
+
type: 'object',
|
|
432
|
+
label: 'Data Source',
|
|
433
|
+
description: 'ObjectStack data source adapter instance',
|
|
434
|
+
required: true
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: 'fieldNames',
|
|
438
|
+
type: 'array',
|
|
439
|
+
label: 'Field Names',
|
|
440
|
+
description: 'Optional: Specify which fields to show (defaults to all fields)',
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: 'filters',
|
|
444
|
+
type: 'object',
|
|
445
|
+
label: 'Filters',
|
|
446
|
+
description: 'Query filters to apply to the data',
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: 'sort',
|
|
450
|
+
type: 'object',
|
|
451
|
+
label: 'Sort',
|
|
452
|
+
description: 'Sorting configuration: { fieldName: "asc" | "desc" }',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: 'pagination',
|
|
456
|
+
type: 'boolean',
|
|
457
|
+
label: 'Enable Pagination',
|
|
458
|
+
defaultValue: true
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
name: 'pageSize',
|
|
462
|
+
type: 'number',
|
|
463
|
+
label: 'Page Size',
|
|
464
|
+
defaultValue: 10,
|
|
465
|
+
description: 'Number of rows per page'
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: 'theme',
|
|
469
|
+
type: 'enum',
|
|
470
|
+
label: 'Theme',
|
|
471
|
+
enum: [
|
|
472
|
+
{ label: 'Quartz', value: 'quartz' },
|
|
473
|
+
{ label: 'Alpine', value: 'alpine' },
|
|
474
|
+
{ label: 'Balham', value: 'balham' },
|
|
475
|
+
{ label: 'Material', value: 'material' }
|
|
476
|
+
],
|
|
477
|
+
defaultValue: 'quartz'
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
name: 'height',
|
|
481
|
+
type: 'number',
|
|
482
|
+
label: 'Height (px)',
|
|
483
|
+
defaultValue: 500
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: 'editable',
|
|
487
|
+
type: 'boolean',
|
|
488
|
+
label: 'Enable Editing',
|
|
489
|
+
defaultValue: false,
|
|
490
|
+
description: 'Allow cells to be edited inline',
|
|
491
|
+
advanced: true
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
name: 'exportConfig',
|
|
495
|
+
type: 'code',
|
|
496
|
+
label: 'Export Config (JSON)',
|
|
497
|
+
description: 'Configure CSV export: { enabled: true, fileName: "data.csv" }',
|
|
498
|
+
advanced: true
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: 'columnConfig',
|
|
502
|
+
type: 'code',
|
|
503
|
+
label: 'Column Config (JSON)',
|
|
504
|
+
description: 'Global column settings: { resizable: true, sortable: true, filterable: true }',
|
|
505
|
+
advanced: true
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
name: 'className',
|
|
509
|
+
type: 'string',
|
|
510
|
+
label: 'CSS Class'
|
|
511
|
+
}
|
|
512
|
+
]
|
|
513
|
+
}
|
|
514
|
+
);
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
10
|
+
import { ObjectAgGridRenderer } from './index';
|
|
11
|
+
import type { DataSource } from '@object-ui/types';
|
|
12
|
+
|
|
13
|
+
describe('ObjectAgGridRenderer', () => {
|
|
14
|
+
let mockDataSource: DataSource;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
mockDataSource = {
|
|
18
|
+
find: vi.fn().mockResolvedValue({
|
|
19
|
+
data: [
|
|
20
|
+
{ id: '1', name: 'Test 1', email: 'test1@example.com' },
|
|
21
|
+
{ id: '2', name: 'Test 2', email: 'test2@example.com' }
|
|
22
|
+
],
|
|
23
|
+
total: 2,
|
|
24
|
+
page: 1,
|
|
25
|
+
pageSize: 10,
|
|
26
|
+
hasMore: false
|
|
27
|
+
}),
|
|
28
|
+
findOne: vi.fn(),
|
|
29
|
+
create: vi.fn(),
|
|
30
|
+
update: vi.fn(),
|
|
31
|
+
delete: vi.fn(),
|
|
32
|
+
bulk: vi.fn(),
|
|
33
|
+
getObjectSchema: vi.fn().mockResolvedValue({
|
|
34
|
+
name: 'contacts',
|
|
35
|
+
label: 'Contacts',
|
|
36
|
+
fields: {
|
|
37
|
+
name: {
|
|
38
|
+
name: 'name',
|
|
39
|
+
label: 'Name',
|
|
40
|
+
type: 'text',
|
|
41
|
+
sortable: true,
|
|
42
|
+
filterable: true
|
|
43
|
+
},
|
|
44
|
+
email: {
|
|
45
|
+
name: 'email',
|
|
46
|
+
label: 'Email',
|
|
47
|
+
type: 'email',
|
|
48
|
+
sortable: true,
|
|
49
|
+
filterable: true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
} as any;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should be defined', () => {
|
|
57
|
+
expect(ObjectAgGridRenderer).toBeDefined();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should accept schema with objectName and dataSource', () => {
|
|
61
|
+
const schema = {
|
|
62
|
+
type: 'object-aggrid',
|
|
63
|
+
objectName: 'contacts',
|
|
64
|
+
dataSource: mockDataSource
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
expect(() => {
|
|
68
|
+
ObjectAgGridRenderer({ schema });
|
|
69
|
+
}).not.toThrow();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should accept optional pagination settings', () => {
|
|
73
|
+
const schema = {
|
|
74
|
+
type: 'object-aggrid',
|
|
75
|
+
objectName: 'contacts',
|
|
76
|
+
dataSource: mockDataSource,
|
|
77
|
+
pagination: true,
|
|
78
|
+
pageSize: 20
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
expect(() => {
|
|
82
|
+
ObjectAgGridRenderer({ schema });
|
|
83
|
+
}).not.toThrow();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should accept optional filters and sorting', () => {
|
|
87
|
+
const schema = {
|
|
88
|
+
type: 'object-aggrid',
|
|
89
|
+
objectName: 'contacts',
|
|
90
|
+
dataSource: mockDataSource,
|
|
91
|
+
filters: { status: 'active' },
|
|
92
|
+
sort: { name: 'asc' as const }
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
expect(() => {
|
|
96
|
+
ObjectAgGridRenderer({ schema });
|
|
97
|
+
}).not.toThrow();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
import type { ColDef } from 'ag-grid-community';
|
|
10
|
+
import type { DataSource } from '@object-ui/types';
|
|
11
|
+
import type { FieldMetadata } from '@object-ui/types';
|
|
12
|
+
import type { AgGridCallbacks, ExportConfig, StatusBarConfig, ColumnConfig, ContextMenuConfig } from './types';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Object AgGrid schema for metadata-driven grid
|
|
16
|
+
*/
|
|
17
|
+
export interface ObjectAgGridSchema {
|
|
18
|
+
type: 'object-aggrid';
|
|
19
|
+
id?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
|
|
22
|
+
// Object metadata
|
|
23
|
+
objectName: string;
|
|
24
|
+
dataSource: DataSource; // Required for metadata-driven grid
|
|
25
|
+
|
|
26
|
+
// Optional field configuration override
|
|
27
|
+
fields?: FieldMetadata[];
|
|
28
|
+
fieldNames?: string[]; // Show only specific fields
|
|
29
|
+
|
|
30
|
+
// Query parameters
|
|
31
|
+
filters?: Record<string, any>;
|
|
32
|
+
sort?: Record<string, 'asc' | 'desc'>;
|
|
33
|
+
pageSize?: number;
|
|
34
|
+
|
|
35
|
+
// Grid configuration (same as aggrid)
|
|
36
|
+
pagination?: boolean;
|
|
37
|
+
domLayout?: 'normal' | 'autoHeight' | 'print';
|
|
38
|
+
animateRows?: boolean;
|
|
39
|
+
rowSelection?: 'single' | 'multiple';
|
|
40
|
+
|
|
41
|
+
// Editing
|
|
42
|
+
editable?: boolean;
|
|
43
|
+
editType?: 'fullRow';
|
|
44
|
+
singleClickEdit?: boolean;
|
|
45
|
+
stopEditingWhenCellsLoseFocus?: boolean;
|
|
46
|
+
|
|
47
|
+
// Export
|
|
48
|
+
exportConfig?: ExportConfig;
|
|
49
|
+
|
|
50
|
+
// Status bar
|
|
51
|
+
statusBar?: StatusBarConfig;
|
|
52
|
+
|
|
53
|
+
// Column features
|
|
54
|
+
columnConfig?: ColumnConfig;
|
|
55
|
+
enableRangeSelection?: boolean;
|
|
56
|
+
enableCharts?: boolean;
|
|
57
|
+
|
|
58
|
+
// Context menu
|
|
59
|
+
contextMenu?: ContextMenuConfig;
|
|
60
|
+
|
|
61
|
+
// Event callbacks
|
|
62
|
+
callbacks?: AgGridCallbacks & {
|
|
63
|
+
onDataLoaded?: (data: any[]) => void;
|
|
64
|
+
onDataError?: (error: Error) => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Styling
|
|
68
|
+
theme?: 'alpine' | 'balham' | 'material' | 'quartz';
|
|
69
|
+
height?: number | string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Props for ObjectAgGridImpl component
|
|
74
|
+
*/
|
|
75
|
+
export interface ObjectAgGridImplProps {
|
|
76
|
+
objectName: string;
|
|
77
|
+
dataSource?: DataSource; // Optional in props, but required for functionality
|
|
78
|
+
fields?: FieldMetadata[];
|
|
79
|
+
fieldNames?: string[];
|
|
80
|
+
filters?: Record<string, any>;
|
|
81
|
+
sort?: Record<string, 'asc' | 'desc'>;
|
|
82
|
+
pageSize?: number;
|
|
83
|
+
pagination?: boolean;
|
|
84
|
+
domLayout?: 'normal' | 'autoHeight' | 'print';
|
|
85
|
+
animateRows?: boolean;
|
|
86
|
+
rowSelection?: 'single' | 'multiple';
|
|
87
|
+
theme?: 'alpine' | 'balham' | 'material' | 'quartz';
|
|
88
|
+
height?: number | string;
|
|
89
|
+
className?: string;
|
|
90
|
+
editable?: boolean;
|
|
91
|
+
editType?: 'fullRow';
|
|
92
|
+
singleClickEdit?: boolean;
|
|
93
|
+
stopEditingWhenCellsLoseFocus?: boolean;
|
|
94
|
+
exportConfig?: ExportConfig;
|
|
95
|
+
statusBar?: StatusBarConfig;
|
|
96
|
+
callbacks?: AgGridCallbacks & {
|
|
97
|
+
onDataLoaded?: (data: any[]) => void;
|
|
98
|
+
onDataError?: (error: Error) => void;
|
|
99
|
+
};
|
|
100
|
+
columnConfig?: ColumnConfig;
|
|
101
|
+
enableRangeSelection?: boolean;
|
|
102
|
+
enableCharts?: boolean;
|
|
103
|
+
contextMenu?: ContextMenuConfig;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Field type to AG Grid filter type mapping
|
|
108
|
+
*/
|
|
109
|
+
export const FIELD_TYPE_TO_FILTER_TYPE: Record<string, string | boolean> = {
|
|
110
|
+
text: 'agTextColumnFilter',
|
|
111
|
+
textarea: 'agTextColumnFilter',
|
|
112
|
+
number: 'agNumberColumnFilter',
|
|
113
|
+
currency: 'agNumberColumnFilter',
|
|
114
|
+
percent: 'agNumberColumnFilter',
|
|
115
|
+
boolean: 'agSetColumnFilter',
|
|
116
|
+
date: 'agDateColumnFilter',
|
|
117
|
+
datetime: 'agDateColumnFilter',
|
|
118
|
+
time: 'agTextColumnFilter',
|
|
119
|
+
email: 'agTextColumnFilter',
|
|
120
|
+
phone: 'agTextColumnFilter',
|
|
121
|
+
url: 'agTextColumnFilter',
|
|
122
|
+
select: 'agSetColumnFilter',
|
|
123
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface AgGridCallbacks {
|
|
|
16
16
|
onRowClicked?: (event: RowClickedEvent) => void;
|
|
17
17
|
onSelectionChanged?: (event: SelectionChangedEvent) => void;
|
|
18
18
|
onCellValueChanged?: (event: CellValueChangedEvent) => void;
|
|
19
|
-
onExport?: (data: any[], format: 'csv') => void;
|
|
19
|
+
onExport?: (data: any[], format: 'csv' | 'excel') => void;
|
|
20
20
|
onContextMenuAction?: (action: string, rowData: any) => void;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -29,6 +29,53 @@ export interface ExportConfig {
|
|
|
29
29
|
skipColumnHeaders?: boolean;
|
|
30
30
|
allColumns?: boolean;
|
|
31
31
|
onlySelected?: boolean;
|
|
32
|
+
format?: 'csv' | 'excel';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Tree data configuration
|
|
37
|
+
*/
|
|
38
|
+
export interface TreeDataConfig {
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
/** Field that contains the hierarchy path (array of strings) */
|
|
41
|
+
pathField?: string;
|
|
42
|
+
/** Field that contains parent ID for parent-child relationships */
|
|
43
|
+
parentIdField?: string;
|
|
44
|
+
/** Field that contains the unique ID */
|
|
45
|
+
idField?: string;
|
|
46
|
+
/** Whether to expand all rows by default */
|
|
47
|
+
expandAll?: boolean;
|
|
48
|
+
/** Depth to expand to by default */
|
|
49
|
+
expandDepth?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Row grouping configuration
|
|
54
|
+
*/
|
|
55
|
+
export interface RowGroupingConfig {
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
/** Fields to group by */
|
|
58
|
+
groupByFields?: string[];
|
|
59
|
+
/** Whether to show group row count */
|
|
60
|
+
showRowCount?: boolean;
|
|
61
|
+
/** Whether to allow user to change grouping */
|
|
62
|
+
userGroupable?: boolean;
|
|
63
|
+
/** Aggregation functions for grouped columns */
|
|
64
|
+
aggregations?: Record<string, 'sum' | 'avg' | 'count' | 'min' | 'max' | 'first' | 'last'>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Excel export configuration
|
|
69
|
+
*/
|
|
70
|
+
export interface ExcelExportConfig {
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
fileName?: string;
|
|
73
|
+
sheetName?: string;
|
|
74
|
+
includeHeaders?: boolean;
|
|
75
|
+
includeGrouping?: boolean;
|
|
76
|
+
onlySelected?: boolean;
|
|
77
|
+
/** Custom column widths */
|
|
78
|
+
columnWidths?: Record<string, number>;
|
|
32
79
|
}
|
|
33
80
|
|
|
34
81
|
/**
|
|
@@ -105,6 +152,15 @@ export interface AgGridSchema {
|
|
|
105
152
|
// Context menu
|
|
106
153
|
contextMenu?: ContextMenuConfig;
|
|
107
154
|
|
|
155
|
+
// Tree data
|
|
156
|
+
treeData?: TreeDataConfig;
|
|
157
|
+
|
|
158
|
+
// Row grouping
|
|
159
|
+
rowGrouping?: RowGroupingConfig;
|
|
160
|
+
|
|
161
|
+
// Excel export
|
|
162
|
+
excelExport?: ExcelExportConfig;
|
|
163
|
+
|
|
108
164
|
// Event callbacks
|
|
109
165
|
callbacks?: AgGridCallbacks;
|
|
110
166
|
|
package/vite.config.ts
CHANGED
|
@@ -24,6 +24,13 @@ export default defineConfig({
|
|
|
24
24
|
resolve: {
|
|
25
25
|
alias: {
|
|
26
26
|
'@': resolve(__dirname, './src'),
|
|
27
|
+
'@object-ui/core': resolve(__dirname, '../core/src'),
|
|
28
|
+
'@object-ui/types': resolve(__dirname, '../types/src'),
|
|
29
|
+
'@object-ui/react': resolve(__dirname, '../react/src'),
|
|
30
|
+
'@object-ui/components': resolve(__dirname, '../components/src'),
|
|
31
|
+
'@object-ui/fields': resolve(__dirname, '../fields/src'),
|
|
32
|
+
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
|
|
33
|
+
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
|
|
27
34
|
},
|
|
28
35
|
},
|
|
29
36
|
build: {
|
|
@@ -47,4 +54,10 @@ export default defineConfig({
|
|
|
47
54
|
},
|
|
48
55
|
},
|
|
49
56
|
},
|
|
57
|
+
test: {
|
|
58
|
+
globals: true,
|
|
59
|
+
environment: 'happy-dom',
|
|
60
|
+
setupFiles: ['../../vitest.setup.tsx'],
|
|
61
|
+
passWithNoTests: true,
|
|
62
|
+
},
|
|
50
63
|
});
|