v-datatable-plus 1.0.7 → 1.1.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/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) [2024] [Adnan Ahmed Ansari (ansaripro)]
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) [2024] [Adnan Ahmed Ansari (ansaripro)]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -15,11 +15,186 @@
15
15
  </a>
16
16
  </p>
17
17
 
18
- VDatatablePlus is a an wrapper component for Vuetify VDataTable and VDataTableServer component, it gives you Header row filter functionlity like other advance data tables. It also utlilize VueDraggable Vue 3 library for columns drag n drop and show/hide functiionality.
19
- <br/>
20
- It also have other feature due to modification of based VDataTable/VDataTableServer components so you you can utilized them as per your need.
21
- <br/><br/>
22
- This repository also expose a ResizeableSplitter component which is useful for split horizontal contents with or without user interaction.
18
+ `v-datatable-plus` provides enhanced wrappers around Vuetify `VDataTable` and `VDataTableServer`.
19
+
20
+ ### Highlights
21
+
22
+ - Header row filtering with typed filter modes (`FilterType`, `FilterMode`)
23
+ - Column menu for show/hide, freeze/unfreeze, and reorder
24
+ - Native column drag-and-drop (no external drag dependency)
25
+ - Optional right panel layout with `ResizeableSplitter`
26
+ - Works in both JavaScript and TypeScript projects
27
+
28
+ ### Requirements
29
+
30
+ - Vue 3
31
+ - Vuetify 3
32
+
33
+ ## TypeScript and JavaScript support
34
+
35
+ This package supports both JavaScript and TypeScript projects.
36
+
37
+ - JavaScript projects can use the package exactly as before.
38
+ - TypeScript projects get declaration files from the package build output.
39
+ - Typed constants are exported: `FilterType` and `FilterMode`.
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install v-datatable-plus
45
+ ```
46
+
47
+ ## Latest Changes
48
+
49
+ - Column drag is now built in.
50
+ - `vuedraggable` is no longer a dependency.
51
+ - `columnMenuDragChange` remains available and emits a `moved` payload with `element`, `oldIndex`, and `newIndex`.
52
+
53
+ ## Migration
54
+
55
+ - Repository migration guide: [MIGRATION.md](MIGRATION.md)
56
+ - Documentation migration page: [Migration](https://ansaripro.github.io/v-datatable-plus/migration)
57
+
58
+ ## Vuetify auto-import note
59
+
60
+ If your app uses Vuetify auto-import/tree-shaking, components used inside external packages are not always detected automatically.
61
+
62
+ Register the required Vuetify components in your `createVuetify` setup (for example: `VDataTable`, `VDataTableServer`, `VToolbar`, `VMenu`, `VList`, `VBtn`, `VCard`, `VIcon`, `VCheckboxBtn`, `VSelect`, `VPagination`, `VSpacer`, `VTextField`).
63
+
64
+ Detailed setup examples are available in [documentation/getting-started.md](documentation/getting-started.md).
65
+
66
+ ## JavaScript usage
67
+
68
+ ```js
69
+ import { createApp } from 'vue';
70
+ import { createVuetify } from 'vuetify';
71
+ import 'vuetify/styles';
72
+ import 'v-datatable-plus/dist/v-datatable-plus.css';
73
+ import VDatatablePlusPlugin from 'v-datatable-plus';
74
+
75
+ import App from './App.vue';
76
+
77
+ const app = createApp(App);
78
+ app.use(createVuetify());
79
+ app.use(VDatatablePlusPlugin);
80
+ app.mount('#app');
81
+ ```
82
+
83
+ ## TypeScript usage
84
+
85
+ ```ts
86
+ import { createApp } from 'vue';
87
+ import { createVuetify } from 'vuetify';
88
+ import 'vuetify/styles';
89
+ import 'v-datatable-plus/dist/v-datatable-plus.css';
90
+ import VDatatablePlusPlugin, { FilterMode, FilterType } from 'v-datatable-plus';
91
+
92
+ import App from './App.vue';
93
+
94
+ const app = createApp(App);
95
+ app.use(createVuetify());
96
+ app.use(VDatatablePlusPlugin);
97
+ app.mount('#app');
98
+
99
+ const filterType: (typeof FilterType)[keyof typeof FilterType] = FilterType.Contains;
100
+ const filterMode: (typeof FilterMode)[keyof typeof FilterMode] = FilterMode.Types;
101
+ ```
102
+
103
+ ## Public type imports (TypeScript)
104
+
105
+ ```ts
106
+ import type {
107
+ DataTableHeader,
108
+ GroupByItem,
109
+ ItemsPerPageOption,
110
+ RowItem,
111
+ RowClickEventPayload,
112
+ ColumnMenuEventPayload,
113
+ SelectedRowValue,
114
+ } from 'v-datatable-plus';
115
+
116
+ const headers: DataTableHeader[] = [
117
+ { key: 'name', title: 'Name', isShow: true, sortable: true },
118
+ { key: 'age', title: 'Age', isShow: true, sortable: true, align: 'end' },
119
+ ];
120
+
121
+ const rows: RowItem[] = [
122
+ { id: 1, name: 'Alice', age: 32 },
123
+ { id: 2, name: 'Bob', age: 28 },
124
+ ];
125
+
126
+ const groupBy: GroupByItem[] = [{ key: 'name', order: 'asc' }];
127
+ const itemsPerPageOptions: ItemsPerPageOption[] = [{ value: 10, title: '10' }];
128
+
129
+ let selectedRow: SelectedRowValue = null;
130
+
131
+ function onRowClick(payload: RowClickEventPayload) {
132
+ selectedRow = payload.param?.item ?? null;
133
+ }
134
+
135
+ function onColumnMenuFixed(payload: ColumnMenuEventPayload) {
136
+ console.log(payload.element.key, payload.$event);
137
+ }
138
+ ```
139
+
140
+ ## Typed wrapper component example
141
+
142
+ ```vue
143
+ <script setup lang="ts">
144
+ import {
145
+ VDatatablePlus,
146
+ type VDatatablePlusProps,
147
+ type VDatatablePlusEmits,
148
+ type RowClickEventPayload,
149
+ } from 'v-datatable-plus';
150
+
151
+ const props = defineProps<VDatatablePlusProps>();
152
+ const emit = defineEmits<VDatatablePlusEmits>();
153
+
154
+ function onClickRow(payload: RowClickEventPayload) {
155
+ emit('click:row', payload);
156
+ }
157
+ </script>
158
+
159
+ <template>
160
+ <VDatatablePlus
161
+ v-bind="props"
162
+ @click:row="onClickRow"
163
+ @update:model-value="emit('update:modelValue', $event)"
164
+ @update:page="emit('update:page', $event)"
165
+ />
166
+ </template>
167
+ ```
168
+
169
+ ## Typed server wrapper example
170
+
171
+ ```vue
172
+ <script setup lang="ts">
173
+ import {
174
+ VDatatableServerPlus,
175
+ type VDatatableServerPlusProps,
176
+ type VDatatableServerPlusEmits,
177
+ type RowClickEventPayload,
178
+ } from 'v-datatable-plus';
179
+
180
+ const props = defineProps<VDatatableServerPlusProps>();
181
+ const emit = defineEmits<VDatatableServerPlusEmits>();
182
+
183
+ function onClickRow(payload: RowClickEventPayload) {
184
+ emit('click:row', payload);
185
+ }
186
+ </script>
187
+
188
+ <template>
189
+ <VDatatableServerPlus
190
+ v-bind="props"
191
+ @click:row="onClickRow"
192
+ @update:model-value="emit('update:modelValue', $event)"
193
+ @update:page="emit('update:page', $event)"
194
+ @update:items-per-page="emit('update:itemsPerPage', $event)"
195
+ />
196
+ </template>
197
+ ```
23
198
 
24
199
  ## [Documentation](https://ansaripro.github.io/v-datatable-plus/)
25
200
 
@@ -0,0 +1,10 @@
1
+ import './style.css';
2
+ import { FilterType, FilterMode } from './types/index';
3
+ import VDatatablePlus from './components/VDatatablePlus.vue';
4
+ import VDatatableServerPlus from './components/VDatatableServerPlus.vue';
5
+ import ResizeableSplitter from './components/ResizeableSplitter.vue';
6
+ import type { Plugin } from 'vue';
7
+ declare const VDatatablePlusPlugin: Plugin;
8
+ export default VDatatablePlusPlugin;
9
+ export { VDatatablePlus, VDatatableServerPlus, ResizeableSplitter, FilterType, FilterMode };
10
+ export type { FilterTypeValue, FilterModeValue, RowItem, SortDirection, GroupByItem, ItemsPerPageOption, SelectedRowValue, DataTableHeader, ColumnMenuEventPayload, RowClickEventPayload, VDatatablePlusProps, VDatatableServerPlusProps, VDatatablePlusEmits, VDatatableServerPlusEmits, } from './types/index';
@@ -0,0 +1,116 @@
1
+ import type { ColumnMenuEventPayload, DataTableHeader, GroupByItem, ItemsPerPageOption, RowClickEventPayload, RowItem, SelectedRowValue } from './datatable';
2
+ type AnyFn = (...args: any[]) => any;
3
+ interface BaseDatatableProps {
4
+ hideTitleBar?: boolean;
5
+ hideColumnMenu?: boolean;
6
+ showRightPanel?: boolean;
7
+ hideFilterRow?: boolean;
8
+ hideFooter?: boolean;
9
+ selectOnRow?: boolean;
10
+ highlightRow?: boolean;
11
+ rightPanelFixed?: boolean;
12
+ rightPanelWidth?: number;
13
+ dragMenuHeight?: number;
14
+ tableHeight?: string | number;
15
+ selectedRow?: SelectedRowValue;
16
+ columnMenuZIndex?: string | number;
17
+ filterMenuZIndex?: string | number;
18
+ title?: string;
19
+ rowHighlightClass?: string;
20
+ headerTextSize?: string;
21
+ headerIconSize?: string;
22
+ color?: string;
23
+ itemValue?: string;
24
+ search?: string;
25
+ customFilter?: AnyFn;
26
+ valueComparator?: AnyFn;
27
+ returnObject?: boolean;
28
+ hideNoData?: boolean;
29
+ showExpand?: boolean;
30
+ showSelect?: boolean;
31
+ disableSort?: boolean;
32
+ expandOnClick?: boolean;
33
+ mobile?: boolean;
34
+ multiSort?: boolean;
35
+ mustSort?: boolean;
36
+ sticky?: boolean;
37
+ hover?: boolean;
38
+ expanded?: any[];
39
+ groupBy?: GroupByItem[];
40
+ modelValue?: any[];
41
+ theme?: string;
42
+ filterKeys?: string | string[];
43
+ customKeyFilter?: string | number | boolean | Record<string, any> | AnyFn;
44
+ customKeySort?: string | number | boolean | Record<string, any> | AnyFn;
45
+ mobileBreakpoint?: number | string;
46
+ itemSelectable?: string | Record<string, any> | AnyFn;
47
+ rowProps?: Record<string, any> | AnyFn;
48
+ cellProps?: Record<string, any> | AnyFn;
49
+ loading?: string | boolean;
50
+ sortBy?: Array<Record<string, any>>;
51
+ items?: RowItem[];
52
+ headers?: DataTableHeader[];
53
+ page?: string | number;
54
+ itemsPerPageOptions?: ItemsPerPageOption[];
55
+ noDataText?: string;
56
+ loadingText?: string;
57
+ filterMode?: string;
58
+ density?: string;
59
+ selectStrategy?: string;
60
+ sortAscIcon?: string;
61
+ sortDescIcon?: string;
62
+ firstIcon?: string;
63
+ lastIcon?: string;
64
+ nextIcon?: string;
65
+ prevIcon?: string;
66
+ dragMenuIcon?: string;
67
+ dragItemIcon?: string;
68
+ dragItemFreezeIcon?: string;
69
+ dragItemUnFreezeIcon?: string;
70
+ filterIcon?: string;
71
+ groupByIcon?: string;
72
+ groupSortAscIcon?: string;
73
+ groupSortDescIcon?: string;
74
+ }
75
+ export interface VDatatablePlusProps extends BaseDatatableProps {
76
+ itemsPerPage?: string | number;
77
+ }
78
+ export interface VDatatableServerPlusProps extends BaseDatatableProps {
79
+ itemsLength?: number;
80
+ itemsPerPage?: number;
81
+ }
82
+ export interface VDatatablePlusEmits {
83
+ (e: 'update:currentItems', value: any): void;
84
+ (e: 'update:expanded', value: any[]): void;
85
+ (e: 'update:groupBy', value: GroupByItem[]): void;
86
+ (e: 'update:itemsPerPage', value: string | number): void;
87
+ (e: 'update:modelValue', value: any[]): void;
88
+ (e: 'update:options', value: any): void;
89
+ (e: 'update:page', value: string | number): void;
90
+ (e: 'update:sortBy', value: Array<Record<string, any>>): void;
91
+ (e: 'update:headers', value: DataTableHeader[]): void;
92
+ (e: 'update:selectedRow', value: SelectedRowValue): void;
93
+ (e: 'click:row', value: RowClickEventPayload): void;
94
+ (e: 'columnMenuOpened', value: boolean): void;
95
+ (e: 'columnMenuDragChange', value: any): void;
96
+ (e: 'columnMenuChecked', value: ColumnMenuEventPayload): void;
97
+ (e: 'columnMenuFixed', value: ColumnMenuEventPayload): void;
98
+ }
99
+ export interface VDatatableServerPlusEmits {
100
+ (e: 'update:currentItems', value: any): void;
101
+ (e: 'update:expanded', value: any[]): void;
102
+ (e: 'update:groupBy', value: GroupByItem[]): void;
103
+ (e: 'update:itemsPerPage', value: number): void;
104
+ (e: 'update:modelValue', value: any[]): void;
105
+ (e: 'update:options', value: any): void;
106
+ (e: 'update:page', value: string | number): void;
107
+ (e: 'update:sortBy', value: Array<Record<string, any>>): void;
108
+ (e: 'update:headers', value: DataTableHeader[]): void;
109
+ (e: 'update:selectedRow', value: SelectedRowValue): void;
110
+ (e: 'click:row', value: RowClickEventPayload): void;
111
+ (e: 'columnMenuOpened', value: boolean): void;
112
+ (e: 'columnMenuDragChange', value: any): void;
113
+ (e: 'columnMenuChecked', value: ColumnMenuEventPayload): void;
114
+ (e: 'columnMenuFixed', value: ColumnMenuEventPayload): void;
115
+ }
116
+ export {};
@@ -0,0 +1,51 @@
1
+ import type { FilterModeValue, FilterTypeValue } from './index';
2
+ export type RowItem = Record<string, any>;
3
+ export type SortDirection = 'asc' | 'desc' | string;
4
+ export interface GroupByItem {
5
+ key: string;
6
+ order: SortDirection;
7
+ }
8
+ export interface ItemsPerPageOption {
9
+ value: string | number;
10
+ title: string;
11
+ }
12
+ export type SelectedRowValue = RowItem | string | number | boolean | null;
13
+ export interface DataTableHeader {
14
+ key: string;
15
+ title?: string;
16
+ value?: any;
17
+ align?: any;
18
+ width?: number | string;
19
+ fixed?: boolean;
20
+ fixedOffset?: number;
21
+ lastFixed?: boolean;
22
+ rowSpan?: number;
23
+ colSpan?: number;
24
+ rowspan?: number;
25
+ colspan?: number;
26
+ children?: any[];
27
+ sortable?: boolean;
28
+ groupable?: boolean;
29
+ filterable?: boolean;
30
+ filterMode?: FilterModeValue | string;
31
+ filterType?: FilterTypeValue | string;
32
+ filterValue?: any;
33
+ allFilterValue?: any;
34
+ filterItems?: Array<{
35
+ title: string;
36
+ value: any;
37
+ }>;
38
+ isShow?: boolean;
39
+ isExclude?: boolean;
40
+ fixable?: boolean;
41
+ draggable?: boolean;
42
+ [key: string]: any;
43
+ }
44
+ export interface ColumnMenuEventPayload {
45
+ element: DataTableHeader;
46
+ $event: any;
47
+ }
48
+ export interface RowClickEventPayload {
49
+ $event: any;
50
+ param: any;
51
+ }
@@ -0,0 +1,16 @@
1
+ export declare const FilterType: {
2
+ readonly IsEqualTo: "eq";
3
+ readonly IsNotEqualTo: "neq";
4
+ readonly StartWith: "starts";
5
+ readonly Contains: "contains";
6
+ readonly NotContains: "notcontains";
7
+ readonly EndWith: "ends";
8
+ };
9
+ export declare const FilterMode: {
10
+ readonly Selection: "selection";
11
+ readonly Types: "types";
12
+ };
13
+ export type FilterTypeValue = (typeof FilterType)[keyof typeof FilterType];
14
+ export type FilterModeValue = (typeof FilterMode)[keyof typeof FilterMode];
15
+ export type { RowItem, SortDirection, GroupByItem, ItemsPerPageOption, SelectedRowValue, DataTableHeader, ColumnMenuEventPayload, RowClickEventPayload, } from './datatable';
16
+ export type { VDatatablePlusProps, VDatatableServerPlusProps, VDatatablePlusEmits, VDatatableServerPlusEmits, } from './components';