@partrunner-ai/ui 2.2.3 → 2.2.5
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/index.cjs +21 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1757,6 +1757,19 @@ var EmptyState = react.forwardRef(function EmptyState2({ icon: Icon, title, desc
|
|
|
1757
1757
|
}
|
|
1758
1758
|
);
|
|
1759
1759
|
});
|
|
1760
|
+
|
|
1761
|
+
// src/text-search.ts
|
|
1762
|
+
function normalizeSearch(value) {
|
|
1763
|
+
return value.normalize("NFD").replace(/[̀-ͯ]/g, "").toLocaleLowerCase();
|
|
1764
|
+
}
|
|
1765
|
+
function searchTokens(query) {
|
|
1766
|
+
return normalizeSearch(query).split(/\s+/).filter(Boolean);
|
|
1767
|
+
}
|
|
1768
|
+
function matchesSearch(text, tokens) {
|
|
1769
|
+
if (tokens.length === 0) return true;
|
|
1770
|
+
const normalized = normalizeSearch(text);
|
|
1771
|
+
return tokens.every((token) => normalized.includes(token));
|
|
1772
|
+
}
|
|
1760
1773
|
function anchorHorizontally({
|
|
1761
1774
|
align,
|
|
1762
1775
|
matchTriggerWidth,
|
|
@@ -1936,9 +1949,9 @@ function MultiSelect({
|
|
|
1936
1949
|
const hasSelection = value.length > 0;
|
|
1937
1950
|
const labelByValue = react.useMemo(() => new Map(options.map((o) => [o.value, o.label])), [options]);
|
|
1938
1951
|
const filtered = react.useMemo(() => {
|
|
1939
|
-
const
|
|
1940
|
-
if (
|
|
1941
|
-
return options.filter((o) => (o.searchText ?? o.label)
|
|
1952
|
+
const tokens = searchTokens(query);
|
|
1953
|
+
if (tokens.length === 0) return options;
|
|
1954
|
+
return options.filter((o) => matchesSearch(o.searchText ?? o.label, tokens));
|
|
1942
1955
|
}, [options, query]);
|
|
1943
1956
|
const toggle = (v) => onChange(value.includes(v) ? value.filter((x) => x !== v) : [...value, v]);
|
|
1944
1957
|
const hidden = value.slice(maxVisible);
|
|
@@ -2390,9 +2403,6 @@ function collectStructure(children) {
|
|
|
2390
2403
|
visit(children);
|
|
2391
2404
|
return { items, searchable };
|
|
2392
2405
|
}
|
|
2393
|
-
function normalizeSearch(value) {
|
|
2394
|
-
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLocaleLowerCase();
|
|
2395
|
-
}
|
|
2396
2406
|
var FOCUSABLE = [
|
|
2397
2407
|
"a[href]",
|
|
2398
2408
|
"button:not(:disabled)",
|
|
@@ -2463,11 +2473,9 @@ function RichSelect({
|
|
|
2463
2473
|
[]
|
|
2464
2474
|
);
|
|
2465
2475
|
const visibleItems = react.useMemo(() => {
|
|
2466
|
-
const
|
|
2467
|
-
if (
|
|
2468
|
-
return structure.items.filter(
|
|
2469
|
-
(item) => normalizeSearch(item.textValue).includes(normalized)
|
|
2470
|
-
);
|
|
2476
|
+
const tokens = searchTokens(query);
|
|
2477
|
+
if (tokens.length === 0) return structure.items;
|
|
2478
|
+
return structure.items.filter((item) => matchesSearch(item.textValue, tokens));
|
|
2471
2479
|
}, [query, structure.items]);
|
|
2472
2480
|
const enabledVisibleItems = visibleItems.filter((item) => !item.disabled);
|
|
2473
2481
|
const activeValue = enabledVisibleItems.some((item) => item.value === activeCandidate) ? activeCandidate : enabledVisibleItems[0]?.value ?? null;
|
|
@@ -2506,9 +2514,9 @@ function RichSelect({
|
|
|
2506
2514
|
const setQuery = react.useCallback(
|
|
2507
2515
|
(nextQuery) => {
|
|
2508
2516
|
setQueryState(nextQuery);
|
|
2509
|
-
const
|
|
2517
|
+
const tokens = searchTokens(nextQuery);
|
|
2510
2518
|
const nextItems = structure.items.filter(
|
|
2511
|
-
(item) => !item.disabled && (
|
|
2519
|
+
(item) => !item.disabled && matchesSearch(item.textValue, tokens)
|
|
2512
2520
|
);
|
|
2513
2521
|
setActiveCandidate(nextItems[0]?.value ?? null);
|
|
2514
2522
|
},
|