@kne/super-select 0.1.51 → 0.1.54
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 +32 -0
- package/dist/index.css +121 -25
- package/dist/index.css.map +1 -1
- package/dist/index.js +183 -191
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +49 -18
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -147,7 +147,7 @@ const TagOverflowInner = ({
|
|
|
147
147
|
"data-tag-measure": true
|
|
148
148
|
}, /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
149
149
|
closable: true,
|
|
150
|
-
|
|
150
|
+
variant: "filled",
|
|
151
151
|
className: style$6['tag-item'],
|
|
152
152
|
style: {
|
|
153
153
|
'--max-tag-width': `${maxTagWidth}px`,
|
|
@@ -170,7 +170,7 @@ const TagOverflowInner = ({
|
|
|
170
170
|
}, displayTags.map(item => /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
|
|
171
171
|
key: item[valueKey],
|
|
172
172
|
closable: true,
|
|
173
|
-
|
|
173
|
+
variant: "filled",
|
|
174
174
|
className: style$6['tag-item'],
|
|
175
175
|
style: {
|
|
176
176
|
'--max-tag-width': `${maxTagWidth}px`,
|
|
@@ -240,11 +240,10 @@ const lockParentScroll = getScrollElements => {
|
|
|
240
240
|
return () => {
|
|
241
241
|
parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
|
|
242
242
|
if (parentScrollLockCount === 0) {
|
|
243
|
-
parentScrollLocked.forEach(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} = _ref;
|
|
243
|
+
parentScrollLocked.forEach(({
|
|
244
|
+
el,
|
|
245
|
+
prev
|
|
246
|
+
}) => {
|
|
248
247
|
el.style.overflow = prev.overflow;
|
|
249
248
|
el.style.overscrollBehavior = prev.overscrollBehavior;
|
|
250
249
|
});
|
|
@@ -276,11 +275,10 @@ const pxToNumber = value => {
|
|
|
276
275
|
const DEFAULT_OVERLAY_MIN_WIDTH = 300;
|
|
277
276
|
|
|
278
277
|
// 与 Modal 模式一致:面板内用临时 value,确认后才写回
|
|
279
|
-
const ModalContent =
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
} = _ref2;
|
|
278
|
+
const ModalContent = ({
|
|
279
|
+
children: renderContent,
|
|
280
|
+
...others
|
|
281
|
+
}) => {
|
|
284
282
|
const {
|
|
285
283
|
open,
|
|
286
284
|
value: propsValue
|
|
@@ -310,14 +308,13 @@ const ModalContent = _ref2 => {
|
|
|
310
308
|
value: contextProps
|
|
311
309
|
}, renderContent(contextProps));
|
|
312
310
|
};
|
|
313
|
-
const MobileSheetMask =
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
} = _ref3;
|
|
311
|
+
const MobileSheetMask = ({
|
|
312
|
+
open,
|
|
313
|
+
mountNode,
|
|
314
|
+
fixedModeClass,
|
|
315
|
+
onClose,
|
|
316
|
+
zIndex = MOBILE_MASK_Z_INDEX
|
|
317
|
+
}) => {
|
|
321
318
|
const [renderMask, setRenderMask] = React.useState(false);
|
|
322
319
|
const [maskClosing, setMaskClosing] = React.useState(false);
|
|
323
320
|
React.useEffect(() => {
|
|
@@ -340,7 +337,7 @@ const MobileSheetMask = _ref3 => {
|
|
|
340
337
|
return null;
|
|
341
338
|
}
|
|
342
339
|
return reactDom.createPortal(/*#__PURE__*/React__default["default"].createElement("div", {
|
|
343
|
-
className: classnames__default["default"](style$6['mobile-sheet-mask'], maskClosing && style$6['mobile-sheet-mask-leave'], fixedModeClass),
|
|
340
|
+
className: classnames__default["default"](style$6['mobile-sheet-mask'], 'select-mobile-sheet-mask', maskClosing && style$6['mobile-sheet-mask-leave'], fixedModeClass),
|
|
344
341
|
style: {
|
|
345
342
|
zIndex
|
|
346
343
|
},
|
|
@@ -350,48 +347,46 @@ const MobileSheetMask = _ref3 => {
|
|
|
350
347
|
}
|
|
351
348
|
}), mountNode);
|
|
352
349
|
};
|
|
353
|
-
const MobileSheetHeader =
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
} = _ref4;
|
|
350
|
+
const MobileSheetHeader = ({
|
|
351
|
+
title,
|
|
352
|
+
cancelText,
|
|
353
|
+
confirmText,
|
|
354
|
+
onCancel,
|
|
355
|
+
onConfirm
|
|
356
|
+
}) => {
|
|
361
357
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
362
|
-
className: style$6['mobile-sheet-header']
|
|
358
|
+
className: classnames__default["default"](style$6['mobile-sheet-header'], 'select-mobile-sheet-header')
|
|
363
359
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
364
360
|
type: "button",
|
|
365
|
-
className: style$6['mobile-sheet-action'],
|
|
361
|
+
className: classnames__default["default"](style$6['mobile-sheet-action'], 'select-mobile-sheet-cancel'),
|
|
366
362
|
onClick: onCancel
|
|
367
363
|
}, cancelText), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
368
|
-
className: style$6['mobile-sheet-title'],
|
|
364
|
+
className: classnames__default["default"](style$6['mobile-sheet-title'], 'select-mobile-sheet-title'),
|
|
369
365
|
title: title
|
|
370
366
|
}, title), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
371
367
|
type: "button",
|
|
372
|
-
className: classnames__default["default"](style$6['mobile-sheet-action'], style$6['mobile-sheet-confirm']),
|
|
368
|
+
className: classnames__default["default"](style$6['mobile-sheet-action'], style$6['mobile-sheet-confirm'], 'select-mobile-sheet-confirm'),
|
|
373
369
|
onClick: onConfirm
|
|
374
370
|
}, confirmText));
|
|
375
371
|
};
|
|
376
|
-
const MobileSheetPanel =
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
} = _ref5;
|
|
372
|
+
const MobileSheetPanel = ({
|
|
373
|
+
open,
|
|
374
|
+
mountNode,
|
|
375
|
+
fixedModeClass,
|
|
376
|
+
overlayClassName,
|
|
377
|
+
title,
|
|
378
|
+
cancelText,
|
|
379
|
+
confirmText,
|
|
380
|
+
onCancel,
|
|
381
|
+
onConfirm,
|
|
382
|
+
children,
|
|
383
|
+
zIndex = MOBILE_POPUP_Z_INDEX
|
|
384
|
+
}) => {
|
|
390
385
|
if (!open || !mountNode) {
|
|
391
386
|
return null;
|
|
392
387
|
}
|
|
393
388
|
return reactDom.createPortal(/*#__PURE__*/React__default["default"].createElement("div", {
|
|
394
|
-
className: classnames__default["default"](style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], fixedModeClass, overlayClassName),
|
|
389
|
+
className: classnames__default["default"](style$6['mobile-sheet-popup'], style$6['mobile-sheet-portal'], 'select-mobile-sheet', fixedModeClass, overlayClassName),
|
|
395
390
|
style: {
|
|
396
391
|
zIndex,
|
|
397
392
|
maxHeight: MOBILE_SHEET_MAX_HEIGHT,
|
|
@@ -518,7 +513,6 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
518
513
|
className: overlayClassName,
|
|
519
514
|
width: 1000,
|
|
520
515
|
open: open,
|
|
521
|
-
destroyOnClose: true,
|
|
522
516
|
destroyOnHidden: true,
|
|
523
517
|
title: placeholder,
|
|
524
518
|
onCancel: () => {
|
|
@@ -746,10 +740,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
746
740
|
getPopupContainer: resolveGetPopupContainer,
|
|
747
741
|
formatMessage
|
|
748
742
|
};
|
|
749
|
-
const inputInnerRender =
|
|
750
|
-
if (props === void 0) {
|
|
751
|
-
props = {};
|
|
752
|
-
}
|
|
743
|
+
const inputInnerRender = (props = {}) => {
|
|
753
744
|
if (typeof contextProps.props.inputRender === 'function') {
|
|
754
745
|
return contextProps.props.inputRender(props, contextProps);
|
|
755
746
|
}
|
|
@@ -878,16 +869,18 @@ const SelectInput = reactIntl.createWithIntlProvider({
|
|
|
878
869
|
placement: placement,
|
|
879
870
|
arrow: false,
|
|
880
871
|
getPopupContainer: resolveGetPopupContainer,
|
|
881
|
-
|
|
882
|
-
|
|
872
|
+
classNames: {
|
|
873
|
+
root: classnames__default["default"](style$6['overlay'], overlayClassName)
|
|
874
|
+
},
|
|
875
|
+
styles: {
|
|
876
|
+
root: mergedOverlayStyle
|
|
877
|
+
},
|
|
883
878
|
align: align,
|
|
884
879
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
885
880
|
transitionName: transitionName,
|
|
886
881
|
trigger: "click",
|
|
887
|
-
destroyPopupOnHide: true,
|
|
888
882
|
destroyOnHidden: true,
|
|
889
|
-
popupRender: () => overlayContent
|
|
890
|
-
dropdownRender: () => overlayContent
|
|
883
|
+
popupRender: () => overlayContent
|
|
891
884
|
}, /*#__PURE__*/React__default["default"].createElement("span", null, inputInnerRender())) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, inputInnerRender({
|
|
892
885
|
onClick: () => {
|
|
893
886
|
setOpen(true);
|
|
@@ -939,10 +932,7 @@ const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-s
|
|
|
939
932
|
id: 'selectAll'
|
|
940
933
|
}))));
|
|
941
934
|
});
|
|
942
|
-
const computedIsSelectAll =
|
|
943
|
-
if (valueKey === void 0) {
|
|
944
|
-
valueKey = 'value';
|
|
945
|
-
}
|
|
935
|
+
const computedIsSelectAll = (value, selectedAllValue, valueKey = 'value') => {
|
|
946
936
|
return value?.length === 1 && get__default["default"](value, `[0][${valueKey}]`) === selectedAllValue[valueKey];
|
|
947
937
|
};
|
|
948
938
|
|
|
@@ -981,7 +971,7 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
981
971
|
className: style$4['tag'],
|
|
982
972
|
key: item[valueKey],
|
|
983
973
|
closable: true,
|
|
984
|
-
|
|
974
|
+
variant: "filled",
|
|
985
975
|
onClose: e => {
|
|
986
976
|
e.preventDefault();
|
|
987
977
|
onRemove(item);
|
|
@@ -994,18 +984,16 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
994
984
|
|
|
995
985
|
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"};
|
|
996
986
|
|
|
997
|
-
const SelectList = React.forwardRef((
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
} = _ref;
|
|
987
|
+
const SelectList = React.forwardRef(({
|
|
988
|
+
children,
|
|
989
|
+
...p
|
|
990
|
+
}, ref) => {
|
|
1002
991
|
const fetchListRef = React.useRef(null);
|
|
1003
992
|
const props = Object.assign({}, {
|
|
1004
|
-
renderItemContent:
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
} = _ref2;
|
|
993
|
+
renderItemContent: ({
|
|
994
|
+
item,
|
|
995
|
+
props
|
|
996
|
+
}) => {
|
|
1009
997
|
const {
|
|
1010
998
|
labelKey
|
|
1011
999
|
} = props;
|
|
@@ -1152,10 +1140,9 @@ const SelectList = React.forwardRef((_ref, ref) => {
|
|
|
1152
1140
|
options,
|
|
1153
1141
|
searchProps
|
|
1154
1142
|
},
|
|
1155
|
-
loader:
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
} = _ref3;
|
|
1143
|
+
loader: ({
|
|
1144
|
+
data
|
|
1145
|
+
}) => {
|
|
1159
1146
|
const {
|
|
1160
1147
|
options,
|
|
1161
1148
|
searchProps
|
|
@@ -1368,13 +1355,12 @@ const FetchTableContent = ({
|
|
|
1368
1355
|
const FetchTable = Fetch.withFetch(FetchTableContent);
|
|
1369
1356
|
|
|
1370
1357
|
const isEmptyParentKey = value => value == null || value === '';
|
|
1371
|
-
const flattenSelectList = (list,
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
} = _ref;
|
|
1358
|
+
const flattenSelectList = (list, {
|
|
1359
|
+
dataType,
|
|
1360
|
+
rowKey,
|
|
1361
|
+
parentKey,
|
|
1362
|
+
childrenKey
|
|
1363
|
+
}) => {
|
|
1378
1364
|
if (!list || !tableView.isTreeDataType(dataType)) {
|
|
1379
1365
|
return list || [];
|
|
1380
1366
|
}
|
|
@@ -1389,13 +1375,12 @@ const flattenSelectList = (list, _ref) => {
|
|
|
1389
1375
|
childrenKey
|
|
1390
1376
|
}).map(row => row.item);
|
|
1391
1377
|
};
|
|
1392
|
-
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps,
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
} = _ref2;
|
|
1378
|
+
const filterTreeOptions = (options, searchProps, getSearchCallback, targetProps, {
|
|
1379
|
+
dataType,
|
|
1380
|
+
valueKey,
|
|
1381
|
+
parentKey,
|
|
1382
|
+
childrenKey
|
|
1383
|
+
}) => {
|
|
1399
1384
|
if (typeof getSearchCallback !== 'function') {
|
|
1400
1385
|
return options;
|
|
1401
1386
|
}
|
|
@@ -1574,10 +1559,9 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1574
1559
|
options,
|
|
1575
1560
|
searchProps
|
|
1576
1561
|
},
|
|
1577
|
-
loader:
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
} = _ref3;
|
|
1562
|
+
loader: ({
|
|
1563
|
+
data
|
|
1564
|
+
}) => {
|
|
1581
1565
|
const {
|
|
1582
1566
|
options: nextOptions,
|
|
1583
1567
|
searchProps: nextSearchProps
|
|
@@ -1656,7 +1640,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1656
1640
|
className: style$2['tag'],
|
|
1657
1641
|
key: item[valueKey],
|
|
1658
1642
|
closable: true,
|
|
1659
|
-
|
|
1643
|
+
variant: "filled",
|
|
1660
1644
|
onClose: e => {
|
|
1661
1645
|
e.preventDefault();
|
|
1662
1646
|
onRemove(item);
|
|
@@ -1744,12 +1728,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1744
1728
|
isSelectedAll,
|
|
1745
1729
|
list: mobileProps.displayDataSource || mobileProps.dataSource,
|
|
1746
1730
|
dataSource: mobileProps.dataSource,
|
|
1747
|
-
renderBody:
|
|
1748
|
-
if (nextList === void 0) {
|
|
1749
|
-
nextList = mobileProps.displayDataSource || mobileProps.dataSource;
|
|
1750
|
-
}
|
|
1751
|
-
return mobileProps.renderBody(nextList, nextContext);
|
|
1752
|
-
}
|
|
1731
|
+
renderBody: (nextList = mobileProps.displayDataSource || mobileProps.dataSource, nextContext) => mobileProps.renderBody(nextList, nextContext)
|
|
1753
1732
|
}) : true
|
|
1754
1733
|
}, typeof onLoadChildren === 'function' ? {
|
|
1755
1734
|
onLoadChildren
|
|
@@ -1794,15 +1773,11 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
|
|
|
1794
1773
|
|
|
1795
1774
|
var style$1 = {"kne-responsive-boundary":"kne-super-select_YFHhC","kne-responsive-scroll":"kne-super-select_yjaz7","list":"kne-super-select_YTqxA","default-list":"kne-super-select_IZN7r","is-selected-all":"kne-super-select_GCIMn","default-list-item":"kne-super-select_AYi0i","is-selected":"kne-super-select_eovZv","single-checked":"kne-super-select_Tr-bO","is-disabled":"kne-super-select_T-hri","selected-all":"kne-super-select_4XFtm","selected-tag":"kne-super-select_Whlzr","select-search":"kne-super-select_7zuBL","select-tree-item-description":"kne-super-select_R-Sye","footer":"kne-super-select_PjlnR","is-mobile":"kne-super-select_yTb5p"};
|
|
1796
1775
|
|
|
1797
|
-
const parseTreeData = memoize__default["default"](
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
parentKey,
|
|
1803
|
-
valueKey,
|
|
1804
|
-
childrenKey
|
|
1805
|
-
} = _ref;
|
|
1776
|
+
const parseTreeData = memoize__default["default"]((data = [], {
|
|
1777
|
+
parentKey,
|
|
1778
|
+
valueKey,
|
|
1779
|
+
childrenKey
|
|
1780
|
+
}) => {
|
|
1806
1781
|
const parseTree = output => {
|
|
1807
1782
|
return output.map(node => {
|
|
1808
1783
|
const children = data.filter(item => {
|
|
@@ -1818,21 +1793,19 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
|
|
|
1818
1793
|
ids: data.map(item => item.id)
|
|
1819
1794
|
};
|
|
1820
1795
|
});
|
|
1821
|
-
const SelectTree = React.forwardRef((
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
} = _ref2;
|
|
1796
|
+
const SelectTree = React.forwardRef(({
|
|
1797
|
+
children,
|
|
1798
|
+
...p
|
|
1799
|
+
}, ref) => {
|
|
1826
1800
|
const fetchListRef = React.useRef(null);
|
|
1827
1801
|
const [expandedKeys, setExpandedKeys] = React.useState([]);
|
|
1828
1802
|
const props = Object.assign({}, {
|
|
1829
1803
|
parentKey: 'parentId',
|
|
1830
1804
|
childrenKey: 'children',
|
|
1831
|
-
renderItemContent:
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
} = _ref3;
|
|
1805
|
+
renderItemContent: ({
|
|
1806
|
+
item,
|
|
1807
|
+
props
|
|
1808
|
+
}) => {
|
|
1836
1809
|
const {
|
|
1837
1810
|
labelKey
|
|
1838
1811
|
} = props;
|
|
@@ -1972,19 +1945,15 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
|
|
|
1972
1945
|
data: {
|
|
1973
1946
|
options
|
|
1974
1947
|
},
|
|
1975
|
-
loader:
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
} = _ref4;
|
|
1979
|
-
return data.options;
|
|
1980
|
-
}
|
|
1948
|
+
loader: ({
|
|
1949
|
+
data
|
|
1950
|
+
}) => data.options
|
|
1981
1951
|
} : api), {
|
|
1982
1952
|
ref: fetchListRef,
|
|
1983
|
-
render:
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
} = _ref5;
|
|
1953
|
+
render: ({
|
|
1954
|
+
data,
|
|
1955
|
+
...fetchProps
|
|
1956
|
+
}) => {
|
|
1988
1957
|
const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
|
|
1989
1958
|
const treeContent = renderTree(Object.assign({}, fetchProps, targetProps, {
|
|
1990
1959
|
isSelectedAll,
|
|
@@ -2238,7 +2207,7 @@ const createTreeUtils = mapping => {
|
|
|
2238
2207
|
};
|
|
2239
2208
|
};
|
|
2240
2209
|
|
|
2241
|
-
var style = {"kne-responsive-boundary":"kne-super-select_5gTKr","kne-responsive-scroll":"kne-super-select_fhAr5","content":"kne-super-select_fHNBt","columns":"kne-super-select_VgpIp","content-item":"kne-super-select_kSkN1","last-level-area":"kne-super-select_1QV-l","is-popup":"kne-super-select_zFwDF","menu":"kne-super-select_s-ON4","scroll-plus-box":"kne-super-select_rIix2","menu-label":"kne-super-select_XAs20","menu-label-text":"kne-super-select_Y8AoQ","menu-item":"kne-super-select_ZwakZ","checkbox-hidden":"kne-super-select_0FUoe","single-mode":"kne-super-select_dahnB","menu-item-icon":"kne-super-select_AZZvN","menu-item-placeholder":"kne-super-select_TudTj","loading":"kne-super-select_ljvZk","search-input":"kne-super-select_FVxuS","scroller":"kne-super-select_vnHAM","is-mobile":"kne-super-select_HjXMw","
|
|
2210
|
+
var style = {"kne-responsive-boundary":"kne-super-select_5gTKr","kne-responsive-scroll":"kne-super-select_fhAr5","content":"kne-super-select_fHNBt","columns":"kne-super-select_VgpIp","content-item":"kne-super-select_kSkN1","last-level-area":"kne-super-select_1QV-l","is-popup":"kne-super-select_zFwDF","menu":"kne-super-select_s-ON4","scroll-plus-box":"kne-super-select_rIix2","menu-label":"kne-super-select_XAs20","menu-label-text":"kne-super-select_Y8AoQ","menu-item":"kne-super-select_ZwakZ","checkbox-hidden":"kne-super-select_0FUoe","single-mode":"kne-super-select_dahnB","menu-item-icon":"kne-super-select_AZZvN","menu-item-placeholder":"kne-super-select_TudTj","loading":"kne-super-select_ljvZk","search-input":"kne-super-select_FVxuS","scroller":"kne-super-select_vnHAM","is-mobile":"kne-super-select_HjXMw","custom-menu":"kne-super-select_OerpL","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","selected":"kne-super-select_OUkpN"};
|
|
2242
2211
|
|
|
2243
2212
|
const CustomMenu = ({
|
|
2244
2213
|
className,
|
|
@@ -2275,27 +2244,26 @@ const numberToPx = val => {
|
|
|
2275
2244
|
};
|
|
2276
2245
|
|
|
2277
2246
|
// 级联选择内容组件
|
|
2278
|
-
const CascaderInner =
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
} = _ref;
|
|
2247
|
+
const CascaderInner = ({
|
|
2248
|
+
options,
|
|
2249
|
+
value,
|
|
2250
|
+
setValue,
|
|
2251
|
+
maxLength,
|
|
2252
|
+
single,
|
|
2253
|
+
onlyAllowLastLevel,
|
|
2254
|
+
openLoadData,
|
|
2255
|
+
onLoadMore,
|
|
2256
|
+
parentIdKey,
|
|
2257
|
+
menuItemWidth,
|
|
2258
|
+
isPopup,
|
|
2259
|
+
searchPlaceholder,
|
|
2260
|
+
onSearch,
|
|
2261
|
+
valueKey,
|
|
2262
|
+
labelKey,
|
|
2263
|
+
onOpenChange,
|
|
2264
|
+
open,
|
|
2265
|
+
isMobile
|
|
2266
|
+
}) => {
|
|
2299
2267
|
const {
|
|
2300
2268
|
message
|
|
2301
2269
|
} = antd.App.useApp();
|
|
@@ -2307,10 +2275,7 @@ const CascaderInner = _ref => {
|
|
|
2307
2275
|
// 构建 mapping
|
|
2308
2276
|
const mapping = React.useMemo(() => {
|
|
2309
2277
|
const map = new Map();
|
|
2310
|
-
const processData =
|
|
2311
|
-
if (parentId === void 0) {
|
|
2312
|
-
parentId = null;
|
|
2313
|
-
}
|
|
2278
|
+
const processData = (items, parentId = null) => {
|
|
2314
2279
|
items.forEach(item => {
|
|
2315
2280
|
const node = {
|
|
2316
2281
|
...item,
|
|
@@ -2381,6 +2346,32 @@ const CascaderInner = _ref => {
|
|
|
2381
2346
|
prevOpenRef.current = open;
|
|
2382
2347
|
}, [open, value, mapping, treeUtils, valueKey, isPopup]);
|
|
2383
2348
|
|
|
2349
|
+
// 移动端多列竖直堆叠:切换后子级列若完全不在可视区,滚动到子级列
|
|
2350
|
+
const scrollerRef = React.useRef(null);
|
|
2351
|
+
const columnsRef = React.useRef(null);
|
|
2352
|
+
const scrollToLevelRef = React.useRef(null);
|
|
2353
|
+
React.useEffect(() => {
|
|
2354
|
+
const level = scrollToLevelRef.current;
|
|
2355
|
+
const scroller = scrollerRef.current;
|
|
2356
|
+
if (!isMobile || level === null || !scroller || !columnsRef.current) {
|
|
2357
|
+
return;
|
|
2358
|
+
}
|
|
2359
|
+
const column = columnsRef.current.children[level];
|
|
2360
|
+
// 懒加载时子级列在数据返回后才渲染
|
|
2361
|
+
if (!column) {
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
scrollToLevelRef.current = null;
|
|
2365
|
+
const scrollerRect = scroller.getBoundingClientRect();
|
|
2366
|
+
const columnRect = column.getBoundingClientRect();
|
|
2367
|
+
if (columnRect.top >= scrollerRect.bottom || columnRect.bottom <= scrollerRect.top) {
|
|
2368
|
+
scroller.scrollTo({
|
|
2369
|
+
top: scroller.scrollTop + columnRect.top - scrollerRect.top,
|
|
2370
|
+
behavior: 'smooth'
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
}, [selectedIds, mapping, isMobile]);
|
|
2374
|
+
|
|
2384
2375
|
// 懒加载支持
|
|
2385
2376
|
const loadMorePropsRef = React.useRef({});
|
|
2386
2377
|
loadMorePropsRef.current = {
|
|
@@ -2546,11 +2537,14 @@ const CascaderInner = _ref => {
|
|
|
2546
2537
|
showSearchButton: !isPopup
|
|
2547
2538
|
}), /*#__PURE__*/React__default["default"].createElement(ScrollBox, _extends({
|
|
2548
2539
|
className: classnames__default["default"](style['scroller'], 'select-cascader-scroller')
|
|
2549
|
-
}, isMobile ? {
|
|
2540
|
+
}, isMobile ? {
|
|
2541
|
+
ref: scrollerRef
|
|
2542
|
+
} : {
|
|
2550
2543
|
options: {
|
|
2551
2544
|
autoHide: false
|
|
2552
2545
|
}
|
|
2553
2546
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2547
|
+
ref: columnsRef,
|
|
2554
2548
|
className: classnames__default["default"](style['columns'], {
|
|
2555
2549
|
[style['is-mobile']]: isMobile
|
|
2556
2550
|
})
|
|
@@ -2566,10 +2560,9 @@ const CascaderInner = _ref => {
|
|
|
2566
2560
|
}, isLastLevel ? isMobile ? /*#__PURE__*/React__default["default"].createElement(CustomMenu, {
|
|
2567
2561
|
className: style['menu'],
|
|
2568
2562
|
selectedKeys: currentIds,
|
|
2569
|
-
onSelect:
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
} = _ref2;
|
|
2563
|
+
onSelect: ({
|
|
2564
|
+
key
|
|
2565
|
+
}) => {
|
|
2573
2566
|
const node = mapping.get(key);
|
|
2574
2567
|
if (!node) return;
|
|
2575
2568
|
const {
|
|
@@ -2625,13 +2618,13 @@ const CascaderInner = _ref => {
|
|
|
2625
2618
|
})) : /*#__PURE__*/React__default["default"].createElement(CustomMenu, {
|
|
2626
2619
|
className: style['menu'],
|
|
2627
2620
|
selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
|
|
2628
|
-
onSelect:
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
} = _ref3;
|
|
2621
|
+
onSelect: ({
|
|
2622
|
+
key
|
|
2623
|
+
}) => {
|
|
2632
2624
|
const node = mapping.get(key);
|
|
2633
2625
|
if (!node) return;
|
|
2634
2626
|
if (isNotLastNode(node.id)) {
|
|
2627
|
+
scrollToLevelRef.current = index + 1;
|
|
2635
2628
|
setSelectedIds(treeUtils.getSelectedQueue(node.id));
|
|
2636
2629
|
} else {
|
|
2637
2630
|
const {
|
|
@@ -2687,30 +2680,29 @@ const CascaderInner = _ref => {
|
|
|
2687
2680
|
};
|
|
2688
2681
|
|
|
2689
2682
|
// 主组件
|
|
2690
|
-
const SelectCascader =
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
} = _ref4;
|
|
2683
|
+
const SelectCascader = ({
|
|
2684
|
+
options = [],
|
|
2685
|
+
value,
|
|
2686
|
+
onChange,
|
|
2687
|
+
defaultValue,
|
|
2688
|
+
maxLength = Number.MAX_VALUE,
|
|
2689
|
+
single = false,
|
|
2690
|
+
onlyAllowLastLevel = false,
|
|
2691
|
+
openLoadData = false,
|
|
2692
|
+
onLoadMore,
|
|
2693
|
+
parentIdKey = 'id',
|
|
2694
|
+
menuItemWidth = 180,
|
|
2695
|
+
isPopup = true,
|
|
2696
|
+
searchPlaceholder,
|
|
2697
|
+
onSearch,
|
|
2698
|
+
valueKey = 'id',
|
|
2699
|
+
labelKey = 'label',
|
|
2700
|
+
placeholder = '请选择',
|
|
2701
|
+
disabled = false,
|
|
2702
|
+
size = 'default',
|
|
2703
|
+
overlayWidth,
|
|
2704
|
+
...props
|
|
2705
|
+
}) => {
|
|
2714
2706
|
// 内部始终使用数组格式处理
|
|
2715
2707
|
// SelectInput 会处理 single 模式的 value 和 onChange 转换
|
|
2716
2708
|
const [innerValue, setInnerValue] = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []);
|