@charcoal-ui/react 5.5.0-beta.3 → 5.5.1

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": "@charcoal-ui/react",
3
- "version": "5.5.0-beta.3",
3
+ "version": "5.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -54,10 +54,10 @@
54
54
  "react-compiler-runtime": "1.0.0",
55
55
  "react-stately": "^3.26.0",
56
56
  "warning": "^4.0.3",
57
- "@charcoal-ui/foundation": "5.5.0-beta.3",
58
- "@charcoal-ui/icons": "5.5.0-beta.3",
59
- "@charcoal-ui/theme": "5.5.0-beta.3",
60
- "@charcoal-ui/utils": "5.5.0-beta.3"
57
+ "@charcoal-ui/foundation": "5.5.1",
58
+ "@charcoal-ui/theme": "5.5.1",
59
+ "@charcoal-ui/icons": "5.5.1",
60
+ "@charcoal-ui/utils": "5.5.1"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": ">=17.0.0"
@@ -131,3 +131,16 @@ export const LinkPaginationWithLinkProps: StoryObj<typeof Pagination> = {
131
131
  </div>
132
132
  ),
133
133
  }
134
+
135
+ export const ComponentAStory: StoryObj<typeof Pagination> = {
136
+ render: () => {
137
+ return (
138
+ <Pagination
139
+ page={5}
140
+ pageCount={100}
141
+ component="a"
142
+ makeUrl={(p) => `https://example.com?page=${p}`}
143
+ />
144
+ )
145
+ },
146
+ }
@@ -2,7 +2,7 @@ import './index.css'
2
2
 
3
3
  import { usePaginationWindow } from './helper'
4
4
  import { useClassNames } from '../../_lib/useClassNames'
5
- import IconButton from '../IconButton'
5
+ import IconButton, { IconButtonProps } from '../IconButton'
6
6
  import {
7
7
  PaginationContext,
8
8
  usePaginationContext,
@@ -14,9 +14,10 @@ import {
14
14
 
15
15
  type NavButtonProps = {
16
16
  direction: 'prev' | 'next'
17
+ ariaLabel: IconButtonProps['aria-label']
17
18
  }
18
19
 
19
- function NavButton({ direction }: NavButtonProps) {
20
+ function NavButton({ direction, ariaLabel }: NavButtonProps) {
20
21
  'use memo'
21
22
  const {
22
23
  page,
@@ -44,6 +45,7 @@ function NavButton({ direction }: NavButtonProps) {
44
45
  icon={isPrev ? '24/Prev' : '24/Next'}
45
46
  size={size}
46
47
  hidden={disabled}
48
+ aria-label={ariaLabel}
47
49
  {...(isLinkMode && makeUrl
48
50
  ? {
49
51
  component: LinkComponent as 'a',
@@ -122,11 +124,13 @@ function PageItem({ value }: { value: number | string }) {
122
124
  )
123
125
  }
124
126
 
125
- interface CommonProps {
127
+ interface PaginationCommonProps {
126
128
  page: number
127
129
  pageCount: number
128
130
  pageRangeDisplayed?: PageRangeDisplayed
129
131
  size?: Size
132
+ ariaLabelPrev?: string
133
+ ariaLabelNext?: string
130
134
  }
131
135
 
132
136
  type NavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'onChange'>
@@ -150,29 +154,33 @@ type NavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'onChange'>
150
154
  * // Link mode with linkProps (e.g. Next.js scroll)
151
155
  * <Pagination page={1} pageCount={10} makeUrl={(p) => `?page=${p}`} component={Link} linkProps={{ scroll: 'marker' }} />
152
156
  */
153
- export type PaginationProps<T extends React.ElementType = 'a'> = CommonProps &
154
- NavProps &
155
- (
156
- | {
157
- onChange(newPage: number): void
158
- makeUrl?: never
159
- component?: never
160
- linkProps?: undefined
161
- }
162
- | {
163
- makeUrl(page: number): string
164
- onChange?: never
165
- /**
166
- * The component used for link elements. Receives `href`, `className`, and `children`.
167
- * @default 'a'
168
- */
169
- component?: T
170
- /**
171
- * Additional props passed to all link elements (e.g. Next.js Link's scroll, prefetch).
172
- */
173
- linkProps?: Omit<React.ComponentPropsWithoutRef<T>, 'href' | 'children'>
174
- }
175
- )
157
+ export type PaginationProps<T extends React.ElementType = 'a'> =
158
+ PaginationCommonProps &
159
+ NavProps &
160
+ (
161
+ | {
162
+ onChange(newPage: number): void
163
+ makeUrl?: never
164
+ component?: never
165
+ linkProps?: undefined
166
+ }
167
+ | {
168
+ makeUrl(page: number): string
169
+ onChange?: never
170
+ /**
171
+ * The component used for link elements. Receives `href`, `className`, and `children`.
172
+ * @default 'a'
173
+ */
174
+ component?: T
175
+ /**
176
+ * Additional props passed to all link elements (e.g. Next.js Link's scroll, prefetch).
177
+ */
178
+ linkProps?: Omit<
179
+ React.ComponentPropsWithoutRef<T>,
180
+ 'href' | 'children'
181
+ >
182
+ }
183
+ )
176
184
 
177
185
  export default function Pagination<T extends React.ElementType = 'a'>({
178
186
  page,
@@ -184,6 +192,8 @@ export default function Pagination<T extends React.ElementType = 'a'>({
184
192
  component: LinkComponent = 'a' as T,
185
193
  linkProps,
186
194
  className,
195
+ ariaLabelNext = 'Next',
196
+ ariaLabelPrev = 'Previous',
187
197
  ...navProps
188
198
  }: PaginationProps<T>) {
189
199
  'use memo'
@@ -217,11 +227,11 @@ export default function Pagination<T extends React.ElementType = 'a'>({
217
227
  {...navProps}
218
228
  className={classNames}
219
229
  >
220
- <NavButton direction="prev" />
230
+ <NavButton direction="prev" ariaLabel={ariaLabelPrev} />
221
231
  {window.map((p) => (
222
232
  <PageItem key={p} value={p} />
223
233
  ))}
224
- <NavButton direction="next" />
234
+ <NavButton direction="next" ariaLabel={ariaLabelNext} />
225
235
  </nav>
226
236
  </PaginationContext.Provider>
227
237
  )