mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-06-04 17:38:12 +08:00
Compare commits
5 Commits
ba4a0760bb
...
e3c0c7ea46
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3c0c7ea46 | ||
|
|
147359b227 | ||
|
|
5b8f1d9be1 | ||
|
|
51b326fcdb | ||
|
|
ab83a771ca |
@ -53,19 +53,21 @@ button
|
||||
|
||||
```
|
||||
project
|
||||
├─ es # es 目录下的代码遵循 esmodule 规范
|
||||
│ ├─ button # button 组件编译后的代码目录
|
||||
│ ├─ dialog # dialog 组件编译后的代码目录
|
||||
│ └─ index.js # 引入所有组件的入口,支持 tree shaking
|
||||
├─ es # es 目录下的代码遵循 esmodule 规范
|
||||
│ ├─ button # button 组件编译后的代码目录
|
||||
│ ├─ dialog # dialog 组件编译后的代码目录
|
||||
│ └─ index.js # 引入所有组件的入口 (ESModule)
|
||||
│
|
||||
└─ lib # lib 目录下的代码遵循 commonjs 规范
|
||||
├─ button # button 组件编译后的代码目录
|
||||
├─ dialog # dialog 组件编译后的代码目录
|
||||
├─ index.js # 引入所有组件的入口
|
||||
├─ index.less # 所有组件未编译的样式
|
||||
├─ index.css # 所有组件打包后的样式,用于 CDN 引入
|
||||
├─ name.js # 所有组件打包后的脚本,未压缩,用于 CDN 引入
|
||||
└─ name.min.js # 所有组件打包后的脚本,已压缩,用于 CDN 引入
|
||||
└─ lib # lib 目录下的代码遵循 commonjs 规范
|
||||
├─ button # button 组件编译后的代码目录
|
||||
├─ dialog # dialog 组件编译后的代码目录
|
||||
├─ index.js # 引入所有组件的入口
|
||||
├─ index.less # 所有组件未编译的样式入口
|
||||
├─ index.css # 打包后的组件样式,用于 CDN 引入
|
||||
├─ [name].js # 打包后的组件脚本,UMD 格式
|
||||
├─ [name].es.js # 打包后的组件脚本,ESModule 格式
|
||||
├─ [name].min.js # 打包和压缩后的组件脚本,UMD 格式
|
||||
└─ [name].es.min.js # 打包和压缩后的组件脚本,ESModule 格式
|
||||
```
|
||||
|
||||
单个组件编译后的目录如下:
|
||||
@ -79,3 +81,30 @@ button
|
||||
├─ index.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"
|
||||
}
|
||||
```
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.15.5",
|
||||
"@babel/preset-env": "^7.15.4",
|
||||
"@babel/preset-env": "^7.15.6",
|
||||
"@babel/preset-typescript": "^7.15.0",
|
||||
"@docsearch/css": "3.0.0-alpha.40",
|
||||
"@docsearch/js": "3.0.0-alpha.40",
|
||||
@ -76,7 +76,7 @@
|
||||
"ora": "^5.4.1",
|
||||
"postcss": "^8.3.6",
|
||||
"postcss-load-config": "^3.1.0",
|
||||
"prettier": "^2.3.2",
|
||||
"prettier": "^2.4.0",
|
||||
"release-it": "^14.11.5",
|
||||
"stylelint": "^13.13.1",
|
||||
"transliteration": "^2.2.0",
|
||||
|
||||
@ -130,17 +130,17 @@ export default defineComponent({
|
||||
const isSameValue = (newValue: SliderValue, oldValue: SliderValue) =>
|
||||
JSON.stringify(newValue) === JSON.stringify(oldValue);
|
||||
|
||||
// 处理两个滑块重叠之后的情况
|
||||
const handleOverlap = (value: NumberRange) => {
|
||||
if (value[0] > value[1]) {
|
||||
return value.slice(0).reverse();
|
||||
}
|
||||
return value;
|
||||
const handleRangeValue = (value: NumberRange) => {
|
||||
// 设置默认值
|
||||
const left = value[0] ?? Number(props.min);
|
||||
const right = value[1] ?? Number(props.max);
|
||||
// 处理两个滑块重叠之后的情况
|
||||
return left > right ? [right, left] : [left, right];
|
||||
};
|
||||
|
||||
const updateValue = (value: SliderValue, end?: boolean) => {
|
||||
if (isRange(value)) {
|
||||
value = handleOverlap(value).map(format) as NumberRange;
|
||||
value = handleRangeValue(value).map(format) as NumberRange;
|
||||
} else {
|
||||
value = format(value);
|
||||
}
|
||||
|
||||
48
yarn.lock
48
yarn.lock
@ -139,7 +139,7 @@
|
||||
dependencies:
|
||||
"@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"
|
||||
resolved "https://registry.nlark.com/@babel/compat-data/download/@babel/compat-data-7.15.0.tgz#2dbaf8b85334796cafbb0f5793a90a2fc010b176"
|
||||
integrity sha1-Lbr4uFM0eWyvuw9Xk6kKL8AQsXY=
|
||||
@ -189,7 +189,7 @@
|
||||
"@babel/helper-explode-assignable-expression" "^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"
|
||||
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=
|
||||
@ -469,16 +469,16 @@
|
||||
"@babel/helper-plugin-utils" "^7.14.5"
|
||||
"@babel/plugin-syntax-numeric-separator" "^7.10.4"
|
||||
|
||||
"@babel/plugin-proposal-object-rest-spread@^7.14.7":
|
||||
version "7.14.7"
|
||||
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"
|
||||
integrity sha1-WSCis99/eQHfAgWXTAZBsT/Z02M=
|
||||
"@babel/plugin-proposal-object-rest-spread@^7.15.6":
|
||||
version "7.15.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.15.6.tgz#ef68050c8703d07b25af402cb96cf7f34a68ed11"
|
||||
integrity sha512-qtOHo7A1Vt+O23qEAX+GdBpqaIuD3i9VRrWgCJeq7WO6H2d14EK3q11urj5Te2MAeK97nMiIdRpwd/ST4JFbNg==
|
||||
dependencies:
|
||||
"@babel/compat-data" "^7.14.7"
|
||||
"@babel/helper-compilation-targets" "^7.14.5"
|
||||
"@babel/compat-data" "^7.15.0"
|
||||
"@babel/helper-compilation-targets" "^7.15.4"
|
||||
"@babel/helper-plugin-utils" "^7.14.5"
|
||||
"@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":
|
||||
version "7.14.5"
|
||||
@ -818,7 +818,7 @@
|
||||
"@babel/helper-plugin-utils" "^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"
|
||||
resolved "https://registry.nlark.com/@babel/plugin-transform-parameters/download/@babel/plugin-transform-parameters-7.15.4.tgz#5f2285cc3160bf48c8502432716b48504d29ed62"
|
||||
integrity sha1-XyKFzDFgv0jIUCQycWtIUE0p7WI=
|
||||
@ -906,10 +906,10 @@
|
||||
"@babel/helper-create-regexp-features-plugin" "^7.14.5"
|
||||
"@babel/helper-plugin-utils" "^7.14.5"
|
||||
|
||||
"@babel/preset-env@^7.15.4":
|
||||
version "7.15.4"
|
||||
resolved "https://registry.nlark.com/@babel/preset-env/download/@babel/preset-env-7.15.4.tgz#197e7f99a755c488f0af411af179cbd10de6e815"
|
||||
integrity sha1-GX5/madVxIjwr0Ea8XnL0Q3m6BU=
|
||||
"@babel/preset-env@^7.15.6":
|
||||
version "7.15.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.15.6.tgz#0f3898db9d63d320f21b17380d8462779de57659"
|
||||
integrity sha512-L+6jcGn7EWu7zqaO2uoTDjjMBW+88FXzV8KvrBl2z6MtRNxlsmUNRlZPaNNPUTgqhyC5DHNFk/2Jmra+ublZWw==
|
||||
dependencies:
|
||||
"@babel/compat-data" "^7.15.0"
|
||||
"@babel/helper-compilation-targets" "^7.15.4"
|
||||
@ -925,7 +925,7 @@
|
||||
"@babel/plugin-proposal-logical-assignment-operators" "^7.14.5"
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator" "^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-chaining" "^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-regex" "^7.14.5"
|
||||
"@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-corejs3 "^0.2.2"
|
||||
babel-plugin-polyfill-regenerator "^0.2.2"
|
||||
@ -1036,10 +1036,10 @@
|
||||
debug "^4.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":
|
||||
version "7.15.4"
|
||||
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"
|
||||
integrity sha1-dO64bb1nSNJ0E5ZVe5hg5X/OCg0=
|
||||
"@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.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.6.tgz#99abdc48218b2881c058dd0a7ab05b99c9be758f"
|
||||
integrity sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==
|
||||
dependencies:
|
||||
"@babel/helper-validator-identifier" "^7.14.9"
|
||||
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"
|
||||
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
|
||||
|
||||
prettier@^2.3.2:
|
||||
version "2.3.2"
|
||||
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"
|
||||
integrity sha1-7ygKBewlNxLkhiM9tcbyNEHnNC0=
|
||||
prettier@^2.4.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.0.tgz#85bdfe0f70c3e777cf13a4ffff39713ca6f64cba"
|
||||
integrity sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==
|
||||
|
||||
pretty-format@^27.0.0, pretty-format@^27.1.0:
|
||||
version "27.1.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user