@fy-/fws-vue 2.3.51 → 2.3.52
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)) {
|
|
@@ -250,12 +293,26 @@ onMounted(() => {
|
|
|
250
293
|
{{ items.page_no + 1 }}
|
|
251
294
|
</router-link>
|
|
252
295
|
</li>
|
|
253
|
-
<li v-if="items.page_no + 1 < items.page_max - 1"
|
|
296
|
+
<li v-if="items.page_no + 1 < items.page_max - 1">
|
|
254
297
|
<div
|
|
255
|
-
|
|
298
|
+
v-if="!showJumpInput"
|
|
299
|
+
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"
|
|
300
|
+
title="Jump to page"
|
|
301
|
+
@click="toggleJumpInput"
|
|
256
302
|
>
|
|
257
303
|
<span class="text-[10px] md:text-xs font-medium">•••</span>
|
|
258
304
|
</div>
|
|
305
|
+
<input
|
|
306
|
+
v-else
|
|
307
|
+
v-model="jumpPageValue"
|
|
308
|
+
type="number"
|
|
309
|
+
:min="1"
|
|
310
|
+
:max="items.page_max"
|
|
311
|
+
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"
|
|
312
|
+
:placeholder="items.page_max.toString().length > 2 ? '···' : '••'"
|
|
313
|
+
@keydown="handleJumpInputKeydown"
|
|
314
|
+
@blur="showJumpInput = false; jumpPageValue = ''"
|
|
315
|
+
>
|
|
259
316
|
</li>
|
|
260
317
|
<li v-if="items.page_no + 1 < items.page_max">
|
|
261
318
|
<router-link
|