@semi-kit/hooks 1.0.2 → 1.0.5
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/lib/index.mjs +1 -0
- package/{dist → lib}/sortable.d.mts +0 -3
- package/lib/sortable.mjs +1 -0
- package/package.json +2 -2
- package/dist/index.mjs +0 -3
- package/dist/sortable.mjs +0 -25
- /package/{dist → lib}/index.d.mts +0 -0
package/lib/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSortable}from"./sortable.mjs";export{useSortable};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import Sortable from "sortablejs";
|
|
2
|
-
|
|
3
|
-
//#region src/sortable.d.ts
|
|
4
2
|
declare const useSortable: (id: string, options?: Sortable.Options) => {
|
|
5
3
|
instance: null;
|
|
6
4
|
initSortable: () => void;
|
|
7
5
|
getInstance: () => Sortable | null;
|
|
8
6
|
destroy: () => null;
|
|
9
7
|
};
|
|
10
|
-
//#endregion
|
|
11
8
|
export { useSortable };
|
package/lib/sortable.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Sortable from"sortablejs";const useSortable=(t,n)=>{let r=null;return{instance:r,initSortable:()=>{let i=document.getElementById(t);i&&(r=Sortable.create(i,{animation:500,...n}))},getInstance:()=>r,destroy:()=>r&&=(r?.destroy(),null)}};export{useSortable};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semi-kit/hooks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Commonly used Hooks collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "lijiaheng <jahnli@163.com>",
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
9
|
+
"lib"
|
|
10
10
|
],
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
package/dist/index.mjs
DELETED
package/dist/sortable.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Sortable from "sortablejs";
|
|
2
|
-
|
|
3
|
-
//#region src/sortable.ts
|
|
4
|
-
const useSortable = (id, options) => {
|
|
5
|
-
let instance = null;
|
|
6
|
-
const getInstance = () => instance;
|
|
7
|
-
const initSortable = () => {
|
|
8
|
-
const el = document.getElementById(id);
|
|
9
|
-
if (!el) return;
|
|
10
|
-
instance = Sortable.create(el, {
|
|
11
|
-
animation: 500,
|
|
12
|
-
...options
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
const destroy = () => instance && (instance?.destroy(), instance = null);
|
|
16
|
-
return {
|
|
17
|
-
instance,
|
|
18
|
-
initSortable,
|
|
19
|
-
getInstance,
|
|
20
|
-
destroy
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { useSortable };
|
|
File without changes
|