@semi-kit/hooks 1.0.3 → 1.0.6

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 CHANGED
@@ -1,3 +1 @@
1
- import { useSortable } from "./sortable.mjs";
2
-
3
- export { useSortable };
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 CHANGED
@@ -1,25 +1 @@
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 };
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@semi-kit/hooks",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "Commonly used Hooks collection",
5
5
  "type": "module",
6
6
  "license": "MIT",