@quiltt/react 4.5.1 → 5.0.1

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +15 -3
  3. package/dist/components/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  4. package/dist/components/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  5. package/dist/components/index.cjs +211 -0
  6. package/dist/components/index.d.ts +55 -0
  7. package/dist/components/index.js +208 -0
  8. package/dist/components/useQuilttConnector-12s-BLTzI3gE.cjs +174 -0
  9. package/dist/components/useQuilttConnector-12s-UQQcvQrO.js +174 -0
  10. package/dist/components/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
  11. package/dist/components/useQuilttSession-12s-BjyJL1qZ.cjs +133 -0
  12. package/dist/components/useQuilttSession-12s-VOH0S5zh.js +133 -0
  13. package/dist/components/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
  14. package/dist/components/useScript-12s-CMIDUHrx.cjs +92 -0
  15. package/dist/{useSession-12s-7GOn4sUn.js → components/useSession-12s-BNPsfKY-.js} +28 -7
  16. package/dist/components/useSession-12s-BNotXj5T.cjs +90 -0
  17. package/dist/{useStorage-12s-DHcq3Kuh.js → components/useStorage-12s-CpG6X57D.js} +7 -17
  18. package/dist/components/useStorage-12s-D7nllsrI.cjs +61 -0
  19. package/dist/contexts/QuilttSettings-12s-BK-0SQME.js +6 -0
  20. package/dist/contexts/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  21. package/dist/contexts/index.cjs +7 -0
  22. package/dist/contexts/index.d.ts +8 -0
  23. package/dist/contexts/index.js +1 -0
  24. package/dist/hooks/QuilttProviderRender-12s-DtQtubjL.js +6 -0
  25. package/dist/hooks/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  26. package/dist/hooks/QuilttSettings-12s-BK-0SQME.js +6 -0
  27. package/dist/hooks/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  28. package/dist/hooks/index.cjs +31 -0
  29. package/dist/hooks/index.d.ts +142 -0
  30. package/dist/hooks/index.js +11 -0
  31. package/dist/hooks/useEventListener-12s-CV8cLxWu.cjs +34 -0
  32. package/dist/hooks/useIsomorphicLayoutEffect-12s-B8KjaroI.cjs +9 -0
  33. package/dist/{useQuilttClient-12s-CAAUait1.js → hooks/useQuilttClient-12s-Dj_MtYTU.js} +1 -1
  34. package/dist/hooks/useQuilttClient-12s-flQYSVdG.cjs +6 -0
  35. package/dist/{useQuilttConnector-12s-D8VedbrT.js → hooks/useQuilttConnector-12s-C0KJHuZN.js} +5 -4
  36. package/dist/hooks/useQuilttConnector-12s-D51PZPgm.cjs +175 -0
  37. package/dist/hooks/useQuilttInstitutions-12s-D_Kr43s3.cjs +82 -0
  38. package/dist/{useQuilttInstitutions-12s-DExzPnfb.js → hooks/useQuilttInstitutions-12s-rgLHD9ye.js} +6 -16
  39. package/dist/hooks/useQuilttRenderGuard-12s-CsS2Ma6Q.js +36 -0
  40. package/dist/hooks/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
  41. package/dist/{useQuilttResolvable-12s-C0BV3AvR.js → hooks/useQuilttResolvable-12s-BUDeH696.js} +6 -16
  42. package/dist/hooks/useQuilttResolvable-12s-D8wnfNBt.cjs +76 -0
  43. package/dist/hooks/useQuilttSession-12s-C8kq5S2Y.cjs +139 -0
  44. package/dist/hooks/useQuilttSession-12s-DQFfjmob.js +135 -0
  45. package/dist/hooks/useQuilttSettings-12s--rCJoNHD.js +10 -0
  46. package/dist/hooks/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
  47. package/dist/hooks/useScript-12s-CMIDUHrx.cjs +92 -0
  48. package/dist/hooks/useScript-12s-JCgaTW9n.js +92 -0
  49. package/dist/hooks/useSession-12s-BNPsfKY-.js +90 -0
  50. package/dist/hooks/useSession-12s-BNotXj5T.cjs +90 -0
  51. package/dist/hooks/useStorage-12s-CpG6X57D.js +61 -0
  52. package/dist/hooks/useStorage-12s-D7nllsrI.cjs +61 -0
  53. package/dist/index.cjs +149 -0
  54. package/dist/index.d.ts +7 -216
  55. package/dist/index.js +7 -191
  56. package/dist/providers/QuilttAuthProvider-12s-CDgQbarX.js +60 -0
  57. package/dist/providers/QuilttAuthProvider-12s-D__FY1Qn.cjs +60 -0
  58. package/dist/providers/QuilttProviderRender-12s-DtQtubjL.js +6 -0
  59. package/dist/providers/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  60. package/dist/providers/QuilttSettings-12s-BK-0SQME.js +6 -0
  61. package/dist/providers/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  62. package/dist/providers/QuilttSettingsProvider-12s-D7e8dsOE.cjs +19 -0
  63. package/dist/{QuilttSettingsProvider-12s-ZcmFmOiZ.js → providers/QuilttSettingsProvider-12s-DND2gPQm.js} +8 -5
  64. package/dist/providers/index.cjs +34 -0
  65. package/dist/providers/index.d.ts +28 -0
  66. package/dist/providers/index.js +30 -0
  67. package/dist/utils/index.cjs +89 -0
  68. package/dist/utils/index.d.ts +31 -0
  69. package/dist/utils/index.js +77 -0
  70. package/package.json +38 -12
  71. package/src/hooks/useQuilttClient.ts +1 -1
  72. package/src/hooks/useQuilttConnector.ts +3 -2
  73. package/src/hooks/useQuilttInstitutions.ts +8 -23
  74. package/src/hooks/useQuilttResolvable.ts +8 -23
  75. package/src/hooks/useSession.ts +32 -6
  76. package/src/hooks/useStorage.ts +7 -15
  77. package/src/index.ts +61 -0
  78. package/src/providers/QuilttAuthProvider.tsx +12 -5
  79. package/src/providers/QuilttProvider.tsx +5 -1
  80. package/src/providers/QuilttSettingsProvider.tsx +4 -5
  81. package/src/utils/index.ts +1 -0
  82. package/src/utils/telemetry.ts +33 -0
  83. package/dist/QuilttAuthProvider-12s-DE-ePRo_.js +0 -205
  84. package/dist/useQuilttSession-12s-sRvULtJv.js +0 -39
  85. /package/dist/{QuilttProviderRender-12s-DtQtubjL.js → components/QuilttProviderRender-12s-DtQtubjL.js} +0 -0
  86. /package/dist/{QuilttSettings-12s-BK-0SQME.js → components/QuilttSettings-12s-BK-0SQME.js} +0 -0
  87. /package/dist/{useQuilttRenderGuard-12s-CsS2Ma6Q.js → components/useQuilttRenderGuard-12s-CsS2Ma6Q.js} +0 -0
  88. /package/dist/{useQuilttSettings-12s--rCJoNHD.js → components/useQuilttSettings-12s--rCJoNHD.js} +0 -0
  89. /package/dist/{useScript-12s-JCgaTW9n.js → components/useScript-12s-JCgaTW9n.js} +0 -0
  90. /package/dist/{useEventListener-12s-D_-6QIXa.js → hooks/useEventListener-12s-D_-6QIXa.js} +0 -0
  91. /package/dist/{useIsomorphicLayoutEffect-12s-DeTHOKz1.js → hooks/useIsomorphicLayoutEffect-12s-DeTHOKz1.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @quiltt/react
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ - [#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
10
+
11
+ - [#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
12
+
13
+ - [#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
14
+
15
+ - [#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
16
+
17
+ - 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)]:
18
+ - @quiltt/core@5.0.1
19
+
20
+ ## 5.0.0
21
+
22
+ ### Major Changes
23
+
24
+ - [#394](https://github.com/quiltt/quiltt-js/pull/394) [`2ba646a`](https://github.com/quiltt/quiltt-js/commit/2ba646a2efcb7bef7949dab74778ab1c3babdb84) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Migrate Apollo Client to v4
25
+
26
+ ### Minor Changes
27
+
28
+ - [#395](https://github.com/quiltt/quiltt-js/pull/395) [`f635500`](https://github.com/quiltt/quiltt-js/commit/f635500f17ab8a76aa0fb87ed7f4971e63a93f12) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Enhanced SDK telemetry with standardized User-Agent headers
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [[`f635500`](https://github.com/quiltt/quiltt-js/commit/f635500f17ab8a76aa0fb87ed7f4971e63a93f12), [`2ba646a`](https://github.com/quiltt/quiltt-js/commit/2ba646a2efcb7bef7949dab74778ab1c3babdb84)]:
33
+ - @quiltt/core@5.0.0
34
+
3
35
  ## 4.5.1
4
36
 
5
37
  ### Patch 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
@@ -63,7 +69,7 @@ export const App = () => {
63
69
  connectorId="<CONNECTOR_ID>"
64
70
  onExitSuccess={handleExitSuccess}
65
71
  className="my-css-class"
66
- styles={{ borderWidth: '2px' }}
72
+ style={{ borderWidth: '2px' }}
67
73
  // ... other props to pass through to the button
68
74
  >
69
75
  Add Account
@@ -97,7 +103,7 @@ export const App = () => {
97
103
  connectorId="<CONNECTOR_ID>"
98
104
  onExitSuccess={handleExitSuccess}
99
105
  className="my-css-class"
100
- styles={{ height: '100%' }}
106
+ style={{ height: '100%' }}
101
107
  // ... other props to pass through to the container
102
108
  />
103
109
  )
@@ -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).
@@ -139,7 +151,7 @@ import { useQuilttConnector } from '@quiltt/react'
139
151
 
140
152
  const App = () => {
141
153
  const { open } = useQuilttConnector('<CONNECTOR_ID>', {
142
- onEvent: (type) => console.log(`Received Quiltt Event: ${type}`)
154
+ onEvent: (type) => console.log(`Received Quiltt Event: ${type}`),
143
155
  onExitSuccess: (metadata) => console.log("Connector onExitSuccess", metadata.connectionId),
144
156
  })
145
157
 
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ var react = require('react');
3
+
4
+ const QuilttProviderRender = react.createContext({});
5
+
6
+ exports.QuilttProviderRender = QuilttProviderRender;
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ var react = require('react');
3
+
4
+ const QuilttSettings = react.createContext({});
5
+
6
+ exports.QuilttSettings = QuilttSettings;
@@ -0,0 +1,211 @@
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-BLTzI3gE.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, 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
+ nonce: props?.nonce,
186
+ onEvent,
187
+ onLoad,
188
+ onExit,
189
+ onExitSuccess,
190
+ onExitAbort,
191
+ onExitError
192
+ });
193
+ // Update previous connectionId reference
194
+ react.useEffect(()=>{
195
+ prevConnectionIdRef.current = connectionId;
196
+ }, [
197
+ connectionId
198
+ ]);
199
+ const Container = as || 'div';
200
+ // Generate key for forced remounting if enabled, but respect user-provided key
201
+ const containerKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
202
+ return /*#__PURE__*/ jsxRuntime.jsx(Container, {
203
+ "quiltt-container": connectorId,
204
+ "quiltt-connection": connectionId,
205
+ ...props,
206
+ children: children
207
+ }, containerKey);
208
+ };
209
+
210
+ exports.QuilttButton = QuilttButton;
211
+ exports.QuilttContainer = QuilttContainer;
@@ -0,0 +1,55 @@
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
+ /**
39
+ * Forces complete remount when connectionId changes.
40
+ * Useful as a fallback for ensuring clean state.
41
+ * @default false
42
+ */
43
+ forceRemountOnConnectionChange?: boolean;
44
+ } & ConnectorSDKCallbacks>;
45
+ /**
46
+ * QuilttContainer uses globally shared callbacks. It's recommended you only use
47
+ * one Container at a time.
48
+ *
49
+ * When connectionId changes, the container will automatically update the existing
50
+ * connector instance with the new connection details. If you need to force a
51
+ * complete remount instead, set forceRemountOnConnectionChange to true.
52
+ */
53
+ 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;
54
+
55
+ export { QuilttButton, QuilttContainer };
@@ -0,0 +1,208 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useRef, useEffect } from 'react';
3
+ import { u as useQuilttConnector } from './useQuilttConnector-12s-UQQcvQrO.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, 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
+ nonce: props?.nonce,
184
+ onEvent,
185
+ onLoad,
186
+ onExit,
187
+ onExitSuccess,
188
+ onExitAbort,
189
+ onExitError
190
+ });
191
+ // Update previous connectionId reference
192
+ useEffect(()=>{
193
+ prevConnectionIdRef.current = connectionId;
194
+ }, [
195
+ connectionId
196
+ ]);
197
+ const Container = as || 'div';
198
+ // Generate key for forced remounting if enabled, but respect user-provided key
199
+ const containerKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
200
+ return /*#__PURE__*/ jsx(Container, {
201
+ "quiltt-container": connectorId,
202
+ "quiltt-connection": connectionId,
203
+ ...props,
204
+ children: children
205
+ }, containerKey);
206
+ };
207
+
208
+ export { QuilttButton, QuilttContainer };