dfish-widget 1.0.76 → 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 CHANGED
@@ -5728,25 +5728,32 @@ const props = __props;
5728
5728
  showCount.value = Math.ceil(flow.value.height / itemHeight) + 1;
5729
5729
  };
5730
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
+
5731
5746
  const watchCurrent = async (val) => {
5732
5747
  await nextTick();
5733
5748
  current = val;
5734
5749
  val = val && $$1.array(val);
5735
5750
  if (!val || !val.length) return
5736
5751
  for (let v of val) {
5737
- if (!showList.value.find(n => v == n[propValue])) {
5752
+ if (!showList.value.find(n => v === n[propValue])) {
5738
5753
  expandTo(v);
5739
5754
  }
5740
5755
  }
5741
- const showIndex = showList.value.findIndex(n => val[0] == n[propValue]);
5742
- if (showIndex === -1 || showIndex === showList.value.length - 1) {
5743
- const item = find(val[0]);
5744
- const i = flatList.value.indexOf(item);
5745
- if (i > -1) {
5746
- await nextTick();
5747
- root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
5748
- }
5749
- }
5756
+ focus(val[0]);
5750
5757
  };
5751
5758
 
5752
5759
  onMounted(async () => {
@@ -5770,7 +5777,7 @@ const props = __props;
5770
5777
  }
5771
5778
  });
5772
5779
 
5773
- expose({toggle, expandTo, find, merge});
5780
+ expose({toggle, focus, find, merge});
5774
5781
 
5775
5782
 
5776
5783
  return (_ctx, _cache) => {
@@ -6763,25 +6770,32 @@ const props = __props;
6763
6770
  showCount.value = Math.ceil(flow.value.height / itemHeight) + 1;
6764
6771
  };
6765
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
+
6766
6788
  const watchCurrent = async (val) => {
6767
6789
  await nextTick();
6768
6790
  current = val;
6769
6791
  val = val && $$1.array(val);
6770
6792
  if (!val || !val.length) return
6771
6793
  for (let v of val) {
6772
- if (!showList.value.find(n => v == n[propValue])) {
6794
+ if (!showList.value.find(n => v === n[propValue])) {
6773
6795
  expandTo(v);
6774
6796
  }
6775
6797
  }
6776
- const showIndex = showList.value.findIndex(n => val[0] == n[propValue]);
6777
- if (showIndex === -1 || showIndex === showList.value.length - 1) {
6778
- const item = find(val[0]);
6779
- const i = flatList.value.indexOf(item);
6780
- if (i > -1) {
6781
- await nextTick();
6782
- root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
6783
- }
6784
- }
6798
+ focus(val[0]);
6785
6799
  };
6786
6800
 
6787
6801
  onMounted(async () => {
@@ -6805,7 +6819,7 @@ const props = __props;
6805
6819
  }
6806
6820
  });
6807
6821
 
6808
- expose({toggle, expandTo, find, merge});
6822
+ expose({toggle, focus, find, merge});
6809
6823
 
6810
6824
 
6811
6825
  return (_ctx, _cache) => {