@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.
Files changed (147) hide show
  1. package/.eslintrc.json +14 -0
  2. package/.storybook/main.ts +20 -0
  3. package/.storybook/preview.ts +45 -0
  4. package/README.md +31 -0
  5. package/dist/index.js +2 -0
  6. package/package.json +83 -0
  7. package/postcss.config.js +6 -0
  8. package/rollup.config.js +104 -0
  9. package/scripts/build-utils.js +16 -0
  10. package/src/components/Avatar/Avatar.stories.tsx +26 -0
  11. package/src/components/Avatar/Avatar.tsx +36 -0
  12. package/src/components/Avatar/index.css +9 -0
  13. package/src/components/Avatar/index.ts +1 -0
  14. package/src/components/Button/Button.stories.tsx +99 -0
  15. package/src/components/Button/Button.tsx +71 -0
  16. package/src/components/Button/index.css +168 -0
  17. package/src/components/Button/index.ts +1 -0
  18. package/src/components/Card/Card.stories.tsx +126 -0
  19. package/src/components/Card/Card.tsx +111 -0
  20. package/src/components/Card/index.css +96 -0
  21. package/src/components/Card/index.ts +1 -0
  22. package/src/components/Chart/Chart.stories.tsx +61 -0
  23. package/src/components/Chart/Chart.tsx +192 -0
  24. package/src/components/Chart/index.css +15 -0
  25. package/src/components/Chart/index.ts +1 -0
  26. package/src/components/Checkbox/Checkbox.stories.tsx +46 -0
  27. package/src/components/Checkbox/Checkbox.tsx +46 -0
  28. package/src/components/Checkbox/index.css +29 -0
  29. package/src/components/Checkbox/index.ts +1 -0
  30. package/src/components/Col/Col.stories.tsx +33 -0
  31. package/src/components/Col/Col.tsx +45 -0
  32. package/src/components/Col/index.css +57 -0
  33. package/src/components/Col/index.ts +1 -0
  34. package/src/components/Collapse/Collapse.stories.tsx +86 -0
  35. package/src/components/Collapse/Collapse.tsx +34 -0
  36. package/src/components/Collapse/CollapseIcon.tsx +33 -0
  37. package/src/components/Collapse/index.css +14 -0
  38. package/src/components/Collapse/index.ts +2 -0
  39. package/src/components/Divider/Divider.stories.tsx +45 -0
  40. package/src/components/Divider/Divider.tsx +42 -0
  41. package/src/components/Divider/index.css +20 -0
  42. package/src/components/Divider/index.ts +1 -0
  43. package/src/components/Drawer/Drawer.stories.tsx +51 -0
  44. package/src/components/Drawer/Drawer.tsx +40 -0
  45. package/src/components/Drawer/index.css +15 -0
  46. package/src/components/Drawer/index.ts +1 -0
  47. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +66 -0
  48. package/src/components/DropdownMenu/DropdownMenu.tsx +91 -0
  49. package/src/components/DropdownMenu/index.css +18 -0
  50. package/src/components/DropdownMenu/index.ts +1 -0
  51. package/src/components/Filter/Filter.stories.tsx +94 -0
  52. package/src/components/Filter/Filter.tsx +213 -0
  53. package/src/components/Filter/index.css +81 -0
  54. package/src/components/Filter/index.ts +1 -0
  55. package/src/components/Form/Form.tsx +11 -0
  56. package/src/components/Form/Item.tsx +33 -0
  57. package/src/components/Form/index.css +4 -0
  58. package/src/components/Form/index.ts +1 -0
  59. package/src/components/HoverCard/HoverCard.stories.tsx +48 -0
  60. package/src/components/HoverCard/HoverCard.tsx +54 -0
  61. package/src/components/HoverCard/index.css +15 -0
  62. package/src/components/HoverCard/index.ts +1 -0
  63. package/src/components/Icon/Icon.stories.tsx +23 -0
  64. package/src/components/Icon/Icon.tsx +36 -0
  65. package/src/components/Icon/index.css +3 -0
  66. package/src/components/Icon/index.ts +1 -0
  67. package/src/components/IconDisplay/IconDisplay.stories.tsx +27 -0
  68. package/src/components/IconDisplay/IconDisplay.tsx +29 -0
  69. package/src/components/IconDisplay/index.css +18 -0
  70. package/src/components/IconDisplay/index.ts +1 -0
  71. package/src/components/Information/Information.stories.tsx +25 -0
  72. package/src/components/Information/Information.tsx +50 -0
  73. package/src/components/Information/index.css +34 -0
  74. package/src/components/Information/index.ts +1 -0
  75. package/src/components/Input/Input.stories.tsx +38 -0
  76. package/src/components/Input/Input.tsx +91 -0
  77. package/src/components/Input/index.css +74 -0
  78. package/src/components/Input/index.ts +1 -0
  79. package/src/components/Label/Label.tsx +26 -0
  80. package/src/components/Label/index.ts +1 -0
  81. package/src/components/Layout/Content.tsx +29 -0
  82. package/src/components/Layout/Header.tsx +29 -0
  83. package/src/components/Layout/Layout.stories.tsx +54 -0
  84. package/src/components/Layout/Layout.tsx +32 -0
  85. package/src/components/Layout/Sider.tsx +29 -0
  86. package/src/components/Layout/index.css +37 -0
  87. package/src/components/Layout/index.ts +4 -0
  88. package/src/components/List/List.stories.tsx +58 -0
  89. package/src/components/List/List.tsx +98 -0
  90. package/src/components/List/index.css +54 -0
  91. package/src/components/List/index.ts +1 -0
  92. package/src/components/Loading/Loading.stories.tsx +23 -0
  93. package/src/components/Loading/Loading.tsx +51 -0
  94. package/src/components/Loading/index.css +36 -0
  95. package/src/components/Loading/index.ts +1 -0
  96. package/src/components/Logo/Logo.stories.tsx +34 -0
  97. package/src/components/Logo/Logo.tsx +39 -0
  98. package/src/components/Logo/index.css +9 -0
  99. package/src/components/Logo/index.ts +1 -0
  100. package/src/components/Menubar/Menubar.stories.tsx +55 -0
  101. package/src/components/Menubar/Menubar.tsx +118 -0
  102. package/src/components/Menubar/index.css +96 -0
  103. package/src/components/Menubar/index.ts +1 -0
  104. package/src/components/Row/Row.stories.tsx +33 -0
  105. package/src/components/Row/Row.tsx +48 -0
  106. package/src/components/Row/index.css +116 -0
  107. package/src/components/Row/index.ts +1 -0
  108. package/src/components/Switch/Switch.stories.tsx +39 -0
  109. package/src/components/Switch/Switch.tsx +36 -0
  110. package/src/components/Switch/index.css +37 -0
  111. package/src/components/Switch/index.ts +1 -0
  112. package/src/components/Table/Table.stories.tsx +85 -0
  113. package/src/components/Table/Table.tsx +123 -0
  114. package/src/components/Table/index.css +74 -0
  115. package/src/components/Table/index.ts +1 -0
  116. package/src/components/Tabs/Tabs.stories.tsx +49 -0
  117. package/src/components/Tabs/Tabs.tsx +76 -0
  118. package/src/components/Tabs/index.css +89 -0
  119. package/src/components/Tabs/index.ts +1 -0
  120. package/src/components/Tag/Tag.stories.tsx +41 -0
  121. package/src/components/Tag/Tag.tsx +39 -0
  122. package/src/components/Tag/index.css +31 -0
  123. package/src/components/Tag/index.ts +1 -0
  124. package/src/components/Text/Text.stories.tsx +41 -0
  125. package/src/components/Toast/Toast.stories.tsx +47 -0
  126. package/src/components/Toast/Toast.tsx +13 -0
  127. package/src/components/Toast/index.ts +1 -0
  128. package/src/components/Tooltip/Tooltip.stories.tsx +44 -0
  129. package/src/components/Tooltip/Tooltip.tsx +60 -0
  130. package/src/components/Tooltip/index.css +15 -0
  131. package/src/components/Tooltip/index.ts +1 -0
  132. package/src/index.css +176 -0
  133. package/src/index.ts +38 -0
  134. package/src/shadcn/checkbox.tsx +28 -0
  135. package/src/shadcn/dropdown-menu.tsx +200 -0
  136. package/src/shadcn/form.tsx +178 -0
  137. package/src/shadcn/hover-card.tsx +31 -0
  138. package/src/shadcn/label.tsx +26 -0
  139. package/src/shadcn/lib/utils.ts +6 -0
  140. package/src/shadcn/menubar.tsx +248 -0
  141. package/src/shadcn/switch.tsx +25 -0
  142. package/src/shadcn/table.tsx +117 -0
  143. package/src/shadcn/tabs.tsx +55 -0
  144. package/src/shadcn/tooltip.tsx +30 -0
  145. package/src/theme.ts +123 -0
  146. package/tailwind.config.js +9 -0
  147. package/tsconfig.json +32 -0
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+ import "./index.css";
4
+
5
+ type DividerProps = {
6
+ id?: string;
7
+ className?: string;
8
+ margin?: number;
9
+ children?: React.ReactNode;
10
+ }
11
+
12
+ const Divider = ({
13
+ id,
14
+ className,
15
+ margin = 26,
16
+ children,
17
+ }: DividerProps) => {
18
+ return (
19
+ <div
20
+ id={id}
21
+ className={classNames(
22
+ "gyramais-divider",
23
+ className,
24
+ )}
25
+ style={{
26
+ padding: `${margin}px 0px`,
27
+ }}
28
+ >
29
+ <hr className="gyramais-divider-divider" />
30
+
31
+ {children && (
32
+ <div className="gyramais-divider-content">
33
+ {children}
34
+ </div>
35
+ )}
36
+
37
+ <hr className="gyramais-divider-divider" />
38
+ </div>
39
+ );
40
+ };
41
+
42
+ export { Divider };
@@ -0,0 +1,20 @@
1
+ .gyramais-divider {
2
+ @apply
3
+ flex
4
+ items-center
5
+ w-full;
6
+ }
7
+
8
+ .gyramais-divider .gyramais-divider-divider {
9
+ @apply
10
+ w-full
11
+ border-[var(--border-color)];
12
+ }
13
+
14
+ .gyramais-divider .gyramais-divider-content {
15
+ @apply
16
+ px-[6px]
17
+ text-base
18
+ text-[#7D9585]
19
+ font-light;
20
+ }
@@ -0,0 +1 @@
1
+ export * from "./Divider";
@@ -0,0 +1,51 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { Drawer } from "./Drawer";
4
+ import { Button } from '../Button';
5
+
6
+
7
+ const meta: Meta<typeof Drawer> = {
8
+ title: "Library/Components/Drawer",
9
+ component: Drawer,
10
+ parameters: {
11
+ layout: 'fullscreen',
12
+ },
13
+ render: ({ visible = false }) => {
14
+ const [internalVisible, setInternalVisible] = useState(false);
15
+
16
+ useEffect(() => {
17
+ setInternalVisible(visible);
18
+ }, [visible])
19
+
20
+ return (
21
+ <>
22
+ <div className="p-4">
23
+ <Button onClick={() => setInternalVisible(true)}>
24
+ Abrir drawer
25
+ </Button>
26
+ </div>
27
+
28
+ <Drawer
29
+ visible={internalVisible}
30
+ onClose={() => setInternalVisible(false)}
31
+ >
32
+ Teste
33
+ </Drawer>
34
+ </>
35
+ );
36
+ }
37
+ };
38
+
39
+ export default meta;
40
+
41
+ type Story = StoryObj<typeof Drawer>;
42
+
43
+ export const Default: Story = {
44
+ args: {
45
+ className: '',
46
+ visible: false,
47
+ children: (
48
+ 'Informação qualquer'
49
+ ),
50
+ },
51
+ }
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+ import "./index.css";
4
+
5
+ import { default as PrimitiveDrawer } from 'react-modern-drawer'
6
+
7
+ type DrawerProps = {
8
+ className?: string;
9
+ visible?: boolean;
10
+ onClose?: () => void;
11
+ direction?: 'left' | 'top' | 'right' | 'bottom';
12
+ children?: React.ReactNode;
13
+ }
14
+
15
+ const Drawer = ({
16
+ className,
17
+ visible = false,
18
+ onClose,
19
+ direction = 'right',
20
+ children,
21
+ }: DrawerProps) => {
22
+ return (
23
+ <PrimitiveDrawer
24
+ open={visible}
25
+ onClose={onClose}
26
+ direction={direction}
27
+ className={classNames(
28
+ "gyramais-drawer",
29
+ className,
30
+ )}
31
+ duration={200}
32
+ >
33
+ <div className="gyramais-drawer-content">
34
+ {children}
35
+ </div>
36
+ </PrimitiveDrawer>
37
+ );
38
+ };
39
+
40
+ export { Drawer };
@@ -0,0 +1,15 @@
1
+ .gyramais-drawer {
2
+ @apply
3
+ min-w-[90%]
4
+ max-w-[90%]
5
+
6
+ md:min-w-[700px]
7
+ md:max-w-[90%]
8
+ }
9
+
10
+ .gyramais-drawer .gyramais-drawer-content {
11
+ @apply
12
+ p-4
13
+
14
+ md:p-6;
15
+ }
@@ -0,0 +1 @@
1
+ export * from "./Drawer";
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { DropdownMenu } from "./DropdownMenu";
4
+ import { Button } from "../Button";
5
+ import SettingsIcon from '@mui/icons-material/Settings';
6
+
7
+ const meta: Meta<typeof DropdownMenu> = {
8
+ title: "Library/Components/DropdownMenu",
9
+ component: DropdownMenu,
10
+ parameters: {
11
+ layout: 'centered',
12
+ },
13
+ render: (props) => (
14
+ <div className="w-full h-[300px] flex items-center justify-center">
15
+ <DropdownMenu {...props}>
16
+ {props.children}
17
+ </DropdownMenu>
18
+ </div>
19
+ )
20
+ };
21
+
22
+ export default meta;
23
+
24
+ type Story = StoryObj<typeof DropdownMenu>;
25
+
26
+ export const Default: Story = {
27
+ args: {
28
+ id: '',
29
+ className: '',
30
+ title: '',
31
+ items: [{
32
+ key: 'options',
33
+ title: 'Opções',
34
+ onClick: () => alert('Opções'),
35
+ }, {
36
+ separator: true,
37
+ }, {
38
+ key: 'promotions',
39
+ title: 'Promoções',
40
+ disabled: true,
41
+ }],
42
+ children: (
43
+ <Button type="white" icon={(<SettingsIcon />)} />
44
+ ),
45
+ },
46
+ }
47
+
48
+ export const Title: Story = {
49
+ args: {
50
+ id: '',
51
+ className: '',
52
+ title: 'Configurações',
53
+ items: [{
54
+ key: 'options',
55
+ title: 'Opções',
56
+ onClick: () => alert('Opções'),
57
+ }, {
58
+ key: 'promotions',
59
+ title: 'Promoções',
60
+ disabled: true,
61
+ }],
62
+ children: (
63
+ <Button type="white" icon={(<SettingsIcon />)} />
64
+ ),
65
+ },
66
+ }
@@ -0,0 +1,91 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+ import "./index.css";
4
+
5
+ import {
6
+ DropdownMenu as PrimitiveDropdownMenu,
7
+ DropdownMenuContent,
8
+ DropdownMenuItem,
9
+ DropdownMenuLabel,
10
+ DropdownMenuSeparator,
11
+ DropdownMenuTrigger,
12
+ } from "../../shadcn/dropdown-menu";
13
+
14
+
15
+ type DropdownMenuProps = {
16
+ id?: string;
17
+ className?: string;
18
+ title?: string;
19
+ visible?: boolean;
20
+ align?: "start" | "center" | "end";
21
+ side?: "top" | "right" | "bottom" | "left";
22
+ sideOffset?: number;
23
+ items?: Array<{
24
+ key?: string;
25
+ title?: string | React.ReactNode;
26
+ disabled?: boolean;
27
+ separator?: boolean;
28
+ onClick?: () => void;
29
+ }>;
30
+ children?: React.ReactNode;
31
+ }
32
+
33
+ const DropdownMenu = ({
34
+ id,
35
+ className,
36
+ title,
37
+ visible,
38
+ align,
39
+ side,
40
+ sideOffset = 8,
41
+ items = [],
42
+ children,
43
+ }: DropdownMenuProps) => {
44
+ return (
45
+ <PrimitiveDropdownMenu
46
+ modal={false}
47
+ open={visible}
48
+ >
49
+ <DropdownMenuTrigger className="gyramais-dropdown-menu-trigger">
50
+ {children}
51
+ </DropdownMenuTrigger>
52
+
53
+ <DropdownMenuContent
54
+ id={id}
55
+ className={classNames(
56
+ 'gyramais-dropdown-menu-content',
57
+ className,
58
+ )}
59
+ align={align}
60
+ side={side}
61
+ sideOffset={sideOffset}
62
+ >
63
+ {title && (
64
+ <>
65
+ <DropdownMenuLabel>
66
+ {title}
67
+ </DropdownMenuLabel>
68
+
69
+ <DropdownMenuSeparator className="gyramais-dropdown-menu-separator" />
70
+ </>
71
+ )}
72
+
73
+ {items.map((item) => item.separator ? (
74
+ <DropdownMenuSeparator className="gyramais-dropdown-menu-separator" />
75
+ ) : (
76
+ <DropdownMenuItem
77
+ id={item.key}
78
+ className="gyramais-dropdown-menu-item"
79
+ key={item.key}
80
+ onClick={item.onClick}
81
+ disabled={item.disabled}
82
+ >
83
+ {item.title}
84
+ </DropdownMenuItem>
85
+ ))}
86
+ </DropdownMenuContent>
87
+ </PrimitiveDropdownMenu>
88
+ );
89
+ };
90
+
91
+ export { DropdownMenu };
@@ -0,0 +1,18 @@
1
+ .gyramais-dropdown-menu-content {
2
+ @apply
3
+ w-fit
4
+ bg-white
5
+ border-[var(--border-color)]
6
+ shadow-xl
7
+ rounded-[12px];
8
+ }
9
+
10
+ .gyramais-dropdown-menu-content .gyramais-dropdown-menu-separator {
11
+ @apply
12
+ bg-[var(--border-color)];
13
+ }
14
+
15
+ .gyramais-dropdown-menu-content .gyramais-dropdown-menu-item {
16
+ @apply
17
+ cursor-pointer;
18
+ }
@@ -0,0 +1 @@
1
+ export * from "./DropdownMenu";
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { Filter } from "./Filter";
4
+
5
+
6
+ const meta: Meta<typeof Filter> = {
7
+ title: "Library/Components/Filter",
8
+ component: Filter,
9
+ parameters: {
10
+ layout: 'padded',
11
+ },
12
+ render: ({ initialValues, filters, onFilter }) => (
13
+ <div className="w-full h-[500px] flex items-center">
14
+ <Filter
15
+ initialValues={initialValues}
16
+ filters={filters}
17
+ onFilter={onFilter}
18
+ />
19
+ </div>
20
+ ),
21
+ };
22
+
23
+ export default meta;
24
+
25
+ type Story = StoryObj<typeof Filter>;
26
+
27
+ export const Default: Story = {
28
+ args: {
29
+ id: '',
30
+ className: '',
31
+ filters: [{
32
+ key: 'isPartner',
33
+ name: 'Apenas clientes de parceiros',
34
+ type: 'boolean',
35
+ disabled: false,
36
+ }, {
37
+ key: 'businessNumber',
38
+ name: 'Número da empresa',
39
+ type: 'text',
40
+ disabled: false,
41
+ }],
42
+ onFilter: (filters) => console.log(filters),
43
+ },
44
+ }
45
+
46
+ export const WithInitialValue: Story = {
47
+ args: {
48
+ id: '',
49
+ className: '',
50
+ filters: [{
51
+ key: 'isPartner',
52
+ name: 'Apenas clientes de parceiros',
53
+ type: 'boolean',
54
+ disabled: false,
55
+ }, {
56
+ key: 'businessNumber',
57
+ name: 'Número da empresa',
58
+ type: 'text',
59
+ disabled: false,
60
+ }],
61
+ initialValues: {
62
+ isPartner: true,
63
+ },
64
+ onFilter: (filters) => console.log(filters),
65
+ },
66
+ }
67
+
68
+ export const UniqueFilterBoolean: Story = {
69
+ args: {
70
+ id: '',
71
+ className: '',
72
+ filters: [{
73
+ key: 'onlyCnpj',
74
+ name: 'Apenas CNPJ',
75
+ type: 'boolean',
76
+ disabled: false,
77
+ }],
78
+ onFilter: (filters) => console.log(filters),
79
+ },
80
+ }
81
+
82
+ export const UniqueFilterText: Story = {
83
+ args: {
84
+ id: '',
85
+ className: '',
86
+ filters: [{
87
+ key: 'onlyCnpj',
88
+ name: 'CNPJ',
89
+ type: 'text',
90
+ disabled: false,
91
+ }],
92
+ onFilter: (filters) => console.log(filters),
93
+ },
94
+ }
@@ -0,0 +1,213 @@
1
+ import React, { useState, useEffect, useMemo } from "react";
2
+ import classNames from "classnames";
3
+ import "./index.css";
4
+
5
+ import { Button } from '../Button';
6
+ import { HoverCard } from "../HoverCard";
7
+ import { Row } from "../Row";
8
+ import { Col } from "../Col";
9
+ import { Input } from "../Input";
10
+ import { Switch } from "../Switch";
11
+
12
+ import FilterListIcon from '@mui/icons-material/FilterList';
13
+
14
+ type FilterItem = {
15
+ key: string;
16
+ name: string;
17
+ type: 'text' | 'boolean';
18
+ disabled?: boolean;
19
+ };
20
+
21
+ type FilterValue = {
22
+ [key: string]: string | boolean;
23
+ };
24
+
25
+ type FilterProps = {
26
+ id?: string;
27
+ className?: string;
28
+ initialValues?: FilterValue;
29
+ filters?: Array<FilterItem>;
30
+ onFilter: (values: { [key: string]: string | boolean }) => void;
31
+ }
32
+
33
+ const Filter = ({
34
+ id,
35
+ className,
36
+ initialValues = {},
37
+ filters = [],
38
+ onFilter,
39
+ }: FilterProps) => {
40
+ const [values, setValues] = useState<FilterValue>({});
41
+ const [filtersOpened, setFiltersOpened] = useState(false);
42
+ const [filtersWithValue, setFiltersWithValue] = useState(0);
43
+
44
+ const uniqueFilter: FilterItem | boolean = useMemo(() => filters.length === 1 && filters[0], [filters]);
45
+
46
+ const handleChangeFilterValue: (params: {
47
+ key: string;
48
+ value: string | boolean;
49
+ }) => void = ({ key, value }) => setValues({...values, [key]: value });
50
+
51
+ const handleFilterButtonClick: () => void = () => {
52
+ if (typeof uniqueFilter === 'object' && uniqueFilter.type === 'boolean') {
53
+ const key = uniqueFilter.key;
54
+ const value = values[key] !== true;
55
+
56
+ handleChangeFilterValue({ key, value })
57
+ onFilter({ [key]: value });
58
+ return;
59
+ }
60
+
61
+ setFiltersOpened(!filtersOpened);
62
+ };
63
+
64
+ const clearFilterValues = () => {
65
+ if (filters) {
66
+ const temp: FilterValue = {};
67
+
68
+ filters.forEach(({ key, type }) => {
69
+ temp[key] = '';
70
+
71
+ if (type === 'boolean') {
72
+ temp[key] = false;
73
+ }
74
+ });
75
+
76
+ setValues(temp);
77
+ }
78
+
79
+ setFiltersWithValue(0);
80
+ };
81
+
82
+ const renderFilterItem: (params: FilterItem) => React.ReactNode = ({
83
+ key,
84
+ name,
85
+ type,
86
+ disabled,
87
+ }) => {
88
+ if (values[key] === null || values[key] === undefined) {
89
+ return false;
90
+ }
91
+
92
+ if (type === 'boolean') {
93
+ return (
94
+ <Row columns={3} gap={8} align="center">
95
+ <Col span={2} className="gyramais-filter-label">
96
+ {name}
97
+ </Col>
98
+
99
+ <Col span={1} className="gyramais-filter-switch-area">
100
+ <Switch
101
+ disabled={disabled}
102
+ checked={!!values[key]}
103
+ onCheckedChange={(checked) => handleChangeFilterValue({ key, value: checked })}
104
+ />
105
+ </Col>
106
+ </Row>
107
+ )
108
+ }
109
+
110
+ return (
111
+ <Input
112
+ disabled={disabled}
113
+ placeholder={name}
114
+ value={values[key] || ''}
115
+ onChange={(e) => handleChangeFilterValue({ key, value: e.target.value })}
116
+ />
117
+ )
118
+ };
119
+
120
+ useEffect(() => {
121
+ const temp: FilterValue = {};
122
+
123
+ if (filters) {
124
+ filters.forEach(({ key, type }) => {
125
+ const initialValue = initialValues[key];
126
+
127
+ if (type === 'text') {
128
+ temp[key] = initialValue && typeof initialValue === 'string' ? `${initialValue}` : '';
129
+ }
130
+
131
+ if (type === 'boolean') {
132
+ temp[key] = initialValue && typeof initialValue === 'boolean' ? initialValue : false;
133
+ }
134
+ });
135
+
136
+ setValues(temp);
137
+ }
138
+
139
+ const appliedFilters = Object.values(temp).filter(Boolean).length;
140
+ setFiltersWithValue(appliedFilters);
141
+ }, []);
142
+
143
+ return (
144
+ <div
145
+ id={id}
146
+ className={classNames(
147
+ "gyramais-filter",
148
+ className,
149
+ )}
150
+ >
151
+ <HoverCard
152
+ visible={filtersOpened}
153
+ side="top"
154
+ align="start"
155
+ content={(
156
+ <Row columns={1} gap={16} className="gyramais-filter-filters-container">
157
+ {filters.map((filter) => (
158
+ <Col key={filter.key} span={1} className="gyramais-filter-filters-item">
159
+ {renderFilterItem(filter)}
160
+ </Col>
161
+ ))}
162
+
163
+ <Col span={1}>
164
+ <Row columns={2} gap={8} align="center">
165
+ <Col span={2} className="gyramais-filter-filters-footer">
166
+ <Button
167
+ className="mr-4"
168
+ link
169
+ onClick={clearFilterValues}
170
+ >
171
+ Limpar
172
+ {filters.length === 1 ? ' filtro' : ' filtros'}
173
+ </Button>
174
+
175
+ <Button
176
+ onClick={() => {
177
+ const appliedFilters = Object.values(values).filter(Boolean).length;
178
+
179
+ onFilter?.(values);
180
+ setFiltersWithValue(appliedFilters);
181
+ setFiltersOpened(false);
182
+ }}
183
+ >
184
+ Filtrar
185
+ </Button>
186
+ </Col>
187
+ </Row>
188
+ </Col>
189
+ </Row>
190
+ )}
191
+ >
192
+ <div className="gyramais-filter-button-container">
193
+ {typeof uniqueFilter !== 'object' && filtersWithValue > 0 && (
194
+ <div className="gyramais-filter-filters-count">
195
+ {filtersWithValue}
196
+ </div>
197
+ )}
198
+
199
+ <Button
200
+ className="gyramais-filter-button"
201
+ type={typeof uniqueFilter === 'object' && values[uniqueFilter.key] && !filtersOpened ? 'primary' : 'white'}
202
+ icon={(<FilterListIcon className="gyramais-filter-button-icon" />)}
203
+ onClick={handleFilterButtonClick}
204
+ >
205
+ {typeof uniqueFilter === 'object' && uniqueFilter.name || 'Filtro'}
206
+ </Button>
207
+ </div>
208
+ </HoverCard>
209
+ </div>
210
+ );
211
+ };
212
+
213
+ export { Filter };