doui-react 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/LICENSE +21 -0
- package/README.md +28 -0
- package/es/api/component/class-name.d.ts +3 -0
- package/es/api/component/class-name.js +15 -0
- package/es/api/component/common.d.ts +22 -0
- package/es/api/component/common.js +144 -0
- package/es/api/component/dom.d.ts +2 -0
- package/es/api/component/dom.js +7 -0
- package/es/api/component/global-style.d.ts +3 -0
- package/es/api/component/global-style.js +16 -0
- package/es/api/component/index.d.ts +9 -0
- package/es/api/component/index.js +9 -0
- package/es/api/component/react-dom.d.ts +3 -0
- package/es/api/component/react-dom.js +72 -0
- package/es/api/component/sort.d.ts +2 -0
- package/es/api/component/sort.js +20 -0
- package/es/api/component/style.d.ts +4 -0
- package/es/api/component/style.js +33 -0
- package/es/api/component/url.d.ts +33 -0
- package/es/api/component/url.js +126 -0
- package/es/api/component/validate-input.d.ts +8 -0
- package/es/api/component/validate-input.js +16 -0
- package/es/api/index.d.ts +2 -0
- package/es/api/index.js +2 -0
- package/es/api/type/common.d.ts +24 -0
- package/es/api/type/common.js +1 -0
- package/es/api/type/index.d.ts +5 -0
- package/es/api/type/index.js +2 -0
- package/es/button/component/index.d.ts +2 -0
- package/es/button/component/index.js +87 -0
- package/es/button/index.d.ts +2 -0
- package/es/button/index.js +2 -0
- package/es/button/type/index.d.ts +31 -0
- package/es/button/type/index.js +1 -0
- package/es/checkbox/component/checkbox-group.d.ts +2 -0
- package/es/checkbox/component/checkbox-group.js +66 -0
- package/es/checkbox/component/checkbox.d.ts +2 -0
- package/es/checkbox/component/checkbox.js +8 -0
- package/es/checkbox/component/index.d.ts +2 -0
- package/es/checkbox/component/index.js +10 -0
- package/es/checkbox/component/use-checkbox.d.ts +12 -0
- package/es/checkbox/component/use-checkbox.js +43 -0
- package/es/checkbox/component/utils.d.ts +13 -0
- package/es/checkbox/component/utils.js +40 -0
- package/es/checkbox/index.d.ts +2 -0
- package/es/checkbox/index.js +2 -0
- package/es/checkbox/style/index.d.ts +5 -0
- package/es/checkbox/style/index.js +11 -0
- package/es/checkbox/type/index.d.ts +18 -0
- package/es/checkbox/type/index.js +1 -0
- package/es/config/index.d.ts +0 -0
- package/es/config/index.js +0 -0
- package/es/date-picker/component/index.d.ts +3 -0
- package/es/date-picker/component/index.js +38 -0
- package/es/date-picker/index.d.ts +2 -0
- package/es/date-picker/index.js +2 -0
- package/es/date-picker/style/index.d.ts +4 -0
- package/es/date-picker/style/index.js +7 -0
- package/es/date-picker/type/index.d.ts +21 -0
- package/es/date-picker/type/index.js +1 -0
- package/es/empty/component/index.d.ts +2 -0
- package/es/empty/component/index.js +17 -0
- package/es/empty/index.d.ts +2 -0
- package/es/empty/index.js +2 -0
- package/es/empty/type/index.d.ts +9 -0
- package/es/empty/type/index.js +1 -0
- package/es/form/component/constant.d.ts +15 -0
- package/es/form/component/constant.js +15 -0
- package/es/form/component/form-content.d.ts +10 -0
- package/es/form/component/form-content.js +280 -0
- package/es/form/component/form-item-map.d.ts +40 -0
- package/es/form/component/form-item-map.js +120 -0
- package/es/form/component/form-item.d.ts +7 -0
- package/es/form/component/form-item.js +219 -0
- package/es/form/component/form-list.d.ts +36 -0
- package/es/form/component/form-list.js +190 -0
- package/es/form/component/form.d.ts +2 -0
- package/es/form/component/form.js +40 -0
- package/es/form/component/index.d.ts +15 -0
- package/es/form/component/index.js +14 -0
- package/es/form/component/submit-button.d.ts +2 -0
- package/es/form/component/submit-button.js +47 -0
- package/es/form/component/use-debug.d.ts +1 -0
- package/es/form/component/use-debug.js +16 -0
- package/es/form/component/utils.d.ts +95 -0
- package/es/form/component/utils.js +435 -0
- package/es/form/component/validator-item.d.ts +7 -0
- package/es/form/component/validator-item.js +53 -0
- package/es/form/hook/index.d.ts +16 -0
- package/es/form/hook/index.js +116 -0
- package/es/form/hook/list-provider.d.ts +6 -0
- package/es/form/hook/list-provider.js +16 -0
- package/es/form/hook/provider.d.ts +23 -0
- package/es/form/hook/provider.js +21 -0
- package/es/form/hook/use-form.d.ts +2 -0
- package/es/form/hook/use-form.js +335 -0
- package/es/form/index.d.ts +3 -0
- package/es/form/index.js +3 -0
- package/es/form/style/form-item.d.ts +3 -0
- package/es/form/style/form-item.js +38 -0
- package/es/form/style/index.d.ts +7 -0
- package/es/form/style/index.js +13 -0
- package/es/form/type/form-item.d.ts +141 -0
- package/es/form/type/form-item.js +1 -0
- package/es/form/type/form-list.d.ts +91 -0
- package/es/form/type/form-list.js +1 -0
- package/es/form/type/index.d.ts +134 -0
- package/es/form/type/index.js +3 -0
- package/es/grid/component/index.d.ts +2 -0
- package/es/grid/component/index.js +76 -0
- package/es/grid/component/pagination.d.ts +50 -0
- package/es/grid/component/pagination.js +54 -0
- package/es/grid/component/utils.d.ts +2 -0
- package/es/grid/component/utils.js +7 -0
- package/es/grid/index.d.ts +2 -0
- package/es/grid/index.js +2 -0
- package/es/grid/style/index.d.ts +11 -0
- package/es/grid/style/index.js +26 -0
- package/es/grid/type/index.d.ts +67 -0
- package/es/grid/type/index.js +1 -0
- package/es/highlight-text/component/index.d.ts +2 -0
- package/es/highlight-text/component/index.js +71 -0
- package/es/highlight-text/index.d.ts +2 -0
- package/es/highlight-text/index.js +2 -0
- package/es/highlight-text/style/index.d.ts +4 -0
- package/es/highlight-text/style/index.js +7 -0
- package/es/highlight-text/type/index.d.ts +18 -0
- package/es/highlight-text/type/index.js +1 -0
- package/es/hooks/hook/common.d.ts +1 -0
- package/es/hooks/hook/common.js +12 -0
- package/es/hooks/hook/index.d.ts +7 -0
- package/es/hooks/hook/index.js +7 -0
- package/es/hooks/hook/use-debounce.d.ts +4 -0
- package/es/hooks/hook/use-debounce.js +23 -0
- package/es/hooks/hook/use-deep.d.ts +9 -0
- package/es/hooks/hook/use-deep.js +64 -0
- package/es/hooks/hook/use-fetch.d.ts +8 -0
- package/es/hooks/hook/use-fetch.js +164 -0
- package/es/hooks/hook/use-list-operation.d.ts +5 -0
- package/es/hooks/hook/use-list-operation.js +70 -0
- package/es/hooks/hook/use-loading.d.ts +7 -0
- package/es/hooks/hook/use-loading.js +59 -0
- package/es/hooks/hook/use-window-resize.d.ts +5 -0
- package/es/hooks/hook/use-window-resize.js +16 -0
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.js +2 -0
- package/es/hooks/type/index.d.ts +2 -0
- package/es/hooks/type/index.js +2 -0
- package/es/hooks/type/use-fetch.d.ts +31 -0
- package/es/hooks/type/use-fetch.js +1 -0
- package/es/hooks/type/use-list-operation.d.ts +34 -0
- package/es/hooks/type/use-list-operation.js +1 -0
- package/es/icon/component/down.d.ts +2 -0
- package/es/icon/component/down.js +42 -0
- package/es/icon/component/index.d.ts +2 -0
- package/es/icon/component/index.js +5 -0
- package/es/icon/component/up.d.ts +2 -0
- package/es/icon/component/up.js +41 -0
- package/es/icon/hook/index.d.ts +477 -0
- package/es/icon/hook/index.js +60 -0
- package/es/icon/index.d.ts +2 -0
- package/es/icon/index.js +2 -0
- package/es/icon/style/index.d.ts +4 -0
- package/es/icon/style/index.js +10 -0
- package/es/icon/type/index.d.ts +14 -0
- package/es/icon/type/index.js +1 -0
- package/es/index.d.ts +25 -0
- package/es/index.js +25 -0
- package/es/input/component/index.d.ts +12 -0
- package/es/input/component/index.js +25 -0
- package/es/input/component/input.d.ts +2 -0
- package/es/input/component/input.js +8 -0
- package/es/input/component/number.d.ts +4 -0
- package/es/input/component/number.js +50 -0
- package/es/input/component/password.d.ts +2 -0
- package/es/input/component/password.js +8 -0
- package/es/input/component/text-area.d.ts +2 -0
- package/es/input/component/text-area.js +16 -0
- package/es/input/component/utils.d.ts +15 -0
- package/es/input/component/utils.js +102 -0
- package/es/input/index.d.ts +2 -0
- package/es/input/index.js +2 -0
- package/es/input/style/index.d.ts +6 -0
- package/es/input/style/index.js +11 -0
- package/es/input/type/index.d.ts +41 -0
- package/es/input/type/index.js +1 -0
- package/es/modal-prompt/component/index.d.ts +5 -0
- package/es/modal-prompt/component/index.js +60 -0
- package/es/modal-prompt/component/open-loading.d.ts +2 -0
- package/es/modal-prompt/component/open-loading.js +21 -0
- package/es/modal-prompt/component/utils.d.ts +4 -0
- package/es/modal-prompt/component/utils.js +49 -0
- package/es/modal-prompt/index.d.ts +2 -0
- package/es/modal-prompt/index.js +2 -0
- package/es/modal-prompt/style/index.d.ts +5 -0
- package/es/modal-prompt/style/index.js +9 -0
- package/es/modal-prompt/type/index.d.ts +36 -0
- package/es/modal-prompt/type/index.js +1 -0
- package/es/open-modal/component/constant.d.ts +1 -0
- package/es/open-modal/component/constant.js +3 -0
- package/es/open-modal/component/footer.d.ts +2 -0
- package/es/open-modal/component/footer.js +34 -0
- package/es/open-modal/component/index.d.ts +4 -0
- package/es/open-modal/component/index.js +9 -0
- package/es/open-modal/component/modal.d.ts +10 -0
- package/es/open-modal/component/modal.js +37 -0
- package/es/open-modal/component/title.d.ts +6 -0
- package/es/open-modal/component/title.js +12 -0
- package/es/open-modal/component/use-modal.d.ts +14 -0
- package/es/open-modal/component/use-modal.js +177 -0
- package/es/open-modal/component/utils.d.ts +11 -0
- package/es/open-modal/component/utils.js +109 -0
- package/es/open-modal/hook/index.d.ts +7 -0
- package/es/open-modal/hook/index.js +17 -0
- package/es/open-modal/hook/use-modal.d.ts +6 -0
- package/es/open-modal/hook/use-modal.js +27 -0
- package/es/open-modal/index.d.ts +3 -0
- package/es/open-modal/index.js +3 -0
- package/es/open-modal/style/index.d.ts +5 -0
- package/es/open-modal/style/index.js +18 -0
- package/es/open-modal/style/wrap.d.ts +2 -0
- package/es/open-modal/style/wrap.js +6 -0
- package/es/open-modal/type/index.d.ts +91 -0
- package/es/open-modal/type/index.js +1 -0
- package/es/portal/component/index.d.ts +2 -0
- package/es/portal/component/index.js +40 -0
- package/es/portal/index.d.ts +2 -0
- package/es/portal/index.js +2 -0
- package/es/portal/type/index.d.ts +13 -0
- package/es/portal/type/index.js +1 -0
- package/es/radio/component/abstract-box.d.ts +380 -0
- package/es/radio/component/abstract-box.js +90 -0
- package/es/radio/component/index.d.ts +2 -0
- package/es/radio/component/index.js +10 -0
- package/es/radio/component/radio.d.ts +2 -0
- package/es/radio/component/radio.js +10 -0
- package/es/radio/component/redio-group.d.ts +2 -0
- package/es/radio/component/redio-group.js +50 -0
- package/es/radio/component/use-box-options.d.ts +6 -0
- package/es/radio/component/use-box-options.js +20 -0
- package/es/radio/component/use-radio.d.ts +23 -0
- package/es/radio/component/use-radio.js +21 -0
- package/es/radio/component/utils.d.ts +7 -0
- package/es/radio/component/utils.js +25 -0
- package/es/radio/index.d.ts +2 -0
- package/es/radio/index.js +2 -0
- package/es/radio/style/index.d.ts +7 -0
- package/es/radio/style/index.js +15 -0
- package/es/radio/type/index.d.ts +32 -0
- package/es/radio/type/index.js +1 -0
- package/es/select/component/constant.d.ts +1 -0
- package/es/select/component/constant.js +1 -0
- package/es/select/component/index.d.ts +3 -0
- package/es/select/component/index.js +16 -0
- package/es/select/component/loading.d.ts +1 -0
- package/es/select/component/loading.js +13 -0
- package/es/select/component/use-select-options.d.ts +11 -0
- package/es/select/component/use-select-options.js +80 -0
- package/es/select/component/use-select.d.ts +2 -0
- package/es/select/component/use-select.js +136 -0
- package/es/select/component/utils.d.ts +14 -0
- package/es/select/component/utils.js +142 -0
- package/es/select/index.d.ts +2 -0
- package/es/select/index.js +2 -0
- package/es/select/style/index.d.ts +4 -0
- package/es/select/style/index.js +7 -0
- package/es/select/type/index.d.ts +105 -0
- package/es/select/type/index.js +1 -0
- package/es/stack/component/center-stack.d.ts +2 -0
- package/es/stack/component/center-stack.js +32 -0
- package/es/stack/component/h-stack.d.ts +2 -0
- package/es/stack/component/h-stack.js +39 -0
- package/es/stack/component/index.d.ts +3 -0
- package/es/stack/component/index.js +3 -0
- package/es/stack/component/v-stack.d.ts +2 -0
- package/es/stack/component/v-stack.js +36 -0
- package/es/stack/index.d.ts +2 -0
- package/es/stack/index.js +2 -0
- package/es/stack/style/index.d.ts +21 -0
- package/es/stack/style/index.js +49 -0
- package/es/stack/type/index.d.ts +54 -0
- package/es/stack/type/index.js +1 -0
- package/es/switch/component/index.d.ts +2 -0
- package/es/switch/component/index.js +60 -0
- package/es/switch/index.d.ts +2 -0
- package/es/switch/index.js +2 -0
- package/es/switch/style/index.d.ts +5 -0
- package/es/switch/style/index.js +13 -0
- package/es/switch/type/index.d.ts +27 -0
- package/es/switch/type/index.js +1 -0
- package/es/table/component/action-button.d.ts +2 -0
- package/es/table/component/action-button.js +95 -0
- package/es/table/component/actions.d.ts +2 -0
- package/es/table/component/actions.js +35 -0
- package/es/table/component/constant.d.ts +1 -0
- package/es/table/component/constant.js +5 -0
- package/es/table/component/editor.d.ts +2 -0
- package/es/table/component/editor.js +35 -0
- package/es/table/component/filter.d.ts +3 -0
- package/es/table/component/filter.js +55 -0
- package/es/table/component/index.d.ts +7 -0
- package/es/table/component/index.js +4 -0
- package/es/table/component/link.d.ts +2 -0
- package/es/table/component/link.js +20 -0
- package/es/table/component/sort.d.ts +6 -0
- package/es/table/component/sort.js +17 -0
- package/es/table/component/switch.d.ts +2 -0
- package/es/table/component/switch.js +27 -0
- package/es/table/component/table-body.d.ts +6 -0
- package/es/table/component/table-body.js +88 -0
- package/es/table/component/table.d.ts +10 -0
- package/es/table/component/table.js +235 -0
- package/es/table/component/time.d.ts +2 -0
- package/es/table/component/time.js +12 -0
- package/es/table/component/utils.d.ts +120 -0
- package/es/table/component/utils.js +222 -0
- package/es/table/component/wrapper.d.ts +6 -0
- package/es/table/component/wrapper.js +30 -0
- package/es/table/hook/index.d.ts +7 -0
- package/es/table/hook/index.js +17 -0
- package/es/table/hook/search.d.ts +5 -0
- package/es/table/hook/search.js +131 -0
- package/es/table/index.d.ts +3 -0
- package/es/table/index.js +3 -0
- package/es/table/style/index.d.ts +9 -0
- package/es/table/style/index.js +16 -0
- package/es/table/type/action.d.ts +48 -0
- package/es/table/type/action.js +1 -0
- package/es/table/type/column.d.ts +110 -0
- package/es/table/type/column.js +1 -0
- package/es/table/type/index.d.ts +113 -0
- package/es/table/type/index.js +11 -0
- package/es/tabs/component/constant.d.ts +2 -0
- package/es/tabs/component/constant.js +2 -0
- package/es/tabs/component/index.d.ts +2 -0
- package/es/tabs/component/index.js +18 -0
- package/es/tabs/component/utils.d.ts +24 -0
- package/es/tabs/component/utils.js +55 -0
- package/es/tabs/index.d.ts +2 -0
- package/es/tabs/index.js +2 -0
- package/es/tabs/style/index.d.ts +5 -0
- package/es/tabs/style/index.js +10 -0
- package/es/tabs/type/index.d.ts +20 -0
- package/es/tabs/type/index.js +1 -0
- package/es/text/component/index.d.ts +3 -0
- package/es/text/component/index.js +57 -0
- package/es/text/component/use-text.d.ts +4 -0
- package/es/text/component/use-text.js +24 -0
- package/es/text/component/utils.d.ts +3 -0
- package/es/text/component/utils.js +9 -0
- package/es/text/index.d.ts +2 -0
- package/es/text/index.js +2 -0
- package/es/text/style/index.d.ts +5 -0
- package/es/text/style/index.js +8 -0
- package/es/text/type/index.d.ts +19 -0
- package/es/text/type/index.js +1 -0
- package/es/tooltip/component/index.d.ts +48 -0
- package/es/tooltip/component/index.js +19 -0
- package/es/tooltip/index.d.ts +2 -0
- package/es/tooltip/index.js +2 -0
- package/es/tooltip/type/index.d.ts +8 -0
- package/es/tooltip/type/index.js +1 -0
- package/es/tree/component/index.d.ts +2 -0
- package/es/tree/component/index.js +23 -0
- package/es/tree/component/utils.d.ts +1 -0
- package/es/tree/component/utils.js +3 -0
- package/es/tree/index.d.ts +2 -0
- package/es/tree/index.js +2 -0
- package/es/tree/style/index.d.ts +4 -0
- package/es/tree/style/index.js +7 -0
- package/es/tree/type/index.d.ts +2 -0
- package/es/tree/type/index.js +1 -0
- package/es/tree-select/component/index.d.ts +2 -0
- package/es/tree-select/component/index.js +15 -0
- package/es/tree-select/component/use-tree-select.d.ts +2 -0
- package/es/tree-select/component/use-tree-select.js +59 -0
- package/es/tree-select/index.d.ts +2 -0
- package/es/tree-select/index.js +2 -0
- package/es/tree-select/style/index.d.ts +5 -0
- package/es/tree-select/style/index.js +15 -0
- package/es/tree-select/type/index.d.ts +23 -0
- package/es/tree-select/type/index.js +1 -0
- package/es/virtual-list/component/index.d.ts +2 -0
- package/es/virtual-list/component/index.js +28 -0
- package/es/virtual-list/index.d.ts +2 -0
- package/es/virtual-list/index.js +2 -0
- package/es/virtual-list/type/index.d.ts +17 -0
- package/es/virtual-list/type/index.js +1 -0
- package/lib/api/component/class-name.d.ts +3 -0
- package/lib/api/component/class-name.js +23 -0
- package/lib/api/component/common.d.ts +22 -0
- package/lib/api/component/common.js +163 -0
- package/lib/api/component/dom.d.ts +2 -0
- package/lib/api/component/dom.js +14 -0
- package/lib/api/component/global-style.d.ts +3 -0
- package/lib/api/component/global-style.js +23 -0
- package/lib/api/component/index.d.ts +9 -0
- package/lib/api/component/index.js +104 -0
- package/lib/api/component/react-dom.d.ts +3 -0
- package/lib/api/component/react-dom.js +80 -0
- package/lib/api/component/sort.d.ts +2 -0
- package/lib/api/component/sort.js +28 -0
- package/lib/api/component/style.d.ts +4 -0
- package/lib/api/component/style.js +43 -0
- package/lib/api/component/url.d.ts +33 -0
- package/lib/api/component/url.js +133 -0
- package/lib/api/component/validate-input.d.ts +8 -0
- package/lib/api/component/validate-input.js +24 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +27 -0
- package/lib/api/type/common.d.ts +24 -0
- package/lib/api/type/common.js +5 -0
- package/lib/api/type/index.d.ts +5 -0
- package/lib/api/type/index.js +16 -0
- package/lib/button/component/index.d.ts +2 -0
- package/lib/button/component/index.js +94 -0
- package/lib/button/index.d.ts +2 -0
- package/lib/button/index.js +27 -0
- package/lib/button/type/index.d.ts +31 -0
- package/lib/button/type/index.js +5 -0
- package/lib/checkbox/component/checkbox-group.d.ts +2 -0
- package/lib/checkbox/component/checkbox-group.js +73 -0
- package/lib/checkbox/component/checkbox.d.ts +2 -0
- package/lib/checkbox/component/checkbox.js +15 -0
- package/lib/checkbox/component/index.d.ts +2 -0
- package/lib/checkbox/component/index.js +17 -0
- package/lib/checkbox/component/use-checkbox.d.ts +12 -0
- package/lib/checkbox/component/use-checkbox.js +50 -0
- package/lib/checkbox/component/utils.d.ts +13 -0
- package/lib/checkbox/component/utils.js +47 -0
- package/lib/checkbox/index.d.ts +2 -0
- package/lib/checkbox/index.js +27 -0
- package/lib/checkbox/style/index.d.ts +5 -0
- package/lib/checkbox/style/index.js +18 -0
- package/lib/checkbox/type/index.d.ts +18 -0
- package/lib/checkbox/type/index.js +5 -0
- package/lib/config/index.d.ts +0 -0
- package/lib/config/index.js +1 -0
- package/lib/date-picker/component/index.d.ts +3 -0
- package/lib/date-picker/component/index.js +46 -0
- package/lib/date-picker/index.d.ts +2 -0
- package/lib/date-picker/index.js +27 -0
- package/lib/date-picker/style/index.d.ts +4 -0
- package/lib/date-picker/style/index.js +14 -0
- package/lib/date-picker/type/index.d.ts +21 -0
- package/lib/date-picker/type/index.js +5 -0
- package/lib/empty/component/index.d.ts +2 -0
- package/lib/empty/component/index.js +24 -0
- package/lib/empty/index.d.ts +2 -0
- package/lib/empty/index.js +27 -0
- package/lib/empty/type/index.d.ts +9 -0
- package/lib/empty/type/index.js +5 -0
- package/lib/form/component/constant.d.ts +15 -0
- package/lib/form/component/constant.js +21 -0
- package/lib/form/component/form-content.d.ts +10 -0
- package/lib/form/component/form-content.js +288 -0
- package/lib/form/component/form-item-map.d.ts +40 -0
- package/lib/form/component/form-item-map.js +128 -0
- package/lib/form/component/form-item.d.ts +7 -0
- package/lib/form/component/form-item.js +227 -0
- package/lib/form/component/form-list.d.ts +36 -0
- package/lib/form/component/form-list.js +201 -0
- package/lib/form/component/form.d.ts +2 -0
- package/lib/form/component/form.js +47 -0
- package/lib/form/component/index.d.ts +15 -0
- package/lib/form/component/index.js +20 -0
- package/lib/form/component/submit-button.d.ts +2 -0
- package/lib/form/component/submit-button.js +54 -0
- package/lib/form/component/use-debug.d.ts +1 -0
- package/lib/form/component/use-debug.js +22 -0
- package/lib/form/component/utils.d.ts +95 -0
- package/lib/form/component/utils.js +467 -0
- package/lib/form/component/validator-item.d.ts +7 -0
- package/lib/form/component/validator-item.js +60 -0
- package/lib/form/hook/index.d.ts +16 -0
- package/lib/form/hook/index.js +163 -0
- package/lib/form/hook/list-provider.d.ts +6 -0
- package/lib/form/hook/list-provider.js +24 -0
- package/lib/form/hook/provider.d.ts +23 -0
- package/lib/form/hook/provider.js +30 -0
- package/lib/form/hook/use-form.d.ts +2 -0
- package/lib/form/hook/use-form.js +342 -0
- package/lib/form/index.d.ts +3 -0
- package/lib/form/index.js +38 -0
- package/lib/form/style/form-item.d.ts +3 -0
- package/lib/form/style/form-item.js +46 -0
- package/lib/form/style/index.d.ts +7 -0
- package/lib/form/style/index.js +32 -0
- package/lib/form/type/form-item.d.ts +141 -0
- package/lib/form/type/form-item.js +5 -0
- package/lib/form/type/form-list.d.ts +91 -0
- package/lib/form/type/form-list.js +5 -0
- package/lib/form/type/index.d.ts +134 -0
- package/lib/form/type/index.js +27 -0
- package/lib/grid/component/index.d.ts +2 -0
- package/lib/grid/component/index.js +83 -0
- package/lib/grid/component/pagination.d.ts +50 -0
- package/lib/grid/component/pagination.js +62 -0
- package/lib/grid/component/utils.d.ts +2 -0
- package/lib/grid/component/utils.js +14 -0
- package/lib/grid/index.d.ts +2 -0
- package/lib/grid/index.js +27 -0
- package/lib/grid/style/index.d.ts +11 -0
- package/lib/grid/style/index.js +33 -0
- package/lib/grid/type/index.d.ts +67 -0
- package/lib/grid/type/index.js +5 -0
- package/lib/highlight-text/component/index.d.ts +2 -0
- package/lib/highlight-text/component/index.js +78 -0
- package/lib/highlight-text/index.d.ts +2 -0
- package/lib/highlight-text/index.js +27 -0
- package/lib/highlight-text/style/index.d.ts +4 -0
- package/lib/highlight-text/style/index.js +14 -0
- package/lib/highlight-text/type/index.d.ts +18 -0
- package/lib/highlight-text/type/index.js +5 -0
- package/lib/hooks/hook/common.d.ts +1 -0
- package/lib/hooks/hook/common.js +18 -0
- package/lib/hooks/hook/index.d.ts +7 -0
- package/lib/hooks/hook/index.js +82 -0
- package/lib/hooks/hook/use-debounce.d.ts +4 -0
- package/lib/hooks/hook/use-debounce.js +32 -0
- package/lib/hooks/hook/use-deep.d.ts +9 -0
- package/lib/hooks/hook/use-deep.js +76 -0
- package/lib/hooks/hook/use-fetch.d.ts +8 -0
- package/lib/hooks/hook/use-fetch.js +171 -0
- package/lib/hooks/hook/use-list-operation.d.ts +5 -0
- package/lib/hooks/hook/use-list-operation.js +80 -0
- package/lib/hooks/hook/use-loading.d.ts +7 -0
- package/lib/hooks/hook/use-loading.js +66 -0
- package/lib/hooks/hook/use-window-resize.d.ts +5 -0
- package/lib/hooks/hook/use-window-resize.js +22 -0
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +27 -0
- package/lib/hooks/type/index.d.ts +2 -0
- package/lib/hooks/type/index.js +27 -0
- package/lib/hooks/type/use-fetch.d.ts +31 -0
- package/lib/hooks/type/use-fetch.js +5 -0
- package/lib/hooks/type/use-list-operation.d.ts +34 -0
- package/lib/hooks/type/use-list-operation.js +5 -0
- package/lib/icon/component/down.d.ts +2 -0
- package/lib/icon/component/down.js +50 -0
- package/lib/icon/component/index.d.ts +2 -0
- package/lib/icon/component/index.js +27 -0
- package/lib/icon/component/up.d.ts +2 -0
- package/lib/icon/component/up.js +49 -0
- package/lib/icon/hook/index.d.ts +477 -0
- package/lib/icon/hook/index.js +67 -0
- package/lib/icon/index.d.ts +2 -0
- package/lib/icon/index.js +27 -0
- package/lib/icon/style/index.d.ts +4 -0
- package/lib/icon/style/index.js +17 -0
- package/lib/icon/type/index.d.ts +14 -0
- package/lib/icon/type/index.js +5 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.js +345 -0
- package/lib/input/component/index.d.ts +12 -0
- package/lib/input/component/index.js +33 -0
- package/lib/input/component/input.d.ts +2 -0
- package/lib/input/component/input.js +15 -0
- package/lib/input/component/number.d.ts +4 -0
- package/lib/input/component/number.js +57 -0
- package/lib/input/component/password.d.ts +2 -0
- package/lib/input/component/password.js +15 -0
- package/lib/input/component/text-area.d.ts +2 -0
- package/lib/input/component/text-area.js +23 -0
- package/lib/input/component/utils.d.ts +15 -0
- package/lib/input/component/utils.js +114 -0
- package/lib/input/index.d.ts +2 -0
- package/lib/input/index.js +27 -0
- package/lib/input/style/index.d.ts +6 -0
- package/lib/input/style/index.js +18 -0
- package/lib/input/type/index.d.ts +41 -0
- package/lib/input/type/index.js +5 -0
- package/lib/modal-prompt/component/index.d.ts +5 -0
- package/lib/modal-prompt/component/index.js +85 -0
- package/lib/modal-prompt/component/open-loading.d.ts +2 -0
- package/lib/modal-prompt/component/open-loading.js +28 -0
- package/lib/modal-prompt/component/utils.d.ts +4 -0
- package/lib/modal-prompt/component/utils.js +57 -0
- package/lib/modal-prompt/index.d.ts +2 -0
- package/lib/modal-prompt/index.js +27 -0
- package/lib/modal-prompt/style/index.d.ts +5 -0
- package/lib/modal-prompt/style/index.js +16 -0
- package/lib/modal-prompt/type/index.d.ts +36 -0
- package/lib/modal-prompt/type/index.js +5 -0
- package/lib/open-modal/component/constant.d.ts +1 -0
- package/lib/open-modal/component/constant.js +10 -0
- package/lib/open-modal/component/footer.d.ts +2 -0
- package/lib/open-modal/component/footer.js +41 -0
- package/lib/open-modal/component/index.d.ts +4 -0
- package/lib/open-modal/component/index.js +30 -0
- package/lib/open-modal/component/modal.d.ts +10 -0
- package/lib/open-modal/component/modal.js +44 -0
- package/lib/open-modal/component/title.d.ts +6 -0
- package/lib/open-modal/component/title.js +18 -0
- package/lib/open-modal/component/use-modal.d.ts +14 -0
- package/lib/open-modal/component/use-modal.js +184 -0
- package/lib/open-modal/component/utils.d.ts +11 -0
- package/lib/open-modal/component/utils.js +117 -0
- package/lib/open-modal/hook/index.d.ts +7 -0
- package/lib/open-modal/hook/index.js +40 -0
- package/lib/open-modal/hook/use-modal.d.ts +6 -0
- package/lib/open-modal/hook/use-modal.js +34 -0
- package/lib/open-modal/index.d.ts +3 -0
- package/lib/open-modal/index.js +38 -0
- package/lib/open-modal/style/index.d.ts +5 -0
- package/lib/open-modal/style/index.js +25 -0
- package/lib/open-modal/style/wrap.d.ts +2 -0
- package/lib/open-modal/style/wrap.js +13 -0
- package/lib/open-modal/type/index.d.ts +91 -0
- package/lib/open-modal/type/index.js +5 -0
- package/lib/portal/component/index.d.ts +2 -0
- package/lib/portal/component/index.js +47 -0
- package/lib/portal/index.d.ts +2 -0
- package/lib/portal/index.js +27 -0
- package/lib/portal/type/index.d.ts +13 -0
- package/lib/portal/type/index.js +5 -0
- package/lib/radio/component/abstract-box.d.ts +380 -0
- package/lib/radio/component/abstract-box.js +98 -0
- package/lib/radio/component/index.d.ts +2 -0
- package/lib/radio/component/index.js +17 -0
- package/lib/radio/component/radio.d.ts +2 -0
- package/lib/radio/component/radio.js +17 -0
- package/lib/radio/component/redio-group.d.ts +2 -0
- package/lib/radio/component/redio-group.js +57 -0
- package/lib/radio/component/use-box-options.d.ts +6 -0
- package/lib/radio/component/use-box-options.js +27 -0
- package/lib/radio/component/use-radio.d.ts +23 -0
- package/lib/radio/component/use-radio.js +28 -0
- package/lib/radio/component/utils.d.ts +7 -0
- package/lib/radio/component/utils.js +33 -0
- package/lib/radio/index.d.ts +2 -0
- package/lib/radio/index.js +27 -0
- package/lib/radio/style/index.d.ts +7 -0
- package/lib/radio/style/index.js +22 -0
- package/lib/radio/type/index.d.ts +32 -0
- package/lib/radio/type/index.js +5 -0
- package/lib/select/component/constant.d.ts +1 -0
- package/lib/select/component/constant.js +7 -0
- package/lib/select/component/index.d.ts +3 -0
- package/lib/select/component/index.js +29 -0
- package/lib/select/component/loading.d.ts +1 -0
- package/lib/select/component/loading.js +20 -0
- package/lib/select/component/use-select-options.d.ts +11 -0
- package/lib/select/component/use-select-options.js +88 -0
- package/lib/select/component/use-select.d.ts +2 -0
- package/lib/select/component/use-select.js +143 -0
- package/lib/select/component/utils.d.ts +14 -0
- package/lib/select/component/utils.js +152 -0
- package/lib/select/index.d.ts +2 -0
- package/lib/select/index.js +27 -0
- package/lib/select/style/index.d.ts +4 -0
- package/lib/select/style/index.js +14 -0
- package/lib/select/type/index.d.ts +105 -0
- package/lib/select/type/index.js +5 -0
- package/lib/stack/component/center-stack.d.ts +2 -0
- package/lib/stack/component/center-stack.js +39 -0
- package/lib/stack/component/h-stack.d.ts +2 -0
- package/lib/stack/component/h-stack.js +46 -0
- package/lib/stack/component/index.d.ts +3 -0
- package/lib/stack/component/index.js +38 -0
- package/lib/stack/component/v-stack.d.ts +2 -0
- package/lib/stack/component/v-stack.js +43 -0
- package/lib/stack/index.d.ts +2 -0
- package/lib/stack/index.js +27 -0
- package/lib/stack/style/index.d.ts +21 -0
- package/lib/stack/style/index.js +59 -0
- package/lib/stack/type/index.d.ts +54 -0
- package/lib/stack/type/index.js +5 -0
- package/lib/switch/component/index.d.ts +2 -0
- package/lib/switch/component/index.js +67 -0
- package/lib/switch/index.d.ts +2 -0
- package/lib/switch/index.js +27 -0
- package/lib/switch/style/index.d.ts +5 -0
- package/lib/switch/style/index.js +20 -0
- package/lib/switch/type/index.d.ts +27 -0
- package/lib/switch/type/index.js +5 -0
- package/lib/table/component/action-button.d.ts +2 -0
- package/lib/table/component/action-button.js +102 -0
- package/lib/table/component/actions.d.ts +2 -0
- package/lib/table/component/actions.js +42 -0
- package/lib/table/component/constant.d.ts +1 -0
- package/lib/table/component/constant.js +12 -0
- package/lib/table/component/editor.d.ts +2 -0
- package/lib/table/component/editor.js +42 -0
- package/lib/table/component/filter.d.ts +3 -0
- package/lib/table/component/filter.js +62 -0
- package/lib/table/component/index.d.ts +7 -0
- package/lib/table/component/index.js +10 -0
- package/lib/table/component/link.d.ts +2 -0
- package/lib/table/component/link.js +27 -0
- package/lib/table/component/sort.d.ts +6 -0
- package/lib/table/component/sort.js +24 -0
- package/lib/table/component/switch.d.ts +2 -0
- package/lib/table/component/switch.js +34 -0
- package/lib/table/component/table-body.d.ts +6 -0
- package/lib/table/component/table-body.js +95 -0
- package/lib/table/component/table.d.ts +10 -0
- package/lib/table/component/table.js +243 -0
- package/lib/table/component/time.d.ts +2 -0
- package/lib/table/component/time.js +19 -0
- package/lib/table/component/utils.d.ts +120 -0
- package/lib/table/component/utils.js +235 -0
- package/lib/table/component/wrapper.d.ts +6 -0
- package/lib/table/component/wrapper.js +37 -0
- package/lib/table/hook/index.d.ts +7 -0
- package/lib/table/hook/index.js +40 -0
- package/lib/table/hook/search.d.ts +5 -0
- package/lib/table/hook/search.js +138 -0
- package/lib/table/index.d.ts +3 -0
- package/lib/table/index.js +38 -0
- package/lib/table/style/index.d.ts +9 -0
- package/lib/table/style/index.js +23 -0
- package/lib/table/type/action.d.ts +48 -0
- package/lib/table/type/action.js +5 -0
- package/lib/table/type/column.d.ts +110 -0
- package/lib/table/type/column.js +5 -0
- package/lib/table/type/index.d.ts +113 -0
- package/lib/table/type/index.js +27 -0
- package/lib/tabs/component/constant.d.ts +2 -0
- package/lib/tabs/component/constant.js +8 -0
- package/lib/tabs/component/index.d.ts +2 -0
- package/lib/tabs/component/index.js +25 -0
- package/lib/tabs/component/utils.d.ts +24 -0
- package/lib/tabs/component/utils.js +63 -0
- package/lib/tabs/index.d.ts +2 -0
- package/lib/tabs/index.js +27 -0
- package/lib/tabs/style/index.d.ts +5 -0
- package/lib/tabs/style/index.js +17 -0
- package/lib/tabs/type/index.d.ts +20 -0
- package/lib/tabs/type/index.js +5 -0
- package/lib/text/component/index.d.ts +3 -0
- package/lib/text/component/index.js +78 -0
- package/lib/text/component/use-text.d.ts +4 -0
- package/lib/text/component/use-text.js +31 -0
- package/lib/text/component/utils.d.ts +3 -0
- package/lib/text/component/utils.js +15 -0
- package/lib/text/index.d.ts +2 -0
- package/lib/text/index.js +27 -0
- package/lib/text/style/index.d.ts +5 -0
- package/lib/text/style/index.js +15 -0
- package/lib/text/type/index.d.ts +19 -0
- package/lib/text/type/index.js +5 -0
- package/lib/tooltip/component/index.d.ts +48 -0
- package/lib/tooltip/component/index.js +28 -0
- package/lib/tooltip/index.d.ts +2 -0
- package/lib/tooltip/index.js +27 -0
- package/lib/tooltip/type/index.d.ts +8 -0
- package/lib/tooltip/type/index.js +5 -0
- package/lib/tree/component/index.d.ts +2 -0
- package/lib/tree/component/index.js +30 -0
- package/lib/tree/component/utils.d.ts +1 -0
- package/lib/tree/component/utils.js +9 -0
- package/lib/tree/index.d.ts +2 -0
- package/lib/tree/index.js +27 -0
- package/lib/tree/style/index.d.ts +4 -0
- package/lib/tree/style/index.js +14 -0
- package/lib/tree/type/index.d.ts +2 -0
- package/lib/tree/type/index.js +5 -0
- package/lib/tree-select/component/index.d.ts +2 -0
- package/lib/tree-select/component/index.js +22 -0
- package/lib/tree-select/component/use-tree-select.d.ts +2 -0
- package/lib/tree-select/component/use-tree-select.js +66 -0
- package/lib/tree-select/index.d.ts +2 -0
- package/lib/tree-select/index.js +27 -0
- package/lib/tree-select/style/index.d.ts +5 -0
- package/lib/tree-select/style/index.js +22 -0
- package/lib/tree-select/type/index.d.ts +23 -0
- package/lib/tree-select/type/index.js +5 -0
- package/lib/virtual-list/component/index.d.ts +2 -0
- package/lib/virtual-list/component/index.js +35 -0
- package/lib/virtual-list/index.d.ts +2 -0
- package/lib/virtual-list/index.js +27 -0
- package/lib/virtual-list/type/index.d.ts +17 -0
- package/lib/virtual-list/type/index.js +5 -0
- package/package.json +147 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["children"];
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
5
|
+
var FormCtx = /*#__PURE__*/createContext({});
|
|
6
|
+
export function FormProvider(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
9
|
+
return _jsx(FormCtx.Provider, {
|
|
10
|
+
value: props,
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function useFormContext() {
|
|
15
|
+
return useContext(FormCtx);
|
|
16
|
+
}
|
|
17
|
+
export function useFormValue() {
|
|
18
|
+
var _useFormContext = useFormContext(),
|
|
19
|
+
values = _useFormContext.values;
|
|
20
|
+
return values;
|
|
21
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import { runDevOrJest, wait } from "../../api";
|
|
5
|
+
import { Form } from 'antd';
|
|
6
|
+
import delay from 'delay';
|
|
7
|
+
import _ from 'lodash';
|
|
8
|
+
import { useUpdate } from 'react-use';
|
|
9
|
+
import { registerMethods } from "../component/constant";
|
|
10
|
+
import { parseFormFailedError, transformKeyToPath, transformNameToPath, transformPathToName } from "../component/utils";
|
|
11
|
+
var pathMap = {
|
|
12
|
+
initForm: '__INTERNAL__.initForm',
|
|
13
|
+
name: '__INTERNAL__.name',
|
|
14
|
+
items: '__INTERNAL__.items',
|
|
15
|
+
itemsStatus: '__INTERNAL__.itemsStatus',
|
|
16
|
+
loading: '__INTERNAL__.loading',
|
|
17
|
+
errors: '__INTERNAL__.errors',
|
|
18
|
+
methods: '__INTERNAL__.methods'
|
|
19
|
+
};
|
|
20
|
+
export function useForm() {
|
|
21
|
+
var form = Form.useForm()[0];
|
|
22
|
+
var update = useUpdate();
|
|
23
|
+
|
|
24
|
+
// 防止重复初始化
|
|
25
|
+
if (_.get(form, pathMap.initForm)) {
|
|
26
|
+
return form;
|
|
27
|
+
}
|
|
28
|
+
_.set(form, pathMap.initForm, true);
|
|
29
|
+
var methods = [registerAndCallMethod, updateForm, setError, setValue, getValue, validate, reset, submit, getName, processFormItems, processFormItemsStatus, getFieldInstance, getFormList, focus];
|
|
30
|
+
methods.forEach(function (fn) {
|
|
31
|
+
return fn(form, update);
|
|
32
|
+
});
|
|
33
|
+
return form;
|
|
34
|
+
}
|
|
35
|
+
function registerAndCallMethod(form) {
|
|
36
|
+
var path = pathMap.methods;
|
|
37
|
+
form.registerMethod = function (name, fn) {
|
|
38
|
+
_.set(form, "".concat(path, ".").concat(name), fn);
|
|
39
|
+
};
|
|
40
|
+
form.callMethod = function (name) {
|
|
41
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
42
|
+
args[_key - 1] = arguments[_key];
|
|
43
|
+
}
|
|
44
|
+
return _.invoke.apply(_, [form, "".concat(path, ".").concat(name)].concat(args));
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getValue(form) {
|
|
48
|
+
form.getValue = function (name) {
|
|
49
|
+
var path = transformNameToPath(name);
|
|
50
|
+
return path ? form.getFieldValue(path) : form.getFieldsValue(true);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function setError(form) {
|
|
54
|
+
form.setError = /*#__PURE__*/function () {
|
|
55
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(nameOrParams, message) {
|
|
56
|
+
var errors, internalErrors;
|
|
57
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
_context.next = 2;
|
|
61
|
+
return wait(function () {
|
|
62
|
+
return !form.callMethod(registerMethods.getLoading);
|
|
63
|
+
});
|
|
64
|
+
case 2:
|
|
65
|
+
errors = [];
|
|
66
|
+
if (_.isString(nameOrParams) || _.isArray(nameOrParams)) {
|
|
67
|
+
errors.push({
|
|
68
|
+
name: transformNameToPath(nameOrParams),
|
|
69
|
+
errors: [message || '']
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
errors = _.map(nameOrParams, function (value, name) {
|
|
73
|
+
return {
|
|
74
|
+
name: transformNameToPath(name),
|
|
75
|
+
errors: [value]
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
form.setFields(errors);
|
|
80
|
+
|
|
81
|
+
// 暂存 errors, 实时校验需要获取 errors
|
|
82
|
+
internalErrors = getInternalErrors(form);
|
|
83
|
+
_.forEach(errors, function (error) {
|
|
84
|
+
return _.set(internalErrors, error.name, error.errors[0]);
|
|
85
|
+
});
|
|
86
|
+
form.callMethod(registerMethods.triggerValidate);
|
|
87
|
+
case 8:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee);
|
|
92
|
+
}));
|
|
93
|
+
return function (_x, _x2) {
|
|
94
|
+
return _ref.apply(this, arguments);
|
|
95
|
+
};
|
|
96
|
+
}();
|
|
97
|
+
form.registerMethod(registerMethods.getInternalErrors, function (name) {
|
|
98
|
+
var internalErrors = getInternalErrors(form);
|
|
99
|
+
return _.get(internalErrors, name);
|
|
100
|
+
});
|
|
101
|
+
form.registerMethod(registerMethods.resetInternalError, function (name) {
|
|
102
|
+
var internalErrors = getInternalErrors(form);
|
|
103
|
+
if (name) {
|
|
104
|
+
_.unset(internalErrors, name);
|
|
105
|
+
} else {
|
|
106
|
+
_.set(form, pathMap.errors, {});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// reset itemsStatus
|
|
110
|
+
form.callMethod(registerMethods.setItemsStatus, name);
|
|
111
|
+
});
|
|
112
|
+
form.resetError = function (name) {
|
|
113
|
+
var nameList = _.castArray(name);
|
|
114
|
+
var fields = nameList.map(function (x) {
|
|
115
|
+
return {
|
|
116
|
+
name: transformNameToPath(x),
|
|
117
|
+
errors: []
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
form.setFields(fields);
|
|
121
|
+
_.forEach(nameList, function (name) {
|
|
122
|
+
return form.callMethod(registerMethods.resetInternalError, name);
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function getInternalErrors(form) {
|
|
127
|
+
var errors = _.get(form, pathMap.errors);
|
|
128
|
+
if (errors) {
|
|
129
|
+
return errors;
|
|
130
|
+
}
|
|
131
|
+
var defaultErrors = {};
|
|
132
|
+
_.set(form, pathMap.errors, defaultErrors);
|
|
133
|
+
return defaultErrors;
|
|
134
|
+
}
|
|
135
|
+
function setValue(form, update) {
|
|
136
|
+
form.setValue = function (nameOrParams, value) {
|
|
137
|
+
if (_.isString(nameOrParams) || _.isArray(nameOrParams)) {
|
|
138
|
+
var name = transformNameToPath(nameOrParams);
|
|
139
|
+
// 该方法会替换 Value
|
|
140
|
+
form.setFieldValue(name, value);
|
|
141
|
+
} else {
|
|
142
|
+
var values = transformKeyToPath(nameOrParams);
|
|
143
|
+
// 该方法会 Merge Value,同时会清空状态
|
|
144
|
+
form.setFieldsValue(values);
|
|
145
|
+
}
|
|
146
|
+
update();
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function validate(form) {
|
|
150
|
+
form.validate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
151
|
+
var _len2,
|
|
152
|
+
args,
|
|
153
|
+
_key2,
|
|
154
|
+
_args2 = arguments;
|
|
155
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
156
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
_context2.next = 2;
|
|
159
|
+
return wait(function () {
|
|
160
|
+
return !form.callMethod(registerMethods.getLoading);
|
|
161
|
+
});
|
|
162
|
+
case 2:
|
|
163
|
+
for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
164
|
+
args[_key2] = _args2[_key2];
|
|
165
|
+
}
|
|
166
|
+
return _context2.abrupt("return", form.callMethod.apply(form, [registerMethods.internalValidate].concat(args)));
|
|
167
|
+
case 4:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context2.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee2);
|
|
172
|
+
}));
|
|
173
|
+
form.registerMethod(registerMethods.internalValidate, /*#__PURE__*/function () {
|
|
174
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(name, options) {
|
|
175
|
+
var path, nameList;
|
|
176
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
177
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
_context3.prev = 0;
|
|
180
|
+
if (!name) {
|
|
181
|
+
_context3.next = 8;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
path = transformNameToPath(name);
|
|
185
|
+
nameList = _.isString(name) ? [path] : path;
|
|
186
|
+
_context3.next = 6;
|
|
187
|
+
return form.validateFields(nameList, options);
|
|
188
|
+
case 6:
|
|
189
|
+
_context3.next = 10;
|
|
190
|
+
break;
|
|
191
|
+
case 8:
|
|
192
|
+
_context3.next = 10;
|
|
193
|
+
return form.validateFields(_objectSpread({
|
|
194
|
+
validateOnly: true
|
|
195
|
+
}, options));
|
|
196
|
+
case 10:
|
|
197
|
+
return _context3.abrupt("return", true);
|
|
198
|
+
case 13:
|
|
199
|
+
_context3.prev = 13;
|
|
200
|
+
_context3.t0 = _context3["catch"](0);
|
|
201
|
+
form.callMethod(registerMethods.onValidateFailed, parseFormFailedError(_context3.t0));
|
|
202
|
+
return _context3.abrupt("return", false);
|
|
203
|
+
case 17:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context3.stop();
|
|
206
|
+
}
|
|
207
|
+
}, _callee3, null, [[0, 13]]);
|
|
208
|
+
}));
|
|
209
|
+
return function (_x3, _x4) {
|
|
210
|
+
return _ref3.apply(this, arguments);
|
|
211
|
+
};
|
|
212
|
+
}());
|
|
213
|
+
}
|
|
214
|
+
function reset(form) {
|
|
215
|
+
form.reset = function (name) {
|
|
216
|
+
if (name) {
|
|
217
|
+
var path = transformNameToPath(name);
|
|
218
|
+
var nameList = _.isString(name) ? [path] : path;
|
|
219
|
+
_.forEach(nameList, function (name) {
|
|
220
|
+
return form.callMethod(registerMethods.resetInternalError, name);
|
|
221
|
+
});
|
|
222
|
+
form.resetFields(nameList);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
form.callMethod(registerMethods.resetInternalError);
|
|
226
|
+
form.resetFields();
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function submit(form) {
|
|
230
|
+
var originalSubmit = form.submit;
|
|
231
|
+
form.submit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
232
|
+
var err;
|
|
233
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
234
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
_context4.prev = 0;
|
|
237
|
+
originalSubmit();
|
|
238
|
+
// 修复submit和validateFields同时调用时,某种场景会出现的bug
|
|
239
|
+
_context4.next = 4;
|
|
240
|
+
return delay(20);
|
|
241
|
+
case 4:
|
|
242
|
+
_context4.next = 6;
|
|
243
|
+
return form.validateFields();
|
|
244
|
+
case 6:
|
|
245
|
+
return _context4.abrupt("return", form.getValue());
|
|
246
|
+
case 9:
|
|
247
|
+
_context4.prev = 9;
|
|
248
|
+
_context4.t0 = _context4["catch"](0);
|
|
249
|
+
err = parseFormFailedError(_context4.t0);
|
|
250
|
+
return _context4.abrupt("return", Promise.reject(err));
|
|
251
|
+
case 13:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context4.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee4, null, [[0, 9]]);
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
function updateForm(form, update) {
|
|
259
|
+
form.update = update;
|
|
260
|
+
}
|
|
261
|
+
function getName(form) {
|
|
262
|
+
var id = runDevOrJest(_.uniqueId('form_'), 'form');
|
|
263
|
+
var path = pathMap.name;
|
|
264
|
+
_.set(form, path, id);
|
|
265
|
+
form.getName = function () {
|
|
266
|
+
return _.get(form, path);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function processFormItems(form) {
|
|
270
|
+
var path = pathMap.items;
|
|
271
|
+
form.setItems = function (items) {
|
|
272
|
+
return _.set(form, path, items);
|
|
273
|
+
};
|
|
274
|
+
form.getItems = function (name) {
|
|
275
|
+
var items = _.get(form, path) || [];
|
|
276
|
+
if (name) {
|
|
277
|
+
var namePath = transformPathToName(name);
|
|
278
|
+
return _.find(items, function (item) {
|
|
279
|
+
return transformPathToName(item.name) === namePath;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return items;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function processFormItemsStatus(form) {
|
|
286
|
+
var path = pathMap.itemsStatus;
|
|
287
|
+
form.registerMethod(registerMethods.setItemsStatus, function (name, errors) {
|
|
288
|
+
if (!name) {
|
|
289
|
+
return _.set(form, path, {});
|
|
290
|
+
}
|
|
291
|
+
var namePath = transformPathToName(name);
|
|
292
|
+
var fullPath = "".concat(path, ".").concat(namePath);
|
|
293
|
+
if (_.isEmpty(errors)) {
|
|
294
|
+
return _.unset(form, fullPath);
|
|
295
|
+
}
|
|
296
|
+
_.set(form, fullPath, errors);
|
|
297
|
+
});
|
|
298
|
+
form.registerMethod(registerMethods.getItemsStatus, function (name) {
|
|
299
|
+
var namePath = transformPathToName(name);
|
|
300
|
+
var fullPath = name ? "".concat(path, ".").concat(namePath) : path;
|
|
301
|
+
var errors = _.get(form, fullPath);
|
|
302
|
+
return removeEmptyError(errors);
|
|
303
|
+
});
|
|
304
|
+
form.getError = function (name) {
|
|
305
|
+
return form.callMethod(registerMethods.getItemsStatus, name);
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function removeEmptyError(error) {
|
|
309
|
+
if (!_.isPlainObject(error)) {
|
|
310
|
+
return error;
|
|
311
|
+
}
|
|
312
|
+
var processed = _.mapValues(error, removeEmptyError);
|
|
313
|
+
return _.omitBy(processed, _.isEmpty);
|
|
314
|
+
}
|
|
315
|
+
function getFieldInstance(form) {
|
|
316
|
+
form.getFieldInstance = function (name) {
|
|
317
|
+
var _form$getItems;
|
|
318
|
+
return (_form$getItems = form.getItems(name)) === null || _form$getItems === void 0 ? void 0 : _form$getItems.refs.current;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function getFormList(form) {
|
|
322
|
+
// @ts-ignore
|
|
323
|
+
form.getFormList = function (name) {
|
|
324
|
+
var list = _(form.getItems()).map('formListContext').compact().unionBy('name').value();
|
|
325
|
+
return name ? _.find(list, {
|
|
326
|
+
name: name
|
|
327
|
+
}) : list;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function focus(form) {
|
|
331
|
+
form.focus = function (name, option) {
|
|
332
|
+
var _form$getFieldInstanc;
|
|
333
|
+
(_form$getFieldInstanc = form.getFieldInstance(name)) === null || _form$getFieldInstanc === void 0 || _form$getFieldInstanc.focus(option);
|
|
334
|
+
};
|
|
335
|
+
}
|
package/es/form/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { FormItemProps, FormItemPropsWithType } from "..";
|
|
2
|
+
export declare function getFormItemWidth({ width, type }: FormItemPropsWithType): string | number | undefined;
|
|
3
|
+
export declare function getFormItemStyle({ labelWidth, controlWidth, requiredMark, layout, type, ...props }: FormItemProps): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
|
+
var _excluded = ["labelWidth", "controlWidth", "requiredMark", "layout", "type"];
|
|
5
|
+
import { transformValueWithStyleUnit } from "../../api";
|
|
6
|
+
import { getWidthAndFlex } from "../../stack/style";
|
|
7
|
+
import { css } from '@emotion/css';
|
|
8
|
+
import { useUnsetWidthKeys } from "../component/constant";
|
|
9
|
+
export function getFormItemWidth(_ref) {
|
|
10
|
+
var width = _ref.width,
|
|
11
|
+
type = _ref.type;
|
|
12
|
+
if (width) {
|
|
13
|
+
return width;
|
|
14
|
+
}
|
|
15
|
+
if (useUnsetWidthKeys.includes(type)) {
|
|
16
|
+
return 'unset';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function getFormItemStyle(_ref2) {
|
|
20
|
+
var labelWidth = _ref2.labelWidth,
|
|
21
|
+
controlWidth = _ref2.controlWidth,
|
|
22
|
+
_ref2$requiredMark = _ref2.requiredMark,
|
|
23
|
+
requiredMark = _ref2$requiredMark === void 0 ? true : _ref2$requiredMark,
|
|
24
|
+
layout = _ref2.layout,
|
|
25
|
+
type = _ref2.type,
|
|
26
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
27
|
+
var baseStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.ant-form-item {\n min-width: 0;\n\n .ant-form-item-label {\n width: ", ";\n\n .ant-form-item-tooltip {\n color: inherit;\n font-size: 13px;\n margin-inline-start: unset;\n margin-left: 3px;\n }\n }\n\n .ant-form-item-control-input {\n width: ", ";\n }\n\n .ant-form-item-required::before {\n display: ", ";\n }\n\n ", "\n ", "\n ", "\n }\n "])), transformValueWithStyleUnit(labelWidth), transformValueWithStyleUnit(controlWidth), requiredMark ? undefined : 'none', layout === 'horizontal' && getHorizontalStyle(), layout === 'vertical' && getVerticalStyle(), type === 'tree' && treeItemStyle());
|
|
28
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n ", "\n "])), getWidthAndFlex(props), baseStyle);
|
|
29
|
+
}
|
|
30
|
+
function getHorizontalStyle() {
|
|
31
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .ant-form-item-row {\n flex-direction: row;\n }\n\n .ant-form-item-label {\n padding-bottom: 0;\n\n > label {\n height: 32px;\n margin-right: 8px;\n }\n }\n\n .ant-form-item-control {\n flex: 1;\n min-width: 0;\n }\n "])));
|
|
32
|
+
}
|
|
33
|
+
function getVerticalStyle() {
|
|
34
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .ant-form-item-row {\n flex-direction: column;\n }\n\n .ant-form-item-label {\n > label {\n height: auto;\n margin-bottom: 4px;\n }\n\n .ant-form-item-required::before {\n position: unset;\n }\n }\n "])));
|
|
35
|
+
}
|
|
36
|
+
function treeItemStyle() {
|
|
37
|
+
return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n &,\n .ant-form-item-row,\n .ant-form-item-control,\n .ant-form-item-control-input,\n .ant-form-item-control-input-content {\n height: 100%;\n }\n "])));
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormProps } from "..";
|
|
2
|
+
export * from './form-item';
|
|
3
|
+
type WrapperProps = Pick<FormProps, 'labelWidth' | 'formItemMarginBottom'>;
|
|
4
|
+
declare const style: {
|
|
5
|
+
wrapper: ({ labelWidth, formItemMarginBottom }: WrapperProps) => import("@emotion/react").SerializedStyles;
|
|
6
|
+
};
|
|
7
|
+
export default style;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { commonFontFamily, transformValueWithStyleUnit } from "../../api";
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
export * from "./form-item";
|
|
6
|
+
var style = {
|
|
7
|
+
wrapper: function wrapper(_ref) {
|
|
8
|
+
var labelWidth = _ref.labelWidth,
|
|
9
|
+
formItemMarginBottom = _ref.formItemMarginBottom;
|
|
10
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n .ant-form-item {\n margin-bottom: ", ";\n }\n\n .ant-form-item-label {\n width: ", ";\n }\n\n .ant-form-item-with-help .ant-form-item-explain {\n line-height: 1.1;\n padding: 4px 0;\n\n .ant-form-item-explain-error + .ant-form-item-explain-error {\n margin-top: 2px;\n }\n }\n\n &.ant-form-horizontal {\n .ant-form-item-required::before {\n position: absolute;\n left: -10px;\n }\n }\n\n &.ant-form-vertical {\n .ant-form-item-label {\n padding-bottom: 2px;\n }\n }\n\n // disabled \u65F6\u4E5F\u9700\u8981\u663E\u793A error \u6846\n .ant-picker-status-error.ant-picker,\n .ant-select-status-error.ant-select:not(.ant-select-customize-input) .ant-select-selector,\n .ant-input-status-error:not(.ant-input-borderless),\n .ant-input-number-status-error:not(.ant-input-number-borderless),\n .ant-input-affix-wrapper-status-error:not(.ant-input-affix-wrapper-borderless) {\n border-color: #ff4d4f;\n }\n "])), commonFontFamily, transformValueWithStyleUnit(formItemMarginBottom), transformValueWithStyleUnit(labelWidth));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default style;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { FunctionReturn, Refs } from "../../api";
|
|
2
|
+
import { CheckboxProps } from "../../checkbox";
|
|
3
|
+
import { DatePickerProps, RangePickerProps } from "../../date-picker";
|
|
4
|
+
import { CommonParams, FormListContext, FormValues } from "..";
|
|
5
|
+
import { InputProps } from "../../input";
|
|
6
|
+
import { RadioProps } from "../../radio";
|
|
7
|
+
import { SelectOptions, SelectProps } from "../../select";
|
|
8
|
+
import { SwitchProps } from "../../switch";
|
|
9
|
+
import { TreeSelectProps } from "../../tree-select";
|
|
10
|
+
import { FormItemProps as AntdFormItemProps } from 'antd/lib/form/FormItem';
|
|
11
|
+
import { SliderRangeProps, SliderSingleProps } from 'antd/lib/slider';
|
|
12
|
+
import { Rule } from 'rc-field-form/lib/interface';
|
|
13
|
+
import { ReactElement, ReactNode } from 'react';
|
|
14
|
+
import { InputComponentType, OtherComponentType } from '../component/form-item';
|
|
15
|
+
type SliderProps = SliderSingleProps | SliderRangeProps;
|
|
16
|
+
type UnionType = Omit<AntdFormItemProps & InputProps & SelectProps & TreeSelectProps & SwitchProps & RadioProps & CheckboxProps & SliderProps, 'rules' | 'type' | 'disabled' | 'options' | 'required'>;
|
|
17
|
+
/**
|
|
18
|
+
* @noExtends
|
|
19
|
+
*/
|
|
20
|
+
export interface FormItemProps extends UnionType {
|
|
21
|
+
/**
|
|
22
|
+
* @description 表单类型
|
|
23
|
+
* @default input
|
|
24
|
+
*/
|
|
25
|
+
type?: InputComponentType | OtherComponentType;
|
|
26
|
+
/**
|
|
27
|
+
* @description 表单名称,支持层级嵌套,如:a.b.c
|
|
28
|
+
* @default (必选)
|
|
29
|
+
*/
|
|
30
|
+
name?: string;
|
|
31
|
+
/**
|
|
32
|
+
* @description 是否禁用
|
|
33
|
+
*/
|
|
34
|
+
disabled?: boolean | ((values: FormValues, params: CommonParams) => boolean);
|
|
35
|
+
/**
|
|
36
|
+
* @description 选择框下拉选项
|
|
37
|
+
* @link SelectOptions: /components/select#select-option
|
|
38
|
+
*/
|
|
39
|
+
options?: SelectOptions | ((values: FormValues, params: OptionsParams) => FunctionReturn<SelectOptions>);
|
|
40
|
+
/**
|
|
41
|
+
* @description 是否必填
|
|
42
|
+
*/
|
|
43
|
+
required?: boolean | string;
|
|
44
|
+
/**
|
|
45
|
+
* @description 校验 `value` 是否在 `options` 中
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
requiredInOptions?: boolean | string;
|
|
49
|
+
/**
|
|
50
|
+
* @description 自定义校验
|
|
51
|
+
*/
|
|
52
|
+
validator?(params: ValidatorProps): FunctionReturn<string | void>;
|
|
53
|
+
/**
|
|
54
|
+
* @description 是否过滤选项中不存在的值
|
|
55
|
+
* @default false
|
|
56
|
+
* @replaceAll boolean | "useFirstOption" | string | number
|
|
57
|
+
*/
|
|
58
|
+
filterNotExistValue?: boolean | string | number | 'useFirstOption';
|
|
59
|
+
/**
|
|
60
|
+
* @description 是否显示
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
show?: boolean | ((values: FormValues, params: CommonParams) => boolean);
|
|
64
|
+
/**
|
|
65
|
+
* @link FormItemRule: https://4x.ant.design/components/form-cn/#Rule
|
|
66
|
+
*/
|
|
67
|
+
rules?: FormItemRule[];
|
|
68
|
+
/**
|
|
69
|
+
* @description 日期选择器属性(当 `type` 为 `date`、`rangeDate` 时生效)
|
|
70
|
+
* @link DatePickerProps | RangePickerProps: /components/date-picker#api
|
|
71
|
+
*/
|
|
72
|
+
dateProps?: DatePickerProps | RangePickerProps;
|
|
73
|
+
/**
|
|
74
|
+
* @description flex 布局属性
|
|
75
|
+
* @default 1
|
|
76
|
+
*/
|
|
77
|
+
flex?: number | string;
|
|
78
|
+
/**
|
|
79
|
+
* @description label 宽度
|
|
80
|
+
*/
|
|
81
|
+
labelWidth?: number | string;
|
|
82
|
+
/**
|
|
83
|
+
* @description 输入框宽度
|
|
84
|
+
*/
|
|
85
|
+
controlWidth?: number | string;
|
|
86
|
+
/**
|
|
87
|
+
* @description 布局方式
|
|
88
|
+
* @default horizontal
|
|
89
|
+
*/
|
|
90
|
+
layout?: 'horizontal' | 'vertical';
|
|
91
|
+
preserveStatus?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* @description 自定义渲染
|
|
94
|
+
*/
|
|
95
|
+
render?: (params: RenderProps) => ReactElement;
|
|
96
|
+
/**
|
|
97
|
+
* @description 子节点
|
|
98
|
+
*/
|
|
99
|
+
children?: ReactNode | ((params: RenderChildrenProps) => ReactNode);
|
|
100
|
+
formListContext?: FormListContext;
|
|
101
|
+
dependencies?: string[];
|
|
102
|
+
removeErrorOnBlur?: boolean;
|
|
103
|
+
__noCollectState__?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface FormItemContext extends Pick<FormItemPropsWithType, 'type' | 'optionDependencies' | 'loading' | 'rules' | 'formListContext'> {
|
|
106
|
+
name: string;
|
|
107
|
+
options?: SelectOptions;
|
|
108
|
+
refs: Refs;
|
|
109
|
+
}
|
|
110
|
+
export interface OptionsParams extends CommonParams {
|
|
111
|
+
search: string;
|
|
112
|
+
}
|
|
113
|
+
export interface RenderProps extends CommonParams, FormItemProps {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
refs: Refs;
|
|
117
|
+
collectState(item: Partial<FormItemContext>): void;
|
|
118
|
+
}
|
|
119
|
+
interface RenderChildrenProps {
|
|
120
|
+
id: string;
|
|
121
|
+
refs: Refs;
|
|
122
|
+
value?: any;
|
|
123
|
+
onChange?(value: any): void;
|
|
124
|
+
onBlur?(event: any): void;
|
|
125
|
+
onFocus?(event: any): void;
|
|
126
|
+
}
|
|
127
|
+
export type FormItemRenderProps = Partial<RenderProps>;
|
|
128
|
+
export type FormItemChildrenProps = Partial<RenderChildrenProps>;
|
|
129
|
+
export type FormItemPropsWithType = FormItemProps & {
|
|
130
|
+
type: string;
|
|
131
|
+
name: string;
|
|
132
|
+
};
|
|
133
|
+
export interface ValidatorProps extends CommonParams {
|
|
134
|
+
value: any;
|
|
135
|
+
item: FormItemProps;
|
|
136
|
+
}
|
|
137
|
+
export type FormItemRule = {
|
|
138
|
+
validateOnMount?: boolean;
|
|
139
|
+
validator?: FormItemProps['validator'];
|
|
140
|
+
} | Omit<Rule, 'validator'>;
|
|
141
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ButtonProps } from "../../button";
|
|
2
|
+
import { FormItemProps, FormValues } from "..";
|
|
3
|
+
import { ListOperation } from "../../hooks";
|
|
4
|
+
import { FormListFieldData } from 'antd/lib/form/FormList';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
export interface FormListContext extends FormListCommonProps {
|
|
7
|
+
name: FormItemProps['name'];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @noExtends
|
|
11
|
+
*/
|
|
12
|
+
export interface FormListProps extends FormItemProps {
|
|
13
|
+
/**
|
|
14
|
+
* @description 表单名称,支持层级嵌套,如:a.b.c
|
|
15
|
+
*/
|
|
16
|
+
name: FormItemProps['name'];
|
|
17
|
+
/**
|
|
18
|
+
* @description 每一项渲染函数
|
|
19
|
+
*/
|
|
20
|
+
item?: ReactNode | ((props: FormListItemProps) => ReactNode);
|
|
21
|
+
/**
|
|
22
|
+
* @description 渲染函数
|
|
23
|
+
*/
|
|
24
|
+
children?(props: FormListChildrenProps): ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* @description 是否在新增时,聚焦第一个输入框
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
focusFirstOnAdd?: boolean | string;
|
|
30
|
+
}
|
|
31
|
+
export interface FormListItemProps extends FormListCommonProps {
|
|
32
|
+
/**
|
|
33
|
+
* @description 当前项的索引
|
|
34
|
+
*/
|
|
35
|
+
index: number;
|
|
36
|
+
/**
|
|
37
|
+
* @description 当前项的值
|
|
38
|
+
*/
|
|
39
|
+
value: any;
|
|
40
|
+
/**
|
|
41
|
+
* @description 更新当前项的值
|
|
42
|
+
*/
|
|
43
|
+
onChange(value?: any): void;
|
|
44
|
+
}
|
|
45
|
+
export interface FormListChildrenProps extends FormListCommonProps {
|
|
46
|
+
/**
|
|
47
|
+
* @description 当前 `List` 中,所有表单项的内容
|
|
48
|
+
*/
|
|
49
|
+
component: ReactNode;
|
|
50
|
+
}
|
|
51
|
+
type FormListOperation = Omit<ListOperation, 'value'>;
|
|
52
|
+
export interface FormListCommonProps extends FormListOperation {
|
|
53
|
+
/**
|
|
54
|
+
* @description 表单值
|
|
55
|
+
*/
|
|
56
|
+
values: FormValues;
|
|
57
|
+
/**
|
|
58
|
+
* @description 当前 `List` 中,所有表单字段
|
|
59
|
+
*/
|
|
60
|
+
fields: FormListFieldData[];
|
|
61
|
+
/**
|
|
62
|
+
* @description 错误信息
|
|
63
|
+
*/
|
|
64
|
+
errors: ReactNode[];
|
|
65
|
+
warnings: ReactNode[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @noExtends
|
|
69
|
+
*/
|
|
70
|
+
export interface FormListActionProps extends ButtonProps {
|
|
71
|
+
/**
|
|
72
|
+
* @description 操作类型
|
|
73
|
+
* @replaceAll "add" | "remove" | "moveUp" | "moveDown" | "move"
|
|
74
|
+
*/
|
|
75
|
+
operation: keyof Omit<FormListOperation, 'update'>;
|
|
76
|
+
/**
|
|
77
|
+
* @description 新增时的默认值(当 `operation` 为 `add` 时生效)
|
|
78
|
+
*/
|
|
79
|
+
defaultValue?: any;
|
|
80
|
+
/**
|
|
81
|
+
* @description 插入位置,默认为数组末尾(当 `operation` 为 `add` 时生效)
|
|
82
|
+
*/
|
|
83
|
+
insertIndex?: number;
|
|
84
|
+
/**
|
|
85
|
+
* @description 当前项的索引(当 `operation` 为 `remove` 时,`index` 为数组支持批量删除,不传时,则清空所有项)
|
|
86
|
+
*/
|
|
87
|
+
index?: number | number[];
|
|
88
|
+
from?: number;
|
|
89
|
+
to?: number;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|