@dust-tt/sparkle 0.4.22 → 0.4.24

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.
@@ -7,6 +7,7 @@ import {
7
7
  DropdownMenu,
8
8
  DropdownMenuCheckboxItem,
9
9
  DropdownMenuContent,
10
+ DropdownMenuFilters,
10
11
  DropdownMenuGroup,
11
12
  DropdownMenuItem,
12
13
  DropdownMenuLabel,
@@ -845,3 +846,84 @@ export const WithTags: Story = {
845
846
  );
846
847
  },
847
848
  };
849
+
850
+ export const WithFilters: Story = {
851
+ render: () => {
852
+ const [selectedFilter, setSelectedFilter] = useState<string | null>("all");
853
+ const [searchText, setSearchText] = useState("");
854
+
855
+ const filters = [
856
+ { label: "All", value: "all" },
857
+ { label: "Documents", value: "documents" },
858
+ { label: "Images", value: "images" },
859
+ { label: "Videos", value: "videos" },
860
+ ];
861
+
862
+ const allItems = [
863
+ { name: "Project Proposal.pdf", type: "documents", icon: DocumentIcon },
864
+ { name: "Q4 Report.docx", type: "documents", icon: DocumentIcon },
865
+ { name: "Team Photo.jpg", type: "images", icon: FolderIcon },
866
+ { name: "Logo Design.png", type: "images", icon: FolderIcon },
867
+ { name: "Product Demo.mp4", type: "videos", icon: FolderIcon },
868
+ { name: "Tutorial.mov", type: "videos", icon: FolderIcon },
869
+ { name: "Budget 2024.xlsx", type: "documents", icon: DocumentIcon },
870
+ { name: "Banner.svg", type: "images", icon: FolderIcon },
871
+ ];
872
+
873
+ const filteredItems =
874
+ selectedFilter === "all"
875
+ ? allItems
876
+ : allItems.filter((item) => item.type === selectedFilter);
877
+
878
+ const searchFilteredItems = filteredItems.filter((item) =>
879
+ item.name.includes(searchText)
880
+ );
881
+
882
+ return (
883
+ <DropdownMenu>
884
+ <DropdownMenuTrigger asChild>
885
+ <Button
886
+ label={`Files (${filteredItems.length})`}
887
+ icon={FolderIcon}
888
+ variant="outline"
889
+ size="sm"
890
+ isSelect
891
+ />
892
+ </DropdownMenuTrigger>
893
+ <DropdownMenuContent
894
+ className="s-w-[320px]"
895
+ dropdownHeaders={
896
+ <>
897
+ <DropdownMenuSearchbar
898
+ value={searchText}
899
+ onChange={setSearchText}
900
+ name="search"
901
+ />
902
+ <DropdownMenuFilters
903
+ filters={filters}
904
+ selectedValues={selectedFilter ? [selectedFilter] : []}
905
+ onSelectFilter={setSelectedFilter}
906
+ />
907
+ </>
908
+ }
909
+ >
910
+ <DropdownMenuSeparator />
911
+ {searchFilteredItems.length > 0 ? (
912
+ searchFilteredItems.map((item) => (
913
+ <DropdownMenuItem
914
+ key={item.name}
915
+ label={item.name}
916
+ icon={item.icon}
917
+ onClick={() => console.log("Selected:", item.name)}
918
+ />
919
+ ))
920
+ ) : (
921
+ <div className="s-flex s-h-24 s-items-center s-justify-center s-text-sm s-text-muted-foreground">
922
+ No items found
923
+ </div>
924
+ )}
925
+ </DropdownMenuContent>
926
+ </DropdownMenu>
927
+ );
928
+ },
929
+ };