@grupalia/rn-ui-kit 0.79.0 → 0.80.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 CHANGED
@@ -105,6 +105,34 @@ This will copy all Inter font weights (100-900) and styles (regular and italic)
105
105
 
106
106
  ## Development
107
107
 
108
+ ### Local Development with yalc
109
+
110
+ To test changes locally in another project before publishing:
111
+
112
+ 1. **In this repository**, publish the package locally:
113
+
114
+ ```bash
115
+ yarn publish-local
116
+ ```
117
+
118
+ 2. **In the target project** (e.g., `promoters-mobile`), add the local package:
119
+
120
+ ```bash
121
+ npx yalc add @grupalia/rn-ui-kit
122
+ ```
123
+
124
+ This creates a reference in your `package.json`:
125
+
126
+ ```json
127
+ "@grupalia/rn-ui-kit": "file:.yalc/@grupalia/rn-ui-kit"
128
+ ```
129
+
130
+ 3. **To update** after making changes, run `yarn publish-local` in this repo, then in the target project:
131
+
132
+ ```bash
133
+ npx yalc update
134
+ ```
135
+
108
136
  ### Running Tests
109
137
 
110
138
  This project uses [Vitest](https://vitest.dev/) for testing. The following commands are available:
@@ -69,4 +69,15 @@ Object.keys(_useCurrentTime).forEach(function (key) {
69
69
  }
70
70
  });
71
71
  });
72
+ var _useRefreshRegistry = require("./useRefreshRegistry");
73
+ Object.keys(_useRefreshRegistry).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _useRefreshRegistry[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _useRefreshRegistry[key];
80
+ }
81
+ });
82
+ });
72
83
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_useBreakpoints","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_useIsAboveBreakpoint","_useInternetConnectionStatus","_useTimezonedDate","_useAppUpdateCheck","_useCurrentTime"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;AAAA,IAAAA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IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,iBAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,iBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,kBAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,kBAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,kBAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,kBAAA,CAAAR,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,eAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,eAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,eAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,eAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["_useBreakpoints","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_useIsAboveBreakpoint","_useInternetConnectionStatus","_useTimezonedDate","_useAppUpdateCheck","_useCurrentTime","_useRefreshRegistry"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,W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oreList":[]}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RefreshProvider = RefreshProvider;
7
+ exports.useRefreshChildQueries = useRefreshChildQueries;
8
+ exports.useRegisterRefresh = useRegisterRefresh;
9
+ var _native = require("@react-navigation/native");
10
+ var _react = require("react");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ const RefreshRegistryContext = /*#__PURE__*/(0, _react.createContext)(null);
13
+ function RefreshProvider({
14
+ children
15
+ }) {
16
+ const registry = (0, _react.useRef)(new Map());
17
+ const [isRefreshing, setIsRefreshing] = (0, _react.useState)(false);
18
+ const register = (0, _react.useCallback)((id, entry) => {
19
+ registry.current.set(id, entry);
20
+ }, []);
21
+ const unregister = (0, _react.useCallback)(id => {
22
+ registry.current.delete(id);
23
+ }, []);
24
+ const refreshAll = (0, _react.useCallback)(async () => {
25
+ setIsRefreshing(true);
26
+ try {
27
+ const entries = [...registry.current.values()];
28
+ const toRefresh = entries.filter(entry => entry.shouldRefresh());
29
+ await Promise.all(toRefresh.map(entry => entry.refetch()));
30
+ } finally {
31
+ setIsRefreshing(false);
32
+ }
33
+ }, []);
34
+ const value = (0, _react.useMemo)(() => ({
35
+ register,
36
+ unregister,
37
+ refreshAll,
38
+ isRefreshing
39
+ }), [register, unregister, refreshAll, isRefreshing]);
40
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(RefreshRegistryContext.Provider, {
41
+ value: value,
42
+ children: children
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Hook for parent components to trigger refresh of all registered child queries.
48
+ * Returns `refresh()` to trigger all focused registered queries and `isRefreshing`
49
+ * to indicate progress.
50
+ *
51
+ * @example
52
+ * const { refresh, isRefreshing } = useRefreshChildQueries();
53
+ *
54
+ * <RefreshControl refreshing={isRefreshing} onRefresh={refresh} />
55
+ */
56
+ function useRefreshChildQueries() {
57
+ const ctx = (0, _react.useContext)(RefreshRegistryContext);
58
+ if (!ctx) {
59
+ throw new Error('useRefreshChildQueries must be used within a RefreshProvider');
60
+ }
61
+ return {
62
+ refresh: ctx.refreshAll,
63
+ isRefreshing: ctx.isRefreshing
64
+ };
65
+ }
66
+ /**
67
+ * Hook for components to register their React Query queries for refresh.
68
+ * Registered queries will be refetched when the parent calls `refresh()`.
69
+ *
70
+ * Only queries on the currently focused screen will be refreshed.
71
+ * This is handled automatically via useIsFocused().
72
+ *
73
+ * Disabled queries (enabled: false) are automatically skipped to avoid
74
+ * polluting the cache with incorrect data.
75
+ *
76
+ * @example
77
+ * const usersQ = useQuery({ queryKey: ['users'], queryFn: fetchUsers });
78
+ * const postsQ = useQuery({ queryKey: ['posts'], queryFn: fetchPosts });
79
+ *
80
+ * useRegisterRefresh([usersQ, postsQ]);
81
+ *
82
+ * // With onRefresh callback (e.g., to reset pagination)
83
+ * useRegisterRefresh([usersQ], { onRefresh: () => setPage(0) });
84
+ */
85
+ function useRegisterRefresh(queries, options) {
86
+ const ctx = (0, _react.useContext)(RefreshRegistryContext);
87
+ const isFocused = (0, _native.useIsFocused)();
88
+ const idRef = (0, _react.useRef)();
89
+ if (!idRef.current) idRef.current = Symbol('useRegisterRefresh');
90
+ const id = idRef.current;
91
+ const queriesRef = (0, _react.useRef)(queries);
92
+ queriesRef.current = queries;
93
+ const optionsRef = (0, _react.useRef)(options);
94
+ optionsRef.current = options;
95
+ const isFocusedRef = (0, _react.useRef)(isFocused);
96
+ isFocusedRef.current = isFocused;
97
+ (0, _react.useEffect)(() => {
98
+ if (!ctx) return undefined;
99
+ ctx.register(id, {
100
+ refetch: () => {
101
+ optionsRef.current?.onRefresh?.();
102
+ const enabledQueries = queriesRef.current.filter(q => q.isEnabled);
103
+ return Promise.all(enabledQueries.map(q => q.refetch()));
104
+ },
105
+ shouldRefresh: () => isFocusedRef.current
106
+ });
107
+ return () => {
108
+ ctx.unregister(id);
109
+ };
110
+ }, [ctx, id]);
111
+ }
112
+ //# sourceMappingURL=useRefreshRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_native","require","_react","_jsxRuntime","RefreshRegistryContext","createContext","RefreshProvider","children","registry","useRef","Map","isRefreshing","setIsRefreshing","useState","register","useCallback","id","entry","current","set","unregister","delete","refreshAll","entries","values","toRefresh","filter","shouldRefresh","Promise","all","map","refetch","value","useMemo","jsx","Provider","useRefreshChildQueries","ctx","useContext","Error","refresh","useRegisterRefresh","queries","options","isFocused","useIsFocused","idRef","Symbol","queriesRef","optionsRef","isFocusedRef","useEffect","undefined","onRefresh","enabledQueries","q","isEnabled"],"sourceRoot":"../../../src","sources":["hooks/useRefreshRegistry.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AASe,IAAAE,WAAA,GAAAF,OAAA;AAcf,MAAMG,sBAAsB,gBAAG,IAAAC,oBAAa,EAAoC,IAAI,CAAC;AAE9E,SAASC,eAAeA,CAAC;EAAEC;AAAkC,CAAC,EAAE;EACrE,MAAMC,QAAQ,GAAG,IAAAC,aAAM,EAA4B,IAAIC,GAAG,CAAC,CAAC,CAAC;EAC7D,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAEvD,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAAC,CAACC,EAAU,EAAEC,KAAmB,KAAK;IAChET,QAAQ,CAACU,OAAO,CAACC,GAAG,CAACH,EAAE,EAAEC,KAAK,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMG,UAAU,GAAG,IAAAL,kBAAW,EAAEC,EAAU,IAAK;IAC7CR,QAAQ,CAACU,OAAO,CAACG,MAAM,CAACL,EAAE,CAAC;EAC7B,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMM,UAAU,GAAG,IAAAP,kBAAW,EAAC,YAAY;IACzCH,eAAe,CAAC,IAAI,CAAC;IACrB,IAAI;MACF,MAAMW,OAAO,GAAG,CA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ignoreList":[]}
@@ -6,4 +6,5 @@ export * from "./useInternetConnectionStatus.js";
6
6
  export * from "./useTimezonedDate.js";
7
7
  export * from "./useAppUpdateCheck.js";
8
8
  export * from "./useCurrentTime.js";
9
+ export * from "./useRefreshRegistry.js";
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;AAAA,cAAc,qBAAkB;AAChC,cAAc,2BAAwB;AACtC,cAAc,kCAA+B;AAC7C,cAAc,uBAAoB;AAClC,cAAc,wBAAqB;AACnC,cAAc,qBAAkB","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;AAAA,cAAc,qBAAkB;AAChC,cAAc,2BAAwB;AACtC,cAAc,kCAA+B;AAC7C,cAAc,uBAAoB;AAClC,cAAc,wBAAqB;AACnC,cAAc,qBAAkB;AAChC,cAAc,yBAAsB","ignoreList":[]}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ import { useIsFocused } from '@react-navigation/native';
4
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const RefreshRegistryContext = /*#__PURE__*/createContext(null);
7
+ export function RefreshProvider({
8
+ children
9
+ }) {
10
+ const registry = useRef(new Map());
11
+ const [isRefreshing, setIsRefreshing] = useState(false);
12
+ const register = useCallback((id, entry) => {
13
+ registry.current.set(id, entry);
14
+ }, []);
15
+ const unregister = useCallback(id => {
16
+ registry.current.delete(id);
17
+ }, []);
18
+ const refreshAll = useCallback(async () => {
19
+ setIsRefreshing(true);
20
+ try {
21
+ const entries = [...registry.current.values()];
22
+ const toRefresh = entries.filter(entry => entry.shouldRefresh());
23
+ await Promise.all(toRefresh.map(entry => entry.refetch()));
24
+ } finally {
25
+ setIsRefreshing(false);
26
+ }
27
+ }, []);
28
+ const value = useMemo(() => ({
29
+ register,
30
+ unregister,
31
+ refreshAll,
32
+ isRefreshing
33
+ }), [register, unregister, refreshAll, isRefreshing]);
34
+ return /*#__PURE__*/_jsx(RefreshRegistryContext.Provider, {
35
+ value: value,
36
+ children: children
37
+ });
38
+ }
39
+
40
+ /**
41
+ * Hook for parent components to trigger refresh of all registered child queries.
42
+ * Returns `refresh()` to trigger all focused registered queries and `isRefreshing`
43
+ * to indicate progress.
44
+ *
45
+ * @example
46
+ * const { refresh, isRefreshing } = useRefreshChildQueries();
47
+ *
48
+ * <RefreshControl refreshing={isRefreshing} onRefresh={refresh} />
49
+ */
50
+ export function useRefreshChildQueries() {
51
+ const ctx = useContext(RefreshRegistryContext);
52
+ if (!ctx) {
53
+ throw new Error('useRefreshChildQueries must be used within a RefreshProvider');
54
+ }
55
+ return {
56
+ refresh: ctx.refreshAll,
57
+ isRefreshing: ctx.isRefreshing
58
+ };
59
+ }
60
+ /**
61
+ * Hook for components to register their React Query queries for refresh.
62
+ * Registered queries will be refetched when the parent calls `refresh()`.
63
+ *
64
+ * Only queries on the currently focused screen will be refreshed.
65
+ * This is handled automatically via useIsFocused().
66
+ *
67
+ * Disabled queries (enabled: false) are automatically skipped to avoid
68
+ * polluting the cache with incorrect data.
69
+ *
70
+ * @example
71
+ * const usersQ = useQuery({ queryKey: ['users'], queryFn: fetchUsers });
72
+ * const postsQ = useQuery({ queryKey: ['posts'], queryFn: fetchPosts });
73
+ *
74
+ * useRegisterRefresh([usersQ, postsQ]);
75
+ *
76
+ * // With onRefresh callback (e.g., to reset pagination)
77
+ * useRegisterRefresh([usersQ], { onRefresh: () => setPage(0) });
78
+ */
79
+ export function useRegisterRefresh(queries, options) {
80
+ const ctx = useContext(RefreshRegistryContext);
81
+ const isFocused = useIsFocused();
82
+ const idRef = useRef();
83
+ if (!idRef.current) idRef.current = Symbol('useRegisterRefresh');
84
+ const id = idRef.current;
85
+ const queriesRef = useRef(queries);
86
+ queriesRef.current = queries;
87
+ const optionsRef = useRef(options);
88
+ optionsRef.current = options;
89
+ const isFocusedRef = useRef(isFocused);
90
+ isFocusedRef.current = isFocused;
91
+ useEffect(() => {
92
+ if (!ctx) return undefined;
93
+ ctx.register(id, {
94
+ refetch: () => {
95
+ optionsRef.current?.onRefresh?.();
96
+ const enabledQueries = queriesRef.current.filter(q => q.isEnabled);
97
+ return Promise.all(enabledQueries.map(q => q.refetch()));
98
+ },
99
+ shouldRefresh: () => isFocusedRef.current
100
+ });
101
+ return () => {
102
+ ctx.unregister(id);
103
+ };
104
+ }, [ctx, id]);
105
+ }
106
+ //# sourceMappingURL=useRefreshRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useIsFocused","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","_jsx","RefreshRegistryContext","RefreshProvider","children","registry","Map","isRefreshing","setIsRefreshing","register","id","entry","current","set","unregister","delete","refreshAll","entries","values","toRefresh","filter","shouldRefresh","Promise","all","map","refetch","value","Provider","useRefreshChildQueries","ctx","Error","refresh","useRegisterRefresh","queries","options","isFocused","idRef","Symbol","queriesRef","optionsRef","isFocusedRef","undefined","onRefresh","enabledQueries","q","isEnabled"],"sourceRoot":"../../../src","sources":["hooks/useRefreshRegistry.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,0BAA0B;AAEvD,SACEC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEH,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAcf,MAAMC,sBAAsB,gBAAGT,aAAa,CAAoC,IAAI,CAAC;AAErF,OAAO,SAASU,eAAeA,CAAC;EAAEC;AAAkC,CAAC,EAAE;EACrE,MAAMC,QAAQ,GAAGP,MAAM,CAA4B,IAAIQ,GAAG,CAAC,CAAC,CAAC;EAC7D,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGT,QAAQ,CAAC,KAAK,CAAC;EAEvD,MAAMU,QAAQ,GAAGf,WAAW,CAAC,CAAC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GAAG,CAACoB,cAAc,CAACnB,GAAG,CAAEoB,CAAC,IAAKA,CAAC,CAACnB,OAAO,CAAC,CAAC,CAAC,CAAC;MAC5D,CAAC;MACDJ,aAAa,EAAEA,CAAA,KAAMmB,YAAY,CAAC5B;IACpC,CAAC,CAAC;IAEF,OAAO,MAAM;MAAEiB,GAAG,CAACf,UAAU,CAACJ,EAAE,CAAC;IAAE,CAAC;EACtC,CAAC,EAAE,CAACmB,GAAG,EAAEnB,EAAE,CAAC,CAAC;AACf","ignoreList":[]}
@@ -4,4 +4,5 @@ export * from './useInternetConnectionStatus';
4
4
  export * from './useTimezonedDate';
5
5
  export * from './useAppUpdateCheck';
6
6
  export * from './useCurrentTime';
7
+ export * from './useRefreshRegistry';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ import { ReactNode } from 'react';
3
+ export declare function RefreshProvider({ children }: {
4
+ children: ReactNode;
5
+ }): import("react").JSX.Element;
6
+ /**
7
+ * Hook for parent components to trigger refresh of all registered child queries.
8
+ * Returns `refresh()` to trigger all focused registered queries and `isRefreshing`
9
+ * to indicate progress.
10
+ *
11
+ * @example
12
+ * const { refresh, isRefreshing } = useRefreshChildQueries();
13
+ *
14
+ * <RefreshControl refreshing={isRefreshing} onRefresh={refresh} />
15
+ */
16
+ export declare function useRefreshChildQueries(): {
17
+ refresh: () => Promise<void>;
18
+ isRefreshing: boolean;
19
+ };
20
+ interface UseRegisterRefreshOptions {
21
+ onRefresh?: () => void;
22
+ }
23
+ /**
24
+ * Hook for components to register their React Query queries for refresh.
25
+ * Registered queries will be refetched when the parent calls `refresh()`.
26
+ *
27
+ * Only queries on the currently focused screen will be refreshed.
28
+ * This is handled automatically via useIsFocused().
29
+ *
30
+ * Disabled queries (enabled: false) are automatically skipped to avoid
31
+ * polluting the cache with incorrect data.
32
+ *
33
+ * @example
34
+ * const usersQ = useQuery({ queryKey: ['users'], queryFn: fetchUsers });
35
+ * const postsQ = useQuery({ queryKey: ['posts'], queryFn: fetchPosts });
36
+ *
37
+ * useRegisterRefresh([usersQ, postsQ]);
38
+ *
39
+ * // With onRefresh callback (e.g., to reset pagination)
40
+ * useRegisterRefresh([usersQ], { onRefresh: () => setPage(0) });
41
+ */
42
+ export declare function useRegisterRefresh(queries: UseQueryResult<unknown>[], options?: UseRegisterRefreshOptions): void;
43
+ export {};
44
+ //# sourceMappingURL=useRefreshRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRefreshRegistry.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useRefreshRegistry.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAQL,SAAS,EACV,MAAM,OAAO,CAAC;AAgBf,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAmCpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB;;;EASrC;AAED,UAAU,yBAAyB;IACjC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,EAClC,OAAO,CAAC,EAAE,yBAAyB,QAgCpC"}
@@ -4,4 +4,5 @@ export * from './useInternetConnectionStatus';
4
4
  export * from './useTimezonedDate';
5
5
  export * from './useAppUpdateCheck';
6
6
  export * from './useCurrentTime';
7
+ export * from './useRefreshRegistry';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ import { ReactNode } from 'react';
3
+ export declare function RefreshProvider({ children }: {
4
+ children: ReactNode;
5
+ }): import("react").JSX.Element;
6
+ /**
7
+ * Hook for parent components to trigger refresh of all registered child queries.
8
+ * Returns `refresh()` to trigger all focused registered queries and `isRefreshing`
9
+ * to indicate progress.
10
+ *
11
+ * @example
12
+ * const { refresh, isRefreshing } = useRefreshChildQueries();
13
+ *
14
+ * <RefreshControl refreshing={isRefreshing} onRefresh={refresh} />
15
+ */
16
+ export declare function useRefreshChildQueries(): {
17
+ refresh: () => Promise<void>;
18
+ isRefreshing: boolean;
19
+ };
20
+ interface UseRegisterRefreshOptions {
21
+ onRefresh?: () => void;
22
+ }
23
+ /**
24
+ * Hook for components to register their React Query queries for refresh.
25
+ * Registered queries will be refetched when the parent calls `refresh()`.
26
+ *
27
+ * Only queries on the currently focused screen will be refreshed.
28
+ * This is handled automatically via useIsFocused().
29
+ *
30
+ * Disabled queries (enabled: false) are automatically skipped to avoid
31
+ * polluting the cache with incorrect data.
32
+ *
33
+ * @example
34
+ * const usersQ = useQuery({ queryKey: ['users'], queryFn: fetchUsers });
35
+ * const postsQ = useQuery({ queryKey: ['posts'], queryFn: fetchPosts });
36
+ *
37
+ * useRegisterRefresh([usersQ, postsQ]);
38
+ *
39
+ * // With onRefresh callback (e.g., to reset pagination)
40
+ * useRegisterRefresh([usersQ], { onRefresh: () => setPage(0) });
41
+ */
42
+ export declare function useRegisterRefresh(queries: UseQueryResult<unknown>[], options?: UseRegisterRefreshOptions): void;
43
+ export {};
44
+ //# sourceMappingURL=useRefreshRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRefreshRegistry.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useRefreshRegistry.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAQL,SAAS,EACV,MAAM,OAAO,CAAC;AAgBf,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAmCpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB;;;EASrC;AAED,UAAU,yBAAyB;IACjC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,EAClC,OAAO,CAAC,EAAE,yBAAyB,QAgCpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grupalia/rn-ui-kit",
3
- "version": "0.79.0",
3
+ "version": "0.80.0",
4
4
  "description": "Grupalia React Native UI Kit",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/module/index.d.ts",