Compare commits

...

5 Commits

Author SHA1 Message Date
neverland
e3c0c7ea46
docs(@vant/cli): add type declaration guide (#9451) 2021-09-11 17:50:14 +08:00
neverland
147359b227
docs(@vant/cli): update output format (#9450)
* docs(@vant/cli): update output format

* docs: upd
2021-09-11 17:45:47 +08:00
Aex
5b8f1d9be1
fix(slider): empty range value (#9409)
* fix: slider empty range value

* fix: update slider default range value
2021-09-11 16:48:52 +08:00
dependabot[bot]
51b326fcdb
build(deps): bump prettier from 2.3.2 to 2.4.0 (#9443)
Bumps [prettier](https://github.com/prettier/prettier) from 2.3.2 to 2.4.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.3.2...2.4.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-11 16:46:49 +08:00
dependabot[bot]
ab83a771ca
build(deps): bump @babel/preset-env from 7.15.4 to 7.15.6 (#9442)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.15.4 to 7.15.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.15.6/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-11 16:42:02 +08:00
4 changed files with 74 additions and 45 deletions

View File

@ -53,19 +53,21 @@ button
``` ```
project project
├─ es # es 目录下的代码遵循 esmodule 规范 ├─ es # es 目录下的代码遵循 esmodule 规范
│ ├─ button # button 组件编译后的代码目录 │ ├─ button # button 组件编译后的代码目录
│ ├─ dialog # dialog 组件编译后的代码目录 │ ├─ dialog # dialog 组件编译后的代码目录
│ └─ index.js # 引入所有组件的入口,支持 tree shaking │ └─ index.js # 引入所有组件的入口 (ESModule)
└─ lib # lib 目录下的代码遵循 commonjs 规范 └─ lib # lib 目录下的代码遵循 commonjs 规范
├─ button # button 组件编译后的代码目录 ├─ button # button 组件编译后的代码目录
├─ dialog # dialog 组件编译后的代码目录 ├─ dialog # dialog 组件编译后的代码目录
├─ index.js # 引入所有组件的入口 ├─ index.js # 引入所有组件的入口
├─ index.less # 所有组件未编译的样式 ├─ index.less # 所有组件未编译的样式入口
├─ index.css # 所有组件打包后的样式,用于 CDN 引入 ├─ index.css # 打包后的组件样式,用于 CDN 引入
├─ name.js # 所有组件打包后的脚本,未压缩,用于 CDN 引入 ├─ [name].js # 打包后的组件脚本UMD 格式
└─ name.min.js # 所有组件打包后的脚本,已压缩,用于 CDN 引入 ├─ [name].es.js # 打包后的组件脚本ESModule 格式
├─ [name].min.js # 打包和压缩后的组件脚本UMD 格式
└─ [name].es.min.js # 打包和压缩后的组件脚本ESModule 格式
``` ```
单个组件编译后的目录如下: 单个组件编译后的目录如下:
@ -79,3 +81,30 @@ button
├─ index.js # 按需引入编译后的样式 ├─ index.js # 按需引入编译后的样式
└─ less.js # 按需引入未编译的样式,可用于主题定制 └─ less.js # 按需引入未编译的样式,可用于主题定制
``` ```
### 生成类型声明
当组件库使用 TS 编写,且根目录下存在 `tsconfig.declaration.json` 文件Vant Cli 会自动生成 `.d.ts` 类型声明文件。
`tsconfig.declaration.json` 的参考格式如下:
```json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": ".",
"emitDeclarationOnly": true
},
"include": ["es/**/*", "lib/**/*"],
"exclude": ["node_modules", "**/test/**/*", "**/demo/**/*"]
}
```
成功生成类型声明后,请在 `package.json` 中添加类型入口声明:
```json
{
"typings": "lib/index.d.ts"
}
```

View File

@ -40,7 +40,7 @@
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.15.5", "@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.4", "@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0", "@babel/preset-typescript": "^7.15.0",
"@docsearch/css": "3.0.0-alpha.40", "@docsearch/css": "3.0.0-alpha.40",
"@docsearch/js": "3.0.0-alpha.40", "@docsearch/js": "3.0.0-alpha.40",
@ -76,7 +76,7 @@
"ora": "^5.4.1", "ora": "^5.4.1",
"postcss": "^8.3.6", "postcss": "^8.3.6",
"postcss-load-config": "^3.1.0", "postcss-load-config": "^3.1.0",
"prettier": "^2.3.2", "prettier": "^2.4.0",
"release-it": "^14.11.5", "release-it": "^14.11.5",
"stylelint": "^13.13.1", "stylelint": "^13.13.1",
"transliteration": "^2.2.0", "transliteration": "^2.2.0",

View File

@ -130,17 +130,17 @@ export default defineComponent({
const isSameValue = (newValue: SliderValue, oldValue: SliderValue) => const isSameValue = (newValue: SliderValue, oldValue: SliderValue) =>
JSON.stringify(newValue) === JSON.stringify(oldValue); JSON.stringify(newValue) === JSON.stringify(oldValue);
// 处理两个滑块重叠之后的情况 const handleRangeValue = (value: NumberRange) => {
const handleOverlap = (value: NumberRange) => { // 设置默认值
if (value[0] > value[1]) { const left = value[0] ?? Number(props.min);
return value.slice(0).reverse(); const right = value[1] ?? Number(props.max);
} // 处理两个滑块重叠之后的情况
return value; return left > right ? [right, left] : [left, right];
}; };
const updateValue = (value: SliderValue, end?: boolean) => { const updateValue = (value: SliderValue, end?: boolean) => {
if (isRange(value)) { if (isRange(value)) {
value = handleOverlap(value).map(format) as NumberRange; value = handleRangeValue(value).map(format) as NumberRange;
} else { } else {
value = format(value); value = format(value);
} }

View File

@ -139,7 +139,7 @@
dependencies: dependencies:
"@babel/highlight" "^7.14.5" "@babel/highlight" "^7.14.5"
"@babel/compat-data@^7.13.11", "@babel/compat-data@^7.14.7", "@babel/compat-data@^7.15.0": "@babel/compat-data@^7.13.11", "@babel/compat-data@^7.15.0":
version "7.15.0" version "7.15.0"
resolved "https://registry.nlark.com/@babel/compat-data/download/@babel/compat-data-7.15.0.tgz#2dbaf8b85334796cafbb0f5793a90a2fc010b176" resolved "https://registry.nlark.com/@babel/compat-data/download/@babel/compat-data-7.15.0.tgz#2dbaf8b85334796cafbb0f5793a90a2fc010b176"
integrity sha1-Lbr4uFM0eWyvuw9Xk6kKL8AQsXY= integrity sha1-Lbr4uFM0eWyvuw9Xk6kKL8AQsXY=
@ -189,7 +189,7 @@
"@babel/helper-explode-assignable-expression" "^7.15.4" "@babel/helper-explode-assignable-expression" "^7.15.4"
"@babel/types" "^7.15.4" "@babel/types" "^7.15.4"
"@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.14.5", "@babel/helper-compilation-targets@^7.15.4": "@babel/helper-compilation-targets@^7.13.0", "@babel/helper-compilation-targets@^7.15.4":
version "7.15.4" version "7.15.4"
resolved "https://registry.nlark.com/@babel/helper-compilation-targets/download/@babel/helper-compilation-targets-7.15.4.tgz?cache=0&sync_timestamp=1630619160059&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40babel%2Fhelper-compilation-targets%2Fdownload%2F%40babel%2Fhelper-compilation-targets-7.15.4.tgz#cf6d94f30fbefc139123e27dd6b02f65aeedb7b9" resolved "https://registry.nlark.com/@babel/helper-compilation-targets/download/@babel/helper-compilation-targets-7.15.4.tgz?cache=0&sync_timestamp=1630619160059&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40babel%2Fhelper-compilation-targets%2Fdownload%2F%40babel%2Fhelper-compilation-targets-7.15.4.tgz#cf6d94f30fbefc139123e27dd6b02f65aeedb7b9"
integrity sha1-z22U8w++/BORI+J91rAvZa7tt7k= integrity sha1-z22U8w++/BORI+J91rAvZa7tt7k=
@ -469,16 +469,16 @@
"@babel/helper-plugin-utils" "^7.14.5" "@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-syntax-numeric-separator" "^7.10.4" "@babel/plugin-syntax-numeric-separator" "^7.10.4"
"@babel/plugin-proposal-object-rest-spread@^7.14.7": "@babel/plugin-proposal-object-rest-spread@^7.15.6":
version "7.14.7" version "7.15.6"
resolved "https://registry.nlark.com/@babel/plugin-proposal-object-rest-spread/download/@babel/plugin-proposal-object-rest-spread-7.14.7.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40babel%2Fplugin-proposal-object-rest-spread%2Fdownload%2F%40babel%2Fplugin-proposal-object-rest-spread-7.14.7.tgz#5920a2b3df7f7901df0205974c0641b13fd9d363" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.15.6.tgz#ef68050c8703d07b25af402cb96cf7f34a68ed11"
integrity sha1-WSCis99/eQHfAgWXTAZBsT/Z02M= integrity sha512-qtOHo7A1Vt+O23qEAX+GdBpqaIuD3i9VRrWgCJeq7WO6H2d14EK3q11urj5Te2MAeK97nMiIdRpwd/ST4JFbNg==
dependencies: dependencies:
"@babel/compat-data" "^7.14.7" "@babel/compat-data" "^7.15.0"
"@babel/helper-compilation-targets" "^7.14.5" "@babel/helper-compilation-targets" "^7.15.4"
"@babel/helper-plugin-utils" "^7.14.5" "@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-syntax-object-rest-spread" "^7.8.3" "@babel/plugin-syntax-object-rest-spread" "^7.8.3"
"@babel/plugin-transform-parameters" "^7.14.5" "@babel/plugin-transform-parameters" "^7.15.4"
"@babel/plugin-proposal-optional-catch-binding@^7.14.5": "@babel/plugin-proposal-optional-catch-binding@^7.14.5":
version "7.14.5" version "7.14.5"
@ -818,7 +818,7 @@
"@babel/helper-plugin-utils" "^7.14.5" "@babel/helper-plugin-utils" "^7.14.5"
"@babel/helper-replace-supers" "^7.14.5" "@babel/helper-replace-supers" "^7.14.5"
"@babel/plugin-transform-parameters@^7.14.5", "@babel/plugin-transform-parameters@^7.15.4": "@babel/plugin-transform-parameters@^7.15.4":
version "7.15.4" version "7.15.4"
resolved "https://registry.nlark.com/@babel/plugin-transform-parameters/download/@babel/plugin-transform-parameters-7.15.4.tgz#5f2285cc3160bf48c8502432716b48504d29ed62" resolved "https://registry.nlark.com/@babel/plugin-transform-parameters/download/@babel/plugin-transform-parameters-7.15.4.tgz#5f2285cc3160bf48c8502432716b48504d29ed62"
integrity sha1-XyKFzDFgv0jIUCQycWtIUE0p7WI= integrity sha1-XyKFzDFgv0jIUCQycWtIUE0p7WI=
@ -906,10 +906,10 @@
"@babel/helper-create-regexp-features-plugin" "^7.14.5" "@babel/helper-create-regexp-features-plugin" "^7.14.5"
"@babel/helper-plugin-utils" "^7.14.5" "@babel/helper-plugin-utils" "^7.14.5"
"@babel/preset-env@^7.15.4": "@babel/preset-env@^7.15.6":
version "7.15.4" version "7.15.6"
resolved "https://registry.nlark.com/@babel/preset-env/download/@babel/preset-env-7.15.4.tgz#197e7f99a755c488f0af411af179cbd10de6e815" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.15.6.tgz#0f3898db9d63d320f21b17380d8462779de57659"
integrity sha1-GX5/madVxIjwr0Ea8XnL0Q3m6BU= integrity sha512-L+6jcGn7EWu7zqaO2uoTDjjMBW+88FXzV8KvrBl2z6MtRNxlsmUNRlZPaNNPUTgqhyC5DHNFk/2Jmra+ublZWw==
dependencies: dependencies:
"@babel/compat-data" "^7.15.0" "@babel/compat-data" "^7.15.0"
"@babel/helper-compilation-targets" "^7.15.4" "@babel/helper-compilation-targets" "^7.15.4"
@ -925,7 +925,7 @@
"@babel/plugin-proposal-logical-assignment-operators" "^7.14.5" "@babel/plugin-proposal-logical-assignment-operators" "^7.14.5"
"@babel/plugin-proposal-nullish-coalescing-operator" "^7.14.5" "@babel/plugin-proposal-nullish-coalescing-operator" "^7.14.5"
"@babel/plugin-proposal-numeric-separator" "^7.14.5" "@babel/plugin-proposal-numeric-separator" "^7.14.5"
"@babel/plugin-proposal-object-rest-spread" "^7.14.7" "@babel/plugin-proposal-object-rest-spread" "^7.15.6"
"@babel/plugin-proposal-optional-catch-binding" "^7.14.5" "@babel/plugin-proposal-optional-catch-binding" "^7.14.5"
"@babel/plugin-proposal-optional-chaining" "^7.14.5" "@babel/plugin-proposal-optional-chaining" "^7.14.5"
"@babel/plugin-proposal-private-methods" "^7.14.5" "@babel/plugin-proposal-private-methods" "^7.14.5"
@ -978,7 +978,7 @@
"@babel/plugin-transform-unicode-escapes" "^7.14.5" "@babel/plugin-transform-unicode-escapes" "^7.14.5"
"@babel/plugin-transform-unicode-regex" "^7.14.5" "@babel/plugin-transform-unicode-regex" "^7.14.5"
"@babel/preset-modules" "^0.1.4" "@babel/preset-modules" "^0.1.4"
"@babel/types" "^7.15.4" "@babel/types" "^7.15.6"
babel-plugin-polyfill-corejs2 "^0.2.2" babel-plugin-polyfill-corejs2 "^0.2.2"
babel-plugin-polyfill-corejs3 "^0.2.2" babel-plugin-polyfill-corejs3 "^0.2.2"
babel-plugin-polyfill-regenerator "^0.2.2" babel-plugin-polyfill-regenerator "^0.2.2"
@ -1036,10 +1036,10 @@
debug "^4.1.0" debug "^4.1.0"
globals "^11.1.0" globals "^11.1.0"
"@babel/types@^7.0.0", "@babel/types@^7.15.0", "@babel/types@^7.15.4", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": "@babel/types@^7.0.0", "@babel/types@^7.15.0", "@babel/types@^7.15.4", "@babel/types@^7.15.6", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
version "7.15.4" version "7.15.6"
resolved "https://registry.nlark.com/@babel/types/download/@babel/types-7.15.4.tgz?cache=0&sync_timestamp=1630619138925&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.15.4.tgz#74eeb86dbd6748d2741396557b9860e57fce0a0d" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.6.tgz#99abdc48218b2881c058dd0a7ab05b99c9be758f"
integrity sha1-dO64bb1nSNJ0E5ZVe5hg5X/OCg0= integrity sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==
dependencies: dependencies:
"@babel/helper-validator-identifier" "^7.14.9" "@babel/helper-validator-identifier" "^7.14.9"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
@ -6533,10 +6533,10 @@ prepend-http@^2.0.0:
resolved "https://registry.nlark.com/prepend-http/download/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" resolved "https://registry.nlark.com/prepend-http/download/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
prettier@^2.3.2: prettier@^2.4.0:
version "2.3.2" version "2.4.0"
resolved "https://registry.nlark.com/prettier/download/prettier-2.3.2.tgz?cache=0&sync_timestamp=1624696193562&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fprettier%2Fdownload%2Fprettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.0.tgz#85bdfe0f70c3e777cf13a4ffff39713ca6f64cba"
integrity sha1-7ygKBewlNxLkhiM9tcbyNEHnNC0= integrity sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==
pretty-format@^27.0.0, pretty-format@^27.1.0: pretty-format@^27.0.0, pretty-format@^27.1.0:
version "27.1.0" version "27.1.0"