@tesouro/embedded-components-react 0.11.29 → 0.11.31

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
@@ -539,6 +539,7 @@ Lists an organization's **debit** cards one page at a time, with a "Show my card
539
539
  | `createCardLabels` | `PartialDeep<CreateCardWidgetLabels>` | English labels | Label overrides forwarded into the built-in create sheet. |
540
540
  | `createCardFeatureLabels` | toast / untitled-funding overrides | English labels | Overrides the create sheet's toasts, untitled funding-account fallback and pending-activation success copy. |
541
541
  | `onCreateCard` | `() => void` | `undefined` | Your own Create card handler. When supplied, the built-in sheet doesn't open. |
542
+ | `initialView` | `'create'` | `undefined` | Opens the built-in create sheet once on arrival, when Create card would open it. Ignored when `onCreateCard` is supplied. |
542
543
  | `headerStart` | `ReactNode` | `undefined` | Your markup for the start of the header row, beside Create card. Put your heading here; you choose the element and level. |
543
544
  | `onActivateCard` | `(cardId: string) => void` | `undefined` | Called when a row's Activate button is clicked. Omit it and the button isn't rendered. |
544
545
 
package/dist/index.d.ts CHANGED
@@ -3342,6 +3342,20 @@ interface CardsWidgetProps extends WidgetProviderProps {
3342
3342
  * nothing.
3343
3343
  */
3344
3344
  onCreateCard?: () => void;
3345
+ /**
3346
+ * Arrival prop (EMBD-6962): `'create'` lands the reader on the built-in
3347
+ * create sheet instead of the bare list, e.g. from a dashboard "Issue card"
3348
+ * shortcut. Same name and shape as `ReceivablesWidget.initialView`
3349
+ * (EMBD-4184), the other "open on the create form" arrival in the package.
3350
+ *
3351
+ * Read once, when the token's scopes first resolve: the sheet opens only if
3352
+ * the built-in flow is available then (debit, `canCreateCard`, and no host
3353
+ * `onCreateCard`); otherwise the list shows as usual. Closing the sheet
3354
+ * returns to the list and nothing reopens it, and a later change to this
3355
+ * prop is ignored. It is not a controlled value: the widget reads no router,
3356
+ * so a host mirroring it into the URL should clear that param itself.
3357
+ */
3358
+ initialView?: 'create';
3345
3359
  /**
3346
3360
  * Your own markup for the start of the list's header row, beside Create card,
3347
3361
  * typically the heading you would otherwise render above the widget. The
@@ -3369,13 +3383,14 @@ interface CardsWidgetProps extends WidgetProviderProps {
3369
3383
  /**
3370
3384
  * Derived from the internal props rather than restated, so the two cannot drift.
3371
3385
  *
3372
- * Four omissions, not one. `cardProgram` is pinned below. The three create-sheet
3373
- * props are debit-only: the built-in sheet issues against `POST /credit-cards`'s
3386
+ * Five omissions, not one. `cardProgram` is pinned below. The four create-sheet
3387
+ * props (`initialView` among them, since it only ever opens that sheet) are
3388
+ * debit-only: the built-in sheet issues against `POST /credit-cards`'s
3374
3389
  * sibling and `CreateCardWidget` covers debit alone, so credit's Create card
3375
3390
  * needs a host `onCreateCard` or the button hides. That was prose in the doc; the
3376
3391
  * type says it here.
3377
3392
  */
3378
- type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels'>;
3393
+ type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels' | 'initialView'>;
3379
3394
  /**
3380
3395
  * One page of an organization's **credit** cards, with a scope-gated Show my
3381
3396
  * cards toggle and per-row Activate affordance. Selecting a row opens that
@@ -1389,6 +1389,20 @@ interface CardsWidgetProps extends WidgetProviderProps {
1389
1389
  * nothing.
1390
1390
  */
1391
1391
  onCreateCard?: () => void;
1392
+ /**
1393
+ * Arrival prop (EMBD-6962): `'create'` lands the reader on the built-in
1394
+ * create sheet instead of the bare list, e.g. from a dashboard "Issue card"
1395
+ * shortcut. Same name and shape as `ReceivablesWidget.initialView`
1396
+ * (EMBD-4184), the other "open on the create form" arrival in the package.
1397
+ *
1398
+ * Read once, when the token's scopes first resolve: the sheet opens only if
1399
+ * the built-in flow is available then (debit, `canCreateCard`, and no host
1400
+ * `onCreateCard`); otherwise the list shows as usual. Closing the sheet
1401
+ * returns to the list and nothing reopens it, and a later change to this
1402
+ * prop is ignored. It is not a controlled value: the widget reads no router,
1403
+ * so a host mirroring it into the URL should clear that param itself.
1404
+ */
1405
+ initialView?: 'create';
1392
1406
  /**
1393
1407
  * Your own markup for the start of the list's header row, beside Create card,
1394
1408
  * typically the heading you would otherwise render above the widget. The
@@ -1416,13 +1430,14 @@ interface CardsWidgetProps extends WidgetProviderProps {
1416
1430
  /**
1417
1431
  * Derived from the internal props rather than restated, so the two cannot drift.
1418
1432
  *
1419
- * Four omissions, not one. `cardProgram` is pinned below. The three create-sheet
1420
- * props are debit-only: the built-in sheet issues against `POST /credit-cards`'s
1433
+ * Five omissions, not one. `cardProgram` is pinned below. The four create-sheet
1434
+ * props (`initialView` among them, since it only ever opens that sheet) are
1435
+ * debit-only: the built-in sheet issues against `POST /credit-cards`'s
1421
1436
  * sibling and `CreateCardWidget` covers debit alone, so credit's Create card
1422
1437
  * needs a host `onCreateCard` or the button hides. That was prose in the doc; the
1423
1438
  * type says it here.
1424
1439
  */
1425
- type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels'>;
1440
+ type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels' | 'initialView'>;
1426
1441
  /**
1427
1442
  * One page of an organization's **credit** cards, with a scope-gated Show my
1428
1443
  * cards toggle and per-row Activate affordance. Selecting a row opens that
@@ -1389,6 +1389,20 @@ interface CardsWidgetProps extends WidgetProviderProps {
1389
1389
  * nothing.
1390
1390
  */
1391
1391
  onCreateCard?: () => void;
1392
+ /**
1393
+ * Arrival prop (EMBD-6962): `'create'` lands the reader on the built-in
1394
+ * create sheet instead of the bare list, e.g. from a dashboard "Issue card"
1395
+ * shortcut. Same name and shape as `ReceivablesWidget.initialView`
1396
+ * (EMBD-4184), the other "open on the create form" arrival in the package.
1397
+ *
1398
+ * Read once, when the token's scopes first resolve: the sheet opens only if
1399
+ * the built-in flow is available then (debit, `canCreateCard`, and no host
1400
+ * `onCreateCard`); otherwise the list shows as usual. Closing the sheet
1401
+ * returns to the list and nothing reopens it, and a later change to this
1402
+ * prop is ignored. It is not a controlled value: the widget reads no router,
1403
+ * so a host mirroring it into the URL should clear that param itself.
1404
+ */
1405
+ initialView?: 'create';
1392
1406
  /**
1393
1407
  * Your own markup for the start of the list's header row, beside Create card,
1394
1408
  * typically the heading you would otherwise render above the widget. The
@@ -2324,6 +2324,20 @@ interface CardsWidgetProps extends WidgetProviderProps {
2324
2324
  * nothing.
2325
2325
  */
2326
2326
  onCreateCard?: () => void;
2327
+ /**
2328
+ * Arrival prop (EMBD-6962): `'create'` lands the reader on the built-in
2329
+ * create sheet instead of the bare list, e.g. from a dashboard "Issue card"
2330
+ * shortcut. Same name and shape as `ReceivablesWidget.initialView`
2331
+ * (EMBD-4184), the other "open on the create form" arrival in the package.
2332
+ *
2333
+ * Read once, when the token's scopes first resolve: the sheet opens only if
2334
+ * the built-in flow is available then (debit, `canCreateCard`, and no host
2335
+ * `onCreateCard`); otherwise the list shows as usual. Closing the sheet
2336
+ * returns to the list and nothing reopens it, and a later change to this
2337
+ * prop is ignored. It is not a controlled value: the widget reads no router,
2338
+ * so a host mirroring it into the URL should clear that param itself.
2339
+ */
2340
+ initialView?: 'create';
2327
2341
  /**
2328
2342
  * Your own markup for the start of the list's header row, beside Create card,
2329
2343
  * typically the heading you would otherwise render above the widget. The
@@ -2351,13 +2365,14 @@ interface CardsWidgetProps extends WidgetProviderProps {
2351
2365
  /**
2352
2366
  * Derived from the internal props rather than restated, so the two cannot drift.
2353
2367
  *
2354
- * Four omissions, not one. `cardProgram` is pinned below. The three create-sheet
2355
- * props are debit-only: the built-in sheet issues against `POST /credit-cards`'s
2368
+ * Five omissions, not one. `cardProgram` is pinned below. The four create-sheet
2369
+ * props (`initialView` among them, since it only ever opens that sheet) are
2370
+ * debit-only: the built-in sheet issues against `POST /credit-cards`'s
2356
2371
  * sibling and `CreateCardWidget` covers debit alone, so credit's Create card
2357
2372
  * needs a host `onCreateCard` or the button hides. That was prose in the doc; the
2358
2373
  * type says it here.
2359
2374
  */
2360
- type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels'>;
2375
+ type CreditCardsWidgetProps = Omit<CardsWidgetProps, 'cardProgram' | 'cardArtSrc' | 'createCardLabels' | 'createCardFeatureLabels' | 'initialView'>;
2361
2376
 
2362
2377
  /**
2363
2378
  * Derived from the internal props rather than restated, so the two cannot drift.
@@ -3,81 +3,84 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { WidgetProvider as e } from "../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
6
+ import { useWidgetConfig as t, useWidgetInitStaleForToken as n } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
6
7
  import "../../../../shared/feature/dist/index.js";
7
- import { WIDGET_NAME as t } from "./analytics/events.js";
8
- import { cardsListDetailsSheetTestIds as n, cardsListTestIds as r } from "./testIds.js";
9
- import { resolveCardsListLabels as i } from "../../../ui/dist/lib/CardsList/labels.js";
10
- import { CardsList as a } from "../../../ui/dist/lib/CardsList/CardsList.js";
11
- import { CardsListDetailsSheet as o } from "../../../ui/dist/lib/CardsList/CardsListDetailsSheet.js";
8
+ import { WIDGET_NAME as r } from "./analytics/events.js";
9
+ import { cardsListDetailsSheetTestIds as i, cardsListTestIds as a } from "./testIds.js";
10
+ import { resolveCardsListLabels as o } from "../../../ui/dist/lib/CardsList/labels.js";
11
+ import { CardsList as s } from "../../../ui/dist/lib/CardsList/CardsList.js";
12
+ import { CardsListDetailsSheet as c } from "../../../ui/dist/lib/CardsList/CardsListDetailsSheet.js";
12
13
  import "../../../ui/dist/index.js";
13
- import { useCardsWidget as s } from "./useCardsWidget.js";
14
- import { CardDetailsWidget as c } from "../../../../card-details-widget/feature/dist/lib/CardDetailsWidget.js";
14
+ import { useCardsWidget as l } from "./useCardsWidget.js";
15
+ import { CardDetailsWidget as u } from "../../../../card-details-widget/feature/dist/lib/CardDetailsWidget.js";
15
16
  import "../../../../card-details-widget/feature/dist/index.js";
16
- import { CreateCardWidget as l } from "../../../create-card/feature/dist/index8.js";
17
+ import { CreateCardWidget as d } from "../../../create-card/feature/dist/index8.js";
17
18
  import "../../../create-card/feature/dist/index.js";
18
- import { useCallback as u, useMemo as d, useState as f } from "react";
19
- import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
19
+ import { useCallback as f, useMemo as p, useState as m } from "react";
20
+ import { Fragment as ee, jsx as h, jsxs as g } from "react/jsx-runtime";
20
21
  // ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/CardsWidget.js
21
- function g({ cardProgram: e, pagination: t, defaultPagination: g, onPaginationChange: _, labels: v, featureLabels: y, selectedCardId: b, defaultSelectedCardId: x, onSelectedCardIdChange: S, cardDetailsLabels: C, cardDetailsFeatureLabels: w, cardDetailsActivateLabels: T, bankLogoSrc: E, bankLogoAlt: D, cardArtSrc: O, createCardLabels: k, createCardFeatureLabels: A, onCreateCard: j, onActivateCard: M, headerStart: ee }) {
22
- let { selectedCardId: N, onSelectCard: P, onCreateCardClick: F, canCreateCard: I, canReadCards: L, ...R } = s({
22
+ function _({ cardProgram: e, pagination: r, defaultPagination: _, onPaginationChange: v, labels: y, featureLabels: b, selectedCardId: x, defaultSelectedCardId: S, onSelectedCardIdChange: C, cardDetailsLabels: w, cardDetailsFeatureLabels: T, cardDetailsActivateLabels: E, bankLogoSrc: D, bankLogoAlt: O, cardArtSrc: k, createCardLabels: A, createCardFeatureLabels: te, onCreateCard: ne, initialView: re, onActivateCard: j, headerStart: M }) {
23
+ let { initResponse: N } = t(), P = n(), { selectedCardId: F, onSelectCard: I, onCreateCardClick: L, canCreateCard: R, canReadCards: z, ...B } = l({
23
24
  cardProgram: e,
24
- pagination: t,
25
- defaultPagination: g,
26
- onPaginationChange: _,
27
- featureLabels: y,
28
- selectedCardId: b,
29
- defaultSelectedCardId: x,
30
- onSelectedCardIdChange: S,
31
- onCreateCard: j,
32
- onActivateCard: M
33
- }), z = d(() => i(v), [v]), [B, V] = f(!1), [H, U] = f(0), [W, G] = f(N), [K, q] = f(null), J = u(() => {
34
- N !== null && P(null), U((e) => e + 1), V(!0);
35
- }, [N, P]), Y = u(() => {
36
- V(!1), N !== null && P(null);
37
- }, [N, P]), X = u((e) => {
38
- V(!1), P(e);
39
- }, [P]), Z = e === "debit" && !!I && F === void 0, Q = B && N === null && Z;
40
- B && (N !== null || !Z) && V(!1), Q ? K !== "create" && q("create") : N !== null && (K !== "details" && q("details"), N !== W && G(N));
41
- let $ = K === "create", te = N !== null || Q;
42
- return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(a, {
43
- ...R,
44
- canCreateCard: I,
45
- onCreateCardClick: F ?? J,
46
- headerStart: ee,
47
- labels: z,
48
- testIds: r
49
- }), /* @__PURE__ */ m(o, {
50
- isOpen: te,
51
- labels: $ ? z.createSheet : z.detailsSheet,
25
+ pagination: r,
26
+ defaultPagination: _,
27
+ onPaginationChange: v,
28
+ featureLabels: b,
29
+ selectedCardId: x,
30
+ defaultSelectedCardId: S,
31
+ onSelectedCardIdChange: C,
32
+ onCreateCard: ne,
33
+ onActivateCard: j
34
+ }), V = p(() => o(y), [y]), [H, U] = m(!1), [W, G] = m(0), [K, q] = m(F), [J, Y] = m(null), [ie, ae] = m(re === "create"), oe = f(() => {
35
+ F !== null && I(null), G((e) => e + 1), U(!0);
36
+ }, [F, I]), X = f(() => {
37
+ U(!1), F !== null && I(null);
38
+ }, [F, I]), se = f((e) => {
39
+ U(!1), I(e);
40
+ }, [I]), Z = e === "debit" && !!R && L === void 0;
41
+ ie && N && !P && (ae(!1), Z && F === null && (G((e) => e + 1), U(!0)));
42
+ let Q = H && F === null && Z;
43
+ H && (F !== null || !Z) && U(!1), Q ? J !== "create" && Y("create") : F !== null && (J !== "details" && Y("details"), F !== K && q(F));
44
+ let $ = J === "create", ce = F !== null || Q;
45
+ return /* @__PURE__ */ g(ee, { children: [/* @__PURE__ */ h(s, {
46
+ ...B,
47
+ canCreateCard: R,
48
+ onCreateCardClick: L ?? oe,
49
+ headerStart: M,
50
+ labels: V,
51
+ testIds: a
52
+ }), /* @__PURE__ */ h(c, {
53
+ isOpen: ce,
54
+ labels: $ ? V.createSheet : V.detailsSheet,
52
55
  contentClassName: $ ? "ttw:overflow-hidden ttw:p-0 ttw:min-h-0" : void 0,
53
- onClose: Y,
54
- testIds: n,
55
- children: $ && Z ? /* @__PURE__ */ m(l, {
56
- cardArtSrc: O ?? "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='190' viewBox='0 0 300 190'><rect width='300' height='190' rx='16' fill='%23334155'/><rect x='28' y='64' width='44' height='34' rx='6' fill='%2364748b'/></svg>",
57
- labels: k,
58
- featureLabels: A,
59
- onClose: Y,
60
- onCancel: Y,
61
- onViewCard: L ? X : void 0,
56
+ onClose: X,
57
+ testIds: i,
58
+ children: $ && Z ? /* @__PURE__ */ h(d, {
59
+ cardArtSrc: k ?? "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='190' viewBox='0 0 300 190'><rect width='300' height='190' rx='16' fill='%23334155'/><rect x='28' y='64' width='44' height='34' rx='6' fill='%2364748b'/></svg>",
60
+ labels: A,
61
+ featureLabels: te,
62
+ onClose: X,
63
+ onCancel: X,
64
+ onViewCard: z ? se : void 0,
62
65
  className: "ttw:min-h-0 ttw:flex-1"
63
- }, H) : W === null ? null : /* @__PURE__ */ m(c, {
64
- cardId: W,
66
+ }, W) : K === null ? null : /* @__PURE__ */ h(u, {
67
+ cardId: K,
65
68
  cardProgram: e,
66
- labels: C,
67
- activateLabels: T,
68
- featureLabels: w,
69
- cardArtSrc: O,
70
- bankLogoSrc: E,
71
- bankLogoAlt: D,
72
- onClose: Y
73
- }, W)
69
+ labels: w,
70
+ activateLabels: E,
71
+ featureLabels: T,
72
+ cardArtSrc: k,
73
+ bankLogoSrc: D,
74
+ bankLogoAlt: O,
75
+ onClose: X
76
+ }, K)
74
77
  })] });
75
78
  }
76
- function _({ baseUrl: n, widgetToken: r, organizationId: i, configClient: a, gatewayRouting: o, linkComponent: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: f, providerLabels: p, ...h }) {
77
- return /* @__PURE__ */ m(e, {
78
- widgetName: t,
79
- baseUrl: n,
80
- widgetToken: r,
79
+ function v({ baseUrl: t, widgetToken: n, organizationId: i, configClient: a, gatewayRouting: o, linkComponent: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: f, providerLabels: p, ...m }) {
80
+ return /* @__PURE__ */ h(e, {
81
+ widgetName: r,
82
+ baseUrl: t,
83
+ widgetToken: n,
81
84
  organizationId: i,
82
85
  configClient: a,
83
86
  gatewayRouting: o,
@@ -88,7 +91,7 @@ function _({ baseUrl: n, widgetToken: r, organizationId: i, configClient: a, gat
88
91
  analytics: d,
89
92
  disclosuresAcceptance: f,
90
93
  providerLabels: p,
91
- children: /* @__PURE__ */ m(g, { ...h })
94
+ children: /* @__PURE__ */ h(_, { ...m })
92
95
  });
93
96
  }
94
- export { _ as CardsWidget, _ as default };
97
+ export { v as CardsWidget, v as default };
@@ -1,5 +1,5 @@
1
1
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.11.29", n = "c7f6f796fbf7ed387f7daf2a60f4937338d68f8c", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.11.31", n = "790f1ec856a54b6a534aec04737c7bed84a6c1a3", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.11.29",
3
+ "version": "0.11.31",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [