From 6ba5fa18dfdc3f7ab6be11660c53cf1f2b72c34c Mon Sep 17 00:00:00 2001 From: rex-zsd Date: Tue, 12 Nov 2019 14:35:06 +0800 Subject: [PATCH] build: compile 1.0.0-beta.3 --- dist/action-sheet/index.wxml | 2 +- dist/action-sheet/index.wxss | 2 +- dist/area/index.js | 5 +- dist/button/index.wxml | 2 +- dist/button/index.wxss | 2 +- dist/card/index.wxss | 2 +- dist/cell-group/index.wxss | 2 +- dist/cell/index.wxss | 2 +- dist/checkbox/index.wxss | 2 +- dist/circle/index.wxss | 2 +- dist/collapse-item/index.wxss | 2 +- dist/count-down/index.js | 4 + dist/count-down/index.wxss | 2 +- dist/datetime-picker/index.js | 2 +- dist/dialog/index.wxss | 2 +- dist/divider/index.wxml | 4 +- dist/divider/index.wxss | 2 +- dist/dropdown-item/index.wxss | 2 +- dist/dropdown-menu/index.wxss | 2 +- dist/field/index.js | 1 + dist/field/index.wxml | 2 + dist/field/index.wxss | 2 +- dist/goods-action-button/index.js | 16 +-- dist/goods-action-button/index.wxml | 1 - dist/goods-action-button/index.wxss | 2 +- dist/goods-action-icon/index.wxss | 2 +- dist/goods-action/index.wxss | 2 +- dist/grid-item/index.wxss | 2 +- dist/icon/index.wxss | 2 +- dist/image/index.wxml | 8 +- dist/image/index.wxss | 2 +- dist/info/index.wxss | 2 +- dist/loading/index.js | 17 +-- dist/loading/index.wxml | 28 ++--- dist/loading/index.wxss | 2 +- dist/nav-bar/index.wxss | 2 +- dist/notice-bar/index.wxml | 2 +- dist/notice-bar/index.wxss | 2 +- dist/panel/index.wxss | 2 +- dist/picker-column/index.wxss | 2 +- dist/picker/index.wxss | 2 +- dist/popup/index.wxss | 2 +- dist/progress/index.wxss | 2 +- dist/radio/index.wxss | 2 +- dist/rate/index.wxss | 2 +- dist/search/index.wxss | 2 +- dist/sidebar-item/index.js | 15 ++- dist/sidebar-item/index.wxml | 2 +- dist/sidebar-item/index.wxss | 2 +- dist/sidebar/index.js | 28 ++--- dist/sidebar/index.wxss | 2 +- dist/skeleton/index.d.ts | 1 + dist/skeleton/index.js | 41 +++++++ dist/skeleton/index.json | 4 + dist/skeleton/index.wxml | 28 +++++ dist/skeleton/index.wxss | 1 + dist/slider/index.wxss | 2 +- dist/stepper/index.wxml | 67 ++++++----- dist/stepper/index.wxss | 2 +- dist/steps/index.wxss | 2 +- dist/sticky/index.js | 106 +++++------------ dist/sticky/index.wxml | 6 +- dist/sticky/index.wxss | 2 +- dist/submit-bar/index.wxss | 2 +- dist/switch/index.wxml | 2 +- dist/switch/index.wxss | 2 +- dist/tab/index.js | 20 +++- dist/tabbar-item/index.wxml | 8 +- dist/tabbar-item/index.wxss | 2 +- dist/tabbar/index.wxss | 2 +- dist/tabs/index.js | 159 ++++++++------------------ dist/tabs/index.json | 3 +- dist/tabs/index.wxml | 65 ++++++----- dist/tabs/index.wxss | 2 +- dist/tag/index.js | 6 + dist/tag/index.wxml | 6 + dist/tag/index.wxss | 2 +- dist/toast/index.wxss | 2 +- dist/toast/toast.js | 2 +- dist/tree-select/index.js | 57 ++++------ dist/tree-select/index.json | 4 +- dist/tree-select/index.wxml | 30 +++-- dist/tree-select/index.wxss | 2 +- dist/uploader/index.d.ts | 1 + dist/uploader/index.js | 156 +++++++++++++++++++++++++ dist/uploader/index.json | 6 + dist/uploader/index.wxml | 60 ++++++++++ dist/uploader/index.wxss | 1 + dist/uploader/utils.d.ts | 12 ++ dist/uploader/utils.js | 16 +++ lib/action-sheet/index.wxml | 2 +- lib/action-sheet/index.wxss | 2 +- lib/area/index.js | 4 +- lib/button/index.wxml | 2 +- lib/button/index.wxss | 2 +- lib/card/index.wxss | 2 +- lib/cell-group/index.wxss | 2 +- lib/cell/index.wxss | 2 +- lib/checkbox/index.wxss | 2 +- lib/circle/index.wxss | 2 +- lib/collapse-item/index.wxss | 2 +- lib/count-down/index.js | 4 + lib/count-down/index.wxss | 2 +- lib/datetime-picker/index.js | 2 +- lib/dialog/index.wxss | 2 +- lib/divider/index.wxml | 4 +- lib/divider/index.wxss | 2 +- lib/dropdown-item/index.wxss | 2 +- lib/dropdown-menu/index.wxss | 2 +- lib/field/index.js | 1 + lib/field/index.wxml | 2 + lib/field/index.wxss | 2 +- lib/goods-action-button/index.js | 16 +-- lib/goods-action-button/index.wxml | 1 - lib/goods-action-button/index.wxss | 2 +- lib/goods-action-icon/index.wxss | 2 +- lib/goods-action/index.wxss | 2 +- lib/grid-item/index.wxss | 2 +- lib/icon/index.wxss | 2 +- lib/image/index.wxml | 8 +- lib/image/index.wxss | 2 +- lib/info/index.wxss | 2 +- lib/loading/index.js | 17 +-- lib/loading/index.wxml | 28 ++--- lib/loading/index.wxss | 2 +- lib/nav-bar/index.wxss | 2 +- lib/notice-bar/index.wxml | 2 +- lib/notice-bar/index.wxss | 2 +- lib/panel/index.wxss | 2 +- lib/picker-column/index.wxss | 2 +- lib/picker/index.wxss | 2 +- lib/popup/index.wxss | 2 +- lib/progress/index.wxss | 2 +- lib/radio/index.wxss | 2 +- lib/rate/index.wxss | 2 +- lib/search/index.wxss | 2 +- lib/sidebar-item/index.js | 15 ++- lib/sidebar-item/index.wxml | 2 +- lib/sidebar-item/index.wxss | 2 +- lib/sidebar/index.js | 28 ++--- lib/sidebar/index.wxss | 2 +- lib/skeleton/index.js | 43 +++++++ lib/skeleton/index.json | 4 + lib/skeleton/index.wxml | 28 +++++ lib/skeleton/index.wxss | 1 + lib/slider/index.wxss | 2 +- lib/stepper/index.wxml | 67 ++++++----- lib/stepper/index.wxss | 2 +- lib/steps/index.wxss | 2 +- lib/sticky/index.js | 102 +++++------------ lib/sticky/index.wxml | 6 +- lib/sticky/index.wxss | 2 +- lib/submit-bar/index.wxss | 2 +- lib/switch/index.wxml | 2 +- lib/switch/index.wxss | 2 +- lib/tab/index.js | 20 +++- lib/tabbar-item/index.wxml | 8 +- lib/tabbar-item/index.wxss | 2 +- lib/tabbar/index.wxss | 2 +- lib/tabs/index.js | 156 ++++++++----------------- lib/tabs/index.json | 3 +- lib/tabs/index.wxml | 65 ++++++----- lib/tabs/index.wxss | 2 +- lib/tag/index.js | 6 + lib/tag/index.wxml | 6 + lib/tag/index.wxss | 2 +- lib/toast/index.wxss | 2 +- lib/toast/toast.js | 2 +- lib/tree-select/index.js | 58 ++++------ lib/tree-select/index.json | 4 +- lib/tree-select/index.wxml | 30 +++-- lib/tree-select/index.wxss | 2 +- lib/uploader/index.js | 171 ++++++++++++++++++++++++++++ lib/uploader/index.json | 6 + lib/uploader/index.wxml | 60 ++++++++++ lib/uploader/index.wxss | 1 + lib/uploader/utils.js | 20 ++++ 177 files changed, 1326 insertions(+), 872 deletions(-) create mode 100644 dist/skeleton/index.d.ts create mode 100644 dist/skeleton/index.js create mode 100644 dist/skeleton/index.json create mode 100644 dist/skeleton/index.wxml create mode 100644 dist/skeleton/index.wxss create mode 100644 dist/uploader/index.d.ts create mode 100644 dist/uploader/index.js create mode 100644 dist/uploader/index.json create mode 100644 dist/uploader/index.wxml create mode 100644 dist/uploader/index.wxss create mode 100644 dist/uploader/utils.d.ts create mode 100644 dist/uploader/utils.js create mode 100644 lib/skeleton/index.js create mode 100644 lib/skeleton/index.json create mode 100644 lib/skeleton/index.wxml create mode 100644 lib/skeleton/index.wxss create mode 100644 lib/uploader/index.js create mode 100644 lib/uploader/index.json create mode 100644 lib/uploader/index.wxml create mode 100644 lib/uploader/index.wxss create mode 100644 lib/uploader/utils.js diff --git a/dist/action-sheet/index.wxml b/dist/action-sheet/index.wxml index 2dcbf4f8..bed9b06b 100644 --- a/dist/action-sheet/index.wxml +++ b/dist/action-sheet/index.wxml @@ -38,7 +38,7 @@ {{ item.name }} {{ item.subname }} - + diff --git a/dist/action-sheet/index.wxss b/dist/action-sheet/index.wxss index 7982ab26..add1116b 100644 --- a/dist/action-sheet/index.wxss +++ b/dist/action-sheet/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333;color:var(--action-sheet-item-text-color,#333)}.van-action-sheet__cancel,.van-action-sheet__item{font-size:16px;line-height:50px;text-align:center;background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel{height:50px}.van-action-sheet__cancel:before{display:block;height:8px;content:" ";background-color:#f8f8f8;background-color:var(--action-sheet-cancel-padding-color,#f8f8f8)}.van-action-sheet__item--disabled{color:#c9c9c9;color:var(--action-sheet-item-disabled-text-color,#c9c9c9)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;font-size:12px;color:#7d7e80;color:var(--action-sheet-subname-color,#7d7e80)}.van-action-sheet__header{font-weight:500;font-size:16px;line-height:44px;text-align:center}.van-action-sheet__description{padding:16px;color:#7d7e80;font-size:14px;line-height:20px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 12px;font-size:18px!important;line-height:inherit!important;color:#999;color:var(--action-sheet-close-icon-color,#999)} \ No newline at end of file +@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;max-height:var(--action-sheet-max-height,90%)!important;color:#323233;color:var(--action-sheet-item-text-color,#323233)}.van-action-sheet__cancel,.van-action-sheet__item{text-align:center;font-size:16px;font-size:var(--action-sheet-item-font-size,16px);line-height:50px;line-height:var(--action-sheet-item-height,50px);background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel:before{display:block;content:" ";height:8px;height:var(--action-sheet-cancel-padding-top,8px);background-color:#f8f8f8;background-color:var(--action-sheet-cancel-padding-color,#f8f8f8)}.van-action-sheet__item--disabled{color:#c8c9cc;color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;margin-left:var(--padding-base,4px);font-size:12px;font-size:var(--action-sheet-subname-font-size,12px);color:#7d7e80;color:var(--action-sheet-subname-color,#7d7e80)}.van-action-sheet__header{text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--action-sheet-header-font-size,16px);line-height:44px;line-height:var(--action-sheet-header-height,44px)}.van-action-sheet__description{text-align:center;padding:16px;padding:var(--padding-md,16px);color:#7d7e80;color:var(--action-sheet-description-color,#7d7e80);font-size:14px;font-size:var(--action-sheet-description-font-size,14px);line-height:20px;line-height:var(--action-sheet-description-line-height,20px)}.van-action-sheet__close{position:absolute!important;top:0;right:0;line-height:inherit!important;padding:0 12px;padding:var(--action-sheet-close-icon-padding,0 12px);font-size:18px!important;font-size:var(--action-sheet-close-icon-size,18px)!important;color:#969799;color:var(--action-sheet-close-icon-color,#969799)}.van-action-sheet__loading{display:-webkit-flex!important;display:flex!important;height:50px;height:var(--action-sheet-item-height,50px)} \ No newline at end of file diff --git a/dist/area/index.js b/dist/area/index.js index 0e7cd6dd..81517e2d 100644 --- a/dist/area/index.js +++ b/dist/area/index.js @@ -67,7 +67,10 @@ VantComponent({ // parse output columns data parseOutputValues(values) { const { columnsPlaceholder } = this.data; - return values.map((value = {}, index) => { + return values.map((value, index) => { + // save undefined value + if (!value) + return value; value = JSON.parse(JSON.stringify(value)); if (!value.code || value.name === columnsPlaceholder[index]) { value.code = ''; diff --git a/dist/button/index.wxml b/dist/button/index.wxml index 639e0f15..77b49429 100644 --- a/dist/button/index.wxml +++ b/dist/button/index.wxml @@ -28,7 +28,7 @@ custom-class="loading-class" size="{{ loadingSize }}" type="{{ loadingType }}" - color="{{ type === 'default' ? '#c9c9c9' : '' }}" + color="{{ type === 'default' ? '#c9c9c9' : 'white' }}" /> - \ No newline at end of file + diff --git a/dist/divider/index.wxss b/dist/divider/index.wxss index 16eb8896..c055e3af 100644 --- a/dist/divider/index.wxss +++ b/dist/divider/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-divider{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin:16px 0;color:#999;font-size:14px;line-height:24px;border:0 solid #eee}.van-divider:after,.van-divider:before{display:block;-webkit-flex:1;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:1px 0 0}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:16px}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{margin-left:16px;content:""}.van-divider--left:before,.van-divider--right:after{max-width:10%} \ No newline at end of file +@import '../common/index.wxss';.van-divider{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin:16px 0;margin:var(--divider-margin,16px 0);color:#969799;color:var(--divider-text-color,#969799);font-size:14px;font-size:var(--divider-font-size,14px);line-height:24px;line-height:var(--divider-line-height,24px);border:0 solid #ebedf0;border-color:var(--divider-border-color,#ebedf0)}.van-divider:after,.van-divider:before{display:block;-webkit-flex:1;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:1px 0 0}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:16px;margin-right:var(--divider-content-padding,16px)}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{content:"";margin-left:16px;margin-left:var(--divider-content-padding,16px)}.van-divider--left:before{max-width:10%;max-width:var(--divider-content-left-width,10%)}.van-divider--right:after{max-width:10%;max-width:var(--divider-content-right-width,10%)} \ No newline at end of file diff --git a/dist/dropdown-item/index.wxss b/dist/dropdown-item/index.wxss index 3eb29f0e..e06c2874 100644 --- a/dist/dropdown-item/index.wxss +++ b/dist/dropdown-item/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dropdown-item{position:fixed;right:0;left:0;overflow:hidden}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:#1989fa}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file +@import '../common/index.wxss';.van-dropdown-item{position:fixed;right:0;left:0;overflow:hidden}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:#1989fa;color:var(--dropdown-menu-option-active-color,#1989fa)}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file diff --git a/dist/dropdown-menu/index.wxss b/dist/dropdown-menu/index.wxss index 12e3d114..43efd779 100644 --- a/dist/dropdown-menu/index.wxss +++ b/dist/dropdown-menu/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dropdown-menu{display:-webkit-flex;display:flex;height:50px;background-color:#fff;-webkit-user-select:none;user-select:none}.van-dropdown-menu__item{display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:#999}.van-dropdown-menu__title{position:relative;box-sizing:border-box;max-width:100%;padding:0 8px;color:#333;font-size:15px;line-height:18px}.van-dropdown-menu__title:after{position:absolute;top:50%;right:-4px;margin-top:-5px;border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);opacity:.8;content:""}.van-dropdown-menu__title--active{color:#1989fa}.van-dropdown-menu__title--down:after{margin-top:-1px;-webkit-transform:rotate(135deg);transform:rotate(135deg)} \ No newline at end of file +@import '../common/index.wxss';.van-dropdown-menu{display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;height:50px;height:var(--dropdown-menu-height,50px);background-color:#fff;background-color:var(--dropdown-menu-background-color,#fff)}.van-dropdown-menu__item{display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:#969799;color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{position:relative;box-sizing:border-box;max-width:100%;padding:0 8px;padding:var(--dropdown-menu-title-padding,0 8px);color:#323233;color:var(--dropdown-menu-title-text-color,#323233);font-size:15px;font-size:var(--dropdown-menu-title-font-size,15px);line-height:18px;line-height:var(--dropdown-menu-title-line-height,18px)}.van-dropdown-menu__title:after{position:absolute;top:50%;right:-4px;margin-top:-5px;border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);opacity:.8;content:""}.van-dropdown-menu__title--active{color:#1989fa;color:var(--dropdown-menu-title-active-text-color,#1989fa)}.van-dropdown-menu__title--down:after{margin-top:-1px;-webkit-transform:rotate(135deg);transform:rotate(135deg)} \ No newline at end of file diff --git a/dist/field/index.js b/dist/field/index.js index 79706603..35dc34c3 100644 --- a/dist/field/index.js +++ b/dist/field/index.js @@ -27,6 +27,7 @@ VantComponent({ customStyle: String, confirmType: String, confirmHold: Boolean, + holdKeyboard: Boolean, errorMessage: String, arrowDirection: String, placeholderStyle: String, diff --git a/dist/field/index.wxml b/dist/field/index.wxml index 944e441f..64901781 100644 --- a/dist/field/index.wxml +++ b/dist/field/index.wxml @@ -32,6 +32,7 @@ cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" show-confirm-bar="{{ showConfirmBar }}" + hold-keyboard="{{ holdKeyboard }}" selection-end="{{ selectionEnd }}" selection-start="{{ selectionStart }}" bindinput="onInput" @@ -53,6 +54,7 @@ placeholder-class="{{ utils.bem('field__placeholder', { error }) }}" confirm-type="{{ confirmType }}" confirm-hold="{{ confirmHold }}" + hold-keyboard="{{ holdKeyboard }}" cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" selection-end="{{ selectionEnd }}" diff --git a/dist/field/index.wxss b/dist/field/index.wxss index 6c2d79c4..9297f8d9 100644 --- a/dist/field/index.wxss +++ b/dist/field/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px;line-height:1.2em}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;box-sizing:border-box;width:100%;height:24px;min-height:24px;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#333;color:var(--text-color,#333)}.van-field__input--textarea{height:18px;min-height:18px}.van-field__input--error{color:#ee0a24;color:var(--red,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#999;color:var(--gray-dark,#999)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#999;color:var(--gray-dark,#999)}.van-field__placeholder--error{color:#ee0a24;color:var(--red,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px}.van-field__clear-root,.van-field__icon-container{margin-right:-10px;padding:0 10px;line-height:inherit;vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c9c9c9;color:var(--gray,#c9c9c9)}.van-field__icon-container{color:#999;color:var(--gray-dark,#999)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:10px}.van-field__button:empty{display:none}.van-field__error-message{font-size:12px;text-align:left;color:#ee0a24;color:var(--red,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} \ No newline at end of file +@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{line-height:1.2em;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;box-sizing:border-box;width:100%;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#323233;color:var(--field-input-text-color,#323233);height:24px;height:var(--cell-line-height,24px);min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__input--textarea{height:18px;height:var(--field-text-area-min-height,18px);min-height:18px;min-height:var(--field-text-area-min-height,18px)}.van-field__input--error{color:#ee0a24;color:var(--field-input-error-text-color,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#969799;color:var(--field-input-disabled-text-color,#969799)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#969799;color:var(--field-placeholder-text-color,#969799)}.van-field__placeholder--error{color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;vertical-align:middle;padding:0 8px;padding:0 var(--padding-xs,8px);margin-right:-8px;margin-right:-var(--padding-xs,8px)}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c8c9cc;color:var(--field-clear-icon-color,#c8c9cc)}.van-field__icon-container{color:#969799;color:var(--field-icon-container-color,#969799)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:8px;padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{text-align:left;font-size:12px;font-size:var(--field-error-message-text-font-size,12px);color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} \ No newline at end of file diff --git a/dist/goods-action-button/index.js b/dist/goods-action-button/index.js index 4aa71c65..8eed4a3c 100644 --- a/dist/goods-action-button/index.js +++ b/dist/goods-action-button/index.js @@ -30,21 +30,11 @@ VantComponent({ this.jumpLink(); }, updateStyle() { - const { parent } = this; - const { children = [] } = parent; + const { children = [] } = this.parent; const index = children.indexOf(this); - const { length } = children; - let isFirst = false; - let isLast = false; - if (index === 0) { - isFirst = true; - } - if (index === length - 1) { - isLast = true; - } this.setData({ - isFirst, - isLast + isFirst: index === 0, + isLast: index === children.length - 1 }); } } diff --git a/dist/goods-action-button/index.wxml b/dist/goods-action-button/index.wxml index 366b8cd7..d6d2daab 100644 --- a/dist/goods-action-button/index.wxml +++ b/dist/goods-action-button/index.wxml @@ -2,7 +2,6 @@ -
@@ -29,8 +29,8 @@ name="photo-o" size="22" /> -
-
+ @@ -43,5 +43,5 @@ name="warning-o" size="22" /> -
+ diff --git a/dist/image/index.wxss b/dist/image/index.wxss index ade9f694..917d3c75 100644 --- a/dist/image/index.wxss +++ b/dist/image/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-image{position:relative;display:inline-block}.van-image--round{overflow:hidden;border-radius:50%}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;width:100%;height:100%}.van-image__error,.van-image__loading{position:absolute;top:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#999;font-size:14px;background-color:#f8f8f8} \ No newline at end of file +@import '../common/index.wxss';.van-image{position:relative;display:inline-block}.van-image--round{overflow:hidden;border-radius:50%}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;width:100%;height:100%}.van-image__error,.van-image__loading{position:absolute;top:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#969799;color:var(--image-placeholder-text-color,#969799);font-size:14px;font-size:var(--image-placeholder-font-size,14px);background-color:#f8f8f8;background-color:var(--image-placeholder-background-color,#f8f8f8)} \ No newline at end of file diff --git a/dist/info/index.wxss b/dist/info/index.wxss index d3ec4c0d..16e3f329 100644 --- a/dist/info/index.wxss +++ b/dist/info/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-info{position:absolute;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translateX(50%);transform:translateX(50%);-webkit-transform-origin:100%;transform-origin:100%;top:-8px;top:calc(var(--info-size, 16px)/-2);min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} \ No newline at end of file +@import '../common/index.wxss';.van-info{position:absolute;top:0;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%);-webkit-transform-origin:100%;transform-origin:100%;min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} \ No newline at end of file diff --git a/dist/loading/index.js b/dist/loading/index.js index ef80c32a..af510c87 100644 --- a/dist/loading/index.js +++ b/dist/loading/index.js @@ -2,27 +2,20 @@ import { VantComponent } from '../common/component'; import { addUnit } from '../common/utils'; VantComponent({ props: { - size: { - type: String, - observer: 'setSizeWithUnit' - }, + color: String, + vertical: Boolean, type: { type: String, value: 'circular' }, - color: { + size: { type: String, - value: '#c9c9c9' + observer: 'setSizeWithUnit' }, textSize: { type: String, observer: 'setTextSizeWithUnit' - }, - vertical: Boolean - }, - data: { - sizeWithUnit: '30px', - textSizeWithUnit: '14px' + } }, methods: { setSizeWithUnit(size) { diff --git a/dist/loading/index.wxml b/dist/loading/index.wxml index 88b0148f..5229d043 100644 --- a/dist/loading/index.wxml +++ b/dist/loading/index.wxml @@ -1,24 +1,16 @@ - + - - + wx:if="{{ type === 'spinner' }}" + wx:for="item in 12" + wx:key="index" + class="van-loading__dot" + /> - + - \ No newline at end of file + diff --git a/dist/loading/index.wxss b/dist/loading/index.wxss index 64ceff23..f28a6b46 100644 --- a/dist/loading/index.wxss +++ b/dist/loading/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-loading__wrapper{position:relative;z-index:0;display:inline-block;line-height:0}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading__spinner{position:relative;z-index:-1;display:inline-block;box-sizing:border-box;width:100%;height:100%;-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;color:#969799}.van-loading__text--vertical{margin:8px 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file +@import '../common/index.wxss';:host{font-size:0;line-height:1}.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#c8c9cc;color:var(--loading-spinner-color,#c8c9cc)}.van-loading__spinner{position:relative;box-sizing:border-box;width:30px;width:var(--loading-spinner-size,30px);max-width:100%;max-height:100%;height:30px;height:var(--loading-spinner-size,30px);-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite;-webkit-animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite;animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;margin-left:var(--padding-xs,8px);color:#969799;color:var(--loading-text-color,#969799);font-size:14px;font-size:var(--loading-text-font-size,14px);line-height:20px;line-height:var(--loading-text-line-height,20px)}.van-loading__text:empty{display:none}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading--vertical .van-loading__text{margin:8px 0 0;margin:var(--padding-xs,8px) 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file diff --git a/dist/nav-bar/index.wxss b/dist/nav-bar/index.wxss index 1ba28ea7..3fbfb7e3 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(--white,#fff)}.van-nav-bar__text{display:inline-block;margin:0 -15px;padding:0 15px;vertical-align:middle;color:#1989fa;color:var(--blue,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;color:#1989fa;color:var(--blue,#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;font-weight:500;font-size:16px}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px} \ 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/notice-bar/index.wxml b/dist/notice-bar/index.wxml index 38b7bc00..eb0851c3 100644 --- a/dist/notice-bar/index.wxml +++ b/dist/notice-bar/index.wxml @@ -24,7 +24,7 @@ wx:if="{{ mode === 'closeable' }}" class="van-notice-bar__right-icon" name="cross" - bind:tap="onClickIcon" + catch:tap="onClickIcon" /> { this.$emit('click', index); parent.$emit('change', index); }); }, - setActive(active) { - return this.setData({ active }); + setActive(selected) { + return this.setData({ selected }); } } }); diff --git a/dist/sidebar-item/index.wxml b/dist/sidebar-item/index.wxml index 6ae8d538..f68e8644 100644 --- a/dist/sidebar-item/index.wxml +++ b/dist/sidebar-item/index.wxml @@ -1,7 +1,7 @@ item !== target); - this.setActive(this.data.active); + this.items = this.children.filter((item) => item !== target); + this.setActive(this.data.activeKey); } }, props: { - active: { + activeKey: { type: Number, value: 0, observer: 'setActive' } }, beforeCreate() { - this.items = []; + this.children = []; this.currentActive = -1; }, methods: { - setActive(active) { - const { items, currentActive } = this; - if (!items.length) { + setActive(activeKey) { + const { children, currentActive } = this; + if (!children.length) { return Promise.resolve(); } - this.currentActive = active; + this.currentActive = activeKey; const stack = []; - if (currentActive !== active && items[currentActive]) { - stack.push(items[currentActive].setActive(false)); + if (currentActive !== activeKey && children[currentActive]) { + stack.push(children[currentActive].setActive(false)); } - if (items[active]) { - stack.push(items[active].setActive(true)); + if (children[activeKey]) { + stack.push(children[activeKey].setActive(true)); } return Promise.all(stack); } diff --git a/dist/sidebar/index.wxss b/dist/sidebar/index.wxss index 42bccb26..ba3ba942 100644 --- a/dist/sidebar/index.wxss +++ b/dist/sidebar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-sidebar{width:85px} \ No newline at end of file +@import '../common/index.wxss';.van-sidebar{width:85px;width:var(--sidebar-width,85px)} \ No newline at end of file diff --git a/dist/skeleton/index.d.ts b/dist/skeleton/index.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/skeleton/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/skeleton/index.js b/dist/skeleton/index.js new file mode 100644 index 00000000..4092bbd9 --- /dev/null +++ b/dist/skeleton/index.js @@ -0,0 +1,41 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + row: { + type: Number, + value: 0 + }, + title: Boolean, + avatar: Boolean, + loading: { + type: Boolean, + value: true + }, + animate: { + type: Boolean, + value: true + }, + avatarSize: { + type: String, + value: '32px' + }, + avatarShape: { + type: String, + value: 'round' + }, + titleWidth: { + type: String, + value: '40%' + }, + rowWidth: { + type: null, + value: '100%', + observer(val) { + this.setData({ isArray: val instanceof Array }); + } + } + }, + data: { + isArray: false + } +}); diff --git a/dist/skeleton/index.json b/dist/skeleton/index.json new file mode 100644 index 00000000..e8cfaaf8 --- /dev/null +++ b/dist/skeleton/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/dist/skeleton/index.wxml b/dist/skeleton/index.wxml new file mode 100644 index 00000000..154d299d --- /dev/null +++ b/dist/skeleton/index.wxml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/dist/skeleton/index.wxss b/dist/skeleton/index.wxss new file mode 100644 index 00000000..565b26e4 --- /dev/null +++ b/dist/skeleton/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-skeleton{display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:0 16px;padding:var(--skeleton-padding,0 16px)}.van-skeleton__avatar{-webkit-flex-shrink:0;flex-shrink:0;margin-right:16px;margin-right:var(--padding-md,16px);background-color:#f2f3f5;background-color:var(--skeleton-avatar-background-color,#f2f3f5)}.van-skeleton__avatar--round{border-radius:100%}.van-skeleton__content{-webkit-flex:1;flex:1}.van-skeleton__avatar+.van-skeleton__content{padding-top:8px;padding-top:var(--padding-xs,8px)}.van-skeleton__row,.van-skeleton__title{height:16px;height:var(--skeleton-row-height,16px);background-color:#f2f3f5;background-color:var(--skeleton-row-background-color,#f2f3f5)}.van-skeleton__title{margin:0}.van-skeleton__row:not(:first-child){margin-top:12px;margin-top:var(--skeleton-row-margin-top,12px)}.van-skeleton__title+.van-skeleton__row{margin-top:20px}.van-skeleton--animate{-webkit-animation:van-skeleton-blink 1.2s ease-in-out infinite;animation:van-skeleton-blink 1.2s ease-in-out infinite}@-webkit-keyframes van-skeleton-blink{50%{opacity:.6}}@keyframes van-skeleton-blink{50%{opacity:.6}} \ No newline at end of file diff --git a/dist/slider/index.wxss b/dist/slider/index.wxss index 85681030..4cd94be6 100644 --- a/dist/slider/index.wxss +++ b/dist/slider/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;background-color:#e5e5e5;background-color:var(--gray-light,#e5e5e5)}.van-slider:before{position:absolute;top:-8px;right:0;bottom:-8px;left:0;content:""}.van-slider__bar{position:relative;border-radius:inherit;transition:width .2s;background-color:#1989fa;background-color:var(--blue,#1989fa)}.van-slider__button{width:24px;height:24px;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.5);background-color:#fff;background-color:var(--white,#fff)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider--disabled{opacity:.3} \ No newline at end of file +@import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;border-radius:var(--border-radius-max,999px);background-color:#e5e5e5;background-color:var(--slider-inactive-background-color,#e5e5e5)}.van-slider:before{position:absolute;right:0;left:0;content:"";top:-8px;top:-var(--padding-xs,8px);bottom:-8px;bottom:-var(--padding-xs,8px)}.van-slider__bar{position:relative;border-radius:inherit;transition:width .2s;transition:width var(--animation-duration-fast,.2s);background-color:#1989fa;background-color:var(--slider-active-background-color,#1989fa)}.van-slider__button{width:24px;height:24px;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.5);background-color:#fff;background-color:var(--slider-button-background-color,#fff)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider--disabled{opacity:.5} \ No newline at end of file diff --git a/dist/stepper/index.wxml b/dist/stepper/index.wxml index 0c03912e..06480dc0 100644 --- a/dist/stepper/index.wxml +++ b/dist/stepper/index.wxml @@ -1,38 +1,37 @@ - - - + + + - diff --git a/dist/stepper/index.wxss b/dist/stepper/index.wxss index 2ffb4c71..cf020ace 100644 --- a/dist/stepper/index.wxss +++ b/dist/stepper/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-stepper{font-size:0}.van-stepper__minus,.van-stepper__plus{position:relative;display:inline-block;box-sizing:border-box;width:28px;height:28px;margin:1px;padding:5px;vertical-align:middle;border:0;background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5)}.van-stepper__minus:before,.van-stepper__plus:before{width:9px;height:1px}.van-stepper__minus:after,.van-stepper__plus:after{width:1px;height:9px}.van-stepper__minus:after,.van-stepper__minus:before,.van-stepper__plus:after,.van-stepper__plus:before{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;content:"";background-color:#333;background-color:var(--text-color,#333)}.van-stepper__minus--hover,.van-stepper__plus--hover{background-color:#e8e8e8;background-color:var(--stepper-active-color,#e8e8e8)}.van-stepper__minus--disabled,.van-stepper__plus--disabled{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus--disabled:after,.van-stepper__minus--disabled:before,.van-stepper__plus--disabled:after,.van-stepper__plus--disabled:before{background-color:#c9c9c9;background-color:var(--gray,#c9c9c9)}.van-stepper__minus--disabled.van-stepper__minus--hover,.van-stepper__minus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus{border-radius:4px 0 0 4px;border-radius:var(--stepper-border-radius,4px) 0 0 var(--stepper-border-radius,4px)}.van-stepper__minus:after{display:none}.van-stepper__plus{border-radius:0 4px 4px 0;border-radius:0 var(--stepper-border-radius,4px) var(--stepper-border-radius,4px) 0}.van-stepper__input{display:inline-block;box-sizing:border-box;width:32px;height:28px;min-height:0;margin:1px;padding:1px;font-size:14px;text-align:center;vertical-align:middle;border:0;border-width:1px 0;border-radius:0;-webkit-appearance:none;color:#333;color:var(--text-color,#333);background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5)}.van-stepper__input--disabled{color:#c9c9c9;color:var(--gray,#c9c9c9);background-color:#f2f3f5;background-color:var(--stepper-input-disabled-color,#f2f3f5)} \ No newline at end of file +@import '../common/index.wxss';.van-stepper{font-size:0}.van-stepper__minus,.van-stepper__plus{position:relative;display:inline-block;box-sizing:border-box;margin:1px;vertical-align:middle;border:0;background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5);color:#323233;color:var(--stepper-button-icon-color,#323233);width:28px;width:var(--stepper-input-height,28px);height:28px;height:var(--stepper-input-height,28px);padding:4px;padding:var(--padding-base,4px)}.van-stepper__minus:before,.van-stepper__plus:before{width:9px;height:1px}.van-stepper__minus:after,.van-stepper__plus:after{width:1px;height:9px}.van-stepper__minus:after,.van-stepper__minus:before,.van-stepper__plus:after,.van-stepper__plus:before{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;content:"";background-color:#323233;background-color:var(--text-color,#323233)}.van-stepper__minus--hover,.van-stepper__plus--hover{background-color:#e8e8e8;background-color:var(--stepper-active-color,#e8e8e8)}.van-stepper__minus--disabled,.van-stepper__plus--disabled{color:#c8c9cc;color:var(--stepper-button-disabled-icon-color,#c8c9cc)}.van-stepper__minus--disabled,.van-stepper__minus--disabled.van-stepper__minus--hover,.van-stepper__minus--disabled.van-stepper__plus--hover,.van-stepper__minus--disabled:after,.van-stepper__minus--disabled:before,.van-stepper__plus--disabled,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled:after,.van-stepper__plus--disabled:before{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus{border-radius:4px 0 0 4px;border-radius:var(--stepper-border-radius,4px) 0 0 var(--stepper-border-radius,4px)}.van-stepper__minus:after{display:none}.van-stepper__plus{border-radius:0 4px 4px 0;border-radius:0 var(--stepper-border-radius,4px) var(--stepper-border-radius,4px) 0}.van-stepper__input{display:inline-block;box-sizing:border-box;min-height:0;margin:1px;padding:1px;text-align:center;vertical-align:middle;border:0;border-width:1px 0;border-radius:0;-webkit-appearance:none;font-size:14px;font-size:var(--stepper-input-font-size,14px);color:#323233;color:var(--stepper-input-text-color,#323233);background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5);width:32px;width:var(--stepper-input-width,32px);height:28px;height:var(--stepper-input-height,28px)}.van-stepper__input--disabled{color:#c8c9cc;color:var(--stepper-input-disabled-text-color,#c8c9cc);background-color:#f2f3f5;background-color:var(--stepper-input-disabled-background-color,#f2f3f5)} \ No newline at end of file diff --git a/dist/steps/index.wxss b/dist/steps/index.wxss index 11e11c8d..2c50b1ab 100644 --- a/dist/steps/index.wxss +++ b/dist/steps/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--white,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:-webkit-flex;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;-webkit-flex:1;flex:1;font-size:14px;color:#999;color:var(--gray-dark,#999)}.van-step--finish{color:#333;color:var(--text-color,#333)}.van-step__circle{width:5px;height:5px;border-radius:50%;background-color:#999;background-color:var(--gray-dark,#999)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{-webkit-transform:none;transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;-webkit-transform:none;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;padding:0 8px;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff)}.van-step--horizontal .van-step__title{display:inline-block;font-size:12px;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);background-color:#eee;background-color:var(--border-color,#eee)}.van-step--horizontal.van-step--process{color:#333;color:var(--text-color,#333)}.van-step--horizontal.van-step--process .van-step__icon{display:block;font-size:12px;line-height:1}.van-step--vertical{padding:10px 10px 10px 0;font-size:14px;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{font-size:12px;line-height:1}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);background-color:#eee;background-color:var(--border-color,#eee)} \ No newline at end of file +@import '../common/index.wxss';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--steps-background-color,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:-webkit-flex;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;-webkit-flex:1;flex:1;font-size:14px;font-size:var(--step-font-size,14px);color:#969799;color:var(--step-text-color,#969799)}.van-step--finish{color:#323233;color:var(--step-finish-text-color,#323233)}.van-step__circle{border-radius:50%;width:5px;width:var(--step-circle-size,5px);height:5px;height:var(--step-circle-size,5px);background-color:#969799;background-color:var(--step-circle-color,#969799)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{-webkit-transform:none;transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;-webkit-transform:none;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff);padding:0 8px;padding:0 var(--padding-xs,8px)}.van-step--horizontal .van-step__title{display:inline-block;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);font-size:12px;font-size:var(--step-horizontal-title-font-size,12px)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)}.van-step--horizontal.van-step--process{color:#323233;color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical{padding:10px 10px 10px 0;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)} \ No newline at end of file diff --git a/dist/sticky/index.js b/dist/sticky/index.js index 479fff5d..4acf585d 100644 --- a/dist/sticky/index.js +++ b/dist/sticky/index.js @@ -1,5 +1,4 @@ import { VantComponent } from '../common/component'; -import { nextTick } from '../common/utils'; VantComponent({ props: { zIndex: { @@ -9,101 +8,58 @@ VantComponent({ offsetTop: { type: Number, value: 0 - } + }, + disabled: Boolean }, data: { - position: '', - height: 0, wrapStyle: '', containerStyle: '' }, methods: { - setWrapStyle() { - const { offsetTop, position } = this.data; - let wrapStyle; - let containerStyle; - switch (position) { - case 'top': - wrapStyle = ` - top: ${offsetTop}px; - position: fixed; - `; - containerStyle = `height: ${this.itemHeight}px;`; - break; - case 'bottom': - wrapStyle = ` - top: auto; - bottom: 0; - `; - containerStyle = ''; - break; - default: - wrapStyle = ''; - containerStyle = ''; + setStyle() { + const { offsetTop, height, fixed, zIndex } = this.data; + if (fixed) { + this.setData({ + wrapStyle: `top: ${offsetTop}px;`, + containerStyle: `height: ${height}px; z-index: ${zIndex};` + }); } - const data = {}; - if (wrapStyle !== this.data.wrapStyle) { - data.wrapStyle = wrapStyle; - } - if (containerStyle !== this.data.containerStyle) { - data.containerStyle = containerStyle; - } - if (JSON.stringify(data) !== '{}') { - this.setData(data); - } - }, - setPosition(position) { - if (position !== this.data.position) { - this.setData({ position }); - nextTick(() => { - this.setWrapStyle(); + else { + this.setData({ + wrapStyle: '', + containerStyle: '' }); } }, observerContentScroll() { - const { offsetTop = 0 } = this.data; - const { windowHeight } = wx.getSystemInfoSync(); - this.createIntersectionObserver({}).disconnect(); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ top: -(this.itemHeight + offsetTop) }) - .observe('.van-sticky', (res) => { - const { top } = res.boundingClientRect; - if (top > offsetTop) { - return; - } - const position = 'top'; - this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: true - }); - this.setPosition(position); + const { offsetTop } = this.data; + const intersectionObserver = this.createIntersectionObserver({ + thresholds: [0, 1] }); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ bottom: -(windowHeight - 1 - offsetTop) }) - .observe('.van-sticky', (res) => { - const { top, bottom } = res.boundingClientRect; - if (bottom <= this.itemHeight - 1) { + this.intersectionObserver = intersectionObserver; + intersectionObserver.relativeToViewport({ top: -offsetTop }); + intersectionObserver.observe('.van-sticky', (res) => { + if (this.data.disabled) { return; } - const position = res.intersectionRatio > 0 ? 'top' : ''; + // @ts-ignore + const { top, height } = res.boundingClientRect; + const fixed = top <= offsetTop; this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: position === 'top' + scrollTop: top, + isFixed: fixed + }); + this.setData({ fixed, height }); + wx.nextTick(() => { + this.setStyle(); }); - this.setPosition(position); }); } }, mounted() { - this.getRect('.van-sticky').then((rect) => { - this.itemHeight = rect.height; - this.itemTop = rect.top; - this.observerContentScroll(); - }); + this.observerContentScroll(); }, destroyed() { - this.createIntersectionObserver({}).disconnect(); + this.intersectionObserver.disconnect(); } }); diff --git a/dist/sticky/index.wxml b/dist/sticky/index.wxml index 73360c28..036cf143 100644 --- a/dist/sticky/index.wxml +++ b/dist/sticky/index.wxml @@ -1,5 +1,7 @@ - - + + + + diff --git a/dist/sticky/index.wxss b/dist/sticky/index.wxss index 86c02f56..52693875 100644 --- a/dist/sticky/index.wxss +++ b/dist/sticky/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-sticky{position:relative} \ No newline at end of file +@import '../common/index.wxss';.van-sticky{position:relative}.van-sticky-wrap--fixed{position:fixed;right:0;left:0} \ No newline at end of file diff --git a/dist/submit-bar/index.wxss b/dist/submit-bar/index.wxss index b891fcb8..c21838e8 100644 --- a/dist/submit-bar/index.wxss +++ b/dist/submit-bar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-submit-bar{position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none;z-index:100;z-index:var(--submit-bar-z-index,100)}.van-submit-bar__tip{padding:10px;padding:var(--submit-bar-tip-padding,10px);color:#f56723;color:var(--submit-bar-tip-color,#f56723);font-size:12px;font-size:var(--submit-bar-tip-font-size,12px);line-height:1.5;line-height:var(--submit-bar-tip-line-height,1.5);background-color:#fff7cc;background-color:var(--submit-bar-tip-background-color,#fff7cc)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end;height:50px;height:var(--submit-bar-height,50px);font-size:14px;font-size:var(--submit-bar-text-font-size,14px);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__bar--safe{padding-bottom:env(safe-area-inset-bottom)}.van-submit-bar__text{-webkit-flex:1;flex:1;padding-right:12px;font-weight:500;text-align:right;color:#333;color:var(--submit-bar-text-color,#333)}.van-submit-bar__price{color:#ee0a24;color:var(--submit-bar-price-color,#ee0a24);font-size:18px;font-size:var(--submit-bar-price-font-size,18px)}.van-submit-bar__currency{font-size:14px;font-size:var(--submit-bar-currency-font-size,14px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px;width:var(--submit-bar-button-width,110px)} \ No newline at end of file +@import '../common/index.wxss';.van-submit-bar{position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none;z-index:100;z-index:var(--submit-bar-z-index,100);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__tip{padding:10px;padding:var(--submit-bar-tip-padding,10px);color:#f56723;color:var(--submit-bar-tip-color,#f56723);font-size:12px;font-size:var(--submit-bar-tip-font-size,12px);line-height:1.5;line-height:var(--submit-bar-tip-line-height,1.5);background-color:#fff7cc;background-color:var(--submit-bar-tip-background-color,#fff7cc)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle;font-size:12px;font-size:var(--submit-bar-tip-icon-size,12px);min-width:18px;min-width:calc(var(--submit-bar-tip-icon-size, 12px)*1.5)}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end;height:50px;height:var(--submit-bar-height,50px);font-size:14px;font-size:var(--submit-bar-text-font-size,14px);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__bar--safe{padding-bottom:env(safe-area-inset-bottom)}.van-submit-bar__text{-webkit-flex:1;flex:1;text-align:right;color:#323233;color:var(--submit-bar-text-color,#323233);padding-right:12px;padding-right:var(--padding-sm,12px);font-weight:500;font-weight:var(--font-weight-bold,500)}.van-submit-bar__price{color:#ee0a24;color:var(--submit-bar-price-color,#ee0a24);font-size:18px;font-size:var(--submit-bar-price-font-size,18px)}.van-submit-bar__currency{font-size:14px;font-size:var(--submit-bar-currency-font-size,14px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px;width:var(--submit-bar-button-width,110px)} \ No newline at end of file diff --git a/dist/switch/index.wxml b/dist/switch/index.wxml index 147d6189..31a104df 100644 --- a/dist/switch/index.wxml +++ b/dist/switch/index.wxml @@ -6,6 +6,6 @@ bind:tap="onClick" > - + diff --git a/dist/switch/index.wxss b/dist/switch/index.wxss index 335fb1b6..e32a72ad 100644 --- a/dist/switch/index.wxss +++ b/dist/switch/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-switch{position:relative;display:inline-block;box-sizing:initial;width:2em;width:var(--switch-width,2em);height:1em;height:var(--switch-height,1em);background-color:#fff;background-color:var(--switch-background-color,#fff);border:1px solid rgba(0,0,0,.1);border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:1em;border-radius:var(--switch-node-size,1em);transition:background-color .3s;transition:background-color var(--switch-transition-duration,.3s)}.van-switch__node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;z-index:var(--switch-node-z-index,1);width:1em;width:var(--switch-node-size,1em);height:1em;height:var(--switch-node-size,1em);background-color:#fff;background-color:var(--switch-node-background-color,#fff);box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05),-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{position:absolute!important;top:25%;left:25%}.van-switch--on{background-color:#1989fa;background-color:var(--switch-on-background-color,#1989fa)}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em);-webkit-transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)));transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)))}.van-switch--disabled{opacity:.4;opacity:var(--switch-disabled-opacity,.4)} \ No newline at end of file +@import '../common/index.wxss';.van-switch{position:relative;display:inline-block;box-sizing:initial;width:2em;width:var(--switch-width,2em);height:1em;height:var(--switch-height,1em);background-color:#fff;background-color:var(--switch-background-color,#fff);border:1px solid rgba(0,0,0,.1);border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:1em;border-radius:var(--switch-node-size,1em);transition:background-color .3s;transition:background-color var(--switch-transition-duration,.3s)}.van-switch__node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;z-index:var(--switch-node-z-index,1);width:1em;width:var(--switch-node-size,1em);height:1em;height:var(--switch-node-size,1em);background-color:#fff;background-color:var(--switch-node-background-color,#fff);box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05),-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{position:absolute!important;top:25%;left:25%;width:50%;height:50%}.van-switch--on{background-color:#1989fa;background-color:var(--switch-on-background-color,#1989fa)}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em);-webkit-transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)));transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)))}.van-switch--disabled{opacity:.4;opacity:var(--switch-disabled-opacity,.4)} \ No newline at end of file diff --git a/dist/tab/index.js b/dist/tab/index.js index 66691711..186dc00f 100644 --- a/dist/tab/index.js +++ b/dist/tab/index.js @@ -2,7 +2,13 @@ import { VantComponent } from '../common/component'; VantComponent({ relation: { name: 'tabs', - type: 'ancestor' + type: 'ancestor', + linked(target) { + this.parent = target; + }, + unlinked() { + this.parent = null; + } }, props: { dot: Boolean, @@ -13,7 +19,6 @@ VantComponent({ name: { type: [Number, String], value: '', - observer: 'setComputedName' } }, data: { @@ -33,10 +38,15 @@ VantComponent({ setComputedName() { this.computedName = this.data.name || this.index; }, + getComputedName() { + if (this.data.name !== '') { + return this.data.name; + } + return this.index; + }, update() { - const parent = this.getRelationNodes('../tabs/index')[0]; - if (parent) { - parent.updateTabs(); + if (this.parent) { + this.parent.updateTabs(); } } } diff --git a/dist/tabbar-item/index.wxml b/dist/tabbar-item/index.wxml index b2649ae4..d83b061f 100644 --- a/dist/tabbar-item/index.wxml +++ b/dist/tabbar-item/index.wxml @@ -5,11 +5,11 @@ style="color: {{ active ? activeColor : inactiveColor }}" bind:tap="onClick" > - + diff --git a/dist/tabbar-item/index.wxss b/dist/tabbar-item/index.wxss index 20d78548..f1e876ef 100644 --- a/dist/tabbar-item/index.wxss +++ b/dist/tabbar-item/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;height:100%;font-size:12px;line-height:1;color:#7d7e80;color:var(--gray-darker,#7d7e80)}.van-tabbar-item__icon{position:relative;margin-bottom:5px;font-size:18px}.van-tabbar-item__icon--dot:after{position:absolute;top:0;right:-8px;width:8px;height:8px;border-radius:100%;content:" ";background-color:#ee0a24;background-color:var(--red,#ee0a24)}.van-tabbar-item__icon image{display:block;width:30px;height:18px}.van-tabbar-item--active{color:#1989fa;color:var(--blue,#1989fa)} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;height:100%;color:#7d7e80;color:var(--tabbar-item-text-color,#7d7e80);font-size:12px;font-size:var(--tabbar-item-font-size,12px);line-height:1;line-height:var(--tabbar-item-line-height,1)}.van-tabbar-item__icon{position:relative;margin-bottom:5px;margin-bottom:var(--tabbar-item-margin-bottom,5px);font-size:18px;font-size:var(--tabbar-item-icon-size,18px)}.van-tabbar-item__icon__inner{display:block;min-width:1em}.van-tabbar-item--active{color:#1989fa;color:var(--tabbar-item-active-color,#1989fa)}.van-tabbar-item__info{margin-top:2px} \ No newline at end of file diff --git a/dist/tabbar/index.wxss b/dist/tabbar/index.wxss index 69eea105..65fad1e3 100644 --- a/dist/tabbar/index.wxss +++ b/dist/tabbar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;width:100%;height:50px;background-color:#fff;background-color:var(--white,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file +@import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;width:100%;height:50px;height:var(--tabbar-height,50px);background-color:#fff;background-color:var(--tabbar-background-color,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file diff --git a/dist/tabs/index.js b/dist/tabs/index.js index 74e8e506..f45fa583 100644 --- a/dist/tabs/index.js +++ b/dist/tabs/index.js @@ -9,7 +9,6 @@ VantComponent({ type: 'descendant', linked(child) { child.index = this.children.length; - child.setComputedName(); this.children.push(child); this.updateTabs(this.data.tabs.concat(child.data)); }, @@ -22,28 +21,39 @@ VantComponent({ while (i >= 0 && i < this.children.length) { const currentChild = this.children[i]; currentChild.index--; - currentChild.setComputedName(); i++; } this.updateTabs(tabs); } }, props: { - color: String, + color: { + type: String, + observer: 'setLine' + }, sticky: Boolean, - animated: Boolean, + animated: { + type: Boolean, + observer: 'setTrack' + }, swipeable: Boolean, lineWidth: { type: [String, Number], - value: -1 + value: -1, + observer: 'setLine' }, lineHeight: { type: [String, Number], - value: -1 + value: -1, + observer: 'setLine' }, active: { type: [String, Number], value: 0, + observer(value) { + this.currentName = value; + this.setActiveTab(); + } }, type: { type: String, @@ -63,7 +73,12 @@ VantComponent({ }, swipeThreshold: { type: Number, - value: 4 + value: 4, + observer() { + this.setData({ + scrollable: this.children.length > this.data.swipeThreshold + }); + } }, offsetTop: { type: Number, @@ -78,20 +93,7 @@ VantComponent({ trackStyle: '', wrapStyle: '', position: '', - currentIndex: 0, - }, - watch: { - swipeThreshold() { - this.setData({ - scrollable: this.children.length > this.data.swipeThreshold - }); - }, - color: 'setLine', - lineWidth: 'setLine', - lineHeight: 'setLine', - active: 'setActiveTab', - animated: 'setTrack', - offsetTop: 'setWrapStyle' + currentIndex: 0 }, beforeCreate() { this.children = []; @@ -100,14 +102,6 @@ VantComponent({ this.setLine(true); this.setTrack(); this.scrollIntoView(); - this.getRect('.van-tabs__wrap').then((rect) => { - this.navHeight = rect.height; - this.observerContentScroll(); - }); - }, - destroyed() { - // @ts-ignore - this.createIntersectionObserver().disconnect(); }, methods: { updateTabs(tabs) { @@ -128,18 +122,19 @@ VantComponent({ 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', child.computedName); + this.trigger('disabled', computedName); } else { - this.trigger('click', child.computedName); - this.setActive(child.computedName); + this.trigger('click', computedName); + this.setActive(computedName); } }, - setActive(computedName) { - if (computedName !== this.currentName) { - this.currentName = computedName; - this.trigger('change', computedName); + setActive(name) { + if (name !== this.currentName) { + this.currentName = name; + this.trigger('change', name); this.setActiveTab(); } }, @@ -151,7 +146,9 @@ VantComponent({ this.getRect('.van-tab', true).then((rects) => { const rect = rects[currentIndex]; const width = lineWidth !== -1 ? lineWidth : rect.width / 2; - const height = lineHeight !== -1 ? `height: ${addUnit(lineHeight)}; border-radius: ${addUnit(lineHeight)};` : ''; + const height = lineHeight !== -1 + ? `height: ${addUnit(lineHeight)}; border-radius: ${addUnit(lineHeight)};` + : ''; let left = rects .slice(0, currentIndex) .reduce((prev, curr) => prev + curr.width, 0); @@ -194,16 +191,19 @@ VantComponent({ }, setActiveTab() { if (!isDef(this.currentName)) { - this.currentName = this.data.active || (this.children[0] || {}).computedName; + 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.computedName === this.currentName + active: item.getComputedName() === this.currentName }; if (data.active) { - this.setData({ - currentIndex: index - }); + this.setData({ currentIndex: index }); data.inited = true; } if (data.active !== item.data.active) { @@ -254,81 +254,14 @@ VantComponent({ const minSwipeDistance = 50; if (direction === 'horizontal' && offsetX >= minSwipeDistance) { if (deltaX > 0 && currentIndex !== 0) { - this.setActive(this.children[currentIndex - 1].computedName); + const child = this.children[currentIndex - 1]; + this.setActive(child.getComputedName()); } else if (deltaX < 0 && currentIndex !== tabs.length - 1) { - this.setActive(this.children[currentIndex + 1].computedName); + const child = this.children[currentIndex - 1]; + this.setActive(child.getComputedName()); } } - }, - setWrapStyle() { - const { offsetTop, position } = this.data; - let wrapStyle; - switch (position) { - case 'top': - wrapStyle = ` - top: ${offsetTop}px; - position: fixed; - `; - break; - case 'bottom': - wrapStyle = ` - top: auto; - bottom: 0; - `; - break; - default: - wrapStyle = ''; - } - if (wrapStyle !== this.data.wrapStyle) { - this.setData({ wrapStyle }); - } - }, - observerContentScroll() { - if (!this.data.sticky) { - return; - } - const { offsetTop } = this.data; - const { windowHeight } = wx.getSystemInfoSync(); - // @ts-ignore - this.createIntersectionObserver().disconnect(); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ top: -(this.navHeight + offsetTop) }) - .observe('.van-tabs', (res) => { - const { top } = res.boundingClientRect; - if (top > offsetTop) { - return; - } - const position = res.intersectionRatio > 0 ? 'top' : 'bottom'; - this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: position === 'top' - }); - this.setPosition(position); - }); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ bottom: -(windowHeight - 1 - offsetTop) }) - .observe('.van-tabs', (res) => { - const { top, bottom } = res.boundingClientRect; - if (bottom < this.navHeight) { - return; - } - const position = res.intersectionRatio > 0 ? 'top' : ''; - this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: position === 'top' - }); - this.setPosition(position); - }); - }, - setPosition(position) { - if (position !== this.data.position) { - this.set({ position }).then(() => { - this.setWrapStyle(); - }); - } } } }); diff --git a/dist/tabs/index.json b/dist/tabs/index.json index bf0ebe00..19c0bc3a 100644 --- a/dist/tabs/index.json +++ b/dist/tabs/index.json @@ -1,6 +1,7 @@ { "component": true, "usingComponents": { - "van-info": "../info/index" + "van-info": "../info/index", + "van-sticky": "../sticky/index" } } diff --git a/dist/tabs/index.wxml b/dist/tabs/index.wxml index fd0a738f..e168bd04 100644 --- a/dist/tabs/index.wxml +++ b/dist/tabs/index.wxml @@ -1,41 +1,44 @@ - - + + + - - - - - - {{ item.title }} - + + + + + + {{ item.title }} + + - - + + + + + - - + diff --git a/dist/tag/index.wxss b/dist/tag/index.wxss index fb8276bc..211e3769 100644 --- a/dist/tag/index.wxss +++ b/dist/tag/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tag{display:inline-block;padding:.2em .5em;font-size:10px;line-height:normal;border-radius:.2em;color:#fff;color:var(--white,#fff)}.van-tag:after{border-color:currentColor;border-radius:.4em}.van-tag--default{background-color:#999;background-color:var(--tag-default-color,#999)}.van-tag--default.van-tag--plain{color:#999;color:var(--tag-default-color,#999)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.6em;border-radius:0 .8em .8em 0}.van-tag--mark:after{border-radius:0 1.6em 1.6em 0}.van-tag--round{border-radius:.8em}.van-tag--round:after{border-radius:1.6em}.van-tag--medium{font-size:12px}.van-tag--large{font-size:14px} \ No newline at end of file +@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px} \ No newline at end of file diff --git a/dist/toast/index.wxss b/dist/toast/index.wxss index 5b0979ba..da946c9b 100644 --- a/dist/toast/index.wxss +++ b/dist/toast/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(51,51,51,.88);background-color:var(--toast-background-color,rgba(51,51,51,.88));border-radius:4px;border-radius:var(--toast-border-radius,4px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:90px;width:var(--toast-default-width,90px);min-height:90px;min-height:var(--toast-default-min-height,90px);padding:15px;padding:var(--toast-default-padding,15px)}.van-toast--icon .van-toast__icon{font-size:48px;font-size:var(--toast-icon-size,48px)}.van-toast--icon .van-toast__text{padding-top:5px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)} \ No newline at end of file +@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(50,50,51,.88);background-color:var(--toast-background-color,rgba(50,50,51,.88));border-radius:4px;border-radius:var(--toast-border-radius,4px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:90px;width:var(--toast-default-width,90px);min-height:90px;min-height:var(--toast-default-min-height,90px);padding:16px;padding:var(--toast-default-padding,16px)}.van-toast--icon .van-toast__icon{font-size:48px;font-size:var(--toast-icon-size,48px)}.van-toast--icon .van-toast__text{padding-top:8px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)} \ No newline at end of file diff --git a/dist/toast/toast.js b/dist/toast/toast.js index 7dacd987..ed5a8943 100644 --- a/dist/toast/toast.js +++ b/dist/toast/toast.js @@ -5,7 +5,7 @@ const defaultOptions = { message: '', show: true, zIndex: 1000, - duration: 3000, + duration: 2000, position: 'middle', forbidClick: false, loadingType: 'circular', diff --git a/dist/tree-select/index.js b/dist/tree-select/index.js index b6b2375d..bf824107 100644 --- a/dist/tree-select/index.js +++ b/dist/tree-select/index.js @@ -1,5 +1,5 @@ import { VantComponent } from '../common/component'; -const ITEM_HEIGHT = 44; +import { addUnit } from '../common/utils'; VantComponent({ classes: [ 'main-item-class', @@ -10,15 +10,20 @@ VantComponent({ 'content-disabled-class' ], props: { - items: Array, + items: { + type: Array, + observer: 'updateSubItems' + }, activeId: null, mainActiveIndex: { type: Number, - value: 0 + value: 0, + observer: 'updateSubItems' }, - maxHeight: { - type: Number, - value: 300 + height: { + type: [Number, String], + value: 300, + observer: 'updateHeight' }, max: { type: Number, @@ -26,21 +31,10 @@ VantComponent({ } }, data: { - subItems: [], - mainHeight: 0, - itemHeight: 0 + subItems: [] }, - watch: { - items() { - this.updateSubItems().then(() => { - this.updateMainHeight(); - }); - }, - maxHeight() { - this.updateItemHeight(this.data.subItems); - this.updateMainHeight(); - }, - mainActiveIndex: 'updateSubItems' + created() { + this.updateHeight(); }, methods: { // 当一个子项被选择时 @@ -48,16 +42,18 @@ VantComponent({ const { item } = event.currentTarget.dataset; const isArray = Array.isArray(this.data.activeId); // 判断有没有超出右侧选择的最大数 - const isOverMax = isArray && (this.data.activeId.length >= this.data.max); + const isOverMax = isArray && this.data.activeId.length >= this.data.max; // 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件 - const isSelected = isArray ? this.data.activeId.indexOf(item.id) > -1 : this.data.activeId === item.id; + const isSelected = isArray + ? this.data.activeId.indexOf(item.id) > -1 + : this.data.activeId === item.id; if (!item.disabled && (!isOverMax || isSelected)) { this.$emit('click-item', item); } }, // 当一个导航被点击时 onClickNav(event) { - const { index } = event.currentTarget.dataset; + const index = event.detail; const item = this.data.items[index]; if (!item.disabled) { this.$emit('click-nav', { index }); @@ -67,19 +63,12 @@ VantComponent({ updateSubItems() { const { items, mainActiveIndex } = this.data; const { children = [] } = items[mainActiveIndex] || {}; - this.updateItemHeight(children); return this.set({ subItems: children }); }, - // 更新组件整体高度,根据最大高度和当前组件需要展示的高度来决定 - updateMainHeight() { - const { items = [], subItems = [] } = this.data; - const maxHeight = Math.max(items.length * ITEM_HEIGHT, subItems.length * ITEM_HEIGHT); - this.setData({ mainHeight: Math.min(maxHeight, this.data.maxHeight) }); - }, - // 更新子项列表高度,根据可展示的最大高度和当前子项列表的高度决定 - updateItemHeight(subItems) { - const itemHeight = Math.min(subItems.length * ITEM_HEIGHT, this.data.maxHeight); - return this.setData({ itemHeight }); + updateHeight() { + this.setData({ + innerHeight: addUnit(this.data.height) + }); } } }); diff --git a/dist/tree-select/index.json b/dist/tree-select/index.json index 0a336c08..42991a2a 100644 --- a/dist/tree-select/index.json +++ b/dist/tree-select/index.json @@ -1,6 +1,8 @@ { "component": true, "usingComponents": { - "van-icon": "../icon/index" + "van-icon": "../icon/index", + "van-sidebar": "../sidebar/index", + "van-sidebar-item": "../sidebar-item/index" } } diff --git a/dist/tree-select/index.wxml b/dist/tree-select/index.wxml index baa6a221..0e8df176 100644 --- a/dist/tree-select/index.wxml +++ b/dist/tree-select/index.wxml @@ -3,29 +3,27 @@ - - {{ item.text }} - + + + - + diff --git a/dist/tree-select/index.wxss b/dist/tree-select/index.wxss index 1a432227..654e55a6 100644 --- a/dist/tree-select/index.wxss +++ b/dist/tree-select/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tree-select{position:relative;font-size:14px;-webkit-user-select:none;user-select:none}.van-tree-select__nav{position:absolute;top:0;bottom:0;left:0;width:35%;min-width:120px;background-color:#fafafa;background-color:var(--background-color-light,#fafafa)}.van-tree-select__nitem{position:relative;padding:0 9px 0 15px;line-height:44px}.van-tree-select__nitem--active:after{position:absolute;top:0;bottom:0;left:0;width:3.6px;content:"";background-color:#ee0a24;background-color:var(--red,#ee0a24)}.van-tree-select__nitem--active{font-weight:700;background-color:#fff;background-color:var(--white,#fff)}.van-tree-select__nitem--disabled{color:#999;color:var(--gray-dark,#999)}.van-tree-select__content{box-sizing:border-box;width:65%;margin-left:35%;padding-left:15px;background-color:#fff;background-color:var(--white,#fff)}.van-tree-select__item{position:relative;font-weight:700;line-height:44px}.van-tree-select__item--active{color:#ee0a24;color:var(--red,#ee0a24)}.van-tree-select__item--disabled{color:#999;color:var(--gray-dark,#999)}.van-tree-select__selected{position:absolute;top:0;right:15px;bottom:0;height:24px;margin:auto 0;line-height:24px} \ No newline at end of file +@import '../common/index.wxss';.van-tree-select{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;font-size:14px;font-size:var(--tree-select-font-size,14px)}.van-tree-select__nav{-webkit-flex:1;flex:1;background-color:#fafafa;background-color:var(--tree-select-nav-background-color,#fafafa);--sidebar-padding:12px 8px 12px 12px}.van-tree-select__nav__inner{width:100%!important;height:100%}.van-tree-select__content{-webkit-flex:2;flex:2;background-color:#fff;background-color:var(--tree-select-content-background-color,#fff)}.van-tree-select__item{position:relative;font-weight:700;padding:0 32px 0 16px;padding:0 32px 0 var(--padding-md,16px);line-height:44px;line-height:var(--tree-select-item-height,44px)}.van-tree-select__item--active{color:#ee0a24;color:var(--tree-select-item-active-color,#ee0a24)}.van-tree-select__item--disabled{color:#c8c9cc;color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/dist/uploader/index.d.ts b/dist/uploader/index.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/dist/uploader/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/uploader/index.js b/dist/uploader/index.js new file mode 100644 index 00000000..01b8734a --- /dev/null +++ b/dist/uploader/index.js @@ -0,0 +1,156 @@ +import { VantComponent } from '../common/component'; +import { isImageFile } from './utils'; +import { addUnit } from '../common/utils'; +VantComponent({ + props: { + disabled: Boolean, + uploadText: String, + previewSize: { + type: null, + value: 90, + observer: 'setComputedPreviewSize' + }, + name: { + type: [Number, String], + value: '' + }, + accept: { + type: String, + value: 'image' + }, + fileList: { + type: Array, + value: [], + observer: 'formatFileList' + }, + maxSize: { + type: Number, + value: Number.MAX_VALUE + }, + maxCount: { + type: Number, + value: 100 + }, + previewImage: { + type: Boolean, + value: true + }, + previewFullImage: { + type: Boolean, + value: true + }, + imageFit: { + type: String, + value: 'scaleToFill' + }, + useSlot: Boolean, + useBeforeRead: Boolean + }, + data: { + lists: [], + computedPreviewSize: '', + isInCount: true + }, + methods: { + formatFileList() { + const { fileList = [], maxCount } = this.data; + const lists = fileList.map(item => (Object.assign(Object.assign({}, item), { isImage: typeof item.isImage === 'undefined' + ? isImageFile(item) + : item.isImage }))); + this.setData({ lists, isInCount: lists.length < maxCount }); + }, + setComputedPreviewSize(val) { + this.setData({ + computedPreviewSize: addUnit(val) + }); + }, + startUpload() { + if (this.data.disabled) + return; + const { name = '', capture = ['album', 'camera'], maxCount = 100, multiple = false, maxSize, accept, lists, useBeforeRead = false // 是否定义了 beforeRead + } = this.data; + let chooseFile = null; + const newMaxCount = maxCount - lists.length; + // 设置为只选择图片的时候使用 chooseImage 来实现 + if (accept === 'image') { + chooseFile = new Promise((resolve, reject) => { + wx.chooseImage({ + count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1, + sourceType: capture, + success: res => { + resolve(res); + }, + fail: err => { + reject(err); + } + }); + }); + } + else { + chooseFile = new Promise((resolve, reject) => { + wx.chooseMessageFile({ + count: multiple ? newMaxCount : 1, + type: 'file', + success(res) { + resolve(res); + }, + fail: err => { + reject(err); + } + }); + }); + } + chooseFile.then(res => { + const file = multiple ? res.tempFiles : res.tempFiles[0]; + // 检查文件大小 + if (file instanceof Array) { + const sizeEnable = file.every(item => item.size <= maxSize); + if (!sizeEnable) { + this.$emit('oversize', { name }); + return; + } + } + else if (file.size > maxSize) { + this.$emit('oversize', { name }); + return; + } + // 触发上传之前的钩子函数 + if (useBeforeRead) { + this.$emit('before-read', { + file, + name, + callback: result => { + if (result) { + // 开始上传 + this.$emit('after-read', { file, name }); + } + } + }); + } + else { + this.$emit('after-read', { file, name }); + } + }); + }, + deleteItem(event) { + const { index } = event.currentTarget.dataset; + this.$emit('delete', { index, name: this.data.name }); + }, + doPreviewImage(event) { + if (!this.data.previewFullImage) + return; + const curUrl = event.currentTarget.dataset.url; + const images = this.data.lists + .filter(item => item.isImage) + .map(item => item.url || item.path); + this.$emit('click-preview', { url: curUrl, name: this.data.name }); + wx.previewImage({ + urls: images, + current: curUrl, + fail() { + wx.showToast({ title: '预览图片失败', icon: 'none' }); + } + }); + } + } +}); diff --git a/dist/uploader/index.json b/dist/uploader/index.json new file mode 100644 index 00000000..0a336c08 --- /dev/null +++ b/dist/uploader/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/dist/uploader/index.wxml b/dist/uploader/index.wxml new file mode 100644 index 00000000..a57cfda2 --- /dev/null +++ b/dist/uploader/index.wxml @@ -0,0 +1,60 @@ + + + + + + + + {{ item.name || ('图片' + index) }} + + + {{ item.name || item.url || item.path }} + + + + + + + + + + + + + + + + {{ uploadText }} + + + + + diff --git a/dist/uploader/index.wxss b/dist/uploader/index.wxss new file mode 100644 index 00000000..88b6a79b --- /dev/null +++ b/dist/uploader/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #e5e5e5}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px}.van-uploader__preview-delete{position:absolute;right:0;bottom:0;display:inline-block;width:18px;height:18px;padding:1px;color:#fff;text-align:center;background-color:rgba(0,0,0,.45)}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f8f8f8}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#7d7e80;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#7d7e80;font-size:12px;text-align:center} \ No newline at end of file diff --git a/dist/uploader/utils.d.ts b/dist/uploader/utils.d.ts new file mode 100644 index 00000000..d3bb3b5b --- /dev/null +++ b/dist/uploader/utils.d.ts @@ -0,0 +1,12 @@ +interface File { + path: string; + url: string; + size: number; + name: string; + type: string; + time: number; + image: boolean; +} +export declare function isImageUrl(url: string): boolean; +export declare function isImageFile(item: File): boolean; +export {}; diff --git a/dist/uploader/utils.js b/dist/uploader/utils.js new file mode 100644 index 00000000..aa59dc1d --- /dev/null +++ b/dist/uploader/utils.js @@ -0,0 +1,16 @@ +const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg']; +export function isImageUrl(url) { + return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1); +} +export function isImageFile(item) { + if (item.type) { + return item.type.indexOf('image') === 0; + } + if (item.path) { + return isImageUrl(item.path); + } + if (item.url) { + return isImageUrl(item.url); + } + return false; +} diff --git a/lib/action-sheet/index.wxml b/lib/action-sheet/index.wxml index 2dcbf4f8..bed9b06b 100644 --- a/lib/action-sheet/index.wxml +++ b/lib/action-sheet/index.wxml @@ -38,7 +38,7 @@ {{ item.name }} {{ item.subname }} - + diff --git a/lib/action-sheet/index.wxss b/lib/action-sheet/index.wxss index 7982ab26..add1116b 100644 --- a/lib/action-sheet/index.wxss +++ b/lib/action-sheet/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;color:#333;color:var(--action-sheet-item-text-color,#333)}.van-action-sheet__cancel,.van-action-sheet__item{font-size:16px;line-height:50px;text-align:center;background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel{height:50px}.van-action-sheet__cancel:before{display:block;height:8px;content:" ";background-color:#f8f8f8;background-color:var(--action-sheet-cancel-padding-color,#f8f8f8)}.van-action-sheet__item--disabled{color:#c9c9c9;color:var(--action-sheet-item-disabled-text-color,#c9c9c9)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;font-size:12px;color:#7d7e80;color:var(--action-sheet-subname-color,#7d7e80)}.van-action-sheet__header{font-weight:500;font-size:16px;line-height:44px;text-align:center}.van-action-sheet__description{padding:16px;color:#7d7e80;font-size:14px;line-height:20px;text-align:center}.van-action-sheet__close{position:absolute!important;top:0;right:0;padding:0 12px;font-size:18px!important;line-height:inherit!important;color:#999;color:var(--action-sheet-close-icon-color,#999)} \ No newline at end of file +@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;max-height:var(--action-sheet-max-height,90%)!important;color:#323233;color:var(--action-sheet-item-text-color,#323233)}.van-action-sheet__cancel,.van-action-sheet__item{text-align:center;font-size:16px;font-size:var(--action-sheet-item-font-size,16px);line-height:50px;line-height:var(--action-sheet-item-height,50px);background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel:before{display:block;content:" ";height:8px;height:var(--action-sheet-cancel-padding-top,8px);background-color:#f8f8f8;background-color:var(--action-sheet-cancel-padding-color,#f8f8f8)}.van-action-sheet__item--disabled{color:#c8c9cc;color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;margin-left:var(--padding-base,4px);font-size:12px;font-size:var(--action-sheet-subname-font-size,12px);color:#7d7e80;color:var(--action-sheet-subname-color,#7d7e80)}.van-action-sheet__header{text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--action-sheet-header-font-size,16px);line-height:44px;line-height:var(--action-sheet-header-height,44px)}.van-action-sheet__description{text-align:center;padding:16px;padding:var(--padding-md,16px);color:#7d7e80;color:var(--action-sheet-description-color,#7d7e80);font-size:14px;font-size:var(--action-sheet-description-font-size,14px);line-height:20px;line-height:var(--action-sheet-description-line-height,20px)}.van-action-sheet__close{position:absolute!important;top:0;right:0;line-height:inherit!important;padding:0 12px;padding:var(--action-sheet-close-icon-padding,0 12px);font-size:18px!important;font-size:var(--action-sheet-close-icon-size,18px)!important;color:#969799;color:var(--action-sheet-close-icon-color,#969799)}.van-action-sheet__loading{display:-webkit-flex!important;display:flex!important;height:50px;height:var(--action-sheet-item-height,50px)} \ No newline at end of file diff --git a/lib/area/index.js b/lib/area/index.js index a2a02029..6776f5d5 100644 --- a/lib/area/index.js +++ b/lib/area/index.js @@ -82,7 +82,9 @@ component_1.VantComponent({ parseOutputValues: function (values) { var columnsPlaceholder = this.data.columnsPlaceholder; return values.map(function (value, index) { - if (value === void 0) { value = {}; } + // save undefined value + if (!value) + return value; value = JSON.parse(JSON.stringify(value)); if (!value.code || value.name === columnsPlaceholder[index]) { value.code = ''; diff --git a/lib/button/index.wxml b/lib/button/index.wxml index 639e0f15..77b49429 100644 --- a/lib/button/index.wxml +++ b/lib/button/index.wxml @@ -28,7 +28,7 @@ custom-class="loading-class" size="{{ loadingSize }}" type="{{ loadingType }}" - color="{{ type === 'default' ? '#c9c9c9' : '' }}" + color="{{ type === 'default' ? '#c9c9c9' : 'white' }}" /> - \ No newline at end of file + diff --git a/lib/divider/index.wxss b/lib/divider/index.wxss index 16eb8896..c055e3af 100644 --- a/lib/divider/index.wxss +++ b/lib/divider/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-divider{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin:16px 0;color:#999;font-size:14px;line-height:24px;border:0 solid #eee}.van-divider:after,.van-divider:before{display:block;-webkit-flex:1;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:1px 0 0}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:16px}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{margin-left:16px;content:""}.van-divider--left:before,.van-divider--right:after{max-width:10%} \ No newline at end of file +@import '../common/index.wxss';.van-divider{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin:16px 0;margin:var(--divider-margin,16px 0);color:#969799;color:var(--divider-text-color,#969799);font-size:14px;font-size:var(--divider-font-size,14px);line-height:24px;line-height:var(--divider-line-height,24px);border:0 solid #ebedf0;border-color:var(--divider-border-color,#ebedf0)}.van-divider:after,.van-divider:before{display:block;-webkit-flex:1;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:1px 0 0}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:16px;margin-right:var(--divider-content-padding,16px)}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{content:"";margin-left:16px;margin-left:var(--divider-content-padding,16px)}.van-divider--left:before{max-width:10%;max-width:var(--divider-content-left-width,10%)}.van-divider--right:after{max-width:10%;max-width:var(--divider-content-right-width,10%)} \ No newline at end of file diff --git a/lib/dropdown-item/index.wxss b/lib/dropdown-item/index.wxss index 3eb29f0e..e06c2874 100644 --- a/lib/dropdown-item/index.wxss +++ b/lib/dropdown-item/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dropdown-item{position:fixed;right:0;left:0;overflow:hidden}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:#1989fa}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file +@import '../common/index.wxss';.van-dropdown-item{position:fixed;right:0;left:0;overflow:hidden}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:#1989fa;color:var(--dropdown-menu-option-active-color,#1989fa)}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file diff --git a/lib/dropdown-menu/index.wxss b/lib/dropdown-menu/index.wxss index 12e3d114..43efd779 100644 --- a/lib/dropdown-menu/index.wxss +++ b/lib/dropdown-menu/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-dropdown-menu{display:-webkit-flex;display:flex;height:50px;background-color:#fff;-webkit-user-select:none;user-select:none}.van-dropdown-menu__item{display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:#999}.van-dropdown-menu__title{position:relative;box-sizing:border-box;max-width:100%;padding:0 8px;color:#333;font-size:15px;line-height:18px}.van-dropdown-menu__title:after{position:absolute;top:50%;right:-4px;margin-top:-5px;border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);opacity:.8;content:""}.van-dropdown-menu__title--active{color:#1989fa}.van-dropdown-menu__title--down:after{margin-top:-1px;-webkit-transform:rotate(135deg);transform:rotate(135deg)} \ No newline at end of file +@import '../common/index.wxss';.van-dropdown-menu{display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;height:50px;height:var(--dropdown-menu-height,50px);background-color:#fff;background-color:var(--dropdown-menu-background-color,#fff)}.van-dropdown-menu__item{display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:#969799;color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{position:relative;box-sizing:border-box;max-width:100%;padding:0 8px;padding:var(--dropdown-menu-title-padding,0 8px);color:#323233;color:var(--dropdown-menu-title-text-color,#323233);font-size:15px;font-size:var(--dropdown-menu-title-font-size,15px);line-height:18px;line-height:var(--dropdown-menu-title-line-height,18px)}.van-dropdown-menu__title:after{position:absolute;top:50%;right:-4px;margin-top:-5px;border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);opacity:.8;content:""}.van-dropdown-menu__title--active{color:#1989fa;color:var(--dropdown-menu-title-active-text-color,#1989fa)}.van-dropdown-menu__title--down:after{margin-top:-1px;-webkit-transform:rotate(135deg);transform:rotate(135deg)} \ No newline at end of file diff --git a/lib/field/index.js b/lib/field/index.js index 48a9fe9d..c9fe7b4c 100644 --- a/lib/field/index.js +++ b/lib/field/index.js @@ -29,6 +29,7 @@ component_1.VantComponent({ customStyle: String, confirmType: String, confirmHold: Boolean, + holdKeyboard: Boolean, errorMessage: String, arrowDirection: String, placeholderStyle: String, diff --git a/lib/field/index.wxml b/lib/field/index.wxml index 944e441f..64901781 100644 --- a/lib/field/index.wxml +++ b/lib/field/index.wxml @@ -32,6 +32,7 @@ cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" show-confirm-bar="{{ showConfirmBar }}" + hold-keyboard="{{ holdKeyboard }}" selection-end="{{ selectionEnd }}" selection-start="{{ selectionStart }}" bindinput="onInput" @@ -53,6 +54,7 @@ placeholder-class="{{ utils.bem('field__placeholder', { error }) }}" confirm-type="{{ confirmType }}" confirm-hold="{{ confirmHold }}" + hold-keyboard="{{ holdKeyboard }}" cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" selection-end="{{ selectionEnd }}" diff --git a/lib/field/index.wxss b/lib/field/index.wxss index 6c2d79c4..9297f8d9 100644 --- a/lib/field/index.wxss +++ b/lib/field/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px;line-height:1.2em}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;box-sizing:border-box;width:100%;height:24px;min-height:24px;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#333;color:var(--text-color,#333)}.van-field__input--textarea{height:18px;min-height:18px}.van-field__input--error{color:#ee0a24;color:var(--red,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#999;color:var(--gray-dark,#999)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#999;color:var(--gray-dark,#999)}.van-field__placeholder--error{color:#ee0a24;color:var(--red,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px}.van-field__clear-root,.van-field__icon-container{margin-right:-10px;padding:0 10px;line-height:inherit;vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c9c9c9;color:var(--gray,#c9c9c9)}.van-field__icon-container{color:#999;color:var(--gray-dark,#999)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:10px}.van-field__button:empty{display:none}.van-field__error-message{font-size:12px;text-align:left;color:#ee0a24;color:var(--red,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} \ No newline at end of file +@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{line-height:1.2em;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;box-sizing:border-box;width:100%;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#323233;color:var(--field-input-text-color,#323233);height:24px;height:var(--cell-line-height,24px);min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__input--textarea{height:18px;height:var(--field-text-area-min-height,18px);min-height:18px;min-height:var(--field-text-area-min-height,18px)}.van-field__input--error{color:#ee0a24;color:var(--field-input-error-text-color,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#969799;color:var(--field-input-disabled-text-color,#969799)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#969799;color:var(--field-placeholder-text-color,#969799)}.van-field__placeholder--error{color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;vertical-align:middle;padding:0 8px;padding:0 var(--padding-xs,8px);margin-right:-8px;margin-right:-var(--padding-xs,8px)}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c8c9cc;color:var(--field-clear-icon-color,#c8c9cc)}.van-field__icon-container{color:#969799;color:var(--field-icon-container-color,#969799)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:8px;padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{text-align:left;font-size:12px;font-size:var(--field-error-message-text-font-size,12px);color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} \ No newline at end of file diff --git a/lib/goods-action-button/index.js b/lib/goods-action-button/index.js index 301bb5b7..064d1ff4 100644 --- a/lib/goods-action-button/index.js +++ b/lib/goods-action-button/index.js @@ -32,21 +32,11 @@ component_1.VantComponent({ this.jumpLink(); }, updateStyle: function () { - var parent = this.parent; - var _a = parent.children, children = _a === void 0 ? [] : _a; + var _a = this.parent.children, children = _a === void 0 ? [] : _a; var index = children.indexOf(this); - var length = children.length; - var isFirst = false; - var isLast = false; - if (index === 0) { - isFirst = true; - } - if (index === length - 1) { - isLast = true; - } this.setData({ - isFirst: isFirst, - isLast: isLast + isFirst: index === 0, + isLast: index === children.length - 1 }); } } diff --git a/lib/goods-action-button/index.wxml b/lib/goods-action-button/index.wxml index 366b8cd7..d6d2daab 100644 --- a/lib/goods-action-button/index.wxml +++ b/lib/goods-action-button/index.wxml @@ -2,7 +2,6 @@ -
@@ -29,8 +29,8 @@ name="photo-o" size="22" /> -
-
+ @@ -43,5 +43,5 @@ name="warning-o" size="22" /> -
+
diff --git a/lib/image/index.wxss b/lib/image/index.wxss index ade9f694..917d3c75 100644 --- a/lib/image/index.wxss +++ b/lib/image/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-image{position:relative;display:inline-block}.van-image--round{overflow:hidden;border-radius:50%}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;width:100%;height:100%}.van-image__error,.van-image__loading{position:absolute;top:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#999;font-size:14px;background-color:#f8f8f8} \ No newline at end of file +@import '../common/index.wxss';.van-image{position:relative;display:inline-block}.van-image--round{overflow:hidden;border-radius:50%}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;width:100%;height:100%}.van-image__error,.van-image__loading{position:absolute;top:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#969799;color:var(--image-placeholder-text-color,#969799);font-size:14px;font-size:var(--image-placeholder-font-size,14px);background-color:#f8f8f8;background-color:var(--image-placeholder-background-color,#f8f8f8)} \ No newline at end of file diff --git a/lib/info/index.wxss b/lib/info/index.wxss index d3ec4c0d..16e3f329 100644 --- a/lib/info/index.wxss +++ b/lib/info/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-info{position:absolute;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translateX(50%);transform:translateX(50%);-webkit-transform-origin:100%;transform-origin:100%;top:-8px;top:calc(var(--info-size, 16px)/-2);min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} \ No newline at end of file +@import '../common/index.wxss';.van-info{position:absolute;top:0;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%);-webkit-transform-origin:100%;transform-origin:100%;min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} \ No newline at end of file diff --git a/lib/loading/index.js b/lib/loading/index.js index efbf9d2c..8db7adac 100644 --- a/lib/loading/index.js +++ b/lib/loading/index.js @@ -4,27 +4,20 @@ var component_1 = require("../common/component"); var utils_1 = require("../common/utils"); component_1.VantComponent({ props: { - size: { - type: String, - observer: 'setSizeWithUnit' - }, + color: String, + vertical: Boolean, type: { type: String, value: 'circular' }, - color: { + size: { type: String, - value: '#c9c9c9' + observer: 'setSizeWithUnit' }, textSize: { type: String, observer: 'setTextSizeWithUnit' - }, - vertical: Boolean - }, - data: { - sizeWithUnit: '30px', - textSizeWithUnit: '14px' + } }, methods: { setSizeWithUnit: function (size) { diff --git a/lib/loading/index.wxml b/lib/loading/index.wxml index 88b0148f..5229d043 100644 --- a/lib/loading/index.wxml +++ b/lib/loading/index.wxml @@ -1,24 +1,16 @@ - + - - + wx:if="{{ type === 'spinner' }}" + wx:for="item in 12" + wx:key="index" + class="van-loading__dot" + /> - + - \ No newline at end of file + diff --git a/lib/loading/index.wxss b/lib/loading/index.wxss index 64ceff23..f28a6b46 100644 --- a/lib/loading/index.wxss +++ b/lib/loading/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-loading__wrapper{position:relative;z-index:0;display:inline-block;line-height:0}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading__spinner{position:relative;z-index:-1;display:inline-block;box-sizing:border-box;width:100%;height:100%;-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;color:#969799}.van-loading__text--vertical{margin:8px 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file +@import '../common/index.wxss';:host{font-size:0;line-height:1}.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#c8c9cc;color:var(--loading-spinner-color,#c8c9cc)}.van-loading__spinner{position:relative;box-sizing:border-box;width:30px;width:var(--loading-spinner-size,30px);max-width:100%;max-height:100%;height:30px;height:var(--loading-spinner-size,30px);-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite;-webkit-animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite;animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;margin-left:var(--padding-xs,8px);color:#969799;color:var(--loading-text-color,#969799);font-size:14px;font-size:var(--loading-text-font-size,14px);line-height:20px;line-height:var(--loading-text-line-height,20px)}.van-loading__text:empty{display:none}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading--vertical .van-loading__text{margin:8px 0 0;margin:var(--padding-xs,8px) 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file diff --git a/lib/nav-bar/index.wxss b/lib/nav-bar/index.wxss index 1ba28ea7..3fbfb7e3 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(--white,#fff)}.van-nav-bar__text{display:inline-block;margin:0 -15px;padding:0 15px;vertical-align:middle;color:#1989fa;color:var(--blue,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;color:#1989fa;color:var(--blue,#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;font-weight:500;font-size:16px}.van-nav-bar__left,.van-nav-bar__right{position:absolute;bottom:0;font-size:14px}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px} \ 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/notice-bar/index.wxml b/lib/notice-bar/index.wxml index 38b7bc00..eb0851c3 100644 --- a/lib/notice-bar/index.wxml +++ b/lib/notice-bar/index.wxml @@ -24,7 +24,7 @@ wx:if="{{ mode === 'closeable' }}" class="van-notice-bar__right-icon" name="cross" - bind:tap="onClickIcon" + catch:tap="onClickIcon" /> + + + + + + + + + + + diff --git a/lib/skeleton/index.wxss b/lib/skeleton/index.wxss new file mode 100644 index 00000000..565b26e4 --- /dev/null +++ b/lib/skeleton/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-skeleton{display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:0 16px;padding:var(--skeleton-padding,0 16px)}.van-skeleton__avatar{-webkit-flex-shrink:0;flex-shrink:0;margin-right:16px;margin-right:var(--padding-md,16px);background-color:#f2f3f5;background-color:var(--skeleton-avatar-background-color,#f2f3f5)}.van-skeleton__avatar--round{border-radius:100%}.van-skeleton__content{-webkit-flex:1;flex:1}.van-skeleton__avatar+.van-skeleton__content{padding-top:8px;padding-top:var(--padding-xs,8px)}.van-skeleton__row,.van-skeleton__title{height:16px;height:var(--skeleton-row-height,16px);background-color:#f2f3f5;background-color:var(--skeleton-row-background-color,#f2f3f5)}.van-skeleton__title{margin:0}.van-skeleton__row:not(:first-child){margin-top:12px;margin-top:var(--skeleton-row-margin-top,12px)}.van-skeleton__title+.van-skeleton__row{margin-top:20px}.van-skeleton--animate{-webkit-animation:van-skeleton-blink 1.2s ease-in-out infinite;animation:van-skeleton-blink 1.2s ease-in-out infinite}@-webkit-keyframes van-skeleton-blink{50%{opacity:.6}}@keyframes van-skeleton-blink{50%{opacity:.6}} \ No newline at end of file diff --git a/lib/slider/index.wxss b/lib/slider/index.wxss index 85681030..4cd94be6 100644 --- a/lib/slider/index.wxss +++ b/lib/slider/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;background-color:#e5e5e5;background-color:var(--gray-light,#e5e5e5)}.van-slider:before{position:absolute;top:-8px;right:0;bottom:-8px;left:0;content:""}.van-slider__bar{position:relative;border-radius:inherit;transition:width .2s;background-color:#1989fa;background-color:var(--blue,#1989fa)}.van-slider__button{width:24px;height:24px;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.5);background-color:#fff;background-color:var(--white,#fff)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider--disabled{opacity:.3} \ No newline at end of file +@import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;border-radius:var(--border-radius-max,999px);background-color:#e5e5e5;background-color:var(--slider-inactive-background-color,#e5e5e5)}.van-slider:before{position:absolute;right:0;left:0;content:"";top:-8px;top:-var(--padding-xs,8px);bottom:-8px;bottom:-var(--padding-xs,8px)}.van-slider__bar{position:relative;border-radius:inherit;transition:width .2s;transition:width var(--animation-duration-fast,.2s);background-color:#1989fa;background-color:var(--slider-active-background-color,#1989fa)}.van-slider__button{width:24px;height:24px;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.5);background-color:#fff;background-color:var(--slider-button-background-color,#fff)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider--disabled{opacity:.5} \ No newline at end of file diff --git a/lib/stepper/index.wxml b/lib/stepper/index.wxml index 0c03912e..06480dc0 100644 --- a/lib/stepper/index.wxml +++ b/lib/stepper/index.wxml @@ -1,38 +1,37 @@ - - - + + + - diff --git a/lib/stepper/index.wxss b/lib/stepper/index.wxss index 2ffb4c71..cf020ace 100644 --- a/lib/stepper/index.wxss +++ b/lib/stepper/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-stepper{font-size:0}.van-stepper__minus,.van-stepper__plus{position:relative;display:inline-block;box-sizing:border-box;width:28px;height:28px;margin:1px;padding:5px;vertical-align:middle;border:0;background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5)}.van-stepper__minus:before,.van-stepper__plus:before{width:9px;height:1px}.van-stepper__minus:after,.van-stepper__plus:after{width:1px;height:9px}.van-stepper__minus:after,.van-stepper__minus:before,.van-stepper__plus:after,.van-stepper__plus:before{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;content:"";background-color:#333;background-color:var(--text-color,#333)}.van-stepper__minus--hover,.van-stepper__plus--hover{background-color:#e8e8e8;background-color:var(--stepper-active-color,#e8e8e8)}.van-stepper__minus--disabled,.van-stepper__plus--disabled{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus--disabled:after,.van-stepper__minus--disabled:before,.van-stepper__plus--disabled:after,.van-stepper__plus--disabled:before{background-color:#c9c9c9;background-color:var(--gray,#c9c9c9)}.van-stepper__minus--disabled.van-stepper__minus--hover,.van-stepper__minus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus{border-radius:4px 0 0 4px;border-radius:var(--stepper-border-radius,4px) 0 0 var(--stepper-border-radius,4px)}.van-stepper__minus:after{display:none}.van-stepper__plus{border-radius:0 4px 4px 0;border-radius:0 var(--stepper-border-radius,4px) var(--stepper-border-radius,4px) 0}.van-stepper__input{display:inline-block;box-sizing:border-box;width:32px;height:28px;min-height:0;margin:1px;padding:1px;font-size:14px;text-align:center;vertical-align:middle;border:0;border-width:1px 0;border-radius:0;-webkit-appearance:none;color:#333;color:var(--text-color,#333);background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5)}.van-stepper__input--disabled{color:#c9c9c9;color:var(--gray,#c9c9c9);background-color:#f2f3f5;background-color:var(--stepper-input-disabled-color,#f2f3f5)} \ No newline at end of file +@import '../common/index.wxss';.van-stepper{font-size:0}.van-stepper__minus,.van-stepper__plus{position:relative;display:inline-block;box-sizing:border-box;margin:1px;vertical-align:middle;border:0;background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5);color:#323233;color:var(--stepper-button-icon-color,#323233);width:28px;width:var(--stepper-input-height,28px);height:28px;height:var(--stepper-input-height,28px);padding:4px;padding:var(--padding-base,4px)}.van-stepper__minus:before,.van-stepper__plus:before{width:9px;height:1px}.van-stepper__minus:after,.van-stepper__plus:after{width:1px;height:9px}.van-stepper__minus:after,.van-stepper__minus:before,.van-stepper__plus:after,.van-stepper__plus:before{position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;content:"";background-color:#323233;background-color:var(--text-color,#323233)}.van-stepper__minus--hover,.van-stepper__plus--hover{background-color:#e8e8e8;background-color:var(--stepper-active-color,#e8e8e8)}.van-stepper__minus--disabled,.van-stepper__plus--disabled{color:#c8c9cc;color:var(--stepper-button-disabled-icon-color,#c8c9cc)}.van-stepper__minus--disabled,.van-stepper__minus--disabled.van-stepper__minus--hover,.van-stepper__minus--disabled.van-stepper__plus--hover,.van-stepper__minus--disabled:after,.van-stepper__minus--disabled:before,.van-stepper__plus--disabled,.van-stepper__plus--disabled.van-stepper__minus--hover,.van-stepper__plus--disabled.van-stepper__plus--hover,.van-stepper__plus--disabled:after,.van-stepper__plus--disabled:before{background-color:#f7f8fa;background-color:var(--stepper-button-disabled-color,#f7f8fa)}.van-stepper__minus{border-radius:4px 0 0 4px;border-radius:var(--stepper-border-radius,4px) 0 0 var(--stepper-border-radius,4px)}.van-stepper__minus:after{display:none}.van-stepper__plus{border-radius:0 4px 4px 0;border-radius:0 var(--stepper-border-radius,4px) var(--stepper-border-radius,4px) 0}.van-stepper__input{display:inline-block;box-sizing:border-box;min-height:0;margin:1px;padding:1px;text-align:center;vertical-align:middle;border:0;border-width:1px 0;border-radius:0;-webkit-appearance:none;font-size:14px;font-size:var(--stepper-input-font-size,14px);color:#323233;color:var(--stepper-input-text-color,#323233);background-color:#f2f3f5;background-color:var(--stepper-background-color,#f2f3f5);width:32px;width:var(--stepper-input-width,32px);height:28px;height:var(--stepper-input-height,28px)}.van-stepper__input--disabled{color:#c8c9cc;color:var(--stepper-input-disabled-text-color,#c8c9cc);background-color:#f2f3f5;background-color:var(--stepper-input-disabled-background-color,#f2f3f5)} \ No newline at end of file diff --git a/lib/steps/index.wxss b/lib/steps/index.wxss index 11e11c8d..2c50b1ab 100644 --- a/lib/steps/index.wxss +++ b/lib/steps/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--white,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:-webkit-flex;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;-webkit-flex:1;flex:1;font-size:14px;color:#999;color:var(--gray-dark,#999)}.van-step--finish{color:#333;color:var(--text-color,#333)}.van-step__circle{width:5px;height:5px;border-radius:50%;background-color:#999;background-color:var(--gray-dark,#999)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{-webkit-transform:none;transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;-webkit-transform:none;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;padding:0 8px;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff)}.van-step--horizontal .van-step__title{display:inline-block;font-size:12px;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);background-color:#eee;background-color:var(--border-color,#eee)}.van-step--horizontal.van-step--process{color:#333;color:var(--text-color,#333)}.van-step--horizontal.van-step--process .van-step__icon{display:block;font-size:12px;line-height:1}.van-step--vertical{padding:10px 10px 10px 0;font-size:14px;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{font-size:12px;line-height:1}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);background-color:#eee;background-color:var(--border-color,#eee)} \ No newline at end of file +@import '../common/index.wxss';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--steps-background-color,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:-webkit-flex;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;-webkit-flex:1;flex:1;font-size:14px;font-size:var(--step-font-size,14px);color:#969799;color:var(--step-text-color,#969799)}.van-step--finish{color:#323233;color:var(--step-finish-text-color,#323233)}.van-step__circle{border-radius:50%;width:5px;width:var(--step-circle-size,5px);height:5px;height:var(--step-circle-size,5px);background-color:#969799;background-color:var(--step-circle-color,#969799)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{-webkit-transform:none;transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;-webkit-transform:none;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff);padding:0 8px;padding:0 var(--padding-xs,8px)}.van-step--horizontal .van-step__title{display:inline-block;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);font-size:12px;font-size:var(--step-horizontal-title-font-size,12px)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)}.van-step--horizontal.van-step--process{color:#323233;color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical{padding:10px 10px 10px 0;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)} \ No newline at end of file diff --git a/lib/sticky/index.js b/lib/sticky/index.js index 7cc8173f..c52c9d04 100644 --- a/lib/sticky/index.js +++ b/lib/sticky/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); -var utils_1 = require("../common/utils"); component_1.VantComponent({ props: { zIndex: { @@ -11,98 +10,59 @@ component_1.VantComponent({ offsetTop: { type: Number, value: 0 - } + }, + disabled: Boolean }, data: { - position: '', - height: 0, wrapStyle: '', containerStyle: '' }, methods: { - setWrapStyle: function () { - var _a = this.data, offsetTop = _a.offsetTop, position = _a.position; - var wrapStyle; - var containerStyle; - switch (position) { - case 'top': - wrapStyle = "\n top: " + offsetTop + "px;\n position: fixed;\n "; - containerStyle = "height: " + this.itemHeight + "px;"; - break; - case 'bottom': - wrapStyle = "\n top: auto;\n bottom: 0;\n "; - containerStyle = ''; - break; - default: - wrapStyle = ''; - containerStyle = ''; + setStyle: function () { + var _a = this.data, offsetTop = _a.offsetTop, height = _a.height, fixed = _a.fixed, zIndex = _a.zIndex; + if (fixed) { + this.setData({ + wrapStyle: "top: " + offsetTop + "px;", + containerStyle: "height: " + height + "px; z-index: " + zIndex + ";" + }); } - var data = {}; - if (wrapStyle !== this.data.wrapStyle) { - data.wrapStyle = wrapStyle; - } - if (containerStyle !== this.data.containerStyle) { - data.containerStyle = containerStyle; - } - if (JSON.stringify(data) !== '{}') { - this.setData(data); - } - }, - setPosition: function (position) { - var _this = this; - if (position !== this.data.position) { - this.setData({ position: position }); - utils_1.nextTick(function () { - _this.setWrapStyle(); + else { + this.setData({ + wrapStyle: '', + containerStyle: '' }); } }, observerContentScroll: function () { var _this = this; - var _a = this.data.offsetTop, offsetTop = _a === void 0 ? 0 : _a; - var windowHeight = wx.getSystemInfoSync().windowHeight; - this.createIntersectionObserver({}).disconnect(); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ top: -(this.itemHeight + offsetTop) }) - .observe('.van-sticky', function (res) { - var top = res.boundingClientRect.top; - if (top > offsetTop) { - return; - } - var position = 'top'; - _this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: true - }); - _this.setPosition(position); + var offsetTop = this.data.offsetTop; + var intersectionObserver = this.createIntersectionObserver({ + thresholds: [0, 1] }); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ bottom: -(windowHeight - 1 - offsetTop) }) - .observe('.van-sticky', function (res) { - var _a = res.boundingClientRect, top = _a.top, bottom = _a.bottom; - if (bottom <= _this.itemHeight - 1) { + this.intersectionObserver = intersectionObserver; + intersectionObserver.relativeToViewport({ top: -offsetTop }); + intersectionObserver.observe('.van-sticky', function (res) { + if (_this.data.disabled) { return; } - var position = res.intersectionRatio > 0 ? 'top' : ''; + // @ts-ignore + var _a = res.boundingClientRect, top = _a.top, height = _a.height; + var fixed = top <= offsetTop; _this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: position === 'top' + scrollTop: top, + isFixed: fixed + }); + _this.setData({ fixed: fixed, height: height }); + wx.nextTick(function () { + _this.setStyle(); }); - _this.setPosition(position); }); } }, mounted: function () { - var _this = this; - this.getRect('.van-sticky').then(function (rect) { - _this.itemHeight = rect.height; - _this.itemTop = rect.top; - _this.observerContentScroll(); - }); + this.observerContentScroll(); }, destroyed: function () { - this.createIntersectionObserver({}).disconnect(); + this.intersectionObserver.disconnect(); } }); diff --git a/lib/sticky/index.wxml b/lib/sticky/index.wxml index 73360c28..036cf143 100644 --- a/lib/sticky/index.wxml +++ b/lib/sticky/index.wxml @@ -1,5 +1,7 @@ - - + + + + diff --git a/lib/sticky/index.wxss b/lib/sticky/index.wxss index 86c02f56..52693875 100644 --- a/lib/sticky/index.wxss +++ b/lib/sticky/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-sticky{position:relative} \ No newline at end of file +@import '../common/index.wxss';.van-sticky{position:relative}.van-sticky-wrap--fixed{position:fixed;right:0;left:0} \ No newline at end of file diff --git a/lib/submit-bar/index.wxss b/lib/submit-bar/index.wxss index b891fcb8..c21838e8 100644 --- a/lib/submit-bar/index.wxss +++ b/lib/submit-bar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-submit-bar{position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none;z-index:100;z-index:var(--submit-bar-z-index,100)}.van-submit-bar__tip{padding:10px;padding:var(--submit-bar-tip-padding,10px);color:#f56723;color:var(--submit-bar-tip-color,#f56723);font-size:12px;font-size:var(--submit-bar-tip-font-size,12px);line-height:1.5;line-height:var(--submit-bar-tip-line-height,1.5);background-color:#fff7cc;background-color:var(--submit-bar-tip-background-color,#fff7cc)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end;height:50px;height:var(--submit-bar-height,50px);font-size:14px;font-size:var(--submit-bar-text-font-size,14px);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__bar--safe{padding-bottom:env(safe-area-inset-bottom)}.van-submit-bar__text{-webkit-flex:1;flex:1;padding-right:12px;font-weight:500;text-align:right;color:#333;color:var(--submit-bar-text-color,#333)}.van-submit-bar__price{color:#ee0a24;color:var(--submit-bar-price-color,#ee0a24);font-size:18px;font-size:var(--submit-bar-price-font-size,18px)}.van-submit-bar__currency{font-size:14px;font-size:var(--submit-bar-currency-font-size,14px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px;width:var(--submit-bar-button-width,110px)} \ No newline at end of file +@import '../common/index.wxss';.van-submit-bar{position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none;z-index:100;z-index:var(--submit-bar-z-index,100);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__tip{padding:10px;padding:var(--submit-bar-tip-padding,10px);color:#f56723;color:var(--submit-bar-tip-color,#f56723);font-size:12px;font-size:var(--submit-bar-tip-font-size,12px);line-height:1.5;line-height:var(--submit-bar-tip-line-height,1.5);background-color:#fff7cc;background-color:var(--submit-bar-tip-background-color,#fff7cc)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle;font-size:12px;font-size:var(--submit-bar-tip-icon-size,12px);min-width:18px;min-width:calc(var(--submit-bar-tip-icon-size, 12px)*1.5)}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end;height:50px;height:var(--submit-bar-height,50px);font-size:14px;font-size:var(--submit-bar-text-font-size,14px);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__bar--safe{padding-bottom:env(safe-area-inset-bottom)}.van-submit-bar__text{-webkit-flex:1;flex:1;text-align:right;color:#323233;color:var(--submit-bar-text-color,#323233);padding-right:12px;padding-right:var(--padding-sm,12px);font-weight:500;font-weight:var(--font-weight-bold,500)}.van-submit-bar__price{color:#ee0a24;color:var(--submit-bar-price-color,#ee0a24);font-size:18px;font-size:var(--submit-bar-price-font-size,18px)}.van-submit-bar__currency{font-size:14px;font-size:var(--submit-bar-currency-font-size,14px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px;width:var(--submit-bar-button-width,110px)} \ No newline at end of file diff --git a/lib/switch/index.wxml b/lib/switch/index.wxml index 147d6189..31a104df 100644 --- a/lib/switch/index.wxml +++ b/lib/switch/index.wxml @@ -6,6 +6,6 @@ bind:tap="onClick" > - + diff --git a/lib/switch/index.wxss b/lib/switch/index.wxss index 335fb1b6..e32a72ad 100644 --- a/lib/switch/index.wxss +++ b/lib/switch/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-switch{position:relative;display:inline-block;box-sizing:initial;width:2em;width:var(--switch-width,2em);height:1em;height:var(--switch-height,1em);background-color:#fff;background-color:var(--switch-background-color,#fff);border:1px solid rgba(0,0,0,.1);border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:1em;border-radius:var(--switch-node-size,1em);transition:background-color .3s;transition:background-color var(--switch-transition-duration,.3s)}.van-switch__node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;z-index:var(--switch-node-z-index,1);width:1em;width:var(--switch-node-size,1em);height:1em;height:var(--switch-node-size,1em);background-color:#fff;background-color:var(--switch-node-background-color,#fff);box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05),-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{position:absolute!important;top:25%;left:25%}.van-switch--on{background-color:#1989fa;background-color:var(--switch-on-background-color,#1989fa)}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em);-webkit-transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)));transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)))}.van-switch--disabled{opacity:.4;opacity:var(--switch-disabled-opacity,.4)} \ No newline at end of file +@import '../common/index.wxss';.van-switch{position:relative;display:inline-block;box-sizing:initial;width:2em;width:var(--switch-width,2em);height:1em;height:var(--switch-height,1em);background-color:#fff;background-color:var(--switch-background-color,#fff);border:1px solid rgba(0,0,0,.1);border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:1em;border-radius:var(--switch-node-size,1em);transition:background-color .3s;transition:background-color var(--switch-transition-duration,.3s)}.van-switch__node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;z-index:var(--switch-node-z-index,1);width:1em;width:var(--switch-node-size,1em);height:1em;height:var(--switch-node-size,1em);background-color:#fff;background-color:var(--switch-node-background-color,#fff);box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05),-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{position:absolute!important;top:25%;left:25%;width:50%;height:50%}.van-switch--on{background-color:#1989fa;background-color:var(--switch-on-background-color,#1989fa)}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em);-webkit-transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)));transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)))}.van-switch--disabled{opacity:.4;opacity:var(--switch-disabled-opacity,.4)} \ No newline at end of file diff --git a/lib/tab/index.js b/lib/tab/index.js index bfb25bbb..ae9a4978 100644 --- a/lib/tab/index.js +++ b/lib/tab/index.js @@ -4,7 +4,13 @@ var component_1 = require("../common/component"); component_1.VantComponent({ relation: { name: 'tabs', - type: 'ancestor' + type: 'ancestor', + linked: function (target) { + this.parent = target; + }, + unlinked: function () { + this.parent = null; + } }, props: { dot: Boolean, @@ -15,7 +21,6 @@ component_1.VantComponent({ name: { type: [Number, String], value: '', - observer: 'setComputedName' } }, data: { @@ -35,10 +40,15 @@ component_1.VantComponent({ setComputedName: function () { this.computedName = this.data.name || this.index; }, + getComputedName: function () { + if (this.data.name !== '') { + return this.data.name; + } + return this.index; + }, update: function () { - var parent = this.getRelationNodes('../tabs/index')[0]; - if (parent) { - parent.updateTabs(); + if (this.parent) { + this.parent.updateTabs(); } } } diff --git a/lib/tabbar-item/index.wxml b/lib/tabbar-item/index.wxml index b2649ae4..d83b061f 100644 --- a/lib/tabbar-item/index.wxml +++ b/lib/tabbar-item/index.wxml @@ -5,11 +5,11 @@ style="color: {{ active ? activeColor : inactiveColor }}" bind:tap="onClick" > - + diff --git a/lib/tabbar-item/index.wxss b/lib/tabbar-item/index.wxss index 20d78548..f1e876ef 100644 --- a/lib/tabbar-item/index.wxss +++ b/lib/tabbar-item/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;height:100%;font-size:12px;line-height:1;color:#7d7e80;color:var(--gray-darker,#7d7e80)}.van-tabbar-item__icon{position:relative;margin-bottom:5px;font-size:18px}.van-tabbar-item__icon--dot:after{position:absolute;top:0;right:-8px;width:8px;height:8px;border-radius:100%;content:" ";background-color:#ee0a24;background-color:var(--red,#ee0a24)}.van-tabbar-item__icon image{display:block;width:30px;height:18px}.van-tabbar-item--active{color:#1989fa;color:var(--blue,#1989fa)} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;height:100%;color:#7d7e80;color:var(--tabbar-item-text-color,#7d7e80);font-size:12px;font-size:var(--tabbar-item-font-size,12px);line-height:1;line-height:var(--tabbar-item-line-height,1)}.van-tabbar-item__icon{position:relative;margin-bottom:5px;margin-bottom:var(--tabbar-item-margin-bottom,5px);font-size:18px;font-size:var(--tabbar-item-icon-size,18px)}.van-tabbar-item__icon__inner{display:block;min-width:1em}.van-tabbar-item--active{color:#1989fa;color:var(--tabbar-item-active-color,#1989fa)}.van-tabbar-item__info{margin-top:2px} \ No newline at end of file diff --git a/lib/tabbar/index.wxss b/lib/tabbar/index.wxss index 69eea105..65fad1e3 100644 --- a/lib/tabbar/index.wxss +++ b/lib/tabbar/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;width:100%;height:50px;background-color:#fff;background-color:var(--white,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file +@import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;width:100%;height:50px;height:var(--tabbar-height,50px);background-color:#fff;background-color:var(--tabbar-background-color,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file diff --git a/lib/tabs/index.js b/lib/tabs/index.js index 45ddd6b0..ea452dcb 100644 --- a/lib/tabs/index.js +++ b/lib/tabs/index.js @@ -11,7 +11,6 @@ component_1.VantComponent({ type: 'descendant', linked: function (child) { child.index = this.children.length; - child.setComputedName(); this.children.push(child); this.updateTabs(this.data.tabs.concat(child.data)); }, @@ -24,28 +23,39 @@ component_1.VantComponent({ while (i >= 0 && i < this.children.length) { var currentChild = this.children[i]; currentChild.index--; - currentChild.setComputedName(); i++; } this.updateTabs(tabs); } }, props: { - color: String, + color: { + type: String, + observer: 'setLine' + }, sticky: Boolean, - animated: Boolean, + animated: { + type: Boolean, + observer: 'setTrack' + }, swipeable: Boolean, lineWidth: { type: [String, Number], - value: -1 + value: -1, + observer: 'setLine' }, lineHeight: { type: [String, Number], - value: -1 + value: -1, + observer: 'setLine' }, active: { type: [String, Number], value: 0, + observer: function (value) { + this.currentName = value; + this.setActiveTab(); + } }, type: { type: String, @@ -65,7 +75,12 @@ component_1.VantComponent({ }, swipeThreshold: { type: Number, - value: 4 + value: 4, + observer: function () { + this.setData({ + scrollable: this.children.length > this.data.swipeThreshold + }); + } }, offsetTop: { type: Number, @@ -80,37 +95,15 @@ component_1.VantComponent({ trackStyle: '', wrapStyle: '', position: '', - currentIndex: 0, - }, - watch: { - swipeThreshold: function () { - this.setData({ - scrollable: this.children.length > this.data.swipeThreshold - }); - }, - color: 'setLine', - lineWidth: 'setLine', - lineHeight: 'setLine', - active: 'setActiveTab', - animated: 'setTrack', - offsetTop: 'setWrapStyle' + currentIndex: 0 }, beforeCreate: function () { this.children = []; }, mounted: function () { - var _this = this; this.setLine(true); this.setTrack(); this.scrollIntoView(); - this.getRect('.van-tabs__wrap').then(function (rect) { - _this.navHeight = rect.height; - _this.observerContentScroll(); - }); - }, - destroyed: function () { - // @ts-ignore - this.createIntersectionObserver().disconnect(); }, methods: { updateTabs: function (tabs) { @@ -131,18 +124,19 @@ component_1.VantComponent({ onTap: function (event) { var index = event.currentTarget.dataset.index; var child = this.children[index]; + var computedName = child.getComputedName(); if (this.data.tabs[index].disabled) { - this.trigger('disabled', child.computedName); + this.trigger('disabled', computedName); } else { - this.trigger('click', child.computedName); - this.setActive(child.computedName); + this.trigger('click', computedName); + this.setActive(computedName); } }, - setActive: function (computedName) { - if (computedName !== this.currentName) { - this.currentName = computedName; - this.trigger('change', computedName); + setActive: function (name) { + if (name !== this.currentName) { + this.currentName = name; + this.trigger('change', name); this.setActiveTab(); } }, @@ -155,7 +149,9 @@ component_1.VantComponent({ this.getRect('.van-tab', true).then(function (rects) { var rect = rects[currentIndex]; var width = lineWidth !== -1 ? lineWidth : rect.width / 2; - var height = lineHeight !== -1 ? "height: " + utils_1.addUnit(lineHeight) + "; border-radius: " + utils_1.addUnit(lineHeight) + ";" : ''; + var height = lineHeight !== -1 + ? "height: " + utils_1.addUnit(lineHeight) + "; border-radius: " + utils_1.addUnit(lineHeight) + ";" + : ''; var left = rects .slice(0, currentIndex) .reduce(function (prev, curr) { return prev + curr.width; }, 0); @@ -187,16 +183,19 @@ component_1.VantComponent({ setActiveTab: function () { var _this = this; if (!utils_1.isDef(this.currentName)) { - this.currentName = this.data.active || (this.children[0] || {}).computedName; + 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.computedName === _this.currentName + active: item.getComputedName() === _this.currentName }; if (data.active) { - _this.setData({ - currentIndex: index - }); + _this.setData({ currentIndex: index }); data.inited = true; } if (data.active !== item.data.active) { @@ -249,77 +248,14 @@ component_1.VantComponent({ var minSwipeDistance = 50; if (direction === 'horizontal' && offsetX >= minSwipeDistance) { if (deltaX > 0 && currentIndex !== 0) { - this.setActive(this.children[currentIndex - 1].computedName); + var child = this.children[currentIndex - 1]; + this.setActive(child.getComputedName()); } else if (deltaX < 0 && currentIndex !== tabs.length - 1) { - this.setActive(this.children[currentIndex + 1].computedName); + var child = this.children[currentIndex - 1]; + this.setActive(child.getComputedName()); } } - }, - setWrapStyle: function () { - var _a = this.data, offsetTop = _a.offsetTop, position = _a.position; - var wrapStyle; - switch (position) { - case 'top': - wrapStyle = "\n top: " + offsetTop + "px;\n position: fixed;\n "; - break; - case 'bottom': - wrapStyle = "\n top: auto;\n bottom: 0;\n "; - break; - default: - wrapStyle = ''; - } - if (wrapStyle !== this.data.wrapStyle) { - this.setData({ wrapStyle: wrapStyle }); - } - }, - observerContentScroll: function () { - var _this = this; - if (!this.data.sticky) { - return; - } - var offsetTop = this.data.offsetTop; - var windowHeight = wx.getSystemInfoSync().windowHeight; - // @ts-ignore - this.createIntersectionObserver().disconnect(); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ top: -(this.navHeight + offsetTop) }) - .observe('.van-tabs', function (res) { - var top = res.boundingClientRect.top; - if (top > offsetTop) { - return; - } - var position = res.intersectionRatio > 0 ? 'top' : 'bottom'; - _this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: position === 'top' - }); - _this.setPosition(position); - }); - // @ts-ignore - this.createIntersectionObserver() - .relativeToViewport({ bottom: -(windowHeight - 1 - offsetTop) }) - .observe('.van-tabs', function (res) { - var _a = res.boundingClientRect, top = _a.top, bottom = _a.bottom; - if (bottom < _this.navHeight) { - return; - } - var position = res.intersectionRatio > 0 ? 'top' : ''; - _this.$emit('scroll', { - scrollTop: top + offsetTop, - isFixed: position === 'top' - }); - _this.setPosition(position); - }); - }, - setPosition: function (position) { - var _this = this; - if (position !== this.data.position) { - this.set({ position: position }).then(function () { - _this.setWrapStyle(); - }); - } } } }); diff --git a/lib/tabs/index.json b/lib/tabs/index.json index bf0ebe00..19c0bc3a 100644 --- a/lib/tabs/index.json +++ b/lib/tabs/index.json @@ -1,6 +1,7 @@ { "component": true, "usingComponents": { - "van-info": "../info/index" + "van-info": "../info/index", + "van-sticky": "../sticky/index" } } diff --git a/lib/tabs/index.wxml b/lib/tabs/index.wxml index fd0a738f..e168bd04 100644 --- a/lib/tabs/index.wxml +++ b/lib/tabs/index.wxml @@ -1,41 +1,44 @@ - - + + + - - - - - - {{ item.title }} - + + + + + + {{ item.title }} + + - - + + + + + - - + diff --git a/lib/tag/index.wxss b/lib/tag/index.wxss index fb8276bc..211e3769 100644 --- a/lib/tag/index.wxss +++ b/lib/tag/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tag{display:inline-block;padding:.2em .5em;font-size:10px;line-height:normal;border-radius:.2em;color:#fff;color:var(--white,#fff)}.van-tag:after{border-color:currentColor;border-radius:.4em}.van-tag--default{background-color:#999;background-color:var(--tag-default-color,#999)}.van-tag--default.van-tag--plain{color:#999;color:var(--tag-default-color,#999)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.6em;border-radius:0 .8em .8em 0}.van-tag--mark:after{border-radius:0 1.6em 1.6em 0}.van-tag--round{border-radius:.8em}.van-tag--round:after{border-radius:1.6em}.van-tag--medium{font-size:12px}.van-tag--large{font-size:14px} \ No newline at end of file +@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px} \ No newline at end of file diff --git a/lib/toast/index.wxss b/lib/toast/index.wxss index 5b0979ba..da946c9b 100644 --- a/lib/toast/index.wxss +++ b/lib/toast/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(51,51,51,.88);background-color:var(--toast-background-color,rgba(51,51,51,.88));border-radius:4px;border-radius:var(--toast-border-radius,4px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:90px;width:var(--toast-default-width,90px);min-height:90px;min-height:var(--toast-default-min-height,90px);padding:15px;padding:var(--toast-default-padding,15px)}.van-toast--icon .van-toast__icon{font-size:48px;font-size:var(--toast-icon-size,48px)}.van-toast--icon .van-toast__text{padding-top:5px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)} \ No newline at end of file +@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(50,50,51,.88);background-color:var(--toast-background-color,rgba(50,50,51,.88));border-radius:4px;border-radius:var(--toast-border-radius,4px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:90px;width:var(--toast-default-width,90px);min-height:90px;min-height:var(--toast-default-min-height,90px);padding:16px;padding:var(--toast-default-padding,16px)}.van-toast--icon .van-toast__icon{font-size:48px;font-size:var(--toast-icon-size,48px)}.van-toast--icon .van-toast__text{padding-top:8px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)} \ No newline at end of file diff --git a/lib/toast/toast.js b/lib/toast/toast.js index a92158ac..b74e6a67 100644 --- a/lib/toast/toast.js +++ b/lib/toast/toast.js @@ -18,7 +18,7 @@ var defaultOptions = { message: '', show: true, zIndex: 1000, - duration: 3000, + duration: 2000, position: 'middle', forbidClick: false, loadingType: 'circular', diff --git a/lib/tree-select/index.js b/lib/tree-select/index.js index 0b11b32c..9efc2370 100644 --- a/lib/tree-select/index.js +++ b/lib/tree-select/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); -var ITEM_HEIGHT = 44; +var utils_1 = require("../common/utils"); component_1.VantComponent({ classes: [ 'main-item-class', @@ -12,15 +12,20 @@ component_1.VantComponent({ 'content-disabled-class' ], props: { - items: Array, + items: { + type: Array, + observer: 'updateSubItems' + }, activeId: null, mainActiveIndex: { type: Number, - value: 0 + value: 0, + observer: 'updateSubItems' }, - maxHeight: { - type: Number, - value: 300 + height: { + type: [Number, String], + value: 300, + observer: 'updateHeight' }, max: { type: Number, @@ -28,22 +33,10 @@ component_1.VantComponent({ } }, data: { - subItems: [], - mainHeight: 0, - itemHeight: 0 + subItems: [] }, - watch: { - items: function () { - var _this = this; - this.updateSubItems().then(function () { - _this.updateMainHeight(); - }); - }, - maxHeight: function () { - this.updateItemHeight(this.data.subItems); - this.updateMainHeight(); - }, - mainActiveIndex: 'updateSubItems' + created: function () { + this.updateHeight(); }, methods: { // 当一个子项被选择时 @@ -51,16 +44,18 @@ component_1.VantComponent({ var item = event.currentTarget.dataset.item; var isArray = Array.isArray(this.data.activeId); // 判断有没有超出右侧选择的最大数 - var isOverMax = isArray && (this.data.activeId.length >= this.data.max); + var isOverMax = isArray && this.data.activeId.length >= this.data.max; // 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件 - var isSelected = isArray ? this.data.activeId.indexOf(item.id) > -1 : this.data.activeId === item.id; + var isSelected = isArray + ? this.data.activeId.indexOf(item.id) > -1 + : this.data.activeId === item.id; if (!item.disabled && (!isOverMax || isSelected)) { this.$emit('click-item', item); } }, // 当一个导航被点击时 onClickNav: function (event) { - var index = event.currentTarget.dataset.index; + var index = event.detail; var item = this.data.items[index]; if (!item.disabled) { this.$emit('click-nav', { index: index }); @@ -70,19 +65,12 @@ component_1.VantComponent({ updateSubItems: function () { var _a = this.data, items = _a.items, mainActiveIndex = _a.mainActiveIndex; var _b = (items[mainActiveIndex] || {}).children, children = _b === void 0 ? [] : _b; - this.updateItemHeight(children); return this.set({ subItems: children }); }, - // 更新组件整体高度,根据最大高度和当前组件需要展示的高度来决定 - updateMainHeight: function () { - var _a = this.data, _b = _a.items, items = _b === void 0 ? [] : _b, _c = _a.subItems, subItems = _c === void 0 ? [] : _c; - var maxHeight = Math.max(items.length * ITEM_HEIGHT, subItems.length * ITEM_HEIGHT); - this.setData({ mainHeight: Math.min(maxHeight, this.data.maxHeight) }); - }, - // 更新子项列表高度,根据可展示的最大高度和当前子项列表的高度决定 - updateItemHeight: function (subItems) { - var itemHeight = Math.min(subItems.length * ITEM_HEIGHT, this.data.maxHeight); - return this.setData({ itemHeight: itemHeight }); + updateHeight: function () { + this.setData({ + innerHeight: utils_1.addUnit(this.data.height) + }); } } }); diff --git a/lib/tree-select/index.json b/lib/tree-select/index.json index 0a336c08..42991a2a 100644 --- a/lib/tree-select/index.json +++ b/lib/tree-select/index.json @@ -1,6 +1,8 @@ { "component": true, "usingComponents": { - "van-icon": "../icon/index" + "van-icon": "../icon/index", + "van-sidebar": "../sidebar/index", + "van-sidebar-item": "../sidebar-item/index" } } diff --git a/lib/tree-select/index.wxml b/lib/tree-select/index.wxml index baa6a221..0e8df176 100644 --- a/lib/tree-select/index.wxml +++ b/lib/tree-select/index.wxml @@ -3,29 +3,27 @@ - - {{ item.text }} - + + + - + diff --git a/lib/tree-select/index.wxss b/lib/tree-select/index.wxss index 1a432227..654e55a6 100644 --- a/lib/tree-select/index.wxss +++ b/lib/tree-select/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-tree-select{position:relative;font-size:14px;-webkit-user-select:none;user-select:none}.van-tree-select__nav{position:absolute;top:0;bottom:0;left:0;width:35%;min-width:120px;background-color:#fafafa;background-color:var(--background-color-light,#fafafa)}.van-tree-select__nitem{position:relative;padding:0 9px 0 15px;line-height:44px}.van-tree-select__nitem--active:after{position:absolute;top:0;bottom:0;left:0;width:3.6px;content:"";background-color:#ee0a24;background-color:var(--red,#ee0a24)}.van-tree-select__nitem--active{font-weight:700;background-color:#fff;background-color:var(--white,#fff)}.van-tree-select__nitem--disabled{color:#999;color:var(--gray-dark,#999)}.van-tree-select__content{box-sizing:border-box;width:65%;margin-left:35%;padding-left:15px;background-color:#fff;background-color:var(--white,#fff)}.van-tree-select__item{position:relative;font-weight:700;line-height:44px}.van-tree-select__item--active{color:#ee0a24;color:var(--red,#ee0a24)}.van-tree-select__item--disabled{color:#999;color:var(--gray-dark,#999)}.van-tree-select__selected{position:absolute;top:0;right:15px;bottom:0;height:24px;margin:auto 0;line-height:24px} \ No newline at end of file +@import '../common/index.wxss';.van-tree-select{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;font-size:14px;font-size:var(--tree-select-font-size,14px)}.van-tree-select__nav{-webkit-flex:1;flex:1;background-color:#fafafa;background-color:var(--tree-select-nav-background-color,#fafafa);--sidebar-padding:12px 8px 12px 12px}.van-tree-select__nav__inner{width:100%!important;height:100%}.van-tree-select__content{-webkit-flex:2;flex:2;background-color:#fff;background-color:var(--tree-select-content-background-color,#fff)}.van-tree-select__item{position:relative;font-weight:700;padding:0 32px 0 16px;padding:0 32px 0 var(--padding-md,16px);line-height:44px;line-height:var(--tree-select-item-height,44px)}.van-tree-select__item--active{color:#ee0a24;color:var(--tree-select-item-active-color,#ee0a24)}.van-tree-select__item--disabled{color:#c8c9cc;color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/lib/uploader/index.js b/lib/uploader/index.js new file mode 100644 index 00000000..c25696ac --- /dev/null +++ b/lib/uploader/index.js @@ -0,0 +1,171 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var component_1 = require("../common/component"); +var utils_1 = require("./utils"); +var utils_2 = require("../common/utils"); +component_1.VantComponent({ + props: { + disabled: Boolean, + uploadText: String, + previewSize: { + type: null, + value: 90, + observer: 'setComputedPreviewSize' + }, + name: { + type: [Number, String], + value: '' + }, + accept: { + type: String, + value: 'image' + }, + fileList: { + type: Array, + value: [], + observer: 'formatFileList' + }, + maxSize: { + type: Number, + value: Number.MAX_VALUE + }, + maxCount: { + type: Number, + value: 100 + }, + previewImage: { + type: Boolean, + value: true + }, + previewFullImage: { + type: Boolean, + value: true + }, + imageFit: { + type: String, + value: 'scaleToFill' + }, + useSlot: Boolean, + useBeforeRead: Boolean + }, + data: { + lists: [], + computedPreviewSize: '', + isInCount: true + }, + methods: { + formatFileList: function () { + var _a = this.data, _b = _a.fileList, fileList = _b === void 0 ? [] : _b, maxCount = _a.maxCount; + var lists = fileList.map(function (item) { return (__assign(__assign({}, item), { isImage: typeof item.isImage === 'undefined' + ? utils_1.isImageFile(item) + : item.isImage })); }); + this.setData({ lists: lists, isInCount: lists.length < maxCount }); + }, + setComputedPreviewSize: function (val) { + this.setData({ + computedPreviewSize: utils_2.addUnit(val) + }); + }, + startUpload: function () { + var _this = this; + if (this.data.disabled) + return; + var _a = this.data, _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.capture, capture = _c === void 0 ? ['album', 'camera'] : _c, _d = _a.maxCount, maxCount = _d === void 0 ? 100 : _d, _e = _a.multiple, multiple = _e === void 0 ? false : _e, maxSize = _a.maxSize, accept = _a.accept, lists = _a.lists, _f = _a.useBeforeRead // 是否定义了 beforeRead + , useBeforeRead = _f === void 0 ? false : _f // 是否定义了 beforeRead + ; + var chooseFile = null; + var newMaxCount = maxCount - lists.length; + // 设置为只选择图片的时候使用 chooseImage 来实现 + if (accept === 'image') { + chooseFile = new Promise(function (resolve, reject) { + wx.chooseImage({ + count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1, + sourceType: capture, + success: function (res) { + resolve(res); + }, + fail: function (err) { + reject(err); + } + }); + }); + } + else { + chooseFile = new Promise(function (resolve, reject) { + wx.chooseMessageFile({ + count: multiple ? newMaxCount : 1, + type: 'file', + success: function (res) { + resolve(res); + }, + fail: function (err) { + reject(err); + } + }); + }); + } + chooseFile.then(function (res) { + var file = multiple ? res.tempFiles : res.tempFiles[0]; + // 检查文件大小 + if (file instanceof Array) { + var sizeEnable = file.every(function (item) { return item.size <= maxSize; }); + if (!sizeEnable) { + _this.$emit('oversize', { name: name }); + return; + } + } + else if (file.size > maxSize) { + _this.$emit('oversize', { name: name }); + return; + } + // 触发上传之前的钩子函数 + if (useBeforeRead) { + _this.$emit('before-read', { + file: file, + name: name, + callback: function (result) { + if (result) { + // 开始上传 + _this.$emit('after-read', { file: file, name: name }); + } + } + }); + } + else { + _this.$emit('after-read', { file: file, name: name }); + } + }); + }, + deleteItem: function (event) { + var index = event.currentTarget.dataset.index; + this.$emit('delete', { index: index, name: this.data.name }); + }, + doPreviewImage: function (event) { + if (!this.data.previewFullImage) + return; + var curUrl = event.currentTarget.dataset.url; + var images = this.data.lists + .filter(function (item) { return item.isImage; }) + .map(function (item) { return item.url || item.path; }); + this.$emit('click-preview', { url: curUrl, name: this.data.name }); + wx.previewImage({ + urls: images, + current: curUrl, + fail: function () { + wx.showToast({ title: '预览图片失败', icon: 'none' }); + } + }); + } + } +}); diff --git a/lib/uploader/index.json b/lib/uploader/index.json new file mode 100644 index 00000000..0a336c08 --- /dev/null +++ b/lib/uploader/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/lib/uploader/index.wxml b/lib/uploader/index.wxml new file mode 100644 index 00000000..a57cfda2 --- /dev/null +++ b/lib/uploader/index.wxml @@ -0,0 +1,60 @@ + + + + + + + + {{ item.name || ('图片' + index) }} + + + {{ item.name || item.url || item.path }} + + + + + + + + + + + + + + + + {{ uploadText }} + + + + + diff --git a/lib/uploader/index.wxss b/lib/uploader/index.wxss new file mode 100644 index 00000000..88b6a79b --- /dev/null +++ b/lib/uploader/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #e5e5e5}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px}.van-uploader__preview-delete{position:absolute;right:0;bottom:0;display:inline-block;width:18px;height:18px;padding:1px;color:#fff;text-align:center;background-color:rgba(0,0,0,.45)}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f8f8f8}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#7d7e80;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#7d7e80;font-size:12px;text-align:center} \ No newline at end of file diff --git a/lib/uploader/utils.js b/lib/uploader/utils.js new file mode 100644 index 00000000..472f08a9 --- /dev/null +++ b/lib/uploader/utils.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg']; +function isImageUrl(url) { + return IMAGE_EXT.some(function (ext) { return url.indexOf("." + ext) !== -1; }); +} +exports.isImageUrl = isImageUrl; +function isImageFile(item) { + if (item.type) { + return item.type.indexOf('image') === 0; + } + if (item.path) { + return isImageUrl(item.path); + } + if (item.url) { + return isImageUrl(item.url); + } + return false; +} +exports.isImageFile = isImageFile;