@hw-component/form 0.0.1 → 0.0.2-beta-v1
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 +201 -0
- package/es/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/es/CheckboxGroup/CheckBox/index.js +40 -0
- package/es/CheckboxGroup/hooks.d.ts +5 -0
- package/es/CheckboxGroup/hooks.js +123 -0
- package/es/CheckboxGroup/index.d.ts +3 -0
- package/es/CheckboxGroup/index.js +91 -0
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Footer.js +23 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Title.js +18 -0
- package/es/DialogForm/DrawerForm/index.d.ts +4 -0
- package/es/DialogForm/DrawerForm/index.js +111 -0
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/DialogForm/ModalForm.js +89 -0
- package/es/DialogForm/hooks.d.ts +14 -0
- package/es/DialogForm/hooks.js +124 -0
- package/es/DialogForm/modal.d.ts +25 -0
- package/es/Form/Context/FormConfigProvider.d.ts +5 -0
- package/es/Form/Context/FormConfigProvider.js +47 -0
- package/es/Form/Context/index.d.ts +5 -0
- package/es/Form/Context/index.js +11 -0
- package/es/Form/FormItem/BasicItem.d.ts +4 -0
- package/es/Form/FormItem/BasicItem.js +73 -0
- package/es/Form/FormItem/Helper.d.ts +7 -0
- package/es/Form/FormItem/Helper.js +24 -0
- package/es/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/es/Form/FormItem/RegularFormItem.js +15 -0
- package/es/Form/FormItem/UpFormItem.d.ts +4 -0
- package/es/Form/FormItem/UpFormItem.js +31 -0
- package/es/Form/FormItem/hooks.d.ts +10 -0
- package/es/Form/FormItem/hooks.js +38 -0
- package/es/Form/FormItem/index.d.ts +4 -0
- package/es/Form/FormItem/index.js +11 -0
- package/es/Form/HFormConnect.d.ts +5 -0
- package/es/Form/HFormConnect.js +55 -0
- package/es/Form/InitSet.d.ts +3 -0
- package/es/Form/InitSet.js +15 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +46 -0
- package/es/Form/config.d.ts +29 -0
- package/es/Form/config.js +45 -0
- package/es/Form/hooks/index.d.ts +6 -0
- package/es/Form/hooks/index.js +45 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +168 -0
- package/es/Form/hooks/useInitConfigData.d.ts +4 -0
- package/es/Form/hooks/useInitConfigData.js +124 -0
- package/es/Form/index.d.ts +4 -0
- package/es/Form/index.js +104 -0
- package/es/Form/modal.d.ts +104 -0
- package/es/Input/ButtonInput.d.ts +4 -0
- package/es/Input/ButtonInput.js +80 -0
- package/es/Input/InputNumber.d.ts +4 -0
- package/es/Input/InputNumber.js +20 -0
- package/es/Input/SelectInput.d.ts +9 -0
- package/es/Input/SelectInput.js +97 -0
- package/es/Input/defaultConfig.d.ts +7 -0
- package/es/Input/defaultConfig.js +11 -0
- package/es/Input/index.d.ts +4 -0
- package/es/Input/index.js +13 -0
- package/es/Input/modal.d.ts +27 -0
- package/es/PageHandler/ErrorComponent.d.ts +4 -0
- package/es/PageHandler/ErrorComponent.js +33 -0
- package/es/PageHandler/LoadingComponent.d.ts +3 -0
- package/es/PageHandler/LoadingComponent.js +18 -0
- package/es/PageHandler/index.d.ts +4 -0
- package/es/PageHandler/index.js +24 -0
- package/es/PageHandler/modal.d.ts +6 -0
- package/es/RadioGroup/index.d.ts +9 -0
- package/es/RadioGroup/index.js +48 -0
- package/es/Select/components/AllSelect.d.ts +3 -3
- package/es/Select/components/AllSelect.js +31 -15
- package/es/Select/components/CheckBoxOption.js +2 -2
- package/es/Select/components/DropdownComponent.js +2 -2
- package/es/Select/components/NoFindItem.js +2 -2
- package/es/Select/components/NotFoundContent.js +3 -5
- package/es/Select/defaultConfig.d.ts +0 -1
- package/es/Select/defaultConfig.js +3 -7
- package/es/Select/hooks/changeHooks.d.ts +1 -1
- package/es/Select/hooks/changeHooks.js +9 -5
- package/es/Select/hooks/norHooks.d.ts +4 -6
- package/es/Select/hooks/norHooks.js +20 -37
- package/es/Select/index.d.ts +1 -1
- package/es/Select/index.js +31 -19
- package/es/Select/modal.d.ts +2 -2
- package/es/Select/utils.d.ts +2 -0
- package/es/Select/utils.js +39 -0
- package/es/Submit/index.d.ts +8 -0
- package/es/Submit/index.js +28 -0
- package/es/Switch/index.d.ts +11 -0
- package/es/Switch/index.js +45 -0
- package/es/TDPicker/RangePicker.d.ts +8 -0
- package/es/TDPicker/RangePicker.js +121 -0
- package/es/TDPicker/TimePicker.d.ts +4 -0
- package/es/TDPicker/TimePicker.js +31 -0
- package/es/TDPicker/hooks.d.ts +33 -0
- package/es/TDPicker/hooks.js +132 -0
- package/es/TDPicker/index.d.ts +4 -0
- package/es/TDPicker/index.js +33 -0
- package/es/TDPicker/modal.d.ts +28 -0
- package/es/TextArea/index.d.ts +4 -0
- package/es/TextArea/index.js +21 -0
- package/es/Upload/Btn.d.ts +4 -0
- package/es/Upload/Btn.js +31 -0
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -0
- package/es/Upload/MediaTypeEle/TypeEle.js +40 -0
- package/es/Upload/MediaTypeEle/index.d.ts +4 -0
- package/es/Upload/MediaTypeEle/index.js +36 -0
- package/es/Upload/Preview/index.d.ts +6 -0
- package/es/Upload/Preview/index.js +21 -0
- package/es/Upload/UrlUpload/index.d.ts +4 -0
- package/es/Upload/UrlUpload/index.js +119 -0
- package/es/Upload/enums.d.ts +5 -0
- package/es/Upload/enums.js +10 -0
- package/es/Upload/hooks/change.d.ts +3 -0
- package/es/Upload/hooks/change.js +109 -0
- package/es/Upload/hooks/customRequest.d.ts +3 -0
- package/es/Upload/hooks/customRequest.js +132 -0
- package/es/Upload/hooks/propsMaker.d.ts +2 -0
- package/es/Upload/hooks/propsMaker.js +37 -0
- package/es/Upload/index.d.ts +3 -0
- package/es/Upload/index.js +140 -0
- package/es/Upload/modal.d.ts +30 -0
- package/es/Upload/util.d.ts +5 -0
- package/es/Upload/util.js +34 -0
- package/es/config.d.ts +2 -0
- package/es/config.js +64 -0
- package/es/hooks/index.d.ts +13 -0
- package/es/hooks/index.js +75 -0
- package/es/index.css +33 -1
- package/es/index.d.ts +24 -1
- package/es/index.js +31 -3
- package/es/modal.d.ts +15 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/lib/CheckboxGroup/CheckBox/index.js +43 -0
- package/lib/CheckboxGroup/hooks.d.ts +5 -0
- package/lib/CheckboxGroup/hooks.js +124 -0
- package/lib/CheckboxGroup/index.d.ts +3 -0
- package/lib/CheckboxGroup/index.js +94 -0
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Footer.js +26 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Title.js +21 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/index.js +114 -0
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/DialogForm/ModalForm.js +92 -0
- package/lib/DialogForm/hooks.d.ts +14 -0
- package/lib/DialogForm/hooks.js +128 -0
- package/lib/DialogForm/modal.d.ts +25 -0
- package/lib/Form/Context/FormConfigProvider.d.ts +5 -0
- package/lib/Form/Context/FormConfigProvider.js +51 -0
- package/lib/Form/Context/index.d.ts +5 -0
- package/lib/Form/Context/index.js +14 -0
- package/lib/Form/FormItem/BasicItem.d.ts +4 -0
- package/lib/Form/FormItem/BasicItem.js +76 -0
- package/lib/Form/FormItem/Helper.d.ts +7 -0
- package/lib/Form/FormItem/Helper.js +27 -0
- package/lib/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/lib/Form/FormItem/RegularFormItem.js +18 -0
- package/lib/Form/FormItem/UpFormItem.d.ts +4 -0
- package/lib/Form/FormItem/UpFormItem.js +34 -0
- package/lib/Form/FormItem/hooks.d.ts +10 -0
- package/lib/Form/FormItem/hooks.js +41 -0
- package/lib/Form/FormItem/index.d.ts +4 -0
- package/lib/Form/FormItem/index.js +14 -0
- package/lib/Form/HFormConnect.d.ts +5 -0
- package/lib/Form/HFormConnect.js +58 -0
- package/lib/Form/InitSet.d.ts +3 -0
- package/lib/Form/InitSet.js +18 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +49 -0
- package/lib/Form/config.d.ts +29 -0
- package/lib/Form/config.js +49 -0
- package/lib/Form/hooks/index.d.ts +6 -0
- package/lib/Form/hooks/index.js +47 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +171 -0
- package/lib/Form/hooks/useInitConfigData.d.ts +4 -0
- package/lib/Form/hooks/useInitConfigData.js +127 -0
- package/lib/Form/index.d.ts +4 -0
- package/lib/Form/index.js +107 -0
- package/lib/Form/modal.d.ts +104 -0
- package/lib/Input/ButtonInput.d.ts +4 -0
- package/lib/Input/ButtonInput.js +83 -0
- package/lib/Input/InputNumber.d.ts +4 -0
- package/lib/Input/InputNumber.js +23 -0
- package/lib/Input/SelectInput.d.ts +9 -0
- package/lib/Input/SelectInput.js +101 -0
- package/lib/Input/defaultConfig.d.ts +7 -0
- package/lib/Input/defaultConfig.js +13 -0
- package/lib/Input/index.d.ts +4 -0
- package/lib/Input/index.js +16 -0
- package/lib/Input/modal.d.ts +27 -0
- package/lib/PageHandler/ErrorComponent.d.ts +4 -0
- package/lib/PageHandler/ErrorComponent.js +36 -0
- package/lib/PageHandler/LoadingComponent.d.ts +3 -0
- package/lib/PageHandler/LoadingComponent.js +21 -0
- package/lib/PageHandler/index.d.ts +4 -0
- package/lib/PageHandler/index.js +27 -0
- package/lib/PageHandler/modal.d.ts +6 -0
- package/lib/RadioGroup/index.d.ts +9 -0
- package/lib/RadioGroup/index.js +51 -0
- package/lib/Select/components/AllSelect.d.ts +3 -3
- package/lib/Select/components/AllSelect.js +29 -13
- package/lib/Select/components/NotFoundContent.js +1 -3
- package/lib/Select/defaultConfig.d.ts +0 -1
- package/lib/Select/defaultConfig.js +0 -5
- package/lib/Select/hooks/changeHooks.d.ts +1 -1
- package/lib/Select/hooks/changeHooks.js +7 -3
- package/lib/Select/hooks/norHooks.d.ts +4 -6
- package/lib/Select/hooks/norHooks.js +18 -35
- package/lib/Select/index.d.ts +1 -1
- package/lib/Select/index.js +26 -14
- package/lib/Select/modal.d.ts +2 -2
- package/lib/Select/utils.d.ts +2 -0
- package/lib/Select/utils.js +41 -0
- package/lib/Submit/index.d.ts +8 -0
- package/lib/Submit/index.js +31 -0
- package/lib/Switch/index.d.ts +11 -0
- package/lib/Switch/index.js +48 -0
- package/lib/TDPicker/RangePicker.d.ts +8 -0
- package/lib/TDPicker/RangePicker.js +124 -0
- package/lib/TDPicker/TimePicker.d.ts +4 -0
- package/lib/TDPicker/TimePicker.js +34 -0
- package/lib/TDPicker/hooks.d.ts +33 -0
- package/lib/TDPicker/hooks.js +139 -0
- package/lib/TDPicker/index.d.ts +4 -0
- package/lib/TDPicker/index.js +36 -0
- package/lib/TDPicker/modal.d.ts +28 -0
- package/lib/TextArea/index.d.ts +4 -0
- package/lib/TextArea/index.js +24 -0
- package/lib/Upload/Btn.d.ts +4 -0
- package/lib/Upload/Btn.js +34 -0
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -0
- package/lib/Upload/MediaTypeEle/TypeEle.js +43 -0
- package/lib/Upload/MediaTypeEle/index.d.ts +4 -0
- package/lib/Upload/MediaTypeEle/index.js +39 -0
- package/lib/Upload/Preview/index.d.ts +6 -0
- package/lib/Upload/Preview/index.js +24 -0
- package/lib/Upload/UrlUpload/index.d.ts +4 -0
- package/lib/Upload/UrlUpload/index.js +122 -0
- package/lib/Upload/enums.d.ts +5 -0
- package/lib/Upload/enums.js +9 -0
- package/lib/Upload/hooks/change.d.ts +3 -0
- package/lib/Upload/hooks/change.js +110 -0
- package/lib/Upload/hooks/customRequest.d.ts +3 -0
- package/lib/Upload/hooks/customRequest.js +133 -0
- package/lib/Upload/hooks/propsMaker.d.ts +2 -0
- package/lib/Upload/hooks/propsMaker.js +38 -0
- package/lib/Upload/index.d.ts +3 -0
- package/lib/Upload/index.js +143 -0
- package/lib/Upload/modal.d.ts +30 -0
- package/lib/Upload/util.d.ts +5 -0
- package/lib/Upload/util.js +38 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.js +65 -0
- package/lib/hooks/index.d.ts +13 -0
- package/lib/hooks/index.js +78 -0
- package/lib/index.css +33 -1
- package/lib/index.d.ts +24 -1
- package/lib/index.js +48 -3
- package/lib/modal.d.ts +15 -0
- package/package.json +4 -3
- package/scripts/rollup.config.js +3 -8
- package/scripts/webpack.config.js +6 -2
- package/src/Layout.tsx +4 -4
- package/src/components/CheckboxGroup/CheckBox/index.tsx +38 -0
- package/src/components/CheckboxGroup/hooks.ts +102 -0
- package/src/components/CheckboxGroup/index.tsx +79 -0
- package/src/components/CheckboxGroup/modal.ts +15 -0
- package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
- package/src/components/DialogForm/ModalForm.tsx +60 -0
- package/src/components/DialogForm/hooks.ts +87 -0
- package/src/components/DialogForm/modal.ts +27 -0
- package/src/components/Form/Context/FormConfigProvider.tsx +38 -0
- package/src/components/Form/Context/index.tsx +14 -0
- package/src/components/Form/FormItem/BasicItem.tsx +70 -0
- package/src/components/Form/FormItem/Helper.tsx +25 -0
- package/src/components/Form/FormItem/RegularFormItem.tsx +7 -0
- package/src/components/Form/FormItem/UpFormItem.tsx +20 -0
- package/src/components/Form/FormItem/hooks.tsx +44 -0
- package/src/components/Form/FormItem/index.tsx +8 -0
- package/src/components/Form/HFormConnect.tsx +67 -0
- package/src/components/Form/InitSet.tsx +10 -0
- package/src/components/Form/Label.tsx +50 -0
- package/src/components/Form/config.ts +41 -0
- package/src/components/Form/hooks/index.ts +22 -0
- package/src/components/Form/hooks/useHForm.ts +142 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +100 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +79 -0
- package/src/components/Form/modal.ts +154 -0
- package/src/components/Input/ButtonInput.tsx +41 -0
- package/src/components/Input/InputNumber.tsx +5 -0
- package/src/components/Input/SelectInput.tsx +76 -0
- package/src/components/Input/defaultConfig.ts +8 -0
- package/src/components/Input/index.tsx +6 -0
- package/src/components/Input/modal.ts +33 -0
- package/src/components/PageHandler/ErrorComponent.tsx +20 -0
- package/src/components/PageHandler/LoadingComponent.tsx +9 -0
- package/src/components/PageHandler/index.tsx +14 -0
- package/src/components/PageHandler/modal.ts +6 -0
- package/src/components/RadioGroup/index.tsx +45 -0
- package/src/components/Select/components/AllSelect.tsx +32 -16
- package/src/components/Select/components/DropdownComponent.tsx +1 -0
- package/src/components/Select/components/NotFoundContent.tsx +1 -1
- package/src/components/Select/defaultConfig.tsx +0 -5
- package/src/components/Select/hooks/changeHooks.tsx +14 -4
- package/src/components/Select/hooks/norHooks.ts +8 -19
- package/src/components/Select/index.less +20 -3
- package/src/components/Select/index.tsx +29 -17
- package/src/components/Select/modal.ts +9 -9
- package/src/components/Select/utils.ts +18 -0
- package/src/components/Submit/index.tsx +28 -0
- package/src/components/Switch/index.tsx +52 -0
- package/src/components/TDPicker/RangePicker.tsx +105 -0
- package/src/components/TDPicker/TimePicker.tsx +15 -0
- package/src/components/TDPicker/hooks.ts +150 -0
- package/src/components/TDPicker/index.tsx +22 -0
- package/src/components/TDPicker/modal.ts +30 -0
- package/src/components/TextArea/index.tsx +8 -0
- package/src/components/Upload/Btn.tsx +24 -0
- package/src/components/Upload/MediaTypeEle/TypeEle.tsx +26 -0
- package/src/components/Upload/MediaTypeEle/index.tsx +34 -0
- package/src/components/Upload/Preview/index.tsx +14 -0
- package/src/components/Upload/UrlUpload/index.tsx +91 -0
- package/src/components/Upload/enums.ts +5 -0
- package/src/components/Upload/hooks/change.ts +79 -0
- package/src/components/Upload/hooks/customRequest.ts +87 -0
- package/src/components/Upload/hooks/propsMaker.ts +20 -0
- package/src/components/Upload/index.tsx +117 -0
- package/src/components/Upload/modal.ts +33 -0
- package/src/components/Upload/util.ts +27 -0
- package/src/components/config.ts +40 -0
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +27 -1
- package/src/components/modal.ts +15 -0
- package/src/components/styles/index.less +2 -0
- package/src/components/styles/local.less +1 -0
- package/src/pages/Checkbox/index.tsx +15 -0
- package/src/pages/DatePicker/index.tsx +33 -0
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +149 -0
- package/src/pages/Input/index.tsx +22 -0
- package/src/pages/ModalForm/index.tsx +127 -0
- package/src/pages/Radio/index.tsx +18 -0
- package/src/pages/Select/index.tsx +7 -4
- package/src/pages/Switch/index.tsx +18 -0
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +55 -10
- package/es/Select/index.less.js +0 -5
- package/lib/Select/index.less.js +0 -8
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
5
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
6
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
7
|
+
import { Modal } from 'antd';
|
|
8
|
+
import HForm from '../Form/index.js';
|
|
9
|
+
import { useCurrentForm, useModifyProps, useSub } from './hooks.js';
|
|
10
|
+
|
|
11
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish"];
|
|
12
|
+
var ModalForm = (function (_ref) {
|
|
13
|
+
var visible = _ref.visible,
|
|
14
|
+
title = _ref.title,
|
|
15
|
+
onCancel = _ref.onCancel,
|
|
16
|
+
configData = _ref.configData,
|
|
17
|
+
infoRequest = _ref.infoRequest,
|
|
18
|
+
request = _ref.request,
|
|
19
|
+
_afterClose = _ref.afterClose,
|
|
20
|
+
dialogForm = _ref.dialogForm,
|
|
21
|
+
_ref$initialValues = _ref.initialValues,
|
|
22
|
+
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
23
|
+
onFinish = _ref.onFinish,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
var currentForm = useCurrentForm(dialogForm);
|
|
26
|
+
var _useModifyProps = useModifyProps({
|
|
27
|
+
configData: configData,
|
|
28
|
+
visible: visible,
|
|
29
|
+
initialValues: initialValues,
|
|
30
|
+
dialogForm: currentForm
|
|
31
|
+
}),
|
|
32
|
+
modalVisible = _useModifyProps.modalVisible,
|
|
33
|
+
modalFormData = _useModifyProps.modalFormData,
|
|
34
|
+
setModalVisible = _useModifyProps.setModalVisible,
|
|
35
|
+
initValue = _useModifyProps.initValue;
|
|
36
|
+
var cancel = function cancel(e) {
|
|
37
|
+
if (onCancel) {
|
|
38
|
+
return onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
|
|
39
|
+
}
|
|
40
|
+
setModalVisible(false);
|
|
41
|
+
};
|
|
42
|
+
var _useSub = useSub({
|
|
43
|
+
request: request,
|
|
44
|
+
onFinish: onFinish
|
|
45
|
+
}),
|
|
46
|
+
loading = _useSub.loading,
|
|
47
|
+
run = _useSub.run;
|
|
48
|
+
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
49
|
+
title: title,
|
|
50
|
+
visible: modalVisible,
|
|
51
|
+
onCancel: cancel,
|
|
52
|
+
confirmLoading: loading,
|
|
53
|
+
afterClose: function afterClose() {
|
|
54
|
+
currentForm.resetFields();
|
|
55
|
+
_afterClose === null || _afterClose === void 0 ? void 0 : _afterClose();
|
|
56
|
+
}
|
|
57
|
+
}, props, {
|
|
58
|
+
onOk: currentForm.submit,
|
|
59
|
+
destroyOnClose: true
|
|
60
|
+
}), /*#__PURE__*/React.createElement(HForm, _extends({
|
|
61
|
+
configData: modalFormData,
|
|
62
|
+
initialValues: initValue,
|
|
63
|
+
onFinish: /*#__PURE__*/function () {
|
|
64
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
65
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
66
|
+
while (1) switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
_context.next = 2;
|
|
69
|
+
return run(values);
|
|
70
|
+
case 2:
|
|
71
|
+
setModalVisible(false);
|
|
72
|
+
case 3:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
75
|
+
}
|
|
76
|
+
}, _callee);
|
|
77
|
+
}));
|
|
78
|
+
return function (_x) {
|
|
79
|
+
return _ref2.apply(this, arguments);
|
|
80
|
+
};
|
|
81
|
+
}()
|
|
82
|
+
}, props, {
|
|
83
|
+
form: currentForm,
|
|
84
|
+
infoRequest: infoRequest
|
|
85
|
+
})));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export { ModalForm as default };
|
|
89
|
+
// powered by hdj
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
|
|
3
|
+
export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, }: ModifyPropsModal) => {
|
|
4
|
+
modalFormData: import("../Form/modal").HItemProps[];
|
|
5
|
+
modalVisible: boolean | undefined;
|
|
6
|
+
setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
|
7
|
+
setModalFormData: import("react").Dispatch<import("react").SetStateAction<import("../Form/modal").HItemProps[]>>;
|
|
8
|
+
initValue: Record<string, any> | undefined;
|
|
9
|
+
setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
|
|
10
|
+
onAfterClose: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const useHDialogForm: () => HDialogFormInstance;
|
|
13
|
+
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance;
|
|
14
|
+
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any]>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
4
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
5
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
6
|
+
import _setTimeout from '@babel/runtime-corejs3/core-js/set-timeout';
|
|
7
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
8
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
9
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
10
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
11
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
12
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
13
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
14
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
15
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
16
|
+
import useHForm from '../Form/hooks/useHForm.js';
|
|
17
|
+
import { useRequest } from 'ahooks';
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
var useModifyProps = function useModifyProps(_ref) {
|
|
22
|
+
var visible = _ref.visible,
|
|
23
|
+
configData = _ref.configData,
|
|
24
|
+
initialValues = _ref.initialValues,
|
|
25
|
+
dialogForm = _ref.dialogForm,
|
|
26
|
+
afterClose = _ref.afterClose;
|
|
27
|
+
var _useState = useState(visible),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
modalVisible = _useState2[0],
|
|
30
|
+
setModalVisible = _useState2[1];
|
|
31
|
+
var _useState3 = useState(configData),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
modalFormData = _useState4[0],
|
|
34
|
+
setModalFormData = _useState4[1];
|
|
35
|
+
var _useState5 = useState(initialValues),
|
|
36
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
+
initValue = _useState6[0],
|
|
38
|
+
setInitValue = _useState6[1];
|
|
39
|
+
var onAfterClose = function onAfterClose() {
|
|
40
|
+
_setTimeout(function () {
|
|
41
|
+
dialogForm.resetFields();
|
|
42
|
+
afterClose === null || afterClose === void 0 ? void 0 : afterClose();
|
|
43
|
+
}, 0);
|
|
44
|
+
};
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
setModalVisible(visible);
|
|
47
|
+
}, [visible]);
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
setModalFormData(configData);
|
|
50
|
+
}, [configData]);
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
dialogForm.show = function () {
|
|
53
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
54
|
+
var changeConfigData = params.configData,
|
|
55
|
+
changeInitialValues = params.initialValues;
|
|
56
|
+
if (!!changeConfigData) {
|
|
57
|
+
setModalFormData(changeConfigData);
|
|
58
|
+
}
|
|
59
|
+
setInitValue(changeInitialValues);
|
|
60
|
+
setModalVisible(true);
|
|
61
|
+
};
|
|
62
|
+
dialogForm.hide = function () {
|
|
63
|
+
setModalVisible(false);
|
|
64
|
+
onAfterClose();
|
|
65
|
+
};
|
|
66
|
+
}, [afterClose]);
|
|
67
|
+
return {
|
|
68
|
+
modalFormData: modalFormData,
|
|
69
|
+
modalVisible: modalVisible,
|
|
70
|
+
setModalVisible: setModalVisible,
|
|
71
|
+
setModalFormData: setModalFormData,
|
|
72
|
+
initValue: initValue,
|
|
73
|
+
setInitValue: setInitValue,
|
|
74
|
+
onAfterClose: onAfterClose
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var useHDialogForm = function useHDialogForm() {
|
|
78
|
+
var hForm = useHForm();
|
|
79
|
+
return useMemo(function () {
|
|
80
|
+
return _objectSpread(_objectSpread({}, hForm), {}, {
|
|
81
|
+
show: function show(params) {},
|
|
82
|
+
hide: function hide() {}
|
|
83
|
+
});
|
|
84
|
+
}, []);
|
|
85
|
+
};
|
|
86
|
+
var useCurrentForm = function useCurrentForm(hDialogForm) {
|
|
87
|
+
var defaultHModalForm = useHDialogForm();
|
|
88
|
+
return hDialogForm || defaultHModalForm;
|
|
89
|
+
};
|
|
90
|
+
var useSub = function useSub(_ref2) {
|
|
91
|
+
var request = _ref2.request,
|
|
92
|
+
onFinish = _ref2.onFinish;
|
|
93
|
+
return useRequest( /*#__PURE__*/function () {
|
|
94
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
95
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
96
|
+
while (1) switch (_context.prev = _context.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!onFinish) {
|
|
99
|
+
_context.next = 2;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
return _context.abrupt("return", onFinish(values));
|
|
103
|
+
case 2:
|
|
104
|
+
if (!request) {
|
|
105
|
+
_context.next = 4;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return _context.abrupt("return", request(values));
|
|
109
|
+
case 4:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context.stop();
|
|
112
|
+
}
|
|
113
|
+
}, _callee);
|
|
114
|
+
}));
|
|
115
|
+
return function (_x) {
|
|
116
|
+
return _ref3.apply(this, arguments);
|
|
117
|
+
};
|
|
118
|
+
}(), {
|
|
119
|
+
manual: true
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { useCurrentForm, useHDialogForm, useModifyProps, useSub };
|
|
124
|
+
// powered by hdj
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ModalProps } from "antd";
|
|
2
|
+
import type { HFormInstance, HItemProps, HFormProps } from "../Form/modal";
|
|
3
|
+
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
type RootProps = HFormProps & ModalProps;
|
|
5
|
+
export interface ModifyPropsModal {
|
|
6
|
+
configData: HItemProps[];
|
|
7
|
+
visible?: boolean;
|
|
8
|
+
initialValues?: Record<string, any>;
|
|
9
|
+
dialogForm: HDialogFormInstance;
|
|
10
|
+
afterClose?: VoidFunction;
|
|
11
|
+
}
|
|
12
|
+
export interface ShowParamsModal {
|
|
13
|
+
configData?: HItemProps[];
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
initialValues?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
export interface HDialogFormInstance extends HFormInstance {
|
|
18
|
+
show: (data?: ShowParamsModal) => void;
|
|
19
|
+
hide: VoidFunction;
|
|
20
|
+
}
|
|
21
|
+
export interface DialogFormProps extends Omit<RootProps, "onFinish"> {
|
|
22
|
+
dialogForm?: HDialogFormInstance;
|
|
23
|
+
onFinish?: PromiseFnResult;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
5
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
6
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
7
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
11
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
12
|
+
import { FormConfigContext } from './index.js';
|
|
13
|
+
import React, { useContext } from 'react';
|
|
14
|
+
import { baseConfig } from '../../config.js';
|
|
15
|
+
|
|
16
|
+
var _excluded = ["children"];
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
var useFormConfigContext = function useFormConfigContext(key) {
|
|
20
|
+
var defaultProps = useContext(FormConfigContext);
|
|
21
|
+
if (!key) {
|
|
22
|
+
return _Object$keys(defaultProps).length === 0 ? _objectSpread({}, baseConfig) : defaultProps;
|
|
23
|
+
}
|
|
24
|
+
return defaultProps[key] || _objectSpread({}, baseConfig[key]);
|
|
25
|
+
};
|
|
26
|
+
var mergeProps = function mergeProps(props) {
|
|
27
|
+
var newProps = _objectSpread({}, baseConfig);
|
|
28
|
+
var keys = _Object$keys(props);
|
|
29
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
30
|
+
var defaultItem = newProps[key];
|
|
31
|
+
if (!defaultItem) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
newProps[key] = _objectSpread(_objectSpread({}, defaultItem), props[key]);
|
|
35
|
+
});
|
|
36
|
+
return newProps;
|
|
37
|
+
};
|
|
38
|
+
var Index = function Index(_ref) {
|
|
39
|
+
var children = _ref.children,
|
|
40
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
+
return /*#__PURE__*/React.createElement(FormConfigContext.Provider, {
|
|
42
|
+
value: mergeProps(props)
|
|
43
|
+
}, children);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { Index as default, useFormConfigContext };
|
|
47
|
+
// powered by hdj
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { IFormConfigContextProps, FormContextProps } from "@/components/Form/modal";
|
|
3
|
+
export declare const FormContext: React.Context<Partial<FormContextProps>>;
|
|
4
|
+
export declare const useFormContext: () => FormContextProps;
|
|
5
|
+
export declare const FormConfigContext: React.Context<IFormConfigContextProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
var FormContext = /*#__PURE__*/React.createContext({});
|
|
5
|
+
var useFormContext = function useFormContext() {
|
|
6
|
+
return useContext(FormContext);
|
|
7
|
+
};
|
|
8
|
+
var FormConfigContext = /*#__PURE__*/React.createContext({});
|
|
9
|
+
|
|
10
|
+
export { FormConfigContext, FormContext, useFormContext };
|
|
11
|
+
// powered by hdj
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
4
|
+
import Index$1 from '../Label.js';
|
|
5
|
+
import { Form, Space } from 'antd';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import Index$2 from './Helper.js';
|
|
8
|
+
import { useClassName } from '../../hooks/index.js';
|
|
9
|
+
import { useHide } from './hooks.js';
|
|
10
|
+
import { useFormContext } from '../Context/index.js';
|
|
11
|
+
|
|
12
|
+
var _excluded = ["hover", "labelWidth", "required", "colon", "label", "itemProps", "children", "helper", "hide", "render"];
|
|
13
|
+
var Content = function Content(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
helper = _ref.helper,
|
|
16
|
+
value = _ref.value,
|
|
17
|
+
onChange = _ref.onChange;
|
|
18
|
+
var className = useClassName("hw-form-base-item");
|
|
19
|
+
var relChild = children && /*#__PURE__*/React.cloneElement(children, {
|
|
20
|
+
value: value,
|
|
21
|
+
onChange: onChange
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
24
|
+
direction: "vertical",
|
|
25
|
+
size: 4,
|
|
26
|
+
style: {
|
|
27
|
+
width: "100%"
|
|
28
|
+
}
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: className
|
|
31
|
+
}, relChild), /*#__PURE__*/React.createElement(Index$2, {
|
|
32
|
+
helper: helper
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
var Index = function Index(_ref2) {
|
|
36
|
+
var hover = _ref2.hover,
|
|
37
|
+
labelWidth = _ref2.labelWidth,
|
|
38
|
+
required = _ref2.required,
|
|
39
|
+
_ref2$colon = _ref2.colon,
|
|
40
|
+
colon = _ref2$colon === void 0 ? true : _ref2$colon,
|
|
41
|
+
label = _ref2.label;
|
|
42
|
+
_ref2.itemProps;
|
|
43
|
+
_ref2.children;
|
|
44
|
+
var helper = _ref2.helper,
|
|
45
|
+
hide = _ref2.hide,
|
|
46
|
+
render = _ref2.render,
|
|
47
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
48
|
+
var _useFormContext = useFormContext(),
|
|
49
|
+
form = _useFormContext.form;
|
|
50
|
+
var hideItem = useHide({
|
|
51
|
+
hide: hide,
|
|
52
|
+
form: form
|
|
53
|
+
});
|
|
54
|
+
if (hideItem) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/React.createElement(Form.Item, _extends({
|
|
58
|
+
label: /*#__PURE__*/React.createElement(Index$1, {
|
|
59
|
+
hover: hover,
|
|
60
|
+
labelWidth: labelWidth,
|
|
61
|
+
required: required,
|
|
62
|
+
colon: colon
|
|
63
|
+
}, label)
|
|
64
|
+
}, props, {
|
|
65
|
+
colon: false,
|
|
66
|
+
required: false
|
|
67
|
+
}), /*#__PURE__*/React.createElement(Content, {
|
|
68
|
+
helper: helper
|
|
69
|
+
}, render(form)));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { Index as default };
|
|
73
|
+
// powered by hdj
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Typography } from 'antd';
|
|
4
|
+
import { useFormContext } from '../Context/index.js';
|
|
5
|
+
|
|
6
|
+
var Index = function Index(_ref) {
|
|
7
|
+
var helper = _ref.helper;
|
|
8
|
+
var _useFormContext = useFormContext(),
|
|
9
|
+
form = _useFormContext.form;
|
|
10
|
+
if (!helper) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (typeof helper === "function") {
|
|
14
|
+
return /*#__PURE__*/React.createElement(Typography.Text, {
|
|
15
|
+
type: "secondary"
|
|
16
|
+
}, helper(form));
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement(Typography.Text, {
|
|
19
|
+
type: "secondary"
|
|
20
|
+
}, helper);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { Index as default };
|
|
24
|
+
// powered by hdj
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import Index from './BasicItem.js';
|
|
5
|
+
|
|
6
|
+
var RegularFormItem = (function (props) {
|
|
7
|
+
var type = props.type,
|
|
8
|
+
colon = props.colon;
|
|
9
|
+
return /*#__PURE__*/React.createElement(Index, _extends({}, props, {
|
|
10
|
+
colon: type === "submit" ? false : colon
|
|
11
|
+
}));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { RegularFormItem as default };
|
|
15
|
+
// powered by hdj
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import { Form } from 'antd';
|
|
6
|
+
import Index from './BasicItem.js';
|
|
7
|
+
import { useShouldUpdate } from './hooks.js';
|
|
8
|
+
|
|
9
|
+
var _excluded = ["shouldUpdate", "dependencies", "hide"];
|
|
10
|
+
var Item = Form.Item;
|
|
11
|
+
var UpFormItem = (function (_ref) {
|
|
12
|
+
var shouldUpdate = _ref.shouldUpdate,
|
|
13
|
+
dependencies = _ref.dependencies,
|
|
14
|
+
hide = _ref.hide,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
var resultShouldUpdate = useShouldUpdate({
|
|
17
|
+
shouldUpdate: shouldUpdate,
|
|
18
|
+
hide: hide
|
|
19
|
+
});
|
|
20
|
+
return /*#__PURE__*/React.createElement(Item, {
|
|
21
|
+
shouldUpdate: resultShouldUpdate,
|
|
22
|
+
dependencies: dependencies
|
|
23
|
+
}, function () {
|
|
24
|
+
return /*#__PURE__*/React.createElement(Index, _extends({
|
|
25
|
+
hide: hide
|
|
26
|
+
}, props));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export { UpFormItem as default };
|
|
31
|
+
// powered by hdj
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FormItemWithRender, HFormInstance } from "@/components/Form/modal";
|
|
3
|
+
import type { HItemProps } from "@/components/Form/modal";
|
|
4
|
+
export declare const useFormItemDomControl: ({ shouldUpdate, hide, dependencies, }: FormItemWithRender) => ({ shouldUpdate, dependencies, hide, ...props }: FormItemWithRender) => JSX.Element;
|
|
5
|
+
interface UseHideUpItemModal extends Omit<HItemProps, "name"> {
|
|
6
|
+
form: HFormInstance;
|
|
7
|
+
}
|
|
8
|
+
export declare const useShouldUpdate: ({ hide, shouldUpdate, }: Omit<HItemProps, "name">) => import("rc-field-form/lib/Field").ShouldUpdate<any> | undefined;
|
|
9
|
+
export declare const useHide: ({ hide, form }: UseHideUpItemModal) => boolean;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import UpFormItem from './UpFormItem.js';
|
|
3
|
+
import RegularFormItem from './RegularFormItem.js';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
|
|
6
|
+
var useFormItemDomControl = function useFormItemDomControl(_ref) {
|
|
7
|
+
var shouldUpdate = _ref.shouldUpdate,
|
|
8
|
+
hide = _ref.hide,
|
|
9
|
+
dependencies = _ref.dependencies;
|
|
10
|
+
return useMemo(function () {
|
|
11
|
+
if (shouldUpdate || typeof hide === "function" || dependencies) {
|
|
12
|
+
return UpFormItem;
|
|
13
|
+
}
|
|
14
|
+
return RegularFormItem;
|
|
15
|
+
}, [shouldUpdate, hide]);
|
|
16
|
+
};
|
|
17
|
+
var useShouldUpdate = function useShouldUpdate(_ref2) {
|
|
18
|
+
var hide = _ref2.hide,
|
|
19
|
+
shouldUpdate = _ref2.shouldUpdate;
|
|
20
|
+
if (typeof hide === "function" && !shouldUpdate) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return shouldUpdate;
|
|
24
|
+
};
|
|
25
|
+
var useHide = function useHide(_ref3) {
|
|
26
|
+
var hide = _ref3.hide,
|
|
27
|
+
form = _ref3.form;
|
|
28
|
+
if (hide === true) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (typeof hide === "function") {
|
|
32
|
+
return hide(form);
|
|
33
|
+
}
|
|
34
|
+
return !!hide;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { useFormItemDomControl, useHide, useShouldUpdate };
|
|
38
|
+
// powered by hdj
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import { useFormItemDomControl } from './hooks.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
var Item = (function (props) {
|
|
6
|
+
var Component = useFormItemDomControl(props);
|
|
7
|
+
return /*#__PURE__*/React.createElement(Component, props);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { Item as default };
|
|
11
|
+
// powered by hdj
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HFormItemProps } from "@/components/Form/modal";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { ConnectConfigModal } from "@/components/Form/modal";
|
|
4
|
+
declare const _default: (component: React.FunctionComponent | React.ComponentClass | React.ForwardRefRenderFunction<any, any>, config?: ConnectConfigModal) => React.ForwardRefExoticComponent<HFormItemProps & React.RefAttributes<any>>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
3
|
+
import { useFormContext } from './Context/index.js';
|
|
4
|
+
import React, { useEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
var formatMaker = function formatMaker(itemProps, formats) {
|
|
7
|
+
if (!formats) {
|
|
8
|
+
return formats;
|
|
9
|
+
}
|
|
10
|
+
var _inputValue = formats.inputValue,
|
|
11
|
+
_outputValue = formats.outputValue;
|
|
12
|
+
return {
|
|
13
|
+
inputValue: function inputValue(value) {
|
|
14
|
+
return _inputValue(itemProps, value);
|
|
15
|
+
},
|
|
16
|
+
outputValue: function outputValue(value) {
|
|
17
|
+
return _outputValue(itemProps, value);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
var HFormConnect = (function (component) {
|
|
22
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
23
|
+
var _config$format = config.format,
|
|
24
|
+
format = _config$format === void 0 ? {} : _config$format;
|
|
25
|
+
var Index = function Index(props, ref) {
|
|
26
|
+
var _props$name = props.name,
|
|
27
|
+
name = _props$name === void 0 ? "" : _props$name;
|
|
28
|
+
var _useFormContext = useFormContext(),
|
|
29
|
+
form = _useFormContext.form,
|
|
30
|
+
_useFormContext$value = _useFormContext.valueType,
|
|
31
|
+
valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
form === null || form === void 0 ? void 0 : form.addFormat(name, formatMaker(props, format[valueType]));
|
|
34
|
+
}, [valueType, props]);
|
|
35
|
+
var addFormat = function addFormat(aFormat) {
|
|
36
|
+
form === null || form === void 0 ? void 0 : form.addFormat(name, formatMaker(props, aFormat[valueType]));
|
|
37
|
+
};
|
|
38
|
+
var addDispatchListener = function addDispatchListener(key, fn) {
|
|
39
|
+
form === null || form === void 0 ? void 0 : form.addDispatchListener({
|
|
40
|
+
key: key,
|
|
41
|
+
name: name
|
|
42
|
+
}, fn);
|
|
43
|
+
};
|
|
44
|
+
var Component = component;
|
|
45
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
46
|
+
addFormat: addFormat,
|
|
47
|
+
addDispatchListener: addDispatchListener,
|
|
48
|
+
ref: ref
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
return /*#__PURE__*/React.forwardRef(Index);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export { HFormConnect as default };
|
|
55
|
+
// powered by hdj
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { useFormContext } from './Context/index.js';
|
|
4
|
+
|
|
5
|
+
var InitSet = (function () {
|
|
6
|
+
var _useFormContext = useFormContext(),
|
|
7
|
+
form = _useFormContext.form;
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
form.initValues();
|
|
10
|
+
}, []);
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { InitSet as default };
|
|
15
|
+
// powered by hdj
|