@hw-component/form 1.9.7 → 1.9.8

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.
@@ -122,6 +122,7 @@ var Index = function Index(props) {
122
122
  colon: false,
123
123
  required: false,
124
124
  noStyle: noStyle,
125
+ hidden: disHide,
125
126
  children: noStyle ? defaultRender(form) : jsx(Content, {
126
127
  helper: helper,
127
128
  children: defaultRender(form)
@@ -80,15 +80,8 @@ var resultProvider = function resultProvider(newData, oldData, value) {
80
80
  });
81
81
  return newResult;
82
82
  };
83
- var multiple = function multiple(_ref3, oldVal) {
84
- var options = _ref3.options,
85
- value = _ref3.value;
86
- var _sourceDataProvider = sourceDataProvider({
87
- value: value
88
- }, oldVal),
89
- newData = _sourceDataProvider.newData,
90
- oldData = _sourceDataProvider.oldData;
91
- var newMatchVal = newData.map(function (item) {
83
+ var notMatchArray = function notMatchArray(data, options) {
84
+ return data.map(function (item) {
92
85
  var itemVal = item.value,
93
86
  index = item.index;
94
87
  var newItem = single({
@@ -99,7 +92,18 @@ var multiple = function multiple(_ref3, oldVal) {
99
92
  index: index
100
93
  });
101
94
  });
102
- return resultProvider(newMatchVal, oldData, value);
95
+ };
96
+ var multiple = function multiple(_ref3, oldVal) {
97
+ var options = _ref3.options,
98
+ value = _ref3.value;
99
+ var _sourceDataProvider = sourceDataProvider({
100
+ value: value
101
+ }, oldVal),
102
+ newData = _sourceDataProvider.newData,
103
+ oldData = _sourceDataProvider.oldData;
104
+ var notMatchOldVal = notMatchArray(oldData, options);
105
+ var newMatchVal = notMatchArray(newData, options);
106
+ return resultProvider(newMatchVal, notMatchOldVal, value);
103
107
  };
104
108
  var tag = function tag(_ref4, oldVal) {
105
109
  var options = _ref4.options,
@@ -125,6 +125,7 @@ var Index = function Index(props) {
125
125
  colon: false,
126
126
  required: false,
127
127
  noStyle: noStyle,
128
+ hidden: disHide,
128
129
  children: noStyle ? defaultRender(form) : jsxRuntime.jsx(Content, {
129
130
  helper: helper,
130
131
  children: defaultRender(form)
@@ -81,15 +81,8 @@ var resultProvider = function resultProvider(newData, oldData, value) {
81
81
  });
82
82
  return newResult;
83
83
  };
84
- var multiple = function multiple(_ref3, oldVal) {
85
- var options = _ref3.options,
86
- value = _ref3.value;
87
- var _sourceDataProvider = sourceDataProvider({
88
- value: value
89
- }, oldVal),
90
- newData = _sourceDataProvider.newData,
91
- oldData = _sourceDataProvider.oldData;
92
- var newMatchVal = newData.map(function (item) {
84
+ var notMatchArray = function notMatchArray(data, options) {
85
+ return data.map(function (item) {
93
86
  var itemVal = item.value,
94
87
  index = item.index;
95
88
  var newItem = single({
@@ -100,7 +93,18 @@ var multiple = function multiple(_ref3, oldVal) {
100
93
  index: index
101
94
  });
102
95
  });
103
- return resultProvider(newMatchVal, oldData, value);
96
+ };
97
+ var multiple = function multiple(_ref3, oldVal) {
98
+ var options = _ref3.options,
99
+ value = _ref3.value;
100
+ var _sourceDataProvider = sourceDataProvider({
101
+ value: value
102
+ }, oldVal),
103
+ newData = _sourceDataProvider.newData,
104
+ oldData = _sourceDataProvider.oldData;
105
+ var notMatchOldVal = notMatchArray(oldData, options);
106
+ var newMatchVal = notMatchArray(newData, options);
107
+ return resultProvider(newMatchVal, notMatchOldVal, value);
104
108
  };
105
109
  var tag = function tag(_ref4, oldVal) {
106
110
  var options = _ref4.options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -104,6 +104,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
104
104
  colon={false}
105
105
  required={false}
106
106
  noStyle={noStyle}
107
+ hidden={disHide}
107
108
  >
108
109
  {noStyle ? (
109
110
  defaultRender(form)
@@ -56,6 +56,7 @@ export const useValueChange = (params: PartialHSelectProps) => {
56
56
  }
57
57
  onChange(newChangeVal, subItemOps);
58
58
  };
59
+
59
60
  useEffect(() => {
60
61
  if (value === null || value === undefined) {
61
62
  setVal(undefined);
@@ -68,7 +69,7 @@ export const useValueChange = (params: PartialHSelectProps) => {
68
69
 
69
70
  if (options) {
70
71
  setVal((oldVale) => {
71
- return matchNotFind(params, oldVale);
72
+ return matchNotFind(params, oldVale);
72
73
  });
73
74
  }
74
75
  }, [value, options, mode]);
@@ -75,17 +75,21 @@ const resultProvider = (
75
75
  });
76
76
  return newResult;
77
77
  };
78
- const multiple = ({ options, value }: PartialHSelectProps, oldVal?: any[]) => {
79
- const { newData, oldData } = sourceDataProvider({ value }, oldVal);
80
- const newMatchVal = newData.map((item) => {
78
+ const notMatchArray=(data,options)=>{
79
+ return data.map((item)=>{
81
80
  const { value: itemVal, index } = item;
82
81
  const newItem = single({ options, value: itemVal });
83
82
  return {
84
83
  ...newItem,
85
84
  index,
86
85
  };
87
- });
88
- return resultProvider(newMatchVal, oldData, value);
86
+ })
87
+ }
88
+ const multiple = ({ options, value }: PartialHSelectProps, oldVal?: any[]) => {
89
+ const { newData, oldData } = sourceDataProvider({ value }, oldVal);
90
+ const notMatchOldVal=notMatchArray(oldData,options);
91
+ const newMatchVal = notMatchArray(newData,options);
92
+ return resultProvider(newMatchVal, notMatchOldVal, value);
89
93
  }; //多选
90
94
 
91
95
  const tag = ({ options, value }: PartialHSelectProps, oldVal?: any[]) => {
@@ -35,6 +35,7 @@ const Index: React.FC<HSelectProps> = ({
35
35
  dispatch,
36
36
  isList,
37
37
  onPopupScroll: propsOnPopupScroll,
38
+
38
39
  ...props
39
40
  }) => {
40
41
  const { icon, render } = modeConfig?.[mode || ""] || {};
@@ -3,6 +3,8 @@ import { Space, Select } from "antd";
3
3
  import { useState } from "react";
4
4
  export default () => {
5
5
  const [selectVal, setSelectVal] = useState([{ name: "11", id: -100 }]);
6
+ const [op,setOp]=useState([{label:"1",value:1}])
7
+ const [val,setVal]=useState([2,3]);
6
8
  return (
7
9
  <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
8
10
  <HSelect
@@ -34,9 +36,19 @@ export default () => {
34
36
  isList
35
37
  />
36
38
  <HSelect
37
- value={1}
38
- options={null}
39
+ value={val}
40
+ onChange={(v)=>{
41
+ console.log(v);
42
+ setVal(v);
43
+ }}
44
+ mode="multiple"
45
+ options={op}
39
46
  />
47
+ <div onClick={()=>{
48
+ setOp([{label:"2",value:2}])
49
+ }}>
50
+ 改变
51
+ </div>
40
52
  </Space>
41
53
  );
42
54
  };