| | |
| | | * addUnit */ |
| | | // 为 css 添加单位 |
| | | function addUnit(value) { |
| | | // prettier-ignore |
| | | var REGEXP = getRegExp('^-?\d+(.\d+)?$'); |
| | | if (value == null) { |
| | | return undefined; |
| | |
| | | return obj && obj.constructor === 'Object'; |
| | | } |
| | | |
| | | var isNoEmptyObj = function (obj) { |
| | | function isBoolean(value) { |
| | | return typeof value === 'boolean'; |
| | | } |
| | | |
| | | function isNoEmptyObj(obj) { |
| | | return isObject(obj) && JSON.stringify(obj) !== '{}'; |
| | | }; |
| | | } |
| | | |
| | | function includes(arr, value) { |
| | | if (!arr || !isArray(arr)) return false; |
| | |
| | | function cls(base, arr) { |
| | | var res = [base]; |
| | | var i = 0; |
| | | for (size = arr.length; i < size; i++) { |
| | | for (var size = arr.length; i < size; i++) { |
| | | var item = arr[i]; |
| | | |
| | | if (item && item.constructor === 'Array') { |
| | |
| | | return item != null && item !== ''; |
| | | }) |
| | | .map(function (item) { |
| | | return isArray(item) ? style(item) : endsWith(item, ';'); |
| | | return isArray(item) ? _style(item) : endsWith(item, ';'); |
| | | }) |
| | | .join(' '); |
| | | } |
| | |
| | | return styles; |
| | | } |
| | | |
| | | function isValidIconName(str) { |
| | | // prettier-ignore |
| | | return getRegExp('^[A-Za-z0-9\-\_]+$').test(str); |
| | | } |
| | | |
| | | module.exports = { |
| | | addUnit: addUnit, |
| | | isString: isString, |
| | | isArray: isArray, |
| | | isObject: isObject, |
| | | isBoolean: isBoolean, |
| | | isNoEmptyObj: isNoEmptyObj, |
| | | includes: includes, |
| | | cls: cls, |
| | | getBadgeAriaLabel: getBadgeAriaLabel, |
| | | _style: _style, |
| | | isValidIconName: isValidIconName, |
| | | }; |