@azrico/reactgrid 1.2.35 → 1.2.37

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.
@@ -1,3 +1,23 @@
1
- export * from './DataGrid';
2
- import AzGrid from './DataGrid';
3
- export default AzGrid;
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.2.35",
3
+ "version": "1.2.37",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -259,18 +259,9 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
259
259
  const click_data = React.useRef<any>(null);
260
260
 
261
261
  const [menuAnchorEl, set_menuAnchorEl] = React.useState<any>(null);
262
- const [menuRow, set_menuRow] = React.useState<any>(null);
263
262
 
264
263
  /* --------------------------------- events --------------------------------- */
265
264
 
266
- const onRowContextMenu = React.useCallback((rowProps, event) => {
267
- if (!rowProps || !rowProps.data || func_selection.has_selection()) return;
268
-
269
- const anEl = func_selection.getVirtualElement(event.clientX, event.clientY);
270
- update_menuRow(rowProps.data);
271
- update_menuAnchorEl(anEl);
272
- event.preventDefault();
273
- }, []);
274
265
  const onRowClick = React.useCallback(
275
266
  (rowProps, event) => {
276
267
  const nowDate = Date.now();
@@ -297,16 +288,26 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
297
288
  }, [props.dataSource]);
298
289
 
299
290
  /* ------------------------------- ContextMenu ------------------------------ */
300
-
301
- const update_menuAnchorEl = React.useCallback((el) => {
302
- if (el) {
303
- set_menuAnchorEl(el);
304
- } else set_menuAnchorEl(null);
291
+ const onRowContextMenu = React.useCallback((rowProps, event) => {
292
+ if (!rowProps || !rowProps.data || func_selection.has_selection()) return;
293
+ const anEl = func_selection.getVirtualElement(event.clientX, event.clientY);
294
+ update_menuAnchorEl(anEl);
305
295
  }, []);
306
- const update_menuRow = React.useCallback((r) => {
307
- if (r) {
308
- set_menuRow(r);
309
- } else set_menuRow(null);
296
+ const renderRowContextMenu = React.useCallback(
297
+ (menuProps, rowProps) => {
298
+ return (
299
+ <ContextMenu
300
+ menuAnchorEl={menuAnchorEl}
301
+ set_menuAnchorEl={update_menuAnchorEl}
302
+ menuRow={rowProps.data}
303
+ menu_items={props.contextMenuItems as any}
304
+ />
305
+ );
306
+ },
307
+ [props.contextMenuItems]
308
+ );
309
+ const update_menuAnchorEl = React.useCallback((el) => {
310
+ set_menuAnchorEl(el || null);
310
311
  }, []);
311
312
 
312
313
  /**
@@ -317,31 +318,27 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
317
318
  onRowClick: onRowClick,
318
319
  onRowContextMenu: onRowContextMenu,
319
320
  };
320
- return { ...props.static_gridOptions, ...events };
321
+ const contextmenuProps: AzGridOptions = {
322
+ renderRowContextMenu: renderRowContextMenu,
323
+ };
324
+ return { ...props.static_gridOptions, ...events, ...contextmenuProps };
321
325
  }, [props.static_gridOptions, onRowClick]);
322
326
 
323
- const contextMenu = React.useMemo(() => {
324
- return (
325
- <ContextMenu
326
- menuAnchorEl={menuAnchorEl}
327
- set_menuAnchorEl={update_menuAnchorEl}
328
- menuRow={menuRow}
329
- menu_items={props.contextMenuItems as any}
330
- />
331
- );
332
- }, [menuAnchorEl, menuRow, props.contextMenuItems]);
327
+ /* -------------------------------------------------------------------------- */
333
328
 
334
329
  if (props.details_dataSource) {
335
330
  return (
336
- <DataGridDetailsWrapper {...props} static_gridOptions={static_gridOptions}>
337
- {contextMenu}
338
- </DataGridDetailsWrapper>
331
+ <DataGridDetailsWrapper
332
+ {...props}
333
+ static_gridOptions={static_gridOptions}
334
+ ></DataGridDetailsWrapper>
339
335
  );
340
336
  } else {
341
337
  return (
342
- <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions}>
343
- {contextMenu}
344
- </DataGridSizeWrapper>
338
+ <DataGridSizeWrapper
339
+ {...props}
340
+ static_gridOptions={static_gridOptions}
341
+ ></DataGridSizeWrapper>
345
342
  );
346
343
  }
347
344
  }