@azrico/reactgrid 1.2.12 → 1.2.14
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.
- package/CHANGELOG.md +4 -0
- package/dist/index.js +3 -21
- package/dist/src/example.js +118 -161
- package/dist/src/func/func_child.js +81 -84
- package/dist/src/func/func_grid.js +271 -260
- package/dist/src/index.js +6 -25
- package/dist/src/views/DataGrid.d.ts +9 -3
- package/dist/src/views/DataGrid.js +223 -269
- package/dist/src/views/index.js +3 -23
- package/package.json +1 -1
- package/src/views/DataGrid.tsx +23 -15
- package/dist/src/themes/base_styles.css +0 -30
- package/dist/src/themes/grid.css +0 -20
package/src/views/DataGrid.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { ContextMenu, ConvertableToMenuItem } from '@azrico/controls';
|
|
16
16
|
import React, { useCallback, useState } from 'react';
|
|
17
17
|
import {
|
|
18
|
+
TypeCellSelection,
|
|
18
19
|
TypeColumn,
|
|
19
20
|
TypeDataGridProps,
|
|
20
21
|
TypeDataSource,
|
|
@@ -41,11 +42,13 @@ export type CellDefinition = any;
|
|
|
41
42
|
export type RowDefinition = any;
|
|
42
43
|
export type RowProps = TypeRowProps;
|
|
43
44
|
export type RowSelectionValue = TypeRowSelection;
|
|
45
|
+
export type CellSelectionValue = TypeCellSelection;
|
|
44
46
|
export type DataRowDefinition = any;
|
|
45
47
|
export type FilterTypes = TypeFilterTypes;
|
|
46
48
|
export type FilterValues = TypeFilterValue;
|
|
47
49
|
export type DataSourceDefinition = TypeDataSource;
|
|
48
50
|
export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
|
|
51
|
+
export type OnCellSelectionChangeFunc = (s: { [key: string]: boolean }) => void;
|
|
49
52
|
export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
|
|
50
53
|
/* -------------------------------------------------------------------------- */
|
|
51
54
|
type loose_column_names = {
|
|
@@ -66,7 +69,7 @@ type customColumnData = {
|
|
|
66
69
|
name: string;
|
|
67
70
|
render: (cell: any, formatterParams, onRendered) => React.ReactNode | undefined | null;
|
|
68
71
|
};
|
|
69
|
-
type
|
|
72
|
+
export type AzGridOptions = Partial<TypeDataGridProps>;
|
|
70
73
|
/* -------------------------------------------------------------------------- */
|
|
71
74
|
export type AzGridProps = {
|
|
72
75
|
dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
@@ -77,7 +80,7 @@ export type AzGridProps = {
|
|
|
77
80
|
licenseKey?: string;
|
|
78
81
|
|
|
79
82
|
gridRef?: any;
|
|
80
|
-
gridOptions?:
|
|
83
|
+
gridOptions?: AzGridOptions;
|
|
81
84
|
|
|
82
85
|
columns?: LooseColumnDefinition[];
|
|
83
86
|
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
@@ -93,9 +96,11 @@ export type AzGridProps = {
|
|
|
93
96
|
RowDetail?: RowDetailsFunc;
|
|
94
97
|
|
|
95
98
|
selected?: RowSelectionValue;
|
|
99
|
+
cellSelection?: CellSelectionValue;
|
|
96
100
|
/* -------------------------------------------------------------------------- */
|
|
97
101
|
onEditComplete?: (editInfo: TypeEditInfo) => void;
|
|
98
102
|
onSelectionChange?: OnSelectionChangeFunc;
|
|
103
|
+
onCellSelectionChange?: OnCellSelectionChangeFunc;
|
|
99
104
|
|
|
100
105
|
onRowClick?: (rowIndex: number, row: any) => void;
|
|
101
106
|
onRowDoubleClick?: (rowIndex: number, row: any) => void;
|
|
@@ -126,14 +131,14 @@ type DataGridProps = ModifyFields<
|
|
|
126
131
|
type DataGridWrapperProps = ModifyFields<
|
|
127
132
|
DataGridProps,
|
|
128
133
|
{
|
|
129
|
-
static_gridOptions:
|
|
130
|
-
dynamic_gridOptions:
|
|
134
|
+
static_gridOptions: AzGridOptions;
|
|
135
|
+
dynamic_gridOptions: AzGridOptions;
|
|
131
136
|
children?: React.ReactNode;
|
|
132
137
|
}
|
|
133
138
|
>;
|
|
134
139
|
/* -------------------------------------------------------------------------- */
|
|
135
140
|
|
|
136
|
-
const defaultOptions:
|
|
141
|
+
const defaultOptions: AzGridOptions = {
|
|
137
142
|
//filterTypes: defaultfilterTypes,
|
|
138
143
|
remoteFilter: false,
|
|
139
144
|
remoteSort: false,
|
|
@@ -144,12 +149,12 @@ const defaultOptions: GridOptions = {
|
|
|
144
149
|
rowIndexColumn: true,
|
|
145
150
|
rowHeight: 35,
|
|
146
151
|
};
|
|
147
|
-
const forcedOptions:
|
|
152
|
+
const forcedOptions: AzGridOptions = {
|
|
148
153
|
idProperty: '__table_id',
|
|
149
154
|
nodesProperty: '__children',
|
|
150
155
|
};
|
|
151
156
|
|
|
152
|
-
const dynamic_option_names = ['selected', 'loading', 'limit', 'skip'];
|
|
157
|
+
const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
|
|
153
158
|
/* -------------------------------------------------------------------------- */
|
|
154
159
|
export function AzGrid(props: AzGridProps) {
|
|
155
160
|
const gridRefBackup = React.useRef<any>(null);
|
|
@@ -186,16 +191,18 @@ export function AzGrid(props: AzGridProps) {
|
|
|
186
191
|
[props.dataSource]
|
|
187
192
|
);
|
|
188
193
|
|
|
189
|
-
const base_gridOptions = React.useMemo<
|
|
194
|
+
const base_gridOptions = React.useMemo<AzGridOptions>(() => {
|
|
190
195
|
const firstcolumn = cached_columns[0];
|
|
191
196
|
const licenseKey = props.licenseKey || get_default_key();
|
|
192
|
-
const events:
|
|
197
|
+
const events: AzGridOptions = {
|
|
193
198
|
onSkipChange: props.onSkipChange,
|
|
194
199
|
onLimitChange: props.onLimitChange,
|
|
195
200
|
onEditComplete: props.onEditComplete,
|
|
196
201
|
};
|
|
197
|
-
const extra_ops:
|
|
202
|
+
const extra_ops: AzGridOptions = {
|
|
198
203
|
onSelectionChange: props.onSelectionChange,
|
|
204
|
+
onCellSelectionChange: props.onCellSelectionChange,
|
|
205
|
+
|
|
199
206
|
licenseKey: licenseKey,
|
|
200
207
|
editable: props.editable as any, //bug in types of the plugin
|
|
201
208
|
treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
|
|
@@ -211,11 +218,11 @@ export function AzGrid(props: AzGridProps) {
|
|
|
211
218
|
props.onEditComplete,
|
|
212
219
|
]);
|
|
213
220
|
|
|
214
|
-
const static_gridOptions = React.useMemo<
|
|
221
|
+
const static_gridOptions = React.useMemo<AzGridOptions>(() => {
|
|
215
222
|
return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
|
|
216
223
|
}, [props.gridOptions, base_gridOptions, forcedOptions]);
|
|
217
224
|
|
|
218
|
-
const dynamic_gridOptions = React.useMemo<
|
|
225
|
+
const dynamic_gridOptions = React.useMemo<AzGridOptions>(
|
|
219
226
|
() => {
|
|
220
227
|
const res = {};
|
|
221
228
|
dynamic_option_names.map((r) => {
|
|
@@ -302,8 +309,8 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
|
|
|
302
309
|
/**
|
|
303
310
|
* Merge click events into grid options
|
|
304
311
|
*/
|
|
305
|
-
const static_gridOptions = React.useMemo<
|
|
306
|
-
const events:
|
|
312
|
+
const static_gridOptions = React.useMemo<AzGridOptions>(() => {
|
|
313
|
+
const events: AzGridOptions = {
|
|
307
314
|
onRowClick: onRowClick,
|
|
308
315
|
onRowContextMenu: onRowContextMenu,
|
|
309
316
|
};
|
|
@@ -370,7 +377,7 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
|
|
|
370
377
|
/**
|
|
371
378
|
* Merge details into grid
|
|
372
379
|
*/
|
|
373
|
-
const static_gridOptions = React.useMemo<
|
|
380
|
+
const static_gridOptions = React.useMemo<AzGridOptions>(() => {
|
|
374
381
|
const finalresult = props.static_gridOptions || {};
|
|
375
382
|
finalresult['renderDetailsGrid'] = renderDetailsGrid;
|
|
376
383
|
return finalresult;
|
|
@@ -425,6 +432,7 @@ function DataGridFlexSize(props: DataGridWrapperProps) {
|
|
|
425
432
|
className={'azgrid-filler'}
|
|
426
433
|
columns={props.columns}
|
|
427
434
|
dataSource={props.dataSource}
|
|
435
|
+
onCellSelectionChange
|
|
428
436
|
/>
|
|
429
437
|
{props.children}
|
|
430
438
|
</div>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.azgrid-container {
|
|
2
|
-
height: 100%;
|
|
3
|
-
width: 100%;
|
|
4
|
-
}
|
|
5
|
-
.azgrid-borderbox {
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
}
|
|
8
|
-
.azgrid-filler {
|
|
9
|
-
height: 100%;
|
|
10
|
-
width: 100%;
|
|
11
|
-
}
|
|
12
|
-
.azgrid-nooverflow {
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
}
|
|
15
|
-
.azgrid-testborder {
|
|
16
|
-
border: 3px solid red;
|
|
17
|
-
}
|
|
18
|
-
.azgrid-pad50px {
|
|
19
|
-
padding: 50px;
|
|
20
|
-
}
|
|
21
|
-
.azgrid-nopad {
|
|
22
|
-
padding: 0;
|
|
23
|
-
}
|
|
24
|
-
.azgrid-nomargin {
|
|
25
|
-
margin: 0;
|
|
26
|
-
}
|
|
27
|
-
.azgrid-delayedresize {
|
|
28
|
-
transition-property: 'width,height';
|
|
29
|
-
transition-delay: 200ms;
|
|
30
|
-
}
|
package/dist/src/themes/grid.css
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
} */
|
|
16
|
-
.InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
|
|
17
|
-
height: 100%;
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
}
|