升级package, 以及更新声明文件
This commit is contained in:
@@ -1 +1 @@
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import{getRect,systemInfo}from"../common/utils";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-navbar`;let Navbar=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-placeholder`,`${prefix}-class-content`,`${prefix}-class-title`,`${prefix}-class-left`,`${prefix}-class-center`,`${prefix}-class-left-icon`,`${prefix}-class-home-icon`,`${prefix}-class-capsule`,`${prefix}-class-nav-btn`],this.timer=null,this.options={multipleSlots:!0},this.properties=props,this.observers={visible(t){const{animation:e}=this.properties,i=`${name}${t?"--visible":"--hide"}`;this.setData({visibleClass:`${i}${e?"-animation":""}`}),this.timer&&clearTimeout(this.timer),e&&(this.timer=setTimeout(()=>{this.setData({visibleClass:i})},300))},"title,titleMaxLength"(){const{title:t}=this.properties,e=this.properties.titleMaxLength||Number.MAX_SAFE_INTEGER;let i=t.slice(0,e);e<t.length&&(i+="..."),this.setData({showTitle:i})}},this.data={prefix:prefix,classPrefix:name,boxStyle:"",showTitle:"",hideLeft:!1,hideCenter:!1,_menuRect:null,_leftRect:null,_boxStyle:{}},this.methods={initStyle(){this.getMenuRect();const{_menuRect:t,_leftRect:e}=this.data;if(!t||!e||!systemInfo)return;const i={"--td-navbar-padding-top":`${systemInfo.statusBarHeight}px`,"--td-navbar-right":systemInfo.windowWidth-t.left+"px","--td-navbar-left-max-width":`${t.left}px`,"--td-navbar-capsule-height":`${t.height}px`,"--td-navbar-capsule-width":`${t.width}px`,"--td-navbar-height":`${2*(t.top-systemInfo.statusBarHeight)+t.height}px`};this.calcCenterStyle(e,t,i)},calcCenterStyle(t,e,i){const n=Math.max(t.right,systemInfo.windowWidth-e.left),s=Object.assign(Object.assign({},i),{"--td-navbar-center-left":`${n}px`,"--td-navbar-center-width":`${Math.max(e.left-n,0)}px`}),a=Object.entries(s).map(([t,e])=>`${t}: ${e}`).join("; ");this.setData({boxStyle:a,_boxStyle:s})},getLeftRect(){getRect(this,`.${name}__left`).then(t=>{t.right>this.data._leftRect.right&&this.calcCenterStyle(t,this.data._menuRect,this.data._boxStyle)})},getMenuRect(){if(wx.getMenuButtonBoundingClientRect){const t=wx.getMenuButtonBoundingClientRect();this.setData({_menuRect:t,_leftRect:{right:systemInfo.windowWidth-t.left}})}},onMenuButtonBoundingClientRectWeightChange(){wx.onMenuButtonBoundingClientRectWeightChange&&(this.onMenuButtonBoundingClientRectWeightChangeCallback=t=>this.queryElements(t),wx.onMenuButtonBoundingClientRectWeightChange(this.onMenuButtonBoundingClientRectWeightChangeCallback))},offMenuButtonBoundingClientRectWeightChange(){this.onMenuButtonBoundingClientRectWeightChangeCallback&&wx.offMenuButtonBoundingClientRectWeightChange(this.onMenuButtonBoundingClientRectWeightChangeCallback)},queryElements(t){Promise.all([getRect(this,`.${this.data.classPrefix}__left`),getRect(this,`.${this.data.classPrefix}__center`)]).then(([e,i])=>{const n=Math.round(e.right),s=Math.round(i.right),a=t.left;this.setData({hideLeft:n>a,hideCenter:n>a||s>a})})},goBack(){const{delta:t}=this.data,e=this;this.triggerEvent("go-back"),t>0&&wx.navigateBack({delta:t,fail(t){e.triggerEvent("fail",t)},complete(t){e.triggerEvent("complete",t)},success(t){e.triggerEvent("success",t)}})}}}attached(){this.initStyle(),this.getLeftRect(),this.onMenuButtonBoundingClientRectWeightChange()}detached(){this.offMenuButtonBoundingClientRectWeightChange()}};Navbar=__decorate([wxComponent()],Navbar);export default Navbar;
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import{getRect,systemInfo}from"../common/utils";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-navbar`;let Navbar=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-placeholder`,`${prefix}-class-content`,`${prefix}-class-title`,`${prefix}-class-left`,`${prefix}-class-center`,`${prefix}-class-left-icon`,`${prefix}-class-home-icon`,`${prefix}-class-capsule`,`${prefix}-class-nav-btn`],this.timer=null,this.options={multipleSlots:!0},this.properties=props,this.observers={visible(t){const{animation:e}=this.properties,i=`${name}${t?"--visible":"--hide"}`;this.setData({visibleClass:`${i}${e?"-animation":""}`}),this.timer&&clearTimeout(this.timer),e&&(this.timer=setTimeout(()=>{this.setData({visibleClass:i})},300))},"title,titleMaxLength"(){const{title:t}=this.properties,e=this.properties.titleMaxLength||Number.MAX_SAFE_INTEGER;let i=t.slice(0,e);e<t.length&&(i+="..."),this.setData({showTitle:i})}},this.data={prefix:prefix,classPrefix:name,boxStyle:"",showTitle:"",hideLeft:!1,hideCenter:!1,_menuRect:null,_leftRect:null,_boxStyle:{}},this.methods={initStyle(){this.getMenuRect();const{_menuRect:t,_leftRect:e}=this.data;if(!t||!e||!systemInfo)return;const i={"--td-navbar-padding-top":`${systemInfo.statusBarHeight}px`,"--td-navbar-right":systemInfo.windowWidth-t.left+"px","--td-navbar-left-max-width":`${t.left}px`,"--td-navbar-capsule-height":`${t.height}px`,"--td-navbar-capsule-width":`${t.width}px`,"--td-navbar-height":`${2*(t.top-systemInfo.statusBarHeight)+t.height}px`};this.calcCenterStyle(e,t,i)},calcCenterStyle(t,e,i){const n=Math.max(t.right,systemInfo.windowWidth-e.left),s=Object.assign(Object.assign({},i),{"z-index":this.properties.zIndex,"--td-navbar-center-left":`${n}px`,"--td-navbar-center-width":`${Math.max(e.left-n,0)}px`}),a=Object.entries(s).map(([t,e])=>`${t}: ${e}`).join("; ");this.setData({boxStyle:a,_boxStyle:s})},getLeftRect(){getRect(this,`.${name}__left`).then(t=>{t.right>this.data._leftRect.right&&this.calcCenterStyle(t,this.data._menuRect,this.data._boxStyle)})},getMenuRect(){if(wx.getMenuButtonBoundingClientRect){const t=wx.getMenuButtonBoundingClientRect();this.setData({_menuRect:t,_leftRect:{right:systemInfo.windowWidth-t.left}})}},onMenuButtonBoundingClientRectWeightChange(){wx.onMenuButtonBoundingClientRectWeightChange&&(this.onMenuButtonBoundingClientRectWeightChangeCallback=t=>this.queryElements(t),wx.onMenuButtonBoundingClientRectWeightChange(this.onMenuButtonBoundingClientRectWeightChangeCallback))},offMenuButtonBoundingClientRectWeightChange(){this.onMenuButtonBoundingClientRectWeightChangeCallback&&wx.offMenuButtonBoundingClientRectWeightChange(this.onMenuButtonBoundingClientRectWeightChangeCallback)},queryElements(t){Promise.all([getRect(this,`.${this.data.classPrefix}__left`),getRect(this,`.${this.data.classPrefix}__center`)]).then(([e,i])=>{const n=Math.round(e.right),s=Math.round(i.right),a=t.left;this.setData({hideLeft:n>a,hideCenter:n>a||s>a})})},goBack(){const{delta:t}=this.data,e=this;this.triggerEvent("go-back"),t>0&&wx.navigateBack({delta:t,fail(t){e.triggerEvent("fail",t)},complete(t){e.triggerEvent("complete",t)},success(t){e.triggerEvent("success",t)}})}}}attached(){this.initStyle(),this.getLeftRect(),this.onMenuButtonBoundingClientRectWeightChange()}detached(){this.offMenuButtonBoundingClientRectWeightChange()}};Navbar=__decorate([wxComponent()],Navbar);export default Navbar;
|
||||
@@ -1 +1 @@
|
||||
<wxs src="../common/utils.wxs" module="_"/><view class="{{_.cls(classPrefix, [['fixed', fixed]])}} {{visibleClass}} class {{prefix}}-class" style="{{_._style([boxStyle, style, customStyle])}}"><view wx:if="{{fixed}}" class="{{classPrefix}}__placeholder {{prefix}}-class-placeholder"/><view class="{{classPrefix}}__content {{prefix}}-class-content"><view class="{{classPrefix}}__left {{hideLeft ? classPrefix + '__left--hide' : ''}} {{prefix}}-class-left"><view wx:if="{{leftArrow}}" class="{{classPrefix}}__btn" bind:tap="goBack" aria-role="button" aria-label="返回"><t-icon name="chevron-left" class="{{classPrefix}}__left-arrow"/></view><slot name="left"/><view class="{{classPrefix}}__capsule {{prefix}}-class-capsule"><slot name="capsule"/></view></view><view class="{{classPrefix}}__center {{hideCenter ? classPrefix + '__center--hide' : ''}} {{prefix}}-class-center"><slot name="title"/><text wx:if="{{title}}" class="{{classPrefix}}__center-title {{prefix}}-class-title">{{showTitle}}</text></view></view></view>
|
||||
<wxs src="../common/utils.wxs" module="_"/><view class="{{_.cls(classPrefix, [['fixed', fixed]])}} {{visibleClass}} class {{prefix}}-class" style="{{_._style([boxStyle, style, customStyle])}}"><view wx:if="{{fixed && placeholder}}" class="{{classPrefix}}__placeholder {{prefix}}-class-placeholder"/><view class="{{classPrefix}}__content {{prefix}}-class-content"><view class="{{classPrefix}}__left {{hideLeft ? classPrefix + '__left--hide' : ''}} {{prefix}}-class-left"><view wx:if="{{leftArrow}}" class="{{classPrefix}}__btn" bind:tap="goBack" aria-role="button" aria-label="返回"><t-icon name="chevron-left" class="{{classPrefix}}__left-arrow"/></view><slot name="left"/><view class="{{classPrefix}}__capsule {{prefix}}-class-capsule"><slot name="capsule"/></view></view><view class="{{classPrefix}}__center {{hideCenter ? classPrefix + '__center--hide' : ''}} {{prefix}}-class-center"><slot name="title"/><text wx:if="{{title}}" class="{{classPrefix}}__center-title {{prefix}}-class-title">{{showTitle}}</text></view></view></view>
|
||||
@@ -1,17 +1,18 @@
|
||||
@import '../common/style/index.wxss';.t-navbar--fixed .t-navbar__content{position:fixed;top:0;left:0;z-index:5001;}
|
||||
@import '../common/style/index.wxss';.t-navbar{position:relative;}
|
||||
.t-navbar--fixed .t-navbar__content{position:fixed;top:0;left:0;}
|
||||
.t-navbar--visible{display:'';}
|
||||
.t-navbar--visible-animation{opacity:1;transition:opacity .3s cubic-bezier(.645,.045,.355,1);}
|
||||
.t-navbar--hide-animation{opacity:0;transition:opacity .3s cubic-bezier(.645,.045,.355,1);}
|
||||
.t-navbar--hide{display:none;}
|
||||
.t-navbar__placeholder{height:var(--td-navbar-height,48px);padding-top:var(--td-navbar-padding-top,20px);position:relative;visibility:hidden;box-sizing:content-box;}
|
||||
.t-navbar__content{position:relative;z-index:1;height:var(--td-navbar-height,48px);width:calc(100% - var(--td-navbar-right,95px));padding-right:var(--td-navbar-right,95px);padding-top:var(--td-navbar-padding-top,20px);color:var(--td-navbar-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));background:var(--td-navbar-background,var(--td-navbar-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff))));display:flex;align-items:center;box-sizing:content-box;}
|
||||
.t-navbar__content{position:relative;height:var(--td-navbar-height,48px);width:calc(100% - var(--td-navbar-right,95px));padding-right:var(--td-navbar-right,95px);padding-top:var(--td-navbar-padding-top,20px);color:var(--td-navbar-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));background:var(--td-navbar-background,var(--td-navbar-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff))));display:flex;align-items:center;box-sizing:content-box;}
|
||||
.t-navbar__left{position:relative;box-sizing:border-box;max-width:var(--td-navbar-left-max-width);overflow:hidden;display:flex;align-items:center;margin-left:var(--td-spacer-1,24rpx);transition:opacity .3s cubic-bezier(.645,.045,.355,1);}
|
||||
.t-navbar__left-arrow{font-size:var(--td-navbar-left-arrow-size,24px);}
|
||||
.t-navbar__left--hide{opacity:0;}
|
||||
.t-navbar__capsule{box-sizing:border-box;width:var(--td-navbar-capsule-width,88px);height:var(--td-navbar-capsule-height,32px);display:flex;align-items:center;}
|
||||
.t-navbar__capsule::before{content:'';position:absolute;z-index:-1;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;box-sizing:border-box;border-radius:calc(var(--td-navbar-capsule-border-radius,16px) * 2);border:2rpx solid var(--td-navbar-capsule-border-color,var(--td-border-level-1-color,var(--td-gray-color-3,#e7e7e7)));}
|
||||
.t-navbar__capsule::before{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;box-sizing:border-box;border-radius:calc(var(--td-navbar-capsule-border-radius,16px) * 2);border:2rpx solid var(--td-navbar-capsule-border-color,var(--td-border-level-1-color,var(--td-gray-color-3,#e7e7e7)));}
|
||||
.t-navbar__capsule:empty{display:none;}
|
||||
.t-navbar__center{font-size:18px;text-align:center;position:absolute;bottom:0;left:var(--td-navbar-center-left,var(--td-navbar-right,95px));width:var(--td-navbar-center-width,187px);height:var(--td-navbar-height,48px);line-height:var(--td-navbar-height,48px);flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:opacity .3s cubic-bezier(.645,.045,.355,1);}
|
||||
.t-navbar__center{text-align:center;position:absolute;bottom:0;left:var(--td-navbar-center-left,var(--td-navbar-right,95px));width:var(--td-navbar-center-width,187px);height:var(--td-navbar-height,48px);flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:opacity .3s cubic-bezier(.645,.045,.355,1);}
|
||||
.t-navbar__center:empty{display:none;}
|
||||
.t-navbar__center-title{font-size:var(--td-navbar-title-font-size,18px);text-overflow:ellipsis;white-space:nowrap;overflow:hidden;font-weight:var(--td-navbar-title-font-weight,600);}
|
||||
.t-navbar__center-title{font:var(--td-navbar-title-font,var(--td-font-title-large,600 36rpx / 52rpx var(--td-font-family,PingFang SC,Microsoft YaHei,Arial Regular)));text-overflow:ellipsis;white-space:nowrap;overflow:hidden;}
|
||||
.t-navbar__center--hide{opacity:0;}
|
||||
@@ -1 +1 @@
|
||||
const props={animation:{type:Boolean,value:!0},delta:{type:Number,value:1},fixed:{type:Boolean,value:!0},leftArrow:{type:Boolean,value:!1},safeAreaInsetTop:{type:Boolean,value:!0},title:{type:String},titleMaxLength:{type:Number},visible:{type:Boolean,value:!0}};export default props;
|
||||
const props={animation:{type:Boolean,value:!0},delta:{type:Number,value:1},fixed:{type:Boolean,value:!0},leftArrow:{type:Boolean,value:!1},placeholder:{type:Boolean,value:!1},safeAreaInsetTop:{type:Boolean,value:!0},title:{type:String},titleMaxLength:{type:Number},visible:{type:Boolean,value:!0},zIndex:{type:Number,value:1}};export default props;
|
||||
@@ -15,6 +15,10 @@ export interface TdNavbarProps {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
placeholder?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
safeAreaInsetTop?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
@@ -31,4 +35,8 @@ export interface TdNavbarProps {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
zIndex?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user