@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.
@@ -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
- setValue = initialValues || {};
80
- form === null || form === void 0 || form.setFieldsValue(setValue);
81
- return _context2.abrupt("return", setValue);
82
- case 11:
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
  }
@@ -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 { Space, Switch } from 'antd';
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(Space, {
63
+ return jsxs("div", {
62
64
  style: style,
63
- children: [beforeText, jsx(Switch, _objectSpread({
64
- checked: swChecked,
65
- checkedChildren: checkedChildren,
66
- unCheckedChildren: unCheckedChildren,
67
- onChange: change
68
- }, props)), jsx("span", {
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
+ }
@@ -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
- setValue = initialValues || {};
81
- form === null || form === void 0 || form.setFieldsValue(setValue);
82
- return _context2.abrupt("return", setValue);
83
- case 11:
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
  }
@@ -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(antd.Space, {
66
+ return jsxRuntime.jsxs("div", {
65
67
  style: style,
66
- children: [beforeText, jsxRuntime.jsx(antd.Switch, _objectSpread({
67
- checked: swChecked,
68
- checkedChildren: checkedChildren,
69
- unCheckedChildren: unCheckedChildren,
70
- onChange: change
71
- }, props)), jsxRuntime.jsx("span", {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.18",
3
+ "version": "1.9.20",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,6 +17,7 @@ export const useModifyProps = ({
17
17
  title,
18
18
  onCancel,
19
19
  autoClear,
20
+
20
21
  }: ModifyPropsModal) => {
21
22
  const [modalVisible, setModalVisible] = useState(visible);
22
23
  const [modalFormData, setModalFormData] = useState(configData);
@@ -51,9 +51,11 @@ export const useInfoReq = ({
51
51
  form?.setFieldsValue(result);
52
52
  return result || {};
53
53
  }
54
- const setValue = initialValues || {};
55
- form?.setFieldsValue(setValue);
56
- return setValue;
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(() => {
@@ -0,0 +1,11 @@
1
+ @import "../styles/local.less";
2
+
3
+ .@{ant-prefix}-hw-switch {
4
+ display: flex;
5
+ flex-direction: row;
6
+ align-items: center;
7
+ .@{ant-prefix}-hw-switch-body{
8
+ margin-left: 4px;
9
+ margin-right: 4px;
10
+ }
11
+ }
@@ -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 } from "../hooks";
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
- <Space style={style}>
65
- {beforeText}
66
- <Switch
67
- checked={swChecked}
68
- checkedChildren={checkedChildren}
69
- unCheckedChildren={unCheckedChildren}
70
- onChange={change}
71
- {...props}
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
- </Space>
80
+ </div>
75
81
  );
76
82
  };
77
83
 
@@ -1,3 +1,4 @@
1
1
  @import "../Select/index.less";
2
2
  @import "../Form/index.less";
3
3
  @import "../Input/index.less";
4
+ @import "../Switch/index.less";
@@ -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
  };