diff --git a/.yarn-offline-mirror/carbon-components-9.68.5.tgz b/.yarn-offline-mirror/carbon-components-9.68.5.tgz deleted file mode 100644 index e8fcb46bea..0000000000 Binary files a/.yarn-offline-mirror/carbon-components-9.68.5.tgz and /dev/null differ diff --git a/.yarn-offline-mirror/carbon-components-9.69.0.tgz b/.yarn-offline-mirror/carbon-components-9.69.0.tgz new file mode 100644 index 0000000000..580835d0b4 Binary files /dev/null and b/.yarn-offline-mirror/carbon-components-9.69.0.tgz differ diff --git a/package.json b/package.json index 70c496357d..dbee65dd11 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ "babel-plugin-dev-expression": "^0.2.1", "babel-plugin-react-docgen": "^2.0.0", "bowser": "^1.6.1", - "carbon-components": "^9.68.5", + "carbon-components": "^9.69.0", "carbon-icons": "^7.0.5", "chalk": "^2.3.0", "cli-table": "^0.3.0", diff --git a/src/components/Pagination/Pagination-story.js b/src/components/Pagination/Pagination-story.js index 84e6baebf3..b5ef8e816e 100644 --- a/src/components/Pagination/Pagination-story.js +++ b/src/components/Pagination/Pagination-story.js @@ -18,6 +18,7 @@ import { } from '@storybook/addon-knobs'; import Pagination from '../Pagination'; import PaginationV2 from '../PaginationV2'; +import { componentsX } from '../../internal/FeatureFlags'; const props = () => ({ disabled: boolean('Disable backward/forward buttons (disabled)', false), @@ -25,7 +26,9 @@ const props = () => ({ totalItems: number('Total number of items (totalItems)', 103), pagesUnknown: boolean('Total number of items unknown (pagesUnknown)', false), pageInputDisabled: boolean('Disable page input (pageInputDisabled)', false), - isLastPage: boolean('At the last page (isLastPage)', false), + isLastPage: componentsX + ? null + : boolean('At the last page (isLastPage)', false), backwardText: text( 'The description for the backward icon (backwardText)', 'Backward' diff --git a/src/components/PaginationV2/PaginationV2.js b/src/components/PaginationV2/PaginationV2.js index 725aa43240..e2b3690db8 100644 --- a/src/components/PaginationV2/PaginationV2.js +++ b/src/components/PaginationV2/PaginationV2.js @@ -9,11 +9,15 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import classnames from 'classnames'; import { iconChevronLeft, iconChevronRight } from 'carbon-icons'; +// TODO: import { CaretRight24, CaretLeft24 } from '@carbon/icons-react'; +import CaretRight24 from '@carbon/icons-react/lib/caret--right/24'; +import CaretLeft24 from '@carbon/icons-react/lib/caret--left/24'; import { settings } from 'carbon-components'; import Icon from '../Icon'; import Select from '../Select'; import SelectItem from '../SelectItem'; import { equals } from '../../tools/array'; +import { componentsX } from '../../internal/FeatureFlags'; const { prefix } = settings; @@ -123,6 +127,7 @@ export default class PaginationV2 extends Component { */ pagesUnknown: PropTypes.bool, + // TODO: remove when v9 is deprecated /** * `true` if the current page should be the last page. */ @@ -140,7 +145,8 @@ export default class PaginationV2 extends Component { forwardText: 'Forward', itemsPerPageText: 'Items per page:', pageNumberText: 'Page Number', - pageRangeText: (current, total) => `${current} of ${total} pages`, + pageRangeText: (current, total) => + componentsX ? `of ${total} pages` : `${current} of ${total} pages`, disabled: false, page: 1, pagesUnknown: false, @@ -246,21 +252,121 @@ export default class PaginationV2 extends Component { ...other } = this.props; - const statePage = this.state.page; - const statePageSize = this.state.pageSize; const classNames = classnames(`${prefix}--pagination`, className); + const inputId = id || this.uniqueId; + const { page: statePage, pageSize: statePageSize } = this.state; + const totalPages = Math.max(Math.ceil(totalItems / statePageSize), 1); + const backButtonDisabled = this.props.disabled || statePage === 1; const backButtonClasses = classnames( `${prefix}--pagination__button`, `${prefix}--pagination__button--backward`, { - [`${prefix}--pagination__button--no-index`]: pageInputDisabled, + [`${prefix}--pagination__button--no-index`]: + pageInputDisabled || backButtonDisabled, + } + ); + const forwardButtonDisabled = + this.props.disabled || statePage === totalPages; + const forwardButtonClasses = classnames( + `${prefix}--pagination__button`, + `${prefix}--pagination__button--forward`, + { + [`${prefix}--pagination__button--no-index`]: + pageInputDisabled || forwardButtonDisabled, } ); - const inputId = id || this.uniqueId; - const totalPages = Math.max(Math.ceil(totalItems / statePageSize), 1); const selectItems = this.renderSelectItems(totalPages); - - return ( + const pageRange = (() => { + if (pageInputDisabled) { + return null; + } + return ( + + {pagesUnknown + ? pageText(statePage) + : pageRangeText(statePage, totalPages)} + + ); + })(); + return componentsX ? ( +