@bbodek/hooks 0.0.13 → 0.0.14

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.
Files changed (34) hide show
  1. package/dist/effects/index.d.ts +3 -0
  2. package/dist/effects/index.d.ts.map +1 -0
  3. package/dist/effects/useIsomorphicLayoutEffect/index.d.ts +2 -0
  4. package/dist/effects/useIsomorphicLayoutEffect/index.d.ts.map +1 -0
  5. package/dist/effects/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +4 -0
  6. package/dist/effects/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts.map +1 -0
  7. package/dist/effects/useScrollLockEffect/index.d.ts +3 -0
  8. package/dist/effects/useScrollLockEffect/index.d.ts.map +1 -0
  9. package/dist/effects/useScrollLockEffect/types/index.d.ts +5 -0
  10. package/dist/effects/useScrollLockEffect/types/index.d.ts.map +1 -0
  11. package/dist/effects/useScrollLockEffect/useScrollLockEffect.d.ts +4 -0
  12. package/dist/effects/useScrollLockEffect/useScrollLockEffect.d.ts.map +1 -0
  13. package/dist/hooks/index.d.ts +3 -0
  14. package/dist/hooks/index.d.ts.map +1 -0
  15. package/dist/hooks/useClickOutSide/index.d.ts +4 -0
  16. package/dist/hooks/useClickOutSide/index.d.ts.map +1 -0
  17. package/dist/hooks/useClickOutSide/types/index.d.ts +9 -0
  18. package/dist/hooks/useClickOutSide/types/index.d.ts.map +1 -0
  19. package/dist/hooks/useClickOutSide/useClickOutSide.d.ts +6 -0
  20. package/dist/hooks/useClickOutSide/useClickOutSide.d.ts.map +1 -0
  21. package/dist/hooks/useClickOutSide/useClickOutSideEffect.d.ts +4 -0
  22. package/dist/hooks/useClickOutSide/useClickOutSideEffect.d.ts.map +1 -0
  23. package/dist/hooks/useForm/index.d.ts +3 -0
  24. package/dist/hooks/useForm/index.d.ts.map +1 -0
  25. package/dist/hooks/useForm/types/index.d.ts +20 -0
  26. package/dist/hooks/useForm/types/index.d.ts.map +1 -0
  27. package/dist/hooks/useForm/useForm.d.ts +4 -0
  28. package/dist/hooks/useForm/useForm.d.ts.map +1 -0
  29. package/dist/index.d.ts +2 -3
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.es.js +1 -1
  32. package/dist/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +2 -2
  33. package/dist/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts.map +1 -1
  34. package/package.json +3 -4
@@ -0,0 +1,3 @@
1
+ export * from './useIsomorphicLayoutEffect';
2
+ export * from './useScrollLockEffect';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/effects/useIsomorphicLayoutEffect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { useLayoutEffect } from 'react';
2
+ declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
3
+ export default useIsomorphicLayoutEffect;
4
+ //# sourceMappingURL=useIsomorphicLayoutEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../../src/effects/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;AAEnD,QAAA,MAAM,yBAAyB,wBAC8B,CAAC;AAE9D,eAAe,yBAAyB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export { default as useScrollLockEffect } from './useScrollLockEffect';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/effects/useScrollLockEffect/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface UseScrollLockEffectProps {
2
+ isLocked: boolean;
3
+ target?: string;
4
+ }
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/effects/useScrollLockEffect/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,4 @@
1
+ import { UseScrollLockEffectProps } from '../../effects/useScrollLockEffect/types';
2
+ declare const useScrollLockEffect: ({ isLocked, target, }: UseScrollLockEffectProps) => void;
3
+ export default useScrollLockEffect;
4
+ //# sourceMappingURL=useScrollLockEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollLockEffect.d.ts","sourceRoot":"","sources":["../../../src/effects/useScrollLockEffect/useScrollLockEffect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,QAAA,MAAM,mBAAmB,GAAI,uBAG1B,wBAAwB,SAgB1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './useClickOutSide';
2
+ export * from './useForm';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export { default as useClickOutside } from './useClickOutSide';
3
+ export { default as useClickOutSideEffect } from './useClickOutSideEffect';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useClickOutSide/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { RefObject } from 'react';
2
+ export interface UseClickOutsideProps {
3
+ onClose: (e: MouseEvent) => void;
4
+ useClickOutsideEvent?: boolean;
5
+ }
6
+ export interface UseClickOutSideEffectProps<T extends HTMLElement> extends UseClickOutsideProps {
7
+ ref: RefObject<T | null>;
8
+ }
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useClickOutSide/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACjC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,WAAW,CAC/D,SAAQ,oBAAoB;IAC5B,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;CAC1B"}
@@ -0,0 +1,6 @@
1
+ import { UseClickOutsideProps } from '../../hooks/useClickOutSide/types';
2
+ declare const useClickOutside: <T extends HTMLElement>({ onClose, useClickOutsideEvent, }: UseClickOutsideProps) => {
3
+ contentRef: import("react").RefObject<T | null>;
4
+ };
5
+ export default useClickOutside;
6
+ //# sourceMappingURL=useClickOutSide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClickOutSide.d.ts","sourceRoot":"","sources":["../../../src/hooks/useClickOutSide/useClickOutSide.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGrE,QAAA,MAAM,eAAe,GAAI,CAAC,SAAS,WAAW,EAAE,oCAG7C,oBAAoB;;CAUtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { UseClickOutSideEffectProps } from '../../hooks/useClickOutSide/types';
2
+ declare const useClickOutSideEffect: <T extends HTMLElement>({ ref, onClose, useClickOutsideEvent, }: UseClickOutSideEffectProps<T>) => void;
3
+ export default useClickOutSideEffect;
4
+ //# sourceMappingURL=useClickOutSideEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClickOutSideEffect.d.ts","sourceRoot":"","sources":["../../../src/hooks/useClickOutSide/useClickOutSideEffect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,QAAA,MAAM,qBAAqB,GAAI,CAAC,SAAS,WAAW,EAAE,yCAInD,0BAA0B,CAAC,CAAC,CAAC,SAoB/B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export { default as useForm } from './useForm';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useForm/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { ChangeEvent, Dispatch, SetStateAction } from 'react';
2
+ export type ValueKey<T> = keyof T & string;
3
+ export type UseFormErrors = {
4
+ [key: string]: string;
5
+ };
6
+ export interface Props<T> {
7
+ initialValues: T;
8
+ validate?: (fields: T) => UseFormErrors;
9
+ }
10
+ export interface UseFormHandleChangeParams {
11
+ event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>;
12
+ }
13
+ export interface UseFormReturnType<T> {
14
+ values: T;
15
+ setValues: Dispatch<SetStateAction<T>>;
16
+ errors: UseFormErrors;
17
+ handleChange: (event: UseFormHandleChangeParams['event']) => void;
18
+ setErrors: Dispatch<SetStateAction<UseFormErrors>>;
19
+ }
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useForm/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,aAAa,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEtD,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,aAAa,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,aAAa,CAAC;CACzC;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC;IACV,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,CAAC,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAClE,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC;CACpD"}
@@ -0,0 +1,4 @@
1
+ import { Props, UseFormReturnType } from '../../hooks/useForm/types';
2
+ declare const useForm: <T extends object>({ initialValues, validate, }: Props<T>) => UseFormReturnType<T>;
3
+ export default useForm;
4
+ //# sourceMappingURL=useForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../src/hooks/useForm/useForm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAiB,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,QAAA,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EAAE,8BAGhC,KAAK,CAAC,CAAC,CAAC,KAAG,iBAAiB,CAAC,CAAC,CA2ChC,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './useClickOutSide';
2
- export * from './useForm';
3
- export * from './useIsomorphicLayoutEffect';
1
+ export * from './effects';
2
+ export * from './hooks';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import{useEffect as e,useRef as n,useState as t,useLayoutEffect as o}from"react";const r=({ref:n,onClose:t,useClickOutsideEvent:o=!0})=>{e((()=>{const e=e=>{n.current&&!n.current.contains(e.target)&&t(e)};return o?document.addEventListener("mousedown",e):document.removeEventListener("mousedown",e),()=>{o&&document.removeEventListener("mousedown",e)}}),[n.current,o])},s=({onClose:e,useClickOutsideEvent:t})=>{const o=n(null);return r({ref:o,onClose:e,useClickOutsideEvent:t}),{contentRef:o}},u=({initialValues:e,validate:n})=>{const[o,r]=t(e),[s,u]=t({});return{values:o,setValues:e=>{const t="function"==typeof e?e(o):e;if(r(t),n){const e=n(t);u(e)}},errors:s,handleChange:t=>{const{name:s,value:c}=t.target;if(s in e&&(r({...o,[s]:c}),n)){const e=n({...o,[s]:c});u(e)}},setErrors:u}},c="undefined"!=typeof window?o:e;export{r as useClickOutSideEffect,s as useClickOutside,u as useForm,c as useIsomorphicLayoutEffect};
1
+ import{useLayoutEffect as e,useEffect as t,useRef as n,useState as o}from"react";const r="undefined"!=typeof window?e:t,s=({isLocked:e,target:n})=>{t((()=>{const t=n?document.getElementById(n):document.body;if(t)return t.style.overflow=e?"hidden":"auto",()=>{t.style.overflow="auto"}}),[e,n])},u=({ref:e,onClose:n,useClickOutsideEvent:o=!0})=>{t((()=>{const t=t=>{e.current&&!e.current.contains(t.target)&&n(t)};return o?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>{o&&document.removeEventListener("mousedown",t)}}),[e.current,o])},c=({onClose:e,useClickOutsideEvent:t})=>{const o=n(null);return u({ref:o,onClose:e,useClickOutsideEvent:t}),{contentRef:o}},i=({initialValues:e,validate:t})=>{const[n,r]=o(e),[s,u]=o({});return{values:n,setValues:e=>{const o="function"==typeof e?e(n):e;if(r(o),t){const e=t(o);u(e)}},errors:s,handleChange:o=>{const{name:s,value:c}=o.target;if(s in e&&(r({...n,[s]:c}),t)){const e=t({...n,[s]:c});u(e)}},setErrors:u}};export{u as useClickOutSideEffect,c as useClickOutside,i as useForm,r as useIsomorphicLayoutEffect,s as useScrollLockEffect};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -1,4 +1,4 @@
1
- import { useLayoutEffect } from 'react';
2
- declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
1
+ import { useEffect } from 'react';
2
+ declare const useIsomorphicLayoutEffect: typeof useEffect;
3
3
  export default useIsomorphicLayoutEffect;
4
4
  //# sourceMappingURL=useIsomorphicLayoutEffect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;AAEnD,QAAA,MAAM,yBAAyB,wBAC8B,CAAC;AAE9D,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,OAAO,CAAC;AAEnD,QAAA,MAAM,yBAAyB,kBAC8B,CAAC;AAE9D,eAAe,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbodek/hooks",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,11 +13,10 @@
13
13
  "dist"
14
14
  ],
15
15
  "scripts": {
16
- "dev": "next dev",
16
+ "dev": "rollup -c --watch & tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --watch",
17
17
  "build": "rollup -c && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
18
18
  "start": "next start",
19
- "lint": "next lint",
20
- "pub": "npm publish"
19
+ "lint": "next lint"
21
20
  },
22
21
  "dependencies": {
23
22
  "next": "^15.3.1",