@vtex/faststore 0.0.2 → 0.0.4
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 +45 -0
- package/README.md +11 -5
- package/dist/catalog.json +556 -265
- package/dist/components.d.ts +3 -1
- package/dist/components.js +5 -3
- 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/my-account-profile.md +208 -0
- 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/my-account-profile/my-account-profile.d.ts +291 -0
- package/dist/matter/my-account-profile/my-account-profile.js +856 -0
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -0
- 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 +4 -2
- 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 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-identification.js","names":[],"sources":["../../../src/matter/email-identification/email-identification.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { useEffect, useState } from 'react';\nimport { EmailField, isValidEmail } from '../../particles/email-field/email-field.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { useSession } from '../session/session.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment (colocated, ADR-0011) — reads only clientProfile.email.\n// Authored as a raw string (not the codegen graphql() factory), mirroring the ShippingSimulator\n// matter: the compiler derives the entity fragment on `clientProfile` and subscribes reactively.\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment EmailIdentificationData on Query {\n clientProfile {\n __typename\n id\n email\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** ClientProfile slice forwarded by the reactive runtime — only `email` is consumed for pre-fill. */\nexport type EmailIdentificationSlice = {\n email?: string | null;\n};\n\nexport type EmailIdentificationControlProps = Omit<ComponentPropsWithRef<'div'>, 'onChange'> & {\n /** Accessible label passed to the EmailField. */\n label?: string;\n /** Input placeholder passed to the EmailField. */\n placeholder?: string;\n /** Inline error text for an invalid email format (port of `checkout/form-messages.invalid-email`). */\n invalidEmailMessage?: string;\n /** ClientProfile slice forwarded by the reactive runtime; `null` until the entity resolves. */\n $data?: EmailIdentificationSlice | null;\n /** Compiler-injected action surface; carries `identity.clientProfileUpdate`. */\n $actions?: ComponentActions;\n};\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const EmailIdentificationControlDefinition = defineComponent<EmailIdentificationControlProps>({\n name: 'EmailIdentificationControl',\n importPath: '@vtex/faststore/components',\n component: EmailIdentificationControl,\n fragment,\n fetchStrategy: 'reactive',\n actions: { identity: ['clientProfileUpdate'] },\n requiresContext: 'session',\n editor: { label: 'Email Identification', category: 'identity' },\n schema: {\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n invalidEmailMessage: { type: 'string', label: 'Invalid email message' },\n },\n guideline:\n 'Checkout-bound email field: pre-fills from clientProfile.email and persists a valid changed email via $actions.identity.clientProfileUpdate (anonymous→identified). Must be inside SessionRoot. See email-identification.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Matter that binds the presentational `EmailField` to the User Identity foundation. It reads\n * `clientProfile.email` (colocated reactive fragment) for the pre-fill, reads the identification\n * tri-state and `canEditData` from `useSession()` (which also enforces the `SessionRoot` ancestor),\n * and on a **valid, changed** email persists only the `email` field through\n * `$actions.identity.clientProfileUpdate` (async / pessimistic, Decision 1). While the write is in\n * flight the field is disabled and `data-fs-email-identification-pending` is present so a\n * checkout-CTA guard can block. When the session reports `canEditData: false` (identified but\n * unauthenticated claimed profile — VTEX refuses the write server-side) the field renders disabled\n * with `data-fs-email-identification-readonly`. Server `userErrors` are surfaced inline; the\n * session state is never computed locally.\n */\nexport function EmailIdentificationControl({\n label,\n placeholder,\n invalidEmailMessage,\n $data: $dataProp,\n $actions,\n className,\n ...props\n}: EmailIdentificationControlProps) {\n const $data = useDataOverride($dataProp);\n // Also enforces the SessionRoot ancestor: useSession() throws when rendered outside one.\n const { canEditData } = useSession();\n // VTEX refuses profile edits for an identified-but-unauthenticated claimed profile; render the\n // field read-only instead of accepting a write that is doomed server-side.\n const readOnly = !canEditData;\n\n const savedEmail = $data?.email ?? '';\n const [value, setValue] = useState(savedEmail);\n const [pending, setPending] = useState(false);\n const [serverError, setServerError] = useState<string | null>(null);\n\n // Sync the pre-fill when the saved profile email resolves or changes (identified/logged-in shopper).\n // Does not fire while the shopper is typing, since `savedEmail` only changes when the profile does.\n useEffect(() => {\n setValue(savedEmail);\n }, [savedEmail]);\n\n function handleValueChange(next: string) {\n setValue(next);\n if (serverError) setServerError(null);\n }\n\n async function handleBlur() {\n const trimmed = value.trim();\n // Cleared field → re-fill with the saved email; clearing must not visually \"un-identify\"\n // (changing email = switching user is a deliberate act, done by typing a new one).\n if (trimmed === '' && savedEmail !== '') {\n setValue(savedEmail);\n return;\n }\n // Invalid format → EmailField shows its own inline error; no persist, no step advance.\n if (!isValidEmail(trimmed)) return;\n // Unchanged → nothing to persist.\n if (trimmed === savedEmail) return;\n\n setPending(true);\n setServerError(null);\n try {\n const errors = (await $actions?.identity?.clientProfileUpdate?.({ email: trimmed })) ?? [];\n if (errors.length > 0) setServerError(errors[0]?.message ?? null);\n } finally {\n setPending(false);\n }\n }\n\n return (\n <div\n {...props}\n className={className}\n data-fs-email-identification-control=\"\"\n {...(pending ? { 'data-fs-email-identification-pending': '' } : {})}\n {...(readOnly ? { 'data-fs-email-identification-readonly': '' } : {})}\n >\n <EmailField\n label={label}\n placeholder={placeholder}\n value={value}\n disabled={pending || readOnly}\n invalid={serverError != null}\n errorMessage={serverError ?? invalidEmailMessage}\n onValueChange={handleValueChange}\n onBlur={handleBlur}\n required\n />\n </div>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"email-identification.js","names":[],"sources":["../../../src/matter/email-identification/email-identification.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { useEffect, useState } from 'react';\nimport { EmailField, isValidEmail } from '../../particles/email-field/email-field.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 { useSession } from '../session/session.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment (colocated, ADR-0011) — reads only clientProfile.email.\n// Authored as a raw string (not the codegen graphql() factory), mirroring the ShippingSimulator\n// matter: the compiler derives the entity fragment on `clientProfile` and subscribes reactively.\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment EmailIdentificationData on Query {\n clientProfile {\n __typename\n id\n email\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** ClientProfile slice forwarded by the reactive runtime — only `email` is consumed for pre-fill. */\nexport type EmailIdentificationSlice = {\n email?: string | null;\n};\n\nexport type EmailIdentificationControlProps = Omit<ComponentPropsWithRef<'div'>, 'onChange'> & {\n /** Accessible label passed to the EmailField. */\n label?: string;\n /** Input placeholder passed to the EmailField. */\n placeholder?: string;\n /** Inline error text for an invalid email format (port of `checkout/form-messages.invalid-email`). */\n invalidEmailMessage?: string;\n /** ClientProfile slice forwarded by the reactive runtime; `null` until the entity resolves. */\n $data?: EmailIdentificationSlice | null;\n /** Compiler-injected action surface; carries `identity.clientProfileUpdate`. */\n $actions?: ComponentActions;\n};\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const EmailIdentificationControlDefinition = defineComponent<EmailIdentificationControlProps>({\n name: 'EmailIdentificationControl',\n importPath: '@vtex/faststore/components',\n component: EmailIdentificationControl,\n fragment,\n fetchStrategy: 'reactive',\n actions: { identity: ['clientProfileUpdate'] },\n requiresContext: 'session',\n editor: { label: 'Email Identification', category: 'identity' },\n schema: {\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n invalidEmailMessage: { type: 'string', label: 'Invalid email message' },\n },\n guideline:\n 'Checkout-bound email field: pre-fills from clientProfile.email and persists a valid changed email via $actions.identity.clientProfileUpdate (anonymous→identified). Must be inside SessionRoot. See email-identification.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Matter that binds the presentational `EmailField` to the User Identity foundation. It reads\n * `clientProfile.email` (colocated reactive fragment) for the pre-fill, reads the identification\n * tri-state and `canEditData` from `useSession()` (which also enforces the `SessionRoot` ancestor),\n * and on a **valid, changed** email persists only the `email` field through\n * `$actions.identity.clientProfileUpdate` (async / pessimistic, Decision 1). While the write is in\n * flight the field is disabled and `data-fs-email-identification-pending` is present so a\n * checkout-CTA guard can block. When the session reports `canEditData: false` (identified but\n * unauthenticated claimed profile — VTEX refuses the write server-side) the field renders disabled\n * with `data-fs-email-identification-readonly`. Server `userErrors` are surfaced inline; the\n * session state is never computed locally.\n */\nexport function EmailIdentificationControl({\n label,\n placeholder,\n invalidEmailMessage,\n $data: $dataProp,\n $actions: $actionsProp,\n className,\n ...props\n}: EmailIdentificationControlProps) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n // Also enforces the SessionRoot ancestor: useSession() throws when rendered outside one.\n const { canEditData } = useSession();\n // VTEX refuses profile edits for an identified-but-unauthenticated claimed profile; render the\n // field read-only instead of accepting a write that is doomed server-side.\n const readOnly = !canEditData;\n\n const savedEmail = $data?.email ?? '';\n const [value, setValue] = useState(savedEmail);\n const [pending, setPending] = useState(false);\n const [serverError, setServerError] = useState<string | null>(null);\n\n // Sync the pre-fill when the saved profile email resolves or changes (identified/logged-in shopper).\n // Does not fire while the shopper is typing, since `savedEmail` only changes when the profile does.\n useEffect(() => {\n setValue(savedEmail);\n }, [savedEmail]);\n\n function handleValueChange(next: string) {\n setValue(next);\n if (serverError) setServerError(null);\n }\n\n async function handleBlur() {\n const trimmed = value.trim();\n // Cleared field → re-fill with the saved email; clearing must not visually \"un-identify\"\n // (changing email = switching user is a deliberate act, done by typing a new one).\n if (trimmed === '' && savedEmail !== '') {\n setValue(savedEmail);\n return;\n }\n // Invalid format → EmailField shows its own inline error; no persist, no step advance.\n if (!isValidEmail(trimmed)) return;\n // Unchanged → nothing to persist.\n if (trimmed === savedEmail) return;\n\n setPending(true);\n setServerError(null);\n try {\n const errors = (await $actions?.identity?.clientProfileUpdate?.({ email: trimmed })) ?? [];\n if (errors.length > 0) setServerError(errors[0]?.message ?? null);\n } finally {\n setPending(false);\n }\n }\n\n return (\n <div\n {...props}\n className={className}\n data-fs-email-identification-control=\"\"\n {...(pending ? { 'data-fs-email-identification-pending': '' } : {})}\n {...(readOnly ? { 'data-fs-email-identification-readonly': '' } : {})}\n >\n <EmailField\n label={label}\n placeholder={placeholder}\n value={value}\n disabled={pending || readOnly}\n invalid={serverError != null}\n errorMessage={serverError ?? invalidEmailMessage}\n onValueChange={handleValueChange}\n onBlur={handleBlur}\n required\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAqDA,MAAa,uCAAuC,gBAAiD;CACnG,MAAM;CACN,YAAY;CACZ,WAAW;CACX;;;;;;;;;CACA,eAAe;CACf,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE;CAC7C,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAAw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jE,GAAK,WAAW,EAAE,yCAAyC,GAAG,IAAI,CAAC;EAEnE,UAAA,oBAAC,YAAD;GACS;GACM;GACN;GACP,UAAU,WAAW;GACrB,SAAS,eAAe;GACxB,cAAc,eAAe;GAC7B,eAAe;GACf,QAAQ;GACR,UAAA;EACD,CAAA;CACE,CAAA;AAET"}
|
|
@@ -75,7 +75,7 @@ export declare const IdentitySummaryErrorDefinition: ComponentDefinition<Identit
|
|
|
75
75
|
* state. Owns the sign-out mutation state (pending/error) and broadcasts everything the read-only
|
|
76
76
|
* parts and the sign-out button need through `IdentitySummaryContext`.
|
|
77
77
|
*/
|
|
78
|
-
export declare function IdentitySummaryRoot({ signOutErrorMessage, className, children, $data: $dataProp, $actions }: IdentitySummaryRootProps): import("react/jsx-runtime").JSX.Element | null;
|
|
78
|
+
export declare function IdentitySummaryRoot({ signOutErrorMessage, className, children, $data: $dataProp, $actions: $actionsProp }: Readonly<IdentitySummaryRootProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
79
79
|
/**
|
|
80
80
|
* Read-only identity display: a session-state badge plus name, email, phone, and document.
|
|
81
81
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
3
|
import "../../core/dist/index.js";
|
|
4
|
+
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
4
5
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
5
6
|
import { useSession } from "../session/session.js";
|
|
6
7
|
import { applyPhoneMask } from "../../particles/phone-field/phone-field.js";
|
|
@@ -168,8 +169,9 @@ const IdentitySummaryErrorDefinition = defineComponent({
|
|
|
168
169
|
* state. Owns the sign-out mutation state (pending/error) and broadcasts everything the read-only
|
|
169
170
|
* parts and the sign-out button need through `IdentitySummaryContext`.
|
|
170
171
|
*/
|
|
171
|
-
function IdentitySummaryRoot({ signOutErrorMessage = "Unable to sign out. Please try again.", className, children, $data: $dataProp, $actions }) {
|
|
172
|
+
function IdentitySummaryRoot({ signOutErrorMessage = "Unable to sign out. Please try again.", className, children, $data: $dataProp, $actions: $actionsProp }) {
|
|
172
173
|
const $data = useDataOverride($dataProp);
|
|
174
|
+
const $actions = useActionsOverride($actionsProp);
|
|
173
175
|
const { state } = useSession();
|
|
174
176
|
const [signOutPending, setSignOutPending] = useState(false);
|
|
175
177
|
const [signOutError, setSignOutError] = useState(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-summary.js","names":[],"sources":["../../../src/matter/identity-summary/identity-summary.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useState } from 'react';\nimport { Badge } from '../../particles/badge/badge.js';\nimport { applyPhoneMask, type PhoneCountry } from '../../particles/phone-field/phone-field.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport type { SessionUserError } from '../../sdk/session/auth-operations.js';\nimport { type SessionState, useSession } from '../session/session.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — colocated self-contained data root (ADR-0011).\n// Reads only `clientProfile` (the fields this read-only summary displays). The\n// edit surface is a separately-composed `ClientProfileForm`, which owns its own\n// fragment and identity actions.\n//\n// Single top-level entity → the compiler delivers `$data` UNWRAPPED, i.e. the\n// `ClientProfile` value directly, not `{ clientProfile: ... }` (ADR-0015 arity-1).\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment IdentitySummaryData on Query {\n clientProfile {\n __typename\n id\n email\n firstName\n lastName\n phone\n document\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The `$data` slice forwarded by the reactive runtime — the unwrapped `ClientProfile` entity.\n * The fragment selects a single top-level field, so the compiler hands the entity value directly\n * (not a `{ clientProfile: ... }` wrapper); ADR-0015.\n */\nexport type IdentitySummaryData = {\n email?: string | null;\n firstName?: string | null;\n lastName?: string | null;\n phone?: string | null;\n document?: string | null;\n} | null;\n\n// ---------------------------------------------------------------------------\n// Context — data + session state + sign-out, provided by IdentitySummaryRoot.\n// The summary/form swap is owned by `IdentityEditController`, which moves only on its own buttons\n// (ADR-0006) — this matter owns only the identity data and the sign-out action, never a bespoke toggle.\n// ---------------------------------------------------------------------------\n\ntype IdentitySummaryContextValue = {\n state: SessionState;\n firstName: string;\n lastName: string;\n email: string;\n phone: string;\n document: string;\n handleSignOut: () => void;\n signOutPending: boolean;\n signOutError: string | null;\n};\n\nconst IDENTITY_SUMMARY_CONTEXT_UNSET = Symbol('IdentitySummaryContextUnset');\n\nconst IdentitySummaryContext = createContext<IdentitySummaryContextValue | typeof IDENTITY_SUMMARY_CONTEXT_UNSET>(\n IDENTITY_SUMMARY_CONTEXT_UNSET,\n);\n\nfunction useIdentitySummaryContext(): IdentitySummaryContextValue {\n const ctx = useContext(IdentitySummaryContext);\n if (ctx === IDENTITY_SUMMARY_CONTEXT_UNSET) {\n throw new Error('IdentitySummary components must be used inside IdentitySummaryRoot.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type IdentitySummaryRootProps = {\n /** Error message shown when the sign-out mutation returns user errors. */\n signOutErrorMessage?: string;\n className?: string;\n children?: ReactNode;\n /** `IdentitySummaryData` slice forwarded by the reactive runtime. */\n $data?: IdentitySummaryData;\n /** Compiler-injected action surface; carries `session.logout`. */\n $actions?: ComponentActions;\n};\n\nexport type IdentitySummarySelectedSummaryProps = {\n /** Phone display country; selects the mask applied to the stored E.164 value. */\n country?: PhoneCountry;\n /** Badge label in the `identified` session state. */\n identifiedBadgeLabel?: string;\n /** Badge label in the `loggedIn` session state. */\n loggedInBadgeLabel?: string;\n className?: string;\n /** Compose custom read-only content; falls back to the default badge + details when omitted. */\n children?: ReactNode;\n};\n\nexport type IdentitySummaryBadgeProps = {\n /** Badge label in the `identified` session state. */\n identifiedLabel?: string;\n /** Badge label in the `loggedIn` session state. */\n loggedInLabel?: string;\n className?: string;\n};\n\nexport type IdentitySummaryFieldProps = {\n className?: string;\n};\n\nexport type IdentitySummaryPhoneProps = {\n /** Phone display country; selects the mask applied to the stored E.164 value. */\n country?: PhoneCountry;\n className?: string;\n};\n\nexport type IdentitySummarySignOutButtonProps = {\n label?: string;\n className?: string;\n children?: ReactNode;\n};\n\nexport type IdentitySummaryErrorProps = {\n className?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const IdentitySummaryRootDefinition = defineComponent<IdentitySummaryRootProps>({\n name: 'IdentitySummaryRoot',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryRoot,\n fragment,\n fetchStrategy: 'reactive',\n requiresContext: 'session',\n providesContext: 'identity-summary',\n actions: { session: ['logout'] },\n editor: { label: 'Identity Summary Root', category: 'identity' },\n schema: {\n signOutErrorMessage: {\n type: 'string',\n default: 'Unable to sign out. Please try again.',\n label: 'Sign-out error message',\n },\n },\n guideline:\n 'Read-only identity summary data root: reads the shopper profile, provides it plus a sign-out action to descendants, and self-gates (renders nothing in the anonymous state). Must be inside SessionRoot. Wrap the parts in an IdentityEditController for the summary/form swap: an IdentitySummaryView holding these parts, an IdentityEditForm holding a ClientProfileForm. See identity-summary.md.',\n});\n\nexport const IdentitySummarySelectedSummaryDefinition = defineComponent<IdentitySummarySelectedSummaryProps>({\n name: 'IdentitySummarySelectedSummary',\n importPath: '@vtex/faststore/components',\n component: IdentitySummarySelectedSummary,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Selected Summary', category: 'identity' },\n schema: {},\n guideline:\n 'Default composition of the identity summary: badge, name, e-mail, phone, document, in that order. It is a shortcut, not the only way — to change the order, drop a field, or interleave anything else, compose IdentitySummaryBadge / Name / Email / Phone / Document directly instead. It offers nothing to the schema: its country and badge-label props configure the default composition only, and are withheld from the schema because a page that set one here and then composed children would watch it vanish. A composed summary configures the leaf instead — the phone mask country on IdentitySummaryPhone, the labels on IdentitySummaryBadge. Must be a descendant of IdentitySummaryRoot.',\n});\n\nexport const IdentitySummaryBadgeDefinition = defineComponent<IdentitySummaryBadgeProps>({\n name: 'IdentitySummaryBadge',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryBadge,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Badge', category: 'identity' },\n schema: {\n identifiedLabel: { type: 'string', default: 'Guest', label: 'Identified badge label' },\n loggedInLabel: { type: 'string', default: 'Signed in', label: 'Logged-in badge label' },\n },\n guideline:\n 'Session-state badge for the identity summary. Place it wherever the summary should carry it; order is composition, not a prop. Must be a descendant of IdentitySummaryRoot.',\n});\n\nexport const IdentitySummaryNameDefinition = defineComponent<IdentitySummaryFieldProps>({\n name: 'IdentitySummaryName',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryName,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Name', category: 'identity' },\n schema: {},\n guideline:\n \"The shopper's full name, or nothing when the profile has neither first nor last name. Place it in whatever order the summary should read. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummaryEmailDefinition = defineComponent<IdentitySummaryFieldProps>({\n name: 'IdentitySummaryEmail',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryEmail,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Email', category: 'identity' },\n schema: {},\n guideline: \"The shopper's e-mail, or nothing when absent. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummaryPhoneDefinition = defineComponent<IdentitySummaryPhoneProps>({\n name: 'IdentitySummaryPhone',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryPhone,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Phone', category: 'identity' },\n schema: {\n country: { type: 'string', label: 'Phone country (US or BR)' },\n },\n guideline:\n \"The shopper's phone, or nothing when absent. Masked for `country` when one is set; rendered as stored otherwise, since each mask truncates to its own country's length. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummaryDocumentDefinition = defineComponent<IdentitySummaryFieldProps>({\n name: 'IdentitySummaryDocument',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryDocument,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Document', category: 'identity' },\n schema: {},\n guideline: \"The shopper's tax document, or nothing when absent. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummarySignOutButtonDefinition = defineComponent<IdentitySummarySignOutButtonProps>({\n name: 'IdentitySummarySignOutButton',\n importPath: '@vtex/faststore/components',\n component: IdentitySummarySignOutButton,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Sign Out Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'Sign out', label: 'Button label' },\n },\n guideline:\n 'Dispatches $actions.session.logout (async/pessimistic): carries data-fs-identity-summary-pending while in flight and disables itself. Compose an Icon + text as children, or rely on `label`. Must be a descendant of IdentitySummaryRoot.',\n});\n\nexport const IdentitySummaryErrorDefinition = defineComponent<IdentitySummaryErrorProps>({\n name: 'IdentitySummaryError',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryError,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Error', category: 'content' },\n schema: {},\n guideline:\n 'Renders the inline sign-out error (role=\"alert\") when the logout mutation returns a user error, else nothing. Must be a descendant of IdentitySummaryRoot.',\n});\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\n/**\n * Data root for the identity summary. Reads the shopper profile from its colocated fragment,\n * enforces the SessionRoot ancestor via `useSession()`, and self-gates to null in the anonymous\n * state. Owns the sign-out mutation state (pending/error) and broadcasts everything the read-only\n * parts and the sign-out button need through `IdentitySummaryContext`.\n */\nexport function IdentitySummaryRoot({\n signOutErrorMessage = 'Unable to sign out. Please try again.',\n className,\n children,\n $data: $dataProp,\n $actions,\n}: IdentitySummaryRootProps) {\n const $data = useDataOverride($dataProp);\n // Enforces the SessionRoot ancestor: useSession() throws when rendered outside one.\n const { state } = useSession();\n\n const [signOutPending, setSignOutPending] = useState(false);\n const [signOutError, setSignOutError] = useState<string | null>(null);\n\n async function handleSignOut() {\n setSignOutPending(true);\n setSignOutError(null);\n try {\n const errors: readonly SessionUserError[] = (await $actions?.session?.logout?.()) ?? [];\n if (errors.length > 0) setSignOutError(errors[0]?.message ?? signOutErrorMessage);\n } catch (error) {\n // A logout that throws rather than resolving userErrors would otherwise leave the shopper still\n // signed in with nothing on screen, and escape as an unhandled rejection.\n console.error('[IdentitySummary] logout failed:', error);\n setSignOutError(signOutErrorMessage);\n } finally {\n setSignOutPending(false);\n }\n }\n\n // Self-gate: nothing to show for an anonymous or unresolved session.\n if (state === 'anonymous') return null;\n\n const contextValue: IdentitySummaryContextValue = {\n state,\n firstName: $data?.firstName ?? '',\n lastName: $data?.lastName ?? '',\n email: $data?.email ?? '',\n phone: $data?.phone ?? '',\n document: $data?.document ?? '',\n handleSignOut,\n signOutPending,\n signOutError,\n };\n\n return (\n <IdentitySummaryContext.Provider value={contextValue}>\n <div\n className={className}\n data-fs-identity-summary=\"\"\n {...(signOutPending ? { 'data-fs-identity-summary-pending': '' } : {})}\n >\n {children}\n </div>\n </IdentitySummaryContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Read-only summary\n// ---------------------------------------------------------------------------\n\n/**\n * Read-only identity display: a session-state badge plus name, email, phone, and document.\n *\n * The props below configure the default composition only — composing children replaces it wholesale,\n * and a leaf placed there takes its own props (`IdentitySummaryPhone` its `country`,\n * `IdentitySummaryBadge` its labels). They are deliberately absent from the schema, so a page cannot\n * set one here and watch it disappear behind composed children.\n */\nexport function IdentitySummarySelectedSummary({\n country,\n identifiedBadgeLabel = 'Guest',\n loggedInBadgeLabel = 'Signed in',\n className,\n children,\n}: IdentitySummarySelectedSummaryProps) {\n return (\n <div className={className} data-fs-identity-summary-summary=\"\">\n {children ?? (\n <>\n <IdentitySummaryBadge identifiedLabel={identifiedBadgeLabel} loggedInLabel={loggedInBadgeLabel} />\n <IdentitySummaryName />\n <IdentitySummaryEmail />\n <IdentitySummaryPhone country={country} />\n <IdentitySummaryDocument />\n </>\n )}\n </div>\n );\n}\n\n/** Session-state badge. Renders `identifiedLabel` for a guest and `loggedInLabel` once authenticated. */\nexport function IdentitySummaryBadge({\n identifiedLabel = 'Guest',\n loggedInLabel = 'Signed in',\n className,\n}: IdentitySummaryBadgeProps) {\n const { state } = useIdentitySummaryContext();\n return (\n <Badge className={className} data-fs-identity-summary-badge=\"\" data-fs-identity-summary-state={state}>\n {state === 'loggedIn' ? loggedInLabel : identifiedLabel}\n </Badge>\n );\n}\n\n/** The shopper's full name. Renders nothing when the profile carries neither name. */\nexport function IdentitySummaryName({ className }: IdentitySummaryFieldProps) {\n const { firstName, lastName } = useIdentitySummaryContext();\n const fullName = [firstName, lastName].filter(Boolean).join(' ');\n if (!fullName) return null;\n return (\n <p className={className} data-fs-identity-summary-name=\"\">\n {fullName}\n </p>\n );\n}\n\n/** The shopper's e-mail. Renders nothing when absent. */\nexport function IdentitySummaryEmail({ className }: IdentitySummaryFieldProps) {\n const { email } = useIdentitySummaryContext();\n if (!email) return null;\n return (\n <p className={className} data-fs-identity-summary-email=\"\">\n {email}\n </p>\n );\n}\n\n/** E.164 prefixes for the countries the masks understand. */\nconst COUNTRY_PREFIX: Record<PhoneCountry, string> = { BR: '+55', US: '+1' };\n\n/**\n * The shopper's phone, masked for `country`. Renders nothing when absent, and renders the stored value\n * as-is whenever the mask does not apply to it — no country given, or a stored E.164 number belonging to\n * a different one. Each mask truncates to its own country's length, so applying the wrong one prints a\n * number that is not the shopper's, with nothing to signal that digits were dropped.\n */\nexport function IdentitySummaryPhone({ country, className }: IdentitySummaryPhoneProps) {\n const { phone } = useIdentitySummaryContext();\n if (!phone) return null;\n const maskApplies = country !== undefined && (!phone.startsWith('+') || phone.startsWith(COUNTRY_PREFIX[country]));\n return (\n <p className={className} data-fs-identity-summary-phone=\"\">\n {maskApplies && country ? applyPhoneMask(phone, country) : phone}\n </p>\n );\n}\n\n/** The shopper's tax document. Renders nothing when absent. */\nexport function IdentitySummaryDocument({ className }: IdentitySummaryFieldProps) {\n const { document } = useIdentitySummaryContext();\n if (!document) return null;\n return (\n <p className={className} data-fs-identity-summary-document=\"\">\n {document}\n </p>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sign-out button + error (domain-coupled; the summary/form swap is IdentityEditController's)\n// ---------------------------------------------------------------------------\n\n/** Dispatches the sign-out mutation (async/pessimistic). */\nexport function IdentitySummarySignOutButton({\n label = 'Sign out',\n className,\n children,\n}: IdentitySummarySignOutButtonProps) {\n const { handleSignOut, signOutPending } = useIdentitySummaryContext();\n return (\n <button\n type=\"button\"\n data-fs-identity-summary-sign-out=\"\"\n className={className}\n disabled={signOutPending}\n {...(signOutPending ? { 'data-fs-identity-summary-pending': '' } : {})}\n onClick={handleSignOut}\n >\n {children ?? label}\n </button>\n );\n}\n\n/** Renders the inline sign-out user error, or nothing when there is none. */\nexport function IdentitySummaryError({ className }: IdentitySummaryErrorProps) {\n const { signOutError } = useIdentitySummaryContext();\n if (!signOutError) return null;\n return (\n <div role=\"alert\" className={className} data-fs-identity-summary-error=\"\">\n {signOutError}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const IdentitySummary = {\n Badge: IdentitySummaryBadge,\n BadgeDefinition: IdentitySummaryBadgeDefinition,\n Name: IdentitySummaryName,\n NameDefinition: IdentitySummaryNameDefinition,\n Email: IdentitySummaryEmail,\n EmailDefinition: IdentitySummaryEmailDefinition,\n Phone: IdentitySummaryPhone,\n PhoneDefinition: IdentitySummaryPhoneDefinition,\n Document: IdentitySummaryDocument,\n DocumentDefinition: IdentitySummaryDocumentDefinition,\n Root: IdentitySummaryRoot,\n RootDefinition: IdentitySummaryRootDefinition,\n SelectedSummary: IdentitySummarySelectedSummary,\n SelectedSummaryDefinition: IdentitySummarySelectedSummaryDefinition,\n SignOutButton: IdentitySummarySignOutButton,\n SignOutButtonDefinition: IdentitySummarySignOutButtonDefinition,\n Error: IdentitySummaryError,\n ErrorDefinition: IdentitySummaryErrorDefinition,\n};\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,WAAyB;;;;;;;;;;;;;AAiD/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;AA6DA,MAAa,gCAAgC,gBAA0C;CACrF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;CAC/B,QAAQ;EAAE,OAAO;EAAyB,UAAU;CAAW;CAC/D,QAAQ,EACN,qBAAqB;EACnB,MAAM;EACN,SAAS;EACT,OAAO;CACT,EACF;CACA,WACE;AACJ,CAAC;AAED,MAAa,2CAA2C,gBAAqD;CAC3G,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA6B,UAAU;CAAW;CACnE,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,iCAAiC,gBAA2C;CACvF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA0B,UAAU;CAAW;CAChE,QAAQ;EACN,iBAAiB;GAAE,MAAM;GAAU,SAAS;GAAS,OAAO;EAAyB;EACrF,eAAe;GAAE,MAAM;GAAU,SAAS;GAAa,OAAO;EAAwB;CACxF;CACA,WACE;AACJ,CAAC;AAED,MAAa,gCAAgC,gBAA2C;CACtF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAAyB,UAAU;CAAW;CAC/D,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;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AEZ;;AAGA,SAAgB,qBAAqB,EAAE,aAAwC;CAC7E,MAAM,EAAE,iBAAiB,0BAA0B;CACnD,IAAI,CAAC,cAAc,OAAO;CAC1B,OACE,oBAAC,OAAD;EAAK,MAAK;EAAmB;EAAW,kCAA+B;EACpE,UAAA;CACE,CAAA;AAET;AAMA,MAAa,kBAAkB;CAC7B,OAAO;CACP,iBAAiB;CACjB,MAAM;CACN,gBAAgB;CAChB,OAAO;CACP,iBAAiB;CACjB,OAAO;CACP,iBAAiB;CACjB,UAAU;CACV,oBAAoB;CACpB,MAAM;CACN,gBAAgB;CAChB,iBAAiB;CACjB,2BAA2B;CAC3B,eAAe;CACf,yBAAyB;CACzB,OAAO;CACP,iBAAiB;AACnB"}
|
|
1
|
+
{"version":3,"file":"identity-summary.js","names":[],"sources":["../../../src/matter/identity-summary/identity-summary.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useState } from 'react';\nimport { Badge } from '../../particles/badge/badge.js';\nimport { applyPhoneMask, type PhoneCountry } from '../../particles/phone-field/phone-field.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 type { SessionUserError } from '../../sdk/session/auth-operations.js';\nimport { type SessionState, useSession } from '../session/session.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — colocated self-contained data root (ADR-0011).\n// Reads only `clientProfile` (the fields this read-only summary displays). The\n// edit surface is a separately-composed `ClientProfileForm`, which owns its own\n// fragment and identity actions.\n//\n// Single top-level entity → the compiler delivers `$data` UNWRAPPED, i.e. the\n// `ClientProfile` value directly, not `{ clientProfile: ... }` (ADR-0015 arity-1).\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment IdentitySummaryData on Query {\n clientProfile {\n __typename\n id\n email\n firstName\n lastName\n phone\n document\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The `$data` slice forwarded by the reactive runtime — the unwrapped `ClientProfile` entity.\n * The fragment selects a single top-level field, so the compiler hands the entity value directly\n * (not a `{ clientProfile: ... }` wrapper); ADR-0015.\n */\nexport type IdentitySummaryData = {\n email?: string | null;\n firstName?: string | null;\n lastName?: string | null;\n phone?: string | null;\n document?: string | null;\n} | null;\n\n// ---------------------------------------------------------------------------\n// Context — data + session state + sign-out, provided by IdentitySummaryRoot.\n// The summary/form swap is owned by `IdentityEditController`, which moves only on its own buttons\n// (ADR-0006) — this matter owns only the identity data and the sign-out action, never a bespoke toggle.\n// ---------------------------------------------------------------------------\n\ntype IdentitySummaryContextValue = {\n state: SessionState;\n firstName: string;\n lastName: string;\n email: string;\n phone: string;\n document: string;\n handleSignOut: () => void;\n signOutPending: boolean;\n signOutError: string | null;\n};\n\nconst IDENTITY_SUMMARY_CONTEXT_UNSET = Symbol('IdentitySummaryContextUnset');\n\nconst IdentitySummaryContext = createContext<IdentitySummaryContextValue | typeof IDENTITY_SUMMARY_CONTEXT_UNSET>(\n IDENTITY_SUMMARY_CONTEXT_UNSET,\n);\n\nfunction useIdentitySummaryContext(): IdentitySummaryContextValue {\n const ctx = useContext(IdentitySummaryContext);\n if (ctx === IDENTITY_SUMMARY_CONTEXT_UNSET) {\n throw new Error('IdentitySummary components must be used inside IdentitySummaryRoot.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type IdentitySummaryRootProps = {\n /** Error message shown when the sign-out mutation returns user errors. */\n signOutErrorMessage?: string;\n className?: string;\n children?: ReactNode;\n /** `IdentitySummaryData` slice forwarded by the reactive runtime. */\n $data?: IdentitySummaryData;\n /** Compiler-injected action surface; carries `session.logout`. */\n $actions?: ComponentActions;\n};\n\nexport type IdentitySummarySelectedSummaryProps = {\n /** Phone display country; selects the mask applied to the stored E.164 value. */\n country?: PhoneCountry;\n /** Badge label in the `identified` session state. */\n identifiedBadgeLabel?: string;\n /** Badge label in the `loggedIn` session state. */\n loggedInBadgeLabel?: string;\n className?: string;\n /** Compose custom read-only content; falls back to the default badge + details when omitted. */\n children?: ReactNode;\n};\n\nexport type IdentitySummaryBadgeProps = {\n /** Badge label in the `identified` session state. */\n identifiedLabel?: string;\n /** Badge label in the `loggedIn` session state. */\n loggedInLabel?: string;\n className?: string;\n};\n\nexport type IdentitySummaryFieldProps = {\n className?: string;\n};\n\nexport type IdentitySummaryPhoneProps = {\n /** Phone display country; selects the mask applied to the stored E.164 value. */\n country?: PhoneCountry;\n className?: string;\n};\n\nexport type IdentitySummarySignOutButtonProps = {\n label?: string;\n className?: string;\n children?: ReactNode;\n};\n\nexport type IdentitySummaryErrorProps = {\n className?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const IdentitySummaryRootDefinition = defineComponent<IdentitySummaryRootProps>({\n name: 'IdentitySummaryRoot',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryRoot,\n fragment,\n fetchStrategy: 'reactive',\n requiresContext: 'session',\n providesContext: 'identity-summary',\n actions: { session: ['logout'] },\n editor: { label: 'Identity Summary Root', category: 'identity' },\n schema: {\n signOutErrorMessage: {\n type: 'string',\n default: 'Unable to sign out. Please try again.',\n label: 'Sign-out error message',\n },\n },\n guideline:\n 'Read-only identity summary data root: reads the shopper profile, provides it plus a sign-out action to descendants, and self-gates (renders nothing in the anonymous state). Must be inside SessionRoot. Wrap the parts in an IdentityEditController for the summary/form swap: an IdentitySummaryView holding these parts, an IdentityEditForm holding a ClientProfileForm. See identity-summary.md.',\n});\n\nexport const IdentitySummarySelectedSummaryDefinition = defineComponent<IdentitySummarySelectedSummaryProps>({\n name: 'IdentitySummarySelectedSummary',\n importPath: '@vtex/faststore/components',\n component: IdentitySummarySelectedSummary,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Selected Summary', category: 'identity' },\n schema: {},\n guideline:\n 'Default composition of the identity summary: badge, name, e-mail, phone, document, in that order. It is a shortcut, not the only way — to change the order, drop a field, or interleave anything else, compose IdentitySummaryBadge / Name / Email / Phone / Document directly instead. It offers nothing to the schema: its country and badge-label props configure the default composition only, and are withheld from the schema because a page that set one here and then composed children would watch it vanish. A composed summary configures the leaf instead — the phone mask country on IdentitySummaryPhone, the labels on IdentitySummaryBadge. Must be a descendant of IdentitySummaryRoot.',\n});\n\nexport const IdentitySummaryBadgeDefinition = defineComponent<IdentitySummaryBadgeProps>({\n name: 'IdentitySummaryBadge',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryBadge,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Badge', category: 'identity' },\n schema: {\n identifiedLabel: { type: 'string', default: 'Guest', label: 'Identified badge label' },\n loggedInLabel: { type: 'string', default: 'Signed in', label: 'Logged-in badge label' },\n },\n guideline:\n 'Session-state badge for the identity summary. Place it wherever the summary should carry it; order is composition, not a prop. Must be a descendant of IdentitySummaryRoot.',\n});\n\nexport const IdentitySummaryNameDefinition = defineComponent<IdentitySummaryFieldProps>({\n name: 'IdentitySummaryName',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryName,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Name', category: 'identity' },\n schema: {},\n guideline:\n \"The shopper's full name, or nothing when the profile has neither first nor last name. Place it in whatever order the summary should read. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummaryEmailDefinition = defineComponent<IdentitySummaryFieldProps>({\n name: 'IdentitySummaryEmail',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryEmail,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Email', category: 'identity' },\n schema: {},\n guideline: \"The shopper's e-mail, or nothing when absent. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummaryPhoneDefinition = defineComponent<IdentitySummaryPhoneProps>({\n name: 'IdentitySummaryPhone',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryPhone,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Phone', category: 'identity' },\n schema: {\n country: { type: 'string', label: 'Phone country (US or BR)' },\n },\n guideline:\n \"The shopper's phone, or nothing when absent. Masked for `country` when one is set; rendered as stored otherwise, since each mask truncates to its own country's length. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummaryDocumentDefinition = defineComponent<IdentitySummaryFieldProps>({\n name: 'IdentitySummaryDocument',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryDocument,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Document', category: 'identity' },\n schema: {},\n guideline: \"The shopper's tax document, or nothing when absent. Must be a descendant of IdentitySummaryRoot.\",\n});\n\nexport const IdentitySummarySignOutButtonDefinition = defineComponent<IdentitySummarySignOutButtonProps>({\n name: 'IdentitySummarySignOutButton',\n importPath: '@vtex/faststore/components',\n component: IdentitySummarySignOutButton,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Sign Out Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'Sign out', label: 'Button label' },\n },\n guideline:\n 'Dispatches $actions.session.logout (async/pessimistic): carries data-fs-identity-summary-pending while in flight and disables itself. Compose an Icon + text as children, or rely on `label`. Must be a descendant of IdentitySummaryRoot.',\n});\n\nexport const IdentitySummaryErrorDefinition = defineComponent<IdentitySummaryErrorProps>({\n name: 'IdentitySummaryError',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryError,\n requiresContext: 'identity-summary',\n editor: { label: 'Identity Summary Error', category: 'content' },\n schema: {},\n guideline:\n 'Renders the inline sign-out error (role=\"alert\") when the logout mutation returns a user error, else nothing. Must be a descendant of IdentitySummaryRoot.',\n});\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\n/**\n * Data root for the identity summary. Reads the shopper profile from its colocated fragment,\n * enforces the SessionRoot ancestor via `useSession()`, and self-gates to null in the anonymous\n * state. Owns the sign-out mutation state (pending/error) and broadcasts everything the read-only\n * parts and the sign-out button need through `IdentitySummaryContext`.\n */\nexport function IdentitySummaryRoot({\n signOutErrorMessage = 'Unable to sign out. Please try again.',\n className,\n children,\n $data: $dataProp,\n $actions: $actionsProp,\n}: Readonly<IdentitySummaryRootProps>) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n // Enforces the SessionRoot ancestor: useSession() throws when rendered outside one.\n const { state } = useSession();\n\n const [signOutPending, setSignOutPending] = useState(false);\n const [signOutError, setSignOutError] = useState<string | null>(null);\n\n async function handleSignOut() {\n setSignOutPending(true);\n setSignOutError(null);\n try {\n const errors: readonly SessionUserError[] = (await $actions?.session?.logout?.()) ?? [];\n if (errors.length > 0) setSignOutError(errors[0]?.message ?? signOutErrorMessage);\n } catch (error) {\n // A logout that throws rather than resolving userErrors would otherwise leave the shopper still\n // signed in with nothing on screen, and escape as an unhandled rejection.\n console.error('[IdentitySummary] logout failed:', error);\n setSignOutError(signOutErrorMessage);\n } finally {\n setSignOutPending(false);\n }\n }\n\n // Self-gate: nothing to show for an anonymous or unresolved session.\n if (state === 'anonymous') return null;\n\n const contextValue: IdentitySummaryContextValue = {\n state,\n firstName: $data?.firstName ?? '',\n lastName: $data?.lastName ?? '',\n email: $data?.email ?? '',\n phone: $data?.phone ?? '',\n document: $data?.document ?? '',\n handleSignOut,\n signOutPending,\n signOutError,\n };\n\n return (\n <IdentitySummaryContext.Provider value={contextValue}>\n <div\n className={className}\n data-fs-identity-summary=\"\"\n {...(signOutPending ? { 'data-fs-identity-summary-pending': '' } : {})}\n >\n {children}\n </div>\n </IdentitySummaryContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Read-only summary\n// ---------------------------------------------------------------------------\n\n/**\n * Read-only identity display: a session-state badge plus name, email, phone, and document.\n *\n * The props below configure the default composition only — composing children replaces it wholesale,\n * and a leaf placed there takes its own props (`IdentitySummaryPhone` its `country`,\n * `IdentitySummaryBadge` its labels). They are deliberately absent from the schema, so a page cannot\n * set one here and watch it disappear behind composed children.\n */\nexport function IdentitySummarySelectedSummary({\n country,\n identifiedBadgeLabel = 'Guest',\n loggedInBadgeLabel = 'Signed in',\n className,\n children,\n}: IdentitySummarySelectedSummaryProps) {\n return (\n <div className={className} data-fs-identity-summary-summary=\"\">\n {children ?? (\n <>\n <IdentitySummaryBadge identifiedLabel={identifiedBadgeLabel} loggedInLabel={loggedInBadgeLabel} />\n <IdentitySummaryName />\n <IdentitySummaryEmail />\n <IdentitySummaryPhone country={country} />\n <IdentitySummaryDocument />\n </>\n )}\n </div>\n );\n}\n\n/** Session-state badge. Renders `identifiedLabel` for a guest and `loggedInLabel` once authenticated. */\nexport function IdentitySummaryBadge({\n identifiedLabel = 'Guest',\n loggedInLabel = 'Signed in',\n className,\n}: IdentitySummaryBadgeProps) {\n const { state } = useIdentitySummaryContext();\n return (\n <Badge className={className} data-fs-identity-summary-badge=\"\" data-fs-identity-summary-state={state}>\n {state === 'loggedIn' ? loggedInLabel : identifiedLabel}\n </Badge>\n );\n}\n\n/** The shopper's full name. Renders nothing when the profile carries neither name. */\nexport function IdentitySummaryName({ className }: IdentitySummaryFieldProps) {\n const { firstName, lastName } = useIdentitySummaryContext();\n const fullName = [firstName, lastName].filter(Boolean).join(' ');\n if (!fullName) return null;\n return (\n <p className={className} data-fs-identity-summary-name=\"\">\n {fullName}\n </p>\n );\n}\n\n/** The shopper's e-mail. Renders nothing when absent. */\nexport function IdentitySummaryEmail({ className }: IdentitySummaryFieldProps) {\n const { email } = useIdentitySummaryContext();\n if (!email) return null;\n return (\n <p className={className} data-fs-identity-summary-email=\"\">\n {email}\n </p>\n );\n}\n\n/** E.164 prefixes for the countries the masks understand. */\nconst COUNTRY_PREFIX: Record<PhoneCountry, string> = { BR: '+55', US: '+1' };\n\n/**\n * The shopper's phone, masked for `country`. Renders nothing when absent, and renders the stored value\n * as-is whenever the mask does not apply to it — no country given, or a stored E.164 number belonging to\n * a different one. Each mask truncates to its own country's length, so applying the wrong one prints a\n * number that is not the shopper's, with nothing to signal that digits were dropped.\n */\nexport function IdentitySummaryPhone({ country, className }: IdentitySummaryPhoneProps) {\n const { phone } = useIdentitySummaryContext();\n if (!phone) return null;\n const maskApplies = country !== undefined && (!phone.startsWith('+') || phone.startsWith(COUNTRY_PREFIX[country]));\n return (\n <p className={className} data-fs-identity-summary-phone=\"\">\n {maskApplies && country ? applyPhoneMask(phone, country) : phone}\n </p>\n );\n}\n\n/** The shopper's tax document. Renders nothing when absent. */\nexport function IdentitySummaryDocument({ className }: IdentitySummaryFieldProps) {\n const { document } = useIdentitySummaryContext();\n if (!document) return null;\n return (\n <p className={className} data-fs-identity-summary-document=\"\">\n {document}\n </p>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sign-out button + error (domain-coupled; the summary/form swap is IdentityEditController's)\n// ---------------------------------------------------------------------------\n\n/** Dispatches the sign-out mutation (async/pessimistic). */\nexport function IdentitySummarySignOutButton({\n label = 'Sign out',\n className,\n children,\n}: IdentitySummarySignOutButtonProps) {\n const { handleSignOut, signOutPending } = useIdentitySummaryContext();\n return (\n <button\n type=\"button\"\n data-fs-identity-summary-sign-out=\"\"\n className={className}\n disabled={signOutPending}\n {...(signOutPending ? { 'data-fs-identity-summary-pending': '' } : {})}\n onClick={handleSignOut}\n >\n {children ?? label}\n </button>\n );\n}\n\n/** Renders the inline sign-out user error, or nothing when there is none. */\nexport function IdentitySummaryError({ className }: IdentitySummaryErrorProps) {\n const { signOutError } = useIdentitySummaryContext();\n if (!signOutError) return null;\n return (\n <div role=\"alert\" className={className} data-fs-identity-summary-error=\"\">\n {signOutError}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const IdentitySummary = {\n Badge: IdentitySummaryBadge,\n BadgeDefinition: IdentitySummaryBadgeDefinition,\n Name: IdentitySummaryName,\n NameDefinition: IdentitySummaryNameDefinition,\n Email: IdentitySummaryEmail,\n EmailDefinition: IdentitySummaryEmailDefinition,\n Phone: IdentitySummaryPhone,\n PhoneDefinition: IdentitySummaryPhoneDefinition,\n Document: IdentitySummaryDocument,\n DocumentDefinition: IdentitySummaryDocumentDefinition,\n Root: IdentitySummaryRoot,\n RootDefinition: IdentitySummaryRootDefinition,\n SelectedSummary: IdentitySummarySelectedSummary,\n SelectedSummaryDefinition: IdentitySummarySelectedSummaryDefinition,\n SignOutButton: IdentitySummarySignOutButton,\n SignOutButtonDefinition: IdentitySummarySignOutButtonDefinition,\n Error: IdentitySummaryError,\n ErrorDefinition: IdentitySummaryErrorDefinition,\n};\n"],"mappings":";;;;;;;;;;;AAsBA,MAAM,WAAyB;;;;;;;;;;;;;AAiD/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;AA6DA,MAAa,gCAAgC,gBAA0C;CACrF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;CAC/B,QAAQ;EAAE,OAAO;EAAyB,UAAU;CAAW;CAC/D,QAAQ,EACN,qBAAqB;EACnB,MAAM;EACN,SAAS;EACT,OAAO;CACT,EACF;CACA,WACE;AACJ,CAAC;AAED,MAAa,2CAA2C,gBAAqD;CAC3G,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA6B,UAAU;CAAW;CACnE,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,iCAAiC,gBAA2C;CACvF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA0B,UAAU;CAAW;CAChE,QAAQ;EACN,iBAAiB;GAAE,MAAM;GAAU,SAAS;GAAS,OAA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AAW,qCAAkC;EACxD,UAAA;CACA,CAAA;AAEP;;AAOA,SAAgB,6BAA6B,EAC3C,QAAQ,YACR,WACA,YACoC;CACpC,MAAM,EAAE,eAAe,mBAAmB,0BAA0B;CACpE,OACE,oBAAC,UAAD;EACE,MAAK;EACL,qCAAkC;EACvB;EACX,UAAU;EACV,GAAK,iBAAiB,EAAE,oCAAoC,GAAG,IAAI,CAAC;EACpE,SAAS;EAER,UAAA,YAAY;CACP,CAAA;AAEZ;;AAGA,SAAgB,qBAAqB,EAAE,aAAwC;CAC7E,MAAM,EAAE,iBAAiB,0BAA0B;CACnD,IAAI,CAAC,cAAc,OAAO;CAC1B,OACE,oBAAC,OAAD;EAAK,MAAK;EAAmB;EAAW,kCAA+B;EACpE,UAAA;CACE,CAAA;AAET;AAMA,MAAa,kBAAkB;CAC7B,OAAO;CACP,iBAAiB;CACjB,MAAM;CACN,gBAAgB;CAChB,OAAO;CACP,iBAAiB;CACjB,OAAO;CACP,iBAAiB;CACjB,UAAU;CACV,oBAAoB;CACpB,MAAM;CACN,gBAAgB;CAChB,iBAAiB;CACjB,2BAA2B;CAC3B,eAAe;CACf,yBAAyB;CACzB,OAAO;CACP,iBAAiB;AACnB"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { ComponentActions } from "../../sdk/actions/types.js";
|
|
4
|
+
import { PhoneCountry } from "../../particles/phone-field/phone-field.js";
|
|
5
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
6
|
+
//#region src/matter/my-account-profile/my-account-profile.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The `$data` slice forwarded by the reactive runtime — the `customerProfile` entity itself, not the
|
|
9
|
+
* `Query` shape the fragment above is authored against. The compiler derives an entity fragment `on
|
|
10
|
+
* CustomerProfile` from the root-field selection for the reactive path (rfc-data-layer.md §"Entity
|
|
11
|
+
* fragments and schema introspection"), and `ReactiveDataProvider` publishes that entity data
|
|
12
|
+
* directly — the same convention `SessionRoot` reads `$data.loggedIn` under, not `$data.session`.
|
|
13
|
+
*/
|
|
14
|
+
export type MyAccountProfileData = {
|
|
15
|
+
id?: string | null;
|
|
16
|
+
firstName?: string | null;
|
|
17
|
+
lastName?: string | null;
|
|
18
|
+
email?: string | null;
|
|
19
|
+
homePhone?: string | null;
|
|
20
|
+
mobilePhone?: string | null;
|
|
21
|
+
document?: string | null;
|
|
22
|
+
documentType?: string | null;
|
|
23
|
+
birthDate?: string | null;
|
|
24
|
+
gender?: string | null;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* The shopper-editable keys. `email` is absent (login identifier) and `documentType` is absent
|
|
28
|
+
* (read for the tax-ID control's active type; not writable in V0).
|
|
29
|
+
*/
|
|
30
|
+
export type MyAccountProfileFieldKey = 'firstName' | 'lastName' | 'homePhone' | 'mobilePhone' | 'document' | 'birthDate' | 'gender';
|
|
31
|
+
export type MyAccountProfileMode = 'view' | 'edit';
|
|
32
|
+
/** Every editable key, always a string — a `null` upstream value is seeded as `''`. */
|
|
33
|
+
export type MyAccountProfileValues = Readonly<Record<MyAccountProfileFieldKey, string>>;
|
|
34
|
+
/**
|
|
35
|
+
* What a Control hands the Root. `validate` returns a message when the value is unacceptable and
|
|
36
|
+
* `null` when it is fine — requiredness is expressed as a validator that rejects `''`. `normalize`
|
|
37
|
+
* is applied on Save, to dirty values only.
|
|
38
|
+
*/
|
|
39
|
+
export type MyAccountProfileFieldRegistration = Readonly<{
|
|
40
|
+
key: MyAccountProfileFieldKey;
|
|
41
|
+
validate?: (value: string) => string | null;
|
|
42
|
+
normalize?: (value: string) => string;
|
|
43
|
+
}>;
|
|
44
|
+
export type MyAccountProfileFieldErrors = Readonly<Partial<Record<MyAccountProfileFieldKey, string>>>;
|
|
45
|
+
export type MyAccountProfileContextValue = Readonly<{
|
|
46
|
+
mode: MyAccountProfileMode;
|
|
47
|
+
savedValues: MyAccountProfileValues;
|
|
48
|
+
draft: MyAccountProfileValues;
|
|
49
|
+
fieldErrors: MyAccountProfileFieldErrors;
|
|
50
|
+
email: string;
|
|
51
|
+
activeDocumentType: string | undefined;
|
|
52
|
+
pending: boolean;
|
|
53
|
+
registerField: (registration: MyAccountProfileFieldRegistration) => () => void;
|
|
54
|
+
setField: (key: MyAccountProfileFieldKey, value: string) => void;
|
|
55
|
+
edit: () => void;
|
|
56
|
+
cancel: () => void;
|
|
57
|
+
}>;
|
|
58
|
+
export type MyAccountProfileRootProps = Readonly<{
|
|
59
|
+
/** Store-configured tax-ID type fallback, used when the saved `documentType` is not registered. */
|
|
60
|
+
documentType?: string;
|
|
61
|
+
saveFailedMessage?: string;
|
|
62
|
+
savedMessage?: string;
|
|
63
|
+
className?: string;
|
|
64
|
+
children?: ReactNode;
|
|
65
|
+
$data?: MyAccountProfileData;
|
|
66
|
+
/** Compiler-injected action surface; carries `identity.customerProfileUpdate`. */
|
|
67
|
+
$actions?: ComponentActions;
|
|
68
|
+
}>;
|
|
69
|
+
export type MyAccountProfileEditButtonProps = Readonly<{
|
|
70
|
+
label?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
children?: ReactNode;
|
|
73
|
+
}>;
|
|
74
|
+
export type MyAccountProfileSaveButtonProps = Readonly<{
|
|
75
|
+
label?: string;
|
|
76
|
+
className?: string;
|
|
77
|
+
children?: ReactNode;
|
|
78
|
+
}>;
|
|
79
|
+
export type MyAccountProfileCancelButtonProps = Readonly<{
|
|
80
|
+
label?: string;
|
|
81
|
+
className?: string;
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
}>;
|
|
84
|
+
export type MyAccountProfileEmailProps = Readonly<{
|
|
85
|
+
className?: string;
|
|
86
|
+
}>;
|
|
87
|
+
/** Throws when used outside `MyAccountProfileRoot`, per ADR-0009. */
|
|
88
|
+
export declare function useMyAccountProfile(): MyAccountProfileContextValue;
|
|
89
|
+
export declare const MyAccountProfileRootDefinition: ComponentDefinition<Readonly<{
|
|
90
|
+
/** Store-configured tax-ID type fallback, used when the saved `documentType` is not registered. */
|
|
91
|
+
documentType?: string;
|
|
92
|
+
saveFailedMessage?: string;
|
|
93
|
+
savedMessage?: string;
|
|
94
|
+
className?: string;
|
|
95
|
+
children?: ReactNode;
|
|
96
|
+
$data?: MyAccountProfileData;
|
|
97
|
+
/** Compiler-injected action surface; carries `identity.customerProfileUpdate`. */
|
|
98
|
+
$actions?: ComponentActions;
|
|
99
|
+
}>>;
|
|
100
|
+
export declare function MyAccountProfileRoot({ $data: $dataProp, $actions: $actionsProp, documentType: documentTypeProp, saveFailedMessage, savedMessage, className, children }: MyAccountProfileRootProps): import("react/jsx-runtime").JSX.Element | null;
|
|
101
|
+
export declare namespace MyAccountProfileRoot {
|
|
102
|
+
var Skeleton: typeof MyAccountProfileSkeleton;
|
|
103
|
+
}
|
|
104
|
+
export declare const MyAccountProfileEditButtonDefinition: ComponentDefinition<Readonly<{
|
|
105
|
+
label?: string;
|
|
106
|
+
className?: string;
|
|
107
|
+
children?: ReactNode;
|
|
108
|
+
}>>;
|
|
109
|
+
export declare function MyAccountProfileEditButton({ label, className, children }: MyAccountProfileEditButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
110
|
+
export declare const MyAccountProfileSaveButtonDefinition: ComponentDefinition<Readonly<{
|
|
111
|
+
label?: string;
|
|
112
|
+
className?: string;
|
|
113
|
+
children?: ReactNode;
|
|
114
|
+
}>>;
|
|
115
|
+
export declare function MyAccountProfileSaveButton({ label, className, children }: MyAccountProfileSaveButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
116
|
+
export declare const MyAccountProfileCancelButtonDefinition: ComponentDefinition<Readonly<{
|
|
117
|
+
label?: string;
|
|
118
|
+
className?: string;
|
|
119
|
+
children?: ReactNode;
|
|
120
|
+
}>>;
|
|
121
|
+
export declare function MyAccountProfileCancelButton({ label, className, children }: MyAccountProfileCancelButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
122
|
+
export declare const MyAccountProfileEmailDefinition: ComponentDefinition<Readonly<{
|
|
123
|
+
className?: string;
|
|
124
|
+
}>>;
|
|
125
|
+
export declare function MyAccountProfileEmail({ className }: MyAccountProfileEmailProps): import("react/jsx-runtime").JSX.Element | null;
|
|
126
|
+
export declare const MyAccountProfileSkeletonDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
127
|
+
export declare function MyAccountProfileSkeleton({ className, ...props }: ComponentPropsWithRef<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
128
|
+
export type MyAccountProfileFirstNameControlProps = Readonly<{
|
|
129
|
+
label?: string;
|
|
130
|
+
requiredMessage?: string;
|
|
131
|
+
className?: string;
|
|
132
|
+
}>;
|
|
133
|
+
export declare const MyAccountProfileFirstNameControlDefinition: ComponentDefinition<Readonly<{
|
|
134
|
+
label?: string;
|
|
135
|
+
requiredMessage?: string;
|
|
136
|
+
className?: string;
|
|
137
|
+
}>>;
|
|
138
|
+
export declare function MyAccountProfileFirstNameControl({ label, requiredMessage, className }: MyAccountProfileFirstNameControlProps): import("react/jsx-runtime").JSX.Element;
|
|
139
|
+
export type MyAccountProfileLastNameControlProps = Readonly<{
|
|
140
|
+
label?: string;
|
|
141
|
+
requiredMessage?: string;
|
|
142
|
+
className?: string;
|
|
143
|
+
}>;
|
|
144
|
+
export declare const MyAccountProfileLastNameControlDefinition: ComponentDefinition<Readonly<{
|
|
145
|
+
label?: string;
|
|
146
|
+
requiredMessage?: string;
|
|
147
|
+
className?: string;
|
|
148
|
+
}>>;
|
|
149
|
+
export declare function MyAccountProfileLastNameControl({ label, requiredMessage, className }: MyAccountProfileLastNameControlProps): import("react/jsx-runtime").JSX.Element;
|
|
150
|
+
export type MyAccountProfilePhoneControlProps = Readonly<{
|
|
151
|
+
label?: string;
|
|
152
|
+
/** Which draft key this instance binds. Compose the Control twice to expose both numbers. */
|
|
153
|
+
field?: 'homePhone' | 'mobilePhone';
|
|
154
|
+
country?: PhoneCountry;
|
|
155
|
+
invalidMessage?: string;
|
|
156
|
+
className?: string;
|
|
157
|
+
}>;
|
|
158
|
+
export declare const MyAccountProfilePhoneControlDefinition: ComponentDefinition<Readonly<{
|
|
159
|
+
label?: string;
|
|
160
|
+
/** Which draft key this instance binds. Compose the Control twice to expose both numbers. */
|
|
161
|
+
field?: "homePhone" | "mobilePhone";
|
|
162
|
+
country?: PhoneCountry;
|
|
163
|
+
invalidMessage?: string;
|
|
164
|
+
className?: string;
|
|
165
|
+
}>>;
|
|
166
|
+
export declare function MyAccountProfilePhoneControl({ label, field, country, invalidMessage, className }: MyAccountProfilePhoneControlProps): import("react/jsx-runtime").JSX.Element;
|
|
167
|
+
export type MyAccountProfileTaxIdControlProps = Readonly<{
|
|
168
|
+
label?: string;
|
|
169
|
+
invalidMessage?: string;
|
|
170
|
+
/** Inline reason shown beside the locked saved CPF. */
|
|
171
|
+
lockedReason?: string;
|
|
172
|
+
className?: string;
|
|
173
|
+
}>;
|
|
174
|
+
export declare const MyAccountProfileTaxIdControlDefinition: ComponentDefinition<Readonly<{
|
|
175
|
+
label?: string;
|
|
176
|
+
invalidMessage?: string;
|
|
177
|
+
/** Inline reason shown beside the locked saved CPF. */
|
|
178
|
+
lockedReason?: string;
|
|
179
|
+
className?: string;
|
|
180
|
+
}>>;
|
|
181
|
+
export declare function MyAccountProfileTaxIdControl({ label, invalidMessage, lockedReason, className }: MyAccountProfileTaxIdControlProps): import("react/jsx-runtime").JSX.Element | null;
|
|
182
|
+
export type MyAccountProfileBirthDateControlProps = Readonly<{
|
|
183
|
+
label?: string;
|
|
184
|
+
className?: string;
|
|
185
|
+
}>;
|
|
186
|
+
export declare const MyAccountProfileBirthDateControlDefinition: ComponentDefinition<Readonly<{
|
|
187
|
+
label?: string;
|
|
188
|
+
className?: string;
|
|
189
|
+
}>>;
|
|
190
|
+
export declare function MyAccountProfileBirthDateControl({ label, className }: MyAccountProfileBirthDateControlProps): import("react/jsx-runtime").JSX.Element;
|
|
191
|
+
export type MyAccountProfileGenderOption = Readonly<{
|
|
192
|
+
value: string;
|
|
193
|
+
label: string;
|
|
194
|
+
}>;
|
|
195
|
+
export type MyAccountProfileGenderControlProps = Readonly<{
|
|
196
|
+
label?: string;
|
|
197
|
+
placeholder?: string;
|
|
198
|
+
clearLabel?: string;
|
|
199
|
+
options?: readonly MyAccountProfileGenderOption[];
|
|
200
|
+
className?: string;
|
|
201
|
+
}>;
|
|
202
|
+
export declare const MyAccountProfileGenderControlDefinition: ComponentDefinition<Readonly<{
|
|
203
|
+
label?: string;
|
|
204
|
+
placeholder?: string;
|
|
205
|
+
clearLabel?: string;
|
|
206
|
+
options?: readonly MyAccountProfileGenderOption[];
|
|
207
|
+
className?: string;
|
|
208
|
+
}>>;
|
|
209
|
+
export declare function MyAccountProfileGenderControl({ label, placeholder, clearLabel, options, className }: MyAccountProfileGenderControlProps): import("react/jsx-runtime").JSX.Element;
|
|
210
|
+
export declare const MyAccountProfile: {
|
|
211
|
+
Root: typeof MyAccountProfileRoot;
|
|
212
|
+
RootDefinition: ComponentDefinition<Readonly<{
|
|
213
|
+
/** Store-configured tax-ID type fallback, used when the saved `documentType` is not registered. */
|
|
214
|
+
documentType?: string;
|
|
215
|
+
saveFailedMessage?: string;
|
|
216
|
+
savedMessage?: string;
|
|
217
|
+
className?: string;
|
|
218
|
+
children?: ReactNode;
|
|
219
|
+
$data?: MyAccountProfileData;
|
|
220
|
+
/** Compiler-injected action surface; carries `identity.customerProfileUpdate`. */
|
|
221
|
+
$actions?: ComponentActions;
|
|
222
|
+
}>>;
|
|
223
|
+
EditButton: typeof MyAccountProfileEditButton;
|
|
224
|
+
EditButtonDefinition: ComponentDefinition<Readonly<{
|
|
225
|
+
label?: string;
|
|
226
|
+
className?: string;
|
|
227
|
+
children?: ReactNode;
|
|
228
|
+
}>>;
|
|
229
|
+
SaveButton: typeof MyAccountProfileSaveButton;
|
|
230
|
+
SaveButtonDefinition: ComponentDefinition<Readonly<{
|
|
231
|
+
label?: string;
|
|
232
|
+
className?: string;
|
|
233
|
+
children?: ReactNode;
|
|
234
|
+
}>>;
|
|
235
|
+
CancelButton: typeof MyAccountProfileCancelButton;
|
|
236
|
+
CancelButtonDefinition: ComponentDefinition<Readonly<{
|
|
237
|
+
label?: string;
|
|
238
|
+
className?: string;
|
|
239
|
+
children?: ReactNode;
|
|
240
|
+
}>>;
|
|
241
|
+
Email: typeof MyAccountProfileEmail;
|
|
242
|
+
EmailDefinition: ComponentDefinition<Readonly<{
|
|
243
|
+
className?: string;
|
|
244
|
+
}>>;
|
|
245
|
+
Skeleton: typeof MyAccountProfileSkeleton;
|
|
246
|
+
SkeletonDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
247
|
+
FirstNameControl: typeof MyAccountProfileFirstNameControl;
|
|
248
|
+
FirstNameControlDefinition: ComponentDefinition<Readonly<{
|
|
249
|
+
label?: string;
|
|
250
|
+
requiredMessage?: string;
|
|
251
|
+
className?: string;
|
|
252
|
+
}>>;
|
|
253
|
+
LastNameControl: typeof MyAccountProfileLastNameControl;
|
|
254
|
+
LastNameControlDefinition: ComponentDefinition<Readonly<{
|
|
255
|
+
label?: string;
|
|
256
|
+
requiredMessage?: string;
|
|
257
|
+
className?: string;
|
|
258
|
+
}>>;
|
|
259
|
+
PhoneControl: typeof MyAccountProfilePhoneControl;
|
|
260
|
+
PhoneControlDefinition: ComponentDefinition<Readonly<{
|
|
261
|
+
label?: string;
|
|
262
|
+
/** Which draft key this instance binds. Compose the Control twice to expose both numbers. */
|
|
263
|
+
field?: "homePhone" | "mobilePhone";
|
|
264
|
+
country?: PhoneCountry;
|
|
265
|
+
invalidMessage?: string;
|
|
266
|
+
className?: string;
|
|
267
|
+
}>>;
|
|
268
|
+
TaxIdControl: typeof MyAccountProfileTaxIdControl;
|
|
269
|
+
TaxIdControlDefinition: ComponentDefinition<Readonly<{
|
|
270
|
+
label?: string;
|
|
271
|
+
invalidMessage?: string;
|
|
272
|
+
/** Inline reason shown beside the locked saved CPF. */
|
|
273
|
+
lockedReason?: string;
|
|
274
|
+
className?: string;
|
|
275
|
+
}>>;
|
|
276
|
+
BirthDateControl: typeof MyAccountProfileBirthDateControl;
|
|
277
|
+
BirthDateControlDefinition: ComponentDefinition<Readonly<{
|
|
278
|
+
label?: string;
|
|
279
|
+
className?: string;
|
|
280
|
+
}>>;
|
|
281
|
+
GenderControl: typeof MyAccountProfileGenderControl;
|
|
282
|
+
GenderControlDefinition: ComponentDefinition<Readonly<{
|
|
283
|
+
label?: string;
|
|
284
|
+
placeholder?: string;
|
|
285
|
+
clearLabel?: string;
|
|
286
|
+
options?: readonly MyAccountProfileGenderOption[];
|
|
287
|
+
className?: string;
|
|
288
|
+
}>>;
|
|
289
|
+
};
|
|
290
|
+
//#endregion
|
|
291
|
+
//# sourceMappingURL=my-account-profile.d.ts.map
|