adminforth 1.11.5-next.1 → 1.11.5-next.3

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.
@@ -63,7 +63,8 @@
63
63
  <SkeleteLoader
64
64
  v-if="!rows"
65
65
  :columns="resource?.columns.filter(c => c.showIn.list).length + 2"
66
- :rows="3"
66
+ :rows="rowHeights.length || 3"
67
+ :row-heights="rowHeights"
67
68
  />
68
69
  <tr v-else-if="rows.length === 0" class="bg-lightListTable dark:bg-darkListTable dark:border-darkListTableBorder">
69
70
  <td :colspan="resource?.columns.length + 2">
@@ -80,6 +81,7 @@
80
81
 
81
82
  <tr @click="onClick($event,row)"
82
83
  v-else v-for="(row, rowI) in rows" :key="`row_${row._primaryKeyValue}`"
84
+ ref="rowRefs"
83
85
  class="bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover"
84
86
 
85
87
  :class="{'border-b': rowI !== rows.length - 1, 'cursor-pointer': row._clickUrl !== null}"
@@ -187,7 +189,7 @@
187
189
  <!-- Buttons -->
188
190
  <button
189
191
  class="flex items-center py-1 px-3 gap-1 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 rounded-s border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
190
- @click="page--" :disabled="page <= 1">
192
+ @click="page--; pageInput = page.toString();" :disabled="page <= 1">
191
193
  <svg class="w-3.5 h-3.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
192
194
  viewBox="0 0 14 10">
193
195
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
@@ -199,28 +201,28 @@
199
201
  </button>
200
202
  <button
201
203
  class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
202
- @click="page = 1" :disabled="page <= 1">
204
+ @click="page = 1; pageInput = page.toString();" :disabled="page <= 1">
203
205
  <!-- <IconChevronDoubleLeftOutline class="w-4 h-4" /> -->
204
206
  1
205
207
  </button>
206
- <div
208
+ <div
207
209
  contenteditable="true"
208
210
  class="min-w-10 outline-none inline-block w-auto min-w-10 py-1.5 px-3 text-sm text-center text-gray-700 border border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800 z-10"
209
211
  @input="page = parseInt($event.target.innerText) || ''"
210
212
  >
211
- {{ page }}
213
+ {{ pageInput }}
212
214
  </div>
213
215
 
214
216
  <button
215
217
  class="flex items-center py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
216
- @click="page = totalPages" :disabled="page >= totalPages">
218
+ @click="page = totalPages; pageInput = page.toString();" :disabled="page >= totalPages">
217
219
  {{ totalPages }}
218
220
 
219
221
  <!-- <IconChevronDoubleRightOutline class="w-4 h-4" /> -->
220
222
  </button>
221
223
  <button
222
224
  class="flex items-center py-1 px-3 gap-1 text-sm font-medium text-gray-900 focus:outline-none bg-white border-l-0 rounded-e border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
223
- @click="page++" :disabled="page >= totalPages">
225
+ @click="page++; pageInput = page.toString();" :disabled="page >= totalPages">
224
226
  <span class="hidden sm:inline">{{ $t('Next') }}</span>
225
227
  <svg class="w-3.5 h-3.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
226
228
  viewBox="0 0 14 10">
@@ -269,7 +271,7 @@
269
271
  <script setup lang="ts">
270
272
 
271
273
 
272
- import { computed, onMounted, ref, watch, type Ref } from 'vue';
274
+ import { computed, onMounted, ref, watch, useTemplateRef, type Ref } from 'vue';
273
275
  import { callAdminForthApi } from '@/utils';
274
276
  import { useI18n } from 'vue-i18n';
275
277
  import ValueRenderer from '@/components/ValueRenderer.vue';
@@ -316,6 +318,7 @@ const emits = defineEmits([
316
318
  ]);
317
319
 
318
320
  const checkboxesInternal: Ref<any[]> = ref([]);
321
+ const pageInput = ref('1');
319
322
  const page = ref(1);
320
323
  const sort = ref([]);
321
324
 
@@ -344,9 +347,19 @@ watch(() => props.sort, (newSort) => {
344
347
  });
345
348
 
346
349
  watch(() => props.page, (newPage) => {
350
+ // page.value and newPage will not be equal only on page load
351
+ // this check prevents cursor jumping on manual input
352
+ if (page.value !== newPage) pageInput.value = newPage.toString();
347
353
  page.value = newPage;
348
354
  });
349
355
 
356
+ const rowRefs = useTemplateRef('rowRefs');
357
+ const rowHeights = ref([]);
358
+ watch(() => props.rows, (newRows) => {
359
+ // rows are set to null when new records are loading
360
+ rowHeights.value = newRows ? [] : rowRefs.value.map((el) => el.offsetHeight);
361
+ });
362
+
350
363
  function addToCheckedValues(id) {
351
364
  if (checkboxesInternal.value.includes(id)) {
352
365
  checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== id);
@@ -1,6 +1,10 @@
1
1
  <template>
2
- <tr v-for="c in new Array(props.rows)" class="bg-lightListTable border-b dark:bg-darkListTable dark:border-darkListBorder">
3
- <td v-for="r in new Array(props.columns)" class="items-center px-6 py-8 cursor-default" >
2
+ <tr
3
+ v-for="(r, ri) in new Array(props.rows)"
4
+ class="bg-lightListTable border-b dark:bg-darkListTable dark:border-darkListBorder"
5
+ :style="[props.rowHeights[ri] !== undefined ? `height: ${props.rowHeights[ri]}px` : '' ]"
6
+ >
7
+ <td v-for="c in new Array(props.columns)" class="items-center px-6 py-8 cursor-default" >
4
8
  <div role="status" class="max-w-sm animate-pulse">
5
9
  <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
6
10
  </div>
@@ -10,9 +14,12 @@
10
14
 
11
15
  <script setup lang="ts">
12
16
 
13
- const props = defineProps<{
17
+ const props = withDefaults(defineProps<{
14
18
  columns: number;
15
19
  rows: number;
16
- }>();
20
+ rowHeights?: number[];
21
+ }>(), {
22
+ rowHeights: [],
23
+ });
17
24
 
18
25
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.11.5-next.1",
3
+ "version": "1.11.5-next.3",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",