Skip to content

Commit 83cef56

Browse files
wip
1 parent fae4944 commit 83cef56

13 files changed

+180
-55
lines changed

package-lock.json

Lines changed: 91 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "draggable component for vue",
55
"license": "MIT",
66
"main": "dist/vuedraggable.umd.min.js",
7-
"types": "src/vuedraggable.d.ts",
7+
"types": "types/vuedraggable.d.ts",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/SortableJS/Vue.Draggable.git"
@@ -15,9 +15,10 @@
1515
"build:doc": "vue-cli-service build ./example/main.js --dest docs --mode development",
1616
"build": "vue-cli-service build --name vuedraggable --entry ./src/vuedraggable.js --target lib",
1717
"lint": "vue-cli-service lint src example",
18-
"prepublishOnly": "npm run lint && npm run test:unit && npm run build:doc && npm run build",
18+
"prepublishOnly": "npm run lint && npm run test:unit && npm run build:doc && npm run build:type && npm run build",
1919
"test:unit": "vue-cli-service test:unit --coverage",
20-
"test:coverage": "vue-cli-service test:unit --coverage --verbose && codecov"
20+
"test:coverage": "vue-cli-service test:unit --coverage --verbose && codecov",
21+
"build:type": "tsc"
2122
},
2223
"keywords": [
2324
"vue",
@@ -37,6 +38,7 @@
3738
"vue": "^3.0.1"
3839
},
3940
"devDependencies": {
41+
"@types/sortablejs": "^1.10.7",
4042
"@vue/cli-plugin-babel": "~4.5.0",
4143
"@vue/cli-plugin-eslint": "~4.5.0",
4244
"@vue/cli-plugin-unit-jest": "^4.5.4",
@@ -57,7 +59,7 @@
5759
"font-awesome": "^4.7.0",
5860
"jquery": "^3.5.1",
5961
"popper.js": "^1.16.1",
60-
"typescript": "^4.0.3",
62+
"typescript": "^4.3.5",
6163
"vue": "^3.0.1",
6264
"vue-jest": "^5.0.0-alpha.5",
6365
"vue-router": "^4.0.0-beta.13",
@@ -91,6 +93,7 @@
9193
"dist/*.css",
9294
"dist/*.map",
9395
"dist/*.js",
96+
"types/*",
9497
"src/*"
9598
],
9699
"module": "dist/vuedraggable.umd.js"

src/vuedraggable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ const draggableComponent = defineComponent({
199199
},
200200

201201
spliceList() {
202+
// @ts-ignore
202203
const spliceList = list => list.splice(...arguments);
203204
this.alterList(spliceList);
204205
},
@@ -243,6 +244,7 @@ const draggableComponent = defineComponent({
243244
}
244245
removeNode(evt.item);
245246
const newIndex = this.getVmIndexFromDomIndex(evt.newIndex);
247+
// @ts-ignore
246248
this.spliceList(newIndex, 0, element);
247249
const added = { element, newIndex };
248250
this.emitChanges({ added });
@@ -255,6 +257,7 @@ const draggableComponent = defineComponent({
255257
return;
256258
}
257259
const { index: oldIndex, element } = this.context;
260+
// @ts-ignore
258261
this.spliceList(oldIndex, 1);
259262
const removed = { element, oldIndex };
260263
this.emitChanges({ removed });

tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2016",
4+
"lib":["esnext", "DOM"],
5+
"moduleResolution": "node",
6+
"allowJs": true,
7+
"checkJs": true,
8+
"emitDeclarationOnly": true,
9+
"downlevelIteration": true,
10+
"esModuleInterop": true,
11+
"outDir": "./types",
12+
"declaration": true
13+
},
14+
"files": [
15+
"./src/vuedraggable.js"
16+
]
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function getComponentAttributes({ $attrs, componentData }: {
2+
$attrs: any;
3+
componentData?: {};
4+
}): any;
5+
export function createSortableOption({ $attrs, callBackBuilder }: {
6+
$attrs: any;
7+
callBackBuilder: any;
8+
}): any;
9+
export function getValidSortableEntries(value: any): any[][];

types/core/componentStructure.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export class ComponentStructure {
2+
constructor({ nodes: { header, default: defaultNodes, footer }, root, realList }: {
3+
nodes: {
4+
header: any;
5+
default: any;
6+
footer: any;
7+
};
8+
root: any;
9+
realList: any;
10+
});
11+
defaultNodes: any;
12+
children: any[];
13+
externalComponent: any;
14+
rootTransition: any;
15+
tag: any;
16+
realList: any;
17+
get _isRootComponent(): any;
18+
render(h: any, attributes: any): any;
19+
updated(): void;
20+
getUnderlyingVm(domElement: any): any;
21+
getVmIndexFromDomIndex(domIndex: any, element: any): any;
22+
}

types/core/renderHelper.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function computeComponentStructure({ $slots, tag, realList, getKey }: {
2+
$slots: any;
3+
tag: any;
4+
realList: any;
5+
getKey: any;
6+
}): ComponentStructure;
7+
import { ComponentStructure } from "./componentStructure";

types/core/sortableEvents.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export namespace events {
2+
export { manage };
3+
export { manageAndEmit };
4+
export { emit };
5+
}
6+
export function isReadOnly(eventName: any): boolean;
7+
declare const manage: string[];
8+
declare const manageAndEmit: string[];
9+
declare const emit: string[];
10+
export {};

types/util/console.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const console: Console;

types/util/htmlHelper.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export function insertNodeAt(fatherNode: any, node: any, position: any): void;
2+
export function removeNode(node: any): void;

0 commit comments

Comments
 (0)