@phsa.tec/design-system-react 0.1.0
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/.eslintrc.json +7 -0
- package/.storybook/main.ts +16 -0
- package/.storybook/preview.ts +15 -0
- package/README.md +36 -0
- package/components.json +21 -0
- package/jest.config.ts +25 -0
- package/next.config.ts +7 -0
- package/package.json +88 -0
- package/postcss.config.mjs +8 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/src/app/columns.tsx +178 -0
- 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 +94 -0
- package/src/app/layout.tsx +35 -0
- package/src/app/page.tsx +7 -0
- package/src/components/actions/AlertDialog/AlertDialog.tsx +45 -0
- package/src/components/actions/AlertDialog/alert-dialog.stories.tsx +21 -0
- package/src/components/actions/AlertDialog/index.ts +1 -0
- package/src/components/actions/Button/Button.stories.ts +38 -0
- package/src/components/actions/Button/Button.tsx +23 -0
- package/src/components/actions/Button/index.ts +1 -0
- package/src/components/actions/Collapsible/index.ts +1 -0
- package/src/components/actions/Dialog/Dialog.stories.tsx +70 -0
- package/src/components/actions/Dialog/Dialog.tsx +87 -0
- package/src/components/actions/Dialog/components/DialogWithActions/index.tsx +40 -0
- package/src/components/actions/Dialog/index.ts +1 -0
- package/src/components/actions/Steps/Steps.stories.tsx +25 -0
- package/src/components/actions/Steps/Steps.tsx +51 -0
- package/src/components/actions/Steps/index.ts +1 -0
- package/src/components/actions/index.ts +5 -0
- package/src/components/dataDisplay/Avatar/Avatar.stories.tsx +22 -0
- package/src/components/dataDisplay/Avatar/Avatar.tsx +21 -0
- package/src/components/dataDisplay/Avatar/index.ts +2 -0
- package/src/components/dataDisplay/Badge/Badge.stories.tsx +36 -0
- package/src/components/dataDisplay/Badge/index.ts +1 -0
- package/src/components/dataDisplay/Card/Card.stories.tsx +24 -0
- package/src/components/dataDisplay/Card/Card.tsx +34 -0
- package/src/components/dataDisplay/Card/index.ts +1 -0
- package/src/components/dataDisplay/DataPairList/DataPairList.tsx +56 -0
- package/src/components/dataDisplay/DataPairList/data-pair-list.stories.tsx +87 -0
- package/src/components/dataDisplay/DataPairList/index.ts +2 -0
- package/src/components/dataDisplay/DataPairList/types.ts +10 -0
- package/src/components/dataDisplay/DropDownMenu/index.ts +1 -0
- package/src/components/dataDisplay/ErrorMessage/ErrorMessage.tsx +6 -0
- package/src/components/dataDisplay/ErrorMessage/index.ts +1 -0
- package/src/components/dataDisplay/Icon/Icon.stories.tsx +21 -0
- package/src/components/dataDisplay/Icon/Icon.tsx +47 -0
- package/src/components/dataDisplay/Icon/index.ts +1 -0
- package/src/components/dataDisplay/Icon/types.ts +6 -0
- package/src/components/dataDisplay/Label/Label.stories.tsx +21 -0
- package/src/components/dataDisplay/Label/Label.tsx +10 -0
- package/src/components/dataDisplay/Label/index.ts +1 -0
- package/src/components/dataDisplay/Table/Table.tsx +173 -0
- package/src/components/dataDisplay/Table/columns.tsx +223 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx +72 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-pagination.tsx +91 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-toolbar.tsx +17 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx +58 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table.stories.tsx +118 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/index.tsx +136 -0
- package/src/components/dataDisplay/Table/components/DynamicTable/types.ts +43 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-column-header.tsx +71 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-faceted-filter.tsx +147 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-pagination.tsx +97 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-row-actions.tsx +78 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-toolbar.tsx +60 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-view-options.tsx +59 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table.tsx +145 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/data.ts +71 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/index.tsx +34 -0
- package/src/components/dataDisplay/Table/custom/CustomTable/schema.ts +11 -0
- package/src/components/dataDisplay/Table/index.ts +2 -0
- package/src/components/dataDisplay/Table/table.stories.tsx +147 -0
- package/src/components/dataDisplay/Table/types.ts +15 -0
- package/src/components/dataDisplay/Tabs/Tabs.stories.tsx +34 -0
- package/src/components/dataDisplay/Tabs/Tabs.tsx +53 -0
- package/src/components/dataDisplay/Tabs/index.ts +1 -0
- package/src/components/dataDisplay/Text/Text.stories.tsx +66 -0
- package/src/components/dataDisplay/Text/Text.tsx +56 -0
- package/src/components/dataDisplay/Text/index.ts +1 -0
- package/src/components/dataDisplay/index.ts +8 -0
- package/src/components/dataInput/Input/components/Input/Input.stories.tsx +99 -0
- package/src/components/dataInput/Input/components/Input/InputBase.tsx +50 -0
- package/src/components/dataInput/Input/components/Input/__tests__/Input.test.tsx +100 -0
- package/src/components/dataInput/Input/components/Input/index.tsx +257 -0
- package/src/components/dataInput/Input/components/InputBase/__tests__/InputBase.test.tsx +120 -0
- package/src/components/dataInput/Input/components/InputBase/index.tsx +89 -0
- package/src/components/dataInput/Input/components/MaskInput/__tests__/mask-input.test.tsx +67 -0
- package/src/components/dataInput/Input/components/MaskInput/index.ts +1 -0
- package/src/components/dataInput/Input/components/MaskInput/mask-input.stories.tsx +59 -0
- package/src/components/dataInput/Input/components/MaskInput/mask-input.tsx +43 -0
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInput.tsx +36 -0
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInputBase.tsx +100 -0
- package/src/components/dataInput/Input/components/MultipleInput/MultipleMaskInput.tsx +35 -0
- package/src/components/dataInput/Input/components/MultipleInput/MultipleNumberInput.tsx +35 -0
- package/src/components/dataInput/Input/components/MultipleInput/index.ts +2 -0
- package/src/components/dataInput/Input/components/MultipleInput/multiple-input.stories.tsx +71 -0
- package/src/components/dataInput/Input/components/NumberInput/__tests__/number-input.test.tsx +95 -0
- package/src/components/dataInput/Input/components/NumberInput/index.ts +1 -0
- package/src/components/dataInput/Input/components/NumberInput/number-input.stories.tsx +76 -0
- package/src/components/dataInput/Input/components/NumberInput/number-input.tsx +68 -0
- package/src/components/dataInput/Input/index.ts +4 -0
- package/src/components/dataInput/Select/MultiSelect/MultiSelect.stories.tsx +119 -0
- package/src/components/dataInput/Select/MultiSelect/MultiSelectBase.tsx +135 -0
- package/src/components/dataInput/Select/MultiSelect/index.tsx +75 -0
- package/src/components/dataInput/Select/Select.stories.tsx +61 -0
- package/src/components/dataInput/Select/Select.tsx +73 -0
- package/src/components/dataInput/Select/SelectBase.tsx +58 -0
- package/src/components/dataInput/Select/index.ts +2 -0
- package/src/components/dataInput/Switch/Switch.stories.tsx +75 -0
- package/src/components/dataInput/Switch/Switch.tsx +52 -0
- package/src/components/dataInput/Switch/index.ts +1 -0
- package/src/components/dataInput/checkbox/Checkbox.tsx +57 -0
- package/src/components/dataInput/checkbox/Checkbox_old.tsx +58 -0
- package/src/components/dataInput/checkbox/Checkout.stories.tsx +62 -0
- package/src/components/dataInput/checkbox/index.ts +1 -0
- package/src/components/dataInput/form/Form.tsx +47 -0
- package/src/components/dataInput/form/index.ts +3 -0
- package/src/components/dataInput/index.ts +5 -0
- package/src/components/feedback/Spinner/index.ts +1 -0
- package/src/components/feedback/Toast/Toast.stories.tsx +45 -0
- package/src/components/feedback/Toast/index.ts +2 -0
- package/src/components/feedback/index.ts +2 -0
- package/src/components/index.ts +6 -0
- package/src/components/layout/Crud/components/Table/index.tsx +183 -0
- package/src/components/layout/Crud/components/Table/types.ts +15 -0
- package/src/components/layout/Crud/crud.stories.tsx +317 -0
- package/src/components/layout/Crud/hook/useCrudLayout/index.tsx +94 -0
- package/src/components/layout/Crud/hook/useRequest/index.tsx +156 -0
- package/src/components/layout/Crud/index.tsx +295 -0
- package/src/components/layout/Crud/store/CrudLayoutStore.ts +75 -0
- package/src/components/layout/Crud/types.ts +14 -0
- package/src/components/layout/Drawer/CustomDrawer/index.tsx +33 -0
- package/src/components/layout/Drawer/Drawer.stories.tsx +80 -0
- package/src/components/layout/Drawer/index.ts +2 -0
- package/src/components/layout/PageLayout/PageLayout.stories.tsx +42 -0
- package/src/components/layout/PageLayout/index.tsx +28 -0
- package/src/components/layout/Separator/index.ts +1 -0
- package/src/components/layout/Sheet/Sheet.stories.tsx +28 -0
- package/src/components/layout/Sheet/Sheet.tsx +22 -0
- package/src/components/layout/Sheet/index.ts +1 -0
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +116 -0
- package/src/components/layout/Sidebar/Sidebar.tsx +50 -0
- package/src/components/layout/Sidebar/components/app-sidebar.tsx +203 -0
- package/src/components/layout/Sidebar/components/footer-sidebar.tsx +17 -0
- package/src/components/layout/Sidebar/components/header-sidebar.tsx +90 -0
- package/src/components/layout/Sidebar/components/menus.tsx +55 -0
- package/src/components/layout/Sidebar/components/nav-projects.tsx +88 -0
- package/src/components/layout/Sidebar/components/nav-user.tsx +114 -0
- package/src/components/layout/Sidebar/components/team-switcher.tsx +85 -0
- package/src/components/layout/Sidebar/index.ts +2 -0
- package/src/components/layout/Sidebar/provider/index.tsx +51 -0
- package/src/components/layout/Tabs/Tabs.tsx +51 -0
- package/src/components/layout/Tabs/index.ts +1 -0
- package/src/components/layout/Tabs/tabs.stories.tsx +57 -0
- package/src/components/layout/index.ts +6 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +66 -0
- package/src/components/navigation/Breadcrumbs/index.ts +2 -0
- package/src/components/navigation/index.ts +1 -0
- package/src/components/ui/alert-dialog.tsx +141 -0
- package/src/components/ui/alert.tsx +59 -0
- package/src/components/ui/avatar.tsx +50 -0
- package/src/components/ui/badge.tsx +40 -0
- package/src/components/ui/breadcrumb.tsx +115 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/card.tsx +83 -0
- package/src/components/ui/checkbox.tsx +34 -0
- package/src/components/ui/collapsible.tsx +11 -0
- package/src/components/ui/command.tsx +153 -0
- package/src/components/ui/dialog.tsx +124 -0
- package/src/components/ui/drawer.tsx +117 -0
- package/src/components/ui/dropdown-menu.tsx +201 -0
- package/src/components/ui/form.tsx +179 -0
- package/src/components/ui/input.tsx +24 -0
- package/src/components/ui/label.tsx +30 -0
- package/src/components/ui/popover.tsx +33 -0
- package/src/components/ui/select.tsx +161 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/sheet.tsx +140 -0
- package/src/components/ui/sidebar.tsx +763 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/sonner.tsx +31 -0
- package/src/components/ui/spinner.tsx +54 -0
- package/src/components/ui/switch.tsx +33 -0
- package/src/components/ui/table.tsx +120 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/toast.tsx +130 -0
- package/src/components/ui/toaster.tsx +35 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/hooks/use-toast.ts +191 -0
- package/src/index.ts +1 -0
- package/src/lib/utils.ts +6 -0
- package/tailwind.config.ts +83 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { fn } from "storybook/test";
|
|
3
|
+
|
|
4
|
+
import { Button } from "./index";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Action/Button",
|
|
8
|
+
component: Button,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
options: [
|
|
15
|
+
"primary",
|
|
16
|
+
"secondary",
|
|
17
|
+
"destructive",
|
|
18
|
+
"outline",
|
|
19
|
+
"ghost",
|
|
20
|
+
"link",
|
|
21
|
+
],
|
|
22
|
+
control: {
|
|
23
|
+
type: "select",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
tags: ["autodocs"],
|
|
28
|
+
args: { onClick: fn() },
|
|
29
|
+
} satisfies Meta<typeof Button>;
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
type Story = StoryObj<typeof meta>;
|
|
33
|
+
|
|
34
|
+
export const Default: Story = {
|
|
35
|
+
args: {
|
|
36
|
+
children: "Button",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Spinner } from "../../../components/feedback";
|
|
3
|
+
import {
|
|
4
|
+
Button as UIButton,
|
|
5
|
+
ButtonProps as UIButtonProps,
|
|
6
|
+
} from "../../ui/button";
|
|
7
|
+
|
|
8
|
+
export type ButtonProps = UIButtonProps & {
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
13
|
+
({ children, disabled, loading, ...rest }, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<UIButton {...rest} disabled={disabled || loading} ref={ref}>
|
|
16
|
+
{loading && <Spinner className="fill-white" />}
|
|
17
|
+
{children}
|
|
18
|
+
</UIButton>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
Button.displayName = "Button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../ui/collapsible";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { DialogWithActions as DialogWithActionsComponent } from "./components/DialogWithActions";
|
|
3
|
+
import { Dialog } from "./Dialog";
|
|
4
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
5
|
+
import { Label } from "@/components/dataDisplay/Label";
|
|
6
|
+
import { Input } from "@/components/dataInput";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Action/Dialog",
|
|
10
|
+
component: Dialog,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
} satisfies Meta<typeof Dialog>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
title: "Dialog Title",
|
|
24
|
+
description: "Dialog Description",
|
|
25
|
+
footer: () => <button>Footer Button</button>,
|
|
26
|
+
},
|
|
27
|
+
render: (props) => {
|
|
28
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
<button onClick={() => setOpen(true)}>Open Dialog</button>
|
|
32
|
+
<Dialog {...props} open={open} onOpenChange={setOpen}>
|
|
33
|
+
This action cannot be undone. This will permanently delete your
|
|
34
|
+
account and remove your data from our servers.
|
|
35
|
+
</Dialog>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const DialogWithActions: Story = {
|
|
42
|
+
render: (args) => {
|
|
43
|
+
return (
|
|
44
|
+
<DialogWithActionsComponent {...args}>
|
|
45
|
+
<div className="grid gap-4 py-4">
|
|
46
|
+
<div className="grid grid-cols-4 items-center gap-4">
|
|
47
|
+
<Label htmlFor="name" className="text-right">
|
|
48
|
+
Name
|
|
49
|
+
</Label>
|
|
50
|
+
<Input
|
|
51
|
+
id="name"
|
|
52
|
+
defaultValue="Pedro Duarte"
|
|
53
|
+
className="col-span-3"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
<div className="grid grid-cols-4 items-center gap-4">
|
|
57
|
+
<Label htmlFor="username" className="text-right">
|
|
58
|
+
Username
|
|
59
|
+
</Label>
|
|
60
|
+
<Input
|
|
61
|
+
id="username"
|
|
62
|
+
defaultValue="@peduarte"
|
|
63
|
+
className="col-span-3"
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</DialogWithActionsComponent>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Dialog as DialogComponent,
|
|
4
|
+
DialogContent,
|
|
5
|
+
DialogDescription,
|
|
6
|
+
DialogFooter,
|
|
7
|
+
DialogHeader,
|
|
8
|
+
DialogTitle,
|
|
9
|
+
DialogProps as DialogComponentProps,
|
|
10
|
+
DialogClose,
|
|
11
|
+
} from "../../../components/ui/dialog";
|
|
12
|
+
import { PropsWithChildren, useRef } from "react";
|
|
13
|
+
import { Button } from "../Button";
|
|
14
|
+
|
|
15
|
+
export type DialogProps = DialogComponentProps &
|
|
16
|
+
PropsWithChildren & {
|
|
17
|
+
className?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
footer?: () => React.ReactNode;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function Dialog({
|
|
24
|
+
title,
|
|
25
|
+
description,
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
footer = () => null,
|
|
29
|
+
...props
|
|
30
|
+
}: DialogProps) {
|
|
31
|
+
return (
|
|
32
|
+
<DialogComponent {...props}>
|
|
33
|
+
<DialogContent className={className}>
|
|
34
|
+
<DialogHeader>
|
|
35
|
+
{title && <DialogTitle>{title}</DialogTitle>}
|
|
36
|
+
{description && <DialogDescription>{description}</DialogDescription>}
|
|
37
|
+
</DialogHeader>
|
|
38
|
+
{children}
|
|
39
|
+
{footer && <DialogFooter>{footer()}</DialogFooter>}
|
|
40
|
+
</DialogContent>
|
|
41
|
+
</DialogComponent>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type DialogWithFormProps = DialogProps & {
|
|
46
|
+
onSubmit: () => void;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const DialogWithForm = ({
|
|
50
|
+
title,
|
|
51
|
+
description,
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
footer = () => null,
|
|
55
|
+
onSubmit = () => {},
|
|
56
|
+
...props
|
|
57
|
+
}: DialogWithFormProps) => {
|
|
58
|
+
const dialogRef = useRef<HTMLDivElement>(null);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<DialogComponent {...props}>
|
|
62
|
+
<DialogContent className={className} ref={dialogRef}>
|
|
63
|
+
<form onSubmit={onSubmit} className="flex flex-col gap-4">
|
|
64
|
+
<DialogHeader>
|
|
65
|
+
{title && <DialogTitle>{title}</DialogTitle>}
|
|
66
|
+
{description && (
|
|
67
|
+
<DialogDescription>{description}</DialogDescription>
|
|
68
|
+
)}
|
|
69
|
+
</DialogHeader>
|
|
70
|
+
{children}
|
|
71
|
+
{footer && (
|
|
72
|
+
<DialogFooter>
|
|
73
|
+
<div className="flex justify-between w-full">
|
|
74
|
+
<DialogClose asChild>
|
|
75
|
+
<Button type="button" variant="secondary">
|
|
76
|
+
Fechar
|
|
77
|
+
</Button>
|
|
78
|
+
</DialogClose>
|
|
79
|
+
{footer()}
|
|
80
|
+
</div>
|
|
81
|
+
</DialogFooter>
|
|
82
|
+
)}
|
|
83
|
+
</form>
|
|
84
|
+
</DialogContent>
|
|
85
|
+
</DialogComponent>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../../../../../components/ui/button";
|
|
3
|
+
import {
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogDescription,
|
|
7
|
+
DialogFooter,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
DialogTrigger,
|
|
11
|
+
} from "../../../../../components/ui/dialog";
|
|
12
|
+
|
|
13
|
+
type DialogWithActionsProps = React.PropsWithChildren & {
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function DialogWithActions({
|
|
19
|
+
children,
|
|
20
|
+
title = "Edit profile",
|
|
21
|
+
description = "Make changes to your profile here. Click save when you're done.",
|
|
22
|
+
}: DialogWithActionsProps) {
|
|
23
|
+
return (
|
|
24
|
+
<Dialog>
|
|
25
|
+
<DialogTrigger asChild>
|
|
26
|
+
<Button variant="outline">Edit Profile</Button>
|
|
27
|
+
</DialogTrigger>
|
|
28
|
+
<DialogContent className="sm:max-w-[425px]">
|
|
29
|
+
<DialogHeader>
|
|
30
|
+
<DialogTitle>{title}</DialogTitle>
|
|
31
|
+
<DialogDescription>{description}</DialogDescription>
|
|
32
|
+
</DialogHeader>
|
|
33
|
+
{children}
|
|
34
|
+
<DialogFooter>
|
|
35
|
+
<Button type="submit">Save changes</Button>
|
|
36
|
+
</DialogFooter>
|
|
37
|
+
</DialogContent>
|
|
38
|
+
</Dialog>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Dialog";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { fn } from "storybook/test";
|
|
3
|
+
|
|
4
|
+
import { Steps } from "./Steps";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Action/Steps",
|
|
8
|
+
component: Steps,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
argTypes: {},
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
args: { onClick: fn() },
|
|
15
|
+
} satisfies Meta<typeof Steps>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
data: [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }],
|
|
23
|
+
value: 3,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Icon } from "../../../components/dataDisplay";
|
|
4
|
+
import { Separator } from "../../../components/layout";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
|
|
7
|
+
type StepsProps = {
|
|
8
|
+
data: {
|
|
9
|
+
label?: string;
|
|
10
|
+
id: number;
|
|
11
|
+
}[];
|
|
12
|
+
onClick?: (id: number) => void;
|
|
13
|
+
value?: number;
|
|
14
|
+
};
|
|
15
|
+
export const Steps = ({ data, onClick = () => {}, value }: StepsProps) => {
|
|
16
|
+
const renderSteps = useCallback(() => {
|
|
17
|
+
return data.map(({ label, id }, index) => {
|
|
18
|
+
const isLast = index === data.length - 1;
|
|
19
|
+
const isActive = typeof value === "number" && id <= value;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div key={index} className={cn(!isLast && "w-full flex items-center")}>
|
|
23
|
+
<div>
|
|
24
|
+
<Button
|
|
25
|
+
onClick={() => onClick && onClick(id)}
|
|
26
|
+
variant={isActive ? "default" : "outline"}
|
|
27
|
+
size="icon"
|
|
28
|
+
className="rounded-full"
|
|
29
|
+
>
|
|
30
|
+
{isActive ? <Icon name="MdCheck" /> : index + 1}
|
|
31
|
+
</Button>
|
|
32
|
+
</div>
|
|
33
|
+
{label && <p className="absolute">{label}</p>}
|
|
34
|
+
{!isLast && (
|
|
35
|
+
<Separator
|
|
36
|
+
orientation="horizontal"
|
|
37
|
+
className={cn(isActive && "bg-primary h-[2px]")}
|
|
38
|
+
/>
|
|
39
|
+
)}
|
|
40
|
+
{/* {
|
|
41
|
+
<Separator
|
|
42
|
+
orientation="horizontal"
|
|
43
|
+
className={cn("bg-primary h-[2px]")}
|
|
44
|
+
/>
|
|
45
|
+
} */}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
}, [data, onClick, value]);
|
|
50
|
+
return <div className="flex w-full">{renderSteps()}</div>;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Steps";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { Avatar } from "./Avatar";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "DataDisplay/Avatar",
|
|
6
|
+
component: Avatar,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof Avatar>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
src: "https://github.com/shadcn.png",
|
|
19
|
+
alt: "Avatar",
|
|
20
|
+
avatarFallback: "A",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar as AvatarComponent,
|
|
3
|
+
AvatarFallback,
|
|
4
|
+
AvatarImage,
|
|
5
|
+
} from "../../../components/ui/avatar";
|
|
6
|
+
|
|
7
|
+
type AvatarProps = {
|
|
8
|
+
src: string;
|
|
9
|
+
alt: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
avatarFallback: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function Avatar({ src, alt, className, avatarFallback }: AvatarProps) {
|
|
15
|
+
return (
|
|
16
|
+
<AvatarComponent>
|
|
17
|
+
<AvatarImage src={src} alt={alt} className={className} />
|
|
18
|
+
<AvatarFallback>{avatarFallback}</AvatarFallback>
|
|
19
|
+
</AvatarComponent>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { Badge } from "./index";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "DataDisplay/Badge",
|
|
6
|
+
component: Badge,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof Badge>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
argTypes: {
|
|
18
|
+
variant: {
|
|
19
|
+
control: {
|
|
20
|
+
type: "select",
|
|
21
|
+
},
|
|
22
|
+
options: [
|
|
23
|
+
"default",
|
|
24
|
+
"primary",
|
|
25
|
+
"secondary",
|
|
26
|
+
"success",
|
|
27
|
+
"warning",
|
|
28
|
+
"destructive",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
args: {
|
|
33
|
+
children: "Badge",
|
|
34
|
+
variant: "default",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../ui/badge";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
|
|
3
|
+
import { Card } from "./index";
|
|
4
|
+
import { Button } from "../../../components/actions";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "DataDisplay/Card",
|
|
8
|
+
component: Card,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
} satisfies Meta<typeof Card>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
title: "Card title",
|
|
21
|
+
description: "Card description",
|
|
22
|
+
footer: () => <Button>Card footer</Button>,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Card as CardComponent,
|
|
4
|
+
CardContent,
|
|
5
|
+
CardDescription,
|
|
6
|
+
CardFooter,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
} from "../../../components/ui/card";
|
|
10
|
+
|
|
11
|
+
export type CardProps = {
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
footer?: () => React.ReactNode | JSX.Element;
|
|
15
|
+
children?: React.ReactNode | JSX.Element;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const Card = ({
|
|
19
|
+
title,
|
|
20
|
+
children,
|
|
21
|
+
description,
|
|
22
|
+
footer = () => <></>,
|
|
23
|
+
}: CardProps) => {
|
|
24
|
+
return (
|
|
25
|
+
<CardComponent>
|
|
26
|
+
<CardHeader>
|
|
27
|
+
{title && <CardTitle>{title}</CardTitle>}
|
|
28
|
+
{description && <CardDescription>{description}</CardDescription>}
|
|
29
|
+
</CardHeader>
|
|
30
|
+
{children && <CardContent>{children}</CardContent>}
|
|
31
|
+
{footer && <CardFooter>{footer()}</CardFooter>}
|
|
32
|
+
</CardComponent>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Card";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { isEmpty } from "lodash";
|
|
3
|
+
import { DataPairListProps } from "./types";
|
|
4
|
+
import { cn } from "../../../lib/utils";
|
|
5
|
+
import { Text } from "../Text";
|
|
6
|
+
|
|
7
|
+
export const DataPairList = ({
|
|
8
|
+
title,
|
|
9
|
+
data,
|
|
10
|
+
labels,
|
|
11
|
+
className,
|
|
12
|
+
infoDirection = "horizontal",
|
|
13
|
+
direction = "vertical",
|
|
14
|
+
withBorder = false,
|
|
15
|
+
header = <></>,
|
|
16
|
+
}: DataPairListProps) => {
|
|
17
|
+
if (isEmpty(data)) return null;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
className={cn(
|
|
22
|
+
"flex flex-col gap-2 rounded-md p-4",
|
|
23
|
+
withBorder && "border border-muted",
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
>
|
|
27
|
+
<div className="flex gap-3">
|
|
28
|
+
{title && <Text variant="title">{title}</Text>}
|
|
29
|
+
{header}
|
|
30
|
+
</div>
|
|
31
|
+
<div
|
|
32
|
+
className={cn(
|
|
33
|
+
"grid grid-cols-1 mt-5",
|
|
34
|
+
direction === "vertical"
|
|
35
|
+
? "gap-3"
|
|
36
|
+
: "sm:grid-cols-2 md:grid-cols-4 gap-10"
|
|
37
|
+
)}
|
|
38
|
+
>
|
|
39
|
+
{Object.entries(data || {}).map(([key, value], index) => (
|
|
40
|
+
<div
|
|
41
|
+
className={cn(
|
|
42
|
+
"flex gap-3",
|
|
43
|
+
infoDirection === "horizontal" ? "flex-row" : "flex-col"
|
|
44
|
+
)}
|
|
45
|
+
key={index}
|
|
46
|
+
>
|
|
47
|
+
<Text className="uppercase text-muted-foreground font-bold">
|
|
48
|
+
{labels?.[key] || key}:
|
|
49
|
+
</Text>
|
|
50
|
+
<Text>{value}</Text>
|
|
51
|
+
</div>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
+
import { DataPairList } from ".";
|
|
3
|
+
import { Button } from "@/components/actions";
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "DataDisplay/DataPairList",
|
|
7
|
+
component: DataPairList,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
},
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
} satisfies Meta<typeof DataPairList>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof meta>;
|
|
16
|
+
|
|
17
|
+
export const Default: Story = {
|
|
18
|
+
args: {
|
|
19
|
+
title: "Informações Pessoais",
|
|
20
|
+
data: {
|
|
21
|
+
name: "John Doe",
|
|
22
|
+
age: 30,
|
|
23
|
+
email: "john@example.com",
|
|
24
|
+
phone: "(11) 99999-9999",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const WithLabels: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
title: "Informações Pessoais",
|
|
32
|
+
data: {
|
|
33
|
+
name: "John Doe",
|
|
34
|
+
age: 30,
|
|
35
|
+
email: "john@example.com",
|
|
36
|
+
phone: "(11) 99999-9999",
|
|
37
|
+
},
|
|
38
|
+
labels: {
|
|
39
|
+
name: "Nome",
|
|
40
|
+
age: "Idade",
|
|
41
|
+
email: "E-mail",
|
|
42
|
+
phone: "Telefone",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const WithoutTitle: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
data: {
|
|
50
|
+
name: "John Doe",
|
|
51
|
+
age: 30,
|
|
52
|
+
email: "john@example.com",
|
|
53
|
+
phone: "(11) 99999-9999",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const EmptyData: Story = {
|
|
59
|
+
args: {
|
|
60
|
+
title: "Sem Dados",
|
|
61
|
+
data: {},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const WithHeader: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
title: "Com botão de ação",
|
|
68
|
+
data: {
|
|
69
|
+
name: "John Doe",
|
|
70
|
+
age: 30,
|
|
71
|
+
email: "john@example.com",
|
|
72
|
+
phone: "(11) 99999-9999",
|
|
73
|
+
},
|
|
74
|
+
header: <Button>Editar</Button>,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const WithClassName: Story = {
|
|
79
|
+
args: {
|
|
80
|
+
title: "Com Classe Customizada",
|
|
81
|
+
data: {
|
|
82
|
+
name: "John Doe",
|
|
83
|
+
age: 30,
|
|
84
|
+
},
|
|
85
|
+
className: "bg-slate-100",
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DataPairListProps {
|
|
2
|
+
title?: string;
|
|
3
|
+
data: Record<string, string | number | undefined>;
|
|
4
|
+
labels?: Record<string, string>;
|
|
5
|
+
className?: string;
|
|
6
|
+
infoDirection?: "vertical" | "horizontal";
|
|
7
|
+
direction?: "vertical" | "horizontal";
|
|
8
|
+
withBorder?: boolean;
|
|
9
|
+
header?: React.ReactNode;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../ui/dropdown-menu";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ErrorMessage";
|