@quiltt/react 4.2.1 → 4.2.2
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/CHANGELOG.md +9 -0
- package/dist/{QuilttAuthProvider-client-DLARZukU.js → QuilttAuthProvider-client-C25Tg4_a.js} +2 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.js +5 -4
- package/dist/{useQuilttConnector-client-CacEgWJN.js → useQuilttConnector-client-BwpjuFHf.js} +3 -3
- package/dist/useQuilttInstitutions-client-CdmGK6Wv.js +89 -0
- package/dist/{useQuilttSession-client-Ddb55W0n.js → useQuilttSession-client-DhsbThvI.js} +1 -1
- package/package.json +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useQuilttInstitutions.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @quiltt/react
|
|
2
2
|
|
|
3
|
+
## 4.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#352](https://github.com/quiltt/quiltt-js/pull/352) [`45b3b32`](https://github.com/quiltt/quiltt-js/commit/45b3b3270b69b95c9553e149e15870be4f43af3b) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Fix useQuilttInstitutions export
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`45b3b32`](https://github.com/quiltt/quiltt-js/commit/45b3b3270b69b95c9553e149e15870be4f43af3b)]:
|
|
10
|
+
- @quiltt/core@4.2.2
|
|
11
|
+
|
|
3
12
|
## 4.2.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/{QuilttAuthProvider-client-DLARZukU.js → QuilttAuthProvider-client-C25Tg4_a.js}
RENAMED
|
@@ -4,9 +4,10 @@ import { JsonWebTokenParse, QuilttClient, InMemoryCache } from '@quiltt/core';
|
|
|
4
4
|
import '@apollo/client/react/hooks/useApolloClient.js';
|
|
5
5
|
import './QuilttSettings-client-BK-0SQME.js';
|
|
6
6
|
import './useSession-client-CCAvnROP.js';
|
|
7
|
+
import 'use-debounce';
|
|
7
8
|
import { jsx } from 'react/jsx-runtime';
|
|
8
9
|
import { ApolloProvider } from '@apollo/client/react/context/ApolloProvider.js';
|
|
9
|
-
import { u as useQuilttSession } from './useQuilttSession-client-
|
|
10
|
+
import { u as useQuilttSession } from './useQuilttSession-client-DhsbThvI.js';
|
|
10
11
|
|
|
11
12
|
const useIdentifySession = (auth, setSession)=>{
|
|
12
13
|
const identifySession = useCallback(async (payload, callbacks)=>{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, ConnectorSDKCallbacks } from '@quiltt/core';
|
|
1
|
+
import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, InstitutionsData, ConnectorSDKCallbacks } from '@quiltt/core';
|
|
2
2
|
export * from '@quiltt/core';
|
|
3
3
|
import { RefObject, useEffect, Dispatch, SetStateAction, FC, PropsWithChildren, JSX, ComponentType, ElementType, MouseEvent } from 'react';
|
|
4
4
|
import { useApolloClient } from '@apollo/client/react/hooks/useApolloClient.js';
|
|
@@ -66,6 +66,14 @@ declare const useQuilttConnector: (connectorId?: string, options?: ConnectorSDKC
|
|
|
66
66
|
open: () => void;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
type UseQuilttInstitutions = (connectorId: string, onErrorCallback?: (msg: string) => void) => {
|
|
70
|
+
searchTerm: string;
|
|
71
|
+
searchResults: InstitutionsData;
|
|
72
|
+
isSearching: boolean;
|
|
73
|
+
setSearchTerm: (term: string) => void;
|
|
74
|
+
};
|
|
75
|
+
declare const useQuilttInstitutions: UseQuilttInstitutions;
|
|
76
|
+
|
|
69
77
|
type UseQuilttSession = (environmentId?: string) => {
|
|
70
78
|
session: Maybe<QuilttJWT> | undefined;
|
|
71
79
|
importSession: ImportSession;
|
|
@@ -176,5 +184,5 @@ type QuilttContainerProps<T extends ElementType> = PropsWithChildren<{
|
|
|
176
184
|
*/
|
|
177
185
|
declare const QuilttContainer: <T extends ElementType = "div">({ as, connectorId, connectionId, forceRemountOnConnectionChange, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props }: QuilttContainerProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
|
|
178
186
|
|
|
179
|
-
export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
|
|
180
|
-
export type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession, SetSession, UseQuilttSession };
|
|
187
|
+
export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttInstitutions, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
|
|
188
|
+
export type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession, SetSession, UseQuilttInstitutions, UseQuilttSession };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export * from '@quiltt/core';
|
|
2
2
|
export { u as useEventListener } from './useEventListener-client-DVM5xwKY.js';
|
|
3
3
|
export { u as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-client-DeTHOKz1.js';
|
|
4
|
-
import { Q as QuilttAuthProvider, i as isDeepEqual } from './QuilttAuthProvider-client-
|
|
5
|
-
export { b as useAuthenticateSession, a as useIdentifySession, u as useImportSession, c as useRevokeSession } from './QuilttAuthProvider-client-
|
|
4
|
+
import { Q as QuilttAuthProvider, i as isDeepEqual } from './QuilttAuthProvider-client-C25Tg4_a.js';
|
|
5
|
+
export { b as useAuthenticateSession, a as useIdentifySession, u as useImportSession, c as useRevokeSession } from './QuilttAuthProvider-client-C25Tg4_a.js';
|
|
6
6
|
export { u as useQuilttClient } from './useQuilttClient-client-CAAUait1.js';
|
|
7
|
-
import { u as useQuilttConnector } from './useQuilttConnector-client-
|
|
8
|
-
export { u as
|
|
7
|
+
import { u as useQuilttConnector } from './useQuilttConnector-client-BwpjuFHf.js';
|
|
8
|
+
export { u as useQuilttInstitutions } from './useQuilttInstitutions-client-CdmGK6Wv.js';
|
|
9
|
+
export { u as useQuilttSession } from './useQuilttSession-client-DhsbThvI.js';
|
|
9
10
|
export { u as useQuilttSettings } from './useQuilttSettings-client-BOCBjFXe.js';
|
|
10
11
|
export { u as useSession } from './useSession-client-CCAvnROP.js';
|
|
11
12
|
export { u as useStorage } from './useStorage-client-DHcq3Kuh.js';
|
package/dist/{useQuilttConnector-client-CacEgWJN.js → useQuilttConnector-client-BwpjuFHf.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { cdnBase } from '@quiltt/core';
|
|
4
|
-
import { u as useQuilttSession } from './useQuilttSession-client-
|
|
4
|
+
import { u as useQuilttSession } from './useQuilttSession-client-DhsbThvI.js';
|
|
5
5
|
import { u as useScript } from './useScript-client-JCgaTW9n.js';
|
|
6
6
|
|
|
7
|
-
var version = "4.2.
|
|
7
|
+
var version = "4.2.2";
|
|
8
8
|
|
|
9
9
|
const useQuilttConnector = (connectorId, options)=>{
|
|
10
10
|
const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`, {
|
|
@@ -150,4 +150,4 @@ const useQuilttConnector = (connectorId, options)=>{
|
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
export { useQuilttConnector as u };
|
|
153
|
+
export { useQuilttConnector as u, version as v };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useMemo, useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { useDebounce } from 'use-debounce';
|
|
4
|
+
import { InstitutionsAPI } from '@quiltt/core';
|
|
5
|
+
import { v as version } from './useQuilttConnector-client-BwpjuFHf.js';
|
|
6
|
+
import { u as useSession } from './useSession-client-CCAvnROP.js';
|
|
7
|
+
|
|
8
|
+
const useQuilttInstitutions = (connectorId, onErrorCallback)=>{
|
|
9
|
+
const agent = useMemo(()=>{
|
|
10
|
+
// Try deprecated navigator.product first (still used in some RN versions)
|
|
11
|
+
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
12
|
+
return `react-native-${version}`;
|
|
13
|
+
}
|
|
14
|
+
// Detect React Native by its unique environment characteristics
|
|
15
|
+
const isReactNative = !!// Has window (unlike Node.js)
|
|
16
|
+
(typeof window !== 'undefined' && // No document in window (unlike browsers)
|
|
17
|
+
typeof window.document === 'undefined' && // Has navigator (unlike Node.js)
|
|
18
|
+
typeof navigator !== 'undefined');
|
|
19
|
+
return isReactNative ? `react-native-${version}` : `react-${version}`;
|
|
20
|
+
}, []);
|
|
21
|
+
const institutionsAPI = useMemo(()=>new InstitutionsAPI(connectorId, agent), [
|
|
22
|
+
connectorId,
|
|
23
|
+
agent
|
|
24
|
+
]);
|
|
25
|
+
const [session] = useSession();
|
|
26
|
+
const [searchTermInput, setSearchTermInput] = useState('');
|
|
27
|
+
const [searchTerm] = useDebounce(searchTermInput, 350);
|
|
28
|
+
const [searchResults, setSearchResults] = useState([]);
|
|
29
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
30
|
+
/**
|
|
31
|
+
* Start Search
|
|
32
|
+
* This function is used to initiate a search for institutions based on the provided term with
|
|
33
|
+
* a minimum length of 2 characters. Debouncing is applied to avoid excessive API calls.
|
|
34
|
+
*/ const startSearch = useCallback((term)=>{
|
|
35
|
+
if (term.trim().length < 2) {
|
|
36
|
+
setSearchResults([]);
|
|
37
|
+
setIsSearching(false);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setIsSearching(true);
|
|
41
|
+
setSearchTermInput(term);
|
|
42
|
+
}, []);
|
|
43
|
+
const handleError = useCallback((message)=>{
|
|
44
|
+
const errorMessage = message || 'Unknown error occurred while searching institutions';
|
|
45
|
+
console.error('Quiltt Institutions Search Error:', errorMessage);
|
|
46
|
+
if (onErrorCallback) onErrorCallback(errorMessage);
|
|
47
|
+
}, [
|
|
48
|
+
onErrorCallback
|
|
49
|
+
]);
|
|
50
|
+
/**
|
|
51
|
+
* Run Search
|
|
52
|
+
* This effect will run when the searchTerm changes and is at least 2 characters long.
|
|
53
|
+
*/ useEffect(()=>{
|
|
54
|
+
if (!session?.token || !connectorId || !searchTerm || searchTerm.trim().length < 2) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const abortController = new AbortController();
|
|
58
|
+
institutionsAPI.search(session?.token, connectorId, searchTerm, abortController.signal).then((response)=>{
|
|
59
|
+
if (!abortController.signal.aborted) {
|
|
60
|
+
if (response.status === 200) {
|
|
61
|
+
setSearchResults(response.data);
|
|
62
|
+
} else {
|
|
63
|
+
handleError(response.data.message || 'Failed to fetch institutions');
|
|
64
|
+
}
|
|
65
|
+
setIsSearching(false);
|
|
66
|
+
}
|
|
67
|
+
}).catch((error)=>{
|
|
68
|
+
if (!abortController.signal.aborted) {
|
|
69
|
+
handleError(error.message);
|
|
70
|
+
setIsSearching(false);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return ()=>abortController.abort();
|
|
74
|
+
}, [
|
|
75
|
+
session?.token,
|
|
76
|
+
connectorId,
|
|
77
|
+
searchTerm,
|
|
78
|
+
institutionsAPI,
|
|
79
|
+
handleError
|
|
80
|
+
]);
|
|
81
|
+
return {
|
|
82
|
+
searchTerm,
|
|
83
|
+
searchResults,
|
|
84
|
+
isSearching,
|
|
85
|
+
setSearchTerm: startSearch
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { useQuilttInstitutions as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { AuthAPI } from '@quiltt/core';
|
|
4
|
-
import { u as useImportSession, a as useIdentifySession, b as useAuthenticateSession, c as useRevokeSession } from './QuilttAuthProvider-client-
|
|
4
|
+
import { u as useImportSession, a as useIdentifySession, b as useAuthenticateSession, c as useRevokeSession } from './QuilttAuthProvider-client-C25Tg4_a.js';
|
|
5
5
|
import { u as useQuilttSettings } from './useQuilttSettings-client-BOCBjFXe.js';
|
|
6
6
|
import { u as useSession } from './useSession-client-CCAvnROP.js';
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quiltt/react",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "React Components and Hooks for Quiltt Connector",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"quiltt",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@apollo/client": "^3.12.4",
|
|
38
38
|
"use-debounce": "^10.0.4",
|
|
39
|
-
"@quiltt/core": "4.2.
|
|
39
|
+
"@quiltt/core": "4.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@biomejs/biome": "1.9.4",
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './helpers'
|
|
|
2
2
|
export * from './session'
|
|
3
3
|
export * from './useQuilttClient'
|
|
4
4
|
export * from './useQuilttConnector'
|
|
5
|
+
export * from './useQuilttInstitutions'
|
|
5
6
|
export * from './useQuilttSession'
|
|
6
7
|
export * from './useQuilttSettings'
|
|
7
8
|
export * from './useSession'
|
|
@@ -7,7 +7,7 @@ import { useDebounce } from 'use-debounce'
|
|
|
7
7
|
import { InstitutionsAPI } from '@quiltt/core'
|
|
8
8
|
import type { ErrorData, InstitutionsData } from '@quiltt/core'
|
|
9
9
|
|
|
10
|
-
import { version } from '
|
|
10
|
+
import { version } from '../version'
|
|
11
11
|
import useSession from './useSession'
|
|
12
12
|
|
|
13
13
|
export type UseQuilttInstitutions = (
|