@panpanzhao/component-ui 0.0.13 → 0.0.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/lib/component-ui.common.js +146 -486
- package/lib/components/formula.js +7 -348
- package/lib/components/table-column.js +5 -346
- package/lib/components/table-editable.js +11 -352
- package/package.json +1 -1
|
@@ -214,350 +214,9 @@ module.exports = require("lodash");
|
|
|
214
214
|
/***/ }),
|
|
215
215
|
|
|
216
216
|
/***/ 20:
|
|
217
|
-
/***/ (function(module,
|
|
218
|
-
|
|
219
|
-
"use strict";
|
|
220
|
-
|
|
221
|
-
// EXPORTS
|
|
222
|
-
__webpack_require__.d(__webpack_exports__, "e", function() { return /* reexport */ uuid; });
|
|
223
|
-
__webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ eachTree; });
|
|
224
|
-
__webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ findTree; });
|
|
225
|
-
__webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ findTreeIndex; });
|
|
226
|
-
__webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ spliceTreeSelf; });
|
|
227
|
-
|
|
228
|
-
// UNUSED EXPORTS: mapTree, getTree, filterTree, everyTree, someTree, spliceTree, getTreeDepth, getTreeAncestors, getTreeParent
|
|
229
|
-
|
|
230
|
-
// CONCATENATED MODULE: ./src/utils/helper.js
|
|
231
|
-
// 参考 https://github.com/streamich/v4-uuid
|
|
232
|
-
var str = function str() {
|
|
233
|
-
return ('00000000000000000' + (Math.random() * 0xffffffffffffffff).toString(16)).slice(-16);
|
|
234
|
-
};
|
|
235
|
-
var uuid = function uuid() {
|
|
236
|
-
var a = str();
|
|
237
|
-
var b = str();
|
|
238
|
-
return a.slice(0, 8) + '-' + a.slice(8, 12) + '-4' + a.slice(13) + '-a' + b.slice(1, 4) + '-' + b.slice(4);
|
|
239
|
-
};
|
|
240
|
-
// CONCATENATED MODULE: ./src/utils/tree.js
|
|
241
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
242
|
-
/**
|
|
243
|
-
* 类似于 arr.map 方法,此方法主要针对类似下面示例的树形结构。
|
|
244
|
-
* [
|
|
245
|
-
* {
|
|
246
|
-
* children: []
|
|
247
|
-
* },
|
|
248
|
-
* // 其他成员
|
|
249
|
-
* ]
|
|
250
|
-
*
|
|
251
|
-
* @param {Tree} tree 树形数据
|
|
252
|
-
* @param {Function} iterator 处理函数,返回的数据会被替换成新的。
|
|
253
|
-
* @return {Tree} 返回处理过的 tree
|
|
254
|
-
*/
|
|
255
|
-
function mapTree(tree, iterator, level, depthFirst, paths) {
|
|
256
|
-
if (level === void 0) {
|
|
257
|
-
level = 1;
|
|
258
|
-
}
|
|
259
|
-
if (depthFirst === void 0) {
|
|
260
|
-
depthFirst = false;
|
|
261
|
-
}
|
|
262
|
-
if (paths === void 0) {
|
|
263
|
-
paths = [];
|
|
264
|
-
}
|
|
265
|
-
return tree.map(function (item, index) {
|
|
266
|
-
if (depthFirst) {
|
|
267
|
-
var children = item.children ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item)) : undefined;
|
|
268
|
-
children && (item = _extends({}, item, {
|
|
269
|
-
children: children
|
|
270
|
-
}));
|
|
271
|
-
item = iterator(item, index, level, paths) || _extends({}, item);
|
|
272
|
-
return item;
|
|
273
|
-
}
|
|
274
|
-
item = iterator(item, index, level, paths) || _extends({}, item);
|
|
275
|
-
if (item.children && item.children.splice) {
|
|
276
|
-
item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
|
|
277
|
-
}
|
|
278
|
-
return item;
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* 遍历树
|
|
284
|
-
* @param tree
|
|
285
|
-
* @param iterator
|
|
286
|
-
*/
|
|
287
|
-
function eachTree(tree, iterator, level, paths) {
|
|
288
|
-
if (level === void 0) {
|
|
289
|
-
level = 1;
|
|
290
|
-
}
|
|
291
|
-
if (paths === void 0) {
|
|
292
|
-
paths = [];
|
|
293
|
-
}
|
|
294
|
-
tree.map(function (item, index) {
|
|
295
|
-
var currentPath = paths.concat(item);
|
|
296
|
-
iterator(item, index, level, currentPath);
|
|
297
|
-
if (item.children && item.children.splice) {
|
|
298
|
-
eachTree(item.children, iterator, level + 1, currentPath);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* 在树中查找节点。
|
|
304
|
-
* @param tree
|
|
305
|
-
* @param iterator
|
|
306
|
-
*/
|
|
307
|
-
function findTree(tree, iterator) {
|
|
308
|
-
var result = null;
|
|
309
|
-
everyTree(tree, function (item, key, level, paths) {
|
|
310
|
-
if (iterator(item, key, level, paths)) {
|
|
311
|
-
result = item;
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
return true;
|
|
315
|
-
});
|
|
316
|
-
return result;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* 在树中查找节点, 返回下标数组。
|
|
321
|
-
* @param tree
|
|
322
|
-
* @param iterator
|
|
323
|
-
*/
|
|
324
|
-
function findTreeIndex(tree, iterator) {
|
|
325
|
-
var idx = [];
|
|
326
|
-
findTree(tree, function (item, index, level, paths) {
|
|
327
|
-
if (iterator(item, index, level, paths)) {
|
|
328
|
-
idx = [index];
|
|
329
|
-
paths = paths.concat();
|
|
330
|
-
paths.unshift({
|
|
331
|
-
children: tree
|
|
332
|
-
});
|
|
333
|
-
for (var i = paths.length - 1; i > 0; i--) {
|
|
334
|
-
var prev = paths[i - 1];
|
|
335
|
-
var current = paths[i];
|
|
336
|
-
idx.unshift(prev.children && prev.children.indexOf(current));
|
|
337
|
-
}
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
|
-
return false;
|
|
341
|
-
});
|
|
342
|
-
return idx.length ? idx : undefined;
|
|
343
|
-
}
|
|
344
|
-
function getTree(tree, idx) {
|
|
345
|
-
var indexes = Array.isArray(idx) ? idx.concat() : [idx];
|
|
346
|
-
var lastIndex = indexes.pop();
|
|
347
|
-
var list = tree;
|
|
348
|
-
for (var i = 0, len = indexes.length; i < len; i++) {
|
|
349
|
-
var index = indexes[i];
|
|
350
|
-
if (!list || !list[index]) {
|
|
351
|
-
list = null;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
list = list[index].children;
|
|
355
|
-
}
|
|
356
|
-
return list ? list[lastIndex] : undefined;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* 过滤树节点
|
|
360
|
-
*
|
|
361
|
-
* @param tree
|
|
362
|
-
* @param iterator
|
|
363
|
-
*/
|
|
364
|
-
function filterTree(tree, iterator, level, depthFirst) {
|
|
365
|
-
if (level === void 0) {
|
|
366
|
-
level = 1;
|
|
367
|
-
}
|
|
368
|
-
if (depthFirst === void 0) {
|
|
369
|
-
depthFirst = false;
|
|
370
|
-
}
|
|
371
|
-
if (depthFirst) {
|
|
372
|
-
return tree.map(function (item) {
|
|
373
|
-
var children = item.children ? filterTree(item.children, iterator, level + 1, depthFirst) : undefined;
|
|
374
|
-
if (Array.isArray(children) && Array.isArray(item.children)) {
|
|
375
|
-
item = _extends({}, item, {
|
|
376
|
-
children: children
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
return item;
|
|
380
|
-
}).filter(function (item, index) {
|
|
381
|
-
return iterator(item, index, level);
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
return tree.filter(function (item, index) {
|
|
385
|
-
return iterator(item, index, level);
|
|
386
|
-
}).map(function (item) {
|
|
387
|
-
if (item.children && item.children.splice) {
|
|
388
|
-
var children = filterTree(item.children, iterator, level + 1, depthFirst);
|
|
389
|
-
if (Array.isArray(children) && Array.isArray(item.children)) {
|
|
390
|
-
item = _extends({}, item, {
|
|
391
|
-
children: children
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return item;
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* 判断树中每个节点是否满足某个条件。
|
|
401
|
-
* @param tree
|
|
402
|
-
* @param iterator
|
|
403
|
-
*/
|
|
404
|
-
function everyTree(tree, iterator, level, paths, indexes) {
|
|
405
|
-
if (level === void 0) {
|
|
406
|
-
level = 1;
|
|
407
|
-
}
|
|
408
|
-
if (paths === void 0) {
|
|
409
|
-
paths = [];
|
|
410
|
-
}
|
|
411
|
-
if (indexes === void 0) {
|
|
412
|
-
indexes = [];
|
|
413
|
-
}
|
|
414
|
-
if (!Array.isArray(tree)) {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
return tree.every(function (item, index) {
|
|
418
|
-
var value = iterator(item, index, level, paths, indexes);
|
|
419
|
-
if (value && item.children && item.children.splice) {
|
|
420
|
-
return everyTree(item.children, iterator, level + 1, paths.concat(item), indexes.concat(index));
|
|
421
|
-
}
|
|
422
|
-
return value;
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* 判断树中是否有某些节点满足某个条件。
|
|
428
|
-
* @param tree
|
|
429
|
-
* @param iterator
|
|
430
|
-
*/
|
|
431
|
-
function someTree(tree, iterator) {
|
|
432
|
-
var result = false;
|
|
433
|
-
everyTree(tree, function (item, key, level, paths) {
|
|
434
|
-
if (iterator(item, key, level, paths)) {
|
|
435
|
-
result = true;
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
return true;
|
|
439
|
-
});
|
|
440
|
-
return result;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* 操作树,遵循 imutable, 每次返回一个新的树。
|
|
445
|
-
* 类似数组的 splice 不同的地方这个方法不修改原始数据,
|
|
446
|
-
* 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。
|
|
447
|
-
*
|
|
448
|
-
* 至于如何获取下标数组,请查看 findTreeIndex
|
|
449
|
-
*
|
|
450
|
-
* @param tree
|
|
451
|
-
* @param idx
|
|
452
|
-
* @param deleteCount
|
|
453
|
-
* @param ...items
|
|
454
|
-
*/
|
|
455
|
-
function spliceTree(tree, idx, deleteCount) {
|
|
456
|
-
if (deleteCount === void 0) {
|
|
457
|
-
deleteCount = 0;
|
|
458
|
-
}
|
|
459
|
-
var list = tree.concat();
|
|
460
|
-
for (var _len = arguments.length, items = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
461
|
-
items[_key - 3] = arguments[_key];
|
|
462
|
-
}
|
|
463
|
-
if (typeof idx === 'number') {
|
|
464
|
-
list.splice.apply(list, [idx, deleteCount].concat(items));
|
|
465
|
-
} else if (Array.isArray(idx) && idx.length) {
|
|
466
|
-
idx = idx.concat();
|
|
467
|
-
var lastIdx = idx.pop();
|
|
468
|
-
var host = idx.reduce(function (list, idx) {
|
|
469
|
-
var child = _extends({}, list[idx], {
|
|
470
|
-
children: list[idx].children ? list[idx].children.concat() : []
|
|
471
|
-
});
|
|
472
|
-
list[idx] = child;
|
|
473
|
-
return child.children;
|
|
474
|
-
}, list);
|
|
475
|
-
host.splice.apply(host, [lastIdx, deleteCount].concat(items));
|
|
476
|
-
}
|
|
477
|
-
return list;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* 计算树的深度
|
|
482
|
-
* @param tree
|
|
483
|
-
*/
|
|
484
|
-
function getTreeDepth(tree) {
|
|
485
|
-
return Math.max.apply(Math, tree.map(function (item) {
|
|
486
|
-
if (Array.isArray(item.children)) {
|
|
487
|
-
return 1 + getTreeDepth(item.children);
|
|
488
|
-
}
|
|
489
|
-
return 1;
|
|
490
|
-
}));
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* 从树中获取某个值的所有祖先
|
|
495
|
-
* @param tree
|
|
496
|
-
* @param value
|
|
497
|
-
*/
|
|
498
|
-
function getTreeAncestors(tree, value, includeSelf) {
|
|
499
|
-
if (includeSelf === void 0) {
|
|
500
|
-
includeSelf = false;
|
|
501
|
-
}
|
|
502
|
-
var ancestors = null;
|
|
503
|
-
findTree(tree, function (item, index, level, paths) {
|
|
504
|
-
if (item === value) {
|
|
505
|
-
ancestors = paths;
|
|
506
|
-
if (includeSelf) {
|
|
507
|
-
ancestors.push(item);
|
|
508
|
-
}
|
|
509
|
-
return true;
|
|
510
|
-
}
|
|
511
|
-
return false;
|
|
512
|
-
});
|
|
513
|
-
return ancestors;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* 从树中获取某个值的上级
|
|
518
|
-
* @param tree
|
|
519
|
-
* @param value
|
|
520
|
-
*/
|
|
521
|
-
function getTreeParent(tree, value) {
|
|
522
|
-
var ancestors = getTreeAncestors(tree, value);
|
|
523
|
-
return ancestors && ancestors.length ? ancestors[ancestors.length - 1] : null;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* 操作树,修车原来的树, 返回修改后的树。
|
|
528
|
-
* 类似数组的 splice 修改原始数据,
|
|
529
|
-
* 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。
|
|
530
|
-
*
|
|
531
|
-
* 至于如何获取下标数组,请查看 findTreeIndex
|
|
532
|
-
*
|
|
533
|
-
* @param tree
|
|
534
|
-
* @param idx
|
|
535
|
-
* @param deleteCount
|
|
536
|
-
* @param ...items
|
|
537
|
-
*/
|
|
538
|
-
function spliceTreeSelf(tree, idx, deleteCount) {
|
|
539
|
-
if (deleteCount === void 0) {
|
|
540
|
-
deleteCount = 0;
|
|
541
|
-
}
|
|
542
|
-
var list = tree;
|
|
543
|
-
for (var _len2 = arguments.length, items = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
|
|
544
|
-
items[_key2 - 3] = arguments[_key2];
|
|
545
|
-
}
|
|
546
|
-
if (typeof idx === 'number') {
|
|
547
|
-
list.splice.apply(list, [idx, deleteCount].concat(items));
|
|
548
|
-
} else if (Array.isArray(idx) && idx.length) {
|
|
549
|
-
idx = idx.concat();
|
|
550
|
-
var lastIdx = idx.pop();
|
|
551
|
-
var host = idx.reduce(function (list, idx) {
|
|
552
|
-
return list[idx] && list[idx].children || [];
|
|
553
|
-
}, list);
|
|
554
|
-
host.splice.apply(host, [lastIdx, deleteCount].concat(items));
|
|
555
|
-
}
|
|
556
|
-
return list;
|
|
557
|
-
}
|
|
558
|
-
// CONCATENATED MODULE: ./src/utils/index.js
|
|
559
|
-
|
|
217
|
+
/***/ (function(module, exports) {
|
|
560
218
|
|
|
219
|
+
module.exports = require("@panpanzhao/component-ui/lib/utils/index");
|
|
561
220
|
|
|
562
221
|
/***/ }),
|
|
563
222
|
|
|
@@ -1094,8 +753,8 @@ var button_default = /*#__PURE__*/__webpack_require__.n(button_);
|
|
|
1094
753
|
var link_ = __webpack_require__(36);
|
|
1095
754
|
var link_default = /*#__PURE__*/__webpack_require__.n(link_);
|
|
1096
755
|
|
|
1097
|
-
// EXTERNAL MODULE:
|
|
1098
|
-
var
|
|
756
|
+
// EXTERNAL MODULE: external "@panpanzhao/component-ui/lib/utils/index"
|
|
757
|
+
var index_ = __webpack_require__(20);
|
|
1099
758
|
|
|
1100
759
|
// EXTERNAL MODULE: external "lodash"
|
|
1101
760
|
var external_lodash_ = __webpack_require__(2);
|
|
@@ -1153,7 +812,7 @@ var external_lodash_ = __webpack_require__(2);
|
|
|
1153
812
|
created: function created() {
|
|
1154
813
|
this.items.forEach(function (row) {
|
|
1155
814
|
if (!row.key) {
|
|
1156
|
-
row.key = Object(
|
|
815
|
+
row.key = Object(index_["uuid"])();
|
|
1157
816
|
}
|
|
1158
817
|
});
|
|
1159
818
|
},
|