UNPKG

@cisdi/form-gbt-select

Version:

administrative division select for ui-engine

62 lines (46 loc) 1.39 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("antd/lib/cascader/style"); var _cascader = _interopRequireDefault(require("antd/lib/cascader")); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _gbt = _interopRequireDefault(require("@opd/gbt2260")); var _react = _interopRequireDefault(require("react")); const provinces = _gbt.default.provinces(); const options = provinces.map(province => { const { code } = province; const option = province; const prefectures = _gbt.default.prefectures(code); const prefectureOptions = prefectures.map(prefecture => { const { code } = prefecture; const option = prefecture; try { const counties = _gbt.default.counties(code); if (counties) { option.children = counties; } } catch (error) {// silence } return option; }); option.children = prefectureOptions; return option; }); const GBT2260Select = props => { return /*#__PURE__*/_react.default.createElement(_cascader.default, (0, _extends2.default)({}, props, { fieldNames: { label: 'name', value: 'code' }, options: options })); }; var _default = GBT2260Select; exports.default = _default;