@plurid/plurid-functions-react 0.0.0-4 → 0.0.0-6

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,74 @@
1
+ import React from 'react';
2
+
3
+ declare const useWindowEvent: (event: any, callback: any) => void;
4
+ declare const useElementEvent: (event: any, element: any, callback: any) => void;
5
+ declare const useGlobalKeyDown: (callback: any, element?: any) => void;
6
+ declare const useGlobalWheel: (callback: any, element?: any) => void;
7
+
8
+ /**
9
+ * Source: https://stackoverflow.com/a/57335271
10
+ *
11
+ * @param callback Function to be called.
12
+ * @param wait Debounce time.
13
+ */
14
+ declare function useDebouncedCallback<A extends any[]>(callback: (...args: A) => void, wait: number): (...args: A) => void;
15
+
16
+ /**
17
+ * @param callback
18
+ * @param delay
19
+ */
20
+ declare const useThrottledCallback: <A extends any[]>(callback: (...args: A) => void, delay: number) => (...args: A) => void;
21
+
22
+ /**
23
+ * Based on
24
+ * https://www.jayfreestone.com/writing/react-portals-with-hooks/
25
+ *
26
+ */
27
+ /**
28
+ * Hook to create a React Portal.
29
+ * Automatically handles creating and tearing-down the root elements (no SRR
30
+ * makes this trivial), so there is no need to ensure the parent target already
31
+ * exists.
32
+ * @example
33
+ * const target = usePortal(id, [id]);
34
+ * return createPortal(children, target);
35
+ *
36
+ * @param id The id of the target container, e.g 'modal' or 'spotlight'
37
+ * @returns The DOM node to use as the Portal target.
38
+ */
39
+ declare const usePortal: (id: string, parentID: string) => any;
40
+
41
+ /**
42
+ * After a `true` dispatch, it will wait the `intervalTime` and autoset to `false`.
43
+ *
44
+ * @param intervalTime
45
+ * @returns
46
+ */
47
+ declare const useFalseAfterTimedTrue: (intervalTime?: number) => [boolean, React.Dispatch<React.SetStateAction<boolean>>];
48
+ /**
49
+ * Keeps reference of the current mounted component.
50
+ *
51
+ * @returns
52
+ */
53
+ declare const useMounted: () => boolean;
54
+
55
+ declare const createMarkup: (text: string) => {
56
+ __html: string;
57
+ };
58
+
59
+ /**
60
+ * Merges multiple references into one `ref` attribute.
61
+ *
62
+ * ``` jsx
63
+ * <SomeComponent
64
+ * ref={merge(ref1, ref2)}
65
+ * />
66
+ * ```
67
+ *
68
+ * Source: https://www.davedrinks.coffee/how-do-i-use-two-react-refs/
69
+ *
70
+ * @param refs
71
+ */
72
+ declare const mergeReferences: (...refs: any[]) => any;
73
+
74
+ export { createMarkup, mergeReferences, useDebouncedCallback, useElementEvent, useFalseAfterTimedTrue, useGlobalKeyDown, useGlobalWheel, useMounted, usePortal, useThrottledCallback, useWindowEvent };
@@ -1,2 +1,74 @@
1
- export * from './hooks';
2
- export * from './utilities';
1
+ import React from 'react';
2
+
3
+ declare const useWindowEvent: (event: any, callback: any) => void;
4
+ declare const useElementEvent: (event: any, element: any, callback: any) => void;
5
+ declare const useGlobalKeyDown: (callback: any, element?: any) => void;
6
+ declare const useGlobalWheel: (callback: any, element?: any) => void;
7
+
8
+ /**
9
+ * Source: https://stackoverflow.com/a/57335271
10
+ *
11
+ * @param callback Function to be called.
12
+ * @param wait Debounce time.
13
+ */
14
+ declare function useDebouncedCallback<A extends any[]>(callback: (...args: A) => void, wait: number): (...args: A) => void;
15
+
16
+ /**
17
+ * @param callback
18
+ * @param delay
19
+ */
20
+ declare const useThrottledCallback: <A extends any[]>(callback: (...args: A) => void, delay: number) => (...args: A) => void;
21
+
22
+ /**
23
+ * Based on
24
+ * https://www.jayfreestone.com/writing/react-portals-with-hooks/
25
+ *
26
+ */
27
+ /**
28
+ * Hook to create a React Portal.
29
+ * Automatically handles creating and tearing-down the root elements (no SRR
30
+ * makes this trivial), so there is no need to ensure the parent target already
31
+ * exists.
32
+ * @example
33
+ * const target = usePortal(id, [id]);
34
+ * return createPortal(children, target);
35
+ *
36
+ * @param id The id of the target container, e.g 'modal' or 'spotlight'
37
+ * @returns The DOM node to use as the Portal target.
38
+ */
39
+ declare const usePortal: (id: string, parentID: string) => any;
40
+
41
+ /**
42
+ * After a `true` dispatch, it will wait the `intervalTime` and autoset to `false`.
43
+ *
44
+ * @param intervalTime
45
+ * @returns
46
+ */
47
+ declare const useFalseAfterTimedTrue: (intervalTime?: number) => [boolean, React.Dispatch<React.SetStateAction<boolean>>];
48
+ /**
49
+ * Keeps reference of the current mounted component.
50
+ *
51
+ * @returns
52
+ */
53
+ declare const useMounted: () => boolean;
54
+
55
+ declare const createMarkup: (text: string) => {
56
+ __html: string;
57
+ };
58
+
59
+ /**
60
+ * Merges multiple references into one `ref` attribute.
61
+ *
62
+ * ``` jsx
63
+ * <SomeComponent
64
+ * ref={merge(ref1, ref2)}
65
+ * />
66
+ * ```
67
+ *
68
+ * Source: https://www.davedrinks.coffee/how-do-i-use-two-react-refs/
69
+ *
70
+ * @param refs
71
+ */
72
+ declare const mergeReferences: (...refs: any[]) => any;
73
+
74
+ export { createMarkup, mergeReferences, useDebouncedCallback, useElementEvent, useFalseAfterTimedTrue, useGlobalKeyDown, useGlobalWheel, useMounted, usePortal, useThrottledCallback, useWindowEvent };