@dust-tt/sparkle 0.2.285 → 0.2.287-rc-1

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.
@@ -2,11 +2,19 @@ import type { Meta } from "@storybook/react";
2
2
  import React, { useEffect, useState } from "react";
3
3
 
4
4
  import {
5
+ Button,
6
+ MoreIcon,
5
7
  NavigationList,
6
8
  NavigationListItem,
7
9
  NavigationListLabel,
10
+ NewDropdownMenu,
11
+ NewDropdownMenuContent,
12
+ NewDropdownMenuItem,
13
+ NewDropdownMenuTrigger,
14
+ PencilSquareIcon,
8
15
  ScrollArea,
9
16
  ScrollBar,
17
+ TrashIcon,
10
18
  } from "../index_with_tw_base";
11
19
 
12
20
  const meta = {
@@ -27,17 +35,35 @@ export const NewNavigationListDemo = () => {
27
35
  >([]);
28
36
 
29
37
  useEffect(() => {
30
- // Generate random titles for each date section only once
31
38
  setConversationTitles([
32
39
  { label: "Today", items: getRandomTitles(5) },
33
40
  { label: "Yesterday", items: getRandomTitles(10) },
34
41
  ]);
35
- console.log(conversationTitles); // Add this line
36
42
  }, []);
37
43
 
38
- // Flatten the items array to easily manage indices
39
44
  const allItems = conversationTitles.flatMap((section) => section.items);
40
45
 
46
+ const getMoreMenu = (title: string) => (
47
+ <NewDropdownMenu>
48
+ <NewDropdownMenuTrigger asChild>
49
+ <Button variant="ghost" icon={MoreIcon} size="xs" />
50
+ </NewDropdownMenuTrigger>
51
+ <NewDropdownMenuContent>
52
+ <NewDropdownMenuItem
53
+ label={`Rename ${title}`}
54
+ icon={PencilSquareIcon}
55
+ onClick={(e) => e.stopPropagation()}
56
+ />
57
+ <NewDropdownMenuItem
58
+ label="Delete"
59
+ icon={TrashIcon}
60
+ variant="warning"
61
+ onClick={(e) => e.stopPropagation()}
62
+ />
63
+ </NewDropdownMenuContent>
64
+ </NewDropdownMenu>
65
+ );
66
+
41
67
  return (
42
68
  <div className="s-h-[400px] s-w-[200px] s-py-12">
43
69
  <ScrollArea>
@@ -46,7 +72,7 @@ export const NewNavigationListDemo = () => {
46
72
  <React.Fragment key={sectionIndex}>
47
73
  <NavigationListLabel label={section.label} />
48
74
  {section.items.map((title, index) => {
49
- const itemIndex = allItems.indexOf(title); // Calculate the global index
75
+ const itemIndex = allItems.indexOf(title);
50
76
  return (
51
77
  <NavigationListItem
52
78
  key={index}
@@ -54,6 +80,7 @@ export const NewNavigationListDemo = () => {
54
80
  onClick={() => setSelectedIndex(itemIndex)}
55
81
  label={title}
56
82
  className="s-w-full"
83
+ moreMenu={getMoreMenu(title)}
57
84
  />
58
85
  );
59
86
  })}