@hw-component/form 1.6.2 → 1.6.4
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 -143
- package/es/Select/hooks/norHooks.d.ts +6 -4
- package/es/Select/hooks/norHooks.js +137 -29
- package/es/Select/hooks/util.d.ts +10 -0
- package/es/Select/hooks/util.js +138 -0
- package/es/Select/index.js +17 -12
- package/es/Select/modal.d.ts +11 -2
- package/lib/Select/hooks/changeHooks.js +35 -144
- package/lib/Select/hooks/norHooks.d.ts +6 -4
- package/lib/Select/hooks/norHooks.js +136 -28
- package/lib/Select/hooks/util.d.ts +10 -0
- package/lib/Select/hooks/util.js +139 -0
- package/lib/Select/index.js +16 -11
- package/lib/Select/modal.d.ts +11 -2
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +1 -1
- package/src/components/DialogForm/ModalForm.tsx +1 -1
- package/src/components/Form/hooks/useDefaultRender.tsx +1 -1
- package/src/components/Form/hooks/useHForm.ts +1 -1
- package/src/components/Form/index.tsx +4 -4
- package/src/components/Input/ButtonInput.tsx +2 -2
- package/src/components/Select/hooks/changeHooks.tsx +30 -107
- package/src/components/Select/hooks/norHooks.ts +107 -17
- package/src/components/Select/hooks/util.ts +109 -0
- package/src/components/Select/index.tsx +7 -2
- package/src/components/Select/modal.ts +14 -2
- package/src/components/Submit/components.tsx +7 -3
- package/src/components/Upload/hooks/customRequest.ts +6 -6
- package/src/pages/DrawerForm/index.tsx +9 -9
- package/src/pages/Form/index.tsx +22 -29
- package/src/pages/Select/index.tsx +25 -3
- package/src/pages/Upload/index.tsx +16 -13
|
@@ -1,150 +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
|
-
if (!mode) {
|
|
130
|
-
return single({
|
|
131
|
-
options: options,
|
|
132
|
-
value: value,
|
|
133
|
-
noMatchItemRender: noMatchItemRender
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
if (mode === "multiple") {
|
|
137
|
-
return multiple({
|
|
138
|
-
options: options,
|
|
139
|
-
value: value,
|
|
140
|
-
noMatchItemRender: noMatchItemRender
|
|
141
|
-
}, oldVale) || [];
|
|
142
|
-
}
|
|
143
|
-
return tag({
|
|
144
|
-
options: options,
|
|
145
|
-
value: value
|
|
146
|
-
}, oldVale);
|
|
147
|
-
};
|
|
148
8
|
var useValueChange = function useValueChange(params) {
|
|
149
9
|
var labelInValue = params.labelInValue,
|
|
150
10
|
onChange = params.onChange,
|
|
@@ -193,9 +53,40 @@ var useValueChange = function useValueChange(params) {
|
|
|
193
53
|
return matchNotFind(params, oldVale);
|
|
194
54
|
});
|
|
195
55
|
}
|
|
196
|
-
}, [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
|
+
};
|
|
197
88
|
return {
|
|
198
|
-
val:
|
|
89
|
+
val: valuesMaker(),
|
|
199
90
|
change: change
|
|
200
91
|
};
|
|
201
92
|
};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type { OptionType, PartialHSelectProps } from "
|
|
1
|
+
import type { OptionType, PartialHSelectProps } from "../modal";
|
|
2
|
+
import { OptionsPageResultModal } from "../modal";
|
|
2
3
|
interface ParamsModal {
|
|
3
4
|
options?: OptionType[];
|
|
4
5
|
params?: any;
|
|
5
6
|
}
|
|
6
|
-
export declare const
|
|
7
|
-
run: (requestParams?: any) => Promise<OptionType[] | undefined>;
|
|
7
|
+
export declare const useSelectReq: ({ manual, request, options, serviceSearch, showSearch, onSearch: propsOnSearch, dispatch, isList, }: PartialHSelectProps) => {
|
|
8
|
+
run: (requestParams?: any, type?: any) => Promise<OptionType[] | OptionsPageResultModal | undefined>;
|
|
8
9
|
loading: boolean;
|
|
9
10
|
error: Error | undefined;
|
|
10
11
|
data: OptionType[] | undefined;
|
|
11
12
|
onSearch: ((value: string) => void) | undefined;
|
|
12
13
|
mathShowSearch: boolean | undefined;
|
|
13
|
-
reload: (reloadParams?: ParamsModal) => void | Promise<OptionType[] | undefined>;
|
|
14
|
+
reload: (reloadParams?: ParamsModal) => void | Promise<OptionType[] | OptionsPageResultModal | undefined>;
|
|
15
|
+
onPopupScroll: ((e: any) => void) | undefined;
|
|
14
16
|
};
|
|
15
17
|
export declare const useFilterOption: ({ filterOption, serviceSearch, }: PartialHSelectProps) => boolean | import("rc-select/lib/Select").FilterFunc<import("rc-select/lib/Select").DefaultOptionType> | undefined;
|
|
16
18
|
export {};
|
|
@@ -1,57 +1,122 @@
|
|
|
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/web.dom-collections.for-each.js';
|
|
7
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
8
|
+
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
2
9
|
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
10
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
11
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
4
12
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
5
13
|
import 'core-js/modules/es.array.iterator.js';
|
|
6
14
|
import 'core-js/modules/es.object.to-string.js';
|
|
7
15
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
16
|
import 'core-js/modules/es.promise.js';
|
|
9
|
-
import
|
|
17
|
+
import 'core-js/modules/es.array.concat.js';
|
|
18
|
+
import { useEffect, useState, useMemo } from 'react';
|
|
10
19
|
import { useRequest } from 'ahooks';
|
|
11
20
|
import { useFormContext } from '../../Form/Context/index.js';
|
|
12
21
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
var useSaveParams = function useSaveParams() {
|
|
25
|
+
var saveParams = useMemo(function () {
|
|
26
|
+
return {
|
|
27
|
+
listParams: {
|
|
28
|
+
isEnd: false,
|
|
29
|
+
page: 1,
|
|
30
|
+
size: 100,
|
|
31
|
+
reqParams: {}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
var resetSaveParams = function resetSaveParams() {
|
|
36
|
+
saveParams.listParams = {
|
|
37
|
+
isEnd: false,
|
|
38
|
+
page: 1,
|
|
39
|
+
size: 100,
|
|
40
|
+
reqParams: {}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var nextPage = function nextPage(data) {
|
|
44
|
+
var size = data.size,
|
|
45
|
+
total = data.total,
|
|
46
|
+
page = data.page;
|
|
47
|
+
saveParams.listParams.size = size;
|
|
48
|
+
saveParams.listParams.page = page + 1;
|
|
49
|
+
saveParams.listParams.isEnd = size * page >= total;
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
saveParams: saveParams,
|
|
53
|
+
resetSaveParams: resetSaveParams,
|
|
54
|
+
nextPage: nextPage
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
var useOptionsRequest = function useOptionsRequest(_ref) {
|
|
58
|
+
var request = _ref.request,
|
|
20
59
|
_ref$dispatch = _ref.dispatch,
|
|
21
|
-
dispatch = _ref$dispatch === void 0 ? {} : _ref$dispatch
|
|
22
|
-
|
|
60
|
+
dispatch = _ref$dispatch === void 0 ? {} : _ref$dispatch,
|
|
61
|
+
manual = _ref.manual,
|
|
62
|
+
options = _ref.options,
|
|
63
|
+
isList = _ref.isList;
|
|
64
|
+
var _useSaveParams = useSaveParams(),
|
|
65
|
+
saveParams = _useSaveParams.saveParams,
|
|
66
|
+
resetSaveParams = _useSaveParams.resetSaveParams,
|
|
67
|
+
nextPage = _useSaveParams.nextPage;
|
|
23
68
|
var _useFormContext = useFormContext(),
|
|
24
69
|
form = _useFormContext.form;
|
|
70
|
+
var dispatchManual = dispatch.manual;
|
|
25
71
|
var _useState = useState(),
|
|
26
72
|
_useState2 = _slicedToArray(_useState, 2),
|
|
27
73
|
data = _useState2[0],
|
|
28
74
|
setData = _useState2[1];
|
|
75
|
+
var paramsProvider = function paramsProvider(params) {
|
|
76
|
+
if (isList) {
|
|
77
|
+
var page = saveParams.listParams.page;
|
|
78
|
+
var size = saveParams.listParams.size;
|
|
79
|
+
return _objectSpread(_objectSpread({}, params), {}, {
|
|
80
|
+
page: page,
|
|
81
|
+
size: size
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return params;
|
|
85
|
+
};
|
|
29
86
|
var _useRequest = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
30
87
|
var requestParams,
|
|
88
|
+
type,
|
|
31
89
|
_requestParams$params,
|
|
32
90
|
params,
|
|
33
91
|
values,
|
|
34
|
-
_requestParams$type,
|
|
35
|
-
type,
|
|
36
92
|
formData,
|
|
37
93
|
_args = arguments;
|
|
38
94
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
95
|
while (1) switch (_context.prev = _context.next) {
|
|
40
96
|
case 0:
|
|
41
97
|
requestParams = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
42
|
-
|
|
98
|
+
type = _args.length > 1 && _args[1] !== undefined ? _args[1] : "init";
|
|
99
|
+
_requestParams$params = requestParams.params, params = _requestParams$params === void 0 ? saveParams.listParams.reqParams : _requestParams$params, values = requestParams.values;
|
|
43
100
|
formData = values || (form === null || form === void 0 ? void 0 : form.getFieldsValue());
|
|
44
101
|
if (type === "init") {
|
|
102
|
+
resetSaveParams();
|
|
45
103
|
setData(undefined);
|
|
46
104
|
}
|
|
105
|
+
saveParams.listParams.reqParams = params;
|
|
106
|
+
if (!(isList && saveParams.listParams.isEnd)) {
|
|
107
|
+
_context.next = 8;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return _context.abrupt("return", data);
|
|
111
|
+
case 8:
|
|
47
112
|
if (!request) {
|
|
48
|
-
_context.next =
|
|
113
|
+
_context.next = 10;
|
|
49
114
|
break;
|
|
50
115
|
}
|
|
51
|
-
return _context.abrupt("return", request(params, formData));
|
|
52
|
-
case
|
|
116
|
+
return _context.abrupt("return", request(paramsProvider(params), formData));
|
|
117
|
+
case 10:
|
|
53
118
|
return _context.abrupt("return", Promise.resolve(options));
|
|
54
|
-
case
|
|
119
|
+
case 11:
|
|
55
120
|
case "end":
|
|
56
121
|
return _context.stop();
|
|
57
122
|
}
|
|
@@ -60,16 +125,53 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
60
125
|
manual: dispatchManual === false ? true : manual,
|
|
61
126
|
debounceInterval: 300,
|
|
62
127
|
onSuccess: function onSuccess(resultData) {
|
|
63
|
-
|
|
128
|
+
if (Array.isArray(resultData) || !resultData) {
|
|
129
|
+
return setData(resultData);
|
|
130
|
+
}
|
|
131
|
+
var oldData = data || [];
|
|
132
|
+
var resultOption = resultData.data;
|
|
133
|
+
var op = resultOption || [];
|
|
134
|
+
nextPage(resultData);
|
|
135
|
+
setData([].concat(_toConsumableArray(oldData), _toConsumableArray(op)));
|
|
64
136
|
}
|
|
65
137
|
}),
|
|
66
138
|
run = _useRequest.run,
|
|
67
139
|
loading = _useRequest.loading,
|
|
68
140
|
error = _useRequest.error;
|
|
141
|
+
return {
|
|
142
|
+
loading: loading,
|
|
143
|
+
run: run,
|
|
144
|
+
error: error,
|
|
145
|
+
data: data,
|
|
146
|
+
setData: setData
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
var useSelectReq = function useSelectReq(_ref3) {
|
|
150
|
+
var manual = _ref3.manual,
|
|
151
|
+
request = _ref3.request,
|
|
152
|
+
options = _ref3.options,
|
|
153
|
+
serviceSearch = _ref3.serviceSearch,
|
|
154
|
+
showSearch = _ref3.showSearch,
|
|
155
|
+
propsOnSearch = _ref3.onSearch,
|
|
156
|
+
_ref3$dispatch = _ref3.dispatch,
|
|
157
|
+
dispatch = _ref3$dispatch === void 0 ? {} : _ref3$dispatch,
|
|
158
|
+
isList = _ref3.isList;
|
|
159
|
+
var _useOptionsRequest = useOptionsRequest({
|
|
160
|
+
request: request,
|
|
161
|
+
dispatch: dispatch,
|
|
162
|
+
manual: manual,
|
|
163
|
+
options: options,
|
|
164
|
+
isList: isList
|
|
165
|
+
}),
|
|
166
|
+
run = _useOptionsRequest.run,
|
|
167
|
+
loading = _useOptionsRequest.loading,
|
|
168
|
+
error = _useOptionsRequest.error,
|
|
169
|
+
data = _useOptionsRequest.data,
|
|
170
|
+
setData = _useOptionsRequest.setData;
|
|
69
171
|
var reload = function reload(reloadParams) {
|
|
70
|
-
var
|
|
71
|
-
changeOpts =
|
|
72
|
-
params =
|
|
172
|
+
var _ref4 = reloadParams || {},
|
|
173
|
+
changeOpts = _ref4.options,
|
|
174
|
+
params = _ref4.params;
|
|
73
175
|
if (changeOpts) {
|
|
74
176
|
return setData(changeOpts);
|
|
75
177
|
}
|
|
@@ -93,6 +195,13 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
93
195
|
setData(options);
|
|
94
196
|
}
|
|
95
197
|
}, [options]);
|
|
198
|
+
var onPopupScroll = function onPopupScroll(e) {
|
|
199
|
+
var target = e.target;
|
|
200
|
+
var changeTarget = target;
|
|
201
|
+
if (changeTarget.scrollTop + changeTarget.offsetHeight === changeTarget.scrollHeight) {
|
|
202
|
+
run({}, "page");
|
|
203
|
+
}
|
|
204
|
+
};
|
|
96
205
|
var mathShowSearch = showSearch || serviceSearch;
|
|
97
206
|
return {
|
|
98
207
|
run: run,
|
|
@@ -101,19 +210,18 @@ var useOptionReq = function useOptionReq(_ref) {
|
|
|
101
210
|
data: data,
|
|
102
211
|
onSearch: mathShowSearch ? onSearch : propsOnSearch,
|
|
103
212
|
mathShowSearch: showSearch || serviceSearch,
|
|
104
|
-
reload: reload
|
|
213
|
+
reload: reload,
|
|
214
|
+
onPopupScroll: isList ? onPopupScroll : undefined
|
|
105
215
|
};
|
|
106
216
|
};
|
|
107
|
-
var useFilterOption = function useFilterOption(
|
|
108
|
-
var filterOption =
|
|
109
|
-
serviceSearch =
|
|
217
|
+
var useFilterOption = function useFilterOption(_ref5) {
|
|
218
|
+
var filterOption = _ref5.filterOption,
|
|
219
|
+
serviceSearch = _ref5.serviceSearch;
|
|
110
220
|
if (serviceSearch) {
|
|
111
|
-
return
|
|
112
|
-
return true;
|
|
113
|
-
};
|
|
221
|
+
return false;
|
|
114
222
|
}
|
|
115
223
|
return filterOption;
|
|
116
224
|
};
|
|
117
225
|
|
|
118
|
-
export { useFilterOption,
|
|
226
|
+
export { useFilterOption, useSelectReq };
|
|
119
227
|
// powered by hdj
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { 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
|
package/es/Select/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import 'core-js/modules/es.array.map.js';
|
|
|
12
12
|
import { jsx } from 'react/jsx-runtime';
|
|
13
13
|
import { createElement } from 'react';
|
|
14
14
|
import { Select } from 'antd';
|
|
15
|
-
import { useFilterOption,
|
|
15
|
+
import { useFilterOption, useSelectReq } from './hooks/norHooks.js';
|
|
16
16
|
import { useValueChange } from './hooks/changeHooks.js';
|
|
17
17
|
import { defaultModeConfig, defaultSelectConfig } from './defaultConfig.js';
|
|
18
18
|
import Index$1 from './components/DropdownComponent.js';
|
|
@@ -20,7 +20,7 @@ import Index$2 from './components/AllSelect.js';
|
|
|
20
20
|
import { useMatchConfigProps, useChangeOptions } from '../hooks/index.js';
|
|
21
21
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"],
|
|
23
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch", "isList", "onPopupScroll"],
|
|
24
24
|
_excluded2 = ["value", "label"];
|
|
25
25
|
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; }
|
|
26
26
|
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; }
|
|
@@ -55,6 +55,8 @@ var Index = function Index(_ref) {
|
|
|
55
55
|
addDispatchListener = _ref.addDispatchListener;
|
|
56
56
|
_ref.addFormat;
|
|
57
57
|
var dispatch = _ref.dispatch,
|
|
58
|
+
isList = _ref.isList,
|
|
59
|
+
propsOnPopupScroll = _ref.onPopupScroll,
|
|
58
60
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
59
61
|
var _ref2 = (modeConfig === null || modeConfig === void 0 ? void 0 : modeConfig[mode || ""]) || {},
|
|
60
62
|
icon = _ref2.icon,
|
|
@@ -67,7 +69,7 @@ var Index = function Index(_ref) {
|
|
|
67
69
|
filterOption: filterOption,
|
|
68
70
|
serviceSearch: serviceSearch
|
|
69
71
|
});
|
|
70
|
-
var
|
|
72
|
+
var _useSelectReq = useSelectReq({
|
|
71
73
|
options: options,
|
|
72
74
|
manual: manual,
|
|
73
75
|
fieldNames: fieldNames,
|
|
@@ -75,15 +77,17 @@ var Index = function Index(_ref) {
|
|
|
75
77
|
serviceSearch: serviceSearch,
|
|
76
78
|
showSearch: showSearch,
|
|
77
79
|
onSearch: propsOnSearch,
|
|
78
|
-
dispatch: dispatch
|
|
80
|
+
dispatch: dispatch,
|
|
81
|
+
isList: isList
|
|
79
82
|
}),
|
|
80
|
-
run =
|
|
81
|
-
loading =
|
|
82
|
-
resultData =
|
|
83
|
-
error =
|
|
84
|
-
onSearch =
|
|
85
|
-
mathShowSearch =
|
|
86
|
-
reload =
|
|
83
|
+
run = _useSelectReq.run,
|
|
84
|
+
loading = _useSelectReq.loading,
|
|
85
|
+
resultData = _useSelectReq.data,
|
|
86
|
+
error = _useSelectReq.error,
|
|
87
|
+
onSearch = _useSelectReq.onSearch,
|
|
88
|
+
mathShowSearch = _useSelectReq.mathShowSearch,
|
|
89
|
+
reload = _useSelectReq.reload,
|
|
90
|
+
onPopupScroll = _useSelectReq.onPopupScroll;
|
|
87
91
|
var data = useChangeOptions({
|
|
88
92
|
options: resultData,
|
|
89
93
|
fieldNames: fieldNames
|
|
@@ -129,7 +133,8 @@ var Index = function Index(_ref) {
|
|
|
129
133
|
optionFilterProp: optionFilterProp,
|
|
130
134
|
filterOption: selfFilterOption,
|
|
131
135
|
showSearch: mathShowSearch,
|
|
132
|
-
labelInValue: true
|
|
136
|
+
labelInValue: true,
|
|
137
|
+
onPopupScroll: propsOnPopupScroll || onPopupScroll
|
|
133
138
|
}, props), {}, {
|
|
134
139
|
children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
135
140
|
var optionValue = item.value,
|