@kne/super-select 0.1.48 → 0.1.49
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/README.md +2 -2
- package/dist/index.js +124 -63
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +223 -159
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2557,7 +2557,7 @@ render(<BaseExample />);
|
|
|
2557
2557
|
|
|
2558
2558
|
#### SelectTableList
|
|
2559
2559
|
|
|
2560
|
-
表格形式的选择组件,适用于需要展示多列数据的选择场景。基于 `@kne/table-
|
|
2560
|
+
表格形式的选择组件,适用于需要展示多列数据的选择场景。基于 `@kne/table-view` 的 `Table` 与 `@kne/react-fetch`,支持普通列表与树形(`tree` / `treeList`)选择;桌面端滚动时表头固定,横向滚动条吸附在可视区域底部。
|
|
2561
2561
|
|
|
2562
2562
|
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2563
2563
|
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | --------------- |
|
|
@@ -2587,7 +2587,7 @@ render(<BaseExample />);
|
|
|
2587
2587
|
|
|
2588
2588
|
树形说明:
|
|
2589
2589
|
|
|
2590
|
-
- `tree` / `treeList` 能力透传自 `@kne/table-
|
|
2590
|
+
- `tree` / `treeList` 能力透传自 `@kne/table-view`(展开收起、缩进、半选、移动端面包屑等)
|
|
2591
2591
|
- 搜索(`getSearchCallback`)在 `tree` 下递归过滤并保留祖先;在 `treeList` 下匹配节点时自动带上祖先路径
|
|
2592
2592
|
- 懒加载示例:`onLoadChildren` 内用包导出的 `mergeTreeChildren` 更新 `options`
|
|
2593
2593
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var React = require('react');
|
|
1
|
+
var React$1 = require('react');
|
|
2
2
|
var reactDom = require('react-dom');
|
|
3
3
|
var globalContext = require('@kne/global-context');
|
|
4
4
|
var useResize = require('@kne/use-resize');
|
|
@@ -19,17 +19,17 @@ var SearchInput = require('@kne/search-input');
|
|
|
19
19
|
var scrollLoader = require('@kne/scroll-loader');
|
|
20
20
|
require('@kne/scroll-loader/dist/index.css');
|
|
21
21
|
var merge = require('lodash/merge');
|
|
22
|
-
var
|
|
23
|
-
require('@kne/table-
|
|
22
|
+
var tableView = require('@kne/table-view');
|
|
23
|
+
require('@kne/table-view/dist/index.css');
|
|
24
|
+
var Fetch = require('@kne/react-fetch');
|
|
24
25
|
var infoPage = require('@kne/info-page');
|
|
25
26
|
require('@kne/info-page/dist/index.css');
|
|
26
27
|
var memoize = require('lodash/memoize');
|
|
27
28
|
var isNil = require('lodash/isNil');
|
|
28
|
-
var Fetch = require('@kne/react-fetch');
|
|
29
29
|
|
|
30
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
31
|
|
|
32
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
32
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
|
|
33
33
|
var useResize__default = /*#__PURE__*/_interopDefaultLegacy(useResize);
|
|
34
34
|
var useControlValue__default = /*#__PURE__*/_interopDefaultLegacy(useControlValue);
|
|
35
35
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
@@ -39,10 +39,9 @@ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
|
39
39
|
var SimpleBar__default = /*#__PURE__*/_interopDefaultLegacy(SimpleBar);
|
|
40
40
|
var SearchInput__default = /*#__PURE__*/_interopDefaultLegacy(SearchInput);
|
|
41
41
|
var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
|
|
42
|
-
var
|
|
42
|
+
var Fetch__default = /*#__PURE__*/_interopDefaultLegacy(Fetch);
|
|
43
43
|
var memoize__default = /*#__PURE__*/_interopDefaultLegacy(memoize);
|
|
44
44
|
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
45
|
-
var Fetch__default = /*#__PURE__*/_interopDefaultLegacy(Fetch);
|
|
46
45
|
|
|
47
46
|
function _extends() {
|
|
48
47
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -104,7 +103,7 @@ const TagOverflowInner = ({
|
|
|
104
103
|
const list = Array.isArray(value) ? value : [];
|
|
105
104
|
const availableWidth = Math.max((innerWidth || 0) - iconSpace, 0);
|
|
106
105
|
const maxTagWidth = innerWidth > 0 ? Math.min(150, Math.max(60, innerWidth - 60)) : 150;
|
|
107
|
-
const shareItems = React.useMemo(() => list.map(item => ({
|
|
106
|
+
const shareItems = React$1.useMemo(() => list.map(item => ({
|
|
108
107
|
key: item?.[valueKey],
|
|
109
108
|
label: item?.[labelKey]
|
|
110
109
|
})), [list, labelKey, valueKey]);
|
|
@@ -239,7 +238,7 @@ const lockParentScroll = getScrollElements => {
|
|
|
239
238
|
};
|
|
240
239
|
};
|
|
241
240
|
const useLockParentScroll = (enabled, getScrollElements) => {
|
|
242
|
-
React.useEffect(() => {
|
|
241
|
+
React$1.useEffect(() => {
|
|
243
242
|
if (!enabled) {
|
|
244
243
|
return undefined;
|
|
245
244
|
}
|
|
@@ -271,8 +270,8 @@ const ModalContent = _ref2 => {
|
|
|
271
270
|
open,
|
|
272
271
|
value: propsValue
|
|
273
272
|
} = others;
|
|
274
|
-
const [value, setValue] = React.useState(propsValue);
|
|
275
|
-
React.useEffect(() => {
|
|
273
|
+
const [value, setValue] = React$1.useState(propsValue);
|
|
274
|
+
React$1.useEffect(() => {
|
|
276
275
|
if (open && !isEqual__default["default"](value, propsValue)) {
|
|
277
276
|
setValue(propsValue);
|
|
278
277
|
}
|
|
@@ -303,9 +302,9 @@ const MobileSheetMask = _ref3 => {
|
|
|
303
302
|
fixedModeClass,
|
|
304
303
|
onClose
|
|
305
304
|
} = _ref3;
|
|
306
|
-
const [renderMask, setRenderMask] = React.useState(false);
|
|
307
|
-
const [maskClosing, setMaskClosing] = React.useState(false);
|
|
308
|
-
React.useEffect(() => {
|
|
305
|
+
const [renderMask, setRenderMask] = React$1.useState(false);
|
|
306
|
+
const [maskClosing, setMaskClosing] = React$1.useState(false);
|
|
307
|
+
React$1.useEffect(() => {
|
|
309
308
|
if (open) {
|
|
310
309
|
setRenderMask(true);
|
|
311
310
|
setMaskClosing(false);
|
|
@@ -408,7 +407,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
408
407
|
'zh-CN': locale$1,
|
|
409
408
|
'en-US': locale
|
|
410
409
|
}
|
|
411
|
-
})(React.forwardRef((p, ref) => {
|
|
410
|
+
})(React$1.forwardRef((p, ref) => {
|
|
412
411
|
const intl = reactIntl.useIntl();
|
|
413
412
|
const {
|
|
414
413
|
formatMessage
|
|
@@ -542,7 +541,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
542
541
|
} = props;
|
|
543
542
|
const getPopupContainerDefault = responsiveUtils.usePopupContainer();
|
|
544
543
|
const getScrollElement = responsiveUtils.useScrollElement();
|
|
545
|
-
const wrapCustomGetPopupContainer = React.useMemo(() => {
|
|
544
|
+
const wrapCustomGetPopupContainer = React$1.useMemo(() => {
|
|
546
545
|
if (typeof getPopupContainerProp === 'function') {
|
|
547
546
|
return triggerNode => getPopupContainerProp(triggerNode) || null;
|
|
548
547
|
}
|
|
@@ -578,16 +577,16 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
578
577
|
} : {
|
|
579
578
|
defaultValue: transformValue(props.defaultValue)
|
|
580
579
|
}));
|
|
581
|
-
const [searchProps, setSearchProps] = React.useState({});
|
|
580
|
+
const [searchProps, setSearchProps] = React$1.useState({});
|
|
582
581
|
const [open, setOpen] = useControlValue__default["default"](props, {
|
|
583
582
|
defaultValue: 'defaultOpen',
|
|
584
583
|
value: 'open',
|
|
585
584
|
onChange: 'onOpenChange'
|
|
586
585
|
});
|
|
587
|
-
const [hover, setHover] = React.useState(false);
|
|
588
|
-
const [innerWidth, setInnerWidth] = React.useState(0);
|
|
589
|
-
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
590
|
-
const [popupMountNode, setPopupMountNode] = React.useState(null);
|
|
586
|
+
const [hover, setHover] = React$1.useState(false);
|
|
587
|
+
const [innerWidth, setInnerWidth] = React$1.useState(0);
|
|
588
|
+
const [containerWidth, setContainerWidth] = React$1.useState(0);
|
|
589
|
+
const [popupMountNode, setPopupMountNode] = React$1.useState(null);
|
|
591
590
|
const containerWidthChange = el => {
|
|
592
591
|
if (!el) {
|
|
593
592
|
return;
|
|
@@ -597,13 +596,13 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
597
596
|
const innerEl = el.querySelector('.select-input-inner');
|
|
598
597
|
setInnerWidth(innerEl.clientWidth);
|
|
599
598
|
};
|
|
600
|
-
const popupOverlayWidth = React.useMemo(() => {
|
|
599
|
+
const popupOverlayWidth = React$1.useMemo(() => {
|
|
601
600
|
const configured = overlayWidth != null && overlayWidth !== '' ? pxToNumber(overlayWidth) : DEFAULT_OVERLAY_MIN_WIDTH;
|
|
602
601
|
return numberToPx$1(Math.max(containerWidth || 0, configured));
|
|
603
602
|
}, [containerWidth, overlayWidth]);
|
|
604
603
|
|
|
605
604
|
// 同步给 Dropdown 外层 minWidth,避免 antd 按窄触发器裁剪面板
|
|
606
|
-
const mergedOverlayStyle = React.useMemo(() => {
|
|
605
|
+
const mergedOverlayStyle = React$1.useMemo(() => {
|
|
607
606
|
return Object.assign({}, overlayStyle, zIndex != null ? {
|
|
608
607
|
zIndex
|
|
609
608
|
} : null, {
|
|
@@ -612,11 +611,11 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
612
611
|
});
|
|
613
612
|
}, [overlayStyle, zIndex, popupOverlayWidth]);
|
|
614
613
|
const resizeRef = useResize__default["default"](containerWidthChange);
|
|
615
|
-
const setContainerRef = React.useCallback(node => {
|
|
614
|
+
const setContainerRef = React$1.useCallback(node => {
|
|
616
615
|
resizeRef.current = node;
|
|
617
616
|
anchorRef(node);
|
|
618
617
|
}, [anchorRef, resizeRef]);
|
|
619
|
-
const resolveGetPopupContainer = React.useCallback(triggerNode => {
|
|
618
|
+
const resolveGetPopupContainer = React$1.useCallback(triggerNode => {
|
|
620
619
|
if (typeof getPopupContainerProp === 'function') {
|
|
621
620
|
const customContainer = getPopupContainerProp(triggerNode);
|
|
622
621
|
if (customContainer) {
|
|
@@ -632,14 +631,14 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
632
631
|
}, [getPopupContainerDefault, getPopupContainerProp, getSheetPopupContainer, useMobileSheet]);
|
|
633
632
|
|
|
634
633
|
// 打开时再取挂载节点,避免落到错误容器
|
|
635
|
-
React.useLayoutEffect(() => {
|
|
634
|
+
React$1.useLayoutEffect(() => {
|
|
636
635
|
if (!useMobileSheet) {
|
|
637
636
|
setPopupMountNode(null);
|
|
638
637
|
return;
|
|
639
638
|
}
|
|
640
639
|
setPopupMountNode(resolveGetPopupContainer(resizeRef.current) || (typeof document !== 'undefined' ? document.body : null));
|
|
641
640
|
}, [useMobileSheet, resolveGetPopupContainer, open, resizeRef]);
|
|
642
|
-
const getLockScrollTargets = React.useCallback(() => {
|
|
641
|
+
const getLockScrollTargets = React$1.useCallback(() => {
|
|
643
642
|
const targets = [];
|
|
644
643
|
const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
|
|
645
644
|
if (scrollEl) {
|
|
@@ -705,12 +704,12 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
705
704
|
return newValue;
|
|
706
705
|
});
|
|
707
706
|
};
|
|
708
|
-
const handleOpenChange = React.useCallback(nextOpen => {
|
|
707
|
+
const handleOpenChange = React$1.useCallback(nextOpen => {
|
|
709
708
|
setOpen(nextOpen);
|
|
710
709
|
}, [setOpen]);
|
|
711
710
|
|
|
712
711
|
// 关闭时清空搜索,保证下次展开重新请求且从初始搜索态开始
|
|
713
|
-
React.useEffect(() => {
|
|
712
|
+
React$1.useEffect(() => {
|
|
714
713
|
if (!open) {
|
|
715
714
|
setSearchProps({});
|
|
716
715
|
}
|
|
@@ -796,7 +795,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
796
795
|
}, current);
|
|
797
796
|
})());
|
|
798
797
|
};
|
|
799
|
-
React.useImperativeHandle(ref, () => {
|
|
798
|
+
React$1.useImperativeHandle(ref, () => {
|
|
800
799
|
return contextProps;
|
|
801
800
|
});
|
|
802
801
|
|
|
@@ -981,12 +980,12 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
981
980
|
|
|
982
981
|
var style$3 = {"kne-responsive-boundary":"kne-super-select_Nc-y4","kne-responsive-scroll":"kne-super-select_RlrDm","list":"kne-super-select_IsXdU","empty":"kne-super-select_SQZ8k","default-list":"kne-super-select_QD1Mz","is-selected-all":"kne-super-select_M-mOy","default-list-item":"kne-super-select_KtOsz","is-selected":"kne-super-select_TQhBB","single-checked":"kne-super-select_2rUrh","is-disabled":"kne-super-select_NbwX5","selected-all":"kne-super-select_vN2Fx","selected-tag":"kne-super-select_6oITk","select-search":"kne-super-select_iAH9D","select-list-item-description":"kne-super-select_TCkeJ","footer":"kne-super-select_v3f23","is-mobile":"kne-super-select_w-WB8"};
|
|
983
982
|
|
|
984
|
-
const SelectList = React.forwardRef((_ref, ref) => {
|
|
983
|
+
const SelectList = React$1.forwardRef((_ref, ref) => {
|
|
985
984
|
let {
|
|
986
985
|
children,
|
|
987
986
|
...p
|
|
988
987
|
} = _ref;
|
|
989
|
-
const fetchListRef = React.useRef(null);
|
|
988
|
+
const fetchListRef = React$1.useRef(null);
|
|
990
989
|
const props = Object.assign({}, {
|
|
991
990
|
renderItemContent: _ref2 => {
|
|
992
991
|
let {
|
|
@@ -1197,6 +1196,68 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1197
1196
|
|
|
1198
1197
|
var style$2 = {"body":"kne-super-select_704J1","is-mobile":"kne-super-select_HYGUN","table-panel-wrap":"kne-super-select_Boo1a","selected-panel-wrap":"kne-super-select_q-BjK","table-panel":"kne-super-select_UAejp","filter-wrap":"kne-super-select_gmlBv","table":"kne-super-select_zE-14","list":"kne-super-select_DrEYJ","is-fit-columns":"kne-super-select_QqZxW","empty":"kne-super-select_5Tyrt","right-options-col":"kne-super-select_sNBrJ","right-options":"kne-super-select_UXi-g","no-padding-btn":"kne-super-select_iaCir","selected-tags-scroll":"kne-super-select_b-3Xk","tag":"kne-super-select_JkYqS","tag-inner":"kne-super-select_VZlBL","single-checked":"kne-super-select_Eiz-u","select-search":"kne-super-select_temy6","tags-search":"kne-super-select_7phL2","descriptions":"kne-super-select_ttNK9","footer":"kne-super-select_lISfA"};
|
|
1199
1198
|
|
|
1199
|
+
const defaultDataFormat = data => ({
|
|
1200
|
+
list: data?.pageData,
|
|
1201
|
+
total: data?.totalCount,
|
|
1202
|
+
data
|
|
1203
|
+
});
|
|
1204
|
+
const FetchTableContent = ({
|
|
1205
|
+
data,
|
|
1206
|
+
reload,
|
|
1207
|
+
refresh,
|
|
1208
|
+
requestParams,
|
|
1209
|
+
fetchProps,
|
|
1210
|
+
dataFormat = defaultDataFormat,
|
|
1211
|
+
pagination,
|
|
1212
|
+
columns,
|
|
1213
|
+
columnRenderProps,
|
|
1214
|
+
...tableProps
|
|
1215
|
+
}) => {
|
|
1216
|
+
const paginationMerged = Object.assign({
|
|
1217
|
+
open: false,
|
|
1218
|
+
paramsType: 'data',
|
|
1219
|
+
requestType: 'reload',
|
|
1220
|
+
currentName: 'currentPage',
|
|
1221
|
+
pageSizeName: 'perPage',
|
|
1222
|
+
pageSize: 20,
|
|
1223
|
+
showSizeChanger: false,
|
|
1224
|
+
showQuickJumper: false,
|
|
1225
|
+
hideOnSinglePage: true
|
|
1226
|
+
}, pagination);
|
|
1227
|
+
const formatData = dataFormat(data);
|
|
1228
|
+
const tableContext = Object.assign({}, columnRenderProps, {
|
|
1229
|
+
data,
|
|
1230
|
+
requestParams,
|
|
1231
|
+
fetchProps
|
|
1232
|
+
});
|
|
1233
|
+
const showPagination = paginationMerged.open && formatData.total > 0;
|
|
1234
|
+
const currentPage = get__default["default"](requestParams, [paginationMerged.paramsType, paginationMerged.currentName], 1);
|
|
1235
|
+
const currentPageSize = Number(get__default["default"](requestParams, [paginationMerged.paramsType, paginationMerged.pageSizeName], paginationMerged.pageSize)) || paginationMerged.pageSize || 20;
|
|
1236
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(tableView.Table, _extends({}, tableProps, {
|
|
1237
|
+
dataSource: formatData.list || [],
|
|
1238
|
+
pagination: false,
|
|
1239
|
+
columns: columns,
|
|
1240
|
+
context: tableContext,
|
|
1241
|
+
columnRenderProps: tableContext
|
|
1242
|
+
})), showPagination ? /*#__PURE__*/React.createElement(antd.Pagination, {
|
|
1243
|
+
total: formatData.total,
|
|
1244
|
+
current: currentPage,
|
|
1245
|
+
pageSize: currentPageSize,
|
|
1246
|
+
showSizeChanger: paginationMerged.showSizeChanger,
|
|
1247
|
+
showQuickJumper: paginationMerged.showQuickJumper,
|
|
1248
|
+
hideOnSinglePage: paginationMerged.hideOnSinglePage,
|
|
1249
|
+
onChange: (page, size) => {
|
|
1250
|
+
(paginationMerged.requestType === 'refresh' ? refresh : reload)({
|
|
1251
|
+
[paginationMerged.paramsType]: Object.assign({}, get__default["default"](requestParams, paginationMerged.paramsType), {
|
|
1252
|
+
[paginationMerged.currentName]: page,
|
|
1253
|
+
[paginationMerged.pageSizeName]: size
|
|
1254
|
+
})
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
}) : null);
|
|
1258
|
+
};
|
|
1259
|
+
const FetchTable = Fetch.withFetch(FetchTableContent);
|
|
1260
|
+
|
|
1200
1261
|
const isEmptyParentKey = value => value == null || value === '';
|
|
1201
1262
|
const flattenSelectList = (list, _ref) => {
|
|
1202
1263
|
let {
|
|
@@ -1205,16 +1266,16 @@ const flattenSelectList = (list, _ref) => {
|
|
|
1205
1266
|
parentKey,
|
|
1206
1267
|
childrenKey
|
|
1207
1268
|
} = _ref;
|
|
1208
|
-
if (!list || !
|
|
1269
|
+
if (!list || !tableView.isTreeDataType(dataType)) {
|
|
1209
1270
|
return list || [];
|
|
1210
1271
|
}
|
|
1211
|
-
const tree =
|
|
1272
|
+
const tree = tableView.normalizeTreeData(list, {
|
|
1212
1273
|
dataType,
|
|
1213
1274
|
rowKey,
|
|
1214
1275
|
parentKey,
|
|
1215
1276
|
childrenKey
|
|
1216
1277
|
});
|
|
1217
|
-
return
|
|
1278
|
+
return tableView.flattenAllTree(tree, {
|
|
1218
1279
|
rowKey,
|
|
1219
1280
|
childrenKey
|
|
1220
1281
|
}).map(row => row.item);
|
|
@@ -1279,13 +1340,13 @@ const getListFromPageData = data => {
|
|
|
1279
1340
|
const TABLE_LIST_MAX_HEIGHT_POPUP = 300;
|
|
1280
1341
|
const TABLE_LIST_MAX_HEIGHT_EMBED = 400;
|
|
1281
1342
|
const TABLE_HEADER_HEIGHT = 48;
|
|
1282
|
-
const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
|
|
1343
|
+
const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React$1.forwardRef((p, ref) => {
|
|
1283
1344
|
const {
|
|
1284
1345
|
formatMessage
|
|
1285
1346
|
} = reactIntl.useIntl();
|
|
1286
|
-
const [tagSearchText, setTagSearchText] = React.useState('');
|
|
1287
|
-
const tablePageRef = React.useRef();
|
|
1288
|
-
const listScrollRef = React.useRef();
|
|
1347
|
+
const [tagSearchText, setTagSearchText] = React$1.useState('');
|
|
1348
|
+
const tablePageRef = React$1.useRef();
|
|
1349
|
+
const listScrollRef = React$1.useRef();
|
|
1289
1350
|
const props = Object.assign({}, {
|
|
1290
1351
|
overlayWidth: '600px',
|
|
1291
1352
|
dataType: 'list',
|
|
@@ -1337,7 +1398,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1337
1398
|
return item[labelKey].indexOf(tagSearchText) > -1;
|
|
1338
1399
|
}
|
|
1339
1400
|
}, p);
|
|
1340
|
-
const bodyRef = React.useRef(null);
|
|
1401
|
+
const bodyRef = React$1.useRef(null);
|
|
1341
1402
|
return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
|
|
1342
1403
|
ref: ref
|
|
1343
1404
|
}), targetProps => {
|
|
@@ -1424,7 +1485,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1424
1485
|
};
|
|
1425
1486
|
}
|
|
1426
1487
|
} : merge__default["default"]({}, api, searchRequestProps);
|
|
1427
|
-
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(
|
|
1488
|
+
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(tableView.hasColumnWidth);
|
|
1428
1489
|
const tableSelection = {
|
|
1429
1490
|
allowSelectedAll,
|
|
1430
1491
|
isSelectedAll,
|
|
@@ -1537,7 +1598,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1537
1598
|
'is-popup': isPopup,
|
|
1538
1599
|
[style$2['is-fit-columns']]: !allColumnsHaveWidth
|
|
1539
1600
|
})
|
|
1540
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
1601
|
+
}, /*#__PURE__*/React__default["default"].createElement(FetchTable, _extends({}, tablePageFetchConfig, {
|
|
1541
1602
|
ref: tablePageRef
|
|
1542
1603
|
}, dataFormat ? {
|
|
1543
1604
|
dataFormat
|
|
@@ -1648,13 +1709,13 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1648
1709
|
ids: data.map(item => item.id)
|
|
1649
1710
|
};
|
|
1650
1711
|
});
|
|
1651
|
-
const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
1712
|
+
const SelectTree = React$1.forwardRef((_ref2, ref) => {
|
|
1652
1713
|
let {
|
|
1653
1714
|
children,
|
|
1654
1715
|
...p
|
|
1655
1716
|
} = _ref2;
|
|
1656
|
-
const fetchListRef = React.useRef(null);
|
|
1657
|
-
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1717
|
+
const fetchListRef = React$1.useRef(null);
|
|
1718
|
+
const [expandedKeys, setExpandedKeys] = React$1.useState([]);
|
|
1658
1719
|
const props = Object.assign({}, {
|
|
1659
1720
|
parentKey: 'parentId',
|
|
1660
1721
|
childrenKey: 'children',
|
|
@@ -2129,13 +2190,13 @@ const CascaderInner = _ref => {
|
|
|
2129
2190
|
const {
|
|
2130
2191
|
message
|
|
2131
2192
|
} = antd.App.useApp();
|
|
2132
|
-
const [searchText, setSearchText] = React.useState('');
|
|
2133
|
-
const [loading, setLoading] = React.useState(false);
|
|
2193
|
+
const [searchText, setSearchText] = React$1.useState('');
|
|
2194
|
+
const [loading, setLoading] = React$1.useState(false);
|
|
2134
2195
|
// 移动端弹窗内不用 SimpleBar,改原生滚动
|
|
2135
2196
|
const ScrollBox = isMobile ? 'div' : SimpleBar__default["default"];
|
|
2136
2197
|
|
|
2137
2198
|
// 构建 mapping
|
|
2138
|
-
const mapping = React.useMemo(() => {
|
|
2199
|
+
const mapping = React$1.useMemo(() => {
|
|
2139
2200
|
const map = new Map();
|
|
2140
2201
|
const processData = function (items, parentId) {
|
|
2141
2202
|
if (parentId === void 0) {
|
|
@@ -2165,12 +2226,12 @@ const CascaderInner = _ref => {
|
|
|
2165
2226
|
}, [options, valueKey, labelKey]);
|
|
2166
2227
|
|
|
2167
2228
|
// 创建树工具
|
|
2168
|
-
const treeUtils = React.useMemo(() => {
|
|
2229
|
+
const treeUtils = React$1.useMemo(() => {
|
|
2169
2230
|
return createTreeUtils(mapping);
|
|
2170
2231
|
}, [mapping]);
|
|
2171
2232
|
|
|
2172
2233
|
// 当前选中的列
|
|
2173
|
-
const [selectedIds, setSelectedIds] = React.useState(() => {
|
|
2234
|
+
const [selectedIds, setSelectedIds] = React$1.useState(() => {
|
|
2174
2235
|
const initValue = value.find(item => {
|
|
2175
2236
|
const id = typeof item === 'object' ? item[valueKey] : item;
|
|
2176
2237
|
return !!mapping.get(id);
|
|
@@ -2189,8 +2250,8 @@ const CascaderInner = _ref => {
|
|
|
2189
2250
|
});
|
|
2190
2251
|
|
|
2191
2252
|
// 当 Modal 打开时,根据 value 重新初始化 selectedIds
|
|
2192
|
-
const prevOpenRef = React.useRef(open);
|
|
2193
|
-
React.useEffect(() => {
|
|
2253
|
+
const prevOpenRef = React$1.useRef(open);
|
|
2254
|
+
React$1.useEffect(() => {
|
|
2194
2255
|
// 只在非 popup 模式下且 Modal 从关闭变为打开时处理
|
|
2195
2256
|
if (!isPopup && open && !prevOpenRef.current) {
|
|
2196
2257
|
const initValue = value.find(item => {
|
|
@@ -2212,14 +2273,14 @@ const CascaderInner = _ref => {
|
|
|
2212
2273
|
}, [open, value, mapping, treeUtils, valueKey, isPopup]);
|
|
2213
2274
|
|
|
2214
2275
|
// 懒加载支持
|
|
2215
|
-
const loadMorePropsRef = React.useRef({});
|
|
2276
|
+
const loadMorePropsRef = React$1.useRef({});
|
|
2216
2277
|
loadMorePropsRef.current = {
|
|
2217
2278
|
openLoadData,
|
|
2218
2279
|
onLoadMore,
|
|
2219
2280
|
parentIdKey,
|
|
2220
2281
|
treeUtils
|
|
2221
2282
|
};
|
|
2222
|
-
React.useEffect(() => {
|
|
2283
|
+
React$1.useEffect(() => {
|
|
2223
2284
|
if (!open || !openLoadData || !onLoadMore) {
|
|
2224
2285
|
return;
|
|
2225
2286
|
}
|
|
@@ -2243,7 +2304,7 @@ const CascaderInner = _ref => {
|
|
|
2243
2304
|
}, [open, selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
|
|
2244
2305
|
|
|
2245
2306
|
// 检查是否为非叶子节点
|
|
2246
|
-
const isNotLastNode = React.useCallback(id => {
|
|
2307
|
+
const isNotLastNode = React$1.useCallback(id => {
|
|
2247
2308
|
const node = mapping.get(id);
|
|
2248
2309
|
if (!node) return false;
|
|
2249
2310
|
if (openLoadData && !node.hasOwnProperty('children')) {
|
|
@@ -2253,7 +2314,7 @@ const CascaderInner = _ref => {
|
|
|
2253
2314
|
}, [mapping, openLoadData]);
|
|
2254
2315
|
|
|
2255
2316
|
// 选择处理
|
|
2256
|
-
const onCheckedChange = React.useCallback((checked, id) => {
|
|
2317
|
+
const onCheckedChange = React$1.useCallback((checked, id) => {
|
|
2257
2318
|
const newValue = (() => {
|
|
2258
2319
|
if (onlyAllowLastLevel && checked) {
|
|
2259
2320
|
const currentIds = value.map(item => typeof item === 'object' ? item[valueKey] : item);
|
|
@@ -2292,7 +2353,7 @@ const CascaderInner = _ref => {
|
|
|
2292
2353
|
}, [value, maxLength, single, onlyAllowLastLevel, treeUtils, mapping, message, valueKey, labelKey, isPopup, onOpenChange, isNotLastNode]);
|
|
2293
2354
|
|
|
2294
2355
|
// 搜索结果
|
|
2295
|
-
const searchResults = React.useMemo(() => {
|
|
2356
|
+
const searchResults = React$1.useMemo(() => {
|
|
2296
2357
|
if (!searchText || !onSearch) return null;
|
|
2297
2358
|
const keyword = searchText.toLowerCase();
|
|
2298
2359
|
return Array.from(mapping.values()).filter(item => {
|
|
@@ -2543,17 +2604,17 @@ const SelectCascader = _ref4 => {
|
|
|
2543
2604
|
} = _ref4;
|
|
2544
2605
|
// 内部始终使用数组格式处理
|
|
2545
2606
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2546
|
-
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2607
|
+
const [innerValue, setInnerValue] = React$1.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2547
2608
|
|
|
2548
2609
|
// currentValue 用于内部处理,始终是数组
|
|
2549
|
-
const currentValue = React.useMemo(() => {
|
|
2610
|
+
const currentValue = React$1.useMemo(() => {
|
|
2550
2611
|
if (value !== undefined) {
|
|
2551
2612
|
// 外部传入的 value 可能是对象(single)或数组(多选)
|
|
2552
2613
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
2553
2614
|
}
|
|
2554
2615
|
return innerValue;
|
|
2555
2616
|
}, [value, innerValue]);
|
|
2556
|
-
const setValue = React.useCallback(newValue => {
|
|
2617
|
+
const setValue = React$1.useCallback(newValue => {
|
|
2557
2618
|
// SelectInput 在 single 模式下会传单个对象或 null/undefined,需要转换为数组
|
|
2558
2619
|
const normalizedValue = (() => {
|
|
2559
2620
|
if (single) {
|
|
@@ -2581,7 +2642,7 @@ const SelectCascader = _ref4 => {
|
|
|
2581
2642
|
}, [value, onChange, single]);
|
|
2582
2643
|
|
|
2583
2644
|
// 传递给 SelectInput 的值:根据 single 参数决定格式
|
|
2584
|
-
const selectInputValue = React.useMemo(() => {
|
|
2645
|
+
const selectInputValue = React$1.useMemo(() => {
|
|
2585
2646
|
if (single) {
|
|
2586
2647
|
// single 模式:传单个对象或 undefined
|
|
2587
2648
|
return currentValue.length > 0 ? currentValue[0] : undefined;
|
|
@@ -2591,7 +2652,7 @@ const SelectCascader = _ref4 => {
|
|
|
2591
2652
|
}, [currentValue, single]);
|
|
2592
2653
|
|
|
2593
2654
|
// 计算 label 显示
|
|
2594
|
-
React.useMemo(() => {
|
|
2655
|
+
React$1.useMemo(() => {
|
|
2595
2656
|
// currentValue 已经是数组格式了
|
|
2596
2657
|
return currentValue.map(item => {
|
|
2597
2658
|
// 如果已经是对象,确保有标准化的字段
|
|
@@ -2700,7 +2761,7 @@ const SelectCascader = _ref4 => {
|
|
|
2700
2761
|
|
|
2701
2762
|
Object.defineProperty(exports, 'mergeTreeChildren', {
|
|
2702
2763
|
enumerable: true,
|
|
2703
|
-
get: function () { return
|
|
2764
|
+
get: function () { return tableView.mergeTreeChildren; }
|
|
2704
2765
|
});
|
|
2705
2766
|
exports.SelectCascader = SelectCascader;
|
|
2706
2767
|
exports.SelectInput = SelectInput;
|