@azrico/reactgrid 1.0.13 → 1.0.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.
@@ -28,7 +28,7 @@ function fix_parent_child_relations(rows) {
28
28
  assign_children(mrow, converted_rows);
29
29
  }
30
30
  const result = top_level_rows.map(r => r.data);
31
- console.log(result);
31
+ //console.log(result);
32
32
  return result;
33
33
  }
34
34
  function assign_children(row, all_rows) {
@@ -40,7 +40,7 @@ function assign_children(row, all_rows) {
40
40
  assign_children(child, all_rows);
41
41
  }
42
42
  row.data.__children = my_children.map(r => r.data);
43
- } else row.data.__children = undefined;
43
+ } else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0) row.data.__children = undefined;
44
44
  }
45
45
  class func_selection {
46
46
  static getVirtualElement(x = 0, y = 0) {
package/dist/src/index.js CHANGED
@@ -17,15 +17,21 @@ 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 }; }
20
24
  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
25
  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; // if (process.env!.NODE_ENV === 'production') {
23
- // // set production urls
24
- // // enable sentry
25
- // } else if (process.env!.NODE_ENV === 'development') {
26
- // const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
27
- // root.render(<ExampleGrid />);
28
- // } else {
29
- // // set defaults
30
- // }
31
- exports.default = _default;
26
+ /* -------------------------------------------------------------------------- */
27
+ var _default = _DataGrid.default;
28
+ exports.default = _default;
29
+ if (process.env.NODE_ENV === 'production') {
30
+ // set production urls
31
+ // enable sentry
32
+ } else if (process.env.NODE_ENV === 'development') {
33
+ const root = _client.default.createRoot(document.getElementById('root'));
34
+ root.render(_react.default.createElement(_example.default, null));
35
+ } else {
36
+ // set defaults
37
+ }
File without changes
@@ -0,0 +1,15 @@
1
+ /* .InovuaReactDataGrid {
2
+ --grid-bg: '#fff';
3
+ }
4
+ .InovuaReactDataGrid {
5
+ background: var(--grid-bg) !important;
6
+ }
7
+ .InovuaReactDataGrid__header {
8
+ background: var(--grid-bg) !important;
9
+ }
10
+ .InovuaReactDataGrid__row {
11
+ background: var(--grid-bg) !important;
12
+ }
13
+ .InovuaReactDataGrid__cell {
14
+ background: var(--grid-bg) !important;
15
+ } */
@@ -1,6 +1,8 @@
1
1
  import '@inovua/reactdatagrid-enterprise/index.css';
2
2
  import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
3
- import '../themes/styles.css';
3
+ import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
4
+ import '../themes/base_styles.css';
5
+ import '../themes/grid.css';
4
6
  import React from 'react';
5
7
  import { TypeColumn, TypeDataGridProps, TypeDataSource, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection } from '@inovua/reactdatagrid-community/types';
6
8
  import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
@@ -32,6 +34,7 @@ type GridOptions = Partial<TypeDataGridProps>;
32
34
  export type AzGridProps = {
33
35
  columns?: columnOrString[];
34
36
  rows?: any[];
37
+ get_rows?: () => any[];
35
38
  licenseKey?: string;
36
39
  gridOptions?: GridOptions;
37
40
  tableColumnExtensions?: Array<{
@@ -44,7 +47,6 @@ export type AzGridProps = {
44
47
  contextMenuItems?: any[];
45
48
  highlightedRow?: any;
46
49
  RowDetail?: RowDetailsFunc;
47
- get_rows?: () => any[];
48
50
  selected?: RowSelectionValue;
49
51
  onSelectionChange?: OnSelectionChangeFunc;
50
52
  onRowsChange?: (rows: any[], options: any) => void;
@@ -7,7 +7,9 @@ exports.AzGrid = AzGrid;
7
7
  exports.default = void 0;
8
8
  require("@inovua/reactdatagrid-enterprise/index.css");
9
9
  require("@inovua/reactdatagrid-enterprise/theme/default-dark.css");
10
- require("../themes/styles.css");
10
+ require("@inovua/reactdatagrid-enterprise/theme/amber-dark.css");
11
+ require("../themes/base_styles.css");
12
+ require("../themes/grid.css");
11
13
  var _react = _interopRequireDefault(require("react"));
12
14
  var _helpers = require("../func/helpers");
13
15
  var _controls = require("@azrico/controls");
@@ -76,10 +78,11 @@ function AzGrid(props) {
76
78
  const ext = mcolExts[index];
77
79
  const ext_cl = get_col_name(ext);
78
80
  const mcol = final_columns.find(s => s.name === ext_cl);
79
- if (!mcol) continue;
80
- if (ext.width) mcol.width = ext.width;
81
- if (ext.visible) mcol.visible = ext.visible;
82
- if (ext.draggable) mcol.draggable = ext.draggable;
81
+ if (mcol) {
82
+ for (const key in ext) {
83
+ if (!mcol[key] && key != 'name') mcol[key] = ext[key];
84
+ }
85
+ }
83
86
  // if (ext.widthGrow) mcol.widthGrow = ext.widthGrow;
84
87
  }
85
88
  /* ------------------------------- frozen cols ------------------------------ */
@@ -133,7 +136,7 @@ function AzGrid(props) {
133
136
  /* -------------------------------------------------------------------------- */
134
137
  _react.default.useEffect(() => {
135
138
  if (pendingChanges <= 0) return;
136
- console.log('Updated Pending Changes: ', pendingChanges);
139
+ //console.log('Updated Pending Changes: ', pendingChanges);
137
140
  let new_rows = [];
138
141
  if (typeof props.get_rows === 'function') {
139
142
  new_rows = props.get_rows();
@@ -147,11 +150,11 @@ function AzGrid(props) {
147
150
  set_pendingChanges(0);
148
151
  }, [pendingChanges]);
149
152
  _react.default.useEffect(() => {
150
- console.log('Rows Changed !');
153
+ //console.log('Rows Changed !');
151
154
  set_pendingChanges(r => r + 1);
152
155
  }, [props.rows]);
153
156
  function onRowsChange(rows, options) {
154
- console.log('onRowsChange');
157
+ //console.log('onRowsChange');
155
158
  if (props.onRowsChange) props.onRowsChange(rows, options);
156
159
  set_pendingChanges(r => r + 1); //notify the cache to update rows after we made changes to them
157
160
  }
@@ -195,7 +198,7 @@ function DataGrid(props) {
195
198
  licenseKey: licenseKey,
196
199
  treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
197
200
  renderRowDetails: props.RowDetail,
198
- theme: dark ? 'default-dark' : 'default-light'
201
+ theme: dark ? 'amber-dark' : 'default-light'
199
202
  };
200
203
  return {
201
204
  ...defaultOptions,
@@ -248,7 +251,7 @@ function DataGrid(props) {
248
251
  ...dynamic_gridOptions,
249
252
  className: 'azgrid-filler',
250
253
  columns: columns,
251
- dataSource: rows
254
+ dataSource: static_gridOptions.dataSource ? static_gridOptions.dataSource : rows
252
255
  }), _react.default.createElement(_controls.ContextMenu, {
253
256
  menuAnchorEl: menuAnchorEl,
254
257
  set_menuAnchorEl: update_menuAnchorEl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/reactgrid",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -24,7 +24,7 @@ export function fix_parent_child_relations<T extends mrow>(rows: T[]): T[] {
24
24
  assign_children(mrow, converted_rows);
25
25
  }
26
26
  const result = top_level_rows.map((r) => r.data) as T[];
27
- console.log(result);
27
+ //console.log(result);
28
28
  return result;
29
29
  }
30
30
 
@@ -37,7 +37,7 @@ function assign_children(row: converted_row, all_rows: converted_row[]) {
37
37
  assign_children(child, all_rows);
38
38
  }
39
39
  row.data.__children = my_children.map((r) => r.data);
40
- } else row.data.__children = undefined;
40
+ } else if (!Array.isArray(row.data.__children) || row.data.__children.length == 0) row.data.__children = undefined;
41
41
  }
42
42
  export class func_selection {
43
43
  static getVirtualElement(x = 0, y = 0) {
package/src/index.tsx CHANGED
@@ -7,12 +7,12 @@ import React from 'react';
7
7
  import ReactDOM from 'react-dom/client';
8
8
  export default AzGrid;
9
9
 
10
- // if (process.env!.NODE_ENV === 'production') {
11
- // // set production urls
12
- // // enable sentry
13
- // } else if (process.env!.NODE_ENV === 'development') {
14
- // const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
15
- // root.render(<ExampleGrid />);
16
- // } else {
17
- // // set defaults
18
- // }
10
+ if (process.env!.NODE_ENV === 'production') {
11
+ // set production urls
12
+ // enable sentry
13
+ } else if (process.env!.NODE_ENV === 'development') {
14
+ const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
15
+ root.render(<ExampleGrid />);
16
+ } else {
17
+ // set defaults
18
+ }
File without changes
@@ -0,0 +1,15 @@
1
+ /* .InovuaReactDataGrid {
2
+ --grid-bg: '#fff';
3
+ }
4
+ .InovuaReactDataGrid {
5
+ background: var(--grid-bg) !important;
6
+ }
7
+ .InovuaReactDataGrid__header {
8
+ background: var(--grid-bg) !important;
9
+ }
10
+ .InovuaReactDataGrid__row {
11
+ background: var(--grid-bg) !important;
12
+ }
13
+ .InovuaReactDataGrid__cell {
14
+ background: var(--grid-bg) !important;
15
+ } */
@@ -1,6 +1,8 @@
1
1
  import '@inovua/reactdatagrid-enterprise/index.css';
2
2
  import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
3
- import '../themes/styles.css';
3
+ import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
4
+ import '../themes/base_styles.css';
5
+ import '../themes/grid.css';
4
6
 
5
7
  import React, { useCallback, useState } from 'react';
6
8
  import {
@@ -49,6 +51,8 @@ type GridOptions = Partial<TypeDataGridProps>;
49
51
  export type AzGridProps = {
50
52
  columns?: columnOrString[];
51
53
  rows?: any[];
54
+ get_rows?: () => any[];
55
+
52
56
  licenseKey?: string;
53
57
 
54
58
  gridOptions?: GridOptions;
@@ -63,7 +67,6 @@ export type AzGridProps = {
63
67
 
64
68
  highlightedRow?: any;
65
69
  RowDetail?: RowDetailsFunc;
66
- get_rows?: () => any[];
67
70
 
68
71
  selected?: RowSelectionValue;
69
72
  onSelectionChange?: OnSelectionChangeFunc;
@@ -152,11 +155,11 @@ export function AzGrid(props: AzGridProps) {
152
155
  const ext = mcolExts[index];
153
156
  const ext_cl = get_col_name(ext);
154
157
  const mcol = final_columns.find((s) => s.name === ext_cl);
155
- if (!mcol) continue;
156
- if (ext.width) mcol.width = ext.width;
157
- if (ext.visible) mcol.visible = ext.visible;
158
- if (ext.draggable) mcol.draggable = ext.draggable;
159
-
158
+ if (mcol) {
159
+ for (const key in ext) {
160
+ if (!mcol[key] && key != 'name') mcol[key] = ext[key];
161
+ }
162
+ }
160
163
  // if (ext.widthGrow) mcol.widthGrow = ext.widthGrow;
161
164
  }
162
165
 
@@ -213,7 +216,7 @@ export function AzGrid(props: AzGridProps) {
213
216
  /* -------------------------------------------------------------------------- */
214
217
  React.useEffect(() => {
215
218
  if (pendingChanges <= 0) return;
216
- console.log('Updated Pending Changes: ', pendingChanges);
219
+ //console.log('Updated Pending Changes: ', pendingChanges);
217
220
  let new_rows: any[] = [];
218
221
  if (typeof props.get_rows === 'function') {
219
222
  new_rows = props.get_rows();
@@ -229,12 +232,12 @@ export function AzGrid(props: AzGridProps) {
229
232
  }, [pendingChanges]);
230
233
 
231
234
  React.useEffect(() => {
232
- console.log('Rows Changed !');
235
+ //console.log('Rows Changed !');
233
236
  set_pendingChanges((r) => r + 1);
234
237
  }, [props.rows]);
235
238
 
236
239
  function onRowsChange(rows: any[], options: any) {
237
- console.log('onRowsChange');
240
+ //console.log('onRowsChange');
238
241
  if (props.onRowsChange) props.onRowsChange(rows, options);
239
242
  set_pendingChanges((r) => r + 1); //notify the cache to update rows after we made changes to them
240
243
  }
@@ -271,7 +274,7 @@ function DataGrid(props: DataGridProps) {
271
274
  licenseKey: licenseKey,
272
275
  treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
273
276
  renderRowDetails: props.RowDetail,
274
- theme: dark ? 'default-dark' : 'default-light',
277
+ theme: dark ? 'amber-dark' : 'default-light',
275
278
  };
276
279
  return { ...defaultOptions, ...events, ...extra_ops, ...props.gridOptions, ...forcedOptions };
277
280
  }, [props.gridOptions]);
@@ -319,7 +322,13 @@ function DataGrid(props: DataGridProps) {
319
322
 
320
323
  return (
321
324
  <div className={clsx(props.className, 'azgrid-nooverflow', 'azgrid-filler')}>
322
- <ReactDataGrid {...static_gridOptions} {...dynamic_gridOptions} className={'azgrid-filler'} columns={columns} dataSource={rows} />
325
+ <ReactDataGrid
326
+ {...static_gridOptions}
327
+ {...dynamic_gridOptions}
328
+ className={'azgrid-filler'}
329
+ columns={columns}
330
+ dataSource={static_gridOptions.dataSource ? static_gridOptions.dataSource : rows}
331
+ />
323
332
  <ContextMenu menuAnchorEl={menuAnchorEl} set_menuAnchorEl={update_menuAnchorEl} menuRow={menuRow} items={contextMenuItems} />
324
333
  </div>
325
334
  );