realgrid-vue 0.9.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.
- package/README.md +94 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +874 -0
- package/dist/index.es.js +1117 -0
- package/license.txt +3 -0
- package/package.json +32 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1117 @@
|
|
|
1
|
+
import * as RealGrid from "realgrid";
|
|
2
|
+
import { version, toRaw, defineComponent, h } from "vue";
|
|
3
|
+
const isVue2 = () => {
|
|
4
|
+
return version.split(".")[0] === "2";
|
|
5
|
+
};
|
|
6
|
+
const toCustomRaw = (props) => {
|
|
7
|
+
return isVue2() ? props : toRaw(props);
|
|
8
|
+
};
|
|
9
|
+
const camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
|
|
10
|
+
const pascalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
11
|
+
const kebabToCamel = (obj, prefix = "") => {
|
|
12
|
+
const ret = {};
|
|
13
|
+
for (let key in obj) {
|
|
14
|
+
ret[camelize(prefix ? `${prefix}-${key}` : key)] = toRaw(obj[key]);
|
|
15
|
+
}
|
|
16
|
+
return ret;
|
|
17
|
+
};
|
|
18
|
+
const extractDiff = (target, origin = {}, diff = {}) => {
|
|
19
|
+
target = target || {};
|
|
20
|
+
const exceptKey = ["children"];
|
|
21
|
+
for (const [key, value] of Object.entries(origin)) {
|
|
22
|
+
if (exceptKey.includes(key)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (!diff.hasOwnProperty(key)) {
|
|
26
|
+
target[key] = null;
|
|
27
|
+
} else if (Array.isArray(value)) {
|
|
28
|
+
if (!diff[key] || JSON.stringify(value) != JSON.stringify(diff[key])) {
|
|
29
|
+
target[key] = diff[key];
|
|
30
|
+
}
|
|
31
|
+
} else if (value instanceof Object && !(value instanceof Date || Array.isArray(value) || typeof value === "function")) {
|
|
32
|
+
if (!(diff[key] instanceof Object)) {
|
|
33
|
+
target[key] = diff[key];
|
|
34
|
+
} else {
|
|
35
|
+
const dif = extractDiff({}, value, diff[key]);
|
|
36
|
+
if (dif && Object.keys(dif).length > 0) {
|
|
37
|
+
target[key] = dif;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else if (value !== diff[key]) {
|
|
41
|
+
target[key] = diff[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
for (const [key, value] of Object.entries(diff)) {
|
|
45
|
+
if (exceptKey.includes(key)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (!origin.hasOwnProperty(key)) {
|
|
49
|
+
target[key] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
};
|
|
54
|
+
const $_connectEvents = (grid, provider, props) => {
|
|
55
|
+
for (const [key, value] of Object.entries(props)) {
|
|
56
|
+
if (key && typeof value === "function" && key.startsWith("on")) {
|
|
57
|
+
if (key === "onRowInserting") {
|
|
58
|
+
grid.onRowInserting = value;
|
|
59
|
+
} else if (key === "onDataRowInserting") {
|
|
60
|
+
provider.onRowInserting = value;
|
|
61
|
+
} else {
|
|
62
|
+
grid.hasOwnProperty(key) && (grid[key] = value);
|
|
63
|
+
provider.hasOwnProperty(key) && (provider[key] = value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var browser = { exports: {} };
|
|
69
|
+
var process = browser.exports = {};
|
|
70
|
+
var cachedSetTimeout;
|
|
71
|
+
var cachedClearTimeout;
|
|
72
|
+
function defaultSetTimout() {
|
|
73
|
+
throw new Error("setTimeout has not been defined");
|
|
74
|
+
}
|
|
75
|
+
function defaultClearTimeout() {
|
|
76
|
+
throw new Error("clearTimeout has not been defined");
|
|
77
|
+
}
|
|
78
|
+
(function() {
|
|
79
|
+
try {
|
|
80
|
+
if (typeof setTimeout === "function") {
|
|
81
|
+
cachedSetTimeout = setTimeout;
|
|
82
|
+
} else {
|
|
83
|
+
cachedSetTimeout = defaultSetTimout;
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
cachedSetTimeout = defaultSetTimout;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
if (typeof clearTimeout === "function") {
|
|
90
|
+
cachedClearTimeout = clearTimeout;
|
|
91
|
+
} else {
|
|
92
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
function runTimeout(fun) {
|
|
99
|
+
if (cachedSetTimeout === setTimeout) {
|
|
100
|
+
return setTimeout(fun, 0);
|
|
101
|
+
}
|
|
102
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
103
|
+
cachedSetTimeout = setTimeout;
|
|
104
|
+
return setTimeout(fun, 0);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
return cachedSetTimeout(fun, 0);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
try {
|
|
110
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
111
|
+
} catch (e2) {
|
|
112
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function runClearTimeout(marker) {
|
|
117
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
118
|
+
return clearTimeout(marker);
|
|
119
|
+
}
|
|
120
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
121
|
+
cachedClearTimeout = clearTimeout;
|
|
122
|
+
return clearTimeout(marker);
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
return cachedClearTimeout(marker);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
try {
|
|
128
|
+
return cachedClearTimeout.call(null, marker);
|
|
129
|
+
} catch (e2) {
|
|
130
|
+
return cachedClearTimeout.call(this, marker);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
var queue = [];
|
|
135
|
+
var draining = false;
|
|
136
|
+
var currentQueue;
|
|
137
|
+
var queueIndex = -1;
|
|
138
|
+
function cleanUpNextTick() {
|
|
139
|
+
if (!draining || !currentQueue) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
draining = false;
|
|
143
|
+
if (currentQueue.length) {
|
|
144
|
+
queue = currentQueue.concat(queue);
|
|
145
|
+
} else {
|
|
146
|
+
queueIndex = -1;
|
|
147
|
+
}
|
|
148
|
+
if (queue.length) {
|
|
149
|
+
drainQueue();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function drainQueue() {
|
|
153
|
+
if (draining) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
157
|
+
draining = true;
|
|
158
|
+
var len = queue.length;
|
|
159
|
+
while (len) {
|
|
160
|
+
currentQueue = queue;
|
|
161
|
+
queue = [];
|
|
162
|
+
while (++queueIndex < len) {
|
|
163
|
+
if (currentQueue) {
|
|
164
|
+
currentQueue[queueIndex].run();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
queueIndex = -1;
|
|
168
|
+
len = queue.length;
|
|
169
|
+
}
|
|
170
|
+
currentQueue = null;
|
|
171
|
+
draining = false;
|
|
172
|
+
runClearTimeout(timeout);
|
|
173
|
+
}
|
|
174
|
+
process.nextTick = function(fun) {
|
|
175
|
+
var args = new Array(arguments.length - 1);
|
|
176
|
+
if (arguments.length > 1) {
|
|
177
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
178
|
+
args[i - 1] = arguments[i];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
queue.push(new Item(fun, args));
|
|
182
|
+
if (queue.length === 1 && !draining) {
|
|
183
|
+
runTimeout(drainQueue);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function Item(fun, array) {
|
|
187
|
+
this.fun = fun;
|
|
188
|
+
this.array = array;
|
|
189
|
+
}
|
|
190
|
+
Item.prototype.run = function() {
|
|
191
|
+
this.fun.apply(null, this.array);
|
|
192
|
+
};
|
|
193
|
+
process.title = "browser";
|
|
194
|
+
process.browser = true;
|
|
195
|
+
process.env = {};
|
|
196
|
+
process.argv = [];
|
|
197
|
+
process.version = "";
|
|
198
|
+
process.versions = {};
|
|
199
|
+
function noop() {
|
|
200
|
+
}
|
|
201
|
+
process.on = noop;
|
|
202
|
+
process.addListener = noop;
|
|
203
|
+
process.once = noop;
|
|
204
|
+
process.off = noop;
|
|
205
|
+
process.removeListener = noop;
|
|
206
|
+
process.removeAllListeners = noop;
|
|
207
|
+
process.emit = noop;
|
|
208
|
+
process.prependListener = noop;
|
|
209
|
+
process.prependOnceListener = noop;
|
|
210
|
+
process.listeners = function(name) {
|
|
211
|
+
return [];
|
|
212
|
+
};
|
|
213
|
+
process.binding = function(name) {
|
|
214
|
+
throw new Error("process.binding is not supported");
|
|
215
|
+
};
|
|
216
|
+
process.cwd = function() {
|
|
217
|
+
return "/";
|
|
218
|
+
};
|
|
219
|
+
process.chdir = function(dir) {
|
|
220
|
+
throw new Error("process.chdir is not supported");
|
|
221
|
+
};
|
|
222
|
+
process.umask = function() {
|
|
223
|
+
return 0;
|
|
224
|
+
};
|
|
225
|
+
const RealGridBase = () => {
|
|
226
|
+
return defineComponent({
|
|
227
|
+
name: "RealGridBase",
|
|
228
|
+
props: {
|
|
229
|
+
disabled: Boolean,
|
|
230
|
+
gridProps: Object,
|
|
231
|
+
dataProps: Object,
|
|
232
|
+
locale: Object,
|
|
233
|
+
autoGenerateField: Boolean,
|
|
234
|
+
rows: Array,
|
|
235
|
+
rowStyleCallback: Function,
|
|
236
|
+
cellStyleCallback: Function,
|
|
237
|
+
layout: Array,
|
|
238
|
+
onInitialized: Function,
|
|
239
|
+
onDestroy: Function,
|
|
240
|
+
onCurrentChanging: Function,
|
|
241
|
+
onCurrentChanged: Function,
|
|
242
|
+
onCurrentRowChanged: Function,
|
|
243
|
+
onValidateColumn: Function,
|
|
244
|
+
onValidateRow: Function,
|
|
245
|
+
onValidationFail: Function,
|
|
246
|
+
onColumnCheckedChanged: Function,
|
|
247
|
+
onMenuItemClicked: Function,
|
|
248
|
+
onContextMenuPopup: Function,
|
|
249
|
+
onContextMenuItemClicked: Function,
|
|
250
|
+
onCellButtonClicked: Function,
|
|
251
|
+
onScrollToBottom: Function,
|
|
252
|
+
onTopIndexChanged: Function,
|
|
253
|
+
onTopIndexChanging: Function,
|
|
254
|
+
onLeftPosChanged: Function,
|
|
255
|
+
onRowsDeleting: Function,
|
|
256
|
+
onRowInserting: Function,
|
|
257
|
+
onSelectionCleared: Function,
|
|
258
|
+
onSelectionChanged: Function,
|
|
259
|
+
onSelectionAdded: Function,
|
|
260
|
+
onSelectionEnded: Function,
|
|
261
|
+
onShowEditor: Function,
|
|
262
|
+
onShowEditCommand: Function,
|
|
263
|
+
onHideEditor: Function,
|
|
264
|
+
onEditChange: Function,
|
|
265
|
+
onGetEditValue: Function,
|
|
266
|
+
onEditCommit: Function,
|
|
267
|
+
onEditCanceled: Function,
|
|
268
|
+
onItemEditCanceled: Function,
|
|
269
|
+
onItemEditCancel: Function,
|
|
270
|
+
onEditSearch: Function,
|
|
271
|
+
onSearchCellButtonClick: Function,
|
|
272
|
+
onCellEdited: Function,
|
|
273
|
+
onEditRowChanged: Function,
|
|
274
|
+
onEditRowPasted: Function,
|
|
275
|
+
onRowsPasted: Function,
|
|
276
|
+
onCellPasting: Function,
|
|
277
|
+
onItemChecked: Function,
|
|
278
|
+
onItemAllChecked: Function,
|
|
279
|
+
onErrorClicked: Function,
|
|
280
|
+
onSorting: Function,
|
|
281
|
+
onSortingChanged: Function,
|
|
282
|
+
onFiltering: Function,
|
|
283
|
+
onFilteringChanged: Function,
|
|
284
|
+
onWheel: Function,
|
|
285
|
+
onKeyDown: Function,
|
|
286
|
+
onKeyPress: Function,
|
|
287
|
+
onKeyUp: Function,
|
|
288
|
+
onShowTooltip: Function,
|
|
289
|
+
onShowHeaderTooltip: Function,
|
|
290
|
+
onColumnPropertyChanged: Function,
|
|
291
|
+
onLayoutPropertyChanged: Function,
|
|
292
|
+
onGridActivated: Function,
|
|
293
|
+
onCopy: Function,
|
|
294
|
+
onPaste: Function,
|
|
295
|
+
onPasted: Function,
|
|
296
|
+
onItemsChecked: Function,
|
|
297
|
+
onCellClicked: Function,
|
|
298
|
+
onCellDblClicked: Function,
|
|
299
|
+
onCellItemClicked: Function,
|
|
300
|
+
onCommandStackChanged: Function,
|
|
301
|
+
onDataLoadComplated: Function,
|
|
302
|
+
onLayoutExpanding: Function,
|
|
303
|
+
onLayoutExpanded: Function,
|
|
304
|
+
onLayoutCollapsing: Function,
|
|
305
|
+
onLayoutCollapsed: Function
|
|
306
|
+
},
|
|
307
|
+
data() {
|
|
308
|
+
return {
|
|
309
|
+
$dataProvider: null,
|
|
310
|
+
$gridView: null,
|
|
311
|
+
_mountTimer: null,
|
|
312
|
+
_mountCBs: []
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
mounted() {
|
|
316
|
+
const container = this.$el;
|
|
317
|
+
const props = kebabToCamel(toCustomRaw(this.$props));
|
|
318
|
+
if (this.$listeners) {
|
|
319
|
+
for (const [key, value] of Object.entries(this.$listeners)) {
|
|
320
|
+
if (key && typeof value === "function") {
|
|
321
|
+
if (key === "row-inserting") {
|
|
322
|
+
props.onRowInserting = value;
|
|
323
|
+
} else if (key === "data-row-inserting") {
|
|
324
|
+
props.onDataRowInserting = value;
|
|
325
|
+
} else {
|
|
326
|
+
const eventName = "on" + pascalize(camelize(key));
|
|
327
|
+
props.hasOwnProperty(eventName) && (props[eventName] = value);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const { grid, dataProvider } = this._createGrid(container, props);
|
|
333
|
+
this.dataProvider = dataProvider;
|
|
334
|
+
this.gridView = grid;
|
|
335
|
+
this.executeCB();
|
|
336
|
+
$_connectEvents(grid, dataProvider, props);
|
|
337
|
+
this._applyOptions(props);
|
|
338
|
+
if (props.layout) {
|
|
339
|
+
grid.setColumnLayout(props.layout);
|
|
340
|
+
}
|
|
341
|
+
this._doInitProc(grid, props);
|
|
342
|
+
},
|
|
343
|
+
computed: {
|
|
344
|
+
dataProvider: {
|
|
345
|
+
get() {
|
|
346
|
+
return toCustomRaw(this.$data.$dataProvider);
|
|
347
|
+
},
|
|
348
|
+
set(value) {
|
|
349
|
+
this.$dataProvider = value;
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
gridView: {
|
|
353
|
+
get() {
|
|
354
|
+
return toCustomRaw(this.$data.$gridView);
|
|
355
|
+
},
|
|
356
|
+
set(value) {
|
|
357
|
+
this.$gridView = value;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
unmounted() {
|
|
362
|
+
const props = kebabToCamel(this.$props);
|
|
363
|
+
const listener = kebabToCamel(this.$attrs, "on");
|
|
364
|
+
const destroyProc = props.onDestroy || listener.onDestroy;
|
|
365
|
+
destroyProc && destroyProc(this.gridView);
|
|
366
|
+
this.gridView = this.gridView && this.gridView.destroy();
|
|
367
|
+
this.dataProvider = this.dataProvider && this.dataProvider.destroy();
|
|
368
|
+
},
|
|
369
|
+
destroyed() {
|
|
370
|
+
const props = kebabToCamel(this.$props);
|
|
371
|
+
const listener = kebabToCamel(this.$attrs, "on");
|
|
372
|
+
const destroyProc = props.onDestroy || listener.onDestroy;
|
|
373
|
+
destroyProc && destroyProc(this.gridView);
|
|
374
|
+
this.gridView = this.gridView && this.gridView.destroy();
|
|
375
|
+
this.dataProvider = this.dataProvider && this.dataProvider.destroy();
|
|
376
|
+
},
|
|
377
|
+
watch: {
|
|
378
|
+
gridProps: {
|
|
379
|
+
handler(val, oldVal) {
|
|
380
|
+
const diff = extractDiff({}, oldVal, val);
|
|
381
|
+
if (this.gridView && diff && Object.keys(diff).length > 0) {
|
|
382
|
+
this.gridView.setOptions(diff);
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
deep: true
|
|
386
|
+
},
|
|
387
|
+
disabled(val, oldVal) {
|
|
388
|
+
this.gridView && (this.gridView.disabled = val);
|
|
389
|
+
},
|
|
390
|
+
dataProps: {
|
|
391
|
+
handler(val, oldVal) {
|
|
392
|
+
const diff = extractDiff({}, oldVal, val);
|
|
393
|
+
if (this.dataProvider && diff && Object.keys(diff).length > 0) {
|
|
394
|
+
this.dataProvider.setOptions(diff);
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
deep: true
|
|
398
|
+
},
|
|
399
|
+
locale: {
|
|
400
|
+
handler(val, oldVal) {
|
|
401
|
+
val && RealGrid.default.setLocale(val);
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
layout: {
|
|
405
|
+
handler(val, oldVal) {
|
|
406
|
+
this.gridView && this.gridView.setColumnLayout(val);
|
|
407
|
+
},
|
|
408
|
+
deep: true
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
methods: {
|
|
412
|
+
addCallback(fn) {
|
|
413
|
+
this.$data._mountCBs.push(fn);
|
|
414
|
+
clearTimeout(this.$data._mountTimer);
|
|
415
|
+
const self = this;
|
|
416
|
+
this.$data._mountTimer = window.setTimeout(function() {
|
|
417
|
+
self.executeCB();
|
|
418
|
+
}, 20);
|
|
419
|
+
},
|
|
420
|
+
removeCallback(fn) {
|
|
421
|
+
if (this.$data._mountCBs.indexOf(fn) >= 0) {
|
|
422
|
+
const idx = this.$data._mountCBs.indexOf(fn);
|
|
423
|
+
this.$data._mountCBs.splice(idx, 1);
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
executeCB() {
|
|
427
|
+
const gridView = isVue2() ? this.$gridView : this.gridView;
|
|
428
|
+
const dataProvider = isVue2() ? this.$dataProvider : this.dataProvider;
|
|
429
|
+
if (!gridView) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
clearTimeout(this._mountTimer);
|
|
433
|
+
if (gridView && gridView["_view"]) {
|
|
434
|
+
gridView.beginUpdate();
|
|
435
|
+
try {
|
|
436
|
+
dataProvider == null ? void 0 : dataProvider.beginUpdate();
|
|
437
|
+
try {
|
|
438
|
+
const cbs = this.$data._mountCBs.sort((v1, v2) => {
|
|
439
|
+
return (v1.$mountSeq == null ? -1 : v1.$mountSeq) - (v2.$mountSeq == null ? -1 : v2.$mountSeq);
|
|
440
|
+
});
|
|
441
|
+
while (cbs && cbs.length) {
|
|
442
|
+
const f = cbs.shift();
|
|
443
|
+
f == null ? void 0 : f.call(this, gridView);
|
|
444
|
+
}
|
|
445
|
+
} finally {
|
|
446
|
+
dataProvider == null ? void 0 : dataProvider.endUpdate();
|
|
447
|
+
}
|
|
448
|
+
} finally {
|
|
449
|
+
gridView.endUpdate(true);
|
|
450
|
+
this.$data._mountTimer = null;
|
|
451
|
+
this.$data._mountCBs = [];
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
_applyOptions(options) {
|
|
456
|
+
const grid = isVue2() ? this.$gridView : this.gridView;
|
|
457
|
+
const dataProvider = isVue2() ? this.$dataProvider : this.dataProvider;
|
|
458
|
+
if (grid) {
|
|
459
|
+
for (let [key, value] of Object.entries(options)) {
|
|
460
|
+
switch (key) {
|
|
461
|
+
case "gridProps":
|
|
462
|
+
value && grid.setOptions(value);
|
|
463
|
+
break;
|
|
464
|
+
case "disabled":
|
|
465
|
+
grid && (grid.disabled = !!value);
|
|
466
|
+
break;
|
|
467
|
+
case "dataProps":
|
|
468
|
+
value && (dataProvider == null ? void 0 : dataProvider.setOptions(value));
|
|
469
|
+
break;
|
|
470
|
+
case "layout":
|
|
471
|
+
value && grid && grid.setColumnLayout(value);
|
|
472
|
+
break;
|
|
473
|
+
case "rowStyleCallback":
|
|
474
|
+
grid.setRowStyleCallback(value);
|
|
475
|
+
break;
|
|
476
|
+
case "cellStyleCallback":
|
|
477
|
+
grid.setCellStyleCallback(value);
|
|
478
|
+
break;
|
|
479
|
+
case "locale":
|
|
480
|
+
value && RealGrid.default.setLocale(value);
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
this._doApplyOptions(options);
|
|
486
|
+
},
|
|
487
|
+
_createGrid(container, props) {
|
|
488
|
+
return {
|
|
489
|
+
grid: null,
|
|
490
|
+
dataProvider: null
|
|
491
|
+
};
|
|
492
|
+
},
|
|
493
|
+
_doInitProc(grid, props) {
|
|
494
|
+
const initProc = props.onInitialized;
|
|
495
|
+
if (initProc) {
|
|
496
|
+
const fType = initProc.constructor.name;
|
|
497
|
+
if (fType === "Function") {
|
|
498
|
+
initProc(grid);
|
|
499
|
+
} else if (fType === "AsyncFunction") {
|
|
500
|
+
Promise.resolve(initProc(grid));
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
_doApplyOptions(options) {
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
render() {
|
|
508
|
+
var _a, _b;
|
|
509
|
+
const parseChild = (vNodes) => {
|
|
510
|
+
const child = [];
|
|
511
|
+
if (Array.isArray(vNodes)) {
|
|
512
|
+
for (let vNode of vNodes) {
|
|
513
|
+
if (Array.isArray(vNode.children)) {
|
|
514
|
+
child.push(...parseChild(vNode.children));
|
|
515
|
+
} else {
|
|
516
|
+
child.push(vNode);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return child;
|
|
521
|
+
};
|
|
522
|
+
const children = [];
|
|
523
|
+
for (let key of Object.keys(this.$slots)) {
|
|
524
|
+
let vNodes = this.$slots[key];
|
|
525
|
+
if (typeof vNodes === "function") {
|
|
526
|
+
vNodes = vNodes();
|
|
527
|
+
}
|
|
528
|
+
children.push(...parseChild(vNodes));
|
|
529
|
+
}
|
|
530
|
+
let displayIndex = 0;
|
|
531
|
+
for (let i = 0; i < children.length; i++) {
|
|
532
|
+
const child = children[i];
|
|
533
|
+
if (child.type instanceof Object && child.type.hasOwnProperty("name")) {
|
|
534
|
+
const name = child.type.name;
|
|
535
|
+
if (name && /^RG.+Column$/.exec(name)) {
|
|
536
|
+
child.props = child.props || {};
|
|
537
|
+
child.props && ((_b = (_a = child.props).displayIndex) != null ? _b : _a.displayIndex = displayIndex++);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
child.$mountSeq = i;
|
|
541
|
+
}
|
|
542
|
+
const style = this.$attrs.style ? this.$attrs.style : { width: "100%", height: "100%" };
|
|
543
|
+
const node = h("div", { style }, children);
|
|
544
|
+
return node;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
const RealGridVue = defineComponent({
|
|
549
|
+
name: "RealGridVue",
|
|
550
|
+
extends: RealGridBase(),
|
|
551
|
+
props: {
|
|
552
|
+
accessibility: Boolean,
|
|
553
|
+
waiOptions: Object,
|
|
554
|
+
onPageChanging: Function,
|
|
555
|
+
onPageChanged: Function,
|
|
556
|
+
onPageCountChanged: Function,
|
|
557
|
+
onGrouping: Function,
|
|
558
|
+
onGrouped: Function,
|
|
559
|
+
onExpanding: Function,
|
|
560
|
+
onExpanded: Function,
|
|
561
|
+
onCollapsing: Function,
|
|
562
|
+
onCollapsed: Function,
|
|
563
|
+
onRowCountChanged: Function,
|
|
564
|
+
onRowUpdating: Function,
|
|
565
|
+
onRowUpdated: Function,
|
|
566
|
+
onRowsUpdated: Function,
|
|
567
|
+
onRowListUpdated: Function,
|
|
568
|
+
onDataRowInserting: Function,
|
|
569
|
+
onRowInserted: Function,
|
|
570
|
+
onRowsInserted: Function,
|
|
571
|
+
onRowDeleting: Function,
|
|
572
|
+
onRowDeleted: Function,
|
|
573
|
+
onRowsDeleted: Function,
|
|
574
|
+
onRowMoving: Function,
|
|
575
|
+
onRowMoved: Function,
|
|
576
|
+
onRowsMoving: Function,
|
|
577
|
+
onRowsMoved: Function,
|
|
578
|
+
onRowListMoving: Function,
|
|
579
|
+
onRowListMoved: Function,
|
|
580
|
+
onValueChanged: Function,
|
|
581
|
+
onDataChanged: Function,
|
|
582
|
+
onRowStateChanged: Function,
|
|
583
|
+
onRowStatesChanged: Function,
|
|
584
|
+
onRowStatesCleared: Function,
|
|
585
|
+
onRestoreRows: Function
|
|
586
|
+
},
|
|
587
|
+
data() {
|
|
588
|
+
return {
|
|
589
|
+
$dataProvider: null,
|
|
590
|
+
$gridView: null
|
|
591
|
+
};
|
|
592
|
+
},
|
|
593
|
+
watch: {
|
|
594
|
+
rows: {
|
|
595
|
+
handler(val, oldVal) {
|
|
596
|
+
var _a;
|
|
597
|
+
if (this.$data._mountTimer != null) {
|
|
598
|
+
const callback = () => {
|
|
599
|
+
browser.exports.nextTick(() => {
|
|
600
|
+
var _a2;
|
|
601
|
+
(_a2 = this.dataProvider) == null ? void 0 : _a2.setRows(toCustomRaw(val));
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
callback.$mountSeq = Infinity;
|
|
605
|
+
this.addCallback(callback);
|
|
606
|
+
} else {
|
|
607
|
+
(_a = this.dataProvider) == null ? void 0 : _a.setRows(toCustomRaw(val));
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
methods: {
|
|
613
|
+
_createGrid(container, props) {
|
|
614
|
+
var _a;
|
|
615
|
+
const grid = new RealGrid.default.GridView(container, props == null ? void 0 : props.accessibility, props == null ? void 0 : props.waiOptions);
|
|
616
|
+
const dataProvider = new RealGrid.default.LocalDataProvider((_a = props.dataProps) == null ? void 0 : _a.undoable);
|
|
617
|
+
grid.setDataSource(dataProvider);
|
|
618
|
+
return {
|
|
619
|
+
grid,
|
|
620
|
+
dataProvider
|
|
621
|
+
};
|
|
622
|
+
},
|
|
623
|
+
_doApplyOptions(options) {
|
|
624
|
+
for (const [key, value] of Object.entries(options)) {
|
|
625
|
+
switch (key) {
|
|
626
|
+
case "rows":
|
|
627
|
+
const dataProvider = isVue2() ? this.$dataProvider : this.dataProvider;
|
|
628
|
+
dataProvider == null ? void 0 : dataProvider.setRows(toCustomRaw(value));
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
const RealTreeVue = defineComponent({
|
|
636
|
+
name: "RealTreeVue",
|
|
637
|
+
extends: RealGridBase(),
|
|
638
|
+
props: {
|
|
639
|
+
treeOptions: Object,
|
|
640
|
+
treeField: String,
|
|
641
|
+
needSorting: Boolean,
|
|
642
|
+
childrenField: String,
|
|
643
|
+
iconField: String,
|
|
644
|
+
json: Object,
|
|
645
|
+
rowsProp: String,
|
|
646
|
+
childrenProp: String,
|
|
647
|
+
iconProp: String,
|
|
648
|
+
onTreeItemExpanding: Function,
|
|
649
|
+
onTreeItemExpanded: Function,
|
|
650
|
+
onTreeItemCollapsing: Function,
|
|
651
|
+
onTreeItemCollapsed: Function,
|
|
652
|
+
onTreeItemChanged: Function,
|
|
653
|
+
onRowCountChanged: Function,
|
|
654
|
+
onRowAdding: Function,
|
|
655
|
+
onRowAdded: Function,
|
|
656
|
+
onRowsAdded: Function,
|
|
657
|
+
onRowDeleting: Function,
|
|
658
|
+
onRowDeleted: Function,
|
|
659
|
+
onRowsDeleted: Function,
|
|
660
|
+
onRowUpdating: Function,
|
|
661
|
+
onRowUpdated: Function,
|
|
662
|
+
onRowsUpdating: Function,
|
|
663
|
+
onRowsUpdated: Function,
|
|
664
|
+
onValueChanged: Function,
|
|
665
|
+
onDataChanged: Function,
|
|
666
|
+
onRowStateChanged: Function,
|
|
667
|
+
onRowStatesChanged: Function,
|
|
668
|
+
onRowSiblingMoving: Function,
|
|
669
|
+
onRowSiblingMoved: Function,
|
|
670
|
+
onRowsSiblingMoving: Function,
|
|
671
|
+
onRowsSiblingMoved: Function,
|
|
672
|
+
onRowParentChanging: Function,
|
|
673
|
+
onRowParentChanged: Function
|
|
674
|
+
},
|
|
675
|
+
data() {
|
|
676
|
+
return {
|
|
677
|
+
$gridView: null,
|
|
678
|
+
$dataProvider: null
|
|
679
|
+
};
|
|
680
|
+
},
|
|
681
|
+
computed: {
|
|
682
|
+
gridView: {
|
|
683
|
+
get() {
|
|
684
|
+
return toCustomRaw(this.$data.$gridView);
|
|
685
|
+
},
|
|
686
|
+
set(value) {
|
|
687
|
+
this.$gridView = value;
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
dataProvider: {
|
|
691
|
+
get() {
|
|
692
|
+
return toCustomRaw(this.$data.$dataProvider);
|
|
693
|
+
},
|
|
694
|
+
set(value) {
|
|
695
|
+
this.$dataProvider = value;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
methods: {
|
|
700
|
+
_createGrid(container, props) {
|
|
701
|
+
var _a;
|
|
702
|
+
const grid = new RealGrid.TreeView(container);
|
|
703
|
+
const dataProvider = new RealGrid.LocalTreeDataProvider((_a = props.dataProps) == null ? void 0 : _a.undoable);
|
|
704
|
+
grid.setDataSource(dataProvider);
|
|
705
|
+
return {
|
|
706
|
+
grid,
|
|
707
|
+
dataProvider
|
|
708
|
+
};
|
|
709
|
+
},
|
|
710
|
+
_doApplyOptions(options) {
|
|
711
|
+
var _a, _b, _c;
|
|
712
|
+
for (const [key, value] of Object.entries(options)) {
|
|
713
|
+
switch (key) {
|
|
714
|
+
case "treeOptions":
|
|
715
|
+
value && ((_a = this.gridView) == null ? void 0 : _a.setTreeOptions(toCustomRaw(value)));
|
|
716
|
+
break;
|
|
717
|
+
case "rows":
|
|
718
|
+
(_b = this.dataProvider) == null ? void 0 : _b.setRows(toCustomRaw(value), this.treeField, this.needSorting, this.childrenField, this.iconField);
|
|
719
|
+
break;
|
|
720
|
+
case "json":
|
|
721
|
+
(_c = this.dataProvider) == null ? void 0 : _c.setObjectRows(toCustomRaw(value), this.rowsProp, this.childrenProp, this.iconProp);
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
watch: {
|
|
728
|
+
rows: {
|
|
729
|
+
handler(val, oldVal) {
|
|
730
|
+
var _a;
|
|
731
|
+
if (this.$data._mountTimer != null) {
|
|
732
|
+
const callback = () => {
|
|
733
|
+
browser.exports.nextTick(() => {
|
|
734
|
+
var _a2;
|
|
735
|
+
(_a2 = this.dataProvider) == null ? void 0 : _a2.setRows(toCustomRaw(val), this.treeField, this.needSorting, this.childrenField, this.iconField);
|
|
736
|
+
});
|
|
737
|
+
};
|
|
738
|
+
callback.$mountSeq = Infinity;
|
|
739
|
+
this.addCallback(callback);
|
|
740
|
+
} else {
|
|
741
|
+
(_a = this.dataProvider) == null ? void 0 : _a.setRows(toCustomRaw(val), this.treeField, this.needSorting, this.childrenField, this.iconField);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
json: {
|
|
746
|
+
handler(val, oldVal) {
|
|
747
|
+
var _a;
|
|
748
|
+
if (this.$data._mountTimer != null) {
|
|
749
|
+
const callback = () => {
|
|
750
|
+
browser.exports.nextTick(() => {
|
|
751
|
+
var _a2;
|
|
752
|
+
(_a2 = this.dataProvider) == null ? void 0 : _a2.setObjectRows(toCustomRaw(val), this.rowsProp, this.childrenProp, this.iconProp);
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
callback.$mountSeq = Infinity;
|
|
756
|
+
this.addCallback(callback);
|
|
757
|
+
} else {
|
|
758
|
+
(_a = this.dataProvider) == null ? void 0 : _a.setObjectRows(toCustomRaw(val), this.rowsProp, this.childrenProp, this.iconProp);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
const ComponentBase = defineComponent({
|
|
765
|
+
name: "ComponentBase",
|
|
766
|
+
props: {},
|
|
767
|
+
data() {
|
|
768
|
+
return {
|
|
769
|
+
$model: null,
|
|
770
|
+
$oldValue: null
|
|
771
|
+
};
|
|
772
|
+
},
|
|
773
|
+
mounted() {
|
|
774
|
+
const p = toCustomRaw(this.$parent);
|
|
775
|
+
if (p) {
|
|
776
|
+
this.$oldValue = kebabToCamel(toCustomRaw(this.$attrs));
|
|
777
|
+
this.mountCB.$mountSeq = isVue2() ? this._vnode.$mountSeq : this.$.vnode.$mountSeq;
|
|
778
|
+
p.addCallback(this.mountCB);
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
unmounted() {
|
|
782
|
+
const p = this.$parent;
|
|
783
|
+
if (p) {
|
|
784
|
+
p.removeCallback(this.mountCB);
|
|
785
|
+
p.addCallback(this.unmountCB);
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
destroyed() {
|
|
789
|
+
const p = this.$parent;
|
|
790
|
+
if (p) {
|
|
791
|
+
p.removeCallback(this.mountCB);
|
|
792
|
+
p.addCallback(this.unmountCB);
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
watch: {
|
|
796
|
+
$attrs: {
|
|
797
|
+
handler(val, oldVal) {
|
|
798
|
+
var _a;
|
|
799
|
+
const value = kebabToCamel(toCustomRaw(val));
|
|
800
|
+
const diff = extractDiff({}, kebabToCamel(toCustomRaw(this.$data.$oldValue)), kebabToCamel(toCustomRaw(val)));
|
|
801
|
+
if (diff && Object.keys(diff).length > 0) {
|
|
802
|
+
const model = toCustomRaw((_a = this.$data) == null ? void 0 : _a.$model);
|
|
803
|
+
model && model.assignFrom(value);
|
|
804
|
+
this._doWatchAttrs(diff);
|
|
805
|
+
this.$oldValue = value;
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
deep: true
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
methods: {
|
|
812
|
+
mountCB() {
|
|
813
|
+
},
|
|
814
|
+
unmountCB() {
|
|
815
|
+
},
|
|
816
|
+
_doWatchAttrs(diff) {
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
render() {
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
const RGSeriesColumn = defineComponent({
|
|
823
|
+
name: "RGSeriesColumn",
|
|
824
|
+
extends: ComponentBase,
|
|
825
|
+
data() {
|
|
826
|
+
return {};
|
|
827
|
+
},
|
|
828
|
+
props: {},
|
|
829
|
+
methods: {
|
|
830
|
+
mountCB(grid) {
|
|
831
|
+
var _a, _b;
|
|
832
|
+
const pAttrs = kebabToCamel(toRaw((_a = this.$parent) == null ? void 0 : _a.$attrs));
|
|
833
|
+
if (pAttrs) {
|
|
834
|
+
const props = kebabToCamel(toRaw(this.$attrs));
|
|
835
|
+
if (grid) {
|
|
836
|
+
this.$model = grid.addColumn({ ...props, type: "series" }, (_b = props.displayIndex) != null ? _b : -1);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
},
|
|
840
|
+
unmountCB(grid) {
|
|
841
|
+
if (this.$data.$model) {
|
|
842
|
+
grid.removeColumn(this.$model.name);
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
_doWatchAttrs(diff) {
|
|
846
|
+
if (diff.hasOwnProperty("width") && !isNaN(diff["width"])) {
|
|
847
|
+
const column = toRaw(this.$data.$model);
|
|
848
|
+
const layout = column.layout;
|
|
849
|
+
if (layout) {
|
|
850
|
+
layout.cellWidth = diff.width;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
const RGStateBar = defineComponent({
|
|
857
|
+
name: "RGStateBar",
|
|
858
|
+
extends: ComponentBase,
|
|
859
|
+
props: {},
|
|
860
|
+
data() {
|
|
861
|
+
return {};
|
|
862
|
+
},
|
|
863
|
+
methods: {
|
|
864
|
+
mountCB(grid) {
|
|
865
|
+
grid.setStateBar(kebabToCamel(toRaw(this.$attrs)));
|
|
866
|
+
this.$model = grid.stateBar;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
const RGRowIndicator = defineComponent({
|
|
871
|
+
name: "RGRowIndicator",
|
|
872
|
+
extends: ComponentBase,
|
|
873
|
+
props: {},
|
|
874
|
+
data() {
|
|
875
|
+
return {};
|
|
876
|
+
},
|
|
877
|
+
methods: {
|
|
878
|
+
mountCB(grid) {
|
|
879
|
+
grid.setRowIndicator(kebabToCamel(toRaw(this.$attrs)));
|
|
880
|
+
this.$model = grid.rowIndicator;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
const RGHeaderSummaries = defineComponent({
|
|
885
|
+
name: "RGHeaderSummaries",
|
|
886
|
+
extends: ComponentBase,
|
|
887
|
+
props: {},
|
|
888
|
+
data() {
|
|
889
|
+
return {};
|
|
890
|
+
},
|
|
891
|
+
methods: {
|
|
892
|
+
mountCB(grid) {
|
|
893
|
+
grid.setHeaderSummaries(kebabToCamel(toRaw(this.$attrs)));
|
|
894
|
+
this.$model = grid.headerSummaries;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
const RGHeaderSummary = defineComponent({
|
|
899
|
+
name: "RGHeaderSummary",
|
|
900
|
+
extends: ComponentBase,
|
|
901
|
+
props: {},
|
|
902
|
+
data() {
|
|
903
|
+
return {};
|
|
904
|
+
},
|
|
905
|
+
methods: {
|
|
906
|
+
mountCB(grid) {
|
|
907
|
+
grid.setHeaderSummary(kebabToCamel(toRaw(this.$attrs)));
|
|
908
|
+
this.$model = grid.headerSummary;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
const RGHeader = defineComponent({
|
|
913
|
+
name: "RGHeader",
|
|
914
|
+
extends: ComponentBase,
|
|
915
|
+
props: {},
|
|
916
|
+
data() {
|
|
917
|
+
return {};
|
|
918
|
+
},
|
|
919
|
+
methods: {
|
|
920
|
+
mountCB(grid) {
|
|
921
|
+
grid.setHeader(kebabToCamel(toRaw(this.$attrs)));
|
|
922
|
+
this.$model = grid.header;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
const RGGroupPanel = defineComponent({
|
|
927
|
+
name: "RGGroupPanel",
|
|
928
|
+
extends: ComponentBase,
|
|
929
|
+
props: {},
|
|
930
|
+
data() {
|
|
931
|
+
return {};
|
|
932
|
+
},
|
|
933
|
+
methods: {
|
|
934
|
+
mountCB(grid) {
|
|
935
|
+
grid.setGroupPanel(kebabToCamel(toRaw(this.$attrs)));
|
|
936
|
+
this.$model = grid.groupPanel;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
const RGFooter = defineComponent({
|
|
941
|
+
name: "RGFooter",
|
|
942
|
+
extends: ComponentBase,
|
|
943
|
+
props: {},
|
|
944
|
+
data() {
|
|
945
|
+
return {};
|
|
946
|
+
},
|
|
947
|
+
methods: {
|
|
948
|
+
mountCB(grid) {
|
|
949
|
+
grid.setFooter(kebabToCamel(toRaw(this.$attrs)));
|
|
950
|
+
this.$model = grid.footer;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
const RGFooters = defineComponent({
|
|
955
|
+
name: "RGFooters",
|
|
956
|
+
extends: ComponentBase,
|
|
957
|
+
props: {},
|
|
958
|
+
data() {
|
|
959
|
+
return {};
|
|
960
|
+
},
|
|
961
|
+
methods: {
|
|
962
|
+
mountCB(grid) {
|
|
963
|
+
grid.setFooters(kebabToCamel(toRaw(this.$attrs)));
|
|
964
|
+
this.$model = grid.footer;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
const RGFilterPanel = defineComponent({
|
|
969
|
+
name: "RGFilterPanel",
|
|
970
|
+
extends: ComponentBase,
|
|
971
|
+
props: {},
|
|
972
|
+
data() {
|
|
973
|
+
return {};
|
|
974
|
+
},
|
|
975
|
+
methods: {
|
|
976
|
+
mountCB(grid) {
|
|
977
|
+
grid.setFilterPanel(kebabToCamel(toRaw(this.$attrs)));
|
|
978
|
+
this.$model = grid.filterPanel;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
const RGDataField = defineComponent({
|
|
983
|
+
name: "RGDataField",
|
|
984
|
+
extends: ComponentBase,
|
|
985
|
+
props: {},
|
|
986
|
+
data() {
|
|
987
|
+
return {};
|
|
988
|
+
},
|
|
989
|
+
methods: {
|
|
990
|
+
mountCB(grid) {
|
|
991
|
+
const attrs = kebabToCamel(toRaw(this.$attrs));
|
|
992
|
+
if (attrs.fieldName) {
|
|
993
|
+
const dp = grid.getDataSource();
|
|
994
|
+
const field = dp.fieldByName(attrs.fieldName);
|
|
995
|
+
if (!field) {
|
|
996
|
+
this.$model = dp.addField(attrs, true);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
unmountDB(grid) {
|
|
1001
|
+
if (this.$model) {
|
|
1002
|
+
const dp = grid.getDataSource();
|
|
1003
|
+
dp.removeField(this.$model);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
const RGDataColumn = defineComponent({
|
|
1009
|
+
name: "RGDataColumn",
|
|
1010
|
+
extends: ComponentBase,
|
|
1011
|
+
data() {
|
|
1012
|
+
return {};
|
|
1013
|
+
},
|
|
1014
|
+
props: {},
|
|
1015
|
+
methods: {
|
|
1016
|
+
mountCB(grid) {
|
|
1017
|
+
var _a, _b;
|
|
1018
|
+
const pAttrs = kebabToCamel(toRaw((_a = this.$parent) == null ? void 0 : _a.$props));
|
|
1019
|
+
if (pAttrs) {
|
|
1020
|
+
const generateField = pAttrs.autoGenerateField;
|
|
1021
|
+
const dp = grid == null ? void 0 : grid.getDataSource();
|
|
1022
|
+
const props = kebabToCamel(toRaw(this.$attrs));
|
|
1023
|
+
let fieldName = props.fieldName;
|
|
1024
|
+
if (generateField) {
|
|
1025
|
+
if (!fieldName && props.field) {
|
|
1026
|
+
fieldName = props.field.fieldName;
|
|
1027
|
+
}
|
|
1028
|
+
if (dp && !dp.fieldByName(fieldName)) {
|
|
1029
|
+
dp.addField(props.field || fieldName);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
if (grid) {
|
|
1033
|
+
this.$model = grid.addColumn({ ...props, ...{ fieldName } }, (_b = props.displayIndex) != null ? _b : -1);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
unmountCB(grid) {
|
|
1038
|
+
var _a;
|
|
1039
|
+
if (this.$data.$model) {
|
|
1040
|
+
grid.removeColumn(this.$data.$model.name);
|
|
1041
|
+
}
|
|
1042
|
+
const pAttrs = kebabToCamel(toRaw((_a = this.$parent) == null ? void 0 : _a.$props));
|
|
1043
|
+
if (pAttrs) {
|
|
1044
|
+
const generateField = pAttrs.autoGenerateField;
|
|
1045
|
+
const dp = grid == null ? void 0 : grid.getDataSource();
|
|
1046
|
+
const props = kebabToCamel(toRaw(this.$attrs));
|
|
1047
|
+
let fieldName = props.fieldName;
|
|
1048
|
+
if (generateField) {
|
|
1049
|
+
if (!fieldName && props.field) {
|
|
1050
|
+
fieldName = props.field.fieldName;
|
|
1051
|
+
}
|
|
1052
|
+
if (!grid.columnByField(fieldName)) {
|
|
1053
|
+
dp.removeField(fieldName);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
_doWatchAttrs(diff) {
|
|
1059
|
+
if (diff.hasOwnProperty("width") && !isNaN(diff["width"])) {
|
|
1060
|
+
const column = toRaw(this.$data.$model);
|
|
1061
|
+
const layout = column.layout;
|
|
1062
|
+
if (layout) {
|
|
1063
|
+
layout.cellWidth = diff.width;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
const RGLiteralColumn = defineComponent({
|
|
1070
|
+
name: "RGLiteralColumn",
|
|
1071
|
+
extends: ComponentBase,
|
|
1072
|
+
data() {
|
|
1073
|
+
return {};
|
|
1074
|
+
},
|
|
1075
|
+
props: {},
|
|
1076
|
+
methods: {
|
|
1077
|
+
mountCB(grid) {
|
|
1078
|
+
var _a, _b;
|
|
1079
|
+
const pAttrs = kebabToCamel(toRaw((_a = this.$parent) == null ? void 0 : _a.$attrs));
|
|
1080
|
+
if (pAttrs) {
|
|
1081
|
+
const props = kebabToCamel(toRaw(this.$attrs));
|
|
1082
|
+
if (grid) {
|
|
1083
|
+
this.$model = grid.addColumn({ ...props, type: "literal" }, (_b = props.displayIndex) != null ? _b : -1);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
unmountCB(grid) {
|
|
1088
|
+
if (this.$data.$model) {
|
|
1089
|
+
grid.removeColumn(this.$model.name);
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
_doWatchAttrs(diff) {
|
|
1093
|
+
if (diff.hasOwnProperty("width") && !isNaN(diff["width"])) {
|
|
1094
|
+
const column = toRaw(this.$data.$model);
|
|
1095
|
+
const layout = column.layout;
|
|
1096
|
+
if (layout) {
|
|
1097
|
+
layout.cellWidth = diff.width;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
const RGCheckBar = defineComponent({
|
|
1104
|
+
name: "RGCheckBar",
|
|
1105
|
+
extends: ComponentBase,
|
|
1106
|
+
props: {},
|
|
1107
|
+
data() {
|
|
1108
|
+
return {};
|
|
1109
|
+
},
|
|
1110
|
+
methods: {
|
|
1111
|
+
mountCB(grid) {
|
|
1112
|
+
grid.setCheckBar(kebabToCamel(toRaw(this.$attrs)));
|
|
1113
|
+
this.$model = grid.checkBar;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
export { RGCheckBar, RGDataColumn, RGDataField, RGFilterPanel, RGFooter, RGFooters, RGGroupPanel, RGHeader, RGHeaderSummaries, RGHeaderSummary, RGLiteralColumn, RGRowIndicator, RGSeriesColumn, RGStateBar, RealGridVue, RealTreeVue };
|