@voidly-io/design-system 1.0.16 → 1.0.17

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.
@@ -0,0 +1,58 @@
1
+ //#region src/hooks/useWindowSize.d.ts
2
+ /**
3
+ * A custom hook that listens for window resize events and updates
4
+ * the state with the current window dimensions.
5
+ * @returns An object containing the current window width and height.
6
+ */
7
+ declare const useWindowSize: () => {
8
+ height: number;
9
+ width: number;
10
+ };
11
+ //#endregion
12
+ //#region src/hooks/useScroll.d.ts
13
+ /**
14
+ * A custom hook that adds a scroll event listener to a specified element and
15
+ * calls the provided onScroll callback whenever a scroll event occurs.
16
+ * The hook also ensures that the event listener is properly cleaned up when
17
+ * the component unmounts or when the element or onScroll callback changes.
18
+ * @param options.element The element to which the scroll event listener will be attached.
19
+ * @param options.onScroll The callback function that will be called when a scroll event occurs.
20
+ * @returns null, as this hook does not return any value.
21
+ */
22
+ declare const useOnScroll: (options: {
23
+ element: HTMLElement | Element | Window | Document | null | undefined;
24
+ onScroll(): void;
25
+ }) => null;
26
+ //#endregion
27
+ //#region src/hooks/useIsClient.d.ts
28
+ /**
29
+ * A custom hook that determines if the current environment is a client (browser).
30
+ * It initializes the state to false and sets it to true when the component is mounted,
31
+ * indicating that the code is running in a client environment.
32
+ * @returns A boolean value indicating whether the current environment is a client.
33
+ */
34
+ declare function useIsClient(): boolean;
35
+ //#endregion
36
+ //#region src/hooks/useIsServer.d.ts
37
+ /**
38
+ * A custom hook that determines if the current environment is a server (Node.js).
39
+ * It uses the useIsClient hook to check if the environment is a client, and returns
40
+ * the opposite value to indicate if it's a server environment.
41
+ * @returns A boolean value indicating whether the current environment is a server.
42
+ */
43
+ declare function useIsServer(): boolean;
44
+ //#endregion
45
+ //#region src/hooks/useForceRerender.d.ts
46
+ /**
47
+ * A custom hook that provides a function to force a component to re-render.
48
+ * It uses a state variable that is incremented whenever the rerender function is called,
49
+ * which triggers a re-render of the component.
50
+ * @returns
51
+ * An object containing the rerender function that can be called
52
+ * to force a re-render of the component.
53
+ */
54
+ declare function useForceRerender(): {
55
+ rerender: () => void;
56
+ };
57
+ //#endregion
58
+ export { useForceRerender, useIsClient, useIsServer, useOnScroll, useWindowSize };
@@ -0,0 +1 @@
1
+ import{c as e}from"react/compiler-runtime";import{useEffect as t,useState as n}from"react";const r=()=>{let r=e(3),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={height:window.innerHeight,width:window.innerWidth},r[0]=i):i=r[0];let[a,o]=n(i),s,c;return r[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>{o({height:window.innerHeight,width:window.innerWidth})};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},c=[],r[1]=s,r[2]=c):(s=r[1],c=r[2]),t(s,c),a},i=n=>{let r=e(4),i,a;return r[0]!==n.element||r[1]!==n.onScroll?(i=()=>{if(n.element)return n.element.addEventListener(`scroll`,n.onScroll),()=>{n.element&&n.element.removeEventListener(`scroll`,n.onScroll)}},a=[n.element,n.onScroll],r[0]=n.element,r[1]=n.onScroll,r[2]=i,r[3]=a):(i=r[2],a=r[3]),t(i,a),null};function a(){let r=e(2),[i,a]=n(!1),o,s;return r[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{a(!0)},s=[],r[0]=o,r[1]=s):(o=r[0],s=r[1]),t(o,s),i}function o(){return!a()}function s(){let t=e(2),[,r]=n(0),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{r(c)},t[0]=i):i=t[0];let a=i,o;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o={rerender:a},t[1]=o):o=t[1],o}function c(e){return e+1}export{s as useForceRerender,a as useIsClient,o as useIsServer,i as useOnScroll,r as useWindowSize};
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@voidly-io/design-system",
3
3
  "type": "module",
4
- "version": "1.0.16",
4
+ "version": "1.0.17",
5
5
  "description": "",
6
6
  "license": "Private",
7
7
  "exports": {
8
8
  ".": "./dist/index.js",
9
9
  "./components": "./dist/components/index.js",
10
+ "./hooks": "./dist/hooks/index.js",
10
11
  "./tokens": "./dist/tokens/index.js",
11
12
  "./package.json": "./package.json"
12
13
  },