@hw-component/form 1.9.18 → 1.9.20
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/hooks/index.js +9 -5
- package/es/Switch/index.js +17 -9
- package/es/index.css +19 -0
- package/lib/Form/hooks/index.js +9 -5
- package/lib/Switch/index.js +15 -7
- package/lib/index.css +19 -0
- package/package.json +1 -1
- package/src/components/DialogForm/hooks.ts +1 -0
- package/src/components/Form/hooks/index.ts +5 -3
- package/src/components/Switch/index.less +11 -0
- package/src/components/Switch/index.tsx +17 -11
- package/src/components/styles/index.less +1 -0
- package/src/pages/Switch/index.tsx +12 -0
package/es/Form/hooks/index.js
CHANGED
|
@@ -58,7 +58,6 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
58
58
|
var infoControl = useRequest(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
59
59
|
var reqParams,
|
|
60
60
|
result,
|
|
61
|
-
setValue,
|
|
62
61
|
_args2 = arguments;
|
|
63
62
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
64
63
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -76,10 +75,15 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
76
75
|
form === null || form === void 0 || form.setFieldsValue(result);
|
|
77
76
|
return _context2.abrupt("return", result || {});
|
|
78
77
|
case 8:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
if (!(typeof initialValues === "undefined")) {
|
|
79
|
+
_context2.next = 10;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return _context2.abrupt("return", {});
|
|
83
|
+
case 10:
|
|
84
|
+
form === null || form === void 0 || form.setFieldsValue(initialValues);
|
|
85
|
+
return _context2.abrupt("return", initialValues);
|
|
86
|
+
case 12:
|
|
83
87
|
case "end":
|
|
84
88
|
return _context2.stop();
|
|
85
89
|
}
|
package/es/Switch/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
5
|
+
import { Switch } from 'antd';
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
|
-
import { useMatchConfigProps } from '../hooks/index.js';
|
|
7
|
+
import { useMatchConfigProps, useClassName } from '../hooks/index.js';
|
|
8
8
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
9
9
|
|
|
10
10
|
var _excluded = ["value", "onChange", "valueMap", "children", "unCheckedChildren", "checkedChildren", "beforeText", "addFormat", "style"];
|
|
@@ -28,6 +28,8 @@ var Index = function Index(_ref) {
|
|
|
28
28
|
}),
|
|
29
29
|
_useMatchConfigProps$ = _useMatchConfigProps.valueSwitchMap,
|
|
30
30
|
valueSwitchMap = _useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$;
|
|
31
|
+
var switchClassName = useClassName("hw-switch");
|
|
32
|
+
var switchBody = useClassName("hw-switch-body");
|
|
31
33
|
var swChecked = useMemo(function () {
|
|
32
34
|
var open = valueSwitchMap.open;
|
|
33
35
|
return value === open;
|
|
@@ -58,14 +60,20 @@ var Index = function Index(_ref) {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
|
-
return jsxs(
|
|
63
|
+
return jsxs("div", {
|
|
62
64
|
style: style,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
className: switchClassName,
|
|
66
|
+
children: [jsx("span", {
|
|
67
|
+
children: beforeText
|
|
68
|
+
}), jsx("div", {
|
|
69
|
+
className: switchBody,
|
|
70
|
+
children: jsx(Switch, _objectSpread({
|
|
71
|
+
checked: swChecked,
|
|
72
|
+
checkedChildren: checkedChildren,
|
|
73
|
+
unCheckedChildren: unCheckedChildren,
|
|
74
|
+
onChange: change
|
|
75
|
+
}, props))
|
|
76
|
+
}), jsx("span", {
|
|
69
77
|
children: children
|
|
70
78
|
})]
|
|
71
79
|
});
|
package/es/index.css
CHANGED
|
@@ -212,3 +212,22 @@
|
|
|
212
212
|
.ant-hw-color-input-picker {
|
|
213
213
|
box-shadow: 0 0 0 0 !important;
|
|
214
214
|
}
|
|
215
|
+
.ant-hw-switch {
|
|
216
|
+
display: -webkit-box;
|
|
217
|
+
display: -webkit-flex;
|
|
218
|
+
display: -ms-flexbox;
|
|
219
|
+
display: flex;
|
|
220
|
+
-webkit-box-orient: horizontal;
|
|
221
|
+
-webkit-box-direction: normal;
|
|
222
|
+
-webkit-flex-direction: row;
|
|
223
|
+
-ms-flex-direction: row;
|
|
224
|
+
flex-direction: row;
|
|
225
|
+
-webkit-box-align: center;
|
|
226
|
+
-webkit-align-items: center;
|
|
227
|
+
-ms-flex-align: center;
|
|
228
|
+
align-items: center;
|
|
229
|
+
}
|
|
230
|
+
.ant-hw-switch .ant-hw-switch-body {
|
|
231
|
+
margin-left: 4px;
|
|
232
|
+
margin-right: 4px;
|
|
233
|
+
}
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -59,7 +59,6 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
59
59
|
var infoControl = ahooks.useRequest(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
60
60
|
var reqParams,
|
|
61
61
|
result,
|
|
62
|
-
setValue,
|
|
63
62
|
_args2 = arguments;
|
|
64
63
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
65
64
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -77,10 +76,15 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
77
76
|
form === null || form === void 0 || form.setFieldsValue(result);
|
|
78
77
|
return _context2.abrupt("return", result || {});
|
|
79
78
|
case 8:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (!(typeof initialValues === "undefined")) {
|
|
80
|
+
_context2.next = 10;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
return _context2.abrupt("return", {});
|
|
84
|
+
case 10:
|
|
85
|
+
form === null || form === void 0 || form.setFieldsValue(initialValues);
|
|
86
|
+
return _context2.abrupt("return", initialValues);
|
|
87
|
+
case 12:
|
|
84
88
|
case "end":
|
|
85
89
|
return _context2.stop();
|
|
86
90
|
}
|
package/lib/Switch/index.js
CHANGED
|
@@ -31,6 +31,8 @@ var Index = function Index(_ref) {
|
|
|
31
31
|
}),
|
|
32
32
|
_useMatchConfigProps$ = _useMatchConfigProps.valueSwitchMap,
|
|
33
33
|
valueSwitchMap = _useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$;
|
|
34
|
+
var switchClassName = index.useClassName("hw-switch");
|
|
35
|
+
var switchBody = index.useClassName("hw-switch-body");
|
|
34
36
|
var swChecked = React.useMemo(function () {
|
|
35
37
|
var open = valueSwitchMap.open;
|
|
36
38
|
return value === open;
|
|
@@ -61,14 +63,20 @@ var Index = function Index(_ref) {
|
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
|
-
return jsxRuntime.jsxs(
|
|
66
|
+
return jsxRuntime.jsxs("div", {
|
|
65
67
|
style: style,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
className: switchClassName,
|
|
69
|
+
children: [jsxRuntime.jsx("span", {
|
|
70
|
+
children: beforeText
|
|
71
|
+
}), jsxRuntime.jsx("div", {
|
|
72
|
+
className: switchBody,
|
|
73
|
+
children: jsxRuntime.jsx(antd.Switch, _objectSpread({
|
|
74
|
+
checked: swChecked,
|
|
75
|
+
checkedChildren: checkedChildren,
|
|
76
|
+
unCheckedChildren: unCheckedChildren,
|
|
77
|
+
onChange: change
|
|
78
|
+
}, props))
|
|
79
|
+
}), jsxRuntime.jsx("span", {
|
|
72
80
|
children: children
|
|
73
81
|
})]
|
|
74
82
|
});
|
package/lib/index.css
CHANGED
|
@@ -212,3 +212,22 @@
|
|
|
212
212
|
.ant-hw-color-input-picker {
|
|
213
213
|
box-shadow: 0 0 0 0 !important;
|
|
214
214
|
}
|
|
215
|
+
.ant-hw-switch {
|
|
216
|
+
display: -webkit-box;
|
|
217
|
+
display: -webkit-flex;
|
|
218
|
+
display: -ms-flexbox;
|
|
219
|
+
display: flex;
|
|
220
|
+
-webkit-box-orient: horizontal;
|
|
221
|
+
-webkit-box-direction: normal;
|
|
222
|
+
-webkit-flex-direction: row;
|
|
223
|
+
-ms-flex-direction: row;
|
|
224
|
+
flex-direction: row;
|
|
225
|
+
-webkit-box-align: center;
|
|
226
|
+
-webkit-align-items: center;
|
|
227
|
+
-ms-flex-align: center;
|
|
228
|
+
align-items: center;
|
|
229
|
+
}
|
|
230
|
+
.ant-hw-switch .ant-hw-switch-body {
|
|
231
|
+
margin-left: 4px;
|
|
232
|
+
margin-right: 4px;
|
|
233
|
+
}
|
package/package.json
CHANGED
|
@@ -51,9 +51,11 @@ export const useInfoReq = ({
|
|
|
51
51
|
form?.setFieldsValue(result);
|
|
52
52
|
return result || {};
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (typeof initialValues==="undefined"){
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
form?.setFieldsValue(initialValues);
|
|
58
|
+
return initialValues;
|
|
57
59
|
});
|
|
58
60
|
const { run, mutate } = infoControl;
|
|
59
61
|
useEffect(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SwitchProps } from "antd";
|
|
2
2
|
import { Space, Switch } from "antd";
|
|
3
3
|
import React, { useMemo } from "react";
|
|
4
|
-
import { useMatchConfigProps
|
|
4
|
+
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";
|
|
@@ -28,6 +28,8 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
28
28
|
const { valueSwitchMap = {} } = useMatchConfigProps({
|
|
29
29
|
valueSwitchMap: propsValueSwitchMap,
|
|
30
30
|
});
|
|
31
|
+
const switchClassName=useClassName("hw-switch");
|
|
32
|
+
const switchBody=useClassName("hw-switch-body")
|
|
31
33
|
const swChecked = useMemo(() => {
|
|
32
34
|
const { open } = valueSwitchMap;
|
|
33
35
|
return value === open;
|
|
@@ -61,17 +63,21 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
61
63
|
},
|
|
62
64
|
});
|
|
63
65
|
return (
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
<div style={style} className={switchClassName}>
|
|
67
|
+
<span>
|
|
68
|
+
{beforeText}
|
|
69
|
+
</span>
|
|
70
|
+
<div className={switchBody}>
|
|
71
|
+
<Switch
|
|
72
|
+
checked={swChecked}
|
|
73
|
+
checkedChildren={checkedChildren}
|
|
74
|
+
unCheckedChildren={unCheckedChildren}
|
|
75
|
+
onChange={change}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
73
79
|
<span>{children}</span>
|
|
74
|
-
</
|
|
80
|
+
</div>
|
|
75
81
|
);
|
|
76
82
|
};
|
|
77
83
|
|
|
@@ -13,6 +13,18 @@ export default () => {
|
|
|
13
13
|
>
|
|
14
14
|
打开
|
|
15
15
|
</HSwitch>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<HSwitch
|
|
19
|
+
value={1}
|
|
20
|
+
beforeText="开关"
|
|
21
|
+
valueMap={{ open: 1, close: 0 }}
|
|
22
|
+
onChange={(val) => {
|
|
23
|
+
console.log(val);
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
手机设备发送微信红包
|
|
27
|
+
</HSwitch>
|
|
16
28
|
</Space>
|
|
17
29
|
);
|
|
18
30
|
};
|