@hw-component/form 1.9.90 → 1.9.92

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,7 +2,7 @@
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, Fragment } from 'react/jsx-runtime';
5
- import React from 'react';
5
+ import React, { useMemo } from 'react';
6
6
  import { useClassName } from '../hooks/index.js';
7
7
  import { Input } from 'antd';
8
8
 
@@ -42,6 +42,21 @@ var Index = function Index(_ref2) {
42
42
  props = _objectWithoutProperties(_ref2, _excluded);
43
43
  var contentClassname = useClassName(["hw-input-group"]);
44
44
  var bodyClassname = useClassName(["hw-input-group-body"]);
45
+ var beforeBodyClassname = useClassName(["hw-input-group-before-body"]);
46
+ var beforeAfterClassname = useClassName(["hw-input-group-after-body"]);
47
+ var noAddonClassname = useClassName(["hw-input-group-no-addon"]);
48
+ var cuBodyClassName = useMemo(function () {
49
+ if (addonBefore && !addonAfter) {
50
+ return beforeBodyClassname;
51
+ }
52
+ if (addonAfter && !addonBefore) {
53
+ return beforeAfterClassname;
54
+ }
55
+ if (!addonBefore && !addonAfter) {
56
+ return noAddonClassname;
57
+ }
58
+ return "";
59
+ }, [addonAfter, addonBefore]);
45
60
  return jsxs(Input.Group, {
46
61
  compact: true,
47
62
  className: "".concat(contentClassname, " ").concat(className),
@@ -50,7 +65,7 @@ var Index = function Index(_ref2) {
50
65
  onChange: onChange,
51
66
  children: addonBefore
52
67
  }), jsx("div", {
53
- className: bodyClassname,
68
+ className: "".concat(bodyClassname, " ").concat(cuBodyClassName),
54
69
  children: /*#__PURE__*/React.cloneElement(children, _objectSpread({
55
70
  value: value,
56
71
  onChange: onChange
package/es/index.css CHANGED
@@ -302,6 +302,17 @@
302
302
  .ant-form-item-has-error .ant-hw-input-group-body {
303
303
  border-color: #ff4d4f !important;
304
304
  }
305
+ .ant-hw-input-group-before-body .ant-hw-input-group-number-body {
306
+ border-top-right-radius: 2px;
307
+ border-bottom-right-radius: 2px;
308
+ }
309
+ .ant-hw-input-group-after-body .ant-hw-input-group-number-body {
310
+ border-top-left-radius: 2px;
311
+ border-bottom-left-radius: 2px;
312
+ }
313
+ .ant-hw-input-group-no-addon .ant-hw-input-group-number-body {
314
+ border-radius: 2px;
315
+ }
305
316
  .ant-hw-rich-editor {
306
317
  box-sizing: border-box;
307
318
  width: 100%;
@@ -45,6 +45,21 @@ var Index = function Index(_ref2) {
45
45
  props = _objectWithoutProperties(_ref2, _excluded);
46
46
  var contentClassname = index.useClassName(["hw-input-group"]);
47
47
  var bodyClassname = index.useClassName(["hw-input-group-body"]);
48
+ var beforeBodyClassname = index.useClassName(["hw-input-group-before-body"]);
49
+ var beforeAfterClassname = index.useClassName(["hw-input-group-after-body"]);
50
+ var noAddonClassname = index.useClassName(["hw-input-group-no-addon"]);
51
+ var cuBodyClassName = React.useMemo(function () {
52
+ if (addonBefore && !addonAfter) {
53
+ return beforeBodyClassname;
54
+ }
55
+ if (addonAfter && !addonBefore) {
56
+ return beforeAfterClassname;
57
+ }
58
+ if (!addonBefore && !addonAfter) {
59
+ return noAddonClassname;
60
+ }
61
+ return "";
62
+ }, [addonAfter, addonBefore]);
48
63
  return jsxRuntime.jsxs(antd.Input.Group, {
49
64
  compact: true,
50
65
  className: "".concat(contentClassname, " ").concat(className),
@@ -53,7 +68,7 @@ var Index = function Index(_ref2) {
53
68
  onChange: onChange,
54
69
  children: addonBefore
55
70
  }), jsxRuntime.jsx("div", {
56
- className: bodyClassname,
71
+ className: "".concat(bodyClassname, " ").concat(cuBodyClassName),
57
72
  children: /*#__PURE__*/React.cloneElement(children, _objectSpread({
58
73
  value: value,
59
74
  onChange: onChange
package/lib/index.css CHANGED
@@ -302,6 +302,17 @@
302
302
  .ant-form-item-has-error .ant-hw-input-group-body {
303
303
  border-color: #ff4d4f !important;
304
304
  }
305
+ .ant-hw-input-group-before-body .ant-hw-input-group-number-body {
306
+ border-top-right-radius: 2px;
307
+ border-bottom-right-radius: 2px;
308
+ }
309
+ .ant-hw-input-group-after-body .ant-hw-input-group-number-body {
310
+ border-top-left-radius: 2px;
311
+ border-bottom-left-radius: 2px;
312
+ }
313
+ .ant-hw-input-group-no-addon .ant-hw-input-group-number-body {
314
+ border-radius: 2px;
315
+ }
305
316
  .ant-hw-rich-editor {
306
317
  box-sizing: border-box;
307
318
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.90",
3
+ "version": "1.9.92",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,4 @@
1
1
  @import "../InputGroup/index";
2
-
3
2
  .@{all-input-group} {
4
3
  .@{all-input-group}-disabled {
5
4
  background-color: #f5f5f5;
@@ -1,4 +1,5 @@
1
1
  @import "../styles/local.less";
2
+
2
3
  @all-input-group: ~"@{ant-prefix}-hw-input-group";
3
4
 
4
5
  .@{all-input-group} {
@@ -24,3 +25,21 @@
24
25
  border-color: #ff4d4f !important;
25
26
  }
26
27
  }
28
+ .@{all-input-group}-before-body{
29
+ .@{all-input-group}-number-body{
30
+ border-top-right-radius:@border-radius-base;
31
+ border-bottom-right-radius:@border-radius-base;
32
+ }
33
+ }
34
+ .@{all-input-group}-after-body{
35
+ .@{all-input-group}-number-body{
36
+ border-top-left-radius:@border-radius-base;
37
+ border-bottom-left-radius:@border-radius-base;
38
+ }
39
+ }
40
+
41
+ .@{all-input-group}-no-addon{
42
+ .@{all-input-group}-number-body{
43
+ border-radius: @border-radius-base;
44
+ }
45
+ }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, {useMemo} from "react";
2
2
  import { useClassName } from "../hooks";
3
3
  import { Input } from "antd";
4
4
  interface HInputGroupProps<T = any> {
@@ -34,13 +34,28 @@ const Index: React.FC<HInputGroupProps> = ({
34
34
  }) => {
35
35
  const contentClassname = useClassName(["hw-input-group"]);
36
36
  const bodyClassname = useClassName(["hw-input-group-body"]);
37
+ const beforeBodyClassname = useClassName(["hw-input-group-before-body"]);
38
+ const beforeAfterClassname = useClassName(["hw-input-group-after-body"]);
39
+ const noAddonClassname = useClassName(["hw-input-group-no-addon"]);
37
40
 
41
+ const cuBodyClassName=useMemo(()=>{
42
+ if (addonBefore&&!addonAfter){
43
+ return beforeBodyClassname;
44
+ }
45
+ if (addonAfter&&!addonBefore){
46
+ return beforeAfterClassname;
47
+ }
48
+ if (!addonBefore&&!addonAfter){
49
+ return noAddonClassname;
50
+ }
51
+ return ""
52
+ },[addonAfter,addonBefore]);
38
53
  return (
39
54
  <Input.Group compact className={`${contentClassname} ${className}`}>
40
55
  <Addon value={value} onChange={onChange}>
41
56
  {addonBefore}
42
57
  </Addon>
43
- <div className={bodyClassname}>
58
+ <div className={`${bodyClassname} ${cuBodyClassName}`}>
44
59
  {React.cloneElement(children as any, { value, onChange, ...props })}
45
60
  </div>
46
61
  <Addon value={value} onChange={onChange}>
@@ -1 +1,2 @@
1
1
  @ant-prefix: ant;
2
+ @border-radius-base: 2px;
@@ -20,6 +20,7 @@ export default () => {
20
20
  <Col span={10}>
21
21
  <HInputNumberGroup
22
22
  addonBefore={<Test />}
23
+ addonAfter={<Test />}
23
24
  value={val}
24
25
  onChange={setVal}
25
26
  />