@alviere/ui 0.16.0 → 0.16.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/dist/index.js CHANGED
@@ -12750,13 +12750,14 @@ const createFlowCoreStore = () => {
12750
12750
  }
12751
12751
  const debug = state2.config.debug || false;
12752
12752
  debug && uiLogger.info("🔄 Updating JWT in shared AlviereCore instance (store)...");
12753
- state2.core.configure({ ...state2.config, jwt: newJwt });
12753
+ const newConfig = { ...state2.config, jwt: newJwt };
12754
+ state2.core.configure(newConfig);
12754
12755
  debug && uiLogger.info("✅ Shared AlviereCore updated with new JWT (store):", {
12755
12756
  accountUuid: state2.core.getAccountUuid(),
12756
12757
  businessUuid: state2.core.getBusinessUuid(),
12757
12758
  isFirstTimeUser: state2.core.isFirstTimeUser()
12758
12759
  });
12759
- return { ...state2, config: { ...state2.config, jwt: newJwt } };
12760
+ return { ...state2, config: newConfig };
12760
12761
  });
12761
12762
  },
12762
12763
  /**
@@ -16457,16 +16458,17 @@ function AddBankAccount($$anchor, $$props) {
16457
16458
  });
16458
16459
  user_effect(() => {
16459
16460
  const routingNumber = baseForm.state.formData.ach_details.routing_number;
16460
- const invalidRoutingNumberMessage = getFieldErrorMessage("ach_routing_number", "pattern", INVALID_ROUTING_NUMBER_MESSAGE);
16461
- if (routingNumber && routingNumber.length === 9 && baseForm.state.alviereCore) {
16461
+ const currentFieldError = untrack$1(() => baseForm.state.validationErrors.ach_routing_number);
16462
+ const fieldPassesSchema = !currentFieldError || currentFieldError === INVALID_ROUTING_NUMBER_MESSAGE;
16463
+ if (routingNumber && routingNumber.length === 9 && fieldPassesSchema && baseForm.state.alviereCore) {
16462
16464
  set(isLoadingBankInfo, true);
16463
16465
  lookupRoutingNumber(routingNumber, baseForm.state.alviereCore).then((info) => {
16464
16466
  set(bankInfo, info, true);
16465
16467
  if (!info) {
16466
- baseForm.actions.setFieldError("ach_routing_number", invalidRoutingNumberMessage);
16468
+ baseForm.actions.setFieldError("ach_routing_number", INVALID_ROUTING_NUMBER_MESSAGE);
16467
16469
  return;
16468
16470
  }
16469
- if (baseForm.state.validationErrors.ach_routing_number === invalidRoutingNumberMessage) {
16471
+ if (baseForm.state.validationErrors.ach_routing_number === INVALID_ROUTING_NUMBER_MESSAGE) {
16470
16472
  baseForm.actions.clearFieldError("ach_routing_number");
16471
16473
  }
16472
16474
  }).catch(async (error) => {
@@ -16477,7 +16479,7 @@ function AddBankAccount($$anchor, $$props) {
16477
16479
  } else if (result.kind === "critical") {
16478
16480
  dispatchCriticalError(result.error, result.errorCode);
16479
16481
  } else {
16480
- baseForm.actions.setFieldError("ach_routing_number", invalidRoutingNumberMessage);
16482
+ baseForm.actions.setFieldError("ach_routing_number", INVALID_ROUTING_NUMBER_MESSAGE);
16481
16483
  uiLogger.warn("Failed to lookup bank info:", error);
16482
16484
  }
16483
16485
  }).finally(() => {
@@ -16485,8 +16487,8 @@ function AddBankAccount($$anchor, $$props) {
16485
16487
  });
16486
16488
  } else {
16487
16489
  set(bankInfo, null);
16488
- if (baseForm.state.validationErrors.ach_routing_number === invalidRoutingNumberMessage) {
16489
- baseForm.actions.clearFieldError("ach_routing_number");
16490
+ if (currentFieldError === INVALID_ROUTING_NUMBER_MESSAGE) {
16491
+ baseForm.actions.validateField("ach_routing_number");
16490
16492
  }
16491
16493
  }
16492
16494
  });
@@ -16515,7 +16517,6 @@ function AddBankAccount($$anchor, $$props) {
16515
16517
  return (_b2 = (_a4 = account.bank_account_details) === null || _a4 === void 0 ? void 0 : _a4.ach_details) === null || _b2 === void 0 ? void 0 : _b2.routing_number;
16516
16518
  }).filter((routing) => typeof routing === "string" && routing.length > 0);
16517
16519
  routingNumbers.forEach((routingNumber) => {
16518
- const invalidRoutingNumberMessage = getFieldErrorMessage("ach_routing_number", "pattern", INVALID_ROUTING_NUMBER_MESSAGE);
16519
16520
  if (get$1(bankInfoByRouting)[routingNumber] !== void 0) {
16520
16521
  return;
16521
16522
  }
@@ -16523,15 +16524,15 @@ function AddBankAccount($$anchor, $$props) {
16523
16524
  lookupRoutingNumber(routingNumber, baseForm.state.alviereCore || void 0).then((info) => {
16524
16525
  set(bankInfoByRouting, Object.assign(Object.assign({}, get$1(bankInfoByRouting)), { [routingNumber]: info }), true);
16525
16526
  const currentRouting = baseForm.state.formData.ach_details.routing_number;
16526
- if (currentRouting === routingNumber && !info && baseForm.state.validationErrors.ach_routing_number !== invalidRoutingNumberMessage) {
16527
- baseForm.actions.setFieldError("ach_routing_number", invalidRoutingNumberMessage);
16527
+ if (currentRouting === routingNumber && !info && baseForm.state.validationErrors.ach_routing_number !== INVALID_ROUTING_NUMBER_MESSAGE) {
16528
+ baseForm.actions.setFieldError("ach_routing_number", INVALID_ROUTING_NUMBER_MESSAGE);
16528
16529
  }
16529
16530
  }).catch((error) => {
16530
16531
  uiLogger.warn("Failed to lookup bank info for routing number:", routingNumber, error);
16531
16532
  set(bankInfoByRouting, Object.assign(Object.assign({}, get$1(bankInfoByRouting)), { [routingNumber]: null }), true);
16532
16533
  const currentRouting = baseForm.state.formData.ach_details.routing_number;
16533
16534
  if (currentRouting === routingNumber) {
16534
- baseForm.actions.setFieldError("ach_routing_number", invalidRoutingNumberMessage);
16535
+ baseForm.actions.setFieldError("ach_routing_number", INVALID_ROUTING_NUMBER_MESSAGE);
16535
16536
  }
16536
16537
  });
16537
16538
  });
@@ -16606,7 +16607,7 @@ function AddBankAccount($$anchor, $$props) {
16606
16607
  baseForm.actions.validateAllFields();
16607
16608
  const routingOnSubmit = baseForm.state.formData.ach_details.routing_number;
16608
16609
  if (baseForm.state.alviereCore && (routingOnSubmit === null || routingOnSubmit === void 0 ? void 0 : routingOnSubmit.length) === 9 && !get$1(isLoadingBankInfo) && get$1(bankInfo) === null) {
16609
- baseForm.actions.setFieldError("ach_routing_number", getFieldErrorMessage("ach_routing_number", "pattern", INVALID_ROUTING_NUMBER_MESSAGE));
16610
+ baseForm.actions.setFieldError("ach_routing_number", INVALID_ROUTING_NUMBER_MESSAGE);
16610
16611
  }
16611
16612
  if (!baseForm.computed.canSubmit) {
16612
16613
  uiLogger.debug("Cannot submit: form validation failed");
@@ -17380,7 +17381,7 @@ function AddBankAccount($$anchor, $$props) {
17380
17381
  baseForm.handlers.handleFieldBlur("ach_routing_number");
17381
17382
  const routing = baseForm.state.formData.ach_details.routing_number;
17382
17383
  if (baseForm.state.alviereCore && (routing == null ? void 0 : routing.length) === 9 && !get$1(isLoadingBankInfo) && get$1(bankInfo) === null) {
17383
- baseForm.actions.setFieldError("ach_routing_number", getFieldErrorMessage("ach_routing_number", "pattern", INVALID_ROUTING_NUMBER_MESSAGE));
17384
+ baseForm.actions.setFieldError("ach_routing_number", INVALID_ROUTING_NUMBER_MESSAGE);
17384
17385
  }
17385
17386
  }
17386
17387
  });
@@ -17978,7 +17979,7 @@ function CheckoutConfirm($$anchor, $$props) {
17978
17979
  set(selfAmount, amount());
17979
17980
  }
17980
17981
  });
17981
- const canPay = /* @__PURE__ */ user_derived(() => () => !legalTextsResolver.requiresLegalTexts || get$1(legalTextsAccepted));
17982
+ const canPay = /* @__PURE__ */ user_derived(() => () => legalTextsResolver.hasResolved && (!legalTextsResolver.requiresLegalTexts || get$1(legalTextsAccepted)));
17982
17983
  async function handlePay() {
17983
17984
  if (!get$1(canPay)() || get$1(isSending)) return;
17984
17985
  set(isSending, true);
@@ -19703,7 +19704,6 @@ function createJwtFlowManager(options) {
19703
19704
  const currentJwt = getJwt();
19704
19705
  if (currentJwt) {
19705
19706
  set(effectiveJwt, currentJwt, true);
19706
- scheduleRefresh(currentJwt);
19707
19707
  }
19708
19708
  });
19709
19709
  user_effect(() => {
@@ -20530,6 +20530,9 @@ function MultiStepFlow($$anchor, $$props) {
20530
20530
  debug: debug()
20531
20531
  });
20532
20532
  }
20533
+ if (jwt()) {
20534
+ jwtManager.updateJwt(jwt());
20535
+ }
20533
20536
  if (((_a3 = config() === null || config() === void 0 ? void 0 : config().steps) === null || _a3 === void 0 ? void 0 : _a3.length) > 0) {
20534
20537
  debug() && uiLogger.info("🚀 MultiStepFlow mounted with", config().steps.length, "steps");
20535
20538
  flowManager.markStepInProgress(0);
@@ -20571,6 +20574,7 @@ function MultiStepFlow($$anchor, $$props) {
20571
20574
  const accumulatedResults2 = flowManager.getAccumulatedResults();
20572
20575
  eventDispatcher.dispatchStepComplete(stepIndex, accumulatedResults2);
20573
20576
  flowManager.flowState.isComplete = true;
20577
+ jwtManager.cancelRefreshTimer();
20574
20578
  eventDispatcher.dispatchFlowComplete(accumulatedResults2);
20575
20579
  return;
20576
20580
  }
@@ -20584,6 +20588,7 @@ function MultiStepFlow($$anchor, $$props) {
20584
20588
  const accumulatedResults = flowManager.getAccumulatedResults();
20585
20589
  if (!flowManager.canGoNext()) {
20586
20590
  flowManager.flowState.isComplete = true;
20591
+ jwtManager.cancelRefreshTimer();
20587
20592
  debug() && uiLogger.info("⚡️ Flow reached completion state, dispatching flow-complete event");
20588
20593
  eventDispatcher.dispatchFlowComplete(accumulatedResults);
20589
20594
  } else {
@@ -20604,6 +20609,7 @@ function MultiStepFlow($$anchor, $$props) {
20604
20609
  if (error2 instanceof AlcoreApiError && isCriticalError(error2.errorCode)) {
20605
20610
  debug() && uiLogger.error(`🚨 Critical error - halting flow: ${error2.errorCode}`);
20606
20611
  set(flowBarrier, null);
20612
+ jwtManager.cancelRefreshTimer();
20607
20613
  set(
20608
20614
  flowError,
20609
20615
  {
@@ -20625,6 +20631,7 @@ function MultiStepFlow($$anchor, $$props) {
20625
20631
  const detail = customEvent.detail || {};
20626
20632
  debug() && uiLogger.info("⛔ Flow barrier triggered:", detail);
20627
20633
  set(flowError, null);
20634
+ jwtManager.cancelRefreshTimer();
20628
20635
  flowManager.markStepInfoBlocked(stepIndex);
20629
20636
  const commonBarrierTitle = resolveFlowLabel(["barrierTitleLabel", "barrierTitle"]);
20630
20637
  const commonBarrierMessage = resolveFlowLabel(["barrierMessageLabel", "barrierMessage"]);