@kdcloudjs/kdesign 1.7.63 → 1.7.65

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.
@@ -2,9 +2,9 @@ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
3
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
4
4
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
5
- import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
6
5
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
7
6
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
7
+ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
8
8
  import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
9
9
  import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
10
10
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
@@ -17,6 +17,7 @@ import { getCompProps } from '../_utils';
17
17
  import { Input, Icon, Tabs, Empty, Spin, Checkbox } from '../index';
18
18
  import usePopper from '../_utils/usePopper';
19
19
  var InternalBaseData = function InternalBaseData(props, ref) {
20
+ var _context2;
20
21
  var _useContext = useContext(ConfigContext),
21
22
  getPrefixCls = _useContext.getPrefixCls,
22
23
  prefixCls = _useContext.prefixCls,
@@ -102,8 +103,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
102
103
  }, [seletedOptions]);
103
104
  // 记录每个选项的开始与结束下标
104
105
  var setValIndxPosition = useCallback(function () {
106
+ var _context;
107
+ var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
105
108
  var arr = [];
106
- inputValue.split(delimiter).reduce(function (pre, next) {
109
+ _filterInstanceProperty(_context = (str || inputValue).split(delimiter)).call(_context, function (item) {
110
+ return !!item;
111
+ }).reduce(function (pre, next) {
107
112
  arr.push({
108
113
  start: pre,
109
114
  end: pre + next.length
@@ -112,6 +117,13 @@ var InternalBaseData = function InternalBaseData(props, ref) {
112
117
  }, 0);
113
118
  return arr;
114
119
  }, [delimiter, inputValue]);
120
+ var initInputValue = _filterInstanceProperty(_context2 = searchInfo.current.editOptions || []).call(_context2, function (item) {
121
+ return !!item;
122
+ }).reduce(function (pre, next, index, arr) {
123
+ var _context3, _context4;
124
+ return _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "".concat(pre)).call(_context4, next[optionLabelProp])).call(_context3, index !== arr.length - 1 ? delimiter : '');
125
+ }, '');
126
+ var initIndexPos = setValIndxPosition(initInputValue);
115
127
  useEffect(function () {
116
128
  var list = setValIndxPosition();
117
129
  setIndxPosList(list);
@@ -130,18 +142,17 @@ var InternalBaseData = function InternalBaseData(props, ref) {
130
142
  searchInfo.current.editOptions = _toConsumableArray(seletedItems);
131
143
  }, [value, isMultiple]);
132
144
  useEffect(function () {
133
- var _a;
145
+ var _a, _b;
134
146
  if (!searchInfo.current.previousEditValue) return;
135
147
  var posList = setValIndxPosition();
136
148
  var preValueArr = getStrToArr(searchInfo.current.previousEditValue, delimiter);
137
149
  var valueArr = getStrToArr(inputValue, delimiter);
138
- var selectionStart = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.selectionStart) || 0;
150
+ var selectionStart = ((_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.selectionStart) || 0;
139
151
  var index = findSelectionIndex(selectionStart, posList);
140
152
  searchInfo.current.searchIndex = index;
141
153
  // 新增一个
142
154
  var list = _toConsumableArray(searchInfo.current.editOptions || []);
143
155
  if (valueArr.length - preValueArr.length === 1) {
144
- searchInfo.current.deleteEndIndx = index;
145
156
  _spliceInstanceProperty(list).call(list, index, 0, null);
146
157
  }
147
158
  if (valueArr.length < preValueArr.length) {
@@ -158,22 +169,35 @@ var InternalBaseData = function InternalBaseData(props, ref) {
158
169
  end = _findDeleteInterval.end;
159
170
  list === null || list === void 0 ? void 0 : _spliceInstanceProperty(list).call(list, start, end - start + 1);
160
171
  }
172
+ // 判断每次单个按del键时删除了分隔符后下一次触发
173
+ if (searchInfo.current.deleteEndIndx > 0 && selectionStart !== searchInfo.current.deleteEndIndx) {
174
+ var _findDeleteInterval2 = findDeleteInterval(selectionStart, searchInfo.current.deleteEndIndx, initIndexPos),
175
+ _start = _findDeleteInterval2.start,
176
+ _end = _findDeleteInterval2.end;
177
+ // 单个删除时找到合理的下标触发
178
+ if (_start !== null && _end !== null && _start <= _end) {
179
+ list === null || list === void 0 ? void 0 : _spliceInstanceProperty(list).call(list, _start, _end - _start + 1);
180
+ searchInfo.current.deleteEndIndx = 0;
181
+ }
182
+ }
161
183
  searchInfo.current.editOptions = list;
162
184
  searchInfo.current.previousEditValue = inputValue;
163
185
  // eslint-disable-next-line react-hooks/exhaustive-deps
164
186
  }, [delimiter, inputValue, isMultiple, setValIndxPosition]);
165
187
  var getStrToArr = function getStrToArr() {
166
- var _context;
188
+ var _context5;
167
189
  var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
168
190
  var delimiter = arguments.length > 1 ? arguments[1] : undefined;
169
- return _filterInstanceProperty(_context = str.split(delimiter)).call(_context, function (item) {
191
+ return _filterInstanceProperty(_context5 = str.split(delimiter)).call(_context5, function (item) {
170
192
  return item;
171
193
  });
172
194
  };
173
195
  // 当选中项文字超出输入框时,显示共多少项
174
196
  useLayoutEffect(function () {
175
- if (!inputRef.current) return;
176
- if (inputRef.current.scrollWidth - inputRef.current.offsetWidth > 0) {
197
+ var _a;
198
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
199
+ if (!inputDom) return;
200
+ if (inputDom.scrollWidth - inputDom.offsetWidth > 0) {
177
201
  setShowTotal(true);
178
202
  } else {
179
203
  setShowTotal(false);
@@ -181,32 +205,49 @@ var InternalBaseData = function InternalBaseData(props, ref) {
181
205
  }, [inputRef, inputValue]);
182
206
  // 通过选中项显示input文字, optionLabelProp为回填到选择框的属性
183
207
  var setValueBySeleted = useCallback(function () {
184
- var _context4;
208
+ var _context8;
185
209
  var defaultInputValue = seletedOptions.reduce(function (pre, next, index, arr) {
186
- var _context2, _context3;
187
- return _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(pre)).call(_context3, next[optionLabelProp])).call(_context2, index !== arr.length - 1 ? delimiter : '');
210
+ var _context6, _context7;
211
+ return _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "".concat(pre)).call(_context7, next[optionLabelProp])).call(_context6, index !== arr.length - 1 ? delimiter : '');
188
212
  }, '');
189
213
  searchInfo.current.previousInputValue = defaultInputValue;
190
214
  setInputValue(defaultInputValue);
191
- searchInfo.current.previousEditValue = _concatInstanceProperty(_context4 = "".concat(defaultInputValue)).call(_context4, delimiter);
215
+ searchInfo.current.previousEditValue = _concatInstanceProperty(_context8 = "".concat(defaultInputValue)).call(_context8, delimiter);
192
216
  }, [delimiter, optionLabelProp, seletedOptions]);
193
217
  useEffect(function () {
194
218
  setValueBySeleted();
195
219
  }, [setValueBySeleted]);
220
+ var findDeletedChar = function findDeletedChar(prev, current) {
221
+ if (prev.length > current.length) {
222
+ for (var i = 0; i < prev.length; i++) {
223
+ if (prev[i] !== current[i]) {
224
+ return prev[i];
225
+ }
226
+ }
227
+ return prev[prev.length - 1];
228
+ }
229
+ return null;
230
+ };
196
231
  var changeInputText = function changeInputText(e) {
232
+ var _a;
197
233
  setOptionShow(true);
198
234
  var textValue = e.target.value;
199
235
  var val = textValue;
200
- if (isMultiple && inputRef.current && textValue && textValue.length > inputValue.length) {
201
- var selectionStart = inputRef.current.selectionStart || 0; // selectionStart: 光标前面有几个字符
236
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
237
+ var selectionStart = inputDom.selectionStart || 0; // selectionStart: 光标前面有几个字符
238
+ if (isMultiple && inputDom && textValue && textValue.length > inputValue.length) {
202
239
  searchInfo.current.selectionStart = selectionStart;
203
240
  var isInHead = selectionStart === 1 && textValue[1] !== delimiter && textValue.length !== 1; // 在首部添加
204
241
  var isInMid = selectionStart !== textValue.length && textValue[selectionStart - 2] === delimiter && textValue[selectionStart] !== delimiter;
205
242
  if (isInHead || isInMid) {
206
- inputRef.current.value = val = textValue.substring(0, selectionStart) + delimiter + textValue.substring(selectionStart, textValue.length);
207
- setCursorPosition(inputRef.current, selectionStart);
243
+ inputDom.value = val = textValue.substring(0, selectionStart) + delimiter + textValue.substring(selectionStart, textValue.length);
244
+ setCursorPosition(inputDom, selectionStart);
208
245
  }
209
246
  }
247
+ // 单个删除时 当删除的字符为分隔符delimiter 记录位置
248
+ if (findDeletedChar(searchInfo.current.previousEditValue || '', textValue) === delimiter) {
249
+ searchInfo.current.deleteEndIndx = selectionStart;
250
+ }
210
251
  setInputValue(val);
211
252
  handleChange(val);
212
253
  };
@@ -216,6 +257,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
216
257
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(str);
217
258
  };
218
259
  var getQueryStr = function getQueryStr(queryStr) {
260
+ var _a, _b;
219
261
  if (!isMultiple) {
220
262
  return queryStr;
221
263
  }
@@ -224,7 +266,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
224
266
  // 只有一条记录
225
267
  return queryStr;
226
268
  }
227
- var selectionStart = inputRef.current.selectionStart || 0;
269
+ var selectionStart = ((_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.selectionStart) || 0;
228
270
  var startIndex = _sliceInstanceProperty(queryStr).call(queryStr, 0, selectionStart).lastIndexOf(delimiter) + 1; // 光标前面最近分隔符index
229
271
  var endIndex = _sliceInstanceProperty(queryStr).call(queryStr, selectionStart).indexOf(delimiter);
230
272
  endIndex = endIndex === -1 ? queryStr.length : selectionStart + endIndex; // 光标后面最近分隔符index
@@ -234,26 +276,26 @@ var InternalBaseData = function InternalBaseData(props, ref) {
234
276
  return queryStr;
235
277
  };
236
278
  var handleFocus = function handleFocus() {
237
- var _context5;
279
+ var _context9;
238
280
  if (disabled) return;
239
281
  setFocused(true);
240
- isMultiple && seletedOptions.length && setInputValue(_concatInstanceProperty(_context5 = "".concat(inputValue)).call(_context5, delimiter));
282
+ isMultiple && seletedOptions.length && setInputValue(_concatInstanceProperty(_context9 = "".concat(inputValue)).call(_context9, delimiter));
241
283
  };
242
284
  var handleBlur = function handleBlur() {
243
- var _context6, _context7;
285
+ var _context10, _context11;
244
286
  if (disabled) return;
245
287
  setFocused(false);
246
288
  setInputValue(searchInfo.current.previousInputValue);
247
- searchInfo.current.previousEditValue = _concatInstanceProperty(_context6 = "".concat(searchInfo.current.previousInputValue)).call(_context6, delimiter);
289
+ searchInfo.current.previousEditValue = _concatInstanceProperty(_context10 = "".concat(searchInfo.current.previousInputValue)).call(_context10, delimiter);
248
290
  // 多选失去焦点时,通过editOptions去改写选中项
249
- var list = _filterInstanceProperty(_context7 = searchInfo.current.editOptions || []).call(_context7, function (item) {
291
+ var list = _filterInstanceProperty(_context11 = searchInfo.current.editOptions || []).call(_context11, function (item) {
250
292
  return item;
251
293
  }) || [];
252
294
  if (_JSON$stringify(list) !== _JSON$stringify(seletedOptions)) {
253
- var _context8;
254
- onChange === null || onChange === void 0 ? void 0 : onChange(_mapInstanceProperty(_context8 = _filterInstanceProperty(list).call(list, function (item) {
295
+ var _context12;
296
+ onChange === null || onChange === void 0 ? void 0 : onChange(_mapInstanceProperty(_context12 = _filterInstanceProperty(list).call(list, function (item) {
255
297
  return item;
256
- })).call(_context8, function (v) {
298
+ })).call(_context12, function (v) {
257
299
  return v.value;
258
300
  }), _filterInstanceProperty(list).call(list, function (item) {
259
301
  return item;
@@ -265,12 +307,14 @@ var InternalBaseData = function InternalBaseData(props, ref) {
265
307
  setSeletedOptions(list);
266
308
  };
267
309
  var showInputTotal = function showInputTotal() {
310
+ var _a;
268
311
  if (disabled) return;
269
- if (inputRef.current) {
270
- var scrollToWidth = inputRef.current.scrollWidth - inputRef.current.offsetWidth;
271
- inputRef.current.scrollLeft = scrollToWidth;
312
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
313
+ if (inputDom) {
314
+ var scrollToWidth = inputDom.scrollWidth - inputDom.offsetWidth;
315
+ inputDom.scrollLeft = scrollToWidth;
272
316
  setTimeout(function () {
273
- setCursorPosition(inputRef.current, inputValue.length + 1);
317
+ setCursorPosition(inputDom, inputValue.length + 1);
274
318
  }, 0);
275
319
  }
276
320
  };
@@ -299,11 +343,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
299
343
  };
300
344
  // 双击选中当前项
301
345
  var handleDoubleClick = function handleDoubleClick() {
302
- var _a, _b;
303
- var _findDbClickSelectedP = findDbClickSelectedPos(((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.selectionStart) || 0, ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.selectionEnd) || 0),
346
+ var _a;
347
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
348
+ var _findDbClickSelectedP = findDbClickSelectedPos((inputDom === null || inputDom === void 0 ? void 0 : inputDom.selectionStart) || 0, (inputDom === null || inputDom === void 0 ? void 0 : inputDom.selectionEnd) || 0),
304
349
  start = _findDbClickSelectedP.start,
305
350
  end = _findDbClickSelectedP.end;
306
- handleSeletedText(inputRef.current, start, end);
351
+ handleSeletedText(inputDom, start, end);
307
352
  };
308
353
  var findDbClickSelectedPos = function findDbClickSelectedPos(selectionStart, selectionEnd) {
309
354
  for (var index = 0; index < indxPosList.length; index++) {
@@ -348,20 +393,20 @@ var InternalBaseData = function InternalBaseData(props, ref) {
348
393
  element.setSelectionRange(start, end);
349
394
  };
350
395
  var handleSelect = function handleSelect(item) {
351
- var _context13;
396
+ var _context17;
352
397
  searchInfo.current.searchValue = undefined;
353
398
  if (_findIndexInstanceProperty(seletedOptions).call(seletedOptions, function (v) {
354
399
  return v.value === item.value;
355
400
  }) !== -1) {
356
- var _context9;
401
+ var _context13;
357
402
  var _list = _filterInstanceProperty(seletedOptions).call(seletedOptions, function (v) {
358
403
  return v.value !== item.value;
359
404
  });
360
405
  // 取消选中(非受控状态下)
361
406
  isMultiple && value === undefined && setSeletedOptions(_list);
362
- onChange === null || onChange === void 0 ? void 0 : onChange(_mapInstanceProperty(_context9 = _filterInstanceProperty(_list).call(_list, function (item) {
407
+ onChange === null || onChange === void 0 ? void 0 : onChange(_mapInstanceProperty(_context13 = _filterInstanceProperty(_list).call(_list, function (item) {
363
408
  return item;
364
- })).call(_context9, function (v) {
409
+ })).call(_context13, function (v) {
365
410
  return v.value;
366
411
  }), _filterInstanceProperty(_list).call(_list, function (item) {
367
412
  return item;
@@ -371,12 +416,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
371
416
  var list = _toConsumableArray(searchInfo.current.editOptions || []);
372
417
  list === null || list === void 0 ? void 0 : _spliceInstanceProperty(list).call(list, searchInfo.current.searchIndex || 0, 1, item);
373
418
  if (isMultiple) {
374
- var _context10, _context11, _context12;
375
- onChange === null || onChange === void 0 ? void 0 : onChange(_mapInstanceProperty(_context10 = _filterInstanceProperty(_context11 = list || []).call(_context11, function (item) {
419
+ var _context14, _context15, _context16;
420
+ onChange === null || onChange === void 0 ? void 0 : onChange(_mapInstanceProperty(_context14 = _filterInstanceProperty(_context15 = list || []).call(_context15, function (item) {
376
421
  return item;
377
- })).call(_context10, function (v) {
422
+ })).call(_context14, function (v) {
378
423
  return v.value;
379
- }), _filterInstanceProperty(_context12 = list || []).call(_context12, function (item) {
424
+ }), _filterInstanceProperty(_context16 = list || []).call(_context16, function (item) {
380
425
  return item;
381
426
  }));
382
427
  } else {
@@ -387,7 +432,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
387
432
  return;
388
433
  }
389
434
  searchInfo.current.editOptions = list;
390
- setSeletedOptions(_filterInstanceProperty(_context13 = list || []).call(_context13, function (item) {
435
+ setSeletedOptions(_filterInstanceProperty(_context17 = list || []).call(_context17, function (item) {
391
436
  return item;
392
437
  }));
393
438
  };
@@ -463,10 +508,10 @@ var InternalBaseData = function InternalBaseData(props, ref) {
463
508
  * @returns {React.ReactNode}
464
509
  */
465
510
  var renderDropdownContent = function renderDropdownContent(data, myColumns) {
466
- var _context14;
511
+ var _context18;
467
512
  var showFooter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
468
513
  var showCheckbox = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
469
- var dropDownColumns = myColumns && Array.isArray(myColumns) ? myColumns : data && Array.isArray(data) && data.length ? _mapInstanceProperty(_context14 = _Object$keys(data[0])).call(_context14, function (v) {
514
+ var dropDownColumns = myColumns && Array.isArray(myColumns) ? myColumns : data && Array.isArray(data) && data.length ? _mapInstanceProperty(_context18 = _Object$keys(data[0])).call(_context18, function (v) {
470
515
  return {
471
516
  key: v
472
517
  };
@@ -52,6 +52,6 @@ export interface ISearchInfoProps {
52
52
  previousEditValue?: string;
53
53
  searchIndex?: number;
54
54
  selectionStart?: number;
55
- deleteEndIndx?: number;
55
+ deleteEndIndx: number;
56
56
  editOptions?: any[];
57
57
  }
@@ -16,8 +16,8 @@
16
16
  @modal-theme-color-active: var(~'@{modal-prefix}-color-theme-active', @color-theme-7);
17
17
  @modal-mask-color-background: var(~'@{modal-prefix}-mask-color-background', rgba(55, 55, 55, 0.5));
18
18
  @modal-close-icon-color-text: var(~'@{modal-prefix}-close-icon-color-text', #666666);
19
- @confirm-modal-title-icon-bg: var(~'@{modal-prefix}-title-icon-color-backround-ongoing', @color-ongoing); // 提示弹窗的背景色
20
- @warning-modal-title-icon-bg: var(~'@{modal-prefix}-title-icon-color-backround-warning', @color-warning); // 警告弹窗的背景色
19
+ @confirm-modal-title-icon-bg: var(~'@{modal-prefix}-title-icon-color-backround-ongoing', @color-ongoing); // 弹出框的背景色
20
+ @warning-modal-title-icon-bg: var(~'@{modal-prefix}-title-icon-color-backround-warning', @color-warning); // 警告弹出框的背景色
21
21
  @error-modal-title-icon-bg: var(~'@{modal-prefix}-title-icon-color-backround-warning', @color-warning); // 反馈浮层错误提示的背景色
22
22
 
23
23
  // z-index
@@ -46,4 +46,4 @@
46
46
  @modal-title-icon-sizing-margin-right: var(~'@{modal-prefix}-title-icon-sizing-margin-right', 8px);
47
47
  @modal-header-sizing-padding-horizontal: var(~'@{modal-prefix}-header-sizing-padding-horizontal', 20px);
48
48
  @modal-header-sizing-padding-vertical: var(~'@{modal-prefix}-header-sizing-padding-vertical', 0px);
49
- @modal-body-sizing-padding: var(~'@{modal-prefix}-body-sizing-padding', 20px);
49
+ @modal-body-sizing-padding: var(~'@{modal-prefix}-body-sizing-padding', 20px);
@@ -523,8 +523,8 @@
523
523
  /* ----------- Split-Panel ——————---- end */
524
524
 
525
525
  /* ----------- Modal ——————---- start */
526
- @confirm-modal-title-icon-bg: @ongoing-bg-color; // 提示弹窗的背景色
527
- @warning-modal-title-icon-bg: @warning-bg-color; // 警告弹窗的背景色
526
+ @confirm-modal-title-icon-bg: @ongoing-bg-color; // 弹出框的背景色
527
+ @warning-modal-title-icon-bg: @warning-bg-color; // 警告弹出框的背景色
528
528
  @error-modal-title-icon-bg: @error-bg-color; // 反馈浮层错误提示的背景色
529
529
  @modal-border-color: @strong-border-color-1;
530
530
  /* ----------- Modal ——————---- end */
@@ -706,4 +706,4 @@
706
706
  @advancedSelector-dropdown-options-height: 32px;
707
707
  @advancedSelector-hover-bg: @hover-color;
708
708
 
709
- /* ----------- AdvancedSelector ——————---- end */
709
+ /* ----------- AdvancedSelector ——————---- end */