@hw-component/form 0.0.5-beta-v6 → 0.0.5-beta-v7
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/Form/config.d.ts +2 -2
- package/es/index.d.ts +1 -26
- package/es/index.js +4 -30
- package/lib/Form/config.d.ts +2 -2
- package/lib/index.d.ts +1 -26
- package/lib/index.js +4 -53
- package/package.json +1 -1
- package/src/components/index.tsx +3 -30
- package/es/CheckboxGroup/CheckBox/index.js +0 -42
- package/es/CheckboxGroup/hooks.js +0 -120
- package/es/CheckboxGroup/index.js +0 -93
- package/es/DialogForm/DrawerForm/Footer.js +0 -27
- package/es/DialogForm/DrawerForm/Title.js +0 -21
- package/es/DialogForm/DrawerForm/index.js +0 -137
- package/es/DialogForm/ModalForm.js +0 -118
- package/es/DialogForm/hooks.js +0 -148
- package/es/Form/Context/FormConfigProvider.js +0 -48
- package/es/Form/Context/index.js +0 -11
- package/es/Form/FormItem/BasicItem.js +0 -92
- package/es/Form/FormItem/Helper.js +0 -26
- package/es/Form/FormItem/RegularFormItem.js +0 -24
- package/es/Form/FormItem/UpFormItem.js +0 -42
- package/es/Form/FormItem/hooks.js +0 -38
- package/es/Form/FormItem/index.js +0 -21
- package/es/Form/HFormConnect.js +0 -68
- package/es/Form/InitSet.js +0 -16
- package/es/Form/Label.js +0 -49
- package/es/Form/config.js +0 -45
- package/es/Form/hooks/index.js +0 -157
- package/es/Form/hooks/useDefaultRender.js +0 -48
- package/es/Form/hooks/useHForm.js +0 -193
- package/es/Form/hooks/useInitConfigData.js +0 -169
- package/es/Form/index.js +0 -102
- package/es/Input/ButtonInput.js +0 -94
- package/es/Input/ColorInput/Picker.js +0 -22
- package/es/Input/ColorInput/data.js +0 -5
- package/es/Input/ColorInput/index.js +0 -94
- package/es/Input/InputNumber.js +0 -29
- package/es/Input/SelectInput.js +0 -95
- package/es/Input/defaultConfig.js +0 -11
- package/es/Input/index.js +0 -23
- package/es/PageHandler/ErrorComponent.js +0 -38
- package/es/PageHandler/LoadingComponent.js +0 -19
- package/es/PageHandler/index.js +0 -26
- package/es/RadioGroup/index.js +0 -58
- package/es/Select/components/AllSelect.js +0 -55
- package/es/Select/components/CheckBoxOption.js +0 -16
- package/es/Select/components/DropdownComponent.js +0 -44
- package/es/Select/components/NoFindItem.js +0 -14
- package/es/Select/components/NotFoundContent.js +0 -43
- package/es/Select/defaultConfig.js +0 -32
- package/es/Select/hooks/changeHooks.js +0 -196
- package/es/Select/hooks/norHooks.js +0 -118
- package/es/Select/index.js +0 -149
- package/es/Select/utils.js +0 -37
- package/es/Submit/index.js +0 -54
- package/es/Switch/index.js +0 -59
- package/es/TDPicker/RangePicker.js +0 -125
- package/es/TDPicker/TimePicker.js +0 -44
- package/es/TDPicker/hooks.js +0 -132
- package/es/TDPicker/index.js +0 -47
- package/es/TextArea/index.js +0 -30
- package/es/Upload/Btn.js +0 -36
- package/es/Upload/MediaTypeEle/TypeEle.js +0 -42
- package/es/Upload/MediaTypeEle/index.js +0 -36
- package/es/Upload/Preview/index.js +0 -22
- package/es/Upload/UrlUpload/index.js +0 -133
- package/es/Upload/enums.js +0 -10
- package/es/Upload/hooks/change.js +0 -107
- package/es/Upload/hooks/customRequest.js +0 -131
- package/es/Upload/hooks/propsMaker.js +0 -36
- package/es/Upload/index.js +0 -145
- package/es/Upload/util.js +0 -34
- package/es/config.js +0 -65
- package/es/hooks/index.js +0 -74
- package/es/index.css +0 -44
- package/lib/CheckboxGroup/CheckBox/index.js +0 -45
- package/lib/CheckboxGroup/hooks.js +0 -121
- package/lib/CheckboxGroup/index.js +0 -96
- package/lib/DialogForm/DrawerForm/Footer.js +0 -30
- package/lib/DialogForm/DrawerForm/Title.js +0 -24
- package/lib/DialogForm/DrawerForm/index.js +0 -140
- package/lib/DialogForm/ModalForm.js +0 -121
- package/lib/DialogForm/hooks.js +0 -152
- package/lib/Form/Context/FormConfigProvider.js +0 -52
- package/lib/Form/Context/index.js +0 -14
- package/lib/Form/FormItem/BasicItem.js +0 -95
- package/lib/Form/FormItem/Helper.js +0 -29
- package/lib/Form/FormItem/RegularFormItem.js +0 -27
- package/lib/Form/FormItem/UpFormItem.js +0 -45
- package/lib/Form/FormItem/hooks.js +0 -41
- package/lib/Form/FormItem/index.js +0 -24
- package/lib/Form/HFormConnect.js +0 -71
- package/lib/Form/InitSet.js +0 -19
- package/lib/Form/Label.js +0 -52
- package/lib/Form/config.js +0 -49
- package/lib/Form/hooks/index.js +0 -161
- package/lib/Form/hooks/useDefaultRender.js +0 -49
- package/lib/Form/hooks/useHForm.js +0 -196
- package/lib/Form/hooks/useInitConfigData.js +0 -172
- package/lib/Form/index.js +0 -105
- package/lib/Input/ButtonInput.js +0 -97
- package/lib/Input/ColorInput/Picker.js +0 -25
- package/lib/Input/ColorInput/data.js +0 -6
- package/lib/Input/ColorInput/index.js +0 -97
- package/lib/Input/InputNumber.js +0 -32
- package/lib/Input/SelectInput.js +0 -99
- package/lib/Input/defaultConfig.js +0 -13
- package/lib/Input/index.js +0 -26
- package/lib/PageHandler/ErrorComponent.js +0 -41
- package/lib/PageHandler/LoadingComponent.js +0 -22
- package/lib/PageHandler/index.js +0 -29
- package/lib/RadioGroup/index.js +0 -61
- package/lib/Select/components/AllSelect.js +0 -58
- package/lib/Select/components/CheckBoxOption.js +0 -19
- package/lib/Select/components/DropdownComponent.js +0 -47
- package/lib/Select/components/NoFindItem.js +0 -17
- package/lib/Select/components/NotFoundContent.js +0 -46
- package/lib/Select/defaultConfig.js +0 -34
- package/lib/Select/hooks/changeHooks.js +0 -197
- package/lib/Select/hooks/norHooks.js +0 -120
- package/lib/Select/index.js +0 -152
- package/lib/Select/utils.js +0 -39
- package/lib/Submit/index.js +0 -57
- package/lib/Switch/index.js +0 -62
- package/lib/TDPicker/RangePicker.js +0 -128
- package/lib/TDPicker/TimePicker.js +0 -47
- package/lib/TDPicker/hooks.js +0 -139
- package/lib/TDPicker/index.js +0 -50
- package/lib/TextArea/index.js +0 -33
- package/lib/Upload/Btn.js +0 -39
- package/lib/Upload/MediaTypeEle/TypeEle.js +0 -45
- package/lib/Upload/MediaTypeEle/index.js +0 -39
- package/lib/Upload/Preview/index.js +0 -25
- package/lib/Upload/UrlUpload/index.js +0 -136
- package/lib/Upload/enums.js +0 -9
- package/lib/Upload/hooks/change.js +0 -108
- package/lib/Upload/hooks/customRequest.js +0 -132
- package/lib/Upload/hooks/propsMaker.js +0 -37
- package/lib/Upload/index.js +0 -148
- package/lib/Upload/util.js +0 -38
- package/lib/config.js +0 -66
- package/lib/hooks/index.js +0 -77
- package/lib/index.css +0 -44
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import UpFormItem from './UpFormItem.js';
|
|
3
|
-
import RegularFormItem from './RegularFormItem.js';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
|
|
6
|
-
var useFormItemDomControl = function useFormItemDomControl(_ref) {
|
|
7
|
-
var shouldUpdate = _ref.shouldUpdate,
|
|
8
|
-
hide = _ref.hide,
|
|
9
|
-
dependencies = _ref.dependencies;
|
|
10
|
-
return useMemo(function () {
|
|
11
|
-
if (shouldUpdate || typeof hide === "function" || dependencies) {
|
|
12
|
-
return UpFormItem;
|
|
13
|
-
}
|
|
14
|
-
return RegularFormItem;
|
|
15
|
-
}, [shouldUpdate, hide]);
|
|
16
|
-
};
|
|
17
|
-
var useShouldUpdate = function useShouldUpdate(_ref2) {
|
|
18
|
-
var hide = _ref2.hide,
|
|
19
|
-
shouldUpdate = _ref2.shouldUpdate;
|
|
20
|
-
if (typeof hide === "function" && !shouldUpdate) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return shouldUpdate;
|
|
24
|
-
};
|
|
25
|
-
var useHide = function useHide(_ref3) {
|
|
26
|
-
var hide = _ref3.hide,
|
|
27
|
-
form = _ref3.form;
|
|
28
|
-
if (hide === true) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (typeof hide === "function") {
|
|
32
|
-
return hide(form);
|
|
33
|
-
}
|
|
34
|
-
return !!hide;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { useFormItemDomControl, useHide, useShouldUpdate };
|
|
38
|
-
// powered by hdj
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import 'core-js/modules/es.object.keys.js';
|
|
3
|
-
import 'core-js/modules/es.symbol.js';
|
|
4
|
-
import 'core-js/modules/es.array.filter.js';
|
|
5
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
-
import { jsx } from 'react/jsx-runtime';
|
|
11
|
-
import { useFormItemDomControl } from './hooks.js';
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
var Item = (function (props) {
|
|
16
|
-
var Component = useFormItemDomControl(props);
|
|
17
|
-
return jsx(Component, _objectSpread({}, props));
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { Item as default };
|
|
21
|
-
// powered by hdj
|
package/es/Form/HFormConnect.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import 'core-js/modules/es.object.keys.js';
|
|
3
|
-
import 'core-js/modules/es.symbol.js';
|
|
4
|
-
import 'core-js/modules/es.array.filter.js';
|
|
5
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
-
import 'core-js/modules/es.function.name.js';
|
|
11
|
-
import { jsx } from 'react/jsx-runtime';
|
|
12
|
-
import { useFormContext } from './Context/index.js';
|
|
13
|
-
import React, { useEffect } from 'react';
|
|
14
|
-
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
var formatMaker = function formatMaker(itemProps, formats) {
|
|
18
|
-
if (!formats) {
|
|
19
|
-
return formats;
|
|
20
|
-
}
|
|
21
|
-
var _inputValue = formats.inputValue,
|
|
22
|
-
_outputValue = formats.outputValue;
|
|
23
|
-
return {
|
|
24
|
-
inputValue: function inputValue(value) {
|
|
25
|
-
return _inputValue(itemProps, value);
|
|
26
|
-
},
|
|
27
|
-
outputValue: function outputValue(value) {
|
|
28
|
-
return _outputValue(itemProps, value);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
var HFormConnect = (function (component) {
|
|
33
|
-
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
34
|
-
var _config$format = config.format,
|
|
35
|
-
format = _config$format === void 0 ? {} : _config$format;
|
|
36
|
-
var Index = function Index(props, ref) {
|
|
37
|
-
var _props$name = props.name,
|
|
38
|
-
name = _props$name === void 0 ? "" : _props$name,
|
|
39
|
-
dispatch = props.dispatch;
|
|
40
|
-
var _useFormContext = useFormContext(),
|
|
41
|
-
form = _useFormContext.form,
|
|
42
|
-
_useFormContext$value = _useFormContext.valueType,
|
|
43
|
-
valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
|
|
44
|
-
useEffect(function () {
|
|
45
|
-
form === null || form === void 0 || form.addFormat(name, formatMaker(props, format[valueType]));
|
|
46
|
-
}, [valueType, props]);
|
|
47
|
-
var addFormat = function addFormat(aFormat) {
|
|
48
|
-
form === null || form === void 0 || form.addFormat(name, formatMaker(props, aFormat[valueType]));
|
|
49
|
-
};
|
|
50
|
-
var addDispatchListener = function addDispatchListener(key, fn) {
|
|
51
|
-
form === null || form === void 0 || form.addDispatchListener({
|
|
52
|
-
key: key,
|
|
53
|
-
name: name,
|
|
54
|
-
dispatch: dispatch
|
|
55
|
-
}, fn);
|
|
56
|
-
};
|
|
57
|
-
var Component = component;
|
|
58
|
-
return jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
|
|
59
|
-
addFormat: addFormat,
|
|
60
|
-
addDispatchListener: addDispatchListener,
|
|
61
|
-
ref: ref
|
|
62
|
-
}));
|
|
63
|
-
};
|
|
64
|
-
return /*#__PURE__*/React.forwardRef(Index);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export { HFormConnect as default };
|
|
68
|
-
// powered by hdj
|
package/es/Form/InitSet.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { useFormContext } from './Context/index.js';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
-
|
|
6
|
-
var InitSet = (function () {
|
|
7
|
-
var _useFormContext = useFormContext(),
|
|
8
|
-
form = _useFormContext.form;
|
|
9
|
-
useEffect(function () {
|
|
10
|
-
form.initValues();
|
|
11
|
-
}, []);
|
|
12
|
-
return jsx(Fragment, {});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export { InitSet as default };
|
|
16
|
-
// powered by hdj
|
package/es/Form/Label.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
package/es/Form/config.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
package/es/Form/hooks/index.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import 'core-js/modules/es.symbol.js';
|
|
3
|
-
import 'core-js/modules/es.array.filter.js';
|
|
4
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
5
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
7
|
-
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
8
|
-
import 'core-js/modules/es.object.keys.js';
|
|
9
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
10
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
11
|
-
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
12
|
-
import { useRequest } from 'ahooks';
|
|
13
|
-
import useHForm from './useHForm.js';
|
|
14
|
-
import { useMemo, useEffect } from 'react';
|
|
15
|
-
import componentConfig from '../config.js';
|
|
16
|
-
import { useFormConfigContext } from '../Context/FormConfigProvider.js';
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
-
var useCurrentForm = function useCurrentForm(form) {
|
|
21
|
-
var selfForm = useHForm();
|
|
22
|
-
return form || selfForm;
|
|
23
|
-
};
|
|
24
|
-
var useInfoReq = function useInfoReq(_ref) {
|
|
25
|
-
var initialValues = _ref.initialValues,
|
|
26
|
-
infoRequest = _ref.infoRequest,
|
|
27
|
-
form = _ref.form,
|
|
28
|
-
params = _ref.params,
|
|
29
|
-
request = _ref.request,
|
|
30
|
-
onFinish = _ref.onFinish;
|
|
31
|
-
var reqData = useMemo(function () {
|
|
32
|
-
var saveParams = params || {};
|
|
33
|
-
return {
|
|
34
|
-
params: saveParams
|
|
35
|
-
};
|
|
36
|
-
}, [params]);
|
|
37
|
-
var subControl = useRequest( /*#__PURE__*/function () {
|
|
38
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
39
|
-
var subVal;
|
|
40
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
|
-
while (1) switch (_context.prev = _context.next) {
|
|
42
|
-
case 0:
|
|
43
|
-
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
44
|
-
if (!request) {
|
|
45
|
-
_context.next = 4;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
_context.next = 4;
|
|
49
|
-
return request(subVal, reqData.params);
|
|
50
|
-
case 4:
|
|
51
|
-
onFinish === null || onFinish === void 0 || onFinish(subVal, reqData.params);
|
|
52
|
-
case 5:
|
|
53
|
-
case "end":
|
|
54
|
-
return _context.stop();
|
|
55
|
-
}
|
|
56
|
-
}, _callee);
|
|
57
|
-
}));
|
|
58
|
-
return function (_x) {
|
|
59
|
-
return _ref2.apply(this, arguments);
|
|
60
|
-
};
|
|
61
|
-
}(), {
|
|
62
|
-
manual: true
|
|
63
|
-
});
|
|
64
|
-
var infoControl = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
65
|
-
var reqParams,
|
|
66
|
-
setValue,
|
|
67
|
-
_args2 = arguments;
|
|
68
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
69
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
70
|
-
case 0:
|
|
71
|
-
reqParams = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : reqData.params;
|
|
72
|
-
setValue = initialValues;
|
|
73
|
-
reqData.params = reqParams;
|
|
74
|
-
if (!(!initialValues && !infoRequest)) {
|
|
75
|
-
_context2.next = 5;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
return _context2.abrupt("return", {});
|
|
79
|
-
case 5:
|
|
80
|
-
if (!infoRequest) {
|
|
81
|
-
_context2.next = 9;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
_context2.next = 8;
|
|
85
|
-
return infoRequest(reqParams);
|
|
86
|
-
case 8:
|
|
87
|
-
setValue = _context2.sent;
|
|
88
|
-
case 9:
|
|
89
|
-
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
90
|
-
return _context2.abrupt("return", setValue || {});
|
|
91
|
-
case 11:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context2.stop();
|
|
94
|
-
}
|
|
95
|
-
}, _callee2);
|
|
96
|
-
})));
|
|
97
|
-
var run = infoControl.run,
|
|
98
|
-
mutate = infoControl.mutate;
|
|
99
|
-
useEffect(function () {
|
|
100
|
-
if (form) {
|
|
101
|
-
form.reload = function (reloadParams) {
|
|
102
|
-
mutate(undefined);
|
|
103
|
-
return run(reloadParams);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}, []);
|
|
107
|
-
return {
|
|
108
|
-
subControl: subControl,
|
|
109
|
-
infoControl: infoControl
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
var useDefaultComponents = function useDefaultComponents() {
|
|
113
|
-
var defaultComponent = useFormConfigContext("defaultComponent");
|
|
114
|
-
return _objectSpread(_objectSpread({}, componentConfig), defaultComponent);
|
|
115
|
-
};
|
|
116
|
-
var dispatchControl = function dispatchControl(form, params, dispatch) {
|
|
117
|
-
if (!dispatch) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
var dispatchKey = Object.keys(dispatch);
|
|
121
|
-
dispatchKey.forEach(function (name) {
|
|
122
|
-
var _dispatch$name = dispatch[name],
|
|
123
|
-
fnKey = _dispatch$name.fnKey,
|
|
124
|
-
reset = _dispatch$name.reset;
|
|
125
|
-
if (reset) {
|
|
126
|
-
form.setFields([{
|
|
127
|
-
name: name,
|
|
128
|
-
value: null,
|
|
129
|
-
errors: []
|
|
130
|
-
}]);
|
|
131
|
-
}
|
|
132
|
-
if (!fnKey) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
form.dispatch({
|
|
136
|
-
key: fnKey,
|
|
137
|
-
name: name
|
|
138
|
-
}, params);
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
var useValuesChange = function useValuesChange(_ref4) {
|
|
142
|
-
var onValuesChange = _ref4.onValuesChange,
|
|
143
|
-
dispatch = _ref4.dispatch,
|
|
144
|
-
form = _ref4.form;
|
|
145
|
-
return function (changedValues, values) {
|
|
146
|
-
var changeKey = Object.keys(changedValues)[0];
|
|
147
|
-
var dispatchItem = dispatch[changeKey];
|
|
148
|
-
dispatchControl(form, {
|
|
149
|
-
changedValues: changedValues,
|
|
150
|
-
oldValues: values
|
|
151
|
-
}, dispatchItem);
|
|
152
|
-
onValuesChange === null || onValuesChange === void 0 || onValuesChange(changedValues, values);
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export { useCurrentForm, useDefaultComponents, useInfoReq, useValuesChange };
|
|
157
|
-
// powered by hdj
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import 'core-js/modules/es.object.keys.js';
|
|
3
|
-
import 'core-js/modules/es.symbol.js';
|
|
4
|
-
import 'core-js/modules/es.array.filter.js';
|
|
5
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
-
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
11
|
-
import { jsx } from 'react/jsx-runtime';
|
|
12
|
-
import componentConfig from '../config.js';
|
|
13
|
-
import React from 'react';
|
|
14
|
-
|
|
15
|
-
var _excluded = ["render", "labelWidth", "colon", "type", "itemProps"];
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
var useDefaultRender = function useDefaultRender(props, defaultComponents) {
|
|
19
|
-
var render = props.render;
|
|
20
|
-
props.labelWidth;
|
|
21
|
-
props.colon;
|
|
22
|
-
var _props$type = props.type,
|
|
23
|
-
type = _props$type === void 0 ? "input" : _props$type,
|
|
24
|
-
_props$itemProps = props.itemProps,
|
|
25
|
-
itemProps = _props$itemProps === void 0 ? {} : _props$itemProps,
|
|
26
|
-
componentProps = _objectWithoutProperties(props, _excluded);
|
|
27
|
-
var mergeComponent = _objectSpread(_objectSpread({}, componentConfig), defaultComponents);
|
|
28
|
-
var dom = mergeComponent[type];
|
|
29
|
-
return function (form) {
|
|
30
|
-
var Component = dom;
|
|
31
|
-
if (dom !== null && dom !== void 0 && dom.Component) {
|
|
32
|
-
Component = dom.Component;
|
|
33
|
-
}
|
|
34
|
-
var node = Component && jsx(Component, _objectSpread(_objectSpread(_objectSpread({}, componentProps), itemProps), {}, {
|
|
35
|
-
form: form
|
|
36
|
-
}));
|
|
37
|
-
if (render) {
|
|
38
|
-
var resultNode = render(props, node, form);
|
|
39
|
-
return /*#__PURE__*/React.cloneElement(resultNode, _objectSpread(_objectSpread(_objectSpread({}, componentProps), itemProps), {}, {
|
|
40
|
-
form: form
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
return node;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { useDefaultRender };
|
|
48
|
-
// powered by hdj
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
// welcome to hoo hoo hoo
|
|
2
|
-
import 'core-js/modules/es.symbol.js';
|
|
3
|
-
import 'core-js/modules/es.array.filter.js';
|
|
4
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
5
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
6
|
-
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
7
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
8
|
-
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
9
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
10
|
-
import 'core-js/modules/es.promise.js';
|
|
11
|
-
import 'core-js/modules/es.object.keys.js';
|
|
12
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
13
|
-
import 'core-js/modules/es.reflect.delete-property.js';
|
|
14
|
-
import 'core-js/modules/es.function.name.js';
|
|
15
|
-
import 'core-js/modules/es.array.concat.js';
|
|
16
|
-
import 'core-js/modules/es.array.map.js';
|
|
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 = symbols.filter(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 source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(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
|
-
initKeys.forEach(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
|
-
keys.forEach(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
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
100
|
-
args[_key - 1] = arguments[_key];
|
|
101
|
-
}
|
|
102
|
-
var key = action.key,
|
|
103
|
-
name = action.name;
|
|
104
|
-
var items = dispatchSourceData[key];
|
|
105
|
-
if (!items) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
var keysFn = items.keysFn,
|
|
109
|
-
defaultFn = items.defaultFn;
|
|
110
|
-
if (name) {
|
|
111
|
-
var _keysFn$name;
|
|
112
|
-
return (_keysFn$name = keysFn[name]) === null || _keysFn$name === void 0 ? void 0 : _keysFn$name.call.apply(_keysFn$name, [keysFn].concat(args));
|
|
113
|
-
}
|
|
114
|
-
var fnArrays = Object.keys(keysFn).map(function (itemKey) {
|
|
115
|
-
return keysFn[itemKey];
|
|
116
|
-
});
|
|
117
|
-
[].concat(_toConsumableArray(fnArrays), _toConsumableArray(defaultFn)).forEach(function (fn) {
|
|
118
|
-
fn.apply(void 0, args);
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
addDispatchListener: function addDispatchListener(action, fn) {
|
|
122
|
-
var key = action.key,
|
|
123
|
-
name = action.name,
|
|
124
|
-
_action$dispatch = action.dispatch,
|
|
125
|
-
dispatch = _action$dispatch === void 0 ? {} : _action$dispatch;
|
|
126
|
-
var manual = dispatch.manual;
|
|
127
|
-
var items = dispatchSourceData[key];
|
|
128
|
-
if (!items) {
|
|
129
|
-
dispatchSourceData[key] = norAddItemDispatch(name, manual, fn);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
var keysFn = items.keysFn,
|
|
133
|
-
defaultFn = items.defaultFn;
|
|
134
|
-
if (name) {
|
|
135
|
-
keysFn[name] = fn;
|
|
136
|
-
} else {
|
|
137
|
-
defaultFn.push(fn);
|
|
138
|
-
}
|
|
139
|
-
if (manual === false && name) {
|
|
140
|
-
initDispatch[name] = fn;
|
|
141
|
-
}
|
|
142
|
-
dispatchSourceData[key] = {
|
|
143
|
-
keysFn: keysFn,
|
|
144
|
-
defaultFn: defaultFn
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
removeDispatchListener: function removeDispatchListener(action) {
|
|
148
|
-
if (!action) {
|
|
149
|
-
dispatchSourceData = {};
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
var key = action.key,
|
|
153
|
-
name = action.name;
|
|
154
|
-
var items = dispatchSourceData[key];
|
|
155
|
-
if (!items) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (name) {
|
|
159
|
-
var keysFn = items.keysFn;
|
|
160
|
-
Reflect.deleteProperty(keysFn, name);
|
|
161
|
-
items.keysFn = keysFn;
|
|
162
|
-
dispatchSourceData[key] = items;
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
Reflect.deleteProperty(dispatchSourceData, key);
|
|
166
|
-
},
|
|
167
|
-
outputValues: function outputValues(value) {
|
|
168
|
-
return this.formatValues(value, "outputValue");
|
|
169
|
-
}
|
|
170
|
-
}, form), {}, {
|
|
171
|
-
setFieldsValue: function setFieldsValue(values) {
|
|
172
|
-
if (!isLoading) {
|
|
173
|
-
cacheValues = values;
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
var newValue = this.formatValues(values);
|
|
177
|
-
form.setFieldsValue(newValue);
|
|
178
|
-
},
|
|
179
|
-
validateFields: function validateFields(nameList) {
|
|
180
|
-
var _this = this;
|
|
181
|
-
return new Promise(function (resolve) {
|
|
182
|
-
form.validateFields(nameList).then(function (value) {
|
|
183
|
-
var result = _this.formatValues(value, "outputValue");
|
|
184
|
-
return resolve(result);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}, []);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
export { useHForm as default };
|
|
193
|
-
// powered by hdj
|