@formily-design/formily-antd 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.umirc.js +44 -0
- package/LICENSE.md +20 -0
- package/README.md +106 -0
- package/copy.ts +6 -0
- package/esm/common/Container/index.d.ts +6 -0
- package/esm/common/Container/index.js +13 -0
- package/esm/common/Container/styles.less +5 -0
- package/esm/common/FormItemSwitcher/index.d.ts +6 -0
- package/esm/common/FormItemSwitcher/index.js +7 -0
- package/esm/common/LoadTemplate/index.d.ts +13 -0
- package/esm/common/LoadTemplate/index.js +8 -0
- package/esm/components/ArrayBase/index.d.ts +1 -0
- package/esm/components/ArrayBase/index.js +71 -0
- package/esm/components/ArrayCards/index.d.ts +1 -0
- package/esm/components/ArrayCards/index.js +1 -0
- package/esm/components/ArrayCards/preview.d.ts +4 -0
- package/esm/components/ArrayCards/preview.js +206 -0
- package/esm/components/ArrayCards/styles.less +2 -0
- package/esm/components/ArrayTable/index.d.ts +1 -0
- package/esm/components/ArrayTable/index.js +1 -0
- package/esm/components/ArrayTable/preview.d.ts +4 -0
- package/esm/components/ArrayTable/preview.js +384 -0
- package/esm/components/ArrayTable/styles.less +2 -0
- package/esm/components/Card/index.d.ts +1 -0
- package/esm/components/Card/index.js +1 -0
- package/esm/components/Card/preview.d.ts +4 -0
- package/esm/components/Card/preview.js +34 -0
- package/esm/components/Cascader/index.d.ts +1 -0
- package/esm/components/Cascader/index.js +1 -0
- package/esm/components/Cascader/preview.d.ts +4 -0
- package/esm/components/Cascader/preview.js +28 -0
- package/esm/components/Checkbox/index.d.ts +1 -0
- package/esm/components/Checkbox/index.js +1 -0
- package/esm/components/Checkbox/preview.d.ts +4 -0
- package/esm/components/Checkbox/preview.js +33 -0
- package/esm/components/DatePicker/index.d.ts +1 -0
- package/esm/components/DatePicker/index.js +1 -0
- package/esm/components/DatePicker/preview.d.ts +4 -0
- package/esm/components/DatePicker/preview.js +50 -0
- package/esm/components/Field/index.d.ts +2 -0
- package/esm/components/Field/index.js +2 -0
- package/esm/components/Field/preview.d.ts +3 -0
- package/esm/components/Field/preview.js +127 -0
- package/esm/components/Field/shared.d.ts +649 -0
- package/esm/components/Field/shared.js +242 -0
- package/esm/components/Form/index.d.ts +1 -0
- package/esm/components/Form/index.js +1 -0
- package/esm/components/Form/preview.d.ts +5 -0
- package/esm/components/Form/preview.js +81 -0
- package/esm/components/Form/styles.less +32 -0
- package/esm/components/FormCollapse/index.d.ts +1 -0
- package/esm/components/FormCollapse/index.js +1 -0
- package/esm/components/FormCollapse/preview.d.ts +6 -0
- package/esm/components/FormCollapse/preview.js +116 -0
- package/esm/components/FormGrid/index.d.ts +1 -0
- package/esm/components/FormGrid/index.js +1 -0
- package/esm/components/FormGrid/preview.d.ts +9 -0
- package/esm/components/FormGrid/preview.js +131 -0
- package/esm/components/FormGrid/styles.less +5 -0
- package/esm/components/FormLayout/index.d.ts +1 -0
- package/esm/components/FormLayout/index.js +1 -0
- package/esm/components/FormLayout/preview.d.ts +4 -0
- package/esm/components/FormLayout/preview.js +29 -0
- package/esm/components/FormTab/index.d.ts +1 -0
- package/esm/components/FormTab/index.js +1 -0
- package/esm/components/FormTab/preview.d.ts +6 -0
- package/esm/components/FormTab/preview.js +123 -0
- package/esm/components/Input/index.d.ts +1 -0
- package/esm/components/Input/index.js +1 -0
- package/esm/components/Input/preview.d.ts +4 -0
- package/esm/components/Input/preview.js +50 -0
- package/esm/components/NumberPicker/index.d.ts +1 -0
- package/esm/components/NumberPicker/index.js +1 -0
- package/esm/components/NumberPicker/preview.d.ts +4 -0
- package/esm/components/NumberPicker/preview.js +29 -0
- package/esm/components/Object/index.d.ts +1 -0
- package/esm/components/Object/index.js +1 -0
- package/esm/components/Object/preview.d.ts +4 -0
- package/esm/components/Object/preview.js +26 -0
- package/esm/components/Password/index.d.ts +1 -0
- package/esm/components/Password/index.js +1 -0
- package/esm/components/Password/preview.d.ts +4 -0
- package/esm/components/Password/preview.js +28 -0
- package/esm/components/Radio/index.d.ts +1 -0
- package/esm/components/Radio/index.js +1 -0
- package/esm/components/Radio/preview.d.ts +4 -0
- package/esm/components/Radio/preview.js +33 -0
- package/esm/components/Rate/index.d.ts +1 -0
- package/esm/components/Rate/index.js +1 -0
- package/esm/components/Rate/preview.d.ts +4 -0
- package/esm/components/Rate/preview.js +29 -0
- package/esm/components/Select/index.d.ts +1 -0
- package/esm/components/Select/index.js +1 -0
- package/esm/components/Select/preview.d.ts +4 -0
- package/esm/components/Select/preview.js +28 -0
- package/esm/components/Slider/index.d.ts +1 -0
- package/esm/components/Slider/index.js +1 -0
- package/esm/components/Slider/preview.d.ts +4 -0
- package/esm/components/Slider/preview.js +29 -0
- package/esm/components/Space/index.d.ts +1 -0
- package/esm/components/Space/index.js +1 -0
- package/esm/components/Space/preview.d.ts +4 -0
- package/esm/components/Space/preview.js +30 -0
- package/esm/components/Switch/index.d.ts +1 -0
- package/esm/components/Switch/index.js +1 -0
- package/esm/components/Switch/preview.d.ts +4 -0
- package/esm/components/Switch/preview.js +29 -0
- package/esm/components/Text/index.d.ts +1 -0
- package/esm/components/Text/index.js +1 -0
- package/esm/components/Text/preview.d.ts +11 -0
- package/esm/components/Text/preview.js +32 -0
- package/esm/components/Text/styles.less +10 -0
- package/esm/components/TimePicker/index.d.ts +1 -0
- package/esm/components/TimePicker/index.js +1 -0
- package/esm/components/TimePicker/preview.d.ts +4 -0
- package/esm/components/TimePicker/preview.js +50 -0
- package/esm/components/Transfer/index.d.ts +1 -0
- package/esm/components/Transfer/index.js +1 -0
- package/esm/components/Transfer/preview.d.ts +4 -0
- package/esm/components/Transfer/preview.js +28 -0
- package/esm/components/TreeSelect/index.d.ts +1 -0
- package/esm/components/TreeSelect/index.js +1 -0
- package/esm/components/TreeSelect/preview.d.ts +4 -0
- package/esm/components/TreeSelect/preview.js +28 -0
- package/esm/components/Upload/index.d.ts +1 -0
- package/esm/components/Upload/index.js +1 -0
- package/esm/components/Upload/preview.d.ts +4 -0
- package/esm/components/Upload/preview.js +56 -0
- package/esm/components/index.d.ts +27 -0
- package/esm/components/index.js +27 -0
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useDropTemplate.d.ts +2 -0
- package/esm/hooks/useDropTemplate.js +20 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/esm/locales/ArrayBase.d.ts +77 -0
- package/esm/locales/ArrayBase.js +91 -0
- package/esm/locales/ArrayCards.d.ts +1 -0
- package/esm/locales/ArrayCards.js +19 -0
- package/esm/locales/ArrayTable.d.ts +138 -0
- package/esm/locales/ArrayTable.js +129 -0
- package/esm/locales/Card.d.ts +44 -0
- package/esm/locales/Card.js +44 -0
- package/esm/locales/Cascader.d.ts +59 -0
- package/esm/locales/Cascader.js +59 -0
- package/esm/locales/Checkbox.d.ts +11 -0
- package/esm/locales/Checkbox.js +11 -0
- package/esm/locales/Component.d.ts +53 -0
- package/esm/locales/Component.js +53 -0
- package/esm/locales/DatePicker.d.ts +75 -0
- package/esm/locales/DatePicker.js +86 -0
- package/esm/locales/Field.d.ts +341 -0
- package/esm/locales/Field.js +338 -0
- package/esm/locales/Form.d.ts +1 -0
- package/esm/locales/Form.js +133 -0
- package/esm/locales/FormCollapse.d.ts +88 -0
- package/esm/locales/FormCollapse.js +82 -0
- package/esm/locales/FormGrid.d.ts +76 -0
- package/esm/locales/FormGrid.js +76 -0
- package/esm/locales/FormLayout.d.ts +128 -0
- package/esm/locales/FormLayout.js +122 -0
- package/esm/locales/FormTab.d.ts +82 -0
- package/esm/locales/FormTab.js +82 -0
- package/esm/locales/Input.d.ts +50 -0
- package/esm/locales/Input.js +50 -0
- package/esm/locales/NumberPicker.d.ts +77 -0
- package/esm/locales/NumberPicker.js +77 -0
- package/esm/locales/Object.d.ts +11 -0
- package/esm/locales/Object.js +11 -0
- package/esm/locales/Password.d.ts +1 -0
- package/esm/locales/Password.js +13 -0
- package/esm/locales/Radio.d.ts +47 -0
- package/esm/locales/Radio.js +29 -0
- package/esm/locales/Rate.d.ts +41 -0
- package/esm/locales/Rate.js +32 -0
- package/esm/locales/Select.d.ts +125 -0
- package/esm/locales/Select.js +125 -0
- package/esm/locales/Slider.d.ts +71 -0
- package/esm/locales/Slider.js +71 -0
- package/esm/locales/Space.d.ts +53 -0
- package/esm/locales/Space.js +50 -0
- package/esm/locales/Switch.d.ts +11 -0
- package/esm/locales/Switch.js +11 -0
- package/esm/locales/Text.d.ts +38 -0
- package/esm/locales/Text.js +38 -0
- package/esm/locales/TextArea.d.ts +35 -0
- package/esm/locales/TextArea.js +35 -0
- package/esm/locales/TimePicker.d.ts +2 -0
- package/esm/locales/TimePicker.js +72 -0
- package/esm/locales/Transfer.d.ts +56 -0
- package/esm/locales/Transfer.js +38 -0
- package/esm/locales/TreeSelect.d.ts +181 -0
- package/esm/locales/TreeSelect.js +178 -0
- package/esm/locales/Upload.d.ts +78 -0
- package/esm/locales/Upload.js +92 -0
- package/esm/locales/Void.d.ts +11 -0
- package/esm/locales/Void.js +11 -0
- package/esm/locales/all.d.ts +31 -0
- package/esm/locales/all.js +31 -0
- package/esm/locales/index.d.ts +2 -0
- package/esm/locales/index.js +2 -0
- package/esm/schemas/ArrayCards.d.ts +59 -0
- package/esm/schemas/ArrayCards.js +4 -0
- package/esm/schemas/ArrayTable.d.ts +5 -0
- package/esm/schemas/ArrayTable.js +111 -0
- package/esm/schemas/CSSStyle.d.ts +2 -0
- package/esm/schemas/CSSStyle.js +49 -0
- package/esm/schemas/Card.d.ts +4 -0
- package/esm/schemas/Card.js +45 -0
- package/esm/schemas/Cascader.d.ts +2 -0
- package/esm/schemas/Cascader.js +74 -0
- package/esm/schemas/Checkbox.d.ts +4 -0
- package/esm/schemas/Checkbox.js +10 -0
- package/esm/schemas/DatePicker.d.ts +4 -0
- package/esm/schemas/DatePicker.js +104 -0
- package/esm/schemas/Form.d.ts +2 -0
- package/esm/schemas/Form.js +6 -0
- package/esm/schemas/FormCollapse.d.ts +4 -0
- package/esm/schemas/FormCollapse.js +58 -0
- package/esm/schemas/FormGrid.d.ts +4 -0
- package/esm/schemas/FormGrid.js +76 -0
- package/esm/schemas/FormItem.d.ts +2 -0
- package/esm/schemas/FormItem.js +138 -0
- package/esm/schemas/FormLayout.d.ts +2 -0
- package/esm/schemas/FormLayout.js +121 -0
- package/esm/schemas/FormTab.d.ts +4 -0
- package/esm/schemas/FormTab.js +43 -0
- package/esm/schemas/Input.d.ts +4 -0
- package/esm/schemas/Input.js +89 -0
- package/esm/schemas/NumberPicker.d.ts +2 -0
- package/esm/schemas/NumberPicker.js +79 -0
- package/esm/schemas/Password.d.ts +2 -0
- package/esm/schemas/Password.js +9 -0
- package/esm/schemas/Radio.d.ts +4 -0
- package/esm/schemas/Radio.js +35 -0
- package/esm/schemas/Rate.d.ts +2 -0
- package/esm/schemas/Rate.js +38 -0
- package/esm/schemas/Select.d.ts +2 -0
- package/esm/schemas/Select.js +159 -0
- package/esm/schemas/Slider.d.ts +2 -0
- package/esm/schemas/Slider.js +77 -0
- package/esm/schemas/Space.d.ts +2 -0
- package/esm/schemas/Space.js +39 -0
- package/esm/schemas/Switch.d.ts +2 -0
- package/esm/schemas/Switch.js +19 -0
- package/esm/schemas/Text.d.ts +2 -0
- package/esm/schemas/Text.js +19 -0
- package/esm/schemas/TimePicker.d.ts +116 -0
- package/esm/schemas/TimePicker.js +120 -0
- package/esm/schemas/Transfer.d.ts +2 -0
- package/esm/schemas/Transfer.js +44 -0
- package/esm/schemas/TreeSelect.d.ts +2 -0
- package/esm/schemas/TreeSelect.js +137 -0
- package/esm/schemas/Upload.d.ts +4 -0
- package/esm/schemas/Upload.js +99 -0
- package/esm/schemas/all.d.ts +27 -0
- package/esm/schemas/all.js +27 -0
- package/esm/schemas/index.d.ts +2 -0
- package/esm/schemas/index.js +2 -0
- package/esm/shared.d.ts +13 -0
- package/esm/shared.js +86 -0
- package/lib/common/Container/index.d.ts +6 -0
- package/lib/common/Container/index.js +20 -0
- package/lib/common/Container/styles.less +5 -0
- package/lib/common/FormItemSwitcher/index.d.ts +6 -0
- package/lib/common/FormItemSwitcher/index.js +14 -0
- package/lib/common/LoadTemplate/index.d.ts +13 -0
- package/lib/common/LoadTemplate/index.js +15 -0
- package/lib/components/ArrayBase/index.d.ts +1 -0
- package/lib/components/ArrayBase/index.js +75 -0
- package/lib/components/ArrayCards/index.d.ts +1 -0
- package/lib/components/ArrayCards/index.js +17 -0
- package/lib/components/ArrayCards/preview.d.ts +4 -0
- package/lib/components/ArrayCards/preview.js +245 -0
- package/lib/components/ArrayCards/styles.less +2 -0
- package/lib/components/ArrayTable/index.d.ts +1 -0
- package/lib/components/ArrayTable/index.js +17 -0
- package/lib/components/ArrayTable/preview.d.ts +4 -0
- package/lib/components/ArrayTable/preview.js +390 -0
- package/lib/components/ArrayTable/styles.less +2 -0
- package/lib/components/Card/index.d.ts +1 -0
- package/lib/components/Card/index.js +17 -0
- package/lib/components/Card/preview.d.ts +4 -0
- package/lib/components/Card/preview.js +41 -0
- package/lib/components/Cascader/index.d.ts +1 -0
- package/lib/components/Cascader/index.js +17 -0
- package/lib/components/Cascader/preview.d.ts +4 -0
- package/lib/components/Cascader/preview.js +31 -0
- package/lib/components/Checkbox/index.d.ts +1 -0
- package/lib/components/Checkbox/index.js +17 -0
- package/lib/components/Checkbox/preview.d.ts +4 -0
- package/lib/components/Checkbox/preview.js +36 -0
- package/lib/components/DatePicker/index.d.ts +1 -0
- package/lib/components/DatePicker/index.js +17 -0
- package/lib/components/DatePicker/preview.d.ts +4 -0
- package/lib/components/DatePicker/preview.js +53 -0
- package/lib/components/Field/index.d.ts +2 -0
- package/lib/components/Field/index.js +18 -0
- package/lib/components/Field/preview.d.ts +3 -0
- package/lib/components/Field/preview.js +133 -0
- package/lib/components/Field/shared.d.ts +649 -0
- package/lib/components/Field/shared.js +248 -0
- package/lib/components/Form/index.d.ts +1 -0
- package/lib/components/Form/index.js +17 -0
- package/lib/components/Form/preview.d.ts +5 -0
- package/lib/components/Form/preview.js +117 -0
- package/lib/components/Form/styles.less +32 -0
- package/lib/components/FormCollapse/index.d.ts +1 -0
- package/lib/components/FormCollapse/index.js +17 -0
- package/lib/components/FormCollapse/preview.d.ts +6 -0
- package/lib/components/FormCollapse/preview.js +152 -0
- package/lib/components/FormGrid/index.d.ts +1 -0
- package/lib/components/FormGrid/index.js +17 -0
- package/lib/components/FormGrid/preview.d.ts +9 -0
- package/lib/components/FormGrid/preview.js +137 -0
- package/lib/components/FormGrid/styles.less +5 -0
- package/lib/components/FormLayout/index.d.ts +1 -0
- package/lib/components/FormLayout/index.js +17 -0
- package/lib/components/FormLayout/preview.d.ts +4 -0
- package/lib/components/FormLayout/preview.js +32 -0
- package/lib/components/FormTab/index.d.ts +1 -0
- package/lib/components/FormTab/index.js +17 -0
- package/lib/components/FormTab/preview.d.ts +6 -0
- package/lib/components/FormTab/preview.js +159 -0
- package/lib/components/Input/index.d.ts +1 -0
- package/lib/components/Input/index.js +17 -0
- package/lib/components/Input/preview.d.ts +4 -0
- package/lib/components/Input/preview.js +53 -0
- package/lib/components/NumberPicker/index.d.ts +1 -0
- package/lib/components/NumberPicker/index.js +17 -0
- package/lib/components/NumberPicker/preview.d.ts +4 -0
- package/lib/components/NumberPicker/preview.js +32 -0
- package/lib/components/Object/index.d.ts +1 -0
- package/lib/components/Object/index.js +17 -0
- package/lib/components/Object/preview.d.ts +4 -0
- package/lib/components/Object/preview.js +29 -0
- package/lib/components/Password/index.d.ts +1 -0
- package/lib/components/Password/index.js +17 -0
- package/lib/components/Password/preview.d.ts +4 -0
- package/lib/components/Password/preview.js +31 -0
- package/lib/components/Radio/index.d.ts +1 -0
- package/lib/components/Radio/index.js +17 -0
- package/lib/components/Radio/preview.d.ts +4 -0
- package/lib/components/Radio/preview.js +36 -0
- package/lib/components/Rate/index.d.ts +1 -0
- package/lib/components/Rate/index.js +17 -0
- package/lib/components/Rate/preview.d.ts +4 -0
- package/lib/components/Rate/preview.js +32 -0
- package/lib/components/Select/index.d.ts +1 -0
- package/lib/components/Select/index.js +17 -0
- package/lib/components/Select/preview.d.ts +4 -0
- package/lib/components/Select/preview.js +31 -0
- package/lib/components/Slider/index.d.ts +1 -0
- package/lib/components/Slider/index.js +17 -0
- package/lib/components/Slider/preview.d.ts +4 -0
- package/lib/components/Slider/preview.js +32 -0
- package/lib/components/Space/index.d.ts +1 -0
- package/lib/components/Space/index.js +17 -0
- package/lib/components/Space/preview.d.ts +4 -0
- package/lib/components/Space/preview.js +33 -0
- package/lib/components/Switch/index.d.ts +1 -0
- package/lib/components/Switch/index.js +17 -0
- package/lib/components/Switch/preview.d.ts +4 -0
- package/lib/components/Switch/preview.js +32 -0
- package/lib/components/Text/index.d.ts +1 -0
- package/lib/components/Text/index.js +17 -0
- package/lib/components/Text/preview.d.ts +11 -0
- package/lib/components/Text/preview.js +39 -0
- package/lib/components/Text/styles.less +10 -0
- package/lib/components/TimePicker/index.d.ts +1 -0
- package/lib/components/TimePicker/index.js +17 -0
- package/lib/components/TimePicker/preview.d.ts +4 -0
- package/lib/components/TimePicker/preview.js +53 -0
- package/lib/components/Transfer/index.d.ts +1 -0
- package/lib/components/Transfer/index.js +17 -0
- package/lib/components/Transfer/preview.d.ts +4 -0
- package/lib/components/Transfer/preview.js +31 -0
- package/lib/components/TreeSelect/index.d.ts +1 -0
- package/lib/components/TreeSelect/index.js +17 -0
- package/lib/components/TreeSelect/preview.d.ts +4 -0
- package/lib/components/TreeSelect/preview.js +31 -0
- package/lib/components/Upload/index.d.ts +1 -0
- package/lib/components/Upload/index.js +17 -0
- package/lib/components/Upload/preview.d.ts +4 -0
- package/lib/components/Upload/preview.js +59 -0
- package/lib/components/index.d.ts +27 -0
- package/lib/components/index.js +43 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +17 -0
- package/lib/hooks/useDropTemplate.d.ts +2 -0
- package/lib/hooks/useDropTemplate.js +24 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +19 -0
- package/lib/locales/ArrayBase.d.ts +77 -0
- package/lib/locales/ArrayBase.js +94 -0
- package/lib/locales/ArrayCards.d.ts +1 -0
- package/lib/locales/ArrayCards.js +22 -0
- package/lib/locales/ArrayTable.d.ts +138 -0
- package/lib/locales/ArrayTable.js +132 -0
- package/lib/locales/Card.d.ts +44 -0
- package/lib/locales/Card.js +47 -0
- package/lib/locales/Cascader.d.ts +59 -0
- package/lib/locales/Cascader.js +62 -0
- package/lib/locales/Checkbox.d.ts +11 -0
- package/lib/locales/Checkbox.js +14 -0
- package/lib/locales/Component.d.ts +53 -0
- package/lib/locales/Component.js +56 -0
- package/lib/locales/DatePicker.d.ts +75 -0
- package/lib/locales/DatePicker.js +89 -0
- package/lib/locales/Field.d.ts +341 -0
- package/lib/locales/Field.js +341 -0
- package/lib/locales/Form.d.ts +1 -0
- package/lib/locales/Form.js +136 -0
- package/lib/locales/FormCollapse.d.ts +88 -0
- package/lib/locales/FormCollapse.js +85 -0
- package/lib/locales/FormGrid.d.ts +76 -0
- package/lib/locales/FormGrid.js +79 -0
- package/lib/locales/FormLayout.d.ts +128 -0
- package/lib/locales/FormLayout.js +125 -0
- package/lib/locales/FormTab.d.ts +82 -0
- package/lib/locales/FormTab.js +85 -0
- package/lib/locales/Input.d.ts +50 -0
- package/lib/locales/Input.js +53 -0
- package/lib/locales/NumberPicker.d.ts +77 -0
- package/lib/locales/NumberPicker.js +80 -0
- package/lib/locales/Object.d.ts +11 -0
- package/lib/locales/Object.js +14 -0
- package/lib/locales/Password.d.ts +1 -0
- package/lib/locales/Password.js +16 -0
- package/lib/locales/Radio.d.ts +47 -0
- package/lib/locales/Radio.js +32 -0
- package/lib/locales/Rate.d.ts +41 -0
- package/lib/locales/Rate.js +35 -0
- package/lib/locales/Select.d.ts +125 -0
- package/lib/locales/Select.js +128 -0
- package/lib/locales/Slider.d.ts +71 -0
- package/lib/locales/Slider.js +74 -0
- package/lib/locales/Space.d.ts +53 -0
- package/lib/locales/Space.js +53 -0
- package/lib/locales/Switch.d.ts +11 -0
- package/lib/locales/Switch.js +14 -0
- package/lib/locales/Text.d.ts +38 -0
- package/lib/locales/Text.js +41 -0
- package/lib/locales/TextArea.d.ts +35 -0
- package/lib/locales/TextArea.js +38 -0
- package/lib/locales/TimePicker.d.ts +2 -0
- package/lib/locales/TimePicker.js +75 -0
- package/lib/locales/Transfer.d.ts +56 -0
- package/lib/locales/Transfer.js +41 -0
- package/lib/locales/TreeSelect.d.ts +181 -0
- package/lib/locales/TreeSelect.js +181 -0
- package/lib/locales/Upload.d.ts +78 -0
- package/lib/locales/Upload.js +95 -0
- package/lib/locales/Void.d.ts +11 -0
- package/lib/locales/Void.js +14 -0
- package/lib/locales/all.d.ts +31 -0
- package/lib/locales/all.js +47 -0
- package/lib/locales/index.d.ts +2 -0
- package/lib/locales/index.js +38 -0
- package/lib/schemas/ArrayCards.d.ts +59 -0
- package/lib/schemas/ArrayCards.js +7 -0
- package/lib/schemas/ArrayTable.d.ts +5 -0
- package/lib/schemas/ArrayTable.js +114 -0
- package/lib/schemas/CSSStyle.d.ts +2 -0
- package/lib/schemas/CSSStyle.js +52 -0
- package/lib/schemas/Card.d.ts +4 -0
- package/lib/schemas/Card.js +48 -0
- package/lib/schemas/Cascader.d.ts +2 -0
- package/lib/schemas/Cascader.js +77 -0
- package/lib/schemas/Checkbox.d.ts +4 -0
- package/lib/schemas/Checkbox.js +13 -0
- package/lib/schemas/DatePicker.d.ts +4 -0
- package/lib/schemas/DatePicker.js +107 -0
- package/lib/schemas/Form.d.ts +2 -0
- package/lib/schemas/Form.js +9 -0
- package/lib/schemas/FormCollapse.d.ts +4 -0
- package/lib/schemas/FormCollapse.js +61 -0
- package/lib/schemas/FormGrid.d.ts +4 -0
- package/lib/schemas/FormGrid.js +79 -0
- package/lib/schemas/FormItem.d.ts +2 -0
- package/lib/schemas/FormItem.js +141 -0
- package/lib/schemas/FormLayout.d.ts +2 -0
- package/lib/schemas/FormLayout.js +124 -0
- package/lib/schemas/FormTab.d.ts +4 -0
- package/lib/schemas/FormTab.js +46 -0
- package/lib/schemas/Input.d.ts +4 -0
- package/lib/schemas/Input.js +92 -0
- package/lib/schemas/NumberPicker.d.ts +2 -0
- package/lib/schemas/NumberPicker.js +82 -0
- package/lib/schemas/Password.d.ts +2 -0
- package/lib/schemas/Password.js +12 -0
- package/lib/schemas/Radio.d.ts +4 -0
- package/lib/schemas/Radio.js +38 -0
- package/lib/schemas/Rate.d.ts +2 -0
- package/lib/schemas/Rate.js +41 -0
- package/lib/schemas/Select.d.ts +2 -0
- package/lib/schemas/Select.js +162 -0
- package/lib/schemas/Slider.d.ts +2 -0
- package/lib/schemas/Slider.js +80 -0
- package/lib/schemas/Space.d.ts +2 -0
- package/lib/schemas/Space.js +42 -0
- package/lib/schemas/Switch.d.ts +2 -0
- package/lib/schemas/Switch.js +22 -0
- package/lib/schemas/Text.d.ts +2 -0
- package/lib/schemas/Text.js +22 -0
- package/lib/schemas/TimePicker.d.ts +116 -0
- package/lib/schemas/TimePicker.js +123 -0
- package/lib/schemas/Transfer.d.ts +2 -0
- package/lib/schemas/Transfer.js +47 -0
- package/lib/schemas/TreeSelect.d.ts +2 -0
- package/lib/schemas/TreeSelect.js +140 -0
- package/lib/schemas/Upload.d.ts +4 -0
- package/lib/schemas/Upload.js +102 -0
- package/lib/schemas/all.d.ts +27 -0
- package/lib/schemas/all.js +43 -0
- package/lib/schemas/index.d.ts +2 -0
- package/lib/schemas/index.js +38 -0
- package/lib/shared.d.ts +13 -0
- package/lib/shared.js +98 -0
- package/package.json +75 -0
- package/playground/components/AsyncSelect/AsyncSelect.tsx +38 -0
- package/playground/components/AsyncSelect/index.tsx +1 -0
- package/playground/components/AsyncSelect/preview.tsx +36 -0
- package/playground/components/ClickEventSetter/ActionConfigModal.tsx +173 -0
- package/playground/components/ClickEventSetter/ActionList.tsx +67 -0
- package/playground/components/ClickEventSetter/DownloadPanel.tsx +24 -0
- package/playground/components/ClickEventSetter/NavigationPanel.tsx +42 -0
- package/playground/components/ClickEventSetter/RequestPanel.tsx +190 -0
- package/playground/components/ClickEventSetter/index.tsx +90 -0
- package/playground/components/ClickEventSetter/styles.less +89 -0
- package/playground/components/ClickEventSetter/types.ts +43 -0
- package/playground/components/FormButton/FormButton.tsx +189 -0
- package/playground/components/FormButton/hooks/useEventActionExecutor.ts +65 -0
- package/playground/components/FormButton/index.ts +1 -0
- package/playground/components/FormButton/preview.tsx +60 -0
- package/playground/components/FormButton/utils/actionExecutors.ts +96 -0
- package/playground/components/FormButtonGroup/FormButtonGroup.tsx +21 -0
- package/playground/components/FormButtonGroup/index.ts +1 -0
- package/playground/components/FormButtonGroup/preview.tsx +66 -0
- package/playground/components/FormList/FormList.tsx +164 -0
- package/playground/components/FormList/index.tsx +1 -0
- package/playground/components/FormList/preview.tsx +429 -0
- package/playground/components/LocationPicker/LocationModal.tsx +328 -0
- package/playground/components/LocationPicker/LocationPicker.tsx +163 -0
- package/playground/components/LocationPicker/SearchBox.tsx +122 -0
- package/playground/components/LocationPicker/api.ts +77 -0
- package/playground/components/LocationPicker/constants.ts +2 -0
- package/playground/components/LocationPicker/index.tsx +44 -0
- package/playground/components/LocationPicker/types.ts +160 -0
- package/playground/components/LocationPicker/utils.ts +46 -0
- package/playground/components/ResourceIcon/index.module.less +10 -0
- package/playground/components/ResourceIcon/index.tsx +10 -0
- package/playground/designerLocales/en-US.ts +38 -0
- package/playground/designerLocales/index.ts +6 -0
- package/playground/designerLocales/ko-KR.ts +10 -0
- package/playground/designerLocales/zh-CN.ts +38 -0
- package/playground/locales/FormButton.ts +38 -0
- package/playground/locales/FormButtonGroup.ts +29 -0
- package/playground/locales/LocationPicker.ts +30 -0
- package/playground/locales/all.ts +3 -0
- package/playground/locales/index.ts +3 -0
- package/playground/main.tsx +222 -0
- package/playground/react-app-env.d.ts +4 -0
- package/playground/request.ts +123 -0
- package/playground/schemas/FormButton.ts +42 -0
- package/playground/schemas/FormButtonGroup.ts +24 -0
- package/playground/schemas/LocationPicker.ts +14 -0
- package/playground/schemas/all.ts +3 -0
- package/playground/schemas/index.ts +3 -0
- package/playground/service/index.ts +1 -0
- package/playground/service/schema.ts +22 -0
- package/playground/template.ejs +20 -0
- package/playground/utils.ts +744 -0
- package/playground/webpack.base.ts +123 -0
- package/playground/webpack.dev.ts +64 -0
- package/playground/webpack.prod.ts +46 -0
- package/playground/widgets/ActionsWidget.tsx +58 -0
- package/playground/widgets/LogoWidget.tsx +20 -0
- package/playground/widgets/MarkupSchemaWidget.tsx +164 -0
- package/playground/widgets/PreviewWidget.tsx +188 -0
- package/playground/widgets/SchemaEditorWidget.tsx +27 -0
- package/playground/widgets/index.ts +5 -0
- package/tsconfig.build.json +12 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import React, { useState, useCallback, useContext, useEffect } from 'react'
|
|
2
|
+
import { Modal, Button, message } from 'antd'
|
|
3
|
+
import { EnvironmentOutlined } from '@ant-design/icons'
|
|
4
|
+
import { TMap, MapContext, MultiMarker } from 'tlbs-map-react'
|
|
5
|
+
import { LocationValue, SearchResult } from './types'
|
|
6
|
+
import { SearchBox } from './SearchBox'
|
|
7
|
+
import { fetchAddressInfo, fetchMapLocationInfo } from './api'
|
|
8
|
+
import { parseAdcode } from './utils'
|
|
9
|
+
|
|
10
|
+
interface LocationModalProps {
|
|
11
|
+
visible: boolean
|
|
12
|
+
value?: LocationValue
|
|
13
|
+
onConfirm: (value: LocationValue) => void
|
|
14
|
+
onCancel: () => void
|
|
15
|
+
mapId?: string
|
|
16
|
+
readOnly?: boolean
|
|
17
|
+
mapKey: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface PointGeometry {
|
|
21
|
+
styleId: string
|
|
22
|
+
position: {
|
|
23
|
+
lat: number
|
|
24
|
+
lng: number
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 默认中心点(北京)
|
|
29
|
+
const DEFAULT_CENTER = {
|
|
30
|
+
lat: 39.9042,
|
|
31
|
+
lng: 116.4074,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 标记样式
|
|
35
|
+
interface MarkerStyle {
|
|
36
|
+
width: number
|
|
37
|
+
height: number
|
|
38
|
+
anchor: { x: number; y: number }
|
|
39
|
+
src?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const MARKER_STYLES: Record<string, MarkerStyle> = {
|
|
43
|
+
marker: {
|
|
44
|
+
width: 30,
|
|
45
|
+
height: 40,
|
|
46
|
+
anchor: { x: 15, y: 40 },
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 地图点击处理组件
|
|
51
|
+
const MapClickHandler: React.FC<{
|
|
52
|
+
onMapClick: (lat: number, lng: number) => void
|
|
53
|
+
}> = ({ onMapClick }) => {
|
|
54
|
+
const mapInstance = useContext(MapContext)
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!mapInstance) return
|
|
58
|
+
|
|
59
|
+
const handleClick = (event: any) => {
|
|
60
|
+
const { lat, lng } = event.latLng
|
|
61
|
+
onMapClick(lat, lng)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 监听地图点击事件
|
|
65
|
+
mapInstance.on('click', handleClick)
|
|
66
|
+
|
|
67
|
+
return () => {
|
|
68
|
+
mapInstance.off('click', handleClick)
|
|
69
|
+
}
|
|
70
|
+
}, [mapInstance, onMapClick])
|
|
71
|
+
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 标记点管理组件
|
|
76
|
+
const MarkerController: React.FC<{
|
|
77
|
+
location: LocationValue | null
|
|
78
|
+
}> = ({ location }) => {
|
|
79
|
+
const [geometries, setGeometries] = useState<PointGeometry[]>([])
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (location) {
|
|
83
|
+
setGeometries([
|
|
84
|
+
{
|
|
85
|
+
styleId: 'marker',
|
|
86
|
+
position: {
|
|
87
|
+
lat: location.lat,
|
|
88
|
+
lng: location.lng,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
])
|
|
92
|
+
} else {
|
|
93
|
+
setGeometries([])
|
|
94
|
+
}
|
|
95
|
+
}, [location])
|
|
96
|
+
|
|
97
|
+
return <MultiMarker styles={MARKER_STYLES} geometries={geometries} />
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const LocationModal: React.FC<LocationModalProps> = (props) => {
|
|
101
|
+
const { visible, value, onConfirm, onCancel, readOnly, mapKey } = props
|
|
102
|
+
|
|
103
|
+
const [selectedLocation, setSelectedLocation] =
|
|
104
|
+
useState<LocationValue | null>(null)
|
|
105
|
+
const [center, setCenter] = useState(DEFAULT_CENTER)
|
|
106
|
+
|
|
107
|
+
/** 处理地图点击 */
|
|
108
|
+
const handleMapClick = useCallback(
|
|
109
|
+
async (lat: number, lng: number) => {
|
|
110
|
+
if (readOnly) return
|
|
111
|
+
const { address, ...addressInfo } = await fetchAddressInfo(lat, lng, {
|
|
112
|
+
mapKey,
|
|
113
|
+
})
|
|
114
|
+
const locationData: LocationValue = {
|
|
115
|
+
...addressInfo,
|
|
116
|
+
address,
|
|
117
|
+
lat,
|
|
118
|
+
lng,
|
|
119
|
+
name: address ? address.split(',')[0] : '',
|
|
120
|
+
}
|
|
121
|
+
setSelectedLocation(locationData)
|
|
122
|
+
},
|
|
123
|
+
[readOnly, mapKey]
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
/** 处理搜索结果选择 */
|
|
127
|
+
const handleSelectSearchResult = useCallback((result: SearchResult) => {
|
|
128
|
+
/** 省市区编码 */
|
|
129
|
+
const adCodeInfo = parseAdcode(String(result.adcode))
|
|
130
|
+
const locationData: LocationValue = {
|
|
131
|
+
...adCodeInfo,
|
|
132
|
+
address: result.address || result.title,
|
|
133
|
+
lat: result.lat,
|
|
134
|
+
lng: result.lng,
|
|
135
|
+
name: result.title,
|
|
136
|
+
provinceName: result.province,
|
|
137
|
+
cityName: result.city,
|
|
138
|
+
districtName: result.district,
|
|
139
|
+
}
|
|
140
|
+
setSelectedLocation(locationData)
|
|
141
|
+
setCenter({ lat: result.lat, lng: result.lng })
|
|
142
|
+
}, [])
|
|
143
|
+
|
|
144
|
+
/** 定位当前位置 */
|
|
145
|
+
const handleLocateCurrent = useCallback(() => {
|
|
146
|
+
if (!navigator.geolocation) {
|
|
147
|
+
message.warning('您的浏览器不支持定位功能')
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
message.loading('正在定位...', 0)
|
|
152
|
+
|
|
153
|
+
// 设备 api 获取位置
|
|
154
|
+
navigator.geolocation.getCurrentPosition(
|
|
155
|
+
(position) => {
|
|
156
|
+
message.destroy()
|
|
157
|
+
const { latitude, longitude } = position.coords
|
|
158
|
+
fetchAddressInfo(latitude, longitude, { mapKey }).then(
|
|
159
|
+
({ address, ...addressInfo }) => {
|
|
160
|
+
const locationData: LocationValue = {
|
|
161
|
+
...addressInfo,
|
|
162
|
+
address,
|
|
163
|
+
lat: latitude,
|
|
164
|
+
lng: longitude,
|
|
165
|
+
name: '当前位置',
|
|
166
|
+
}
|
|
167
|
+
setSelectedLocation(locationData)
|
|
168
|
+
setCenter({ lat: latitude, lng: longitude })
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
},
|
|
172
|
+
(error) => {
|
|
173
|
+
message.destroy()
|
|
174
|
+
console.error('定位失败:', error)
|
|
175
|
+
switch (error.code) {
|
|
176
|
+
case error.PERMISSION_DENIED:
|
|
177
|
+
message.warning('定位权限被拒绝,请手动选择位置')
|
|
178
|
+
break
|
|
179
|
+
case error.POSITION_UNAVAILABLE:
|
|
180
|
+
message.error('位置信息不可用')
|
|
181
|
+
break
|
|
182
|
+
case error.TIMEOUT:
|
|
183
|
+
message.error('定位超时')
|
|
184
|
+
break
|
|
185
|
+
default:
|
|
186
|
+
message.error('定位失败')
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
enableHighAccuracy: true,
|
|
191
|
+
timeout: 10000,
|
|
192
|
+
maximumAge: 0,
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}, [mapKey])
|
|
196
|
+
|
|
197
|
+
/** 确认选择 */
|
|
198
|
+
const handleConfirm = useCallback(async () => {
|
|
199
|
+
if (selectedLocation) {
|
|
200
|
+
// 如果没有地址,尝试获取
|
|
201
|
+
if (!selectedLocation.address) {
|
|
202
|
+
const { address, ...addressInfo } = await fetchAddressInfo(
|
|
203
|
+
selectedLocation.lat,
|
|
204
|
+
selectedLocation.lng,
|
|
205
|
+
{
|
|
206
|
+
mapKey,
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
onConfirm({ ...selectedLocation, ...addressInfo, address })
|
|
210
|
+
} else {
|
|
211
|
+
onConfirm(selectedLocation)
|
|
212
|
+
}
|
|
213
|
+
} else if (value) {
|
|
214
|
+
onConfirm(value)
|
|
215
|
+
} else {
|
|
216
|
+
message.warning('请先选择位置')
|
|
217
|
+
}
|
|
218
|
+
}, [selectedLocation, value, onConfirm, mapKey])
|
|
219
|
+
|
|
220
|
+
/** 取消 */
|
|
221
|
+
const handleCancel = useCallback(() => {
|
|
222
|
+
setSelectedLocation(null)
|
|
223
|
+
onCancel()
|
|
224
|
+
}, [onCancel])
|
|
225
|
+
|
|
226
|
+
/** 地图加载完成回调 */
|
|
227
|
+
const onMapInited = () => {
|
|
228
|
+
if (visible && !value) {
|
|
229
|
+
fetchMapLocationInfo(mapKey).then(({ lat, lng }) => {
|
|
230
|
+
setCenter({ lat, lng })
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** 弹窗打开时重置地图 key 以重新初始化 */
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (visible) {
|
|
238
|
+
if (value) {
|
|
239
|
+
setSelectedLocation(value)
|
|
240
|
+
setCenter({ lat: value.lat, lng: value.lng })
|
|
241
|
+
} else {
|
|
242
|
+
setCenter(DEFAULT_CENTER)
|
|
243
|
+
setSelectedLocation(null)
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}, [visible, value])
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<Modal
|
|
250
|
+
title={readOnly ? '查看位置' : '选择位置'}
|
|
251
|
+
open={visible}
|
|
252
|
+
onCancel={handleCancel}
|
|
253
|
+
footer={
|
|
254
|
+
readOnly
|
|
255
|
+
? [
|
|
256
|
+
<Button key="cancel" onClick={handleCancel}>
|
|
257
|
+
取消
|
|
258
|
+
</Button>,
|
|
259
|
+
]
|
|
260
|
+
: [
|
|
261
|
+
<Button
|
|
262
|
+
key="locate"
|
|
263
|
+
icon={<EnvironmentOutlined />}
|
|
264
|
+
onClick={handleLocateCurrent}
|
|
265
|
+
>
|
|
266
|
+
定位当前
|
|
267
|
+
</Button>,
|
|
268
|
+
<Button key="cancel" onClick={handleCancel}>
|
|
269
|
+
取消
|
|
270
|
+
</Button>,
|
|
271
|
+
<Button key="confirm" type="primary" onClick={handleConfirm}>
|
|
272
|
+
确认选择
|
|
273
|
+
</Button>,
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
width={700}
|
|
277
|
+
centered
|
|
278
|
+
destroyOnClose
|
|
279
|
+
>
|
|
280
|
+
<div className="location-modal-content">
|
|
281
|
+
{!readOnly && (
|
|
282
|
+
<SearchBox onSelect={handleSelectSearchResult} mapKey={mapKey} />
|
|
283
|
+
)}
|
|
284
|
+
{mapKey ? (
|
|
285
|
+
<div
|
|
286
|
+
style={{
|
|
287
|
+
width: '100%',
|
|
288
|
+
height: 400,
|
|
289
|
+
marginTop: 16,
|
|
290
|
+
borderRadius: 8,
|
|
291
|
+
overflow: 'hidden',
|
|
292
|
+
}}
|
|
293
|
+
>
|
|
294
|
+
<TMap
|
|
295
|
+
apiKey={mapKey}
|
|
296
|
+
options={{ center }}
|
|
297
|
+
style={{ width: '100%', height: '100%' }}
|
|
298
|
+
onMapInited={onMapInited}
|
|
299
|
+
>
|
|
300
|
+
<MapClickHandler onMapClick={handleMapClick} />
|
|
301
|
+
<MarkerController location={selectedLocation} />
|
|
302
|
+
</TMap>
|
|
303
|
+
</div>
|
|
304
|
+
) : (
|
|
305
|
+
<div style={{ height: 60, display: 'flex', alignItems: 'center' }}>
|
|
306
|
+
地图加载失败,请配置地图 key
|
|
307
|
+
</div>
|
|
308
|
+
)}
|
|
309
|
+
{selectedLocation?.address && (
|
|
310
|
+
<div
|
|
311
|
+
style={{
|
|
312
|
+
marginTop: 12,
|
|
313
|
+
padding: 8,
|
|
314
|
+
background: '#f0f9ff',
|
|
315
|
+
borderRadius: 4,
|
|
316
|
+
fontSize: 14,
|
|
317
|
+
}}
|
|
318
|
+
>
|
|
319
|
+
<EnvironmentOutlined style={{ marginRight: 8, color: '#1890ff' }} />
|
|
320
|
+
{selectedLocation.address}
|
|
321
|
+
</div>
|
|
322
|
+
)}
|
|
323
|
+
</div>
|
|
324
|
+
</Modal>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export default LocationModal
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { useState, useCallback, useMemo } from 'react'
|
|
2
|
+
import { Input, Space } from 'antd'
|
|
3
|
+
import { EnvironmentOutlined } from '@ant-design/icons'
|
|
4
|
+
import { LocationPickerProps, LocationValue } from './types'
|
|
5
|
+
import { LocationModal } from './LocationModal'
|
|
6
|
+
import { PreviewText } from '@formily/antd-v5'
|
|
7
|
+
import { connect, mapReadPretty } from '@formily/react'
|
|
8
|
+
|
|
9
|
+
/** 业务字段和组件值的映射默认配置 */
|
|
10
|
+
const VALUE_MAP = {
|
|
11
|
+
/** 完整地址 */
|
|
12
|
+
address: 'address',
|
|
13
|
+
/** 纬度 */
|
|
14
|
+
lat: 'lat',
|
|
15
|
+
/** 经度 */
|
|
16
|
+
lng: 'lng',
|
|
17
|
+
/** 省级编码 */
|
|
18
|
+
provinceCode: 'provinceCode',
|
|
19
|
+
/** 省级名称 */
|
|
20
|
+
provinceName: 'provinceName',
|
|
21
|
+
/** 市级编码 */
|
|
22
|
+
cityCode: 'cityCode',
|
|
23
|
+
/** 市级名称 */
|
|
24
|
+
cityName: 'cityName',
|
|
25
|
+
/** 区级编码 */
|
|
26
|
+
districtCode: 'districtCode',
|
|
27
|
+
/** 区级名称 */
|
|
28
|
+
districtName: 'districtName',
|
|
29
|
+
/** 名称 */
|
|
30
|
+
name: 'name',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 将组件值映射为业务字段 */
|
|
34
|
+
const mapToBusinessFields = (
|
|
35
|
+
location: LocationValue,
|
|
36
|
+
fieldNames: Record<string, string>
|
|
37
|
+
): Record<string, unknown> => {
|
|
38
|
+
const result: Record<string, unknown> = {}
|
|
39
|
+
Object.entries(fieldNames).forEach(([key, fieldKey]) => {
|
|
40
|
+
const v = location[key as keyof LocationValue]
|
|
41
|
+
if (v !== undefined && v !== null) {
|
|
42
|
+
result[fieldKey] = v
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 将业务字段映射为组件值 */
|
|
49
|
+
const mapToComponentValue = (
|
|
50
|
+
value: Record<string, unknown>,
|
|
51
|
+
fieldNames: Record<string, string>
|
|
52
|
+
): LocationValue => {
|
|
53
|
+
const result: LocationValue = {
|
|
54
|
+
address: '',
|
|
55
|
+
lat: 0,
|
|
56
|
+
lng: 0,
|
|
57
|
+
provinceCode: '',
|
|
58
|
+
provinceName: '',
|
|
59
|
+
cityCode: '',
|
|
60
|
+
cityName: '',
|
|
61
|
+
districtCode: '',
|
|
62
|
+
districtName: '',
|
|
63
|
+
name: '',
|
|
64
|
+
}
|
|
65
|
+
Object.entries(fieldNames).forEach(([key, fieldKey]) => {
|
|
66
|
+
const v = value[fieldKey]
|
|
67
|
+
if (v !== undefined && v !== null) {
|
|
68
|
+
result[key as keyof LocationValue] = v as never
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
return result
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function LocationPickerComp(props: LocationPickerProps) {
|
|
75
|
+
const {
|
|
76
|
+
value,
|
|
77
|
+
onChange,
|
|
78
|
+
placeholder = '请选择位置',
|
|
79
|
+
disabled,
|
|
80
|
+
mapId,
|
|
81
|
+
readOnly,
|
|
82
|
+
fieldNames: propsFieldNames,
|
|
83
|
+
mapApiKey,
|
|
84
|
+
...restProps
|
|
85
|
+
} = props
|
|
86
|
+
const fieldNames = useMemo(
|
|
87
|
+
() => ({ ...VALUE_MAP, ...propsFieldNames }),
|
|
88
|
+
[propsFieldNames]
|
|
89
|
+
)
|
|
90
|
+
const [modalVisible, setModalVisible] = useState(false)
|
|
91
|
+
|
|
92
|
+
const handleOpenModal = useCallback(() => {
|
|
93
|
+
if (!disabled) {
|
|
94
|
+
setModalVisible(true)
|
|
95
|
+
}
|
|
96
|
+
}, [disabled])
|
|
97
|
+
|
|
98
|
+
const handleConfirm = useCallback(
|
|
99
|
+
(location: LocationValue) => {
|
|
100
|
+
onChange?.(mapToBusinessFields(location, fieldNames))
|
|
101
|
+
setModalVisible(false)
|
|
102
|
+
},
|
|
103
|
+
[onChange, fieldNames]
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
const handleCancel = useCallback(() => {
|
|
107
|
+
setModalVisible(false)
|
|
108
|
+
}, [])
|
|
109
|
+
|
|
110
|
+
// 将业务字段映射为组件值
|
|
111
|
+
const fieldValue = value ? mapToComponentValue(value, fieldNames) : undefined
|
|
112
|
+
// 显示值
|
|
113
|
+
const displayValue = fieldValue?.address ?? ''
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<Input
|
|
118
|
+
{...restProps}
|
|
119
|
+
value={displayValue}
|
|
120
|
+
placeholder={placeholder}
|
|
121
|
+
disabled={disabled}
|
|
122
|
+
readOnly
|
|
123
|
+
prefix={
|
|
124
|
+
<Space>
|
|
125
|
+
<EnvironmentOutlined style={{ color: '#1890ff' }} />
|
|
126
|
+
</Space>
|
|
127
|
+
}
|
|
128
|
+
onClick={handleOpenModal}
|
|
129
|
+
style={{ cursor: disabled ? 'not-allowed' : 'pointer' }}
|
|
130
|
+
/>
|
|
131
|
+
<LocationModal
|
|
132
|
+
visible={modalVisible}
|
|
133
|
+
value={fieldValue}
|
|
134
|
+
onConfirm={handleConfirm}
|
|
135
|
+
onCancel={handleCancel}
|
|
136
|
+
mapId={mapId}
|
|
137
|
+
mapKey={mapApiKey}
|
|
138
|
+
readOnly={readOnly}
|
|
139
|
+
/>
|
|
140
|
+
</>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** 位置选择器阅读模式组件 */
|
|
145
|
+
function PockerPreviewText(props: LocationPickerProps) {
|
|
146
|
+
const { value, fieldNames: propsFieldNames } = props
|
|
147
|
+
const fieldNames = useMemo(
|
|
148
|
+
() => ({ ...VALUE_MAP, ...propsFieldNames }),
|
|
149
|
+
[propsFieldNames]
|
|
150
|
+
)
|
|
151
|
+
// 将业务字段映射为组件值
|
|
152
|
+
const fieldValue = value ? mapToComponentValue(value, fieldNames) : undefined
|
|
153
|
+
// 显示值
|
|
154
|
+
const displayValue = fieldValue?.address ?? ''
|
|
155
|
+
return <PreviewText.Input value={displayValue} />
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const LocationPicker = connect(
|
|
159
|
+
LocationPickerComp,
|
|
160
|
+
mapReadPretty(PockerPreviewText)
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
export default LocationPicker
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react'
|
|
2
|
+
import { Input, Button, List, message } from 'antd'
|
|
3
|
+
import { SearchOutlined } from '@ant-design/icons'
|
|
4
|
+
import { SearchResult } from './types'
|
|
5
|
+
import { fetchPlaceSuggestion } from './api'
|
|
6
|
+
|
|
7
|
+
interface SearchBoxProps {
|
|
8
|
+
onSearch?: () => void
|
|
9
|
+
onSelect: (result: SearchResult) => void
|
|
10
|
+
mapKey: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SearchBox: React.FC<SearchBoxProps> = (props) => {
|
|
14
|
+
const { onSearch, onSelect, mapKey } = props
|
|
15
|
+
|
|
16
|
+
const [keyword, setKeyword] = useState('')
|
|
17
|
+
const [searchResults, setSearchResults] = useState<SearchResult[]>([])
|
|
18
|
+
const [searching, setSearching] = useState(false)
|
|
19
|
+
|
|
20
|
+
const handleSearch = useCallback(async () => {
|
|
21
|
+
if (!keyword.trim()) {
|
|
22
|
+
message.warning('请输入地址关键字')
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setSearching(true)
|
|
27
|
+
try {
|
|
28
|
+
const data = await fetchPlaceSuggestion(keyword, { mapKey })
|
|
29
|
+
if (data && data.length > 0) {
|
|
30
|
+
// 模糊搜索结果
|
|
31
|
+
const results: SearchResult[] = data.map((item) => ({
|
|
32
|
+
title: item.title || '',
|
|
33
|
+
address: item.address || '',
|
|
34
|
+
lat: item.location?.lat || 0,
|
|
35
|
+
lng: item.location?.lng || 0,
|
|
36
|
+
category: item.category,
|
|
37
|
+
adcode: item.adcode,
|
|
38
|
+
province: item.province,
|
|
39
|
+
city: item.city,
|
|
40
|
+
district: item.district,
|
|
41
|
+
}))
|
|
42
|
+
setSearchResults(results)
|
|
43
|
+
onSearch?.()
|
|
44
|
+
} else {
|
|
45
|
+
message.warning('未找到相关地址')
|
|
46
|
+
setSearchResults([])
|
|
47
|
+
onSearch?.()
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('搜索地址失败:', error)
|
|
51
|
+
message.error('搜索地址失败,请稍后重试')
|
|
52
|
+
} finally {
|
|
53
|
+
setSearching(false)
|
|
54
|
+
}
|
|
55
|
+
}, [keyword, onSearch, mapKey])
|
|
56
|
+
|
|
57
|
+
const handleSelect = useCallback(
|
|
58
|
+
(result: SearchResult) => {
|
|
59
|
+
setSearchResults([])
|
|
60
|
+
setKeyword('')
|
|
61
|
+
onSelect(result)
|
|
62
|
+
},
|
|
63
|
+
[onSelect]
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
67
|
+
setKeyword(e.target.value)
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
const handleKeyPress = useCallback(
|
|
71
|
+
(e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
72
|
+
if (e.key === 'Enter') {
|
|
73
|
+
handleSearch()
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[handleSearch]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
<Input
|
|
82
|
+
placeholder="输入地址搜索..."
|
|
83
|
+
value={keyword}
|
|
84
|
+
onChange={handleChange}
|
|
85
|
+
onKeyDown={handleKeyPress}
|
|
86
|
+
suffix={
|
|
87
|
+
<Button
|
|
88
|
+
type="primary"
|
|
89
|
+
icon={<SearchOutlined />}
|
|
90
|
+
loading={searching}
|
|
91
|
+
onClick={handleSearch}
|
|
92
|
+
style={{ marginRight: -8 }}
|
|
93
|
+
/>
|
|
94
|
+
}
|
|
95
|
+
style={{ width: '100%' }}
|
|
96
|
+
/>
|
|
97
|
+
{searchResults.length > 0 && (
|
|
98
|
+
<List
|
|
99
|
+
size="small"
|
|
100
|
+
dataSource={searchResults}
|
|
101
|
+
renderItem={(item) => (
|
|
102
|
+
<List.Item
|
|
103
|
+
onClick={() => handleSelect(item)}
|
|
104
|
+
style={{ cursor: 'pointer' }}
|
|
105
|
+
>
|
|
106
|
+
<List.Item.Meta title={item.title} description={item.address} />
|
|
107
|
+
</List.Item>
|
|
108
|
+
)}
|
|
109
|
+
style={{
|
|
110
|
+
maxHeight: 150,
|
|
111
|
+
overflow: 'auto',
|
|
112
|
+
border: '1px solid #d9d9d9',
|
|
113
|
+
borderTop: 'none',
|
|
114
|
+
borderRadius: '0 0 8px 8px',
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default SearchBox
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GeocoderResponse,
|
|
3
|
+
MapLocationResponse,
|
|
4
|
+
SuggestionResponse,
|
|
5
|
+
} from './types'
|
|
6
|
+
import { fetchMapService, parseAdcode } from './utils'
|
|
7
|
+
|
|
8
|
+
/** 地址解析函数 */
|
|
9
|
+
export function fetchAddressInfo(
|
|
10
|
+
lat: number,
|
|
11
|
+
lng: number,
|
|
12
|
+
options: {
|
|
13
|
+
mapKey: string
|
|
14
|
+
}
|
|
15
|
+
): Promise<{
|
|
16
|
+
address: string
|
|
17
|
+
provinceCode: string
|
|
18
|
+
cityCode: string
|
|
19
|
+
districtCode: string
|
|
20
|
+
provinceName: string
|
|
21
|
+
cityName: string
|
|
22
|
+
districtName: string
|
|
23
|
+
}> {
|
|
24
|
+
const TENCENT_MAP_KEY = options.mapKey
|
|
25
|
+
const url = `https://apis.map.qq.com/ws/geocoder/v1/?location=${lat},${lng}&output=jsonp&key=${TENCENT_MAP_KEY}`
|
|
26
|
+
return fetchMapService<GeocoderResponse>(url).then((res) => {
|
|
27
|
+
if (!res.result) {
|
|
28
|
+
throw new Error('获取地址失败')
|
|
29
|
+
}
|
|
30
|
+
/** 省市区编码 */
|
|
31
|
+
const adCodeInfo = parseAdcode(res.result.ad_info.adcode)
|
|
32
|
+
return {
|
|
33
|
+
address: res.result.address || '',
|
|
34
|
+
...adCodeInfo,
|
|
35
|
+
provinceName: res.result.address_component.province,
|
|
36
|
+
cityName: res.result.address_component.city,
|
|
37
|
+
districtName: res.result.address_component.district,
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 请求地图定位 */
|
|
43
|
+
export function fetchMapLocationInfo(
|
|
44
|
+
mapKey: string
|
|
45
|
+
): Promise<{ lat: number; lng: number }> {
|
|
46
|
+
const url = `https://apis.map.qq.com/ws/location/v1/ip?key=${mapKey}&output=jsonp`
|
|
47
|
+
return fetchMapService<MapLocationResponse>(url).then((res) => {
|
|
48
|
+
if (res.result) {
|
|
49
|
+
return {
|
|
50
|
+
lat: res.result.location.lat,
|
|
51
|
+
lng: res.result.location.lng,
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
// 提示错误
|
|
55
|
+
throw new Error('获取定位失败')
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** 关键词输入提示 */
|
|
61
|
+
export function fetchPlaceSuggestion(
|
|
62
|
+
keyword: string,
|
|
63
|
+
options: {
|
|
64
|
+
mapKey: string
|
|
65
|
+
}
|
|
66
|
+
): Promise<SuggestionResponse['data']> {
|
|
67
|
+
const TENCENT_MAP_KEY = options.mapKey
|
|
68
|
+
const encodedKeyword = keyword.trim()
|
|
69
|
+
const url = `https://apis.map.qq.com/ws/place/v1/suggestion?keyword=${encodedKeyword}&key=${TENCENT_MAP_KEY}&output=jsonp`
|
|
70
|
+
return fetchMapService<SuggestionResponse>(url).then((res) => {
|
|
71
|
+
if (res.data) {
|
|
72
|
+
return res.data
|
|
73
|
+
} else {
|
|
74
|
+
return []
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|