wca-designsystem 1.0.57 → 1.0.58

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.57",
2
+ "version": "1.0.58",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,42 +1,42 @@
1
- import React from 'react';
2
- import { Checkbox, Switch } from '@mantine/core';
3
- import * as S from './styles';
4
- import { Column } from '.';
5
- import buscar from '../../../assets/imagens/icons/Busca.svg';
6
- import { useCallback } from 'react';
7
- import { theme } from '../../../styles/theme';
8
- import { Capitalize } from '../../../utils/functions';
9
- import InputDeTexto from '../../atomos/InputDeTexto';
10
- import Icone from '../../atomos/Icone';
1
+ import React from 'react'
2
+ import { Checkbox, Switch } from '@mantine/core'
3
+ import * as S from './styles'
4
+ import { Column } from '.'
5
+ import buscar from '../../../assets/imagens/icons/Busca.svg'
6
+ import { useCallback } from 'react'
7
+ import { theme } from '../../../styles/theme'
8
+ import { Capitalize } from '../../../utils/functions'
9
+ import InputDeTexto from '../../atomos/InputDeTexto'
10
+ import Icone from '../../atomos/Icone'
11
11
 
12
12
  type HeaderOptions = {
13
- [key: string | number | symbol]: string; // Um índice genérico para mapear headers a valores
14
- };
13
+ [key: string | number | symbol]: string // Um índice genérico para mapear headers a valores
14
+ }
15
15
 
16
16
  type HeaderTabelaProps<T> = {
17
- data: Array<T>;
18
- columns: Column<T>[];
19
- selectAllChecked?: boolean;
20
- setSelectAllChecked?: React.Dispatch<React.SetStateAction<boolean>>;
21
- setRowSelection?: React.Dispatch<React.SetStateAction<Array<T>>> | undefined;
22
- fixedPosition: Array<String>;
23
- calcStickPosition?: (index: number) => number;
24
- headerSelection?: Array<String>;
25
- color?: string;
26
- tdMinWidth?: string;
27
- toogleFiltros: boolean;
28
- hasSelect?: boolean;
29
- hasExpand?: boolean;
30
- setSimples: React.Dispatch<React.SetStateAction<boolean>>;
31
- setGlobalFilter: React.Dispatch<React.SetStateAction<string>>;
32
- setPagination: React.Dispatch<any>;
17
+ data: Array<T>
18
+ columns: Column<T>[]
19
+ selectAllChecked?: boolean
20
+ setSelectAllChecked?: React.Dispatch<React.SetStateAction<boolean>>
21
+ setRowSelection?: React.Dispatch<React.SetStateAction<Array<T>>> | undefined
22
+ fixedPosition: Array<String>
23
+ calcStickPosition?: (index: number) => number
24
+ headerSelection?: Array<String>
25
+ color?: string
26
+ tdMinWidth?: string
27
+ toogleFiltros: boolean
28
+ hasSelect?: boolean
29
+ hasExpand?: boolean
30
+ setSimples: React.Dispatch<React.SetStateAction<boolean>>
31
+ setGlobalFilter: React.Dispatch<React.SetStateAction<string>>
32
+ setPagination: React.Dispatch<any>
33
33
  setFiltrosPor: React.Dispatch<
34
34
  React.SetStateAction<{
35
- value: string;
36
- label: string;
35
+ value: string
36
+ label: string
37
37
  }>
38
- >;
39
- };
38
+ >
39
+ }
40
40
  const HeaderTabela = <T,>({
41
41
  data,
42
42
  selectAllChecked,
@@ -59,44 +59,45 @@ const HeaderTabela = <T,>({
59
59
  const coloredHeader = useCallback(
60
60
  (key: string | number | symbol) => {
61
61
  if (!headerSelection) {
62
- return { background: color, color: theme.colors.white! };
62
+ return { background: color, color: theme.colors.white! }
63
63
  }
64
64
 
65
65
  const isHeaderSelect = headerSelection?.some(
66
- headerSelect => headerSelect === key
67
- );
66
+ (headerSelect) => headerSelect === key
67
+ )
68
68
 
69
69
  if (isHeaderSelect) {
70
- return { background: color!, color: theme.colors.white };
70
+ return { background: color!, color: theme.colors.white }
71
71
  } else {
72
- return { background: theme.colors.white, color: color! };
72
+ return { background: theme.colors.white, color: color! }
73
73
  }
74
74
  },
75
75
  [headerSelection]
76
- );
76
+ )
77
77
 
78
78
  const handleSelectAll = useCallback(
79
79
  (checked: boolean) => {
80
- setSelectAllChecked?.(checked);
80
+ setSelectAllChecked?.(checked)
81
81
 
82
82
  if (checked) {
83
- setRowSelection!(data); // Seleciona todos os dados
83
+ setRowSelection!(data) // Seleciona todos os dados
84
84
  } else {
85
- setRowSelection!([]); // Desmarca todos
85
+ setRowSelection!([]) // Desmarca todos
86
86
  }
87
87
  },
88
88
  [data, setRowSelection]
89
- );
89
+ )
90
90
 
91
- const renderHeaderOptions = useCallback((header: string | number | symbol):
92
- | string
93
- | undefined => {
94
- const especialHeaders: HeaderOptions = {
95
- ativo: 'Status',
96
- };
91
+ const renderHeaderOptions = useCallback(
92
+ (header: string | number | symbol): string | undefined => {
93
+ const especialHeaders: HeaderOptions = {
94
+ ativo: 'Status',
95
+ }
97
96
 
98
- return especialHeaders[header] ?? Capitalize(String(header));
99
- }, []);
97
+ return especialHeaders[header] ?? Capitalize(String(header))
98
+ },
99
+ []
100
+ )
100
101
  return (
101
102
  <S.TabelaHeader color={color}>
102
103
  <tr>
@@ -108,21 +109,21 @@ const HeaderTabela = <T,>({
108
109
  color={color}
109
110
  type="checkbox"
110
111
  checked={selectAllChecked}
111
- onChange={e => handleSelectAll(e.target.checked)}
112
+ onChange={(e) => handleSelectAll(e.target.checked)}
112
113
  />
113
114
  </th>
114
115
  )}
115
116
  {columns.map((header, index) => {
116
117
  if (header.key === 'expand')
117
- return <th key={index} className="expand"></th>;
118
+ return <th key={index} className="expand"></th>
118
119
  if (header.key === 'select')
119
- return <React.Fragment key={index}></React.Fragment>;
120
+ return <React.Fragment key={index}></React.Fragment>
120
121
  if (header.key !== 'acoes') {
121
122
  return (
122
123
  <th
123
124
  key={index}
124
125
  className={
125
- fixedPosition?.some(fixed => header.key === fixed)
126
+ fixedPosition?.some((fixed) => header.key === fixed)
126
127
  ? 'sticky'
127
128
  : ''
128
129
  }
@@ -130,7 +131,7 @@ const HeaderTabela = <T,>({
130
131
  minWidth: tdMinWidth,
131
132
  background: coloredHeader(header.key).background,
132
133
  color: coloredHeader(header.key).color,
133
- left: fixedPosition?.some(fixed => header.key === fixed)
134
+ left: fixedPosition?.some((fixed) => header.key === fixed)
134
135
  ? calcStickPosition!(index)
135
136
  : 0,
136
137
  }}
@@ -142,14 +143,14 @@ const HeaderTabela = <T,>({
142
143
  defaultChecked
143
144
  label="ativo"
144
145
  color={color}
145
- onChange={e => {
146
- setSimples(false);
146
+ onChange={(e) => {
147
+ setSimples(false)
147
148
  setFiltrosPor({
148
149
  label: 'Ativo',
149
150
  value: 'ativo',
150
- });
151
- setGlobalFilter(String(e.currentTarget.checked));
152
- setPagination({ pageIndex: 1, pageSize: 10 });
151
+ })
152
+ setGlobalFilter(String(e.currentTarget.checked))
153
+ setPagination({ pageIndex: 1, pageSize: 10 })
153
154
  }}
154
155
  />
155
156
  ) : (
@@ -160,16 +161,16 @@ const HeaderTabela = <T,>({
160
161
  }
161
162
  tipo="table"
162
163
  placeholder={`Pesquisar por: ${header.header}`}
163
- onChange={e => {
164
- setPagination({ pageIndex: 1, pageSize: 10 });
164
+ onChange={(e) => {
165
+ setPagination({ pageIndex: 1, pageSize: 10 })
165
166
  setFiltrosPor({
166
167
  label: header.header,
167
168
  value:
168
169
  header.key === 'nome'
169
170
  ? 'nomeCompleto'
170
171
  : String(header.key),
171
- });
172
- setGlobalFilter(e.currentTarget.value);
172
+ })
173
+ setGlobalFilter(e.currentTarget.value)
173
174
  }}
174
175
  leftSection={<Icone fill={color} svg={buscar} />}
175
176
  />
@@ -179,7 +180,7 @@ const HeaderTabela = <T,>({
179
180
  <>{renderHeaderOptions(header.header)}</>
180
181
  )}
181
182
  </th>
182
- );
183
+ )
183
184
  } else {
184
185
  return (
185
186
  <th
@@ -190,14 +191,14 @@ const HeaderTabela = <T,>({
190
191
  right: header.key === 'mrt-row-actions' ? '0' : undefined,
191
192
  }}
192
193
  >
193
- <p>Ações</p>
194
+ Ações
194
195
  </th>
195
- );
196
+ )
196
197
  }
197
198
  })}
198
199
  </tr>
199
200
  </S.TabelaHeader>
200
- );
201
- };
201
+ )
202
+ }
202
203
 
203
- export default HeaderTabela;
204
+ export default HeaderTabela