@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,295 +0,0 @@
1
- import { AlertCircle, Edit, Plus, Trash2 } from "lucide-react";
2
- import { Table } from "./components/Table";
3
- import { CrudLayoutProps } from "./types";
4
- import { Button } from "@/components/ui/button";
5
- import { useCallback, useEffect, useMemo, useState } from "react";
6
- import { Form } from "@/components/ui/form";
7
- import {
8
- Dialog,
9
- DialogHeader,
10
- DialogContent,
11
- DialogTitle,
12
- DialogDescription,
13
- DialogFooter,
14
- } from "@/components/ui/dialog";
15
- import {
16
- useTitleModal,
17
- useDescriptionModal,
18
- useSubmitButtonText,
19
- useCreateButtonText,
20
- useCrudLayoutActions,
21
- useOpenEditModal,
22
- useDeleteId,
23
- useEditId,
24
- useSendingButtonText,
25
- } from "./store/CrudLayoutStore";
26
- import {
27
- AlertDialog,
28
- AlertDialogAction,
29
- AlertDialogCancel,
30
- AlertDialogContent,
31
- AlertDialogDescription,
32
- AlertDialogFooter,
33
- AlertDialogHeader,
34
- AlertDialogTitle,
35
- } from "@/components/ui/alert-dialog";
36
- import { useRequest } from "./hook/useRequest";
37
- import { Alert, AlertDescription } from "@/components/ui/alert";
38
- import { toast } from "sonner";
39
-
40
- export const CrudLayout = <
41
- ListData extends { _id: string },
42
- CreateData,
43
- UpdateData
44
- >({
45
- columns,
46
- title,
47
- createRequest,
48
- updateRequest,
49
- deleteRequest,
50
- listRequest = () => Promise.resolve({ data: [], total: 0 }),
51
- formComponent,
52
- actions = [],
53
- form,
54
- }: CrudLayoutProps<ListData, CreateData, UpdateData>) => {
55
- const [isModalOpen, setIsModalOpen] = useState(false);
56
- const [modalMode, setModalMode] = useState<"create" | "edit">("create");
57
- const [page, setPage] = useState(1);
58
- const [limit, setLimit] = useState(10);
59
-
60
- const titleModal = useTitleModal();
61
- const descriptionModal = useDescriptionModal();
62
- const submitButtonText = useSubmitButtonText();
63
- const createButtonText = useCreateButtonText();
64
- const sendingButtonText = useSendingButtonText();
65
- const deleteId = useDeleteId();
66
- const editId = useEditId();
67
- const openEditModal = useOpenEditModal();
68
- const { setDeleteId, setOpenEditModal, setEditId } = useCrudLayoutActions();
69
-
70
- const isEditMode = useMemo(() => modalMode === "edit", [modalMode]);
71
-
72
- const {
73
- listData,
74
- total,
75
- error,
76
- createActionRequest,
77
- updateActionRequest,
78
- deleteActionRequest,
79
- isLoading,
80
- } = useRequest({
81
- queryKey: "configs",
82
- createRequest,
83
- updateRequest,
84
- deleteRequest,
85
- listRequest,
86
- page,
87
- limit,
88
- });
89
-
90
- useEffect(() => {
91
- if (openEditModal && editId) {
92
- const itemToEdit = listData.find((item: ListData) => item._id === editId);
93
- if (itemToEdit) {
94
- form.reset(itemToEdit);
95
- setModalMode("edit");
96
- setIsModalOpen(true);
97
- setOpenEditModal(false);
98
- }
99
- }
100
- }, [editId, form, listData, openEditModal, setOpenEditModal]);
101
-
102
- const resetForm = useCallback(() => {
103
- form.reset({});
104
- const formValues = form.getValues();
105
- Object.keys(formValues).forEach((key) => {
106
- form.setValue(key, "");
107
- });
108
- }, [form]);
109
-
110
- const customColumns = useMemo(() => {
111
- const editButton = actions.includes("update") && {
112
- id: "actions",
113
- header: "Ações",
114
- cell: ({ row }) => {
115
- const data = row.original;
116
- return (
117
- <div className="flex gap-2">
118
- {actions.includes("update") && (
119
- <Button
120
- variant="outline"
121
- size="sm"
122
- onClick={() => {
123
- setEditId(data._id);
124
- setOpenEditModal(true);
125
- }}
126
- >
127
- <Edit className="h-4 w-4" />
128
- </Button>
129
- )}
130
- {actions.includes("delete") && (
131
- <Button
132
- variant="outline"
133
- size="sm"
134
- onClick={() => setDeleteId(data._id)}
135
- >
136
- <Trash2 className="h-4 w-4" />
137
- </Button>
138
- )}
139
- </div>
140
- );
141
- },
142
- };
143
-
144
- const data = [...columns];
145
-
146
- if (editButton) data.push(editButton);
147
-
148
- return data;
149
- }, [columns, actions, setEditId, setOpenEditModal, setDeleteId]);
150
-
151
- const closeModal = useCallback(() => {
152
- setIsModalOpen(false);
153
- setModalMode("create");
154
- setEditId(null);
155
- resetForm();
156
- }, [setEditId, resetForm]);
157
-
158
- const onSubmit = useCallback(
159
- async (data: CreateData | UpdateData) => {
160
- try {
161
- let success;
162
-
163
- if (isEditMode) {
164
- success = await updateActionRequest(data as UpdateData);
165
- if (success) {
166
- toast.success("Configuração atualizada");
167
- }
168
- } else {
169
- success = await createActionRequest(data as CreateData);
170
- if (success) {
171
- toast.success("Configuração criada");
172
- }
173
- }
174
-
175
- if (success) {
176
- closeModal();
177
- }
178
- } catch (error) {
179
- console.error("Erro ao salvar:", error);
180
- toast.error("Erro ao salvar configuração");
181
- }
182
- },
183
- [createActionRequest, updateActionRequest, isEditMode, closeModal]
184
- );
185
-
186
- const onClickCreate = useCallback(() => {
187
- resetForm();
188
- setModalMode("create");
189
- setEditId(null);
190
- setIsModalOpen(true);
191
- }, [setEditId, resetForm]);
192
-
193
- const onDeleteData = useCallback(
194
- async (dataId: string) => {
195
- const success = await deleteActionRequest(dataId);
196
- if (success) {
197
- toast.success("Configuração deletada com sucesso");
198
- setDeleteId(null);
199
- }
200
- },
201
- [deleteActionRequest, setDeleteId]
202
- );
203
-
204
- const handleModalOpenChange = useCallback(
205
- (isOpen: boolean) => {
206
- if (!isOpen) {
207
- closeModal();
208
- }
209
- },
210
- [closeModal]
211
- );
212
-
213
- const handlePageChange = useCallback((newPage: number) => {
214
- setPage(newPage);
215
- }, []);
216
-
217
- const handleLimitChange = useCallback((newLimit: number) => {
218
- setLimit(newLimit);
219
- setPage(1); // Reset to first page when changing limit
220
- }, []);
221
-
222
- return (
223
- <div className="container mx-auto p-4 space-y-6 bg-white rounded-md">
224
- <div className="flex justify-between items-center md:flex-row flex-col gap-4">
225
- <h1 className="text-2xl font-bold">{title}</h1>
226
- <Button onClick={onClickCreate} className="w-full md:w-auto">
227
- <Plus className="mr-2 h-4 w-4" /> {createButtonText}
228
- </Button>
229
- </div>
230
-
231
- <Dialog open={isModalOpen} onOpenChange={handleModalOpenChange}>
232
- <DialogContent>
233
- <DialogHeader>
234
- <DialogTitle>{titleModal}</DialogTitle>
235
- <DialogDescription>{descriptionModal}</DialogDescription>
236
- </DialogHeader>
237
- <Form {...form}>
238
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
239
- {formComponent}
240
- <DialogFooter>
241
- <Button type="submit" disabled={isLoading}>
242
- {isLoading ? sendingButtonText : submitButtonText}
243
- </Button>
244
- </DialogFooter>
245
- </form>
246
- </Form>
247
- </DialogContent>
248
- </Dialog>
249
-
250
- {error && (
251
- <Alert variant="destructive">
252
- <AlertCircle className="h-4 w-4" />
253
- <AlertDescription>{error}</AlertDescription>
254
- </Alert>
255
- )}
256
-
257
- <Table<ListData>
258
- data={listData}
259
- columns={customColumns}
260
- isLoading={isLoading}
261
- pagination={{
262
- page,
263
- limit,
264
- total,
265
- onPageChange: handlePageChange,
266
- onLimitChange: handleLimitChange,
267
- }}
268
- />
269
- <AlertDialog
270
- open={!!deleteId}
271
- onOpenChange={(open) => {
272
- if (!open) {
273
- setDeleteId(null);
274
- }
275
- }}
276
- >
277
- <AlertDialogContent>
278
- <AlertDialogHeader>
279
- <AlertDialogTitle>{titleModal}</AlertDialogTitle>
280
- <AlertDialogDescription>{descriptionModal}</AlertDialogDescription>
281
- </AlertDialogHeader>
282
- <AlertDialogFooter>
283
- <AlertDialogCancel>Cancelar</AlertDialogCancel>
284
- <AlertDialogAction
285
- onClick={() => onDeleteData(deleteId as string)}
286
- className="bg-red-600 hover:bg-red-700"
287
- >
288
- {isLoading ? sendingButtonText : "Excluir"}
289
- </AlertDialogAction>
290
- </AlertDialogFooter>
291
- </AlertDialogContent>
292
- </AlertDialog>
293
- </div>
294
- );
295
- };
@@ -1,75 +0,0 @@
1
- import { create } from "zustand";
2
-
3
- export type CrudLayoutStore = {
4
- titleModal?: string;
5
- descriptionModal?: string;
6
- submitButtonText?: string;
7
- createButtonText?: string;
8
- isEditMode: boolean;
9
- deleteId: string | null;
10
- editId: string | null;
11
- openEditModal: boolean;
12
- sendingButtonText?: string;
13
- actions: {
14
- setTitleModal: (title: string) => void;
15
- setDescriptionModal: (description: string) => void;
16
- setSubmitButtonText: (text: string) => void;
17
- setCreateButtonText: (text: string) => void;
18
- setIsEditMode: (isEditMode: boolean) => void;
19
- setDeleteId: (id: string | null) => void;
20
- setEditId: (id: string | null) => void;
21
- setOpenEditModal: (open: boolean) => void;
22
- setSendingButtonText: (text?: string) => void;
23
- };
24
- };
25
-
26
- export const useCrudLayoutStore = create<CrudLayoutStore>((set) => ({
27
- titleModal: "",
28
- descriptionModal: "",
29
- submitButtonText: "Salvar",
30
- createButtonText: "Criar",
31
- isEditMode: false,
32
- deleteId: null,
33
- editId: null,
34
- openEditModal: false,
35
- actions: {
36
- setTitleModal: (title) => set({ titleModal: title }),
37
- setDescriptionModal: (description) =>
38
- set({ descriptionModal: description }),
39
- setSubmitButtonText: (text) => set({ submitButtonText: text }),
40
- setCreateButtonText: (text) => set({ createButtonText: text }),
41
- setIsEditMode: (isEditMode) => set({ isEditMode }),
42
- setDeleteId: (id) => set({ deleteId: id }),
43
- setEditId: (id) => set({ editId: id }),
44
- setOpenEditModal: (open) => set({ openEditModal: open }),
45
- setSendingButtonText: (text) => set({ sendingButtonText: text }),
46
- },
47
- }));
48
-
49
- export const useCrudLayoutActions = () =>
50
- useCrudLayoutStore((state) => state.actions);
51
-
52
- export const useTitleModal = () =>
53
- useCrudLayoutStore((state) => state.titleModal);
54
-
55
- export const useDescriptionModal = () =>
56
- useCrudLayoutStore((state) => state.descriptionModal);
57
-
58
- export const useSubmitButtonText = () =>
59
- useCrudLayoutStore((state) => state.submitButtonText);
60
-
61
- export const useCreateButtonText = () =>
62
- useCrudLayoutStore((state) => state.createButtonText);
63
-
64
- export const useIsEditMode = () =>
65
- useCrudLayoutStore((state) => state.isEditMode);
66
-
67
- export const useDeleteId = () => useCrudLayoutStore((state) => state.deleteId);
68
-
69
- export const useEditId = () => useCrudLayoutStore((state) => state.editId);
70
-
71
- export const useOpenEditModal = () =>
72
- useCrudLayoutStore((state) => state.openEditModal);
73
-
74
- export const useSendingButtonText = () =>
75
- useCrudLayoutStore((state) => state.sendingButtonText);
@@ -1,14 +0,0 @@
1
- import { ColumnDef } from "@tanstack/react-table";
2
-
3
- export type CrudLayoutProps<ListData, CreateData, UpdateData> = {
4
- columns: ColumnDef<ListData>[];
5
- title: string;
6
- listRequest?: () => Promise<ListData[]>;
7
- createRequest?: (data?: CreateData) => Promise<ListData>;
8
- updateRequest?: (data?: UpdateData) => Promise<ListData>;
9
- deleteRequest?: (key: string) => Promise<void>;
10
- formComponent: React.ReactNode;
11
-
12
- form: any;
13
- actions?: ["create", "update", "delete"];
14
- };
@@ -1,33 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { Minus, Plus } from "lucide-react";
5
- // import { Bar, BarChart, ResponsiveContainer } from "recharts";
6
-
7
- import { Button } from "../../../actions";
8
- import {
9
- Drawer,
10
- DrawerClose,
11
- DrawerContent,
12
- DrawerDescription,
13
- DrawerFooter,
14
- DrawerHeader,
15
- DrawerProps,
16
- DrawerTitle,
17
- DrawerTrigger,
18
- } from "../../Drawer";
19
-
20
- export type CustomDrawerProps = DrawerProps & {
21
- className?: string;
22
- };
23
-
24
- export function CustomDrawer({ className, ...props }: CustomDrawerProps) {
25
- return (
26
- <Drawer {...props}>
27
- {/* <DrawerTrigger asChild>
28
- <Button variant="outline">Open Drawer</Button>
29
- </DrawerTrigger> */}
30
- <DrawerContent className={className}>{props.children}</DrawerContent>
31
- </Drawer>
32
- );
33
- }
@@ -1,80 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
-
3
- import { Button } from "../../actions/Button";
4
-
5
- import {
6
- Drawer,
7
- DrawerClose,
8
- DrawerContent,
9
- DrawerDescription,
10
- DrawerFooter,
11
- DrawerHeader,
12
- DrawerTitle,
13
- DrawerTrigger,
14
- CustomDrawer as CustomDrawerComponent,
15
- CustomDrawerProps,
16
- } from "./index";
17
-
18
- const meta = {
19
- title: "DataDisplay/Drawer",
20
- render: (args) => {
21
- return (
22
- <Drawer>
23
- <DrawerTrigger>Open</DrawerTrigger>
24
- <DrawerContent>
25
- <DrawerHeader>
26
- <DrawerTitle>Are you absolutely sure?</DrawerTitle>
27
- <DrawerDescription>This action cannot be undone.</DrawerDescription>
28
- </DrawerHeader>
29
- <DrawerFooter>
30
- <Button>Submit</Button>
31
- <DrawerClose>
32
- <Button variant="outline">Cancel</Button>
33
- </DrawerClose>
34
- </DrawerFooter>
35
- </DrawerContent>
36
- </Drawer>
37
- );
38
- },
39
- parameters: {
40
- layout: "centered",
41
- },
42
- tags: ["autodocs"],
43
- } satisfies Meta<typeof Drawer>;
44
-
45
- export default meta;
46
- type Story = StoryObj<typeof meta>;
47
-
48
- export const Default: Story = {
49
- args: {
50
- children: "Drawer",
51
- },
52
- };
53
-
54
- export const CustomDrawer: StoryObj<CustomDrawerProps> = {
55
- args: {
56
- children: "Drawer",
57
- open: true,
58
- },
59
- argTypes: {
60
- direction: {
61
- options: ["top", "right", "bottom", "left"],
62
- control: {
63
- type: "select",
64
- },
65
- },
66
- className: {
67
- control: {
68
- type: "text",
69
- },
70
- },
71
- open: {
72
- control: {
73
- type: "boolean",
74
- },
75
- },
76
- },
77
- render: (args) => {
78
- return <CustomDrawerComponent {...args} />;
79
- },
80
- };
@@ -1,2 +0,0 @@
1
- export * from "../../ui/drawer";
2
- export * from "./CustomDrawer";
@@ -1,42 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
- import { PageLayout } from "./index";
3
- import { Icon, Text } from "../../../components/dataDisplay";
4
- import { Button } from "../../../components/actions";
5
-
6
- const meta: Meta<typeof PageLayout> = {
7
- title: "Layout/PageLayout",
8
- component: PageLayout,
9
- parameters: {
10
- layout: "fullscreen",
11
- },
12
- tags: ["autodocs"],
13
- argTypes: {
14
- title: { control: "text" },
15
- subtitle: { control: "text" },
16
- header: { control: "text" },
17
- },
18
- };
19
-
20
- export default meta;
21
- type Story = StoryObj<typeof PageLayout>;
22
-
23
- export const Default: Story = {
24
- args: {
25
- title: "Page Title",
26
- subtitle: "Page Subtitle",
27
- children: <Text>Page content goes here.</Text>,
28
- },
29
- };
30
-
31
- export const WithHeader: Story = {
32
- args: {
33
- title: "Page Title",
34
- subtitle: "Page Subtitle",
35
- header: (
36
- <Button>
37
- <Icon name="MdAdd" />
38
- </Button>
39
- ),
40
- children: <Text>Page content goes here.</Text>,
41
- },
42
- };
@@ -1,28 +0,0 @@
1
- import { Text } from "../../../components/dataDisplay";
2
- import { PropsWithChildren } from "react";
3
-
4
- export type PageLayoutProps = PropsWithChildren & {
5
- title: string;
6
- subtitle?: string;
7
- header?: React.ReactNode;
8
- };
9
-
10
- export const PageLayout = ({
11
- subtitle,
12
- title,
13
- children,
14
- header,
15
- }: PageLayoutProps) => {
16
- return (
17
- <div className="m-5 p-4 bg-white">
18
- <div className="flex justify-between">
19
- <div>
20
- {title && <Text variant="title">{title}</Text>}
21
- {subtitle && <Text variant="muted">{subtitle}</Text>}
22
- </div>
23
- {header}
24
- </div>
25
- <div className="mt-5">{children}</div>
26
- </div>
27
- );
28
- };
@@ -1 +0,0 @@
1
- export * from "../../ui/separator";
@@ -1,28 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
-
3
- import { Sheet } from "./index";
4
-
5
- const meta = {
6
- title: "Layout/Sheet",
7
- component: Sheet,
8
- parameters: {
9
- layout: "centered",
10
- },
11
- args: {
12
- open: false,
13
- children: "Sheet content",
14
- },
15
- argTypes: {
16
- open: {
17
- control: {
18
- type: "boolean",
19
- },
20
- },
21
- },
22
- tags: ["autodocs"],
23
- } satisfies Meta<typeof Sheet>;
24
-
25
- export default meta;
26
- type Story = StoryObj<typeof meta>;
27
-
28
- export const Default: Story = {};
@@ -1,22 +0,0 @@
1
- import {
2
- Sheet as SheetComponent,
3
- SheetContent,
4
- } from "../../../components/ui/sheet";
5
- import { PropsWithChildren } from "react";
6
-
7
- export type SheetProps = typeof SheetComponent &
8
- PropsWithChildren & {
9
- side?: "left" | "right" | "top" | "bottom";
10
- className?: string;
11
- onOpenChange?: (open: boolean) => void;
12
- open?: boolean;
13
- };
14
- export function Sheet({ side, className, children, ...props }: SheetProps) {
15
- return (
16
- <SheetComponent {...props}>
17
- <SheetContent side={side} className={className}>
18
- {children}
19
- </SheetContent>
20
- </SheetComponent>
21
- );
22
- }
@@ -1 +0,0 @@
1
- export * from "./Sheet";