@dust-tt/sparkle 0.2.563 → 0.2.564-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 (108) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/components/DataTable.d.ts +2 -4
  3. package/dist/esm/components/DataTable.d.ts.map +1 -1
  4. package/dist/esm/components/DataTable.js +9 -27
  5. package/dist/esm/components/DataTable.js.map +1 -1
  6. package/dist/esm/components/MultiPageSheet.d.ts +0 -1
  7. package/dist/esm/components/MultiPageSheet.d.ts.map +1 -1
  8. package/dist/esm/components/MultiPageSheet.js +2 -2
  9. package/dist/esm/components/MultiPageSheet.js.map +1 -1
  10. package/dist/esm/components/RadioGroup.d.ts +1 -4
  11. package/dist/esm/components/RadioGroup.d.ts.map +1 -1
  12. package/dist/esm/components/RadioGroup.js +2 -2
  13. package/dist/esm/components/RadioGroup.js.map +1 -1
  14. package/dist/esm/components/TextArea.d.ts +1 -4
  15. package/dist/esm/components/TextArea.d.ts.map +1 -1
  16. package/dist/esm/components/TextArea.js +1 -5
  17. package/dist/esm/components/TextArea.js.map +1 -1
  18. package/dist/esm/components/index.d.ts +2 -4
  19. package/dist/esm/components/index.d.ts.map +1 -1
  20. package/dist/esm/components/index.js +2 -3
  21. package/dist/esm/components/index.js.map +1 -1
  22. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts.map +1 -1
  23. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js +33 -4
  24. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js.map +1 -1
  25. package/dist/esm/components/markdown/ContentBlockWrapper.d.ts +2 -1
  26. package/dist/esm/components/markdown/ContentBlockWrapper.d.ts.map +1 -1
  27. package/dist/esm/components/markdown/ContentBlockWrapper.js +44 -6
  28. package/dist/esm/components/markdown/ContentBlockWrapper.js.map +1 -1
  29. package/dist/esm/components/markdown/Markdown.js +6 -6
  30. package/dist/esm/components/markdown/Markdown.js.map +1 -1
  31. package/dist/esm/components/markdown/PrettyJsonViewer.js +2 -2
  32. package/dist/esm/components/markdown/PrettyJsonViewer.js.map +1 -1
  33. package/dist/esm/hooks/index.d.ts +2 -0
  34. package/dist/esm/hooks/index.d.ts.map +1 -1
  35. package/dist/esm/hooks/index.js +2 -0
  36. package/dist/esm/hooks/index.js.map +1 -1
  37. package/dist/esm/hooks/useHashParams.d.ts +19 -0
  38. package/dist/esm/hooks/useHashParams.d.ts.map +1 -0
  39. package/dist/esm/hooks/useHashParams.js +69 -0
  40. package/dist/esm/hooks/useHashParams.js.map +1 -0
  41. package/dist/esm/hooks/usePaginationFromUrl.d.ts +11 -0
  42. package/dist/esm/hooks/usePaginationFromUrl.d.ts.map +1 -0
  43. package/dist/esm/hooks/usePaginationFromUrl.js +25 -0
  44. package/dist/esm/hooks/usePaginationFromUrl.js.map +1 -0
  45. package/dist/esm/logo/platforms/index.d.ts +0 -3
  46. package/dist/esm/logo/platforms/index.d.ts.map +1 -1
  47. package/dist/esm/logo/platforms/index.js +0 -3
  48. package/dist/esm/logo/platforms/index.js.map +1 -1
  49. package/dist/esm/stories/DataTable.stories.d.ts +0 -1
  50. package/dist/esm/stories/DataTable.stories.d.ts.map +1 -1
  51. package/dist/esm/stories/DataTable.stories.js +1 -21
  52. package/dist/esm/stories/DataTable.stories.js.map +1 -1
  53. package/dist/esm/stories/Markdown.stories.d.ts.map +1 -1
  54. package/dist/esm/stories/Markdown.stories.js +1 -1
  55. package/dist/esm/stories/Markdown.stories.js.map +1 -1
  56. package/dist/esm/stories/Pagination.stories.d.ts +13 -0
  57. package/dist/esm/stories/Pagination.stories.d.ts.map +1 -0
  58. package/dist/esm/stories/Pagination.stories.js +49 -0
  59. package/dist/esm/stories/Pagination.stories.js.map +1 -0
  60. package/dist/sparkle.css +12 -65
  61. package/package.json +1 -1
  62. package/src/components/DataTable.tsx +3 -44
  63. package/src/components/MultiPageSheet.tsx +1 -3
  64. package/src/components/RadioGroup.tsx +2 -2
  65. package/src/components/TextArea.tsx +1 -16
  66. package/src/components/index.ts +2 -19
  67. package/src/components/markdown/CodeBlockWithExtendedSupport.tsx +41 -2
  68. package/src/components/markdown/ContentBlockWrapper.tsx +51 -10
  69. package/src/components/markdown/Markdown.tsx +6 -6
  70. package/src/components/markdown/PrettyJsonViewer.tsx +2 -2
  71. package/src/hooks/index.ts +2 -0
  72. package/src/hooks/useHashParams.ts +101 -0
  73. package/src/hooks/usePaginationFromUrl.ts +46 -0
  74. package/src/logo/platforms/index.ts +0 -3
  75. package/src/stories/DataTable.stories.tsx +1 -61
  76. package/src/stories/Markdown.stories.tsx +0 -7
  77. package/src/stories/Pagination.stories.tsx +92 -0
  78. package/dist/esm/components/MultiPageDialog.d.ts +0 -45
  79. package/dist/esm/components/MultiPageDialog.d.ts.map +0 -1
  80. package/dist/esm/components/MultiPageDialog.js +0 -111
  81. package/dist/esm/components/MultiPageDialog.js.map +0 -1
  82. package/dist/esm/logo/platforms/Datadog.d.ts +0 -5
  83. package/dist/esm/logo/platforms/Datadog.d.ts.map +0 -1
  84. package/dist/esm/logo/platforms/Datadog.js +0 -10
  85. package/dist/esm/logo/platforms/Datadog.js.map +0 -1
  86. package/dist/esm/logo/platforms/Freshdesk.d.ts +0 -5
  87. package/dist/esm/logo/platforms/Freshdesk.d.ts.map +0 -1
  88. package/dist/esm/logo/platforms/Freshdesk.js +0 -7
  89. package/dist/esm/logo/platforms/Freshdesk.js.map +0 -1
  90. package/dist/esm/logo/platforms/Freshservice.d.ts +0 -5
  91. package/dist/esm/logo/platforms/Freshservice.d.ts.map +0 -1
  92. package/dist/esm/logo/platforms/Freshservice.js +0 -7
  93. package/dist/esm/logo/platforms/Freshservice.js.map +0 -1
  94. package/dist/esm/logo/src/platforms/Datadog.svg +0 -11
  95. package/dist/esm/logo/src/platforms/Freshdesk.svg +0 -1
  96. package/dist/esm/logo/src/platforms/Freshservice.svg +0 -1
  97. package/dist/esm/stories/MultiPageDialog.stories.d.ts +0 -11
  98. package/dist/esm/stories/MultiPageDialog.stories.d.ts.map +0 -1
  99. package/dist/esm/stories/MultiPageDialog.stories.js +0 -510
  100. package/dist/esm/stories/MultiPageDialog.stories.js.map +0 -1
  101. package/src/components/MultiPageDialog.tsx +0 -303
  102. package/src/logo/platforms/Datadog.tsx +0 -27
  103. package/src/logo/platforms/Freshdesk.tsx +0 -15
  104. package/src/logo/platforms/Freshservice.tsx +0 -21
  105. package/src/logo/src/platforms/Datadog.svg +0 -11
  106. package/src/logo/src/platforms/Freshdesk.svg +0 -1
  107. package/src/logo/src/platforms/Freshservice.svg +0 -1
  108. package/src/stories/MultiPageDialog.stories.tsx +0 -866
@@ -1,866 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import React, { useState } from "react";
3
-
4
- import { Button } from "@sparkle/components/Button";
5
- import {
6
- MultiPageDialog,
7
- MultiPageDialogContent,
8
- type MultiPageDialogPage,
9
- MultiPageDialogTrigger,
10
- } from "@sparkle/components/MultiPageDialog";
11
- import { Cog6ToothIcon, DocumentTextIcon, UserIcon } from "@sparkle/icons/app";
12
-
13
- const meta: Meta<typeof MultiPageDialogContent> = {
14
- title: "Primitives/MultiPageDialog",
15
- component: MultiPageDialogContent,
16
- };
17
-
18
- export default meta;
19
- type Story = StoryObj<typeof meta>;
20
-
21
- const samplePages: MultiPageDialogPage[] = [
22
- {
23
- id: "profile",
24
- title: "User Profile",
25
- description: "Manage your personal information",
26
- icon: UserIcon,
27
- content: (
28
- <div className="s-space-y-4">
29
- <div>
30
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
31
- Personal Information
32
- </h3>
33
- <p className="s-text-sm s-text-muted-foreground">
34
- Update your profile details and preferences.
35
- </p>
36
- </div>
37
- <div className="s-space-y-3">
38
- <div>
39
- <label className="s-text-sm s-font-medium">Full Name</label>
40
- <input
41
- type="text"
42
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
43
- placeholder="John Doe"
44
- />
45
- </div>
46
- <div>
47
- <label className="s-text-sm s-font-medium">Email</label>
48
- <input
49
- type="email"
50
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
51
- placeholder="john@example.com"
52
- />
53
- </div>
54
- </div>
55
- </div>
56
- ),
57
- },
58
- {
59
- id: "documents",
60
- title: "Documents",
61
- description: "Manage your uploaded files",
62
- icon: DocumentTextIcon,
63
- content: (
64
- <div className="s-space-y-4">
65
- <div>
66
- <h3 className="s-mb-2 s-text-lg s-font-semibold">File Management</h3>
67
- <p className="s-text-sm s-text-muted-foreground">
68
- Upload, organize, and manage your documents.
69
- </p>
70
- </div>
71
- <div className="s-space-y-2">
72
- <div className="s-flex s-items-center s-justify-between s-rounded-md s-border s-p-3">
73
- <span className="s-text-sm">document1.pdf</span>
74
- <Button label="Download" size="sm" variant="outline" />
75
- </div>
76
- <div className="s-flex s-items-center s-justify-between s-rounded-md s-border s-p-3">
77
- <span className="s-text-sm">report.docx</span>
78
- <Button label="Download" size="sm" variant="outline" />
79
- </div>
80
- </div>
81
- </div>
82
- ),
83
- },
84
- {
85
- id: "settings",
86
- title: "Settings",
87
- description: "Configure your preferences",
88
- icon: Cog6ToothIcon,
89
- content: (
90
- <div className="s-space-y-4">
91
- <div>
92
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
93
- Application Settings
94
- </h3>
95
- <p className="s-text-sm s-text-muted-foreground">
96
- Customize your experience and notification preferences.
97
- </p>
98
- </div>
99
- <div className="s-space-y-3">
100
- <div className="s-flex s-items-center s-justify-between">
101
- <span className="s-text-sm">Email notifications</span>
102
- <input type="checkbox" className="s-rounded" defaultChecked />
103
- </div>
104
- <div className="s-flex s-items-center s-justify-between">
105
- <span className="s-text-sm">Dark mode</span>
106
- <input type="checkbox" className="s-rounded" />
107
- </div>
108
- <div className="s-flex s-items-center s-justify-between">
109
- <span className="s-text-sm">Auto-save</span>
110
- <input type="checkbox" className="s-rounded" defaultChecked />
111
- </div>
112
- </div>
113
- </div>
114
- ),
115
- },
116
- ];
117
-
118
- const MultiPageDialogDemo = () => {
119
- const [currentPageId, setCurrentPageId] = useState("profile");
120
- const [isOpen, setIsOpen] = useState(false);
121
-
122
- const handleSave = () => {
123
- alert("Changes saved!");
124
- setIsOpen(false);
125
- };
126
-
127
- const handleCancel = () => {
128
- setIsOpen(false);
129
- };
130
-
131
- return (
132
- <MultiPageDialog open={isOpen} onOpenChange={setIsOpen}>
133
- <MultiPageDialogTrigger asChild>
134
- <Button label="Open Multi-Page Dialog" />
135
- </MultiPageDialogTrigger>
136
- <MultiPageDialogContent
137
- pages={samplePages}
138
- currentPageId={currentPageId}
139
- onPageChange={setCurrentPageId}
140
- size="xl"
141
- leftButton={{
142
- label: "Cancel",
143
- variant: "outline",
144
- onClick: handleCancel,
145
- }}
146
- rightButton={{
147
- label: "Save Changes",
148
- variant: "primary",
149
- onClick: handleSave,
150
- }}
151
- />
152
- </MultiPageDialog>
153
- );
154
- };
155
-
156
- export const Default: Story = {
157
- render: () => <MultiPageDialogDemo />,
158
- };
159
-
160
- // Simple two-button example (like your screenshot)
161
- export const SimpleToolDialog: Story = {
162
- render: () => {
163
- const [isOpen, setIsOpen] = useState(false);
164
- const [selectedTools, setSelectedTools] = useState<string[]>([]);
165
-
166
- const handleAddTools = () => {
167
- alert(
168
- `Adding ${selectedTools.length} tools: ${selectedTools.join(", ")}`
169
- );
170
- setIsOpen(false);
171
- };
172
-
173
- const handleCancel = () => {
174
- setSelectedTools([]);
175
- setIsOpen(false);
176
- };
177
-
178
- const toggleTool = (tool: string) => {
179
- setSelectedTools((prev) =>
180
- prev.includes(tool) ? prev.filter((t) => t !== tool) : [...prev, tool]
181
- );
182
- };
183
-
184
- const toolPages: MultiPageDialogPage[] = [
185
- {
186
- id: "tool-selection",
187
- title: "Add tools",
188
- content: (
189
- <div className="s-space-y-6">
190
- <div className="s-space-y-4">
191
- <h3 className="s-text-lg s-font-semibold">Capabilities</h3>
192
- <div className="s-grid s-grid-cols-2 s-gap-3">
193
- {[
194
- {
195
- name: "Image generation",
196
- desc: "Generate images using natural language",
197
- },
198
- {
199
- name: "Run agent",
200
- desc: "Run a child agent (agent as tool)",
201
- },
202
- {
203
- name: "Interactive content",
204
- desc: "Generate interactive content",
205
- },
206
- {
207
- name: "Agent memory",
208
- desc: "Store and recall information",
209
- },
210
- ].map((tool) => (
211
- <div
212
- key={tool.name}
213
- className={`s-cursor-pointer s-rounded-lg s-border s-p-4 s-transition-colors hover:s-bg-gray-50 ${
214
- selectedTools.includes(tool.name)
215
- ? "s-border-blue-300 s-bg-blue-50"
216
- : "s-border-gray-200"
217
- }`}
218
- onClick={() => toggleTool(tool.name)}
219
- >
220
- <div className="s-flex s-items-start s-justify-between">
221
- <div>
222
- <h4 className="s-font-medium">{tool.name}</h4>
223
- <p className="s-text-sm s-text-gray-600">{tool.desc}</p>
224
- </div>
225
- {selectedTools.includes(tool.name) && (
226
- <span className="s-rounded s-bg-green-100 s-px-2 s-py-1 s-text-xs s-text-green-700">
227
- ADDED
228
- </span>
229
- )}
230
- </div>
231
- {!selectedTools.includes(tool.name) && (
232
- <button className="s-mt-2 s-text-sm s-text-blue-600 hover:s-text-blue-700">
233
- + Add
234
- </button>
235
- )}
236
- </div>
237
- ))}
238
- </div>
239
- </div>
240
-
241
- {selectedTools.length > 0 && (
242
- <div className="s-space-y-3">
243
- <h4 className="s-font-medium">Added tools</h4>
244
- <div className="s-flex s-flex-wrap s-gap-2">
245
- {selectedTools.map((tool) => (
246
- <span
247
- key={tool}
248
- className="s-flex s-items-center s-gap-1 s-rounded s-bg-gray-100 s-px-3 s-py-1 s-text-sm"
249
- >
250
- {tool}
251
- <button
252
- onClick={(e) => {
253
- e.stopPropagation();
254
- toggleTool(tool);
255
- }}
256
- className="s-ml-1 s-text-gray-500 hover:s-text-gray-700"
257
- >
258
- ×
259
- </button>
260
- </span>
261
- ))}
262
- </div>
263
- </div>
264
- )}
265
- </div>
266
- ),
267
- },
268
- ];
269
-
270
- return (
271
- <MultiPageDialog open={isOpen} onOpenChange={setIsOpen}>
272
- <MultiPageDialogTrigger asChild>
273
- <Button label="Add tools" />
274
- </MultiPageDialogTrigger>
275
- <MultiPageDialogContent
276
- pages={toolPages}
277
- currentPageId="tool-selection"
278
- onPageChange={() => {}}
279
- size="xl"
280
- leftButton={{
281
- label: "Cancel",
282
- variant: "outline",
283
- onClick: handleCancel,
284
- }}
285
- rightButton={{
286
- label:
287
- selectedTools.length > 0
288
- ? `Add ${selectedTools.length} tool${selectedTools.length > 1 ? "s" : ""}`
289
- : "Add tools",
290
- variant: "primary",
291
- disabled: selectedTools.length === 0,
292
- onClick: handleAddTools,
293
- }}
294
- />
295
- </MultiPageDialog>
296
- );
297
- },
298
- };
299
-
300
- export const InteractiveContent: Story = {
301
- render: () => {
302
- const [currentPageId, setCurrentPageId] = useState("step1");
303
- const [isOpen, setIsOpen] = useState(false);
304
- const [formData, setFormData] = useState({
305
- name: "",
306
- email: "",
307
- selectedFile: "",
308
- notifications: false,
309
- });
310
-
311
- const handleSave = () => {
312
- alert(`Setup completed! Data: ${JSON.stringify(formData, null, 2)}`);
313
- setIsOpen(false);
314
- };
315
-
316
- const handleCancel = () => {
317
- setIsOpen(false);
318
- };
319
-
320
- const handleNext = () => {
321
- if (currentPageId === "step1") {
322
- setCurrentPageId("step2");
323
- } else if (currentPageId === "step2") {
324
- setCurrentPageId("step3");
325
- }
326
- };
327
-
328
- const handlePrevious = () => {
329
- if (currentPageId === "step3") {
330
- setCurrentPageId("step2");
331
- } else if (currentPageId === "step2") {
332
- setCurrentPageId("step1");
333
- }
334
- };
335
-
336
- const canProceed = () => {
337
- if (currentPageId === "step1") {
338
- return formData.name && formData.email;
339
- }
340
- if (currentPageId === "step2") {
341
- return formData.selectedFile;
342
- }
343
- return true;
344
- };
345
-
346
- const isFirstPage = currentPageId === "step1";
347
- const isLastPage = currentPageId === "step3";
348
-
349
- const interactivePages: MultiPageDialogPage[] = [
350
- {
351
- id: "step1",
352
- title: "Personal Info",
353
- description: "Enter your basic information",
354
- icon: UserIcon,
355
- content: (
356
- <div className="s-space-y-4">
357
- <div>
358
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
359
- Let's get started
360
- </h3>
361
- <p className="s-text-sm s-text-muted-foreground">
362
- Fill in your details to continue to the next step.
363
- </p>
364
- </div>
365
- <div className="s-space-y-3">
366
- <div>
367
- <label className="s-text-sm s-font-medium">Full Name *</label>
368
- <input
369
- type="text"
370
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
371
- placeholder="Enter your name"
372
- value={formData.name}
373
- onChange={(e) =>
374
- setFormData({ ...formData, name: e.target.value })
375
- }
376
- />
377
- </div>
378
- <div>
379
- <label className="s-text-sm s-font-medium">Email *</label>
380
- <input
381
- type="email"
382
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
383
- placeholder="Enter your email"
384
- value={formData.email}
385
- onChange={(e) =>
386
- setFormData({ ...formData, email: e.target.value })
387
- }
388
- />
389
- </div>
390
- </div>
391
- </div>
392
- ),
393
- },
394
- {
395
- id: "step2",
396
- title: "File Selection",
397
- description: "Choose your files",
398
- icon: DocumentTextIcon,
399
- content: (
400
- <div className="s-space-y-4">
401
- <div>
402
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
403
- Select a file to work with
404
- </h3>
405
- <p className="s-text-sm s-text-muted-foreground">
406
- Choose from the available files below.
407
- </p>
408
- </div>
409
- <div className="s-space-y-2">
410
- {[
411
- "project-proposal.pdf",
412
- "budget-2024.xlsx",
413
- "meeting-notes.docx",
414
- ].map((file) => (
415
- <div
416
- key={file}
417
- className={`s-flex s-cursor-pointer s-items-center s-justify-between s-rounded-md s-border s-p-3 s-transition-colors hover:s-bg-gray-50 ${
418
- formData.selectedFile === file
419
- ? "s-border-blue-300 s-bg-blue-50"
420
- : ""
421
- }`}
422
- onClick={() =>
423
- setFormData({ ...formData, selectedFile: file })
424
- }
425
- >
426
- <span className="s-text-sm">{file}</span>
427
- <div className="s-flex s-items-center s-gap-2">
428
- <input
429
- type="radio"
430
- checked={formData.selectedFile === file}
431
- readOnly
432
- className="s-pointer-events-none"
433
- />
434
- </div>
435
- </div>
436
- ))}
437
- </div>
438
- </div>
439
- ),
440
- },
441
- {
442
- id: "step3",
443
- title: "Final Settings",
444
- description: "Configure your preferences",
445
- icon: Cog6ToothIcon,
446
- content: (
447
- <div className="s-space-y-4">
448
- <div>
449
- <h3 className="s-mb-2 s-text-lg s-font-semibold">Almost done!</h3>
450
- <p className="s-text-sm s-text-muted-foreground">
451
- Configure your final preferences and complete the setup.
452
- </p>
453
- </div>
454
- <div className="s-space-y-3">
455
- <div className="s-flex s-items-center s-justify-between">
456
- <span className="s-text-sm">Enable email notifications</span>
457
- <input
458
- type="checkbox"
459
- className="s-rounded"
460
- checked={formData.notifications}
461
- onChange={(e) =>
462
- setFormData({
463
- ...formData,
464
- notifications: e.target.checked,
465
- })
466
- }
467
- />
468
- </div>
469
- <div className="s-rounded-md s-bg-gray-50 s-p-3">
470
- <h4 className="s-mb-2 s-text-sm s-font-medium">Summary</h4>
471
- <div className="s-space-y-1 s-text-xs s-text-gray-600">
472
- <div>Name: {formData.name}</div>
473
- <div>Email: {formData.email}</div>
474
- <div>Selected File: {formData.selectedFile}</div>
475
- <div>
476
- Notifications:{" "}
477
- {formData.notifications ? "Enabled" : "Disabled"}
478
- </div>
479
- </div>
480
- </div>
481
- </div>
482
- </div>
483
- ),
484
- },
485
- ];
486
-
487
- return (
488
- <MultiPageDialog open={isOpen} onOpenChange={setIsOpen}>
489
- <MultiPageDialogTrigger asChild>
490
- <Button label="Open Interactive Setup" />
491
- </MultiPageDialogTrigger>
492
- <MultiPageDialogContent
493
- pages={interactivePages}
494
- currentPageId={currentPageId}
495
- onPageChange={setCurrentPageId}
496
- size="lg"
497
- leftButton={{
498
- label: "Cancel",
499
- variant: "outline",
500
- onClick: handleCancel,
501
- }}
502
- centerButton={
503
- !isFirstPage
504
- ? {
505
- label: "Previous",
506
- variant: "outline",
507
- onClick: handlePrevious,
508
- }
509
- : undefined
510
- }
511
- rightButton={{
512
- label: isLastPage ? "Complete Setup" : "Next",
513
- variant: "primary",
514
- disabled: !canProceed(),
515
- onClick: isLastPage ? handleSave : handleNext,
516
- }}
517
- />
518
- </MultiPageDialog>
519
- );
520
- },
521
- };
522
-
523
- export const WithConditionalNavigation: Story = {
524
- render: () => {
525
- const [currentPageId, setCurrentPageId] = useState("data-selection");
526
- const [isOpen, setIsOpen] = useState(false);
527
- const [selectedItems, setSelectedItems] = useState<string[]>([]);
528
- const [description, setDescription] = useState("");
529
-
530
- const handleSave = () => {
531
- alert(
532
- `Configuration saved! Selected: ${selectedItems.join(", ")}, Description: ${description}`
533
- );
534
- setIsOpen(false);
535
- };
536
-
537
- const handleCancel = () => {
538
- setIsOpen(false);
539
- };
540
-
541
- const handleNext = () => {
542
- if (currentPageId === "data-selection") {
543
- setCurrentPageId("description");
544
- }
545
- };
546
-
547
- const handlePrevious = () => {
548
- if (currentPageId === "description") {
549
- setCurrentPageId("data-selection");
550
- }
551
- };
552
-
553
- const isFirstPage = currentPageId === "data-selection";
554
- const isLastPage = currentPageId === "description";
555
- const canProceedFromFirst = selectedItems.length > 0;
556
- const canSave = description.trim().length > 0;
557
-
558
- const conditionalPages: MultiPageDialogPage[] = [
559
- {
560
- id: "data-selection",
561
- title: "Select Data Sources",
562
- description: "Choose which data sources to include",
563
- icon: DocumentTextIcon,
564
- content: (
565
- <div className="s-space-y-4">
566
- <div>
567
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
568
- Available Data Sources
569
- </h3>
570
- <p className="s-text-sm s-text-muted-foreground">
571
- Select at least one data source to proceed to the next step.
572
- </p>
573
- </div>
574
- <div className="s-space-y-2">
575
- {[
576
- "Company Database",
577
- "Customer Files",
578
- "Analytics Data",
579
- "Reports Archive",
580
- ].map((item) => (
581
- <div
582
- key={item}
583
- className={`s-flex s-cursor-pointer s-items-center s-justify-between s-rounded-md s-border s-p-3 s-transition-colors hover:s-bg-gray-50 ${
584
- selectedItems.includes(item)
585
- ? "s-border-blue-300 s-bg-blue-50"
586
- : ""
587
- }`}
588
- onClick={() => {
589
- if (selectedItems.includes(item)) {
590
- setSelectedItems(selectedItems.filter((i) => i !== item));
591
- } else {
592
- setSelectedItems([...selectedItems, item]);
593
- }
594
- }}
595
- >
596
- <span className="s-text-sm">{item}</span>
597
- <input
598
- type="checkbox"
599
- checked={selectedItems.includes(item)}
600
- readOnly
601
- className="s-pointer-events-none"
602
- />
603
- </div>
604
- ))}
605
- </div>
606
- {selectedItems.length > 0 && (
607
- <div className="s-rounded-md s-border s-bg-blue-50 s-p-3">
608
- <p className="s-text-sm s-text-blue-700">
609
- {selectedItems.length} data source
610
- {selectedItems.length !== 1 ? "s" : ""} selected
611
- </p>
612
- </div>
613
- )}
614
- </div>
615
- ),
616
- },
617
- {
618
- id: "description",
619
- title: "Add Description",
620
- description: "Describe your configuration",
621
- icon: Cog6ToothIcon,
622
- content: (
623
- <div className="s-space-y-4">
624
- <div>
625
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
626
- Configuration Details
627
- </h3>
628
- <p className="s-text-sm s-text-muted-foreground">
629
- Add a description for your selected data sources.
630
- </p>
631
- </div>
632
- <div className="s-rounded-md s-border s-bg-blue-50 s-p-3">
633
- <p className="s-text-sm s-text-blue-700">
634
- Selected: {selectedItems.join(", ")}
635
- </p>
636
- </div>
637
- <div className="s-space-y-2">
638
- <label className="s-text-sm s-font-medium">Description</label>
639
- <textarea
640
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
641
- placeholder="Describe how these data sources will be used..."
642
- value={description}
643
- onChange={(e) => setDescription(e.target.value)}
644
- rows={4}
645
- />
646
- <p className="s-text-xs s-text-muted-foreground">
647
- This description helps explain the purpose of your
648
- configuration.
649
- </p>
650
- </div>
651
- </div>
652
- ),
653
- },
654
- ];
655
-
656
- return (
657
- <MultiPageDialog open={isOpen} onOpenChange={setIsOpen}>
658
- <MultiPageDialogTrigger asChild>
659
- <Button label="Open Configuration Wizard" />
660
- </MultiPageDialogTrigger>
661
- <MultiPageDialogContent
662
- pages={conditionalPages}
663
- currentPageId={currentPageId}
664
- onPageChange={setCurrentPageId}
665
- size="lg"
666
- leftButton={{
667
- label: "Cancel",
668
- variant: "outline",
669
- onClick: handleCancel,
670
- }}
671
- centerButton={
672
- !isFirstPage
673
- ? {
674
- label: "Previous",
675
- variant: "outline",
676
- onClick: handlePrevious,
677
- }
678
- : undefined
679
- }
680
- rightButton={{
681
- label: isLastPage ? "Save Configuration" : "Next",
682
- variant: "primary",
683
- disabled: isFirstPage ? !canProceedFromFirst : !canSave,
684
- onClick: isLastPage ? handleSave : handleNext,
685
- }}
686
- footerContent={
687
- <div className="s-rounded s-bg-blue-50 s-px-3 s-py-2">
688
- <p className="s-text-xs s-text-blue-700">
689
- {selectedItems.length > 0 && (
690
- <>
691
- {selectedItems.length} data source
692
- {selectedItems.length !== 1 ? "s" : ""} selected •{" "}
693
- </>
694
- )}
695
- Step {isFirstPage ? "1" : "2"} of 2
696
- </p>
697
- </div>
698
- }
699
- />
700
- </MultiPageDialog>
701
- );
702
- },
703
- };
704
-
705
- export const ScrollableContent: Story = {
706
- render: () => {
707
- const [currentPageId, setCurrentPageId] = useState("long-form");
708
- const [isOpen, setIsOpen] = useState(false);
709
-
710
- const handleSave = () => {
711
- alert("Long form submitted!");
712
- setIsOpen(false);
713
- };
714
-
715
- const handleCancel = () => {
716
- setIsOpen(false);
717
- };
718
-
719
- const handleNext = () => {
720
- if (currentPageId === "long-form") {
721
- setCurrentPageId("summary");
722
- }
723
- };
724
-
725
- const handlePrevious = () => {
726
- if (currentPageId === "summary") {
727
- setCurrentPageId("long-form");
728
- }
729
- };
730
-
731
- const isFirstPage = currentPageId === "long-form";
732
- const isLastPage = currentPageId === "summary";
733
-
734
- const scrollablePages: MultiPageDialogPage[] = [
735
- {
736
- id: "long-form",
737
- title: "Long Form Content",
738
- description: "This page demonstrates scrollable content",
739
- icon: DocumentTextIcon,
740
- content: (
741
- <div className="s-space-y-6">
742
- <div>
743
- <h3 className="s-mb-2 s-text-lg s-font-semibold">
744
- Terms and Conditions
745
- </h3>
746
- <p className="s-text-sm s-text-muted-foreground">
747
- This page contains a lot of content to demonstrate scrolling
748
- functionality. The content should be scrollable within the
749
- dialog area.
750
- </p>
751
- </div>
752
-
753
- {Array.from({ length: 15 }, (_, i) => (
754
- <div key={i} className="s-space-y-3">
755
- <h4 className="s-text-md s-font-semibold">Section {i + 1}</h4>
756
- <p className="s-text-sm s-text-muted-foreground">
757
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
758
- do eiusmod tempor incididunt ut labore et dolore magna aliqua.
759
- Ut enim ad minim veniam, quis nostrud exercitation ullamco
760
- laboris nisi ut aliquip ex ea commodo consequat. Duis aute
761
- irure dolor in reprehenderit in voluptate velit esse cillum
762
- dolore eu fugiat nulla pariatur.
763
- </p>
764
- <div className="s-space-y-2">
765
- <div>
766
- <label className="s-text-sm s-font-medium">
767
- Field {i + 1}
768
- </label>
769
- <input
770
- type="text"
771
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
772
- placeholder={`Enter value for field ${i + 1}`}
773
- />
774
- </div>
775
- {i % 3 === 0 && (
776
- <div>
777
- <label className="s-text-sm s-font-medium">
778
- Additional Notes
779
- </label>
780
- <textarea
781
- className="s-mt-1 s-w-full s-rounded-md s-border s-px-3 s-py-2"
782
- placeholder="Add any additional notes here..."
783
- rows={3}
784
- />
785
- </div>
786
- )}
787
- </div>
788
- </div>
789
- ))}
790
-
791
- <div className="s-rounded-md s-border s-bg-blue-50 s-p-4">
792
- <h4 className="s-mb-2 s-text-sm s-font-semibold s-text-blue-900">
793
- Scroll Test Complete
794
- </h4>
795
- <p className="s-text-xs s-text-blue-700">
796
- If you can see this message, the scrolling functionality is
797
- working correctly! The dialog maintains its fixed height while
798
- allowing the content to scroll.
799
- </p>
800
- </div>
801
- </div>
802
- ),
803
- },
804
- {
805
- id: "summary",
806
- title: "Summary",
807
- description: "Review your information",
808
- icon: Cog6ToothIcon,
809
- content: (
810
- <div className="s-space-y-4">
811
- <div>
812
- <h3 className="s-mb-2 s-text-lg s-font-semibold">Form Summary</h3>
813
- <p className="s-text-sm s-text-muted-foreground">
814
- Thank you for testing the scrollable content functionality.
815
- </p>
816
- </div>
817
- <div className="s-rounded-md s-border s-bg-green-50 s-p-3">
818
- <p className="s-text-sm s-text-green-700">
819
- ✓ Scrolling functionality verified
820
- </p>
821
- <p className="s-text-sm s-text-green-700">
822
- ✓ Fixed dialog height maintained
823
- </p>
824
- <p className="s-text-sm s-text-green-700">
825
- ✓ Content overflow handled properly
826
- </p>
827
- </div>
828
- </div>
829
- ),
830
- },
831
- ];
832
-
833
- return (
834
- <MultiPageDialog open={isOpen} onOpenChange={setIsOpen}>
835
- <MultiPageDialogTrigger asChild>
836
- <Button label="Open Scrollable Content Dialog" />
837
- </MultiPageDialogTrigger>
838
- <MultiPageDialogContent
839
- pages={scrollablePages}
840
- currentPageId={currentPageId}
841
- onPageChange={setCurrentPageId}
842
- size="lg"
843
- leftButton={{
844
- label: "Cancel",
845
- variant: "outline",
846
- onClick: handleCancel,
847
- }}
848
- centerButton={
849
- !isFirstPage
850
- ? {
851
- label: "Previous",
852
- variant: "outline",
853
- onClick: handlePrevious,
854
- }
855
- : undefined
856
- }
857
- rightButton={{
858
- label: isLastPage ? "Submit Form" : "Next",
859
- variant: "primary",
860
- onClick: isLastPage ? handleSave : handleNext,
861
- }}
862
- />
863
- </MultiPageDialog>
864
- );
865
- },
866
- };