diff --git a/sparkle/package-lock.json b/sparkle/package-lock.json index bba79a7fb03f..80f8a90de2e2 100644 --- a/sparkle/package-lock.json +++ b/sparkle/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dust-tt/sparkle", - "version": "0.2.195", + "version": "0.2.196", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dust-tt/sparkle", - "version": "0.2.195", + "version": "0.2.196", "license": "ISC", "dependencies": { "@emoji-mart/data": "^1.1.2", diff --git a/sparkle/package.json b/sparkle/package.json index 8c6f139f34c9..ec221a11dfd1 100644 --- a/sparkle/package.json +++ b/sparkle/package.json @@ -1,6 +1,6 @@ { "name": "@dust-tt/sparkle", - "version": "0.2.195", + "version": "0.2.196", "scripts": { "build": "rm -rf dist && rollup -c", "build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true", diff --git a/sparkle/src/components/Tree.tsx b/sparkle/src/components/Tree.tsx index ea59c2d63321..0b6d77f7a517 100644 --- a/sparkle/src/components/Tree.tsx +++ b/sparkle/src/components/Tree.tsx @@ -49,6 +49,7 @@ interface TreeItemProps { label?: string; type?: "node" | "item" | "leaf"; variant?: "file" | "folder" | "database" | "channel"; + size?: "sm" | "md"; visual?: React.ReactNode; checkbox?: CheckboxProps; onChevronClick?: () => void; @@ -56,6 +57,7 @@ interface TreeItemProps { defaultCollapsed?: boolean; className?: string; actions?: React.ReactNode; + areActionsFading?: boolean; } export interface TreeItemPropsWithChildren extends TreeItemProps { @@ -73,12 +75,14 @@ Tree.Item = function ({ type = "node", className = "", variant = "file", + size = "sm", visual, checkbox, onChevronClick, collapsed, defaultCollapsed, actions, + areActionsFading = true, renderTreeItems, children, }: TreeItemPropsWithChildren | TreeItemPropsWithRender) { @@ -108,7 +112,8 @@ Tree.Item = function ({
{type === "node" && ( @@ -126,8 +131,13 @@ Tree.Item = function ({ {type === "leaf" &&
} {checkbox && } -
-
+
+
{visual ? ( visual ) : ( @@ -138,9 +148,23 @@ Tree.Item = function ({ /> )} -
{label}
+
+ {label} +
{actions && ( -
+
{actions}
)} diff --git a/sparkle/src/stories/Tree.stories.tsx b/sparkle/src/stories/Tree.stories.tsx index defe65ccf305..2ecf1e7d3776 100644 --- a/sparkle/src/stories/Tree.stories.tsx +++ b/sparkle/src/stories/Tree.stories.tsx @@ -5,7 +5,11 @@ import { v4 as uuidv4 } from "uuid"; import { Dust } from "@sparkle/icons/solid"; import { + Button, + Chip, CloudArrowDownIcon, + Cog6ToothIcon, + DriveLogo, IconButton, IntercomLogo, NotionLogo, @@ -250,11 +254,11 @@ export const TreeExample = () => {
With custom visual
- + } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -266,7 +270,7 @@ export const TreeExample = () => { } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -278,7 +282,7 @@ export const TreeExample = () => { } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -290,7 +294,7 @@ export const TreeExample = () => { } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -303,6 +307,7 @@ export const TreeExample = () => {
+
Tree
@@ -529,11 +534,11 @@ export const TreeExample = () => {
With custom visual
- + } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -545,7 +550,7 @@ export const TreeExample = () => { } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -557,7 +562,7 @@ export const TreeExample = () => { } + visual={} checkbox={{ variant: "checkable", checked: false, @@ -569,7 +574,163 @@ export const TreeExample = () => { } + visual={} + checkbox={{ + variant: "checkable", + checked: false, + onChange: () => { + return; + }, + }} + /> + +
+
+
+
+ ); +}; + +export const SelectDataSourceExample = () => { + return ( +
+
+
+
Display Data source Tree example
+
+ + } + size="md" + areActionsFading={false} + actions={ +
+ + Managed by: Stanislas Polu + + +
+ } + /> + } + areActionsFading={false} + actions={ +
+ + Managed by: Stanislas Polu + + +
+ } + size="md" + /> + } + areActionsFading={false} + size="md" + actions={ +
+ + Managed by: Stanislas Polu + + +
+ } + collapsed={false} + > + + + + + + +
+ } + areActionsFading={false} + size="md" + defaultCollapsed={true} + actions={ +
+ + Managed by: Stanislas Polu + + +
+ } + /> +
+
+
+
+
+
+
Select Data source Tree example
+
+ + } + size="md" + checkbox={{ + variant: "checkable", + checked: false, + onChange: () => { + return; + }, + }} + /> + } + size="md" + checkbox={{ + variant: "checkable", + checked: false, + onChange: () => { + return; + }, + }} + /> + } + size="md" checkbox={{ variant: "checkable", checked: false, @@ -577,6 +738,63 @@ export const TreeExample = () => { return; }, }} + collapsed={false} + > + + { + return; + }, + }} + /> + { + return; + }, + }} + /> + { + return; + }, + }} + /> + { + return; + }, + }} + /> + + + } + size="md" + checkbox={{ + variant: "checkable", + checked: false, + onChange: () => { + return; + }, + }} + defaultCollapsed={true} />