@hi-ui/check-select 4.0.0-beta.26 → 4.0.0-beta.29
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/lib/cjs/CheckSelect.js +33 -10
- package/lib/esm/CheckSelect.js +33 -10
- package/lib/types/CheckSelect.d.ts +0 -4
- package/package.json +11 -11
package/lib/cjs/CheckSelect.js
CHANGED
@@ -114,7 +114,7 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
114
114
|
onSearchProp = _a.onSearch,
|
115
115
|
_a$fieldNames = _a.fieldNames,
|
116
116
|
fieldNames = _a$fieldNames === void 0 ? DEFAULT_FIELD_NAMES : _a$fieldNames,
|
117
|
-
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "disabled", "clearable", "
|
117
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "disabled", "clearable", "showCheckAll", "showOnlyShowChecked", "placeholder", "displayRender", "onSelect", "height", "itemHeight", "virtual", "onOpen", "onClose", "appearance", "invalid", "dataSource", "filterOption", "searchable", "render", "renderExtraFooter", "onSearch", "fieldNames"]);
|
118
118
|
|
119
119
|
var i18n = localeContext.useLocaleContext();
|
120
120
|
var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('checkSelect.placeholder') : placeholderProp; // ************************** Picker ************************* //
|
@@ -250,23 +250,46 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
250
250
|
allChecked = _useMemo[0],
|
251
251
|
indeterminate = _useMemo[1];
|
252
252
|
|
253
|
+
var valueLatestRef = useLatest.useLatestRef(value);
|
253
254
|
var toggleCheckAll = React.useCallback(function (showChecked) {
|
254
|
-
var
|
255
|
-
|
256
|
-
});
|
255
|
+
var value = valueLatestRef.current; // 当前页的数据选项
|
256
|
+
|
257
257
|
var items = dropdownItems.filter(function (item) {
|
258
258
|
return !('groupTitle' in item);
|
259
259
|
});
|
260
|
+
var targetIds = items.map(function (_ref2) {
|
261
|
+
var id = _ref2.id;
|
262
|
+
return id;
|
263
|
+
});
|
260
264
|
|
261
265
|
if (showChecked) {
|
262
|
-
|
263
|
-
|
264
|
-
return id;
|
265
|
-
})
|
266
|
+
var nextCheckedIds = Array.from(new Set(value.concat(targetIds)));
|
267
|
+
var changedIds = nextCheckedIds.filter(function (id) {
|
268
|
+
return !value.includes(id);
|
269
|
+
});
|
270
|
+
var changedItems = mergedData.filter(function (_ref3) {
|
271
|
+
var id = _ref3.id;
|
272
|
+
return changedIds.includes(id);
|
273
|
+
});
|
274
|
+
tryChangeValue(nextCheckedIds, changedItems, showChecked);
|
266
275
|
} else {
|
267
|
-
|
276
|
+
var _nextCheckedIds = value.filter(function (id) {
|
277
|
+
return !targetIds.includes(id);
|
278
|
+
});
|
279
|
+
|
280
|
+
var _changedIds = value.filter(function (id) {
|
281
|
+
return !_nextCheckedIds.includes(id);
|
282
|
+
});
|
283
|
+
|
284
|
+
var _changedItems = mergedData.filter(function (_ref4) {
|
285
|
+
var id = _ref4.id;
|
286
|
+
return _changedIds.includes(id);
|
287
|
+
}); // items
|
288
|
+
|
289
|
+
|
290
|
+
tryChangeValue(_nextCheckedIds, _changedItems, showChecked);
|
268
291
|
}
|
269
|
-
}, [dropdownItems, mergedData,
|
292
|
+
}, [dropdownItems, mergedData, valueLatestRef, tryChangeValue]);
|
270
293
|
|
271
294
|
var renderDefaultFooter = function renderDefaultFooter() {
|
272
295
|
var extra = renderExtraFooter ? renderExtraFooter() : null;
|
package/lib/esm/CheckSelect.js
CHANGED
@@ -72,7 +72,7 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
72
72
|
onSearchProp = _a.onSearch,
|
73
73
|
_a$fieldNames = _a.fieldNames,
|
74
74
|
fieldNames = _a$fieldNames === void 0 ? DEFAULT_FIELD_NAMES : _a$fieldNames,
|
75
|
-
rest = __rest(_a, ["prefixCls", "role", "className", "children", "disabled", "clearable", "
|
75
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "children", "disabled", "clearable", "showCheckAll", "showOnlyShowChecked", "placeholder", "displayRender", "onSelect", "height", "itemHeight", "virtual", "onOpen", "onClose", "appearance", "invalid", "dataSource", "filterOption", "searchable", "render", "renderExtraFooter", "onSearch", "fieldNames"]);
|
76
76
|
|
77
77
|
var i18n = useLocaleContext();
|
78
78
|
var placeholder = isUndef(placeholderProp) ? i18n.get('checkSelect.placeholder') : placeholderProp; // ************************** Picker ************************* //
|
@@ -208,23 +208,46 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
208
208
|
allChecked = _useMemo[0],
|
209
209
|
indeterminate = _useMemo[1];
|
210
210
|
|
211
|
+
var valueLatestRef = useLatestRef(value);
|
211
212
|
var toggleCheckAll = useCallback(function (showChecked) {
|
212
|
-
var
|
213
|
-
|
214
|
-
});
|
213
|
+
var value = valueLatestRef.current; // 当前页的数据选项
|
214
|
+
|
215
215
|
var items = dropdownItems.filter(function (item) {
|
216
216
|
return !('groupTitle' in item);
|
217
217
|
});
|
218
|
+
var targetIds = items.map(function (_ref2) {
|
219
|
+
var id = _ref2.id;
|
220
|
+
return id;
|
221
|
+
});
|
218
222
|
|
219
223
|
if (showChecked) {
|
220
|
-
|
221
|
-
|
222
|
-
return id;
|
223
|
-
})
|
224
|
+
var nextCheckedIds = Array.from(new Set(value.concat(targetIds)));
|
225
|
+
var changedIds = nextCheckedIds.filter(function (id) {
|
226
|
+
return !value.includes(id);
|
227
|
+
});
|
228
|
+
var changedItems = mergedData.filter(function (_ref3) {
|
229
|
+
var id = _ref3.id;
|
230
|
+
return changedIds.includes(id);
|
231
|
+
});
|
232
|
+
tryChangeValue(nextCheckedIds, changedItems, showChecked);
|
224
233
|
} else {
|
225
|
-
|
234
|
+
var _nextCheckedIds = value.filter(function (id) {
|
235
|
+
return !targetIds.includes(id);
|
236
|
+
});
|
237
|
+
|
238
|
+
var _changedIds = value.filter(function (id) {
|
239
|
+
return !_nextCheckedIds.includes(id);
|
240
|
+
});
|
241
|
+
|
242
|
+
var _changedItems = mergedData.filter(function (_ref4) {
|
243
|
+
var id = _ref4.id;
|
244
|
+
return _changedIds.includes(id);
|
245
|
+
}); // items
|
246
|
+
|
247
|
+
|
248
|
+
tryChangeValue(_nextCheckedIds, _changedItems, showChecked);
|
226
249
|
}
|
227
|
-
}, [dropdownItems, mergedData,
|
250
|
+
}, [dropdownItems, mergedData, valueLatestRef, tryChangeValue]);
|
228
251
|
|
229
252
|
var renderDefaultFooter = function renderDefaultFooter() {
|
230
253
|
var extra = renderExtraFooter ? renderExtraFooter() : null;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/check-select",
|
3
|
-
"version": "4.0.0-beta.
|
3
|
+
"version": "4.0.0-beta.29",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
@@ -44,19 +44,19 @@
|
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
46
|
"@hi-ui/array-utils": "^4.0.0-beta.7",
|
47
|
-
"@hi-ui/checkbox": "^4.0.0-beta.
|
47
|
+
"@hi-ui/checkbox": "^4.0.0-beta.11",
|
48
48
|
"@hi-ui/classname": "^4.0.0-beta.0",
|
49
49
|
"@hi-ui/core": "^4.0.0-beta.8",
|
50
50
|
"@hi-ui/core-css": "^4.0.0-beta.5",
|
51
51
|
"@hi-ui/env": "^4.0.0-beta.0",
|
52
|
-
"@hi-ui/func-utils": "^4.0.0-beta.
|
53
|
-
"@hi-ui/highlighter": "^4.0.0-beta.
|
52
|
+
"@hi-ui/func-utils": "^4.0.0-beta.12",
|
53
|
+
"@hi-ui/highlighter": "^4.0.0-beta.9",
|
54
54
|
"@hi-ui/icons": "^4.0.0-beta.10",
|
55
|
-
"@hi-ui/input": "^4.0.0-beta.
|
56
|
-
"@hi-ui/locale-context": "^4.0.0-beta.
|
57
|
-
"@hi-ui/picker": "^4.0.0-beta.
|
58
|
-
"@hi-ui/popper": "^4.0.0-beta.
|
59
|
-
"@hi-ui/tag-input": "^4.0.0-beta.
|
55
|
+
"@hi-ui/input": "^4.0.0-beta.14",
|
56
|
+
"@hi-ui/locale-context": "^4.0.0-beta.18",
|
57
|
+
"@hi-ui/picker": "^4.0.0-beta.23",
|
58
|
+
"@hi-ui/popper": "^4.0.0-beta.13",
|
59
|
+
"@hi-ui/tag-input": "^4.0.0-beta.18",
|
60
60
|
"@hi-ui/times": "^4.0.0-beta.5",
|
61
61
|
"@hi-ui/tree-utils": "^4.0.0-beta.4",
|
62
62
|
"@hi-ui/type-assertion": "^4.0.0-beta.4",
|
@@ -64,7 +64,7 @@
|
|
64
64
|
"@hi-ui/use-children": "^4.0.0-beta.4",
|
65
65
|
"@hi-ui/use-data-source": "^4.0.0-beta.5",
|
66
66
|
"@hi-ui/use-latest": "^4.0.0-beta.4",
|
67
|
-
"@hi-ui/use-search-mode": "^4.0.0-beta.
|
67
|
+
"@hi-ui/use-search-mode": "^4.0.0-beta.18",
|
68
68
|
"@hi-ui/use-toggle": "^4.0.0-beta.4",
|
69
69
|
"@hi-ui/use-uncontrolled-state": "^4.0.0-beta.4",
|
70
70
|
"rc-virtual-list": "^3.4.1"
|
@@ -78,5 +78,5 @@
|
|
78
78
|
"react": "^17.0.1",
|
79
79
|
"react-dom": "^17.0.1"
|
80
80
|
},
|
81
|
-
"gitHead": "
|
81
|
+
"gitHead": "7f47840510e6dfce429eeed1591c154e321cd14f"
|
82
82
|
}
|