@hw-component/form 0.0.4 → 0.0.5-beta-v1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/CheckboxGroup/CheckBox/index.d.ts +2 -5
- package/es/CheckboxGroup/CheckBox/index.js +15 -9
- 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 +70 -26
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/DialogForm/DrawerForm/Footer.d.ts +7 -0
- package/es/DialogForm/DrawerForm/Footer.js +27 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +3 -0
- package/es/DialogForm/DrawerForm/Title.js +21 -0
- package/es/DialogForm/DrawerForm/index.d.ts +3 -0
- package/es/DialogForm/DrawerForm/index.js +138 -0
- package/es/DialogForm/ModalForm.d.ts +3 -0
- package/es/DialogForm/ModalForm.js +119 -0
- package/es/DialogForm/hooks.d.ts +16 -0
- package/es/DialogForm/hooks.js +150 -0
- package/es/DialogForm/modal.d.ts +33 -0
- package/es/Form/Context/FormConfigProvider.d.ts +5 -0
- package/es/Form/Context/FormConfigProvider.js +49 -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 +93 -0
- package/es/Form/FormItem/Helper.d.ts +7 -0
- package/es/Form/FormItem/Helper.js +26 -0
- package/es/Form/FormItem/RegularFormItem.d.ts +3 -0
- package/es/Form/FormItem/RegularFormItem.js +25 -0
- package/es/Form/FormItem/UpFormItem.d.ts +3 -0
- package/es/Form/FormItem/UpFormItem.js +43 -0
- package/es/Form/FormItem/hooks.d.ts +8 -0
- package/es/Form/FormItem/hooks.js +38 -0
- package/es/Form/FormItem/index.d.ts +3 -0
- package/es/Form/FormItem/index.js +22 -0
- package/es/Form/HFormConnect.d.ts +5 -0
- package/es/Form/HFormConnect.js +68 -0
- package/es/Form/InitSet.d.ts +2 -0
- package/es/Form/InitSet.js +16 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +49 -0
- package/es/Form/config.d.ts +29 -0
- package/es/Form/config.js +45 -0
- package/es/Form/hooks/index.d.ts +16 -0
- package/es/Form/hooks/index.js +158 -0
- package/es/Form/hooks/useDefaultRender.d.ts +3 -0
- package/es/Form/hooks/useDefaultRender.js +49 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +194 -0
- package/es/Form/hooks/useInitConfigData.d.ts +8 -0
- package/es/Form/hooks/useInitConfigData.js +172 -0
- package/es/Form/index.d.ts +3 -0
- package/es/Form/index.js +103 -0
- package/es/Form/modal.d.ts +123 -0
- package/es/Input/ButtonInput.d.ts +2 -2
- package/es/Input/ButtonInput.js +34 -19
- package/es/Input/ColorInput/Picker.d.ts +3 -0
- package/es/Input/ColorInput/Picker.js +22 -0
- package/es/Input/ColorInput/data.d.ts +1 -0
- package/es/Input/ColorInput/data.js +5 -0
- package/es/Input/ColorInput/index.d.ts +3 -0
- package/es/Input/ColorInput/index.js +87 -0
- package/es/Input/InputNumber.d.ts +0 -1
- package/es/Input/InputNumber.js +18 -8
- package/es/Input/SelectInput.d.ts +2 -1
- package/es/Input/SelectInput.js +43 -14
- package/es/Input/defaultConfig.js +2 -2
- package/es/Input/index.d.ts +0 -1
- package/es/Input/index.js +17 -6
- package/es/Input/modal.d.ts +30 -0
- package/es/PageHandler/ErrorComponent.d.ts +3 -0
- package/es/PageHandler/ErrorComponent.js +38 -0
- package/es/PageHandler/LoadingComponent.d.ts +2 -0
- package/es/PageHandler/LoadingComponent.js +19 -0
- package/es/PageHandler/index.d.ts +4 -0
- package/es/PageHandler/index.js +26 -0
- package/es/PageHandler/modal.d.ts +6 -0
- package/es/RadioGroup/index.d.ts +2 -3
- package/es/RadioGroup/index.js +25 -10
- package/es/Select/components/AllSelect.d.ts +3 -4
- package/es/Select/components/AllSelect.js +36 -18
- package/es/Select/components/CheckBoxOption.js +8 -6
- package/es/Select/components/DropdownComponent.js +18 -13
- package/es/Select/components/NoFindItem.d.ts +0 -1
- package/es/Select/components/NoFindItem.js +7 -6
- package/es/Select/components/NotFoundContent.d.ts +0 -1
- package/es/Select/components/NotFoundContent.js +25 -22
- package/es/Select/defaultConfig.d.ts +0 -1
- package/es/Select/defaultConfig.js +5 -5
- package/es/Select/hooks/changeHooks.js +7 -4
- package/es/Select/hooks/norHooks.d.ts +10 -3
- package/es/Select/hooks/norHooks.js +53 -17
- package/es/Select/index.d.ts +2 -3
- package/es/Select/index.js +65 -36
- package/es/Select/modal.d.ts +9 -1
- package/es/Select/utils.js +2 -2
- package/es/Submit/index.d.ts +9 -0
- package/es/Submit/index.js +55 -0
- package/es/Switch/index.d.ts +4 -3
- package/es/Switch/index.js +37 -18
- package/es/TDPicker/RangePicker.d.ts +8 -0
- package/es/TDPicker/RangePicker.js +126 -0
- package/es/TDPicker/TimePicker.d.ts +3 -0
- package/es/TDPicker/TimePicker.js +45 -0
- package/es/TDPicker/hooks.d.ts +33 -0
- package/es/TDPicker/hooks.js +132 -0
- package/es/TDPicker/index.d.ts +4 -0
- package/es/TDPicker/index.js +48 -0
- package/es/TDPicker/modal.d.ts +35 -0
- package/es/TextArea/index.d.ts +3 -0
- package/es/TextArea/index.js +31 -0
- package/es/Upload/Btn.d.ts +3 -0
- package/es/Upload/Btn.js +36 -0
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +9 -0
- package/es/Upload/MediaTypeEle/TypeEle.js +42 -0
- package/es/Upload/MediaTypeEle/index.d.ts +3 -0
- package/es/Upload/MediaTypeEle/index.js +37 -0
- package/es/Upload/Preview/index.d.ts +5 -0
- package/es/Upload/Preview/index.js +22 -0
- package/es/Upload/UrlUpload/index.d.ts +3 -0
- package/es/Upload/UrlUpload/index.js +132 -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 +144 -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 +57 -10
- package/{lib/hooks/useChangeOptions.d.ts → es/hooks/index.d.ts} +3 -0
- package/es/hooks/index.js +75 -0
- package/es/index.css +42 -1
- package/es/index.d.ts +26 -11
- package/es/index.js +33 -13
- package/es/modal.d.ts +16 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +2 -5
- package/lib/CheckboxGroup/CheckBox/index.js +12 -6
- 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 +68 -24
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/DialogForm/DrawerForm/Footer.d.ts +7 -0
- package/lib/DialogForm/DrawerForm/Footer.js +30 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +3 -0
- package/lib/DialogForm/DrawerForm/Title.js +24 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +3 -0
- package/lib/DialogForm/DrawerForm/index.js +141 -0
- package/lib/DialogForm/ModalForm.d.ts +3 -0
- package/lib/DialogForm/ModalForm.js +122 -0
- package/lib/DialogForm/hooks.d.ts +16 -0
- package/lib/DialogForm/hooks.js +154 -0
- package/lib/DialogForm/modal.d.ts +33 -0
- package/lib/Form/Context/FormConfigProvider.d.ts +5 -0
- package/lib/Form/Context/FormConfigProvider.js +53 -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 +96 -0
- package/lib/Form/FormItem/Helper.d.ts +7 -0
- package/lib/Form/FormItem/Helper.js +29 -0
- package/lib/Form/FormItem/RegularFormItem.d.ts +3 -0
- package/lib/Form/FormItem/RegularFormItem.js +28 -0
- package/lib/Form/FormItem/UpFormItem.d.ts +3 -0
- package/lib/Form/FormItem/UpFormItem.js +46 -0
- package/lib/Form/FormItem/hooks.d.ts +8 -0
- package/lib/Form/FormItem/hooks.js +41 -0
- package/lib/Form/FormItem/index.d.ts +3 -0
- package/lib/Form/FormItem/index.js +25 -0
- package/lib/Form/HFormConnect.d.ts +5 -0
- package/lib/Form/HFormConnect.js +71 -0
- package/lib/Form/InitSet.d.ts +2 -0
- package/lib/Form/InitSet.js +19 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +52 -0
- package/lib/Form/config.d.ts +29 -0
- package/lib/Form/config.js +49 -0
- package/lib/Form/hooks/index.d.ts +16 -0
- package/lib/Form/hooks/index.js +162 -0
- package/lib/Form/hooks/useDefaultRender.d.ts +3 -0
- package/lib/Form/hooks/useDefaultRender.js +50 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +197 -0
- package/lib/Form/hooks/useInitConfigData.d.ts +8 -0
- package/lib/Form/hooks/useInitConfigData.js +175 -0
- package/lib/Form/index.d.ts +3 -0
- package/lib/Form/index.js +106 -0
- package/lib/Form/modal.d.ts +123 -0
- package/lib/Input/ButtonInput.d.ts +2 -2
- package/lib/Input/ButtonInput.js +32 -17
- package/lib/Input/ColorInput/Picker.d.ts +3 -0
- package/lib/Input/ColorInput/Picker.js +25 -0
- package/lib/Input/ColorInput/data.d.ts +1 -0
- package/lib/Input/ColorInput/data.js +6 -0
- package/lib/Input/ColorInput/index.d.ts +3 -0
- package/lib/Input/ColorInput/index.js +90 -0
- package/lib/Input/InputNumber.d.ts +0 -1
- package/lib/Input/InputNumber.js +15 -5
- package/lib/Input/SelectInput.d.ts +2 -1
- package/lib/Input/SelectInput.js +42 -12
- package/lib/Input/index.d.ts +0 -1
- package/lib/Input/index.js +15 -4
- package/lib/Input/modal.d.ts +30 -0
- package/lib/PageHandler/ErrorComponent.d.ts +3 -0
- package/lib/PageHandler/ErrorComponent.js +41 -0
- package/lib/PageHandler/LoadingComponent.d.ts +2 -0
- package/lib/PageHandler/LoadingComponent.js +22 -0
- package/lib/PageHandler/index.d.ts +4 -0
- package/lib/PageHandler/index.js +29 -0
- package/lib/PageHandler/modal.d.ts +6 -0
- package/lib/RadioGroup/index.d.ts +2 -3
- package/lib/RadioGroup/index.js +23 -8
- package/lib/Select/components/AllSelect.d.ts +3 -4
- package/lib/Select/components/AllSelect.js +34 -16
- package/lib/Select/components/CheckBoxOption.js +6 -4
- package/lib/Select/components/DropdownComponent.js +16 -11
- package/lib/Select/components/NoFindItem.d.ts +0 -1
- package/lib/Select/components/NoFindItem.js +5 -4
- package/lib/Select/components/NotFoundContent.d.ts +0 -1
- package/lib/Select/components/NotFoundContent.js +23 -20
- package/lib/Select/defaultConfig.d.ts +0 -1
- package/lib/Select/defaultConfig.js +3 -3
- package/lib/Select/hooks/changeHooks.js +5 -2
- package/lib/Select/hooks/norHooks.d.ts +10 -3
- package/lib/Select/hooks/norHooks.js +50 -14
- package/lib/Select/index.d.ts +2 -3
- package/lib/Select/index.js +62 -33
- package/lib/Select/modal.d.ts +9 -1
- package/lib/Submit/index.d.ts +9 -0
- package/lib/Submit/index.js +58 -0
- package/lib/Switch/index.d.ts +4 -3
- package/lib/Switch/index.js +34 -15
- package/lib/TDPicker/RangePicker.d.ts +8 -0
- package/lib/TDPicker/RangePicker.js +129 -0
- package/lib/TDPicker/TimePicker.d.ts +3 -0
- package/lib/TDPicker/TimePicker.js +48 -0
- package/lib/TDPicker/hooks.d.ts +33 -0
- package/lib/TDPicker/hooks.js +139 -0
- package/lib/TDPicker/index.d.ts +4 -0
- package/lib/TDPicker/index.js +51 -0
- package/lib/TDPicker/modal.d.ts +35 -0
- package/lib/TextArea/index.d.ts +3 -0
- package/lib/TextArea/index.js +34 -0
- package/lib/Upload/Btn.d.ts +3 -0
- package/lib/Upload/Btn.js +39 -0
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +9 -0
- package/lib/Upload/MediaTypeEle/TypeEle.js +45 -0
- package/lib/Upload/MediaTypeEle/index.d.ts +3 -0
- package/lib/Upload/MediaTypeEle/index.js +40 -0
- package/lib/Upload/Preview/index.d.ts +5 -0
- package/lib/Upload/Preview/index.js +25 -0
- package/lib/Upload/UrlUpload/index.d.ts +3 -0
- package/lib/Upload/UrlUpload/index.js +135 -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 +147 -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 +55 -8
- package/{es/hooks/useChangeOptions.d.ts → lib/hooks/index.d.ts} +3 -0
- package/lib/hooks/index.js +78 -0
- package/lib/index.css +42 -1
- package/lib/index.d.ts +26 -11
- package/lib/index.js +52 -23
- package/lib/modal.d.ts +16 -0
- package/package.json +7 -4
- package/scripts/rollup.config.js +2 -4
- package/scripts/webpack.config.js +5 -8
- 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 +20 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +95 -0
- package/src/components/DialogForm/ModalForm.tsx +77 -0
- package/src/components/DialogForm/hooks.ts +109 -0
- package/src/components/DialogForm/modal.ts +36 -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 +76 -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 +40 -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 +43 -0
- package/src/components/Form/hooks/index.ts +111 -0
- package/src/components/Form/hooks/useDefaultRender.tsx +42 -0
- package/src/components/Form/hooks/useHForm.ts +164 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +194 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +85 -0
- package/src/components/Form/modal.ts +179 -0
- package/src/components/Input/ButtonInput.tsx +11 -5
- package/src/components/Input/ColorInput/Picker.tsx +18 -0
- package/src/components/Input/ColorInput/data.ts +102 -0
- package/src/components/Input/ColorInput/index.less +10 -0
- package/src/components/Input/ColorInput/index.tsx +48 -0
- package/src/components/Input/SelectInput.tsx +33 -3
- package/src/components/Input/modal.ts +36 -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 -17
- 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 +6 -2
- package/src/components/Select/hooks/norHooks.ts +33 -6
- package/src/components/Select/index.less +20 -4
- package/src/components/Select/index.tsx +25 -11
- package/src/components/Select/modal.ts +17 -8
- package/src/components/Submit/index.tsx +46 -0
- package/src/components/Switch/index.tsx +14 -9
- package/src/components/TDPicker/RangePicker.tsx +109 -0
- package/src/components/TDPicker/TimePicker.tsx +25 -0
- package/src/components/TDPicker/hooks.ts +150 -0
- package/src/components/TDPicker/index.tsx +28 -0
- package/src/components/TDPicker/modal.ts +46 -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 +35 -8
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +30 -11
- package/src/components/modal.ts +20 -0
- package/src/components/styles/index.less +3 -0
- package/src/components/styles/local.less +1 -1
- 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 +203 -0
- package/src/pages/Input/index.tsx +2 -0
- package/src/pages/ModalForm/index.tsx +147 -0
- package/src/pages/Select/index.tsx +6 -3
- package/src/pages/Switch/index.tsx +1 -1
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +24 -0
- package/tsconfig.json +1 -1
- package/es/DatePicker/RangePicker.d.ts +0 -4
- package/es/DatePicker/RangePicker.js +0 -23
- package/es/DatePicker/index.d.ts +0 -4
- package/es/DatePicker/index.js +0 -39
- package/es/TimePicker/index.d.ts +0 -2
- package/es/hooks/useChangeOptions.js +0 -25
- package/es/hooks/useClassName.d.ts +0 -1
- package/es/hooks/useClassName.js +0 -15
- package/lib/DatePicker/RangePicker.d.ts +0 -4
- package/lib/DatePicker/RangePicker.js +0 -26
- package/lib/DatePicker/index.d.ts +0 -4
- package/lib/DatePicker/index.js +0 -42
- package/lib/TimePicker/index.d.ts +0 -2
- package/lib/hooks/useChangeOptions.js +0 -26
- package/lib/hooks/useClassName.d.ts +0 -1
- package/lib/hooks/useClassName.js +0 -16
- package/src/components/DatePicker/RangePicker.tsx +0 -19
- package/src/components/DatePicker/index.tsx +0 -38
- package/src/components/DatePicker/modal.d.ts +0 -17
- 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
- package/src/components/hooks/useClassName.ts +0 -9
package/es/Form/Label.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { QuestionCircleOutlined } from '@ant-design/icons';
|
|
4
|
+
import { Tooltip } from 'antd';
|
|
5
|
+
import { useClassName } from '../hooks/index.js';
|
|
6
|
+
|
|
7
|
+
var useHover = function useHover(_ref) {
|
|
8
|
+
var hover = _ref.hover;
|
|
9
|
+
if (!hover || typeof hover === "string") {
|
|
10
|
+
return {
|
|
11
|
+
text: hover,
|
|
12
|
+
icon: jsx(QuestionCircleOutlined, {})
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return hover;
|
|
16
|
+
};
|
|
17
|
+
var Index = function Index(_ref2) {
|
|
18
|
+
var labelWidth = _ref2.labelWidth,
|
|
19
|
+
children = _ref2.children,
|
|
20
|
+
colon = _ref2.colon,
|
|
21
|
+
required = _ref2.required,
|
|
22
|
+
hover = _ref2.hover;
|
|
23
|
+
var _useHover = useHover({
|
|
24
|
+
hover: hover
|
|
25
|
+
}),
|
|
26
|
+
text = _useHover.text,
|
|
27
|
+
icon = _useHover.icon;
|
|
28
|
+
var array = [colon ? "hw-form-item-colon" : "", required ? "hw-form-item-required" : ""];
|
|
29
|
+
var className = useClassName(array);
|
|
30
|
+
return jsxs("div", {
|
|
31
|
+
style: {
|
|
32
|
+
width: labelWidth
|
|
33
|
+
},
|
|
34
|
+
className: className,
|
|
35
|
+
children: [children, text && jsx("span", {
|
|
36
|
+
style: {
|
|
37
|
+
marginLeft: 4
|
|
38
|
+
},
|
|
39
|
+
children: jsx(Tooltip, {
|
|
40
|
+
placement: "top",
|
|
41
|
+
title: text,
|
|
42
|
+
children: icon
|
|
43
|
+
})
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { Index as default };
|
|
49
|
+
// powered by hdj
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const placeholderConfig: {
|
|
3
|
+
inputType: string[];
|
|
4
|
+
selectType: string[];
|
|
5
|
+
};
|
|
6
|
+
declare const componentConfig: {
|
|
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: import("react").FC<import("../TDPicker/modal").HDatePickerProps>;
|
|
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("../Input/modal").HInputProps<any>) => 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, position, reset, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
|
+
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
27
|
+
colorInput: ({ value, onChange, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
28
|
+
};
|
|
29
|
+
export default componentConfig;
|
|
@@ -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 Index$3 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$4 from '../Upload/UrlUpload/index.js';
|
|
16
|
+
import HSubmit from '../Submit/index.js';
|
|
17
|
+
import TextArea from '../TextArea/index.js';
|
|
18
|
+
import ColorInput from '../Input/ColorInput/index.js';
|
|
19
|
+
|
|
20
|
+
var placeholderConfig = {
|
|
21
|
+
inputType: ["input", "inputNumber", "selectInput", "buttonInput"],
|
|
22
|
+
selectType: ["select", "datePicker", "timePicker", "colorInput"]
|
|
23
|
+
};
|
|
24
|
+
var componentConfig = {
|
|
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: Index$3,
|
|
34
|
+
rangePicker: HRangePicker,
|
|
35
|
+
timePicker: HTimePicker,
|
|
36
|
+
input: HInput,
|
|
37
|
+
upload: HUpload,
|
|
38
|
+
urlUpload: Index$4,
|
|
39
|
+
submit: HSubmit,
|
|
40
|
+
textArea: TextArea,
|
|
41
|
+
colorInput: ColorInput
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { componentConfig as default, placeholderConfig };
|
|
45
|
+
// powered by hdj
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HFormProps, HFormInstance } from "../modal";
|
|
2
|
+
import type { DispatchModal } from "../modal";
|
|
3
|
+
interface UseValuesChangeModal {
|
|
4
|
+
onValuesChange: HFormProps["onValuesChange"];
|
|
5
|
+
dispatch: DispatchModal;
|
|
6
|
+
form: HFormInstance;
|
|
7
|
+
}
|
|
8
|
+
export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
9
|
+
type ParamsModal = Omit<HFormProps, "configData">;
|
|
10
|
+
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
|
|
11
|
+
subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
12
|
+
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<import("rc-field-form/lib/interface").Store, [reqParams?: any]>;
|
|
13
|
+
};
|
|
14
|
+
export declare const useDefaultComponents: () => any;
|
|
15
|
+
export declare const useValuesChange: ({ onValuesChange, dispatch, form, }: UseValuesChangeModal) => (changedValues: any, values: any) => void;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
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 _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
9
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
10
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
11
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
12
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
13
|
+
import { useRequest } from 'ahooks';
|
|
14
|
+
import useHForm from './useHForm.js';
|
|
15
|
+
import { useMemo, useEffect } from 'react';
|
|
16
|
+
import componentConfig from '../config.js';
|
|
17
|
+
import { useFormConfigContext } from '../Context/FormConfigProvider.js';
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
var useCurrentForm = function useCurrentForm(form) {
|
|
22
|
+
var selfForm = useHForm();
|
|
23
|
+
return form || selfForm;
|
|
24
|
+
};
|
|
25
|
+
var useInfoReq = function useInfoReq(_ref) {
|
|
26
|
+
var initialValues = _ref.initialValues,
|
|
27
|
+
infoRequest = _ref.infoRequest,
|
|
28
|
+
form = _ref.form,
|
|
29
|
+
params = _ref.params,
|
|
30
|
+
request = _ref.request,
|
|
31
|
+
onFinish = _ref.onFinish;
|
|
32
|
+
var reqData = useMemo(function () {
|
|
33
|
+
var saveParams = params || {};
|
|
34
|
+
return {
|
|
35
|
+
params: saveParams
|
|
36
|
+
};
|
|
37
|
+
}, [params]);
|
|
38
|
+
var subControl = useRequest( /*#__PURE__*/function () {
|
|
39
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
40
|
+
var subVal;
|
|
41
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
|
+
while (1) switch (_context.prev = _context.next) {
|
|
43
|
+
case 0:
|
|
44
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
45
|
+
if (!request) {
|
|
46
|
+
_context.next = 4;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
_context.next = 4;
|
|
50
|
+
return request(subVal, reqData.params);
|
|
51
|
+
case 4:
|
|
52
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(subVal, reqData.params);
|
|
53
|
+
case 5:
|
|
54
|
+
case "end":
|
|
55
|
+
return _context.stop();
|
|
56
|
+
}
|
|
57
|
+
}, _callee);
|
|
58
|
+
}));
|
|
59
|
+
return function (_x) {
|
|
60
|
+
return _ref2.apply(this, arguments);
|
|
61
|
+
};
|
|
62
|
+
}(), {
|
|
63
|
+
manual: true
|
|
64
|
+
});
|
|
65
|
+
var infoControl = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
66
|
+
var reqParams,
|
|
67
|
+
setValue,
|
|
68
|
+
_args2 = arguments;
|
|
69
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
70
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
|
|
73
|
+
setValue = initialValues;
|
|
74
|
+
reqData.params = reqParams;
|
|
75
|
+
if (!(!initialValues && !infoRequest)) {
|
|
76
|
+
_context2.next = 5;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
return _context2.abrupt("return", {});
|
|
80
|
+
case 5:
|
|
81
|
+
if (!infoRequest) {
|
|
82
|
+
_context2.next = 9;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
_context2.next = 8;
|
|
86
|
+
return infoRequest(reqParams);
|
|
87
|
+
case 8:
|
|
88
|
+
setValue = _context2.sent;
|
|
89
|
+
case 9:
|
|
90
|
+
form === null || form === void 0 ? void 0 : form.setFieldsValue(setValue);
|
|
91
|
+
return _context2.abrupt("return", setValue || {});
|
|
92
|
+
case 11:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context2.stop();
|
|
95
|
+
}
|
|
96
|
+
}, _callee2);
|
|
97
|
+
})));
|
|
98
|
+
var run = infoControl.run,
|
|
99
|
+
mutate = infoControl.mutate;
|
|
100
|
+
useEffect(function () {
|
|
101
|
+
if (form) {
|
|
102
|
+
form.reload = function (reloadParams) {
|
|
103
|
+
mutate(undefined);
|
|
104
|
+
return run(reloadParams);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}, []);
|
|
108
|
+
return {
|
|
109
|
+
subControl: subControl,
|
|
110
|
+
infoControl: infoControl
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
var useDefaultComponents = function useDefaultComponents() {
|
|
114
|
+
var defaultComponent = useFormConfigContext("defaultComponent");
|
|
115
|
+
return _objectSpread(_objectSpread({}, componentConfig), defaultComponent);
|
|
116
|
+
};
|
|
117
|
+
var dispatchControl = function dispatchControl(form, params, dispatch) {
|
|
118
|
+
if (!dispatch) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var dispatchKey = _Object$keys(dispatch);
|
|
122
|
+
_forEachInstanceProperty(dispatchKey).call(dispatchKey, function (name) {
|
|
123
|
+
var _dispatch$name = dispatch[name],
|
|
124
|
+
fnKey = _dispatch$name.fnKey,
|
|
125
|
+
reset = _dispatch$name.reset;
|
|
126
|
+
if (reset) {
|
|
127
|
+
form.setFields([{
|
|
128
|
+
name: name,
|
|
129
|
+
value: null,
|
|
130
|
+
errors: []
|
|
131
|
+
}]);
|
|
132
|
+
}
|
|
133
|
+
if (!fnKey) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
form.dispatch({
|
|
137
|
+
key: fnKey,
|
|
138
|
+
name: name
|
|
139
|
+
}, params);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
var useValuesChange = function useValuesChange(_ref4) {
|
|
143
|
+
var onValuesChange = _ref4.onValuesChange,
|
|
144
|
+
dispatch = _ref4.dispatch,
|
|
145
|
+
form = _ref4.form;
|
|
146
|
+
return function (changedValues, values) {
|
|
147
|
+
var changeKey = _Object$keys(changedValues)[0];
|
|
148
|
+
var dispatchItem = dispatch[changeKey];
|
|
149
|
+
dispatchControl(form, {
|
|
150
|
+
changedValues: changedValues,
|
|
151
|
+
oldValues: values
|
|
152
|
+
}, dispatchItem);
|
|
153
|
+
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(changedValues, values);
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export { useCurrentForm, useDefaultComponents, useInfoReq, useValuesChange };
|
|
158
|
+
// powered by hdj
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
3
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
4
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
5
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
6
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
7
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
11
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
import componentConfig from '../config.js';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
|
|
16
|
+
var _excluded = ["render", "labelWidth", "colon", "type", "itemProps"];
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
var useDefaultRender = function useDefaultRender(props, defaultComponents) {
|
|
20
|
+
var render = props.render;
|
|
21
|
+
props.labelWidth;
|
|
22
|
+
props.colon;
|
|
23
|
+
var _props$type = props.type,
|
|
24
|
+
type = _props$type === void 0 ? "input" : _props$type,
|
|
25
|
+
_props$itemProps = props.itemProps,
|
|
26
|
+
itemProps = _props$itemProps === void 0 ? {} : _props$itemProps,
|
|
27
|
+
componentProps = _objectWithoutProperties(props, _excluded);
|
|
28
|
+
var mergeComponent = _objectSpread(_objectSpread({}, componentConfig), defaultComponents);
|
|
29
|
+
var dom = mergeComponent[type];
|
|
30
|
+
return function (form) {
|
|
31
|
+
var Component = dom;
|
|
32
|
+
if (dom !== null && dom !== void 0 && dom.Component) {
|
|
33
|
+
Component = dom.Component;
|
|
34
|
+
}
|
|
35
|
+
var node = Component && jsx(Component, _objectSpread(_objectSpread(_objectSpread({}, componentProps), itemProps), {}, {
|
|
36
|
+
form: form
|
|
37
|
+
}));
|
|
38
|
+
if (render) {
|
|
39
|
+
var resultNode = render(props, node, form);
|
|
40
|
+
return /*#__PURE__*/React.cloneElement(resultNode, _objectSpread(_objectSpread(_objectSpread({}, componentProps), itemProps), {}, {
|
|
41
|
+
form: form
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
return node;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { useDefaultRender };
|
|
49
|
+
// powered by hdj
|
|
@@ -0,0 +1,194 @@
|
|
|
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 initDispatch = {};
|
|
30
|
+
var cacheValues = {};
|
|
31
|
+
var isLoading = false;
|
|
32
|
+
var norAddItemDispatch = function norAddItemDispatch(name, manual, fn) {
|
|
33
|
+
if (manual === false && name) {
|
|
34
|
+
initDispatch[name] = fn;
|
|
35
|
+
}
|
|
36
|
+
if (!name) {
|
|
37
|
+
return {
|
|
38
|
+
keysFn: {},
|
|
39
|
+
defaultFn: [fn]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
keysFn: _defineProperty({}, name, fn),
|
|
44
|
+
defaultFn: []
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
return _objectSpread(_objectSpread({
|
|
48
|
+
reload: function reload(params) {
|
|
49
|
+
return _Promise.resolve(params);
|
|
50
|
+
},
|
|
51
|
+
initValues: function initValues() {
|
|
52
|
+
var newValue = {};
|
|
53
|
+
if (cacheValues) {
|
|
54
|
+
newValue = this.formatValues(cacheValues);
|
|
55
|
+
form.setFieldsValue(newValue);
|
|
56
|
+
}
|
|
57
|
+
var initKeys = _Object$keys(initDispatch);
|
|
58
|
+
_forEachInstanceProperty(initKeys).call(initKeys, function (key) {
|
|
59
|
+
initDispatch[key]({
|
|
60
|
+
changedValues: newValue,
|
|
61
|
+
oldValues: newValue
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
isLoading = true;
|
|
65
|
+
},
|
|
66
|
+
addFormat: function addFormat(name, format) {
|
|
67
|
+
if (!format) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
var inputValue = format.inputValue,
|
|
71
|
+
outputValue = format.outputValue;
|
|
72
|
+
formatSourceData[name] = {
|
|
73
|
+
inputValue: inputValue,
|
|
74
|
+
outputValue: outputValue
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
formatValues: function formatValues() {
|
|
78
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
79
|
+
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
80
|
+
var valKeys = _Object$keys(value).length;
|
|
81
|
+
if (!valKeys) {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
var newValue = _objectSpread({}, value);
|
|
85
|
+
var keys = _Object$keys(formatSourceData);
|
|
86
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
87
|
+
var _formatSourceData$key;
|
|
88
|
+
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
89
|
+
if (!format) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
var resultValue = format(value);
|
|
93
|
+
_Reflect$deleteProperty(newValue, key);
|
|
94
|
+
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
95
|
+
});
|
|
96
|
+
return newValue;
|
|
97
|
+
},
|
|
98
|
+
dispatch: function dispatch(action) {
|
|
99
|
+
var _context2, _context3, _context4;
|
|
100
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
101
|
+
args[_key - 1] = arguments[_key];
|
|
102
|
+
}
|
|
103
|
+
var key = action.key,
|
|
104
|
+
name = action.name;
|
|
105
|
+
var items = dispatchSourceData[key];
|
|
106
|
+
if (!items) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var keysFn = items.keysFn,
|
|
110
|
+
defaultFn = items.defaultFn;
|
|
111
|
+
if (name) {
|
|
112
|
+
var _keysFn$name, _context;
|
|
113
|
+
return (_keysFn$name = keysFn[name]) === null || _keysFn$name === void 0 ? void 0 : _keysFn$name.call.apply(_keysFn$name, _concatInstanceProperty(_context = [keysFn]).call(_context, args));
|
|
114
|
+
}
|
|
115
|
+
var fnArrays = _mapInstanceProperty(_context2 = _Object$keys(keysFn)).call(_context2, function (itemKey) {
|
|
116
|
+
return keysFn[itemKey];
|
|
117
|
+
});
|
|
118
|
+
_forEachInstanceProperty(_context3 = _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(fnArrays), _toConsumableArray(defaultFn))).call(_context3, function (fn) {
|
|
119
|
+
fn.apply(void 0, args);
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
addDispatchListener: function addDispatchListener(action, fn) {
|
|
123
|
+
var key = action.key,
|
|
124
|
+
name = action.name,
|
|
125
|
+
_action$dispatch = action.dispatch,
|
|
126
|
+
dispatch = _action$dispatch === void 0 ? {} : _action$dispatch;
|
|
127
|
+
var manual = dispatch.manual;
|
|
128
|
+
var items = dispatchSourceData[key];
|
|
129
|
+
if (!items) {
|
|
130
|
+
dispatchSourceData[key] = norAddItemDispatch(name, manual, fn);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
var keysFn = items.keysFn,
|
|
134
|
+
defaultFn = items.defaultFn;
|
|
135
|
+
if (name) {
|
|
136
|
+
keysFn[name] = fn;
|
|
137
|
+
} else {
|
|
138
|
+
defaultFn.push(fn);
|
|
139
|
+
}
|
|
140
|
+
if (manual === false && name) {
|
|
141
|
+
initDispatch[name] = fn;
|
|
142
|
+
}
|
|
143
|
+
dispatchSourceData[key] = {
|
|
144
|
+
keysFn: keysFn,
|
|
145
|
+
defaultFn: defaultFn
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
removeDispatchListener: function removeDispatchListener(action) {
|
|
149
|
+
if (!action) {
|
|
150
|
+
dispatchSourceData = {};
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var key = action.key,
|
|
154
|
+
name = action.name;
|
|
155
|
+
var items = dispatchSourceData[key];
|
|
156
|
+
if (!items) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (name) {
|
|
160
|
+
var keysFn = items.keysFn;
|
|
161
|
+
_Reflect$deleteProperty(keysFn, name);
|
|
162
|
+
items.keysFn = keysFn;
|
|
163
|
+
dispatchSourceData[key] = items;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
167
|
+
},
|
|
168
|
+
outputValues: function outputValues(value) {
|
|
169
|
+
return this.formatValues(value, "outputValue");
|
|
170
|
+
}
|
|
171
|
+
}, form), {}, {
|
|
172
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
173
|
+
if (!isLoading) {
|
|
174
|
+
cacheValues = values;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
var newValue = this.formatValues(values);
|
|
178
|
+
form.setFieldsValue(newValue);
|
|
179
|
+
},
|
|
180
|
+
validateFields: function validateFields(nameList) {
|
|
181
|
+
var _this = this;
|
|
182
|
+
return new _Promise(function (resolve) {
|
|
183
|
+
form.validateFields(nameList).then(function (value) {
|
|
184
|
+
var result = _this.formatValues(value, "outputValue");
|
|
185
|
+
return resolve(result);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}, []);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
export { useHForm as default };
|
|
194
|
+
// powered by hdj
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HFormProps, HItemProps } from "../modal";
|
|
2
|
+
import type { DispatchSourceDataModal } from "../modal";
|
|
3
|
+
type InitConfigModal = Required<Pick<HFormProps, "configData" | "form">>;
|
|
4
|
+
declare const _default: ({ configData, form }: InitConfigModal) => {
|
|
5
|
+
newConfigData: HItemProps[];
|
|
6
|
+
dispatchSourceData: DispatchSourceDataModal;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|