diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 572a66fb..64ea61b7 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,3 +1,3 @@
你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。
-https://youzan.github.io/vant-issue-generater?repo=VantWeapp
+http://vant-contrib.gitee.io/vant-issue-generater?repo=VantWeapp
diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml
new file mode 100644
index 00000000..30cbac7d
--- /dev/null
+++ b/.github/workflows/sync.yml
@@ -0,0 +1,30 @@
+name: Sync to Gitee
+
+on:
+ push:
+ branches: [dev]
+
+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:youzan/vant-weapp.git'
+ # 注意替换为你的 Gitee 目标仓库地址
+ destination-repo: 'git@gitee.com:vant-contrib/vant-weapp.git'
+
+ - name: Build Gitee Pages
+ uses: yanglbme/gitee-pages-action@master
+ with:
+ # 注意替换为你的 Gitee 用户名
+ gitee-username: chenjiahan
+ # 注意在 Settings->Secrets 配置 GITEE_PASSWORD
+ gitee-password: ${{ secrets.GITEE_PASSWORD }}
+ # 注意替换为你的 Gitee 仓库
+ gitee-repo: vant-contrib/vant-weapp
diff --git a/README.md b/README.md
index ae024c9f..7b074ce1 100644
--- a/README.md
+++ b/README.md
@@ -11,19 +11,19 @@
- 🔥 文档网站
-
-
- 💡 国内镜像文档
+ 🔥 文档网站
🚀 Vue 版
+
---
-## 介绍
+### 介绍
-Vant Weapp 是移动端 Vue 组件库 [Vant](https://github.com/youzan/vant) 的小程序版本,两者基于相同的视觉规范,提供一致的 API 接口,助力开发者快速搭建小程序应用。
+Vant 是**有赞前端团队**开源的移动端组件库,于 2016 年开源,已持续维护 4 年时间。Vant 对内承载了有赞所有核心业务,对外服务十多万前端开发者,是业界主流的移动端组件库之一。
+
+目前 Vant 官方提供了 [Vue 版本](https://vant-contrib.gitee.io/vant)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),由社区团队维护 [React 版本](https://github.com/mxdi9i7/vant-react)。
## 预览
@@ -111,7 +111,7 @@ Vant Weapp 最低支持到小程序基础库 1.9.9 版本
我们正在寻找更多优秀的小伙伴,一起拓展前端技术的边界,期待你的加入!
-- 职位详情(Base: 杭州/深圳)
+- 职位详情(Base: 杭州/深圳)
- 团队博客
- 开源项目
@@ -120,7 +120,7 @@ Vant Weapp 最低支持到小程序基础库 1.9.9 版本
* [更新日志](https://github.com/youzan/vant-weapp/blob/dev/docs/markdown/changelog.md)
* [意见反馈](https://github.com/youzan/vant-weapp/issues)
* [加入我们](https://job.youzan.com)
-* [Vant: 移动端 Vue UI](https://github.com/youzan/vant)
+* [Vant Vue 版](https://github.com/youzan/vant)
## 开源协议
diff --git a/dist/area/index.js b/dist/area/index.js
index e7fc8a35..17c25b33 100644
--- a/dist/area/index.js
+++ b/dist/area/index.js
@@ -1,5 +1,6 @@
import { VantComponent } from '../common/component';
import { pickerProps } from '../picker/shared';
+import { requestAnimationFrame } from '../common/utils';
const COLUMNSPLACEHOLDERCODE = '000000';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
@@ -44,9 +45,9 @@ VantComponent({
typeToColumnsPlaceholder: {},
},
mounted() {
- setTimeout(() => {
+ requestAnimationFrame(() => {
this.setValues();
- }, 0);
+ });
},
methods: {
getPicker() {
@@ -165,27 +166,32 @@ VantComponent({
return;
}
const stack = [];
- stack.push(picker.setColumnValues(0, province, false));
- stack.push(picker.setColumnValues(1, city, false));
- if (city.length && code.slice(2, 4) === '00') {
- [{ code }] = city;
+ const indexes = [];
+ const { columnsNum } = this.data;
+ if (columnsNum >= 1) {
+ stack.push(picker.setColumnValues(0, province, false));
+ indexes.push(this.getIndex('province', code));
+ }
+ if (columnsNum >= 2) {
+ stack.push(picker.setColumnValues(1, city, false));
+ indexes.push(this.getIndex('city', code));
+ if (city.length && code.slice(2, 4) === '00') {
+ [{ code }] = city;
+ }
+ }
+ if (columnsNum === 3) {
+ stack.push(
+ picker.setColumnValues(
+ 2,
+ this.getList('county', code.slice(0, 4)),
+ false
+ )
+ );
+ indexes.push(this.getIndex('county', code));
}
- stack.push(
- picker.setColumnValues(
- 2,
- this.getList('county', code.slice(0, 4)),
- false
- )
- );
return Promise.all(stack)
.catch(() => {})
- .then(() =>
- picker.setIndexes([
- this.getIndex('province', code),
- this.getIndex('city', code),
- this.getIndex('county', code),
- ])
- )
+ .then(() => picker.setIndexes(indexes))
.catch(() => {});
},
getValues() {
diff --git a/dist/button/index.js b/dist/button/index.js
index 9571e6b9..2dd7c883 100644
--- a/dist/button/index.js
+++ b/dist/button/index.js
@@ -1,13 +1,19 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
+import { canIUseFormFieldButton } from '../common/version';
+const mixins = [button, openType];
+if (canIUseFormFieldButton()) {
+ mixins.push('wx://form-field-button');
+}
VantComponent({
- mixins: [button, openType],
+ mixins,
classes: ['hover-class', 'loading-class'],
data: {
baseStyle: '',
},
props: {
+ formType: String,
icon: String,
classPrefix: {
type: String,
diff --git a/dist/button/index.wxml b/dist/button/index.wxml
index 30abac96..ab393e8f 100644
--- a/dist/button/index.wxml
+++ b/dist/button/index.wxml
@@ -6,6 +6,7 @@
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
hover-class="van-button--active hover-class"
lang="{{ lang }}"
+ form-type="{{ formType }}"
style="{{ baseStyle }} {{ customStyle }}"
open-type="{{ disabled ? '' : openType }}"
business-id="{{ businessId }}"
diff --git a/dist/calendar/index.js b/dist/calendar/index.js
index 447fc7a1..ef2ae517 100644
--- a/dist/calendar/index.js
+++ b/dist/calendar/index.js
@@ -11,6 +11,7 @@ import {
getDayByOffset,
} from './utils';
import Toast from '../toast/toast';
+import { requestAnimationFrame } from '../common/utils';
VantComponent({
props: {
title: {
@@ -152,12 +153,12 @@ VantComponent({
];
}
if (type === 'multiple') {
- return [defaultDate || minDate];
+ return defaultDate || [minDate];
}
return defaultDate || minDate;
},
scrollIntoView() {
- setTimeout(() => {
+ requestAnimationFrame(() => {
const {
currentDate,
type,
@@ -179,7 +180,7 @@ VantComponent({
}
return false;
});
- }, 100);
+ });
},
onOpen() {
this.$emit('open');
@@ -276,7 +277,10 @@ VantComponent({
return true;
},
onConfirm() {
- if (this.data.type === 'range' && !this.checkRange()) {
+ if (
+ this.data.type === 'range' &&
+ !this.checkRange(this.data.currentDate)
+ ) {
return;
}
wx.nextTick(() => {
diff --git a/dist/calendar/index.json b/dist/calendar/index.json
index 61dec086..397d5aea 100644
--- a/dist/calendar/index.json
+++ b/dist/calendar/index.json
@@ -4,6 +4,7 @@
"header": "./components/header/index",
"month": "./components/month/index",
"van-button": "../button/index",
- "van-popup": "../popup/index"
+ "van-popup": "../popup/index",
+ "van-toast": "../toast/index"
}
}
diff --git a/dist/cell/index.js b/dist/cell/index.js
index b55b75c2..a0123d1d 100644
--- a/dist/cell/index.js
+++ b/dist/cell/index.js
@@ -27,6 +27,7 @@ VantComponent({
type: Boolean,
value: true,
},
+ titleStyle: String,
},
methods: {
onClick(event) {
diff --git a/dist/cell/index.wxml b/dist/cell/index.wxml
index afaaaf86..fed768e2 100644
--- a/dist/cell/index.wxml
+++ b/dist/cell/index.wxml
@@ -16,7 +16,7 @@
{{ title }}
diff --git a/dist/cell/index.wxss b/dist/cell/index.wxss
index 7afd1c4f..69b245d6 100644
--- a/dist/cell/index.wxss
+++ b/dist/cell/index.wxss
@@ -1 +1 @@
-@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:auto;right:0;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}
\ No newline at end of file
+@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;content:" ";pointer-events:none;right:16px;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)}
\ No newline at end of file
diff --git a/dist/circle/canvas.d.ts b/dist/circle/canvas.d.ts
new file mode 100644
index 00000000..2ba9531d
--- /dev/null
+++ b/dist/circle/canvas.d.ts
@@ -0,0 +1,6 @@
+///
+declare type CanvasContext = WechatMiniprogram.CanvasContext;
+export declare function adaptor(
+ ctx: CanvasRenderingContext2D
+): CanvasContext & CanvasRenderingContext2D;
+export {};
diff --git a/dist/circle/canvas.js b/dist/circle/canvas.js
new file mode 100644
index 00000000..c311335e
--- /dev/null
+++ b/dist/circle/canvas.js
@@ -0,0 +1,43 @@
+export function adaptor(ctx) {
+ // @ts-ignore
+ return Object.assign(ctx, {
+ setStrokeStyle(val) {
+ ctx.strokeStyle = val;
+ },
+ setLineWidth(val) {
+ ctx.lineWidth = val;
+ },
+ setLineCap(val) {
+ ctx.lineCap = val;
+ },
+ setFillStyle(val) {
+ ctx.fillStyle = val;
+ },
+ setFontSize(val) {
+ ctx.font = String(val);
+ },
+ setGlobalAlpha(val) {
+ ctx.globalAlpha = val;
+ },
+ setLineJoin(val) {
+ ctx.lineJoin = val;
+ },
+ setTextAlign(val) {
+ ctx.textAlign = val;
+ },
+ setMiterLimit(val) {
+ ctx.miterLimit = val;
+ },
+ setShadow(offsetX, offsetY, blur, color) {
+ ctx.shadowOffsetX = offsetX;
+ ctx.shadowOffsetY = offsetY;
+ ctx.shadowBlur = blur;
+ ctx.shadowColor = color;
+ },
+ setTextBaseline(val) {
+ ctx.textBaseline = val;
+ },
+ createCircularGradient() {},
+ draw() {},
+ });
+}
diff --git a/dist/circle/index.js b/dist/circle/index.js
index 6f04c71e..3feaa5c8 100644
--- a/dist/circle/index.js
+++ b/dist/circle/index.js
@@ -1,6 +1,7 @@
import { VantComponent } from '../common/component';
import { isObj } from '../common/utils';
import { BLUE, WHITE } from '../common/color';
+import { adaptor } from './canvas';
function format(rate) {
return Math.min(Math.max(rate, 0), 100);
}
@@ -26,6 +27,9 @@ VantComponent({
size: {
type: Number,
value: 100,
+ observer() {
+ this.drawCircle(this.currentValue);
+ },
},
fill: String,
layerColor: {
@@ -35,7 +39,11 @@ VantComponent({
color: {
type: [String, Object],
value: BLUE,
- observer: 'setHoverColor',
+ observer() {
+ this.setHoverColor().then(() => {
+ this.drawCircle(this.currentValue);
+ });
+ },
},
type: {
type: String,
@@ -55,25 +63,45 @@ VantComponent({
},
methods: {
getContext() {
- if (!this.ctx) {
- this.ctx = wx.createCanvasContext('van-circle', this);
+ const { type, size } = this.data;
+ if (type === '') {
+ const ctx = wx.createCanvasContext('van-circle', this);
+ return Promise.resolve(ctx);
}
- return this.ctx;
+ const dpr = wx.getSystemInfoSync().pixelRatio;
+ return new Promise((resolve) => {
+ wx.createSelectorQuery()
+ .in(this)
+ .select('#van-circle')
+ .node()
+ .exec((res) => {
+ const canvas = res[0].node;
+ const ctx = canvas.getContext(type);
+ if (!this.inited) {
+ this.inited = true;
+ canvas.width = size * dpr;
+ canvas.height = size * dpr;
+ ctx.scale(dpr, dpr);
+ }
+ resolve(adaptor(ctx));
+ });
+ });
},
setHoverColor() {
- const { color, size, type } = this.data;
- const context = type ? this.getContext(type) : this.getContext();
- let hoverColor = color;
+ const { color, size } = this.data;
if (isObj(color)) {
- const LinearColor = context.createLinearGradient(size, 0, 0, 0);
- Object.keys(color)
- .sort((a, b) => parseFloat(a) - parseFloat(b))
- .map((key) =>
- LinearColor.addColorStop(parseFloat(key) / 100, color[key])
- );
- hoverColor = LinearColor;
+ return this.getContext().then((context) => {
+ const LinearColor = context.createLinearGradient(size, 0, 0, 0);
+ Object.keys(color)
+ .sort((a, b) => parseFloat(a) - parseFloat(b))
+ .map((key) =>
+ LinearColor.addColorStop(parseFloat(key) / 100, color[key])
+ );
+ this.hoverColor = LinearColor;
+ });
}
- this.setData({ hoverColor });
+ this.hoverColor = color;
+ return Promise.resolve();
},
presetCanvas(context, strokeStyle, beginAngle, endAngle, fill) {
const { strokeWidth, lineCap, clockwise, size } = this.data;
@@ -95,24 +123,25 @@ VantComponent({
this.presetCanvas(context, layerColor, 0, PERIMETER, fill);
},
renderHoverCircle(context, formatValue) {
- const { clockwise, hoverColor } = this.data;
+ const { clockwise } = this.data;
// 结束角度
const progress = PERIMETER * (formatValue / 100);
const endAngle = clockwise
? BEGIN_ANGLE + progress
: 3 * Math.PI - (BEGIN_ANGLE + progress);
- this.presetCanvas(context, hoverColor, BEGIN_ANGLE, endAngle);
+ this.presetCanvas(context, this.hoverColor, BEGIN_ANGLE, endAngle);
},
drawCircle(currentValue) {
- const { size, type } = this.data;
- const context = type ? this.getContext(type) : this.getContext();
- context.clearRect(0, 0, size, size);
- this.renderLayerCircle(context);
- const formatValue = format(currentValue);
- if (formatValue !== 0) {
- this.renderHoverCircle(context, formatValue);
- }
- context.draw();
+ const { size } = this.data;
+ this.getContext().then((context) => {
+ context.clearRect(0, 0, size, size);
+ this.renderLayerCircle(context);
+ const formatValue = format(currentValue);
+ if (formatValue !== 0) {
+ this.renderHoverCircle(context, formatValue);
+ }
+ context.draw();
+ });
},
reRender() {
// tofector 动画暂时没有想到好的解决方案
@@ -143,13 +172,13 @@ VantComponent({
}
},
},
- created() {
- const { value } = this.data;
- this.currentValue = value;
- this.drawCircle(value);
+ mounted() {
+ this.currentValue = this.data.value;
+ this.setHoverColor().then(() => {
+ this.drawCircle(this.currentValue);
+ });
},
destroyed() {
- this.ctx = null;
this.clearInterval();
},
});
diff --git a/dist/circle/index.wxml b/dist/circle/index.wxml
index 607fc9d5..52bc59fc 100644
--- a/dist/circle/index.wxml
+++ b/dist/circle/index.wxml
@@ -1,9 +1,9 @@
-
+
{{ text }}
-
\ No newline at end of file
+
diff --git a/dist/collapse-item/index.js b/dist/collapse-item/index.js
index ed260930..aec309e5 100644
--- a/dist/collapse-item/index.js
+++ b/dist/collapse-item/index.js
@@ -1,5 +1,4 @@
import { VantComponent } from '../common/component';
-const nextTick = () => new Promise((resolve) => setTimeout(resolve, 20));
VantComponent({
classes: ['title-class', 'content-class'],
relation: {
@@ -25,20 +24,17 @@ VantComponent({
},
},
data: {
- contentHeight: 0,
expanded: false,
- transition: false,
+ },
+ created() {
+ this.animation = wx.createAnimation({
+ duration: 0,
+ timingFunction: 'ease-in-out',
+ });
},
mounted() {
- this.updateExpanded()
- .then(nextTick)
- .then(() => {
- const data = { transition: true };
- if (this.data.expanded) {
- data.contentHeight = 'auto';
- }
- this.setData(data);
- });
+ this.updateExpanded();
+ this.inited = true;
},
methods: {
updateExpanded() {
@@ -53,25 +49,41 @@ VantComponent({
const expanded = accordion
? value === currentName
: (value || []).some((name) => name === currentName);
- const stack = [];
if (expanded !== this.data.expanded) {
- stack.push(this.updateStyle(expanded));
+ this.updateStyle(expanded);
}
- stack.push(this.set({ index, expanded }));
- return Promise.all(stack);
+ this.setData({ index, expanded });
},
updateStyle(expanded) {
- return this.getRect('.van-collapse-item__content')
+ const { inited } = this;
+ this.getRect('.van-collapse-item__content')
.then((rect) => rect.height)
.then((height) => {
+ const { animation } = this;
if (expanded) {
- return this.set({
- contentHeight: height ? `${height}px` : 'auto',
+ if (height === 0) {
+ animation.height('auto').top(1).step();
+ } else {
+ animation
+ .height(height)
+ .top(1)
+ .step({
+ duration: inited ? 300 : 1,
+ })
+ .height('auto')
+ .step();
+ }
+ this.setData({
+ animation: animation.export(),
});
+ return;
}
- return this.set({ contentHeight: `${height}px` })
- .then(nextTick)
- .then(() => this.set({ contentHeight: 0 }));
+ animation.height(height).top(0).step({ duration: 1 }).height(0).step({
+ duration: 300,
+ });
+ this.setData({
+ animation: animation.export(),
+ });
});
},
onClick() {
@@ -83,12 +95,5 @@ VantComponent({
const currentName = name == null ? index : name;
this.parent.switch(currentName, !expanded);
},
- onTransitionEnd() {
- if (this.data.expanded) {
- this.setData({
- contentHeight: 'auto',
- });
- }
- },
},
});
diff --git a/dist/collapse-item/index.wxml b/dist/collapse-item/index.wxml
index 91afbc2d..ae4cc831 100644
--- a/dist/collapse-item/index.wxml
+++ b/dist/collapse-item/index.wxml
@@ -31,9 +31,9 @@
/>
{
- fn();
- }, 1000 / 30);
+ setTimeout(() => {
+ fn();
+ }, 1000 / 30);
}
let systemInfo = null;
export function getSystemInfoSync() {
- if (systemInfo == null) {
- systemInfo = wx.getSystemInfoSync();
- }
- return systemInfo;
+ if (systemInfo == null) {
+ systemInfo = wx.getSystemInfoSync();
+ }
+ return systemInfo;
}
export function addUnit(value) {
- if (!isDef(value)) {
- return undefined;
- }
- value = String(value);
- return isNumber(value) ? `${value}px` : value;
+ if (!isDef(value)) {
+ return undefined;
+ }
+ value = String(value);
+ return isNumber(value) ? `${value}px` : value;
+}
+export function requestAnimationFrame(cb) {
+ const systemInfo = getSystemInfoSync();
+ if (systemInfo.platform === 'devtools') {
+ return nextTick(cb);
+ }
+ return wx
+ .createSelectorQuery()
+ .selectViewport()
+ .boundingClientRect()
+ .exec(() => {
+ cb();
+ });
}
diff --git a/dist/common/version.d.ts b/dist/common/version.d.ts
index f69a9f61..d4c6fe24 100644
--- a/dist/common/version.d.ts
+++ b/dist/common/version.d.ts
@@ -1 +1,2 @@
export declare function canIUseModel(): boolean;
+export declare function canIUseFormFieldButton(): boolean;
diff --git a/dist/common/version.js b/dist/common/version.js
index a4f69619..01f24f88 100644
--- a/dist/common/version.js
+++ b/dist/common/version.js
@@ -25,3 +25,7 @@ export function canIUseModel() {
const system = getSystemInfoSync();
return compareVersion(system.SDKVersion, '2.9.3') >= 0;
}
+export function canIUseFormFieldButton() {
+ const system = getSystemInfoSync();
+ return compareVersion(system.SDKVersion, '2.10.3') >= 0;
+}
diff --git a/dist/datetime-picker/index.js b/dist/datetime-picker/index.js
index 3ff8e39e..ef9394d9 100644
--- a/dist/datetime-picker/index.js
+++ b/dist/datetime-picker/index.js
@@ -89,7 +89,7 @@ VantComponent({
methods: {
updateValue() {
const { data } = this;
- const val = this.correctValue(this.data.value);
+ const val = this.correctValue(data.value);
const isEqual = val === data.innerValue;
if (!isEqual) {
this.updateColumnValue(val).then(() => {
@@ -251,12 +251,16 @@ VantComponent({
const { data } = this;
let value;
const picker = this.getPicker();
+ const originColumns = this.getOriginColumns();
if (data.type === 'time') {
const indexes = picker.getIndexes();
- value = `${+data.columns[0].values[indexes[0]]}:${+data.columns[1]
+ value = `${+originColumns[0].values[indexes[0]]}:${+originColumns[1]
.values[indexes[1]]}`;
} else {
- const values = picker.getValues();
+ const indexes = picker.getIndexes();
+ const values = indexes.map(
+ (value, index) => originColumns[index].values[value]
+ );
const year = getTrueValue(values[0]);
const month = getTrueValue(values[1]);
const maxDate = getMonthEndDay(year, month);
@@ -281,7 +285,8 @@ VantComponent({
},
updateColumnValue(value) {
let values = [];
- const { type, formatter = defaultFormatter } = this.data;
+ const { type } = this.data;
+ const formatter = this.data.formatter || defaultFormatter;
const picker = this.getPicker();
if (type === 'time') {
const pair = value.split(':');
diff --git a/dist/dialog/dialog.d.ts b/dist/dialog/dialog.d.ts
index 66769a6d..2bffd13e 100644
--- a/dist/dialog/dialog.d.ts
+++ b/dist/dialog/dialog.d.ts
@@ -1,47 +1,50 @@
///
declare type DialogAction = 'confirm' | 'cancel';
declare type DialogOptions = {
- lang?: string;
- show?: boolean;
- title?: string;
- width?: string | number;
- zIndex?: number;
- context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
- message?: string;
- overlay?: boolean;
- selector?: string;
- ariaLabel?: string;
- className?: string;
- customStyle?: string;
- transition?: string;
- asyncClose?: boolean;
- businessId?: number;
- sessionFrom?: string;
- overlayStyle?: string;
- appParameter?: string;
- messageAlign?: string;
- sendMessageImg?: string;
- showMessageCard?: boolean;
- sendMessagePath?: string;
- sendMessageTitle?: string;
- confirmButtonText?: string;
- cancelButtonText?: string;
- showConfirmButton?: boolean;
- showCancelButton?: boolean;
- closeOnClickOverlay?: boolean;
- confirmButtonOpenType?: string;
+ lang?: string;
+ show?: boolean;
+ title?: string;
+ width?: string | number;
+ zIndex?: number;
+ theme?: string;
+ context?:
+ | WechatMiniprogram.Page.TrivialInstance
+ | WechatMiniprogram.Component.TrivialInstance;
+ message?: string;
+ overlay?: boolean;
+ selector?: string;
+ ariaLabel?: string;
+ className?: string;
+ customStyle?: string;
+ transition?: string;
+ asyncClose?: boolean;
+ businessId?: number;
+ sessionFrom?: string;
+ overlayStyle?: string;
+ appParameter?: string;
+ messageAlign?: string;
+ sendMessageImg?: string;
+ showMessageCard?: boolean;
+ sendMessagePath?: string;
+ sendMessageTitle?: string;
+ confirmButtonText?: string;
+ cancelButtonText?: string;
+ showConfirmButton?: boolean;
+ showCancelButton?: boolean;
+ closeOnClickOverlay?: boolean;
+ confirmButtonOpenType?: string;
};
interface Dialog {
- (options: DialogOptions): Promise;
- alert?: (options: DialogOptions) => Promise;
- confirm?: (options: DialogOptions) => Promise;
- close?: () => void;
- stopLoading?: () => void;
- install?: () => void;
- setDefaultOptions?: (options: DialogOptions) => void;
- resetDefaultOptions?: () => void;
- defaultOptions?: DialogOptions;
- currentOptions?: DialogOptions;
+ (options: DialogOptions): Promise;
+ alert?: (options: DialogOptions) => Promise;
+ confirm?: (options: DialogOptions) => Promise;
+ close?: () => void;
+ stopLoading?: () => void;
+ install?: () => void;
+ setDefaultOptions?: (options: DialogOptions) => void;
+ resetDefaultOptions?: () => void;
+ defaultOptions?: DialogOptions;
+ currentOptions?: DialogOptions;
}
declare const Dialog: Dialog;
export default Dialog;
diff --git a/dist/dialog/dialog.js b/dist/dialog/dialog.js
index a69fe74f..9ba35ce9 100644
--- a/dist/dialog/dialog.js
+++ b/dist/dialog/dialog.js
@@ -14,6 +14,9 @@ const Dialog = (options) => {
dialog.setData(
Object.assign({ onCancel: reject, onConfirm: resolve }, options)
);
+ wx.nextTick(() => {
+ dialog.setData({ show: true });
+ });
queue.push(dialog);
} else {
console.warn(
@@ -23,9 +26,10 @@ const Dialog = (options) => {
});
};
Dialog.defaultOptions = {
- show: true,
+ show: false,
title: '',
width: null,
+ theme: 'default',
message: '',
zIndex: 100,
overlay: true,
diff --git a/dist/dialog/index.js b/dist/dialog/index.js
index 3222d387..5aa7f8f4 100644
--- a/dist/dialog/index.js
+++ b/dist/dialog/index.js
@@ -1,7 +1,7 @@
import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
-import { GRAY, BLUE } from '../common/color';
+import { GRAY, RED } from '../common/color';
VantComponent({
mixins: [button, openType],
props: {
@@ -13,6 +13,10 @@ VantComponent({
},
title: String,
message: String,
+ theme: {
+ type: String,
+ value: 'default',
+ },
useSlot: Boolean,
className: String,
customStyle: String,
@@ -38,7 +42,7 @@ VantComponent({
},
confirmButtonColor: {
type: String,
- value: BLUE,
+ value: RED,
},
cancelButtonColor: {
type: String,
diff --git a/dist/dialog/index.json b/dist/dialog/index.json
index e2ee09ae..1b87cc89 100644
--- a/dist/dialog/index.json
+++ b/dist/dialog/index.json
@@ -2,6 +2,8 @@
"component": true,
"usingComponents": {
"van-popup": "../popup/index",
- "van-button": "../button/index"
+ "van-button": "../button/index",
+ "van-goods-action": "../goods-action//index",
+ "van-goods-action-button": "../goods-action-button/index"
}
}
diff --git a/dist/dialog/index.wxml b/dist/dialog/index.wxml
index cbad7f6f..fd13bc9a 100644
--- a/dist/dialog/index.wxml
+++ b/dist/dialog/index.wxml
@@ -5,7 +5,7 @@
z-index="{{ zIndex }}"
overlay="{{ overlay }}"
transition="{{ transition }}"
- custom-class="van-dialog {{ className }}"
+ custom-class="van-dialog van-dialog--{{ theme }} {{ className }}"
custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}"
overlay-style="{{ overlayStyle }}"
close-on-click-overlay="{{ closeOnClickOverlay }}"
@@ -13,7 +13,7 @@
>