roose 5 年 前
コミット
34cd8fff72
100 ファイル変更2087 行追加1935 行削除
  1. 4 3
      app.json
  2. 57 38
      miniprogram_npm/vant-weapp/action-sheet/index.js
  3. 20 4
      miniprogram_npm/vant-weapp/action-sheet/index.wxml
  4. 1 1
      miniprogram_npm/vant-weapp/action-sheet/index.wxss
  5. 216 204
      miniprogram_npm/vant-weapp/area/index.js
  6. 0 1
      miniprogram_npm/vant-weapp/badge-group/index.d.ts
  7. 0 43
      miniprogram_npm/vant-weapp/badge-group/index.js
  8. 0 3
      miniprogram_npm/vant-weapp/badge-group/index.json
  9. 0 3
      miniprogram_npm/vant-weapp/badge-group/index.wxml
  10. 0 1
      miniprogram_npm/vant-weapp/badge-group/index.wxss
  11. 0 1
      miniprogram_npm/vant-weapp/badge/index.d.ts
  12. 0 30
      miniprogram_npm/vant-weapp/badge/index.js
  13. 0 6
      miniprogram_npm/vant-weapp/badge/index.json
  14. 0 17
      miniprogram_npm/vant-weapp/badge/index.wxml
  15. 0 1
      miniprogram_npm/vant-weapp/badge/index.wxss
  16. 72 31
      miniprogram_npm/vant-weapp/button/index.js
  17. 25 8
      miniprogram_npm/vant-weapp/button/index.wxml
  18. 1 1
      miniprogram_npm/vant-weapp/button/index.wxss
  19. 44 33
      miniprogram_npm/vant-weapp/card/index.js
  20. 12 7
      miniprogram_npm/vant-weapp/card/index.wxml
  21. 1 1
      miniprogram_npm/vant-weapp/card/index.wxss
  22. 7 7
      miniprogram_npm/vant-weapp/cell-group/index.js
  23. 1 1
      miniprogram_npm/vant-weapp/cell-group/index.json
  24. 1 1
      miniprogram_npm/vant-weapp/cell-group/index.wxss
  25. 32 32
      miniprogram_npm/vant-weapp/cell/index.js
  26. 1 1
      miniprogram_npm/vant-weapp/cell/index.json
  27. 1 1
      miniprogram_npm/vant-weapp/cell/index.wxss
  28. 30 34
      miniprogram_npm/vant-weapp/checkbox-group/index.js
  29. 66 66
      miniprogram_npm/vant-weapp/checkbox/index.js
  30. 6 4
      miniprogram_npm/vant-weapp/checkbox/index.wxml
  31. 1 1
      miniprogram_npm/vant-weapp/checkbox/index.wxss
  32. 22 19
      miniprogram_npm/vant-weapp/col/index.js
  33. 1 1
      miniprogram_npm/vant-weapp/col/index.wxml
  34. 85 87
      miniprogram_npm/vant-weapp/collapse-item/index.js
  35. 1 1
      miniprogram_npm/vant-weapp/collapse-item/index.wxss
  36. 41 44
      miniprogram_npm/vant-weapp/collapse/index.js
  37. 4 1
      miniprogram_npm/vant-weapp/common/color.d.ts
  38. 4 1
      miniprogram_npm/vant-weapp/common/color.js
  39. 1 1
      miniprogram_npm/vant-weapp/common/component.d.ts
  40. 94 41
      miniprogram_npm/vant-weapp/common/component.js
  41. 1 1
      miniprogram_npm/vant-weapp/common/index.wxss
  42. 1 1
      miniprogram_npm/vant-weapp/common/style/clearfix.wxss
  43. 1 1
      miniprogram_npm/vant-weapp/common/style/ellipsis.wxss
  44. 1 1
      miniprogram_npm/vant-weapp/common/style/hairline.wxss
  45. 2 1
      miniprogram_npm/vant-weapp/common/utils.d.ts
  46. 8 1
      miniprogram_npm/vant-weapp/common/utils.js
  47. 288 258
      miniprogram_npm/vant-weapp/datetime-picker/index.js
  48. 5 8
      miniprogram_npm/vant-weapp/definitions/index.d.ts
  49. 8 13
      miniprogram_npm/vant-weapp/definitions/weapp.d.ts
  50. 2 0
      miniprogram_npm/vant-weapp/dialog/dialog.d.ts
  51. 51 45
      miniprogram_npm/vant-weapp/dialog/dialog.js
  52. 104 90
      miniprogram_npm/vant-weapp/dialog/index.js
  53. 11 5
      miniprogram_npm/vant-weapp/dialog/index.wxml
  54. 1 1
      miniprogram_npm/vant-weapp/dialog/index.wxss
  55. 32 34
      miniprogram_npm/vant-weapp/divider/index.js
  56. 1 1
      miniprogram_npm/vant-weapp/divider/index.json
  57. 120 100
      miniprogram_npm/vant-weapp/field/index.js
  58. 1 1
      miniprogram_npm/vant-weapp/field/index.json
  59. 32 17
      miniprogram_npm/vant-weapp/field/index.wxml
  60. 1 1
      miniprogram_npm/vant-weapp/field/index.wxss
  61. 34 15
      miniprogram_npm/vant-weapp/goods-action-button/index.js
  62. 6 3
      miniprogram_npm/vant-weapp/goods-action-button/index.wxml
  63. 1 1
      miniprogram_npm/vant-weapp/goods-action-button/index.wxss
  64. 15 14
      miniprogram_npm/vant-weapp/goods-action-icon/index.js
  65. 4 1
      miniprogram_npm/vant-weapp/goods-action-icon/index.wxml
  66. 1 1
      miniprogram_npm/vant-weapp/goods-action-icon/index.wxss
  67. 29 2
      miniprogram_npm/vant-weapp/goods-action/index.js
  68. 1 1
      miniprogram_npm/vant-weapp/goods-action/index.wxml
  69. 1 1
      miniprogram_npm/vant-weapp/goods-action/index.wxss
  70. 23 15
      miniprogram_npm/vant-weapp/icon/index.js
  71. 5 4
      miniprogram_npm/vant-weapp/icon/index.wxml
  72. 1 1
      miniprogram_npm/vant-weapp/icon/index.wxss
  73. 5 4
      miniprogram_npm/vant-weapp/info/index.js
  74. 5 3
      miniprogram_npm/vant-weapp/info/index.wxml
  75. 1 1
      miniprogram_npm/vant-weapp/info/index.wxss
  76. 13 14
      miniprogram_npm/vant-weapp/loading/index.js
  77. 1 1
      miniprogram_npm/vant-weapp/loading/index.json
  78. 8 6
      miniprogram_npm/vant-weapp/loading/index.wxml
  79. 1 1
      miniprogram_npm/vant-weapp/loading/index.wxss
  80. 25 20
      miniprogram_npm/vant-weapp/mixins/basic.js
  81. 13 16
      miniprogram_npm/vant-weapp/mixins/button.js
  82. 14 14
      miniprogram_npm/vant-weapp/mixins/link.js
  83. 0 1
      miniprogram_npm/vant-weapp/mixins/observer/behavior.d.ts
  84. 0 47
      miniprogram_npm/vant-weapp/mixins/observer/behavior.js
  85. 0 1
      miniprogram_npm/vant-weapp/mixins/observer/index.d.ts
  86. 0 27
      miniprogram_npm/vant-weapp/mixins/observer/index.js
  87. 0 1
      miniprogram_npm/vant-weapp/mixins/observer/props.d.ts
  88. 0 22
      miniprogram_npm/vant-weapp/mixins/observer/props.js
  89. 22 22
      miniprogram_npm/vant-weapp/mixins/open-type.js
  90. 0 4
      miniprogram_npm/vant-weapp/mixins/safe-area.d.ts
  91. 0 39
      miniprogram_npm/vant-weapp/mixins/safe-area.js
  92. 34 25
      miniprogram_npm/vant-weapp/mixins/touch.js
  93. 1 1
      miniprogram_npm/vant-weapp/mixins/transition.d.ts
  94. 112 105
      miniprogram_npm/vant-weapp/mixins/transition.js
  95. 65 26
      miniprogram_npm/vant-weapp/nav-bar/index.js
  96. 3 1
      miniprogram_npm/vant-weapp/nav-bar/index.wxml
  97. 1 1
      miniprogram_npm/vant-weapp/nav-bar/index.wxss
  98. 118 111
      miniprogram_npm/vant-weapp/notice-bar/index.js
  99. 1 1
      miniprogram_npm/vant-weapp/notice-bar/index.json
  100. 0 0
      miniprogram_npm/vant-weapp/notice-bar/index.wxml

+ 4 - 3
app.json

@@ -1,8 +1,8 @@
 {
-  "pages": [
-    "pages/test/index",
+  "pages": [   
     "pages/my/index",
     "pages/home/index",
+    "pages/test/index",
     "pages/bank/index",
     "pages/market/index",
     "pages/policy/index"
@@ -74,7 +74,8 @@
     "van-nav-bar": "../../miniprogram_npm/vant-weapp/nav-bar/index",
     "van-tabbar": "../../miniprogram_npm/vant-weapp/tabbar/index",
     "van-tabbar-item": "../../miniprogram_npm/vant-weapp/tabbar-item/index",
-    "van-rate": "../../miniprogram_npm/vant-weapp/rate/index"
+    "van-rate": "../../miniprogram_npm/vant-weapp/rate/index",
+    "van-tag": "../../miniprogram_npm/vant-weapp/tag/index"
   },
   "window": {
     "backgroundTextStyle": "light",

+ 57 - 38
miniprogram_npm/vant-weapp/action-sheet/index.js

@@ -1,43 +1,62 @@
 import { VantComponent } from '../common/component';
-import { safeArea } from '../mixins/safe-area';
+import { button } from '../mixins/button';
+import { openType } from '../mixins/open-type';
 VantComponent({
-    mixins: [safeArea()],
-    props: {
-        show: Boolean,
-        title: String,
-        cancelText: String,
-        customStyle: String,
-        overlayStyle: String,
-        zIndex: {
-            type: Number,
-            value: 100
-        },
-        actions: {
-            type: Array,
-            value: []
-        },
-        overlay: {
-            type: Boolean,
-            value: true
-        },
-        closeOnClickOverlay: {
-            type: Boolean,
-            value: true
-        }
+  mixins: [button, openType],
+  props: {
+    show: Boolean,
+    title: String,
+    cancelText: String,
+    description: String,
+    round: {
+      type: Boolean,
+      value: true,
+    },
+    zIndex: {
+      type: Number,
+      value: 100,
+    },
+    actions: {
+      type: Array,
+      value: [],
+    },
+    overlay: {
+      type: Boolean,
+      value: true,
+    },
+    closeOnClickOverlay: {
+      type: Boolean,
+      value: true,
+    },
+    closeOnClickAction: {
+      type: Boolean,
+      value: true,
     },
-    methods: {
-        onSelect(event) {
-            const { index } = event.currentTarget.dataset;
-            const item = this.data.actions[index];
-            if (item && !item.disabled && !item.loading) {
-                this.$emit('select', item);
-            }
-        },
-        onCancel() {
-            this.$emit('cancel');
-        },
-        onClose() {
-            this.$emit('close');
+    safeAreaInsetBottom: {
+      type: Boolean,
+      value: true,
+    },
+  },
+  methods: {
+    onSelect(event) {
+      const { index } = event.currentTarget.dataset;
+      const item = this.data.actions[index];
+      if (item && !item.disabled && !item.loading) {
+        this.$emit('select', item);
+        if (this.data.closeOnClickAction) {
+          this.onClose();
         }
-    }
+      }
+    },
+    onCancel() {
+      this.$emit('cancel');
+    },
+    onClose() {
+      this.$emit('close');
+    },
+    onClickOverlay() {
+      this.$emit('click-overlay');
+      this.onClose();
+    },
+  },
 });

+ 20 - 4
miniprogram_npm/vant-weapp/action-sheet/index.wxml

@@ -3,14 +3,13 @@
 <van-popup
   show="{{ show }}"
   position="bottom"
+  round="{{ round }}"
   z-index="{{ zIndex }}"
   overlay="{{ overlay }}"
-  custom-style="{{ customStyle }}"
-  overlay-style="{{ overlayStyle }}"
   custom-class="van-action-sheet"
   safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
   close-on-click-overlay="{{ closeOnClickOverlay }}"
-  bind:close="onClose"
+  bind:close="onClickOverlay"
 >
   <view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header">
     {{ title }}
@@ -20,22 +19,39 @@
       bind:click="onClose"
     />
   </view>
+  <view wx:if="{{ description }}" class="van-action-sheet__description">
+    {{ description }}
+  </view>
   <view wx:if="{{ actions && actions.length }}">
     <!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 -->
     <button
       wx:for="{{ actions }}"
       wx:key="index"
       open-type="{{ item.openType }}"
+      style="{{ item.color ? 'color: ' + item.color : '' }}"
       class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}"
       hover-class="van-action-sheet__item--hover"
       data-index="{{ index }}"
       bind:tap="onSelect"
+      bindgetuserinfo="bindGetUserInfo"
+      bindcontact="bindContact"
+      bindgetphonenumber="bindGetPhoneNumber"
+      binderror="bindError"
+      bindlaunchapp="bindLaunchApp"
+      bindopensetting="bindOpenSetting"
+      lang="{{ lang }}"
+      session-from="{{ sessionFrom }}"
+      send-message-title="{{ sendMessageTitle }}"
+      send-message-path="{{ sendMessagePath }}"
+      send-message-img="{{ sendMessageImg }}"
+      show-message-card="{{ showMessageCard }}"
+      app-parameter="{{ appParameter }}"
     >
       <block wx:if="{{ !item.loading }}">
         {{ item.name }}
         <text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text>
       </block>
-      <van-loading wx:else size="20px" />
+      <van-loading wx:else custom-class="van-action-sheet__loading" size="20px" />
     </button>
   </view>
   <slot />

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/action-sheet/index.wxss


+ 216 - 204
miniprogram_npm/vant-weapp/area/index.js

@@ -2,211 +2,223 @@ import { VantComponent } from '../common/component';
 import { pickerProps } from '../picker/shared';
 const COLUMNSPLACEHOLDERCODE = '000000';
 VantComponent({
-    classes: ['active-class', 'toolbar-class', 'column-class'],
-    props: Object.assign({}, pickerProps, { value: String, areaList: {
-            type: Object,
-            value: {}
-        }, columnsNum: {
-            type: [String, Number],
-            value: 3
-        }, columnsPlaceholder: {
-            type: Array,
-            observer(val) {
-                this.setData({
-                    typeToColumnsPlaceholder: {
-                        province: val[0] || '',
-                        city: val[1] || '',
-                        county: val[2] || '',
-                    }
-                });
-            }
-        } }),
-    data: {
-        columns: [{ values: [] }, { values: [] }, { values: [] }],
-        displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
-        typeToColumnsPlaceholder: {}
-    },
-    watch: {
-        value(value) {
-            this.code = value;
-            this.setValues();
-        },
-        areaList: 'setValues',
-        columnsNum(value) {
-            this.set({
-                displayColumns: this.data.columns.slice(0, +value)
-            });
+  classes: ['active-class', 'toolbar-class', 'column-class'],
+  props: Object.assign(Object.assign({}, pickerProps), {
+    value: {
+      type: String,
+      observer(value) {
+        this.code = value;
+        this.setValues();
+      },
+    },
+    areaList: {
+      type: Object,
+      value: {},
+      observer: 'setValues',
+    },
+    columnsNum: {
+      type: null,
+      value: 3,
+      observer(value) {
+        this.setData({
+          displayColumns: this.data.columns.slice(0, +value),
+        });
+      },
+    },
+    columnsPlaceholder: {
+      type: Array,
+      observer(val) {
+        this.setData({
+          typeToColumnsPlaceholder: {
+            province: val[0] || '',
+            city: val[1] || '',
+            county: val[2] || '',
+          },
+        });
+      },
+    },
+  }),
+  data: {
+    columns: [{ values: [] }, { values: [] }, { values: [] }],
+    displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
+    typeToColumnsPlaceholder: {},
+  },
+  mounted() {
+    setTimeout(() => {
+      this.setValues();
+    }, 0);
+  },
+  methods: {
+    getPicker() {
+      if (this.picker == null) {
+        this.picker = this.selectComponent('.van-area__picker');
+      }
+      return this.picker;
+    },
+    onCancel(event) {
+      this.emit('cancel', event.detail);
+    },
+    onConfirm(event) {
+      const { index } = event.detail;
+      let { value } = event.detail;
+      value = this.parseOutputValues(value);
+      this.emit('confirm', { value, index });
+    },
+    emit(type, detail) {
+      detail.values = detail.value;
+      delete detail.value;
+      this.$emit(type, detail);
+    },
+    // parse output columns data
+    parseOutputValues(values) {
+      const { columnsPlaceholder } = this.data;
+      return values.map((value, index) => {
+        // save undefined value
+        if (!value) return value;
+        value = JSON.parse(JSON.stringify(value));
+        if (!value.code || value.name === columnsPlaceholder[index]) {
+          value.code = '';
+          value.name = '';
+        }
+        return value;
+      });
+    },
+    onChange(event) {
+      const { index, picker, value } = event.detail;
+      this.code = value[index].code;
+      this.setValues().then(() => {
+        this.$emit('change', {
+          picker,
+          values: this.parseOutputValues(picker.getValues()),
+          index,
+        });
+      });
+    },
+    getConfig(type) {
+      const { areaList } = this.data;
+      return (areaList && areaList[`${type}_list`]) || {};
+    },
+    getList(type, code) {
+      const { typeToColumnsPlaceholder } = this.data;
+      let result = [];
+      if (type !== 'province' && !code) {
+        return result;
+      }
+      const list = this.getConfig(type);
+      result = Object.keys(list).map((code) => ({
+        code,
+        name: list[code],
+      }));
+      if (code) {
+        // oversea code
+        if (code[0] === '9' && type === 'city') {
+          code = '9';
+        }
+        result = result.filter((item) => item.code.indexOf(code) === 0);
+      }
+      if (typeToColumnsPlaceholder[type] && result.length) {
+        // set columns placeholder
+        const codeFill =
+          type === 'province'
+            ? ''
+            : type === 'city'
+            ? COLUMNSPLACEHOLDERCODE.slice(2, 4)
+            : COLUMNSPLACEHOLDERCODE.slice(4, 6);
+        result.unshift({
+          code: `${code}${codeFill}`,
+          name: typeToColumnsPlaceholder[type],
+        });
+      }
+      return result;
+    },
+    getIndex(type, code) {
+      let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
+      const list = this.getList(type, code.slice(0, compareNum - 2));
+      // oversea code
+      if (code[0] === '9' && type === 'province') {
+        compareNum = 1;
+      }
+      code = code.slice(0, compareNum);
+      for (let i = 0; i < list.length; i++) {
+        if (list[i].code.slice(0, compareNum) === code) {
+          return i;
         }
+      }
+      return 0;
     },
-    mounted() {
-        setTimeout(() => {
-            this.setValues();
-        }, 0);
-    },
-    methods: {
-        getPicker() {
-            if (this.picker == null) {
-                this.picker = this.selectComponent('.van-area__picker');
-            }
-            return this.picker;
-        },
-        onCancel(event) {
-            this.emit('cancel', event.detail);
-        },
-        onConfirm(event) {
-            const { index } = event.detail;
-            let { value } = event.detail;
-            value = this.parseOutputValues(value);
-            this.emit('confirm', { value, index });
-        },
-        emit(type, detail) {
-            detail.values = detail.value;
-            delete detail.value;
-            this.$emit(type, detail);
-        },
-        // parse output columns data
-        parseOutputValues(values) {
-            const { columnsPlaceholder } = this.data;
-            return values.map((value, index) => {
-                // save undefined value
-                if (!value)
-                    return value;
-                value = JSON.parse(JSON.stringify(value));
-                if (!value.code || value.name === columnsPlaceholder[index]) {
-                    value.code = '';
-                    value.name = '';
-                }
-                return value;
-            });
-        },
-        onChange(event) {
-            const { index, picker, value } = event.detail;
-            this.code = value[index].code;
-            let getValues = picker.getValues();
-            getValues = this.parseOutputValues(getValues);
-            this.setValues().then(() => {
-                this.$emit('change', {
-                    picker,
-                    values: getValues,
-                    index
-                });
-            });
-        },
-        getConfig(type) {
-            const { areaList } = this.data;
-            return (areaList && areaList[`${type}_list`]) || {};
-        },
-        getList(type, code) {
-            const { typeToColumnsPlaceholder } = this.data;
-            let result = [];
-            if (type !== 'province' && !code) {
-                return result;
-            }
-            const list = this.getConfig(type);
-            result = Object.keys(list).map(code => ({
-                code,
-                name: list[code]
-            }));
-            if (code) {
-                // oversea code
-                if (code[0] === '9' && type === 'city') {
-                    code = '9';
-                }
-                result = result.filter(item => item.code.indexOf(code) === 0);
-            }
-            if (typeToColumnsPlaceholder[type] && result.length) {
-                // set columns placeholder
-                const codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6);
-                result.unshift({
-                    code: `${code}${codeFill}`,
-                    name: typeToColumnsPlaceholder[type]
-                });
-            }
-            return result;
-        },
-        getIndex(type, code) {
-            let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
-            const list = this.getList(type, code.slice(0, compareNum - 2));
-            // oversea code
-            if (code[0] === '9' && type === 'province') {
-                compareNum = 1;
-            }
-            code = code.slice(0, compareNum);
-            for (let i = 0; i < list.length; i++) {
-                if (list[i].code.slice(0, compareNum) === code) {
-                    return i;
-                }
-            }
-            return 0;
-        },
-        setValues() {
-            const county = this.getConfig('county');
-            let { code } = this;
-            if (!code) {
-                if (this.data.columnsPlaceholder.length) {
-                    code = COLUMNSPLACEHOLDERCODE;
-                }
-                else if (Object.keys(county)[0]) {
-                    code = Object.keys(county)[0];
-                }
-                else {
-                    code = '';
-                }
-            }
-            const province = this.getList('province');
-            const city = this.getList('city', code.slice(0, 2));
-            const picker = this.getPicker();
-            if (!picker) {
-                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;
-            }
-            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)
-            ]))
-                .catch(() => { });
-        },
-        getValues() {
-            const picker = this.getPicker();
-            return picker ? picker.getValues().filter(value => !!value) : [];
-        },
-        getDetail() {
-            const values = this.getValues();
-            const area = {
-                code: '',
-                country: '',
-                province: '',
-                city: '',
-                county: ''
-            };
-            if (!values.length) {
-                return area;
-            }
-            const names = values.map((item) => item.name);
-            area.code = values[values.length - 1].code;
-            if (area.code[0] === '9') {
-                area.country = names[1] || '';
-                area.province = names[2] || '';
-            }
-            else {
-                area.province = names[0] || '';
-                area.city = names[1] || '';
-                area.county = names[2] || '';
-            }
-            return area;
-        },
-        reset() {
-            this.code = '';
-            return this.setValues();
+    setValues() {
+      const county = this.getConfig('county');
+      let { code } = this;
+      if (!code) {
+        if (this.data.columnsPlaceholder.length) {
+          code = COLUMNSPLACEHOLDERCODE;
+        } else if (Object.keys(county)[0]) {
+          code = Object.keys(county)[0];
+        } else {
+          code = '';
         }
-    }
+      }
+      const province = this.getList('province');
+      const city = this.getList('city', code.slice(0, 2));
+      const picker = this.getPicker();
+      if (!picker) {
+        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;
+      }
+      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),
+          ])
+        )
+        .catch(() => {});
+    },
+    getValues() {
+      const picker = this.getPicker();
+      return picker ? picker.getValues().filter((value) => !!value) : [];
+    },
+    getDetail() {
+      const values = this.getValues();
+      const area = {
+        code: '',
+        country: '',
+        province: '',
+        city: '',
+        county: '',
+      };
+      if (!values.length) {
+        return area;
+      }
+      const names = values.map((item) => item.name);
+      area.code = values[values.length - 1].code;
+      if (area.code[0] === '9') {
+        area.country = names[1] || '';
+        area.province = names[2] || '';
+      } else {
+        area.province = names[0] || '';
+        area.city = names[1] || '';
+        area.county = names[2] || '';
+      }
+      return area;
+    },
+    reset(code) {
+      this.code = code || '';
+      return this.setValues();
+    },
+  },
 });

+ 0 - 1
miniprogram_npm/vant-weapp/badge-group/index.d.ts

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

+ 0 - 43
miniprogram_npm/vant-weapp/badge-group/index.js

@@ -1,43 +0,0 @@
-import { VantComponent } from '../common/component';
-VantComponent({
-    relation: {
-        name: 'badge',
-        type: 'descendant',
-        linked(target) {
-            this.badges.push(target);
-            this.setActive(this.data.active);
-        },
-        unlinked(target) {
-            this.badges = this.badges.filter(item => item !== target);
-            this.setActive(this.data.active);
-        }
-    },
-    props: {
-        active: {
-            type: Number,
-            value: 0,
-            observer: 'setActive'
-        }
-    },
-    beforeCreate() {
-        this.badges = [];
-        this.currentActive = -1;
-    },
-    methods: {
-        setActive(active) {
-            const { badges, currentActive } = this;
-            if (!badges.length) {
-                return Promise.resolve();
-            }
-            this.currentActive = active;
-            const stack = [];
-            if (currentActive !== active && badges[currentActive]) {
-                stack.push(badges[currentActive].setActive(false));
-            }
-            if (badges[active]) {
-                stack.push(badges[active].setActive(true));
-            }
-            return Promise.all(stack);
-        }
-    }
-});

+ 0 - 3
miniprogram_npm/vant-weapp/badge-group/index.json

@@ -1,3 +0,0 @@
-{
-  "component": true
-}

+ 0 - 3
miniprogram_npm/vant-weapp/badge-group/index.wxml

@@ -1,3 +0,0 @@
-<view class="van-badge-group van-hairline--top-bottom custom-class">
-  <slot />
-</view>

+ 0 - 1
miniprogram_npm/vant-weapp/badge-group/index.wxss

@@ -1 +0,0 @@
-@import '../common/index.wxss';.van-badge-group{width:85px}

+ 0 - 1
miniprogram_npm/vant-weapp/badge/index.d.ts

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

+ 0 - 30
miniprogram_npm/vant-weapp/badge/index.js

@@ -1,30 +0,0 @@
-import { VantComponent } from '../common/component';
-VantComponent({
-    relation: {
-        type: 'ancestor',
-        name: 'badge-group',
-        linked(target) {
-            this.parent = target;
-        }
-    },
-    props: {
-        info: null,
-        title: String
-    },
-    methods: {
-        onClick() {
-            const { parent } = this;
-            if (!parent) {
-                return;
-            }
-            const index = parent.badges.indexOf(this);
-            parent.setActive(index).then(() => {
-                this.$emit('click', index);
-                parent.$emit('change', index);
-            });
-        },
-        setActive(active) {
-            return this.set({ active });
-        }
-    }
-});

+ 0 - 6
miniprogram_npm/vant-weapp/badge/index.json

@@ -1,6 +0,0 @@
-{
-  "component": true,
-  "usingComponents": {
-    "van-info": "../info/index"
-  }
-}

+ 0 - 17
miniprogram_npm/vant-weapp/badge/index.wxml

@@ -1,17 +0,0 @@
-<wxs src="../wxs/utils.wxs" module="utils" />
-
-<view
-  class="{{ utils.bem('badge', { active }) }} van-hairline custom-class"
-  hover-class="van-badge--hover"
-  hover-stay-time="70"
-  bind:tap="onClick"
->
-  <view class="van-badge__text">
-    <van-info
-      wx:if="{{ info !== null }}"
-      info="{{ info }}"
-      custom-style="right: 4px"
-    />
-    {{ title }}
-  </view>
-</view>

ファイルの差分が大きいため隠しています
+ 0 - 1
miniprogram_npm/vant-weapp/badge/index.wxss


+ 72 - 31
miniprogram_npm/vant-weapp/button/index.js

@@ -1,38 +1,79 @@
 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],
-    classes: ['hover-class', 'loading-class'],
-    props: {
-        icon: String,
-        color: String,
-        plain: Boolean,
-        block: Boolean,
-        round: Boolean,
-        square: Boolean,
-        loading: Boolean,
-        hairline: Boolean,
-        disabled: Boolean,
-        loadingText: String,
-        type: {
-            type: String,
-            value: 'default'
-        },
-        size: {
-            type: String,
-            value: 'normal'
-        },
-        loadingSize: {
-            type: String,
-            value: '20px'
-        }
+  mixins,
+  classes: ['hover-class', 'loading-class'],
+  data: {
+    baseStyle: '',
+  },
+  props: {
+    formType: String,
+    icon: String,
+    classPrefix: {
+      type: String,
+      value: 'van-icon',
+    },
+    plain: Boolean,
+    block: Boolean,
+    round: Boolean,
+    square: Boolean,
+    loading: Boolean,
+    hairline: Boolean,
+    disabled: Boolean,
+    loadingText: String,
+    customStyle: String,
+    loadingType: {
+      type: String,
+      value: 'circular',
+    },
+    type: {
+      type: String,
+      value: 'default',
+    },
+    dataset: null,
+    size: {
+      type: String,
+      value: 'normal',
     },
-    methods: {
-        onClick() {
-            if (!this.data.disabled && !this.data.loading) {
-                this.$emit('click');
-            }
+    loadingSize: {
+      type: String,
+      value: '20px',
+    },
+    color: {
+      type: String,
+      observer(color) {
+        let style = '';
+        if (color) {
+          style += `color: ${this.data.plain ? color : 'white'};`;
+          if (!this.data.plain) {
+            // Use background instead of backgroundColor to make linear-gradient work
+            style += `background: ${color};`;
+          }
+          // hide border when color is linear-gradient
+          if (color.indexOf('gradient') !== -1) {
+            style += 'border: 0;';
+          } else {
+            style += `border-color: ${color};`;
+          }
+        }
+        if (style !== this.data.baseStyle) {
+          this.setData({ baseStyle: style });
         }
-    }
+      },
+    },
+  },
+  methods: {
+    onClick() {
+      if (!this.data.loading) {
+        this.$emit('click');
+      }
+    },
+    noop() {},
+  },
 });

+ 25 - 8
miniprogram_npm/vant-weapp/button/index.wxml

@@ -2,11 +2,13 @@
 
 <button
   id="{{ id }}"
+  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' : '' }}"
-  open-type="{{ openType }}"
   hover-class="van-button--active hover-class"
-  style="{{ color ? 'border-color: ' + color + ';' + (plain ? 'color: ' + color : 'color: #fff; background-color: ' + color) : '' }}"
   lang="{{ lang }}"
+  form-type="{{ formType }}"
+  style="{{ baseStyle }} {{ customStyle }}"
+  open-type="{{ disabled ? '' : openType }}"
   business-id="{{ businessId }}"
   session-from="{{ sessionFrom }}"
   send-message-title="{{ sendMessageTitle }}"
@@ -15,7 +17,7 @@
   show-message-card="{{ showMessageCard }}"
   app-parameter="{{ appParameter }}"
   aria-label="{{ ariaLabel }}"
-  bindtap="onClick"
+  bindtap="{{ !disabled ? 'onClick' : 'noop' }}"
   bindgetuserinfo="bindGetUserInfo"
   bindcontact="bindContact"
   bindgetphonenumber="bindGetPhoneNumber"
@@ -27,12 +29,10 @@
     <van-loading
       custom-class="loading-class"
       size="{{ loadingSize }}"
-      color="{{ type === 'default' ? '#c9c9c9' : '' }}"
+      type="{{ loadingType }}"
+      color="{{ loadingColor(type,color,plain) }}"
     />
-    <view
-      wx:if="{{ loadingText }}"
-      class="van-button__loading-text"
-    >
+    <view wx:if="{{ loadingText }}" class="van-button__loading-text">
       {{ loadingText }}
     </view>
   </block>
@@ -41,6 +41,7 @@
       wx:if="{{ icon }}"
       size="1.2em"
       name="{{ icon }}"
+      class-prefix="{{ classPrefix }}"
       class="van-button__icon"
       custom-style="line-height: inherit;"
     />
@@ -49,3 +50,19 @@
     </view>
   </block>
 </button>
+
+
+<wxs module="loadingColor">
+function get(type, color,plain) {
+  if(plain) {
+    return color ? color: '#c9c9c9';
+  }
+
+  if(type === 'default') {
+    return '#c9c9c9';
+  }
+  return 'white';
+}
+
+module.exports = get;
+</wxs>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/button/index.wxss


+ 44 - 33
miniprogram_npm/vant-weapp/card/index.js

@@ -1,38 +1,49 @@
 import { link } from '../mixins/link';
 import { VantComponent } from '../common/component';
 VantComponent({
-    classes: [
-        'num-class',
-        'desc-class',
-        'thumb-class',
-        'title-class',
-        'price-class',
-        'origin-price-class',
-    ],
-    mixins: [link],
-    props: {
-        tag: String,
-        num: String,
-        desc: String,
-        thumb: String,
-        title: String,
-        price: String,
-        centered: Boolean,
-        lazyLoad: Boolean,
-        thumbLink: String,
-        originPrice: String,
-        thumbMode: {
-            type: String,
-            value: 'aspectFit'
-        },
-        currency: {
-            type: String,
-            value: '¥'
-        }
+  classes: [
+    'num-class',
+    'desc-class',
+    'thumb-class',
+    'title-class',
+    'price-class',
+    'origin-price-class',
+  ],
+  mixins: [link],
+  props: {
+    tag: String,
+    num: String,
+    desc: String,
+    thumb: String,
+    title: String,
+    price: {
+      type: String,
+      observer: 'updatePrice',
     },
-    methods: {
-        onClickThumb() {
-            this.jumpLink('thumbLink');
-        }
-    }
+    centered: Boolean,
+    lazyLoad: Boolean,
+    thumbLink: String,
+    originPrice: String,
+    thumbMode: {
+      type: String,
+      value: 'aspectFit',
+    },
+    currency: {
+      type: String,
+      value: '¥',
+    },
+  },
+  methods: {
+    updatePrice() {
+      const { price } = this.data;
+      const priceArr = price.toString().split('.');
+      this.setData({
+        integerStr: priceArr[0],
+        decimalStr: priceArr[1] ? `.${priceArr[1]}` : '',
+      });
+    },
+    onClickThumb() {
+      this.jumpLink('thumbLink');
+    },
+  },
 });

+ 12 - 7
miniprogram_npm/vant-weapp/card/index.wxml

@@ -21,19 +21,24 @@
       </van-tag>
     </view>
 
-    <view class="van-card__content">
-      <view wx:if="{{ title }}" class="van-card__title title-class">{{ title }}</view>
-      <slot wx:else name="title" />
+    <view class="van-card__content {{ utils.bem('card__content', { center: centered }) }}">
+      <view>
+        <view wx:if="{{ title }}" class="van-card__title title-class">{{ title }}</view>
+        <slot wx:else name="title" />
 
-      <view wx:if="{{ desc }}" class="van-card__desc desc-class">{{ desc }}</view>
-      <slot wx:else name="desc" />
+        <view wx:if="{{ desc }}" class="van-card__desc desc-class">{{ desc }}</view>
+        <slot wx:else name="desc" />
 
-      <slot name="tags" />
+        <slot name="tags" />
+      </view>
 
       <view class="van-card__bottom">
-        <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
+        <slot name="price-top" />
+        <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }}<text class="van-card__price-integer">{{ integerStr }}</text><text class="van-card__price-decimal">{{ decimalStr }}</text></view>
+        <slot wx:else name="price" />
         <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
         <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
+        <slot wx:else  name="num" />
         <slot name="bottom" />
       </view>
     </view>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/card/index.wxss


+ 7 - 7
miniprogram_npm/vant-weapp/cell-group/index.js

@@ -1,10 +1,10 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    props: {
-        title: String,
-        border: {
-            type: Boolean,
-            value: true
-        }
-    }
+  props: {
+    title: String,
+    border: {
+      type: Boolean,
+      value: true,
+    },
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/cell-group/index.json

@@ -1,3 +1,3 @@
 {
   "component": true
-}
+}

+ 1 - 1
miniprogram_npm/vant-weapp/cell-group/index.wxss

@@ -1 +1 @@
-@import '../common/index.wxss';.van-cell-group__title{font-size:14px;padding:15px 15px 5px;color:#999;line-height:16px}
+@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)}

+ 32 - 32
miniprogram_npm/vant-weapp/cell/index.js

@@ -1,37 +1,37 @@
 import { link } from '../mixins/link';
 import { VantComponent } from '../common/component';
 VantComponent({
-    classes: [
-        'title-class',
-        'label-class',
-        'value-class',
-        'right-icon-class',
-        'hover-class'
-    ],
-    mixins: [link],
-    props: {
-        title: null,
-        value: null,
-        icon: String,
-        size: String,
-        label: String,
-        center: Boolean,
-        isLink: Boolean,
-        required: Boolean,
-        clickable: Boolean,
-        titleWidth: String,
-        customStyle: String,
-        arrowDirection: String,
-        useLabelSlot: Boolean,
-        border: {
-            type: Boolean,
-            value: true
-        }
+  classes: [
+    'title-class',
+    'label-class',
+    'value-class',
+    'right-icon-class',
+    'hover-class',
+  ],
+  mixins: [link],
+  props: {
+    title: null,
+    value: null,
+    icon: String,
+    size: String,
+    label: String,
+    center: Boolean,
+    isLink: Boolean,
+    required: Boolean,
+    clickable: Boolean,
+    titleWidth: String,
+    customStyle: String,
+    arrowDirection: String,
+    useLabelSlot: Boolean,
+    border: {
+      type: Boolean,
+      value: true,
     },
-    methods: {
-        onClick(event) {
-            this.$emit('click', event.detail);
-            this.jumpLink();
-        }
-    }
+  },
+  methods: {
+    onClick(event) {
+      this.$emit('click', event.detail);
+      this.jumpLink();
+    },
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/cell/index.json

@@ -3,4 +3,4 @@
   "usingComponents": {
     "van-icon": "../icon/index"
   }
-}
+}

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/cell/index.wxss


+ 30 - 34
miniprogram_npm/vant-weapp/checkbox-group/index.js

@@ -1,39 +1,35 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    field: true,
-    relation: {
-        name: 'checkbox',
-        type: 'descendant',
-        linked(target) {
-            this.children = this.children || [];
-            this.children.push(target);
-            this.updateChild(target);
-        },
-        unlinked(target) {
-            this.children = this.children.filter((child) => child !== target);
-        }
+  field: true,
+  relation: {
+    name: 'checkbox',
+    type: 'descendant',
+    current: 'checkbox-group',
+    linked(target) {
+      this.updateChild(target);
     },
-    props: {
-        max: Number,
-        value: {
-            type: Array,
-            observer: 'updateChildren'
-        },
-        disabled: {
-            type: Boolean,
-            observer: 'updateChildren'
-        }
+  },
+  props: {
+    max: Number,
+    value: {
+      type: Array,
+      observer: 'updateChildren',
     },
-    methods: {
-        updateChildren() {
-            (this.children || []).forEach((child) => this.updateChild(child));
-        },
-        updateChild(child) {
-            const { value, disabled } = this.data;
-            child.set({
-                value: value.indexOf(child.data.name) !== -1,
-                disabled: disabled || child.data.disabled
-            });
-        }
-    }
+    disabled: {
+      type: Boolean,
+      observer: 'updateChildren',
+    },
+  },
+  methods: {
+    updateChildren() {
+      (this.children || []).forEach((child) => this.updateChild(child));
+    },
+    updateChild(child) {
+      const { value, disabled } = this.data;
+      child.setData({
+        value: value.indexOf(child.data.name) !== -1,
+        parentDisabled: disabled,
+      });
+    },
+  },
 });

+ 66 - 66
miniprogram_npm/vant-weapp/checkbox/index.js

@@ -1,74 +1,74 @@
 import { VantComponent } from '../common/component';
 function emit(target, value) {
-    target.$emit('input', value);
-    target.$emit('change', value);
+  target.$emit('input', value);
+  target.$emit('change', value);
 }
 VantComponent({
-    field: true,
-    relation: {
-        name: 'checkbox-group',
-        type: 'ancestor',
-        linked(target) {
-            this.parent = target;
-        },
-        unlinked() {
-            this.parent = null;
-        }
+  field: true,
+  relation: {
+    name: 'checkbox-group',
+    type: 'ancestor',
+    current: 'checkbox',
+  },
+  classes: ['icon-class', 'label-class'],
+  props: {
+    value: Boolean,
+    disabled: Boolean,
+    useIconSlot: Boolean,
+    checkedColor: String,
+    labelPosition: String,
+    labelDisabled: Boolean,
+    shape: {
+      type: String,
+      value: 'round',
     },
-    classes: ['icon-class', 'label-class'],
-    props: {
-        value: Boolean,
-        disabled: Boolean,
-        useIconSlot: Boolean,
-        checkedColor: String,
-        labelPosition: String,
-        labelDisabled: Boolean,
-        shape: {
-            type: String,
-            value: 'round'
-        }
+    iconSize: {
+      type: null,
+      value: 20,
+    },
+  },
+  data: {
+    parentDisabled: false,
+  },
+  methods: {
+    emitChange(value) {
+      if (this.parent) {
+        this.setParentValue(this.parent, value);
+      } else {
+        emit(this, value);
+      }
+    },
+    toggle() {
+      const { parentDisabled, disabled, value } = this.data;
+      if (!disabled && !parentDisabled) {
+        this.emitChange(!value);
+      }
     },
-    methods: {
-        emitChange(value) {
-            if (this.parent) {
-                this.setParentValue(this.parent, value);
-            }
-            else {
-                emit(this, value);
-            }
-        },
-        toggle() {
-            const { disabled, value } = this.data;
-            if (!disabled) {
-                this.emitChange(!value);
-            }
-        },
-        onClickLabel() {
-            const { labelDisabled, disabled, value } = this.data;
-            if (!disabled && !labelDisabled) {
-                this.emitChange(!value);
-            }
-        },
-        setParentValue(parent, value) {
-            const parentValue = parent.data.value.slice();
-            const { name } = this.data;
-            const { max } = parent.data;
-            if (value) {
-                if (max && parentValue.length >= max) {
-                    return;
-                }
-                if (parentValue.indexOf(name) === -1) {
-                    parentValue.push(name);
-                    emit(parent, parentValue);
-                }
-            }
-            else {
-                const index = parentValue.indexOf(name);
-                if (index !== -1) {
-                    parentValue.splice(index, 1);
-                    emit(parent, parentValue);
-                }
-            }
+    onClickLabel() {
+      const { labelDisabled, parentDisabled, disabled, value } = this.data;
+      if (!disabled && !labelDisabled && !parentDisabled) {
+        this.emitChange(!value);
+      }
+    },
+    setParentValue(parent, value) {
+      const parentValue = parent.data.value.slice();
+      const { name } = this.data;
+      const { max } = parent.data;
+      if (value) {
+        if (max && parentValue.length >= max) {
+          return;
+        }
+        if (parentValue.indexOf(name) === -1) {
+          parentValue.push(name);
+          emit(parent, parentValue);
         }
-    }
+      } else {
+        const index = parentValue.indexOf(name);
+        if (index !== -1) {
+          parentValue.splice(index, 1);
+          emit(parent, parentValue);
+        }
+      }
+    },
+  },
 });

+ 6 - 4
miniprogram_npm/vant-weapp/checkbox/index.wxml

@@ -1,4 +1,5 @@
 <wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
 
 <view class="van-checkbox custom-class">
   <view class="van-checkbox__icon-wrap" bindtap="toggle">
@@ -6,13 +7,14 @@
     <van-icon
       wx:else
       name="success"
-      class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}"
-      style="{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}"
+      size="0.8em"
+      class="{{ utils.bem('checkbox__icon', [shape, { disabled: disabled || parentDisabled, checked: value }]) }}"
+      style="{{ computed.iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) }}"
       custom-class="icon-class"
-      custom-style="line-height: 20px;"
+      custom-style="line-height: 1.25em;"
     />
   </view>
-  <view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel">
+  <view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled: disabled || parentDisabled }]) }}" bindtap="onClickLabel">
     <slot />
   </view>
 </view>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/checkbox/index.wxss


+ 22 - 19
miniprogram_npm/vant-weapp/col/index.js

@@ -1,23 +1,26 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    relation: {
-        name: 'row',
-        type: 'ancestor'
+  relation: {
+    name: 'row',
+    type: 'ancestor',
+    current: 'col',
+  },
+  props: {
+    span: Number,
+    offset: Number,
+  },
+  data: {
+    viewStyle: '',
+  },
+  methods: {
+    setGutter(gutter) {
+      const padding = `${gutter / 2}px`;
+      const viewStyle = gutter
+        ? `padding-left: ${padding}; padding-right: ${padding};`
+        : '';
+      if (viewStyle !== this.data.viewStyle) {
+        this.setData({ viewStyle });
+      }
     },
-    props: {
-        span: Number,
-        offset: Number
-    },
-    data: {
-        style: ''
-    },
-    methods: {
-        setGutter(gutter) {
-            const padding = `${gutter / 2}px`;
-            const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : '';
-            if (style !== this.data.style) {
-                this.set({ style });
-            }
-        }
-    }
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/col/index.wxml

@@ -2,7 +2,7 @@
 
 <view
   class="custom-class {{ utils.bem('col', [span]) }} {{ offset ? 'van-col--offset-' + offset : '' }}"
-  style="{{ style }}"
+  style="{{ viewStyle }}"
 >
   <slot />
 </view>

+ 85 - 87
miniprogram_npm/vant-weapp/collapse-item/index.js

@@ -1,96 +1,94 @@
 import { VantComponent } from '../common/component';
-const nextTick = () => new Promise(resolve => setTimeout(resolve, 20));
+const nextTick = () => new Promise((resolve) => setTimeout(resolve, 20));
 VantComponent({
-    classes: ['title-class', 'content-class'],
-    relation: {
-        name: 'collapse',
-        type: 'ancestor',
-        linked(parent) {
-            this.parent = parent;
-        }
+  classes: ['title-class', 'content-class'],
+  relation: {
+    name: 'collapse',
+    type: 'ancestor',
+    current: 'collapse-item',
+  },
+  props: {
+    name: null,
+    title: null,
+    value: null,
+    icon: String,
+    label: String,
+    disabled: Boolean,
+    clickable: Boolean,
+    border: {
+      type: Boolean,
+      value: true,
     },
-    props: {
-        name: null,
-        title: null,
-        value: null,
-        icon: String,
-        label: String,
-        disabled: Boolean,
-        clickable: Boolean,
-        border: {
-            type: Boolean,
-            value: true
-        },
-        isLink: {
-            type: Boolean,
-            value: true
-        }
+    isLink: {
+      type: Boolean,
+      value: true,
     },
-    data: {
-        contentHeight: 0,
-        expanded: false,
-        transition: false
+  },
+  data: {
+    contentHeight: 0,
+    expanded: false,
+    transition: false,
+  },
+  mounted() {
+    this.updateExpanded()
+      .then(nextTick)
+      .then(() => {
+        const data = { transition: true };
+        if (this.data.expanded) {
+          data.contentHeight = 'auto';
+        }
+        this.setData(data);
+      });
+  },
+  methods: {
+    updateExpanded() {
+      if (!this.parent) {
+        return Promise.resolve();
+      }
+      const { value, accordion } = this.parent.data;
+      const { children = [] } = this.parent;
+      const { name } = this.data;
+      const index = children.indexOf(this);
+      const currentName = name == null ? index : name;
+      const expanded = accordion
+        ? value === currentName
+        : (value || []).some((name) => name === currentName);
+      const stack = [];
+      if (expanded !== this.data.expanded) {
+        stack.push(this.updateStyle(expanded));
+      }
+      stack.push(this.set({ index, expanded }));
+      return Promise.all(stack);
     },
-    mounted() {
-        this.updateExpanded()
+    updateStyle(expanded) {
+      return this.getRect('.van-collapse-item__content')
+        .then((rect) => rect.height)
+        .then((height) => {
+          if (expanded) {
+            return this.set({
+              contentHeight: height ? `${height}px` : 'auto',
+            });
+          }
+          return this.set({ contentHeight: `${height}px` })
             .then(nextTick)
-            .then(() => {
-            const data = { transition: true };
-            if (this.data.expanded) {
-                data.contentHeight = 'auto';
-            }
-            this.set(data);
+            .then(() => this.set({ contentHeight: 0 }));
         });
     },
-    methods: {
-        updateExpanded() {
-            if (!this.parent) {
-                return Promise.resolve();
-            }
-            const { value, accordion } = this.parent.data;
-            const { children = [] } = this.parent;
-            const { name } = this.data;
-            const index = children.indexOf(this);
-            const currentName = name == null ? index : name;
-            const expanded = accordion
-                ? value === currentName
-                : (value || []).some((name) => name === currentName);
-            const stack = [];
-            if (expanded !== this.data.expanded) {
-                stack.push(this.updateStyle(expanded));
-            }
-            stack.push(this.set({ index, expanded }));
-            return Promise.all(stack);
-        },
-        updateStyle(expanded) {
-            return this.getRect('.van-collapse-item__content')
-                .then((rect) => rect.height)
-                .then((height) => {
-                if (expanded) {
-                    return this.set({
-                        contentHeight: height ? `${height}px` : 'auto'
-                    });
-                }
-                return this.set({ contentHeight: `${height}px` })
-                    .then(nextTick)
-                    .then(() => this.set({ contentHeight: 0 }));
-            });
-        },
-        onClick() {
-            if (this.data.disabled) {
-                return;
-            }
-            const { name, expanded } = this.data;
-            const index = this.parent.children.indexOf(this);
-            const currentName = name == null ? index : name;
-            this.parent.switch(currentName, !expanded);
-        },
-        onTransitionEnd() {
-            if (this.data.expanded) {
-                this.set({
-                    contentHeight: 'auto'
-                });
-            }
-        }
-    }
+    onClick() {
+      if (this.data.disabled) {
+        return;
+      }
+      const { name, expanded } = this.data;
+      const index = this.parent.children.indexOf(this);
+      const currentName = name == null ? index : name;
+      this.parent.switch(currentName, !expanded);
+    },
+    onTransitionEnd() {
+      if (this.data.expanded) {
+        this.setData({
+          contentHeight: 'auto',
+        });
+      }
+    },
+  },
 });

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/collapse-item/index.wxss


+ 41 - 44
miniprogram_npm/vant-weapp/collapse/index.js

@@ -1,50 +1,47 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    relation: {
-        name: 'collapse-item',
-        type: 'descendant',
-        linked(child) {
-            this.children.push(child);
-        },
-        unlinked(child) {
-            this.children = this.children.filter((item) => item !== child);
-        }
+  relation: {
+    name: 'collapse-item',
+    type: 'descendant',
+    current: 'collapse',
+  },
+  props: {
+    value: {
+      type: null,
+      observer: 'updateExpanded',
     },
-    props: {
-        value: {
-            type: null,
-            observer: 'updateExpanded'
-        },
-        accordion: {
-            type: Boolean,
-            observer: 'updateExpanded'
-        },
-        border: {
-            type: Boolean,
-            value: true
-        }
+    accordion: {
+      type: Boolean,
+      observer: 'updateExpanded',
     },
-    beforeCreate() {
-        this.children = [];
+    border: {
+      type: Boolean,
+      value: true,
     },
-    methods: {
-        updateExpanded() {
-            this.children.forEach((child) => {
-                child.updateExpanded();
-            });
-        },
-        switch(name, expanded) {
-            const { accordion, value } = this.data;
-            if (!accordion) {
-                name = expanded
-                    ? (value || []).concat(name)
-                    : (value || []).filter((activeName) => activeName !== name);
-            }
-            else {
-                name = expanded ? name : '';
-            }
-            this.$emit('change', name);
-            this.$emit('input', name);
-        }
-    }
+  },
+  methods: {
+    updateExpanded() {
+      this.children.forEach((child) => {
+        child.updateExpanded();
+      });
+    },
+    switch(name, expanded) {
+      const { accordion, value } = this.data;
+      const changeItem = name;
+      if (!accordion) {
+        name = expanded
+          ? (value || []).concat(name)
+          : (value || []).filter((activeName) => activeName !== name);
+      } else {
+        name = expanded ? name : '';
+      }
+      if (expanded) {
+        this.$emit('open', changeItem);
+      } else {
+        this.$emit('close', changeItem);
+      }
+      this.$emit('change', name);
+      this.$emit('input', name);
+    },
+  },
 });

+ 4 - 1
miniprogram_npm/vant-weapp/common/color.d.ts

@@ -1,4 +1,7 @@
-export declare const RED = "#f44";
+export declare const RED = "#ee0a24";
 export declare const BLUE = "#1989fa";
+export declare const WHITE = "#fff";
 export declare const GREEN = "#07c160";
 export declare const ORANGE = "#ff976a";
+export declare const GRAY = "#323233";
+export declare const GRAY_DARK = "#969799";

+ 4 - 1
miniprogram_npm/vant-weapp/common/color.js

@@ -1,4 +1,7 @@
-export const RED = '#f44';
+export const RED = '#ee0a24';
 export const BLUE = '#1989fa';
+export const WHITE = '#fff';
 export const GREEN = '#07c160';
 export const ORANGE = '#ff976a';
+export const GRAY = '#323233';
+export const GRAY_DARK = '#969799';

+ 1 - 1
miniprogram_npm/vant-weapp/common/component.d.ts

@@ -1,3 +1,3 @@
 import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index';
-declare function VantComponent<Data, Props, Methods, Computed>(vantOptions?: VantComponentOptions<Data, Props, Methods, Computed, CombinedComponentInstance<Data, Props, Methods, Computed>>): void;
+declare function VantComponent<Data, Props, Methods>(vantOptions?: VantComponentOptions<Data, Props, Methods, CombinedComponentInstance<Data, Props, Methods>>): void;
 export { VantComponent };

+ 94 - 41
miniprogram_npm/vant-weapp/common/component.js

@@ -1,48 +1,101 @@
 import { basic } from '../mixins/basic';
-import { observe } from '../mixins/observer/index';
+const relationFunctions = {
+  ancestor: {
+    linked(parent) {
+      this.parent = parent;
+    },
+    unlinked() {
+      this.parent = null;
+    },
+  },
+  descendant: {
+    linked(child) {
+      this.children = this.children || [];
+      this.children.push(child);
+    },
+    unlinked(child) {
+      this.children = (this.children || []).filter((it) => it !== child);
+    },
+  },
+};
 function mapKeys(source, target, map) {
-    Object.keys(map).forEach(key => {
-        if (source[key]) {
-            target[map[key]] = source[key];
-        }
-    });
+  Object.keys(map).forEach((key) => {
+    if (source[key]) {
+      target[map[key]] = source[key];
+    }
+  });
+}
+function makeRelation(options, vantOptions, relation) {
+  const { type, name, linked, unlinked, linkChanged } = relation;
+  const { beforeCreate, destroyed } = vantOptions;
+  if (type === 'descendant') {
+    options.created = function () {
+      beforeCreate && beforeCreate.bind(this)();
+      this.children = this.children || [];
+    };
+    options.detached = function () {
+      this.children = [];
+      destroyed && destroyed.bind(this)();
+    };
+  }
+  options.relations = Object.assign(options.relations || {}, {
+    [`../${name}/index`]: {
+      type,
+      linked(node) {
+        relationFunctions[type].linked.bind(this)(node);
+        linked && linked.bind(this)(node);
+      },
+      linkChanged(node) {
+        linkChanged && linkChanged.bind(this)(node);
+      },
+      unlinked(node) {
+        relationFunctions[type].unlinked.bind(this)(node);
+        unlinked && unlinked.bind(this)(node);
+      },
+    },
+  });
 }
 function VantComponent(vantOptions = {}) {
-    const options = {};
-    mapKeys(vantOptions, options, {
-        data: 'data',
-        props: 'properties',
-        mixins: 'behaviors',
-        methods: 'methods',
-        beforeCreate: 'created',
-        created: 'attached',
-        mounted: 'ready',
-        relations: 'relations',
-        destroyed: 'detached',
-        classes: 'externalClasses'
+  const options = {};
+  mapKeys(vantOptions, options, {
+    data: 'data',
+    props: 'properties',
+    mixins: 'behaviors',
+    methods: 'methods',
+    beforeCreate: 'created',
+    created: 'attached',
+    mounted: 'ready',
+    relations: 'relations',
+    destroyed: 'detached',
+    classes: 'externalClasses',
+  });
+  const { relation } = vantOptions;
+  if (relation) {
+    makeRelation(options, vantOptions, relation);
+  }
+  // add default externalClasses
+  options.externalClasses = options.externalClasses || [];
+  options.externalClasses.push('custom-class');
+  // add default behaviors
+  options.behaviors = options.behaviors || [];
+  options.behaviors.push(basic);
+  // map field to form-field behavior
+  if (vantOptions.field) {
+    options.behaviors.push('wx://form-field');
+  }
+  if (options.properties) {
+    Object.keys(options.properties).forEach((name) => {
+      if (Array.isArray(options.properties[name])) {
+        // miniprogram do not allow multi type
+        options.properties[name] = null;
+      }
     });
-    const { relation } = vantOptions;
-    if (relation) {
-        options.relations = Object.assign(options.relations || {}, {
-            [`../${relation.name}/index`]: relation
-        });
-    }
-    // add default externalClasses
-    options.externalClasses = options.externalClasses || [];
-    options.externalClasses.push('custom-class');
-    // add default behaviors
-    options.behaviors = options.behaviors || [];
-    options.behaviors.push(basic);
-    // map field to form-field behavior
-    if (vantOptions.field) {
-        options.behaviors.push('wx://form-field');
-    }
-    // add default options
-    options.options = {
-        multipleSlots: true,
-        addGlobalClass: true
-    };
-    observe(vantOptions, options);
-    Component(options);
+  }
+  // add default options
+  options.options = {
+    multipleSlots: true,
+    addGlobalClass: true,
+  };
+  Component(options);
 }
 export { VantComponent };

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/common/index.wxss


+ 1 - 1
miniprogram_npm/vant-weapp/common/style/clearfix.wxss

@@ -1 +1 @@
-.van-clearfix:after{content:"";display:table;clear:both}
+.van-clearfix:after{display:table;clear:both;content:""}

+ 1 - 1
miniprogram_npm/vant-weapp/common/style/ellipsis.wxss

@@ -1 +1 @@
-.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}
+.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/common/style/hairline.wxss


+ 2 - 1
miniprogram_npm/vant-weapp/common/utils.d.ts

@@ -4,4 +4,5 @@ export declare function isObj(x: any): boolean;
 export declare function isNumber(value: any): boolean;
 export declare function range(num: number, min: number, max: number): number;
 export declare function nextTick(fn: Function): void;
-export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSuccessCallbackResult;
+export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSyncResult;
+export declare function addUnit(value?: string | number): string | undefined;

+ 8 - 1
miniprogram_npm/vant-weapp/common/utils.js

@@ -6,7 +6,7 @@ export function isObj(x) {
     return x !== null && (type === 'object' || type === 'function');
 }
 export function isNumber(value) {
-    return /^\d+$/.test(value);
+    return /^\d+(\.\d+)?$/.test(value);
 }
 export function range(num, min, max) {
     return Math.min(Math.max(num, min), max);
@@ -23,3 +23,10 @@ export function getSystemInfoSync() {
     }
     return systemInfo;
 }
+export function addUnit(value) {
+    if (!isDef(value)) {
+        return undefined;
+    }
+    value = String(value);
+    return isNumber(value) ? `${value}px` : value;
+}

+ 288 - 258
miniprogram_npm/vant-weapp/datetime-picker/index.js

@@ -3,285 +3,315 @@ import { isDef } from '../common/utils';
 import { pickerProps } from '../picker/shared';
 const currentYear = new Date().getFullYear();
 function isValidDate(date) {
-    return isDef(date) && !isNaN(new Date(date).getTime());
+  return isDef(date) && !isNaN(new Date(date).getTime());
 }
 function range(num, min, max) {
-    return Math.min(Math.max(num, min), max);
+  return Math.min(Math.max(num, min), max);
 }
 function padZero(val) {
-    return `00${val}`.slice(-2);
+  return `00${val}`.slice(-2);
 }
 function times(n, iteratee) {
-    let index = -1;
-    const result = Array(n < 0 ? 0 : n);
-    while (++index < n) {
-        result[index] = iteratee(index);
-    }
-    return result;
+  let index = -1;
+  const result = Array(n < 0 ? 0 : n);
+  while (++index < n) {
+    result[index] = iteratee(index);
+  }
+  return result;
 }
 function getTrueValue(formattedValue) {
-    if (!formattedValue)
-        return;
-    while (isNaN(parseInt(formattedValue, 10))) {
-        formattedValue = formattedValue.slice(1);
-    }
-    return parseInt(formattedValue, 10);
+  if (!formattedValue) return;
+  while (isNaN(parseInt(formattedValue, 10))) {
+    formattedValue = formattedValue.slice(1);
+  }
+  return parseInt(formattedValue, 10);
 }
 function getMonthEndDay(year, month) {
-    return 32 - new Date(year, month - 1, 32).getDate();
+  return 32 - new Date(year, month - 1, 32).getDate();
 }
 const defaultFormatter = (_, value) => value;
 VantComponent({
-    classes: ['active-class', 'toolbar-class', 'column-class'],
-    props: Object.assign({}, pickerProps, { formatter: {
-            type: Function,
-            value: defaultFormatter
-        }, value: null, type: {
-            type: String,
-            value: 'datetime'
-        }, showToolbar: {
-            type: Boolean,
-            value: true
-        }, minDate: {
-            type: Number,
-            value: new Date(currentYear - 10, 0, 1).getTime()
-        }, maxDate: {
-            type: Number,
-            value: new Date(currentYear + 10, 11, 31).getTime()
-        }, minHour: {
-            type: Number,
-            value: 0
-        }, maxHour: {
-            type: Number,
-            value: 23
-        }, minMinute: {
-            type: Number,
-            value: 0
-        }, maxMinute: {
-            type: Number,
-            value: 59
-        } }),
-    data: {
-        innerValue: Date.now(),
-        columns: []
+  classes: ['active-class', 'toolbar-class', 'column-class'],
+  props: Object.assign(Object.assign({}, pickerProps), {
+    value: {
+      type: null,
+      observer: 'updateValue',
     },
-    watch: {
-        value: 'updateValue',
-        type: 'updateValue',
-        minDate: 'updateValue',
-        maxDate: 'updateValue',
-        minHour: 'updateValue',
-        maxHour: 'updateValue',
-        minMinute: 'updateValue',
-        maxMinute: 'updateValue'
+    filter: null,
+    type: {
+      type: String,
+      value: 'datetime',
+      observer: 'updateValue',
     },
-    methods: {
-        updateValue() {
-            const { data } = this;
-            const val = this.correctValue(this.data.value);
-            const isEqual = val === data.innerValue;
-            if (!isEqual) {
-                this.updateColumnValue(val).then(() => {
-                    this.$emit('input', val);
-                });
-            }
-            else {
-                this.updateColumns();
-            }
-        },
-        getPicker() {
-            if (this.picker == null) {
-                this.picker = this.selectComponent('.van-datetime-picker');
-                const { picker } = this;
-                const { setColumnValues } = picker;
-                picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]);
-            }
-            return this.picker;
-        },
-        updateColumns() {
-            const { formatter = defaultFormatter } = this.data;
-            const results = this.getRanges().map(({ type, range }) => {
-                const values = times(range[1] - range[0] + 1, index => {
-                    let value = range[0] + index;
-                    value = type === 'year' ? `${value}` : padZero(value);
-                    return formatter(type, value);
-                });
-                return { values };
-            });
-            return this.set({ columns: results });
-        },
-        getRanges() {
-            const { data } = this;
-            if (data.type === 'time') {
-                return [
-                    {
-                        type: 'hour',
-                        range: [data.minHour, data.maxHour]
-                    },
-                    {
-                        type: 'minute',
-                        range: [data.minMinute, data.maxMinute]
-                    }
-                ];
-            }
-            const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = this.getBoundary('max', data.innerValue);
-            const { minYear, minDate, minMonth, minHour, minMinute } = this.getBoundary('min', data.innerValue);
-            const result = [
-                {
-                    type: 'year',
-                    range: [minYear, maxYear]
-                },
-                {
-                    type: 'month',
-                    range: [minMonth, maxMonth]
-                },
-                {
-                    type: 'day',
-                    range: [minDate, maxDate]
-                },
-                {
-                    type: 'hour',
-                    range: [minHour, maxHour]
-                },
-                {
-                    type: 'minute',
-                    range: [minMinute, maxMinute]
-                }
-            ];
-            if (data.type === 'date')
-                result.splice(3, 2);
-            if (data.type === 'year-month')
-                result.splice(2, 3);
-            return result;
-        },
-        correctValue(value) {
-            const { data } = this;
-            // validate value
-            const isDateType = data.type !== 'time';
-            if (isDateType && !isValidDate(value)) {
-                value = data.minDate;
-            }
-            else if (!isDateType && !value) {
-                const { minHour } = data;
-                value = `${padZero(minHour)}:00`;
-            }
-            // time type
-            if (!isDateType) {
-                let [hour, minute] = value.split(':');
-                hour = padZero(range(hour, data.minHour, data.maxHour));
-                minute = padZero(range(minute, data.minMinute, data.maxMinute));
-                return `${hour}:${minute}`;
-            }
-            // date type
-            value = Math.max(value, data.minDate);
-            value = Math.min(value, data.maxDate);
-            return value;
+    showToolbar: {
+      type: Boolean,
+      value: true,
+    },
+    formatter: {
+      type: null,
+      value: defaultFormatter,
+    },
+    minDate: {
+      type: Number,
+      value: new Date(currentYear - 10, 0, 1).getTime(),
+      observer: 'updateValue',
+    },
+    maxDate: {
+      type: Number,
+      value: new Date(currentYear + 10, 11, 31).getTime(),
+      observer: 'updateValue',
+    },
+    minHour: {
+      type: Number,
+      value: 0,
+      observer: 'updateValue',
+    },
+    maxHour: {
+      type: Number,
+      value: 23,
+      observer: 'updateValue',
+    },
+    minMinute: {
+      type: Number,
+      value: 0,
+      observer: 'updateValue',
+    },
+    maxMinute: {
+      type: Number,
+      value: 59,
+      observer: 'updateValue',
+    },
+  }),
+  data: {
+    innerValue: Date.now(),
+    columns: [],
+  },
+  methods: {
+    updateValue() {
+      const { data } = this;
+      const val = this.correctValue(this.data.value);
+      const isEqual = val === data.innerValue;
+      if (!isEqual) {
+        this.updateColumnValue(val).then(() => {
+          this.$emit('input', val);
+        });
+      } else {
+        this.updateColumns();
+      }
+    },
+    getPicker() {
+      if (this.picker == null) {
+        this.picker = this.selectComponent('.van-datetime-picker');
+        const { picker } = this;
+        const { setColumnValues } = picker;
+        picker.setColumnValues = (...args) =>
+          setColumnValues.apply(picker, [...args, false]);
+      }
+      return this.picker;
+    },
+    updateColumns() {
+      const { formatter = defaultFormatter } = this.data;
+      const results = this.getOriginColumns().map((column) => ({
+        values: column.values.map((value) => formatter(column.type, value)),
+      }));
+      return this.set({ columns: results });
+    },
+    getOriginColumns() {
+      const { filter } = this.data;
+      const results = this.getRanges().map(({ type, range }) => {
+        let values = times(range[1] - range[0] + 1, (index) => {
+          let value = range[0] + index;
+          value = type === 'year' ? `${value}` : padZero(value);
+          return value;
+        });
+        if (filter) {
+          values = filter(type, values);
+        }
+        return { type, values };
+      });
+      return results;
+    },
+    getRanges() {
+      const { data } = this;
+      if (data.type === 'time') {
+        return [
+          {
+            type: 'hour',
+            range: [data.minHour, data.maxHour],
+          },
+          {
+            type: 'minute',
+            range: [data.minMinute, data.maxMinute],
+          },
+        ];
+      }
+      const {
+        maxYear,
+        maxDate,
+        maxMonth,
+        maxHour,
+        maxMinute,
+      } = this.getBoundary('max', data.innerValue);
+      const {
+        minYear,
+        minDate,
+        minMonth,
+        minHour,
+        minMinute,
+      } = this.getBoundary('min', data.innerValue);
+      const result = [
+        {
+          type: 'year',
+          range: [minYear, maxYear],
         },
-        getBoundary(type, innerValue) {
-            const value = new Date(innerValue);
-            const boundary = new Date(this.data[`${type}Date`]);
-            const year = boundary.getFullYear();
-            let month = 1;
-            let date = 1;
-            let hour = 0;
-            let minute = 0;
-            if (type === 'max') {
-                month = 12;
-                date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
-                hour = 23;
-                minute = 59;
-            }
-            if (value.getFullYear() === year) {
-                month = boundary.getMonth() + 1;
-                if (value.getMonth() + 1 === month) {
-                    date = boundary.getDate();
-                    if (value.getDate() === date) {
-                        hour = boundary.getHours();
-                        if (value.getHours() === hour) {
-                            minute = boundary.getMinutes();
-                        }
-                    }
-                }
-            }
-            return {
-                [`${type}Year`]: year,
-                [`${type}Month`]: month,
-                [`${type}Date`]: date,
-                [`${type}Hour`]: hour,
-                [`${type}Minute`]: minute
-            };
+        {
+          type: 'month',
+          range: [minMonth, maxMonth],
         },
-        onCancel() {
-            this.$emit('cancel');
+        {
+          type: 'day',
+          range: [minDate, maxDate],
         },
-        onConfirm() {
-            this.$emit('confirm', this.data.innerValue);
+        {
+          type: 'hour',
+          range: [minHour, maxHour],
         },
-        onChange() {
-            const { data } = this;
-            let value;
-            const picker = this.getPicker();
-            if (data.type === 'time') {
-                const indexes = picker.getIndexes();
-                value = `${indexes[0] + data.minHour}:${indexes[1] + data.minMinute}`;
-            }
-            else {
-                const values = picker.getValues();
-                const year = getTrueValue(values[0]);
-                const month = getTrueValue(values[1]);
-                const maxDate = getMonthEndDay(year, month);
-                let date = getTrueValue(values[2]);
-                if (data.type === 'year-month') {
-                    date = 1;
-                }
-                date = date > maxDate ? maxDate : date;
-                let hour = 0;
-                let minute = 0;
-                if (data.type === 'datetime') {
-                    hour = getTrueValue(values[3]);
-                    minute = getTrueValue(values[4]);
-                }
-                value = new Date(year, month - 1, date, hour, minute);
-            }
-            value = this.correctValue(value);
-            this.updateColumnValue(value).then(() => {
-                this.$emit('input', value);
-                this.$emit('change', picker);
-            });
+        {
+          type: 'minute',
+          range: [minMinute, maxMinute],
         },
-        updateColumnValue(value) {
-            let values = [];
-            const { type, formatter = defaultFormatter } = this.data;
-            const picker = this.getPicker();
-            if (type === 'time') {
-                const pair = value.split(':');
-                values = [
-                    formatter('hour', pair[0]),
-                    formatter('minute', pair[1])
-                ];
-            }
-            else {
-                const date = new Date(value);
-                values = [
-                    formatter('year', `${date.getFullYear()}`),
-                    formatter('month', padZero(date.getMonth() + 1))
-                ];
-                if (type === 'date') {
-                    values.push(formatter('day', padZero(date.getDate())));
-                }
-                if (type === 'datetime') {
-                    values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes())));
-                }
+      ];
+      if (data.type === 'date') result.splice(3, 2);
+      if (data.type === 'year-month') result.splice(2, 3);
+      return result;
+    },
+    correctValue(value) {
+      const { data } = this;
+      // validate value
+      const isDateType = data.type !== 'time';
+      if (isDateType && !isValidDate(value)) {
+        value = data.minDate;
+      } else if (!isDateType && !value) {
+        const { minHour } = data;
+        value = `${padZero(minHour)}:00`;
+      }
+      // time type
+      if (!isDateType) {
+        let [hour, minute] = value.split(':');
+        hour = padZero(range(hour, data.minHour, data.maxHour));
+        minute = padZero(range(minute, data.minMinute, data.maxMinute));
+        return `${hour}:${minute}`;
+      }
+      // date type
+      value = Math.max(value, data.minDate);
+      value = Math.min(value, data.maxDate);
+      return value;
+    },
+    getBoundary(type, innerValue) {
+      const value = new Date(innerValue);
+      const boundary = new Date(this.data[`${type}Date`]);
+      const year = boundary.getFullYear();
+      let month = 1;
+      let date = 1;
+      let hour = 0;
+      let minute = 0;
+      if (type === 'max') {
+        month = 12;
+        date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
+        hour = 23;
+        minute = 59;
+      }
+      if (value.getFullYear() === year) {
+        month = boundary.getMonth() + 1;
+        if (value.getMonth() + 1 === month) {
+          date = boundary.getDate();
+          if (value.getDate() === date) {
+            hour = boundary.getHours();
+            if (value.getHours() === hour) {
+              minute = boundary.getMinutes();
             }
-            return this.set({ innerValue: value })
-                .then(() => this.updateColumns())
-                .then(() => picker.setValues(values));
+          }
         }
+      }
+      return {
+        [`${type}Year`]: year,
+        [`${type}Month`]: month,
+        [`${type}Date`]: date,
+        [`${type}Hour`]: hour,
+        [`${type}Minute`]: minute,
+      };
     },
-    created() {
-        const innerValue = this.correctValue(this.data.value);
-        this.updateColumnValue(innerValue).then(() => {
-            this.$emit('input', innerValue);
-        });
-    }
+    onCancel() {
+      this.$emit('cancel');
+    },
+    onConfirm() {
+      this.$emit('confirm', this.data.innerValue);
+    },
+    onChange() {
+      const { data } = this;
+      let value;
+      const picker = this.getPicker();
+      if (data.type === 'time') {
+        const indexes = picker.getIndexes();
+        value = `${+data.columns[0].values[indexes[0]]}:${+data.columns[1]
+          .values[indexes[1]]}`;
+      } else {
+        const values = picker.getValues();
+        const year = getTrueValue(values[0]);
+        const month = getTrueValue(values[1]);
+        const maxDate = getMonthEndDay(year, month);
+        let date = getTrueValue(values[2]);
+        if (data.type === 'year-month') {
+          date = 1;
+        }
+        date = date > maxDate ? maxDate : date;
+        let hour = 0;
+        let minute = 0;
+        if (data.type === 'datetime') {
+          hour = getTrueValue(values[3]);
+          minute = getTrueValue(values[4]);
+        }
+        value = new Date(year, month - 1, date, hour, minute);
+      }
+      value = this.correctValue(value);
+      this.updateColumnValue(value).then(() => {
+        this.$emit('input', value);
+        this.$emit('change', picker);
+      });
+    },
+    updateColumnValue(value) {
+      let values = [];
+      const { type, formatter = defaultFormatter } = this.data;
+      const picker = this.getPicker();
+      if (type === 'time') {
+        const pair = value.split(':');
+        values = [formatter('hour', pair[0]), formatter('minute', pair[1])];
+      } else {
+        const date = new Date(value);
+        values = [
+          formatter('year', `${date.getFullYear()}`),
+          formatter('month', padZero(date.getMonth() + 1)),
+        ];
+        if (type === 'date') {
+          values.push(formatter('day', padZero(date.getDate())));
+        }
+        if (type === 'datetime') {
+          values.push(
+            formatter('day', padZero(date.getDate())),
+            formatter('hour', padZero(date.getHours())),
+            formatter('minute', padZero(date.getMinutes()))
+          );
+        }
+      }
+      return this.set({ innerValue: value })
+        .then(() => this.updateColumns())
+        .then(() => picker.setValues(values));
+    },
+  },
+  created() {
+    const innerValue = this.correctValue(this.data.value);
+    this.updateColumnValue(innerValue).then(() => {
+      this.$emit('input', innerValue);
+    });
+  },
 });

+ 5 - 8
miniprogram_npm/vant-weapp/definitions/index.d.ts

@@ -3,22 +3,19 @@ import { Weapp } from './weapp';
 declare type RecordToAny<T> = {
     [K in keyof T]: any;
 };
-declare type RecordToReturn<T> = {
-    [P in keyof T]: T[P] extends (...args: any[]) => any ? ReturnType<T[P]> : T[P];
+export declare type CombinedComponentInstance<Data, Props, Methods> = Methods & WechatMiniprogram.Component.TrivialInstance & Weapp.FormField & {
+    data: Data & RecordToAny<Props>;
 };
-export declare type CombinedComponentInstance<Data, Props, Methods, Computed> = Methods & WechatMiniprogram.Component.TrivialInstance & Weapp.FormField & {
-    data: Data & RecordToReturn<Computed> & RecordToAny<Props>;
-};
-export interface VantComponentOptions<Data, Props, Methods, Computed, Instance> {
+export interface VantComponentOptions<Data, Props, Methods, Instance> {
     data?: Data;
     field?: boolean;
     classes?: string[];
     mixins?: string[];
     props?: Props & Weapp.PropertyOption;
-    watch?: Weapp.WatchOption<Instance>;
-    computed?: Computed & Weapp.ComputedOption<Instance>;
     relation?: Weapp.RelationOption<Instance> & {
+        type: 'ancestor' | 'descendant';
         name: string;
+        current: string;
     };
     relations?: {
         [componentName: string]: Weapp.RelationOption<Instance>;

+ 8 - 13
miniprogram_npm/vant-weapp/definitions/weapp.d.ts

@@ -1,6 +1,6 @@
 /// <reference types="miniprogram-api-typings" />
 export declare namespace Weapp {
-    interface FormField {
+    export interface FormField {
         data: {
             name: string;
             value: any;
@@ -13,7 +13,7 @@ export declare namespace Weapp {
             [key: string]: any;
         };
     }
-    interface Event {
+    export interface Event {
         /**
          * 代表事件的类型。
          */
@@ -57,14 +57,14 @@ export declare namespace Weapp {
          */
         clientY: number;
     }
-    interface TouchEvent extends Event {
+    export interface TouchEvent extends Event {
         touches: Array<Touch>;
         changedTouches: Array<Touch>;
     }
     /**
      * relation定义,miniprogram-api-typings缺少this定义
      */
-    interface RelationOption<Instance> {
+    export interface RelationOption<Instance> {
         /** 目标组件的相对关系 */
         type: 'parent' | 'child' | 'ancestor' | 'descendant';
         /** 关系生命周期函数,当关系被建立在页面节点树中时触发,触发时机在组件attached生命周期之后 */
@@ -80,23 +80,17 @@ export declare namespace Weapp {
      * obverser定义,miniprogram-api-typings缺少this定义
      */
     type Observer<Instance, T> = (this: Instance, newVal: T, oldVal: T, changedPath: Array<string | number>) => void;
-    /**
-     * watch定义
-     */
-    interface WatchOption<Instance> {
-        [name: string]: string | Observer<Instance, any>;
-    }
     /**
      * methods定义,miniprogram-api-typings缺少this定义
      */
-    interface MethodOption<Instance> {
+    export interface MethodOption<Instance> {
         [name: string]: (this: Instance, ...args: any[]) => any;
     }
-    interface ComputedOption<Instance> {
+    export interface ComputedOption<Instance> {
         [name: string]: (this: Instance) => any;
     }
     type PropertyType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | FunctionConstructor | null;
-    interface PropertyOption {
+    export interface PropertyOption {
         [name: string]: PropertyType | PropertyType[] | {
             /** 属性类型 */
             type: PropertyType | PropertyType[];
@@ -108,4 +102,5 @@ export declare namespace Weapp {
             optionalTypes?: PropertyType[];
         };
     }
+    export {};
 }

+ 2 - 0
miniprogram_npm/vant-weapp/dialog/dialog.d.ts

@@ -4,6 +4,7 @@ declare type DialogOptions = {
     lang?: string;
     show?: boolean;
     title?: string;
+    width?: string | number;
     zIndex?: number;
     context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
     message?: string;
@@ -16,6 +17,7 @@ declare type DialogOptions = {
     asyncClose?: boolean;
     businessId?: number;
     sessionFrom?: string;
+    overlayStyle?: string;
     appParameter?: string;
     messageAlign?: string;
     sendMessageImg?: string;

+ 51 - 45
miniprogram_npm/vant-weapp/dialog/dialog.js

@@ -1,61 +1,67 @@
 let queue = [];
 function getContext() {
-    const pages = getCurrentPages();
-    return pages[pages.length - 1];
+  const pages = getCurrentPages();
+  return pages[pages.length - 1];
 }
-const Dialog = options => {
-    options = Object.assign({}, Dialog.currentOptions, options);
-    return new Promise((resolve, reject) => {
-        const context = options.context || getContext();
-        const dialog = context.selectComponent(options.selector);
-        delete options.context;
-        delete options.selector;
-        if (dialog) {
-            dialog.set(Object.assign({ onCancel: reject, onConfirm: resolve }, options));
-            queue.push(dialog);
-        }
-        else {
-            console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
-        }
-    });
+const Dialog = (options) => {
+  options = Object.assign(Object.assign({}, Dialog.currentOptions), options);
+  return new Promise((resolve, reject) => {
+    const context = options.context || getContext();
+    const dialog = context.selectComponent(options.selector);
+    delete options.context;
+    delete options.selector;
+    if (dialog) {
+      dialog.setData(
+        Object.assign({ onCancel: reject, onConfirm: resolve }, options)
+      );
+      queue.push(dialog);
+    } else {
+      console.warn(
+        '未找到 van-dialog 节点,请确认 selector 及 context 是否正确'
+      );
+    }
+  });
 };
 Dialog.defaultOptions = {
-    show: true,
-    title: '',
-    message: '',
-    zIndex: 100,
-    overlay: true,
-    className: '',
-    customStyle: '',
-    asyncClose: false,
-    messageAlign: '',
-    transition: 'scale',
-    selector: '#van-dialog',
-    confirmButtonText: '确认',
-    cancelButtonText: '取消',
-    showConfirmButton: true,
-    showCancelButton: false,
-    closeOnClickOverlay: false,
-    confirmButtonOpenType: ''
+  show: true,
+  title: '',
+  width: null,
+  message: '',
+  zIndex: 100,
+  overlay: true,
+  selector: '#van-dialog',
+  className: '',
+  asyncClose: false,
+  transition: 'scale',
+  customStyle: '',
+  messageAlign: '',
+  overlayStyle: '',
+  confirmButtonText: '确认',
+  cancelButtonText: '取消',
+  showConfirmButton: true,
+  showCancelButton: false,
+  closeOnClickOverlay: false,
+  confirmButtonOpenType: '',
 };
 Dialog.alert = Dialog;
-Dialog.confirm = options => Dialog(Object.assign({ showCancelButton: true }, options));
+Dialog.confirm = (options) =>
+  Dialog(Object.assign({ showCancelButton: true }, options));
 Dialog.close = () => {
-    queue.forEach(dialog => {
-        dialog.close();
-    });
-    queue = [];
+  queue.forEach((dialog) => {
+    dialog.close();
+  });
+  queue = [];
 };
 Dialog.stopLoading = () => {
-    queue.forEach(dialog => {
-        dialog.stopLoading();
-    });
+  queue.forEach((dialog) => {
+    dialog.stopLoading();
+  });
 };
-Dialog.setDefaultOptions = options => {
-    Object.assign(Dialog.currentOptions, options);
+Dialog.setDefaultOptions = (options) => {
+  Object.assign(Dialog.currentOptions, options);
 };
 Dialog.resetDefaultOptions = () => {
-    Dialog.currentOptions = Object.assign({}, Dialog.defaultOptions);
+  Dialog.currentOptions = Object.assign({}, Dialog.defaultOptions);
 };
 Dialog.resetDefaultOptions();
 export default Dialog;

+ 104 - 90
miniprogram_npm/vant-weapp/dialog/index.js

@@ -1,98 +1,112 @@
 import { VantComponent } from '../common/component';
 import { button } from '../mixins/button';
 import { openType } from '../mixins/open-type';
+import { GRAY, BLUE } from '../common/color';
 VantComponent({
-    mixins: [button, openType],
-    props: {
-        show: Boolean,
-        title: String,
-        message: String,
-        useSlot: Boolean,
-        className: String,
-        customStyle: String,
-        asyncClose: Boolean,
-        messageAlign: String,
-        showCancelButton: Boolean,
-        closeOnClickOverlay: Boolean,
-        confirmButtonOpenType: String,
-        zIndex: {
-            type: Number,
-            value: 2000
-        },
-        confirmButtonText: {
-            type: String,
-            value: '确认'
-        },
-        cancelButtonText: {
-            type: String,
-            value: '取消'
-        },
-        showConfirmButton: {
-            type: Boolean,
-            value: true
-        },
-        overlay: {
-            type: Boolean,
-            value: true
-        },
-        transition: {
-            type: String,
-            value: 'scale'
-        }
+  mixins: [button, openType],
+  props: {
+    show: {
+      type: Boolean,
+      observer(show) {
+        !show && this.stopLoading();
+      },
+    },
+    title: String,
+    message: String,
+    useSlot: Boolean,
+    className: String,
+    customStyle: String,
+    asyncClose: Boolean,
+    messageAlign: String,
+    overlayStyle: String,
+    useTitleSlot: Boolean,
+    showCancelButton: Boolean,
+    closeOnClickOverlay: Boolean,
+    confirmButtonOpenType: String,
+    width: null,
+    zIndex: {
+      type: Number,
+      value: 2000,
+    },
+    confirmButtonText: {
+      type: String,
+      value: '确认',
+    },
+    cancelButtonText: {
+      type: String,
+      value: '取消',
+    },
+    confirmButtonColor: {
+      type: String,
+      value: BLUE,
+    },
+    cancelButtonColor: {
+      type: String,
+      value: GRAY,
+    },
+    showConfirmButton: {
+      type: Boolean,
+      value: true,
+    },
+    overlay: {
+      type: Boolean,
+      value: true,
+    },
+    transition: {
+      type: String,
+      value: 'scale',
     },
-    data: {
+  },
+  data: {
+    loading: {
+      confirm: false,
+      cancel: false,
+    },
+  },
+  methods: {
+    onConfirm() {
+      this.handleAction('confirm');
+    },
+    onCancel() {
+      this.handleAction('cancel');
+    },
+    onClickOverlay() {
+      this.onClose('overlay');
+    },
+    handleAction(action) {
+      if (this.data.asyncClose) {
+        this.setData({
+          [`loading.${action}`]: true,
+        });
+      }
+      this.onClose(action);
+    },
+    close() {
+      this.setData({
+        show: false,
+      });
+    },
+    stopLoading() {
+      this.setData({
         loading: {
-            confirm: false,
-            cancel: false
-        }
-    },
-    watch: {
-        show(show) {
-            !show && this.stopLoading();
-        }
-    },
-    methods: {
-        onConfirm() {
-            this.handleAction('confirm');
-        },
-        onCancel() {
-            this.handleAction('cancel');
+          confirm: false,
+          cancel: false,
         },
-        onClickOverlay() {
-            this.onClose('overlay');
-        },
-        handleAction(action) {
-            if (this.data.asyncClose) {
-                this.set({
-                    [`loading.${action}`]: true
-                });
-            }
-            this.onClose(action);
-        },
-        close() {
-            this.set({
-                show: false
-            });
-        },
-        stopLoading() {
-            this.set({
-                loading: {
-                    confirm: false,
-                    cancel: false
-                }
-            });
-        },
-        onClose(action) {
-            if (!this.data.asyncClose) {
-                this.close();
-            }
-            this.$emit('close', action);
-            // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading
-            this.$emit(action, { dialog: this });
-            const callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel'];
-            if (callback) {
-                callback(this);
-            }
-        }
-    }
+      });
+    },
+    onClose(action) {
+      if (!this.data.asyncClose) {
+        this.close();
+      }
+      this.$emit('close', action);
+      // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading
+      this.$emit(action, { dialog: this });
+      const callback = this.data[
+        action === 'confirm' ? 'onConfirm' : 'onCancel'
+      ];
+      if (callback) {
+        callback(this);
+      }
+    },
+  },
 });

+ 11 - 5
miniprogram_npm/vant-weapp/dialog/index.wxml

@@ -1,18 +1,22 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
 <van-popup
   show="{{ show }}"
   z-index="{{ zIndex }}"
   overlay="{{ overlay }}"
-  custom-class="van-dialog {{ className }}"
   transition="{{ transition }}"
-  custom-style="{{ customStyle }}"
+  custom-class="van-dialog {{ className }}"
+  custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}"
+  overlay-style="{{ overlayStyle }}"
   close-on-click-overlay="{{ closeOnClickOverlay }}"
   bind:close="onClickOverlay"
 >
   <view
-    wx:if="{{ title }}"
+    wx:if="{{ title || useTitleSlot  }}"
     class="van-dialog__header {{ message || useSlot ? '' : 'van-dialog--isolated' }}"
   >
-    {{ title }}
+    <slot wx:if="{{ useTitleSlot }}" name="title" />
+    <block wx:elif="{{ title }}">{{ title }}</block>
   </view>
 
   <slot wx:if="{{ useSlot }}" />
@@ -20,7 +24,7 @@
     wx:elif="{{ message }}"
     class="van-dialog__message {{ title ? 'van-dialog__message--has-title' : '' }} {{ messageAlign ? 'van-dialog__message--' + messageAlign : '' }}"
   >
-    <text>{{ message }}</text>
+    <text class="van-dialog__message-text">{{ message }}</text>
   </view>
 
   <view class="van-hairline--top van-dialog__footer">
@@ -30,6 +34,7 @@
       loading="{{ loading.cancel }}"
       class="van-dialog__button van-hairline--right"
       custom-class="van-dialog__cancel"
+      custom-style="color: {{ cancelButtonColor }}"
       bind:click="onCancel"
     >
       {{ cancelButtonText }}
@@ -40,6 +45,7 @@
       class="van-dialog__button"
       loading="{{ loading.confirm }}"
       custom-class="van-dialog__confirm"
+      custom-style="color: {{ confirmButtonColor }}"
 
       open-type="{{ confirmButtonOpenType }}"
       lang="{{ lang }}"

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/dialog/index.wxss


+ 32 - 34
miniprogram_npm/vant-weapp/divider/index.js

@@ -1,35 +1,33 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var component_1 = require("../common/component");
-component_1.VantComponent({
-    props: {
-        dashed: {
-            type: Boolean,
-            value: false
-        },
-        hairline: {
-            type: Boolean,
-            value: false
-        },
-        contentPosition: {
-            type: String,
-            value: ''
-        },
-        fontSize: {
-            type: Number,
-            value: ''
-        },
-        borderColor: {
-            type: String,
-            value: ''
-        },
-        textColor: {
-            type: String,
-            value: ''
-        },
-        customStyle: {
-            type: String,
-            value: ''
-        }
-    }
+import { VantComponent } from '../common/component';
+VantComponent({
+  props: {
+    dashed: {
+      type: Boolean,
+      value: false,
+    },
+    hairline: {
+      type: Boolean,
+      value: false,
+    },
+    contentPosition: {
+      type: String,
+      value: '',
+    },
+    fontSize: {
+      type: Number,
+      value: '',
+    },
+    borderColor: {
+      type: String,
+      value: '',
+    },
+    textColor: {
+      type: String,
+      value: '',
+    },
+    customStyle: {
+      type: String,
+      value: '',
+    },
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/divider/index.json

@@ -1,4 +1,4 @@
 {
   "component": true,
   "usingComponents": {}
-}
+}

+ 120 - 100
miniprogram_npm/vant-weapp/field/index.js

@@ -1,105 +1,125 @@
 import { VantComponent } from '../common/component';
-import { getSystemInfoSync } from '../common/utils';
+import { commonProps, inputProps, textareaProps } from './props';
+import { canIUseModel } from '../common/version';
 VantComponent({
-    field: true,
-    classes: ['input-class', 'right-icon-class'],
-    props: {
-        size: String,
-        icon: String,
-        label: String,
-        error: Boolean,
-        fixed: Boolean,
-        focus: Boolean,
-        center: Boolean,
-        isLink: Boolean,
-        leftIcon: String,
-        rightIcon: String,
-        disabled: Boolean,
-        autosize: Boolean,
-        readonly: Boolean,
-        required: Boolean,
-        password: Boolean,
-        iconClass: String,
-        clearable: Boolean,
-        inputAlign: String,
-        customStyle: String,
-        confirmType: String,
-        confirmHold: Boolean,
-        errorMessage: String,
-        placeholder: String,
-        placeholderStyle: String,
-        errorMessageAlign: String,
-        selectionEnd: {
-            type: Number,
-            value: -1
-        },
-        selectionStart: {
-            type: Number,
-            value: -1
-        },
-        showConfirmBar: {
-            type: Boolean,
-            value: true
-        },
-        adjustPosition: {
-            type: Boolean,
-            value: true
-        },
-        cursorSpacing: {
-            type: Number,
-            value: 50
-        },
-        maxlength: {
-            type: Number,
-            value: -1
-        },
-        type: {
-            type: String,
-            value: 'text'
-        },
-        border: {
-            type: Boolean,
-            value: true
-        },
-        titleWidth: {
-            type: String,
-            value: '90px'
-        }
+  field: true,
+  classes: ['input-class', 'right-icon-class'],
+  props: Object.assign(
+    Object.assign(
+      Object.assign(Object.assign({}, commonProps), inputProps),
+      textareaProps
+    ),
+    {
+      size: String,
+      icon: String,
+      label: String,
+      error: Boolean,
+      center: Boolean,
+      isLink: Boolean,
+      leftIcon: String,
+      rightIcon: String,
+      autosize: [Boolean, Object],
+      readonly: {
+        type: Boolean,
+        observer: 'setShowClear',
+      },
+      required: Boolean,
+      iconClass: String,
+      clearable: {
+        type: Boolean,
+        observer: 'setShowClear',
+      },
+      clickable: Boolean,
+      inputAlign: String,
+      customStyle: String,
+      errorMessage: String,
+      arrowDirection: String,
+      showWordLimit: Boolean,
+      errorMessageAlign: String,
+      border: {
+        type: Boolean,
+        value: true,
+      },
+      titleWidth: {
+        type: String,
+        value: '90px',
+      },
+    }
+  ),
+  data: {
+    focused: false,
+    innerValue: '',
+    showClear: false,
+  },
+  created() {
+    this.value = this.data.value;
+    this.setData({ innerValue: this.value });
+  },
+  methods: {
+    onInput(event) {
+      const { value = '' } = event.detail || {};
+      this.value = value;
+      this.setShowClear();
+      this.emitChange();
     },
-    data: {
-        focused: false,
-        system: getSystemInfoSync().system.split(' ').shift().toLowerCase()
+    onFocus(event) {
+      this.focused = true;
+      this.setShowClear();
+      this.$emit('focus', event.detail);
     },
-    methods: {
-        onInput(event) {
-            const { value = '' } = event.detail || {};
-            this.set({ value }, () => {
-                this.emitChange(value);
-            });
-        },
-        onFocus(event) {
-            this.set({ focused: true });
-            this.$emit('focus', event.detail);
-        },
-        onBlur(event) {
-            this.set({ focused: false });
-            this.$emit('blur', event.detail);
-        },
-        onClickIcon() {
-            this.$emit('click-icon');
-        },
-        onClear() {
-            this.set({ value: '' }, () => {
-                this.emitChange('');
-                this.$emit('clear', '');
-            });
-        },
-        onConfirm() {
-            this.$emit('confirm', this.data.value);
-        },
-        emitChange(value) {
-            this.$emit('input', value);
-            this.$emit('change', value);
-        }
-    }
+    onBlur(event) {
+      this.focused = false;
+      this.setShowClear();
+      this.$emit('blur', event.detail);
+    },
+    onClickIcon() {
+      this.$emit('click-icon');
+    },
+    onClear() {
+      this.setData({ innerValue: '' });
+      this.value = '';
+      this.setShowClear();
+      wx.nextTick(() => {
+        this.emitChange();
+        this.$emit('clear', '');
+      });
+    },
+    onConfirm(event) {
+      const { value = '' } = event.detail || {};
+      this.value = value;
+      this.setShowClear();
+      this.$emit('confirm', value);
+    },
+    setValue(value) {
+      this.value = value;
+      this.setShowClear();
+      if (value === '') {
+        this.setData({ innerValue: '' });
+      }
+      this.emitChange();
+    },
+    onLineChange(event) {
+      this.$emit('linechange', event.detail);
+    },
+    onKeyboardHeightChange(event) {
+      this.$emit('keyboardheightchange', event.detail);
+    },
+    emitChange() {
+      if (canIUseModel()) {
+        this.setData({ value: this.value });
+      }
+      wx.nextTick(() => {
+        this.$emit('input', this.value);
+        this.$emit('change', this.value);
+      });
+    },
+    setShowClear() {
+      const { clearable, readonly } = this.data;
+      const { focused, value } = this;
+      this.setData({
+        showClear: !!clearable && !!focused && !!value && !readonly,
+      });
+    },
+    noop() {},
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/field/index.json

@@ -4,4 +4,4 @@
     "van-cell": "../cell/index",
     "van-icon": "../icon/index"
   }
-}
+}

+ 32 - 17
miniprogram_npm/vant-weapp/field/index.wxml

@@ -1,41 +1,51 @@
 <wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
 
 <van-cell
+  size="{{ size }}"
   icon="{{ leftIcon }}"
   title="{{ label }}"
   center="{{ center }}"
   border="{{ border }}"
   is-link="{{ isLink }}"
   required="{{ required }}"
-  custom-style="{{ customStyle }}"
+  clickable="{{ clickable }}"
   title-width="{{ titleWidth }}"
+  custom-style="{{ customStyle }}"
+  arrow-direction="{{ arrowDirection }}"
   custom-class="van-field"
-  size="{{ size }}"
 >
   <slot name="left-icon" slot="icon" />
   <slot name="label" slot="title" />
-  <view class="{{ utils.bem('field__body', [type, system]) }}">
+  <view class="{{ utils.bem('field__body', [type]) }}">
     <textarea
       wx:if="{{ type === 'textarea' }}"
       class="input-class {{ utils.bem('field__input', [inputAlign, type, { disabled, error }]) }}"
       fixed="{{ fixed }}"
       focus="{{ focus }}"
-      value="{{ value }}"
+      cursor="{{ cursor }}"
+      value="{{ innerValue }}"
+      auto-focus="{{ autoFocus }}"
       disabled="{{ disabled || readonly }}"
       maxlength="{{ maxlength }}"
       placeholder="{{ placeholder }}"
       placeholder-style="{{ placeholderStyle }}"
       placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
-      auto-height="{{ autosize }}"
+      auto-height="{{ !!autosize }}"
+      style="{{ computed.inputStyle(autosize) }}"
       cursor-spacing="{{ cursorSpacing }}"
       adjust-position="{{ adjustPosition }}"
       show-confirm-bar="{{ showConfirmBar }}"
+      hold-keyboard="{{ holdKeyboard }}"
       selection-end="{{ selectionEnd }}"
       selection-start="{{ selectionStart }}"
+      disable-default-padding="{{ disableDefaultPadding }}"
       bindinput="onInput"
-      bind:blur="onBlur"
-      bind:focus="onFocus"
-      bind:confirm="onConfirm"
+      bindblur="onBlur"
+      bindfocus="onFocus"
+      bindconfirm="onConfirm"
+      bindlinechange="onLineChange"
+      bindkeyboardheightchange="onKeyboardHeightChange"
     >
     </textarea>
     <input
@@ -43,7 +53,9 @@
       class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}"
       type="{{ type }}"
       focus="{{ focus }}"
-      value="{{ value }}"
+      cursor="{{ cursor }}"
+      value="{{ innerValue }}"
+      auto-focus="{{ autoFocus }}"
       disabled="{{ disabled || readonly }}"
       maxlength="{{ maxlength }}"
       placeholder="{{ placeholder }}"
@@ -51,27 +63,27 @@
       placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
       confirm-type="{{ confirmType }}"
       confirm-hold="{{ confirmHold }}"
+      hold-keyboard="{{ holdKeyboard }}"
       cursor-spacing="{{ cursorSpacing }}"
       adjust-position="{{ adjustPosition }}"
       selection-end="{{ selectionEnd }}"
       selection-start="{{ selectionStart }}"
       password="{{ password || type === 'password' }}"
       bindinput="onInput"
-      bind:blur="onBlur"
-      bind:focus="onFocus"
-      bind:confirm="onConfirm"
+      bindblur="onBlur"
+      bindfocus="onFocus"
+      bindconfirm="onConfirm"
+      bindkeyboardheightchange="onKeyboardHeightChange"
     />
     <van-icon
-      wx:if="{{ clearable && focused && value && !readonly }}"
-      size="16px"
+      wx:if="{{ showClear }}"
       name="clear"
       class="van-field__clear-root van-field__icon-root"
-      bindtouchstart="onClear"
+      catch:touchstart="onClear"
     />
     <view class="van-field__icon-container" bind:tap="onClickIcon">
       <van-icon
         wx:if="{{ rightIcon || icon }}"
-        size="16px"
         name="{{ rightIcon || icon }}"
         class="van-field__icon-root {{ iconClass }}"
         custom-class="right-icon-class"
@@ -83,7 +95,10 @@
       <slot name="button" />
     </view>
   </view>
-  <view wx:if="{{ errorMessage }}" class="van-field__error-message {{ utils.bem('field__error', [errorMessageAlign, { disabled, error }]) }}">
+  <view wx:if="{{ showWordLimit && maxlength }}" class="van-field__word-limit">
+    <view class="{{ utils.bem('field__word-num', { full: value.length >= maxlength }) }}">{{ value.length }}</view>/{{ maxlength }}
+  </view>
+  <view wx:if="{{ errorMessage }}" class="{{ utils.bem('field__error-message', [errorMessageAlign, { disabled, error }]) }}">
     {{ errorMessage }}
   </view>
 </van-cell>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/field/index.wxss


+ 34 - 15
miniprogram_npm/vant-weapp/goods-action-button/index.js

@@ -3,20 +3,39 @@ import { link } from '../mixins/link';
 import { button } from '../mixins/button';
 import { openType } from '../mixins/open-type';
 VantComponent({
-    mixins: [link, button, openType],
-    props: {
-        text: String,
-        loading: Boolean,
-        disabled: Boolean,
-        type: {
-            type: String,
-            value: 'danger'
-        }
+  mixins: [link, button, openType],
+  relation: {
+    type: 'ancestor',
+    name: 'goods-action',
+    current: 'goods-action-button',
+  },
+  props: {
+    text: String,
+    color: String,
+    loading: Boolean,
+    disabled: Boolean,
+    plain: Boolean,
+    type: {
+      type: String,
+      value: 'danger',
     },
-    methods: {
-        onClick(event) {
-            this.$emit('click', event.detail);
-            this.jumpLink();
-        }
-    }
+  },
+  methods: {
+    onClick(event) {
+      this.$emit('click', event.detail);
+      this.jumpLink();
+    },
+    updateStyle() {
+      if (this.parent == null) {
+        return;
+      }
+      const { children = [] } = this.parent;
+      const { length } = children;
+      const index = children.indexOf(this);
+      this.setData({
+        isFirst: index === 0,
+        isLast: index === length - 1,
+      });
+    },
+  },
 });

+ 6 - 3
miniprogram_npm/vant-weapp/goods-action-button/index.wxml

@@ -1,13 +1,15 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
 <van-button
-  square
   id="{{ id }}"
-  size="large"
   lang="{{ lang }}"
   type="{{ type }}"
+  color="{{ color }}"
+  plain="{{ plain }}"
   loading="{{ loading }}"
   disabled="{{ disabled }}"
   open-type="{{ openType }}"
-  custom-class="custom-class"
+  class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain: plain }])}}"
+  custom-class="van-goods-action-button__inner"
   business-id="{{ businessId }}"
   session-from="{{ sessionFrom }}"
   app-parameter="{{ appParameter }}"
@@ -24,4 +26,5 @@
   bindlaunchapp="bindLaunchApp"
 >
   {{ text }}
+  <slot></slot>
 </van-button>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/goods-action-button/index.wxss


+ 15 - 14
miniprogram_npm/vant-weapp/goods-action-icon/index.js

@@ -3,19 +3,20 @@ import { link } from '../mixins/link';
 import { button } from '../mixins/button';
 import { openType } from '../mixins/open-type';
 VantComponent({
-    classes: ['icon-class', 'text-class'],
-    mixins: [link, button, openType],
-    props: {
-        text: String,
-        info: String,
-        icon: String,
-        disabled: Boolean,
-        loading: Boolean
+  classes: ['icon-class', 'text-class'],
+  mixins: [link, button, openType],
+  props: {
+    text: String,
+    dot: Boolean,
+    info: String,
+    icon: String,
+    disabled: Boolean,
+    loading: Boolean,
+  },
+  methods: {
+    onClick(event) {
+      this.$emit('click', event.detail);
+      this.jumpLink();
     },
-    methods: {
-        onClick(event) {
-            this.$emit('click', event.detail);
-            this.jumpLink();
-        }
-    }
+  },
 });

+ 4 - 1
miniprogram_npm/vant-weapp/goods-action-icon/index.wxml

@@ -22,14 +22,17 @@
   bindgetphonenumber="bindGetPhoneNumber"
   bindlaunchapp="bindLaunchApp"
 >
-  <view class="van-goods-action-icon__content van-hairline--right">
+  <view class="van-goods-action-icon__content">
     <van-icon
+      wx:if="{{ icon }}"
       size="20px"
       name="{{ icon }}"
+      dot="{{ dot }}"
       info="{{ info }}"
       class="van-goods-action-icon__icon"
       custom-class="icon-class"
     />
+    <slot name="icon" />
     <text class="text-class">{{ text }}</text>
   </view>
 </van-button>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/goods-action-icon/index.wxss


+ 29 - 2
miniprogram_npm/vant-weapp/goods-action/index.js

@@ -1,5 +1,32 @@
 import { VantComponent } from '../common/component';
-import { safeArea } from '../mixins/safe-area';
 VantComponent({
-    mixins: [safeArea()]
+  relation: {
+    type: 'descendant',
+    name: 'goods-action-button',
+    current: 'goods-action',
+    linked() {
+      this.updateStyle();
+    },
+    unlinked() {
+      this.updateStyle();
+    },
+    linkChanged() {
+      this.updateStyle();
+    },
+  },
+  props: {
+    safeAreaInsetBottom: {
+      type: Boolean,
+      value: true,
+    },
+  },
+  methods: {
+    updateStyle() {
+      wx.nextTick(() => {
+        this.children.forEach((child) => {
+          child.updateStyle();
+        });
+      });
+    },
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/goods-action/index.wxml

@@ -1,5 +1,5 @@
 <wxs src="../wxs/utils.wxs" module="utils" />
 
-<view class="custom-class {{ utils.bem('goods-action', { safe: isIPhoneX && safeAreaInsetBottom }) }}">
+<view class="custom-class {{ utils.bem('goods-action', { safe: safeAreaInsetBottom }) }}">
   <slot />
 </view>

+ 1 - 1
miniprogram_npm/vant-weapp/goods-action/index.wxss

@@ -1 +1 @@
-@import '../common/index.wxss';.van-goods-action{position:fixed;right:0;bottom:0;left:0;display:-webkit-flex;display:flex;background-color:#fff}.van-goods-action--safe{padding-bottom:34px}
+@import '../common/index.wxss';.van-goods-action{position:fixed;right:0;bottom:0;left:0;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;background-color:#fff;background-color:var(--goods-action-background-color,#fff)}.van-goods-action--safe{padding-bottom:env(safe-area-inset-bottom)}

+ 23 - 15
miniprogram_npm/vant-weapp/icon/index.js

@@ -1,19 +1,27 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    props: {
-        info: null,
-        name: String,
-        size: String,
-        color: String,
-        customStyle: String,
-        classPrefix: {
-            type: String,
-            value: 'van-icon'
-        }
+  props: {
+    dot: Boolean,
+    info: null,
+    size: null,
+    color: String,
+    customStyle: String,
+    classPrefix: {
+      type: String,
+      value: 'van-icon',
     },
-    methods: {
-        onClick() {
-            this.$emit('click');
-        }
-    }
+    name: {
+      type: String,
+      observer(val) {
+        this.setData({
+          isImageName: val.indexOf('/') !== -1,
+        });
+      },
+    },
+  },
+  methods: {
+    onClick() {
+      this.$emit('click');
+    },
+  },
 });

+ 5 - 4
miniprogram_npm/vant-weapp/icon/index.wxml

@@ -1,17 +1,18 @@
 <wxs src="../wxs/utils.wxs" module="utils" />
 
 <view
-  class="custom-class {{ classPrefix }} {{ utils.isSrc(name) ? 'van-icon--image' : classPrefix + '-' + name }}"
-  style="{{ color ? 'color: ' + color + ';' : '' }}{{ size ? 'font-size: ' + size + ';' : '' }}{{ customStyle }}"
+  class="custom-class {{ classPrefix }} {{ isImageName ? 'van-icon--image' : classPrefix + '-' + name }}"
+  style="color: {{ color }};font-size: {{ utils.addUnit(size) }};{{ customStyle }}"
   bind:tap="onClick"
 >
   <van-info
-    wx:if="{{ info !== null }}"
+    wx:if="{{ info !== null || dot }}"
+    dot="{{ dot }}"
     info="{{ info }}"
     custom-class="van-icon__info"
   />
   <image
-    wx:if="{{ utils.isSrc(name) }}"
+    wx:if="{{ isImageName }}"
     src="{{ name }}"
     mode="aspectFit"
     class="van-icon__image"

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/icon/index.wxss


+ 5 - 4
miniprogram_npm/vant-weapp/info/index.js

@@ -1,7 +1,8 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    props: {
-        info: null,
-        customStyle: String
-    }
+  props: {
+    dot: Boolean,
+    info: null,
+    customStyle: String,
+  },
 });

+ 5 - 3
miniprogram_npm/vant-weapp/info/index.wxml

@@ -1,5 +1,7 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
 <view
-  wx:if="{{ info !== null && info !== '' }}"
-  class="custom-class van-info"
+  wx:if="{{ info !== null && info !== '' || dot }}"
+  class="custom-class van-info {{ utils.bem('info', { dot }) }}"
   style="{{ customStyle }}"
->{{ info }}</view>
+>{{ dot ? '' : info }}</view>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/info/index.wxss


+ 13 - 14
miniprogram_npm/vant-weapp/loading/index.js

@@ -1,17 +1,16 @@
 import { VantComponent } from '../common/component';
 VantComponent({
-    props: {
-        size: {
-            type: String,
-            value: '30px'
-        },
-        type: {
-            type: String,
-            value: 'circular'
-        },
-        color: {
-            type: String,
-            value: '#c9c9c9'
-        }
-    }
+  props: {
+    color: String,
+    vertical: Boolean,
+    type: {
+      type: String,
+      value: 'circular',
+    },
+    size: String,
+    textSize: String,
+  },
+  data: {
+    array12: Array.from({ length: 12 }),
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/loading/index.json

@@ -1,3 +1,3 @@
 {
   "component": true
-}
+}

+ 8 - 6
miniprogram_npm/vant-weapp/loading/index.wxml

@@ -1,16 +1,18 @@
-<view
-  class="van-loading custom-class"
-  style="width: {{ size }}; height: {{ size }}"
->
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view class="custom-class van-loading {{ vertical ? 'van-loading--vertical' : '' }}">
   <view
     class="van-loading__spinner van-loading__spinner--{{ type }}"
-    style="color: {{ color }};"
+    style="color: {{ color }}; width: {{ utils.addUnit(size) }}; height: {{ utils.addUnit(size) }}"
   >
     <view
       wx:if="{{ type === 'spinner' }}"
-      wx:for="item in 12"
+      wx:for="{{ array12 }}"
       wx:key="index"
       class="van-loading__dot"
     />
   </view>
+  <view class="van-loading__text" style="font-size: {{ utils.addUnit(textSize) }};">
+    <slot />
+  </view>
 </view>

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/loading/index.wxss


+ 25 - 20
miniprogram_npm/vant-weapp/mixins/basic.js

@@ -1,22 +1,27 @@
 export const basic = Behavior({
-    methods: {
-        $emit(...args) {
-            this.triggerEvent(...args);
-        },
-        getRect(selector, all) {
-            return new Promise(resolve => {
-                wx.createSelectorQuery()
-                    .in(this)[all ? 'selectAll' : 'select'](selector)
-                    .boundingClientRect(rect => {
-                    if (all && Array.isArray(rect) && rect.length) {
-                        resolve(rect);
-                    }
-                    if (!all && rect) {
-                        resolve(rect);
-                    }
-                })
-                    .exec();
-            });
-        }
-    }
+  methods: {
+    $emit(...args) {
+      this.triggerEvent(...args);
+    },
+    set(data, callback) {
+      this.setData(data, callback);
+      return new Promise((resolve) => wx.nextTick(resolve));
+    },
+    getRect(selector, all) {
+      return new Promise((resolve) => {
+        wx.createSelectorQuery()
+          .in(this)
+          [all ? 'selectAll' : 'select'](selector)
+          .boundingClientRect((rect) => {
+            if (all && Array.isArray(rect) && rect.length) {
+              resolve(rect);
+            }
+            if (!all && rect) {
+              resolve(rect);
+            }
+          })
+          .exec();
+      });
+    },
+  },
 });

+ 13 - 16
miniprogram_npm/vant-weapp/mixins/button.js

@@ -1,18 +1,15 @@
 export const button = Behavior({
-    externalClasses: ['hover-class'],
-    properties: {
-        id: String,
-        lang: {
-            type: String,
-            value: 'en'
-        },
-        businessId: Number,
-        sessionFrom: String,
-        sendMessageTitle: String,
-        sendMessagePath: String,
-        sendMessageImg: String,
-        showMessageCard: Boolean,
-        appParameter: String,
-        ariaLabel: String
-    }
+  externalClasses: ['hover-class'],
+  properties: {
+    id: String,
+    lang: String,
+    businessId: Number,
+    sessionFrom: String,
+    sendMessageTitle: String,
+    sendMessagePath: String,
+    sendMessageImg: String,
+    showMessageCard: Boolean,
+    appParameter: String,
+    ariaLabel: String,
+  },
 });

+ 14 - 14
miniprogram_npm/vant-weapp/mixins/link.js

@@ -1,17 +1,17 @@
 export const link = Behavior({
-    properties: {
-        url: String,
-        linkType: {
-            type: String,
-            value: 'navigateTo'
-        }
+  properties: {
+    url: String,
+    linkType: {
+      type: String,
+      value: 'navigateTo',
     },
-    methods: {
-        jumpLink(urlKey = 'url') {
-            const url = this.data[urlKey];
-            if (url) {
-                wx[this.data.linkType]({ url });
-            }
-        }
-    }
+  },
+  methods: {
+    jumpLink(urlKey = 'url') {
+      const url = this.data[urlKey];
+      if (url) {
+        wx[this.data.linkType]({ url });
+      }
+    },
+  },
 });

+ 0 - 1
miniprogram_npm/vant-weapp/mixins/observer/behavior.d.ts

@@ -1 +0,0 @@
-export declare const behavior: string;

+ 0 - 47
miniprogram_npm/vant-weapp/mixins/observer/behavior.js

@@ -1,47 +0,0 @@
-function setAsync(context, data) {
-    return new Promise(resolve => {
-        context.setData(data, resolve);
-    });
-}
-export const behavior = Behavior({
-    created() {
-        if (!this.$options) {
-            return;
-        }
-        const cache = {};
-        const { computed } = this.$options();
-        const keys = Object.keys(computed);
-        this.calcComputed = () => {
-            const needUpdate = {};
-            keys.forEach(key => {
-                const value = computed[key].call(this);
-                if (cache[key] !== value) {
-                    cache[key] = value;
-                    needUpdate[key] = value;
-                }
-            });
-            return needUpdate;
-        };
-    },
-    attached() {
-        this.set();
-    },
-    methods: {
-        // set data and set computed data
-        set(data, callback) {
-            const stack = [];
-            if (data) {
-                stack.push(setAsync(this, data));
-            }
-            if (this.calcComputed) {
-                stack.push(setAsync(this, this.calcComputed()));
-            }
-            return Promise.all(stack).then(res => {
-                if (callback && typeof callback === 'function') {
-                    callback.call(this);
-                }
-                return res;
-            });
-        }
-    }
-});

+ 0 - 1
miniprogram_npm/vant-weapp/mixins/observer/index.d.ts

@@ -1 +0,0 @@
-export declare function observe(vantOptions: any, options: any): void;

+ 0 - 27
miniprogram_npm/vant-weapp/mixins/observer/index.js

@@ -1,27 +0,0 @@
-import { behavior } from './behavior';
-import { observeProps } from './props';
-export function observe(vantOptions, options) {
-    const { watch, computed } = vantOptions;
-    options.behaviors.push(behavior);
-    if (watch) {
-        const props = options.properties || {};
-        Object.keys(watch).forEach(key => {
-            if (key in props) {
-                let prop = props[key];
-                if (prop === null || !('type' in prop)) {
-                    prop = { type: prop };
-                }
-                prop.observer = watch[key];
-                props[key] = prop;
-            }
-        });
-        options.properties = props;
-    }
-    if (computed) {
-        options.methods = options.methods || {};
-        options.methods.$options = () => vantOptions;
-        if (options.properties) {
-            observeProps(options.properties);
-        }
-    }
-}

+ 0 - 1
miniprogram_npm/vant-weapp/mixins/observer/props.d.ts

@@ -1 +0,0 @@
-export declare function observeProps(props: any): void;

+ 0 - 22
miniprogram_npm/vant-weapp/mixins/observer/props.js

@@ -1,22 +0,0 @@
-export function observeProps(props) {
-    if (!props) {
-        return;
-    }
-    Object.keys(props).forEach(key => {
-        let prop = props[key];
-        if (prop === null || !('type' in prop)) {
-            prop = { type: prop };
-        }
-        let { observer } = prop;
-        prop.observer = function (...args) {
-            if (observer) {
-                if (typeof observer === 'string') {
-                    observer = this[observer];
-                }
-                observer.apply(this, args);
-            }
-            this.set();
-        };
-        props[key] = prop;
-    });
-}

+ 22 - 22
miniprogram_npm/vant-weapp/mixins/open-type.js

@@ -1,25 +1,25 @@
 export const openType = Behavior({
-    properties: {
-        openType: String
+  properties: {
+    openType: String,
+  },
+  methods: {
+    bindGetUserInfo(event) {
+      this.$emit('getuserinfo', event.detail);
     },
-    methods: {
-        bindGetUserInfo(event) {
-            this.$emit('getuserinfo', event.detail);
-        },
-        bindContact(event) {
-            this.$emit('contact', event.detail);
-        },
-        bindGetPhoneNumber(event) {
-            this.$emit('getphonenumber', event.detail);
-        },
-        bindError(event) {
-            this.$emit('error', event.detail);
-        },
-        bindLaunchApp(event) {
-            this.$emit('launchapp', event.detail);
-        },
-        bindOpenSetting(event) {
-            this.$emit('opensetting', event.detail);
-        },
-    }
+    bindContact(event) {
+      this.$emit('contact', event.detail);
+    },
+    bindGetPhoneNumber(event) {
+      this.$emit('getphonenumber', event.detail);
+    },
+    bindError(event) {
+      this.$emit('error', event.detail);
+    },
+    bindLaunchApp(event) {
+      this.$emit('launchapp', event.detail);
+    },
+    bindOpenSetting(event) {
+      this.$emit('opensetting', event.detail);
+    },
+  },
 });

+ 0 - 4
miniprogram_npm/vant-weapp/mixins/safe-area.d.ts

@@ -1,4 +0,0 @@
-export declare const safeArea: ({ safeAreaInsetBottom, safeAreaInsetTop }?: {
-    safeAreaInsetBottom?: boolean;
-    safeAreaInsetTop?: boolean;
-}) => string;

+ 0 - 39
miniprogram_npm/vant-weapp/mixins/safe-area.js

@@ -1,39 +0,0 @@
-let cache = null;
-function getSafeArea() {
-    return new Promise((resolve, reject) => {
-        if (cache != null) {
-            resolve(cache);
-        }
-        else {
-            wx.getSystemInfo({
-                success: ({ model, statusBarHeight }) => {
-                    const deviceType = model.replace(/\s/g, '-');
-                    const iphoneNew = /iphone-x|iPhone11|iPhone12/i.test(deviceType);
-                    cache = {
-                        isIPhoneX: iphoneNew,
-                        statusBarHeight
-                    };
-                    resolve(cache);
-                },
-                fail: reject
-            });
-        }
-    });
-}
-export const safeArea = ({ safeAreaInsetBottom = true, safeAreaInsetTop = false } = {}) => Behavior({
-    properties: {
-        safeAreaInsetTop: {
-            type: Boolean,
-            value: safeAreaInsetTop
-        },
-        safeAreaInsetBottom: {
-            type: Boolean,
-            value: safeAreaInsetBottom
-        }
-    },
-    created() {
-        getSafeArea().then(({ isIPhoneX, statusBarHeight }) => {
-            this.set({ isIPhoneX, statusBarHeight });
-        });
-    }
-});

+ 34 - 25
miniprogram_npm/vant-weapp/mixins/touch.js

@@ -1,27 +1,36 @@
+const MIN_DISTANCE = 10;
+function getDirection(x, y) {
+  if (x > y && x > MIN_DISTANCE) {
+    return 'horizontal';
+  }
+  if (y > x && y > MIN_DISTANCE) {
+    return 'vertical';
+  }
+  return '';
+}
 export const touch = Behavior({
-    methods: {
-        touchStart(event) {
-            const touch = event.touches[0];
-            this.direction = '';
-            this.deltaX = 0;
-            this.deltaY = 0;
-            this.offsetX = 0;
-            this.offsetY = 0;
-            this.startX = touch.clientX;
-            this.startY = touch.clientY;
-        },
-        touchMove(event) {
-            const touch = event.touches[0];
-            this.deltaX = touch.clientX - this.startX;
-            this.deltaY = touch.clientY - this.startY;
-            this.offsetX = Math.abs(this.deltaX);
-            this.offsetY = Math.abs(this.deltaY);
-            this.direction =
-                this.offsetX > this.offsetY
-                    ? 'horizontal'
-                    : this.offsetX < this.offsetY
-                        ? 'vertical'
-                        : '';
-        }
-    }
+  methods: {
+    resetTouchStatus() {
+      this.direction = '';
+      this.deltaX = 0;
+      this.deltaY = 0;
+      this.offsetX = 0;
+      this.offsetY = 0;
+    },
+    touchStart(event) {
+      this.resetTouchStatus();
+      const touch = event.touches[0];
+      this.startX = touch.clientX;
+      this.startY = touch.clientY;
+    },
+    touchMove(event) {
+      const touch = event.touches[0];
+      this.deltaX = touch.clientX - this.startX;
+      this.deltaY = touch.clientY - this.startY;
+      this.offsetX = Math.abs(this.deltaX);
+      this.offsetY = Math.abs(this.deltaY);
+      this.direction =
+        this.direction || getDirection(this.offsetX, this.offsetY);
+    },
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/mixins/transition.d.ts

@@ -1 +1 @@
-export declare const transition: (showDefaultValue: boolean) => any;
+export declare const transition: (showDefaultValue: boolean) => string;

+ 112 - 105
miniprogram_npm/vant-weapp/mixins/transition.js

@@ -1,111 +1,118 @@
 import { isObj } from '../common/utils';
 const getClassNames = (name) => ({
-    enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`,
-    'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`,
-    leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`,
-    'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`
+  enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`,
+  'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`,
+  leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`,
+  'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`,
 });
-const nextTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 30));
+const nextTick = () => new Promise((resolve) => setTimeout(resolve, 1000 / 30));
 export const transition = function (showDefaultValue) {
-    return Behavior({
-        properties: {
-            customStyle: String,
-            // @ts-ignore
-            show: {
-                type: Boolean,
-                value: showDefaultValue,
-                observer: 'observeShow'
-            },
-            // @ts-ignore
-            duration: {
-                type: [Number, Object],
-                value: 300,
-                observer: 'observeDuration'
-            },
-            name: {
-                type: String,
-                value: 'fade'
-            }
-        },
-        data: {
-            type: '',
-            inited: false,
-            display: false
-        },
-        attached() {
-            if (this.data.show) {
-                this.enter();
-            }
-        },
-        methods: {
-            observeShow(value) {
-                if (value) {
-                    this.enter();
-                }
-                else {
-                    this.leave();
-                }
-            },
-            enter() {
-                const { duration, name } = this.data;
-                const classNames = getClassNames(name);
-                const currentDuration = isObj(duration) ? duration.enter : duration;
-                this.status = 'enter';
-                Promise.resolve()
-                    .then(nextTick)
-                    .then(() => {
-                    this.checkStatus('enter');
-                    this.set({
-                        inited: true,
-                        display: true,
-                        classes: classNames.enter,
-                        currentDuration
-                    });
-                })
-                    .then(nextTick)
-                    .then(() => {
-                    this.checkStatus('enter');
-                    this.set({
-                        classes: classNames['enter-to']
-                    });
-                })
-                    .catch(() => { });
-            },
-            leave() {
-                const { duration, name } = this.data;
-                const classNames = getClassNames(name);
-                const currentDuration = isObj(duration) ? duration.leave : duration;
-                this.status = 'leave';
-                Promise.resolve()
-                    .then(nextTick)
-                    .then(() => {
-                    this.checkStatus('leave');
-                    this.set({
-                        classes: classNames.leave,
-                        currentDuration
-                    });
-                })
-                    .then(() => setTimeout(() => this.onTransitionEnd(), currentDuration))
-                    .then(nextTick)
-                    .then(() => {
-                    this.checkStatus('leave');
-                    this.set({
-                        classes: classNames['leave-to']
-                    });
-                })
-                    .catch(() => { });
-            },
-            checkStatus(status) {
-                if (status !== this.status) {
-                    throw new Error(`incongruent status: ${status}`);
-                }
-            },
-            onTransitionEnd() {
-                if (!this.data.show) {
-                    this.set({ display: false });
-                    this.$emit('transitionEnd');
-                }
-            }
+  return Behavior({
+    properties: {
+      customStyle: String,
+      // @ts-ignore
+      show: {
+        type: Boolean,
+        value: showDefaultValue,
+        observer: 'observeShow',
+      },
+      // @ts-ignore
+      duration: {
+        type: null,
+        value: 300,
+        observer: 'observeDuration',
+      },
+      name: {
+        type: String,
+        value: 'fade',
+      },
+    },
+    data: {
+      type: '',
+      inited: false,
+      display: false,
+    },
+    methods: {
+      observeShow(value, old) {
+        if (value === old) {
+          return;
         }
-    });
+        value ? this.enter() : this.leave();
+      },
+      enter() {
+        const { duration, name } = this.data;
+        const classNames = getClassNames(name);
+        const currentDuration = isObj(duration) ? duration.enter : duration;
+        this.status = 'enter';
+        this.$emit('before-enter');
+        Promise.resolve()
+          .then(nextTick)
+          .then(() => {
+            this.checkStatus('enter');
+            this.$emit('enter');
+            this.setData({
+              inited: true,
+              display: true,
+              classes: classNames.enter,
+              currentDuration,
+            });
+          })
+          .then(nextTick)
+          .then(() => {
+            this.checkStatus('enter');
+            this.transitionEnded = false;
+            this.setData({
+              classes: classNames['enter-to'],
+            });
+          })
+          .catch(() => {});
+      },
+      leave() {
+        if (!this.data.display) {
+          return;
+        }
+        const { duration, name } = this.data;
+        const classNames = getClassNames(name);
+        const currentDuration = isObj(duration) ? duration.leave : duration;
+        this.status = 'leave';
+        this.$emit('before-leave');
+        Promise.resolve()
+          .then(nextTick)
+          .then(() => {
+            this.checkStatus('leave');
+            this.$emit('leave');
+            this.setData({
+              classes: classNames.leave,
+              currentDuration,
+            });
+          })
+          .then(nextTick)
+          .then(() => {
+            this.checkStatus('leave');
+            this.transitionEnded = false;
+            setTimeout(() => this.onTransitionEnd(), currentDuration);
+            this.setData({
+              classes: classNames['leave-to'],
+            });
+          })
+          .catch(() => {});
+      },
+      checkStatus(status) {
+        if (status !== this.status) {
+          throw new Error(`incongruent status: ${status}`);
+        }
+      },
+      onTransitionEnd() {
+        if (this.transitionEnded) {
+          return;
+        }
+        this.transitionEnded = true;
+        this.$emit(`after-${this.status}`);
+        const { show, display } = this.data;
+        if (!show && display) {
+          this.setData({ display: false });
+        }
+      },
+    },
+  });
 };

+ 65 - 26
miniprogram_npm/vant-weapp/nav-bar/index.js

@@ -1,29 +1,68 @@
 import { VantComponent } from '../common/component';
-import { safeArea } from '../mixins/safe-area';
 VantComponent({
-    mixins: [safeArea({ safeAreaInsetTop: true })],
-    classes: ['title-class'],
-    props: {
-        title: String,
-        fixed: Boolean,
-        leftText: String,
-        rightText: String,
-        leftArrow: Boolean,
-        border: {
-            type: Boolean,
-            value: true
-        },
-        zIndex: {
-            type: Number,
-            value: 120
-        }
-    },
-    methods: {
-        onClickLeft() {
-            this.$emit('click-left');
-        },
-        onClickRight() {
-            this.$emit('click-right');
-        }
-    }
+  classes: ['title-class'],
+  props: {
+    title: String,
+    fixed: {
+      type: Boolean,
+      observer: 'setHeight',
+    },
+    placeholder: {
+      type: Boolean,
+      observer: 'setHeight',
+    },
+    leftText: String,
+    rightText: String,
+    customStyle: String,
+    leftArrow: Boolean,
+    border: {
+      type: Boolean,
+      value: true,
+    },
+    zIndex: {
+      type: Number,
+      value: 1,
+    },
+    safeAreaInsetTop: {
+      type: Boolean,
+      value: true,
+    },
+  },
+  data: {
+    statusBarHeight: 0,
+    height: 44,
+    baseStyle: '',
+  },
+  created() {
+    const { statusBarHeight } = wx.getSystemInfoSync();
+    const { safeAreaInsetTop, zIndex } = this.data;
+    const paddingTop = safeAreaInsetTop ? statusBarHeight : 0;
+    const baseStyle = `z-index: ${zIndex};padding-top: ${paddingTop}px;`;
+    this.setData({
+      statusBarHeight,
+      height: 44 + statusBarHeight,
+      baseStyle,
+    });
+  },
+  mounted() {
+    this.setHeight();
+  },
+  methods: {
+    onClickLeft() {
+      this.$emit('click-left');
+    },
+    onClickRight() {
+      this.$emit('click-right');
+    },
+    setHeight() {
+      if (!this.data.fixed || !this.data.placeholder) {
+        return;
+      }
+      wx.nextTick(() => {
+        this.getRect('.van-nav-bar').then((res) => {
+          this.setData({ height: res.height });
+        });
+      });
+    },
+  },
 });

+ 3 - 1
miniprogram_npm/vant-weapp/nav-bar/index.wxml

@@ -1,8 +1,10 @@
 <wxs src="../wxs/utils.wxs" module="utils" />
 
+<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;" />
+
 <view
   class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}"
-  style="z-index: {{ zIndex }}; {{ safeAreaInsetTop ? 'padding-top: ' + statusBarHeight + 'px;' : '' }}"
+  style="{{ baseStyle }} {{ customStyle }}"
 >
   <view class="van-nav-bar__left" bind:tap="onClickLeft">
     <block wx:if="{{ leftArrow || leftText }}">

ファイルの差分が大きいため隠しています
+ 1 - 1
miniprogram_npm/vant-weapp/nav-bar/index.wxss


+ 118 - 111
miniprogram_npm/vant-weapp/notice-bar/index.js

@@ -2,122 +2,129 @@ import { VantComponent } from '../common/component';
 const FONT_COLOR = '#ed6a0c';
 const BG_COLOR = '#fffbe8';
 VantComponent({
-    props: {
-        text: {
-            type: String,
-            value: ''
-        },
-        mode: {
-            type: String,
-            value: ''
-        },
-        url: {
-            type: String,
-            value: ''
-        },
-        openType: {
-            type: String,
-            value: 'navigate'
-        },
-        delay: {
-            type: Number,
-            value: 1
-        },
-        speed: {
-            type: Number,
-            value: 50
-        },
-        scrollable: {
-            type: Boolean,
-            value: true
-        },
-        leftIcon: {
-            type: String,
-            value: ''
-        },
-        color: {
-            type: String,
-            value: FONT_COLOR
-        },
-        backgroundColor: {
-            type: String,
-            value: BG_COLOR
-        },
-        wrapable: Boolean
+  props: {
+    text: {
+      type: String,
+      value: '',
+      observer() {
+        wx.nextTick(() => {
+          this.init();
+        });
+      },
     },
-    data: {
-        show: true
+    mode: {
+      type: String,
+      value: '',
     },
-    watch: {
-        text() {
-            this.set({}, this.init);
-        }
+    url: {
+      type: String,
+      value: '',
+    },
+    openType: {
+      type: String,
+      value: 'navigate',
+    },
+    delay: {
+      type: Number,
+      value: 1,
     },
-    created() {
-        this.resetAnimation = wx.createAnimation({
-            duration: 0,
-            timingFunction: 'linear'
+    speed: {
+      type: Number,
+      value: 50,
+      observer() {
+        wx.nextTick(() => {
+          this.init();
         });
+      },
+    },
+    scrollable: {
+      type: Boolean,
+      value: true,
+    },
+    leftIcon: {
+      type: String,
+      value: '',
+    },
+    color: {
+      type: String,
+      value: FONT_COLOR,
     },
-    destroyed() {
-        this.timer && clearTimeout(this.timer);
+    backgroundColor: {
+      type: String,
+      value: BG_COLOR,
     },
-    methods: {
-        init() {
-            Promise.all([
-                this.getRect('.van-notice-bar__content'),
-                this.getRect('.van-notice-bar__wrap')
-            ]).then((rects) => {
-                const [contentRect, wrapRect] = rects;
-                if (contentRect == null ||
-                    wrapRect == null ||
-                    !contentRect.width ||
-                    !wrapRect.width) {
-                    return;
-                }
-                const { speed, scrollable, delay } = this.data;
-                if (scrollable && wrapRect.width < contentRect.width) {
-                    const duration = (contentRect.width / speed) * 1000;
-                    this.wrapWidth = wrapRect.width;
-                    this.contentWidth = contentRect.width;
-                    this.duration = duration;
-                    this.animation = wx.createAnimation({
-                        duration,
-                        timingFunction: 'linear',
-                        delay
-                    });
-                    this.scroll();
-                }
-            });
-        },
-        scroll() {
-            this.timer && clearTimeout(this.timer);
-            this.timer = null;
-            this.set({
-                animationData: this.resetAnimation
-                    .translateX(this.wrapWidth)
-                    .step()
-                    .export()
-            });
-            setTimeout(() => {
-                this.set({
-                    animationData: this.animation
-                        .translateX(-this.contentWidth)
-                        .step()
-                        .export()
-                });
-            }, 20);
-            this.timer = setTimeout(() => {
-                this.scroll();
-            }, this.duration);
-        },
-        onClickIcon() {
-            this.timer && clearTimeout(this.timer);
-            this.timer = null;
-            this.set({ show: false });
-        },
-        onClick(event) {
-            this.$emit('click', event);
+    wrapable: Boolean,
+  },
+  data: {
+    show: true,
+  },
+  created() {
+    this.resetAnimation = wx.createAnimation({
+      duration: 0,
+      timingFunction: 'linear',
+    });
+  },
+  destroyed() {
+    this.timer && clearTimeout(this.timer);
+  },
+  methods: {
+    init() {
+      Promise.all([
+        this.getRect('.van-notice-bar__content'),
+        this.getRect('.van-notice-bar__wrap'),
+      ]).then((rects) => {
+        const [contentRect, wrapRect] = rects;
+        if (
+          contentRect == null ||
+          wrapRect == null ||
+          !contentRect.width ||
+          !wrapRect.width
+        ) {
+          return;
         }
-    }
+        const { speed, scrollable, delay } = this.data;
+        if (scrollable && wrapRect.width < contentRect.width) {
+          const duration = (contentRect.width / speed) * 1000;
+          this.wrapWidth = wrapRect.width;
+          this.contentWidth = contentRect.width;
+          this.duration = duration;
+          this.animation = wx.createAnimation({
+            duration,
+            timingFunction: 'linear',
+            delay,
+          });
+          this.scroll();
+        }
+      });
+    },
+    scroll() {
+      this.timer && clearTimeout(this.timer);
+      this.timer = null;
+      this.setData({
+        animationData: this.resetAnimation
+          .translateX(this.wrapWidth)
+          .step()
+          .export(),
+      });
+      setTimeout(() => {
+        this.setData({
+          animationData: this.animation
+            .translateX(-this.contentWidth)
+            .step()
+            .export(),
+        });
+      }, 20);
+      this.timer = setTimeout(() => {
+        this.scroll();
+      }, this.duration);
+    },
+    onClickIcon() {
+      this.timer && clearTimeout(this.timer);
+      this.timer = null;
+      this.setData({ show: false });
+    },
+    onClick(event) {
+      this.$emit('click', event);
+    },
+  },
 });

+ 1 - 1
miniprogram_npm/vant-weapp/notice-bar/index.json

@@ -3,4 +3,4 @@
   "usingComponents": {
     "van-icon": "../icon/index"
   }
-}
+}

+ 0 - 0
miniprogram_npm/vant-weapp/notice-bar/index.wxml


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません