vant 3.5.4 → 3.6.0

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 (78) hide show
  1. package/README.md +4 -0
  2. package/changelog.generated.md +33 -2
  3. package/es/badge/Badge.mjs +1 -1
  4. package/es/calendar/Calendar.mjs +3 -4
  5. package/es/composables/use-global-z-index.d.ts +4 -0
  6. package/es/composables/use-global-z-index.mjs +9 -0
  7. package/es/composables/use-height.mjs +2 -0
  8. package/es/composables/use-lock-scroll.mjs +3 -1
  9. package/es/config-provider/ConfigProvider.d.ts +3 -0
  10. package/es/config-provider/ConfigProvider.mjs +8 -1
  11. package/es/config-provider/index.d.ts +2 -0
  12. package/es/empty/Empty.d.ts +1 -1
  13. package/es/empty/Empty.mjs +281 -16
  14. package/es/field/Field.mjs +4 -1
  15. package/es/field/types.d.ts +1 -0
  16. package/es/field/utils.d.ts +1 -0
  17. package/es/field/utils.mjs +8 -2
  18. package/es/index.d.ts +2 -1
  19. package/es/index.mjs +4 -1
  20. package/es/popover/Popover.mjs +11 -9
  21. package/es/popup/Popup.mjs +6 -5
  22. package/es/pull-refresh/PullRefresh.mjs +10 -3
  23. package/es/search/index.css +1 -1
  24. package/es/search/index.less +3 -1
  25. package/es/space/Space.d.ts +48 -0
  26. package/es/space/Space.mjs +87 -0
  27. package/es/space/index.css +1 -0
  28. package/es/space/index.d.ts +37 -0
  29. package/es/space/index.less +38 -0
  30. package/es/space/index.mjs +8 -0
  31. package/es/space/style/index.d.ts +1 -0
  32. package/es/space/style/index.mjs +2 -0
  33. package/es/space/style/less.d.ts +1 -0
  34. package/es/space/style/less.mjs +2 -0
  35. package/lib/badge/Badge.js +1 -1
  36. package/lib/calendar/Calendar.js +3 -4
  37. package/lib/composables/use-global-z-index.d.ts +4 -0
  38. package/lib/composables/use-global-z-index.js +28 -0
  39. package/lib/composables/use-height.js +2 -0
  40. package/lib/composables/use-lock-scroll.js +3 -1
  41. package/lib/config-provider/ConfigProvider.d.ts +3 -0
  42. package/lib/config-provider/ConfigProvider.js +7 -0
  43. package/lib/config-provider/index.d.ts +2 -0
  44. package/lib/empty/Empty.d.ts +1 -1
  45. package/lib/empty/Empty.js +281 -16
  46. package/lib/field/Field.js +3 -0
  47. package/lib/field/types.d.ts +1 -0
  48. package/lib/field/utils.d.ts +1 -0
  49. package/lib/field/utils.js +8 -2
  50. package/lib/index.css +1 -1
  51. package/lib/index.d.ts +2 -1
  52. package/lib/index.js +4 -1
  53. package/lib/index.less +1 -0
  54. package/lib/popover/Popover.js +10 -8
  55. package/lib/popup/Popup.js +6 -5
  56. package/lib/pull-refresh/PullRefresh.js +9 -2
  57. package/lib/search/index.css +1 -1
  58. package/lib/search/index.less +3 -1
  59. package/lib/space/Space.d.ts +48 -0
  60. package/lib/space/Space.js +106 -0
  61. package/lib/space/index.css +1 -0
  62. package/lib/space/index.d.ts +37 -0
  63. package/lib/space/index.js +30 -0
  64. package/lib/space/index.less +38 -0
  65. package/lib/space/style/index.d.ts +1 -0
  66. package/lib/space/style/index.js +2 -0
  67. package/lib/space/style/less.d.ts +1 -0
  68. package/lib/space/style/less.js +2 -0
  69. package/lib/vant.cjs.js +1170 -1055
  70. package/lib/vant.es.js +1171 -1056
  71. package/lib/vant.js +1176 -1057
  72. package/lib/vant.min.js +1 -1
  73. package/lib/web-types.json +1042 -970
  74. package/package.json +2 -2
  75. package/es/empty/Images.d.ts +0 -4
  76. package/es/empty/Images.mjs +0 -271
  77. package/lib/empty/Images.d.ts +0 -4
  78. package/lib/empty/Images.js +0 -290
package/README.md CHANGED
@@ -67,10 +67,14 @@ pnpm add vant
67
67
 
68
68
  ```js
69
69
  import { createApp } from 'vue';
70
+ // 1. Import the components you need
70
71
  import { Button } from 'vant';
72
+ // 2. Import the components style
71
73
  import 'vant/lib/index.css';
72
74
 
73
75
  const app = createApp();
76
+
77
+ // 3. Register the components you need
74
78
  app.use(Button);
75
79
  ```
76
80
 
@@ -1,14 +1,45 @@
1
- ### [v3.5.4](https://github.com/vant-ui/vant/compare/v3.5.3...v3.5.4)
1
+ ### [v3.6.0](https://github.com/vant-ui/vant/compare/v3.5.3...v3.6.0)
2
2
 
3
- `2022-08-06`
3
+ `2022-08-21`
4
4
 
5
5
  **Bug Fixes**
6
6
 
7
7
  - @vant/cli: should replace NODE_ENV in vite v3 [#10887](https://github.com/vant-ui/vant/issues/10887)
8
+ - Calendar: content disappeared when hiding [#10910](https://github.com/vant-ui/vant/issues/10910)
9
+ - Calendar: fix reading getFullYear error [#10908](https://github.com/vant-ui/vant/issues/10908)
10
+ - Calendar: reading getFullYear error in some cases [#10909](https://github.com/vant-ui/vant/issues/10909)
11
+ - Empty: generate unique id to avoid render issue [#10943](https://github.com/vant-ui/vant/issues/10943)
12
+ - incorrect tag name in WebStorm [#10946](https://github.com/vant-ui/vant/issues/10946)
13
+ - Popover: can not scroll inside popup [#10949](https://github.com/vant-ui/vant/issues/10949)
14
+ - PullRefresh: remove passive event warning [#10938](https://github.com/vant-ui/vant/issues/10938)
15
+ - Search: --van-search-input-height var not work [#10911](https://github.com/vant-ui/vant/issues/10911)
8
16
 
9
17
  **Document**
10
18
 
19
+ - add import tips [#10941](https://github.com/vant-ui/vant/issues/10941)
20
+ - add tips in advanced-usage.zh-CN.md [#10927](https://github.com/vant-ui/vant/issues/10927)
21
+ - changelog: 3.5.4 [961f70](https://github.com/vant-ui/vant/commit/961f70d523b723c864d99dceb2be1a19ec506d03)
11
22
  - changelog: vant@3.5.3 [#10869](https://github.com/vant-ui/vant/issues/10869)
23
+ - Form: fix the type of rule trigger option [#10912](https://github.com/vant-ui/vant/issues/10912)
24
+ - import quick start document [#10945](https://github.com/vant-ui/vant/issues/10945)
25
+ - Search: fix action-text type [#10936](https://github.com/vant-ui/vant/issues/10936)
26
+ - Search: fix action-text type [#10935](https://github.com/vant-ui/vant/issues/10935)
27
+ - Space: add version tip [#10886](https://github.com/vant-ui/vant/issues/10886)
28
+
29
+ **Feature**
30
+
31
+ - @vant/use: useClickAway support multiple targets [#10948](https://github.com/vant-ui/vant/issues/10948)
32
+ - Badge: fix the problem mentioned at README. [#10921](https://github.com/vant-ui/vant/issues/10921)
33
+ - ConfigProvider: add z-index prop [#10915](https://github.com/vant-ui/vant/issues/10915)
34
+ - Form: add validateEmpty option of rule [#10913](https://github.com/vant-ui/vant/issues/10913)
35
+ - Popup: add role and tabindex for a11y [#10894](https://github.com/vant-ui/vant/issues/10894)
36
+ - Space: add new component space [#10857](https://github.com/vant-ui/vant/issues/10857)
37
+ - touch-emulator: support .mjs extension [#10888](https://github.com/vant-ui/vant/issues/10888)
38
+
39
+ **release**
40
+
41
+ - @vant/use 1.4.2 [326880](https://github.com/vant-ui/vant/commit/326880a4e19f8ab8ffe6042a8cc968cc03b02616)
42
+ - 3.5.4 [cfdb5c](https://github.com/vant-ui/vant/commit/cfdb5c1fbe496f6a064ab8bebe7f1ae8734490c0)
12
43
  ### [v3.5.3](https://github.com/vant-ui/vant/compare/v3.5.2...v3.5.3)
13
44
 
14
45
  `2022-07-31`
@@ -26,7 +26,7 @@ var stdin_default = defineComponent({
26
26
  content,
27
27
  showZero
28
28
  } = props;
29
- return isDef(content) && content !== "" && (showZero || content !== 0);
29
+ return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
30
30
  };
31
31
  const renderContent = () => {
32
32
  const {
@@ -112,9 +112,6 @@ var stdin_default = defineComponent({
112
112
  const months = computed(() => {
113
113
  const months2 = [];
114
114
  const cursor = new Date(props.minDate);
115
- if (props.lazyRender && !props.show && props.poppable) {
116
- return months2;
117
- }
118
115
  cursor.setDate(1);
119
116
  do {
120
117
  months2.push(new Date(cursor));
@@ -192,7 +189,9 @@ var stdin_default = defineComponent({
192
189
  }
193
190
  if (currentDate.value) {
194
191
  const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
195
- scrollToDate(targetDate);
192
+ if (isDate(targetDate)) {
193
+ scrollToDate(targetDate);
194
+ }
196
195
  } else {
197
196
  raf(onScroll);
198
197
  }
@@ -0,0 +1,4 @@
1
+ /** the global z-index is automatically incremented after reading */
2
+ export declare const useGlobalZIndex: () => number;
3
+ /** reset the global z-index */
4
+ export declare const setGlobalZIndex: (val: number) => void;
@@ -0,0 +1,9 @@
1
+ let globalZIndex = 2e3;
2
+ const useGlobalZIndex = () => ++globalZIndex;
3
+ const setGlobalZIndex = (val) => {
4
+ globalZIndex = val;
5
+ };
6
+ export {
7
+ setGlobalZIndex,
8
+ useGlobalZIndex
9
+ };
@@ -1,5 +1,6 @@
1
1
  import { useRect } from "@vant/use";
2
2
  import { ref, onMounted, nextTick } from "vue";
3
+ import { onPopupReopen } from "./on-popup-reopen.mjs";
3
4
  const useHeight = (element, withSafeArea) => {
4
5
  const height = ref();
5
6
  const setHeight = () => {
@@ -13,6 +14,7 @@ const useHeight = (element, withSafeArea) => {
13
14
  }
14
15
  }
15
16
  });
17
+ onPopupReopen(() => nextTick(setHeight));
16
18
  return height;
17
19
  };
18
20
  export {
@@ -6,9 +6,11 @@ let totalLockCount = 0;
6
6
  const BODY_LOCK_CLASS = "van-overflow-hidden";
7
7
  function useLockScroll(rootRef, shouldLock) {
8
8
  const touch = useTouch();
9
+ const DIRECTION_UP = "01";
10
+ const DIRECTION_DOWN = "10";
9
11
  const onTouchMove = (event) => {
10
12
  touch.move(event);
11
- const direction = touch.deltaY.value > 0 ? "10" : "01";
13
+ const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
12
14
  const el = getScrollParent(event.target, rootRef.value);
13
15
  const { scrollHeight, offsetHeight, scrollTop } = el;
14
16
  let status = "11";
@@ -9,6 +9,7 @@ declare const configProviderProps: {
9
9
  type: PropType<keyof HTMLElementTagNameMap>;
10
10
  default: keyof HTMLElementTagNameMap;
11
11
  };
12
+ zIndex: NumberConstructor;
12
13
  themeVars: PropType<Record<string, Numeric>>;
13
14
  iconPrefix: StringConstructor;
14
15
  };
@@ -18,6 +19,7 @@ declare const _default: import("vue").DefineComponent<{
18
19
  type: PropType<keyof HTMLElementTagNameMap>;
19
20
  default: keyof HTMLElementTagNameMap;
20
21
  };
22
+ zIndex: NumberConstructor;
21
23
  themeVars: PropType<Record<string, Numeric>>;
22
24
  iconPrefix: StringConstructor;
23
25
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
@@ -25,6 +27,7 @@ declare const _default: import("vue").DefineComponent<{
25
27
  type: PropType<keyof HTMLElementTagNameMap>;
26
28
  default: keyof HTMLElementTagNameMap;
27
29
  };
30
+ zIndex: NumberConstructor;
28
31
  themeVars: PropType<Record<string, Numeric>>;
29
32
  iconPrefix: StringConstructor;
30
33
  }>>, {
@@ -1,10 +1,12 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
- import { provide, computed, defineComponent } from "vue";
2
+ import { provide, computed, watchEffect, defineComponent } from "vue";
3
3
  import { kebabCase, makeStringProp, createNamespace } from "../utils/index.mjs";
4
+ import { setGlobalZIndex } from "../composables/use-global-z-index.mjs";
4
5
  const [name, bem] = createNamespace("config-provider");
5
6
  const CONFIG_PROVIDER_KEY = Symbol(name);
6
7
  const configProviderProps = {
7
8
  tag: makeStringProp("div"),
9
+ zIndex: Number,
8
10
  themeVars: Object,
9
11
  iconPrefix: String
10
12
  };
@@ -27,6 +29,11 @@ var stdin_default = defineComponent({
27
29
  }
28
30
  });
29
31
  provide(CONFIG_PROVIDER_KEY, props);
32
+ watchEffect(() => {
33
+ if (props.zIndex !== void 0) {
34
+ setGlobalZIndex(props.zIndex);
35
+ }
36
+ });
30
37
  return () => _createVNode(props.tag, {
31
38
  "class": bem(),
32
39
  "style": style.value
@@ -3,6 +3,7 @@ export declare const ConfigProvider: import("../utils").WithInstall<import("vue"
3
3
  type: import("vue").PropType<keyof HTMLElementTagNameMap>;
4
4
  default: keyof HTMLElementTagNameMap;
5
5
  };
6
+ zIndex: NumberConstructor;
6
7
  themeVars: import("vue").PropType<Record<string, import("../utils").Numeric>>;
7
8
  iconPrefix: StringConstructor;
8
9
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -10,6 +11,7 @@ export declare const ConfigProvider: import("../utils").WithInstall<import("vue"
10
11
  type: import("vue").PropType<keyof HTMLElementTagNameMap>;
11
12
  default: keyof HTMLElementTagNameMap;
12
13
  };
14
+ zIndex: NumberConstructor;
13
15
  themeVars: import("vue").PropType<Record<string, import("../utils").Numeric>>;
14
16
  iconPrefix: StringConstructor;
15
17
  }>>, {
@@ -1,4 +1,4 @@
1
- import { PropType, type ExtractPropTypes } from 'vue';
1
+ import { type PropType, type ExtractPropTypes } from 'vue';
2
2
  import { Numeric } from '../utils';
3
3
  declare const emptyProps: {
4
4
  image: {
@@ -1,14 +1,8 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import { defineComponent } from "vue";
3
+ import { useId } from "../composables/use-id.mjs";
3
4
  import { getSizeStyle, makeStringProp, createNamespace } from "../utils/index.mjs";
4
- import { renderError, renderSearch, renderNetwork, renderMaterial } from "./Images.mjs";
5
5
  const [name, bem] = createNamespace("empty");
6
- const PRESET_IMAGES = {
7
- error: renderError,
8
- search: renderSearch,
9
- network: renderNetwork,
10
- default: renderMaterial
11
- };
12
6
  const emptyProps = {
13
7
  image: makeStringProp("default"),
14
8
  imageSize: [Number, String, Array],
@@ -20,15 +14,6 @@ var stdin_default = defineComponent({
20
14
  setup(props, {
21
15
  slots
22
16
  }) {
23
- const renderImage = () => {
24
- var _a;
25
- if (slots.image) {
26
- return slots.image();
27
- }
28
- return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || _createVNode("img", {
29
- "src": props.image
30
- }, null);
31
- };
32
17
  const renderDescription = () => {
33
18
  const description = slots.description ? slots.description() : props.description;
34
19
  if (description) {
@@ -44,6 +29,286 @@ var stdin_default = defineComponent({
44
29
  }, [slots.default()]);
45
30
  }
46
31
  };
32
+ const baseId = useId();
33
+ const getId = (num) => `${baseId}-${num}`;
34
+ const getUrlById = (num) => `url(#${getId(num)})`;
35
+ const renderStop = (color, offset, opacity) => _createVNode("stop", {
36
+ "stop-color": color,
37
+ "offset": `${offset}%`,
38
+ "stop-opacity": opacity
39
+ }, null);
40
+ const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
41
+ const renderShadow = (id) => [_createVNode("defs", null, [_createVNode("radialGradient", {
42
+ "id": getId(id),
43
+ "cx": "50%",
44
+ "cy": "54%",
45
+ "fx": "50%",
46
+ "fy": "54%",
47
+ "r": "297%",
48
+ "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
49
+ }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), _createVNode("ellipse", {
50
+ "fill": getUrlById(id),
51
+ "opacity": ".8",
52
+ "cx": "80",
53
+ "cy": "140",
54
+ "rx": "46",
55
+ "ry": "8"
56
+ }, null)];
57
+ const renderBuilding = () => [_createVNode("defs", null, [_createVNode("linearGradient", {
58
+ "id": getId("a"),
59
+ "x1": "64%",
60
+ "y1": "100%",
61
+ "x2": "64%"
62
+ }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), _createVNode("g", {
63
+ "opacity": ".8"
64
+ }, [_createVNode("path", {
65
+ "d": "M36 131V53H16v20H2v58h34z",
66
+ "fill": getUrlById("a")
67
+ }, null), _createVNode("path", {
68
+ "d": "M123 15h22v14h9v77h-31V15z",
69
+ "fill": getUrlById("a")
70
+ }, null)])];
71
+ const renderCloud = () => [_createVNode("defs", null, [_createVNode("linearGradient", {
72
+ "id": getId("b"),
73
+ "x1": "64%",
74
+ "y1": "97%",
75
+ "x2": "64%",
76
+ "y2": "0%"
77
+ }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), _createVNode("g", {
78
+ "opacity": ".8"
79
+ }, [_createVNode("path", {
80
+ "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",
81
+ "fill": getUrlById("b")
82
+ }, null), _createVNode("path", {
83
+ "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",
84
+ "fill": getUrlById("b")
85
+ }, null)])];
86
+ const renderNetwork = () => _createVNode("svg", {
87
+ "viewBox": "0 0 160 160"
88
+ }, [_createVNode("defs", null, [_createVNode("linearGradient", {
89
+ "id": getId(1),
90
+ "x1": "64%",
91
+ "y1": "100%",
92
+ "x2": "64%"
93
+ }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), _createVNode("linearGradient", {
94
+ "id": getId(2),
95
+ "x1": "50%",
96
+ "x2": "50%",
97
+ "y2": "84%"
98
+ }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), _createVNode("linearGradient", {
99
+ "id": getId(3),
100
+ "x1": "100%",
101
+ "x2": "100%",
102
+ "y2": "100%"
103
+ }, [renderStops("#EAEDF0", "#DCDEE0")]), _createVNode("radialGradient", {
104
+ "id": getId(4),
105
+ "cx": "50%",
106
+ "cy": "0%",
107
+ "fx": "50%",
108
+ "fy": "0%",
109
+ "r": "100%",
110
+ "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
111
+ }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), _createVNode("g", {
112
+ "fill": "none"
113
+ }, [renderBuilding(), _createVNode("path", {
114
+ "fill": getUrlById(4),
115
+ "d": "M0 139h160v21H0z"
116
+ }, null), _createVNode("path", {
117
+ "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
118
+ "fill": getUrlById(2)
119
+ }, null), _createVNode("g", {
120
+ "opacity": ".6",
121
+ "stroke-linecap": "round",
122
+ "stroke-width": "7"
123
+ }, [_createVNode("path", {
124
+ "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
125
+ "stroke": getUrlById(3)
126
+ }, null), _createVNode("path", {
127
+ "d": "M53 36a34 34 0 0 0 0 48",
128
+ "stroke": getUrlById(3)
129
+ }, null), _createVNode("path", {
130
+ "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
131
+ "stroke": getUrlById(3)
132
+ }, null), _createVNode("path", {
133
+ "d": "M106 84a34 34 0 0 0 0-48",
134
+ "stroke": getUrlById(3)
135
+ }, null)]), _createVNode("g", {
136
+ "transform": "translate(31 105)"
137
+ }, [_createVNode("rect", {
138
+ "fill": "#EBEDF0",
139
+ "width": "98",
140
+ "height": "34",
141
+ "rx": "2"
142
+ }, null), _createVNode("rect", {
143
+ "fill": "#FFF",
144
+ "x": "9",
145
+ "y": "8",
146
+ "width": "80",
147
+ "height": "18",
148
+ "rx": "1.1"
149
+ }, null), _createVNode("rect", {
150
+ "fill": "#EBEDF0",
151
+ "x": "15",
152
+ "y": "12",
153
+ "width": "18",
154
+ "height": "6",
155
+ "rx": "1.1"
156
+ }, null)])])]);
157
+ const renderMaterial = () => _createVNode("svg", {
158
+ "viewBox": "0 0 160 160"
159
+ }, [_createVNode("defs", null, [_createVNode("linearGradient", {
160
+ "x1": "50%",
161
+ "x2": "50%",
162
+ "y2": "100%",
163
+ "id": getId(5)
164
+ }, [renderStops("#F2F3F5", "#DCDEE0")]), _createVNode("linearGradient", {
165
+ "x1": "95%",
166
+ "y1": "48%",
167
+ "x2": "5.5%",
168
+ "y2": "51%",
169
+ "id": getId(6)
170
+ }, [renderStops("#EAEDF1", "#DCDEE0")]), _createVNode("linearGradient", {
171
+ "y1": "45%",
172
+ "x2": "100%",
173
+ "y2": "54%",
174
+ "id": getId(7)
175
+ }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), _createVNode("g", {
176
+ "transform": "translate(36 50)",
177
+ "fill": "none"
178
+ }, [_createVNode("g", {
179
+ "transform": "translate(8)"
180
+ }, [_createVNode("rect", {
181
+ "fill": "#EBEDF0",
182
+ "opacity": ".6",
183
+ "x": "38",
184
+ "y": "13",
185
+ "width": "36",
186
+ "height": "53",
187
+ "rx": "2"
188
+ }, null), _createVNode("rect", {
189
+ "fill": getUrlById(5),
190
+ "width": "64",
191
+ "height": "66",
192
+ "rx": "2"
193
+ }, null), _createVNode("rect", {
194
+ "fill": "#FFF",
195
+ "x": "6",
196
+ "y": "6",
197
+ "width": "52",
198
+ "height": "55",
199
+ "rx": "1"
200
+ }, null), _createVNode("g", {
201
+ "transform": "translate(15 17)",
202
+ "fill": getUrlById(6)
203
+ }, [_createVNode("rect", {
204
+ "width": "34",
205
+ "height": "6",
206
+ "rx": "1"
207
+ }, null), _createVNode("path", {
208
+ "d": "M0 14h34v6H0z"
209
+ }, null), _createVNode("rect", {
210
+ "y": "28",
211
+ "width": "34",
212
+ "height": "6",
213
+ "rx": "1"
214
+ }, null)])]), _createVNode("rect", {
215
+ "fill": getUrlById(7),
216
+ "y": "61",
217
+ "width": "88",
218
+ "height": "28",
219
+ "rx": "1"
220
+ }, null), _createVNode("rect", {
221
+ "fill": "#F7F8FA",
222
+ "x": "29",
223
+ "y": "72",
224
+ "width": "30",
225
+ "height": "6",
226
+ "rx": "1"
227
+ }, null)])]);
228
+ const renderError = () => _createVNode("svg", {
229
+ "viewBox": "0 0 160 160"
230
+ }, [_createVNode("defs", null, [_createVNode("linearGradient", {
231
+ "x1": "50%",
232
+ "x2": "50%",
233
+ "y2": "100%",
234
+ "id": getId(8)
235
+ }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), _createVNode("path", {
236
+ "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",
237
+ "fill": getUrlById(8)
238
+ }, null)]);
239
+ const renderSearch = () => _createVNode("svg", {
240
+ "viewBox": "0 0 160 160"
241
+ }, [_createVNode("defs", null, [_createVNode("linearGradient", {
242
+ "x1": "50%",
243
+ "y1": "100%",
244
+ "x2": "50%",
245
+ "id": getId(9)
246
+ }, [renderStops("#EEE", "#D8D8D8")]), _createVNode("linearGradient", {
247
+ "x1": "100%",
248
+ "y1": "50%",
249
+ "y2": "50%",
250
+ "id": getId(10)
251
+ }, [renderStops("#F2F3F5", "#DCDEE0")]), _createVNode("linearGradient", {
252
+ "x1": "50%",
253
+ "x2": "50%",
254
+ "y2": "100%",
255
+ "id": getId(11)
256
+ }, [renderStops("#F2F3F5", "#DCDEE0")]), _createVNode("linearGradient", {
257
+ "x1": "50%",
258
+ "x2": "50%",
259
+ "y2": "100%",
260
+ "id": getId(12)
261
+ }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), _createVNode("g", {
262
+ "transform": "rotate(-45 113 -4)",
263
+ "fill": "none"
264
+ }, [_createVNode("rect", {
265
+ "fill": getUrlById(9),
266
+ "x": "24",
267
+ "y": "52.8",
268
+ "width": "5.8",
269
+ "height": "19",
270
+ "rx": "1"
271
+ }, null), _createVNode("rect", {
272
+ "fill": getUrlById(10),
273
+ "x": "22.1",
274
+ "y": "67.3",
275
+ "width": "9.9",
276
+ "height": "28",
277
+ "rx": "1"
278
+ }, null), _createVNode("circle", {
279
+ "stroke": getUrlById(11),
280
+ "stroke-width": "8",
281
+ "cx": "27",
282
+ "cy": "27",
283
+ "r": "27"
284
+ }, null), _createVNode("circle", {
285
+ "fill": getUrlById(12),
286
+ "cx": "27",
287
+ "cy": "27",
288
+ "r": "16"
289
+ }, null), _createVNode("path", {
290
+ "d": "M37 7c-8 0-15 5-16 12",
291
+ "stroke": getUrlById(11),
292
+ "stroke-width": "3",
293
+ "opacity": ".5",
294
+ "stroke-linecap": "round",
295
+ "transform": "rotate(45 29 13)"
296
+ }, null)])]);
297
+ const renderImage = () => {
298
+ var _a;
299
+ if (slots.image) {
300
+ return slots.image();
301
+ }
302
+ const PRESET_IMAGES = {
303
+ error: renderError,
304
+ search: renderSearch,
305
+ network: renderNetwork,
306
+ default: renderMaterial
307
+ };
308
+ return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || _createVNode("img", {
309
+ "src": props.image
310
+ }, null);
311
+ };
47
312
  return () => _createVNode("div", {
48
313
  "class": bem()
49
314
  }, [_createVNode("div", {
@@ -1,7 +1,7 @@
1
1
  import { createTextVNode as _createTextVNode, mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
2
2
  import { ref, watch, provide, computed, nextTick, reactive, onMounted, defineComponent } from "vue";
3
3
  import { isDef, extend, addUnit, toArray, FORM_KEY, numericProp, unknownProp, resetScroll, formatNumber, preventDefault, makeStringProp, makeNumericProp, createNamespace } from "../utils/index.mjs";
4
- import { cutString, runSyncRule, endComposing, mapInputType, startComposing, getRuleMessage, resizeTextarea, getStringLength, runRuleValidator } from "./utils.mjs";
4
+ import { cutString, runSyncRule, endComposing, mapInputType, isEmptyValue, startComposing, getRuleMessage, resizeTextarea, getStringLength, runRuleValidator } from "./utils.mjs";
5
5
  import { cellSharedProps } from "../cell/Cell.mjs";
6
6
  import { CUSTOM_FIELD_INJECTION_KEY, useParent } from "@vant/use";
7
7
  import { useId } from "../composables/use-id.mjs";
@@ -117,6 +117,9 @@ var stdin_default = defineComponent({
117
117
  return;
118
118
  }
119
119
  if (rule.validator) {
120
+ if (isEmptyValue(value) && rule.validateEmpty === false) {
121
+ return;
122
+ }
120
123
  return runRuleValidator(value, rule).then((result) => {
121
124
  if (result && typeof result === "string") {
122
125
  state.status = "failed";
@@ -23,6 +23,7 @@ export declare type FieldRule = {
23
23
  required?: boolean;
24
24
  validator?: FieldRuleValidator;
25
25
  formatter?: FiledRuleFormatter;
26
+ validateEmpty?: boolean;
26
27
  };
27
28
  export declare type FieldValidationStatus = 'passed' | 'failed' | 'unvalidated';
28
29
  export declare type FieldFormSharedProps = 'colon' | 'disabled' | 'readonly' | 'labelWidth' | 'labelAlign' | 'inputAlign' | 'errorMessageAlign';
@@ -1,5 +1,6 @@
1
1
  import { HTMLAttributes, InputHTMLAttributes } from 'vue';
2
2
  import type { FieldRule, FieldType, FieldAutosizeConfig } from './types';
3
+ export declare function isEmptyValue(value: unknown): boolean;
3
4
  export declare function runSyncRule(value: unknown, rule: FieldRule): boolean;
4
5
  export declare function runRuleValidator(value: unknown, rule: FieldRule): Promise<unknown>;
5
6
  export declare function getRuleMessage(value: unknown, rule: FieldRule): string;
@@ -15,8 +15,13 @@ function isEmptyValue(value) {
15
15
  return !value;
16
16
  }
17
17
  function runSyncRule(value, rule) {
18
- if (rule.required && isEmptyValue(value)) {
19
- return false;
18
+ if (isEmptyValue(value)) {
19
+ if (rule.required) {
20
+ return false;
21
+ }
22
+ if (rule.validateEmpty === false) {
23
+ return true;
24
+ }
20
25
  }
21
26
  if (rule.pattern && !rule.pattern.test(String(value))) {
22
27
  return false;
@@ -93,6 +98,7 @@ export {
93
98
  endComposing,
94
99
  getRuleMessage,
95
100
  getStringLength,
101
+ isEmptyValue,
96
102
  mapInputType,
97
103
  resizeTextarea,
98
104
  runRuleValidator,
package/es/index.d.ts CHANGED
@@ -67,6 +67,7 @@ export * from "./sidebar";
67
67
  export * from "./sidebar-item";
68
68
  export * from "./skeleton";
69
69
  export * from "./slider";
70
+ export * from "./space";
70
71
  export * from "./step";
71
72
  export * from "./stepper";
72
73
  export * from "./steps";
@@ -90,4 +91,4 @@ declare namespace _default {
90
91
  }
91
92
  export default _default;
92
93
  export function install(app: any): void;
93
- export const version: "3.5.4";
94
+ export const version: "3.6.0";
package/es/index.mjs CHANGED
@@ -66,6 +66,7 @@ import { Sidebar } from "./sidebar/index.mjs";
66
66
  import { SidebarItem } from "./sidebar-item/index.mjs";
67
67
  import { Skeleton } from "./skeleton/index.mjs";
68
68
  import { Slider } from "./slider/index.mjs";
69
+ import { Space } from "./space/index.mjs";
69
70
  import { Step } from "./step/index.mjs";
70
71
  import { Stepper } from "./stepper/index.mjs";
71
72
  import { Steps } from "./steps/index.mjs";
@@ -83,7 +84,7 @@ import { Tag } from "./tag/index.mjs";
83
84
  import { Toast } from "./toast/index.mjs";
84
85
  import { TreeSelect } from "./tree-select/index.mjs";
85
86
  import { Uploader } from "./uploader/index.mjs";
86
- const version = "3.5.4";
87
+ const version = "3.6.0";
87
88
  function install(app) {
88
89
  const components = [
89
90
  ActionBar,
@@ -154,6 +155,7 @@ function install(app) {
154
155
  SidebarItem,
155
156
  Skeleton,
156
157
  Slider,
158
+ Space,
157
159
  Step,
158
160
  Stepper,
159
161
  Steps,
@@ -249,6 +251,7 @@ export * from "./sidebar/index.mjs";
249
251
  export * from "./sidebar-item/index.mjs";
250
252
  export * from "./skeleton/index.mjs";
251
253
  export * from "./slider/index.mjs";
254
+ export * from "./space/index.mjs";
252
255
  export * from "./step/index.mjs";
253
256
  export * from "./stepper/index.mjs";
254
257
  export * from "./steps/index.mjs";