MCPcopy Index your code
hub / github.com/tinyplex/tinybase / SortedTablePaginator

Function SortedTablePaginator

src/ui-react-dom/SortedTablePaginator.tsx:82–129  ·  view source on GitHub ↗
({
  onChange,
  total,
  offset = 0,
  limit = total,
  singular = 'row',
  plural = singular + 's',
}: SortedTablePaginatorProps)

Source from the content-addressed store, hash-verified

80};
81
82export const SortedTablePaginator: typeof SortedTablePaginatorDecl = ({
83 onChange,
84 total,
85 offset = 0,
86 limit = total,
87 singular = 'row',
88 plural = singular + 's',
89}: SortedTablePaginatorProps) => {
90 if (offset > total || offset < 0) {
91 offset = 0;
92 onChange(0);
93 }
94 const handlePrevClick = useCallbackOrUndefined(
95 () => onChange(offset - limit),
96 [onChange, offset, limit],
97 offset > 0,
98 );
99 const handleNextClick = useCallbackOrUndefined(
100 () => onChange(offset + limit),
101 [onChange, offset, limit],
102 offset + limit < total,
103 );
104 return (
105 <>
106 {total > limit && (
107 <>
108 <button
109 className="previous"
110 disabled={offset == 0}
111 onClick={handlePrevClick}
112 >
113 {LEFT_ARROW}
114 </button>
115 <button
116 className="next"
117 disabled={offset + limit >= total}
118 onClick={handleNextClick}
119 >
120 {RIGHT_ARROW}
121 </button>
122 {offset + 1} to {mathMin(total, offset + limit)}
123 {' of '}
124 </>
125 )}
126 {total} {total != 1 ? plural : singular}
127 </>
128 );
129};

Callers

nothing calls this directly

Calls 1

useCallbackOrUndefinedFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…