vuetable-next 1.0.3 → 1.0.5
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/dist/vuetable-next.d.ts +678 -0
- package/dist/vuetable-next.js +432 -429
- package/dist/vuetable-next.js.map +1 -1
- package/dist/vuetable-next.umd.cjs +16 -16
- package/dist/vuetable-next.umd.cjs.map +1 -1
- package/package.json +8 -5
- package/src/components/Vuetable.vue +17 -8
- package/src/components/VuetableFieldCheckbox.vue +4 -4
- package/src/components/VuetablePagination.vue +1 -1
- package/src/components/VuetablePaginationDropdown.vue +1 -1
- package/src/components/VuetablePaginationMixin.vue +2 -2
- package/src/components/VuetableRowHeader.vue +22 -16
- package/src/index.ts +0 -2
- package/tsconfig.json +7 -1
- package/vite.config.ts +4 -1
- package/dist/vite.svg +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuetable-next",
|
|
3
3
|
"description": "Simple table for displaying data.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"author": "Artem Alesenko",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
26
|
"types": "./dist/vuetable-next.d.ts",
|
|
27
|
-
"import": "./dist/vuetable-next.
|
|
28
|
-
"require": "./dist/vuetable-next.umd.
|
|
27
|
+
"import": "./dist/vuetable-next.js",
|
|
28
|
+
"require": "./dist/vuetable-next.umd.cjs"
|
|
29
29
|
},
|
|
30
30
|
"./*": "./*"
|
|
31
31
|
},
|
|
@@ -61,7 +61,10 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@eslint/js": "^8.57.0",
|
|
64
|
+
"@microsoft/api-extractor": "7.47.7",
|
|
64
65
|
"@types/jquery": "^3.5.30",
|
|
66
|
+
"@types/node": "^22.5.5",
|
|
67
|
+
"@types/promise-polyfill": "^6.0.6",
|
|
65
68
|
"@types/semver": "^7.5.8",
|
|
66
69
|
"@vitejs/plugin-vue": "^5.1.3",
|
|
67
70
|
"@vue/test-utils": "^2.4.6",
|
|
@@ -72,11 +75,11 @@
|
|
|
72
75
|
"jsdom": "^25.0.0",
|
|
73
76
|
"promise-polyfill": "^8.3.0",
|
|
74
77
|
"semver": "^7.6.3",
|
|
75
|
-
"typescript": "^5.
|
|
78
|
+
"typescript": "^5.4.2",
|
|
76
79
|
"typescript-eslint": "^7.17.0",
|
|
77
80
|
"unplugin-auto-import": "^0.18.2",
|
|
78
81
|
"vite": "^5.3.4",
|
|
79
|
-
"vite-plugin-dts": "^4.
|
|
82
|
+
"vite-plugin-dts": "^4.0.3",
|
|
80
83
|
"vitest": "^2.0.5",
|
|
81
84
|
"vue": "^3.5.3",
|
|
82
85
|
"vue-tsc": "^2.0.24"
|
|
@@ -82,8 +82,10 @@
|
|
|
82
82
|
:class="bodyClass('vuetable-slot', field)"
|
|
83
83
|
:style="{ width: field.width! }">
|
|
84
84
|
<slot
|
|
85
|
-
:name="field.name"
|
|
86
|
-
:row-data="item"
|
|
85
|
+
:name="field.name as string"
|
|
86
|
+
:row-data="item"
|
|
87
|
+
:row-index="itemIndex"
|
|
88
|
+
:row-field="field">
|
|
87
89
|
</slot>
|
|
88
90
|
</td>
|
|
89
91
|
</template>
|
|
@@ -186,14 +188,14 @@ interface Props {
|
|
|
186
188
|
dataManager?: ((sortOrder: SortOrder[], pagination: { [key: string]: any }) => any[]) | null
|
|
187
189
|
dataPath?: string
|
|
188
190
|
paginationPath?: string
|
|
189
|
-
queryParams?: { [key: string]: string | number } | ((sortOrder: string, currentPage: number, perPage: number) => { [key: string]: string | number } | string | number)
|
|
191
|
+
queryParams?: { [key: string]: string | number } | ((sortOrder: SortOrder[] | string, currentPage: number, perPage: number) => { [key: string]: string | number } | string | number)
|
|
190
192
|
appendParams?: { [key: string]: string | number }
|
|
191
193
|
httpOptions?: Record<string, unknown>
|
|
192
194
|
httpFetch?: ((apiUrl: string, httpOptions: Record<string, unknown>) => AxiosResponse) | null
|
|
193
195
|
perPage?: number
|
|
194
196
|
initialPage?: number /** Page that should be displayed when the table is first displayed */
|
|
195
197
|
firstPage?: number /** First page number. Set this prop to 0 for zero based pagination */
|
|
196
|
-
sortOrder?: SortOrder[]
|
|
198
|
+
sortOrder?: SortOrder[]
|
|
197
199
|
multiSort?: boolean
|
|
198
200
|
tableHeight?: string | null
|
|
199
201
|
/*
|
|
@@ -215,7 +217,7 @@ interface Props {
|
|
|
215
217
|
showSortIcons?: boolean
|
|
216
218
|
headerRows?: string[]
|
|
217
219
|
transform?: ((response: AxiosResponse) => any) | null
|
|
218
|
-
sortParams?: ((sortOrder:
|
|
220
|
+
sortParams?: ((sortOrder: SortOrder[]) => string) | null
|
|
219
221
|
fieldPrefix?: string
|
|
220
222
|
}
|
|
221
223
|
|
|
@@ -233,9 +235,13 @@ interface Field {
|
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
interface Pagination {
|
|
236
|
-
|
|
238
|
+
total: number
|
|
239
|
+
per_page: number
|
|
240
|
+
from: number
|
|
241
|
+
to: number
|
|
237
242
|
last_page: number
|
|
238
243
|
current_page: number
|
|
244
|
+
first_page: number
|
|
239
245
|
}
|
|
240
246
|
|
|
241
247
|
const {
|
|
@@ -395,6 +401,8 @@ defineExpose({
|
|
|
395
401
|
trackBy,
|
|
396
402
|
showSortIcons,
|
|
397
403
|
instanceFetch,
|
|
404
|
+
isFieldSlot,
|
|
405
|
+
onHeaderEvent,
|
|
398
406
|
setData,
|
|
399
407
|
getFieldTitle,
|
|
400
408
|
orderBy,
|
|
@@ -443,6 +451,7 @@ provide("vuetable", {
|
|
|
443
451
|
showSortIcons,
|
|
444
452
|
css: toRefs($_css),
|
|
445
453
|
isFieldSlot,
|
|
454
|
+
onHeaderEvent,
|
|
446
455
|
setData,
|
|
447
456
|
getFieldTitle,
|
|
448
457
|
orderBy,
|
|
@@ -628,8 +637,8 @@ function isFieldComponent (fieldName: any) {
|
|
|
628
637
|
return fieldName.slice(0, fieldPrefix.length) === fieldPrefix || fieldName.slice(0, 2) === "__";
|
|
629
638
|
}
|
|
630
639
|
|
|
631
|
-
function isFieldSlot (fieldName: string) {
|
|
632
|
-
return typeof slots[fieldName] !== "undefined";
|
|
640
|
+
function isFieldSlot (fieldName: string | DefineComponent) {
|
|
641
|
+
return typeof slots[fieldName as string] !== "undefined";
|
|
633
642
|
}
|
|
634
643
|
|
|
635
644
|
function titleCase (str: string) {
|
|
@@ -25,7 +25,7 @@ import type Vuetable from "./Vuetable.vue";
|
|
|
25
25
|
interface Props {
|
|
26
26
|
rowData?: { [key: string]: any }
|
|
27
27
|
rowIndex?: number
|
|
28
|
-
rowField?: { [key: string]:
|
|
28
|
+
rowField?: { [key: string]: any } | null
|
|
29
29
|
isHeader?: boolean
|
|
30
30
|
title?: string
|
|
31
31
|
}
|
|
@@ -53,7 +53,7 @@ function toggleAllCheckbox (event: Event) {
|
|
|
53
53
|
vuetable.onCheckboxToggledAll((event as CustomEvent).target.checked);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function isSelected (rowData: { [key: string]:
|
|
56
|
+
function isSelected (rowData: { [key: string]: any }): boolean {
|
|
57
57
|
return vuetable.isSelectedRow(rowData[vuetable.trackBy]);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ function isAllItemsInCurrentPageSelected () {
|
|
|
62
62
|
|
|
63
63
|
const idColumn = vuetable.trackBy;
|
|
64
64
|
const checkboxEl = checkbox.value?.$el.querySelector("input[type=checkbox]");
|
|
65
|
-
const selected = vuetable.tableData.filter((item: { [key: string]:
|
|
65
|
+
const selected = vuetable.tableData.filter((item: { [key: string]: string }) => vuetable.isSelectedRow(item[idColumn]) );
|
|
66
66
|
|
|
67
67
|
// count == 0, clear the checkbox
|
|
68
68
|
if (selected.length <= 0) {
|
|
@@ -70,7 +70,7 @@ function isAllItemsInCurrentPageSelected () {
|
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
72
|
// count > 0 and count < perPage, set checkbox state to 'indeterminate'
|
|
73
|
-
else if (selected.length < vuetable.perPage) {
|
|
73
|
+
else if (selected.length < vuetable.perPage!) {
|
|
74
74
|
checkboxEl.indeterminate = true;
|
|
75
75
|
return true;
|
|
76
76
|
}
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
<script setup lang="ts">
|
|
55
55
|
import { defineEmits, defineProps, reactive, toRef } from "vue-demi";
|
|
56
56
|
import CssSemanticUI from "./VuetableCssSemanticUI.ts";
|
|
57
|
-
import { useVuetablePagination } from "./useVuetablePagination
|
|
57
|
+
import { useVuetablePagination } from "./useVuetablePagination";
|
|
58
58
|
|
|
59
59
|
interface Props {
|
|
60
60
|
css?: { [key: string]: string }
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<script setup lang="ts">
|
|
22
22
|
import { defineEmits, defineProps, reactive } from "vue-demi";
|
|
23
23
|
import mitt from "mitt";
|
|
24
|
-
import CssSemanticUI from "./VuetableCssSemanticUI
|
|
24
|
+
import CssSemanticUI from "./VuetableCssSemanticUI";
|
|
25
25
|
import { useVuetablePagination } from "./useVuetablePagination.ts";
|
|
26
26
|
|
|
27
27
|
interface Props {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import CssSemanticUI from "./VuetableCssSemanticUI";
|
|
3
|
-
import {defineComponent} from "vue-demi";
|
|
3
|
+
import { defineComponent } from "vue-demi";
|
|
4
4
|
|
|
5
5
|
interface TablePagination {
|
|
6
6
|
current_page: number;
|
|
@@ -88,7 +88,7 @@ export default defineComponent({
|
|
|
88
88
|
|
|
89
89
|
methods: {
|
|
90
90
|
mergeCss () {
|
|
91
|
-
this.customCss = {...CssSemanticUI.pagination, ...this.css};
|
|
91
|
+
this.customCss = { ...CssSemanticUI.pagination, ...this.css };
|
|
92
92
|
},
|
|
93
93
|
loadPage (page: number) {
|
|
94
94
|
this.$emit("vuetable-pagination:change-page", page);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<template v-else-if="vuetable.isFieldSlot(field.name)">
|
|
18
18
|
<th :key="fieldIndex"
|
|
19
19
|
:class="headerClass('vuetable-th-slot', field)"
|
|
20
|
-
:style="{width: field.width}"
|
|
20
|
+
:style="{ width: field.width! }"
|
|
21
21
|
v-html="renderTitle(field)"
|
|
22
22
|
@click="onColumnHeaderClicked(field, $event)">
|
|
23
23
|
</th>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<th :key="fieldIndex"
|
|
27
27
|
:id="'_' + field.name"
|
|
28
28
|
:class="headerClass('vuetable-th', field)"
|
|
29
|
-
:style="{width: field.width}"
|
|
29
|
+
:style="{ width: field.width! }"
|
|
30
30
|
v-html="renderTitle(field)"
|
|
31
31
|
@click="onColumnHeaderClicked(field, $event)">
|
|
32
32
|
</th>
|
|
@@ -43,16 +43,22 @@ import VuetableFieldCheckbox from "./VuetableFieldCheckbox.vue";
|
|
|
43
43
|
import VuetableFieldHandle from "./VuetableFieldHandle.vue";
|
|
44
44
|
import VuetableFieldSequence from "./VuetableFieldSequence.vue";
|
|
45
45
|
import VuetableColGutter from "./VuetableColGutter.vue";
|
|
46
|
-
import type {
|
|
46
|
+
import type { DefineComponent } from "vue-demi";
|
|
47
47
|
import { inject } from "vue-demi";
|
|
48
48
|
import { defineOptions } from "vue-demi";
|
|
49
49
|
import type Vuetable from "./Vuetable.vue";
|
|
50
50
|
|
|
51
51
|
interface Field {
|
|
52
|
-
name:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
name: string | DefineComponent
|
|
53
|
+
sortField: string | null
|
|
54
|
+
title: string | ((str?: any) => string)
|
|
55
|
+
titleClass: string
|
|
56
|
+
dataClass: string
|
|
57
|
+
formatter: (<T>(...args: any[]) => T) | null
|
|
58
|
+
visible: boolean
|
|
59
|
+
width: string | null
|
|
60
|
+
$_index: number
|
|
61
|
+
[key: string]: unknown
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
defineOptions({
|
|
@@ -95,13 +101,13 @@ function toSnakeCase (str: Field["name"]) {
|
|
|
95
101
|
|
|
96
102
|
function sortClass (field: Field) {
|
|
97
103
|
const index = currentSortOrderPosition(field);
|
|
98
|
-
return index ? (vuetable.sortOrder[index].direction == "asc") ? vuetable.css
|
|
104
|
+
return index ? (vuetable.sortOrder![index].direction == "asc") ? vuetable.css!.ascendingClass : vuetable.css!.descendingClass : "";
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
function sortIcon (field: Field) {
|
|
102
108
|
const index = currentSortOrderPosition(field);
|
|
103
109
|
|
|
104
|
-
return index ? vuetable.css
|
|
110
|
+
return index ? vuetable.css!.sortableIcon : (vuetable.sortOrder![index].direction == "asc") ? vuetable.css!.ascendingIcon : vuetable.css!.descendingIcon;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
function isInCurrentSortGroup (field: Field) {
|
|
@@ -109,7 +115,7 @@ function isInCurrentSortGroup (field: Field) {
|
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
function hasSortableIcon (field: Field) {
|
|
112
|
-
return vuetable.isSortable(field) && vuetable.css
|
|
118
|
+
return vuetable.isSortable(field) && vuetable.css!.sortableIcon != "";
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
function currentSortOrderPosition (field: Field): number {
|
|
@@ -117,7 +123,7 @@ function currentSortOrderPosition (field: Field): number {
|
|
|
117
123
|
return 0;
|
|
118
124
|
}
|
|
119
125
|
|
|
120
|
-
for (let i = 0; i < vuetable.sortOrder
|
|
126
|
+
for (let i = 0; i < vuetable.sortOrder!.length; i++) {
|
|
121
127
|
if (fieldIsInSortOrderPosition(field, i)) {
|
|
122
128
|
return i;
|
|
123
129
|
}
|
|
@@ -127,7 +133,7 @@ function currentSortOrderPosition (field: Field): number {
|
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
function fieldIsInSortOrderPosition (field: Field, index: number) {
|
|
130
|
-
return vuetable.sortOrder[index].field === field.name && vuetable.sortOrder[index].sortField === field.sortField;
|
|
136
|
+
return vuetable.sortOrder![index].field === field.name && vuetable.sortOrder![index].sortField === field.sortField;
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
function renderTitle (field: Field) {
|
|
@@ -164,7 +170,7 @@ function sortIconOpacity (field: Field) {
|
|
|
164
170
|
const min = 0.3;
|
|
165
171
|
let step = 0.3;
|
|
166
172
|
|
|
167
|
-
const count = vuetable.sortOrder
|
|
173
|
+
const count = vuetable.sortOrder!.length;
|
|
168
174
|
const current = currentSortOrderPosition(field);
|
|
169
175
|
|
|
170
176
|
if (max - count * step < min) {
|
|
@@ -175,13 +181,13 @@ function sortIconOpacity (field: Field) {
|
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
function renderIconTag (classes: string[], options = "") {
|
|
178
|
-
return typeof vuetable.css
|
|
184
|
+
return typeof vuetable.css!.renderIcon === "undefined"
|
|
179
185
|
? `<i class="${classes.join(" ")}" ${options}></i>`
|
|
180
|
-
: vuetable.css
|
|
186
|
+
: vuetable.css!.renderIcon(classes, options);
|
|
181
187
|
}
|
|
182
188
|
|
|
183
189
|
function onColumnHeaderClicked (field: Field, event: Event): void {
|
|
184
|
-
vuetable.orderBy(field, event);
|
|
190
|
+
vuetable.orderBy(field, event as Event & { [key: string]: string });
|
|
185
191
|
}
|
|
186
192
|
</script>
|
|
187
193
|
|
package/src/index.ts
CHANGED
|
@@ -12,8 +12,6 @@ import VuetableFieldMixin from "./components/VuetableFieldMixin.vue";
|
|
|
12
12
|
import VuetableFieldCheckboxMixin from "./components/VuetableFieldCheckboxMixin.vue";
|
|
13
13
|
import VuetablePaginationInfoMixin from "./components/VuetablePaginationInfoMixin.vue";
|
|
14
14
|
import VuetablePaginationMixin from "./components/VuetablePaginationMixin.vue";
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
-
// @ts-expect-error
|
|
17
15
|
import Promise from "promise-polyfill";
|
|
18
16
|
|
|
19
17
|
// @ts-ignore
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { version } from "vue";
|
|
|
6
6
|
import type { SemVer } from "semver";
|
|
7
7
|
import { parse } from "semver";
|
|
8
8
|
import dts from "vite-plugin-dts";
|
|
9
|
+
import { resolve } from "path";
|
|
9
10
|
|
|
10
11
|
const { major, minor } = parse(version) as SemVer;
|
|
11
12
|
|
|
@@ -33,14 +34,16 @@ export default defineConfig({
|
|
|
33
34
|
build: {
|
|
34
35
|
lib: {
|
|
35
36
|
name,
|
|
36
|
-
entry: "src/index.ts"
|
|
37
|
+
entry: resolve(__dirname, "src/index.ts")
|
|
37
38
|
},
|
|
39
|
+
copyPublicDir: false,
|
|
38
40
|
sourcemap: true,
|
|
39
41
|
rollupOptions: {
|
|
40
42
|
external: ["vue-demi"],
|
|
41
43
|
output: {
|
|
42
44
|
globals: {
|
|
43
45
|
[name]: PascalCasedName,
|
|
46
|
+
"vue-demi": "VueDemi"
|
|
44
47
|
},
|
|
45
48
|
exports: "named"
|
|
46
49
|
}
|
package/dist/vite.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|