@manohub/ui 1.2.5 → 1.2.6
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/components/select/index.d.ts +2 -2
- package/dist/components/select/index.js +2 -2
- package/dist/components/select/select-tree-filter.d.ts +3 -1
- package/dist/components/select/select-tree-filter.js +7 -4
- package/dist/components/select/select-tree.d.ts +2 -2
- package/dist/components/select/select-tree.js +1 -1
- package/package.json +2 -2
|
@@ -95,7 +95,7 @@ export declare const Select: import("vue").DefineComponent<import("vue").Extract
|
|
|
95
95
|
type: BooleanConstructor;
|
|
96
96
|
default: boolean;
|
|
97
97
|
};
|
|
98
|
-
/** 自定义过滤(缺省按 `label
|
|
98
|
+
/** 自定义过滤(缺省按 `label` **忽略大小写**地包含关键词) */
|
|
99
99
|
filterOption: {
|
|
100
100
|
type: PropType<(option: SelectOption, keyword: string) => boolean>;
|
|
101
101
|
default: undefined;
|
|
@@ -201,7 +201,7 @@ export declare const Select: import("vue").DefineComponent<import("vue").Extract
|
|
|
201
201
|
type: BooleanConstructor;
|
|
202
202
|
default: boolean;
|
|
203
203
|
};
|
|
204
|
-
/** 自定义过滤(缺省按 `label
|
|
204
|
+
/** 自定义过滤(缺省按 `label` **忽略大小写**地包含关键词) */
|
|
205
205
|
filterOption: {
|
|
206
206
|
type: PropType<(option: SelectOption, keyword: string) => boolean>;
|
|
207
207
|
default: undefined;
|
|
@@ -46,7 +46,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
46
46
|
type: Boolean,
|
|
47
47
|
default: false
|
|
48
48
|
},
|
|
49
|
-
/** 自定义过滤(缺省按 `label
|
|
49
|
+
/** 自定义过滤(缺省按 `label` **忽略大小写**地包含关键词) */
|
|
50
50
|
filterOption: {
|
|
51
51
|
type: Function,
|
|
52
52
|
default: void 0
|
|
@@ -139,7 +139,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
139
139
|
return list;
|
|
140
140
|
});
|
|
141
141
|
const selectedOptions = computed(() => flatOptions.value.filter((option) => selectedValues.value.includes(option.value)));
|
|
142
|
-
const matched = (option, kw) => props.filterOption ? props.filterOption(option, kw) : option.label.includes(kw);
|
|
142
|
+
const matched = (option, kw) => props.filterOption ? props.filterOption(option, kw) : option.label.toLowerCase().includes(kw.toLowerCase());
|
|
143
143
|
const visibleOptions = computed(() => {
|
|
144
144
|
const kw = keyword.value;
|
|
145
145
|
if (!kw) return props.options;
|
|
@@ -29,7 +29,7 @@ export declare function findTreeNode(nodes: ListNode[], key: string, accessors:
|
|
|
29
29
|
export interface TreeFilterOptions extends TreeAccessors {
|
|
30
30
|
/** 关键词(调用方保证非空;空串走「不过滤」那条路,不进本函数) */
|
|
31
31
|
keyword: string;
|
|
32
|
-
/**
|
|
32
|
+
/** 自定义命中判定(缺省:标签**忽略大小写**地包含关键词 —— 与 `Select` 的缺省过滤同口径) */
|
|
33
33
|
match?: (node: ListNode, keyword: string) => boolean;
|
|
34
34
|
}
|
|
35
35
|
export interface TreeFilterResult {
|
|
@@ -56,6 +56,8 @@ export interface HitSegment {
|
|
|
56
56
|
/**
|
|
57
57
|
* 把标签文本按关键词切成「命中 / 未命中」交替的片段(**全部**出现位置都切,不只第一处)。
|
|
58
58
|
*
|
|
59
|
+
* 命中判定与 `filterTreeNodes` 的缺省口径一致:**忽略大小写**(搜 `http` 要能高亮 `HTTP`)。
|
|
60
|
+
*
|
|
59
61
|
* 关键词为空、或压根没命中时返回**一整段未命中**(消费方据此仍能渲染出原文,不必分情况)。
|
|
60
62
|
*/
|
|
61
63
|
export declare function splitHighlight(text: string, keyword: string): HitSegment[];
|
|
@@ -13,7 +13,8 @@ function findTreeNode(nodes, key, accessors) {
|
|
|
13
13
|
return void 0;
|
|
14
14
|
}
|
|
15
15
|
function filterTreeNodes(nodes, options) {
|
|
16
|
-
const
|
|
16
|
+
const keyword = options.keyword.toLowerCase();
|
|
17
|
+
const hit = (node) => options.match ? options.match(node, options.keyword) : treeLabel(node, options.labelKey).toLowerCase().includes(keyword);
|
|
17
18
|
const keys = [];
|
|
18
19
|
const collectKeys = (node) => {
|
|
19
20
|
keys.push(treeNodeKey(node, options.rowKey));
|
|
@@ -41,14 +42,16 @@ function filterTreeNodes(nodes, options) {
|
|
|
41
42
|
}
|
|
42
43
|
function splitHighlight(text, keyword) {
|
|
43
44
|
if (!keyword) return [{ text, hit: false }];
|
|
45
|
+
const haystack = text.toLowerCase();
|
|
46
|
+
const needle = keyword.toLowerCase();
|
|
44
47
|
const segments = [];
|
|
45
48
|
let cursor = 0;
|
|
46
49
|
for (; ; ) {
|
|
47
|
-
const at =
|
|
50
|
+
const at = haystack.indexOf(needle, cursor);
|
|
48
51
|
if (at < 0) break;
|
|
49
52
|
if (at > cursor) segments.push({ text: text.slice(cursor, at), hit: false });
|
|
50
|
-
segments.push({ text: text.slice(at, at +
|
|
51
|
-
cursor = at +
|
|
53
|
+
segments.push({ text: text.slice(at, at + needle.length), hit: true });
|
|
54
|
+
cursor = at + needle.length;
|
|
52
55
|
}
|
|
53
56
|
if (cursor < text.length) segments.push({ text: text.slice(cursor), hit: false });
|
|
54
57
|
return segments.length ? segments : [{ text, hit: false }];
|
|
@@ -78,7 +78,7 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
78
78
|
type: BooleanConstructor;
|
|
79
79
|
default: boolean;
|
|
80
80
|
};
|
|
81
|
-
/**
|
|
81
|
+
/** 自定义命中判定(缺省:标签忽略大小写地包含关键词) */
|
|
82
82
|
filterNode: {
|
|
83
83
|
type: PropType<(node: ListNode, keyword: string) => boolean>;
|
|
84
84
|
default: undefined;
|
|
@@ -217,7 +217,7 @@ export declare const SelectTree: import("vue").DefineComponent<import("vue").Ext
|
|
|
217
217
|
type: BooleanConstructor;
|
|
218
218
|
default: boolean;
|
|
219
219
|
};
|
|
220
|
-
/**
|
|
220
|
+
/** 自定义命中判定(缺省:标签忽略大小写地包含关键词) */
|
|
221
221
|
filterNode: {
|
|
222
222
|
type: PropType<(node: ListNode, keyword: string) => boolean>;
|
|
223
223
|
default: undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manohub/ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "AIHub 自绘组件层:不依赖 farris 的手写 Vue TSX 组件 + 自带令牌层(Farris 规范视觉 · daisyUI 式语义令牌 · shadcn 式 API 词汇)。",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"vue": "^3.5.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@manohub/icon": "^1.2.
|
|
38
|
+
"@manohub/icon": "^1.2.6"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^24.0.0",
|