Custom pagination widget

I read that

Every widget and connector that handles a list of items exposes a transformItems option.

I want to customize a pagination widget in a simple way. I want to keep first, previous, next and last buttons; remove the individual page number buttons and replace them in the middle of the widget with text like “21-40 of 450”.

I know that with the active page number, items per page and total results, I can figure out the text to insert.

So first, I want to inspect the items. I tried a few variations of this code:

        search.addWidget(
            pagination({
                container: '#pages',
                transformItems: function(items) {
                	console.log(items);
                },
            })
         );

and saw nothing in my console. The widget displays correctly.

What would be the easiest way to get my desired result?

Now I see that the pagination widget does not have a transformItems function.

So instead, I have inserted some code from my old Helper-based app within my hits widget. It produces buttons that could call search.start() or another function, with a page number.

This pagination renders nicely but I don’t know how to call search.start() with a page number (as I could with the Helper). Is it possible with InstantSearch.js?