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,280 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
var _excluded = ["loading", "footer"];
|
|
7
|
+
import { executeFunction } from "../../api";
|
|
8
|
+
import { FormProvider, useValidateForm } from "./..";
|
|
9
|
+
import { useDebounce, useDebounceState, useLoading, useSafeState } from "../../hooks";
|
|
10
|
+
import { Spin } from 'antd';
|
|
11
|
+
import delay from 'delay';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import { useMount, useSetState, useUpdateEffect } from 'react-use';
|
|
15
|
+
import { registerMethods } from "./constant";
|
|
16
|
+
import { FormItem } from "./form-item";
|
|
17
|
+
import { useDebug } from "./use-debug";
|
|
18
|
+
import { focusFirstInput, generateCollectionKey, getContextWrapper, hasItemLoading, removeFormListFormItems, removeTableEditorFormItems, setContextWrapper, validateFormOnMount } from "./utils";
|
|
19
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
20
|
+
function useItemsCollection(_ref) {
|
|
21
|
+
var form = _ref.form;
|
|
22
|
+
var _useState = useState([]),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
items = _useState2[0],
|
|
25
|
+
setItems = _useState2[1];
|
|
26
|
+
var itemsRef = useRef({});
|
|
27
|
+
var updateItems = useDebounce(function () {
|
|
28
|
+
var items = _.values(itemsRef.current);
|
|
29
|
+
setItems(items);
|
|
30
|
+
form.setItems(items);
|
|
31
|
+
}, 20);
|
|
32
|
+
function collect(item) {
|
|
33
|
+
var key = generateCollectionKey(item.name);
|
|
34
|
+
if (!key) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
_.set(itemsRef.current, key, item);
|
|
38
|
+
updateItems();
|
|
39
|
+
}
|
|
40
|
+
function removeCollect(name) {
|
|
41
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
42
|
+
var key = generateCollectionKey(name);
|
|
43
|
+
if (!key) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (options.isFormList) {
|
|
47
|
+
itemsRef.current = removeFormListFormItems(name, itemsRef.current);
|
|
48
|
+
return updateItems();
|
|
49
|
+
}
|
|
50
|
+
if (options.isTableEditor) {
|
|
51
|
+
itemsRef.current = removeTableEditorFormItems(name, itemsRef.current);
|
|
52
|
+
return updateItems();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 只有当 ListItem 卸载时,才重置 loading
|
|
56
|
+
var path = options.onlyResetLoading ? [key, 'loading'] : key;
|
|
57
|
+
_.unset(itemsRef.current, path);
|
|
58
|
+
updateItems();
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
collect: collect,
|
|
62
|
+
removeCollect: removeCollect,
|
|
63
|
+
items: items
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function useInit(_ref2) {
|
|
67
|
+
var form = _ref2.form,
|
|
68
|
+
initialValues = _ref2.initialValues,
|
|
69
|
+
initialContext = _ref2.initialContext;
|
|
70
|
+
var _useSetState = useSetState({}),
|
|
71
|
+
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
72
|
+
context = _useSetState2[0],
|
|
73
|
+
setContext = _useSetState2[1];
|
|
74
|
+
var _useLoading = useLoading( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
75
|
+
var context, values;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
_context.next = 2;
|
|
80
|
+
return executeFunction(initialContext);
|
|
81
|
+
case 2:
|
|
82
|
+
context = _context.sent;
|
|
83
|
+
_context.next = 5;
|
|
84
|
+
return executeFunction(initialValues, context);
|
|
85
|
+
case 5:
|
|
86
|
+
values = _context.sent;
|
|
87
|
+
form.setFieldsValue(values);
|
|
88
|
+
setContext(context);
|
|
89
|
+
case 8:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee);
|
|
94
|
+
}))),
|
|
95
|
+
_useLoading2 = _slicedToArray(_useLoading, 2),
|
|
96
|
+
_useLoading2$ = _useLoading2[0],
|
|
97
|
+
loading = _useLoading2$ === void 0 ? true : _useLoading2$,
|
|
98
|
+
init = _useLoading2[1];
|
|
99
|
+
|
|
100
|
+
// 初始化数据
|
|
101
|
+
useMount(init);
|
|
102
|
+
return {
|
|
103
|
+
loading: loading,
|
|
104
|
+
context: context,
|
|
105
|
+
setContext: setContext
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export function useValidateFormOnMount(props) {
|
|
109
|
+
var isValidated = useRef(false);
|
|
110
|
+
var _useItemsCollection = useItemsCollection(props),
|
|
111
|
+
collect = _useItemsCollection.collect,
|
|
112
|
+
removeCollect = _useItemsCollection.removeCollect,
|
|
113
|
+
items = _useItemsCollection.items;
|
|
114
|
+
var form = props.form,
|
|
115
|
+
onMount = props.onMount,
|
|
116
|
+
loading = props.loading,
|
|
117
|
+
validateOnMount = props.validateOnMount,
|
|
118
|
+
focusFirstOnMount = props.focusFirstOnMount;
|
|
119
|
+
function validateForm() {
|
|
120
|
+
return _validateForm.apply(this, arguments);
|
|
121
|
+
} // loading 中不校验,避免表单数据未初始化完成
|
|
122
|
+
function _validateForm() {
|
|
123
|
+
_validateForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
124
|
+
var params;
|
|
125
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
126
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (!shouldSkipValidation()) {
|
|
129
|
+
_context2.next = 2;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
return _context2.abrupt("return");
|
|
133
|
+
case 2:
|
|
134
|
+
_context2.next = 4;
|
|
135
|
+
return delay(20);
|
|
136
|
+
case 4:
|
|
137
|
+
// 等待表单渲染完成
|
|
138
|
+
params = {
|
|
139
|
+
form: form,
|
|
140
|
+
items: items
|
|
141
|
+
};
|
|
142
|
+
_context2.next = 7;
|
|
143
|
+
return validateFormOnMount(params, validateOnMount);
|
|
144
|
+
case 7:
|
|
145
|
+
focusFirstInput(_objectSpread(_objectSpread({}, params), {}, {
|
|
146
|
+
focusFirstOnMount: focusFirstOnMount
|
|
147
|
+
}));
|
|
148
|
+
onMount === null || onMount === void 0 || onMount(params);
|
|
149
|
+
isValidated.current = true;
|
|
150
|
+
case 10:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context2.stop();
|
|
153
|
+
}
|
|
154
|
+
}, _callee2);
|
|
155
|
+
}));
|
|
156
|
+
return _validateForm.apply(this, arguments);
|
|
157
|
+
}
|
|
158
|
+
function shouldSkipValidation() {
|
|
159
|
+
return isValidated.current || loading || _.isEmpty(items) || hasItemLoading(items);
|
|
160
|
+
}
|
|
161
|
+
var validate = useDebounce(validateForm, 100, {
|
|
162
|
+
leading: false
|
|
163
|
+
});
|
|
164
|
+
useUpdateEffect(function () {
|
|
165
|
+
validate();
|
|
166
|
+
}, [loading, items]);
|
|
167
|
+
return {
|
|
168
|
+
collect: collect,
|
|
169
|
+
removeCollect: removeCollect,
|
|
170
|
+
items: items
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function useFormSpinning(context) {
|
|
174
|
+
var _useSafeState = useSafeState(true),
|
|
175
|
+
_useSafeState2 = _slicedToArray(_useSafeState, 2),
|
|
176
|
+
spinning = _useSafeState2[0],
|
|
177
|
+
setSpinning = _useSafeState2[1];
|
|
178
|
+
var currentSpinning = context.loading || hasItemLoading(context.items);
|
|
179
|
+
var debounceTime = 100;
|
|
180
|
+
var updateSpinning = useDebounce(function (loading) {
|
|
181
|
+
!loading && setSpinning(false);
|
|
182
|
+
}, debounceTime, {
|
|
183
|
+
leading: false
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// 只有首次使用合成 loading
|
|
187
|
+
useEffect(function () {
|
|
188
|
+
spinning && updateSpinning(currentSpinning);
|
|
189
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
190
|
+
}, [currentSpinning]);
|
|
191
|
+
|
|
192
|
+
// 注册事件
|
|
193
|
+
context.form.registerMethod(registerMethods.getLoading, function () {
|
|
194
|
+
return spinning;
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// 等待 FormItem 渲染校验完成
|
|
198
|
+
return useDebounceState(spinning, debounceTime);
|
|
199
|
+
}
|
|
200
|
+
function useFormContext(props) {
|
|
201
|
+
var _useInit = useInit(props),
|
|
202
|
+
loading = _useInit.loading,
|
|
203
|
+
initialContext = _useInit.context,
|
|
204
|
+
setContext = _useInit.setContext;
|
|
205
|
+
var _useValidateFormOnMou = useValidateFormOnMount(_objectSpread(_objectSpread({}, props), {}, {
|
|
206
|
+
loading: loading
|
|
207
|
+
})),
|
|
208
|
+
collect = _useValidateFormOnMou.collect,
|
|
209
|
+
removeCollect = _useValidateFormOnMou.removeCollect,
|
|
210
|
+
items = _useValidateFormOnMou.items;
|
|
211
|
+
var form = props.form,
|
|
212
|
+
context = props.context,
|
|
213
|
+
disabled = props.disabled,
|
|
214
|
+
debug = props.debug;
|
|
215
|
+
var spinning = useFormSpinning({
|
|
216
|
+
loading: loading,
|
|
217
|
+
items: items,
|
|
218
|
+
form: form
|
|
219
|
+
});
|
|
220
|
+
var values = form.getValue();
|
|
221
|
+
var allContext = _objectSpread(_objectSpread(_objectSpread({}, initialContext), context), {}, {
|
|
222
|
+
loading: loading,
|
|
223
|
+
// initialContext、initialValues 的 loading
|
|
224
|
+
spinning: spinning,
|
|
225
|
+
// 控制 Spin 的 Loading 是否显示
|
|
226
|
+
disabled: disabled,
|
|
227
|
+
form: form,
|
|
228
|
+
values: values,
|
|
229
|
+
items: items,
|
|
230
|
+
debug: debug,
|
|
231
|
+
__collect__: collect,
|
|
232
|
+
__removeCollect__: removeCollect
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// 注册事件
|
|
236
|
+
form.setContext = setContextWrapper(setContext);
|
|
237
|
+
form.getContext = getContextWrapper(allContext);
|
|
238
|
+
return allContext;
|
|
239
|
+
}
|
|
240
|
+
function FormChildren(_ref4) {
|
|
241
|
+
var items = _ref4.items,
|
|
242
|
+
children = _ref4.children,
|
|
243
|
+
onValidate = _ref4.onValidate;
|
|
244
|
+
useValidateForm({
|
|
245
|
+
onValidate: onValidate,
|
|
246
|
+
validateOnly: true
|
|
247
|
+
});
|
|
248
|
+
useDebug();
|
|
249
|
+
if (children) {
|
|
250
|
+
return _jsx(_Fragment, {
|
|
251
|
+
children: children
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return _jsx(_Fragment, {
|
|
255
|
+
children: _.map(items, function (item, index) {
|
|
256
|
+
return _jsx(FormItem, _objectSpread({}, item), item.name || index);
|
|
257
|
+
})
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
export function FormContent(_ref5) {
|
|
261
|
+
var _ref5$loading = _ref5.loading,
|
|
262
|
+
useLoadingWrapper = _ref5$loading === void 0 ? true : _ref5$loading,
|
|
263
|
+
footer = _ref5.footer,
|
|
264
|
+
props = _objectWithoutProperties(_ref5, _excluded);
|
|
265
|
+
var context = useFormContext(props);
|
|
266
|
+
function render() {
|
|
267
|
+
if (useLoadingWrapper) {
|
|
268
|
+
return _jsxs(Spin, {
|
|
269
|
+
spinning: context.spinning,
|
|
270
|
+
children: [_jsx(FormChildren, _objectSpread({}, props)), footer]
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return _jsxs(_Fragment, {
|
|
274
|
+
children: [_jsx(FormChildren, _objectSpread({}, props)), footer]
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return _jsx(FormProvider, _objectSpread(_objectSpread({}, context), {}, {
|
|
278
|
+
children: render()
|
|
279
|
+
}));
|
|
280
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckboxProps } from "../../checkbox";
|
|
3
|
+
import { DatePicker, RangePicker } from "../../date-picker";
|
|
4
|
+
import { FormInstance, FormItemContext, FormItemProps } from "..";
|
|
5
|
+
import { Radio } from "../../radio";
|
|
6
|
+
import { SelectCallbackProps, SelectProps } from "../../select";
|
|
7
|
+
import { Switch } from "../../switch";
|
|
8
|
+
import { TreeSelectProps } from "../../tree-select";
|
|
9
|
+
export interface FormItemSelectProps extends Pick<FormItemProps, 'requiredInOptions' | 'filterNotExistValue' | 'labelInValue'> {
|
|
10
|
+
name: string;
|
|
11
|
+
form?: FormInstance;
|
|
12
|
+
collectState(item: Partial<FormItemContext>): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function useCollectFormItemState({ name, collectState, filterNotExistValue, requiredInOptions, form: outerForm, ...props }: FormItemSelectProps): {
|
|
15
|
+
__filterNotExistValue__: boolean;
|
|
16
|
+
__callback__: import("use-debounce").DebouncedState<({ loading, options, value }: SelectCallbackProps) => Promise<void>>;
|
|
17
|
+
labelInValue?: boolean | undefined;
|
|
18
|
+
};
|
|
19
|
+
declare function FormItemSelect(props: FormItemSelectProps & SelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function FormItemTreeSelect(props: FormItemSelectProps & TreeSelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare function FormItemTree(props: FormItemSelectProps & TreeSelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare function FormItemCheckbox(props: FormItemSelectProps & CheckboxProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const supportCollectStateItem: {
|
|
24
|
+
select: typeof FormItemSelect;
|
|
25
|
+
treeSelect: typeof FormItemTreeSelect;
|
|
26
|
+
tree: typeof FormItemTree;
|
|
27
|
+
checkbox: typeof FormItemCheckbox;
|
|
28
|
+
};
|
|
29
|
+
export declare const formItemMap: {
|
|
30
|
+
select: typeof FormItemSelect;
|
|
31
|
+
treeSelect: typeof FormItemTreeSelect;
|
|
32
|
+
tree: typeof FormItemTree;
|
|
33
|
+
checkbox: typeof FormItemCheckbox;
|
|
34
|
+
switch: typeof Switch;
|
|
35
|
+
radio: typeof Radio;
|
|
36
|
+
slider: import("react").ForwardRefExoticComponent<(import("antd").SliderSingleProps | import("antd/lib/slider").SliderRangeProps) & import("react").RefAttributes<unknown>>;
|
|
37
|
+
date: typeof DatePicker;
|
|
38
|
+
rangeDate: typeof RangePicker;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["name", "collectState", "filterNotExistValue", "requiredInOptions", "form"];
|
|
6
|
+
import { Checkbox } from "../../checkbox";
|
|
7
|
+
import { DatePicker, RangePicker } from "../../date-picker";
|
|
8
|
+
import { useFormContext } from "./..";
|
|
9
|
+
import { useDebounce } from "../../hooks";
|
|
10
|
+
import { Radio } from "../../radio";
|
|
11
|
+
import { Select } from "../../select";
|
|
12
|
+
import { Switch } from "../../switch";
|
|
13
|
+
import { Tree } from "../../tree";
|
|
14
|
+
import { TreeSelect } from "../../tree-select";
|
|
15
|
+
import { Slider } from 'antd';
|
|
16
|
+
import delay from 'delay';
|
|
17
|
+
import { isEmpty, transformPathToName, updateNotExistValue } from "./utils";
|
|
18
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
19
|
+
export function useCollectFormItemState(_ref) {
|
|
20
|
+
var name = _ref.name,
|
|
21
|
+
collectState = _ref.collectState,
|
|
22
|
+
filterNotExistValue = _ref.filterNotExistValue,
|
|
23
|
+
requiredInOptions = _ref.requiredInOptions,
|
|
24
|
+
outerForm = _ref.form,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var _useFormContext = useFormContext(),
|
|
27
|
+
_useFormContext$form = _useFormContext.form,
|
|
28
|
+
form = _useFormContext$form === void 0 ? outerForm : _useFormContext$form;
|
|
29
|
+
var requiredInOptionsAndFilterNotExistValue = requiredInOptions && filterNotExistValue;
|
|
30
|
+
function onCallback(_x) {
|
|
31
|
+
return _onCallback.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
function _onCallback() {
|
|
34
|
+
_onCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
35
|
+
var loading, options, value, isUpdated;
|
|
36
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
37
|
+
while (1) switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
loading = _ref2.loading, options = _ref2.options, value = _ref2.value;
|
|
40
|
+
collectState({
|
|
41
|
+
loading: loading,
|
|
42
|
+
options: options
|
|
43
|
+
});
|
|
44
|
+
if (!(loading || isEmpty(value))) {
|
|
45
|
+
_context.next = 4;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
return _context.abrupt("return");
|
|
49
|
+
case 4:
|
|
50
|
+
if (requiredInOptionsAndFilterNotExistValue) {
|
|
51
|
+
_context.next = 8;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
isUpdated = updateNotExistValue({
|
|
55
|
+
filterNotExistValue: filterNotExistValue,
|
|
56
|
+
form: form,
|
|
57
|
+
value: value,
|
|
58
|
+
name: name,
|
|
59
|
+
options: options,
|
|
60
|
+
labelInValue: props.labelInValue
|
|
61
|
+
});
|
|
62
|
+
if (!isUpdated) {
|
|
63
|
+
_context.next = 8;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return _context.abrupt("return");
|
|
67
|
+
case 8:
|
|
68
|
+
if (!requiredInOptions) {
|
|
69
|
+
_context.next = 13;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
_context.next = 11;
|
|
73
|
+
return delay(50);
|
|
74
|
+
case 11:
|
|
75
|
+
_context.next = 13;
|
|
76
|
+
return form.validate(transformPathToName(name));
|
|
77
|
+
case 13:
|
|
78
|
+
case "end":
|
|
79
|
+
return _context.stop();
|
|
80
|
+
}
|
|
81
|
+
}, _callee);
|
|
82
|
+
}));
|
|
83
|
+
return _onCallback.apply(this, arguments);
|
|
84
|
+
}
|
|
85
|
+
return _objectSpread(_objectSpread({}, props), {}, {
|
|
86
|
+
__filterNotExistValue__: !!requiredInOptionsAndFilterNotExistValue,
|
|
87
|
+
__callback__: useDebounce(onCallback)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function FormItemSelect(props) {
|
|
91
|
+
var params = useCollectFormItemState(props);
|
|
92
|
+
return _jsx(Select, _objectSpread({}, params));
|
|
93
|
+
}
|
|
94
|
+
function FormItemTreeSelect(props) {
|
|
95
|
+
var params = useCollectFormItemState(props);
|
|
96
|
+
return _jsx(TreeSelect, _objectSpread({}, params));
|
|
97
|
+
}
|
|
98
|
+
function FormItemTree(props) {
|
|
99
|
+
var params = useCollectFormItemState(props);
|
|
100
|
+
return _jsx(Tree, _objectSpread({}, params));
|
|
101
|
+
}
|
|
102
|
+
function FormItemCheckbox(props) {
|
|
103
|
+
var params = useCollectFormItemState(_objectSpread({
|
|
104
|
+
filterNotExistValue: true
|
|
105
|
+
}, props));
|
|
106
|
+
return _jsx(Checkbox, _objectSpread({}, params));
|
|
107
|
+
}
|
|
108
|
+
export var supportCollectStateItem = {
|
|
109
|
+
select: FormItemSelect,
|
|
110
|
+
treeSelect: FormItemTreeSelect,
|
|
111
|
+
tree: FormItemTree,
|
|
112
|
+
checkbox: FormItemCheckbox
|
|
113
|
+
};
|
|
114
|
+
export var formItemMap = _objectSpread({
|
|
115
|
+
switch: Switch,
|
|
116
|
+
radio: Radio,
|
|
117
|
+
slider: Slider,
|
|
118
|
+
date: DatePicker,
|
|
119
|
+
rangeDate: RangePicker
|
|
120
|
+
}, supportCollectStateItem);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormItemProps } from "..";
|
|
2
|
+
import { InputProps } from "../../input";
|
|
3
|
+
import { formItemMap } from './form-item-map';
|
|
4
|
+
export type InputComponentType = InputProps['type'];
|
|
5
|
+
export type OtherComponentType = keyof typeof formItemMap;
|
|
6
|
+
export declare function useCollectItemsStatus({ name, preserveStatus }: FormItemProps): void;
|
|
7
|
+
export declare function FormItem(props: FormItemProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
var _excluded = ["item", "items"],
|
|
5
|
+
_excluded2 = ["type", "name", "disabled", "dateProps", "render", "onChange"],
|
|
6
|
+
_excluded3 = ["show", "className", "style", "flex", "labelWidth", "controlWidth", "requiredMark", "layout"];
|
|
7
|
+
import { executeFunction, mergeFunction, mergeProps } from "../../api";
|
|
8
|
+
import { useFormContext, useFormListContext } from "./..";
|
|
9
|
+
import { useDeepEffect } from "../../hooks";
|
|
10
|
+
import { Input } from "../../input";
|
|
11
|
+
import { inputMap } from "../../input/component";
|
|
12
|
+
import { cx } from '@emotion/css';
|
|
13
|
+
import { Form } from 'antd';
|
|
14
|
+
import _ from 'lodash';
|
|
15
|
+
import { useEffect, useRef } from 'react';
|
|
16
|
+
import { useSetState, useUnmount, useUpdateEffect } from 'react-use';
|
|
17
|
+
import { getFormItemStyle, getFormItemWidth } from "../style";
|
|
18
|
+
import { needCollectItemPropKeys, registerMethods } from "./constant";
|
|
19
|
+
import { formItemMap, supportCollectStateItem } from "./form-item-map";
|
|
20
|
+
import { generateFormItem, getComponentProps, getFormItemId, getFormItemProps, noStyle, transformOptions } from "./utils";
|
|
21
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
22
|
+
export function useCollectItemsStatus(_ref) {
|
|
23
|
+
var name = _ref.name,
|
|
24
|
+
preserveStatus = _ref.preserveStatus;
|
|
25
|
+
var _useFormContext = useFormContext(),
|
|
26
|
+
form = _useFormContext.form;
|
|
27
|
+
var _Form$Item$useStatus = Form.Item.useStatus(),
|
|
28
|
+
status = _Form$Item$useStatus.status;
|
|
29
|
+
|
|
30
|
+
// 还原 Error
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
if (!preserveStatus) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
var errors = form.callMethod(registerMethods.getItemsStatus, name);
|
|
36
|
+
if (_.isEmpty(errors)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
form.setFields([{
|
|
40
|
+
name: name,
|
|
41
|
+
errors: errors
|
|
42
|
+
}]);
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
}, [preserveStatus]);
|
|
45
|
+
|
|
46
|
+
// 将 Error 缓存到 Form 中
|
|
47
|
+
useUpdateEffect(function () {
|
|
48
|
+
var errors = form.getFieldError(name);
|
|
49
|
+
form.callMethod(registerMethods.setItemsStatus, name, errors);
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, [status]);
|
|
52
|
+
}
|
|
53
|
+
function useCollectItemState(item) {
|
|
54
|
+
var refs = useRef();
|
|
55
|
+
var _useFormContext2 = useFormContext(),
|
|
56
|
+
form = _useFormContext2.form,
|
|
57
|
+
__collect__ = _useFormContext2.__collect__,
|
|
58
|
+
__removeCollect__ = _useFormContext2.__removeCollect__;
|
|
59
|
+
var initialState = _.pick(item, needCollectItemPropKeys);
|
|
60
|
+
var _useSetState = useSetState(initialState),
|
|
61
|
+
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
62
|
+
itemState = _useSetState2[0],
|
|
63
|
+
collectState = _useSetState2[1];
|
|
64
|
+
useDeepEffect(function () {
|
|
65
|
+
if (item.__noCollectState__) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
__collect__(_objectSpread(_objectSpread({}, itemState), {}, {
|
|
69
|
+
refs: refs
|
|
70
|
+
}));
|
|
71
|
+
}, [itemState]);
|
|
72
|
+
useCollectItemsStatus(item);
|
|
73
|
+
useUnmount(function () {
|
|
74
|
+
if (item.__noCollectState__) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!item.preserveStatus) {
|
|
78
|
+
resetError();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ListItem 卸载时,索引会发生变化,所以只需重置 loading,其余属性统一在 FormList 卸载时处理
|
|
82
|
+
var isListField = item.isListField || !_.isEmpty(itemState.formListContext);
|
|
83
|
+
__removeCollect__(itemState.name, {
|
|
84
|
+
onlyResetLoading: isListField
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
function resetError() {
|
|
88
|
+
form.callMethod(registerMethods.resetInternalError, item.name);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
refs: refs,
|
|
92
|
+
collectState: collectState,
|
|
93
|
+
resetError: resetError
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function FormItemChildren(_ref2) {
|
|
97
|
+
var item = _ref2.item,
|
|
98
|
+
items = _ref2.items,
|
|
99
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
100
|
+
var _useFormContext3 = useFormContext(),
|
|
101
|
+
form = _useFormContext3.form,
|
|
102
|
+
values = _useFormContext3.values,
|
|
103
|
+
globalDisabled = _useFormContext3.disabled;
|
|
104
|
+
var params = {
|
|
105
|
+
form: form,
|
|
106
|
+
items: items
|
|
107
|
+
};
|
|
108
|
+
var type = item.type,
|
|
109
|
+
name = item.name,
|
|
110
|
+
disabled = item.disabled,
|
|
111
|
+
dateProps = item.dateProps,
|
|
112
|
+
render = item.render,
|
|
113
|
+
onChange = item.onChange,
|
|
114
|
+
restItem = _objectWithoutProperties(item, _excluded2);
|
|
115
|
+
var _useCollectItemState = useCollectItemState(item),
|
|
116
|
+
refs = _useCollectItemState.refs,
|
|
117
|
+
collectState = _useCollectItemState.collectState,
|
|
118
|
+
resetError = _useCollectItemState.resetError;
|
|
119
|
+
var baseProps = _objectSpread(_objectSpread({}, getComponentProps(restItem)), {}, {
|
|
120
|
+
disabled: globalDisabled !== null && globalDisabled !== void 0 ? globalDisabled : executeFunction(disabled, values, params),
|
|
121
|
+
onChange: mergeFunction(resetError, onChange),
|
|
122
|
+
name: name,
|
|
123
|
+
refs: refs
|
|
124
|
+
});
|
|
125
|
+
var componentProps = mergeProps(baseProps, props);
|
|
126
|
+
if (render) {
|
|
127
|
+
return render(_objectSpread(_objectSpread({}, componentProps), {}, {
|
|
128
|
+
collectState: collectState,
|
|
129
|
+
items: items,
|
|
130
|
+
form: form,
|
|
131
|
+
refs: refs,
|
|
132
|
+
id: getFormItemId(name, form)
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
if (type in inputMap) {
|
|
136
|
+
return _jsx(Input, _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
137
|
+
type: type
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
var otherComponentProps = _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
141
|
+
options: transformOptions(item, values, params)
|
|
142
|
+
});
|
|
143
|
+
if (_.get(supportCollectStateItem, type)) {
|
|
144
|
+
_.assign(otherComponentProps, {
|
|
145
|
+
collectState: collectState
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
var Component = formItemMap[type];
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
return _jsx(Component, _objectSpread(_objectSpread({}, otherComponentProps), dateProps));
|
|
151
|
+
}
|
|
152
|
+
function FormItemComponent(_ref3) {
|
|
153
|
+
var item = _ref3.item,
|
|
154
|
+
items = _ref3.items;
|
|
155
|
+
var _useFormContext4 = useFormContext(),
|
|
156
|
+
form = _useFormContext4.form,
|
|
157
|
+
values = _useFormContext4.values;
|
|
158
|
+
var _item$show = item.show,
|
|
159
|
+
show = _item$show === void 0 ? true : _item$show,
|
|
160
|
+
className = item.className,
|
|
161
|
+
style = item.style,
|
|
162
|
+
flex = item.flex,
|
|
163
|
+
labelWidth = item.labelWidth,
|
|
164
|
+
controlWidth = item.controlWidth,
|
|
165
|
+
requiredMark = item.requiredMark,
|
|
166
|
+
layout = item.layout,
|
|
167
|
+
restItem = _objectWithoutProperties(item, _excluded3);
|
|
168
|
+
|
|
169
|
+
// 是否显示
|
|
170
|
+
var params = {
|
|
171
|
+
form: form,
|
|
172
|
+
items: items
|
|
173
|
+
};
|
|
174
|
+
if (!executeFunction(show, values, params)) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
var cssName = getFormItemStyle({
|
|
178
|
+
width: getFormItemWidth(restItem),
|
|
179
|
+
style: style,
|
|
180
|
+
flex: flex,
|
|
181
|
+
labelWidth: labelWidth,
|
|
182
|
+
controlWidth: controlWidth,
|
|
183
|
+
requiredMark: requiredMark,
|
|
184
|
+
layout: layout,
|
|
185
|
+
type: restItem.type
|
|
186
|
+
});
|
|
187
|
+
var formItemProps = getFormItemProps(_objectSpread({
|
|
188
|
+
form: form,
|
|
189
|
+
style: style,
|
|
190
|
+
className: cx(cssName, className),
|
|
191
|
+
noStyle: noStyle(item)
|
|
192
|
+
}, restItem));
|
|
193
|
+
return _jsx(Form.Item, _objectSpread(_objectSpread({}, formItemProps), {}, {
|
|
194
|
+
children: _jsx(FormItemChildren, {
|
|
195
|
+
item: restItem,
|
|
196
|
+
items: items
|
|
197
|
+
})
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
export function FormItem(props) {
|
|
201
|
+
var _useFormContext5 = useFormContext(),
|
|
202
|
+
items = _useFormContext5.items,
|
|
203
|
+
form = _useFormContext5.form;
|
|
204
|
+
var formListContext = useFormListContext();
|
|
205
|
+
var item = generateFormItem({
|
|
206
|
+
form: form,
|
|
207
|
+
items: items,
|
|
208
|
+
item: _objectSpread({}, props),
|
|
209
|
+
formListContext: formListContext
|
|
210
|
+
});
|
|
211
|
+
if (!form) {
|
|
212
|
+
console.error('FormItem can only be used in Form! \n');
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
return _jsx(FormItemComponent, {
|
|
216
|
+
item: item,
|
|
217
|
+
items: items
|
|
218
|
+
});
|
|
219
|
+
}
|