@starter-solutions/inertia-data-table-vue 0.1.4 → 0.2.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.
- package/README.md +39 -3
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/useInertiaDataTableConfig.d.ts +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +57 -34
- package/dist/types/config.d.ts +41 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +28 -2
package/README.md
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
-
# inertia-data-table-vue
|
|
1
|
+
# @starter-solutions/inertia-data-table-vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> ⚠️ This is the **Vue 3 frontend companion package** for
|
|
4
|
+
> **starter-solutions/inertia-data-table (Laravel)**.
|
|
5
|
+
>
|
|
6
|
+
> If you are looking for the backend package, visit:
|
|
7
|
+
> 👉 https://github.com/starter-solutions/inertia-data-table-laravel
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📦 Overview
|
|
12
|
+
|
|
13
|
+
`@starter-solutions/inertia-data-table-vue` provides Vue 3 composables and components for handling:
|
|
14
|
+
|
|
15
|
+
- Server-driven pagination
|
|
16
|
+
- Sorting
|
|
17
|
+
- Query state management
|
|
18
|
+
- Inertia-powered table updates
|
|
19
|
+
|
|
20
|
+
It is designed to work seamlessly with the Laravel package:
|
|
21
|
+
|
|
22
|
+
**Backend (Laravel):**
|
|
23
|
+
https://github.com/starter-solutions/inertia-data-table-laravel
|
|
24
|
+
|
|
25
|
+
Together they provide a clean, consistent way to manage paginated and sortable data tables across your Laravel + Inertia + Vue application.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🚀 Installation
|
|
4
30
|
|
|
5
31
|
```bash
|
|
6
|
-
npm
|
|
32
|
+
npm install @starter-solutions/inertia-data-table-vue
|
|
7
33
|
```
|
|
34
|
+
|
|
35
|
+
## 🐛 Issues & Support
|
|
36
|
+
|
|
37
|
+
Bug reports and feature requests should be submitted to the main repository:
|
|
38
|
+
|
|
39
|
+
🔗 https://github.com/starter-solutions/inertia-data-table/issues
|
|
40
|
+
|
|
41
|
+
## 📄 License
|
|
42
|
+
|
|
43
|
+
MIT © Starter Solutions
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InertiaDataTableDefaults, InertiaDataTableOptions, InertiaDataTableQueryParams, InertiaDataTableSettings, InertiaDataTableStateRoutes } from '../types/config';
|
|
2
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
|
|
4
|
+
export declare const useInertiaDataTableConfig: (tableKey: MaybeRefOrGetter<string>, options?: MaybeRefOrGetter<InertiaDataTableOptions>) => {
|
|
5
|
+
settings: import('vue').ComputedRef<InertiaDataTableSettings>;
|
|
6
|
+
stateRoutes: import('vue').ComputedRef<InertiaDataTableStateRoutes>;
|
|
7
|
+
queryParams: import('vue').ComputedRef<InertiaDataTableQueryParams>;
|
|
8
|
+
defaults: import('vue').ComputedRef<InertiaDataTableDefaults>;
|
|
9
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@inertiajs/vue3"),t=require("vue"),v=(e,n)=>{const l=d.usePage(),r=t.computed(()=>{const s=t.toValue(n);return{tableKey:t.toValue(e),pagePropsKey:t.toValue(s==null?void 0:s.pagePropsKey)??t.toValue(e),useUrlQuery:t.toValue(s==null?void 0:s.useUrlQuery)??!1}}),u=t.computed(()=>l.props.inertiaDataTable.stateRoutes),o=t.computed(()=>l.props.inertiaDataTable.queryParams),a=t.computed(()=>l.props.inertiaDataTable.defaults);return{settings:r,stateRoutes:u,queryParams:o,defaults:a}},k=e=>{const n=t.computed(()=>c(t.toValue(e))),l=t.computed(()=>n.value.data),r=t.computed(()=>n.value.pagination);return{data:l,pagination:r,getPaginatedRequest:(a={})=>({page:a.page??r.value.current_page,per_page:a.per_page??r.value.per_page,sort_by:a.sort_by??r.value.sort_by,descending:a.descending??r.value.descending}),validPage:a=>a>0&&a<=r.value.last_page}},c=e=>({data:(e==null?void 0:e.data)??[],pagination:_(e)}),i=e=>"meta"in e&&typeof e.meta=="object"&&e.meta!==null,_=e=>{if(!e)return{current_page:1,last_page:1,per_page:10,total:0,from:null,to:null,path:"",links:[],first_page_url:null,last_page_url:null,next_page_url:null,prev_page_url:null,sort_by:"id",descending:!1};if(i(e))return{current_page:e.meta.current_page,last_page:e.meta.last_page,per_page:e.meta.per_page,total:e.meta.total,from:e.meta.from,to:e.meta.to,path:e.meta.path,links:e.meta.links,first_page_url:e.links.first,last_page_url:e.links.last,next_page_url:e.links.next,prev_page_url:e.links.prev,sort_by:e.meta.sort_by??"id",descending:e.meta.descending??!1};const{current_page:n,last_page:l,per_page:r,total:u,from:o,to:a,path:s,links:p,first_page_url:g,last_page_url:m,next_page_url:f,prev_page_url:b,sort_by:y,descending:P}=e;return{current_page:n,last_page:l,per_page:r,total:u,from:o,to:a,path:s,links:p,first_page_url:g,last_page_url:m,next_page_url:f,prev_page_url:b,sort_by:y??"id",descending:P??!1}};function T(){return{install(e){}}}exports.createInertiaDataTable=T;exports.getPaginationMeta=_;exports.isResource=i;exports.normalizePagination=c;exports.useInertiaDataTableConfig=v;exports.useLaravelPagination=k;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './composables
|
|
1
|
+
export * from './composables';
|
|
2
2
|
export * from './plugin';
|
|
3
|
-
export type * from './types
|
|
3
|
+
export type * from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { usePage as b } from "@inertiajs/vue3";
|
|
2
|
+
import { computed as l, toValue as u } from "vue";
|
|
3
|
+
const D = (e, n) => {
|
|
4
|
+
const s = b(), a = l(() => {
|
|
5
|
+
const r = u(n);
|
|
6
|
+
return {
|
|
7
|
+
tableKey: u(e),
|
|
8
|
+
pagePropsKey: u(r == null ? void 0 : r.pagePropsKey) ?? u(e),
|
|
9
|
+
useUrlQuery: u(r == null ? void 0 : r.useUrlQuery) ?? !1
|
|
10
|
+
};
|
|
11
|
+
}), o = l(
|
|
12
|
+
() => s.props.inertiaDataTable.stateRoutes
|
|
13
|
+
), _ = l(
|
|
14
|
+
() => s.props.inertiaDataTable.queryParams
|
|
15
|
+
), t = l(
|
|
16
|
+
() => s.props.inertiaDataTable.defaults
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
settings: a,
|
|
20
|
+
stateRoutes: o,
|
|
21
|
+
queryParams: _,
|
|
22
|
+
defaults: t
|
|
23
|
+
};
|
|
24
|
+
}, R = (e) => {
|
|
25
|
+
const n = l(() => P(u(e))), s = l(() => n.value.data), a = l(() => n.value.pagination);
|
|
4
26
|
return {
|
|
5
|
-
data:
|
|
27
|
+
data: s,
|
|
6
28
|
pagination: a,
|
|
7
29
|
getPaginatedRequest: (t = {}) => ({
|
|
8
30
|
page: t.page ?? a.value.current_page,
|
|
@@ -12,10 +34,10 @@ const d = (e) => {
|
|
|
12
34
|
}),
|
|
13
35
|
validPage: (t) => t > 0 && t <= a.value.last_page
|
|
14
36
|
};
|
|
15
|
-
},
|
|
37
|
+
}, P = (e) => ({
|
|
16
38
|
data: (e == null ? void 0 : e.data) ?? [],
|
|
17
39
|
pagination: k(e)
|
|
18
|
-
}),
|
|
40
|
+
}), v = (e) => "meta" in e && typeof e.meta == "object" && e.meta !== null, k = (e) => {
|
|
19
41
|
if (!e)
|
|
20
42
|
return {
|
|
21
43
|
current_page: 1,
|
|
@@ -35,7 +57,7 @@ const d = (e) => {
|
|
|
35
57
|
sort_by: "id",
|
|
36
58
|
descending: !1
|
|
37
59
|
};
|
|
38
|
-
if (
|
|
60
|
+
if (v(e))
|
|
39
61
|
return {
|
|
40
62
|
current_page: e.meta.current_page,
|
|
41
63
|
last_page: e.meta.last_page,
|
|
@@ -55,52 +77,53 @@ const d = (e) => {
|
|
|
55
77
|
descending: e.meta.descending ?? !1
|
|
56
78
|
};
|
|
57
79
|
const {
|
|
58
|
-
current_page:
|
|
59
|
-
last_page:
|
|
80
|
+
current_page: n,
|
|
81
|
+
last_page: s,
|
|
60
82
|
per_page: a,
|
|
61
|
-
total:
|
|
83
|
+
total: o,
|
|
62
84
|
from: _,
|
|
63
85
|
to: t,
|
|
64
|
-
path:
|
|
65
|
-
links:
|
|
86
|
+
path: r,
|
|
87
|
+
links: p,
|
|
66
88
|
//links
|
|
67
|
-
first_page_url:
|
|
68
|
-
last_page_url:
|
|
69
|
-
next_page_url:
|
|
70
|
-
prev_page_url:
|
|
89
|
+
first_page_url: g,
|
|
90
|
+
last_page_url: c,
|
|
91
|
+
next_page_url: i,
|
|
92
|
+
prev_page_url: m,
|
|
71
93
|
//custom
|
|
72
|
-
sort_by:
|
|
73
|
-
descending:
|
|
94
|
+
sort_by: f,
|
|
95
|
+
descending: y
|
|
74
96
|
} = e;
|
|
75
97
|
return {
|
|
76
|
-
current_page:
|
|
77
|
-
last_page:
|
|
98
|
+
current_page: n,
|
|
99
|
+
last_page: s,
|
|
78
100
|
per_page: a,
|
|
79
|
-
total:
|
|
101
|
+
total: o,
|
|
80
102
|
from: _,
|
|
81
103
|
to: t,
|
|
82
|
-
path:
|
|
83
|
-
links:
|
|
104
|
+
path: r,
|
|
105
|
+
links: p,
|
|
84
106
|
//links
|
|
85
|
-
first_page_url:
|
|
86
|
-
last_page_url:
|
|
87
|
-
next_page_url:
|
|
88
|
-
prev_page_url:
|
|
107
|
+
first_page_url: g,
|
|
108
|
+
last_page_url: c,
|
|
109
|
+
next_page_url: i,
|
|
110
|
+
prev_page_url: m,
|
|
89
111
|
//custom
|
|
90
|
-
sort_by:
|
|
91
|
-
descending:
|
|
112
|
+
sort_by: f ?? "id",
|
|
113
|
+
descending: y ?? !1
|
|
92
114
|
};
|
|
93
115
|
};
|
|
94
|
-
function
|
|
116
|
+
function T() {
|
|
95
117
|
return {
|
|
96
118
|
install(e) {
|
|
97
119
|
}
|
|
98
120
|
};
|
|
99
121
|
}
|
|
100
122
|
export {
|
|
101
|
-
|
|
123
|
+
T as createInertiaDataTable,
|
|
102
124
|
k as getPaginationMeta,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
v as isResource,
|
|
126
|
+
P as normalizePagination,
|
|
127
|
+
D as useInertiaDataTableConfig,
|
|
128
|
+
R as useLaravelPagination
|
|
106
129
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type InertiaDataTableStateRoutes = {
|
|
4
|
+
set: string;
|
|
5
|
+
drop: string;
|
|
6
|
+
dropAll: string;
|
|
7
|
+
};
|
|
8
|
+
export type InertiaDataTableQueryParams = {
|
|
9
|
+
tableKey: string;
|
|
10
|
+
perPage: string;
|
|
11
|
+
sortBy: string;
|
|
12
|
+
descending: string;
|
|
13
|
+
pageName: string;
|
|
14
|
+
};
|
|
15
|
+
export type InertiaDataTableDefaults = {
|
|
16
|
+
perPage: number;
|
|
17
|
+
sortBy: string;
|
|
18
|
+
};
|
|
19
|
+
export type InertiaDataTableSharedProps = {
|
|
20
|
+
inertiaDataTable: {
|
|
21
|
+
stateRoutes: InertiaDataTableStateRoutes;
|
|
22
|
+
queryParams: InertiaDataTableQueryParams;
|
|
23
|
+
defaults: InertiaDataTableDefaults;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type InertiaDataTableOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Whether to use the URL query for pagination and sorting state. If false, the state is stored in the session.
|
|
29
|
+
* Using the URL query allows for better shareability of links, but requires more complex handling of the query parameters in the backend.
|
|
30
|
+
*/
|
|
31
|
+
useUrlQuery?: MaybeRefOrGetter<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* The key in which the paginated data is stored in the page props. Defaults to the tableKey if not provided.
|
|
34
|
+
*/
|
|
35
|
+
pagePropsKey?: MaybeRefOrGetter<string>;
|
|
36
|
+
};
|
|
37
|
+
export type InertiaDataTableSettings = {
|
|
38
|
+
tableKey: string;
|
|
39
|
+
pagePropsKey: string;
|
|
40
|
+
useUrlQuery: boolean;
|
|
41
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starter-solutions/inertia-data-table-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"description": "Vue 3 + Inertia.js data table utilities with Laravel backend integration.",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.cjs",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -16,10 +17,35 @@
|
|
|
16
17
|
"types": "./dist/index.d.ts"
|
|
17
18
|
}
|
|
18
19
|
},
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Luca Hoffmann",
|
|
22
|
+
"url": "https://github.com/HoffmannLuca"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/starter-solutions/inertia-data-table-vue.git"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/starter-solutions/inertia-data-table#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/starter-solutions/inertia-data-table/issues"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"laravel",
|
|
34
|
+
"inertia",
|
|
35
|
+
"vue",
|
|
36
|
+
"vue3",
|
|
37
|
+
"typescript",
|
|
38
|
+
"data-table",
|
|
39
|
+
"pagination",
|
|
40
|
+
"sorting"
|
|
41
|
+
],
|
|
19
42
|
"scripts": {
|
|
20
43
|
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
21
44
|
"build": "vite build",
|
|
22
|
-
"dev": "vite"
|
|
45
|
+
"dev": "vite",
|
|
46
|
+
"git-patch": "npm version patch && git push --follow-tags",
|
|
47
|
+
"git-minor": "npm version minor && git push --follow-tags",
|
|
48
|
+
"git-major": "npm version major && git push --follow-tags"
|
|
23
49
|
},
|
|
24
50
|
"peerDependencies": {
|
|
25
51
|
"@inertiajs/vue3": "^2.0.0",
|