dfish-widget 1.0.74 → 1.0.76

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/index.esm.js CHANGED
@@ -712,7 +712,9 @@ const frag = function(s) {
712
712
 
713
713
  const el = function(o) {
714
714
  if (o) {
715
- return o.isWidget ? o.el() : (o.$el || o)
715
+ const d = o.$el;
716
+ if (d) return d.nodeType === 1 ? d : d.nextElementSibling
717
+ return o.isWidget ? o.el() : o
716
718
  }
717
719
  };
718
720
  // o -> el, s -> html string/object, r -> where[`after`, `prepend`, `before`, `append`]
@@ -1546,7 +1548,7 @@ $$1.ease = function(fn, ms, count) {
1546
1548
 
1547
1549
  // @a -> widget|HTMLElement, y -> {print: T/F(是否打印), head: "head标签", input2text: T/F(把表单值转为文本)
1548
1550
  $$1.print = function(a, y) {
1549
- let d = a.el ? a.el() : (a.$el || a), w = d.ownerDocument, b = $$1.q('link[media=print]', w), c = [];
1551
+ let d = $$1.el(a), w = d.ownerDocument, b = $$1.q('link[media=print]', w), c = [];
1550
1552
  y = y || {};
1551
1553
  $$1.q('meta', w).each(function() {c.push(this.outerHTML);});
1552
1554
  (b.length > 0 ? b : $$1.q('link', w)).each(function() {c.push('<link rel="stylesheet" type="text/css" href="' + this.getAttribute('href') + '"/>');});
@@ -5518,6 +5520,7 @@ const props = __props;
5518
5520
  const propValue = alias.value || 'id';
5519
5521
  alias.text || 'text';
5520
5522
  const propChildren = alias.children || 'children';
5523
+ const propClass = alias.class || 'class';
5521
5524
 
5522
5525
  const leafSymbol = Symbol('leaf');
5523
5526
  const showCount = ref(0);
@@ -5546,6 +5549,10 @@ const props = __props;
5546
5549
  return s
5547
5550
  };
5548
5551
 
5552
+ const itemClass = (item) => {
5553
+ return typeof propClass === 'function' ? propClass(item) : item[propClass]
5554
+ };
5555
+
5549
5556
  const itemStyle = (item) => {
5550
5557
  return {
5551
5558
  top: `${item[leafSymbol].showIndex * itemHeight}px`,
@@ -5682,18 +5689,25 @@ const props = __props;
5682
5689
  return item
5683
5690
  };
5684
5691
 
5685
- const merge = (newList, oldList) => {
5686
- if (!Array.isArray(newList)) return
5687
- const item = newList.find(n => n[propChildren] && n[propChildren].length);
5688
- if (item) {
5689
- if (!oldList) oldList = props.children;
5690
- const old = oldList.find(n => n[propValue] == item[propValue]);
5691
- if (old) {
5692
- if (old[propChildren] && old[propChildren].length) {
5693
- merge(item[propChildren], old[propChildren]);
5694
- } else {
5695
- old[propChildren] = item[propChildren];
5696
- toFlat(old[propChildren], old);
5692
+ const merge = (newList) => {
5693
+ if (!Array.isArray(newList)) return []
5694
+ const oldList = JSON.parse(JSON.stringify(props.children));
5695
+ mergeChildren(newList, oldList);
5696
+ props.children.length = 0;
5697
+ props.children.push.apply(props.children, newList);
5698
+ flatList.value = toFlat(newList);
5699
+ };
5700
+
5701
+ const mergeChildren = (newList, oldList) => {
5702
+ for (let n of newList) {
5703
+ let o = oldList.find(v => v[propValue] === n[propValue]);
5704
+ if (o) {
5705
+ if (o[propChildren]) {
5706
+ if (n[propChildren]) mergeChildren(n[propChildren], o[propChildren]);
5707
+ else n[propChildren] = o[propChildren];
5708
+ }
5709
+ if (o.expanded != null) {
5710
+ n.expanded = o.expanded;
5697
5711
  }
5698
5712
  }
5699
5713
  }
@@ -5811,7 +5825,7 @@ return (_ctx, _cache) => {
5811
5825
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(showList), (item, index) => {
5812
5826
  return (openBlock(), createElementBlock("div", {
5813
5827
  key: index,
5814
- class: normalizeClass(['w-table-v2-tr', {'z-on': isCurrent(item)}]),
5828
+ class: normalizeClass(['w-table-v2-tr', itemClass(item), {'z-on': isCurrent(item)}]),
5815
5829
  style: normalizeStyle(itemStyle(item)),
5816
5830
  onClick: $event => (clickItem($event, item))
5817
5831
  }, [
@@ -6552,6 +6566,8 @@ const props = __props;
6552
6566
  const propValue = alias.value || 'id';
6553
6567
  const propText = alias.text || 'text';
6554
6568
  const propChildren = alias.children || 'children';
6569
+ const propClass = alias.class || 'class';
6570
+ const propDisabled = alias.disabled || 'disabled';
6555
6571
 
6556
6572
  const leafSymbol = Symbol('leaf');
6557
6573
  const showCount = ref(0);
@@ -6568,6 +6584,10 @@ const props = __props;
6568
6584
  }
6569
6585
  });
6570
6586
 
6587
+ const itemClass = (item, index) => {
6588
+ return typeof propClass === 'function' ? propClass(item, index) : item[propClass]
6589
+ };
6590
+
6571
6591
  const itemStyle = (item) => {
6572
6592
  return {
6573
6593
  top: `${item[leafSymbol].showIndex * itemHeight}px`,
@@ -6591,8 +6611,12 @@ const props = __props;
6591
6611
  return Array.isArray(props.current) ? props.current.includes(item[propValue]) : (props.current === item[propValue])
6592
6612
  };
6593
6613
 
6614
+ const isDisabled = (item, index) => {
6615
+ return typeof propDisabled === 'function' ? propDisabled(item, index) : item[propDisabled]
6616
+ };
6617
+
6594
6618
  const clickItem = (e, item) => {
6595
- emits('click:item', e, item);
6619
+ if (!isDisabled(item)) emits('click:item', e, item);
6596
6620
  };
6597
6621
 
6598
6622
  const clickToggle = (e, item) => {
@@ -6700,18 +6724,25 @@ const props = __props;
6700
6724
  return item
6701
6725
  };
6702
6726
 
6703
- const merge = (newList, oldList) => {
6704
- if (!Array.isArray(newList)) return
6705
- const item = newList.find(n => n[propChildren] && n[propChildren].length);
6706
- if (item) {
6707
- if (!oldList) oldList = props.children;
6708
- const old = oldList.find(n => n[propValue] == item[propValue]);
6709
- if (old) {
6710
- if (old[propChildren] && old[propChildren].length) {
6711
- merge(item[propChildren], old[propChildren]);
6712
- } else {
6713
- old[propChildren] = item[propChildren];
6714
- toFlat(old[propChildren], old);
6727
+ const merge = (newList) => {
6728
+ if (!Array.isArray(newList)) return []
6729
+ const oldList = JSON.parse(JSON.stringify(props.children));
6730
+ mergeChildren(newList, oldList);
6731
+ props.children.length = 0;
6732
+ props.children.push.apply(props.children, newList);
6733
+ flatList.value = toFlat(newList);
6734
+ };
6735
+
6736
+ const mergeChildren = (newList, oldList) => {
6737
+ for (let n of newList) {
6738
+ let o = oldList.find(v => v[propValue] === n[propValue]);
6739
+ if (o) {
6740
+ if (o[propChildren]) {
6741
+ if (n[propChildren]) mergeChildren(n[propChildren], o[propChildren]);
6742
+ else n[propChildren] = o[propChildren];
6743
+ }
6744
+ if (o.expanded != null) {
6745
+ n.expanded = o.expanded;
6715
6746
  }
6716
6747
  }
6717
6748
  }
@@ -6806,7 +6837,7 @@ return (_ctx, _cache) => {
6806
6837
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(showList), (item, index) => {
6807
6838
  return (openBlock(), createElementBlock("div", {
6808
6839
  key: index,
6809
- class: normalizeClass(['w-leaf w-leaf-v2', {'z-folder': isFolder(item), 'z-on': isCurrent(item)}]),
6840
+ class: normalizeClass(['w-leaf w-leaf-v2', itemClass(item, index), {'z-folder': isFolder(item), 'z-on': isCurrent(item), 'z-ds': isDisabled(item, index)}]),
6810
6841
  style: normalizeStyle(itemStyle(item)),
6811
6842
  onClick: $event => (clickItem($event, item))
6812
6843
  }, [