@azrico/reactgrid 1.1.17 → 1.1.19

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.
@@ -29,7 +29,6 @@ type loose_column_fields = loose_column_names & {
29
29
  items: any[];
30
30
  };
31
31
  export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
32
- type columnOrString = string | LooseColumnDefinition;
33
32
  type customColumnData = {
34
33
  name: string;
35
34
  render: (cell: any, formatterParams: any, onRendered: any) => React.ReactNode | undefined | null;
@@ -39,10 +38,8 @@ export type AzGridProps = {
39
38
  dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
40
39
  licenseKey?: string;
41
40
  gridOptions?: GridOptions;
42
- columns?: columnOrString[];
43
- columnExtensions?: Array<{
44
- name: string;
45
- } & Partial<LooseColumnDefinition>>;
41
+ columns?: LooseColumnDefinition[];
42
+ columnExtensions?: Partial<LooseColumnDefinition>;
46
43
  editableColumns?: string[];
47
44
  leftColumns?: string[];
48
45
  rightColumns?: string[];
@@ -264,6 +264,10 @@ function ApplyColumnData(props) {
264
264
  if (mcolExts && Array.isArray(mcolExts)) for (let index = 0; index < mcolExts.length; index++) {
265
265
  const ext = mcolExts[index];
266
266
  const ext_cl = get_col_name(ext);
267
+ if (!ext_cl) {
268
+ console.warn('ColumnExtension must have a name');
269
+ continue;
270
+ }
267
271
  const mcol = final_columns.find(s => get_col_name(s) === ext_cl);
268
272
  if (mcol) {
269
273
  for (const key in ext) {
@@ -385,10 +389,10 @@ function to_datasource(arr, idProperty) {
385
389
  * @returns
386
390
  */
387
391
  function get_col_name(obj) {
388
- if (!obj) return 'default';
392
+ if (!obj) return '';
389
393
  if (typeof obj == 'string') return obj;
390
- if (typeof obj != 'object') return 'default';
391
- return obj.name || obj.field || obj.key || obj.columnName || 'default';
394
+ if (typeof obj != 'object') return '';
395
+ return obj.name || obj.field || obj.key || obj.columnName || '';
392
396
  }
393
397
  /**
394
398
  * Gets header of a column
@@ -396,9 +400,9 @@ function get_col_name(obj) {
396
400
  * @returns
397
401
  */
398
402
  function get_col_header(obj) {
399
- if (!obj) return 'default';
403
+ if (!obj) return '';
400
404
  if (typeof obj == 'string') return obj;
401
- if (typeof obj != 'object') return 'default';
405
+ if (typeof obj != 'object') return '';
402
406
  return obj.header || obj.title || get_col_name(obj);
403
407
  }
404
408
  /**
@@ -407,10 +411,10 @@ function get_col_header(obj) {
407
411
  * @returns
408
412
  */
409
413
  function get_row_id(obj) {
410
- if (!obj) return 'default';
414
+ if (!obj) return '-1';
411
415
  if (typeof obj == 'string') return obj;
412
- if (typeof obj != 'object') return 'default';
413
- return obj.__table_id || obj.id || 'default';
416
+ if (typeof obj != 'object') return '-1';
417
+ return obj.__table_id || obj.id || '-1';
414
418
  }
415
419
  /**
416
420
  * Gets default activation key for grid plugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/reactgrid",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -57,7 +57,7 @@ type loose_column_fields = loose_column_names & {
57
57
  };
58
58
  export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
59
59
  //
60
- type columnOrString = string | LooseColumnDefinition;
60
+
61
61
  type customColumnData = {
62
62
  name: string;
63
63
  render: (cell: any, formatterParams, onRendered) => React.ReactNode | undefined | null;
@@ -71,8 +71,8 @@ export type AzGridProps = {
71
71
 
72
72
  gridOptions?: GridOptions;
73
73
 
74
- columns?: columnOrString[];
75
- columnExtensions?: Array<{ name: string } & Partial<LooseColumnDefinition>>;
74
+ columns?: LooseColumnDefinition[];
75
+ columnExtensions?: Partial<LooseColumnDefinition>;
76
76
 
77
77
  editableColumns?: string[];
78
78
  leftColumns?: string[];
@@ -395,6 +395,10 @@ function ApplyColumnData(props: any): ColumnDefinition[] {
395
395
  for (let index = 0; index < mcolExts.length; index++) {
396
396
  const ext = mcolExts[index];
397
397
  const ext_cl = get_col_name(ext);
398
+ if (!ext_cl) {
399
+ console.warn('ColumnExtension must have a name');
400
+ continue;
401
+ }
398
402
  const mcol = final_columns.find((s) => get_col_name(s) === ext_cl);
399
403
  if (mcol) {
400
404
  for (const key in ext) {
@@ -520,10 +524,10 @@ function to_datasource(arr: any[], idProperty: string) {
520
524
  * @returns
521
525
  */
522
526
  function get_col_name(obj: any): string {
523
- if (!obj) return 'default';
527
+ if (!obj) return '';
524
528
  if (typeof obj == 'string') return obj;
525
- if (typeof obj != 'object') return 'default';
526
- return obj.name || obj.field || obj.key || obj.columnName || 'default';
529
+ if (typeof obj != 'object') return '';
530
+ return obj.name || obj.field || obj.key || obj.columnName || '';
527
531
  }
528
532
  /**
529
533
  * Gets header of a column
@@ -531,9 +535,9 @@ function get_col_name(obj: any): string {
531
535
  * @returns
532
536
  */
533
537
  function get_col_header(obj: any): string {
534
- if (!obj) return 'default';
538
+ if (!obj) return '';
535
539
  if (typeof obj == 'string') return obj;
536
- if (typeof obj != 'object') return 'default';
540
+ if (typeof obj != 'object') return '';
537
541
  return obj.header || obj.title || get_col_name(obj);
538
542
  }
539
543
  /**
@@ -542,10 +546,10 @@ function get_col_header(obj: any): string {
542
546
  * @returns
543
547
  */
544
548
  function get_row_id(obj: any): any {
545
- if (!obj) return 'default';
549
+ if (!obj) return '-1';
546
550
  if (typeof obj == 'string') return obj;
547
- if (typeof obj != 'object') return 'default';
548
- return obj.__table_id || obj.id || 'default';
551
+ if (typeof obj != 'object') return '-1';
552
+ return obj.__table_id || obj.id || '-1';
549
553
  }
550
554
 
551
555
  /**