datatables.net-vue3 1.0.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 +21 -0
- package/Readme.md +75 -0
- package/dist/datatables.net-vue.esm.js +26554 -0
- package/dist/datatables.net-vue.min.js +47 -0
- package/dist/datatables.net-vue.ssr.js +26686 -0
- package/dist/types/src/datatables.net-vue.vue.d.ts +48 -0
- package/dist/types/src/entry.esm.d.ts +7 -0
- package/package.json +70 -0
- package/src/datatables.net-vue.vue +124 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 SpryMedia Limited
|
|
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
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
# DataTables component for Vue 3
|
|
3
|
+
|
|
4
|
+
This library provides a Vue 3 component for [DataTables.net](https://datatables.net) to be used inside a Vue application.
|
|
5
|
+
|
|
6
|
+
To install:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm install --save datatables.net-vue
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This will automatically install DataTables as a dependency. Other DataTables extensions can also be installed in your application - see below.
|
|
13
|
+
|
|
14
|
+
In your Vue component you can then:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import DataTable from 'datatables.net-vue'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Which makes a `DataTable` component available. It provides the following parameters:
|
|
21
|
+
|
|
22
|
+
* `columns` - Define the columns array used for [DataTables initialisation](https://datatables.net/reference/option/#datatables%20-%20columns)
|
|
23
|
+
* `data` - [Data array for DataTables](https://datatables.net/reference/option/data). This is _optional_ and if you are using Ajax to load the DataTable data is not required.
|
|
24
|
+
* `ajax` - [Ajax option for DataTables](https://datatables.net/reference/option/ajax) - to load data for the table over Ajax.
|
|
25
|
+
* `class` - Class name to assign to the `table` tag
|
|
26
|
+
* `options` - The [DataTables options](https://datatables.net/reference/option) for the table. Note that this can include `columns`, `data` and `ajax` - if they are provided by one of the properties from above that will override a matching option given here.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Templates
|
|
30
|
+
|
|
31
|
+
The `DataTable` component provides a single slot that can be used to define the HTML for the table structure - i.e. the `thead` and `tfoot`:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<DataTable :data="[[1,2], [3,4]]" class="display">
|
|
35
|
+
<thead>
|
|
36
|
+
<tr>
|
|
37
|
+
<th>A</th>
|
|
38
|
+
<th>B</th>
|
|
39
|
+
</tr>
|
|
40
|
+
</thead>
|
|
41
|
+
</DataTable>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**IMPORTANT** You should not use a Vue `for` in the template to display the HTML for the table body! Doing so will cause a conflict between DataTables and Vue both trying to control the same DOM elements. Allow DataTables to build the HTML for the rows.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Extensions
|
|
48
|
+
|
|
49
|
+
DataTables provides [a wide range of extensions](https://datatables.net/extensions/index) that singificantly expands its abilities. Extensions can be imported from npm and then registered with DataTables through it's `use()` method - e.g.:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import DataTable from 'datatables.net-vue'
|
|
53
|
+
import Select from 'datatables.net-select';
|
|
54
|
+
|
|
55
|
+
DataTable.use(Select);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Styling
|
|
60
|
+
|
|
61
|
+
The Vue component for DataTables doesn't include any styling by default. We provide support for a number of different styling libraries, and you will need to install those that you require and for any additional extensions you require.
|
|
62
|
+
|
|
63
|
+
For example, to use Bootstrap 5 styling, you would install the `-bs5` packages for DataTables:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm install datatables.net-bs5
|
|
67
|
+
npm install datatables.net-select-bs5
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
And in your Vue application's CSS (assuming your are using Vite or some other builder which can resolve the `style` property for npm packages):
|
|
71
|
+
|
|
72
|
+
```css
|
|
73
|
+
@import 'datatables.net-dt';
|
|
74
|
+
@import 'datatables.net-select-dt';
|
|
75
|
+
```
|