@semi-kit/hooks 1.0.3 → 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 -3
- package/lib/sortable.d.mts +0 -3
- package/lib/sortable.mjs +1 -25
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
package/lib/sortable.d.mts
CHANGED
|
@@ -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
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
import Sortable from
|
|
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 };
|
|
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};
|