@azrico/reactgrid 1.1.18 → 1.1.20
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/src/index.js +3 -8
- package/dist/src/views/DataGrid.d.ts +1 -3
- package/dist/src/views/DataGrid.js +15 -10
- package/package.json +1 -1
- package/src/index.tsx +2 -4
- package/src/views/DataGrid.tsx +19 -12
package/dist/src/index.js
CHANGED
|
@@ -17,14 +17,9 @@ Object.keys(_DataGrid).forEach(function (key) {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
-
var _example = _interopRequireDefault(require("./example"));
|
|
21
|
-
var _react = _interopRequireDefault(require("react"));
|
|
22
|
-
var _client = _interopRequireDefault(require("react-dom/client"));
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
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); }
|
|
25
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; }
|
|
26
22
|
/* -------------------------------------------------------------------------- */
|
|
27
|
-
var _default = _DataGrid.default;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
root.render(_react.default.createElement(_example.default, null));
|
|
23
|
+
var _default = _DataGrid.default; // const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
24
|
+
// root.render(<ExampleGrid />);
|
|
25
|
+
exports.default = _default;
|
|
@@ -39,9 +39,7 @@ export type AzGridProps = {
|
|
|
39
39
|
licenseKey?: string;
|
|
40
40
|
gridOptions?: GridOptions;
|
|
41
41
|
columns?: LooseColumnDefinition[];
|
|
42
|
-
columnExtensions?:
|
|
43
|
-
name: string;
|
|
44
|
-
} & Partial<LooseColumnDefinition>>;
|
|
42
|
+
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
45
43
|
editableColumns?: string[];
|
|
46
44
|
leftColumns?: string[];
|
|
47
45
|
rightColumns?: string[];
|
|
@@ -142,11 +142,12 @@ function DataGrid(props) {
|
|
|
142
142
|
if (lastclick) {
|
|
143
143
|
const diffTime = Math.abs(nowDate - lastclick);
|
|
144
144
|
if (diffTime < 400) {
|
|
145
|
-
|
|
145
|
+
click_data.current[get_row_id(rowProps)] = null;
|
|
146
|
+
return props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
149
|
-
props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
150
|
+
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
150
151
|
}, []);
|
|
151
152
|
/* ------------------------------- ContextMenu ------------------------------ */
|
|
152
153
|
const update_menuAnchorEl = _react.default.useCallback(el => {
|
|
@@ -264,6 +265,10 @@ function ApplyColumnData(props) {
|
|
|
264
265
|
if (mcolExts && Array.isArray(mcolExts)) for (let index = 0; index < mcolExts.length; index++) {
|
|
265
266
|
const ext = mcolExts[index];
|
|
266
267
|
const ext_cl = get_col_name(ext);
|
|
268
|
+
if (!ext_cl) {
|
|
269
|
+
console.warn('ColumnExtension must have a name');
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
267
272
|
const mcol = final_columns.find(s => get_col_name(s) === ext_cl);
|
|
268
273
|
if (mcol) {
|
|
269
274
|
for (const key in ext) {
|
|
@@ -385,10 +390,10 @@ function to_datasource(arr, idProperty) {
|
|
|
385
390
|
* @returns
|
|
386
391
|
*/
|
|
387
392
|
function get_col_name(obj) {
|
|
388
|
-
if (!obj) return '
|
|
393
|
+
if (!obj) return '';
|
|
389
394
|
if (typeof obj == 'string') return obj;
|
|
390
|
-
if (typeof obj != 'object') return '
|
|
391
|
-
return obj.name || obj.field || obj.key || obj.columnName || '
|
|
395
|
+
if (typeof obj != 'object') return '';
|
|
396
|
+
return obj.name || obj.field || obj.key || obj.columnName || '';
|
|
392
397
|
}
|
|
393
398
|
/**
|
|
394
399
|
* Gets header of a column
|
|
@@ -396,9 +401,9 @@ function get_col_name(obj) {
|
|
|
396
401
|
* @returns
|
|
397
402
|
*/
|
|
398
403
|
function get_col_header(obj) {
|
|
399
|
-
if (!obj) return '
|
|
404
|
+
if (!obj) return '';
|
|
400
405
|
if (typeof obj == 'string') return obj;
|
|
401
|
-
if (typeof obj != 'object') return '
|
|
406
|
+
if (typeof obj != 'object') return '';
|
|
402
407
|
return obj.header || obj.title || get_col_name(obj);
|
|
403
408
|
}
|
|
404
409
|
/**
|
|
@@ -407,10 +412,10 @@ function get_col_header(obj) {
|
|
|
407
412
|
* @returns
|
|
408
413
|
*/
|
|
409
414
|
function get_row_id(obj) {
|
|
410
|
-
if (!obj) return '
|
|
415
|
+
if (!obj) return '-1';
|
|
411
416
|
if (typeof obj == 'string') return obj;
|
|
412
|
-
if (typeof obj != 'object') return '
|
|
413
|
-
return obj.__table_id || obj.id || '
|
|
417
|
+
if (typeof obj != 'object') return '-1';
|
|
418
|
+
return obj.__table_id || obj.id || '-1';
|
|
414
419
|
}
|
|
415
420
|
/**
|
|
416
421
|
* Gets default activation key for grid plugin
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -7,9 +7,7 @@ import ReactDOM from 'react-dom/client';
|
|
|
7
7
|
|
|
8
8
|
/* -------------------------------------------------------------------------- */
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
export default AzGrid;
|
|
13
11
|
|
|
14
|
-
const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
15
|
-
root.render(<ExampleGrid />);
|
|
12
|
+
// const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
13
|
+
// root.render(<ExampleGrid />);
|
package/src/views/DataGrid.tsx
CHANGED
|
@@ -72,7 +72,7 @@ export type AzGridProps = {
|
|
|
72
72
|
gridOptions?: GridOptions;
|
|
73
73
|
|
|
74
74
|
columns?: LooseColumnDefinition[];
|
|
75
|
-
columnExtensions?:
|
|
75
|
+
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
76
76
|
|
|
77
77
|
editableColumns?: string[];
|
|
78
78
|
leftColumns?: string[];
|
|
@@ -255,13 +255,16 @@ function DataGrid(props: DataGridProps) {
|
|
|
255
255
|
if (lastclick) {
|
|
256
256
|
const diffTime = Math.abs(nowDate - lastclick);
|
|
257
257
|
if (diffTime < 400) {
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
click_data.current[get_row_id(rowProps)] = null;
|
|
259
|
+
return (
|
|
260
|
+
props.onRowDoubleClick &&
|
|
261
|
+
props.onRowDoubleClick(rowProps.rowIndex, rowProps.data)
|
|
262
|
+
);
|
|
260
263
|
}
|
|
261
264
|
}
|
|
262
265
|
|
|
263
266
|
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
264
|
-
props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
267
|
+
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
265
268
|
}, []);
|
|
266
269
|
/* ------------------------------- ContextMenu ------------------------------ */
|
|
267
270
|
|
|
@@ -395,6 +398,10 @@ function ApplyColumnData(props: any): ColumnDefinition[] {
|
|
|
395
398
|
for (let index = 0; index < mcolExts.length; index++) {
|
|
396
399
|
const ext = mcolExts[index];
|
|
397
400
|
const ext_cl = get_col_name(ext);
|
|
401
|
+
if (!ext_cl) {
|
|
402
|
+
console.warn('ColumnExtension must have a name');
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
398
405
|
const mcol = final_columns.find((s) => get_col_name(s) === ext_cl);
|
|
399
406
|
if (mcol) {
|
|
400
407
|
for (const key in ext) {
|
|
@@ -520,10 +527,10 @@ function to_datasource(arr: any[], idProperty: string) {
|
|
|
520
527
|
* @returns
|
|
521
528
|
*/
|
|
522
529
|
function get_col_name(obj: any): string {
|
|
523
|
-
if (!obj) return '
|
|
530
|
+
if (!obj) return '';
|
|
524
531
|
if (typeof obj == 'string') return obj;
|
|
525
|
-
if (typeof obj != 'object') return '
|
|
526
|
-
return obj.name || obj.field || obj.key || obj.columnName || '
|
|
532
|
+
if (typeof obj != 'object') return '';
|
|
533
|
+
return obj.name || obj.field || obj.key || obj.columnName || '';
|
|
527
534
|
}
|
|
528
535
|
/**
|
|
529
536
|
* Gets header of a column
|
|
@@ -531,9 +538,9 @@ function get_col_name(obj: any): string {
|
|
|
531
538
|
* @returns
|
|
532
539
|
*/
|
|
533
540
|
function get_col_header(obj: any): string {
|
|
534
|
-
if (!obj) return '
|
|
541
|
+
if (!obj) return '';
|
|
535
542
|
if (typeof obj == 'string') return obj;
|
|
536
|
-
if (typeof obj != 'object') return '
|
|
543
|
+
if (typeof obj != 'object') return '';
|
|
537
544
|
return obj.header || obj.title || get_col_name(obj);
|
|
538
545
|
}
|
|
539
546
|
/**
|
|
@@ -542,10 +549,10 @@ function get_col_header(obj: any): string {
|
|
|
542
549
|
* @returns
|
|
543
550
|
*/
|
|
544
551
|
function get_row_id(obj: any): any {
|
|
545
|
-
if (!obj) return '
|
|
552
|
+
if (!obj) return '-1';
|
|
546
553
|
if (typeof obj == 'string') return obj;
|
|
547
|
-
if (typeof obj != 'object') return '
|
|
548
|
-
return obj.__table_id || obj.id || '
|
|
554
|
+
if (typeof obj != 'object') return '-1';
|
|
555
|
+
return obj.__table_id || obj.id || '-1';
|
|
549
556
|
}
|
|
550
557
|
|
|
551
558
|
/**
|