@dust-tt/sparkle 0.2.224 → 0.2.226

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 (71) hide show
  1. package/dist/cjs/index.js +293 -153
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/components/Breadcrumbs.d.ts +7 -6
  4. package/dist/esm/components/Breadcrumbs.d.ts.map +1 -1
  5. package/dist/esm/components/Breadcrumbs.js +3 -2
  6. package/dist/esm/components/Breadcrumbs.js.map +1 -1
  7. package/dist/esm/components/DataTable.d.ts +5 -2
  8. package/dist/esm/components/DataTable.d.ts.map +1 -1
  9. package/dist/esm/components/DataTable.js +50 -33
  10. package/dist/esm/components/DataTable.js.map +1 -1
  11. package/dist/esm/components/DropdownMenu.d.ts +10 -10
  12. package/dist/esm/components/DropdownMenu.d.ts.map +1 -1
  13. package/dist/esm/components/DropdownMenu.js +7 -7
  14. package/dist/esm/components/DropdownMenu.js.map +1 -1
  15. package/dist/esm/components/Item.d.ts +18 -15
  16. package/dist/esm/components/Item.d.ts.map +1 -1
  17. package/dist/esm/components/Item.js +2 -1
  18. package/dist/esm/components/Item.js.map +1 -1
  19. package/dist/esm/components/PaginatedCitationsGrid.d.ts.map +1 -1
  20. package/dist/esm/components/PaginatedCitationsGrid.js +8 -4
  21. package/dist/esm/components/PaginatedCitationsGrid.js.map +1 -1
  22. package/dist/esm/components/Pagination.d.ts +5 -4
  23. package/dist/esm/components/Pagination.d.ts.map +1 -1
  24. package/dist/esm/components/Pagination.js +35 -35
  25. package/dist/esm/components/Pagination.js.map +1 -1
  26. package/dist/esm/hooks/index.d.ts +3 -0
  27. package/dist/esm/hooks/index.d.ts.map +1 -0
  28. package/dist/esm/hooks/index.js +3 -0
  29. package/dist/esm/hooks/index.js.map +1 -0
  30. package/dist/esm/hooks/useHashParams.d.ts +18 -0
  31. package/dist/esm/hooks/useHashParams.d.ts.map +1 -0
  32. package/dist/esm/hooks/useHashParams.js +67 -0
  33. package/dist/esm/hooks/useHashParams.js.map +1 -0
  34. package/dist/esm/hooks/usePaginationFromUrl.d.ts +6 -0
  35. package/dist/esm/hooks/usePaginationFromUrl.d.ts.map +1 -0
  36. package/dist/esm/hooks/usePaginationFromUrl.js +23 -0
  37. package/dist/esm/hooks/usePaginationFromUrl.js.map +1 -0
  38. package/dist/esm/index.d.ts +1 -0
  39. package/dist/esm/index.d.ts.map +1 -1
  40. package/dist/esm/index.js +1 -0
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/esm/stories/DataTable.stories.d.ts +2 -0
  43. package/dist/esm/stories/DataTable.stories.d.ts.map +1 -1
  44. package/dist/esm/stories/DataTable.stories.js +133 -105
  45. package/dist/esm/stories/DataTable.stories.js.map +1 -1
  46. package/dist/esm/stories/DropdownMenu.stories.d.ts.map +1 -1
  47. package/dist/esm/stories/DropdownMenu.stories.js +32 -31
  48. package/dist/esm/stories/DropdownMenu.stories.js.map +1 -1
  49. package/dist/esm/stories/Item.stories.d.ts.map +1 -1
  50. package/dist/esm/stories/Item.stories.js +8 -6
  51. package/dist/esm/stories/Item.stories.js.map +1 -1
  52. package/dist/esm/stories/Pagination.stories.d.ts +1 -0
  53. package/dist/esm/stories/Pagination.stories.d.ts.map +1 -1
  54. package/dist/esm/stories/Pagination.stories.js +25 -3
  55. package/dist/esm/stories/Pagination.stories.js.map +1 -1
  56. package/dist/sparkle.css +4 -0
  57. package/package.json +1 -1
  58. package/src/components/Breadcrumbs.tsx +11 -10
  59. package/src/components/DataTable.tsx +116 -81
  60. package/src/components/DropdownMenu.tsx +13 -13
  61. package/src/components/Item.tsx +20 -16
  62. package/src/components/PaginatedCitationsGrid.tsx +11 -6
  63. package/src/components/Pagination.tsx +48 -45
  64. package/src/hooks/index.ts +2 -0
  65. package/src/hooks/useHashParams.ts +95 -0
  66. package/src/hooks/usePaginationFromUrl.ts +36 -0
  67. package/src/index.ts +1 -0
  68. package/src/stories/DataTable.stories.tsx +200 -129
  69. package/src/stories/DropdownMenu.stories.tsx +43 -31
  70. package/src/stories/Item.stories.tsx +26 -6
  71. package/src/stories/Pagination.stories.tsx +38 -10
@@ -82,8 +82,8 @@ export const ListItemExample = () => (
82
82
  <DropdownMenu>
83
83
  <DropdownMenu.Button label="Dust" />
84
84
  <DropdownMenu.Items>
85
- <DropdownMenu.Item label="item 1" href="#" />
86
- <DropdownMenu.Item label="item 2" href="#" />
85
+ <DropdownMenu.Item label="item 1" link={{ href: "#" }} />
86
+ <DropdownMenu.Item label="item 2" link={{ href: "#" }} />
87
87
  </DropdownMenu.Items>
88
88
  </DropdownMenu>
89
89
  </div>
@@ -91,8 +91,16 @@ export const ListItemExample = () => (
91
91
  <DropdownMenu>
92
92
  <DropdownMenu.Button label="Dust" />
93
93
  <DropdownMenu.Items>
94
- <DropdownMenu.Item label="item 1" href="#" icon={Cog6ToothIcon} />
95
- <DropdownMenu.Item label="item 2" href="#" icon={Cog6ToothIcon} />
94
+ <DropdownMenu.Item
95
+ label="item 1"
96
+ link={{ href: "#" }}
97
+ icon={Cog6ToothIcon}
98
+ />
99
+ <DropdownMenu.Item
100
+ label="item 2"
101
+ link={{ href: "#" }}
102
+ icon={Cog6ToothIcon}
103
+ />
96
104
  </DropdownMenu.Items>
97
105
  </DropdownMenu>
98
106
  </div>
@@ -102,13 +110,25 @@ export const ListItemExample = () => (
102
110
  <DropdownMenu.Items>
103
111
  <DropdownMenu.Item
104
112
  label="item 1"
105
- href="#"
113
+ link={{ href: "#" }}
114
+ icon={Cog6ToothIcon}
115
+ description="Desciption of the item"
116
+ />
117
+ <DropdownMenu.Item
118
+ label="Dust site"
119
+ link={{ href: "https://dust.tt", target: "_blank" }}
120
+ icon={Cog6ToothIcon}
121
+ description="Desciption of the item"
122
+ />
123
+ <DropdownMenu.Item
124
+ label="item 1"
125
+ link={{ href: "#" }}
106
126
  icon={Cog6ToothIcon}
107
127
  description="Desciption of the item"
108
128
  />
109
129
  <DropdownMenu.Item
110
130
  label="item 2"
111
- href="#"
131
+ link={{ href: "#" }}
112
132
  icon={Cog6ToothIcon}
113
133
  description="Desciption of the item"
114
134
  />
@@ -1,6 +1,8 @@
1
1
  import type { Meta } from "@storybook/react";
2
2
  import React from "react";
3
3
 
4
+ import { usePaginationFromUrl } from "@sparkle/hooks/usePaginationFromUrl";
5
+
4
6
  import { Pagination } from "../index_with_tw_base";
5
7
 
6
8
  const meta = {
@@ -9,38 +11,64 @@ const meta = {
9
11
  } satisfies Meta<typeof Pagination>;
10
12
 
11
13
  export default meta;
12
-
13
14
  export const PaginationSM = () => {
15
+ const [pagination, setPagination] = React.useState({
16
+ pageIndex: 0,
17
+ pageSize: 50,
18
+ });
14
19
  return (
15
20
  <Pagination
16
- itemsCount={960}
17
- maxItemsPerPage={50}
18
- onButtonClick={() => {}}
21
+ rowCount={960}
22
+ pagination={pagination}
23
+ setPagination={setPagination}
19
24
  />
20
25
  );
21
26
  };
22
27
 
23
28
  export const PaginationXS = () => {
29
+ const [pagination, setPagination] = React.useState({
30
+ pageIndex: 0,
31
+ pageSize: 50,
32
+ });
24
33
  return (
25
34
  <Pagination
26
- itemsCount={960}
27
- maxItemsPerPage={50}
35
+ rowCount={960}
28
36
  size="xs"
29
37
  showDetails={false}
30
- onButtonClick={() => {}}
38
+ pagination={pagination}
39
+ setPagination={setPagination}
31
40
  />
32
41
  );
33
42
  };
34
43
 
35
44
  export const PaginationNoPageButtons = () => {
45
+ const [pagination, setPagination] = React.useState({
46
+ pageIndex: 0,
47
+ pageSize: 50,
48
+ });
36
49
  return (
37
50
  <Pagination
38
- itemsCount={960}
39
- maxItemsPerPage={50}
51
+ rowCount={960}
40
52
  size="xs"
41
53
  showDetails={false}
42
54
  showPageButtons={false}
43
- onButtonClick={() => {}}
55
+ pagination={pagination}
56
+ setPagination={setPagination}
44
57
  />
45
58
  );
46
59
  };
60
+
61
+ export const PaginationWithUrl = () => {
62
+ const { pagination, setPagination } = usePaginationFromUrl("example", 50);
63
+
64
+ return (
65
+ <>
66
+ <div className="s-p-2">Current hash: {location.hash}</div>
67
+ <Pagination
68
+ rowCount={960}
69
+ pagination={pagination}
70
+ setPagination={setPagination}
71
+ />
72
+ </>
73
+ );
74
+ };