@machinerd/js-module 0.0.10 → 0.1.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/README.md +30 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +18 -0
- package/dist/hooks/index.d.mts +18 -0
- package/dist/hooks/index.mjs +1 -0
- package/dist/hooks-5I2NBtcY.mjs +1 -0
- package/dist/hooks-DPYIex_y.cjs +1 -0
- package/dist/styles/index.css +761 -0
- package/dist/ui/index.cjs +1 -0
- package/dist/ui/index.d.cts +291 -0
- package/dist/ui/index.d.mts +291 -0
- package/dist/ui/index.mjs +1 -0
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.d.cts +48 -26
- package/dist/util/index.d.mts +48 -26
- package/dist/util/index.mjs +1 -1
- package/dist/util-CDkao6z3.cjs +1 -0
- package/dist/util-DCPr_-5a.mjs +1 -0
- package/package.json +35 -9
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# JS-Module
|
|
2
|
+
- install
|
|
3
|
+
```bash
|
|
4
|
+
npm install @machinerd/js-module
|
|
5
|
+
# or
|
|
6
|
+
yarn add @machinerd/js-module
|
|
7
|
+
# or
|
|
8
|
+
pnpm add @machinerd/js-module
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- api client
|
|
12
|
+
```js
|
|
13
|
+
import apiClient from '@machinerd/js-module';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- function
|
|
17
|
+
```js
|
|
18
|
+
import { sleep } '@machinerd/js-module/util';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- components
|
|
22
|
+
```js
|
|
23
|
+
import { Button } '@machinerd/js-module/ui';
|
|
24
|
+
import '@machinerd/js-module/styles/index.css';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- hooks
|
|
28
|
+
```js
|
|
29
|
+
import { useOutsideClick } '@machinerd/js-module/hooks';
|
|
30
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../hooks-DPYIex_y.cjs`);exports.useOutsideClick=e.t,exports.useWindowSize=e.n;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dispatch, RefObject, SetStateAction } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-window-size.d.ts
|
|
4
|
+
declare function useWindowSize(defaultWidth?: number): {
|
|
5
|
+
windowSize: number;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/hooks/use-outside-click.d.ts
|
|
9
|
+
interface UseOutsideClickProps {
|
|
10
|
+
ref: RefObject<HTMLElement | null>;
|
|
11
|
+
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
12
|
+
}
|
|
13
|
+
declare function useOutsideClick({
|
|
14
|
+
ref,
|
|
15
|
+
setOpen
|
|
16
|
+
}: UseOutsideClickProps): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { type UseOutsideClickProps, useOutsideClick, useWindowSize };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dispatch, RefObject, SetStateAction } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-window-size.d.ts
|
|
4
|
+
declare function useWindowSize(defaultWidth?: number): {
|
|
5
|
+
windowSize: number;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/hooks/use-outside-click.d.ts
|
|
9
|
+
interface UseOutsideClickProps {
|
|
10
|
+
ref: RefObject<HTMLElement | null>;
|
|
11
|
+
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
12
|
+
}
|
|
13
|
+
declare function useOutsideClick({
|
|
14
|
+
ref,
|
|
15
|
+
setOpen
|
|
16
|
+
}: UseOutsideClickProps): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { type UseOutsideClickProps, useOutsideClick, useWindowSize };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"../hooks-5I2NBtcY.mjs";export{t as useOutsideClick,e as useWindowSize};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{throttle as e}from"lodash-es";import{useCallback as t,useEffect as n,useState as r}from"react";function i(t=1280){let[i,a]=r(t);return n(()=>{let t=e(()=>{let e=window.innerWidth;a(e)},200);return window.addEventListener(`resize`,t),t(),()=>window.removeEventListener(`resize`,t)},[]),{windowSize:i}}function a({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])}export{i as n,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`lodash-es`),n=require(`react`);function r(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}}function i({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])}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|