wave-ui 3.1.0 → 3.1.2

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": "wave-ui",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "An emerging UI framework for Vue.js (2 & 3) with only the bright side. :sunny:",
5
5
  "author": "Antoni Andre <antoniandre.web@gmail.com>",
6
6
  "homepage": "https://antoniandre.github.io/wave-ui",
@@ -49,24 +49,25 @@
49
49
  "lint": "vite lint"
50
50
  },
51
51
  "devDependencies": {
52
- "@babel/core": "^7.21.0",
53
- "@babel/eslint-parser": "^7.19.1",
52
+ "@babel/core": "^7.21.3",
53
+ "@babel/eslint-parser": "^7.21.3",
54
54
  "@babel/plugin-proposal-class-properties": "^7.18.6",
55
+ "@faker-js/faker": "^7.6.0",
55
56
  "@mdi/font": "^5.9.55",
56
57
  "@vitejs/plugin-vue": "^3.2.0",
57
58
  "@vue/compiler-sfc": "3.2.45",
58
- "autoprefixer": "^10.4.13",
59
- "axios": "^0.25.0",
60
- "eslint": "^7.32.0",
61
- "eslint-plugin-vue": "^9.9.0",
59
+ "autoprefixer": "^10.4.14",
60
+ "axios": "^1.3.4",
61
+ "eslint": "^8.36.0",
62
+ "eslint-plugin-vue": "^9.10.0",
62
63
  "font-awesome": "^4.7.0",
63
- "gsap": "^3.11.4",
64
+ "gsap": "^3.11.5",
64
65
  "ionicons": "^4.6.3",
65
66
  "material-design-icons": "^3.0.1",
66
67
  "postcss": "^8.4.21",
67
68
  "pug": "^3.0.2",
68
69
  "rollup-plugin-delete": "^2.0.0",
69
- "sass": "^1.58.3",
70
+ "sass": "^1.60.0",
70
71
  "simple-syntax-highlighter": "^2.2.5",
71
72
  "splitpanes": "^3.1.5",
72
73
  "standard": "^17.0.0",
@@ -59,7 +59,7 @@
59
59
 
60
60
  //- Normal rows.
61
61
  template(v-if="tableItems.length && loading !== true")
62
- template(v-for="(item, i) in sortedItems" :key="i")
62
+ template(v-for="(item, i) in paginatedItems" :key="i")
63
63
  //- Fully custom tr (`item` slot).
64
64
  slot(
65
65
  v-if="$slots.item"
@@ -136,26 +136,41 @@
136
136
  tr.w-table__row.w-table__pagination-wrap(v-if="pagination && paginationConfig")
137
137
  td.w-table__cell(:colspan="headers.length")
138
138
  .w-table__pagination
139
- w-select.pagination-number.pagination-number--items-per-page(
140
- v-if="paginationConfig.itemsPerPageOptions"
141
- v-model="paginationConfig.itemsPerPage"
142
- :items="paginationConfig.itemsPerPageOptions"
143
- label-position="left"
144
- label="Items per page"
145
- label-color="inherit")
146
- span.pagination-number.pagination-number--results.
147
- {{ paginationConfig.start }}-{{ paginationConfig.end }} of {{ paginationConfig.total }}
148
- .pagination-arrows
149
- w-button.pagination-arrow.pagination-arrow--prev(
150
- @click="paginationConfig.page--"
151
- icon="wi-chevron-left"
152
- text
153
- lg)
154
- w-button.pagination-arrow.pagination-arrow--next(
155
- @click="paginationConfig.page++"
156
- icon="wi-chevron-right"
157
- text
158
- lg)
139
+ | {{ paginationConfig }}
140
+ slot(
141
+ name="pagination"
142
+ :range="`${paginationConfig.start}-${paginationConfig.end} of ${paginationConfig.total}`"
143
+ :total="paginationConfig.total")
144
+ w-select.pagination-number.pagination-number--items-per-page(
145
+ v-if="paginationConfig.itemsPerPageOptions"
146
+ v-model="paginationConfig.itemsPerPage"
147
+ @input="updatePaginationConfig"
148
+ :items="paginationConfig.itemsPerPageOptions"
149
+ label-position="left"
150
+ label="Items per page"
151
+ label-color="inherit")
152
+ .pagination-arrows
153
+ w-button.pagination-arrow.pagination-arrow--prev(
154
+ @click="goToPage('-1')"
155
+ :disabled="paginationConfig.page <= 1"
156
+ icon="wi-chevron-left"
157
+ text
158
+ lg)
159
+ w-button.pagination-arrow.pagination-arrow--prev(
160
+ v-for="i in paginationConfig.pagesCount"
161
+ :key="i"
162
+ @click="goToPage(i)"
163
+ round
164
+ text
165
+ lg) {{ i }}
166
+ w-button.pagination-arrow.pagination-arrow--next(
167
+ @click="goToPage('+1')"
168
+ :disabled="paginationConfig.page >= paginationConfig.pagesCount"
169
+ icon="wi-chevron-right"
170
+ text
171
+ lg)
172
+ span.pagination-number.pagination-number--results.
173
+ {{ paginationConfig.start }}-{{ paginationConfig.end }} of {{ paginationConfig.total }}
159
174
  </template>
160
175
 
161
176
  <script>
@@ -339,6 +354,10 @@ export default {
339
354
  // Faster lookup than array.includes(uid) and also cached.
340
355
  expandedRowsByUid () {
341
356
  return this.expandedRowsInternal.reduce((obj, uid) => (obj[uid] = true) && obj, {})
357
+ },
358
+
359
+ paginatedItems () {
360
+ return this.sortedItems.slice(this.paginationConfig.start, this.paginationConfig.end)
342
361
  }
343
362
  },
344
363
 
@@ -535,17 +554,32 @@ export default {
535
554
  },
536
555
 
537
556
  updatePaginationConfig () {
538
- const itemsPerPage = this.pagination?.itemsPerPage || 10
557
+ const itemsPerPage = this.pagination?.itemsPerPage || 20
558
+ const itemsPerPageOptions = this.pagination?.itemsPerPageOptions || [20, 100, { label: 'All', value: 0 }]
539
559
  const total = this.pagination?.total || this.items.length
560
+ const itemsPerPageOrTotal = itemsPerPage || total
540
561
  const page = this.pagination?.page || 1
541
562
  this.paginationConfig = {
542
563
  itemsPerPage,
543
- itemsPerPageOptions: this.pagination?.itemsPerPageOptions || [{ label: '10', value: 10 }, { label: '100', value: 100 }, { label: 'All', value: 0 }],
564
+ itemsPerPageOptions: itemsPerPageOptions.map(item => ({
565
+ label: ['string', 'number'].includes(typeof item) ? item.toString() : (item.label || item.value),
566
+ value: ['string', 'number'].includes(typeof item) ? ~~item : (item.value ?? item.label)
567
+ })),
544
568
  page,
545
569
  start: this.pagination?.start || 1,
546
- end: total >= (itemsPerPage * page) ? (itemsPerPage * page) : (total % (itemsPerPage * page)),
547
- total
570
+ end: total >= (itemsPerPageOrTotal * page) ? (itemsPerPageOrTotal * page) : (total % (itemsPerPageOrTotal * page)),
571
+ total,
572
+ pagesCount: Math.ceil(total / itemsPerPageOrTotal)
548
573
  }
574
+ },
575
+
576
+ goToPage (page) {
577
+ if (['-1', '+1'].includes(page)) this.paginationConfig.page += +page
578
+ else this.paginationConfig.page = page
579
+ const { itemsPerPage } = this.paginationConfig
580
+ this.paginationConfig.page = Math.max(1, this.paginationConfig.page)
581
+ this.paginationConfig.start = (itemsPerPage * (this.paginationConfig.page - 1)) + 1
582
+ this.paginationConfig.end = (this.paginationConfig.start - 1) + itemsPerPage
549
583
  }
550
584
  },
551
585
 
@@ -581,6 +615,11 @@ export default {
581
615
 
582
616
  selectedRows (array) {
583
617
  this.selectedRowsInternal = Array.isArray(array) && array.length ? this.selectedRows : []
618
+ },
619
+
620
+ pagination: {
621
+ handler () { this.updatePaginationConfig() },
622
+ deep: true
584
623
  }
585
624
  }
586
625
  }
@@ -800,27 +839,31 @@ $tr-border-top: 1px;
800
839
  }
801
840
  }
802
841
 
842
+ // Pagination.
843
+ // ------------------------------------------------------
844
+ &__pagination-wrap {
845
+ border-top: $border;
846
+ }
803
847
  &__pagination {
804
848
  display: flex;
805
849
  align-items: center;
806
850
  justify-content: flex-end;
807
- padding-top: $base-increment;
808
- padding-bottom: $base-increment;
809
851
 
810
852
  .pagination-number--items-per-page {
811
- margin-right: 6 * $base-increment;
812
853
  flex-grow: 0;
813
854
  text-align: right;
814
855
  }
856
+
857
+ .pagination-arrows {
858
+ margin-left: 3 * $base-increment;
859
+ margin-right: 3 * $base-increment;
860
+ }
861
+
815
862
  .pagination-number--of {
816
863
  margin-left: $base-increment;
817
864
  margin-right: $base-increment;
818
865
  }
819
866
  .w-select__selection {max-width: 60px;}
820
-
821
- .pagination-arrows {
822
- margin-left: 6 * $base-increment;
823
- }
824
867
  }
825
868
  }
826
869
 
@@ -48,7 +48,7 @@ $base-font-size: 14px !default; // Must be a px unit.
48
48
  $base-increment: round(divide($base-font-size, 4)) !default;
49
49
  $layout-padding: $base-increment * 4 !default; // Applied on the .content-wrap tag.
50
50
  $border-radius: 3px !default;
51
- $border-color: rgba(var(--w-contrast-bg-color-rgb), 0.15) !default;
51
+ $border-color: rgba(var(--w-contrast-bg-color-rgb), 0.12) !default;
52
52
  $border: 1px solid $border-color !default;
53
53
  $transition-duration: 0.25s !default;
54
54
  $fast-transition-duration: 0.15s !default;