UNPKG

@cisdi/form-gbt-select

Version:

administrative division select for ui-engine

44 lines (39 loc) 1.01 kB
import "antd/es/cascader/style"; import _Cascader from "antd/es/cascader"; import _extends from "@babel/runtime/helpers/extends"; import gbt2260 from '@opd/gbt2260'; import React from 'react'; const provinces = gbt2260.provinces(); const options = provinces.map(province => { const { code } = province; const option = province; const prefectures = gbt2260.prefectures(code); const prefectureOptions = prefectures.map(prefecture => { const { code } = prefecture; const option = prefecture; try { const counties = gbt2260.counties(code); if (counties) { option.children = counties; } } catch (error) {// silence } return option; }); option.children = prefectureOptions; return option; }); const GBT2260Select = props => { return /*#__PURE__*/React.createElement(_Cascader, _extends({}, props, { fieldNames: { label: 'name', value: 'code' }, options: options })); }; export default GBT2260Select;