@azrico/reactgrid 1.1.14 → 1.1.15
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 +3 -1
- 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 +34 -17
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.15",
|
|
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,
|
|
@@ -84,6 +85,7 @@ export type AzGridProps = {
|
|
|
84
85
|
|
|
85
86
|
selected?: RowSelectionValue;
|
|
86
87
|
/* -------------------------------------------------------------------------- */
|
|
88
|
+
onEditComplete?: (editInfo: TypeEditInfo) => void;
|
|
87
89
|
onSelectionChange?: OnSelectionChangeFunc;
|
|
88
90
|
|
|
89
91
|
onRowClick?: (rowIndex: number, row: any) => void;
|
|
@@ -96,6 +98,7 @@ export type AzGridProps = {
|
|
|
96
98
|
//
|
|
97
99
|
loading?: boolean;
|
|
98
100
|
dark?: boolean;
|
|
101
|
+
editable: boolean;
|
|
99
102
|
allowChildRows?: boolean;
|
|
100
103
|
looseCacheCheck?: boolean;
|
|
101
104
|
className?: string;
|
|
@@ -128,7 +131,7 @@ const defaultOptions: GridOptions = {
|
|
|
128
131
|
//filterTypes: defaultfilterTypes,
|
|
129
132
|
remoteFilter: false,
|
|
130
133
|
remoteSort: false,
|
|
131
|
-
|
|
134
|
+
editStartEvent: 'click',
|
|
132
135
|
rowReorderColumn: false,
|
|
133
136
|
resizable: true,
|
|
134
137
|
rowIndexColumn: true,
|
|
@@ -280,19 +283,27 @@ function DataGrid(props: DataGridProps) {
|
|
|
280
283
|
const licenseKey = props.licenseKey || get_default_key();
|
|
281
284
|
const events: GridOptions = {
|
|
282
285
|
onRowClick: onRowClick,
|
|
286
|
+
onRowContextMenu: onRowContextMenu,
|
|
283
287
|
onSkipChange: props.onSkipChange,
|
|
284
288
|
onLimitChange: props.onLimitChange,
|
|
285
|
-
|
|
289
|
+
onEditComplete: props.onEditComplete,
|
|
286
290
|
};
|
|
287
291
|
const extra_ops: GridOptions = {
|
|
288
292
|
onSelectionChange: props.onSelectionChange,
|
|
289
293
|
licenseKey: licenseKey,
|
|
294
|
+
editable: props.editable,
|
|
290
295
|
treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
|
|
291
296
|
renderRowDetails: props.RowDetail,
|
|
292
297
|
theme: dark ? 'amber-dark' : 'default-light',
|
|
293
298
|
};
|
|
294
299
|
return { ...defaultOptions, ...events, ...extra_ops };
|
|
295
|
-
}, [
|
|
300
|
+
}, [
|
|
301
|
+
columns,
|
|
302
|
+
props.allowChildRows,
|
|
303
|
+
props.editable,
|
|
304
|
+
props.RowDetail,
|
|
305
|
+
props.onEditComplete,
|
|
306
|
+
]);
|
|
296
307
|
|
|
297
308
|
const static_gridOptions = React.useMemo<GridOptions>(() => {
|
|
298
309
|
return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
|
|
@@ -342,8 +353,8 @@ function DataGrid(props: DataGridProps) {
|
|
|
342
353
|
* @param props
|
|
343
354
|
* @returns
|
|
344
355
|
*/
|
|
345
|
-
function ApplyColumnData(props: any) {
|
|
346
|
-
const final_columns: MakeWriteable<
|
|
356
|
+
function ApplyColumnData(props: any): ColumnDefinition[] {
|
|
357
|
+
const final_columns: MakeWriteable<LooseColumnDefinition>[] = [];
|
|
347
358
|
let mcols = props.columns || [];
|
|
348
359
|
let mcolExts = props.columnExtensions || [];
|
|
349
360
|
let rightColumns = props.rightColumns || [];
|
|
@@ -424,30 +435,34 @@ function ApplyColumnData(props: any) {
|
|
|
424
435
|
}
|
|
425
436
|
}
|
|
426
437
|
for (let index = 0; index < final_columns.length; index++) {
|
|
427
|
-
const col
|
|
438
|
+
const col = final_columns[index];
|
|
428
439
|
|
|
429
440
|
if (col.type) {
|
|
430
441
|
switch (col.type) {
|
|
431
442
|
case 'combo':
|
|
432
443
|
case 'select':
|
|
444
|
+
//@ts-ignore
|
|
433
445
|
col.editor = SelectEditor;
|
|
434
446
|
break;
|
|
435
|
-
case 'number':
|
|
436
|
-
case 'numberic':
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
case 'truefalse':
|
|
440
|
-
case 'bool':
|
|
441
|
-
|
|
442
|
-
|
|
447
|
+
//case 'number':
|
|
448
|
+
//case 'numberic':
|
|
449
|
+
// col.editor = NumericEditor;
|
|
450
|
+
// break;
|
|
451
|
+
//case 'truefalse':
|
|
452
|
+
//case 'bool':
|
|
453
|
+
// col.editor = BoolEditor;
|
|
454
|
+
// break;
|
|
443
455
|
}
|
|
444
456
|
delete col.type;
|
|
445
457
|
}
|
|
458
|
+
//@ts-ignore
|
|
446
459
|
if (!col.editorProps) col.editorProps = {};
|
|
447
|
-
|
|
448
460
|
if (col.items) {
|
|
461
|
+
//@ts-ignore
|
|
449
462
|
if (!col.editorProps.idProperty) col.editorProps.idProperty = 'id';
|
|
463
|
+
//@ts-ignore
|
|
450
464
|
if (!col.editorProps.collapseOnSelect) col.editorProps.collapseOnSelect = true;
|
|
465
|
+
//@ts-ignore
|
|
451
466
|
col.editorProps.dataSource = to_datasource(col.items, col.editorProps.idProperty);
|
|
452
467
|
|
|
453
468
|
delete col.items;
|
|
@@ -478,7 +493,7 @@ function ApplyColumnData(props: any) {
|
|
|
478
493
|
}
|
|
479
494
|
}
|
|
480
495
|
/* -------------------------------------------------------------------------- */
|
|
481
|
-
|
|
496
|
+
console.log(final_columns);
|
|
482
497
|
return final_columns;
|
|
483
498
|
}
|
|
484
499
|
|
|
@@ -489,11 +504,13 @@ function to_datasource(arr: any[], idProperty: string) {
|
|
|
489
504
|
arr.map((s: any) => {
|
|
490
505
|
let elem = {};
|
|
491
506
|
elem[idProperty] = '_cid_' + index;
|
|
492
|
-
elem = { ...elem, ...s };
|
|
507
|
+
if (typeof s === 'object') elem = { ...elem, ...s };
|
|
508
|
+
else elem['label'] = s;
|
|
493
509
|
res.push(elem);
|
|
494
510
|
index++;
|
|
495
511
|
});
|
|
496
512
|
}
|
|
513
|
+
|
|
497
514
|
return res;
|
|
498
515
|
}
|
|
499
516
|
/**
|