@dust-tt/sparkle 0.2.645 → 0.2.646-rc-2
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/cjs/index.js +1 -1
- package/dist/esm/components/DataTable.d.ts +3 -13
- package/dist/esm/components/DataTable.d.ts.map +1 -1
- package/dist/esm/components/DataTable.js +8 -9
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/markdown/BlockquoteBlock.d.ts +3 -1
- package/dist/esm/components/markdown/BlockquoteBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/BlockquoteBlock.js +7 -3
- package/dist/esm/components/markdown/BlockquoteBlock.js.map +1 -1
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts +4 -2
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts.map +1 -1
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js +11 -6
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js.map +1 -1
- package/dist/esm/components/markdown/HeaderBlocks.d.ts +24 -0
- package/dist/esm/components/markdown/HeaderBlocks.d.ts.map +1 -0
- package/dist/esm/components/markdown/HeaderBlocks.js +54 -0
- package/dist/esm/components/markdown/HeaderBlocks.js.map +1 -0
- package/dist/esm/components/markdown/InputBlock.d.ts +10 -0
- package/dist/esm/components/markdown/InputBlock.d.ts.map +1 -0
- package/dist/esm/components/markdown/InputBlock.js +26 -0
- package/dist/esm/components/markdown/InputBlock.js.map +1 -0
- package/dist/esm/components/markdown/LinkBlock.d.ts +10 -0
- package/dist/esm/components/markdown/LinkBlock.d.ts.map +1 -0
- package/dist/esm/components/markdown/LinkBlock.js +11 -0
- package/dist/esm/components/markdown/LinkBlock.js.map +1 -0
- package/dist/esm/components/markdown/List.d.ts +17 -3
- package/dist/esm/components/markdown/List.d.ts.map +1 -1
- package/dist/esm/components/markdown/List.js +21 -7
- package/dist/esm/components/markdown/List.js.map +1 -1
- package/dist/esm/components/markdown/Markdown.d.ts +2 -9
- package/dist/esm/components/markdown/Markdown.d.ts.map +1 -1
- package/dist/esm/components/markdown/Markdown.js +45 -66
- package/dist/esm/components/markdown/Markdown.js.map +1 -1
- package/dist/esm/components/markdown/ParagraphBlock.d.ts +3 -1
- package/dist/esm/components/markdown/ParagraphBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/ParagraphBlock.js +7 -3
- package/dist/esm/components/markdown/ParagraphBlock.js.map +1 -1
- package/dist/esm/components/markdown/PreBlock.d.ts +3 -1
- package/dist/esm/components/markdown/PreBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/PreBlock.js +7 -3
- package/dist/esm/components/markdown/PreBlock.js.map +1 -1
- package/dist/esm/components/markdown/TableBlock.d.ts +17 -11
- package/dist/esm/components/markdown/TableBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/TableBlock.js +18 -14
- package/dist/esm/components/markdown/TableBlock.js.map +1 -1
- package/dist/esm/components/markdown/TextFormattingBlocks.d.ts +10 -0
- package/dist/esm/components/markdown/TextFormattingBlocks.d.ts.map +1 -0
- package/dist/esm/components/markdown/TextFormattingBlocks.js +12 -0
- package/dist/esm/components/markdown/TextFormattingBlocks.js.map +1 -0
- package/dist/esm/components/markdown/index.d.ts +4 -0
- package/dist/esm/components/markdown/index.d.ts.map +1 -1
- package/dist/esm/components/markdown/index.js +4 -0
- package/dist/esm/components/markdown/index.js.map +1 -1
- package/dist/esm/components/markdown/types.d.ts +13 -0
- package/dist/esm/components/markdown/types.d.ts.map +1 -0
- package/dist/esm/components/markdown/types.js +2 -0
- package/dist/esm/components/markdown/types.js.map +1 -0
- package/dist/esm/components/markdown/useAnimatedText.d.ts +2 -0
- package/dist/esm/components/markdown/useAnimatedText.d.ts.map +1 -0
- package/dist/esm/components/markdown/useAnimatedText.js +31 -0
- package/dist/esm/components/markdown/useAnimatedText.js.map +1 -0
- package/dist/esm/components/markdown/utils.d.ts +11 -0
- package/dist/esm/components/markdown/utils.d.ts.map +1 -1
- package/dist/esm/components/markdown/utils.js +21 -0
- package/dist/esm/components/markdown/utils.js.map +1 -1
- package/dist/esm/stories/DataTable.stories.d.ts +0 -1
- package/dist/esm/stories/DataTable.stories.d.ts.map +1 -1
- package/dist/esm/stories/DataTable.stories.js +0 -188
- package/dist/esm/stories/DataTable.stories.js.map +1 -1
- package/dist/esm/styles/global.css +0 -12
- package/dist/esm/styles/global_with_tw_base.css +0 -12
- package/dist/esm/styles/tailwind.css +0 -11
- package/dist/sparkle.css +0 -34
- package/package.json +2 -1
- package/src/components/DataTable.tsx +2 -31
- package/src/components/markdown/BlockquoteBlock.tsx +36 -29
- package/src/components/markdown/CodeBlockWithExtendedSupport.tsx +142 -131
- package/src/components/markdown/HeaderBlocks.tsx +160 -0
- package/src/components/markdown/InputBlock.tsx +60 -0
- package/src/components/markdown/LinkBlock.tsx +36 -0
- package/src/components/markdown/List.tsx +53 -30
- package/src/components/markdown/Markdown.tsx +108 -171
- package/src/components/markdown/ParagraphBlock.tsx +18 -12
- package/src/components/markdown/PreBlock.tsx +28 -18
- package/src/components/markdown/TableBlock.tsx +125 -95
- package/src/components/markdown/TextFormattingBlocks.tsx +31 -0
- package/src/components/markdown/index.ts +4 -0
- package/src/components/markdown/types.ts +5 -0
- package/src/components/markdown/useAnimatedText.ts +36 -0
- package/src/components/markdown/utils.ts +37 -0
- package/src/stories/DataTable.stories.tsx +0 -235
- package/src/styles/global.css +0 -12
- package/src/styles/global_with_tw_base.css +0 -12
- package/src/styles/tailwind.css +0 -11
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import React, { ReactNode, useMemo } from "react";
|
|
2
|
+
import React, { memo, ReactNode, useMemo } from "react";
|
|
3
3
|
|
|
4
4
|
import { ScrollArea, ScrollBar } from "@sparkle/components";
|
|
5
5
|
import { ContentBlockWrapper } from "@sparkle/components/markdown/ContentBlockWrapper";
|
|
6
6
|
|
|
7
|
+
import { MarkdownNode } from "./types";
|
|
8
|
+
import { sameNodePosition } from "./utils";
|
|
9
|
+
|
|
7
10
|
const getNodeText = (node: ReactNode): string => {
|
|
8
11
|
if (["string", "number"].includes(typeof node)) {
|
|
9
12
|
return node as string;
|
|
@@ -18,100 +21,127 @@ const getNodeText = (node: ReactNode): string => {
|
|
|
18
21
|
return "";
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
export const MemoTableBlock = memo(
|
|
25
|
+
({ children }: { children: React.ReactNode; node?: MarkdownNode }) => {
|
|
26
|
+
const tableData = useMemo(() => {
|
|
27
|
+
const [headNode, bodyNode] = Array.from(children as [any, any]);
|
|
28
|
+
if (
|
|
29
|
+
!headNode ||
|
|
30
|
+
!bodyNode ||
|
|
31
|
+
!("props" in headNode) ||
|
|
32
|
+
!("props" in bodyNode)
|
|
33
|
+
) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const headCells = headNode.props.children[0].props.children.map(
|
|
38
|
+
(c: any) => getNodeText(c.props.children)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const headHtml = `<thead><tr>${headCells
|
|
42
|
+
.map((c: any) => `<th><b>${c}</b></th>`)
|
|
43
|
+
.join("")}</tr></thead>`;
|
|
44
|
+
const headPlain = headCells.join("\t");
|
|
45
|
+
|
|
46
|
+
const bodyRows = bodyNode.props.children.map((row: any) =>
|
|
47
|
+
row.props.children.map((cell: any) => {
|
|
48
|
+
const children = cell.props.children;
|
|
49
|
+
return (Array.isArray(children) ? children : [children])
|
|
50
|
+
.map((child: any) =>
|
|
51
|
+
child?.type?.name === "CiteBlock" ? "" : getNodeText(child)
|
|
52
|
+
)
|
|
53
|
+
.join("");
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
const bodyHtml = `<tbody>${bodyRows
|
|
57
|
+
.map((row: any) => {
|
|
58
|
+
return `<tr>${row
|
|
59
|
+
.map((cell: any) => `<td>${cell}</td>`)
|
|
60
|
+
.join("")}</tr>`;
|
|
61
|
+
})
|
|
62
|
+
.join("")}</tbody>`;
|
|
63
|
+
const bodyPlain = bodyRows.map((row: any) => row.join("\t")).join("\n");
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
"text/html": `<table>${headHtml}${bodyHtml}</table>`,
|
|
67
|
+
"text/plain": headPlain + "\n" + bodyPlain,
|
|
68
|
+
};
|
|
69
|
+
}, [children]);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<ContentBlockWrapper
|
|
73
|
+
innerClassName="s-relative s-my-2 s-w-full s-border s-border-border dark:s-border-border-night s-rounded-2xl"
|
|
74
|
+
content={tableData}
|
|
75
|
+
>
|
|
76
|
+
<ScrollArea className="s-w-full s-rounded-2xl">
|
|
77
|
+
<table className="s-w-full">{children}</table>
|
|
78
|
+
<ScrollBar orientation="horizontal" />
|
|
79
|
+
</ScrollArea>
|
|
80
|
+
</ContentBlockWrapper>
|
|
35
81
|
);
|
|
82
|
+
},
|
|
83
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
84
|
+
);
|
|
36
85
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (Array.isArray(children) ? children : [children])
|
|
46
|
-
.map((child: any) =>
|
|
47
|
-
child?.type?.name === "CiteBlock" ? "" : getNodeText(child)
|
|
48
|
-
)
|
|
49
|
-
.join("");
|
|
50
|
-
})
|
|
86
|
+
MemoTableBlock.displayName = "TableBlock";
|
|
87
|
+
|
|
88
|
+
export const MemoTableHeadBlock = memo(
|
|
89
|
+
({ children }: { children: React.ReactNode; node?: MarkdownNode }) => {
|
|
90
|
+
return (
|
|
91
|
+
<thead className="s-bg-muted-background s-px-2 s-py-2 dark:s-bg-muted-background-night">
|
|
92
|
+
{children}
|
|
93
|
+
</thead>
|
|
51
94
|
);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{Array.isArray(children) ? (
|
|
106
|
-
children.map((child: any, i) => {
|
|
107
|
-
if (child === "<br>") {
|
|
108
|
-
return <br key={i} />;
|
|
109
|
-
}
|
|
110
|
-
return <React.Fragment key={i}>{child}</React.Fragment>;
|
|
111
|
-
})
|
|
112
|
-
) : (
|
|
113
|
-
<>{children}</>
|
|
114
|
-
)}
|
|
115
|
-
</td>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
95
|
+
},
|
|
96
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
MemoTableHeadBlock.displayName = "TableHeadBlock";
|
|
100
|
+
|
|
101
|
+
export const MemoTableBodyBlock = memo(
|
|
102
|
+
({ children }: { children: React.ReactNode; node?: MarkdownNode }) => {
|
|
103
|
+
return (
|
|
104
|
+
<tbody className="s-bg-white dark:s-bg-background-night">
|
|
105
|
+
{children}
|
|
106
|
+
</tbody>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
MemoTableBodyBlock.displayName = "TableBodyBlock";
|
|
113
|
+
|
|
114
|
+
export const MemoTableHeaderBlock = memo(
|
|
115
|
+
({ children }: { children: React.ReactNode; node?: MarkdownNode }) => {
|
|
116
|
+
return (
|
|
117
|
+
<th className="s-truncate s-whitespace-nowrap s-break-words s-py-3.5 s-pl-4 s-text-left s-text-xs s-font-semibold s-text-muted-foreground dark:s-text-muted-foreground-night">
|
|
118
|
+
{children}
|
|
119
|
+
</th>
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
MemoTableHeaderBlock.displayName = "TableHeaderBlock";
|
|
126
|
+
|
|
127
|
+
export const MemoTableDataBlock = memo(
|
|
128
|
+
({ children }: { children: React.ReactNode; node?: MarkdownNode }) => {
|
|
129
|
+
return (
|
|
130
|
+
<td className="s-px-4 s-py-3 s-text-sm s-text-foreground dark:s-text-foreground-night">
|
|
131
|
+
{Array.isArray(children) ? (
|
|
132
|
+
children.map((child: any, i) => {
|
|
133
|
+
if (child === "<br>") {
|
|
134
|
+
return <br key={i} />;
|
|
135
|
+
}
|
|
136
|
+
return <React.Fragment key={i}>{child}</React.Fragment>;
|
|
137
|
+
})
|
|
138
|
+
) : (
|
|
139
|
+
<>{children}</>
|
|
140
|
+
)}
|
|
141
|
+
</td>
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
MemoTableDataBlock.displayName = "TableDataBlock";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { memo } from "react";
|
|
2
|
+
|
|
3
|
+
import { sameNodePosition } from "@sparkle/components/markdown/utils";
|
|
4
|
+
|
|
5
|
+
import { MarkdownNode } from "./types";
|
|
6
|
+
|
|
7
|
+
interface StrongBlockProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
node?: MarkdownNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MemoStrongBlock = memo(
|
|
13
|
+
({ children }: StrongBlockProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<strong className="s-font-semibold s-text-foreground dark:s-text-foreground-night">
|
|
16
|
+
{children}
|
|
17
|
+
</strong>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
MemoStrongBlock.displayName = "StrongBlock";
|
|
24
|
+
|
|
25
|
+
export const MemoHorizontalRuleBlock = memo(() => {
|
|
26
|
+
return (
|
|
27
|
+
<div className="s-my-6 s-border-b s-border-primary-150 dark:s-border-primary-150-night" />
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
MemoHorizontalRuleBlock.displayName = "HorizontalRuleBlock";
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export * from "./CodeBlock";
|
|
2
2
|
export * from "./CodeBlockWithExtendedSupport";
|
|
3
3
|
export * from "./ContentBlockWrapper";
|
|
4
|
+
export * from "./HeaderBlocks";
|
|
5
|
+
export * from "./InputBlock";
|
|
6
|
+
export * from "./LinkBlock";
|
|
4
7
|
export * from "./Markdown";
|
|
5
8
|
export * from "./MarkdownContentContext";
|
|
6
9
|
export * from "./PrettyJsonViewer";
|
|
7
10
|
export * from "./TableBlock";
|
|
11
|
+
export * from "./TextFormattingBlocks";
|
|
8
12
|
export * from "./utils";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { animate } from "framer-motion";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
const delimiter = /(?=[\s\S])/;
|
|
5
|
+
|
|
6
|
+
export function useAnimatedText(text: string, shouldAnimate: boolean) {
|
|
7
|
+
const [cursor, setCursor] = useState(0);
|
|
8
|
+
const [startingCursor, setStartingCursor] = useState(0);
|
|
9
|
+
const [prevText, setPrevText] = useState(text);
|
|
10
|
+
|
|
11
|
+
if (prevText !== text) {
|
|
12
|
+
setPrevText(text);
|
|
13
|
+
setStartingCursor(cursor);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (shouldAnimate) {
|
|
18
|
+
const textParts = text.split(delimiter);
|
|
19
|
+
const controls = animate(startingCursor, textParts.length, {
|
|
20
|
+
duration: 4,
|
|
21
|
+
ease: "easeOut",
|
|
22
|
+
onUpdate(latest) {
|
|
23
|
+
setCursor(Math.floor(latest));
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return () => controls.stop();
|
|
28
|
+
}
|
|
29
|
+
}, [startingCursor, text]);
|
|
30
|
+
|
|
31
|
+
if (!shouldAnimate) {
|
|
32
|
+
return text;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return text.split(delimiter).slice(0, cursor).join("");
|
|
36
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MarkdownNode } from "./types";
|
|
2
|
+
|
|
1
3
|
export function sanitizeContent(str: string): string {
|
|
2
4
|
// (1) Add closing backticks if they are missing such that we render a code block or inline
|
|
3
5
|
// element during streaming.
|
|
@@ -39,3 +41,38 @@ export function detectLanguage(children: React.ReactNode) {
|
|
|
39
41
|
|
|
40
42
|
return "text";
|
|
41
43
|
}
|
|
44
|
+
|
|
45
|
+
export function sameNodePosition(
|
|
46
|
+
prev?: MarkdownNode,
|
|
47
|
+
next?: MarkdownNode
|
|
48
|
+
): boolean {
|
|
49
|
+
if (!(prev?.position || next?.position)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (!(prev?.position && next?.position)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const prevStart = prev.position.start;
|
|
57
|
+
const nextStart = next.position.start;
|
|
58
|
+
const prevEnd = prev.position.end;
|
|
59
|
+
const nextEnd = next.position.end;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
prevStart?.line === nextStart?.line &&
|
|
63
|
+
prevStart?.column === nextStart?.column &&
|
|
64
|
+
prevEnd?.line === nextEnd?.line &&
|
|
65
|
+
prevEnd?.column === nextEnd?.column
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function sameTextStyling(
|
|
70
|
+
prev: { textColor?: string; textSize?: string; forcedTextSize?: string },
|
|
71
|
+
next: { textColor?: string; textSize?: string; forcedTextSize?: string }
|
|
72
|
+
): boolean {
|
|
73
|
+
return (
|
|
74
|
+
prev.textColor === next.textColor &&
|
|
75
|
+
prev.textSize === next.textSize &&
|
|
76
|
+
prev.forcedTextSize === next.forcedTextSize
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -52,7 +52,6 @@ type Data = {
|
|
|
52
52
|
>;
|
|
53
53
|
id?: number;
|
|
54
54
|
roundedAvatar?: boolean;
|
|
55
|
-
avatarStack?: { name: string; visual: string }[];
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
type TransformedData = {
|
|
@@ -182,130 +181,6 @@ const data: TransformedData[] = [
|
|
|
182
181
|
},
|
|
183
182
|
];
|
|
184
183
|
|
|
185
|
-
const avatarStackData: TransformedData[] = [
|
|
186
|
-
{
|
|
187
|
-
name: "Team Alpha",
|
|
188
|
-
description: "Development team",
|
|
189
|
-
usedBy: 12,
|
|
190
|
-
addedBy: "Project Manager",
|
|
191
|
-
lastUpdated: "2024-01-15",
|
|
192
|
-
size: "256kb",
|
|
193
|
-
avatarStack: [
|
|
194
|
-
{
|
|
195
|
-
name: "Alice Johnson",
|
|
196
|
-
visual: "https://avatars.githubusercontent.com/u/1?s=200&v=4",
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
name: "Bob Smith",
|
|
200
|
-
visual: "https://avatars.githubusercontent.com/u/2?s=200&v=4",
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
name: "Carol Davis",
|
|
204
|
-
visual: "https://avatars.githubusercontent.com/u/3?s=200&v=4",
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
name: "David Wilson",
|
|
208
|
-
visual: "https://avatars.githubusercontent.com/u/4?s=200&v=4",
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
name: "Eve Brown",
|
|
212
|
-
visual: "https://avatars.githubusercontent.com/u/5?s=200&v=4",
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
onClick: () => alert("Team Alpha clicked"),
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: "Marketing Team",
|
|
219
|
-
description: "Marketing and communications",
|
|
220
|
-
usedBy: 8,
|
|
221
|
-
addedBy: "Marketing Director",
|
|
222
|
-
lastUpdated: "2024-01-14",
|
|
223
|
-
size: "128kb",
|
|
224
|
-
avatarStack: [
|
|
225
|
-
{
|
|
226
|
-
name: "Frank Miller",
|
|
227
|
-
visual: "https://avatars.githubusercontent.com/u/6?s=200&v=4",
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: "Grace Lee",
|
|
231
|
-
visual: "https://avatars.githubusercontent.com/u/7?s=200&v=4",
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
name: "Henry Taylor",
|
|
235
|
-
visual: "https://avatars.githubusercontent.com/u/8?s=200&v=4",
|
|
236
|
-
},
|
|
237
|
-
],
|
|
238
|
-
onClick: () => alert("Marketing Team clicked"),
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: "Design Squad",
|
|
242
|
-
description: "UI/UX design team",
|
|
243
|
-
usedBy: 6,
|
|
244
|
-
addedBy: "Design Lead",
|
|
245
|
-
lastUpdated: "2024-01-13",
|
|
246
|
-
size: "512kb",
|
|
247
|
-
avatarStack: [
|
|
248
|
-
{
|
|
249
|
-
name: "Ivy Chen",
|
|
250
|
-
visual: "https://avatars.githubusercontent.com/u/9?s=200&v=4",
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
name: "Jack Rodriguez",
|
|
254
|
-
visual: "https://avatars.githubusercontent.com/u/10?s=200&v=4",
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: "Kate Anderson",
|
|
258
|
-
visual: "https://avatars.githubusercontent.com/u/11?s=200&v=4",
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
name: "Liam Thompson",
|
|
262
|
-
visual: "https://avatars.githubusercontent.com/u/12?s=200&v=4",
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
roundedAvatar: true,
|
|
266
|
-
onClick: () => alert("Design Squad clicked"),
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
name: "Large Team",
|
|
270
|
-
description: "Cross-functional team with many members",
|
|
271
|
-
usedBy: 25,
|
|
272
|
-
addedBy: "Team Lead",
|
|
273
|
-
lastUpdated: "2024-01-12",
|
|
274
|
-
size: "1.2mb",
|
|
275
|
-
avatarStack: [
|
|
276
|
-
{
|
|
277
|
-
name: "Maya Patel",
|
|
278
|
-
visual: "https://avatars.githubusercontent.com/u/13?s=200&v=4",
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
name: "Noah Garcia",
|
|
282
|
-
visual: "https://avatars.githubusercontent.com/u/14?s=200&v=4",
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
name: "Olivia Martinez",
|
|
286
|
-
visual: "https://avatars.githubusercontent.com/u/15?s=200&v=4",
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
name: "Paul Kim",
|
|
290
|
-
visual: "https://avatars.githubusercontent.com/u/16?s=200&v=4",
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
name: "Quinn White",
|
|
294
|
-
visual: "https://avatars.githubusercontent.com/u/17?s=200&v=4",
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
name: "Rachel Green",
|
|
298
|
-
visual: "https://avatars.githubusercontent.com/u/18?s=200&v=4",
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
name: "Sam Johnson",
|
|
302
|
-
visual: "https://avatars.githubusercontent.com/u/19?s=200&v=4",
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
onClick: () => alert("Large Team clicked"),
|
|
306
|
-
},
|
|
307
|
-
];
|
|
308
|
-
|
|
309
184
|
const columns: ColumnDef<Data>[] = [
|
|
310
185
|
{
|
|
311
186
|
accessorKey: "name",
|
|
@@ -895,113 +770,3 @@ export const DataTableWithRadioSelectionExample = () => {
|
|
|
895
770
|
</div>
|
|
896
771
|
);
|
|
897
772
|
};
|
|
898
|
-
|
|
899
|
-
// Column definition for avatar stack story
|
|
900
|
-
const avatarStackColumns: ColumnDef<Data>[] = [
|
|
901
|
-
{
|
|
902
|
-
accessorKey: "name",
|
|
903
|
-
header: "Team Name",
|
|
904
|
-
sortingFn: "text",
|
|
905
|
-
id: "name",
|
|
906
|
-
meta: {
|
|
907
|
-
className: "s-w-full",
|
|
908
|
-
tooltip: "Team name with member avatars",
|
|
909
|
-
},
|
|
910
|
-
cell: (info) => (
|
|
911
|
-
<DataTable.CellContent
|
|
912
|
-
avatarStack={
|
|
913
|
-
info.row.original.avatarStack
|
|
914
|
-
? {
|
|
915
|
-
items: info.row.original.avatarStack,
|
|
916
|
-
nbVisibleItems: 3,
|
|
917
|
-
}
|
|
918
|
-
: undefined
|
|
919
|
-
}
|
|
920
|
-
description={info.row.original.description}
|
|
921
|
-
roundedAvatar={info.row.original.roundedAvatar}
|
|
922
|
-
>
|
|
923
|
-
{info.row.original.name}
|
|
924
|
-
</DataTable.CellContent>
|
|
925
|
-
),
|
|
926
|
-
},
|
|
927
|
-
{
|
|
928
|
-
accessorKey: "usedBy",
|
|
929
|
-
id: "usedBy",
|
|
930
|
-
meta: {
|
|
931
|
-
className: "s-w-[82px] s-hidden @xs/table:s-table-cell",
|
|
932
|
-
},
|
|
933
|
-
header: "Members",
|
|
934
|
-
cell: (info) => (
|
|
935
|
-
<DataTable.BasicCellContent label={info.row.original.usedBy} />
|
|
936
|
-
),
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
accessorKey: "addedBy",
|
|
940
|
-
header: "Created by",
|
|
941
|
-
id: "addedBy",
|
|
942
|
-
meta: {
|
|
943
|
-
className: "s-w-[128px]",
|
|
944
|
-
},
|
|
945
|
-
cell: (info) => (
|
|
946
|
-
<DataTable.BasicCellContent
|
|
947
|
-
label={info.row.original.addedBy}
|
|
948
|
-
textToCopy={info.row.original.addedBy}
|
|
949
|
-
tooltip={info.row.original.addedBy}
|
|
950
|
-
/>
|
|
951
|
-
),
|
|
952
|
-
},
|
|
953
|
-
{
|
|
954
|
-
accessorKey: "lastUpdated",
|
|
955
|
-
id: "lastUpdated",
|
|
956
|
-
header: "Last updated",
|
|
957
|
-
meta: {
|
|
958
|
-
className: "s-w-[128px] s-hidden @sm/table:s-table-cell",
|
|
959
|
-
},
|
|
960
|
-
cell: (info) => (
|
|
961
|
-
<DataTable.BasicCellContent label={info.row.original.lastUpdated} />
|
|
962
|
-
),
|
|
963
|
-
enableSorting: false,
|
|
964
|
-
},
|
|
965
|
-
{
|
|
966
|
-
accessorKey: "size",
|
|
967
|
-
id: "size",
|
|
968
|
-
header: "Size",
|
|
969
|
-
meta: {
|
|
970
|
-
className: "s-w-[48px] s-hidden @sm/table:s-table-cell",
|
|
971
|
-
},
|
|
972
|
-
cell: (info) => (
|
|
973
|
-
<DataTable.BasicCellContent label={info.row.original.size} />
|
|
974
|
-
),
|
|
975
|
-
},
|
|
976
|
-
];
|
|
977
|
-
|
|
978
|
-
export const DataTableWithAvatarStackExample = () => {
|
|
979
|
-
const [filter, setFilter] = React.useState<string>("");
|
|
980
|
-
|
|
981
|
-
return (
|
|
982
|
-
<div className="s-flex s-w-full s-max-w-4xl s-flex-col s-gap-6">
|
|
983
|
-
<h3 className="s-text-lg s-font-medium">DataTable with Avatar Stack</h3>
|
|
984
|
-
<p className="s-text-sm s-text-muted-foreground">
|
|
985
|
-
This example demonstrates the DataTable with avatar stacks showing team
|
|
986
|
-
members. The avatar stack displays up to 4 visible avatars with a count
|
|
987
|
-
indicator for additional members.
|
|
988
|
-
</p>
|
|
989
|
-
|
|
990
|
-
<div className="s-flex s-flex-col s-gap-4">
|
|
991
|
-
<Input
|
|
992
|
-
name="filter"
|
|
993
|
-
placeholder="Filter teams..."
|
|
994
|
-
value={filter}
|
|
995
|
-
onChange={(e) => setFilter(e.target.value)}
|
|
996
|
-
/>
|
|
997
|
-
|
|
998
|
-
<DataTable
|
|
999
|
-
data={avatarStackData}
|
|
1000
|
-
filter={filter}
|
|
1001
|
-
filterColumn="name"
|
|
1002
|
-
columns={avatarStackColumns}
|
|
1003
|
-
/>
|
|
1004
|
-
</div>
|
|
1005
|
-
</div>
|
|
1006
|
-
);
|
|
1007
|
-
};
|
package/src/styles/global.css
CHANGED
|
@@ -51,15 +51,3 @@
|
|
|
51
51
|
--tw-checker-color: theme("colors.slate.950"); /* Dark mode pattern color */
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
.s-blinking-cursor > :not(pre):last-child::after {
|
|
56
|
-
content: "";
|
|
57
|
-
width: 8px;
|
|
58
|
-
height: 16px;
|
|
59
|
-
@apply s-bg-success-400;
|
|
60
|
-
display: inline-block;
|
|
61
|
-
@apply s-animate-cursor-blink;
|
|
62
|
-
margin-left: 5px;
|
|
63
|
-
position: relative;
|
|
64
|
-
top: 4px;
|
|
65
|
-
}
|
|
@@ -2,18 +2,6 @@
|
|
|
2
2
|
@tailwind components;
|
|
3
3
|
@tailwind utilities;
|
|
4
4
|
|
|
5
|
-
.s-blinking-cursor > :not(pre):last-child::after {
|
|
6
|
-
content: "";
|
|
7
|
-
width: 8px;
|
|
8
|
-
height: 16px;
|
|
9
|
-
@apply s-bg-success-400;
|
|
10
|
-
display: inline-block;
|
|
11
|
-
@apply s-animate-cursor-blink;
|
|
12
|
-
margin-left: 5px;
|
|
13
|
-
position: relative;
|
|
14
|
-
top: 4px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
5
|
@keyframes collapse-down {
|
|
18
6
|
from {
|
|
19
7
|
height: 0;
|
package/src/styles/tailwind.css
CHANGED
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
@tailwind components;
|
|
3
3
|
@tailwind utilities;
|
|
4
4
|
|
|
5
|
-
.s-blinking-cursor > :not(pre):last-child::after {
|
|
6
|
-
content: "";
|
|
7
|
-
width: 8px;
|
|
8
|
-
height: 16px;
|
|
9
|
-
@apply s-bg-success-400;
|
|
10
|
-
display: inline-block;
|
|
11
|
-
@apply s-animate-cursor-blink;
|
|
12
|
-
margin-left: 5px;
|
|
13
|
-
position: relative;
|
|
14
|
-
top: 4px;
|
|
15
|
-
}
|
|
16
5
|
|
|
17
6
|
@keyframes bgblink {
|
|
18
7
|
0%,
|