@vtex/faststore 0.0.2 → 0.0.3
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/CHANGELOG.md +26 -0
- package/README.md +4 -2
- package/dist/catalog.json +286 -265
- package/dist/components.d.ts +2 -1
- package/dist/components.js +2 -1
- package/dist/content-types.json +16 -0
- package/dist/core/dist/actions/registry.d.ts +1 -1
- package/dist/core/dist/actions/registry.js +1 -1
- package/dist/core/dist/actions/registry.js.map +1 -1
- package/dist/docs/cart.md +2 -2
- package/dist/docs/session.md +12 -6
- package/dist/docs/sign-in-redirect.md +137 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +2 -2
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +5 -2
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
- package/dist/matter/buy-button/buy-button.d.ts +1 -1
- package/dist/matter/buy-button/buy-button.js +3 -1
- package/dist/matter/buy-button/buy-button.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +6 -6
- package/dist/matter/cart/cart.js +13 -6
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-item/cart-item.d.ts +2 -2
- package/dist/matter/cart-item/cart-item.js +5 -2
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences.js +3 -1
- package/dist/matter/client-preferences/client-preferences.js.map +1 -1
- package/dist/matter/client-profile/client-profile.d.ts +1 -1
- package/dist/matter/client-profile/client-profile.js +3 -1
- package/dist/matter/client-profile/client-profile.js.map +1 -1
- package/dist/matter/client-profile-form/client-profile-form.d.ts +1 -1
- package/dist/matter/client-profile-form/client-profile-form.js +3 -1
- package/dist/matter/client-profile-form/client-profile-form.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options-accordion.d.ts +1 -1
- package/dist/matter/delivery-options/delivery-options-accordion.js +3 -1
- package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options-controller.d.ts +1 -1
- package/dist/matter/delivery-options/delivery-options-controller.js +3 -1
- package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options.d.ts +1 -1
- package/dist/matter/delivery-options/delivery-options.js +3 -1
- package/dist/matter/delivery-options/delivery-options.js.map +1 -1
- package/dist/matter/email-identification/email-identification.d.ts +1 -1
- package/dist/matter/email-identification/email-identification.js +3 -1
- package/dist/matter/email-identification/email-identification.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.d.ts +1 -1
- package/dist/matter/identity-summary/identity-summary.js +3 -1
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/product-list/product-list.d.ts +1 -1
- package/dist/matter/product-list/product-list.js +3 -1
- package/dist/matter/product-list/product-list.js.map +1 -1
- package/dist/matter/region/region.d.ts +1 -1
- package/dist/matter/region/region.js +5 -2
- package/dist/matter/region/region.js.map +1 -1
- package/dist/matter/session/session.js +1 -1
- package/dist/matter/session/session.js.map +1 -1
- package/dist/matter/shipping-address/shipping-address.d.ts +1 -1
- package/dist/matter/shipping-address/shipping-address.js +3 -1
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/sign-in-form/sign-in-form.d.ts +1 -1
- package/dist/matter/sign-in-form/sign-in-form.js +3 -1
- package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
- package/dist/matter/sign-in-redirect/sign-in-redirect.d.ts +45 -0
- package/dist/matter/sign-in-redirect/sign-in-redirect.js +127 -0
- package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -0
- package/dist/sdk/actions/actions-override-context.js +37 -0
- package/dist/sdk/actions/actions-override-context.js.map +1 -0
- package/dist/sdk/actions/cart-action-provider.d.ts +8 -6
- package/dist/sdk/actions/cart-action-provider.js +10 -8
- package/dist/sdk/actions/cart-action-provider.js.map +1 -1
- package/dist/sdk/actions/identity-action-provider.d.ts +2 -2
- package/dist/sdk/actions/identity-action-provider.js +4 -4
- package/dist/sdk/actions/identity-action-provider.js.map +1 -1
- package/dist/sdk/actions/inject-actions.d.ts +1 -5
- package/dist/sdk/actions/inject-actions.js +23 -21
- package/dist/sdk/actions/inject-actions.js.map +1 -1
- package/dist/sdk/actions/region-action-provider.d.ts +4 -3
- package/dist/sdk/actions/region-action-provider.js +6 -5
- package/dist/sdk/actions/region-action-provider.js.map +1 -1
- package/dist/sdk/actions/session-action-provider.d.ts +4 -3
- package/dist/sdk/actions/session-action-provider.js +6 -5
- package/dist/sdk/actions/session-action-provider.js.map +1 -1
- package/dist/sdk/actions/shipping-action-provider.d.ts +4 -3
- package/dist/sdk/actions/shipping-action-provider.js +6 -5
- package/dist/sdk/actions/shipping-action-provider.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/client/create-client.js +24 -2
- package/dist/sdk/client/create-client.js.map +1 -1
- package/dist/sdk/content/create-content-runtime.js +1 -1
- package/dist/utils/safe-href.js +74 -4
- package/dist/utils/safe-href.js.map +1 -1
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ const SessionRootDefinition = defineComponent({
|
|
|
50
50
|
},
|
|
51
51
|
schema: {},
|
|
52
52
|
providesContext: "session",
|
|
53
|
-
guideline: "Read-only identity-state provider, normally the root of the shared layout so the header and every page it serves resolve the same session: reads the Session and broadcasts the anonymous/identified/logged-in tri-state plus the raw loggedIn and canEditData flags. Layout scope fetches client-side
|
|
53
|
+
guideline: "Read-only identity-state provider, normally the root of the shared layout so the header and every page it serves resolve the same session: reads the Session and broadcasts the anonymous/identified/logged-in tri-state plus the raw loggedIn and canEditData flags. Layout scope fetches once client-side and reuses the cache across navigation; page scope fetches fresh server-side on every request. Exactly one per rendered tree — a page must not add its own when the layout already hosts one. See session.md."
|
|
54
54
|
});
|
|
55
55
|
const SessionGuardDefinition = defineComponent({
|
|
56
56
|
name: "SessionGuard",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":[],"sources":["../../../src/matter/session/session.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo } from 'react';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport type { SessionEntity } from '../../sdk/session/operations.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — typed via @graphql-codegen client-preset\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment SessionData on Query {\n session {\n ...SessionFragment\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Tri-state derivation — the single home of the truth table (Decision 2).\n// ---------------------------------------------------------------------------\n\nexport type SessionState = 'anonymous' | 'identified' | 'loggedIn';\n\n/**\n * Derive the identity tri-state from the two raw session flags. `loggedIn` takes precedence: an\n * authenticated shopper is always `loggedIn` regardless of `isIdentified`.\n */\nexport function deriveSessionState({\n loggedIn,\n isIdentified,\n}: {\n loggedIn: boolean;\n isIdentified: boolean;\n}): SessionState {\n if (loggedIn) return 'loggedIn';\n if (isIdentified) return 'identified';\n return 'anonymous';\n}\n\n// ---------------------------------------------------------------------------\n// Session context (read-only derived state + raw flags)\n// ---------------------------------------------------------------------------\n\nexport type SessionContextValue = Readonly<{\n /** Derived tri-state: anonymous | identified | loggedIn. */\n state: SessionState;\n /** Raw authenticated-session flag from `session.loggedIn`. */\n loggedIn: boolean;\n /** Raw edit-permission flag from `session.canEditData`; lets Controls render editable vs. masked. */\n canEditData: boolean;\n /** True while the Session entity has not yet resolved. */\n loading: boolean;\n}>;\n\nconst SESSION_DATA_UNSET = Symbol('SessionContextUnset');\n\nconst SessionContextInternal = createContext<SessionContextValue | typeof SESSION_DATA_UNSET>(SESSION_DATA_UNSET);\n\nexport const SessionContext = SessionContextInternal as React.Context<SessionContextValue>;\n\n/**\n * Read the derived session state and raw flags from the nearest `SessionRoot`. Throws when called\n * outside a `SessionRoot` subtree (a misplaced `useSession()` is a composition bug the author should\n * see immediately, not a silent degrade to anonymous), mirroring `useCart()` (Decision 6).\n *\n * While the Session entity is unresolved the context carries `loading: true` and `state:\n * 'anonymous'` (the least-privileged default); consumers that must not flash gate on `loading`.\n */\nexport function useSession(): SessionContextValue {\n const ctx = useContext(SessionContextInternal);\n if (ctx === SESSION_DATA_UNSET) {\n throw new Error('useSession() must be used inside a <SessionRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type SessionRootProps = {\n /**\n * Session entity slice forwarded by the reactive runtime (`ReactiveDataProvider`) — the value of\n * the `session` top-level field on `SessionData on Query`, not the wrapping `{ session: … }` shape.\n * Receives `null` while the entity has not yet resolved.\n */\n $data?: SessionEntity | null;\n children?: ReactNode;\n};\n\nexport type SessionGuardProps = {\n /** The session states under which the children render. Renders nothing for any other state. */\n when?: SessionState[];\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const SessionRootDefinition = defineComponent<SessionRootProps>({\n name: 'SessionRoot',\n importPath: '@vtex/faststore/components',\n component: SessionRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Session Root', category: 'identity' },\n schema: {},\n providesContext: 'session',\n guideline:\n 'Read-only identity-state provider, normally the root of the shared layout so the header and every page it serves resolve the same session: reads the Session and broadcasts the anonymous/identified/logged-in tri-state plus the raw loggedIn and canEditData flags. Layout scope fetches client-side
|
|
1
|
+
{"version":3,"file":"session.js","names":[],"sources":["../../../src/matter/session/session.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo } from 'react';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport type { SessionEntity } from '../../sdk/session/operations.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — typed via @graphql-codegen client-preset\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment SessionData on Query {\n session {\n ...SessionFragment\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Tri-state derivation — the single home of the truth table (Decision 2).\n// ---------------------------------------------------------------------------\n\nexport type SessionState = 'anonymous' | 'identified' | 'loggedIn';\n\n/**\n * Derive the identity tri-state from the two raw session flags. `loggedIn` takes precedence: an\n * authenticated shopper is always `loggedIn` regardless of `isIdentified`.\n */\nexport function deriveSessionState({\n loggedIn,\n isIdentified,\n}: {\n loggedIn: boolean;\n isIdentified: boolean;\n}): SessionState {\n if (loggedIn) return 'loggedIn';\n if (isIdentified) return 'identified';\n return 'anonymous';\n}\n\n// ---------------------------------------------------------------------------\n// Session context (read-only derived state + raw flags)\n// ---------------------------------------------------------------------------\n\nexport type SessionContextValue = Readonly<{\n /** Derived tri-state: anonymous | identified | loggedIn. */\n state: SessionState;\n /** Raw authenticated-session flag from `session.loggedIn`. */\n loggedIn: boolean;\n /** Raw edit-permission flag from `session.canEditData`; lets Controls render editable vs. masked. */\n canEditData: boolean;\n /** True while the Session entity has not yet resolved. */\n loading: boolean;\n}>;\n\nconst SESSION_DATA_UNSET = Symbol('SessionContextUnset');\n\nconst SessionContextInternal = createContext<SessionContextValue | typeof SESSION_DATA_UNSET>(SESSION_DATA_UNSET);\n\nexport const SessionContext = SessionContextInternal as React.Context<SessionContextValue>;\n\n/**\n * Read the derived session state and raw flags from the nearest `SessionRoot`. Throws when called\n * outside a `SessionRoot` subtree (a misplaced `useSession()` is a composition bug the author should\n * see immediately, not a silent degrade to anonymous), mirroring `useCart()` (Decision 6).\n *\n * While the Session entity is unresolved the context carries `loading: true` and `state:\n * 'anonymous'` (the least-privileged default); consumers that must not flash gate on `loading`.\n */\nexport function useSession(): SessionContextValue {\n const ctx = useContext(SessionContextInternal);\n if (ctx === SESSION_DATA_UNSET) {\n throw new Error('useSession() must be used inside a <SessionRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type SessionRootProps = {\n /**\n * Session entity slice forwarded by the reactive runtime (`ReactiveDataProvider`) — the value of\n * the `session` top-level field on `SessionData on Query`, not the wrapping `{ session: … }` shape.\n * Receives `null` while the entity has not yet resolved.\n */\n $data?: SessionEntity | null;\n children?: ReactNode;\n};\n\nexport type SessionGuardProps = {\n /** The session states under which the children render. Renders nothing for any other state. */\n when?: SessionState[];\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const SessionRootDefinition = defineComponent<SessionRootProps>({\n name: 'SessionRoot',\n importPath: '@vtex/faststore/components',\n component: SessionRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Session Root', category: 'identity' },\n schema: {},\n providesContext: 'session',\n guideline:\n 'Read-only identity-state provider, normally the root of the shared layout so the header and every page it serves resolve the same session: reads the Session and broadcasts the anonymous/identified/logged-in tri-state plus the raw loggedIn and canEditData flags. Layout scope fetches once client-side and reuses the cache across navigation; page scope fetches fresh server-side on every request. Exactly one per rendered tree — a page must not add its own when the layout already hosts one. See session.md.',\n});\n\nexport const SessionGuardDefinition = defineComponent<SessionGuardProps>({\n name: 'SessionGuard',\n importPath: '@vtex/faststore/components',\n component: SessionGuard,\n editor: { label: 'Session Guard', category: 'identity' },\n schema: {\n when: { type: 'array', items: ['anonymous', 'identified', 'loggedIn'] as const, label: 'When State' },\n },\n requiresContext: 'session',\n guideline:\n 'Declarative gate: renders its children only when the current session state is one of the values in `when` (e.g. {\"when\":[\"identified\",\"loggedIn\"]}), else renders nothing. Use it in page or layout JSON to show or hide an identity subtree by state without writing the gate into a component. Must be inside SessionRoot, which may be hosted by the page or by its layout.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function SessionRoot({ $data: $dataProp, children }: SessionRootProps) {\n const $data = useDataOverride($dataProp);\n const session = $data ?? null;\n const loading = session == null;\n\n const value: SessionContextValue = useMemo(() => {\n const loggedIn = session?.loggedIn ?? false;\n const isIdentified = session?.isIdentified ?? false;\n return {\n state: deriveSessionState({ loggedIn, isIdentified }),\n loggedIn,\n canEditData: session?.canEditData ?? false,\n loading,\n };\n }, [session?.loggedIn, session?.isIdentified, session?.canEditData, loading]);\n\n return <SessionContextInternal value={value}>{children}</SessionContextInternal>;\n}\n\nexport function SessionGuard({ when, children }: SessionGuardProps) {\n const { state } = useSession();\n if (!when?.includes(state)) return null;\n return <>{children}</>;\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const Session = {\n Root: SessionRoot,\n Guard: SessionGuard,\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,WAAW,QAAQ;;;;;;CAMxB;;;;;AAYD,SAAgB,mBAAmB,EACjC,UACA,gBAIe;CACf,IAAI,UAAU,OAAO;CACrB,IAAI,cAAc,OAAO;CACzB,OAAO;AACT;AAiBA,MAAM,qBAAqB,OAAO,qBAAqB;AAEvD,MAAM,yBAAyB,cAA+D,kBAAkB;AAEhH,MAAa,iBAAiB;;;;;;;;;AAU9B,SAAgB,aAAkC;CAChD,MAAM,MAAM,WAAW,sBAAsB;CAC7C,IAAI,QAAQ,oBACV,MAAM,IAAI,MAAM,2DAA2D;CAE7E,OAAO;AACT;AA0BA,MAAa,wBAAwB,gBAAkC;CACrE,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,QAAQ;EAAE,OAAO;EAAgB,UAAU;CAAW;CACtD,QAAQ,CAAC;CACT,iBAAiB;CACjB,WACE;AACJ,CAAC;AAED,MAAa,yBAAyB,gBAAmC;CACvE,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAiB,UAAU;CAAW;CACvD,QAAQ,EACN,MAAM;EAAE,MAAM;EAAS,OAAO;GAAC;GAAa;GAAc;EAAU;EAAY,OAAO;CAAa,EACtG;CACA,iBAAiB;CACjB,WACE;AACJ,CAAC;AAMD,SAAgB,YAAY,EAAE,OAAO,WAAW,YAA8B;CAE5E,MAAM,UADQ,gBAAgB,SACV,KAAK;CACzB,MAAM,UAAU,WAAW;CAE3B,MAAM,QAA6B,cAAc;EAC/C,MAAM,WAAW,SAAS,YAAY;EAEtC,OAAO;GACL,OAAO,mBAAmB;IAAE;IAAU,cAFnB,SAAS,gBAAgB;GAEO,CAAC;GACpD;GACA,aAAa,SAAS,eAAe;GACrC;EACF;CACF,GAAG;EAAC,SAAS;EAAU,SAAS;EAAc,SAAS;EAAa;CAAO,CAAC;CAE5E,OAAO,oBAAC,wBAAD;EAA+B;EAAQ;CAAiC,CAAA;AACjF;AAEA,SAAgB,aAAa,EAAE,MAAM,YAA+B;CAClE,MAAM,EAAE,UAAU,WAAW;CAC7B,IAAI,CAAC,MAAM,SAAS,KAAK,GAAG,OAAO;CACnC,OAAO,oBAAA,UAAA,EAAG,SAAW,CAAA;AACvB;AAMA,MAAa,UAAU;CACrB,MAAM;CACN,OAAO;AACT"}
|
|
@@ -149,7 +149,7 @@ export declare const ShippingAddressCancelButtonDefinition: ComponentDefinition<
|
|
|
149
149
|
* ShippingAddressRoot owns the batched form state, manages the current descriptor,
|
|
150
150
|
* and provides context to child Controls. It handles submit dispatch and error tracking.
|
|
151
151
|
*/
|
|
152
|
-
export declare function ShippingAddressRoot({ defaultCountry, className, children, $data: $dataProp, $actions }: ShippingAddressRootProps): import("react/jsx-runtime").JSX.Element;
|
|
152
|
+
export declare function ShippingAddressRoot({ defaultCountry, className, children, $data: $dataProp, $actions: $actionsProp }: Readonly<ShippingAddressRootProps>): import("react/jsx-runtime").JSX.Element;
|
|
153
153
|
/**
|
|
154
154
|
* RecipientNameControl — the only client-validated field (US-4, US-6).
|
|
155
155
|
* Pre-filled from clientProfile, editable, required.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
3
|
import "../../core/dist/index.js";
|
|
4
4
|
import { Field } from "../../particles/field/field.js";
|
|
5
|
+
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
5
6
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
6
7
|
import { AddressSummary, AddressSummaryRoot } from "../../particles/address-summary/address-summary.js";
|
|
7
8
|
import { Select } from "../../particles/select/select.js";
|
|
@@ -389,8 +390,9 @@ const ShippingAddressCancelButtonDefinition = defineComponent({
|
|
|
389
390
|
* ShippingAddressRoot owns the batched form state, manages the current descriptor,
|
|
390
391
|
* and provides context to child Controls. It handles submit dispatch and error tracking.
|
|
391
392
|
*/
|
|
392
|
-
function ShippingAddressRoot({ defaultCountry = "BRA", className, children, $data: $dataProp, $actions }) {
|
|
393
|
+
function ShippingAddressRoot({ defaultCountry = "BRA", className, children, $data: $dataProp, $actions: $actionsProp }) {
|
|
393
394
|
const $data = useDataOverride($dataProp);
|
|
395
|
+
const $actions = useActionsOverride($actionsProp);
|
|
394
396
|
const currentAddress = $data?.shipping?.address;
|
|
395
397
|
const savedAddresses = $data?.shipping?.savedAddresses ?? [];
|
|
396
398
|
const clientProfile = $data?.clientProfile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shipping-address.js","names":[],"sources":["../../../src/matter/shipping-address/shipping-address.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AddressSummary, AddressSummaryRoot } from '../../particles/address-summary/address-summary.js';\nimport type { DrawerRootProps } from '../../particles/drawer/drawer.js';\nimport { Field } from '../../particles/field/field.js';\nimport { Select } from '../../particles/select/select.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport {\n SHIPPING_NETWORK_ERROR_CODE,\n type ShippingAddressInput,\n type ShippingAddressUpdateErrorEntity,\n} from '../../sdk/shipping/shipping-operations.js';\nimport type { CountryDescriptor } from './country-descriptors.js';\nimport { getAvailableCountries, getCountryDescriptor } from './country-descriptors.js';\n\n/**\n * Shipping address step (T2 — Enter and save the delivery address).\n * Single-file matter per ADR-0001; batches form state and writes once via shipping.setAddress.\n * Controls are thin context-bound components that read/write draft state (specs/shipping-address-step.md).\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingAddressData on Query {\n shipping {\n __typename\n id\n address {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n savedAddresses {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n }\n clientProfile {\n __typename\n firstName\n lastName\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The `$data` slice forwarded by the reactive runtime. `ShippingAddressData` selects two root\n * fields (`shipping`, `clientProfile`), so the compiler composes them via\n * `MultipleReactiveDataProvider`, which keys each entity's resolved slice by its own root field —\n * `$data` is `{ shipping: {...}, clientProfile: {...} }`, not a flat/unwrapped shape (that unwrapped\n * shape only applies to single-root-field fragments, e.g. CartTotalizerRoot's `$data.totalizers`).\n */\nexport type ShippingAddressData = {\n shipping?: {\n address?: {\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n } | null;\n savedAddresses?: Array<{\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n }>;\n } | null;\n clientProfile?: {\n firstName?: string | null;\n lastName?: string | null;\n } | null;\n} | null;\n\n/** The batched draft state, keyed by canonical field name (Decision 1). */\ntype AddressDraft = {\n recipientName: string;\n postalCode: string;\n country: string;\n street: string;\n number: string;\n complement: string;\n neighborhood: string;\n city: string;\n state: string;\n};\n\n/** Context value for child Controls to read/write the draft and access the descriptor. */\ntype ShippingAddressContextValue = {\n draft: AddressDraft;\n setDraftField: (field: keyof AddressDraft, value: string) => void;\n descriptor: CountryDescriptor | undefined;\n savedAddresses: Array<{ id: string; address: Partial<AddressDraft> }>;\n selectedSavedId: string | undefined;\n setSelectedSavedId: (id: string | undefined) => void;\n submitting: boolean;\n errors: readonly ShippingAddressUpdateErrorEntity[];\n upstreamError: boolean;\n handleSubmit: () => void;\n currentAddressId: string | undefined;\n /** Formatted current address fields; undefined when there is no current address yet. */\n currentAddress: Partial<AddressDraft> | undefined;\n /**\n * Increments once per successful `setAddress` call (main form submit or drawer submit).\n * Consumed by `ShippingAddressEditController` to switch back to view mode without\n * `ShippingAddressSubmit`/`ShippingAddressSavedAddressSubmit` needing to know about\n * view/edit mode — mirrors the `cartLastAddVar` pulse pattern in matter/cart/cart.tsx,\n * but scoped to this Root's own context since the signal originates and is consumed\n * entirely within this subtree (no cross-tree/global signal needed here).\n */\n submitSuccessSignal: number;\n isFormValid: boolean;\n /**\n * Throws away in-progress edits: re-seeds every field from the stored address and drops the touch marks.\n * Consumed by `ShippingAddressCancelButton`, which would otherwise leave the abandoned values in the\n * draft — the Root outlives the form, and touched fields are never re-seeded.\n */\n discardDraft: () => void;\n};\n\nconst SHIPPING_ADDRESS_CONTEXT_UNSET = Symbol('ShippingAddressContextUnset');\n\nconst ShippingAddressContext = createContext<ShippingAddressContextValue | typeof SHIPPING_ADDRESS_CONTEXT_UNSET>(\n SHIPPING_ADDRESS_CONTEXT_UNSET,\n);\n\nfunction useShippingAddressContext(): ShippingAddressContextValue {\n const ctx = useContext(ShippingAddressContext);\n if (ctx === SHIPPING_ADDRESS_CONTEXT_UNSET) {\n throw new Error('ShippingAddress components must be used inside ShippingAddressRoot.');\n }\n return ctx;\n}\n\n/**\n * Drawer flow state (US-8), kept in its own context separate from ShippingAddressContext so the\n * main data/actions context — read by every field Control — stays unaware of this one downstream\n * UI surface. Only ShippingAddressSavedAddressDrawerController and ShippingAddressSavedAddressSubmit\n * consume it.\n */\ntype ShippingAddressDrawerContextValue = {\n savedAddressDrawerOpen: boolean;\n setSavedAddressDrawerOpen: (open: boolean) => void;\n drawerSubmitting: boolean;\n handleDrawerSubmit: () => void;\n};\n\nconst SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET = Symbol('ShippingAddressDrawerContextUnset');\n\nconst ShippingAddressDrawerContext = createContext<\n ShippingAddressDrawerContextValue | typeof SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET\n>(SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET);\n\nfunction useShippingAddressDrawerContext(): ShippingAddressDrawerContextValue {\n const ctx = useContext(ShippingAddressDrawerContext);\n if (ctx === SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET) {\n throw new Error(\n 'ShippingAddressSavedAddressDrawerController and ShippingAddressSavedAddressSubmit must be used inside ShippingAddressRoot.',\n );\n }\n return ctx;\n}\n\n/**\n * View/edit mode state (view/edit toggle), kept in its own context — separate from\n * ShippingAddressContext and ShippingAddressDrawerContext — so neither of those needs to know\n * this UI surface exists. Consumed by ShippingAddressSummaryView, ShippingAddressEditForm,\n * ShippingAddressEditButton and ShippingAddressCancelButton; the last two are its only writers.\n */\n/** Internal: the section's two states never reach the schema, because each has its own component. */\ntype ShippingAddressSectionState = 'view' | 'edit';\n\ntype ShippingAddressSectionContextValue = {\n mode: ShippingAddressSectionState;\n setMode: (mode: ShippingAddressSectionState) => void;\n};\n\nconst SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET = Symbol('ShippingAddressSectionContextUnset');\n\nconst ShippingAddressSectionContext = createContext<\n ShippingAddressSectionContextValue | typeof SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET\n>(SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET);\n\nfunction useShippingAddressSectionContext(): ShippingAddressSectionContextValue {\n const ctx = useContext(ShippingAddressSectionContext);\n if (ctx === SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET) {\n throw new Error(\n 'ShippingAddressSummaryView, ShippingAddressEditForm, ShippingAddressEditButton and ShippingAddressCancelButton must be used inside ShippingAddressEditController.',\n );\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Props Types\n// ---------------------------------------------------------------------------\n\nexport type ShippingAddressRootProps = {\n /** Default country (ISO alpha-3) when no address exists. */\n defaultCountry?: string;\n className?: string;\n children?: ReactNode;\n /** `ShippingAddressData` forwarded by the reactive runtime. */\n $data?: ShippingAddressData;\n /** Compiler-injected action surface; carries `shipping.setAddress`. */\n $actions?: ComponentActions;\n};\n\nexport type ShippingAddressStreetControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressNumberControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressCityControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressStateControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressPostalCodeControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressComplementControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressNeighborhoodControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressCountryControlProps = {\n className?: string;\n label?: string;\n};\n\nexport type ShippingAddressRecipientNameControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedListProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedOptionProps = {\n id: string;\n className?: string;\n};\n\nexport type ShippingAddressSubmitProps = {\n className?: string;\n label?: string;\n pendingLabel?: string;\n};\n\nexport type ShippingAddressErrorProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedAddressDrawerControllerProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressSavedAddressSubmitProps = {\n className?: string;\n label?: string;\n pendingLabel?: string;\n};\n\nexport type ShippingAddressSelectedSummaryProps = {\n className?: string;\n /**\n * The lines to render, in order — typically the `AddressSummaryRecipient` / `Street` / `Locality`\n * leaves. Defaults to recipient, street, locality when omitted.\n */\n children?: ReactNode;\n};\n\nexport type ShippingAddressEditControllerProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressSectionPanelProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressEditButtonProps = {\n className?: string;\n label?: string;\n /** Compose custom button content (e.g. an Icon plus text); falls back to `label`. */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Root Definition\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddressRootDefinition = defineComponent<ShippingAddressRootProps>({\n name: 'ShippingAddressRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'shipping-address',\n actions: { shipping: ['setAddress'] },\n editor: { label: 'Shipping Address Root', category: 'content' },\n schema: {\n defaultCountry: { type: 'string', default: 'BRA', label: 'Default country (ISO-3)' },\n },\n guideline:\n 'Country-adaptive single-address delivery form; batches all fields and writes once via shipping.setAddress. See shipping-address.md.',\n});\n\n// Control Definitions\nexport const ShippingAddressRecipientNameControlDefinition = defineComponent<ShippingAddressRecipientNameControlProps>({\n name: 'ShippingAddressRecipientNameControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRecipientNameControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Recipient Name Control', category: 'action' },\n schema: {},\n guideline: 'Recipient-name input field; required for submit. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressStreetControlDefinition = defineComponent<ShippingAddressStreetControlProps>({\n name: 'ShippingAddressStreetControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStreetControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Street Control', category: 'action' },\n schema: {},\n guideline: 'Street name input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressNumberControlDefinition = defineComponent<ShippingAddressNumberControlProps>({\n name: 'ShippingAddressNumberControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNumberControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Number Control', category: 'action' },\n schema: {},\n guideline: 'Street number input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressCityControlDefinition = defineComponent<ShippingAddressCityControlProps>({\n name: 'ShippingAddressCityControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCityControl,\n requiresContext: 'shipping-address',\n editor: { label: 'City Control', category: 'action' },\n schema: {},\n guideline: 'City name input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressStateControlDefinition = defineComponent<ShippingAddressStateControlProps>({\n name: 'ShippingAddressStateControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStateControl,\n requiresContext: 'shipping-address',\n editor: { label: 'State Control', category: 'action' },\n schema: {},\n guideline: 'State/province input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressPostalCodeControlDefinition = defineComponent<ShippingAddressPostalCodeControlProps>({\n name: 'ShippingAddressPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressPostalCodeControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Postal Code Control', category: 'action' },\n schema: {},\n guideline: 'Postal code input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressComplementControlDefinition = defineComponent<ShippingAddressComplementControlProps>({\n name: 'ShippingAddressComplementControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressComplementControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Complement Control', category: 'action' },\n schema: {},\n guideline: 'Complement (apartment, suite, etc.) input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressNeighborhoodControlDefinition = defineComponent<ShippingAddressNeighborhoodControlProps>({\n name: 'ShippingAddressNeighborhoodControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNeighborhoodControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Neighborhood Control', category: 'action' },\n schema: {},\n guideline:\n 'Neighborhood (bairro) input field; shown only for countries that have this field (BR in v1). Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressCountryControlDefinition = defineComponent<ShippingAddressCountryControlProps>({\n name: 'ShippingAddressCountryControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCountryControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Country Control', category: 'action' },\n schema: {\n label: { type: 'string', default: 'país', label: 'Field label' },\n },\n guideline:\n 'Country selector; lists only countries with an implemented descriptor. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedListDefinition = defineComponent<ShippingAddressSavedListProps>({\n name: 'ShippingAddressSavedList',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedList,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address List', category: 'commerce' },\n schema: {},\n guideline:\n 'List of saved addresses for logged-in shoppers; renders only if savedAddresses is non-empty. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedOptionDefinition = defineComponent<ShippingAddressSavedOptionProps>({\n name: 'ShippingAddressSavedOption',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedOption,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Option', category: 'commerce' },\n schema: { id: { type: 'string', label: 'Saved address ID' } },\n guideline:\n 'A single saved address option; renders its address via the same AddressSummary particle (through its own AddressSummaryRoot) used by ShippingAddressSelectedSummary, so both share one formatting implementation. Must be a descendant of ShippingAddressSavedList.',\n});\n\nexport const ShippingAddressSubmitDefinition = defineComponent<ShippingAddressSubmitProps>({\n name: 'ShippingAddressSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSubmit,\n requiresContext: 'shipping-address',\n editor: { label: 'Shipping Address Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'salvar endereço', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'salvando...', label: 'Pending label' },\n },\n guideline:\n 'Submit button; dispatches the batched address write. Disabled until recipient name is non-blank. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressErrorDefinition = defineComponent<ShippingAddressErrorProps>({\n name: 'ShippingAddressError',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressError,\n requiresContext: 'shipping-address',\n editor: { label: 'Shipping Address Error', category: 'commerce' },\n schema: {},\n guideline:\n 'Error banner; shows domain validation errors inline or a generic upstream-error state. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedAddressDrawerControllerDefinition =\n defineComponent<ShippingAddressSavedAddressDrawerControllerProps>({\n name: 'ShippingAddressSavedAddressDrawerController',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedAddressDrawerController,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Drawer Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DrawerRoot child (the saved-address selection drawer) and makes it controlled by the shipping-address drawer state: open state and blocked-dismissal-while-submitting are handled here, so do not set raw open/onOpenChange on the wrapped DrawerRoot. Compose as the parent of DrawerRoot, with the drawer trigger and popup as DrawerRoot descendants, same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside ShippingAddressRoot.',\n });\n\nexport const ShippingAddressSavedAddressSubmitDefinition = defineComponent<ShippingAddressSavedAddressSubmitProps>({\n name: 'ShippingAddressSavedAddressSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedAddressSubmit,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'selecionar', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'selecionando...', label: 'Pending label' },\n },\n guideline:\n \"The drawer's \\\"selecionar\\\" submit button; independent submitting state from the main form's Submit (Decision 7); no-ops when the selected saved address is already the current one (Decision 8). Must be inside the saved-address drawer's DrawerPopup and inside ShippingAddressRoot.\",\n});\n\nexport const ShippingAddressSelectedSummaryDefinition = defineComponent<ShippingAddressSelectedSummaryProps>({\n name: 'ShippingAddressSelectedSummary',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSelectedSummary,\n requiresContext: 'shipping-address',\n providesContext: 'address-summary',\n editor: { label: 'Selected Address Summary', category: 'commerce' },\n schema: {},\n guideline:\n 'Provides the current delivery address to the generic AddressSummary particle via AddressSummaryRoot context, and renders the default AddressSummary when composed with no children. Compose AddressSummaryRecipient / Street / Locality directly to choose the order or drop a line. Self-gates to null when there is no current address yet. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressEditControllerDefinition = defineComponent<ShippingAddressEditControllerProps>({\n name: 'ShippingAddressEditController',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditController,\n requiresContext: 'shipping-address',\n providesContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Controller', category: 'commerce' },\n schema: {},\n guideline:\n \"Owns the view/edit toggle for the delivery address section: defaults to view when a current address exists, edit otherwise; switches back to view automatically whenever setAddress succeeds (main form submit or saved-address drawer submit), without ShippingAddressSubmit/ShippingAddressSavedAddressSubmit needing to know about this mode. Compose a ShippingAddressSummaryView holding SelectedSummary + EditButton and a ShippingAddressEditForm holding the form Controls/Submit/Error. Self-contained: it decides from its own data and the shopper's own presses, so no other section opens it and finishing it opens nothing. Must be inside ShippingAddressRoot.\",\n});\n\nexport const ShippingAddressSummaryViewDefinition = defineComponent<ShippingAddressSectionPanelProps>({\n name: 'ShippingAddressSummaryView',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSummaryView,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Summary View', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the delivery section shows the saved-address summary, and nothing while it shows the form. Compose SelectedSummary and a ShippingAddressEditButton inside. Takes no props: which state it gates is which component it is. Must be inside a ShippingAddressEditController.',\n});\n\nexport const ShippingAddressEditFormDefinition = defineComponent<ShippingAddressSectionPanelProps>({\n name: 'ShippingAddressEditForm',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditForm,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Form', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the delivery section shows the address form, and nothing while it shows the summary. Compose the Controls, Submit and Error parts inside. Must be inside a ShippingAddressEditController.',\n});\n\nexport const ShippingAddressEditButtonDefinition = defineComponent<ShippingAddressEditButtonProps>({\n name: 'ShippingAddressEditButton',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditButton,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'editar', label: 'Button label' },\n },\n guideline:\n 'CTA that switches the view/edit mode to edit. Typically placed inside a ShippingAddressSummaryView, next to SelectedSummary. Must be inside ShippingAddressEditController.',\n});\n\nexport const ShippingAddressCancelButtonDefinition = defineComponent<ShippingAddressEditButtonProps>({\n name: 'ShippingAddressCancelButton',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCancelButton,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Cancel Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'cancelar', label: 'Button label' },\n },\n guideline:\n 'Returns the delivery section to its summary without saving. Place it inside a ShippingAddressEditForm so a shopper who opened the form has a way back that does not depend on a successful write. Must be inside ShippingAddressEditController.',\n});\n\n// ---------------------------------------------------------------------------\n// Root Component\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressRoot owns the batched form state, manages the current descriptor,\n * and provides context to child Controls. It handles submit dispatch and error tracking.\n */\nexport function ShippingAddressRoot({\n defaultCountry = 'BRA',\n className,\n children,\n $data: $dataProp,\n $actions,\n}: ShippingAddressRootProps) {\n const $data = useDataOverride($dataProp);\n\n // Current address and saved addresses from the fragment\n const currentAddress = $data?.shipping?.address;\n const savedAddresses = $data?.shipping?.savedAddresses ?? [];\n const clientProfile = $data?.clientProfile;\n\n // Joined shopper-profile name (US-4) — the single fallback for recipientName whenever an\n // address record (the current address, or a saved address picked from the drawer) has none.\n // Always applied as a real draft value, never just a placeholder hint, so the shopper never has\n // to retype a name the profile already has.\n const joinedProfileName = [clientProfile?.firstName, clientProfile?.lastName].filter(Boolean).join(' ');\n\n // Seeds the batched draft from the current address, falling back to empty. The recipient name defaults to\n // the joined profile name when the address has none (US-4): it must be a real pre-filled value, not just a\n // placeholder hint, so the shopper can submit without retyping it. Shared with `discardDraft` below so the\n // initial seed and the cancel path cannot drift apart.\n const seedDraft = useCallback(\n (): AddressDraft => ({\n recipientName: currentAddress?.recipientName ?? joinedProfileName,\n postalCode: currentAddress?.postalCode ?? '',\n country: currentAddress?.country ?? defaultCountry,\n street: currentAddress?.street ?? '',\n number: currentAddress?.number ?? '',\n complement: currentAddress?.complement ?? '',\n neighborhood: currentAddress?.neighborhood ?? '',\n city: currentAddress?.city ?? '',\n state: currentAddress?.state ?? '',\n }),\n [currentAddress, joinedProfileName, defaultCountry],\n );\n\n const [draft, setDraft] = useState<AddressDraft>(seedDraft);\n\n // Error tracking and submission state\n const [submitting, setSubmitting] = useState(false);\n const [errors, setErrors] = useState<readonly ShippingAddressUpdateErrorEntity[]>([]);\n const [upstreamError, setUpstreamError] = useState(false);\n const [selectedSavedId, setSelectedSavedId] = useState<string | undefined>();\n const [savedAddressDrawerOpen, setSavedAddressDrawerOpen] = useState(false);\n const [drawerSubmitting, setDrawerSubmitting] = useState(false);\n const [submitSuccessSignal, setSubmitSuccessSignal] = useState(0);\n\n // Per-field dirty tracking. `draft`'s initial state is set once (via useState's lazy\n // initializer) from whatever currentAddress holds on this component's first render — for a live\n // page, the reactive fragment often resolves asynchronously after that first render\n // (currentAddress starts undefined), so draft needs to catch up once it arrives. Tracked per\n // field, not as one global flag, so editing one field doesn't stop the others from picking up a\n // later currentAddress update (US-1, third criterion: \"untouched fields reflect the new values\").\n const [touchedFields, setTouchedFields] = useState<ReadonlySet<keyof AddressDraft>>(() => new Set());\n\n // Cancelling throws the edit away, and the marks have to go with the values. They are deliberately kept\n // after a successful write — a server that has not echoed the recipient back would otherwise re-seed the\n // profile name over what the shopper typed — but an abandoned edit has nothing worth preserving, and a\n // mark left behind would keep the stored value permanently out of reach of the re-seed effect below.\n const discardDraft = useCallback(() => {\n setTouchedFields(new Set());\n setDraft(seedDraft());\n setErrors([]);\n setUpstreamError(false);\n }, [seedDraft]);\n\n const currentAddressSnapshot = JSON.stringify(currentAddress ?? null);\n const clientProfileSnapshot = JSON.stringify(clientProfile ?? null);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the stringified snapshots (currentAddressSnapshot/clientProfileSnapshot), not object identity, so the effect doesn't refire on every render when Apollo returns a new-but-equal object reference.\n useEffect(() => {\n setDraft((prev) => {\n return {\n recipientName: touchedFields.has('recipientName')\n ? prev.recipientName\n : (currentAddress?.recipientName ?? (joinedProfileName || prev.recipientName)),\n postalCode: touchedFields.has('postalCode') ? prev.postalCode : (currentAddress?.postalCode ?? prev.postalCode),\n country: touchedFields.has('country') ? prev.country : (currentAddress?.country ?? prev.country),\n street: touchedFields.has('street') ? prev.street : (currentAddress?.street ?? prev.street),\n number: touchedFields.has('number') ? prev.number : (currentAddress?.number ?? prev.number),\n complement: touchedFields.has('complement') ? prev.complement : (currentAddress?.complement ?? prev.complement),\n neighborhood: touchedFields.has('neighborhood')\n ? prev.neighborhood\n : (currentAddress?.neighborhood ?? prev.neighborhood),\n city: touchedFields.has('city') ? prev.city : (currentAddress?.city ?? prev.city),\n state: touchedFields.has('state') ? prev.state : (currentAddress?.state ?? prev.state),\n };\n });\n }, [currentAddressSnapshot, clientProfileSnapshot, touchedFields]);\n\n // Compute current address ID for comparison with saved addresses (Decision 8)\n const currentAddressId = currentAddress?.id ?? undefined;\n\n // Formatted current address for read-only display (ShippingAddressSelectedSummary);\n // undefined when there is no current address yet, so the summary can self-gate on it.\n const formattedCurrentAddress = useMemo(() => {\n if (!currentAddress) return undefined;\n return {\n recipientName: currentAddress.recipientName ?? '',\n postalCode: currentAddress.postalCode ?? '',\n country: currentAddress.country ?? '',\n street: currentAddress.street ?? '',\n number: currentAddress.number ?? '',\n complement: currentAddress.complement ?? '',\n neighborhood: currentAddress.neighborhood ?? '',\n city: currentAddress.city ?? '',\n state: currentAddress.state ?? '',\n } satisfies Partial<AddressDraft>;\n }, [currentAddress]);\n\n // Get the current descriptor based on draft country\n const descriptor = getCountryDescriptor(draft.country);\n\n // Map saved addresses with extracted address data\n const mappedSavedAddresses = useMemo(\n () =>\n savedAddresses.map((saved) => ({\n id: saved.id ?? '',\n address: {\n recipientName: saved.recipientName ?? '',\n postalCode: saved.postalCode ?? '',\n country: saved.country ?? '',\n street: saved.street ?? '',\n number: saved.number ?? '',\n complement: saved.complement ?? '',\n neighborhood: saved.neighborhood ?? '',\n city: saved.city ?? '',\n state: saved.state ?? '',\n } as Partial<AddressDraft>,\n })),\n [savedAddresses],\n );\n\n // Update a single draft field\n const setDraftField = useCallback((field: keyof AddressDraft, value: string) => {\n setTouchedFields((prev) => (prev.has(field) ? prev : new Set(prev).add(field)));\n setDraft((prev) => ({ ...prev, [field]: value }));\n }, []);\n\n // Handle saved option selection\n const selectSavedAddress = useCallback(\n (id: string | undefined) => {\n setSelectedSavedId(id);\n if (id) {\n const saved = mappedSavedAddresses.find((s) => s.id === id);\n if (saved?.address) {\n // Selecting a saved address replaces the whole draft with its fields, so mark every\n // field touched — otherwise a later currentAddress sync could clobber this selection.\n setTouchedFields((prev) => new Set([...prev, ...(Object.keys(saved.address) as Array<keyof AddressDraft>)]));\n // A saved address can legitimately have a blank recipientName (Decision 9); fall back to\n // the joined profile name here too, same as the no-address case (US-4), so the field shows\n // a real pre-filled value instead of an empty string masquerading behind a placeholder.\n setDraft((prev) => ({\n ...prev,\n ...saved.address,\n recipientName: saved.address.recipientName || joinedProfileName,\n }));\n }\n }\n },\n [mappedSavedAddresses, joinedProfileName],\n );\n\n // Client-side validation: non-blank recipientName required\n const isFormValid = draft.recipientName.trim().length > 0;\n\n // Submit handler: dispatch setAddress action\n const handleSubmit = useCallback(async () => {\n if (!isFormValid || submitting) return;\n\n if (!$actions?.shipping?.setAddress) return;\n\n setSubmitting(true);\n setErrors([]);\n setUpstreamError(false);\n\n try {\n // Build input, including savedAddressId only if one was selected (US-3, third acceptance criterion).\n // Only include a field the active country's descriptor actually declares (US-2, third/fourth\n // criteria) — otherwise a stale value from a previously-selected country (e.g. `neighborhood`\n // retained in the draft after switching BR -> USA) would leak into the submitted payload.\n const isFieldActive = (field: keyof AddressDraft) => descriptor?.fields.some((f) => f.name === field) ?? false;\n\n const addressFields = {\n recipientName: draft.recipientName.trim(),\n postalCode: draft.postalCode,\n country: draft.country,\n ...(isFieldActive('street') ? { street: draft.street } : {}),\n ...(isFieldActive('number') ? { number: draft.number } : {}),\n ...(isFieldActive('complement') ? { complement: draft.complement } : {}),\n ...(isFieldActive('neighborhood') ? { neighborhood: draft.neighborhood } : {}),\n ...(isFieldActive('city') ? { city: draft.city } : {}),\n ...(isFieldActive('state') ? { state: draft.state } : {}),\n };\n\n const input: ShippingAddressInput = selectedSavedId\n ? { savedAddressId: selectedSavedId, ...addressFields }\n : addressFields;\n\n const userErrors = await $actions.shipping.setAddress(input);\n if (userErrors.length === 0) {\n // Success: cache merge will reactively update the form (US-5, second criterion). The touched\n // marks stay: dropping them re-arms the seeding effect, which would overwrite a recipient the\n // shopper typed with the profile-name fallback whenever the stored address still carries none.\n setErrors([]);\n setSubmitSuccessSignal((n) => n + 1);\n } else if (userErrors.some((e) => e.code === SHIPPING_NETWORK_ERROR_CODE)) {\n // The action resolves (never throws) the synthetic upstream/network failure as a userError;\n // route it to the generic error state, not the inline domain list (US-6 2nd criterion,\n // Decision 5). Draft retained (US-6, third criterion).\n setErrors([]);\n setUpstreamError(true);\n } else {\n // Domain userErrors render inline; retain draft on error (US-6, third criterion)\n setErrors(userErrors);\n }\n } catch (error) {\n // Network/upstream error: surface as generic state (US-6, second criterion)\n console.error('[ShippingAddress] setAddress failed:', error);\n setUpstreamError(true);\n setErrors([]);\n } finally {\n setSubmitting(false);\n }\n }, [isFormValid, submitting, $actions?.shipping?.setAddress, draft, selectedSavedId, descriptor]);\n\n // Drawer submit handler: dispatch setAddress for the selected saved address (US-8, Decision 7)\n const handleDrawerSubmit = useCallback(async () => {\n // Guard: if nothing picked in the drawer, return immediately\n if (!selectedSavedId) return;\n\n // No-op guard (Decision 8): if the selected address is already current, just close and return\n if (currentAddressId !== undefined && selectedSavedId === currentAddressId) {\n setSavedAddressDrawerOpen(false);\n return;\n }\n\n const selectedAddress = mappedSavedAddresses.find((s) => s.id === selectedSavedId);\n if (!selectedAddress) return;\n\n // Incomplete saved address (missing the one client-enforced field, recipientName): an\n // auto-submit would only fail server-side with MISSING_RECIPIENT_NAME. selectSavedAddress\n // already populated the draft from this record when it was picked, so just close the drawer\n // and let the shopper review/complete it via the main form's own submit (Decision 9).\n if (!selectedAddress.address.recipientName?.trim()) {\n setSavedAddressDrawerOpen(false);\n return;\n }\n\n if (!$actions?.shipping?.setAddress) return;\n\n setDrawerSubmitting(true);\n setErrors([]);\n setUpstreamError(false);\n\n try {\n // Build input from the saved address's stored fields (Decision 6)\n const input: ShippingAddressInput = {\n savedAddressId: selectedSavedId,\n recipientName: selectedAddress.address.recipientName || '',\n postalCode: selectedAddress.address.postalCode || '',\n country: selectedAddress.address.country || '',\n street: selectedAddress.address.street || '',\n number: selectedAddress.address.number || '',\n complement: selectedAddress.address.complement || '',\n neighborhood: selectedAddress.address.neighborhood || '',\n city: selectedAddress.address.city || '',\n state: selectedAddress.address.state || '',\n };\n\n const userErrors = await $actions.shipping.setAddress(input);\n if (userErrors.length === 0) {\n // Success: close the drawer (7th acceptance criterion)\n setErrors([]);\n setSavedAddressDrawerOpen(false);\n setSubmitSuccessSignal((n) => n + 1);\n } else if (userErrors.some((e) => e.code === SHIPPING_NETWORK_ERROR_CODE)) {\n // Resolved synthetic upstream/network failure: generic error state (Decision 5).\n setErrors([]);\n setUpstreamError(true);\n } else {\n // Domain userErrors render inline; leave drawer open for retry (7th acceptance criterion)\n setErrors(userErrors);\n }\n } catch (error) {\n // Network/upstream error: surface as generic state and leave drawer open\n console.error('[ShippingAddress] drawer submit failed:', error);\n setUpstreamError(true);\n setErrors([]);\n } finally {\n setDrawerSubmitting(false);\n }\n }, [selectedSavedId, currentAddressId, mappedSavedAddresses, $actions?.shipping?.setAddress]);\n\n // Provide context to all children\n const contextValue: ShippingAddressContextValue = {\n draft,\n setDraftField,\n descriptor,\n savedAddresses: mappedSavedAddresses,\n selectedSavedId,\n setSelectedSavedId: selectSavedAddress,\n submitting,\n errors,\n upstreamError,\n handleSubmit,\n currentAddressId,\n currentAddress: formattedCurrentAddress,\n submitSuccessSignal,\n isFormValid,\n discardDraft,\n };\n\n const drawerContextValue: ShippingAddressDrawerContextValue = {\n savedAddressDrawerOpen,\n setSavedAddressDrawerOpen,\n drawerSubmitting,\n handleDrawerSubmit,\n };\n\n return (\n <ShippingAddressContext.Provider value={contextValue}>\n <ShippingAddressDrawerContext.Provider value={drawerContextValue}>\n <div className={className} data-fs-shipping-address=\"\">\n {children}\n </div>\n </ShippingAddressDrawerContext.Provider>\n </ShippingAddressContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Control Components (thin, context-bound, reuse particles)\n// ---------------------------------------------------------------------------\n\n/**\n * RecipientNameControl — the only client-validated field (US-4, US-6).\n * Pre-filled from clientProfile, editable, required.\n */\nexport function ShippingAddressRecipientNameControl({ className }: ShippingAddressRecipientNameControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const isRendered = descriptor?.fields.some((f) => f.name === 'recipientName');\n if (!isRendered) return null;\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'recipientName');\n const label = fieldDescriptor?.label ?? 'nome do destinatário';\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"recipient-name\" disabled={submitting}>\n <Field.Label>{label}</Field.Label>\n <Field.Control\n value={draft.recipientName}\n onChange={(e) => setDraftField('recipientName', e.currentTarget.value)}\n />\n </Field.Root>\n );\n}\n\n/** StreetControl */\nexport function ShippingAddressStreetControl({ className }: ShippingAddressStreetControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'street');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"street\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.street} onChange={(e) => setDraftField('street', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** NumberControl */\nexport function ShippingAddressNumberControl({ className }: ShippingAddressNumberControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'number');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"number\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.number} onChange={(e) => setDraftField('number', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** CityControl */\nexport function ShippingAddressCityControl({ className }: ShippingAddressCityControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'city');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"city\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.city} onChange={(e) => setDraftField('city', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** StateControl */\nexport function ShippingAddressStateControl({ className }: ShippingAddressStateControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'state');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"state\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.state} onChange={(e) => setDraftField('state', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** PostalCodeControl */\nexport function ShippingAddressPostalCodeControl({ className }: ShippingAddressPostalCodeControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'postalCode');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"postal-code\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.postalCode} onChange={(e) => setDraftField('postalCode', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** ComplementControl */\nexport function ShippingAddressComplementControl({ className }: ShippingAddressComplementControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'complement');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"complement\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.complement} onChange={(e) => setDraftField('complement', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** NeighborhoodControl (BR-specific in v1) */\nexport function ShippingAddressNeighborhoodControl({ className }: ShippingAddressNeighborhoodControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'neighborhood');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"neighborhood\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control\n value={draft.neighborhood}\n onChange={(e) => setDraftField('neighborhood', e.currentTarget.value)}\n />\n </Field.Root>\n );\n}\n\n/** CountryControl — lists only countries with a descriptor (US-2, first criterion) */\nexport function ShippingAddressCountryControl({ className, label = 'país' }: ShippingAddressCountryControlProps) {\n const { draft, setDraftField, setSelectedSavedId, submitting } = useShippingAddressContext();\n\n const availableCountries = getAvailableCountries();\n const countryOptions = availableCountries.map((iso) => {\n const desc = getCountryDescriptor(iso);\n return { value: iso, label: desc?.label ?? iso };\n });\n\n const handleCountryChange = (value: string | null) => {\n if (!value) return;\n const newDesc = getCountryDescriptor(value);\n if (newDesc) {\n setDraftField('country', value);\n setSelectedSavedId(undefined);\n }\n };\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"country\" disabled={submitting}>\n <Field.Label>{label}</Field.Label>\n <Select.Root value={draft.country} onValueChange={handleCountryChange} disabled={submitting}>\n <Select.Trigger>\n {/* Resolves the label directly from the country descriptor rather than relying on Base\n UI's automatic item-label lookup, which only reflects a mounted Select.Item (i.e.\n after the popup has been opened at least once) — otherwise the trigger would show\n the raw ISO code (e.g. \"BRA\") before the shopper ever opens the dropdown. */}\n <Select.Value>{(value) => (value ? (getCountryDescriptor(value)?.label ?? value) : value)}</Select.Value>\n <Select.Icon>▾</Select.Icon>\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n <Select.List>\n {countryOptions.map((option) => (\n <Select.Item key={option.value} value={option.value} label={option.label}>\n {option.label}\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </Field.Root>\n );\n}\n\n// ---------------------------------------------------------------------------\n// SavedAddresses List and Option (US-3)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedList — renders only when savedAddresses is non-empty (logged-in signal).\n */\nexport function ShippingAddressSavedList({ className }: ShippingAddressSavedListProps) {\n const { savedAddresses } = useShippingAddressContext();\n\n if (savedAddresses.length === 0) return null;\n\n return (\n <div className={className} data-fs-shipping-address-saved-list=\"\">\n {savedAddresses.map((saved) => (\n <ShippingAddressSavedOption key={saved.id} id={saved.id} />\n ))}\n </div>\n );\n}\n\n/**\n * ShippingAddressSavedOption — selectable saved address; populates draft on selection.\n * Includes isCurrent visual variant to mark the address matching the current cart address (Decision 8).\n */\nexport function ShippingAddressSavedOption({ id, className }: ShippingAddressSavedOptionProps) {\n const { savedAddresses, selectedSavedId, setSelectedSavedId, currentAddressId } = useShippingAddressContext();\n\n const saved = savedAddresses.find((s) => s.id === id);\n if (!saved) return null;\n\n const isSelected = selectedSavedId === id;\n const isCurrent = currentAddressId !== undefined && currentAddressId === id;\n const hasAddressContent = Boolean(\n saved.address.recipientName || saved.address.street || saved.address.city || saved.address.neighborhood,\n );\n const inputId = `saved-address-${id}`;\n\n return (\n <div\n className={className}\n data-fs-shipping-address-saved-option=\"\"\n {...(isSelected ? { 'data-fs-shipping-address-saved-option-selected': '' } : {})}\n {...(isCurrent ? { 'data-fs-shipping-address-saved-option-current': '' } : {})}\n >\n <input\n id={inputId}\n type=\"radio\"\n name=\"saved-address\"\n value={id}\n checked={isSelected}\n onChange={() => setSelectedSavedId(id)}\n />\n <label htmlFor={inputId}>\n {hasAddressContent ? (\n <AddressSummaryRoot address={saved.address}>\n <AddressSummary />\n </AddressSummaryRoot>\n ) : (\n `Endereço ${id}`\n )}\n </label>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Submit Button (US-5)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSubmit — dispatches the batched submit; reflects pending state.\n */\nexport function ShippingAddressSubmit({\n className,\n label = 'salvar endereço',\n pendingLabel = 'salvando...',\n}: ShippingAddressSubmitProps) {\n const { submitting, handleSubmit, isFormValid } = useShippingAddressContext();\n\n return (\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={submitting || !isFormValid}\n className={className}\n data-fs-shipping-address-submit=\"\"\n {...(submitting ? { 'data-fs-shipping-address-submit-pending': '' } : {})}\n >\n {submitting ? pendingLabel : label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Saved-Address Drawer Controller (US-8)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedAddressDrawerController — makes the wrapped DrawerRoot controlled by the\n * shipping-address context's savedAddressDrawerOpen state, and blocks dismissal (Escape, backdrop\n * click, close button) while drawerSubmitting is true by simply not forwarding the close request\n * to the setter. Mirrors CartOpenOnAdd's cloneElement mechanism. Expects a single DrawerRoot child.\n */\nexport function ShippingAddressSavedAddressDrawerController({\n children,\n}: ShippingAddressSavedAddressDrawerControllerProps) {\n const { savedAddressDrawerOpen, setSavedAddressDrawerOpen, drawerSubmitting } = useShippingAddressDrawerContext();\n\n if (!isValidElement<Pick<DrawerRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open: savedAddressDrawerOpen,\n onOpenChange: (next: boolean) => {\n if (!next && drawerSubmitting) return;\n setSavedAddressDrawerOpen(next);\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Saved-Address Submit (US-8)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedAddressSubmit — the drawer's \"selecionar\" submit button; independent\n * submitting state from the main form's Submit (Decision 7); no-ops when the selected saved\n * address is already the current one (Decision 8).\n */\nexport function ShippingAddressSavedAddressSubmit({\n className,\n label = 'selecionar',\n pendingLabel = 'selecionando...',\n}: ShippingAddressSavedAddressSubmitProps) {\n const { selectedSavedId } = useShippingAddressContext();\n const { drawerSubmitting, handleDrawerSubmit } = useShippingAddressDrawerContext();\n\n return (\n <button\n type=\"button\"\n onClick={handleDrawerSubmit}\n disabled={drawerSubmitting || !selectedSavedId}\n className={className}\n data-fs-shipping-address-saved-address-submit=\"\"\n {...(drawerSubmitting ? { 'data-fs-shipping-address-saved-address-submit-pending': '' } : {})}\n >\n {drawerSubmitting ? pendingLabel : label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Selected Address Summary (read-only, self-gating)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSelectedSummary — provides the current delivery address via AddressSummaryRoot's\n * context and renders it through AddressSummary. Composed lines go through that same wrapper rather\n * than replacing it, because AddressSummaryRoot renders no DOM and `className` would have nowhere to\n * land. Self-gating on currentAddress: renders null when there is none yet, rather than an empty\n * provider with nothing meaningful to show.\n */\nexport function ShippingAddressSelectedSummary({ className, children }: ShippingAddressSelectedSummaryProps) {\n const { currentAddress } = useShippingAddressContext();\n\n if (!currentAddress) return null;\n\n return (\n <AddressSummaryRoot address={currentAddress}>\n <AddressSummary className={className}>{children}</AddressSummary>\n </AddressSummaryRoot>\n );\n}\n\n// ---------------------------------------------------------------------------\n// View/Edit Mode Toggle (composable — Free Particle Model)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressEditController — owns the view/edit mode. Defaults to 'view' when a current\n * address exists, 'edit' otherwise (derived reactively from currentAddressId, so it self-corrects\n * if the address arrives asynchronously after mount, same issue as the draft-sync effect above).\n * Once the shopper explicitly toggles (via ShippingAddressEditButton) or a submit succeeds, the\n * explicit mode takes over. Does not render any DOM itself; provides ShippingAddressSectionContext\n * to ShippingAddressSummaryView/ShippingAddressEditForm/ShippingAddressEditButton descendants.\n */\nexport function ShippingAddressEditController({ children }: ShippingAddressEditControllerProps) {\n const { currentAddressId, submitSuccessSignal } = useShippingAddressContext();\n const [explicitMode, setExplicitMode] = useState<ShippingAddressSectionState | undefined>(undefined);\n const lastHandledSignal = useRef(submitSuccessSignal);\n\n useEffect(() => {\n if (submitSuccessSignal !== lastHandledSignal.current) {\n lastHandledSignal.current = submitSuccessSignal;\n setExplicitMode('view');\n }\n }, [submitSuccessSignal]);\n\n // This section decides alone: the form when there is no address to show, the summary when there is, and\n // whatever the shopper last chose once they have chosen. It reports nothing to anything else, so finishing\n // it opens no other section.\n const mode: ShippingAddressSectionState = explicitMode ?? (currentAddressId !== undefined ? 'view' : 'edit');\n\n const modeContextValue = useMemo<ShippingAddressSectionContextValue>(\n () => ({ mode, setMode: setExplicitMode }),\n [mode],\n );\n\n return (\n <ShippingAddressSectionContext.Provider value={modeContextValue}>{children}</ShippingAddressSectionContext.Provider>\n );\n}\n\n/** Renders its children only while the section shows the saved-address summary. */\nexport function ShippingAddressSummaryView({ children }: ShippingAddressSectionPanelProps) {\n const { mode } = useShippingAddressSectionContext();\n if (mode !== 'view') return null;\n return <>{children}</>;\n}\n\n/** Renders its children only while the section shows the address form. */\nexport function ShippingAddressEditForm({ children }: ShippingAddressSectionPanelProps) {\n const { mode } = useShippingAddressSectionContext();\n if (mode !== 'edit') return null;\n return <>{children}</>;\n}\n\n/**\n * ShippingAddressEditButton — CTA that switches the mode to 'edit'. Has no knowledge of why the\n * mode might currently be 'view' (a current address, or a just-completed submit) — it only writes\n * the mode forward.\n */\nexport function ShippingAddressEditButton({ className, label = 'editar', children }: ShippingAddressEditButtonProps) {\n const { setMode } = useShippingAddressSectionContext();\n return (\n <button type=\"button\" onClick={() => setMode('edit')} className={className} data-fs-shipping-address-edit-button=\"\">\n {children ?? label}\n </button>\n );\n}\n\n/**\n * ShippingAddressCancelButton — returns the section to its summary without writing. Without it a\n * shopper who opens the form can only leave through a successful `setAddress`, and blanking the\n * recipient disables Submit, which leaves the section stuck open over the summary it replaced.\n */\nexport function ShippingAddressCancelButton({\n className,\n label = 'cancelar',\n children,\n}: ShippingAddressEditButtonProps) {\n const { setMode } = useShippingAddressSectionContext();\n const { discardDraft } = useShippingAddressContext();\n return (\n <button\n type=\"button\"\n onClick={() => {\n discardDraft();\n setMode('view');\n }}\n className={className}\n data-fs-shipping-address-cancel-button=\"\"\n >\n {children ?? label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Error Component (US-6)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressError — renders domain userErrors inline, or generic upstream error state.\n */\nexport function ShippingAddressError({ className }: ShippingAddressErrorProps) {\n const { errors, upstreamError } = useShippingAddressContext();\n\n if (errors.length === 0 && !upstreamError) return null;\n\n return (\n <div className={className} data-fs-shipping-address-error=\"\">\n {upstreamError ? (\n <div>Não foi possível salvar este endereço. Revise os dados e tente novamente.</div>\n ) : (\n <ul>\n {errors.map((error, idx) => (\n <li key={idx}>{error.message}</li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddress = {\n Root: ShippingAddressRoot,\n RootDefinition: ShippingAddressRootDefinition,\n RecipientNameControl: ShippingAddressRecipientNameControl,\n RecipientNameControlDefinition: ShippingAddressRecipientNameControlDefinition,\n StreetControl: ShippingAddressStreetControl,\n StreetControlDefinition: ShippingAddressStreetControlDefinition,\n NumberControl: ShippingAddressNumberControl,\n NumberControlDefinition: ShippingAddressNumberControlDefinition,\n CityControl: ShippingAddressCityControl,\n CityControlDefinition: ShippingAddressCityControlDefinition,\n StateControl: ShippingAddressStateControl,\n StateControlDefinition: ShippingAddressStateControlDefinition,\n PostalCodeControl: ShippingAddressPostalCodeControl,\n PostalCodeControlDefinition: ShippingAddressPostalCodeControlDefinition,\n ComplementControl: ShippingAddressComplementControl,\n ComplementControlDefinition: ShippingAddressComplementControlDefinition,\n NeighborhoodControl: ShippingAddressNeighborhoodControl,\n NeighborhoodControlDefinition: ShippingAddressNeighborhoodControlDefinition,\n CountryControl: ShippingAddressCountryControl,\n CountryControlDefinition: ShippingAddressCountryControlDefinition,\n SavedList: ShippingAddressSavedList,\n SavedListDefinition: ShippingAddressSavedListDefinition,\n SavedOption: ShippingAddressSavedOption,\n SavedOptionDefinition: ShippingAddressSavedOptionDefinition,\n Submit: ShippingAddressSubmit,\n SubmitDefinition: ShippingAddressSubmitDefinition,\n SavedAddressDrawerController: ShippingAddressSavedAddressDrawerController,\n SavedAddressDrawerControllerDefinition: ShippingAddressSavedAddressDrawerControllerDefinition,\n SavedAddressSubmit: ShippingAddressSavedAddressSubmit,\n SavedAddressSubmitDefinition: ShippingAddressSavedAddressSubmitDefinition,\n SelectedSummary: ShippingAddressSelectedSummary,\n SelectedSummaryDefinition: ShippingAddressSelectedSummaryDefinition,\n EditController: ShippingAddressEditController,\n EditControllerDefinition: ShippingAddressEditControllerDefinition,\n SummaryView: ShippingAddressSummaryView,\n SummaryViewDefinition: ShippingAddressSummaryViewDefinition,\n EditForm: ShippingAddressEditForm,\n EditFormDefinition: ShippingAddressEditFormDefinition,\n EditButton: ShippingAddressEditButton,\n EditButtonDefinition: ShippingAddressEditButtonDefinition,\n CancelButton: ShippingAddressCancelButton,\n CancelButtonDefinition: ShippingAddressCancelButtonDefinition,\n Error: ShippingAddressError,\n ErrorDefinition: ShippingAddressErrorDefinition,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI/B,MAAM,iCAAiC,OAAO,6BAA6B;AAE3E,MAAM,yBAAyB,cAC7B,8BACF;AAEA,SAAS,4BAAyD;CAChE,MAAM,MAAM,WAAW,sBAAsB;CAC7C,IAAI,QAAQ,gCACV,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAeA,MAAM,wCAAwC,OAAO,mCAAmC;AAExF,MAAM,+BAA+B,cAEnC,qCAAqC;AAEvC,SAAS,kCAAqE;CAC5E,MAAM,MAAM,WAAW,4BAA4B;CACnD,IAAI,QAAQ,uCACV,MAAM,IAAI,MACR,4HACF;CAEF,OAAO;AACT;AAgBA,MAAM,yCAAyC,OAAO,oCAAoC;AAE1F,MAAM,gCAAgC,cAEpC,sCAAsC;AAExC,SAAS,mCAAuE;CAC9E,MAAM,MAAM,WAAW,6BAA6B;CACpD,IAAI,QAAQ,wCACV,MAAM,IAAI,MACR,mKACF;CAEF,OAAO;AACT;AA+GA,MAAa,gCAAgC,gBAA0C;CACrF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,iBAAiB;CACjB,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE;CACpC,QAAQ;EAAE,OAAO;EAAyB,UAAU;CAAU;CAC9D,QAAQ,EACN,gBAAgB;EAAE,MAAM;EAAU,SAAS;EAAO,OAAO;CAA0B,EACrF;CACA,WACE;AACJ,CAAC;AAGD,MAAa,gDAAgD,gBAA0D;CACrH,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA0B,UAAU;CAAS;CAC9D,QAAQ,CAAC;CACT,WAAW;AACb,CAAC;AAED,MAAa,yCAAyC,g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AD;EAAgB;EAAW,kCAA+B;EACvD,UAAA,gBACC,oBAAC,OAAD,EAAA,UAAK,4EAA8E,CAAA,IAEnF,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,QAClB,oBAAC,MAAD,EAAA,UAAe,MAAM,QAAY,GAAxB,GAAwB,CAClC,EACC,CAAA;CAEH,CAAA;AAET;AAMA,MAAa,kBAAkB;CAC7B,MAAM;CACN,gBAAgB;CAChB,sBAAsB;CACtB,gCAAgC;CAChC,eAAe;CACf,yBAAyB;CACzB,eAAe;CACf,yBAAyB;CACzB,aAAa;CACb,uBAAuB;CACvB,cAAc;CACd,wBAAwB;CACxB,mBAAmB;CACnB,6BAA6B;CAC7B,mBAAmB;CACnB,6BAA6B;CAC7B,qBAAqB;CACrB,+BAA+B;CAC/B,gBAAgB;CAChB,0BAA0B;CAC1B,WAAW;CACX,qBAAqB;CACrB,aAAa;CACb,uBAAuB;CACvB,QAAQ;CACR,kBAAkB;CAClB,8BAA8B;CAC9B,wCAAwC;CACxC,oBAAoB;CACpB,8BAA8B;CAC9B,iBAAiB;CACjB,2BAA2B;CAC3B,gBAAgB;CAChB,0BAA0B;CAC1B,aAAa;CACb,uBAAuB;CACvB,UAAU;CACV,oBAAoB;CACpB,YAAY;CACZ,sBAAsB;CACtB,cAAc;CACd,wBAAwB;CACxB,OAAO;CACP,iBAAiB;AACnB"}
|
|
1
|
+
{"version":3,"file":"shipping-address.js","names":[],"sources":["../../../src/matter/shipping-address/shipping-address.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AddressSummary, AddressSummaryRoot } from '../../particles/address-summary/address-summary.js';\nimport type { DrawerRootProps } from '../../particles/drawer/drawer.js';\nimport { Field } from '../../particles/field/field.js';\nimport { Select } from '../../particles/select/select.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport {\n SHIPPING_NETWORK_ERROR_CODE,\n type ShippingAddressInput,\n type ShippingAddressUpdateErrorEntity,\n} from '../../sdk/shipping/shipping-operations.js';\nimport type { CountryDescriptor } from './country-descriptors.js';\nimport { getAvailableCountries, getCountryDescriptor } from './country-descriptors.js';\n\n/**\n * Shipping address step (T2 — Enter and save the delivery address).\n * Single-file matter per ADR-0001; batches form state and writes once via shipping.setAddress.\n * Controls are thin context-bound components that read/write draft state (specs/shipping-address-step.md).\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingAddressData on Query {\n shipping {\n __typename\n id\n address {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n savedAddresses {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n }\n clientProfile {\n __typename\n firstName\n lastName\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The `$data` slice forwarded by the reactive runtime. `ShippingAddressData` selects two root\n * fields (`shipping`, `clientProfile`), so the compiler composes them via\n * `MultipleReactiveDataProvider`, which keys each entity's resolved slice by its own root field —\n * `$data` is `{ shipping: {...}, clientProfile: {...} }`, not a flat/unwrapped shape (that unwrapped\n * shape only applies to single-root-field fragments, e.g. CartTotalizerRoot's `$data.totalizers`).\n */\nexport type ShippingAddressData = {\n shipping?: {\n address?: {\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n } | null;\n savedAddresses?: Array<{\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n }>;\n } | null;\n clientProfile?: {\n firstName?: string | null;\n lastName?: string | null;\n } | null;\n} | null;\n\n/** The batched draft state, keyed by canonical field name (Decision 1). */\ntype AddressDraft = {\n recipientName: string;\n postalCode: string;\n country: string;\n street: string;\n number: string;\n complement: string;\n neighborhood: string;\n city: string;\n state: string;\n};\n\n/** Context value for child Controls to read/write the draft and access the descriptor. */\ntype ShippingAddressContextValue = {\n draft: AddressDraft;\n setDraftField: (field: keyof AddressDraft, value: string) => void;\n descriptor: CountryDescriptor | undefined;\n savedAddresses: Array<{ id: string; address: Partial<AddressDraft> }>;\n selectedSavedId: string | undefined;\n setSelectedSavedId: (id: string | undefined) => void;\n submitting: boolean;\n errors: readonly ShippingAddressUpdateErrorEntity[];\n upstreamError: boolean;\n handleSubmit: () => void;\n currentAddressId: string | undefined;\n /** Formatted current address fields; undefined when there is no current address yet. */\n currentAddress: Partial<AddressDraft> | undefined;\n /**\n * Increments once per successful `setAddress` call (main form submit or drawer submit).\n * Consumed by `ShippingAddressEditController` to switch back to view mode without\n * `ShippingAddressSubmit`/`ShippingAddressSavedAddressSubmit` needing to know about\n * view/edit mode — mirrors the `cartLastAddVar` pulse pattern in matter/cart/cart.tsx,\n * but scoped to this Root's own context since the signal originates and is consumed\n * entirely within this subtree (no cross-tree/global signal needed here).\n */\n submitSuccessSignal: number;\n isFormValid: boolean;\n /**\n * Throws away in-progress edits: re-seeds every field from the stored address and drops the touch marks.\n * Consumed by `ShippingAddressCancelButton`, which would otherwise leave the abandoned values in the\n * draft — the Root outlives the form, and touched fields are never re-seeded.\n */\n discardDraft: () => void;\n};\n\nconst SHIPPING_ADDRESS_CONTEXT_UNSET = Symbol('ShippingAddressContextUnset');\n\nconst ShippingAddressContext = createContext<ShippingAddressContextValue | typeof SHIPPING_ADDRESS_CONTEXT_UNSET>(\n SHIPPING_ADDRESS_CONTEXT_UNSET,\n);\n\nfunction useShippingAddressContext(): ShippingAddressContextValue {\n const ctx = useContext(ShippingAddressContext);\n if (ctx === SHIPPING_ADDRESS_CONTEXT_UNSET) {\n throw new Error('ShippingAddress components must be used inside ShippingAddressRoot.');\n }\n return ctx;\n}\n\n/**\n * Drawer flow state (US-8), kept in its own context separate from ShippingAddressContext so the\n * main data/actions context — read by every field Control — stays unaware of this one downstream\n * UI surface. Only ShippingAddressSavedAddressDrawerController and ShippingAddressSavedAddressSubmit\n * consume it.\n */\ntype ShippingAddressDrawerContextValue = {\n savedAddressDrawerOpen: boolean;\n setSavedAddressDrawerOpen: (open: boolean) => void;\n drawerSubmitting: boolean;\n handleDrawerSubmit: () => void;\n};\n\nconst SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET = Symbol('ShippingAddressDrawerContextUnset');\n\nconst ShippingAddressDrawerContext = createContext<\n ShippingAddressDrawerContextValue | typeof SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET\n>(SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET);\n\nfunction useShippingAddressDrawerContext(): ShippingAddressDrawerContextValue {\n const ctx = useContext(ShippingAddressDrawerContext);\n if (ctx === SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET) {\n throw new Error(\n 'ShippingAddressSavedAddressDrawerController and ShippingAddressSavedAddressSubmit must be used inside ShippingAddressRoot.',\n );\n }\n return ctx;\n}\n\n/**\n * View/edit mode state (view/edit toggle), kept in its own context — separate from\n * ShippingAddressContext and ShippingAddressDrawerContext — so neither of those needs to know\n * this UI surface exists. Consumed by ShippingAddressSummaryView, ShippingAddressEditForm,\n * ShippingAddressEditButton and ShippingAddressCancelButton; the last two are its only writers.\n */\n/** Internal: the section's two states never reach the schema, because each has its own component. */\ntype ShippingAddressSectionState = 'view' | 'edit';\n\ntype ShippingAddressSectionContextValue = {\n mode: ShippingAddressSectionState;\n setMode: (mode: ShippingAddressSectionState) => void;\n};\n\nconst SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET = Symbol('ShippingAddressSectionContextUnset');\n\nconst ShippingAddressSectionContext = createContext<\n ShippingAddressSectionContextValue | typeof SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET\n>(SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET);\n\nfunction useShippingAddressSectionContext(): ShippingAddressSectionContextValue {\n const ctx = useContext(ShippingAddressSectionContext);\n if (ctx === SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET) {\n throw new Error(\n 'ShippingAddressSummaryView, ShippingAddressEditForm, ShippingAddressEditButton and ShippingAddressCancelButton must be used inside ShippingAddressEditController.',\n );\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Props Types\n// ---------------------------------------------------------------------------\n\nexport type ShippingAddressRootProps = {\n /** Default country (ISO alpha-3) when no address exists. */\n defaultCountry?: string;\n className?: string;\n children?: ReactNode;\n /** `ShippingAddressData` forwarded by the reactive runtime. */\n $data?: ShippingAddressData;\n /** Compiler-injected action surface; carries `shipping.setAddress`. */\n $actions?: ComponentActions;\n};\n\nexport type ShippingAddressStreetControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressNumberControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressCityControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressStateControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressPostalCodeControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressComplementControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressNeighborhoodControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressCountryControlProps = {\n className?: string;\n label?: string;\n};\n\nexport type ShippingAddressRecipientNameControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedListProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedOptionProps = {\n id: string;\n className?: string;\n};\n\nexport type ShippingAddressSubmitProps = {\n className?: string;\n label?: string;\n pendingLabel?: string;\n};\n\nexport type ShippingAddressErrorProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedAddressDrawerControllerProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressSavedAddressSubmitProps = {\n className?: string;\n label?: string;\n pendingLabel?: string;\n};\n\nexport type ShippingAddressSelectedSummaryProps = {\n className?: string;\n /**\n * The lines to render, in order — typically the `AddressSummaryRecipient` / `Street` / `Locality`\n * leaves. Defaults to recipient, street, locality when omitted.\n */\n children?: ReactNode;\n};\n\nexport type ShippingAddressEditControllerProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressSectionPanelProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressEditButtonProps = {\n className?: string;\n label?: string;\n /** Compose custom button content (e.g. an Icon plus text); falls back to `label`. */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Root Definition\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddressRootDefinition = defineComponent<ShippingAddressRootProps>({\n name: 'ShippingAddressRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'shipping-address',\n actions: { shipping: ['setAddress'] },\n editor: { label: 'Shipping Address Root', category: 'content' },\n schema: {\n defaultCountry: { type: 'string', default: 'BRA', label: 'Default country (ISO-3)' },\n },\n guideline:\n 'Country-adaptive single-address delivery form; batches all fields and writes once via shipping.setAddress. See shipping-address.md.',\n});\n\n// Control Definitions\nexport const ShippingAddressRecipientNameControlDefinition = defineComponent<ShippingAddressRecipientNameControlProps>({\n name: 'ShippingAddressRecipientNameControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRecipientNameControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Recipient Name Control', category: 'action' },\n schema: {},\n guideline: 'Recipient-name input field; required for submit. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressStreetControlDefinition = defineComponent<ShippingAddressStreetControlProps>({\n name: 'ShippingAddressStreetControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStreetControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Street Control', category: 'action' },\n schema: {},\n guideline: 'Street name input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressNumberControlDefinition = defineComponent<ShippingAddressNumberControlProps>({\n name: 'ShippingAddressNumberControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNumberControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Number Control', category: 'action' },\n schema: {},\n guideline: 'Street number input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressCityControlDefinition = defineComponent<ShippingAddressCityControlProps>({\n name: 'ShippingAddressCityControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCityControl,\n requiresContext: 'shipping-address',\n editor: { label: 'City Control', category: 'action' },\n schema: {},\n guideline: 'City name input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressStateControlDefinition = defineComponent<ShippingAddressStateControlProps>({\n name: 'ShippingAddressStateControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStateControl,\n requiresContext: 'shipping-address',\n editor: { label: 'State Control', category: 'action' },\n schema: {},\n guideline: 'State/province input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressPostalCodeControlDefinition = defineComponent<ShippingAddressPostalCodeControlProps>({\n name: 'ShippingAddressPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressPostalCodeControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Postal Code Control', category: 'action' },\n schema: {},\n guideline: 'Postal code input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressComplementControlDefinition = defineComponent<ShippingAddressComplementControlProps>({\n name: 'ShippingAddressComplementControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressComplementControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Complement Control', category: 'action' },\n schema: {},\n guideline: 'Complement (apartment, suite, etc.) input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressNeighborhoodControlDefinition = defineComponent<ShippingAddressNeighborhoodControlProps>({\n name: 'ShippingAddressNeighborhoodControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNeighborhoodControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Neighborhood Control', category: 'action' },\n schema: {},\n guideline:\n 'Neighborhood (bairro) input field; shown only for countries that have this field (BR in v1). Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressCountryControlDefinition = defineComponent<ShippingAddressCountryControlProps>({\n name: 'ShippingAddressCountryControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCountryControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Country Control', category: 'action' },\n schema: {\n label: { type: 'string', default: 'país', label: 'Field label' },\n },\n guideline:\n 'Country selector; lists only countries with an implemented descriptor. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedListDefinition = defineComponent<ShippingAddressSavedListProps>({\n name: 'ShippingAddressSavedList',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedList,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address List', category: 'commerce' },\n schema: {},\n guideline:\n 'List of saved addresses for logged-in shoppers; renders only if savedAddresses is non-empty. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedOptionDefinition = defineComponent<ShippingAddressSavedOptionProps>({\n name: 'ShippingAddressSavedOption',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedOption,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Option', category: 'commerce' },\n schema: { id: { type: 'string', label: 'Saved address ID' } },\n guideline:\n 'A single saved address option; renders its address via the same AddressSummary particle (through its own AddressSummaryRoot) used by ShippingAddressSelectedSummary, so both share one formatting implementation. Must be a descendant of ShippingAddressSavedList.',\n});\n\nexport const ShippingAddressSubmitDefinition = defineComponent<ShippingAddressSubmitProps>({\n name: 'ShippingAddressSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSubmit,\n requiresContext: 'shipping-address',\n editor: { label: 'Shipping Address Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'salvar endereço', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'salvando...', label: 'Pending label' },\n },\n guideline:\n 'Submit button; dispatches the batched address write. Disabled until recipient name is non-blank. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressErrorDefinition = defineComponent<ShippingAddressErrorProps>({\n name: 'ShippingAddressError',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressError,\n requiresContext: 'shipping-address',\n editor: { label: 'Shipping Address Error', category: 'commerce' },\n schema: {},\n guideline:\n 'Error banner; shows domain validation errors inline or a generic upstream-error state. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedAddressDrawerControllerDefinition =\n defineComponent<ShippingAddressSavedAddressDrawerControllerProps>({\n name: 'ShippingAddressSavedAddressDrawerController',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedAddressDrawerController,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Drawer Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DrawerRoot child (the saved-address selection drawer) and makes it controlled by the shipping-address drawer state: open state and blocked-dismissal-while-submitting are handled here, so do not set raw open/onOpenChange on the wrapped DrawerRoot. Compose as the parent of DrawerRoot, with the drawer trigger and popup as DrawerRoot descendants, same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside ShippingAddressRoot.',\n });\n\nexport const ShippingAddressSavedAddressSubmitDefinition = defineComponent<ShippingAddressSavedAddressSubmitProps>({\n name: 'ShippingAddressSavedAddressSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedAddressSubmit,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'selecionar', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'selecionando...', label: 'Pending label' },\n },\n guideline:\n \"The drawer's \\\"selecionar\\\" submit button; independent submitting state from the main form's Submit (Decision 7); no-ops when the selected saved address is already the current one (Decision 8). Must be inside the saved-address drawer's DrawerPopup and inside ShippingAddressRoot.\",\n});\n\nexport const ShippingAddressSelectedSummaryDefinition = defineComponent<ShippingAddressSelectedSummaryProps>({\n name: 'ShippingAddressSelectedSummary',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSelectedSummary,\n requiresContext: 'shipping-address',\n providesContext: 'address-summary',\n editor: { label: 'Selected Address Summary', category: 'commerce' },\n schema: {},\n guideline:\n 'Provides the current delivery address to the generic AddressSummary particle via AddressSummaryRoot context, and renders the default AddressSummary when composed with no children. Compose AddressSummaryRecipient / Street / Locality directly to choose the order or drop a line. Self-gates to null when there is no current address yet. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressEditControllerDefinition = defineComponent<ShippingAddressEditControllerProps>({\n name: 'ShippingAddressEditController',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditController,\n requiresContext: 'shipping-address',\n providesContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Controller', category: 'commerce' },\n schema: {},\n guideline:\n \"Owns the view/edit toggle for the delivery address section: defaults to view when a current address exists, edit otherwise; switches back to view automatically whenever setAddress succeeds (main form submit or saved-address drawer submit), without ShippingAddressSubmit/ShippingAddressSavedAddressSubmit needing to know about this mode. Compose a ShippingAddressSummaryView holding SelectedSummary + EditButton and a ShippingAddressEditForm holding the form Controls/Submit/Error. Self-contained: it decides from its own data and the shopper's own presses, so no other section opens it and finishing it opens nothing. Must be inside ShippingAddressRoot.\",\n});\n\nexport const ShippingAddressSummaryViewDefinition = defineComponent<ShippingAddressSectionPanelProps>({\n name: 'ShippingAddressSummaryView',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSummaryView,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Summary View', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the delivery section shows the saved-address summary, and nothing while it shows the form. Compose SelectedSummary and a ShippingAddressEditButton inside. Takes no props: which state it gates is which component it is. Must be inside a ShippingAddressEditController.',\n});\n\nexport const ShippingAddressEditFormDefinition = defineComponent<ShippingAddressSectionPanelProps>({\n name: 'ShippingAddressEditForm',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditForm,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Form', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the delivery section shows the address form, and nothing while it shows the summary. Compose the Controls, Submit and Error parts inside. Must be inside a ShippingAddressEditController.',\n});\n\nexport const ShippingAddressEditButtonDefinition = defineComponent<ShippingAddressEditButtonProps>({\n name: 'ShippingAddressEditButton',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditButton,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'editar', label: 'Button label' },\n },\n guideline:\n 'CTA that switches the view/edit mode to edit. Typically placed inside a ShippingAddressSummaryView, next to SelectedSummary. Must be inside ShippingAddressEditController.',\n});\n\nexport const ShippingAddressCancelButtonDefinition = defineComponent<ShippingAddressEditButtonProps>({\n name: 'ShippingAddressCancelButton',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCancelButton,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Cancel Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'cancelar', label: 'Button label' },\n },\n guideline:\n 'Returns the delivery section to its summary without saving. Place it inside a ShippingAddressEditForm so a shopper who opened the form has a way back that does not depend on a successful write. Must be inside ShippingAddressEditController.',\n});\n\n// ---------------------------------------------------------------------------\n// Root Component\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressRoot owns the batched form state, manages the current descriptor,\n * and provides context to child Controls. It handles submit dispatch and error tracking.\n */\nexport function ShippingAddressRoot({\n defaultCountry = 'BRA',\n className,\n children,\n $data: $dataProp,\n $actions: $actionsProp,\n}: Readonly<ShippingAddressRootProps>) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n\n // Current address and saved addresses from the fragment\n const currentAddress = $data?.shipping?.address;\n const savedAddresses = $data?.shipping?.savedAddresses ?? [];\n const clientProfile = $data?.clientProfile;\n\n // Joined shopper-profile name (US-4) — the single fallback for recipientName whenever an\n // address record (the current address, or a saved address picked from the drawer) has none.\n // Always applied as a real draft value, never just a placeholder hint, so the shopper never has\n // to retype a name the profile already has.\n const joinedProfileName = [clientProfile?.firstName, clientProfile?.lastName].filter(Boolean).join(' ');\n\n // Seeds the batched draft from the current address, falling back to empty. The recipient name defaults to\n // the joined profile name when the address has none (US-4): it must be a real pre-filled value, not just a\n // placeholder hint, so the shopper can submit without retyping it. Shared with `discardDraft` below so the\n // initial seed and the cancel path cannot drift apart.\n const seedDraft = useCallback(\n (): AddressDraft => ({\n recipientName: currentAddress?.recipientName ?? joinedProfileName,\n postalCode: currentAddress?.postalCode ?? '',\n country: currentAddress?.country ?? defaultCountry,\n street: currentAddress?.street ?? '',\n number: currentAddress?.number ?? '',\n complement: currentAddress?.complement ?? '',\n neighborhood: currentAddress?.neighborhood ?? '',\n city: currentAddress?.city ?? '',\n state: currentAddress?.state ?? '',\n }),\n [currentAddress, joinedProfileName, defaultCountry],\n );\n\n const [draft, setDraft] = useState<AddressDraft>(seedDraft);\n\n // Error tracking and submission state\n const [submitting, setSubmitting] = useState(false);\n const [errors, setErrors] = useState<readonly ShippingAddressUpdateErrorEntity[]>([]);\n const [upstreamError, setUpstreamError] = useState(false);\n const [selectedSavedId, setSelectedSavedId] = useState<string | undefined>();\n const [savedAddressDrawerOpen, setSavedAddressDrawerOpen] = useState(false);\n const [drawerSubmitting, setDrawerSubmitting] = useState(false);\n const [submitSuccessSignal, setSubmitSuccessSignal] = useState(0);\n\n // Per-field dirty tracking. `draft`'s initial state is set once (via useState's lazy\n // initializer) from whatever currentAddress holds on this component's first render — for a live\n // page, the reactive fragment often resolves asynchronously after that first render\n // (currentAddress starts undefined), so draft needs to catch up once it arrives. Tracked per\n // field, not as one global flag, so editing one field doesn't stop the others from picking up a\n // later currentAddress update (US-1, third criterion: \"untouched fields reflect the new values\").\n const [touchedFields, setTouchedFields] = useState<ReadonlySet<keyof AddressDraft>>(() => new Set());\n\n // Cancelling throws the edit away, and the marks have to go with the values. They are deliberately kept\n // after a successful write — a server that has not echoed the recipient back would otherwise re-seed the\n // profile name over what the shopper typed — but an abandoned edit has nothing worth preserving, and a\n // mark left behind would keep the stored value permanently out of reach of the re-seed effect below.\n const discardDraft = useCallback(() => {\n setTouchedFields(new Set());\n setDraft(seedDraft());\n setErrors([]);\n setUpstreamError(false);\n }, [seedDraft]);\n\n const currentAddressSnapshot = JSON.stringify(currentAddress ?? null);\n const clientProfileSnapshot = JSON.stringify(clientProfile ?? null);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the stringified snapshots (currentAddressSnapshot/clientProfileSnapshot), not object identity, so the effect doesn't refire on every render when Apollo returns a new-but-equal object reference.\n useEffect(() => {\n setDraft((prev) => {\n return {\n recipientName: touchedFields.has('recipientName')\n ? prev.recipientName\n : (currentAddress?.recipientName ?? (joinedProfileName || prev.recipientName)),\n postalCode: touchedFields.has('postalCode') ? prev.postalCode : (currentAddress?.postalCode ?? prev.postalCode),\n country: touchedFields.has('country') ? prev.country : (currentAddress?.country ?? prev.country),\n street: touchedFields.has('street') ? prev.street : (currentAddress?.street ?? prev.street),\n number: touchedFields.has('number') ? prev.number : (currentAddress?.number ?? prev.number),\n complement: touchedFields.has('complement') ? prev.complement : (currentAddress?.complement ?? prev.complement),\n neighborhood: touchedFields.has('neighborhood')\n ? prev.neighborhood\n : (currentAddress?.neighborhood ?? prev.neighborhood),\n city: touchedFields.has('city') ? prev.city : (currentAddress?.city ?? prev.city),\n state: touchedFields.has('state') ? prev.state : (currentAddress?.state ?? prev.state),\n };\n });\n }, [currentAddressSnapshot, clientProfileSnapshot, touchedFields]);\n\n // Compute current address ID for comparison with saved addresses (Decision 8)\n const currentAddressId = currentAddress?.id ?? undefined;\n\n // Formatted current address for read-only display (ShippingAddressSelectedSummary);\n // undefined when there is no current address yet, so the summary can self-gate on it.\n const formattedCurrentAddress = useMemo(() => {\n if (!currentAddress) return undefined;\n return {\n recipientName: currentAddress.recipientName ?? '',\n postalCode: currentAddress.postalCode ?? '',\n country: currentAddress.country ?? '',\n street: currentAddress.street ?? '',\n number: currentAddress.number ?? '',\n complement: currentAddress.complement ?? '',\n neighborhood: currentAddress.neighborhood ?? '',\n city: currentAddress.city ?? '',\n state: currentAddress.state ?? '',\n } satisfies Partial<AddressDraft>;\n }, [currentAddress]);\n\n // Get the current descriptor based on draft country\n const descriptor = getCountryDescriptor(draft.country);\n\n // Map saved addresses with extracted address data\n const mappedSavedAddresses = useMemo(\n () =>\n savedAddresses.map((saved) => ({\n id: saved.id ?? '',\n address: {\n recipientName: saved.recipientName ?? '',\n postalCode: saved.postalCode ?? '',\n country: saved.country ?? '',\n street: saved.street ?? '',\n number: saved.number ?? '',\n complement: saved.complement ?? '',\n neighborhood: saved.neighborhood ?? '',\n city: saved.city ?? '',\n state: saved.state ?? '',\n } as Partial<AddressDraft>,\n })),\n [savedAddresses],\n );\n\n // Update a single draft field\n const setDraftField = useCallback((field: keyof AddressDraft, value: string) => {\n setTouchedFields((prev) => (prev.has(field) ? prev : new Set(prev).add(field)));\n setDraft((prev) => ({ ...prev, [field]: value }));\n }, []);\n\n // Handle saved option selection\n const selectSavedAddress = useCallback(\n (id: string | undefined) => {\n setSelectedSavedId(id);\n if (id) {\n const saved = mappedSavedAddresses.find((s) => s.id === id);\n if (saved?.address) {\n // Selecting a saved address replaces the whole draft with its fields, so mark every\n // field touched — otherwise a later currentAddress sync could clobber this selection.\n setTouchedFields((prev) => new Set([...prev, ...(Object.keys(saved.address) as Array<keyof AddressDraft>)]));\n // A saved address can legitimately have a blank recipientName (Decision 9); fall back to\n // the joined profile name here too, same as the no-address case (US-4), so the field shows\n // a real pre-filled value instead of an empty string masquerading behind a placeholder.\n setDraft((prev) => ({\n ...prev,\n ...saved.address,\n recipientName: saved.address.recipientName || joinedProfileName,\n }));\n }\n }\n },\n [mappedSavedAddresses, joinedProfileName],\n );\n\n // Client-side validation: non-blank recipientName required\n const isFormValid = draft.recipientName.trim().length > 0;\n\n // Submit handler: dispatch setAddress action\n const handleSubmit = useCallback(async () => {\n if (!isFormValid || submitting) return;\n\n if (!$actions?.shipping?.setAddress) return;\n\n setSubmitting(true);\n setErrors([]);\n setUpstreamError(false);\n\n try {\n // Build input, including savedAddressId only if one was selected (US-3, third acceptance criterion).\n // Only include a field the active country's descriptor actually declares (US-2, third/fourth\n // criteria) — otherwise a stale value from a previously-selected country (e.g. `neighborhood`\n // retained in the draft after switching BR -> USA) would leak into the submitted payload.\n const isFieldActive = (field: keyof AddressDraft) => descriptor?.fields.some((f) => f.name === field) ?? false;\n\n const addressFields = {\n recipientName: draft.recipientName.trim(),\n postalCode: draft.postalCode,\n country: draft.country,\n ...(isFieldActive('street') ? { street: draft.street } : {}),\n ...(isFieldActive('number') ? { number: draft.number } : {}),\n ...(isFieldActive('complement') ? { complement: draft.complement } : {}),\n ...(isFieldActive('neighborhood') ? { neighborhood: draft.neighborhood } : {}),\n ...(isFieldActive('city') ? { city: draft.city } : {}),\n ...(isFieldActive('state') ? { state: draft.state } : {}),\n };\n\n const input: ShippingAddressInput = selectedSavedId\n ? { savedAddressId: selectedSavedId, ...addressFields }\n : addressFields;\n\n const userErrors = await $actions.shipping.setAddress(input);\n if (userErrors.length === 0) {\n // Success: cache merge will reactively update the form (US-5, second criterion). The touched\n // marks stay: dropping them re-arms the seeding effect, which would overwrite a recipient the\n // shopper typed with the profile-name fallback whenever the stored address still carries none.\n setErrors([]);\n setSubmitSuccessSignal((n) => n + 1);\n } else if (userErrors.some((e) => e.code === SHIPPING_NETWORK_ERROR_CODE)) {\n // The action resolves (never throws) the synthetic upstream/network failure as a userError;\n // route it to the generic error state, not the inline domain list (US-6 2nd criterion,\n // Decision 5). Draft retained (US-6, third criterion).\n setErrors([]);\n setUpstreamError(true);\n } else {\n // Domain userErrors render inline; retain draft on error (US-6, third criterion)\n setErrors(userErrors);\n }\n } catch (error) {\n // Network/upstream error: surface as generic state (US-6, second criterion)\n console.error('[ShippingAddress] setAddress failed:', error);\n setUpstreamError(true);\n setErrors([]);\n } finally {\n setSubmitting(false);\n }\n }, [isFormValid, submitting, $actions?.shipping?.setAddress, draft, selectedSavedId, descriptor]);\n\n // Drawer submit handler: dispatch setAddress for the selected saved address (US-8, Decision 7)\n const handleDrawerSubmit = useCallback(async () => {\n // Guard: if nothing picked in the drawer, return immediately\n if (!selectedSavedId) return;\n\n // No-op guard (Decision 8): if the selected address is already current, just close and return\n if (currentAddressId !== undefined && selectedSavedId === currentAddressId) {\n setSavedAddressDrawerOpen(false);\n return;\n }\n\n const selectedAddress = mappedSavedAddresses.find((s) => s.id === selectedSavedId);\n if (!selectedAddress) return;\n\n // Incomplete saved address (missing the one client-enforced field, recipientName): an\n // auto-submit would only fail server-side with MISSING_RECIPIENT_NAME. selectSavedAddress\n // already populated the draft from this record when it was picked, so just close the drawer\n // and let the shopper review/complete it via the main form's own submit (Decision 9).\n if (!selectedAddress.address.recipientName?.trim()) {\n setSavedAddressDrawerOpen(false);\n return;\n }\n\n if (!$actions?.shipping?.setAddress) return;\n\n setDrawerSubmitting(true);\n setErrors([]);\n setUpstreamError(false);\n\n try {\n // Build input from the saved address's stored fields (Decision 6)\n const input: ShippingAddressInput = {\n savedAddressId: selectedSavedId,\n recipientName: selectedAddress.address.recipientName || '',\n postalCode: selectedAddress.address.postalCode || '',\n country: selectedAddress.address.country || '',\n street: selectedAddress.address.street || '',\n number: selectedAddress.address.number || '',\n complement: selectedAddress.address.complement || '',\n neighborhood: selectedAddress.address.neighborhood || '',\n city: selectedAddress.address.city || '',\n state: selectedAddress.address.state || '',\n };\n\n const userErrors = await $actions.shipping.setAddress(input);\n if (userErrors.length === 0) {\n // Success: close the drawer (7th acceptance criterion)\n setErrors([]);\n setSavedAddressDrawerOpen(false);\n setSubmitSuccessSignal((n) => n + 1);\n } else if (userErrors.some((e) => e.code === SHIPPING_NETWORK_ERROR_CODE)) {\n // Resolved synthetic upstream/network failure: generic error state (Decision 5).\n setErrors([]);\n setUpstreamError(true);\n } else {\n // Domain userErrors render inline; leave drawer open for retry (7th acceptance criterion)\n setErrors(userErrors);\n }\n } catch (error) {\n // Network/upstream error: surface as generic state and leave drawer open\n console.error('[ShippingAddress] drawer submit failed:', error);\n setUpstreamError(true);\n setErrors([]);\n } finally {\n setDrawerSubmitting(false);\n }\n }, [selectedSavedId, currentAddressId, mappedSavedAddresses, $actions?.shipping?.setAddress]);\n\n // Provide context to all children\n const contextValue: ShippingAddressContextValue = {\n draft,\n setDraftField,\n descriptor,\n savedAddresses: mappedSavedAddresses,\n selectedSavedId,\n setSelectedSavedId: selectSavedAddress,\n submitting,\n errors,\n upstreamError,\n handleSubmit,\n currentAddressId,\n currentAddress: formattedCurrentAddress,\n submitSuccessSignal,\n isFormValid,\n discardDraft,\n };\n\n const drawerContextValue: ShippingAddressDrawerContextValue = {\n savedAddressDrawerOpen,\n setSavedAddressDrawerOpen,\n drawerSubmitting,\n handleDrawerSubmit,\n };\n\n return (\n <ShippingAddressContext.Provider value={contextValue}>\n <ShippingAddressDrawerContext.Provider value={drawerContextValue}>\n <div className={className} data-fs-shipping-address=\"\">\n {children}\n </div>\n </ShippingAddressDrawerContext.Provider>\n </ShippingAddressContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Control Components (thin, context-bound, reuse particles)\n// ---------------------------------------------------------------------------\n\n/**\n * RecipientNameControl — the only client-validated field (US-4, US-6).\n * Pre-filled from clientProfile, editable, required.\n */\nexport function ShippingAddressRecipientNameControl({ className }: ShippingAddressRecipientNameControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const isRendered = descriptor?.fields.some((f) => f.name === 'recipientName');\n if (!isRendered) return null;\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'recipientName');\n const label = fieldDescriptor?.label ?? 'nome do destinatário';\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"recipient-name\" disabled={submitting}>\n <Field.Label>{label}</Field.Label>\n <Field.Control\n value={draft.recipientName}\n onChange={(e) => setDraftField('recipientName', e.currentTarget.value)}\n />\n </Field.Root>\n );\n}\n\n/** StreetControl */\nexport function ShippingAddressStreetControl({ className }: ShippingAddressStreetControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'street');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"street\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.street} onChange={(e) => setDraftField('street', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** NumberControl */\nexport function ShippingAddressNumberControl({ className }: ShippingAddressNumberControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'number');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"number\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.number} onChange={(e) => setDraftField('number', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** CityControl */\nexport function ShippingAddressCityControl({ className }: ShippingAddressCityControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'city');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"city\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.city} onChange={(e) => setDraftField('city', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** StateControl */\nexport function ShippingAddressStateControl({ className }: ShippingAddressStateControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'state');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"state\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.state} onChange={(e) => setDraftField('state', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** PostalCodeControl */\nexport function ShippingAddressPostalCodeControl({ className }: ShippingAddressPostalCodeControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'postalCode');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"postal-code\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.postalCode} onChange={(e) => setDraftField('postalCode', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** ComplementControl */\nexport function ShippingAddressComplementControl({ className }: ShippingAddressComplementControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'complement');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"complement\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.complement} onChange={(e) => setDraftField('complement', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** NeighborhoodControl (BR-specific in v1) */\nexport function ShippingAddressNeighborhoodControl({ className }: ShippingAddressNeighborhoodControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'neighborhood');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"neighborhood\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control\n value={draft.neighborhood}\n onChange={(e) => setDraftField('neighborhood', e.currentTarget.value)}\n />\n </Field.Root>\n );\n}\n\n/** CountryControl — lists only countries with a descriptor (US-2, first criterion) */\nexport function ShippingAddressCountryControl({ className, label = 'país' }: ShippingAddressCountryControlProps) {\n const { draft, setDraftField, setSelectedSavedId, submitting } = useShippingAddressContext();\n\n const availableCountries = getAvailableCountries();\n const countryOptions = availableCountries.map((iso) => {\n const desc = getCountryDescriptor(iso);\n return { value: iso, label: desc?.label ?? iso };\n });\n\n const handleCountryChange = (value: string | null) => {\n if (!value) return;\n const newDesc = getCountryDescriptor(value);\n if (newDesc) {\n setDraftField('country', value);\n setSelectedSavedId(undefined);\n }\n };\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"country\" disabled={submitting}>\n <Field.Label>{label}</Field.Label>\n <Select.Root value={draft.country} onValueChange={handleCountryChange} disabled={submitting}>\n <Select.Trigger>\n {/* Resolves the label directly from the country descriptor rather than relying on Base\n UI's automatic item-label lookup, which only reflects a mounted Select.Item (i.e.\n after the popup has been opened at least once) — otherwise the trigger would show\n the raw ISO code (e.g. \"BRA\") before the shopper ever opens the dropdown. */}\n <Select.Value>{(value) => (value ? (getCountryDescriptor(value)?.label ?? value) : value)}</Select.Value>\n <Select.Icon>▾</Select.Icon>\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n <Select.List>\n {countryOptions.map((option) => (\n <Select.Item key={option.value} value={option.value} label={option.label}>\n {option.label}\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </Field.Root>\n );\n}\n\n// ---------------------------------------------------------------------------\n// SavedAddresses List and Option (US-3)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedList — renders only when savedAddresses is non-empty (logged-in signal).\n */\nexport function ShippingAddressSavedList({ className }: ShippingAddressSavedListProps) {\n const { savedAddresses } = useShippingAddressContext();\n\n if (savedAddresses.length === 0) return null;\n\n return (\n <div className={className} data-fs-shipping-address-saved-list=\"\">\n {savedAddresses.map((saved) => (\n <ShippingAddressSavedOption key={saved.id} id={saved.id} />\n ))}\n </div>\n );\n}\n\n/**\n * ShippingAddressSavedOption — selectable saved address; populates draft on selection.\n * Includes isCurrent visual variant to mark the address matching the current cart address (Decision 8).\n */\nexport function ShippingAddressSavedOption({ id, className }: ShippingAddressSavedOptionProps) {\n const { savedAddresses, selectedSavedId, setSelectedSavedId, currentAddressId } = useShippingAddressContext();\n\n const saved = savedAddresses.find((s) => s.id === id);\n if (!saved) return null;\n\n const isSelected = selectedSavedId === id;\n const isCurrent = currentAddressId !== undefined && currentAddressId === id;\n const hasAddressContent = Boolean(\n saved.address.recipientName || saved.address.street || saved.address.city || saved.address.neighborhood,\n );\n const inputId = `saved-address-${id}`;\n\n return (\n <div\n className={className}\n data-fs-shipping-address-saved-option=\"\"\n {...(isSelected ? { 'data-fs-shipping-address-saved-option-selected': '' } : {})}\n {...(isCurrent ? { 'data-fs-shipping-address-saved-option-current': '' } : {})}\n >\n <input\n id={inputId}\n type=\"radio\"\n name=\"saved-address\"\n value={id}\n checked={isSelected}\n onChange={() => setSelectedSavedId(id)}\n />\n <label htmlFor={inputId}>\n {hasAddressContent ? (\n <AddressSummaryRoot address={saved.address}>\n <AddressSummary />\n </AddressSummaryRoot>\n ) : (\n `Endereço ${id}`\n )}\n </label>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Submit Button (US-5)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSubmit — dispatches the batched submit; reflects pending state.\n */\nexport function ShippingAddressSubmit({\n className,\n label = 'salvar endereço',\n pendingLabel = 'salvando...',\n}: ShippingAddressSubmitProps) {\n const { submitting, handleSubmit, isFormValid } = useShippingAddressContext();\n\n return (\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={submitting || !isFormValid}\n className={className}\n data-fs-shipping-address-submit=\"\"\n {...(submitting ? { 'data-fs-shipping-address-submit-pending': '' } : {})}\n >\n {submitting ? pendingLabel : label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Saved-Address Drawer Controller (US-8)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedAddressDrawerController — makes the wrapped DrawerRoot controlled by the\n * shipping-address context's savedAddressDrawerOpen state, and blocks dismissal (Escape, backdrop\n * click, close button) while drawerSubmitting is true by simply not forwarding the close request\n * to the setter. Mirrors CartOpenOnAdd's cloneElement mechanism. Expects a single DrawerRoot child.\n */\nexport function ShippingAddressSavedAddressDrawerController({\n children,\n}: ShippingAddressSavedAddressDrawerControllerProps) {\n const { savedAddressDrawerOpen, setSavedAddressDrawerOpen, drawerSubmitting } = useShippingAddressDrawerContext();\n\n if (!isValidElement<Pick<DrawerRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open: savedAddressDrawerOpen,\n onOpenChange: (next: boolean) => {\n if (!next && drawerSubmitting) return;\n setSavedAddressDrawerOpen(next);\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Saved-Address Submit (US-8)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedAddressSubmit — the drawer's \"selecionar\" submit button; independent\n * submitting state from the main form's Submit (Decision 7); no-ops when the selected saved\n * address is already the current one (Decision 8).\n */\nexport function ShippingAddressSavedAddressSubmit({\n className,\n label = 'selecionar',\n pendingLabel = 'selecionando...',\n}: ShippingAddressSavedAddressSubmitProps) {\n const { selectedSavedId } = useShippingAddressContext();\n const { drawerSubmitting, handleDrawerSubmit } = useShippingAddressDrawerContext();\n\n return (\n <button\n type=\"button\"\n onClick={handleDrawerSubmit}\n disabled={drawerSubmitting || !selectedSavedId}\n className={className}\n data-fs-shipping-address-saved-address-submit=\"\"\n {...(drawerSubmitting ? { 'data-fs-shipping-address-saved-address-submit-pending': '' } : {})}\n >\n {drawerSubmitting ? pendingLabel : label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Selected Address Summary (read-only, self-gating)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSelectedSummary — provides the current delivery address via AddressSummaryRoot's\n * context and renders it through AddressSummary. Composed lines go through that same wrapper rather\n * than replacing it, because AddressSummaryRoot renders no DOM and `className` would have nowhere to\n * land. Self-gating on currentAddress: renders null when there is none yet, rather than an empty\n * provider with nothing meaningful to show.\n */\nexport function ShippingAddressSelectedSummary({ className, children }: ShippingAddressSelectedSummaryProps) {\n const { currentAddress } = useShippingAddressContext();\n\n if (!currentAddress) return null;\n\n return (\n <AddressSummaryRoot address={currentAddress}>\n <AddressSummary className={className}>{children}</AddressSummary>\n </AddressSummaryRoot>\n );\n}\n\n// ---------------------------------------------------------------------------\n// View/Edit Mode Toggle (composable — Free Particle Model)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressEditController — owns the view/edit mode. Defaults to 'view' when a current\n * address exists, 'edit' otherwise (derived reactively from currentAddressId, so it self-corrects\n * if the address arrives asynchronously after mount, same issue as the draft-sync effect above).\n * Once the shopper explicitly toggles (via ShippingAddressEditButton) or a submit succeeds, the\n * explicit mode takes over. Does not render any DOM itself; provides ShippingAddressSectionContext\n * to ShippingAddressSummaryView/ShippingAddressEditForm/ShippingAddressEditButton descendants.\n */\nexport function ShippingAddressEditController({ children }: ShippingAddressEditControllerProps) {\n const { currentAddressId, submitSuccessSignal } = useShippingAddressContext();\n const [explicitMode, setExplicitMode] = useState<ShippingAddressSectionState | undefined>(undefined);\n const lastHandledSignal = useRef(submitSuccessSignal);\n\n useEffect(() => {\n if (submitSuccessSignal !== lastHandledSignal.current) {\n lastHandledSignal.current = submitSuccessSignal;\n setExplicitMode('view');\n }\n }, [submitSuccessSignal]);\n\n // This section decides alone: the form when there is no address to show, the summary when there is, and\n // whatever the shopper last chose once they have chosen. It reports nothing to anything else, so finishing\n // it opens no other section.\n const mode: ShippingAddressSectionState = explicitMode ?? (currentAddressId !== undefined ? 'view' : 'edit');\n\n const modeContextValue = useMemo<ShippingAddressSectionContextValue>(\n () => ({ mode, setMode: setExplicitMode }),\n [mode],\n );\n\n return (\n <ShippingAddressSectionContext.Provider value={modeContextValue}>{children}</ShippingAddressSectionContext.Provider>\n );\n}\n\n/** Renders its children only while the section shows the saved-address summary. */\nexport function ShippingAddressSummaryView({ children }: ShippingAddressSectionPanelProps) {\n const { mode } = useShippingAddressSectionContext();\n if (mode !== 'view') return null;\n return <>{children}</>;\n}\n\n/** Renders its children only while the section shows the address form. */\nexport function ShippingAddressEditForm({ children }: ShippingAddressSectionPanelProps) {\n const { mode } = useShippingAddressSectionContext();\n if (mode !== 'edit') return null;\n return <>{children}</>;\n}\n\n/**\n * ShippingAddressEditButton — CTA that switches the mode to 'edit'. Has no knowledge of why the\n * mode might currently be 'view' (a current address, or a just-completed submit) — it only writes\n * the mode forward.\n */\nexport function ShippingAddressEditButton({ className, label = 'editar', children }: ShippingAddressEditButtonProps) {\n const { setMode } = useShippingAddressSectionContext();\n return (\n <button type=\"button\" onClick={() => setMode('edit')} className={className} data-fs-shipping-address-edit-button=\"\">\n {children ?? label}\n </button>\n );\n}\n\n/**\n * ShippingAddressCancelButton — returns the section to its summary without writing. Without it a\n * shopper who opens the form can only leave through a successful `setAddress`, and blanking the\n * recipient disables Submit, which leaves the section stuck open over the summary it replaced.\n */\nexport function ShippingAddressCancelButton({\n className,\n label = 'cancelar',\n children,\n}: ShippingAddressEditButtonProps) {\n const { setMode } = useShippingAddressSectionContext();\n const { discardDraft } = useShippingAddressContext();\n return (\n <button\n type=\"button\"\n onClick={() => {\n discardDraft();\n setMode('view');\n }}\n className={className}\n data-fs-shipping-address-cancel-button=\"\"\n >\n {children ?? label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Error Component (US-6)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressError — renders domain userErrors inline, or generic upstream error state.\n */\nexport function ShippingAddressError({ className }: ShippingAddressErrorProps) {\n const { errors, upstreamError } = useShippingAddressContext();\n\n if (errors.length === 0 && !upstreamError) return null;\n\n return (\n <div className={className} data-fs-shipping-address-error=\"\">\n {upstreamError ? (\n <div>Não foi possível salvar este endereço. Revise os dados e tente novamente.</div>\n ) : (\n <ul>\n {errors.map((error, idx) => (\n <li key={idx}>{error.message}</li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddress = {\n Root: ShippingAddressRoot,\n RootDefinition: ShippingAddressRootDefinition,\n RecipientNameControl: ShippingAddressRecipientNameControl,\n RecipientNameControlDefinition: ShippingAddressRecipientNameControlDefinition,\n StreetControl: ShippingAddressStreetControl,\n StreetControlDefinition: ShippingAddressStreetControlDefinition,\n NumberControl: ShippingAddressNumberControl,\n NumberControlDefinition: ShippingAddressNumberControlDefinition,\n CityControl: ShippingAddressCityControl,\n CityControlDefinition: ShippingAddressCityControlDefinition,\n StateControl: ShippingAddressStateControl,\n StateControlDefinition: ShippingAddressStateControlDefinition,\n PostalCodeControl: ShippingAddressPostalCodeControl,\n PostalCodeControlDefinition: ShippingAddressPostalCodeControlDefinition,\n ComplementControl: ShippingAddressComplementControl,\n ComplementControlDefinition: ShippingAddressComplementControlDefinition,\n NeighborhoodControl: ShippingAddressNeighborhoodControl,\n NeighborhoodControlDefinition: ShippingAddressNeighborhoodControlDefinition,\n CountryControl: ShippingAddressCountryControl,\n CountryControlDefinition: ShippingAddressCountryControlDefinition,\n SavedList: ShippingAddressSavedList,\n SavedListDefinition: ShippingAddressSavedListDefinition,\n SavedOption: ShippingAddressSavedOption,\n SavedOptionDefinition: ShippingAddressSavedOptionDefinition,\n Submit: ShippingAddressSubmit,\n SubmitDefinition: ShippingAddressSubmitDefinition,\n SavedAddressDrawerController: ShippingAddressSavedAddressDrawerController,\n SavedAddressDrawerControllerDefinition: ShippingAddressSavedAddressDrawerControllerDefinition,\n SavedAddressSubmit: ShippingAddressSavedAddressSubmit,\n SavedAddressSubmitDefinition: ShippingAddressSavedAddressSubmitDefinition,\n SelectedSummary: ShippingAddressSelectedSummary,\n SelectedSummaryDefinition: ShippingAddressSelectedSummaryDefinition,\n EditController: ShippingAddressEditController,\n EditControllerDefinition: ShippingAddressEditControllerDefinition,\n SummaryView: ShippingAddressSummaryView,\n SummaryViewDefinition: ShippingAddressSummaryViewDefinition,\n EditForm: ShippingAddressEditForm,\n EditFormDefinition: ShippingAddressEditFormDefinition,\n EditButton: ShippingAddressEditButton,\n EditButtonDefinition: ShippingAddressEditButtonDefinition,\n CancelButton: ShippingAddressCancelButton,\n CancelButtonDefinition: ShippingAddressCancelButtonDefinition,\n Error: ShippingAddressError,\n ErrorDefinition: ShippingAddressErrorDefinition,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI/B,MAAM,iCAAiC,OAAO,6BAA6B;AAE3E,MAAM,yBAAyB,cAC7B,8BACF;AAEA,SAAS,4BAAyD;CAChE,MAAM,MAAM,WAAW,sBAAsB;CAC7C,IAAI,QAAQ,gCACV,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAeA,MAAM,wCAAwC,OAAO,mCAAmC;AAExF,MAAM,+BAA+B,cAEnC,qCAAqC;AAEvC,SAAS,kCAAqE;CAC5E,MAAM,MAAM,WAAW,4BAA4B;CACnD,IAAI,QAAQ,uCACV,MAAM,IAAI,MACR,4HACF;CAEF,OAAO;AACT;AAgBA,MAAM,yCAAyC,OAAO,oCAAoC;AAE1F,MAAM,gCAAgC,cAEpC,sCAAsC;AAExC,SAAS,mCAAuE;CAC9E,MAAM,MAAM,WAAW,6BAA6B;CACpD,IAAI,QAAQ,wCACV,MAAM,IAAI,MACR,mKACF;CAEF,OAAO;AACT;AA+GA,MAAa,gCAAgC,gBAA0C;CACrF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,iBAAiB;CACjB,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE;CACpC,QAAQ;EAAE,OAAO;EAAyB,UAAU;CAAU;CAC9D,QAAQ,EACN,gBA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iB,0BAA0B;CACnD,OACE,oBAAC,UAAD;EACE,MAAK;EACL,eAAe;GACb,aAAa;GACb,QAAQ,MAAM;EAChB;EACW;EACX,0CAAuC;EAEtC,UAAA,YAAY;CACP,CAAA;AAEZ;;;;AASA,SAAgB,qBAAqB,EAAE,aAAwC;CAC7E,MAAM,EAAE,QAAQ,kBAAkB,0BAA0B;CAE5D,IAAI,OAAO,WAAW,KAAK,CAAC,eAAe,OAAO;CAElD,OACE,oBAAC,OAAD;EAAgB;EAAW,kCAA+B;EACvD,UAAA,gBACC,oBAAC,OAAD,EAAA,UAAK,4EAA8E,CAAA,IAEnF,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,QAClB,oBAAC,MAAD,EAAA,UAAe,MAAM,QAAY,GAAxB,GAAwB,CAClC,EACC,CAAA;CAEH,CAAA;AAET;AAMA,MAAa,kBAAkB;CAC7B,MAAM;CACN,gBAAgB;CAChB,sBAAsB;CACtB,gCAAgC;CAChC,eAAe;CACf,yBAAyB;CACzB,eAAe;CACf,yBAAyB;CACzB,aAAa;CACb,uBAAuB;CACvB,cAAc;CACd,wBAAwB;CACxB,mBAAmB;CACnB,6BAA6B;CAC7B,mBAAmB;CACnB,6BAA6B;CAC7B,qBAAqB;CACrB,+BAA+B;CAC/B,gBAAgB;CAChB,0BAA0B;CAC1B,WAAW;CACX,qBAAqB;CACrB,aAAa;CACb,uBAAuB;CACvB,QAAQ;CACR,kBAAkB;CAClB,8BAA8B;CAC9B,wCAAwC;CACxC,oBAAoB;CACpB,8BAA8B;CAC9B,iBAAiB;CACjB,2BAA2B;CAC3B,gBAAgB;CAChB,0BAA0B;CAC1B,aAAa;CACb,uBAAuB;CACvB,UAAU;CACV,oBAAoB;CACpB,YAAY;CACZ,sBAAsB;CACtB,cAAc;CACd,wBAAwB;CACxB,OAAO;CACP,iBAAiB;AACnB"}
|
|
@@ -74,6 +74,6 @@ export declare const SignInFormDefinition: ComponentDefinition<Readonly<{
|
|
|
74
74
|
* from any ancestor `UNAUTHORIZED` gate. While the write is in flight the form is disabled and
|
|
75
75
|
* `data-fs-sign-in-form-pending` is present so a checkout-CTA guard can block.
|
|
76
76
|
*/
|
|
77
|
-
export declare function SignInForm({ emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, showPasswordLabel, hidePasswordLabel, submitLabel, invalidEmailMessage, passwordRequiredMessage, invalidCredentialsMessage, blockedMessage, networkErrorMessage, genericErrorMessage, $data: $dataProp, $actions, className }: SignInFormProps): import("react/jsx-runtime").JSX.Element | null;
|
|
77
|
+
export declare function SignInForm({ emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, showPasswordLabel, hidePasswordLabel, submitLabel, invalidEmailMessage, passwordRequiredMessage, invalidCredentialsMessage, blockedMessage, networkErrorMessage, genericErrorMessage, $data: $dataProp, $actions: $actionsProp, className }: SignInFormProps): import("react/jsx-runtime").JSX.Element | null;
|
|
78
78
|
//#endregion
|
|
79
79
|
//# sourceMappingURL=sign-in-form.d.ts.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
3
|
import "../../core/dist/index.js";
|
|
4
4
|
import { EmailField, isValidEmail } from "../../particles/email-field/email-field.js";
|
|
5
|
+
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
5
6
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
6
7
|
import { useSession } from "../session/session.js";
|
|
7
8
|
import { Button } from "../../particles/button/button.js";
|
|
@@ -124,8 +125,9 @@ const SignInFormDefinition = defineComponent({
|
|
|
124
125
|
* from any ancestor `UNAUTHORIZED` gate. While the write is in flight the form is disabled and
|
|
125
126
|
* `data-fs-sign-in-form-pending` is present so a checkout-CTA guard can block.
|
|
126
127
|
*/
|
|
127
|
-
function SignInForm({ emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, showPasswordLabel, hidePasswordLabel, submitLabel = "Sign In", invalidEmailMessage = "Enter a valid email address.", passwordRequiredMessage = "Enter your password.", invalidCredentialsMessage = "Incorrect email or password. Please try again.", blockedMessage = "This account has been blocked. Please contact support.", networkErrorMessage = "Unable to complete the request. Please try again.", genericErrorMessage = "Unable to sign in. Please try again.", $data: $dataProp, $actions, className }) {
|
|
128
|
+
function SignInForm({ emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, showPasswordLabel, hidePasswordLabel, submitLabel = "Sign In", invalidEmailMessage = "Enter a valid email address.", passwordRequiredMessage = "Enter your password.", invalidCredentialsMessage = "Incorrect email or password. Please try again.", blockedMessage = "This account has been blocked. Please contact support.", networkErrorMessage = "Unable to complete the request. Please try again.", genericErrorMessage = "Unable to sign in. Please try again.", $data: $dataProp, $actions: $actionsProp, className }) {
|
|
128
129
|
const $data = useDataOverride($dataProp);
|
|
130
|
+
const $actions = useActionsOverride($actionsProp);
|
|
129
131
|
const { state } = useSession();
|
|
130
132
|
const savedEmail = $data?.email ?? "";
|
|
131
133
|
const [email, setEmail] = useState(savedEmail);
|