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

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 (213) 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/package.json +46 -6
  9. package/.eslintrc.json +0 -7
  10. package/.github/workflows/deploy-storybook.yml +0 -75
  11. package/.storybook/main.ts +0 -16
  12. package/.storybook/preview.ts +0 -15
  13. package/components.json +0 -21
  14. package/jest.config.ts +0 -25
  15. package/next.config.ts +0 -7
  16. package/postcss.config.mjs +0 -8
  17. package/public/file.svg +0 -1
  18. package/public/globe.svg +0 -1
  19. package/public/next.svg +0 -1
  20. package/public/vercel.svg +0 -1
  21. package/public/window.svg +0 -1
  22. package/src/app/columns.tsx +0 -178
  23. package/src/app/favicon.ico +0 -0
  24. package/src/app/fonts/GeistMonoVF.woff +0 -0
  25. package/src/app/fonts/GeistVF.woff +0 -0
  26. package/src/app/globals.css +0 -94
  27. package/src/app/layout.tsx +0 -35
  28. package/src/app/page.tsx +0 -7
  29. package/src/components/actions/AlertDialog/AlertDialog.tsx +0 -45
  30. package/src/components/actions/AlertDialog/alert-dialog.stories.tsx +0 -21
  31. package/src/components/actions/AlertDialog/index.ts +0 -1
  32. package/src/components/actions/Button/Button.stories.ts +0 -38
  33. package/src/components/actions/Button/Button.tsx +0 -23
  34. package/src/components/actions/Button/index.ts +0 -1
  35. package/src/components/actions/Collapsible/index.ts +0 -1
  36. package/src/components/actions/Dialog/Dialog.stories.tsx +0 -70
  37. package/src/components/actions/Dialog/Dialog.tsx +0 -87
  38. package/src/components/actions/Dialog/components/DialogWithActions/index.tsx +0 -40
  39. package/src/components/actions/Dialog/index.ts +0 -1
  40. package/src/components/actions/Steps/Steps.stories.tsx +0 -25
  41. package/src/components/actions/Steps/Steps.tsx +0 -51
  42. package/src/components/actions/Steps/index.ts +0 -1
  43. package/src/components/actions/index.ts +0 -5
  44. package/src/components/dataDisplay/Avatar/Avatar.stories.tsx +0 -22
  45. package/src/components/dataDisplay/Avatar/Avatar.tsx +0 -21
  46. package/src/components/dataDisplay/Avatar/index.ts +0 -2
  47. package/src/components/dataDisplay/Badge/Badge.stories.tsx +0 -36
  48. package/src/components/dataDisplay/Badge/index.ts +0 -1
  49. package/src/components/dataDisplay/Card/Card.stories.tsx +0 -24
  50. package/src/components/dataDisplay/Card/Card.tsx +0 -34
  51. package/src/components/dataDisplay/Card/index.ts +0 -1
  52. package/src/components/dataDisplay/DataPairList/DataPairList.tsx +0 -56
  53. package/src/components/dataDisplay/DataPairList/data-pair-list.stories.tsx +0 -87
  54. package/src/components/dataDisplay/DataPairList/index.ts +0 -2
  55. package/src/components/dataDisplay/DataPairList/types.ts +0 -10
  56. package/src/components/dataDisplay/DropDownMenu/index.ts +0 -1
  57. package/src/components/dataDisplay/ErrorMessage/ErrorMessage.tsx +0 -6
  58. package/src/components/dataDisplay/ErrorMessage/index.ts +0 -1
  59. package/src/components/dataDisplay/Icon/Icon.stories.tsx +0 -21
  60. package/src/components/dataDisplay/Icon/Icon.tsx +0 -47
  61. package/src/components/dataDisplay/Icon/index.ts +0 -1
  62. package/src/components/dataDisplay/Icon/types.ts +0 -6
  63. package/src/components/dataDisplay/Label/Label.stories.tsx +0 -21
  64. package/src/components/dataDisplay/Label/Label.tsx +0 -10
  65. package/src/components/dataDisplay/Label/index.ts +0 -1
  66. package/src/components/dataDisplay/Table/Table.tsx +0 -173
  67. package/src/components/dataDisplay/Table/columns.tsx +0 -223
  68. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx +0 -72
  69. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-pagination.tsx +0 -91
  70. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-toolbar.tsx +0 -17
  71. package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx +0 -58
  72. package/src/components/dataDisplay/Table/components/DynamicTable/data-table.stories.tsx +0 -118
  73. package/src/components/dataDisplay/Table/components/DynamicTable/index.tsx +0 -136
  74. package/src/components/dataDisplay/Table/components/DynamicTable/types.ts +0 -43
  75. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-column-header.tsx +0 -71
  76. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-faceted-filter.tsx +0 -147
  77. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-pagination.tsx +0 -97
  78. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-row-actions.tsx +0 -78
  79. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-toolbar.tsx +0 -60
  80. package/src/components/dataDisplay/Table/custom/CustomTable/data-table-view-options.tsx +0 -59
  81. package/src/components/dataDisplay/Table/custom/CustomTable/data-table.tsx +0 -145
  82. package/src/components/dataDisplay/Table/custom/CustomTable/data.ts +0 -71
  83. package/src/components/dataDisplay/Table/custom/CustomTable/index.tsx +0 -34
  84. package/src/components/dataDisplay/Table/custom/CustomTable/schema.ts +0 -11
  85. package/src/components/dataDisplay/Table/index.ts +0 -2
  86. package/src/components/dataDisplay/Table/table.stories.tsx +0 -147
  87. package/src/components/dataDisplay/Table/types.ts +0 -15
  88. package/src/components/dataDisplay/Tabs/Tabs.stories.tsx +0 -34
  89. package/src/components/dataDisplay/Tabs/Tabs.tsx +0 -53
  90. package/src/components/dataDisplay/Tabs/index.ts +0 -1
  91. package/src/components/dataDisplay/Text/Text.stories.tsx +0 -66
  92. package/src/components/dataDisplay/Text/Text.tsx +0 -56
  93. package/src/components/dataDisplay/Text/index.ts +0 -1
  94. package/src/components/dataDisplay/index.ts +0 -8
  95. package/src/components/dataInput/Input/components/Input/Input.stories.tsx +0 -99
  96. package/src/components/dataInput/Input/components/Input/InputBase.tsx +0 -50
  97. package/src/components/dataInput/Input/components/Input/__tests__/input.test.tsx +0 -38
  98. package/src/components/dataInput/Input/components/Input/index.tsx +0 -48
  99. package/src/components/dataInput/Input/components/Input/types.ts +0 -15
  100. package/src/components/dataInput/Input/components/InputBase/index.tsx +0 -31
  101. package/src/components/dataInput/Input/components/MaskInput/__tests__/mask-input.test.tsx +0 -77
  102. package/src/components/dataInput/Input/components/MaskInput/index.ts +0 -1
  103. package/src/components/dataInput/Input/components/MaskInput/mask-input.stories.tsx +0 -85
  104. package/src/components/dataInput/Input/components/MaskInput/mask-input.tsx +0 -73
  105. package/src/components/dataInput/Input/components/MultipleInput/MultipleInput.tsx +0 -105
  106. package/src/components/dataInput/Input/components/MultipleInput/MultipleInputBase.tsx +0 -100
  107. package/src/components/dataInput/Input/components/MultipleInput/MultipleMaskInput.tsx +0 -35
  108. package/src/components/dataInput/Input/components/MultipleInput/MultipleNumberInput.tsx +0 -35
  109. package/src/components/dataInput/Input/components/MultipleInput/__tests__/multiple-input.test.tsx +0 -152
  110. package/src/components/dataInput/Input/components/MultipleInput/index.ts +0 -2
  111. package/src/components/dataInput/Input/components/MultipleInput/multiple-input.stories.tsx +0 -96
  112. package/src/components/dataInput/Input/components/NumberInput/__tests__/number-input.test.tsx +0 -175
  113. package/src/components/dataInput/Input/components/NumberInput/index.ts +0 -1
  114. package/src/components/dataInput/Input/components/NumberInput/number-input.stories.tsx +0 -76
  115. package/src/components/dataInput/Input/components/NumberInput/number-input.tsx +0 -70
  116. package/src/components/dataInput/Input/index.ts +0 -4
  117. package/src/components/dataInput/Select/MultiSelect/MultiSelect.stories.tsx +0 -119
  118. package/src/components/dataInput/Select/MultiSelect/MultiSelectBase.tsx +0 -135
  119. package/src/components/dataInput/Select/MultiSelect/index.tsx +0 -75
  120. package/src/components/dataInput/Select/Select.stories.tsx +0 -61
  121. package/src/components/dataInput/Select/Select.tsx +0 -73
  122. package/src/components/dataInput/Select/SelectBase.tsx +0 -58
  123. package/src/components/dataInput/Select/index.ts +0 -2
  124. package/src/components/dataInput/Switch/Switch.stories.tsx +0 -75
  125. package/src/components/dataInput/Switch/Switch.tsx +0 -52
  126. package/src/components/dataInput/Switch/index.ts +0 -1
  127. package/src/components/dataInput/checkbox/Checkbox.tsx +0 -57
  128. package/src/components/dataInput/checkbox/Checkbox_old.tsx +0 -58
  129. package/src/components/dataInput/checkbox/Checkout.stories.tsx +0 -62
  130. package/src/components/dataInput/checkbox/index.ts +0 -1
  131. package/src/components/dataInput/form/Form.tsx +0 -47
  132. package/src/components/dataInput/form/index.ts +0 -3
  133. package/src/components/dataInput/index.ts +0 -5
  134. package/src/components/feedback/ErrorLabel/index.tsx +0 -24
  135. package/src/components/feedback/Spinner/index.ts +0 -1
  136. package/src/components/feedback/Toast/Toast.stories.tsx +0 -45
  137. package/src/components/feedback/Toast/index.ts +0 -2
  138. package/src/components/feedback/index.ts +0 -2
  139. package/src/components/index.ts +0 -6
  140. package/src/components/layout/Crud/components/Table/index.tsx +0 -183
  141. package/src/components/layout/Crud/components/Table/types.ts +0 -15
  142. package/src/components/layout/Crud/crud.stories.tsx +0 -317
  143. package/src/components/layout/Crud/hook/useCrudLayout/index.tsx +0 -94
  144. package/src/components/layout/Crud/hook/useRequest/index.tsx +0 -156
  145. package/src/components/layout/Crud/index.tsx +0 -295
  146. package/src/components/layout/Crud/store/CrudLayoutStore.ts +0 -75
  147. package/src/components/layout/Crud/types.ts +0 -14
  148. package/src/components/layout/Drawer/CustomDrawer/index.tsx +0 -33
  149. package/src/components/layout/Drawer/Drawer.stories.tsx +0 -80
  150. package/src/components/layout/Drawer/index.ts +0 -2
  151. package/src/components/layout/PageLayout/PageLayout.stories.tsx +0 -42
  152. package/src/components/layout/PageLayout/index.tsx +0 -28
  153. package/src/components/layout/Separator/index.ts +0 -1
  154. package/src/components/layout/Sheet/Sheet.stories.tsx +0 -28
  155. package/src/components/layout/Sheet/Sheet.tsx +0 -22
  156. package/src/components/layout/Sheet/index.ts +0 -1
  157. package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -116
  158. package/src/components/layout/Sidebar/Sidebar.tsx +0 -50
  159. package/src/components/layout/Sidebar/components/app-sidebar.tsx +0 -203
  160. package/src/components/layout/Sidebar/components/footer-sidebar.tsx +0 -17
  161. package/src/components/layout/Sidebar/components/header-sidebar.tsx +0 -90
  162. package/src/components/layout/Sidebar/components/menus.tsx +0 -55
  163. package/src/components/layout/Sidebar/components/nav-projects.tsx +0 -88
  164. package/src/components/layout/Sidebar/components/nav-user.tsx +0 -114
  165. package/src/components/layout/Sidebar/components/team-switcher.tsx +0 -85
  166. package/src/components/layout/Sidebar/index.ts +0 -2
  167. package/src/components/layout/Sidebar/provider/index.tsx +0 -51
  168. package/src/components/layout/Tabs/Tabs.tsx +0 -51
  169. package/src/components/layout/Tabs/index.ts +0 -1
  170. package/src/components/layout/Tabs/tabs.stories.tsx +0 -57
  171. package/src/components/layout/index.ts +0 -6
  172. package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +0 -66
  173. package/src/components/navigation/Breadcrumbs/index.ts +0 -2
  174. package/src/components/navigation/index.ts +0 -1
  175. package/src/components/ui/alert-dialog.tsx +0 -141
  176. package/src/components/ui/alert.tsx +0 -59
  177. package/src/components/ui/avatar.tsx +0 -50
  178. package/src/components/ui/badge.tsx +0 -40
  179. package/src/components/ui/breadcrumb.tsx +0 -115
  180. package/src/components/ui/button.tsx +0 -57
  181. package/src/components/ui/card.tsx +0 -83
  182. package/src/components/ui/checkbox.tsx +0 -34
  183. package/src/components/ui/collapsible.tsx +0 -11
  184. package/src/components/ui/command.tsx +0 -153
  185. package/src/components/ui/dialog.tsx +0 -124
  186. package/src/components/ui/drawer.tsx +0 -117
  187. package/src/components/ui/dropdown-menu.tsx +0 -201
  188. package/src/components/ui/form.tsx +0 -179
  189. package/src/components/ui/input.tsx +0 -24
  190. package/src/components/ui/label.tsx +0 -30
  191. package/src/components/ui/popover.tsx +0 -33
  192. package/src/components/ui/select.tsx +0 -161
  193. package/src/components/ui/separator.tsx +0 -31
  194. package/src/components/ui/sheet.tsx +0 -140
  195. package/src/components/ui/sidebar.tsx +0 -763
  196. package/src/components/ui/skeleton.tsx +0 -15
  197. package/src/components/ui/sonner.tsx +0 -31
  198. package/src/components/ui/spinner.tsx +0 -54
  199. package/src/components/ui/switch.tsx +0 -33
  200. package/src/components/ui/table.tsx +0 -120
  201. package/src/components/ui/tabs.tsx +0 -55
  202. package/src/components/ui/toast.tsx +0 -130
  203. package/src/components/ui/toaster.tsx +0 -35
  204. package/src/components/ui/tooltip.tsx +0 -32
  205. package/src/hooks/use-conditional-controller.tsx +0 -35
  206. package/src/hooks/use-mask.tsx +0 -116
  207. package/src/hooks/use-mobile.tsx +0 -19
  208. package/src/hooks/use-toast.ts +0 -191
  209. package/src/index.ts +0 -1
  210. package/src/introduction.mdx +0 -132
  211. package/src/lib/utils.ts +0 -6
  212. package/tailwind.config.ts +0 -83
  213. package/tsconfig.json +0 -27
@@ -1,147 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
- import { Table } from "./Table";
3
- import { ColumnDef } from "@tanstack/react-table";
4
-
5
- const meta: Meta<typeof Table> = {
6
- title: "DataDisplay/Table",
7
- component: Table,
8
- parameters: {
9
- layout: "centered",
10
- },
11
- };
12
-
13
- export default meta;
14
- type Story = StoryObj<typeof Table<User>>;
15
-
16
- type User = {
17
- id: number;
18
- name: string;
19
- email: string;
20
- role: string;
21
- };
22
-
23
- const mockData: User[] = [
24
- {
25
- id: 1,
26
- name: "John Doe",
27
- email: "john@example.com",
28
- role: "Admin",
29
- },
30
- {
31
- id: 2,
32
- name: "Jane Smith",
33
- email: "jane@example.com",
34
- role: "User",
35
- },
36
- {
37
- id: 3,
38
- name: "Bob Johnson",
39
- email: "bob@example.com",
40
- role: "Editor",
41
- },
42
- {
43
- id: 4,
44
- name: "Alice Brown",
45
- email: "alice@example.com",
46
- role: "User",
47
- },
48
- {
49
- id: 5,
50
- name: "Charlie Wilson",
51
- email: "charlie@example.com",
52
- role: "Editor",
53
- },
54
- {
55
- id: 6,
56
- name: "Diana Miller",
57
- email: "diana@example.com",
58
- role: "User",
59
- },
60
- ];
61
-
62
- const columns: ColumnDef<User>[] = [
63
- {
64
- accessorKey: "id",
65
- header: "ID",
66
- enableSorting: true,
67
- },
68
- {
69
- accessorKey: "name",
70
- header: "Name",
71
- enableSorting: true,
72
- },
73
- {
74
- accessorKey: "email",
75
- header: "Email",
76
- enableSorting: true,
77
- },
78
- {
79
- accessorKey: "role",
80
- header: "Role",
81
- },
82
- ];
83
-
84
- export const Default: Story = {
85
- args: {
86
- data: mockData,
87
- columns: columns,
88
- pagination: {
89
- pageIndex: 0,
90
- pageSize: 5,
91
- },
92
- onPaginationChange: (pagination) => {
93
- console.log("Page changed:", {
94
- pageIndex: pagination.pageIndex,
95
- pageSize: pagination.pageSize,
96
- });
97
- },
98
- },
99
- };
100
-
101
- export const SmallPageSize: Story = {
102
- args: {
103
- data: mockData,
104
- columns: columns,
105
- pagination: {
106
- pageIndex: 0,
107
- pageSize: 3,
108
- },
109
- onPaginationChange: (pagination) => {
110
- console.log("Page changed:", {
111
- pageIndex: pagination.pageIndex,
112
- pageSize: pagination.pageSize,
113
- });
114
- },
115
- },
116
- };
117
-
118
- export const StartingFromPage2: Story = {
119
- args: {
120
- data: mockData,
121
- columns: columns,
122
- pagination: {
123
- pageIndex: 1, // Starts from second page
124
- pageSize: 3,
125
- },
126
- onPaginationChange: (pagination) => {
127
- console.log("Page changed:", {
128
- pageIndex: pagination.pageIndex,
129
- pageSize: pagination.pageSize,
130
- });
131
- },
132
- },
133
- };
134
-
135
- export const EmptyTable: Story = {
136
- args: {
137
- data: [],
138
- columns: columns,
139
- },
140
- };
141
-
142
- export const SingleRow: Story = {
143
- args: {
144
- data: [mockData[0]],
145
- columns: columns,
146
- },
147
- };
@@ -1,15 +0,0 @@
1
- export interface Column<T> {
2
- header: string;
3
- accessorKey: keyof T;
4
- cell?: (row: T) => React.ReactNode;
5
- sortable?: boolean;
6
- filterable?: boolean;
7
- }
8
-
9
- export interface TableProps<T> {
10
- data: T[];
11
- columns: Column<T>[];
12
- className?: string;
13
- filters?: React.ReactNode;
14
- onSort?: (field: keyof T, direction: "asc" | "desc") => void;
15
- }
@@ -1,34 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
-
3
- import { Tabs } from "./Tabs";
4
-
5
- const meta = {
6
- title: "DataDisplay/Tabs",
7
- component: Tabs,
8
- parameters: {
9
- layout: "centered",
10
- },
11
- tags: ["autodocs"],
12
- } satisfies Meta<typeof Tabs>;
13
-
14
- export default meta;
15
- type Story = StoryObj<typeof meta>;
16
-
17
- export const Default: Story = {
18
- args: {
19
- data: [
20
- {
21
- label: "Tab 1",
22
- value: "tab1",
23
- content: <div>Tab 1 content</div>,
24
- },
25
- {
26
- label: "Tab 2",
27
- value: "tab2",
28
- content: <div>Tab 2 content</div>,
29
- },
30
- ],
31
- defaultValue: "tab1",
32
- onSelectTab: (value) => console.log(value),
33
- },
34
- };
@@ -1,53 +0,0 @@
1
- import {
2
- Tabs as TabsShadcn,
3
- TabsContent,
4
- TabsList,
5
- TabsTrigger,
6
- } from "../../../components/ui/tabs";
7
- import { useCallback } from "react";
8
-
9
- export type TabsProps = {
10
- data: {
11
- label: string;
12
- value: string;
13
- content: JSX.Element;
14
- }[];
15
- defaultValue: string;
16
- className?: string;
17
- onSelectTab?: (value: string) => void;
18
- value?: string;
19
- };
20
-
21
- export function Tabs({
22
- data,
23
- className,
24
- value,
25
- onSelectTab = () => {},
26
- }: TabsProps) {
27
- const renderTabsTrigger = useCallback(() => {
28
- return data.map(({ label, value }, index) => (
29
- <TabsTrigger key={index} value={value} onClick={() => onSelectTab(value)}>
30
- {label}
31
- </TabsTrigger>
32
- ));
33
- }, [data, onSelectTab]);
34
-
35
- const renderTabsContent = useCallback(() => {
36
- return data.map(({ value, content }, index) => (
37
- <TabsContent key={index} value={value}>
38
- {content}
39
- </TabsContent>
40
- ));
41
- }, [data]);
42
-
43
- return (
44
- <TabsShadcn defaultValue={value} className={className}>
45
- {data?.length && (
46
- <TabsList className="grid w-full grid-cols-2">
47
- {renderTabsTrigger()}
48
- </TabsList>
49
- )}
50
- {data?.length && renderTabsContent()}
51
- </TabsShadcn>
52
- );
53
- }
@@ -1 +0,0 @@
1
- export * from "./Tabs";
@@ -1,66 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
- import { Text } from "./Text";
3
-
4
- const meta: Meta<typeof Text> = {
5
- title: "DataDisplay/Text",
6
- component: Text,
7
- parameters: {
8
- layout: "centered",
9
- },
10
- tags: ["autodocs"],
11
- argTypes: {
12
- variant: {
13
- control: "select",
14
- options: ["display", "title", "subtitle", "body", "caption", "muted"],
15
- },
16
- align: {
17
- control: "select",
18
- options: ["left", "center", "right", "justify"],
19
- },
20
- },
21
- };
22
-
23
- export default meta;
24
- type Story = StoryObj<typeof Text>;
25
-
26
- export const Display: Story = {
27
- args: {
28
- variant: "display",
29
- children: "Cabeçalho Principal (Display)",
30
- },
31
- };
32
-
33
- export const Title: Story = {
34
- args: {
35
- variant: "title",
36
- children: "Título da Seção",
37
- },
38
- };
39
-
40
- export const Subtitle: Story = {
41
- args: {
42
- variant: "subtitle",
43
- children: "Subtítulo explicativo",
44
- },
45
- };
46
-
47
- export const Normal: Story = {
48
- args: {
49
- variant: "normal",
50
- children: "Texto de corpo padrão",
51
- },
52
- };
53
-
54
- export const Caption: Story = {
55
- args: {
56
- variant: "caption",
57
- children: "Texto de legenda",
58
- },
59
- };
60
-
61
- export const Muted: Story = {
62
- args: {
63
- variant: "muted",
64
- children: "Texto desativado ou informativo",
65
- },
66
- };
@@ -1,56 +0,0 @@
1
- import { cva, type VariantProps } from "class-variance-authority";
2
- import { cn } from "../../..//lib/utils";
3
-
4
- // Definição das variantes com pesos adequados
5
- const textVariants = cva("", {
6
- variants: {
7
- variant: {
8
- display: "text-5xl font-extrabold tracking-tight",
9
- title: "text-3xl font-bold tracking-tight",
10
- subtitle: "text-2xl font-semibold",
11
- normal: "text-base font-normal",
12
- caption: "text-sm font-medium",
13
- muted: "text-sm font-normal text-muted-foreground",
14
- },
15
- align: {
16
- left: "text-left",
17
- center: "text-center",
18
- right: "text-right",
19
- justify: "text-justify",
20
- },
21
- },
22
- defaultVariants: {
23
- variant: "normal",
24
- align: "left",
25
- },
26
- });
27
-
28
- // Mapeia variantes para as tags HTML corretas
29
- const tagMap = {
30
- display: "h1",
31
- title: "h2",
32
- subtitle: "h3",
33
- normal: "p",
34
- caption: "small",
35
- muted: "p",
36
- } as const;
37
-
38
- type TextProps = VariantProps<typeof textVariants> & {
39
- className?: string;
40
- children: React.ReactNode;
41
- };
42
-
43
- export function Text({
44
- variant = "normal",
45
- align,
46
- className,
47
- children,
48
- }: TextProps) {
49
- const Tag = tagMap[variant || "normal"] || "p";
50
-
51
- return (
52
- <Tag className={cn(textVariants({ variant, align }), className)}>
53
- {children}
54
- </Tag>
55
- );
56
- }
@@ -1 +0,0 @@
1
- export * from "./Text";
@@ -1,8 +0,0 @@
1
- export * from "./Table";
2
- export * from "./Badge";
3
- export * from "./Icon";
4
- export * from "./Card";
5
- export * from "./Avatar";
6
- export * from "./DropDownMenu";
7
- export * from "./DataPairList";
8
- export * from "./Text";
@@ -1,99 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/nextjs";
2
- import { Input } from "./index";
3
- import { useForm } from "react-hook-form";
4
- import { Form } from "@/components/ui/form";
5
- import { Button } from "@/components/actions";
6
-
7
- const meta: Meta<typeof Input> = {
8
- title: "Data Input/Input/Input",
9
- component: Input,
10
- tags: ["autodocs"],
11
- parameters: {
12
- layout: "centered",
13
- },
14
- };
15
-
16
- export default meta;
17
- type Story = StoryObj<typeof Input>;
18
-
19
- export const Default: Story = {
20
- args: {
21
- label: "Default Input",
22
- placeholder: "Type something...",
23
- name: "default",
24
- mask: "999.999.999-99",
25
- },
26
- };
27
-
28
- export const Required: Story = {
29
- args: {
30
- label: "Required Input",
31
- placeholder: "This field is required",
32
- name: "required",
33
- required: true,
34
- },
35
- };
36
-
37
- export const WithForm: Story = {
38
- args: {
39
- label: "Input with Form",
40
- placeholder: "Standalone input",
41
- name: "test",
42
- },
43
- decorators: [
44
- (Story: React.ComponentType) => {
45
- const form = useForm();
46
- return (
47
- <Form {...form}>
48
- <Story />
49
- </Form>
50
- );
51
- },
52
- ],
53
- };
54
-
55
- export const WithFormMask: Story = {
56
- args: {
57
- label: "Input with Form",
58
- placeholder: "Standalone input",
59
- name: "standalone",
60
- mask: "999.999.999-99",
61
- },
62
- decorators: [
63
- (Story: React.ComponentType) => {
64
- const form = useForm();
65
- return (
66
- <Form {...form}>
67
- <Story />
68
- </Form>
69
- );
70
- },
71
- ],
72
- };
73
-
74
- export const Disabled: Story = {
75
- args: {
76
- label: "Disabled Input",
77
- placeholder: "You cannot type here",
78
- name: "disabled",
79
- disabled: true,
80
- },
81
- };
82
-
83
- export const Error: Story = {
84
- args: {
85
- label: "Error Input",
86
- placeholder: "This field is required",
87
- name: "error",
88
- error: "This is an error message",
89
- },
90
- };
91
-
92
- export const WithButton: Story = {
93
- args: {
94
- label: "Input with Button",
95
- placeholder: "Type something...",
96
- name: "default",
97
- component: <Button>Click me</Button>,
98
- },
99
- };
@@ -1,50 +0,0 @@
1
- import React, { forwardRef, useCallback, useImperativeHandle } from "react";
2
- import { Input, InputProps } from "../../../../ui/input";
3
- import { mask as remask } from "remask";
4
- import { cn } from "@/lib/utils";
5
-
6
- export type InputBaseProps = InputProps & {
7
- onChangeText?: (text: string) => void;
8
- mask?: string | string[];
9
- "data-testid"?: string;
10
- };
11
-
12
- export const InputBase = forwardRef<HTMLInputElement, InputBaseProps>(
13
- ({ mask, className, ...props }, ref) => {
14
- const { onChangeText = () => {}, ...rest } = props;
15
- const inputRef = React.useRef<HTMLInputElement>(null);
16
-
17
- const setMask = useCallback(
18
- (value?: string | number | readonly string[] | undefined) => {
19
- const inputValue = value || "";
20
- if (!mask) return String(inputValue);
21
- return remask(String(inputValue), mask);
22
- },
23
- [mask]
24
- );
25
-
26
- useImperativeHandle(ref, () => inputRef.current!);
27
-
28
- return (
29
- <Input
30
- {...rest}
31
- ref={inputRef}
32
- className={cn(
33
- "border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",
34
- "p-0 h-auto bg-transparent",
35
- className
36
- )}
37
- onChange={(e) => {
38
- const value = setMask(e.target.value);
39
- if (inputRef.current) {
40
- inputRef.current.value = value;
41
- }
42
- props.onChange?.(e);
43
- onChangeText(value);
44
- }}
45
- />
46
- );
47
- }
48
- );
49
-
50
- InputBase.displayName = "InputBase";
@@ -1,38 +0,0 @@
1
- import "@testing-library/jest-dom";
2
- import { fireEvent, render, screen } from "@testing-library/react";
3
- import { Input } from "../index";
4
-
5
- describe("Input", () => {
6
- it("should render label", () => {
7
- render(<Input label="test" data-testid="input" />);
8
- const label = screen.getByTestId("input-label");
9
- expect(label).toBeInTheDocument();
10
- expect(label).toHaveTextContent("test");
11
- });
12
-
13
- it("should render error", () => {
14
- render(<Input error="test" data-testid="input" />);
15
- const error = screen.getByTestId("input-error-label");
16
- expect(error).toBeInTheDocument();
17
- expect(error).toHaveTextContent("test");
18
- });
19
-
20
- it("should is disabled", () => {
21
- render(<Input disabled data-testid="input" />);
22
- const input = screen.getByTestId("input");
23
- expect(input).toBeDisabled();
24
- });
25
-
26
- it("should is required", () => {
27
- render(<Input required data-testid="input" label="test" />);
28
- const label = screen.getByTestId("input-label");
29
- expect(label).toHaveTextContent("test *");
30
- });
31
-
32
- it("should change value", () => {
33
- render(<Input data-testid="input" />);
34
- const input = screen.getByTestId("input");
35
- fireEvent.change(input, { target: { value: "test" } });
36
- expect(input).toHaveValue("test");
37
- });
38
- });
@@ -1,48 +0,0 @@
1
- import { Input as InputUI } from "@/components/ui/input";
2
- import { InputProps } from "./types";
3
- import { useMemo } from "react";
4
- import { InputBase } from "../InputBase";
5
- import { useConditionalController } from "@/hooks/use-conditional-controller";
6
- import { cn } from "@/lib/utils";
7
-
8
- export const Input = ({
9
- "data-testid": dataTestId,
10
- withoutForm = false,
11
- extraElement,
12
- containerClassName,
13
- ...props
14
- }: InputProps) => {
15
- const formData = useConditionalController({
16
- name: props.name || "",
17
- withoutForm,
18
- });
19
-
20
- const inputProps = useMemo(() => {
21
- return {
22
- ...formData,
23
- ...props,
24
- };
25
- }, [formData, props]);
26
-
27
- return (
28
- <InputBase
29
- label={props.label}
30
- error={props.error}
31
- required={props.required}
32
- data-testid={dataTestId}
33
- >
34
- <div className={cn("flex items-center gap-2", containerClassName)}>
35
- <InputUI
36
- {...inputProps}
37
- data-testid={dataTestId}
38
- className={cn(
39
- props.className,
40
- props.error &&
41
- "border-destructive focus:border-destructive focus-visible:ring-0"
42
- )}
43
- />
44
- {extraElement}
45
- </div>
46
- </InputBase>
47
- );
48
- };
@@ -1,15 +0,0 @@
1
- import { InputBaseProps } from "./InputBase";
2
-
3
- export type InputProps = Omit<InputBaseProps, "children"> & {
4
- component?: React.ReactNode;
5
- error?: string;
6
- withoutForm?: boolean;
7
- label?: string;
8
- leftIcon?: React.ReactNode;
9
- rightIcon?: React.ReactNode;
10
- helperText?: string;
11
- floatingLabel?: boolean;
12
- "data-testid"?: string;
13
- extraElement?: React.ReactNode;
14
- containerClassName?: string;
15
- };
@@ -1,31 +0,0 @@
1
- import { ErrorLabel } from "@/components/feedback/ErrorLabel";
2
- import { InputProps as InputPropsUI } from "../../../../ui/input";
3
- import { Label } from "../../../../ui/label";
4
-
5
- export type InputBaseProps = Omit<InputPropsUI, "children"> & {
6
- label?: string;
7
- error?: string;
8
- required?: boolean;
9
- children: React.ReactNode;
10
- "data-testid"?: string;
11
- };
12
-
13
- export const InputBase = ({
14
- label,
15
- error,
16
- children,
17
- required,
18
- "data-testid": testId,
19
- }: InputBaseProps) => {
20
- return (
21
- <div>
22
- {label && (
23
- <Label data-testid={`${testId}-label`}>
24
- {`${label} ${required ? "*" : ""}`}{" "}
25
- </Label>
26
- )}
27
- {children}
28
- {error && <ErrorLabel data-testid={testId}>{error}</ErrorLabel>}
29
- </div>
30
- );
31
- };