From 756d2e429dca283cbb47ac7a4b73b68d8a3f6cf3 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 1 Nov 2021 15:25:34 -0400
Subject: [PATCH 01/21] Fix console error of Custom table example
---
src-docs/src/views/tables/custom/custom.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/tables/custom/custom.js b/src-docs/src/views/tables/custom/custom.js
index a906a22b0da..e48bf46e856 100644
--- a/src-docs/src/views/tables/custom/custom.js
+++ b/src-docs/src/views/tables/custom/custom.js
@@ -756,7 +756,7 @@ export default class extends Component {
Date: Mon, 1 Nov 2021 17:01:15 -0400
Subject: [PATCH 02/21] [EuiPagination] Allowing `null` if `pageCount` is
unknown
---
.../in_memory_table.test.tsx.snap | 150 ++---
.../__snapshots__/pagination.test.tsx.snap | 543 ++++++++++++++++++
src/components/pagination/pagination.test.tsx | 34 ++
src/components/pagination/pagination.tsx | 390 ++++++++-----
4 files changed, 891 insertions(+), 226 deletions(-)
diff --git a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
index 43e8529e7a3..3b1af414703 100644
--- a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
+++ b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
@@ -485,56 +485,64 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
aria-label="Pagination for table: "
className="euiPagination"
>
-
-
-
-
-
-
-
-
+ type="arrowLeft"
+ >
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+ type="arrowRight"
+ >
+
+
+
+
+
-
+
diff --git a/src/components/pagination/__snapshots__/pagination.test.tsx.snap b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
index 4e4fcc5c9f4..606a7c2bc47 100644
--- a/src/components/pagination/__snapshots__/pagination.test.tsx.snap
+++ b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
@@ -63,3 +63,546 @@ exports[`EuiPagination is rendered 1`] = `
`;
+
+exports[`EuiPagination props activePage is rendered 1`] = `
+
+`;
+
+exports[`EuiPagination props aria-controls is rendered 1`] = `
+
+`;
+
+exports[`EuiPagination props compressed is rendered 1`] = `
+
+`;
+
+exports[`EuiPagination props pageCount can be null 1`] = `
+
+`;
+
+exports[`EuiPagination props pageCount is rendered 1`] = `
+
+`;
diff --git a/src/components/pagination/pagination.test.tsx b/src/components/pagination/pagination.test.tsx
index 9a817f8eb1f..4afed958c97 100644
--- a/src/components/pagination/pagination.test.tsx
+++ b/src/components/pagination/pagination.test.tsx
@@ -18,4 +18,38 @@ describe('EuiPagination', () => {
expect(component).toMatchSnapshot();
});
+
+ describe('props', () => {
+ describe('pageCount', () => {
+ test('is rendered', () => {
+ const component = render( );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('can be null', () => {
+ const component = render( );
+
+ expect(component).toMatchSnapshot();
+ });
+ });
+
+ test('activePage is rendered', () => {
+ const component = render( );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('compressed is rendered', () => {
+ const component = render( );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('aria-controls is rendered', () => {
+ const component = render( );
+
+ expect(component).toMatchSnapshot();
+ });
+ });
});
diff --git a/src/components/pagination/pagination.tsx b/src/components/pagination/pagination.tsx
index 9d52aa4f156..130e3f3d4f3 100644
--- a/src/components/pagination/pagination.tsx
+++ b/src/components/pagination/pagination.tsx
@@ -25,8 +25,9 @@ type SafeClickHandler = (e: MouseEvent, pageIndex: number) => void;
export interface EuiPaginationProps {
/**
* The total number of pages.
+ * Pass `null` if total count in unknown.
*/
- pageCount?: number;
+ pageCount?: number | null;
/**
* The current page using a zero based index.
@@ -42,7 +43,7 @@ export interface EuiPaginationProps {
compressed?: boolean;
/**
- * If passed in, passes value through to each button to set aria-controls
+ * If passed in, passes value through to each button to set aria-controls.
*/
'aria-controls'?: string;
}
@@ -72,40 +73,230 @@ export const EuiPagination: FunctionComponent = ({
onPageClick(pageIndex);
};
- const sharedButtonProps = { activePage, pageCount, ariaControls, safeClick };
-
const classes = classNames('euiPagination', className);
const hasControl = ariaControls !== undefined;
- const pages = [];
- const firstPageInRange = Math.max(
- 0,
- Math.min(
- activePage - NUMBER_SURROUNDING_PAGES,
- pageCount - MAX_VISIBLE_PAGES
- )
+
+ const nextButton = (
+
);
- const lastPageInRange = Math.min(
- pageCount,
- firstPageInRange + MAX_VISIBLE_PAGES
+
+ const previousButton = (
+
);
- for (let i = firstPageInRange, index = 0; i < lastPageInRange; i++, index++) {
- pages.push(
-
- );
+ let centerPageCount;
+
+ if (pageCount) {
+ const sharedButtonProps = {
+ activePage,
+ ariaControls,
+ safeClick,
+ pageCount,
+ };
+
+ if (compressed) {
+ centerPageCount = (
+
+
+
+ ),
+ total: (
+
+ ),
+ }}
+ />
+
+
+ );
+ } else {
+ const pages = [];
+
+ const firstPageInRange = Math.max(
+ 0,
+ Math.min(
+ activePage - NUMBER_SURROUNDING_PAGES,
+ pageCount - MAX_VISIBLE_PAGES
+ )
+ );
+ const lastPageInRange = Math.min(
+ pageCount,
+ firstPageInRange + MAX_VISIBLE_PAGES
+ );
+
+ for (
+ let i = firstPageInRange, index = 0;
+ i < lastPageInRange;
+ i++, index++
+ ) {
+ pages.push(
+
+ );
+ }
+
+ const firstPageButtons = [];
+
+ if (firstPageInRange > 0) {
+ firstPageButtons.push(
+
+ );
+
+ if (firstPageInRange > 1 && firstPageInRange !== 2) {
+ firstPageButtons.push(
+
+ {(firstRangeAriaLabel: string) => (
+
+ …
+
+ )}
+
+ );
+ } else if (firstPageInRange === 2) {
+ firstPageButtons.push(
+
+ );
+ }
+ }
+
+ const lastPageButtons = [];
+
+ if (lastPageInRange < pageCount) {
+ if (lastPageInRange + 1 === pageCount - 1) {
+ lastPageButtons.push(
+
+ );
+ } else if (lastPageInRange < pageCount - 1) {
+ lastPageButtons.push(
+
+ {(lastRangeAriaLabel: string) => (
+
+ …
+
+ )}
+
+ );
+ }
+
+ lastPageButtons.push(
+
+ );
+ }
+
+ const selectablePages = pages;
+
+ const accessibleName = {
+ ...(rest['aria-label'] && { 'aria-label': rest['aria-label'] }),
+ ...(rest['aria-labelledby'] && {
+ 'aria-labelledby': rest['aria-labelledby'],
+ }),
+ };
+
+ centerPageCount = (
+
+ {firstPageButtons}
+ {selectablePages}
+ {lastPageButtons}
+
+ );
+ }
}
+ return (
+
+ {previousButton}
+ {centerPageCount}
+ {nextButton}
+
+ );
+};
+
+const PaginationButtonPrevious = ({
+ hasControl,
+ activePage,
+ disabled,
+ ariaControls,
+ safeClick,
+}: {
+ hasControl?: boolean;
+ activePage: number;
+ disabled?: boolean;
+ ariaControls?: string;
+ safeClick: SafeClickHandler;
+}) => {
let prevPageButtonProps = {};
- if (hasControl && activePage !== 0) {
+ if (hasControl && !disabled) {
prevPageButtonProps = {
'aria-controls': ariaControls,
href: `#${ariaControls}`,
};
} else {
- prevPageButtonProps = { disabled: activePage === 0 };
+ prevPageButtonProps = { disabled };
}
- const previousButton = (
+ return (
= ({
onClick={(e: MouseEvent) => safeClick(e, activePage - 1)}
iconType="arrowLeft"
color="text"
- aria-label={
- activePage === 0 ? disabledPreviousPage : previousPage
- }
+ aria-label={disabled ? disabledPreviousPage : previousPage}
data-test-subj="pagination-button-previous"
{...prevPageButtonProps}
/>
@@ -132,90 +321,32 @@ export const EuiPagination: FunctionComponent = ({
)}
);
+};
- const firstPageButtons = [];
-
- if (firstPageInRange > 0) {
- firstPageButtons.push(
-
- );
-
- if (firstPageInRange > 1 && firstPageInRange !== 2) {
- firstPageButtons.push(
-
- {(firstRangeAriaLabel: string) => (
-
- …
-
- )}
-
- );
- } else if (firstPageInRange === 2) {
- firstPageButtons.push(
-
- );
- }
- }
-
- const lastPageButtons = [];
-
- if (lastPageInRange < pageCount) {
- if (lastPageInRange + 1 === pageCount - 1) {
- lastPageButtons.push(
-
- );
- } else if (lastPageInRange < pageCount - 1) {
- lastPageButtons.push(
-
- {(lastRangeAriaLabel: string) => (
-
- …
-
- )}
-
- );
- }
-
- lastPageButtons.push(
-
- );
- }
-
+const PaginationButtonNext = ({
+ hasControl,
+ activePage,
+ disabled,
+ ariaControls,
+ safeClick,
+}: {
+ hasControl?: boolean;
+ activePage: number;
+ disabled?: boolean;
+ ariaControls?: string;
+ safeClick: SafeClickHandler;
+}) => {
let nextPageButtonProps = {};
- if (hasControl && activePage !== pageCount - 1) {
+ if (hasControl && !disabled) {
nextPageButtonProps = {
'aria-controls': ariaControls,
href: `#${ariaControls}`,
};
} else {
- nextPageButtonProps = { disabled: activePage === pageCount - 1 };
+ nextPageButtonProps = { disabled };
}
- const nextButton = (
+ return (
= ({
safeClick(e, activePage + 1)}
iconType="arrowRight"
- aria-label={
- activePage === pageCount - 1 ? disabledNextPage : nextPage
- }
+ aria-label={disabled ? disabledNextPage : nextPage}
color="text"
data-test-subj="pagination-button-next"
{...nextPageButtonProps}
@@ -239,63 +368,6 @@ export const EuiPagination: FunctionComponent = ({
)}
);
-
- const selectablePages = pages;
-
- if (compressed) {
- const firstPageButtonCompressed = (
-
- );
- const lastPageButtonCompressed = (
-
- );
-
- return (
-
- {previousButton}
-
-
-
-
-
- {nextButton}
-
- );
- }
-
- const accessibleName = {
- ...(rest['aria-label'] && { 'aria-label': rest['aria-label'] }),
- ...(rest['aria-labelledby'] && {
- 'aria-labelledby': rest['aria-labelledby'],
- }),
- };
-
- return (
-
- {previousButton}
-
- {firstPageButtons}
- {selectablePages}
- {lastPageButtons}
-
- {nextButton}
-
- );
};
const PaginationButtonWrapper = ({
From faf9b6dcf8f3de210adb2eb732778015ef96e0f4 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 1 Nov 2021 17:18:10 -0400
Subject: [PATCH 03/21] =?UTF-8?q?[EuiPagination]=20Added=20tooltip=20aroun?=
=?UTF-8?q?d=20prev/next=20buttons=20and=20added=20`'arrows=E2=80=99`=20op?=
=?UTF-8?q?tion=20for=20`compressed`?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../in_memory_table.test.tsx.snap | 157 ++++---
.../__snapshots__/data_grid.test.tsx.snap | 62 +--
.../__snapshots__/pagination.test.tsx.snap | 397 +++++++++++-------
src/components/pagination/pagination.test.tsx | 13 +-
src/components/pagination/pagination.tsx | 46 +-
.../table_pagination.test.tsx.snap | 112 ++---
6 files changed, 475 insertions(+), 312 deletions(-)
diff --git a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
index 3b1af414703..79f680958a4 100644
--- a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
+++ b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
@@ -505,41 +505,58 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
default="Previous page"
token="euiPagination.disabledPreviousPage"
>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -740,39 +757,55 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
default="Next page"
token="euiPagination.disabledNextPage"
>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap b/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
index 27962a9b854..8321d16cf54 100644
--- a/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
+++ b/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
@@ -43,21 +43,25 @@ exports[`EuiDataGrid pagination renders 1`] = `
aria-label="Pagination for preceding grid: test grid"
class="euiPagination"
>
-
-
-
+
+
+
+
-
-
-
+
+
+
+
diff --git a/src/components/pagination/__snapshots__/pagination.test.tsx.snap b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
index 606a7c2bc47..04ee83b25aa 100644
--- a/src/components/pagination/__snapshots__/pagination.test.tsx.snap
+++ b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
@@ -6,20 +6,24 @@ exports[`EuiPagination is rendered 1`] = `
class="euiPagination testClass1 testClass2"
data-test-subj="test subject string"
>
-
-
-
+
+
+
+
-
-
-
+
+
+
+
`;
@@ -68,19 +76,23 @@ exports[`EuiPagination props activePage is rendered 1`] = `
`;
@@ -273,20 +289,24 @@ exports[`EuiPagination props aria-controls is rendered 1`] = `
`;
-exports[`EuiPagination props compressed is rendered 1`] = `
+exports[`EuiPagination props compressed is rendered 1`] = `
+`;
+
+exports[`EuiPagination props compressed arrows is rendered 1`] = `
+
`;
@@ -411,33 +486,41 @@ exports[`EuiPagination props pageCount can be null 1`] = `
`;
@@ -445,20 +528,24 @@ exports[`EuiPagination props pageCount is rendered 1`] = `
`;
diff --git a/src/components/pagination/pagination.test.tsx b/src/components/pagination/pagination.test.tsx
index 4afed958c97..0f3fe573594 100644
--- a/src/components/pagination/pagination.test.tsx
+++ b/src/components/pagination/pagination.test.tsx
@@ -40,10 +40,17 @@ describe('EuiPagination', () => {
expect(component).toMatchSnapshot();
});
- test('compressed is rendered', () => {
- const component = render( );
+ describe('compressed', () => {
+ test(' is rendered', () => {
+ const component = render( );
- expect(component).toMatchSnapshot();
+ expect(component).toMatchSnapshot();
+ });
+ test('arrows is rendered', () => {
+ const component = render( );
+
+ expect(component).toMatchSnapshot();
+ });
});
test('aria-controls is rendered', () => {
diff --git a/src/components/pagination/pagination.tsx b/src/components/pagination/pagination.tsx
index 130e3f3d4f3..14403926199 100644
--- a/src/components/pagination/pagination.tsx
+++ b/src/components/pagination/pagination.tsx
@@ -15,6 +15,7 @@ import { EuiButtonIcon } from '../button';
import { EuiI18n } from '../i18n';
import { EuiText } from '../text';
import { EuiHideFor } from '../responsive';
+import { EuiToolTip } from '../tool_tip';
const MAX_VISIBLE_PAGES = 5;
const NUMBER_SURROUNDING_PAGES = Math.floor(MAX_VISIBLE_PAGES * 0.5);
@@ -40,7 +41,7 @@ export interface EuiPaginationProps {
/**
* If true, will only show next/prev arrows instead of page numbers.
*/
- compressed?: boolean;
+ compressed?: boolean | 'arrows';
/**
* If passed in, passes value through to each button to set aria-controls.
@@ -106,7 +107,7 @@ export const EuiPagination: FunctionComponent = ({
pageCount,
};
- if (compressed) {
+ if (compressed === true) {
centerPageCount = (
@@ -133,7 +134,7 @@ export const EuiPagination: FunctionComponent = ({
);
- } else {
+ } else if (compressed !== 'arrows') {
const pages = [];
const firstPageInRange = Math.max(
@@ -308,14 +309,19 @@ const PaginationButtonPrevious = ({
default="Previous page"
>
{(disabledPreviousPage: string) => (
- safeClick(e, activePage - 1)}
- iconType="arrowLeft"
- color="text"
- aria-label={disabled ? disabledPreviousPage : previousPage}
- data-test-subj="pagination-button-previous"
- {...prevPageButtonProps}
- />
+
+ safeClick(e, activePage - 1)}
+ iconType="arrowLeft"
+ color="text"
+ aria-label={disabled ? disabledPreviousPage : previousPage}
+ data-test-subj="pagination-button-previous"
+ {...prevPageButtonProps}
+ />
+
)}
)}
@@ -355,14 +361,16 @@ const PaginationButtonNext = ({
{(nextPage: string) => (
{(disabledNextPage: string) => (
- safeClick(e, activePage + 1)}
- iconType="arrowRight"
- aria-label={disabled ? disabledNextPage : nextPage}
- color="text"
- data-test-subj="pagination-button-next"
- {...nextPageButtonProps}
- />
+
+ safeClick(e, activePage + 1)}
+ iconType="arrowRight"
+ aria-label={disabled ? disabledNextPage : nextPage}
+ color="text"
+ data-test-subj="pagination-button-next"
+ {...nextPageButtonProps}
+ />
+
)}
)}
diff --git a/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap b/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
index 0fa07f8016b..54fb2e4b40d 100644
--- a/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
+++ b/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
@@ -44,19 +44,23 @@ exports[`EuiTablePagination is rendered 1`] = `
class="euiPagination testClass1 testClass2"
data-test-subj="test subject string"
>
-
-
-
+
+
+
+
-
-
-
+
+
+
+
@@ -197,19 +205,23 @@ exports[`EuiTablePagination is rendered when hiding the per page options 1`] = `
class="euiPagination testClass1 testClass2"
data-test-subj="test subject string"
>
-
-
-
+
+
+
+
-
-
-
+
+
+
+
From ddf394088d7d70f412f2d38d24ab562ea4f3a508 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 1 Nov 2021 17:35:12 -0400
Subject: [PATCH 04/21] [EuiIcon] Added `doubleArrowLeft` and
`doubleArrowRight` while also updating the other `arrow` icons to a thicker
weight
---
src-docs/src/views/icon/icons.js | 2 +
.../icon/__snapshots__/icon.test.tsx.snap | 66 ++++++++++++++++---
src/components/icon/assets/arrow_down.tsx | 7 +-
src/components/icon/assets/arrow_left.tsx | 7 +-
src/components/icon/assets/arrow_right.tsx | 7 +-
src/components/icon/assets/arrow_up.tsx | 7 +-
.../icon/assets/doubleArrowLeft.tsx | 43 ++++++++++++
.../icon/assets/doubleArrowRight.tsx | 43 ++++++++++++
src/components/icon/icon.tsx | 2 +
src/components/icon/svgs/arrow_down.svg | 6 +-
src/components/icon/svgs/arrow_left.svg | 6 +-
src/components/icon/svgs/arrow_right.svg | 6 +-
src/components/icon/svgs/arrow_up.svg | 6 +-
src/components/icon/svgs/doubleArrowLeft.svg | 4 ++
src/components/icon/svgs/doubleArrowRight.svg | 4 ++
15 files changed, 180 insertions(+), 36 deletions(-)
create mode 100644 src/components/icon/assets/doubleArrowLeft.tsx
create mode 100644 src/components/icon/assets/doubleArrowRight.tsx
create mode 100644 src/components/icon/svgs/doubleArrowLeft.svg
create mode 100644 src/components/icon/svgs/doubleArrowRight.svg
diff --git a/src-docs/src/views/icon/icons.js b/src-docs/src/views/icon/icons.js
index abf1f690a4d..75196ac4407 100644
--- a/src-docs/src/views/icon/icons.js
+++ b/src-docs/src/views/icon/icons.js
@@ -64,6 +64,8 @@ export const iconTypes = [
'documentEdit',
'documents',
'dot',
+ 'doubleArrowLeft',
+ 'doubleArrowRight',
'download',
'email',
'empty',
diff --git a/src/components/icon/__snapshots__/icon.test.tsx.snap b/src/components/icon/__snapshots__/icon.test.tsx.snap
index c182fddcced..f532637cab8 100644
--- a/src/components/icon/__snapshots__/icon.test.tsx.snap
+++ b/src/components/icon/__snapshots__/icon.test.tsx.snap
@@ -704,6 +704,7 @@ exports[`EuiIcon props type arrowDown is rendered 1`] = `
`;
@@ -722,6 +723,7 @@ exports[`EuiIcon props type arrowLeft is rendered 1`] = `
`;
@@ -740,6 +742,7 @@ exports[`EuiIcon props type arrowRight is rendered 1`] = `
`;
@@ -758,6 +761,7 @@ exports[`EuiIcon props type arrowUp is rendered 1`] = `
`;
@@ -1819,6 +1823,52 @@ exports[`EuiIcon props type dot is rendered 1`] = `
`;
+exports[`EuiIcon props type doubleArrowLeft is rendered 1`] = `
+
+
+
+
+`;
+
+exports[`EuiIcon props type doubleArrowRight is rendered 1`] = `
+
+
+
+
+`;
+
exports[`EuiIcon props type download is rendered 1`] = `
& SVGRProps) => (
{title ? {title} : null}
);
diff --git a/src/components/icon/assets/arrow_left.tsx b/src/components/icon/assets/arrow_left.tsx
index 8e4b4612df5..fdf6d474de6 100644
--- a/src/components/icon/assets/arrow_left.tsx
+++ b/src/components/icon/assets/arrow_left.tsx
@@ -20,17 +20,18 @@ const EuiIconArrowLeft = ({
...props
}: React.SVGProps & SVGRProps) => (
{title ? {title} : null}
);
diff --git a/src/components/icon/assets/arrow_right.tsx b/src/components/icon/assets/arrow_right.tsx
index bef0510b595..2c483a470a3 100644
--- a/src/components/icon/assets/arrow_right.tsx
+++ b/src/components/icon/assets/arrow_right.tsx
@@ -20,17 +20,18 @@ const EuiIconArrowRight = ({
...props
}: React.SVGProps & SVGRProps) => (
{title ? {title} : null}
);
diff --git a/src/components/icon/assets/arrow_up.tsx b/src/components/icon/assets/arrow_up.tsx
index f41d22b1c42..a1c3593ce51 100644
--- a/src/components/icon/assets/arrow_up.tsx
+++ b/src/components/icon/assets/arrow_up.tsx
@@ -20,17 +20,18 @@ const EuiIconArrowUp = ({
...props
}: React.SVGProps & SVGRProps) => (
{title ? {title} : null}
);
diff --git a/src/components/icon/assets/doubleArrowLeft.tsx b/src/components/icon/assets/doubleArrowLeft.tsx
new file mode 100644
index 00000000000..36a901bf367
--- /dev/null
+++ b/src/components/icon/assets/doubleArrowLeft.tsx
@@ -0,0 +1,43 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+// THIS IS A GENERATED FILE. DO NOT MODIFY MANUALLY. @see scripts/compile-icons.js
+
+import * as React from 'react';
+interface SVGRProps {
+ title?: string;
+ titleId?: string;
+}
+
+const EuiIconDoubleArrowLeft = ({
+ title,
+ titleId,
+ ...props
+}: React.SVGProps & SVGRProps) => (
+
+ {title ? {title} : null}
+
+
+
+);
+
+export const icon = EuiIconDoubleArrowLeft;
diff --git a/src/components/icon/assets/doubleArrowRight.tsx b/src/components/icon/assets/doubleArrowRight.tsx
new file mode 100644
index 00000000000..1a5757d116b
--- /dev/null
+++ b/src/components/icon/assets/doubleArrowRight.tsx
@@ -0,0 +1,43 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+// THIS IS A GENERATED FILE. DO NOT MODIFY MANUALLY. @see scripts/compile-icons.js
+
+import * as React from 'react';
+interface SVGRProps {
+ title?: string;
+ titleId?: string;
+}
+
+const EuiIconDoubleArrowRight = ({
+ title,
+ titleId,
+ ...props
+}: React.SVGProps & SVGRProps) => (
+
+ {title ? {title} : null}
+
+
+
+);
+
+export const icon = EuiIconDoubleArrowRight;
diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx
index 70b6cf52884..ae6041e1b54 100644
--- a/src/components/icon/icon.tsx
+++ b/src/components/icon/icon.tsx
@@ -94,6 +94,8 @@ const typeToPathMap = {
documentation: 'documentation',
documents: 'documents',
dot: 'dot',
+ doubleArrowLeft: 'doubleArrowLeft',
+ doubleArrowRight: 'doubleArrowRight',
download: 'download',
editorAlignCenter: 'editor_align_center',
editorAlignLeft: 'editor_align_left',
diff --git a/src/components/icon/svgs/arrow_down.svg b/src/components/icon/svgs/arrow_down.svg
index 4f0c33a7976..11e0c80973d 100644
--- a/src/components/icon/svgs/arrow_down.svg
+++ b/src/components/icon/svgs/arrow_down.svg
@@ -1,5 +1,3 @@
-
-
-
-
+
+
diff --git a/src/components/icon/svgs/arrow_left.svg b/src/components/icon/svgs/arrow_left.svg
index ccd3d335cac..a31e2c40a08 100644
--- a/src/components/icon/svgs/arrow_left.svg
+++ b/src/components/icon/svgs/arrow_left.svg
@@ -1,5 +1,3 @@
-
-
-
-
+
+
diff --git a/src/components/icon/svgs/arrow_right.svg b/src/components/icon/svgs/arrow_right.svg
index 765b00e17b6..fa910500528 100644
--- a/src/components/icon/svgs/arrow_right.svg
+++ b/src/components/icon/svgs/arrow_right.svg
@@ -1,5 +1,3 @@
-
-
-
-
+
+
diff --git a/src/components/icon/svgs/arrow_up.svg b/src/components/icon/svgs/arrow_up.svg
index 76c9e560b92..b8c0b624464 100644
--- a/src/components/icon/svgs/arrow_up.svg
+++ b/src/components/icon/svgs/arrow_up.svg
@@ -1,5 +1,3 @@
-
-
-
-
+
+
diff --git a/src/components/icon/svgs/doubleArrowLeft.svg b/src/components/icon/svgs/doubleArrowLeft.svg
new file mode 100644
index 00000000000..f6a7721a889
--- /dev/null
+++ b/src/components/icon/svgs/doubleArrowLeft.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/components/icon/svgs/doubleArrowRight.svg b/src/components/icon/svgs/doubleArrowRight.svg
new file mode 100644
index 00000000000..f305f1b3d64
--- /dev/null
+++ b/src/components/icon/svgs/doubleArrowRight.svg
@@ -0,0 +1,4 @@
+
+
+
+
From 57ef10d77ca2feaed458ccb68aaaec4987ac2d88 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 8 Nov 2021 16:53:14 -0500
Subject: [PATCH 05/21] Added `first` and `last` buttons and refactored arrow
button component
---
.../in_memory_table.test.tsx.snap | 202 +++------
.../button/button_icon/button_icon.tsx | 2 +-
src/components/button/button_icon/index.ts | 1 +
.../__snapshots__/data_grid.test.tsx.snap | 63 ++-
.../__snapshots__/pagination.test.tsx.snap | 416 ++++++++----------
src/components/pagination/pagination.tsx | 183 +++-----
.../pagination/pagination_button_arrow.tsx | 78 ++++
.../table_pagination.test.tsx.snap | 116 +++--
8 files changed, 477 insertions(+), 584 deletions(-)
create mode 100644 src/components/pagination/pagination_button_arrow.tsx
diff --git a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
index 79f680958a4..7c49513868f 100644
--- a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
+++ b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
@@ -485,81 +485,52 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
aria-label="Pagination for table: "
className="euiPagination"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ aria-hidden="true"
+ className="euiButtonIcon__icon"
+ color="inherit"
+ data-euiicon-type="arrowLeft"
+ size="m"
+ />
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ aria-hidden="true"
+ className="euiButtonIcon__icon"
+ color="inherit"
+ data-euiicon-type="arrowRight"
+ size="m"
+ />
+
+
+
+
diff --git a/src/components/button/button_icon/button_icon.tsx b/src/components/button/button_icon/button_icon.tsx
index 4e9ad1ee1ca..752e260f229 100644
--- a/src/components/button/button_icon/button_icon.tsx
+++ b/src/components/button/button_icon/button_icon.tsx
@@ -73,7 +73,7 @@ export interface EuiButtonIconProps extends CommonProps {
display?: EuiButtonIconDisplay;
}
-type EuiButtonIconPropsForAnchor = {
+export type EuiButtonIconPropsForAnchor = {
type?: string;
} & PropsForAnchor<
EuiButtonIconProps,
diff --git a/src/components/button/button_icon/index.ts b/src/components/button/button_icon/index.ts
index b2e4516914f..6c54524adfb 100644
--- a/src/components/button/button_icon/index.ts
+++ b/src/components/button/button_icon/index.ts
@@ -11,4 +11,5 @@ export {
EuiButtonIconColor,
EuiButtonIconProps,
EuiButtonIconPropsForButton,
+ EuiButtonIconPropsForAnchor,
} from './button_icon';
diff --git a/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap b/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
index e1ab897ee36..5d77da95c89 100644
--- a/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
+++ b/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap
@@ -43,25 +43,22 @@ exports[`EuiDataGrid pagination renders 1`] = `
aria-label="Pagination for preceding grid: test grid"
class="euiPagination"
>
-
-
-
-
-
+
+
-
-
-
-
-
+
+
diff --git a/src/components/pagination/__snapshots__/pagination.test.tsx.snap b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
index 04ee83b25aa..44739d25486 100644
--- a/src/components/pagination/__snapshots__/pagination.test.tsx.snap
+++ b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
@@ -6,24 +6,20 @@ exports[`EuiPagination is rendered 1`] = `
class="euiPagination testClass1 testClass2"
data-test-subj="test subject string"
>
-
-
-
-
-
+
+
-
-
-
-
-
+
+
`;
@@ -76,23 +68,20 @@ exports[`EuiPagination props activePage is rendered 1`] = `
`;
@@ -289,24 +275,20 @@ exports[`EuiPagination props aria-controls is rendered 1`] = `
`;
@@ -359,24 +337,20 @@ exports[`EuiPagination props compressed is rendered 1`] = `
`;
@@ -443,42 +413,34 @@ exports[`EuiPagination props compressed arrows is rendered 1`] = `
`;
@@ -486,41 +448,34 @@ exports[`EuiPagination props pageCount can be null 1`] = `
`;
@@ -528,24 +483,20 @@ exports[`EuiPagination props pageCount is rendered 1`] = `
`;
diff --git a/src/components/pagination/pagination.tsx b/src/components/pagination/pagination.tsx
index 14403926199..dce63a64ded 100644
--- a/src/components/pagination/pagination.tsx
+++ b/src/components/pagination/pagination.tsx
@@ -11,17 +11,28 @@ import classNames from 'classnames';
import { CommonProps } from '../common';
import { EuiPaginationButton } from './pagination_button';
-import { EuiButtonIcon } from '../button';
import { EuiI18n } from '../i18n';
import { EuiText } from '../text';
import { EuiHideFor } from '../responsive';
-import { EuiToolTip } from '../tool_tip';
+import { EuiPaginationButtonArrow } from './pagination_button_arrow';
const MAX_VISIBLE_PAGES = 5;
const NUMBER_SURROUNDING_PAGES = Math.floor(MAX_VISIBLE_PAGES * 0.5);
export type PageClickHandler = (pageIndex: number) => void;
-type SafeClickHandler = (e: MouseEvent, pageIndex: number) => void;
+export type SafeClickHandler = (
+ e: MouseEvent,
+ pageIndex: number | null
+) => void;
+
+export interface EuiPaginationIndeterminateProps {
+ onNextPage: () => void;
+ onPreviousPage: () => void;
+ onFirstPage: () => void;
+ onLastPage: () => void;
+ isFirstPage: boolean;
+ isLastPage: boolean;
+}
export interface EuiPaginationProps {
/**
@@ -33,8 +44,9 @@ export interface EuiPaginationProps {
/**
* The current page using a zero based index.
* So if you set the activePage to 1, it will activate the second page.
+ * Pass `null` if total count in unknown.
*/
- activePage?: number;
+ activePage?: number | null;
onPageClick?: PageClickHandler;
@@ -47,6 +59,14 @@ export interface EuiPaginationProps {
* If passed in, passes value through to each button to set aria-controls.
*/
'aria-controls'?: string;
+
+ /**
+ *
+ */
+ // indeterminateProps?: EuiPaginationIndeterminateProps;
+
+ onFirstPage?: () => void;
+ onLastPage?: () => void;
}
type Props = CommonProps & HTMLAttributes & EuiPaginationProps;
@@ -58,6 +78,8 @@ export const EuiPagination: FunctionComponent = ({
onPageClick = () => {},
compressed,
'aria-controls': ariaControls,
+ onFirstPage,
+ onLastPage,
...rest
}) => {
const safeClick: SafeClickHandler = (e, pageIndex) => {
@@ -71,35 +93,60 @@ export const EuiPagination: FunctionComponent = ({
}
}
- onPageClick(pageIndex);
+ onPageClick(pageIndex === null ? 0 : pageIndex);
};
const classes = classNames('euiPagination', className);
- const hasControl = ariaControls !== undefined;
- const nextButton = (
- safeClick(e, 0)}
+ disabled={activePage === 0}
/>
);
const previousButton = (
-
+ safeClick(e, activePage !== null ? activePage - 1 : null)
+ }
disabled={activePage === 0}
/>
);
+ const nextButton = (
+
+ safeClick(e, activePage !== null ? activePage + 1 : null)
+ }
+ disabled={pageCount ? activePage === pageCount - 1 : false}
+ />
+ );
+
+ const lastButton = onLastPage && (
+
+ safeClick(e, pageCount ? pageCount - 1 : null)
+ }
+ disabled={pageCount ? activePage === pageCount - 1 : false}
+ />
+ );
+
let centerPageCount;
- if (pageCount) {
+ if (pageCount && activePage !== null) {
const sharedButtonProps = {
activePage,
ariaControls,
@@ -267,117 +314,15 @@ export const EuiPagination: FunctionComponent = ({
return (
+ {firstButton}
{previousButton}
{centerPageCount}
{nextButton}
+ {lastButton}
);
};
-const PaginationButtonPrevious = ({
- hasControl,
- activePage,
- disabled,
- ariaControls,
- safeClick,
-}: {
- hasControl?: boolean;
- activePage: number;
- disabled?: boolean;
- ariaControls?: string;
- safeClick: SafeClickHandler;
-}) => {
- let prevPageButtonProps = {};
- if (hasControl && !disabled) {
- prevPageButtonProps = {
- 'aria-controls': ariaControls,
- href: `#${ariaControls}`,
- };
- } else {
- prevPageButtonProps = { disabled };
- }
-
- return (
-
- {(previousPage: string) => (
-
- {(disabledPreviousPage: string) => (
-
- safeClick(e, activePage - 1)}
- iconType="arrowLeft"
- color="text"
- aria-label={disabled ? disabledPreviousPage : previousPage}
- data-test-subj="pagination-button-previous"
- {...prevPageButtonProps}
- />
-
- )}
-
- )}
-
- );
-};
-
-const PaginationButtonNext = ({
- hasControl,
- activePage,
- disabled,
- ariaControls,
- safeClick,
-}: {
- hasControl?: boolean;
- activePage: number;
- disabled?: boolean;
- ariaControls?: string;
- safeClick: SafeClickHandler;
-}) => {
- let nextPageButtonProps = {};
- if (hasControl && !disabled) {
- nextPageButtonProps = {
- 'aria-controls': ariaControls,
- href: `#${ariaControls}`,
- };
- } else {
- nextPageButtonProps = { disabled };
- }
-
- return (
-
- {(nextPage: string) => (
-
- {(disabledNextPage: string) => (
-
- safeClick(e, activePage + 1)}
- iconType="arrowRight"
- aria-label={disabled ? disabledNextPage : nextPage}
- color="text"
- data-test-subj="pagination-button-next"
- {...nextPageButtonProps}
- />
-
- )}
-
- )}
-
- );
-};
-
const PaginationButtonWrapper = ({
pageIndex,
inList = true,
diff --git a/src/components/pagination/pagination_button_arrow.tsx b/src/components/pagination/pagination_button_arrow.tsx
new file mode 100644
index 00000000000..1d1a2292bcd
--- /dev/null
+++ b/src/components/pagination/pagination_button_arrow.tsx
@@ -0,0 +1,78 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React, { FunctionComponent } from 'react';
+import { toSentenceCase } from '../../services';
+
+import {
+ EuiButtonIcon,
+ EuiButtonIconPropsForAnchor,
+} from '../button/button_icon';
+import { keysOf } from '../common';
+import { useEuiI18n } from '../i18n';
+
+const typeToIconTypeMap = {
+ first: 'doubleArrowLeft',
+ previous: 'arrowLeft',
+ next: 'arrowRight',
+ last: 'doubleArrowRight',
+};
+
+export const TYPES = keysOf(typeToIconTypeMap);
+export type EuiPaginationButtonArrowType = typeof TYPES[number];
+
+export type Props = Partial> & {
+ type: EuiPaginationButtonArrowType;
+ activePage?: number | null;
+ disabled?: boolean;
+ ariaControls?: string;
+};
+
+export const EuiPaginationButtonArrow: FunctionComponent = ({
+ type,
+ activePage,
+ disabled,
+ ariaControls,
+ onClick,
+}) => {
+ let labelModifier: number | undefined;
+
+ if (type === 'previous') {
+ labelModifier = activePage != null ? activePage : 0;
+ } else if (type === 'next') {
+ labelModifier = activePage != null ? activePage + 2 : 0;
+ }
+
+ const label = useEuiI18n(
+ 'euiPaginationButtonArrow.previousPage',
+ ({ page }) => `${toSentenceCase(type)} page${page ? `, ${page}` : ''}`,
+ {
+ page: labelModifier,
+ }
+ );
+
+ const buttonProps: Partial = {};
+
+ if (ariaControls && !disabled) {
+ buttonProps.href = `#${ariaControls}`;
+ buttonProps['aria-controls'] = ariaControls;
+ }
+
+ return (
+
+ );
+};
diff --git a/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap b/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
index 54fb2e4b40d..75d49f0504c 100644
--- a/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
+++ b/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
@@ -44,23 +44,20 @@ exports[`EuiTablePagination is rendered 1`] = `
class="euiPagination testClass1 testClass2"
data-test-subj="test subject string"
>
-
-
-
-
-
+
+
-
-
-
-
-
+
+
@@ -205,23 +199,20 @@ exports[`EuiTablePagination is rendered when hiding the per page options 1`] = `
class="euiPagination testClass1 testClass2"
data-test-subj="test subject string"
>
-
-
-
-
-
+
+
-
-
-
-
-
+
+
From 46476e31bb469cb46bbcc482ac857ed37a82526a Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 8 Nov 2021 17:30:00 -0500
Subject: [PATCH 06/21] Using negative index for `activePage` to indicate last
page
---
.../__snapshots__/pagination.test.tsx.snap | 93 ++++++++++++++++++-
src/components/pagination/pagination.test.tsx | 22 ++++-
src/components/pagination/pagination.tsx | 60 ++++--------
.../pagination/pagination_button_arrow.tsx | 2 +-
4 files changed, 127 insertions(+), 50 deletions(-)
diff --git a/src/components/pagination/__snapshots__/pagination.test.tsx.snap b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
index 44739d25486..d62a3214ec6 100644
--- a/src/components/pagination/__snapshots__/pagination.test.tsx.snap
+++ b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
@@ -64,6 +64,69 @@ exports[`EuiPagination is rendered 1`] = `
`;
+exports[`EuiPagination props activePage can be 0 1`] = `
+
+`;
+
exports[`EuiPagination props activePage is rendered 1`] = `
`;
-exports[`EuiPagination props compressed arrows is rendered 1`] = `
-
-`;
-
exports[`EuiPagination props pageCount can be 0 1`] = `
),
snippet: centeredPaginationSnippet,
@@ -231,7 +220,7 @@ export const PaginationExample = {
title: 'Customizable pagination',
source: [
{
- type: GuideSectionTypes.JS,
+ type: GuideSectionTypes.TSX,
code: customizablePaginationSource,
},
],
@@ -249,7 +238,6 @@ export const PaginationExample = {
tables.
),
- snippet: customizablePaginationSnippet,
demo: ,
props: { EuiPagination },
},
From 043654f916e0dff433cbc429bbef64dbf35e6fe1 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 15 Nov 2021 16:38:03 -0500
Subject: [PATCH 15/21] i18n updates
---
.../pagination/pagination_button_arrow.tsx | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/components/pagination/pagination_button_arrow.tsx b/src/components/pagination/pagination_button_arrow.tsx
index f1a734723ca..7804044a5c0 100644
--- a/src/components/pagination/pagination_button_arrow.tsx
+++ b/src/components/pagination/pagination_button_arrow.tsx
@@ -7,7 +7,6 @@
*/
import React, { FunctionComponent } from 'react';
-import { toSentenceCase } from '../../services';
import {
EuiButtonIcon,
@@ -42,6 +41,13 @@ export const EuiPaginationButtonArrow: FunctionComponent = ({
}) => {
let labelModifier: number | undefined;
+ const labels = {
+ first: useEuiI18n('euiPaginationButtonArrow.firstPage', 'First'),
+ previous: useEuiI18n('euiPaginationButtonArrow.previousPage', 'Previous'),
+ next: useEuiI18n('euiPaginationButtonArrow.nextPage', 'Next'),
+ last: useEuiI18n('euiPaginationButtonArrow.lastPage', 'Last'),
+ };
+
if (type === 'previous') {
labelModifier = activePage != null ? activePage : 0;
} else if (type === 'next') {
@@ -49,9 +55,10 @@ export const EuiPaginationButtonArrow: FunctionComponent = ({
}
const label = useEuiI18n(
- 'euiPaginationButtonArrow.previousPage',
- ({ page }) => `${toSentenceCase(type)} page${page ? `, ${page}` : ''}`,
+ 'euiPaginationButtonArrow.label',
+ ({ type, page }) => `${type} page${page ? `, ${page}` : ''}`,
{
+ type: labels[type],
page: labelModifier,
}
);
From 3a4cf61f2981e4c310ed9a532a2c1daee11491fd Mon Sep 17 00:00:00 2001
From: Greg Thompson
Date: Wed, 17 Nov 2021 12:36:28 -0600
Subject: [PATCH 16/21] update indeterminate page i18n tokens
---
.../__snapshots__/pagination.test.tsx.snap | 20 +++----
.../pagination/pagination_button_arrow.tsx | 56 ++++++++++++-------
2 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/src/components/pagination/__snapshots__/pagination.test.tsx.snap b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
index a23964de145..1e61d2a44d2 100644
--- a/src/components/pagination/__snapshots__/pagination.test.tsx.snap
+++ b/src/components/pagination/__snapshots__/pagination.test.tsx.snap
@@ -7,7 +7,7 @@ exports[`EuiPagination is rendered 1`] = `
data-test-subj="test subject string"
>
= ({
ariaControls,
onClick,
}) => {
- let labelModifier: number | undefined;
-
const labels = {
- first: useEuiI18n('euiPaginationButtonArrow.firstPage', 'First'),
- previous: useEuiI18n('euiPaginationButtonArrow.previousPage', 'Previous'),
- next: useEuiI18n('euiPaginationButtonArrow.nextPage', 'Next'),
- last: useEuiI18n('euiPaginationButtonArrow.lastPage', 'Last'),
+ first: useEuiI18n('euiPaginationButtonArrow.firstPage', 'First page'),
+ previous: useEuiI18n(
+ 'euiPaginationButtonArrow.previousPage',
+ 'Previous page, {page}',
+ {
+ page: activePage ?? 1,
+ }
+ ),
+ next: useEuiI18n('euiPaginationButtonArrow.nextPage', 'Next page, {page}', {
+ page: activePage != null ? activePage + 2 : 2,
+ }),
+ last: useEuiI18n('euiPaginationButtonArrow.lastPage', 'Last page'),
};
- if (type === 'previous') {
- labelModifier = activePage != null ? activePage : 0;
- } else if (type === 'next') {
- labelModifier = activePage != null ? activePage + 2 : 0;
- }
+ const indeterminateLabels = {
+ previous: useEuiI18n(
+ 'euiPaginationButtonArrow.previousPageIndeterminate',
+ 'Previous page, {count} from last page',
+ {
+ count: activePage != null ? Math.abs(activePage) : 1,
+ }
+ ),
+ next: useEuiI18n(
+ 'euiPaginationButtonArrow.nextPageIndeterminate',
+ 'Next page, {count} from last page',
+ {
+ count: activePage != null ? Math.abs(activePage) - 2 : 2,
+ }
+ ),
+ };
- const label = useEuiI18n(
- 'euiPaginationButtonArrow.label',
- ({ type, page }) => `${type} page${page ? `, ${page}` : ''}`,
- {
- type: labels[type],
- page: labelModifier,
- }
- );
+ let label =
+ (type === 'next' || type === 'previous') &&
+ activePage != null &&
+ activePage < 0
+ ? indeterminateLabels[type]
+ : labels[type];
+ if (type === 'next' && activePage === -2) {
+ label = labels.last;
+ }
const buttonProps: Partial = {};
From 11b028c830740f9308671aa2923e75bf5de49fc8 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 22 Nov 2021 16:03:43 -0500
Subject: [PATCH 17/21] Fixup a11y text by using simplified `Page # of #`
syntax
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
and reduced arrow button titles to `First, Previous, Next, Last`.
*Temporarily doesn’t hide SR-only text*
---
.../in_memory_table.test.tsx.snap | 15 +++--
.../__snapshots__/data_grid.test.tsx.snap | 7 ++-
.../__snapshots__/pagination.test.tsx.snap | 55 +++++++++++--------
src/components/pagination/_pagination.scss | 1 +
src/components/pagination/pagination.tsx | 24 ++++++--
.../pagination/pagination_button_arrow.tsx | 42 ++------------
.../table_pagination.test.tsx.snap | 18 +++---
7 files changed, 77 insertions(+), 85 deletions(-)
diff --git a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
index 548df2b4ddc..5e8e5d7dff2 100644
--- a/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
+++ b/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap
@@ -485,8 +485,8 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
aria-label="Pagination for table: "
className="euiPagination"
>
+ Page 2 of 2