@hw-component/form 1.6.3 → 1.6.5
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/.eslintcache +1 -1
- package/es/Select/hooks/changeHooks.js +34 -147
- package/es/Select/hooks/norHooks.d.ts +2 -3
- package/es/Select/hooks/norHooks.js +9 -1
- package/es/Select/hooks/util.d.ts +10 -0
- package/es/Select/hooks/util.js +138 -0
- package/lib/Select/hooks/changeHooks.js +35 -148
- package/lib/Select/hooks/norHooks.d.ts +2 -3
- package/lib/Select/hooks/norHooks.js +9 -1
- package/lib/Select/hooks/util.d.ts +10 -0
- package/lib/Select/hooks/util.js +139 -0
- package/package.json +1 -1
- package/src/components/Select/hooks/changeHooks.tsx +31 -113
- package/src/components/Select/hooks/norHooks.ts +69 -66
- package/src/components/Select/hooks/util.ts +106 -0
- package/src/components/Select/index.tsx +5 -5
- package/src/components/Select/modal.ts +3 -5
- package/src/pages/Form/index.tsx +1 -11
- package/src/pages/Select/index.tsx +25 -25
|
@@ -1,154 +1,10 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import 'core-js/modules/es.object.keys.js';
|
|
3
|
-
import 'core-js/modules/es.symbol.js';
|
|
4
|
-
import 'core-js/modules/es.array.filter.js';
|
|
5
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
6
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
7
2
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
8
|
-
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
9
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
-
import 'core-js/modules/es.array.find-index.js';
|
|
11
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
12
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
13
3
|
import 'core-js/modules/es.array.map.js';
|
|
14
4
|
import { useState, useEffect } from 'react';
|
|
15
5
|
import { itemOpProvider } from '../utils.js';
|
|
6
|
+
import { matchNotFind } from './util.js';
|
|
16
7
|
|
|
17
|
-
var _excluded = ["index"],
|
|
18
|
-
_excluded2 = ["index"];
|
|
19
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
var single = function single(_ref) {
|
|
22
|
-
var options = _ref.options,
|
|
23
|
-
value = _ref.value,
|
|
24
|
-
noMatchItemRender = _ref.noMatchItemRender;
|
|
25
|
-
var newOptions = options || [];
|
|
26
|
-
var index = newOptions.findIndex(function (item) {
|
|
27
|
-
return item.value === value;
|
|
28
|
-
});
|
|
29
|
-
if (index !== -1) {
|
|
30
|
-
var label = newOptions[index].label;
|
|
31
|
-
return {
|
|
32
|
-
value: value,
|
|
33
|
-
label: label
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
value: value,
|
|
38
|
-
label: (noMatchItemRender === null || noMatchItemRender === void 0 ? void 0 : noMatchItemRender({
|
|
39
|
-
value: value
|
|
40
|
-
})) || value
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
var findNewValInOldVal = function findNewValInOldVal(val, oldVal) {
|
|
44
|
-
if (!oldVal) {
|
|
45
|
-
return -1;
|
|
46
|
-
}
|
|
47
|
-
return oldVal.findIndex(function (item) {
|
|
48
|
-
return item.value === val;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
var sourceDataProvider = function sourceDataProvider(_ref2, oldVal) {
|
|
52
|
-
_ref2.options;
|
|
53
|
-
var value = _ref2.value;
|
|
54
|
-
var oldData = [];
|
|
55
|
-
var newData = [];
|
|
56
|
-
value.forEach(function (item, i) {
|
|
57
|
-
var index = findNewValInOldVal(item, oldVal);
|
|
58
|
-
if (index === -1) {
|
|
59
|
-
newData.push({
|
|
60
|
-
value: item,
|
|
61
|
-
index: i
|
|
62
|
-
});
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
var newVal = oldVal === null || oldVal === void 0 ? void 0 : oldVal[index];
|
|
66
|
-
oldData.push(_objectSpread(_objectSpread({}, newVal), {}, {
|
|
67
|
-
index: i
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
oldData: oldData,
|
|
72
|
-
newData: newData
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
var resultProvider = function resultProvider(newData, oldData, value) {
|
|
76
|
-
var newResult = new Array(value.length);
|
|
77
|
-
oldData.forEach(function (item) {
|
|
78
|
-
var index = item.index,
|
|
79
|
-
val = _objectWithoutProperties(item, _excluded);
|
|
80
|
-
newResult[index] = _objectSpread({}, val);
|
|
81
|
-
});
|
|
82
|
-
newData.forEach(function (item) {
|
|
83
|
-
var index = item.index,
|
|
84
|
-
val = _objectWithoutProperties(item, _excluded2);
|
|
85
|
-
newResult[index] = _objectSpread({}, val);
|
|
86
|
-
});
|
|
87
|
-
return newResult;
|
|
88
|
-
};
|
|
89
|
-
var multiple = function multiple(_ref3, oldVal) {
|
|
90
|
-
var options = _ref3.options,
|
|
91
|
-
value = _ref3.value,
|
|
92
|
-
noMatchItemRender = _ref3.noMatchItemRender;
|
|
93
|
-
var _sourceDataProvider = sourceDataProvider({
|
|
94
|
-
options: options,
|
|
95
|
-
value: value
|
|
96
|
-
}, oldVal),
|
|
97
|
-
newData = _sourceDataProvider.newData,
|
|
98
|
-
oldData = _sourceDataProvider.oldData;
|
|
99
|
-
var newMatchVal = newData.map(function (item) {
|
|
100
|
-
var itemVal = item.value,
|
|
101
|
-
index = item.index;
|
|
102
|
-
var newItem = single({
|
|
103
|
-
options: options,
|
|
104
|
-
value: itemVal,
|
|
105
|
-
noMatchItemRender: noMatchItemRender
|
|
106
|
-
});
|
|
107
|
-
return _objectSpread(_objectSpread({}, newItem), {}, {
|
|
108
|
-
index: index
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
return resultProvider(newMatchVal, oldData, value);
|
|
112
|
-
};
|
|
113
|
-
var tag = function tag(_ref4, oldVal) {
|
|
114
|
-
var options = _ref4.options,
|
|
115
|
-
value = _ref4.value;
|
|
116
|
-
var _sourceDataProvider2 = sourceDataProvider({
|
|
117
|
-
options: options,
|
|
118
|
-
value: value
|
|
119
|
-
}, oldVal),
|
|
120
|
-
newData = _sourceDataProvider2.newData,
|
|
121
|
-
oldData = _sourceDataProvider2.oldData;
|
|
122
|
-
return resultProvider(newData, oldData, value);
|
|
123
|
-
};
|
|
124
|
-
var matchNotFind = function matchNotFind(_ref5, oldVale) {
|
|
125
|
-
var options = _ref5.options,
|
|
126
|
-
value = _ref5.value,
|
|
127
|
-
mode = _ref5.mode,
|
|
128
|
-
noMatchItemRender = _ref5.noMatchItemRender,
|
|
129
|
-
labelInValue = _ref5.labelInValue;
|
|
130
|
-
if (labelInValue) {
|
|
131
|
-
return value;
|
|
132
|
-
}
|
|
133
|
-
if (!mode) {
|
|
134
|
-
return single({
|
|
135
|
-
options: options,
|
|
136
|
-
value: value,
|
|
137
|
-
noMatchItemRender: noMatchItemRender
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (mode === "multiple") {
|
|
141
|
-
return multiple({
|
|
142
|
-
options: options,
|
|
143
|
-
value: value,
|
|
144
|
-
noMatchItemRender: noMatchItemRender
|
|
145
|
-
}, oldVale) || [];
|
|
146
|
-
}
|
|
147
|
-
return tag({
|
|
148
|
-
options: options,
|
|
149
|
-
value: value
|
|
150
|
-
}, oldVale);
|
|
151
|
-
};
|
|
152
8
|
var useValueChange = function useValueChange(params) {
|
|
153
9
|
var labelInValue = params.labelInValue,
|
|
154
10
|
onChange = params.onChange,
|
|
@@ -197,9 +53,40 @@ var useValueChange = function useValueChange(params) {
|
|
|
197
53
|
return matchNotFind(params, oldVale);
|
|
198
54
|
});
|
|
199
55
|
}
|
|
200
|
-
}, [value, options, mode
|
|
56
|
+
}, [value, options, mode]);
|
|
57
|
+
var itemMaker = function itemMaker(item) {
|
|
58
|
+
var itemVal = item.value,
|
|
59
|
+
label = item.label,
|
|
60
|
+
noMatch = item.noMatch;
|
|
61
|
+
if (noMatch) {
|
|
62
|
+
return {
|
|
63
|
+
value: itemVal,
|
|
64
|
+
label: (noMatchItemRender === null || noMatchItemRender === void 0 ? void 0 : noMatchItemRender({
|
|
65
|
+
value: value
|
|
66
|
+
})) || value
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
value: itemVal,
|
|
71
|
+
label: label
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
var valuesMaker = function valuesMaker() {
|
|
75
|
+
if (labelInValue) {
|
|
76
|
+
return val;
|
|
77
|
+
}
|
|
78
|
+
if (!val) {
|
|
79
|
+
return val;
|
|
80
|
+
}
|
|
81
|
+
if (Array.isArray(val)) {
|
|
82
|
+
return val.map(function (item) {
|
|
83
|
+
return itemMaker(item);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return itemMaker(val);
|
|
87
|
+
};
|
|
201
88
|
return {
|
|
202
|
-
val:
|
|
89
|
+
val: valuesMaker(),
|
|
203
90
|
change: change
|
|
204
91
|
};
|
|
205
92
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { OptionType, PartialHSelectProps } from "../modal";
|
|
2
|
-
import { OptionsPageResultModal } from "../modal";
|
|
3
2
|
interface ParamsModal {
|
|
4
3
|
options?: OptionType[];
|
|
5
4
|
params?: any;
|
|
6
5
|
}
|
|
7
6
|
export declare const useSelectReq: ({ manual, request, options, serviceSearch, showSearch, onSearch: propsOnSearch, dispatch, isList, }: PartialHSelectProps) => {
|
|
8
|
-
run: (requestParams?:
|
|
7
|
+
run: (requestParams?: {}, type?: string) => void;
|
|
9
8
|
loading: boolean;
|
|
10
9
|
error: Error | undefined;
|
|
11
10
|
data: OptionType[] | undefined;
|
|
12
11
|
onSearch: ((value: string) => void) | undefined;
|
|
13
12
|
mathShowSearch: boolean | undefined;
|
|
14
|
-
reload: (reloadParams?: ParamsModal) => void
|
|
13
|
+
reload: (reloadParams?: ParamsModal) => void;
|
|
15
14
|
onPopupScroll: ((e: any) => void) | undefined;
|
|
16
15
|
};
|
|
17
16
|
export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
|
|
@@ -135,9 +135,17 @@ var useOptionsRequest = function useOptionsRequest(_ref) {
|
|
|
135
135
|
setData([].concat(_toConsumableArray(oldData), _toConsumableArray(op)));
|
|
136
136
|
}
|
|
137
137
|
}),
|
|
138
|
-
|
|
138
|
+
listRun = _useRequest.run,
|
|
139
139
|
loading = _useRequest.loading,
|
|
140
140
|
error = _useRequest.error;
|
|
141
|
+
var run = function run() {
|
|
142
|
+
var requestParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
143
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "init";
|
|
144
|
+
if (loading) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
listRun(requestParams, type);
|
|
148
|
+
};
|
|
141
149
|
return {
|
|
142
150
|
loading: loading,
|
|
143
151
|
run: run,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OptionType, PartialHSelectProps } from "@/components/Select/modal";
|
|
2
|
+
export declare const matchNotFind: ({ options, value, mode }: PartialHSelectProps, oldVale?: OptionType[]) => any[] | {
|
|
3
|
+
value: any;
|
|
4
|
+
label: any;
|
|
5
|
+
noMatch?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
value: any;
|
|
8
|
+
label: any;
|
|
9
|
+
noMatch: boolean;
|
|
10
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.object.keys.js';
|
|
3
|
+
import 'core-js/modules/es.symbol.js';
|
|
4
|
+
import 'core-js/modules/es.array.filter.js';
|
|
5
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
6
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
7
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
8
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
9
|
+
import 'core-js/modules/es.array.find-index.js';
|
|
10
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
11
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
12
|
+
import 'core-js/modules/es.array.map.js';
|
|
13
|
+
|
|
14
|
+
var _excluded = ["index"],
|
|
15
|
+
_excluded2 = ["index"];
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
+
var findNewValInOldVal = function findNewValInOldVal(val, oldVal) {
|
|
19
|
+
if (!oldVal) {
|
|
20
|
+
return -1;
|
|
21
|
+
}
|
|
22
|
+
return oldVal.findIndex(function (item) {
|
|
23
|
+
return item.value === val;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var sourceDataProvider = function sourceDataProvider(_ref, oldVal) {
|
|
27
|
+
var value = _ref.value;
|
|
28
|
+
var oldData = [];
|
|
29
|
+
var newData = [];
|
|
30
|
+
value.forEach(function (item, i) {
|
|
31
|
+
var index = findNewValInOldVal(item, oldVal);
|
|
32
|
+
if (index === -1) {
|
|
33
|
+
newData.push({
|
|
34
|
+
value: item,
|
|
35
|
+
index: i
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var newVal = oldVal === null || oldVal === void 0 ? void 0 : oldVal[index];
|
|
40
|
+
oldData.push(_objectSpread(_objectSpread({}, newVal), {}, {
|
|
41
|
+
index: i
|
|
42
|
+
}));
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
oldData: oldData,
|
|
46
|
+
newData: newData
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var single = function single(_ref2) {
|
|
50
|
+
var options = _ref2.options,
|
|
51
|
+
value = _ref2.value;
|
|
52
|
+
var newOptions = options || [];
|
|
53
|
+
var index = newOptions.findIndex(function (item) {
|
|
54
|
+
return item.value === value;
|
|
55
|
+
});
|
|
56
|
+
if (index !== -1) {
|
|
57
|
+
var label = newOptions[index].label;
|
|
58
|
+
return {
|
|
59
|
+
value: value,
|
|
60
|
+
label: label
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
value: value,
|
|
65
|
+
label: value,
|
|
66
|
+
noMatch: true
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var resultProvider = function resultProvider(newData, oldData, value) {
|
|
70
|
+
var newResult = new Array(value.length);
|
|
71
|
+
oldData.forEach(function (item) {
|
|
72
|
+
var index = item.index,
|
|
73
|
+
val = _objectWithoutProperties(item, _excluded);
|
|
74
|
+
newResult[index] = _objectSpread({}, val);
|
|
75
|
+
});
|
|
76
|
+
newData.forEach(function (item) {
|
|
77
|
+
var index = item.index,
|
|
78
|
+
val = _objectWithoutProperties(item, _excluded2);
|
|
79
|
+
newResult[index] = _objectSpread({}, val);
|
|
80
|
+
});
|
|
81
|
+
return newResult;
|
|
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) {
|
|
92
|
+
var itemVal = item.value,
|
|
93
|
+
index = item.index;
|
|
94
|
+
var newItem = single({
|
|
95
|
+
options: options,
|
|
96
|
+
value: itemVal
|
|
97
|
+
});
|
|
98
|
+
return _objectSpread(_objectSpread({}, newItem), {}, {
|
|
99
|
+
index: index
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
return resultProvider(newMatchVal, oldData, value);
|
|
103
|
+
};
|
|
104
|
+
var tag = function tag(_ref4, oldVal) {
|
|
105
|
+
var options = _ref4.options,
|
|
106
|
+
value = _ref4.value;
|
|
107
|
+
var _sourceDataProvider2 = sourceDataProvider({
|
|
108
|
+
options: options,
|
|
109
|
+
value: value
|
|
110
|
+
}, oldVal),
|
|
111
|
+
newData = _sourceDataProvider2.newData,
|
|
112
|
+
oldData = _sourceDataProvider2.oldData;
|
|
113
|
+
return resultProvider(newData, oldData, value);
|
|
114
|
+
};
|
|
115
|
+
var matchNotFind = function matchNotFind(_ref5, oldVale) {
|
|
116
|
+
var options = _ref5.options,
|
|
117
|
+
value = _ref5.value,
|
|
118
|
+
mode = _ref5.mode;
|
|
119
|
+
if (!mode) {
|
|
120
|
+
return single({
|
|
121
|
+
options: options,
|
|
122
|
+
value: value
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (mode === "multiple") {
|
|
126
|
+
return multiple({
|
|
127
|
+
options: options,
|
|
128
|
+
value: value
|
|
129
|
+
}, oldVale) || [];
|
|
130
|
+
}
|
|
131
|
+
return tag({
|
|
132
|
+
options: options,
|
|
133
|
+
value: value
|
|
134
|
+
}, oldVale);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export { matchNotFind };
|
|
138
|
+
// powered by hdj
|
|
@@ -1,155 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('core-js/modules/es.object.keys.js');
|
|
4
|
-
require('core-js/modules/es.symbol.js');
|
|
5
|
-
require('core-js/modules/es.array.filter.js');
|
|
6
|
-
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
7
|
-
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
8
3
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
9
|
-
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
10
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
11
|
-
require('core-js/modules/es.array.find-index.js');
|
|
12
|
-
require('core-js/modules/es.object.to-string.js');
|
|
13
|
-
require('core-js/modules/web.dom-collections.for-each.js');
|
|
14
4
|
require('core-js/modules/es.array.map.js');
|
|
15
5
|
var React = require('react');
|
|
16
6
|
var utils = require('../utils.js');
|
|
7
|
+
var util = require('./util.js');
|
|
17
8
|
|
|
18
|
-
var _excluded = ["index"],
|
|
19
|
-
_excluded2 = ["index"];
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
-
var single = function single(_ref) {
|
|
23
|
-
var options = _ref.options,
|
|
24
|
-
value = _ref.value,
|
|
25
|
-
noMatchItemRender = _ref.noMatchItemRender;
|
|
26
|
-
var newOptions = options || [];
|
|
27
|
-
var index = newOptions.findIndex(function (item) {
|
|
28
|
-
return item.value === value;
|
|
29
|
-
});
|
|
30
|
-
if (index !== -1) {
|
|
31
|
-
var label = newOptions[index].label;
|
|
32
|
-
return {
|
|
33
|
-
value: value,
|
|
34
|
-
label: label
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
value: value,
|
|
39
|
-
label: (noMatchItemRender === null || noMatchItemRender === void 0 ? void 0 : noMatchItemRender({
|
|
40
|
-
value: value
|
|
41
|
-
})) || value
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var findNewValInOldVal = function findNewValInOldVal(val, oldVal) {
|
|
45
|
-
if (!oldVal) {
|
|
46
|
-
return -1;
|
|
47
|
-
}
|
|
48
|
-
return oldVal.findIndex(function (item) {
|
|
49
|
-
return item.value === val;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
var sourceDataProvider = function sourceDataProvider(_ref2, oldVal) {
|
|
53
|
-
_ref2.options;
|
|
54
|
-
var value = _ref2.value;
|
|
55
|
-
var oldData = [];
|
|
56
|
-
var newData = [];
|
|
57
|
-
value.forEach(function (item, i) {
|
|
58
|
-
var index = findNewValInOldVal(item, oldVal);
|
|
59
|
-
if (index === -1) {
|
|
60
|
-
newData.push({
|
|
61
|
-
value: item,
|
|
62
|
-
index: i
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
var newVal = oldVal === null || oldVal === void 0 ? void 0 : oldVal[index];
|
|
67
|
-
oldData.push(_objectSpread(_objectSpread({}, newVal), {}, {
|
|
68
|
-
index: i
|
|
69
|
-
}));
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
oldData: oldData,
|
|
73
|
-
newData: newData
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
var resultProvider = function resultProvider(newData, oldData, value) {
|
|
77
|
-
var newResult = new Array(value.length);
|
|
78
|
-
oldData.forEach(function (item) {
|
|
79
|
-
var index = item.index,
|
|
80
|
-
val = _objectWithoutProperties(item, _excluded);
|
|
81
|
-
newResult[index] = _objectSpread({}, val);
|
|
82
|
-
});
|
|
83
|
-
newData.forEach(function (item) {
|
|
84
|
-
var index = item.index,
|
|
85
|
-
val = _objectWithoutProperties(item, _excluded2);
|
|
86
|
-
newResult[index] = _objectSpread({}, val);
|
|
87
|
-
});
|
|
88
|
-
return newResult;
|
|
89
|
-
};
|
|
90
|
-
var multiple = function multiple(_ref3, oldVal) {
|
|
91
|
-
var options = _ref3.options,
|
|
92
|
-
value = _ref3.value,
|
|
93
|
-
noMatchItemRender = _ref3.noMatchItemRender;
|
|
94
|
-
var _sourceDataProvider = sourceDataProvider({
|
|
95
|
-
options: options,
|
|
96
|
-
value: value
|
|
97
|
-
}, oldVal),
|
|
98
|
-
newData = _sourceDataProvider.newData,
|
|
99
|
-
oldData = _sourceDataProvider.oldData;
|
|
100
|
-
var newMatchVal = newData.map(function (item) {
|
|
101
|
-
var itemVal = item.value,
|
|
102
|
-
index = item.index;
|
|
103
|
-
var newItem = single({
|
|
104
|
-
options: options,
|
|
105
|
-
value: itemVal,
|
|
106
|
-
noMatchItemRender: noMatchItemRender
|
|
107
|
-
});
|
|
108
|
-
return _objectSpread(_objectSpread({}, newItem), {}, {
|
|
109
|
-
index: index
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
return resultProvider(newMatchVal, oldData, value);
|
|
113
|
-
};
|
|
114
|
-
var tag = function tag(_ref4, oldVal) {
|
|
115
|
-
var options = _ref4.options,
|
|
116
|
-
value = _ref4.value;
|
|
117
|
-
var _sourceDataProvider2 = sourceDataProvider({
|
|
118
|
-
options: options,
|
|
119
|
-
value: value
|
|
120
|
-
}, oldVal),
|
|
121
|
-
newData = _sourceDataProvider2.newData,
|
|
122
|
-
oldData = _sourceDataProvider2.oldData;
|
|
123
|
-
return resultProvider(newData, oldData, value);
|
|
124
|
-
};
|
|
125
|
-
var matchNotFind = function matchNotFind(_ref5, oldVale) {
|
|
126
|
-
var options = _ref5.options,
|
|
127
|
-
value = _ref5.value,
|
|
128
|
-
mode = _ref5.mode,
|
|
129
|
-
noMatchItemRender = _ref5.noMatchItemRender,
|
|
130
|
-
labelInValue = _ref5.labelInValue;
|
|
131
|
-
if (labelInValue) {
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
if (!mode) {
|
|
135
|
-
return single({
|
|
136
|
-
options: options,
|
|
137
|
-
value: value,
|
|
138
|
-
noMatchItemRender: noMatchItemRender
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
if (mode === "multiple") {
|
|
142
|
-
return multiple({
|
|
143
|
-
options: options,
|
|
144
|
-
value: value,
|
|
145
|
-
noMatchItemRender: noMatchItemRender
|
|
146
|
-
}, oldVale) || [];
|
|
147
|
-
}
|
|
148
|
-
return tag({
|
|
149
|
-
options: options,
|
|
150
|
-
value: value
|
|
151
|
-
}, oldVale);
|
|
152
|
-
};
|
|
153
9
|
var useValueChange = function useValueChange(params) {
|
|
154
10
|
var labelInValue = params.labelInValue,
|
|
155
11
|
onChange = params.onChange,
|
|
@@ -195,12 +51,43 @@ var useValueChange = function useValueChange(params) {
|
|
|
195
51
|
}
|
|
196
52
|
if (options) {
|
|
197
53
|
setVal(function (oldVale) {
|
|
198
|
-
return matchNotFind(params, oldVale);
|
|
54
|
+
return util.matchNotFind(params, oldVale);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, [value, options, mode]);
|
|
58
|
+
var itemMaker = function itemMaker(item) {
|
|
59
|
+
var itemVal = item.value,
|
|
60
|
+
label = item.label,
|
|
61
|
+
noMatch = item.noMatch;
|
|
62
|
+
if (noMatch) {
|
|
63
|
+
return {
|
|
64
|
+
value: itemVal,
|
|
65
|
+
label: (noMatchItemRender === null || noMatchItemRender === void 0 ? void 0 : noMatchItemRender({
|
|
66
|
+
value: value
|
|
67
|
+
})) || value
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
value: itemVal,
|
|
72
|
+
label: label
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
var valuesMaker = function valuesMaker() {
|
|
76
|
+
if (labelInValue) {
|
|
77
|
+
return val;
|
|
78
|
+
}
|
|
79
|
+
if (!val) {
|
|
80
|
+
return val;
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(val)) {
|
|
83
|
+
return val.map(function (item) {
|
|
84
|
+
return itemMaker(item);
|
|
199
85
|
});
|
|
200
86
|
}
|
|
201
|
-
|
|
87
|
+
return itemMaker(val);
|
|
88
|
+
};
|
|
202
89
|
return {
|
|
203
|
-
val:
|
|
90
|
+
val: valuesMaker(),
|
|
204
91
|
change: change
|
|
205
92
|
};
|
|
206
93
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { OptionType, PartialHSelectProps } from "../modal";
|
|
2
|
-
import { OptionsPageResultModal } from "../modal";
|
|
3
2
|
interface ParamsModal {
|
|
4
3
|
options?: OptionType[];
|
|
5
4
|
params?: any;
|
|
6
5
|
}
|
|
7
6
|
export declare const useSelectReq: ({ manual, request, options, serviceSearch, showSearch, onSearch: propsOnSearch, dispatch, isList, }: PartialHSelectProps) => {
|
|
8
|
-
run: (requestParams?:
|
|
7
|
+
run: (requestParams?: {}, type?: string) => void;
|
|
9
8
|
loading: boolean;
|
|
10
9
|
error: Error | undefined;
|
|
11
10
|
data: OptionType[] | undefined;
|
|
12
11
|
onSearch: ((value: string) => void) | undefined;
|
|
13
12
|
mathShowSearch: boolean | undefined;
|
|
14
|
-
reload: (reloadParams?: ParamsModal) => void
|
|
13
|
+
reload: (reloadParams?: ParamsModal) => void;
|
|
15
14
|
onPopupScroll: ((e: any) => void) | undefined;
|
|
16
15
|
};
|
|
17
16
|
export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
|
|
@@ -136,9 +136,17 @@ var useOptionsRequest = function useOptionsRequest(_ref) {
|
|
|
136
136
|
setData([].concat(_toConsumableArray(oldData), _toConsumableArray(op)));
|
|
137
137
|
}
|
|
138
138
|
}),
|
|
139
|
-
|
|
139
|
+
listRun = _useRequest.run,
|
|
140
140
|
loading = _useRequest.loading,
|
|
141
141
|
error = _useRequest.error;
|
|
142
|
+
var run = function run() {
|
|
143
|
+
var requestParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
144
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "init";
|
|
145
|
+
if (loading) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
listRun(requestParams, type);
|
|
149
|
+
};
|
|
142
150
|
return {
|
|
143
151
|
loading: loading,
|
|
144
152
|
run: run,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OptionType, PartialHSelectProps } from "@/components/Select/modal";
|
|
2
|
+
export declare const matchNotFind: ({ options, value, mode }: PartialHSelectProps, oldVale?: OptionType[]) => any[] | {
|
|
3
|
+
value: any;
|
|
4
|
+
label: any;
|
|
5
|
+
noMatch?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
value: any;
|
|
8
|
+
label: any;
|
|
9
|
+
noMatch: boolean;
|
|
10
|
+
};
|