@open-mercato/ui 0.6.8-develop.7016.1.4ed7b1e49d → 0.6.8-develop.7019.1.f4c01c4b5c
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": "@open-mercato/ui",
|
|
3
|
-
"version": "0.6.8-develop.
|
|
3
|
+
"version": "0.6.8-develop.7019.1.f4c01c4b5c",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -155,14 +155,14 @@
|
|
|
155
155
|
"remark-gfm": "^4.0.1"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
158
|
+
"@open-mercato/shared": "0.6.8-develop.7019.1.f4c01c4b5c",
|
|
159
159
|
"react": ">=18.0.0",
|
|
160
160
|
"react-dom": ">=18.0.0",
|
|
161
161
|
"react-is": ">=18.0.0"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@figma/code-connect": "^1.3.4",
|
|
165
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
165
|
+
"@open-mercato/shared": "0.6.8-develop.7019.1.f4c01c4b5c",
|
|
166
166
|
"@testing-library/dom": "^10.4.1",
|
|
167
167
|
"@testing-library/jest-dom": "^7.0.0",
|
|
168
168
|
"@testing-library/react": "^16.3.1",
|
|
@@ -301,7 +301,7 @@ export type DataTableProps<T extends RowData> = {
|
|
|
301
301
|
emptyState?: React.ReactNode
|
|
302
302
|
error?: React.ReactNode | string | null
|
|
303
303
|
rowActions?: (row: T) => React.ReactNode
|
|
304
|
-
onRowClick?: (row: T) => void
|
|
304
|
+
onRowClick?: (row: T, event: React.MouseEvent<HTMLTableRowElement>) => void
|
|
305
305
|
rowClickActionIds?: string[]
|
|
306
306
|
disableRowClick?: boolean
|
|
307
307
|
bulkActions?: BulkAction<T>[]
|
|
@@ -3467,7 +3467,7 @@ export function DataTable<T extends RowData>({
|
|
|
3467
3467
|
}
|
|
3468
3468
|
|
|
3469
3469
|
if (onRowClick) {
|
|
3470
|
-
onRowClick(row.original as T)
|
|
3470
|
+
onRowClick(row.original as T, e)
|
|
3471
3471
|
} else if (defaultRowAction) {
|
|
3472
3472
|
if (defaultRowAction.href) {
|
|
3473
3473
|
router.push(defaultRowAction.href)
|
|
@@ -128,4 +128,41 @@ describe('DataTable SSR render', () => {
|
|
|
128
128
|
queryClient.clear()
|
|
129
129
|
}
|
|
130
130
|
})
|
|
131
|
+
|
|
132
|
+
it('forwards the click event to onRowClick, and skips it when clicking the actions cell', () => {
|
|
133
|
+
const columns: ColumnDef<Row>[] = [
|
|
134
|
+
{ accessorKey: 'name', header: 'Name' },
|
|
135
|
+
]
|
|
136
|
+
const queryClient = new QueryClient({ defaultOptions: { queries: { gcTime: 0 } } })
|
|
137
|
+
let capturedRowTagName: string | null = null
|
|
138
|
+
const onRowClick = jest.fn((_row: Row, event: React.MouseEvent<HTMLTableRowElement>) => {
|
|
139
|
+
capturedRowTagName = event.currentTarget.tagName
|
|
140
|
+
})
|
|
141
|
+
try {
|
|
142
|
+
render(
|
|
143
|
+
<QueryClientProvider client={queryClient}>
|
|
144
|
+
<I18nProvider locale="en" dict={{}}>
|
|
145
|
+
<DataTable
|
|
146
|
+
columns={columns}
|
|
147
|
+
data={[{ id: '1', name: 'Ada' }]}
|
|
148
|
+
onRowClick={onRowClick}
|
|
149
|
+
rowActions={() => <button type="button">Edit</button>}
|
|
150
|
+
/>
|
|
151
|
+
</I18nProvider>
|
|
152
|
+
</QueryClientProvider>,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
fireEvent.click(screen.getByText('Ada'))
|
|
156
|
+
expect(onRowClick).toHaveBeenCalledTimes(1)
|
|
157
|
+
const [row, event] = onRowClick.mock.calls[0]
|
|
158
|
+
expect(row).toEqual({ id: '1', name: 'Ada' })
|
|
159
|
+
expect(event.type).toBe('click')
|
|
160
|
+
expect(capturedRowTagName).toBe('TR')
|
|
161
|
+
|
|
162
|
+
fireEvent.click(screen.getByText('Edit'))
|
|
163
|
+
expect(onRowClick).toHaveBeenCalledTimes(1)
|
|
164
|
+
} finally {
|
|
165
|
+
queryClient.clear()
|
|
166
|
+
}
|
|
167
|
+
})
|
|
131
168
|
})
|