diff --git a/README.md b/README.md index 766f5857c..bb73583e3 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Modern browsers and Android 4.0+, iOS 8.0+. | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection | | [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React (maintained by the community) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | diff --git a/README.zh-CN.md b/README.zh-CN.md index e3804faf1..f39e36e19 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -90,6 +90,7 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手 | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 | | [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React 版(由社区维护) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 | diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index 24771359a..8e9a4e833 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -10,6 +10,60 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/). - Minor version:released every one to two months, including backwards compatible features. - Major version:including breaking changes and new features. +### [v2.10.0-beta.0](https://github.com/youzan/vant/compare/v2.9.4-beta.0...v2.10.0-beta.0) + +`2020-07-25` + +**Feature** + +- AddressEdit: add tel-maxlength prop [#6869](https://github.com/youzan/vant/issues/6869) +- Calendar: enable close-on-popstate by default [#6874](https://github.com/youzan/vant/issues/6874) +- Dialog: enable close-on-popsate by default [#6873](https://github.com/youzan/vant/issues/6873) +- ImagePreview: enable close-on-popstate by default [#6875](https://github.com/youzan/vant/issues/6875) +- NumberKeyboard: add get-container prop [#6870](https://github.com/youzan/vant/issues/6870) + +**style** + +- uniform line-height [#6862](https://github.com/youzan/vant/issues/6862) +- DropdownMenu: adjust default active color to @red [#6863](https://github.com/youzan/vant/issues/6863) +- ActionSheet: add @action-sheet-loading-icon-size var [#6847](https://github.com/youzan/vant/issues/6847) +- ActionSheet: adjust cancel text color to @gray-7 [#6846](https://github.com/youzan/vant/issues/6846) +- ActionSheet: increase header height to 48px [#6856](https://github.com/youzan/vant/issues/6856) +- Cell: adjust icon margin to 4px [#6844](https://github.com/youzan/vant/issues/6844) +- Field: adjust icon margin to 4px [#6849](https://github.com/youzan/vant/issues/6849) +- NumberKeyboard: increase title size [#6845](https://github.com/youzan/vant/issues/6845) +- Picker: adjust default value of visible-item-count to 6 [#6827](https://github.com/youzan/vant/issues/6827) +- Sidebar: adjust width to 80px [#6861](https://github.com/youzan/vant/issues/6861) +- Tag: adjust size and padding [#6828](https://github.com/youzan/vant/issues/6828) +- Toast: adjust background color [#6848](https://github.com/youzan/vant/issues/6848) +- Toast: adjust icon size to 36px [#6857](https://github.com/youzan/vant/issues/6857) + +**Bug Fixes** + +- Field: failed to reset validation when message is empty [#6867](https://github.com/youzan/vant/issues/6867) +- Icon: incorrect image icon height when loading [#6858](https://github.com/youzan/vant/issues/6858) +- ImagePreview: fit orientationchange [#6825](https://github.com/youzan/vant/issues/6825) + +### [v2.9.3](https://github.com/youzan/vant/compare/v2.9.2...v2.9.3) + +`2020-07-19` + +**Feature** + +- Tabs: add before-change prop [#6817](https://github.com/youzan/vant/issues/6817) +- Sticky: offset-top support vw unit [#6816](https://github.com/youzan/vant/issues/6816) +- Picker: item-height support vw unit [#6816](https://github.com/youzan/vant/issues/6816) +- Sku: add mobile message value formatter [19e0d0](https://github.com/youzan/vant/commit/19e0d0df0e52cb9b683aef1f7f09d9c4ae425b97) +- Tab: add scrollTo method [#6800](https://github.com/youzan/vant/issues/6800) +- Uploader: add preview-options prop [#6810](https://github.com/youzan/vant/issues/6810) + +**Bug Fixes** + +- Calendar: rendering fails in some cases [#6812](https://github.com/youzan/vant/issues/6812) +- ImagePreview: image overflow in some cases [#6811](https://github.com/youzan/vant/issues/6811) +- NumberKeyboard: flex not work on legacy safari [#6804](https://github.com/youzan/vant/issues/6804) +- Slider: missing transition in vertical mode [#6786](https://github.com/youzan/vant/issues/6786) + ### [v2.9.2](https://github.com/youzan/vant/compare/v2.9.1...v2.9.2) `2020-07-14` diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index 419bc9209..7dbcf98e5 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -10,6 +10,60 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 - 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。 - 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。 +### [v2.10.0-beta.0](https://github.com/youzan/vant/compare/v2.9.4-beta.0...v2.10.0-beta.0) + +`2020-07-25` + +**Feature** + +- AddressEdit: 新增 tel-maxlength 属性 [#6869](https://github.com/youzan/vant/issues/6869) +- Calendar: 默认开启 close-on-popstate 属性 [#6874](https://github.com/youzan/vant/issues/6874) +- Dialog: 默认开启 close-on-popstate 属性 [#6873](https://github.com/youzan/vant/issues/6873) +- ImagePreview: 默认开启 close-on-popstate 属性 [#6875](https://github.com/youzan/vant/issues/6875) +- NumberKeyboard: 新增 get-container 属性 [#6870](https://github.com/youzan/vant/issues/6870) + +**style** + +- 新增 line-height 相关 LESS 变量 [#6862](https://github.com/youzan/vant/issues/6862) +- DropdownMenu: 默认选中态颜色调整为红色 [#6863](https://github.com/youzan/vant/issues/6863) +- ActionSheet: 加载图标大小调整为 22px [#6847](https://github.com/youzan/vant/issues/6847) +- ActionSheet: 取消按钮文字颜色调整为 @gray-7 [#6846](https://github.com/youzan/vant/issues/6846) +- ActionSheet: 标题栏高度调整为 48px [#6856](https://github.com/youzan/vant/issues/6856) +- Cell: 图标与文字的间距调整为 4px [#6844](https://github.com/youzan/vant/issues/6844) +- Field: 图标与文字的间距调整为 4px [#6849](https://github.com/youzan/vant/issues/6849) +- NumberKeyboard: 标题栏高度调整为 40px [#6845](https://github.com/youzan/vant/issues/6845) +- Picker: 默认可见的选项个数调整为 6 个 [#6827](https://github.com/youzan/vant/issues/6827) +- Sidebar: 宽度调整为 80px [#6861](https://github.com/youzan/vant/issues/6861) +- Tag: 更新文字大小和标签大小 [#6828](https://github.com/youzan/vant/issues/6828) +- Toast: 更新背景色 [#6848](https://github.com/youzan/vant/issues/6848) +- Toast: 图标大小调整为 36px [#6857](https://github.com/youzan/vant/issues/6857) + +**Bug Fixes** + +- Field: 修复 rule 的 message 为空时无法重置表单状态的问题 [#6867](https://github.com/youzan/vant/issues/6867) +- Icon: 修复图片图标加载过程中高度异常的问题 [#6858](https://github.com/youzan/vant/issues/6858) +- ImagePreview: 修复 iOS 下旋转屏幕时布局错误的问题 [#6825](https://github.com/youzan/vant/issues/6825) + +### [v2.9.3](https://github.com/youzan/vant/compare/v2.9.2...v2.9.3) + +`2020-07-19` + +**Feature** + +- Tabs: 新增 before-change 属性,用于在切换标签前执行校验逻辑 [#6817](https://github.com/youzan/vant/issues/6817) +- Sticky: offset-top 属性支持传入 vw 单位 [#6816](https://github.com/youzan/vant/issues/6816) +- Picker: item-height 属性支持传入 vw 单位 [#6816](https://github.com/youzan/vant/issues/6816) +- Sku: 新增对手机号留言的格式化处理 [19e0d0](https://github.com/youzan/vant/commit/19e0d0df0e52cb9b683aef1f7f09d9c4ae425b97) +- Tab: 新增 scrollTo 方法,用于在滚动导航模式下滚动到特定位置 [#6800](https://github.com/youzan/vant/issues/6800) +- Uploader: 新增 preview-options 属性,用于自定义全屏图片预览的配置项 [#6810](https://github.com/youzan/vant/issues/6810) + +**Bug Fixes** + +- Calendar: 修复在个别情况下内容渲染失败的问题 [#6812](https://github.com/youzan/vant/issues/6812) +- ImagePreview: 修复在个别情况下图片错位的问题 [#6811](https://github.com/youzan/vant/issues/6811) +- NumberKeyboard: 修复在旧版本 iOS 上按键内容不居中的问题 [#6804](https://github.com/youzan/vant/issues/6804) +- Slider: 修复垂直模式下滑动动画失效的问题 [#6786](https://github.com/youzan/vant/issues/6786) + ### [v2.9.2](https://github.com/youzan/vant/compare/v2.9.1...v2.9.2) `2020-07-14` diff --git a/docs/markdown/home.en-US.md b/docs/markdown/home.en-US.md index 765d18823..3ee90ba6c 100644 --- a/docs/markdown/home.en-US.md +++ b/docs/markdown/home.en-US.md @@ -35,6 +35,7 @@ Modern browsers and Android 4.0+, iOS 8.0+. | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Official vant demo collection | | [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React (maintained by the community) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | diff --git a/docs/markdown/home.zh-CN.md b/docs/markdown/home.zh-CN.md index 2e25343f6..ad310a9d0 100644 --- a/docs/markdown/home.zh-CN.md +++ b/docs/markdown/home.zh-CN.md @@ -51,6 +51,7 @@ | --- | --- | | [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 | | [vant-weapp](https://github.com/youzan/vant-weapp) | 微信小程序组件库 | +| [vant-react](https://github.com/mxdi9i7/vant-react) | Vant React 版(由社区维护) | | [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | | [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 | | [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 | diff --git a/package.json b/package.json index 57c6c9872..d3a664ced 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vant", - "version": "2.9.2", + "version": "2.10.0-beta.0", "description": "Mobile UI Components built on Vue", "main": "lib/index.js", "module": "es/index.js", diff --git a/packages/vant-cli/yarn.lock b/packages/vant-cli/yarn.lock index 5df48b461..76d0fd363 100644 --- a/packages/vant-cli/yarn.lock +++ b/packages/vant-cli/yarn.lock @@ -3487,9 +3487,9 @@ co@^4.6.0: integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= codecov@^3.7.0: - version "3.7.0" - resolved "https://registry.npm.taobao.org/codecov/download/codecov-3.7.0.tgz#4a09939cde24447a43f36d068e8b4e0188dc3f27" - integrity sha1-SgmTnN4kRHpD820GjotOAYjcPyc= + version "3.7.1" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.1.tgz#434cb8d55f18ef01672e5739d3d266696bebc202" + integrity sha512-JHWxyPTkMLLJn9SmKJnwAnvY09kg2Os2+Ux+GG7LwZ9g8gzDDISpIN5wAsH1UBaafA/yGcd3KofMaorE8qd6Lw== dependencies: argv "0.0.2" ignore-walk "3.0.3" @@ -7657,11 +7657,16 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "^3.0.0" -lodash@4.17.15, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: +lodash@4.17.15: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== + log-symbols@^2.0.0, log-symbols@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" diff --git a/packages/vant-eslint-config/yarn.lock b/packages/vant-eslint-config/yarn.lock index 9e72d478c..475e583d1 100644 --- a/packages/vant-eslint-config/yarn.lock +++ b/packages/vant-eslint-config/yarn.lock @@ -813,9 +813,9 @@ locate-path@^2.0.0: path-exists "^3.0.0" lodash@^4.17.14, lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== mimic-fn@^2.1.0: version "2.1.0" diff --git a/packages/vant-stylelint-config/yarn.lock b/packages/vant-stylelint-config/yarn.lock index 037f17894..88d8f4c77 100644 --- a/packages/vant-stylelint-config/yarn.lock +++ b/packages/vant-stylelint-config/yarn.lock @@ -1270,9 +1270,9 @@ locate-path@^2.0.0: path-exists "^3.0.0" lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== log-symbols@^2.0.0, log-symbols@^2.2.0: version "2.2.0" diff --git a/packages/vant-waterfall/yarn.lock b/packages/vant-waterfall/yarn.lock index dea18f849..5ffaa03d1 100644 --- a/packages/vant-waterfall/yarn.lock +++ b/packages/vant-waterfall/yarn.lock @@ -1609,9 +1609,9 @@ locate-path@^2.0.0: path-exists "^3.0.0" lodash@^4.17.13: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== loose-envify@^1.0.0: version "1.4.0" diff --git a/src/action-sheet/index.js b/src/action-sheet/index.js index da0cac156..c6b70bcde 100644 --- a/src/action-sheet/index.js +++ b/src/action-sheet/index.js @@ -120,7 +120,7 @@ export default createComponent({ function OptionContent() { if (loading) { - return ; + return ; } return [ diff --git a/src/action-sheet/index.less b/src/action-sheet/index.less index 79ba786b9..3a776e4f7 100644 --- a/src/action-sheet/index.less +++ b/src/action-sheet/index.less @@ -41,6 +41,10 @@ } } + &__cancel { + color: @action-sheet-cancel-text-color; + } + &__subname { margin-top: @padding-xs; color: @action-sheet-subname-color; @@ -74,6 +78,11 @@ } } + &__loading-icon .van-loading__spinner { + width: @action-sheet-loading-icon-size; + height: @action-sheet-loading-icon-size; + } + &__close { position: absolute; top: 0; diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index e71b51fbe..d1bb01fd6 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -2,7 +2,7 @@ exports[`callback events 1`] = `
diff --git a/src/address-edit/README.md b/src/address-edit/README.md index b2419a84d..f92f8122a 100644 --- a/src/address-edit/README.md +++ b/src/address-edit/README.md @@ -86,6 +86,7 @@ export default { | is-saving | Whether to show save button loading status | _boolean_ | `false` | | is-deleting | Whether to show delete button loading status | _boolean_ | `false` | | tel-validator | The method to validate tel | _(tel: string) => boolean_ | - | +| tel-maxlength `v2.10.0` | Tel maxlength | _number \| string_ | - | | postal-validator `v2.1.2` | The method to validate postal | _(tel: string) => boolean_ | - | | validator | Custom validator | _(key, val) => string_ | - | diff --git a/src/address-edit/README.zh-CN.md b/src/address-edit/README.zh-CN.md index e9eb5d4b9..a0d7fe29b 100644 --- a/src/address-edit/README.zh-CN.md +++ b/src/address-edit/README.zh-CN.md @@ -86,6 +86,7 @@ export default { | is-saving | 是否显示保存按钮加载动画 | _boolean_ | `false` | | is-deleting | 是否显示删除按钮加载动画 | _boolean_ | `false` | | tel-validator | 手机号格式校验函数 | _string => boolean_ | - | +| tel-maxlength `v2.10.0` | 手机号最大长度 | _number \| string_ | - | | postal-validator `v2.1.2` | 邮政编码格式校验函数 | _string => boolean_ | - | | validator | 自定义校验函数 | _(key, val) => string_ | - | diff --git a/src/address-edit/index.js b/src/address-edit/index.js index ba7267c89..f810496f7 100644 --- a/src/address-edit/index.js +++ b/src/address-edit/index.js @@ -40,11 +40,12 @@ export default createComponent({ showDelete: Boolean, showPostal: Boolean, searchResult: Array, + telMaxlength: [Number, String], showSetDefault: Boolean, - showSearchResult: Boolean, saveButtonText: String, - deleteButtonText: String, areaPlaceholder: String, + deleteButtonText: String, + showSearchResult: Boolean, showArea: { type: Boolean, default: true, @@ -283,6 +284,7 @@ export default createComponent({ clearable type="tel" label={t('tel')} + maxlength={this.telMaxlength} placeholder={t('telPlaceholder')} errorMessage={errorInfo.tel} onFocus={onFocus('tel')} diff --git a/src/address-edit/test/index.spec.js b/src/address-edit/test/index.spec.js index 2af606077..376133a9d 100644 --- a/src/address-edit/test/index.spec.js +++ b/src/address-edit/test/index.spec.js @@ -1,6 +1,6 @@ import AddressEdit from '..'; import areaList from '../../area/demo/area-simple'; -import { mount, later } from '../../../test'; +import { mount, later, trigger } from '../../../test'; const addressInfo = { name: '测试', @@ -306,3 +306,17 @@ test('click-area event', () => { field.trigger('click'); expect(wrapper.emitted('click-area')[0]).toBeTruthy(); }); + +test('tel-maxlength prop', () => { + const wrapper = mount(AddressEdit, { + propsData: { + telMaxlength: 4, + }, + }); + + const telInput = wrapper.find('input[type="tel"]'); + telInput.element.value = '123456'; + trigger(telInput, 'input'); + + expect(telInput.element.value).toEqual('1234'); +}); diff --git a/src/address-list/index.less b/src/address-list/index.less index 7a777636b..27d2b2e41 100644 --- a/src/address-list/index.less +++ b/src/address-list/index.less @@ -50,7 +50,7 @@ align-items: center; margin-bottom: @padding-xs; font-size: @font-size-lg; - line-height: 22px; + line-height: @line-height-lg; } &__tag { diff --git a/src/area/README.md b/src/area/README.md index 9c10fdb57..f8494fa0b 100644 --- a/src/area/README.md +++ b/src/area/README.md @@ -64,9 +64,9 @@ To have a selected value,simply pass the `code` of target area to `value` prop | area-list | Area list data | _object_ | - | | columns-placeholder `v2.2.5` | Placeholder of columns | _string[]_ | `[]` | | loading | Whether to show loading prompt | _boolean_ | `false` | -| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | | columns-num | Level of picker | _number \| string_ | `3` | -| visible-item-count | Count of visible columns | _number \| string_ | `5` | +| visible-item-count | Count of visible columns | _number \| string_ | `6` | | swipe-duration `v2.2.13` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | | is-oversea-code `v2.1.4` | The method to validate oversea code | _() => boolean_ | - | diff --git a/src/area/README.zh-CN.md b/src/area/README.zh-CN.md index 71f8367e5..5e2691ffe 100644 --- a/src/area/README.zh-CN.md +++ b/src/area/README.zh-CN.md @@ -64,9 +64,9 @@ Vue.use(Area); | area-list | 省市区数据,格式见下方 | _object_ | - | | columns-placeholder `v2.2.5` | 列占位提示文字 | _string[]_ | `[]` | | loading | 是否显示加载状态 | _boolean_ | `false` | -| item-height `v2.8.6` | 选项高度,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `44` | +| item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | | columns-num | 显示列数,3-省市区,2-省市,1-省 | _number \| string_ | `3` | -| visible-item-count | 可见的选项个数 | _number \| string_ | `5` | +| visible-item-count | 可见的选项个数 | _number \| string_ | `6` | | swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` | | is-oversea-code `v2.1.4` | 根据`code`校验海外地址,海外地址会划分至单独的分类 | _() => boolean_ | - | diff --git a/src/area/test/__snapshots__/demo.spec.js.snap b/src/area/test/__snapshots__/demo.spec.js.snap index 1853af53c..984178494 100644 --- a/src/area/test/__snapshots__/demo.spec.js.snap +++ b/src/area/test/__snapshots__/demo.spec.js.snap @@ -8,9 +8,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 北京市
    • @@ -119,14 +119,14 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 北京市
-
    +
    • 东城区
    • @@ -177,7 +177,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -189,9 +189,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 北京市
    • @@ -300,7 +300,7 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 杭州市
    • @@ -337,7 +337,7 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 鹿城区
    • @@ -373,7 +373,7 @@ exports[`renders demo correctly 1`] = `
-
+
@@ -385,9 +385,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 北京市
    • @@ -496,13 +496,13 @@ exports[`renders demo correctly 1`] = `
-
    +
    • 北京市
-
+
@@ -514,9 +514,9 @@ exports[`renders demo correctly 1`] = `
标题
-
+
-
    +
    • 请选择
    • @@ -628,12 +628,12 @@ exports[`renders demo correctly 1`] = `
-
    +
      -
        +
          -
          +
          diff --git a/src/area/test/__snapshots__/index.spec.js.snap b/src/area/test/__snapshots__/index.spec.js.snap index 2db538023..e29ea9587 100644 --- a/src/area/test/__snapshots__/index.spec.js.snap +++ b/src/area/test/__snapshots__/index.spec.js.snap @@ -4,9 +4,9 @@ exports[`change option 1`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -16,7 +16,7 @@ exports[`change option 1`] = `
          -
            +
            • 北京市
            • @@ -26,7 +26,7 @@ exports[`change option 1`] = `
          -
            +
            • 东城区
            • @@ -35,7 +35,7 @@ exports[`change option 1`] = `
          -
          +
          @@ -46,9 +46,9 @@ exports[`change option 2`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -58,7 +58,7 @@ exports[`change option 2`] = `
          -
            +
            • 天津市
            • @@ -68,7 +68,7 @@ exports[`change option 2`] = `
          -
            +
            • 和平区
            • @@ -77,7 +77,7 @@ exports[`change option 2`] = `
          -
          +
          @@ -88,9 +88,9 @@ exports[`change option 3`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -100,7 +100,7 @@ exports[`change option 3`] = `
          -
            +
            • 天津市
            • @@ -110,7 +110,7 @@ exports[`change option 3`] = `
          -
            +
            • 和平区
            • @@ -119,7 +119,7 @@ exports[`change option 3`] = `
          -
          +
          @@ -130,9 +130,9 @@ exports[`columns-num prop 1`] = `
          -
          +
          -
            +
            • 北京市
            • @@ -142,7 +142,7 @@ exports[`columns-num prop 1`] = `
          -
            +
            • 北京市
            • @@ -151,7 +151,7 @@ exports[`columns-num prop 1`] = `
          -
          +
          @@ -161,17 +161,17 @@ exports[`columns-num prop 1`] = ` exports[`columns-top、columns-bottom slot 1`] = `
          - Top
          + Top
          -
            +
              -
                +
                  -
                    +
                      -
                      +
                      Bottom @@ -182,9 +182,9 @@ exports[`reset method 1`] = `
                      -
                      +
                      -
                        +
                        • 北京市
                        • @@ -194,7 +194,7 @@ exports[`reset method 1`] = `
                      -
                        +
                        • 天津市
                        • @@ -204,13 +204,13 @@ exports[`reset method 1`] = `
                      -
                        +
                        • 蓟县
                      -
                      +
                      @@ -221,9 +221,9 @@ exports[`reset method 2`] = `
                      -
                      +
                      -
                        +
                        • 北京市
                        • @@ -233,7 +233,7 @@ exports[`reset method 2`] = `
                      -
                        +
                        • 北京市
                        • @@ -243,7 +243,7 @@ exports[`reset method 2`] = `
                      -
                        +
                        • 东城区
                        • @@ -252,7 +252,7 @@ exports[`reset method 2`] = `
                      -
                      +
                      @@ -263,17 +263,17 @@ exports[`title slot 1`] = `
                      Custom Title
                      -
                      +
                      -
                        +
                          -
                            +
                              -
                                +
                                  -
                                  +
                                  @@ -284,9 +284,9 @@ exports[`watch areaList & code 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 北京市
                                    • @@ -296,7 +296,7 @@ exports[`watch areaList & code 1`] = `
                                  -
                                    +
                                    • 北京市
                                    • @@ -306,7 +306,7 @@ exports[`watch areaList & code 1`] = `
                                  -
                                    +
                                    • 东城区
                                    • @@ -315,7 +315,7 @@ exports[`watch areaList & code 1`] = `
                                  -
                                  +
                                  @@ -326,9 +326,9 @@ exports[`watch areaList & code 2`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 北京市
                                    • @@ -338,7 +338,7 @@ exports[`watch areaList & code 2`] = `
                                  -
                                    +
                                    • 北京市
                                    • @@ -348,7 +348,7 @@ exports[`watch areaList & code 2`] = `
                                  -
                                    +
                                    • 东城区
                                    • @@ -357,7 +357,7 @@ exports[`watch areaList & code 2`] = `
                                  -
                                  +
                                  @@ -368,9 +368,9 @@ exports[`watch areaList & code 3`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 北京市
                                    • @@ -380,7 +380,7 @@ exports[`watch areaList & code 3`] = `
                                  -
                                    +
                                    • 北京市
                                    • @@ -390,7 +390,7 @@ exports[`watch areaList & code 3`] = `
                                  -
                                    +
                                    • 东城区
                                    • @@ -399,7 +399,7 @@ exports[`watch areaList & code 3`] = `
                                  -
                                  +
                                  diff --git a/src/button/README.md b/src/button/README.md index 3414b3b30..922c2de2b 100644 --- a/src/button/README.md +++ b/src/button/README.md @@ -14,9 +14,9 @@ Vue.use(Button); ### Type ```html -Default Primary Info +Default Danger Warning ``` @@ -60,11 +60,11 @@ Vue.use(Button); ### Icon ```html - -Button -Button + +Button + + Button + ``` ### Size @@ -94,9 +94,9 @@ Vue.use(Button); ```html Pure Pure -Gradient + + Gradient + ``` ## API diff --git a/src/button/README.zh-CN.md b/src/button/README.zh-CN.md index 092bd1211..8c01ac951 100644 --- a/src/button/README.zh-CN.md +++ b/src/button/README.zh-CN.md @@ -13,19 +13,19 @@ Vue.use(Button); ### 按钮类型 -支持`default`、`primary`、`info`、`warning`、`danger`五种类型,默认为`default` +按钮支持 `default`、`primary`、`info`、`warning`、`danger` 五种类型,默认为 `default`。 ```html -默认按钮 主要按钮 信息按钮 +默认按钮 警告按钮 危险按钮 ``` ### 朴素按钮 -通过`plain`属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为白色。 +通过 `plain` 属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为白色。 ```html 朴素按钮 @@ -34,7 +34,7 @@ Vue.use(Button); ### 细边框 -设置`hairline`属性可以开启 0.5px 边框,基于伪类实现 +设置 `hairline` 属性可以展示 0.5px 的细边框。 ```html 细边框按钮 @@ -43,7 +43,7 @@ Vue.use(Button); ### 禁用状态 -通过`disabled`属性来禁用按钮,禁用状态下按钮不可点击 +通过 `disabled` 属性来禁用按钮,禁用状态下按钮不可点击。 ```html 禁用状态 @@ -52,7 +52,7 @@ Vue.use(Button); ### 加载状态 -通过`loading`属性设置按钮为加载状态,加载状态下默认会隐藏按钮文字,可以通过`loading-text`设置加载状态下的文字 +通过 `loading` 属性设置按钮为加载状态,加载状态下默认会隐藏按钮文字,可以通过 `loading-text` 设置加载状态下的文字。 ```html @@ -62,7 +62,7 @@ Vue.use(Button); ### 按钮形状 -通过`square`设置方形按钮,通过`round`设置圆形按钮 +通过 `square` 设置方形按钮,通过 `round` 设置圆形按钮。 ```html 方形按钮 @@ -71,19 +71,19 @@ Vue.use(Button); ### 图标按钮 -通过`icon`属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL +通过 `icon` 属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL。 ```html - -按钮 -按钮 + +按钮 + + 按钮 + ``` ### 按钮尺寸 -支持`large`、`normal`、`small`、`mini`四种尺寸,默认为`normal` +支持 `large`、`normal`、`small`、`mini` 四种尺寸,默认为 `normal`。 ```html 大号按钮 @@ -94,7 +94,7 @@ Vue.use(Button); ### 块级元素 -按钮在默认情况下为行内块级元素,通过`block`属性可以将按钮的元素类型设置为块级元素 +按钮在默认情况下为行内块级元素,通过 `block` 属性可以将按钮的元素类型设置为块级元素。 ```html 块级元素 @@ -102,7 +102,7 @@ Vue.use(Button); ### 页面导航 -可以通过`url`属性进行 URL 跳转,或通过`to`属性进行路由跳转 +可以通过 `url` 属性进行 URL 跳转,或通过 `to` 属性进行路由跳转。 ```html URL 跳转 @@ -111,14 +111,14 @@ Vue.use(Button); ### 自定义颜色 -通过`color`属性可以自定义按钮的颜色 +通过 `color` 属性可以自定义按钮的颜色。 ```html 单色按钮 单色按钮 -渐变色按钮 + + 渐变色按钮 + ``` ## API diff --git a/src/button/demo/index.vue b/src/button/demo/index.vue index 2eb52e3bd..befe6c9b4 100644 --- a/src/button/demo/index.vue +++ b/src/button/demo/index.vue @@ -2,9 +2,9 @@
                                  - {{ t('default') }} {{ t('primary') }} {{ t('info') }} + {{ t('default') }}
                                  {{ t('danger') }} {{ t('warning') }} @@ -37,12 +37,12 @@
                                  - - + + @@ -71,7 +71,7 @@ diff --git a/src/button/test/__snapshots__/demo.spec.js.snap b/src/button/test/__snapshots__/demo.spec.js.snap index 9d218df71..466a4c918 100644 --- a/src/button/test/__snapshots__/demo.spec.js.snap +++ b/src/button/test/__snapshots__/demo.spec.js.snap @@ -3,12 +3,12 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  diff --git a/src/contact-card/demo/index.vue b/src/contact-card/demo/index.vue index de3dbc438..c1968e315 100644 --- a/src/contact-card/demo/index.vue +++ b/src/contact-card/demo/index.vue @@ -115,7 +115,7 @@ export default { if (this.isEdit) { this.list = this.list.map((item) => - (item.id === info.id ? info : item) + item.id === info.id ? info : item ); } else { this.list.push(info); @@ -135,10 +135,12 @@ export default { diff --git a/src/coupon/index.less b/src/coupon/index.less index 1673c30e4..6caf77bb7 100644 --- a/src/coupon/index.less +++ b/src/coupon/index.less @@ -68,7 +68,7 @@ margin-bottom: 10px; font-weight: bold; font-size: @coupon-name-font-size; - line-height: 20px; + line-height: @line-height-md; } &__valid { diff --git a/src/datetime-picker/README.md b/src/datetime-picker/README.md index bd27f1e51..44b5d09f2 100644 --- a/src/datetime-picker/README.md +++ b/src/datetime-picker/README.md @@ -259,8 +259,8 @@ export default { | filter | Option filter | _(type, vals) => vals_ | - | | formatter | Option text formatter | _(type, val) => val_ | - | | columns-order `v2.9.2` | Array for ordering columns, where item can be set to
                                  `year`, `month`, `day`, `hour` and `minute` | _string[]_ | - | -| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` | -| visible-item-count | Count of visible columns | _number \| string_ | `5` | +| item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | +| visible-item-count | Count of visible columns | _number \| string_ | `6` | | swipe-duration `v2.2.13` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | ### DatePicker Props diff --git a/src/datetime-picker/README.zh-CN.md b/src/datetime-picker/README.zh-CN.md index 22f7d54f8..17fb28660 100644 --- a/src/datetime-picker/README.zh-CN.md +++ b/src/datetime-picker/README.zh-CN.md @@ -268,8 +268,8 @@ export default { | filter | 选项过滤函数 | _(type, vals) => vals_ | - | | formatter | 选项格式化函数 | _(type, val) => val_ | - | | columns-order `v2.9.2` | 自定义列排序数组, 子项可选值为
                                  `year`、`month`、`day`、`hour`、`minute` | _string[]_ | - | -| item-height `v2.8.6` | 选项高度,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `44` | -| visible-item-count | 可见的选项个数 | _number \| string_ | `5` | +| item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | +| visible-item-count | 可见的选项个数 | _number \| string_ | `6` | | swipe-duration `v2.2.13` | 快速滑动时惯性滚动的时长,单位`ms` | _number \| string_ | `1000` | ### DatePicker Props diff --git a/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap index 1489ea5bc..69d2e9083 100644 --- a/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/date-picker.spec.js.snap @@ -4,16 +4,16 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                  -
                                    +
                                    • 05
                                    • @@ -23,7 +23,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 05
                                    • @@ -45,7 +45,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -64,7 +64,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -103,7 +103,7 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  @@ -114,9 +114,9 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 2010 year
                                    • @@ -126,7 +126,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 05 month
                                    • @@ -136,7 +136,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 05 day
                                    • @@ -158,7 +158,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 00 hour
                                    • @@ -177,7 +177,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 00 minute
                                    • @@ -216,7 +216,7 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap index 93186057a..fea04fd14 100644 --- a/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/datetime-picker.spec.js.snap @@ -4,9 +4,9 @@ exports[`time type 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 22
                                    • @@ -16,7 +16,7 @@ exports[`time type 1`] = `
                                  -
                                    +
                                    • 58
                                    • @@ -25,7 +25,7 @@ exports[`time type 1`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/test/__snapshots__/demo.spec.js.snap b/src/datetime-picker/test/__snapshots__/demo.spec.js.snap index 30a574b09..39071a4ab 100644 --- a/src/datetime-picker/test/__snapshots__/demo.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/demo.spec.js.snap @@ -8,9 +8,9 @@ exports[`renders demo correctly 1`] = `
                                  选择年月日
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                    • @@ -32,7 +32,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -72,7 +72,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -168,7 +168,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -180,9 +180,9 @@ exports[`renders demo correctly 1`] = `
                                  选择年月
                                  -
                                  +
                                  -
                                    +
                                    • 2020年
                                    • @@ -204,7 +204,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01月
                                    • @@ -243,7 +243,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -255,9 +255,9 @@ exports[`renders demo correctly 1`] = `
                                  选择月日
                                  -
                                  +
                                  -
                                    +
                                    • 01月
                                    • @@ -297,7 +297,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01日
                                    • @@ -393,7 +393,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -405,9 +405,9 @@ exports[`renders demo correctly 1`] = `
                                  选择时间
                                  -
                                  +
                                  -
                                    +
                                    • 10
                                    • @@ -444,7 +444,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -627,7 +627,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -639,9 +639,9 @@ exports[`renders demo correctly 1`] = `
                                  选择完整时间
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                    • @@ -663,7 +663,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -703,7 +703,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -800,7 +800,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -876,7 +876,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -1059,7 +1059,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -1071,9 +1071,9 @@ exports[`renders demo correctly 1`] = `
                                  选择年月日小时
                                  -
                                  +
                                  -
                                    +
                                    • 2020
                                    • @@ -1095,7 +1095,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -1135,7 +1135,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01
                                    • @@ -1232,7 +1232,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -1307,7 +1307,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -1319,9 +1319,9 @@ exports[`renders demo correctly 1`] = `
                                  选项过滤器
                                  -
                                  +
                                  -
                                    +
                                    • 00
                                    • @@ -1397,7 +1397,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -1436,7 +1436,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -1448,9 +1448,9 @@ exports[`renders demo correctly 1`] = `
                                  自定义列排序
                                  -
                                  +
                                  -
                                    +
                                    • 01月
                                    • @@ -1490,7 +1490,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 01日
                                    • @@ -1587,7 +1587,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 2020年
                                    • @@ -1608,7 +1608,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  diff --git a/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap b/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap index ec25eb174..ec66b33e1 100644 --- a/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap +++ b/src/datetime-picker/test/__snapshots__/time-picker.spec.js.snap @@ -4,9 +4,9 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 00
                                    • @@ -25,7 +25,7 @@ exports[`filter prop 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -46,7 +46,7 @@ exports[`filter prop 1`] = `
                                  -
                                  +
                                  @@ -57,9 +57,9 @@ exports[`format initial value 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 22
                                    • @@ -69,7 +69,7 @@ exports[`format initial value 1`] = `
                                  -
                                    +
                                    • 58
                                    • @@ -78,7 +78,7 @@ exports[`format initial value 1`] = `
                                  -
                                  +
                                  @@ -89,9 +89,9 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 00 hour
                                    • @@ -110,7 +110,7 @@ exports[`formatter prop 1`] = `
                                  -
                                    +
                                    • 00 minute
                                    • @@ -131,7 +131,7 @@ exports[`formatter prop 1`] = `
                                  -
                                  +
                                  @@ -142,9 +142,9 @@ exports[`max-hour & max-minute 1`] = `
                                  -
                                  +
                                  -
                                    +
                                    • 00
                                    • @@ -157,7 +157,7 @@ exports[`max-hour & max-minute 1`] = `
                                  -
                                    +
                                    • 00
                                    • @@ -169,7 +169,7 @@ exports[`max-hour & max-minute 1`] = `
                                  -
                                  +
                                  diff --git a/src/dialog/Dialog.js b/src/dialog/Dialog.js index 7c341c609..815dad25c 100644 --- a/src/dialog/Dialog.js +++ b/src/dialog/Dialog.js @@ -21,6 +21,14 @@ export default createComponent({ confirmButtonText: String, confirmButtonColor: String, showCancelButton: Boolean, + overlay: { + type: Boolean, + default: true, + }, + allowHtml: { + type: Boolean, + default: true, + }, transition: { type: String, default: 'van-dialog-bounce', @@ -29,7 +37,7 @@ export default createComponent({ type: Boolean, default: true, }, - overlay: { + closeOnPopstate: { type: Boolean, default: true, }, @@ -37,10 +45,6 @@ export default createComponent({ type: Boolean, default: false, }, - allowHtml: { - type: Boolean, - default: true, - }, }, data() { diff --git a/src/dialog/README.md b/src/dialog/README.md index 941616d97..4dbcace02 100644 --- a/src/dialog/README.md +++ b/src/dialog/README.md @@ -130,7 +130,7 @@ export default { | overlay | Whether to show overlay | _boolean_ | `true` | | overlayClass `v2.2.7` | Custom overlay class | _string_ | - | | overlayStyle `v2.2.7` | Custom overlay style | _object_ | - | -| closeOnPopstate `v2.0.5` | Whether to close when popstate | _boolean_ | `false` | +| closeOnPopstate `v2.0.5` | Whether to close when popstate | _boolean_ | `true` | | closeOnClickOverlay | Whether to close when click overlay | _boolean_ | `false` | | lockScroll | Whether to lock body scroll | _boolean_ | `true` | | allowHtml `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `true` | @@ -156,7 +156,7 @@ export default { | overlay | Whether to show overlay | _boolean_ | `true` | | overlay-class `v2.2.7` | Custom overlay class | _string_ | - | | overlay-style `v2.2.7` | Custom overlay style | _object_ | - | -| close-on-popstate `v2.0.5` | Whether to close when popstate | _boolean_ | `false` | +| close-on-popstate `v2.0.5` | Whether to close when popstate | _boolean_ | `true` | | close-on-click-overlay | Whether to close when click overlay | _boolean_ | `false` | | lazy-render | Whether to lazy render util appeared | _boolean_ | `true` | | lock-scroll | Whether to lock background scroll | _boolean_ | `true` | diff --git a/src/dialog/README.zh-CN.md b/src/dialog/README.zh-CN.md index 4845d1ca2..7ead0b38c 100644 --- a/src/dialog/README.zh-CN.md +++ b/src/dialog/README.zh-CN.md @@ -160,7 +160,7 @@ export default { | overlay | 是否展示遮罩层 | _boolean_ | `true` | | overlayClass `v2.2.7` | 自定义遮罩层类名 | _string_ | - | | overlayStyle `v2.2.7` | 自定义遮罩层样式 | _object_ | - | -| closeOnPopstate `v2.0.5` | 是否在页面回退时自动关闭 | _boolean_ | `false` | +| closeOnPopstate `v2.0.5` | 是否在页面回退时自动关闭 | _boolean_ | `true` | | closeOnClickOverlay | 是否在点击遮罩层后关闭弹窗 | _boolean_ | `false` | | lockScroll | 是否锁定背景滚动 | _boolean_ | `true` | | allowHtml `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `true` | @@ -188,7 +188,7 @@ export default { | overlay | 是否展示遮罩层 | _boolean_ | `true` | | overlay-class `v2.2.7` | 自定义遮罩层类名 | _string_ | - | | overlay-style `v2.2.7` | 自定义遮罩层样式 | _object_ | - | -| close-on-popstate `v2.0.5` | 是否在页面回退时自动关闭 | _boolean_ | `false` | +| close-on-popstate `v2.0.5` | 是否在页面回退时自动关闭 | _boolean_ | `true` | | close-on-click-overlay | 是否在点击遮罩层后关闭弹窗 | _boolean_ | `false` | | lazy-render | 是否在显示弹层时才渲染节点 | _boolean_ | `true` | | lock-scroll | 是否锁定背景滚动 | _boolean_ | `true` | diff --git a/src/dialog/index.js b/src/dialog/index.js index 48f4f9d5a..2805cdaaf 100644 --- a/src/dialog/index.js +++ b/src/dialog/index.js @@ -65,7 +65,7 @@ Dialog.defaultOptions = { confirmButtonColor: null, showConfirmButton: true, showCancelButton: false, - closeOnPopstate: false, + closeOnPopstate: true, closeOnClickOverlay: false, callback: (action) => { instance[action === 'confirm' ? 'resolve' : 'reject'](action); diff --git a/src/dropdown-menu/README.md b/src/dropdown-menu/README.md index d3b5526be..0805893f3 100644 --- a/src/dropdown-menu/README.md +++ b/src/dropdown-menu/README.md @@ -50,7 +50,11 @@ export default { - Confirm +
                                  + + Confirm + +
                                  ``` @@ -112,7 +116,7 @@ Use `active-color` prop to custom active color of the title and options | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| active-color | Active color of title and option | _string_ | `#1989fa` | +| active-color | Active color of title and option | _string_ | `#ee0a24` | | direction `v2.0.1` | Expand direction, can be set to `up` | _string_ | `down` | | z-index | z-index of menu item | _number \| string_ | `10` | | duration | Transition duration, unit second | _number \| string_ | `0.2` | diff --git a/src/dropdown-menu/README.zh-CN.md b/src/dropdown-menu/README.zh-CN.md index 2336c71d6..ac1547b93 100644 --- a/src/dropdown-menu/README.zh-CN.md +++ b/src/dropdown-menu/README.zh-CN.md @@ -52,7 +52,11 @@ export default { - 确认 +
                                  + + 确认 + +
                                  ``` @@ -116,7 +120,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| active-color | 菜单标题和选项的选中态颜色 | _string_ | `#1989fa` | +| active-color | 菜单标题和选项的选中态颜色 | _string_ | `#ee0a24` | | direction `v2.0.1` | 菜单展开方向,可选值为`up` | _string_ | `down` | | z-index | 菜单栏 z-index 层级 | _number \| string_ | `10` | | duration | 动画时长,单位秒 | _number \| string_ | `0.2` | diff --git a/src/dropdown-menu/demo/index.vue b/src/dropdown-menu/demo/index.vue index 18e8ef119..4eeb25073 100644 --- a/src/dropdown-menu/demo/index.vue +++ b/src/dropdown-menu/demo/index.vue @@ -13,9 +13,17 @@ - - {{ t('confirm') }} - +
                                  + + {{ t('confirm') }} + +
                                  diff --git a/src/field/index.js b/src/field/index.js index abf59cb12..8150656f3 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -282,7 +282,7 @@ export default createComponent({ }, resetValidation() { - if (this.validateMessage) { + if (this.validateFailed) { this.validateFailed = false; this.validateMessage = ''; } diff --git a/src/field/index.less b/src/field/index.less index 305c8fe23..88712250b 100644 --- a/src/field/index.less +++ b/src/field/index.less @@ -123,7 +123,7 @@ } &__left-icon { - margin-right: 5px; + margin-right: @padding-base; } &__right-icon { diff --git a/src/form/test/__snapshots__/methods.spec.js.snap b/src/form/test/__snapshots__/methods.spec.js.snap deleted file mode 100644 index 6c019b6b1..000000000 --- a/src/form/test/__snapshots__/methods.spec.js.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`resetValidation method - reset one field 1`] = ` -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  B failed
                                  -
                                  -
                                  -
                                  -`; diff --git a/src/form/test/methods.spec.js b/src/form/test/methods.spec.js index d00cd0679..5acb4549b 100644 --- a/src/form/test/methods.spec.js +++ b/src/form/test/methods.spec.js @@ -50,12 +50,12 @@ test('validate method - validate one field and passed', (done) => { test('validate method - validate one field and failed', (done) => { mountForm({ - template: ` - - - - - + template: ` + + + + + `, data: getSimpleRules, mounted() { @@ -90,7 +90,27 @@ test('resetValidation method - reset one field', (done) => { mounted() { this.$refs.form.validate().catch(() => { this.$refs.form.resetValidation('A'); - expect(wrapper).toMatchSnapshot(); + expect(wrapper.findAll('.van-field--error').length).toEqual(1); + this.$refs.form.resetValidation('B'); + expect(wrapper.findAll('.van-field--error').length).toEqual(0); + done(); + }); + }, + }); +}); + +test('resetValidation method - reset when rule message is empty', (done) => { + const wrapper = mountSimpleRulesForm({ + data() { + return { + rulesA: [{ required: true, message: '' }], + rulesB: [{ required: true, message: '' }], + }; + }, + mounted() { + this.$refs.form.validate().catch(() => { + this.$refs.form.resetValidation('A'); + expect(wrapper.findAll('.van-field--error').length).toEqual(1); done(); }); }, diff --git a/src/icon/index.less b/src/icon/index.less index f1b78f967..803156141 100644 --- a/src/icon/index.less +++ b/src/icon/index.less @@ -3,6 +3,7 @@ .van-icon { &__image { + display: block; width: 1em; height: 1em; object-fit: contain; diff --git a/src/image-preview/ImagePreview.js b/src/image-preview/ImagePreview.js index 9c03d4e7c..3b56ee72e 100644 --- a/src/image-preview/ImagePreview.js +++ b/src/image-preview/ImagePreview.js @@ -20,6 +20,7 @@ export default createComponent({ }), BindEventMixin(function (bind) { bind(window, 'resize', this.resize, true); + bind(window, 'orientationchange', this.resize, true); }), ], @@ -36,22 +37,10 @@ export default createComponent({ type: Boolean, default: true, }, - swipeDuration: { - type: [Number, String], - default: 500, - }, overlay: { type: Boolean, default: true, }, - showIndex: { - type: Boolean, - default: true, - }, - startPosition: { - type: [Number, String], - default: 0, - }, minZoom: { type: [Number, String], default: 1 / 3, @@ -60,6 +49,18 @@ export default createComponent({ type: [Number, String], default: 3, }, + showIndex: { + type: Boolean, + default: true, + }, + swipeDuration: { + type: [Number, String], + default: 500, + }, + startPosition: { + type: [Number, String], + default: 0, + }, overlayClass: { type: String, default: bem('overlay'), @@ -68,6 +69,10 @@ export default createComponent({ type: String, default: 'clear', }, + closeOnPopstate: { + type: Boolean, + default: true, + }, closeIconPosition: { type: String, default: 'top-right', diff --git a/src/image-preview/README.md b/src/image-preview/README.md index 3ccfdf6a5..e46997566 100644 --- a/src/image-preview/README.md +++ b/src/image-preview/README.md @@ -109,7 +109,7 @@ export default { | onClose | Triggered when close | _Function_ | - | | onChange `v2.0.3` | Triggered when current image change | _Function_ | - | | onScale | Triggered when current image scale | _Function_ | - | -| closeOnPopstate | Whether to close when popstate | _boolean_ | `false` | +| closeOnPopstate | Whether to close when popstate | _boolean_ | `true` | | asyncClose | Whether to enable async close | _boolean_ | `false` | | className | Custom className | _any_ | - | | maxZoom | Max zoom | _number \| string_ | `3` | @@ -130,7 +130,7 @@ export default { | show-indicators | Whether to show indicators | _boolean_ | `false` | | loop | Whether to enable loop | _boolean_ | `true` | | async-close | Whether to enable async close | _boolean_ | `false` | -| close-on-popstate | Whether to close when popstate | _boolean_ | `false` | +| close-on-popstate | Whether to close when popstate | _boolean_ | `true` | | class-name | Custom className | _any_ | - | | max-zoom | Max zoom | _number \| string_ | `3` | | min-zoom | Min zoom | _number \| string_ | `1/3` | diff --git a/src/image-preview/README.zh-CN.md b/src/image-preview/README.zh-CN.md index ed1ba9ce3..defe34bc8 100644 --- a/src/image-preview/README.zh-CN.md +++ b/src/image-preview/README.zh-CN.md @@ -144,7 +144,7 @@ export default { | onChange `v2.0.3` | 切换图片时的回调函数,回调参数为当前索引 | _Function_ | - | | onScale | 缩放图片时的回调函数,回调参数为当前索引和当前缩放值组成的对象 | _Function_ | - | | asyncClose | 是否开启异步关闭 | _boolean_ | `false` | -| closeOnPopstate | 是否在页面回退时自动关闭 | _boolean_ | `false` | +| closeOnPopstate | 是否在页面回退时自动关闭 | _boolean_ | `true` | | className | 自定义类名 | _any_ | - | | maxZoom | 手势缩放时,最大缩放比例 | _number \| string_ | `3` | | minZoom | 手势缩放时,最小缩放比例 | _number \| string_ | `1/3` | @@ -166,7 +166,7 @@ export default { | show-indicators | 是否显示轮播指示器 | _boolean_ | `false` | | loop | 是否开启循环播放 | _boolean_ | `true` | | async-close | 是否开启异步关闭 | _boolean_ | `false` | -| close-on-popstate | 是否在页面回退时自动关闭 | _boolean_ | `false` | +| close-on-popstate | 是否在页面回退时自动关闭 | _boolean_ | `true` | | class-name | 自定义类名 | _any_ | - | | max-zoom | 手势缩放时,最大缩放比例 | _number \| string_ | `3` | | min-zoom | 手势缩放时,最小缩放比例 | _number \| string_ | `1/3` | diff --git a/src/image-preview/demo/index.vue b/src/image-preview/demo/index.vue index ec4960fdb..79a3f1742 100644 --- a/src/image-preview/demo/index.vue +++ b/src/image-preview/demo/index.vue @@ -88,7 +88,6 @@ export default { swipeDuration: 300, asyncClose: !!timer, closeable, - closeOnPopstate: true, startPosition: typeof position === 'number' ? position : 0, }); diff --git a/src/image-preview/index.js b/src/image-preview/index.js index eae0c340b..5bc02398f 100644 --- a/src/image-preview/index.js +++ b/src/image-preview/index.js @@ -6,23 +6,23 @@ let instance; const defaultConfig = { loop: true, - images: [], value: true, - minZoom: 1 / 3, + images: [], maxZoom: 3, - className: '', + minZoom: 1 / 3, onClose: null, onChange: null, + className: '', showIndex: true, closeable: false, closeIcon: 'clear', asyncClose: false, + getContainer: 'body', startPosition: 0, swipeDuration: 500, showIndicators: false, - closeOnPopstate: false, + closeOnPopstate: true, closeIconPosition: 'top-right', - getContainer: 'body', }; const initInstance = () => { diff --git a/src/image-preview/index.less b/src/image-preview/index.less index 0de2d1fd8..adf1433d2 100644 --- a/src/image-preview/index.less +++ b/src/image-preview/index.less @@ -14,6 +14,7 @@ display: flex; align-items: center; justify-content: center; + overflow: hidden; } } diff --git a/src/mixins/portal.js b/src/mixins/portal.js new file mode 100644 index 000000000..ec3e65f26 --- /dev/null +++ b/src/mixins/portal.js @@ -0,0 +1,47 @@ +function getElement(selector) { + if (typeof selector === 'string') { + return document.querySelector(selector); + } + + return selector(); +} + +export function PortalMixin({ ref, afterPortal } = {}) { + return { + props: { + getContainer: [String, Function], + }, + + watch: { + getContainer: 'portal', + }, + + mounted() { + if (this.getContainer) { + this.portal(); + } + }, + + methods: { + portal() { + const { getContainer } = this; + const el = ref ? this.$refs[ref] : this.$el; + + let container; + if (getContainer) { + container = getElement(getContainer); + } else if (this.$parent) { + container = this.$parent.$el; + } + + if (container && container !== el.parentNode) { + container.appendChild(el); + } + + if (afterPortal) { + afterPortal.call(this); + } + }, + }, + }; +} diff --git a/src/number-keyboard/Key.js b/src/number-keyboard/Key.js index 158aa0a57..858af2257 100644 --- a/src/number-keyboard/Key.js +++ b/src/number-keyboard/Key.js @@ -78,8 +78,9 @@ export default createComponent({ render() { return (
                                  - +
                                  ); }, diff --git a/src/number-keyboard/README.md b/src/number-keyboard/README.md index 67faf36b7..ba612b0e8 100644 --- a/src/number-keyboard/README.md +++ b/src/number-keyboard/README.md @@ -160,6 +160,7 @@ export default { | close-button-loading `v2.7.0` | Whether to show loading close button in custom theme | _boolean_ | `false` | | show-delete-key `v2.5.9` | Whether to show delete button | _boolean_ | `true` | | hide-on-click-outside | Whether to hide keyboard when click outside | _boolean_ | `true` | +| get-container `v2.10.0` | Return the mount node for NumberKeyboard | _string \| () => Element_ | - | | safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` | ### Events diff --git a/src/number-keyboard/README.zh-CN.md b/src/number-keyboard/README.zh-CN.md index 24bea797a..4228b1b9a 100644 --- a/src/number-keyboard/README.zh-CN.md +++ b/src/number-keyboard/README.zh-CN.md @@ -173,6 +173,7 @@ export default { | close-button-loading `v2.7.0` | 是否将关闭按钮设置为加载中状态,仅在 `theme="custom"` 时有效 | _boolean_ | `false` | | show-delete-key `v2.5.9` | 是否展示删除图标 | _boolean_ | `true` | | hide-on-click-outside | 点击外部时是否收起键盘 | _boolean_ | `true` | +| get-container `v2.10.0` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - | | safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` | ### Events diff --git a/src/number-keyboard/index.js b/src/number-keyboard/index.js index ebd1c85f8..3ea42df30 100644 --- a/src/number-keyboard/index.js +++ b/src/number-keyboard/index.js @@ -1,5 +1,6 @@ import { createNamespace } from '../utils'; import { stopPropagation } from '../utils/dom/event'; +import { PortalMixin } from '../mixins/portal'; import { BindEventMixin } from '../mixins/bind-event'; import Key from './Key'; @@ -7,6 +8,7 @@ const [createComponent, bem] = createNamespace('number-keyboard'); export default createComponent({ mixins: [ + PortalMixin(), BindEventMixin(function (bind) { if (this.hideOnClickOutside) { bind(document.body, 'touchstart', this.onBlur); diff --git a/src/number-keyboard/index.less b/src/number-keyboard/index.less index da0cb56aa..a6dcb5805 100644 --- a/src/number-keyboard/index.less +++ b/src/number-keyboard/index.less @@ -79,13 +79,10 @@ display: flex; align-items: center; justify-content: center; - width: 100%; height: @number-keyboard-key-height; - padding: 0; font-size: @number-keyboard-key-font-size; line-height: 1.5; background-color: @white; - border: none; border-radius: @border-radius-lg; cursor: pointer; diff --git a/src/number-keyboard/test/__snapshots__/demo.spec.js.snap b/src/number-keyboard/test/__snapshots__/demo.spec.js.snap index a420dbc39..8de8b1efe 100644 --- a/src/number-keyboard/test/__snapshots__/demo.spec.js.snap +++ b/src/number-keyboard/test/__snapshots__/demo.spec.js.snap @@ -41,45 +41,95 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  +
                                  +
                                  +
                                  0
                                  +
                                  +
                                  +
                                  -
                                  +
                                  +
                                  @@ -87,20 +137,44 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  +
                                  +
                                  @@ -110,66 +184,142 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  +
                                  +
                                  diff --git a/src/number-keyboard/test/__snapshots__/index.spec.js.snap b/src/number-keyboard/test/__snapshots__/index.spec.js.snap index 912ecac3d..928a45c13 100644 --- a/src/number-keyboard/test/__snapshots__/index.spec.js.snap +++ b/src/number-keyboard/test/__snapshots__/index.spec.js.snap @@ -4,20 +4,44 @@ exports[`extra-key slot 1`] = `
                                  @@ -27,22 +51,46 @@ exports[`focus on key 1`] = `
                                  @@ -52,22 +100,46 @@ exports[`focus on key 2`] = `
                                  @@ -77,22 +149,46 @@ exports[`move and blur key 1`] = `
                                  @@ -102,22 +198,46 @@ exports[`move and blur key 2`] = `
                                  @@ -127,22 +247,46 @@ exports[`move and blur key 3`] = `
                                  @@ -155,22 +299,46 @@ exports[`render title 1`] = `
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  +
                                  +
                                  +
                                  0
                                  +
                                  +
                                  +
                                  -
                                  +
                                  +
                                  @@ -181,22 +349,46 @@ exports[`title-left slot 1`] = `
                                  Custom Title Left
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  +
                                  +
                                  +
                                  0
                                  +
                                  +
                                  +
                                  -
                                  +
                                  +
                                  diff --git a/src/password-input/test/__snapshots__/demo.spec.js.snap b/src/password-input/test/__snapshots__/demo.spec.js.snap index 52ca0fd65..ca92591da 100644 --- a/src/password-input/test/__snapshots__/demo.spec.js.snap +++ b/src/password-input/test/__snapshots__/demo.spec.js.snap @@ -19,22 +19,46 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  -
                                  +
                                  +
                                  +
                                  0
                                  +
                                  +
                                  +
                                  -
                                  +
                                  +
                                  diff --git a/src/picker/README.md b/src/picker/README.md index a2654b023..619598f14 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -252,8 +252,8 @@ export default { | show-toolbar | Whether to show toolbar | _boolean_ | `false` | | allow-html `v2.1.8` | Whether to allow HTML in option text | _boolean_ | `true` | | default-index | Default value index of single column picker | _number \| string_ | `0` | -| item-height `v2.8.6` | Option height, supports `px` ans `rem` unit, default `px` | _number \| string_ | `44` | -| visible-item-count | Count of visible columns | _number \| string_ | `5` | +| item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | +| visible-item-count | Count of visible columns | _number \| string_ | `6` | | swipe-duration `v2.2.10` | Duration of the momentum animation,unit `ms` | _number \| string_ | `1000` | ### Events diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index 9d0fdad33..b2ace5118 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -174,7 +174,7 @@ export default { ``` ```js -const citys = { +const cities = { 浙江: ['杭州', '宁波', '温州', '嘉兴', '湖州'], 福建: ['福州', '厦门', '莆田', '三明', '泉州'], }; @@ -182,12 +182,12 @@ const citys = { export default { data() { return { - columns: [{ values: Object.keys(citys) }, { values: citys['浙江'] }], + columns: [{ values: Object.keys(cities) }, { values: cities['浙江'] }], }; }, methods: { onChange(picker, values) { - picker.setColumnValues(1, citys[values[0]]); + picker.setColumnValues(1, cities[values[0]]); }, }, }; @@ -275,8 +275,8 @@ export default { | show-toolbar | 是否显示顶部栏 | _boolean_ | `false` | | allow-html `v2.1.8` | 是否允许选项内容中渲染 HTML | _boolean_ | `true` | | default-index | 单列选择时,默认选中项的索引 | _number \| string_ | `0` | -| item-height `v2.8.6` | 选项高度,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `44` | -| visible-item-count | 可见的选项个数 | _number \| string_ | `5` | +| item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | +| visible-item-count | 可见的选项个数 | _number \| string_ | `6` | | swipe-duration `v2.2.10` | 快速滑动时惯性滚动的时长,单位 `ms` | _number \| string_ | `1000` | ### Events diff --git a/src/picker/shared.ts b/src/picker/shared.ts index 9df9467d7..7736234a5 100644 --- a/src/picker/shared.ts +++ b/src/picker/shared.ts @@ -23,7 +23,7 @@ export const pickerProps = { }, visibleItemCount: { type: [Number, String], - default: 5, + default: 6, }, swipeDuration: { type: [Number, String], diff --git a/src/picker/test/__snapshots__/demo.spec.js.snap b/src/picker/test/__snapshots__/demo.spec.js.snap index ef31702d1..44490e4d6 100644 --- a/src/picker/test/__snapshots__/demo.spec.js.snap +++ b/src/picker/test/__snapshots__/demo.spec.js.snap @@ -8,9 +8,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 杭州
                                    • @@ -28,7 +28,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -40,9 +40,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 杭州
                                    • @@ -60,7 +60,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -72,9 +72,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 周一
                                    • @@ -93,7 +93,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 上午
                                    • @@ -105,7 +105,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -117,9 +117,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 浙江
                                    • @@ -129,7 +129,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 杭州
                                    • @@ -139,7 +139,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 西湖区
                                    • @@ -148,7 +148,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -160,9 +160,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 杭州
                                    • @@ -174,7 +174,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -186,9 +186,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 浙江
                                    • @@ -198,7 +198,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 杭州
                                    • @@ -216,7 +216,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  @@ -228,9 +228,9 @@ exports[`renders demo correctly 1`] = `
                                  标题
                                  -
                                  +
                                  -
                                    +
                                    • 浙江
                                    • @@ -240,7 +240,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                    +
                                    • 杭州
                                    • @@ -258,7 +258,7 @@ exports[`renders demo correctly 1`] = `
                                  -
                                  +
                                  diff --git a/src/picker/test/__snapshots__/index.spec.js.snap b/src/picker/test/__snapshots__/index.spec.js.snap index fe9515293..24c30aa69 100644 --- a/src/picker/test/__snapshots__/index.spec.js.snap +++ b/src/picker/test/__snapshots__/index.spec.js.snap @@ -59,11 +59,11 @@ exports[`column watch default index 2`] = ` exports[`columns-top、columns-bottom prop 1`] = `
                                  - Custom Columns Top
                                  + Custom Columns Top
                                  -
                                    +
                                      -
                                      +
                                      Custom Columns Bottom @@ -73,15 +73,15 @@ exports[`columns-top、columns-bottom prop 1`] = ` exports[`not allow html 1`] = `
                                      -
                                      +
                                      -
                                        +
                                        • <div>option</div>
                                      -
                                      +
                                      @@ -92,11 +92,11 @@ exports[`render title slot 1`] = `
                                      Custom title
                                      -
                                      +
                                      -
                                        +
                                          -
                                          +
                                          @@ -106,9 +106,9 @@ exports[`render title slot 1`] = ` exports[`set rem item-height 1`] = `
                                          -
                                          +
                                          -
                                            +
                                            • 1990
                                            • @@ -117,7 +117,7 @@ exports[`set rem item-height 1`] = `
                                          -
                                          +
                                          @@ -128,11 +128,11 @@ exports[`toolbar-position prop 1`] = `
                                          -
                                          +
                                          -
                                            +
                                              -
                                              +
                                              diff --git a/src/sku/Sku.js b/src/sku/Sku.js index fce56e9ec..2c269538a 100644 --- a/src/sku/Sku.js +++ b/src/sku/Sku.js @@ -542,7 +542,6 @@ export default createComponent({ ImagePreview({ images: this.imageList, startPosition: index, - closeOnPopstate: true, onClose: () => { this.$emit('close-preview', params); }, diff --git a/src/sku/components/SkuMessages.js b/src/sku/components/SkuMessages.js index 7c50eda87..de63f77fd 100644 --- a/src/sku/components/SkuMessages.js +++ b/src/sku/components/SkuMessages.js @@ -111,6 +111,21 @@ export default createComponent({ } } }, + /** + * The phone number copied from IOS mobile phone address book + * will add spaces and invisible Unicode characters + * which cannot pass the /^\d+$/ verification + * so keep numbers and dots + */ + getFormatter(message) { + return function formatter(value) { + if (message.type === 'mobile' || message.type === 'tel') { + return value.replace(/[^\d.]/g, ''); + } + + return value; + }; + }, genMessage(message, index) { if (message.type === 'image') { @@ -157,6 +172,7 @@ export default createComponent({ required={String(message.required) === '1'} placeholder={this.getPlaceholder(message)} type={this.getType(message)} + formatter={this.getFormatter(message)} /> ); }, diff --git a/src/sku/test/index.spec.js b/src/sku/test/index.spec.js index 01efb6f04..9822dde0b 100644 --- a/src/sku/test/index.spec.js +++ b/src/sku/test/index.spec.js @@ -32,6 +32,49 @@ test('resetSelectedSku method', () => { expect(wrapper.emitted('buy-clicked').length).toEqual(1); }); +test('message formatter', () => { + const skuData = getSkuData(); + + skuData.sku.messages = skuData.sku.messages.filter( + message => message.type === 'tel' + ); + + const wrapper = mount(Sku, { + propsData: { + value: true, + initialSku, + sku: skuData.sku, + quota: skuData.quota, + goods: skuData.goods_info, + goodsId: skuData.goods_id, + quotaUsed: skuData.quota_used, + hideStock: skuData.sku.hide_stock, + startSaleNum: skuData.start_sale_num, + }, + }); + + const input = wrapper.find('input'); + const correctValue = '15000000000'; + + // \u202c + input.element.value = '15000000000‬'; + input.trigger('input'); + + expect(input.element.value).toEqual(correctValue); + + // \u0020 + input.element.value = '150 0000 0000'; + input.trigger('input'); + + expect(input.element.value).toEqual(correctValue); + + // /[a-zA-z]/ + input.element.value = 'a-zA-z'; + input.trigger('input'); + + expect(input.element.value).toEqual(''); +}); + test('stringToDate', () => { expect(dateToString(stringToDate(''))).toEqual(''); expect(dateToString(stringToDate('2020-07-01'))).toEqual('2020-07-01'); diff --git a/src/step/index.less b/src/step/index.less index 8ecc8ca13..ed99f540c 100644 --- a/src/step/index.less +++ b/src/step/index.less @@ -88,7 +88,7 @@ display: block; float: none; padding: 10px 10px 10px 0; - line-height: 18px; + line-height: @line-height-sm; &:not(:last-child)::after { border-bottom-width: 1px; diff --git a/src/stepper/README.zh-CN.md b/src/stepper/README.zh-CN.md index f8c03d49b..9043c3394 100644 --- a/src/stepper/README.zh-CN.md +++ b/src/stepper/README.zh-CN.md @@ -167,3 +167,15 @@ export default { | minus | 点击减少按钮时触发 | - | | focus | 输入框聚焦时触发 | _event: Event_ | | blur | 输入框失焦时触发 | _event: Event_ | + +## 常见问题 + +### 为什么 value 有时候会变成 string 类型? + +这是因为用户输入过程中可能出现小数点或空值,比如 `1.`,这种情况下组件会抛出字符串类型。 + +如果希望 value 保持 number 类型,可以在 v-model 上添加 `number` 修饰符: + +```html + +``` diff --git a/src/sticky/README.md b/src/sticky/README.md index fcb804a05..17ce81ccd 100644 --- a/src/sticky/README.md +++ b/src/sticky/README.md @@ -56,7 +56,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| offset-top `v2.8.7` | Offset top, supports `px` ans `rem` unit, default `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | Offset top, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `0` | | z-index | z-index when sticky | _number \| string_ | `99` | | container | Container DOM | _Element_ | - | diff --git a/src/sticky/README.zh-CN.md b/src/sticky/README.zh-CN.md index e26650d6f..696d07055 100644 --- a/src/sticky/README.zh-CN.md +++ b/src/sticky/README.zh-CN.md @@ -66,7 +66,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| offset-top `v2.8.7` | 吸顶时与顶部的距离,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | 吸顶时与顶部的距离,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `0` | | z-index | 吸顶时的 z-index | _number \| string_ | `99` | | container | 容器对应的 HTML 节点 | _Element_ | - | diff --git a/src/sticky/test/__snapshots__/index.spec.js.snap b/src/sticky/test/__snapshots__/index.spec.js.snap index be6374a1d..fbfac5d00 100644 --- a/src/sticky/test/__snapshots__/index.spec.js.snap +++ b/src/sticky/test/__snapshots__/index.spec.js.snap @@ -36,6 +36,14 @@ exports[`offset-top with rem unit 1`] = `
                                              `; +exports[`offset-top with vw unit 1`] = ` +
                                              +
                                              + Content +
                                              +
                                              +`; + exports[`sticky to top 1`] = `
                                              diff --git a/src/sticky/test/index.spec.js b/src/sticky/test/index.spec.js index 7fb2de770..16c6b2c2f 100644 --- a/src/sticky/test/index.spec.js +++ b/src/sticky/test/index.spec.js @@ -63,6 +63,22 @@ test('offset-top with rem unit', () => { window.getComputedStyle = originGetComputedStyle; }); +test('offset-top with vw unit', () => { + window.innerWidth = 300; + + const wrapper = mount({ + template: ` + + Content + + `, + }); + + mockScrollTop(100); + expect(wrapper).toMatchSnapshot(); + mockScrollTop(0); +}); + test('should not trigger scroll event when hidden', () => { const scroll = jest.fn(); mount({ diff --git a/src/style/var.less b/src/style/var.less index a0957a179..5989aea32 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -43,6 +43,10 @@ @font-size-md: 14px; @font-size-lg: 16px; @font-weight-bold: 500; +@line-height-xs: 14px; +@line-height-sm: 18px; +@line-height-md: 20px; +@line-height-lg: 22px; @base-font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif; @@ -65,25 +69,27 @@ // ActionSheet @action-sheet-max-height: 80%; -@action-sheet-header-height: 44px; +@action-sheet-header-height: 48px; @action-sheet-header-font-size: @font-size-lg; @action-sheet-description-color: @gray-6; @action-sheet-description-font-size: @font-size-md; -@action-sheet-description-line-height: 20px; +@action-sheet-description-line-height: @line-height-md; @action-sheet-item-background: @white; @action-sheet-item-font-size: @font-size-lg; -@action-sheet-item-line-height: 22px; +@action-sheet-item-line-height: @line-height-lg; @action-sheet-item-text-color: @text-color; @action-sheet-item-disabled-text-color: @gray-5; @action-sheet-subname-color: @gray-6; @action-sheet-subname-font-size: @font-size-sm; -@action-sheet-subname-line-height: 20px; +@action-sheet-subname-line-height: @line-height-sm; @action-sheet-close-icon-size: 22px; @action-sheet-close-icon-color: @gray-5; @action-sheet-close-icon-active-color: @gray-6; @action-sheet-close-icon-padding: 0 @padding-md; +@action-sheet-cancel-text-color: @gray-7; @action-sheet-cancel-padding-top: @padding-xs; @action-sheet-cancel-padding-color: @background-color; +@action-sheet-loading-icon-size: 22px; // AddressEdit @address-edit-padding: @padding-sm; @@ -97,13 +103,13 @@ @address-list-disabled-text-color: @gray-6; @address-list-disabled-text-padding: @padding-base * 5 0 @padding-md; @address-list-disabled-text-font-size: @font-size-md; -@address-list-disabled-text-line-height: 20px; +@address-list-disabled-text-line-height: @line-height-md; @address-list-add-button-z-index: 999; @address-list-item-padding: @padding-sm; @address-list-item-text-color: @text-color; @address-list-item-disabled-text-color: @gray-5; @address-list-item-font-size: 13px; -@address-list-item-line-height: 18px; +@address-list-item-line-height: @line-height-sm; @address-list-item-radio-icon-color: @red; @address-list-edit-icon-size: 20px; @@ -159,7 +165,7 @@ @calendar-selected-day-size: 54px; @calendar-selected-day-color: @white; @calendar-info-font-size: @font-size-xs; -@calendar-info-line-height: 14px; +@calendar-info-line-height: @line-height-xs; @calendar-selected-day-background-color: @red; @calendar-day-disabled-color: @gray-5; @calendar-confirm-button-height: 36px; @@ -174,7 +180,7 @@ @card-thumb-border-radius: @border-radius-lg; @card-title-line-height: 16px; @card-desc-color: @gray-7; -@card-desc-line-height: 20px; +@card-desc-line-height: @line-height-md; @card-price-color: @gray-8; @card-origin-price-color: @gray-6; @card-num-color: @gray-6; @@ -195,7 +201,7 @@ @cell-required-color: @red; @cell-label-color: @gray-6; @cell-label-font-size: @font-size-sm; -@cell-label-line-height: 18px; +@cell-label-line-height: @line-height-sm; @cell-label-margin-top: @padding-base; @cell-value-color: @gray-6; @cell-icon-size: 16px; @@ -226,12 +232,12 @@ @circle-text-color: @text-color; @circle-text-font-weight: @font-weight-bold; @circle-text-font-size: @font-size-md; -@circle-text-line-height: 18px; +@circle-text-line-height: @line-height-md; // Collapse @collapse-item-transition-duration: @animation-duration-base; @collapse-item-content-padding: @padding-sm @padding-md; -@collapse-item-content-font-size: 14px; +@collapse-item-content-font-size: @font-size-md; @collapse-item-content-line-height: 1.5; @collapse-item-content-text-color: @gray-6; @collapse-item-content-background-color: @white; @@ -241,7 +247,7 @@ @contact-card-padding: @padding-md; @contact-card-add-icon-size: 40px; @contact-card-add-icon-color: @blue; -@contact-card-value-line-height: 20px; +@contact-card-value-line-height: @line-height-md; // ContactEdit @contact-edit-padding: @padding-md; @@ -259,7 +265,7 @@ // CountDown @count-down-text-color: @text-color; @count-down-font-size: @font-size-md; -@count-down-line-height: 20px; +@count-down-line-height: @line-height-md; // Coupon @coupon-margin: 0 @padding-sm @padding-sm; @@ -289,7 +295,7 @@ @coupon-list-empty-image-size: 200px; @coupon-list-empty-tip-color: @gray-6; @coupon-list-empty-tip-font-size: @font-size-md; -@coupon-list-empty-tip-line-height: 20px; +@coupon-list-empty-tip-line-height: @line-height-md; // Dialog @dialog-width: 320px; @@ -304,7 +310,7 @@ @dialog-header-isolated-padding: @padding-lg 0; @dialog-message-padding: @padding-lg; @dialog-message-font-size: @font-size-md; -@dialog-message-line-height: 20px; +@dialog-message-line-height: @line-height-md; @dialog-message-max-height: 60vh; @dialog-has-title-message-text-color: @gray-7; @dialog-has-title-message-padding-top: @padding-sm; @@ -325,11 +331,11 @@ @dropdown-menu-background-color: @white; @dropdown-menu-title-font-size: 15px; @dropdown-menu-title-text-color: @text-color; -@dropdown-menu-title-active-text-color: @blue; +@dropdown-menu-title-active-text-color: @red; @dropdown-menu-title-disabled-text-color: @gray-6; @dropdown-menu-title-padding: 0 @padding-xs; -@dropdown-menu-title-line-height: 22px; -@dropdown-menu-option-active-color: @blue; +@dropdown-menu-title-line-height: @line-height-lg; +@dropdown-menu-option-active-color: @red; @dropdown-menu-content-max-height: 80%; @dropdown-item-z-index: 10; @@ -339,8 +345,8 @@ @empty-description-margin-top: @padding-md; @empty-description-padding: 0 60px; @empty-description-color: @gray-6; -@empty-description-font-size: 14px; -@empty-description-line-height: 20px; +@empty-description-font-size: @font-size-md; +@empty-description-line-height: @line-height-md; @empty-bottom-margin-top: 24px; // Field @@ -399,7 +405,7 @@ // IndexBar @index-bar-sidebar-z-index: 2; @index-bar-index-font-size: @font-size-xs; -@index-bar-index-line-height: 14px; +@index-bar-index-line-height: @line-height-xs; @index-bar-index-active-color: @green; // Info @@ -424,7 +430,7 @@ // ImagePreview @image-preview-index-text-color: @white; @image-preview-index-font-size: @font-size-md; -@image-preview-index-line-height: 22px; +@image-preview-index-line-height: @line-height-md; @image-preview-index-text-shadow: 0 1px 1px @gray-8; @image-preview-overlay-background-color: rgba(0, 0, 0, 0.9); @image-preview-close-icon-size: 22px; @@ -471,7 +477,7 @@ @notify-text-color: @white; @notify-padding: @padding-xs @padding-md; @notify-font-size: @font-size-md; -@notify-line-height: 20px; +@notify-line-height: @line-height-md; @notify-primary-background-color: @blue; @notify-success-background-color: @green; @notify-danger-background-color: @red; @@ -484,8 +490,8 @@ @number-keyboard-key-active-color: @gray-3; @number-keyboard-delete-font-size: @font-size-lg; @number-keyboard-title-color: @gray-7; -@number-keyboard-title-height: 30px; -@number-keyboard-title-font-size: @font-size-md; +@number-keyboard-title-height: 34px; +@number-keyboard-title-font-size: @font-size-lg; @number-keyboard-close-padding: 0 @padding-md; @number-keyboard-close-color: @text-link-color; @number-keyboard-close-font-size: @font-size-md; @@ -533,7 +539,7 @@ @picker-background-color: @white; @picker-toolbar-height: 44px; @picker-title-font-size: @font-size-lg; -@picker-title-line-height: 20px; +@picker-title-line-height: @line-height-md; @picker-action-padding: 0 @padding-md; @picker-action-font-size: @font-size-md; @picker-confirm-action-color: @text-link-color; @@ -591,7 +597,7 @@ @share-sheet-header-padding: @padding-sm @padding-md @padding-base; @share-sheet-title-color: @text-color; @share-sheet-title-font-size: @font-size-md; -@share-sheet-title-line-height: 20px; +@share-sheet-title-line-height: @line-height-md; @share-sheet-description-color: @gray-6; @share-sheet-description-font-size: @font-size-sm; @share-sheet-description-line-height: 16px; @@ -618,11 +624,9 @@ @search-action-font-size: @font-size-md; // Sidebar -@sidebar-width: 85px; - -// SidebarItem +@sidebar-width: 80px; @sidebar-font-size: @font-size-md; -@sidebar-line-height: 20px; +@sidebar-line-height: @line-height-md; @sidebar-text-color: @text-color; @sidebar-disabled-text-color: @gray-5; @sidebar-padding: 20px @padding-sm; @@ -766,12 +770,15 @@ @tabs-bottom-bar-color: @tabs-default-color; // Tag -@tag-padding: 0.2em 0.5em; -@tag-font-size: @font-size-xs; -@tag-medium-font-size: @font-size-sm; -@tag-large-font-size: @font-size-md; +@tag-padding: 0 @padding-base; @tag-text-color: @white; -@tag-border-radius: 0.2em; +@tag-font-size: @font-size-sm; +@tag-border-radius: 2px; +@tag-line-height: 16px; +@tag-medium-padding: 2px 6px; +@tag-large-padding: @padding-base @padding-xs; +@tag-large-border-radius: @border-radius-md; +@tag-large-font-size: @font-size-md; @tag-round-border-radius: @border-radius-max; @tag-danger-color: @red; @tag-primary-color: @blue; @@ -785,10 +792,10 @@ @toast-font-size: @font-size-md; @toast-text-color: @white; @toast-loading-icon-color: @white; -@toast-line-height: 20px; +@toast-line-height: @line-height-md; @toast-border-radius: @border-radius-lg; -@toast-background-color: fade(@text-color, 88%); -@toast-icon-size: 40px; +@toast-background-color: fade(@black, 70%); +@toast-icon-size: 36px; @toast-text-min-width: 96px; @toast-text-padding: @padding-xs @padding-sm; @toast-default-padding: @padding-md; @@ -828,7 +835,7 @@ @uploader-mask-background-color: fade(@gray-8, 88%); @uploader-mask-icon-size: 22px; @uploader-mask-message-font-size: @font-size-sm; -@uploader-mask-message-line-height: 14px; +@uploader-mask-message-line-height: @line-height-xs; @uploader-loading-icon-size: 22px; @uploader-loading-icon-color: @white; @uploader-disabled-opacity: @disabled-opacity; diff --git a/src/swipe/index.js b/src/swipe/index.js index 95816beea..608289690 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -18,6 +18,7 @@ export default createComponent({ ParentMixin('vanSwipe'), BindEventMixin(function (bind, isBind) { bind(window, 'resize', this.resize, true); + bind(window, 'orientationchange', this.resize, true); bind(window, 'visibilitychange', this.onVisibilityChange); if (isBind) { diff --git a/src/tab/README.md b/src/tab/README.md index ef80688fb..714912b34 100644 --- a/src/tab/README.md +++ b/src/tab/README.md @@ -126,7 +126,7 @@ export default { ### Sticky -In sticky mode, the tab will be fixed to top when scroll to top +In sticky mode, the tab will be fixed to top when scroll to top. ```html @@ -138,7 +138,7 @@ In sticky mode, the tab will be fixed to top when scroll to top ### Custom title -Use title slot to custom tab title +Use title slot to custom tab title. ```html @@ -151,7 +151,7 @@ Use title slot to custom tab title ### Switch Animation -Use `animated` props to change tabs with animation +Use `animated` props to change tabs with animation. ```html @@ -163,7 +163,7 @@ Use `animated` props to change tabs with animation ### Swipeable -In swipeable mode, you can switch tabs with swipe gestrue in the content +In swipeable mode, you can switch tabs with swipe gestrue in the content. ```html @@ -175,7 +175,7 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content ### Scrollspy -In scrollspy mode, the list of content will be tiled +In scrollspy mode, the list of content will be tiled. ```html @@ -185,6 +185,34 @@ In scrollspy mode, the list of content will be tiled ``` +### Before Change + +```html + + + content {{ index }} + + +``` + +```js +export default { + methods: { + beforeChange(index) { + // prevent change + if (index === 1) { + return false; + } + + // async + return new Promise((resolve) => { + resolve(index !== 3); + }); + }, + }, +}; +``` + ## API ### Tabs Props @@ -205,10 +233,11 @@ In scrollspy mode, the list of content will be tiled | swipeable | Whether to switch tabs with swipe gestrue in the content | _boolean_ | `false` | | lazy-render | Whether to enable tab content lazy render | _boolean_ | `true` | | scrollspy `v2.3.0` | Whether to use scrollspy mode | _boolean_ | `false` | -| offset-top `v2.8.7` | Sticky offset top , supports `px` ans `rem` unit, default `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | Sticky offset top , supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `0` | | swipe-threshold | Set swipe tabs threshold | _number \| string_ | `4` | - | | title-active-color | Title active color | _string_ | - | | title-inactive-color | Title inactive color | _string_ | - | +| before-change `v2.9.3` | Callback function before changing tabs,return `false` to prevent change,support return Promise | _(name) => boolean \| Promise_ | - | ### Tab Props @@ -241,6 +270,7 @@ Use [ref](https://vuejs.org/v2/api/#ref) to get Tabs instance and call instance | Name | Description | Attribute | Return value | | --- | --- | --- | --- | | resize | Resize Tabs when container element resized | - | void | +| scrollTo `v2.9.3` | Go to specified tab in scrollspy mode | name | void | ### Tabs Slots diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index db16f8397..a2ba20c5b 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -14,7 +14,7 @@ Vue.use(Tabs); ### 基础用法 -通过`v-model`绑定当前激活标签对应的索引值,默认情况下启用第一个标签 +通过 `v-model` 绑定当前激活标签对应的索引值,默认情况下启用第一个标签。 ```html @@ -37,7 +37,7 @@ export default { ### 通过名称匹配 -在标签指定`name`属性的情况下,`v-model`的值为当前标签的`name`(此时无法通过索引值来匹配标签) +在标签指定 `name` 属性的情况下,`v-model` 的值为当前标签的 `name`(此时无法通过索引值来匹配标签)。 ```html @@ -59,7 +59,7 @@ export default { ### 标签栏滚动 -标签数量超过 4 个时,标签栏可以在水平方向上滚动,切换时会自动将当前标签居中 +标签数量超过 4 个时,标签栏可以在水平方向上滚动,切换时会自动将当前标签居中。 ```html @@ -71,7 +71,7 @@ export default { ### 禁用标签 -设置`disabled`属性即可禁用标签。如果需要监听禁用标签的点击事件,可以在`van-tabs`上监听`disabled`事件 +设置 `disabled` 属性即可禁用标签,如果需要监听禁用标签的点击事件,可以在 `van-tabs` 上监听`disabled` 事件。 ```html @@ -95,7 +95,7 @@ export default { ### 样式风格 -`Tab`支持两种样式风格:`line`和`card`,默认为`line`样式,可以通过`type`属性修改样式风格 +`Tab` 支持两种样式风格:`line` 和`card`,默认为 `line` 样式,可以通过 `type` 属性切换样式风格。 ```html @@ -107,7 +107,7 @@ export default { ### 点击事件 -可以在`van-tabs`上绑定`click`事件,事件传参为标签对应的索引和标题 +可以在 `van-tabs` 上绑定 `click` 事件,事件传参为标签对应的标识符和标题。 ```html @@ -130,7 +130,7 @@ export default { ### 粘性布局 -通过`sticky`属性可以开启粘性布局,粘性布局下,当 Tab 滚动到顶部时会自动吸顶 +通过 `sticky` 属性可以开启粘性布局,粘性布局下,标签页滚动到顶部时会自动吸顶。 ```html @@ -142,7 +142,7 @@ export default { ### 自定义标签 -通过 title 插槽可以自定义标签内容 +通过 `title` 插槽可以自定义标签内容。 ```html @@ -155,7 +155,7 @@ export default { ### 切换动画 -通过`animated`属性可以开启切换标签内容时的转场动画 +通过 `animated` 属性可以开启切换标签内容时的转场动画。 ```html @@ -167,7 +167,7 @@ export default { ### 滑动切换 -通过`swipeable`属性可以开启滑动切换标签页 +通过 `swipeable` 属性可以开启滑动切换标签页。 ```html @@ -179,7 +179,7 @@ export default { ### 滚动导航 -通过`scrollspy`属性可以开启滚动导航模式,该模式下,内容将会平铺展示 +通过 `scrollspy` 属性可以开启滚动导航模式,该模式下,内容将会平铺展示。 ```html @@ -189,6 +189,37 @@ export default { ``` +### 异步切换 + +通过 `before-change` 属性可以在切换标签前执行特定的逻辑。 + +```html + + + 内容 {{ index }} + + +``` + +```js +export default { + methods: { + beforeChange(index) { + // 返回 false 表示阻止此次切换 + if (index === 1) { + return false; + } + + // 返回 Promise 来执行异步逻辑 + return new Promise((resolve) => { + // 在 resolve 函数中返回 true 或 false + resolve(index !== 3); + }); + }, + }, +}; +``` + ## API ### Tabs Props @@ -209,10 +240,11 @@ export default { | swipeable | 是否开启手势滑动切换 | _boolean_ | `false` | | lazy-render | 是否开启延迟渲染(首次切换到标签时才触发内容渲染) | _boolean_ | `true` | | scrollspy `v2.3.0` | 是否开启滚动导航 | _boolean_ | `false` | -| offset-top `v2.8.7` | 粘性定位布局下与顶部的最小距离,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `0` | +| offset-top `v2.8.7` | 粘性定位布局下与顶部的最小距离,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `0` | | swipe-threshold | 滚动阈值,标签数量超过阈值时开始横向滚动 | _number \| string_ | `4` | | title-active-color | 标题选中态颜色 | _string_ | - | | title-inactive-color | 标题默认态颜色 | _string_ | - | +| before-change `v2.9.3` | 切换标签前的回调函数,返回 `false` 可阻止切换,支持返回 Promise | _(name) => boolean \| Promise_ | - | ### Tab Props @@ -243,9 +275,10 @@ export default { 通过 ref 可以获取到 Tabs 实例并调用实例方法,详见[组件实例方法](#/zh-CN/quickstart#zu-jian-shi-li-fang-fa) -| 方法名 | 说明 | 参数 | 返回值 | -| ------ | -------------------------------------------- | ---- | ------ | -| resize | 外层元素大小变化后,可以调用此方法来触发重绘 | - | void | +| 方法名 | 说明 | 参数 | 返回值 | +| --- | --- | --- | --- | +| resize | 外层元素大小变化后,可以调用此方法来触发重绘 | - | void | +| scrollTo `v2.9.3` | 滚动到指定的标签页,在滚动导航模式下可用 | name: 标识符 | void | ### Tabs Slots diff --git a/src/tab/demo/index.vue b/src/tab/demo/index.vue index 6a72eea9e..9d24cac71 100644 --- a/src/tab/demo/index.vue +++ b/src/tab/demo/index.vue @@ -93,6 +93,14 @@ + + + + + {{ t('content') }} {{ index }} + + + @@ -112,6 +120,7 @@ export default { title10: '滚动导航', disabled: ' 已被禁用', matchByName: '通过名称匹配', + beforeChange: '异步切换', }, 'en-US': { tab: 'Tab ', @@ -127,6 +136,7 @@ export default { title10: 'Scrollspy', disabled: ' is disabled', matchByName: 'Match By Name', + beforeChange: 'Before Change', }, }, @@ -146,6 +156,16 @@ export default { onClick(index, title) { this.$toast(title); }, + + beforeChange(name) { + if (name === 1) { + return false; + } + + return new Promise((resolve) => { + resolve(name !== 3); + }); + }, }, }; diff --git a/src/tab/test/__snapshots__/demo.spec.js.snap b/src/tab/test/__snapshots__/demo.spec.js.snap index e8b7e703a..7349ac11c 100644 --- a/src/tab/test/__snapshots__/demo.spec.js.snap +++ b/src/tab/test/__snapshots__/demo.spec.js.snap @@ -318,5 +318,32 @@ exports[`renders demo correctly 1`] = `
                                              +
                                              +
                                              +
                                              +
                                              + + + + +
                                              +
                                              +
                                              +
                                              +
                                              + 内容 1 +
                                              + + + +
                                              +
                                              +
                                              `; diff --git a/src/tab/test/__snapshots__/index.spec.js.snap b/src/tab/test/__snapshots__/index.spec.js.snap index 6f4a6c641..4cc331f17 100644 --- a/src/tab/test/__snapshots__/index.spec.js.snap +++ b/src/tab/test/__snapshots__/index.spec.js.snap @@ -229,7 +229,7 @@ exports[`render nav-left & nav-right slot 1`] = ` exports[`rendered event 1`] = `
                                              Text
                                              `; -exports[`scrollspy 1`] = ` +exports[`scrollspy prop 1`] = `
                                              @@ -251,7 +251,7 @@ exports[`scrollspy 1`] = `
                                              `; -exports[`scrollspy 2`] = ` +exports[`scrollspy prop 2`] = `
                                              diff --git a/src/tab/test/index.spec.js b/src/tab/test/index.spec.js index 9c9d326c4..9eb51fba5 100644 --- a/src/tab/test/index.spec.js +++ b/src/tab/test/index.spec.js @@ -258,7 +258,7 @@ test('info prop', () => { expect(wrapper).toMatchSnapshot(); }); -test('scrollspy', async () => { +test('scrollspy prop', async () => { const onChange = jest.fn(); window.scrollTo = jest.fn(); @@ -288,6 +288,30 @@ test('scrollspy', async () => { expect(onChange).toHaveBeenCalledWith('c', 'title3'); }); +test('scrollTo method', async () => { + const onChange = jest.fn(); + window.scrollTo = jest.fn(); + + mount({ + template: ` + + Text + Text + Text + + `, + methods: { + onChange, + }, + mounted() { + this.$refs.root.scrollTo('b'); + }, + }); + + await later(); + expect(onChange).toHaveBeenCalledWith('b', 'title2'); +}); + test('rendered event', async () => { const onRendered = jest.fn(); @@ -338,3 +362,51 @@ test('should not trigger rendered event when disable lazy-render', async () => { await later(); expect(onRendered).toHaveBeenCalledTimes(0); }); + +test('before-change prop', async () => { + const onChange = jest.fn(); + const wrapper = mount({ + template: ` + + Text + Text + Text + Text + Text + + `, + methods: { + onChange, + beforeChange(name) { + switch (name) { + case 1: + return false; + case 2: + return true; + case 3: + return Promise.resolve(false); + case 4: + return Promise.resolve(true); + } + }, + }, + }); + + await later(); + + const tabs = wrapper.findAll('.van-tab'); + tabs.at(1).trigger('click'); + expect(onChange).toHaveBeenCalledTimes(0); + + tabs.at(2).trigger('click'); + expect(onChange).toHaveBeenCalledTimes(1); + expect(onChange).toHaveBeenLastCalledWith(2, 'title3'); + + tabs.at(3).trigger('click'); + expect(onChange).toHaveBeenCalledTimes(1); + + tabs.at(4).trigger('click'); + await later(); + expect(onChange).toHaveBeenCalledTimes(2); + expect(onChange).toHaveBeenLastCalledWith(4, 'title5'); +}); diff --git a/src/tabs/index.js b/src/tabs/index.js index 9765c0e2f..476024b43 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -1,5 +1,5 @@ // Utils -import { createNamespace, isDef, addUnit } from '../utils'; +import { createNamespace, isDef, addUnit, isPromise } from '../utils'; import { scrollLeftTo, scrollTopTo } from './utils'; import { route } from '../utils/router'; import { isHidden } from '../utils/dom/style'; @@ -53,6 +53,7 @@ export default createComponent({ background: String, lineWidth: [Number, String], lineHeight: [Number, String], + beforeChange: Function, titleActiveColor: String, titleInactiveColor: String, type: { @@ -266,14 +267,34 @@ export default createComponent({ } }, + callBeforeChange(name, done) { + if (this.beforeChange) { + const returnVal = this.beforeChange(name); + + if (isPromise(returnVal)) { + returnVal.then((value) => { + if (value) { + done(); + } + }); + } else if (returnVal) { + done(); + } + } else { + done(); + } + }, + // emit event when clicked onClick(item, index) { const { title, disabled, computedName } = this.children[index]; if (disabled) { this.$emit('disabled', computedName, title); } else { - this.setCurrentIndex(index); - this.scrollToCurrentContent(); + this.callBeforeChange(computedName, () => { + this.setCurrentIndex(index); + this.scrollToCurrentContent(); + }); this.$emit('click', computedName, title); route(item.$router, item); } @@ -299,7 +320,15 @@ export default createComponent({ this.$emit('scroll', params); }, - scrollToCurrentContent() { + // @exposed-api + scrollTo(name) { + this.$nextTick(() => { + this.setCurrentIndexByName(name); + this.scrollToCurrentContent(true); + }); + }, + + scrollToCurrentContent(immediate = false) { if (this.scrollspy) { const target = this.children[this.currentIndex]; const el = target?.$el; @@ -308,7 +337,7 @@ export default createComponent({ const to = getElementTop(el, this.scroller) - this.scrollOffset; this.lockScroll = true; - scrollTopTo(this.scroller, to, +this.duration, () => { + scrollTopTo(this.scroller, to, immediate ? 0 : +this.duration, () => { this.lockScroll = false; }); } diff --git a/src/tag/README.md b/src/tag/README.md index eb36c57e8..4a8a32d45 100644 --- a/src/tag/README.md +++ b/src/tag/README.md @@ -14,7 +14,6 @@ Vue.use(Tag); ### Basic Usage ```html -Tag Tag Tag Tag @@ -24,7 +23,6 @@ Vue.use(Tag); ### Round style ```html -Tag Tag Tag Tag @@ -34,7 +32,6 @@ Vue.use(Tag); ### Mark style ```html -Tag Tag Tag Tag @@ -44,7 +41,6 @@ Vue.use(Tag); ### Plain style ```html -Tag Tag Tag Tag @@ -55,7 +51,6 @@ Vue.use(Tag); ```html Tag -Tag Tag Tag Tag diff --git a/src/tag/README.zh-CN.md b/src/tag/README.zh-CN.md index 34b682c6f..f9fc0e99b 100644 --- a/src/tag/README.zh-CN.md +++ b/src/tag/README.zh-CN.md @@ -13,10 +13,9 @@ Vue.use(Tag); ### 基础用法 -通过`type`属性控制标签颜色,默认为灰色 +通过 `type` 属性控制标签颜色。 ```html -标签 标签 标签 标签 @@ -25,10 +24,9 @@ Vue.use(Tag); ### 圆角样式 -通过`round`设置为圆角样式 +通过 `round` 设置为圆角样式。 ```html -标签 标签 标签 标签 @@ -37,10 +35,9 @@ Vue.use(Tag); ### 标记样式 -通过`mark`设置为标记样式(半圆角) +通过 `mark` 设置为标记样式(半圆角)。 ```html -标签 标签 标签 标签 @@ -49,10 +46,9 @@ Vue.use(Tag); ### 空心样式 -设置`plain`属性设置为空心样式 +设置 `plain` 属性设置为空心样式。 ```html -标签 标签 标签 标签 @@ -63,7 +59,6 @@ Vue.use(Tag); ```html 标签 -标签 标签 标签 标签 @@ -79,7 +74,7 @@ Vue.use(Tag); ### 可关闭标签 -添加`closeable`属性表示标签是可关闭的,关闭标签时会触发`close`事件,在`close`事件中可以执行隐藏标签的逻辑 +添加 `closeable` 属性表示标签是可关闭的,关闭标签时会触发 `close` 事件,在 `close` 事件中可以执行隐藏标签的逻辑。 ```html - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -9,7 +8,6 @@ - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -17,7 +15,6 @@ - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -25,7 +22,6 @@ - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} @@ -34,7 +30,6 @@ {{ t('tag') }} - {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} {{ t('tag') }} diff --git a/src/tag/index.js b/src/tag/index.js index 3ddd51ee9..a66c4b7c3 100644 --- a/src/tag/index.js +++ b/src/tag/index.js @@ -1,6 +1,5 @@ // Utils import { createNamespace } from '../utils'; -import { BORDER_SURROUND } from '../utils/constant'; // Components import Icon from '../icon'; @@ -56,7 +55,7 @@ export default createComponent({ {slots.default?.()} {CloseIcon} diff --git a/src/tag/index.less b/src/tag/index.less index b7ebdb053..9f5d3b49c 100644 --- a/src/tag/index.less +++ b/src/tag/index.less @@ -1,19 +1,15 @@ @import '../style/var'; .van-tag { + position: relative; display: inline-flex; align-items: center; padding: @tag-padding; color: @tag-text-color; font-size: @tag-font-size; - line-height: normal; + line-height: @tag-line-height; border-radius: @tag-border-radius; - &::after { - border-color: currentColor; - border-radius: @tag-border-radius * 2; - } - &--default { background-color: @tag-default-color; @@ -56,30 +52,42 @@ &--plain { background-color: @tag-plain-background-color; - } - &--mark { - padding-right: 0.7em; - - &, - &::after { - border-radius: 0 @tag-round-border-radius @tag-round-border-radius 0; - } - } - - &--round { - &, - &::after { - border-radius: @tag-round-border-radius; + &::before { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border: 1px solid currentColor; + border-radius: inherit; + content: ''; + pointer-events: none; } } &--medium { - font-size: @tag-medium-font-size; + padding: @tag-medium-padding; } &--large { + padding: @tag-large-padding; font-size: @tag-large-font-size; + border-radius: @tag-large-border-radius; + } + + &--mark { + border-radius: 0 @tag-round-border-radius @tag-round-border-radius 0; + + &::after { + display: block; + width: 2px; + content: ''; + } + } + + &--round { + border-radius: @tag-round-border-radius; } &__close { diff --git a/src/tag/test/__snapshots__/demo.spec.js.snap b/src/tag/test/__snapshots__/demo.spec.js.snap index 622597aba..b75a4f8c3 100644 --- a/src/tag/test/__snapshots__/demo.spec.js.snap +++ b/src/tag/test/__snapshots__/demo.spec.js.snap @@ -2,11 +2,11 @@ exports[`renders demo correctly 1`] = `
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              -
                                              标签 标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              +
                                              标签 标签 标签 标签
                                              标签 标签 标签
                                              标签 diff --git a/src/uploader/README.md b/src/uploader/README.md index 62271d6d2..6681badd0 100644 --- a/src/uploader/README.md +++ b/src/uploader/README.md @@ -203,6 +203,7 @@ Use `disabled` prop to disable uploader. | preview-size | Size of preview image | _number \| string_ | `80px` | | preview-image `v2.1.5` | Whether to show image preview | _boolean_ | `true` | | preview-full-image | Whethe to show full screen image preview when click image | _boolean_ | `true` | +| preview-options `v2.9.3` | Options of full screen image preview,see [ImagePreview](#/en-US/image-preview) | _object_ | - | | multiple | Whether to enable multiple selection pictures | _boolean_ | `false` | | disabled | Whether to disabled the upload | _boolean_ | `false` | | deletable `v2.2.12` | Whether to show delete icon | _boolean_ | `true` | diff --git a/src/uploader/README.zh-CN.md b/src/uploader/README.zh-CN.md index fa14d0286..45d33af9e 100644 --- a/src/uploader/README.zh-CN.md +++ b/src/uploader/README.zh-CN.md @@ -227,6 +227,7 @@ export default { | preview-size | 预览图和上传区域的尺寸,默认单位为`px` | _number \| string_ | `80px` | | preview-image | 是否在上传完成后展示预览图 | _boolean_ | `true` | | preview-full-image `v2.1.5` | 是否在点击预览图后展示全屏图片预览 | _boolean_ | `true` | +| preview-options `v2.9.3` | 全屏图片预览的配置项,可选值见 [ImagePreview](#/zh-CN/image-preview) | _object_ | - | | multiple | 是否开启图片多选,部分安卓机型不支持 | _boolean_ | `false` | | disabled | 是否禁用文件上传 | _boolean_ | `false` | | deletable `v2.2.12` | 是否展示删除按钮 | _boolean_ | `true` | diff --git a/src/uploader/index.js b/src/uploader/index.js index 1ede615a5..d56416cf9 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -30,6 +30,7 @@ export default createComponent({ beforeRead: Function, beforeDelete: Function, previewSize: [Number, String], + previewOptions: Object, name: { type: [Number, String], default: '', @@ -256,11 +257,11 @@ export default createComponent({ this.imagePreview = ImagePreview({ images: imageContents, - closeOnPopstate: true, startPosition: imageFiles.indexOf(item), onClose: () => { this.$emit('close-preview'); }, + ...this.previewOptions, }); }, diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index 5aa5c894d..76ab58f30 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -406,6 +406,23 @@ test('click to preview image', async () => { expect(images.length).toEqual(1); }); +test('preview-options prop', async () => { + const wrapper = mount(Uploader, { + propsData: { + fileList: [{ url: IMAGE }], + previewOptions: { + closeable: true, + }, + }, + }); + + wrapper.find('.van-image').trigger('click'); + await later(); + + const closeIcon = document.querySelectorAll('.van-image-preview__close-icon'); + expect(closeIcon.length).toEqual(1); +}); + test('closeImagePreview method', () => { const close = jest.fn(); const wrapper = mount(Uploader, { diff --git a/src/utils/dom/scroll.ts b/src/utils/dom/scroll.ts index aa3f7f571..6d7457f74 100644 --- a/src/utils/dom/scroll.ts +++ b/src/utils/dom/scroll.ts @@ -40,7 +40,10 @@ export function getScroller(el: HTMLElement, root: ScrollElement = window) { } export function getScrollTop(el: ScrollElement): number { - return 'scrollTop' in el ? el.scrollTop : el.pageYOffset; + const top = 'scrollTop' in el ? el.scrollTop : el.pageYOffset; + + // iOS scroll bounce cause minus scrollTop + return Math.max(top, 0); } export function setScrollTop(el: ScrollElement, value: number) { diff --git a/src/utils/format/unit.ts b/src/utils/format/unit.ts index b50167e7c..9b2de011d 100644 --- a/src/utils/format/unit.ts +++ b/src/utils/format/unit.ts @@ -1,4 +1,4 @@ -import { isDef } from '..'; +import { isDef, inBrowser } from '..'; import { isNumeric } from '../validate/number'; export function addUnit(value?: string | number): string | undefined { @@ -30,13 +30,24 @@ function convertRem(value: string) { return +value * getRootFontSize(); } +function convertVw(value: string) { + value = value.replace(/vw/g, ''); + return (+value * window.innerWidth) / 100; +} + export function unitToPx(value: string | number): number { if (typeof value === 'number') { return value; } - if (value.indexOf('rem') !== -1) { - return convertRem(value); + if (inBrowser) { + if (value.indexOf('rem') !== -1) { + return convertRem(value); + } + + if (value.indexOf('vw') !== -1) { + return convertVw(value); + } } return parseFloat(value); diff --git a/types/tabs.d.ts b/types/tabs.d.ts index 57b8cad0a..1b9d9becd 100644 --- a/types/tabs.d.ts +++ b/types/tabs.d.ts @@ -2,4 +2,6 @@ import { VanComponent } from './component'; export class Tabs extends VanComponent { resize(): void; + + scrollTo(name: string | number): void; } diff --git a/yarn.lock b/yarn.lock index 4da81328a..46927e534 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1584,9 +1584,9 @@ defer-to-connect "^2.0.0" "@tootallnate/once@1": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.0.0.tgz#9c13c2574c92d4503b005feca8f2e16cc1611506" - integrity sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA== + version "1.1.2" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" + integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== "@types/anymatch@*": version "1.3.1" @@ -2461,9 +2461,9 @@ agent-base@5: integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== agent-base@6: - version "6.0.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.0.tgz#5d0101f19bbfaed39980b22ae866de153b93f09a" - integrity sha512-j1Q7cSCqN+AwrmDd+pzgqc0/NpC655x2bUf5ZjRIO77DcNBFmh+OgRNzF6OKdCC9RSCb19fGd99+bhXFdkRNqw== + version "6.0.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.1.tgz#808007e4e5867decb0ab6ab2f928fbdb5a596db4" + integrity sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg== dependencies: debug "4" @@ -3673,9 +3673,9 @@ co@^4.6.0: integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= codecov@^3.7.0: - version "3.7.0" - resolved "https://registry.npmjs.org/codecov/-/codecov-3.7.0.tgz#4a09939cde24447a43f36d068e8b4e0188dc3f27" - integrity sha512-uIixKofG099NbUDyzRk1HdGtaG8O+PBUAg3wfmjwXw2+ek+PZp+puRvbTohqrVfuudaezivJHFgTtSC3M8MXww== + version "3.7.1" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.1.tgz#434cb8d55f18ef01672e5739d3d266696bebc202" + integrity sha512-JHWxyPTkMLLJn9SmKJnwAnvY09kg2Os2+Ux+GG7LwZ9g8gzDDISpIN5wAsH1UBaafA/yGcd3KofMaorE8qd6Lw== dependencies: argv "0.0.2" ignore-walk "3.0.3"