vi-grid-builder 0.0.1 → 0.0.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/ViGridBuilderPlugin.js +13 -1
- package/package.json +1 -1
- package/src/ViGridBuilder.vue +13 -2
- package/src/ViGridField.vue +1 -0
- package/src/composables/useGridActions.js +18 -0
- package/src/fields/ViGridActions.vue +23 -26
- package/src/mixins/field-mixin.js +13 -0
- package/index.html +0 -13
- package/src/style.css +0 -89
package/ViGridBuilderPlugin.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import ViGridBuilder from "./src/ViGridBuilder.vue"
|
|
2
2
|
import ViPaginationPlugin from 'vi-pagination'
|
|
3
|
+
import fieldMixin from "./src/mixins/field-mixin.js"
|
|
4
|
+
import {useGridActions} from "./src/composables/useGridActions.js"
|
|
3
5
|
export default {
|
|
4
6
|
install(app, options ={pagination:{}, fieldComponents:{}, defaultSlots:{}}) {
|
|
5
7
|
|
|
@@ -19,8 +21,18 @@ export default {
|
|
|
19
21
|
|
|
20
22
|
return options?.defaultSlots ?? {}
|
|
21
23
|
}
|
|
24
|
+
},
|
|
25
|
+
noDataLabel:{
|
|
26
|
+
type: String,
|
|
27
|
+
default: options.noDataLabel ?? 'No data found'
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
});
|
|
25
31
|
}
|
|
26
|
-
};
|
|
32
|
+
};
|
|
33
|
+
const mixins = {fieldMixin};
|
|
34
|
+
const composables = {useGridActions};
|
|
35
|
+
export {
|
|
36
|
+
mixins,
|
|
37
|
+
composables
|
|
38
|
+
}
|
package/package.json
CHANGED
package/src/ViGridBuilder.vue
CHANGED
|
@@ -25,9 +25,17 @@
|
|
|
25
25
|
</td>
|
|
26
26
|
</tr>
|
|
27
27
|
</tbody>
|
|
28
|
-
<tbody v-else class="table-body">
|
|
29
28
|
|
|
30
|
-
<
|
|
29
|
+
<tbody v-else-if="!currentVisibleRows.length" class="table-body">
|
|
30
|
+
<tr>
|
|
31
|
+
<slot name="empty-data">
|
|
32
|
+
<component v-if="defaultSlots.noRows" :is="defaultSlots.noRows"/>
|
|
33
|
+
<td v-else :colspan="columns.length" align="center">{{noDataLabel}}</td>
|
|
34
|
+
</slot>
|
|
35
|
+
</tr>
|
|
36
|
+
</tbody>
|
|
37
|
+
<tbody v-else class="table-body">
|
|
38
|
+
<tr v-for="row in currentVisibleRows" :key="row[rowKey]">
|
|
31
39
|
|
|
32
40
|
<td v-for="column in columns" :key="column.name">
|
|
33
41
|
<vi-grid-field
|
|
@@ -116,6 +124,9 @@
|
|
|
116
124
|
},
|
|
117
125
|
defaultSlots: {
|
|
118
126
|
type: Object
|
|
127
|
+
},
|
|
128
|
+
noDataLabel: {
|
|
129
|
+
type: String,
|
|
119
130
|
}
|
|
120
131
|
},
|
|
121
132
|
data: () => ({search: null, isFetchingData: false}),
|
package/src/ViGridField.vue
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
export function useGridActions(props) {
|
|
4
|
+
|
|
5
|
+
const visibleActions = computed(() => props.field.actions.filter((action ) => {
|
|
6
|
+
if (action.isVisible === undefined) {
|
|
7
|
+
return true
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
return action.isVisible(props.row)
|
|
11
|
+
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
// Return the computed variable
|
|
15
|
+
return {
|
|
16
|
+
visibleActions,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,54 +1,51 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<div class="vi-grid-actions">
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
<vi-grid-kebab-menu
|
|
5
|
+
v-if="field.kebab"
|
|
6
|
+
:actions="visibleActions"
|
|
7
|
+
@actionClicked="$action => $emit(`action-clicked`, {action:$action, row})"
|
|
8
|
+
/>
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<vi-grid-builder-actions
|
|
11
|
+
v-else
|
|
12
|
+
:actions="visibleActions"
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/>
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script>
|
|
20
20
|
import ViGridKebabMenu from "./partials/ViGridKebabMenu.vue";
|
|
21
21
|
import ViGridBuilderActions from "./partials/ViGridBuilderActions.vue";
|
|
22
22
|
|
|
23
|
+
import {useGridActions} from "../composables/useGridActions.js"
|
|
24
|
+
import fieldMixin from "../mixins/field-mixin.js"
|
|
25
|
+
|
|
23
26
|
export default {
|
|
24
27
|
name: "ViGridActions",
|
|
28
|
+
mixins: [fieldMixin],
|
|
25
29
|
components: {ViGridBuilderActions, ViGridKebabMenu},
|
|
26
30
|
props: {
|
|
27
31
|
field: {
|
|
28
32
|
type: Object,
|
|
29
33
|
required: true
|
|
30
34
|
},
|
|
31
|
-
row:{
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
+
row: {}
|
|
35
36
|
},
|
|
36
|
-
computed:{
|
|
37
|
-
visibleActions() {
|
|
38
|
-
return this.field.actions.filter((action ) => {
|
|
39
|
-
if (action.isVisible === undefined) {
|
|
40
|
-
return true
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
setup() {
|
|
39
|
+
const {visibleActions} = useGridActions();
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
return {
|
|
42
|
+
visibleActions,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
48
45
|
|
|
49
46
|
}
|
|
50
47
|
</script>
|
|
51
48
|
|
|
52
49
|
<style lang="scss">
|
|
53
|
-
|
|
50
|
+
@import "ViGridActions";
|
|
54
51
|
</style>
|
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite + Vue</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="app"></div>
|
|
11
|
-
<script type="module" src="/src/examples/main.js"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/src/style.css
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
-
line-height: 1.5;
|
|
4
|
-
font-weight: 400;
|
|
5
|
-
|
|
6
|
-
color-scheme: light dark;
|
|
7
|
-
color: rgba(255, 255, 255, 0.87);
|
|
8
|
-
background-color: #242424;
|
|
9
|
-
|
|
10
|
-
font-synthesis: none;
|
|
11
|
-
text-rendering: optimizeLegibility;
|
|
12
|
-
-webkit-font-smoothing: antialiased;
|
|
13
|
-
-moz-osx-font-smoothing: grayscale;
|
|
14
|
-
-webkit-text-size-adjust: 100%;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
a {
|
|
18
|
-
font-weight: 500;
|
|
19
|
-
color: #646cff;
|
|
20
|
-
text-decoration: inherit;
|
|
21
|
-
}
|
|
22
|
-
a:hover {
|
|
23
|
-
color: #535bf2;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
a {
|
|
27
|
-
font-weight: 500;
|
|
28
|
-
color: #646cff;
|
|
29
|
-
text-decoration: inherit;
|
|
30
|
-
}
|
|
31
|
-
a:hover {
|
|
32
|
-
color: #535bf2;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
body {
|
|
36
|
-
margin: 0;
|
|
37
|
-
display: flex;
|
|
38
|
-
place-items: center;
|
|
39
|
-
min-width: 320px;
|
|
40
|
-
min-height: 100vh;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
h1 {
|
|
44
|
-
font-size: 3.2em;
|
|
45
|
-
line-height: 1.1;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
button {
|
|
49
|
-
border-radius: 8px;
|
|
50
|
-
border: 1px solid transparent;
|
|
51
|
-
padding: 0.6em 1.2em;
|
|
52
|
-
font-size: 1em;
|
|
53
|
-
font-weight: 500;
|
|
54
|
-
font-family: inherit;
|
|
55
|
-
background-color: #1a1a1a;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
transition: border-color 0.25s;
|
|
58
|
-
}
|
|
59
|
-
button:hover {
|
|
60
|
-
border-color: #646cff;
|
|
61
|
-
}
|
|
62
|
-
button:focus,
|
|
63
|
-
button:focus-visible {
|
|
64
|
-
outline: 4px auto -webkit-focus-ring-color;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.card {
|
|
68
|
-
padding: 2em;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
#app {
|
|
72
|
-
max-width: 1280px;
|
|
73
|
-
margin: 0 auto;
|
|
74
|
-
padding: 2rem;
|
|
75
|
-
text-align: center;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@media (prefers-color-scheme: light) {
|
|
79
|
-
:root {
|
|
80
|
-
color: #213547;
|
|
81
|
-
background-color: #ffffff;
|
|
82
|
-
}
|
|
83
|
-
a:hover {
|
|
84
|
-
color: #747bff;
|
|
85
|
-
}
|
|
86
|
-
button {
|
|
87
|
-
background-color: #f9f9f9;
|
|
88
|
-
}
|
|
89
|
-
}
|