@open-mercato/ui 0.6.8-develop.6977.1.5041da373e → 0.6.8-develop.6981.1.5c7cff2f3b

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.6977.1.5041da373e",
3
+ "version": "0.6.8-develop.6981.1.5c7cff2f3b",
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.6977.1.5041da373e",
158
+ "@open-mercato/shared": "0.6.8-develop.6981.1.5c7cff2f3b",
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.6977.1.5041da373e",
165
+ "@open-mercato/shared": "0.6.8-develop.6981.1.5c7cff2f3b",
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",
@@ -295,6 +295,8 @@ export type DataTableProps<T extends RowData> = {
295
295
  sorting?: SortingState
296
296
  onSortingChange?: (s: SortingState) => void
297
297
  pagination?: PaginationProps
298
+ /** Render the query duration in the pagination footer. Set to false for a count-only footer. */
299
+ showQueryTime?: boolean
298
300
  isLoading?: boolean
299
301
  emptyState?: React.ReactNode
300
302
  error?: React.ReactNode | string | null
@@ -1206,6 +1208,7 @@ export function DataTable<T extends RowData>({
1206
1208
  sorting: sortingProp,
1207
1209
  onSortingChange,
1208
1210
  pagination,
1211
+ showQueryTime = true,
1209
1212
  isLoading,
1210
1213
  emptyState,
1211
1214
  error,
@@ -2615,7 +2618,7 @@ export function DataTable<T extends RowData>({
2615
2618
  const effectiveDuration = (typeof durationMs === 'number' && Number.isFinite(durationMs) && durationMs >= 0)
2616
2619
  ? durationMs
2617
2620
  : measuredDurationMs ?? undefined
2618
- const durationLabel = formatDurationLabel(effectiveDuration)
2621
+ const durationLabel = showQueryTime ? formatDurationLabel(effectiveDuration) : ''
2619
2622
  const normalizedCacheStatus = cacheStatus === 'hit' || cacheStatus === 'miss' ? cacheStatus : null
2620
2623
  const cacheBadge = normalizedCacheStatus ? (
2621
2624
  <span
@@ -2669,7 +2672,7 @@ export function DataTable<T extends RowData>({
2669
2672
  />
2670
2673
  </div>
2671
2674
  )
2672
- }, [pagination, measuredDurationMs, scrollTableIntoView, t])
2675
+ }, [pagination, showQueryTime, measuredDurationMs, scrollTableIntoView, t])
2673
2676
 
2674
2677
  // Auto filters: fetch custom field defs when requested
2675
2678
  const resolvedEntityIds = React.useMemo(() => {
@@ -0,0 +1,70 @@
1
+ /** @jest-environment jsdom */
2
+ import * as React from 'react'
3
+ import { renderToString } from 'react-dom/server'
4
+ import { DataTable } from '../DataTable'
5
+ import type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'
6
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
7
+ import { I18nProvider } from '@open-mercato/shared/lib/i18n/context'
8
+
9
+ jest.mock('next/navigation', () => ({
10
+ useRouter: () => ({ push: jest.fn(), replace: jest.fn(), prefetch: jest.fn() }),
11
+ }))
12
+
13
+ jest.mock('../injection/useInjectionDataWidgets', () => ({
14
+ useInjectionDataWidgets: () => ({ widgets: [], isLoading: false }),
15
+ }))
16
+
17
+ type Row = { id: string; name: string }
18
+
19
+ function renderFooter(showQueryTime?: boolean): string {
20
+ const columns: ColumnDef<Row>[] = [
21
+ { accessorKey: 'name', header: 'Name' },
22
+ ]
23
+ const queryClient = new QueryClient({ defaultOptions: { queries: { gcTime: 0 } } })
24
+ try {
25
+ return renderToString(
26
+ React.createElement(
27
+ QueryClientProvider as any,
28
+ { client: queryClient },
29
+ React.createElement(
30
+ I18nProvider as any,
31
+ { locale: 'en', dict: {} },
32
+ React.createElement(DataTable as any, {
33
+ columns,
34
+ data: [{ id: '1', name: 'Ada' }],
35
+ ...(showQueryTime === undefined ? {} : { showQueryTime }),
36
+ pagination: {
37
+ page: 1,
38
+ pageSize: 20,
39
+ total: 1,
40
+ totalPages: 1,
41
+ durationMs: 142,
42
+ onPageChange: () => {},
43
+ },
44
+ }),
45
+ ),
46
+ )
47
+ )
48
+ } finally {
49
+ queryClient.clear()
50
+ }
51
+ }
52
+
53
+ describe('DataTable showQueryTime', () => {
54
+ it('renders the query duration in the footer by default', () => {
55
+ const html = renderFooter(undefined)
56
+ expect(html).toContain('Showing 1 to 1 of 1 results in 142ms')
57
+ })
58
+
59
+ it('renders the count-only footer when showQueryTime is false', () => {
60
+ const html = renderFooter(false)
61
+ expect(html).toContain('Showing 1 to 1 of 1 results')
62
+ expect(html).not.toContain('142ms')
63
+ expect(html).not.toContain('results in')
64
+ })
65
+
66
+ it('renders the query duration when showQueryTime is explicitly true', () => {
67
+ const html = renderFooter(true)
68
+ expect(html).toContain('Showing 1 to 1 of 1 results in 142ms')
69
+ })
70
+ })