@hw-component/form 0.0.2 → 0.0.3-beta-v2
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/es/CheckboxGroup/CheckBox/index.d.ts +2 -5
- package/es/CheckboxGroup/CheckBox/index.js +9 -5
- package/es/CheckboxGroup/hooks.d.ts +1 -1
- package/es/CheckboxGroup/hooks.js +18 -19
- package/es/CheckboxGroup/index.d.ts +2 -3
- package/es/CheckboxGroup/index.js +57 -15
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/DialogForm/DrawerForm/Footer.d.ts +8 -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 +124 -0
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/DialogForm/ModalForm.js +103 -0
- package/es/DialogForm/hooks.d.ts +15 -0
- package/es/DialogForm/hooks.js +137 -0
- package/es/DialogForm/modal.d.ts +31 -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 +32 -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 +8 -0
- package/es/Form/hooks/index.js +102 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +176 -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 +79 -0
- package/es/Form/modal.d.ts +107 -0
- package/es/Input/ButtonInput.d.ts +2 -2
- package/es/Input/ButtonInput.js +9 -6
- package/es/Input/InputNumber.js +6 -6
- package/es/Input/SelectInput.d.ts +2 -1
- package/es/Input/SelectInput.js +40 -10
- package/es/Input/defaultConfig.js +2 -2
- package/es/Input/index.js +4 -4
- 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 +2 -2
- package/es/RadioGroup/index.js +11 -7
- package/es/Select/components/AllSelect.d.ts +3 -3
- package/es/Select/components/AllSelect.js +26 -13
- 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.js +2 -2
- package/es/Select/hooks/changeHooks.js +3 -4
- package/es/Select/hooks/norHooks.d.ts +3 -2
- package/es/Select/hooks/norHooks.js +9 -4
- package/es/Select/index.d.ts +1 -1
- package/es/Select/index.js +21 -14
- package/es/Select/modal.d.ts +1 -0
- package/es/Select/utils.js +2 -2
- package/es/Submit/index.d.ts +8 -0
- package/es/Submit/index.js +28 -0
- package/es/Switch/index.d.ts +4 -3
- package/es/Switch/index.js +14 -10
- 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/{lib/DatePicker → es/TDPicker}/index.d.ts +2 -2
- package/es/{DatePicker → TDPicker}/index.js +14 -20
- 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 +141 -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 -14
- package/es/config.js +55 -9
- package/{lib/hooks/useChangeOptions.d.ts → es/hooks/index.d.ts} +3 -0
- package/es/hooks/index.js +75 -0
- package/es/index.css +33 -1
- package/es/index.d.ts +24 -11
- package/es/index.js +31 -13
- package/es/modal.d.ts +15 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +2 -5
- package/lib/CheckboxGroup/CheckBox/index.js +7 -3
- package/lib/CheckboxGroup/hooks.d.ts +1 -1
- package/lib/CheckboxGroup/hooks.js +16 -17
- package/lib/CheckboxGroup/index.d.ts +2 -3
- package/lib/CheckboxGroup/index.js +54 -12
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/DialogForm/DrawerForm/Footer.d.ts +8 -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 +127 -0
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/DialogForm/ModalForm.js +106 -0
- package/lib/DialogForm/hooks.d.ts +15 -0
- package/lib/DialogForm/hooks.js +141 -0
- package/lib/DialogForm/modal.d.ts +31 -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 +35 -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 +8 -0
- package/lib/Form/hooks/index.js +104 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +179 -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 +82 -0
- package/lib/Form/modal.d.ts +107 -0
- package/lib/Input/ButtonInput.d.ts +2 -2
- package/lib/Input/ButtonInput.js +7 -4
- package/lib/Input/InputNumber.js +2 -2
- package/lib/Input/SelectInput.d.ts +2 -1
- package/lib/Input/SelectInput.js +39 -8
- package/lib/Input/index.js +2 -2
- 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 +2 -2
- package/lib/RadioGroup/index.js +9 -5
- package/lib/Select/components/AllSelect.d.ts +3 -3
- package/lib/Select/components/AllSelect.js +24 -11
- package/lib/Select/components/NotFoundContent.js +1 -3
- package/lib/Select/hooks/changeHooks.js +1 -2
- package/lib/Select/hooks/norHooks.d.ts +3 -2
- package/lib/Select/hooks/norHooks.js +7 -2
- package/lib/Select/index.d.ts +1 -1
- package/lib/Select/index.js +18 -11
- package/lib/Select/modal.d.ts +1 -0
- package/lib/Submit/index.d.ts +8 -0
- package/lib/Submit/index.js +31 -0
- package/lib/Switch/index.d.ts +4 -3
- package/lib/Switch/index.js +12 -8
- 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/{es/DatePicker → lib/TDPicker}/index.d.ts +2 -2
- package/lib/{DatePicker → TDPicker}/index.js +11 -17
- 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 +144 -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 -14
- package/lib/config.js +53 -7
- package/{es/hooks/useChangeOptions.d.ts → lib/hooks/index.d.ts} +3 -0
- package/lib/hooks/index.js +78 -0
- package/lib/index.css +33 -1
- package/lib/index.d.ts +24 -11
- package/lib/index.js +48 -23
- 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 +7 -7
- package/src/components/CheckboxGroup/hooks.ts +12 -13
- package/src/components/CheckboxGroup/index.tsx +40 -7
- package/src/components/CheckboxGroup/{modal.d.ts → modal.ts} +4 -1
- package/src/components/DialogForm/DrawerForm/Footer.tsx +24 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +93 -0
- package/src/components/DialogForm/ModalForm.tsx +68 -0
- package/src/components/DialogForm/hooks.ts +100 -0
- package/src/components/DialogForm/modal.ts +34 -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 +61 -0
- package/src/components/Form/hooks/useHForm.ts +150 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +100 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +75 -0
- package/src/components/Form/modal.ts +157 -0
- package/src/components/Input/ButtonInput.tsx +11 -5
- package/src/components/Input/SelectInput.tsx +34 -3
- 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 +8 -4
- package/src/components/Select/components/AllSelect.tsx +28 -15
- package/src/components/Select/components/DropdownComponent.tsx +1 -0
- package/src/components/Select/components/NotFoundContent.tsx +1 -1
- package/src/components/Select/hooks/changeHooks.tsx +1 -2
- package/src/components/Select/hooks/norHooks.ts +6 -1
- package/src/components/Select/index.less +20 -3
- package/src/components/Select/index.tsx +17 -9
- package/src/components/Select/modal.ts +8 -7
- package/src/components/Submit/index.tsx +28 -0
- package/src/components/Switch/index.tsx +14 -9
- 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 +119 -0
- package/src/components/Upload/modal.ts +33 -0
- package/src/components/Upload/util.ts +27 -0
- package/src/components/config.ts +34 -8
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +27 -12
- 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/components/typings.d.ts +0 -5
- package/src/pages/Checkbox/index.tsx +4 -5
- package/src/pages/DatePicker/index.tsx +20 -2
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +148 -0
- package/src/pages/ModalForm/index.tsx +139 -0
- package/src/pages/Select/index.tsx +6 -2
- package/src/pages/Switch/index.tsx +1 -1
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +24 -0
- package/es/DatePicker/RangePicker.d.ts +0 -4
- package/es/DatePicker/RangePicker.js +0 -23
- package/es/Select/index.less.js +0 -5
- package/es/TimePicker/index.d.ts +0 -2
- package/es/hooks/useChangeOptions.js +0 -25
- package/lib/DatePicker/RangePicker.d.ts +0 -4
- package/lib/DatePicker/RangePicker.js +0 -26
- package/lib/Select/index.less.js +0 -8
- package/lib/TimePicker/index.d.ts +0 -2
- package/lib/hooks/useChangeOptions.js +0 -26
- package/src/components/DatePicker/RangePicker.tsx +0 -7
- package/src/components/DatePicker/index.tsx +0 -38
- package/src/components/DatePicker/modal.d.ts +0 -16
- package/src/components/Input/modal.d.ts +0 -26
- package/src/components/TimePicker/index.tsx +0 -1
- package/src/components/hooks/useChangeOptions.ts +0 -22
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import HSelect from '../Select/index.js';
|
|
3
|
+
import HInput from '../Input/index.js';
|
|
4
|
+
import HInputNumber from '../Input/InputNumber.js';
|
|
5
|
+
import HSelectInput from '../Input/SelectInput.js';
|
|
6
|
+
import Index from '../Input/ButtonInput.js';
|
|
7
|
+
import HCheckboxGroup from '../CheckboxGroup/index.js';
|
|
8
|
+
import Index$1 from '../CheckboxGroup/CheckBox/index.js';
|
|
9
|
+
import HRadioGroup from '../RadioGroup/index.js';
|
|
10
|
+
import Index$2 from '../Switch/index.js';
|
|
11
|
+
import HDatePicker from '../TDPicker/index.js';
|
|
12
|
+
import HRangePicker from '../TDPicker/RangePicker.js';
|
|
13
|
+
import HTimePicker from '../TDPicker/TimePicker.js';
|
|
14
|
+
import HUpload from '../Upload/index.js';
|
|
15
|
+
import Index$3 from '../Upload/UrlUpload/index.js';
|
|
16
|
+
import HSubmit from '../Submit/index.js';
|
|
17
|
+
import Index$4 from './Context/FormConfigProvider.js';
|
|
18
|
+
import TextArea from '../TextArea/index.js';
|
|
19
|
+
|
|
20
|
+
var placeholderConfig = {
|
|
21
|
+
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
22
|
+
selectType: ["select", "datePicker", "timePicker"]
|
|
23
|
+
};
|
|
24
|
+
var FormConfig = {
|
|
25
|
+
select: HSelect,
|
|
26
|
+
inputNumber: HInputNumber,
|
|
27
|
+
selectInput: HSelectInput,
|
|
28
|
+
buttonInput: Index,
|
|
29
|
+
checkboxGroup: HCheckboxGroup,
|
|
30
|
+
checkBox: Index$1,
|
|
31
|
+
radioGroup: HRadioGroup,
|
|
32
|
+
"switch": Index$2,
|
|
33
|
+
datePicker: HDatePicker,
|
|
34
|
+
rangePicker: HRangePicker,
|
|
35
|
+
timePicker: HTimePicker,
|
|
36
|
+
input: HInput,
|
|
37
|
+
upload: HUpload,
|
|
38
|
+
urlUpload: Index$3,
|
|
39
|
+
submit: HSubmit,
|
|
40
|
+
formConfigProvider: Index$4,
|
|
41
|
+
textArea: TextArea
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { FormConfig as default, placeholderConfig };
|
|
45
|
+
// powered by hdj
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HFormProps, HFormInstance } from "../modal";
|
|
2
|
+
export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
3
|
+
type ParamsModal = Omit<HFormProps, "configData">;
|
|
4
|
+
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
|
|
5
|
+
subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
6
|
+
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<import("rc-field-form/lib/interface").Store, [reqParams?: any]>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
4
|
+
import { useRequest } from 'ahooks';
|
|
5
|
+
import useHForm from './useHForm.js';
|
|
6
|
+
import { useMemo, useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
var useCurrentForm = function useCurrentForm(form) {
|
|
9
|
+
var selfForm = useHForm();
|
|
10
|
+
return form || selfForm;
|
|
11
|
+
};
|
|
12
|
+
var useInfoReq = function useInfoReq(_ref) {
|
|
13
|
+
var initialValues = _ref.initialValues,
|
|
14
|
+
infoRequest = _ref.infoRequest,
|
|
15
|
+
form = _ref.form,
|
|
16
|
+
params = _ref.params,
|
|
17
|
+
request = _ref.request,
|
|
18
|
+
onFinish = _ref.onFinish;
|
|
19
|
+
var reqData = useMemo(function () {
|
|
20
|
+
var saveParams = params || {};
|
|
21
|
+
return {
|
|
22
|
+
params: saveParams
|
|
23
|
+
};
|
|
24
|
+
}, [params]);
|
|
25
|
+
var subControl = useRequest( /*#__PURE__*/function () {
|
|
26
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
27
|
+
var subVal;
|
|
28
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
29
|
+
while (1) switch (_context.prev = _context.next) {
|
|
30
|
+
case 0:
|
|
31
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
32
|
+
if (!request) {
|
|
33
|
+
_context.next = 4;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
_context.next = 4;
|
|
37
|
+
return request(subVal, reqData.params);
|
|
38
|
+
case 4:
|
|
39
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(subVal, reqData.params);
|
|
40
|
+
case 5:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context.stop();
|
|
43
|
+
}
|
|
44
|
+
}, _callee);
|
|
45
|
+
}));
|
|
46
|
+
return function (_x) {
|
|
47
|
+
return _ref2.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
}(), {
|
|
50
|
+
manual: true
|
|
51
|
+
});
|
|
52
|
+
var infoControl = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
53
|
+
var reqParams,
|
|
54
|
+
setValue,
|
|
55
|
+
_args2 = arguments;
|
|
56
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
57
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
|
|
60
|
+
setValue = initialValues;
|
|
61
|
+
reqData.params = reqParams;
|
|
62
|
+
if (!(!initialValues && !infoRequest)) {
|
|
63
|
+
_context2.next = 5;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return _context2.abrupt("return", {});
|
|
67
|
+
case 5:
|
|
68
|
+
if (!infoRequest) {
|
|
69
|
+
_context2.next = 9;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
_context2.next = 8;
|
|
73
|
+
return infoRequest(reqParams);
|
|
74
|
+
case 8:
|
|
75
|
+
setValue = _context2.sent;
|
|
76
|
+
case 9:
|
|
77
|
+
form === null || form === void 0 ? void 0 : form.setFieldsValue(setValue);
|
|
78
|
+
return _context2.abrupt("return", setValue || {});
|
|
79
|
+
case 11:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context2.stop();
|
|
82
|
+
}
|
|
83
|
+
}, _callee2);
|
|
84
|
+
})));
|
|
85
|
+
var run = infoControl.run,
|
|
86
|
+
mutate = infoControl.mutate;
|
|
87
|
+
useEffect(function () {
|
|
88
|
+
if (form) {
|
|
89
|
+
form.reload = function (params) {
|
|
90
|
+
mutate(undefined);
|
|
91
|
+
return run(params);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}, []);
|
|
95
|
+
return {
|
|
96
|
+
subControl: subControl,
|
|
97
|
+
infoControl: infoControl
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { useCurrentForm, useInfoReq };
|
|
102
|
+
// powered by hdj
|
|
@@ -0,0 +1,176 @@
|
|
|
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 _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
11
|
+
import _Promise from '@babel/runtime-corejs3/core-js/promise';
|
|
12
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
13
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
14
|
+
import _Reflect$deleteProperty from '@babel/runtime-corejs3/core-js/reflect/delete-property';
|
|
15
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
|
|
16
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
17
|
+
import { useMemo } from 'react';
|
|
18
|
+
import { Form } from 'antd';
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
var useHForm = (function () {
|
|
23
|
+
var _Form$useForm = Form.useForm(),
|
|
24
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
25
|
+
form = _Form$useForm2[0];
|
|
26
|
+
return useMemo(function () {
|
|
27
|
+
var formatSourceData = {};
|
|
28
|
+
var dispatchSourceData = {};
|
|
29
|
+
var cacheValues = {};
|
|
30
|
+
var isLoading = false;
|
|
31
|
+
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
32
|
+
if (!name) {
|
|
33
|
+
return {
|
|
34
|
+
keysFn: {},
|
|
35
|
+
defaultFn: [fn]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
keysFn: _defineProperty({}, name, fn),
|
|
40
|
+
defaultFn: []
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
return _objectSpread(_objectSpread({
|
|
44
|
+
reload: function reload(params) {
|
|
45
|
+
return _Promise.resolve(params);
|
|
46
|
+
},
|
|
47
|
+
initValues: function initValues() {
|
|
48
|
+
if (cacheValues) {
|
|
49
|
+
var newValue = this.formatValues(cacheValues);
|
|
50
|
+
form.setFieldsValue(newValue);
|
|
51
|
+
}
|
|
52
|
+
isLoading = true;
|
|
53
|
+
},
|
|
54
|
+
addFormat: function addFormat(name, format) {
|
|
55
|
+
if (!format) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var inputValue = format.inputValue,
|
|
59
|
+
outputValue = format.outputValue;
|
|
60
|
+
formatSourceData[name] = {
|
|
61
|
+
inputValue: inputValue,
|
|
62
|
+
outputValue: outputValue
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
formatValues: function formatValues() {
|
|
66
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
68
|
+
var valKeys = _Object$keys(value).length;
|
|
69
|
+
if (!valKeys) {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
var newValue = _objectSpread({}, value);
|
|
73
|
+
var keys = _Object$keys(formatSourceData);
|
|
74
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
75
|
+
var _formatSourceData$key;
|
|
76
|
+
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
77
|
+
if (!format) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var resultValue = format(value);
|
|
81
|
+
_Reflect$deleteProperty(newValue, key);
|
|
82
|
+
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
83
|
+
});
|
|
84
|
+
return newValue;
|
|
85
|
+
},
|
|
86
|
+
dispatch: function dispatch(action) {
|
|
87
|
+
var _context2, _context3, _context4;
|
|
88
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
89
|
+
args[_key - 1] = arguments[_key];
|
|
90
|
+
}
|
|
91
|
+
var key = action.key,
|
|
92
|
+
name = action.name;
|
|
93
|
+
var items = dispatchSourceData[key];
|
|
94
|
+
if (!items) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
var keysFn = items.keysFn,
|
|
98
|
+
defaultFn = items.defaultFn;
|
|
99
|
+
if (name) {
|
|
100
|
+
var _keysFn$name, _context;
|
|
101
|
+
return (_keysFn$name = keysFn[name]) === null || _keysFn$name === void 0 ? void 0 : _keysFn$name.call.apply(_keysFn$name, _concatInstanceProperty(_context = [keysFn]).call(_context, args));
|
|
102
|
+
}
|
|
103
|
+
var fnArrays = _mapInstanceProperty(_context2 = _Object$keys(keysFn)).call(_context2, function (itemKey) {
|
|
104
|
+
return keysFn[itemKey];
|
|
105
|
+
});
|
|
106
|
+
_forEachInstanceProperty(_context3 = _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(fnArrays), _toConsumableArray(defaultFn))).call(_context3, function (fn) {
|
|
107
|
+
fn.apply(void 0, args);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
addDispatchListener: function addDispatchListener(action, fn) {
|
|
111
|
+
var key = action.key,
|
|
112
|
+
name = action.name;
|
|
113
|
+
var items = dispatchSourceData[key];
|
|
114
|
+
if (!items) {
|
|
115
|
+
dispatchSourceData[key] = norAddItemDispatch(name, fn);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var keysFn = items.keysFn,
|
|
119
|
+
defaultFn = items.defaultFn;
|
|
120
|
+
if (name) {
|
|
121
|
+
keysFn[name] = fn;
|
|
122
|
+
} else {
|
|
123
|
+
defaultFn.push(fn);
|
|
124
|
+
}
|
|
125
|
+
dispatchSourceData[key] = {
|
|
126
|
+
keysFn: keysFn,
|
|
127
|
+
defaultFn: defaultFn
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
removeDispatchListener: function removeDispatchListener(action) {
|
|
131
|
+
if (!action) {
|
|
132
|
+
dispatchSourceData = {};
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var key = action.key,
|
|
136
|
+
name = action.name;
|
|
137
|
+
var items = dispatchSourceData[key];
|
|
138
|
+
if (!items) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (name) {
|
|
142
|
+
var keysFn = items.keysFn;
|
|
143
|
+
_Reflect$deleteProperty(keysFn, name);
|
|
144
|
+
items.keysFn = keysFn;
|
|
145
|
+
dispatchSourceData[key] = items;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
149
|
+
},
|
|
150
|
+
outputValues: function outputValues(value) {
|
|
151
|
+
return this.formatValues(value, "outputValue");
|
|
152
|
+
}
|
|
153
|
+
}, form), {}, {
|
|
154
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
155
|
+
if (!isLoading) {
|
|
156
|
+
cacheValues = values;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
var newValue = this.formatValues(values);
|
|
160
|
+
form.setFieldsValue(newValue);
|
|
161
|
+
},
|
|
162
|
+
validateFields: function validateFields(nameList) {
|
|
163
|
+
var _this = this;
|
|
164
|
+
return new _Promise(function (resolve) {
|
|
165
|
+
form.validateFields(nameList).then(function (value) {
|
|
166
|
+
var result = _this.formatValues(value, "outputValue");
|
|
167
|
+
return resolve(result);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}, []);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export { useHForm as default };
|
|
176
|
+
// powered by hdj
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
4
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
5
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
6
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
7
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
8
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
9
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
10
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
11
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
12
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
13
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
14
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
15
|
+
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/index-of';
|
|
16
|
+
import FormConfig, { placeholderConfig } from '../config.js';
|
|
17
|
+
|
|
18
|
+
var _excluded = ["render", "type", "itemProps"],
|
|
19
|
+
_excluded2 = ["render"];
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
var mathRequired = function mathRequired(configItem, form) {
|
|
23
|
+
var required = configItem.required,
|
|
24
|
+
placeholder = configItem.placeholder,
|
|
25
|
+
rules = configItem.rules,
|
|
26
|
+
_configItem$type = configItem.type,
|
|
27
|
+
type = _configItem$type === void 0 ? "input" : _configItem$type;
|
|
28
|
+
var resultRequired = false;
|
|
29
|
+
var dom = FormConfig[type];
|
|
30
|
+
var resultRules = rules === null || rules === void 0 ? void 0 : _mapInstanceProperty(rules).call(rules, function (item) {
|
|
31
|
+
var eachItem = item;
|
|
32
|
+
if (typeof item === "function") {
|
|
33
|
+
eachItem = item(form);
|
|
34
|
+
}
|
|
35
|
+
var _eachItem = eachItem,
|
|
36
|
+
itemRequired = _eachItem.required,
|
|
37
|
+
message = _eachItem.message;
|
|
38
|
+
if (itemRequired) {
|
|
39
|
+
resultRequired = itemRequired;
|
|
40
|
+
}
|
|
41
|
+
if (itemRequired && !message) {
|
|
42
|
+
return _objectSpread(_objectSpread({}, eachItem), {}, {
|
|
43
|
+
required: itemRequired,
|
|
44
|
+
message: !!(dom !== null && dom !== void 0 && dom.requiredErrMsg) ? dom.requiredErrMsg(configItem) : placeholder
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return eachItem;
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
required: typeof required === "boolean" ? required : resultRequired,
|
|
51
|
+
rules: resultRules
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
55
|
+
var _context;
|
|
56
|
+
var label = props.label,
|
|
57
|
+
placeholder = props.placeholder,
|
|
58
|
+
_props$type = props.type,
|
|
59
|
+
type = _props$type === void 0 ? "input" : _props$type;
|
|
60
|
+
var dom = FormConfig[type];
|
|
61
|
+
if (placeholder) {
|
|
62
|
+
return placeholder;
|
|
63
|
+
}
|
|
64
|
+
if (dom !== null && dom !== void 0 && dom.placeholder) {
|
|
65
|
+
return dom.placeholder(props);
|
|
66
|
+
}
|
|
67
|
+
if (_indexOfInstanceProperty(_context = placeholderConfig.inputType).call(_context, type) !== -1) {
|
|
68
|
+
return "\u8BF7\u8F93\u5165".concat(label);
|
|
69
|
+
}
|
|
70
|
+
return "\u8BF7\u9009\u62E9".concat(label);
|
|
71
|
+
};
|
|
72
|
+
var defaultRenderMaker = function defaultRenderMaker(props) {
|
|
73
|
+
var render = props.render,
|
|
74
|
+
_props$type2 = props.type,
|
|
75
|
+
type = _props$type2 === void 0 ? "input" : _props$type2,
|
|
76
|
+
_props$itemProps = props.itemProps,
|
|
77
|
+
itemProps = _props$itemProps === void 0 ? {} : _props$itemProps,
|
|
78
|
+
componentProps = _objectWithoutProperties(props, _excluded);
|
|
79
|
+
var dom = FormConfig[type];
|
|
80
|
+
return function (form) {
|
|
81
|
+
var Component = !!(dom !== null && dom !== void 0 && dom.Component) ? dom.Component : dom;
|
|
82
|
+
var node = Component && /*#__PURE__*/React.createElement(Component, _extends({}, componentProps, itemProps, {
|
|
83
|
+
form: form
|
|
84
|
+
}));
|
|
85
|
+
if (render) {
|
|
86
|
+
return render(props, node, form);
|
|
87
|
+
}
|
|
88
|
+
return node;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(props) {
|
|
92
|
+
var placeholder = matchDefaultPlaceholder(props);
|
|
93
|
+
return _objectSpread(_objectSpread({}, props), {}, {
|
|
94
|
+
placeholder: placeholder,
|
|
95
|
+
render: defaultRenderMaker(_objectSpread(_objectSpread({}, props), {}, {
|
|
96
|
+
placeholder: placeholder
|
|
97
|
+
}))
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var itemControl = function itemControl(item, form) {
|
|
101
|
+
var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
|
|
102
|
+
render = _defaultPlaceholderPr.render,
|
|
103
|
+
defaultProps = _objectWithoutProperties(_defaultPlaceholderPr, _excluded2);
|
|
104
|
+
var _mathRequired = mathRequired(defaultProps, form),
|
|
105
|
+
rules = _mathRequired.rules,
|
|
106
|
+
required = _mathRequired.required;
|
|
107
|
+
return _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
108
|
+
required: required,
|
|
109
|
+
rules: rules,
|
|
110
|
+
render: render
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var useInitConfigData = (function (_ref) {
|
|
114
|
+
var configData = _ref.configData,
|
|
115
|
+
form = _ref.form;
|
|
116
|
+
return useMemo(function () {
|
|
117
|
+
return _mapInstanceProperty(configData).call(configData, function (item) {
|
|
118
|
+
return itemControl(item, form);
|
|
119
|
+
});
|
|
120
|
+
}, [configData]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export { useInitConfigData as default };
|
|
124
|
+
// powered by hdj
|
package/es/Form/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
6
|
+
import { Form } from 'antd';
|
|
7
|
+
import Item from './FormItem/index.js';
|
|
8
|
+
import { useCurrentForm, useInfoReq } from './hooks/index.js';
|
|
9
|
+
import { FormContext } from './Context/index.js';
|
|
10
|
+
import Index from '../PageHandler/index.js';
|
|
11
|
+
import useInitConfigData from './hooks/useInitConfigData.js';
|
|
12
|
+
import InitSet from './InitSet.js';
|
|
13
|
+
|
|
14
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params"];
|
|
15
|
+
var HForm = (function (_ref) {
|
|
16
|
+
var configData = _ref.configData,
|
|
17
|
+
labelWidth = _ref.labelWidth,
|
|
18
|
+
form = _ref.form,
|
|
19
|
+
request = _ref.request,
|
|
20
|
+
onFinish = _ref.onFinish,
|
|
21
|
+
infoRequest = _ref.infoRequest,
|
|
22
|
+
_ref$valueType = _ref.valueType,
|
|
23
|
+
valueType = _ref$valueType === void 0 ? "float" : _ref$valueType,
|
|
24
|
+
initialValues = _ref.initialValues,
|
|
25
|
+
_ref$params = _ref.params,
|
|
26
|
+
params = _ref$params === void 0 ? {} : _ref$params,
|
|
27
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
var hForm = useCurrentForm(form);
|
|
29
|
+
var newConfigData = useInitConfigData({
|
|
30
|
+
configData: configData,
|
|
31
|
+
form: hForm
|
|
32
|
+
});
|
|
33
|
+
var _useInfoReq = useInfoReq({
|
|
34
|
+
initialValues: initialValues,
|
|
35
|
+
request: request,
|
|
36
|
+
onFinish: onFinish,
|
|
37
|
+
valueType: valueType,
|
|
38
|
+
form: hForm,
|
|
39
|
+
infoRequest: infoRequest,
|
|
40
|
+
params: params
|
|
41
|
+
}),
|
|
42
|
+
subControl = _useInfoReq.subControl,
|
|
43
|
+
infoControl = _useInfoReq.infoControl;
|
|
44
|
+
var run = subControl.run,
|
|
45
|
+
loading = subControl.loading;
|
|
46
|
+
var infoRun = infoControl.run,
|
|
47
|
+
infoLoading = infoControl.loading,
|
|
48
|
+
infoErr = infoControl.error,
|
|
49
|
+
infoData = infoControl.data;
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
return function () {
|
|
52
|
+
hForm.removeDispatchListener();
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
return /*#__PURE__*/React.createElement(Index, {
|
|
56
|
+
loading: infoLoading,
|
|
57
|
+
error: infoErr,
|
|
58
|
+
data: infoData,
|
|
59
|
+
reload: infoRun
|
|
60
|
+
}, /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
61
|
+
value: {
|
|
62
|
+
loading: loading,
|
|
63
|
+
form: hForm,
|
|
64
|
+
valueType: valueType
|
|
65
|
+
}
|
|
66
|
+
}, /*#__PURE__*/React.createElement(Form, _extends({
|
|
67
|
+
form: hForm,
|
|
68
|
+
onFinish: run
|
|
69
|
+
}, props), _mapInstanceProperty(newConfigData).call(newConfigData, function (itemData, index) {
|
|
70
|
+
var itemLabelWidth = itemData.labelWidth;
|
|
71
|
+
return /*#__PURE__*/React.createElement(Item, _extends({}, itemData, {
|
|
72
|
+
key: index,
|
|
73
|
+
labelWidth: itemLabelWidth || labelWidth
|
|
74
|
+
}));
|
|
75
|
+
}), /*#__PURE__*/React.createElement(InitSet, null))));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export { HForm as default };
|
|
79
|
+
// powered by hdj
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { FormInstance, FormItemProps, FormProps } from "antd";
|
|
2
|
+
import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import type { HButtonProps, HInputProps, HSelectInputProps } from "@/components/Input/modal";
|
|
5
|
+
import type { HRadioGroupProps } from "@/components/RadioGroup";
|
|
6
|
+
import type { HSelectProps } from "@/components/Select/modal";
|
|
7
|
+
import type { ButtonProps } from "antd/es";
|
|
8
|
+
import type { HSwitchProps } from "@/components/Switch";
|
|
9
|
+
import type { HDatePickerProps, HRangePickerProps, HTimePickerProps } from "@/components/TDPicker/modal";
|
|
10
|
+
import type { TextAreaProps } from "antd/es/input";
|
|
11
|
+
import type { IUpLoadProps } from "@/components/Upload/modal";
|
|
12
|
+
import type { SelectProps } from "antd";
|
|
13
|
+
import type { RangePickerProps } from "antd/es/date-picker";
|
|
14
|
+
import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRangePickerValueMapModal } from "../modal";
|
|
15
|
+
import type { ForwardedRef } from "react";
|
|
16
|
+
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => void;
|
|
17
|
+
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps;
|
|
18
|
+
export interface HoverModal {
|
|
19
|
+
text?: string;
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
23
|
+
export type HideModal = (form: HFormInstance) => boolean;
|
|
24
|
+
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
25
|
+
export interface HItemProps extends Omit<FormItemProps, "name"> {
|
|
26
|
+
type?: string;
|
|
27
|
+
itemProps?: ItemPropsType;
|
|
28
|
+
render?: RenderFun;
|
|
29
|
+
helper?: HelperModal | string;
|
|
30
|
+
hover?: string | HoverModal;
|
|
31
|
+
labelWidth?: number;
|
|
32
|
+
hide?: boolean | HideModal;
|
|
33
|
+
placeholder?: string | string[];
|
|
34
|
+
name?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "onFinish"> {
|
|
37
|
+
configData: HItemProps[];
|
|
38
|
+
labelWidth?: number;
|
|
39
|
+
request?: (values: T, params?: any) => Promise<R>;
|
|
40
|
+
infoRequest?: PromiseFnResult;
|
|
41
|
+
valueType?: string;
|
|
42
|
+
form?: HFormInstance;
|
|
43
|
+
params?: any;
|
|
44
|
+
onFinish?: (values: T, params?: any) => void;
|
|
45
|
+
}
|
|
46
|
+
export interface HFormItemProps extends HItemProps {
|
|
47
|
+
required?: boolean;
|
|
48
|
+
value?: any;
|
|
49
|
+
onChange?: (val: any, item: any) => void;
|
|
50
|
+
}
|
|
51
|
+
export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
|
|
52
|
+
render: (form: HFormInstance) => React.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export type argsFn = (...args: any[]) => void;
|
|
55
|
+
export interface FormContextProps {
|
|
56
|
+
loading?: boolean;
|
|
57
|
+
form: HFormInstance;
|
|
58
|
+
valueType?: string;
|
|
59
|
+
}
|
|
60
|
+
interface ConfigUploadProps {
|
|
61
|
+
exFiles?: string[];
|
|
62
|
+
maxSize?: number;
|
|
63
|
+
request?: PromiseFnResult;
|
|
64
|
+
}
|
|
65
|
+
export interface IFormConfigContextProps {
|
|
66
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
67
|
+
valueCheckMap?: ValueCheckMapModal;
|
|
68
|
+
valueSwitchMap?: ValueSwitchMapModal;
|
|
69
|
+
valueRangePickerValueMap?: DateRangePickerValueMapModal;
|
|
70
|
+
dateRanges?: RangePickerProps["ranges"];
|
|
71
|
+
uploadProps?: ConfigUploadProps;
|
|
72
|
+
}
|
|
73
|
+
interface ActionModal {
|
|
74
|
+
key: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface HFormInstance extends FormInstance {
|
|
78
|
+
addFormat: (name: string, formats?: FormatItemModal) => void;
|
|
79
|
+
initValues: VoidFunction;
|
|
80
|
+
formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
|
|
81
|
+
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
82
|
+
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
83
|
+
addDispatchListener: AddDispatchListenerFn;
|
|
84
|
+
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
85
|
+
reload: PromiseFnResult;
|
|
86
|
+
}
|
|
87
|
+
export interface ConnectConfigModal {
|
|
88
|
+
format?: Record<string, addFormatItemModal>;
|
|
89
|
+
}
|
|
90
|
+
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
91
|
+
export interface FormatItemModal {
|
|
92
|
+
inputValue: ValueFormat;
|
|
93
|
+
outputValue: ValueFormat;
|
|
94
|
+
}
|
|
95
|
+
type addValueFormat = (item: HFormItemProps, value: Record<string, any>) => Record<string, any>;
|
|
96
|
+
export interface addFormatItemModal {
|
|
97
|
+
inputValue: addValueFormat;
|
|
98
|
+
outputValue: addValueFormat;
|
|
99
|
+
}
|
|
100
|
+
export interface ConnectResultProps extends HFormItemProps {
|
|
101
|
+
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
102
|
+
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
103
|
+
ref?: ForwardedRef<any>;
|
|
104
|
+
value?: any;
|
|
105
|
+
onChange?: (value: any, item?: any) => void;
|
|
106
|
+
}
|
|
107
|
+
export {};
|