@hw-component/form 1.9.38 → 1.9.40
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/Basic.js +2 -1
- package/es/Form/hooks/useInitConfigData.js +3 -2
- package/es/Form/modal.d.ts +1 -1
- package/es/Switch/index.d.ts +2 -0
- package/es/Switch/index.js +33 -4
- package/es/Upload/MediaTypeEle/TypeEle.js +3 -0
- package/lib/Form/Basic.js +2 -1
- package/lib/Form/hooks/useInitConfigData.js +3 -2
- package/lib/Form/modal.d.ts +1 -1
- package/lib/Switch/index.d.ts +2 -0
- package/lib/Switch/index.js +33 -4
- package/lib/Upload/MediaTypeEle/TypeEle.js +3 -0
- package/package.json +1 -1
- package/src/components/Form/Basic.tsx +2 -1
- package/src/components/Form/hooks/useInitConfigData.tsx +3 -2
- package/src/components/Form/modal.ts +1 -1
- package/src/components/Switch/index.tsx +13 -4
- package/src/components/Upload/MediaTypeEle/TypeEle.tsx +1 -1
- package/src/components/Upload/UrlUpload/index.tsx +1 -1
- package/src/pages/Form/index.tsx +9 -1
- package/src/pages/ModalForm/index.tsx +121 -126
- package/src/pages/Switch/index.tsx +12 -4
- package/src/pages/Upload/index.tsx +2 -1
package/es/Form/Basic.js
CHANGED
|
@@ -55,7 +55,8 @@ var Basic = (function (_ref) {
|
|
|
55
55
|
var defaultItemProps = _objectSpread(_objectSpread({
|
|
56
56
|
onPressEnter: dismissOnPressEnter ? undefined : defaultOnPressEnter
|
|
57
57
|
}, formItemProps), itemProps);
|
|
58
|
-
var
|
|
58
|
+
var arrayName = Array.isArray(name) ? name.join(".") : name;
|
|
59
|
+
var key = arrayName || nameKey;
|
|
59
60
|
return /*#__PURE__*/createElement(Item, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
60
61
|
labelAlign: labelAlign,
|
|
61
62
|
key: key || index,
|
|
@@ -106,6 +106,7 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
|
|
|
106
106
|
dispatch = _item$dispatch === void 0 ? {} : _item$dispatch,
|
|
107
107
|
_item$dependencies = item.dependencies,
|
|
108
108
|
dependencies = _item$dependencies === void 0 ? "allDependencies" : _item$dependencies;
|
|
109
|
+
var relName = Array.isArray(name) ? name.join(".") : name;
|
|
109
110
|
var fnKey = dispatch.fnKey,
|
|
110
111
|
_dispatch$dependencie = dispatch.dependencies,
|
|
111
112
|
dispatchDependencies = _dispatch$dependencie === void 0 ? dependencies : _dispatch$dependencie,
|
|
@@ -119,7 +120,7 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
|
|
|
119
120
|
if (Array.isArray(dispatchDependencies)) {
|
|
120
121
|
var allDispatch = _objectSpread({}, dispatchSourceData);
|
|
121
122
|
dispatchDependencies.forEach(function (key) {
|
|
122
|
-
var itemDispatch = itemDispatchProvider(
|
|
123
|
+
var itemDispatch = itemDispatchProvider(relName, {
|
|
123
124
|
dependencies: key,
|
|
124
125
|
fnKey: fnKey,
|
|
125
126
|
manual: manual,
|
|
@@ -129,7 +130,7 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
|
|
|
129
130
|
});
|
|
130
131
|
return allDispatch;
|
|
131
132
|
}
|
|
132
|
-
var itemDispatch = itemDispatchProvider(
|
|
133
|
+
var itemDispatch = itemDispatchProvider(relName, {
|
|
133
134
|
dependencies: dispatchDependencies,
|
|
134
135
|
fnKey: fnKey,
|
|
135
136
|
manual: manual,
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign" |
|
|
|
45
45
|
labelWidth?: number;
|
|
46
46
|
hide?: boolean | HideModal;
|
|
47
47
|
placeholder?: string | string[];
|
|
48
|
-
name?: string;
|
|
48
|
+
name?: string | string[];
|
|
49
49
|
dispatch?: DispatchModal;
|
|
50
50
|
itemSpan?: ColProps;
|
|
51
51
|
hideLabel?: boolean;
|
package/es/Switch/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import type { SwitchProps } from "antd";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { ValueSwitchMapModal } from "../modal";
|
|
4
4
|
import type { addFormatItemModal } from "../Form/modal";
|
|
5
|
+
import { PromiseFnResult } from "../modal";
|
|
5
6
|
export interface HSwitchProps extends Omit<SwitchProps, "onChange"> {
|
|
6
7
|
valueMap?: ValueSwitchMapModal;
|
|
7
8
|
value?: any;
|
|
8
9
|
onChange?: (val: any) => void;
|
|
9
10
|
beforeText?: React.ReactNode;
|
|
10
11
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
12
|
+
request?: PromiseFnResult;
|
|
11
13
|
}
|
|
12
14
|
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
13
15
|
export default _default;
|
package/es/Switch/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
2
|
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
4
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
4
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
7
|
import { Switch } from 'antd';
|
|
6
8
|
import { useMemo } from 'react';
|
|
7
9
|
import { useMatchConfigProps, useClassName } from '../hooks/index.js';
|
|
8
10
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
11
|
+
import { useRequest } from 'ahooks';
|
|
9
12
|
|
|
10
|
-
var _excluded = ["value", "onChange", "valueMap", "children", "unCheckedChildren", "checkedChildren", "beforeText", "addFormat", "style"];
|
|
13
|
+
var _excluded = ["value", "onChange", "valueMap", "children", "unCheckedChildren", "checkedChildren", "beforeText", "addFormat", "style", "request"];
|
|
11
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
16
|
var Index = function Index(_ref) {
|
|
@@ -22,6 +25,7 @@ var Index = function Index(_ref) {
|
|
|
22
25
|
beforeText = _ref.beforeText,
|
|
23
26
|
addFormat = _ref.addFormat,
|
|
24
27
|
style = _ref.style,
|
|
28
|
+
request = _ref.request,
|
|
25
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
30
|
var _useMatchConfigProps = useMatchConfigProps({
|
|
27
31
|
valueSwitchMap: propsValueSwitchMap
|
|
@@ -31,14 +35,38 @@ var Index = function Index(_ref) {
|
|
|
31
35
|
var switchClassName = useClassName("hw-switch");
|
|
32
36
|
var switchBefore = useClassName("hw-switch-before");
|
|
33
37
|
var switchAfter = useClassName("hw-switch-after");
|
|
38
|
+
var _useRequest = useRequest(/*#__PURE__*/function () {
|
|
39
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(val) {
|
|
40
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
_context.next = 2;
|
|
44
|
+
return request === null || request === void 0 ? void 0 : request(val);
|
|
45
|
+
case 2:
|
|
46
|
+
onChange === null || onChange === void 0 || onChange(val);
|
|
47
|
+
case 3:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
50
|
+
}
|
|
51
|
+
}, _callee);
|
|
52
|
+
}));
|
|
53
|
+
return function (_x) {
|
|
54
|
+
return _ref2.apply(this, arguments);
|
|
55
|
+
};
|
|
56
|
+
}(), {
|
|
57
|
+
manual: true
|
|
58
|
+
}),
|
|
59
|
+
run = _useRequest.run,
|
|
60
|
+
loading = _useRequest.loading;
|
|
34
61
|
var swChecked = useMemo(function () {
|
|
35
62
|
var open = valueSwitchMap.open;
|
|
36
63
|
return value === open;
|
|
37
64
|
}, [value]);
|
|
38
65
|
var change = function change(checked) {
|
|
39
|
-
var subVal = valueSwitchMap.close;
|
|
40
|
-
if (
|
|
41
|
-
subVal
|
|
66
|
+
var subVal = checked ? valueSwitchMap.open : valueSwitchMap.close;
|
|
67
|
+
if (request) {
|
|
68
|
+
run(subVal);
|
|
69
|
+
return;
|
|
42
70
|
}
|
|
43
71
|
onChange === null || onChange === void 0 || onChange(subVal);
|
|
44
72
|
};
|
|
@@ -69,6 +97,7 @@ var Index = function Index(_ref) {
|
|
|
69
97
|
children: beforeText
|
|
70
98
|
}), jsx(Switch, _objectSpread({
|
|
71
99
|
checked: swChecked,
|
|
100
|
+
loading: loading,
|
|
72
101
|
checkedChildren: checkedChildren,
|
|
73
102
|
unCheckedChildren: unCheckedChildren,
|
|
74
103
|
onChange: change
|
package/lib/Form/Basic.js
CHANGED
|
@@ -58,7 +58,8 @@ var Basic = (function (_ref) {
|
|
|
58
58
|
var defaultItemProps = _objectSpread(_objectSpread({
|
|
59
59
|
onPressEnter: dismissOnPressEnter ? undefined : defaultOnPressEnter
|
|
60
60
|
}, formItemProps), itemProps);
|
|
61
|
-
var
|
|
61
|
+
var arrayName = Array.isArray(name) ? name.join(".") : name;
|
|
62
|
+
var key = arrayName || nameKey;
|
|
62
63
|
return /*#__PURE__*/React.createElement(index$1.default, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
63
64
|
labelAlign: labelAlign,
|
|
64
65
|
key: key || index,
|
|
@@ -109,6 +109,7 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
|
|
|
109
109
|
dispatch = _item$dispatch === void 0 ? {} : _item$dispatch,
|
|
110
110
|
_item$dependencies = item.dependencies,
|
|
111
111
|
dependencies = _item$dependencies === void 0 ? "allDependencies" : _item$dependencies;
|
|
112
|
+
var relName = Array.isArray(name) ? name.join(".") : name;
|
|
112
113
|
var fnKey = dispatch.fnKey,
|
|
113
114
|
_dispatch$dependencie = dispatch.dependencies,
|
|
114
115
|
dispatchDependencies = _dispatch$dependencie === void 0 ? dependencies : _dispatch$dependencie,
|
|
@@ -122,7 +123,7 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
|
|
|
122
123
|
if (Array.isArray(dispatchDependencies)) {
|
|
123
124
|
var allDispatch = _objectSpread({}, dispatchSourceData);
|
|
124
125
|
dispatchDependencies.forEach(function (key) {
|
|
125
|
-
var itemDispatch = itemDispatchProvider(
|
|
126
|
+
var itemDispatch = itemDispatchProvider(relName, {
|
|
126
127
|
dependencies: key,
|
|
127
128
|
fnKey: fnKey,
|
|
128
129
|
manual: manual,
|
|
@@ -132,7 +133,7 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
|
|
|
132
133
|
});
|
|
133
134
|
return allDispatch;
|
|
134
135
|
}
|
|
135
|
-
var itemDispatch = itemDispatchProvider(
|
|
136
|
+
var itemDispatch = itemDispatchProvider(relName, {
|
|
136
137
|
dependencies: dispatchDependencies,
|
|
137
138
|
fnKey: fnKey,
|
|
138
139
|
manual: manual,
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign" |
|
|
|
45
45
|
labelWidth?: number;
|
|
46
46
|
hide?: boolean | HideModal;
|
|
47
47
|
placeholder?: string | string[];
|
|
48
|
-
name?: string;
|
|
48
|
+
name?: string | string[];
|
|
49
49
|
dispatch?: DispatchModal;
|
|
50
50
|
itemSpan?: ColProps;
|
|
51
51
|
hideLabel?: boolean;
|
package/lib/Switch/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import type { SwitchProps } from "antd";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { ValueSwitchMapModal } from "../modal";
|
|
4
4
|
import type { addFormatItemModal } from "../Form/modal";
|
|
5
|
+
import { PromiseFnResult } from "../modal";
|
|
5
6
|
export interface HSwitchProps extends Omit<SwitchProps, "onChange"> {
|
|
6
7
|
valueMap?: ValueSwitchMapModal;
|
|
7
8
|
value?: any;
|
|
8
9
|
onChange?: (val: any) => void;
|
|
9
10
|
beforeText?: React.ReactNode;
|
|
10
11
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
12
|
+
request?: PromiseFnResult;
|
|
11
13
|
}
|
|
12
14
|
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
13
15
|
export default _default;
|
package/lib/Switch/index.js
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
6
7
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
7
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
10
|
var antd = require('antd');
|
|
9
11
|
var React = require('react');
|
|
10
12
|
var index = require('../hooks/index.js');
|
|
11
13
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
14
|
+
var ahooks = require('ahooks');
|
|
12
15
|
|
|
13
|
-
var _excluded = ["value", "onChange", "valueMap", "children", "unCheckedChildren", "checkedChildren", "beforeText", "addFormat", "style"];
|
|
16
|
+
var _excluded = ["value", "onChange", "valueMap", "children", "unCheckedChildren", "checkedChildren", "beforeText", "addFormat", "style", "request"];
|
|
14
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
19
|
var Index = function Index(_ref) {
|
|
@@ -25,6 +28,7 @@ var Index = function Index(_ref) {
|
|
|
25
28
|
beforeText = _ref.beforeText,
|
|
26
29
|
addFormat = _ref.addFormat,
|
|
27
30
|
style = _ref.style,
|
|
31
|
+
request = _ref.request,
|
|
28
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
33
|
var _useMatchConfigProps = index.useMatchConfigProps({
|
|
30
34
|
valueSwitchMap: propsValueSwitchMap
|
|
@@ -34,14 +38,38 @@ var Index = function Index(_ref) {
|
|
|
34
38
|
var switchClassName = index.useClassName("hw-switch");
|
|
35
39
|
var switchBefore = index.useClassName("hw-switch-before");
|
|
36
40
|
var switchAfter = index.useClassName("hw-switch-after");
|
|
41
|
+
var _useRequest = ahooks.useRequest(/*#__PURE__*/function () {
|
|
42
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(val) {
|
|
43
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
_context.next = 2;
|
|
47
|
+
return request === null || request === void 0 ? void 0 : request(val);
|
|
48
|
+
case 2:
|
|
49
|
+
onChange === null || onChange === void 0 || onChange(val);
|
|
50
|
+
case 3:
|
|
51
|
+
case "end":
|
|
52
|
+
return _context.stop();
|
|
53
|
+
}
|
|
54
|
+
}, _callee);
|
|
55
|
+
}));
|
|
56
|
+
return function (_x) {
|
|
57
|
+
return _ref2.apply(this, arguments);
|
|
58
|
+
};
|
|
59
|
+
}(), {
|
|
60
|
+
manual: true
|
|
61
|
+
}),
|
|
62
|
+
run = _useRequest.run,
|
|
63
|
+
loading = _useRequest.loading;
|
|
37
64
|
var swChecked = React.useMemo(function () {
|
|
38
65
|
var open = valueSwitchMap.open;
|
|
39
66
|
return value === open;
|
|
40
67
|
}, [value]);
|
|
41
68
|
var change = function change(checked) {
|
|
42
|
-
var subVal = valueSwitchMap.close;
|
|
43
|
-
if (
|
|
44
|
-
subVal
|
|
69
|
+
var subVal = checked ? valueSwitchMap.open : valueSwitchMap.close;
|
|
70
|
+
if (request) {
|
|
71
|
+
run(subVal);
|
|
72
|
+
return;
|
|
45
73
|
}
|
|
46
74
|
onChange === null || onChange === void 0 || onChange(subVal);
|
|
47
75
|
};
|
|
@@ -72,6 +100,7 @@ var Index = function Index(_ref) {
|
|
|
72
100
|
children: beforeText
|
|
73
101
|
}), jsxRuntime.jsx(antd.Switch, _objectSpread({
|
|
74
102
|
checked: swChecked,
|
|
103
|
+
loading: loading,
|
|
75
104
|
checkedChildren: checkedChildren,
|
|
76
105
|
unCheckedChildren: unCheckedChildren,
|
|
77
106
|
onChange: change
|
package/package.json
CHANGED
|
@@ -135,6 +135,7 @@ const dispatchProvider = (
|
|
|
135
135
|
dispatchSourceData: DispatchSourceDataModal
|
|
136
136
|
) => {
|
|
137
137
|
const { name = "", dispatch = {}, dependencies = "allDependencies" } = item;
|
|
138
|
+
const relName=Array.isArray(name)?name.join("."):name;
|
|
138
139
|
const {
|
|
139
140
|
fnKey,
|
|
140
141
|
dependencies: dispatchDependencies = dependencies as string | string[],
|
|
@@ -150,7 +151,7 @@ const dispatchProvider = (
|
|
|
150
151
|
};
|
|
151
152
|
dispatchDependencies.forEach((key) => {
|
|
152
153
|
const itemDispatch = itemDispatchProvider(
|
|
153
|
-
|
|
154
|
+
relName,
|
|
154
155
|
{ dependencies: key, fnKey, manual, reset },
|
|
155
156
|
dispatchSourceData
|
|
156
157
|
);
|
|
@@ -162,7 +163,7 @@ const dispatchProvider = (
|
|
|
162
163
|
return allDispatch;
|
|
163
164
|
}
|
|
164
165
|
const itemDispatch = itemDispatchProvider(
|
|
165
|
-
|
|
166
|
+
relName,
|
|
166
167
|
{ dependencies: dispatchDependencies, fnKey, manual, reset },
|
|
167
168
|
dispatchSourceData
|
|
168
169
|
);
|
|
@@ -5,6 +5,8 @@ import { useClassName, useMatchConfigProps } from "../hooks";
|
|
|
5
5
|
import type { ValueSwitchMapModal } from "../modal";
|
|
6
6
|
import type { addFormatItemModal } from "../Form/modal";
|
|
7
7
|
import HFormConnect from "../Form/HFormConnect";
|
|
8
|
+
import {PromiseFnResult} from "../modal";
|
|
9
|
+
import {useRequest} from "ahooks";
|
|
8
10
|
|
|
9
11
|
export interface HSwitchProps extends Omit<SwitchProps, "onChange"> {
|
|
10
12
|
valueMap?: ValueSwitchMapModal;
|
|
@@ -12,6 +14,7 @@ export interface HSwitchProps extends Omit<SwitchProps, "onChange"> {
|
|
|
12
14
|
onChange?: (val: any) => void;
|
|
13
15
|
beforeText?: React.ReactNode;
|
|
14
16
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
17
|
+
request?:PromiseFnResult
|
|
15
18
|
}
|
|
16
19
|
const Index: React.FC<HSwitchProps> = ({
|
|
17
20
|
value,
|
|
@@ -23,6 +26,7 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
23
26
|
beforeText,
|
|
24
27
|
addFormat,
|
|
25
28
|
style,
|
|
29
|
+
request,
|
|
26
30
|
...props
|
|
27
31
|
}) => {
|
|
28
32
|
const { valueSwitchMap = {} } = useMatchConfigProps({
|
|
@@ -31,15 +35,19 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
31
35
|
const switchClassName = useClassName("hw-switch");
|
|
32
36
|
const switchBefore = useClassName("hw-switch-before");
|
|
33
37
|
const switchAfter = useClassName("hw-switch-after");
|
|
34
|
-
|
|
38
|
+
const {run,loading}=useRequest(async (val)=>{
|
|
39
|
+
await request?.(val);
|
|
40
|
+
onChange?.(val);
|
|
41
|
+
},{manual:true});
|
|
35
42
|
const swChecked = useMemo(() => {
|
|
36
43
|
const { open } = valueSwitchMap;
|
|
37
44
|
return value === open;
|
|
38
45
|
}, [value]);
|
|
39
46
|
const change = (checked) => {
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
subVal
|
|
47
|
+
const subVal = checked?valueSwitchMap.open:valueSwitchMap.close;
|
|
48
|
+
if (request){
|
|
49
|
+
run(subVal);
|
|
50
|
+
return;
|
|
43
51
|
}
|
|
44
52
|
onChange?.(subVal);
|
|
45
53
|
};
|
|
@@ -69,6 +77,7 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
69
77
|
{beforeText && <span className={switchBefore}>{beforeText}</span>}
|
|
70
78
|
<Switch
|
|
71
79
|
checked={swChecked}
|
|
80
|
+
loading={loading}
|
|
72
81
|
checkedChildren={checkedChildren}
|
|
73
82
|
unCheckedChildren={unCheckedChildren}
|
|
74
83
|
onChange={change}
|
|
@@ -24,7 +24,7 @@ export default ({ mediaType, url, onReady, onError }: TypeEleProps) => {
|
|
|
24
24
|
|
|
25
25
|
if (mediaType === MediaTypeEnum.audio) {
|
|
26
26
|
return (
|
|
27
|
-
<audio autoPlay controls
|
|
27
|
+
<audio autoPlay controls style={{width:"100%"}} onPlay={onReady} onError={onError}>
|
|
28
28
|
<source src={url} />
|
|
29
29
|
</audio>
|
|
30
30
|
);
|
|
@@ -103,7 +103,7 @@ const Index = ({
|
|
|
103
103
|
}}
|
|
104
104
|
/>
|
|
105
105
|
{inputHelper && <Text type={"secondary"}>{inputHelper}</Text>}
|
|
106
|
-
<Upload {...upProps} ref={ref} value={value} onChange={onChange}
|
|
106
|
+
<Upload {...upProps} ref={ref} value={value} onChange={onChange}/>
|
|
107
107
|
{load && (
|
|
108
108
|
<div style={{ display: "none" }}>
|
|
109
109
|
<TypeEle
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -12,95 +12,95 @@ const Test = (props) => {
|
|
|
12
12
|
return <HUrlUpload {...props} />;
|
|
13
13
|
};
|
|
14
14
|
const data = [
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
15
|
+
// {
|
|
16
|
+
// label: "输入框",
|
|
17
|
+
// name: "name",
|
|
18
|
+
// hideLabel: true,
|
|
19
|
+
// rules: [
|
|
20
|
+
// () => {
|
|
21
|
+
// return {
|
|
22
|
+
// required: true,
|
|
23
|
+
// };
|
|
24
|
+
// },
|
|
25
|
+
// ],
|
|
26
|
+
// },
|
|
27
|
+
// {
|
|
28
|
+
// label: "数字",
|
|
29
|
+
// name: "sz",
|
|
30
|
+
// type: "inputNumber",
|
|
31
|
+
// rules: [{ required: true }],
|
|
32
|
+
// },
|
|
33
|
+
// {
|
|
34
|
+
// label: "下拉输入框",
|
|
35
|
+
// name: "selectInput",
|
|
36
|
+
// type: "selectInput",
|
|
37
|
+
// rules: [{ required: true }],
|
|
38
|
+
// itemProps: {
|
|
39
|
+
// valueName: {
|
|
40
|
+
// select: "op",
|
|
41
|
+
// input: "opInput",
|
|
42
|
+
// },
|
|
43
|
+
// selectProps: {
|
|
44
|
+
// options: [{ label: "测试", value: 1 }],
|
|
45
|
+
// },
|
|
46
|
+
// },
|
|
47
|
+
// },
|
|
48
|
+
// {
|
|
49
|
+
// label: "按钮输入框",
|
|
50
|
+
// name: "buttonInput",
|
|
51
|
+
// type: "buttonInput",
|
|
52
|
+
// children: "点击",
|
|
53
|
+
// rules: [{ required: true }],
|
|
54
|
+
// },
|
|
55
|
+
// {
|
|
56
|
+
// label: "选择",
|
|
57
|
+
// name: "checkboxGroup",
|
|
58
|
+
// type: "checkboxGroup",
|
|
59
|
+
// rules: [{ required: true }],
|
|
60
|
+
// helper: "帮助我",
|
|
61
|
+
// options: [
|
|
62
|
+
// { label: "选择1", value: "check1" },
|
|
63
|
+
// { label: "选择2", value: "check2" },
|
|
64
|
+
// ],
|
|
65
|
+
// },
|
|
66
|
+
// {
|
|
67
|
+
// label: "开关",
|
|
68
|
+
// name: "switch",
|
|
69
|
+
// type: "switch",
|
|
70
|
+
// rules: [{ required: true }],
|
|
71
|
+
// },
|
|
72
|
+
// {
|
|
73
|
+
// label: "时间",
|
|
74
|
+
// name: "datePicker",
|
|
75
|
+
// type: "datePicker",
|
|
76
|
+
// hover: "时间选择",
|
|
77
|
+
// helper: "帮助我",
|
|
78
|
+
// rules: [{ required: true }],
|
|
79
|
+
// },
|
|
80
|
+
// {
|
|
81
|
+
// label: "时间段",
|
|
82
|
+
// name: "rangePicker",
|
|
83
|
+
// type: "rangePicker",
|
|
84
|
+
// helper: "帮助我",
|
|
85
|
+
// rules: [{ required: true }],
|
|
86
|
+
// itemProps: {
|
|
87
|
+
// valueMap: {
|
|
88
|
+
// start: "testStart",
|
|
89
|
+
// end: "testEnd",
|
|
90
|
+
// },
|
|
91
|
+
// },
|
|
92
|
+
// },
|
|
93
|
+
// {
|
|
94
|
+
// label: "时分秒",
|
|
95
|
+
// name: "timePicker",
|
|
96
|
+
// type: "timePicker",
|
|
97
|
+
// rules: [{ required: true }],
|
|
98
|
+
// itemProps: {
|
|
99
|
+
// subProvider: () => {
|
|
100
|
+
// console.log("fff");
|
|
101
|
+
// },
|
|
102
|
+
// },
|
|
103
|
+
// },
|
|
104
104
|
{
|
|
105
105
|
label: "文件",
|
|
106
106
|
name: "upload",
|
|
@@ -110,38 +110,36 @@ const data = [
|
|
|
110
110
|
{
|
|
111
111
|
label: "地址文件",
|
|
112
112
|
name: "urlUpload",
|
|
113
|
-
|
|
114
|
-
return <Test />;
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
label: "下拉框",
|
|
119
|
-
name: "select",
|
|
120
|
-
type: "select",
|
|
121
|
-
dispatch: {
|
|
122
|
-
fnKey: "reload",
|
|
123
|
-
dependencies: ["selectInput", "sz"],
|
|
124
|
-
manual: false,
|
|
125
|
-
},
|
|
126
|
-
itemProps: {
|
|
127
|
-
request: (params = {}, values) => {
|
|
128
|
-
const { label = "123", value = 1 } = params;
|
|
129
|
-
return Promise.resolve([{ label, value }]);
|
|
130
|
-
},
|
|
131
|
-
showSearch: true,
|
|
132
|
-
},
|
|
133
|
-
rules: [{ required: true }],
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
label: "验证码",
|
|
137
|
-
type: "verificationCodeInput",
|
|
138
|
-
name: "verificationCodeInput",
|
|
139
|
-
itemProps: {
|
|
140
|
-
request: () => {
|
|
141
|
-
return Promise.resolve({ code: 200 });
|
|
142
|
-
},
|
|
143
|
-
},
|
|
113
|
+
type: "urlUpload",
|
|
144
114
|
},
|
|
115
|
+
// {
|
|
116
|
+
// label: "下拉框",
|
|
117
|
+
// name: "select",
|
|
118
|
+
// type: "select",
|
|
119
|
+
// dispatch: {
|
|
120
|
+
// fnKey: "reload",
|
|
121
|
+
// dependencies: ["selectInput", "sz"],
|
|
122
|
+
// manual: false,
|
|
123
|
+
// },
|
|
124
|
+
// itemProps: {
|
|
125
|
+
// request: (params = {}, values) => {
|
|
126
|
+
// const { label = "123", value = 1 } = params;
|
|
127
|
+
// return Promise.resolve([{ label, value }]);
|
|
128
|
+
// },
|
|
129
|
+
// showSearch: true,
|
|
130
|
+
// },
|
|
131
|
+
// rules: [{ required: true }],
|
|
132
|
+
// },
|
|
133
|
+
// {
|
|
134
|
+
// label: "验证码",
|
|
135
|
+
// type: "verificationCodeInput",
|
|
136
|
+
// name: "verificationCodeInput",
|
|
137
|
+
// itemProps: {
|
|
138
|
+
// request: () => {
|
|
139
|
+
// return Promise.resolve({ code: 200 });
|
|
140
|
+
// },
|
|
141
|
+
// },
|
|
142
|
+
// },
|
|
145
143
|
];
|
|
146
144
|
let num = 0;
|
|
147
145
|
const Test1 = ({ formNode }) => {
|
|
@@ -163,12 +161,6 @@ export default () => {
|
|
|
163
161
|
onClick={() => {
|
|
164
162
|
num++;
|
|
165
163
|
modalForm.show({
|
|
166
|
-
params: {
|
|
167
|
-
name: num,
|
|
168
|
-
},
|
|
169
|
-
initialValues: {
|
|
170
|
-
urlUpload: "ffff",
|
|
171
|
-
},
|
|
172
164
|
});
|
|
173
165
|
}}
|
|
174
166
|
>
|
|
@@ -200,6 +192,9 @@ export default () => {
|
|
|
200
192
|
<HModalForm
|
|
201
193
|
configData={data}
|
|
202
194
|
labelWidth={88}
|
|
195
|
+
infoRequest={()=>{
|
|
196
|
+
console.log("infoRequest")
|
|
197
|
+
}}
|
|
203
198
|
labelAlign={"left"}
|
|
204
199
|
request={(values, params) => {
|
|
205
200
|
console.log(values, params);
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Space } from "antd";
|
|
2
2
|
import { HSwitch } from "../../components";
|
|
3
|
+
import {useState} from "react";
|
|
4
|
+
const req=()=>{
|
|
5
|
+
return new Promise((resolve, reject)=>{
|
|
6
|
+
setTimeout(()=>{
|
|
7
|
+
resolve({})
|
|
8
|
+
},2000)
|
|
9
|
+
})
|
|
10
|
+
}
|
|
3
11
|
export default () => {
|
|
12
|
+
const [val,setVal]=useState();
|
|
4
13
|
return (
|
|
5
14
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
6
15
|
<HSwitch
|
|
@@ -16,12 +25,11 @@ export default () => {
|
|
|
16
25
|
</HSwitch>
|
|
17
26
|
|
|
18
27
|
<HSwitch
|
|
19
|
-
value={
|
|
28
|
+
value={val}
|
|
20
29
|
beforeText="开关"
|
|
21
30
|
valueMap={{ open: 1, close: 0 }}
|
|
22
|
-
onChange={
|
|
23
|
-
|
|
24
|
-
}}
|
|
31
|
+
onChange={setVal}
|
|
32
|
+
request={req}
|
|
25
33
|
>
|
|
26
34
|
手机设备发送微信红包
|
|
27
35
|
</HSwitch>
|
|
@@ -21,6 +21,7 @@ export default () => {
|
|
|
21
21
|
onChange={setFiles}
|
|
22
22
|
multiple={true}
|
|
23
23
|
maxCount={3}
|
|
24
|
+
|
|
24
25
|
maxSize={Number.MAX_SAFE_INTEGER}
|
|
25
26
|
/>
|
|
26
27
|
<HUpload
|
|
@@ -32,7 +33,7 @@ export default () => {
|
|
|
32
33
|
}}
|
|
33
34
|
onChange={setFiles1}
|
|
34
35
|
/>
|
|
35
|
-
<HUrlUpload inputHelper="测试" />
|
|
36
|
+
<HUrlUpload inputHelper="测试" mediaType={MediaTypeEnum.video} value={files} onChange={setFiles}/>
|
|
36
37
|
</Space>
|
|
37
38
|
);
|
|
38
39
|
};
|