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