@cloudscape-design/components 3.0.106 → 3.0.107
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/internal/environment.js +1 -1
- package/package.json +1 -1
- package/pagination/interfaces.d.ts +4 -0
- package/pagination/interfaces.d.ts.map +1 -1
- package/pagination/interfaces.js.map +1 -1
- package/pagination/internal.d.ts.map +1 -1
- package/pagination/internal.js +2 -1
- package/pagination/internal.js.map +1 -1
package/internal/environment.js
CHANGED
package/package.json
CHANGED
|
@@ -23,6 +23,8 @@ export interface PaginationProps {
|
|
|
23
23
|
disabled?: boolean;
|
|
24
24
|
/**
|
|
25
25
|
* Adds aria-labels to the pagination buttons:
|
|
26
|
+
* * `paginationLabel` (string) - Label for the entire pagination group. It allows users to distinguish context
|
|
27
|
+
* * in cases of multiple pagination components in a page.
|
|
26
28
|
* * `previousPageLabel` (string) - Previous page button.
|
|
27
29
|
* * `pageLabel` (number => string) - Individual page button, this function is called for every page number that's rendered.
|
|
28
30
|
* * `nextPageLabel` (string) - Next page button
|
|
@@ -31,6 +33,7 @@ export interface PaginationProps {
|
|
|
31
33
|
* ```
|
|
32
34
|
* {
|
|
33
35
|
* nextPageLabel: 'Next page',
|
|
36
|
+
* paginationLabel: 'Table pagination'
|
|
34
37
|
* previousPageLabel: 'Previous page',
|
|
35
38
|
* pageLabel: pageNumber => `Page ${pageNumber}`
|
|
36
39
|
* }
|
|
@@ -58,6 +61,7 @@ export interface PaginationProps {
|
|
|
58
61
|
export declare namespace PaginationProps {
|
|
59
62
|
interface Labels {
|
|
60
63
|
nextPageLabel?: string;
|
|
64
|
+
paginationLabel?: string;
|
|
61
65
|
previousPageLabel?: string;
|
|
62
66
|
pageLabel?: (pageNumber: number) => string;
|
|
63
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/pagination/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE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E,OAAO,CAAC;QAChC,kBAAkB,EAAE,MAAM,CAAC;KAC5B;IAED,UAAiB,YAAY;QAC3B,gBAAgB,EAAE,MAAM,CAAC;KAC1B;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/pagination/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface PaginationProps {\n /**\n * Index of the current page. The first page has an index of 1.\n */\n currentPageIndex: number;\n\n /**\n * Sets the total number of pages. Only positive integers are allowed.\n */\n pagesCount: number;\n\n /**\n * Sets the pagination variant. It can be either default (when setting it to `false`) or open ended (when setting it\n * to `true`). Default pagination navigates you through the items list. The open-end variant enables you\n * to lazy-load your items because it always displays three dots before the next page icon. The next page button is\n * never disabled. When the user clicks on it but there are no more items to show, the\n * `onNextPageClick` handler is called with `requestedPageAvailable: false` in the event detail.\n */\n openEnd?: boolean;\n\n /**\n * If set to `true`, the pagination links will be disabled. Use it, for example, if you want to prevent the user\n * from changing page before items are loaded.\n */\n disabled?: boolean;\n\n /**\n * Adds aria-labels to the pagination buttons:\n * * `previousPageLabel` (string) - Previous page button.\n * * `pageLabel` (number => string) - Individual page button, this function is called for every page number that's rendered.\n * * `nextPageLabel` (string) - Next page button\n *\n * Example:\n * ```\n * {\n * nextPageLabel: 'Next page',\n * previousPageLabel: 'Previous page',\n * pageLabel: pageNumber => `Page ${pageNumber}`\n * }\n * ```\n */\n ariaLabels?: PaginationProps.Labels;\n\n /**\n * Called when a user interaction causes a pagination change. The event `detail` contains the new `currentPageIndex`.\n */\n onChange?: NonCancelableEventHandler<PaginationProps.ChangeDetail>;\n\n /**\n * Called when the previous page arrow is clicked. The event `detail` contains the following:\n * * `requestedPageAvailable` (boolean) - Always set to `true`.\n * * `requestedPageIndex` (integer) - The index of the requested page.\n */\n onPreviousPageClick?: NonCancelableEventHandler<PaginationProps.PageClickDetail>;\n\n /**\n * Called when the next page arrow is clicked. The event `detail` contains the following:\n * * `requestedPageAvailable` (boolean) - Indicates whether the requested page is available for display.\n * The value can be `false` when the `openEnd` property is set to `true`.\n * * `requestedPageIndex` (integer) - The index of the requested page.\n */\n onNextPageClick?: NonCancelableEventHandler<PaginationProps.PageClickDetail>;\n}\n\nexport namespace PaginationProps {\n export interface Labels {\n nextPageLabel?: string;\n previousPageLabel?: string;\n pageLabel?: (pageNumber: number) => string;\n }\n\n export interface PageClickDetail {\n requestedPageAvailable: boolean;\n requestedPageIndex: number;\n }\n\n export interface ChangeDetail {\n currentPageIndex: number;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/pagination/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface PaginationProps {\n /**\n * Index of the current page. The first page has an index of 1.\n */\n currentPageIndex: number;\n\n /**\n * Sets the total number of pages. Only positive integers are allowed.\n */\n pagesCount: number;\n\n /**\n * Sets the pagination variant. It can be either default (when setting it to `false`) or open ended (when setting it\n * to `true`). Default pagination navigates you through the items list. The open-end variant enables you\n * to lazy-load your items because it always displays three dots before the next page icon. The next page button is\n * never disabled. When the user clicks on it but there are no more items to show, the\n * `onNextPageClick` handler is called with `requestedPageAvailable: false` in the event detail.\n */\n openEnd?: boolean;\n\n /**\n * If set to `true`, the pagination links will be disabled. Use it, for example, if you want to prevent the user\n * from changing page before items are loaded.\n */\n disabled?: boolean;\n\n /**\n * Adds aria-labels to the pagination buttons:\n * * `paginationLabel` (string) - Label for the entire pagination group. It allows users to distinguish context\n * * in cases of multiple pagination components in a page.\n * * `previousPageLabel` (string) - Previous page button.\n * * `pageLabel` (number => string) - Individual page button, this function is called for every page number that's rendered.\n * * `nextPageLabel` (string) - Next page button\n *\n * Example:\n * ```\n * {\n * nextPageLabel: 'Next page',\n * paginationLabel: 'Table pagination'\n * previousPageLabel: 'Previous page',\n * pageLabel: pageNumber => `Page ${pageNumber}`\n * }\n * ```\n */\n ariaLabels?: PaginationProps.Labels;\n\n /**\n * Called when a user interaction causes a pagination change. The event `detail` contains the new `currentPageIndex`.\n */\n onChange?: NonCancelableEventHandler<PaginationProps.ChangeDetail>;\n\n /**\n * Called when the previous page arrow is clicked. The event `detail` contains the following:\n * * `requestedPageAvailable` (boolean) - Always set to `true`.\n * * `requestedPageIndex` (integer) - The index of the requested page.\n */\n onPreviousPageClick?: NonCancelableEventHandler<PaginationProps.PageClickDetail>;\n\n /**\n * Called when the next page arrow is clicked. The event `detail` contains the following:\n * * `requestedPageAvailable` (boolean) - Indicates whether the requested page is available for display.\n * The value can be `false` when the `openEnd` property is set to `true`.\n * * `requestedPageIndex` (integer) - The index of the requested page.\n */\n onNextPageClick?: NonCancelableEventHandler<PaginationProps.PageClickDetail>;\n}\n\nexport namespace PaginationProps {\n export interface Labels {\n nextPageLabel?: string;\n paginationLabel?: string;\n previousPageLabel?: string;\n pageLabel?: (pageNumber: number) => string;\n }\n\n export interface PageClickDetail {\n requestedPageAvailable: boolean;\n requestedPageIndex: number;\n }\n\n export interface ChangeDetail {\n currentPageIndex: number;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/pagination/internal.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/pagination/internal.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA+D/C,aAAK,uBAAuB,GAAG,eAAe,GAAG,0BAA0B,CAAC;AAE5E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,iBAAwB,EACxB,GAAG,IAAI,EACR,EAAE,uBAAuB,eAgFzB"}
|
package/pagination/internal.js
CHANGED
|
@@ -11,6 +11,7 @@ import styles from './styles.css.js';
|
|
|
11
11
|
import { getPaginationState, range } from './utils';
|
|
12
12
|
var defaultAriaLabels = {
|
|
13
13
|
nextPageLabel: '',
|
|
14
|
+
paginationLabel: '',
|
|
14
15
|
previousPageLabel: '',
|
|
15
16
|
pageLabel: function (pageNumber) { return "".concat(pageNumber); }
|
|
16
17
|
};
|
|
@@ -51,7 +52,7 @@ export default function InternalPagination(_a) {
|
|
|
51
52
|
function handlePageClick(requestedPageIndex) {
|
|
52
53
|
fireNonCancelableEvent(onChange, { currentPageIndex: requestedPageIndex });
|
|
53
54
|
}
|
|
54
|
-
return (React.createElement("ul", __assign({}, baseProps, { className: clsx(baseProps.className, styles.root, disabled && styles['root-disabled']), ref: __internalRootRef }),
|
|
55
|
+
return (React.createElement("ul", __assign({ "aria-label": ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.paginationLabel }, baseProps, { className: clsx(baseProps.className, styles.root, disabled && styles['root-disabled']), ref: __internalRootRef }),
|
|
55
56
|
React.createElement(PageButton, { className: styles.arrow, pageIndex: currentPageIndex - 1, ariaLabel: (_c = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.previousPageLabel) !== null && _c !== void 0 ? _c : defaultAriaLabels.nextPageLabel, disabled: disabled || currentPageIndex === 1, onClick: handlePrevPageClick },
|
|
56
57
|
React.createElement(InternalIcon, { name: "angle-left", variant: disabled ? 'disabled' : 'normal' })),
|
|
57
58
|
React.createElement(PageNumber, { pageIndex: 1, isCurrent: currentPageIndex === 1, disabled: disabled, ariaLabel: pageNumberLabelFn(1), onClick: handlePageClick }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/pagination/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIpD,IAAM,iBAAiB,GAAqC;IAC1D,aAAa,EAAE,EAAE;IACjB,iBAAiB,EAAE,EAAE;IACrB,SAAS,EAAE,UAAA,UAAU,IAAI,OAAA,UAAG,UAAU,CAAE,EAAf,CAAe;CACzC,CAAC;AAYF,SAAS,UAAU,CAAC,EAQF;QAPhB,SAAS,eAAA,EACT,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EACjB,QAAQ,cAAA,EACR,OAAO,aAAA;IAEP,IAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,SAAS,WAAW,CAAC,KAAuB;QAC1C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,OAAO,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CACL,4BAAI,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC;QAChC,2CACM,YAAY,IAChB,SAAS,EAAE,IAAI,CACb,SAAS,EACT,MAAM,CAAC,MAAM,EACb,QAAQ,IAAI,MAAM,CAAC,iBAAiB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AAC,YAAY,IAAC,IAAI,EAAC,aAAa,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,GAAI,CACnE,CACV,CACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport InternalIcon from '../icon/internal';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { getBaseProps } from '../internal/base-component';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport styles from './styles.css.js';\nimport { getPaginationState, range } from './utils';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { PaginationProps } from './interfaces';\n\nconst defaultAriaLabels: Required<PaginationProps.Labels> = {\n nextPageLabel: '',\n paginationLabel: '',\n previousPageLabel: '',\n pageLabel: pageNumber => `${pageNumber}`,\n};\n\ninterface PageButtonProps {\n className?: string;\n ariaLabel: string;\n disabled?: boolean;\n pageIndex: number;\n isCurrent?: boolean;\n children?: React.ReactNode;\n onClick: (requestedIndex: number) => void;\n}\n\nfunction PageButton({\n className,\n ariaLabel,\n disabled,\n pageIndex,\n isCurrent = false,\n children,\n onClick,\n}: PageButtonProps) {\n const focusVisible = useFocusVisible();\n function handleClick(event: React.MouseEvent) {\n event.preventDefault();\n onClick(pageIndex);\n }\n return (\n <li className={styles['page-item']}>\n <button\n {...focusVisible}\n className={clsx(\n className,\n styles.button,\n disabled && styles['button-disabled'],\n isCurrent && styles['button-current']\n )}\n type=\"button\"\n aria-label={ariaLabel}\n disabled={disabled}\n onClick={handleClick}\n aria-current={isCurrent}\n >\n {children}\n </button>\n </li>\n );\n}\n\nfunction PageNumber({ pageIndex, ...rest }: PageButtonProps) {\n return (\n <PageButton className={styles['page-number']} pageIndex={pageIndex} {...rest}>\n {pageIndex}\n </PageButton>\n );\n}\n\ntype InternalPaginationProps = PaginationProps & InternalBaseComponentProps;\n\nexport default function InternalPagination({\n openEnd,\n currentPageIndex,\n ariaLabels,\n pagesCount,\n disabled,\n onChange,\n onNextPageClick,\n onPreviousPageClick,\n __internalRootRef = null,\n ...rest\n}: InternalPaginationProps) {\n const baseProps = getBaseProps(rest);\n const pageNumberLabelFn = ariaLabels?.pageLabel ?? defaultAriaLabels.pageLabel;\n const { leftDots, leftIndex, rightIndex, rightDots } = getPaginationState(currentPageIndex, pagesCount, openEnd);\n\n function handlePrevPageClick(requestedPageIndex: number) {\n handlePageClick(requestedPageIndex);\n fireNonCancelableEvent(onPreviousPageClick, {\n requestedPageAvailable: true,\n requestedPageIndex: requestedPageIndex,\n });\n }\n\n function handleNextPageClick(requestedPageIndex: number) {\n handlePageClick(requestedPageIndex);\n fireNonCancelableEvent(onNextPageClick, {\n requestedPageAvailable: currentPageIndex < pagesCount,\n requestedPageIndex: requestedPageIndex,\n });\n }\n\n function handlePageClick(requestedPageIndex: number) {\n fireNonCancelableEvent(onChange, { currentPageIndex: requestedPageIndex });\n }\n\n return (\n <ul\n aria-label={ariaLabels?.paginationLabel}\n {...baseProps}\n className={clsx(baseProps.className, styles.root, disabled && styles['root-disabled'])}\n ref={__internalRootRef}\n >\n <PageButton\n className={styles.arrow}\n pageIndex={currentPageIndex - 1}\n ariaLabel={ariaLabels?.previousPageLabel ?? defaultAriaLabels.nextPageLabel}\n disabled={disabled || currentPageIndex === 1}\n onClick={handlePrevPageClick}\n >\n <InternalIcon name=\"angle-left\" variant={disabled ? 'disabled' : 'normal'} />\n </PageButton>\n <PageNumber\n pageIndex={1}\n isCurrent={currentPageIndex === 1}\n disabled={disabled}\n ariaLabel={pageNumberLabelFn(1)}\n onClick={handlePageClick}\n />\n {leftDots && <li className={styles.dots}>...</li>}\n {range(leftIndex, rightIndex).map(pageIndex => (\n <PageNumber\n key={pageIndex}\n isCurrent={currentPageIndex === pageIndex}\n pageIndex={pageIndex}\n disabled={disabled}\n ariaLabel={pageNumberLabelFn(pageIndex)}\n onClick={handlePageClick}\n />\n ))}\n {rightDots && <li className={styles.dots}>...</li>}\n {!openEnd && pagesCount > 1 && (\n <PageNumber\n isCurrent={currentPageIndex === pagesCount}\n pageIndex={pagesCount}\n disabled={disabled}\n ariaLabel={pageNumberLabelFn(pagesCount)}\n onClick={handlePageClick}\n />\n )}\n <PageButton\n className={styles.arrow}\n pageIndex={currentPageIndex + 1}\n ariaLabel={ariaLabels?.nextPageLabel ?? defaultAriaLabels.nextPageLabel}\n disabled={disabled || (!openEnd && (pagesCount === 0 || currentPageIndex === pagesCount))}\n onClick={handleNextPageClick}\n >\n <InternalIcon name=\"angle-right\" variant={disabled ? 'disabled' : 'normal'} />\n </PageButton>\n </ul>\n );\n}\n"]}
|