@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
|
@@ -1,280 +1,291 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
data: result_data
|
|
54
|
-
};
|
|
55
|
-
if (!Array.isArray(result_data.data)) result_data.data = [result_data.data];
|
|
56
|
-
//no need to fix parent/child when using cache (it should be already fixed)
|
|
57
|
-
if (!isUsingCache && props.allowChildRows) {
|
|
58
|
-
result_data.data = (0, _func_child.fix_parent_child_relations)(result_data.data);
|
|
59
|
-
}
|
|
60
|
-
if (!result_data.count) {
|
|
61
|
-
result_data.count = result_data.data.length;
|
|
62
|
-
}
|
|
63
|
-
//update cache
|
|
64
|
-
props.cached_data.current = result_data;
|
|
65
|
-
return result_data;
|
|
66
|
-
}
|
|
1
|
+
import BoolEditor from '@inovua/reactdatagrid-community/BoolEditor';
|
|
2
|
+
import NumericEditor from '@inovua/reactdatagrid-community/NumericEditor';
|
|
3
|
+
import SelectEditor from '@inovua/reactdatagrid-community/SelectEditor';
|
|
4
|
+
import { fix_parent_child_relations } from './func_child';
|
|
5
|
+
import { object_equals } from '@azrico/object';
|
|
6
|
+
const defaultColumnOptions = {
|
|
7
|
+
draggable: false,
|
|
8
|
+
lockable: false,
|
|
9
|
+
editable: false,
|
|
10
|
+
};
|
|
11
|
+
export async function ApplyDataSource(datasource, props) {
|
|
12
|
+
let result_data = undefined;
|
|
13
|
+
let isUsingCache = false;
|
|
14
|
+
const cacheInfo = { ds: datasource, skip: props.skip, limit: props.limit };
|
|
15
|
+
//check if we can used cached data
|
|
16
|
+
//if the datasource is changed since last render, we should invalidate cache
|
|
17
|
+
if (!validateCache(props.last_cache_info.current, cacheInfo, props.looseCacheCheck)) {
|
|
18
|
+
props.cached_data.current = undefined;
|
|
19
|
+
props.last_cache_info.current = cacheInfo;
|
|
20
|
+
}
|
|
21
|
+
if (props.cached_data.current) {
|
|
22
|
+
//cache is valid, use the cache
|
|
23
|
+
isUsingCache = true;
|
|
24
|
+
result_data = props.cached_data.current;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
//cache is invalid, use the datasource again
|
|
28
|
+
isUsingCache = false;
|
|
29
|
+
if (typeof datasource === 'function') {
|
|
30
|
+
result_data = await datasource(props);
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
result_data = datasource;
|
|
34
|
+
}
|
|
35
|
+
//making sure the datasource is a valid object :
|
|
36
|
+
if (!result_data)
|
|
37
|
+
result_data = [];
|
|
38
|
+
if (Array.isArray(result_data) || typeof result_data !== 'object')
|
|
39
|
+
result_data = { data: result_data };
|
|
40
|
+
if (!Array.isArray(result_data.data))
|
|
41
|
+
result_data.data = [result_data.data];
|
|
42
|
+
//no need to fix parent/child when using cache (it should be already fixed)
|
|
43
|
+
if (!isUsingCache && props.allowChildRows) {
|
|
44
|
+
result_data.data = fix_parent_child_relations(result_data.data);
|
|
45
|
+
}
|
|
46
|
+
if (!result_data.count) {
|
|
47
|
+
result_data.count = result_data.data.length;
|
|
48
|
+
}
|
|
49
|
+
//update cache
|
|
50
|
+
props.cached_data.current = result_data;
|
|
51
|
+
return result_data;
|
|
52
|
+
}
|
|
67
53
|
/**
|
|
68
54
|
* merges together all different props for columns
|
|
69
55
|
* to build a single final column data array
|
|
70
56
|
* @param column_data
|
|
71
57
|
* @returns
|
|
72
|
-
*/
|
|
73
|
-
function ApplyColumnData(column_data) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
58
|
+
*/
|
|
59
|
+
export function ApplyColumnData(column_data) {
|
|
60
|
+
const final_columns = [];
|
|
61
|
+
if (!column_data)
|
|
62
|
+
column_data = {};
|
|
63
|
+
if (Array.isArray(column_data))
|
|
64
|
+
column_data = { columns: column_data };
|
|
65
|
+
let mcols = column_data.columns || [];
|
|
66
|
+
let mcolExts = column_data.columnExtensions || [];
|
|
67
|
+
let rightColumns = column_data.rightColumns || [];
|
|
68
|
+
let leftColumns = column_data.leftColumns || [];
|
|
69
|
+
let editableColumns = column_data.editableColumns || [];
|
|
70
|
+
let customColumns = column_data.customColumns || [];
|
|
71
|
+
if (!Array.isArray(mcols))
|
|
72
|
+
return [];
|
|
73
|
+
/* ------------------------------- fix columns ------------------------------ */
|
|
74
|
+
mcols
|
|
75
|
+
.map((r) => {
|
|
76
|
+
if (r == null)
|
|
77
|
+
return null;
|
|
78
|
+
if (typeof r === 'string')
|
|
79
|
+
return { field: r, header: r };
|
|
80
|
+
if (typeof r === 'object') {
|
|
81
|
+
let final_cl = {
|
|
82
|
+
name: get_col_name(r),
|
|
83
|
+
header: get_col_header(r),
|
|
84
|
+
width: r.width || undefined,
|
|
85
|
+
};
|
|
86
|
+
final_cl = {
|
|
87
|
+
...defaultColumnOptions,
|
|
88
|
+
...r,
|
|
89
|
+
...final_cl,
|
|
90
|
+
};
|
|
91
|
+
return final_cl;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
})
|
|
95
|
+
.forEach((r) => {
|
|
96
|
+
if (r != null)
|
|
97
|
+
final_columns.push(r);
|
|
98
|
+
});
|
|
99
|
+
/* ---------------------------- apply extensions ---------------------------- */
|
|
100
|
+
if (mcolExts && Array.isArray(mcolExts))
|
|
101
|
+
for (let index = 0; index < mcolExts.length; index++) {
|
|
102
|
+
const ext = mcolExts[index];
|
|
103
|
+
const ext_cl = get_col_name(ext);
|
|
104
|
+
if (!ext_cl) {
|
|
105
|
+
console.warn('ColumnExtension must have a name');
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const mcol = final_columns.find((s) => get_col_name(s) === ext_cl);
|
|
109
|
+
if (mcol) {
|
|
110
|
+
for (const key in ext) {
|
|
111
|
+
if (!mcol[key] && key != 'name')
|
|
112
|
+
mcol[key] = ext[key];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// if (ext.widthGrow) mcol.widthGrow = ext.widthGrow;
|
|
116
|
+
}
|
|
117
|
+
/* ------------------------------- frozen cols ------------------------------ */
|
|
118
|
+
if (Array.isArray(leftColumns)) {
|
|
119
|
+
for (let index = 0; index < leftColumns.length; index++) {
|
|
120
|
+
const r = get_col_name(leftColumns[index]);
|
|
121
|
+
const mcol = final_columns.find((s) => get_col_name(s) === r);
|
|
122
|
+
if (mcol) {
|
|
123
|
+
mcol.locked = 'start';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(rightColumns)) {
|
|
128
|
+
for (let index = 0; index < rightColumns.length; index++) {
|
|
129
|
+
const r = get_col_name(rightColumns[index]);
|
|
130
|
+
const mcol = final_columns.find((s) => get_col_name(s) === r);
|
|
131
|
+
if (mcol) {
|
|
132
|
+
mcol.locked = 'end';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/* -------------------------------- ediatable ------------------------------- */
|
|
137
|
+
if (Array.isArray(editableColumns)) {
|
|
138
|
+
for (let index = 0; index < editableColumns.length; index++) {
|
|
139
|
+
const r = get_col_name(editableColumns[index]);
|
|
140
|
+
const mcol = final_columns.find((s) => get_col_name(s) === r);
|
|
141
|
+
if (mcol) {
|
|
142
|
+
mcol.editable = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (let index = 0; index < final_columns.length; index++) {
|
|
147
|
+
const col = final_columns[index];
|
|
148
|
+
if (col.type) {
|
|
149
|
+
switch (col.type) {
|
|
150
|
+
case 'combo':
|
|
151
|
+
case 'select':
|
|
152
|
+
//@ts-ignore
|
|
153
|
+
col.editor = SelectEditor;
|
|
154
|
+
break;
|
|
155
|
+
case 'number':
|
|
156
|
+
case 'numberic':
|
|
157
|
+
//@ts-ignore
|
|
158
|
+
col.editor = NumericEditor;
|
|
159
|
+
break;
|
|
160
|
+
case 'truefalse':
|
|
161
|
+
case 'bool':
|
|
162
|
+
//@ts-ignore
|
|
163
|
+
col.editor = BoolEditor;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (col.editable != false)
|
|
167
|
+
col.editable = true;
|
|
168
|
+
delete col.type;
|
|
169
|
+
}
|
|
170
|
+
//@ts-ignore
|
|
171
|
+
if (!col.editorProps)
|
|
172
|
+
col.editorProps = {};
|
|
173
|
+
if (col.items) {
|
|
174
|
+
//@ts-ignore
|
|
175
|
+
if (!col.editorProps.idProperty)
|
|
176
|
+
col.editorProps.idProperty = 'id';
|
|
177
|
+
//@ts-ignore
|
|
178
|
+
if (!col.editorProps.collapseOnSelect)
|
|
179
|
+
col.editorProps.collapseOnSelect = true;
|
|
180
|
+
//@ts-ignore
|
|
181
|
+
col.editorProps.dataSource = to_datasource(col.items, col.editorProps.idProperty);
|
|
182
|
+
delete col.items;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/* -------------------------------------------------------------------------- */
|
|
186
|
+
if (Array.isArray(customColumns)) {
|
|
187
|
+
for (let index = 0; index < customColumns.length; index++) {
|
|
188
|
+
const r = customColumns[index];
|
|
189
|
+
const rn = get_col_name(r);
|
|
190
|
+
const mcol = final_columns.find((s) => get_col_name(s) === rn);
|
|
191
|
+
if (mcol) {
|
|
192
|
+
//@ts-ignore
|
|
193
|
+
mcol.render = r.render;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/* ------------------------------ apply renames ----------------------------- */
|
|
198
|
+
for (let index = 0; index < final_columns.length; index++) {
|
|
199
|
+
const col = final_columns[index];
|
|
200
|
+
if (!col.name) {
|
|
201
|
+
col.name = get_col_name(col);
|
|
202
|
+
delete col.field;
|
|
203
|
+
delete col.key;
|
|
204
|
+
delete col.columnName;
|
|
205
|
+
if (col.flex && !col.defaultFlex)
|
|
206
|
+
col.defaultFlex = col.flex;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/* -------------------------------------------------------------------------- */
|
|
210
|
+
//console.log(final_columns);
|
|
211
|
+
return final_columns;
|
|
212
|
+
}
|
|
213
|
+
export function to_datasource(arr, idProperty, valueAsID = true) {
|
|
214
|
+
const res = [];
|
|
215
|
+
let index = 0;
|
|
216
|
+
if (Array.isArray(arr)) {
|
|
217
|
+
arr.map((s) => {
|
|
218
|
+
let elem = {};
|
|
219
|
+
if (valueAsID)
|
|
220
|
+
elem[idProperty] = String(s).toLowerCase();
|
|
221
|
+
else
|
|
222
|
+
elem[idProperty] = '_cid_' + index;
|
|
223
|
+
if (typeof s === 'object')
|
|
224
|
+
elem = { ...elem, ...s };
|
|
225
|
+
else
|
|
226
|
+
elem['label'] = s;
|
|
227
|
+
res.push(elem);
|
|
228
|
+
index++;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return res;
|
|
232
|
+
}
|
|
234
233
|
/**
|
|
235
234
|
* Gets name of a column from its column object
|
|
236
235
|
* @param obj
|
|
237
236
|
* @returns
|
|
238
|
-
*/
|
|
239
|
-
function get_col_name(obj) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
*/
|
|
238
|
+
export function get_col_name(obj) {
|
|
239
|
+
if (!obj)
|
|
240
|
+
return '';
|
|
241
|
+
if (typeof obj == 'string')
|
|
242
|
+
return obj;
|
|
243
|
+
if (typeof obj != 'object')
|
|
244
|
+
return '';
|
|
245
|
+
return obj.name || obj.field || obj.key || obj.columnName || '';
|
|
246
|
+
}
|
|
245
247
|
/**
|
|
246
248
|
* Gets header of a column
|
|
247
249
|
* @param obj
|
|
248
250
|
* @returns
|
|
249
|
-
*/
|
|
250
|
-
function get_col_header(obj) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
251
|
+
*/
|
|
252
|
+
export function get_col_header(obj) {
|
|
253
|
+
if (!obj)
|
|
254
|
+
return '';
|
|
255
|
+
if (typeof obj == 'string')
|
|
256
|
+
return obj;
|
|
257
|
+
if (typeof obj != 'object')
|
|
258
|
+
return '';
|
|
259
|
+
return obj.header || obj.title || get_col_name(obj);
|
|
260
|
+
}
|
|
256
261
|
/**
|
|
257
262
|
* Gets name of a column from its column object
|
|
258
263
|
* @param obj
|
|
259
264
|
* @returns
|
|
260
|
-
*/
|
|
261
|
-
function get_row_id(obj) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
*/
|
|
266
|
+
export function get_row_id(obj) {
|
|
267
|
+
if (!obj)
|
|
268
|
+
return '-1';
|
|
269
|
+
if (typeof obj == 'string')
|
|
270
|
+
return obj;
|
|
271
|
+
if (typeof obj != 'object')
|
|
272
|
+
return '-1';
|
|
273
|
+
return obj.__table_id || obj.id || '-1';
|
|
274
|
+
}
|
|
267
275
|
/**
|
|
268
276
|
* Gets default activation key for grid plugin
|
|
269
277
|
* @returns
|
|
270
|
-
*/
|
|
271
|
-
function get_default_key() {
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
//check if two cache objects are the same
|
|
275
|
-
function validateCache(current, old, looseCheck = false) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
*/
|
|
279
|
+
export function get_default_key() {
|
|
280
|
+
return 'ExpiryDate=2999-01-01,Z=1040577552';
|
|
281
|
+
}
|
|
282
|
+
//check if two cache objects are the same
|
|
283
|
+
export function validateCache(current, old, looseCheck = false) {
|
|
284
|
+
if (!old || !object_equals(current, old))
|
|
285
|
+
return false;
|
|
286
|
+
if (looseCheck)
|
|
287
|
+
return true;
|
|
288
|
+
if (current.ds != old.ds)
|
|
289
|
+
return false;
|
|
290
|
+
return true;
|
|
291
|
+
}
|
package/dist/src/index.js
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _DataGrid = _interopRequireWildcard(require("./views/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
|
-
/* -------------------------------------------------------------------------- */
|
|
23
|
-
var _default = _DataGrid.default; // const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
24
|
-
// root.render(<ExampleGrid />);
|
|
25
|
-
exports.default = _default;
|
|
1
|
+
export * from './views/DataGrid';
|
|
2
|
+
import AzGrid from './views/DataGrid';
|
|
3
|
+
/* -------------------------------------------------------------------------- */
|
|
4
|
+
export default AzGrid;
|
|
5
|
+
// const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
6
|
+
// root.render(<ExampleGrid />);
|
|
@@ -5,18 +5,22 @@ import '../themes/base_styles.css';
|
|
|
5
5
|
import '../themes/grid.css';
|
|
6
6
|
import { ConvertableToMenuItem } from '@azrico/controls';
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import { TypeColumn, TypeDataGridProps, TypeDataSource, TypeEditInfo, TypeFilterTypes, TypeFilterValue, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection } from '@inovua/reactdatagrid-community/types';
|
|
8
|
+
import { TypeCellSelection, TypeColumn, TypeDataGridProps, TypeDataSource, TypeEditInfo, TypeFilterTypes, TypeFilterValue, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection } from '@inovua/reactdatagrid-community/types';
|
|
9
9
|
import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
|
|
10
10
|
export type ColumnDefinition = TypeColumn;
|
|
11
11
|
export type CellDefinition = any;
|
|
12
12
|
export type RowDefinition = any;
|
|
13
13
|
export type RowProps = TypeRowProps;
|
|
14
14
|
export type RowSelectionValue = TypeRowSelection;
|
|
15
|
+
export type CellSelectionValue = TypeCellSelection;
|
|
15
16
|
export type DataRowDefinition = any;
|
|
16
17
|
export type FilterTypes = TypeFilterTypes;
|
|
17
18
|
export type FilterValues = TypeFilterValue;
|
|
18
19
|
export type DataSourceDefinition = TypeDataSource;
|
|
19
20
|
export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
|
|
21
|
+
export type OnCellSelectionChangeFunc = (s: {
|
|
22
|
+
[key: string]: boolean;
|
|
23
|
+
}) => void;
|
|
20
24
|
export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
|
|
21
25
|
type loose_column_names = {
|
|
22
26
|
key: string;
|
|
@@ -34,7 +38,7 @@ type customColumnData = {
|
|
|
34
38
|
name: string;
|
|
35
39
|
render: (cell: any, formatterParams: any, onRendered: any) => React.ReactNode | undefined | null;
|
|
36
40
|
};
|
|
37
|
-
type
|
|
41
|
+
export type AzGridOptions = Partial<TypeDataGridProps>;
|
|
38
42
|
export type AzGridProps = {
|
|
39
43
|
dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
40
44
|
details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
@@ -42,7 +46,7 @@ export type AzGridProps = {
|
|
|
42
46
|
details_filter?: FilterValues;
|
|
43
47
|
licenseKey?: string;
|
|
44
48
|
gridRef?: any;
|
|
45
|
-
gridOptions?:
|
|
49
|
+
gridOptions?: AzGridOptions;
|
|
46
50
|
columns?: LooseColumnDefinition[];
|
|
47
51
|
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
48
52
|
editableColumns?: string[];
|
|
@@ -53,8 +57,10 @@ export type AzGridProps = {
|
|
|
53
57
|
highlightedRow?: any;
|
|
54
58
|
RowDetail?: RowDetailsFunc;
|
|
55
59
|
selected?: RowSelectionValue;
|
|
60
|
+
cellSelection?: CellSelectionValue;
|
|
56
61
|
onEditComplete?: (editInfo: TypeEditInfo) => void;
|
|
57
62
|
onSelectionChange?: OnSelectionChangeFunc;
|
|
63
|
+
onCellSelectionChange?: OnCellSelectionChangeFunc;
|
|
58
64
|
onRowClick?: (rowIndex: number, row: any) => void;
|
|
59
65
|
onRowDoubleClick?: (rowIndex: number, row: any) => void;
|
|
60
66
|
onLimitChange?: (v: number) => void;
|