@semi-kit/hooks 0.0.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 ADDED
@@ -0,0 +1,23 @@
1
+ # tsdown-starter
2
+
3
+ A starter for creating a TypeScript package.
4
+
5
+ ## Development
6
+
7
+ - Install dependencies:
8
+
9
+ ```bash
10
+ npm install
11
+ ```
12
+
13
+ - Run the unit tests:
14
+
15
+ ```bash
16
+ npm run test
17
+ ```
18
+
19
+ - Build the library:
20
+
21
+ ```bash
22
+ npm run build
23
+ ```
@@ -0,0 +1,2 @@
1
+ import { useSortable } from "./sortable.mjs";
2
+ export { useSortable };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { useSortable } from "./sortable.mjs";
2
+
3
+ export { useSortable };
@@ -0,0 +1,11 @@
1
+ import Sortable from "sortablejs";
2
+
3
+ //#region src/sortable.d.ts
4
+ declare const useSortable: (id: string, options?: Sortable.Options) => {
5
+ instance: null;
6
+ initSortable: () => void;
7
+ getInstance: () => Sortable | null;
8
+ destroy: () => null;
9
+ };
10
+ //#endregion
11
+ export { useSortable };
@@ -0,0 +1,25 @@
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 };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@semi-kit/hooks",
3
+ "version": "0.0.1",
4
+ "description": "Commonly used Hooks collection",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "lijiaheng <jahnli@163.com>",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "main": "./dist/index.mjs",
15
+ "module": "./dist/index.mjs",
16
+ "types": "./dist/index.d.mts",
17
+ "exports": {
18
+ ".": "./dist/index.mjs",
19
+ "./sortable": "./dist/sortable.mjs",
20
+ "./package.json": "./package.json"
21
+ },
22
+ "scripts": {
23
+ "build": "tsdown",
24
+ "dev": "tsdown --watch",
25
+ "typecheck": "tsc --noEmit",
26
+ "prepublishOnly": "pnpm run build",
27
+ "release": "npm publish"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^24.10.1",
31
+ "bumpp": "^10.3.1",
32
+ "tsdown": "^0.16.4",
33
+ "typescript": "^5.9.3",
34
+ "@types/sortablejs": "^1.15.9",
35
+ "sortablejs": "^1.15.6"
36
+ },
37
+ "peerDependencies": {
38
+ "sortablejs": "*",
39
+ "@types/sortablejs": "*"
40
+ }
41
+ }