@kdcloudjs/kdesign 1.7.62 → 1.7.64

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.
@@ -130,12 +130,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
130
130
  searchInfo.current.editOptions = _toConsumableArray(seletedItems);
131
131
  }, [value, isMultiple]);
132
132
  useEffect(function () {
133
- var _a;
133
+ var _a, _b;
134
134
  if (!searchInfo.current.previousEditValue) return;
135
135
  var posList = setValIndxPosition();
136
136
  var preValueArr = getStrToArr(searchInfo.current.previousEditValue, delimiter);
137
137
  var valueArr = getStrToArr(inputValue, delimiter);
138
- var selectionStart = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.selectionStart) || 0;
138
+ var selectionStart = ((_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.selectionStart) || 0;
139
139
  var index = findSelectionIndex(selectionStart, posList);
140
140
  searchInfo.current.searchIndex = index;
141
141
  // 新增一个
@@ -172,8 +172,10 @@ var InternalBaseData = function InternalBaseData(props, ref) {
172
172
  };
173
173
  // 当选中项文字超出输入框时,显示共多少项
174
174
  useLayoutEffect(function () {
175
- if (!inputRef.current) return;
176
- if (inputRef.current.scrollWidth - inputRef.current.offsetWidth > 0) {
175
+ var _a;
176
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
177
+ if (!inputDom) return;
178
+ if (inputDom.scrollWidth - inputDom.offsetWidth > 0) {
177
179
  setShowTotal(true);
178
180
  } else {
179
181
  setShowTotal(false);
@@ -194,17 +196,19 @@ var InternalBaseData = function InternalBaseData(props, ref) {
194
196
  setValueBySeleted();
195
197
  }, [setValueBySeleted]);
196
198
  var changeInputText = function changeInputText(e) {
199
+ var _a;
197
200
  setOptionShow(true);
198
201
  var textValue = e.target.value;
199
202
  var val = textValue;
200
- if (isMultiple && inputRef.current && textValue && textValue.length > inputValue.length) {
201
- var selectionStart = inputRef.current.selectionStart || 0; // selectionStart: 光标前面有几个字符
203
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
204
+ if (isMultiple && inputDom && textValue && textValue.length > inputValue.length) {
205
+ var selectionStart = inputDom.selectionStart || 0; // selectionStart: 光标前面有几个字符
202
206
  searchInfo.current.selectionStart = selectionStart;
203
207
  var isInHead = selectionStart === 1 && textValue[1] !== delimiter && textValue.length !== 1; // 在首部添加
204
208
  var isInMid = selectionStart !== textValue.length && textValue[selectionStart - 2] === delimiter && textValue[selectionStart] !== delimiter;
205
209
  if (isInHead || isInMid) {
206
- inputRef.current.value = val = textValue.substring(0, selectionStart) + delimiter + textValue.substring(selectionStart, textValue.length);
207
- setCursorPosition(inputRef.current, selectionStart);
210
+ inputDom.value = val = textValue.substring(0, selectionStart) + delimiter + textValue.substring(selectionStart, textValue.length);
211
+ setCursorPosition(inputDom, selectionStart);
208
212
  }
209
213
  }
210
214
  setInputValue(val);
@@ -216,6 +220,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
216
220
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(str);
217
221
  };
218
222
  var getQueryStr = function getQueryStr(queryStr) {
223
+ var _a, _b;
219
224
  if (!isMultiple) {
220
225
  return queryStr;
221
226
  }
@@ -224,7 +229,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
224
229
  // 只有一条记录
225
230
  return queryStr;
226
231
  }
227
- var selectionStart = inputRef.current.selectionStart || 0;
232
+ var selectionStart = ((_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.selectionStart) || 0;
228
233
  var startIndex = _sliceInstanceProperty(queryStr).call(queryStr, 0, selectionStart).lastIndexOf(delimiter) + 1; // 光标前面最近分隔符index
229
234
  var endIndex = _sliceInstanceProperty(queryStr).call(queryStr, selectionStart).indexOf(delimiter);
230
235
  endIndex = endIndex === -1 ? queryStr.length : selectionStart + endIndex; // 光标后面最近分隔符index
@@ -265,12 +270,14 @@ var InternalBaseData = function InternalBaseData(props, ref) {
265
270
  setSeletedOptions(list);
266
271
  };
267
272
  var showInputTotal = function showInputTotal() {
273
+ var _a;
268
274
  if (disabled) return;
269
- if (inputRef.current) {
270
- var scrollToWidth = inputRef.current.scrollWidth - inputRef.current.offsetWidth;
271
- inputRef.current.scrollLeft = scrollToWidth;
275
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
276
+ if (inputDom) {
277
+ var scrollToWidth = inputDom.scrollWidth - inputDom.offsetWidth;
278
+ inputDom.scrollLeft = scrollToWidth;
272
279
  setTimeout(function () {
273
- setCursorPosition(inputRef.current, inputValue.length + 1);
280
+ setCursorPosition(inputDom, inputValue.length + 1);
274
281
  }, 0);
275
282
  }
276
283
  };
@@ -299,11 +306,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
299
306
  };
300
307
  // 双击选中当前项
301
308
  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),
309
+ var _a;
310
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
311
+ var _findDbClickSelectedP = findDbClickSelectedPos((inputDom === null || inputDom === void 0 ? void 0 : inputDom.selectionStart) || 0, (inputDom === null || inputDom === void 0 ? void 0 : inputDom.selectionEnd) || 0),
304
312
  start = _findDbClickSelectedP.start,
305
313
  end = _findDbClickSelectedP.end;
306
- handleSeletedText(inputRef.current, start, end);
314
+ handleSeletedText(inputDom, start, end);
307
315
  };
308
316
  var findDbClickSelectedPos = function findDbClickSelectedPos(selectionStart, selectionEnd) {
309
317
  for (var index = 0; index < indxPosList.length; index++) {
@@ -215,7 +215,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
215
215
  // 输入框变化搜索内容
216
216
  var handleSearchChange = useCallback(function (event) {
217
217
  var val = event.currentTarget.value;
218
- setOptionShow(true);
218
+ handleVisibleChange(true);
219
219
  setSearchValue(val);
220
220
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
221
221
  }, [onSearch]);
@@ -263,7 +263,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
263
263
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(keys, state);
264
264
  !isMultiple && (onChange === null || onChange === void 0 ? void 0 : onChange(keys[0], [TreeMap.get(keys[0])]));
265
265
  if (!isMultiple) {
266
- setOptionShow(false);
266
+ handleVisibleChange(false);
267
267
  }
268
268
  };
269
269
  var handleCheck = function handleCheck(keys, state) {
@@ -357,6 +357,9 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
357
357
  useEffect(function () {
358
358
  setSelectedKeys(initValue);
359
359
  }, [initValue]);
360
+ useEffect(function () {
361
+ setOptionShow(props.visible);
362
+ }, [props.visible]);
360
363
  // 渲染下拉列表框
361
364
  var renderContent = function renderContent() {
362
365
  var dropDownStyle = _extends({
@@ -394,7 +397,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
394
397
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
395
398
  className: singleCls,
396
399
  ref: selectionRef,
397
- title: label
400
+ title: typeof label === 'string' ? label : ''
398
401
  }, /*#__PURE__*/React.createElement("span", {
399
402
  className: "".concat(selectPrefixCls, "-selection-search")
400
403
  }, /*#__PURE__*/React.createElement("input", {
@@ -449,7 +452,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
449
452
  return handleRemove(e, key);
450
453
  },
451
454
  "data-tag": key,
452
- title: label
455
+ title: typeof label === 'string' ? label : ''
453
456
  }, label));
454
457
  }), maxTagCount && selectTreeNodes.length > maxTagCount ? maxTagPlaceholder ? handleMaxTagHolder() : /*#__PURE__*/React.createElement("span", {
455
458
  className: itemCls
@@ -513,9 +516,10 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
513
516
  onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(visible);
514
517
  }
515
518
  };
516
- var popperProps = _extends(_extends({}, treeSelectProps), {
519
+ var popperProps = _extends(_extends({
520
+ placement: 'bottomLeft'
521
+ }, treeSelectProps), {
517
522
  prefixCls: "".concat(selectPrefixCls, "-panel"),
518
- placement: 'bottomLeft',
519
523
  popperStyle: catchStyle(),
520
524
  defaultVisible: optionShow,
521
525
  visible: optionShow,
@@ -142,12 +142,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
142
142
  searchInfo.current.editOptions = (0, _toConsumableArray2.default)(seletedItems);
143
143
  }, [value, isMultiple]);
144
144
  (0, _react.useEffect)(function () {
145
- var _a;
145
+ var _a, _b;
146
146
  if (!searchInfo.current.previousEditValue) return;
147
147
  var posList = setValIndxPosition();
148
148
  var preValueArr = getStrToArr(searchInfo.current.previousEditValue, delimiter);
149
149
  var valueArr = getStrToArr(inputValue, delimiter);
150
- 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;
151
151
  var index = findSelectionIndex(selectionStart, posList);
152
152
  searchInfo.current.searchIndex = index;
153
153
  // 新增一个
@@ -184,8 +184,10 @@ var InternalBaseData = function InternalBaseData(props, ref) {
184
184
  };
185
185
  // 当选中项文字超出输入框时,显示共多少项
186
186
  (0, _react.useLayoutEffect)(function () {
187
- if (!inputRef.current) return;
188
- if (inputRef.current.scrollWidth - inputRef.current.offsetWidth > 0) {
187
+ var _a;
188
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
189
+ if (!inputDom) return;
190
+ if (inputDom.scrollWidth - inputDom.offsetWidth > 0) {
189
191
  setShowTotal(true);
190
192
  } else {
191
193
  setShowTotal(false);
@@ -206,17 +208,19 @@ var InternalBaseData = function InternalBaseData(props, ref) {
206
208
  setValueBySeleted();
207
209
  }, [setValueBySeleted]);
208
210
  var changeInputText = function changeInputText(e) {
211
+ var _a;
209
212
  setOptionShow(true);
210
213
  var textValue = e.target.value;
211
214
  var val = textValue;
212
- if (isMultiple && inputRef.current && textValue && textValue.length > inputValue.length) {
213
- var selectionStart = inputRef.current.selectionStart || 0; // selectionStart: 光标前面有几个字符
215
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
216
+ if (isMultiple && inputDom && textValue && textValue.length > inputValue.length) {
217
+ var selectionStart = inputDom.selectionStart || 0; // selectionStart: 光标前面有几个字符
214
218
  searchInfo.current.selectionStart = selectionStart;
215
219
  var isInHead = selectionStart === 1 && textValue[1] !== delimiter && textValue.length !== 1; // 在首部添加
216
220
  var isInMid = selectionStart !== textValue.length && textValue[selectionStart - 2] === delimiter && textValue[selectionStart] !== delimiter;
217
221
  if (isInHead || isInMid) {
218
- inputRef.current.value = val = textValue.substring(0, selectionStart) + delimiter + textValue.substring(selectionStart, textValue.length);
219
- setCursorPosition(inputRef.current, selectionStart);
222
+ inputDom.value = val = textValue.substring(0, selectionStart) + delimiter + textValue.substring(selectionStart, textValue.length);
223
+ setCursorPosition(inputDom, selectionStart);
220
224
  }
221
225
  }
222
226
  setInputValue(val);
@@ -228,6 +232,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
228
232
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(str);
229
233
  };
230
234
  var getQueryStr = function getQueryStr(queryStr) {
235
+ var _a, _b;
231
236
  if (!isMultiple) {
232
237
  return queryStr;
233
238
  }
@@ -236,7 +241,7 @@ var InternalBaseData = function InternalBaseData(props, ref) {
236
241
  // 只有一条记录
237
242
  return queryStr;
238
243
  }
239
- var selectionStart = inputRef.current.selectionStart || 0;
244
+ var selectionStart = ((_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.selectionStart) || 0;
240
245
  var startIndex = (0, _slice.default)(queryStr).call(queryStr, 0, selectionStart).lastIndexOf(delimiter) + 1; // 光标前面最近分隔符index
241
246
  var endIndex = (0, _slice.default)(queryStr).call(queryStr, selectionStart).indexOf(delimiter);
242
247
  endIndex = endIndex === -1 ? queryStr.length : selectionStart + endIndex; // 光标后面最近分隔符index
@@ -277,12 +282,14 @@ var InternalBaseData = function InternalBaseData(props, ref) {
277
282
  setSeletedOptions(list);
278
283
  };
279
284
  var showInputTotal = function showInputTotal() {
285
+ var _a;
280
286
  if (disabled) return;
281
- if (inputRef.current) {
282
- var scrollToWidth = inputRef.current.scrollWidth - inputRef.current.offsetWidth;
283
- inputRef.current.scrollLeft = scrollToWidth;
287
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
288
+ if (inputDom) {
289
+ var scrollToWidth = inputDom.scrollWidth - inputDom.offsetWidth;
290
+ inputDom.scrollLeft = scrollToWidth;
284
291
  setTimeout(function () {
285
- setCursorPosition(inputRef.current, inputValue.length + 1);
292
+ setCursorPosition(inputDom, inputValue.length + 1);
286
293
  }, 0);
287
294
  }
288
295
  };
@@ -311,11 +318,12 @@ var InternalBaseData = function InternalBaseData(props, ref) {
311
318
  };
312
319
  // 双击选中当前项
313
320
  var handleDoubleClick = function handleDoubleClick() {
314
- var _a, _b;
315
- 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),
321
+ var _a;
322
+ var inputDom = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.input;
323
+ var _findDbClickSelectedP = findDbClickSelectedPos((inputDom === null || inputDom === void 0 ? void 0 : inputDom.selectionStart) || 0, (inputDom === null || inputDom === void 0 ? void 0 : inputDom.selectionEnd) || 0),
316
324
  start = _findDbClickSelectedP.start,
317
325
  end = _findDbClickSelectedP.end;
318
- handleSeletedText(inputRef.current, start, end);
326
+ handleSeletedText(inputDom, start, end);
319
327
  };
320
328
  var findDbClickSelectedPos = function findDbClickSelectedPos(selectionStart, selectionEnd) {
321
329
  for (var index = 0; index < indxPosList.length; index++) {
@@ -227,7 +227,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
227
227
  // 输入框变化搜索内容
228
228
  var handleSearchChange = (0, _react.useCallback)(function (event) {
229
229
  var val = event.currentTarget.value;
230
- setOptionShow(true);
230
+ handleVisibleChange(true);
231
231
  setSearchValue(val);
232
232
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
233
233
  }, [onSearch]);
@@ -275,7 +275,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
275
275
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(keys, state);
276
276
  !isMultiple && (onChange === null || onChange === void 0 ? void 0 : onChange(keys[0], [TreeMap.get(keys[0])]));
277
277
  if (!isMultiple) {
278
- setOptionShow(false);
278
+ handleVisibleChange(false);
279
279
  }
280
280
  };
281
281
  var handleCheck = function handleCheck(keys, state) {
@@ -369,6 +369,9 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
369
369
  (0, _react.useEffect)(function () {
370
370
  setSelectedKeys(initValue);
371
371
  }, [initValue]);
372
+ (0, _react.useEffect)(function () {
373
+ setOptionShow(props.visible);
374
+ }, [props.visible]);
372
375
  // 渲染下拉列表框
373
376
  var renderContent = function renderContent() {
374
377
  var dropDownStyle = (0, _extends2.default)({
@@ -406,7 +409,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
406
409
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
407
410
  className: singleCls,
408
411
  ref: selectionRef,
409
- title: label
412
+ title: typeof label === 'string' ? label : ''
410
413
  }, /*#__PURE__*/_react.default.createElement("span", {
411
414
  className: "".concat(selectPrefixCls, "-selection-search")
412
415
  }, /*#__PURE__*/_react.default.createElement("input", {
@@ -461,7 +464,7 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
461
464
  return handleRemove(e, key);
462
465
  },
463
466
  "data-tag": key,
464
- title: label
467
+ title: typeof label === 'string' ? label : ''
465
468
  }, label));
466
469
  }), maxTagCount && selectTreeNodes.length > maxTagCount ? maxTagPlaceholder ? handleMaxTagHolder() : /*#__PURE__*/_react.default.createElement("span", {
467
470
  className: itemCls
@@ -525,9 +528,10 @@ var InternalTreeSelect = function InternalTreeSelect(props, ref) {
525
528
  onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(visible);
526
529
  }
527
530
  };
528
- var popperProps = (0, _extends2.default)((0, _extends2.default)({}, treeSelectProps), {
531
+ var popperProps = (0, _extends2.default)((0, _extends2.default)({
532
+ placement: 'bottomLeft'
533
+ }, treeSelectProps), {
529
534
  prefixCls: "".concat(selectPrefixCls, "-panel"),
530
- placement: 'bottomLeft',
531
535
  popperStyle: catchStyle(),
532
536
  defaultVisible: optionShow,
533
537
  visible: optionShow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.7.62",
3
+ "version": "1.7.64",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [