mobile-more
Version:
基于 antd-mobile v5 扩展移动端 UI 组件
55 lines (52 loc) • 2.32 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["value", "split", "gap", "wrapperStyle", "wrapperClassName", "type", "className", "spaceProps"];
import React from 'react';
import { castArray, toString } from 'ut2';
import classNames from 'classnames';
import { Space } from 'antd-mobile';
import BaseDictionary from "./BaseDictionary";
import { prefixClass } from "../../config";
var prefixCls = "".concat(prefixClass, "-dictionary");
var BizDictionary = function BizDictionary(_ref) {
var value = _ref.value,
_ref$split = _ref.split,
split = _ref$split === void 0 ? '、' : _ref$split,
_ref$gap = _ref.gap,
gap = _ref$gap === void 0 ? '0px' : _ref$gap,
wrapperStyle = _ref.wrapperStyle,
wrapperClassName = _ref.wrapperClassName,
_ref$type = _ref.type,
type = _ref$type === void 0 ? 'text' : _ref$type,
className = _ref.className,
spaceProps = _ref.spaceProps,
restProps = _objectWithoutProperties(_ref, _excluded);
var values = castArray(value);
return /*#__PURE__*/React.createElement(Space, _extends({
wrap: true
}, spaceProps, {
style: _objectSpread(_objectSpread({
'--gap': gap
}, wrapperStyle), spaceProps === null || spaceProps === void 0 ? void 0 : spaceProps.style),
className: classNames(prefixCls, "".concat(prefixCls, "-").concat(type), wrapperClassName, spaceProps === null || spaceProps === void 0 ? void 0 : spaceProps.className)
}), values.map(function (item, index) {
return /*#__PURE__*/React.createElement(React.Fragment, {
key: toString(item) + index
}, /*#__PURE__*/React.createElement(BaseDictionary, _extends({
value: item,
type: type,
className: classNames("".concat(prefixCls, "-item"), className)
}, restProps)), index !== values.length - 1 && split && /*#__PURE__*/React.createElement("span", {
className: "".concat(prefixCls, "-split")
}, split));
}));
};
/**
* @deprecated 即将废弃,请使用 `BizDictionary` 替代。
*/
export var Dictionary = BizDictionary;
/**
* @deprecated 即将废弃,请使用 `BizDictionaryProps` 替代。
*/
export default BizDictionary;