@phsa.tec/design-system-react 0.1.6 → 0.1.9

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 (217) hide show
  1. package/README.md +390 -209
  2. package/dist/index.d.mts +485 -0
  3. package/dist/index.d.ts +485 -0
  4. package/dist/index.js +4259 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +4186 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/styles.css +2534 -0
  9. package/dist/styles.css.map +1 -0
  10. package/dist/styles.d.mts +2 -0
  11. package/dist/styles.d.ts +2 -0
  12. package/package.json +46 -6
  13. package/.eslintrc.json +0 -7
  14. package/.github/workflows/deploy-storybook.yml +0 -75
  15. package/.storybook/main.ts +0 -16
  16. package/.storybook/preview.ts +0 -15
  17. package/components.json +0 -21
  18. package/jest.config.ts +0 -25
  19. package/next.config.ts +0 -7
  20. package/postcss.config.mjs +0 -8
  21. package/public/file.svg +0 -1
  22. package/public/globe.svg +0 -1
  23. package/public/next.svg +0 -1
  24. package/public/vercel.svg +0 -1
  25. package/public/window.svg +0 -1
  26. package/src/app/columns.tsx +0 -178
  27. package/src/app/favicon.ico +0 -0
  28. package/src/app/fonts/GeistMonoVF.woff +0 -0
  29. package/src/app/fonts/GeistVF.woff +0 -0
  30. package/src/app/globals.css +0 -94
  31. package/src/app/layout.tsx +0 -35
  32. package/src/app/page.tsx +0 -7
  33. package/src/components/actions/AlertDialog/AlertDialog.tsx +0 -45
  34. package/src/components/actions/AlertDialog/alert-dialog.stories.tsx +0 -21
  35. package/src/components/actions/AlertDialog/index.ts +0 -1
  36. package/src/components/actions/Button/Button.stories.ts +0 -38
  37. package/src/components/actions/Button/Button.tsx +0 -23
  38. package/src/components/actions/Button/index.ts +0 -1
  39. package/src/components/actions/Collapsible/index.ts +0 -1
  40. package/src/components/actions/Dialog/Dialog.stories.tsx +0 -70
  41. package/src/components/actions/Dialog/Dialog.tsx +0 -87
  42. package/src/components/actions/Dialog/components/DialogWithActions/index.tsx +0 -40
  43. package/src/components/actions/Dialog/index.ts +0 -1
  44. package/src/components/actions/Steps/Steps.stories.tsx +0 -25
  45. package/src/components/actions/Steps/Steps.tsx +0 -51
  46. package/src/components/actions/Steps/index.ts +0 -1
  47. package/src/components/actions/index.ts +0 -5
  48. package/src/components/dataDisplay/Avatar/Avatar.stories.tsx +0 -22
  49. package/src/components/dataDisplay/Avatar/Avatar.tsx +0 -21
  50. package/src/components/dataDisplay/Avatar/index.ts +0 -2
  51. package/src/components/dataDisplay/Badge/Badge.stories.tsx +0 -36
  52. package/src/components/dataDisplay/Badge/index.ts +0 -1
  53. package/src/components/dataDisplay/Card/Card.stories.tsx +0 -24
  54. package/src/components/dataDisplay/Card/Card.tsx +0 -34
  55. package/src/components/dataDisplay/Card/index.ts +0 -1
  56. package/src/components/dataDisplay/DataPairList/DataPairList.tsx +0 -56
  57. package/src/components/dataDisplay/DataPairList/data-pair-list.stories.tsx +0 -87
  58. package/src/components/dataDisplay/DataPairList/index.ts +0 -2
  59. package/src/components/dataDisplay/DataPairList/types.ts +0 -10
  60. package/src/components/dataDisplay/DropDownMenu/index.ts +0 -1
  61. package/src/components/dataDisplay/ErrorMessage/ErrorMessage.tsx +0 -6
  62. package/src/components/dataDisplay/ErrorMessage/index.ts +0 -1
  63. package/src/components/dataDisplay/Icon/Icon.stories.tsx +0 -21
  64. package/src/components/dataDisplay/Icon/Icon.tsx +0 -47
  65. package/src/components/dataDisplay/Icon/index.ts +0 -1
  66. package/src/components/dataDisplay/Icon/types.ts +0 -6
  67. package/src/components/dataDisplay/Label/Label.stories.tsx +0 -21
  68. package/src/components/dataDisplay/Label/Label.tsx +0 -10
  69. package/src/components/dataDisplay/Label/index.ts +0 -1
  70. package/src/components/dataDisplay/Table/Table.tsx +0 -173
  71. package/src/components/dataDisplay/Table/columns.tsx +0 -223
  72. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx +0 -72
  73. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-pagination.tsx +0 -91
  74. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-toolbar.tsx +0 -17
  75. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx +0 -58
  76. package/src/components/dataDisplay/Table/components/DynamicTable/data-table.stories.tsx +0 -118
  77. package/src/components/dataDisplay/Table/components/DynamicTable/index.tsx +0 -136
  78. package/src/components/dataDisplay/Table/components/DynamicTable/types.ts +0 -43
  79. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-column-header.tsx +0 -71
  80. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-faceted-filter.tsx +0 -147
  81. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-pagination.tsx +0 -97
  82. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-row-actions.tsx +0 -78
  83. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-toolbar.tsx +0 -60
  84. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-view-options.tsx +0 -59
  85. package/src/components/dataDisplay/Table/custom/CustomTable/data-table.tsx +0 -145
  86. package/src/components/dataDisplay/Table/custom/CustomTable/data.ts +0 -71
  87. package/src/components/dataDisplay/Table/custom/CustomTable/index.tsx +0 -34
  88. package/src/components/dataDisplay/Table/custom/CustomTable/schema.ts +0 -11
  89. package/src/components/dataDisplay/Table/index.ts +0 -2
  90. package/src/components/dataDisplay/Table/table.stories.tsx +0 -147
  91. package/src/components/dataDisplay/Table/types.ts +0 -15
  92. package/src/components/dataDisplay/Tabs/Tabs.stories.tsx +0 -34
  93. package/src/components/dataDisplay/Tabs/Tabs.tsx +0 -53
  94. package/src/components/dataDisplay/Tabs/index.ts +0 -1
  95. package/src/components/dataDisplay/Text/Text.stories.tsx +0 -66
  96. package/src/components/dataDisplay/Text/Text.tsx +0 -56
  97. package/src/components/dataDisplay/Text/index.ts +0 -1
  98. package/src/components/dataDisplay/index.ts +0 -8
  99. package/src/components/dataInput/Input/components/Input/Input.stories.tsx +0 -99
  100. package/src/components/dataInput/Input/components/Input/InputBase.tsx +0 -50
  101. package/src/components/dataInput/Input/components/Input/__tests__/input.test.tsx +0 -38
  102. package/src/components/dataInput/Input/components/Input/index.tsx +0 -48
  103. package/src/components/dataInput/Input/components/Input/types.ts +0 -15
  104. package/src/components/dataInput/Input/components/InputBase/index.tsx +0 -31
  105. package/src/components/dataInput/Input/components/MaskInput/__tests__/mask-input.test.tsx +0 -77
  106. package/src/components/dataInput/Input/components/MaskInput/index.ts +0 -1
  107. package/src/components/dataInput/Input/components/MaskInput/mask-input.stories.tsx +0 -85
  108. package/src/components/dataInput/Input/components/MaskInput/mask-input.tsx +0 -73
  109. package/src/components/dataInput/Input/components/MultipleInput/MultipleInput.tsx +0 -105
  110. package/src/components/dataInput/Input/components/MultipleInput/MultipleInputBase.tsx +0 -100
  111. package/src/components/dataInput/Input/components/MultipleInput/MultipleMaskInput.tsx +0 -35
  112. package/src/components/dataInput/Input/components/MultipleInput/MultipleNumberInput.tsx +0 -35
  113. package/src/components/dataInput/Input/components/MultipleInput/__tests__/multiple-input.test.tsx +0 -152
  114. package/src/components/dataInput/Input/components/MultipleInput/index.ts +0 -2
  115. package/src/components/dataInput/Input/components/MultipleInput/multiple-input.stories.tsx +0 -96
  116. package/src/components/dataInput/Input/components/NumberInput/__tests__/number-input.test.tsx +0 -175
  117. package/src/components/dataInput/Input/components/NumberInput/index.ts +0 -1
  118. package/src/components/dataInput/Input/components/NumberInput/number-input.stories.tsx +0 -76
  119. package/src/components/dataInput/Input/components/NumberInput/number-input.tsx +0 -70
  120. package/src/components/dataInput/Input/index.ts +0 -4
  121. package/src/components/dataInput/Select/MultiSelect/MultiSelect.stories.tsx +0 -119
  122. package/src/components/dataInput/Select/MultiSelect/MultiSelectBase.tsx +0 -135
  123. package/src/components/dataInput/Select/MultiSelect/index.tsx +0 -75
  124. package/src/components/dataInput/Select/Select.stories.tsx +0 -61
  125. package/src/components/dataInput/Select/Select.tsx +0 -73
  126. package/src/components/dataInput/Select/SelectBase.tsx +0 -58
  127. package/src/components/dataInput/Select/index.ts +0 -2
  128. package/src/components/dataInput/Switch/Switch.stories.tsx +0 -75
  129. package/src/components/dataInput/Switch/Switch.tsx +0 -52
  130. package/src/components/dataInput/Switch/index.ts +0 -1
  131. package/src/components/dataInput/checkbox/Checkbox.tsx +0 -57
  132. package/src/components/dataInput/checkbox/Checkbox_old.tsx +0 -58
  133. package/src/components/dataInput/checkbox/Checkout.stories.tsx +0 -62
  134. package/src/components/dataInput/checkbox/index.ts +0 -1
  135. package/src/components/dataInput/form/Form.tsx +0 -47
  136. package/src/components/dataInput/form/index.ts +0 -3
  137. package/src/components/dataInput/index.ts +0 -5
  138. package/src/components/feedback/ErrorLabel/index.tsx +0 -24
  139. package/src/components/feedback/Spinner/index.ts +0 -1
  140. package/src/components/feedback/Toast/Toast.stories.tsx +0 -45
  141. package/src/components/feedback/Toast/index.ts +0 -2
  142. package/src/components/feedback/index.ts +0 -2
  143. package/src/components/index.ts +0 -6
  144. package/src/components/layout/Crud/components/Table/index.tsx +0 -183
  145. package/src/components/layout/Crud/components/Table/types.ts +0 -15
  146. package/src/components/layout/Crud/crud.stories.tsx +0 -317
  147. package/src/components/layout/Crud/hook/useCrudLayout/index.tsx +0 -94
  148. package/src/components/layout/Crud/hook/useRequest/index.tsx +0 -156
  149. package/src/components/layout/Crud/index.tsx +0 -295
  150. package/src/components/layout/Crud/store/CrudLayoutStore.ts +0 -75
  151. package/src/components/layout/Crud/types.ts +0 -14
  152. package/src/components/layout/Drawer/CustomDrawer/index.tsx +0 -33
  153. package/src/components/layout/Drawer/Drawer.stories.tsx +0 -80
  154. package/src/components/layout/Drawer/index.ts +0 -2
  155. package/src/components/layout/PageLayout/PageLayout.stories.tsx +0 -42
  156. package/src/components/layout/PageLayout/index.tsx +0 -28
  157. package/src/components/layout/Separator/index.ts +0 -1
  158. package/src/components/layout/Sheet/Sheet.stories.tsx +0 -28
  159. package/src/components/layout/Sheet/Sheet.tsx +0 -22
  160. package/src/components/layout/Sheet/index.ts +0 -1
  161. package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -116
  162. package/src/components/layout/Sidebar/Sidebar.tsx +0 -50
  163. package/src/components/layout/Sidebar/components/app-sidebar.tsx +0 -203
  164. package/src/components/layout/Sidebar/components/footer-sidebar.tsx +0 -17
  165. package/src/components/layout/Sidebar/components/header-sidebar.tsx +0 -90
  166. package/src/components/layout/Sidebar/components/menus.tsx +0 -55
  167. package/src/components/layout/Sidebar/components/nav-projects.tsx +0 -88
  168. package/src/components/layout/Sidebar/components/nav-user.tsx +0 -114
  169. package/src/components/layout/Sidebar/components/team-switcher.tsx +0 -85
  170. package/src/components/layout/Sidebar/index.ts +0 -2
  171. package/src/components/layout/Sidebar/provider/index.tsx +0 -51
  172. package/src/components/layout/Tabs/Tabs.tsx +0 -51
  173. package/src/components/layout/Tabs/index.ts +0 -1
  174. package/src/components/layout/Tabs/tabs.stories.tsx +0 -57
  175. package/src/components/layout/index.ts +0 -6
  176. package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +0 -66
  177. package/src/components/navigation/Breadcrumbs/index.ts +0 -2
  178. package/src/components/navigation/index.ts +0 -1
  179. package/src/components/ui/alert-dialog.tsx +0 -141
  180. package/src/components/ui/alert.tsx +0 -59
  181. package/src/components/ui/avatar.tsx +0 -50
  182. package/src/components/ui/badge.tsx +0 -40
  183. package/src/components/ui/breadcrumb.tsx +0 -115
  184. package/src/components/ui/button.tsx +0 -57
  185. package/src/components/ui/card.tsx +0 -83
  186. package/src/components/ui/checkbox.tsx +0 -34
  187. package/src/components/ui/collapsible.tsx +0 -11
  188. package/src/components/ui/command.tsx +0 -153
  189. package/src/components/ui/dialog.tsx +0 -124
  190. package/src/components/ui/drawer.tsx +0 -117
  191. package/src/components/ui/dropdown-menu.tsx +0 -201
  192. package/src/components/ui/form.tsx +0 -179
  193. package/src/components/ui/input.tsx +0 -24
  194. package/src/components/ui/label.tsx +0 -30
  195. package/src/components/ui/popover.tsx +0 -33
  196. package/src/components/ui/select.tsx +0 -161
  197. package/src/components/ui/separator.tsx +0 -31
  198. package/src/components/ui/sheet.tsx +0 -140
  199. package/src/components/ui/sidebar.tsx +0 -763
  200. package/src/components/ui/skeleton.tsx +0 -15
  201. package/src/components/ui/sonner.tsx +0 -31
  202. package/src/components/ui/spinner.tsx +0 -54
  203. package/src/components/ui/switch.tsx +0 -33
  204. package/src/components/ui/table.tsx +0 -120
  205. package/src/components/ui/tabs.tsx +0 -55
  206. package/src/components/ui/toast.tsx +0 -130
  207. package/src/components/ui/toaster.tsx +0 -35
  208. package/src/components/ui/tooltip.tsx +0 -32
  209. package/src/hooks/use-conditional-controller.tsx +0 -35
  210. package/src/hooks/use-mask.tsx +0 -116
  211. package/src/hooks/use-mobile.tsx +0 -19
  212. package/src/hooks/use-toast.ts +0 -191
  213. package/src/index.ts +0 -1
  214. package/src/introduction.mdx +0 -132
  215. package/src/lib/utils.ts +0 -6
  216. package/tailwind.config.ts +0 -83
  217. package/tsconfig.json +0 -27
@@ -1,136 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import {
5
- flexRender,
6
- getCoreRowModel,
7
- getSortedRowModel,
8
- getPaginationRowModel,
9
- useReactTable,
10
- SortingState,
11
- VisibilityState,
12
- PaginationState,
13
- } from "@tanstack/react-table";
14
- import {
15
- Table,
16
- TableBody,
17
- TableCell,
18
- TableHead,
19
- TableHeader,
20
- TableRow,
21
- } from "../../../../../components/ui/table";
22
- import { DataTableToolbar } from "./data-table-toolbar";
23
- import { DataTablePagination } from "./data-table-pagination";
24
- import { cn } from "../../../../../lib/utils";
25
- import { DataTableColumnHeader } from "./data-table-column-header";
26
- import { DynamicTableProps } from "./types";
27
-
28
- export function DynamicTable<TData>({
29
- data,
30
- columns,
31
- className,
32
- toolbar,
33
- pagination: showPagination = true,
34
- sorting: showSorting = true,
35
- columnVisibility: showColumnVisibility = true,
36
- filters,
37
- rowsPerPage = [10, 20, 30, 40, 50],
38
- defaultSort = [],
39
- defaultVisibility = {},
40
- }: DynamicTableProps<TData>) {
41
- const [sorting, setSorting] = React.useState<SortingState>(defaultSort);
42
- const [columnVisibility, setColumnVisibility] =
43
- React.useState<VisibilityState>(defaultVisibility);
44
- const [{ pageIndex, pageSize }, setPagination] =
45
- React.useState<PaginationState>({
46
- pageIndex: 0,
47
- pageSize: rowsPerPage[0],
48
- });
49
-
50
- const pagination = React.useMemo(
51
- () => ({
52
- pageIndex,
53
- pageSize,
54
- }),
55
- [pageIndex, pageSize]
56
- );
57
-
58
- const table = useReactTable({
59
- data,
60
- columns,
61
- getCoreRowModel: getCoreRowModel(),
62
- onSortingChange: setSorting,
63
- getSortedRowModel: showSorting ? getSortedRowModel() : undefined,
64
- getPaginationRowModel: getPaginationRowModel(),
65
- onColumnVisibilityChange: setColumnVisibility,
66
- onPaginationChange: setPagination,
67
- manualPagination: false,
68
- pageCount: Math.ceil(data.length / pageSize),
69
- state: {
70
- sorting,
71
- columnVisibility,
72
- pagination,
73
- },
74
- enableSorting: showSorting,
75
- });
76
-
77
- return (
78
- <div className="space-y-4">
79
- {(toolbar || filters || showColumnVisibility) && (
80
- <DataTableToolbar
81
- table={table}
82
- filters={filters}
83
- showColumnVisibility={showColumnVisibility}
84
- />
85
- )}
86
- <div className={cn("rounded-md border", className)}>
87
- <Table>
88
- <TableHeader>
89
- {table.getHeaderGroups().map((headerGroup) => (
90
- <TableRow key={headerGroup.id}>
91
- {headerGroup.headers.map((header) => (
92
- <TableHead key={header.id}>
93
- {header.isPlaceholder ? null : (
94
- <DataTableColumnHeader
95
- column={header.column}
96
- title={header.column.columnDef.header as string}
97
- />
98
- )}
99
- </TableHead>
100
- ))}
101
- </TableRow>
102
- ))}
103
- </TableHeader>
104
- <TableBody>
105
- {table.getRowModel().rows?.length ? (
106
- table.getRowModel().rows.map((row) => (
107
- <TableRow key={row.id}>
108
- {row.getVisibleCells().map((cell) => (
109
- <TableCell key={cell.id}>
110
- {flexRender(
111
- cell.column.columnDef.cell,
112
- cell.getContext()
113
- )}
114
- </TableCell>
115
- ))}
116
- </TableRow>
117
- ))
118
- ) : (
119
- <TableRow>
120
- <TableCell
121
- colSpan={columns.length}
122
- className="h-24 text-center"
123
- >
124
- Nenhum resultado encontrado.
125
- </TableCell>
126
- </TableRow>
127
- )}
128
- </TableBody>
129
- </Table>
130
- </div>
131
- {showPagination && (
132
- <DataTablePagination table={table} pageSizeOptions={rowsPerPage} />
133
- )}
134
- </div>
135
- );
136
- }
@@ -1,43 +0,0 @@
1
- import {
2
- ColumnDef,
3
- SortingState,
4
- Table,
5
- VisibilityState,
6
- } from "@tanstack/react-table";
7
-
8
- export interface DynamicTableProps<TData> {
9
- data: TData[];
10
- columns: ColumnDef<TData>[];
11
- className?: string;
12
- toolbar?: React.ReactNode;
13
- pagination?: boolean;
14
- sorting?: boolean;
15
- columnVisibility?: boolean;
16
- filters?: React.ReactNode;
17
- rowsPerPage?: number[];
18
- defaultSort?: SortingState;
19
- defaultVisibility?: VisibilityState;
20
- }
21
-
22
- export interface DataTableToolbarProps<TData> {
23
- table: Table<TData>;
24
- filters?: React.ReactNode;
25
- showColumnVisibility?: boolean;
26
- }
27
-
28
- export interface DynamicTablePaginationProps<TData> {
29
- table: Table<TData>;
30
- pageSizeOptions?: number[];
31
- }
32
-
33
- export interface DynamicTableToolbarProps<TData> {
34
- table: Table<TData>;
35
- filters?: React.ReactNode;
36
- showColumnVisibility?: boolean;
37
- }
38
-
39
- export interface DynamicTablePaginationProps<TData> {
40
- table: Table<TData>;
41
- filters?: React.ReactNode;
42
- showColumnVisibility?: boolean;
43
- }
@@ -1,71 +0,0 @@
1
- import {
2
- ArrowDownIcon,
3
- ArrowUpIcon,
4
- CaretSortIcon,
5
- EyeNoneIcon,
6
- } from "@radix-ui/react-icons";
7
- import { Column } from "@tanstack/react-table";
8
-
9
- import {
10
- DropdownMenu,
11
- DropdownMenuContent,
12
- DropdownMenuItem,
13
- DropdownMenuSeparator,
14
- DropdownMenuTrigger,
15
- } from "../../../../../components/ui/dropdown-menu";
16
- import { Button } from "../../../../../components/ui/button";
17
- import { cn } from "../../../../../lib/utils";
18
-
19
- interface DataTableColumnHeaderProps<TData, TValue>
20
- extends React.HTMLAttributes<HTMLDivElement> {
21
- column: Column<TData, TValue>;
22
- title: string;
23
- }
24
-
25
- export function DataTableColumnHeader<TData, TValue>({
26
- column,
27
- title,
28
- className,
29
- }: DataTableColumnHeaderProps<TData, TValue>) {
30
- if (!column.getCanSort()) {
31
- return <div className={cn(className)}>{title}</div>;
32
- }
33
-
34
- return (
35
- <div className={cn("flex items-center space-x-2", className)}>
36
- <DropdownMenu>
37
- <DropdownMenuTrigger asChild>
38
- <Button
39
- variant="ghost"
40
- size="sm"
41
- className="-ml-3 h-8 data-[state=open]:bg-accent"
42
- >
43
- <span>{title}</span>
44
- {column.getIsSorted() === "desc" ? (
45
- <ArrowDownIcon className="ml-2 h-4 w-4" />
46
- ) : column.getIsSorted() === "asc" ? (
47
- <ArrowUpIcon className="ml-2 h-4 w-4" />
48
- ) : (
49
- <CaretSortIcon className="ml-2 h-4 w-4" />
50
- )}
51
- </Button>
52
- </DropdownMenuTrigger>
53
- <DropdownMenuContent align="start">
54
- <DropdownMenuItem onClick={() => column.toggleSorting(false)}>
55
- <ArrowUpIcon className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
56
- Asc
57
- </DropdownMenuItem>
58
- <DropdownMenuItem onClick={() => column.toggleSorting(true)}>
59
- <ArrowDownIcon className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
60
- Desc
61
- </DropdownMenuItem>
62
- <DropdownMenuSeparator />
63
- <DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
64
- <EyeNoneIcon className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
65
- Hide
66
- </DropdownMenuItem>
67
- </DropdownMenuContent>
68
- </DropdownMenu>
69
- </div>
70
- );
71
- }
@@ -1,147 +0,0 @@
1
- import * as React from "react";
2
- import { CheckIcon, PlusCircledIcon } from "@radix-ui/react-icons";
3
- import { Column } from "@tanstack/react-table";
4
-
5
- import {
6
- Command,
7
- CommandEmpty,
8
- CommandGroup,
9
- CommandInput,
10
- CommandItem,
11
- CommandList,
12
- CommandSeparator,
13
- } from "../../../../ui/command";
14
- import {
15
- Popover,
16
- PopoverContent,
17
- PopoverTrigger,
18
- } from "../../../../ui/popover";
19
- import { Separator } from "../../../../ui/separator";
20
- import { Button } from "../../../../ui/button";
21
- import { Badge } from "../../../../ui/badge";
22
- import { cn } from "../../../../../lib/utils";
23
-
24
- interface DataTableFacetedFilterProps<TData, TValue> {
25
- column?: Column<TData, TValue>;
26
- title?: string;
27
- options: {
28
- label: string;
29
- value: string;
30
- icon?: React.ComponentType<{ className?: string }>;
31
- }[];
32
- }
33
-
34
- export function DataTableFacetedFilter<TData, TValue>({
35
- column,
36
- title,
37
- options,
38
- }: DataTableFacetedFilterProps<TData, TValue>) {
39
- const facets = column?.getFacetedUniqueValues();
40
- const selectedValues = new Set(column?.getFilterValue() as string[]);
41
-
42
- return (
43
- <Popover>
44
- <PopoverTrigger asChild>
45
- <Button variant="outline" size="sm" className="h-8 border-dashed">
46
- <PlusCircledIcon className="mr-2 h-4 w-4" />
47
- {title}
48
- {selectedValues?.size > 0 && (
49
- <>
50
- <Separator orientation="vertical" className="mx-2 h-4" />
51
- <Badge
52
- variant="secondary"
53
- className="rounded-sm px-1 font-normal lg:hidden"
54
- >
55
- {selectedValues.size}
56
- </Badge>
57
- <div className="hidden space-x-1 lg:flex">
58
- {selectedValues.size > 2 ? (
59
- <Badge
60
- variant="secondary"
61
- className="rounded-sm px-1 font-normal"
62
- >
63
- {selectedValues.size} selected
64
- </Badge>
65
- ) : (
66
- options
67
- .filter((option) => selectedValues.has(option.value))
68
- .map((option) => (
69
- <Badge
70
- variant="secondary"
71
- key={option.value}
72
- className="rounded-sm px-1 font-normal"
73
- >
74
- {option.label}
75
- </Badge>
76
- ))
77
- )}
78
- </div>
79
- </>
80
- )}
81
- </Button>
82
- </PopoverTrigger>
83
- <PopoverContent className="w-[200px] p-0" align="start">
84
- <Command>
85
- <CommandInput placeholder={title} />
86
- <CommandList>
87
- <CommandEmpty>No results found.</CommandEmpty>
88
- <CommandGroup>
89
- {options.map((option) => {
90
- const isSelected = selectedValues.has(option.value);
91
- return (
92
- <CommandItem
93
- key={option.value}
94
- onSelect={() => {
95
- if (isSelected) {
96
- selectedValues.delete(option.value);
97
- } else {
98
- selectedValues.add(option.value);
99
- }
100
- const filterValues = Array.from(selectedValues);
101
- column?.setFilterValue(
102
- filterValues.length ? filterValues : undefined
103
- );
104
- }}
105
- >
106
- <div
107
- className={cn(
108
- "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
109
- isSelected
110
- ? "bg-primary text-primary-foreground"
111
- : "opacity-50 [&_svg]:invisible"
112
- )}
113
- >
114
- <CheckIcon className={cn("h-4 w-4")} />
115
- </div>
116
- {option.icon && (
117
- <option.icon className="mr-2 h-4 w-4 text-muted-foreground" />
118
- )}
119
- <span>{option.label}</span>
120
- {facets?.get(option.value) && (
121
- <span className="ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs">
122
- {facets.get(option.value)}
123
- </span>
124
- )}
125
- </CommandItem>
126
- );
127
- })}
128
- </CommandGroup>
129
- {selectedValues.size > 0 && (
130
- <>
131
- <CommandSeparator />
132
- <CommandGroup>
133
- <CommandItem
134
- onSelect={() => column?.setFilterValue(undefined)}
135
- className="justify-center text-center"
136
- >
137
- Clear filters
138
- </CommandItem>
139
- </CommandGroup>
140
- </>
141
- )}
142
- </CommandList>
143
- </Command>
144
- </PopoverContent>
145
- </Popover>
146
- );
147
- }
@@ -1,97 +0,0 @@
1
- import { Table } from "@tanstack/react-table";
2
- import {
3
- ChevronLeft,
4
- ChevronRight,
5
- ChevronsLeft,
6
- ChevronsRight,
7
- } from "lucide-react";
8
-
9
- import { Button } from "../../../../ui/button";
10
- import {
11
- Select,
12
- SelectContent,
13
- SelectItem,
14
- SelectTrigger,
15
- SelectValue,
16
- } from "../../../../ui/select";
17
-
18
- interface DataTablePaginationProps<TData> {
19
- table: Table<TData>;
20
- }
21
-
22
- export function DataTablePagination<TData>({
23
- table,
24
- }: DataTablePaginationProps<TData>) {
25
- return (
26
- <div className="flex items-center justify-between px-2">
27
- <div className="flex-1 text-sm text-muted-foreground">
28
- {/* {table.getFilteredSelectedRowModel().rows.length} of{" "}
29
- {table.getFilteredRowModel().rows.length} row(s) selected. */}
30
- </div>
31
- <div className="flex items-center space-x-6 lg:space-x-8">
32
- <div className="flex items-center space-x-2">
33
- <p className="text-sm font-medium">Linhas por página</p>
34
- <Select
35
- value={`${table.getState().pagination.pageSize}`}
36
- onValueChange={(value) => {
37
- table.setPageSize(Number(value));
38
- }}
39
- >
40
- <SelectTrigger className="h-8 w-[70px]">
41
- <SelectValue placeholder={table.getState().pagination.pageSize} />
42
- </SelectTrigger>
43
- <SelectContent side="top">
44
- {[10, 20, 30, 40, 50].map((pageSize) => (
45
- <SelectItem key={pageSize} value={`${pageSize}`}>
46
- {pageSize}
47
- </SelectItem>
48
- ))}
49
- </SelectContent>
50
- </Select>
51
- </div>
52
- <div className="flex w-[100px] items-center justify-center text-sm font-medium">
53
- Página {table.getState().pagination.pageIndex + 1} de{" "}
54
- {table.getPageCount()}
55
- </div>
56
- <div className="flex items-center space-x-2">
57
- <Button
58
- variant="outline"
59
- className="hidden h-8 w-8 p-0 lg:flex"
60
- onClick={() => table.setPageIndex(0)}
61
- disabled={!table.getCanPreviousPage()}
62
- >
63
- <span className="sr-only">Go to first page</span>
64
- <ChevronsLeft />
65
- </Button>
66
- <Button
67
- variant="outline"
68
- className="h-8 w-8 p-0"
69
- onClick={() => table.previousPage()}
70
- disabled={!table.getCanPreviousPage()}
71
- >
72
- <span className="sr-only">Go to previous page</span>
73
- <ChevronLeft />
74
- </Button>
75
- <Button
76
- variant="outline"
77
- className="h-8 w-8 p-0"
78
- onClick={() => table.nextPage()}
79
- disabled={!table.getCanNextPage()}
80
- >
81
- <span className="sr-only">Go to next page</span>
82
- <ChevronRight />
83
- </Button>
84
- <Button
85
- variant="outline"
86
- className="hidden h-8 w-8 p-0 lg:flex"
87
- onClick={() => table.setPageIndex(table.getPageCount() - 1)}
88
- disabled={!table.getCanNextPage()}
89
- >
90
- <span className="sr-only">Go to last page</span>
91
- <ChevronsRight />
92
- </Button>
93
- </div>
94
- </div>
95
- </div>
96
- );
97
- }
@@ -1,78 +0,0 @@
1
- "use client";
2
-
3
- import { DotsHorizontalIcon } from "@radix-ui/react-icons";
4
- import { Row } from "@tanstack/react-table";
5
-
6
- import {
7
- DropdownMenu,
8
- DropdownMenuContent,
9
- DropdownMenuItem,
10
- DropdownMenuRadioGroup,
11
- DropdownMenuRadioItem,
12
- DropdownMenuSeparator,
13
- DropdownMenuShortcut,
14
- DropdownMenuSub,
15
- DropdownMenuSubContent,
16
- DropdownMenuSubTrigger,
17
- DropdownMenuTrigger,
18
- } from "../../../../../components/ui/dropdown-menu";
19
- import { Button } from "../../../../../components/ui/button";
20
- import { taskSchema } from "./schema";
21
- import { labels } from "./data";
22
-
23
- interface DataTableRowActionsProps<TData> {
24
- row: Row<TData>;
25
- options: {
26
- action: (row: Row<TData>) => void;
27
- label: string;
28
- }[];
29
- }
30
-
31
- export function DataTableRowActions<TData>({
32
- row,
33
- options,
34
- }: DataTableRowActionsProps<TData>) {
35
- // const task = taskSchema.parse(row.original);
36
-
37
- return (
38
- <DropdownMenu>
39
- <DropdownMenuTrigger asChild>
40
- <Button
41
- variant="ghost"
42
- className="flex h-8 w-8 p-0 data-[state=open]:bg-muted"
43
- >
44
- <DotsHorizontalIcon className="h-4 w-4" />
45
- <span className="sr-only">Open menu</span>
46
- </Button>
47
- </DropdownMenuTrigger>
48
- <DropdownMenuContent align="end" className="w-[160px]">
49
- {options.map(({ action, label }, index) => (
50
- <DropdownMenuItem key={index} onClick={() => action(row)}>
51
- {label}
52
- </DropdownMenuItem>
53
- ))}
54
- {/* <DropdownMenuItem>Edit</DropdownMenuItem>
55
- <DropdownMenuItem>Make a copy</DropdownMenuItem>
56
- <DropdownMenuItem>Favorite</DropdownMenuItem>
57
- <DropdownMenuSeparator />
58
- <DropdownMenuSub>
59
- <DropdownMenuSubTrigger>Labels</DropdownMenuSubTrigger>
60
- <DropdownMenuSubContent>
61
- <DropdownMenuRadioGroup value={task.label}>
62
- {labels.map((label) => (
63
- <DropdownMenuRadioItem key={label.value} value={label.value}>
64
- {label.label}
65
- </DropdownMenuRadioItem>
66
- ))}
67
- </DropdownMenuRadioGroup>
68
- </DropdownMenuSubContent>
69
- </DropdownMenuSub>
70
- <DropdownMenuSeparator />
71
- <DropdownMenuItem>
72
- Delete
73
- <DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
74
- </DropdownMenuItem> */}
75
- </DropdownMenuContent>
76
- </DropdownMenu>
77
- );
78
- }
@@ -1,60 +0,0 @@
1
- "use client";
2
-
3
- import { Cross2Icon } from "@radix-ui/react-icons";
4
- import { Table } from "@tanstack/react-table";
5
-
6
- import { priorities, statuses } from "./data";
7
- import { DataTableFacetedFilter } from "./data-table-faceted-filter";
8
- import { Input } from "../../../../../components/ui/input";
9
- import { Button } from "../../../../../components/ui/button";
10
- import { DataTableViewOptions } from "./data-table-view-options";
11
-
12
- interface DataTableToolbarProps<TData> {
13
- table: Table<TData>;
14
- }
15
-
16
- export function DataTableToolbar<TData>({
17
- table,
18
- }: DataTableToolbarProps<TData>) {
19
- const isFiltered = table.getState().columnFilters.length > 0;
20
-
21
- return (
22
- <div className="flex items-center justify-between">
23
- <div className="flex flex-1 items-center space-x-2">
24
- <Input
25
- placeholder="Filter tasks..."
26
- value={(table.getColumn("title")?.getFilterValue() as string) ?? ""}
27
- onChange={(event) =>
28
- table.getColumn("title")?.setFilterValue(event.target.value)
29
- }
30
- className="h-8 w-[150px] lg:w-[250px]"
31
- />
32
- {table.getColumn("status") && (
33
- <DataTableFacetedFilter
34
- column={table.getColumn("status")}
35
- title="Status"
36
- options={statuses}
37
- />
38
- )}
39
- {table.getColumn("priority") && (
40
- <DataTableFacetedFilter
41
- column={table.getColumn("priority")}
42
- title="Priority"
43
- options={priorities}
44
- />
45
- )}
46
- {isFiltered && (
47
- <Button
48
- variant="ghost"
49
- onClick={() => table.resetColumnFilters()}
50
- className="h-8 px-2 lg:px-3"
51
- >
52
- Reset
53
- <Cross2Icon className="ml-2 h-4 w-4" />
54
- </Button>
55
- )}
56
- </div>
57
- <DataTableViewOptions table={table} />
58
- </div>
59
- );
60
- }
@@ -1,59 +0,0 @@
1
- "use client";
2
-
3
- import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu";
4
- import { MixerHorizontalIcon } from "@radix-ui/react-icons";
5
- import { Table } from "@tanstack/react-table";
6
-
7
- import {
8
- DropdownMenu,
9
- DropdownMenuCheckboxItem,
10
- DropdownMenuContent,
11
- DropdownMenuLabel,
12
- DropdownMenuSeparator,
13
- } from "../../../../../components/ui/dropdown-menu";
14
- import { Button } from "../../../../../components/ui/button";
15
-
16
- interface DataTableViewOptionsProps<TData> {
17
- table: Table<TData>;
18
- }
19
-
20
- export function DataTableViewOptions<TData>({
21
- table,
22
- }: DataTableViewOptionsProps<TData>) {
23
- return (
24
- <DropdownMenu>
25
- <DropdownMenuTrigger asChild>
26
- <Button
27
- variant="outline"
28
- size="sm"
29
- className="ml-auto hidden h-8 lg:flex"
30
- >
31
- <MixerHorizontalIcon className="mr-2 h-4 w-4" />
32
- View
33
- </Button>
34
- </DropdownMenuTrigger>
35
- <DropdownMenuContent align="end" className="w-[150px]">
36
- <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>
37
- <DropdownMenuSeparator />
38
- {table
39
- .getAllColumns()
40
- .filter(
41
- (column) =>
42
- typeof column.accessorFn !== "undefined" && column.getCanHide()
43
- )
44
- .map((column) => {
45
- return (
46
- <DropdownMenuCheckboxItem
47
- key={column.id}
48
- className="capitalize"
49
- checked={column.getIsVisible()}
50
- onCheckedChange={(value) => column.toggleVisibility(!!value)}
51
- >
52
- {column.id}
53
- </DropdownMenuCheckboxItem>
54
- );
55
- })}
56
- </DropdownMenuContent>
57
- </DropdownMenu>
58
- );
59
- }