diff --git a/dist/area/index.js b/dist/area/index.js index 81517e2d..5601d778 100644 --- a/dist/area/index.js +++ b/dist/area/index.js @@ -82,12 +82,10 @@ VantComponent({ 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, + values: this.parseOutputValues(picker.getValues()), index }); }); diff --git a/dist/dropdown-menu/index.js b/dist/dropdown-menu/index.js index 4b71fe15..302659a1 100644 --- a/dist/dropdown-menu/index.js +++ b/dist/dropdown-menu/index.js @@ -19,7 +19,7 @@ VantComponent({ childIndex: this.children.length }); this.children.push(target); - // 收集 dropdown-item 的 data 挂在 data 上 + // 收集 dorpdown-item 的 data 挂在 data 上 target && this.setData({ itemListData: this.data.itemListData.concat([target.data]) diff --git a/dist/goods-action-button/index.wxss b/dist/goods-action-button/index.wxss index 0ab5cde6..5b603f1f 100644 --- a/dist/goods-action-button/index.wxss +++ b/dist/goods-action-button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:40px/2!important;border-top-left-radius:var(--goods-action-button-height,40px)/2!important;border-bottom-left-radius:40px/2!important;border-bottom-left-radius:var(--goods-action-button-height,40px)/2!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:40px/2!important;border-top-right-radius:var(--goods-action-button-height,40px)/2!important;border-bottom-right-radius:40px/2!important;border-bottom-right-radius:var(--goods-action-button-height,40px)/2!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file diff --git a/dist/icon/index.wxss b/dist/icon/index.wxss index 5689487a..8fa5efcd 100644 --- a/dist/icon/index.wxss +++ b/dist/icon/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calender-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medel-o:before{content:"\F083"}.van-icon-medel:before{content:"\F084"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} \ No newline at end of file +@import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calender-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medel-o:before{content:"\F083"}.van-icon-medel:before{content:"\F084"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} \ No newline at end of file diff --git a/dist/index-anchor/index.d.ts b/dist/index-anchor/index.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/index-anchor/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/index-anchor/index.js b/dist/index-anchor/index.js new file mode 100644 index 00000000..caaf1911 --- /dev/null +++ b/dist/index-anchor/index.js @@ -0,0 +1,22 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + relation: { + name: 'index-bar', + type: 'ancestor', + linked(target) { + this.parent = target; + }, + unlinked() { + this.parent = null; + } + }, + props: { + useSlot: Boolean, + index: null + }, + data: { + active: false, + wrapperStyle: '', + anchorStyle: '' + } +}); diff --git a/dist/index-anchor/index.json b/dist/index-anchor/index.json new file mode 100644 index 00000000..467ce294 --- /dev/null +++ b/dist/index-anchor/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/dist/index-anchor/index.wxml b/dist/index-anchor/index.wxml new file mode 100644 index 00000000..49affa7c --- /dev/null +++ b/dist/index-anchor/index.wxml @@ -0,0 +1,14 @@ + + + + + {{ index }} + + + diff --git a/dist/index-anchor/index.wxss b/dist/index-anchor/index.wxss new file mode 100644 index 00000000..b8c3c0a4 --- /dev/null +++ b/dist/index-anchor/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-anchor{padding:0 16px;padding:var(--index-anchor-padding,0 16px);color:#323233;color:var(--index-anchor-text-color,#323233);font-weight:500;font-weight:var(--index-anchor-font-weight,500);font-size:14px;font-size:var(--index-anchor-font-size,14px);line-height:32px;line-height:var(--index-anchor-line-height,32px);background-color:initial;background-color:var(--index-anchor-background-color,transparent)}.van-index-anchor--active{right:0;left:0;color:#07c160;color:var(--index-anchor-active-text-color,#07c160);background-color:#fff;background-color:var(--index-anchor-active-background-color,#fff)} \ No newline at end of file diff --git a/dist/index-bar/index.d.ts b/dist/index-bar/index.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/index-bar/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/index-bar/index.js b/dist/index-bar/index.js new file mode 100644 index 00000000..ec8e8e73 --- /dev/null +++ b/dist/index-bar/index.js @@ -0,0 +1,240 @@ +import { VantComponent } from '../common/component'; +import { GREEN } from '../common/color'; +const indexList = () => { + const indexList = []; + const charCodeOfA = 'A'.charCodeAt(0); + for (let i = 0; i < 26; i++) { + indexList.push(String.fromCharCode(charCodeOfA + i)); + } + return indexList; +}; +VantComponent({ + relation: { + name: 'index-anchor', + type: 'descendant', + linked() { + this.updateData(); + }, + linkChanged() { + this.updateData(); + }, + unlinked() { + this.updateData(); + } + }, + props: { + sticky: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 1 + }, + highlightColor: { + type: String, + value: GREEN + }, + scrollTop: { + type: Number, + value: 0, + observer: 'onScroll' + }, + stickyOffsetTop: { + type: Number, + value: 0 + }, + indexList: { + type: Array, + value: indexList() + } + }, + data: { + activeAnchorIndex: null, + showSidebar: false + }, + methods: { + updateData() { + this.timer && clearTimeout(this.timer); + this.timer = setTimeout(() => { + this.children = this.getRelationNodes('../index-anchor/index'); + this.setData({ + showSidebar: !!this.children.length + }); + this.setRect().then(() => { + this.onScroll(); + }); + }, 0); + }, + setRect() { + return Promise.all([ + this.setAnchorsRect(), + this.setListRect(), + this.setSiderbarRect() + ]); + }, + setAnchorsRect() { + return Promise.all(this.children.map(anchor => (anchor.getRect('.van-index-anchor-wrapper').then((rect) => { + Object.assign(anchor, { + height: rect.height, + top: rect.top + this.data.scrollTop + }); + })))); + }, + setListRect() { + return this.getRect('.van-index-bar').then((rect) => { + Object.assign(this, { + height: rect.height, + top: rect.top + this.data.scrollTop + }); + }); + }, + setSiderbarRect() { + return this.getRect('.van-index-bar__sidebar').then(res => { + this.sidebar = { + height: res.height, + top: res.top + }; + }); + }, + setDiffData({ target, data }) { + const diffData = {}; + Object.keys(data).forEach(key => { + if (target.data[key] !== data[key]) { + diffData[key] = data[key]; + } + }); + if (Object.keys(diffData).length) { + target.setData(diffData); + } + }, + getAnchorRect(anchor) { + return anchor.getRect('.van-index-anchor-wrapper').then((rect) => ({ + height: rect.height, + top: rect.top + })); + }, + getActiveAnchorIndex() { + const { children } = this; + const { sticky, scrollTop, stickyOffsetTop } = this.data; + for (let i = this.children.length - 1; i >= 0; i--) { + const preAnchorHeight = i > 0 ? children[i - 1].height : 0; + const reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0; + if (reachTop + scrollTop >= children[i].top) { + return i; + } + } + return -1; + }, + onScroll() { + const { children = [] } = this; + if (!children.length) { + return; + } + const { sticky, stickyOffsetTop, zIndex, highlightColor, scrollTop } = this.data; + const active = this.getActiveAnchorIndex(); + this.setDiffData({ + target: this, + data: { + activeAnchorIndex: active + } + }); + if (sticky) { + let isActiveAnchorSticky = false; + if (active !== -1) { + isActiveAnchorSticky = children[active].top <= stickyOffsetTop + scrollTop; + } + children.forEach((item, index) => { + if (index === active) { + let wrapperStyle = ''; + let anchorStyle = ` + color: ${highlightColor}; + `; + if (isActiveAnchorSticky) { + wrapperStyle = ` + height: ${children[index].height}px; + `; + anchorStyle = ` + position: fixed; + top: ${stickyOffsetTop}px; + z-index: ${zIndex}; + color: ${highlightColor}; + `; + } + this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle, + wrapperStyle + } + }); + } + else if (index === active - 1) { + const currentAnchor = children[index]; + const currentOffsetTop = currentAnchor.top; + const targetOffsetTop = index === children.length - 1 + ? this.top + : children[index + 1].top; + const parentOffsetHeight = targetOffsetTop - currentOffsetTop; + const translateY = parentOffsetHeight - currentAnchor.height; + const anchorStyle = ` + position: relative; + transform: translate3d(0, ${translateY}px, 0); + z-index: ${zIndex}; + color: ${highlightColor}; + `; + this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle + } + }); + } + else { + this.setDiffData({ + target: item, + data: { + active: false, + anchorStyle: '', + wrapperStyle: '', + } + }); + } + }); + } + }, + onClick(event) { + this.scrollToAnchor(event.target.dataset.index); + }, + onTouchMove(event) { + const sidebarLength = this.children.length; + const touch = event.touches[0]; + const itemHeight = this.sidebar.height / sidebarLength; + let index = Math.floor((touch.clientY - this.sidebar.top) / itemHeight); + if (index < 0) { + index = 0; + } + else if (index > sidebarLength - 1) { + index = sidebarLength - 1; + } + this.scrollToAnchor(index); + }, + onTouchStop() { + this.scrollToAnchorIndex = null; + }, + scrollToAnchor(index) { + if (typeof index !== 'number' || this.scrollToAnchorIndex === index) { + return; + } + this.scrollToAnchorIndex = index; + const anchor = this.children.filter(item => item.data.index === this.data.indexList[index])[0]; + this.$emit('select', anchor.data.index); + anchor && wx.pageScrollTo({ + duration: 0, + scrollTop: anchor.top + }); + } + } +}); diff --git a/dist/index-bar/index.json b/dist/index-bar/index.json new file mode 100644 index 00000000..467ce294 --- /dev/null +++ b/dist/index-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/dist/index-bar/index.wxml b/dist/index-bar/index.wxml new file mode 100644 index 00000000..19a59cf9 --- /dev/null +++ b/dist/index-bar/index.wxml @@ -0,0 +1,22 @@ + + + + + + {{ item }} + + + diff --git a/dist/index-bar/index.wxss b/dist/index-bar/index.wxss new file mode 100644 index 00000000..dba5dc07 --- /dev/null +++ b/dist/index-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-bar{position:relative}.van-index-bar__sidebar{position:fixed;top:50%;right:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;user-select:none}.van-index-bar__index{font-weight:500;padding:0 4px 0 16px;padding:0 var(--padding-base,4px) 0 var(--padding-md,16px);font-size:10px;font-size:var(--index-bar-index-font-size,10px);line-height:14px;line-height:var(--index-bar-index-line-height,14px)} \ No newline at end of file diff --git a/dist/nav-bar/index.wxss b/dist/nav-bar/index.wxss index 3fbfb7e3..be4ebb5d 100644 --- a/dist/nav-bar/index.wxss +++ b/dist/nav-bar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-nav-bar{position:relative;text-align:center;-webkit-user-select:none;user-select:none;height:44px;height:var(--nav-bar-height,44px);line-height:44px;line-height:var(--nav-bar-height,44px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 -16px;padding:0 -var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px;font-size:var(--nav-bar-arrow-size,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)} \ No newline at end of file +@import '../common/index.wxss';.van-nav-bar{position:relative;text-align:center;-webkit-user-select:none;user-select:none;height:44px;height:var(--nav-bar-height,44px);line-height:44px;line-height:var(--nav-bar-height,44px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 16px;padding:0 var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px;font-size:var(--nav-bar-arrow-size,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/dist/rate/index.js b/dist/rate/index.js index 5e4988d2..20781e04 100644 --- a/dist/rate/index.js +++ b/dist/rate/index.js @@ -8,10 +8,7 @@ VantComponent({ readonly: Boolean, disabled: Boolean, allowHalf: Boolean, - size: { - type: null, - observer: 'setSizeWithUnit' - }, + size: null, icon: { type: String, value: 'star' @@ -47,8 +44,7 @@ VantComponent({ }, data: { innerValue: 0, - gutterWithUnit: undefined, - sizeWithUnit: '20px' + gutterWithUnit: undefined }, watch: { value(value) { @@ -58,11 +54,6 @@ VantComponent({ } }, methods: { - setSizeWithUnit(val) { - this.setData({ - sizeWithUnit: addUnit(val) - }); - }, setGutterWithUnit(val) { this.setData({ gutterWithUnit: addUnit(val) diff --git a/dist/rate/index.wxml b/dist/rate/index.wxml index 5b3dc065..9d48ef79 100644 --- a/dist/rate/index.wxml +++ b/dist/rate/index.wxml @@ -8,7 +8,7 @@ class="van-rate__item" wx:for="{{ count }}" wx:key="index" - style="font-size: {{ sizeWithUnit }};padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}" + style="padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}" > nodesRef.boundingClientRect(resolve).exec()); + }, + initObserver() { + this.disconnectObserver(); + this.getRect(ROOT_ELEMENT).then((rect) => { + this.setData({ height: rect.height }); + wx.nextTick(() => { + this.observeContent(); + this.observeContainer(); + }); + }); + }, + disconnectObserver(observerName) { + if (observerName) { + const observer = this[observerName]; + observer && observer.disconnect(); + } + else { + this.contentObserver && this.contentObserver.disconnect(); + this.containerObserver && this.containerObserver.disconnect(); + } + }, + observeContent() { const { offsetTop } = this.data; - const intersectionObserver = this.createIntersectionObserver({ + this.disconnectObserver('contentObserver'); + const contentObserver = this.createIntersectionObserver({ thresholds: [0, 1] }); - this.intersectionObserver = intersectionObserver; - intersectionObserver.relativeToViewport({ top: -offsetTop }); - intersectionObserver.observe('.van-sticky', (res) => { + this.contentObserver = contentObserver; + contentObserver.relativeToViewport({ top: -offsetTop }); + contentObserver.observe(ROOT_ELEMENT, res => { if (this.data.disabled) { return; } - // @ts-ignore - const { top, height } = res.boundingClientRect; - const fixed = top <= offsetTop; - this.$emit('scroll', { - scrollTop: top, - isFixed: fixed + this.setFixed(res.boundingClientRect.top); + }); + }, + observeContainer() { + if (typeof this.data.container !== 'function') { + return; + } + const { height } = this.data; + this.getContainerRect().then((rect) => { + this.containerHeight = rect.height; + this.disconnectObserver('containerObserver'); + const containerObserver = this.createIntersectionObserver({ + thresholds: [0, 1] }); - this.setData({ fixed, height }); - wx.nextTick(() => { - this.setStyle(); + this.containerObserver = containerObserver; + containerObserver.relativeToViewport({ + top: this.containerHeight - height }); + containerObserver.observe(ROOT_ELEMENT, res => { + if (this.data.disabled) { + return; + } + this.setFixed(res.boundingClientRect.top); + }); + }); + }, + setFixed(top) { + const { offsetTop, height } = this.data; + const { containerHeight } = this; + const fixed = containerHeight && height + ? top > height - containerHeight && top < offsetTop + : top < offsetTop; + this.$emit('scroll', { + scrollTop: top, + isFixed: fixed + }); + this.setData({ fixed }); + wx.nextTick(() => { + this.setStyle(); }); } }, mounted() { - this.observerContentScroll(); + this.mounted = true; + if (!this.data.disabled) { + this.initObserver(); + } }, destroyed() { - this.intersectionObserver.disconnect(); + this.disconnectObserver(); } }); diff --git a/dist/sticky/index.wxml b/dist/sticky/index.wxml index 036cf143..2f95359a 100644 --- a/dist/sticky/index.wxml +++ b/dist/sticky/index.wxml @@ -1,6 +1,6 @@ - + diff --git a/dist/tab/index.js b/dist/tab/index.js index 186dc00f..0bdca30c 100644 --- a/dist/tab/index.js +++ b/dist/tab/index.js @@ -22,10 +22,7 @@ VantComponent({ } }, data: { - width: null, - inited: false, - active: false, - animated: false + active: false }, watch: { title: 'update', @@ -35,15 +32,20 @@ VantComponent({ titleStyle: 'update' }, methods: { - setComputedName() { - this.computedName = this.data.name || this.index; - }, getComputedName() { if (this.data.name !== '') { return this.data.name; } return this.index; }, + updateRender(active, parent) { + const { data: parentData } = parent; + this.inited = this.inited || active; + this.setData({ + active, + shouldRender: this.inited || !parentData.lazyRender + }); + }, update() { if (this.parent) { this.parent.updateTabs(); diff --git a/dist/tab/index.wxml b/dist/tab/index.wxml index b90f452a..0fda4a84 100644 --- a/dist/tab/index.wxml +++ b/dist/tab/index.wxml @@ -1,9 +1,8 @@ diff --git a/dist/tab/index.wxss b/dist/tab/index.wxss index e2e67a98..b4e61b05 100644 --- a/dist/tab/index.wxss +++ b/dist/tab/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tab__pane{box-sizing:border-box;overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} \ No newline at end of file diff --git a/dist/tabs/index.js b/dist/tabs/index.js index f45fa583..d813f0f7 100644 --- a/dist/tabs/index.js +++ b/dist/tabs/index.js @@ -1,29 +1,25 @@ import { VantComponent } from '../common/component'; import { touch } from '../mixins/touch'; -import { nextTick, isDef, addUnit } from '../common/utils'; +import { isDef, addUnit } from '../common/utils'; VantComponent({ mixins: [touch], classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'], relation: { name: 'tab', type: 'descendant', - linked(child) { - child.index = this.children.length; - this.children.push(child); - this.updateTabs(this.data.tabs.concat(child.data)); + linked(target) { + target.index = this.children.length; + this.children.push(target); + this.updateTabs(); }, - unlinked(child) { - const index = this.children.indexOf(child); - const { tabs } = this.data; - tabs.splice(index, 1); - this.children.splice(index, 1); - let i = index; - while (i >= 0 && i < this.children.length) { - const currentChild = this.children[i]; - currentChild.index--; - i++; - } - this.updateTabs(tabs); + unlinked(target) { + this.children = this.children + .filter((child) => child !== target) + .map((child, index) => { + child.index = index; + return child; + }); + this.updateTabs(); } }, props: { @@ -47,12 +43,15 @@ VantComponent({ value: -1, observer: 'setLine' }, + titleActiveColor: String, + titleInactiveColor: String, active: { type: [String, Number], value: 0, - observer(value) { - this.currentName = value; - this.setActiveTab(); + observer(name) { + if (name !== this.getCurrentName()) { + this.setCurrentIndexByName(name); + } } }, type: { @@ -63,6 +62,10 @@ VantComponent({ type: Boolean, value: true }, + ellipsis: { + type: Boolean, + value: true + }, duration: { type: Number, value: 0.3 @@ -74,16 +77,20 @@ VantComponent({ swipeThreshold: { type: Number, value: 4, - observer() { + observer(value) { this.setData({ - scrollable: this.children.length > this.data.swipeThreshold + scrollable: this.children.length > value || !this.data.ellipsis }); } }, offsetTop: { type: Number, value: 0 - } + }, + lazyRender: { + type: Boolean, + value: true + }, }, data: { tabs: [], @@ -91,51 +98,87 @@ VantComponent({ scrollLeft: 0, scrollable: false, trackStyle: '', - wrapStyle: '', - position: '', - currentIndex: 0 + currentIndex: null, + container: null }, beforeCreate() { this.children = []; }, mounted() { + this.setData({ + container: () => this.createSelectorQuery().select('.van-tabs') + }); this.setLine(true); this.setTrack(); this.scrollIntoView(); }, methods: { - updateTabs(tabs) { - tabs = tabs || this.data.tabs; + updateTabs() { + const { children = [], data } = this; this.setData({ - tabs, - scrollable: tabs.length > this.data.swipeThreshold + tabs: children.map((child) => child.data), + scrollable: this.children.length > data.swipeThreshold || !data.ellipsis }); - this.setActiveTab(); + this.setCurrentIndexByName(this.getCurrentName() || data.active); }, - trigger(eventName, name) { - const { tabs, currentIndex } = this.data; + trigger(eventName) { + const { currentIndex } = this.data; + const child = this.children[currentIndex]; this.$emit(eventName, { - name, - title: tabs[currentIndex].title + index: currentIndex, + name: child.getComputedName(), + title: child.data.title }); }, onTap(event) { const { index } = event.currentTarget.dataset; const child = this.children[index]; - const computedName = child.getComputedName(); - if (this.data.tabs[index].disabled) { - this.trigger('disabled', computedName); + if (child.data.disabled) { + this.trigger('disabled'); } else { - this.trigger('click', computedName); - this.setActive(computedName); + this.setCurrentIndex(index); + wx.nextTick(() => { + this.trigger('click'); + }); } }, - setActive(name) { - if (name !== this.currentName) { - this.currentName = name; - this.trigger('change', name); - this.setActiveTab(); + // correct the index of active tab + setCurrentIndexByName(name) { + const { children = [] } = this; + const matched = children.filter((child) => child.getComputedName() === name); + const defaultIndex = (children[0] || {}).index || 0; + this.setCurrentIndex(matched.length ? matched[0].index : defaultIndex); + }, + setCurrentIndex(currentIndex) { + const { data, children = [] } = this; + if (!isDef(currentIndex) || + currentIndex >= children.length || + currentIndex < 0) { + return; + } + const shouldEmitChange = data.currentIndex !== null; + this.setData({ currentIndex }); + children.forEach((item, index) => { + const active = index === currentIndex; + if (active !== item.data.active || !item.inited) { + item.updateRender(active, this); + } + }); + wx.nextTick(() => { + this.setLine(); + this.setTrack(); + this.scrollIntoView(); + this.trigger('input'); + if (shouldEmitChange) { + this.trigger('change'); + } + }); + }, + getCurrentName() { + const activeTab = this.children[this.data.currentIndex]; + if (activeTab) { + return activeTab.getComputedName(); } }, setLine(skipTransition) { @@ -143,8 +186,11 @@ VantComponent({ return; } const { color, duration, currentIndex, lineWidth, lineHeight } = this.data; - this.getRect('.van-tab', true).then((rects) => { + this.getRect('.van-tab', true).then((rects = []) => { const rect = rects[currentIndex]; + if (rect == null) { + return; + } const width = lineWidth !== -1 ? lineWidth : rect.width / 2; const height = lineHeight !== -1 ? `height: ${addUnit(lineHeight)}; border-radius: ${addUnit(lineHeight)};` @@ -170,50 +216,12 @@ VantComponent({ }, setTrack() { const { animated, duration, currentIndex } = this.data; - if (!animated) - return ''; - this.getRect('.van-tabs__content').then((rect) => { - const { width } = rect; - this.setData({ - trackStyle: ` - width: ${width * this.children.length}px; - left: ${-1 * currentIndex * width}px; - transition: left ${duration}s; - display: -webkit-box; - display: flex; - ` - }); - const data = { width, animated }; - this.children.forEach((item) => { - item.setData(data); - }); - }); - }, - setActiveTab() { - if (!isDef(this.currentName)) { - const { active } = this.data; - const { children = [] } = this; - this.currentName = - active === '' && children.length - ? children[0].getComputedName() - : active; - } - this.children.forEach((item, index) => { - const data = { - active: item.getComputedName() === this.currentName - }; - if (data.active) { - this.setData({ currentIndex: index }); - data.inited = true; - } - if (data.active !== item.data.active) { - item.setData(data); - } - }); - nextTick(() => { - this.setLine(); - this.setTrack(); - this.scrollIntoView(); + this.setData({ + trackStyle: ` + transform: translate3d(${-100 * currentIndex}%, 0, 0); + -webkit-transition-duration: ${animated ? duration : 0}s; + transition-duration: ${animated ? duration : 0}s; + ` }); }, // scroll active tab into view @@ -235,6 +243,9 @@ VantComponent({ }); }); }, + onTouchScroll(event) { + this.$emit('scroll', event.detail); + }, onTouchStart(event) { if (!this.data.swipeable) return; @@ -254,12 +265,10 @@ VantComponent({ const minSwipeDistance = 50; if (direction === 'horizontal' && offsetX >= minSwipeDistance) { if (deltaX > 0 && currentIndex !== 0) { - const child = this.children[currentIndex - 1]; - this.setActive(child.getComputedName()); + this.setCurrentIndex(currentIndex - 1); } else if (deltaX < 0 && currentIndex !== tabs.length - 1) { - const child = this.children[currentIndex - 1]; - this.setActive(child.getComputedName()); + this.setCurrentIndex(currentIndex + 1); } } } diff --git a/dist/tabs/index.wxml b/dist/tabs/index.wxml index e168bd04..27d44c81 100644 --- a/dist/tabs/index.wxml +++ b/dist/tabs/index.wxml @@ -1,7 +1,14 @@ + - + @@ -18,11 +25,11 @@ wx:for="{{ tabs }}" wx:key="index" data-index="{{ index }}" - class="van-ellipsis tab-class {{ index === currentIndex ? 'tab-active-class' : '' }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled }) }}" - style="{{ color && index !== currentIndex && type === 'card' && !item.disabled ? 'color: ' + color : '' }} {{ color && index === currentIndex && type === 'card' ? ';background-color:' + color : '' }} {{ color ? ';border-color: ' + color : '' }} {{ scrollable ? ';flex-basis:' + (88 / swipeThreshold) + '%' : '' }}" + class="{{ getters.tabClass(index === currentIndex, ellipsis) }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled, complete: !ellipsis }) }}" + style="{{ getters.tabStyle(index === currentIndex, ellipsis, color, type, item.disabled, titleActiveColor, titleInactiveColor, swipeThreshold, scrollable) }}" bind:tap="onTap" > - + {{ item.title }} 9 ? 9 : newMaxCount) : 1, sourceType: capture, - success: res => { - resolve(res); - }, - fail: err => { - reject(err); - } + success: resolve, + fail: reject }); }); } @@ -91,16 +88,12 @@ VantComponent({ wx.chooseMessageFile({ count: multiple ? newMaxCount : 1, type: 'file', - success(res) { - resolve(res); - }, - fail: err => { - reject(err); - } + success: resolve, + fail: reject }); }); } - chooseFile.then(res => { + chooseFile.then((res) => { const file = multiple ? res.tempFiles : res.tempFiles[0]; // 检查文件大小 if (file instanceof Array) { @@ -119,7 +112,7 @@ VantComponent({ this.$emit('before-read', { file, name, - callback: result => { + callback: (result) => { if (result) { // 开始上传 this.$emit('after-read', { file, name }); diff --git a/lib/area/index.js b/lib/area/index.js index 6776f5d5..676724c1 100644 --- a/lib/area/index.js +++ b/lib/area/index.js @@ -97,12 +97,10 @@ component_1.VantComponent({ var _this = this; var _a = event.detail, index = _a.index, picker = _a.picker, value = _a.value; this.code = value[index].code; - var getValues = picker.getValues(); - getValues = this.parseOutputValues(getValues); this.setValues().then(function () { _this.$emit('change', { picker: picker, - values: getValues, + values: _this.parseOutputValues(picker.getValues()), index: index }); }); diff --git a/lib/goods-action-button/index.wxss b/lib/goods-action-button/index.wxss index 0ab5cde6..5b603f1f 100644 --- a/lib/goods-action-button/index.wxss +++ b/lib/goods-action-button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:40px/2!important;border-top-left-radius:var(--goods-action-button-height,40px)/2!important;border-bottom-left-radius:40px/2!important;border-bottom-left-radius:var(--goods-action-button-height,40px)/2!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:40px/2!important;border-top-right-radius:var(--goods-action-button-height,40px)/2!important;border-bottom-right-radius:40px/2!important;border-bottom-right-radius:var(--goods-action-button-height,40px)/2!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file diff --git a/lib/icon/index.wxss b/lib/icon/index.wxss index 5689487a..8fa5efcd 100644 --- a/lib/icon/index.wxss +++ b/lib/icon/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calender-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medel-o:before{content:"\F083"}.van-icon-medel:before{content:"\F084"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} \ No newline at end of file +@import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-0bc654.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calender-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medel-o:before{content:"\F083"}.van-icon-medel:before{content:"\F084"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} \ No newline at end of file diff --git a/lib/index-anchor/index.js b/lib/index-anchor/index.js new file mode 100644 index 00000000..caea5e8c --- /dev/null +++ b/lib/index-anchor/index.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var component_1 = require("../common/component"); +component_1.VantComponent({ + relation: { + name: 'index-bar', + type: 'ancestor', + linked: function (target) { + this.parent = target; + }, + unlinked: function () { + this.parent = null; + } + }, + props: { + useSlot: Boolean, + index: null + }, + data: { + active: false, + wrapperStyle: '', + anchorStyle: '' + } +}); diff --git a/lib/index-anchor/index.json b/lib/index-anchor/index.json new file mode 100644 index 00000000..467ce294 --- /dev/null +++ b/lib/index-anchor/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/lib/index-anchor/index.wxml b/lib/index-anchor/index.wxml new file mode 100644 index 00000000..49affa7c --- /dev/null +++ b/lib/index-anchor/index.wxml @@ -0,0 +1,14 @@ + + + + + {{ index }} + + + diff --git a/lib/index-anchor/index.wxss b/lib/index-anchor/index.wxss new file mode 100644 index 00000000..b8c3c0a4 --- /dev/null +++ b/lib/index-anchor/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-anchor{padding:0 16px;padding:var(--index-anchor-padding,0 16px);color:#323233;color:var(--index-anchor-text-color,#323233);font-weight:500;font-weight:var(--index-anchor-font-weight,500);font-size:14px;font-size:var(--index-anchor-font-size,14px);line-height:32px;line-height:var(--index-anchor-line-height,32px);background-color:initial;background-color:var(--index-anchor-background-color,transparent)}.van-index-anchor--active{right:0;left:0;color:#07c160;color:var(--index-anchor-active-text-color,#07c160);background-color:#fff;background-color:var(--index-anchor-active-background-color,#fff)} \ No newline at end of file diff --git a/lib/index-bar/index.js b/lib/index-bar/index.js new file mode 100644 index 00000000..f416740a --- /dev/null +++ b/lib/index-bar/index.js @@ -0,0 +1,235 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var component_1 = require("../common/component"); +var color_1 = require("../common/color"); +var indexList = function () { + var indexList = []; + var charCodeOfA = 'A'.charCodeAt(0); + for (var i = 0; i < 26; i++) { + indexList.push(String.fromCharCode(charCodeOfA + i)); + } + return indexList; +}; +component_1.VantComponent({ + relation: { + name: 'index-anchor', + type: 'descendant', + linked: function () { + this.updateData(); + }, + linkChanged: function () { + this.updateData(); + }, + unlinked: function () { + this.updateData(); + } + }, + props: { + sticky: { + type: Boolean, + value: true + }, + zIndex: { + type: Number, + value: 1 + }, + highlightColor: { + type: String, + value: color_1.GREEN + }, + scrollTop: { + type: Number, + value: 0, + observer: 'onScroll' + }, + stickyOffsetTop: { + type: Number, + value: 0 + }, + indexList: { + type: Array, + value: indexList() + } + }, + data: { + activeAnchorIndex: null, + showSidebar: false + }, + methods: { + updateData: function () { + var _this = this; + this.timer && clearTimeout(this.timer); + this.timer = setTimeout(function () { + _this.children = _this.getRelationNodes('../index-anchor/index'); + _this.setData({ + showSidebar: !!_this.children.length + }); + _this.setRect().then(function () { + _this.onScroll(); + }); + }, 0); + }, + setRect: function () { + return Promise.all([ + this.setAnchorsRect(), + this.setListRect(), + this.setSiderbarRect() + ]); + }, + setAnchorsRect: function () { + var _this = this; + return Promise.all(this.children.map(function (anchor) { return (anchor.getRect('.van-index-anchor-wrapper').then(function (rect) { + Object.assign(anchor, { + height: rect.height, + top: rect.top + _this.data.scrollTop + }); + })); })); + }, + setListRect: function () { + var _this = this; + return this.getRect('.van-index-bar').then(function (rect) { + Object.assign(_this, { + height: rect.height, + top: rect.top + _this.data.scrollTop + }); + }); + }, + setSiderbarRect: function () { + var _this = this; + return this.getRect('.van-index-bar__sidebar').then(function (res) { + _this.sidebar = { + height: res.height, + top: res.top + }; + }); + }, + setDiffData: function (_a) { + var target = _a.target, data = _a.data; + var diffData = {}; + Object.keys(data).forEach(function (key) { + if (target.data[key] !== data[key]) { + diffData[key] = data[key]; + } + }); + if (Object.keys(diffData).length) { + target.setData(diffData); + } + }, + getAnchorRect: function (anchor) { + return anchor.getRect('.van-index-anchor-wrapper').then(function (rect) { return ({ + height: rect.height, + top: rect.top + }); }); + }, + getActiveAnchorIndex: function () { + var children = this.children; + var _a = this.data, sticky = _a.sticky, scrollTop = _a.scrollTop, stickyOffsetTop = _a.stickyOffsetTop; + for (var i = this.children.length - 1; i >= 0; i--) { + var preAnchorHeight = i > 0 ? children[i - 1].height : 0; + var reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0; + if (reachTop + scrollTop >= children[i].top) { + return i; + } + } + return -1; + }, + onScroll: function () { + var _this = this; + var _a = this.children, children = _a === void 0 ? [] : _a; + if (!children.length) { + return; + } + var _b = this.data, sticky = _b.sticky, stickyOffsetTop = _b.stickyOffsetTop, zIndex = _b.zIndex, highlightColor = _b.highlightColor, scrollTop = _b.scrollTop; + var active = this.getActiveAnchorIndex(); + this.setDiffData({ + target: this, + data: { + activeAnchorIndex: active + } + }); + if (sticky) { + var isActiveAnchorSticky_1 = false; + if (active !== -1) { + isActiveAnchorSticky_1 = children[active].top <= stickyOffsetTop + scrollTop; + } + children.forEach(function (item, index) { + if (index === active) { + var wrapperStyle = ''; + var anchorStyle = "\n color: " + highlightColor + ";\n "; + if (isActiveAnchorSticky_1) { + wrapperStyle = "\n height: " + children[index].height + "px;\n "; + anchorStyle = "\n position: fixed;\n top: " + stickyOffsetTop + "px;\n z-index: " + zIndex + ";\n color: " + highlightColor + ";\n "; + } + _this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle: anchorStyle, + wrapperStyle: wrapperStyle + } + }); + } + else if (index === active - 1) { + var currentAnchor = children[index]; + var currentOffsetTop = currentAnchor.top; + var targetOffsetTop = index === children.length - 1 + ? _this.top + : children[index + 1].top; + var parentOffsetHeight = targetOffsetTop - currentOffsetTop; + var translateY = parentOffsetHeight - currentAnchor.height; + var anchorStyle = "\n position: relative;\n transform: translate3d(0, " + translateY + "px, 0);\n z-index: " + zIndex + ";\n color: " + highlightColor + ";\n "; + _this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle: anchorStyle + } + }); + } + else { + _this.setDiffData({ + target: item, + data: { + active: false, + anchorStyle: '', + wrapperStyle: '', + } + }); + } + }); + } + }, + onClick: function (event) { + this.scrollToAnchor(event.target.dataset.index); + }, + onTouchMove: function (event) { + var sidebarLength = this.children.length; + var touch = event.touches[0]; + var itemHeight = this.sidebar.height / sidebarLength; + var index = Math.floor((touch.clientY - this.sidebar.top) / itemHeight); + if (index < 0) { + index = 0; + } + else if (index > sidebarLength - 1) { + index = sidebarLength - 1; + } + this.scrollToAnchor(index); + }, + onTouchStop: function () { + this.scrollToAnchorIndex = null; + }, + scrollToAnchor: function (index) { + var _this = this; + if (typeof index !== 'number' || this.scrollToAnchorIndex === index) { + return; + } + this.scrollToAnchorIndex = index; + var anchor = this.children.filter(function (item) { return item.data.index === _this.data.indexList[index]; })[0]; + this.$emit('select', anchor.data.index); + anchor && wx.pageScrollTo({ + duration: 0, + scrollTop: anchor.top + }); + } + } +}); diff --git a/lib/index-bar/index.json b/lib/index-bar/index.json new file mode 100644 index 00000000..467ce294 --- /dev/null +++ b/lib/index-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/lib/index-bar/index.wxml b/lib/index-bar/index.wxml new file mode 100644 index 00000000..19a59cf9 --- /dev/null +++ b/lib/index-bar/index.wxml @@ -0,0 +1,22 @@ + + + + + + {{ item }} + + + diff --git a/lib/index-bar/index.wxss b/lib/index-bar/index.wxss new file mode 100644 index 00000000..dba5dc07 --- /dev/null +++ b/lib/index-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-bar{position:relative}.van-index-bar__sidebar{position:fixed;top:50%;right:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;user-select:none}.van-index-bar__index{font-weight:500;padding:0 4px 0 16px;padding:0 var(--padding-base,4px) 0 var(--padding-md,16px);font-size:10px;font-size:var(--index-bar-index-font-size,10px);line-height:14px;line-height:var(--index-bar-index-line-height,14px)} \ No newline at end of file diff --git a/lib/nav-bar/index.wxss b/lib/nav-bar/index.wxss index 3fbfb7e3..be4ebb5d 100644 --- a/lib/nav-bar/index.wxss +++ b/lib/nav-bar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-nav-bar{position:relative;text-align:center;-webkit-user-select:none;user-select:none;height:44px;height:var(--nav-bar-height,44px);line-height:44px;line-height:var(--nav-bar-height,44px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 -16px;padding:0 -var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px;font-size:var(--nav-bar-arrow-size,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)} \ No newline at end of file +@import '../common/index.wxss';.van-nav-bar{position:relative;text-align:center;-webkit-user-select:none;user-select:none;height:44px;height:var(--nav-bar-height,44px);line-height:44px;line-height:var(--nav-bar-height,44px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 16px;padding:0 var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px;font-size:var(--nav-bar-arrow-size,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/lib/rate/index.js b/lib/rate/index.js index e34b6a90..eb846fdc 100644 --- a/lib/rate/index.js +++ b/lib/rate/index.js @@ -21,10 +21,7 @@ component_1.VantComponent({ readonly: Boolean, disabled: Boolean, allowHalf: Boolean, - size: { - type: null, - observer: 'setSizeWithUnit' - }, + size: null, icon: { type: String, value: 'star' @@ -60,8 +57,7 @@ component_1.VantComponent({ }, data: { innerValue: 0, - gutterWithUnit: undefined, - sizeWithUnit: '20px' + gutterWithUnit: undefined }, watch: { value: function (value) { @@ -71,11 +67,6 @@ component_1.VantComponent({ } }, methods: { - setSizeWithUnit: function (val) { - this.setData({ - sizeWithUnit: utils_1.addUnit(val) - }); - }, setGutterWithUnit: function (val) { this.setData({ gutterWithUnit: utils_1.addUnit(val) diff --git a/lib/rate/index.wxml b/lib/rate/index.wxml index 5b3dc065..9d48ef79 100644 --- a/lib/rate/index.wxml +++ b/lib/rate/index.wxml @@ -8,7 +8,7 @@ class="van-rate__item" wx:for="{{ count }}" wx:key="index" - style="font-size: {{ sizeWithUnit }};padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}" + style="padding-right: {{ index !== count - 1 ? gutterWithUnit : '' }}" > height - containerHeight && top < offsetTop + : top < offsetTop; + this.$emit('scroll', { + scrollTop: top, + isFixed: fixed + }); + this.setData({ fixed: fixed }); + wx.nextTick(function () { + _this.setStyle(); }); } }, mounted: function () { - this.observerContentScroll(); + this.mounted = true; + if (!this.data.disabled) { + this.initObserver(); + } }, destroyed: function () { - this.intersectionObserver.disconnect(); + this.disconnectObserver(); } }); diff --git a/lib/sticky/index.wxml b/lib/sticky/index.wxml index 036cf143..2f95359a 100644 --- a/lib/sticky/index.wxml +++ b/lib/sticky/index.wxml @@ -1,6 +1,6 @@ - + diff --git a/lib/tab/index.js b/lib/tab/index.js index ae9a4978..ef726b05 100644 --- a/lib/tab/index.js +++ b/lib/tab/index.js @@ -24,10 +24,7 @@ component_1.VantComponent({ } }, data: { - width: null, - inited: false, - active: false, - animated: false + active: false }, watch: { title: 'update', @@ -37,15 +34,20 @@ component_1.VantComponent({ titleStyle: 'update' }, methods: { - setComputedName: function () { - this.computedName = this.data.name || this.index; - }, getComputedName: function () { if (this.data.name !== '') { return this.data.name; } return this.index; }, + updateRender: function (active, parent) { + var parentData = parent.data; + this.inited = this.inited || active; + this.setData({ + active: active, + shouldRender: this.inited || !parentData.lazyRender + }); + }, update: function () { if (this.parent) { this.parent.updateTabs(); diff --git a/lib/tab/index.wxml b/lib/tab/index.wxml index b90f452a..0fda4a84 100644 --- a/lib/tab/index.wxml +++ b/lib/tab/index.wxml @@ -1,9 +1,8 @@ diff --git a/lib/tab/index.wxss b/lib/tab/index.wxss index e2e67a98..b4e61b05 100644 --- a/lib/tab/index.wxss +++ b/lib/tab/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tab__pane{box-sizing:border-box;overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} \ No newline at end of file diff --git a/lib/tabs/index.js b/lib/tabs/index.js index ea452dcb..580308be 100644 --- a/lib/tabs/index.js +++ b/lib/tabs/index.js @@ -9,23 +9,19 @@ component_1.VantComponent({ relation: { name: 'tab', type: 'descendant', - linked: function (child) { - child.index = this.children.length; - this.children.push(child); - this.updateTabs(this.data.tabs.concat(child.data)); + linked: function (target) { + target.index = this.children.length; + this.children.push(target); + this.updateTabs(); }, - unlinked: function (child) { - var index = this.children.indexOf(child); - var tabs = this.data.tabs; - tabs.splice(index, 1); - this.children.splice(index, 1); - var i = index; - while (i >= 0 && i < this.children.length) { - var currentChild = this.children[i]; - currentChild.index--; - i++; - } - this.updateTabs(tabs); + unlinked: function (target) { + this.children = this.children + .filter(function (child) { return child !== target; }) + .map(function (child, index) { + child.index = index; + return child; + }); + this.updateTabs(); } }, props: { @@ -49,12 +45,15 @@ component_1.VantComponent({ value: -1, observer: 'setLine' }, + titleActiveColor: String, + titleInactiveColor: String, active: { type: [String, Number], value: 0, - observer: function (value) { - this.currentName = value; - this.setActiveTab(); + observer: function (name) { + if (name !== this.getCurrentName()) { + this.setCurrentIndexByName(name); + } } }, type: { @@ -65,6 +64,10 @@ component_1.VantComponent({ type: Boolean, value: true }, + ellipsis: { + type: Boolean, + value: true + }, duration: { type: Number, value: 0.3 @@ -76,16 +79,20 @@ component_1.VantComponent({ swipeThreshold: { type: Number, value: 4, - observer: function () { + observer: function (value) { this.setData({ - scrollable: this.children.length > this.data.swipeThreshold + scrollable: this.children.length > value || !this.data.ellipsis }); } }, offsetTop: { type: Number, value: 0 - } + }, + lazyRender: { + type: Boolean, + value: true + }, }, data: { tabs: [], @@ -93,51 +100,90 @@ component_1.VantComponent({ scrollLeft: 0, scrollable: false, trackStyle: '', - wrapStyle: '', - position: '', - currentIndex: 0 + currentIndex: null, + container: null }, beforeCreate: function () { this.children = []; }, mounted: function () { + var _this = this; + this.setData({ + container: function () { return _this.createSelectorQuery().select('.van-tabs'); } + }); this.setLine(true); this.setTrack(); this.scrollIntoView(); }, methods: { - updateTabs: function (tabs) { - tabs = tabs || this.data.tabs; + updateTabs: function () { + var _a = this, _b = _a.children, children = _b === void 0 ? [] : _b, data = _a.data; this.setData({ - tabs: tabs, - scrollable: tabs.length > this.data.swipeThreshold + tabs: children.map(function (child) { return child.data; }), + scrollable: this.children.length > data.swipeThreshold || !data.ellipsis }); - this.setActiveTab(); + this.setCurrentIndexByName(this.getCurrentName() || data.active); }, - trigger: function (eventName, name) { - var _a = this.data, tabs = _a.tabs, currentIndex = _a.currentIndex; + trigger: function (eventName) { + var currentIndex = this.data.currentIndex; + var child = this.children[currentIndex]; this.$emit(eventName, { - name: name, - title: tabs[currentIndex].title + index: currentIndex, + name: child.getComputedName(), + title: child.data.title }); }, onTap: function (event) { + var _this = this; var index = event.currentTarget.dataset.index; var child = this.children[index]; - var computedName = child.getComputedName(); - if (this.data.tabs[index].disabled) { - this.trigger('disabled', computedName); + if (child.data.disabled) { + this.trigger('disabled'); } else { - this.trigger('click', computedName); - this.setActive(computedName); + this.setCurrentIndex(index); + wx.nextTick(function () { + _this.trigger('click'); + }); } }, - setActive: function (name) { - if (name !== this.currentName) { - this.currentName = name; - this.trigger('change', name); - this.setActiveTab(); + // correct the index of active tab + setCurrentIndexByName: function (name) { + var _a = this.children, children = _a === void 0 ? [] : _a; + var matched = children.filter(function (child) { return child.getComputedName() === name; }); + var defaultIndex = (children[0] || {}).index || 0; + this.setCurrentIndex(matched.length ? matched[0].index : defaultIndex); + }, + setCurrentIndex: function (currentIndex) { + var _this = this; + var _a = this, data = _a.data, _b = _a.children, children = _b === void 0 ? [] : _b; + if (!utils_1.isDef(currentIndex) || + currentIndex >= children.length || + currentIndex < 0) { + return; + } + var shouldEmitChange = data.currentIndex !== null; + this.setData({ currentIndex: currentIndex }); + children.forEach(function (item, index) { + var active = index === currentIndex; + if (active !== item.data.active || !item.inited) { + item.updateRender(active, _this); + } + }); + wx.nextTick(function () { + _this.setLine(); + _this.setTrack(); + _this.scrollIntoView(); + _this.trigger('input'); + if (shouldEmitChange) { + _this.trigger('change'); + } + }); + }, + getCurrentName: function () { + var activeTab = this.children[this.data.currentIndex]; + if (activeTab) { + return activeTab.getComputedName(); } }, setLine: function (skipTransition) { @@ -147,7 +193,11 @@ component_1.VantComponent({ } var _a = this.data, color = _a.color, duration = _a.duration, currentIndex = _a.currentIndex, lineWidth = _a.lineWidth, lineHeight = _a.lineHeight; this.getRect('.van-tab', true).then(function (rects) { + if (rects === void 0) { rects = []; } var rect = rects[currentIndex]; + if (rect == null) { + return; + } var width = lineWidth !== -1 ? lineWidth : rect.width / 2; var height = lineHeight !== -1 ? "height: " + utils_1.addUnit(lineHeight) + "; border-radius: " + utils_1.addUnit(lineHeight) + ";" @@ -165,47 +215,9 @@ component_1.VantComponent({ }); }, setTrack: function () { - var _this = this; var _a = this.data, animated = _a.animated, duration = _a.duration, currentIndex = _a.currentIndex; - if (!animated) - return ''; - this.getRect('.van-tabs__content').then(function (rect) { - var width = rect.width; - _this.setData({ - trackStyle: "\n width: " + width * _this.children.length + "px;\n left: " + -1 * currentIndex * width + "px;\n transition: left " + duration + "s;\n display: -webkit-box;\n display: flex;\n " - }); - var data = { width: width, animated: animated }; - _this.children.forEach(function (item) { - item.setData(data); - }); - }); - }, - setActiveTab: function () { - var _this = this; - if (!utils_1.isDef(this.currentName)) { - var active = this.data.active; - var _a = this.children, children = _a === void 0 ? [] : _a; - this.currentName = - active === '' && children.length - ? children[0].getComputedName() - : active; - } - this.children.forEach(function (item, index) { - var data = { - active: item.getComputedName() === _this.currentName - }; - if (data.active) { - _this.setData({ currentIndex: index }); - data.inited = true; - } - if (data.active !== item.data.active) { - item.setData(data); - } - }); - utils_1.nextTick(function () { - _this.setLine(); - _this.setTrack(); - _this.scrollIntoView(); + this.setData({ + trackStyle: "\n transform: translate3d(" + -100 * currentIndex + "%, 0, 0);\n -webkit-transition-duration: " + (animated ? duration : 0) + "s;\n transition-duration: " + (animated ? duration : 0) + "s;\n " }); }, // scroll active tab into view @@ -229,6 +241,9 @@ component_1.VantComponent({ }); }); }, + onTouchScroll: function (event) { + this.$emit('scroll', event.detail); + }, onTouchStart: function (event) { if (!this.data.swipeable) return; @@ -248,12 +263,10 @@ component_1.VantComponent({ var minSwipeDistance = 50; if (direction === 'horizontal' && offsetX >= minSwipeDistance) { if (deltaX > 0 && currentIndex !== 0) { - var child = this.children[currentIndex - 1]; - this.setActive(child.getComputedName()); + this.setCurrentIndex(currentIndex - 1); } else if (deltaX < 0 && currentIndex !== tabs.length - 1) { - var child = this.children[currentIndex - 1]; - this.setActive(child.getComputedName()); + this.setCurrentIndex(currentIndex + 1); } } } diff --git a/lib/tabs/index.wxml b/lib/tabs/index.wxml index e168bd04..27d44c81 100644 --- a/lib/tabs/index.wxml +++ b/lib/tabs/index.wxml @@ -1,7 +1,14 @@ + - + @@ -18,11 +25,11 @@ wx:for="{{ tabs }}" wx:key="index" data-index="{{ index }}" - class="van-ellipsis tab-class {{ index === currentIndex ? 'tab-active-class' : '' }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled }) }}" - style="{{ color && index !== currentIndex && type === 'card' && !item.disabled ? 'color: ' + color : '' }} {{ color && index === currentIndex && type === 'card' ? ';background-color:' + color : '' }} {{ color ? ';border-color: ' + color : '' }} {{ scrollable ? ';flex-basis:' + (88 / swipeThreshold) + '%' : '' }}" + class="{{ getters.tabClass(index === currentIndex, ellipsis) }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled, complete: !ellipsis }) }}" + style="{{ getters.tabStyle(index === currentIndex, ellipsis, color, type, item.disabled, titleActiveColor, titleInactiveColor, swipeThreshold, scrollable) }}" bind:tap="onTap" > - + {{ item.title }} 9 ? 9 : newMaxCount) : 1, sourceType: capture, - success: function (res) { - resolve(res); - }, - fail: function (err) { - reject(err); - } + success: resolve, + fail: reject }); }); } @@ -106,12 +103,8 @@ component_1.VantComponent({ wx.chooseMessageFile({ count: multiple ? newMaxCount : 1, type: 'file', - success: function (res) { - resolve(res); - }, - fail: function (err) { - reject(err); - } + success: resolve, + fail: reject }); }); }