@hw-component/form 0.0.1-bate
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/.babelrc +23 -0
- package/.eslintrc.js +8 -0
- package/.husky/pre-commit +4 -0
- package/.stylelintrc.js +5 -0
- package/LICENSE +201 -0
- package/es/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/es/CheckboxGroup/CheckBox/index.js +40 -0
- package/es/CheckboxGroup/hooks.d.ts +5 -0
- package/es/CheckboxGroup/hooks.js +123 -0
- package/es/CheckboxGroup/index.d.ts +3 -0
- package/es/CheckboxGroup/index.js +89 -0
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/Form/Context/FormConfigProvider.d.ts +5 -0
- package/es/Form/Context/FormConfigProvider.js +47 -0
- package/es/Form/Context/index.d.ts +5 -0
- package/es/Form/Context/index.js +11 -0
- package/es/Form/FormItem/BasicItem.d.ts +4 -0
- package/es/Form/FormItem/BasicItem.js +73 -0
- package/es/Form/FormItem/Helper.d.ts +7 -0
- package/es/Form/FormItem/Helper.js +24 -0
- package/es/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/es/Form/FormItem/RegularFormItem.js +15 -0
- package/es/Form/FormItem/UpFormItem.d.ts +4 -0
- package/es/Form/FormItem/UpFormItem.js +31 -0
- package/es/Form/FormItem/hooks.d.ts +10 -0
- package/es/Form/FormItem/hooks.js +38 -0
- package/es/Form/FormItem/index.d.ts +4 -0
- package/es/Form/FormItem/index.js +11 -0
- package/es/Form/HFormConnect.d.ts +6 -0
- package/es/Form/HFormConnect.js +54 -0
- package/es/Form/InitSet.d.ts +6 -0
- package/es/Form/InitSet.js +16 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +46 -0
- package/es/Form/config.d.ts +28 -0
- package/es/Form/config.js +43 -0
- package/es/Form/hooks/index.d.ts +12 -0
- package/es/Form/hooks/index.js +77 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +111 -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 +73 -0
- package/es/Form/modal.d.ts +92 -0
- package/es/Input/ButtonInput.d.ts +4 -0
- package/es/Input/ButtonInput.js +80 -0
- package/es/Input/InputNumber.d.ts +4 -0
- package/es/Input/InputNumber.js +20 -0
- package/es/Input/SelectInput.d.ts +9 -0
- package/es/Input/SelectInput.js +94 -0
- package/es/Input/defaultConfig.d.ts +7 -0
- package/es/Input/defaultConfig.js +11 -0
- package/es/Input/index.d.ts +4 -0
- package/es/Input/index.js +13 -0
- package/es/Input/modal.d.ts +25 -0
- package/es/PageHandler/ErrorComponent.d.ts +4 -0
- package/es/PageHandler/ErrorComponent.js +33 -0
- package/es/PageHandler/LoadingComponent.d.ts +3 -0
- package/es/PageHandler/LoadingComponent.js +18 -0
- package/es/PageHandler/index.d.ts +4 -0
- package/es/PageHandler/index.js +24 -0
- package/es/PageHandler/modal.d.ts +6 -0
- package/es/RadioGroup/index.d.ts +9 -0
- package/es/RadioGroup/index.js +48 -0
- package/es/Select/components/AllSelect.d.ts +7 -0
- package/es/Select/components/AllSelect.js +50 -0
- package/es/Select/components/CheckBoxOption.d.ts +7 -0
- package/es/Select/components/CheckBoxOption.js +14 -0
- package/es/Select/components/DropdownComponent.d.ts +9 -0
- package/es/Select/components/DropdownComponent.js +39 -0
- package/es/Select/components/NoFindItem.d.ts +6 -0
- package/es/Select/components/NoFindItem.js +13 -0
- package/es/Select/components/NotFoundContent.d.ts +7 -0
- package/es/Select/components/NotFoundContent.js +38 -0
- package/es/Select/defaultConfig.d.ts +6 -0
- package/es/Select/defaultConfig.js +33 -0
- package/es/Select/hooks/changeHooks.d.ts +5 -0
- package/es/Select/hooks/changeHooks.js +194 -0
- package/es/Select/hooks/norHooks.d.ts +10 -0
- package/es/Select/hooks/norHooks.js +85 -0
- package/es/Select/index.d.ts +4 -0
- package/es/Select/index.js +128 -0
- package/es/Select/modal.d.ts +30 -0
- package/es/Select/utils.d.ts +2 -0
- package/es/Select/utils.js +39 -0
- package/es/Submit/index.d.ts +8 -0
- package/es/Submit/index.js +28 -0
- package/es/Switch/index.d.ts +11 -0
- package/es/Switch/index.js +45 -0
- package/es/TDPicker/RangePicker.d.ts +8 -0
- package/es/TDPicker/RangePicker.js +116 -0
- package/es/TDPicker/TimePicker.d.ts +4 -0
- package/es/TDPicker/TimePicker.js +31 -0
- package/es/TDPicker/hooks.d.ts +33 -0
- package/es/TDPicker/hooks.js +132 -0
- package/es/TDPicker/index.d.ts +4 -0
- package/es/TDPicker/index.js +33 -0
- package/es/TDPicker/modal.d.ts +28 -0
- package/es/TextArea/index.d.ts +3 -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 +69 -0
- package/es/Upload/hooks/propsMaker.d.ts +2 -0
- package/es/Upload/hooks/propsMaker.js +37 -0
- package/es/Upload/index.d.ts +4 -0
- package/es/Upload/index.js +106 -0
- package/es/Upload/modal.d.ts +28 -0
- package/es/Upload/util.d.ts +5 -0
- package/es/Upload/util.js +34 -0
- package/es/config.d.ts +2 -0
- package/es/config.js +64 -0
- package/es/hooks/index.d.ts +13 -0
- package/es/hooks/index.js +75 -0
- package/es/index.css +35 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +25 -0
- package/es/modal.d.ts +15 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/lib/CheckboxGroup/CheckBox/index.js +43 -0
- package/lib/CheckboxGroup/hooks.d.ts +5 -0
- package/lib/CheckboxGroup/hooks.js +124 -0
- package/lib/CheckboxGroup/index.d.ts +3 -0
- package/lib/CheckboxGroup/index.js +92 -0
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/Form/Context/FormConfigProvider.d.ts +5 -0
- package/lib/Form/Context/FormConfigProvider.js +51 -0
- package/lib/Form/Context/index.d.ts +5 -0
- package/lib/Form/Context/index.js +14 -0
- package/lib/Form/FormItem/BasicItem.d.ts +4 -0
- package/lib/Form/FormItem/BasicItem.js +76 -0
- package/lib/Form/FormItem/Helper.d.ts +7 -0
- package/lib/Form/FormItem/Helper.js +27 -0
- package/lib/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/lib/Form/FormItem/RegularFormItem.js +18 -0
- package/lib/Form/FormItem/UpFormItem.d.ts +4 -0
- package/lib/Form/FormItem/UpFormItem.js +34 -0
- package/lib/Form/FormItem/hooks.d.ts +10 -0
- package/lib/Form/FormItem/hooks.js +41 -0
- package/lib/Form/FormItem/index.d.ts +4 -0
- package/lib/Form/FormItem/index.js +14 -0
- package/lib/Form/HFormConnect.d.ts +6 -0
- package/lib/Form/HFormConnect.js +57 -0
- package/lib/Form/InitSet.d.ts +6 -0
- package/lib/Form/InitSet.js +19 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +49 -0
- package/lib/Form/config.d.ts +28 -0
- package/lib/Form/config.js +47 -0
- package/lib/Form/hooks/index.d.ts +12 -0
- package/lib/Form/hooks/index.js +80 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +114 -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 +76 -0
- package/lib/Form/modal.d.ts +92 -0
- package/lib/Input/ButtonInput.d.ts +4 -0
- package/lib/Input/ButtonInput.js +83 -0
- package/lib/Input/InputNumber.d.ts +4 -0
- package/lib/Input/InputNumber.js +23 -0
- package/lib/Input/SelectInput.d.ts +9 -0
- package/lib/Input/SelectInput.js +98 -0
- package/lib/Input/defaultConfig.d.ts +7 -0
- package/lib/Input/defaultConfig.js +13 -0
- package/lib/Input/index.d.ts +4 -0
- package/lib/Input/index.js +16 -0
- package/lib/Input/modal.d.ts +25 -0
- package/lib/PageHandler/ErrorComponent.d.ts +4 -0
- package/lib/PageHandler/ErrorComponent.js +36 -0
- package/lib/PageHandler/LoadingComponent.d.ts +3 -0
- package/lib/PageHandler/LoadingComponent.js +21 -0
- package/lib/PageHandler/index.d.ts +4 -0
- package/lib/PageHandler/index.js +27 -0
- package/lib/PageHandler/modal.d.ts +6 -0
- package/lib/RadioGroup/index.d.ts +9 -0
- package/lib/RadioGroup/index.js +51 -0
- package/lib/Select/components/AllSelect.d.ts +7 -0
- package/lib/Select/components/AllSelect.js +53 -0
- package/lib/Select/components/CheckBoxOption.d.ts +7 -0
- package/lib/Select/components/CheckBoxOption.js +17 -0
- package/lib/Select/components/DropdownComponent.d.ts +9 -0
- package/lib/Select/components/DropdownComponent.js +42 -0
- package/lib/Select/components/NoFindItem.d.ts +6 -0
- package/lib/Select/components/NoFindItem.js +16 -0
- package/lib/Select/components/NotFoundContent.d.ts +7 -0
- package/lib/Select/components/NotFoundContent.js +41 -0
- package/lib/Select/defaultConfig.d.ts +6 -0
- package/lib/Select/defaultConfig.js +35 -0
- package/lib/Select/hooks/changeHooks.d.ts +5 -0
- package/lib/Select/hooks/changeHooks.js +195 -0
- package/lib/Select/hooks/norHooks.d.ts +10 -0
- package/lib/Select/hooks/norHooks.js +87 -0
- package/lib/Select/index.d.ts +4 -0
- package/lib/Select/index.js +131 -0
- package/lib/Select/modal.d.ts +30 -0
- package/lib/Select/utils.d.ts +2 -0
- package/lib/Select/utils.js +41 -0
- package/lib/Submit/index.d.ts +8 -0
- package/lib/Submit/index.js +31 -0
- package/lib/Switch/index.d.ts +11 -0
- package/lib/Switch/index.js +48 -0
- package/lib/TDPicker/RangePicker.d.ts +8 -0
- package/lib/TDPicker/RangePicker.js +119 -0
- package/lib/TDPicker/TimePicker.d.ts +4 -0
- package/lib/TDPicker/TimePicker.js +34 -0
- package/lib/TDPicker/hooks.d.ts +33 -0
- package/lib/TDPicker/hooks.js +139 -0
- package/lib/TDPicker/index.d.ts +4 -0
- package/lib/TDPicker/index.js +36 -0
- package/lib/TDPicker/modal.d.ts +28 -0
- package/lib/TextArea/index.d.ts +3 -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 +70 -0
- package/lib/Upload/hooks/propsMaker.d.ts +2 -0
- package/lib/Upload/hooks/propsMaker.js +38 -0
- package/lib/Upload/index.d.ts +4 -0
- package/lib/Upload/index.js +109 -0
- package/lib/Upload/modal.d.ts +28 -0
- package/lib/Upload/util.d.ts +5 -0
- package/lib/Upload/util.js +38 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.js +65 -0
- package/lib/hooks/index.d.ts +13 -0
- package/lib/hooks/index.js +78 -0
- package/lib/index.css +35 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +43 -0
- package/lib/modal.d.ts +15 -0
- package/package.json +81 -0
- package/public/index.html +19 -0
- package/scripts/rollup.config.js +75 -0
- package/scripts/webpack.config.js +76 -0
- package/src/Layout.tsx +61 -0
- package/src/app.tsx +33 -0
- package/src/components/CheckboxGroup/CheckBox/index.tsx +38 -0
- package/src/components/CheckboxGroup/hooks.ts +102 -0
- package/src/components/CheckboxGroup/index.tsx +79 -0
- package/src/components/CheckboxGroup/modal.ts +15 -0
- package/src/components/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 +26 -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 +49 -0
- package/src/components/Form/InitSet.tsx +12 -0
- package/src/components/Form/Label.tsx +50 -0
- package/src/components/Form/config.ts +40 -0
- package/src/components/Form/hooks/index.ts +42 -0
- package/src/components/Form/hooks/useHForm.ts +89 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +100 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +61 -0
- package/src/components/Form/modal.ts +142 -0
- package/src/components/Input/ButtonInput.tsx +41 -0
- package/src/components/Input/InputNumber.tsx +5 -0
- package/src/components/Input/SelectInput.tsx +74 -0
- package/src/components/Input/defaultConfig.ts +8 -0
- package/src/components/Input/index.tsx +6 -0
- package/src/components/Input/modal.ts +31 -0
- package/src/components/PageHandler/ErrorComponent.tsx +20 -0
- package/src/components/PageHandler/LoadingComponent.tsx +9 -0
- package/src/components/PageHandler/index.tsx +14 -0
- package/src/components/PageHandler/modal.ts +6 -0
- package/src/components/RadioGroup/index.tsx +45 -0
- package/src/components/Select/components/AllSelect.tsx +54 -0
- package/src/components/Select/components/CheckBoxOption.tsx +14 -0
- package/src/components/Select/components/DropdownComponent.tsx +36 -0
- package/src/components/Select/components/NoFindItem.tsx +7 -0
- package/src/components/Select/components/NotFoundContent.tsx +25 -0
- package/src/components/Select/defaultConfig.tsx +23 -0
- package/src/components/Select/hooks/changeHooks.tsx +151 -0
- package/src/components/Select/hooks/norHooks.ts +63 -0
- package/src/components/Select/index.less +22 -0
- package/src/components/Select/index.tsx +120 -0
- package/src/components/Select/modal.ts +30 -0
- package/src/components/Select/utils.ts +18 -0
- package/src/components/Submit/index.tsx +28 -0
- package/src/components/Switch/index.tsx +52 -0
- package/src/components/TDPicker/RangePicker.tsx +103 -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 +44 -0
- package/src/components/Upload/hooks/propsMaker.ts +20 -0
- package/src/components/Upload/index.tsx +85 -0
- package/src/components/Upload/modal.ts +31 -0
- package/src/components/Upload/util.ts +27 -0
- package/src/components/config.ts +40 -0
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +21 -0
- 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 +11 -0
- package/src/index.less +20 -0
- package/src/index.tsx +12 -0
- package/src/pages/Checkbox/index.tsx +15 -0
- package/src/pages/DatePicker/index.tsx +33 -0
- package/src/pages/Form/index.tsx +146 -0
- package/src/pages/Input/index.tsx +22 -0
- package/src/pages/Radio/index.tsx +18 -0
- package/src/pages/Select/index.tsx +57 -0
- package/src/pages/Switch/index.tsx +18 -0
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +68 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,111 @@
|
|
|
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 _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
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 _Reflect$deleteProperty from '@babel/runtime-corejs3/core-js/reflect/delete-property';
|
|
13
|
+
import _Promise from '@babel/runtime-corejs3/core-js/promise';
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import { Form } from 'antd';
|
|
16
|
+
|
|
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 useHForm = (function () {
|
|
20
|
+
var _Form$useForm = Form.useForm(),
|
|
21
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
22
|
+
form = _Form$useForm2[0];
|
|
23
|
+
return useMemo(function () {
|
|
24
|
+
var formatSourceData = {};
|
|
25
|
+
var dispatchSourceData = {};
|
|
26
|
+
return _objectSpread(_objectSpread({
|
|
27
|
+
addFormat: function addFormat(name, format) {
|
|
28
|
+
if (!format) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
var inputValue = format.inputValue,
|
|
32
|
+
outputValue = format.outputValue;
|
|
33
|
+
formatSourceData[name] = {
|
|
34
|
+
inputValue: inputValue,
|
|
35
|
+
outputValue: outputValue
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
formatValues: function formatValues() {
|
|
39
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
40
|
+
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
41
|
+
var valKeys = _Object$keys(value).length;
|
|
42
|
+
if (!valKeys) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
var newValue = _objectSpread({}, value);
|
|
46
|
+
var keys = _Object$keys(formatSourceData);
|
|
47
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
48
|
+
var _formatSourceData$key;
|
|
49
|
+
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
50
|
+
if (!format) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
var resultValue = format(value);
|
|
54
|
+
_Reflect$deleteProperty(newValue, key);
|
|
55
|
+
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
56
|
+
});
|
|
57
|
+
return newValue;
|
|
58
|
+
},
|
|
59
|
+
dispatch: function dispatch(key) {
|
|
60
|
+
var items = dispatchSourceData[key];
|
|
61
|
+
if (!items) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
_forEachInstanceProperty(items).call(items, function (fn) {
|
|
65
|
+
fn();
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
addDispatchListener: function addDispatchListener(key, fn) {
|
|
69
|
+
var items = dispatchSourceData[key];
|
|
70
|
+
if (!items) {
|
|
71
|
+
dispatchSourceData[key] = [fn];
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
items.push(fn);
|
|
75
|
+
dispatchSourceData[key] = items;
|
|
76
|
+
},
|
|
77
|
+
removeDispatchListener: function removeDispatchListener(key) {
|
|
78
|
+
if (!key) {
|
|
79
|
+
dispatchSourceData = {};
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
83
|
+
},
|
|
84
|
+
initValues: function initValues() {
|
|
85
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
86
|
+
var newValue = this.formatValues(value);
|
|
87
|
+
form.setFieldsValue(newValue);
|
|
88
|
+
},
|
|
89
|
+
outputValues: function outputValues(value) {
|
|
90
|
+
return this.formatValues(value, "outputValue");
|
|
91
|
+
}
|
|
92
|
+
}, form), {}, {
|
|
93
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
94
|
+
var newValue = this.formatValues(values);
|
|
95
|
+
form.setFieldsValue(newValue);
|
|
96
|
+
},
|
|
97
|
+
validateFields: function validateFields(nameList) {
|
|
98
|
+
var _this = this;
|
|
99
|
+
return new _Promise(function (resolve) {
|
|
100
|
+
form.validateFields(nameList).then(function (value) {
|
|
101
|
+
var result = _this.formatValues(value, "outputValue");
|
|
102
|
+
return resolve(result);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}, []);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export { useHForm as default };
|
|
111
|
+
// powered by hdj
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
4
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
5
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
6
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
7
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
8
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
9
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
10
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
11
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
12
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
13
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
14
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
15
|
+
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/index-of';
|
|
16
|
+
import FormConfig, { placeholderConfig } from '../config.js';
|
|
17
|
+
|
|
18
|
+
var _excluded = ["render", "type", "itemProps"],
|
|
19
|
+
_excluded2 = ["render"];
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
var mathRequired = function mathRequired(configItem, form) {
|
|
23
|
+
var required = configItem.required,
|
|
24
|
+
placeholder = configItem.placeholder,
|
|
25
|
+
rules = configItem.rules,
|
|
26
|
+
_configItem$type = configItem.type,
|
|
27
|
+
type = _configItem$type === void 0 ? "input" : _configItem$type;
|
|
28
|
+
var resultRequired = false;
|
|
29
|
+
var dom = FormConfig[type];
|
|
30
|
+
var resultRules = rules === null || rules === void 0 ? void 0 : _mapInstanceProperty(rules).call(rules, function (item) {
|
|
31
|
+
var eachItem = item;
|
|
32
|
+
if (typeof item === "function") {
|
|
33
|
+
eachItem = item(form);
|
|
34
|
+
}
|
|
35
|
+
var _eachItem = eachItem,
|
|
36
|
+
itemRequired = _eachItem.required,
|
|
37
|
+
message = _eachItem.message;
|
|
38
|
+
if (itemRequired) {
|
|
39
|
+
resultRequired = itemRequired;
|
|
40
|
+
}
|
|
41
|
+
if (itemRequired && !message) {
|
|
42
|
+
return _objectSpread(_objectSpread({}, eachItem), {}, {
|
|
43
|
+
required: itemRequired,
|
|
44
|
+
message: !!(dom !== null && dom !== void 0 && dom.requiredErrMsg) ? dom.requiredErrMsg(configItem) : placeholder
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return eachItem;
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
required: typeof required === "boolean" ? required : resultRequired,
|
|
51
|
+
rules: resultRules
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
55
|
+
var _context;
|
|
56
|
+
var label = props.label,
|
|
57
|
+
placeholder = props.placeholder,
|
|
58
|
+
_props$type = props.type,
|
|
59
|
+
type = _props$type === void 0 ? "input" : _props$type;
|
|
60
|
+
var dom = FormConfig[type];
|
|
61
|
+
if (placeholder) {
|
|
62
|
+
return placeholder;
|
|
63
|
+
}
|
|
64
|
+
if (dom !== null && dom !== void 0 && dom.placeholder) {
|
|
65
|
+
return dom.placeholder(props);
|
|
66
|
+
}
|
|
67
|
+
if (_indexOfInstanceProperty(_context = placeholderConfig.inputType).call(_context, type) !== -1) {
|
|
68
|
+
return "\u8BF7\u8F93\u5165".concat(label);
|
|
69
|
+
}
|
|
70
|
+
return "\u8BF7\u9009\u62E9".concat(label);
|
|
71
|
+
};
|
|
72
|
+
var defaultRenderMaker = function defaultRenderMaker(props) {
|
|
73
|
+
var render = props.render,
|
|
74
|
+
_props$type2 = props.type,
|
|
75
|
+
type = _props$type2 === void 0 ? "input" : _props$type2,
|
|
76
|
+
_props$itemProps = props.itemProps,
|
|
77
|
+
itemProps = _props$itemProps === void 0 ? {} : _props$itemProps,
|
|
78
|
+
componentProps = _objectWithoutProperties(props, _excluded);
|
|
79
|
+
var dom = FormConfig[type];
|
|
80
|
+
return function (form) {
|
|
81
|
+
var Component = !!(dom !== null && dom !== void 0 && dom.Component) ? dom.Component : dom;
|
|
82
|
+
var node = Component && /*#__PURE__*/React.createElement(Component, _extends({}, componentProps, itemProps, {
|
|
83
|
+
form: form
|
|
84
|
+
}));
|
|
85
|
+
if (render) {
|
|
86
|
+
return render(props, node, form);
|
|
87
|
+
}
|
|
88
|
+
return node;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(props) {
|
|
92
|
+
var placeholder = matchDefaultPlaceholder(props);
|
|
93
|
+
return _objectSpread(_objectSpread({}, props), {}, {
|
|
94
|
+
placeholder: placeholder,
|
|
95
|
+
render: defaultRenderMaker(_objectSpread(_objectSpread({}, props), {}, {
|
|
96
|
+
placeholder: placeholder
|
|
97
|
+
}))
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var itemControl = function itemControl(item, form) {
|
|
101
|
+
var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
|
|
102
|
+
render = _defaultPlaceholderPr.render,
|
|
103
|
+
defaultProps = _objectWithoutProperties(_defaultPlaceholderPr, _excluded2);
|
|
104
|
+
var _mathRequired = mathRequired(defaultProps, form),
|
|
105
|
+
rules = _mathRequired.rules,
|
|
106
|
+
required = _mathRequired.required;
|
|
107
|
+
return _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
108
|
+
required: required,
|
|
109
|
+
rules: rules,
|
|
110
|
+
render: render
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var useInitConfigData = (function (_ref) {
|
|
114
|
+
var configData = _ref.configData,
|
|
115
|
+
form = _ref.form;
|
|
116
|
+
return useMemo(function () {
|
|
117
|
+
return _mapInstanceProperty(configData).call(configData, function (item) {
|
|
118
|
+
return itemControl(item, form);
|
|
119
|
+
});
|
|
120
|
+
}, [configData]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export { useInitConfigData as default };
|
|
124
|
+
// powered by hdj
|
package/es/Form/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
6
|
+
import { Form } from 'antd';
|
|
7
|
+
import Item from './FormItem/index.js';
|
|
8
|
+
import { useCurrentForm, useSub, useInit } from './hooks/index.js';
|
|
9
|
+
import { FormContext } from './Context/index.js';
|
|
10
|
+
import Index from '../PageHandler/index.js';
|
|
11
|
+
import useInitConfigData from './hooks/useInitConfigData.js';
|
|
12
|
+
import InitSet from './InitSet.js';
|
|
13
|
+
|
|
14
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues"];
|
|
15
|
+
var index = (function (_ref) {
|
|
16
|
+
var configData = _ref.configData,
|
|
17
|
+
labelWidth = _ref.labelWidth,
|
|
18
|
+
form = _ref.form,
|
|
19
|
+
request = _ref.request,
|
|
20
|
+
onFinish = _ref.onFinish,
|
|
21
|
+
infoRequest = _ref.infoRequest,
|
|
22
|
+
_ref$valueType = _ref.valueType,
|
|
23
|
+
valueType = _ref$valueType === void 0 ? "float" : _ref$valueType,
|
|
24
|
+
initialValues = _ref.initialValues,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var hForm = useCurrentForm(form);
|
|
27
|
+
var newConfigData = useInitConfigData({
|
|
28
|
+
configData: configData,
|
|
29
|
+
form: hForm
|
|
30
|
+
});
|
|
31
|
+
var _useSub = useSub({
|
|
32
|
+
request: request,
|
|
33
|
+
onFinish: onFinish,
|
|
34
|
+
valueType: valueType,
|
|
35
|
+
form: hForm
|
|
36
|
+
}),
|
|
37
|
+
run = _useSub.run,
|
|
38
|
+
loading = _useSub.loading;
|
|
39
|
+
var _useInit = useInit({
|
|
40
|
+
infoRequest: infoRequest,
|
|
41
|
+
initialValues: initialValues
|
|
42
|
+
}),
|
|
43
|
+
infoRun = _useInit.infoRun,
|
|
44
|
+
infoLoading = _useInit.infoLoading,
|
|
45
|
+
infoErr = _useInit.infoErr,
|
|
46
|
+
infoData = _useInit.infoData;
|
|
47
|
+
return /*#__PURE__*/React.createElement(Index, {
|
|
48
|
+
loading: infoLoading,
|
|
49
|
+
error: infoErr,
|
|
50
|
+
data: infoData,
|
|
51
|
+
reload: infoRun
|
|
52
|
+
}, /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
53
|
+
value: {
|
|
54
|
+
loading: loading,
|
|
55
|
+
form: hForm,
|
|
56
|
+
valueType: valueType
|
|
57
|
+
}
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Form, _extends({
|
|
59
|
+
form: hForm,
|
|
60
|
+
onFinish: run
|
|
61
|
+
}, props), _mapInstanceProperty(newConfigData).call(newConfigData, function (itemData, index) {
|
|
62
|
+
var itemLabelWidth = itemData.labelWidth;
|
|
63
|
+
return /*#__PURE__*/React.createElement(Item, _extends({}, itemData, {
|
|
64
|
+
key: index,
|
|
65
|
+
labelWidth: itemLabelWidth || labelWidth
|
|
66
|
+
}));
|
|
67
|
+
})), /*#__PURE__*/React.createElement(InitSet, {
|
|
68
|
+
initValues: infoData
|
|
69
|
+
})));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export { index as default };
|
|
73
|
+
// powered by hdj
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { FormInstance, FormItemProps, FormProps } from "antd";
|
|
2
|
+
import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import type { HButtonProps, HInputProps, HSelectInputProps } from "@/components/Input/modal";
|
|
5
|
+
import type { HRadioGroupProps } from "@/components/RadioGroup";
|
|
6
|
+
import type { HSelectProps } from "@/components/Select/modal";
|
|
7
|
+
import type { ButtonProps } from "antd/es";
|
|
8
|
+
import type { HSwitchProps } from "@/components/Switch";
|
|
9
|
+
import type { HDatePickerProps, HRangePickerProps, HTimePickerProps } from "@/components/TDPicker/modal";
|
|
10
|
+
import type { TextAreaProps } from "antd/es/input";
|
|
11
|
+
import type { IUpLoadProps } from "@/components/Upload/modal";
|
|
12
|
+
import type { SelectProps } from "antd";
|
|
13
|
+
import type { RangePickerProps } from "antd/es/date-picker";
|
|
14
|
+
import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRangePickerValueMapModal } from "../modal";
|
|
15
|
+
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => void;
|
|
16
|
+
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps;
|
|
17
|
+
export interface HoverModal {
|
|
18
|
+
text?: string;
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
22
|
+
export type HideModal = (form: HFormInstance) => boolean;
|
|
23
|
+
export interface HItemProps extends Omit<FormItemProps, "name"> {
|
|
24
|
+
type?: string;
|
|
25
|
+
itemProps?: ItemPropsType;
|
|
26
|
+
render?: RenderFun;
|
|
27
|
+
helper?: HelperModal;
|
|
28
|
+
hover?: string | HoverModal;
|
|
29
|
+
labelWidth?: number;
|
|
30
|
+
hide?: boolean | HideModal;
|
|
31
|
+
placeholder?: string | string[];
|
|
32
|
+
formatKeys?: string[];
|
|
33
|
+
name: string;
|
|
34
|
+
}
|
|
35
|
+
export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
|
|
36
|
+
configData: HItemProps[];
|
|
37
|
+
labelWidth?: number;
|
|
38
|
+
request?: PromiseFnResult<T, R>;
|
|
39
|
+
infoRequest?: () => Promise<T>;
|
|
40
|
+
valueType?: string;
|
|
41
|
+
form?: HFormInstance;
|
|
42
|
+
}
|
|
43
|
+
export interface HFormItemProps extends HItemProps {
|
|
44
|
+
required?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
|
|
47
|
+
render: (form: HFormInstance) => React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
export interface FormContextProps {
|
|
50
|
+
loading?: boolean;
|
|
51
|
+
form: HFormInstance;
|
|
52
|
+
valueType?: string;
|
|
53
|
+
}
|
|
54
|
+
interface ConfigUploadProps {
|
|
55
|
+
exFiles?: string[];
|
|
56
|
+
maxSize?: number;
|
|
57
|
+
request?: PromiseFnResult;
|
|
58
|
+
}
|
|
59
|
+
export interface IFormConfigContextProps {
|
|
60
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
61
|
+
valueCheckMap?: ValueCheckMapModal;
|
|
62
|
+
valueSwitchMap?: ValueSwitchMapModal;
|
|
63
|
+
valueRangePickerValueMap?: DateRangePickerValueMapModal;
|
|
64
|
+
dateRanges?: RangePickerProps["ranges"];
|
|
65
|
+
uploadProps?: ConfigUploadProps;
|
|
66
|
+
}
|
|
67
|
+
export interface HFormInstance extends FormInstance {
|
|
68
|
+
addFormat: (name: string, formats?: FormatItemModal) => void;
|
|
69
|
+
initValues: (values?: Record<string, any>) => void;
|
|
70
|
+
formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
|
|
71
|
+
dispatch: (key: string) => void;
|
|
72
|
+
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
73
|
+
addDispatchListener: (key: string, fn: VoidFunction) => void;
|
|
74
|
+
removeDispatchListener: (key?: string) => void;
|
|
75
|
+
}
|
|
76
|
+
export interface ConnectConfigModal {
|
|
77
|
+
format?: Record<string, addFormatItemModal>;
|
|
78
|
+
}
|
|
79
|
+
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
80
|
+
export interface FormatItemModal {
|
|
81
|
+
inputValue: ValueFormat;
|
|
82
|
+
outputValue: ValueFormat;
|
|
83
|
+
}
|
|
84
|
+
type addValueFormat = (item: HFormItemProps, value: Record<string, any>) => Record<string, any>;
|
|
85
|
+
export interface addFormatItemModal {
|
|
86
|
+
inputValue: addValueFormat;
|
|
87
|
+
outputValue: addValueFormat;
|
|
88
|
+
}
|
|
89
|
+
export interface ConnectResultProps {
|
|
90
|
+
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
6
|
+
import { Input, Button } from 'antd';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { useRequest } from 'ahooks';
|
|
9
|
+
|
|
10
|
+
var _excluded = ["buttonProps", "value", "onChange", "children", "request"],
|
|
11
|
+
_excluded2 = ["onClick", "type"];
|
|
12
|
+
var Index = function Index(_ref) {
|
|
13
|
+
var _ref$buttonProps = _ref.buttonProps,
|
|
14
|
+
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
|
|
15
|
+
value = _ref.value,
|
|
16
|
+
onChange = _ref.onChange,
|
|
17
|
+
children = _ref.children,
|
|
18
|
+
request = _ref.request,
|
|
19
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
var onClick = buttonProps.onClick,
|
|
21
|
+
_buttonProps$type = buttonProps.type,
|
|
22
|
+
type = _buttonProps$type === void 0 ? "primary" : _buttonProps$type,
|
|
23
|
+
oProps = _objectWithoutProperties(buttonProps, _excluded2);
|
|
24
|
+
var _useRequest = useRequest(function (val) {
|
|
25
|
+
return request === null || request === void 0 ? void 0 : request(val);
|
|
26
|
+
}, {
|
|
27
|
+
manual: true
|
|
28
|
+
}),
|
|
29
|
+
run = _useRequest.run,
|
|
30
|
+
loading = _useRequest.loading;
|
|
31
|
+
var change = function change(e) {
|
|
32
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
|
|
33
|
+
};
|
|
34
|
+
var click = /*#__PURE__*/function () {
|
|
35
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(e) {
|
|
36
|
+
var result;
|
|
37
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
38
|
+
while (1) switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
result = value;
|
|
41
|
+
if (!request) {
|
|
42
|
+
_context.next = 5;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
_context.next = 4;
|
|
46
|
+
return run(value);
|
|
47
|
+
case 4:
|
|
48
|
+
result = _context.sent;
|
|
49
|
+
case 5:
|
|
50
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(result, e);
|
|
51
|
+
case 6:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
}));
|
|
57
|
+
return function click(_x) {
|
|
58
|
+
return _ref2.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}();
|
|
61
|
+
return /*#__PURE__*/React.createElement(Input.Group, {
|
|
62
|
+
compact: true,
|
|
63
|
+
style: {
|
|
64
|
+
display: "flex"
|
|
65
|
+
}
|
|
66
|
+
}, /*#__PURE__*/React.createElement(Input, _extends({}, props, {
|
|
67
|
+
style: {
|
|
68
|
+
flex: 1
|
|
69
|
+
},
|
|
70
|
+
value: value,
|
|
71
|
+
onChange: change
|
|
72
|
+
})), /*#__PURE__*/React.createElement(Button, _extends({}, oProps, {
|
|
73
|
+
type: type,
|
|
74
|
+
onClick: click,
|
|
75
|
+
loading: loading
|
|
76
|
+
}), children));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { Index as default };
|
|
80
|
+
// powered by hdj
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import { InputNumber } from 'antd';
|
|
6
|
+
|
|
7
|
+
var _excluded = ["style"];
|
|
8
|
+
var HInputNumber = (function (_ref) {
|
|
9
|
+
var _ref$style = _ref.style,
|
|
10
|
+
style = _ref$style === void 0 ? {
|
|
11
|
+
width: "100%"
|
|
12
|
+
} : _ref$style,
|
|
13
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
+
return /*#__PURE__*/React.createElement(InputNumber, _extends({
|
|
15
|
+
style: style
|
|
16
|
+
}, props));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { HInputNumber as default };
|
|
20
|
+
// powered by hdj
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { HSelectInputProps } from "./modal";
|
|
3
|
+
export declare enum SelectInputType {
|
|
4
|
+
input = 0,
|
|
5
|
+
select = 1
|
|
6
|
+
}
|
|
7
|
+
export declare const Index: ({ selectProps, value, onChange, valueName, addFormat, ...props }: HSelectInputProps) => JSX.Element;
|
|
8
|
+
declare const _default: (props: import("../Form/modal").HFormItemProps) => import("react").ReactElement<import("../Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
4
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
5
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
6
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
7
|
+
import _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 _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
11
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
12
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
13
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
14
|
+
import _Object$values from '@babel/runtime-corejs3/core-js/object/values';
|
|
15
|
+
import { Input } from 'antd';
|
|
16
|
+
import HSelect from '../Select/index.js';
|
|
17
|
+
import { defaultValueName, defaultSelectStyle } from './defaultConfig.js';
|
|
18
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
19
|
+
|
|
20
|
+
var _excluded = ["selectProps", "value", "onChange", "valueName", "addFormat"],
|
|
21
|
+
_excluded2 = ["style", "placeholder"];
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
var SelectInputType;
|
|
25
|
+
(function (SelectInputType) {
|
|
26
|
+
SelectInputType[SelectInputType["input"] = 0] = "input";
|
|
27
|
+
SelectInputType[SelectInputType["select"] = 1] = "select";
|
|
28
|
+
})(SelectInputType || (SelectInputType = {}));
|
|
29
|
+
var Index = function Index(_ref) {
|
|
30
|
+
var _ref$selectProps = _ref.selectProps,
|
|
31
|
+
selectProps = _ref$selectProps === void 0 ? {} : _ref$selectProps,
|
|
32
|
+
_ref$value = _ref.value,
|
|
33
|
+
value = _ref$value === void 0 ? {} : _ref$value,
|
|
34
|
+
onChange = _ref.onChange,
|
|
35
|
+
_ref$valueName = _ref.valueName,
|
|
36
|
+
valueName = _ref$valueName === void 0 ? defaultValueName : _ref$valueName,
|
|
37
|
+
addFormat = _ref.addFormat,
|
|
38
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var _valueName$input = valueName.input,
|
|
40
|
+
input = _valueName$input === void 0 ? "" : _valueName$input,
|
|
41
|
+
_valueName$select = valueName.select,
|
|
42
|
+
select = _valueName$select === void 0 ? "" : _valueName$select;
|
|
43
|
+
var inputVal = value[input],
|
|
44
|
+
selectVal = value[select];
|
|
45
|
+
var _selectProps$style = selectProps.style,
|
|
46
|
+
style = _selectProps$style === void 0 ? defaultSelectStyle : _selectProps$style,
|
|
47
|
+
_selectProps$placehol = selectProps.placeholder,
|
|
48
|
+
placeholder = _selectProps$placehol === void 0 ? "请选择" : _selectProps$placehol,
|
|
49
|
+
sProps = _objectWithoutProperties(selectProps, _excluded2);
|
|
50
|
+
var change = function change(val, key) {
|
|
51
|
+
var newVal = _objectSpread({}, value);
|
|
52
|
+
newVal[key] = val;
|
|
53
|
+
var type = key === input ? SelectInputType.input : SelectInputType.select;
|
|
54
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newVal, type);
|
|
55
|
+
};
|
|
56
|
+
addFormat === null || addFormat === void 0 ? void 0 : addFormat({
|
|
57
|
+
"float": {
|
|
58
|
+
inputValue: function inputValue(item, initValue) {
|
|
59
|
+
var _context;
|
|
60
|
+
var name = item.name;
|
|
61
|
+
var resultObj = {};
|
|
62
|
+
_forEachInstanceProperty(_context = _Object$values(valueName)).call(_context, function (key) {
|
|
63
|
+
resultObj[key] = initValue[key];
|
|
64
|
+
});
|
|
65
|
+
return _defineProperty({}, name, resultObj);
|
|
66
|
+
},
|
|
67
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
68
|
+
var name = item.name;
|
|
69
|
+
var _outputValue$name = _outputValue[name],
|
|
70
|
+
itemVal = _outputValue$name === void 0 ? {} : _outputValue$name;
|
|
71
|
+
var newItemVal = _defineProperty({}, itemVal[select], itemVal[input]);
|
|
72
|
+
return _objectSpread({}, newItemVal);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
77
|
+
value: inputVal,
|
|
78
|
+
onChange: function onChange(e) {
|
|
79
|
+
change(e.target.value, input);
|
|
80
|
+
},
|
|
81
|
+
addonBefore: /*#__PURE__*/React.createElement(HSelect, _extends({}, sProps, {
|
|
82
|
+
style: style,
|
|
83
|
+
placeholder: placeholder,
|
|
84
|
+
value: selectVal,
|
|
85
|
+
onChange: function onChange(val) {
|
|
86
|
+
change(val, select);
|
|
87
|
+
}
|
|
88
|
+
}))
|
|
89
|
+
}, props));
|
|
90
|
+
};
|
|
91
|
+
var HSelectInput = HFormConnect(Index);
|
|
92
|
+
|
|
93
|
+
export { Index, SelectInputType, HSelectInput as default };
|
|
94
|
+
// powered by hdj
|