@webilio-xyz/webilio-vue 1.0.11 → 1.0.13

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": "@webilio-xyz/webilio-vue",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host 0.0.0.0",
@@ -115,8 +115,14 @@ onUnmounted(() => {
115
115
  />
116
116
  </div>
117
117
  </div>
118
- <div>
118
+ <div class="flex flex-col space-y-2">
119
+ <div>
119
120
  <slot name="content" />
121
+ </div>
122
+
123
+ <div>
124
+ <slot name="footer" />
125
+ </div>
120
126
  </div>
121
127
  </template>
122
128
  </div>
@@ -29,6 +29,22 @@ const props = defineProps({
29
29
  footerClass: {
30
30
  type: String,
31
31
  default: ''
32
+ },
33
+ headerClass: {
34
+ type: String,
35
+ default: ''
36
+ },
37
+ trHeadClass: {
38
+ type: String,
39
+ default: ''
40
+ },
41
+ paginationClass: {
42
+ type: String,
43
+ default: ''
44
+ },
45
+ currentPage: {
46
+ type: Number,
47
+ default: 1
32
48
  }
33
49
  })
34
50
 
@@ -42,7 +58,9 @@ const computedResults = computed(() => {
42
58
 
43
59
  const dataLoading = ref(false);
44
60
 
45
- const currentPage = ref(get(data, 'current_page', 1));
61
+ const tableCurrentPage = ref(get(data, 'current_page', props.currentPage));
62
+
63
+
46
64
 
47
65
  defineExpose({
48
66
  getData
@@ -54,7 +72,7 @@ function getData() {
54
72
  window.location.pathname,
55
73
  {
56
74
  filters: {...props.additionalFilters, ...filters.value},
57
- page: currentPage.value
75
+ page: tableCurrentPage.value
58
76
  },
59
77
  {
60
78
  preserveState: true,
@@ -73,25 +91,35 @@ function getData() {
73
91
  const debouncedGetData = debounce(getData, 500);
74
92
 
75
93
  watch(props, debouncedGetData, {deep: true});
76
- watch(currentPage, debouncedGetData)
77
-
94
+ watch(tableCurrentPage, debouncedGetData)
95
+ watch(() => props.currentPage, (newPage) => {
96
+ tableCurrentPage.value = newPage
97
+ })
78
98
  </script>
79
99
 
80
100
  <template>
81
101
  <TableComponent
102
+ ref="props.table"
82
103
  :is-loading="dataLoading"
83
104
  :data="computedResults"
84
105
  :columns="columns"
85
106
  :class="tableClass"
107
+ :headerClass="headerClass"
108
+ :trHeadClass="trHeadClass"
86
109
  />
87
- <div class="flex items-center" :class="footerClass">
88
- <div class="flex-grow flex">
89
- <span class="py-2">{{ $t('table.nbResults', {total: get(data, 'total', 0)}) }}</span>
90
- </div>
91
-
92
- <TablePaginationComponent
93
- :last-page="data.last_page"
94
- v-model="currentPage"
95
- />
96
- </div>
110
+
111
+ <slot name="pagination">
112
+ <div class="flex items-center" :class="footerClass">
113
+ <div class="flex-grow flex">
114
+ <span class="py-2">{{ $t('table.nbResults', {total: get(data, 'total', 0)}) }}</span>
115
+ </div>
116
+
117
+ <TablePaginationComponent
118
+ :last-page="data.last_page"
119
+ v-model="tableCurrentPage"
120
+ :class="footerClass"
121
+ />
122
+ </div>
123
+ </slot>
124
+
97
125
  </template>
@@ -19,6 +19,10 @@ const props = defineProps({
19
19
  headerClass: {
20
20
  type: String,
21
21
  default: ''
22
+ },
23
+ trHeadClass: {
24
+ type: String,
25
+ default: ''
22
26
  }
23
27
  });
24
28
 
@@ -26,7 +30,7 @@ const props = defineProps({
26
30
 
27
31
  <template>
28
32
  <table class="overflow-x-auto table w-full relative">
29
- <TableHeaderComponent :columns="columns" :class="headerClass"/>
33
+ <TableHeaderComponent :columns="columns" :headerClass="headerClass" :trClass="trHeadClass"/>
30
34
  <template v-if="data?.length && !isLoading">
31
35
  <template v-for="(datum, i) in data" :key="i">
32
36
  <TableRowComponent
@@ -7,6 +7,14 @@ const props = defineProps({
7
7
  type: Columns,
8
8
  default: []
9
9
  },
10
+ trClass: {
11
+ type: String,
12
+ default: ''
13
+ },
14
+ headerClass: {
15
+ type: String,
16
+ default: 'sticky border-b-2 h-20 bg-gray-100 z-10 text-gray-700 text-xs font-medium uppercase shadow-md'
17
+ }
10
18
  })
11
19
 
12
20
  const renderedColumns = computed(() => {
@@ -15,8 +23,8 @@ const renderedColumns = computed(() => {
15
23
  </script>
16
24
 
17
25
  <template>
18
- <thead class="sticky border-b-2 h-20 bg-gray-100 z-10 text-gray-700 text-xs font-medium uppercase shadow-md">
19
- <tr>
26
+ <thead :class="headerClass">
27
+ <tr :class="trClass">
20
28
  <th
21
29
  v-for="column in renderedColumns"
22
30
  :key="column.key"
@@ -12,9 +12,27 @@ const props = defineProps({
12
12
  type: Number,
13
13
  default: 1
14
14
  },
15
+ buttonClass: {
16
+ type: String,
17
+ default: ''
18
+ },
19
+ buttonLrClass: {
20
+ type: String,
21
+ default: ''
22
+ },
23
+ buttonPageClass: {
24
+ type: String,
25
+ default: ''
26
+ },
15
27
  });
16
28
 
17
29
  const currentPage = computed(() => props.modelValue);
30
+ const lrClassButtons = computed(() => {
31
+ return `${props.buttonClass} ${props.buttonLrClass}`;
32
+ })
33
+ const pageClassButtons = computed(() => {
34
+ return `${props.buttonClass} ${props.buttonPageClass}`;
35
+ })
18
36
 
19
37
  const emits = defineEmits(['update:modelValue']);
20
38
 
@@ -28,17 +46,19 @@ const changePage = (page) => {
28
46
  <template>
29
47
  <div class="flex space-x-1.5">
30
48
  <Button
49
+ :class="lrClassButtons"
31
50
  :disabled="currentPage === 1"
32
51
  @click="changePage(currentPage - 1)"
33
52
  >
34
53
  <ChevronLeftIcon class="w-5 h-5" />
35
54
  </Button>
36
55
  <template v-if="currentPage === 1">
37
- <Button disabled>
56
+ <Button :class="pageClassButtons" disabled>
38
57
  {{ currentPage }}
39
58
  </Button>
40
59
  <template v-if="lastPage < 5">
41
60
  <Button
61
+ :class="pageClassButtons"
42
62
  v-for="pageId in range(currentPage + 1, lastPage + 1)"
43
63
  :key="pageId"
44
64
  @click="changePage(pageId)"
@@ -48,6 +68,7 @@ const changePage = (page) => {
48
68
  </template>
49
69
  <template v-else>
50
70
  <Button
71
+ :class="pageClassButtons"
51
72
  v-for="pageId in range(currentPage + 1, currentPage + 3)"
52
73
  :key="pageId"
53
74
  @click="changePage(pageId)"
@@ -55,7 +76,7 @@ const changePage = (page) => {
55
76
  {{ pageId }}
56
77
  </Button>
57
78
  <span class="py-2">...</span>
58
- <Button @click="changePage(lastPage)">
79
+ <Button :class="pageClassButtons" @click="changePage(lastPage)">
59
80
  {{ lastPage }}
60
81
  </Button>
61
82
  </template>
@@ -63,6 +84,7 @@ const changePage = (page) => {
63
84
  <template v-else-if="currentPage === lastPage">
64
85
  <template v-if="lastPage < 5">
65
86
  <Button
87
+ :class="pageClassButtons"
66
88
  v-for="pageId in range(1, lastPage)"
67
89
  :key="pageId"
68
90
  @click="changePage(pageId)"
@@ -71,11 +93,12 @@ const changePage = (page) => {
71
93
  </Button>
72
94
  </template>
73
95
  <template v-else>
74
- <Button @click="changePage(1)">
96
+ <Button :class="pageClassButtons" @click="changePage(1)">
75
97
  1
76
98
  </Button>
77
99
  <span class="py-2">...</span>
78
100
  <Button
101
+ :class="pageClassButtons"
79
102
  v-for="pageId in range(currentPage - 2, currentPage)"
80
103
  :key="pageId"
81
104
  @click="changePage(pageId)"
@@ -83,13 +106,13 @@ const changePage = (page) => {
83
106
  {{ pageId }}
84
107
  </Button>
85
108
  </template>
86
- <Button disabled>
109
+ <Button :class="pageClassButtons" disabled>
87
110
  {{ currentPage }}
88
111
  </Button>
89
112
  </template>
90
113
  <template v-else>
91
114
  <template v-if="currentPage > 2">
92
- <Button @click="changePage(1)">
115
+ <Button :class="pageClassButtons" @click="changePage(1)">
93
116
  1
94
117
  </Button>
95
118
  <span
@@ -98,16 +121,18 @@ const changePage = (page) => {
98
121
  >...</span>
99
122
  </template>
100
123
  <Button
124
+ :class="pageClassButtons"
101
125
  v-for="pageId in range(currentPage - 1, currentPage)"
102
126
  :key="pageId"
103
127
  @click="changePage(pageId)"
104
128
  >
105
129
  {{ pageId }}
106
130
  </Button>
107
- <Button disabled>
131
+ <Button :class="pageClassButtons" disabled>
108
132
  {{ currentPage }}
109
133
  </Button>
110
134
  <Button
135
+ :class="pageClassButtons"
111
136
  v-for="pageId in range(currentPage + 1, currentPage + 2)"
112
137
  :key="pageId"
113
138
  @click="changePage(pageId)"
@@ -119,12 +144,13 @@ const changePage = (page) => {
119
144
  v-if="currentPage < (lastPage - 2)"
120
145
  class="py-2"
121
146
  >...</span>
122
- <Button @click="changePage(lastPage)">
147
+ <Button :class="pageClassButtons" @click="changePage(lastPage)">
123
148
  {{ lastPage }}
124
149
  </Button>
125
150
  </template>
126
151
  </template>
127
152
  <Button
153
+ :class="lrClassButtons"
128
154
  :disabled="currentPage === lastPage"
129
155
  @click="changePage(currentPage + 1)"
130
156
  >
@@ -135,4 +161,4 @@ const changePage = (page) => {
135
161
 
136
162
  <style scoped>
137
163
 
138
- </style>
164
+ </style>
@@ -5,7 +5,7 @@ const show = ref(false);
5
5
  export default {
6
6
  component: ModalComponent,
7
7
  description: "Generic modal component",
8
- importStatement: "import { ModalComponent } from from '@webilio-xyz/webilio-vue/Modal';",
8
+ importStatement: "import { ModalComponent } from '@webilio-xyz/webilio-vue/Modal';",
9
9
  propsToDemo: {
10
10
  'show': {
11
11
  props: {
@@ -24,6 +24,11 @@ export default {
24
24
  'modelValue':'content'
25
25
  }
26
26
  },
27
+ 'footer': {
28
+ props: {
29
+ 'modelValue':'footer'
30
+ }
31
+ },
27
32
  },
28
33
  events: {
29
34
  close: () => {