@azrico/reactgrid 1.1.5 → 1.1.8

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.
@@ -10,13 +10,15 @@ require("@inovua/reactdatagrid-enterprise/theme/default-dark.css");
10
10
  require("@inovua/reactdatagrid-enterprise/theme/amber-dark.css");
11
11
  require("../themes/base_styles.css");
12
12
  require("../themes/grid.css");
13
- var _react = _interopRequireDefault(require("react"));
13
+ var _react = _interopRequireWildcard(require("react"));
14
14
  var _helpers = require("../func/helpers");
15
15
  var _controls = require("@azrico/controls");
16
16
  var _reactdatagridEnterprise = _interopRequireDefault(require("@inovua/reactdatagrid-enterprise"));
17
17
  var _clsx = _interopRequireDefault(require("clsx"));
18
18
  var _object = require("@azrico/object");
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
20
22
  /* -------------------------------------------------------------------------- */
21
23
  // const defaultfilterTypes: FilterTypes = {
22
24
  // string: {
@@ -120,6 +122,30 @@ function DataGrid(props) {
120
122
  const gridRef = _react.default.useRef(null);
121
123
  const [menuAnchorEl, set_menuAnchorEl] = _react.default.useState(null);
122
124
  const [menuRow, set_menuRow] = _react.default.useState(null);
125
+ /* --------------------------------- events --------------------------------- */
126
+ const onRowContextMenu = (0, _react.useCallback)((rowProps, event) => {
127
+ if (_helpers.func_selection.has_selection()) return;
128
+ update_menuAnchorEl(_helpers.func_selection.getVirtualElement(event.clientX, event.clientY));
129
+ update_menuRow(rowProps.data);
130
+ event.preventDefault();
131
+ }, []);
132
+ const onRowClick = (0, _react.useCallback)((rowProps, event) => {
133
+ props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
134
+ }, []);
135
+ const onRowDoubleClick = _react.default.useCallback((event, rowProps) => {
136
+ props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
137
+ }, []);
138
+ /* ------------------------------- ContextMenu ------------------------------ */
139
+ const update_menuAnchorEl = _react.default.useCallback(el => {
140
+ if (!el) {
141
+ set_menuAnchorEl(el);
142
+ } else if (menuAnchorEl) set_menuAnchorEl(null);
143
+ }, []);
144
+ const update_menuRow = _react.default.useCallback(r => {
145
+ if (!r) {
146
+ set_menuRow(r);
147
+ } else if (menuRow) set_menuRow(null);
148
+ }, []);
123
149
  /* -------------------------------------------------------------------------- */
124
150
  /* Create the grid */
125
151
  /* -------------------------------------------------------------------------- */
@@ -127,8 +153,8 @@ function DataGrid(props) {
127
153
  const firstcolumn = columns[0];
128
154
  const licenseKey = props.licenseKey || get_default_key();
129
155
  const events = {
130
- onRowClick: props.onRowClick ? onRowClick : undefined,
131
- onRowDoubleClick: props.onRowDoubleClick ? onRowDoubleClick : undefined,
156
+ onRowClick: onRowClick,
157
+ onRowDoubleClick: onRowDoubleClick,
132
158
  onSkipChange: props.onSkipChange,
133
159
  onLimitChange: props.onLimitChange,
134
160
  onRowContextMenu: onRowContextMenu
@@ -145,7 +171,7 @@ function DataGrid(props) {
145
171
  ...events,
146
172
  ...extra_ops
147
173
  };
148
- }, [props.allowChildRows, columns, props.RowDetail]);
174
+ }, [columns, props.allowChildRows, props.RowDetail, onRowClick, onRowDoubleClick, onRowContextMenu]);
149
175
  const static_gridOptions = _react.default.useMemo(() => {
150
176
  return {
151
177
  ...base_gridOptions,
@@ -160,31 +186,6 @@ function DataGrid(props) {
160
186
  });
161
187
  return res;
162
188
  }, dynamic_option_names.map(r => props[r]));
163
- /* --------------------------------- events --------------------------------- */
164
- function onRowContextMenu(row, ev) {
165
- if (_helpers.func_selection.has_selection()) return;
166
- update_menuAnchorEl(_helpers.func_selection.getVirtualElement(ev.clientX, ev.clientY));
167
- update_menuRow(row.data);
168
- ev.preventDefault();
169
- }
170
- function onRowClick(row, event) {
171
- props.onRowClick && props.onRowClick(row.rowIndex, row.data);
172
- }
173
- function onRowDoubleClick(event, row) {
174
- props.onRowDoubleClick && props.onRowDoubleClick(row.rowIndex, row.data);
175
- }
176
- /* ------------------------------- ContextMenu ------------------------------ */
177
- function update_menuAnchorEl(el) {
178
- if (!el) {
179
- set_menuAnchorEl(el);
180
- } else if (menuAnchorEl) set_menuAnchorEl(null);
181
- }
182
- function update_menuRow(r) {
183
- if (!r) {
184
- set_menuRow(r);
185
- } else if (menuRow) set_menuRow(null);
186
- }
187
- /* -------------------------------------------------------------------------- */
188
189
  // const { width, height, ref: resize_ref } = useResizeDetector();
189
190
  return _react.default.createElement("div", {
190
191
  className: (0, _clsx.default)(props.className, 'azgrid-nooverflow', 'azgrid-filler')
@@ -325,6 +326,7 @@ function ApplyColumnData(props) {
325
326
  }
326
327
  }
327
328
  }
329
+ if (!Array.isArray(final_columns) || final_columns.length <= 0) return [];
328
330
  return final_columns;
329
331
  }
330
332
  /* -------------------------------------------------------------------------- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/reactgrid",
3
- "version": "1.1.5",
3
+ "version": "1.1.8",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -203,6 +203,7 @@ export function AzGrid(props: AzGridProps) {
203
203
  },
204
204
  [props.dataSource]
205
205
  );
206
+
206
207
  return (
207
208
  <DataGrid
208
209
  {...props}
@@ -223,6 +224,33 @@ function DataGrid(props: DataGridProps) {
223
224
  const [menuAnchorEl, set_menuAnchorEl] = React.useState<any>(null);
224
225
  const [menuRow, set_menuRow] = React.useState<any>(null);
225
226
 
227
+ /* --------------------------------- events --------------------------------- */
228
+
229
+ const onRowContextMenu = useCallback((rowProps, event) => {
230
+ if (func_selection.has_selection()) return;
231
+ update_menuAnchorEl(func_selection.getVirtualElement(event.clientX, event.clientY));
232
+ update_menuRow(rowProps.data);
233
+ event.preventDefault();
234
+ }, []);
235
+ const onRowClick = useCallback((rowProps, event) => {
236
+ props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
237
+ }, []);
238
+ const onRowDoubleClick = React.useCallback((event, rowProps) => {
239
+ props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
240
+ }, []);
241
+
242
+ /* ------------------------------- ContextMenu ------------------------------ */
243
+ const update_menuAnchorEl = React.useCallback((el) => {
244
+ if (!el) {
245
+ set_menuAnchorEl(el);
246
+ } else if (menuAnchorEl) set_menuAnchorEl(null);
247
+ }, []);
248
+ const update_menuRow = React.useCallback((r) => {
249
+ if (!r) {
250
+ set_menuRow(r);
251
+ } else if (menuRow) set_menuRow(null);
252
+ }, []);
253
+
226
254
  /* -------------------------------------------------------------------------- */
227
255
  /* Create the grid */
228
256
  /* -------------------------------------------------------------------------- */
@@ -231,8 +259,8 @@ function DataGrid(props: DataGridProps) {
231
259
  const firstcolumn = columns[0];
232
260
  const licenseKey = props.licenseKey || get_default_key();
233
261
  const events: GridOptions = {
234
- onRowClick: props.onRowClick ? onRowClick : undefined,
235
- onRowDoubleClick: props.onRowDoubleClick ? onRowDoubleClick : undefined,
262
+ onRowClick: onRowClick,
263
+ onRowDoubleClick: onRowDoubleClick,
236
264
  onSkipChange: props.onSkipChange,
237
265
  onLimitChange: props.onLimitChange,
238
266
  onRowContextMenu: onRowContextMenu,
@@ -245,7 +273,14 @@ function DataGrid(props: DataGridProps) {
245
273
  theme: dark ? 'amber-dark' : 'default-light',
246
274
  };
247
275
  return { ...defaultOptions, ...events, ...extra_ops };
248
- }, [props.allowChildRows, columns, props.RowDetail]);
276
+ }, [
277
+ columns,
278
+ props.allowChildRows,
279
+ props.RowDetail,
280
+ onRowClick,
281
+ onRowDoubleClick,
282
+ onRowContextMenu,
283
+ ]);
249
284
 
250
285
  const static_gridOptions = React.useMemo<GridOptions>(() => {
251
286
  return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
@@ -262,34 +297,6 @@ function DataGrid(props: DataGridProps) {
262
297
  dynamic_option_names.map((r) => props[r])
263
298
  );
264
299
 
265
- /* --------------------------------- events --------------------------------- */
266
- function onRowContextMenu(row: TypeRowProps, ev: any) {
267
- if (func_selection.has_selection()) return;
268
- update_menuAnchorEl(func_selection.getVirtualElement(ev.clientX, ev.clientY));
269
- update_menuRow(row.data);
270
- ev.preventDefault();
271
- }
272
- function onRowClick(row: RowProps, event) {
273
- props.onRowClick && props.onRowClick(row.rowIndex, row.data);
274
- }
275
- function onRowDoubleClick(event: MouseEvent, row: RowProps) {
276
- props.onRowDoubleClick && props.onRowDoubleClick(row.rowIndex, row.data);
277
- }
278
-
279
- /* ------------------------------- ContextMenu ------------------------------ */
280
-
281
- function update_menuAnchorEl(el) {
282
- if (!el) {
283
- set_menuAnchorEl(el);
284
- } else if (menuAnchorEl) set_menuAnchorEl(null);
285
- }
286
- function update_menuRow(r) {
287
- if (!r) {
288
- set_menuRow(r);
289
- } else if (menuRow) set_menuRow(null);
290
- }
291
-
292
- /* -------------------------------------------------------------------------- */
293
300
  // const { width, height, ref: resize_ref } = useResizeDetector();
294
301
 
295
302
  return (
@@ -444,7 +451,7 @@ function ApplyColumnData(props: any) {
444
451
  }
445
452
  }
446
453
  }
447
-
454
+ if (!Array.isArray(final_columns) || final_columns.length <= 0) return [];
448
455
  return final_columns;
449
456
  }
450
457