w-design-system 0.0.92 → 0.0.93

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,6 +1,6 @@
1
1
  {
2
2
  "name": "w-design-system",
3
- "version": "0.0.92",
3
+ "version": "0.0.93",
4
4
  "main": "dist/w-design-system.umd.js",
5
5
  "module": "dist/w-design-system.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -118,7 +118,12 @@ export const Table = <T extends { id: number }>({
118
118
  onRowClick,
119
119
  }: TableProps<T>) => {
120
120
  const [expandedRows, setExpandedRows] = useState<number[]>([])
121
+ const [selectedRowId, setSelectedRowId] = useState<number | null>(null)
121
122
 
123
+ const handleRowClick = (row: T) => {
124
+ setSelectedRowId(row.id)
125
+ onRowClick?.(row) // dispara a função recebida por props
126
+ }
122
127
  const handleExpandClick = (id: number) => {
123
128
  setExpandedRows(prev => (prev.includes(id) ? prev.filter(x => x !== id) : [...prev, id]))
124
129
  }
@@ -159,7 +164,11 @@ export const Table = <T extends { id: number }>({
159
164
  <Tr
160
165
  striped={striped}
161
166
  clickable={rowClickable && !!onRowClick}
162
- onClick={() => rowClickable && onRowClick && onRowClick(row)}
167
+ onClick={() => rowClickable && onRowClick && handleRowClick(row)}
168
+ style={{
169
+ border: `1px solid ${selectedRowId === row.id ? theme.colors.cyan30 : 'transparent'}`,
170
+ background: selectedRowId === row.id ? theme.colors.cyan10 : 'transparent',
171
+ }}
163
172
  >
164
173
  {columns.map((col, colIndex) => (
165
174
  <Td key={colIndex} width={col.width} align={col.align || 'left'}>
@@ -206,7 +206,16 @@ export const LoadingState: Story = {
206
206
  render: () => (
207
207
  <CardStories title={'Tabela'} subTitle={'tabela-loading'}>
208
208
  <div style={{ width: '900px', height: '800px' }}>
209
- <Table columns={columns} loading={true} height={'100%'} data={[]} />
209
+ <Table
210
+ columns={columns}
211
+ loading={true}
212
+ height={'100%'}
213
+ data={[]}
214
+ onRowClick={student => {
215
+ console.log('Linha selecionada:', student)
216
+ // aqui você pode abrir um modal, preencher formulário, etc.
217
+ }}
218
+ />
210
219
  </div>
211
220
  </CardStories>
212
221
  ),