@dust-tt/sparkle 0.2.203 → 0.2.205

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dust-tt/sparkle",
3
- "version": "0.2.203",
3
+ "version": "0.2.205",
4
4
  "scripts": {
5
5
  "build": "rm -rf dist && rollup -c",
6
6
  "build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
@@ -92,4 +92,4 @@
92
92
  "tailwind-scrollbar-hide": "^1.1.7"
93
93
  },
94
94
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
95
- }
95
+ }
@@ -249,6 +249,7 @@ DataTable.Row = function Row({
249
249
  interface CellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
250
250
  avatarUrl?: string;
251
251
  icon?: React.ComponentType<{ className?: string }>;
252
+ iconClassName?: string;
252
253
  children?: ReactNode;
253
254
  description?: string;
254
255
  }
@@ -258,6 +259,7 @@ DataTable.Cell = function Cell({
258
259
  className,
259
260
  avatarUrl,
260
261
  icon,
262
+ iconClassName,
261
263
  description,
262
264
  ...props
263
265
  }: CellProps) {
@@ -274,7 +276,14 @@ DataTable.Cell = function Cell({
274
276
  <Avatar visual={avatarUrl} size="xs" className="s-mr-2" />
275
277
  )}
276
278
  {icon && (
277
- <Icon visual={icon} size="sm" className="s-mr-2 s-text-element-600" />
279
+ <Icon
280
+ visual={icon}
281
+ size="sm"
282
+ className={classNames(
283
+ "s-mr-2 s-text-element-600",
284
+ iconClassName || ""
285
+ )}
286
+ />
278
287
  )}
279
288
  <div className="s-flex">
280
289
  <span className="s-text-sm s-text-element-800">{children}</span>
@@ -58,6 +58,8 @@ interface TreeItemProps {
58
58
  className?: string;
59
59
  actions?: React.ReactNode;
60
60
  areActionsFading?: boolean;
61
+ isSelected?: boolean;
62
+ onItemClick?: () => void;
61
63
  }
62
64
 
63
65
  export interface TreeItemPropsWithChildren extends TreeItemProps {
@@ -85,6 +87,8 @@ Tree.Item = function ({
85
87
  areActionsFading = true,
86
88
  renderTreeItems,
87
89
  children,
90
+ isSelected = false,
91
+ onItemClick,
88
92
  }: TreeItemPropsWithChildren | TreeItemPropsWithRender) {
89
93
  const [collapsedState, setCollapsedState] = useState<boolean>(
90
94
  defaultCollapsed ?? true
@@ -113,8 +117,13 @@ Tree.Item = function ({
113
117
  className={classNames(
114
118
  className ? className : "",
115
119
  "s-group s-flex s-cursor-default s-flex-row s-items-center s-gap-4",
116
- size === "sm" ? "s-py-1" : "s-py-2"
120
+ size === "sm" ? "s-py-1" : "s-py-2",
121
+ onItemClick ? "s-cursor-pointer" : "",
122
+ isSelected
123
+ ? "s-rounded-md s-border s-border-neutral-200 s-bg-white"
124
+ : ""
117
125
  )}
126
+ onClick={onItemClick ? onItemClick : undefined}
118
127
  >
119
128
  {type === "node" && (
120
129
  <IconButton
@@ -125,7 +134,12 @@ Tree.Item = function ({
125
134
  }
126
135
  size="sm"
127
136
  variant="secondary"
128
- onClick={effectiveOnChevronClick}
137
+ onClick={(e) => {
138
+ e.stopPropagation();
139
+ if (effectiveOnChevronClick) {
140
+ effectiveOnChevronClick();
141
+ }
142
+ }}
129
143
  />
130
144
  )}
131
145
  {type === "leaf" && <div className="s-w-5"></div>}
@@ -1,6 +1,5 @@
1
1
  import type { Meta } from "@storybook/react";
2
2
  import React from "react";
3
- import { v4 as uuidv4 } from "uuid";
4
3
 
5
4
  import { Dust } from "@sparkle/icons/solid";
6
5
 
@@ -33,7 +32,7 @@ export const TreeExample = () => {
33
32
  <div className="s-text-xl">Tree</div>
34
33
  <div>
35
34
  <Tree isBoxed>
36
- <Tree.Item label="item 1 (no children)" variant="folder" />
35
+ <Tree.Item label="item 1 (no children)" variant="folder" isSelected={true}/>
37
36
  <Tree.Item label="item 2 (loading)" variant="folder">
38
37
  <Tree isLoading />
39
38
  </Tree.Item>
@@ -586,11 +585,76 @@ export const TreeExample = () => {
586
585
  </Tree>
587
586
  </div>
588
587
  </div>
588
+ <DummyNavBar/>
589
589
  </div>
590
590
  </div>
591
591
  );
592
592
  };
593
593
 
594
+ export const DummyNavBar = () => {
595
+ return <div className="s-flex s-flex-col s-gap-3">
596
+ <div className="s-text-xl">Nav bar</div>
597
+ <div>
598
+ <Tree isBoxed>
599
+ <Tree.Item
600
+ label="Intercom"
601
+ visual={<IntercomLogo />}
602
+ onItemClick={() => console.log("Clickable")}
603
+ isSelected={true}
604
+ >
605
+ <Tree>
606
+ <Tree.Item
607
+ type="leaf"
608
+ label="item 1"
609
+ checkbox={{
610
+ variant: "checkable",
611
+ checked: false,
612
+ onChange: () => {
613
+ return;
614
+ },
615
+ }}
616
+ />
617
+ <Tree.Item
618
+ label="item 2"
619
+ type="leaf"
620
+ checkbox={{
621
+ variant: "checkable",
622
+ checked: false,
623
+ onChange: () => {
624
+ return;
625
+ },
626
+ }}
627
+ />
628
+ <Tree.Item
629
+ label="item 3"
630
+ type="leaf"
631
+ checkbox={{
632
+ variant: "checkable",
633
+ checked: false,
634
+ onChange: () => {
635
+ return;
636
+ },
637
+ }}
638
+ />
639
+ </Tree>
640
+ </Tree.Item>
641
+ <Tree.Item
642
+ label="Notion"
643
+ visual={<NotionLogo />}
644
+ />
645
+ <Tree.Item
646
+ label="Slack"
647
+ visual={<SlackLogo />}
648
+ />
649
+ <Tree.Item
650
+ label="Dust"
651
+ visual={<Dust />}
652
+ />
653
+ </Tree>
654
+ </div>
655
+ </div>;
656
+ }
657
+
594
658
  export const SelectDataSourceExample = () => {
595
659
  return (
596
660
  <div className="s-flex s-w-full s-flex-col s-gap-10">
@@ -838,30 +902,4 @@ const createTreeItems = (n = 5, getLabel: () => string) => {
838
902
  }
839
903
 
840
904
  return <Tree>{items}</Tree>;
841
- };
842
-
843
- export const DeeplyNestedTreeWithActions = () => {
844
- const getLabel = () =>
845
- `${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}-${uuidv4()}`;
846
- return (
847
- <div className="s-mx-auto s-max-w-2xl s-gap-3 s-pt-10">
848
- <div className="s-pb-10 s-text-xl">Huge</div>
849
- <div>
850
- <Tree>{createTreeItems(20, getLabel)}</Tree>
851
- </div>
852
- </div>
853
- );
854
- };
855
-
856
- export const SmallTreeWithActions = () => {
857
- const getLabel = () =>
858
- `${uuidv4().slice(0, Math.floor(Math.random() * 32) + 3)}`;
859
- return (
860
- <div className="s-mx-auto s-max-w-2xl s-gap-3 s-pt-10">
861
- <div className="s-pb-10 s-text-xl">Huge</div>
862
- <div>
863
- <Tree>{createTreeItems(5, getLabel)}</Tree>
864
- </div>
865
- </div>
866
- );
867
- };
905
+ };