@hw-component/form 1.9.39 → 1.9.41

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 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 key = name || nameKey;
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(name, {
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(name, {
133
+ var itemDispatch = itemDispatchProvider(relName, {
133
134
  dependencies: dispatchDependencies,
134
135
  fnKey: fnKey,
135
136
  manual: manual,
@@ -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;
@@ -3,11 +3,11 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
3
3
  import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
4
4
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
5
5
  import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
6
- import { jsxs, jsx } from 'react/jsx-runtime';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
7
  import { Input, Button } from 'antd';
8
8
  import { useRequest } from 'ahooks';
9
9
 
10
- var _excluded = ["buttonProps", "value", "onChange", "children", "request"],
10
+ var _excluded = ["buttonProps", "value", "onChange", "children", "request", "layType"],
11
11
  _excluded2 = ["onClick", "type", "ghost", "loading"];
12
12
  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; }
13
13
  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; }
@@ -18,14 +18,17 @@ var Index = function Index(_ref) {
18
18
  onChange = _ref.onChange,
19
19
  children = _ref.children,
20
20
  request = _ref.request,
21
+ _ref$layType = _ref.layType,
22
+ layType = _ref$layType === void 0 ? "group" : _ref$layType,
21
23
  props = _objectWithoutProperties(_ref, _excluded);
22
24
  var onClick = buttonProps.onClick,
23
- _buttonProps$type = buttonProps.type,
24
- type = _buttonProps$type === void 0 ? "primary" : _buttonProps$type,
25
+ type = buttonProps.type,
25
26
  _buttonProps$ghost = buttonProps.ghost,
26
27
  ghost = _buttonProps$ghost === void 0 ? true : _buttonProps$ghost,
27
28
  btnLoading = buttonProps.loading,
28
29
  oProps = _objectWithoutProperties(buttonProps, _excluded2);
30
+ var defaultBtnType = layType === "group" ? "primary" : "link";
31
+ var btnType = type || defaultBtnType;
29
32
  var _useRequest = useRequest(function (val) {
30
33
  return request === null || request === void 0 ? void 0 : request(val);
31
34
  }, {
@@ -63,6 +66,19 @@ var Index = function Index(_ref) {
63
66
  return _ref2.apply(this, arguments);
64
67
  };
65
68
  }();
69
+ if (layType === "text") {
70
+ return jsx(Input, _objectSpread(_objectSpread({}, props), {}, {
71
+ suffix: jsx(Button, _objectSpread(_objectSpread({
72
+ type: btnType,
73
+ onClick: click,
74
+ size: "small",
75
+ loading: loading || btnLoading,
76
+ ghost: ghost
77
+ }, oProps), {}, {
78
+ children: children
79
+ }))
80
+ }));
81
+ }
66
82
  return jsxs(Input.Group, {
67
83
  compact: true,
68
84
  style: {
@@ -75,7 +91,7 @@ var Index = function Index(_ref) {
75
91
  value: value,
76
92
  onChange: change
77
93
  })), jsx(Button, _objectSpread(_objectSpread({
78
- type: type,
94
+ type: btnType,
79
95
  onClick: click,
80
96
  loading: loading || btnLoading,
81
97
  style: {
@@ -30,5 +30,6 @@ export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
30
30
  export interface HButtonInputProps extends HInputProps {
31
31
  buttonProps?: HButtonProps;
32
32
  request?: PromiseFnResult;
33
+ layType?: "group" | "text";
33
34
  }
34
35
  export {};
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 key = name || nameKey;
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(name, {
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(name, {
136
+ var itemDispatch = itemDispatchProvider(relName, {
136
137
  dependencies: dispatchDependencies,
137
138
  fnKey: fnKey,
138
139
  manual: manual,
@@ -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;
@@ -10,7 +10,7 @@ var jsxRuntime = require('react/jsx-runtime');
10
10
  var antd = require('antd');
11
11
  var ahooks = require('ahooks');
12
12
 
13
- var _excluded = ["buttonProps", "value", "onChange", "children", "request"],
13
+ var _excluded = ["buttonProps", "value", "onChange", "children", "request", "layType"],
14
14
  _excluded2 = ["onClick", "type", "ghost", "loading"];
15
15
  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; }
16
16
  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; }
@@ -21,14 +21,17 @@ var Index = function Index(_ref) {
21
21
  onChange = _ref.onChange,
22
22
  children = _ref.children,
23
23
  request = _ref.request,
24
+ _ref$layType = _ref.layType,
25
+ layType = _ref$layType === void 0 ? "group" : _ref$layType,
24
26
  props = _objectWithoutProperties(_ref, _excluded);
25
27
  var onClick = buttonProps.onClick,
26
- _buttonProps$type = buttonProps.type,
27
- type = _buttonProps$type === void 0 ? "primary" : _buttonProps$type,
28
+ type = buttonProps.type,
28
29
  _buttonProps$ghost = buttonProps.ghost,
29
30
  ghost = _buttonProps$ghost === void 0 ? true : _buttonProps$ghost,
30
31
  btnLoading = buttonProps.loading,
31
32
  oProps = _objectWithoutProperties(buttonProps, _excluded2);
33
+ var defaultBtnType = layType === "group" ? "primary" : "link";
34
+ var btnType = type || defaultBtnType;
32
35
  var _useRequest = ahooks.useRequest(function (val) {
33
36
  return request === null || request === void 0 ? void 0 : request(val);
34
37
  }, {
@@ -66,6 +69,19 @@ var Index = function Index(_ref) {
66
69
  return _ref2.apply(this, arguments);
67
70
  };
68
71
  }();
72
+ if (layType === "text") {
73
+ return jsxRuntime.jsx(antd.Input, _objectSpread(_objectSpread({}, props), {}, {
74
+ suffix: jsxRuntime.jsx(antd.Button, _objectSpread(_objectSpread({
75
+ type: btnType,
76
+ onClick: click,
77
+ size: "small",
78
+ loading: loading || btnLoading,
79
+ ghost: ghost
80
+ }, oProps), {}, {
81
+ children: children
82
+ }))
83
+ }));
84
+ }
69
85
  return jsxRuntime.jsxs(antd.Input.Group, {
70
86
  compact: true,
71
87
  style: {
@@ -78,7 +94,7 @@ var Index = function Index(_ref) {
78
94
  value: value,
79
95
  onChange: change
80
96
  })), jsxRuntime.jsx(antd.Button, _objectSpread(_objectSpread({
81
- type: type,
97
+ type: btnType,
82
98
  onClick: click,
83
99
  loading: loading || btnLoading,
84
100
  style: {
@@ -30,5 +30,6 @@ export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
30
30
  export interface HButtonInputProps extends HInputProps {
31
31
  buttonProps?: HButtonProps;
32
32
  request?: PromiseFnResult;
33
+ layType?: "group" | "text";
33
34
  }
34
35
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.39",
3
+ "version": "1.9.41",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,7 +53,8 @@ export default ({
53
53
  ...formItemProps,
54
54
  ...itemProps,
55
55
  };
56
- const key=name||nameKey;
56
+ const arrayName=Array.isArray(name)?name.join("."):name;
57
+ const key=arrayName||nameKey;
57
58
  return (
58
59
  <Item
59
60
  {...itemData}
@@ -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
- name,
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
- name,
166
+ relName,
166
167
  { dependencies: dispatchDependencies, fnKey, manual, reset },
167
168
  dispatchSourceData
168
169
  );
@@ -92,7 +92,7 @@ export interface HItemProps
92
92
  labelWidth?: number;
93
93
  hide?: boolean | HideModal;
94
94
  placeholder?: string | string[];
95
- name?: string;
95
+ name?: string|string[];
96
96
  dispatch?: DispatchModal;
97
97
  itemSpan?: ColProps;
98
98
  hideLabel?: boolean;
@@ -9,15 +9,18 @@ const Index: React.FC<HButtonInputProps> = ({
9
9
  onChange,
10
10
  children,
11
11
  request,
12
+ layType="group",
12
13
  ...props
13
14
  }) => {
14
15
  const {
15
16
  onClick,
16
- type = "primary",
17
+ type ,
17
18
  ghost = true,
18
19
  loading: btnLoading,
19
20
  ...oProps
20
21
  } = buttonProps;
22
+ const defaultBtnType=layType==="group"?"primary":"link"
23
+ const btnType=type||defaultBtnType
21
24
  const { run, loading } = useRequest(
22
25
  (val) => {
23
26
  return request?.(val);
@@ -34,12 +37,28 @@ const Index: React.FC<HButtonInputProps> = ({
34
37
  }
35
38
  onClick?.(result, onChange);
36
39
  };
37
-
40
+ if (layType==="text"){
41
+ return <Input
42
+ {...props}
43
+ suffix={
44
+ <Button
45
+ type={btnType}
46
+ onClick={click}
47
+ size={"small"}
48
+ loading={loading || btnLoading}
49
+ ghost={ghost}
50
+ {...oProps}
51
+ >
52
+ {children}
53
+ </Button>
54
+ }
55
+ />
56
+ }
38
57
  return (
39
58
  <Input.Group compact style={{ display: "flex" }}>
40
59
  <Input {...props} style={{ flex: 1 }} value={value} onChange={change} />
41
60
  <Button
42
- type={type}
61
+ type={btnType}
43
62
  onClick={click}
44
63
  loading={loading || btnLoading}
45
64
  style={{ marginLeft: 8, borderRadius: 4 }}
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from "react";
1
+ import React, { useCallback, useEffect, useMemo } from "react";
2
2
  import ButtonInput from "../ButtonInput";
3
3
  import { useRequest } from "ahooks";
4
4
  import type { HFormInstance } from "../../Form/modal";
@@ -37,4 +37,5 @@ export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
37
37
  export interface HButtonInputProps extends HInputProps {
38
38
  buttonProps?: HButtonProps;
39
39
  request?: PromiseFnResult;
40
+ layType?:"group"|"text";
40
41
  }
@@ -24,6 +24,7 @@ export default () => {
24
24
  <HInputNumber />
25
25
  <HColorInput value={colorVal} onChange={setColorVal} />
26
26
  <HVerificationCodeInput
27
+ layType="text"
27
28
  request={() => {
28
29
  return Promise.resolve({ code: 200 });
29
30
  }}