@azrico/reactgrid 1.1.14 → 1.1.16
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/dist/index.js +21 -3
- package/dist/src/example.js +130 -95
- package/dist/src/func/helpers.js +80 -75
- package/dist/src/index.js +30 -5
- package/dist/src/themes/base_styles.css +26 -0
- package/dist/src/themes/grid.css +20 -0
- package/dist/src/views/DataGrid.d.ts +5 -3
- package/dist/src/views/DataGrid.js +409 -394
- package/dist/src/views/index.js +23 -3
- package/package.json +2 -2
- package/src/example.tsx +8 -0
- package/src/index.tsx +7 -3
- package/src/views/DataGrid.tsx +37 -19
package/dist/src/views/index.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {};
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _DataGrid = _interopRequireWildcard(require("./DataGrid"));
|
|
9
|
+
Object.keys(_DataGrid).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
12
|
+
if (key in exports && exports[key] === _DataGrid[key]) return;
|
|
13
|
+
Object.defineProperty(exports, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _DataGrid[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
var _default = _DataGrid.default;
|
|
23
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/reactgrid",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "React Datagrid",
|
|
6
6
|
"author": "Azrideus <MehrdadTavangar@gmail.com>",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@azrico/object": "^1.3.1",
|
|
34
34
|
"@emotion/react": "^11.9.3",
|
|
35
35
|
"@emotion/styled": "^11.9.3",
|
|
36
|
-
"@inovua/reactdatagrid-enterprise": "^5.8.
|
|
36
|
+
"@inovua/reactdatagrid-enterprise": "^5.8.1",
|
|
37
37
|
"clsx": "^1.2.1",
|
|
38
38
|
"react": "^18.2.0",
|
|
39
39
|
"react-resize-detector": "^7.1.2"
|
package/src/example.tsx
CHANGED
|
@@ -11,6 +11,13 @@ const columns = [
|
|
|
11
11
|
title: 'Category',
|
|
12
12
|
defaultFlex: 1,
|
|
13
13
|
},
|
|
14
|
+
{
|
|
15
|
+
name: 'job',
|
|
16
|
+
title: 'Job',
|
|
17
|
+
type: 'combo',
|
|
18
|
+
items: ['Engineer', 'Doctor'],
|
|
19
|
+
defaultFlex: 1,
|
|
20
|
+
},
|
|
14
21
|
];
|
|
15
22
|
const leftColumns = ['username', 'row'];
|
|
16
23
|
const customColumns = [
|
|
@@ -96,6 +103,7 @@ export function ExampleGrid() {
|
|
|
96
103
|
contextMenuItems={contextMenuItems}
|
|
97
104
|
// customColumns={customColumns}
|
|
98
105
|
columns={columns}
|
|
106
|
+
editable={true}
|
|
99
107
|
// leftColumns={leftColumns}
|
|
100
108
|
gridOptions={
|
|
101
109
|
{
|
package/src/index.tsx
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export * from './views/DataGrid';
|
|
2
2
|
|
|
3
3
|
import AzGrid from './views/DataGrid';
|
|
4
|
-
/* -------------------------------------------------------------------------- */
|
|
5
4
|
import ExampleGrid from './example';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
import ReactDOM from 'react-dom/client';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------- */
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
8
12
|
export default AzGrid;
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
15
|
+
root.render(<ExampleGrid />);
|
package/src/views/DataGrid.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
TypeColumn,
|
|
11
11
|
TypeDataGridProps,
|
|
12
12
|
TypeDataSource,
|
|
13
|
+
TypeEditInfo,
|
|
13
14
|
TypeFilterTypes,
|
|
14
15
|
TypeRowDetailsInfo,
|
|
15
16
|
TypeRowProps,
|
|
@@ -64,14 +65,15 @@ type customColumnData = {
|
|
|
64
65
|
type GridOptions = Partial<TypeDataGridProps>;
|
|
65
66
|
/* -------------------------------------------------------------------------- */
|
|
66
67
|
export type AzGridProps = {
|
|
67
|
-
columns?: columnOrString[];
|
|
68
68
|
dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
69
69
|
|
|
70
70
|
licenseKey?: string;
|
|
71
71
|
|
|
72
72
|
gridOptions?: GridOptions;
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
columns?: columnOrString[];
|
|
75
|
+
columnExtensions?: Array<{ name: string } & Partial<LooseColumnDefinition>>;
|
|
76
|
+
|
|
75
77
|
editableColumns?: string[];
|
|
76
78
|
leftColumns?: string[];
|
|
77
79
|
rightColumns?: string[];
|
|
@@ -84,6 +86,7 @@ export type AzGridProps = {
|
|
|
84
86
|
|
|
85
87
|
selected?: RowSelectionValue;
|
|
86
88
|
/* -------------------------------------------------------------------------- */
|
|
89
|
+
onEditComplete?: (editInfo: TypeEditInfo) => void;
|
|
87
90
|
onSelectionChange?: OnSelectionChangeFunc;
|
|
88
91
|
|
|
89
92
|
onRowClick?: (rowIndex: number, row: any) => void;
|
|
@@ -96,6 +99,7 @@ export type AzGridProps = {
|
|
|
96
99
|
//
|
|
97
100
|
loading?: boolean;
|
|
98
101
|
dark?: boolean;
|
|
102
|
+
editable: boolean;
|
|
99
103
|
allowChildRows?: boolean;
|
|
100
104
|
looseCacheCheck?: boolean;
|
|
101
105
|
className?: string;
|
|
@@ -128,7 +132,7 @@ const defaultOptions: GridOptions = {
|
|
|
128
132
|
//filterTypes: defaultfilterTypes,
|
|
129
133
|
remoteFilter: false,
|
|
130
134
|
remoteSort: false,
|
|
131
|
-
|
|
135
|
+
editStartEvent: 'click',
|
|
132
136
|
rowReorderColumn: false,
|
|
133
137
|
resizable: true,
|
|
134
138
|
rowIndexColumn: true,
|
|
@@ -280,19 +284,27 @@ function DataGrid(props: DataGridProps) {
|
|
|
280
284
|
const licenseKey = props.licenseKey || get_default_key();
|
|
281
285
|
const events: GridOptions = {
|
|
282
286
|
onRowClick: onRowClick,
|
|
287
|
+
onRowContextMenu: onRowContextMenu,
|
|
283
288
|
onSkipChange: props.onSkipChange,
|
|
284
289
|
onLimitChange: props.onLimitChange,
|
|
285
|
-
|
|
290
|
+
onEditComplete: props.onEditComplete,
|
|
286
291
|
};
|
|
287
292
|
const extra_ops: GridOptions = {
|
|
288
293
|
onSelectionChange: props.onSelectionChange,
|
|
289
294
|
licenseKey: licenseKey,
|
|
295
|
+
editable: props.editable,
|
|
290
296
|
treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
|
|
291
297
|
renderRowDetails: props.RowDetail,
|
|
292
298
|
theme: dark ? 'amber-dark' : 'default-light',
|
|
293
299
|
};
|
|
294
300
|
return { ...defaultOptions, ...events, ...extra_ops };
|
|
295
|
-
}, [
|
|
301
|
+
}, [
|
|
302
|
+
columns,
|
|
303
|
+
props.allowChildRows,
|
|
304
|
+
props.editable,
|
|
305
|
+
props.RowDetail,
|
|
306
|
+
props.onEditComplete,
|
|
307
|
+
]);
|
|
296
308
|
|
|
297
309
|
const static_gridOptions = React.useMemo<GridOptions>(() => {
|
|
298
310
|
return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
|
|
@@ -342,8 +354,8 @@ function DataGrid(props: DataGridProps) {
|
|
|
342
354
|
* @param props
|
|
343
355
|
* @returns
|
|
344
356
|
*/
|
|
345
|
-
function ApplyColumnData(props: any) {
|
|
346
|
-
const final_columns: MakeWriteable<
|
|
357
|
+
function ApplyColumnData(props: any): ColumnDefinition[] {
|
|
358
|
+
const final_columns: MakeWriteable<LooseColumnDefinition>[] = [];
|
|
347
359
|
let mcols = props.columns || [];
|
|
348
360
|
let mcolExts = props.columnExtensions || [];
|
|
349
361
|
let rightColumns = props.rightColumns || [];
|
|
@@ -424,30 +436,34 @@ function ApplyColumnData(props: any) {
|
|
|
424
436
|
}
|
|
425
437
|
}
|
|
426
438
|
for (let index = 0; index < final_columns.length; index++) {
|
|
427
|
-
const col
|
|
439
|
+
const col = final_columns[index];
|
|
428
440
|
|
|
429
441
|
if (col.type) {
|
|
430
442
|
switch (col.type) {
|
|
431
443
|
case 'combo':
|
|
432
444
|
case 'select':
|
|
445
|
+
//@ts-ignore
|
|
433
446
|
col.editor = SelectEditor;
|
|
434
447
|
break;
|
|
435
|
-
case 'number':
|
|
436
|
-
case 'numberic':
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
case 'truefalse':
|
|
440
|
-
case 'bool':
|
|
441
|
-
|
|
442
|
-
|
|
448
|
+
//case 'number':
|
|
449
|
+
//case 'numberic':
|
|
450
|
+
// col.editor = NumericEditor;
|
|
451
|
+
// break;
|
|
452
|
+
//case 'truefalse':
|
|
453
|
+
//case 'bool':
|
|
454
|
+
// col.editor = BoolEditor;
|
|
455
|
+
// break;
|
|
443
456
|
}
|
|
444
457
|
delete col.type;
|
|
445
458
|
}
|
|
459
|
+
//@ts-ignore
|
|
446
460
|
if (!col.editorProps) col.editorProps = {};
|
|
447
|
-
|
|
448
461
|
if (col.items) {
|
|
462
|
+
//@ts-ignore
|
|
449
463
|
if (!col.editorProps.idProperty) col.editorProps.idProperty = 'id';
|
|
464
|
+
//@ts-ignore
|
|
450
465
|
if (!col.editorProps.collapseOnSelect) col.editorProps.collapseOnSelect = true;
|
|
466
|
+
//@ts-ignore
|
|
451
467
|
col.editorProps.dataSource = to_datasource(col.items, col.editorProps.idProperty);
|
|
452
468
|
|
|
453
469
|
delete col.items;
|
|
@@ -478,7 +494,7 @@ function ApplyColumnData(props: any) {
|
|
|
478
494
|
}
|
|
479
495
|
}
|
|
480
496
|
/* -------------------------------------------------------------------------- */
|
|
481
|
-
|
|
497
|
+
console.log(final_columns);
|
|
482
498
|
return final_columns;
|
|
483
499
|
}
|
|
484
500
|
|
|
@@ -489,11 +505,13 @@ function to_datasource(arr: any[], idProperty: string) {
|
|
|
489
505
|
arr.map((s: any) => {
|
|
490
506
|
let elem = {};
|
|
491
507
|
elem[idProperty] = '_cid_' + index;
|
|
492
|
-
elem = { ...elem, ...s };
|
|
508
|
+
if (typeof s === 'object') elem = { ...elem, ...s };
|
|
509
|
+
else elem['label'] = s;
|
|
493
510
|
res.push(elem);
|
|
494
511
|
index++;
|
|
495
512
|
});
|
|
496
513
|
}
|
|
514
|
+
|
|
497
515
|
return res;
|
|
498
516
|
}
|
|
499
517
|
/**
|