@kne/super-select 0.1.33 → 0.1.35

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/dist/index.js CHANGED
@@ -45,6 +45,15 @@ function _extends() {
45
45
  return n;
46
46
  }, _extends.apply(null, arguments);
47
47
  }
48
+ function _objectWithoutPropertiesLoose(r, e) {
49
+ if (null == r) return {};
50
+ var t = {};
51
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
52
+ if (-1 !== e.indexOf(n)) continue;
53
+ t[n] = r[n];
54
+ }
55
+ return t;
56
+ }
48
57
 
49
58
  const context = globalContext.createContext();
50
59
  const {
@@ -52,7 +61,7 @@ const {
52
61
  useContext
53
62
  } = context;
54
63
 
55
- var style$5 = {"select-input":"_d8lGc","disabled":"_3kjwO","wrap":"_dsTM2","select-input-inner":"_NQoX9","large":"_T8ZX8","small":"_1B72H","select-input-icon":"_g8QC-","placeholder":"_r3q69","overlay-content":"_zEqGe","overlay":"_ybN30","select-input-prefix":"_4Pw75","select-input-suffix":"_Wd4pE"};
64
+ var style$6 = {"select-input":"kne-super-select_d8lGc","disabled":"kne-super-select_3kjwO","wrap":"kne-super-select_dsTM2","select-input-inner":"kne-super-select_NQoX9","large":"kne-super-select_T8ZX8","small":"kne-super-select_1B72H","single-label":"kne-super-select_pL0tE","tag-item":"kne-super-select_lc4o7","tag-label":"kne-super-select_RJmlD","overflow-tag":"kne-super-select_aHua2","measure-layer":"kne-super-select_QoQpC","select-input-icon":"kne-super-select_g8QC-","placeholder":"kne-super-select_r3q69","overlay-content":"kne-super-select_zEqGe","overlay":"kne-super-select_ybN30","select-input-prefix":"kne-super-select_4Pw75","select-input-suffix":"kne-super-select_Wd4pE"};
56
65
 
57
66
  const locale$1 = {
58
67
  placeholder: '请选择',
@@ -76,8 +85,99 @@ const locale = {
76
85
  removeAll: 'Remove All'
77
86
  };
78
87
 
79
- const numberToPx = val => {
80
- return typeof val === 'number' ? `${val}px` : val;
88
+ /**
89
+ * 标签溢出内部渲染组件
90
+ * 根据 innerWidth 计算标签显示数量
91
+ */
92
+ const TagOverflowInner = ({
93
+ value,
94
+ innerWidth,
95
+ labelKey,
96
+ valueKey,
97
+ onRemove,
98
+ overflowTagWidth = 45,
99
+ iconSpace = 20
100
+ }) => {
101
+ const [visibleCount, setVisibleCount] = React.useState(value.length);
102
+ const measureRef = React.useRef(null);
103
+
104
+ // 测量每个标签的实际宽度并计算可见数量
105
+ React.useLayoutEffect(() => {
106
+ // innerWidth 为 0 时,保持当前状态,等待正确的宽度
107
+ if (!measureRef.current || innerWidth === 0 || value.length === 0) {
108
+ setVisibleCount(value.length);
109
+ return;
110
+ }
111
+ const tagElements = measureRef.current.querySelectorAll('[data-tag-measure]');
112
+ if (tagElements.length === 0) return;
113
+
114
+ // 获取每个标签的实际占用宽度(包含 margin)
115
+ const tagWidths = Array.from(tagElements).map(el => {
116
+ const style = window.getComputedStyle(el);
117
+ const marginLeft = parseFloat(style.marginLeft) || 0;
118
+ const marginRight = parseFloat(style.marginRight) || 0;
119
+ return el.offsetWidth + marginLeft + marginRight;
120
+ });
121
+ const availableWidth = innerWidth - iconSpace;
122
+ let totalWidth = 0;
123
+ let count = 0;
124
+ for (let i = 0; i < tagWidths.length; i++) {
125
+ // 如果不是最后一个,需要预留 +N 标签空间
126
+ const needOverflowSpace = i < tagWidths.length - 1;
127
+ const requiredWidth = tagWidths[i] + (needOverflowSpace ? overflowTagWidth : 0);
128
+ if (totalWidth + requiredWidth <= availableWidth) {
129
+ totalWidth += tagWidths[i];
130
+ count++;
131
+ } else {
132
+ break;
133
+ }
134
+ }
135
+
136
+ // 确保至少显示一个标签
137
+ setVisibleCount(Math.max(1, count));
138
+ }, [value, innerWidth, overflowTagWidth, iconSpace]);
139
+
140
+ // 计算单个标签最大宽度:min(150px, innerWidth - 60),初始状态默认 150px
141
+ const maxTagWidth = innerWidth > 0 ? Math.min(150, Math.max(60, innerWidth - 60)) : 150;
142
+ const displayTags = value.slice(0, visibleCount);
143
+ const hiddenCount = value.length - visibleCount;
144
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
145
+ ref: measureRef,
146
+ className: style$6['measure-layer']
147
+ }, value.map(item => /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
148
+ key: item[valueKey],
149
+ "data-tag-measure": true,
150
+ closable: true,
151
+ bordered: false,
152
+ className: style$6['tag-item'],
153
+ style: {
154
+ '--max-tag-width': `${maxTagWidth}px`
155
+ }
156
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
157
+ className: style$6['tag-label']
158
+ }, item[labelKey])))), displayTags.map(item => /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
159
+ key: item[valueKey],
160
+ closable: true,
161
+ bordered: false,
162
+ className: style$6['tag-item'],
163
+ style: {
164
+ '--max-tag-width': `${maxTagWidth}px`
165
+ },
166
+ onClose: e => {
167
+ e.preventDefault();
168
+ onRemove(item);
169
+ }
170
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
171
+ className: style$6['tag-label'],
172
+ title: item[labelKey]
173
+ }, item[labelKey]))), hiddenCount > 0 && /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
174
+ className: style$6['overflow-tag']
175
+ }, "+", hiddenCount));
176
+ };
177
+
178
+ const _excluded$3 = ["children"];
179
+ const numberToPx$1 = val => {
180
+ return typeof val === 'number' ? val + "px" : val;
81
181
  };
82
182
  const pxToNumber = value => {
83
183
  if (!value) return 0;
@@ -88,15 +188,13 @@ const pxToNumber = value => {
88
188
  return match ? Number(match[0]) : 0;
89
189
  };
90
190
  const ModalContent = _ref => {
91
- let {
92
- children,
93
- ...others
94
- } = _ref;
95
- const {
96
- open,
97
- value: propsValue
98
- } = others;
99
- const [value, setValue] = React.useState(propsValue);
191
+ let children = _ref.children,
192
+ others = _objectWithoutPropertiesLoose(_ref, _excluded$3);
193
+ const open = others.open,
194
+ propsValue = others.value;
195
+ const _useState = React.useState(propsValue),
196
+ value = _useState[0],
197
+ setValue = _useState[1];
100
198
  React.useEffect(() => {
101
199
  if (open && !isEqual__default["default"](value, propsValue)) {
102
200
  setValue(propsValue);
@@ -124,9 +222,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
124
222
  }
125
223
  })(React.forwardRef((p, ref) => {
126
224
  const intl = reactIntl.useIntl();
127
- const {
128
- formatMessage
129
- } = intl;
225
+ const formatMessage = intl.formatMessage;
130
226
  const props = Object.assign({}, {
131
227
  children: () => formatMessage({
132
228
  id: 'defaultChildren'
@@ -161,17 +257,15 @@ const SelectInput = reactIntl.createWithIntlProvider({
161
257
  extra: null,
162
258
  size: 'default',
163
259
  renderModal: contextProps => {
164
- const {
165
- props,
166
- open,
167
- onComplete,
168
- onOpenChange
169
- } = contextProps;
170
- const {
171
- placeholder,
172
- children
173
- } = props;
260
+ const props = contextProps.props,
261
+ open = contextProps.open,
262
+ onComplete = contextProps.onComplete,
263
+ onOpenChange = contextProps.onOpenChange;
264
+ const placeholder = props.placeholder,
265
+ children = props.children,
266
+ overlayClassName = props.overlayClassName;
174
267
  return /*#__PURE__*/React__default["default"].createElement(antd.Modal, {
268
+ className: overlayClassName,
175
269
  width: 1000,
176
270
  open: open,
177
271
  title: placeholder,
@@ -189,27 +283,29 @@ const SelectInput = reactIntl.createWithIntlProvider({
189
283
  [props.valueKey]: props.selectedAllValue.value,
190
284
  [props.labelKey]: props.selectedAllValue.label
191
285
  };
192
- const {
193
- children,
194
- prefix,
195
- suffix,
196
- className,
197
- maxLength,
198
- overlayClassName,
199
- single,
200
- labelWrap,
201
- isPopup,
202
- allowClear,
203
- disabled,
204
- placeholder,
205
- selectedAllValue,
206
- overlayWidth,
207
- placement,
208
- renderModal,
209
- labelKey,
210
- valueKey,
211
- size
212
- } = props;
286
+ const children = props.children,
287
+ prefix = props.prefix,
288
+ suffix = props.suffix,
289
+ className = props.className,
290
+ maxLength = props.maxLength,
291
+ overlayClassName = props.overlayClassName,
292
+ overlayStyle = props.overlayStyle,
293
+ align = props.align,
294
+ autoAdjustOverflow = props.autoAdjustOverflow,
295
+ transitionName = props.transitionName,
296
+ single = props.single,
297
+ labelWrap = props.labelWrap,
298
+ isPopup = props.isPopup,
299
+ allowClear = props.allowClear,
300
+ disabled = props.disabled,
301
+ placeholder = props.placeholder,
302
+ selectedAllValue = props.selectedAllValue,
303
+ overlayWidth = props.overlayWidth,
304
+ placement = props.placement,
305
+ renderModal = props.renderModal,
306
+ labelKey = props.labelKey,
307
+ valueKey = props.valueKey,
308
+ size = props.size;
213
309
  const transformValue = value => {
214
310
  if (single) {
215
311
  return isEmpty.isNotEmpty(value) ? [value] : [];
@@ -217,30 +313,51 @@ const SelectInput = reactIntl.createWithIntlProvider({
217
313
  return Array.isArray(value) ? value : [];
218
314
  }
219
315
  };
220
- const [value, setValue] = useControlValue__default["default"](Object.assign({}, props, {
221
- onChange: value => {
222
- props.onChange && props.onChange(props.single ? last__default["default"](value) : value);
316
+ const _useControlValue = useControlValue__default["default"](Object.assign({}, props, {
317
+ onChange: value => {
318
+ props.onChange && props.onChange(props.single ? last__default["default"](value) : value);
319
+ }
320
+ }, 'value' in props ? {
321
+ value: transformValue(props.value)
322
+ } : {
323
+ defaultValue: transformValue(props.defaultValue)
324
+ })),
325
+ value = _useControlValue[0],
326
+ setValue = _useControlValue[1];
327
+ const _useState2 = React.useState({}),
328
+ searchProps = _useState2[0],
329
+ setSearchProps = _useState2[1];
330
+ const _useControlValue2 = useControlValue__default["default"](props, {
331
+ defaultValue: 'defaultOpen',
332
+ value: 'open',
333
+ onChange: 'onOpenChange'
334
+ }),
335
+ open = _useControlValue2[0],
336
+ setOpen = _useControlValue2[1];
337
+ const _useState3 = React.useState(false),
338
+ hover = _useState3[0],
339
+ setHover = _useState3[1];
340
+ const _useState4 = React.useState(0),
341
+ innerWidth = _useState4[0],
342
+ setInnerWidth = _useState4[1];
343
+ const _useState5 = React.useState(0),
344
+ containerWidth = _useState5[0],
345
+ setContainerWidth = _useState5[1];
346
+ const containerWidthChange = el => {
347
+ if (!el) {
348
+ return;
223
349
  }
224
- }, 'value' in props ? {
225
- value: transformValue(props.value)
226
- } : {
227
- defaultValue: transformValue(props.defaultValue)
228
- }));
229
- const [searchProps, setSearchProps] = React.useState({});
230
- const [open, setOpen] = useControlValue__default["default"](props, {
231
- defaultValue: 'defaultOpen',
232
- value: 'open',
233
- onChange: 'onOpenChange'
234
- });
235
- const [hover, setHover] = React.useState(false);
236
- const [inputWidth, setInputWidth] = React.useState(0);
237
- const inputRef = useResize__default["default"](el => {
238
- setInputWidth(el.clientWidth);
239
- });
240
- const popupOverlayWidth = numberToPx(Math.max(inputWidth, pxToNumber(overlayWidth)));
241
- const {
242
- message
243
- } = antd.App.useApp();
350
+ const containerWidth = el.clientWidth;
351
+ setContainerWidth(containerWidth);
352
+ const innerEl = el.querySelector('.select-input-inner');
353
+ setInnerWidth(innerEl.clientWidth);
354
+ };
355
+ const popupOverlayWidth = React.useMemo(() => {
356
+ return numberToPx$1(Math.max(containerWidth, pxToNumber(overlayWidth)));
357
+ }, [containerWidth, overlayWidth]);
358
+ const containerRef = useResize__default["default"](containerWidthChange);
359
+ const _App$useApp = antd.App.useApp(),
360
+ message = _App$useApp.message;
244
361
  const checkMaxLength = (value, maxLength) => {
245
362
  if (Number.isInteger(maxLength) && maxLength > 0 && value.length >= maxLength) {
246
363
  message.error(formatMessage({
@@ -297,7 +414,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
297
414
  searchProps,
298
415
  setSearchProps,
299
416
  hover,
300
- inputWidth,
417
+ inputWidth: containerWidth,
301
418
  onAdd,
302
419
  onRemove,
303
420
  onSelect,
@@ -313,12 +430,12 @@ const SelectInput = reactIntl.createWithIntlProvider({
313
430
  return contextProps.props.inputRender(props, contextProps);
314
431
  }
315
432
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, _extends({}, props, {
316
- ref: inputRef,
317
- className: classnames__default["default"](className, style$5['select-input'], 'select-input', {
318
- [style$5['wrap']]: labelWrap,
319
- [style$5['disabled']]: disabled,
320
- [style$5['small']]: size === 'small',
321
- [style$5['large']]: size === 'large'
433
+ ref: containerRef,
434
+ className: classnames__default["default"](className, style$6['select-input'], 'select-input', {
435
+ [style$6['wrap']]: labelWrap,
436
+ [style$6['disabled']]: disabled,
437
+ [style$6['small']]: size === 'small',
438
+ [style$6['large']]: size === 'large'
322
439
  }),
323
440
  justify: "space-between",
324
441
  onMouseOver: () => {
@@ -330,27 +447,26 @@ const SelectInput = reactIntl.createWithIntlProvider({
330
447
  }), (() => {
331
448
  const current = typeof prefix === 'function' ? prefix(contextProps) : prefix;
332
449
  return current && /*#__PURE__*/React__default["default"].createElement("span", {
333
- className: classnames__default["default"](style$5['select-input-prefix'], 'select-input-prefix'),
450
+ className: classnames__default["default"](style$6['select-input-prefix'], 'select-input-prefix'),
334
451
  onClick: e => {
335
452
  e.stopPropagation();
336
453
  }
337
454
  }, current);
338
455
  })(), /*#__PURE__*/React__default["default"].createElement("div", {
339
- className: classnames__default["default"](style$5['select-input-inner'], 'select-input-inner')
340
- }, value.length > 0 ? single || value[0][valueKey] === selectedAllValue[valueKey] ? value[0][labelKey] : value.map(item => {
341
- return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
342
- key: item[valueKey],
343
- closable: true,
344
- bordered: false,
345
- onClose: e => {
346
- e.preventDefault();
347
- onRemove(item);
348
- }
349
- }, item[labelKey]);
456
+ className: classnames__default["default"](style$6['select-input-inner'], 'select-input-inner')
457
+ }, value.length > 0 ? single || value[0][valueKey] === selectedAllValue[valueKey] ? /*#__PURE__*/React__default["default"].createElement("span", {
458
+ className: classnames__default["default"](style$6['single-label'], 'select-input-single-label'),
459
+ title: value[0][labelKey]
460
+ }, value[0][labelKey]) : /*#__PURE__*/React__default["default"].createElement(TagOverflowInner, {
461
+ value: value,
462
+ innerWidth: innerWidth,
463
+ labelKey: labelKey,
464
+ valueKey: valueKey,
465
+ onRemove: onRemove
350
466
  }) : /*#__PURE__*/React__default["default"].createElement("span", {
351
- className: classnames__default["default"](style$5['placeholder'], 'select-input-placeholder')
467
+ className: classnames__default["default"](style$6['placeholder'], 'select-input-placeholder')
352
468
  }, placeholder)), /*#__PURE__*/React__default["default"].createElement("div", {
353
- className: classnames__default["default"](style$5['select-input-icon'], 'select-input-icon')
469
+ className: classnames__default["default"](style$6['select-input-icon'], 'select-input-icon')
354
470
  }, !disabled && allowClear && hover && value.length > 0 ? /*#__PURE__*/React__default["default"].createElement(icons.CloseCircleFilled, {
355
471
  onClick: e => {
356
472
  e.stopPropagation();
@@ -359,7 +475,7 @@ const SelectInput = reactIntl.createWithIntlProvider({
359
475
  }) : /*#__PURE__*/React__default["default"].createElement(icons.DownOutlined, null)), (() => {
360
476
  const current = typeof suffix === 'function' ? suffix(contextProps) : suffix;
361
477
  return current && /*#__PURE__*/React__default["default"].createElement("span", {
362
- className: classnames__default["default"](style$5['select-input-suffix'], 'select-input-suffix'),
478
+ className: classnames__default["default"](style$6['select-input-suffix'], 'select-input-suffix'),
363
479
  onClick: e => {
364
480
  e.stopPropagation();
365
481
  }
@@ -379,13 +495,17 @@ const SelectInput = reactIntl.createWithIntlProvider({
379
495
  onOpenChange: setOpen,
380
496
  placement: placement,
381
497
  arrow: false,
382
- overlayClassName: classnames__default["default"](style$5['overlay'], overlayClassName),
498
+ overlayClassName: classnames__default["default"](style$6['overlay'], overlayClassName),
499
+ overlayStyle: overlayStyle,
500
+ align: align,
501
+ autoAdjustOverflow: autoAdjustOverflow,
502
+ transitionName: transitionName,
383
503
  trigger: "click",
384
504
  popupRender: () => /*#__PURE__*/React__default["default"].createElement("div", {
385
505
  style: {
386
506
  '--overlay-width': popupOverlayWidth
387
507
  },
388
- className: classnames__default["default"](style$5['overlay-content'], 'over-content'),
508
+ className: classnames__default["default"](style$6['overlay-content'], 'over-content'),
389
509
  onClick: e => {
390
510
  e.stopPropagation();
391
511
  }
@@ -397,32 +517,29 @@ const SelectInput = reactIntl.createWithIntlProvider({
397
517
  }), /*#__PURE__*/React__default["default"].createElement(ModalContent, contextProps, renderModal)));
398
518
  }));
399
519
 
400
- var style$4 = {"selected-all":"_prlgN"};
520
+ var style$5 = {"selected-all":"kne-super-select_prlgN"};
401
521
 
402
522
  const SelectedAll = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
403
- const {
404
- formatMessage
405
- } = reactIntl.useIntl();
406
- const {
407
- props,
408
- value,
409
- setValue
410
- } = useContext();
411
- const {
412
- unit,
413
- selectedAllValue,
414
- valueKey
415
- } = Object.assign({}, {
416
- unit: number => formatMessage({
417
- id: 'numberOf'
418
- }, {
419
- number
420
- })
421
- }, props);
523
+ const _useIntl = reactIntl.useIntl(),
524
+ formatMessage = _useIntl.formatMessage;
525
+ const _useContext = useContext(),
526
+ props = _useContext.props,
527
+ value = _useContext.value,
528
+ setValue = _useContext.setValue;
529
+ const _Object$assign = Object.assign({}, {
530
+ unit: number => formatMessage({
531
+ id: 'numberOf'
532
+ }, {
533
+ number
534
+ })
535
+ }, props),
536
+ unit = _Object$assign.unit,
537
+ selectedAllValue = _Object$assign.selectedAllValue,
538
+ valueKey = _Object$assign.valueKey;
422
539
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
423
540
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
424
541
  justify: "space-between",
425
- className: classnames__default["default"](style$4['selected-all'], 'selected-all')
542
+ className: classnames__default["default"](style$5['selected-all'], 'selected-all')
426
543
  }, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
427
544
  gap: 8
428
545
  }, /*#__PURE__*/React__default["default"].createElement("span", null, formatMessage({
@@ -445,42 +562,39 @@ const computedIsSelectAll = function (value, selectedAllValue, valueKey) {
445
562
  if (valueKey === void 0) {
446
563
  valueKey = 'value';
447
564
  }
448
- return value?.length === 1 && get__default["default"](value, `[0][${valueKey}]`) === selectedAllValue[valueKey];
565
+ return (value == null ? void 0 : value.length) === 1 && get__default["default"](value, "[0][" + valueKey + "]") === selectedAllValue[valueKey];
449
566
  };
450
567
 
451
- var style$3 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-container":"_dKZHi","tag-container-inner":"_oijCI","tag":"_WmnnS","tag-inner":"_TMcFl"};
568
+ var style$4 = {"label":"kne-super-select_l3KoW","tag-list":"kne-super-select_CCPzb","tag-container":"kne-super-select_dKZHi","tag-container-inner":"kne-super-select_oijCI","tag":"kne-super-select_WmnnS","tag-inner":"kne-super-select_TMcFl"};
452
569
 
453
570
  const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(() => {
454
- const {
455
- formatMessage
456
- } = reactIntl.useIntl();
457
- const {
458
- props,
459
- value,
460
- onRemove
461
- } = useContext();
462
- const {
463
- single,
464
- maxLength,
465
- labelKey,
466
- valueKey
467
- } = Object.assign({}, props);
571
+ const _useIntl = reactIntl.useIntl(),
572
+ formatMessage = _useIntl.formatMessage;
573
+ const _useContext = useContext(),
574
+ props = _useContext.props,
575
+ value = _useContext.value,
576
+ onRemove = _useContext.onRemove;
577
+ const _Object$assign = Object.assign({}, props),
578
+ single = _Object$assign.single,
579
+ maxLength = _Object$assign.maxLength,
580
+ labelKey = _Object$assign.labelKey,
581
+ valueKey = _Object$assign.valueKey;
468
582
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
469
- className: classnames__default["default"](style$3['tag-list'], 'selected-tag-list'),
583
+ className: classnames__default["default"](style$4['tag-list'], 'selected-tag-list'),
470
584
  gap: 8
471
585
  }, /*#__PURE__*/React__default["default"].createElement("div", {
472
- className: style$3['label']
586
+ className: style$4['label']
473
587
  }, formatMessage({
474
588
  id: 'selected'
475
- }), !single && value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
476
- className: style$3['tag-container']
589
+ }), !single && value.length > 0 && "(" + value.length + (Number.isInteger(maxLength) ? "/" + maxLength : '') + ")", ":"), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
590
+ className: style$4['tag-container']
477
591
  }, /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
478
592
  gap: 8,
479
593
  wrap: true,
480
- className: style$3['tag-container-inner']
594
+ className: style$4['tag-container-inner']
481
595
  }, value.map(item => {
482
596
  return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
483
- className: style$3['tag'],
597
+ className: style$4['tag'],
484
598
  key: item[valueKey],
485
599
  closable: true,
486
600
  bordered: false,
@@ -489,55 +603,46 @@ const SelectedTagList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
489
603
  onRemove(item);
490
604
  }
491
605
  }, /*#__PURE__*/React__default["default"].createElement("span", {
492
- className: style$3['tag-inner']
606
+ className: style$4['tag-inner']
493
607
  }, item[labelKey]));
494
608
  }))));
495
609
  });
496
610
 
497
- var style$2 = {"list":"_IsXdU","is-popup":"_-dvpa","empty":"_SQZ8k","default-list":"_QD1Mz","is-selected-all":"_M-mOy","default-list-item":"_KtOsz","is-selected":"_TQhBB","single-checked":"_2rUrh","is-disabled":"_NbwX5","selected-all":"_vN2Fx","selected-tag":"_6oITk","select-search":"_iAH9D","select-list-item-description":"_TCkeJ","footer":"_v3f23"};
611
+ var style$3 = {"list":"kne-super-select_IsXdU","is-popup":"kne-super-select_-dvpa","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"};
498
612
 
613
+ const _excluded$2 = ["children"];
499
614
  const SelectList = React.forwardRef((_ref, ref) => {
500
- let {
501
- children,
502
- ...p
503
- } = _ref;
615
+ let children = _ref.children,
616
+ p = _objectWithoutPropertiesLoose(_ref, _excluded$2);
504
617
  const fetchListRef = React.useRef(null);
505
618
  const props = Object.assign({}, {
506
619
  renderItemContent: _ref2 => {
507
- let {
508
- item,
509
- props
510
- } = _ref2;
511
- const {
512
- labelKey
513
- } = props;
620
+ let item = _ref2.item,
621
+ props = _ref2.props;
622
+ const labelKey = props.labelKey;
514
623
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
515
624
  className: 'select-list-item-label'
516
625
  }, item[labelKey]), item.description && /*#__PURE__*/React__default["default"].createElement("div", {
517
- className: classnames__default["default"](style$2['select-list-item-description'], 'select-list-item-description')
626
+ className: classnames__default["default"](style$3['select-list-item-description'], 'select-list-item-description')
518
627
  }, item.description));
519
628
  },
520
629
  renderItem: contextProps => {
521
- const {
522
- item,
523
- props,
524
- isSelectedAll,
525
- value,
526
- onSelect,
527
- setValue,
528
- onOpenChange
529
- } = contextProps;
530
- const {
531
- single,
532
- isPopup,
533
- renderItemContent,
534
- valueKey
535
- } = props;
630
+ const item = contextProps.item,
631
+ props = contextProps.props,
632
+ isSelectedAll = contextProps.isSelectedAll,
633
+ value = contextProps.value,
634
+ onSelect = contextProps.onSelect,
635
+ setValue = contextProps.setValue,
636
+ onOpenChange = contextProps.onOpenChange;
637
+ const single = props.single,
638
+ isPopup = props.isPopup,
639
+ renderItemContent = props.renderItemContent,
640
+ valueKey = props.valueKey;
536
641
  const isChecked = value.some(target => target[valueKey] === item[valueKey]);
537
642
  return /*#__PURE__*/React__default["default"].createElement(antd.List.Item, {
538
- className: classnames__default["default"](style$2['default-list-item'], 'select-list-item', {
539
- [style$2['is-selected']]: isChecked,
540
- [style$2['is-disabled']]: item.disabled
643
+ className: classnames__default["default"](style$3['default-list-item'], 'select-list-item', {
644
+ [style$3['is-selected']]: isChecked,
645
+ [style$3['is-disabled']]: item.disabled
541
646
  }),
542
647
  key: item[valueKey],
543
648
  onClick: () => {
@@ -565,26 +670,22 @@ const SelectList = React.forwardRef((_ref, ref) => {
565
670
  flex: 1,
566
671
  className: 'select-list-item-content'
567
672
  }, renderItemContent(contextProps)), single && /*#__PURE__*/React__default["default"].createElement("div", {
568
- className: style$2['single-checked']
673
+ className: style$3['single-checked']
569
674
  }, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
570
675
  },
571
676
  renderList: contextProps => {
572
- const {
573
- props,
574
- isSelectedAll,
575
- list
576
- } = contextProps;
577
- const {
578
- renderItem
579
- } = props;
677
+ const props = contextProps.props,
678
+ isSelectedAll = contextProps.isSelectedAll,
679
+ list = contextProps.list;
680
+ const renderItem = props.renderItem;
580
681
  if (!(list && list.length > 0)) {
581
682
  return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
582
- className: style$2['empty']
683
+ className: style$3['empty']
583
684
  });
584
685
  }
585
686
  return /*#__PURE__*/React__default["default"].createElement(antd.List, {
586
- className: classnames__default["default"](style$2['default-list'], {
587
- [style$2['is-selected-all']]: isSelectedAll
687
+ className: classnames__default["default"](style$3['default-list'], {
688
+ [style$3['is-selected-all']]: isSelectedAll
588
689
  }),
589
690
  size: "small",
590
691
  dataSource: list,
@@ -597,31 +698,27 @@ const SelectList = React.forwardRef((_ref, ref) => {
597
698
  return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
598
699
  ref: ref
599
700
  }), targetProps => {
600
- const {
601
- props,
602
- value,
603
- searchProps,
604
- setSearchProps,
605
- onOpenChange
606
- } = targetProps;
607
- const {
608
- footer,
609
- isPopup,
610
- getSearchProps,
611
- getSearchCallback,
612
- searchPlaceholder,
613
- valueKey,
614
- single,
615
- allowSelectedAll,
616
- showSelectedTag,
617
- api,
618
- options,
619
- renderList,
620
- selectedAllValue
621
- } = props;
701
+ const props = targetProps.props,
702
+ value = targetProps.value,
703
+ searchProps = targetProps.searchProps,
704
+ setSearchProps = targetProps.setSearchProps,
705
+ onOpenChange = targetProps.onOpenChange;
706
+ const footer = props.footer,
707
+ isPopup = props.isPopup,
708
+ getSearchProps = props.getSearchProps,
709
+ getSearchCallback = props.getSearchCallback,
710
+ searchPlaceholder = props.searchPlaceholder,
711
+ valueKey = props.valueKey,
712
+ single = props.single,
713
+ allowSelectedAll = props.allowSelectedAll,
714
+ showSelectedTag = props.showSelectedTag,
715
+ api = props.api,
716
+ options = props.options,
717
+ renderList = props.renderList,
718
+ selectedAllValue = props.selectedAllValue;
622
719
  const components = {
623
720
  search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
624
- className: classnames__default["default"](style$2['select-search'], 'select-list-search', {
721
+ className: classnames__default["default"](style$3['select-search'], 'select-list-search', {
625
722
  'is-popup': isPopup
626
723
  }),
627
724
  placeholder: searchPlaceholder,
@@ -635,12 +732,12 @@ const SelectList = React.forwardRef((_ref, ref) => {
635
732
  showSearchButton: !isPopup
636
733
  }),
637
734
  selectedAll: /*#__PURE__*/React__default["default"].createElement("div", {
638
- className: classnames__default["default"](style$2['selected-all'], 'select-list-selected-all', {
735
+ className: classnames__default["default"](style$3['selected-all'], 'select-list-selected-all', {
639
736
  'is-popup': isPopup
640
737
  })
641
738
  }, !single && allowSelectedAll && /*#__PURE__*/React__default["default"].createElement(SelectedAll, null)),
642
739
  fetchList: /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
643
- className: classnames__default["default"](style$2['list'], 'select-list-scroll-list', {
740
+ className: classnames__default["default"](style$3['list'], 'select-list-scroll-list', {
644
741
  'is-popup': isPopup
645
742
  }),
646
743
  searchProps: searchProps,
@@ -651,13 +748,9 @@ const SelectList = React.forwardRef((_ref, ref) => {
651
748
  searchProps
652
749
  },
653
750
  loader: _ref3 => {
654
- let {
655
- data
656
- } = _ref3;
657
- const {
658
- options,
659
- searchProps
660
- } = data;
751
+ let data = _ref3.data;
752
+ const options = data.options,
753
+ searchProps = data.searchProps;
661
754
  if (typeof getSearchCallback === 'function') {
662
755
  const newOptions = options.filter(item => getSearchCallback(searchProps, item));
663
756
  return {
@@ -677,12 +770,12 @@ const SelectList = React.forwardRef((_ref, ref) => {
677
770
  }));
678
771
  }),
679
772
  selectedTag: showSelectedTag && /*#__PURE__*/React__default["default"].createElement("div", {
680
- className: classnames__default["default"](style$2['selected-tag'], 'select-list-selected-tag', {
773
+ className: classnames__default["default"](style$3['selected-tag'], 'select-list-selected-tag', {
681
774
  'is-popup': isPopup
682
775
  })
683
776
  }, /*#__PURE__*/React__default["default"].createElement(SelectedTagList, null)),
684
777
  footer: footer && /*#__PURE__*/React__default["default"].createElement("div", {
685
- className: classnames__default["default"](style$2['footer'], 'select-list-footer')
778
+ className: classnames__default["default"](style$3['footer'], 'select-list-footer')
686
779
  }, typeof footer === 'function' ? footer({
687
780
  reload: () => {
688
781
  fetchListRef.current && fetchListRef.current.reload();
@@ -703,36 +796,32 @@ const SelectList = React.forwardRef((_ref, ref) => {
703
796
  });
704
797
  });
705
798
 
706
- var style$1 = {"list":"_DrEYJ","is-popup":"_KgWTX","empty":"_5Tyrt","table":"_zE-14","right-options":"_UXi-g","no-padding-btn":"_iaCir","tag":"_JkYqS","tag-inner":"_VZlBL","single-checked":"_Eiz-u","select-search":"_temy6","tags-search":"_7phL2","descriptions":"_ttNK9","footer":"_lISfA"};
799
+ var style$2 = {"list":"kne-super-select_DrEYJ","is-popup":"kne-super-select_KgWTX","empty":"kne-super-select_5Tyrt","table":"kne-super-select_zE-14","right-options":"kne-super-select_UXi-g","no-padding-btn":"kne-super-select_iaCir","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"};
707
800
 
708
801
  const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'super-select')(React.forwardRef((p, ref) => {
709
- const {
710
- formatMessage
711
- } = reactIntl.useIntl();
712
- const [tagSearchText, setTagSearchText] = React.useState('');
802
+ const _useIntl = reactIntl.useIntl(),
803
+ formatMessage = _useIntl.formatMessage;
804
+ const _useState = React.useState(''),
805
+ tagSearchText = _useState[0],
806
+ setTagSearchText = _useState[1];
713
807
  const fetchListRef = React.useRef();
714
808
  const props = Object.assign({}, {
715
809
  overlayWidth: '600px',
716
810
  filterRender: contextProps => {
717
- const {
718
- props,
719
- searchProps,
720
- setSearchProps
721
- } = contextProps;
722
- const {
723
- isPopup,
724
- searchPlaceholder,
725
- api,
726
- getSearchProps,
727
- options,
728
- getSearchCallback,
729
- labelKey
730
- } = props;
811
+ const props = contextProps.props,
812
+ searchProps = contextProps.searchProps,
813
+ setSearchProps = contextProps.setSearchProps;
814
+ const isPopup = props.isPopup,
815
+ searchPlaceholder = props.searchPlaceholder,
816
+ api = props.api,
817
+ getSearchProps = props.getSearchProps,
818
+ options = props.options,
819
+ getSearchCallback = props.getSearchCallback;
731
820
  if (!(api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function')) {
732
821
  return null;
733
822
  }
734
823
  return /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
735
- className: classnames__default["default"](style$1['select-search'], 'select-table-search', {
824
+ className: classnames__default["default"](style$2['select-search'], 'select-table-search', {
736
825
  'is-popup': isPopup
737
826
  }),
738
827
  placeholder: searchPlaceholder,
@@ -747,12 +836,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
747
836
  });
748
837
  },
749
838
  getTagSearchCallback: (tagSearchText, item, contextProps) => {
750
- const {
751
- props
752
- } = contextProps;
753
- const {
754
- labelKey
755
- } = props;
839
+ const props = contextProps.props;
840
+ const labelKey = props.labelKey;
756
841
  if (!tagSearchText) {
757
842
  return true;
758
843
  }
@@ -763,39 +848,35 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
763
848
  return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
764
849
  ref: ref
765
850
  }), targetProps => {
766
- const {
767
- props,
768
- value,
769
- setValue,
770
- onSelect,
771
- onRemove,
772
- onOpenChange,
773
- searchProps
774
- } = targetProps;
775
- const {
776
- footer,
777
- filterRender,
778
- columns,
779
- options,
780
- getSearchProps,
781
- getSearchCallback,
782
- getTagSearchCallback,
783
- api,
784
- selectedAllValue,
785
- isPopup,
786
- single,
787
- maxLength,
788
- searchPlaceholder,
789
- allowSelectedAll,
790
- labelKey,
791
- valueKey
792
- } = props;
851
+ const props = targetProps.props,
852
+ value = targetProps.value,
853
+ setValue = targetProps.setValue,
854
+ onRemove = targetProps.onRemove,
855
+ onOpenChange = targetProps.onOpenChange,
856
+ searchProps = targetProps.searchProps;
857
+ const footer = props.footer,
858
+ filterRender = props.filterRender,
859
+ columns = props.columns,
860
+ options = props.options,
861
+ getSearchProps = props.getSearchProps,
862
+ getSearchCallback = props.getSearchCallback,
863
+ getTagSearchCallback = props.getTagSearchCallback,
864
+ api = props.api,
865
+ selectedAllValue = props.selectedAllValue,
866
+ isPopup = props.isPopup,
867
+ single = props.single,
868
+ maxLength = props.maxLength,
869
+ searchPlaceholder = props.searchPlaceholder,
870
+ allowSelectedAll = props.allowSelectedAll,
871
+ labelKey = props.labelKey,
872
+ valueKey = props.valueKey;
793
873
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
794
874
  const footerEl = footer && /*#__PURE__*/React__default["default"].createElement("div", {
795
- className: classnames__default["default"](style$1['footer'], 'select-table-footer')
875
+ className: classnames__default["default"](style$2['footer'], 'select-table-footer')
796
876
  }, typeof footer === 'function' ? footer({
797
877
  reload: () => {
798
- fetchListRef.current?.fetchApi && fetchListRef.current?.fetchApi.reload();
878
+ var _fetchListRef$current, _fetchListRef$current2;
879
+ ((_fetchListRef$current = fetchListRef.current) == null ? void 0 : _fetchListRef$current.fetchApi) && ((_fetchListRef$current2 = fetchListRef.current) == null ? void 0 : _fetchListRef$current2.fetchApi.reload());
799
880
  },
800
881
  close: () => {
801
882
  onOpenChange(false);
@@ -806,11 +887,11 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
806
887
  ref: bodyRef
807
888
  }, /*#__PURE__*/React__default["default"].createElement(antd.Col, {
808
889
  className: classnames__default["default"]({
809
- [style$1['single-body']]: single
890
+ [style$2['single-body']]: single
810
891
  }),
811
892
  span: single ? 24 : 16
812
893
  }, /*#__PURE__*/React__default["default"].createElement("div", null, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React__default["default"].createElement("div", {
813
- className: classnames__default["default"](style$1['table'], 'select-table')
894
+ className: classnames__default["default"](style$2['table'], 'select-table')
814
895
  }, /*#__PURE__*/React__default["default"].createElement(infoPage.TableView, {
815
896
  columns: columns,
816
897
  rowKey: valueKey,
@@ -823,12 +904,11 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
823
904
  type: single ? 'radio' : 'checkbox',
824
905
  selectedRowKeys: (value || []).map(item => item[valueKey]),
825
906
  onChange: (selectedRowKeys, selectedKey, _ref) => {
826
- let {
827
- checked
828
- } = _ref;
907
+ let checked = _ref.checked;
829
908
  setValue(value => {
830
909
  if (checked) {
831
- const selectedItem = fetchListRef.current?.list.find(item => item[valueKey] === selectedKey);
910
+ var _fetchListRef$current3;
911
+ const selectedItem = (_fetchListRef$current3 = fetchListRef.current) == null ? void 0 : _fetchListRef$current3.list.find(item => item[valueKey] === selectedKey);
832
912
  if (selectedItem) {
833
913
  if (single) {
834
914
  return [selectedItem];
@@ -848,12 +928,10 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
848
928
  }
849
929
  },
850
930
  render: _ref2 => {
851
- let {
852
- header,
853
- renderBody
854
- } = _ref2;
931
+ let header = _ref2.header,
932
+ renderBody = _ref2.renderBody;
855
933
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, header, /*#__PURE__*/React__default["default"].createElement(scrollLoader.FetchScrollLoader, _extends({}, props, {
856
- className: classnames__default["default"](style$1['list'], 'select-table-list-scroll-list', {
934
+ className: classnames__default["default"](style$2['list'], 'select-table-list-scroll-list', {
857
935
  'is-popup': isPopup
858
936
  }),
859
937
  searchProps: searchProps,
@@ -864,13 +942,9 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
864
942
  searchProps
865
943
  },
866
944
  loader: _ref3 => {
867
- let {
868
- data
869
- } = _ref3;
870
- const {
871
- options,
872
- searchProps
873
- } = data;
945
+ let data = _ref3.data;
946
+ const options = data.options,
947
+ searchProps = data.searchProps;
874
948
  if (typeof getSearchCallback === 'function') {
875
949
  const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
876
950
  return {
@@ -884,29 +958,27 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
884
958
  } : api)
885
959
  }), fetchProps => {
886
960
  fetchListRef.current = fetchProps;
887
- const {
888
- list
889
- } = fetchProps;
961
+ const list = fetchProps.list;
890
962
  const contextProps = Object.assign({}, fetchProps, targetProps, {
891
963
  isSelectedAll
892
964
  });
893
965
  if (!(list && list.length > 0)) {
894
966
  return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
895
- className: classnames__default["default"](style$1['empty'])
967
+ className: classnames__default["default"](style$2['empty'])
896
968
  });
897
969
  }
898
970
  return renderBody(list, contextProps);
899
971
  }));
900
972
  }
901
973
  })), single && footerEl || /*#__PURE__*/React__default["default"].createElement("div", {
902
- className: classnames__default["default"](style$1['footer'], 'select-table-footer')
974
+ className: classnames__default["default"](style$2['footer'], 'select-table-footer')
903
975
  })), !single && /*#__PURE__*/React__default["default"].createElement(antd.Col, {
904
- className: classnames__default["default"](style$1['right-options'], {
976
+ className: classnames__default["default"](style$2['right-options'], {
905
977
  'is-popup': isPopup
906
978
  }),
907
979
  span: 8
908
980
  }, /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
909
- className: style$1['tags-search'],
981
+ className: style$2['tags-search'],
910
982
  placeholder: searchPlaceholder,
911
983
  value: tagSearchText,
912
984
  onSearch: value => {
@@ -919,8 +991,8 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
919
991
  align: 'middle'
920
992
  }, /*#__PURE__*/React__default["default"].createElement(antd.Col, null, formatMessage({
921
993
  id: 'selected'
922
- }), value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
923
- className: style$1['no-padding-btn'],
994
+ }), value.length > 0 && "(" + value.length + (Number.isInteger(maxLength) ? "/" + maxLength : '') + ")", ":"), /*#__PURE__*/React__default["default"].createElement(antd.Col, null, /*#__PURE__*/React__default["default"].createElement(antd.Button, {
995
+ className: style$2['no-padding-btn'],
924
996
  type: "link",
925
997
  onClick: () => {
926
998
  setValue([]);
@@ -931,8 +1003,9 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
931
1003
  wrap: true,
932
1004
  gap: 8
933
1005
  }, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {
1006
+ var _fetchListRef$current4, _fetchListRef$current5;
934
1007
  return /*#__PURE__*/React__default["default"].createElement(antd.Tag, {
935
- className: style$1['tag'],
1008
+ className: style$2['tag'],
936
1009
  key: item[valueKey],
937
1010
  closable: true,
938
1011
  bordered: false,
@@ -943,7 +1016,7 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
943
1016
  }, /*#__PURE__*/React__default["default"].createElement(antd.Popover, {
944
1017
  getPopupContainer: () => bodyRef.current,
945
1018
  content: /*#__PURE__*/React__default["default"].createElement(infoPage.CentralContent, {
946
- className: style$1['descriptions'],
1019
+ className: style$2['descriptions'],
947
1020
  columns: columns.filter(item => {
948
1021
  if (Object.hasOwn(item, 'previewHidden')) {
949
1022
  return !item.previewHidden;
@@ -954,28 +1027,28 @@ const SelectTableList = reactIntl.createWithIntlProvider('zh-CN', locale$1, 'sup
954
1027
  })),
955
1028
  dataSource: Object.assign({}, item),
956
1029
  context: Object.assign({}, targetProps, {
957
- fetchApi: fetchListRef.current?.fetchApi,
958
- list: fetchListRef.current?.list
1030
+ fetchApi: (_fetchListRef$current4 = fetchListRef.current) == null ? void 0 : _fetchListRef$current4.fetchApi,
1031
+ list: (_fetchListRef$current5 = fetchListRef.current) == null ? void 0 : _fetchListRef$current5.list
959
1032
  })
960
1033
  })
961
1034
  }, /*#__PURE__*/React__default["default"].createElement("span", {
962
- className: style$1['tag-inner']
1035
+ className: style$2['tag-inner']
963
1036
  }, item[labelKey])));
964
1037
  }))), footerEl));
965
1038
  });
966
1039
  }));
967
1040
 
968
- var style = {"list":"_YTqxA","is-popup":"_TR-1a","default-list":"_IZN7r","is-selected-all":"_GCIMn","default-list-item":"_AYi0i","is-selected":"_eovZv","single-checked":"_Tr-bO","is-disabled":"_T-hri","selected-all":"_4XFtm","selected-tag":"_Whlzr","select-search":"_7zuBL","select-tree-item-description":"_R-Sye","footer":"_PjlnR"};
1041
+ var style$1 = {"list":"kne-super-select_YTqxA","is-popup":"kne-super-select_TR-1a","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"};
969
1042
 
1043
+ const _excluded$1 = ["children"],
1044
+ _excluded2 = ["data"];
970
1045
  const parseTreeData = memoize__default["default"](function (data, _ref) {
971
1046
  if (data === void 0) {
972
1047
  data = [];
973
1048
  }
974
- let {
975
- parentKey,
976
- valueKey,
977
- childrenKey
978
- } = _ref;
1049
+ let parentKey = _ref.parentKey,
1050
+ valueKey = _ref.valueKey,
1051
+ childrenKey = _ref.childrenKey;
979
1052
  const parseTree = output => {
980
1053
  return output.map(node => {
981
1054
  const children = data.filter(item => {
@@ -992,48 +1065,40 @@ const parseTreeData = memoize__default["default"](function (data, _ref) {
992
1065
  };
993
1066
  });
994
1067
  const SelectTree = React.forwardRef((_ref2, ref) => {
995
- let {
996
- children,
997
- ...p
998
- } = _ref2;
1068
+ let children = _ref2.children,
1069
+ p = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
999
1070
  const fetchListRef = React.useRef(null);
1000
- const [expandedKeys, setExpandedKeys] = React.useState([]);
1071
+ const _useState = React.useState([]),
1072
+ expandedKeys = _useState[0],
1073
+ setExpandedKeys = _useState[1];
1001
1074
  const props = Object.assign({}, {
1002
1075
  parentKey: 'parentId',
1003
1076
  childrenKey: 'children',
1004
1077
  renderItemContent: _ref3 => {
1005
- let {
1006
- item,
1007
- props
1008
- } = _ref3;
1009
- const {
1010
- labelKey
1011
- } = props;
1078
+ let item = _ref3.item,
1079
+ props = _ref3.props;
1080
+ const labelKey = props.labelKey;
1012
1081
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
1013
1082
  className: 'select-tree-item-label'
1014
1083
  }, item[labelKey]));
1015
1084
  },
1016
1085
  renderItem: contextProps => {
1017
- const {
1018
- item,
1019
- props,
1020
- isSelectedAll,
1021
- value,
1022
- onSelect,
1023
- setValue,
1024
- onOpenChange
1025
- } = contextProps;
1026
- const {
1027
- single,
1028
- isPopup,
1029
- renderItemContent,
1030
- valueKey
1031
- } = props;
1086
+ const item = contextProps.item,
1087
+ props = contextProps.props,
1088
+ isSelectedAll = contextProps.isSelectedAll,
1089
+ value = contextProps.value,
1090
+ onSelect = contextProps.onSelect,
1091
+ setValue = contextProps.setValue,
1092
+ onOpenChange = contextProps.onOpenChange;
1093
+ const single = props.single,
1094
+ isPopup = props.isPopup,
1095
+ renderItemContent = props.renderItemContent,
1096
+ valueKey = props.valueKey;
1032
1097
  const isChecked = value.some(target => target[valueKey] === item[valueKey]);
1033
1098
  return /*#__PURE__*/React__default["default"].createElement(antd.Flex, {
1034
- className: classnames__default["default"](style['default-list-item'], 'select-tree-item', {
1035
- [style['is-selected']]: isChecked,
1036
- [style['is-disabled']]: item.disabled
1099
+ className: classnames__default["default"](style$1['default-list-item'], 'select-tree-item', {
1100
+ [style$1['is-selected']]: isChecked,
1101
+ [style$1['is-disabled']]: item.disabled
1037
1102
  }),
1038
1103
  key: item[valueKey],
1039
1104
  onClick: () => {
@@ -1061,36 +1126,30 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
1061
1126
  flex: 1,
1062
1127
  className: 'select-tree-item-content'
1063
1128
  }, renderItemContent(contextProps)), single && /*#__PURE__*/React__default["default"].createElement("div", {
1064
- className: style['single-checked']
1129
+ className: style$1['single-checked']
1065
1130
  }, isChecked && /*#__PURE__*/React__default["default"].createElement(icons.CheckOutlined, null)));
1066
1131
  },
1067
1132
  renderTree: contextProps => {
1068
- const {
1069
- props,
1070
- isSelectedAll,
1071
- data
1072
- } = contextProps;
1073
- const {
1074
- renderItem,
1075
- valueKey,
1076
- labelKey,
1077
- childrenKey,
1078
- parentKey
1079
- } = props;
1080
- const {
1081
- treeData,
1082
- ids
1083
- } = parseTreeData(data, {
1084
- valueKey,
1085
- parentKey,
1086
- childrenKey
1087
- });
1133
+ const props = contextProps.props,
1134
+ isSelectedAll = contextProps.isSelectedAll,
1135
+ data = contextProps.data;
1136
+ const renderItem = props.renderItem,
1137
+ valueKey = props.valueKey,
1138
+ labelKey = props.labelKey,
1139
+ childrenKey = props.childrenKey,
1140
+ parentKey = props.parentKey;
1141
+ const _parseTreeData = parseTreeData(data, {
1142
+ valueKey,
1143
+ parentKey,
1144
+ childrenKey
1145
+ }),
1146
+ treeData = _parseTreeData.treeData;
1088
1147
  if (!(treeData && treeData.length > 0)) {
1089
1148
  return props.empty || /*#__PURE__*/React__default["default"].createElement(antd.Empty, null);
1090
1149
  }
1091
1150
  return /*#__PURE__*/React__default["default"].createElement(antd.Tree, {
1092
- className: classnames__default["default"](style['default-list'], {
1093
- [style['is-selected-all']]: isSelectedAll
1151
+ className: classnames__default["default"](style$1['default-list'], {
1152
+ [style$1['is-selected-all']]: isSelectedAll
1094
1153
  }),
1095
1154
  showIcon: true,
1096
1155
  selectable: false,
@@ -1115,26 +1174,22 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
1115
1174
  return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
1116
1175
  ref: ref
1117
1176
  }), targetProps => {
1118
- const {
1119
- props,
1120
- value,
1121
- onOpenChange
1122
- } = targetProps;
1123
- const {
1124
- footer,
1125
- isPopup,
1126
- valueKey,
1127
- single,
1128
- allowSelectedAll,
1129
- showSelectedTag,
1130
- api,
1131
- options,
1132
- renderTree,
1133
- selectedAllValue
1134
- } = props;
1177
+ const props = targetProps.props,
1178
+ value = targetProps.value,
1179
+ onOpenChange = targetProps.onOpenChange;
1180
+ const footer = props.footer,
1181
+ isPopup = props.isPopup,
1182
+ valueKey = props.valueKey,
1183
+ single = props.single,
1184
+ allowSelectedAll = props.allowSelectedAll,
1185
+ showSelectedTag = props.showSelectedTag,
1186
+ api = props.api,
1187
+ options = props.options,
1188
+ renderTree = props.renderTree,
1189
+ selectedAllValue = props.selectedAllValue;
1135
1190
  const components = {
1136
1191
  selectedAll: /*#__PURE__*/React__default["default"].createElement("div", {
1137
- className: classnames__default["default"](style['selected-all'], 'select-tree-selected-all', {
1192
+ className: classnames__default["default"](style$1['selected-all'], 'select-tree-selected-all', {
1138
1193
  'is-popup': isPopup
1139
1194
  })
1140
1195
  }, !single && allowSelectedAll && /*#__PURE__*/React__default["default"].createElement(SelectedAll, null)),
@@ -1143,21 +1198,17 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
1143
1198
  options
1144
1199
  },
1145
1200
  loader: _ref4 => {
1146
- let {
1147
- data
1148
- } = _ref4;
1201
+ let data = _ref4.data;
1149
1202
  return data.options;
1150
1203
  }
1151
1204
  } : api), {
1152
1205
  ref: fetchListRef,
1153
1206
  render: _ref5 => {
1154
- let {
1155
- data,
1156
- ...fetchProps
1157
- } = _ref5;
1207
+ let data = _ref5.data,
1208
+ fetchProps = _objectWithoutPropertiesLoose(_ref5, _excluded2);
1158
1209
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue, valueKey);
1159
1210
  return /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
1160
- className: classnames__default["default"](style['list'], 'select-tree-scroll-list', {
1211
+ className: classnames__default["default"](style$1['list'], 'select-tree-scroll-list', {
1161
1212
  'is-popup': isPopup
1162
1213
  })
1163
1214
  }, renderTree(Object.assign({}, fetchProps, targetProps, {
@@ -1167,12 +1218,12 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
1167
1218
  }
1168
1219
  })),
1169
1220
  selectedTag: showSelectedTag && /*#__PURE__*/React__default["default"].createElement("div", {
1170
- className: classnames__default["default"](style['selected-tag'], 'select-tree-selected-tag', {
1221
+ className: classnames__default["default"](style$1['selected-tag'], 'select-tree-selected-tag', {
1171
1222
  'is-popup': isPopup
1172
1223
  })
1173
1224
  }, /*#__PURE__*/React__default["default"].createElement(SelectedTagList, null)),
1174
1225
  footer: footer && /*#__PURE__*/React__default["default"].createElement("div", {
1175
- className: classnames__default["default"](style['footer'], 'select-list-footer')
1226
+ className: classnames__default["default"](style$1['footer'], 'select-list-footer')
1176
1227
  }, typeof footer === 'function' ? footer({
1177
1228
  reload: () => {
1178
1229
  fetchListRef.current && fetchListRef.current.reload();
@@ -1193,10 +1244,802 @@ const SelectTree = React.forwardRef((_ref2, ref) => {
1193
1244
  });
1194
1245
  });
1195
1246
 
1247
+ const createTreeUtils = mapping => {
1248
+ const mappingList = Array.from(mapping.values());
1249
+ const rootNodes = mappingList.filter(item => item.parentId === null);
1250
+ const delItem = (array, item) => {
1251
+ const index = array.indexOf(item);
1252
+ if (index > -1) {
1253
+ array.splice(index, 1);
1254
+ }
1255
+ };
1256
+
1257
+ /**
1258
+ * 通过一个nodeId获取所有父级和所有子级的第一个元素,组成一个从最顶级到最子级的数组
1259
+ * */
1260
+ const getSelectedQueue = id => {
1261
+ const currentNode = mapping.get(id);
1262
+ if (!currentNode) {
1263
+ return [];
1264
+ }
1265
+ const getFirstChild = target => {
1266
+ if (target.children && target.children.length > 0) {
1267
+ return getFirstChild(target.children.find(item => item.children && target.children.length > 0) || get__default["default"](target.children, '0'));
1268
+ }
1269
+ const hasChildrenItem = getAllChildren(target.parentId).find(item => item.children && item.children.length > 0);
1270
+ if (hasChildrenItem) {
1271
+ return getFirstChild(hasChildrenItem);
1272
+ }
1273
+ return target;
1274
+ };
1275
+ const getParentNodeIdList = (targetId, parents = []) => {
1276
+ const output = [targetId, ...parents];
1277
+ const node = mapping.get(targetId);
1278
+ if (!node || isNil__default["default"](node.parentId)) {
1279
+ return output;
1280
+ }
1281
+ return getParentNodeIdList(node.parentId, output);
1282
+ };
1283
+ const lastLevelNode = getFirstChild(currentNode);
1284
+ return getParentNodeIdList(get__default["default"](lastLevelNode, 'id'));
1285
+ };
1286
+
1287
+ /**
1288
+ * 通过一个nodeId获得该节点的所有子级后代的id数组
1289
+ * */
1290
+ const getAllChildren = id => {
1291
+ const output = [];
1292
+ const core = id => {
1293
+ const node = mapping.get(id);
1294
+ if (!node) {
1295
+ return;
1296
+ }
1297
+ if (Array.isArray(node.children) && node.children.length > 0) {
1298
+ output.push(...node.children);
1299
+ node.children.forEach(item => {
1300
+ core(item.id);
1301
+ });
1302
+ }
1303
+ };
1304
+ core(id);
1305
+ return output;
1306
+ };
1307
+
1308
+ /**
1309
+ * 从自身节点开始向父级查找callback返回为true的node,找到第一个返回结果
1310
+ * */
1311
+ const findInParents = (id, callback) => {
1312
+ const core = id => {
1313
+ const currentNode = mapping.get(id);
1314
+ if (!currentNode) {
1315
+ return null;
1316
+ }
1317
+ if (callback(currentNode)) {
1318
+ return currentNode;
1319
+ }
1320
+ if (!isNil__default["default"](currentNode.parentId)) {
1321
+ return core(currentNode.parentId);
1322
+ }
1323
+ return null;
1324
+ };
1325
+ return core(id);
1326
+ };
1327
+ const getSiblingNode = id => {
1328
+ const currentNode = mapping.get(id);
1329
+ if (!currentNode) {
1330
+ return [];
1331
+ }
1332
+ const parentId = currentNode.parentId;
1333
+ if (isNil__default["default"](parentId)) {
1334
+ return rootNodes;
1335
+ }
1336
+ const parentNode = mapping.get(parentId);
1337
+ return parentNode.children;
1338
+ };
1339
+ const setNodeChecked = (id, value = []) => {
1340
+ const newValue = value.slice(0);
1341
+ const core = id => {
1342
+ const node = mapping.get(id);
1343
+ if (!node) {
1344
+ return;
1345
+ }
1346
+ newValue.push(id);
1347
+ getAllChildren(id).forEach(node => {
1348
+ delItem(newValue, node.id);
1349
+ });
1350
+ const siblingNode = getSiblingNode(id);
1351
+ const siblingNodeIsAllChecked = siblingNode.every(node => newValue.indexOf(node.id) > -1);
1352
+ if (node.parentId && siblingNodeIsAllChecked) {
1353
+ siblingNode.forEach(node => {
1354
+ delItem(newValue, node.id);
1355
+ });
1356
+ core(node.parentId);
1357
+ }
1358
+ };
1359
+ core(id);
1360
+ return newValue;
1361
+ };
1362
+ const setNodeUnchecked = (id, value = []) => {
1363
+ const newValue = value.slice(0);
1364
+ const core = id => {
1365
+ const node = mapping.get(id);
1366
+ if (!node) {
1367
+ return;
1368
+ }
1369
+ if (newValue.indexOf(node.id) > -1) {
1370
+ delItem(newValue, node.id);
1371
+ return;
1372
+ }
1373
+ const siblingNode = getSiblingNode(id);
1374
+ if (node.parentId) {
1375
+ siblingNode.forEach(node => {
1376
+ if (id !== node.id) {
1377
+ newValue.push(node.id);
1378
+ }
1379
+ });
1380
+ core(node.parentId);
1381
+ }
1382
+ };
1383
+ core(id);
1384
+ return newValue;
1385
+ };
1386
+ const computedCheckboxStatus = (id, value = []) => {
1387
+ if (!!findInParents(id, node => {
1388
+ return value.indexOf(node.id) > -1;
1389
+ })) {
1390
+ return {
1391
+ checked: true,
1392
+ indeterminate: false
1393
+ };
1394
+ }
1395
+ const indeterminate = ((id, callback) => {
1396
+ const core = id => {
1397
+ const currentNode = mapping.get(id);
1398
+ if (!currentNode) {
1399
+ return null;
1400
+ }
1401
+ if (callback(currentNode)) {
1402
+ return currentNode;
1403
+ }
1404
+ if (Array.isArray(currentNode.children) && currentNode.children.length > 0) {
1405
+ return currentNode.children.find(item => !!core(item.id));
1406
+ }
1407
+ };
1408
+ return !!core(id);
1409
+ })(id, node => value.indexOf(node.id) > -1);
1410
+ if (indeterminate) {
1411
+ return {
1412
+ checked: false,
1413
+ indeterminate: true
1414
+ };
1415
+ }
1416
+ return {
1417
+ checked: false,
1418
+ indeterminate: false
1419
+ };
1420
+ };
1421
+ const transformToTreeData = () => {
1422
+ const core = nodeList => {
1423
+ if (Array.isArray(nodeList) && nodeList.length > 0) {
1424
+ return nodeList.map(node => {
1425
+ const children = mappingList.filter(item => item.parentId === node.id);
1426
+ return Object.assign({}, node, {
1427
+ children: core(children)
1428
+ });
1429
+ });
1430
+ }
1431
+ return null;
1432
+ };
1433
+ return core(rootNodes);
1434
+ };
1435
+ const treeData = transformToTreeData();
1436
+ return {
1437
+ mapping,
1438
+ getSelectedQueue,
1439
+ getAllChildren,
1440
+ computedCheckboxStatus,
1441
+ getSiblingNode,
1442
+ findInParents,
1443
+ setNodeChecked,
1444
+ setNodeUnchecked,
1445
+ treeData,
1446
+ treeMapping: new Map((treeData || []).map(item => [item.id, item]))
1447
+ };
1448
+ };
1449
+
1450
+ var style = {"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","list":"kne-super-select_iUhv7","is-selected":"kne-super-select_tx4-l","custom-menu":"kne-super-select_OerpL","selected":"kne-super-select_OUkpN"};
1451
+
1452
+ const CustomMenu = ({
1453
+ className,
1454
+ selectedKeys,
1455
+ items,
1456
+ onSelect
1457
+ }) => {
1458
+ const handleItemClick = (key, e) => {
1459
+ // 只阻止事件冒泡,不阻止默认行为
1460
+ e.stopPropagation();
1461
+ onSelect?.({
1462
+ key,
1463
+ domEvent: e
1464
+ });
1465
+ };
1466
+ return /*#__PURE__*/React__default["default"].createElement(antd.List, {
1467
+ className: classnames__default["default"](style['custom-menu'], className),
1468
+ dataSource: items,
1469
+ renderItem: item => {
1470
+ const isSelected = selectedKeys?.includes(item.key);
1471
+ return /*#__PURE__*/React__default["default"].createElement(antd.List.Item, {
1472
+ className: classnames__default["default"](style['custom-menu-item'], {
1473
+ [style['selected']]: isSelected
1474
+ }),
1475
+ onClick: e => handleItemClick(item.key, e)
1476
+ }, item.label);
1477
+ }
1478
+ });
1479
+ };
1480
+
1481
+ const _excluded = ["options", "value", "onChange", "defaultValue", "maxLength", "single", "onlyAllowLastLevel", "openLoadData", "onLoadMore", "parentIdKey", "menuItemWidth", "isPopup", "searchPlaceholder", "onSearch", "valueKey", "labelKey", "placeholder", "disabled", "size", "overlayWidth"];
1482
+ const numberToPx = val => {
1483
+ return typeof val === 'number' ? val + "px" : val;
1484
+ };
1485
+
1486
+ // 级联选择内容组件
1487
+ const CascaderInner = _ref => {
1488
+ let options = _ref.options,
1489
+ value = _ref.value,
1490
+ setValue = _ref.setValue,
1491
+ maxLength = _ref.maxLength,
1492
+ single = _ref.single,
1493
+ onlyAllowLastLevel = _ref.onlyAllowLastLevel,
1494
+ openLoadData = _ref.openLoadData,
1495
+ onLoadMore = _ref.onLoadMore,
1496
+ parentIdKey = _ref.parentIdKey,
1497
+ menuItemWidth = _ref.menuItemWidth,
1498
+ isPopup = _ref.isPopup,
1499
+ searchPlaceholder = _ref.searchPlaceholder,
1500
+ onSearch = _ref.onSearch,
1501
+ valueKey = _ref.valueKey,
1502
+ labelKey = _ref.labelKey,
1503
+ onOpenChange = _ref.onOpenChange,
1504
+ open = _ref.open;
1505
+ const _App$useApp = antd.App.useApp(),
1506
+ message = _App$useApp.message;
1507
+ const _useState = React.useState(''),
1508
+ searchText = _useState[0],
1509
+ setSearchText = _useState[1];
1510
+ const _useState2 = React.useState(false),
1511
+ loading = _useState2[0],
1512
+ setLoading = _useState2[1];
1513
+
1514
+ // 构建 mapping
1515
+ const mapping = React.useMemo(() => {
1516
+ const map = new Map();
1517
+ const processData = function (items, parentId) {
1518
+ if (parentId === void 0) {
1519
+ parentId = null;
1520
+ }
1521
+ items.forEach(item => {
1522
+ const node = _extends({}, item, {
1523
+ id: item[valueKey],
1524
+ label: item[labelKey],
1525
+ parentId
1526
+ });
1527
+ if (item.children && item.children.length > 0) {
1528
+ node.children = item.children.map(child => _extends({}, child, {
1529
+ id: child[valueKey],
1530
+ label: child[labelKey],
1531
+ parentId: node.id
1532
+ }));
1533
+ processData(item.children, node.id);
1534
+ }
1535
+ map.set(node.id, node);
1536
+ });
1537
+ };
1538
+ processData(options);
1539
+ return map;
1540
+ }, [options, valueKey, labelKey]);
1541
+
1542
+ // 创建树工具
1543
+ const treeUtils = React.useMemo(() => {
1544
+ return createTreeUtils(mapping);
1545
+ }, [mapping]);
1546
+
1547
+ // 当前选中的列
1548
+ const _useState3 = React.useState(() => {
1549
+ const initValue = value.find(item => {
1550
+ const id = typeof item === 'object' ? item[valueKey] : item;
1551
+ return !!mapping.get(id);
1552
+ });
1553
+ if (initValue) {
1554
+ const id = typeof initValue === 'object' ? initValue[valueKey] : initValue;
1555
+ return treeUtils.getSelectedQueue(id);
1556
+ }
1557
+
1558
+ // 默认选中第一列
1559
+ const firstNode = Array.from(mapping.values()).find(item => isNil__default["default"](item.parentId));
1560
+ if (firstNode) {
1561
+ return treeUtils.getSelectedQueue(firstNode.id);
1562
+ }
1563
+ return [];
1564
+ }),
1565
+ selectedIds = _useState3[0],
1566
+ setSelectedIds = _useState3[1];
1567
+
1568
+ // 当 Modal 打开时,根据 value 重新初始化 selectedIds
1569
+ const prevOpenRef = React.useRef(open);
1570
+ React.useEffect(() => {
1571
+ // 只在非 popup 模式下且 Modal 从关闭变为打开时处理
1572
+ if (!isPopup && open && !prevOpenRef.current) {
1573
+ const initValue = value.find(item => {
1574
+ const id = typeof item === 'object' ? item[valueKey] : item;
1575
+ return !!mapping.get(id);
1576
+ });
1577
+ if (initValue) {
1578
+ const id = typeof initValue === 'object' ? initValue[valueKey] : initValue;
1579
+ setSelectedIds(treeUtils.getSelectedQueue(id));
1580
+ } else {
1581
+ // 默认选中第一列
1582
+ const firstNode = Array.from(mapping.values()).find(item => isNil__default["default"](item.parentId));
1583
+ if (firstNode) {
1584
+ setSelectedIds(treeUtils.getSelectedQueue(firstNode.id));
1585
+ }
1586
+ }
1587
+ }
1588
+ prevOpenRef.current = open;
1589
+ }, [open, value, mapping, treeUtils, valueKey, isPopup]);
1590
+
1591
+ // 懒加载支持
1592
+ const loadMorePropsRef = React.useRef({});
1593
+ loadMorePropsRef.current = {
1594
+ openLoadData,
1595
+ onLoadMore,
1596
+ parentIdKey,
1597
+ treeUtils
1598
+ };
1599
+ React.useEffect(() => {
1600
+ if (!openLoadData || !onLoadMore) {
1601
+ return;
1602
+ }
1603
+ const lastNode = mapping.get(last__default["default"](selectedIds));
1604
+ if (!lastNode) {
1605
+ return;
1606
+ }
1607
+
1608
+ // 检查是否需要加载子节点
1609
+ if (lastNode.hasOwnProperty('children') && lastNode.children !== undefined) {
1610
+ return;
1611
+ }
1612
+ setLoading(true);
1613
+ onLoadMore({
1614
+ [parentIdKey]: lastNode.id
1615
+ }).then(() => {
1616
+ setLoading(false);
1617
+ }).catch(() => {
1618
+ setLoading(false);
1619
+ });
1620
+ }, [selectedIds, mapping, openLoadData, onLoadMore, parentIdKey]);
1621
+
1622
+ // 检查是否为非叶子节点
1623
+ const isNotLastNode = React.useCallback(id => {
1624
+ const node = mapping.get(id);
1625
+ if (!node) return false;
1626
+ if (openLoadData && !node.hasOwnProperty('children')) {
1627
+ return true;
1628
+ }
1629
+ return node.children && node.children.length > 0;
1630
+ }, [mapping, openLoadData]);
1631
+
1632
+ // 选择处理
1633
+ const onCheckedChange = React.useCallback((checked, id) => {
1634
+ const newValue = (() => {
1635
+ if (onlyAllowLastLevel && checked) {
1636
+ const currentIds = value.map(item => typeof item === 'object' ? item[valueKey] : item);
1637
+ if (currentIds.includes(id)) return currentIds;
1638
+ return [...currentIds, id];
1639
+ }
1640
+ if (onlyAllowLastLevel) {
1641
+ const currentIds = value.map(item => typeof item === 'object' ? item[valueKey] : item);
1642
+ return currentIds.filter(itemId => itemId !== id);
1643
+ }
1644
+ const currentIds = value.map(item => typeof item === 'object' ? item[valueKey] : item);
1645
+ return checked ? treeUtils.setNodeChecked(id, currentIds) : treeUtils.setNodeUnchecked(id, currentIds);
1646
+ })();
1647
+ if (newValue.length > maxLength) {
1648
+ message.error("\u6700\u591A\u53EA\u80FD\u9009\u62E9 " + maxLength + " \u9879");
1649
+ return;
1650
+ }
1651
+
1652
+ // 转换回完整对象
1653
+ const newValues = newValue.map(id => {
1654
+ const node = mapping.get(id);
1655
+ // 返回完整的节点数据,保留所有原始字段
1656
+ return node ? _extends({}, node, {
1657
+ [valueKey]: node.id,
1658
+ [labelKey]: node.label
1659
+ }) : null;
1660
+ }).filter(Boolean);
1661
+ const finalValue = single && newValues.length > 0 ? [last__default["default"](newValues)] : newValues;
1662
+ setValue(finalValue);
1663
+
1664
+ // 单选且是叶子节点且在 popup 模式下,自动关闭下拉框
1665
+ if (single && newValues.length > 0 && !isNotLastNode(id) && isPopup && onOpenChange) {
1666
+ onOpenChange(false);
1667
+ }
1668
+ }, [value, maxLength, single, onlyAllowLastLevel, treeUtils, mapping, message, valueKey, labelKey, isPopup, onOpenChange, isNotLastNode]);
1669
+
1670
+ // 搜索结果
1671
+ const searchResults = React.useMemo(() => {
1672
+ if (!searchText || !onSearch) return null;
1673
+ const keyword = searchText.toLowerCase();
1674
+ return Array.from(mapping.values()).filter(item => {
1675
+ return item.label && item.label.toLowerCase().includes(keyword);
1676
+ });
1677
+ }, [searchText, mapping, onSearch]);
1678
+
1679
+ // 搜索选择
1680
+ const onSearchSelect = item => {
1681
+ const currentIds = value.map(v => typeof v === 'object' ? v[valueKey] : v);
1682
+ const checked = currentIds.includes(item.id);
1683
+ onCheckedChange(!checked, item.id);
1684
+ if (!checked) {
1685
+ setSelectedIds(treeUtils.getSelectedQueue(item.id));
1686
+ }
1687
+ setSearchText('');
1688
+ };
1689
+
1690
+ // 渲染搜索内容
1691
+ if (searchText && searchResults) {
1692
+ const currentIds = value.map(v => typeof v === 'object' ? v[valueKey] : v);
1693
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1694
+ className: classnames__default["default"](style['content'], {
1695
+ [style['is-popup']]: isPopup
1696
+ })
1697
+ }, /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
1698
+ className: classnames__default["default"](style['search-input'], {
1699
+ 'is-popup': isPopup
1700
+ }),
1701
+ placeholder: searchPlaceholder,
1702
+ value: searchText,
1703
+ onSearch: setSearchText,
1704
+ simple: isPopup,
1705
+ showSearchButton: !isPopup
1706
+ }), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
1707
+ className: style['scroll-plus-box']
1708
+ }, searchResults.length === 0 ? /*#__PURE__*/React__default["default"].createElement(antd.Empty, {
1709
+ description: "\u6682\u65E0\u6570\u636E"
1710
+ }) : /*#__PURE__*/React__default["default"].createElement(antd.List, {
1711
+ className: style['list'],
1712
+ size: "small",
1713
+ dataSource: searchResults,
1714
+ rowKey: "id",
1715
+ renderItem: item => {
1716
+ const checked = currentIds.includes(item.id);
1717
+ return /*#__PURE__*/React__default["default"].createElement(antd.List.Item, {
1718
+ className: classnames__default["default"]({
1719
+ [style['is-selected']]: checked
1720
+ }),
1721
+ onClick: () => onSearchSelect(item)
1722
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, item.label), checked && /*#__PURE__*/React__default["default"].createElement("span", {
1723
+ style: {
1724
+ marginLeft: 8,
1725
+ color: '#1677ff'
1726
+ }
1727
+ }, "\u2713"));
1728
+ }
1729
+ })));
1730
+ }
1731
+
1732
+ // 渲染级联列
1733
+ const currentIds = value.map(v => typeof v === 'object' ? v[valueKey] : v);
1734
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1735
+ className: classnames__default["default"](style['content'], {
1736
+ [style['is-popup']]: isPopup,
1737
+ [style['has-search']]: !!onSearch
1738
+ }),
1739
+ style: {
1740
+ '--menu-item-width': numberToPx(menuItemWidth)
1741
+ }
1742
+ }, onSearch && /*#__PURE__*/React__default["default"].createElement(SearchInput__default["default"], {
1743
+ className: classnames__default["default"](style['search-input'], {
1744
+ 'is-popup': isPopup
1745
+ }),
1746
+ placeholder: searchPlaceholder,
1747
+ value: searchText,
1748
+ onSearch: setSearchText,
1749
+ simple: isPopup,
1750
+ showSearchButton: !isPopup
1751
+ }), /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
1752
+ className: style['scroller'],
1753
+ options: {
1754
+ autoHide: false
1755
+ }
1756
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
1757
+ className: style['columns']
1758
+ }, selectedIds.map((selectedId, index) => {
1759
+ const selectNode = mapping.get(selectedId);
1760
+ const siblingNodes = treeUtils.getSiblingNode(selectedId);
1761
+ const isLastLevel = !isNotLastNode(selectNode == null ? void 0 : selectNode.id) && index > 0;
1762
+ return /*#__PURE__*/React__default["default"].createElement(SimpleBar__default["default"], {
1763
+ key: selectedId || index,
1764
+ className: classnames__default["default"](style['content-item'], {
1765
+ [style['last-level-area']]: isLastLevel
1766
+ })
1767
+ }, isLastLevel ? /*#__PURE__*/React__default["default"].createElement(antd.Space, {
1768
+ wrap: true,
1769
+ style: {
1770
+ padding: 12
1771
+ },
1772
+ className: classnames__default["default"]({
1773
+ [style['single-mode']]: single
1774
+ })
1775
+ }, siblingNodes.map(node => {
1776
+ const _treeUtils$computedCh = treeUtils.computedCheckboxStatus(node.id, currentIds),
1777
+ checked = _treeUtils$computedCh.checked,
1778
+ indeterminate = _treeUtils$computedCh.indeterminate;
1779
+ return /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
1780
+ key: node.id,
1781
+ checked: checked,
1782
+ indeterminate: indeterminate,
1783
+ onChange: e => onCheckedChange(e.target.checked, node.id)
1784
+ }, node.label);
1785
+ })) : /*#__PURE__*/React__default["default"].createElement(CustomMenu, {
1786
+ className: style['menu'],
1787
+ selectedKeys: index === selectedIds.length - 1 ? [] : selectedIds,
1788
+ onSelect: _ref2 => {
1789
+ let key = _ref2.key;
1790
+ const node = mapping.get(key);
1791
+ if (!node) return;
1792
+ if (isNotLastNode(node.id)) {
1793
+ setSelectedIds(treeUtils.getSelectedQueue(node.id));
1794
+ } else {
1795
+ const _treeUtils$computedCh2 = treeUtils.computedCheckboxStatus(node.id, currentIds),
1796
+ checked = _treeUtils$computedCh2.checked;
1797
+ onCheckedChange(!checked, node.id);
1798
+ }
1799
+ },
1800
+ items: siblingNodes.map(node => {
1801
+ const _treeUtils$computedCh3 = treeUtils.computedCheckboxStatus(node.id, currentIds),
1802
+ checked = _treeUtils$computedCh3.checked,
1803
+ indeterminate = _treeUtils$computedCh3.indeterminate;
1804
+ const hasChildren = isNotLastNode(node.id);
1805
+
1806
+ // 计算子级选中数量
1807
+ const childrenSelectedCount = hasChildren ? treeUtils.getAllChildren(node.id).filter(child => currentIds.includes(child.id)).length : 0;
1808
+ return {
1809
+ key: node.id,
1810
+ label: /*#__PURE__*/React__default["default"].createElement(antd.Space, {
1811
+ className: classnames__default["default"](style['menu-item'], {
1812
+ [style['checkbox-hidden']]: onlyAllowLastLevel && hasChildren,
1813
+ [style['single-mode']]: single
1814
+ })
1815
+ }, (!onlyAllowLastLevel || !hasChildren) && /*#__PURE__*/React__default["default"].createElement(antd.Checkbox, {
1816
+ checked: checked,
1817
+ indeterminate: indeterminate,
1818
+ onClick: e => e.stopPropagation(),
1819
+ onChange: e => {
1820
+ e.stopPropagation();
1821
+ onCheckedChange(e.target.checked, node.id);
1822
+ }
1823
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
1824
+ className: style['menu-label']
1825
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
1826
+ className: style['menu-label-text']
1827
+ }, node.label), hasChildren && childrenSelectedCount > 0 && /*#__PURE__*/React__default["default"].createElement(antd.Badge, {
1828
+ count: childrenSelectedCount,
1829
+ size: "small"
1830
+ })), hasChildren ? /*#__PURE__*/React__default["default"].createElement(icons.RightOutlined, {
1831
+ className: style['menu-item-icon']
1832
+ }) : /*#__PURE__*/React__default["default"].createElement("span", {
1833
+ className: style['menu-item-placeholder']
1834
+ }))
1835
+ };
1836
+ })
1837
+ }));
1838
+ }), loading && /*#__PURE__*/React__default["default"].createElement("div", {
1839
+ className: style['loading']
1840
+ }, /*#__PURE__*/React__default["default"].createElement(antd.Spin, {
1841
+ size: "small"
1842
+ })))));
1843
+ };
1844
+
1845
+ // 主组件
1846
+ const SelectCascader = _ref3 => {
1847
+ let _ref3$options = _ref3.options,
1848
+ options = _ref3$options === void 0 ? [] : _ref3$options,
1849
+ value = _ref3.value,
1850
+ onChange = _ref3.onChange,
1851
+ defaultValue = _ref3.defaultValue,
1852
+ _ref3$maxLength = _ref3.maxLength,
1853
+ maxLength = _ref3$maxLength === void 0 ? Number.MAX_VALUE : _ref3$maxLength,
1854
+ _ref3$single = _ref3.single,
1855
+ single = _ref3$single === void 0 ? false : _ref3$single,
1856
+ _ref3$onlyAllowLastLe = _ref3.onlyAllowLastLevel,
1857
+ onlyAllowLastLevel = _ref3$onlyAllowLastLe === void 0 ? false : _ref3$onlyAllowLastLe,
1858
+ _ref3$openLoadData = _ref3.openLoadData,
1859
+ openLoadData = _ref3$openLoadData === void 0 ? false : _ref3$openLoadData,
1860
+ onLoadMore = _ref3.onLoadMore,
1861
+ _ref3$parentIdKey = _ref3.parentIdKey,
1862
+ parentIdKey = _ref3$parentIdKey === void 0 ? 'id' : _ref3$parentIdKey,
1863
+ _ref3$menuItemWidth = _ref3.menuItemWidth,
1864
+ menuItemWidth = _ref3$menuItemWidth === void 0 ? 180 : _ref3$menuItemWidth,
1865
+ _ref3$isPopup = _ref3.isPopup,
1866
+ isPopup = _ref3$isPopup === void 0 ? true : _ref3$isPopup,
1867
+ searchPlaceholder = _ref3.searchPlaceholder,
1868
+ onSearch = _ref3.onSearch,
1869
+ _ref3$valueKey = _ref3.valueKey,
1870
+ valueKey = _ref3$valueKey === void 0 ? 'id' : _ref3$valueKey,
1871
+ _ref3$labelKey = _ref3.labelKey,
1872
+ labelKey = _ref3$labelKey === void 0 ? 'label' : _ref3$labelKey,
1873
+ _ref3$placeholder = _ref3.placeholder,
1874
+ placeholder = _ref3$placeholder === void 0 ? '请选择' : _ref3$placeholder,
1875
+ _ref3$disabled = _ref3.disabled,
1876
+ disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
1877
+ _ref3$size = _ref3.size,
1878
+ size = _ref3$size === void 0 ? 'default' : _ref3$size,
1879
+ overlayWidth = _ref3.overlayWidth,
1880
+ props = _objectWithoutPropertiesLoose(_ref3, _excluded);
1881
+ // 内部始终使用数组格式处理
1882
+ // SelectInput 会处理 single 模式的 value 和 onChange 转换
1883
+ const _useState4 = React.useState(Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : []),
1884
+ innerValue = _useState4[0],
1885
+ setInnerValue = _useState4[1];
1886
+
1887
+ // currentValue 用于内部处理,始终是数组
1888
+ const currentValue = React.useMemo(() => {
1889
+ if (value !== undefined) {
1890
+ // 外部传入的 value 可能是对象(single)或数组(多选)
1891
+ return Array.isArray(value) ? value : value ? [value] : [];
1892
+ }
1893
+ return innerValue;
1894
+ }, [value, innerValue]);
1895
+ const setValue = React.useCallback(newValue => {
1896
+ // SelectInput 在 single 模式下会传单个对象或 null/undefined,需要转换为数组
1897
+ const normalizedValue = (() => {
1898
+ if (single) {
1899
+ // 单选模式:可能是单个对象、null、undefined 或数组
1900
+ if (Array.isArray(newValue)) {
1901
+ return newValue;
1902
+ }
1903
+ return isEmpty.isNotEmpty(newValue) ? [newValue] : [];
1904
+ }
1905
+ // 多选模式:确保是数组
1906
+ return Array.isArray(newValue) ? newValue : [];
1907
+ })();
1908
+ if (value === undefined) {
1909
+ setInnerValue(normalizedValue);
1910
+ }
1911
+
1912
+ // 根据单选/多选模式转换输出格式
1913
+ if (single) {
1914
+ // 单选:返回单个对象或 null
1915
+ onChange == null || onChange(normalizedValue.length > 0 ? normalizedValue[0] : null);
1916
+ } else {
1917
+ // 多选:返回数组
1918
+ onChange == null || onChange(normalizedValue);
1919
+ }
1920
+ }, [value, onChange, single]);
1921
+
1922
+ // 传递给 SelectInput 的值:根据 single 参数决定格式
1923
+ const selectInputValue = React.useMemo(() => {
1924
+ if (single) {
1925
+ // single 模式:传单个对象或 undefined
1926
+ return currentValue.length > 0 ? currentValue[0] : undefined;
1927
+ }
1928
+ // 多选模式:传数组
1929
+ return currentValue;
1930
+ }, [currentValue, single]);
1931
+
1932
+ // 计算 label 显示
1933
+ React.useMemo(() => {
1934
+ // currentValue 已经是数组格式了
1935
+ return currentValue.map(item => {
1936
+ // 如果已经是对象,确保有标准化的字段
1937
+ if (typeof item === 'object') {
1938
+ // 优先使用 item[labelKey],然后是 item.label,最后是 item.name
1939
+ const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
1940
+ return _extends({}, item, {
1941
+ [valueKey]: item[valueKey] || item.id,
1942
+ [labelKey]: label
1943
+ });
1944
+ }
1945
+ // 如果是值,从 options 中查找
1946
+ const findLabel = items => {
1947
+ for (const node of items) {
1948
+ if (node[valueKey] === item) {
1949
+ return {
1950
+ [valueKey]: item,
1951
+ [labelKey]: node[labelKey] || node.name || String(item)
1952
+ };
1953
+ }
1954
+ if (node.children) {
1955
+ const found = findLabel(node.children);
1956
+ if (found) return found;
1957
+ }
1958
+ }
1959
+ return null;
1960
+ };
1961
+ return findLabel(options) || {
1962
+ [valueKey]: item,
1963
+ [labelKey]: String(item)
1964
+ };
1965
+ }).filter(Boolean);
1966
+ }, [currentValue, options, valueKey, labelKey]);
1967
+ return /*#__PURE__*/React__default["default"].createElement(SelectInput, _extends({}, props, {
1968
+ value: selectInputValue,
1969
+ onChange: setValue,
1970
+ single: single,
1971
+ maxLength: maxLength,
1972
+ isPopup: isPopup,
1973
+ placeholder: placeholder,
1974
+ disabled: disabled,
1975
+ size: size,
1976
+ valueKey: valueKey,
1977
+ labelKey: labelKey,
1978
+ overlayWidth: overlayWidth || menuItemWidth * 2
1979
+ }), contextProps => {
1980
+ // 使用 contextProps 中的 value 和 setValue,支持 Modal 模式下的内部状态管理
1981
+ const contextValue = contextProps.value;
1982
+ const contextSetValue = contextProps.setValue;
1983
+
1984
+ // 计算当前显示的 value
1985
+ const currentDisplayValue = contextValue.map(item => {
1986
+ // 如果已经是对象,确保有标准化的字段
1987
+ if (typeof item === 'object') {
1988
+ const label = item[labelKey] || item.label || item.name || String(item[valueKey] || '');
1989
+ return _extends({}, item, {
1990
+ [valueKey]: item[valueKey] || item.id,
1991
+ [labelKey]: label
1992
+ });
1993
+ }
1994
+ // 如果是值,从 options 中查找
1995
+ const findLabel = items => {
1996
+ for (const node of items) {
1997
+ if (node[valueKey] === item) {
1998
+ return {
1999
+ [valueKey]: item,
2000
+ [labelKey]: node[labelKey] || node.name || String(item)
2001
+ };
2002
+ }
2003
+ if (node.children) {
2004
+ const found = findLabel(node.children);
2005
+ if (found) return found;
2006
+ }
2007
+ }
2008
+ return null;
2009
+ };
2010
+ return findLabel(options) || {
2011
+ [valueKey]: item,
2012
+ [labelKey]: String(item)
2013
+ };
2014
+ }).filter(Boolean);
2015
+ return /*#__PURE__*/React__default["default"].createElement(CascaderInner, {
2016
+ options: options,
2017
+ value: currentDisplayValue,
2018
+ setValue: contextSetValue,
2019
+ maxLength: maxLength,
2020
+ single: single,
2021
+ onlyAllowLastLevel: onlyAllowLastLevel,
2022
+ openLoadData: openLoadData,
2023
+ onLoadMore: onLoadMore,
2024
+ parentIdKey: parentIdKey,
2025
+ menuItemWidth: menuItemWidth,
2026
+ isPopup: isPopup,
2027
+ searchPlaceholder: searchPlaceholder,
2028
+ onSearch: onSearch,
2029
+ valueKey: valueKey,
2030
+ labelKey: labelKey,
2031
+ onOpenChange: contextProps.onOpenChange,
2032
+ open: contextProps.open
2033
+ });
2034
+ });
2035
+ };
2036
+
2037
+ exports.SelectCascader = SelectCascader;
1196
2038
  exports.SelectInput = SelectInput;
1197
2039
  exports.SelectTableList = SelectTableList;
1198
2040
  exports.SelectTree = SelectTree;
1199
2041
  exports.SelectedAll = SelectedAll;
1200
2042
  exports.SelectedTagList = SelectedTagList;
2043
+ exports.createTreeUtils = createTreeUtils;
1201
2044
  exports["default"] = SelectList;
1202
2045
  //# sourceMappingURL=index.js.map