@quiltt/react 5.0.0 → 5.0.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 +26 -0
- package/README.md +12 -0
- package/dist/components/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
- package/dist/components/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
- package/dist/components/index.cjs +212 -0
- package/dist/components/index.d.ts +56 -0
- package/dist/components/index.js +209 -0
- package/dist/{useQuilttConnector-12s-DfCZ1lpS.js → components/useQuilttConnector-12s-3VgurfwU.js} +6 -77
- package/dist/components/useQuilttConnector-12s-zU4NFJ-H.cjs +174 -0
- package/dist/components/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
- package/dist/components/useQuilttSession-12s-BjyJL1qZ.cjs +133 -0
- package/dist/components/useQuilttSession-12s-VOH0S5zh.js +133 -0
- package/dist/components/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
- package/dist/components/useScript-12s-CMIDUHrx.cjs +92 -0
- package/dist/{useSession-12s-BlrWOArd.js → components/useSession-12s-BNPsfKY-.js} +27 -6
- package/dist/components/useSession-12s-BNotXj5T.cjs +90 -0
- package/dist/components/useStorage-12s-D7nllsrI.cjs +61 -0
- package/dist/contexts/QuilttSettings-12s-BK-0SQME.js +6 -0
- package/dist/contexts/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
- package/dist/contexts/index.cjs +7 -0
- package/dist/contexts/index.d.ts +8 -0
- package/dist/contexts/index.js +1 -0
- package/dist/hooks/QuilttProviderRender-12s-DtQtubjL.js +6 -0
- package/dist/hooks/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
- package/dist/hooks/QuilttSettings-12s-BK-0SQME.js +6 -0
- package/dist/hooks/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
- package/dist/hooks/index.cjs +31 -0
- package/dist/hooks/index.d.ts +142 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/useEventListener-12s-CV8cLxWu.cjs +34 -0
- package/dist/hooks/useIsomorphicLayoutEffect-12s-B8KjaroI.cjs +9 -0
- package/dist/hooks/useQuilttClient-12s-flQYSVdG.cjs +6 -0
- package/dist/hooks/useQuilttConnector-12s-BLZ0GoAH.js +174 -0
- package/dist/hooks/useQuilttConnector-12s-sP-k4D3J.cjs +175 -0
- package/dist/hooks/useQuilttInstitutions-12s-BU_Vm7TY.cjs +82 -0
- package/dist/{useQuilttInstitutions-12s-ClSQJPmP.js → hooks/useQuilttInstitutions-12s-ByXIt9W6.js} +3 -2
- package/dist/hooks/useQuilttRenderGuard-12s-CsS2Ma6Q.js +36 -0
- package/dist/hooks/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
- package/dist/{useQuilttResolvable-12s-Dm4vsARj.js → hooks/useQuilttResolvable-12s-C5DByktm.js} +3 -2
- package/dist/hooks/useQuilttResolvable-12s-CGEfKPVU.cjs +76 -0
- package/dist/hooks/useQuilttSession-12s-C8kq5S2Y.cjs +139 -0
- package/dist/{useQuilttSession-12s-_8sB_8aP.js → hooks/useQuilttSession-12s-DQFfjmob.js} +1 -1
- package/dist/hooks/useQuilttSettings-12s--rCJoNHD.js +10 -0
- package/dist/hooks/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
- package/dist/hooks/useScript-12s-CMIDUHrx.cjs +92 -0
- package/dist/hooks/useScript-12s-JCgaTW9n.js +92 -0
- package/dist/hooks/useSession-12s-BNPsfKY-.js +90 -0
- package/dist/hooks/useSession-12s-BNotXj5T.cjs +90 -0
- package/dist/hooks/useStorage-12s-CpG6X57D.js +61 -0
- package/dist/hooks/useStorage-12s-D7nllsrI.cjs +61 -0
- package/dist/index.cjs +149 -0
- package/dist/index.d.ts +3 -216
- package/dist/index.js +3 -190
- package/dist/{QuilttAuthProvider-12s-C_Wt9rkK.js → providers/QuilttAuthProvider-12s-CDgQbarX.js} +14 -12
- package/dist/providers/QuilttAuthProvider-12s-D__FY1Qn.cjs +60 -0
- package/dist/providers/QuilttProviderRender-12s-DtQtubjL.js +6 -0
- package/dist/providers/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
- package/dist/providers/QuilttSettings-12s-BK-0SQME.js +6 -0
- package/dist/providers/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
- package/dist/providers/QuilttSettingsProvider-12s-D7e8dsOE.cjs +19 -0
- package/dist/{QuilttSettingsProvider-12s-ZcmFmOiZ.js → providers/QuilttSettingsProvider-12s-DND2gPQm.js} +8 -5
- package/dist/providers/index.cjs +34 -0
- package/dist/providers/index.d.ts +28 -0
- package/dist/providers/index.js +30 -0
- package/dist/utils/index.cjs +89 -0
- package/dist/utils/index.d.ts +31 -0
- package/dist/utils/index.js +77 -0
- package/package.json +33 -7
- package/src/components/QuilttContainer.tsx +3 -0
- package/src/hooks/useSession.ts +32 -6
- package/src/providers/QuilttAuthProvider.tsx +8 -2
- package/src/providers/QuilttProvider.tsx +5 -1
- package/src/providers/QuilttSettingsProvider.tsx +4 -5
- /package/dist/{QuilttProviderRender-12s-DtQtubjL.js → components/QuilttProviderRender-12s-DtQtubjL.js} +0 -0
- /package/dist/{QuilttSettings-12s-BK-0SQME.js → components/QuilttSettings-12s-BK-0SQME.js} +0 -0
- /package/dist/{useQuilttRenderGuard-12s-CsS2Ma6Q.js → components/useQuilttRenderGuard-12s-CsS2Ma6Q.js} +0 -0
- /package/dist/{useQuilttSettings-12s--rCJoNHD.js → components/useQuilttSettings-12s--rCJoNHD.js} +0 -0
- /package/dist/{useScript-12s-JCgaTW9n.js → components/useScript-12s-JCgaTW9n.js} +0 -0
- /package/dist/{useStorage-12s-CpG6X57D.js → components/useStorage-12s-CpG6X57D.js} +0 -0
- /package/dist/{useEventListener-12s-D_-6QIXa.js → hooks/useEventListener-12s-D_-6QIXa.js} +0 -0
- /package/dist/{useIsomorphicLayoutEffect-12s-DeTHOKz1.js → hooks/useIsomorphicLayoutEffect-12s-DeTHOKz1.js} +0 -0
- /package/dist/{useQuilttClient-12s-Dj_MtYTU.js → hooks/useQuilttClient-12s-Dj_MtYTU.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @quiltt/react
|
|
2
2
|
|
|
3
|
+
## 5.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#407](https://github.com/quiltt/quiltt-js/pull/407) [`0262754`](https://github.com/quiltt/quiltt-js/commit/0262754fa680d39cea1426a09796783488a4f4d6) Thanks [@rubendinho](https://github.com/rubendinho)! - Add Institution Prop to QuilttContainer
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`0262754`](https://github.com/quiltt/quiltt-js/commit/0262754fa680d39cea1426a09796783488a4f4d6)]:
|
|
10
|
+
- @quiltt/core@5.0.2
|
|
11
|
+
|
|
12
|
+
## 5.0.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#403](https://github.com/quiltt/quiltt-js/pull/403) [`b714ff3`](https://github.com/quiltt/quiltt-js/commit/b714ff3b3ee878445ca8e09903153ac0b43d693b) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Prevent Infinite Re-Renders in QuilttProvider
|
|
17
|
+
|
|
18
|
+
- [#399](https://github.com/quiltt/quiltt-js/pull/399) [`77d11b6`](https://github.com/quiltt/quiltt-js/commit/77d11b69ceb950da9ca500aa73bae7a3abdfb3a2) Thanks [@CarltonHowell](https://github.com/CarltonHowell)! - Output commonJS
|
|
19
|
+
|
|
20
|
+
- [#402](https://github.com/quiltt/quiltt-js/pull/402) [`97eccbe`](https://github.com/quiltt/quiltt-js/commit/97eccbe6df42843307a11d28a0a8b5a36e43f3d9) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Remove Node.js Dependencies in React Native Builds
|
|
21
|
+
|
|
22
|
+
- [#401](https://github.com/quiltt/quiltt-js/pull/401) [`2bf07c3`](https://github.com/quiltt/quiltt-js/commit/2bf07c36bf8dc573f01db8f4c69a48e05d313b8b) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Improve expired auth token detection and clearing
|
|
23
|
+
|
|
24
|
+
- [#404](https://github.com/quiltt/quiltt-js/pull/404) [`45eb8c9`](https://github.com/quiltt/quiltt-js/commit/45eb8c907f51c0c8c5a3c069c35e0f301a4c374f) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Add Subpath Exports and Reorganize Core Modules
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`b714ff3`](https://github.com/quiltt/quiltt-js/commit/b714ff3b3ee878445ca8e09903153ac0b43d693b), [`77d11b6`](https://github.com/quiltt/quiltt-js/commit/77d11b69ceb950da9ca500aa73bae7a3abdfb3a2), [`97eccbe`](https://github.com/quiltt/quiltt-js/commit/97eccbe6df42843307a11d28a0a8b5a36e43f3d9), [`2bf07c3`](https://github.com/quiltt/quiltt-js/commit/2bf07c36bf8dc573f01db8f4c69a48e05d313b8b), [`45eb8c9`](https://github.com/quiltt/quiltt-js/commit/45eb8c907f51c0c8c5a3c069c35e0f301a4c374f)]:
|
|
27
|
+
- @quiltt/core@5.0.1
|
|
28
|
+
|
|
3
29
|
## 5.0.0
|
|
4
30
|
|
|
5
31
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -37,6 +37,12 @@ The `@quiltt/react` library ships with `@quiltt/core`, which provides an API cli
|
|
|
37
37
|
|
|
38
38
|
All components automatically handle Session token management under the hood, using the `useQuilttSession` hook.
|
|
39
39
|
|
|
40
|
+
For better tree-shaking, you can import components from subpaths:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { QuilttButton } from '@quiltt/react/components'
|
|
44
|
+
```
|
|
45
|
+
|
|
40
46
|
To pre-authenticate the Connector for one of your user profiles, make sure to set your token using the `QuilttProvider` provider or the `useQuilttSession` hook. See the [Authentication guides](https://www.quiltt.dev/authentication) for how to generate a Session.
|
|
41
47
|
|
|
42
48
|
### QuilttButton
|
|
@@ -128,6 +134,12 @@ export default Layout
|
|
|
128
134
|
|
|
129
135
|
For maximum control over the lifecycle of Quiltt Connector and Quiltt Sessions, you can also use hooks directly.
|
|
130
136
|
|
|
137
|
+
For better tree-shaking, you can import hooks from subpaths:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { useQuilttSession } from '@quiltt/react/hooks'
|
|
141
|
+
```
|
|
142
|
+
|
|
131
143
|
### useQuilttConnector
|
|
132
144
|
|
|
133
145
|
A hook to manage the lifecycle of [Quiltt Connector](https://www.quiltt.dev/connector).
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var useQuilttConnector12s = require('./useQuilttConnector-12s-zU4NFJ-H.cjs');
|
|
6
|
+
var useQuilttRenderGuard12s = require('./useQuilttRenderGuard-12s-D9WbRzZO.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Performs a deep equality comparison between two values
|
|
10
|
+
*
|
|
11
|
+
* This function recursively compares all properties to determine if they are equal.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true
|
|
16
|
+
* isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } }) // false
|
|
17
|
+
* ```
|
|
18
|
+
*/ const isDeepEqual = (obj1, obj2)=>{
|
|
19
|
+
// Handle primitive types and null/undefined
|
|
20
|
+
if (obj1 === obj2) return true;
|
|
21
|
+
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
|
|
22
|
+
// Handle special object types
|
|
23
|
+
if (obj1 instanceof Date && obj2 instanceof Date) {
|
|
24
|
+
return obj1.getTime() === obj2.getTime();
|
|
25
|
+
}
|
|
26
|
+
if (obj1 instanceof RegExp && obj2 instanceof RegExp) {
|
|
27
|
+
return obj1.toString() === obj2.toString();
|
|
28
|
+
}
|
|
29
|
+
if (obj1 instanceof Map && obj2 instanceof Map) {
|
|
30
|
+
if (obj1.size !== obj2.size) return false;
|
|
31
|
+
for (const [key, value] of obj1){
|
|
32
|
+
if (!obj2.has(key) || !isDeepEqual(value, obj2.get(key))) return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (obj1 instanceof Set && obj2 instanceof Set) {
|
|
37
|
+
if (obj1.size !== obj2.size) return false;
|
|
38
|
+
const arr2 = Array.from(obj2);
|
|
39
|
+
for (const item of obj1){
|
|
40
|
+
if (!arr2.some((value)=>isDeepEqual(item, value))) return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
// Handle arrays
|
|
45
|
+
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
46
|
+
if (obj1.length !== obj2.length) return false;
|
|
47
|
+
return obj1.every((value, index)=>isDeepEqual(value, obj2[index]));
|
|
48
|
+
}
|
|
49
|
+
// If one is array and other isn't, they're not equal
|
|
50
|
+
if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
|
|
51
|
+
const keys1 = Object.keys(obj1);
|
|
52
|
+
const keys2 = Object.keys(obj2);
|
|
53
|
+
if (keys1.length !== keys2.length) return false;
|
|
54
|
+
return keys1.every((key)=>{
|
|
55
|
+
return Object.hasOwn(obj2, key) && isDeepEqual(obj1[key], obj2[key]);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* QuilttButton provides a clickable interface to open Quiltt connectors.
|
|
61
|
+
*
|
|
62
|
+
* When connectionId changes, the button will automatically update the existing
|
|
63
|
+
* connector instance with the new connection details. If you need to force a
|
|
64
|
+
* complete remount instead, set forceRemountOnConnectionChange to true.
|
|
65
|
+
*/ const QuilttButton = ({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange = false, onEvent, onOpen, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, onClick, onHtmlLoad, children, ...props })=>{
|
|
66
|
+
// Check flag to warn about potential anti-pattern (may produce false positives for valid nested patterns)
|
|
67
|
+
useQuilttRenderGuard12s.useQuilttRenderGuard('QuilttButton');
|
|
68
|
+
// Keep track of previous connectionId for change detection
|
|
69
|
+
const prevConnectionIdRef = react.useRef(connectionId);
|
|
70
|
+
const prevCallbacksRef = react.useRef({
|
|
71
|
+
onEvent,
|
|
72
|
+
onOpen,
|
|
73
|
+
onLoad,
|
|
74
|
+
onExit,
|
|
75
|
+
onExitSuccess,
|
|
76
|
+
onExitAbort,
|
|
77
|
+
onExitError
|
|
78
|
+
});
|
|
79
|
+
// Track if callbacks have changed to help with debugging
|
|
80
|
+
const currentCallbacks = {
|
|
81
|
+
onEvent,
|
|
82
|
+
onOpen,
|
|
83
|
+
onLoad,
|
|
84
|
+
onExit,
|
|
85
|
+
onExitSuccess,
|
|
86
|
+
onExitAbort,
|
|
87
|
+
onExitError
|
|
88
|
+
};
|
|
89
|
+
const callbacksChanged = !isDeepEqual(prevCallbacksRef.current, currentCallbacks);
|
|
90
|
+
react.useEffect(()=>{
|
|
91
|
+
prevCallbacksRef.current = currentCallbacks;
|
|
92
|
+
});
|
|
93
|
+
// Warning for potential callback reference issues
|
|
94
|
+
react.useEffect(()=>{
|
|
95
|
+
if (callbacksChanged && prevConnectionIdRef.current !== undefined) {
|
|
96
|
+
console.warn('[Quiltt] Callback functions changed after initial render. ' + 'This may cause unexpected behavior. Consider memoizing callback functions ' + 'with useCallback to maintain stable references.');
|
|
97
|
+
}
|
|
98
|
+
}, [
|
|
99
|
+
callbacksChanged
|
|
100
|
+
]);
|
|
101
|
+
const { open } = useQuilttConnector12s.useQuilttConnector(connectorId, {
|
|
102
|
+
connectionId,
|
|
103
|
+
institution,
|
|
104
|
+
nonce: props?.nonce,
|
|
105
|
+
onEvent,
|
|
106
|
+
onOpen,
|
|
107
|
+
onLoad,
|
|
108
|
+
onExit,
|
|
109
|
+
onExitSuccess,
|
|
110
|
+
onExitAbort,
|
|
111
|
+
onExitError
|
|
112
|
+
});
|
|
113
|
+
// Update previous connectionId reference
|
|
114
|
+
react.useEffect(()=>{
|
|
115
|
+
prevConnectionIdRef.current = connectionId;
|
|
116
|
+
}, [
|
|
117
|
+
connectionId
|
|
118
|
+
]);
|
|
119
|
+
const Button = as || 'button';
|
|
120
|
+
const handleClick = (event)=>{
|
|
121
|
+
// Call the user's onClick handler first to allow for:
|
|
122
|
+
// 1. Pre-open validation
|
|
123
|
+
// 2. Preventing opening via event.preventDefault()
|
|
124
|
+
// 3. Setting up state before connector opens
|
|
125
|
+
onClick?.(event);
|
|
126
|
+
// Only open if event wasn't prevented
|
|
127
|
+
if (!event.defaultPrevented) {
|
|
128
|
+
open();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
// Generate key for forced remounting if enabled, but respect user-provided key
|
|
132
|
+
const buttonKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
|
|
133
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Button, {
|
|
134
|
+
onClick: handleClick,
|
|
135
|
+
onLoad: onHtmlLoad,
|
|
136
|
+
"quiltt-connection": connectionId,
|
|
137
|
+
...props,
|
|
138
|
+
children: children
|
|
139
|
+
}, buttonKey);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* QuilttContainer uses globally shared callbacks. It's recommended you only use
|
|
144
|
+
* one Container at a time.
|
|
145
|
+
*
|
|
146
|
+
* When connectionId changes, the container will automatically update the existing
|
|
147
|
+
* connector instance with the new connection details. If you need to force a
|
|
148
|
+
* complete remount instead, set forceRemountOnConnectionChange to true.
|
|
149
|
+
*/ const QuilttContainer = ({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange = false, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props })=>{
|
|
150
|
+
// Check flag to warn about potential anti-pattern (may produce false positives for valid nested patterns)
|
|
151
|
+
useQuilttRenderGuard12s.useQuilttRenderGuard('QuilttContainer');
|
|
152
|
+
// Keep track of previous connectionId for change detection
|
|
153
|
+
const prevConnectionIdRef = react.useRef(connectionId);
|
|
154
|
+
const prevCallbacksRef = react.useRef({
|
|
155
|
+
onEvent,
|
|
156
|
+
onLoad,
|
|
157
|
+
onExit,
|
|
158
|
+
onExitSuccess,
|
|
159
|
+
onExitAbort,
|
|
160
|
+
onExitError
|
|
161
|
+
});
|
|
162
|
+
// Track if callbacks have changed to help with debugging
|
|
163
|
+
const currentCallbacks = {
|
|
164
|
+
onEvent,
|
|
165
|
+
onLoad,
|
|
166
|
+
onExit,
|
|
167
|
+
onExitSuccess,
|
|
168
|
+
onExitAbort,
|
|
169
|
+
onExitError
|
|
170
|
+
};
|
|
171
|
+
const callbacksChanged = !isDeepEqual(prevCallbacksRef.current, currentCallbacks);
|
|
172
|
+
react.useEffect(()=>{
|
|
173
|
+
prevCallbacksRef.current = currentCallbacks;
|
|
174
|
+
});
|
|
175
|
+
// Warning for potential callback reference issues
|
|
176
|
+
react.useEffect(()=>{
|
|
177
|
+
if (callbacksChanged && prevConnectionIdRef.current !== undefined) {
|
|
178
|
+
console.warn('[Quiltt] Callback functions changed after initial render. ' + 'This may cause unexpected behavior. Consider memoizing callback functions ' + 'with useCallback to maintain stable references.');
|
|
179
|
+
}
|
|
180
|
+
}, [
|
|
181
|
+
callbacksChanged
|
|
182
|
+
]);
|
|
183
|
+
useQuilttConnector12s.useQuilttConnector(connectorId, {
|
|
184
|
+
connectionId,
|
|
185
|
+
institution,
|
|
186
|
+
nonce: props?.nonce,
|
|
187
|
+
onEvent,
|
|
188
|
+
onLoad,
|
|
189
|
+
onExit,
|
|
190
|
+
onExitSuccess,
|
|
191
|
+
onExitAbort,
|
|
192
|
+
onExitError
|
|
193
|
+
});
|
|
194
|
+
// Update previous connectionId reference
|
|
195
|
+
react.useEffect(()=>{
|
|
196
|
+
prevConnectionIdRef.current = connectionId;
|
|
197
|
+
}, [
|
|
198
|
+
connectionId
|
|
199
|
+
]);
|
|
200
|
+
const Container = as || 'div';
|
|
201
|
+
// Generate key for forced remounting if enabled, but respect user-provided key
|
|
202
|
+
const containerKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
|
|
203
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Container, {
|
|
204
|
+
"quiltt-container": connectorId,
|
|
205
|
+
"quiltt-connection": connectionId,
|
|
206
|
+
...props,
|
|
207
|
+
children: children
|
|
208
|
+
}, containerKey);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
exports.QuilttButton = QuilttButton;
|
|
212
|
+
exports.QuilttContainer = QuilttContainer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { JSX, ComponentType, ElementType, PropsWithChildren, MouseEvent } from 'react';
|
|
3
|
+
import { ConnectorSDKCallbacks } from '@quiltt/core';
|
|
4
|
+
|
|
5
|
+
type PropsOf<Tag> = Tag extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[Tag] : Tag extends ComponentType<infer Props> ? Props & JSX.IntrinsicAttributes : never;
|
|
6
|
+
|
|
7
|
+
type BaseQuilttButtonProps<T extends ElementType> = {
|
|
8
|
+
as?: T;
|
|
9
|
+
connectorId: string;
|
|
10
|
+
connectionId?: string;
|
|
11
|
+
institution?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Forces complete remount when connectionId changes.
|
|
14
|
+
* Useful as a fallback for ensuring clean state.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
forceRemountOnConnectionChange?: boolean;
|
|
18
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
19
|
+
};
|
|
20
|
+
type QuilttCallbackProps = Omit<ConnectorSDKCallbacks, 'onLoad'> & {
|
|
21
|
+
onLoad?: ConnectorSDKCallbacks['onLoad'];
|
|
22
|
+
onHtmlLoad?: React.ReactEventHandler<HTMLElement>;
|
|
23
|
+
};
|
|
24
|
+
type QuilttButtonProps<T extends ElementType> = PropsWithChildren<BaseQuilttButtonProps<T> & QuilttCallbackProps>;
|
|
25
|
+
/**
|
|
26
|
+
* QuilttButton provides a clickable interface to open Quiltt connectors.
|
|
27
|
+
*
|
|
28
|
+
* When connectionId changes, the button will automatically update the existing
|
|
29
|
+
* connector instance with the new connection details. If you need to force a
|
|
30
|
+
* complete remount instead, set forceRemountOnConnectionChange to true.
|
|
31
|
+
*/
|
|
32
|
+
declare const QuilttButton: <T extends ElementType = "button">({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange, onEvent, onOpen, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, onClick, onHtmlLoad, children, ...props }: QuilttButtonProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
type QuilttContainerProps<T extends ElementType> = PropsWithChildren<{
|
|
35
|
+
as?: T;
|
|
36
|
+
connectorId: string;
|
|
37
|
+
connectionId?: string;
|
|
38
|
+
institution?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Forces complete remount when connectionId changes.
|
|
41
|
+
* Useful as a fallback for ensuring clean state.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
forceRemountOnConnectionChange?: boolean;
|
|
45
|
+
} & ConnectorSDKCallbacks>;
|
|
46
|
+
/**
|
|
47
|
+
* QuilttContainer uses globally shared callbacks. It's recommended you only use
|
|
48
|
+
* one Container at a time.
|
|
49
|
+
*
|
|
50
|
+
* When connectionId changes, the container will automatically update the existing
|
|
51
|
+
* connector instance with the new connection details. If you need to force a
|
|
52
|
+
* complete remount instead, set forceRemountOnConnectionChange to true.
|
|
53
|
+
*/
|
|
54
|
+
declare const QuilttContainer: <T extends ElementType = "div">({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props }: QuilttContainerProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
|
|
55
|
+
|
|
56
|
+
export { QuilttButton, QuilttContainer };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { u as useQuilttConnector } from './useQuilttConnector-12s-3VgurfwU.js';
|
|
4
|
+
import { u as useQuilttRenderGuard } from './useQuilttRenderGuard-12s-CsS2Ma6Q.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Performs a deep equality comparison between two values
|
|
8
|
+
*
|
|
9
|
+
* This function recursively compares all properties to determine if they are equal.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true
|
|
14
|
+
* isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } }) // false
|
|
15
|
+
* ```
|
|
16
|
+
*/ const isDeepEqual = (obj1, obj2)=>{
|
|
17
|
+
// Handle primitive types and null/undefined
|
|
18
|
+
if (obj1 === obj2) return true;
|
|
19
|
+
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
|
|
20
|
+
// Handle special object types
|
|
21
|
+
if (obj1 instanceof Date && obj2 instanceof Date) {
|
|
22
|
+
return obj1.getTime() === obj2.getTime();
|
|
23
|
+
}
|
|
24
|
+
if (obj1 instanceof RegExp && obj2 instanceof RegExp) {
|
|
25
|
+
return obj1.toString() === obj2.toString();
|
|
26
|
+
}
|
|
27
|
+
if (obj1 instanceof Map && obj2 instanceof Map) {
|
|
28
|
+
if (obj1.size !== obj2.size) return false;
|
|
29
|
+
for (const [key, value] of obj1){
|
|
30
|
+
if (!obj2.has(key) || !isDeepEqual(value, obj2.get(key))) return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (obj1 instanceof Set && obj2 instanceof Set) {
|
|
35
|
+
if (obj1.size !== obj2.size) return false;
|
|
36
|
+
const arr2 = Array.from(obj2);
|
|
37
|
+
for (const item of obj1){
|
|
38
|
+
if (!arr2.some((value)=>isDeepEqual(item, value))) return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
// Handle arrays
|
|
43
|
+
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
44
|
+
if (obj1.length !== obj2.length) return false;
|
|
45
|
+
return obj1.every((value, index)=>isDeepEqual(value, obj2[index]));
|
|
46
|
+
}
|
|
47
|
+
// If one is array and other isn't, they're not equal
|
|
48
|
+
if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
|
|
49
|
+
const keys1 = Object.keys(obj1);
|
|
50
|
+
const keys2 = Object.keys(obj2);
|
|
51
|
+
if (keys1.length !== keys2.length) return false;
|
|
52
|
+
return keys1.every((key)=>{
|
|
53
|
+
return Object.hasOwn(obj2, key) && isDeepEqual(obj1[key], obj2[key]);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* QuilttButton provides a clickable interface to open Quiltt connectors.
|
|
59
|
+
*
|
|
60
|
+
* When connectionId changes, the button will automatically update the existing
|
|
61
|
+
* connector instance with the new connection details. If you need to force a
|
|
62
|
+
* complete remount instead, set forceRemountOnConnectionChange to true.
|
|
63
|
+
*/ const QuilttButton = ({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange = false, onEvent, onOpen, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, onClick, onHtmlLoad, children, ...props })=>{
|
|
64
|
+
// Check flag to warn about potential anti-pattern (may produce false positives for valid nested patterns)
|
|
65
|
+
useQuilttRenderGuard('QuilttButton');
|
|
66
|
+
// Keep track of previous connectionId for change detection
|
|
67
|
+
const prevConnectionIdRef = useRef(connectionId);
|
|
68
|
+
const prevCallbacksRef = useRef({
|
|
69
|
+
onEvent,
|
|
70
|
+
onOpen,
|
|
71
|
+
onLoad,
|
|
72
|
+
onExit,
|
|
73
|
+
onExitSuccess,
|
|
74
|
+
onExitAbort,
|
|
75
|
+
onExitError
|
|
76
|
+
});
|
|
77
|
+
// Track if callbacks have changed to help with debugging
|
|
78
|
+
const currentCallbacks = {
|
|
79
|
+
onEvent,
|
|
80
|
+
onOpen,
|
|
81
|
+
onLoad,
|
|
82
|
+
onExit,
|
|
83
|
+
onExitSuccess,
|
|
84
|
+
onExitAbort,
|
|
85
|
+
onExitError
|
|
86
|
+
};
|
|
87
|
+
const callbacksChanged = !isDeepEqual(prevCallbacksRef.current, currentCallbacks);
|
|
88
|
+
useEffect(()=>{
|
|
89
|
+
prevCallbacksRef.current = currentCallbacks;
|
|
90
|
+
});
|
|
91
|
+
// Warning for potential callback reference issues
|
|
92
|
+
useEffect(()=>{
|
|
93
|
+
if (callbacksChanged && prevConnectionIdRef.current !== undefined) {
|
|
94
|
+
console.warn('[Quiltt] Callback functions changed after initial render. ' + 'This may cause unexpected behavior. Consider memoizing callback functions ' + 'with useCallback to maintain stable references.');
|
|
95
|
+
}
|
|
96
|
+
}, [
|
|
97
|
+
callbacksChanged
|
|
98
|
+
]);
|
|
99
|
+
const { open } = useQuilttConnector(connectorId, {
|
|
100
|
+
connectionId,
|
|
101
|
+
institution,
|
|
102
|
+
nonce: props?.nonce,
|
|
103
|
+
onEvent,
|
|
104
|
+
onOpen,
|
|
105
|
+
onLoad,
|
|
106
|
+
onExit,
|
|
107
|
+
onExitSuccess,
|
|
108
|
+
onExitAbort,
|
|
109
|
+
onExitError
|
|
110
|
+
});
|
|
111
|
+
// Update previous connectionId reference
|
|
112
|
+
useEffect(()=>{
|
|
113
|
+
prevConnectionIdRef.current = connectionId;
|
|
114
|
+
}, [
|
|
115
|
+
connectionId
|
|
116
|
+
]);
|
|
117
|
+
const Button = as || 'button';
|
|
118
|
+
const handleClick = (event)=>{
|
|
119
|
+
// Call the user's onClick handler first to allow for:
|
|
120
|
+
// 1. Pre-open validation
|
|
121
|
+
// 2. Preventing opening via event.preventDefault()
|
|
122
|
+
// 3. Setting up state before connector opens
|
|
123
|
+
onClick?.(event);
|
|
124
|
+
// Only open if event wasn't prevented
|
|
125
|
+
if (!event.defaultPrevented) {
|
|
126
|
+
open();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// Generate key for forced remounting if enabled, but respect user-provided key
|
|
130
|
+
const buttonKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
|
|
131
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
132
|
+
onClick: handleClick,
|
|
133
|
+
onLoad: onHtmlLoad,
|
|
134
|
+
"quiltt-connection": connectionId,
|
|
135
|
+
...props,
|
|
136
|
+
children: children
|
|
137
|
+
}, buttonKey);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* QuilttContainer uses globally shared callbacks. It's recommended you only use
|
|
142
|
+
* one Container at a time.
|
|
143
|
+
*
|
|
144
|
+
* When connectionId changes, the container will automatically update the existing
|
|
145
|
+
* connector instance with the new connection details. If you need to force a
|
|
146
|
+
* complete remount instead, set forceRemountOnConnectionChange to true.
|
|
147
|
+
*/ const QuilttContainer = ({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange = false, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props })=>{
|
|
148
|
+
// Check flag to warn about potential anti-pattern (may produce false positives for valid nested patterns)
|
|
149
|
+
useQuilttRenderGuard('QuilttContainer');
|
|
150
|
+
// Keep track of previous connectionId for change detection
|
|
151
|
+
const prevConnectionIdRef = useRef(connectionId);
|
|
152
|
+
const prevCallbacksRef = useRef({
|
|
153
|
+
onEvent,
|
|
154
|
+
onLoad,
|
|
155
|
+
onExit,
|
|
156
|
+
onExitSuccess,
|
|
157
|
+
onExitAbort,
|
|
158
|
+
onExitError
|
|
159
|
+
});
|
|
160
|
+
// Track if callbacks have changed to help with debugging
|
|
161
|
+
const currentCallbacks = {
|
|
162
|
+
onEvent,
|
|
163
|
+
onLoad,
|
|
164
|
+
onExit,
|
|
165
|
+
onExitSuccess,
|
|
166
|
+
onExitAbort,
|
|
167
|
+
onExitError
|
|
168
|
+
};
|
|
169
|
+
const callbacksChanged = !isDeepEqual(prevCallbacksRef.current, currentCallbacks);
|
|
170
|
+
useEffect(()=>{
|
|
171
|
+
prevCallbacksRef.current = currentCallbacks;
|
|
172
|
+
});
|
|
173
|
+
// Warning for potential callback reference issues
|
|
174
|
+
useEffect(()=>{
|
|
175
|
+
if (callbacksChanged && prevConnectionIdRef.current !== undefined) {
|
|
176
|
+
console.warn('[Quiltt] Callback functions changed after initial render. ' + 'This may cause unexpected behavior. Consider memoizing callback functions ' + 'with useCallback to maintain stable references.');
|
|
177
|
+
}
|
|
178
|
+
}, [
|
|
179
|
+
callbacksChanged
|
|
180
|
+
]);
|
|
181
|
+
useQuilttConnector(connectorId, {
|
|
182
|
+
connectionId,
|
|
183
|
+
institution,
|
|
184
|
+
nonce: props?.nonce,
|
|
185
|
+
onEvent,
|
|
186
|
+
onLoad,
|
|
187
|
+
onExit,
|
|
188
|
+
onExitSuccess,
|
|
189
|
+
onExitAbort,
|
|
190
|
+
onExitError
|
|
191
|
+
});
|
|
192
|
+
// Update previous connectionId reference
|
|
193
|
+
useEffect(()=>{
|
|
194
|
+
prevConnectionIdRef.current = connectionId;
|
|
195
|
+
}, [
|
|
196
|
+
connectionId
|
|
197
|
+
]);
|
|
198
|
+
const Container = as || 'div';
|
|
199
|
+
// Generate key for forced remounting if enabled, but respect user-provided key
|
|
200
|
+
const containerKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
|
|
201
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
202
|
+
"quiltt-container": connectorId,
|
|
203
|
+
"quiltt-connection": connectionId,
|
|
204
|
+
...props,
|
|
205
|
+
children: children
|
|
206
|
+
}, containerKey);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export { QuilttButton, QuilttContainer };
|
package/dist/{useQuilttConnector-12s-DfCZ1lpS.js → components/useQuilttConnector-12s-3VgurfwU.js}
RENAMED
|
@@ -1,82 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { u as useQuilttSession } from './useQuilttSession-12s-
|
|
2
|
+
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
import { cdnBase } from '@quiltt/core';
|
|
4
|
+
import { u as useQuilttSession } from './useQuilttSession-12s-VOH0S5zh.js';
|
|
5
5
|
import { u as useScript } from './useScript-12s-JCgaTW9n.js';
|
|
6
|
+
import { getUserAgent, isDeepEqual } from '../utils/index.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
* Performs a deep equality comparison between two values
|
|
9
|
-
*
|
|
10
|
-
* This function recursively compares all properties to determine if they are equal.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true
|
|
15
|
-
* isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } }) // false
|
|
16
|
-
* ```
|
|
17
|
-
*/ const isDeepEqual = (obj1, obj2)=>{
|
|
18
|
-
// Handle primitive types and null/undefined
|
|
19
|
-
if (obj1 === obj2) return true;
|
|
20
|
-
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
|
|
21
|
-
// Handle special object types
|
|
22
|
-
if (obj1 instanceof Date && obj2 instanceof Date) {
|
|
23
|
-
return obj1.getTime() === obj2.getTime();
|
|
24
|
-
}
|
|
25
|
-
if (obj1 instanceof RegExp && obj2 instanceof RegExp) {
|
|
26
|
-
return obj1.toString() === obj2.toString();
|
|
27
|
-
}
|
|
28
|
-
if (obj1 instanceof Map && obj2 instanceof Map) {
|
|
29
|
-
if (obj1.size !== obj2.size) return false;
|
|
30
|
-
for (const [key, value] of obj1){
|
|
31
|
-
if (!obj2.has(key) || !isDeepEqual(value, obj2.get(key))) return false;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
if (obj1 instanceof Set && obj2 instanceof Set) {
|
|
36
|
-
if (obj1.size !== obj2.size) return false;
|
|
37
|
-
const arr2 = Array.from(obj2);
|
|
38
|
-
for (const item of obj1){
|
|
39
|
-
if (!arr2.some((value)=>isDeepEqual(item, value))) return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
// Handle arrays
|
|
44
|
-
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
45
|
-
if (obj1.length !== obj2.length) return false;
|
|
46
|
-
return obj1.every((value, index)=>isDeepEqual(value, obj2[index]));
|
|
47
|
-
}
|
|
48
|
-
// If one is array and other isn't, they're not equal
|
|
49
|
-
if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
|
|
50
|
-
const keys1 = Object.keys(obj1);
|
|
51
|
-
const keys2 = Object.keys(obj2);
|
|
52
|
-
if (keys1.length !== keys2.length) return false;
|
|
53
|
-
return keys1.every((key)=>{
|
|
54
|
-
return Object.hasOwn(obj2, key) && isDeepEqual(obj1[key], obj2[key]);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Gets the React version from the runtime
|
|
60
|
-
*/ const getReactVersion = ()=>{
|
|
61
|
-
return React.version || 'unknown';
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Generates platform information string for React web
|
|
65
|
-
* Format: React/<version>; <browser>/<version>
|
|
66
|
-
*/ const getPlatformInfo = ()=>{
|
|
67
|
-
const reactVersion = getReactVersion();
|
|
68
|
-
const browserInfo = getBrowserInfo();
|
|
69
|
-
return `React/${reactVersion}; ${browserInfo}`;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Generates User-Agent string for React SDK
|
|
73
|
-
* Format: Quiltt/<sdk-version> (React/<react-version>; <browser>/<version>)
|
|
74
|
-
*/ const getUserAgent = (sdkVersion)=>{
|
|
75
|
-
const platformInfo = getPlatformInfo();
|
|
76
|
-
return getUserAgent$1(sdkVersion, platformInfo);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
var version = "5.0.0";
|
|
8
|
+
var version = "5.0.2";
|
|
80
9
|
|
|
81
10
|
const useQuilttConnector = (connectorId, options)=>{
|
|
82
11
|
const userAgent = getUserAgent(version);
|
|
@@ -242,4 +171,4 @@ const useQuilttConnector = (connectorId, options)=>{
|
|
|
242
171
|
};
|
|
243
172
|
};
|
|
244
173
|
|
|
245
|
-
export {
|
|
174
|
+
export { useQuilttConnector as u };
|