@fy-/fws-vue 2.3.51 → 2.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,7 @@ import { getURL, hasFW } from '@fy-/fws-js'
|
|
|
6
6
|
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/vue/24/solid'
|
|
7
7
|
import { useServerHead } from '@unhead/vue'
|
|
8
8
|
import { useDebounceFn } from '@vueuse/core'
|
|
9
|
-
import { computed, onMounted, shallowRef, watch } from 'vue'
|
|
9
|
+
import { computed, onMounted, ref, shallowRef, watch } from 'vue'
|
|
10
10
|
import { useRoute } from 'vue-router'
|
|
11
11
|
import { useEventBus } from '../../composables/event-bus'
|
|
12
12
|
import { useServerRouter } from '../../stores/serverRouter'
|
|
@@ -32,6 +32,10 @@ const history = useServerRouter()
|
|
|
32
32
|
const isMounted = shallowRef(false)
|
|
33
33
|
const pageWatcher = shallowRef<WatchStopHandle>()
|
|
34
34
|
|
|
35
|
+
// Jump to page functionality
|
|
36
|
+
const jumpPageValue = ref('')
|
|
37
|
+
const showJumpInput = ref(false)
|
|
38
|
+
|
|
35
39
|
// Memoize the hash string to avoid repeated computation
|
|
36
40
|
const hashString = computed(() => props.hash !== '' ? `#${props.hash}` : undefined)
|
|
37
41
|
|
|
@@ -73,6 +77,45 @@ const prev = useDebounceFn(() => {
|
|
|
73
77
|
})
|
|
74
78
|
}, 300)
|
|
75
79
|
|
|
80
|
+
// Jump to page functionality
|
|
81
|
+
const jumpToPage = useDebounceFn(() => {
|
|
82
|
+
const targetPage = Number.parseInt(jumpPageValue.value)
|
|
83
|
+
|
|
84
|
+
if (Number.isNaN(targetPage) || !isNewPage(targetPage)) {
|
|
85
|
+
jumpPageValue.value = ''
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const newQuery = { ...route.query }
|
|
90
|
+
newQuery.page = targetPage.toString()
|
|
91
|
+
|
|
92
|
+
history.push({
|
|
93
|
+
path: history.currentRoute.path,
|
|
94
|
+
query: newQuery,
|
|
95
|
+
hash: hashString.value,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
jumpPageValue.value = ''
|
|
99
|
+
showJumpInput.value = false
|
|
100
|
+
}, 300)
|
|
101
|
+
|
|
102
|
+
function toggleJumpInput() {
|
|
103
|
+
showJumpInput.value = !showJumpInput.value
|
|
104
|
+
if (!showJumpInput.value) {
|
|
105
|
+
jumpPageValue.value = ''
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function handleJumpInputKeydown(event: KeyboardEvent) {
|
|
110
|
+
if (event.key === 'Enter') {
|
|
111
|
+
jumpToPage()
|
|
112
|
+
}
|
|
113
|
+
else if (event.key === 'Escape') {
|
|
114
|
+
showJumpInput.value = false
|
|
115
|
+
jumpPageValue.value = ''
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
76
119
|
// Extract route generation to a reusable function to reduce duplicated code
|
|
77
120
|
function page(page: number): RouteLocationRaw {
|
|
78
121
|
if (!isNewPage(page)) {
|
|
@@ -210,12 +253,26 @@ onMounted(() => {
|
|
|
210
253
|
1
|
|
211
254
|
</router-link>
|
|
212
255
|
</li>
|
|
213
|
-
<li v-if="items.page_no - 1 > 2"
|
|
256
|
+
<li v-if="items.page_no - 1 > 2">
|
|
214
257
|
<div
|
|
215
|
-
|
|
258
|
+
v-if="!showJumpInput"
|
|
259
|
+
class="flex items-center justify-center w-5 md:w-6 h-7 md:h-8 text-fv-neutral-500 hover:text-primary-600 dark:text-fv-neutral-400 dark:hover:text-white cursor-pointer transition-all"
|
|
260
|
+
title="Jump to page"
|
|
261
|
+
@click="toggleJumpInput"
|
|
216
262
|
>
|
|
217
263
|
<span class="text-[10px] md:text-xs font-medium">•••</span>
|
|
218
264
|
</div>
|
|
265
|
+
<input
|
|
266
|
+
v-else
|
|
267
|
+
v-model="jumpPageValue"
|
|
268
|
+
type="number"
|
|
269
|
+
:min="1"
|
|
270
|
+
:max="items.page_max"
|
|
271
|
+
class="w-8 md:w-10 h-7 md:h-8 text-xs text-center text-fv-neutral-700 bg-white/80 border border-fv-neutral-300 rounded-md shadow-sm focus:ring-2 focus:ring-primary-400/40 focus:border-primary-400 focus:outline-none dark:bg-fv-neutral-800 dark:text-fv-neutral-300 dark:border-fv-neutral-600 dark:focus:ring-primary-500/40 dark:focus:border-primary-500 transition-all"
|
|
272
|
+
:placeholder="items.page_max.toString().length > 2 ? '···' : '••'"
|
|
273
|
+
@keydown="handleJumpInputKeydown"
|
|
274
|
+
@blur="showJumpInput = false; jumpPageValue = ''"
|
|
275
|
+
>
|
|
219
276
|
</li>
|
|
220
277
|
<li
|
|
221
278
|
v-if="items.page_no - 1 >= 1"
|
|
@@ -250,12 +307,26 @@ onMounted(() => {
|
|
|
250
307
|
{{ items.page_no + 1 }}
|
|
251
308
|
</router-link>
|
|
252
309
|
</li>
|
|
253
|
-
<li v-if="items.page_no + 1 < items.page_max - 1"
|
|
310
|
+
<li v-if="items.page_no + 1 < items.page_max - 1">
|
|
254
311
|
<div
|
|
255
|
-
|
|
312
|
+
v-if="!showJumpInput"
|
|
313
|
+
class="flex items-center justify-center w-5 md:w-6 h-7 md:h-8 text-fv-neutral-500 hover:text-primary-600 dark:text-fv-neutral-400 dark:hover:text-white cursor-pointer transition-all"
|
|
314
|
+
title="Jump to page"
|
|
315
|
+
@click="toggleJumpInput"
|
|
256
316
|
>
|
|
257
317
|
<span class="text-[10px] md:text-xs font-medium">•••</span>
|
|
258
318
|
</div>
|
|
319
|
+
<input
|
|
320
|
+
v-else
|
|
321
|
+
v-model="jumpPageValue"
|
|
322
|
+
type="number"
|
|
323
|
+
:min="1"
|
|
324
|
+
:max="items.page_max"
|
|
325
|
+
class="w-8 md:w-10 h-7 md:h-8 text-xs text-center text-fv-neutral-700 bg-white/80 border border-fv-neutral-300 rounded-md shadow-sm focus:ring-2 focus:ring-primary-400/40 focus:border-primary-400 focus:outline-none dark:bg-fv-neutral-800 dark:text-fv-neutral-300 dark:border-fv-neutral-600 dark:focus:ring-primary-500/40 dark:focus:border-primary-500 transition-all"
|
|
326
|
+
:placeholder="items.page_max.toString().length > 2 ? '···' : '••'"
|
|
327
|
+
@keydown="handleJumpInputKeydown"
|
|
328
|
+
@blur="showJumpInput = false; jumpPageValue = ''"
|
|
329
|
+
>
|
|
259
330
|
</li>
|
|
260
331
|
<li v-if="items.page_no + 1 < items.page_max">
|
|
261
332
|
<router-link
|
|
@@ -266,6 +337,27 @@ onMounted(() => {
|
|
|
266
337
|
{{ items.page_max }}
|
|
267
338
|
</router-link>
|
|
268
339
|
</li>
|
|
340
|
+
<li v-if="items.page_max > 5 && (items.page_no - 1 <= 2 && items.page_no + 1 >= items.page_max - 1)">
|
|
341
|
+
<div
|
|
342
|
+
v-if="!showJumpInput"
|
|
343
|
+
class="flex items-center justify-center w-6 md:w-8 h-7 md:h-8 text-fv-neutral-500 hover:text-primary-600 dark:text-fv-neutral-400 dark:hover:text-white cursor-pointer transition-all"
|
|
344
|
+
title="Jump to page"
|
|
345
|
+
@click="toggleJumpInput"
|
|
346
|
+
>
|
|
347
|
+
<span class="text-[10px] md:text-xs font-bold">⋯</span>
|
|
348
|
+
</div>
|
|
349
|
+
<input
|
|
350
|
+
v-else
|
|
351
|
+
v-model="jumpPageValue"
|
|
352
|
+
type="number"
|
|
353
|
+
:min="1"
|
|
354
|
+
:max="items.page_max"
|
|
355
|
+
class="w-8 md:w-10 h-7 md:h-8 text-xs text-center text-fv-neutral-700 bg-white/80 border border-fv-neutral-300 rounded-md shadow-sm focus:ring-2 focus:ring-primary-400/40 focus:border-primary-400 focus:outline-none dark:bg-fv-neutral-800 dark:text-fv-neutral-300 dark:border-fv-neutral-600 dark:focus:ring-primary-500/40 dark:focus:border-primary-500 transition-all"
|
|
356
|
+
:placeholder="items.page_max.toString().length > 2 ? '···' : '••'"
|
|
357
|
+
@keydown="handleJumpInputKeydown"
|
|
358
|
+
@blur="showJumpInput = false; jumpPageValue = ''"
|
|
359
|
+
>
|
|
360
|
+
</li>
|
|
269
361
|
<li v-if="items.page_no < items.page_max">
|
|
270
362
|
<button
|
|
271
363
|
type="button"
|