tablevu 0.2.22 → 0.3.0-beta.1

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 CHANGED
@@ -1,125 +1,76 @@
1
- # tablevu (alpha version)
2
- Simple javasript table for vuejs 3.x (Doesn't work with vuejs 2.x)
1
+ # tablevu
3
2
 
4
- * No Dependencies
3
+ A simple, fast, and easy-to-use Vue 3 data table component.
5
4
 
6
- * Working with javascript array or server side (odata or default request)
5
+ ## Installation
7
6
 
8
- * Sorting
9
-
10
- * Filtering
11
-
12
- * Custom column rendering
13
-
14
- * ...
15
-
16
-
17
- ## Install
18
- ```shell
7
+ ```bash
19
8
  npm install tablevu
20
9
  ```
21
10
 
22
-
23
11
  ## Usage
24
- * **data** : Array or Server side parameters
25
-
26
- * **grouping** : Grouping data specific column or function
27
-
28
- * **filter** : Reactive filter value
29
-
30
- * **search** : Reactive search value
31
-
32
- * **rowid** : Key value for row.
33
-
34
- * **class** : Table class name. (default "table")
35
-
36
- * **buttonclass** : Arrow buttons class name (default "btn")
37
-
38
- * **onRowClick** : Row click event
39
-
40
- * **onRowDblClick** : Row double click event
41
-
42
- * **columns**
43
- * **name** : Column name
44
-
45
- * **label** : Column label
46
-
47
- * **searchable** : Column is searchable (default true)
48
-
49
- * **orderable** : Column is orderable (default true)
50
-
51
- * **width** : Column width
52
-
53
- * **align** : Column align
54
-
55
- * **style** : Column style
56
12
 
57
- * **type** : Data type (datetime, date, time, numeric). Show local value
58
-
59
- * **render** : Render value
13
+ ```vue
14
+ <script setup>
15
+ import { TableVu } from 'tablevu'
60
16
 
17
+ const columns = [
18
+ { name: 'id', label: 'ID' },
19
+ { name: 'name', label: 'Name' },
20
+ { name: 'email', label: 'Email' }
21
+ ]
61
22
 
62
- ## Samples
63
-
64
- * odata sample (Coming soon..)
65
- * search sample (Coming soon..)
66
-
67
-
68
- **odata sample**
23
+ const data = [
24
+ { id: 1, name: 'John', email: 'john@example.com' },
25
+ { id: 2, name: 'Jane', email: 'jane@example.com' }
26
+ ]
27
+ </script>
69
28
 
70
- ```code
71
29
  <template>
72
- <tablevu :data="grid" rowid="OrderId" />
30
+ <TableVu :data="data" :columns="columns" />
73
31
  </template>
74
-
75
- <script>
76
- import { tablevu, odata } from 'tablevu'
77
-
78
- export default {
79
- name: 'App',
80
- components: {
81
- tablevu
82
- },
83
- setup() {
84
- const prm = {
85
- url: `https://services.odata.org/V3/Northwind/Northwind.svc/Orders?$format=json`,
86
- header: { 'Content-Type': 'application/json;odata=verbose' },
87
- select: ['OrderID', 'OrderDate', 'ShipName', 'ShipAddress'],
88
- expand: [
89
- ]
90
- };
91
-
92
- const grid = {
93
- adapter: (grd) => {
94
- return odata(prm, grd);
95
- },
96
- pageSize: 10,
97
- columns: [
98
- { name: 'OrderID', label: 'id', width: '26rem' },
99
- { name: 'OrderDate', label: 'name', width: '26rem' },
100
- { name: 'ShipName', label: 'name', width: '26rem' },
101
- { name: 'ShipAddress', label: 'name', width: '26rem' },
102
- ]
103
- }
104
-
105
- return { grid }
106
- }
107
- }
108
- </script>
109
32
  ```
110
33
 
111
- ## Dev. Dependencies
112
-
113
- - [Vuejs](https://github.com/vuejs/vue) 3.0+
114
-
115
-
116
- ## Browser Support
117
-
118
- Modern browsers.
119
-
120
-
121
- ## Authors
122
- endb
34
+ ## Props
35
+
36
+ | Prop | Type | Default | Description |
37
+ |------|------|---------|-------------|
38
+ | `data` | `Object` | - | Must contain `columns`, `pageSize`, `currPage`, `sort`, and `value`/`@count` properties, or an array |
39
+ | `columns` | `Array` | - | Column definitions with `name`, `label`, `type`, `align`, `width`, `render` properties |
40
+ | `search` | `String` | - | Search term (debounced) |
41
+ | `filter` | `Array` / `Object` | - | Filter objects |
42
+ | `command` | `Array` | `[]` | Commands like `refresh`, `first`, `previous`, `next`, `last` |
43
+ | `rowid` | `String` | - | Row ID field name |
44
+ | `onRowClick` | `Function` | - | Row click handler |
45
+ | `onRowDblClick` | `Function` | - | Row double-click handler |
46
+ | `class` | `String` | `'table'` | CSS class for the table |
47
+ | `buttonclass` | `String` | `'btn'` | CSS class for pagination buttons |
48
+
49
+ ## Events
50
+
51
+ - `row-click` - Emitted when a row is clicked
52
+ - `row-dbl-click` - Emitted when a row is double-clicked
53
+
54
+ ## Example
55
+
56
+ ```vue
57
+ <script setup>
58
+ import { ref } from 'vue'
59
+ import { TableVu } from 'tablevu'
60
+
61
+ const data = ref([])
62
+ const columns = ref([
63
+ { name: 'id', label: 'ID' },
64
+ { name: 'name', label: 'Name' }
65
+ ])
66
+ </script>
123
67
 
124
- ## License
125
- tablevu is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
68
+ <template>
69
+ <TableVu
70
+ :data="data"
71
+ :columns="columns"
72
+ @row-click="handleRowClick"
73
+ @row-dbl-click="handleRowDblClick"
74
+ />
75
+ </template>
76
+ ```
@@ -0,0 +1,14 @@
1
+ import type { TablevuSort, TablevuColumn } from './table';
2
+ export interface ArrayAdapterParams {
3
+ pageSize?: number;
4
+ currPage?: number;
5
+ sort?: TablevuSort[];
6
+ cols?: TablevuColumn[];
7
+ filter?: any;
8
+ search?: string | null;
9
+ }
10
+ export interface AdapterResult<T = any> {
11
+ rows: T[];
12
+ count: number;
13
+ }
14
+ export default function adaptArray<T = any>(props: ArrayAdapterParams, data: T[]): Promise<AdapterResult<T>>;
@@ -0,0 +1,7 @@
1
+ export { default as TableVu } from './table';
2
+ export * from './table';
3
+ export { default as odata, toODataFilter as buildFilter, } from './odata';
4
+ export type { FilterOperator, Filter, Column, Sort, Expand, DataTableProps, ODataOptions } from './odata';
5
+ export { default as webapi } from './webapi';
6
+ export * from './webapi';
7
+ export { default as adaptArray, type ArrayAdapterParams, type AdapterResult } from './array';
@@ -0,0 +1,40 @@
1
+ export type FilterOperator = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le' | 'contains' | 'startsWith' | 'endsWith' | 'in' | 'between' | 'isNull' | 'isNotNull' | 'and' | 'or' | 'not' | 'any' | 'all' | 'countGt' | 'countGe' | 'countLt' | 'countLe';
2
+ export interface Filter {
3
+ column?: string;
4
+ operator: FilterOperator;
5
+ value?: unknown;
6
+ filters?: Filter[];
7
+ func?: string;
8
+ params?: unknown[];
9
+ }
10
+ export interface Column {
11
+ name: string;
12
+ searchable?: boolean;
13
+ }
14
+ export interface Sort {
15
+ index?: number;
16
+ name?: string;
17
+ dir?: 'asc' | 'desc' | string;
18
+ }
19
+ export interface Expand {
20
+ name: string;
21
+ select?: string[];
22
+ }
23
+ export interface DataTableProps {
24
+ pageSize?: number;
25
+ currPage?: number;
26
+ filter?: Filter;
27
+ search?: string;
28
+ sort?: Sort[];
29
+ cols?: Column[];
30
+ }
31
+ export interface ODataOptions {
32
+ url: string;
33
+ header?: RequestInit;
34
+ select?: string[];
35
+ expand?: Expand[];
36
+ filter?: Filter;
37
+ count?: boolean;
38
+ }
39
+ export declare function toODataFilter(filter: Filter): string;
40
+ export default function odata(options: ODataOptions, props?: DataTableProps): Request;
@@ -0,0 +1,173 @@
1
+ import { PropType, EmitsOptions } from 'vue';
2
+ export type TablevuStatus = -1 | 0 | 1;
3
+ export declare const TablevuStatus: {
4
+ Error: TablevuStatus;
5
+ Ready: TablevuStatus;
6
+ Loading: TablevuStatus;
7
+ };
8
+ export interface TablevuColumn {
9
+ name: string;
10
+ label?: string;
11
+ type?: 'string' | 'number' | 'numeric' | 'integer' | 'date' | 'time' | 'datetime' | 'boolean';
12
+ align?: 'left' | 'center' | 'right';
13
+ width?: string;
14
+ style?: Record<string, string>;
15
+ render?: (row: any) => any;
16
+ colspan?: number;
17
+ depth?: string[];
18
+ header?: {
19
+ colspan?: number;
20
+ style?: Record<string, string>;
21
+ align?: string;
22
+ };
23
+ popup?: boolean;
24
+ filter?: any;
25
+ }
26
+ export interface TablevuSort {
27
+ index?: number;
28
+ name?: string;
29
+ dir?: 'asc' | 'desc' | null | string;
30
+ }
31
+ export interface TablevuGroup {
32
+ value?: string | number | bigint | ((row: any) => any);
33
+ content?: string | number | ((row: any) => any);
34
+ expandAll?: boolean;
35
+ class?: string;
36
+ }
37
+ export interface TablevuPageSettings {
38
+ size?: number;
39
+ type?: 'incremental' | 'dynamic';
40
+ }
41
+ export interface TablevuFooterSettings {
42
+ button?: {
43
+ class?: string;
44
+ };
45
+ }
46
+ export interface TablevuSettings {
47
+ group?: TablevuGroup;
48
+ page?: TablevuPageSettings;
49
+ sort?: TablevuSort[];
50
+ columns?: TablevuColumn[];
51
+ searchMinChar?: number;
52
+ footer?: TablevuFooterSettings;
53
+ onData?: (rows: any[]) => any[];
54
+ }
55
+ export interface TablevuProps {
56
+ settings?: TablevuSettings;
57
+ data?: any[] | ((params: any, data: any[]) => Promise<any>);
58
+ group?: string | object;
59
+ search?: string;
60
+ filter?: any;
61
+ command?: Array<{
62
+ name: string;
63
+ }>;
64
+ rowid?: string;
65
+ onRowClick?: (event: MouseEvent, row: any) => void;
66
+ onRowDblClick?: (event: MouseEvent, row: any) => void;
67
+ class?: string;
68
+ style?: string;
69
+ }
70
+ export interface TablevuEmits {
71
+ (e: 'onRowClick', event: MouseEvent, row: any): void;
72
+ (e: 'onRowDblClick', event: MouseEvent, row: any): void;
73
+ }
74
+ interface AdapterResult {
75
+ rows: any[];
76
+ count: number;
77
+ }
78
+ type AdapterFunction = (params: {
79
+ pageSize: number;
80
+ currPage: number;
81
+ sort: TablevuSort[];
82
+ cols: TablevuColumn[];
83
+ filter: any;
84
+ search: string | null;
85
+ }, data: any[]) => Promise<AdapterResult>;
86
+ interface TablevuSpec {
87
+ caption: any;
88
+ group: TablevuGroup & {
89
+ value: any;
90
+ content: any;
91
+ expandAll: boolean;
92
+ class: string;
93
+ };
94
+ page: {
95
+ count: number;
96
+ size: number;
97
+ current: number;
98
+ type: string | null;
99
+ };
100
+ sort: TablevuSort[];
101
+ columns: TablevuColumn[];
102
+ footer: {
103
+ button: {
104
+ class: string;
105
+ };
106
+ };
107
+ status: TablevuStatus;
108
+ time: number | null;
109
+ search: string | null;
110
+ filter: any;
111
+ onData?: (rows: any[]) => any[];
112
+ }
113
+ interface TableSetupReturn {
114
+ spec: TablevuSpec;
115
+ renderHeader: () => any[];
116
+ renderBody: () => any[];
117
+ renderFooter: () => any[];
118
+ renderCaption: () => any;
119
+ }
120
+ declare const tablevu: {
121
+ props: {
122
+ readonly settings: {
123
+ readonly type: PropType<TablevuSettings>;
124
+ readonly default: null;
125
+ };
126
+ readonly data: {
127
+ readonly type: PropType<any[] | AdapterFunction>;
128
+ };
129
+ readonly group: {
130
+ readonly type: PropType<string | object>;
131
+ };
132
+ readonly search: {
133
+ readonly type: PropType<string>;
134
+ };
135
+ readonly filter: {
136
+ readonly type: PropType<any>;
137
+ };
138
+ readonly command: {
139
+ readonly type: PropType<Array<{
140
+ name: string;
141
+ }>>;
142
+ readonly default: () => never[];
143
+ };
144
+ readonly rowid: {
145
+ readonly type: PropType<string>;
146
+ };
147
+ readonly onRowClick: {
148
+ readonly type: PropType<(event: MouseEvent, row: any) => void>;
149
+ };
150
+ readonly onRowDblClick: {
151
+ readonly type: PropType<(event: MouseEvent, row: any) => void>;
152
+ };
153
+ readonly class: {
154
+ readonly type: PropType<string>;
155
+ readonly default: "table";
156
+ };
157
+ readonly style: {
158
+ readonly type: PropType<string>;
159
+ readonly default: null;
160
+ };
161
+ };
162
+ emits: EmitsOptions;
163
+ setup(props: TablevuProps, { attrs, slots, emit, expose }: {
164
+ attrs: any;
165
+ slots: any;
166
+ emit: any;
167
+ expose: any;
168
+ }): TableSetupReturn;
169
+ render(props: TablevuProps): import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
170
+ [key: string]: any;
171
+ }>;
172
+ };
173
+ export default tablevu;