@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,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const placeholderConfig: {
|
|
3
|
+
inputType: string[];
|
|
4
|
+
selectType: string[];
|
|
5
|
+
};
|
|
6
|
+
declare const _default: {
|
|
7
|
+
select: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("../Select/modal").HSelectProps) => JSX.Element;
|
|
8
|
+
inputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
9
|
+
selectInput: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
|
+
buttonInput: import("react").FC<import("../Input/modal").HButtonInputProps>;
|
|
11
|
+
checkboxGroup: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
12
|
+
checkBox: import("react").FC<import("../CheckboxGroup/modal").HCheckboxProps>;
|
|
13
|
+
radioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("../RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
14
|
+
switch: import("react").FC<import("../Switch").HSwitchProps>;
|
|
15
|
+
datePicker: ({ value, onChange, showTime, format, ...props }: import("../TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
|
+
rangePicker: {
|
|
17
|
+
Component: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
18
|
+
placeholder: ({ label }: import("./modal").HItemProps) => string[];
|
|
19
|
+
requiredErrMsg: ({ label }: import("./modal").HItemProps) => string;
|
|
20
|
+
};
|
|
21
|
+
timePicker: ({ value, format, onChange, ...props }: import("../TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
22
|
+
input: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
23
|
+
upload: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
24
|
+
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
|
+
submit: ({ text, type, form, loading, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
|
+
formConfigProvider: import("react").FC<import("./modal").IFormConfigContextProps>;
|
|
27
|
+
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var index = require('../Select/index.js');
|
|
6
|
+
var index$6 = require('../Input/index.js');
|
|
7
|
+
var InputNumber = require('../Input/InputNumber.js');
|
|
8
|
+
var SelectInput = require('../Input/SelectInput.js');
|
|
9
|
+
var ButtonInput = require('../Input/ButtonInput.js');
|
|
10
|
+
var index$1 = require('../CheckboxGroup/index.js');
|
|
11
|
+
var index$2 = require('../CheckboxGroup/CheckBox/index.js');
|
|
12
|
+
var index$3 = require('../RadioGroup/index.js');
|
|
13
|
+
var index$4 = require('../Switch/index.js');
|
|
14
|
+
var index$5 = require('../TDPicker/index.js');
|
|
15
|
+
var RangePicker = require('../TDPicker/RangePicker.js');
|
|
16
|
+
var TimePicker = require('../TDPicker/TimePicker.js');
|
|
17
|
+
var index$7 = require('../Upload/index.js');
|
|
18
|
+
var index$8 = require('../Upload/UrlUpload/index.js');
|
|
19
|
+
var index$9 = require('../Submit/index.js');
|
|
20
|
+
var FormConfigProvider = require('./Context/FormConfigProvider.js');
|
|
21
|
+
var index$a = require('../TextArea/index.js');
|
|
22
|
+
|
|
23
|
+
var placeholderConfig = {
|
|
24
|
+
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
25
|
+
selectType: ["select", "datePicker", "timePicker"]
|
|
26
|
+
};
|
|
27
|
+
var FormConfig = {
|
|
28
|
+
select: index.default,
|
|
29
|
+
inputNumber: InputNumber.default,
|
|
30
|
+
selectInput: SelectInput.default,
|
|
31
|
+
buttonInput: ButtonInput.default,
|
|
32
|
+
checkboxGroup: index$1.default,
|
|
33
|
+
checkBox: index$2.default,
|
|
34
|
+
radioGroup: index$3.default,
|
|
35
|
+
"switch": index$4.default,
|
|
36
|
+
datePicker: index$5.default,
|
|
37
|
+
rangePicker: RangePicker.default,
|
|
38
|
+
timePicker: TimePicker.default,
|
|
39
|
+
input: index$6.default,
|
|
40
|
+
upload: index$7.default,
|
|
41
|
+
urlUpload: index$8.default,
|
|
42
|
+
submit: index$9.default,
|
|
43
|
+
formConfigProvider: FormConfigProvider.default,
|
|
44
|
+
textArea: index$a.default
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.default = FormConfig;
|
|
48
|
+
exports.placeholderConfig = placeholderConfig;
|
|
49
|
+
// powered by h
|
|
@@ -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,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var ahooks = require('ahooks');
|
|
6
|
+
var useHForm = require('./useHForm.js');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
|
|
9
|
+
var useCurrentForm = function useCurrentForm(form) {
|
|
10
|
+
var selfForm = useHForm.default();
|
|
11
|
+
return form || selfForm;
|
|
12
|
+
};
|
|
13
|
+
var useInfoReq = function useInfoReq(_ref) {
|
|
14
|
+
var initialValues = _ref.initialValues,
|
|
15
|
+
infoRequest = _ref.infoRequest,
|
|
16
|
+
form = _ref.form,
|
|
17
|
+
params = _ref.params,
|
|
18
|
+
request = _ref.request,
|
|
19
|
+
onFinish = _ref.onFinish;
|
|
20
|
+
var reqData = React.useMemo(function () {
|
|
21
|
+
var saveParams = params || {};
|
|
22
|
+
return {
|
|
23
|
+
params: saveParams
|
|
24
|
+
};
|
|
25
|
+
}, [params]);
|
|
26
|
+
var subControl = ahooks.useRequest( /*#__PURE__*/function () {
|
|
27
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
28
|
+
var subVal;
|
|
29
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
33
|
+
if (!request) {
|
|
34
|
+
_context.next = 4;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
_context.next = 4;
|
|
38
|
+
return request(subVal, reqData.params);
|
|
39
|
+
case 4:
|
|
40
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(subVal, reqData.params);
|
|
41
|
+
case 5:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
}));
|
|
47
|
+
return function (_x) {
|
|
48
|
+
return _ref2.apply(this, arguments);
|
|
49
|
+
};
|
|
50
|
+
}(), {
|
|
51
|
+
manual: true
|
|
52
|
+
});
|
|
53
|
+
var infoControl = ahooks.useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
54
|
+
var reqParams,
|
|
55
|
+
setValue,
|
|
56
|
+
_args2 = arguments;
|
|
57
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
58
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
|
|
61
|
+
setValue = initialValues;
|
|
62
|
+
reqData.params = reqParams;
|
|
63
|
+
if (!(!initialValues && !infoRequest)) {
|
|
64
|
+
_context2.next = 5;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
return _context2.abrupt("return", {});
|
|
68
|
+
case 5:
|
|
69
|
+
if (!infoRequest) {
|
|
70
|
+
_context2.next = 9;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
_context2.next = 8;
|
|
74
|
+
return infoRequest(reqParams);
|
|
75
|
+
case 8:
|
|
76
|
+
setValue = _context2.sent;
|
|
77
|
+
case 9:
|
|
78
|
+
form === null || form === void 0 ? void 0 : form.setFieldsValue(setValue);
|
|
79
|
+
return _context2.abrupt("return", setValue || {});
|
|
80
|
+
case 11:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context2.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _callee2);
|
|
85
|
+
})));
|
|
86
|
+
var run = infoControl.run,
|
|
87
|
+
mutate = infoControl.mutate;
|
|
88
|
+
React.useEffect(function () {
|
|
89
|
+
if (form) {
|
|
90
|
+
form.reload = function (params) {
|
|
91
|
+
mutate(undefined);
|
|
92
|
+
return run(params);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}, []);
|
|
96
|
+
return {
|
|
97
|
+
subControl: subControl,
|
|
98
|
+
infoControl: infoControl
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.useCurrentForm = useCurrentForm;
|
|
103
|
+
exports.useInfoReq = useInfoReq;
|
|
104
|
+
// powered by h
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
6
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
7
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
8
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
9
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
10
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
11
|
+
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
12
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
14
|
+
var _Promise = require('@babel/runtime-corejs3/core-js/promise');
|
|
15
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
|
|
16
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
17
|
+
var _Reflect$deleteProperty = require('@babel/runtime-corejs3/core-js/reflect/delete-property');
|
|
18
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
|
|
19
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
20
|
+
var React = require('react');
|
|
21
|
+
var antd = require('antd');
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
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; }
|
|
25
|
+
var useHForm = (function () {
|
|
26
|
+
var _Form$useForm = antd.Form.useForm(),
|
|
27
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
28
|
+
form = _Form$useForm2[0];
|
|
29
|
+
return React.useMemo(function () {
|
|
30
|
+
var formatSourceData = {};
|
|
31
|
+
var dispatchSourceData = {};
|
|
32
|
+
var cacheValues = {};
|
|
33
|
+
var isLoading = false;
|
|
34
|
+
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
35
|
+
if (!name) {
|
|
36
|
+
return {
|
|
37
|
+
keysFn: {},
|
|
38
|
+
defaultFn: [fn]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
keysFn: _defineProperty({}, name, fn),
|
|
43
|
+
defaultFn: []
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
return _objectSpread(_objectSpread({
|
|
47
|
+
reload: function reload(params) {
|
|
48
|
+
return _Promise.resolve(params);
|
|
49
|
+
},
|
|
50
|
+
initValues: function initValues() {
|
|
51
|
+
if (cacheValues) {
|
|
52
|
+
var newValue = this.formatValues(cacheValues);
|
|
53
|
+
form.setFieldsValue(newValue);
|
|
54
|
+
}
|
|
55
|
+
isLoading = true;
|
|
56
|
+
},
|
|
57
|
+
addFormat: function addFormat(name, format) {
|
|
58
|
+
if (!format) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var inputValue = format.inputValue,
|
|
62
|
+
outputValue = format.outputValue;
|
|
63
|
+
formatSourceData[name] = {
|
|
64
|
+
inputValue: inputValue,
|
|
65
|
+
outputValue: outputValue
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
formatValues: function formatValues() {
|
|
69
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
70
|
+
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
71
|
+
var valKeys = _Object$keys(value).length;
|
|
72
|
+
if (!valKeys) {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
var newValue = _objectSpread({}, value);
|
|
76
|
+
var keys = _Object$keys(formatSourceData);
|
|
77
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
78
|
+
var _formatSourceData$key;
|
|
79
|
+
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
80
|
+
if (!format) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
var resultValue = format(value);
|
|
84
|
+
_Reflect$deleteProperty(newValue, key);
|
|
85
|
+
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
86
|
+
});
|
|
87
|
+
return newValue;
|
|
88
|
+
},
|
|
89
|
+
dispatch: function dispatch(action) {
|
|
90
|
+
var _context2, _context3, _context4;
|
|
91
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
92
|
+
args[_key - 1] = arguments[_key];
|
|
93
|
+
}
|
|
94
|
+
var key = action.key,
|
|
95
|
+
name = action.name;
|
|
96
|
+
var items = dispatchSourceData[key];
|
|
97
|
+
if (!items) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
var keysFn = items.keysFn,
|
|
101
|
+
defaultFn = items.defaultFn;
|
|
102
|
+
if (name) {
|
|
103
|
+
var _keysFn$name, _context;
|
|
104
|
+
return (_keysFn$name = keysFn[name]) === null || _keysFn$name === void 0 ? void 0 : _keysFn$name.call.apply(_keysFn$name, _concatInstanceProperty(_context = [keysFn]).call(_context, args));
|
|
105
|
+
}
|
|
106
|
+
var fnArrays = _mapInstanceProperty(_context2 = _Object$keys(keysFn)).call(_context2, function (itemKey) {
|
|
107
|
+
return keysFn[itemKey];
|
|
108
|
+
});
|
|
109
|
+
_forEachInstanceProperty(_context3 = _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(fnArrays), _toConsumableArray(defaultFn))).call(_context3, function (fn) {
|
|
110
|
+
fn.apply(void 0, args);
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
addDispatchListener: function addDispatchListener(action, fn) {
|
|
114
|
+
var key = action.key,
|
|
115
|
+
name = action.name;
|
|
116
|
+
var items = dispatchSourceData[key];
|
|
117
|
+
if (!items) {
|
|
118
|
+
dispatchSourceData[key] = norAddItemDispatch(name, fn);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var keysFn = items.keysFn,
|
|
122
|
+
defaultFn = items.defaultFn;
|
|
123
|
+
if (name) {
|
|
124
|
+
keysFn[name] = fn;
|
|
125
|
+
} else {
|
|
126
|
+
defaultFn.push(fn);
|
|
127
|
+
}
|
|
128
|
+
dispatchSourceData[key] = {
|
|
129
|
+
keysFn: keysFn,
|
|
130
|
+
defaultFn: defaultFn
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
removeDispatchListener: function removeDispatchListener(action) {
|
|
134
|
+
if (!action) {
|
|
135
|
+
dispatchSourceData = {};
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
var key = action.key,
|
|
139
|
+
name = action.name;
|
|
140
|
+
var items = dispatchSourceData[key];
|
|
141
|
+
if (!items) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (name) {
|
|
145
|
+
var keysFn = items.keysFn;
|
|
146
|
+
_Reflect$deleteProperty(keysFn, name);
|
|
147
|
+
items.keysFn = keysFn;
|
|
148
|
+
dispatchSourceData[key] = items;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
152
|
+
},
|
|
153
|
+
outputValues: function outputValues(value) {
|
|
154
|
+
return this.formatValues(value, "outputValue");
|
|
155
|
+
}
|
|
156
|
+
}, form), {}, {
|
|
157
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
158
|
+
if (!isLoading) {
|
|
159
|
+
cacheValues = values;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var newValue = this.formatValues(values);
|
|
163
|
+
form.setFieldsValue(newValue);
|
|
164
|
+
},
|
|
165
|
+
validateFields: function validateFields(nameList) {
|
|
166
|
+
var _this = this;
|
|
167
|
+
return new _Promise(function (resolve) {
|
|
168
|
+
form.validateFields(nameList).then(function (value) {
|
|
169
|
+
var result = _this.formatValues(value, "outputValue");
|
|
170
|
+
return resolve(result);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}, []);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
exports.default = useHForm;
|
|
179
|
+
// powered by h
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
|
|
7
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
8
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
9
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
10
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
11
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
12
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
13
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
14
|
+
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
15
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
16
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
17
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
18
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/index-of');
|
|
19
|
+
var config = require('../config.js');
|
|
20
|
+
|
|
21
|
+
var _excluded = ["render", "type", "itemProps"],
|
|
22
|
+
_excluded2 = ["render"];
|
|
23
|
+
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; }
|
|
24
|
+
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; }
|
|
25
|
+
var mathRequired = function mathRequired(configItem, form) {
|
|
26
|
+
var required = configItem.required,
|
|
27
|
+
placeholder = configItem.placeholder,
|
|
28
|
+
rules = configItem.rules,
|
|
29
|
+
_configItem$type = configItem.type,
|
|
30
|
+
type = _configItem$type === void 0 ? "input" : _configItem$type;
|
|
31
|
+
var resultRequired = false;
|
|
32
|
+
var dom = config.default[type];
|
|
33
|
+
var resultRules = rules === null || rules === void 0 ? void 0 : _mapInstanceProperty(rules).call(rules, function (item) {
|
|
34
|
+
var eachItem = item;
|
|
35
|
+
if (typeof item === "function") {
|
|
36
|
+
eachItem = item(form);
|
|
37
|
+
}
|
|
38
|
+
var _eachItem = eachItem,
|
|
39
|
+
itemRequired = _eachItem.required,
|
|
40
|
+
message = _eachItem.message;
|
|
41
|
+
if (itemRequired) {
|
|
42
|
+
resultRequired = itemRequired;
|
|
43
|
+
}
|
|
44
|
+
if (itemRequired && !message) {
|
|
45
|
+
return _objectSpread(_objectSpread({}, eachItem), {}, {
|
|
46
|
+
required: itemRequired,
|
|
47
|
+
message: !!(dom !== null && dom !== void 0 && dom.requiredErrMsg) ? dom.requiredErrMsg(configItem) : placeholder
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return eachItem;
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
required: typeof required === "boolean" ? required : resultRequired,
|
|
54
|
+
rules: resultRules
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
58
|
+
var _context;
|
|
59
|
+
var label = props.label,
|
|
60
|
+
placeholder = props.placeholder,
|
|
61
|
+
_props$type = props.type,
|
|
62
|
+
type = _props$type === void 0 ? "input" : _props$type;
|
|
63
|
+
var dom = config.default[type];
|
|
64
|
+
if (placeholder) {
|
|
65
|
+
return placeholder;
|
|
66
|
+
}
|
|
67
|
+
if (dom !== null && dom !== void 0 && dom.placeholder) {
|
|
68
|
+
return dom.placeholder(props);
|
|
69
|
+
}
|
|
70
|
+
if (_indexOfInstanceProperty(_context = config.placeholderConfig.inputType).call(_context, type) !== -1) {
|
|
71
|
+
return "\u8BF7\u8F93\u5165".concat(label);
|
|
72
|
+
}
|
|
73
|
+
return "\u8BF7\u9009\u62E9".concat(label);
|
|
74
|
+
};
|
|
75
|
+
var defaultRenderMaker = function defaultRenderMaker(props) {
|
|
76
|
+
var render = props.render,
|
|
77
|
+
_props$type2 = props.type,
|
|
78
|
+
type = _props$type2 === void 0 ? "input" : _props$type2,
|
|
79
|
+
_props$itemProps = props.itemProps,
|
|
80
|
+
itemProps = _props$itemProps === void 0 ? {} : _props$itemProps,
|
|
81
|
+
componentProps = _objectWithoutProperties(props, _excluded);
|
|
82
|
+
var dom = config.default[type];
|
|
83
|
+
return function (form) {
|
|
84
|
+
var Component = !!(dom !== null && dom !== void 0 && dom.Component) ? dom.Component : dom;
|
|
85
|
+
var node = Component && /*#__PURE__*/React.createElement(Component, _extends({}, componentProps, itemProps, {
|
|
86
|
+
form: form
|
|
87
|
+
}));
|
|
88
|
+
if (render) {
|
|
89
|
+
return render(props, node, form);
|
|
90
|
+
}
|
|
91
|
+
return node;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(props) {
|
|
95
|
+
var placeholder = matchDefaultPlaceholder(props);
|
|
96
|
+
return _objectSpread(_objectSpread({}, props), {}, {
|
|
97
|
+
placeholder: placeholder,
|
|
98
|
+
render: defaultRenderMaker(_objectSpread(_objectSpread({}, props), {}, {
|
|
99
|
+
placeholder: placeholder
|
|
100
|
+
}))
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
var itemControl = function itemControl(item, form) {
|
|
104
|
+
var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
|
|
105
|
+
render = _defaultPlaceholderPr.render,
|
|
106
|
+
defaultProps = _objectWithoutProperties(_defaultPlaceholderPr, _excluded2);
|
|
107
|
+
var _mathRequired = mathRequired(defaultProps, form),
|
|
108
|
+
rules = _mathRequired.rules,
|
|
109
|
+
required = _mathRequired.required;
|
|
110
|
+
return _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
111
|
+
required: required,
|
|
112
|
+
rules: rules,
|
|
113
|
+
render: render
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
var useInitConfigData = (function (_ref) {
|
|
117
|
+
var configData = _ref.configData,
|
|
118
|
+
form = _ref.form;
|
|
119
|
+
return React.useMemo(function () {
|
|
120
|
+
return _mapInstanceProperty(configData).call(configData, function (item) {
|
|
121
|
+
return itemControl(item, form);
|
|
122
|
+
});
|
|
123
|
+
}, [configData]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
exports.default = useInitConfigData;
|
|
127
|
+
// powered by h
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
7
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
9
|
+
var antd = require('antd');
|
|
10
|
+
var index$3 = require('./FormItem/index.js');
|
|
11
|
+
var index = require('./hooks/index.js');
|
|
12
|
+
var index$2 = require('./Context/index.js');
|
|
13
|
+
var index$1 = require('../PageHandler/index.js');
|
|
14
|
+
var useInitConfigData = require('./hooks/useInitConfigData.js');
|
|
15
|
+
var InitSet = require('./InitSet.js');
|
|
16
|
+
|
|
17
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params"];
|
|
18
|
+
var HForm = (function (_ref) {
|
|
19
|
+
var configData = _ref.configData,
|
|
20
|
+
labelWidth = _ref.labelWidth,
|
|
21
|
+
form = _ref.form,
|
|
22
|
+
request = _ref.request,
|
|
23
|
+
onFinish = _ref.onFinish,
|
|
24
|
+
infoRequest = _ref.infoRequest,
|
|
25
|
+
_ref$valueType = _ref.valueType,
|
|
26
|
+
valueType = _ref$valueType === void 0 ? "float" : _ref$valueType,
|
|
27
|
+
initialValues = _ref.initialValues,
|
|
28
|
+
_ref$params = _ref.params,
|
|
29
|
+
params = _ref$params === void 0 ? {} : _ref$params,
|
|
30
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
+
var hForm = index.useCurrentForm(form);
|
|
32
|
+
var newConfigData = useInitConfigData.default({
|
|
33
|
+
configData: configData,
|
|
34
|
+
form: hForm
|
|
35
|
+
});
|
|
36
|
+
var _useInfoReq = index.useInfoReq({
|
|
37
|
+
initialValues: initialValues,
|
|
38
|
+
request: request,
|
|
39
|
+
onFinish: onFinish,
|
|
40
|
+
valueType: valueType,
|
|
41
|
+
form: hForm,
|
|
42
|
+
infoRequest: infoRequest,
|
|
43
|
+
params: params
|
|
44
|
+
}),
|
|
45
|
+
subControl = _useInfoReq.subControl,
|
|
46
|
+
infoControl = _useInfoReq.infoControl;
|
|
47
|
+
var run = subControl.run,
|
|
48
|
+
loading = subControl.loading;
|
|
49
|
+
var infoRun = infoControl.run,
|
|
50
|
+
infoLoading = infoControl.loading,
|
|
51
|
+
infoErr = infoControl.error,
|
|
52
|
+
infoData = infoControl.data;
|
|
53
|
+
React.useEffect(function () {
|
|
54
|
+
return function () {
|
|
55
|
+
hForm.removeDispatchListener();
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
return /*#__PURE__*/React.createElement(index$1.default, {
|
|
59
|
+
loading: infoLoading,
|
|
60
|
+
error: infoErr,
|
|
61
|
+
data: infoData,
|
|
62
|
+
reload: infoRun
|
|
63
|
+
}, /*#__PURE__*/React.createElement(index$2.FormContext.Provider, {
|
|
64
|
+
value: {
|
|
65
|
+
loading: loading,
|
|
66
|
+
form: hForm,
|
|
67
|
+
valueType: valueType
|
|
68
|
+
}
|
|
69
|
+
}, /*#__PURE__*/React.createElement(antd.Form, _extends({
|
|
70
|
+
form: hForm,
|
|
71
|
+
onFinish: run
|
|
72
|
+
}, props), _mapInstanceProperty(newConfigData).call(newConfigData, function (itemData, index) {
|
|
73
|
+
var itemLabelWidth = itemData.labelWidth;
|
|
74
|
+
return /*#__PURE__*/React.createElement(index$3.default, _extends({}, itemData, {
|
|
75
|
+
key: index,
|
|
76
|
+
labelWidth: itemLabelWidth || labelWidth
|
|
77
|
+
}));
|
|
78
|
+
}), /*#__PURE__*/React.createElement(InitSet.default, null))));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
exports.default = HForm;
|
|
82
|
+
// powered by h
|