Skip to content

Commit 3ec255f

Browse files
committed
Revert "Shuffle @oxide/pagination files (#1970)"
3eebf49
1 parent 3eebf49 commit 3ec255f

File tree

5 files changed

+12
-52
lines changed

5 files changed

+12
-52
lines changed

libs/pagination/Pagination.tsx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8-
import { useState } from 'react'
98
import tunnel from 'tunnel-rat'
109

1110
import {
@@ -30,28 +29,3 @@ export function Pagination({ inline = false, ...props }: PaginationProps) {
3029
}
3130

3231
Pagination.Target = Tunnel.Out
33-
34-
type PageToken = string | undefined
35-
36-
export function usePagination() {
37-
const [prevPages, setPrevPages] = useState<PageToken[]>([])
38-
const [currentPage, setCurrentPage] = useState<PageToken>()
39-
40-
const goToPrevPage = () => {
41-
const prevPage = prevPages.pop()
42-
setCurrentPage(prevPage)
43-
setPrevPages(prevPages)
44-
}
45-
46-
const goToNextPage = (nextPageToken: string) => {
47-
setPrevPages([...prevPages, currentPage])
48-
setCurrentPage(nextPageToken)
49-
}
50-
51-
return {
52-
currentPage,
53-
goToNextPage,
54-
goToPrevPage,
55-
hasPrev: prevPages.length > 0,
56-
}
57-
}

libs/pagination/__tests__/use-pagination.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { act, renderHook } from '@testing-library/react'
99
import { describe, expect, it } from 'vitest'
1010

11-
import { usePagination } from '../index.tsx'
11+
import { usePagination } from '../use-pagination'
1212

1313
describe('usePagination', () => {
1414
it('starts with empty state', () => {

libs/pagination/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
5+
*
6+
* Copyright Oxide Computer Company
7+
*/
8+
9+
export * from './Pagination'
10+
export * from './use-pagination'
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,6 @@
66
* Copyright Oxide Computer Company
77
*/
88
import { useState } from 'react'
9-
import tunnel from 'tunnel-rat'
10-
11-
import {
12-
Pagination as UIPagination,
13-
type PaginationProps as UIPaginationProps,
14-
} from '@oxide/ui'
15-
16-
const Tunnel = tunnel('pagination')
17-
18-
interface PaginationProps extends UIPaginationProps {
19-
/** If true pagination will be rendered wherever `Pagination.Target` is included */
20-
inline?: boolean
21-
}
22-
export function Pagination({ inline = false, ...props }: PaginationProps) {
23-
if (inline) return <UIPagination {...props} />
24-
25-
return (
26-
<Tunnel.In>
27-
<UIPagination className="gutter h-14 py-5" {...props} />
28-
</Tunnel.In>
29-
)
30-
}
31-
32-
Pagination.Target = Tunnel.Out
339

3410
type PageToken = string | undefined
3511

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@oxide/ui": ["libs/ui/index.ts"],
2020
"@oxide/util": ["libs/util/index.ts"],
2121
"@oxide/table": ["libs/table/index.ts"],
22-
"@oxide/pagination": ["libs/pagination/index.tsx"]
22+
"@oxide/pagination": ["libs/pagination/index.ts"]
2323
},
2424
"resolveJsonModule": true,
2525
"rootDir": ".",

0 commit comments

Comments
 (0)