@hw-component/form 0.0.4-beta-v1 → 0.0.4-beta-v3
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/DialogForm/DrawerForm/index.d.ts +1 -1
- package/es/DialogForm/DrawerForm/index.js +4 -2
- package/es/DialogForm/ModalForm.d.ts +1 -1
- package/es/DialogForm/ModalForm.js +3 -1
- package/es/Select/hooks/norHooks.d.ts +6 -0
- package/es/Select/hooks/norHooks.js +19 -5
- package/es/Select/index.d.ts +2 -2
- package/es/Select/index.js +13 -8
- package/es/Select/modal.d.ts +2 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +1 -1
- package/lib/DialogForm/DrawerForm/index.js +4 -2
- package/lib/DialogForm/ModalForm.d.ts +1 -1
- package/lib/DialogForm/ModalForm.js +3 -1
- package/lib/Select/hooks/norHooks.d.ts +6 -0
- package/lib/Select/hooks/norHooks.js +18 -4
- package/lib/Select/index.d.ts +2 -2
- package/lib/Select/index.js +9 -4
- package/lib/Select/modal.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +2 -0
- package/src/components/DialogForm/ModalForm.tsx +2 -0
- package/src/components/Select/hooks/norHooks.ts +17 -1
- package/src/components/Select/index.tsx +7 -3
- package/src/components/Select/modal.ts +2 -0
- package/src/pages/Form/index.tsx +137 -105
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "../modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -18,7 +18,7 @@ import HForm from '../../Form/index.js';
|
|
|
18
18
|
import Title from './Title.js';
|
|
19
19
|
import Footer from './Footer.js';
|
|
20
20
|
|
|
21
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params"];
|
|
21
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange"];
|
|
22
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
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
24
|
var DrawerForm = (function (_ref) {
|
|
@@ -41,6 +41,7 @@ var DrawerForm = (function (_ref) {
|
|
|
41
41
|
_ref.form;
|
|
42
42
|
var footer = _ref.footer,
|
|
43
43
|
params = _ref.params,
|
|
44
|
+
onValuesChange = _ref.onValuesChange,
|
|
44
45
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
45
46
|
var currentForm = useCurrentForm(dialogForm);
|
|
46
47
|
var _useModifyProps = useModifyProps({
|
|
@@ -93,7 +94,8 @@ var DrawerForm = (function (_ref) {
|
|
|
93
94
|
footer: footerComponent(),
|
|
94
95
|
children: jsx(HForm, _objectSpread(_objectSpread({
|
|
95
96
|
configData: modalFormData,
|
|
96
|
-
initialValues: initValue
|
|
97
|
+
initialValues: initValue,
|
|
98
|
+
onValuesChange: onValuesChange
|
|
97
99
|
}, props), {}, {
|
|
98
100
|
form: currentForm,
|
|
99
101
|
params: formParams,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -16,7 +16,7 @@ import { Modal } from 'antd';
|
|
|
16
16
|
import HForm from '../Form/index.js';
|
|
17
17
|
import { useCurrentForm, useModifyProps, useSub } from './hooks.js';
|
|
18
18
|
|
|
19
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk"];
|
|
19
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange"];
|
|
20
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
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
22
|
var ModalForm = (function (_ref) {
|
|
@@ -33,6 +33,7 @@ var ModalForm = (function (_ref) {
|
|
|
33
33
|
onFinish = _ref.onFinish,
|
|
34
34
|
params = _ref.params,
|
|
35
35
|
onOk = _ref.onOk,
|
|
36
|
+
onValuesChange = _ref.onValuesChange,
|
|
36
37
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
38
|
var currentForm = useCurrentForm(dialogForm);
|
|
38
39
|
var _useModifyProps = useModifyProps({
|
|
@@ -74,6 +75,7 @@ var ModalForm = (function (_ref) {
|
|
|
74
75
|
children: jsx(HForm, _objectSpread(_objectSpread({
|
|
75
76
|
configData: modalFormData,
|
|
76
77
|
initialValues: initValue,
|
|
78
|
+
onValuesChange: onValuesChange,
|
|
77
79
|
onFinish: function () {
|
|
78
80
|
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
79
81
|
var result, close;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { OptionType, PartialHSelectProps } from "@/components/Select/modal";
|
|
2
|
+
interface ParamsModal {
|
|
3
|
+
options?: OptionType[];
|
|
4
|
+
params?: any;
|
|
5
|
+
}
|
|
2
6
|
export declare const useOptionReq: ({ manual, request, options, serviceSearch, showSearch, onSearch: propsOnSearch, }: PartialHSelectProps) => {
|
|
3
7
|
run: (params?: any, type?: any) => Promise<OptionType[] | undefined>;
|
|
4
8
|
loading: boolean;
|
|
@@ -6,5 +10,7 @@ export declare const useOptionReq: ({ manual, request, options, serviceSearch, s
|
|
|
6
10
|
data: OptionType[] | undefined;
|
|
7
11
|
onSearch: ((value: string) => void) | undefined;
|
|
8
12
|
mathShowSearch: boolean | undefined;
|
|
13
|
+
reload: ({ options: changeOpts, params: requestParams }: ParamsModal) => void | Promise<OptionType[] | undefined>;
|
|
9
14
|
};
|
|
10
15
|
export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
|
|
16
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
|
3
3
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
4
4
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
5
5
|
import _Promise from '@babel/runtime-corejs3/core-js/promise';
|
|
6
|
-
import { useState } from 'react';
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
7
|
import { useRequest } from 'ahooks';
|
|
8
8
|
|
|
9
9
|
var useOptionReq = function useOptionReq(_ref) {
|
|
@@ -51,6 +51,14 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
51
51
|
run = _useRequest.run,
|
|
52
52
|
loading = _useRequest.loading,
|
|
53
53
|
error = _useRequest.error;
|
|
54
|
+
var reload = function reload(_ref3) {
|
|
55
|
+
var changeOpts = _ref3.options,
|
|
56
|
+
requestParams = _ref3.params;
|
|
57
|
+
if (changeOpts) {
|
|
58
|
+
return setData(changeOpts);
|
|
59
|
+
}
|
|
60
|
+
return run(requestParams);
|
|
61
|
+
};
|
|
54
62
|
var onSearch = function onSearch(inputValue) {
|
|
55
63
|
if (!serviceSearch) {
|
|
56
64
|
propsOnSearch === null || propsOnSearch === void 0 ? void 0 : propsOnSearch(inputValue);
|
|
@@ -60,6 +68,11 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
60
68
|
inputValue: inputValue
|
|
61
69
|
});
|
|
62
70
|
};
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
if (options) {
|
|
73
|
+
setData(options);
|
|
74
|
+
}
|
|
75
|
+
}, [options]);
|
|
63
76
|
var mathShowSearch = showSearch || serviceSearch;
|
|
64
77
|
return {
|
|
65
78
|
run: run,
|
|
@@ -67,12 +80,13 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
67
80
|
error: error,
|
|
68
81
|
data: data,
|
|
69
82
|
onSearch: mathShowSearch ? onSearch : propsOnSearch,
|
|
70
|
-
mathShowSearch: showSearch || serviceSearch
|
|
83
|
+
mathShowSearch: showSearch || serviceSearch,
|
|
84
|
+
reload: reload
|
|
71
85
|
};
|
|
72
86
|
};
|
|
73
|
-
var useFilterOption = function useFilterOption(
|
|
74
|
-
var filterOption =
|
|
75
|
-
serviceSearch =
|
|
87
|
+
var useFilterOption = function useFilterOption(_ref4) {
|
|
88
|
+
var filterOption = _ref4.filterOption,
|
|
89
|
+
serviceSearch = _ref4.serviceSearch;
|
|
76
90
|
if (serviceSearch) {
|
|
77
91
|
return function () {
|
|
78
92
|
return true;
|
package/es/Select/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const _default: (
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
3
3
|
export default _default;
|
package/es/Select/index.js
CHANGED
|
@@ -15,15 +15,16 @@ import { Select } from 'antd';
|
|
|
15
15
|
import { useFilterOption, useOptionReq } from './hooks/norHooks.js';
|
|
16
16
|
import { useValueChange } from './hooks/changeHooks.js';
|
|
17
17
|
import { defaultModeConfig, defaultSelectConfig } from './defaultConfig.js';
|
|
18
|
-
import Index from './components/DropdownComponent.js';
|
|
19
|
-
import Index$
|
|
18
|
+
import Index$1 from './components/DropdownComponent.js';
|
|
19
|
+
import Index$2 from './components/AllSelect.js';
|
|
20
20
|
import { useMatchConfigProps, useChangeOptions } from '../hooks/index.js';
|
|
21
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
21
22
|
|
|
22
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect"];
|
|
23
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener"];
|
|
23
24
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
25
|
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; }
|
|
25
26
|
var Option = Select.Option;
|
|
26
|
-
var
|
|
27
|
+
var Index = function Index(_ref) {
|
|
27
28
|
var _ref$style = _ref.style,
|
|
28
29
|
style = _ref$style === void 0 ? {
|
|
29
30
|
width: "100%"
|
|
@@ -50,6 +51,7 @@ var HSelect = (function (_ref) {
|
|
|
50
51
|
_ref$noMatchItemRende = _ref.noMatchItemRender,
|
|
51
52
|
noMatchItemRender = _ref$noMatchItemRende === void 0 ? defaultSelectConfig.noMatchItemRender : _ref$noMatchItemRende,
|
|
52
53
|
allSelect = _ref.allSelect,
|
|
54
|
+
addDispatchListener = _ref.addDispatchListener,
|
|
53
55
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
54
56
|
var _ref2 = (modeConfig === null || modeConfig === void 0 ? void 0 : modeConfig[mode || ""]) || {},
|
|
55
57
|
icon = _ref2.icon,
|
|
@@ -76,7 +78,8 @@ var HSelect = (function (_ref) {
|
|
|
76
78
|
resultData = _useOptionReq.data,
|
|
77
79
|
error = _useOptionReq.error,
|
|
78
80
|
onSearch = _useOptionReq.onSearch,
|
|
79
|
-
mathShowSearch = _useOptionReq.mathShowSearch
|
|
81
|
+
mathShowSearch = _useOptionReq.mathShowSearch,
|
|
82
|
+
reload = _useOptionReq.reload;
|
|
80
83
|
var data = useChangeOptions({
|
|
81
84
|
options: resultData,
|
|
82
85
|
fieldNames: fieldNames
|
|
@@ -92,6 +95,7 @@ var HSelect = (function (_ref) {
|
|
|
92
95
|
}),
|
|
93
96
|
val = _useValueChange.val,
|
|
94
97
|
change = _useValueChange.change;
|
|
98
|
+
addDispatchListener === null || addDispatchListener === void 0 ? void 0 : addDispatchListener("reload", reload);
|
|
95
99
|
return jsx(Select, _objectSpread(_objectSpread({
|
|
96
100
|
style: style,
|
|
97
101
|
mode: mode,
|
|
@@ -100,12 +104,12 @@ var HSelect = (function (_ref) {
|
|
|
100
104
|
onSearch: onSearch,
|
|
101
105
|
onChange: change,
|
|
102
106
|
dropdownRender: function dropdownRender(node) {
|
|
103
|
-
return jsx(Index, {
|
|
107
|
+
return jsx(Index$1, {
|
|
104
108
|
loading: loading,
|
|
105
109
|
reload: run,
|
|
106
110
|
error: error,
|
|
107
111
|
options: data,
|
|
108
|
-
children: jsx(Index$
|
|
112
|
+
children: jsx(Index$2, {
|
|
109
113
|
allSelect: allSelect,
|
|
110
114
|
options: data,
|
|
111
115
|
mode: mode,
|
|
@@ -136,7 +140,8 @@ var HSelect = (function (_ref) {
|
|
|
136
140
|
}), optionValue);
|
|
137
141
|
})
|
|
138
142
|
}));
|
|
139
|
-
}
|
|
143
|
+
};
|
|
144
|
+
var HSelect = HFormConnect(Index);
|
|
140
145
|
|
|
141
146
|
export { HSelect as default };
|
|
142
147
|
// powered by hdj
|
package/es/Select/modal.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SelectProps } from "antd";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
import { argsFn } from "@/components/Form/modal";
|
|
4
5
|
export type OptionType = Record<string, any>;
|
|
5
6
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
6
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
@@ -22,6 +23,7 @@ export interface HSelectProps extends Omit<SelectProps, "options"> {
|
|
|
22
23
|
options?: OptionType[];
|
|
23
24
|
noMatchItemRender?: RenderFn;
|
|
24
25
|
allSelect?: boolean;
|
|
26
|
+
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
25
27
|
}
|
|
26
28
|
export interface FilterDataModal {
|
|
27
29
|
value: any;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "../modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, params, onValuesChange, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -21,7 +21,7 @@ var index = require('../../Form/index.js');
|
|
|
21
21
|
var Title = require('./Title.js');
|
|
22
22
|
var Footer = require('./Footer.js');
|
|
23
23
|
|
|
24
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params"];
|
|
24
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "closable", "initialValues", "labelWidth", "onOk", "onFinish", "size", "form", "footer", "params", "onValuesChange"];
|
|
25
25
|
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; }
|
|
26
26
|
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; }
|
|
27
27
|
var DrawerForm = (function (_ref) {
|
|
@@ -44,6 +44,7 @@ var DrawerForm = (function (_ref) {
|
|
|
44
44
|
_ref.form;
|
|
45
45
|
var footer = _ref.footer,
|
|
46
46
|
params = _ref.params,
|
|
47
|
+
onValuesChange = _ref.onValuesChange,
|
|
47
48
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
48
49
|
var currentForm = hooks.useCurrentForm(dialogForm);
|
|
49
50
|
var _useModifyProps = hooks.useModifyProps({
|
|
@@ -96,7 +97,8 @@ var DrawerForm = (function (_ref) {
|
|
|
96
97
|
footer: footerComponent(),
|
|
97
98
|
children: jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
98
99
|
configData: modalFormData,
|
|
99
|
-
initialValues: initValue
|
|
100
|
+
initialValues: initValue,
|
|
101
|
+
onValuesChange: onValuesChange
|
|
100
102
|
}, props), {}, {
|
|
101
103
|
form: currentForm,
|
|
102
104
|
params: formParams,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DialogFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, ...props }: DialogFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, params, onOk, onValuesChange, ...props }: DialogFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -19,7 +19,7 @@ var antd = require('antd');
|
|
|
19
19
|
var index = require('../Form/index.js');
|
|
20
20
|
var hooks = require('./hooks.js');
|
|
21
21
|
|
|
22
|
-
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk"];
|
|
22
|
+
var _excluded = ["visible", "title", "onCancel", "configData", "infoRequest", "request", "afterClose", "dialogForm", "initialValues", "onFinish", "params", "onOk", "onValuesChange"];
|
|
23
23
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
var ModalForm = (function (_ref) {
|
|
@@ -36,6 +36,7 @@ var ModalForm = (function (_ref) {
|
|
|
36
36
|
onFinish = _ref.onFinish,
|
|
37
37
|
params = _ref.params,
|
|
38
38
|
onOk = _ref.onOk,
|
|
39
|
+
onValuesChange = _ref.onValuesChange,
|
|
39
40
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
41
|
var currentForm = hooks.useCurrentForm(dialogForm);
|
|
41
42
|
var _useModifyProps = hooks.useModifyProps({
|
|
@@ -77,6 +78,7 @@ var ModalForm = (function (_ref) {
|
|
|
77
78
|
children: jsxRuntime.jsx(index.default, _objectSpread(_objectSpread({
|
|
78
79
|
configData: modalFormData,
|
|
79
80
|
initialValues: initValue,
|
|
81
|
+
onValuesChange: onValuesChange,
|
|
80
82
|
onFinish: function () {
|
|
81
83
|
var _onFinish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
82
84
|
var result, close;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { OptionType, PartialHSelectProps } from "@/components/Select/modal";
|
|
2
|
+
interface ParamsModal {
|
|
3
|
+
options?: OptionType[];
|
|
4
|
+
params?: any;
|
|
5
|
+
}
|
|
2
6
|
export declare const useOptionReq: ({ manual, request, options, serviceSearch, showSearch, onSearch: propsOnSearch, }: PartialHSelectProps) => {
|
|
3
7
|
run: (params?: any, type?: any) => Promise<OptionType[] | undefined>;
|
|
4
8
|
loading: boolean;
|
|
@@ -6,5 +10,7 @@ export declare const useOptionReq: ({ manual, request, options, serviceSearch, s
|
|
|
6
10
|
data: OptionType[] | undefined;
|
|
7
11
|
onSearch: ((value: string) => void) | undefined;
|
|
8
12
|
mathShowSearch: boolean | undefined;
|
|
13
|
+
reload: ({ options: changeOpts, params: requestParams }: ParamsModal) => void | Promise<OptionType[] | undefined>;
|
|
9
14
|
};
|
|
10
15
|
export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
|
|
16
|
+
export {};
|
|
@@ -52,6 +52,14 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
52
52
|
run = _useRequest.run,
|
|
53
53
|
loading = _useRequest.loading,
|
|
54
54
|
error = _useRequest.error;
|
|
55
|
+
var reload = function reload(_ref3) {
|
|
56
|
+
var changeOpts = _ref3.options,
|
|
57
|
+
requestParams = _ref3.params;
|
|
58
|
+
if (changeOpts) {
|
|
59
|
+
return setData(changeOpts);
|
|
60
|
+
}
|
|
61
|
+
return run(requestParams);
|
|
62
|
+
};
|
|
55
63
|
var onSearch = function onSearch(inputValue) {
|
|
56
64
|
if (!serviceSearch) {
|
|
57
65
|
propsOnSearch === null || propsOnSearch === void 0 ? void 0 : propsOnSearch(inputValue);
|
|
@@ -61,6 +69,11 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
61
69
|
inputValue: inputValue
|
|
62
70
|
});
|
|
63
71
|
};
|
|
72
|
+
React.useEffect(function () {
|
|
73
|
+
if (options) {
|
|
74
|
+
setData(options);
|
|
75
|
+
}
|
|
76
|
+
}, [options]);
|
|
64
77
|
var mathShowSearch = showSearch || serviceSearch;
|
|
65
78
|
return {
|
|
66
79
|
run: run,
|
|
@@ -68,12 +81,13 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
68
81
|
error: error,
|
|
69
82
|
data: data,
|
|
70
83
|
onSearch: mathShowSearch ? onSearch : propsOnSearch,
|
|
71
|
-
mathShowSearch: showSearch || serviceSearch
|
|
84
|
+
mathShowSearch: showSearch || serviceSearch,
|
|
85
|
+
reload: reload
|
|
72
86
|
};
|
|
73
87
|
};
|
|
74
|
-
var useFilterOption = function useFilterOption(
|
|
75
|
-
var filterOption =
|
|
76
|
-
serviceSearch =
|
|
88
|
+
var useFilterOption = function useFilterOption(_ref4) {
|
|
89
|
+
var filterOption = _ref4.filterOption,
|
|
90
|
+
serviceSearch = _ref4.serviceSearch;
|
|
77
91
|
if (serviceSearch) {
|
|
78
92
|
return function () {
|
|
79
93
|
return true;
|
package/lib/Select/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const _default: (
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
3
3
|
export default _default;
|
package/lib/Select/index.js
CHANGED
|
@@ -21,12 +21,13 @@ var defaultConfig = require('./defaultConfig.js');
|
|
|
21
21
|
var DropdownComponent = require('./components/DropdownComponent.js');
|
|
22
22
|
var AllSelect = require('./components/AllSelect.js');
|
|
23
23
|
var index = require('../hooks/index.js');
|
|
24
|
+
var HFormConnect = require('../Form/HFormConnect.js');
|
|
24
25
|
|
|
25
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect"];
|
|
26
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener"];
|
|
26
27
|
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; }
|
|
27
28
|
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; }
|
|
28
29
|
var Option = antd.Select.Option;
|
|
29
|
-
var
|
|
30
|
+
var Index = function Index(_ref) {
|
|
30
31
|
var _ref$style = _ref.style,
|
|
31
32
|
style = _ref$style === void 0 ? {
|
|
32
33
|
width: "100%"
|
|
@@ -53,6 +54,7 @@ var HSelect = (function (_ref) {
|
|
|
53
54
|
_ref$noMatchItemRende = _ref.noMatchItemRender,
|
|
54
55
|
noMatchItemRender = _ref$noMatchItemRende === void 0 ? defaultConfig.defaultSelectConfig.noMatchItemRender : _ref$noMatchItemRende,
|
|
55
56
|
allSelect = _ref.allSelect,
|
|
57
|
+
addDispatchListener = _ref.addDispatchListener,
|
|
56
58
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
59
|
var _ref2 = (modeConfig === null || modeConfig === void 0 ? void 0 : modeConfig[mode || ""]) || {},
|
|
58
60
|
icon = _ref2.icon,
|
|
@@ -79,7 +81,8 @@ var HSelect = (function (_ref) {
|
|
|
79
81
|
resultData = _useOptionReq.data,
|
|
80
82
|
error = _useOptionReq.error,
|
|
81
83
|
onSearch = _useOptionReq.onSearch,
|
|
82
|
-
mathShowSearch = _useOptionReq.mathShowSearch
|
|
84
|
+
mathShowSearch = _useOptionReq.mathShowSearch,
|
|
85
|
+
reload = _useOptionReq.reload;
|
|
83
86
|
var data = index.useChangeOptions({
|
|
84
87
|
options: resultData,
|
|
85
88
|
fieldNames: fieldNames
|
|
@@ -95,6 +98,7 @@ var HSelect = (function (_ref) {
|
|
|
95
98
|
}),
|
|
96
99
|
val = _useValueChange.val,
|
|
97
100
|
change = _useValueChange.change;
|
|
101
|
+
addDispatchListener === null || addDispatchListener === void 0 ? void 0 : addDispatchListener("reload", reload);
|
|
98
102
|
return jsxRuntime.jsx(antd.Select, _objectSpread(_objectSpread({
|
|
99
103
|
style: style,
|
|
100
104
|
mode: mode,
|
|
@@ -139,7 +143,8 @@ var HSelect = (function (_ref) {
|
|
|
139
143
|
}), optionValue);
|
|
140
144
|
})
|
|
141
145
|
}));
|
|
142
|
-
}
|
|
146
|
+
};
|
|
147
|
+
var HSelect = HFormConnect.default(Index);
|
|
143
148
|
|
|
144
149
|
exports.default = HSelect;
|
|
145
150
|
// powered by h
|
package/lib/Select/modal.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SelectProps } from "antd";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
import { argsFn } from "@/components/Form/modal";
|
|
4
5
|
export type OptionType = Record<string, any>;
|
|
5
6
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
6
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
@@ -22,6 +23,7 @@ export interface HSelectProps extends Omit<SelectProps, "options"> {
|
|
|
22
23
|
options?: OptionType[];
|
|
23
24
|
noMatchItemRender?: RenderFn;
|
|
24
25
|
allSelect?: boolean;
|
|
26
|
+
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
25
27
|
}
|
|
26
28
|
export interface FilterDataModal {
|
|
27
29
|
value: any;
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ export default ({
|
|
|
22
22
|
form,
|
|
23
23
|
footer,
|
|
24
24
|
params,
|
|
25
|
+
onValuesChange,
|
|
25
26
|
...props
|
|
26
27
|
}: DialogFormProps) => {
|
|
27
28
|
const currentForm = useCurrentForm(dialogForm);
|
|
@@ -74,6 +75,7 @@ export default ({
|
|
|
74
75
|
<HForm
|
|
75
76
|
configData={modalFormData}
|
|
76
77
|
initialValues={initValue}
|
|
78
|
+
onValuesChange={onValuesChange}
|
|
77
79
|
{...props}
|
|
78
80
|
form={currentForm}
|
|
79
81
|
params={formParams}
|
|
@@ -15,6 +15,7 @@ export default ({
|
|
|
15
15
|
onFinish,
|
|
16
16
|
params,
|
|
17
17
|
onOk,
|
|
18
|
+
onValuesChange,
|
|
18
19
|
...props
|
|
19
20
|
}: DialogFormProps) => {
|
|
20
21
|
const currentForm = useCurrentForm(dialogForm);
|
|
@@ -55,6 +56,7 @@ export default ({
|
|
|
55
56
|
<HForm
|
|
56
57
|
configData={modalFormData}
|
|
57
58
|
initialValues={initValue}
|
|
59
|
+
onValuesChange={onValuesChange}
|
|
58
60
|
onFinish={async (values, outParams) => {
|
|
59
61
|
const result = await run(values, outParams);
|
|
60
62
|
const close = onOk?.(result, outParams);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
import type {
|
|
3
3
|
OptionType,
|
|
4
4
|
PartialHSelectProps,
|
|
5
5
|
} from "@/components/Select/modal";
|
|
6
6
|
import { useRequest } from "ahooks";
|
|
7
7
|
|
|
8
|
+
interface ParamsModal{
|
|
9
|
+
options?: OptionType[];
|
|
10
|
+
params?:any;
|
|
11
|
+
}
|
|
8
12
|
export const useOptionReq = ({
|
|
9
13
|
manual,
|
|
10
14
|
request,
|
|
@@ -32,6 +36,12 @@ export const useOptionReq = ({
|
|
|
32
36
|
},
|
|
33
37
|
}
|
|
34
38
|
);
|
|
39
|
+
const reload=({options:changeOpts,params:requestParams}:ParamsModal)=>{
|
|
40
|
+
if (changeOpts){
|
|
41
|
+
return setData(changeOpts);
|
|
42
|
+
};
|
|
43
|
+
return run(requestParams);
|
|
44
|
+
}
|
|
35
45
|
const onSearch = (inputValue: string) => {
|
|
36
46
|
if (!serviceSearch) {
|
|
37
47
|
propsOnSearch?.(inputValue);
|
|
@@ -39,6 +49,11 @@ export const useOptionReq = ({
|
|
|
39
49
|
}
|
|
40
50
|
run({ inputValue });
|
|
41
51
|
};
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (options) {
|
|
54
|
+
setData(options);
|
|
55
|
+
}
|
|
56
|
+
}, [options]);
|
|
42
57
|
const mathShowSearch = showSearch || serviceSearch;
|
|
43
58
|
return {
|
|
44
59
|
run,
|
|
@@ -47,6 +62,7 @@ export const useOptionReq = ({
|
|
|
47
62
|
data,
|
|
48
63
|
onSearch: mathShowSearch ? onSearch : propsOnSearch,
|
|
49
64
|
mathShowSearch: showSearch || serviceSearch,
|
|
65
|
+
reload
|
|
50
66
|
};
|
|
51
67
|
};
|
|
52
68
|
|
|
@@ -7,9 +7,10 @@ import { defaultModeConfig, defaultSelectConfig } from "./defaultConfig";
|
|
|
7
7
|
import DropdownComponent from "./components/DropdownComponent";
|
|
8
8
|
import AllSelect from "./components/AllSelect";
|
|
9
9
|
import { useChangeOptions, useMatchConfigProps } from "../hooks";
|
|
10
|
+
import HFormConnect from "../Form/HFormConnect";
|
|
10
11
|
const { Option } = Select;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const Index: React.FC<HSelectProps> = ({
|
|
13
14
|
style = { width: "100%" },
|
|
14
15
|
mode,
|
|
15
16
|
options,
|
|
@@ -29,8 +30,9 @@ export default ({
|
|
|
29
30
|
labelInValue,
|
|
30
31
|
noMatchItemRender = defaultSelectConfig.noMatchItemRender,
|
|
31
32
|
allSelect,
|
|
33
|
+
addDispatchListener,
|
|
32
34
|
...props
|
|
33
|
-
}
|
|
35
|
+
}) => {
|
|
34
36
|
const { icon, render } = modeConfig?.[mode || ""] || {};
|
|
35
37
|
const { fieldNames } = useMatchConfigProps({ fieldNames: propsFieldNames });
|
|
36
38
|
|
|
@@ -42,6 +44,7 @@ export default ({
|
|
|
42
44
|
error,
|
|
43
45
|
onSearch,
|
|
44
46
|
mathShowSearch,
|
|
47
|
+
reload
|
|
45
48
|
} = useOptionReq({
|
|
46
49
|
options,
|
|
47
50
|
manual,
|
|
@@ -62,7 +65,7 @@ export default ({
|
|
|
62
65
|
noMatchItemRender,
|
|
63
66
|
fieldNames,
|
|
64
67
|
});
|
|
65
|
-
|
|
68
|
+
addDispatchListener?.("reload",reload);
|
|
66
69
|
return (
|
|
67
70
|
<Select
|
|
68
71
|
style={style}
|
|
@@ -118,3 +121,4 @@ export default ({
|
|
|
118
121
|
</Select>
|
|
119
122
|
);
|
|
120
123
|
};
|
|
124
|
+
export default HFormConnect(Index);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SelectProps } from "antd";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
+
import {argsFn} from "@/components/Form/modal";
|
|
4
5
|
export type OptionType = Record<string, any>;
|
|
5
6
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
6
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
@@ -23,6 +24,7 @@ export interface HSelectProps extends Omit<SelectProps, "options"> {
|
|
|
23
24
|
options?: OptionType[];
|
|
24
25
|
noMatchItemRender?: RenderFn; //没有数据
|
|
25
26
|
allSelect?: boolean; //显示全选
|
|
27
|
+
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
26
28
|
}
|
|
27
29
|
export interface FilterDataModal {
|
|
28
30
|
value: any;
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,119 +1,136 @@
|
|
|
1
1
|
import { HForm, HFormConfigProvider, useHForm } from "../../components";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
const formData = (options) => {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
label: "输入框",
|
|
8
|
+
name: "name",
|
|
9
|
+
rules: [
|
|
10
|
+
() => {
|
|
11
|
+
return {
|
|
12
|
+
required: true,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: "数字",
|
|
19
|
+
name: "sz",
|
|
20
|
+
type: "inputNumber",
|
|
21
|
+
rules: [{ required: true }],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "下拉框",
|
|
25
|
+
name: "select",
|
|
26
|
+
type: "select",
|
|
27
|
+
itemProps: {
|
|
28
|
+
request: (params={}) => {
|
|
29
|
+
const {label="123",value=1}=params;
|
|
30
|
+
return Promise.resolve([{ label, value }]);
|
|
31
|
+
},
|
|
30
32
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
rules: [{ required: true }],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "下拉输入框",
|
|
37
|
+
name: "selectInput",
|
|
38
|
+
type: "selectInput",
|
|
39
|
+
rules: [{ required: true }],
|
|
40
|
+
itemProps: {
|
|
41
|
+
valueName: {
|
|
42
|
+
select: "op",
|
|
43
|
+
input: "opInput",
|
|
44
|
+
},
|
|
45
|
+
selectProps: {
|
|
46
|
+
options: [{ label: "测试", value: 1 }],
|
|
47
|
+
},
|
|
33
48
|
},
|
|
34
49
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
50
|
+
{
|
|
51
|
+
label: "按钮输入框",
|
|
52
|
+
name: "buttonInput",
|
|
53
|
+
type: "buttonInput",
|
|
54
|
+
children: "点击",
|
|
55
|
+
rules: [{ required: true }],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "选择",
|
|
59
|
+
name: "checkboxGroup",
|
|
60
|
+
type: "checkboxGroup",
|
|
61
|
+
rules: [{ required: true }],
|
|
62
|
+
helper: "帮助我",
|
|
63
|
+
options: [
|
|
64
|
+
{ label: "选择1", value: "check1" },
|
|
65
|
+
{ label: "选择2", value: "check2" },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: "开关",
|
|
70
|
+
name: "switch",
|
|
71
|
+
type: "switch",
|
|
72
|
+
rules: [{ required: true }],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: "时间",
|
|
76
|
+
name: "datePicker",
|
|
77
|
+
type: "datePicker",
|
|
78
|
+
hover: "时间选择",
|
|
79
|
+
helper: "帮助我",
|
|
80
|
+
rules: [{ required: true }],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "时间段",
|
|
84
|
+
name: "rangePicker",
|
|
85
|
+
type: "rangePicker",
|
|
86
|
+
helper: "帮助我",
|
|
87
|
+
rules: [{ required: true }],
|
|
88
|
+
itemProps: {
|
|
89
|
+
valueMap: {
|
|
90
|
+
start: "testStart",
|
|
91
|
+
end: "testEnd",
|
|
92
|
+
},
|
|
78
93
|
},
|
|
79
94
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
{
|
|
96
|
+
label: "时分秒",
|
|
97
|
+
name: "timePicker",
|
|
98
|
+
type: "timePicker",
|
|
99
|
+
rules: [{ required: true }],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: "文件",
|
|
103
|
+
name: "upload",
|
|
104
|
+
type: "upload",
|
|
105
|
+
rules: [{ required: true }],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: "地址文件",
|
|
109
|
+
name: "urlUpload",
|
|
110
|
+
type: "urlUpload",
|
|
111
|
+
rules: [{ required: true }],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: "颜色",
|
|
115
|
+
name: "colorInput",
|
|
116
|
+
type: "colorInput",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "测试",
|
|
120
|
+
type: "test",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "submit",
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
};
|
|
112
127
|
const Test = (props) => {
|
|
113
128
|
return <div>ffff</div>;
|
|
114
129
|
};
|
|
115
130
|
export default () => {
|
|
116
131
|
const form = useHForm();
|
|
132
|
+
const [options, setOptions] = useState([{ label: "1", value: 1 }]);
|
|
133
|
+
|
|
117
134
|
return (
|
|
118
135
|
<div style={{ overflow: "auto", height: "90vh" }}>
|
|
119
136
|
<HFormConfigProvider
|
|
@@ -124,7 +141,7 @@ export default () => {
|
|
|
124
141
|
}}
|
|
125
142
|
>
|
|
126
143
|
<HForm
|
|
127
|
-
configData={
|
|
144
|
+
configData={formData(options)}
|
|
128
145
|
labelWidth={200}
|
|
129
146
|
form={form}
|
|
130
147
|
onFinish={(value) => {
|
|
@@ -156,6 +173,21 @@ export default () => {
|
|
|
156
173
|
}}
|
|
157
174
|
/>
|
|
158
175
|
</HFormConfigProvider>
|
|
176
|
+
<div
|
|
177
|
+
onClick={() => {
|
|
178
|
+
form.dispatch({
|
|
179
|
+
name:"select",
|
|
180
|
+
key:"reload"
|
|
181
|
+
},{
|
|
182
|
+
params:{
|
|
183
|
+
label:"更新",
|
|
184
|
+
value:2
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
点我
|
|
190
|
+
</div>
|
|
159
191
|
</div>
|
|
160
192
|
);
|
|
161
193
|
};
|