···
.filter((f) => f.length > 0);
+
const exclusions: { pattern: string; hasWildcard: boolean }[] = [];
+
const inclusions: { pattern: string; hasWildcard: boolean }[] = [];
+
const lower = f.slice(1).toLowerCase();
+
hasWildcard: lower.includes("*"),
+
const lower = f.toLowerCase();
+
hasWildcard: lower.includes("*"),
+
const matchesPattern = (value: string, filter: { pattern: string; hasWildcard: boolean }) => {
+
if (filter.hasWildcard) {
+
// Convert wildcard pattern to regex
+
const regexPattern = filter.pattern
+
.replace(/[.+?^${}()|[\]\\]/g, "\\$&") // Escape special regex chars except *
+
.replace(/\*/g, ".*"); // Replace * with .*
+
const regex = new RegExp(`^${regexPattern}$`);
+
return regex.test(value);
+
return value === filter.pattern;
return labels().filter((label) => {
const labelValue = label.val.toLowerCase();
+
if (exclusions.some((exc) => matchesPattern(labelValue, exc))) {
+
// If there are inclusions, at least one must match
if (inclusions.length > 0) {
+
return inclusions.some((inc) => matchesPattern(labelValue, inc));
// If only exclusions were specified, include everything not excluded
···
<div class="flex w-full items-center gap-x-2">
+
placeholder="Filter labels (* for partial, -exclude)"
onInput={(e) => setFilter(e.currentTarget.value)}