@machinerd/js-module 0.8.1 → 0.10.0
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/dist/api-client-B-kwZogn.mjs +1 -0
- package/dist/api-client-BH5tW3p8.cjs +1 -0
- package/dist/common-BQEGjmFn.cjs +1 -0
- package/dist/{common-Df03Ovdm.mjs → common-CCtD91nO.mjs} +1 -1
- package/dist/{common-Bn0Ko6B7.cjs → common-D4sUwkFd.cjs} +1 -1
- package/dist/common-L3y7_eAy.mjs +1 -0
- package/dist/hooks/common/index.cjs +1 -0
- package/dist/hooks/common/index.d.cts +71 -0
- package/dist/hooks/common/index.d.mts +71 -0
- package/dist/hooks/common/index.mjs +1 -0
- package/dist/hooks/use-snackbar.cjs +1 -0
- package/dist/hooks/use-snackbar.d.cts +10 -0
- package/dist/hooks/use-snackbar.d.mts +10 -0
- package/dist/hooks/use-snackbar.mjs +1 -0
- package/dist/{index-B3fFA21M.d.mts → index-CFOJBfVt.d.mts} +4 -0
- package/dist/{index-CeiAF-WU.d.cts → index-ChiDX5zW.d.cts} +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/providers/api-client/index.cjs +1 -0
- package/dist/providers/{index.d.cts → api-client/index.d.cts} +3 -3
- package/dist/providers/{index.d.mts → api-client/index.d.mts} +1 -1
- package/dist/providers/api-client/index.mjs +1 -0
- package/dist/providers/noti-stack/index.cjs +1 -0
- package/dist/providers/noti-stack/index.d.cts +11 -0
- package/dist/providers/noti-stack/index.d.mts +11 -0
- package/dist/providers/noti-stack/index.mjs +1 -0
- package/dist/{skeleton-DtV9S1QK.cjs → skeleton-BCdxpynL.cjs} +1 -1
- package/dist/{skeleton-B6_oBhkl.mjs → skeleton-azZrk5-3.mjs} +1 -1
- package/dist/src-6KfzqI9Z.cjs +1 -0
- package/dist/src-Ce2i3Lkj.mjs +1 -0
- package/dist/styles/index.css +120 -0
- package/dist/ui/carousel/index.cjs +1 -1
- package/dist/ui/carousel/index.d.cts +9 -9
- package/dist/ui/carousel/index.d.mts +9 -9
- package/dist/ui/carousel/index.mjs +1 -1
- package/dist/ui/dialog/index.cjs +1 -1
- package/dist/ui/dialog/index.d.cts +2 -2
- package/dist/ui/dialog/index.d.mts +4 -4
- package/dist/ui/dialog/index.mjs +1 -1
- package/dist/ui/dnd/index.cjs +1 -0
- package/dist/ui/dnd/index.d.cts +17 -0
- package/dist/ui/dnd/index.d.mts +17 -0
- package/dist/ui/dnd/index.mjs +1 -0
- package/dist/ui/image/index.cjs +1 -1
- package/dist/ui/image/index.d.cts +8 -8
- package/dist/ui/image/index.d.mts +6 -6
- package/dist/ui/image/index.mjs +1 -1
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.d.cts +19 -19
- package/dist/ui/index.d.mts +23 -23
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/motion-dialog/index.cjs +1 -0
- package/dist/ui/motion-dialog/index.d.cts +34 -0
- package/dist/ui/motion-dialog/index.d.mts +34 -0
- package/dist/ui/motion-dialog/index.mjs +1 -0
- package/dist/ui/sheet/index.cjs +1 -1
- package/dist/ui/sheet/index.d.cts +2 -2
- package/dist/ui/sheet/index.d.mts +2 -2
- package/dist/ui/sheet/index.mjs +1 -1
- package/dist/ui/switch/index.cjs +1 -0
- package/dist/ui/switch/index.d.cts +16 -0
- package/dist/ui/switch/index.d.mts +16 -0
- package/dist/ui/switch/index.mjs +1 -0
- package/dist/ui/tooltip/index.cjs +1 -1
- package/dist/ui/tooltip/index.d.cts +2 -2
- package/dist/ui/tooltip/index.mjs +1 -1
- package/dist/use-dialog-stack-DmBRPhe2.cjs +1 -0
- package/dist/use-dialog-stack-STwnhvBB.mjs +1 -0
- package/dist/use-subset-image-CTy5mCLo.cjs +1 -0
- package/dist/use-subset-image-Ck1Gk5Qk.d.mts +601 -0
- package/dist/use-subset-image-LQWsE5P4.mjs +1 -0
- package/dist/use-subset-image-oZAiC9VK.d.cts +601 -0
- package/dist/util/common.cjs +1 -1
- package/dist/util/common.d.cts +8 -1
- package/dist/util/common.d.mts +8 -1
- package/dist/util/common.mjs +1 -1
- package/dist/util/fetcher.cjs +1 -0
- package/dist/util/fetcher.d.cts +15 -0
- package/dist/util/fetcher.d.mts +15 -0
- package/dist/util/fetcher.mjs +1 -0
- package/dist/util/file.mjs +1 -1
- package/package.json +66 -33
- package/dist/hooks/index.cjs +0 -1
- package/dist/hooks/index.d.cts +0 -2
- package/dist/hooks/index.d.mts +0 -2
- package/dist/hooks/index.mjs +0 -1
- package/dist/hooks-CUj2xuzU.cjs +0 -1
- package/dist/hooks-gbU5dqVF.mjs +0 -1
- package/dist/index-BFHrNSKP.d.mts +0 -655
- package/dist/index-DiRj3rRA.d.cts +0 -655
- package/dist/providers/index.cjs +0 -1
- package/dist/providers/index.mjs +0 -1
- package/dist/providers-CkXkdYcB.cjs +0 -1
- package/dist/providers-zftmvT1z.mjs +0 -1
- package/dist/src-CjpmdVyv.cjs +0 -1
- package/dist/src-CukOR3K2.mjs +0 -1
- package/dist/use-subset-image-D8ssrZhj.mjs +0 -1
- package/dist/use-subset-image-DC86cg6O.cjs +0 -1
- /package/dist/{file-DShNxIW4.mjs → file-CjW1pMb_.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t,n)=>async r=>(await e({input:{filter:{...n?.filter,...r.filter},page:n?.page||r.page||1,pageSize:n?.pageSize||r.pageSize||10,sort:n?.sort||r.sort||[]}}))[t];exports.createSdkFetcher=e;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/util/fetcher.d.ts
|
|
2
|
+
interface BaseInput<Filter extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
filter?: Filter;
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
sort?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare const createSdkFetcher: <TQuery extends Record<string, {
|
|
9
|
+
total: number;
|
|
10
|
+
list: any[];
|
|
11
|
+
}>, TKey extends keyof TQuery, TInput extends BaseInput = BaseInput>(func: (variables: {
|
|
12
|
+
input: TInput;
|
|
13
|
+
}) => Promise<TQuery>, key: TKey, customInput?: Partial<TInput>) => (input: TInput) => Promise<TQuery[TKey]>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BaseInput, createSdkFetcher };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/util/fetcher.d.ts
|
|
2
|
+
interface BaseInput<Filter extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
filter?: Filter;
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
sort?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare const createSdkFetcher: <TQuery extends Record<string, {
|
|
9
|
+
total: number;
|
|
10
|
+
list: any[];
|
|
11
|
+
}>, TKey extends keyof TQuery, TInput extends BaseInput = BaseInput>(func: (variables: {
|
|
12
|
+
input: TInput;
|
|
13
|
+
}) => Promise<TQuery>, key: TKey, customInput?: Partial<TInput>) => (input: TInput) => Promise<TQuery[TKey]>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BaseInput, createSdkFetcher };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t,n)=>async r=>(await e({input:{filter:{...n?.filter,...r.filter},page:n?.page||r.page||1,pageSize:n?.pageSize||r.pageSize||10,sort:n?.sort||r.sort||[]}}))[t];export{e as createSdkFetcher};
|
package/dist/util/file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"../file-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"../file-CjW1pMb_.mjs";export{a as formatBytes,n as getFileExtension,i as getFilename,t as isExternalSrc,e as isSrcSetCompatible,r as parsePath};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machinerd/js-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"import": "./dist/util/date.mjs",
|
|
29
29
|
"require": "./dist/util/date.cjs"
|
|
30
30
|
},
|
|
31
|
+
"./util/fetcher": {
|
|
32
|
+
"import": "./dist/util/fetcher.mjs",
|
|
33
|
+
"require": "./dist/util/fetcher.cjs"
|
|
34
|
+
},
|
|
31
35
|
"./util/file": {
|
|
32
36
|
"import": "./dist/util/file.mjs",
|
|
33
37
|
"require": "./dist/util/file.cjs"
|
|
@@ -56,6 +60,14 @@
|
|
|
56
60
|
"import": "./dist/ui/dialog/index.mjs",
|
|
57
61
|
"require": "./dist/ui/dialog/index.cjs"
|
|
58
62
|
},
|
|
63
|
+
"./ui/motion-dialog": {
|
|
64
|
+
"import": "./dist/ui/motion-dialog/index.mjs",
|
|
65
|
+
"require": "./dist/ui/motion-dialog/index.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./ui/dnd": {
|
|
68
|
+
"import": "./dist/ui/dnd/index.mjs",
|
|
69
|
+
"require": "./dist/ui/dnd/index.cjs"
|
|
70
|
+
},
|
|
59
71
|
"./ui/image": {
|
|
60
72
|
"import": "./dist/ui/image/index.mjs",
|
|
61
73
|
"require": "./dist/ui/image/index.cjs"
|
|
@@ -64,17 +76,29 @@
|
|
|
64
76
|
"import": "./dist/ui/sheet/index.mjs",
|
|
65
77
|
"require": "./dist/ui/sheet/index.cjs"
|
|
66
78
|
},
|
|
79
|
+
"./ui/switch": {
|
|
80
|
+
"import": "./dist/ui/switch/index.mjs",
|
|
81
|
+
"require": "./dist/ui/switch/index.cjs"
|
|
82
|
+
},
|
|
67
83
|
"./ui/tooltip": {
|
|
68
84
|
"import": "./dist/ui/tooltip/index.mjs",
|
|
69
85
|
"require": "./dist/ui/tooltip/index.cjs"
|
|
70
86
|
},
|
|
71
|
-
"./hooks": {
|
|
72
|
-
"import": "./dist/hooks/index.mjs",
|
|
73
|
-
"require": "./dist/hooks/index.cjs"
|
|
87
|
+
"./hooks/common": {
|
|
88
|
+
"import": "./dist/hooks/common/index.mjs",
|
|
89
|
+
"require": "./dist/hooks/common/index.cjs"
|
|
74
90
|
},
|
|
75
|
-
"./
|
|
76
|
-
"import": "./dist/
|
|
77
|
-
"require": "./dist/
|
|
91
|
+
"./hooks/use-snackbar": {
|
|
92
|
+
"import": "./dist/hooks/use-snackbar.mjs",
|
|
93
|
+
"require": "./dist/hooks/use-snackbar.cjs"
|
|
94
|
+
},
|
|
95
|
+
"./providers/api-client": {
|
|
96
|
+
"import": "./dist/providers/api-client/index.mjs",
|
|
97
|
+
"require": "./dist/providers/api-client/index.cjs"
|
|
98
|
+
},
|
|
99
|
+
"./providers/noti-stack": {
|
|
100
|
+
"import": "./dist/providers/noti-stack/index.mjs",
|
|
101
|
+
"require": "./dist/providers/noti-stack/index.cjs"
|
|
78
102
|
},
|
|
79
103
|
"./styles/index.css": "./dist/styles/index.css"
|
|
80
104
|
},
|
|
@@ -82,11 +106,14 @@
|
|
|
82
106
|
"author": "KOMACHINE",
|
|
83
107
|
"license": "MIT",
|
|
84
108
|
"devDependencies": {
|
|
109
|
+
"@dnd-kit/core": "^6.3.1",
|
|
110
|
+
"@dnd-kit/modifiers": "^9.0.0",
|
|
111
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
112
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
85
113
|
"@eslint/js": "^9.39.5",
|
|
86
114
|
"@storybook/addon-docs": "^10.3.5",
|
|
87
|
-
"@storybook/react-vite": "^10.
|
|
115
|
+
"@storybook/react-vite": "^10.5.10",
|
|
88
116
|
"@tailwindcss/postcss": "^4.1.18",
|
|
89
|
-
"@typed/node": "^6.7.0",
|
|
90
117
|
"@types/google-libphonenumber": "^7.4.30",
|
|
91
118
|
"@types/js-cookie": "^3.0.6",
|
|
92
119
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -102,59 +129,65 @@
|
|
|
102
129
|
"eslint-plugin-prettier": "^5.5.6",
|
|
103
130
|
"eslint-plugin-react": "^7.37.5",
|
|
104
131
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
105
|
-
"motion": "^
|
|
132
|
+
"motion": "^13.1.1",
|
|
133
|
+
"notistack": "^3.0.0",
|
|
106
134
|
"postcss": "^8.5.6",
|
|
107
135
|
"prettier": "^3.9.6",
|
|
108
136
|
"react": "^18.3.1",
|
|
109
137
|
"react-dom": "^18.3.1",
|
|
110
|
-
"
|
|
111
|
-
"react-select": "^5.10.2",
|
|
112
|
-
"react-select-async-paginate": "^0.7.11",
|
|
113
|
-
"storybook": "^10.2.3",
|
|
138
|
+
"storybook": "^10.5.10",
|
|
114
139
|
"tailwindcss": "^4.1.18",
|
|
115
140
|
"tsdown": "0.17.0-beta.5",
|
|
116
141
|
"typescript": "^5.9.3",
|
|
117
142
|
"typescript-eslint": "^8.65.0"
|
|
118
143
|
},
|
|
119
144
|
"dependencies": {
|
|
120
|
-
"@radix-ui/react-slot": "^1.
|
|
145
|
+
"@radix-ui/react-slot": "^1.3.3",
|
|
121
146
|
"class-variance-authority": "^0.7.1",
|
|
122
147
|
"clsx": "^2.1.1",
|
|
123
|
-
"dayjs": "^1.11.
|
|
124
|
-
"google-libphonenumber": "^3.2.
|
|
125
|
-
"js-cookie": "^3.0.
|
|
126
|
-
"lodash-es": "^4.
|
|
127
|
-
"nanoid": "^
|
|
128
|
-
"query-string": "^9.
|
|
129
|
-
"slug": "^
|
|
148
|
+
"dayjs": "^1.11.23",
|
|
149
|
+
"google-libphonenumber": "^3.2.46",
|
|
150
|
+
"js-cookie": "^3.0.8",
|
|
151
|
+
"lodash-es": "^4.18.1",
|
|
152
|
+
"nanoid": "^6.0.1",
|
|
153
|
+
"query-string": "^9.5.0",
|
|
154
|
+
"slug": "^12.0.1"
|
|
130
155
|
},
|
|
131
156
|
"peerDependencies": {
|
|
157
|
+
"@dnd-kit/core": "^6.0.0",
|
|
158
|
+
"@dnd-kit/modifiers": "^9.0.0",
|
|
159
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
160
|
+
"@dnd-kit/utilities": "^3.0.0",
|
|
132
161
|
"embla-carousel": "^8.0.0",
|
|
133
162
|
"embla-carousel-react": "^8.0.0",
|
|
134
|
-
"
|
|
163
|
+
"notistack": "^3.0.0",
|
|
164
|
+
"motion": "^13.0.0",
|
|
135
165
|
"react": "^18.3.1 || ^19.0.0",
|
|
136
|
-
"react-dom": "^18.3.1 || ^19.0.0"
|
|
137
|
-
"react-hook-form": "^7.0.0",
|
|
138
|
-
"react-select": "^5.0.0",
|
|
139
|
-
"react-select-async-paginate": "^0.7.0"
|
|
166
|
+
"react-dom": "^18.3.1 || ^19.0.0"
|
|
140
167
|
},
|
|
141
168
|
"peerDependenciesMeta": {
|
|
142
|
-
"
|
|
169
|
+
"@dnd-kit/core": {
|
|
143
170
|
"optional": true
|
|
144
171
|
},
|
|
145
|
-
"
|
|
172
|
+
"@dnd-kit/modifiers": {
|
|
146
173
|
"optional": true
|
|
147
174
|
},
|
|
148
|
-
"
|
|
175
|
+
"@dnd-kit/sortable": {
|
|
176
|
+
"optional": true
|
|
177
|
+
},
|
|
178
|
+
"@dnd-kit/utilities": {
|
|
179
|
+
"optional": true
|
|
180
|
+
},
|
|
181
|
+
"embla-carousel": {
|
|
149
182
|
"optional": true
|
|
150
183
|
},
|
|
151
|
-
"
|
|
184
|
+
"embla-carousel-react": {
|
|
152
185
|
"optional": true
|
|
153
186
|
},
|
|
154
|
-
"
|
|
187
|
+
"notistack": {
|
|
155
188
|
"optional": true
|
|
156
189
|
},
|
|
157
|
-
"
|
|
190
|
+
"motion": {
|
|
158
191
|
"optional": true
|
|
159
192
|
}
|
|
160
193
|
},
|
package/dist/hooks/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`../src-CjpmdVyv.cjs`),require(`../file-5mweNdAM.cjs`);const e=require(`../hooks-CUj2xuzU.cjs`);require(`../providers-CkXkdYcB.cjs`);const t=require(`../use-subset-image-DC86cg6O.cjs`);exports.SUBSETS=t.t,exports.useDelayUnmount=e.o,exports.useDragScroll=e.a,exports.useOutsideClick=e.i,exports.useScrollLock=e.r,exports.useScrollTop=e.n,exports.useSubsetImage=t.n,exports.useWindowSize=e.t;
|
package/dist/hooks/index.d.cts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as UseSubsetImageProps, c as useScrollTop, d as UseOutsideClickProps, f as useOutsideClick, i as SUBSETS, l as UseScrollLockProps, m as useDelayUnmount, n as BaseProps, o as useSubsetImage, p as useDragScroll, r as Folder, s as UseScrollTopProps, t as useWindowSize, u as useScrollLock } from "../index-DiRj3rRA.cjs";
|
|
2
|
-
export { BaseProps, Folder, SUBSETS, UseOutsideClickProps, UseScrollLockProps, UseScrollTopProps, UseSubsetImageProps, useDelayUnmount, useDragScroll, useOutsideClick, useScrollLock, useScrollTop, useSubsetImage, useWindowSize };
|
package/dist/hooks/index.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as UseSubsetImageProps, c as useScrollTop, d as UseOutsideClickProps, f as useOutsideClick, i as SUBSETS, l as UseScrollLockProps, m as useDelayUnmount, n as BaseProps, o as useSubsetImage, p as useDragScroll, r as Folder, s as UseScrollTopProps, t as useWindowSize, u as useScrollLock } from "../index-BFHrNSKP.mjs";
|
|
2
|
-
export { BaseProps, Folder, SUBSETS, UseOutsideClickProps, UseScrollLockProps, UseScrollTopProps, UseSubsetImageProps, useDelayUnmount, useDragScroll, useOutsideClick, useScrollLock, useScrollTop, useSubsetImage, useWindowSize };
|
package/dist/hooks/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../src-CukOR3K2.mjs";import"../file-DShNxIW4.mjs";import{a as e,i as t,n,o as r,r as i,t as a}from"../hooks-gbU5dqVF.mjs";import"../providers-zftmvT1z.mjs";import{n as o,t as s}from"../use-subset-image-D8ssrZhj.mjs";export{s as SUBSETS,r as useDelayUnmount,e as useDragScroll,t as useOutsideClick,i as useScrollLock,n as useScrollTop,o as useSubsetImage,a as useWindowSize};
|
package/dist/hooks-CUj2xuzU.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`lodash-es`),n=require(`react`);function r(e,t){let[r,i]=(0,n.useState)(e);return(0,n.useEffect)(()=>{if(e){i(!0);return}let n=setTimeout(()=>i(!1),t);return()=>clearTimeout(n)},[e,t]),e||r}function i(e=1){let t=(0,n.useRef)(null),[r,i]=(0,n.useState)(!1),[a,o]=(0,n.useState)(0),[s,c]=(0,n.useState)(0),l=(0,n.useRef)(!1);return{ref:t,onMouseDown:e=>{t.current&&(i(!0),l.current=!1,o(e.pageX-t.current.offsetLeft),c(t.current.scrollLeft))},onMouseLeave:()=>i(!1),onMouseUp:()=>i(!1),onMouseMove:n=>{if(!r||!t.current)return;n.preventDefault();let i=(n.pageX-t.current.offsetLeft-a)*e;Math.abs(i)>10&&(l.current=!0),t.current.scrollLeft=s-i},onClickCapture:e=>{l.current&&(e.stopPropagation(),e.preventDefault())}}}function a({ref:e,setOpen:t}){let r=(0,n.useCallback)(n=>{e.current?.contains(n.target)||t(!1)},[e,t]);(0,n.useEffect)(()=>(document.addEventListener(`mousedown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`touchstart`,r)}),[r])}const o=[`mouse`,`touch`];function s({open:e,type:t=o}){let r=(0,n.useCallback)(e=>{e.preventDefault()},[]),i=(0,n.useCallback)(e=>{e.preventDefault()},[]);(0,n.useEffect)(()=>{let n=e&&t.includes(`mouse`),a=e&&t.includes(`touch`);return n?(document.body.classList.add(`overflow-hidden`),document.addEventListener(`wheel`,i,{passive:!1})):(document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`wheel`,i)),a?document.addEventListener(`touchmove`,r,{passive:!1}):document.removeEventListener(`touchmove`,r),()=>{document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`touchmove`,r),document.removeEventListener(`wheel`,i)}},[e,t,r,i])}function c({enabled:e=!0,behavior:t=`smooth`}={}){let[r,i]=(0,n.useState)(!1),a=(0,n.useRef)(null),o=(0,n.useCallback)(()=>{window.scrollTo({top:0,behavior:t})},[t]);return(0,n.useEffect)(()=>{let t=a.current;if(!t||!e){i(!1);return}let n=new IntersectionObserver(e=>{let t=e[0];t&&i(!t.isIntersecting)},{root:null,rootMargin:`0px`,threshold:0});return n.observe(t),()=>n.disconnect()},[e]),{isVisible:r,handleScrolToTop:o,ref:a}}function l(e=1280){let[r,i]=(0,n.useState)(e);return(0,n.useEffect)(()=>{let e=(0,t.throttle)(()=>{let e=window.innerWidth;i(e)},200);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]),{windowSize:r}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|
package/dist/hooks-gbU5dqVF.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{throttle as e}from"lodash-es";import{useCallback as t,useEffect as n,useRef as r,useState as i}from"react";function a(e,t){let[r,a]=i(e);return n(()=>{if(e){a(!0);return}let n=setTimeout(()=>a(!1),t);return()=>clearTimeout(n)},[e,t]),e||r}function o(e=1){let t=r(null),[n,a]=i(!1),[o,s]=i(0),[c,l]=i(0),u=r(!1);return{ref:t,onMouseDown:e=>{t.current&&(a(!0),u.current=!1,s(e.pageX-t.current.offsetLeft),l(t.current.scrollLeft))},onMouseLeave:()=>a(!1),onMouseUp:()=>a(!1),onMouseMove:r=>{if(!n||!t.current)return;r.preventDefault();let i=(r.pageX-t.current.offsetLeft-o)*e;Math.abs(i)>10&&(u.current=!0),t.current.scrollLeft=c-i},onClickCapture:e=>{u.current&&(e.stopPropagation(),e.preventDefault())}}}function s({ref:e,setOpen:r}){let i=t(t=>{e.current?.contains(t.target)||r(!1)},[e,r]);n(()=>(document.addEventListener(`mousedown`,i),document.addEventListener(`touchstart`,i),()=>{document.removeEventListener(`mousedown`,i),document.removeEventListener(`touchstart`,i)}),[i])}const c=[`mouse`,`touch`];function l({open:e,type:r=c}){let i=t(e=>{e.preventDefault()},[]),a=t(e=>{e.preventDefault()},[]);n(()=>{let t=e&&r.includes(`mouse`),n=e&&r.includes(`touch`);return t?(document.body.classList.add(`overflow-hidden`),document.addEventListener(`wheel`,a,{passive:!1})):(document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`wheel`,a)),n?document.addEventListener(`touchmove`,i,{passive:!1}):document.removeEventListener(`touchmove`,i),()=>{document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`touchmove`,i),document.removeEventListener(`wheel`,a)}},[e,r,i,a])}function u({enabled:e=!0,behavior:a=`smooth`}={}){let[o,s]=i(!1),c=r(null),l=t(()=>{window.scrollTo({top:0,behavior:a})},[a]);return n(()=>{let t=c.current;if(!t||!e){s(!1);return}let n=new IntersectionObserver(e=>{let t=e[0];t&&s(!t.isIntersecting)},{root:null,rootMargin:`0px`,threshold:0});return n.observe(t),()=>n.disconnect()},[e]),{isVisible:o,handleScrolToTop:l,ref:c}}function d(t=1280){let[r,a]=i(t);return n(()=>{let t=e(()=>{let e=window.innerWidth;a(e)},200);return window.addEventListener(`resize`,t),t(),()=>window.removeEventListener(`resize`,t)},[]),{windowSize:r}}export{o as a,s as i,u as n,a as o,l as r,d as t};
|