vi-grid-builder 1.0.6 → 2.0.0

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.
Files changed (63) hide show
  1. package/README.md +240 -11
  2. package/ViGridBuilderPlugin.js +35 -36
  3. package/package.json +5 -2
  4. package/playground/.vscode/extensions.json +3 -0
  5. package/playground/README.md +29 -0
  6. package/playground/index.html +13 -0
  7. package/playground/jsconfig.json +8 -0
  8. package/playground/package-lock.json +2524 -0
  9. package/playground/package.json +20 -0
  10. package/playground/public/favicon.ico +0 -0
  11. package/playground/src/App.vue +84 -0
  12. package/playground/src/assets/base.css +86 -0
  13. package/playground/src/assets/logo.svg +1 -0
  14. package/playground/src/assets/main.css +35 -0
  15. package/playground/src/components/ActionsField.vue +99 -0
  16. package/playground/src/components/ClickableRow.vue +68 -0
  17. package/playground/src/components/ClientSideData.vue +86 -0
  18. package/playground/src/components/ColumnVisibility.vue +85 -0
  19. package/playground/src/components/CustomField.vue +64 -0
  20. package/playground/src/components/CustomHeader.vue +85 -0
  21. package/playground/src/components/GlobalOptions.vue +68 -0
  22. package/playground/src/components/LoadingSlot.vue +11 -0
  23. package/playground/src/components/PaginationOptions.vue +130 -0
  24. package/playground/src/components/RowSelect.vue +72 -0
  25. package/playground/src/components/ServerSideData.vue +62 -0
  26. package/playground/src/components/SortableColumnServerSide.vue +73 -0
  27. package/playground/src/components/TableStyle.vue +112 -0
  28. package/playground/src/components/fields/SampleCustomField.vue +24 -0
  29. package/playground/src/components/icons/IconCommunity.vue +7 -0
  30. package/playground/src/components/icons/IconDocumentation.vue +7 -0
  31. package/playground/src/components/icons/IconEcosystem.vue +7 -0
  32. package/playground/src/components/icons/IconSupport.vue +7 -0
  33. package/playground/src/components/icons/IconTooling.vue +19 -0
  34. package/playground/src/main.js +51 -0
  35. package/playground/vite.config.js +17 -0
  36. package/src/ViGridBuilder.scss +157 -58
  37. package/src/ViGridBuilder.vue +367 -207
  38. package/src/ViGridField.scss +1 -2
  39. package/src/ViGridField.vue +13 -6
  40. package/src/ViGridHeadCell.vue +32 -0
  41. package/src/ViGridHeadColumnCell.vue +42 -0
  42. package/src/ViGridHeader.vue +67 -0
  43. package/src/composables/useColumns.js +21 -0
  44. package/src/composables/useGridActions.js +17 -3
  45. package/src/composables/useGridSettings.js +18 -0
  46. package/src/composables/usePagination.js +39 -0
  47. package/src/composables/useRowHelper.js +38 -0
  48. package/src/composables/useRowSelect.js +53 -0
  49. package/src/composables/useSettings.js +29 -0
  50. package/src/composables/useSort.js +103 -0
  51. package/src/fields/ViGridActions.scss +0 -1
  52. package/src/fields/ViGridActions.vue +37 -13
  53. package/src/fields/ViGridCheckbox.vue +31 -0
  54. package/src/fields/ViGridNumber.vue +18 -0
  55. package/src/fields/partials/ViGridKebabMenu.scss +60 -25
  56. package/src/fields/partials/ViGridKebabMenu.vue +75 -54
  57. package/src/fields/partials/{ViGridBuilderActions.vue → ViGridSimpleActions.vue} +3 -3
  58. package/src/settings/GridSettings.js +24 -0
  59. package/vite.config.js +12 -2
  60. package/src/examples/App.vue +0 -123
  61. package/src/examples/components/TableTitle.vue +0 -20
  62. package/src/examples/main.js +0 -11
  63. /package/src/fields/partials/{ViGridBuilderActions.scss → ViGridSimpleActions.scss} +0 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "vi-grid-builder-playground",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "axios": "^1.7.7",
13
+ "vue": "^3.5.12"
14
+ },
15
+ "devDependencies": {
16
+ "@vitejs/plugin-vue": "^5.1.4",
17
+ "vite": "^5.4.10",
18
+ "vite-plugin-vue-devtools": "^7.5.4"
19
+ }
20
+ }
Binary file
@@ -0,0 +1,84 @@
1
+ <template>
2
+
3
+ <div>
4
+ <h1> Examples</h1>
5
+ </div>
6
+ <custom-header/>
7
+
8
+
9
+
10
+ <custom-field/>
11
+
12
+ <clickable-row/>
13
+
14
+
15
+ <column-visibility/>
16
+
17
+
18
+ <table-style/>
19
+
20
+
21
+ <row-select/>
22
+
23
+ <sortable-column-server-side/>
24
+
25
+ <client-side-data/>
26
+
27
+ <server-side-data/>
28
+
29
+ <actions-field/>
30
+
31
+
32
+
33
+ <pagination-options/>
34
+
35
+
36
+ </template>
37
+
38
+
39
+ <script>
40
+ import CustomHeader from "@/components/CustomHeader.vue";
41
+ import ClickableRow from "@/components/ClickableRow.vue";
42
+ import ColumnVisibility from "@/components/ColumnVisibility.vue";
43
+ import RowSelect from "@/components/RowSelect.vue";
44
+ import SortableColumnServerSide from "@/components/SortableColumnServerSide.vue";
45
+ import ClientSideData from "@/components/ClientSideData.vue";
46
+ import ServerSideData from "@/components/ServerSideData.vue";
47
+ import ActionsField from "@/components/ActionsField.vue";
48
+ import TableStyle from "@/components/TableStyle.vue";
49
+ import PaginationOptions from "@/components/PaginationOptions.vue";
50
+ import CustomField from "@/components/CustomField.vue";
51
+ import GlobalOptions from "@/components/GlobalOptions.vue";
52
+
53
+
54
+ export default {
55
+ components: {
56
+ GlobalOptions,
57
+ CustomField,
58
+ PaginationOptions,
59
+ TableStyle,
60
+ ActionsField,
61
+ ServerSideData,
62
+ ClientSideData, SortableColumnServerSide, RowSelect, ColumnVisibility, ClickableRow, CustomHeader
63
+ },
64
+ }
65
+ </script>
66
+ <style>
67
+ .example-container {
68
+ padding: 30px;
69
+ margin-top: 30px;
70
+ }
71
+
72
+ .example-container > h3 {
73
+ font-weight: bold;
74
+ margin: 20px 0 30px 0;
75
+ text-transform: uppercase;
76
+ background-color: white;
77
+ }
78
+
79
+ .example-container > .example-body {
80
+ background-color: #f8f8f8;
81
+ text-align: center;
82
+ padding: 20px;
83
+ }
84
+ </style>
@@ -0,0 +1,86 @@
1
+ /* color palette from <https://github.com/vuejs/theme> */
2
+ :root {
3
+ --vt-c-white: #ffffff;
4
+ --vt-c-white-soft: #f8f8f8;
5
+ --vt-c-white-mute: #f2f2f2;
6
+
7
+ --vt-c-black: #181818;
8
+ --vt-c-black-soft: #222222;
9
+ --vt-c-black-mute: #282828;
10
+
11
+ --vt-c-indigo: #2c3e50;
12
+
13
+ --vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
14
+ --vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
15
+ --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
16
+ --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
17
+
18
+ --vt-c-text-light-1: var(--vt-c-indigo);
19
+ --vt-c-text-light-2: rgba(60, 60, 60, 0.66);
20
+ --vt-c-text-dark-1: var(--vt-c-white);
21
+ --vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
22
+ }
23
+
24
+ /* semantic color variables for this project */
25
+ :root {
26
+ --color-background: var(--vt-c-white);
27
+ --color-background-soft: var(--vt-c-white-soft);
28
+ --color-background-mute: var(--vt-c-white-mute);
29
+
30
+ --color-border: var(--vt-c-divider-light-2);
31
+ --color-border-hover: var(--vt-c-divider-light-1);
32
+
33
+ --color-heading: var(--vt-c-text-light-1);
34
+ --color-text: var(--vt-c-text-light-1);
35
+
36
+ --section-gap: 160px;
37
+ }
38
+
39
+ @media (prefers-color-scheme: dark) {
40
+ :root {
41
+ --color-background: var(--vt-c-black);
42
+ --color-background-soft: var(--vt-c-black-soft);
43
+ --color-background-mute: var(--vt-c-black-mute);
44
+
45
+ --color-border: var(--vt-c-divider-dark-2);
46
+ --color-border-hover: var(--vt-c-divider-dark-1);
47
+
48
+ --color-heading: var(--vt-c-text-dark-1);
49
+ --color-text: var(--vt-c-text-dark-2);
50
+ }
51
+ }
52
+
53
+ *,
54
+ *::before,
55
+ *::after {
56
+ box-sizing: border-box;
57
+ margin: 0;
58
+ font-weight: normal;
59
+ }
60
+
61
+ body {
62
+ min-height: 100vh;
63
+ color: var(--color-text);
64
+ background: var(--color-background);
65
+ transition:
66
+ color 0.5s,
67
+ background-color 0.5s;
68
+ line-height: 1.6;
69
+ font-family:
70
+ Inter,
71
+ -apple-system,
72
+ BlinkMacSystemFont,
73
+ 'Segoe UI',
74
+ Roboto,
75
+ Oxygen,
76
+ Ubuntu,
77
+ Cantarell,
78
+ 'Fira Sans',
79
+ 'Droid Sans',
80
+ 'Helvetica Neue',
81
+ sans-serif;
82
+ font-size: 15px;
83
+ text-rendering: optimizeLegibility;
84
+ -webkit-font-smoothing: antialiased;
85
+ -moz-osx-font-smoothing: grayscale;
86
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
@@ -0,0 +1,35 @@
1
+ @import 'base.css';
2
+
3
+ #app {
4
+ max-width: 1280px;
5
+ margin: 0 auto;
6
+ padding: 2rem;
7
+ font-weight: normal;
8
+ }
9
+
10
+ a,
11
+ .green {
12
+ text-decoration: none;
13
+ color: hsla(160, 100%, 37%, 1);
14
+ transition: 0.4s;
15
+ padding: 3px;
16
+ }
17
+
18
+ @media (hover: hover) {
19
+ a:hover {
20
+ background-color: hsla(160, 100%, 37%, 0.2);
21
+ }
22
+ }
23
+
24
+ @media (min-width: 1024px) {
25
+ body {
26
+ /*display: flex;*/
27
+ /*place-items: center;*/
28
+ }
29
+
30
+ #app {
31
+ /*display: grid;*/
32
+ /*grid-template-columns: 1fr 1fr;*/
33
+ /*padding: 0 2rem;*/
34
+ }
35
+ }
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div class="example-container">
3
+
4
+ <h3 id="custom-header">Actions field</h3>
5
+ <div class="example-body">
6
+
7
+ <vi-grid-builder
8
+ v-bind="config"
9
+ :rows="rows"
10
+ :pagination="pagination"
11
+ :fetch-server-data="fetchData"
12
+ clickable-row
13
+ selectable
14
+ @view="viewRow"
15
+ @delete="removeRow"
16
+ @rowClicked="clickRow"
17
+ />
18
+
19
+ </div>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ import axios from "axios";
25
+
26
+ export default {
27
+
28
+ data: () => ({
29
+
30
+ loading: true,
31
+ rows: [],
32
+ config: {
33
+ rowKey: 'id',
34
+ columns: [{
35
+ label: 'ID',
36
+ name: 'id',
37
+ },
38
+ {
39
+ label: 'Title',
40
+ name: 'title',
41
+ },
42
+
43
+ {
44
+ label: '',
45
+ name: 'userId',
46
+ type:'actions',
47
+ kebab:true,
48
+ actions:[
49
+ {
50
+ name:'Edit row',
51
+ action:'edit',
52
+ },
53
+
54
+ {
55
+ name:'View row',
56
+ action:'view',
57
+ },
58
+ {
59
+ name:'Remove row',
60
+ action:'delete',
61
+ isVisible: (row) =>row.id === 1
62
+ },
63
+ ]
64
+ },
65
+ ],
66
+ },
67
+ selectedRows: [],
68
+ pagination: {
69
+ page: 1,
70
+ rowsPerPage: 10,
71
+ rowsNumber:100
72
+ }
73
+ }),
74
+ methods:{
75
+ clickRow(row){
76
+ alert('Row clicked'+row.id)
77
+ },
78
+ viewRow(row){
79
+ alert(`View row ${row.id}`);
80
+ },
81
+ removeRow(row){
82
+ alert(`Delete row with id ${row.id} ?`);
83
+ },
84
+ fetchData(args){
85
+ //todo sort example
86
+ return axios.get(`https://jsonplaceholder.typicode.com/posts?_page=${args.pagination.page}&_limit=${args.pagination.rowsPerPage}`)
87
+ .then(response => {
88
+
89
+ this.rows = response.data;
90
+ this.pagination = {
91
+ ...this.pagination,
92
+ ...args.pagination,
93
+ }
94
+ })
95
+ }
96
+ }
97
+ }
98
+
99
+ </script>
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <div class="example-container">
3
+
4
+ <h3 id="custom-header">Clickable row</h3>
5
+ <div class="example-body">
6
+
7
+ <vi-grid-builder
8
+ v-bind="config"
9
+ :rows="rows"
10
+ :server-mode="false"
11
+ :loading="loading"
12
+ clickable-row
13
+ @rowClicked="onRowClicked"
14
+ />
15
+ </div>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ import axios from "axios";
21
+ import {getCurrentInstance} from "vue";
22
+
23
+ export default {
24
+
25
+ data: () => ({
26
+
27
+ loading: true,
28
+ rows: [],
29
+ config: {
30
+ rowKey: 'id',
31
+ columns: [{
32
+ label: 'ID',
33
+ name: 'id',
34
+ },
35
+ {
36
+ label: 'Title',
37
+ name: 'title',
38
+ },
39
+ ],
40
+
41
+ pagination: {page: 1, rowsPerPage: 10}
42
+ }
43
+ }),
44
+ methods: {
45
+ onRowClicked(row) {
46
+ alert(`Clickable row ${row.id} with title ${row.title}`);
47
+ }
48
+ },
49
+ async mounted() {
50
+ return axios.get('https://jsonplaceholder.typicode.com/posts')
51
+ .then(response => {
52
+ this.rows = response.data.slice(0, 5);
53
+ this.loading = false;
54
+ })
55
+ .catch(error => {
56
+ // Handle any errors
57
+ console.error('Error fetching data:', error);
58
+ });
59
+ },
60
+ }
61
+
62
+
63
+ </script>
64
+
65
+
66
+ <style scoped lang="scss">
67
+
68
+ </style>
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <div class="example-container">
3
+
4
+ <h3 id="custom-header">Client side data</h3>
5
+ <div class="example-body">
6
+
7
+ <div></div>
8
+ <vi-grid-builder
9
+ v-bind="config"
10
+ :rows="rows"
11
+ :server-mode="false"
12
+ v-model:pagination="pagination"
13
+ :loading="loading"
14
+ selectable
15
+ @selectedRowsUpdate="selectedRows = $event"
16
+ />
17
+
18
+ </div>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ import axios from "axios";
24
+
25
+ function shuffleArray(array) {
26
+ const shuffled = [...array]; // Create a copy to avoid mutating the original array
27
+ for (let i = shuffled.length - 1; i > 0; i--) {
28
+ const randomIndex = Math.floor(Math.random() * (i + 1));
29
+ [shuffled[i], shuffled[randomIndex]] = [shuffled[randomIndex], shuffled[i]];
30
+ }
31
+ return shuffled;
32
+ }
33
+ export default {
34
+
35
+ data: () => ({
36
+
37
+ loading: true,
38
+ rows: [],
39
+ config: {
40
+ rowKey: 'id',
41
+ columns: [{
42
+ label: 'ID',
43
+ name: 'id',
44
+ sortable: true,
45
+
46
+ },
47
+ {
48
+ label: 'Title',
49
+ name: 'title',
50
+ sortable: true,
51
+ },
52
+ ],
53
+
54
+ pagination: {page: 1, rowsPerPage: 10}
55
+ },
56
+ selectedRows: [],
57
+ pagination: {
58
+ page: 1,
59
+ rowsPerPage: 5,
60
+ totalRows: 11,
61
+ }
62
+ }),
63
+ async mounted() {
64
+ return axios.get('https://jsonplaceholder.typicode.com/posts')
65
+ .then(response => {
66
+ let that = this;
67
+ setTimeout(() => {
68
+ that.rows = shuffleArray(response.data.slice(0, 11));
69
+ that.loading = false;
70
+ }, 4000)
71
+ })
72
+
73
+ .catch(error => {
74
+ // Handle any errors
75
+ console.error('Error fetching data:', error);
76
+ });
77
+ },
78
+ }
79
+
80
+
81
+ </script>
82
+
83
+
84
+ <style scoped lang="scss">
85
+
86
+ </style>
@@ -0,0 +1,85 @@
1
+ <template>
2
+ <div class="example-container">
3
+
4
+ <h3 id="custom-header">Column visibility</h3>
5
+ <div>
6
+ <input type="checkbox" v-model="showContentColumn"><label> Show 'content' column</label>
7
+ </div>
8
+ <div class="example-body">
9
+ <vi-grid-builder
10
+ v-bind="config"
11
+ :rows="rows"
12
+ :server-mode="false"
13
+ :loading="loading"
14
+ clickable-row
15
+ />
16
+ </div>
17
+
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ import axios from "axios";
23
+ import {getCurrentInstance} from "vue";
24
+
25
+ export default {
26
+
27
+ data: () => ({
28
+
29
+ loading: true,
30
+ rows: [],
31
+ showContentColumn: false,
32
+
33
+ }),
34
+ computed: {
35
+ config() {
36
+ return {
37
+ rowKey: 'id',
38
+
39
+ columns: [{
40
+ label: 'ID',
41
+ name: 'id',
42
+ },
43
+ {
44
+ label: 'User ID',
45
+ name: 'userId',
46
+ isVisible: false
47
+ },
48
+ {
49
+ label: 'Title',
50
+ name: 'title',
51
+ },
52
+ {
53
+ label: 'Content',
54
+ name: 'body',
55
+ isVisible: this.showContentColumn
56
+ },
57
+
58
+ ],
59
+ pagination: {page: 1, rowsPerPage: 10}
60
+ }
61
+
62
+
63
+ }
64
+ },
65
+
66
+ async mounted() {
67
+ return axios.get('https://jsonplaceholder.typicode.com/posts')
68
+ .then(response => {
69
+ this.rows = response.data.slice(0, 5);
70
+ this.loading = false;
71
+ })
72
+ .catch(error => {
73
+ // Handle any errors
74
+ console.error('Error fetching data:', error);
75
+ });
76
+ },
77
+ }
78
+
79
+
80
+ </script>
81
+
82
+
83
+ <style scoped lang="scss">
84
+
85
+ </style>
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <div class="example-container">
3
+
4
+ <h3 id="custom-header">Custom field </h3>
5
+ <div class="example-body">
6
+
7
+ <vi-grid-builder
8
+ v-bind="config"
9
+ :rows="rows"
10
+ :pagination="pagination"
11
+ :fetch-server-data="fetchData"
12
+ />
13
+
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import axios from "axios";
20
+
21
+ export default {
22
+
23
+ data: () => ({
24
+
25
+ loading: true,
26
+ rows: [],
27
+ config: {
28
+ rowKey: 'id',
29
+ columns: [{
30
+ label: 'ID',
31
+ name: 'id',
32
+ type:'sample-custom-field'
33
+ },
34
+ {
35
+ label: 'Title',
36
+ name: 'title',
37
+
38
+ },
39
+ ],
40
+ },
41
+ selectedRows: [],
42
+ pagination: {
43
+ page: 1,
44
+ rowsPerPage: 5,
45
+ rowsNumber:100
46
+ }
47
+ }),
48
+ methods:{
49
+ fetchData(args){
50
+ //todo sort example
51
+ return axios.get(`https://jsonplaceholder.typicode.com/posts?_page=${args.pagination.page}&_limit=${args.pagination.rowsPerPage}`)
52
+ .then(response => {
53
+
54
+ this.rows = response.data;
55
+ this.pagination = {
56
+ ...this.pagination,
57
+ ...args.pagination,
58
+ }
59
+ })
60
+ }
61
+ }
62
+ }
63
+
64
+ </script>