@@ -11,7 +11,6 @@ import { dboAction } from "../../Ajax";
1111import DatePicker from "../../Date/Picker" ;
1212import * as DomUtil from "../../Dom/Util" ;
1313import { ucfirst } from "../../StringUtil" ;
14- import UiPagination from "../Pagination" ;
1514import UiSearchInput from "./Input" ;
1615import * as UiScroll from "../Scroll" ;
1716import { setValues as setItemListValues } from "../ItemList" ;
@@ -242,21 +241,43 @@ export class UiSearchExtended {
242241 const wrapperDiv = document . createElement ( "div" ) ;
243242 wrapperDiv . classList . add ( "pagination" + ucfirst ( position ) ) ;
244243 this . form . parentElement ! . insertBefore ( wrapperDiv , this . delimiter ) ;
245- const div = document . createElement ( "div" ) ;
246- wrapperDiv . appendChild ( div ) ;
247244
248- new UiPagination ( div , {
249- activePage : this . activePage ,
250- maxPage : this . pages ,
245+ const pagination = document . createElement ( "woltlab-core-pagination" ) ;
246+ pagination . page = this . activePage ;
247+ pagination . count = this . pages ;
248+ pagination . behavior = "button" ;
249+ pagination . url = this . getPaginationUrl ( ) ;
250+ pagination . addEventListener ( "switchPage" , ( event : CustomEvent ) => {
251+ void this . changePage ( event . detail ) . then ( ( ) => {
252+ if ( position === "bottom" ) {
253+ UiScroll . element ( this . form . nextElementSibling as HTMLElement , undefined , "auto" ) ;
254+ }
255+ } ) ;
256+ } ) ;
251257
252- callbackSwitch : ( pageNo ) => {
253- void this . changePage ( pageNo ) . then ( ( ) => {
254- if ( position === "bottom" ) {
255- UiScroll . element ( this . form . nextElementSibling as HTMLElement , undefined , "auto" ) ;
256- }
257- } ) ;
258- } ,
258+ wrapperDiv . append ( pagination ) ;
259+ }
260+
261+ private getPaginationUrl ( ) : string {
262+ const url = new URL ( this . form . action ) ;
263+ url . search += url . search !== "" ? "&" : "?" ;
264+
265+ const searchParameters : SearchParameters = [ ] ;
266+ new FormData ( this . form ) . forEach ( ( value , key ) => {
267+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
268+ const trimmed = value . toString ( ) . trim ( ) ;
269+ if ( trimmed ) {
270+ searchParameters . push ( [ key , trimmed ] ) ;
271+ }
259272 } ) ;
273+ const parameters = searchParameters . slice ( ) ;
274+
275+ if ( this . activePage > 1 ) {
276+ parameters . push ( [ "pageNo" , this . activePage . toString ( ) ] ) ;
277+ }
278+ url . search += new URLSearchParams ( parameters ) . toString ( ) ;
279+
280+ return url . toString ( ) ;
260281 }
261282
262283 private async changePage ( pageNo : number ) : Promise < void > {
0 commit comments