@hw-component/form 1.9.19 → 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.
@@ -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
+ }
@@ -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.19",
3
+ "version": "1.9.20",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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
  };