vuetable-next 1.0.9 → 1.0.10
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 +2 -52
- package/auto-imports.d.ts +9 -0
- package/package.json +87 -87
- package/src/assets/vue.svg +1 -0
- package/src/components/Demo.vue +17 -0
- package/src/components/Vuetable.vue +1216 -0
- package/src/components/VuetableColGroup.vue +66 -0
- package/src/components/VuetableColGutter.vue +25 -0
- package/src/components/VuetableCssSemanticUI.ts +36 -0
- package/src/components/VuetableFieldCheckbox.vue +87 -0
- package/src/components/VuetableFieldCheckboxMixin.vue +46 -0
- package/src/components/VuetableFieldHandle.vue +41 -0
- package/src/components/VuetableFieldMixin.vue +30 -0
- package/src/components/VuetableFieldSequence.vue +43 -0
- package/src/components/VuetablePagination.vue +119 -0
- package/src/components/VuetablePaginationDropdown.vue +88 -0
- package/src/components/VuetablePaginationInfo.vue +51 -0
- package/src/components/VuetablePaginationInfoMixin.vue +64 -0
- package/src/components/VuetablePaginationMixin.vue +107 -0
- package/src/components/VuetableRowHeader.vue +195 -0
- package/src/components/useVuetablePagination.ts +57 -0
- package/src/components/useVuetablePaginationInfo.ts +41 -0
- package/src/data/fields.ts +102 -0
- package/src/data/lang.ts +4 -0
- package/src/helpers/toValue.ts +9 -0
- package/src/index.ts +57 -0
- package/src/main.ts +398 -0
- package/src/style.css +79 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CssSemanticUI from "./VuetableCssSemanticUI";
|
|
3
|
+
import { defineComponent } from "vue-demi";
|
|
4
|
+
|
|
5
|
+
interface TablePagination {
|
|
6
|
+
current_page: number;
|
|
7
|
+
last_page: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface Data {
|
|
11
|
+
eventPrefix: string
|
|
12
|
+
tablePagination: TablePagination | null
|
|
13
|
+
customCss: Record<string, any>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
emits: [
|
|
18
|
+
"vuetable-pagination:change-page",
|
|
19
|
+
],
|
|
20
|
+
props: {
|
|
21
|
+
css: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default () {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
onEachSide: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default () {
|
|
30
|
+
return 2;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
firstPage: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 1
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
data () {
|
|
40
|
+
return <Data>{
|
|
41
|
+
eventPrefix: "vuetable-pagination:",
|
|
42
|
+
tablePagination: null,
|
|
43
|
+
customCss: {}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
created () {
|
|
48
|
+
this.mergeCss();
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
computed: {
|
|
52
|
+
totalPage () {
|
|
53
|
+
return this.tablePagination === null
|
|
54
|
+
? 0
|
|
55
|
+
: this.tablePagination.last_page - this.firstPage + 1;
|
|
56
|
+
},
|
|
57
|
+
lastPage () {
|
|
58
|
+
return this.tablePagination === null
|
|
59
|
+
? 0
|
|
60
|
+
: this.tablePagination.last_page;
|
|
61
|
+
},
|
|
62
|
+
isOnFirstPage () {
|
|
63
|
+
return this.tablePagination === null
|
|
64
|
+
? false
|
|
65
|
+
: this.tablePagination.current_page === this.firstPage;
|
|
66
|
+
},
|
|
67
|
+
isOnLastPage () {
|
|
68
|
+
return this.tablePagination === null
|
|
69
|
+
? false
|
|
70
|
+
: this.tablePagination.current_page === this.lastPage;
|
|
71
|
+
},
|
|
72
|
+
notEnoughPages () {
|
|
73
|
+
return this.totalPage < (this.onEachSide * 2) + 4;
|
|
74
|
+
},
|
|
75
|
+
windowSize () {
|
|
76
|
+
return this.onEachSide * 2 +1;
|
|
77
|
+
},
|
|
78
|
+
windowStart () {
|
|
79
|
+
if (!this.tablePagination || this.tablePagination.current_page <= this.onEachSide) {
|
|
80
|
+
return 1;
|
|
81
|
+
} else if (this.tablePagination.current_page >= (this.totalPage - this.onEachSide)) {
|
|
82
|
+
return this.totalPage - this.onEachSide * 2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this.tablePagination.current_page - this.onEachSide;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
methods: {
|
|
90
|
+
mergeCss () {
|
|
91
|
+
this.customCss = { ...CssSemanticUI.pagination, ...this.css };
|
|
92
|
+
},
|
|
93
|
+
loadPage (page: number) {
|
|
94
|
+
this.$emit("vuetable-pagination:change-page", page);
|
|
95
|
+
},
|
|
96
|
+
isCurrentPage (page: number) {
|
|
97
|
+
return page === this.tablePagination!.current_page;
|
|
98
|
+
},
|
|
99
|
+
setPaginationData (tablePagination: TablePagination) {
|
|
100
|
+
this.tablePagination = tablePagination;
|
|
101
|
+
},
|
|
102
|
+
resetData () {
|
|
103
|
+
this.tablePagination = null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
</script>
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tr>
|
|
3
|
+
<template v-for="(field, fieldIndex) in vuetable.tableFields">
|
|
4
|
+
<template v-if="field.visible">
|
|
5
|
+
<template v-if="vuetable.isFieldComponent(field.name)">
|
|
6
|
+
<component :is="field.name"
|
|
7
|
+
:key="fieldIndex"
|
|
8
|
+
is-header
|
|
9
|
+
:row-field="field"
|
|
10
|
+
:title="renderTitle(field)"
|
|
11
|
+
:class="headerClass('vuetable-th-component', field)"
|
|
12
|
+
:style="{width: field.width}"
|
|
13
|
+
@vuetable:header-event="vuetable.onHeaderEvent"
|
|
14
|
+
@click="onColumnHeaderClicked(field, $event)">
|
|
15
|
+
</component>
|
|
16
|
+
</template>
|
|
17
|
+
<template v-else-if="vuetable.isFieldSlot(field.name)">
|
|
18
|
+
<th :key="fieldIndex"
|
|
19
|
+
:class="headerClass('vuetable-th-slot', field)"
|
|
20
|
+
:style="{ width: field.width! }"
|
|
21
|
+
v-html="renderTitle(field)"
|
|
22
|
+
@click="onColumnHeaderClicked(field, $event)">
|
|
23
|
+
</th>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-else>
|
|
26
|
+
<th :key="fieldIndex"
|
|
27
|
+
:id="'_' + field.name"
|
|
28
|
+
:class="headerClass('vuetable-th', field)"
|
|
29
|
+
:style="{ width: field.width! }"
|
|
30
|
+
v-html="renderTitle(field)"
|
|
31
|
+
@click="onColumnHeaderClicked(field, $event)">
|
|
32
|
+
</th>
|
|
33
|
+
</template>
|
|
34
|
+
</template>
|
|
35
|
+
</template>
|
|
36
|
+
<VuetableColGutter v-if="vuetable.scrollVisible">
|
|
37
|
+
</VuetableColGutter>
|
|
38
|
+
</tr>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup lang="ts">
|
|
42
|
+
import VuetableFieldCheckbox from "./VuetableFieldCheckbox.vue";
|
|
43
|
+
import VuetableFieldHandle from "./VuetableFieldHandle.vue";
|
|
44
|
+
import VuetableFieldSequence from "./VuetableFieldSequence.vue";
|
|
45
|
+
import VuetableColGutter from "./VuetableColGutter.vue";
|
|
46
|
+
import type { DefineComponent } from "vue-demi";
|
|
47
|
+
import { inject, defineOptions } from "vue-demi";
|
|
48
|
+
import type Vuetable from "./Vuetable.vue";
|
|
49
|
+
|
|
50
|
+
interface Field {
|
|
51
|
+
name: string | DefineComponent
|
|
52
|
+
sortField: string | null
|
|
53
|
+
title: string | ((str?: any) => string)
|
|
54
|
+
titleClass: string
|
|
55
|
+
dataClass: string
|
|
56
|
+
formatter: (<T>(...args: any[]) => T) | null
|
|
57
|
+
visible: boolean
|
|
58
|
+
width: string | null
|
|
59
|
+
$_index: number
|
|
60
|
+
[key: string]: unknown
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
defineOptions({
|
|
64
|
+
name: "vuetable-row-header",
|
|
65
|
+
components: {
|
|
66
|
+
"vuetable-field-checkbox": VuetableFieldCheckbox,
|
|
67
|
+
"vuetable-field-handle": VuetableFieldHandle,
|
|
68
|
+
"vuetable-field-sequence": VuetableFieldSequence
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const vuetable = inject("vuetable") as InstanceType<typeof Vuetable>;
|
|
73
|
+
|
|
74
|
+
defineExpose({
|
|
75
|
+
stripPrefix,
|
|
76
|
+
isInCurrentSortGroup,
|
|
77
|
+
hasSortableIcon,
|
|
78
|
+
currentSortOrderPosition,
|
|
79
|
+
fieldIsInSortOrderPosition
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
function stripPrefix (name: string) {
|
|
83
|
+
return name.replace(vuetable.fieldPrefix, "");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function headerClass (base: string, field: Field) {
|
|
87
|
+
return [
|
|
88
|
+
`${ base }-${ toSnakeCase(field.name) }`,
|
|
89
|
+
field.titleClass || "",
|
|
90
|
+
sortClass(field),
|
|
91
|
+
{ "sortable": vuetable.isSortable(field) }
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function toSnakeCase (str: Field["name"]) {
|
|
96
|
+
return typeof(str) === "string" && str.replace(/([A-Z])/g, (chr) => "_"+chr.toLowerCase())
|
|
97
|
+
.replace(" ", "_")
|
|
98
|
+
.replace(".", "_");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function sortClass (field: Field) {
|
|
102
|
+
const index = currentSortOrderPosition(field);
|
|
103
|
+
return index ? (vuetable.sortOrder![index].direction == "asc") ? vuetable.css!.ascendingClass : vuetable.css!.descendingClass : "";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function sortIcon (field: Field) {
|
|
107
|
+
const index = currentSortOrderPosition(field);
|
|
108
|
+
|
|
109
|
+
return index ? vuetable.css!.sortableIcon : (vuetable.sortOrder![index].direction == "asc") ? vuetable.css!.ascendingIcon : vuetable.css!.descendingIcon;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isInCurrentSortGroup (field: Field) {
|
|
113
|
+
return !!currentSortOrderPosition(field);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function hasSortableIcon (field: Field) {
|
|
117
|
+
return vuetable.isSortable(field) && vuetable.css!.sortableIcon != "";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function currentSortOrderPosition (field: Field): number {
|
|
121
|
+
if ( !vuetable.isSortable(field)) {
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < vuetable.sortOrder!.length; i++) {
|
|
126
|
+
if (fieldIsInSortOrderPosition(field, i)) {
|
|
127
|
+
return i;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function fieldIsInSortOrderPosition (field: Field, index: number) {
|
|
135
|
+
return vuetable.sortOrder![index].field === field.name && vuetable.sortOrder![index].sortField === field.sortField;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function renderTitle (field: Field) {
|
|
139
|
+
const title = getTitle(field);
|
|
140
|
+
|
|
141
|
+
if (title.length > 0 && isInCurrentSortGroup(field) || hasSortableIcon(field)) {
|
|
142
|
+
const style = `opacity:${sortIconOpacity(field)};position:relative;float:right`;
|
|
143
|
+
const iconTag = vuetable.showSortIcons ? renderIconTag(["sort-icon", sortIcon(field)], `style="${style}"`) : "";
|
|
144
|
+
return title + " " + iconTag;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return title;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getTitle (field: Field) {
|
|
151
|
+
if (typeof field.title === "function") return field.title();
|
|
152
|
+
|
|
153
|
+
return typeof field.title === "undefined"
|
|
154
|
+
? field.name.toString().replace(".", " ")
|
|
155
|
+
: field.title;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function sortIconOpacity (field: Field) {
|
|
159
|
+
/*
|
|
160
|
+
* fields with stronger precedence have darker color
|
|
161
|
+
*
|
|
162
|
+
* if there are few fields, we go down by 0.3
|
|
163
|
+
* ex. 2 fields are selected: 1.0, 0.7
|
|
164
|
+
*
|
|
165
|
+
* if there are more we go down evenly on the given spectrum
|
|
166
|
+
* ex. 6 fields are selected: 1.0, 0.86, 0.72, 0.58, 0.44, 0.3
|
|
167
|
+
*/
|
|
168
|
+
const max = 1.0;
|
|
169
|
+
const min = 0.3;
|
|
170
|
+
let step = 0.3;
|
|
171
|
+
|
|
172
|
+
const count = vuetable.sortOrder!.length;
|
|
173
|
+
const current = currentSortOrderPosition(field);
|
|
174
|
+
|
|
175
|
+
if (max - count * step < min) {
|
|
176
|
+
step = (max - min) / (count-1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return max - current * step;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function renderIconTag (classes: string[], options = "") {
|
|
183
|
+
return typeof vuetable.css!.renderIcon === "undefined"
|
|
184
|
+
? `<i class="${classes.join(" ")}" ${options}></i>`
|
|
185
|
+
: vuetable.css!.renderIcon(classes, options);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function onColumnHeaderClicked (field: Field, event: Event): void {
|
|
189
|
+
vuetable.orderBy(field, event as Event & { [key: string]: string });
|
|
190
|
+
}
|
|
191
|
+
</script>
|
|
192
|
+
|
|
193
|
+
<style scoped>
|
|
194
|
+
|
|
195
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { computed, type ComputedGetter, type Ref, ref } from "vue-demi";
|
|
2
|
+
import { toValue } from "../helpers/toValue.ts";
|
|
3
|
+
|
|
4
|
+
interface TablePagination {
|
|
5
|
+
last_page: number
|
|
6
|
+
current_page: number
|
|
7
|
+
from: number
|
|
8
|
+
to: number
|
|
9
|
+
total: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useVuetablePagination (onEachSide: Ref<number> | ComputedGetter<number>, firstPage: Ref<number> | ComputedGetter<number>) {
|
|
13
|
+
const tablePagination = ref<TablePagination | null>(null);
|
|
14
|
+
|
|
15
|
+
const lastPage = computed(() => tablePagination.value?.last_page ?? 0);
|
|
16
|
+
const isOnFirstPage = computed(() => tablePagination.value?.current_page === toValue(firstPage));
|
|
17
|
+
const isOnLastPage = computed(() => tablePagination.value?.current_page === lastPage.value);
|
|
18
|
+
const windowSize = computed(() => (toValue(onEachSide) * 2) + 1);
|
|
19
|
+
const totalPage = computed(() =>
|
|
20
|
+
tablePagination.value ? (tablePagination.value.last_page - toValue(firstPage) + 1) : 0);
|
|
21
|
+
const notEnoughPages = computed(() => totalPage.value < (toValue(onEachSide) * 2) + 4);
|
|
22
|
+
|
|
23
|
+
const windowStart = computed(() => {
|
|
24
|
+
if (!tablePagination.value || tablePagination.value.current_page <= toValue(onEachSide)) {
|
|
25
|
+
return 1;
|
|
26
|
+
} else if (tablePagination.value.current_page >= (totalPage.value - toValue(onEachSide))) {
|
|
27
|
+
return totalPage.value - toValue(onEachSide) * 2;
|
|
28
|
+
}
|
|
29
|
+
return tablePagination.value.current_page - toValue(onEachSide);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function setPaginationData (value: TablePagination) {
|
|
33
|
+
tablePagination.value = value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resetData () {
|
|
37
|
+
tablePagination.value = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isCurrentPage (page: number) {
|
|
41
|
+
return page === tablePagination.value?.current_page;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
tablePagination,
|
|
46
|
+
lastPage,
|
|
47
|
+
isOnFirstPage,
|
|
48
|
+
isOnLastPage,
|
|
49
|
+
notEnoughPages,
|
|
50
|
+
windowSize,
|
|
51
|
+
windowStart,
|
|
52
|
+
totalPage,
|
|
53
|
+
setPaginationData,
|
|
54
|
+
resetData,
|
|
55
|
+
isCurrentPage
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ComputedGetter, Ref } from "vue-demi";
|
|
2
|
+
import { computed, ref } from "vue-demi";
|
|
3
|
+
import { toValue } from "../helpers/toValue.ts";
|
|
4
|
+
|
|
5
|
+
interface TablePagination {
|
|
6
|
+
last_page: number
|
|
7
|
+
current_page: number
|
|
8
|
+
from: number
|
|
9
|
+
to: number
|
|
10
|
+
total: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useVuetablePaginationInfo (noDataTemplate: Ref<string> | ComputedGetter<string>, infoTemplate: Ref<string> | ComputedGetter<string>) {
|
|
14
|
+
const tablePagination = ref<TablePagination | null>(null);
|
|
15
|
+
|
|
16
|
+
const isNoData = computed(() => tablePagination.value == null || tablePagination.value.total == 0);
|
|
17
|
+
const paginationInfo = computed(() => isNoData.value ? toValue(noDataTemplate) : toValue(infoTemplate)
|
|
18
|
+
.replace("{from}", `${ tablePagination.value!.from || 0 }`)
|
|
19
|
+
.replace("{to}", `${ tablePagination.value!.to || 0 }`)
|
|
20
|
+
.replace("{total}", `${ tablePagination.value!.total || 0 }`));
|
|
21
|
+
|
|
22
|
+
function setPaginationData (value: TablePagination) {
|
|
23
|
+
tablePagination.value = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function resetData () {
|
|
27
|
+
tablePagination.value = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isCurrentPage (page: number) {
|
|
31
|
+
return page === tablePagination.value?.current_page;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
tablePagination,
|
|
36
|
+
paginationInfo,
|
|
37
|
+
setPaginationData,
|
|
38
|
+
resetData,
|
|
39
|
+
isCurrentPage
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {lang} from "./lang.ts";
|
|
2
|
+
|
|
3
|
+
export const fields = [
|
|
4
|
+
{
|
|
5
|
+
name: "__handle",
|
|
6
|
+
width: "40px"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "__sequence",
|
|
10
|
+
title: "No.",
|
|
11
|
+
width: "50px",
|
|
12
|
+
titleClass: "right aligned",
|
|
13
|
+
dataClass: "right aligned"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "__checkbox",
|
|
17
|
+
title: "checkbox",
|
|
18
|
+
width: "30px",
|
|
19
|
+
titleClass: "center aligned",
|
|
20
|
+
dataClass: "center aligned"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "id",
|
|
24
|
+
title: "<i class=\"unordered list icon\"></i> Detail",
|
|
25
|
+
width: "80px",
|
|
26
|
+
dataClass: "center aligned",
|
|
27
|
+
formatter: (value, vuetable) => {
|
|
28
|
+
const icon = vuetable.isVisibleDetailRow(value) ? "down" : "right";
|
|
29
|
+
return [
|
|
30
|
+
"<a class=\"show-detail-row\">",
|
|
31
|
+
"<i class=\"chevron circle " + icon + " icon\"></i>",
|
|
32
|
+
"</a>"
|
|
33
|
+
].join("");
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "name",
|
|
39
|
+
title: "<i class=\"book icon\"></i> Full Name",
|
|
40
|
+
sortField: "name",
|
|
41
|
+
width: "150px",
|
|
42
|
+
filterable: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "email",
|
|
46
|
+
title: "<i class=\"mail outline icon\"></i> Email",
|
|
47
|
+
sortField: "email",
|
|
48
|
+
width: "200px",
|
|
49
|
+
visible: true,
|
|
50
|
+
filterable: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "nickname",
|
|
54
|
+
title: (nameOnly = false) => {
|
|
55
|
+
return nameOnly
|
|
56
|
+
? lang["nickname"]
|
|
57
|
+
: `<i class="paw icon"></i> ${lang["nickname"]}`;
|
|
58
|
+
},
|
|
59
|
+
sortField: "nickname",
|
|
60
|
+
width: "120px",
|
|
61
|
+
formatter: (value) => {
|
|
62
|
+
return value.toUpperCase();
|
|
63
|
+
},
|
|
64
|
+
filterable: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "birthdate",
|
|
68
|
+
title: (nameOnly = false) => {
|
|
69
|
+
return nameOnly
|
|
70
|
+
? lang["birthdate"]
|
|
71
|
+
: `<i class="orange birthday icon"></i> ${lang["birthdate"]}`;
|
|
72
|
+
},
|
|
73
|
+
width: "100px",
|
|
74
|
+
sortField: "birthdate",
|
|
75
|
+
formatter: (value) => {
|
|
76
|
+
if (value === null) return "";
|
|
77
|
+
return moment(value, "YYYY-MM-DD").format("D MMM YYYY");
|
|
78
|
+
},
|
|
79
|
+
filterable: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "gender",
|
|
83
|
+
title: "Gender",
|
|
84
|
+
sortField: "gender",
|
|
85
|
+
width: "100px",
|
|
86
|
+
titleClass: "center aligned",
|
|
87
|
+
dataClass: "center aligned",
|
|
88
|
+
formatter: (value) => {
|
|
89
|
+
return value === "M"
|
|
90
|
+
? "<span class=\"ui teal label\"><i class=\"male icon\"></i>Male</span>"
|
|
91
|
+
: "<span class=\"ui pink label\"><i class=\"female icon\"></i>Female</span>";
|
|
92
|
+
},
|
|
93
|
+
filterable: true,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "slot-actions",
|
|
97
|
+
title: "Actions",
|
|
98
|
+
width: "140px",
|
|
99
|
+
titleClass: "center aligned",
|
|
100
|
+
dataClass: "center aligned"
|
|
101
|
+
}
|
|
102
|
+
];
|
package/src/data/lang.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Ref, type ComputedRef, unref } from "vue-demi";
|
|
2
|
+
|
|
3
|
+
export type MaybeRef<T = any> = T | Ref<T>;
|
|
4
|
+
export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
|
|
5
|
+
|
|
6
|
+
export function toValue<T> (source: MaybeRefOrGetter<T> | ComputedRef<T>): T {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
return typeof source === "function" ? source() : unref(source);
|
|
9
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { App } from "vue-demi";
|
|
2
|
+
import Vuetable from "./components/Vuetable.vue";
|
|
3
|
+
import VuetableColGutter from "./components/VuetableColGutter.vue";
|
|
4
|
+
import VuetableFieldCheckbox from "./components/VuetableFieldCheckbox.vue";
|
|
5
|
+
import VuetableFieldHandle from "./components/VuetableFieldHandle.vue";
|
|
6
|
+
import VuetableFieldSequence from "./components/VuetableFieldSequence.vue";
|
|
7
|
+
import VuetablePagination from "./components/VuetablePagination.vue";
|
|
8
|
+
import VuetablePaginationDropdown from "./components/VuetablePaginationDropdown.vue";
|
|
9
|
+
import VuetablePaginationInfo from "./components/VuetablePaginationInfo.vue";
|
|
10
|
+
import VuetableRowHeader from "./components/VuetableRowHeader.vue";
|
|
11
|
+
import VuetableFieldMixin from "./components/VuetableFieldMixin.vue";
|
|
12
|
+
import VuetableFieldCheckboxMixin from "./components/VuetableFieldCheckboxMixin.vue";
|
|
13
|
+
import VuetablePaginationInfoMixin from "./components/VuetablePaginationInfoMixin.vue";
|
|
14
|
+
import VuetablePaginationMixin from "./components/VuetablePaginationMixin.vue";
|
|
15
|
+
import Promise from "promise-polyfill";
|
|
16
|
+
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const rootVariable = (typeof self === "object" && self.self === self && self) || (typeof global === "object" && global) || this;
|
|
19
|
+
if (!rootVariable!.Promise) {
|
|
20
|
+
rootVariable!.Promise = Promise;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function install (Vue: App) {
|
|
24
|
+
Vue.component("vuetable", Vuetable);
|
|
25
|
+
Vue.component("vuetable-col-gutter", VuetableColGutter);
|
|
26
|
+
Vue.component("vuetable-field-checkbox", VuetableFieldCheckbox);
|
|
27
|
+
Vue.component("vuetable-field-handle", VuetableFieldHandle);
|
|
28
|
+
Vue.component("vuetable-field-sequence", VuetableFieldSequence);
|
|
29
|
+
Vue.component("vuetable-pagination", VuetablePagination);
|
|
30
|
+
Vue.component("vuetable-pagination-dropdown", VuetablePaginationDropdown);
|
|
31
|
+
Vue.component("vuetable-pagination-info", VuetablePaginationInfo);
|
|
32
|
+
Vue.component("vuetable-row-header", VuetableRowHeader);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Vuetable.install = install;
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
Vuetable,
|
|
39
|
+
// Mixins
|
|
40
|
+
VuetableFieldMixin,
|
|
41
|
+
VuetableFieldCheckboxMixin,
|
|
42
|
+
VuetablePaginationInfoMixin,
|
|
43
|
+
VuetablePaginationMixin,
|
|
44
|
+
// Components
|
|
45
|
+
VuetableColGutter,
|
|
46
|
+
VuetableFieldCheckbox,
|
|
47
|
+
VuetableFieldHandle,
|
|
48
|
+
VuetableFieldSequence,
|
|
49
|
+
VuetablePagination,
|
|
50
|
+
VuetablePaginationDropdown,
|
|
51
|
+
VuetablePaginationInfo,
|
|
52
|
+
VuetableRowHeader,
|
|
53
|
+
// Utils
|
|
54
|
+
install
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default Vuetable;
|