UNPKG

mobile-more

Version:

基于 antd-mobile v5 扩展移动端 UI 组件

35 lines 1.25 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["value", "mapKeys", "options"]; import React from 'react'; import { findTreeSelect } from 'util-helpers'; import SuperCascadePicker from "../ItemCascadePicker/SuperCascadePicker"; import transformKeys from "../utils/transformKeys"; var AreaCodePicker = function AreaCodePicker(_ref) { var value = _ref.value, mapKeys = _ref.mapKeys, outOptions = _ref.options, restProps = _objectWithoutProperties(_ref, _excluded); var options = React.useMemo(function () { var opts = outOptions || []; if (mapKeys) { return transformKeys(opts, mapKeys); } return opts; }, [mapKeys, outOptions]); var realValue = React.useMemo(function () { if (typeof value === 'string') { return findTreeSelect(options, function (item) { return item.value === value; }).map(function (item) { return item.value; }); } return value; }, [options, value]); return /*#__PURE__*/React.createElement(SuperCascadePicker, _extends({ value: realValue, options: options }, restProps)); }; export default AreaCodePicker;