@azrico/reactgrid 1.3.52 → 1.4.0

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.
@@ -19,8 +19,9 @@
19
19
  display: flex;
20
20
  flex-direction: column;
21
21
  }
22
- .azgrid-testborder {
23
- border: 3px solid red;
22
+ .azgrid-scope {
23
+ min-height: 0;
24
+ min-width: 0;
24
25
  }
25
26
  .azgrid-pad50px {
26
27
  padding: 50px;
@@ -0,0 +1,49 @@
1
+ /* Example host preset; separate from the neutral grid theme. */
2
+ .azgrid-example-deco, .azgrid-theme-deco {
3
+ --azgrid-bg: #0A0A0A;
4
+ --azgrid-fg: #eee7d6;
5
+ --azgrid-border: #6b5824;
6
+ --azgrid-accent: #D4AF37;
7
+ --azgrid-muted-fg: #9b8a5b;
8
+ --azgrid-radius: 0;
9
+ --azgrid-font-family: Georgia, serif;
10
+ --azgrid-header-bg: #0A0A0A;
11
+ --azgrid-header-fg: #D4AF37;
12
+ --azgrid-header-border: #6b5824;
13
+ --azgrid-header-text-transform: uppercase;
14
+ --azgrid-header-letter-spacing: .1em;
15
+ --azgrid-header-font-weight: 600;
16
+ --azgrid-row-bg-even: #0A0A0A;
17
+ --azgrid-row-bg-odd: #12110e;
18
+ --azgrid-row-bg-hover: #282211;
19
+ --azgrid-row-fg-hover: #fff6dc;
20
+ --azgrid-row-bg-selected: #423619;
21
+ --azgrid-row-fg-selected: #fff6dc;
22
+ --azgrid-row-bg-active: #332a15;
23
+ --azgrid-cell-border: #6b5824;
24
+ --azgrid-cell-border-width: 1px;
25
+ --azgrid-cell-padding: 0 10px;
26
+ --azgrid-filter-bg: #12110e;
27
+ --azgrid-filter-fg: #eee7d6;
28
+ --azgrid-filter-border: #6b5824;
29
+ --azgrid-filter-placeholder: #9b8a5b;
30
+ --azgrid-filter-focus-ring: #D4AF37;
31
+ --azgrid-pagination-bg: #0A0A0A;
32
+ --azgrid-pagination-fg: #D4AF37;
33
+ --azgrid-pagination-border: #6b5824;
34
+ --azgrid-menu-bg: #12110e;
35
+ --azgrid-menu-fg: #eee7d6;
36
+ --azgrid-menu-border: #6b5824;
37
+ --azgrid-menu-bg-hover: #282211;
38
+ --azgrid-scrollbar-track: #0A0A0A;
39
+ --azgrid-scrollbar-thumb: #6b5824;
40
+ --azgrid-empty-bg: #0A0A0A;
41
+ --azgrid-empty-fg: #9b8a5b;
42
+ --azgrid-loading-bg: rgba(10, 10, 10, .85);
43
+ --azgrid-loading-fg: #D4AF37;
44
+ --azgrid-tree-bg: #12110e;
45
+ --azgrid-tree-fg: #D4AF37;
46
+ --azgrid-details-bg: #12110e;
47
+ --azgrid-shadow-color: rgba(0, 0, 0, .6);
48
+ --azgrid-locked-column-shadow: 0 0 5px #6b5824;
49
+ }
@@ -1,85 +1,17 @@
1
- .InovuaReactDataGrid {
2
- z-index: 1000;
3
- font-family: 'Nunito Sans', 'Iran Sans', sans-serif;
4
- }
5
-
6
- .InovuaReactDataGrid {
7
- --grid-bg: oklch(var(--b1, 100% 0 106));
8
- --grid-fg: oklch(var(--bc, 23.5% 0 0));
9
- --grid-bg-hover: oklch(var(--b2, 94.75% 0.014 277.06));
10
- --grid-bg-hover2: oklch(var(--b3, 94.75% 0.014 277.06));
11
- --grid-fg-hover: oklch(var(--bc, 23.5% 0 0));
12
- }.InovuaReactDataGrid--theme-amber-dark {
13
- --grid-bg: #313943;
14
- --grid-fg: #c5cae9;
15
- --grid-bg-hover: oklch(var(--b2, 40.8% 0.011 128.75));
16
- --grid-fg-hover: #ececec;
17
- }
18
- .InovuaReactDataGrid__row {
19
- color: var(--grid-fg);
20
- border-top-width: 1px;
21
- }
22
- .InovuaReactDataGrid--theme-default-light .InovuaReactDataGrid__row--odd {
23
- background-color: #fafafa;
24
- }
25
- .InovuaReactDataGrid--theme-default-light .InovuaReactDataGrid__row--even {
26
- background-color: #fff;
27
- }
28
- /* --------------------------- selected row color --------------------------- */
29
- .InovuaReactDataGrid
30
- .InovuaReactDataGrid__row--active
31
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
32
- .InovuaReactDataGrid
33
- .InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--even
34
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
35
- .InovuaReactDataGrid
36
- .InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--odd
37
- .InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background) {
38
- color: var(--grid-fg-hover);
39
- }
40
- /* ----------------------------- hover row color ---------------------------- */
41
- .InovuaReactDataGrid--show-hover-rows
42
- .InovuaReactDataGrid__row:not(.InovuaReactDataGrid__row--scrolling):not(
43
- .InovuaReactDataGrid__row--empty
44
- )
45
- .InovuaReactDataGrid__row-hover-target:hover {
46
- background: var(--grid-bg-hover) !important;
47
- color: var(--grid-fg-hover) !important;
48
- }
49
- .InovuaReactDataGrid--theme-default-light.InovuaReactDataGrid--show-hover-rows
50
- .InovuaReactDataGrid__row--no-zebra:not(.InovuaReactDataGrid__row--scrolling):not(
51
- .InovuaReactDataGrid__row--empty
52
- )
53
- .InovuaReactDataGrid__row-hover-target:hover
54
- .InovuaReactDataGrid__row-index-column,
55
- .InovuaReactDataGrid--theme-default-light.InovuaReactDataGrid--show-hover-rows
56
- .InovuaReactDataGrid__row-hover-target:hover
57
- .InovuaReactDataGrid__row-index-column {
58
- background: var(--grid-bg-hover2) !important;
59
- }
60
- /* -------------------------------------------------------------------------- */
61
- .inovua-react-toolkit-text-input {
62
- font-family: inherit;
63
- }
64
- .inovua-react-toolkit-text-input input {
65
- font-family: inherit;
66
- }
67
-
68
- .InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
69
- height: 100%;
70
- display: flex;
71
- align-items: center;
72
- }
73
- .InovuaReactDataGrid__column-header__content {
74
- text-overflow: clip;
75
- }
76
-
77
- .InovuaReactDataGrid__row.deleted:after {
78
- position: absolute;
79
- content: '';
80
- left: 5px;
81
- top: 50%;
82
- right: 5px;
83
- border-top: 1.5px solid;
84
- border-color: gray;
1
+ .InovuaReactDataGrid { z-index: 1000; }
2
+ .inovua-react-toolkit-text-input,
3
+ .inovua-react-toolkit-text-input input { font-family: inherit; }
4
+ .InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
5
+ height: 100%;
6
+ display: flex;
7
+ align-items: center;
8
+ }
9
+ .InovuaReactDataGrid__column-header__content { text-overflow: clip; }
10
+ .InovuaReactDataGrid__row.deleted:after {
11
+ position: absolute;
12
+ content: '';
13
+ left: 5px;
14
+ top: 50%;
15
+ right: 5px;
16
+ border-top: 1.5px solid;
85
17
  }
@@ -1,5 +1,5 @@
1
1
  import { ModifyFields } from '../func/func_grid';
2
- import { ConvertableToMenuItem } from '@azrico/controls';
2
+ import { ConvertableToMenuItem } from '@azrico/controls/context-menu';
3
3
  import React from 'react';
4
4
  import { TypeCellSelection, TypeColumn, TypeDataGridProps, TypeDataSource, TypeEditInfo, TypeFilterTypes, TypeFilterValue, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection, TypeComputedProps } from '@inovua/reactdatagrid-community/types';
5
5
  import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
@@ -66,6 +66,8 @@ export type AzGridProps = {
66
66
  editable?: boolean | ((editValue: any, cellProps: any) => boolean);
67
67
  advancedFilterFields?: string[];
68
68
  loading?: boolean;
69
+ theme?: 'light' | 'dark' | (string & {});
70
+ /** @deprecated Use theme="dark" or theme="light" instead. */
69
71
  dark?: boolean;
70
72
  delayedSize?: boolean;
71
73
  allowChildRows?: boolean;
@@ -1,6 +1,4 @@
1
1
  import '@inovua/reactdatagrid-enterprise/index.css';
2
- import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
3
- import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
4
2
  import '../themes/base_styles.css';
5
3
  import '../themes/grid.css';
6
4
  import React from 'react';
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.AzGrid = AzGrid;
7
7
  exports.default = void 0;
8
8
  require("@inovua/reactdatagrid-enterprise/index.css");
9
- require("@inovua/reactdatagrid-enterprise/theme/default-dark.css");
10
- require("@inovua/reactdatagrid-enterprise/theme/amber-dark.css");
11
9
  require("../themes/base_styles.css");
12
10
  require("../themes/grid.css");
13
11
  var _func_grid = require("../func/func_grid");
14
- var _controls = require("@azrico/controls");
12
+ var _contextMenu = require("@azrico/controls/context-menu");
15
13
  var _react = _interopRequireDefault(require("react"));
14
+ var _styles = require("@mui/material/styles");
16
15
  var _reactdatagridEnterprise = _interopRequireDefault(require("@inovua/reactdatagrid-enterprise"));
17
16
  var _clsx = _interopRequireDefault(require("clsx"));
18
17
  var _reactUseSize = require("react-use-size");
@@ -36,7 +35,8 @@ const defaultOptions = {
36
35
  };
37
36
  const forcedOptions = {
38
37
  idProperty: '__table_id',
39
- nodesProperty: '__children'
38
+ nodesProperty: '__children',
39
+ theme: 'default-light'
40
40
  };
41
41
  const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
42
42
  /* -------------------------------------------------------------------------- */
@@ -65,8 +65,7 @@ function AzGrid(props) {
65
65
  licenseKey: licenseKey,
66
66
  editable: props.editable,
67
67
  treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
68
- renderRowDetails: props.RowDetail,
69
- theme: props.dark ? 'amber-dark' : 'default-light'
68
+ renderRowDetails: props.RowDetail
70
69
  };
71
70
  return {
72
71
  ...defaultOptions,
@@ -108,6 +107,20 @@ function AzGrid(props) {
108
107
  * @returns
109
108
  */
110
109
  function DataGridEventsWrapper(props) {
110
+ var _props$theme;
111
+ const scopeRef = _react.default.useRef(null);
112
+ const hostTheme = (0, _styles.useTheme)();
113
+ // Keep the existing context menu and its portal in this grid's CSS scope.
114
+ const menuTheme = _react.default.useMemo(() => (0, _styles.createTheme)(hostTheme, {
115
+ components: {
116
+ MuiPopper: {
117
+ defaultProps: {
118
+ container: () => scopeRef.current
119
+ }
120
+ }
121
+ }
122
+ }), [hostTheme]);
123
+ const themeClass = `azgrid-theme-${(_props$theme = props.theme) !== null && _props$theme !== void 0 ? _props$theme : props.dark ? 'dark' : 'light'}`;
111
124
  /* -------------------------------------------------------------------------- */
112
125
  const {
113
126
  onRowClick,
@@ -137,13 +150,19 @@ function DataGridEventsWrapper(props) {
137
150
  }, [props.static_gridOptions]);
138
151
  /* -------------------------------------------------------------------------- */
139
152
  //TODO ContextMenu not from mui...
140
- return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_controls.ContextMenu, {
153
+ return _react.default.createElement("div", {
154
+ ref: scopeRef,
155
+ className: (0, _clsx.default)('azgrid-scope azgrid-flexed azgrid-flexlayout', themeClass)
156
+ }, _react.default.createElement(_styles.ThemeProvider, {
157
+ theme: menuTheme
158
+ }, _react.default.createElement(_contextMenu.ContextMenu, {
159
+ classname: "azgrid-context-menu",
141
160
  menuAnchorEl: menuAnchorEl,
142
161
  menuRow: menuRow,
143
162
  close: update_menuRow,
144
163
  dontAutoClose: false,
145
164
  menu_items: props.contextMenuItems
146
- }), props.details_dataSource ? _react.default.createElement(DataGridDetailsWrapper, {
165
+ })), props.details_dataSource ? _react.default.createElement(DataGridDetailsWrapper, {
147
166
  ...props,
148
167
  static_gridOptions: static_gridOptions
149
168
  }) : _react.default.createElement(DataGridSizeWrapper, {
@@ -157,7 +176,10 @@ function DataGridDetailsWrapper(props) {
157
176
  const renderDetailsGrid = ({
158
177
  data
159
178
  }) => {
179
+ var _props$theme2;
160
180
  return _react.default.createElement(_reactdatagridEnterprise.default, {
181
+ theme: "default-light",
182
+ className: (0, _clsx.default)('azgrid', `azgrid-theme-${(_props$theme2 = props.theme) !== null && _props$theme2 !== void 0 ? _props$theme2 : props.dark ? 'dark' : 'light'}`),
161
183
  defaultFilterValue: props.details_filter,
162
184
  dataSource: details_dataSource,
163
185
  columns: cached_details_columns
@@ -170,7 +192,7 @@ function DataGridDetailsWrapper(props) {
170
192
  const finalresult = props.static_gridOptions || {};
171
193
  finalresult['renderDetailsGrid'] = renderDetailsGrid;
172
194
  return finalresult;
173
- }, [props.static_gridOptions]);
195
+ }, [props.static_gridOptions, props.theme, props.dark]);
174
196
  return _react.default.createElement(DataGridSizeWrapper, {
175
197
  ...props,
176
198
  static_gridOptions: static_gridOptions
@@ -229,6 +251,7 @@ function DataGridSearchWrapper(props) {
229
251
  }));
230
252
  }
231
253
  function DataGridCore(props) {
254
+ var _props$theme3;
232
255
  return _react.default.createElement("div", {
233
256
  className: (0, _clsx.default)(props.className, 'azgrid-flexed', 'azgrid-flexlayout')
234
257
  }, _react.default.createElement(_reactdatagridEnterprise.default, {
@@ -238,7 +261,8 @@ function DataGridCore(props) {
238
261
  handle: ref => {
239
262
  if (ref) props.gridRef.current = ref.current;
240
263
  },
241
- className: 'azgrid-flexed',
264
+ theme: "default-light",
265
+ className: (0, _clsx.default)('azgrid azgrid-flexed', props.allowChildRows && 'azgrid-tree', `azgrid-theme-${(_props$theme3 = props.theme) !== null && _props$theme3 !== void 0 ? _props$theme3 : props.dark ? 'dark' : 'light'}`),
242
266
  columns: props.columns,
243
267
  dataSource: props.dataSource
244
268
  }), props.children);
@@ -17,6 +17,5 @@ Object.keys(_DataGrid).forEach(function (key) {
17
17
  }
18
18
  });
19
19
  });
20
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
22
21
  var _default = exports.default = _DataGrid.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/reactgrid",
3
- "version": "1.3.52",
3
+ "version": "1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -9,6 +9,8 @@
9
9
  "start": "react-scripts start",
10
10
  "build": "tsc && yarn cp_themes && babel dist --out-dir dist",
11
11
  "test": "rem",
12
+ "check:theme": "node config/check-theme.cjs",
13
+ "theme:generate": "node config/generate-theme.cjs",
12
14
  "cp_themes": "copyfiles ./src/themes/* ./dist/"
13
15
  },
14
16
  "config-overrides-path": "../../config/config-overrides.js",
@@ -29,7 +31,7 @@
29
31
  "typescript": "^4.8.4"
30
32
  },
31
33
  "dependencies": {
32
- "@azrico/controls": "^1.5.92",
34
+ "@azrico/controls": "1.6.1",
33
35
  "@azrico/object": "^1.4.97",
34
36
  "@emotion/react": "^11.9.3",
35
37
  "@emotion/styled": "^11.9.3",
@@ -40,11 +42,12 @@
40
42
  "react-use-size": "^3.0.1"
41
43
  },
42
44
  "peerDependencies": {
43
- "@azrico/controls": ">=1.5.12",
44
- "@azrico/object": ">=1.4.12",
45
+ "@azrico/controls": ">=1.6.1",
46
+ "@azrico/object": ">=1.4.97",
45
47
  "@emotion/react": ">=11.9.3",
46
48
  "@emotion/styled": ">=11.9.3",
47
49
  "@inovua/reactdatagrid-enterprise": ">=5.10.2",
50
+ "@mui/material": ">=5.0.0 <8.0.0",
48
51
  "clsx": ">=1.2.1",
49
52
  "react": ">=18.2.0",
50
53
  "react-use-size": ">=3.0.1"
@@ -61,5 +64,5 @@
61
64
  "last 1 safari version"
62
65
  ]
63
66
  },
64
- "packageManager": "yarn@3.5.0"
65
- }
67
+ "packageManager": "yarn@4.10.2"
68
+ }
@@ -1,9 +1,9 @@
1
- {
2
- "short_name": "AzGrid",
3
- "name": "React Grid Wrapper",
4
- "icons": [],
5
- "start_url": "./index.html",
6
- "display": "standalone",
7
- "theme_color": "#000000",
8
- "background_color": "#ffffff"
9
- }
1
+ {
2
+ "short_name": "AzGrid",
3
+ "name": "React Grid Wrapper",
4
+ "icons": [],
5
+ "start_url": "./index.html",
6
+ "display": "standalone",
7
+ "theme_color": "#000000",
8
+ "background_color": "#ffffff"
9
+ }
package/src/example.tsx CHANGED
@@ -2,6 +2,8 @@ export * from './views/DataGrid';
2
2
 
3
3
  import AzGrid from './views/DataGrid';
4
4
  import React from 'react';
5
+ import './themes/azgrid-theme.css';
6
+ import './themes/example-palettes.css';
5
7
 
6
8
  const columns = [
7
9
  {
@@ -125,39 +127,52 @@ export function ExampleGrid() {
125
127
  }, []);
126
128
 
127
129
  return (
128
- <AzGrid
129
- delayedSize
130
- dark
131
- // details_dataSource={details_dataSource}
132
- dataSource={dataSource}
133
- details_columns={columns}
134
- onRowClick={onRowClick}
135
- onRowDoubleClick={onRowDoubleClick}
136
- allowChildRows
137
- // onSelectionChange={onSelectionChange}
138
- // selected={selected}
139
- contextMenuItems={contextMenuItems as any}
140
- customColumns={customColumns}
141
- columns={columns}
142
- editableColumns={editableColumns}
143
- editable={true}
144
- onEditComplete={onEditComplete}
145
- advancedFilterFields={['name']}
146
- // leftColumns={leftColumns}
147
- gridOptions={
148
- {
149
- // defaultFilterValue: filterValue,
150
- // remoteFilter: false,
151
- // multiSelect: true,
152
- // pagination: 'local',
153
- // defaultLimit: 100,
154
- // limit: 100,
155
- // pageSizes: [100],
156
- // rowIndexColumn: true,
157
- // checkboxColumn: true,
158
- }
159
- }
160
- />
130
+ <div style={{ display: 'grid', gap: 20, height: '100%', overflow: 'auto' }}>
131
+ {['light', 'dark', 'deco'].map((theme) => (
132
+ <section key={theme} className={theme === 'deco' ? 'azgrid-example-deco' : undefined} style={{ height: 360, display: 'flex', flexDirection: 'column' }}>
133
+ <h3>{theme === 'deco' ? 'Art Deco (host variables)' : `Default ${theme}`}</h3>
134
+ <AzGrid
135
+ theme={theme}
136
+ delayedSize
137
+ // details_dataSource={details_dataSource}
138
+ dataSource={dataSource}
139
+ details_columns={columns}
140
+ onRowClick={onRowClick}
141
+ onRowDoubleClick={onRowDoubleClick}
142
+ allowChildRows
143
+ // onSelectionChange={onSelectionChange}
144
+ // selected={selected}
145
+ contextMenuItems={contextMenuItems as any}
146
+ customColumns={customColumns}
147
+ columns={columns}
148
+ editableColumns={editableColumns}
149
+ editable={true}
150
+ onEditComplete={onEditComplete}
151
+ advancedFilterFields={['name']}
152
+ // leftColumns={leftColumns}
153
+ gridOptions={
154
+ {
155
+ defaultFilterValue: [{ name: 'name', operator: 'contains', type: 'string', value: '' }],
156
+ pagination: 'local',
157
+ defaultLimit: 10,
158
+ pageSizes: [10, 25, 50],
159
+ checkboxColumn: true,
160
+ multiSelect: true,
161
+ // defaultFilterValue: filterValue,
162
+ // remoteFilter: false,
163
+ // multiSelect: true,
164
+ // pagination: 'local',
165
+ // defaultLimit: 100,
166
+ // limit: 100,
167
+ // pageSizes: [100],
168
+ // rowIndexColumn: true,
169
+ // checkboxColumn: true,
170
+ }
171
+ }
172
+ />
173
+ </section>
174
+ ))}
175
+ </div>
161
176
  );
162
177
  }
163
178
  export default ExampleGrid;
@@ -1,34 +1,34 @@
1
- import React from 'react';
2
- import {
3
- AzGridProps,
4
- DataGridWrapperProps,
5
- GridType,
6
- LooseColumnDefinition,
7
- } from '../types/types';
8
- import { applyColumnData, find_realData, get_row_id } from '../func/func_grid';
9
- import { func_selection } from '../func/func_child';
10
-
11
- export function useColumnData(
12
- inputOrProps: undefined | any[] | LooseColumnDefinition[] | AzGridProps
13
- ) {
14
- if (inputOrProps == null) return [];
15
- if (Array.isArray(inputOrProps)) return useThisColumnData(inputOrProps);
16
- return usePropsColumnData(inputOrProps);
17
- }
18
- function useThisColumnData(cols: any[]) {
19
- return React.useMemo(() => {
20
- return applyColumnData(cols);
21
- }, [cols]);
22
- }
23
- function usePropsColumnData(props: AzGridProps) {
24
- return React.useMemo(() => {
25
- return applyColumnData(props);
26
- }, [
27
- props.columns,
28
- props.leftColumns,
29
- props.rightColumns,
30
- props.editableColumns,
31
- props.columnExtensions,
32
- props.customColumns,
33
- ]);
34
- }
1
+ import React from 'react';
2
+ import {
3
+ AzGridProps,
4
+ DataGridWrapperProps,
5
+ GridType,
6
+ LooseColumnDefinition,
7
+ } from '../types/types';
8
+ import { applyColumnData, find_realData, get_row_id } from '../func/func_grid';
9
+ import { func_selection } from '../func/func_child';
10
+
11
+ export function useColumnData(
12
+ inputOrProps: undefined | any[] | LooseColumnDefinition[] | AzGridProps
13
+ ) {
14
+ if (inputOrProps == null) return [];
15
+ if (Array.isArray(inputOrProps)) return useThisColumnData(inputOrProps);
16
+ return usePropsColumnData(inputOrProps);
17
+ }
18
+ function useThisColumnData(cols: any[]) {
19
+ return React.useMemo(() => {
20
+ return applyColumnData(cols);
21
+ }, [cols]);
22
+ }
23
+ function usePropsColumnData(props: AzGridProps) {
24
+ return React.useMemo(() => {
25
+ return applyColumnData(props);
26
+ }, [
27
+ props.columns,
28
+ props.leftColumns,
29
+ props.rightColumns,
30
+ props.editableColumns,
31
+ props.columnExtensions,
32
+ props.customColumns,
33
+ ]);
34
+ }
@@ -1,25 +1,25 @@
1
- import React from 'react';
2
- import { AzGridProps, DataGridWrapperProps, GridType } from '../types/types';
3
- import {
4
- applyColumnData,
5
- ApplyDataSource,
6
- find_realData,
7
- get_row_id,
8
- } from '../func/func_grid';
9
- import { func_selection } from '../func/func_child';
10
-
11
- export function useDataSource(ds: any, props: AzGridProps) {
12
- const cached_data = React.useRef<any>();
13
- const last_cache_info = React.useRef<any>();
14
- return React.useCallback(
15
- async (dt) => {
16
- return await ApplyDataSource(ds, {
17
- skip: dt?.skip,
18
- limit: dt?.limit,
19
- cached_data: cached_data,
20
- last_cache_info: last_cache_info,
21
- });
22
- },
23
- [ds]
24
- );
25
- }
1
+ import React from 'react';
2
+ import { AzGridProps, DataGridWrapperProps, GridType } from '../types/types';
3
+ import {
4
+ applyColumnData,
5
+ ApplyDataSource,
6
+ find_realData,
7
+ get_row_id,
8
+ } from '../func/func_grid';
9
+ import { func_selection } from '../func/func_child';
10
+
11
+ export function useDataSource(ds: any, props: AzGridProps) {
12
+ const cached_data = React.useRef<any>();
13
+ const last_cache_info = React.useRef<any>();
14
+ return React.useCallback(
15
+ async (dt) => {
16
+ return await ApplyDataSource(ds, {
17
+ skip: dt?.skip,
18
+ limit: dt?.limit,
19
+ cached_data: cached_data,
20
+ last_cache_info: last_cache_info,
21
+ });
22
+ },
23
+ [ds]
24
+ );
25
+ }