@azrico/reactgrid 1.2.33 → 1.2.35
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/.vscode/launch.json +15 -0
- package/CHANGELOG.md +86 -72
- package/config/config-overrides.js +12 -36
- package/config/tsconfig.base.json +0 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -21
- package/dist/src/example.d.ts +4 -4
- package/dist/src/example.js +112 -155
- package/dist/src/func/func_child.d.ts +29 -29
- package/dist/src/func/func_child.js +70 -73
- package/dist/src/func/func_grid.d.ts +39 -39
- package/dist/src/func/func_grid.js +275 -261
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +10 -60
- package/dist/src/themes/grid.css +13 -0
- package/dist/src/views/DataGrid.d.ts +79 -79
- package/dist/src/views/DataGrid.js +195 -246
- package/dist/src/views/index.d.ts +3 -3
- package/dist/src/views/index.js +3 -23
- package/package.json +2 -2
- package/public/manifest.json +9 -9
- package/src/index.tsx +5 -5
- package/src/themes/grid.css +13 -0
- package/src/views/index.ts +4 -4
|
@@ -1,286 +1,300 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
exports.ApplyColumnData = ApplyColumnData;
|
|
7
|
-
exports.ApplyDataSource = ApplyDataSource;
|
|
8
|
-
exports.get_col_header = get_col_header;
|
|
9
|
-
exports.get_col_name = get_col_name;
|
|
10
|
-
exports.get_default_key = get_default_key;
|
|
11
|
-
exports.get_row_id = get_row_id;
|
|
12
|
-
exports.set_row_id = set_row_id;
|
|
13
|
-
exports.to_datasource = to_datasource;
|
|
14
|
-
exports.validateCache = validateCache;
|
|
15
|
-
var _BoolEditor = _interopRequireDefault(require("@inovua/reactdatagrid-community/BoolEditor"));
|
|
16
|
-
var _NumericEditor = _interopRequireDefault(require("@inovua/reactdatagrid-community/NumericEditor"));
|
|
17
|
-
var _SelectEditor = _interopRequireDefault(require("@inovua/reactdatagrid-community/SelectEditor"));
|
|
18
|
-
var _func_child = require("./func_child");
|
|
19
|
-
var _object = require("@azrico/object");
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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';
|
|
21
6
|
const defaultColumnOptions = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
draggable: false,
|
|
8
|
+
lockable: false,
|
|
9
|
+
editable: false,
|
|
25
10
|
};
|
|
26
|
-
async function ApplyDataSource(datasource, props) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//if the datasource is changed since last render, we should invalidate cache
|
|
36
|
-
if (!validateCache(props.last_cache_info.current, cacheInfo, props.looseCacheCheck)) {
|
|
37
|
-
props.cached_data.current = undefined;
|
|
38
|
-
props.last_cache_info.current = cacheInfo;
|
|
39
|
-
}
|
|
40
|
-
if (props.cached_data.current) {
|
|
41
|
-
//cache is valid, use the cache
|
|
42
|
-
isUsingCache = true;
|
|
43
|
-
result_data = props.cached_data.current;
|
|
44
|
-
} else {
|
|
45
|
-
//cache is invalid, use the datasource again
|
|
46
|
-
isUsingCache = false;
|
|
47
|
-
if (typeof datasource === 'function') {
|
|
48
|
-
result_data = await datasource(props);
|
|
49
|
-
} else result_data = datasource;
|
|
50
|
-
}
|
|
51
|
-
//making sure the datasource is a valid object :
|
|
52
|
-
if (!result_data) result_data = [];
|
|
53
|
-
if (Array.isArray(result_data) || typeof result_data !== 'object') result_data = {
|
|
54
|
-
data: result_data
|
|
55
|
-
};
|
|
56
|
-
if (!Array.isArray(result_data.data)) result_data.data = [result_data.data];
|
|
57
|
-
//no need to fix parent/child when using cache (it should be already fixed)
|
|
58
|
-
if (!isUsingCache && props.allowChildRows) {
|
|
59
|
-
result_data.data = (0, _func_child.fix_parent_child_relations)(result_data.data);
|
|
60
|
-
}
|
|
61
|
-
if (!result_data.count) {
|
|
62
|
-
result_data.count = result_data.data.length;
|
|
63
|
-
}
|
|
64
|
-
//update cache
|
|
65
|
-
props.cached_data.current = result_data;
|
|
66
|
-
return result_data;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* merges together all different props for columns
|
|
70
|
-
* to build a single final column data array
|
|
71
|
-
* @param column_data
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
function ApplyColumnData(column_data) {
|
|
75
|
-
const final_columns = [];
|
|
76
|
-
if (!column_data) column_data = {};
|
|
77
|
-
if (Array.isArray(column_data)) column_data = {
|
|
78
|
-
columns: column_data
|
|
79
|
-
};
|
|
80
|
-
let mcols = column_data.columns || [];
|
|
81
|
-
let mcolExts = column_data.columnExtensions || [];
|
|
82
|
-
let rightColumns = column_data.rightColumns || [];
|
|
83
|
-
let leftColumns = column_data.leftColumns || [];
|
|
84
|
-
let editableColumns = column_data.editableColumns || [];
|
|
85
|
-
let customColumns = column_data.customColumns || [];
|
|
86
|
-
if (!Array.isArray(mcols)) return [];
|
|
87
|
-
/* ------------------------------- fix columns ------------------------------ */
|
|
88
|
-
mcols.map(r => {
|
|
89
|
-
if (r == null) return null;
|
|
90
|
-
if (typeof r === 'string') return {
|
|
91
|
-
field: r,
|
|
92
|
-
header: r
|
|
93
|
-
};
|
|
94
|
-
if (typeof r === 'object') {
|
|
95
|
-
let final_cl = {
|
|
96
|
-
name: get_col_name(r),
|
|
97
|
-
header: get_col_header(r),
|
|
98
|
-
width: r.width || undefined
|
|
99
|
-
};
|
|
100
|
-
final_cl = {
|
|
101
|
-
...defaultColumnOptions,
|
|
102
|
-
...r,
|
|
103
|
-
...final_cl
|
|
104
|
-
};
|
|
105
|
-
return final_cl;
|
|
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;
|
|
106
20
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/* ---------------------------- apply extensions ---------------------------- */
|
|
112
|
-
if (mcolExts && Array.isArray(mcolExts)) for (let index = 0; index < mcolExts.length; index++) {
|
|
113
|
-
const ext = mcolExts[index];
|
|
114
|
-
const ext_cl = get_col_name(ext);
|
|
115
|
-
if (!ext_cl) {
|
|
116
|
-
console.warn('ColumnExtension must have a name');
|
|
117
|
-
continue;
|
|
21
|
+
if (props.cached_data.current) {
|
|
22
|
+
//cache is valid, use the cache
|
|
23
|
+
isUsingCache = true;
|
|
24
|
+
result_data = props.cached_data.current;
|
|
118
25
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
|
|
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;
|
|
124
34
|
}
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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);
|
|
135
45
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
for (let index = 0; index < rightColumns.length; index++) {
|
|
139
|
-
const r = get_col_name(rightColumns[index]);
|
|
140
|
-
const mcol = final_columns.find(s => get_col_name(s) === r);
|
|
141
|
-
if (mcol) {
|
|
142
|
-
mcol.locked = 'end';
|
|
143
|
-
}
|
|
46
|
+
if (!result_data.count) {
|
|
47
|
+
result_data.count = result_data.data.length;
|
|
144
48
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
49
|
+
//update cache
|
|
50
|
+
props.cached_data.current = result_data;
|
|
51
|
+
return result_data;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* merges together all different props for columns
|
|
55
|
+
* to build a single final column data array
|
|
56
|
+
* @param column_data
|
|
57
|
+
* @returns
|
|
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
|
+
}
|
|
154
126
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
col.editor = _SelectEditor.default;
|
|
164
|
-
break;
|
|
165
|
-
case 'number':
|
|
166
|
-
case 'numberic':
|
|
167
|
-
//@ts-ignore
|
|
168
|
-
col.editor = _NumericEditor.default;
|
|
169
|
-
break;
|
|
170
|
-
case 'truefalse':
|
|
171
|
-
case 'bool':
|
|
172
|
-
//@ts-ignore
|
|
173
|
-
col.editor = _BoolEditor.default;
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
if (col.editable != false) col.editable = true;
|
|
177
|
-
delete col.type;
|
|
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
|
+
}
|
|
178
135
|
}
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
delete col.items;
|
|
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
|
+
}
|
|
189
145
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
+
}
|
|
198
170
|
//@ts-ignore
|
|
199
|
-
|
|
200
|
-
|
|
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
|
+
}
|
|
201
184
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
+
}
|
|
212
196
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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;
|
|
217
212
|
}
|
|
218
|
-
function to_datasource(arr, idProperty, valueAsID = true) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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;
|
|
234
232
|
}
|
|
235
|
-
/**
|
|
236
|
-
* Gets name of a column from its column object
|
|
237
|
-
* @param obj
|
|
238
|
-
* @returns
|
|
233
|
+
/**
|
|
234
|
+
* Gets name of a column from its column object
|
|
235
|
+
* @param obj
|
|
236
|
+
* @returns
|
|
239
237
|
*/
|
|
240
|
-
function get_col_name(obj) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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 || '';
|
|
245
246
|
}
|
|
246
|
-
/**
|
|
247
|
-
* Gets header of a column
|
|
248
|
-
* @param obj
|
|
249
|
-
* @returns
|
|
247
|
+
/**
|
|
248
|
+
* Gets header of a column
|
|
249
|
+
* @param obj
|
|
250
|
+
* @returns
|
|
250
251
|
*/
|
|
251
|
-
function get_col_header(obj) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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);
|
|
256
260
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Gets name of a column from its column object
|
|
259
|
-
* @param obj
|
|
260
|
-
* @returns
|
|
261
|
+
/**
|
|
262
|
+
* Gets name of a column from its column object
|
|
263
|
+
* @param obj
|
|
264
|
+
* @returns
|
|
261
265
|
*/
|
|
262
|
-
function get_row_id(obj) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
266
|
+
export function get_row_id(obj) {
|
|
267
|
+
if (!obj)
|
|
268
|
+
return undefined;
|
|
269
|
+
if (typeof obj == 'string')
|
|
270
|
+
return obj;
|
|
271
|
+
if (typeof obj != 'object')
|
|
272
|
+
return undefined;
|
|
273
|
+
return obj.__table_id || obj.id || undefined;
|
|
267
274
|
}
|
|
268
|
-
function set_row_id(obj, val) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
export function set_row_id(obj, val) {
|
|
276
|
+
if (typeof obj != 'object')
|
|
277
|
+
return false;
|
|
278
|
+
if (val === undefined)
|
|
279
|
+
delete obj.__table_id;
|
|
280
|
+
else
|
|
281
|
+
obj.__table_id = val;
|
|
282
|
+
return obj.__table_id;
|
|
272
283
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Gets default activation key for grid plugin
|
|
275
|
-
* @returns
|
|
284
|
+
/**
|
|
285
|
+
* Gets default activation key for grid plugin
|
|
286
|
+
* @returns
|
|
276
287
|
*/
|
|
277
|
-
function get_default_key() {
|
|
278
|
-
|
|
288
|
+
export function get_default_key() {
|
|
289
|
+
return 'ExpiryDate=2999-01-01,Z=1040577552';
|
|
279
290
|
}
|
|
280
291
|
//check if two cache objects are the same
|
|
281
|
-
function validateCache(current, old, looseCheck = false) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
292
|
+
export function validateCache(current, old, looseCheck = false) {
|
|
293
|
+
if (!old || !object_equals(current, old))
|
|
294
|
+
return false;
|
|
295
|
+
if (looseCheck)
|
|
296
|
+
return true;
|
|
297
|
+
if (current.ds != old.ds)
|
|
298
|
+
return false;
|
|
299
|
+
return true;
|
|
300
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './views/DataGrid';
|
|
2
|
-
export { get_row_id, set_row_id, get_col_name, get_col_header } from './func/func_grid';
|
|
3
|
-
import AzGrid from './views/DataGrid';
|
|
4
|
-
export default AzGrid;
|
|
1
|
+
export * from './views/DataGrid';
|
|
2
|
+
export { get_row_id, set_row_id, get_col_name, get_col_header } from './func/func_grid';
|
|
3
|
+
import AzGrid from './views/DataGrid';
|
|
4
|
+
export default AzGrid;
|
package/dist/src/index.js
CHANGED
|
@@ -1,64 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
get_row_id: true,
|
|
8
|
-
set_row_id: true,
|
|
9
|
-
get_col_name: true,
|
|
10
|
-
get_col_header: true
|
|
11
|
-
};
|
|
12
|
-
exports.default = void 0;
|
|
13
|
-
Object.defineProperty(exports, "get_col_header", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _func_grid.get_col_header;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "get_col_name", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _func_grid.get_col_name;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "get_row_id", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _func_grid.get_row_id;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "set_row_id", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _func_grid.set_row_id;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
var _DataGrid = _interopRequireWildcard(require("./views/DataGrid"));
|
|
38
|
-
Object.keys(_DataGrid).forEach(function (key) {
|
|
39
|
-
if (key === "default" || key === "__esModule") return;
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
41
|
-
if (key in exports && exports[key] === _DataGrid[key]) return;
|
|
42
|
-
Object.defineProperty(exports, key, {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _DataGrid[key];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
var _func_grid = require("./func/func_grid");
|
|
50
|
-
var _example = _interopRequireDefault(require("./example"));
|
|
51
|
-
var _react = _interopRequireDefault(require("react"));
|
|
52
|
-
var _client = _interopRequireDefault(require("react-dom/client"));
|
|
53
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
54
|
-
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); }
|
|
55
|
-
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; }
|
|
1
|
+
export * from './views/DataGrid';
|
|
2
|
+
export { get_row_id, set_row_id, get_col_name, get_col_header } from './func/func_grid';
|
|
3
|
+
import AzGrid from './views/DataGrid';
|
|
4
|
+
import ExampleGrid from './example';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom/client';
|
|
56
7
|
/* -------------------------------------------------------------------------- */
|
|
57
8
|
//
|
|
58
|
-
|
|
59
|
-
exports.default = _default;
|
|
9
|
+
export default AzGrid;
|
|
60
10
|
const testroot = document.getElementById('testroot');
|
|
61
11
|
if (testroot) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
12
|
+
const root = ReactDOM.createRoot(document.getElementById('testroot'));
|
|
13
|
+
root.render(React.createElement(ExampleGrid, null));
|
|
14
|
+
}
|
package/dist/src/themes/grid.css
CHANGED
|
@@ -19,3 +19,16 @@
|
|
|
19
19
|
display: flex;
|
|
20
20
|
align-items: center;
|
|
21
21
|
}
|
|
22
|
+
.InovuaReactDataGrid__column-header__content {
|
|
23
|
+
text-overflow: clip;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.InovuaReactDataGrid__row.deleted:after {
|
|
27
|
+
position: absolute;
|
|
28
|
+
content: '';
|
|
29
|
+
left: 5px;
|
|
30
|
+
top: 50%;
|
|
31
|
+
right: 5px;
|
|
32
|
+
border-top: 1.5px solid;
|
|
33
|
+
border-color: gray;
|
|
34
|
+
}
|