vi-grid-builder 2.0.1 → 2.0.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/README.md CHANGED
@@ -59,15 +59,23 @@ const app = createApp(App).use(ViGridBuilder)
59
59
  | name | String | Name of the field for which data will be presented | / |
60
60
  | sortable | Boolean | Is the column sortable? | false |
61
61
  | isVisible | Boolean | Is the column visible? | true |
62
- | format | Function | Function to format the data before display | / |
62
+ | render | Function | Function to cange| format the data before display | / |
63
63
  | align | centre, left, right | How to align the content in the cells for this column | / |
64
64
  | sort | Function | Compare function for sorting data in this column | / |
65
- mode| date, dateTime, time| Option for date field | dateTime|
66
- format| String| Option for formatting the date field | yyyy-MM-dd HH:mm:ss
67
- actions |Array| Option for field of type action | /|
68
- link |String| Option for field of type link, this will be name of the field from which we need to get the link, and name attribute is for the text of the link| /
69
65
 
70
- ## Example config for columns
66
+ ##Aditional columsn options for sepcific fields
67
+
68
+ field type| option | type | description | default value |
69
+ |------------|------------|-----------------------------|--------------------------------------------------------|---------------|
70
+ |date | mode| date,time, dateTime| what part of the date shoudl be displayed| dateTime
71
+ |date | format| object | format of date field| {date:"yyyy-MM-dd",dateTime:"yyyy-MM-dd HH:mm:ss",time:"HH:mm:ss",}|
72
+ |actions |actions|Array of object| Option for field of type action | every object should have unique action field and name for the text displayed for the action |
73
+ |actions |kebab|boolean| should action menu be 'kebab type'| false |
74
+ |link |String| link field| If the link field is provided, it is used as the URL, and name is used as the link text. If the link field is not provided, both the URL and link text default to the name field value.| /
75
+
76
+
77
+
78
+ ## Example config for columns
71
79
 
72
80
  ```js
73
81
  columns: [
@@ -202,7 +210,7 @@ Pagination is passed as object in table prop, the obejct should have this fields
202
210
  | rowsPerPageOptions |Array of obecjts| Droprdown options for displayin how many rows per page| /
203
211
 
204
212
 
205
- ## Table css classes
213
+ ## CSS CLASSES
206
214
 
207
215
  |class name | description
208
216
  |--|--|
@@ -230,6 +238,31 @@ Pagination is passed as object in table prop, the obejct should have this fields
230
238
  | .vi-footer-row| class for last row in table that holds usually pagination|
231
239
  | .vi-footer-cell| class for cell in last row|
232
240
 
241
+ ## CSS VARIBALES
242
+
243
+ |name | usage | default value
244
+ |--|--|--|
245
+ |--vi-grid-primary-color | background color of header and used as backgorund for rows on hover| rgba(0, 0, 255, 0.65)
246
+ |--vi-grid-primary-text_color | text color of header and used as text color for rows on hover| rgb(255, 255, 255)
247
+ | --vi-grid-secondary-color | background color even rows in stripped table|rgb(243, 243, 243)
248
+ | --vi-grid-text-color | color of text in tabel body cells|rgb(0, 0, 0)
249
+ | --vi-grid-color |background color for table|rgb(255, 255, 255)
250
+
251
+ You can override this values in the options when plugin is installed:
252
+ ```js
253
+ const app = createApp(App);
254
+ app.use(ViGridBuilderPlugin, {
255
+ ...
256
+ style: {
257
+ 'color': 'white',
258
+ 'text-color': 'black',
259
+ 'secondary-color': 'lightgrey',
260
+ 'primary-color': '#f18080',
261
+ 'primary-text-color': 'white',
262
+ }
263
+ });
264
+ ```
265
+
233
266
 
234
267
 
235
268
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vi-grid-builder",
3
3
  "main": "ViGridBuilderPlugin",
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -14,7 +14,7 @@
14
14
  "@fortawesome/free-solid-svg-icons": "^6.7.1",
15
15
  "@fortawesome/vue-fontawesome": "^3.0.8",
16
16
  "date-fns": "^2.30.0",
17
- "vi-pagination": "^1.0.0",
17
+ "vi-pagination": "^1.0.1",
18
18
  "vue": "^3.3.4"
19
19
  },
20
20
  "devDependencies": {
@@ -3,6 +3,8 @@
3
3
  <div>
4
4
  <h1> Examples</h1>
5
5
  </div>
6
+
7
+ <field-types/>
6
8
  <custom-header/>
7
9
 
8
10
 
@@ -49,10 +51,12 @@ import TableStyle from "@/components/TableStyle.vue";
49
51
  import PaginationOptions from "@/components/PaginationOptions.vue";
50
52
  import CustomField from "@/components/CustomField.vue";
51
53
  import GlobalOptions from "@/components/GlobalOptions.vue";
54
+ import FieldTypes from "@/components/FieldTypes.vue";
52
55
 
53
56
 
54
57
  export default {
55
58
  components: {
59
+ FieldTypes,
56
60
  GlobalOptions,
57
61
  CustomField,
58
62
  PaginationOptions,
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <div class="example-container">
3
+
4
+ <h3 id="custom-header">Defautl field types</h3>
5
+ <div class="example-body">
6
+
7
+ <vi-grid-builder
8
+ stripped
9
+ v-bind="config"
10
+ v-model:pagination="config.pagination"
11
+ :rows="rows"
12
+ :server-mode="false"
13
+ />
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import axios from "axios";
20
+
21
+ function getRandomDate(startDate, endDate) {
22
+ const start = new Date(startDate).getTime();
23
+ const end = new Date(endDate).getTime();
24
+ const randomTimestamp = Math.floor(Math.random() * (end - start + 1)) + start;
25
+ return new Date(randomTimestamp).toISOString();
26
+ }
27
+ const posts = Array.from({ length: 25 }, (_, index) => ({
28
+ id: index + 1,
29
+ title: `Post Title ${index + 1}`,
30
+ link: `https://example.com/post-${index + 1}`,
31
+ image: "https://images.pexels.com/photos/2325447/pexels-photo-2325447.jpeg",
32
+ status: Math.random() > 0.5 ? "published" : "unpublished",
33
+ date:getRandomDate("2020-01-01", "2024-12-31")
34
+ }));
35
+
36
+ console.log(posts);
37
+
38
+
39
+ export default {
40
+
41
+ data: () => ({
42
+
43
+ loading: true,
44
+ rows:posts,
45
+ config: {
46
+ rowKey: 'id',
47
+ columns: [{
48
+ label: 'ID',
49
+ name: 'id',
50
+
51
+ },
52
+ {
53
+ label: 'Title',
54
+ name: 'title',
55
+ },
56
+ {
57
+ label: 'Link',
58
+ name: 'link',
59
+ type:'link',
60
+ // link:'link'
61
+ },
62
+ {
63
+ label: 'Link with title',
64
+ name: 'title',
65
+ type:'link',
66
+ link:'link'
67
+ },
68
+ {
69
+ label: 'Image',
70
+ name: 'image',
71
+ type:'image'
72
+ },
73
+ {
74
+ label: 'Status',
75
+ name: 'status',
76
+ type:'badge'
77
+ },
78
+ {
79
+ label: 'Date',
80
+ name: 'date',
81
+ type:'date',
82
+ mode:'date'
83
+ },
84
+ {
85
+ label: 'Time',
86
+ name: 'date',
87
+ type:'date',
88
+ mode:'time'
89
+ },
90
+ {
91
+ label: 'Simple actions',
92
+ name: 'actions',
93
+ type:'actions',
94
+ actions:[
95
+ {
96
+ action:'edit',
97
+ name:'Edit post'
98
+ },
99
+ {
100
+ action:'remove',
101
+ name:'Remove post'
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ label: 'Kebap type actions',
107
+ name: 'actions',
108
+ type:'actions',
109
+ kebab:true,
110
+ actions:[
111
+ {
112
+ action:'edit',
113
+ name:'Edit post'
114
+ },
115
+ {
116
+ action:'remove',
117
+ name:'Remove post'
118
+ }
119
+ ]
120
+ },
121
+ ],
122
+
123
+ pagination: {page: 1, rowsPerPage:15},
124
+
125
+ },
126
+ compact: false,
127
+
128
+ }),
129
+
130
+ }
131
+
132
+
133
+ </script>
134
+
135
+
136
+ <style scoped lang="scss">
137
+
138
+ </style>
@@ -5,19 +5,17 @@ import App from './App.vue'
5
5
 
6
6
  import ViGridBuilderPlugin from '../../ViGridBuilderPlugin.js';
7
7
  import SampleCustomField from "./components/fields/SampleCustomField.vue";
8
- import LoadingSlot from "@/components/LoadingSlot.vue";
9
8
 
10
9
  const app = createApp(App);
11
10
  app.use(ViGridBuilderPlugin, {
12
11
  fieldComponents: {
13
12
  SampleCustomField,
14
13
  },
15
- defaultSlots:{
16
- loading:LoadingSlot
14
+ dateFormats:{
15
+ time:'HH:mm'
17
16
  },
18
17
 
19
18
  align: 'right',
20
- disablePagination: true,
21
19
 
22
20
  compactPagination: true,
23
21
  noDataLabel: 'emtpy tabled',
@@ -4,7 +4,7 @@
4
4
 
5
5
  --vi-grid-secondary-color: rgb(243, 243, 243); //stripped background
6
6
  --vi-grid-text-color: rgb(0, 0, 0); //text color in body cells
7
- --vi-grid-color: rgb(255, 255, 255); //backgournd color for table
7
+ --vi-grid-color: rgb(255, 255, 255); //background color for table
8
8
  }
9
9
  .vi-grid-builder {
10
10
  width: 100%;
@@ -101,7 +101,7 @@
101
101
  <vi-grid-field
102
102
  :class="column.align ?? settings.align"
103
103
  :field="column"
104
- :field-value="column.format ? column.format(row) : row[column.name]"
104
+ :field-value="column.render ? column.render(row) : row[column.name]"
105
105
  :row-value="row"
106
106
  :row-key="rowKey"
107
107
  v-model:row-menu-opened="rowMenuOpened"
@@ -17,6 +17,9 @@ export default function useRowHelper(props, emit) {
17
17
  }
18
18
 
19
19
  let rowsPerPage = props.pagination?.rowsPerPage ?? globalGridSettings.value.rowsPerPage
20
+ if (rowsPerPage === 0) {
21
+ return sortedRows.value;
22
+ }
20
23
  const startIndex = (props.pagination.page - 1) * rowsPerPage;
21
24
  const endIndex = startIndex + rowsPerPage;
22
25
 
@@ -1,3 +1,7 @@
1
1
  .vi-grid-image {
2
2
 
3
+ img {
4
+ max-width: 100%;
5
+ max-height: 100px;
6
+ }
3
7
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="vi-grid-link">
3
- <a :href="row[link]" target="_blank" v-if="row[link]">{{value}}</a>
3
+ <a :href="row[link] ?? value" target="_blank" v-if="(link && row[link]) || (!link && value)">{{value}}</a>
4
4
  <div v-else>{{value}}</div>
5
5
  </div>
6
6
  </template>
@@ -11,7 +11,7 @@
11
11
  props: {
12
12
  link: {
13
13
  type: String,
14
- required: true
14
+ // required: true
15
15
  },
16
16
  row: {
17
17
  type: Object,
@@ -1,11 +0,0 @@
1
- <script setup>
2
-
3
- </script>
4
-
5
- <template>
6
- <idv> loading default slot</idv>
7
- </template>
8
-
9
- <style scoped lang="scss">
10
-
11
- </style>
@@ -1,18 +0,0 @@
1
- <template>
2
- <div class="vi-grid-number">
3
- {{value}}
4
- </div>
5
- </template>
6
-
7
- <script>
8
- export default {
9
- name: "ViGridNumber",
10
- props: {
11
- value: {},
12
- },
13
- }
14
- </script>
15
-
16
- <style lang="scss">
17
- @import "ViGridNumber";
18
- </style>