vant 4.0.0-alpha.2 → 4.0.0-alpha.3

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.
Files changed (52) hide show
  1. package/changelog.generated.md +33 -29
  2. package/es/empty/Empty.js +10 -13
  3. package/es/empty/Images.d.ts +4 -0
  4. package/es/empty/Images.js +271 -0
  5. package/es/field/Field.js +6 -3
  6. package/es/field/types.d.ts +1 -1
  7. package/es/form/Form.d.ts +13 -13
  8. package/es/form/Form.js +6 -3
  9. package/es/form/index.d.ts +9 -9
  10. package/es/index.d.ts +1 -1
  11. package/es/index.js +1 -1
  12. package/es/loading/Loading.js +3 -1
  13. package/es/search/index.css +1 -1
  14. package/es/search/index.less +1 -1
  15. package/es/uploader/Uploader.js +2 -2
  16. package/es/uploader/utils.d.ts +0 -1
  17. package/es/uploader/utils.js +2 -4
  18. package/es/utils/basic.d.ts +1 -0
  19. package/es/utils/basic.js +3 -1
  20. package/lib/empty/Empty.js +10 -13
  21. package/lib/empty/Images.d.ts +4 -0
  22. package/lib/empty/Images.js +290 -0
  23. package/lib/field/Field.js +5 -2
  24. package/lib/field/types.d.ts +1 -1
  25. package/lib/form/Form.d.ts +13 -13
  26. package/lib/form/Form.js +5 -2
  27. package/lib/form/index.d.ts +9 -9
  28. package/lib/index.css +1 -1
  29. package/lib/index.d.ts +1 -1
  30. package/lib/index.js +1 -1
  31. package/lib/loading/Loading.js +3 -1
  32. package/lib/search/index.css +1 -1
  33. package/lib/search/index.less +1 -1
  34. package/lib/uploader/Uploader.js +1 -1
  35. package/lib/uploader/utils.d.ts +0 -1
  36. package/lib/uploader/utils.js +2 -4
  37. package/lib/utils/basic.d.ts +1 -0
  38. package/lib/utils/basic.js +3 -1
  39. package/lib/vant.cjs.js +233 -49
  40. package/lib/vant.cjs.min.js +1 -1
  41. package/lib/vant.es.js +233 -49
  42. package/lib/vant.es.min.js +233 -49
  43. package/lib/vant.js +233 -49
  44. package/lib/vant.min.js +1 -1
  45. package/package.json +1 -1
  46. package/vetur/attributes.json +551 -551
  47. package/vetur/tags.json +200 -200
  48. package/vetur/web-types.json +1778 -1778
  49. package/es/empty/Network.d.ts +0 -1
  50. package/es/empty/Network.js +0 -89
  51. package/lib/empty/Network.d.ts +0 -1
  52. package/lib/empty/Network.js +0 -108
package/lib/vant.js CHANGED
@@ -24,6 +24,7 @@
24
24
  }, {});
25
25
  }
26
26
  const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
27
+ const toArray = (item) => Array.isArray(item) ? item : [item];
27
28
  const unknownProp = null;
28
29
  const numericProp = [Number, String];
29
30
  const truthProp = {
@@ -667,10 +668,10 @@
667
668
  };
668
669
  var stdin_default$1B = Locale;
669
670
  function createTranslate(name2) {
670
- const prefix2 = camelize(name2) + ".";
671
+ const prefix = camelize(name2) + ".";
671
672
  return (path, ...args) => {
672
673
  const messages2 = stdin_default$1B.messages();
673
- const message = get(messages2, prefix2 + path) || get(messages2, path);
674
+ const message = get(messages2, prefix + path) || get(messages2, path);
674
675
  return isFunction(message) ? message(...args) : message;
675
676
  };
676
677
  }
@@ -1036,7 +1037,9 @@
1036
1037
  return vue.createVNode("div", {
1037
1038
  "class": bem$1l([type, {
1038
1039
  vertical
1039
- }])
1040
+ }]),
1041
+ "aria-live": "polite",
1042
+ "aria-busy": true
1040
1043
  }, [vue.createVNode("span", {
1041
1044
  "class": bem$1l("spinner", type),
1042
1045
  "style": spinnerStyle.value
@@ -2502,9 +2505,12 @@
2502
2505
  scrollToError: Boolean,
2503
2506
  validateFirst: Boolean,
2504
2507
  submitOnEnter: truthProp,
2505
- validateTrigger: makeStringProp("onBlur"),
2506
2508
  showErrorMessage: truthProp,
2507
- errorMessageAlign: String
2509
+ errorMessageAlign: String,
2510
+ validateTrigger: {
2511
+ type: [String, Array],
2512
+ default: "onBlur"
2513
+ }
2508
2514
  };
2509
2515
  var stdin_default$1l = vue.defineComponent({
2510
2516
  name: name$1e,
@@ -2717,7 +2723,7 @@
2717
2723
  return [...str].slice(0, maxlength).join("");
2718
2724
  }
2719
2725
  let current = 0;
2720
- function useId() {
2726
+ function useId$1() {
2721
2727
  const vm = vue.getCurrentInstance();
2722
2728
  const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
2723
2729
  return `${name2}-${++current}`;
@@ -2777,7 +2783,7 @@
2777
2783
  emit,
2778
2784
  slots
2779
2785
  }) {
2780
- const id = useId();
2786
+ const id = useId$1();
2781
2787
  const state = vue.reactive({
2782
2788
  focused: false,
2783
2789
  validateFailed: false,
@@ -2867,10 +2873,13 @@
2867
2873
  });
2868
2874
  const validateWithTrigger = (trigger) => {
2869
2875
  if (form && props.rules) {
2870
- const defaultTrigger = form.props.validateTrigger === trigger;
2876
+ const {
2877
+ validateTrigger
2878
+ } = form.props;
2879
+ const defaultTrigger = toArray(validateTrigger).includes(trigger);
2871
2880
  const rules = props.rules.filter((rule) => {
2872
2881
  if (rule.trigger) {
2873
- return rule.trigger === trigger;
2882
+ return toArray(rule.trigger).includes(trigger);
2874
2883
  }
2875
2884
  return defaultTrigger;
2876
2885
  });
@@ -6051,7 +6060,7 @@
6051
6060
  const root = vue.ref();
6052
6061
  const navRef = vue.ref();
6053
6062
  const wrapRef = vue.ref();
6054
- const id = useId();
6063
+ const id = useId$1();
6055
6064
  const scroller = useScrollParent(root);
6056
6065
  const [titleRefs, setTitleRefs] = useRefs();
6057
6066
  const {
@@ -6438,7 +6447,7 @@
6438
6447
  setup(props, {
6439
6448
  slots
6440
6449
  }) {
6441
- const id = useId();
6450
+ const id = useId$1();
6442
6451
  const inited = vue.ref(false);
6443
6452
  const {
6444
6453
  parent,
@@ -7808,31 +7817,78 @@
7808
7817
  }
7809
7818
  });
7810
7819
  const CouponCell = withInstall(stdin_default$K);
7811
- const prefix = "van-empty-network-";
7820
+ const getId = (num) => `van-empty-${num}`;
7821
+ const useId = (num) => `url(#${getId(num)})`;
7812
7822
  const renderStop = (color, offset2, opacity) => vue.createVNode("stop", {
7813
7823
  "stop-color": color,
7814
7824
  "offset": `${offset2}%`,
7815
7825
  "stop-opacity": opacity
7816
7826
  }, null);
7817
- const Network = vue.createVNode("svg", {
7827
+ const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
7828
+ const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
7829
+ "id": getId(id),
7830
+ "cx": "50%",
7831
+ "cy": "54%",
7832
+ "fx": "50%",
7833
+ "fy": "54%",
7834
+ "r": "297%",
7835
+ "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
7836
+ }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
7837
+ "fill": useId(id),
7838
+ "opacity": ".8",
7839
+ "cx": "80",
7840
+ "cy": "140",
7841
+ "rx": "46",
7842
+ "ry": "8"
7843
+ }, null)];
7844
+ const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
7845
+ "id": getId("a"),
7846
+ "x1": "64%",
7847
+ "y1": "100%",
7848
+ "x2": "64%"
7849
+ }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
7850
+ "opacity": ".8"
7851
+ }, [vue.createVNode("path", {
7852
+ "d": "M36 131V53H16v20H2v58h34z",
7853
+ "fill": useId("a")
7854
+ }, null), vue.createVNode("path", {
7855
+ "d": "M123 15h22v14h9v77h-31V15z",
7856
+ "fill": useId("a")
7857
+ }, null)])];
7858
+ const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
7859
+ "id": getId("b"),
7860
+ "x1": "64%",
7861
+ "y1": "97%",
7862
+ "x2": "64%",
7863
+ "y2": "0%"
7864
+ }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
7865
+ "opacity": ".8"
7866
+ }, [vue.createVNode("path", {
7867
+ "d": "M87 6c3 0 7 3 8 6a8 8 0 1 1-1 16H80a7 7 0 0 1-8-6c0-4 3-7 6-7 0-5 4-9 9-9Z",
7868
+ "fill": useId("b")
7869
+ }, null), vue.createVNode("path", {
7870
+ "d": "M19 23c2 0 3 1 4 3 2 0 4 2 4 4a4 4 0 0 1-4 3v1h-7v-1l-1 1c-2 0-3-2-3-4 0-1 1-3 3-3 0-2 2-4 4-4Z",
7871
+ "fill": useId("b")
7872
+ }, null)])];
7873
+ const renderNetwork = () => vue.createVNode("svg", {
7818
7874
  "viewBox": "0 0 160 160"
7819
7875
  }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
7820
- "id": `${prefix}1`,
7876
+ "id": getId(1),
7821
7877
  "x1": "64%",
7822
7878
  "y1": "100%",
7823
7879
  "x2": "64%"
7824
7880
  }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
7825
- "id": `${prefix}2`,
7881
+ "id": getId(2),
7826
7882
  "x1": "50%",
7827
7883
  "x2": "50%",
7828
7884
  "y2": "84%"
7829
7885
  }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
7830
- "id": `${prefix}3`,
7886
+ "id": getId(3),
7831
7887
  "x1": "100%",
7832
7888
  "x2": "100%",
7833
7889
  "y2": "100%"
7834
- }, [renderStop("#EAEDF0", 0), renderStop("#DCDEE0", 100)]), vue.createVNode("radialGradient", {
7835
- "id": `${prefix}4`,
7890
+ }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
7891
+ "id": getId(4),
7836
7892
  "cx": "50%",
7837
7893
  "cy": "0%",
7838
7894
  "fx": "50%",
@@ -7841,36 +7897,28 @@
7841
7897
  "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
7842
7898
  }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
7843
7899
  "fill": "none"
7844
- }, [vue.createVNode("g", {
7845
- "opacity": ".8"
7846
- }, [vue.createVNode("path", {
7847
- "d": "M36 131V53H16v20H2v58h34z",
7848
- "fill": `url(#${prefix}1)`
7849
- }, null), vue.createVNode("path", {
7850
- "d": "M123 15h22v14h9v77h-31V15z",
7851
- "fill": `url(#${prefix}1)`
7852
- }, null)]), vue.createVNode("path", {
7853
- "fill": `url(#${prefix}4)`,
7900
+ }, [renderBuilding(), vue.createVNode("path", {
7901
+ "fill": useId(4),
7854
7902
  "d": "M0 139h160v21H0z"
7855
7903
  }, null), vue.createVNode("path", {
7856
7904
  "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
7857
- "fill": `url(#${prefix}2)`
7905
+ "fill": useId(2)
7858
7906
  }, null), vue.createVNode("g", {
7859
7907
  "opacity": ".6",
7860
7908
  "stroke-linecap": "round",
7861
7909
  "stroke-width": "7"
7862
7910
  }, [vue.createVNode("path", {
7863
7911
  "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
7864
- "stroke": `url(#${prefix}3)`
7912
+ "stroke": useId(3)
7865
7913
  }, null), vue.createVNode("path", {
7866
7914
  "d": "M53 36a34 34 0 0 0 0 48",
7867
- "stroke": `url(#${prefix}3)`
7915
+ "stroke": useId(3)
7868
7916
  }, null), vue.createVNode("path", {
7869
7917
  "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
7870
- "stroke": `url(#${prefix}3)`
7918
+ "stroke": useId(3)
7871
7919
  }, null), vue.createVNode("path", {
7872
7920
  "d": "M106 84a34 34 0 0 0 0-48",
7873
- "stroke": `url(#${prefix}3)`
7921
+ "stroke": useId(3)
7874
7922
  }, null)]), vue.createVNode("g", {
7875
7923
  "transform": "translate(31 105)"
7876
7924
  }, [vue.createVNode("rect", {
@@ -7893,8 +7941,153 @@
7893
7941
  "height": "6",
7894
7942
  "rx": "1.1"
7895
7943
  }, null)])])]);
7944
+ const renderMaterial = () => vue.createVNode("svg", {
7945
+ "viewBox": "0 0 160 160"
7946
+ }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
7947
+ "x1": "50%",
7948
+ "x2": "50%",
7949
+ "y2": "100%",
7950
+ "id": getId(5)
7951
+ }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
7952
+ "x1": "95%",
7953
+ "y1": "48%",
7954
+ "x2": "5.5%",
7955
+ "y2": "51%",
7956
+ "id": getId(6)
7957
+ }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
7958
+ "y1": "45%",
7959
+ "x2": "100%",
7960
+ "y2": "54%",
7961
+ "id": getId(7)
7962
+ }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
7963
+ "transform": "translate(36 50)",
7964
+ "fill": "none"
7965
+ }, [vue.createVNode("g", {
7966
+ "transform": "translate(8)"
7967
+ }, [vue.createVNode("rect", {
7968
+ "fill": "#EBEDF0",
7969
+ "opacity": ".6",
7970
+ "x": "38",
7971
+ "y": "13",
7972
+ "width": "36",
7973
+ "height": "53",
7974
+ "rx": "2"
7975
+ }, null), vue.createVNode("rect", {
7976
+ "fill": useId(5),
7977
+ "width": "64",
7978
+ "height": "66",
7979
+ "rx": "2"
7980
+ }, null), vue.createVNode("rect", {
7981
+ "fill": "#FFF",
7982
+ "x": "6",
7983
+ "y": "6",
7984
+ "width": "52",
7985
+ "height": "55",
7986
+ "rx": "1"
7987
+ }, null), vue.createVNode("g", {
7988
+ "transform": "translate(15 17)",
7989
+ "fill": useId(6)
7990
+ }, [vue.createVNode("rect", {
7991
+ "width": "34",
7992
+ "height": "6",
7993
+ "rx": "1"
7994
+ }, null), vue.createVNode("path", {
7995
+ "d": "M0 14h34v6H0z"
7996
+ }, null), vue.createVNode("rect", {
7997
+ "y": "28",
7998
+ "width": "34",
7999
+ "height": "6",
8000
+ "rx": "1"
8001
+ }, null)])]), vue.createVNode("rect", {
8002
+ "fill": useId(7),
8003
+ "y": "61",
8004
+ "width": "88",
8005
+ "height": "28",
8006
+ "rx": "1"
8007
+ }, null), vue.createVNode("rect", {
8008
+ "fill": "#F7F8FA",
8009
+ "x": "29",
8010
+ "y": "72",
8011
+ "width": "30",
8012
+ "height": "6",
8013
+ "rx": "1"
8014
+ }, null)])]);
8015
+ const renderError = () => vue.createVNode("svg", {
8016
+ "viewBox": "0 0 160 160"
8017
+ }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
8018
+ "x1": "50%",
8019
+ "x2": "50%",
8020
+ "y2": "100%",
8021
+ "id": getId(8)
8022
+ }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
8023
+ "d": "m59 60 21 21 21-21h3l9 9v3L92 93l21 21v3l-9 9h-3l-21-21-21 21h-3l-9-9v-3l21-21-21-21v-3l9-9h3Z",
8024
+ "fill": useId(8)
8025
+ }, null)]);
8026
+ const renderSearch = () => vue.createVNode("svg", {
8027
+ "viewBox": "0 0 160 160"
8028
+ }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
8029
+ "x1": "50%",
8030
+ "y1": "100%",
8031
+ "x2": "50%",
8032
+ "id": getId(9)
8033
+ }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
8034
+ "x1": "100%",
8035
+ "y1": "50%",
8036
+ "y2": "50%",
8037
+ "id": getId(10)
8038
+ }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
8039
+ "x1": "50%",
8040
+ "x2": "50%",
8041
+ "y2": "100%",
8042
+ "id": getId(11)
8043
+ }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
8044
+ "x1": "50%",
8045
+ "x2": "50%",
8046
+ "y2": "100%",
8047
+ "id": getId(12)
8048
+ }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
8049
+ "transform": "rotate(-45 113 -4)",
8050
+ "fill": "none"
8051
+ }, [vue.createVNode("rect", {
8052
+ "fill": useId(9),
8053
+ "x": "24",
8054
+ "y": "52.8",
8055
+ "width": "5.8",
8056
+ "height": "19",
8057
+ "rx": "1"
8058
+ }, null), vue.createVNode("rect", {
8059
+ "fill": useId(10),
8060
+ "x": "22.1",
8061
+ "y": "67.3",
8062
+ "width": "9.9",
8063
+ "height": "28",
8064
+ "rx": "1"
8065
+ }, null), vue.createVNode("circle", {
8066
+ "stroke": useId(11),
8067
+ "stroke-width": "8",
8068
+ "cx": "27",
8069
+ "cy": "27",
8070
+ "r": "27"
8071
+ }, null), vue.createVNode("circle", {
8072
+ "fill": useId(12),
8073
+ "cx": "27",
8074
+ "cy": "27",
8075
+ "r": "16"
8076
+ }, null), vue.createVNode("path", {
8077
+ "d": "M37 7c-8 0-15 5-16 12",
8078
+ "stroke": useId(11),
8079
+ "stroke-width": "3",
8080
+ "opacity": ".5",
8081
+ "stroke-linecap": "round",
8082
+ "transform": "rotate(45 29 13)"
8083
+ }, null)])]);
7896
8084
  const [name$D, bem$C] = createNamespace("empty");
7897
- const PRESET_IMAGES = ["error", "search", "default"];
8085
+ const PRESET_IMAGES = {
8086
+ error: renderError,
8087
+ search: renderSearch,
8088
+ network: renderNetwork,
8089
+ default: renderMaterial
8090
+ };
7898
8091
  const emptyProps = {
7899
8092
  image: makeStringProp("default"),
7900
8093
  imageSize: [Number, String, Array],
@@ -7907,20 +8100,12 @@
7907
8100
  slots
7908
8101
  }) {
7909
8102
  const renderImage = () => {
8103
+ var _a;
7910
8104
  if (slots.image) {
7911
8105
  return slots.image();
7912
8106
  }
7913
- let {
7914
- image
7915
- } = props;
7916
- if (image === "network") {
7917
- return Network;
7918
- }
7919
- if (PRESET_IMAGES.includes(image)) {
7920
- image = `https://img.yzcdn.cn/vant/empty-image-${image}.png`;
7921
- }
7922
- return vue.createVNode("img", {
7923
- "src": image
8107
+ return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
8108
+ "src": props.image
7924
8109
  }, null);
7925
8110
  };
7926
8111
  const renderDescription = () => {
@@ -8545,7 +8730,7 @@
8545
8730
  setup(props, {
8546
8731
  slots
8547
8732
  }) {
8548
- const id = useId();
8733
+ const id = useId$1();
8549
8734
  const root = vue.ref();
8550
8735
  const barRef = vue.ref();
8551
8736
  const offset2 = vue.ref(0);
@@ -12226,7 +12411,7 @@
12226
12411
  slots,
12227
12412
  attrs
12228
12413
  }) {
12229
- const id = useId();
12414
+ const id = useId$1();
12230
12415
  const filedRef = vue.ref();
12231
12416
  const onCancel = () => {
12232
12417
  if (!slots.action) {
@@ -13844,7 +14029,6 @@
13844
14029
  });
13845
14030
  const TreeSelect = withInstall(stdin_default$6);
13846
14031
  const [name, bem, t] = createNamespace("uploader");
13847
- const toArray = (item) => Array.isArray(item) ? item : [item];
13848
14032
  function readFileContent(file, resultType) {
13849
14033
  return new Promise((resolve) => {
13850
14034
  if (resultType === "file") {
@@ -15103,7 +15287,7 @@
15103
15287
  });
15104
15288
  }
15105
15289
  };
15106
- const version = "4.0.0-alpha.2";
15290
+ const version = "4.0.0-alpha.3";
15107
15291
  function install(app) {
15108
15292
  const components = [
15109
15293
  ActionBar,