mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[build] 2.4.4
This commit is contained in:
parent
ef1028837d
commit
8a762b3ece
41
dist/actionsheet/index.js
vendored
Normal file
41
dist/actionsheet/index.js
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
const { extractComponentId } = require('../common/helper');
|
||||
|
||||
module.exports = {
|
||||
_handleZanActionsheetMaskClick({ currentTarget = {} }) {
|
||||
const dataset = currentTarget.dataset || {};
|
||||
const { componentId, closeOnClickOverlay } = dataset;
|
||||
|
||||
// 判断是否在点击背景时需要关闭弹层
|
||||
if (!closeOnClickOverlay) {
|
||||
return;
|
||||
}
|
||||
|
||||
resolveCancelClick.call(this, { componentId });
|
||||
},
|
||||
|
||||
_handleZanActionsheetCancelBtnClick(e) {
|
||||
const componentId = extractComponentId(e);
|
||||
|
||||
resolveCancelClick.call(this, { componentId });
|
||||
},
|
||||
|
||||
_handleZanActionsheetBtnClick({ currentTarget = {} }) {
|
||||
const dataset = currentTarget.dataset || {};
|
||||
const { componentId, index } = dataset;
|
||||
|
||||
if (this.handleZanActionsheetClick) {
|
||||
this.handleZanActionsheetClick({ componentId, index });
|
||||
} else {
|
||||
console.warn('页面缺少 handleZanActionsheetClick 回调函数');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function resolveCancelClick({ componentId }) {
|
||||
console.info('[zan:actionsheet:cancel]');
|
||||
if (this.handleZanActionsheetCancel) {
|
||||
this.handleZanActionsheetCancel({ componentId });
|
||||
} else {
|
||||
console.warn('页面缺少 handleZanActionsheetCancel 回调函数');
|
||||
}
|
||||
}
|
40
dist/actionsheet/index.wxml
vendored
Normal file
40
dist/actionsheet/index.wxml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<template name="zan-actionsheet">
|
||||
<view class="zan-actionsheet {{ show ? 'zan-actionsheet--show' : '' }}">
|
||||
<view
|
||||
class="zan-actionsheet__mask"
|
||||
catchtap="_handleZanActionsheetMaskClick"
|
||||
data-close-on-click-overlay="{{ closeOnClickOverlay }}"
|
||||
data-component-id="{{ componentId }}"></view>
|
||||
<view class="zan-actionsheet__container">
|
||||
<!-- 实际按钮显示 -->
|
||||
<button
|
||||
wx:for="{{ actions }}"
|
||||
wx:for-index="index"
|
||||
wx:for-item="item"
|
||||
wx:key="{{ index }}-{{ item.name }}"
|
||||
catchtap="_handleZanActionsheetBtnClick"
|
||||
data-component-id="{{ componentId }}"
|
||||
data-index="{{ index }}"
|
||||
open-type="{{ item.openType }}"
|
||||
class="zan-btn zan-actionsheet__btn {{ item.loading ? 'zan-btn--loading' : '' }} {{ item.className }}"
|
||||
>
|
||||
<text>{{ item.name }}</text>
|
||||
<text
|
||||
wx:if="{{ item.subname }}"
|
||||
class="zan-actionsheet__subname">{{ item.subname }}</text>
|
||||
</button>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<view
|
||||
wx:if="{{ cancelText }}"
|
||||
class="zan-actionsheet__footer"
|
||||
>
|
||||
<button
|
||||
class="zan-btn zan-actionsheet__btn"
|
||||
catchtap="_handleZanActionsheetCancelBtnClick"
|
||||
data-component-id="{{ componentId }}"
|
||||
>{{ cancelText }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
1
dist/actionsheet/index.wxss
vendored
Normal file
1
dist/actionsheet/index.wxss
vendored
Normal file
@ -0,0 +1 @@
|
||||
.zan-actionsheet{background-color:#f8f8f8}.zan-actionsheet__mask{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10;background:rgba(0,0,0,.7);display:none}.zan-actionsheet__container{position:fixed;left:0;right:0;bottom:0;background:#f8f8f8;transform:translate3d(0,50%,0);transform-origin:center;transition:all .2s ease;z-index:11;opacity:0;visibility:hidden}.zan-actionsheet__btn.zan-btn{height:50px;line-height:50px;margin-bottom:0}.zan-actionsheet__btn.zan-btn::after{border-width:0;border-bottom-width:1px}.zan-actionsheet__btn.zan-btn:last-child::after{border-bottom-width:0}.zan-actionsheet__subname{margin-left:2px;font-size:12px;color:#666}.zan-actionsheet__footer{margin-top:10px}.zan-actionsheet__btn.zan-btn--loading .zan-actionsheet__subname{color:transparent}.zan-actionsheet--show .zan-actionsheet__container{opacity:1;transform:translate3d(0,0,0);visibility:visible}.zan-actionsheet--show .zan-actionsheet__mask{display:block}
|
2
dist/badge/index.wxss
vendored
2
dist/badge/index.wxss
vendored
@ -1 +1 @@
|
||||
.zan-badge{position:relative}.zan-badge__count{position:absolute;top:-8px;right:0;height:1.6em;min-width:1.6em;line-height:1.6;padding:0 .4em;font-size:10px;font-family:tahoma;border-radius:.8em;background:#f44;color:#fff;text-align:center;white-space:nowrap;transform:translateX(50%);transform-origin:-10% center;z-index:10;box-shadow:0 0 0 1px #fff;box-sizing:border-box}
|
||||
.zan-badge{position:relative}.zan-badge__count{position:absolute;top:-16px;right:0;height:1.6em;min-width:1.6em;line-height:1.6;padding:0 .4em;font-size:20px;border-radius:.8em;background:#f44;color:#fff;text-align:center;white-space:nowrap;transform:translateX(50%) scale(.5);transform-origin:center;z-index:10;box-shadow:0 0 0 2px #fff;box-sizing:border-box}
|
98
dist/common/helper.js
vendored
98
dist/common/helper.js
vendored
@ -5,56 +5,72 @@ function extractComponentId(event = {}) {
|
||||
return componentId;
|
||||
}
|
||||
|
||||
const LIFE_CYCLE = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll'];
|
||||
/*
|
||||
1. 直接合并所有生命周期函数
|
||||
注:默认合并所有生命周期函数
|
||||
配置合并指定的生命周期 or 忽略指定字段
|
||||
const extend = extendCreator({
|
||||
life: ['onLoad', 'onPullDownRefresh'],
|
||||
exclude: ['binder']
|
||||
});
|
||||
|
||||
Page(extend({}, {
|
||||
onLoad() {},
|
||||
...
|
||||
}));
|
||||
|
||||
2. 只合并指定的生命周期
|
||||
const extendOnload = extend(['onLoad']);
|
||||
Page(extendOnload({}, {
|
||||
onLoad() {},
|
||||
...
|
||||
}));
|
||||
*/
|
||||
const extend = (obj, ...rest) => {
|
||||
if (Array.isArray(obj)) {
|
||||
let lifeCycleList = obj.filter(item => LIFE_CYCLE.indexOf(item) >= 0);
|
||||
return extendWithLife.bind(null, lifeCycleList);
|
||||
}
|
||||
return extendWithLife(LIFE_CYCLE, obj, ...rest);
|
||||
|
||||
const LIFE_CYCLE = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll'];
|
||||
|
||||
const extendCreator = (config = {}) => {
|
||||
const {
|
||||
life = LIFE_CYCLE,
|
||||
exclude = []
|
||||
} = config;
|
||||
|
||||
const excludeList = exclude.concat(LIFE_CYCLE.map(getFuncArrayName));
|
||||
|
||||
if (!Array.isArray(life) || !Array.isArray(exclude)) throw new Error('Invalid Extend Config');
|
||||
let lifeCycleList = life.filter(item => LIFE_CYCLE.indexOf(item) >= 0);
|
||||
return function extend(target, ...objList) {
|
||||
objList.forEach((source) => {
|
||||
if (source) {
|
||||
let keys = Object.keys(source);
|
||||
keys.forEach((key) => {
|
||||
let value = source[key];
|
||||
if (excludeList.indexOf(key) >= 0) return;
|
||||
if (lifeCycleList.indexOf(key) >= 0 && typeof value === 'function') {
|
||||
let funcArrayName = getFuncArrayName(key);
|
||||
if (!target[funcArrayName]) {
|
||||
target[funcArrayName] = [];
|
||||
if (target[key]) {
|
||||
target[funcArrayName].push(target[key]);
|
||||
}
|
||||
target[key] = function (...rest) {
|
||||
target[funcArrayName].forEach(func => func.apply(this, rest));
|
||||
};
|
||||
}
|
||||
|
||||
if (source[funcArrayName]) {
|
||||
// 经过生命周期合并的组件直接整合函数列表
|
||||
target[funcArrayName].push(...source[funcArrayName]);
|
||||
} else {
|
||||
// 添加生命周期函数进入函数列表
|
||||
target[funcArrayName].push(value);
|
||||
}
|
||||
} else {
|
||||
target[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return target;
|
||||
};
|
||||
};
|
||||
|
||||
const extendWithLife = (lifeCycleList, target, ...objList) => {
|
||||
objList.forEach((source) => {
|
||||
if (source) {
|
||||
let keys = Object.keys(source);
|
||||
keys.forEach((key) => {
|
||||
let value = source[key];
|
||||
if (lifeCycleList.indexOf(key) >= 0 && typeof value === 'function') {
|
||||
// 合并生命周期函数,可选择改成闭包函数列表
|
||||
let funcArrayName = `__$${key}`;
|
||||
if (!target[funcArrayName]) {
|
||||
target[funcArrayName] = [value];
|
||||
target[key] = function(...rest) {
|
||||
target[funcArrayName].forEach(func => func.apply(this, rest));
|
||||
};
|
||||
} else {
|
||||
target[funcArrayName].push(value);
|
||||
}
|
||||
} else {
|
||||
target[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return target;
|
||||
};
|
||||
const getFuncArrayName = name => `__$${name}`;
|
||||
|
||||
module.exports = {
|
||||
extractComponentId,
|
||||
extend
|
||||
extend: Object.assign,
|
||||
extendCreator
|
||||
};
|
||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -1,12 +1,16 @@
|
||||
exports.CheckLabel = require('./select/index');
|
||||
exports.Actionsheet = require('./actionsheet/index');
|
||||
exports.Dialog = require('./dialog/index');
|
||||
exports.Field = require('./field/index');
|
||||
exports.NoticeBar = require('./noticebar/index');
|
||||
exports.Select = require('./select/index');
|
||||
exports.Stepper = require('./stepper/index');
|
||||
exports.Switch = require('./switch/index');
|
||||
exports.Tab = require('./tab/index');
|
||||
exports.Toast = require('./toast/index');
|
||||
exports.TopTips = require('./toptips/index');
|
||||
|
||||
// 兼容老版本,在下次大版本发布时会被移除
|
||||
exports.CheckLabel = require('./select/index');
|
||||
|
||||
const { extend } = require('./common/helper');
|
||||
exports.extend = extend;
|
||||
|
2
dist/index.wxss
vendored
2
dist/index.wxss
vendored
File diff suppressed because one or more lines are too long
7
dist/select/index.wxml
vendored
7
dist/select/index.wxml
vendored
@ -1,5 +1,10 @@
|
||||
<template name="zan-select">
|
||||
<radio-group class="zan-select__list" bindchange="_handleZanSelectChange" data-component-id="{{ componentId }}">
|
||||
<radio-group
|
||||
class="zan-select__list"
|
||||
name="{{ name || componentId || '' }}"
|
||||
bindchange="_handleZanSelectChange"
|
||||
data-component-id="{{ componentId }}"
|
||||
>
|
||||
<label wx:for="{{ items }}" wx:key="value">
|
||||
<view class="zan-cell">
|
||||
<radio class="zan-select__radio" value="{{ item.value }}" checked="{{ item.value === checkedValue }}"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user