@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,123 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import { GlobSync } from 'glob'
|
|
4
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
5
|
+
import autoprefixer from 'autoprefixer'
|
|
6
|
+
import yaml from 'js-yaml'
|
|
7
|
+
//import { getThemeVariables } from 'antd/dist/theme'
|
|
8
|
+
|
|
9
|
+
const getWorkspaceAlias = () => {
|
|
10
|
+
const basePath = path.resolve(__dirname, '../../../')
|
|
11
|
+
const results: Record<string, string> = {}
|
|
12
|
+
|
|
13
|
+
const pkg = fs.readJSONSync(path.resolve(basePath, 'package.json')) || {}
|
|
14
|
+
|
|
15
|
+
let workspaces: string[] = []
|
|
16
|
+
|
|
17
|
+
if (Array.isArray(pkg.workspaces)) {
|
|
18
|
+
workspaces = pkg.workspaces
|
|
19
|
+
} else {
|
|
20
|
+
const pnpmWorkspacePath = path.resolve(basePath, 'pnpm-workspace.yaml')
|
|
21
|
+
if (fs.existsSync(pnpmWorkspacePath)) {
|
|
22
|
+
const pnpmWorkspace = yaml.load(
|
|
23
|
+
fs.readFileSync(pnpmWorkspacePath, 'utf-8')
|
|
24
|
+
) as { packages?: string[] }
|
|
25
|
+
workspaces = pnpmWorkspace.packages || []
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (workspaces.length > 0) {
|
|
30
|
+
workspaces.forEach((pattern) => {
|
|
31
|
+
const { found } = new GlobSync(pattern, { cwd: basePath })
|
|
32
|
+
found.forEach((name) => {
|
|
33
|
+
const pkgJson = fs.readJSONSync(
|
|
34
|
+
path.resolve(basePath, name, './package.json')
|
|
35
|
+
)
|
|
36
|
+
results[pkgJson.name] = path.resolve(basePath, name, './src')
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const currentPkg = fs.readJSONSync(path.resolve(__dirname, '../package.json'))
|
|
42
|
+
results[currentPkg.name] = path.resolve(__dirname, '../src')
|
|
43
|
+
|
|
44
|
+
return results
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
mode: 'development',
|
|
49
|
+
devtool: 'inline-source-map', // 嵌入到源文件中
|
|
50
|
+
stats: {
|
|
51
|
+
entrypoints: false,
|
|
52
|
+
children: false,
|
|
53
|
+
},
|
|
54
|
+
entry: {
|
|
55
|
+
playground: path.resolve(__dirname, './main'),
|
|
56
|
+
},
|
|
57
|
+
output: {
|
|
58
|
+
path: path.resolve(__dirname, '../build'),
|
|
59
|
+
filename: '[name].[hash].bundle.js',
|
|
60
|
+
},
|
|
61
|
+
resolve: {
|
|
62
|
+
modules: [path.resolve(__dirname, '../../../node_modules'), 'node_modules'],
|
|
63
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.mjs'],
|
|
64
|
+
alias: getWorkspaceAlias(),
|
|
65
|
+
},
|
|
66
|
+
module: {
|
|
67
|
+
rules: [
|
|
68
|
+
{
|
|
69
|
+
test: /\.tsx?$/,
|
|
70
|
+
use: [
|
|
71
|
+
{
|
|
72
|
+
loader: require.resolve('ts-loader'),
|
|
73
|
+
options: {
|
|
74
|
+
transpileOnly: true,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
test: /\.css$/,
|
|
81
|
+
use: [MiniCssExtractPlugin.loader, require.resolve('css-loader')],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
test: /\.less$/,
|
|
85
|
+
use: [
|
|
86
|
+
MiniCssExtractPlugin.loader,
|
|
87
|
+
{ loader: 'css-loader' },
|
|
88
|
+
{
|
|
89
|
+
loader: 'postcss-loader',
|
|
90
|
+
options: {
|
|
91
|
+
plugins: () => autoprefixer(),
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
loader: 'less-loader',
|
|
96
|
+
options: {
|
|
97
|
+
// modifyVars: getThemeVariables({
|
|
98
|
+
// dark: true, // 开启暗黑模式
|
|
99
|
+
// }),
|
|
100
|
+
javascriptEnabled: true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
test: /\.(woff|woff2|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
107
|
+
use: ['url-loader'],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
test: /\.html?$/,
|
|
111
|
+
loader: require.resolve('file-loader'),
|
|
112
|
+
options: {
|
|
113
|
+
name: '[name].[ext]',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
test: /\.mjs$/,
|
|
118
|
+
include: /node_modules/,
|
|
119
|
+
type: 'javascript/auto',
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import baseConfig from './webpack.base'
|
|
2
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
4
|
+
import MonacoPlugin from 'monaco-editor-webpack-plugin'
|
|
5
|
+
//import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
|
6
|
+
import webpack from 'webpack'
|
|
7
|
+
import path from 'path'
|
|
8
|
+
|
|
9
|
+
const PORT = 3001
|
|
10
|
+
|
|
11
|
+
const createPages = (pages) => {
|
|
12
|
+
return pages.map(({ filename, template, chunk }) => {
|
|
13
|
+
return new HtmlWebpackPlugin({
|
|
14
|
+
filename,
|
|
15
|
+
template,
|
|
16
|
+
inject: 'body',
|
|
17
|
+
chunks: chunk,
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
for (const key in baseConfig.entry) {
|
|
23
|
+
if (Array.isArray(baseConfig.entry[key])) {
|
|
24
|
+
baseConfig.entry[key].push(
|
|
25
|
+
require.resolve('webpack/hot/dev-server'),
|
|
26
|
+
`${require.resolve('webpack-dev-server/client')}?http://localhost:${PORT}`
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
...baseConfig,
|
|
33
|
+
plugins: [
|
|
34
|
+
new MiniCssExtractPlugin({
|
|
35
|
+
filename: '[name].[hash].css',
|
|
36
|
+
chunkFilename: '[id].[hash].css',
|
|
37
|
+
}),
|
|
38
|
+
...createPages([
|
|
39
|
+
{
|
|
40
|
+
filename: 'index.html',
|
|
41
|
+
template: path.resolve(__dirname, './template.ejs'),
|
|
42
|
+
chunk: ['playground'],
|
|
43
|
+
},
|
|
44
|
+
]),
|
|
45
|
+
new webpack.HotModuleReplacementPlugin(),
|
|
46
|
+
new MonacoPlugin({
|
|
47
|
+
languages: ['json'],
|
|
48
|
+
}),
|
|
49
|
+
// new BundleAnalyzerPlugin()
|
|
50
|
+
],
|
|
51
|
+
devServer: {
|
|
52
|
+
host: '127.0.0.1',
|
|
53
|
+
open: true,
|
|
54
|
+
port: PORT,
|
|
55
|
+
proxy: {
|
|
56
|
+
'/apimap': {
|
|
57
|
+
target: 'https://apis.map.qq.com/ws',
|
|
58
|
+
changeOrigin: true,
|
|
59
|
+
secure: false,
|
|
60
|
+
pathRewrite: { '^/apimap': '' },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import baseConfig from './webpack.base'
|
|
2
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
3
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
4
|
+
import MonacoPlugin from 'monaco-editor-webpack-plugin'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
|
|
7
|
+
const createPages = (pages) => {
|
|
8
|
+
return pages.map(({ filename, template, chunk }) => {
|
|
9
|
+
return new HtmlWebpackPlugin({
|
|
10
|
+
filename,
|
|
11
|
+
template,
|
|
12
|
+
inject: 'body',
|
|
13
|
+
chunks: chunk,
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
...baseConfig,
|
|
20
|
+
mode: 'production',
|
|
21
|
+
plugins: [
|
|
22
|
+
new MiniCssExtractPlugin({
|
|
23
|
+
filename: '[name].[hash].css',
|
|
24
|
+
chunkFilename: '[id].[hash].css',
|
|
25
|
+
}),
|
|
26
|
+
...createPages([
|
|
27
|
+
{
|
|
28
|
+
filename: 'index.html',
|
|
29
|
+
template: path.resolve(__dirname, './template.ejs'),
|
|
30
|
+
chunk: ['playground'],
|
|
31
|
+
},
|
|
32
|
+
]),
|
|
33
|
+
new MonacoPlugin({
|
|
34
|
+
languages: ['json'],
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
optimization: {
|
|
38
|
+
minimize: true,
|
|
39
|
+
},
|
|
40
|
+
externals: {
|
|
41
|
+
react: 'React',
|
|
42
|
+
'react-dom': 'ReactDOM',
|
|
43
|
+
moment: 'moment',
|
|
44
|
+
antd: 'antd',
|
|
45
|
+
},
|
|
46
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { Space, Button, Radio } from 'antd'
|
|
3
|
+
import { GithubOutlined } from '@ant-design/icons'
|
|
4
|
+
import { useDesigner, TextWidget } from '@formily-design/react'
|
|
5
|
+
import { GlobalRegistry } from '@formily-design/core'
|
|
6
|
+
import { observer } from '@formily/react'
|
|
7
|
+
import { loadInitialSchema, saveSchema } from '../service'
|
|
8
|
+
|
|
9
|
+
export const ActionsWidget = observer(() => {
|
|
10
|
+
const designer = useDesigner()
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
loadInitialSchema(designer)
|
|
13
|
+
}, [])
|
|
14
|
+
const supportLocales = ['zh-cn', 'en-us', 'ko-kr']
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!supportLocales.includes(GlobalRegistry.getDesignerLanguage())) {
|
|
17
|
+
GlobalRegistry.setDesignerLanguage('zh-cn')
|
|
18
|
+
}
|
|
19
|
+
}, [])
|
|
20
|
+
return (
|
|
21
|
+
<Space style={{ marginRight: 10 }}>
|
|
22
|
+
<Button href="https://designable-fusion.formilyjs.org">
|
|
23
|
+
Alibaba Fusion
|
|
24
|
+
</Button>
|
|
25
|
+
<Radio.Group
|
|
26
|
+
value={GlobalRegistry.getDesignerLanguage()}
|
|
27
|
+
optionType="button"
|
|
28
|
+
options={[
|
|
29
|
+
{ label: 'English', value: 'en-us' },
|
|
30
|
+
{ label: '简体中文', value: 'zh-cn' },
|
|
31
|
+
{ label: '한국어', value: 'ko-kr' },
|
|
32
|
+
]}
|
|
33
|
+
onChange={(e) => {
|
|
34
|
+
GlobalRegistry.setDesignerLanguage(e.target.value)
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
<Button href="https://github.com/alibaba/designable" target="_blank">
|
|
38
|
+
<GithubOutlined />
|
|
39
|
+
Github
|
|
40
|
+
</Button>
|
|
41
|
+
<Button
|
|
42
|
+
onClick={() => {
|
|
43
|
+
saveSchema(designer)
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<TextWidget>Save</TextWidget>
|
|
47
|
+
</Button>
|
|
48
|
+
<Button
|
|
49
|
+
type="primary"
|
|
50
|
+
onClick={() => {
|
|
51
|
+
saveSchema(designer)
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<TextWidget>Publish</TextWidget>
|
|
55
|
+
</Button>
|
|
56
|
+
</Space>
|
|
57
|
+
)
|
|
58
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useTheme } from '@formily-design/react'
|
|
3
|
+
|
|
4
|
+
const logo = {
|
|
5
|
+
dark: '//img.alicdn.com/imgextra/i2/O1CN01NTUDi81fHLQvZCPnc_!!6000000003981-55-tps-1141-150.svg',
|
|
6
|
+
light:
|
|
7
|
+
'//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const LogoWidget: React.FC = () => {
|
|
11
|
+
const url = logo[useTheme()]
|
|
12
|
+
return (
|
|
13
|
+
<div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
|
|
14
|
+
<img
|
|
15
|
+
src={url}
|
|
16
|
+
style={{ margin: '12px 8px', height: 18, width: 'auto' }}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { TreeNode } from '@formily-design/core'
|
|
3
|
+
import { MonacoInput } from '@formily-design/react-settings-form'
|
|
4
|
+
import { isEmpty, isPlainObj } from '@formily/shared'
|
|
5
|
+
|
|
6
|
+
export interface IMarkupSchemaWidgetProps {
|
|
7
|
+
tree: TreeNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const transformToMarkupSchemaCode = (tree: TreeNode) => {
|
|
11
|
+
const printAttribute = (node: TreeNode) => {
|
|
12
|
+
if (!node) return ''
|
|
13
|
+
const props = { ...node.props }
|
|
14
|
+
if (node.depth !== 0) {
|
|
15
|
+
props.name = node.props.name || node.id
|
|
16
|
+
}
|
|
17
|
+
return `${Object.keys(props)
|
|
18
|
+
.map((key) => {
|
|
19
|
+
if (
|
|
20
|
+
key === 'x-designable-id' ||
|
|
21
|
+
key === 'x-designable-source-name' ||
|
|
22
|
+
key === '_isJSONSchemaObject' ||
|
|
23
|
+
key === 'version' ||
|
|
24
|
+
key === 'type'
|
|
25
|
+
)
|
|
26
|
+
return ''
|
|
27
|
+
const value = props[key]
|
|
28
|
+
if (isPlainObj(value) && isEmpty(value)) return ''
|
|
29
|
+
if (typeof value === 'string') return `${key}="${value}"`
|
|
30
|
+
return `${key}={${JSON.stringify(value)}}`
|
|
31
|
+
})
|
|
32
|
+
.join(' ')}`
|
|
33
|
+
}
|
|
34
|
+
const printChildren = (node: TreeNode) => {
|
|
35
|
+
if (!node) return ''
|
|
36
|
+
return node.children
|
|
37
|
+
.map((child) => {
|
|
38
|
+
return printNode(child)
|
|
39
|
+
})
|
|
40
|
+
.join('')
|
|
41
|
+
}
|
|
42
|
+
const printTag = (node: TreeNode) => {
|
|
43
|
+
if (node.props.type === 'string') return 'SchemaField.String'
|
|
44
|
+
if (node.props.type === 'number') return 'SchemaField.Number'
|
|
45
|
+
if (node.props.type === 'boolean') return 'SchemaField.Boolean'
|
|
46
|
+
if (node.props.type === 'date') return 'SchemaField.Date'
|
|
47
|
+
if (node.props.type === 'datetime') return 'SchemaField.DateTime'
|
|
48
|
+
if (node.props.type === 'array') return 'SchemaField.Array'
|
|
49
|
+
if (node.props.type === 'object') return 'SchemaField.Object'
|
|
50
|
+
if (node.props.type === 'void') return 'SchemaField.Void'
|
|
51
|
+
return 'SchemaField.Markup'
|
|
52
|
+
}
|
|
53
|
+
const printNode = (node: TreeNode) => {
|
|
54
|
+
if (!node) return ''
|
|
55
|
+
return `<${printTag(node)} ${printAttribute(node)} ${
|
|
56
|
+
node.children.length
|
|
57
|
+
? `>${printChildren(node)}</${printTag(node)}>`
|
|
58
|
+
: '/>'
|
|
59
|
+
}`
|
|
60
|
+
}
|
|
61
|
+
const root = tree.find((child) => {
|
|
62
|
+
return child.componentName === 'Form' || child.componentName === 'Root'
|
|
63
|
+
})
|
|
64
|
+
return `import React, { useMemo } from 'react'
|
|
65
|
+
import { createForm } from '@formily/core'
|
|
66
|
+
import { createSchemaField } from '@formily/react'
|
|
67
|
+
import {
|
|
68
|
+
Form,
|
|
69
|
+
FormItem,
|
|
70
|
+
DatePicker,
|
|
71
|
+
Checkbox,
|
|
72
|
+
Cascader,
|
|
73
|
+
Editable,
|
|
74
|
+
Input,
|
|
75
|
+
NumberPicker,
|
|
76
|
+
Switch,
|
|
77
|
+
Password,
|
|
78
|
+
PreviewText,
|
|
79
|
+
Radio,
|
|
80
|
+
Reset,
|
|
81
|
+
Select,
|
|
82
|
+
Space,
|
|
83
|
+
Submit,
|
|
84
|
+
TimePicker,
|
|
85
|
+
Transfer,
|
|
86
|
+
TreeSelect,
|
|
87
|
+
Upload,
|
|
88
|
+
FormGrid,
|
|
89
|
+
FormLayout,
|
|
90
|
+
FormTab,
|
|
91
|
+
FormCollapse,
|
|
92
|
+
ArrayTable,
|
|
93
|
+
ArrayCards,
|
|
94
|
+
} from '@formily/antd-v5'
|
|
95
|
+
import { Card, Slider, Rate } from 'antd'
|
|
96
|
+
|
|
97
|
+
const Text: React.FC<{
|
|
98
|
+
value?: string
|
|
99
|
+
content?: string
|
|
100
|
+
mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p'
|
|
101
|
+
}> = ({ value, mode, content, ...props }) => {
|
|
102
|
+
const tagName = mode === 'normal' || !mode ? 'div' : mode
|
|
103
|
+
return React.createElement(tagName, props, value || content)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const SchemaField = createSchemaField({
|
|
107
|
+
components: {
|
|
108
|
+
Space,
|
|
109
|
+
FormGrid,
|
|
110
|
+
FormLayout,
|
|
111
|
+
FormTab,
|
|
112
|
+
FormCollapse,
|
|
113
|
+
ArrayTable,
|
|
114
|
+
ArrayCards,
|
|
115
|
+
FormItem,
|
|
116
|
+
DatePicker,
|
|
117
|
+
Checkbox,
|
|
118
|
+
Cascader,
|
|
119
|
+
Editable,
|
|
120
|
+
Input,
|
|
121
|
+
Text,
|
|
122
|
+
NumberPicker,
|
|
123
|
+
Switch,
|
|
124
|
+
Password,
|
|
125
|
+
PreviewText,
|
|
126
|
+
Radio,
|
|
127
|
+
Reset,
|
|
128
|
+
Select,
|
|
129
|
+
Submit,
|
|
130
|
+
TimePicker,
|
|
131
|
+
Transfer,
|
|
132
|
+
TreeSelect,
|
|
133
|
+
Upload,
|
|
134
|
+
Card,
|
|
135
|
+
Slider,
|
|
136
|
+
Rate,
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
export default ()=>{
|
|
141
|
+
const form = useMemo(() => createForm(), [])
|
|
142
|
+
|
|
143
|
+
return <Form form={form} ${printAttribute(root)}>
|
|
144
|
+
<SchemaField>
|
|
145
|
+
${printChildren(root)}
|
|
146
|
+
</SchemaField>
|
|
147
|
+
</Form>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
`
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export const MarkupSchemaWidget: React.FC<IMarkupSchemaWidgetProps> = (
|
|
154
|
+
props
|
|
155
|
+
) => {
|
|
156
|
+
return (
|
|
157
|
+
<MonacoInput
|
|
158
|
+
{...props}
|
|
159
|
+
options={{ readOnly: true }}
|
|
160
|
+
value={transformToMarkupSchemaCode(props.tree)}
|
|
161
|
+
language="typescript"
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react'
|
|
2
|
+
import { createForm, onFormSubmitSuccess } from '@formily/core'
|
|
3
|
+
import { connect, createSchemaField, mapProps } from '@formily/react'
|
|
4
|
+
import {
|
|
5
|
+
Form,
|
|
6
|
+
FormItem,
|
|
7
|
+
DatePicker,
|
|
8
|
+
Checkbox,
|
|
9
|
+
Cascader,
|
|
10
|
+
Editable,
|
|
11
|
+
Input,
|
|
12
|
+
NumberPicker,
|
|
13
|
+
Switch,
|
|
14
|
+
Password,
|
|
15
|
+
PreviewText,
|
|
16
|
+
Radio,
|
|
17
|
+
Reset,
|
|
18
|
+
Select,
|
|
19
|
+
Space,
|
|
20
|
+
Submit,
|
|
21
|
+
TimePicker,
|
|
22
|
+
Transfer,
|
|
23
|
+
TreeSelect,
|
|
24
|
+
Upload,
|
|
25
|
+
FormGrid,
|
|
26
|
+
FormLayout,
|
|
27
|
+
FormTab,
|
|
28
|
+
FormCollapse,
|
|
29
|
+
ArrayTable,
|
|
30
|
+
ArrayCards,
|
|
31
|
+
// FormButtonGroup,
|
|
32
|
+
FormProps,
|
|
33
|
+
} from '@formily/antd-v5'
|
|
34
|
+
import { Card, Slider, Rate, Spin } from 'antd'
|
|
35
|
+
import { TreeNode } from '@formily-design/core'
|
|
36
|
+
import { transformToSchema } from '@formily-design/formily-transformer'
|
|
37
|
+
import {
|
|
38
|
+
transformSchema,
|
|
39
|
+
executeFormApi,
|
|
40
|
+
IFormApiConfig,
|
|
41
|
+
getLocalStorageData,
|
|
42
|
+
} from '../utils'
|
|
43
|
+
import { FormButtonGroup } from '../components/FormButtonGroup/FormButtonGroup'
|
|
44
|
+
import { FormButton } from '../components/FormButton/FormButton'
|
|
45
|
+
import { LocationPicker } from '../components/LocationPicker/LocationPicker'
|
|
46
|
+
import { FormList } from '../components/FormList/FormList'
|
|
47
|
+
|
|
48
|
+
const Text: React.FC<{
|
|
49
|
+
value?: string
|
|
50
|
+
content?: string
|
|
51
|
+
mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p'
|
|
52
|
+
}> = ({ value, mode, content, ...props }) => {
|
|
53
|
+
const tagName = mode === 'normal' || !mode ? 'div' : mode
|
|
54
|
+
return React.createElement(tagName, props, value || content)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 重置 LocationPicker 组件属性
|
|
58
|
+
const LocationPickerComponent = connect(
|
|
59
|
+
LocationPicker,
|
|
60
|
+
mapProps((props) => {
|
|
61
|
+
return {
|
|
62
|
+
...props,
|
|
63
|
+
// 将组件值映射为业务字段
|
|
64
|
+
fieldNames: {
|
|
65
|
+
address: 'fullAddress',
|
|
66
|
+
lat: 'latitude',
|
|
67
|
+
lng: 'longitude',
|
|
68
|
+
...props.fieldNames,
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const SchemaField = createSchemaField({
|
|
75
|
+
components: {
|
|
76
|
+
Space,
|
|
77
|
+
FormGrid,
|
|
78
|
+
FormLayout,
|
|
79
|
+
FormTab,
|
|
80
|
+
FormCollapse,
|
|
81
|
+
ArrayTable,
|
|
82
|
+
ArrayCards,
|
|
83
|
+
FormItem,
|
|
84
|
+
DatePicker,
|
|
85
|
+
Checkbox,
|
|
86
|
+
Cascader,
|
|
87
|
+
Editable,
|
|
88
|
+
Input,
|
|
89
|
+
Text,
|
|
90
|
+
NumberPicker,
|
|
91
|
+
Switch,
|
|
92
|
+
Password,
|
|
93
|
+
PreviewText,
|
|
94
|
+
Radio,
|
|
95
|
+
Reset,
|
|
96
|
+
Select,
|
|
97
|
+
Submit,
|
|
98
|
+
TimePicker,
|
|
99
|
+
Transfer,
|
|
100
|
+
TreeSelect,
|
|
101
|
+
Upload,
|
|
102
|
+
Card,
|
|
103
|
+
Slider,
|
|
104
|
+
Rate,
|
|
105
|
+
FormButtonGroup,
|
|
106
|
+
FormButton,
|
|
107
|
+
LocationPicker: LocationPickerComponent,
|
|
108
|
+
FormList,
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
export interface IPreviewWidgetProps {
|
|
113
|
+
tree: TreeNode
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface IFormSetterProps extends FormProps {
|
|
117
|
+
api?: IFormApiConfig
|
|
118
|
+
initApi?: IFormApiConfig
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const PreviewWidget: React.FC<IPreviewWidgetProps> = (props) => {
|
|
122
|
+
const form = useMemo(
|
|
123
|
+
() =>
|
|
124
|
+
createForm({
|
|
125
|
+
/** effects 里可以配置各种逻辑,如:字段联动、事件监听、observable + reaction 组合的响应式状态 */
|
|
126
|
+
effects() {
|
|
127
|
+
/** 监听表单提交成功 */
|
|
128
|
+
onFormSubmitSuccess((form) => {
|
|
129
|
+
// 处理表单提交后返回页面逻辑
|
|
130
|
+
// console.log('onFormSubmitSuccess', form)
|
|
131
|
+
})
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
[]
|
|
135
|
+
)
|
|
136
|
+
const { form: transformForm, schema } = useMemo(
|
|
137
|
+
() => transformToSchema(props.tree),
|
|
138
|
+
[props.tree]
|
|
139
|
+
)
|
|
140
|
+
const [detailLoading, setDetailLoading] = useState(false)
|
|
141
|
+
const formProps = transformForm as IFormSetterProps
|
|
142
|
+
// 接口需要的业务参数
|
|
143
|
+
const apiParams = {}
|
|
144
|
+
const scope = {
|
|
145
|
+
/** 所有 localStorage 数据 */
|
|
146
|
+
$localStorage: getLocalStorageData(),
|
|
147
|
+
/** 表单请求接口需要的业务参数 */
|
|
148
|
+
apiParams,
|
|
149
|
+
/** 全局数据 */
|
|
150
|
+
$globalData: {
|
|
151
|
+
...apiParams,
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
// TODO: 需要添加业务数据参数判断
|
|
156
|
+
if (form && formProps.initApi) {
|
|
157
|
+
setDetailLoading(true)
|
|
158
|
+
// 加载初始数据
|
|
159
|
+
executeFormApi(formProps.initApi, {})
|
|
160
|
+
.then((data) => {
|
|
161
|
+
form.setInitialValues(data)
|
|
162
|
+
})
|
|
163
|
+
.finally(() => {
|
|
164
|
+
setDetailLoading(false)
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}, [form, formProps.initApi])
|
|
168
|
+
return (
|
|
169
|
+
<Spin spinning={detailLoading}>
|
|
170
|
+
<Form {...formProps} form={form}>
|
|
171
|
+
<SchemaField
|
|
172
|
+
schema={transformSchema(schema, { $globalData: scope.$globalData })}
|
|
173
|
+
scope={{
|
|
174
|
+
...scope,
|
|
175
|
+
/** 表单提交作用域表达式 - 执行 form 配置的 API */
|
|
176
|
+
submitFormApi: formProps.api
|
|
177
|
+
? (formValues: Record<string, any>) =>
|
|
178
|
+
executeFormApi(formProps.api, formValues, {
|
|
179
|
+
apiParams,
|
|
180
|
+
scope,
|
|
181
|
+
})
|
|
182
|
+
: undefined,
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
</Form>
|
|
186
|
+
</Spin>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
transformToSchema,
|
|
4
|
+
transformToTreeNode,
|
|
5
|
+
} from '@formily-design/formily-transformer'
|
|
6
|
+
import { TreeNode, ITreeNode } from '@formily-design/core'
|
|
7
|
+
import { MonacoInput } from '@formily-design/react-settings-form'
|
|
8
|
+
|
|
9
|
+
export interface ISchemaEditorWidgetProps {
|
|
10
|
+
tree: TreeNode
|
|
11
|
+
onChange?: (tree: ITreeNode) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const SchemaEditorWidget: React.FC<ISchemaEditorWidgetProps> = (
|
|
15
|
+
props
|
|
16
|
+
) => {
|
|
17
|
+
return (
|
|
18
|
+
<MonacoInput
|
|
19
|
+
{...props}
|
|
20
|
+
value={JSON.stringify(transformToSchema(props.tree), null, 2)}
|
|
21
|
+
onChange={(value) => {
|
|
22
|
+
props.onChange?.(transformToTreeNode(JSON.parse(value)))
|
|
23
|
+
}}
|
|
24
|
+
language="json"
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|