dfish-widget 1.0.76 → 1.0.78

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
@@ -2237,10 +2237,22 @@ var script$1l = {
2237
2237
  // 表单验证。如果检测到错误,将返回一个包含错误信息的数组 /@r -> range, n -> validate group name
2238
2238
  async getValidError(range) {
2239
2239
  let e, q = this.getFormList(range);
2240
+ const group = {};
2240
2241
  for (let i = 0, l = q.length, c, v; i < l; i++) {
2241
- if ((c = $$1(q[i])) && c.isFormWidget && (v = await c.getValidError())) {
2242
- if (!e) e = [];
2243
- if (!e.find(n => n.wid == v.wid)) e.push(v);
2242
+ if ((c = $$1(q[i])) && c.isFormWidget) {
2243
+ if (q[i].name in group) {
2244
+ v = group[q[i].name] && $$1.extend({wid: c.uid}, group[q[i].name]);
2245
+ } else {
2246
+ v = await c.getValidError();
2247
+ }
2248
+ if (v) {
2249
+ if (!e) e = [];
2250
+ if (!e.find(n => n.wid == v.wid)) e.push(v);
2251
+ }
2252
+ }
2253
+ // checkbox 和 radio 只需验证一个
2254
+ if (q[i].type === 'checkbox' || q[i].type === 'radio') {
2255
+ group[q[i].name] = v;
2244
2256
  }
2245
2257
  }
2246
2258
  return e
@@ -4299,6 +4311,11 @@ let inst$1 = null;
4299
4311
  name: 'w-tip',
4300
4312
  mixins: [script$1a],
4301
4313
  props: ['face', 'text', 'escape'],
4314
+ provide() {
4315
+ return {
4316
+ provideView: this.provideView
4317
+ }
4318
+ },
4302
4319
  methods: {
4303
4320
  x_default() {
4304
4321
  return {
@@ -5728,25 +5745,32 @@ const props = __props;
5728
5745
  showCount.value = Math.ceil(flow.value.height / itemHeight) + 1;
5729
5746
  };
5730
5747
 
5748
+ const focus = async (id) => {
5749
+ if (!showList.value.find(n => id === n[propValue])) {
5750
+ expandTo(id);
5751
+ }
5752
+ const showIndex = showList.value.findIndex(n => id === n[propValue]);
5753
+ if (showIndex === -1 || showIndex === showList.value.length - 1) {
5754
+ const item = find(id);
5755
+ const i = flatList.value.indexOf(item);
5756
+ if (i > -1) {
5757
+ await nextTick();
5758
+ root.value.scrollToY(((i + 1) * itemHeight) - (flow.value.height / 2));
5759
+ }
5760
+ }
5761
+ };
5762
+
5731
5763
  const watchCurrent = async (val) => {
5732
5764
  await nextTick();
5733
5765
  current = val;
5734
5766
  val = val && $$1.array(val);
5735
5767
  if (!val || !val.length) return
5736
5768
  for (let v of val) {
5737
- if (!showList.value.find(n => v == n[propValue])) {
5769
+ if (!showList.value.find(n => v === n[propValue])) {
5738
5770
  expandTo(v);
5739
5771
  }
5740
5772
  }
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
- }
5773
+ focus(val[0]);
5750
5774
  };
5751
5775
 
5752
5776
  onMounted(async () => {
@@ -5770,7 +5794,7 @@ const props = __props;
5770
5794
  }
5771
5795
  });
5772
5796
 
5773
- expose({toggle, expandTo, find, merge});
5797
+ expose({toggle, focus, find, merge});
5774
5798
 
5775
5799
 
5776
5800
  return (_ctx, _cache) => {
@@ -6763,19 +6787,14 @@ const props = __props;
6763
6787
  showCount.value = Math.ceil(flow.value.height / itemHeight) + 1;
6764
6788
  };
6765
6789
 
6766
- const watchCurrent = async (val) => {
6790
+ const focus = async (id) => {
6767
6791
  await nextTick();
6768
- current = val;
6769
- val = val && $$1.array(val);
6770
- if (!val || !val.length) return
6771
- for (let v of val) {
6772
- if (!showList.value.find(n => v == n[propValue])) {
6773
- expandTo(v);
6774
- }
6792
+ if (!showList.value.find(n => id === n[propValue])) {
6793
+ expandTo(id);
6775
6794
  }
6776
- const showIndex = showList.value.findIndex(n => val[0] == n[propValue]);
6795
+ const showIndex = showList.value.findIndex(n => id === n[propValue]);
6777
6796
  if (showIndex === -1 || showIndex === showList.value.length - 1) {
6778
- const item = find(val[0]);
6797
+ const item = find(id);
6779
6798
  const i = flatList.value.indexOf(item);
6780
6799
  if (i > -1) {
6781
6800
  await nextTick();
@@ -6784,6 +6803,20 @@ const props = __props;
6784
6803
  }
6785
6804
  };
6786
6805
 
6806
+ const watchCurrent = async (val) => {
6807
+ await nextTick();
6808
+ current = val;
6809
+ val = val && $$1.array(val);
6810
+ if (!val || !val.length) return
6811
+ for (let v of val) {
6812
+ if (!showList.value.find(n => v === n[propValue])) {
6813
+ expandTo(v);
6814
+ }
6815
+ }
6816
+ console.log('watchCurrent');
6817
+ focus(val[0]);
6818
+ };
6819
+
6787
6820
  onMounted(async () => {
6788
6821
  watch(() => root.value.wScrollSizeY, (ssy) => {
6789
6822
  initShowCount();
@@ -6805,7 +6838,7 @@ const props = __props;
6805
6838
  }
6806
6839
  });
6807
6840
 
6808
- expose({toggle, expandTo, find, merge});
6841
+ expose({toggle, focus, find, merge});
6809
6842
 
6810
6843
 
6811
6844
  return (_ctx, _cache) => {