@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
@@ -28,6 +28,35 @@ import {
28
28
  import { CommandLineIcon, SparklesIcon } from "@sparkle/icons/app";
29
29
  import { cn } from "@sparkle/lib/utils";
30
30
 
31
+ const PRETTY_JSON_PREFERENCE_KEY = "pretty-json-preference";
32
+
33
+ const getPrettyJsonPreference = (): boolean => {
34
+ if (typeof window === "undefined") {
35
+ return false;
36
+ }
37
+
38
+ try {
39
+ const prettyJsonPreference = localStorage.getItem(
40
+ PRETTY_JSON_PREFERENCE_KEY
41
+ );
42
+ return prettyJsonPreference === "true";
43
+ } catch {
44
+ return false;
45
+ }
46
+ };
47
+
48
+ const setPrettyJsonPreference = (value: boolean): void => {
49
+ if (typeof window === "undefined") {
50
+ return;
51
+ }
52
+
53
+ try {
54
+ localStorage.setItem(PRETTY_JSON_PREFERENCE_KEY, String(value));
55
+ } catch {
56
+ // do nothing
57
+ }
58
+ };
59
+
31
60
  // Helper function to ensure we get hex values
32
61
  const toHex = (color: string) => {
33
62
  if (color.startsWith("#")) {
@@ -330,7 +359,8 @@ export function CodeBlockWithExtendedSupport({
330
359
  try {
331
360
  const parsed = JSON.parse(validChildrenContent);
332
361
  setParsedJson(parsed);
333
- setShowPrettyJson(true);
362
+ const prettyJsonPreference = getPrettyJsonPreference();
363
+ setShowPrettyJson(prettyJsonPreference);
334
364
  } catch (e) {
335
365
  setParsedJson(null);
336
366
  setShowPrettyJson(false);
@@ -353,6 +383,7 @@ export function CodeBlockWithExtendedSupport({
353
383
  getContentToDownload={getContentToDownload}
354
384
  actions={
355
385
  <Button
386
+ className="s-font-sans"
356
387
  size="xs"
357
388
  variant={"outline"}
358
389
  label={showMermaid ? "Markdown" : "Mermaid"}
@@ -361,6 +392,7 @@ export function CodeBlockWithExtendedSupport({
361
392
  tooltip={showMermaid ? "Switch to Markdown" : "Switch to Mermaid"}
362
393
  />
363
394
  }
395
+ buttonDisplay="inside"
364
396
  >
365
397
  {showMermaid ? (
366
398
  <MermaidGraph chart={validChildrenContent} />
@@ -380,17 +412,23 @@ export function CodeBlockWithExtendedSupport({
380
412
  getContentToDownload={getContentToDownload}
381
413
  actions={
382
414
  <Button
415
+ className="s-font-sans"
383
416
  size="xs"
384
417
  variant={"outline"}
385
418
  label={showPrettyJson ? "Raw JSON" : "Pretty JSON"}
386
419
  icon={showPrettyJson ? CommandLineIcon : SparklesIcon}
387
- onClick={() => setShowPrettyJson(!showPrettyJson)}
420
+ onClick={() => {
421
+ const newValue = !showPrettyJson;
422
+ setShowPrettyJson(newValue);
423
+ setPrettyJsonPreference(newValue);
424
+ }}
388
425
  tooltip={
389
426
  showPrettyJson ? "Switch to Raw JSON" : "Switch to Pretty View"
390
427
  }
391
428
  />
392
429
  }
393
430
  displayActions="hover"
431
+ buttonDisplay="inside"
394
432
  >
395
433
  {showPrettyJson ? (
396
434
  <PrettyJsonViewer data={parsedJson} />
@@ -407,6 +445,7 @@ export function CodeBlockWithExtendedSupport({
407
445
  <ContentBlockWrapper
408
446
  content={validChildrenContent}
409
447
  getContentToDownload={getContentToDownload}
448
+ buttonDisplay="inside"
410
449
  >
411
450
  <CodeBlock className={className} inline={inline}>
412
451
  {children}
@@ -1,3 +1,4 @@
1
+ import { cva } from "class-variance-authority";
1
2
  import React, { useCallback } from "react";
2
3
 
3
4
  import { Button } from "@sparkle/components/";
@@ -16,6 +17,51 @@ const contentTypeExtensions: Record<SupportedContentType, string> = {
16
17
  "text/csv": ".csv",
17
18
  };
18
19
 
20
+ const wrapperVariants = cva("s-group s-relative s-w-full !s-overflow-visible", {
21
+ variants: {
22
+ buttonDisplay: {
23
+ inside: "s-mt-0",
24
+ outside: "s-mt-11",
25
+ },
26
+ },
27
+ defaultVariants: {
28
+ buttonDisplay: "outside",
29
+ },
30
+ });
31
+
32
+ const stickyContainerVariants = cva("s-sticky s-z-[1] s-h-0", {
33
+ variants: {
34
+ buttonDisplay: {
35
+ inside: "s-top-0",
36
+ outside: "s-top-11",
37
+ },
38
+ },
39
+ defaultVariants: {
40
+ buttonDisplay: "outside",
41
+ },
42
+ });
43
+
44
+ const actionsVariants = cva(
45
+ "s-absolute s-right-2 s-flex s-items-center s-gap-1 s-py-2",
46
+ {
47
+ variants: {
48
+ buttonDisplay: {
49
+ inside: "",
50
+ outside: "s-bottom-0 s-h-11",
51
+ },
52
+ displayActions: {
53
+ hover:
54
+ "s-opacity-0 s-transition-opacity s-duration-200 group-hover:s-opacity-100",
55
+ always: "",
56
+ },
57
+ },
58
+ defaultVariants: {
59
+ buttonDisplay: "outside",
60
+ displayActions: "always",
61
+ },
62
+ }
63
+ );
64
+
19
65
  export interface ContentToDownload {
20
66
  content: string;
21
67
  filename: string;
@@ -37,6 +83,7 @@ interface ContentBlockWrapperProps {
37
83
  getContentToDownload?: GetContentToDownloadFunction;
38
84
  actions?: React.ReactNode[] | React.ReactNode;
39
85
  displayActions?: "hover" | "always";
86
+ buttonDisplay?: "inside" | "outside";
40
87
  }
41
88
 
42
89
  export function ContentBlockWrapper({
@@ -47,6 +94,7 @@ export function ContentBlockWrapper({
47
94
  actions,
48
95
  displayActions = "always",
49
96
  getContentToDownload,
97
+ buttonDisplay = "outside",
50
98
  }: ContentBlockWrapperProps) {
51
99
  const [isCopied, copyToClipboard] = useCopyToClipboard();
52
100
 
@@ -92,19 +140,12 @@ export function ContentBlockWrapper({
92
140
  return (
93
141
  <div
94
142
  id="BlockWrapper"
95
- className={cn(
96
- "s-group s-relative s-mt-11 s-w-full !s-overflow-visible",
97
- className
98
- )}
143
+ className={cn(wrapperVariants({ buttonDisplay }), className)}
99
144
  >
100
- <div className="s-sticky s-top-11 s-z-[1] s-h-0">
145
+ <div className={stickyContainerVariants({ buttonDisplay })}>
101
146
  <div
102
147
  id="BlockActions"
103
- className={cn(
104
- "s-absolute s-bottom-0 s-right-2 s-flex s-h-11 s-items-center s-gap-1 s-py-2",
105
- displayActions === "hover" &&
106
- "s-opacity-0 s-transition-opacity s-duration-200 group-hover:s-opacity-100"
107
- )}
148
+ className={actionsVariants({ buttonDisplay, displayActions })}
108
149
  >
109
150
  {actions && actions}
110
151
  {getContentToDownload && (
@@ -29,12 +29,12 @@ import { cn } from "@sparkle/lib/utils";
29
29
 
30
30
  const sizes = {
31
31
  p: "s-copy-sm @sm:s-text-base @sm:s-leading-7",
32
- h1: "s-heading-2xl",
33
- h2: "s-heading-xl",
34
- h3: "s-heading-lg",
35
- h4: "s-text-base s-font-semibold",
36
- h5: "s-text-sm s-font-semibold",
37
- h6: "s-text-sm s-font-regular s-italic",
32
+ h1: "s-heading-3xl",
33
+ h2: "s-heading-2xl",
34
+ h3: "s-heading-xl",
35
+ h4: "s-heading-lg",
36
+ h5: "s-text-base s-font-bold",
37
+ h6: "s-text-base s-font-regular s-italic",
38
38
  };
39
39
 
40
40
  function showUnsupportedDirective() {
@@ -162,7 +162,7 @@ function JsonValue({
162
162
  <div
163
163
  key={key}
164
164
  className={cn(
165
- "s-max-w-full s-border-b s-pb-3 last:s-border-0",
165
+ "s-max-w-full s-border-b s-pb-3 last:s-border-0 last:s-pb-0",
166
166
  "s-border-structure-200 dark:s-border-structure-200-night"
167
167
  )}
168
168
  >
@@ -211,7 +211,7 @@ export function PrettyJsonViewer({ data, className }: JsonViewerProps) {
211
211
  <div
212
212
  className={cn(
213
213
  "s-bg-structure-50 dark:s-bg-structure-50-night",
214
- "s-overflow-hidden s-rounded-lg s-px-4 s-text-base",
214
+ "s-overflow-hidden s-rounded-lg s-px-4 s-py-4 s-text-base",
215
215
  className
216
216
  )}
217
217
  >
@@ -1 +1,3 @@
1
1
  export * from "./useCopyToClipboard";
2
+ export * from "./useHashParams";
3
+ export * from "./usePaginationFromUrl";
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Original code from : https://www.npmjs.com/package/use-hash-param
3
+ * ISC License
4
+ */
5
+
6
+ import { useCallback, useEffect, useState } from "react";
7
+
8
+ const getHashSearchParams = (location: Location): [string, URLSearchParams] => {
9
+ const hash = location.hash.slice(1);
10
+ const [prefix, query] = hash.split("?");
11
+
12
+ return [prefix, new URLSearchParams(query)];
13
+ };
14
+
15
+ const getHashParam = (key: string, defaultValue?: string) => {
16
+ if (typeof window === "undefined") {
17
+ return defaultValue;
18
+ }
19
+
20
+ const [, searchParams] = getHashSearchParams(window.location);
21
+
22
+ return searchParams.get(key) ?? defaultValue;
23
+ };
24
+
25
+ const setHashParam = (
26
+ key: string,
27
+ value: string | undefined,
28
+ shouldReplaceState: boolean
29
+ ) => {
30
+ if (typeof window !== "undefined") {
31
+ const { pathname, search } = window.location;
32
+ const [prefix, searchParams] = getHashSearchParams(window.location);
33
+
34
+ if (typeof value === "undefined" || value === "") {
35
+ searchParams.delete(key);
36
+ } else {
37
+ searchParams.set(key, value);
38
+ }
39
+
40
+ const hashSearch = searchParams.toString();
41
+ const hash = hashSearch ? `${prefix}?${hashSearch}` : prefix;
42
+ const newUrl = `${pathname}${search}#${hash}`;
43
+
44
+ if (shouldReplaceState && "replaceState" in history) {
45
+ history.replaceState(null, "", newUrl);
46
+ } else {
47
+ window.location.hash = hash;
48
+ }
49
+ }
50
+ };
51
+
52
+ type Updater = (prevValue?: string) => string;
53
+
54
+ export type HistoryOptions = "replace" | "push";
55
+
56
+ type SetterOptions = {
57
+ history: HistoryOptions;
58
+ };
59
+ type Setter = (value?: string | Updater, options?: SetterOptions) => void;
60
+
61
+ /**
62
+ * @param key The parameter-name to use from the hash-string query string.
63
+ * @param defaultValue A default value to use if the parameter is not specified and on the server.
64
+ * @returns A two-tuple, the first element is the selected param value (either extracted from the hash param or the default value).
65
+ * The second element is a setter function to change the param value.
66
+ */
67
+
68
+ export const useHashParam = (
69
+ key: string,
70
+ defaultValue?: string
71
+ ): [string | undefined, Setter] => {
72
+ const [innerValue, setInnerValue] = useState<string | undefined>(() =>
73
+ getHashParam(key, defaultValue)
74
+ );
75
+
76
+ useEffect(() => {
77
+ const handleHashChange = () =>
78
+ setInnerValue(getHashParam(key, defaultValue));
79
+ handleHashChange();
80
+ window.addEventListener("hashchange", handleHashChange);
81
+ return () => window.removeEventListener("hashchange", handleHashChange);
82
+ }, [key]);
83
+
84
+ const setValue = useCallback<Setter>(
85
+ (
86
+ newValue?: string | Updater,
87
+ options: SetterOptions = { history: "replace" }
88
+ ) => {
89
+ const newInnerValue =
90
+ typeof newValue === "function"
91
+ ? newValue(getHashParam(key, defaultValue))
92
+ : newValue;
93
+
94
+ setInnerValue(newInnerValue);
95
+ setHashParam(key, newInnerValue, options.history === "replace");
96
+ },
97
+ [key]
98
+ );
99
+
100
+ return [innerValue || defaultValue, setValue];
101
+ };
@@ -0,0 +1,46 @@
1
+ import { PaginationState } from "@tanstack/react-table";
2
+ import { useMemo } from "react";
3
+
4
+ import { HistoryOptions, useHashParam } from "@sparkle/hooks/useHashParams";
5
+
6
+ const defaultPageSize = 25;
7
+
8
+ export const usePaginationFromUrl = ({
9
+ urlPrefix,
10
+ initialPageSize = defaultPageSize,
11
+ defaultHistory = "push",
12
+ }: {
13
+ urlPrefix?: string;
14
+ initialPageSize?: number;
15
+ defaultHistory?: HistoryOptions;
16
+ }) => {
17
+ const [pageIndexParam, setPageIndexParam] = useHashParam(
18
+ urlPrefix ? `${urlPrefix}PageIndex` : "pageIndex"
19
+ );
20
+ const [pageSizeParam, setPageSizeParam] = useHashParam(
21
+ urlPrefix ? `${urlPrefix}PageSize` : "pageSize"
22
+ );
23
+
24
+ const pageIndex = pageIndexParam ? parseInt(pageIndexParam) : 0;
25
+ const pageSize = pageSizeParam ? parseInt(pageSizeParam) : initialPageSize;
26
+
27
+ const res = useMemo(() => {
28
+ const pagination: PaginationState = { pageIndex, pageSize };
29
+
30
+ const setPagination = (
31
+ newValue: PaginationState,
32
+ history?: HistoryOptions
33
+ ) => {
34
+ if (newValue.pageIndex !== pageIndex || newValue.pageSize !== pageSize) {
35
+ setPageIndexParam(newValue.pageIndex.toString(), {
36
+ history: history ?? defaultHistory,
37
+ });
38
+ setPageSizeParam(newValue.pageSize.toString());
39
+ }
40
+ };
41
+
42
+ return { pagination, setPagination };
43
+ }, [pageIndex, pageSize, urlPrefix]);
44
+
45
+ return res;
46
+ };
@@ -5,13 +5,10 @@ export { default as ChromeLogo } from "./Chrome";
5
5
  export { default as ClaudeLogo } from "./Claude";
6
6
  export { default as CohereLogo } from "./Cohere";
7
7
  export { default as ConfluenceLogo } from "./Confluence";
8
- export { default as DatadogLogo } from "./Datadog";
9
8
  export { default as DeepseekLogo } from "./Deepseek";
10
9
  export { default as DriveLogo } from "./Drive";
11
10
  export { default as FigmaLogo } from "./Figma";
12
11
  export { default as FireworksLogo } from "./Fireworks";
13
- export { default as FreshdeskLogo } from "./Freshdesk";
14
- export { default as FreshserviceLogo } from "./Freshservice";
15
12
  export { default as GcalLogo } from "./Gcal";
16
13
  export { default as GeminiLogo } from "./Gemini";
17
14
  export { default as GithubLogo } from "./Github";
@@ -20,11 +20,7 @@ import {
20
20
  Input,
21
21
  ScrollableDataTable,
22
22
  } from "@sparkle/components/";
23
- import {
24
- createRadioSelectionColumn,
25
- createSelectionColumn,
26
- MenuItem,
27
- } from "@sparkle/components/DataTable";
23
+ import { createSelectionColumn, MenuItem } from "@sparkle/components/DataTable";
28
24
  import { FolderIcon } from "@sparkle/icons/app";
29
25
 
30
26
  const meta = {
@@ -653,59 +649,3 @@ export const DataTableWithRowSelectionExample = () => {
653
649
  </div>
654
650
  );
655
651
  };
656
-
657
- export const DataTableWithRadioSelectionExample = () => {
658
- const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
659
- const [data] = useState<Data[]>(() => createData(0, 10));
660
- const [filter, setFilter] = useState("");
661
-
662
- const columnsWithRadioSelection: ColumnDef<Data>[] = useMemo(
663
- () => [createRadioSelectionColumn<Data>(), ...columns],
664
- []
665
- );
666
-
667
- // Get the selected row ID from rowSelection state
668
- const selectedRowId = Object.keys(rowSelection).find(
669
- (id) => rowSelection[id]
670
- );
671
-
672
- return (
673
- <div className="s-flex s-w-full s-max-w-4xl s-flex-col s-gap-6">
674
- <h3 className="s-text-lg s-font-medium">
675
- DataTable with Radio Selection (Single Row)
676
- </h3>
677
-
678
- <div className="s-flex s-flex-col s-gap-4">
679
- <Input
680
- name="filter"
681
- placeholder="Filter"
682
- value={filter}
683
- onChange={(e) => setFilter(e.target.value)}
684
- />
685
-
686
- <DataTable
687
- data={data}
688
- filter={filter}
689
- filterColumn="name"
690
- columns={columnsWithRadioSelection}
691
- rowSelection={rowSelection}
692
- setRowSelection={setRowSelection}
693
- enableRowSelection={true}
694
- enableMultiRowSelection={false}
695
- getRowId={(row) => row.name}
696
- />
697
-
698
- <div className="s-rounded-md s-border s-bg-muted/50 s-p-2">
699
- <h4 className="s-mb-2 s-font-medium">Radio Selection State:</h4>
700
- <pre className="s-overflow-auto s-text-xs">
701
- {JSON.stringify(rowSelection, null, 2)}
702
- </pre>
703
- <p className="s-mt-2 s-text-sm">
704
- {selectedRowId ? `Selected: ${selectedRowId}` : "No row selected"}{" "}
705
- (only one row can be selected at a time)
706
- </p>
707
- </div>
708
- </div>
709
- </div>
710
- );
711
- };
@@ -29,13 +29,6 @@ const example = `
29
29
 
30
30
  ### Level 3 Title
31
31
 
32
- #### Level 4 Title
33
-
34
- ##### Level 5 Title
35
-
36
- ###### Level 6 Title
37
-
38
-
39
32
  This is a paragraph with **bold** text and *italic* text. This is \`code\` block:
40
33
  \`\`\`
41
34
  Block
@@ -0,0 +1,92 @@
1
+ import type { Meta } from "@storybook/react";
2
+ import React from "react";
3
+
4
+ import { usePaginationFromUrl } from "@sparkle/hooks/usePaginationFromUrl";
5
+
6
+ import { Pagination } from "../index_with_tw_base";
7
+
8
+ const meta = {
9
+ title: "Components/Pagination",
10
+ component: Pagination,
11
+ } satisfies Meta<typeof Pagination>;
12
+
13
+ export default meta;
14
+ export const PaginationSM = () => {
15
+ const [pagination, setPagination] = React.useState({
16
+ pageIndex: 0,
17
+ pageSize: 50,
18
+ });
19
+ return (
20
+ <Pagination
21
+ rowCount={960}
22
+ pagination={pagination}
23
+ setPagination={setPagination}
24
+ />
25
+ );
26
+ };
27
+
28
+ export const PaginationXS = () => {
29
+ const [pagination, setPagination] = React.useState({
30
+ pageIndex: 0,
31
+ pageSize: 50,
32
+ });
33
+ return (
34
+ <Pagination
35
+ rowCount={960}
36
+ size="xs"
37
+ showDetails={false}
38
+ pagination={pagination}
39
+ setPagination={setPagination}
40
+ />
41
+ );
42
+ };
43
+
44
+ export const PaginationNoPageButtons = () => {
45
+ const [pagination, setPagination] = React.useState({
46
+ pageIndex: 0,
47
+ pageSize: 50,
48
+ });
49
+ return (
50
+ <Pagination
51
+ rowCount={960}
52
+ size="xs"
53
+ showDetails={false}
54
+ showPageButtons={false}
55
+ pagination={pagination}
56
+ setPagination={setPagination}
57
+ />
58
+ );
59
+ };
60
+
61
+ export const PaginationButtonsDisabled = () => {
62
+ const [pagination, setPagination] = React.useState({
63
+ pageIndex: 0,
64
+ pageSize: 50,
65
+ });
66
+ return (
67
+ <Pagination
68
+ rowCount={960}
69
+ pagination={pagination}
70
+ setPagination={setPagination}
71
+ disablePaginationNumbers
72
+ />
73
+ );
74
+ };
75
+
76
+ export const PaginationWithUrl = () => {
77
+ const { pagination, setPagination } = usePaginationFromUrl({
78
+ urlPrefix: "example",
79
+ initialPageSize: 50,
80
+ });
81
+
82
+ return (
83
+ <>
84
+ <div className="s-p-2">Current hash: {location.hash}</div>
85
+ <Pagination
86
+ rowCount={960}
87
+ pagination={pagination}
88
+ setPagination={setPagination}
89
+ />
90
+ </>
91
+ );
92
+ };
@@ -1,45 +0,0 @@
1
- import * as React from "react";
2
- import { Button } from "../components";
3
- declare const MULTI_PAGE_DIALOG_SIZES: readonly ["md", "lg", "xl"];
4
- type MultiPageDialogSizeType = (typeof MULTI_PAGE_DIALOG_SIZES)[number];
5
- interface MultiPageDialogPage {
6
- id: string;
7
- title: string;
8
- description?: string;
9
- icon?: React.ComponentType;
10
- content: React.ReactNode;
11
- }
12
- declare const MultiPageDialogRoot: React.FC<import("@radix-ui/react-dialog").DialogProps>;
13
- declare const MultiPageDialogTrigger: React.ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
14
- declare const MultiPageDialogClose: React.ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
15
- interface MultiPageDialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {
16
- leftButton?: React.ComponentProps<typeof Button>;
17
- centerButton?: React.ComponentProps<typeof Button>;
18
- rightButton?: React.ComponentProps<typeof Button>;
19
- }
20
- declare const MultiPageDialogFooter: {
21
- ({ className, children, leftButton, centerButton, rightButton, ...props }: MultiPageDialogFooterProps): React.JSX.Element;
22
- displayName: string;
23
- };
24
- interface MultiPageDialogProps {
25
- pages: MultiPageDialogPage[];
26
- currentPageId: string;
27
- onPageChange: (pageId: string) => void;
28
- size?: MultiPageDialogSizeType;
29
- trapFocusScope?: boolean;
30
- isAlertDialog?: boolean;
31
- showNavigation?: boolean;
32
- showHeaderNavigation?: boolean;
33
- className?: string;
34
- disableNext?: boolean;
35
- leftButton?: React.ComponentProps<typeof Button>;
36
- centerButton?: React.ComponentProps<typeof Button>;
37
- rightButton?: React.ComponentProps<typeof Button>;
38
- footerContent?: React.ReactNode;
39
- }
40
- interface MultiPageDialogContentProps extends MultiPageDialogProps {
41
- children?: never;
42
- }
43
- declare const MultiPageDialogContent: React.ForwardRefExoticComponent<MultiPageDialogContentProps & React.RefAttributes<HTMLDivElement>>;
44
- export { MultiPageDialogRoot as MultiPageDialog, MultiPageDialogClose, MultiPageDialogContent, MultiPageDialogFooter, type MultiPageDialogFooterProps, type MultiPageDialogPage, type MultiPageDialogProps, MultiPageDialogTrigger, };
45
- //# sourceMappingURL=MultiPageDialog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiPageDialog.d.ts","sourceRoot":"","sources":["../../../src/components/MultiPageDialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAa/D,QAAA,MAAM,uBAAuB,6BAA8B,CAAC;AAC5D,KAAK,uBAAuB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAqBxE,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC3B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,QAAA,MAAM,mBAAmB,wDAAS,CAAC;AACnC,QAAA,MAAM,sBAAsB,+HAAgB,CAAC;AAC7C,QAAA,MAAM,oBAAoB,6HAAc,CAAC;AAEzC,UAAU,0BACR,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;CACnD;AAED,QAAA,MAAM,qBAAqB;+EAOxB,0BAA0B;;CAmB5B,CAAC;AAIF,UAAU,oBAAoB;IAC5B,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,IAAI,CAAC,EAAE,uBAAuB,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;IAClD,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC;AAED,UAAU,2BAA4B,SAAQ,oBAAoB;IAChE,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED,QAAA,MAAM,sBAAsB,oGAoL3B,CAAC;AAIF,OAAO,EACL,mBAAmB,IAAI,eAAe,EACtC,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,sBAAsB,GACvB,CAAC"}