@v2coding/ui 1.5.2 → 1.5.4

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.
@@ -1876,7 +1876,7 @@ const DefaultVType = {
1876
1876
  const isValid = ID_Card$1.isValid(value);
1877
1877
 
1878
1878
  if (isValid) {
1879
- callback('');
1879
+ callback();
1880
1880
  } else {
1881
1881
  callback(message || `请输入正确的${label}`);
1882
1882
  }
@@ -9795,12 +9795,7 @@ var Drag = {
9795
9795
  name: 'dialogDrag',
9796
9796
 
9797
9797
  bind(el) {
9798
- const dialogHeaderEl = el.querySelector('.el-dialog__header');
9799
- const dragDom = el.querySelector('.el-dialog'); //dialogHeaderEl.style.cursor = 'move';
9800
-
9801
- dialogHeaderEl.style.cssText += ';cursor:move;';
9802
- dragDom.style.cssText += ';top:0px;'; // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
9803
-
9798
+ // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
9804
9799
  const sty = function () {
9805
9800
  if (window.document.currentStyle) {
9806
9801
  return (dom, attr) => dom.currentStyle[attr];
@@ -9809,60 +9804,77 @@ var Drag = {
9809
9804
  }
9810
9805
  }();
9811
9806
 
9812
- dialogHeaderEl.onmousedown = e => {
9813
- // 鼠标按下,计算当前元素距离可视区的距离
9814
- const disX = e.clientX - dialogHeaderEl.offsetLeft;
9815
- const disY = e.clientY - dialogHeaderEl.offsetTop;
9816
- const screenWidth = el.scrollWidth; // body当前宽度
9807
+ const init = () => {
9808
+ const dialogHeaderEl = el.querySelector('.el-dialog__header');
9809
+ const dragDom = el.querySelector('.el-dialog');
9810
+ dialogHeaderEl.style.cssText += ';cursor:move;';
9811
+ dragDom.style.cssText += ';top:0px;';
9817
9812
 
9818
- const screenHeight = el.scrollHeight; // 可见区域高度(应为body高度,可某些环境下无法获取)
9813
+ dialogHeaderEl.onmousedown = e => {
9814
+ // 鼠标按下,计算当前元素距离可视区的距离
9815
+ const disX = e.clientX - dialogHeaderEl.offsetLeft;
9816
+ const disY = e.clientY - dialogHeaderEl.offsetTop;
9817
+ const screenWidth = el.scrollWidth; // body当前宽度
9819
9818
 
9820
- const dragDomWidth = dragDom.offsetWidth; // 对话框宽度
9819
+ const screenHeight = el.scrollHeight; // 可见区域高度(应为body高度,可某些环境下无法获取)
9821
9820
 
9822
- const dragDomheight = dragDom.offsetHeight; // 对话框高度
9821
+ const dragDomWidth = dragDom.offsetWidth; // 对话框宽度
9823
9822
 
9824
- const minDragDomLeft = dragDom.offsetLeft;
9825
- const maxDragDomLeft = Math.max(0, screenWidth - dragDom.offsetLeft - dragDomWidth);
9826
- const minDragDomTop = dragDom.offsetTop;
9827
- const maxDragDomTop = Math.max(0, screenHeight - dragDom.offsetTop - dragDomheight); // 获取到的值带px 正则匹配替换
9823
+ const dragDomheight = dragDom.offsetHeight; // 对话框高度
9828
9824
 
9829
- let styL = sty(dragDom, 'left');
9830
- let styT = sty(dragDom, 'top'); // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
9831
-
9832
- if (styL.includes('%')) {
9833
- styL = +document.body.clientWidth * (+styL.replace(/%/g, '') / 100);
9834
- styT = +document.body.clientHeight * (+styT.replace(/%/g, '') / 100);
9835
- } else {
9836
- styL = +styL.replace(/px/g, '');
9837
- styT = +styT.replace(/px/g, '');
9838
- }
9825
+ const minDragDomLeft = dragDom.offsetLeft;
9826
+ const maxDragDomLeft = Math.max(0, screenWidth - dragDom.offsetLeft - dragDomWidth);
9827
+ const minDragDomTop = dragDom.offsetTop;
9828
+ const maxDragDomTop = Math.max(0, screenHeight - dragDom.offsetTop - dragDomheight); // 获取到的值带px 正则匹配替换
9839
9829
 
9840
- document.onmousemove = function (e) {
9841
- // 通过事件委托,计算移动的距离
9842
- let left = e.clientX - disX;
9843
- let top = e.clientY - disY; // 边界处理
9830
+ let styL = sty(dragDom, 'left');
9831
+ let styT = sty(dragDom, 'top'); // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
9844
9832
 
9845
- if (-left > minDragDomLeft) {
9846
- left = -minDragDomLeft;
9847
- } else if (left > maxDragDomLeft) {
9848
- left = maxDragDomLeft;
9833
+ if (styL.includes('%')) {
9834
+ styL = +document.body.clientWidth * (+styL.replace(/%/g, '') / 100);
9835
+ styT = +document.body.clientHeight * (+styT.replace(/%/g, '') / 100);
9836
+ } else {
9837
+ styL = +styL.replace(/px/g, '');
9838
+ styT = +styT.replace(/px/g, '');
9849
9839
  }
9850
9840
 
9851
- if (-top > minDragDomTop) {
9852
- top = -minDragDomTop;
9853
- } else if (top > maxDragDomTop) {
9854
- top = maxDragDomTop;
9855
- } // 移动当前元素
9841
+ document.onmousemove = function (e) {
9842
+ // 通过事件委托,计算移动的距离
9843
+ let left = e.clientX - disX;
9844
+ let top = e.clientY - disY; // 边界处理
9856
9845
 
9846
+ if (-left > minDragDomLeft) {
9847
+ left = -minDragDomLeft;
9848
+ } else if (left > maxDragDomLeft) {
9849
+ left = maxDragDomLeft;
9850
+ }
9851
+
9852
+ if (-top > minDragDomTop) {
9853
+ top = -minDragDomTop;
9854
+ } else if (top > maxDragDomTop) {
9855
+ top = maxDragDomTop;
9856
+ } // 移动当前元素
9857
9857
 
9858
- dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
9859
- };
9860
9858
 
9861
- document.onmouseup = function () {
9862
- document.onmousemove = null;
9863
- document.onmouseup = null;
9859
+ dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
9860
+ };
9861
+
9862
+ document.onmouseup = function () {
9863
+ document.onmousemove = null;
9864
+ document.onmouseup = null;
9865
+ };
9864
9866
  };
9865
9867
  };
9868
+
9869
+ init();
9870
+ const observer = new MutationObserver(mutationsList => {
9871
+ init();
9872
+ });
9873
+ observer.observe(el, {
9874
+ childList: true,
9875
+ subtree: false,
9876
+ attributes: false
9877
+ });
9866
9878
  }
9867
9879
 
9868
9880
  };
@@ -11283,8 +11295,47 @@ const array2Tree = function (arr) {
11283
11295
  });
11284
11296
  return root[opt.childrenKey];
11285
11297
  };
11298
+ const tree2Array = function (tree) {
11299
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
11300
+
11301
+ if (!Array.isArray(tree) || tree.length <= 0) {
11302
+ return [];
11303
+ }
11304
+
11305
+ const DEFAULT_OPT = {
11306
+ childrenKey: 'children',
11307
+ flattenChildren: true,
11308
+ deleteChildren: true
11309
+ };
11310
+ opt = Object.assign({}, DEFAULT_OPT, opt);
11311
+ const result = [];
11312
+
11313
+ const traverse = nodes => {
11314
+ if (!Array.isArray(nodes) || nodes.length <= 0) {
11315
+ return;
11316
+ }
11317
+
11318
+ nodes.forEach(node => {
11319
+ // 添加当前节点到结果数组
11320
+ result.push(node); // 如果有子节点且需要展开
11321
+
11322
+ if (opt.flattenChildren && node[opt.childrenKey] && Array.isArray(node[opt.childrenKey])) {
11323
+ traverse(node[opt.childrenKey]);
11324
+
11325
+ if (opt.deleteChildren) {
11326
+ // 删除children属性
11327
+ delete node[opt.childrenKey];
11328
+ }
11329
+ }
11330
+ });
11331
+ };
11332
+
11333
+ traverse(tree);
11334
+ return result;
11335
+ };
11286
11336
  var arrays = {
11287
- array2Tree
11337
+ array2Tree,
11338
+ tree2Array
11288
11339
  };
11289
11340
 
11290
11341
  var mixin = {