()
| 81 | props: SortedTablePaginatorProps, |
| 82 | ) => { |
| 83 | const content = () => { |
| 84 | let offset = props.offset ?? 0; |
| 85 | const limit = props.limit ?? props.total; |
| 86 | if (offset > props.total || offset < 0) { |
| 87 | offset = 0; |
| 88 | props.onChange(0); |
| 89 | } |
| 90 | const singular = props.singular ?? 'row'; |
| 91 | const plural = props.plural ?? singular + 's'; |
| 92 | return ( |
| 93 | <> |
| 94 | {props.total > limit && ( |
| 95 | <> |
| 96 | <button |
| 97 | class="previous" |
| 98 | disabled={offset == 0} |
| 99 | onClick={getCallbackOrUndefined( |
| 100 | () => props.onChange(offset - limit), |
| 101 | offset > 0, |
| 102 | )} |
| 103 | > |
| 104 | {LEFT_ARROW} |
| 105 | </button> |
| 106 | <button |
| 107 | class="next" |
| 108 | disabled={offset + limit >= props.total} |
| 109 | onClick={getCallbackOrUndefined( |
| 110 | () => props.onChange(offset + limit), |
| 111 | offset + limit < props.total, |
| 112 | )} |
| 113 | > |
| 114 | {RIGHT_ARROW} |
| 115 | </button> |
| 116 | {offset + 1} to {mathMin(props.total, offset + limit)} |
| 117 | {' of '} |
| 118 | </> |
| 119 | )} |
| 120 | {props.total} {props.total != 1 ? plural : singular} |
| 121 | </> |
| 122 | ); |
| 123 | }; |
| 124 | return <>{content()}</>; |
| 125 | }; |
no test coverage detected
searching dependent graphs…