vantui-edit
Version:
一套适用于Taro3及React的vantui组件库
95 lines (90 loc) • 4.49 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["url", "linkType", "size", "center", "required", "border", "isLink", "clickable", "icon", "titleWidth", "titleStyle", "title", "label", "value", "arrowDirection", "onClick", "renderIcon", "renderTitle", "renderLabel", "renderRightIcon", "renderExtra", "children", "style", "className"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
import { useCallback } from 'react';
import { View } from '@tarojs/components';
import * as utils from '../wxs/utils';
import { jumpLink } from '../common/jumpLink';
import { Icon } from '../icon';
import * as computed from './wxs';
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export function Cell(props) {
var url = props.url,
linkType = props.linkType,
size = props.size,
center = props.center,
required = props.required,
_props$border = props.border,
border = _props$border === void 0 ? true : _props$border,
isLink = props.isLink,
clickable = props.clickable,
icon = props.icon,
titleWidth = props.titleWidth,
titleStyle = props.titleStyle,
title = props.title,
label = props.label,
value = props.value,
arrowDirection = props.arrowDirection,
onClick = props.onClick,
renderIcon = props.renderIcon,
renderTitle = props.renderTitle,
renderLabel = props.renderLabel,
renderRightIcon = props.renderRightIcon,
renderExtra = props.renderExtra,
children = props.children,
style = props.style,
className = props.className,
others = _objectWithoutProperties(props, _excluded);
var _click = useCallback(function (event) {
onClick === null || onClick === void 0 ? void 0 : onClick(event);
if (url) jumpLink(url, linkType);
}, [linkType, onClick, url]);
return /*#__PURE__*/_jsxs(View, _objectSpread(_objectSpread({
className: ' ' + utils.bem('cell', [size, {
center: center,
required: required,
borderless: !border,
clickable: isLink || clickable
}]) + " ".concat(className || ''),
hoverClass: "van-cell--hover hover-class",
hoverStayTime: 70,
style: utils.style([style]),
onClick: _click
}, others), {}, {
children: [icon ? /*#__PURE__*/_jsx(Icon, {
name: icon,
className: "van-cell__left-icon-wrap van-cell__left-icon"
}) : renderIcon, /*#__PURE__*/_jsxs(View, {
style: computed.titleStyle({
titleWidth: titleWidth,
titleStyle: titleStyle
}),
className: "van-cell__title title-class",
children: [title || title === 0 ? /*#__PURE__*/_jsx(_Fragment, {
children: title
}) : renderTitle, (label || renderLabel) && /*#__PURE__*/_jsx(View, {
className: "van-cell__label label-class",
children: renderLabel || label && /*#__PURE__*/_jsx(_Fragment, {
children: label
})
})]
}), /*#__PURE__*/_jsx(View, {
className: "van-cell__value value-class",
children: value || value === 0 ? /*#__PURE__*/_jsx(_Fragment, {
children: value
}) : children
}), /*#__PURE__*/_jsx(View, {
children: isLink ? /*#__PURE__*/_jsx(Icon, {
name: arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow',
className: "van-cell__right-icon-wrap right-icon-class van-cell__right-icon"
}) : renderRightIcon
}), /*#__PURE__*/_jsx(View, {
children: renderExtra
})]
}));
}
export default Cell;