@krosoft/react 0.0.292 → 0.0.293
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.
|
@@ -3,7 +3,7 @@ export interface FilterOption {
|
|
|
3
3
|
label: string;
|
|
4
4
|
color?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function SearchableFilterPill<T extends string>({ labelKey, options, selected, onToggle, onClear, onSelectAll, searchable, searchPlaceholder, }: {
|
|
6
|
+
export declare function SearchableFilterPill<T extends string>({ labelKey, options, selected, onToggle, onClear, onSelectAll, searchable, searchPlaceholder, className, }: {
|
|
7
7
|
labelKey: string;
|
|
8
8
|
options: FilterOption[];
|
|
9
9
|
selected: T[];
|
|
@@ -12,5 +12,6 @@ export declare function SearchableFilterPill<T extends string>({ labelKey, optio
|
|
|
12
12
|
onSelectAll?: (values: T[]) => void;
|
|
13
13
|
searchable?: boolean;
|
|
14
14
|
searchPlaceholder?: string;
|
|
15
|
+
className?: string;
|
|
15
16
|
}): React.ReactElement;
|
|
16
17
|
//# sourceMappingURL=SearchableFilterPill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchableFilterPill.d.ts","sourceRoot":"","sources":["../../../../src/components/core/filters/SearchableFilterPill.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,EACrD,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAkB,EAClB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"SearchableFilterPill.d.ts","sourceRoot":"","sources":["../../../../src/components/core/filters/SearchableFilterPill.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,EACrD,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAkB,EAClB,iBAAiB,EACjB,SAAiC,GAClC,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,KAAK,CAAC,YAAY,CA4IrB"}
|
|
@@ -275,24 +275,26 @@ function G({ options: e, value: t, onChange: n, variant: r = "solid" }) {
|
|
|
275
275
|
}
|
|
276
276
|
//#endregion
|
|
277
277
|
//#region src/components/core/filters/SearchableFilterPill.tsx
|
|
278
|
-
function K({ labelKey: n, options: r, selected: o, onToggle: s, onClear: c, onSelectAll: u, searchable: f = !1, searchPlaceholder: m }) {
|
|
279
|
-
let { t:
|
|
278
|
+
function K({ labelKey: n, options: r, selected: o, onToggle: s, onClear: c, onSelectAll: u, searchable: f = !1, searchPlaceholder: m, className: h = "w-full md:w-[180px]" }) {
|
|
279
|
+
let { t: g } = t(), [_, v] = k(""), y = o.length > 0, b = O(() => _ === "" ? r : r.filter((e) => e.label.toLowerCase().includes(_.toLowerCase())), [r, _]), x = O(() => b.length !== 0 && b.every((e) => o.includes(e.value)), [b, o]);
|
|
280
280
|
return /* @__PURE__ */ j(p, {
|
|
281
281
|
onOpenChange: () => {
|
|
282
|
-
|
|
282
|
+
v("");
|
|
283
283
|
},
|
|
284
284
|
children: [/* @__PURE__ */ A(l, {
|
|
285
285
|
asChild: !0,
|
|
286
286
|
children: /* @__PURE__ */ j("button", {
|
|
287
|
-
className: e(a, "inline-flex items-center gap-1.5 whitespace-nowrap transition-colors",
|
|
288
|
-
children: [
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
className: e(a, "inline-flex items-center justify-between gap-1.5 whitespace-nowrap transition-colors", y ? "border-primary bg-primary/10 text-primary font-medium" : "hover:bg-muted", h),
|
|
288
|
+
children: [/* @__PURE__ */ A("span", {
|
|
289
|
+
className: "truncate",
|
|
290
|
+
children: g(n)
|
|
291
|
+
}), /* @__PURE__ */ j("div", {
|
|
292
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
293
|
+
children: [o.length > 0 && /* @__PURE__ */ A("span", {
|
|
291
294
|
className: "flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground",
|
|
292
295
|
children: o.length
|
|
293
|
-
}),
|
|
294
|
-
|
|
295
|
-
]
|
|
296
|
+
}), /* @__PURE__ */ A(N, { className: "size-3.5 opacity-60" })]
|
|
297
|
+
})]
|
|
296
298
|
})
|
|
297
299
|
}), /* @__PURE__ */ j(d, {
|
|
298
300
|
className: "w-72 max-w-[var(--radix-popover-content-available-width)] p-0",
|
|
@@ -304,10 +306,10 @@ function K({ labelKey: n, options: r, selected: o, onToggle: s, onClear: c, onSe
|
|
|
304
306
|
className: "relative",
|
|
305
307
|
children: [/* @__PURE__ */ A(F, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }), /* @__PURE__ */ A("input", {
|
|
306
308
|
className: "w-full rounded-control bg-muted/50 py-1.5 pl-7 pr-2 text-sm text-foreground placeholder:text-muted-foreground outline-none focus:ring-1 focus:ring-ring",
|
|
307
|
-
placeholder: m ??
|
|
308
|
-
value:
|
|
309
|
+
placeholder: m ?? g("search.placeholder"),
|
|
310
|
+
value: _,
|
|
309
311
|
onChange: (e) => {
|
|
310
|
-
|
|
312
|
+
v(e.target.value);
|
|
311
313
|
},
|
|
312
314
|
autoFocus: !0
|
|
313
315
|
})]
|
|
@@ -315,10 +317,10 @@ function K({ labelKey: n, options: r, selected: o, onToggle: s, onClear: c, onSe
|
|
|
315
317
|
}) : null,
|
|
316
318
|
/* @__PURE__ */ j("div", {
|
|
317
319
|
className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto overflow-x-hidden p-1.5",
|
|
318
|
-
children: [
|
|
320
|
+
children: [b.length === 0 && /* @__PURE__ */ A("p", {
|
|
319
321
|
className: "px-2 py-3 text-center text-xs text-muted-foreground",
|
|
320
|
-
children:
|
|
321
|
-
}),
|
|
322
|
+
children: g("states.noResult")
|
|
323
|
+
}), b.map((e) => /* @__PURE__ */ j("label", {
|
|
322
324
|
className: "flex min-w-0 items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors",
|
|
323
325
|
children: [
|
|
324
326
|
/* @__PURE__ */ A("span", {
|
|
@@ -342,37 +344,37 @@ function K({ labelKey: n, options: r, selected: o, onToggle: s, onClear: c, onSe
|
|
|
342
344
|
]
|
|
343
345
|
}, e.value))]
|
|
344
346
|
}),
|
|
345
|
-
|
|
347
|
+
b.length > 0 && /* @__PURE__ */ A("div", {
|
|
346
348
|
className: "border-t border-border p-1.5",
|
|
347
|
-
children:
|
|
349
|
+
children: x ? /* @__PURE__ */ A("button", {
|
|
348
350
|
onClick: () => {
|
|
349
351
|
c === void 0 ? o.forEach((e) => {
|
|
350
352
|
s(e);
|
|
351
353
|
}) : c();
|
|
352
354
|
},
|
|
353
355
|
className: "w-full rounded-md px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors text-center",
|
|
354
|
-
children:
|
|
356
|
+
children: g("filters.deselectAll")
|
|
355
357
|
}) : /* @__PURE__ */ A("button", {
|
|
356
358
|
type: "button",
|
|
357
359
|
onClick: () => {
|
|
358
|
-
if (
|
|
360
|
+
if (x) {
|
|
359
361
|
if (u !== void 0) {
|
|
360
|
-
let e =
|
|
362
|
+
let e = b.map((e) => e.value);
|
|
361
363
|
u(o.filter((t) => !e.includes(t)));
|
|
362
364
|
} else c === void 0 ? o.forEach((e) => {
|
|
363
365
|
s(e);
|
|
364
366
|
}) : c();
|
|
365
367
|
} else if (u !== void 0) {
|
|
366
368
|
let e = [...o];
|
|
367
|
-
|
|
369
|
+
b.forEach((t) => {
|
|
368
370
|
e.includes(t.value) || e.push(t.value);
|
|
369
371
|
}), u(e);
|
|
370
|
-
} else
|
|
372
|
+
} else b.forEach((e) => {
|
|
371
373
|
o.includes(e.value) || s(e.value);
|
|
372
374
|
});
|
|
373
375
|
},
|
|
374
376
|
className: "w-full rounded-md px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors text-center",
|
|
375
|
-
children:
|
|
377
|
+
children: g("filters.selectAll")
|
|
376
378
|
})
|
|
377
379
|
})
|
|
378
380
|
]
|