@kne/super-select 0.1.47 → 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 +57 -2
- package/dist/index.js +129 -66
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +228 -162
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -737,6 +737,59 @@ const SearchableTableExample = ({ isPopup }) => {
|
|
|
737
737
|
);
|
|
738
738
|
};
|
|
739
739
|
|
|
740
|
+
const remoteSearchListFilter = { language: 'zh-CN' };
|
|
741
|
+
|
|
742
|
+
// 远程搜索:getSearchProps 必须写入 params(paramsType=params),不能写进 data
|
|
743
|
+
const RemoteSearchTableExample = ({ isPopup }) => {
|
|
744
|
+
const [value, setValue] = useState([]);
|
|
745
|
+
const [lastRequest, setLastRequest] = useState(null);
|
|
746
|
+
const api = React.useMemo(
|
|
747
|
+
() => ({
|
|
748
|
+
params: { filter: remoteSearchListFilter },
|
|
749
|
+
loader: request => {
|
|
750
|
+
const snapshot = { params: request?.params || {}, data: request?.data || {} };
|
|
751
|
+
setTimeout(() => setLastRequest(snapshot), 0);
|
|
752
|
+
const keyword = (snapshot.params.filter?.keyword || '').toLowerCase();
|
|
753
|
+
const pageData = employeeOptions.filter(item => {
|
|
754
|
+
if (!keyword) {
|
|
755
|
+
return true;
|
|
756
|
+
}
|
|
757
|
+
return item.name.toLowerCase().includes(keyword) || item.email.toLowerCase().includes(keyword) || item.department.toLowerCase().includes(keyword);
|
|
758
|
+
});
|
|
759
|
+
return { pageData, totalCount: pageData.length };
|
|
760
|
+
}
|
|
761
|
+
}),
|
|
762
|
+
[]
|
|
763
|
+
);
|
|
764
|
+
|
|
765
|
+
return (
|
|
766
|
+
<Flex vertical gap={8}>
|
|
767
|
+
<span>远程搜索(paramsType=params):</span>
|
|
768
|
+
<div style={{ color: '#666', fontSize: 12, lineHeight: 1.6 }}>
|
|
769
|
+
模拟 GET 列表,loader 只读 params.filter.keyword。修好后搜「员工1」或「技术」列表会过滤,且下方 params.filter 含 keyword、data 为空对象;未修好时关键词进 data,列表不变。建议切到「弹窗」模式再搜。
|
|
770
|
+
</div>
|
|
771
|
+
<SelectTableList
|
|
772
|
+
api={api}
|
|
773
|
+
columns={employeeColumns}
|
|
774
|
+
valueKey="id"
|
|
775
|
+
labelKey="name"
|
|
776
|
+
value={value}
|
|
777
|
+
onChange={setValue}
|
|
778
|
+
isPopup={isPopup}
|
|
779
|
+
placeholder="搜索姓名、邮箱或部门"
|
|
780
|
+
getSearchProps={({ searchText }) => ({
|
|
781
|
+
filter: Object.assign({}, remoteSearchListFilter, searchText ? { keyword: searchText } : {})
|
|
782
|
+
})}
|
|
783
|
+
pagination={{ paramsType: 'params' }}
|
|
784
|
+
style={{ width: 600 }}
|
|
785
|
+
/>
|
|
786
|
+
{lastRequest ? (
|
|
787
|
+
<pre style={{ margin: 0, fontSize: 12, background: '#f5f5f5', padding: 8, borderRadius: 4, overflow: 'auto' }}>{JSON.stringify(lastRequest, null, 2)}</pre>
|
|
788
|
+
) : null}
|
|
789
|
+
</Flex>
|
|
790
|
+
);
|
|
791
|
+
};
|
|
792
|
+
|
|
740
793
|
// 全选功能
|
|
741
794
|
const SelectAllTableExample = ({ isPopup }) => {
|
|
742
795
|
const [value, setValue] = useState([]);
|
|
@@ -1267,6 +1320,8 @@ const BaseExample = () => {
|
|
|
1267
1320
|
<Divider />
|
|
1268
1321
|
<SearchableTableExample isPopup={isPopup} />
|
|
1269
1322
|
<Divider />
|
|
1323
|
+
<RemoteSearchTableExample isPopup={isPopup} />
|
|
1324
|
+
<Divider />
|
|
1270
1325
|
<SelectAllTableExample isPopup={isPopup} />
|
|
1271
1326
|
<Divider />
|
|
1272
1327
|
<WideTableExample isPopup={isPopup} />
|
|
@@ -2502,7 +2557,7 @@ render(<BaseExample />);
|
|
|
2502
2557
|
|
|
2503
2558
|
#### SelectTableList
|
|
2504
2559
|
|
|
2505
|
-
表格形式的选择组件,适用于需要展示多列数据的选择场景。基于 `@kne/table-
|
|
2560
|
+
表格形式的选择组件,适用于需要展示多列数据的选择场景。基于 `@kne/table-view` 的 `Table` 与 `@kne/react-fetch`,支持普通列表与树形(`tree` / `treeList`)选择;桌面端滚动时表头固定,横向滚动条吸附在可视区域底部。
|
|
2506
2561
|
|
|
2507
2562
|
| 属性名 | 说明 | 类型 | 默认值 |
|
|
2508
2563
|
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | --------------- |
|
|
@@ -2532,7 +2587,7 @@ render(<BaseExample />);
|
|
|
2532
2587
|
|
|
2533
2588
|
树形说明:
|
|
2534
2589
|
|
|
2535
|
-
- `tree` / `treeList` 能力透传自 `@kne/table-
|
|
2590
|
+
- `tree` / `treeList` 能力透传自 `@kne/table-view`(展开收起、缩进、半选、移动端面包屑等)
|
|
2536
2591
|
- 搜索(`getSearchCallback`)在 `tree` 下递归过滤并保留祖先;在 `treeList` 下匹配节点时自动带上祖先路径
|
|
2537
2592
|
- 懒加载示例:`onLoadChildren` 内用包导出的 `mergeTreeChildren` 更新 `options`
|
|
2538
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 => {
|
|
@@ -1395,6 +1456,10 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1395
1456
|
onOpenChange(false);
|
|
1396
1457
|
}
|
|
1397
1458
|
}) : footer);
|
|
1459
|
+
const paginationParamsType = paginationProp?.paramsType || 'data';
|
|
1460
|
+
const searchRequestProps = typeof getSearchProps === 'function' && isEmpty.isNotEmpty(searchProps) ? {
|
|
1461
|
+
[paginationParamsType]: getSearchProps(searchProps) || {}
|
|
1462
|
+
} : {};
|
|
1398
1463
|
const tablePageFetchConfig = options ? {
|
|
1399
1464
|
data: {
|
|
1400
1465
|
options,
|
|
@@ -1419,10 +1484,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1419
1484
|
totalCount: pageData.length
|
|
1420
1485
|
};
|
|
1421
1486
|
}
|
|
1422
|
-
} : merge__default["default"]({}, api,
|
|
1423
|
-
|
|
1424
|
-
} : {});
|
|
1425
|
-
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(TablePage.hasColumnWidth);
|
|
1487
|
+
} : merge__default["default"]({}, api, searchRequestProps);
|
|
1488
|
+
const allColumnsHaveWidth = Array.isArray(columns) && columns.length > 0 && columns.every(tableView.hasColumnWidth);
|
|
1426
1489
|
const tableSelection = {
|
|
1427
1490
|
allowSelectedAll,
|
|
1428
1491
|
isSelectedAll,
|
|
@@ -1535,7 +1598,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1535
1598
|
'is-popup': isPopup,
|
|
1536
1599
|
[style$2['is-fit-columns']]: !allColumnsHaveWidth
|
|
1537
1600
|
})
|
|
1538
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
1601
|
+
}, /*#__PURE__*/React__default["default"].createElement(FetchTable, _extends({}, tablePageFetchConfig, {
|
|
1539
1602
|
ref: tablePageRef
|
|
1540
1603
|
}, dataFormat ? {
|
|
1541
1604
|
dataFormat
|
|
@@ -1646,13 +1709,13 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1646
1709
|
ids: data.map(item => item.id)
|
|
1647
1710
|
};
|
|
1648
1711
|
});
|
|
1649
|
-
const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
1712
|
+
const SelectTree = React$1.forwardRef((_ref2, ref) => {
|
|
1650
1713
|
let {
|
|
1651
1714
|
children,
|
|
1652
1715
|
...p
|
|
1653
1716
|
} = _ref2;
|
|
1654
|
-
const fetchListRef = React.useRef(null);
|
|
1655
|
-
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1717
|
+
const fetchListRef = React$1.useRef(null);
|
|
1718
|
+
const [expandedKeys, setExpandedKeys] = React$1.useState([]);
|
|
1656
1719
|
const props = Object.assign({}, {
|
|
1657
1720
|
parentKey: 'parentId',
|
|
1658
1721
|
childrenKey: 'children',
|
|
@@ -2127,13 +2190,13 @@ const CascaderInner = _ref => {
|
|
|
2127
2190
|
const {
|
|
2128
2191
|
message
|
|
2129
2192
|
} = antd.App.useApp();
|
|
2130
|
-
const [searchText, setSearchText] = React.useState('');
|
|
2131
|
-
const [loading, setLoading] = React.useState(false);
|
|
2193
|
+
const [searchText, setSearchText] = React$1.useState('');
|
|
2194
|
+
const [loading, setLoading] = React$1.useState(false);
|
|
2132
2195
|
// 移动端弹窗内不用 SimpleBar,改原生滚动
|
|
2133
2196
|
const ScrollBox = isMobile ? 'div' : SimpleBar__default["default"];
|
|
2134
2197
|
|
|
2135
2198
|
// 构建 mapping
|
|
2136
|
-
const mapping = React.useMemo(() => {
|
|
2199
|
+
const mapping = React$1.useMemo(() => {
|
|
2137
2200
|
const map = new Map();
|
|
2138
2201
|
const processData = function (items, parentId) {
|
|
2139
2202
|
if (parentId === void 0) {
|
|
@@ -2163,12 +2226,12 @@ const CascaderInner = _ref => {
|
|
|
2163
2226
|
}, [options, valueKey, labelKey]);
|
|
2164
2227
|
|
|
2165
2228
|
// 创建树工具
|
|
2166
|
-
const treeUtils = React.useMemo(() => {
|
|
2229
|
+
const treeUtils = React$1.useMemo(() => {
|
|
2167
2230
|
return createTreeUtils(mapping);
|
|
2168
2231
|
}, [mapping]);
|
|
2169
2232
|
|
|
2170
2233
|
// 当前选中的列
|
|
2171
|
-
const [selectedIds, setSelectedIds] = React.useState(() => {
|
|
2234
|
+
const [selectedIds, setSelectedIds] = React$1.useState(() => {
|
|
2172
2235
|
const initValue = value.find(item => {
|
|
2173
2236
|
const id = typeof item === 'object' ? item[valueKey] : item;
|
|
2174
2237
|
return !!mapping.get(id);
|
|
@@ -2187,8 +2250,8 @@ const CascaderInner = _ref => {
|
|
|
2187
2250
|
});
|
|
2188
2251
|
|
|
2189
2252
|
// 当 Modal 打开时,根据 value 重新初始化 selectedIds
|
|
2190
|
-
const prevOpenRef = React.useRef(open);
|
|
2191
|
-
React.useEffect(() => {
|
|
2253
|
+
const prevOpenRef = React$1.useRef(open);
|
|
2254
|
+
React$1.useEffect(() => {
|
|
2192
2255
|
// 只在非 popup 模式下且 Modal 从关闭变为打开时处理
|
|
2193
2256
|
if (!isPopup && open && !prevOpenRef.current) {
|
|
2194
2257
|
const initValue = value.find(item => {
|
|
@@ -2210,14 +2273,14 @@ const CascaderInner = _ref => {
|
|
|
2210
2273
|
}, [open, value, mapping, treeUtils, valueKey, isPopup]);
|
|
2211
2274
|
|
|
2212
2275
|
// 懒加载支持
|
|
2213
|
-
const loadMorePropsRef = React.useRef({});
|
|
2276
|
+
const loadMorePropsRef = React$1.useRef({});
|
|
2214
2277
|
loadMorePropsRef.current = {
|
|
2215
2278
|
openLoadData,
|
|
2216
2279
|
onLoadMore,
|
|
2217
2280
|
parentIdKey,
|
|
2218
2281
|
treeUtils
|
|
2219
2282
|
};
|
|
2220
|
-
React.useEffect(() => {
|
|
2283
|
+
React$1.useEffect(() => {
|
|
2221
2284
|
if (!open || !openLoadData || !onLoadMore) {
|
|
2222
2285
|
return;
|
|
2223
2286
|
}
|
|
@@ -2241,7 +2304,7 @@ const CascaderInner = _ref => {
|
|
|
2241
2304
|
}, [open, selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
|
|
2242
2305
|
|
|
2243
2306
|
// 检查是否为非叶子节点
|
|
2244
|
-
const isNotLastNode = React.useCallback(id => {
|
|
2307
|
+
const isNotLastNode = React$1.useCallback(id => {
|
|
2245
2308
|
const node = mapping.get(id);
|
|
2246
2309
|
if (!node) return false;
|
|
2247
2310
|
if (openLoadData && !node.hasOwnProperty('children')) {
|
|
@@ -2251,7 +2314,7 @@ const CascaderInner = _ref => {
|
|
|
2251
2314
|
}, [mapping, openLoadData]);
|
|
2252
2315
|
|
|
2253
2316
|
// 选择处理
|
|
2254
|
-
const onCheckedChange = React.useCallback((checked, id) => {
|
|
2317
|
+
const onCheckedChange = React$1.useCallback((checked, id) => {
|
|
2255
2318
|
const newValue = (() => {
|
|
2256
2319
|
if (onlyAllowLastLevel && checked) {
|
|
2257
2320
|
const currentIds = value.map(item => typeof item === 'object' ? item[valueKey] : item);
|
|
@@ -2290,7 +2353,7 @@ const CascaderInner = _ref => {
|
|
|
2290
2353
|
}, [value, maxLength, single, onlyAllowLastLevel, treeUtils, mapping, message, valueKey, labelKey, isPopup, onOpenChange, isNotLastNode]);
|
|
2291
2354
|
|
|
2292
2355
|
// 搜索结果
|
|
2293
|
-
const searchResults = React.useMemo(() => {
|
|
2356
|
+
const searchResults = React$1.useMemo(() => {
|
|
2294
2357
|
if (!searchText || !onSearch) return null;
|
|
2295
2358
|
const keyword = searchText.toLowerCase();
|
|
2296
2359
|
return Array.from(mapping.values()).filter(item => {
|
|
@@ -2541,17 +2604,17 @@ const SelectCascader = _ref4 => {
|
|
|
2541
2604
|
} = _ref4;
|
|
2542
2605
|
// 内部始终使用数组格式处理
|
|
2543
2606
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2544
|
-
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2607
|
+
const [innerValue, setInnerValue] = React$1.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|
|
2545
2608
|
|
|
2546
2609
|
// currentValue 用于内部处理,始终是数组
|
|
2547
|
-
const currentValue = React.useMemo(() => {
|
|
2610
|
+
const currentValue = React$1.useMemo(() => {
|
|
2548
2611
|
if (value !== undefined) {
|
|
2549
2612
|
// 外部传入的 value 可能是对象(single)或数组(多选)
|
|
2550
2613
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
2551
2614
|
}
|
|
2552
2615
|
return innerValue;
|
|
2553
2616
|
}, [value, innerValue]);
|
|
2554
|
-
const setValue = React.useCallback(newValue => {
|
|
2617
|
+
const setValue = React$1.useCallback(newValue => {
|
|
2555
2618
|
// SelectInput 在 single 模式下会传单个对象或 null/undefined,需要转换为数组
|
|
2556
2619
|
const normalizedValue = (() => {
|
|
2557
2620
|
if (single) {
|
|
@@ -2579,7 +2642,7 @@ const SelectCascader = _ref4 => {
|
|
|
2579
2642
|
}, [value, onChange, single]);
|
|
2580
2643
|
|
|
2581
2644
|
// 传递给 SelectInput 的值:根据 single 参数决定格式
|
|
2582
|
-
const selectInputValue = React.useMemo(() => {
|
|
2645
|
+
const selectInputValue = React$1.useMemo(() => {
|
|
2583
2646
|
if (single) {
|
|
2584
2647
|
// single 模式:传单个对象或 undefined
|
|
2585
2648
|
return currentValue.length > 0 ? currentValue[0] : undefined;
|
|
@@ -2589,7 +2652,7 @@ const SelectCascader = _ref4 => {
|
|
|
2589
2652
|
}, [currentValue, single]);
|
|
2590
2653
|
|
|
2591
2654
|
// 计算 label 显示
|
|
2592
|
-
React.useMemo(() => {
|
|
2655
|
+
React$1.useMemo(() => {
|
|
2593
2656
|
// currentValue 已经是数组格式了
|
|
2594
2657
|
return currentValue.map(item => {
|
|
2595
2658
|
// 如果已经是对象,确保有标准化的字段
|
|
@@ -2698,7 +2761,7 @@ const SelectCascader = _ref4 => {
|
|
|
2698
2761
|
|
|
2699
2762
|
Object.defineProperty(exports, 'mergeTreeChildren', {
|
|
2700
2763
|
enumerable: true,
|
|
2701
|
-
get: function () { return
|
|
2764
|
+
get: function () { return tableView.mergeTreeChildren; }
|
|
2702
2765
|
});
|
|
2703
2766
|
exports.SelectCascader = SelectCascader;
|
|
2704
2767
|
exports.SelectInput = SelectInput;
|