@azrico/reactgrid 1.2.3 → 1.2.5

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.
@@ -37,6 +37,7 @@ type GridOptions = Partial<TypeDataGridProps>;
37
37
  export type AzGridProps = {
38
38
  dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
39
39
  licenseKey?: string;
40
+ gridRef?: any;
40
41
  gridOptions?: GridOptions;
41
42
  columns?: LooseColumnDefinition[];
42
43
  columnExtensions?: Partial<LooseColumnDefinition>;
@@ -64,6 +64,8 @@ const defaultColumnOptions = {
64
64
  const dynamic_option_names = ['selected', 'loading', 'limit', 'skip'];
65
65
  /* -------------------------------------------------------------------------- */
66
66
  function AzGrid(props) {
67
+ const gridRefBackup = _react.default.useRef(null);
68
+ const gridRef = props.gridRef || gridRefBackup;
67
69
  /* -------------------------------------------------------------------------- */
68
70
  /* Columns */
69
71
  /* -------------------------------------------------------------------------- */
@@ -151,6 +153,7 @@ function AzGrid(props) {
151
153
  }, dynamic_option_names.map(r => props[r]));
152
154
  return _react.default.createElement(DataGridEventsWrapper, {
153
155
  ...props,
156
+ gridRef: gridRef,
154
157
  static_gridOptions: static_gridOptions,
155
158
  dynamic_gridOptions: dynamic_gridOptions,
156
159
  columns: cached_columns,
@@ -223,7 +226,7 @@ function DataGridEventsWrapper(props) {
223
226
  menuAnchorEl: menuAnchorEl,
224
227
  set_menuAnchorEl: update_menuAnchorEl,
225
228
  menuRow: menuRow,
226
- items: props.contextMenuItems
229
+ menu_items: props.contextMenuItems
227
230
  }), props.children);
228
231
  }
229
232
  function DataGridSizeWrapper(props) {
@@ -239,7 +242,6 @@ function DataGridSizeWrapper(props) {
239
242
  }
240
243
  }
241
244
  function DataGridDelayedSize(props) {
242
- const gridRef = _react.default.useRef(null);
243
245
  const {
244
246
  ref,
245
247
  height,
@@ -251,7 +253,7 @@ function DataGridDelayedSize(props) {
251
253
  }, _react.default.createElement(_reactdatagridEnterprise.default, {
252
254
  ...props.static_gridOptions,
253
255
  ...props.dynamic_gridOptions,
254
- handle: ref => gridRef.current = ref ? ref.current : null,
256
+ handle: ref => props.gridRef.current = ref ? ref.current : null,
255
257
  className: 'azgrid-delayedresize',
256
258
  style: {
257
259
  height: height,
@@ -262,13 +264,12 @@ function DataGridDelayedSize(props) {
262
264
  }), props.children);
263
265
  }
264
266
  function DataGridFlexSize(props) {
265
- const gridRef = _react.default.useRef(null);
266
267
  return _react.default.createElement("div", {
267
268
  className: (0, _clsx.default)(props.className, 'azgrid-nooverflow', 'azgrid-filler')
268
269
  }, _react.default.createElement(_reactdatagridEnterprise.default, {
269
270
  ...props.static_gridOptions,
270
271
  ...props.dynamic_gridOptions,
271
- handle: ref => gridRef.current = ref ? ref.current : null,
272
+ handle: ref => props.gridRef.current = ref ? ref.current : null,
272
273
  className: 'azgrid-filler',
273
274
  columns: props.columns,
274
275
  dataSource: props.dataSource
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/reactgrid",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -29,7 +29,7 @@
29
29
  "typescript": "^4.8.4"
30
30
  },
31
31
  "dependencies": {
32
- "@azrico/controls": "1.3.36",
32
+ "@azrico/controls": "1.3.37",
33
33
  "@azrico/object": "^1.3.1",
34
34
  "@emotion/react": "^11.9.3",
35
35
  "@emotion/styled": "^11.9.3",
@@ -69,6 +69,7 @@ export type AzGridProps = {
69
69
 
70
70
  licenseKey?: string;
71
71
 
72
+ gridRef?: any;
72
73
  gridOptions?: GridOptions;
73
74
 
74
75
  columns?: LooseColumnDefinition[];
@@ -162,6 +163,8 @@ const defaultColumnOptions: ColumnDefinition = {
162
163
  const dynamic_option_names = ['selected', 'loading', 'limit', 'skip'];
163
164
  /* -------------------------------------------------------------------------- */
164
165
  export function AzGrid(props: AzGridProps) {
166
+ const gridRefBackup = React.useRef<any>(null);
167
+ const gridRef = props.gridRef || gridRefBackup;
165
168
  /* -------------------------------------------------------------------------- */
166
169
  /* Columns */
167
170
  /* -------------------------------------------------------------------------- */
@@ -272,6 +275,7 @@ export function AzGrid(props: AzGridProps) {
272
275
  return (
273
276
  <DataGridEventsWrapper
274
277
  {...props}
278
+ gridRef={gridRef}
275
279
  static_gridOptions={static_gridOptions}
276
280
  dynamic_gridOptions={dynamic_gridOptions}
277
281
  columns={cached_columns}
@@ -358,7 +362,7 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
358
362
  menuAnchorEl={menuAnchorEl}
359
363
  set_menuAnchorEl={update_menuAnchorEl}
360
364
  menuRow={menuRow}
361
- items={props.contextMenuItems}
365
+ menu_items={props.contextMenuItems as any}
362
366
  />
363
367
  {props.children}
364
368
  </DataGridSizeWrapper>
@@ -373,7 +377,6 @@ function DataGridSizeWrapper(props: DataGridWrapperProps) {
373
377
  }
374
378
  }
375
379
  function DataGridDelayedSize(props: DataGridWrapperProps) {
376
- const gridRef = React.useRef<any>(null);
377
380
  const { ref, height, width } = useComponentSize();
378
381
  return (
379
382
  <div
@@ -383,7 +386,7 @@ function DataGridDelayedSize(props: DataGridWrapperProps) {
383
386
  <ReactDataGrid
384
387
  {...props.static_gridOptions}
385
388
  {...props.dynamic_gridOptions}
386
- handle={(ref) => (gridRef.current = ref ? ref.current : null)}
389
+ handle={(ref) => (props.gridRef.current = ref ? ref.current : null)}
387
390
  className={'azgrid-delayedresize'}
388
391
  style={{
389
392
  height: height,
@@ -397,13 +400,12 @@ function DataGridDelayedSize(props: DataGridWrapperProps) {
397
400
  );
398
401
  }
399
402
  function DataGridFlexSize(props: DataGridWrapperProps) {
400
- const gridRef = React.useRef<any>(null);
401
403
  return (
402
404
  <div className={clsx(props.className, 'azgrid-nooverflow', 'azgrid-filler')}>
403
405
  <ReactDataGrid
404
406
  {...props.static_gridOptions}
405
407
  {...props.dynamic_gridOptions}
406
- handle={(ref) => (gridRef.current = ref ? ref.current : null)}
408
+ handle={(ref) => (props.gridRef.current = ref ? ref.current : null)}
407
409
  className={'azgrid-filler'}
408
410
  columns={props.columns}
409
411
  dataSource={props.dataSource}