@phsa.tec/design-system-react 0.1.6 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +390 -209
- package/dist/index.d.mts +485 -0
- package/dist/index.d.ts +485 -0
- package/dist/index.js +4259 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4186 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2534 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.mts +2 -0
- package/dist/styles.d.ts +2 -0
- package/package.json +46 -6
- package/.eslintrc.json +0 -7
- package/.github/workflows/deploy-storybook.yml +0 -75
- package/.storybook/main.ts +0 -16
- package/.storybook/preview.ts +0 -15
- package/components.json +0 -21
- package/jest.config.ts +0 -25
- package/next.config.ts +0 -7
- package/postcss.config.mjs +0 -8
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/src/app/columns.tsx +0 -178
- package/src/app/favicon.ico +0 -0
- package/src/app/fonts/GeistMonoVF.woff +0 -0
- package/src/app/fonts/GeistVF.woff +0 -0
- package/src/app/globals.css +0 -94
- package/src/app/layout.tsx +0 -35
- package/src/app/page.tsx +0 -7
- package/src/components/actions/AlertDialog/AlertDialog.tsx +0 -45
- package/src/components/actions/AlertDialog/alert-dialog.stories.tsx +0 -21
- package/src/components/actions/AlertDialog/index.ts +0 -1
- package/src/components/actions/Button/Button.stories.ts +0 -38
- package/src/components/actions/Button/Button.tsx +0 -23
- package/src/components/actions/Button/index.ts +0 -1
- package/src/components/actions/Collapsible/index.ts +0 -1
- package/src/components/actions/Dialog/Dialog.stories.tsx +0 -70
- package/src/components/actions/Dialog/Dialog.tsx +0 -87
- package/src/components/actions/Dialog/components/DialogWithActions/index.tsx +0 -40
- package/src/components/actions/Dialog/index.ts +0 -1
- package/src/components/actions/Steps/Steps.stories.tsx +0 -25
- package/src/components/actions/Steps/Steps.tsx +0 -51
- package/src/components/actions/Steps/index.ts +0 -1
- package/src/components/actions/index.ts +0 -5
- package/src/components/dataDisplay/Avatar/Avatar.stories.tsx +0 -22
- package/src/components/dataDisplay/Avatar/Avatar.tsx +0 -21
- package/src/components/dataDisplay/Avatar/index.ts +0 -2
- package/src/components/dataDisplay/Badge/Badge.stories.tsx +0 -36
- package/src/components/dataDisplay/Badge/index.ts +0 -1
- package/src/components/dataDisplay/Card/Card.stories.tsx +0 -24
- package/src/components/dataDisplay/Card/Card.tsx +0 -34
- package/src/components/dataDisplay/Card/index.ts +0 -1
- package/src/components/dataDisplay/DataPairList/DataPairList.tsx +0 -56
- package/src/components/dataDisplay/DataPairList/data-pair-list.stories.tsx +0 -87
- package/src/components/dataDisplay/DataPairList/index.ts +0 -2
- package/src/components/dataDisplay/DataPairList/types.ts +0 -10
- package/src/components/dataDisplay/DropDownMenu/index.ts +0 -1
- package/src/components/dataDisplay/ErrorMessage/ErrorMessage.tsx +0 -6
- package/src/components/dataDisplay/ErrorMessage/index.ts +0 -1
- package/src/components/dataDisplay/Icon/Icon.stories.tsx +0 -21
- package/src/components/dataDisplay/Icon/Icon.tsx +0 -47
- package/src/components/dataDisplay/Icon/index.ts +0 -1
- package/src/components/dataDisplay/Icon/types.ts +0 -6
- package/src/components/dataDisplay/Label/Label.stories.tsx +0 -21
- package/src/components/dataDisplay/Label/Label.tsx +0 -10
- package/src/components/dataDisplay/Label/index.ts +0 -1
- package/src/components/dataDisplay/Table/Table.tsx +0 -173
- package/src/components/dataDisplay/Table/columns.tsx +0 -223
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx +0 -72
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-pagination.tsx +0 -91
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-toolbar.tsx +0 -17
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx +0 -58
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table.stories.tsx +0 -118
- package/src/components/dataDisplay/Table/components/DynamicTable/index.tsx +0 -136
- package/src/components/dataDisplay/Table/components/DynamicTable/types.ts +0 -43
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-column-header.tsx +0 -71
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-faceted-filter.tsx +0 -147
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-pagination.tsx +0 -97
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-row-actions.tsx +0 -78
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-toolbar.tsx +0 -60
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-view-options.tsx +0 -59
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table.tsx +0 -145
- package/src/components/dataDisplay/Table/custom/CustomTable/data.ts +0 -71
- package/src/components/dataDisplay/Table/custom/CustomTable/index.tsx +0 -34
- package/src/components/dataDisplay/Table/custom/CustomTable/schema.ts +0 -11
- package/src/components/dataDisplay/Table/index.ts +0 -2
- package/src/components/dataDisplay/Table/table.stories.tsx +0 -147
- package/src/components/dataDisplay/Table/types.ts +0 -15
- package/src/components/dataDisplay/Tabs/Tabs.stories.tsx +0 -34
- package/src/components/dataDisplay/Tabs/Tabs.tsx +0 -53
- package/src/components/dataDisplay/Tabs/index.ts +0 -1
- package/src/components/dataDisplay/Text/Text.stories.tsx +0 -66
- package/src/components/dataDisplay/Text/Text.tsx +0 -56
- package/src/components/dataDisplay/Text/index.ts +0 -1
- package/src/components/dataDisplay/index.ts +0 -8
- package/src/components/dataInput/Input/components/Input/Input.stories.tsx +0 -99
- package/src/components/dataInput/Input/components/Input/InputBase.tsx +0 -50
- package/src/components/dataInput/Input/components/Input/__tests__/input.test.tsx +0 -38
- package/src/components/dataInput/Input/components/Input/index.tsx +0 -48
- package/src/components/dataInput/Input/components/Input/types.ts +0 -15
- package/src/components/dataInput/Input/components/InputBase/index.tsx +0 -31
- package/src/components/dataInput/Input/components/MaskInput/__tests__/mask-input.test.tsx +0 -77
- package/src/components/dataInput/Input/components/MaskInput/index.ts +0 -1
- package/src/components/dataInput/Input/components/MaskInput/mask-input.stories.tsx +0 -85
- package/src/components/dataInput/Input/components/MaskInput/mask-input.tsx +0 -73
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInput.tsx +0 -105
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInputBase.tsx +0 -100
- package/src/components/dataInput/Input/components/MultipleInput/MultipleMaskInput.tsx +0 -35
- package/src/components/dataInput/Input/components/MultipleInput/MultipleNumberInput.tsx +0 -35
- package/src/components/dataInput/Input/components/MultipleInput/__tests__/multiple-input.test.tsx +0 -152
- package/src/components/dataInput/Input/components/MultipleInput/index.ts +0 -2
- package/src/components/dataInput/Input/components/MultipleInput/multiple-input.stories.tsx +0 -96
- package/src/components/dataInput/Input/components/NumberInput/__tests__/number-input.test.tsx +0 -175
- package/src/components/dataInput/Input/components/NumberInput/index.ts +0 -1
- package/src/components/dataInput/Input/components/NumberInput/number-input.stories.tsx +0 -76
- package/src/components/dataInput/Input/components/NumberInput/number-input.tsx +0 -70
- package/src/components/dataInput/Input/index.ts +0 -4
- package/src/components/dataInput/Select/MultiSelect/MultiSelect.stories.tsx +0 -119
- package/src/components/dataInput/Select/MultiSelect/MultiSelectBase.tsx +0 -135
- package/src/components/dataInput/Select/MultiSelect/index.tsx +0 -75
- package/src/components/dataInput/Select/Select.stories.tsx +0 -61
- package/src/components/dataInput/Select/Select.tsx +0 -73
- package/src/components/dataInput/Select/SelectBase.tsx +0 -58
- package/src/components/dataInput/Select/index.ts +0 -2
- package/src/components/dataInput/Switch/Switch.stories.tsx +0 -75
- package/src/components/dataInput/Switch/Switch.tsx +0 -52
- package/src/components/dataInput/Switch/index.ts +0 -1
- package/src/components/dataInput/checkbox/Checkbox.tsx +0 -57
- package/src/components/dataInput/checkbox/Checkbox_old.tsx +0 -58
- package/src/components/dataInput/checkbox/Checkout.stories.tsx +0 -62
- package/src/components/dataInput/checkbox/index.ts +0 -1
- package/src/components/dataInput/form/Form.tsx +0 -47
- package/src/components/dataInput/form/index.ts +0 -3
- package/src/components/dataInput/index.ts +0 -5
- package/src/components/feedback/ErrorLabel/index.tsx +0 -24
- package/src/components/feedback/Spinner/index.ts +0 -1
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -45
- package/src/components/feedback/Toast/index.ts +0 -2
- package/src/components/feedback/index.ts +0 -2
- package/src/components/index.ts +0 -6
- package/src/components/layout/Crud/components/Table/index.tsx +0 -183
- package/src/components/layout/Crud/components/Table/types.ts +0 -15
- package/src/components/layout/Crud/crud.stories.tsx +0 -317
- package/src/components/layout/Crud/hook/useCrudLayout/index.tsx +0 -94
- package/src/components/layout/Crud/hook/useRequest/index.tsx +0 -156
- package/src/components/layout/Crud/index.tsx +0 -295
- package/src/components/layout/Crud/store/CrudLayoutStore.ts +0 -75
- package/src/components/layout/Crud/types.ts +0 -14
- package/src/components/layout/Drawer/CustomDrawer/index.tsx +0 -33
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -80
- package/src/components/layout/Drawer/index.ts +0 -2
- package/src/components/layout/PageLayout/PageLayout.stories.tsx +0 -42
- package/src/components/layout/PageLayout/index.tsx +0 -28
- package/src/components/layout/Separator/index.ts +0 -1
- package/src/components/layout/Sheet/Sheet.stories.tsx +0 -28
- package/src/components/layout/Sheet/Sheet.tsx +0 -22
- package/src/components/layout/Sheet/index.ts +0 -1
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -116
- package/src/components/layout/Sidebar/Sidebar.tsx +0 -50
- package/src/components/layout/Sidebar/components/app-sidebar.tsx +0 -203
- package/src/components/layout/Sidebar/components/footer-sidebar.tsx +0 -17
- package/src/components/layout/Sidebar/components/header-sidebar.tsx +0 -90
- package/src/components/layout/Sidebar/components/menus.tsx +0 -55
- package/src/components/layout/Sidebar/components/nav-projects.tsx +0 -88
- package/src/components/layout/Sidebar/components/nav-user.tsx +0 -114
- package/src/components/layout/Sidebar/components/team-switcher.tsx +0 -85
- package/src/components/layout/Sidebar/index.ts +0 -2
- package/src/components/layout/Sidebar/provider/index.tsx +0 -51
- package/src/components/layout/Tabs/Tabs.tsx +0 -51
- package/src/components/layout/Tabs/index.ts +0 -1
- package/src/components/layout/Tabs/tabs.stories.tsx +0 -57
- package/src/components/layout/index.ts +0 -6
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +0 -66
- package/src/components/navigation/Breadcrumbs/index.ts +0 -2
- package/src/components/navigation/index.ts +0 -1
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -59
- package/src/components/ui/avatar.tsx +0 -50
- package/src/components/ui/badge.tsx +0 -40
- package/src/components/ui/breadcrumb.tsx +0 -115
- package/src/components/ui/button.tsx +0 -57
- package/src/components/ui/card.tsx +0 -83
- package/src/components/ui/checkbox.tsx +0 -34
- package/src/components/ui/collapsible.tsx +0 -11
- package/src/components/ui/command.tsx +0 -153
- package/src/components/ui/dialog.tsx +0 -124
- package/src/components/ui/drawer.tsx +0 -117
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/form.tsx +0 -179
- package/src/components/ui/input.tsx +0 -24
- package/src/components/ui/label.tsx +0 -30
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/select.tsx +0 -161
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/sheet.tsx +0 -140
- package/src/components/ui/sidebar.tsx +0 -763
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/spinner.tsx +0 -54
- package/src/components/ui/switch.tsx +0 -33
- package/src/components/ui/table.tsx +0 -120
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/toast.tsx +0 -130
- package/src/components/ui/toaster.tsx +0 -35
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/hooks/use-conditional-controller.tsx +0 -35
- package/src/hooks/use-mask.tsx +0 -116
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/hooks/use-toast.ts +0 -191
- package/src/index.ts +0 -1
- package/src/introduction.mdx +0 -132
- package/src/lib/utils.ts +0 -6
- package/tailwind.config.ts +0 -83
- package/tsconfig.json +0 -27
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Steps";
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../ui/badge";
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Card";
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../ui/dropdown-menu";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ErrorMessage";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
-
|
|
3
|
-
import { Icon } from "./index";
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: "DataDisplay/Icon",
|
|
7
|
-
component: Icon,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: "centered",
|
|
10
|
-
},
|
|
11
|
-
tags: ["autodocs"],
|
|
12
|
-
} satisfies Meta<typeof Icon>;
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
type Story = StoryObj<typeof meta>;
|
|
16
|
-
|
|
17
|
-
export const Default: Story = {
|
|
18
|
-
args: {
|
|
19
|
-
name: "MdHome",
|
|
20
|
-
},
|
|
21
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from "react";
|
|
2
|
-
import { IconContext } from "react-icons";
|
|
3
|
-
import { IconProps } from "./types";
|
|
4
|
-
|
|
5
|
-
export const Icon: React.FC<IconProps> = ({ name, size = 24, ...rest }) => {
|
|
6
|
-
const nameIcon = useMemo(() => name, [name]);
|
|
7
|
-
|
|
8
|
-
const iconsModulePath = useMemo(
|
|
9
|
-
() => ({
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
11
|
-
md: require("react-icons/md"),
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
13
|
-
fa: require("react-icons/fa"),
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
15
|
-
bs: require("react-icons/bs"),
|
|
16
|
-
}),
|
|
17
|
-
[]
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const typeIcon = useMemo(() => {
|
|
21
|
-
const matches = [...nameIcon.matchAll(/[A-Z]/g)];
|
|
22
|
-
return String(
|
|
23
|
-
nameIcon.slice(0, matches[1]?.index) || ""
|
|
24
|
-
).toLocaleLowerCase();
|
|
25
|
-
}, [nameIcon]);
|
|
26
|
-
|
|
27
|
-
const Icon = useCallback(
|
|
28
|
-
(props: typeof rest) => {
|
|
29
|
-
try {
|
|
30
|
-
if (!typeIcon || !nameIcon) return <></>;
|
|
31
|
-
|
|
32
|
-
return iconsModulePath[typeIcon as keyof typeof iconsModulePath][
|
|
33
|
-
nameIcon
|
|
34
|
-
]?.(props);
|
|
35
|
-
} catch {
|
|
36
|
-
return <></>;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
[iconsModulePath, nameIcon, typeIcon]
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<IconContext.Provider value={{ size: String(size) }}>
|
|
44
|
-
<Icon {...rest} />
|
|
45
|
-
</IconContext.Provider>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Icon";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/nextjs";
|
|
2
|
-
|
|
3
|
-
import { Label } from "./index";
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: "DataDisplay/Label",
|
|
7
|
-
component: Label,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: "centered",
|
|
10
|
-
},
|
|
11
|
-
tags: ["autodocs"],
|
|
12
|
-
} satisfies Meta<typeof Label>;
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
type Story = StoryObj<typeof meta>;
|
|
16
|
-
|
|
17
|
-
export const Default: Story = {
|
|
18
|
-
args: {
|
|
19
|
-
children: "Label",
|
|
20
|
-
},
|
|
21
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Label";
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ChevronDown,
|
|
5
|
-
ChevronUp,
|
|
6
|
-
ChevronLeft,
|
|
7
|
-
ChevronRight,
|
|
8
|
-
} from "lucide-react";
|
|
9
|
-
import {
|
|
10
|
-
Table as ShadcnTable,
|
|
11
|
-
TableBody,
|
|
12
|
-
TableCell,
|
|
13
|
-
TableHead,
|
|
14
|
-
TableHeader,
|
|
15
|
-
TableRow,
|
|
16
|
-
} from "@/components/ui/table";
|
|
17
|
-
import { Button } from "@/components/ui/button";
|
|
18
|
-
import {
|
|
19
|
-
ColumnDef,
|
|
20
|
-
SortingState,
|
|
21
|
-
flexRender,
|
|
22
|
-
getCoreRowModel,
|
|
23
|
-
getSortedRowModel,
|
|
24
|
-
getPaginationRowModel,
|
|
25
|
-
useReactTable,
|
|
26
|
-
PaginationState,
|
|
27
|
-
} from "@tanstack/react-table";
|
|
28
|
-
|
|
29
|
-
export interface TableProps<TData> {
|
|
30
|
-
data: TData[];
|
|
31
|
-
columns: ColumnDef<TData, unknown>[];
|
|
32
|
-
pageSize?: number;
|
|
33
|
-
onSortingChange?: (sorting: SortingState) => void;
|
|
34
|
-
sorting?: SortingState;
|
|
35
|
-
onPaginationChange?: (pagination: PaginationState) => void;
|
|
36
|
-
pagination?: PaginationState;
|
|
37
|
-
emptyMessage?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function Table<TData>({
|
|
41
|
-
data,
|
|
42
|
-
columns,
|
|
43
|
-
onSortingChange = () => {},
|
|
44
|
-
sorting = [],
|
|
45
|
-
pagination = { pageIndex: 0, pageSize: 0 },
|
|
46
|
-
onPaginationChange = () => {},
|
|
47
|
-
emptyMessage = "No results.",
|
|
48
|
-
}: TableProps<TData>) {
|
|
49
|
-
const table = useReactTable({
|
|
50
|
-
data,
|
|
51
|
-
columns,
|
|
52
|
-
state: {
|
|
53
|
-
sorting,
|
|
54
|
-
},
|
|
55
|
-
onSortingChange: (sorting) => {
|
|
56
|
-
onSortingChange(sorting as SortingState);
|
|
57
|
-
},
|
|
58
|
-
getCoreRowModel: getCoreRowModel(),
|
|
59
|
-
getSortedRowModel: getSortedRowModel(),
|
|
60
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
61
|
-
onPaginationChange: (pagination) => {
|
|
62
|
-
onPaginationChange(pagination as PaginationState);
|
|
63
|
-
},
|
|
64
|
-
initialState: {
|
|
65
|
-
pagination,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const getSortingIcons = (column: {
|
|
70
|
-
getIsSorted: () => string | false;
|
|
71
|
-
getCanSort: () => boolean;
|
|
72
|
-
}) => {
|
|
73
|
-
const sortDirection = column.getIsSorted();
|
|
74
|
-
|
|
75
|
-
if (!column.getCanSort()) return null;
|
|
76
|
-
|
|
77
|
-
if (sortDirection === "asc") {
|
|
78
|
-
return <ChevronUp className="ml-2 h-4 w-4 inline" />;
|
|
79
|
-
} else if (sortDirection === "desc") {
|
|
80
|
-
return <ChevronDown className="ml-2 h-4 w-4 inline" />;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<div className="ml-2 inline-flex flex-col">
|
|
85
|
-
<ChevronUp className="h-3 w-3" />
|
|
86
|
-
<ChevronDown className="h-3 w-3 -mt-1" />
|
|
87
|
-
</div>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<div className="rounded-md border">
|
|
93
|
-
<ShadcnTable>
|
|
94
|
-
<TableHeader>
|
|
95
|
-
{table.getHeaderGroups().map((headerGroup) => (
|
|
96
|
-
<TableRow key={headerGroup.id}>
|
|
97
|
-
{headerGroup.headers.map((header) => (
|
|
98
|
-
<TableHead key={header.id}>
|
|
99
|
-
{header.isPlaceholder ? null : (
|
|
100
|
-
<div
|
|
101
|
-
className={
|
|
102
|
-
header.column.getCanSort()
|
|
103
|
-
? "cursor-pointer select-none flex items-center"
|
|
104
|
-
: ""
|
|
105
|
-
}
|
|
106
|
-
onClick={header.column.getToggleSortingHandler()}
|
|
107
|
-
>
|
|
108
|
-
{flexRender(
|
|
109
|
-
header.column.columnDef.header,
|
|
110
|
-
header.getContext()
|
|
111
|
-
)}
|
|
112
|
-
{getSortingIcons(header.column)}
|
|
113
|
-
</div>
|
|
114
|
-
)}
|
|
115
|
-
</TableHead>
|
|
116
|
-
))}
|
|
117
|
-
</TableRow>
|
|
118
|
-
))}
|
|
119
|
-
</TableHeader>
|
|
120
|
-
<TableBody>
|
|
121
|
-
{table.getRowModel().rows.length ? (
|
|
122
|
-
table.getRowModel().rows.map((row) => (
|
|
123
|
-
<TableRow key={row.id}>
|
|
124
|
-
{row.getVisibleCells().map((cell) => (
|
|
125
|
-
<TableCell key={cell.id}>
|
|
126
|
-
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
127
|
-
</TableCell>
|
|
128
|
-
))}
|
|
129
|
-
</TableRow>
|
|
130
|
-
))
|
|
131
|
-
) : (
|
|
132
|
-
<TableRow>
|
|
133
|
-
<TableCell colSpan={columns.length} className="h-24 text-center">
|
|
134
|
-
{emptyMessage}
|
|
135
|
-
</TableCell>
|
|
136
|
-
</TableRow>
|
|
137
|
-
)}
|
|
138
|
-
</TableBody>
|
|
139
|
-
</ShadcnTable>
|
|
140
|
-
|
|
141
|
-
<div className="flex items-center justify-end space-x-2 py-4 px-4 border-t">
|
|
142
|
-
<div className="flex-1 text-sm text-muted-foreground">
|
|
143
|
-
{table.getFilteredRowModel().rows.length} row(s) total
|
|
144
|
-
</div>
|
|
145
|
-
<div className="space-x-2">
|
|
146
|
-
<Button
|
|
147
|
-
variant="outline"
|
|
148
|
-
size="sm"
|
|
149
|
-
onClick={() => table.previousPage()}
|
|
150
|
-
disabled={!table.getCanPreviousPage()}
|
|
151
|
-
>
|
|
152
|
-
<ChevronLeft className="h-4 w-4" />
|
|
153
|
-
</Button>
|
|
154
|
-
<Button
|
|
155
|
-
variant="outline"
|
|
156
|
-
size="sm"
|
|
157
|
-
onClick={() => table.nextPage()}
|
|
158
|
-
disabled={!table.getCanNextPage()}
|
|
159
|
-
>
|
|
160
|
-
<ChevronRight className="h-4 w-4" />
|
|
161
|
-
</Button>
|
|
162
|
-
</div>
|
|
163
|
-
<div className="flex items-center gap-1">
|
|
164
|
-
<p className="text-sm font-medium">Page</p>
|
|
165
|
-
<span className="text-sm font-medium">
|
|
166
|
-
{table.getState().pagination.pageIndex + 1} of{" "}
|
|
167
|
-
{table.getPageCount() || 0}
|
|
168
|
-
</span>
|
|
169
|
-
</div>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
);
|
|
173
|
-
}
|