@gyramais/gyra-design 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 +14 -0
- package/.storybook/main.ts +20 -0
- package/.storybook/preview.ts +45 -0
- package/README.md +31 -0
- package/dist/index.js +2 -0
- package/package.json +83 -0
- package/postcss.config.js +6 -0
- package/rollup.config.js +104 -0
- package/scripts/build-utils.js +16 -0
- package/src/components/Avatar/Avatar.stories.tsx +26 -0
- package/src/components/Avatar/Avatar.tsx +36 -0
- package/src/components/Avatar/index.css +9 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/Button.stories.tsx +99 -0
- package/src/components/Button/Button.tsx +71 -0
- package/src/components/Button/index.css +168 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/Card.stories.tsx +126 -0
- package/src/components/Card/Card.tsx +111 -0
- package/src/components/Card/index.css +96 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Chart/Chart.stories.tsx +61 -0
- package/src/components/Chart/Chart.tsx +192 -0
- package/src/components/Chart/index.css +15 -0
- package/src/components/Chart/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +46 -0
- package/src/components/Checkbox/Checkbox.tsx +46 -0
- package/src/components/Checkbox/index.css +29 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Col/Col.stories.tsx +33 -0
- package/src/components/Col/Col.tsx +45 -0
- package/src/components/Col/index.css +57 -0
- package/src/components/Col/index.ts +1 -0
- package/src/components/Collapse/Collapse.stories.tsx +86 -0
- package/src/components/Collapse/Collapse.tsx +34 -0
- package/src/components/Collapse/CollapseIcon.tsx +33 -0
- package/src/components/Collapse/index.css +14 -0
- package/src/components/Collapse/index.ts +2 -0
- package/src/components/Divider/Divider.stories.tsx +45 -0
- package/src/components/Divider/Divider.tsx +42 -0
- package/src/components/Divider/index.css +20 -0
- package/src/components/Divider/index.ts +1 -0
- package/src/components/Drawer/Drawer.stories.tsx +51 -0
- package/src/components/Drawer/Drawer.tsx +40 -0
- package/src/components/Drawer/index.css +15 -0
- package/src/components/Drawer/index.ts +1 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +66 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +91 -0
- package/src/components/DropdownMenu/index.css +18 -0
- package/src/components/DropdownMenu/index.ts +1 -0
- package/src/components/Filter/Filter.stories.tsx +94 -0
- package/src/components/Filter/Filter.tsx +213 -0
- package/src/components/Filter/index.css +81 -0
- package/src/components/Filter/index.ts +1 -0
- package/src/components/Form/Form.tsx +11 -0
- package/src/components/Form/Item.tsx +33 -0
- package/src/components/Form/index.css +4 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/HoverCard/HoverCard.stories.tsx +48 -0
- package/src/components/HoverCard/HoverCard.tsx +54 -0
- package/src/components/HoverCard/index.css +15 -0
- package/src/components/HoverCard/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +23 -0
- package/src/components/Icon/Icon.tsx +36 -0
- package/src/components/Icon/index.css +3 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/IconDisplay/IconDisplay.stories.tsx +27 -0
- package/src/components/IconDisplay/IconDisplay.tsx +29 -0
- package/src/components/IconDisplay/index.css +18 -0
- package/src/components/IconDisplay/index.ts +1 -0
- package/src/components/Information/Information.stories.tsx +25 -0
- package/src/components/Information/Information.tsx +50 -0
- package/src/components/Information/index.css +34 -0
- package/src/components/Information/index.ts +1 -0
- package/src/components/Input/Input.stories.tsx +38 -0
- package/src/components/Input/Input.tsx +91 -0
- package/src/components/Input/index.css +74 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/Label/Label.tsx +26 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Layout/Content.tsx +29 -0
- package/src/components/Layout/Header.tsx +29 -0
- package/src/components/Layout/Layout.stories.tsx +54 -0
- package/src/components/Layout/Layout.tsx +32 -0
- package/src/components/Layout/Sider.tsx +29 -0
- package/src/components/Layout/index.css +37 -0
- package/src/components/Layout/index.ts +4 -0
- package/src/components/List/List.stories.tsx +58 -0
- package/src/components/List/List.tsx +98 -0
- package/src/components/List/index.css +54 -0
- package/src/components/List/index.ts +1 -0
- package/src/components/Loading/Loading.stories.tsx +23 -0
- package/src/components/Loading/Loading.tsx +51 -0
- package/src/components/Loading/index.css +36 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Logo/Logo.stories.tsx +34 -0
- package/src/components/Logo/Logo.tsx +39 -0
- package/src/components/Logo/index.css +9 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menubar/Menubar.stories.tsx +55 -0
- package/src/components/Menubar/Menubar.tsx +118 -0
- package/src/components/Menubar/index.css +96 -0
- package/src/components/Menubar/index.ts +1 -0
- package/src/components/Row/Row.stories.tsx +33 -0
- package/src/components/Row/Row.tsx +48 -0
- package/src/components/Row/index.css +116 -0
- package/src/components/Row/index.ts +1 -0
- package/src/components/Switch/Switch.stories.tsx +39 -0
- package/src/components/Switch/Switch.tsx +36 -0
- package/src/components/Switch/index.css +37 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Table/Table.stories.tsx +85 -0
- package/src/components/Table/Table.tsx +123 -0
- package/src/components/Table/index.css +74 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Tabs/Tabs.stories.tsx +49 -0
- package/src/components/Tabs/Tabs.tsx +76 -0
- package/src/components/Tabs/index.css +89 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tag/Tag.stories.tsx +41 -0
- package/src/components/Tag/Tag.tsx +39 -0
- package/src/components/Tag/index.css +31 -0
- package/src/components/Tag/index.ts +1 -0
- package/src/components/Text/Text.stories.tsx +41 -0
- package/src/components/Toast/Toast.stories.tsx +47 -0
- package/src/components/Toast/Toast.tsx +13 -0
- package/src/components/Toast/index.ts +1 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +44 -0
- package/src/components/Tooltip/Tooltip.tsx +60 -0
- package/src/components/Tooltip/index.css +15 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/index.css +176 -0
- package/src/index.ts +38 -0
- package/src/shadcn/checkbox.tsx +28 -0
- package/src/shadcn/dropdown-menu.tsx +200 -0
- package/src/shadcn/form.tsx +178 -0
- package/src/shadcn/hover-card.tsx +31 -0
- package/src/shadcn/label.tsx +26 -0
- package/src/shadcn/lib/utils.ts +6 -0
- package/src/shadcn/menubar.tsx +248 -0
- package/src/shadcn/switch.tsx +25 -0
- package/src/shadcn/table.tsx +117 -0
- package/src/shadcn/tabs.tsx +55 -0
- package/src/shadcn/tooltip.tsx +30 -0
- package/src/theme.ts +123 -0
- package/tailwind.config.js +9 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.gyramais-filter .gyramais-filter-filters-container {
|
|
2
|
+
@apply
|
|
3
|
+
w-[360px]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.gyramais-filter .gyramais-filter-button-container {
|
|
7
|
+
@apply
|
|
8
|
+
relative
|
|
9
|
+
w-fit;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gyramais-filter .gyramais-filter-button {
|
|
13
|
+
@apply
|
|
14
|
+
!px-2
|
|
15
|
+
!py-1
|
|
16
|
+
!text-xs
|
|
17
|
+
!rounded-[24px]
|
|
18
|
+
!border-[var(--primary-button-color)]
|
|
19
|
+
!font-medium;
|
|
20
|
+
}
|
|
21
|
+
.gyramais-filter .gyramais-filter-button.gyramais-button-white {
|
|
22
|
+
@apply
|
|
23
|
+
text-[var(--primary-button-color)];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.gyramais-filter .gyramais-button-icon-container {
|
|
27
|
+
@apply
|
|
28
|
+
!mr-1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.gyramais-filter .gyramais-filter-button-icon {
|
|
32
|
+
@apply
|
|
33
|
+
!text-base;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.gyramais-filter .gyramais-filter-filters-count {
|
|
37
|
+
@apply
|
|
38
|
+
absolute
|
|
39
|
+
z-10
|
|
40
|
+
-right-[4px]
|
|
41
|
+
-top-[4px]
|
|
42
|
+
flex
|
|
43
|
+
items-center
|
|
44
|
+
justify-center
|
|
45
|
+
min-w-[16px]
|
|
46
|
+
min-h-[16px]
|
|
47
|
+
w-4
|
|
48
|
+
h-4
|
|
49
|
+
rounded-full
|
|
50
|
+
bg-[var(--primary-button-color)]
|
|
51
|
+
text-[var(--primary-button-text-color)]
|
|
52
|
+
text-[10px]
|
|
53
|
+
cursor-default;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.gyramais-filter .gyramais-filter-label {
|
|
57
|
+
@apply
|
|
58
|
+
font-semibold
|
|
59
|
+
leading-5
|
|
60
|
+
text-[var(--primary-button-color)]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.gyramais-filter .gyramais-filter-switch-area {
|
|
64
|
+
@apply
|
|
65
|
+
flex
|
|
66
|
+
justify-end
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.gyramais-filter .gyramais-input {
|
|
70
|
+
@apply
|
|
71
|
+
!min-h-fit
|
|
72
|
+
!py-3
|
|
73
|
+
!rounded-[16px];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.gyramais-filter .gyramais-filter-filters-footer {
|
|
77
|
+
@apply
|
|
78
|
+
flex
|
|
79
|
+
items-center
|
|
80
|
+
justify-end
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Filter";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
FormItem, FormControl, FormMessage, FormField
|
|
4
|
+
} from '../../shadcn/form'
|
|
5
|
+
import './index.css';
|
|
6
|
+
|
|
7
|
+
type FormItemProps = {
|
|
8
|
+
id?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
control?: any
|
|
12
|
+
name: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Item = ({
|
|
16
|
+
children, control, name
|
|
17
|
+
}: FormItemProps) => (
|
|
18
|
+
<FormField
|
|
19
|
+
control={control}
|
|
20
|
+
name={name}
|
|
21
|
+
defaultValue=""
|
|
22
|
+
render={({ field }) => (
|
|
23
|
+
<FormItem>
|
|
24
|
+
<FormControl>
|
|
25
|
+
{React.cloneElement(children, { ...children.props, ...field })}
|
|
26
|
+
</FormControl>
|
|
27
|
+
<FormMessage id="gyramais-form-message" />
|
|
28
|
+
</FormItem>
|
|
29
|
+
)}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export default Item;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Form";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { HoverCard } from "./HoverCard";
|
|
4
|
+
import { Tag } from '../Tag';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof HoverCard> = {
|
|
7
|
+
title: "Library/Components/HoverCard",
|
|
8
|
+
component: HoverCard,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'padded',
|
|
11
|
+
},
|
|
12
|
+
render: ({ children, content, side, sideOffset, visible }) => (
|
|
13
|
+
<div className="w-full h-[260px] flex items-center justify-center">
|
|
14
|
+
<HoverCard
|
|
15
|
+
side={side}
|
|
16
|
+
sideOffset={sideOffset}
|
|
17
|
+
visible={visible}
|
|
18
|
+
content={content}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</HoverCard>
|
|
22
|
+
</div>
|
|
23
|
+
),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
type Story = StoryObj<typeof HoverCard>;
|
|
29
|
+
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
id: '',
|
|
33
|
+
className: '',
|
|
34
|
+
side: 'bottom',
|
|
35
|
+
sideOffset: 8,
|
|
36
|
+
visible: undefined,
|
|
37
|
+
content: (
|
|
38
|
+
<div>
|
|
39
|
+
Informação qualquer
|
|
40
|
+
</div>
|
|
41
|
+
),
|
|
42
|
+
children: (
|
|
43
|
+
<Tag>
|
|
44
|
+
Coloca o mouse aqui
|
|
45
|
+
</Tag>
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
HoverCard as PrimitiveHoverCard,
|
|
7
|
+
HoverCardContent,
|
|
8
|
+
HoverCardTrigger,
|
|
9
|
+
} from "../../shadcn/hover-card";
|
|
10
|
+
|
|
11
|
+
type HoverCardProps = {
|
|
12
|
+
id?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
align?: "start" | "center" | "end";
|
|
15
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
16
|
+
sideOffset?: number;
|
|
17
|
+
visible?: boolean;
|
|
18
|
+
content: React.ReactNode;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const HoverCard = ({
|
|
23
|
+
id,
|
|
24
|
+
className,
|
|
25
|
+
align,
|
|
26
|
+
side,
|
|
27
|
+
sideOffset = 8,
|
|
28
|
+
visible,
|
|
29
|
+
content,
|
|
30
|
+
children,
|
|
31
|
+
}: HoverCardProps) => {
|
|
32
|
+
return (
|
|
33
|
+
<PrimitiveHoverCard openDelay={100} closeDelay={100} open={visible}>
|
|
34
|
+
<HoverCardTrigger className="gyramais-hover-card-trigger">
|
|
35
|
+
{children}
|
|
36
|
+
</HoverCardTrigger>
|
|
37
|
+
|
|
38
|
+
<HoverCardContent
|
|
39
|
+
id={id}
|
|
40
|
+
className={classNames(
|
|
41
|
+
'gyramais-hover-card-content',
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
align={align}
|
|
45
|
+
side={side}
|
|
46
|
+
sideOffset={sideOffset}
|
|
47
|
+
>
|
|
48
|
+
{content}
|
|
49
|
+
</HoverCardContent>
|
|
50
|
+
</PrimitiveHoverCard>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { HoverCard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HoverCard";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Icon } from "./Icon";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Icon> = {
|
|
5
|
+
title: "Library/Components/Icon",
|
|
6
|
+
component: Icon,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Icon>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
id: '',
|
|
19
|
+
className: '',
|
|
20
|
+
width: '56',
|
|
21
|
+
height: 'auto',
|
|
22
|
+
},
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
|
|
5
|
+
type IconProps = {
|
|
6
|
+
id?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
width?: number | string;
|
|
9
|
+
height?: number | string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Icon = ({
|
|
13
|
+
id,
|
|
14
|
+
className,
|
|
15
|
+
width,
|
|
16
|
+
height,
|
|
17
|
+
}: IconProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<img
|
|
20
|
+
id={id}
|
|
21
|
+
className={classNames(
|
|
22
|
+
'gyramais-icon',
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
style={{
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
}}
|
|
29
|
+
width={width}
|
|
30
|
+
height={height}
|
|
31
|
+
alt="Icone"
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { Icon };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Icon";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { IconDisplay } from "./IconDisplay";
|
|
4
|
+
|
|
5
|
+
import PersonIcon from '@mui/icons-material/Person';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof IconDisplay> = {
|
|
8
|
+
title: "Library/Components/IconDisplay",
|
|
9
|
+
component: IconDisplay,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof IconDisplay>;
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
id: '',
|
|
22
|
+
className: '',
|
|
23
|
+
icon: (
|
|
24
|
+
<PersonIcon />
|
|
25
|
+
),
|
|
26
|
+
},
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
|
|
5
|
+
type IconDisplayProps = {
|
|
6
|
+
id?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const IconDisplay = ({
|
|
12
|
+
id,
|
|
13
|
+
className,
|
|
14
|
+
icon,
|
|
15
|
+
}: IconDisplayProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
id={id}
|
|
19
|
+
className={classNames(
|
|
20
|
+
"gyramais-icon-display",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
{icon}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { IconDisplay };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.gyramais-icon-display {
|
|
2
|
+
@apply
|
|
3
|
+
h-10
|
|
4
|
+
w-10
|
|
5
|
+
min-h-10
|
|
6
|
+
min-w-10
|
|
7
|
+
flex
|
|
8
|
+
items-center
|
|
9
|
+
justify-center
|
|
10
|
+
bg-[var(--dark-button-color)]
|
|
11
|
+
rounded-[8px]
|
|
12
|
+
text-[var(--primary-button-color)]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gyramais-icon-display svg {
|
|
16
|
+
@apply
|
|
17
|
+
text-[24px]
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./IconDisplay";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Information } from "./Information";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Information> = {
|
|
5
|
+
title: "Library/Components/Information",
|
|
6
|
+
component: Information,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Information>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
id: '',
|
|
19
|
+
className: '',
|
|
20
|
+
label: 'Título',
|
|
21
|
+
children: (
|
|
22
|
+
'Informação qualquer'
|
|
23
|
+
),
|
|
24
|
+
},
|
|
25
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import { Tooltip } from "../Tooltip";
|
|
5
|
+
|
|
6
|
+
type InformationProps = {
|
|
7
|
+
id?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
label?: React.ReactNode | string;
|
|
10
|
+
children?: React.ReactNode | string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Information = ({
|
|
14
|
+
id,
|
|
15
|
+
className,
|
|
16
|
+
label,
|
|
17
|
+
children,
|
|
18
|
+
}: InformationProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
id={id}
|
|
22
|
+
className={classNames(
|
|
23
|
+
"gyramais-information",
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
>
|
|
27
|
+
<div className="gyramais-information-label">
|
|
28
|
+
{label}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div className="gyramais-information-content">
|
|
32
|
+
{typeof children === 'string' ? (
|
|
33
|
+
<Tooltip
|
|
34
|
+
content={children}
|
|
35
|
+
align="start"
|
|
36
|
+
side="bottom"
|
|
37
|
+
>
|
|
38
|
+
{children || '-'}
|
|
39
|
+
</Tooltip>
|
|
40
|
+
) : (
|
|
41
|
+
<>
|
|
42
|
+
{children || '-'}
|
|
43
|
+
</>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { Information };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.gyramais-information {
|
|
2
|
+
@apply
|
|
3
|
+
w-full;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.gyramais-information .gyramais-information-label {
|
|
7
|
+
@apply
|
|
8
|
+
text-sm
|
|
9
|
+
text-black
|
|
10
|
+
font-light
|
|
11
|
+
leading-[16.8px]
|
|
12
|
+
mb-1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gyramais-information .gyramais-information-content {
|
|
16
|
+
@apply
|
|
17
|
+
text-base
|
|
18
|
+
text-[#212227]
|
|
19
|
+
font-semibold
|
|
20
|
+
leading-[16px]
|
|
21
|
+
text-ellipsis
|
|
22
|
+
whitespace-nowrap
|
|
23
|
+
overflow-hidden
|
|
24
|
+
w-full;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.gyramais-information .gyramais-tooltip-trigger {
|
|
28
|
+
@apply
|
|
29
|
+
text-ellipsis
|
|
30
|
+
whitespace-nowrap
|
|
31
|
+
overflow-hidden
|
|
32
|
+
w-full
|
|
33
|
+
text-left;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Information";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Input } from "./Input";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Input> = {
|
|
5
|
+
title: "Library/Components/Input",
|
|
6
|
+
component: Input,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Input>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
id: '',
|
|
19
|
+
className: '',
|
|
20
|
+
name: '',
|
|
21
|
+
type: 'text',
|
|
22
|
+
disabled: false,
|
|
23
|
+
placeholder: 'Placeholder',
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const Masked: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
id: '',
|
|
30
|
+
className: '',
|
|
31
|
+
name: '',
|
|
32
|
+
type: 'text',
|
|
33
|
+
disabled: false,
|
|
34
|
+
placeholder: 'CPF',
|
|
35
|
+
guide: false,
|
|
36
|
+
mask: [/\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, '-', /\d/, /\d/],
|
|
37
|
+
},
|
|
38
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
|
|
5
|
+
import MaskedInput, { Mask } from 'react-text-mask'
|
|
6
|
+
|
|
7
|
+
type InputProps = {
|
|
8
|
+
id?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
type?: 'text' | 'password';
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
value?: any;
|
|
15
|
+
mask?: Mask | ((value: string) => Mask);
|
|
16
|
+
guide?: boolean;
|
|
17
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const Input = React.forwardRef(({
|
|
21
|
+
id,
|
|
22
|
+
className,
|
|
23
|
+
name,
|
|
24
|
+
type = 'text',
|
|
25
|
+
disabled,
|
|
26
|
+
placeholder,
|
|
27
|
+
value,
|
|
28
|
+
mask,
|
|
29
|
+
guide = false,
|
|
30
|
+
onChange,
|
|
31
|
+
}: InputProps, ref) => {
|
|
32
|
+
const [hasValue, setHasValue] = useState(false);
|
|
33
|
+
|
|
34
|
+
useEffect(() => setHasValue(!!value), [value]);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className="gyramais-input-controller">
|
|
38
|
+
{placeholder && (
|
|
39
|
+
<div
|
|
40
|
+
className={classNames(
|
|
41
|
+
'gyramais-input-placeholder',
|
|
42
|
+
hasValue ? 'gyramais-input-with-value' : '',
|
|
43
|
+
disabled ? 'gyramais-input-placeholder-disabled' : '',
|
|
44
|
+
)}
|
|
45
|
+
>
|
|
46
|
+
{placeholder}
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
|
|
50
|
+
{mask ? (
|
|
51
|
+
<MaskedInput
|
|
52
|
+
id={id}
|
|
53
|
+
className={classNames(
|
|
54
|
+
"gyramais-input",
|
|
55
|
+
className,
|
|
56
|
+
)}
|
|
57
|
+
name={name}
|
|
58
|
+
type={type}
|
|
59
|
+
disabled={disabled}
|
|
60
|
+
value={value}
|
|
61
|
+
onChange={(e) => {
|
|
62
|
+
setHasValue(!!e.target.value);
|
|
63
|
+
|
|
64
|
+
onChange?.(e);
|
|
65
|
+
}}
|
|
66
|
+
mask={mask || false}
|
|
67
|
+
guide={guide}
|
|
68
|
+
/>
|
|
69
|
+
) : (
|
|
70
|
+
<input
|
|
71
|
+
id={id}
|
|
72
|
+
className={classNames(
|
|
73
|
+
"gyramais-input",
|
|
74
|
+
className,
|
|
75
|
+
)}
|
|
76
|
+
name={name}
|
|
77
|
+
type={type}
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
value={value}
|
|
80
|
+
onChange={(e) => {
|
|
81
|
+
setHasValue(!!e.target.value);
|
|
82
|
+
|
|
83
|
+
onChange?.(e);
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export { Input };
|