@lensui/lens-table 0.1.84 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.cjs +3 -4
- package/dist/index.js +3 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -316,9 +316,9 @@ const columns: GridColumn<Row>[] = [
|
|
|
316
316
|
| `date-time-range` | `'2026-01-01 09:00 ~ 2026-01-01 18:00'` | 日期时间范围选择器,包含日期和时间面板。 |
|
|
317
317
|
|
|
318
318
|
`select` 可配置 `searchable` 开启输入筛选。需要把输入限制为已有选项时,设置
|
|
319
|
-
`strictOptions: true
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
`strictOptions: true`:首次打开显示完整列表;开始输入后按输入内容筛选且不产生选中勾;
|
|
320
|
+
没有匹配项或清空输入时显示完整列表。失焦时只提交精确匹配的选项,不匹配则恢复进入编辑前的值。
|
|
321
|
+
若 `options` 包含 `{ label: '', value: '' }`,清空输入会在失焦时提交该空选项。
|
|
322
322
|
|
|
323
323
|
可选 `format` 用于控制提交到数据里的字符串格式,例如:
|
|
324
324
|
|
package/dist/index.cjs
CHANGED
|
@@ -367,17 +367,16 @@ function SearchableChoiceEditor({ value, options, allowCustomValue, strictOption
|
|
|
367
367
|
const filteredOptions = (0, import_react2.useMemo)(() => {
|
|
368
368
|
if (strictOptions) {
|
|
369
369
|
if (!hasTyped) return options;
|
|
370
|
-
if (inputValue === "") return options.filter((option) => option.value === "");
|
|
371
370
|
const strictQuery = inputValue.trim().toLocaleLowerCase();
|
|
372
|
-
|
|
373
|
-
return
|
|
371
|
+
const matches = options.filter((option) => option.label.toLocaleLowerCase().includes(strictQuery) || option.value.toLocaleLowerCase().includes(strictQuery));
|
|
372
|
+
return matches.length > 0 ? matches : options;
|
|
374
373
|
}
|
|
375
374
|
const query = inputValue.trim().toLocaleLowerCase();
|
|
376
375
|
if (!query || query === originalValue.toLocaleLowerCase()) return options;
|
|
377
376
|
return options.filter((option) => option.label.toLocaleLowerCase().includes(query) || option.value.toLocaleLowerCase().includes(query));
|
|
378
377
|
}, [hasTyped, inputValue, options, originalValue, strictOptions]);
|
|
379
378
|
const exactInputOption = options.find((option) => option.value === inputValue);
|
|
380
|
-
const selectedValue = exactInputOption?.value;
|
|
379
|
+
const selectedValue = hasTyped ? void 0 : exactInputOption?.value;
|
|
381
380
|
const resolveInputValue = (0, import_react2.useCallback)(() => {
|
|
382
381
|
if (strictOptions) return exactInputOption?.value ?? originalValue;
|
|
383
382
|
return allowCustomValue ? inputValue || originalValue : originalValue;
|
package/dist/index.js
CHANGED
|
@@ -337,17 +337,16 @@ function SearchableChoiceEditor({ value, options, allowCustomValue, strictOption
|
|
|
337
337
|
const filteredOptions = useMemo(() => {
|
|
338
338
|
if (strictOptions) {
|
|
339
339
|
if (!hasTyped) return options;
|
|
340
|
-
if (inputValue === "") return options.filter((option) => option.value === "");
|
|
341
340
|
const strictQuery = inputValue.trim().toLocaleLowerCase();
|
|
342
|
-
|
|
343
|
-
return
|
|
341
|
+
const matches = options.filter((option) => option.label.toLocaleLowerCase().includes(strictQuery) || option.value.toLocaleLowerCase().includes(strictQuery));
|
|
342
|
+
return matches.length > 0 ? matches : options;
|
|
344
343
|
}
|
|
345
344
|
const query = inputValue.trim().toLocaleLowerCase();
|
|
346
345
|
if (!query || query === originalValue.toLocaleLowerCase()) return options;
|
|
347
346
|
return options.filter((option) => option.label.toLocaleLowerCase().includes(query) || option.value.toLocaleLowerCase().includes(query));
|
|
348
347
|
}, [hasTyped, inputValue, options, originalValue, strictOptions]);
|
|
349
348
|
const exactInputOption = options.find((option) => option.value === inputValue);
|
|
350
|
-
const selectedValue = exactInputOption?.value;
|
|
349
|
+
const selectedValue = hasTyped ? void 0 : exactInputOption?.value;
|
|
351
350
|
const resolveInputValue = useCallback(() => {
|
|
352
351
|
if (strictOptions) return exactInputOption?.value ?? originalValue;
|
|
353
352
|
return allowCustomValue ? inputValue || originalValue : originalValue;
|