UNPKG

@antmjs/vantui

Version:

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

74 lines (72 loc) 3.64 kB
"use strict"; var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.lineStyle = lineStyle; exports.navStyle = navStyle; exports.tabClass = tabClass; exports.tabStyle = tabStyle; exports.trackStyle = trackStyle; var _style = require("../wxs/style"); var utils = _interopRequireWildcard(require("../wxs/utils")); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function tabClass(active, ellipsis) { var classes = ['tab-class']; if (active) { classes.push('tab-active-class'); } if (ellipsis) { classes.push('van-ellipsis'); } return classes.join(' '); } function tabStyle(data) { var titleColor = data.active ? data.titleActiveColor : data.titleInactiveColor; var ellipsis = data.scrollable && data.ellipsis; // card theme color if (data.type === 'card') { return (0, _style.style)({ 'border-color': data.color, 'background-color': !data.disabled && data.active ? data.color : null, color: titleColor || (!data.disabled && !data.active ? data.color : null), 'flex-basis': ellipsis ? 88 / data.swipeThreshold + '%' : null }); } return (0, _style.style)({ color: titleColor, 'flex-basis': ellipsis ? 88 / data.swipeThreshold + '%' : null }); } function navStyle(color, type) { return (0, _style.style)({ 'border-color': type === 'card' && color ? color : null }); } function trackStyle(data) { if (!data.animated) { return ''; } return (0, _style.style)({ // left: -100 * data.currentIndex + '%', transform: "translate3d(".concat(-100 * data.currentIndex, "%, 0px, 0px)"), '-webkit-transform': "translate3d(".concat(-100 * data.currentIndex, "%, 0px, 0px)"), 'transition-duration': data.duration + 's', '-webkit-transition-duration': data.duration + 's', transition: data.duration + 's' }); } function lineStyle(data) { return (0, _style.style)({ visibility: data.lineOffsetLeft === 0 ? 'hidden' : 'visible', width: utils.addUnit(data.lineWidth), transform: 'translateX(' + data.lineOffsetLeft + 'px)', '-webkit-transform': 'translateX(' + data.lineOffsetLeft + 'px)', 'background-color': data.color, height: data.lineHeight !== -1 ? utils.addUnit(data.lineHeight) : null, 'border-radius': data.lineHeight !== -1 ? utils.addUnit(data.lineHeight) : null, 'transition-duration': !data.skipTransition ? data.duration + 's' : null, '-webkit-transition-duration': !data.skipTransition ? data.duration + 's' : null }); }