@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,190 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form, Input, Select, Tabs, Button } from 'antd'
|
|
3
|
+
import { MonacoInput } from '@formily-design/react-settings-form'
|
|
4
|
+
import { TextWidget } from '@formily-design/react'
|
|
5
|
+
import './styles.less'
|
|
6
|
+
|
|
7
|
+
export interface IRequestPanelProps {
|
|
8
|
+
form?: any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const RequestPanel: React.FC<IRequestPanelProps> = () => {
|
|
12
|
+
const tabsItems = [
|
|
13
|
+
{
|
|
14
|
+
key: 'basic',
|
|
15
|
+
label: <TextWidget token="SettingComponents.RemoteDataSource.basic" />,
|
|
16
|
+
children: (
|
|
17
|
+
<div className="request-panel-section">
|
|
18
|
+
<Form.Item
|
|
19
|
+
label={
|
|
20
|
+
<TextWidget token="SettingComponents.RemoteDataSource.url" />
|
|
21
|
+
}
|
|
22
|
+
name="url"
|
|
23
|
+
rules={[{ required: true, message: '请输入请求地址' }]}
|
|
24
|
+
>
|
|
25
|
+
<Input placeholder="https://api.example.com/data" />
|
|
26
|
+
</Form.Item>
|
|
27
|
+
<Form.Item
|
|
28
|
+
label={
|
|
29
|
+
<TextWidget token="SettingComponents.RemoteDataSource.method" />
|
|
30
|
+
}
|
|
31
|
+
name="method"
|
|
32
|
+
initialValue="POST"
|
|
33
|
+
>
|
|
34
|
+
<Select
|
|
35
|
+
options={[
|
|
36
|
+
{ label: 'GET', value: 'GET' },
|
|
37
|
+
{ label: 'POST', value: 'POST' },
|
|
38
|
+
{ label: 'PUT', value: 'PUT' },
|
|
39
|
+
{ label: 'DELETE', value: 'DELETE' },
|
|
40
|
+
{ label: 'PATCH', value: 'PATCH' },
|
|
41
|
+
]}
|
|
42
|
+
/>
|
|
43
|
+
</Form.Item>
|
|
44
|
+
<Form.Item
|
|
45
|
+
label={
|
|
46
|
+
<TextWidget token="SettingComponents.ClickEventSetter.successMessage" />
|
|
47
|
+
}
|
|
48
|
+
name="successMessage"
|
|
49
|
+
>
|
|
50
|
+
<Input placeholder="请输入成功提示文案(可选)" />
|
|
51
|
+
</Form.Item>
|
|
52
|
+
</div>
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'headers',
|
|
57
|
+
label: <TextWidget token="SettingComponents.RemoteDataSource.headers" />,
|
|
58
|
+
children: (
|
|
59
|
+
<div className="request-panel-section">
|
|
60
|
+
<Form.List name="headers">
|
|
61
|
+
{(fields, { add, remove }) => (
|
|
62
|
+
<>
|
|
63
|
+
{fields.map((field) => (
|
|
64
|
+
<div key={field.key} className="request-panel-row">
|
|
65
|
+
<Form.Item
|
|
66
|
+
{...field}
|
|
67
|
+
label=""
|
|
68
|
+
style={{ marginBottom: 0 }}
|
|
69
|
+
name={[field.name, 'key']}
|
|
70
|
+
>
|
|
71
|
+
<Input placeholder="Key" style={{ width: '45%' }} />
|
|
72
|
+
</Form.Item>
|
|
73
|
+
<span style={{ margin: '0 8px' }}>-</span>
|
|
74
|
+
<Form.Item
|
|
75
|
+
style={{ marginBottom: 0 }}
|
|
76
|
+
name={[field.name, 'value']}
|
|
77
|
+
>
|
|
78
|
+
<Input placeholder="Value" style={{ width: '45%' }} />
|
|
79
|
+
</Form.Item>
|
|
80
|
+
<Button
|
|
81
|
+
type="text"
|
|
82
|
+
danger
|
|
83
|
+
onClick={() => remove(field.name)}
|
|
84
|
+
style={{ marginLeft: 8 }}
|
|
85
|
+
>
|
|
86
|
+
X
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
))}
|
|
90
|
+
<Button
|
|
91
|
+
type="dashed"
|
|
92
|
+
onClick={() => add({ key: '', value: '' })}
|
|
93
|
+
block
|
|
94
|
+
>
|
|
95
|
+
<TextWidget token="SettingComponents.RemoteDataSource.addHeader" />
|
|
96
|
+
</Button>
|
|
97
|
+
</>
|
|
98
|
+
)}
|
|
99
|
+
</Form.List>
|
|
100
|
+
</div>
|
|
101
|
+
),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: 'params',
|
|
105
|
+
label: <TextWidget token="SettingComponents.RemoteDataSource.params" />,
|
|
106
|
+
children: (
|
|
107
|
+
<div className="request-panel-section">
|
|
108
|
+
<Form.List name="params">
|
|
109
|
+
{(fields, { add, remove }) => (
|
|
110
|
+
<>
|
|
111
|
+
{fields.map((field) => (
|
|
112
|
+
<div key={field.key} className="request-panel-row">
|
|
113
|
+
<Form.Item
|
|
114
|
+
{...field}
|
|
115
|
+
label=""
|
|
116
|
+
style={{ marginBottom: 0 }}
|
|
117
|
+
name={[field.name, 'key']}
|
|
118
|
+
>
|
|
119
|
+
<Input placeholder="参数名" style={{ width: '45%' }} />
|
|
120
|
+
</Form.Item>
|
|
121
|
+
<span style={{ margin: '0 8px' }}>-</span>
|
|
122
|
+
<Form.Item
|
|
123
|
+
style={{ marginBottom: 0 }}
|
|
124
|
+
name={[field.name, 'value']}
|
|
125
|
+
>
|
|
126
|
+
<Input placeholder="表单字段" style={{ width: '45%' }} />
|
|
127
|
+
</Form.Item>
|
|
128
|
+
<Button
|
|
129
|
+
type="text"
|
|
130
|
+
danger
|
|
131
|
+
onClick={() => remove(field.name)}
|
|
132
|
+
style={{ marginLeft: 8 }}
|
|
133
|
+
>
|
|
134
|
+
X
|
|
135
|
+
</Button>
|
|
136
|
+
</div>
|
|
137
|
+
))}
|
|
138
|
+
<Button
|
|
139
|
+
type="dashed"
|
|
140
|
+
onClick={() => add({ key: '', field: '' })}
|
|
141
|
+
block
|
|
142
|
+
>
|
|
143
|
+
<TextWidget token="SettingComponents.RemoteDataSource.addParam" />
|
|
144
|
+
</Button>
|
|
145
|
+
</>
|
|
146
|
+
)}
|
|
147
|
+
</Form.List>
|
|
148
|
+
</div>
|
|
149
|
+
),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: 'handlers',
|
|
153
|
+
label: <TextWidget token="SettingComponents.RemoteDataSource.handlers" />,
|
|
154
|
+
children: (
|
|
155
|
+
<div className="request-panel-section">
|
|
156
|
+
<Form.Item
|
|
157
|
+
label={
|
|
158
|
+
<TextWidget token="SettingComponents.RemoteDataSource.beforeRequest" />
|
|
159
|
+
}
|
|
160
|
+
name="beforeRequest"
|
|
161
|
+
>
|
|
162
|
+
<MonacoInput
|
|
163
|
+
language="javascript.expression"
|
|
164
|
+
height={120}
|
|
165
|
+
helpLink={false}
|
|
166
|
+
/>
|
|
167
|
+
</Form.Item>
|
|
168
|
+
<Form.Item
|
|
169
|
+
label={
|
|
170
|
+
<TextWidget token="SettingComponents.RemoteDataSource.dataHandler" />
|
|
171
|
+
}
|
|
172
|
+
name="dataHandler"
|
|
173
|
+
>
|
|
174
|
+
<MonacoInput
|
|
175
|
+
language="javascript.expression"
|
|
176
|
+
height={120}
|
|
177
|
+
helpLink={false}
|
|
178
|
+
/>
|
|
179
|
+
</Form.Item>
|
|
180
|
+
</div>
|
|
181
|
+
),
|
|
182
|
+
},
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div className="request-panel">
|
|
187
|
+
<Tabs items={tabsItems} defaultActiveKey="basic" size="small" />
|
|
188
|
+
</div>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { Fragment, useState, useMemo } from 'react'
|
|
2
|
+
import { Modal, Button } from 'antd'
|
|
3
|
+
import { usePrefix, TextWidget } from '@formily-design/react'
|
|
4
|
+
import { IEventAction, IEventConfig } from './types'
|
|
5
|
+
import { ActionList } from './ActionList'
|
|
6
|
+
import { ActionConfigModal } from './ActionConfigModal'
|
|
7
|
+
import './styles.less'
|
|
8
|
+
|
|
9
|
+
export interface IClickEventSetterProps {
|
|
10
|
+
className?: string
|
|
11
|
+
style?: React.CSSProperties
|
|
12
|
+
onChange: (value: IEventConfig) => void
|
|
13
|
+
value?: IEventConfig
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ClickEventSetter: React.FC<IClickEventSetterProps> = (props) => {
|
|
17
|
+
const { value, onChange } = props
|
|
18
|
+
const prefix = usePrefix('click-event-setter')
|
|
19
|
+
const [modalVisible, setModalVisible] = useState(false)
|
|
20
|
+
const [editingAction, setEditingAction] = useState<IEventAction | null>(null)
|
|
21
|
+
const [editingIndex, setEditingIndex] = useState<number>(-1)
|
|
22
|
+
|
|
23
|
+
const actions = useMemo(() => value?.actions || [], [value])
|
|
24
|
+
|
|
25
|
+
const openModal = () => setModalVisible(true)
|
|
26
|
+
const closeModal = () => {
|
|
27
|
+
setModalVisible(false)
|
|
28
|
+
setEditingAction(null)
|
|
29
|
+
setEditingIndex(-1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const handleEditAction = (action: IEventAction, index: number) => {
|
|
33
|
+
setEditingAction(action)
|
|
34
|
+
setEditingIndex(index)
|
|
35
|
+
setModalVisible(true)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const handleDeleteAction = (index: number) => {
|
|
39
|
+
const newActions = [...actions]
|
|
40
|
+
newActions.splice(index, 1)
|
|
41
|
+
onChange({ actions: newActions })
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const handleSaveAction = (action: IEventAction) => {
|
|
45
|
+
const newActions = [...actions]
|
|
46
|
+
if (editingIndex >= 0) {
|
|
47
|
+
newActions[editingIndex] = action
|
|
48
|
+
} else {
|
|
49
|
+
newActions.push(action)
|
|
50
|
+
}
|
|
51
|
+
onChange({ actions: newActions })
|
|
52
|
+
closeModal()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Fragment>
|
|
57
|
+
<div className={`${prefix}-container`}>
|
|
58
|
+
<Button block onClick={openModal} className={`${prefix}-trigger`}>
|
|
59
|
+
<TextWidget token="SettingComponents.ClickEventSetter.configureEvents" />
|
|
60
|
+
</Button>
|
|
61
|
+
{actions.length > 0 && (
|
|
62
|
+
<ActionList
|
|
63
|
+
actions={actions}
|
|
64
|
+
onEdit={handleEditAction}
|
|
65
|
+
onDelete={handleDeleteAction}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
<Modal
|
|
70
|
+
title={
|
|
71
|
+
<TextWidget token="SettingComponents.ClickEventSetter.configureEvents" />
|
|
72
|
+
}
|
|
73
|
+
width={700}
|
|
74
|
+
styles={{ body: { padding: 10 } }}
|
|
75
|
+
transitionName=""
|
|
76
|
+
maskTransitionName=""
|
|
77
|
+
open={modalVisible}
|
|
78
|
+
onCancel={closeModal}
|
|
79
|
+
footer={null}
|
|
80
|
+
destroyOnClose
|
|
81
|
+
>
|
|
82
|
+
<ActionConfigModal
|
|
83
|
+
editingAction={editingAction}
|
|
84
|
+
onSave={handleSaveAction}
|
|
85
|
+
onCancel={closeModal}
|
|
86
|
+
/>
|
|
87
|
+
</Modal>
|
|
88
|
+
</Fragment>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @click-event-setter-prefix: ~'click-event-setter';
|
|
2
|
+
@click-event-setter-prefix: 'dn-click-event-setter';
|
|
3
|
+
|
|
4
|
+
.dn-click-event-setter-container {
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.dn-click-event-setter-trigger {
|
|
9
|
+
margin-bottom: 8px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* Action List Styles */
|
|
13
|
+
.click-event-action-list {
|
|
14
|
+
width: 100%;
|
|
15
|
+
border: 1px solid #e8e8e8;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
|
|
18
|
+
.click-event-action-item {
|
|
19
|
+
padding: 4px;
|
|
20
|
+
border-bottom: 1px solid #f0f0f0;
|
|
21
|
+
word-break: break-all;
|
|
22
|
+
|
|
23
|
+
&:last-child {
|
|
24
|
+
border-bottom: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ant-list-item-action {
|
|
28
|
+
margin-inline-start: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.click-event-action-title {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: 2px;
|
|
35
|
+
|
|
36
|
+
.click-event-action-description {
|
|
37
|
+
color: #666;
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
max-width: 300px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Action Config Modal Styles */
|
|
49
|
+
.action-config-modal {
|
|
50
|
+
.action-config-basic {
|
|
51
|
+
padding: 8px 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.action-config-panel {
|
|
55
|
+
padding: 8px 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.action-config-footer {
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: flex-end;
|
|
61
|
+
gap: 8px;
|
|
62
|
+
margin-top: 16px;
|
|
63
|
+
padding-top: 16px;
|
|
64
|
+
border-top: 1px solid #f0f0f0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Request Panel Styles */
|
|
69
|
+
.request-panel {
|
|
70
|
+
&-section {
|
|
71
|
+
padding: 8px 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&-row {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
margin-bottom: 8px;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Navigation Panel Styles */
|
|
82
|
+
.navigation-panel {
|
|
83
|
+
padding: 8px 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Download Panel Styles */
|
|
87
|
+
.download-panel {
|
|
88
|
+
padding: 8px 0;
|
|
89
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// 事件动作类型
|
|
2
|
+
export type EventActionType = 'navigation' | 'request' | 'download'
|
|
3
|
+
|
|
4
|
+
// 事件配置结构
|
|
5
|
+
export interface IEventConfig {
|
|
6
|
+
actions: IEventAction[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 单个事件动作基础接口
|
|
10
|
+
export interface IEventActionBase {
|
|
11
|
+
id: string
|
|
12
|
+
type: EventActionType
|
|
13
|
+
description?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 页面跳转动作
|
|
17
|
+
export interface INavigationAction extends IEventActionBase {
|
|
18
|
+
type: 'navigation'
|
|
19
|
+
url: string
|
|
20
|
+
target?: '_blank' | '_self'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 服务请求动作
|
|
24
|
+
export interface IRequestAction extends IEventActionBase {
|
|
25
|
+
type: 'request'
|
|
26
|
+
url: string
|
|
27
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
|
|
28
|
+
headers?: Record<string, string>
|
|
29
|
+
params?: Record<string, string>
|
|
30
|
+
beforeRequest?: string
|
|
31
|
+
dataHandler?: string
|
|
32
|
+
successMessage?: string
|
|
33
|
+
dataKey?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 下载文件动作
|
|
37
|
+
export interface IDownloadAction extends IEventActionBase {
|
|
38
|
+
type: 'download'
|
|
39
|
+
url: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 联合类型
|
|
43
|
+
export type IEventAction = INavigationAction | IRequestAction | IDownloadAction
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { DnFC } from '@formily-design/react'
|
|
3
|
+
import { Button as AntButton, ButtonProps } from 'antd'
|
|
4
|
+
import { Reset, Submit } from '@formily/antd-v5'
|
|
5
|
+
import { useForm, observer, useExpressionScope } from '@formily/react'
|
|
6
|
+
import { IEventAction } from '../ClickEventSetter/types'
|
|
7
|
+
import {
|
|
8
|
+
useEventActionExecutor,
|
|
9
|
+
hasActionOfType,
|
|
10
|
+
} from './hooks/useEventActionExecutor'
|
|
11
|
+
|
|
12
|
+
interface IFormButtonSetterProps {
|
|
13
|
+
/** 是否禁用表单验证 */
|
|
14
|
+
noValidate?: boolean
|
|
15
|
+
/** 事件配置 */
|
|
16
|
+
onEvent?: {
|
|
17
|
+
/** 点击事件配置 */
|
|
18
|
+
click?: {
|
|
19
|
+
/** 点击事件动作列表 */
|
|
20
|
+
actions: IEventAction[]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IFormButtonProps extends IFormButtonSetterProps, ButtonProps {
|
|
26
|
+
onClick?: (e: React.MouseEvent<Element, MouseEvent>) => void
|
|
27
|
+
title?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const FormButton: DnFC<IFormButtonProps> = (props: IFormButtonProps) => {
|
|
31
|
+
const { htmlType } = props
|
|
32
|
+
|
|
33
|
+
if (htmlType === 'reset')
|
|
34
|
+
return <ResetButton {...props}>{props.title}</ResetButton>
|
|
35
|
+
if (htmlType === 'submit')
|
|
36
|
+
return <SubmitButton {...props}>{props.title}</SubmitButton>
|
|
37
|
+
return <Button {...props}>{props.title}</Button>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 获取点击事件动作列表
|
|
42
|
+
*/
|
|
43
|
+
function getClickActions(
|
|
44
|
+
onEvent?: IFormButtonSetterProps['onEvent']
|
|
45
|
+
): IEventAction[] | undefined {
|
|
46
|
+
return onEvent?.click?.actions
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 重置
|
|
51
|
+
* 为什么使用 observer 包裹?
|
|
52
|
+
* 因为 useForm() 获取的 form 实例是响应式的,observer 可以确保组件在 form 状态变化时重新渲染。使用 connect 或 observer 都可以达到这个目的。
|
|
53
|
+
* https://react.formilyjs.org/zh-CN/api/shared/observer
|
|
54
|
+
*/
|
|
55
|
+
const ResetButton = observer(
|
|
56
|
+
({
|
|
57
|
+
children,
|
|
58
|
+
onEvent,
|
|
59
|
+
...props
|
|
60
|
+
}: React.ComponentProps<typeof Reset> & IFormButtonSetterProps) => {
|
|
61
|
+
const form = useForm()
|
|
62
|
+
const actions = getClickActions(onEvent)
|
|
63
|
+
const { execute: executeEvents, executing } = useEventActionExecutor(
|
|
64
|
+
actions,
|
|
65
|
+
form
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
const handleClick = async () => {
|
|
69
|
+
if (actions && actions.length > 0) {
|
|
70
|
+
await executeEvents()
|
|
71
|
+
}
|
|
72
|
+
// 执行表单重置
|
|
73
|
+
form.reset()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Reset
|
|
78
|
+
{...props}
|
|
79
|
+
htmlType="button"
|
|
80
|
+
loading={executing}
|
|
81
|
+
onClick={handleClick}
|
|
82
|
+
>
|
|
83
|
+
{children}
|
|
84
|
+
</Reset>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
/** 提交 */
|
|
90
|
+
const SubmitButton = observer(
|
|
91
|
+
({
|
|
92
|
+
children,
|
|
93
|
+
noValidate,
|
|
94
|
+
onEvent,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentProps<typeof Submit> & IFormButtonSetterProps) => {
|
|
97
|
+
const form = useForm()
|
|
98
|
+
const actions = getClickActions(onEvent)
|
|
99
|
+
const hasRequestAction = hasActionOfType(actions, 'request')
|
|
100
|
+
const { execute: executeEvents, executing } = useEventActionExecutor(
|
|
101
|
+
actions,
|
|
102
|
+
form
|
|
103
|
+
)
|
|
104
|
+
// useExpressionScope 读取表达式作用域,获取表单配置的提交 API submitFormApi
|
|
105
|
+
const { submitFormApi, apiParams } = useExpressionScope()
|
|
106
|
+
const handleClick = async () => {
|
|
107
|
+
if (noValidate) {
|
|
108
|
+
// 获取表单值
|
|
109
|
+
const values = form.values
|
|
110
|
+
// 手动更新表单状态为提交中
|
|
111
|
+
form.setSubmitting(true)
|
|
112
|
+
try {
|
|
113
|
+
if (hasRequestAction) {
|
|
114
|
+
// 有 request 动作时,仅执行事件动作,不执行表单提交
|
|
115
|
+
await executeEvents(values, apiParams)
|
|
116
|
+
} else if (actions && actions.length > 0) {
|
|
117
|
+
// 有事件但无 request 动作时,先执行事件再提交
|
|
118
|
+
await executeEvents(values, apiParams)
|
|
119
|
+
await doSubmit(values)
|
|
120
|
+
} else {
|
|
121
|
+
// 无事件配置时,直接提交
|
|
122
|
+
await doSubmit(values)
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
form.setSubmitting(false)
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
form.submit(async (values) => {
|
|
129
|
+
if (hasRequestAction) {
|
|
130
|
+
// 有 request 动作时,仅执行事件动作,不执行表单提交
|
|
131
|
+
await executeEvents(values, apiParams)
|
|
132
|
+
} else if (actions && actions.length > 0) {
|
|
133
|
+
// 有事件但无 request 动作时,先执行事件再提交
|
|
134
|
+
await executeEvents(values, apiParams)
|
|
135
|
+
await doSubmit(values)
|
|
136
|
+
} else {
|
|
137
|
+
// 无事件配置时,直接提交
|
|
138
|
+
await doSubmit(values)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** 表单提交 - 执行 form 配置的 API */
|
|
145
|
+
const doSubmit = async (values: Record<string, any>) => {
|
|
146
|
+
await submitFormApi?.(values)
|
|
147
|
+
}
|
|
148
|
+
return (
|
|
149
|
+
<Submit
|
|
150
|
+
{...props}
|
|
151
|
+
htmlType="button"
|
|
152
|
+
loading={executing || form.submitting}
|
|
153
|
+
onClick={handleClick}
|
|
154
|
+
>
|
|
155
|
+
{children}
|
|
156
|
+
</Submit>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
/** 按钮 */
|
|
162
|
+
const Button = observer(
|
|
163
|
+
({
|
|
164
|
+
children,
|
|
165
|
+
onEvent,
|
|
166
|
+
...props
|
|
167
|
+
}: React.ComponentProps<typeof AntButton> & IFormButtonSetterProps) => {
|
|
168
|
+
const form = useForm()
|
|
169
|
+
const actions = getClickActions(onEvent)
|
|
170
|
+
// useExpressionScope 读取表达式作用域
|
|
171
|
+
const { apiParams } = useExpressionScope()
|
|
172
|
+
const { execute: executeEvents, executing } = useEventActionExecutor(
|
|
173
|
+
actions,
|
|
174
|
+
form
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
const handleClick = async () => {
|
|
178
|
+
if (actions && actions.length > 0) {
|
|
179
|
+
await executeEvents(form.values, apiParams)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<AntButton {...props} loading={executing} onClick={handleClick}>
|
|
185
|
+
{children}
|
|
186
|
+
</AntButton>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react'
|
|
2
|
+
import { IEventAction } from '../../ClickEventSetter/types'
|
|
3
|
+
import { executeActions } from '../utils/actionExecutors'
|
|
4
|
+
import { Form } from '@formily/core'
|
|
5
|
+
|
|
6
|
+
interface UseEventActionExecutorOptions {
|
|
7
|
+
onComplete?: () => void
|
|
8
|
+
onError?: (error: Error) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface UseEventActionExecutorReturn {
|
|
12
|
+
executing: boolean
|
|
13
|
+
execute: (
|
|
14
|
+
formValues?: Record<string, any>,
|
|
15
|
+
apiParams?: Record<string, any>
|
|
16
|
+
) => Promise<void>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useEventActionExecutor(
|
|
20
|
+
actions: IEventAction[] | undefined,
|
|
21
|
+
form: Form,
|
|
22
|
+
options?: UseEventActionExecutorOptions
|
|
23
|
+
): UseEventActionExecutorReturn {
|
|
24
|
+
const [executing, setExecuting] = useState(false)
|
|
25
|
+
|
|
26
|
+
const execute = useCallback(
|
|
27
|
+
async (
|
|
28
|
+
formValues?: Record<string, any>,
|
|
29
|
+
apiParams?: Record<string, any>
|
|
30
|
+
) => {
|
|
31
|
+
if (!actions || actions.length === 0) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
setExecuting(true)
|
|
35
|
+
try {
|
|
36
|
+
await executeActions(actions, formValues, apiParams, (error, index) => {
|
|
37
|
+
console.error(`动作 ${index + 1} 执行失败:`, error)
|
|
38
|
+
})
|
|
39
|
+
options?.onComplete?.()
|
|
40
|
+
} catch (error) {
|
|
41
|
+
const err = error instanceof Error ? error : new Error(String(error))
|
|
42
|
+
options?.onError?.(err)
|
|
43
|
+
} finally {
|
|
44
|
+
setExecuting(false)
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[actions, form, options]
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
executing,
|
|
52
|
+
execute,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 检查动作配置中是否包含指定类型的动作
|
|
58
|
+
*/
|
|
59
|
+
export function hasActionOfType(
|
|
60
|
+
actions: IEventAction[] | undefined,
|
|
61
|
+
type: string
|
|
62
|
+
): boolean {
|
|
63
|
+
if (!actions) return false
|
|
64
|
+
return actions.some((action) => action.type === type)
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './preview'
|