@tesouro/embedded-components-react 0.2.307 → 0.2.309

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/README.md CHANGED
@@ -546,25 +546,26 @@ A composite settings widget that combines Monite document settings, tags, GL cod
546
546
 
547
547
  #### Props
548
548
 
549
- | Prop | Type | Default | Description |
550
- | ------------------------- | -------------------------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
551
- | `acceptInviteRedirectUri` | `string` | Same-origin `/accept-invite` | Forwarded to the Team section's widget — allowlisted URL invite emails link to. Defaults to `${window.location.origin}/accept-invite`; set it when the host app's registered landing route differs from the widget's same-origin default, or the origin is not on the OIDC redirect-URI allowlist (preview/localhost). |
552
- | `labels` | `Partial<Labels>` | English labels | Overrides the settings heading copy. |
553
- | `featureLabels` | `Partial<FeatureLabels>` | English labels | Overrides section labels. |
554
- | `profileContent` | `ReactNode` | Profile widget | Replaces the profile section content. |
555
- | `teamContent` | `ReactNode` | Empty | Supplies the team section content. |
556
- | `invoiceContent` | `ReactNode` | Monite template settings | Replaces invoice settings content. |
557
- | `billPayContent` | `ReactNode` | Monite approval policies | Replaces bill-pay settings content. |
558
- | `accountingContent` | `ReactNode` | GL code table widget | Replaces accounting content. |
559
- | `tagsContent` | `ReactNode` | Monite tags | Replaces tags content. |
560
- | `expenseContent` | `ReactNode` | Expense policies and requirements | Replaces expense content. |
561
- | `profileContactUrl` | `string` | `undefined` | Forwarded to the Profile section's widget — where its "to change this information, contact your bank" line links. Left unset, the card shows the plain unlinked sentence instead; the bank name comes from widget init. |
562
- | `selectedSection` | `SettingsWidgetSectionId` | `undefined` | The section to show. Leave unset to let the widget own the selection; supply it (with `onSelectedSectionChange`) to drive navigation from a route or search param. A section the user's scopes hide falls back to the first visible one. |
563
- | `onSelectedSectionChange` | `(section: SettingsWidgetSectionId) => void` | `undefined` | Called with the id of the section the user selected. Fires whether or not `selectedSection` is supplied, so a host can mirror the selection into its URL without taking ownership of it. |
564
- | `additionalSections` | `SettingsWidgetAdditionalSection[]` | `undefined` | Host-owned sections rendered alongside the built-in ones. Each is `{ id, label, content }` plus an optional `after` naming the built-in section to place it behind. Unlike the built-ins, these are not scope-gated. |
565
- | `helpContactUrl` | `string` | `undefined` | Forwarded to the Help section's widget — where its "Contact Us" line links (a support page URL or a `mailto:`). The line is hidden while unset, since the package has no tenant-agnostic support address to fall back on; the bank name in that line comes from widget init. |
566
- | `helpContent` | `ReactNode` | Help widget | Replaces the help section content. |
567
- | `finopsThemeColors` | `FinopsThemeColors` | `undefined` | Optional Monite theme color overrides. |
549
+ | Prop | Type | Default | Description |
550
+ | ------------------------- | -------------------------------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
551
+ | `acceptInviteRedirectUri` | `string` | Same-origin `/accept-invite` | Forwarded to the Team section's widget — allowlisted URL invite emails link to. Defaults to `${window.location.origin}/accept-invite`; set it when the host app's registered landing route differs from the widget's same-origin default, or the origin is not on the OIDC redirect-URI allowlist (preview/localhost). |
552
+ | `labels` | `Partial<Labels>` | English labels | Overrides the settings heading copy. |
553
+ | `featureLabels` | `Partial<FeatureLabels>` | English labels | Overrides section labels. |
554
+ | `profileContent` | `ReactNode` | Profile widget | Replaces the profile section content. |
555
+ | `teamContent` | `ReactNode` | Empty | Supplies the team section content. |
556
+ | `invoiceContent` | `ReactNode` | Monite template settings | Replaces invoice settings content. |
557
+ | `billPayContent` | `ReactNode` | Monite approval policies | Replaces bill-pay settings content. |
558
+ | `accountingContent` | `ReactNode` | GL code table widget | Replaces accounting content. |
559
+ | `tagsContent` | `ReactNode` | Monite tags | Replaces tags content. |
560
+ | `expenseContent` | `ReactNode` | Expense policies and requirements | Replaces expense content. |
561
+ | `profileContactUrl` | `string` | `undefined` | Forwarded to the Profile section's widget — where its "to change this information, contact your bank" line links. Left unset, the card shows the plain unlinked sentence instead; the bank name comes from widget init. |
562
+ | `selectedSection` | `SettingsWidgetSectionId` | `undefined` | The section to show. Leave unset to let the widget own the selection; supply it (with `onSelectedSectionChange`) to drive navigation from a route or search param. A section the user's scopes hide falls back to the first visible one. |
563
+ | `defaultSelectedSection` | `SettingsWidgetSectionId` | First visible section | The section to open on, for a host that wants a deep link without owning the selection. Read once per mount and ignored when `selectedSection` is supplied. Scopes arrive with widget init, so a section this names opens as soon as it becomes visible; one the user's scopes never grant leaves the first visible section on screen. |
564
+ | `onSelectedSectionChange` | `(section: SettingsWidgetSectionId) => void` | `undefined` | Called with the id of the section the user selected. Fires whether or not `selectedSection` is supplied, so a host can mirror the selection into its URL without taking ownership of it. |
565
+ | `additionalSections` | `SettingsWidgetAdditionalSection[]` | `undefined` | Host-owned sections rendered alongside the built-in ones. Each is `{ id, label, content }` plus an optional `after` naming the built-in section to place it behind. Unlike the built-ins, these are not scope-gated. |
566
+ | `helpContactUrl` | `string` | `undefined` | Forwarded to the Help section's widget — where its "Contact Us" line links (a support page URL or a `mailto:`). The line is hidden while unset, since the package has no tenant-agnostic support address to fall back on; the bank name in that line comes from widget init. |
567
+ | `helpContent` | `ReactNode` | Help widget | Replaces the help section content. |
568
+ | `finopsThemeColors` | `FinopsThemeColors` | `undefined` | Optional Monite theme color overrides. |
568
569
 
569
570
  ### TagsWidget
570
571
 
@@ -599,10 +600,13 @@ A self-contained banking widget for creating book or ACH transfers and reviewing
599
600
 
600
601
  #### Props
601
602
 
602
- | Prop | Type | Default | Description |
603
- | --------------- | --------------------------------------- | ---------------- | --------------------------------------------------------------------- |
604
- | `labels` | `Partial<TransfersWidgetLabels>` | English labels | Override shell and modal copy. |
605
- | `featureLabels` | `Partial<TransfersWidgetFeatureLabels>` | English defaults | Override routing copy, fallbacks, default currency, and ACH SEC code. |
603
+ | Prop | Type | Default | Description |
604
+ | ---------------------------- | --------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
605
+ | `labels` | `Partial<TransfersWidgetLabels>` | English labels | Override shell and modal copy. |
606
+ | `featureLabels` | `Partial<TransfersWidgetFeatureLabels>` | English defaults | Override routing copy, fallbacks, default currency, and ACH SEC code. |
607
+ | `isTransferMoneyOpen` | `boolean` | Uncontrolled | Whether the transfer money modal is showing. Supplying it makes the modal controlled: the widget reports every open and close and changes nothing until you re-supply a new value. |
608
+ | `defaultIsTransferMoneyOpen` | `boolean` | `false` | The modal's state on first render, for a host that only wants to seed it. Ignored when `isTransferMoneyOpen` is supplied. |
609
+ | `onTransferMoneyOpenChange` | `(open: boolean) => void` | `undefined` | Called on every open and close — the **Transfer money** CTA, the modal's own dismissals (Esc, overlay, close), and the close after a completed transfer. |
606
610
 
607
611
  ### UploadReceiptWidget
608
612
 
@@ -784,11 +784,13 @@ interface WidgetSuiteCardsSelection {
784
784
  }
785
785
  interface WidgetSuiteSettingsSelection {
786
786
  /**
787
- * The settings section on screen. Controlled only: the suite never supplies a
788
- * value of its own, because `SettingsWidget` substitutes another section when
789
- * this one is not available to the user and reports nothing when it does
790
- * (EMBD-4980 adds the `defaultSelectedSection` that would make an initial
791
- * value safe).
787
+ * The settings section on screen. The suite holds this one, so it survives
788
+ * leaving the section — but hands it down as the widget's
789
+ * `defaultSelectedSection`, never its controlled `selectedSection`. The widget
790
+ * substitutes another section when this one is not available to the user and
791
+ * reports nothing when it does, so a controlled value could disagree with the
792
+ * screen with no way to recover; an initial one just loses a deep link the
793
+ * user could never have reached.
792
794
  */
793
795
  section?: SettingsWidgetSectionId;
794
796
  }
@@ -814,14 +816,11 @@ interface WidgetSuiteSelection {
814
816
  settings?: WidgetSuiteSettingsSelection;
815
817
  }
816
818
  /**
817
- * Where the suite can *open*, which is not everything it can be driven to:
818
- * `SettingsWidget` takes no initial section, so naming one here would be a
819
- * silent no-op (EMBD-4980 adds the prop that makes it work).
820
- *
821
- * Derived rather than hand-written, so each key stays in exactly one of the two
822
- * types as the widgets behind them gain the props they are missing.
819
+ * Where the suite can *open*, which is narrower than what it can be driven to
820
+ * whenever a key's widget takes no initial value. Every key has both halves
821
+ * today, so nothing is omitted; this is where the next controlled-only key goes.
823
822
  */
824
- type WidgetSuiteDefaultSelection = Omit<WidgetSuiteSelection, 'settings'>;
823
+ type WidgetSuiteDefaultSelection = WidgetSuiteSelection;
825
824
  interface WidgetSuiteCardsSelectionSnapshot {
826
825
  cardId: string | null;
827
826
  pagination: CardsWidgetPaginationInput | undefined;
@@ -871,8 +870,7 @@ interface WidgetSuiteProps extends WidgetProviderProps {
871
870
  * Where the suite opens, for a host that wants a deep link but not ownership.
872
871
  * Read once per mount, and ignored per key when `selection` names that key.
873
872
  *
874
- * Carries every key `selection` does bar `settings` — see
875
- * {@link WidgetSuiteDefaultSelection}.
873
+ * Carries every key `selection` does — see {@link WidgetSuiteDefaultSelection}.
876
874
  */
877
875
  defaultSelection?: WidgetSuiteDefaultSelection;
878
876
  /**
@@ -938,9 +936,9 @@ interface WidgetSuiteProps extends WidgetProviderProps {
938
936
  * Navigation is one `selection` object a host can drive key by key, published to
939
937
  * the sections through `WidgetSuiteProvider`. Only the open panel is mounted, so
940
938
  * a key the suite holds survives leaving a section and coming back and a key it
941
- * does not hold is lost: today Accounts remembers its open account and Cards its
942
- * open card, while Bill Pay forgets its tab, Settings its section and each card
943
- * list its cursor. That split is the widgets' current shape rather than a
939
+ * does not hold is lost: today Accounts remembers its open account, Cards its
940
+ * open card and Settings its section, while Bill Pay forgets its tab and each
941
+ * card list its cursor. That split is the widgets' current shape rather than a
944
942
  * decision — see `WidgetSuiteSelection` for the ticket behind each gap.
945
943
  */
946
944
  declare function WidgetSuite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, errorFallback, onError, analytics, disclosuresAcceptance, ...innerProps }: WidgetSuiteProps): React.JSX.Element;
@@ -784,11 +784,13 @@ interface WidgetSuiteCardsSelection {
784
784
  }
785
785
  interface WidgetSuiteSettingsSelection {
786
786
  /**
787
- * The settings section on screen. Controlled only: the suite never supplies a
788
- * value of its own, because `SettingsWidget` substitutes another section when
789
- * this one is not available to the user and reports nothing when it does
790
- * (EMBD-4980 adds the `defaultSelectedSection` that would make an initial
791
- * value safe).
787
+ * The settings section on screen. The suite holds this one, so it survives
788
+ * leaving the section — but hands it down as the widget's
789
+ * `defaultSelectedSection`, never its controlled `selectedSection`. The widget
790
+ * substitutes another section when this one is not available to the user and
791
+ * reports nothing when it does, so a controlled value could disagree with the
792
+ * screen with no way to recover; an initial one just loses a deep link the
793
+ * user could never have reached.
792
794
  */
793
795
  section?: SettingsWidgetSectionId;
794
796
  }
@@ -814,14 +816,11 @@ interface WidgetSuiteSelection {
814
816
  settings?: WidgetSuiteSettingsSelection;
815
817
  }
816
818
  /**
817
- * Where the suite can *open*, which is not everything it can be driven to:
818
- * `SettingsWidget` takes no initial section, so naming one here would be a
819
- * silent no-op (EMBD-4980 adds the prop that makes it work).
820
- *
821
- * Derived rather than hand-written, so each key stays in exactly one of the two
822
- * types as the widgets behind them gain the props they are missing.
819
+ * Where the suite can *open*, which is narrower than what it can be driven to
820
+ * whenever a key's widget takes no initial value. Every key has both halves
821
+ * today, so nothing is omitted; this is where the next controlled-only key goes.
823
822
  */
824
- type WidgetSuiteDefaultSelection = Omit<WidgetSuiteSelection, 'settings'>;
823
+ type WidgetSuiteDefaultSelection = WidgetSuiteSelection;
825
824
  interface WidgetSuiteCardsSelectionSnapshot {
826
825
  cardId: string | null;
827
826
  pagination: CardsWidgetPaginationInput | undefined;
@@ -871,8 +870,7 @@ interface WidgetSuiteProps extends WidgetProviderProps {
871
870
  * Where the suite opens, for a host that wants a deep link but not ownership.
872
871
  * Read once per mount, and ignored per key when `selection` names that key.
873
872
  *
874
- * Carries every key `selection` does bar `settings` — see
875
- * {@link WidgetSuiteDefaultSelection}.
873
+ * Carries every key `selection` does — see {@link WidgetSuiteDefaultSelection}.
876
874
  */
877
875
  defaultSelection?: WidgetSuiteDefaultSelection;
878
876
  /**
@@ -938,9 +936,9 @@ interface WidgetSuiteProps extends WidgetProviderProps {
938
936
  * Navigation is one `selection` object a host can drive key by key, published to
939
937
  * the sections through `WidgetSuiteProvider`. Only the open panel is mounted, so
940
938
  * a key the suite holds survives leaving a section and coming back and a key it
941
- * does not hold is lost: today Accounts remembers its open account and Cards its
942
- * open card, while Bill Pay forgets its tab, Settings its section and each card
943
- * list its cursor. That split is the widgets' current shape rather than a
939
+ * does not hold is lost: today Accounts remembers its open account, Cards its
940
+ * open card and Settings its section, while Bill Pay forgets its tab and each
941
+ * card list its cursor. That split is the widgets' current shape rather than a
944
942
  * decision — see `WidgetSuiteSelection` for the ticket behind each gap.
945
943
  */
946
944
  declare function WidgetSuite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, errorFallback, onError, analytics, disclosuresAcceptance, ...innerProps }: WidgetSuiteProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -4271,6 +4271,13 @@ interface SettingsWidgetProps extends MoniteRegionProviderProps {
4271
4271
  * drive navigation from a route, a search param, or host state. A section
4272
4272
  * hidden by the user's scopes falls back to the first visible one. */
4273
4273
  selectedSection?: SettingsWidgetSectionId;
4274
+ /** The section to open on, for a host that wants a deep link without taking
4275
+ * ownership of the selection. Ignored when
4276
+ * {@link SettingsWidgetProps.selectedSection} is supplied; defaults to the
4277
+ * first visible section. Scopes arrive with the init response, so a section
4278
+ * this names opens as soon as it becomes visible, and one the user's scopes
4279
+ * never grant leaves the first visible section on screen. */
4280
+ defaultSelectedSection?: SettingsWidgetSectionId;
4274
4281
  /** Called with the id of the section the user selected. Fires whether or not
4275
4282
  * {@link SettingsWidgetProps.selectedSection} is supplied, so a host can mirror
4276
4283
  * the selection into its URL without taking ownership of it. */
@@ -4709,10 +4716,25 @@ declare const DEFAULT_FEATURE_LABELS: FeatureLabels;
4709
4716
  interface TransfersWidgetPassthroughProps {
4710
4717
  labels?: Partial<TransfersWidgetLabels>;
4711
4718
  featureLabels?: Partial<FeatureLabels>;
4719
+ /**
4720
+ * Whether the transfer money modal is showing. Supplying it makes the modal
4721
+ * controlled: the widget reports every open and close through
4722
+ * `onTransferMoneyOpenChange` and changes nothing on screen until the host
4723
+ * supplies a new value. Omit to let the widget own it.
4724
+ */
4725
+ isTransferMoneyOpen?: boolean;
4726
+ /** The modal's state on first render, for a host that only wants to seed it. */
4727
+ defaultIsTransferMoneyOpen?: boolean;
4728
+ /**
4729
+ * Called on every open and close — the CTA, the modal's own dismissals, and
4730
+ * the close that follows a completed transfer — whether or not the modal is
4731
+ * controlled.
4732
+ */
4733
+ onTransferMoneyOpenChange?: (open: boolean) => void;
4712
4734
  }
4713
4735
  interface TransfersWidgetProps extends WidgetProviderProps, TransfersWidgetPassthroughProps {
4714
4736
  }
4715
- declare function TransfersWidget({ labels, featureLabels, ...widgetProviderProps }: TransfersWidgetProps): React.JSX.Element;
4737
+ declare function TransfersWidget({ labels, featureLabels, isTransferMoneyOpen, defaultIsTransferMoneyOpen, onTransferMoneyOpenChange, ...widgetProviderProps }: TransfersWidgetProps): React.JSX.Element;
4716
4738
 
4717
4739
  /**
4718
4740
  * Public {@link WidgetProvider} — the integrator-facing provider.
@@ -697,6 +697,13 @@ interface SettingsWidgetProps extends MoniteRegionProviderProps {
697
697
  * drive navigation from a route, a search param, or host state. A section
698
698
  * hidden by the user's scopes falls back to the first visible one. */
699
699
  selectedSection?: SettingsWidgetSectionId;
700
+ /** The section to open on, for a host that wants a deep link without taking
701
+ * ownership of the selection. Ignored when
702
+ * {@link SettingsWidgetProps.selectedSection} is supplied; defaults to the
703
+ * first visible section. Scopes arrive with the init response, so a section
704
+ * this names opens as soon as it becomes visible, and one the user's scopes
705
+ * never grant leaves the first visible section on screen. */
706
+ defaultSelectedSection?: SettingsWidgetSectionId;
700
707
  /** Called with the id of the section the user selected. Fires whether or not
701
708
  * {@link SettingsWidgetProps.selectedSection} is supplied, so a host can mirror
702
709
  * the selection into its URL without taking ownership of it. */
@@ -680,10 +680,25 @@ declare const DEFAULT_FEATURE_LABELS: FeatureLabels;
680
680
  interface TransfersWidgetPassthroughProps {
681
681
  labels?: Partial<TransfersWidgetLabels>;
682
682
  featureLabels?: Partial<FeatureLabels>;
683
+ /**
684
+ * Whether the transfer money modal is showing. Supplying it makes the modal
685
+ * controlled: the widget reports every open and close through
686
+ * `onTransferMoneyOpenChange` and changes nothing on screen until the host
687
+ * supplies a new value. Omit to let the widget own it.
688
+ */
689
+ isTransferMoneyOpen?: boolean;
690
+ /** The modal's state on first render, for a host that only wants to seed it. */
691
+ defaultIsTransferMoneyOpen?: boolean;
692
+ /**
693
+ * Called on every open and close — the CTA, the modal's own dismissals, and
694
+ * the close that follows a completed transfer — whether or not the modal is
695
+ * controlled.
696
+ */
697
+ onTransferMoneyOpenChange?: (open: boolean) => void;
683
698
  }
684
699
  interface TransfersWidgetProps extends WidgetProviderProps, TransfersWidgetPassthroughProps {
685
700
  }
686
- declare function TransfersWidget({ labels, featureLabels, ...widgetProviderProps }: TransfersWidgetProps): React.JSX.Element;
701
+ declare function TransfersWidget({ labels, featureLabels, isTransferMoneyOpen, defaultIsTransferMoneyOpen, onTransferMoneyOpenChange, ...widgetProviderProps }: TransfersWidgetProps): React.JSX.Element;
687
702
 
688
703
  export { DEFAULT_FEATURE_LABELS as TRANSFERS_FEATURE_LABELS_EN, TRANSFERS_WIDGET_LABELS_EN, TransfersWidget };
689
704
  export type { FeatureLabels as TransfersWidgetFeatureLabels, TransfersWidgetLabels, TransfersWidgetProps };
@@ -11,164 +11,186 @@ import { TESOURO_NEW_EMBEDDED_BANK_ACCOUNT_CREATED_SUCCESS_EVENT as ee, emitWidg
11
11
  import { useWidgetConfig as ne, useWidgetError as re, useWidgetLoading as ie } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
12
  import "../../../shared/feature/dist/index.js";
13
13
  import { BankAccountsWidgetAnalyticsEvent as i } from "./index2.js";
14
- import { copyTextToClipboard as ae, formatAmountLabel as a, formatTotalAvailableBalanceLabel as oe, maskAccountNumber as o } from "./index3.js";
15
- import { DEFAULT_FEATURE_LABELS as se } from "./index4.js";
16
- import { getBankAccountsPermissions as ce } from "./index5.js";
17
- import { toAccessRows as le, toOrganizationRoleOptions as ue, toTeamMembers as de } from "./index6.js";
18
- import { DEFAULT_LABELS as fe } from "../../ui/dist/lib/labels.js";
14
+ import { copyTextToClipboard as ae, formatAmountLabel as a, formatTotalAvailableBalanceLabel as oe, maskAccountNumber as se } from "./index3.js";
15
+ import { DEFAULT_FEATURE_LABELS as ce } from "./index4.js";
16
+ import { getBankAccountsPermissions as le } from "./index5.js";
17
+ import { toAccessRows as ue, toOrganizationRoleOptions as de, toTeamMembers as fe } from "./index6.js";
18
+ import { DEFAULT_LABELS as pe } from "../../ui/dist/lib/labels.js";
19
19
  import "../../ui/dist/index.js";
20
- import { useCreateBankAccountMutation as pe } from "../../data-access/dist/index3.js";
21
- import { useGrantBankAccountAccessMutation as me } from "../../data-access/dist/index4.js";
22
- import { useAllOrganizationUsersQuery as he } from "../../data-access/dist/index5.js";
20
+ import { useCreateBankAccountMutation as me } from "../../data-access/dist/index3.js";
21
+ import { useGrantBankAccountAccessMutation as he } from "../../data-access/dist/index4.js";
22
+ import { useAllOrganizationUsersQuery as ge } from "../../data-access/dist/index5.js";
23
23
  import "../../data-access/dist/index.js";
24
- import { filterRolesForOrganization as ge } from "../../../../shared/util-validation/dist/index6.js";
25
- import { useCallback as s, useEffect as _e, useMemo as c, useState as l } from "react";
26
- import { useControllableState as ve } from "@radix-ui/react-use-controllable-state";
24
+ import { filterRolesForOrganization as _e } from "../../../../shared/util-validation/dist/index6.js";
25
+ import { useCallback as o, useEffect as s, useMemo as c, useRef as ve, useState as l } from "react";
26
+ import { useControllableState as ye } from "@radix-ui/react-use-controllable-state";
27
27
  //#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js
28
28
  var u = { nickname: "" };
29
- function d({ labels: a, featureLabels: o, isBankingTaglineVisible: d = !0, bankLogoSrc: be, bankLogoAlt: xe, depositAgreementUrl: Se, selectedAccountId: Ce, defaultSelectedAccountId: we, onSelectedAccountIdChange: Te, "data-testid": Ee }) {
30
- let f = {
31
- ...fe,
29
+ function d(e, t) {
30
+ return e !== void 0 && t !== void 0 && e !== t;
31
+ }
32
+ function f({ labels: a, featureLabels: se, isBankingTaglineVisible: f = !0, bankLogoSrc: xe, bankLogoAlt: Se, depositAgreementUrl: Ce, selectedAccountId: we, defaultSelectedAccountId: Te, onSelectedAccountIdChange: Ee, "data-testid": De } = {}) {
33
+ let p = {
34
+ ...pe,
32
35
  ...a
33
- }, p = {
34
- ...se,
35
- ...o
36
- }, m = r(), { organizationId: h, widgetToken: De, initResponse: g } = ne(), Oe = ie(), _ = !!re(), v = !!(h && De), y = c(() => ce(g?.scopes), [g?.scopes]), ke = v && y.canRead && !!g, [b, x] = ve({
37
- prop: Ce,
38
- defaultProp: we ?? null,
39
- onChange: Te,
36
+ }, m = {
37
+ ...ce,
38
+ ...se
39
+ }, h = r(), { organizationId: g, widgetToken: Oe, initResponse: _ } = ne(), ke = ie(), v = !!re(), y = !!(g && Oe), b = c(() => le(_?.scopes), [_?.scopes]), Ae = y && b.canRead && !!_, x = _?.userId ?? void 0, [S, je] = l(g);
40
+ g !== void 0 && g !== S && je(g);
41
+ let [C, Me] = l(x);
42
+ x !== void 0 && x !== C && Me(x);
43
+ let [Ne, w] = ye({
44
+ prop: we,
45
+ defaultProp: Te ?? null,
46
+ onChange: Ee,
40
47
  caller: "BankAccountsWidget"
41
- }), S = ke && !b, C = s((e) => {
42
- x(e);
43
- }, [x]), [w, T] = l(!1), [E, D] = l(u), [O, k] = l([]), [Ae, A] = l(!1), [j, M] = l(), [N, je] = l({}), [P, F] = l({});
44
- _e(() => {
45
- m(i.Mounted);
46
- }, [m]);
47
- let I = t({ enabled: S }), L = pe(), R = me(), z = w, B = he({ enabled: z }), V = n({ enabled: z }), H = c(() => {
48
- let e = V.data?.data ?? [], t = h ? ge(e, {
49
- organizationId: h,
50
- organizationTypes: g?.organizationTypes ?? []
48
+ }), T = ve({
49
+ organizationId: S,
50
+ userId: C
51
+ }), Pe = d(T.current.organizationId, S) || d(T.current.userId, C);
52
+ s(() => {
53
+ let e = T.current;
54
+ T.current = {
55
+ organizationId: S,
56
+ userId: C
57
+ }, (d(e.organizationId, S) || d(e.userId, C)) && w(null);
58
+ }, [
59
+ S,
60
+ C,
61
+ w
62
+ ]);
63
+ let E = Pe ? null : Ne, D = Ae && !E, O = o((e) => {
64
+ w(e);
65
+ }, [w]), [k, Fe] = l(!1), [A, j] = l(u), [M, N] = l([]), [Ie, P] = l(!1), [F, I] = l(), [Le, Re] = l({}), [L, R] = l({});
66
+ s(() => {
67
+ h(i.Mounted);
68
+ }, [h]);
69
+ let z = t({ enabled: D }), B = me(), V = he(), H = k, U = ge({ enabled: H }), W = n({ enabled: H }), G = c(() => {
70
+ let e = W.data?.data ?? [], t = g ? _e(e, {
71
+ organizationId: g,
72
+ organizationTypes: _?.organizationTypes ?? []
51
73
  }) : e;
52
- return de(B.data?.data ?? [], ue(t));
74
+ return fe(U.data?.data ?? [], de(t));
53
75
  }, [
54
- V.data?.data,
55
- B.data?.data,
56
- h,
57
- g?.organizationTypes
58
- ]), U = B.isLoading || B.isFetchingNextPage || !!B.hasNextPage || V.isResolving, W = !U && !B.isError, G = S ? I.data?.data ?? [] : [], K = [.../* @__PURE__ */ new Set([...H.filter((e) => e.locked).map((e) => e.id), ...O])], q = g?.bankName?.trim() ?? "", Me = g?.vspName?.trim() ?? "", Ne = Se?.trim() || void 0, J = v && y.canWrite, Y = !I.hasNextPage && !I.isFetchingNextPage, Pe = c(() => Y ? oe(G) : void 0, [G, Y]), Fe = G.length > 1 && y.canRead && Y, X = s(async (t, n, r) => {
59
- await ae(r) && (e.success(n === "account" ? p.copyAccountNumberToast : p.copyRoutingNumberToast), F((e) => ({
76
+ W.data?.data,
77
+ U.data?.data,
78
+ g,
79
+ _?.organizationTypes
80
+ ]), K = U.isLoading || U.isFetchingNextPage || !!U.hasNextPage || W.isResolving, q = !K && !U.isError, J = D ? z.data?.data ?? [] : [], Y = [.../* @__PURE__ */ new Set([...G.filter((e) => e.locked).map((e) => e.id), ...M])], X = _?.bankName?.trim() ?? "", ze = _?.vspName?.trim() ?? "", Be = Ce?.trim() || void 0, Z = y && b.canWrite, Q = !z.hasNextPage && !z.isFetchingNextPage, Ve = c(() => Q ? oe(J) : void 0, [J, Q]), He = J.length > 1 && b.canRead && Q, $ = o(async (t, n, r) => {
81
+ await ae(r) && (e.success(n === "account" ? m.copyAccountNumberToast : m.copyRoutingNumberToast), R((e) => ({
60
82
  ...e,
61
83
  [t]: n
62
84
  })), window.setTimeout(() => {
63
- F((e) => ({
85
+ R((e) => ({
64
86
  ...e,
65
87
  [t]: void 0
66
88
  }));
67
89
  }, 2e3));
68
- }, [p.copyAccountNumberToast, p.copyRoutingNumberToast]), Ie = c(() => G.map((e) => ye(e, p, {
69
- isAccountNumberVisible: N[e.id] ?? !1,
70
- isAccountNumberCopied: P[e.id] === "account",
71
- isRoutingNumberCopied: P[e.id] === "routing",
72
- onToggleAccountNumberVisibility: () => je((t) => ({
90
+ }, [m.copyAccountNumberToast, m.copyRoutingNumberToast]), Ue = c(() => J.map((e) => be(e, m, {
91
+ isAccountNumberVisible: Le[e.id] ?? !1,
92
+ isAccountNumberCopied: L[e.id] === "account",
93
+ isRoutingNumberCopied: L[e.id] === "routing",
94
+ onToggleAccountNumberVisibility: () => Re((t) => ({
73
95
  ...t,
74
96
  [e.id]: !t[e.id]
75
97
  })),
76
- onCopyAccountNumber: () => void X(e.id, "account", e.accountNumber),
77
- onCopyRoutingNumber: () => void X(e.id, "routing", e.routingNumber),
98
+ onCopyAccountNumber: () => void $(e.id, "account", e.accountNumber),
99
+ onCopyRoutingNumber: () => void $(e.id, "routing", e.routingNumber),
78
100
  onSelect: () => {
79
- C(e.id), m(i.AccountSelected, { accountId: e.id });
101
+ O(e.id), h(i.AccountSelected, { accountId: e.id });
80
102
  }
81
103
  })), [
82
- G,
83
- N,
84
- P,
85
- p,
86
- X,
87
- C,
88
- m
89
- ]), Z = (t) => {
90
- R.mutate({
104
+ J,
105
+ Le,
106
+ L,
107
+ m,
108
+ $,
109
+ O,
110
+ h
111
+ ]), We = (t) => {
112
+ V.mutate({
91
113
  path: { id: t },
92
- body: { userIds: K }
114
+ body: { userIds: Y }
93
115
  }, { onSuccess: () => {
94
- te(ee), e.success(p.createSuccessToast), D(u), k([]), M(void 0), A(!1), T(!1);
116
+ te(ee), e.success(m.createSuccessToast), j(u), N([]), I(void 0), P(!1), Fe(!1);
95
117
  } });
96
- }, Le = () => {
97
- if (J && W) {
98
- if (E.nickname.trim() === "") {
99
- A(!0);
118
+ }, Ge = () => {
119
+ if (Z && q) {
120
+ if (A.nickname.trim() === "") {
121
+ P(!0);
100
122
  return;
101
123
  }
102
- if (K.length === 0) {
124
+ if (Y.length === 0) {
103
125
  console.warn("No team members selected on submit");
104
126
  return;
105
127
  }
106
- if (j) {
107
- Z(j);
128
+ if (F) {
129
+ We(F);
108
130
  return;
109
131
  }
110
- L.mutate({ body: { nickname: E.nickname.trim() } }, { onSuccess: (e) => {
111
- m(i.AccountCreated, { accountId: e?.id }), e?.id && (M(e.id), Z(e.id));
132
+ B.mutate({ body: { nickname: A.nickname.trim() } }, { onSuccess: (e) => {
133
+ h(i.AccountCreated, { accountId: e?.id }), e?.id && (I(e.id), We(e.id));
112
134
  } });
113
135
  }
114
- }, Re = (e, t) => {
115
- H.find((t) => t.id === e)?.locked || k((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
116
- }, Q = (e) => {
117
- e && !J || (e && (D(u), k([]), M(void 0), A(!1), L.reset(), R.reset()), T(e));
118
- }, $ = L.isPending || R.isPending, ze = le(H, {
119
- selectedUserIds: O,
120
- disabled: $ || !y.canWrite,
121
- fallbackTooltip: f.teamMemberAccessTooltip,
122
- onUserToggle: Re
136
+ }, Ke = (e, t) => {
137
+ G.find((t) => t.id === e)?.locked || N((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
138
+ }, qe = (e) => {
139
+ e && !Z || (e && (j(u), N([]), I(void 0), P(!1), B.reset(), V.reset()), Fe(e));
140
+ }, Je = B.isPending || V.isPending, Ye = ue(G, {
141
+ selectedUserIds: M,
142
+ disabled: Je || !b.canWrite,
143
+ fallbackTooltip: p.teamMemberAccessTooltip,
144
+ onUserToggle: Ke
123
145
  });
124
146
  return {
125
- "data-testid": Ee,
126
- selectedAccountId: b,
127
- title: f.title,
128
- bankDisplayName: q,
129
- bankLogoSrc: be,
130
- bankLogoAlt: xe,
131
- availableBalanceLabel: Pe,
132
- shouldDisplayAvailableBalance: Fe,
133
- isBankingTaglineVisible: d,
134
- accountCards: Ie,
135
- shouldDisplayAddAccountCard: y.canWrite,
136
- isLoading: !_ && (!v || Oe && !g || S && (I.isLoading || I.isFetchingNextPage || I.hasNextPage)),
137
- isError: _ || S && I.isError,
138
- isCreateOpen: w,
139
- createForm: E,
147
+ "data-testid": De,
148
+ selectedAccountId: E,
149
+ title: p.title,
150
+ bankDisplayName: X,
151
+ bankLogoSrc: xe,
152
+ bankLogoAlt: Se,
153
+ availableBalanceLabel: Ve,
154
+ shouldDisplayAvailableBalance: He,
155
+ isBankingTaglineVisible: f,
156
+ accountCards: Ue,
157
+ shouldDisplayAddAccountCard: b.canWrite,
158
+ isLoading: !v && (!y || ke && !_ || D && (z.isLoading || z.isFetchingNextPage || z.hasNextPage)),
159
+ isError: v || D && z.isError,
160
+ isCreateOpen: k,
161
+ createForm: A,
140
162
  legalCopy: {
141
- bankName: q,
142
- vspName: Me,
143
- agreementUrl: Ne
163
+ bankName: X,
164
+ vspName: ze,
165
+ agreementUrl: Be
144
166
  },
145
- accessRows: ze,
146
- isTeamMembersLoading: U,
147
- isTeamMembersError: B.isError,
148
- isCreateSubmitDisabled: !J || !W || E.nickname.trim() === "" || K.length === 0,
149
- isCreateError: L.isError || R.isError,
150
- hasNicknameError: Ae,
151
- isSubmitting: $,
152
- isCreateDisabled: !J,
153
- onCreateOpenChange: Q,
167
+ accessRows: Ye,
168
+ isTeamMembersLoading: K,
169
+ isTeamMembersError: U.isError,
170
+ isCreateSubmitDisabled: !Z || !q || A.nickname.trim() === "" || Y.length === 0,
171
+ isCreateError: B.isError || V.isError,
172
+ hasNicknameError: Ie,
173
+ isSubmitting: Je,
174
+ isCreateDisabled: !Z,
175
+ onCreateOpenChange: qe,
154
176
  onCreateFormChange: (e) => {
155
- A(!1), D(e);
177
+ P(!1), j(e);
156
178
  },
157
- onCreateSubmit: Le,
158
- onAddAccountClick: () => Q(!0),
159
- onSelectAccount: C
179
+ onCreateSubmit: Ge,
180
+ onAddAccountClick: () => qe(!0),
181
+ onSelectAccount: O
160
182
  };
161
183
  }
162
- function ye(e, t, n) {
184
+ function be(e, t, n) {
163
185
  return {
164
186
  id: e.id,
165
187
  name: e.nickname?.trim() || t.accountFallback,
166
188
  balanceLabel: a(e.balance),
167
189
  accountNumberLabel: e.accountNumber,
168
- maskedAccountNumberLabel: o(e.accountNumber),
190
+ maskedAccountNumberLabel: se(e.accountNumber),
169
191
  routingNumberLabel: e.routingNumber,
170
192
  ...n
171
193
  };
172
194
  }
173
195
  //#endregion
174
- export { d as useBankAccountsWidget };
196
+ export { f as useBankAccountsWidget };
@@ -24,7 +24,7 @@ var r = {
24
24
  UploadedPartial: (e, t) => `Uploaded ${e} of ${t} attachments`,
25
25
  TooManyFiles: (e) => `You can only upload up to ${e} files at a time`,
26
26
  Matching: (e) => e === 1 ? "Matching 1 receipt to a transaction" : `Matching ${e} receipts to transactions`,
27
- MatchedAll: (e) => e === 1 ? "Receipt matched to a transaction" : `All ${e} receipts matched to transactions`,
27
+ MatchedAll: (e) => e === 1 ? "1 of 1 receipt matched to a transaction" : `${e} of ${e} receipts matched to transactions`,
28
28
  MatchedPartial: (e, t) => `${e} of ${t} receipts matched. Match the rest from the receipt inbox.`,
29
29
  MatchingUnfinished: (e) => e === 1 ? "Still processing 1 receipt. Matching continues in the background." : `Still processing ${e} receipts. Matching continues in the background.`
30
30
  };