@kdcloudjs/kdesign 1.7.63 → 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++) {
@@ -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++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.7.63",
3
+ "version": "1.7.64",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [