norma-library 0.6.2 → 0.6.4

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 (169) hide show
  1. package/.babelrc.json +18 -18
  2. package/.prettierignore +10 -10
  3. package/.prettierrc.json +20 -20
  4. package/.storybook/main.ts +20 -20
  5. package/.storybook/preview.ts +15 -15
  6. package/README.md +43 -43
  7. package/commitlint.config.js +1 -1
  8. package/dist/esm/components/UncontrolledTable/components/header/index.js +3 -1
  9. package/dist/esm/components/UncontrolledTable/components/header/index.js.map +1 -1
  10. package/dist/esm/components/UncontrolledTable/components/header/styles.js +1 -1
  11. package/dist/esm/components/UncontrolledTable/components/header/styles.js.map +1 -1
  12. package/dist/esm/components/UncontrolledTable/index.js +1 -1
  13. package/dist/esm/components/UncontrolledTable/index.js.map +1 -1
  14. package/dist/esm/components/UncontrolledTable/interface.d.ts +2 -0
  15. package/docs/index.md +118 -118
  16. package/package.json +136 -136
  17. package/src/components/Accordion.tsx +39 -39
  18. package/src/components/Avatar.tsx +17 -17
  19. package/src/components/Badge.tsx +14 -14
  20. package/src/components/Box/index.tsx +12 -12
  21. package/src/components/Box/interfaces.ts +3 -3
  22. package/src/components/Box/styles.tsx +22 -22
  23. package/src/components/Breadcrumb/index.tsx +27 -27
  24. package/src/components/Breadcrumb/interface.ts +8 -8
  25. package/src/components/Breadcrumb/styles.tsx +32 -32
  26. package/src/components/Button.tsx +26 -26
  27. package/src/components/Card.tsx +37 -37
  28. package/src/components/ChatMessage.tsx +87 -87
  29. package/src/components/ChatMessageBalloon/ChatMessageBalloon.style.ts +56 -56
  30. package/src/components/ChatMessageBalloon/ChatMessageBalloon.tsx +55 -55
  31. package/src/components/CheckBox.tsx +21 -21
  32. package/src/components/DateInput/index.tsx +34 -34
  33. package/src/components/DateInput/interface.ts +13 -13
  34. package/src/components/DateInput/styles.tsx +27 -27
  35. package/src/components/DatePicker.tsx +67 -67
  36. package/src/components/DropDown.tsx +24 -24
  37. package/src/components/IconButton.tsx +37 -37
  38. package/src/components/Icons.tsx +82 -82
  39. package/src/components/Modal.tsx +103 -103
  40. package/src/components/MultiSelectInput/components/MultiValue/index.tsx +44 -44
  41. package/src/components/MultiSelectInput/components/Option/index.tsx +62 -62
  42. package/src/components/MultiSelectInput/components/Option/styles.tsx +8 -8
  43. package/src/components/MultiSelectInput/index.tsx +60 -60
  44. package/src/components/MultiSelectInput/interfaces.ts +15 -15
  45. package/src/components/MultiSelectInput/styles.tsx +43 -43
  46. package/src/components/Paper.tsx +12 -12
  47. package/src/components/ProgressBar.tsx +71 -71
  48. package/src/components/RadioGroup.tsx +43 -43
  49. package/src/components/RangerSlider.tsx +65 -65
  50. package/src/components/Select.tsx +74 -74
  51. package/src/components/SelectInput/components/Option/index.tsx +61 -61
  52. package/src/components/SelectInput/components/Option/styles.tsx +8 -8
  53. package/src/components/SelectInput/index.tsx +45 -45
  54. package/src/components/SelectInput/interfaces.ts +15 -15
  55. package/src/components/SelectInput/styles.tsx +31 -31
  56. package/src/components/StatusModal/StatusModal.style.tsx +75 -75
  57. package/src/components/StatusModal/StatusModal.tsx +58 -58
  58. package/src/components/Svgs.tsx +506 -506
  59. package/src/components/Table/components/header/index.tsx +86 -86
  60. package/src/components/Table/components/header/styles.tsx +59 -59
  61. package/src/components/Table/components/index.tsx +8 -8
  62. package/src/components/Table/components/pagination/index.tsx +39 -39
  63. package/src/components/Table/components/pagination/styles.tsx +28 -28
  64. package/src/components/Table/components/tbody/index.tsx +30 -30
  65. package/src/components/Table/components/tbody/styles.tsx +4 -4
  66. package/src/components/Table/index.tsx +317 -317
  67. package/src/components/Table/interface.ts +23 -23
  68. package/src/components/Table/styles.tsx +117 -117
  69. package/src/components/Tabs.tsx +105 -105
  70. package/src/components/Tag.tsx +33 -33
  71. package/src/components/TextField.tsx +19 -19
  72. package/src/components/TextInput/index.tsx +37 -37
  73. package/src/components/TextInput/interface.ts +9 -9
  74. package/src/components/TextInput/styles.tsx +23 -23
  75. package/src/components/TimeLine.tsx +89 -89
  76. package/src/components/TimePicker.tsx +78 -78
  77. package/src/components/Typography/Text/index.tsx +20 -20
  78. package/src/components/Typography/Text/interfaces.ts +5 -5
  79. package/src/components/Typography/Text/styles.tsx +40 -40
  80. package/src/components/Typography/Title/index.tsx +22 -22
  81. package/src/components/Typography/Title/interfaces.ts +6 -6
  82. package/src/components/Typography/Title/styles.tsx +40 -40
  83. package/src/components/Typography/index.tsx +6 -6
  84. package/src/components/UncontrolledTable/components/header/index.tsx +72 -65
  85. package/src/components/UncontrolledTable/components/header/styles.tsx +65 -63
  86. package/src/components/UncontrolledTable/components/index.tsx +8 -8
  87. package/src/components/UncontrolledTable/components/pagination/index.tsx +43 -43
  88. package/src/components/UncontrolledTable/components/pagination/styles.tsx +28 -28
  89. package/src/components/UncontrolledTable/components/tbody/index.tsx +33 -33
  90. package/src/components/UncontrolledTable/components/tbody/styles.tsx +32 -32
  91. package/src/components/UncontrolledTable/index.tsx +222 -221
  92. package/src/components/UncontrolledTable/interface.ts +44 -43
  93. package/src/components/UncontrolledTable/styles.tsx +123 -123
  94. package/src/components/UncontrolledTabs/UncontrolledTabs.style.tsx +56 -56
  95. package/src/components/UncontrolledTabs/UncontrolledTabs.tsx +68 -68
  96. package/src/components/index.ts +24 -24
  97. package/src/helpers/alignments.ts +14 -14
  98. package/src/helpers/borders.ts +18 -18
  99. package/src/helpers/colors.ts +258 -258
  100. package/src/helpers/index.ts +5 -5
  101. package/src/helpers/radios.ts +24 -24
  102. package/src/helpers/sizes.ts +72 -72
  103. package/src/hooks/useClickOutside.tsx +18 -18
  104. package/src/index.ts +70 -70
  105. package/src/interfaces/Accordion.ts +12 -12
  106. package/src/interfaces/Avatar.tsx +15 -15
  107. package/src/interfaces/Badge.ts +19 -19
  108. package/src/interfaces/Button.ts +22 -22
  109. package/src/interfaces/Card.ts +11 -11
  110. package/src/interfaces/ChatMessage.ts +12 -12
  111. package/src/interfaces/ChatMessageBalloon.ts +17 -17
  112. package/src/interfaces/CheckBox.ts +27 -27
  113. package/src/interfaces/DatePicker.ts +13 -13
  114. package/src/interfaces/DropDown.ts +14 -14
  115. package/src/interfaces/IconButton.ts +22 -22
  116. package/src/interfaces/Icons.ts +17 -17
  117. package/src/interfaces/Modal.ts +18 -18
  118. package/src/interfaces/Paper.ts +12 -12
  119. package/src/interfaces/ProgressBar.ts +29 -29
  120. package/src/interfaces/RadioGroup.ts +23 -23
  121. package/src/interfaces/RangerSlider.ts +21 -21
  122. package/src/interfaces/Select.ts +17 -17
  123. package/src/interfaces/Tabs.ts +19 -19
  124. package/src/interfaces/Tag.ts +17 -17
  125. package/src/interfaces/TextField.ts +44 -44
  126. package/src/interfaces/TimeLine.ts +11 -11
  127. package/src/interfaces/TimePicker.ts +13 -13
  128. package/src/interfaces/index.ts +23 -23
  129. package/src/providers/NormaProvider.tsx +13 -13
  130. package/src/sample-data-2.json +178 -178
  131. package/src/sample-data.json +177 -177
  132. package/src/stories/Accordion.stories.tsx +65 -65
  133. package/src/stories/Avatar.stories.tsx +123 -123
  134. package/src/stories/Badge.stories.tsx +39 -39
  135. package/src/stories/Box.stories.tsx +35 -35
  136. package/src/stories/Breadcrumb.stories.tsx +44 -44
  137. package/src/stories/Button.stories.tsx +93 -93
  138. package/src/stories/Card.stories.tsx +39 -39
  139. package/src/stories/ChatMessage.stories.tsx +84 -84
  140. package/src/stories/ChatMessageBalloon.stories.tsx +108 -108
  141. package/src/stories/CheckBox.stories.tsx +88 -88
  142. package/src/stories/DateInput.stories.tsx +51 -51
  143. package/src/stories/DatePicker.stories.tsx +50 -50
  144. package/src/stories/DropDown.stories.tsx +57 -57
  145. package/src/stories/IconButton.stories.tsx +78 -78
  146. package/src/stories/Modal.stories.tsx +246 -246
  147. package/src/stories/ModalStatus.stories.tsx +46 -46
  148. package/src/stories/MultiSelectInput.stories.tsx +90 -90
  149. package/src/stories/Paper.stories.tsx +53 -53
  150. package/src/stories/ProgressBar.stories.tsx +116 -116
  151. package/src/stories/RadioGroup.stories.tsx +87 -87
  152. package/src/stories/RangerSlider.stories.tsx +149 -149
  153. package/src/stories/Select.stories.tsx +100 -100
  154. package/src/stories/SelectInput.stories.tsx +78 -78
  155. package/src/stories/Table.stories.tsx +372 -372
  156. package/src/stories/Tabs.stories.tsx +61 -61
  157. package/src/stories/Tag.stories.tsx +56 -56
  158. package/src/stories/Text.stories.tsx +37 -37
  159. package/src/stories/TextField.stories.tsx +310 -310
  160. package/src/stories/TextInput.stories.tsx +52 -52
  161. package/src/stories/TimeLine.stories.tsx +35 -35
  162. package/src/stories/TimePicker.stories.tsx +87 -87
  163. package/src/stories/Title.stories.tsx +43 -43
  164. package/src/stories/UncontrolledTable.stories.tsx +315 -305
  165. package/src/stories/UncontrolledTabs.stories.tsx +63 -63
  166. package/src/styles/globals.scss +17 -17
  167. package/src/types/index.ts +207 -207
  168. package/src/utils/styledBreakpoints.ts +25 -25
  169. package/vite.config.ts +15 -15
@@ -1,221 +1,222 @@
1
- import React, { useState, useMemo, useRef } from 'react';
2
- import * as S from './styles';
3
-
4
- import {
5
- flexRender,
6
- getCoreRowModel,
7
- getSortedRowModel,
8
- useReactTable,
9
- ColumnFiltersState,
10
- TableOptions,
11
- } from '@tanstack/react-table';
12
-
13
- import { Pagination, Header, TBody } from './components';
14
- import { UncontrolledTableProps } from './interface';
15
- import useClickOutside from '../../hooks/useClickOutside';
16
-
17
- const UncontrolledTable = (props: UncontrolledTableProps) => {
18
- const {
19
- data,
20
- columns,
21
- onClick,
22
- onMouseOver,
23
- onMouseOut,
24
- showTotalResults,
25
- showSettings,
26
- onChangePage,
27
- pagination,
28
- totalPages,
29
- showClearFields,
30
- onClearFieldsClick,
31
- onFilterClick,
32
- onSortClick,
33
- customTotalResults,
34
- labels,
35
- tableClassName,
36
- stickyHeader,
37
- } = props;
38
-
39
- const [openFilterDialog, setOpenFilterDialog] = useState('');
40
- const [sorting, setSorting] = useState<any>([]);
41
- const [filterByColumn, setFilterByColumn] = useState<ColumnFiltersState>([]);
42
- const [globalFilters, setGlobalFilters] = useState<any>([]);
43
- const [orderSmallest, setOrderSmallest] = useState(false);
44
- const [orderLargest, setOrderLargest] = useState(false);
45
-
46
- const reactTableConfig = useMemo(() => {
47
- const config: TableOptions<unknown> = {
48
- columns: columns as any,
49
- data,
50
- state: {
51
- sorting: sorting,
52
- columnFilters: filterByColumn,
53
- pagination: pagination,
54
- },
55
- rowCount: totalPages,
56
- getCoreRowModel: getCoreRowModel(),
57
- getSortedRowModel: getSortedRowModel(),
58
- onSortingChange: setSorting,
59
- onColumnFiltersChange: setFilterByColumn,
60
- manualPagination: true,
61
- };
62
-
63
- return config;
64
- }, [data, sorting, filterByColumn, columns, pagination]);
65
-
66
- const table = useReactTable(reactTableConfig);
67
- const filterRef = useRef<HTMLDivElement>(null);
68
-
69
- useClickOutside(filterRef, () => setOpenFilterDialog(''));
70
-
71
- return (
72
- <S.Container>
73
- <Header
74
- table={table}
75
- globalFilters={globalFilters}
76
- orderSmallest={orderSmallest}
77
- orderLargest={orderLargest}
78
- showTotalResults={showTotalResults}
79
- showSettings={showSettings}
80
- setGlobalFilters={setGlobalFilters}
81
- setOrderLargest={setOrderLargest}
82
- setOrderSmallest={setOrderSmallest}
83
- showClearFiels={showClearFields}
84
- customTotalResults={customTotalResults}
85
- clearLabel={labels?.clearFilter}
86
- onClearFieldsClick={() => onClearFieldsClick && onClearFieldsClick()}
87
- />
88
- <S.Table className={tableClassName || ''}>
89
- <S.Thead $sticky={stickyHeader}>
90
- {table.getHeaderGroups().map((headerGroup: any) => (
91
- <S.TableRow key={headerGroup.id}>
92
- {headerGroup.headers.map((header: any) => (
93
- <S.Th key={header.id}>
94
- <S.ColumnContent
95
- onClick={() => {
96
- if (!header?.column?.columnDef?.disableMenu)
97
- setOpenFilterDialog(header.column.columnDef.accessorKey);
98
- }}
99
- >
100
- <S.TextColumn>
101
- {!header.isPlaceholder && flexRender(header.column.columnDef.header, header.getContext())}
102
- </S.TextColumn>
103
- {!header?.column?.columnDef?.disableMenu && (
104
- <S.IconFilterDialog>
105
- <svg fill="#666" focusable="false" aria-hidden="true" viewBox="0 0 24 24">
106
- <path d="m7 10 5 5 5-5z" />
107
- </svg>
108
- </S.IconFilterDialog>
109
- )}
110
- </S.ColumnContent>
111
- {openFilterDialog === header.column.columnDef.accessorKey && (
112
- <S.FilterDialog ref={filterRef}>
113
- <S.ListFilterDialog>
114
- <S.OptionFilterDialog
115
- style={{
116
- background: orderSmallest ? 'rgba(0, 0, 0, 0.04)' : '',
117
- }}
118
- onClick={() => {
119
- onSortClick && onSortClick(header.column.columnDef.accessorKey, 'asc');
120
- setOpenFilterDialog('');
121
- }}
122
- >
123
- <div className="icon">
124
- <svg
125
- fill="#666"
126
- stroke="currentColor"
127
- strokeWidth="1.5"
128
- viewBox="0 0 24 24"
129
- xmlns="http://www.w3.org/2000/svg"
130
- aria-hidden="true"
131
- width="20"
132
- height="20"
133
- >
134
- <path
135
- strokeLinecap="round"
136
- strokeLinejoin="round"
137
- d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75"
138
- />
139
- </svg>
140
- </div>
141
- <p>{labels?.orderAsc || 'Menor primeiro'}</p>
142
- </S.OptionFilterDialog>
143
- <S.OptionFilterDialog
144
- style={{
145
- background: orderLargest ? 'rgba(0, 0, 0, 0.04)' : '',
146
- }}
147
- onClick={() => {
148
- onSortClick && onSortClick(header.column.columnDef.accessorKey, 'desc');
149
- setOpenFilterDialog('');
150
- }}
151
- >
152
- <div className="icon rotate">
153
- <svg
154
- fill="#666"
155
- stroke="currentColor"
156
- strokeWidth="1.5"
157
- viewBox="0 0 24 24"
158
- xmlns="http://www.w3.org/2000/svg"
159
- aria-hidden="true"
160
- width="20"
161
- height="20"
162
- >
163
- <path
164
- strokeLinecap="round"
165
- strokeLinejoin="round"
166
- d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75"
167
- ></path>
168
- </svg>
169
- </div>
170
- <p>{labels?.orderDesc || 'Maior primeiro'}</p>
171
- </S.OptionFilterDialog>
172
- {!header?.column?.columnDef?.nofilter && (
173
- <S.OptionFilterDialog
174
- onClick={() => {
175
- onFilterClick && onFilterClick(header.column.columnDef.accessorKey);
176
- setOpenFilterDialog('');
177
- }}
178
- >
179
- <div className="icon">
180
- <svg
181
- fill="none"
182
- stroke="currentColor"
183
- strokeWidth="1.5"
184
- viewBox="0 0 24 24"
185
- xmlns="http://www.w3.org/2000/svg"
186
- aria-hidden="true"
187
- width="16"
188
- height="16"
189
- >
190
- <path
191
- strokeLinecap="round"
192
- strokeLinejoin="round"
193
- d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z"
194
- ></path>
195
- </svg>
196
- </div>
197
- <p>{labels?.filter || 'Filtrar por'}</p>
198
- </S.OptionFilterDialog>
199
- )}
200
- </S.ListFilterDialog>
201
- </S.FilterDialog>
202
- )}
203
- </S.Th>
204
- ))}
205
- </S.TableRow>
206
- ))}
207
- </S.Thead>
208
- <TBody table={table} onClick={onClick} onMouseOver={onMouseOver} onMouseOut={onMouseOut} />
209
- </S.Table>
210
- {pagination && (
211
- <Pagination
212
- pagination={pagination}
213
- count={totalPages}
214
- onChangePage={(page: number) => onChangePage({ ...pagination, pageIndex: page })}
215
- />
216
- )}
217
- </S.Container>
218
- );
219
- };
220
-
221
- export default UncontrolledTable;
1
+ import React, { useState, useMemo, useRef } from 'react';
2
+ import * as S from './styles';
3
+
4
+ import {
5
+ flexRender,
6
+ getCoreRowModel,
7
+ getSortedRowModel,
8
+ useReactTable,
9
+ ColumnFiltersState,
10
+ TableOptions,
11
+ } from '@tanstack/react-table';
12
+
13
+ import { Pagination, Header, TBody } from './components';
14
+ import { UncontrolledTableProps } from './interface';
15
+ import useClickOutside from '../../hooks/useClickOutside';
16
+
17
+ const UncontrolledTable = (props: UncontrolledTableProps) => {
18
+ const {
19
+ data,
20
+ columns,
21
+ onClick,
22
+ onMouseOver,
23
+ onMouseOut,
24
+ showTotalResults,
25
+ showSettings,
26
+ onChangePage,
27
+ pagination,
28
+ totalPages,
29
+ showClearFields,
30
+ onClearFieldsClick,
31
+ onFilterClick,
32
+ onSortClick,
33
+ customTotalResults,
34
+ labels,
35
+ tableClassName,
36
+ stickyHeader,
37
+ } = props;
38
+
39
+ const [openFilterDialog, setOpenFilterDialog] = useState('');
40
+ const [sorting, setSorting] = useState<any>([]);
41
+ const [filterByColumn, setFilterByColumn] = useState<ColumnFiltersState>([]);
42
+ const [globalFilters, setGlobalFilters] = useState<any>([]);
43
+ const [orderSmallest, setOrderSmallest] = useState(false);
44
+ const [orderLargest, setOrderLargest] = useState(false);
45
+
46
+ const reactTableConfig = useMemo(() => {
47
+ const config: TableOptions<unknown> = {
48
+ columns: columns as any,
49
+ data,
50
+ state: {
51
+ sorting: sorting,
52
+ columnFilters: filterByColumn,
53
+ pagination: pagination,
54
+ },
55
+ rowCount: totalPages,
56
+ getCoreRowModel: getCoreRowModel(),
57
+ getSortedRowModel: getSortedRowModel(),
58
+ onSortingChange: setSorting,
59
+ onColumnFiltersChange: setFilterByColumn,
60
+ manualPagination: true,
61
+ };
62
+
63
+ return config;
64
+ }, [data, sorting, filterByColumn, columns, pagination]);
65
+
66
+ const table = useReactTable(reactTableConfig);
67
+ const filterRef = useRef<HTMLDivElement>(null);
68
+
69
+ useClickOutside(filterRef, () => setOpenFilterDialog(''));
70
+
71
+ return (
72
+ <S.Container>
73
+ <Header
74
+ table={table}
75
+ globalFilters={globalFilters}
76
+ orderSmallest={orderSmallest}
77
+ orderLargest={orderLargest}
78
+ showTotalResults={showTotalResults}
79
+ showSettings={showSettings}
80
+ setGlobalFilters={setGlobalFilters}
81
+ setOrderLargest={setOrderLargest}
82
+ setOrderSmallest={setOrderSmallest}
83
+ showClearFiels={showClearFields}
84
+ customTotalResults={customTotalResults}
85
+ clearLabel={labels?.clearFilter}
86
+ onClearFieldsClick={() => onClearFieldsClick && onClearFieldsClick()}
87
+ customIcons={props.customIcons}
88
+ />
89
+ <S.Table className={tableClassName || ''}>
90
+ <S.Thead $sticky={stickyHeader}>
91
+ {table.getHeaderGroups().map((headerGroup: any) => (
92
+ <S.TableRow key={headerGroup.id}>
93
+ {headerGroup.headers.map((header: any) => (
94
+ <S.Th key={header.id}>
95
+ <S.ColumnContent
96
+ onClick={() => {
97
+ if (!header?.column?.columnDef?.disableMenu)
98
+ setOpenFilterDialog(header.column.columnDef.accessorKey);
99
+ }}
100
+ >
101
+ <S.TextColumn>
102
+ {!header.isPlaceholder && flexRender(header.column.columnDef.header, header.getContext())}
103
+ </S.TextColumn>
104
+ {!header?.column?.columnDef?.disableMenu && (
105
+ <S.IconFilterDialog>
106
+ <svg fill="#666" focusable="false" aria-hidden="true" viewBox="0 0 24 24">
107
+ <path d="m7 10 5 5 5-5z" />
108
+ </svg>
109
+ </S.IconFilterDialog>
110
+ )}
111
+ </S.ColumnContent>
112
+ {openFilterDialog === header.column.columnDef.accessorKey && (
113
+ <S.FilterDialog ref={filterRef}>
114
+ <S.ListFilterDialog>
115
+ <S.OptionFilterDialog
116
+ style={{
117
+ background: orderSmallest ? 'rgba(0, 0, 0, 0.04)' : '',
118
+ }}
119
+ onClick={() => {
120
+ onSortClick && onSortClick(header.column.columnDef.accessorKey, 'asc');
121
+ setOpenFilterDialog('');
122
+ }}
123
+ >
124
+ <div className="icon">
125
+ <svg
126
+ fill="#666"
127
+ stroke="currentColor"
128
+ strokeWidth="1.5"
129
+ viewBox="0 0 24 24"
130
+ xmlns="http://www.w3.org/2000/svg"
131
+ aria-hidden="true"
132
+ width="20"
133
+ height="20"
134
+ >
135
+ <path
136
+ strokeLinecap="round"
137
+ strokeLinejoin="round"
138
+ d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75"
139
+ />
140
+ </svg>
141
+ </div>
142
+ <p>{labels?.orderAsc || 'Menor primeiro'}</p>
143
+ </S.OptionFilterDialog>
144
+ <S.OptionFilterDialog
145
+ style={{
146
+ background: orderLargest ? 'rgba(0, 0, 0, 0.04)' : '',
147
+ }}
148
+ onClick={() => {
149
+ onSortClick && onSortClick(header.column.columnDef.accessorKey, 'desc');
150
+ setOpenFilterDialog('');
151
+ }}
152
+ >
153
+ <div className="icon rotate">
154
+ <svg
155
+ fill="#666"
156
+ stroke="currentColor"
157
+ strokeWidth="1.5"
158
+ viewBox="0 0 24 24"
159
+ xmlns="http://www.w3.org/2000/svg"
160
+ aria-hidden="true"
161
+ width="20"
162
+ height="20"
163
+ >
164
+ <path
165
+ strokeLinecap="round"
166
+ strokeLinejoin="round"
167
+ d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75"
168
+ ></path>
169
+ </svg>
170
+ </div>
171
+ <p>{labels?.orderDesc || 'Maior primeiro'}</p>
172
+ </S.OptionFilterDialog>
173
+ {!header?.column?.columnDef?.nofilter && (
174
+ <S.OptionFilterDialog
175
+ onClick={() => {
176
+ onFilterClick && onFilterClick(header.column.columnDef.accessorKey);
177
+ setOpenFilterDialog('');
178
+ }}
179
+ >
180
+ <div className="icon">
181
+ <svg
182
+ fill="none"
183
+ stroke="currentColor"
184
+ strokeWidth="1.5"
185
+ viewBox="0 0 24 24"
186
+ xmlns="http://www.w3.org/2000/svg"
187
+ aria-hidden="true"
188
+ width="16"
189
+ height="16"
190
+ >
191
+ <path
192
+ strokeLinecap="round"
193
+ strokeLinejoin="round"
194
+ d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z"
195
+ ></path>
196
+ </svg>
197
+ </div>
198
+ <p>{labels?.filter || 'Filtrar por'}</p>
199
+ </S.OptionFilterDialog>
200
+ )}
201
+ </S.ListFilterDialog>
202
+ </S.FilterDialog>
203
+ )}
204
+ </S.Th>
205
+ ))}
206
+ </S.TableRow>
207
+ ))}
208
+ </S.Thead>
209
+ <TBody table={table} onClick={onClick} onMouseOver={onMouseOver} onMouseOut={onMouseOut} />
210
+ </S.Table>
211
+ {pagination && (
212
+ <Pagination
213
+ pagination={pagination}
214
+ count={totalPages}
215
+ onChangePage={(page: number) => onChangePage({ ...pagination, pageIndex: page })}
216
+ />
217
+ )}
218
+ </S.Container>
219
+ );
220
+ };
221
+
222
+ export default UncontrolledTable;
@@ -1,43 +1,44 @@
1
- import { ColumnDef } from '@tanstack/react-table';
2
-
3
- type Labels = {
4
- orderAsc: string;
5
- orderDesc: string;
6
- filter: string;
7
- clearFilter: string;
8
- };
9
-
10
- interface Pagination {
11
- pageIndex: number;
12
- pageSize: number;
13
- }
14
-
15
- export interface UncontrolledTableProps {
16
- data: any;
17
- columns: ColumnDef<ColumnsTable>[];
18
- onClick: any;
19
- onMouseOver: any;
20
- onMouseOut: any;
21
- showTotalResults: boolean;
22
- showSettings: boolean;
23
- pagination?: Pagination;
24
- totalPages: number;
25
- showClearFields?: boolean;
26
- customTotalResults?: string;
27
- onChangePage: (pagination: Pagination) => void;
28
- onClearFieldsClick?: () => void;
29
- onFilterClick?: (column: string) => void;
30
- onSortClick?: (column: string, direction: string) => void;
31
- labels?: Labels;
32
- tableClassName?: string;
33
- stickyHeader?: boolean;
34
- }
35
-
36
- export interface ColumnsTable {
37
- header: string;
38
- accessorKey: string;
39
- type: string;
40
- enableColumnFilter: boolean;
41
- filterFn: string;
42
- nofilter?: boolean;
43
- }
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+
3
+ type Labels = {
4
+ orderAsc: string;
5
+ orderDesc: string;
6
+ filter: string;
7
+ clearFilter: string;
8
+ };
9
+
10
+ interface Pagination {
11
+ pageIndex: number;
12
+ pageSize: number;
13
+ }
14
+
15
+ export interface UncontrolledTableProps {
16
+ data: any;
17
+ columns: ColumnDef<ColumnsTable>[];
18
+ onClick: any;
19
+ onMouseOver: any;
20
+ onMouseOut: any;
21
+ showTotalResults: boolean;
22
+ showSettings: boolean;
23
+ pagination?: Pagination;
24
+ totalPages: number;
25
+ showClearFields?: boolean;
26
+ customTotalResults?: string;
27
+ onChangePage: (pagination: Pagination) => void;
28
+ onClearFieldsClick?: () => void;
29
+ onFilterClick?: (column: string) => void;
30
+ onSortClick?: (column: string, direction: string) => void;
31
+ labels?: Labels;
32
+ tableClassName?: string;
33
+ stickyHeader?: boolean;
34
+ customIcons?: React.ReactNode[];
35
+ }
36
+
37
+ export interface ColumnsTable {
38
+ header: string;
39
+ accessorKey: string;
40
+ type: string;
41
+ enableColumnFilter: boolean;
42
+ filterFn: string;
43
+ nofilter?: boolean;
44
+ }