@ozura/elements 1.3.1-next.72 → 1.3.1-next.74

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.
@@ -1262,13 +1262,23 @@ class OzVault {
1262
1262
  * });
1263
1263
  */
1264
1264
  get isComplete() {
1265
- if (this.elements.size === 0)
1265
+ return this.allComplete([...this.elementsByType.values()]);
1266
+ }
1267
+ /**
1268
+ * Like {@link isComplete}, but for bank-account elements created via
1269
+ * {@link createBankElement}. Card and bank fields are tracked separately so a
1270
+ * card-only checkout is never gated on bank fields (and vice versa), matching
1271
+ * the `createToken()` / `createBankToken()` split. A vault with both card and
1272
+ * bank elements exposes each completion state independently.
1273
+ */
1274
+ get isBankComplete() {
1275
+ return this.allComplete([...this.bankElementsByType.values()]);
1276
+ }
1277
+ /** True iff the set is non-empty and every element has reported complete-and-valid. */
1278
+ allComplete(els) {
1279
+ if (els.length === 0)
1266
1280
  return false;
1267
- for (const frameId of this.elements.keys()) {
1268
- if (this.completionState.get(frameId) !== true)
1269
- return false;
1270
- }
1271
- return true;
1281
+ return els.every(el => this.completionState.get(el.frameId) === true);
1272
1282
  }
1273
1283
  /**
1274
1284
  * `true` while a `createToken()` or `createBankToken()` call is in progress
@@ -2422,7 +2432,7 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
2422
2432
  * an `<OzElements>` provider tree.
2423
2433
  */
2424
2434
  function useOzElements() {
2425
- var _a, _b;
2435
+ var _a, _b, _c;
2426
2436
  const { vault, initError, mountedCount, readyCount, notifyTokenize, notifyChange, tokenizeCount } = useContext(OzContext);
2427
2437
  const createToken = useCallback(async (options) => {
2428
2438
  if (!vault) {
@@ -2460,11 +2470,15 @@ function useOzElements() {
2460
2470
  }, [vault, notifyTokenize, notifyChange]);
2461
2471
  const reset = useCallback(() => {
2462
2472
  vault === null || vault === void 0 ? void 0 : vault.reset();
2463
- }, [vault]);
2473
+ // reset() clears completion state and cancels any in-flight tokenization, so
2474
+ // re-render to refresh the derived isComplete / isTokenizing getters below.
2475
+ notifyChange();
2476
+ }, [vault, notifyChange]);
2464
2477
  const ready = vault !== null && vault.isReady && mountedCount > 0 && readyCount >= mountedCount;
2465
2478
  const isComplete = (_a = vault === null || vault === void 0 ? void 0 : vault.isComplete) !== null && _a !== void 0 ? _a : false;
2466
- const isTokenizing = (_b = vault === null || vault === void 0 ? void 0 : vault.isTokenizing) !== null && _b !== void 0 ? _b : false;
2467
- return { createToken, createBankToken, reset, ready, initError, tokenizeCount, isComplete, isTokenizing };
2479
+ const isBankComplete = (_b = vault === null || vault === void 0 ? void 0 : vault.isBankComplete) !== null && _b !== void 0 ? _b : false;
2480
+ const isTokenizing = (_c = vault === null || vault === void 0 ? void 0 : vault.isTokenizing) !== null && _c !== void 0 ? _c : false;
2481
+ return { createToken, createBankToken, reset, ready, initError, tokenizeCount, isComplete, isBankComplete, isTokenizing };
2468
2482
  }
2469
2483
  const SKELETON_STYLE = {
2470
2484
  height: 46,