diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md index 50e092ae5..b04c069ed 100644 --- a/.gitee/ISSUE_TEMPLATE.zh-CN.md +++ b/.gitee/ISSUE_TEMPLATE.zh-CN.md @@ -1,3 +1,5 @@ -你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。 +注意:gitee 中为 vant 的镜像仓库,不进行 issue 处理。 -http://vant-contrib.gitee.io/vant-issue-generater +请移步 GitHub issues 进行反馈: + +https://github.com/youzan/vant/issues diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index d8e014065..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: monthly - open-pull-requests-limit: 20 diff --git a/README.md b/README.md index 1c310d914..f6e51db73 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ - 🍭 Support Vue 2 & Vue 3 - 🍭 Support Tree Shaking - 🍭 Support Custom Theme +- 🍭 Support Accessibility (still improving) - 🍭 Support i18n - 🌍 Support SSR @@ -74,10 +75,6 @@ app.use(Button); See more in [Quickstart](https://youzan.github.io/vant#/en-US/quickstart). -## Contribution - -Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md) before making a pull request. - ## Browser Support Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0. @@ -117,6 +114,26 @@ You can scan the following QR code to access the demo: +## Core Team + +Core contributors of Vant and Vant Weapp: + +| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | +| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | +| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | + +## All Contributors + +Thanks to the following friends for their contributions to Vant: + + + contributors + + +## Contribution Guide + +Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md) before making a pull request. + ## LICENSE [MIT](https://en.wikipedia.org/wiki/MIT_License) diff --git a/README.zh-CN.md b/README.zh-CN.md index fd07f8e92..03f6f2285 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -40,6 +40,7 @@ Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源 - 🍭 支持 Vue 2、Vue 3 和微信小程序 - 🍭 支持主题定制,内置 700+ 个主题变量 - 🍭 支持按需引入和 Tree Shaking +- 🍭 支持无障碍访问(持续改进中) - 🍭 支持服务器端渲染 - 🌍 支持国际化和语言包定制 @@ -78,12 +79,6 @@ app.use(Button); vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手](https://vant-contrib.gitee.io/vant#/zh-CN/quickstart). -## 贡献代码 - -修改代码请阅读我们的 [贡献指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)。 - -使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。 - ## 浏览器支持 Vant 2 支持现代浏览器以及 Android >= 4.0、iOS >= 8.0。 @@ -127,6 +122,28 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致 +## 核心团队 + +以下是 Vant 和 Vant Weapp 的核心贡献者们: + +| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | +| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | +| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | + +## 贡献者们 + +感谢以下小伙伴们为 Vant 发展做出的贡献: + + + contributors + + +## 贡献指南 + +修改代码请阅读我们的 [贡献指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)。 + +使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。 + ## 开源协议 本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。 diff --git a/package.json b/package.json index 7ab3d63b2..b83ed52ad 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "@vant/stylelint-config": "workspace:*", "eslint": "^8.2.0", "husky": "^7.0.4", - "lint-staged": "^11.2.6", - "prettier": "^2.4.1", + "lint-staged": "^12.1.2", + "prettier": "^2.5.0", "rimraf": "^3.0.2", "stylelint": "^13.13.1" } diff --git a/packages/create-vant-cli-app/package.json b/packages/create-vant-cli-app/package.json index 40aafd7c7..ae8978eb1 100644 --- a/packages/create-vant-cli-app/package.json +++ b/packages/create-vant-cli-app/package.json @@ -8,14 +8,10 @@ }, "scripts": { "dev": "tsc --watch", - "build": "tsc", + "build": "rimraf ./lib && tsc", "release": "pnpm build & release-it", "prepare": "pnpm build" }, - "repository": { - "type": "git", - "url": "https://github.com/youzan/vant/tree/dev/packages/create-vant-cli-app" - }, "files": [ "lib", "generators" @@ -26,13 +22,19 @@ "publishConfig": { "registry": "https://registry.npmjs.org/" }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/create-vant-cli-app" + }, + "bugs": "https://github.com/youzan/vant/issues", "author": "chenjiahan", "license": "MIT", "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/inquirer": "^8.1.3", "release-it": "^14.11.6", - "typescript": "4.x" + "typescript": "~4.5.2" }, "dependencies": { "chalk": "^4.1.2", diff --git a/packages/create-vant-cli-app/tsconfig.json b/packages/create-vant-cli-app/tsconfig.json index d40c806f7..738ecb181 100644 --- a/packages/create-vant-cli-app/tsconfig.json +++ b/packages/create-vant-cli-app/tsconfig.json @@ -1,13 +1,10 @@ { + "extends": "../../tsconfig", "compilerOptions": { "target": "ES2019", "outDir": "./lib", "module": "commonjs", - "strict": true, - "declaration": true, - "skipLibCheck": true, - "esModuleInterop": true, - "lib": ["esnext"] + "declaration": true }, "include": ["src/**/*"] } diff --git a/packages/vant-area-data/package.json b/packages/vant-area-data/package.json index 34920953f..54d7a255a 100644 --- a/packages/vant-area-data/package.json +++ b/packages/vant-area-data/package.json @@ -4,15 +4,21 @@ "description": "Vant 省市区数据", "main": "./lib/index.js", "typings": "./lib/index.d.ts", + "scripts": { + "build": "rimraf ./lib && tsc", + "release": "pnpm build && npm publish", + "prepare": "pnpm build" + }, "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }, - "scripts": { - "build": "tsc", - "release": "pnpm build && npm publish", - "prepare": "pnpm build" + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-area-data" }, - "license": "MIT", - "repository": "https://github.com/youzan/vant" + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", + "license": "MIT" } diff --git a/packages/vant-area-data/tsconfig.json b/packages/vant-area-data/tsconfig.json index 69369e785..12b1beb8b 100644 --- a/packages/vant-area-data/tsconfig.json +++ b/packages/vant-area-data/tsconfig.json @@ -1,13 +1,9 @@ { + "extends": "../../tsconfig", "compilerOptions": { "target": "ES2019", "outDir": "./lib", - "module": "ES2015", - "strict": true, - "declaration": true, - "skipLibCheck": true, - "esModuleInterop": true, - "lib": ["esnext"] + "declaration": true }, "include": ["src/**/*"] } diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md index 48a42ef51..590a1eed5 100644 --- a/packages/vant-cli/changelog.md +++ b/packages/vant-cli/changelog.md @@ -1,5 +1,11 @@ # 更新日志 +## v4.0.0-rc.4 + +- 新增 CommonJS 格式的构建产物,分别为 `lib/[name].cjs.js` 和 `lib/[name].cjs.min.js` +- 现在 ESModule 和 CommonJS 格式的产物会自动对外部依赖进行 external 处理 +- 修复 Windows 路径兼容问题 + ## v4.0.0-rc.3 ### 不兼容更新 @@ -286,7 +292,7 @@ yarn add sass `2020-12-01` --  升级 docsearch 3,优化搜索框样式 +- 升级 docsearch 3,优化搜索框样式 ## v3.0.0 @@ -469,7 +475,7 @@ yarn add sass `2020-01-15` -- 优化 help 命令  +- 优化 help 命令 - 优化控制台输出信息 ### v2.1.6 diff --git a/packages/vant-cli/docs/config.md b/packages/vant-cli/docs/config.md index 34aecff15..66b671709 100644 --- a/packages/vant-cli/docs/config.md +++ b/packages/vant-cli/docs/config.md @@ -1,13 +1,15 @@ # 配置指南 -- [配置指南](#) +- [配置指南](#----) - [vant.config.mjs](#vantconfigmjs) - [name](#name) - - [build.css](#buildcss) + - [build.css.base](#buildcssbase) + - [build.css.preprocessor](#buildcsspreprocessor) - [build.site.publicPath](#buildsitepublicpath) - [build.srcDir](#buildsrcdir) - [build.namedExport](#buildnamedexport) - [build.configureVite](#buildconfigurevite) + - [build.packageManager](#buildpackagemanager) - [site.title](#sitetitle) - [site.logo](#sitelogo) - [site.description](#sitedescription) @@ -18,11 +20,11 @@ - [site.hideSimulator](#sitehidesimulator) - [site.simulator.url](#sitesimulatorurl) - [site.htmlMeta](#sitehtmlmeta) + - [site.enableVConsole](#siteenablevconsole) - [Babel](#babel) - - [默认配置](#-1) - - [依赖](#-2) + - [默认配置](#----) - [Postcss](#postcss) - - [默认配置](#-3) + - [默认配置](#-----1) - [browserslist](#browserslist) ## vant.config.mjs @@ -77,14 +79,33 @@ export default { - Type: `string` - Default: `''` -组件库名称,建议使用中划线分割,如`demo-ui`。 +组件库名称,建议使用中划线分割,如 `demo-ui`。 -### build.css +### build.css.base -- Type: `object` -- Default: `{ preprocessor: 'less' }` +- Type: `string` +- Default: `'style/base.less'` -CSS 预处理器配置,目前支持`less`和`sass`两种预处理器,默认使用`less`。 +全局样式文件的路径,可以为相对路径或绝对路径。 + +相对路径基于 `src` 目录计算。 + +```js +module.exports = { + build: { + css: { + base: 'style/global.scss', + }, + }, +}; +``` + +### build.css.preprocessor + +- Type: `string` +- Default: `'less'` + +CSS 预处理器配置,目前支持 `less` 和 `sass` 两种预处理器,默认使用 `less`。 ```js module.exports = { diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json index 1378f40b4..bf7d00e87 100644 --- a/packages/vant-cli/package.json +++ b/packages/vant-cli/package.json @@ -1,6 +1,6 @@ { "name": "@vant/cli", - "version": "4.0.0-rc.3", + "version": "4.0.0-rc.4", "type": "module", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -10,13 +10,9 @@ "engines": { "node": "^14.16.0 || >=16.0.0" }, - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, "scripts": { "dev": "tsc --watch", - "build": "tsc", + "build": "rimraf ./lib && tsc", "release": "pnpm build & release-it", "prepare": "pnpm build" }, @@ -31,6 +27,16 @@ "keywords": [ "vant" ], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-cli" + }, + "bugs": "https://github.com/youzan/vant/issues", "author": "chenjiahan", "license": "MIT", "devDependencies": { @@ -42,12 +48,12 @@ "vue": "^3.2.20" }, "dependencies": { + "@types/jest": "^27.0.3", "@babel/core": "^7.16.0", "@babel/preset-env": "^7.16.0", "@babel/preset-typescript": "^7.16.0", "@docsearch/css": "3.0.0-alpha.41", "@docsearch/js": "3.0.0-alpha.41", - "@types/jest": "^27.0.2", "@vant/eslint-config": "^3.3.2", "@vant/markdown-vetur": "^2.2.0", "@vant/stylelint-config": "^1.4.2", @@ -74,19 +80,19 @@ "jest-canvas-mock": "^2.3.1", "jest-serializer-html": "^7.1.0", "less": "^4.1.2", - "lint-staged": "^11.2.6", + "lint-staged": "^12.1.2", "lodash-es": "^4.17.21", "markdown-it": "^12.2.0", "markdown-it-anchor": "^8.4.1", "ora": "^6.0.1", "postcss": "^8.3.11", "postcss-load-config": "^3.1.0", - "prettier": "^2.4.1", + "prettier": "^2.5.0", "release-it": "^14.11.6", "stylelint": "^13.0.0", "transliteration": "^2.2.0", "ts-jest": "^27.0.7", - "typescript": "^4.4.4", + "typescript": "^4.5.2", "vite": "^2.6.13", "vite-plugin-html": "^2.1.1", "vite-plugin-md": "^0.11.4", diff --git a/packages/vant-cli/site/desktop/components/Content.vue b/packages/vant-cli/site/desktop/components/Content.vue index bc1926a08..31d2af192 100644 --- a/packages/vant-cli/site/desktop/components/Content.vue +++ b/packages/vant-cli/site/desktop/components/Content.vue @@ -170,6 +170,10 @@ export default { } } + > ul { + margin: 12px 0; + } + > ul li, > ol li { position: relative; diff --git a/packages/vant-cli/src/commands/build.ts b/packages/vant-cli/src/commands/build.ts index 3b7a9b0b4..82abe9c2f 100644 --- a/packages/vant-cli/src/commands/build.ts +++ b/packages/vant-cli/src/commands/build.ts @@ -8,7 +8,7 @@ import { installDependencies } from '../common/manager.js'; import { compileSfc } from '../compiler/compile-sfc.js'; import { compileStyle } from '../compiler/compile-style.js'; import { compileScript } from '../compiler/compile-script.js'; -import { compilePackage } from '../compiler/compile-package.js'; +import { compileBundles } from '../compiler/compile-bundles.js'; import { genPackageEntry } from '../compiler/gen-package-entry.js'; import { genStyleDepsMap } from '../compiler/gen-style-deps-map.js'; import { genComponentStyle } from '../compiler/gen-component-style.js'; @@ -133,8 +133,7 @@ async function buildPackageStyleEntry() { async function buildBundledOutputs() { setModuleEnv('esmodule'); - await compilePackage(false); - await compilePackage(true); + await compileBundles(); genVeturConfig(); } diff --git a/packages/vant-cli/src/commands/jest.ts b/packages/vant-cli/src/commands/jest.ts index 6952dff42..284a95c44 100644 --- a/packages/vant-cli/src/commands/jest.ts +++ b/packages/vant-cli/src/commands/jest.ts @@ -6,8 +6,9 @@ import { JEST_CONFIG_FILE, PACKAGE_ENTRY_FILE, } from '../common/constant.js'; +import type { Config } from '@jest/types'; -export function test(command: any) { +export function test(command: Config.Argv) { setNodeEnv('test'); genPackageEntry({ @@ -26,7 +27,7 @@ export function test(command: any) { // make jest tests faster // see: https://ivantanev.com/make-jest-faster/ maxWorkers: '50%', - } as any; + } as Config.Argv; jest .runCLI(config, [ROOT]) diff --git a/packages/vant-cli/src/compiler/compile-bundles.ts b/packages/vant-cli/src/compiler/compile-bundles.ts new file mode 100644 index 000000000..0e1367fa8 --- /dev/null +++ b/packages/vant-cli/src/compiler/compile-bundles.ts @@ -0,0 +1,68 @@ +import fse from 'fs-extra'; +import { join } from 'path'; +import { build } from 'vite'; +import { getPackageJson, getVantConfig, LIB_DIR } from '../common/constant.js'; +import { mergeCustomViteConfig } from '../common/index.js'; +import { getViteConfigForPackage } from '../config/vite.package.js'; + +// generate entry file for nuxt +async function genEntryForSSR() { + const { name } = getVantConfig(); + const cjsPath = join(LIB_DIR, 'ssr.js'); + const mjsPath = join(LIB_DIR, 'ssr.mjs'); + + const cjsContent = `'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./${name}.cjs.min.js'); +} else { + module.exports = require('./${name}.cjs.js'); +}; +`; + + const mjsContent = `export * from './index.js';\n`; + + return Promise.all([ + fse.outputFile(cjsPath, cjsContent), + fse.outputFile(mjsPath, mjsContent), + ]); +} + +export async function compileBundles() { + const dependencies = getPackageJson().dependencies || {}; + const externals = Object.keys(dependencies); + + const configs = [ + // umd bundle + getViteConfigForPackage({ + minify: false, + formats: ['umd'], + external: ['vue'], + }), + // umd bundle (minified) + getViteConfigForPackage({ + minify: true, + formats: ['umd'], + external: ['vue'], + }), + // esm/cjs bundle + getViteConfigForPackage({ + minify: false, + formats: ['es', 'cjs'], + external: ['vue', ...externals], + }), + // esm/cjs bundle (minified) + // vite will not minify es bundle + // see: https://github.com/vuejs/vue-next/issues/2860 + getViteConfigForPackage({ + minify: true, + formats: ['es', 'cjs'], + external: ['vue', ...externals], + }), + ]; + + await Promise.all( + configs.map((config) => build(mergeCustomViteConfig(config))) + ); + await genEntryForSSR(); +} diff --git a/packages/vant-cli/src/compiler/compile-package.ts b/packages/vant-cli/src/compiler/compile-package.ts deleted file mode 100644 index 00466bae6..000000000 --- a/packages/vant-cli/src/compiler/compile-package.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { build } from 'vite'; -import { mergeCustomViteConfig } from '../common/index.js'; -import { getViteConfigForPackage } from '../config/vite.package.js'; - -export async function compilePackage( - minify: boolean -): ReturnType { - const config = mergeCustomViteConfig(getViteConfigForPackage(minify)); - return build(config); -} diff --git a/packages/vant-cli/src/config/vite.package.ts b/packages/vant-cli/src/config/vite.package.ts index 6812bba56..7c780e3b4 100644 --- a/packages/vant-cli/src/config/vite.package.ts +++ b/packages/vant-cli/src/config/vite.package.ts @@ -1,9 +1,17 @@ import { join } from 'path'; -import type { InlineConfig } from 'vite'; import { setBuildTarget } from '../common/index.js'; import { CWD, ES_DIR, getVantConfig, LIB_DIR } from '../common/constant.js'; +import type { InlineConfig, LibraryFormats } from 'vite'; -export function getViteConfigForPackage(minify: boolean): InlineConfig { +export function getViteConfigForPackage({ + minify, + formats, + external, +}: { + minify: boolean; + formats: LibraryFormats[]; + external: string[]; +}): InlineConfig { setBuildTarget('package'); const { name } = getVantConfig(); @@ -17,6 +25,7 @@ export function getViteConfigForPackage(minify: boolean): InlineConfig { lib: { name, entry: join(ES_DIR, 'index.js'), + formats, fileName: (format: string) => { const suffix = format === 'umd' ? '' : `.${format}`; return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`; @@ -25,7 +34,7 @@ export function getViteConfigForPackage(minify: boolean): InlineConfig { // terser has better compression than esbuild minify: minify ? 'terser' : false, rollupOptions: { - external: ['vue'], + external, output: { dir: LIB_DIR, exports: 'named', diff --git a/packages/vant-cli/tsconfig.json b/packages/vant-cli/tsconfig.json index 3bfcc20c0..12b1beb8b 100644 --- a/packages/vant-cli/tsconfig.json +++ b/packages/vant-cli/tsconfig.json @@ -1,14 +1,9 @@ { + "extends": "../../tsconfig", "compilerOptions": { "target": "ES2019", "outDir": "./lib", - "module": "ESNext", - "strict": true, - "declaration": true, - "skipLibCheck": true, - "esModuleInterop": true, - "moduleResolution":"Node", - "lib": ["esnext", "dom"] + "declaration": true }, "include": ["src/**/*"] } diff --git a/packages/vant-eslint-config/package.json b/packages/vant-eslint-config/package.json index c2d4e8084..3bccabb81 100644 --- a/packages/vant-eslint-config/package.json +++ b/packages/vant-eslint-config/package.json @@ -1,14 +1,20 @@ { "name": "@vant/eslint-config", - "version": "3.3.2", + "version": "3.4.0", "description": "eslint config of vant", "main": "index.js", "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-eslint-config" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-eslint-config", "dependencies": { "@typescript-eslint/eslint-plugin": "^5.3.1", "@typescript-eslint/parser": "5.3.1", @@ -19,6 +25,6 @@ }, "devDependencies": { "eslint": "^8.0.0", - "typescript": "4.x" + "typescript": "~4.5.2" } } diff --git a/packages/vant-icons/package.json b/packages/vant-icons/package.json index d243680d5..25b941ed7 100644 --- a/packages/vant-icons/package.json +++ b/packages/vant-icons/package.json @@ -7,15 +7,21 @@ "files": [ "src" ], + "scripts": { + "release": "release-it" + }, "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }, - "scripts": { - "release": "release-it" + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-icons" }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-icons", "devDependencies": { "release-it": "^14.11.6" }, diff --git a/packages/vant-markdown-loader/package.json b/packages/vant-markdown-loader/package.json index b2a69b9ca..493200b47 100644 --- a/packages/vant-markdown-loader/package.json +++ b/packages/vant-markdown-loader/package.json @@ -7,8 +7,14 @@ "access": "public", "registry": "https://registry.npmjs.org/" }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-markdown-loader" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-markdown-loader", "dependencies": { "front-matter": "^4.0.2", "highlight.js": "^10.7.1", diff --git a/packages/vant-markdown-vetur/package.json b/packages/vant-markdown-vetur/package.json index 2e49c59f0..d63526874 100644 --- a/packages/vant-markdown-vetur/package.json +++ b/packages/vant-markdown-vetur/package.json @@ -3,22 +3,27 @@ "version": "2.2.0", "description": "simple parse markdown to vue component description for vetur auto-completion", "main": "lib/index.js", - "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-markdown-vetur", - "author": "zhangshuai", - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, "files": [ "lib" ], "scripts": { "dev": "tsc --watch", - "build": "tsc", + "build": "rimraf ./lib && tsc", "release": "pnpm build && npm publish", "prepare": "pnpm build" }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-markdown-vetur" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "zhangshuai", + "license": "MIT", "dependencies": { "fast-glob": "^3.2.2", "fs-extra": "^10.0.0" diff --git a/packages/vant-markdown-vetur/tsconfig.json b/packages/vant-markdown-vetur/tsconfig.json index d40c806f7..738ecb181 100644 --- a/packages/vant-markdown-vetur/tsconfig.json +++ b/packages/vant-markdown-vetur/tsconfig.json @@ -1,13 +1,10 @@ { + "extends": "../../tsconfig", "compilerOptions": { "target": "ES2019", "outDir": "./lib", "module": "commonjs", - "strict": true, - "declaration": true, - "skipLibCheck": true, - "esModuleInterop": true, - "lib": ["esnext"] + "declaration": true }, "include": ["src/**/*"] } diff --git a/packages/vant-popperjs/build.js b/packages/vant-popperjs/build.js new file mode 100644 index 000000000..f696cf294 --- /dev/null +++ b/packages/vant-popperjs/build.js @@ -0,0 +1 @@ +require('../vant-use/build'); diff --git a/packages/vant-popperjs/package.json b/packages/vant-popperjs/package.json index a29052e96..03ca773ea 100644 --- a/packages/vant-popperjs/package.json +++ b/packages/vant-popperjs/package.json @@ -2,8 +2,8 @@ "name": "@vant/popperjs", "version": "1.1.0", "description": "Pre-compiled popperjs core", - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", + "main": "dist/index.cjs.js", + "module": "dist/index.esm.js", "types": "dist/index.d.ts", "sideEffects": false, "files": [ @@ -15,24 +15,28 @@ }, "scripts": { "clean": "rimraf ./dist", - "dev": "rollup --config rollup.config.js --watch", + "dev": "node ./build.js -w", "build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly", - "build:bundle": "rollup --config rollup.config.js", + "build:bundle": "node ./build.js", "build": "pnpm clean && pnpm build:bundle && pnpm build:types", "release": "pnpm build && release-it", "prepare": "pnpm build" }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-markdown-loader" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-popperjs", "dependencies": { "@popperjs/core": "^2.9.2" }, "devDependencies": { - "typescript": "4.x", - "rollup": "^2.33.3", - "rollup-plugin-esbuild": "^4.6.0", - "@rollup/plugin-node-resolve": "^13.0.0", - "release-it": "^14.2.2" + "esbuild": "^0.13.15", + "release-it": "^14.2.2", + "typescript": "~4.5.2" }, "release-it": { "git": { diff --git a/packages/vant-popperjs/rollup.config.js b/packages/vant-popperjs/rollup.config.js deleted file mode 100644 index 7a76e73a7..000000000 --- a/packages/vant-popperjs/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import path from 'path'; -import esbuild from 'rollup-plugin-esbuild'; -import nodeResolve from '@rollup/plugin-node-resolve'; - -export default { - input: path.join(__dirname, 'src', 'index.ts'), - output: [ - { - dir: 'dist/cjs', - format: 'cjs', - }, - { - dir: 'dist/esm', - format: 'esm', - }, - ], - plugins: [esbuild(), nodeResolve()], -}; diff --git a/packages/vant-popperjs/tsconfig.json b/packages/vant-popperjs/tsconfig.json index ac6b07b09..04da53d75 100644 --- a/packages/vant-popperjs/tsconfig.json +++ b/packages/vant-popperjs/tsconfig.json @@ -1,12 +1,8 @@ { + "extends": "../../tsconfig", "compilerOptions": { - "target": "ES2015", "outDir": "./dist", - "module": "ESNext", - "strict": true, - "declaration": true, - "skipLibCheck": true, - "moduleResolution": "Node", + "declaration": true }, "include": ["src/**/*"] } diff --git a/packages/vant-stylelint-config/package.json b/packages/vant-stylelint-config/package.json index 810fbce35..6f5ec15f5 100644 --- a/packages/vant-stylelint-config/package.json +++ b/packages/vant-stylelint-config/package.json @@ -7,8 +7,14 @@ "access": "public", "registry": "https://registry.npmjs.org/" }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-stylelint-config" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-stylelint-config", "dependencies": { "stylelint-config-prettier": "^8.0.1", "stylelint-config-standard": "^22.0.0" diff --git a/packages/vant-touch-emulator/package.json b/packages/vant-touch-emulator/package.json index 49cc893bb..3531d7993 100644 --- a/packages/vant-touch-emulator/package.json +++ b/packages/vant-touch-emulator/package.json @@ -6,6 +6,12 @@ "publishConfig": { "access": "public" }, - "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator" + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-touch-emulator" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", + "license": "MIT" } diff --git a/packages/vant-use/build.js b/packages/vant-use/build.js new file mode 100644 index 000000000..1f2ff0842 --- /dev/null +++ b/packages/vant-use/build.js @@ -0,0 +1,20 @@ +const { build } = require('esbuild'); + +function bundleBundle(format) { + const outfile = `dist/index.${format}.js`; + const finish = () => console.log('Build finished:', outfile); + const onRebuild = (error) => (error ? console.log(error) : finish()); + + build({ + watch: process.argv.includes('-w') && { onRebuild }, + format, + bundle: true, + target: ['chrome53'], + outfile, + external: ['vue'], + entryPoints: ['./src/index.ts'], + }).then(finish); +} + +bundleBundle('esm'); +bundleBundle('cjs'); diff --git a/packages/vant-use/package.json b/packages/vant-use/package.json index 835b8d421..8e710264d 100644 --- a/packages/vant-use/package.json +++ b/packages/vant-use/package.json @@ -2,8 +2,8 @@ "name": "@vant/use", "version": "1.3.4", "description": "Vant Composition API", - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", + "main": "dist/index.cjs.js", + "module": "dist/index.esm.js", "typings": "dist/index.d.ts", "sideEffects": false, "files": [ @@ -11,9 +11,9 @@ ], "scripts": { "clean": "rimraf ./dist", - "dev": "rollup --config rollup.config.js --watch", + "dev": "node ./build.js -w", "build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly", - "build:bundle": "rollup --config rollup.config.js", + "build:bundle": "node ./build.js", "build": "pnpm clean && pnpm build:bundle && pnpm build:types", "release": "pnpm build && release-it", "prepare": "pnpm build" @@ -22,13 +22,18 @@ "access": "public", "registry": "https://registry.npmjs.org/" }, + "repository": { + "type": "git", + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant-use" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", "license": "MIT", - "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-use", "devDependencies": { + "esbuild": "^0.13.15", "release-it": "^14.0.2", - "typescript": "4.x", - "rollup": "^2.33.3", - "rollup-plugin-esbuild": "^4.6.0", + "typescript": "~4.5.2", "vue": "^3.2.20" }, "release-it": { diff --git a/packages/vant-use/rollup.config.js b/packages/vant-use/rollup.config.js deleted file mode 100644 index 4a3a5096b..000000000 --- a/packages/vant-use/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import path from 'path'; -import esbuild from 'rollup-plugin-esbuild'; - -export default { - input: path.join(__dirname, 'src', 'index.ts'), - output: [ - { - dir: 'dist/cjs', - format: 'cjs', - }, - { - dir: 'dist/esm', - format: 'esm', - }, - ], - external: ['vue'], - plugins: [esbuild()], -}; diff --git a/packages/vant-use/tsconfig.json b/packages/vant-use/tsconfig.json index ac6b07b09..04da53d75 100644 --- a/packages/vant-use/tsconfig.json +++ b/packages/vant-use/tsconfig.json @@ -1,12 +1,8 @@ { + "extends": "../../tsconfig", "compilerOptions": { - "target": "ES2015", "outDir": "./dist", - "module": "ESNext", - "strict": true, - "declaration": true, - "skipLibCheck": true, - "moduleResolution": "Node", + "declaration": true }, "include": ["src/**/*"] } diff --git a/packages/vant/docs/markdown/changelog.en-US.md b/packages/vant/docs/markdown/changelog.en-US.md index bfdc84537..8de69a172 100644 --- a/packages/vant/docs/markdown/changelog.en-US.md +++ b/packages/vant/docs/markdown/changelog.en-US.md @@ -16,22 +16,125 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/). ## Details +### [v3.3.6](https://github.com/compare/v3.3.5...v3.3.6) + +`2021-12-05` + +**Bug Fixes** + +- fix ssr.js require path [#9999](https://github.com/youzan/vant/issues/9999) + +### [v3.3.5](https://github.com/compare/v3.3.4...v3.3.5) + +`2021-12-02` + +**Bug Fixes** + +- fix exports field break SSR [#9988](https://github.com/youzan/vant/issues/9988) +- fix exports field break unplugin-vue-components [#9985](https://github.com/youzan/vant/issues/9985) + +### [v3.3.4](https://github.com/compare/v3.3.3...v3.3.4) + +`2021-12-01` + +- fix `lib/ssr.js` not exist + +### [v3.3.3](https://github.com/compare/v3.3.2...v3.3.3) + +`2021-11-30` + +**Feature** + +- Support nuxt3 [#9970](https://github.com/youzan/vant/issues/9970) +- Locale: add pt-BR locale [#9959](https://github.com/youzan/vant/issues/9959) + +**Bug Fixes** + +- Swipe: fix incorrect border radius in iOS safari [#9958](https://github.com/youzan/vant/issues/9958) +- Uploader: fix preview is slow when sum of images size be bigger [#9961](https://github.com/youzan/vant/issues/9961) + +### [v3.3.2](https://github.com/compare/v3.3.1...v3.3.2) + +`2021-11-28` + +**Feature** + +- add exports field and use bundled output by default [#9952](https://github.com/youzan/vant/issues/9952) +- Tabbar: support highlighted with child route [#9926](https://github.com/youzan/vant/issues/9926) + +**Bug Fixes** + +- Calendar: auto selected to max range when show-confirm is false [#9948](https://github.com/youzan/vant/issues/9948) +- Calendar: should scroll to current date instead of current month [#9949](https://github.com/youzan/vant/issues/9949) +- Swipe: should prevent touchmove event when swiping [#9920](https://github.com/youzan/vant/issues/9920) +- Tabs: rename wrapper class to `van-tab__panel-wrapper` [#9951](https://github.com/youzan/vant/issues/9951) + +### [v3.3.1](https://github.com/compare/v3.3.0...v3.3.1) + +`2021-11-23` + +**Bug Fixes** + +- AddressEdit: should not emit save event when validation failed [#9917](https://github.com/youzan/vant/issues/9917) + +### [v3.3.0](https://github.com/compare/v3.2.8...v3.3.0) + +`2021-11-19` + +**Accessibility** + +- Cascader: add role, aria and tabindex [#9886](https://github.com/youzan/vant/issues/9886) +- CountDown: add timer role [#9906](https://github.com/youzan/vant/issues/9906) +- DropdownMenu: add role, aria and tabindex [#9893](https://github.com/youzan/vant/issues/9893) +- Field: add aria-labelledby [#9883](https://github.com/youzan/vant/issues/9883) +- List: add role and tabindex [#9888](https://github.com/youzan/vant/issues/9888) +- Pagination: refactor DOM to improve a11y [#9901](https://github.com/youzan/vant/issues/9901) +- Popover: add tabindex and aria-disabled [#9889](https://github.com/youzan/vant/issues/9889) +- Rate: improve a11y when disabled or readonly [#9881](https://github.com/youzan/vant/issues/9881) +- Search: id prop add default value [#9884](https://github.com/youzan/vant/issues/9884) +- Sidebar: add role, aria and tabindex [#9903](https://github.com/youzan/vant/issues/9903) +- Slider: improve a11y when disabled or readonly [#9880](https://github.com/youzan/vant/issues/9880) +- Stepper: add aria-disabled [#9877](https://github.com/youzan/vant/issues/9877) +- Stepper: add group role [#9876](https://github.com/youzan/vant/issues/9876) +- Switch: add tabindex [#9887](https://github.com/youzan/vant/issues/9887) +- Tabbar: add role, aria and tabindex [#9895](https://github.com/youzan/vant/issues/9895) +- Tabs: add aria-controls [#9882](https://github.com/youzan/vant/issues/9882) +- Tabs: add aria-disabled [#9878](https://github.com/youzan/vant/issues/9878) +- Tabs: add aria-orientation and tabindex [#9872](https://github.com/youzan/vant/issues/9872) +- Uploader: add role, aria and tabindex [#9905](https://github.com/youzan/vant/issues/9905) +- remove tabindex from disabled elements [#9879](https://github.com/youzan/vant/issues/9879) + +**Feature** + +- Popup: reduce unused listener [#9896](https://github.com/youzan/vant/issues/9896) +- Field: expose sub-types of FieldRule [#9843](https://github.com/youzan/vant/issues/9843) +- minify svg icons [#9869](https://github.com/youzan/vant/issues/9869) + +**Bug Fixes** + +- Popover: useClickAway failed in SSR [#9899](https://github.com/youzan/vant/issues/9899) +- CouponList: incorrect list height [#9874](https://github.com/youzan/vant/issues/9874) +- Field: should not trigger validation after blurring readonly input [#9862](https://github.com/youzan/vant/issues/9862) +- Switch: switch node inherit font-size [#9842](https://github.com/youzan/vant/issues/9842) +- Tabbar: before-change not work in route mode [#9856](https://github.com/youzan/vant/issues/9856) +- Tabs: rename panel class to `van-tab__panel` [#9885](https://github.com/youzan/vant/issues/9885) + ### [v3.2.8](https://github.com/compare/v3.2.7...v3.2.8) `2021-11-09` **Feature** -- Cascader: add options-bottom slot [#9804](https://github.com/issues/9804) +- Cascader: add options-bottom slot [#9804](https://github.com/youzan/vant/issues/9804) - SubmitBar: add SubmitBarTextAlign type [f95567](https://github.com/commit/f95567ade758d453f4acad8a40d8ae717035476a) -- PasswordInput: add PasswordInputProps type [#9820](https://github.com/issues/9820) +- PasswordInput: add PasswordInputProps type [#9820](https://github.com/youzan/vant/issues/9820) **Bug Fixes** -- NavBar: fix NavBarProps spelling [#9818](https://github.com/issues/9818) -- Progress: incorrect border-radius [#9826](https://github.com/issues/9826) -- SubmitBar: fix missing SubmitBarProps export [#9819](https://github.com/issues/9819) -- Tabs: should emit click-tab after before-change [#9805](https://github.com/issues/9805) +- NavBar: fix NavBarProps spelling [#9818](https://github.com/youzan/vant/issues/9818) +- Progress: incorrect border-radius [#9826](https://github.com/youzan/vant/issues/9826) +- SubmitBar: fix missing SubmitBarProps export [#9819](https://github.com/youzan/vant/issues/9819) +- Tabs: should emit click-tab after before-change [#9805](https://github.com/youzan/vant/issues/9805) ### [v3.2.7](https://github.com/youzan/vant/compare/v3.2.6...v3.2.7) diff --git a/packages/vant/docs/markdown/changelog.zh-CN.md b/packages/vant/docs/markdown/changelog.zh-CN.md index 348b29626..c26e4dcfa 100644 --- a/packages/vant/docs/markdown/changelog.zh-CN.md +++ b/packages/vant/docs/markdown/changelog.zh-CN.md @@ -16,22 +16,128 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 ## 更新内容 +### [v3.3.6](https://github.com/compare/v3.3.5...v3.3.6) + +`2021-12-05` + +**Bug Fixes** + +- 修复 ssr.js 文件引用路径错误的问题 [#9999](https://github.com/youzan/vant/issues/9999) + +### [v3.3.5](https://github.com/compare/v3.3.4...v3.3.5) + +`2021-12-02` + +**Bug Fixes** + +- 修复 exports field 导致 SSR 无法正确引入的问题 [#9988](https://github.com/youzan/vant/issues/9988) +- 修复 exports field 导致 unplugin-vue-components 引用报错的问题 [#9985](https://github.com/youzan/vant/issues/9985) + +### [v3.3.4](https://github.com/compare/v3.3.3...v3.3.4) + +`2021-12-01` + +- 修复 `lib/ssr.js` 文件不存在导致 SSR 失败的问题 + +### [v3.3.3](https://github.com/compare/v3.3.2...v3.3.3) + +`2021-11-30` + +**Feature** + +- 支持在 nuxt3 中使用 [#9970](https://github.com/youzan/vant/issues/9970) +- Locale: 新增 pt-BR 葡萄牙语 (巴西) [#9959](https://github.com/youzan/vant/issues/9959) + +**Bug Fixes** + +- Swipe: 修复 iOS 系统下圆角失效的问题 [#9958](https://github.com/youzan/vant/issues/9958) +- Uploader: 修复图片预览卡顿的问题 [#9961](https://github.com/youzan/vant/issues/9961) + +### [v3.3.2](https://github.com/compare/v3.3.1...v3.3.2) + +`2021-11-28` + +**Feature** + +- 新增 `package.json` 中的 `exports` 字段 [#9952](https://github.com/issues/9952) +- Tabbar: 支持在 route 模式下匹配子路由 [#9926](https://github.com/issues/9926) +- Tabs: 将 `van-tab__pane-wrapper` 类重命名为 `van-tab__panel-wrapper` [#9951](https://github.com/issues/9951) + +**Bug Fixes** + +- Calendar: 修复 show-confirm 为 false 时不会限制最大日期范围的问题 [#9948](https://github.com/issues/9948) +- Calendar: 修复 `scrollToDate` 方法无法精确滚动到对应日期的问题 [#9949](https://github.com/issues/9949) +- Swipe: 修复开始滑动时未阻止 touchmove 事件行为的问题 [#9920](https://github.com/issues/9920) + +### [v3.3.1](https://github.com/compare/v3.3.0...v3.3.1) + +`2021-11-23` + +**Bug Fixes** + +- AddressEdit: 修复表单校验不通过时也会触发 save 事件的问题 [#9917](https://github.com/issues/9917) + +### [v3.3.0](https://github.com/compare/v3.2.8...v3.3.0) + +`2021-11-19` + +**Accessibility** + +改善以下组件的无障碍访问体验: + +- Cascader: 增加 role="menu", tabindex, aria-checked, aria-disabled 属性 [#9886](https://github.com/youzan/vant/issues/9886) +- CountDown: 增加 role="timer" 属性 [#9906](https://github.com/youzan/vant/issues/9906) +- DropdownMenu: 增加 role="menu", tabindex, aria-labelledby 属性 [#9893](https://github.com/youzan/vant/issues/9893) +- Field: 增加 aria-labelledby 属性 [#9883](https://github.com/youzan/vant/issues/9883) +- List: 增加 role="button", tabindex 属性 [#9888](https://github.com/youzan/vant/issues/9888) +- Pagination: 增加 role="navigation" 和 button 标签 [#9901](https://github.com/youzan/vant/issues/9901) +- Popover: 增加 tabindex, aria-disabled 属性 [#9889](https://github.com/youzan/vant/issues/9889) +- Rate: 增加 aria-disabled, aria-readonly 属性 [#9881](https://github.com/youzan/vant/issues/9881) +- Search: 提供默认的 id 属性 属性 [#9884](https://github.com/youzan/vant/issues/9884) +- Sidebar: 增加 role="tab", tabindex, aria-selected 属性 [#9903](https://github.com/youzan/vant/issues/9903) +- Slider: 增加 aria-disabled, aria-readonly 属性 [#9880](https://github.com/youzan/vant/issues/9880) +- Stepper: 增加 aria-disabled 属性 [#9877](https://github.com/youzan/vant/issues/9877) +- Stepper: 增加 role="group" 属性 [#9876](https://github.com/youzan/vant/issues/9876) +- Switch: 增加 tabindex 属性 [#9887](https://github.com/youzan/vant/issues/9887) +- Tabbar: 增加 role="tab", tabindex, aria-selected 属性 [#9895](https://github.com/youzan/vant/issues/9895) +- Tabs: 增加 aria-controls 属性 [#9882](https://github.com/youzan/vant/issues/9882) +- Tabs: 增加 aria-disabled 属性 [#9878](https://github.com/youzan/vant/issues/9878) +- Tabs: 增加 tabindex, aria-orientation 属性 [#9872](https://github.com/youzan/vant/issues/9872) +- Uploader: 删除按钮增加 role="button", tabindex, aria-label 属性 [#9905](https://github.com/youzan/vant/issues/9905) +- 移除禁用元素的 tabindex 属性 [#9879](https://github.com/youzan/vant/issues/9879) + +**Feature** + +- Popup: 移除多余的 click 事件监听 [#9896](https://github.com/youzan/vant/issues/9896) +- Field: 导出 `FieldRuleValidator` 等多个类型定义 [#9843](https://github.com/youzan/vant/issues/9843) +- Empty: 压缩 svg 图标 [#9869](https://github.com/youzan/vant/issues/9869) +- NumberKeyboard: 压缩 svg 图标 [#9869](https://github.com/youzan/vant/issues/9869) +- Tabs: 将 `van-tab__pane` 类重命名为 `van-tab__panel` [#9885](https://github.com/youzan/vant/issues/9885) + +**Bug Fixes** + +- Popover: 修复 useClickAway 方法在 SSR 时报错的问题 [#9899](https://github.com/youzan/vant/issues/9899) +- CouponList: 修复列表高度不正确的问题 [#9874](https://github.com/youzan/vant/issues/9874) +- Field: 修复点击只读输入框会触发表单验证的问题 [#9862](https://github.com/youzan/vant/issues/9862) +- Switch: 修复全局设置 font-size 时样式错误的问题 [#9842](https://github.com/youzan/vant/issues/9842) +- Tabbar: 修复 route 模式下无法触发 before-change 属性的问题 [#9856](https://github.com/youzan/vant/issues/9856) + ### [v3.2.8](https://github.com/compare/v3.2.7...v3.2.8) `2021-11-09` **Feature** -- Cascader: 新增 options-bottom 插槽 [#9804](https://github.com/issues/9804) +- Cascader: 新增 options-bottom 插槽 [#9804](https://github.com/youzan/vant/issues/9804) - SubmitBar: 新增 SubmitBarTextAlign 类型 [f95567](https://github.com/commit/f95567ade758d453f4acad8a40d8ae717035476a) -- PasswordInput: 新增 PasswordInputProps 类型 [#9820](https://github.com/issues/9820) +- PasswordInput: 新增 PasswordInputProps 类型 [#9820](https://github.com/youzan/vant/issues/9820) **Bug Fixes** -- NavBar: 修复 NavBarProps 拼写错误的问题 [#9818](https://github.com/issues/9818) -- Progress: 修复圆角大小错误的问题 [#9826](https://github.com/issues/9826) -- SubmitBar: 修复未导出 SubmitBarProps 的问题 [#9819](https://github.com/issues/9819) -- Tabs: 修复 click-tab 触发顺序早于 before-change 的问题 [#9805](https://github.com/issues/9805) +- NavBar: 修复 NavBarProps 拼写错误的问题 [#9818](https://github.com/youzan/vant/issues/9818) +- Progress: 修复圆角大小错误的问题 [#9826](https://github.com/youzan/vant/issues/9826) +- SubmitBar: 修复未导出 SubmitBarProps 的问题 [#9819](https://github.com/youzan/vant/issues/9819) +- Tabs: 修复 click-tab 触发顺序早于 before-change 的问题 [#9805](https://github.com/youzan/vant/issues/9805) ### [v3.2.7](https://github.com/youzan/vant/compare/v3.2.6...v3.2.7) diff --git a/packages/vant/docs/markdown/contribution.zh-CN.md b/packages/vant/docs/markdown/contribution.zh-CN.md index a093675e1..e471e9c26 100644 --- a/packages/vant/docs/markdown/contribution.zh-CN.md +++ b/packages/vant/docs/markdown/contribution.zh-CN.md @@ -34,29 +34,36 @@ pnpm dev ### 目录结构 -项目的主要目录结构如下所示: +Vant 采用 monorepo 进行代码管理,所有子包在 `packages` 目录下: + +``` +root +└─ packages + ├─ vant # 组件库 + ├─ vant-cli # 脚手架 + ├─ vant-icons # 图标库 + ├─ vant-use # Composition API + └─ .... # 其他周边 npm 包 +``` + +其中,`vant` 目录为组件库的核心代码: ``` vant -├─ docs # 文档 -├─ packages # 基础包 -├─ src # 组件源代码 -├─ test # 单测工具类 -└─ vant.config.mjs # 文档网站配置 +├─ docs # 文档 +├─ src # 组件源代码 +├─ test # 单测工具类 +└─ vant.config.mjs # 文档网站配置 ``` -组件代码位于 src 目录下,每个组件一个独立的文件夹。 - -### 组件目录结构 - -添加新组件时,请按照下面的目录结构组织文件,并在 `vant.config.mjs` 中配置组件名称。 +`src` 目录包含各个组件的源码,每个文件夹对应一个组件: ``` src └─ button ├─ demo # 示例代码 ├─ test # 单元测试 - ├─ Component.ts # 组件 + ├─ Component.tsx # 组件 ├─ index.ts # 组件入口 ├─ index.less # 样式 ├─ var.less # 样式变量 @@ -93,7 +100,7 @@ src ```bash # 添加主仓库到 remote,作为 fork 后仓库的上游仓库 -git remote add upstream https://github.com/youzan/vant.git +git remote add upstream git@github.com:youzan/vant.git # 拉取主仓库最新代码 git fetch upstream diff --git a/packages/vant/docs/markdown/home.en-US.md b/packages/vant/docs/markdown/home.en-US.md index d5a860695..36e907c5a 100644 --- a/packages/vant/docs/markdown/home.en-US.md +++ b/packages/vant/docs/markdown/home.en-US.md @@ -17,6 +17,7 @@ - 🍭 Support Vue 2 & Vue 3 - 🍭 Support Tree Shaking - 🍭 Support Custom Theme +- 🍭 Support Accessibility (still improving) - 🍭 Support i18n - 🌍 Support SSR @@ -24,16 +25,14 @@ See in [Quickstart](#/en-US/quickstart). -### Contribution - -Please make sure to read the [Contributing Guide](https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.md) before making a pull request. - ### Browser Support Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0. Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3). +## Links + ### Official Ecosystem | Project | Description | @@ -55,12 +54,34 @@ Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3). | [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI | | [@antmjs/vantui](https://github.com/antmjs/vantui) | Mobile UI Components based on Vant, supporting Taro and React | -### Links +### Other Links - [Feedback](https://github.com/youzan/vant/issues) - [Changelog](#/en-US/changelog) - [Gitter](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link) +## Contribution + +### Core Team + +Core contributors of Vant and Vant Weapp: + +| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | +| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | +| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | + +### All Contributors + +Thanks to the following friends for their contributions to Vant: + + + contributors + + +### Contribution Guide + +Please make sure to read the [Contributing Guide](https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.md) before making a pull request. + ### LICENSE [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) diff --git a/packages/vant/docs/markdown/home.zh-CN.md b/packages/vant/docs/markdown/home.zh-CN.md index e92e2e47f..5748fb7e0 100644 --- a/packages/vant/docs/markdown/home.zh-CN.md +++ b/packages/vant/docs/markdown/home.zh-CN.md @@ -27,6 +27,7 @@ Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源 - 🍭 支持 Vue 2、Vue 3 和微信小程序 - 🍭 支持主题定制,内置 700+ 个主题变量 - 🍭 支持按需引入和 Tree Shaking +- 🍭 支持无障碍访问(持续改进中) - 🍭 支持服务器端渲染 - 🌍 支持国际化和语言包定制 @@ -34,18 +35,14 @@ Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源 请阅读[快速上手](#/zh-CN/quickstart)章节,通过该章节你可以了解到 Vant 的安装方法和基本使用姿势。 -### 贡献代码 - -贡献代码请阅读我们的[贡献指南](#/zh-CN/contribution)。 - -使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。 - ### 浏览器支持 Vant 2 支持现代浏览器以及 Android >= 4.0、iOS >= 8.0。 Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致)。 +## 链接 + ### 官方生态 由 Vant 官方团队维护的项目如下: @@ -71,13 +68,37 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致 | [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 | | [@antmjs/vantui](https://github.com/antmjs/vantui) | 基于 Vant Weapp 开发的多端组件库,同时支持 Taro 和 React | -### 链接 +### 其他链接 - [意见反馈](https://github.com/youzan/vant/issues) - [更新日志](#/zh-CN/changelog) - [码云镜像](https://gitee.com/vant-contrib/vant) - [Gitter 讨论组](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link) +## 贡献 + +### 核心团队 + +以下是 Vant 和 Vant Weapp 的核心贡献者们: + +| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | +| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | +| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | + +### 贡献者们 + +感谢以下小伙伴们为 Vant 发展做出的贡献: + + + contributors + + +### 贡献指南 + +贡献代码请阅读我们的[贡献指南](#/zh-CN/contribution)。 + +使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。 + ### 开源协议 本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源 diff --git a/packages/vant/docs/markdown/quickstart.en-US.md b/packages/vant/docs/markdown/quickstart.en-US.md index 1d13d6a0e..46ed3a006 100644 --- a/packages/vant/docs/markdown/quickstart.en-US.md +++ b/packages/vant/docs/markdown/quickstart.en-US.md @@ -56,12 +56,21 @@ The easiest way to use Vant is to include a CDN link in the html file, after whi ``` +#### Free CDN + You can use Vant through these free CDN services: - [jsdelivr](https://www.jsdelivr.com/package/npm/vant) - [cdnjs](https://cdnjs.com/libraries/vant) - [unpkg](https://unpkg.com/) +Note: Free CDN is generally used for making prototypes or personal projects. It is not recommended to use free CDN in production environment. + +For enterprise developers, we recommend: + +- install with npm, use build tools to bundle it +- download the scripts, host it on your own server + ### CLI We recommend to use [Vue Cli](https://cli.vuejs.org/) to create a new project. @@ -83,16 +92,67 @@ In the GUI, click on 'Dependencies' -> `Install Dependencies` and add `vant` to ## Usage -### 1. Import on demand +### Import on demand in vite projects (recommended) -Use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) to import components on demand. +If you are using vite, please use [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import). + +#### 1. Install Plugin + +```bash +npm i vite-plugin-style-import@1.2.0 -D +``` + +#### 2. Configure Plugin + +Configure the plugin in the `vite.config.js` file: + +```js +import vue from '@vitejs/plugin-vue'; +import styleImport from 'vite-plugin-style-import'; + +export default { + plugins: [ + vue(), + styleImport({ + libs: [ + { + libraryName: 'vant', + esModule: true, + resolveStyle: (name) => `vant/es/${name}/style/index`, + }, + ], + }), + ], +}; +``` + +#### 3. Import Components + +Then you can import components from Vant: + +```js +import { createApp } from 'vue'; +import { Button } from 'vant'; + +const app = createApp(); +app.use(Button); +``` + +> Vant supports Tree Shaking by default. + +### Import on demand in non-vite projects (recommended) + +In non-vite projects, use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) to import components on demand. + +#### 1. Install Plugin ```bash -# Install plugin npm i babel-plugin-import -D ``` -Set babel config in .babelrc or babel.config.js: +#### 2. Configure Plugin + +Set babel config in `.babelrc` or `babel.config.js`: ```json { @@ -109,7 +169,9 @@ Set babel config in .babelrc or babel.config.js: } ``` -Then you can import components from vant: +#### 3. Import Components + +Then you can import components from Vant: ```js // Input @@ -122,43 +184,9 @@ import 'vant/es/button/style'; > If you are using TypeScript,please use [ts-import-plugin](https://github.com/Brooooooklyn/ts-import-plugin) instead. -### 2. Vite Plugin +### Import all components (not recommended) -If you are using Vite, please use [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import). - -```bash -npm i vite-plugin-style-import -D -``` - -```js -// vite.config.js -import vue from '@vitejs/plugin-vue'; -import styleImport from 'vite-plugin-style-import'; - -export default { - plugins: [ - vue(), - styleImport({ - libs: [ - { - libraryName: 'vant', - esModule: true, - resolveStyle: (name) => `vant/es/${name}/style`, - }, - ], - }), - ], -}; -``` - -### 3. Manually import - -```js -import Button from 'vant/es/button'; -import 'vant/es/button/style'; -``` - -### 4. Import all components +Import all components will **increase the bundle size**, so this is not recommended. ```js import { createApp } from 'vue'; @@ -170,3 +198,13 @@ app.use(Vant); ``` > If you configured babel-plugin-import, you won't be allowed to import all components. + +### Manually import (not recommended) + +```js +// import script +import Button from 'vant/es/button/index'; +// import style +// if the component does not have a style file, there is no need to import +import 'vant/es/button/style/index'; +``` diff --git a/packages/vant/docs/markdown/quickstart.zh-CN.md b/packages/vant/docs/markdown/quickstart.zh-CN.md index 5086c2867..933efc374 100644 --- a/packages/vant/docs/markdown/quickstart.zh-CN.md +++ b/packages/vant/docs/markdown/quickstart.zh-CN.md @@ -61,30 +61,20 @@ pnpm add vant@3 ``` +#### 免费 CDN + 你可以通过以下免费 CDN 服务来使用 Vant: - [jsdelivr](https://www.jsdelivr.com/package/npm/vant) - [cdnjs](https://cdnjs.com/libraries/vant) - [unpkg](https://unpkg.com/) -### 通过脚手架安装 +注意:免费 CDN 一般用于制作原型或个人小型项目,不推荐在企业生产环境中使用免费 CDN。 -在新项目中使用 Vant 时,推荐使用 Vue 官方提供的脚手架 [Vue Cli](https://cli.vuejs.org/zh/) 创建项目并安装 Vant。 +对于企业开发者,建议使用以下方式: -```bash -# 安装 Vue Cli -npm install -g @vue/cli - -# 创建一个项目 -vue create hello-world - -# 创建完成后,可以通过命令打开图形化界面,如下图所示 -vue ui -``` - -![](https://img.yzcdn.cn/vant/vue-cli-demo-201809032000.png) - -在图形化界面中,点击 `依赖` -> `安装依赖`,然后将 `vant` 添加到依赖中即可。 +- 通过 npm 引入,并通过构建工具进行打包 +- 下载对应文件,并托管在你自己的服务器或 CDN 上 ## 示例 @@ -92,8 +82,9 @@ vue ui 我们提供了丰富的[示例工程](https://github.com/youzan/vant-demo),通过示例工程你可以了解如下内容: -- 基于 Vue Cli 和 Vant 搭建应用 +- 基于 Vite 和 Vant 搭建应用 - 基于 Nuxt 和 Vant 搭建应用 +- 基于 Vue Cli 和 Vant 搭建应用 - 配置按需引入组件 - 配置基于 Rem 的适配方案 - 配置基于 Viewport 的适配方案 @@ -102,15 +93,66 @@ vue ui ## 引入组件 -### 方式一. 通过 babel 插件按需引入组件 +### 在 vite 项目中按需引入组件(推荐) -[babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 是一款 babel 插件,它会在编译过程中将 import 语句自动转换为按需引入的方式。 +在 vite 项目中使用 Vant 时,推荐安装 [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import) 插件,它可以自动按需引入组件的样式。 + +#### 1. 安装插件 + +```bash +npm i vite-plugin-style-import@1.2.0 -D +``` + +#### 2. 配置插件 + +安装完成后,在 `vite.config.js` 文件中配置插件: + +```js +import vue from '@vitejs/plugin-vue'; +import styleImport from 'vite-plugin-style-import'; + +export default { + plugins: [ + vue(), + styleImport({ + libs: [ + { + libraryName: 'vant', + esModule: true, + resolveStyle: (name) => `vant/es/${name}/style/index`, + }, + ], + }), + ], +}; +``` + +#### 3. 引入组件 + +完成以上两步,就可以直接使用 Vant 组件了: + +```js +import { createApp } from 'vue'; +import { Button } from 'vant'; + +const app = createApp(); +app.use(Button); +``` + +> Vant 默认支持通过 Tree Shaking 实现 script 的按需引入。 + +### 在非 vite 项目中按需引入组件(推荐) + +在非 vite 的项目中,可以通过 babel 插件来实现按需引入组件。我们需要安装 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 插件,它会在编译过程中将 import 语句自动转换为按需引入的方式。 + +#### 1. 安装插件 ```bash -# 安装插件 npm i babel-plugin-import -D ``` +#### 2. 配置插件 + 在.babelrc 或 babel.config.js 中添加配置: ```json @@ -128,6 +170,8 @@ npm i babel-plugin-import -D } ``` +#### 3. 引入组件 + 接着你可以在代码中直接引入 Vant 组件,插件会自动将代码转化为按需引入的形式。 ```js @@ -141,50 +185,9 @@ import 'vant/es/button/style'; > 如果你在使用 TypeScript,可以使用 [ts-import-plugin](https://github.com/Brooooooklyn/ts-import-plugin) 实现按需引入。 -### 方式二. 在 Vite 项目中按需引入组件 +### 导入所有组件(不推荐) -对于 vite 项目,可以使用 [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import) 实现按需引入, 原理和 `babel-plugin-import` 类似。 - -```bash -# 安装插件 -npm i vite-plugin-style-import -D -``` - -```js -// vite.config.js -import vue from '@vitejs/plugin-vue'; -import styleImport from 'vite-plugin-style-import'; - -export default { - plugins: [ - vue(), - styleImport({ - libs: [ - { - libraryName: 'vant', - esModule: true, - resolveStyle: (name) => `vant/es/${name}/style`, - }, - ], - }), - ], -}; -``` - -### 方式三. 手动按需引入组件 - -在不使用插件的情况下,可以手动引入需要使用的组件和样式。 - -```js -// 引入组件 -import Button from 'vant/es/button'; -// 引入组件对应的样式,若组件没有样式文件,则无须引入 -import 'vant/es/button/style'; -``` - -### 方式四. 导入所有组件 - -Vant 支持一次性导入所有组件,引入所有组件会增加代码包体积,因此不推荐这种做法。 +Vant 支持一次性导入所有组件,引入所有组件会**增加代码包体积**,因此不推荐这种做法。 ```js import { createApp } from 'vue'; @@ -195,4 +198,16 @@ const app = createApp(); app.use(Vant); ``` -> Tips: 配置按需引入后,将不允许直接导入所有组件。 +> Tips: 配置按需引入插件后,将不允许直接导入所有组件。 + +### 手动按需引入组件(不推荐) + +在不使用任何构建插件的情况下,可以手动引入需要使用的组件和样式。 + +```js +// 引入组件脚本 +import Button from 'vant/es/button/index'; +// 引入组件样式 +// 若组件没有样式文件,则无须引入 +import 'vant/es/button/style/index'; +``` diff --git a/packages/vant/docs/markdown/use-event-listener.en-US.md b/packages/vant/docs/markdown/use-event-listener.en-US.md new file mode 100644 index 000000000..b36e84808 --- /dev/null +++ b/packages/vant/docs/markdown/use-event-listener.en-US.md @@ -0,0 +1,66 @@ +# useEventListener + +### Intro + +Attaching an event when the component is `mounted` and `activated`, then removing the event when the component is `unmounted` and `deactivated`. + +## Usage + +### Basic Usage + +```js +import { ref } from 'vue'; +import { useEventListener } from '@vant/use'; + +export default { + setup() { + // attach the resize event to window + useEventListener('resize', () => { + console.log('window resize'); + }); + + // attach the click event to the body element + useEventListener( + 'click', + () => { + console.log('click body'); + }, + { target: document.body } + ); + }, +}; +``` + +## API + +### Type Declarations + +```ts +type Options = { + target?: EventTarget | Ref; + capture?: boolean; + passive?: boolean; +}; + +function useEventListener( + type: string, + listener: EventListener, + options?: Options +): void; +``` + +### Params + +| Name | Description | Type | Default Value | +| -------- | ----------------- | --------------- | ------------- | +| type | Event type | _string_ | - | +| listener | Callback function | _EventListener_ | - | +| options | Options | _Options_ | - | + +### Options + +| Name | Description | Type | Default Value | +| --- | --- | --- | --- | +| target | Target element | _EventTarget \| Ref\_ | `window` | +| capture | Whether to enable capture | _boolean_ | `false` | +| passive | if true, indicates that the listener will never call `preventDefault()` | _boolean_ | `false` | diff --git a/packages/vant/docs/markdown/use-event-listener.zh-CN.md b/packages/vant/docs/markdown/use-event-listener.zh-CN.md index cb6b0e9ce..a8fe6a6df 100644 --- a/packages/vant/docs/markdown/use-event-listener.zh-CN.md +++ b/packages/vant/docs/markdown/use-event-listener.zh-CN.md @@ -32,6 +32,8 @@ export default { }; ``` +## API + ### 类型定义 ```ts @@ -48,15 +50,13 @@ function useEventListener( ): void; ``` -## API - ### 参数 -| 参数 | 说明 | 类型 | 默认值 | -| -------- | ------------------------ | --------------- | ------ | -| type | 监听的事件类型 | _string_ | - | -| listener | 点击外部时触发的回调函数 | _EventListener_ | - | -| options | 可选的配置项 | _Options_ | - | +| 参数 | 说明 | 类型 | 默认值 | +| -------- | -------------- | --------------- | ------ | +| type | 监听的事件类型 | _string_ | - | +| listener | 事件回调函数 | _EventListener_ | - | +| options | 可选的配置项 | _Options_ | - | ### Options diff --git a/packages/vant/docs/markdown/use-rect.zh-CN.md b/packages/vant/docs/markdown/use-rect.zh-CN.md index 23f726edb..41842757c 100644 --- a/packages/vant/docs/markdown/use-rect.zh-CN.md +++ b/packages/vant/docs/markdown/use-rect.zh-CN.md @@ -13,16 +13,18 @@ ``` ```js -import { ref } from 'vue'; +import { ref, onMounted } from 'vue'; import { useRect } from '@vant/use'; export default { setup() { const root = ref(); - const rect = useRect(root); - - console.log(rect); // -> 元素的大小及其相对于视口的位置 + onMounted(()=>{ + const rect = useRect(root); + console.log(rect); // -> 元素的大小及其相对于视口的位置 + }) + return { root }; }, }; diff --git a/packages/vant/package.json b/packages/vant/package.json index cd1019e13..490010481 100644 --- a/packages/vant/package.json +++ b/packages/vant/package.json @@ -1,19 +1,34 @@ { "name": "vant", - "version": "3.2.8", + "version": "3.3.6", "description": "Mobile UI Components built on Vue", - "main": "lib/index.js", - "module": "es/index.js", + "main": "lib/vant.cjs.js", + "module": "lib/vant.es.js", "style": "lib/index.css", "typings": "lib/index.d.ts", + "unpkg": "lib/vant.min.js", + "jsdelivr": "lib/vant.min.js", + "exports": { + ".": { + "node": { + "import": "./lib/ssr.mjs", + "require": "./lib/ssr.js" + }, + "import": "./lib/vant.es.js", + "require": "./lib/vant.cjs.js", + "types": "./lib/index.d.ts" + }, + "./es": "./lib/vant.es.js", + "./lib": "./lib/vant.cjs.js", + "./es/": "./es/", + "./lib/": "./lib/", + "./package.json": "./package.json" + }, "files": [ "es", "lib", "vetur" ], - "publishConfig": { - "registry": "https://registry.npmjs.org/" - }, "scripts": { "dev": "vant-cli dev", "lint": "vant-cli lint", @@ -25,12 +40,19 @@ "test:watch": "vant-cli test --watch", "test:coverage": "open test/coverage/index.html" }, - "npm": { - "tag": "next" + "publishConfig": { + "registry": "https://registry.npmjs.org/" }, "repository": { "type": "git", - "url": "git@github.com:youzan/vant.git" + "url": "https://github.com/youzan/vant.git", + "directory": "packages/vant" + }, + "bugs": "https://github.com/youzan/vant/issues", + "author": "chenjiahan", + "license": "MIT", + "npm": { + "tag": "next" }, "keywords": [ "ui", @@ -41,8 +63,6 @@ "component", "components" ], - "author": "youzanfe", - "license": "MIT", "dependencies": { "@vant/icons": "^1.7.1", "@vant/popperjs": "^1.1.0", @@ -54,10 +74,11 @@ "devDependencies": { "@vant/area-data": "^1.1.3", "@vant/cli": "workspace:*", + "@vant/eslint-config": "workspace:*", "@vue/compiler-sfc": "^3.2.20", "@vue/runtime-core": "^3.2.20", "@vue/test-utils": "^2.0.0-rc.16", - "typescript": "4.x", + "typescript": "~4.5.2", "vue": "^3.2.20", "vue-router": "^4.0.12" }, @@ -67,11 +88,9 @@ "*.css", "*.less" ], + "web-types": "vetur/web-types.json", "vetur": { "tags": "vetur/tags.json", "attributes": "vetur/attributes.json" - }, - "web-types": "vetur/web-types.json", - "unpkg": "lib/vant.min.js", - "jsdelivr": "lib/vant.min.js" + } } diff --git a/packages/vant/src/action-bar-icon/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/action-bar-icon/test/__snapshots__/index.spec.ts.snap index 9c6c7f696..328419215 100644 --- a/packages/vant/src/action-bar-icon/test/__snapshots__/index.spec.ts.snap +++ b/packages/vant/src/action-bar-icon/test/__snapshots__/index.spec.ts.snap @@ -30,7 +30,7 @@ exports[`should render icon slot with badge correctly 1`] = ` >
Custom Icon -
+
1
@@ -45,7 +45,7 @@ exports[`should render icon slot with dot correctly 1`] = ` >
Custom Icon -
+
Content diff --git a/packages/vant/src/action-bar/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/action-bar/test/__snapshots__/demo.spec.ts.snap index 4f0f8f701..41dd9e613 100644 --- a/packages/vant/src/action-bar/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/action-bar/test/__snapshots__/demo.spec.ts.snap @@ -45,7 +45,7 @@ exports[`should render demo and match snapshot 1`] = ` tabindex="0" >
-
+
Icon1 @@ -55,7 +55,7 @@ exports[`should render demo and match snapshot 1`] = ` tabindex="0" >
-
+
5
@@ -66,7 +66,7 @@ exports[`should render demo and match snapshot 1`] = ` tabindex="0" >
-
+
12
diff --git a/packages/vant/src/address-edit/AddressEdit.tsx b/packages/vant/src/address-edit/AddressEdit.tsx index 69229bfb2..4842c4a01 100644 --- a/packages/vant/src/address-edit/AddressEdit.tsx +++ b/packages/vant/src/address-edit/AddressEdit.tsx @@ -351,7 +351,6 @@ export default defineComponent({ class={bem('button')} loading={props.isSaving} nativeType="submit" - onClick={onSave} /> {props.showDelete && ( - -
+ +
diff --git a/packages/vant/src/cascader/README.md b/packages/vant/src/cascader/README.md index cde09899b..ea1e5c969 100644 --- a/packages/vant/src/cascader/README.md +++ b/packages/vant/src/cascader/README.md @@ -248,7 +248,7 @@ export default { | --- | --- | --- | --- | | title | Title | _string_ | - | | value | Value of selected option | _string \| number_ | - | -| options | Options | _Option[]_ | `[]` | +| options | Options | _CascaderOption[]_ | `[]` | | placeholder | Placeholder of unselected tab | _string_ | `Select` | | active-color | Active color | _string_ | `#ee0a24` | | swipeable `v3.0.11` | Whether to enable gestures to slide left and right | _boolean_ | `false` | @@ -256,14 +256,14 @@ export default { | close-icon `v3.0.10` | Close icon name | _string_ | `cross` | | field-names `v3.0.4` | Custom the fields of options | _object_ | `{ text: 'text', value: 'value', children: 'children' }` | -### Data Structure of Option +### Data Structure of CascaderOption | Key | Description | Type | | ------------------ | ------------------------- | --------------------------- | | text | Option text | _string_ | | value | Option value | _string \| number_ | | color `v3.1.0` | Text color | _string_ | -| children | Cascade children | _Option[]_ | +| children | Cascade children | _CascaderOption[]_ | | disabled `v3.1.2` | Whether to disable option | _boolean_ | | className `v3.1.0` | className for the option | _string \| Array \| object_ | @@ -271,8 +271,8 @@ export default { | Event | Description | Arguments | | --- | --- | --- | -| change | Emitted when active option changed | `{ value, selectedOptions, tabIndex }` | -| finish | Emitted when all options is selected | `{ value, selectedOptions, tabIndex }` | +| change | Emitted when active option changed | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | +| finish | Emitted when all options is selected | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | | close | Emitted when the close icon is clicked | - | | click-tab | Emitted when a tab is clicked | _activeTab: number, title: string_ | @@ -281,7 +281,7 @@ export default { | Name | Description | SlotProps | | --- | --- | --- | | title | Custom title | - | -| option `v3.1.4` | Custom option text | _{ option: Option, selected: boolean }_ | +| option `v3.1.4` | Custom option text | _{ option: CascaderOption, selected: boolean }_ | | options-top `v3.2.7` | Custom the content above the options | _{ tabIndex: number }_ | | options-bottom `v3.2.8` | Custom the content below the options | _{ tabIndex: number }_ | diff --git a/packages/vant/src/cascader/README.zh-CN.md b/packages/vant/src/cascader/README.zh-CN.md index 78fac0a94..09e737e46 100644 --- a/packages/vant/src/cascader/README.zh-CN.md +++ b/packages/vant/src/cascader/README.zh-CN.md @@ -258,7 +258,7 @@ export default { | --- | --- | --- | --- | | title | 顶部标题 | _string_ | - | | value | 选中项的值 | _string \| number_ | - | -| options | 可选项数据源 | _Option[]_ | `[]` | +| options | 可选项数据源 | _CascaderOption[]_ | `[]` | | placeholder | 未选中时的提示文案 | _string_ | `请选择` | | active-color | 选中状态的高亮颜色 | _string_ | `#ee0a24` | | swipeable `v3.0.11` | 是否开启手势左右滑动切换 | _boolean_ | `false` | @@ -266,7 +266,7 @@ export default { | close-icon `v3.0.10` | 关闭[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `cross` | | field-names `v3.0.4` | 自定义 `options` 结构中的字段 | _object_ | `{ text: 'text', value: 'value', children: 'children' }` | -### Option 数据结构 +### CascaderOption 数据结构 `options` 属性是一个由对象构成的数组,数组中的每个对象配置一个可选项,对象可以包含以下值: @@ -275,25 +275,25 @@ export default { | text | 选项文字(必填) | _string_ | | value | 选项对应的值(必填) | _string \| number_ | | color `v3.1.0` | 选项文字颜色 | _string_ | -| children | 子选项列表 | _Option[]_ | +| children | 子选项列表 | _CascaderOption[]_ | | disabled `v3.1.2` | 是否禁用选项 | _boolean_ | | className `v3.1.0` | 为对应列添加额外的 class | _string \| Array \| object_ | ### Events -| 事件 | 说明 | 回调参数 | -| --------- | ---------------------- | -------------------------------------- | -| change | 选中项变化时触发 | `{ value, selectedOptions, tabIndex }` | -| finish | 全部选项选择完成后触发 | `{ value, selectedOptions, tabIndex }` | -| close | 点击关闭图标时触发 | - | -| click-tab | 点击标签时触发 | _tabIndex: number, title: string_ | +| 事件 | 说明 | 回调参数 | +| --- | --- | --- | +| change | 选中项变化时触发 | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | +| finish | 全部选项选择完成后触发 | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ | +| close | 点击关闭图标时触发 | - | +| click-tab | 点击标签时触发 | _tabIndex: number, title: string_ | ### Slots | 名称 | 说明 | 参数 | | --- | --- | --- | | title | 自定义顶部标题 | - | -| option `v3.1.4` | 自定义选项文字 | _{ option: Option, selected: boolean }_ | +| option `v3.1.4` | 自定义选项文字 | _{ option: CascaderOption, selected: boolean }_ | | options-top `v3.2.7` | 自定义选项上方的内容 | _{ tabIndex: number }_ | | options-bottom `v3.2.8` | 自定义选项下方的内容 | _{ tabIndex: number }_ | diff --git a/packages/vant/src/cascader/demo/index.vue b/packages/vant/src/cascader/demo/index.vue index 92a354d19..d821b87a1 100644 --- a/packages/vant/src/cascader/demo/index.vue +++ b/packages/vant/src/cascader/demo/index.vue @@ -55,7 +55,7 @@ const t = useTranslate({ type StateItem = { show: boolean; - value: string | number | null; + value: string | number | undefined; result: string; options?: CascaderOption[]; tabIndex?: number; @@ -68,18 +68,18 @@ const baseState = reactive({ }); const customColorState = reactive({ show: false, - value: null, + value: undefined, result: '', }); const asyncState = reactive({ show: false, - value: null, + value: undefined, result: '', options: t('asyncOptions1'), }); const customFieldState = reactive({ show: false, - value: null, + value: undefined, result: '', }); @@ -91,7 +91,7 @@ const fieldNames = { const customContentState = reactive({ show: false, - value: null, + value: undefined, result: '', }); diff --git a/packages/vant/src/cascader/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/cascader/test/__snapshots__/index.spec.ts.snap index f9e33e7a1..cca0ccf5f 100644 --- a/packages/vant/src/cascader/test/__snapshots__/index.spec.ts.snap +++ b/packages/vant/src/cascader/test/__snapshots__/index.spec.ts.snap @@ -111,7 +111,7 @@ exports[`should update tabs when previous tab is clicked 1`] = `
-
-
- Content - Content - Content + Content 1 + Content 2 + Content 3 ``` @@ -48,9 +48,9 @@ In accordion mode, only one panel can be expanded at the same time. ```html - Content - Content - Content + Content 1 + Content 2 + Content 3 ``` @@ -71,12 +71,12 @@ Use the `disabled` prop to disable CollapseItem. ```html - Content + Content 1 - Content + Content 2 - Content + Content 3 ``` @@ -89,10 +89,10 @@ Use the `disabled` prop to disable CollapseItem. - Content + Content 1 - Content + Content 2 ``` diff --git a/packages/vant/src/collapse/README.zh-CN.md b/packages/vant/src/collapse/README.zh-CN.md index 30d1f7df5..9a2e19ff5 100644 --- a/packages/vant/src/collapse/README.zh-CN.md +++ b/packages/vant/src/collapse/README.zh-CN.md @@ -25,9 +25,15 @@ app.use(CollapseItem); ```html - 内容 - 内容 - 内容 + + 代码是写出来给人看的,附带能在机器上运行。 + + + 技术无非就是那些开发它的人的共同灵魂。 + + + 在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。 + ``` @@ -48,9 +54,15 @@ export default { ```html - 内容 - 内容 - 内容 + + 代码是写出来给人看的,附带能在机器上运行。 + + + 技术无非就是那些开发它的人的共同灵魂。 + + + 在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。 + ``` @@ -71,9 +83,15 @@ export default { ```html - 内容 - 内容 - 内容 + + 代码是写出来给人看的,附带能在机器上运行。 + + + 技术无非就是那些开发它的人的共同灵魂。 + + + 在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。 + ``` @@ -87,10 +105,10 @@ export default { - 内容 + 代码是写出来给人看的,附带能在机器上运行。 - 内容 + 技术无非就是那些开发它的人的共同灵魂。 ``` diff --git a/packages/vant/src/collapse/demo/index.vue b/packages/vant/src/collapse/demo/index.vue index e0d69a050..4eca23131 100644 --- a/packages/vant/src/collapse/demo/index.vue +++ b/packages/vant/src/collapse/demo/index.vue @@ -7,14 +7,18 @@ import { useTranslate } from '../../../docs/site/use-translate'; const t = useTranslate({ 'zh-CN': { + text1: '代码是写出来给人看的,附带能在机器上运行。', + text2: '技术无非就是那些开发它的人的共同灵魂。', + text3: '在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。', accordion: '手风琴', titleSlot: '自定义标题内容', - text: '代码是写出来给人看的,附带能在机器上运行', }, 'en-US': { + text1: 'Content 1', + text2: 'Content 2', + text3: 'Content 3', accordion: 'Accordion', titleSlot: 'Custom title', - text: 'Content', }, }); @@ -28,13 +32,13 @@ const active4 = ref([]); - {{ t('text') }} + {{ t('text1') }} - {{ t('text') }} + {{ t('text2') }} - {{ t('text') }} + {{ t('text3') }} @@ -42,13 +46,13 @@ const active4 = ref([]); - {{ t('text') }} + {{ t('text1') }} - {{ t('text') }} + {{ t('text2') }} - {{ t('text') }} + {{ t('text3') }} @@ -56,13 +60,13 @@ const active4 = ref([]); - {{ t('text') }} + {{ t('text1') }} - {{ t('text') }} + {{ t('text2') }} - {{ t('text') }} + {{ t('text3') }} @@ -73,14 +77,14 @@ const active4 = ref([]); - {{ t('text') }} + {{ t('text1') }} - {{ t('text') }} + {{ t('text2') }} diff --git a/packages/vant/src/collapse/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/collapse/test/__snapshots__/demo.spec.ts.snap index 7693a1511..ae5409411 100644 --- a/packages/vant/src/collapse/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/collapse/test/__snapshots__/demo.spec.ts.snap @@ -19,7 +19,7 @@ exports[`should render demo and match snapshot 1`] = `
- Content + Content 1
@@ -73,7 +73,7 @@ exports[`should render demo and match snapshot 1`] = `
- Content + Content 1
diff --git a/packages/vant/src/config-provider/README.zh-CN.md b/packages/vant/src/config-provider/README.zh-CN.md index d349a3999..77c64f4e7 100644 --- a/packages/vant/src/config-provider/README.zh-CN.md +++ b/packages/vant/src/config-provider/README.zh-CN.md @@ -120,7 +120,7 @@ Vant 中的 CSS 变量分为 **基础变量** 和 **组件变量**。组件变 #### 修改变量 -由于 CSS 变量继承机制的原因, 两者的修改方式有一定差异: +由于 CSS 变量继承机制的原因,两者的修改方式有一定差异: - 基础变量只能通过 `root 选择器` 修改,不能通过 `ConfigProvider 组件` 修改。 - 组件变量可以通过 `root 选择器` 和 `ConfigProvider 组件` 修改。 diff --git a/packages/vant/src/count-down/CountDown.tsx b/packages/vant/src/count-down/CountDown.tsx index 4e746a73f..7254d24fb 100644 --- a/packages/vant/src/count-down/CountDown.tsx +++ b/packages/vant/src/count-down/CountDown.tsx @@ -58,7 +58,7 @@ export default defineComponent({ }); return () => ( -
+
{slots.default ? slots.default(current.value) : timeText.value}
); diff --git a/packages/vant/src/count-down/test/__snapshots__/index.spec.tsx.snap b/packages/vant/src/count-down/test/__snapshots__/index.spec.tsx.snap index 6db98621a..1233e3fdd 100644 --- a/packages/vant/src/count-down/test/__snapshots__/index.spec.tsx.snap +++ b/packages/vant/src/count-down/test/__snapshots__/index.spec.tsx.snap @@ -1,31 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should format S milliseconds correctly 1`] = ` -
+
01-5
`; exports[`should format SS milliseconds correctly 1`] = ` -
+
01-50
`; exports[`should format complete time correctly 1`] = ` -
+
01-05-59-59-999
`; exports[`should format incomplete time correctly 1`] = ` -
+
29-59-59-999
`; exports[`should not start counting when auto-start prop is false 1`] = ` -
+
100
`; diff --git a/packages/vant/src/dialog/README.zh-CN.md b/packages/vant/src/dialog/README.zh-CN.md index cc57a1e0f..735f1f331 100644 --- a/packages/vant/src/dialog/README.zh-CN.md +++ b/packages/vant/src/dialog/README.zh-CN.md @@ -58,13 +58,13 @@ export default { ```js Dialog.alert({ title: '标题', - message: '弹窗内容', + message: '代码是写出来给人看的,附带能在机器上运行。', }).then(() => { // on close }); Dialog.alert({ - message: '弹窗内容', + message: '生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。', }).then(() => { // on close }); @@ -77,7 +77,8 @@ Dialog.alert({ ```js Dialog.confirm({ title: '标题', - message: '弹窗内容', + message: + '如果解决方法是丑陋的,那就肯定还有更好的解决方法,只是还没有发现而已。', }) .then(() => { // on confirm @@ -94,14 +95,14 @@ Dialog.confirm({ ```js Dialog.alert({ title: '标题', - message: '弹窗内容', + message: '代码是写出来给人看的,附带能在机器上运行。', theme: 'round-button', }).then(() => { // on close }); Dialog.alert({ - message: '弹窗内容', + message: '生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。', theme: 'round-button', }).then(() => { // on close @@ -127,7 +128,8 @@ const beforeClose = (action) => Dialog.confirm({ title: '标题', - message: '弹窗内容', + message: + '如果解决方法是丑陋的,那就肯定还有更好的解决方法,只是还没有发现而已。', beforeClose, }); ``` diff --git a/packages/vant/src/dialog/demo/index.vue b/packages/vant/src/dialog/demo/index.vue index 3ac5f1dbe..30dc145da 100644 --- a/packages/vant/src/dialog/demo/index.vue +++ b/packages/vant/src/dialog/demo/index.vue @@ -3,7 +3,7 @@ import VanCell from '../../cell'; import { Dialog } from '..'; import { ref } from 'vue'; import { useTranslate } from '../../../docs/site/use-translate'; -import type { DialogAction } from '../Dialog'; +import type { DialogAction } from '../types'; const VanDialog = Dialog.Component; @@ -13,16 +13,22 @@ const t = useTranslate({ alert1: '提示弹窗', alert2: '提示弹窗(无标题)', confirm: '确认弹窗', + content1: '代码是写出来给人看的,附带能在机器上运行。', + content2: '生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。', + content3: + '如果解决方法是丑陋的,那就肯定还有更好的解决方法,只是还没有发现而已。', beforeClose: '异步关闭', roundButton: '圆角按钮样式', componentCall: '组件调用', - content: '代码是写出来给人看的,附带能在机器上运行', }, 'en-US': { title: 'Title', alert1: 'Alert', alert2: 'Alert without title', confirm: 'Confirm dialog', + content1: 'Content', + content2: 'Content', + content3: 'Content', beforeClose: 'Before Close', roundButton: 'Round Button Style', componentCall: 'Component Call', @@ -35,13 +41,13 @@ const image = 'https://img.yzcdn.cn/vant/apple-3.jpg'; const onClickAlert = () => { Dialog.alert({ title: t('title'), - message: t('content'), + message: t('content1'), }); }; const onClickAlert2 = () => { Dialog.alert({ - message: t('content'), + message: t('content2'), }); }; @@ -49,21 +55,21 @@ const onClickRound = () => { Dialog.alert({ theme: 'round-button', title: t('title'), - message: t('content'), + message: t('content1'), }); }; const onClickRound2 = () => { Dialog.alert({ theme: 'round-button', - message: t('content'), + message: t('content2'), }); }; const onClickConfirm = () => { Dialog.confirm({ title: t('title'), - message: t('content'), + message: t('content3'), }); }; @@ -75,7 +81,7 @@ const onClickBeforeClose = () => { Dialog.confirm({ title: t('title'), - message: t('content'), + message: t('content3'), beforeClose, }); }; diff --git a/packages/vant/src/form/README.md b/packages/vant/src/form/README.md index 76d2f9fe0..cc928af84 100644 --- a/packages/vant/src/form/README.md +++ b/packages/vant/src/form/README.md @@ -431,9 +431,9 @@ export default { setup() { const result = ref(''); const showArea = ref(false); - const onConfirm = (value) => { + const onConfirm = (areaValues) => { showArea.value = false; - result.value = values + result.value = areaValues .filter((item) => !!item) .map((item) => item.name) .join('/'); @@ -492,7 +492,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | | label-width | Field label width | _number \| string_ | `6.2em` | -| label-align | Field label align, can be set to `center` `right` | _string_ | `left` | +| label-align | Field label align, can be set to `center` `right` | _string_ | `left` | | input-align | Field input align, can be set to `center` `right` | _string_ | `left` | | error-message-align | Error message align, can be set to `center` `right` | _string_ | `left` | | validate-trigger | When to validate the form,can be set to `onChange`、`onSubmit` | _string_ | `onBlur` | @@ -509,7 +509,7 @@ export default { | Key | Description | Type | | --- | --- | --- | -| required | Whether to be a required field | _boolean_ | +| required | Whether to be a required field, the value is not allowed to be empty string, empty array, `undefined`, `null` | _boolean_ | | message | Error message | _string \| (value, rule) => string_ | | validator | Custom validator | _(value, rule) => boolean \| string \| Promise_ | | pattern | Regex pattern | _RegExp_ | diff --git a/packages/vant/src/form/README.zh-CN.md b/packages/vant/src/form/README.zh-CN.md index 6f124bd99..2f4e1b769 100644 --- a/packages/vant/src/form/README.zh-CN.md +++ b/packages/vant/src/form/README.zh-CN.md @@ -461,9 +461,9 @@ export default { setup() { const result = ref(''); const showArea = ref(false); - const onConfirm = (value) => { + const onConfirm = (areaValues) => { showArea.value = false; - result.value = values + result.value = areaValues .filter((item) => !!item) .map((item) => item.name) .join('/'); @@ -524,7 +524,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | label-width | 表单项 label 宽度,默认单位为`px` | _number \| string_ | `6.2em` | -| label-align |  表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` | +| label-align | 表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` | | input-align | 输入框对齐方式,可选值为 `center` `right` | _string_ | `left` | | error-message-align | 错误提示文案对齐方式,可选值为 `center` `right` | _string_ | `left` | | validate-trigger | 表单校验触发时机,可选值为 `onChange`、`onSubmit`,详见下表 | _string_ | `onBlur` | @@ -545,14 +545,14 @@ export default { | 键名 | 说明 | 类型 | | --- | --- | --- | -| required | 是否为必选字段 | _boolean_ | +| required | 是否为必选字段,当值为空字符串、空数组、`undefined`、`null` 时,校验不通过 | _boolean_ | | message | 错误提示文案 | _string \| (value, rule) => string_ | | validator | 通过函数进行校验 | _(value, rule) => boolean \| string \| Promise_ | | pattern | 通过正则表达式进行校验 | _RegExp_ | | trigger | 本项规则的触发时机,可选值为 `onChange`、`onBlur` | _string_ | | formatter | 格式化函数,将表单项的值转换后进行校验 | _(value, rule) => any_ | -### validate-trigger  可选值 +### validate-trigger 可选值 通过 `validate-trigger` 属性可以自定义表单校验的触发时机。 diff --git a/packages/vant/src/form/demo/FieldTypeArea.vue b/packages/vant/src/form/demo/FieldTypeArea.vue index af5a04f1b..d6fc5df12 100644 --- a/packages/vant/src/form/demo/FieldTypeArea.vue +++ b/packages/vant/src/form/demo/FieldTypeArea.vue @@ -23,8 +23,8 @@ const t = useTranslate({ const areaCode = ref(''); const showArea = ref(false); -const onConfirm = (values: AreaColumnOption[]) => { - areaCode.value = values +const onConfirm = (areaValues: AreaColumnOption[]) => { + areaCode.value = areaValues .filter((item) => !!item) .map((item) => item.name) .join('/'); diff --git a/packages/vant/src/form/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/form/test/__snapshots__/demo.spec.ts.snap index b2072dc75..04062414c 100644 --- a/packages/vant/src/form/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/form/test/__snapshots__/demo.spec.ts.snap @@ -459,7 +459,11 @@ exports[`should render demo and match snapshot 1`] = `
-
+
diff --git a/packages/vant/src/grid/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/grid/test/__snapshots__/demo.spec.ts.snap index f2a4ab92a..a9807a062 100644 --- a/packages/vant/src/grid/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/grid/test/__snapshots__/demo.spec.ts.snap @@ -433,7 +433,7 @@ exports[`should render demo and match snapshot 1`] = ` >
-
+
@@ -446,7 +446,7 @@ exports[`should render demo and match snapshot 1`] = ` >
-
+
99+
diff --git a/packages/vant/src/grid/test/__snapshots__/index.spec.js.snap b/packages/vant/src/grid/test/__snapshots__/index.spec.js.snap index e24978336..92931e130 100644 --- a/packages/vant/src/grid/test/__snapshots__/index.spec.js.snap +++ b/packages/vant/src/grid/test/__snapshots__/index.spec.js.snap @@ -8,7 +8,7 @@ exports[`should render icon-slot correctly 1`] = `
Custom Icon -
+
1
diff --git a/packages/vant/src/icon/demo/index.vue b/packages/vant/src/icon/demo/index.vue index 9b8b1e109..241361dde 100644 --- a/packages/vant/src/icon/demo/index.vue +++ b/packages/vant/src/icon/demo/index.vue @@ -93,7 +93,7 @@ const copy = (icon: string, option: Record = {}) => {