dfish-widget 1.0.75 → 1.0.77
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 +58 -27
- package/lib/index.esm.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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 =
|
|
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`,
|
|
@@ -5721,25 +5728,32 @@ const props = __props;
|
|
|
5721
5728
|
showCount.value = Math.ceil(flow.value.height / itemHeight) + 1;
|
|
5722
5729
|
};
|
|
5723
5730
|
|
|
5731
|
+
const focus = async (id) => {
|
|
5732
|
+
if (!showList.value.find(n => id === n[propValue])) {
|
|
5733
|
+
expandTo(id);
|
|
5734
|
+
}
|
|
5735
|
+
const showIndex = showList.value.findIndex(n => id === n[propValue]);
|
|
5736
|
+
if (showIndex === -1 || showIndex === showList.value.length - 1) {
|
|
5737
|
+
const item = find(id);
|
|
5738
|
+
const i = flatList.value.indexOf(item);
|
|
5739
|
+
if (i > -1) {
|
|
5740
|
+
await nextTick();
|
|
5741
|
+
root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
|
|
5742
|
+
}
|
|
5743
|
+
}
|
|
5744
|
+
};
|
|
5745
|
+
|
|
5724
5746
|
const watchCurrent = async (val) => {
|
|
5725
5747
|
await nextTick();
|
|
5726
5748
|
current = val;
|
|
5727
5749
|
val = val && $$1.array(val);
|
|
5728
5750
|
if (!val || !val.length) return
|
|
5729
5751
|
for (let v of val) {
|
|
5730
|
-
if (!showList.value.find(n => v
|
|
5752
|
+
if (!showList.value.find(n => v === n[propValue])) {
|
|
5731
5753
|
expandTo(v);
|
|
5732
5754
|
}
|
|
5733
5755
|
}
|
|
5734
|
-
|
|
5735
|
-
if (showIndex === -1 || showIndex === showList.value.length - 1) {
|
|
5736
|
-
const item = find(val[0]);
|
|
5737
|
-
const i = flatList.value.indexOf(item);
|
|
5738
|
-
if (i > -1) {
|
|
5739
|
-
await nextTick();
|
|
5740
|
-
root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
|
|
5741
|
-
}
|
|
5742
|
-
}
|
|
5756
|
+
focus(val[0]);
|
|
5743
5757
|
};
|
|
5744
5758
|
|
|
5745
5759
|
onMounted(async () => {
|
|
@@ -5763,7 +5777,7 @@ const props = __props;
|
|
|
5763
5777
|
}
|
|
5764
5778
|
});
|
|
5765
5779
|
|
|
5766
|
-
expose({toggle,
|
|
5780
|
+
expose({toggle, focus, find, merge});
|
|
5767
5781
|
|
|
5768
5782
|
|
|
5769
5783
|
return (_ctx, _cache) => {
|
|
@@ -5818,7 +5832,7 @@ return (_ctx, _cache) => {
|
|
|
5818
5832
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(showList), (item, index) => {
|
|
5819
5833
|
return (openBlock(), createElementBlock("div", {
|
|
5820
5834
|
key: index,
|
|
5821
|
-
class: normalizeClass(['w-table-v2-tr', {'z-on': isCurrent(item)}]),
|
|
5835
|
+
class: normalizeClass(['w-table-v2-tr', itemClass(item), {'z-on': isCurrent(item)}]),
|
|
5822
5836
|
style: normalizeStyle(itemStyle(item)),
|
|
5823
5837
|
onClick: $event => (clickItem($event, item))
|
|
5824
5838
|
}, [
|
|
@@ -6559,6 +6573,8 @@ const props = __props;
|
|
|
6559
6573
|
const propValue = alias.value || 'id';
|
|
6560
6574
|
const propText = alias.text || 'text';
|
|
6561
6575
|
const propChildren = alias.children || 'children';
|
|
6576
|
+
const propClass = alias.class || 'class';
|
|
6577
|
+
const propDisabled = alias.disabled || 'disabled';
|
|
6562
6578
|
|
|
6563
6579
|
const leafSymbol = Symbol('leaf');
|
|
6564
6580
|
const showCount = ref(0);
|
|
@@ -6575,6 +6591,10 @@ const props = __props;
|
|
|
6575
6591
|
}
|
|
6576
6592
|
});
|
|
6577
6593
|
|
|
6594
|
+
const itemClass = (item, index) => {
|
|
6595
|
+
return typeof propClass === 'function' ? propClass(item, index) : item[propClass]
|
|
6596
|
+
};
|
|
6597
|
+
|
|
6578
6598
|
const itemStyle = (item) => {
|
|
6579
6599
|
return {
|
|
6580
6600
|
top: `${item[leafSymbol].showIndex * itemHeight}px`,
|
|
@@ -6598,8 +6618,12 @@ const props = __props;
|
|
|
6598
6618
|
return Array.isArray(props.current) ? props.current.includes(item[propValue]) : (props.current === item[propValue])
|
|
6599
6619
|
};
|
|
6600
6620
|
|
|
6621
|
+
const isDisabled = (item, index) => {
|
|
6622
|
+
return typeof propDisabled === 'function' ? propDisabled(item, index) : item[propDisabled]
|
|
6623
|
+
};
|
|
6624
|
+
|
|
6601
6625
|
const clickItem = (e, item) => {
|
|
6602
|
-
emits('click:item', e, item);
|
|
6626
|
+
if (!isDisabled(item)) emits('click:item', e, item);
|
|
6603
6627
|
};
|
|
6604
6628
|
|
|
6605
6629
|
const clickToggle = (e, item) => {
|
|
@@ -6746,25 +6770,32 @@ const props = __props;
|
|
|
6746
6770
|
showCount.value = Math.ceil(flow.value.height / itemHeight) + 1;
|
|
6747
6771
|
};
|
|
6748
6772
|
|
|
6773
|
+
const focus = async (id) => {
|
|
6774
|
+
if (!showList.value.find(n => id === n[propValue])) {
|
|
6775
|
+
expandTo(id);
|
|
6776
|
+
}
|
|
6777
|
+
const showIndex = showList.value.findIndex(n => id === n[propValue]);
|
|
6778
|
+
if (showIndex === -1 || showIndex === showList.value.length - 1) {
|
|
6779
|
+
const item = find(id);
|
|
6780
|
+
const i = flatList.value.indexOf(item);
|
|
6781
|
+
if (i > -1) {
|
|
6782
|
+
await nextTick();
|
|
6783
|
+
root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
};
|
|
6787
|
+
|
|
6749
6788
|
const watchCurrent = async (val) => {
|
|
6750
6789
|
await nextTick();
|
|
6751
6790
|
current = val;
|
|
6752
6791
|
val = val && $$1.array(val);
|
|
6753
6792
|
if (!val || !val.length) return
|
|
6754
6793
|
for (let v of val) {
|
|
6755
|
-
if (!showList.value.find(n => v
|
|
6794
|
+
if (!showList.value.find(n => v === n[propValue])) {
|
|
6756
6795
|
expandTo(v);
|
|
6757
6796
|
}
|
|
6758
6797
|
}
|
|
6759
|
-
|
|
6760
|
-
if (showIndex === -1 || showIndex === showList.value.length - 1) {
|
|
6761
|
-
const item = find(val[0]);
|
|
6762
|
-
const i = flatList.value.indexOf(item);
|
|
6763
|
-
if (i > -1) {
|
|
6764
|
-
await nextTick();
|
|
6765
|
-
root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
|
|
6766
|
-
}
|
|
6767
|
-
}
|
|
6798
|
+
focus(val[0]);
|
|
6768
6799
|
};
|
|
6769
6800
|
|
|
6770
6801
|
onMounted(async () => {
|
|
@@ -6788,7 +6819,7 @@ const props = __props;
|
|
|
6788
6819
|
}
|
|
6789
6820
|
});
|
|
6790
6821
|
|
|
6791
|
-
expose({toggle,
|
|
6822
|
+
expose({toggle, focus, find, merge});
|
|
6792
6823
|
|
|
6793
6824
|
|
|
6794
6825
|
return (_ctx, _cache) => {
|
|
@@ -6820,7 +6851,7 @@ return (_ctx, _cache) => {
|
|
|
6820
6851
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(showList), (item, index) => {
|
|
6821
6852
|
return (openBlock(), createElementBlock("div", {
|
|
6822
6853
|
key: index,
|
|
6823
|
-
class: normalizeClass(['w-leaf w-leaf-v2', {'z-folder': isFolder(item), 'z-on': isCurrent(item)}]),
|
|
6854
|
+
class: normalizeClass(['w-leaf w-leaf-v2', itemClass(item, index), {'z-folder': isFolder(item), 'z-on': isCurrent(item), 'z-ds': isDisabled(item, index)}]),
|
|
6824
6855
|
style: normalizeStyle(itemStyle(item)),
|
|
6825
6856
|
onClick: $event => (clickItem($event, item))
|
|
6826
6857
|
}, [
|