@jinaan/uikit 0.1.53 → 0.1.56
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/data-table.d.ts +4 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/index.js +640 -622
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/combobox.tsx +3 -3
- package/src/data-table.tsx +53 -25
package/package.json
CHANGED
package/src/combobox.tsx
CHANGED
|
@@ -206,10 +206,10 @@ export function Combobox({
|
|
|
206
206
|
aria-selected={item.value === value}
|
|
207
207
|
onClick={() => pick(item)}
|
|
208
208
|
className={cn(
|
|
209
|
-
"flex w-full items-center gap-3 rounded-lg px-2 py-
|
|
209
|
+
"flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition-colors",
|
|
210
210
|
item.value === value
|
|
211
|
-
? "bg-(--
|
|
212
|
-
: "hover:bg-(--
|
|
211
|
+
? "bg-(--combobox-search-bg)"
|
|
212
|
+
: "hover:bg-(--combobox-search-bg) focus:bg-(--combobox-search-bg) data-highlighted:bg-(--combobox-search-bg)",
|
|
213
213
|
)}
|
|
214
214
|
>
|
|
215
215
|
{renderItem ? (
|
package/src/data-table.tsx
CHANGED
|
@@ -77,11 +77,14 @@ export interface DataTableFilterOption {
|
|
|
77
77
|
export interface DataTableFilter<T> {
|
|
78
78
|
id: string;
|
|
79
79
|
label: string;
|
|
80
|
-
options
|
|
80
|
+
options?: DataTableFilterOption[];
|
|
81
81
|
value: string[];
|
|
82
82
|
onChange: (value: string[]) => void;
|
|
83
83
|
/** Return true when the row matches the selected filter values. */
|
|
84
84
|
match: (row: T, values: string[]) => boolean;
|
|
85
|
+
/** Use text input instead of checkbox options. */
|
|
86
|
+
type?: "text" | "select";
|
|
87
|
+
placeholder?: string;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
export interface BulkAction<T> {
|
|
@@ -684,39 +687,64 @@ export function DataTable<T>({
|
|
|
684
687
|
<FunnelSimple />
|
|
685
688
|
<span className="font-medium">{filter.label}</span>
|
|
686
689
|
<span className="h-4 w-px bg-line" aria-hidden />
|
|
687
|
-
<span className="text-muted">
|
|
690
|
+
<span className="text-muted max-w-28 truncate">
|
|
688
691
|
{filter.value.length > 0
|
|
689
|
-
?
|
|
692
|
+
? filter.type === "text"
|
|
693
|
+
? filter.value[0]
|
|
694
|
+
: `${filter.value.length} selected`
|
|
690
695
|
: "Enter value"}
|
|
691
696
|
</span>
|
|
692
697
|
<CaretDown className="text-muted" />
|
|
693
698
|
</Button>
|
|
694
699
|
</DropdownMenuTrigger>
|
|
695
|
-
<DropdownMenuContent align="start" className="w-56">
|
|
700
|
+
<DropdownMenuContent align="start" className={filter.type === "text" ? "w-72" : "w-56"}>
|
|
696
701
|
<DropdownMenuLabel className="text-[13px]">
|
|
697
702
|
Filter by {filter.label}
|
|
698
703
|
</DropdownMenuLabel>
|
|
699
|
-
{filter.
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
704
|
+
{filter.type === "text" ? (
|
|
705
|
+
<div className="px-1 pb-1">
|
|
706
|
+
<Input
|
|
707
|
+
value={filter.value[0] ?? ""}
|
|
708
|
+
onChange={(e) => filter.onChange(e.target.value ? [e.target.value] : [])}
|
|
709
|
+
onClear={filter.value[0] ? () => filter.onChange([]) : undefined}
|
|
710
|
+
placeholder={filter.placeholder ?? `Search ${filter.label.toLowerCase()}...`}
|
|
711
|
+
aria-label={filter.placeholder ?? `Search ${filter.label.toLowerCase()}...`}
|
|
712
|
+
leadingIcon={<MagnifyingGlass className="size-3.5" />}
|
|
713
|
+
size="sm"
|
|
714
|
+
className="h-(--control-h-xs) border-0 bg-(--combobox-search-bg) focus-visible:border-muted focus-visible:ring-0"
|
|
715
|
+
/>
|
|
716
|
+
</div>
|
|
717
|
+
) : (
|
|
718
|
+
<>
|
|
719
|
+
{(filter.options ?? []).map((option) => {
|
|
720
|
+
const checked = filter.value.includes(option.value);
|
|
721
|
+
return (
|
|
722
|
+
<DropdownMenuCheckboxItem
|
|
723
|
+
key={option.value}
|
|
724
|
+
checked={checked}
|
|
725
|
+
onCheckedChange={() =>
|
|
726
|
+
filter.onChange(
|
|
727
|
+
checked
|
|
728
|
+
? filter.value.filter((value) => value !== option.value)
|
|
729
|
+
: [...filter.value, option.value],
|
|
730
|
+
)
|
|
731
|
+
}
|
|
732
|
+
onSelect={(e) => e.preventDefault()}
|
|
733
|
+
>
|
|
734
|
+
{option.label}
|
|
735
|
+
</DropdownMenuCheckboxItem>
|
|
736
|
+
);
|
|
737
|
+
})}
|
|
738
|
+
<DropdownMenuSeparator />
|
|
739
|
+
<DropdownMenuItem onSelect={clear}>Clear filter</DropdownMenuItem>
|
|
740
|
+
</>
|
|
741
|
+
)}
|
|
742
|
+
{filter.type === "text" ? (
|
|
743
|
+
<>
|
|
744
|
+
<DropdownMenuSeparator />
|
|
745
|
+
<DropdownMenuItem onSelect={clear}>Clear filter</DropdownMenuItem>
|
|
746
|
+
</>
|
|
747
|
+
) : null}
|
|
720
748
|
</DropdownMenuContent>
|
|
721
749
|
</DropdownMenu>
|
|
722
750
|
</div>
|