diff --git a/build/index.js b/build/index.js index 4352910a..5bf55e48 100644 --- a/build/index.js +++ b/build/index.js @@ -17,7 +17,7 @@ const path = require('path'); const componentData = require('./until'); const result = `{common/*,core/*,behaviors,utils,${componentData()}}`; -const isCustom = (result !== '{common/*,behaviors,utils,}'); +const isCustom = (result !== '{common/*,core/*,behaviors,utils,}'); const distPath = path.resolve(__dirname, '../dist'); const examplePath = path.resolve(__dirname, '../examples/dist'); diff --git a/dist/action-sheet/index.js b/dist/action-sheet/index.js new file mode 100644 index 00000000..03b9d598 --- /dev/null +++ b/dist/action-sheet/index.js @@ -0,0 +1 @@ +import zIndex from"../behaviors/zIndex";import hover from"../behaviors/hover";Component({behaviors:[zIndex,hover],externalClasses:["l-class-title","l-class-item","l-class-cancel","l-title-class","l-item-class","l-cancel-class"],properties:{locked:Boolean,showCancel:Boolean,show:Boolean,itemList:Array,cancelText:{type:String,value:"取消"},title:String,zIndex:{type:Number,value:777},openApi:{type:Boolean,value:!0}},data:{success:"",fail:"",isIphoneX:!1},attached(){this.data.openApi&&this.initActionSheet(),this.initUIAdapter()},pageLifetimes:{show(){this.data.openApi&&this.initActionSheet()}},methods:{initUIAdapter(){wx.getSystemInfo({success:e=>{this.setData({isIphoneX:"iPhone X"===e.model})}})},initActionSheet(){wx.lin=wx.lin||{},wx.lin.showActionSheet=(e={})=>{const{itemList:t=[],success:s=null,fail:i=null,title:a="",locked:l=!1,cancelText:n="取消",showCancel:c=!1}=e;return this.setData({itemList:t.slice(0,10),success:s,fail:i,title:a,locked:l,cancelText:n,showCancel:c,show:!0}),this}},handleClickItem(e){const{success:t}=this.data;t&&t({...e.currentTarget.dataset}),this.triggerEvent("linitemtap",{...e.currentTarget.dataset},{bubbles:!0,composed:!0}),this._hideActionSheet()},_showActionSheet(){this.setData({show:!0})},_hideActionSheet(){this.setData({show:!1})},handleClickCancel(){const{fail:e}=this.data;e&&e({errMsg:"showactionsheet:fail cancel"}),this.triggerEvent("lincancel",{errMsg:"showactionsheet:fail cancel"},{bubbles:!0,composed:!0}),this._hideActionSheet()},handleClickPopUp(){this.data.locked||this.handleClickCancel()}}}); \ No newline at end of file diff --git a/dist/action-sheet/index.json b/dist/action-sheet/index.json new file mode 100644 index 00000000..f301e159 --- /dev/null +++ b/dist/action-sheet/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{"l-icon":"../icon/index","l-popup":"../popup/index","l-button":"../button/index"} } \ No newline at end of file diff --git a/dist/action-sheet/index.wxml b/dist/action-sheet/index.wxml new file mode 100644 index 00000000..b6cd7996 --- /dev/null +++ b/dist/action-sheet/index.wxml @@ -0,0 +1,21 @@ + + + + {{ title }} + + + + + + + {{ item.name }} + + + + + + {{ cancelText }} + + + + diff --git a/dist/action-sheet/index.wxss b/dist/action-sheet/index.wxss new file mode 100644 index 00000000..be530956 --- /dev/null +++ b/dist/action-sheet/index.wxss @@ -0,0 +1 @@ +.l-action-sheet{background:#f7f7f7}.l-item-button{height:88rpx;line-height:88rpx;text-align:center;background:#fff;border-bottom:2rpx solid #f3f3f3;font-size:28rpx;color:#45526b;display:flex;align-items:center;justify-content:center;width:100%;overflow:hidden}.l-cancel{margin-top:12rpx}.l-cancel-x .l-item-button{padding-bottom:44rpx}.l-image-button>.l-button-text{margin-left:20rpx}.list-hover{opacity:.8} \ No newline at end of file diff --git a/dist/album/index.js b/dist/album/index.js new file mode 100644 index 00000000..ea03b607 --- /dev/null +++ b/dist/album/index.js @@ -0,0 +1 @@ +Component({externalClasses:["l-class","l-single-image-class","l-multi-image-class"],properties:{urls:{type:Array},preview:{type:Boolean,value:!0},gapRow:{type:Number,value:10},gapColumn:{type:Number,value:10},singleSize:{type:Number,value:360},multipleSize:{type:Number,value:158},singleMode:{type:String,value:"aspectFit"},multipleMode:{type:String,value:"aspectFill"},key:{type:String,value:"url"},maxNumber:{type:Number,value:9},customRowNumber:{type:Boolean,value:!1},everyRowNumber:{type:Number,value:3},previewFullImage:{type:Boolean,value:!0}},data:{newType:!0,shortSideValue:0,showUrls:[],isLong:!1},observers:{urls:function(){this.init()}},methods:{init(){let{urls:e,maxNumber:t,key:a}=this.data;if(e.length>t&&(e=e.slice(0,t),this.setData({isLong:!0})),this.setData({showUrls:e}),!this.data.customRowNumber){let e=this.data.showUrls.length;e>1&&e<5?this.setData({everyRowNumber:2}):this.setData({everyRowNumber:3})}const s=this.judgeType();this.setData({newType:s}),1===e.length&&this.horizontalOrVertical(s?e[0][a]:e[0])},judgeType(){const e=this.data.urls;return 0===e.length||"object"==typeof e[0]},horizontalOrVertical:function(e){wx.getImageInfo({src:e,success:e=>{const t=e.width>=e.height?e.width:e.height,a=e.width>=e.height?e.height:e.width;this.setData({horizontalScreen:e.width>=e.height,shortSideValue:a*this.data.singleSize/t})}})},onPreviewTap(e){const t=e.currentTarget.id;let a;a=this.data.previewFullImage?this.data.urls:this.data.showUrls;let s="",i=[];const l=this.data.newType,r=this.data.key;if(l){s=a[t][r];for(let e=0;e + + + + + + + +{{urls.length-maxNumber}} + + + + diff --git a/dist/album/index.wxs b/dist/album/index.wxs new file mode 100644 index 00000000..b41eda00 --- /dev/null +++ b/dist/album/index.wxs @@ -0,0 +1,79 @@ +var containerStyle = function (urls, multipleSize, gapRow, gapColumn) { + if (urls.length === 2 || urls.length === 4) { + return 'width:' + (2 * multipleSize + gapRow) + 'rpx; grid-row-gap:' + gapColumn + 'rpx; grid-column-gap:' + gapRow + 'rpx;grid-template-columns:repeat(auto-fit, ' + multipleSize + 'rpx);' + } else { + return 'width:' + (3 * multipleSize + 2 * gapRow) + 'rpx; grid-row-gap:' + gapColumn + 'rpx; grid-column-gap:' + gapRow + 'rpx;grid-template-columns:repeat(auto-fit, ' + multipleSize + 'rpx);' + } + +} + +var blockClass = function (urls, horizontalScreen) { + if (urls.length === 1) { + if (horizontalScreen) { + return 'l-single-image-class' + } else { + return 'vertical l-single-image-class' + } + } else { + return 'l-multi-image-class' + } +} + +var blockStyle = function (urls, horizontalScreen, shortSideValue, singleSize, multipleSize) { + if (urls.length === 1) { + if (horizontalScreen) { + return 'height:' + shortSideValue + 'rpx;width:' + singleSize + 'rpx;' + } else { + return 'width:' + shortSideValue + 'rpx;height:' + singleSize + 'rpx;' + } + } else { + return 'height:' + multipleSize + 'rpx;width:' + multipleSize + 'rpx;' + } +} + +var gridStyle = function (gapRow, gapColumn, multipleSize, everyRowNumber) { + return 'display:inline-grid;grid-template-columns: repeat(' + everyRowNumber + ',' + multipleSize + 'rpx);grid-row-gap:' + gapRow + 'rpx;grid-column-gap:' + gapColumn + 'rpx;' +} + +var dimBack = function (isLong, index, maxNumber, previewFullImage) { + if (previewFullImage) { + if (isLong) { + if (index == maxNumber - 1) { + return 'dimback' + } + } + } + return '' +} + +var dim = function (isLong, index, maxNumber, previewFullImage) { + if (previewFullImage) { + if (isLong) { + if (index == maxNumber - 1) { + return 'dim' + } + } + } + return '' +} + +var image = function (isLong, index, maxNumber, previewFullImage) { + if (previewFullImage) { + if (isLong) { + if (index == maxNumber - 1) { + return true + } + } + } + return false +} + +module.exports = { + containerStyle: containerStyle, + blockClass: blockClass, + blockStyle: blockStyle, + gridStyle: gridStyle, + dimBack: dimBack, + dim: dim, + image: image, +} diff --git a/dist/album/index.wxss b/dist/album/index.wxss new file mode 100644 index 00000000..73f94e0d --- /dev/null +++ b/dist/album/index.wxss @@ -0,0 +1 @@ +.container{display:grid}.vertical{height:360rpx}.parent{display:inline-grid;grid-template-columns:repeat(auto-fill)}.child{box-sizing:border-box;background-color:#fff;flex:0 0 44%;height:100px;border:1px solid red;margin-top:4%;margin-left:2%;margin-right:2%}.dimback{background:#000}.dim{opacity:.6}.imageContainer{position:relative}.imageContainer:last-child>.text{color:#fff;font-weight:700;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:larger} \ No newline at end of file diff --git a/dist/arc-popup/index.js b/dist/arc-popup/index.js new file mode 100644 index 00000000..86ad0520 --- /dev/null +++ b/dist/arc-popup/index.js @@ -0,0 +1 @@ +import validator from"../behaviors/validator";import zIndex from"../behaviors/zIndex";const detail=!0,option={bubbles:!0,composed:!0};Component({behaviors:[zIndex,validator],externalClasses:["l-class","l-panel-class","l-bg-class","l-header-class"],options:{multipleSlots:!0},properties:{show:{type:Boolean,value:!1},maxHeight:{type:Number,value:600},minHeight:{type:Number,value:200},arcRadius:{type:Number,value:18},transition:{type:Boolean,value:!0},locked:{type:Boolean,value:!1},opacity:{type:Number,value:.4},direction:{type:String,options:["top","bottom"],value:"bottom"},headerFixed:{type:Boolean,value:!0}},data:{_arcRadiusTop:12,_ardRadiusBottom:18,arcStyle:""},observers:{show:function(t){t?(this.triggerEvent("linshow",!0,option),this.getArcPopupStyle()):this.triggerEvent("linclose",!0,option)},arcRadius:function(t){"top"===this.properties.direction?this.data._arcRadiusTop=t:this.data._ardRadiusBottom=t,this.getArcPopupStyle()}},pageLifetimes:{show(){this._init()}},methods:{_init(){wx.lin=wx.lin||{},wx.lin.showArcPopup=t=>{const{zIndex:o=99,tranistion:e=!0,direction:i="bottom",locked:a=!1}={...t};this.setData({zIndex:o,tranistion:e,direction:i,locked:a,show:!0})},wx.lin.hideArcPopup=()=>{this.setData({show:!1})}},getArcPopupStyle(){const t=this.properties.direction,o=this.data._arcRadiusTop,e=this.data._ardRadiusBottom,i=`\n border-bottom-left-radius:${"top"===t?o:0}rpx;\n border-bottom-right-radius:${"top"===t?o:0}rpx;\n border-top-left-radius:${"bottom"===t?e:0}rpx;\n border-top-right-radius:${"bottom"===t?e:0}rpx;\n max-height:${this.properties.maxHeight}rpx;\n min-height:${this.properties.minHeight}rpx;\n `;this.setData({arcStyle:i})},onArcPopupTap(){this.data.locked||this.properties.show&&this.setData({show:!1})}},ready(){this.getArcPopupStyle()}}); \ No newline at end of file diff --git a/dist/arc-popup/index.json b/dist/arc-popup/index.json new file mode 100644 index 00000000..11a6eb11 --- /dev/null +++ b/dist/arc-popup/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{"l-popup":"../popup/index"}} \ No newline at end of file diff --git a/dist/arc-popup/index.wxml b/dist/arc-popup/index.wxml new file mode 100644 index 00000000..6fe07631 --- /dev/null +++ b/dist/arc-popup/index.wxml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/dist/arc-popup/index.wxss b/dist/arc-popup/index.wxss new file mode 100644 index 00000000..e30086a0 --- /dev/null +++ b/dist/arc-popup/index.wxss @@ -0,0 +1 @@ +.container-arc-popup{width:100%}.arc-popup{overflow:hidden;width:100%;background:#fff}.content-arc-popup{padding:30rpx;box-sizing:border-box}.header-popup{width:100%;z-index:999}.header-popup.fixed{position:sticky;top:0;background-color:#fff} \ No newline at end of file diff --git a/dist/avatar/index.js b/dist/avatar/index.js new file mode 100644 index 00000000..afe8b943 --- /dev/null +++ b/dist/avatar/index.js @@ -0,0 +1 @@ +Component({externalClasses:["l-class","l-class-text","l-text-class"],properties:{icon:String,iconColor:{type:String,value:"#3963BC"},iconSize:{type:String,value:"28"},text:String,src:String,openData:{type:Array,observer:"_initOpenData"},shape:{type:String,value:"circle"},mode:{type:String,value:"scaleToFill"},size:{type:Number,value:120},placement:{type:String,value:"right"}},data:{_isHaveUserNickName:!1,_isHaveUserAvatarUrl:!1,_iconSize:"",_iconColor:"#ffffff"},methods:{_initOpenData:function(e){this._isHaveUserAvatarUrl(e),this._isHaveUserNickName(e)},_isHaveUserAvatarUrl:function(e){this.setData({_isHaveUserAvatarUrl:-1!==e.indexOf("userAvatarUrl")})},_isHaveUserNickName:function(e){this.setData({_isHaveUserNickName:-1!==e.indexOf("userNickName")})},tapAvatar:function(e){this.triggerEvent("lintap",e,{bubbles:!0,composed:!0})}}}); \ No newline at end of file diff --git a/dist/avatar/index.json b/dist/avatar/index.json new file mode 100644 index 00000000..a1fa4d66 --- /dev/null +++ b/dist/avatar/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{"l-icon":"../icon/index"} } \ No newline at end of file diff --git a/dist/avatar/index.wxml b/dist/avatar/index.wxml new file mode 100644 index 00000000..e6bd29d4 --- /dev/null +++ b/dist/avatar/index.wxml @@ -0,0 +1,12 @@ + + + + + + + + + + {{text}} + + diff --git a/dist/avatar/index.wxss b/dist/avatar/index.wxss new file mode 100644 index 00000000..3458284b --- /dev/null +++ b/dist/avatar/index.wxss @@ -0,0 +1 @@ +.l-avatar{display:inline-flex;justify-content:center;align-items:center}.l-avatar-image{flex:1;display:inline-flex;justify-content:center;align-items:center;background:#ccc;overflow:hidden}.l-avatar-text{display:inline-block;height:max-content;width:max-content;font-size:28rpx;color:#45526b;line-height:40px}.open-data{width:100%;height:100%}.l-avatar-text .l-avatar-text-text,.l-avatar-text .open-data{font-size:inherit;color:inherit;line-height:inherit}.l-square{border-radius:8rpx}.l-circle{border-radius:50%}.l-placement-left,.l-placement-right{align-items:center;justify-content:center}.l-placement-left{margin-right:24rpx;flex-direction:row-reverse}.l-placement-left .l-avatar-text{margin-right:24rpx}.l-placement-right{flex-direction:row}.l-placement-right .l-avatar-text{margin-left:24rpx}.l-placement-top{flex-direction:column-reverse}.l-placement-top .l-avatar-text{margin-bottom:12rpx}.l-placement-bottom{flex-direction:column}.l-placement-bottom .l-avatar-text{margin-top:12rpx} \ No newline at end of file diff --git a/dist/badge/index.js b/dist/badge/index.js new file mode 100644 index 00000000..37964a96 --- /dev/null +++ b/dist/badge/index.js @@ -0,0 +1 @@ +import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-class-self","l-self-class"],behaviors:[validator],properties:{dot:{type:Boolean,value:!1},shape:{type:String,value:"horn",options:["horn","circle"]},value:{type:String,value:"0"},mode:{type:String,value:"number",options:["number","text"]},maxCount:{type:Number,value:99},numberType:{type:String,value:"overflow",options:["overflow","limit","ellipsis"]},show:{type:Boolean,value:!0}},data:{finalCount:0},observers:{value:function(){this.finalCount()}},methods:{finalCount(){isNaN(Number(this.data.value))||"text"===this.data.mode?this.setData({finalCount:this.data.value}):this.switchType()},switchType(){switch(this.data.numberType){case"overflow":this.setData({finalCount:Number(this.data.value)>Number(this.data.maxCount)?this.data.maxCount+"+":this.data.value});break;case"ellipsis":this.setData({finalCount:Number(this.data.value)>Number(this.data.maxCount)?"...":this.data.value});break;case"limit":this.setData({finalCount:Number(this.data.value)>999?Number(this.data.value)>=9999?Math.floor(this.data.value/1e4*100)/100+"w":Math.floor(this.data.value/1e3*100)/100+"k":this.data.value});break;default:this.setData({finalCount:Number(this.data.value)})}},handleTap(){this.triggerEvent("lintap",{},{bubbles:!0,composed:!0})}}}); \ No newline at end of file diff --git a/dist/badge/index.json b/dist/badge/index.json new file mode 100644 index 00000000..1450e2ec --- /dev/null +++ b/dist/badge/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{}} \ No newline at end of file diff --git a/dist/badge/index.wxml b/dist/badge/index.wxml new file mode 100644 index 00000000..1e687872 --- /dev/null +++ b/dist/badge/index.wxml @@ -0,0 +1,7 @@ + + + + + {{finalCount}} + + diff --git a/dist/badge/index.wxss b/dist/badge/index.wxss new file mode 100644 index 00000000..5d1021d6 --- /dev/null +++ b/dist/badge/index.wxss @@ -0,0 +1 @@ +.l-badge{position:relative;display:inline-block;line-height:1;vertical-align:middle}.l-badge-content{max-width:650rpx;left:70%;background-color:#ff474b;color:#fff;position:absolute;font-size:20rpx;display:inline-block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:center;box-sizing:border-box;z-index:10;letter-spacing:.5rpx}.l-badge-content-horn{height:28rpx;min-width:54rpx;padding:0 8rpx;border-radius:14rpx 14rpx 14rpx 0rpx;line-height:28rpx;top:-10rpx}.l-badge-content-circle{height:32rpx;min-width:32rpx;padding:0 10rpx;border-radius:16rpx;line-height:32rpx;top:-10rpx}.l-badge-dot{height:16rpx;width:16rpx;transform:translateX(50%);border-radius:50%;background-color:#ff474b;position:absolute;top:-4rpx;right:0rpx} \ No newline at end of file diff --git a/dist/button/index.js b/dist/button/index.js new file mode 100644 index 00000000..ec788348 --- /dev/null +++ b/dist/button/index.js @@ -0,0 +1 @@ +import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-label-class","l-hover-class","l-img-class","l-icon-class"],behaviors:[validator],properties:{name:{type:String,value:"lin"},type:{type:String,value:"default",options:["warning","success","error","default"]},plain:Boolean,size:{type:String,value:"medium",options:["medium","large","mini","long"]},shape:{type:String,value:"circle",options:["square","circle","semicircle"]},disabled:{type:Boolean,value:!1},special:{type:Boolean,value:!1},loading:{type:Boolean,value:!1},width:Number,height:Number,icon:String,image:String,bgColor:String,iconColor:String,iconSize:String,openType:String,appParameter:String,lang:String,hoverStopPropagation:Boolean,hoverStartTime:{type:Number,value:20},hoverStayTime:{type:Number,value:70},sessionFrom:{type:String,value:""},sendMessageTitle:String,sendMessagePath:String,sendMessageImg:String,showMessageCard:Boolean,formType:String,disabledHover:{type:Boolean,value:!1}},methods:{handleTap(){if(this.data.disabled||this.data.loading)return!1;this.triggerEvent("lintap",{},{bubbles:!0,composed:!0})},openTypeEvent(e){this.triggerEvent(e.type,e.detail,{})}}}); \ No newline at end of file diff --git a/dist/button/index.json b/dist/button/index.json new file mode 100644 index 00000000..e11651a3 --- /dev/null +++ b/dist/button/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{"l-icon":"../icon/index"}} \ No newline at end of file diff --git a/dist/button/index.wxml b/dist/button/index.wxml new file mode 100644 index 00000000..27c9b93c --- /dev/null +++ b/dist/button/index.wxml @@ -0,0 +1,16 @@ + + diff --git a/dist/button/index.wxss b/dist/button/index.wxss new file mode 100644 index 00000000..21cfe7df --- /dev/null +++ b/dist/button/index.wxss @@ -0,0 +1 @@ +.btn-hover::before{opacity:.15;position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;transform:translate(-50%,-50%);content:' ';background-color:#333;border-color:#333}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}.margin-long{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/dist/calendar/calendar.wxml b/dist/calendar/calendar.wxml new file mode 100644 index 00000000..2761e9c5 --- /dev/null +++ b/dist/calendar/calendar.wxml @@ -0,0 +1,14 @@ + + + diff --git a/dist/calendar/components/day/index.js b/dist/calendar/components/day/index.js new file mode 100644 index 00000000..18c33594 --- /dev/null +++ b/dist/calendar/components/day/index.js @@ -0,0 +1 @@ +Component({data:{},properties:{text:null,topInfo:null,bottomInfo:null,type:null,color:{type:String,value:""}},methods:{}}); \ No newline at end of file diff --git a/dist/calendar/components/day/index.json b/dist/calendar/components/day/index.json new file mode 100644 index 00000000..a8456c1f --- /dev/null +++ b/dist/calendar/components/day/index.json @@ -0,0 +1 @@ +{"component":true} \ No newline at end of file diff --git a/dist/calendar/components/day/index.wxml b/dist/calendar/components/day/index.wxml new file mode 100644 index 00000000..938a0745 --- /dev/null +++ b/dist/calendar/components/day/index.wxml @@ -0,0 +1,6 @@ + + + {{ topInfo }} + {{ text }} + {{ bottomInfo }} + \ No newline at end of file diff --git a/dist/calendar/components/day/index.wxs b/dist/calendar/components/day/index.wxs new file mode 100644 index 00000000..b81bd182 --- /dev/null +++ b/dist/calendar/components/day/index.wxs @@ -0,0 +1,27 @@ +function getDayStyle(type, color) { + var style = []; + + if (color) { + if ( + type === 'start' || + type === 'end' || + type === 'selected' + ) { + style.push(['background', color]); + } else if (type === 'middle') { + style.push(['color', color]); + // style.push(['background', color]); + // style.push(['opacity', '0.1']); + } + } + + return style + .map(function(item) { + return item.join(':'); + }) + .join(';'); +} + +module.exports = { + getDayStyle: getDayStyle, +}; \ No newline at end of file diff --git a/dist/calendar/components/day/index.wxss b/dist/calendar/components/day/index.wxss new file mode 100644 index 00000000..e9a84857 --- /dev/null +++ b/dist/calendar/components/day/index.wxss @@ -0,0 +1 @@ +.calendar-day-container{display:flex;flex-direction:column;height:100%;align-items:center;position:relative;color:#666}.calendar-day-container.selected{background-color:#3963bc;color:#fff;border-radius:8rpx}.calendar-day-container.start{background-color:#3963bc;color:#fff;border-radius:8rpx}.calendar-day-container.end{background-color:#3963bc;color:#fff;border-radius:8rpx}.calendar-day-container.disabled{color:#c8c9cc;cursor:default;background:#fff}.calendar-day-container.middle{color:#3963bc}.calendar-day-container.middle::after{position:absolute;top:0;right:0;bottom:0;left:0;background-color:currentColor;opacity:.1;content:''}.calendar-day-container .top{height:24rpx;line-height:24rpx;font-size:16rpx}.calendar-day-container .text{flex:1;font-size:32rpx}.calendar-day-container .bottom{height:24rpx;line-height:24rpx;font-size:16rpx} \ No newline at end of file diff --git a/dist/calendar/components/header/index.js b/dist/calendar/components/header/index.js new file mode 100644 index 00000000..a734e34b --- /dev/null +++ b/dist/calendar/components/header/index.js @@ -0,0 +1 @@ +Component({data:{weekdays:["日","一","二","三","四","五","六"]},properties:{title:{type:String,value:"日期选择"},subTitle:String,showTitle:Boolean,showSubtitle:Boolean},methods:{}}); \ No newline at end of file diff --git a/dist/calendar/components/header/index.json b/dist/calendar/components/header/index.json new file mode 100644 index 00000000..a8456c1f --- /dev/null +++ b/dist/calendar/components/header/index.json @@ -0,0 +1 @@ +{"component":true} \ No newline at end of file diff --git a/dist/calendar/components/header/index.wxml b/dist/calendar/components/header/index.wxml new file mode 100644 index 00000000..e6872612 --- /dev/null +++ b/dist/calendar/components/header/index.wxml @@ -0,0 +1,18 @@ + + + + + {{ title }} + + + + + {{ subTitle }} + + + + + {{ item }} + + + \ No newline at end of file diff --git a/dist/calendar/components/header/index.wxss b/dist/calendar/components/header/index.wxss new file mode 100644 index 00000000..b9566429 --- /dev/null +++ b/dist/calendar/components/header/index.wxss @@ -0,0 +1 @@ +.calendar-header-container .calendar-header-container_title{text-align:center;padding:20rpx 0;font-size:36rpx;line-height:44rpx}.calendar-header-container .calendar-header-container_subtitle{text-align:center;font-size:36rpx;line-height:44rpx;margin-bottom:30rpx}.calendar-header-container .calendar-header__weekdays{display:flex;justify-content:center;align-items:center;margin:0 20rpx;padding:10rpx 0;border-bottom:1rpx solid #f3f3f3}.calendar-header-container .calendar-header__weekdays .calendar-header__weekday{width:14.285%;text-align:center} \ No newline at end of file diff --git a/dist/calendar/components/mounth/index.js b/dist/calendar/components/mounth/index.js new file mode 100644 index 00000000..6515d797 --- /dev/null +++ b/dist/calendar/components/mounth/index.js @@ -0,0 +1 @@ +import{compareDay,getMonthEndDay}from"../../util";import*as config from"../../config";Component({data:{days:[]},properties:{minDate:{type:[Date,String,null]},maxDate:{type:[Date,String,null]},formatter:{type:null,observer:"setDays"},date:{type:null,observer:"setDays"},currentDate:{type:[null,Array],observer(){this.setDays()}},type:{type:String,observer:"setDays"},showMonthTitle:Boolean,color:{type:String,value:""}},methods:{onClick(t){const{item:e}=t.currentTarget.dataset;"disabled"!==e.type&&"empty"!==e.type&&this.triggerEvent("clickDay",e)},debounce(t){let e;return()=>{let a=this,r=arguments;e&&clearTimeout(e),e=setTimeout((function(){t.apply(a,r)}),300)}},setDays(){this.debounce(this.setDay)()},setDay(){let t=[];const e=new Date(this.data.date),a=e.getFullYear(),r=e.getMonth(),n=new Date(a,r,1).getDay(),o=getMonthEndDay(a,r+1);for(let e=1;e<=o;e++){const n=new Date(a,r,e).getTime(),o=this.getDayType(n);let s={date:n,type:o,text:e,bottomInfo:this.getBottomInfo(o),topInfo:""};this.data.formatter&&(s=this.data.formatter(s)),t.push(s)}for(let e=0;e0===compareDay(e,t))},getMultipleDayType(t){const{currentDate:e}=this.data;return Array.isArray(e)&&this.isDateInCurrent(t)?"selected":""},getRangeDayType(t){const{currentDate:e}=this.data;if(!Array.isArray(e))return;const[a,r]=e;if(!a)return;const n=compareDay(t,a);if(!r)return 0===n?"start":"";const o=compareDay(t,r);return 0===n?"start":0===o?"end":n>0&&o<0?"middle":void 0},getDayType(t){const{type:e,minDate:a,maxDate:r,currentDate:n}=this.data;return compareDay(t,a)<0||compareDay(t,r)>0?"disabled":e===config.TYPE_SINGLE?0===compareDay(t,n)?"selected":"":e===config.TYPE_MULTIPLE?this.getMultipleDayType(t):e===config.TYPE_RANGE?this.getRangeDayType(t):void 0},getBottomInfo(t){return this.data.type===config.TYPE_RANGE?"start"===t?"开始":"end"===t?"结束":"":""}}}); \ No newline at end of file diff --git a/dist/calendar/components/mounth/index.json b/dist/calendar/components/mounth/index.json new file mode 100644 index 00000000..e6f3689c --- /dev/null +++ b/dist/calendar/components/mounth/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{"day":"../day/index"}} \ No newline at end of file diff --git a/dist/calendar/components/mounth/index.wxml b/dist/calendar/components/mounth/index.wxml new file mode 100644 index 00000000..63d289fb --- /dev/null +++ b/dist/calendar/components/mounth/index.wxml @@ -0,0 +1,12 @@ + + + + + {{ computed.formatMonthTitle(date) }} + + + + + + + \ No newline at end of file diff --git a/dist/calendar/components/mounth/index.wxs b/dist/calendar/components/mounth/index.wxs new file mode 100644 index 00000000..3e860b4e --- /dev/null +++ b/dist/calendar/components/mounth/index.wxs @@ -0,0 +1,12 @@ +/* eslint-disable */ + +function formatMonthTitle(date) { + date = getDate(date); + return date.getFullYear() + '年' + (date.getMonth() + 1) + '月'; +} + + + +module.exports = { + formatMonthTitle: formatMonthTitle +}; diff --git a/dist/calendar/components/mounth/index.wxss b/dist/calendar/components/mounth/index.wxss new file mode 100644 index 00000000..3259ccb7 --- /dev/null +++ b/dist/calendar/components/mounth/index.wxss @@ -0,0 +1 @@ +.calendar-mounth-container{color:#333;display:flex;flex-direction:column}.calendar-mounth-container .title{text-align:center;font-weight:800}.calendar-mounth-container .calendar-day-container{display:flex;flex-wrap:wrap}.calendar-mounth-container .calendar-day-container .calendar-day-wrap{width:14.285%} \ No newline at end of file diff --git a/dist/calendar/config.js b/dist/calendar/config.js new file mode 100644 index 00000000..8f6a692f --- /dev/null +++ b/dist/calendar/config.js @@ -0,0 +1 @@ +export const TYPE_SINGLE="single";export const TYPE_RANGE="range";export const TYPE_MULTIPLE="multiple"; \ No newline at end of file diff --git a/dist/calendar/dete.js b/dist/calendar/dete.js new file mode 100644 index 00000000..b0e5253f --- /dev/null +++ b/dist/calendar/dete.js @@ -0,0 +1 @@ +const formatFlags={format:function(t,a){let e;const r={"y+":(a=new Date(a)).getFullYear().toString(),"M+":(a.getMonth()+1).toString(),"d+":a.getDate().toString()};for(let a in r)e=new RegExp("("+a+")").exec(t),e&&(t=t.replace(e[1],1===e[1].length?r[a]:r[a].padStart(e[1].length,"0")));return t}};formatFlags.format("yyyy/MM/dd",new Date),formatFlags.format("yyyy-MM-dd",new Date),formatFlags.format("yyyy-M-dd",new Date),formatFlags.format("yyyy-M-d",new Date),formatFlags.format("M-dd",new Date),formatFlags.format("MM-dd",new Date);export default formatFlags; \ No newline at end of file diff --git a/dist/calendar/index.js b/dist/calendar/index.js new file mode 100644 index 00000000..75549da5 --- /dev/null +++ b/dist/calendar/index.js @@ -0,0 +1 @@ +import eventBus from"../core/utils/event-bus.js";import validator from"../behaviors/validator";import rules from"../behaviors/rules";import*as config from"./config";import formatFlags from"./dete";import{getDayByOffset,getDate,compareDay,calcDateNum,copyDates,getTime,formatMonthTitle,compareMonth,getMonths}from"./util";Component({externalClasses:["l-class"],behaviors:["wx://form-field",validator,rules],properties:{show:{type:Boolean,value:!1,observer(t){t&&(this.initRect(),this.scrollIntoView())}},type:{type:String,value:config.TYPE_SINGLE,options:[config.TYPE_SINGLE,config.TYPE_MULTIPLE,config.TYPE_RANGE],observer(){this.setData({currentDate:this.initCurrentDate()})}},color:{type:String,value:""},defaultDate:{type:[String,Number,Date,Array],value:"",observer(){this.setData({currentDate:this.initCurrentDate()})}},format:{type:String,value:"timestamp"},formatter:{type:[Function,null],value:null},minDate:{type:[String,Number,null],value:Date.now()},maxDate:{type:[String,Number,null],value:new Date((new Date).getFullYear(),(new Date).getMonth()+6,(new Date).getDate()).getTime()},minSelect:{type:[Number,null],value:null},maxSelect:{type:[Number,null],value:null},allowSameDay:Boolean,showConfirm:{type:Boolean,value:!0},confirmText:{type:String,value:"确认"},maxLimitMessage:{type:String},minLimitMessage:{type:String},showTitle:{type:Boolean,value:!0},showSubtitle:{type:Boolean,value:!0},title:{type:String,value:"日期选择"}},lifetimes:{attached(){this.setData({currentDate:this.initCurrentDate()})},ready(){this.data.show&&(this.initRect(),this.scrollIntoView())}},data:{currentDate:null,types:config,subTitle:"",scrollIntoViewIndex:""},methods:{clickDay(t){const{type:e,currentDate:a,maxLimitMessage:i,maxSelect:r,allowSameDay:n}=this.data,{date:s}=t.detail;if(e===config.TYPE_SINGLE&&(this.setData({currentDate:getTime(s)}),this.triggerEvent("linclickday",copyDates(s)),this.triggerEvent("linselect",copyDates(s))),e===config.TYPE_MULTIPLE){let t=null;if(a.some((e,a)=>{const i=0===compareDay(e,s);return i&&(t=a),i}))a.splice(t,1),this.setData({currentDate:getTime(a)}),this.triggerEvent("linunselect",copyDates(a));else{if(r&&a.length>=r)return wx.lin.showToast({title:i||`选择天数不能超过 ${r} 天`}),void this.triggerEvent("linclickday",copyDates(s));this.setData({currentDate:getTime([...a,s])}),this.triggerEvent("linselect",copyDates([...a,s]))}this.triggerEvent("linclickday",copyDates(s))}if(e===config.TYPE_RANGE){const[t,e]=a;if(t&&!e){const e=compareDay(s,t);1===e?this.checkSelectRange([t,s])&&(this.setData({currentDate:getTime([t,s])}),this.triggerEvent("linselect",copyDates([t,s]))):-1===e?this.setData({currentDate:getTime([s,null])}):n&&this.setData({currentDate:getTime([s,s])})}else this.setData({currentDate:getTime([s,null])})}},checkSelectRange(t){const{maxSelect:e,maxLimitMessage:a,minSelect:i,minLimitMessage:r}=this.data;return e&&calcDateNum(t)>e?(wx.lin.showToast({title:a||`选择天数不能超过 ${e} 天`}),!1):!(i&&calcDateNum(t)1===compareDay(t,e)&&-1===compareDay(t,i)):-1===compareDay(a,e)?[e]:1===compareDay(a,i)?[i]:[e]:[];if(t===config.TYPE_RANGE){if(r){let[t=e,r]=a;return-1!==compareDay(t,e)&&-1===compareDay(t,i)||(t=e),r||(r=getDayByOffset(getDate(t),1).getTime()),1!==compareDay(r,i)&&-1!==compareDay(r,e)||(r=getDayByOffset(getDate(t),1).getTime()),[t,r]}return[e,getDayByOffset(getDate(e),1).getTime()]}},initRect(){null!==!this.contentObserver&&void 0!==this.contentObserver&&this.contentObserver.disconnect();const t=this.createIntersectionObserver({thresholds:[0,.1,.9,1],observeAll:!0});this.contentObserver=t,t.relativeTo(".calendar-body-wrap"),t.observe(".month",t=>{t.boundingClientRect.top<=t.relativeRect.top&&this.setData({subTitle:formatMonthTitle(t.dataset.date)})})},scrollIntoView(){setTimeout(()=>{const{currentDate:t,type:e,show:a,minDate:i,maxDate:r}=this.data,n="single"===e?t:t[0];if(!n||!a)return;getMonths(i,r).some((t,e)=>0===compareMonth(t,n)&&(this.setData({scrollIntoViewIndex:"month"+e}),!0))},100)},closePicker(){this.setData({show:!1})},onClickConfirm(){const{format:t,type:e,currentDate:a}=this.data;eventBus.emit("lin-form-blur-"+this.id,this.id);let i=null;i="single"===e?"timestamp"!==t?formatFlags.format("yyyy-MM-dd",a):a:a.map(e=>"timestamp"!==t?formatFlags.format("yyyy-MM-dd",e):e),this.triggerEvent("linconfirm",i)},getValues(){return this.data.currentDate},reset(){this.setData({currentDate:null})}}}); \ No newline at end of file diff --git a/dist/calendar/index.json b/dist/calendar/index.json new file mode 100644 index 00000000..46d8ab41 --- /dev/null +++ b/dist/calendar/index.json @@ -0,0 +1 @@ +{"component":true,"usingComponents":{"header":"./components/header/index","mounth":"./components/mounth/index","l-toast":"/dist/toast/index","l-popup":"/dist/popup/index","l-button":"/dist/button/index"}} \ No newline at end of file diff --git a/dist/calendar/index.wxml b/dist/calendar/index.wxml new file mode 100644 index 00000000..8873281b --- /dev/null +++ b/dist/calendar/index.wxml @@ -0,0 +1,7 @@ + + + +