UNPKG

@antmjs/vantui

Version:

一套适用于Taro3及React的vantui组件库

48 lines 1.58 kB
import * as array from './array'; import * as object from './object'; function kebabCase(word) { var _word$replace; var newWord = (_word$replace = word.replace(new RegExp('[A-Z]', 'g'), function (i) { return '-' + i; })) === null || _word$replace === void 0 ? void 0 : _word$replace.toLowerCase(); return newWord; } function cssStyle(styles) { if (array.isArray(styles)) { var obj = {}; styles.filter(function (item) { return item != null && item !== ''; }).map(function (item) { Object.assign(obj, cssStyle(item)); }); return obj; } if (toString.call(styles) === '[object String]') { var _obj = {}; styles.split(';').map(function (item) { var _property$, _property$2; var property = item.split(':'); _obj[((_property$ = property[0]) === null || _property$ === void 0 ? void 0 : _property$.trim()) || ''] = (_property$2 = property[1]) === null || _property$2 === void 0 ? void 0 : _property$2.trim(); }); return _obj; } return styles; } function style(styles) { if (array.isArray(styles)) { return styles.filter(function (item) { return item != null && item !== ''; }).map(function (item) { return style(item); }).join(';') || ''; } if (toString.call(styles) === '[object Object]') { return object.keys(styles).filter(function (key) { return styles[key] != null && styles[key] !== ''; }).map(function (key) { return [kebabCase(key), [styles[key]]].join(':'); }).join(';') || ''; } return styles || ''; } export { style, cssStyle };