Compare commits

..

No commits in common. "dev" and "v1.10.6" have entirely different histories.
dev ... v1.10.6

335 changed files with 5269 additions and 8720 deletions

View File

@ -1,3 +1,3 @@
你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。 你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。
http://vant-ui.github.io/vant-issue-generater?repo=VantWeapp http://vant-contrib.gitee.io/vant-issue-generater?repo=VantWeapp

View File

@ -1 +1 @@
blank_issues_enabled: false blank_issues_enabled: true

View File

@ -1,5 +1,5 @@
name: 我要反馈 Vant Weapp 的 Bug name: 我要反馈 Vant Weapp 的 Bug
description: 通过标准模板进行 Bug 反馈 description: 通过标准模板进行 Bug 反馈
title: "[Bug Report] 请在此填写标题" title: "[Bug Report] 请在此填写标题"
labels: ["bug: need confirm"] labels: ["bug: need confirm"]
body: body:
@ -16,7 +16,7 @@ body:
id: reproduce id: reproduce
attributes: attributes:
label: 重现链接 label: 重现链接
description: 请提供一个尽可能简单的微信小程序代码片段协助我们排查,这可以更快的帮助我们定位问题,解决 issue description: 请提供一个尽可能简单的 GitHub 仓库链接 或者 真实的代码片段。不要填写无效的链接 或 代码,这会导致你的 issue 被直接关闭
validations: validations:
required: true required: true

View File

@ -1,10 +0,0 @@
"change: feat":
- "/^(feat|types|style)/"
"change: fix":
- "/^fix/"
"change: perf":
- "/^perf/"
"change: breaking":
- "/^breaking change/"
"change: docs":
- "/^docs/"

View File

@ -7,8 +7,6 @@ on:
- 'docs/**/*.md' - 'docs/**/*.md'
- 'packages/**/*.md' - 'packages/**/*.md'
workflow_dispatch:
jobs: jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -24,16 +22,9 @@ jobs:
- name: Build Site - name: Build Site
run: npx --no-install vant-cli build-site run: npx --no-install vant-cli build-site
- name: Deploy for GitHub 🚀 - name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.6.0 uses: JamesIves/github-pages-deploy-action@4.1.1
with: with:
branch: gh-pages branch: gh-pages
folder: site-dist folder: site-dist
token: ${{ secrets.VANT_UI_TOKEN }} clean-exclude: 0.x
repository-name: vant-ui/vant-ui.github.io
target-folder: vant-weapp
# enable single-commit to reduce the repo size
single-commit: true
clean: true
clean-exclude: |
0.x

View File

@ -1,20 +0,0 @@
name: PR Labeler
on:
pull_request_target:
types:
- opened
- edited
jobs:
change-labeling:
name: Labeling for changes
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/pr-labeler.yml
enable-versioned-regex: 0
include-title: 1
sync-labels: 1

View File

@ -11,12 +11,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@master
- name: Create Release for Tag - name: Create Release for Tag
id: release_tag id: release_tag
uses: ncipollo/release-action@v1 uses: yyx990803/release-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
generateReleaseNotes: "true" tag_name: ${{ github.ref }}
body: | body: |
> 请访问 [更新日志](https://vant-ui.github.io/vant-weapp/#/changelog) 了解所有更新 更新内容参见 [CHANGELOG](https://vant-contrib.gitee.io/vant-weapp/#/changelog)

20
.github/workflows/sync-gitee.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: Sync to Gitee
on:
push:
branches: [dev, gh-pages]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Sync to Gitee
uses: wearerequired/git-mirror-action@master
env:
# 注意在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
with:
# 注意替换为你的 GitHub 源仓库地址
source-repo: git@github.com:vant-ui/vant-weapp.git
# 注意替换为你的 Gitee 目标仓库地址
destination-repo: git@gitee.com:vant-contrib/vant-weapp.git

View File

@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: '18.x' node-version: '14.x'
- name: Install dependencies - name: Install dependencies
uses: bahmutov/npm-install@v1 uses: bahmutov/npm-install@v1
@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: '18.x' node-version: '14.x'
- name: Install dependencies - name: Install dependencies
uses: bahmutov/npm-install@v1 uses: bahmutov/npm-install@v1
@ -47,7 +47,7 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: '18.x' node-version: '14.x'
- name: Install dependencies - name: Install dependencies
uses: bahmutov/npm-install@v1 uses: bahmutov/npm-install@v1

View File

@ -11,9 +11,9 @@
</p> </p>
<p align="center"> <p align="center">
🔥 <a href="https://vant.pro/vant-weapp/">文档网站(国内)</a> 🔥 <a href="https://vant-contrib.gitee.io/vant-weapp">文档网站(国内)</a>
&nbsp; &nbsp;
🔥 <a href="https://vant-ui.github.io/vant-weapp/">文档网站GitHub</a> 🌈 <a href="https://vant-ui.github.io/vant-weapp">文档网站GitHub</a>
&nbsp; &nbsp;
🚀 <a href="https://github.com/vant-ui/vant" target="_blank">Vue 版</a> 🚀 <a href="https://github.com/vant-ui/vant" target="_blank">Vue 版</a>
</p> </p>
@ -24,11 +24,11 @@
Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。 Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
目前 Vant 官方提供了 [Vue 2 版本](https://vant-ui.github.io/vant/v2/)、[Vue 3 版本](https://vant-ui.github.io/vant/)和[微信小程序版本](http://vant-ui.github.io/vant-weapp/),并由社区团队维护 [React 版本](https://github.com/3lang3/react-vant)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。 目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant/v2)、[Vue 3 版本](https://vant-contrib.gitee.io/vant)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/3lang3/react-vant)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。
## 预览 ## 预览
扫描下方小程序二维码,体验组件库示例。注意因微信审核机制限制,目前示例小程序不是最新版本,可以 clone 代码到本地开发工具预览 扫描下方小程序二维码,体验组件库示例:
<img src="https://img.yzcdn.cn/vant-weapp/qrcode-201808101114.jpg" width="200" height="200" style="margin-top: 10px;" > <img src="https://img.yzcdn.cn/vant-weapp/qrcode-201808101114.jpg" width="200" height="200" style="margin-top: 10px;" >
@ -58,7 +58,7 @@ npm i vant-weapp -S --production
直接通过 git 下载 Vant Weapp 源代码,并将 `dist` 目录拷贝到自己的项目中。 直接通过 git 下载 Vant Weapp 源代码,并将 `dist` 目录拷贝到自己的项目中。
```bash ```bash
git clone https://github.com/youzan/vant-weapp.git git clone https://github.com/vant-ui/vant-weapp.git
``` ```
## 使用组件 ## 使用组件
@ -99,30 +99,24 @@ Vant Weapp 最低支持到小程序基础库 2.6.5 版本。
## 链接 ## 链接
- [文档网站GitHub](https://vant-ui.github.io/vant-weapp/) - [意见反馈](https://github.com/vant-ui/vant-weapp/issues)
- [文档网站(国内)](https://vant.pro/vant-weapp/) - [设计资源](https://vant-contrib.gitee.io/vant/#/zh-CN/design)
- [意见反馈](https://github.com/youzan/vant-weapp/issues) - [更新日志](https://vant-contrib.gitee.io/vant-weapp/#/changelog)
- [设计资源](https://vant-ui.github.io/vant/#/zh-CN/design)
- [更新日志](https://vant-ui.github.io/vant-weapp/#/changelog)
- [官方示例](https://github.com/vant-ui/vant-demo) - [官方示例](https://github.com/vant-ui/vant-demo)
## 核心团队 ## 核心团队
以下是 Vant 和 Vant Weapp 的核心贡献者们: 以下是 Vant 和 Vant Weapp 的核心贡献者们:
| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | | [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) |
| :-: | :-: | :-: | :-: | :-: | :-: | | :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | | [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
| [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![JakeLaoyu](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | [![landluck](https://avatars.githubusercontent.com/u/27060081?s=80&v=4)](https://github.com/landluck/) | [![wjw-gavin](https://avatars.githubusercontent.com/u/19986739?s=80&v=4)](https://github.com/wjw-gavin/) | [![inottn](https://avatars.githubusercontent.com/u/18509404?s=80&v=4)](https://github.com/inottn/) | [![zhousg](https://avatars.githubusercontent.com/u/15833290?s=80&v=4)](https://github.com/zhousg/) |
| :-: | :-: | :-: | :-: | :-: | :-: |
| [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | [landluck](https://github.com/landluck/) | [wjw-gavin](https://github.com/wjw-gavin/) | [inottn](https://github.com/inottn/) | [zhousg](https://github.com/zhousg/) |
## 贡献者们 ## 贡献者们
感谢以下小伙伴们为 Vant Weapp 发展做出的贡献: 感谢以下小伙伴们为 Vant Weapp 发展做出的贡献:
<a href="https://github.com/youzan/vant-weapp/graphs/contributors"> <a href="https://github.com/vant-ui/vant-weapp/graphs/contributors">
<img src="https://opencollective.com/vant-weapp/contributors.svg?width=890&button=false" alt="contributors"> <img src="https://opencollective.com/vant-weapp/contributors.svg?width=890&button=false" alt="contributors">
</a> </a>

View File

@ -28,4 +28,7 @@ then
else else
npm publish npm publish
fi fi
# changelog
vant-cli changelog
fi fi

View File

@ -1,7 +1,6 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { button } from '../mixins/button'; import { button } from '../mixins/button';
VantComponent({ VantComponent({
classes: ['list-class'],
mixins: [button], mixins: [button],
props: { props: {
show: Boolean, show: Boolean,
@ -36,10 +35,6 @@ VantComponent({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
rootPortal: {
type: Boolean,
value: false,
},
}, },
methods: { methods: {
onSelect(event) { onSelect(event) {

View File

@ -6,10 +6,9 @@
round="{{ round }}" round="{{ round }}"
z-index="{{ zIndex }}" z-index="{{ zIndex }}"
overlay="{{ overlay }}" overlay="{{ overlay }}"
custom-class="van-action-sheet custom-class" custom-class="van-action-sheet"
safe-area-inset-bottom="{{ safeAreaInsetBottom }}" safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
close-on-click-overlay="{{ closeOnClickOverlay }}" close-on-click-overlay="{{ closeOnClickOverlay }}"
root-portal="{{ rootPortal }}"
bind:close="onClickOverlay" bind:close="onClickOverlay"
> >
<view wx:if="{{ title }}" class="van-action-sheet__header"> <view wx:if="{{ title }}" class="van-action-sheet__header">
@ -23,7 +22,7 @@
<view wx:if="{{ description }}" class="van-action-sheet__description van-hairline--bottom"> <view wx:if="{{ description }}" class="van-action-sheet__description van-hairline--bottom">
{{ description }} {{ description }}
</view> </view>
<view wx:if="{{ actions && actions.length }}" class="list-class"> <view wx:if="{{ actions && actions.length }}">
<!-- button外包一层view防止actions动态变化导致渲染时button被打散 --> <!-- button外包一层view防止actions动态变化导致渲染时button被打散 -->
<button <button
wx:for="{{ actions }}" wx:for="{{ actions }}"

View File

@ -2,7 +2,7 @@
<wxs src="./index.wxs" module="computed" /> <wxs src="./index.wxs" module="computed" />
<button <button
id="{{ id || buttonId }}" id="{{ id }}"
data-detail="{{ dataset }}" data-detail="{{ dataset }}"
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}" class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}" hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}"
@ -22,8 +22,6 @@
bindgetuserinfo="onGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindcontact="onContact" bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber" bindgetphonenumber="onGetPhoneNumber"
bindgetrealtimephonenumber="onGetRealTimePhoneNumber"
bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
binderror="onError" binderror="onError"
bindlaunchapp="onLaunchApp" bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting" bindopensetting="onOpenSetting"

View File

@ -1,5 +1,3 @@
<wxs src="./index.wxs" module="computed" />
<wxs src="../wxs/utils.wxs" module="utils" />
<view class="van-calendar"> <view class="van-calendar">
<header <header
title="{{ title }}" title="{{ title }}"
@ -56,12 +54,12 @@
type="danger" type="danger"
color="{{ color }}" color="{{ color }}"
custom-class="van-calendar__confirm" custom-class="van-calendar__confirm"
disabled="{{ computed.getButtonDisabled(type, currentDate, minRange) }}" disabled="{{ computed.getButtonDisabled(type, currentDate) }}"
nativeType="text" nativeType="text"
bind:click="onConfirm" bind:click="onConfirm"
> >
{{ {{
computed.getButtonDisabled(type, currentDate, minRange) computed.getButtonDisabled(type, currentDate)
? confirmDisabledText ? confirmDisabledText
: confirmText : confirmText
}} }}

View File

@ -40,7 +40,6 @@ VantComponent({
}, },
defaultDate: { defaultDate: {
type: null, type: null,
value: getToday().getTime(),
observer(val) { observer(val) {
this.setData({ currentDate: val }); this.setData({ currentDate: val });
this.scrollIntoView(); this.scrollIntoView();
@ -104,33 +103,17 @@ VantComponent({
type: null, type: null,
value: null, value: null,
}, },
minRange: {
type: Number,
value: 1,
},
firstDayOfWeek: { firstDayOfWeek: {
type: Number, type: Number,
value: 0, value: 0,
}, },
readonly: Boolean, readonly: Boolean,
rootPortal: {
type: Boolean,
value: false,
},
}, },
data: { data: {
subtitle: '', subtitle: '',
currentDate: null, currentDate: null,
scrollIntoView: '', scrollIntoView: '',
}, },
watch: {
minDate() {
this.initRect();
},
maxDate() {
this.initRect();
},
},
created() { created() {
this.setData({ this.setData({
currentDate: this.getInitialDate(this.data.defaultDate), currentDate: this.getInitialDate(this.data.defaultDate),
@ -144,7 +127,7 @@ VantComponent({
}, },
methods: { methods: {
reset() { reset() {
this.setData({ currentDate: this.getInitialDate(this.data.defaultDate) }); this.setData({ currentDate: this.getInitialDate() });
this.scrollIntoView(); this.scrollIntoView();
}, },
initRect() { initRect() {
@ -176,19 +159,15 @@ VantComponent({
return date; return date;
}, },
getInitialDate(defaultDate = null) { getInitialDate(defaultDate = null) {
const { type, minDate, maxDate, allowSameDay } = this.data; const { type, minDate, maxDate } = this.data;
if (!defaultDate)
return [];
const now = getToday().getTime(); const now = getToday().getTime();
if (type === 'range') { if (type === 'range') {
if (!Array.isArray(defaultDate)) { if (!Array.isArray(defaultDate)) {
defaultDate = []; defaultDate = [];
} }
const [startDay, endDay] = defaultDate || []; const [startDay, endDay] = defaultDate || [];
const startDate = getTime(startDay || now); const start = this.limitDateRange(startDay || now, minDate, getPrevDay(new Date(maxDate)).getTime());
const start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : getPrevDay(new Date(maxDate)).getTime()); const end = this.limitDateRange(endDay || now, getNextDay(new Date(minDate)).getTime());
const date = getTime(endDay || now);
const end = this.limitDateRange(date, allowSameDay ? date : getNextDay(new Date(minDate)).getTime());
return [start, end]; return [start, end];
} }
if (type === 'multiple') { if (type === 'multiple') {
@ -205,8 +184,6 @@ VantComponent({
scrollIntoView() { scrollIntoView() {
requestAnimationFrame(() => { requestAnimationFrame(() => {
const { currentDate, type, show, poppable, minDate, maxDate } = this.data; const { currentDate, type, show, poppable, minDate, maxDate } = this.data;
if (!currentDate)
return;
// @ts-ignore // @ts-ignore
const targetDate = type === 'single' ? currentDate : currentDate[0]; const targetDate = type === 'single' ? currentDate : currentDate[0];
const displayed = show || !poppable; const displayed = show || !poppable;
@ -263,7 +240,7 @@ VantComponent({
this.select([date, null]); this.select([date, null]);
} }
else if (allowSameDay) { else if (allowSameDay) {
this.select([date, date], true); this.select([date, date]);
} }
} }
else { else {

View File

@ -12,8 +12,6 @@
position="{{ position }}" position="{{ position }}"
closeable="{{ showTitle || showSubtitle }}" closeable="{{ showTitle || showSubtitle }}"
close-on-click-overlay="{{ closeOnClickOverlay }}" close-on-click-overlay="{{ closeOnClickOverlay }}"
safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
root-portal="{{ rootPortal }}"
bind:enter="onOpen" bind:enter="onOpen"
bind:close="onClose" bind:close="onClose"
bind:after-enter="onOpened" bind:after-enter="onOpened"

View File

@ -15,7 +15,7 @@ function getMonths(minDate, maxDate) {
return months; return months;
} }
function getButtonDisabled(type, currentDate, minRange) { function getButtonDisabled(type, currentDate) {
if (currentDate == null) { if (currentDate == null) {
return true; return true;
} }
@ -25,7 +25,7 @@ function getButtonDisabled(type, currentDate, minRange) {
} }
if (type === 'multiple') { if (type === 'multiple') {
return currentDate.length < minRange; return !currentDate.length;
} }
return !currentDate; return !currentDate;

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-calendar{background-color:var(--calendar-background-color,#fff);display:flex;flex-direction:column;height:var(--calendar-height,100%)}.van-calendar__close-icon{top:11px}.van-calendar__popup--bottom,.van-calendar__popup--top{height:var(--calendar-popup-height,90%)}.van-calendar__popup--left,.van-calendar__popup--right{height:100%}.van-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.van-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.van-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.van-calendar__footer+.van-calendar__footer,.van-calendar__footer:empty{display:none}.van-calendar__footer:empty+.van-calendar__footer{display:block!important}.van-calendar__confirm{height:var(--calendar-confirm-button-height,36px)!important;line-height:var(--calendar-confirm-button-line-height,34px)!important;margin:var(--calendar-confirm-button-margin,7px 0)!important} @import '../common/index.wxss';.van-calendar{background-color:var(--calendar-background-color,#fff);display:flex;flex-direction:column;height:var(--calendar-height,100%)}.van-calendar__close-icon{top:11px}.van-calendar__popup--bottom,.van-calendar__popup--top{height:var(--calendar-popup-height,80%)}.van-calendar__popup--left,.van-calendar__popup--right{height:100%}.van-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.van-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.van-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.van-calendar__footer+.van-calendar__footer,.van-calendar__footer:empty{display:none}.van-calendar__footer:empty+.van-calendar__footer{display:block!important}.van-calendar__confirm{height:var(--calendar-confirm-button-height,36px)!important;line-height:var(--calendar-confirm-button-line-height,34px)!important;margin:var(--calendar-confirm-button-margin,7px 0)!important}

View File

@ -1 +0,0 @@
export {};

210
dist/cascader/index.js vendored
View File

@ -1,210 +0,0 @@
import { VantComponent } from '../common/component';
var FieldName;
(function (FieldName) {
FieldName["TEXT"] = "text";
FieldName["VALUE"] = "value";
FieldName["CHILDREN"] = "children";
})(FieldName || (FieldName = {}));
const defaultFieldNames = {
text: FieldName.TEXT,
value: FieldName.VALUE,
children: FieldName.CHILDREN,
};
VantComponent({
props: {
title: String,
value: {
type: String,
},
placeholder: {
type: String,
value: '请选择',
},
activeColor: {
type: String,
value: '#1989fa',
},
options: {
type: Array,
value: [],
},
swipeable: {
type: Boolean,
value: false,
},
closeable: {
type: Boolean,
value: true,
},
showHeader: {
type: Boolean,
value: true,
},
closeIcon: {
type: String,
value: 'cross',
},
fieldNames: {
type: Object,
value: defaultFieldNames,
observer: 'updateFieldNames',
},
useTitleSlot: Boolean,
},
data: {
tabs: [],
activeTab: 0,
textKey: FieldName.TEXT,
valueKey: FieldName.VALUE,
childrenKey: FieldName.CHILDREN,
innerValue: '',
},
watch: {
options() {
this.updateTabs();
},
value(newVal) {
this.updateValue(newVal);
},
},
created() {
this.updateTabs();
},
methods: {
updateValue(val) {
if (val !== undefined) {
const values = this.data.tabs.map((tab) => tab.selected && tab.selected[this.data.valueKey]);
if (values.indexOf(val) > -1) {
return;
}
}
this.innerValue = val;
this.updateTabs();
},
updateFieldNames() {
const { text = 'text', value = 'value', children = 'children', } = this.data.fieldNames || defaultFieldNames;
this.setData({
textKey: text,
valueKey: value,
childrenKey: children,
});
},
getSelectedOptionsByValue(options, value) {
for (let i = 0; i < options.length; i++) {
const option = options[i];
if (option[this.data.valueKey] === value) {
return [option];
}
if (option[this.data.childrenKey]) {
const selectedOptions = this.getSelectedOptionsByValue(option[this.data.childrenKey], value);
if (selectedOptions) {
return [option, ...selectedOptions];
}
}
}
},
updateTabs() {
const { options } = this.data;
const { innerValue } = this;
if (!options.length) {
return;
}
if (innerValue !== undefined) {
const selectedOptions = this.getSelectedOptionsByValue(options, innerValue);
if (selectedOptions) {
let optionsCursor = options;
const tabs = selectedOptions.map((option) => {
const tab = {
options: optionsCursor,
selected: option,
};
const next = optionsCursor.find((item) => item[this.data.valueKey] === option[this.data.valueKey]);
if (next) {
optionsCursor = next[this.data.childrenKey];
}
return tab;
});
if (optionsCursor) {
tabs.push({
options: optionsCursor,
selected: null,
});
}
this.setData({
tabs,
});
wx.nextTick(() => {
this.setData({
activeTab: tabs.length - 1,
});
});
return;
}
}
this.setData({
tabs: [
{
options,
selected: null,
},
],
activeTab: 0,
});
},
onClose() {
this.$emit('close');
},
onClickTab(e) {
const { index: tabIndex, title } = e.detail;
this.$emit('click-tab', { title, tabIndex });
this.setData({
activeTab: tabIndex,
});
},
// 选中
onSelect(e) {
const { option, tabIndex } = e.currentTarget.dataset;
if (option && option.disabled) {
return;
}
const { valueKey, childrenKey } = this.data;
let { tabs } = this.data;
tabs[tabIndex].selected = option;
if (tabs.length > tabIndex + 1) {
tabs = tabs.slice(0, tabIndex + 1);
}
if (option[childrenKey]) {
const nextTab = {
options: option[childrenKey],
selected: null,
};
if (tabs[tabIndex + 1]) {
tabs[tabIndex + 1] = nextTab;
}
else {
tabs.push(nextTab);
}
wx.nextTick(() => {
this.setData({
activeTab: tabIndex + 1,
});
});
}
this.setData({
tabs,
});
const selectedOptions = tabs.map((tab) => tab.selected).filter(Boolean);
const value = option[valueKey];
const params = {
value,
tabIndex,
selectedOptions,
};
this.innerValue = value;
this.$emit('change', params);
if (!option[childrenKey]) {
this.$emit('finish', params);
}
},
},
});

View File

@ -1,8 +0,0 @@
{
"component": true,
"usingComponents": {
"van-icon": "../icon/index",
"van-tab": "../tab/index",
"van-tabs": "../tabs/index"
}
}

View File

@ -1,54 +0,0 @@
<wxs src="./index.wxs" module="utils" />
<view wx:if="{{ showHeader }}" class="van-cascader__header">
<slot name="title" wx:if="{{ useTitleSlot }}"></slot>
<text class="van-cascader__title" wx:else>{{ title }}</text>
<van-icon
wx:if="{{ closeable }}"
name="{{ closeIcon }}"
class="van-cascader__close-icon"
bind:tap="onClose"
/>
</view>
<van-tabs
active="{{ activeTab }}"
custom-class="van-cascader__tabs"
wrap-class="van-cascader__tabs-wrap"
tab-class="van-cascader__tab"
color="{{ activeColor }}"
border="{{ false }}"
swipeable="{{ swipeable }}"
bind:click="onClickTab"
>
<van-tab
wx:for="{{ tabs }}"
wx:for-item="tab"
wx:for-index="tabIndex"
wx:key="tabIndex"
title="{{ tab.selected ? tab.selected[textKey] : placeholder }}"
style="width: 100%;"
title-style="{{ !tab.selected ? 'color: #969799;font-weight:normal;' : '' }}"
>
<!-- 暂不支持 -->
<!-- <slot name="options-top"></slot> -->
<view class="van-cascader__options">
<view
wx:for="{{ tab.options }}"
wx:for-item="option"
wx:key="index"
class="{{ option.className }} {{ utils.optionClass(tab, valueKey, option) }}"
style="{{ utils.optionStyle({ tab, valueKey, option, activeColor }) }}"
data-option="{{ option }}"
data-tab-index="{{ tabIndex }}"
bind:tap="onSelect"
>
<text>{{ option[textKey] }}</text>
<van-icon wx:if="{{ utils.isSelected(tab, valueKey, option) }}" name="success" size="18" />
</view>
</view>
<!-- 暂不支持 -->
<!-- <slot name="options-bottom"></slot> -->
</van-tab>
</van-tabs>

View File

@ -1,24 +0,0 @@
var utils = require('../wxs/utils.wxs');
var style = require('../wxs/style.wxs');
function isSelected(tab, valueKey, option) {
return tab.selected && tab.selected[valueKey] === option[valueKey]
}
function optionClass(tab, valueKey, option) {
return utils.bem('cascader__option', { selected: isSelected(tab, valueKey, option), disabled: option.disabled })
}
function optionStyle(data) {
var color = data.option.color || (isSelected(data.tab, data.valueKey, data.option) ? data.activeColor : undefined);
return style({
color
});
}
module.exports = {
isSelected: isSelected,
optionClass: optionClass,
optionStyle: optionStyle,
};

View File

@ -1 +0,0 @@
@import '../common/index.wxss';.van-cascader__header{align-items:center;display:flex;height:48px;justify-content:space-between;padding:0 16px}.van-cascader__title{font-size:16px;font-weight:600;line-height:20px}.van-cascader__close-icon{color:#c8c9cc;font-size:22px;height:22px}.van-cascader__tabs-wrap{height:48px!important;padding:0 8px}.van-cascader__tab{color:#323233!important;flex:none!important;font-weight:600!important;padding:0 8px!important}.van-cascader__tab--unselected{color:#969799!important;font-weight:400!important}.van-cascader__option{align-items:center;cursor:pointer;display:flex;font-size:14px;justify-content:space-between;line-height:20px;padding:10px 16px}.van-cascader__option:active{background-color:#f2f3f5}.van-cascader__option--selected{color:#1989fa;font-weight:600}.van-cascader__option--disabled{color:#c8c9cc;cursor:not-allowed}.van-cascader__option--disabled:active{background-color:initial}.van-cascader__options{-webkit-overflow-scrolling:touch;box-sizing:border-box;height:384px;overflow-y:auto;padding-top:6px}

View File

@ -1,4 +1,4 @@
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
type CanvasContext = WechatMiniprogram.CanvasContext; declare type CanvasContext = WechatMiniprogram.CanvasContext;
export declare function adaptor(ctx: CanvasContext & Record<string, unknown>): CanvasContext; export declare function adaptor(ctx: CanvasContext & Record<string, unknown>): CanvasContext;
export {}; export {};

View File

@ -93,8 +93,6 @@ VantComponent({
const { color, size } = this.data; const { color, size } = this.data;
if (isObj(color)) { if (isObj(color)) {
return this.getContext().then((context) => { return this.getContext().then((context) => {
if (!context)
return;
const LinearColor = context.createLinearGradient(size, 0, 0, 0); const LinearColor = context.createLinearGradient(size, 0, 0, 0);
Object.keys(color) Object.keys(color)
.sort((a, b) => parseFloat(a) - parseFloat(b)) .sort((a, b) => parseFloat(a) - parseFloat(b))
@ -136,8 +134,6 @@ VantComponent({
drawCircle(currentValue) { drawCircle(currentValue) {
const { size } = this.data; const { size } = this.data;
this.getContext().then((context) => { this.getContext().then((context) => {
if (!context)
return;
context.clearRect(0, 0, size, size); context.clearRect(0, 0, size, size);
this.renderLayerCircle(context); this.renderLayerCircle(context);
const formatValue = format(currentValue); const formatValue = format(currentValue);

View File

@ -11,7 +11,6 @@ function VantComponent(vantOptions) {
mapKeys(vantOptions, options, { mapKeys(vantOptions, options, {
data: 'data', data: 'data',
props: 'properties', props: 'properties',
watch: 'observers',
mixins: 'behaviors', mixins: 'behaviors',
methods: 'methods', methods: 'methods',
beforeCreate: 'created', beforeCreate: 'created',

View File

@ -1,5 +1,5 @@
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
type TrivialInstance = WechatMiniprogram.Component.TrivialInstance; declare type TrivialInstance = WechatMiniprogram.Component.TrivialInstance;
export declare function useParent(name: string, onEffect?: (this: TrivialInstance) => void): { export declare function useParent(name: string, onEffect?: (this: TrivialInstance) => void): {
relations: { relations: {
[x: string]: WechatMiniprogram.Component.RelationOption; [x: string]: WechatMiniprogram.Component.RelationOption;

View File

@ -8,14 +8,10 @@ export { getSystemInfoSync } from './version';
export declare function range(num: number, min: number, max: number): number; export declare function range(num: number, min: number, max: number): number;
export declare function nextTick(cb: (...args: any[]) => void): void; export declare function nextTick(cb: (...args: any[]) => void): void;
export declare function addUnit(value?: string | number): string | undefined; export declare function addUnit(value?: string | number): string | undefined;
export declare function requestAnimationFrame(cb: () => void): NodeJS.Timeout; export declare function requestAnimationFrame(cb: () => void): NodeJS.Timeout | WechatMiniprogram.NodesRef;
export declare function pickExclude(obj: unknown, keys: string[]): {}; export declare function pickExclude(obj: unknown, keys: string[]): {};
export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>; export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>;
export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>; export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void; export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void;
export declare function toPromise(promiseLike: Promise<unknown> | unknown): Promise<unknown>; export declare function toPromise(promiseLike: Promise<unknown> | unknown): Promise<unknown>;
export declare function addNumber(num1: any, num2: any): number;
export declare const clamp: (num: any, min: any, max: any) => number;
export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject; export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;
export declare const isPC: boolean;
export declare const isWxWork: boolean;

26
dist/common/utils.js vendored
View File

@ -1,5 +1,5 @@
import { isDef, isNumber, isPlainObject, isPromise } from './validator'; import { isDef, isNumber, isPlainObject, isPromise } from './validator';
import { canIUseGroupSetData, canIUseNextTick, getSystemInfoSync, } from './version'; import { canIUseGroupSetData, canIUseNextTick, getSystemInfoSync } from './version';
export { isDef } from './validator'; export { isDef } from './validator';
export { getSystemInfoSync } from './version'; export { getSystemInfoSync } from './version';
export function range(num, min, max) { export function range(num, min, max) {
@ -23,9 +23,19 @@ export function addUnit(value) {
return isNumber(value) ? `${value}px` : value; return isNumber(value) ? `${value}px` : value;
} }
export function requestAnimationFrame(cb) { export function requestAnimationFrame(cb) {
return setTimeout(() => { const systemInfo = getSystemInfoSync();
if (systemInfo.platform === 'devtools') {
return setTimeout(() => {
cb();
}, 1000 / 30);
}
return wx
.createSelectorQuery()
.selectViewport()
.boundingClientRect()
.exec(() => {
cb(); cb();
}, 1000 / 30); });
} }
export function pickExclude(obj, keys) { export function pickExclude(obj, keys) {
if (!isPlainObject(obj)) { if (!isPlainObject(obj)) {
@ -70,17 +80,7 @@ export function toPromise(promiseLike) {
} }
return Promise.resolve(promiseLike); return Promise.resolve(promiseLike);
} }
// 浮点数精度处理
export function addNumber(num1, num2) {
const cardinal = Math.pow(10, 10);
return Math.round((num1 + num2) * cardinal) / cardinal;
}
// 限制value在[min, max]之间
export const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
export function getCurrentPage() { export function getCurrentPage() {
const pages = getCurrentPages(); const pages = getCurrentPages();
return pages[pages.length - 1]; return pages[pages.length - 1];
} }
export const isPC = ['mac', 'windows'].includes(getSystemInfoSync().platform);
// 是否企业微信
export const isWxWork = getSystemInfoSync().environment === 'wxwork';

View File

@ -1,10 +1,5 @@
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
interface WxWorkSystemInfo extends WechatMiniprogram.SystemInfo { export declare function getSystemInfoSync(): WechatMiniprogram.SystemInfo;
environment?: 'wxwork';
}
interface SystemInfo extends WxWorkSystemInfo, WechatMiniprogram.SystemInfo {
}
export declare function getSystemInfoSync(): SystemInfo;
export declare function canIUseModel(): boolean; export declare function canIUseModel(): boolean;
export declare function canIUseFormFieldButton(): boolean; export declare function canIUseFormFieldButton(): boolean;
export declare function canIUseAnimate(): boolean; export declare function canIUseAnimate(): boolean;
@ -12,4 +7,3 @@ export declare function canIUseGroupSetData(): boolean;
export declare function canIUseNextTick(): boolean; export declare function canIUseNextTick(): boolean;
export declare function canIUseCanvas2d(): boolean; export declare function canIUseCanvas2d(): boolean;
export declare function canIUseGetUserProfile(): boolean; export declare function canIUseGetUserProfile(): boolean;
export {};

View File

@ -1,4 +1,4 @@
export type TimeData = { export declare type TimeData = {
days: number; days: number;
hours: number; hours: number;
minutes: number; minutes: number;

View File

@ -4,9 +4,8 @@ interface VantComponentInstance {
children: WechatMiniprogram.Component.TrivialInstance[]; children: WechatMiniprogram.Component.TrivialInstance[];
index: number; index: number;
$emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void; $emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void;
setView: (value: Record<string, any>, callback?: () => void) => void;
} }
export type VantComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends WechatMiniprogram.Component.PropertyOption, Methods extends WechatMiniprogram.Component.MethodOption> = { export declare type VantComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends WechatMiniprogram.Component.PropertyOption, Methods extends WechatMiniprogram.Component.MethodOption> = {
data?: Data; data?: Data;
field?: boolean; field?: boolean;
classes?: string[]; classes?: string[];
@ -16,7 +15,6 @@ export type VantComponentOptions<Data extends WechatMiniprogram.Component.DataOp
relations: Record<string, WechatMiniprogram.Component.RelationOption>; relations: Record<string, WechatMiniprogram.Component.RelationOption>;
mixin: string; mixin: string;
}; };
watch?: Record<string, (...args: any[]) => any>;
methods?: Methods; methods?: Methods;
beforeCreate?: () => void; beforeCreate?: () => void;
created?: () => void; created?: () => void;

View File

@ -1,7 +1,7 @@
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
export type Action = 'confirm' | 'cancel' | 'overlay'; export declare type Action = 'confirm' | 'cancel' | 'overlay';
type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance; declare type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
interface DialogOptions { interface DialogOptions {
lang?: string; lang?: string;
show?: boolean; show?: boolean;
@ -14,9 +14,6 @@ interface DialogOptions {
overlay?: boolean; overlay?: boolean;
selector?: string; selector?: string;
ariaLabel?: string; ariaLabel?: string;
/**
* @deprecated use custom-class instead
*/
className?: string; className?: string;
customStyle?: string; customStyle?: string;
transition?: string; transition?: string;

10
dist/dialog/index.js vendored
View File

@ -4,7 +4,6 @@ import { GRAY, RED } from '../common/color';
import { toPromise } from '../common/utils'; import { toPromise } from '../common/utils';
VantComponent({ VantComponent({
mixins: [button], mixins: [button],
classes: ['cancle-button-class', 'confirm-button-class'],
props: { props: {
show: { show: {
type: Boolean, type: Boolean,
@ -18,17 +17,14 @@ VantComponent({
type: String, type: String,
value: 'default', value: 'default',
}, },
confirmButtonId: String, useSlot: Boolean,
className: String, className: String,
customStyle: String, customStyle: String,
asyncClose: Boolean, asyncClose: Boolean,
messageAlign: String, messageAlign: String,
beforeClose: null, beforeClose: null,
overlayStyle: String, overlayStyle: String,
useSlot: Boolean,
useTitleSlot: Boolean, useTitleSlot: Boolean,
useConfirmButtonSlot: Boolean,
useCancelButtonSlot: Boolean,
showCancelButton: Boolean, showCancelButton: Boolean,
closeOnClickOverlay: Boolean, closeOnClickOverlay: Boolean,
confirmButtonOpenType: String, confirmButtonOpenType: String,
@ -65,10 +61,6 @@ VantComponent({
type: String, type: String,
value: 'scale', value: 'scale',
}, },
rootPortal: {
type: Boolean,
value: false,
},
}, },
data: { data: {
loading: { loading: {

View File

@ -5,11 +5,10 @@
z-index="{{ zIndex }}" z-index="{{ zIndex }}"
overlay="{{ overlay }}" overlay="{{ overlay }}"
transition="{{ transition }}" transition="{{ transition }}"
custom-class="van-dialog van-dialog--{{ theme }}{{ className }} custom-class" custom-class="van-dialog van-dialog--{{ theme }} {{ className }}"
custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}" custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}"
overlay-style="{{ overlayStyle }}" overlay-style="{{ overlayStyle }}"
close-on-click-overlay="{{ closeOnClickOverlay }}" close-on-click-overlay="{{ closeOnClickOverlay }}"
root-portal="{{ rootPortal }}"
bind:close="onClickOverlay" bind:close="onClickOverlay"
> >
<view <view
@ -34,7 +33,7 @@
size="large" size="large"
loading="{{ loading.cancel }}" loading="{{ loading.cancel }}"
class="van-dialog__button van-hairline--right" class="van-dialog__button van-hairline--right"
custom-class="van-dialog__cancel cancle-button-class" custom-class="van-dialog__cancel"
custom-style="color: {{ cancelButtonColor }}" custom-style="color: {{ cancelButtonColor }}"
bind:click="onCancel" bind:click="onCancel"
> >
@ -45,9 +44,9 @@
size="large" size="large"
class="van-dialog__button" class="van-dialog__button"
loading="{{ loading.confirm }}" loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm confirm-button-class" custom-class="van-dialog__confirm"
custom-style="color: {{ confirmButtonColor }}" custom-style="color: {{ confirmButtonColor }}"
button-id="{{ confirmButtonId }}"
open-type="{{ confirmButtonOpenType }}" open-type="{{ confirmButtonOpenType }}"
lang="{{ lang }}" lang="{{ lang }}"
business-id="{{ businessId }}" business-id="{{ businessId }}"
@ -57,8 +56,7 @@
send-message-img="{{ sendMessageImg }}" send-message-img="{{ sendMessageImg }}"
show-message-card="{{ showMessageCard }}" show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}" app-parameter="{{ appParameter }}"
bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
bindgetRealTimePhoneNumber="onGetRealTimePhoneNumber"
bind:click="onConfirm" bind:click="onConfirm"
bindgetuserinfo="onGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindcontact="onContact" bindcontact="onContact"
@ -71,55 +69,45 @@
</van-goods-action-button> </van-goods-action-button>
</van-goods-action> </van-goods-action>
<view wx:elif="{{ showCancelButton || showConfirmButton }}" class="van-hairline--top van-dialog__footer"> <view wx:else class="van-hairline--top van-dialog__footer">
<block wx:if="{{ showCancelButton }}"> <van-button
<slot wx:if="{{ useCancelButtonSlot }}" name="cancel-button" /> wx:if="{{ showCancelButton }}"
size="large"
loading="{{ loading.cancel }}"
class="van-dialog__button van-hairline--right"
custom-class="van-dialog__cancel"
custom-style="color: {{ cancelButtonColor }}"
bind:click="onCancel"
>
{{ cancelButtonText }}
</van-button>
<van-button
wx:if="{{ showConfirmButton }}"
size="large"
class="van-dialog__button"
loading="{{ loading.confirm }}"
custom-class="van-dialog__confirm"
custom-style="color: {{ confirmButtonColor }}"
<van-button open-type="{{ confirmButtonOpenType }}"
wx:else lang="{{ lang }}"
size="large" business-id="{{ businessId }}"
loading="{{ loading.cancel }}" session-from="{{ sessionFrom }}"
class="van-dialog__button van-hairline--right" send-message-title="{{ sendMessageTitle }}"
custom-class="van-dialog__cancel cancle-button-class" send-message-path="{{ sendMessagePath }}"
custom-style="color: {{ cancelButtonColor }}" send-message-img="{{ sendMessageImg }}"
bind:click="onCancel" show-message-card="{{ showMessageCard }}"
> app-parameter="{{ appParameter }}"
{{ cancelButtonText }}
</van-button>
</block>
<block wx:if="{{ showConfirmButton }}"> bind:click="onConfirm"
<slot wx:if="{{ useConfirmButtonSlot }}" name="confirm-button" /> bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
<van-button bindgetphonenumber="onGetPhoneNumber"
wx:else binderror="onError"
size="large" bindlaunchapp="onLaunchApp"
class="van-dialog__button" bindopensetting="onOpenSetting"
loading="{{ loading.confirm }}" >
custom-class="van-dialog__confirm confirm-button-class" {{ confirmButtonText }}
custom-style="color: {{ confirmButtonColor }}" </van-button>
button-id="{{ confirmButtonId }}"
open-type="{{ confirmButtonOpenType }}"
lang="{{ lang }}"
business-id="{{ businessId }}"
session-from="{{ sessionFrom }}"
send-message-title="{{ sendMessageTitle }}"
send-message-path="{{ sendMessagePath }}"
send-message-img="{{ sendMessageImg }}"
show-message-card="{{ showMessageCard }}"
app-parameter="{{ appParameter }}"
bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
bindgetRealTimePhoneNumber="onGetRealTimePhoneNumber"
bind:click="onConfirm"
bindgetuserinfo="onGetUserInfo"
bindcontact="onContact"
bindgetphonenumber="onGetPhoneNumber"
binderror="onError"
bindlaunchapp="onLaunchApp"
bindopensetting="onOpenSetting"
>
{{ confirmButtonText }}
</van-button>
</block>
</view> </view>
</van-popup> </van-popup>

View File

@ -1,7 +1,6 @@
import { useParent } from '../common/relation'; import { useParent } from '../common/relation';
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
VantComponent({ VantComponent({
classes: ['item-title-class'],
field: true, field: true,
relation: useParent('dropdown-menu', function () { relation: useParent('dropdown-menu', function () {
this.updateDataFromParent(); this.updateDataFromParent();
@ -26,21 +25,12 @@ VantComponent({
observer: 'rerender', observer: 'rerender',
}, },
popupStyle: String, popupStyle: String,
useBeforeToggle: {
type: Boolean,
value: false,
},
rootPortal: {
type: Boolean,
value: false,
},
}, },
data: { data: {
transition: true, transition: true,
showPopup: false, showPopup: false,
showWrapper: false, showWrapper: false,
displayTitle: '', displayTitle: '',
safeAreaTabBar: false,
}, },
methods: { methods: {
rerender() { rerender() {
@ -51,14 +41,13 @@ VantComponent({
}, },
updateDataFromParent() { updateDataFromParent() {
if (this.parent) { if (this.parent) {
const { overlay, duration, activeColor, closeOnClickOverlay, direction, safeAreaTabBar, } = this.parent.data; const { overlay, duration, activeColor, closeOnClickOverlay, direction, } = this.parent.data;
this.setData({ this.setData({
overlay, overlay,
duration, duration,
activeColor, activeColor,
closeOnClickOverlay, closeOnClickOverlay,
direction, direction,
safeAreaTabBar,
}); });
} }
}, },
@ -87,6 +76,7 @@ VantComponent({
} }
}, },
toggle(show, options = {}) { toggle(show, options = {}) {
var _a;
const { showPopup } = this.data; const { showPopup } = this.data;
if (typeof show !== 'boolean') { if (typeof show !== 'boolean') {
show = !showPopup; show = !showPopup;
@ -94,37 +84,19 @@ VantComponent({
if (show === showPopup) { if (show === showPopup) {
return; return;
} }
this.onBeforeToggle(show).then((status) => { this.setData({
var _a; transition: !options.immediate,
if (!status) { showPopup: show,
return; });
} if (show) {
this.setData({ (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then((wrapperStyle) => {
transition: !options.immediate, this.setData({ wrapperStyle, showWrapper: true });
showPopup: show,
});
if (show) {
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.getChildWrapperStyle().then((wrapperStyle) => {
this.setData({ wrapperStyle, showWrapper: true });
this.rerender();
});
}
else {
this.rerender(); this.rerender();
}
});
},
onBeforeToggle(status) {
const { useBeforeToggle } = this.data;
if (!useBeforeToggle) {
return Promise.resolve(true);
}
return new Promise((resolve) => {
this.$emit('before-toggle', {
status,
callback: (value) => resolve(value),
}); });
}); }
else {
this.rerender();
}
}, },
}, },
}); });

View File

@ -2,7 +2,7 @@
<view <view
wx:if="{{ showWrapper }}" wx:if="{{ showWrapper }}"
class="{{ utils.bem('dropdown-item', direction) }} custom-class" class="{{ utils.bem('dropdown-item', direction) }}"
style="{{ wrapperStyle }}" style="{{ wrapperStyle }}"
> >
<van-popup <van-popup
@ -12,9 +12,7 @@
overlay="{{ overlay }}" overlay="{{ overlay }}"
position="{{ direction === 'down' ? 'top' : 'bottom' }}" position="{{ direction === 'down' ? 'top' : 'bottom' }}"
duration="{{ transition ? duration : 0 }}" duration="{{ transition ? duration : 0 }}"
safe-area-tab-bar="{{ safeAreaTabBar }}"
close-on-click-overlay="{{ closeOnClickOverlay }}" close-on-click-overlay="{{ closeOnClickOverlay }}"
rootPortal="{{ rootPortal }}"
bind:enter="onOpen" bind:enter="onOpen"
bind:leave="onClose" bind:leave="onClose"
bind:close="toggle" bind:close="toggle"
@ -32,7 +30,7 @@
> >
<view <view
slot="title" slot="title"
class="van-dropdown-item__title item-title-class" class="van-dropdown-item__title"
style="{{ item.value === value ? 'color:' + activeColor : '' }}" style="{{ item.value === value ? 'color:' + activeColor : '' }}"
> >
{{ item.text }} {{ item.text }}

View File

@ -4,7 +4,6 @@ import { addUnit, getRect, getSystemInfoSync } from '../common/utils';
let ARRAY = []; let ARRAY = [];
VantComponent({ VantComponent({
field: true, field: true,
classes: ['title-class'],
relation: useChildren('dropdown-item', function () { relation: useChildren('dropdown-item', function () {
this.updateItemListData(); this.updateItemListData();
}), }),
@ -32,10 +31,6 @@ VantComponent({
value: 'down', value: 'down',
observer: 'updateChildrenData', observer: 'updateChildrenData',
}, },
safeAreaTabBar: {
type: Boolean,
value: false,
},
closeOnClickOverlay: { closeOnClickOverlay: {
type: Boolean, type: Boolean,
value: true, value: true,

View File

@ -10,7 +10,7 @@
bind:tap="onTitleTap" bind:tap="onTitleTap"
> >
<view <view
class="{{ item.titleClass }} {{ utils.bem('dropdown-menu__title', { active: item.showPopup, down: item.showPopup === (direction === 'down') }) }} title-class" class="{{ item.titleClass }} {{ utils.bem('dropdown-menu__title', { active: item.showPopup, down: item.showPopup === (direction === 'down') }) }}"
style="{{ item.showPopup ? 'color:' + activeColor : '' }}" style="{{ item.showPopup ? 'color:' + activeColor : '' }}"
> >
<view class="van-ellipsis"> <view class="van-ellipsis">

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-dropdown-menu{background-color:var(--dropdown-menu-background-color,#fff);box-shadow:var(--dropdown-menu-box-shadow,0 2px 12px hsla(210,1%,40%,.12));display:flex;height:var(--dropdown-menu-height,50px);-webkit-user-select:none;user-select:none}.van-dropdown-menu__item{align-items:center;display:flex;flex:1;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{box-sizing:border-box;color:var(--dropdown-menu-title-text-color,#323233);font-size:var(--dropdown-menu-title-font-size,15px);line-height:var(--dropdown-menu-title-line-height,18px);max-width:100%;padding:var(--dropdown-menu-title-padding,0 24px 0 8px);position:relative}.van-dropdown-menu__title:after{border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;content:"";margin-top:-5px;opacity:.8;position:absolute;right:11px;top:50%;transform:rotate(-45deg)}.van-dropdown-menu__title--active{color:var(--dropdown-menu-title-active-text-color,#ee0a24)}.van-dropdown-menu__title--down:after{margin-top:-1px;transform:rotate(135deg)} @import '../common/index.wxss';.van-dropdown-menu{background-color:var(--dropdown-menu-background-color,#fff);box-shadow:var(--dropdown-menu-box-shadow,0 2px 12px hsla(210,1%,40%,.12));display:flex;height:var(--dropdown-menu-height,50px);-webkit-user-select:none;user-select:none}.van-dropdown-menu__item{align-items:center;display:flex;flex:1;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{box-sizing:border-box;color:var(--dropdown-menu-title-text-color,#323233);font-size:var(--dropdown-menu-title-font-size,15px);line-height:var(--dropdown-menu-title-line-height,18px);max-width:100%;padding:var(--dropdown-menu-title-padding,0 8px);position:relative}.van-dropdown-menu__title:after{border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;content:"";margin-top:-5px;opacity:.8;position:absolute;right:-4px;top:50%;transform:rotate(-45deg)}.van-dropdown-menu__title--active{color:var(--dropdown-menu-title-active-text-color,#ee0a24)}.van-dropdown-menu__title--down:after{margin-top:-1px;transform:rotate(135deg)}

53
dist/field/index.js vendored
View File

@ -22,45 +22,22 @@ VantComponent({
}, clearIcon: { }, clearIcon: {
type: String, type: String,
value: 'clear', value: 'clear',
}, extraEventParams: {
type: Boolean,
value: false,
} }), } }),
data: { data: {
focused: false, focused: false,
innerValue: '', innerValue: '',
showClear: false, showClear: false,
}, },
watch: {
value(value) {
if (value !== this.value) {
this.setData({ innerValue: value });
this.value = value;
this.setShowClear();
}
},
clearTrigger() {
this.setShowClear();
},
},
created() { created() {
this.value = this.data.value; this.value = this.data.value;
this.setData({ innerValue: this.value }); this.setData({ innerValue: this.value });
}, },
methods: { methods: {
formatValue(value) {
const { maxlength } = this.data;
if (maxlength !== -1 && value.length > maxlength) {
return value.slice(0, maxlength);
}
return value;
},
onInput(event) { onInput(event) {
const { value = '' } = event.detail || {}; const { value = '' } = event.detail || {};
const formatValue = this.formatValue(value); this.value = value;
this.value = formatValue;
this.setShowClear(); this.setShowClear();
return this.emitChange(Object.assign(Object.assign({}, event.detail), { value: formatValue })); this.emitChange();
}, },
onFocus(event) { onFocus(event) {
this.focused = true; this.focused = true;
@ -83,7 +60,7 @@ VantComponent({
this.value = ''; this.value = '';
this.setShowClear(); this.setShowClear();
nextTick(() => { nextTick(() => {
this.emitChange({ value: '' }); this.emitChange();
this.$emit('clear', ''); this.$emit('clear', '');
}); });
}, },
@ -99,7 +76,7 @@ VantComponent({
if (value === '') { if (value === '') {
this.setData({ innerValue: '' }); this.setData({ innerValue: '' });
} }
this.emitChange({ value }); this.emitChange();
}, },
onLineChange(event) { onLineChange(event) {
this.$emit('linechange', event.detail); this.$emit('linechange', event.detail);
@ -107,20 +84,12 @@ VantComponent({
onKeyboardHeightChange(event) { onKeyboardHeightChange(event) {
this.$emit('keyboardheightchange', event.detail); this.$emit('keyboardheightchange', event.detail);
}, },
onBindNicknameReview(event) { emitChange() {
this.$emit('nicknamereview', event.detail); this.setData({ value: this.value });
}, nextTick(() => {
emitChange(detail) { this.$emit('input', this.value);
const { extraEventParams } = this.data; this.$emit('change', this.value);
this.setData({ value: detail.value }); });
let result;
const data = extraEventParams
? Object.assign(Object.assign({}, detail), { callback: (data) => {
result = data;
} }) : detail.value;
this.$emit('input', data);
this.$emit('change', data);
return result;
}, },
setShowClear() { setShowClear() {
const { clearable, readonly, clearTrigger } = this.data; const { clearable, readonly, clearTrigger } = this.data;
@ -131,7 +100,7 @@ VantComponent({
const trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused); const trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
showClear = hasValue && trigger; showClear = hasValue && trigger;
} }
this.setView({ showClear }); this.setData({ showClear });
}, },
noop() { }, noop() { },
}, },

14
dist/field/index.wxml vendored
View File

@ -13,12 +13,12 @@
title-style="margin-right: 12px;" title-style="margin-right: 12px;"
custom-style="{{ customStyle }}" custom-style="{{ customStyle }}"
arrow-direction="{{ arrowDirection }}" arrow-direction="{{ arrowDirection }}"
custom-class="custom-class van-field" custom-class="van-field"
> >
<slot name="left-icon" slot="icon" /> <slot name="left-icon" slot="icon" />
<label for="{{ name }}" wx:if="{{ label }}" class="label-class {{ utils.bem('field__label', { disabled }) }}" slot="title"> <view wx:if="{{ label }}" class="label-class {{ utils.bem('field__label', { disabled }) }}" slot="title">
{{ label }} {{ label }}
</label> </view>
<slot wx:else name="label" slot="title" /> <slot wx:else name="label" slot="title" />
<view class="{{ utils.bem('field__body', [type]) }}"> <view class="{{ utils.bem('field__body', [type]) }}">
<view class="{{ utils.bem('field__control', [inputAlign, 'custom']) }}" bindtap="onClickInput"> <view class="{{ utils.bem('field__control', [inputAlign, 'custom']) }}" bindtap="onClickInput">
@ -47,10 +47,10 @@
<slot name="button" /> <slot name="button" />
</view> </view>
</view> </view>
<label for="{{ name }}" wx:if="{{ showWordLimit && maxlength }}" class="van-field__word-limit"> <view wx:if="{{ showWordLimit && maxlength }}" class="van-field__word-limit">
<view class="{{ utils.bem('field__word-num', { full: value.length >= maxlength }) }}">{{ value.length >= maxlength ? maxlength : value.length }}</view>/{{ maxlength }} <view class="{{ utils.bem('field__word-num', { full: value.length >= maxlength }) }}">{{ value.length >= maxlength ? maxlength : value.length }}</view>/{{ maxlength }}
</label> </view>
<label for="{{ name }}" wx:if="{{ errorMessage }}" class="{{ utils.bem('field__error-message', [errorMessageAlign, { disabled, error }]) }}"> <view wx:if="{{ errorMessage }}" class="{{ utils.bem('field__error-message', [errorMessageAlign, { disabled, error }]) }}">
{{ errorMessage }} {{ errorMessage }}
</label> </view>
</van-cell> </van-cell>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-field{--cell-icon-size:var(--field-icon-size,16px)}.van-field__label{color:var(--field-label-color,#646566)}.van-field__label--disabled{color:var(--field-disabled-text-color,#c8c9cc)}.van-field__body{align-items:center;display:flex}.van-field__body--textarea{box-sizing:border-box;line-height:1.2em;min-height:var(--cell-line-height,24px);padding:3.6px 0}.van-field__control:empty+.van-field__control{display:block}.van-field__control{background-color:initial;border:0;box-sizing:border-box;color:var(--field-input-text-color,#323233);display:none;height:var(--cell-line-height,24px);line-height:inherit;margin:0;min-height:var(--cell-line-height,24px);padding:0;position:relative;resize:none;text-align:left;width:100%}.van-field__control:empty{display:none}.van-field__control--textarea{height:var(--field-text-area-min-height,18px);min-height:var(--field-text-area-min-height,18px)}.van-field__control--error{color:var(--field-input-error-text-color,#ee0a24)}.van-field__control--disabled{background-color:initial;color:var(--field-input-disabled-text-color,#c8c9cc);opacity:1}.van-field__control--center{text-align:center}.van-field__control--right{text-align:right}.van-field__control--custom{align-items:center;display:flex;min-height:var(--cell-line-height,24px)}.van-field__placeholder{color:var(--field-placeholder-text-color,#c8c9cc);left:0;pointer-events:none;position:absolute;right:0;top:0}.van-field__placeholder--error{color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{align-items:center;display:flex;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;margin-right:calc(var(--padding-xs, 8px)*-1);padding:0 var(--padding-xs,8px);vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{flex-shrink:0}.van-field__clear-root{color:var(--field-clear-icon-color,#c8c9cc);font-size:var(--field-clear-icon-size,16px)}.van-field__icon-container{color:var(--field-icon-container-color,#969799);font-size:var(--field-icon-size,16px)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{color:var(--field-error-message-color,#ee0a24);display:block;font-size:var(--field-error-message-text-font-size,12px);text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}.van-field__word-limit{color:var(--field-word-limit-color,#646566);font-size:var(--field-word-limit-font-size,12px);line-height:var(--field-word-limit-line-height,16px);margin-top:var(--padding-base,4px);text-align:right}.van-field__word-num{display:inline}.van-field__word-num--full{color:var(--field-word-num-full-color,#ee0a24)} @import '../common/index.wxss';.van-field{--cell-icon-size:var(--field-icon-size,16px)}.van-field__label{color:var(--field-label-color,#646566)}.van-field__label--disabled{color:var(--field-disabled-text-color,#c8c9cc)}.van-field__body{align-items:center;display:flex}.van-field__body--textarea{box-sizing:border-box;line-height:1.2em;min-height:var(--cell-line-height,24px);padding:3.6px 0}.van-field__control:empty+.van-field__control{display:block}.van-field__control{background-color:initial;border:0;box-sizing:border-box;color:var(--field-input-text-color,#323233);display:none;height:var(--cell-line-height,24px);line-height:inherit;margin:0;min-height:var(--cell-line-height,24px);padding:0;position:relative;resize:none;text-align:left;width:100%}.van-field__control:empty{display:none}.van-field__control--textarea{height:var(--field-text-area-min-height,18px);min-height:var(--field-text-area-min-height,18px)}.van-field__control--error{color:var(--field-input-error-text-color,#ee0a24)}.van-field__control--disabled{background-color:initial;color:var(--field-input-disabled-text-color,#c8c9cc);opacity:1}.van-field__control--center{text-align:center}.van-field__control--right{text-align:right}.van-field__control--custom{align-items:center;display:flex;min-height:var(--cell-line-height,24px)}.van-field__placeholder{color:var(--field-placeholder-text-color,#c8c9cc);left:0;pointer-events:none;position:absolute;right:0;top:0}.van-field__placeholder--error{color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{align-items:center;display:flex;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;margin-right:calc(var(--padding-xs, 8px)*-1);padding:0 var(--padding-xs,8px);vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{flex-shrink:0}.van-field__clear-root{color:var(--field-clear-icon-color,#c8c9cc);font-size:var(--field-clear-icon-size,16px)}.van-field__icon-container{color:var(--field-icon-container-color,#969799);font-size:var(--field-icon-size,16px)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{color:var(--field-error-message-color,#ee0a24);font-size:var(--field-error-message-text-font-size,12px);text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}.van-field__word-limit{color:var(--field-word-limit-color,#646566);font-size:var(--field-word-limit-font-size,12px);line-height:var(--field-word-limit-line-height,16px);margin-top:var(--padding-base,4px);text-align:right}.van-field__word-num{display:inline}.van-field__word-num--full{color:var(--field-word-num-full-color,#ee0a24)}

View File

@ -1,6 +1,4 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<input <input
id="{{ name }}"
class="{{ utils.bem('field__control', [inputAlign, { disabled, error }]) }} input-class" class="{{ utils.bem('field__control', [inputAlign, { disabled, error }]) }} input-class"
type="{{ type }}" type="{{ type }}"
focus="{{ focus }}" focus="{{ focus }}"
@ -27,5 +25,4 @@
bindfocus="onFocus" bindfocus="onFocus"
bindconfirm="onConfirm" bindconfirm="onConfirm"
bindkeyboardheightchange="onKeyboardHeightChange" bindkeyboardheightchange="onKeyboardHeightChange"
bindnicknamereview="onBindNicknameReview"
/> />

10
dist/field/props.js vendored
View File

@ -1,5 +1,13 @@
export const commonProps = { export const commonProps = {
value: String, value: {
type: String,
observer(value) {
if (value !== this.value) {
this.setData({ innerValue: value });
this.value = value;
}
},
},
placeholder: String, placeholder: String,
placeholderStyle: String, placeholderStyle: String,
placeholderClass: String, placeholderClass: String,

View File

@ -1,7 +1,4 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<textarea <textarea
id="{{ name }}"
class="{{ utils.bem('field__control', [inputAlign, type, { disabled, error }]) }} input-class" class="{{ utils.bem('field__control', [inputAlign, type, { disabled, error }]) }} input-class"
fixed="{{ fixed }}" fixed="{{ fixed }}"
focus="{{ focus }}" focus="{{ focus }}"

View File

@ -1,8 +0,0 @@
export interface InputDetails {
/** 输入框内容 */
value: string;
/** 光标位置 */
cursor?: number;
/** keyCode 为键值 (目前工具还不支持返回keyCode参数) `2.1.0` 起支持 */
keyCode?: number;
}

1
dist/field/types.js vendored
View File

@ -1 +0,0 @@
export {};

View File

@ -8,10 +8,6 @@ VantComponent({
props: { props: {
text: String, text: String,
color: String, color: String,
size: {
type: String,
value: 'normal',
},
loading: Boolean, loading: Boolean,
disabled: Boolean, disabled: Boolean,
plain: Boolean, plain: Boolean,
@ -19,10 +15,6 @@ VantComponent({
type: String, type: String,
value: 'danger', value: 'danger',
}, },
customStyle: {
type: String,
value: '',
},
}, },
methods: { methods: {
onClick(event) { onClick(event) {

View File

@ -1,18 +1,15 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<van-button <van-button
id="{{ id }}" id="{{ id }}"
button-id="{{ buttonId }}"
lang="{{ lang }}" lang="{{ lang }}"
type="{{ type }}" type="{{ type }}"
size="{{ size }}"
color="{{ color }}" color="{{ color }}"
plain="{{ plain }}" plain="{{ plain }}"
loading="{{ loading }}" loading="{{ loading }}"
disabled="{{ disabled }}" disabled="{{ disabled }}"
open-type="{{ openType }}" open-type="{{ openType }}"
class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain: plain }])}}" class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain: plain }])}}"
custom-class="van-goods-action-button__inner custom-class" custom-class="van-goods-action-button__inner"
custom-style="{{customStyle}}"
business-id="{{ businessId }}" business-id="{{ businessId }}"
session-from="{{ sessionFrom }}" session-from="{{ sessionFrom }}"
app-parameter="{{ appParameter }}" app-parameter="{{ appParameter }}"
@ -25,8 +22,6 @@
bindcontact="onContact" bindcontact="onContact"
bindopensetting="onOpenSetting" bindopensetting="onOpenSetting"
bindgetuserinfo="onGetUserInfo" bindgetuserinfo="onGetUserInfo"
bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
bindgetRealTimePhoneNumber="onGetRealTimePhoneNumber"
bindgetphonenumber="onGetPhoneNumber" bindgetphonenumber="onGetPhoneNumber"
bindlaunchapp="onLaunchApp" bindlaunchapp="onLaunchApp"
> >

View File

@ -2,15 +2,13 @@ import { VantComponent } from '../common/component';
import { button } from '../mixins/button'; import { button } from '../mixins/button';
import { link } from '../mixins/link'; import { link } from '../mixins/link';
VantComponent({ VantComponent({
classes: ['icon-class', 'text-class', 'info-class'], classes: ['icon-class', 'text-class'],
mixins: [link, button], mixins: [link, button],
props: { props: {
text: String, text: String,
dot: Boolean, dot: Boolean,
info: String, info: String,
icon: String, icon: String,
size: String,
color: String,
classPrefix: { classPrefix: {
type: String, type: String,
value: 'van-icon', value: 'van-icon',

View File

@ -27,15 +27,10 @@
name="{{ icon }}" name="{{ icon }}"
dot="{{ dot }}" dot="{{ dot }}"
info="{{ info }}" info="{{ info }}"
size="{{ size }}"
color="{{ color }}"
class-prefix="{{ classPrefix }}" class-prefix="{{ classPrefix }}"
class="van-goods-action-icon__icon" class="van-goods-action-icon__icon"
custom-class="icon-class" custom-class="icon-class"
info-class="info-class"
/> />
<view wx:else> <slot wx:else name="icon" />
<slot name="icon" />
</view>
<text class="text-class">{{ text }}</text> <text class="text-class">{{ text }}</text>
</van-button> </van-button>

1
dist/icon/index.js vendored
View File

@ -1,6 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
VantComponent({ VantComponent({
classes: ['info-class'],
props: { props: {
dot: Boolean, dot: Boolean,
info: null, info: null,

View File

@ -9,7 +9,7 @@
wx:if="{{ info !== null || dot }}" wx:if="{{ info !== null || dot }}"
dot="{{ dot }}" dot="{{ dot }}"
info="{{ info }}" info="{{ info }}"
custom-class="van-icon__info info-class" custom-class="van-icon__info"
/> />
<image <image
wx:if="{{ computed.isImage(name) }}" wx:if="{{ computed.isImage(name) }}"

4
dist/icon/index.wxs vendored
View File

@ -9,10 +9,6 @@ function isImage(name) {
function rootClass(data) { function rootClass(data) {
var classes = ['custom-class']; var classes = ['custom-class'];
if (data.classPrefix !== 'van-icon') {
classes.push('van-icon--custom')
}
if (data.classPrefix != null) { if (data.classPrefix != null) {
classes.push(data.classPrefix); classes.push(data.classPrefix);
} }

File diff suppressed because one or more lines are too long

4
dist/image/index.js vendored
View File

@ -25,10 +25,6 @@ VantComponent({
type: String, type: String,
value: 'fill', value: 'fill',
}, },
webp: {
type: Boolean,
value: false,
},
showError: { showError: {
type: Boolean, type: Boolean,
value: true, value: true,

View File

@ -11,7 +11,6 @@
src="{{ src }}" src="{{ src }}"
mode="{{ computed.mode(fit) }}" mode="{{ computed.mode(fit) }}"
lazy-load="{{ lazyLoad }}" lazy-load="{{ lazyLoad }}"
webp="{{ webp }}"
class="image-class van-image__img" class="image-class van-image__img"
show-menu-by-longpress="{{ showMenuByLongpress }}" show-menu-by-longpress="{{ showMenuByLongpress }}"
bind:load="onLoad" bind:load="onLoad"

15
dist/mixins/basic.js vendored
View File

@ -7,20 +7,5 @@ export const basic = Behavior({
this.setData(data); this.setData(data);
return new Promise((resolve) => wx.nextTick(resolve)); return new Promise((resolve) => wx.nextTick(resolve));
}, },
// high performance setData
setView(data, callback) {
const target = {};
let hasChange = false;
Object.keys(data).forEach((key) => {
if (data[key] !== this.data[key]) {
target[key] = data[key];
hasChange = true;
}
});
if (hasChange) {
return this.setData(target, callback);
}
return callback && callback();
},
}, },
}); });

View File

@ -3,7 +3,6 @@ export const button = Behavior({
externalClasses: ['hover-class'], externalClasses: ['hover-class'],
properties: { properties: {
id: String, id: String,
buttonId: String,
lang: String, lang: String,
businessId: Number, businessId: Number,
sessionFrom: String, sessionFrom: String,
@ -29,9 +28,6 @@ export const button = Behavior({
onGetPhoneNumber(event) { onGetPhoneNumber(event) {
this.triggerEvent('getphonenumber', event.detail); this.triggerEvent('getphonenumber', event.detail);
}, },
onGetRealTimePhoneNumber(event) {
this.triggerEvent('getrealtimephonenumber', event.detail);
},
onError(event) { onError(event) {
this.triggerEvent('error', event.detail); this.triggerEvent('error', event.detail);
}, },
@ -41,9 +37,6 @@ export const button = Behavior({
onOpenSetting(event) { onOpenSetting(event) {
this.triggerEvent('opensetting', event.detail); this.triggerEvent('opensetting', event.detail);
}, },
onAgreePrivacyAuthorization(event) {
this.triggerEvent('agreeprivacyauthorization', event.detail);
},
onChooseAvatar(event) { onChooseAvatar(event) {
this.triggerEvent('chooseavatar', event.detail); this.triggerEvent('chooseavatar', event.detail);
}, },

View File

@ -1,6 +1,6 @@
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption; declare type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
type Scroller = (this: WechatMiniprogram.Component.TrivialInstance, event?: IPageScrollOption) => void; declare type Scroller = (this: WechatMiniprogram.Component.TrivialInstance, event?: IPageScrollOption) => void;
export declare function pageScrollMixin(scroller: Scroller): string; export declare function pageScrollMixin(scroller: Scroller): string;
export {}; export {};

View File

@ -18,7 +18,7 @@ export function pageScrollMixin(scroller) {
} }
const _scroller = scroller.bind(this); const _scroller = scroller.bind(this);
const { vanPageScroller = [] } = page; const { vanPageScroller = [] } = page;
if (isFunction(page.onPageScroll) && page.onPageScroll !== onPageScroll) { if (!vanPageScroller.length && isFunction(page.onPageScroll)) {
vanPageScroller.push(page.onPageScroll.bind(page)); vanPageScroller.push(page.onPageScroll.bind(page));
} }
vanPageScroller.push(_scroller); vanPageScroller.push(_scroller);
@ -32,7 +32,7 @@ export function pageScrollMixin(scroller) {
return; return;
} }
const { vanPageScroller } = page; const { vanPageScroller } = page;
const index = vanPageScroller.findIndex((v) => v === this._scroller); const index = vanPageScroller.findIndex(v => v === this._scroller);
if (index > -1) { if (index > -1) {
page.vanPageScroller.splice(index, 1); page.vanPageScroller.splice(index, 1);
} }

View File

@ -21,6 +21,7 @@ export function transition(showDefaultValue) {
duration: { duration: {
type: null, type: null,
value: 300, value: 300,
observer: 'observeDuration',
}, },
name: { name: {
type: String, type: String,
@ -45,71 +46,56 @@ export function transition(showDefaultValue) {
value ? this.enter() : this.leave(); value ? this.enter() : this.leave();
}, },
enter() { enter() {
if (this.enterFinishedPromise) const { duration, name } = this.data;
return; const classNames = getClassNames(name);
this.enterFinishedPromise = new Promise((resolve) => { const currentDuration = isObj(duration) ? duration.enter : duration;
const { duration, name } = this.data; this.status = 'enter';
const classNames = getClassNames(name); this.$emit('before-enter');
const currentDuration = isObj(duration) ? duration.enter : duration; requestAnimationFrame(() => {
if (this.status === 'enter') { if (this.status !== 'enter') {
return; return;
} }
this.status = 'enter'; this.$emit('enter');
this.$emit('before-enter'); this.setData({
inited: true,
display: true,
classes: classNames.enter,
currentDuration,
});
requestAnimationFrame(() => { requestAnimationFrame(() => {
if (this.status !== 'enter') { if (this.status !== 'enter') {
return; return;
} }
this.$emit('enter'); this.transitionEnded = false;
this.setData({ this.setData({ classes: classNames['enter-to'] });
inited: true,
display: true,
classes: classNames.enter,
currentDuration,
});
requestAnimationFrame(() => {
if (this.status !== 'enter') {
return;
}
this.transitionEnded = false;
this.setData({ classes: classNames['enter-to'] });
resolve();
});
}); });
}); });
}, },
leave() { leave() {
if (!this.enterFinishedPromise) if (!this.data.display) {
return; return;
this.enterFinishedPromise.then(() => { }
if (!this.data.display) { const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.leave : duration;
this.status = 'leave';
this.$emit('before-leave');
requestAnimationFrame(() => {
if (this.status !== 'leave') {
return; return;
} }
const { duration, name } = this.data; this.$emit('leave');
const classNames = getClassNames(name); this.setData({
const currentDuration = isObj(duration) ? duration.leave : duration; classes: classNames.leave,
this.status = 'leave'; currentDuration,
this.$emit('before-leave'); });
requestAnimationFrame(() => { requestAnimationFrame(() => {
if (this.status !== 'leave') { if (this.status !== 'leave') {
return; return;
} }
this.$emit('leave'); this.transitionEnded = false;
this.setData({ setTimeout(() => this.onTransitionEnd(), currentDuration);
classes: classNames.leave, this.setData({ classes: classNames['leave-to'] });
currentDuration,
});
requestAnimationFrame(() => {
if (this.status !== 'leave') {
return;
}
this.transitionEnded = false;
setTimeout(() => {
this.onTransitionEnd();
this.enterFinishedPromise = null;
}, currentDuration);
this.setData({ classes: classNames['leave-to'] });
});
}); });
}); });
}, },

View File

@ -103,7 +103,7 @@ VantComponent({
}); });
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.scroll(); this.scroll();
}, this.duration + this.data.delay); }, this.duration);
}, },
onClickIcon(event) { onClickIcon(event) {
if (this.data.mode === 'closeable') { if (this.data.mode === 'closeable') {

View File

@ -15,10 +15,6 @@ VantComponent({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
rootPortal: {
type: Boolean,
value: false,
},
}, },
methods: { methods: {
onClick() { onClick() {

View File

@ -1,7 +1,21 @@
<import src="./overlay.wxml" /> <van-transition
wx:if="{{ lockScroll }}"
<root-portal wx:if="{{ rootPortal }}"> show="{{ show }}"
<include src="./overlay.wxml" /> custom-class="van-overlay custom-class"
</root-portal> custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
<include wx:else src="./overlay.wxml" /> bind:tap="onClick"
catch:touchmove="noop"
>
<slot></slot>
</van-transition>
<van-transition
wx:else
show="{{ show }}"
custom-class="van-overlay custom-class"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"
>
<slot></slot>
</van-transition>

View File

@ -1,10 +0,0 @@
<van-transition
show="{{ show }}"
custom-class="van-overlay custom-class"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"
catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
>
<slot></slot>
</van-transition>

8
dist/popup/index.js vendored
View File

@ -53,18 +53,10 @@ VantComponent({
type: Boolean, type: Boolean,
value: false, value: false,
}, },
safeAreaTabBar: {
type: Boolean,
value: false,
},
lockScroll: { lockScroll: {
type: Boolean, type: Boolean,
value: true, value: true,
}, },
rootPortal: {
type: Boolean,
value: false,
},
}, },
created() { created() {
this.observeClass(); this.observeClass();

23
dist/popup/index.wxml vendored
View File

@ -1,8 +1,6 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" /> <wxs src="./index.wxs" module="computed" />
<import src="./popup.wxml" />
<van-overlay <van-overlay
wx:if="{{ overlay }}" wx:if="{{ overlay }}"
show="{{ show }}" show="{{ show }}"
@ -11,11 +9,18 @@
duration="{{ duration }}" duration="{{ duration }}"
bind:click="onClickOverlay" bind:click="onClickOverlay"
lock-scroll="{{ lockScroll }}" lock-scroll="{{ lockScroll }}"
root-portal="{{ rootPortal }}"
/> />
<view
<root-portal wx:if="{{ rootPortal }}"> wx:if="{{ inited }}"
<include src="./popup.wxml" /> class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop }]) }}"
</root-portal> style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle }) }}"
bind:transitionend="onTransitionEnd"
<include wx:else src="./popup.wxml" /> >
<slot />
<van-icon
wx:if="{{ closeable }}"
name="{{ closeIcon }}"
class="close-icon-class van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}"
bind:tap="onClickCloseIcon"
/>
</view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-popup{-webkit-overflow-scrolling:touch;animation:ease both;background-color:var(--popup-background-color,#fff);box-sizing:border-box;max-height:100%;overflow-y:auto;position:fixed;transition-timing-function:ease}.van-popup--center{left:50%;top:50%;transform:translate3d(-50%,-50%,0)}.van-popup--center.van-popup--round{border-radius:var(--popup-round-border-radius,16px)}.van-popup--top{left:0;top:0;width:100%}.van-popup--top.van-popup--round{border-radius:0 0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px))}.van-popup--right{right:0;top:50%;transform:translate3d(0,-50%,0)}.van-popup--right.van-popup--round{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0 0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px))}.van-popup--bottom{bottom:0;left:0;width:100%}.van-popup--bottom.van-popup--round{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0 0}.van-popup--left{left:0;top:50%;transform:translate3d(0,-50%,0)}.van-popup--left.van-popup--round{border-radius:0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0}.van-popup--bottom.van-popup--safe{padding-bottom:env(safe-area-inset-bottom)}.van-popup--bottom.van-popup--safeTabBar,.van-popup--top.van-popup--safeTabBar{bottom:var(--tabbar-height,50px)}.van-popup--safeTop{padding-top:env(safe-area-inset-top)}.van-popup__close-icon{color:var(--popup-close-icon-color,#969799);font-size:var(--popup-close-icon-size,18px);position:absolute;z-index:var(--popup-close-icon-z-index,1)}.van-popup__close-icon--top-left{left:var(--popup-close-icon-margin,16px);top:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--top-right{right:var(--popup-close-icon-margin,16px);top:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-left{bottom:var(--popup-close-icon-margin,16px);left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-right{bottom:var(--popup-close-icon-margin,16px);right:var(--popup-close-icon-margin,16px)}.van-popup__close-icon:active{opacity:.6}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,transform}.van-scale-enter,.van-scale-leave-to{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:transform}.van-bottom-enter,.van-bottom-leave-to{transform:translate3d(0,100%,0)}.van-top-enter,.van-top-leave-to{transform:translate3d(0,-100%,0)}.van-left-enter,.van-left-leave-to{transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{transform:translate3d(100%,-50%,0)} @import '../common/index.wxss';.van-popup{-webkit-overflow-scrolling:touch;animation:ease both;background-color:var(--popup-background-color,#fff);box-sizing:border-box;max-height:100%;overflow-y:auto;position:fixed;transition-timing-function:ease}.van-popup--center{left:50%;top:50%;transform:translate3d(-50%,-50%,0)}.van-popup--center.van-popup--round{border-radius:var(--popup-round-border-radius,16px)}.van-popup--top{left:0;top:0;width:100%}.van-popup--top.van-popup--round{border-radius:0 0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px))}.van-popup--right{right:0;top:50%;transform:translate3d(0,-50%,0)}.van-popup--right.van-popup--round{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0 0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px))}.van-popup--bottom{bottom:0;left:0;width:100%}.van-popup--bottom.van-popup--round{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0 0}.van-popup--left{left:0;top:50%;transform:translate3d(0,-50%,0)}.van-popup--left.van-popup--round{border-radius:0 var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) var(--popup-round-border-radius,var(--popup-round-border-radius,16px)) 0}.van-popup--bottom.van-popup--safe{padding-bottom:env(safe-area-inset-bottom)}.van-popup--safeTop{padding-top:env(safe-area-inset-top)}.van-popup__close-icon{color:var(--popup-close-icon-color,#969799);font-size:var(--popup-close-icon-size,18px);position:absolute;z-index:var(--popup-close-icon-z-index,1)}.van-popup__close-icon--top-left{left:var(--popup-close-icon-margin,16px);top:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--top-right{right:var(--popup-close-icon-margin,16px);top:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-left{bottom:var(--popup-close-icon-margin,16px);left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-right{bottom:var(--popup-close-icon-margin,16px);right:var(--popup-close-icon-margin,16px)}.van-popup__close-icon:active{opacity:.6}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,transform}.van-scale-enter,.van-scale-leave-to{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:transform}.van-bottom-enter,.van-bottom-leave-to{transform:translate3d(0,100%,0)}.van-top-enter,.van-top-leave-to{transform:translate3d(0,-100%,0)}.van-left-enter,.van-left-leave-to{transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{transform:translate3d(100%,-50%,0)}

16
dist/popup/popup.wxml vendored
View File

@ -1,16 +0,0 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view
wx:if="{{ inited }}"
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle }) }}"
bind:transitionend="onTransitionEnd"
>
<slot />
<van-icon
wx:if="{{ closeable }}"
name="{{ closeIcon }}"
class="close-icon-class van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}"
bind:tap="onClickCloseIcon"
/>
</view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-rate{display:inline-flex;-webkit-user-select:none;user-select:none}.van-rate__item{padding:0 var(--rate-horizontal-padding,2px);position:relative}.van-rate__item:not(:last-child){padding-right:var(--rate-icon-gutter,4px)}.van-rate__icon{color:var(--rate-icon-void-color,#c8c9cc);display:block;font-size:var(--rate-icon-size,20px);height:100%}.van-rate__icon--half{left:var(--rate-horizontal-padding,2px);overflow:hidden;position:absolute;top:0;width:.5em}.van-rate__icon--full,.van-rate__icon--half{color:var(--rate-icon-full-color,#ee0a24)}.van-rate__icon--disabled{color:var(--rate-icon-disabled-color,#c8c9cc)} @import '../common/index.wxss';.van-rate{display:inline-flex;-webkit-user-select:none;user-select:none}.van-rate__item{padding:0 var(--rate-horizontal-padding,2px);position:relative}.van-rate__item:not(:last-child){padding-right:var(--rate-icon-gutter,4px)}.van-rate__icon{color:var(--rate-icon-void-color,#c8c9cc);display:block;font-size:var(--rate-icon-size,20px);height:1em}.van-rate__icon--half{left:var(--rate-horizontal-padding,2px);overflow:hidden;position:absolute;top:0;width:.5em}.van-rate__icon--full,.van-rate__icon--half{color:var(--rate-icon-full-color,#ee0a24)}.van-rate__icon--disabled{color:var(--rate-icon-disabled-color,#c8c9cc)}

10
dist/search/index.js vendored
View File

@ -4,10 +4,6 @@ VantComponent({
field: true, field: true,
classes: ['field-class', 'input-class', 'cancel-class'], classes: ['field-class', 'input-class', 'cancel-class'],
props: { props: {
value: {
type: String,
value: '',
},
label: String, label: String,
focus: Boolean, focus: Boolean,
error: Boolean, error: Boolean,
@ -53,10 +49,6 @@ VantComponent({
type: String, type: String,
value: 'clear', value: 'clear',
}, },
cursorSpacing: {
type: Number,
value: 0,
},
}, },
methods: { methods: {
onChange(event) { onChange(event) {
@ -68,7 +60,7 @@ VantComponent({
onCancel() { onCancel() {
/** /**
* 修复修改输入框值时输入框失焦和赋值同时触发赋值失效 * 修复修改输入框值时输入框失焦和赋值同时触发赋值失效
* https://github.com/youzan/vant-weapp/issues/1768 * https://github.com/vant-ui/vant-weapp/issues/1768
*/ */
setTimeout(() => { setTimeout(() => {
if (canIUseModel()) { if (canIUseModel()) {

View File

@ -28,7 +28,6 @@
input-class="input-class" input-class="input-class"
placeholder="{{ placeholder }}" placeholder="{{ placeholder }}"
placeholder-style="{{ placeholderStyle }}" placeholder-style="{{ placeholderStyle }}"
cursor-spacing="{{ cursorSpacing }}"
custom-style="padding: 5px 10px 5px 0; background-color: transparent;" custom-style="padding: 5px 10px 5px 0; background-color: transparent;"
bind:blur="onBlur" bind:blur="onBlur"
bind:focus="onFocus" bind:focus="onFocus"
@ -49,6 +48,6 @@
hover-stay-time="70" hover-stay-time="70"
> >
<slot wx:if="{{ useActionSlot }}" name="action" /> <slot wx:if="{{ useActionSlot }}" name="action" />
<view wx:else bind:tap="onCancel" class="van-search__action-button cancel-class">{{ actionText }}</view> <view wx:else bind:tap="onCancel" class="cancel-class">{{ actionText }}</view>
</view> </view>
</view> </view>

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-search{align-items:center;box-sizing:border-box;display:flex;padding:var(--search-padding,10px 12px)}.van-search__content{background-color:var(--search-background-color,#f7f8fa);border-radius:2px;display:flex;flex:1;padding-left:var(--padding-sm,12px)}.van-search__content--round{border-radius:999px}.van-search__label{color:var(--search-label-color,#323233);font-size:var(--search-label-font-size,14px);line-height:var(--search-input-height,34px);padding:var(--search-label-padding,0 5px)}.van-search__field{flex:1}.van-search__field__left-icon{color:var(--search-left-icon-color,#969799)}.van-search--withaction{padding-right:0}.van-search__action{color:var(--search-action-text-color,#323233);font-size:var(--search-action-font-size,14px);line-height:var(--search-input-height,34px)}.van-search__action--hover{background-color:#f2f3f5}.van-search__action-button{padding:var(--search-action-padding,0 8px)} @import '../common/index.wxss';.van-search{align-items:center;box-sizing:border-box;display:flex;padding:var(--search-padding,10px 12px)}.van-search__content{background-color:var(--search-background-color,#f7f8fa);border-radius:2px;display:flex;flex:1;padding-left:var(--padding-sm,12px)}.van-search__content--round{border-radius:999px}.van-search__label{color:var(--search-label-color,#323233);font-size:var(--search-label-font-size,14px);line-height:var(--search-input-height,34px);padding:var(--search-label-padding,0 5px)}.van-search__field{flex:1}.van-search__field__left-icon{color:var(--search-left-icon-color,#969799)}.van-search--withaction{padding-right:0}.van-search__action{color:var(--search-action-text-color,#323233);font-size:var(--search-action-font-size,14px);line-height:var(--search-input-height,34px);padding:var(--search-action-padding,0 8px)}.van-search__action--hover{background-color:#f2f3f5}

View File

@ -36,10 +36,6 @@ VantComponent({
type: null, type: null,
value: 300, value: 300,
}, },
rootPortal: {
type: Boolean,
value: false,
},
}, },
methods: { methods: {
onClickOverlay() { onClickOverlay() {

View File

@ -11,7 +11,6 @@
overlay-style="{{ overlayStyle }}" overlay-style="{{ overlayStyle }}"
close-on-click-overlay="{{ closeOnClickOverlay }}" close-on-click-overlay="{{ closeOnClickOverlay }}"
safe-area-inset-bottom="{{ safeAreaInsetBottom }}" safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
root-portal="{{ rootPortal }}"
bind:close="onClose" bind:close="onClose"
bind:click-overlay="onClickOverlay" bind:click-overlay="onClickOverlay"
> >

32
dist/slider/index.js vendored
View File

@ -1,12 +1,7 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch'; import { touch } from '../mixins/touch';
import { canIUseModel } from '../common/version'; import { canIUseModel } from '../common/version';
import { getRect, addUnit, nextTick, addNumber, clamp } from '../common/utils'; import { getRect, addUnit } from '../common/utils';
const DRAG_STATUS = {
START: 'start',
MOVING: 'moving',
END: 'end',
};
VantComponent({ VantComponent({
mixins: [touch], mixins: [touch],
props: { props: {
@ -59,16 +54,16 @@ VantComponent({
else { else {
this.startValue = this.format(this.newValue); this.startValue = this.format(this.newValue);
} }
this.dragStatus = DRAG_STATUS.START; this.dragStatus = 'start';
}, },
onTouchMove(event) { onTouchMove(event) {
if (this.data.disabled) if (this.data.disabled)
return; return;
if (this.dragStatus === DRAG_STATUS.START) { if (this.dragStatus === 'start') {
this.$emit('drag-start'); this.$emit('drag-start');
} }
this.touchMove(event); this.touchMove(event);
this.dragStatus = DRAG_STATUS.MOVING; this.dragStatus = 'draging';
getRect(this, '.van-slider').then((rect) => { getRect(this, '.van-slider').then((rect) => {
const { vertical } = this.data; const { vertical } = this.data;
const delta = vertical ? this.deltaY : this.deltaX; const delta = vertical ? this.deltaY : this.deltaX;
@ -87,12 +82,9 @@ VantComponent({
onTouchEnd() { onTouchEnd() {
if (this.data.disabled) if (this.data.disabled)
return; return;
if (this.dragStatus === DRAG_STATUS.MOVING) { if (this.dragStatus === 'draging') {
this.dragStatus = DRAG_STATUS.END; this.updateValue(this.newValue, true);
nextTick(() => { this.$emit('drag-end');
this.updateValue(this.newValue, true);
this.$emit('drag-end');
});
} }
}, },
onClick(event) { onClick(event) {
@ -174,7 +166,7 @@ VantComponent({
getOffsetWidth(current, min) { getOffsetWidth(current, min) {
const scope = this.getScope(); const scope = this.getScope();
// 避免最小值小于最小step时出现负数情况 // 避免最小值小于最小step时出现负数情况
return `${Math.max(((current - min) * 100) / scope, 0)}%`; return `${Math.max((current - min) * 100 / scope, 0)}%`;
}, },
// 计算选中条的长度百分比 // 计算选中条的长度百分比
calcMainAxis() { calcMainAxis() {
@ -196,12 +188,8 @@ VantComponent({
return '0%'; return '0%';
}, },
format(value) { format(value) {
const min = +this.data.min; const { max, min, step } = this.data;
const max = +this.data.max; return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
const step = +this.data.step;
value = clamp(value, min, max);
const diff = Math.round((value - min) / step) * step;
return addNumber(min, diff);
}, },
}, },
}); });

26
dist/stepper/index.js vendored
View File

@ -16,6 +16,7 @@ VantComponent({
props: { props: {
value: { value: {
type: null, type: null,
observer: 'observeValue',
}, },
integer: { integer: {
type: Boolean, type: Boolean,
@ -65,11 +66,6 @@ VantComponent({
data: { data: {
currentValue: '', currentValue: '',
}, },
watch: {
value() {
this.observeValue();
},
},
created() { created() {
this.setData({ this.setData({
currentValue: this.format(this.data.value), currentValue: this.format(this.data.value),
@ -77,8 +73,10 @@ VantComponent({
}, },
methods: { methods: {
observeValue() { observeValue() {
const { value } = this.data; const { value, currentValue } = this.data;
this.setData({ currentValue: this.format(value) }); if (!equal(value, currentValue)) {
this.setData({ currentValue: this.format(value) });
}
}, },
check() { check() {
const val = this.format(this.data.currentValue); const val = this.format(this.data.currentValue);
@ -87,18 +85,17 @@ VantComponent({
} }
}, },
isDisabled(type) { isDisabled(type) {
const { disabled, disablePlus, disableMinus, currentValue, max, min } = this.data; const { disabled, disablePlus, disableMinus, currentValue, max, min, } = this.data;
if (type === 'plus') { if (type === 'plus') {
return disabled || disablePlus || +currentValue >= +max; return disabled || disablePlus || currentValue >= max;
} }
return disabled || disableMinus || +currentValue <= +min; return disabled || disableMinus || currentValue <= min;
}, },
onFocus(event) { onFocus(event) {
this.$emit('focus', event.detail); this.$emit('focus', event.detail);
}, },
onBlur(event) { onBlur(event) {
const value = this.format(event.detail.value); const value = this.format(event.detail.value);
this.setData({ currentValue: value });
this.emitChange(value); this.emitChange(value);
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value })); this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value }));
}, },
@ -128,7 +125,12 @@ VantComponent({
if (value === '') { if (value === '') {
return; return;
} }
let formatted = this.format(value); let formatted = this.filter(value);
// limit max decimal length
if (isDef(this.data.decimalLength) && formatted.indexOf('.') !== -1) {
const pair = formatted.split('.');
formatted = `${pair[0]}.${pair[1].slice(0, this.data.decimalLength)}`;
}
this.emitChange(formatted); this.emitChange(formatted);
}, },
emitChange(value) { emitChange(value) {

View File

@ -16,6 +16,7 @@
<slot name="minus" /> <slot name="minus" />
</view> </view>
<input <input
always-embed="{{ false }}"
type="{{ integer ? 'number' : 'digit' }}" type="{{ integer ? 'number' : 'digit' }}"
class="input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}" class="input-class {{ utils.bem('stepper__input', { disabled: disabled || disableInput }) }}"
style="{{ computed.inputStyle({ buttonSize, inputWidth }) }}" style="{{ computed.inputStyle({ buttonSize, inputWidth }) }}"

View File

@ -20,7 +20,7 @@
wx:if="{{ item.inactiveIcon || inactiveIcon }}" wx:if="{{ item.inactiveIcon || inactiveIcon }}"
color="{{ status(index, active) === 'inactive' ? inactiveColor: activeColor }}" color="{{ status(index, active) === 'inactive' ? inactiveColor: activeColor }}"
name="{{ item.inactiveIcon || inactiveIcon }}" name="{{ item.inactiveIcon || inactiveIcon }}"
class="van-step__icon" custom-class="van-step__icon"
/> />
<view <view
wx:else wx:else
@ -29,7 +29,7 @@
/> />
</block> </block>
<van-icon wx:else name="{{ item.activeIcon || activeIcon }}" color="{{ activeColor }}" class="van-step__icon" /> <van-icon wx:else name="{{ item.activeIcon || activeIcon }}" color="{{ activeColor }}" custom-class="van-step__icon" />
</view> </view>
<view <view
wx:if="{{ index !== steps.length - 1 }}" wx:if="{{ index !== steps.length - 1 }}"

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-steps{background-color:var(--steps-background-color,#fff);overflow:hidden}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{display:flex;overflow:hidden;position:relative}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.van-step--finish{color:var(--step-finish-text-color,#323233)}.van-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;transform:none}.van-step--horizontal:last-child .van-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{background-color:#fff;bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.van-step--horizontal .van-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{background-color:var(--step-line-color,#ebedf0);bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal.van-step--process{color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical{line-height:18px;padding:10px 10px 10px 0}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{background-color:#fff;content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.van-step--vertical .van-step__icon{background-color:var(--steps-background-color,#fff);font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical .van-step__line{background-color:var(--step-line-color,#ebedf0);height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1} @import '../common/index.wxss';.van-steps{background-color:var(--steps-background-color,#fff);overflow:hidden}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{display:flex;overflow:hidden;position:relative}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{color:var(--step-text-color,#969799);flex:1;font-size:var(--step-font-size,14px);position:relative}.van-step--finish{color:var(--step-finish-text-color,#323233)}.van-step__circle{background-color:var(--step-circle-color,#969799);border-radius:50%;height:var(--step-circle-size,5px);width:var(--step-circle-size,5px)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;transform:none}.van-step--horizontal:last-child .van-step__circle-container{padding:0 0 0 8px;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{background-color:#fff;bottom:6px;padding:0 var(--padding-xs,8px);position:absolute;transform:translate3d(-50%,50%,0);z-index:1}.van-step--horizontal .van-step__title{display:inline-block;font-size:var(--step-horizontal-title-font-size,12px);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{background-color:var(--step-line-color,#ebedf0);bottom:6px;height:1px;left:0;position:absolute;right:0;transform:translate3d(0,50%,0)}.van-step--horizontal.van-step--process{color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical{line-height:18px;padding:10px 10px 10px 0}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{background-color:#fff;content:"";height:20px;left:-15px;position:absolute;top:0;width:1px;z-index:1}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{left:-14px;position:absolute;top:19px;transform:translate3d(-50%,-50%,0);z-index:2}.van-step--vertical .van-step__icon{font-size:var(--step-icon-size,12px);line-height:1}.van-step--vertical .van-step__line{background-color:var(--step-line-color,#ebedf0);height:100%;transform:translate3d(-50%,0,0);width:1px;z-index:1}

14
dist/sticky/index.js vendored
View File

@ -57,8 +57,10 @@ VantComponent({
} }
this.scrollTop = scrollTop || this.scrollTop; this.scrollTop = scrollTop || this.scrollTop;
if (typeof container === 'function') { if (typeof container === 'function') {
Promise.all([getRect(this, ROOT_ELEMENT), this.getContainerRect()]) Promise.all([
.then(([root, container]) => { getRect(this, ROOT_ELEMENT),
this.getContainerRect(),
]).then(([root, container]) => {
if (offsetTop + root.height > container.height + container.top) { if (offsetTop + root.height > container.height + container.top) {
this.setDataAfterDiff({ this.setDataAfterDiff({
fixed: false, fixed: false,
@ -75,12 +77,11 @@ VantComponent({
else { else {
this.setDataAfterDiff({ fixed: false, transform: 0 }); this.setDataAfterDiff({ fixed: false, transform: 0 });
} }
}) });
.catch(() => { });
return; return;
} }
getRect(this, ROOT_ELEMENT).then((root) => { getRect(this, ROOT_ELEMENT).then((root) => {
if (!isDef(root) || (!root.width && !root.height)) { if (!isDef(root)) {
return; return;
} }
if (offsetTop >= root.top) { if (offsetTop >= root.top) {
@ -111,9 +112,6 @@ VantComponent({
}, },
getContainerRect() { getContainerRect() {
const nodesRef = this.data.container(); const nodesRef = this.data.container();
if (!nodesRef) {
return Promise.reject(new Error('not found container'));
}
return new Promise((resolve) => nodesRef.boundingClientRect(resolve).exec()); return new Promise((resolve) => nodesRef.boundingClientRect(resolve).exec());
}, },
}, },

View File

@ -6,14 +6,6 @@ VantComponent({
name: null, name: null,
icon: String, icon: String,
dot: Boolean, dot: Boolean,
url: {
type: String,
value: '',
},
linkType: {
type: String,
value: 'redirectTo',
},
iconPrefix: { iconPrefix: {
type: String, type: String,
value: 'van-icon', value: 'van-icon',
@ -35,10 +27,6 @@ VantComponent({
parent.$emit('change', active); parent.$emit('change', active);
} }
} }
const { url, linkType } = this.data;
if (url && wx[linkType]) {
return wx[linkType]({ url });
}
this.$emit('click'); this.$emit('click');
}, },
updateFromParent() { updateFromParent() {

60
dist/tabs/index.js vendored
View File

@ -5,13 +5,7 @@ import { isDef } from '../common/validator';
import { useChildren } from '../common/relation'; import { useChildren } from '../common/relation';
VantComponent({ VantComponent({
mixins: [touch], mixins: [touch],
classes: [ classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'],
'nav-class',
'tab-class',
'tab-active-class',
'line-class',
'wrap-class',
],
relation: useChildren('tab', function () { relation: useChildren('tab', function () {
this.updateTabs(); this.updateTabs();
}), }),
@ -79,10 +73,6 @@ VantComponent({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
useBeforeChange: {
type: Boolean,
value: false,
},
}, },
data: { data: {
tabs: [], tabs: [],
@ -93,7 +83,6 @@ VantComponent({
skipTransition: true, skipTransition: true,
scrollWithAnimation: false, scrollWithAnimation: false,
lineOffsetLeft: 0, lineOffsetLeft: 0,
inited: false,
}, },
mounted() { mounted() {
requestAnimationFrame(() => { requestAnimationFrame(() => {
@ -116,25 +105,28 @@ VantComponent({
}, },
trigger(eventName, child) { trigger(eventName, child) {
const { currentIndex } = this.data; const { currentIndex } = this.data;
const data = this.getChildData(currentIndex, child); const currentChild = child || this.children[currentIndex];
if (!isDef(data)) { if (!isDef(currentChild)) {
return; return;
} }
this.$emit(eventName, data); this.$emit(eventName, {
index: currentChild.index,
name: currentChild.getComputedName(),
title: currentChild.data.title,
});
}, },
onTap(event) { onTap(event) {
const { index } = event.currentTarget.dataset; const { index } = event.currentTarget.dataset;
const child = this.children[index]; const child = this.children[index];
if (child.data.disabled) { if (child.data.disabled) {
this.trigger('disabled', child); this.trigger('disabled', child);
return;
} }
this.onBeforeChange(index).then(() => { else {
this.setCurrentIndex(index); this.setCurrentIndex(index);
nextTick(() => { nextTick(() => {
this.trigger('click'); this.trigger('click');
}); });
}); }
}, },
// correct the index of active tab // correct the index of active tab
setCurrentIndexByName(name) { setCurrentIndexByName(name) {
@ -160,9 +152,6 @@ VantComponent({
}); });
}); });
if (currentIndex === data.currentIndex) { if (currentIndex === data.currentIndex) {
if (!data.inited) {
this.resize();
}
return; return;
} }
const shouldEmitChange = data.currentIndex !== null; const shouldEmitChange = data.currentIndex !== null;
@ -202,13 +191,12 @@ VantComponent({
.reduce((prev, curr) => prev + curr.width, 0); .reduce((prev, curr) => prev + curr.width, 0);
lineOffsetLeft += lineOffsetLeft +=
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8); (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
this.setData({ lineOffsetLeft, inited: true }); this.setData({ lineOffsetLeft });
this.swiping = true; this.swiping = true;
if (skipTransition) { if (skipTransition) {
// waiting transition end nextTick(() => {
setTimeout(() => {
this.setData({ skipTransition: false }); this.setData({ skipTransition: false });
}, this.data.duration); });
} }
}); });
}, },
@ -259,7 +247,7 @@ VantComponent({
if (direction === 'horizontal' && offsetX >= minSwipeDistance) { if (direction === 'horizontal' && offsetX >= minSwipeDistance) {
const index = this.getAvaiableTab(deltaX); const index = this.getAvaiableTab(deltaX);
if (index !== -1) { if (index !== -1) {
this.onBeforeChange(index).then(() => this.setCurrentIndex(index)); this.setCurrentIndex(index);
} }
} }
this.swiping = false; this.swiping = false;
@ -278,25 +266,5 @@ VantComponent({
} }
return -1; return -1;
}, },
onBeforeChange(index) {
const { useBeforeChange } = this.data;
if (!useBeforeChange) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
this.$emit('before-change', Object.assign(Object.assign({}, this.getChildData(index)), { callback: (status) => (status ? resolve() : reject()) }));
});
},
getChildData(index, child) {
const currentChild = child || this.children[index];
if (!isDef(currentChild)) {
return;
}
return {
index: currentChild.index,
name: currentChild.getComputedName(),
title: currentChild.data.title,
};
},
}, },
}); });

View File

@ -1,7 +1,7 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" /> <wxs src="./index.wxs" module="computed" />
<view class="custom-class {{ utils.bem('tabs') }}"> <view class="custom-class {{ utils.bem('tabs', [type]) }}">
<van-sticky <van-sticky
disabled="{{ !sticky }}" disabled="{{ !sticky }}"
z-index="{{ zIndex }}" z-index="{{ zIndex }}"
@ -9,7 +9,7 @@
container="{{ container }}" container="{{ container }}"
bind:scroll="onTouchScroll" bind:scroll="onTouchScroll"
> >
<view class="{{ utils.bem('tabs--') + type }} {{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }} wrap-class"> <view class="{{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}">
<slot name="nav-left" /> <slot name="nav-left" />
<scroll-view <scroll-view
@ -20,7 +20,7 @@
style="{{ color ? 'border-color: ' + color : '' }}" style="{{ color ? 'border-color: ' + color : '' }}"
> >
<view class="{{ utils.bem('tabs__nav', [type, { complete: !ellipsis }]) }} nav-class" style="{{ computed.navStyle(color, type) }}"> <view class="{{ utils.bem('tabs__nav', [type, { complete: !ellipsis }]) }} nav-class" style="{{ computed.navStyle(color, type) }}">
<view wx:if="{{ type === 'line' }}" class="van-tabs__line" style="{{ computed.lineStyle({ color, lineOffsetLeft, lineHeight, skipTransition, duration, lineWidth, inited }) }}" /> <view wx:if="{{ type === 'line' }}" class="van-tabs__line" style="{{ computed.lineStyle({ color, lineOffsetLeft, lineHeight, skipTransition, duration, lineWidth }) }}" />
<view <view
wx:for="{{ tabs }}" wx:for="{{ tabs }}"
wx:key="index" wx:key="index"

1
dist/tabs/index.wxs vendored
View File

@ -60,7 +60,6 @@ function trackStyle(data) {
function lineStyle(data) { function lineStyle(data) {
return style({ return style({
width: utils.addUnit(data.lineWidth), width: utils.addUnit(data.lineWidth),
opacity: data.inited ? 1 : 0,
transform: 'translateX(' + data.lineOffsetLeft + 'px)', transform: 'translateX(' + data.lineOffsetLeft + 'px)',
'-webkit-transform': 'translateX(' + data.lineOffsetLeft + 'px)', '-webkit-transform': 'translateX(' + data.lineOffsetLeft + 'px)',
'background-color': data.color, 'background-color': data.color,

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-tabs{-webkit-tap-highlight-color:transparent;position:relative}.van-tabs__wrap{display:flex;overflow:hidden}.van-tabs__wrap--scrollable .van-tab{flex:0 0 22%}.van-tabs__wrap--scrollable .van-tab--complete{flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-left:8px;padding-right:8px}.van-tabs__scroll{background-color:var(--tabs-nav-background-color,#fff);overflow:auto}.van-tabs__scroll--line{box-sizing:initial;height:calc(100% + 15px)}.van-tabs__scroll--card{border:1px solid var(--tabs-default-color,#ee0a24);border-radius:2px;box-sizing:border-box;margin:0 var(--padding-md,16px);width:calc(100% - var(--padding-md, 16px)*2)}.van-tabs__scroll::-webkit-scrollbar{display:none}.van-tabs__nav{display:flex;position:relative;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:var(--tabs-card-height,30px)}.van-tabs__nav--card .van-tab{border-right:1px solid var(--tabs-default-color,#ee0a24);color:var(--tabs-default-color,#ee0a24);line-height:calc(var(--tabs-card-height, 30px) - 2px)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{background-color:var(--tabs-default-color,#ee0a24);color:#fff}.van-tabs__nav--card .van-tab--disabled{color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{background-color:var(--tabs-bottom-bar-color,#ee0a24);border-radius:var(--tabs-bottom-bar-height,3px);bottom:0;height:var(--tabs-bottom-bar-height,3px);left:0;opacity:0;position:absolute;z-index:1}.van-tabs__track{height:100%;position:relative;width:100%}.van-tabs__track--animated{display:flex;transition-property:left}.van-tabs__content{overflow:hidden}.van-tabs--line{height:var(--tabs-line-height,44px)}.van-tabs--card{height:var(--tabs-card-height,30px)}.van-tab{box-sizing:border-box;color:var(--tab-text-color,#646566);cursor:pointer;flex:1;font-size:var(--tab-font-size,14px);line-height:var(--tabs-line-height,44px);min-width:0;padding:0 5px;position:relative;text-align:center}.van-tab--active{color:var(--tab-active-text-color,#323233);font-weight:var(--font-weight-bold,500)}.van-tab--disabled{color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;transform:translateX(0)!important} @import '../common/index.wxss';.van-tabs{-webkit-tap-highlight-color:transparent;position:relative}.van-tabs__wrap{display:flex;overflow:hidden}.van-tabs__wrap--scrollable .van-tab{flex:0 0 22%}.van-tabs__wrap--scrollable .van-tab--complete{flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-left:8px;padding-right:8px}.van-tabs__scroll{background-color:var(--tabs-nav-background-color,#fff)}.van-tabs__scroll--line{box-sizing:initial;height:calc(100% + 15px)}.van-tabs__scroll--card{border:1px solid var(--tabs-default-color,#ee0a24);border-radius:2px;box-sizing:border-box;margin:0 var(--padding-md,16px);width:calc(100% - var(--padding-md, 16px)*2)}.van-tabs__scroll::-webkit-scrollbar{display:none}.van-tabs__nav{display:flex;position:relative;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:var(--tabs-card-height,30px)}.van-tabs__nav--card .van-tab{border-right:1px solid var(--tabs-default-color,#ee0a24);color:var(--tabs-default-color,#ee0a24);line-height:calc(var(--tabs-card-height, 30px) - 2px)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{background-color:var(--tabs-default-color,#ee0a24);color:#fff}.van-tabs__nav--card .van-tab--disabled{color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{background-color:var(--tabs-bottom-bar-color,#ee0a24);border-radius:var(--tabs-bottom-bar-height,3px);bottom:0;height:var(--tabs-bottom-bar-height,3px);left:0;position:absolute;z-index:1}.van-tabs__track{height:100%;position:relative;width:100%}.van-tabs__track--animated{display:flex;transition-property:left}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:var(--tabs-card-height,30px)}.van-tab{box-sizing:border-box;color:var(--tab-text-color,#646566);cursor:pointer;flex:1;font-size:var(--tab-font-size,14px);line-height:var(--tabs-line-height,44px);min-width:0;padding:0 5px;position:relative;text-align:center}.van-tab--active{color:var(--tab-active-text-color,#323233);font-weight:var(--font-weight-bold,500)}.van-tab--disabled{color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{display:inline-block;position:relative!important;top:-1px!important;transform:translateX(0)!important}

View File

@ -1,7 +1,7 @@
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" /> /// <reference types="miniprogram-api-typings" />
type ToastMessage = string | number; declare type ToastMessage = string | number;
type ToastContext = WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance; declare type ToastContext = WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance;
interface ToastOptions { interface ToastOptions {
show?: boolean; show?: boolean;
type?: string; type?: string;

View File

@ -1,9 +1,9 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { isImageFile, chooseFile, isVideoFile } from './utils';
import { chooseImageProps, chooseVideoProps } from './shared';
import { isBoolean, isPromise } from '../common/validator'; import { isBoolean, isPromise } from '../common/validator';
import { imageProps, mediaProps, messageFileProps, videoProps } from './shared';
import { chooseFile, isImageFile, isVideoFile } from './utils';
VantComponent({ VantComponent({
props: Object.assign(Object.assign(Object.assign(Object.assign({ disabled: Boolean, multiple: Boolean, uploadText: String, useBeforeRead: Boolean, afterRead: null, beforeRead: null, previewSize: { props: Object.assign(Object.assign({ disabled: Boolean, multiple: Boolean, uploadText: String, useBeforeRead: Boolean, afterRead: null, beforeRead: null, previewSize: {
type: null, type: null,
value: 80, value: 80,
}, name: { }, name: {
@ -34,16 +34,13 @@ VantComponent({
}, previewFullImage: { }, previewFullImage: {
type: Boolean, type: Boolean,
value: true, value: true,
}, videoFit: {
type: String,
value: 'contain',
}, imageFit: { }, imageFit: {
type: String, type: String,
value: 'scaleToFill', value: 'scaleToFill',
}, uploadIcon: { }, uploadIcon: {
type: String, type: String,
value: 'photograph', value: 'photograph',
} }, imageProps), videoProps), mediaProps), messageFileProps), } }, chooseImageProps), chooseVideoProps),
data: { data: {
lists: [], lists: [],
isInCount: true, isInCount: true,
@ -117,12 +114,11 @@ VantComponent({
if (!this.data.previewFullImage) if (!this.data.previewFullImage)
return; return;
const { index } = event.currentTarget.dataset; const { index } = event.currentTarget.dataset;
const { lists, showmenu } = this.data; const { lists } = this.data;
const item = lists[index]; const item = lists[index];
wx.previewImage({ wx.previewImage({
urls: lists.filter((item) => isImageFile(item)).map((item) => item.url), urls: lists.filter((item) => isImageFile(item)).map((item) => item.url),
current: item.url, current: item.url,
showmenu,
fail() { fail() {
wx.showToast({ title: '预览图片失败', icon: 'none' }); wx.showToast({ title: '预览图片失败', icon: 'none' });
}, },
@ -133,20 +129,11 @@ VantComponent({
return; return;
const { index } = event.currentTarget.dataset; const { index } = event.currentTarget.dataset;
const { lists } = this.data; const { lists } = this.data;
const sources = [];
const current = lists.reduce((sum, cur, curIndex) => {
if (!isVideoFile(cur)) {
return sum;
}
sources.push(Object.assign(Object.assign({}, cur), { type: 'video' }));
if (curIndex < index) {
sum++;
}
return sum;
}, 0);
wx.previewMedia({ wx.previewMedia({
sources, sources: lists
current, .filter((item) => isVideoFile(item))
.map((item) => (Object.assign(Object.assign({}, item), { type: 'video' }))),
current: index,
fail() { fail() {
wx.showToast({ title: '预览视频失败', icon: 'none' }); wx.showToast({ title: '预览视频失败', icon: 'none' });
}, },

View File

@ -28,8 +28,6 @@
title="{{ item.name || ('视频' + index) }}" title="{{ item.name || ('视频' + index) }}"
poster="{{ item.thumb }}" poster="{{ item.thumb }}"
autoplay="{{ item.autoplay }}" autoplay="{{ item.autoplay }}"
object-fit="{{videoFit}}"
referrer-policy="{{videoReferrerPolicy}}"
class="van-uploader__preview-image" class="van-uploader__preview-image"
style="{{ computed.sizeStyle({ previewSize }) }}" style="{{ computed.sizeStyle({ previewSize }) }}"
data-index="{{ index }}" data-index="{{ index }}"

View File

@ -1,4 +1,4 @@
export declare const imageProps: { export declare const chooseImageProps: {
sizeType: { sizeType: {
type: ArrayConstructor; type: ArrayConstructor;
value: string[]; value: string[];
@ -7,12 +7,8 @@ export declare const imageProps: {
type: ArrayConstructor; type: ArrayConstructor;
value: string[]; value: string[];
}; };
showmenu: {
type: BooleanConstructor;
value: boolean;
};
}; };
export declare const videoProps: { export declare const chooseVideoProps: {
capture: { capture: {
type: ArrayConstructor; type: ArrayConstructor;
value: string[]; value: string[];
@ -29,29 +25,4 @@ export declare const videoProps: {
type: StringConstructor; type: StringConstructor;
value: string; value: string;
}; };
referrerPolicy: {
type: StringConstructor;
value: string;
};
};
export declare const mediaProps: {
capture: {
type: ArrayConstructor;
value: string[];
};
mediaType: {
type: ArrayConstructor;
value: string[];
};
maxDuration: {
type: NumberConstructor;
value: number;
};
camera: {
type: StringConstructor;
value: string;
};
};
export declare const messageFileProps: {
extension: null;
}; };

View File

@ -1,5 +1,5 @@
// props for image // props for choose image
export const imageProps = { export const chooseImageProps = {
sizeType: { sizeType: {
type: Array, type: Array,
value: ['original', 'compressed'], value: ['original', 'compressed'],
@ -8,13 +8,9 @@ export const imageProps = {
type: Array, type: Array,
value: ['album', 'camera'], value: ['album', 'camera'],
}, },
showmenu: {
type: Boolean,
value: true,
},
}; };
// props for video // props for choose video
export const videoProps = { export const chooseVideoProps = {
capture: { capture: {
type: Array, type: Array,
value: ['album', 'camera'], value: ['album', 'camera'],
@ -31,31 +27,4 @@ export const videoProps = {
type: String, type: String,
value: 'back', value: 'back',
}, },
referrerPolicy: {
type: String,
value: 'no-referrer',
},
};
// props for media
export const mediaProps = {
capture: {
type: Array,
value: ['album', 'camera'],
},
mediaType: {
type: Array,
value: ['image', 'video', 'mix'],
},
maxDuration: {
type: Number,
value: 60,
},
camera: {
type: String,
value: 'back',
},
};
// props for file
export const messageFileProps = {
extension: null,
}; };

View File

@ -10,7 +10,7 @@ export interface File {
} }
export declare function isImageFile(item: File): boolean; export declare function isImageFile(item: File): boolean;
export declare function isVideoFile(item: File): boolean; export declare function isVideoFile(item: File): boolean;
export declare function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, mediaType, extension, }: { export declare function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, }: {
accept: any; accept: any;
multiple: any; multiple: any;
capture: any; capture: any;
@ -19,6 +19,4 @@ export declare function chooseFile({ accept, multiple, capture, compressed, maxD
sizeType: any; sizeType: any;
camera: any; camera: any;
maxCount: any; maxCount: any;
mediaType: any;
extension: any;
}): Promise<File | File[]>; }): Promise<File | File[]>;

View File

@ -1,4 +1,4 @@
import { pickExclude, isPC, isWxWork } from '../common/utils'; import { pickExclude } from '../common/utils';
import { isImageUrl, isVideoUrl } from '../common/validator'; import { isImageUrl, isVideoUrl } from '../common/validator';
export function isImageFile(item) { export function isImageFile(item) {
if (item.isImage != null) { if (item.isImage != null) {
@ -25,7 +25,7 @@ export function isVideoFile(item) {
return false; return false;
} }
function formatImage(res) { function formatImage(res) {
return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { type: 'image', url: item.tempFilePath || item.path, thumb: item.tempFilePath || item.path }))); return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { type: 'image', url: item.path, thumb: item.path })));
} }
function formatVideo(res) { function formatVideo(res) {
return [ return [
@ -33,41 +33,26 @@ function formatVideo(res) {
]; ];
} }
function formatMedia(res) { function formatMedia(res) {
return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['fileType', 'thumbTempFilePath', 'tempFilePath'])), { type: item.fileType, url: item.tempFilePath, thumb: item.fileType === 'video' ? item.thumbTempFilePath : item.tempFilePath }))); return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['fileType', 'thumbTempFilePath', 'tempFilePath'])), { type: res.type, url: item.tempFilePath, thumb: res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath })));
} }
function formatFile(res) { function formatFile(res) {
return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { url: item.path }))); return res.tempFiles.map((item) => (Object.assign(Object.assign({}, pickExclude(item, ['path'])), { url: item.path })));
} }
export function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, mediaType, extension, }) { export function chooseFile({ accept, multiple, capture, compressed, maxDuration, sizeType, camera, maxCount, }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
switch (accept) { switch (accept) {
case 'image': case 'image':
if (isPC || isWxWork) { wx.chooseImage({
wx.chooseImage({ count: multiple ? Math.min(maxCount, 9) : 1,
count: multiple ? Math.min(maxCount, 9) : 1, sourceType: capture,
sourceType: capture, sizeType,
sizeType, success: (res) => resolve(formatImage(res)),
success: (res) => resolve(formatImage(res)), fail: reject,
fail: reject, });
});
}
else {
wx.chooseMedia({
count: multiple ? Math.min(maxCount, 9) : 1,
mediaType: ['image'],
sourceType: capture,
maxDuration,
sizeType,
camera,
success: (res) => resolve(formatImage(res)),
fail: reject,
});
}
break; break;
case 'media': case 'media':
wx.chooseMedia({ wx.chooseMedia({
count: multiple ? Math.min(maxCount, 9) : 1, count: multiple ? Math.min(maxCount, 9) : 1,
mediaType,
sourceType: capture, sourceType: capture,
maxDuration, maxDuration,
sizeType, sizeType,
@ -87,7 +72,12 @@ export function chooseFile({ accept, multiple, capture, compressed, maxDuration,
}); });
break; break;
default: default:
wx.chooseMessageFile(Object.assign(Object.assign({ count: multiple ? maxCount : 1, type: accept }, (extension ? { extension } : {})), { success: (res) => resolve(formatFile(res)), fail: reject })); wx.chooseMessageFile({
count: multiple ? maxCount : 1,
type: accept,
success: (res) => resolve(formatFile(res)),
fail: reject,
});
break; break;
} }
}); });

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。 Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
目前 Vant 官方提供了 [Vue 2 版本](/vant/v2/)、[Vue 3 版本](/vant/)和[微信小程序版本](/vant-weapp/),并由社区团队维护 [React 版本](https://github.com/3lang3/react-vant)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。 目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant/v2)、[Vue 3 版本](https://vant-contrib.gitee.io/vant)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/3lang3/react-vant)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。
### 预览 ### 预览
@ -26,9 +26,9 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
### 链接 ### 链接
- [意见反馈](https://github.com/youzan/vant-weapp/issues) - [意见反馈](https://github.com/vant-ui/vant-weapp/issues)
- [设计资源](/vant/#/zh-CN/design) - [设计资源](https://vant-contrib.gitee.io/vant/#/zh-CN/design)
- [更新日志](/vant-weapp/#/changelog) - [更新日志](https://vant-contrib.gitee.io/vant-weapp/#/changelog)
- [官方示例](https://github.com/vant-ui/vant-demo) - [官方示例](https://github.com/vant-ui/vant-demo)
## 贡献 ## 贡献
@ -37,25 +37,21 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
以下是 Vant 和 Vant Weapp 的核心贡献者们: 以下是 Vant 和 Vant Weapp 的核心贡献者们:
| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | | [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) |
| :-: | :-: | :-: | :-: | :-: | :-: | | :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | | [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
| [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![JakeLaoyu](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | [![landluck](https://avatars.githubusercontent.com/u/27060081?s=80&v=4)](https://github.com/landluck/) | [![wjw-gavin](https://avatars.githubusercontent.com/u/19986739?s=80&v=4)](https://github.com/wjw-gavin/) | [![inottn](https://avatars.githubusercontent.com/u/18509404?s=80&v=4)](https://github.com/inottn/) | [![zhousg](https://avatars.githubusercontent.com/u/15833290?s=80&v=4)](https://github.com/zhousg/) |
| :-: | :-: | :-: | :-: | :-: | :-: |
| [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | [landluck](https://github.com/landluck/) | [wjw-gavin](https://github.com/wjw-gavin/) | [inottn](https://github.com/inottn/) | [zhousg](https://github.com/zhousg/) |
### 贡献者们 ### 贡献者们
感谢以下小伙伴们为 Vant Weapp 发展做出的贡献: 感谢以下小伙伴们为 Vant Weapp 发展做出的贡献:
<a href="https://github.com/youzan/vant-weapp/graphs/contributors"> <a href="https://github.com/vant-ui/vant-weapp/graphs/contributors">
<img src="https://opencollective.com/vant-weapp/contributors.svg?width=890&button=false" alt="contributors" style="width: 100%; margin: 16px 0"> <img src="https://opencollective.com/vant-weapp/contributors.svg?width=890&button=false" alt="contributors" style="width: 100%; margin: 16px 0">
</a> </a>
### 贡献代码 ### 贡献代码
使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant-weapp/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant-weapp/pulls)。 使用过程中发现任何问题都可以提 [Issue](https://github.com/vant-ui/vant-weapp/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/vant-ui/vant-weapp/pulls)。
### 开源协议 ### 开源协议

View File

@ -25,13 +25,36 @@ npm i vant-weapp -S --production
将 app.json 中的 `"style": "v2"` 去除,小程序的[新版基础组件](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#style)强行加上了许多样式,难以覆盖,不关闭将造成部分组件样式混乱。 将 app.json 中的 `"style": "v2"` 去除,小程序的[新版基础组件](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#style)强行加上了许多样式,难以覆盖,不关闭将造成部分组件样式混乱。
### 步骤三 构建 npm 包 ### 步骤三 修改 project.config.json
开发者工具创建的项目,`miniprogramRoot` 默认为 `miniprogram``package.json` 在其外部npm 构建无法正常工作。
需要手动在 `project.config.json` 内添加如下配置,使开发者工具可以正确索引到 npm 依赖的位置。
```json
{
...
"setting": {
...
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./miniprogram/"
}
]
}
}
```
注意: 由于目前新版开发者工具创建的小程序目录文件结构问题npm构建的文件目录为miniprogram_npm并且开发工具会默认在当前目录下创建miniprogram_npm的文件名所以新版本的miniprogramNpmDistDir配置为'./'即可
### 步骤四 构建 npm 包
打开微信开发者工具,点击 **工具 -> 构建 npm**,并勾选 **使用 npm 模块** 选项,构建完成后,即可引入组件。 打开微信开发者工具,点击 **工具 -> 构建 npm**,并勾选 **使用 npm 模块** 选项,构建完成后,即可引入组件。
<img style="width: 500px;" src="https://img.yzcdn.cn/public_files/2019/08/15/fa0549210055976cb63798503611ce3d.png" /> <img style="width: 500px;" src="https://img.yzcdn.cn/public_files/2019/08/15/fa0549210055976cb63798503611ce3d.png" />
### 步骤四 typescript 支持 ### 步骤 typescript 支持
如果你使用 typescript 开发小程序,还需要做如下操作,以获得顺畅的开发体验。 如果你使用 typescript 开发小程序,还需要做如下操作,以获得顺畅的开发体验。
@ -118,7 +141,7 @@ yarn add -D miniprogram-api-typings
```bash ```bash
# 将项目克隆到本地 # 将项目克隆到本地
git clone git@github.com:youzan/vant-weapp.git git clone git@github.com:vant-ui/vant-weapp.git
# 安装项目依赖 # 安装项目依赖
cd vant-weapp && npm install cd vant-weapp && npm install

Some files were not shown because too many files have changed in this diff Show More