@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.
- package/README.md +390 -209
- package/dist/index.d.mts +485 -0
- package/dist/index.d.ts +485 -0
- package/dist/index.js +4259 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4186 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2534 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.mts +2 -0
- package/dist/styles.d.ts +2 -0
- package/package.json +46 -6
- package/.eslintrc.json +0 -7
- package/.github/workflows/deploy-storybook.yml +0 -75
- package/.storybook/main.ts +0 -16
- package/.storybook/preview.ts +0 -15
- package/components.json +0 -21
- package/jest.config.ts +0 -25
- package/next.config.ts +0 -7
- package/postcss.config.mjs +0 -8
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/src/app/columns.tsx +0 -178
- package/src/app/favicon.ico +0 -0
- package/src/app/fonts/GeistMonoVF.woff +0 -0
- package/src/app/fonts/GeistVF.woff +0 -0
- package/src/app/globals.css +0 -94
- package/src/app/layout.tsx +0 -35
- package/src/app/page.tsx +0 -7
- package/src/components/actions/AlertDialog/AlertDialog.tsx +0 -45
- package/src/components/actions/AlertDialog/alert-dialog.stories.tsx +0 -21
- package/src/components/actions/AlertDialog/index.ts +0 -1
- package/src/components/actions/Button/Button.stories.ts +0 -38
- package/src/components/actions/Button/Button.tsx +0 -23
- package/src/components/actions/Button/index.ts +0 -1
- package/src/components/actions/Collapsible/index.ts +0 -1
- package/src/components/actions/Dialog/Dialog.stories.tsx +0 -70
- package/src/components/actions/Dialog/Dialog.tsx +0 -87
- package/src/components/actions/Dialog/components/DialogWithActions/index.tsx +0 -40
- package/src/components/actions/Dialog/index.ts +0 -1
- package/src/components/actions/Steps/Steps.stories.tsx +0 -25
- package/src/components/actions/Steps/Steps.tsx +0 -51
- package/src/components/actions/Steps/index.ts +0 -1
- package/src/components/actions/index.ts +0 -5
- package/src/components/dataDisplay/Avatar/Avatar.stories.tsx +0 -22
- package/src/components/dataDisplay/Avatar/Avatar.tsx +0 -21
- package/src/components/dataDisplay/Avatar/index.ts +0 -2
- package/src/components/dataDisplay/Badge/Badge.stories.tsx +0 -36
- package/src/components/dataDisplay/Badge/index.ts +0 -1
- package/src/components/dataDisplay/Card/Card.stories.tsx +0 -24
- package/src/components/dataDisplay/Card/Card.tsx +0 -34
- package/src/components/dataDisplay/Card/index.ts +0 -1
- package/src/components/dataDisplay/DataPairList/DataPairList.tsx +0 -56
- package/src/components/dataDisplay/DataPairList/data-pair-list.stories.tsx +0 -87
- package/src/components/dataDisplay/DataPairList/index.ts +0 -2
- package/src/components/dataDisplay/DataPairList/types.ts +0 -10
- package/src/components/dataDisplay/DropDownMenu/index.ts +0 -1
- package/src/components/dataDisplay/ErrorMessage/ErrorMessage.tsx +0 -6
- package/src/components/dataDisplay/ErrorMessage/index.ts +0 -1
- package/src/components/dataDisplay/Icon/Icon.stories.tsx +0 -21
- package/src/components/dataDisplay/Icon/Icon.tsx +0 -47
- package/src/components/dataDisplay/Icon/index.ts +0 -1
- package/src/components/dataDisplay/Icon/types.ts +0 -6
- package/src/components/dataDisplay/Label/Label.stories.tsx +0 -21
- package/src/components/dataDisplay/Label/Label.tsx +0 -10
- package/src/components/dataDisplay/Label/index.ts +0 -1
- package/src/components/dataDisplay/Table/Table.tsx +0 -173
- package/src/components/dataDisplay/Table/columns.tsx +0 -223
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx +0 -72
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-pagination.tsx +0 -91
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-toolbar.tsx +0 -17
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx +0 -58
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table.stories.tsx +0 -118
- package/src/components/dataDisplay/Table/components/DynamicTable/index.tsx +0 -136
- package/src/components/dataDisplay/Table/components/DynamicTable/types.ts +0 -43
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-column-header.tsx +0 -71
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-faceted-filter.tsx +0 -147
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-pagination.tsx +0 -97
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-row-actions.tsx +0 -78
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-toolbar.tsx +0 -60
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-view-options.tsx +0 -59
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table.tsx +0 -145
- package/src/components/dataDisplay/Table/custom/CustomTable/data.ts +0 -71
- package/src/components/dataDisplay/Table/custom/CustomTable/index.tsx +0 -34
- package/src/components/dataDisplay/Table/custom/CustomTable/schema.ts +0 -11
- package/src/components/dataDisplay/Table/index.ts +0 -2
- package/src/components/dataDisplay/Table/table.stories.tsx +0 -147
- package/src/components/dataDisplay/Table/types.ts +0 -15
- package/src/components/dataDisplay/Tabs/Tabs.stories.tsx +0 -34
- package/src/components/dataDisplay/Tabs/Tabs.tsx +0 -53
- package/src/components/dataDisplay/Tabs/index.ts +0 -1
- package/src/components/dataDisplay/Text/Text.stories.tsx +0 -66
- package/src/components/dataDisplay/Text/Text.tsx +0 -56
- package/src/components/dataDisplay/Text/index.ts +0 -1
- package/src/components/dataDisplay/index.ts +0 -8
- package/src/components/dataInput/Input/components/Input/Input.stories.tsx +0 -99
- package/src/components/dataInput/Input/components/Input/InputBase.tsx +0 -50
- package/src/components/dataInput/Input/components/Input/__tests__/input.test.tsx +0 -38
- package/src/components/dataInput/Input/components/Input/index.tsx +0 -48
- package/src/components/dataInput/Input/components/Input/types.ts +0 -15
- package/src/components/dataInput/Input/components/InputBase/index.tsx +0 -31
- package/src/components/dataInput/Input/components/MaskInput/__tests__/mask-input.test.tsx +0 -77
- package/src/components/dataInput/Input/components/MaskInput/index.ts +0 -1
- package/src/components/dataInput/Input/components/MaskInput/mask-input.stories.tsx +0 -85
- package/src/components/dataInput/Input/components/MaskInput/mask-input.tsx +0 -73
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInput.tsx +0 -105
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInputBase.tsx +0 -100
- package/src/components/dataInput/Input/components/MultipleInput/MultipleMaskInput.tsx +0 -35
- package/src/components/dataInput/Input/components/MultipleInput/MultipleNumberInput.tsx +0 -35
- package/src/components/dataInput/Input/components/MultipleInput/__tests__/multiple-input.test.tsx +0 -152
- package/src/components/dataInput/Input/components/MultipleInput/index.ts +0 -2
- package/src/components/dataInput/Input/components/MultipleInput/multiple-input.stories.tsx +0 -96
- package/src/components/dataInput/Input/components/NumberInput/__tests__/number-input.test.tsx +0 -175
- package/src/components/dataInput/Input/components/NumberInput/index.ts +0 -1
- package/src/components/dataInput/Input/components/NumberInput/number-input.stories.tsx +0 -76
- package/src/components/dataInput/Input/components/NumberInput/number-input.tsx +0 -70
- package/src/components/dataInput/Input/index.ts +0 -4
- package/src/components/dataInput/Select/MultiSelect/MultiSelect.stories.tsx +0 -119
- package/src/components/dataInput/Select/MultiSelect/MultiSelectBase.tsx +0 -135
- package/src/components/dataInput/Select/MultiSelect/index.tsx +0 -75
- package/src/components/dataInput/Select/Select.stories.tsx +0 -61
- package/src/components/dataInput/Select/Select.tsx +0 -73
- package/src/components/dataInput/Select/SelectBase.tsx +0 -58
- package/src/components/dataInput/Select/index.ts +0 -2
- package/src/components/dataInput/Switch/Switch.stories.tsx +0 -75
- package/src/components/dataInput/Switch/Switch.tsx +0 -52
- package/src/components/dataInput/Switch/index.ts +0 -1
- package/src/components/dataInput/checkbox/Checkbox.tsx +0 -57
- package/src/components/dataInput/checkbox/Checkbox_old.tsx +0 -58
- package/src/components/dataInput/checkbox/Checkout.stories.tsx +0 -62
- package/src/components/dataInput/checkbox/index.ts +0 -1
- package/src/components/dataInput/form/Form.tsx +0 -47
- package/src/components/dataInput/form/index.ts +0 -3
- package/src/components/dataInput/index.ts +0 -5
- package/src/components/feedback/ErrorLabel/index.tsx +0 -24
- package/src/components/feedback/Spinner/index.ts +0 -1
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -45
- package/src/components/feedback/Toast/index.ts +0 -2
- package/src/components/feedback/index.ts +0 -2
- package/src/components/index.ts +0 -6
- package/src/components/layout/Crud/components/Table/index.tsx +0 -183
- package/src/components/layout/Crud/components/Table/types.ts +0 -15
- package/src/components/layout/Crud/crud.stories.tsx +0 -317
- package/src/components/layout/Crud/hook/useCrudLayout/index.tsx +0 -94
- package/src/components/layout/Crud/hook/useRequest/index.tsx +0 -156
- package/src/components/layout/Crud/index.tsx +0 -295
- package/src/components/layout/Crud/store/CrudLayoutStore.ts +0 -75
- package/src/components/layout/Crud/types.ts +0 -14
- package/src/components/layout/Drawer/CustomDrawer/index.tsx +0 -33
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -80
- package/src/components/layout/Drawer/index.ts +0 -2
- package/src/components/layout/PageLayout/PageLayout.stories.tsx +0 -42
- package/src/components/layout/PageLayout/index.tsx +0 -28
- package/src/components/layout/Separator/index.ts +0 -1
- package/src/components/layout/Sheet/Sheet.stories.tsx +0 -28
- package/src/components/layout/Sheet/Sheet.tsx +0 -22
- package/src/components/layout/Sheet/index.ts +0 -1
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -116
- package/src/components/layout/Sidebar/Sidebar.tsx +0 -50
- package/src/components/layout/Sidebar/components/app-sidebar.tsx +0 -203
- package/src/components/layout/Sidebar/components/footer-sidebar.tsx +0 -17
- package/src/components/layout/Sidebar/components/header-sidebar.tsx +0 -90
- package/src/components/layout/Sidebar/components/menus.tsx +0 -55
- package/src/components/layout/Sidebar/components/nav-projects.tsx +0 -88
- package/src/components/layout/Sidebar/components/nav-user.tsx +0 -114
- package/src/components/layout/Sidebar/components/team-switcher.tsx +0 -85
- package/src/components/layout/Sidebar/index.ts +0 -2
- package/src/components/layout/Sidebar/provider/index.tsx +0 -51
- package/src/components/layout/Tabs/Tabs.tsx +0 -51
- package/src/components/layout/Tabs/index.ts +0 -1
- package/src/components/layout/Tabs/tabs.stories.tsx +0 -57
- package/src/components/layout/index.ts +0 -6
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +0 -66
- package/src/components/navigation/Breadcrumbs/index.ts +0 -2
- package/src/components/navigation/index.ts +0 -1
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -59
- package/src/components/ui/avatar.tsx +0 -50
- package/src/components/ui/badge.tsx +0 -40
- package/src/components/ui/breadcrumb.tsx +0 -115
- package/src/components/ui/button.tsx +0 -57
- package/src/components/ui/card.tsx +0 -83
- package/src/components/ui/checkbox.tsx +0 -34
- package/src/components/ui/collapsible.tsx +0 -11
- package/src/components/ui/command.tsx +0 -153
- package/src/components/ui/dialog.tsx +0 -124
- package/src/components/ui/drawer.tsx +0 -117
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/form.tsx +0 -179
- package/src/components/ui/input.tsx +0 -24
- package/src/components/ui/label.tsx +0 -30
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/select.tsx +0 -161
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/sheet.tsx +0 -140
- package/src/components/ui/sidebar.tsx +0 -763
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/spinner.tsx +0 -54
- package/src/components/ui/switch.tsx +0 -33
- package/src/components/ui/table.tsx +0 -120
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/toast.tsx +0 -130
- package/src/components/ui/toaster.tsx +0 -35
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/hooks/use-conditional-controller.tsx +0 -35
- package/src/hooks/use-mask.tsx +0 -116
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/hooks/use-toast.ts +0 -191
- package/src/index.ts +0 -1
- package/src/introduction.mdx +0 -132
- package/src/lib/utils.ts +0 -6
- package/tailwind.config.ts +0 -83
- package/tsconfig.json +0 -27
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
4
|
-
import { Checkbox } from "../../../components/ui/checkbox";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import {
|
|
7
|
-
ArrowDownIcon,
|
|
8
|
-
ArrowRightIcon,
|
|
9
|
-
ArrowUpIcon,
|
|
10
|
-
CheckCircledIcon,
|
|
11
|
-
CircleIcon,
|
|
12
|
-
CrossCircledIcon,
|
|
13
|
-
QuestionMarkCircledIcon,
|
|
14
|
-
StopwatchIcon,
|
|
15
|
-
} from "@radix-ui/react-icons";
|
|
16
|
-
import { DataTableColumnHeader } from "./custom/CustomTable/data-table-column-header";
|
|
17
|
-
import { Badge } from "../../../components/ui/badge";
|
|
18
|
-
import { DataTableRowActions } from "./custom/CustomTable/data-table-row-actions";
|
|
19
|
-
|
|
20
|
-
export const labels = [
|
|
21
|
-
{
|
|
22
|
-
value: "bug",
|
|
23
|
-
label: "Bug",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: "feature",
|
|
27
|
-
label: "Feature",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
value: "documentation",
|
|
31
|
-
label: "Documentation",
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
export const statuses = [
|
|
36
|
-
{
|
|
37
|
-
value: "backlog",
|
|
38
|
-
label: "Backlog",
|
|
39
|
-
icon: QuestionMarkCircledIcon,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
value: "todo",
|
|
43
|
-
label: "Todo",
|
|
44
|
-
icon: CircleIcon,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
value: "in progress",
|
|
48
|
-
label: "In Progress",
|
|
49
|
-
icon: StopwatchIcon,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
value: "done",
|
|
53
|
-
label: "Done",
|
|
54
|
-
icon: CheckCircledIcon,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
value: "canceled",
|
|
58
|
-
label: "Canceled",
|
|
59
|
-
icon: CrossCircledIcon,
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
export const priorities = [
|
|
64
|
-
{
|
|
65
|
-
label: "Low",
|
|
66
|
-
value: "low",
|
|
67
|
-
icon: ArrowDownIcon,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: "Medium",
|
|
71
|
-
value: "medium",
|
|
72
|
-
icon: ArrowRightIcon,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
label: "High",
|
|
76
|
-
value: "high",
|
|
77
|
-
icon: ArrowUpIcon,
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
export const taskSchema = z.object({
|
|
82
|
-
id: z.string(),
|
|
83
|
-
title: z.string(),
|
|
84
|
-
status: z.string(),
|
|
85
|
-
label: z.string(),
|
|
86
|
-
priority: z.string(),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export type Task = z.infer<typeof taskSchema>;
|
|
90
|
-
|
|
91
|
-
export const columns: ColumnDef<Task>[] = [
|
|
92
|
-
{
|
|
93
|
-
id: "select",
|
|
94
|
-
header: ({ table }) => (
|
|
95
|
-
<Checkbox
|
|
96
|
-
checked={
|
|
97
|
-
table.getIsAllPageRowsSelected() ||
|
|
98
|
-
(table.getIsSomePageRowsSelected() && "indeterminate")
|
|
99
|
-
}
|
|
100
|
-
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
|
101
|
-
aria-label="Select all"
|
|
102
|
-
className="translate-y-[2px]"
|
|
103
|
-
/>
|
|
104
|
-
),
|
|
105
|
-
cell: ({ row }) => (
|
|
106
|
-
<Checkbox
|
|
107
|
-
checked={row.getIsSelected()}
|
|
108
|
-
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
|
109
|
-
aria-label="Select row"
|
|
110
|
-
className="translate-y-[2px]"
|
|
111
|
-
/>
|
|
112
|
-
),
|
|
113
|
-
enableSorting: false,
|
|
114
|
-
enableHiding: false,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
accessorKey: "id",
|
|
118
|
-
header: ({ column }) => (
|
|
119
|
-
<DataTableColumnHeader column={column} title="Task" />
|
|
120
|
-
),
|
|
121
|
-
cell: ({ row }) => <div className="w-[80px]">{row.getValue("id")}</div>,
|
|
122
|
-
enableSorting: false,
|
|
123
|
-
enableHiding: false,
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
accessorKey: "title",
|
|
127
|
-
header: ({ column }) => (
|
|
128
|
-
<DataTableColumnHeader column={column} title="Title" />
|
|
129
|
-
),
|
|
130
|
-
cell: ({ row }) => {
|
|
131
|
-
const label = labels.find((label) => label.value === row.original.label);
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<div className="flex space-x-2">
|
|
135
|
-
{label && <Badge variant="outline">{label.label}</Badge>}
|
|
136
|
-
<span className="max-w-[500px] truncate font-medium">
|
|
137
|
-
{row.getValue("title")}
|
|
138
|
-
</span>
|
|
139
|
-
</div>
|
|
140
|
-
);
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
accessorKey: "status",
|
|
145
|
-
header: ({ column }) => (
|
|
146
|
-
<DataTableColumnHeader column={column} title="Status" />
|
|
147
|
-
),
|
|
148
|
-
cell: ({ row }) => {
|
|
149
|
-
const status = statuses.find(
|
|
150
|
-
(status) => status.value === row.getValue("status")
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
if (!status) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<div className="flex w-[100px] items-center">
|
|
159
|
-
{status.icon && (
|
|
160
|
-
<status.icon className="mr-2 h-4 w-4 text-muted-foreground" />
|
|
161
|
-
)}
|
|
162
|
-
<span>{status.label}</span>
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
filterFn: (row, id, value) => {
|
|
167
|
-
return value.includes(row.getValue(id));
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
accessorKey: "priority",
|
|
172
|
-
header: ({ column }) => (
|
|
173
|
-
<DataTableColumnHeader column={column} title="Priority" />
|
|
174
|
-
),
|
|
175
|
-
cell: ({ row }) => {
|
|
176
|
-
const priority = priorities.find(
|
|
177
|
-
(priority) => priority.value === row.getValue("priority")
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
if (!priority) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<div className="flex items-center">
|
|
186
|
-
{priority.icon && (
|
|
187
|
-
<priority.icon className="mr-2 h-4 w-4 text-muted-foreground" />
|
|
188
|
-
)}
|
|
189
|
-
<span>{priority.label}</span>
|
|
190
|
-
</div>
|
|
191
|
-
);
|
|
192
|
-
},
|
|
193
|
-
filterFn: (row, id, value) => {
|
|
194
|
-
return value.includes(row.getValue(id));
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
id: "actions",
|
|
199
|
-
cell: ({ row }) => (
|
|
200
|
-
<DataTableRowActions
|
|
201
|
-
row={row}
|
|
202
|
-
options={[
|
|
203
|
-
{
|
|
204
|
-
action: () => alert("Edit"),
|
|
205
|
-
label: "Edit",
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
action: () => alert("Make a copy"),
|
|
209
|
-
label: "Make a copy",
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
action: () => alert("Favorite"),
|
|
213
|
-
label: "Favorite",
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
action: () => alert("Delete"),
|
|
217
|
-
label: "Delete",
|
|
218
|
-
},
|
|
219
|
-
]}
|
|
220
|
-
/>
|
|
221
|
-
),
|
|
222
|
-
},
|
|
223
|
-
];
|
package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ArrowDownIcon,
|
|
5
|
-
ArrowUpIcon,
|
|
6
|
-
CaretSortIcon,
|
|
7
|
-
EyeNoneIcon,
|
|
8
|
-
} from "@radix-ui/react-icons";
|
|
9
|
-
import { Column } from "@tanstack/react-table";
|
|
10
|
-
import { cn } from "../../../../../lib/utils";
|
|
11
|
-
import { Button } from "../../../../../components/ui/button";
|
|
12
|
-
import {
|
|
13
|
-
DropdownMenu,
|
|
14
|
-
DropdownMenuContent,
|
|
15
|
-
DropdownMenuItem,
|
|
16
|
-
DropdownMenuSeparator,
|
|
17
|
-
DropdownMenuTrigger,
|
|
18
|
-
} from "../../../../../components/ui/dropdown-menu";
|
|
19
|
-
|
|
20
|
-
interface DataTableColumnHeaderProps<TData, TValue>
|
|
21
|
-
extends React.HTMLAttributes<HTMLDivElement> {
|
|
22
|
-
column: Column<TData, TValue>;
|
|
23
|
-
title: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function DataTableColumnHeader<TData, TValue>({
|
|
27
|
-
column,
|
|
28
|
-
title,
|
|
29
|
-
className,
|
|
30
|
-
}: DataTableColumnHeaderProps<TData, TValue>) {
|
|
31
|
-
if (!column.getCanSort()) {
|
|
32
|
-
return <div className={cn(className)}>{title}</div>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div className={cn("flex items-center space-x-2", className)}>
|
|
37
|
-
<DropdownMenu>
|
|
38
|
-
<DropdownMenuTrigger asChild>
|
|
39
|
-
<Button
|
|
40
|
-
variant="ghost"
|
|
41
|
-
size="sm"
|
|
42
|
-
className="-ml-3 h-8 data-[state=open]:bg-accent"
|
|
43
|
-
>
|
|
44
|
-
<span>{title}</span>
|
|
45
|
-
{column.getIsSorted() === "desc" ? (
|
|
46
|
-
<ArrowDownIcon className="ml-2 h-4 w-4" />
|
|
47
|
-
) : column.getIsSorted() === "asc" ? (
|
|
48
|
-
<ArrowUpIcon className="ml-2 h-4 w-4" />
|
|
49
|
-
) : (
|
|
50
|
-
<CaretSortIcon className="ml-2 h-4 w-4" />
|
|
51
|
-
)}
|
|
52
|
-
</Button>
|
|
53
|
-
</DropdownMenuTrigger>
|
|
54
|
-
<DropdownMenuContent align="start">
|
|
55
|
-
<DropdownMenuItem onClick={() => column.toggleSorting(false)}>
|
|
56
|
-
<ArrowUpIcon className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
|
|
57
|
-
Crescente
|
|
58
|
-
</DropdownMenuItem>
|
|
59
|
-
<DropdownMenuItem onClick={() => column.toggleSorting(true)}>
|
|
60
|
-
<ArrowDownIcon className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
|
|
61
|
-
Decrescente
|
|
62
|
-
</DropdownMenuItem>
|
|
63
|
-
<DropdownMenuSeparator />
|
|
64
|
-
<DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
|
|
65
|
-
<EyeNoneIcon className="mr-2 h-3.5 w-3.5 text-muted-foreground/70" />
|
|
66
|
-
Ocultar
|
|
67
|
-
</DropdownMenuItem>
|
|
68
|
-
</DropdownMenuContent>
|
|
69
|
-
</DropdownMenu>
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ChevronLeftIcon,
|
|
5
|
-
ChevronRightIcon,
|
|
6
|
-
DoubleArrowLeftIcon,
|
|
7
|
-
DoubleArrowRightIcon,
|
|
8
|
-
} from "@radix-ui/react-icons";
|
|
9
|
-
import { Button } from "../../../../../components/ui/button";
|
|
10
|
-
import {
|
|
11
|
-
Select,
|
|
12
|
-
SelectContent,
|
|
13
|
-
SelectItem,
|
|
14
|
-
SelectTrigger,
|
|
15
|
-
SelectValue,
|
|
16
|
-
} from "../../../../../components/ui/select";
|
|
17
|
-
import { DynamicTablePaginationProps } from "./types";
|
|
18
|
-
|
|
19
|
-
export function DataTablePagination<TData>({
|
|
20
|
-
table,
|
|
21
|
-
pageSizeOptions = [10, 20, 30, 40, 50],
|
|
22
|
-
}: DynamicTablePaginationProps<TData>) {
|
|
23
|
-
return (
|
|
24
|
-
<div className="flex items-center justify-between px-2">
|
|
25
|
-
<div className="flex-1 text-sm text-muted-foreground">
|
|
26
|
-
{table.getFilteredSelectedRowModel().rows.length} de{" "}
|
|
27
|
-
{table.getFilteredRowModel().rows.length} linha(s) selecionada(s).
|
|
28
|
-
</div>
|
|
29
|
-
<div className="flex items-center space-x-6 lg:space-x-8">
|
|
30
|
-
<div className="flex items-center space-x-2">
|
|
31
|
-
<p className="text-sm font-medium">Linhas por página</p>
|
|
32
|
-
<Select
|
|
33
|
-
value={`${table.getState().pagination.pageSize}`}
|
|
34
|
-
onValueChange={(value) => {
|
|
35
|
-
table.setPageSize(Number(value));
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
<SelectTrigger className="h-8 w-[70px]">
|
|
39
|
-
<SelectValue placeholder={table.getState().pagination.pageSize} />
|
|
40
|
-
</SelectTrigger>
|
|
41
|
-
<SelectContent side="top">
|
|
42
|
-
{pageSizeOptions.map((pageSize) => (
|
|
43
|
-
<SelectItem key={pageSize} value={`${pageSize}`}>
|
|
44
|
-
{pageSize}
|
|
45
|
-
</SelectItem>
|
|
46
|
-
))}
|
|
47
|
-
</SelectContent>
|
|
48
|
-
</Select>
|
|
49
|
-
</div>
|
|
50
|
-
<div className="flex w-[100px] items-center justify-center text-sm font-medium">
|
|
51
|
-
Página {table.getState().pagination.pageIndex + 1} de{" "}
|
|
52
|
-
{table.getPageCount()}
|
|
53
|
-
</div>
|
|
54
|
-
<div className="flex items-center space-x-2">
|
|
55
|
-
<Button
|
|
56
|
-
variant="outline"
|
|
57
|
-
className="hidden h-8 w-8 p-0 lg:flex"
|
|
58
|
-
onClick={() => table.setPageIndex(0)}
|
|
59
|
-
disabled={!table.getCanPreviousPage()}
|
|
60
|
-
>
|
|
61
|
-
<DoubleArrowLeftIcon className="h-4 w-4" />
|
|
62
|
-
</Button>
|
|
63
|
-
<Button
|
|
64
|
-
variant="outline"
|
|
65
|
-
className="h-8 w-8 p-0"
|
|
66
|
-
onClick={() => table.previousPage()}
|
|
67
|
-
disabled={!table.getCanPreviousPage()}
|
|
68
|
-
>
|
|
69
|
-
<ChevronLeftIcon className="h-4 w-4" />
|
|
70
|
-
</Button>
|
|
71
|
-
<Button
|
|
72
|
-
variant="outline"
|
|
73
|
-
className="h-8 w-8 p-0"
|
|
74
|
-
onClick={() => table.nextPage()}
|
|
75
|
-
disabled={!table.getCanNextPage()}
|
|
76
|
-
>
|
|
77
|
-
<ChevronRightIcon className="h-4 w-4" />
|
|
78
|
-
</Button>
|
|
79
|
-
<Button
|
|
80
|
-
variant="outline"
|
|
81
|
-
className="hidden h-8 w-8 p-0 lg:flex"
|
|
82
|
-
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
|
|
83
|
-
disabled={!table.getCanNextPage()}
|
|
84
|
-
>
|
|
85
|
-
<DoubleArrowRightIcon className="h-4 w-4" />
|
|
86
|
-
</Button>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { DataTableViewOptions } from "./data-table-view-options";
|
|
4
|
-
import { DynamicTableToolbarProps } from "./types";
|
|
5
|
-
|
|
6
|
-
export function DataTableToolbar<TData>({
|
|
7
|
-
table,
|
|
8
|
-
filters,
|
|
9
|
-
showColumnVisibility,
|
|
10
|
-
}: DynamicTableToolbarProps<TData>) {
|
|
11
|
-
return (
|
|
12
|
-
<div className="flex items-center justify-between">
|
|
13
|
-
<div className="flex flex-1 items-center space-x-2">{filters}</div>
|
|
14
|
-
{showColumnVisibility && <DataTableViewOptions table={table} />}
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx
DELETED
|
@@ -1,58 +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
|
-
import { Button } from "../../../../../components/ui/button";
|
|
7
|
-
import {
|
|
8
|
-
DropdownMenu,
|
|
9
|
-
DropdownMenuCheckboxItem,
|
|
10
|
-
DropdownMenuContent,
|
|
11
|
-
DropdownMenuLabel,
|
|
12
|
-
DropdownMenuSeparator,
|
|
13
|
-
} from "../../../../../components/ui/dropdown-menu";
|
|
14
|
-
|
|
15
|
-
interface DataTableViewOptionsProps<TData> {
|
|
16
|
-
table: Table<TData>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function DataTableViewOptions<TData>({
|
|
20
|
-
table,
|
|
21
|
-
}: DataTableViewOptionsProps<TData>) {
|
|
22
|
-
return (
|
|
23
|
-
<DropdownMenu>
|
|
24
|
-
<DropdownMenuTrigger asChild>
|
|
25
|
-
<Button
|
|
26
|
-
variant="outline"
|
|
27
|
-
size="sm"
|
|
28
|
-
className="ml-auto hidden h-8 lg:flex"
|
|
29
|
-
>
|
|
30
|
-
<MixerHorizontalIcon className="mr-2 h-4 w-4" />
|
|
31
|
-
Colunas
|
|
32
|
-
</Button>
|
|
33
|
-
</DropdownMenuTrigger>
|
|
34
|
-
<DropdownMenuContent align="end" className="w-[150px]">
|
|
35
|
-
<DropdownMenuLabel>Colunas visíveis</DropdownMenuLabel>
|
|
36
|
-
<DropdownMenuSeparator />
|
|
37
|
-
{table
|
|
38
|
-
.getAllColumns()
|
|
39
|
-
.filter(
|
|
40
|
-
(column) =>
|
|
41
|
-
typeof column.accessorFn !== "undefined" && column.getCanHide()
|
|
42
|
-
)
|
|
43
|
-
.map((column) => {
|
|
44
|
-
return (
|
|
45
|
-
<DropdownMenuCheckboxItem
|
|
46
|
-
key={column.id}
|
|
47
|
-
className="capitalize"
|
|
48
|
-
checked={column.getIsVisible()}
|
|
49
|
-
onCheckedChange={(value) => column.toggleVisibility(!!value)}
|
|
50
|
-
>
|
|
51
|
-
{column.id}
|
|
52
|
-
</DropdownMenuCheckboxItem>
|
|
53
|
-
);
|
|
54
|
-
})}
|
|
55
|
-
</DropdownMenuContent>
|
|
56
|
-
</DropdownMenu>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
-
import { DynamicTable } from "./index";
|
|
3
|
-
import { Button } from "../../../../../components/ui/button";
|
|
4
|
-
import { Input } from "../../../../../components/ui/input";
|
|
5
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
6
|
-
|
|
7
|
-
interface User {
|
|
8
|
-
id: number;
|
|
9
|
-
name: string;
|
|
10
|
-
email: string;
|
|
11
|
-
role: string;
|
|
12
|
-
status: "active" | "inactive";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const meta: Meta<typeof DynamicTable> = {
|
|
16
|
-
title: "DataDisplay/DynamicTable",
|
|
17
|
-
component: DynamicTable,
|
|
18
|
-
parameters: {
|
|
19
|
-
layout: "centered",
|
|
20
|
-
},
|
|
21
|
-
tags: ["autodocs"],
|
|
22
|
-
} satisfies Meta<typeof DynamicTable>;
|
|
23
|
-
|
|
24
|
-
export default meta;
|
|
25
|
-
type Story = StoryObj<typeof DynamicTable<User>>;
|
|
26
|
-
|
|
27
|
-
const data: User[] = [
|
|
28
|
-
{
|
|
29
|
-
id: 1,
|
|
30
|
-
name: "John Doe",
|
|
31
|
-
email: "john@example.com",
|
|
32
|
-
role: "Admin",
|
|
33
|
-
status: "active",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
id: 2,
|
|
37
|
-
name: "Jane Smith",
|
|
38
|
-
email: "jane@example.com",
|
|
39
|
-
role: "User",
|
|
40
|
-
status: "inactive",
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const columns: ColumnDef<User>[] = [
|
|
45
|
-
{
|
|
46
|
-
accessorKey: "id",
|
|
47
|
-
header: "ID",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
accessorKey: "name",
|
|
51
|
-
header: "Nome",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
accessorKey: "email",
|
|
55
|
-
header: "Email",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
accessorKey: "role",
|
|
59
|
-
header: "Função",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
accessorKey: "status",
|
|
63
|
-
header: "Status",
|
|
64
|
-
cell: ({ row }) => (
|
|
65
|
-
<span
|
|
66
|
-
className={`px-2 py-1 rounded-full text-xs font-medium ${
|
|
67
|
-
row.original.status === "active"
|
|
68
|
-
? "bg-green-100 text-green-800"
|
|
69
|
-
: "bg-red-100 text-red-800"
|
|
70
|
-
}`}
|
|
71
|
-
>
|
|
72
|
-
{row.original.status === "active" ? "Ativo" : "Inativo"}
|
|
73
|
-
</span>
|
|
74
|
-
),
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: "actions",
|
|
78
|
-
cell: () => (
|
|
79
|
-
<Button variant="ghost" size="sm">
|
|
80
|
-
Editar
|
|
81
|
-
</Button>
|
|
82
|
-
),
|
|
83
|
-
},
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
export const Default: Story = {
|
|
87
|
-
args: {
|
|
88
|
-
data,
|
|
89
|
-
columns,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const WithFilters: Story = {
|
|
94
|
-
args: {
|
|
95
|
-
...Default.args,
|
|
96
|
-
filters: (
|
|
97
|
-
<>
|
|
98
|
-
<Input placeholder="Buscar por nome..." className="max-w-xs" />
|
|
99
|
-
<Button>Filtrar</Button>
|
|
100
|
-
</>
|
|
101
|
-
),
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const WithPagination: Story = {
|
|
106
|
-
args: {
|
|
107
|
-
...Default.args,
|
|
108
|
-
pagination: true,
|
|
109
|
-
rowsPerPage: [5, 10, 20],
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const WithColumnVisibility: Story = {
|
|
114
|
-
args: {
|
|
115
|
-
...Default.args,
|
|
116
|
-
columnVisibility: true,
|
|
117
|
-
},
|
|
118
|
-
};
|