@dust-tt/sparkle 0.2.615 → 0.2.617-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.
Files changed (63) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/components/Avatar.d.ts +1 -1
  3. package/dist/esm/components/Avatar.js +4 -4
  4. package/dist/esm/components/Avatar.js.map +1 -1
  5. package/dist/esm/components/DataTable.d.ts.map +1 -1
  6. package/dist/esm/components/DataTable.js +50 -12
  7. package/dist/esm/components/DataTable.js.map +1 -1
  8. package/dist/esm/components/NavigationList.d.ts +1 -4
  9. package/dist/esm/components/NavigationList.d.ts.map +1 -1
  10. package/dist/esm/components/NavigationList.js +2 -2
  11. package/dist/esm/components/NavigationList.js.map +1 -1
  12. package/dist/esm/components/ScrollArea.d.ts +0 -1
  13. package/dist/esm/components/ScrollArea.d.ts.map +1 -1
  14. package/dist/esm/components/ScrollArea.js +4 -7
  15. package/dist/esm/components/ScrollArea.js.map +1 -1
  16. package/dist/esm/components/Spinner.d.ts +1 -1
  17. package/dist/esm/components/Spinner.js +7 -7
  18. package/dist/esm/components/Spinner.js.map +1 -1
  19. package/dist/esm/components/ToolCard.d.ts +0 -6
  20. package/dist/esm/components/ToolCard.d.ts.map +1 -1
  21. package/dist/esm/components/ToolCard.js +11 -18
  22. package/dist/esm/components/ToolCard.js.map +1 -1
  23. package/dist/esm/components/Tooltip.d.ts.map +1 -1
  24. package/dist/esm/components/Tooltip.js.map +1 -1
  25. package/dist/esm/components/WindowUtility.d.ts +2 -3
  26. package/dist/esm/components/WindowUtility.d.ts.map +1 -1
  27. package/dist/esm/components/WindowUtility.js +17 -25
  28. package/dist/esm/components/WindowUtility.js.map +1 -1
  29. package/dist/esm/components/markdown/CodeBlock.d.ts +1 -2
  30. package/dist/esm/components/markdown/CodeBlock.d.ts.map +1 -1
  31. package/dist/esm/components/markdown/CodeBlock.js +2 -9
  32. package/dist/esm/components/markdown/CodeBlock.js.map +1 -1
  33. package/dist/esm/index.d.ts +0 -1
  34. package/dist/esm/index.d.ts.map +1 -1
  35. package/dist/esm/index.js +0 -1
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/stories/Avatar.stories.js +4 -4
  38. package/dist/esm/stories/MultiPageDialog.stories.js +1 -1
  39. package/dist/esm/stories/MultiPageDialog.stories.js.map +1 -1
  40. package/dist/esm/stories/Spinner.stories.js +3 -3
  41. package/dist/esm/stories/ToolCard.stories.d.ts.map +1 -1
  42. package/dist/esm/stories/ToolCard.stories.js +6 -14
  43. package/dist/esm/stories/ToolCard.stories.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/components/Avatar.tsx +4 -4
  46. package/src/components/DataTable.tsx +46 -7
  47. package/src/components/NavigationList.tsx +2 -7
  48. package/src/components/ScrollArea.tsx +3 -9
  49. package/src/components/Spinner.tsx +7 -7
  50. package/src/components/ToolCard.tsx +35 -60
  51. package/src/components/Tooltip.tsx +38 -49
  52. package/src/components/WindowUtility.tsx +18 -11
  53. package/src/components/markdown/CodeBlock.tsx +0 -10
  54. package/src/index.ts +0 -1
  55. package/src/stories/Avatar.stories.tsx +4 -4
  56. package/src/stories/MultiPageDialog.stories.tsx +1 -1
  57. package/src/stories/Spinner.stories.tsx +3 -3
  58. package/src/stories/ToolCard.stories.tsx +35 -49
  59. package/dist/esm/stories/CodeBlock.stories.d.ts +0 -17
  60. package/dist/esm/stories/CodeBlock.stories.d.ts.map +0 -1
  61. package/dist/esm/stories/CodeBlock.stories.js +0 -125
  62. package/dist/esm/stories/CodeBlock.stories.js.map +0 -1
  63. package/src/stories/CodeBlock.stories.tsx +0 -361
@@ -13,55 +13,41 @@ const meta: Meta<typeof ToolCard> = {
13
13
  export default meta;
14
14
 
15
15
  export const Examples = () => (
16
- <div className="s-flex s-gap-3">
17
- {/* Not added - default md size */}
18
- <div className="s-w-80">
19
- <ToolCard
20
- icon={BookOpenIcon}
21
- cardContainerClassName="s-h-36"
22
- label="Image Generation"
23
- description="Agent can generate images (GPT Image 1)."
24
- isSelected
25
- canAdd
26
- onClick={() => console.log("Add Image Generation")}
27
- toolInfo={{
28
- label: "Click here",
29
- onClick: () => console.log("Click here"),
30
- }}
31
- />
32
- </div>
16
+ <div className="s-grid s-grid-cols-2 s-gap-3">
17
+ {/* Not added */}
18
+ <ToolCard
19
+ icon={BookOpenIcon}
20
+ label="Image Generation"
21
+ description="Agent can generate images (GPT Image 1)."
22
+ isSelected={false}
23
+ canAdd={true}
24
+ onClick={() => console.log("Add Image Generation")}
25
+ />
33
26
 
34
- {/* Added - xl size */}
35
- <div className="s-w-80">
36
- <ToolCard
37
- cardContainerClassName="s-h-36"
38
- icon={CommandLineIcon}
39
- label="Reasoning"
40
- description={
41
- <>
42
- Agent can decide to trigger a reasoning model for complex tasks.
43
- Agent can decide to trigger a reasoning model for complex tasks.
44
- Agent can decide to trigger a reasoning model for complex tasks.
45
- Agent can decide to trigger a reasoning model for complex tasks.
46
- Agent can decide to trigger a reasoning model for complex tasks.
47
- Agent can decide to trigger a reasoning model for complex tasks.{" "}
48
- <Hoverable
49
- href="https://example.com/help"
50
- target="_blank"
51
- rel="noopener noreferrer"
52
- variant="primary"
53
- >
54
- the docs
55
- </Hoverable>
56
- </>
57
- }
58
- isSelected
59
- canAdd={false}
60
- toolInfo={{
61
- label: "Click here",
62
- onClick: () => console.log("Click here"),
63
- }}
64
- />
65
- </div>
27
+ {/* Added */}
28
+ <ToolCard
29
+ icon={CommandLineIcon}
30
+ label="Reasoning"
31
+ description={
32
+ <>
33
+ Agent can decide to trigger a reasoning model for complex tasks. Agent
34
+ can decide to trigger a reasoning model for complex tasks. Agent can
35
+ decide to trigger a reasoning model for complex tasks. Agent can
36
+ decide to trigger a reasoning model for complex tasks. Agent can
37
+ decide to trigger a reasoning model for complex tasks. Agent can
38
+ decide to trigger a reasoning model for complex tasks.{" "}
39
+ <Hoverable
40
+ href="https://example.com/help"
41
+ target="_blank"
42
+ rel="noopener noreferrer"
43
+ variant="primary"
44
+ >
45
+ the docs
46
+ </Hoverable>
47
+ </>
48
+ }
49
+ isSelected={true}
50
+ canAdd={false}
51
+ />
66
52
  </div>
67
53
  );
@@ -1,17 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { CodeBlock } from "../index_with_tw_base";
3
- declare const meta: Meta<typeof CodeBlock>;
4
- export default meta;
5
- type Story = StoryObj<typeof meta>;
6
- export declare const InlineCode: Story;
7
- export declare const InlineCodeWithVariant: Story;
8
- export declare const TypescriptBlock: Story;
9
- export declare const ReactTSXBlock: Story;
10
- export declare const CSSBlock: Story;
11
- export declare const JSONBlock: Story;
12
- export declare const BashBlock: Story;
13
- export declare const SQLBlock: Story;
14
- export declare const LongCodeWithWrapping: Story;
15
- export declare const LongCodeWithoutWrapping: Story;
16
- export declare const TypescriptWithLineNumbers: Story;
17
- //# sourceMappingURL=CodeBlock.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CodeBlock.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/CodeBlock.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CA2ChC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAGnC,eAAO,MAAM,UAAU,EAAE,KAKxB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAMnC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAsB7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KA+C3B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAmCtB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KA+BvB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KA2BvB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KA+BtB,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,KAuBlC,CAAC;AAGF,eAAO,MAAM,uBAAuB,EAAE,KAcrC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,KA2CvC,CAAC"}
@@ -1,125 +0,0 @@
1
- import React from "react";
2
- import { CodeBlock } from "../index_with_tw_base";
3
- var meta = {
4
- title: "Components/CodeBlock",
5
- component: CodeBlock,
6
- argTypes: {
7
- children: {
8
- description: "The code content to display",
9
- control: { type: "text" },
10
- },
11
- className: {
12
- description: "CSS class name, can include language specification (e.g., 'language-javascript')",
13
- control: { type: "text" },
14
- },
15
- inline: {
16
- description: "Whether to render as inline code (single line) or block code",
17
- control: { type: "boolean" },
18
- defaultValue: false,
19
- },
20
- variant: {
21
- description: "Visual variant of the code block",
22
- options: ["surface"],
23
- control: { type: "select" },
24
- defaultValue: "surface",
25
- },
26
- wrapLongLines: {
27
- description: "Whether to wrap long lines in block code",
28
- control: { type: "boolean" },
29
- defaultValue: false,
30
- },
31
- showLineNumber: {
32
- description: "Whether to show line numbers on the left side of the code",
33
- control: { type: "boolean" },
34
- defaultValue: false,
35
- },
36
- },
37
- decorators: [
38
- function (Story) { return (React.createElement("div", { className: "s-bg-background s-p-4 dark:s-bg-background-night" },
39
- React.createElement(Story, null))); },
40
- ],
41
- };
42
- export default meta;
43
- // Inline code examples
44
- export var InlineCode = {
45
- args: {
46
- children: "const greeting = 'Hello, World!';",
47
- inline: true,
48
- },
49
- };
50
- export var InlineCodeWithVariant = {
51
- args: {
52
- children: "npm install @dust-tt/sparkle",
53
- inline: true,
54
- variant: "surface",
55
- },
56
- };
57
- export var TypescriptBlock = {
58
- args: {
59
- children: "interface User {\n id: number;\n name: string;\n email: string;\n isActive: boolean;\n}\n\nconst createUser = (userData: Partial<User>): User => {\n return {\n id: Math.random(),\n name: userData.name || \"Anonymous\",\n email: userData.email || \"\",\n isActive: userData.isActive ?? true,\n };\n};\n\nconst newUser = createUser({ name: \"John Doe\", email: \"john@example.com\" });",
60
- className: "language-typescript",
61
- inline: false,
62
- },
63
- };
64
- export var ReactTSXBlock = {
65
- args: {
66
- children: "import React, { useState, useEffect } from 'react';\nimport { Button } from '@dust-tt/sparkle';\n\ninterface CounterProps {\n initialValue?: number;\n step?: number;\n onCountChange?: (count: number) => void;\n}\n\nconst Counter: React.FC<CounterProps> = ({ \n initialValue = 0, \n step = 1,\n onCountChange\n}) => {\n const [count, setCount] = useState<number>(initialValue);\n\n useEffect(() => {\n document.title = `Count: ${count}`;\n onCountChange?.(count);\n }, [count, onCountChange]);\n\n const increment = (): void => setCount(prev => prev + step);\n const decrement = (): void => setCount(prev => prev - step);\n const reset = (): void => setCount(initialValue);\n\n return (\n <div className=\"flex items-center gap-4\">\n <Button onClick={decrement} variant=\"outline\">\n -\n </Button>\n <span className=\"text-2xl font-bold\">{count}</span>\n <Button onClick={increment} variant=\"primary\">\n +\n </Button>\n <Button onClick={reset} variant=\"ghost\">\n Reset\n </Button>\n </div>\n );\n};\n\nexport default Counter;",
67
- className: "language-tsx",
68
- inline: false,
69
- },
70
- };
71
- export var CSSBlock = {
72
- args: {
73
- children: ".code-block {\n background-color: var(--s-muted);\n border: 1px solid var(--s-border);\n border-radius: 0.5rem;\n padding: 1rem;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n overflow-x: auto;\n}\n\n.code-block .keyword {\n color: #8b5cf6; /* violet-500 */\n}\n\n.code-block .string {\n color: #10b981; /* emerald-500 */\n}\n\n.code-block .comment {\n color: #6b7280; /* gray-500 */\n font-style: italic;\n}\n\n@media (prefers-color-scheme: dark) {\n .code-block {\n background-color: var(--s-muted-night);\n border-color: var(--s-border-night);\n }\n}",
74
- className: "language-css",
75
- inline: false,
76
- },
77
- };
78
- export var JSONBlock = {
79
- args: {
80
- children: "{\n \"name\": \"@dust-tt/sparkle\",\n \"version\": \"1.0.0\",\n \"description\": \"A beautiful component library for React applications\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"rollup -c\",\n \"dev\": \"rollup -c -w\",\n \"test\": \"jest\",\n \"lint\": \"eslint src/**/*.{ts,tsx}\"\n },\n \"dependencies\": {\n \"react\": \"^18.0.0\",\n \"react-dom\": \"^18.0.0\",\n \"class-variance-authority\": \"^0.7.0\"\n },\n \"devDependencies\": {\n \"@types/react\": \"^18.0.0\",\n \"@types/react-dom\": \"^18.0.0\",\n \"typescript\": \"^5.0.0\"\n },\n \"keywords\": [\"react\", \"components\", \"ui\", \"typescript\"],\n \"author\": \"Dust Team\",\n \"license\": \"MIT\"\n}",
81
- className: "language-json",
82
- inline: false,
83
- },
84
- };
85
- export var BashBlock = {
86
- args: {
87
- children: "#!/bin/bash\n\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n\n# Run tests\nnpm test\n\n# Deploy to production\nif [ \"$ENVIRONMENT\" = \"production\" ]; then\n echo \"Deploying to production...\"\n npm run deploy:prod\nelse\n echo \"Deploying to staging...\"\n npm run deploy:staging\nfi\n\n# Clean up\nnpm run clean",
88
- className: "language-bash",
89
- inline: false,
90
- },
91
- };
92
- export var SQLBlock = {
93
- args: {
94
- children: "-- Create users table\nCREATE TABLE users (\n id SERIAL PRIMARY KEY,\n username VARCHAR(50) UNIQUE NOT NULL,\n email VARCHAR(100) UNIQUE NOT NULL,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\n-- Insert sample data\nINSERT INTO users (username, email) VALUES\n ('alice', 'alice@example.com'),\n ('bob', 'bob@example.com'),\n ('charlie', 'charlie@example.com');\n\n-- Query with joins\nSELECT \n u.username,\n u.email,\n p.title as post_title,\n p.created_at as post_date\nFROM users u\nLEFT JOIN posts p ON u.id = p.user_id\nWHERE u.created_at > '2024-01-01'\nORDER BY p.created_at DESC\nLIMIT 10;",
95
- className: "language-sql",
96
- inline: false,
97
- },
98
- };
99
- // Long code example with line wrapping
100
- export var LongCodeWithWrapping = {
101
- args: {
102
- children: "// This is a very long line of code that demonstrates how the wrapLongLines prop works when set to true. It contains a lot of text and would normally overflow the container, but with wrapLongLines enabled, it will wrap to the next line instead of creating a horizontal scrollbar. This is particularly useful for mobile devices or narrow containers where horizontal scrolling is not desirable.\n\nfunction processVeryLongFunctionNameWithManyParameters(\n parameterOne: string,\n parameterTwo: number,\n parameterThree: boolean,\n parameterFour: object,\n parameterFive: array,\n parameterSix: function,\n parameterSeven: string,\n parameterEight: number\n): Promise<ComplexReturnType> {\n // Implementation here\n return new Promise((resolve, reject) => {\n // More implementation\n });\n}",
103
- className: "language-typescript",
104
- inline: false,
105
- wrapLongLines: true,
106
- },
107
- };
108
- // Long code example without line wrapping (default)
109
- export var LongCodeWithoutWrapping = {
110
- args: {
111
- children: "// This is a very long line of code that demonstrates how the wrapLongLines prop works when set to false (default). It contains a lot of text and will create a horizontal scrollbar when it overflows the container. This is the default behavior and is useful when you want to preserve the exact formatting of the code.\n\nfunction processVeryLongFunctionNameWithManyParameters(parameterOne: string, parameterTwo: number, parameterThree: boolean, parameterFour: object, parameterFive: array, parameterSix: function, parameterSeven: string, parameterEight: number): Promise<ComplexReturnType> {\n // Implementation here\n return new Promise((resolve, reject) => {\n // More implementation\n });\n}",
112
- className: "language-typescript",
113
- inline: false,
114
- wrapLongLines: false,
115
- },
116
- };
117
- export var TypescriptWithLineNumbers = {
118
- args: {
119
- children: "interface User {\n id: number;\n name: string;\n email: string;\n isActive: boolean;\n}\n\nclass UserService {\n private users: User[] = [];\n\n addUser(user: Omit<User, 'id'>): User {\n const newUser: User = {\n id: this.users.length + 1,\n ...user\n };\n \n this.users.push(newUser);\n return newUser;\n }\n\n getUserById(id: number): User | undefined {\n return this.users.find(user => user.id === id);\n }\n\n getAllUsers(): User[] {\n return [...this.users];\n }\n}\n\nconst userService = new UserService();\nconst newUser = userService.addUser({\n name: \"John Doe\",\n email: \"john@example.com\",\n isActive: true\n});\n\nconsole.log(\"Created user:\", newUser);",
120
- className: "language-typescript",
121
- inline: false,
122
- showLineNumber: true,
123
- },
124
- };
125
- //# sourceMappingURL=CodeBlock.stories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CodeBlock.stories.js","sourceRoot":"","sources":["../../../src/stories/CodeBlock.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,IAAM,IAAI,GAA2B;IACnC,KAAK,EAAE,sBAAsB;IAC7B,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE;QACR,QAAQ,EAAE;YACR,WAAW,EAAE,6BAA6B;YAC1C,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SAC1B;QACD,SAAS,EAAE;YACT,WAAW,EACT,kFAAkF;YACpF,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SAC1B;QACD,MAAM,EAAE;YACN,WAAW,EACT,8DAA8D;YAChE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC5B,YAAY,EAAE,KAAK;SACpB;QACD,OAAO,EAAE;YACP,WAAW,EAAE,kCAAkC;YAC/C,OAAO,EAAE,CAAC,SAAS,CAAC;YACpB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,YAAY,EAAE,SAAS;SACxB;QACD,aAAa,EAAE;YACb,WAAW,EAAE,0CAA0C;YACvD,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC5B,YAAY,EAAE,KAAK;SACpB;QACD,cAAc,EAAE;YACd,WAAW,EAAE,2DAA2D;YACxE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC5B,YAAY,EAAE,KAAK;SACpB;KACF;IACD,UAAU,EAAE;QACV,UAAC,KAAK,IAAK,OAAA,CACT,6BAAK,SAAS,EAAC,kDAAkD;YAC/D,oBAAC,KAAK,OAAG,CACL,CACP,EAJU,CAIV;KACF;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAGpB,uBAAuB;AACvB,MAAM,CAAC,IAAM,UAAU,GAAU;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,mCAAmC;QAC7C,MAAM,EAAE,IAAI;KACb;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,qBAAqB,GAAU;IAC1C,IAAI,EAAE;QACJ,QAAQ,EAAE,8BAA8B;QACxC,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,SAAS;KACnB;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,eAAe,GAAU;IACpC,IAAI,EAAE;QACJ,QAAQ,EAAE,mZAgB+D;QACzE,SAAS,EAAE,qBAAqB;QAChC,MAAM,EAAE,KAAK;KACd;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,aAAa,GAAU;IAClC,IAAI,EAAE;QACJ,QAAQ,EAAE,2lCAyCU;QACpB,SAAS,EAAE,cAAc;QACzB,MAAM,EAAE,KAAK;KACd;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,QAAQ,GAAU;IAC7B,IAAI,EAAE;QACJ,QAAQ,EAAE,ynBA6BZ;QACE,SAAS,EAAE,cAAc;QACzB,MAAM,EAAE,KAAK;KACd;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,QAAQ,EAAE,kwBAyBZ;QACE,SAAS,EAAE,eAAe;QAC1B,MAAM,EAAE,KAAK;KACd;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,QAAQ,EAAE,gWAqBA;QACV,SAAS,EAAE,eAAe;QAC1B,MAAM,EAAE,KAAK;KACd;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,QAAQ,GAAU;IAC7B,IAAI,EAAE;QACJ,QAAQ,EAAE,+pBAyBJ;QACN,SAAS,EAAE,cAAc;QACzB,MAAM,EAAE,KAAK;KACd;CACF,CAAC;AAEF,uCAAuC;AACvC,MAAM,CAAC,IAAM,oBAAoB,GAAU;IACzC,IAAI,EAAE;QACJ,QAAQ,EAAE,oyBAgBZ;QACE,SAAS,EAAE,qBAAqB;QAChC,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,IAAI;KACpB;CACF,CAAC;AAEF,oDAAoD;AACpD,MAAM,CAAC,IAAM,uBAAuB,GAAU;IAC5C,IAAI,EAAE;QACJ,QAAQ,EAAE,6rBAOZ;QACE,SAAS,EAAE,qBAAqB;QAChC,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,KAAK;KACrB;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,yBAAyB,GAAU;IAC9C,IAAI,EAAE;QACJ,QAAQ,EAAE,6sBAoCyB;QACnC,SAAS,EAAE,qBAAqB;QAChC,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,IAAI;KACrB;CACF,CAAC"}
@@ -1,361 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import React from "react";
3
-
4
- import { CodeBlock } from "../index_with_tw_base";
5
-
6
- const meta: Meta<typeof CodeBlock> = {
7
- title: "Components/CodeBlock",
8
- component: CodeBlock,
9
- argTypes: {
10
- children: {
11
- description: "The code content to display",
12
- control: { type: "text" },
13
- },
14
- className: {
15
- description:
16
- "CSS class name, can include language specification (e.g., 'language-javascript')",
17
- control: { type: "text" },
18
- },
19
- inline: {
20
- description:
21
- "Whether to render as inline code (single line) or block code",
22
- control: { type: "boolean" },
23
- defaultValue: false,
24
- },
25
- variant: {
26
- description: "Visual variant of the code block",
27
- options: ["surface"],
28
- control: { type: "select" },
29
- defaultValue: "surface",
30
- },
31
- wrapLongLines: {
32
- description: "Whether to wrap long lines in block code",
33
- control: { type: "boolean" },
34
- defaultValue: false,
35
- },
36
- showLineNumber: {
37
- description: "Whether to show line numbers on the left side of the code",
38
- control: { type: "boolean" },
39
- defaultValue: false,
40
- },
41
- },
42
- decorators: [
43
- (Story) => (
44
- <div className="s-bg-background s-p-4 dark:s-bg-background-night">
45
- <Story />
46
- </div>
47
- ),
48
- ],
49
- };
50
-
51
- export default meta;
52
- type Story = StoryObj<typeof meta>;
53
-
54
- // Inline code examples
55
- export const InlineCode: Story = {
56
- args: {
57
- children: "const greeting = 'Hello, World!';",
58
- inline: true,
59
- },
60
- };
61
-
62
- export const InlineCodeWithVariant: Story = {
63
- args: {
64
- children: "npm install @dust-tt/sparkle",
65
- inline: true,
66
- variant: "surface",
67
- },
68
- };
69
-
70
- export const TypescriptBlock: Story = {
71
- args: {
72
- children: `interface User {
73
- id: number;
74
- name: string;
75
- email: string;
76
- isActive: boolean;
77
- }
78
-
79
- const createUser = (userData: Partial<User>): User => {
80
- return {
81
- id: Math.random(),
82
- name: userData.name || "Anonymous",
83
- email: userData.email || "",
84
- isActive: userData.isActive ?? true,
85
- };
86
- };
87
-
88
- const newUser = createUser({ name: "John Doe", email: "john@example.com" });`,
89
- className: "language-typescript",
90
- inline: false,
91
- },
92
- };
93
-
94
- export const ReactTSXBlock: Story = {
95
- args: {
96
- children: `import React, { useState, useEffect } from 'react';
97
- import { Button } from '@dust-tt/sparkle';
98
-
99
- interface CounterProps {
100
- initialValue?: number;
101
- step?: number;
102
- onCountChange?: (count: number) => void;
103
- }
104
-
105
- const Counter: React.FC<CounterProps> = ({
106
- initialValue = 0,
107
- step = 1,
108
- onCountChange
109
- }) => {
110
- const [count, setCount] = useState<number>(initialValue);
111
-
112
- useEffect(() => {
113
- document.title = \`Count: \${count}\`;
114
- onCountChange?.(count);
115
- }, [count, onCountChange]);
116
-
117
- const increment = (): void => setCount(prev => prev + step);
118
- const decrement = (): void => setCount(prev => prev - step);
119
- const reset = (): void => setCount(initialValue);
120
-
121
- return (
122
- <div className="flex items-center gap-4">
123
- <Button onClick={decrement} variant="outline">
124
- -
125
- </Button>
126
- <span className="text-2xl font-bold">{count}</span>
127
- <Button onClick={increment} variant="primary">
128
- +
129
- </Button>
130
- <Button onClick={reset} variant="ghost">
131
- Reset
132
- </Button>
133
- </div>
134
- );
135
- };
136
-
137
- export default Counter;`,
138
- className: "language-tsx",
139
- inline: false,
140
- },
141
- };
142
-
143
- export const CSSBlock: Story = {
144
- args: {
145
- children: `.code-block {
146
- background-color: var(--s-muted);
147
- border: 1px solid var(--s-border);
148
- border-radius: 0.5rem;
149
- padding: 1rem;
150
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
151
- font-size: 0.875rem;
152
- line-height: 1.5;
153
- overflow-x: auto;
154
- }
155
-
156
- .code-block .keyword {
157
- color: #8b5cf6; /* violet-500 */
158
- }
159
-
160
- .code-block .string {
161
- color: #10b981; /* emerald-500 */
162
- }
163
-
164
- .code-block .comment {
165
- color: #6b7280; /* gray-500 */
166
- font-style: italic;
167
- }
168
-
169
- @media (prefers-color-scheme: dark) {
170
- .code-block {
171
- background-color: var(--s-muted-night);
172
- border-color: var(--s-border-night);
173
- }
174
- }`,
175
- className: "language-css",
176
- inline: false,
177
- },
178
- };
179
-
180
- export const JSONBlock: Story = {
181
- args: {
182
- children: `{
183
- "name": "@dust-tt/sparkle",
184
- "version": "1.0.0",
185
- "description": "A beautiful component library for React applications",
186
- "main": "dist/index.js",
187
- "types": "dist/index.d.ts",
188
- "scripts": {
189
- "build": "rollup -c",
190
- "dev": "rollup -c -w",
191
- "test": "jest",
192
- "lint": "eslint src/**/*.{ts,tsx}"
193
- },
194
- "dependencies": {
195
- "react": "^18.0.0",
196
- "react-dom": "^18.0.0",
197
- "class-variance-authority": "^0.7.0"
198
- },
199
- "devDependencies": {
200
- "@types/react": "^18.0.0",
201
- "@types/react-dom": "^18.0.0",
202
- "typescript": "^5.0.0"
203
- },
204
- "keywords": ["react", "components", "ui", "typescript"],
205
- "author": "Dust Team",
206
- "license": "MIT"
207
- }`,
208
- className: "language-json",
209
- inline: false,
210
- },
211
- };
212
-
213
- export const BashBlock: Story = {
214
- args: {
215
- children: `#!/bin/bash
216
-
217
- # Install dependencies
218
- npm install
219
-
220
- # Build the project
221
- npm run build
222
-
223
- # Run tests
224
- npm test
225
-
226
- # Deploy to production
227
- if [ "$ENVIRONMENT" = "production" ]; then
228
- echo "Deploying to production..."
229
- npm run deploy:prod
230
- else
231
- echo "Deploying to staging..."
232
- npm run deploy:staging
233
- fi
234
-
235
- # Clean up
236
- npm run clean`,
237
- className: "language-bash",
238
- inline: false,
239
- },
240
- };
241
-
242
- export const SQLBlock: Story = {
243
- args: {
244
- children: `-- Create users table
245
- CREATE TABLE users (
246
- id SERIAL PRIMARY KEY,
247
- username VARCHAR(50) UNIQUE NOT NULL,
248
- email VARCHAR(100) UNIQUE NOT NULL,
249
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
250
- updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
251
- );
252
-
253
- -- Insert sample data
254
- INSERT INTO users (username, email) VALUES
255
- ('alice', 'alice@example.com'),
256
- ('bob', 'bob@example.com'),
257
- ('charlie', 'charlie@example.com');
258
-
259
- -- Query with joins
260
- SELECT
261
- u.username,
262
- u.email,
263
- p.title as post_title,
264
- p.created_at as post_date
265
- FROM users u
266
- LEFT JOIN posts p ON u.id = p.user_id
267
- WHERE u.created_at > '2024-01-01'
268
- ORDER BY p.created_at DESC
269
- LIMIT 10;`,
270
- className: "language-sql",
271
- inline: false,
272
- },
273
- };
274
-
275
- // Long code example with line wrapping
276
- export const LongCodeWithWrapping: Story = {
277
- args: {
278
- children: `// This is a very long line of code that demonstrates how the wrapLongLines prop works when set to true. It contains a lot of text and would normally overflow the container, but with wrapLongLines enabled, it will wrap to the next line instead of creating a horizontal scrollbar. This is particularly useful for mobile devices or narrow containers where horizontal scrolling is not desirable.
279
-
280
- function processVeryLongFunctionNameWithManyParameters(
281
- parameterOne: string,
282
- parameterTwo: number,
283
- parameterThree: boolean,
284
- parameterFour: object,
285
- parameterFive: array,
286
- parameterSix: function,
287
- parameterSeven: string,
288
- parameterEight: number
289
- ): Promise<ComplexReturnType> {
290
- // Implementation here
291
- return new Promise((resolve, reject) => {
292
- // More implementation
293
- });
294
- }`,
295
- className: "language-typescript",
296
- inline: false,
297
- wrapLongLines: true,
298
- },
299
- };
300
-
301
- // Long code example without line wrapping (default)
302
- export const LongCodeWithoutWrapping: Story = {
303
- args: {
304
- children: `// This is a very long line of code that demonstrates how the wrapLongLines prop works when set to false (default). It contains a lot of text and will create a horizontal scrollbar when it overflows the container. This is the default behavior and is useful when you want to preserve the exact formatting of the code.
305
-
306
- function processVeryLongFunctionNameWithManyParameters(parameterOne: string, parameterTwo: number, parameterThree: boolean, parameterFour: object, parameterFive: array, parameterSix: function, parameterSeven: string, parameterEight: number): Promise<ComplexReturnType> {
307
- // Implementation here
308
- return new Promise((resolve, reject) => {
309
- // More implementation
310
- });
311
- }`,
312
- className: "language-typescript",
313
- inline: false,
314
- wrapLongLines: false,
315
- },
316
- };
317
-
318
- export const TypescriptWithLineNumbers: Story = {
319
- args: {
320
- children: `interface User {
321
- id: number;
322
- name: string;
323
- email: string;
324
- isActive: boolean;
325
- }
326
-
327
- class UserService {
328
- private users: User[] = [];
329
-
330
- addUser(user: Omit<User, 'id'>): User {
331
- const newUser: User = {
332
- id: this.users.length + 1,
333
- ...user
334
- };
335
-
336
- this.users.push(newUser);
337
- return newUser;
338
- }
339
-
340
- getUserById(id: number): User | undefined {
341
- return this.users.find(user => user.id === id);
342
- }
343
-
344
- getAllUsers(): User[] {
345
- return [...this.users];
346
- }
347
- }
348
-
349
- const userService = new UserService();
350
- const newUser = userService.addUser({
351
- name: "John Doe",
352
- email: "john@example.com",
353
- isActive: true
354
- });
355
-
356
- console.log("Created user:", newUser);`,
357
- className: "language-typescript",
358
- inline: false,
359
- showLineNumber: true,
360
- },
361
- };