mp-colorui
Version:
MP ColorUI 是一款基于 Taro 框架并且联合 Color-UI CSS 库开发的多端 UI 组件库(支持小程序端和H5端)
836 lines (776 loc) • 20 kB
JavaScript
(wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["common"],{
/***/ "./src/components/calendar/index.scss":
/*!********************************************!*\
!*** ./src/components/calendar/index.scss ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ "./src/components/form/context.ts":
/*!****************************************!*\
!*** ./src/components/form/context.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
provider: {},
inject: function inject(key) {
return this.provider[key] || null;
},
focus: ''
};
/***/ }),
/***/ "./src/components/text/index.scss":
/*!****************************************!*\
!*** ./src/components/text/index.scss ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ "./src/constant/color.js":
/*!*******************************!*\
!*** ./src/constant/color.js ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
normalColor: [{
title: 'red',
color: '#e54d42',
fontColor: '#ffffff'
}, {
title: 'orange',
color: '#f37b1d',
fontColor: '#ffffff'
}, {
title: 'yellow',
color: '#fbbd08',
fontColor: '#ffffff'
}, {
title: 'olive',
color: '#8dc63f',
fontColor: '#ffffff'
}, {
title: 'green',
color: '#39b54a',
fontColor: '#ffffff'
}, {
title: 'cyan',
color: '#1cbbb4',
fontColor: '#ffffff'
}, {
title: 'blue',
color: '#0081ff',
fontColor: '#ffffff'
}, {
title: 'purple',
color: '#6739b6',
fontColor: '#ffffff'
}, {
title: 'mauve',
color: '#9c26b0',
fontColor: '#ffffff'
}, {
title: 'pink',
color: '#e03997',
fontColor: '#ffffff'
}, {
title: 'brown',
color: '#a5673f',
fontColor: '#ffffff'
}, {
title: 'grey',
color: '#8799a3',
fontColor: '#ffffff'
}, {
title: 'black',
color: '#333333',
fontColor: '#ffffff'
}, {
title: 'gray',
color: '#aaaaaa',
fontColor: '#ffffff'
}, {
title: 'white',
color: '#ffffff',
fontColor: '#000000'
}],
lightColor: [{
title: 'redLight',
color: '#fadbd9',
fontColor: '#e54d42'
}, {
title: 'orangeLight',
color: '#fde6d2',
fontColor: '#f37b1d'
}, {
title: 'yellowLight',
color: '#fef2ce',
fontColor: '#fbbd08'
}, {
title: 'oliveLight',
color: '#e8f4d9',
fontColor: '#8dc63f'
}, {
title: 'greenLight',
color: '#d7f0db',
fontColor: '#39b54a'
}, {
title: 'cyanLight',
color: '#d2f1f0',
fontColor: '#1cbbb4'
}, {
title: 'blueLight',
color: '#cce6ff',
fontColor: '#0081ff'
}, {
title: 'purpleLight',
color: '#e1d7f0',
fontColor: '#6739b6'
}, {
title: 'mauveLight',
color: '#ebd4ef',
fontColor: '#9c26b0'
}, {
title: 'pinkLight',
color: '#f9d7ea',
fontColor: '#e03997'
}, {
title: 'brownLight',
color: '#ede1d9',
fontColor: '#a5673f'
}, {
title: 'greyLight',
color: '#e7ebed',
fontColor: '#8799a3'
}],
gradualColor: [{
title: 'gradualRed',
color: ['#f43f3b', '#ec008c']
}, {
title: 'gradualOrange',
color: ['#ff9700', '#ed1c24']
}, {
title: 'gradualGreen',
color: ['#39b54a', '#8dc63f']
}, {
title: 'gradualPurple',
color: ['#9000ff', '#5e00ff']
}, {
title: 'gradualPink',
color: ['#ec008c', '#6739b6']
}, {
title: 'gradualBlue',
color: ['#0081ff', '#1cbbb4']
}]
};
/***/ }),
/***/ "./src/constant/menu.js":
/*!******************************!*\
!*** ./src/constant/menu.js ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = [{
key: "base",
name: "基础",
description: "包含颜色、文本、图标等"
}, {
key: "view",
name: "视图",
description: "包含标签、头像、时间轴等"
}, {
key: "action",
name: "操作反馈",
description: "包含模态框、进度条、加载等"
}, {
key: "form",
name: "表单",
description: "包含输入框、单选框、复选框等"
}, {
key: "layout",
name: "布局",
description: "包含列表、卡片、抽屉等"
}, {
key: "navigate",
name: "导航",
description: "包含导航栏、标签栏、标签页等"
}];
var baseList = exports.baseList = [{
key: "color",
name: "Color 颜色"
}, {
key: "icon",
name: "Icon 图标"
}, {
key: "button",
name: "Button 按钮"
}, {
key: "floatButton",
name: "FloatButton 浮动按钮"
}, {
key: "text",
name: "Text 文字"
}];
var actionList = exports.actionList = [{
key: "modal",
name: "Modal 模态框"
}, {
key: "progress",
name: "Progress 进度条"
}, {
key: "loading",
name: "Loading 加载"
}, {
key: "animation",
name: "Animation 动画"
}, {
key: "message",
name: "Message 提示消息"
}, {
key: "tip",
name: "Tip 提示"
}, {
key: "swiperAction",
name: "SwiperAction 滑动操作"
}, {
key: "actionSheet",
name: "ActionSheet 动作面板"
}];
var viewList = exports.viewList = [{
key: "avatar",
name: "Avatar 头像"
}, {
key: "tag",
name: "Tag 标签"
}, {
key: "timeline",
name: "Timeline 时间轴"
}, {
key: "swiper",
name: "Swiper 滑动视图"
}, {
key: "steps",
name: "Steps 步骤条"
}, {
key: "searchBar",
name: "SearchBar 搜索栏"
}, {
key: "shopBar",
name: "ShopBar 购物栏"
}, {
key: "titleBar",
name: "TitleBar 标题栏"
}, {
key: "divider",
name: "Divider 分割线"
}, {
key: "curtain",
name: "Curtain 幕帘"
}, {
key: "noticeBar",
name: "NoticeBar 通告栏"
}, {
key: "calendar",
name: "Calendar 日历"
}];
var formList = exports.formList = [{
key: "form",
name: "Form 表单"
}, {
key: "input",
name: "Input 输入框"
}, {
key: "radio",
name: "Radio 单选按钮"
}, {
key: "checkbox",
name: "Checkbox 多选按钮"
}, {
key: "switch",
name: "Switch 开关"
}, {
key: "select",
name: "Select 选择器"
}, {
key: "imagePicker",
name: "ImagePicker 图片选择器"
}, {
key: "textarea",
name: "Textarea 输入域"
}, {
key: "tree",
name: "Tree 树形结构"
}];
var layoutList = exports.layoutList = [{
key: "layout",
name: "Layout 基本布局"
}, {
key: "flex",
name: "Flex 弹性布局"
}, {
key: "grid",
name: "Grid 栅格布局"
}, {
key: "menuList",
name: "MenuList 菜单列表"
}, {
key: "card",
name: "Card 卡片"
}, {
key: "drawer",
name: "Drawer 抽屉"
}, {
key: "screenDrawer",
name: "ScreenDrawer 全屏抽屉"
}, {
key: "accordion",
name: "Accordion 手风琴"
}];
var navigateList = exports.navigateList = [{
key: "navBar",
name: "NavBar 导航栏"
}, {
key: "tabBar",
name: "TabBar 标签栏"
}, {
key: "tabs",
name: "Tabs 标签页"
}, {
key: "verticalTab",
name: "VerticalTab 垂直导航"
}];
/***/ }),
/***/ "./src/lib/index.ts":
/*!**************************!*\
!*** ./src/lib/index.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ClUtils = exports.idLocalUrl = exports.getRectNumber = exports.isWeApp = exports.isAliPay = exports.isH5 = exports.generateId = exports.screenPercent = exports.throttling = exports.debounce = exports.isNumber = exports.getNowTIme = exports.getNowDate = exports.classNames = undefined;
var _taroWeapp = __webpack_require__(/*! @tarojs/taro-weapp */ "./node_modules/@tarojs/taro-weapp/index.js");
var _taroWeapp2 = _interopRequireDefault(_taroWeapp);
var _classnames = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
var _classnames2 = _interopRequireDefault(_classnames);
var _model = __webpack_require__(/*! ./model */ "./src/lib/model.ts");
var model = _interopRequireWildcard(_model);
var _rules = __webpack_require__(/*! ./rules */ "./src/lib/rules.ts");
var _rules2 = _interopRequireDefault(_rules);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var classNames = exports.classNames = _classnames2.default;
var fullDate = function fullDate(num) {
if (num < 10) return "0" + num;
return num;
};
/**
* 获取当前日期
* @param type 单位
*/
var getNowDate = exports.getNowDate = function getNowDate(type) {
var date = new Date();
var year = date.getFullYear();
var month = fullDate(date.getMonth());
var day = fullDate(date.getDate());
if (type === "year") return "" + year;
if (type === "month") return year + "-" + month;
if (type === "day") return year + "-" + month + "-" + day;
return year + "-" + month + "-" + day;
};
/**
* 获取当前格式化时间 hh:mm
*/
var getNowTIme = exports.getNowTIme = function getNowTIme() {
var date = new Date();
var hour = date.getHours();
var min = date.getMinutes();
return hour + ":" + min;
};
/**
* 判断是否为 number
* @param obj 参数值
*/
var isNumber = exports.isNumber = function isNumber(obj) {
return typeof obj === "number" && !isNaN(obj);
};
/**
* 函数防抖
* @param func 要执行的函数
* @param wait 延迟时间
* @returns func
*/
var debounce = exports.debounce = function debounce(func, wait) {
var timeout = void 0;
return function () {
var context = this;
var args = arguments;
if (timeout) clearTimeout(timeout);
timeout = setTimeout(function () {
func.apply(context, args);
clearTimeout(timeout);
}, wait);
};
};
/**
* 函数节流
* @param func 要执行的函数
* @param wait 延迟时间
* @returns func
*/
var throttling = exports.throttling = function throttling(func, wait) {
var timeout = void 0;
return function () {
var context = this;
var args = arguments;
if (timeout) return;
timeout = setTimeout(function () {
func.apply(context, args);
clearTimeout(timeout);
}, wait);
};
};
/**
* 按照 750 作为设计时的百分比
*/
var screenPercent = exports.screenPercent = _taroWeapp2.default.getSystemInfoSync().screenWidth / 750;
/**
* 随机生成 id
* @param hashLength number 长度
* @returns {string} id
*/
var generateId = exports.generateId = function generateId() {
var hashLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 24;
if (!hashLength || typeof Number(hashLength) != "number") {
return "";
}
var ar = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
var hs = [];
var hl = Number(hashLength);
var al = ar.length;
for (var i = 0; i < hl; i++) {
var radom = Math.random() * al;
var index = Math.floor(radom);
var code = ar[index];
hs.push(code);
}
return "id-" + hs.join("");
};
/**
* 是否是 H5 环境
* @type {boolean}
*/
var isH5 = exports.isH5 = _taroWeapp2.default.ENV_TYPE.WEB === _taroWeapp2.default.getEnv();
/**
* 是否是 支付宝 环境
* @type {boolean}
*/
var isAliPay = exports.isAliPay = _taroWeapp2.default.ENV_TYPE.ALIPAY === _taroWeapp2.default.getEnv();
/**
* 是否是 微信 环境
* @type {boolean}
*/
var isWeApp = exports.isWeApp = _taroWeapp2.default.ENV_TYPE.WEAPP === _taroWeapp2.default.getEnv();
/**
* 获取 Rect
* @returns {number}
*/
var getRectNumber = exports.getRectNumber = function getRectNumber() {
if (isAliPay) return 0;
return 1;
};
/**
* 是否为本地链接
* @param {string} url
* @returns {boolean}
*/
var idLocalUrl = exports.idLocalUrl = function idLocalUrl(url) {
return url.indexOf(".") === 0 || url.indexOf("/") === 0;
};
var ClUtils = exports.ClUtils = {
rule: _rules2.default
};
exports.default = {
model: model,
getNowDate: getNowDate,
rule: _rules2.default
};
/***/ }),
/***/ "./src/lib/model.ts":
/*!**************************!*\
!*** ./src/lib/model.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var SIZE = exports.SIZE = {
xsmall: 'xs',
small: 'sm',
normal: '',
diff: 'df',
large: 'lg',
xlarge: 'xl',
xxlarge: 'xxl',
slarge: 'sl',
xslarge: 'xsl'
};
var COLOR_LIST = ['red', 'orange', 'yellow', 'olive', 'green', 'cyan', 'blue', 'purple', 'mauve', 'pink', 'brown', 'grey', 'gray', 'black', 'white'];
var GRADUAL_COLOR_LIST = ['gradualRed', 'gradualOrange', 'gradualGreen', 'gradualPurple', 'gradualPink', 'gradualBlue'];
var COLOR = exports.COLOR = {};
COLOR_LIST.reduce(function (pre, cur) {
pre[cur] = cur;
return pre;
}, COLOR);
var BG_COLOR_LIST = exports.BG_COLOR_LIST = {};
COLOR_LIST.reduce(function (pre, cur) {
pre[cur] = 'bg-' + cur;
pre['light-' + cur] = 'bg-' + cur + ' light';
return pre;
}, BG_COLOR_LIST);
GRADUAL_COLOR_LIST.reduce(function (pre, cur) {
pre[cur] = 'bg-' + cur.replace(/[A-Z]/g, function (match) {
return '-' + match.toLowerCase();
});
return pre;
}, BG_COLOR_LIST);
var TEXT_COLOR_LIST = exports.TEXT_COLOR_LIST = {};
COLOR_LIST.reduce(function (pre, cur) {
pre[cur] = 'text-' + cur;
return pre;
}, TEXT_COLOR_LIST);
var SHADOW_LIST = exports.SHADOW_LIST = {
normal: 'shadow',
large: 'shadow-lg',
wrap: 'shadow-wrap',
auto: 'shadow-blur'
};
var solids = 'solids';
var solid = 'solid';
var SOLID_LIST = exports.SOLID_LIST = {
none: '',
around: '' + solid,
top: solid + '-top',
left: solid + '-left',
right: solid + '-right',
bottom: solid + '-bottom',
'bold-around': '' + solids,
'bold-top': solids + '-top',
'bold-left': solids + '-left',
'bold-right': solids + '-right',
'bold-bottom': solids + '-bottom'
};
var pxMap = exports.pxMap = {
xsmall: 40,
small: 48,
normal: 56,
large: 64,
xlarge: 72,
xxlarge: 88,
slarge: 160,
xslarge: 240
};
/***/ }),
/***/ "./src/lib/rules.ts":
/*!**************************!*\
!*** ./src/lib/rules.ts ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* 手机号码正则校验
* @param value 需要校验值
* @returns {boolean}
*/
var phone = exports.phone = function phone(value) {
return (/^[1]([3-9])[0-9]{9}$/.test(value)
);
};
/**
* email 地址校验
* @param value 需要校验值
* @returns {boolean}
*/
var email = exports.email = function email(value) {
return (/^([a-zA-Z0-9\u4e00-\u9fa5]+[_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(value)
);
};
/**
* 数值范围校验
* @param min 最小值
* @param max 最大值
* @param value 需要校验值
* @returns {boolean}
*/
var range = exports.range = function range(min, max, value) {
return value >= min && value <= max;
};
/**
* 是否为空
* @param value 需要校验值
* @returns {boolean}
*/
var required = exports.required = function required(value) {
return !!value;
};
/**
* 是否为纯英文
* @param value 需要校验值
* @returns {boolean}
*/
var en = exports.en = function en(value) {
return (/(^[A-Za-z]+$)/.test(value)
);
};
/**
* 是否为纯中文
* @param value 需要校验值
* @returns {boolean}
*/
var cn = exports.cn = function cn(value) {
return (/(^[\u4e00-\u9fa5]{0,}$)/.test(value)
);
};
/**
* 是否为金钱数字
* @param value 需要校验值
* @returns {boolean}
*/
var money = exports.money = function money(value) {
return (/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test("" + value)
);
};
/**
* 是否字母数字组合
* @param value 需要校验值
* @returns {boolean}
*/
var code = exports.code = function code(value) {
return (/(^[A-Za-z0-9]+$)/.test(value)
);
};
/**
* 是否为纯数字
* @param value 需要校验值
* @returns {boolean}
*/
var number = exports.number = function number(value) {
return (/^[0-9]+.?[0-9]*$/.test("" + value)
);
};
/**
* 是否为 ip 地址
* @param value 需要校验值
* @returns {boolean}
*/
var ip = exports.ip = function ip(value) {
return (/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(value)
);
};
/**
* 是否为合法 url
* @param value 需要校验值
* @returns {boolean}
*/
var url = exports.url = function url(value) {
return (/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(value)
);
};
/**
* 是否为合法身份证
* @param value 需要校验值
* @returns {boolean}
*/
var idCard = exports.idCard = function idCard(value) {
var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
var iSum = 0;
if (!/^\d{17}(\d|x)$/i.test(value)) {
return false; //身份证长度或格式错误
}
var idCardValid = value.replace(/x$/i, "a");
if (aCity[parseInt(idCardValid.substr(0, 2))] == null) {
return false; //身份证地区非法;
}
var sBirthday = idCardValid.substr(6, 4) + "-" + Number(idCardValid.substr(10, 2)) + "-" + Number(idCardValid.substr(12, 2));
var d = new Date(sBirthday.replace(/-/g, "/"));
if (sBirthday != d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate()) {
return false; //身份证上的出生日期非法;
}
for (var i = 17; i >= 0; i--) {
iSum += Math.pow(2, i) % 11 * parseInt(idCardValid.charAt(17 - i), 11);
}
if (iSum % 11 != 1) {
return false; //身份证号非法;
}
};
exports.default = {
phone: phone,
email: email,
range: range,
required: required,
en: en,
cn: cn,
money: money,
number: number,
ip: ip,
url: url,
idCard: idCard
};
/***/ }),
/***/ "./src/utils/index.ts":
/*!****************************!*\
!*** ./src/utils/index.ts ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
;
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @description 将驼峰式转化为 -
* @param str
* @returns {*}
*/
var toMidLine = exports.toMidLine = function toMidLine(str) {
return str.replace(/[A-Z]/g, function (match) {
return '-' + match.toLowerCase();
});
};
/**
* @description 浅色
* @param color
* @returns {string}
*/
var convertLightColor = exports.convertLightColor = function convertLightColor(color) {
return toMidLine(color).split('-').reverse().join('-');
};
exports.default = {
toMidLine: toMidLine,
convertLightColor: convertLightColor
};
/***/ })
}]);