@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,52 +0,0 @@
1
- import { Label } from "../../../components/ui/label";
2
- import {
3
- Switch as SwitchUI,
4
- SwitchProps as SwitchUIProps,
5
- } from "../../../components/ui/switch";
6
- import { useFormContext } from "react-hook-form";
7
- import {
8
- FormControl,
9
- FormField,
10
- FormItem,
11
- FormLabel,
12
- } from "../../../components/ui/form";
13
- import { cn } from "../../../lib/utils";
14
-
15
- export type SwitchProps = SwitchUIProps & {
16
- label?: string;
17
- withoutForm?: boolean;
18
- };
19
-
20
- export function Switch({
21
- label,
22
- withoutForm,
23
- className,
24
- ...props
25
- }: SwitchProps) {
26
- const form = useFormContext();
27
- const hasForm = !!form && !withoutForm && !!props.name;
28
-
29
- if (!hasForm)
30
- return (
31
- <div className="flex items-center space-x-2">
32
- <SwitchUI {...props} />
33
- {label && <Label htmlFor={props.id}>{label}</Label>}
34
- </div>
35
- );
36
- return (
37
- <FormField
38
- control={form.control}
39
- name={props.name ?? ""}
40
- render={({ field }) => (
41
- <FormItem
42
- className={cn(className, "flex items-center space-x-2 space-y-0")}
43
- >
44
- <FormControl>
45
- <Switch checked={field.value} onCheckedChange={field.onChange} />
46
- </FormControl>
47
- <FormLabel>{label}</FormLabel>
48
- </FormItem>
49
- )}
50
- />
51
- );
52
- }
@@ -1 +0,0 @@
1
- export * from "./Switch";
@@ -1,57 +0,0 @@
1
- import { useFormContext } from "react-hook-form";
2
- import {
3
- Checkbox as CheckboxUI,
4
- CheckboxProps as CheckboxUIProps,
5
- } from "../../ui/checkbox";
6
- import { Label } from "../../../components/ui/label";
7
-
8
- import { FormControl, FormField, FormItem, FormLabel } from "../form";
9
-
10
- import { ErrorMessage } from "../../../components/dataDisplay/ErrorMessage";
11
-
12
- export type CheckboxProps = CheckboxUIProps & {
13
- label: string;
14
- error?: string;
15
- withoutForm?: boolean;
16
- };
17
-
18
- export const Checkbox = ({
19
- label,
20
- error,
21
- withoutForm,
22
- ...props
23
- }: CheckboxProps) => {
24
- const form = useFormContext();
25
-
26
- const hasForm = !withoutForm && !!form && !!props.name;
27
- if (!hasForm)
28
- return (
29
- <div className="flex items-center space-x-2">
30
- <CheckboxUI {...props} />
31
- {label && <Label htmlFor={props.id}>{label}</Label>}
32
- {error && <ErrorMessage>{error}</ErrorMessage>}
33
- </div>
34
- );
35
-
36
- return (
37
- <FormField
38
- control={form.control}
39
- name={props.name ?? ""}
40
- render={({ field }) => (
41
- <FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4">
42
- <FormControl>
43
- <CheckboxUI
44
- checked={field.value}
45
- onCheckedChange={field.onChange}
46
- />
47
- </FormControl>
48
- {label && (
49
- <div className="space-y-1 leading-none">
50
- <FormLabel>{label}</FormLabel>
51
- </div>
52
- )}
53
- </FormItem>
54
- )}
55
- />
56
- );
57
- };
@@ -1,58 +0,0 @@
1
- import { Label } from "../../../components/ui/label";
2
- import {
3
- Checkbox as CheckboxUI,
4
- CheckboxProps as CheckboxUIProps,
5
- } from "../../ui/checkbox";
6
- import { ErrorMessage } from "../../../components/dataDisplay/ErrorMessage";
7
- import { FormControl } from "..";
8
- import { FormField, FormItem, FormLabel } from "../form";
9
- import { useFormContext } from "react-hook-form";
10
-
11
- export type CheckboxProps = CheckboxUIProps & {
12
- label: string;
13
- error?: string;
14
- withoutForm?: boolean;
15
- };
16
-
17
- export const Checkbox = ({
18
- label,
19
- error,
20
- withoutForm,
21
- ...props
22
- }: CheckboxProps) => {
23
- const form = useFormContext();
24
-
25
- const hasForm = !withoutForm && !!form && !!props.name;
26
- // if (!hasForm)
27
- // return (
28
- // <div className="flex items-center space-x-2">
29
- // <CheckboxUI {...props} />
30
- // {label && <Label htmlFor={props.id}>{label}</Label>}
31
- // {error && <ErrorMessage>{error}</ErrorMessage>}
32
- // </div>
33
- // );
34
-
35
- return <></>;
36
-
37
- return (
38
- <FormField
39
- control={form.control}
40
- name={props.name ?? ""}
41
- render={({ field }) => (
42
- <FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4">
43
- <FormControl>
44
- <CheckboxUI
45
- checked={field.value}
46
- onCheckedChange={field.onChange}
47
- />
48
- </FormControl>
49
- {label && (
50
- <div className="space-y-1 leading-none">
51
- <FormLabel>{label}</FormLabel>
52
- </div>
53
- )}
54
- </FormItem>
55
- )}
56
- />
57
- );
58
- };
@@ -1,62 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
- import { Checkbox } from "./Checkbox";
3
- import { Form } from "../form";
4
- import { useForm } from "react-hook-form";
5
-
6
- type Story = StoryObj<typeof Checkbox>;
7
-
8
- const meta = {
9
- title: "Data Input/Checkbox",
10
- component: Checkbox,
11
- tags: ["autodocs"],
12
- args: {
13
- label: "Accept terms and conditions",
14
- },
15
- } satisfies Meta<typeof Checkbox>;
16
-
17
- export default meta;
18
-
19
- export const Default: Story = {
20
- args: {
21
- label: "Accept terms and conditions",
22
- },
23
- };
24
-
25
- export const Checked: Story = {
26
- args: {
27
- label: "Accept terms and conditions",
28
- checked: true,
29
- },
30
- };
31
-
32
- export const Disabled: Story = {
33
- args: {
34
- label: "Accept terms and conditions",
35
- disabled: true,
36
- },
37
- };
38
-
39
- export const DisabledChecked: Story = {
40
- args: {
41
- label: "Accept terms and conditions",
42
- disabled: true,
43
- checked: true,
44
- },
45
- };
46
-
47
- export const WithForm: Story = {
48
- args: {
49
- label: "Accept terms and conditions",
50
- },
51
- decorators: [
52
- (Story: React.ComponentType) => {
53
- const form = useForm();
54
-
55
- return (
56
- <Form {...form}>
57
- <Story />
58
- </Form>
59
- );
60
- },
61
- ],
62
- };
@@ -1 +0,0 @@
1
- export * from "./Checkbox";
@@ -1,47 +0,0 @@
1
- import { useMemo } from "react";
2
- import {
3
- FormControl,
4
- FormField,
5
- FormItem,
6
- FormLabel,
7
- FormMessage,
8
- } from "./index";
9
- import {
10
- ControllerRenderProps,
11
- FieldValues,
12
- useFormContext,
13
- } from "react-hook-form";
14
-
15
- export type FormContainerProps = {
16
- name: string;
17
- label?: string;
18
- render: (
19
- props?: ControllerRenderProps<FieldValues, string>
20
- ) => React.ReactNode;
21
- className?: string;
22
- };
23
- export const FormContainer = ({
24
- name,
25
- label,
26
- className,
27
- render = () => <></>,
28
- }: FormContainerProps) => {
29
- const form = useFormContext();
30
- const control = useMemo(() => form?.control, [form]);
31
-
32
- return (
33
- <FormField
34
- control={control}
35
- name={name}
36
- render={({ field }) => (
37
- <FormItem className={className}>
38
- <FormItem className={className}>
39
- {label && <FormLabel>{label}</FormLabel>}
40
- <FormControl>{render && render(field)}</FormControl>
41
- </FormItem>
42
- <FormMessage />
43
- </FormItem>
44
- )}
45
- />
46
- );
47
- };
@@ -1,3 +0,0 @@
1
- import { useFormContext } from "react-hook-form";
2
- export * from "../../ui/form";
3
- export { useFormContext };
@@ -1,5 +0,0 @@
1
- export * from "./checkbox";
2
- export * from "./Input";
3
- export * from "./form";
4
- export * from "./Select";
5
- export * from "./Switch";
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import { Icon } from "@/components/dataDisplay";
3
- import { cn } from "@/lib/utils";
4
-
5
- export type ErrorLabelProps = React.PropsWithChildren<{
6
- className?: string;
7
- "data-testid"?: string;
8
- }>;
9
-
10
- export const ErrorLabel = ({
11
- children,
12
- className,
13
- "data-testid": dataTestId,
14
- }: ErrorLabelProps) => {
15
- return (
16
- <div
17
- className={cn("flex items-center gap-2 my-2", className)}
18
- data-testid={`${dataTestId}-error-label`}
19
- >
20
- <Icon name="MdErrorOutline" size={18} className="text-destructive" />
21
- <span className="text-destructive text-sm">{children}</span>
22
- </div>
23
- );
24
- };
@@ -1 +0,0 @@
1
- export * from "../../ui/spinner";
@@ -1,45 +0,0 @@
1
- import React from "react";
2
- import type { Meta, StoryObj } from "@storybook/nextjs";
3
- import { fn } from "storybook/test";
4
- import { Button } from "../../../components/actions";
5
- import { Toaster, useToast } from "./index";
6
-
7
- const meta = {
8
- title: "DataInput/Toast",
9
- component: Toaster,
10
- parameters: {
11
- layout: "centered",
12
- },
13
- tags: ["autodocs"],
14
- args: { onClick: fn() },
15
- } satisfies Meta<typeof Toaster>;
16
-
17
- export default meta;
18
- type Story = StoryObj<typeof meta>;
19
-
20
- export const Default: Story = {
21
- args: {
22
- title: "Success",
23
- description: "This is a success message",
24
- variant: "default",
25
- },
26
- argTypes: {
27
- descritpion: { control: { type: "text" } },
28
- title: { control: { type: "text" } },
29
- variant: {
30
- control: {
31
- type: "select",
32
- },
33
- options: ["default", "success", "destructive"],
34
- },
35
- },
36
- render: (args) => {
37
- const { toast } = useToast();
38
- return (
39
- <div className="w-[500px] h-[500px]">
40
- <Button onClick={() => toast(args)}>Success</Button>
41
- <Toaster />
42
- </div>
43
- );
44
- },
45
- };
@@ -1,2 +0,0 @@
1
- export * from "../../ui/toaster";
2
- export * from "../../../hooks/use-toast";
@@ -1,2 +0,0 @@
1
- export * from "./Spinner";
2
- export * from "./Toast";
@@ -1,6 +0,0 @@
1
- export * from "./dataDisplay";
2
- export * from "./dataInput";
3
- export * from "./actions";
4
- export * from "./layout";
5
- export * from "./navigation";
6
- export * from "./feedback";
@@ -1,183 +0,0 @@
1
- import {
2
- Table as TableUI,
3
- TableBody,
4
- TableHead,
5
- TableHeader,
6
- TableRow,
7
- TableCell,
8
- } from "@/components/ui/table";
9
- import {
10
- flexRender,
11
- getCoreRowModel,
12
- useReactTable,
13
- } from "@tanstack/react-table";
14
- import { TableProps } from "./types";
15
- import { Button } from "@/components/ui/button";
16
- import {
17
- Select,
18
- SelectContent,
19
- SelectItem,
20
- SelectTrigger,
21
- SelectValue,
22
- } from "@/components/ui/select";
23
- import { ChevronLeft, ChevronRight } from "lucide-react";
24
-
25
- export function Table<TData>({
26
- data,
27
- columns,
28
- isLoading,
29
- pagination,
30
- }: TableProps<TData>) {
31
- // Configuração da tabela
32
- const table = useReactTable({
33
- data,
34
- columns,
35
- getCoreRowModel: getCoreRowModel(),
36
- manualPagination: true,
37
- pageCount: pagination ? Math.ceil(pagination.total / pagination.limit) : 1,
38
- });
39
-
40
- if (isLoading && data.length === 0) {
41
- return (
42
- <div className="rounded-md border">
43
- <TableUI>
44
- <TableHeader>
45
- {table.getHeaderGroups().map((headerGroup) => (
46
- <TableRow key={headerGroup.id}>
47
- {headerGroup.headers.map((header) => (
48
- <TableHead key={header.id}>
49
- {flexRender(
50
- header.column.columnDef.header,
51
- header.getContext()
52
- )}
53
- </TableHead>
54
- ))}
55
- </TableRow>
56
- ))}
57
- </TableHeader>
58
- <TableBody>
59
- <TableRow>
60
- <TableCell colSpan={columns.length} className="text-center">
61
- Carregando...
62
- </TableCell>
63
- </TableRow>
64
- </TableBody>
65
- </TableUI>
66
- </div>
67
- );
68
- }
69
-
70
- if (data.length === 0) {
71
- return (
72
- <div className="rounded-md border">
73
- <TableUI>
74
- <TableHeader>
75
- {table.getHeaderGroups().map((headerGroup) => (
76
- <TableRow key={headerGroup.id}>
77
- {headerGroup.headers.map((header) => (
78
- <TableHead key={header.id}>
79
- {flexRender(
80
- header.column.columnDef.header,
81
- header.getContext()
82
- )}
83
- </TableHead>
84
- ))}
85
- </TableRow>
86
- ))}
87
- </TableHeader>
88
- <TableBody>
89
- <TableRow>
90
- <TableCell colSpan={columns.length} className="text-center">
91
- Nenhuma configuração encontrada
92
- </TableCell>
93
- </TableRow>
94
- </TableBody>
95
- </TableUI>
96
- </div>
97
- );
98
- }
99
-
100
- return (
101
- <div className="space-y-4">
102
- <div className="rounded-md border">
103
- <TableUI>
104
- <TableHeader>
105
- {table.getHeaderGroups().map((headerGroup) => (
106
- <TableRow key={headerGroup.id}>
107
- {headerGroup.headers.map((header) => (
108
- <TableHead key={header.id}>
109
- {flexRender(
110
- header.column.columnDef.header,
111
- header.getContext()
112
- )}
113
- </TableHead>
114
- ))}
115
- </TableRow>
116
- ))}
117
- </TableHeader>
118
- <TableBody>
119
- {table.getRowModel().rows.map((row) => (
120
- <TableRow key={row.id}>
121
- {row.getVisibleCells().map((cell) => (
122
- <TableCell key={cell.id}>
123
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
124
- </TableCell>
125
- ))}
126
- </TableRow>
127
- ))}
128
- </TableBody>
129
- </TableUI>
130
- </div>
131
-
132
- {pagination && (
133
- <div className="flex items-center justify-between px-2">
134
- <div className="flex items-center space-x-2">
135
- <p className="text-sm font-medium">Linhas por página</p>
136
- <Select
137
- value={pagination.limit.toString()}
138
- onValueChange={(value) => pagination.onLimitChange(Number(value))}
139
- >
140
- <SelectTrigger className="h-8 w-[70px]">
141
- <SelectValue />
142
- </SelectTrigger>
143
- <SelectContent side="top">
144
- <SelectItem value="10">10</SelectItem>
145
- <SelectItem value="20">20</SelectItem>
146
- <SelectItem value="50">50</SelectItem>
147
- <SelectItem value="100">100</SelectItem>
148
- </SelectContent>
149
- </Select>
150
- </div>
151
-
152
- <div className="flex items-center space-x-6 lg:space-x-8">
153
- <div className="flex w-[100px] items-center justify-center text-sm font-medium">
154
- Página {pagination.page} de{" "}
155
- {Math.ceil(pagination.total / pagination.limit)}
156
- </div>
157
- <div className="flex items-center space-x-2">
158
- <Button
159
- variant="outline"
160
- className="h-8 w-8 p-0"
161
- onClick={() => pagination.onPageChange(pagination.page - 1)}
162
- disabled={pagination.page <= 1}
163
- >
164
- <ChevronLeft className="h-4 w-4" />
165
- </Button>
166
- <Button
167
- variant="outline"
168
- className="h-8 w-8 p-0"
169
- onClick={() => pagination.onPageChange(pagination.page + 1)}
170
- disabled={
171
- pagination.page >=
172
- Math.ceil(pagination.total / pagination.limit)
173
- }
174
- >
175
- <ChevronRight className="h-4 w-4" />
176
- </Button>
177
- </div>
178
- </div>
179
- </div>
180
- )}
181
- </div>
182
- );
183
- }
@@ -1,15 +0,0 @@
1
- import { ColumnDef } from "@tanstack/react-table";
2
-
3
- export interface TableProps<TData> {
4
- data: TData[];
5
- columns: ColumnDef<TData>[];
6
- isLoading: boolean;
7
- pagination: {
8
- page: number;
9
- limit: number;
10
- total: number;
11
- onPageChange: (page: number) => void;
12
- onLimitChange: (limit: number) => void;
13
- pageOptions: number[];
14
- };
15
- }