@redseed/redseed-ui-vue3 2.13.1 → 2.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redseed/redseed-ui-vue3",
3
- "version": "2.13.1",
3
+ "version": "2.13.3",
4
4
  "description": "RedSeed UI Vue 3 components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,7 +45,15 @@ const pageUpdated = (event) => {
45
45
  emit('pageUpdated', event)
46
46
  }
47
47
 
48
- const emit = defineEmits(['pageUpdated'])
48
+ const firstPageUpdated = (event) => {
49
+ emit('firstPageUpdated', event)
50
+ }
51
+
52
+ const lastPageUpdated = (event) => {
53
+ emit('lastPageUpdated', event)
54
+ }
55
+
56
+ const emit = defineEmits(['pageUpdated', 'firstPageUpated', 'lastPageUpdated'])
49
57
 
50
58
  const showEmptyMessage = computed(() => !props.totalItems && !props.controlApplied)
51
59
 
@@ -54,8 +62,14 @@ const showNotFoundMessage = computed(() => !props.totalItems && props.controlApp
54
62
  <template>
55
63
  <div ref="cardGroupElement" :class="cardGroupClasses">
56
64
  <div class="rsui-card-group__pagination">
57
- <Pagination v-if="totalItems > perPage" :totalItems="totalItems" :perPage="perPage" :currentPage="currentPage"
58
- @change="pageUpdated"></Pagination>
65
+ <Pagination v-if="totalItems > perPage"
66
+ :totalItems="totalItems"
67
+ :perPage="perPage"
68
+ :currentPage="currentPage"
69
+ @change="pageUpdated"
70
+ @first="pageUpdated"
71
+ @last="pageUpdated"
72
+ ></Pagination>
59
73
  </div>
60
74
  <div v-if="totalItems" class="rsui-card-group__cards">
61
75
  <slot></slot>
@@ -95,7 +109,7 @@ const showNotFoundMessage = computed(() => !props.totalItems && props.controlApp
95
109
  }
96
110
  }
97
111
 
98
- &--md,
112
+ &--md,
99
113
  &--lg,
100
114
  &--xl {
101
115
  .rsui-card-group__cards {
@@ -40,7 +40,7 @@ const paginationClass = computed(() => [
40
40
  }
41
41
  ])
42
42
 
43
- const emit = defineEmits(['change'])
43
+ const emit = defineEmits(['change', 'firstPage', 'lastPage'])
44
44
 
45
45
  const listControlElement = ref(null)
46
46
 
@@ -64,11 +64,15 @@ const searchText = ref('')
64
64
  const appliedFilters = ref([])
65
65
  const sortDesc = ref(false)
66
66
  const pagination = ref(null)
67
+ const paginationFirst = ref(null)
68
+ const paginationLast = ref(null)
67
69
 
68
70
  watch(searchText, () => { fireChangeEvent() }, { flush: 'post' })
69
71
  watch(appliedFilters, () => { fireChangeEvent() }, { deep: true, flush: 'post' })
70
72
  watch(sortDesc, () => { fireChangeEvent() }, { flush: 'post' })
71
73
  watch(pagination, () => { fireChangeEvent() }, { deep: true, flush: 'post' })
74
+ watch(paginationFirst, () => { fireFirstPageEvent() }, { deep: true, flush: 'post' })
75
+ watch(paginationLast, () => { fireLastPageEvent() }, { deep: true, flush: 'post' })
72
76
 
73
77
  function fireChangeEvent() {
74
78
  emit('change', {
@@ -78,6 +82,24 @@ function fireChangeEvent() {
78
82
  pagination: pagination.value
79
83
  })
80
84
  }
85
+
86
+ function fireFirstPageEvent() {
87
+ emit('firstPage', {
88
+ searchText: searchText.value,
89
+ appliedFilters: appliedFilters.value,
90
+ sortDesc: sortDesc.value,
91
+ pagination: pagination.value
92
+ })
93
+ }
94
+
95
+ function fireLastPageEvent() {
96
+ emit('lastPage', {
97
+ searchText: searchText.value,
98
+ appliedFilters: appliedFilters.value,
99
+ sortDesc: sortDesc.value,
100
+ pagination: pagination.value
101
+ })
102
+ }
81
103
  </script>
82
104
  <template>
83
105
  <div ref="listControlElement"
@@ -135,6 +157,8 @@ function fireChangeEvent() {
135
157
  :perPage="perPage"
136
158
  :currentPage="currentPage"
137
159
  @change="pagination = $event"
160
+ @fitst="paginationFirst = $event"
161
+ @last="paginationLast = $event"
138
162
  ></Pagination>
139
163
  </div>
140
164
  </div>
@@ -124,8 +124,11 @@ const range = computed(() => {
124
124
  if (goingNext.value) return startRange
125
125
  }
126
126
 
127
- // default to show start range
128
- return startRange
127
+ if (current.value <= scaleOffset + 1) return startRange
128
+
129
+ if (current.value == totalPages.value) return endRange
130
+
131
+ return middleRangeGoingNext
129
132
  })
130
133
 
131
134
  const showSingleScale = computed(() => hasOnePage.value || props.currentPageOnly)
@@ -150,7 +153,7 @@ const showCollapsedEnd = computed(() => totalPages.value > 6
150
153
  && !range.value.includes(totalPages.value)
151
154
  )
152
155
 
153
- const emit = defineEmits(['change'])
156
+ const emit = defineEmits(['change', 'first', 'last'])
154
157
 
155
158
  const goingPrevious = ref(false)
156
159
  const goingNext = ref(false)
@@ -176,6 +179,26 @@ function goToPage(page) {
176
179
  perPage: props.perPage,
177
180
  })
178
181
  }
182
+
183
+ function goToFirstPage(page) {
184
+ goToPage(page)
185
+
186
+ emit('first', {
187
+ currentPage: current.value,
188
+ totalPages: totalPages.value,
189
+ perPage: props.perPage,
190
+ })
191
+ }
192
+
193
+ function goToLastPage(page) {
194
+ goToPage(page)
195
+
196
+ emit('last', {
197
+ currentPage: current.value,
198
+ totalPages: totalPages.value,
199
+ perPage: props.perPage,
200
+ })
201
+ }
179
202
  </script>
180
203
  <template>
181
204
  <div class="rsui-pagination">
@@ -217,7 +240,7 @@ function goToPage(page) {
217
240
  <PaginationItem
218
241
  v-if="showCollapsedStart"
219
242
  :active="current == 1"
220
- @click="goToPage(1)"
243
+ @click="goToFirstPage(1)"
221
244
  >
222
245
  1
223
246
  </PaginationItem>
@@ -241,7 +264,7 @@ function goToPage(page) {
241
264
  <PaginationItem
242
265
  v-if="showCollapsedEnd"
243
266
  :active="totalPages == current"
244
- @click="goToPage(totalPages)"
267
+ @click="goToLastPage(totalPages)"
245
268
  >
246
269
  {{ totalPages }}
247
270
  </PaginationItem>