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,435 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
var _excluded = ["onValidateFailed", "initialValues", "form"],
|
|
7
|
+
_excluded2 = ["tooltip"],
|
|
8
|
+
_excluded3 = ["className", "style"],
|
|
9
|
+
_excluded4 = ["children"];
|
|
10
|
+
/* eslint-disable max-lines */
|
|
11
|
+
import { includesNonStrictMode, renderComponentByType } from "../../api";
|
|
12
|
+
import { getOptionsValue } from "../../select/component/utils";
|
|
13
|
+
import { generateTooltip } from "../../text";
|
|
14
|
+
import { getTooltipProps } from "../../tooltip";
|
|
15
|
+
import { InfoCircleOutlined } from '@ant-design/icons';
|
|
16
|
+
import { getFieldId } from 'antd/lib/form/util';
|
|
17
|
+
import delay from 'delay';
|
|
18
|
+
import _ from 'lodash';
|
|
19
|
+
import { antdFormItemKeys, antdFormPropsKeys, registerMethods } from "./constant";
|
|
20
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
|
+
export function getFormProps(props) {
|
|
22
|
+
var _props$form;
|
|
23
|
+
var _$pick = _.pick(props, antdFormPropsKeys),
|
|
24
|
+
onValidateFailed = _$pick.onValidateFailed,
|
|
25
|
+
initialValues = _$pick.initialValues,
|
|
26
|
+
form = _$pick.form,
|
|
27
|
+
formProps = _objectWithoutProperties(_$pick, _excluded);
|
|
28
|
+
return _.merge({
|
|
29
|
+
form: form,
|
|
30
|
+
name: (_props$form = props.form) === null || _props$form === void 0 ? void 0 : _props$form.getName(),
|
|
31
|
+
component: 'div',
|
|
32
|
+
autoComplete: 'off',
|
|
33
|
+
labelWrap: true,
|
|
34
|
+
validateMessages: {
|
|
35
|
+
required: '${label} is required.'
|
|
36
|
+
},
|
|
37
|
+
validateTrigger: ['onChange', 'onBlur'],
|
|
38
|
+
onFinishFailed: function onFinishFailed(error) {
|
|
39
|
+
var errorInfo = parseFormFailedError(error);
|
|
40
|
+
onValidateFailed === null || onValidateFailed === void 0 || onValidateFailed(errorInfo);
|
|
41
|
+
}
|
|
42
|
+
}, formProps);
|
|
43
|
+
}
|
|
44
|
+
export function getFormItemProps(props) {
|
|
45
|
+
var _props$initialValue;
|
|
46
|
+
var _$pick2 = _.pick(props, antdFormItemKeys),
|
|
47
|
+
tooltip = _$pick2.tooltip,
|
|
48
|
+
pickProps = _objectWithoutProperties(_$pick2, _excluded2);
|
|
49
|
+
var name = removePrefixNameIfNeed(props.formListContext, props.name);
|
|
50
|
+
return _objectSpread(_objectSpread({}, pickProps), {}, {
|
|
51
|
+
name: name,
|
|
52
|
+
tooltip: generateTooltipWithIcon(tooltip),
|
|
53
|
+
initialValue: (_props$initialValue = props.initialValue) !== null && _props$initialValue !== void 0 ? _props$initialValue : props.defaultValue
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function generateTooltipWithIcon(tooltip) {
|
|
57
|
+
if (!tooltip) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var _getTooltipProps = getTooltipProps(generateTooltip(tooltip)),
|
|
61
|
+
className = _getTooltipProps.className,
|
|
62
|
+
style = _getTooltipProps.style,
|
|
63
|
+
tooltipProps = _objectWithoutProperties(_getTooltipProps, _excluded3);
|
|
64
|
+
return _objectSpread({
|
|
65
|
+
icon: _jsx(InfoCircleOutlined, {
|
|
66
|
+
className: className,
|
|
67
|
+
style: style
|
|
68
|
+
})
|
|
69
|
+
}, tooltipProps);
|
|
70
|
+
}
|
|
71
|
+
export function getComponentProps(props) {
|
|
72
|
+
var keys = [].concat(_toConsumableArray(antdFormItemKeys), ['formListContext', 'formItemContext', 'children', 'validator', 'removeErrorOnBlur', 'preserveStatus']);
|
|
73
|
+
return _.omit(props, keys);
|
|
74
|
+
}
|
|
75
|
+
export function generateFormItem(props) {
|
|
76
|
+
var item = props.item,
|
|
77
|
+
formListContext = props.formListContext;
|
|
78
|
+
var processedItem = processFormItemProps(item, formListContext);
|
|
79
|
+
return _objectSpread(_objectSpread({}, processedItem), {}, {
|
|
80
|
+
rules: generateRules(_objectSpread(_objectSpread({}, props), {}, {
|
|
81
|
+
item: processedItem
|
|
82
|
+
})),
|
|
83
|
+
type: item.type || 'input',
|
|
84
|
+
dependencies: transformNameToPath(item.dependencies)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function processFormItemProps(_ref, formListContext) {
|
|
88
|
+
var children = _ref.children,
|
|
89
|
+
item = _objectWithoutProperties(_ref, _excluded4);
|
|
90
|
+
if (children) {
|
|
91
|
+
item.render = function (params) {
|
|
92
|
+
var props = _.pick(params, ['refs', 'id', 'value', 'onChange', 'onBlur', 'onFocus']);
|
|
93
|
+
return renderComponentByType(children, props);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 将嵌套的 name 转换 antd form 的 name
|
|
98
|
+
_.set(item, 'name', transformNameToPath(item.name));
|
|
99
|
+
|
|
100
|
+
// 挂载 formListContext 属性,并拼接 name
|
|
101
|
+
if (!_.isEmpty(formListContext)) {
|
|
102
|
+
item.formListContext = formListContext;
|
|
103
|
+
item.isListField = true;
|
|
104
|
+
_.set(item, 'name', generateListItemName(formListContext.name, item.name));
|
|
105
|
+
}
|
|
106
|
+
return item;
|
|
107
|
+
}
|
|
108
|
+
export function generateListItemName(listName, name) {
|
|
109
|
+
return _.flattenDeep([listName, name]).filter(function (x) {
|
|
110
|
+
return !_.isNil(x);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export function removePrefixNameIfNeed(formListContext, name) {
|
|
114
|
+
var listName = formListContext === null || formListContext === void 0 ? void 0 : formListContext.name;
|
|
115
|
+
return listName ? _.drop(name, _.castArray(listName).length) : name;
|
|
116
|
+
}
|
|
117
|
+
function generateRules(_ref2) {
|
|
118
|
+
var item = _ref2.item,
|
|
119
|
+
form = _ref2.form,
|
|
120
|
+
items = _ref2.items,
|
|
121
|
+
isFormList = _ref2.isFormList;
|
|
122
|
+
var rules = _.clone(item.rules || []);
|
|
123
|
+
var params = {
|
|
124
|
+
form: form,
|
|
125
|
+
items: items
|
|
126
|
+
};
|
|
127
|
+
if (item.required && !item.rules) {
|
|
128
|
+
var message = generateRequiredMessage(item);
|
|
129
|
+
rules.push({
|
|
130
|
+
required: true,
|
|
131
|
+
message: message
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (item.validator) {
|
|
135
|
+
rules.push({
|
|
136
|
+
validator: item.validator
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (!isFormList && !item.removeErrorOnBlur) {
|
|
140
|
+
rules.push({
|
|
141
|
+
validator: function validator() {
|
|
142
|
+
return form.callMethod(registerMethods.getInternalErrors, item.name);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (item.requiredInOptions) {
|
|
147
|
+
var _message = _.isString(item.requiredInOptions) ? item.requiredInOptions : 'The value does not exist.';
|
|
148
|
+
var validator = function validator(_ref3) {
|
|
149
|
+
var _form$getItems;
|
|
150
|
+
var value = _ref3.value;
|
|
151
|
+
var options = (_form$getItems = form.getItems(item.name)) === null || _form$getItems === void 0 ? void 0 : _form$getItems.options;
|
|
152
|
+
if (!isEmpty(value) && isValueNotExistInOptions(value, options)) {
|
|
153
|
+
return _message;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
rules.push({
|
|
157
|
+
validator: validator
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return _.map(rules, function (r) {
|
|
161
|
+
var rule = _.clone(r);
|
|
162
|
+
var originValidator = r.validator;
|
|
163
|
+
if (originValidator) {
|
|
164
|
+
rule.validator = /*#__PURE__*/function () {
|
|
165
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(__, value) {
|
|
166
|
+
var res;
|
|
167
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
168
|
+
while (1) switch (_context.prev = _context.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
_context.next = 2;
|
|
171
|
+
return originValidator(_objectSpread({
|
|
172
|
+
value: value,
|
|
173
|
+
item: item
|
|
174
|
+
}, params));
|
|
175
|
+
case 2:
|
|
176
|
+
res = _context.sent;
|
|
177
|
+
return _context.abrupt("return", res ? Promise.reject(res) : Promise.resolve());
|
|
178
|
+
case 4:
|
|
179
|
+
case "end":
|
|
180
|
+
return _context.stop();
|
|
181
|
+
}
|
|
182
|
+
}, _callee);
|
|
183
|
+
}));
|
|
184
|
+
return function (_x, _x2) {
|
|
185
|
+
return _ref4.apply(this, arguments);
|
|
186
|
+
};
|
|
187
|
+
}();
|
|
188
|
+
}
|
|
189
|
+
return rule;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function generateRequiredMessage(item) {
|
|
193
|
+
if (_.isString(item.required)) {
|
|
194
|
+
return item.required;
|
|
195
|
+
}
|
|
196
|
+
if (!item.label) {
|
|
197
|
+
return 'The value is required.';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export function isValueNotExistInOptions(value, options) {
|
|
201
|
+
var optionsValue = getOptionsValue(options);
|
|
202
|
+
var values = parseValueWhenLabelInValue(value);
|
|
203
|
+
return !includesNonStrictMode(optionsValue, values);
|
|
204
|
+
}
|
|
205
|
+
export function isEmpty(value) {
|
|
206
|
+
var arr = _(value).castArray().reject(_.isNil).value();
|
|
207
|
+
return _.isEmpty(arr);
|
|
208
|
+
}
|
|
209
|
+
export function parseValueWhenLabelInValue(value) {
|
|
210
|
+
return _.castArray(value).map(function (x) {
|
|
211
|
+
return _.isPlainObject(x) ? x === null || x === void 0 ? void 0 : x.value : x;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
export function updateNotExistValue(_ref5) {
|
|
215
|
+
var form = _ref5.form,
|
|
216
|
+
value = _ref5.value,
|
|
217
|
+
name = _ref5.name,
|
|
218
|
+
options = _ref5.options,
|
|
219
|
+
_ref5$filterNotExistV = _ref5.filterNotExistValue,
|
|
220
|
+
filterNotExistValue = _ref5$filterNotExistV === void 0 ? false : _ref5$filterNotExistV,
|
|
221
|
+
labelInValue = _ref5.labelInValue;
|
|
222
|
+
if (filterNotExistValue === false || !isValueNotExistInOptions(value, options)) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
var namePath = transformPathToName(name);
|
|
226
|
+
// 多选
|
|
227
|
+
if (_.isArray(value)) {
|
|
228
|
+
var filteredValue = _.filter(value, function (item) {
|
|
229
|
+
return !isValueNotExistInOptions(item, options);
|
|
230
|
+
});
|
|
231
|
+
form.setValue(namePath, filteredValue);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 单选
|
|
236
|
+
if (filterNotExistValue === true) {
|
|
237
|
+
form.reset(namePath);
|
|
238
|
+
} else {
|
|
239
|
+
var val = filterNotExistValue === 'useFirstOption' ? getFirstOptionValue(options, labelInValue) : filterNotExistValue;
|
|
240
|
+
form.setValue(namePath, val);
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
function getFirstOptionValue(options, labelInValue) {
|
|
245
|
+
if (!options) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
var value = _.first(getOptionsValue(options));
|
|
249
|
+
return labelInValue ? {
|
|
250
|
+
value: value
|
|
251
|
+
} : value;
|
|
252
|
+
}
|
|
253
|
+
export function validateFormOnMount(_x3, _x4) {
|
|
254
|
+
return _validateFormOnMount.apply(this, arguments);
|
|
255
|
+
}
|
|
256
|
+
function _validateFormOnMount() {
|
|
257
|
+
_validateFormOnMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref6, validateOnMount) {
|
|
258
|
+
var form, items, fields;
|
|
259
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
260
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
261
|
+
case 0:
|
|
262
|
+
form = _ref6.form, items = _ref6.items;
|
|
263
|
+
fields = [];
|
|
264
|
+
_.forEach(items, function (item) {
|
|
265
|
+
if (validateOnMount || _.some(item.rules, 'validateOnMount')) {
|
|
266
|
+
fields.push(item.name);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
if (!_.isEmpty(fields)) {
|
|
270
|
+
_context2.next = 5;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
return _context2.abrupt("return");
|
|
274
|
+
case 5:
|
|
275
|
+
_context2.next = 7;
|
|
276
|
+
return form.validate(fields);
|
|
277
|
+
case 7:
|
|
278
|
+
case "end":
|
|
279
|
+
return _context2.stop();
|
|
280
|
+
}
|
|
281
|
+
}, _callee2);
|
|
282
|
+
}));
|
|
283
|
+
return _validateFormOnMount.apply(this, arguments);
|
|
284
|
+
}
|
|
285
|
+
export function transformNameToPath(name) {
|
|
286
|
+
if (_.isString(name) && _.includes(name, '.')) {
|
|
287
|
+
return _.toPath(name);
|
|
288
|
+
}
|
|
289
|
+
if (_.isArray(name)) {
|
|
290
|
+
return _.map(name, transformNameToPath);
|
|
291
|
+
}
|
|
292
|
+
return name;
|
|
293
|
+
}
|
|
294
|
+
export function transformPathToName(path) {
|
|
295
|
+
if (_.isNil(path)) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (_.isArray(path)) {
|
|
299
|
+
return _(path).map(transformPathToName).reject(_.isNil).join('.');
|
|
300
|
+
}
|
|
301
|
+
return path.toString();
|
|
302
|
+
}
|
|
303
|
+
export function transformKeyToPath(params) {
|
|
304
|
+
var result = {};
|
|
305
|
+
_.forEach(params, function (value, key) {
|
|
306
|
+
return _.set(result, key, value);
|
|
307
|
+
});
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
export function parseFormFailedError(error) {
|
|
311
|
+
var errorInfo = {};
|
|
312
|
+
error.errorFields.forEach(function (item) {
|
|
313
|
+
var key = item.name.join('.');
|
|
314
|
+
errorInfo[key] = item.errors[0];
|
|
315
|
+
});
|
|
316
|
+
return errorInfo;
|
|
317
|
+
}
|
|
318
|
+
export function noStyle(item) {
|
|
319
|
+
return !item.name && !!item.render;
|
|
320
|
+
}
|
|
321
|
+
export function transformOptions(item, values, params) {
|
|
322
|
+
var options = item.options,
|
|
323
|
+
type = item.type;
|
|
324
|
+
if (!type || !_.isFunction(options)) {
|
|
325
|
+
return options;
|
|
326
|
+
}
|
|
327
|
+
if (['select', 'treeSelect'].includes(type)) {
|
|
328
|
+
return function () {
|
|
329
|
+
var search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
330
|
+
return options(values, _objectSpread(_objectSpread({}, params), {}, {
|
|
331
|
+
search: search
|
|
332
|
+
}));
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return options(values, _objectSpread(_objectSpread({}, params), {}, {
|
|
336
|
+
search: ''
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
export function focusFirstInput(_ref7) {
|
|
340
|
+
var _parseFocusFirst;
|
|
341
|
+
var form = _ref7.form,
|
|
342
|
+
items = _ref7.items,
|
|
343
|
+
focusFirstOnMount = _ref7.focusFirstOnMount;
|
|
344
|
+
var name = (_parseFocusFirst = parseFocusFirst(focusFirstOnMount)) !== null && _parseFocusFirst !== void 0 ? _parseFocusFirst : _.get(items, '0.name');
|
|
345
|
+
if (!name) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
form.focus(name);
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
function parseFocusFirst(focusFirstOnMount) {
|
|
352
|
+
if (focusFirstOnMount === true) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
return focusFirstOnMount;
|
|
356
|
+
}
|
|
357
|
+
export function scrollToFieldOnAdd(_x5) {
|
|
358
|
+
return _scrollToFieldOnAdd.apply(this, arguments);
|
|
359
|
+
}
|
|
360
|
+
function _scrollToFieldOnAdd() {
|
|
361
|
+
_scrollToFieldOnAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref8) {
|
|
362
|
+
var name, form, insertIndex, _ref8$focusFirstOnAdd, focusFirstOnAdd, prefixName, insertItems, focusFirstOnMount;
|
|
363
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
364
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
365
|
+
case 0:
|
|
366
|
+
name = _ref8.name, form = _ref8.form, insertIndex = _ref8.insertIndex, _ref8$focusFirstOnAdd = _ref8.focusFirstOnAdd, focusFirstOnAdd = _ref8$focusFirstOnAdd === void 0 ? true : _ref8$focusFirstOnAdd;
|
|
367
|
+
if (form) {
|
|
368
|
+
_context3.next = 3;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
return _context3.abrupt("return");
|
|
372
|
+
case 3:
|
|
373
|
+
_context3.next = 5;
|
|
374
|
+
return delay(50);
|
|
375
|
+
case 5:
|
|
376
|
+
// 等待 form.setItems 完成
|
|
377
|
+
prefixName = "".concat(transformPathToName(name), ".").concat(insertIndex);
|
|
378
|
+
insertItems = form.getItems().filter(function (item) {
|
|
379
|
+
var _transformPathToName;
|
|
380
|
+
return (_transformPathToName = transformPathToName(item.name)) === null || _transformPathToName === void 0 ? void 0 : _transformPathToName.startsWith(prefixName);
|
|
381
|
+
});
|
|
382
|
+
focusFirstOnMount = _.isString(focusFirstOnAdd) ? "".concat(prefixName, ".").concat(focusFirstOnAdd) : focusFirstOnAdd;
|
|
383
|
+
focusFirstInput({
|
|
384
|
+
form: form,
|
|
385
|
+
items: insertItems,
|
|
386
|
+
focusFirstOnMount: focusFirstOnMount
|
|
387
|
+
});
|
|
388
|
+
case 9:
|
|
389
|
+
case "end":
|
|
390
|
+
return _context3.stop();
|
|
391
|
+
}
|
|
392
|
+
}, _callee3);
|
|
393
|
+
}));
|
|
394
|
+
return _scrollToFieldOnAdd.apply(this, arguments);
|
|
395
|
+
}
|
|
396
|
+
export function setContextWrapper(setContext) {
|
|
397
|
+
return function (nameOrParams, value) {
|
|
398
|
+
if (_.isString(nameOrParams)) {
|
|
399
|
+
setContext(function (state) {
|
|
400
|
+
return _.set(state, nameOrParams, value);
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
nameOrParams && setContext(nameOrParams);
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
export function getContextWrapper(context) {
|
|
408
|
+
return function (name) {
|
|
409
|
+
return name ? _.get(context, name) : context;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
export function generateCollectionKey(name) {
|
|
413
|
+
return _.camelCase(name);
|
|
414
|
+
}
|
|
415
|
+
export function removeFormListFormItems(name, collectionItems) {
|
|
416
|
+
var namePath = transformPathToName(name);
|
|
417
|
+
return _.omitBy(collectionItems, function (item) {
|
|
418
|
+
var _item$formListContext;
|
|
419
|
+
return transformPathToName((_item$formListContext = item.formListContext) === null || _item$formListContext === void 0 ? void 0 : _item$formListContext.name) === namePath;
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
export function removeTableEditorFormItems(name, collectionItems) {
|
|
423
|
+
var namePath = transformPathToName(name);
|
|
424
|
+
return _.omitBy(collectionItems, function (item) {
|
|
425
|
+
return _.startsWith(transformPathToName(item.name), namePath);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
export function getFormItemId(name, form) {
|
|
429
|
+
return getFieldId(_.castArray(name), form.getName());
|
|
430
|
+
}
|
|
431
|
+
export function hasItemLoading(items) {
|
|
432
|
+
return _.some(items, {
|
|
433
|
+
loading: true
|
|
434
|
+
});
|
|
435
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FunctionReturn } from "../../api";
|
|
2
|
+
import { FormContext, FormItemProps } from "..";
|
|
3
|
+
export interface ValidatorItemProps extends Omit<FormItemProps, 'validator'> {
|
|
4
|
+
validator?: (props: FormContext) => FunctionReturn<boolean | void>;
|
|
5
|
+
shouldTriggerValidate?: any;
|
|
6
|
+
}
|
|
7
|
+
export declare function ValidatorItem({ validator, shouldTriggerValidate, ...props }: ValidatorItemProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 = ["validator", "shouldTriggerValidate"];
|
|
6
|
+
import { useFormContext } from "./..";
|
|
7
|
+
import { useUpdateEffect } from 'react-use';
|
|
8
|
+
import { registerMethods } from "./constant";
|
|
9
|
+
import { FormItem } from "./form-item";
|
|
10
|
+
import { Fragment as _Fragment, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
11
|
+
export function ValidatorItem(_ref) {
|
|
12
|
+
var validator = _ref.validator,
|
|
13
|
+
shouldTriggerValidate = _ref.shouldTriggerValidate,
|
|
14
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
|
+
var context = useFormContext();
|
|
16
|
+
function validate() {
|
|
17
|
+
return _validate.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
function _validate() {
|
|
20
|
+
_validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
21
|
+
var res;
|
|
22
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
_context.next = 2;
|
|
26
|
+
return validator === null || validator === void 0 ? void 0 : validator(context);
|
|
27
|
+
case 2:
|
|
28
|
+
res = _context.sent;
|
|
29
|
+
return _context.abrupt("return", res === false ? 'error' : '');
|
|
30
|
+
case 4:
|
|
31
|
+
case "end":
|
|
32
|
+
return _context.stop();
|
|
33
|
+
}
|
|
34
|
+
}, _callee);
|
|
35
|
+
}));
|
|
36
|
+
return _validate.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
useUpdateEffect(function () {
|
|
39
|
+
context.form.callMethod(registerMethods.triggerValidate);
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [shouldTriggerValidate]);
|
|
42
|
+
return _jsx(FormItem, _objectSpread(_objectSpread({
|
|
43
|
+
name: "__validatorItem__"
|
|
44
|
+
}, props), {}, {
|
|
45
|
+
hidden: true,
|
|
46
|
+
noStyle: true,
|
|
47
|
+
__noCollectState__: true,
|
|
48
|
+
validator: validate,
|
|
49
|
+
render: function render() {
|
|
50
|
+
return _jsx(_Fragment, {});
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionReturn } from "../../api";
|
|
2
|
+
import { FormProps, FormValues } from "..";
|
|
3
|
+
import { FormItemSelectProps } from "../component/form-item-map";
|
|
4
|
+
import { SelectCallbackProps } from "../../select";
|
|
5
|
+
import { DependencyList } from 'react';
|
|
6
|
+
export * from './list-provider';
|
|
7
|
+
export * from './provider';
|
|
8
|
+
export * from './use-form';
|
|
9
|
+
export declare function useFormValueChange<T>(fn: (values: FormValues) => FunctionReturn<T>, deps?: DependencyList): T | undefined;
|
|
10
|
+
interface UseValidateFormProps extends Pick<FormProps, 'onValidate'> {
|
|
11
|
+
validateOnly?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useValidateForm({ onValidate, validateOnly }?: UseValidateFormProps): boolean;
|
|
14
|
+
export interface ValidateNotExistValueProps extends FormItemSelectProps, SelectCallbackProps {
|
|
15
|
+
}
|
|
16
|
+
export declare function useValidateNotExistValue({ loading, value, options, ...props }: ValidateNotExistValueProps): void;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
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", "value", "options"];
|
|
7
|
+
import { useFormContext } from "./..";
|
|
8
|
+
import { useCollectFormItemState } from "../component/form-item-map";
|
|
9
|
+
import { useDebounce, useDeepEffect, useSafeState } from "../../hooks";
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
import { registerMethods } from "../component/constant";
|
|
12
|
+
import { hasItemLoading } from "../component/utils";
|
|
13
|
+
export * from "./list-provider";
|
|
14
|
+
export * from "./provider";
|
|
15
|
+
export * from "./use-form";
|
|
16
|
+
export function useFormValueChange(fn) {
|
|
17
|
+
var deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
18
|
+
var _useFormContext = useFormContext(),
|
|
19
|
+
values = _useFormContext.values;
|
|
20
|
+
var _useSafeState = useSafeState(),
|
|
21
|
+
_useSafeState2 = _slicedToArray(_useSafeState, 2),
|
|
22
|
+
result = _useSafeState2[0],
|
|
23
|
+
setResult = _useSafeState2[1];
|
|
24
|
+
useDeepEffect( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
25
|
+
var res;
|
|
26
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
27
|
+
while (1) switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
_context.next = 2;
|
|
30
|
+
return fn(values);
|
|
31
|
+
case 2:
|
|
32
|
+
res = _context.sent;
|
|
33
|
+
setResult(res);
|
|
34
|
+
case 4:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee);
|
|
39
|
+
})), [values].concat(_toConsumableArray(deps)));
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
export function useValidateForm() {
|
|
43
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
44
|
+
onValidate = _ref2.onValidate,
|
|
45
|
+
validateOnly = _ref2.validateOnly;
|
|
46
|
+
var _useFormContext2 = useFormContext(),
|
|
47
|
+
loading = _useFormContext2.loading,
|
|
48
|
+
form = _useFormContext2.form,
|
|
49
|
+
items = _useFormContext2.items,
|
|
50
|
+
values = _useFormContext2.values;
|
|
51
|
+
var _useSafeState3 = useSafeState(false),
|
|
52
|
+
_useSafeState4 = _slicedToArray(_useSafeState3, 2),
|
|
53
|
+
result = _useSafeState4[0],
|
|
54
|
+
setResult = _useSafeState4[1];
|
|
55
|
+
var validate = /*#__PURE__*/function () {
|
|
56
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
57
|
+
var _onValidate;
|
|
58
|
+
var isValid, customValidate, final;
|
|
59
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
60
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
if (!(loading || hasItemLoading(items))) {
|
|
63
|
+
_context2.next = 2;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return _context2.abrupt("return");
|
|
67
|
+
case 2:
|
|
68
|
+
_context2.next = 4;
|
|
69
|
+
return form.callMethod(registerMethods.internalValidate);
|
|
70
|
+
case 4:
|
|
71
|
+
isValid = _context2.sent;
|
|
72
|
+
customValidate = (_onValidate = onValidate === null || onValidate === void 0 ? void 0 : onValidate(isValid, form)) !== null && _onValidate !== void 0 ? _onValidate : true;
|
|
73
|
+
final = customValidate && isValid;
|
|
74
|
+
if (!validateOnly) {
|
|
75
|
+
setResult(final);
|
|
76
|
+
}
|
|
77
|
+
case 8:
|
|
78
|
+
case "end":
|
|
79
|
+
return _context2.stop();
|
|
80
|
+
}
|
|
81
|
+
}, _callee2);
|
|
82
|
+
}));
|
|
83
|
+
return function validate() {
|
|
84
|
+
return _ref3.apply(this, arguments);
|
|
85
|
+
};
|
|
86
|
+
}();
|
|
87
|
+
var onChangeDebounce = useDebounce(validate, 100, {
|
|
88
|
+
leading: false
|
|
89
|
+
});
|
|
90
|
+
useEffect(function () {
|
|
91
|
+
onChangeDebounce();
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
}, [values, loading, items]);
|
|
94
|
+
|
|
95
|
+
// 供 form.setError 使用
|
|
96
|
+
form.registerMethod(registerMethods.triggerValidate, onChangeDebounce);
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
export function useValidateNotExistValue(_ref4) {
|
|
100
|
+
var loading = _ref4.loading,
|
|
101
|
+
value = _ref4.value,
|
|
102
|
+
options = _ref4.options,
|
|
103
|
+
props = _objectWithoutProperties(_ref4, _excluded);
|
|
104
|
+
var _useFormContext3 = useFormContext(),
|
|
105
|
+
formLoading = _useFormContext3.loading;
|
|
106
|
+
var _useCollectFormItemSt = useCollectFormItemState(props),
|
|
107
|
+
__callback__ = _useCollectFormItemSt.__callback__;
|
|
108
|
+
var params = {
|
|
109
|
+
options: options,
|
|
110
|
+
value: value,
|
|
111
|
+
loading: formLoading || loading
|
|
112
|
+
};
|
|
113
|
+
useDeepEffect(function () {
|
|
114
|
+
__callback__(params);
|
|
115
|
+
}, [params]);
|
|
116
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormListContext } from "..";
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export declare function FormListProvider({ children, ...props }: FormListContext & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function useFormListContext(): FormListContext;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 FormListCtx = /*#__PURE__*/createContext({});
|
|
6
|
+
export function FormListProvider(_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
9
|
+
return _jsx(FormListCtx.Provider, {
|
|
10
|
+
value: props,
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function useFormListContext() {
|
|
15
|
+
return useContext(FormListCtx);
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FormInstance, FormItemContext, FormValues } from "..";
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface RemoveCollectOptions {
|
|
4
|
+
isFormList?: boolean;
|
|
5
|
+
isTableEditor?: boolean;
|
|
6
|
+
onlyResetLoading?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface FormContext {
|
|
9
|
+
loading: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
form: FormInstance;
|
|
12
|
+
values: FormValues;
|
|
13
|
+
items: FormItemContext[];
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
__collect__(item: FormItemContext): void;
|
|
17
|
+
__removeCollect__(name: string, options?: RemoveCollectOptions): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function FormProvider({ children, ...props }: FormContext & {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function useFormContext<T>(): T & FormContext;
|
|
23
|
+
export declare function useFormValue(): FormValues;
|