datatables.net-vue3 2.0.0 → 2.1.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 +12 -0
- package/dist/datatables.net-vue3.d.ts +83 -0
- package/dist/datatables.net-vue3.js +1 -0
- package/dist/datatables.net-vue3.mjs +119 -0
- package/dist/datatables.net-vue3.umd.js +1 -0
- package/package.json +20 -40
- package/src/datatables.net-vue.vue +128 -105
- package/dist/datatables.net-vue.esm.js +0 -137
- package/dist/datatables.net-vue.min.js +0 -1
- package/dist/datatables.net-vue.ssr.js +0 -274
- package/dist/types/src/datatables.net-vue.vue.d.ts +0 -48
- package/dist/types/src/entry.esm.d.ts +0 -7
package/Readme.md
CHANGED
|
@@ -89,3 +89,15 @@ And in your Vue application's CSS (assuming your are using Vite or some other bu
|
|
|
89
89
|
@import 'datatables.net-dt';
|
|
90
90
|
@import 'datatables.net-select-dt';
|
|
91
91
|
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
Clone this repo and then in your terminal:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
npm install
|
|
100
|
+
npm run dev
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
You will then be able to access various examples in your browser by clicking the link shown in your terminal.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AllowedComponentProps } from 'vue';
|
|
2
|
+
import type { Api } from 'datatables.net';
|
|
3
|
+
import { ComponentCustomProps } from 'vue';
|
|
4
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
5
|
+
import type { Config } from 'datatables.net';
|
|
6
|
+
import type { ConfigColumns } from 'datatables.net';
|
|
7
|
+
import { DefineComponent } from 'vue';
|
|
8
|
+
import { ExtractPropTypes } from 'vue';
|
|
9
|
+
import { Plugin as Plugin_2 } from 'vue';
|
|
10
|
+
import { PropType } from 'vue';
|
|
11
|
+
import { Ref } from 'vue';
|
|
12
|
+
import { VNodeProps } from 'vue';
|
|
13
|
+
|
|
14
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
15
|
+
|
|
16
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
17
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
18
|
+
type: PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
19
|
+
} : {
|
|
20
|
+
type: PropType<T[K]>;
|
|
21
|
+
required: true;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
26
|
+
new (): {
|
|
27
|
+
$slots: S;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
declare const _default: InstallableComponent;
|
|
32
|
+
export default _default;
|
|
33
|
+
|
|
34
|
+
declare const _default_2: __VLS_WithTemplateSlots<DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
35
|
+
/**
|
|
36
|
+
* Load data for the table's content from an Ajax source
|
|
37
|
+
*/
|
|
38
|
+
ajax?: Config['ajax'];
|
|
39
|
+
/**
|
|
40
|
+
* Set column specific initialisation properties.
|
|
41
|
+
*/
|
|
42
|
+
columns?: ConfigColumns[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Data to use as the display data for the table.
|
|
45
|
+
*/
|
|
46
|
+
data?: any;
|
|
47
|
+
/**
|
|
48
|
+
* DataTables options
|
|
49
|
+
*/
|
|
50
|
+
options?: Config | undefined;
|
|
51
|
+
}>, {
|
|
52
|
+
/**
|
|
53
|
+
* DataTable instance
|
|
54
|
+
*/
|
|
55
|
+
dt: Ref<Api<any> | undefined>;
|
|
56
|
+
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, string[], string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
57
|
+
/**
|
|
58
|
+
* Load data for the table's content from an Ajax source
|
|
59
|
+
*/
|
|
60
|
+
ajax?: Config['ajax'];
|
|
61
|
+
/**
|
|
62
|
+
* Set column specific initialisation properties.
|
|
63
|
+
*/
|
|
64
|
+
columns?: ConfigColumns[] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Data to use as the display data for the table.
|
|
67
|
+
*/
|
|
68
|
+
data?: any;
|
|
69
|
+
/**
|
|
70
|
+
* DataTables options
|
|
71
|
+
*/
|
|
72
|
+
options?: Config | undefined;
|
|
73
|
+
}>>> & {
|
|
74
|
+
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
75
|
+
}, {}>, {
|
|
76
|
+
default: (_: {}) => any;
|
|
77
|
+
}>;
|
|
78
|
+
|
|
79
|
+
export declare type InstallableComponent = typeof _default_2 & {
|
|
80
|
+
install: Exclude<Plugin_2['install'], undefined>;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("vue"),v=["childRow","column-sizing","column-visibility","destroy","draw","error","init","length","order","page","preDraw","preInit","preXhr","processing","requestChild","search","stateLoadParams","stateLoaded","stateSaveParams","xhr","autoFill","preAutoFill","buttons-action","buttons-processing","column-reorder","key","key-blur","key-focus","key-refocus","key-return-submit","responsive-display","responsive-resize","rowgroup-datasrc","pre-row-reorder","row-reorder","row-reordered","dtsb-inserted","deselect","select","select-blur","selectItems","selectStyle","user-select","stateRestore-change"];let d;const w={name:"Datatables.netVue",inheritAttrs:!1,use(o){d=o}},g=r.defineComponent({...w,props:{ajax:null,columns:null,data:null,options:null},emits:v,setup(o,{expose:u}){const s=o,c=r.ref(null),a=r.ref(),b=r.ref([]);r.watch(()=>s.data,e=>{var l,i,p,m;let t=(l=a.value)==null?void 0:l.data().toArray();for(let n of e)t!=null&&t.includes(n)||(i=a.value)==null||i.row.add(n);if(typeof t<"u")for(let n of t)e.includes(n)||(p=a.value)==null||p.row((k,y)=>y===n).remove();(m=a.value)==null||m.rows().invalidate().draw(!1),f(e)},{deep:!0}),r.onMounted(()=>{const e=r.getCurrentInstance();let t=s.options||{};if(s.data&&(t.data=s.data,f(t.data)),s.columns&&(t.columns=s.columns),s.ajax&&(t.ajax=s.ajax),!d)throw new Error("DataTables library not set. See https://datatables.net/tn/19 for details.");a.value=new d(r.unref(c),t);for(let l of v)a.value&&e&&a.value.on(l,i=>{e.emit(l,{event:i,dt:a})})}),r.onBeforeUnmount(()=>{var e;(e=a.value)==null||e.destroy(!0)});function f(e){b.value=e.value?e.value.slice():e.slice()}return u({dt:a}),(e,t)=>t[0]||(r.setBlockTracking(-1),t[0]=r.createElementVNode("div",{class:"datatable"},[r.createElementVNode("table",r.mergeProps({ref_key:"table",ref:c},e.$attrs,{style:{width:"100%"}}),[r.renderSlot(e.$slots,"default")],16)]),r.setBlockTracking(1),t[0])}}),h=(()=>{const o=g;return o.install=u=>{u.component("Datatables.netVue",o)},o})();module.exports=h;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineComponent as h, ref as u, watch as k, onMounted as x, getCurrentInstance as D, unref as _, onBeforeUnmount as j, setBlockTracking as v, createElementVNode as b, mergeProps as S, renderSlot as A } from "vue";
|
|
2
|
+
const y = [
|
|
3
|
+
"childRow",
|
|
4
|
+
"column-sizing",
|
|
5
|
+
"column-visibility",
|
|
6
|
+
"destroy",
|
|
7
|
+
"draw",
|
|
8
|
+
"error",
|
|
9
|
+
"init",
|
|
10
|
+
"length",
|
|
11
|
+
"order",
|
|
12
|
+
"page",
|
|
13
|
+
"preDraw",
|
|
14
|
+
"preInit",
|
|
15
|
+
"preXhr",
|
|
16
|
+
"processing",
|
|
17
|
+
"requestChild",
|
|
18
|
+
"search",
|
|
19
|
+
"stateLoadParams",
|
|
20
|
+
"stateLoaded",
|
|
21
|
+
"stateSaveParams",
|
|
22
|
+
"xhr",
|
|
23
|
+
"autoFill",
|
|
24
|
+
"preAutoFill",
|
|
25
|
+
"buttons-action",
|
|
26
|
+
"buttons-processing",
|
|
27
|
+
"column-reorder",
|
|
28
|
+
"key",
|
|
29
|
+
"key-blur",
|
|
30
|
+
"key-focus",
|
|
31
|
+
"key-refocus",
|
|
32
|
+
"key-return-submit",
|
|
33
|
+
"responsive-display",
|
|
34
|
+
"responsive-resize",
|
|
35
|
+
"rowgroup-datasrc",
|
|
36
|
+
"pre-row-reorder",
|
|
37
|
+
"row-reorder",
|
|
38
|
+
"row-reordered",
|
|
39
|
+
"dtsb-inserted",
|
|
40
|
+
"deselect",
|
|
41
|
+
"select",
|
|
42
|
+
"select-blur",
|
|
43
|
+
"selectItems",
|
|
44
|
+
"selectStyle",
|
|
45
|
+
"user-select",
|
|
46
|
+
"stateRestore-change"
|
|
47
|
+
];
|
|
48
|
+
let d;
|
|
49
|
+
const C = {
|
|
50
|
+
name: "Datatables.netVue",
|
|
51
|
+
inheritAttrs: !1,
|
|
52
|
+
use(s) {
|
|
53
|
+
d = s;
|
|
54
|
+
}
|
|
55
|
+
}, E = /* @__PURE__ */ h({
|
|
56
|
+
...C,
|
|
57
|
+
props: {
|
|
58
|
+
ajax: null,
|
|
59
|
+
columns: null,
|
|
60
|
+
data: null,
|
|
61
|
+
options: null
|
|
62
|
+
},
|
|
63
|
+
emits: y,
|
|
64
|
+
setup(s, { expose: i }) {
|
|
65
|
+
const r = s, c = u(null), a = u(), w = u([]);
|
|
66
|
+
k(
|
|
67
|
+
() => r.data,
|
|
68
|
+
(e) => {
|
|
69
|
+
var o, n, p, m;
|
|
70
|
+
let t = (o = a.value) == null ? void 0 : o.data().toArray();
|
|
71
|
+
for (let l of e)
|
|
72
|
+
t != null && t.includes(l) || (n = a.value) == null || n.row.add(l);
|
|
73
|
+
if (typeof t < "u")
|
|
74
|
+
for (let l of t)
|
|
75
|
+
e.includes(l) || (p = a.value) == null || p.row((I, g) => g === l).remove();
|
|
76
|
+
(m = a.value) == null || m.rows().invalidate().draw(!1), f(e);
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
deep: !0
|
|
80
|
+
}
|
|
81
|
+
), x(() => {
|
|
82
|
+
const e = D();
|
|
83
|
+
let t = r.options || {};
|
|
84
|
+
if (r.data && (t.data = r.data, f(t.data)), r.columns && (t.columns = r.columns), r.ajax && (t.ajax = r.ajax), !d)
|
|
85
|
+
throw new Error(
|
|
86
|
+
"DataTables library not set. See https://datatables.net/tn/19 for details."
|
|
87
|
+
);
|
|
88
|
+
a.value = new d(_(c), t);
|
|
89
|
+
for (let o of y)
|
|
90
|
+
a.value && e && a.value.on(o, (n) => {
|
|
91
|
+
e.emit(o, { event: n, dt: a });
|
|
92
|
+
});
|
|
93
|
+
}), j(() => {
|
|
94
|
+
var e;
|
|
95
|
+
(e = a.value) == null || e.destroy(!0);
|
|
96
|
+
});
|
|
97
|
+
function f(e) {
|
|
98
|
+
w.value = e.value ? e.value.slice() : e.slice();
|
|
99
|
+
}
|
|
100
|
+
return i({
|
|
101
|
+
dt: a
|
|
102
|
+
}), (e, t) => t[0] || (v(-1), t[0] = b("div", { class: "datatable" }, [
|
|
103
|
+
b("table", S({
|
|
104
|
+
ref_key: "table",
|
|
105
|
+
ref: c
|
|
106
|
+
}, e.$attrs, { style: { width: "100%" } }), [
|
|
107
|
+
A(e.$slots, "default")
|
|
108
|
+
], 16)
|
|
109
|
+
]), v(1), t[0]);
|
|
110
|
+
}
|
|
111
|
+
}), P = /* @__PURE__ */ (() => {
|
|
112
|
+
const s = E;
|
|
113
|
+
return s.install = (i) => {
|
|
114
|
+
i.component("Datatables.netVue", s);
|
|
115
|
+
}, s;
|
|
116
|
+
})();
|
|
117
|
+
export {
|
|
118
|
+
P as default
|
|
119
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("vue")):typeof define=="function"&&define.amd?define(["vue"],o):(e=typeof globalThis<"u"?globalThis:e||self,e.datatables=e.datatables||{},e.datatables["net-vue3"]=o(e.Vue))})(this,function(e){"use strict";const o=["childRow","column-sizing","column-visibility","destroy","draw","error","init","length","order","page","preDraw","preInit","preXhr","processing","requestChild","search","stateLoadParams","stateLoaded","stateSaveParams","xhr","autoFill","preAutoFill","buttons-action","buttons-processing","column-reorder","key","key-blur","key-focus","key-refocus","key-return-submit","responsive-display","responsive-resize","rowgroup-datasrc","pre-row-reorder","row-reorder","row-reordered","dtsb-inserted","deselect","select","select-blur","selectItems","selectStyle","user-select","stateRestore-change"];let u;const y={name:"Datatables.netVue",inheritAttrs:!1,use(n){u=n}},h=e.defineComponent({...y,props:{ajax:null,columns:null,data:null,options:null},emits:o,setup(n,{expose:c}){const r=n,f=e.ref(null),s=e.ref(),w=e.ref([]);e.watch(()=>r.data,t=>{var l,d,m,b;let a=(l=s.value)==null?void 0:l.data().toArray();for(let i of t)a!=null&&a.includes(i)||(d=s.value)==null||d.row.add(i);if(typeof a<"u")for(let i of a)t.includes(i)||(m=s.value)==null||m.row((x,k)=>k===i).remove();(b=s.value)==null||b.rows().invalidate().draw(!1),p(t)},{deep:!0}),e.onMounted(()=>{const t=e.getCurrentInstance();let a=r.options||{};if(r.data&&(a.data=r.data,p(a.data)),r.columns&&(a.columns=r.columns),r.ajax&&(a.ajax=r.ajax),!u)throw new Error("DataTables library not set. See https://datatables.net/tn/19 for details.");s.value=new u(e.unref(f),a);for(let l of o)s.value&&t&&s.value.on(l,d=>{t.emit(l,{event:d,dt:s})})}),e.onBeforeUnmount(()=>{var t;(t=s.value)==null||t.destroy(!0)});function p(t){w.value=t.value?t.value.slice():t.slice()}return c({dt:s}),(t,a)=>a[0]||(e.setBlockTracking(-1),a[0]=e.createElementVNode("div",{class:"datatable"},[e.createElementVNode("table",e.mergeProps({ref_key:"table",ref:f},t.$attrs,{style:{width:"100%"}}),[e.renderSlot(t.$slots,"default")],16)]),e.setBlockTracking(1),a[0])}});return(()=>{const n=h;return n.install=c=>{c.component("Datatables.netVue",n)},n})()});
|
package/package.json
CHANGED
|
@@ -1,59 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datatables.net-vue3",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Vue3 component for DataTables",
|
|
5
|
-
"main": "dist/datatables.net-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"unpkg": "dist/datatables.net-
|
|
9
|
-
"types": "dist/
|
|
5
|
+
"main": "dist/datatables.net-vue3.umd.js",
|
|
6
|
+
"module": "dist/datatables.net-vue3.mjs",
|
|
7
|
+
"require": "dist/datatables.net-vue3.js",
|
|
8
|
+
"unpkg": "dist/datatables.net-vue3.umd.js",
|
|
9
|
+
"types": "dist/datatables.net-vue3.d.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/*",
|
|
12
12
|
"src/**/*.vue"
|
|
13
13
|
],
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"build": "
|
|
19
|
-
"build:ssr": "NODE_ENV=production rollup --config build/rollup.config.js --format cjs",
|
|
20
|
-
"build:es": "NODE_ENV=production rollup --config build/rollup.config.js --format es",
|
|
21
|
-
"build:unpkg": "NODE_ENV=production rollup --config build/rollup.config.js --format iife",
|
|
22
|
-
"postbuild": "rimraf ./dist/types/dev ./dist/types/src/entry.d.ts"
|
|
23
|
-
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"datatables.net": "^1.13.1",
|
|
26
|
-
"jquery": "^3.6.0"
|
|
16
|
+
"dev": "vite --host",
|
|
17
|
+
"build": "cross-env NODE_ENV=production vite build && npm run build-types",
|
|
18
|
+
"build-types": "vue-tsc --emitDeclarationOnly -p ./tsconfig.types.json && api-extractor run && rimraf ./temp"
|
|
27
19
|
},
|
|
28
20
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@babel/preset-env": "^7.14.7",
|
|
31
|
-
"@babel/preset-typescript": "^7.14.5",
|
|
32
|
-
"@rollup/plugin-alias": "^3.1.2",
|
|
33
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
34
|
-
"@rollup/plugin-commonjs": "^14.0.0",
|
|
35
|
-
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
36
|
-
"@rollup/plugin-replace": "^2.4.2",
|
|
21
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
37
22
|
"@types/jquery": "^3.5.14",
|
|
38
|
-
"@
|
|
39
|
-
"@vue/cli-plugin-typescript": "^4.5.13",
|
|
40
|
-
"@vue/cli-service": "^4.5.13",
|
|
41
|
-
"@vue/compiler-sfc": "^3.0.11",
|
|
42
|
-
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
23
|
+
"@vitejs/plugin-vue": "^4.0.0",
|
|
43
24
|
"cross-env": "^7.0.3",
|
|
44
|
-
"
|
|
45
|
-
"postcss": "^8.2.10",
|
|
25
|
+
"datatables.net-select-dt": "^1.5.0",
|
|
46
26
|
"rimraf": "^3.0.2",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"rollup-plugin-typescript2": "^0.30.0",
|
|
51
|
-
"rollup-plugin-vue": "^6.0.0",
|
|
52
|
-
"ttypescript": "^1.5.12",
|
|
53
|
-
"typescript": "^4.0.3",
|
|
54
|
-
"vue": "^3.0.5"
|
|
27
|
+
"typescript": "^4.8.4",
|
|
28
|
+
"vue": "^3.2.45",
|
|
29
|
+
"vue-tsc": "^1.0.16"
|
|
55
30
|
},
|
|
56
31
|
"peerDependencies": {
|
|
32
|
+
"datatables.net": "^1.13.1",
|
|
33
|
+
"jquery": "^3.6.0",
|
|
57
34
|
"vue": "^3.0.5"
|
|
58
35
|
},
|
|
59
36
|
"engines": {
|
|
@@ -66,5 +43,8 @@
|
|
|
66
43
|
"author": {
|
|
67
44
|
"name": "SpryMedia Ltd",
|
|
68
45
|
"url": "http://datatables.net"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"datatables.net-responsive-dt": "^2.4.0"
|
|
69
49
|
}
|
|
70
50
|
}
|
|
@@ -1,122 +1,145 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
export let DataTablesLib: any
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
_dt: null | any,
|
|
9
|
-
oldData: Array<any>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const Comp = defineComponent({
|
|
13
|
-
name: 'DataTable',
|
|
14
|
-
expose: [
|
|
15
|
-
'dt',
|
|
16
|
-
],
|
|
17
|
-
data(): IData {
|
|
18
|
-
return {
|
|
19
|
-
_dt: null,
|
|
20
|
-
oldData: [],
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
computed: {},
|
|
24
|
-
methods: {
|
|
25
|
-
dt() {
|
|
26
|
-
return this._dt;
|
|
27
|
-
},
|
|
28
|
-
saveOld(d: any) {
|
|
29
|
-
this.oldData = d.value
|
|
30
|
-
? d.value.slice()
|
|
31
|
-
: d.slice();
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
mounted() {
|
|
35
|
-
// Component shown so we can initialise DataTables of the table now
|
|
36
|
-
let table = this.$el.querySelector('table');
|
|
37
|
-
let options: any = this.options;
|
|
38
|
-
|
|
39
|
-
if (this.data) {
|
|
40
|
-
options.data = this.data;
|
|
41
|
-
this.saveOld(options.data);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (this.columns) {
|
|
45
|
-
options.columns = this.columns;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (this.ajax) {
|
|
49
|
-
options.ajax = this.ajax;
|
|
4
|
+
export default {
|
|
5
|
+
name: 'Datatables.netVue',
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
use(lib: any) {
|
|
8
|
+
DataTablesLib = lib;
|
|
50
9
|
}
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
51
12
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
13
|
+
<script lang="ts" setup>
|
|
14
|
+
// imports
|
|
15
|
+
import { ref, unref, watch, onMounted, onBeforeUnmount, getCurrentInstance} from 'vue';
|
|
16
|
+
import type { Api, Config, ConfigColumns } from 'datatables.net';
|
|
17
|
+
import dtEvents from './dtEvents';
|
|
18
|
+
|
|
19
|
+
// props
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
/**
|
|
22
|
+
* Load data for the table's content from an Ajax source
|
|
23
|
+
*/
|
|
24
|
+
ajax?: Config['ajax'];
|
|
25
|
+
/**
|
|
26
|
+
* Set column specific initialisation properties.
|
|
27
|
+
*/
|
|
28
|
+
columns?: ConfigColumns[];
|
|
29
|
+
/**
|
|
30
|
+
* Data to use as the display data for the table.
|
|
31
|
+
*/
|
|
32
|
+
data?: any;
|
|
33
|
+
/**
|
|
34
|
+
* DataTables options
|
|
35
|
+
*/
|
|
36
|
+
options?: Config;
|
|
37
|
+
}>();
|
|
38
|
+
|
|
39
|
+
// emits
|
|
40
|
+
defineEmits(dtEvents);
|
|
41
|
+
|
|
42
|
+
// setup
|
|
43
|
+
const table = ref<HTMLTableElement | null>(null);
|
|
44
|
+
|
|
45
|
+
// data
|
|
46
|
+
const dt = ref<Api<any>>();
|
|
47
|
+
const oldData = ref<any[]>([]);
|
|
48
|
+
|
|
49
|
+
// computed
|
|
50
|
+
|
|
51
|
+
// watch
|
|
52
|
+
watch(
|
|
53
|
+
() => props.data,
|
|
54
|
+
(newVal) => {
|
|
55
|
+
let known = dt.value?.data().toArray();
|
|
56
|
+
|
|
57
|
+
// Find any new rows
|
|
58
|
+
for (let n of newVal) {
|
|
59
|
+
if (!known?.includes(n)) {
|
|
60
|
+
dt.value?.row.add(n);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Remove any old rows
|
|
65
|
+
if (typeof known !== 'undefined') {
|
|
66
|
+
for (let k of known) {
|
|
67
|
+
if (!newVal.includes(k)) {
|
|
68
|
+
dt.value?.row((_idx: any, d: any) => d === k).remove();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Data in other rows might have changes, so we need to invalidate the rows
|
|
74
|
+
dt.value?.rows().invalidate().draw(false);
|
|
75
|
+
|
|
76
|
+
saveOld(newVal);
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
deep: true,
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// lifecycle
|
|
84
|
+
onMounted(() => {
|
|
85
|
+
const inst = getCurrentInstance();
|
|
86
|
+
let options: any = props.options || {};
|
|
87
|
+
|
|
88
|
+
if (props.data) {
|
|
89
|
+
options.data = props.data;
|
|
90
|
+
saveOld(options.data);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (props.columns) {
|
|
94
|
+
options.columns = props.columns;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (props.ajax) {
|
|
98
|
+
options.ajax = props.ajax;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!DataTablesLib) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
'DataTables library not set. See https://datatables.net/tn/19 for details.'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Create the DataTable!
|
|
108
|
+
dt.value = new DataTablesLib(unref(table), options);
|
|
109
|
+
|
|
110
|
+
// Re-export all DataTables events by listening for them using DataTable's
|
|
111
|
+
// `on` method and then emit them to our Vue component
|
|
112
|
+
for (let eName of dtEvents) {
|
|
113
|
+
if (dt.value && inst) {
|
|
114
|
+
dt.value.on(eName, (event) => {
|
|
115
|
+
inst.emit(eName, { event: event, dt: dt });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
55
120
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
beforeUnmount() {
|
|
59
|
-
this._dt.destroy(true);
|
|
60
|
-
},
|
|
61
|
-
props: {
|
|
62
|
-
ajax: null,
|
|
63
|
-
class: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: '',
|
|
66
|
-
},
|
|
67
|
-
columns: {
|
|
68
|
-
type: Array,
|
|
69
|
-
default: null,
|
|
70
|
-
},
|
|
71
|
-
data: {
|
|
72
|
-
type: Array,
|
|
73
|
-
default: null,
|
|
74
|
-
},
|
|
75
|
-
options: {
|
|
76
|
-
default: {}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
watch: {
|
|
80
|
-
data: {
|
|
81
|
-
handler(newVal) {
|
|
82
|
-
let known = this._dt.data().toArray();
|
|
83
|
-
|
|
84
|
-
// Find any new rows
|
|
85
|
-
for (let n of newVal) {
|
|
86
|
-
if (! known.includes(n)) {
|
|
87
|
-
this._dt.row.add(n);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Remove any old rows
|
|
92
|
-
for (let k of known) {
|
|
93
|
-
if (! newVal.includes(k)) {
|
|
94
|
-
this._dt.row((_idx: any, d: any) => d === k).remove();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Data in other rows might have changes, so we need to invalidate the rows
|
|
99
|
-
this._dt.rows().invalidate().draw(false);
|
|
100
|
-
|
|
101
|
-
this.saveOld(newVal);
|
|
102
|
-
},
|
|
103
|
-
deep: true
|
|
104
|
-
}
|
|
105
|
-
}
|
|
121
|
+
onBeforeUnmount(() => {
|
|
122
|
+
dt.value?.destroy(true);
|
|
106
123
|
});
|
|
107
124
|
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
// methods
|
|
126
|
+
function saveOld(d: any) {
|
|
127
|
+
oldData.value = d.value ? d.value.slice() : d.slice();
|
|
111
128
|
}
|
|
112
129
|
|
|
113
|
-
|
|
130
|
+
// expose
|
|
131
|
+
defineExpose({
|
|
132
|
+
/**
|
|
133
|
+
* DataTable instance
|
|
134
|
+
*/
|
|
135
|
+
dt,
|
|
136
|
+
});
|
|
114
137
|
|
|
115
138
|
</script>
|
|
116
139
|
|
|
117
140
|
<template>
|
|
118
141
|
<div class="datatable" v-once>
|
|
119
|
-
<table
|
|
142
|
+
<table ref="table" v-bind="$attrs" style="width:100%">
|
|
120
143
|
<slot></slot>
|
|
121
144
|
</table>
|
|
122
145
|
</div>
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { defineComponent, setBlockTracking, createElementVNode, normalizeClass, renderSlot } from 'vue';
|
|
2
|
-
|
|
3
|
-
var DataTablesLib;
|
|
4
|
-
const Comp = defineComponent({
|
|
5
|
-
name: 'DataTable',
|
|
6
|
-
expose: ['dt'],
|
|
7
|
-
|
|
8
|
-
data() {
|
|
9
|
-
return {
|
|
10
|
-
_dt: null,
|
|
11
|
-
oldData: []
|
|
12
|
-
};
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
computed: {},
|
|
16
|
-
methods: {
|
|
17
|
-
dt() {
|
|
18
|
-
return this._dt;
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
saveOld(d) {
|
|
22
|
-
this.oldData = d.value ? d.value.slice() : d.slice();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
mounted() {
|
|
28
|
-
// Component shown so we can initialise DataTables of the table now
|
|
29
|
-
let table = this.$el.querySelector('table');
|
|
30
|
-
let options = this.options;
|
|
31
|
-
|
|
32
|
-
if (this.data) {
|
|
33
|
-
options.data = this.data;
|
|
34
|
-
this.saveOld(options.data);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (this.columns) {
|
|
38
|
-
options.columns = this.columns;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (this.ajax) {
|
|
42
|
-
options.ajax = this.ajax;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!DataTablesLib) {
|
|
46
|
-
throw new Error('DataTables library not set. See https://datatables.net/tn/19 for details.');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this._dt = new DataTablesLib(table, options);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
beforeUnmount() {
|
|
53
|
-
this._dt.destroy(true);
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
props: {
|
|
57
|
-
ajax: null,
|
|
58
|
-
class: {
|
|
59
|
-
type: String,
|
|
60
|
-
default: ''
|
|
61
|
-
},
|
|
62
|
-
columns: {
|
|
63
|
-
type: Array,
|
|
64
|
-
default: null
|
|
65
|
-
},
|
|
66
|
-
data: {
|
|
67
|
-
type: Array,
|
|
68
|
-
default: null
|
|
69
|
-
},
|
|
70
|
-
options: {
|
|
71
|
-
default: {}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
watch: {
|
|
75
|
-
data: {
|
|
76
|
-
handler(newVal) {
|
|
77
|
-
let known = this._dt.data().toArray(); // Find any new rows
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
for (let n of newVal) {
|
|
81
|
-
if (!known.includes(n)) {
|
|
82
|
-
this._dt.row.add(n);
|
|
83
|
-
}
|
|
84
|
-
} // Remove any old rows
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
for (let k of known) {
|
|
88
|
-
if (!newVal.includes(k)) {
|
|
89
|
-
this._dt.row((_idx, d) => d === k).remove();
|
|
90
|
-
}
|
|
91
|
-
} // Data in other rows might have changes, so we need to invalidate the rows
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this._dt.rows().invalidate().draw(false);
|
|
95
|
-
|
|
96
|
-
this.saveOld(newVal);
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
deep: true
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}); // Expose a static method that can be used to add extensions
|
|
103
|
-
|
|
104
|
-
Comp.use = function (lib) {
|
|
105
|
-
DataTablesLib = lib;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
var script = Comp;
|
|
109
|
-
|
|
110
|
-
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
111
|
-
return _cache[0] || (setBlockTracking(-1), _cache[0] = createElementVNode("div", {
|
|
112
|
-
class: "datatable"
|
|
113
|
-
}, [createElementVNode("table", {
|
|
114
|
-
class: normalizeClass(_ctx.class)
|
|
115
|
-
}, [renderSlot(_ctx.$slots, "default")], 2)]), setBlockTracking(1), _cache[0]);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
script.render = render;
|
|
119
|
-
|
|
120
|
-
// Import vue component
|
|
121
|
-
// IIFE injects install function into component, allowing component
|
|
122
|
-
// to be registered via Vue.use() as well as Vue.component(),
|
|
123
|
-
|
|
124
|
-
var entry_esm = /*#__PURE__*/(() => {
|
|
125
|
-
// Assign InstallableComponent type
|
|
126
|
-
const installable = script; // Attach install function executed by Vue.use()
|
|
127
|
-
|
|
128
|
-
installable.install = app => {
|
|
129
|
-
app.component('Datatables.netVue', installable);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
return installable;
|
|
133
|
-
})(); // It's possible to expose named exports when writing components that can
|
|
134
|
-
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
|
|
135
|
-
// export const RollupDemoDirective = directive;
|
|
136
|
-
|
|
137
|
-
export { entry_esm as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
this.Datatables=this.Datatables||{},this.Datatables.netVue=function(t){"use strict";function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,a,o=[],l=!0,i=!1;try{for(n=n.call(t);!(l=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);l=!0);}catch(t){i=!0,a=t}finally{try{l||null==n.return||n.return()}finally{if(i)throw a}}return o}(t,e)||n(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function a(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var a=0,o=function(){};return{s:o,n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,i=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){u=!0,l=t},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw l}}}}var o,l=t.defineComponent({name:"DataTable",expose:["dt"],data:function(){return{_dt:null,oldData:[]}},computed:{},methods:{dt:function(){return this._dt},saveOld:function(t){this.oldData=t.value?t.value.slice():t.slice()}},mounted:function(){var t=this.$el.querySelector("table"),e=this.options;if(this.data&&(e.data=this.data,this.saveOld(e.data)),this.columns&&(e.columns=this.columns),this.ajax&&(e.ajax=this.ajax),!o)throw new Error("DataTables library not set. See https://datatables.net/tn/19 for details.");this._dt=new o(t,e)},beforeUnmount:function(){this._dt.destroy(!0)},props:{ajax:null,class:{type:String,default:""},columns:{type:Array,default:null},data:{type:Array,default:null},options:{default:{}}},watch:{data:{handler:function(t){var e,n=this,r=this._dt.data().toArray(),o=a(t);try{for(o.s();!(e=o.n()).done;){var l=e.value;r.includes(l)||this._dt.row.add(l)}}catch(t){o.e(t)}finally{o.f()}var i,u=a(r);try{var s=function(){var e=i.value;t.includes(e)||n._dt.row((function(t,n){return n===e})).remove()};for(u.s();!(i=u.n()).done;)s()}catch(t){u.e(t)}finally{u.f()}this._dt.rows().invalidate().draw(!1),this.saveOld(t)},deep:!0}}});l.use=function(t){o=t};var i=l;i.render=function(e,n,r,a,o,l){return n[0]||(t.setBlockTracking(-1),n[0]=t.createElementVNode("div",{class:"datatable"},[t.createElementVNode("table",{class:t.normalizeClass(e.class)},[t.renderSlot(e.$slots,"default")],2)]),t.setBlockTracking(1),n[0])};var u=function(){var t=i;return t.install=function(e){e.component("Datatables.netVue",t)},t}(),s=Object.freeze({__proto__:null,default:u});return Object.entries(s).forEach((function(t){var n=e(t,2),r=n[0],a=n[1];"default"!==r&&(u[r]=a)})),u}(Vue);
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
'use strict';var vue=require('vue');function _slicedToArray(arr, i) {
|
|
2
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function _arrayWithHoles(arr) {
|
|
6
|
-
if (Array.isArray(arr)) return arr;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) {
|
|
10
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
-
|
|
12
|
-
if (_i == null) return;
|
|
13
|
-
var _arr = [];
|
|
14
|
-
var _n = true;
|
|
15
|
-
var _d = false;
|
|
16
|
-
|
|
17
|
-
var _s, _e;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
21
|
-
_arr.push(_s.value);
|
|
22
|
-
|
|
23
|
-
if (i && _arr.length === i) break;
|
|
24
|
-
}
|
|
25
|
-
} catch (err) {
|
|
26
|
-
_d = true;
|
|
27
|
-
_e = err;
|
|
28
|
-
} finally {
|
|
29
|
-
try {
|
|
30
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
31
|
-
} finally {
|
|
32
|
-
if (_d) throw _e;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return _arr;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
40
|
-
if (!o) return;
|
|
41
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
42
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
45
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _arrayLikeToArray(arr, len) {
|
|
49
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
50
|
-
|
|
51
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
52
|
-
|
|
53
|
-
return arr2;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _nonIterableRest() {
|
|
57
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
61
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
62
|
-
|
|
63
|
-
if (!it) {
|
|
64
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
65
|
-
if (it) o = it;
|
|
66
|
-
var i = 0;
|
|
67
|
-
|
|
68
|
-
var F = function () {};
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
s: F,
|
|
72
|
-
n: function () {
|
|
73
|
-
if (i >= o.length) return {
|
|
74
|
-
done: true
|
|
75
|
-
};
|
|
76
|
-
return {
|
|
77
|
-
done: false,
|
|
78
|
-
value: o[i++]
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
e: function (e) {
|
|
82
|
-
throw e;
|
|
83
|
-
},
|
|
84
|
-
f: F
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var normalCompletion = true,
|
|
92
|
-
didErr = false,
|
|
93
|
-
err;
|
|
94
|
-
return {
|
|
95
|
-
s: function () {
|
|
96
|
-
it = it.call(o);
|
|
97
|
-
},
|
|
98
|
-
n: function () {
|
|
99
|
-
var step = it.next();
|
|
100
|
-
normalCompletion = step.done;
|
|
101
|
-
return step;
|
|
102
|
-
},
|
|
103
|
-
e: function (e) {
|
|
104
|
-
didErr = true;
|
|
105
|
-
err = e;
|
|
106
|
-
},
|
|
107
|
-
f: function () {
|
|
108
|
-
try {
|
|
109
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
110
|
-
} finally {
|
|
111
|
-
if (didErr) throw err;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}var DataTablesLib;
|
|
116
|
-
var Comp = vue.defineComponent({
|
|
117
|
-
name: 'DataTable',
|
|
118
|
-
expose: ['dt'],
|
|
119
|
-
data: function data() {
|
|
120
|
-
return {
|
|
121
|
-
_dt: null,
|
|
122
|
-
oldData: []
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
computed: {},
|
|
126
|
-
methods: {
|
|
127
|
-
dt: function dt() {
|
|
128
|
-
return this._dt;
|
|
129
|
-
},
|
|
130
|
-
saveOld: function saveOld(d) {
|
|
131
|
-
this.oldData = d.value ? d.value.slice() : d.slice();
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
mounted: function mounted() {
|
|
135
|
-
// Component shown so we can initialise DataTables of the table now
|
|
136
|
-
var table = this.$el.querySelector('table');
|
|
137
|
-
var options = this.options;
|
|
138
|
-
|
|
139
|
-
if (this.data) {
|
|
140
|
-
options.data = this.data;
|
|
141
|
-
this.saveOld(options.data);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (this.columns) {
|
|
145
|
-
options.columns = this.columns;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (this.ajax) {
|
|
149
|
-
options.ajax = this.ajax;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (!DataTablesLib) {
|
|
153
|
-
throw new Error('DataTables library not set. See https://datatables.net/tn/19 for details.');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
this._dt = new DataTablesLib(table, options);
|
|
157
|
-
},
|
|
158
|
-
beforeUnmount: function beforeUnmount() {
|
|
159
|
-
this._dt.destroy(true);
|
|
160
|
-
},
|
|
161
|
-
props: {
|
|
162
|
-
ajax: null,
|
|
163
|
-
class: {
|
|
164
|
-
type: String,
|
|
165
|
-
default: ''
|
|
166
|
-
},
|
|
167
|
-
columns: {
|
|
168
|
-
type: Array,
|
|
169
|
-
default: null
|
|
170
|
-
},
|
|
171
|
-
data: {
|
|
172
|
-
type: Array,
|
|
173
|
-
default: null
|
|
174
|
-
},
|
|
175
|
-
options: {
|
|
176
|
-
default: {}
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
watch: {
|
|
180
|
-
data: {
|
|
181
|
-
handler: function handler(newVal) {
|
|
182
|
-
var _this = this;
|
|
183
|
-
|
|
184
|
-
var known = this._dt.data().toArray(); // Find any new rows
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var _iterator = _createForOfIteratorHelper(newVal),
|
|
188
|
-
_step;
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
192
|
-
var n = _step.value;
|
|
193
|
-
|
|
194
|
-
if (!known.includes(n)) {
|
|
195
|
-
this._dt.row.add(n);
|
|
196
|
-
}
|
|
197
|
-
} // Remove any old rows
|
|
198
|
-
|
|
199
|
-
} catch (err) {
|
|
200
|
-
_iterator.e(err);
|
|
201
|
-
} finally {
|
|
202
|
-
_iterator.f();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
var _iterator2 = _createForOfIteratorHelper(known),
|
|
206
|
-
_step2;
|
|
207
|
-
|
|
208
|
-
try {
|
|
209
|
-
var _loop = function _loop() {
|
|
210
|
-
var k = _step2.value;
|
|
211
|
-
|
|
212
|
-
if (!newVal.includes(k)) {
|
|
213
|
-
_this._dt.row(function (_idx, d) {
|
|
214
|
-
return d === k;
|
|
215
|
-
}).remove();
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
220
|
-
_loop();
|
|
221
|
-
} // Data in other rows might have changes, so we need to invalidate the rows
|
|
222
|
-
|
|
223
|
-
} catch (err) {
|
|
224
|
-
_iterator2.e(err);
|
|
225
|
-
} finally {
|
|
226
|
-
_iterator2.f();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
this._dt.rows().invalidate().draw(false);
|
|
230
|
-
|
|
231
|
-
this.saveOld(newVal);
|
|
232
|
-
},
|
|
233
|
-
deep: true
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}); // Expose a static method that can be used to add extensions
|
|
237
|
-
|
|
238
|
-
Comp.use = function (lib) {
|
|
239
|
-
DataTablesLib = lib;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
var script = Comp;function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
243
|
-
return _cache[0] || (vue.setBlockTracking(-1), _cache[0] = vue.createElementVNode("div", {
|
|
244
|
-
class: "datatable"
|
|
245
|
-
}, [vue.createElementVNode("table", {
|
|
246
|
-
class: vue.normalizeClass(_ctx.class)
|
|
247
|
-
}, [vue.renderSlot(_ctx.$slots, "default")], 2)]), vue.setBlockTracking(1), _cache[0]);
|
|
248
|
-
}script.render = render;// Import vue component
|
|
249
|
-
|
|
250
|
-
// Default export is installable instance of component.
|
|
251
|
-
// IIFE injects install function into component, allowing component
|
|
252
|
-
// to be registered via Vue.use() as well as Vue.component(),
|
|
253
|
-
var component = /*#__PURE__*/(function () {
|
|
254
|
-
// Assign InstallableComponent type
|
|
255
|
-
var installable = script; // Attach install function executed by Vue.use()
|
|
256
|
-
|
|
257
|
-
installable.install = function (app) {
|
|
258
|
-
app.component('Datatables.netVue', installable);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
return installable;
|
|
262
|
-
})(); // It's possible to expose named exports when writing components that can
|
|
263
|
-
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
|
|
264
|
-
// export const RollupDemoDirective = directive;
|
|
265
|
-
var namedExports=/*#__PURE__*/Object.freeze({__proto__:null,'default':component});// only expose one global var, with named exports exposed as properties of
|
|
266
|
-
// that global var (eg. plugin.namedExport)
|
|
267
|
-
|
|
268
|
-
Object.entries(namedExports).forEach(function (_ref) {
|
|
269
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
270
|
-
exportName = _ref2[0],
|
|
271
|
-
exported = _ref2[1];
|
|
272
|
-
|
|
273
|
-
if (exportName !== 'default') component[exportName] = exported;
|
|
274
|
-
});module.exports=component;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export interface IData {
|
|
2
|
-
_dt: null | any;
|
|
3
|
-
oldData: Array<any>;
|
|
4
|
-
}
|
|
5
|
-
declare const Comp: import("vue").DefineComponent<{
|
|
6
|
-
ajax: null;
|
|
7
|
-
class: {
|
|
8
|
-
type: StringConstructor;
|
|
9
|
-
default: string;
|
|
10
|
-
};
|
|
11
|
-
columns: {
|
|
12
|
-
type: ArrayConstructor;
|
|
13
|
-
default: null;
|
|
14
|
-
};
|
|
15
|
-
data: {
|
|
16
|
-
type: ArrayConstructor;
|
|
17
|
-
default: null;
|
|
18
|
-
};
|
|
19
|
-
options: {
|
|
20
|
-
default: {};
|
|
21
|
-
};
|
|
22
|
-
}, unknown, IData, {}, {
|
|
23
|
-
dt(): any;
|
|
24
|
-
saveOld(d: any): void;
|
|
25
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
26
|
-
ajax: null;
|
|
27
|
-
class: {
|
|
28
|
-
type: StringConstructor;
|
|
29
|
-
default: string;
|
|
30
|
-
};
|
|
31
|
-
columns: {
|
|
32
|
-
type: ArrayConstructor;
|
|
33
|
-
default: null;
|
|
34
|
-
};
|
|
35
|
-
data: {
|
|
36
|
-
type: ArrayConstructor;
|
|
37
|
-
default: null;
|
|
38
|
-
};
|
|
39
|
-
options: {
|
|
40
|
-
default: {};
|
|
41
|
-
};
|
|
42
|
-
}>>, {
|
|
43
|
-
data: unknown[];
|
|
44
|
-
class: string;
|
|
45
|
-
columns: unknown[];
|
|
46
|
-
options: {};
|
|
47
|
-
}>;
|
|
48
|
-
export default Comp;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vue';
|
|
2
|
-
import component from "./datatables.net-vue.vue";
|
|
3
|
-
declare type InstallableComponent = typeof component & {
|
|
4
|
-
install: Exclude<Plugin['install'], undefined>;
|
|
5
|
-
};
|
|
6
|
-
declare const _default: InstallableComponent;
|
|
7
|
-
export default _default;
|