diff --git a/README.md b/README.md index fce836a5..fc91fe57 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ ReactDOM.render(, container); | showQuickJumper | show quick goto jumper | Bool / Object | false / {goButton: true} | | showTotal | show total records and range | Function(total, [from, to]) | - | | className | className of pagination | String | - | -| simple | when set, show simple pager | Object | null | +| simple | when set, show simple pager | Bool / { readOnly?: boolean; } | - | | locale | to set l10n config | Object | [zh_CN](https://github.com/react-component/pagination/blob/master/src/locale/zh_CN.js) | | style | the style of pagination | Object | {} | | showLessItems | show less page items | Bool | false | diff --git a/assets/index.less b/assets/index.less index aed81e27..64ceac6d 100644 --- a/assets/index.less +++ b/assets/index.less @@ -210,7 +210,7 @@ } &-slash { - margin: 0 10px 0 5px; + margin: 0 10px 0 12px; } &-options { @@ -262,14 +262,14 @@ } &-simple &-simple-pager { - display: inline-block; + display: flex; + align-items: center; height: @pagination-item-size-sm; margin-right: 8px; input { box-sizing: border-box; height: 100%; - margin-right: 8px; padding: 0 6px; text-align: center; background-color: @pagination-item-input-bg; diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index 3469f6b9..beeba080 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -16,6 +16,13 @@ export default () => { onChange={setPageIndex} />
+ +

= (props) => { // ================== Simple ================== // FIXME: ts type + const isReadOnly = typeof simple === 'object' ? simple.readOnly : !simple; let gotoButton: any = goButton; let simplePager: React.ReactNode = null; @@ -380,16 +381,20 @@ const Pagination: React.FC = (props) => { title={showTitle ? `${current}/${allPages}` : null} className={`${prefixCls}-simple-pager`} > - + {isReadOnly ? ( + internalInputVal + ) : ( + + )} / {allPages} diff --git a/src/interface.ts b/src/interface.ts index be78072a..7cc6032b 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -37,7 +37,7 @@ export interface PaginationData { showPrevNextJumpers: boolean; showQuickJumper: boolean | object; showTitle: boolean; - simple: boolean; + simple: boolean | { readOnly?: boolean; }; disabled: boolean; locale: PaginationLocale; diff --git a/tests/__snapshots__/demo.test.tsx.snap b/tests/__snapshots__/demo.test.tsx.snap index 3ff98abb..0e218d2a 100644 --- a/tests/__snapshots__/demo.test.tsx.snap +++ b/tests/__snapshots__/demo.test.tsx.snap @@ -3375,6 +3375,46 @@ exports[`Example simple 1`] = `
+
    +
  • +
  • +
  • + 1 + + / + + 5 +
  • +
  • +
  • +
+
    diff --git a/tests/__snapshots__/simple.test.tsx.snap b/tests/__snapshots__/simple.test.tsx.snap index 8dee2660..f2bcb51a 100644 --- a/tests/__snapshots__/simple.test.tsx.snap +++ b/tests/__snapshots__/simple.test.tsx.snap @@ -67,3 +67,48 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j `; + +exports[`simple Pagination should support simple is readOnly value 1`] = ` +
    +
      +
    • +
    • +
    • + 1 + + / + + 0 +
    • +
    • +
    • +
    +
    +`; diff --git a/tests/simple.test.tsx b/tests/simple.test.tsx index c02e8d19..7bef3f8b 100644 --- a/tests/simple.test.tsx +++ b/tests/simple.test.tsx @@ -299,4 +299,9 @@ describe('simple Pagination', () => { expect(quickJumper).toMatchSnapshot(); }); }); + + it('should support simple is readOnly value', () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); });