@vtex/faststore 0.0.1 → 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.
Files changed (94) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +4 -2
  3. package/dist/catalog.json +286 -265
  4. package/dist/components.d.ts +2 -1
  5. package/dist/components.js +2 -1
  6. package/dist/content-types.json +16 -0
  7. package/dist/core/dist/actions/registry.d.ts +1 -1
  8. package/dist/core/dist/actions/registry.js +1 -1
  9. package/dist/core/dist/actions/registry.js.map +1 -1
  10. package/dist/docs/account-entry-point.md +1 -1
  11. package/dist/docs/cart.md +2 -2
  12. package/dist/docs/session.md +12 -6
  13. package/dist/docs/sign-in-redirect.md +137 -0
  14. package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +2 -2
  15. package/dist/matter/access-code-sign-in/access-code-sign-in.js +5 -2
  16. package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
  17. package/dist/matter/account-entry-point/account-entry-point.js +4 -16
  18. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  19. package/dist/matter/buy-button/buy-button.d.ts +1 -1
  20. package/dist/matter/buy-button/buy-button.js +3 -1
  21. package/dist/matter/buy-button/buy-button.js.map +1 -1
  22. package/dist/matter/cart/cart.d.ts +6 -6
  23. package/dist/matter/cart/cart.js +13 -6
  24. package/dist/matter/cart/cart.js.map +1 -1
  25. package/dist/matter/cart-item/cart-item.d.ts +2 -2
  26. package/dist/matter/cart-item/cart-item.js +5 -2
  27. package/dist/matter/cart-item/cart-item.js.map +1 -1
  28. package/dist/matter/client-preferences/client-preferences.js +3 -1
  29. package/dist/matter/client-preferences/client-preferences.js.map +1 -1
  30. package/dist/matter/client-profile/client-profile.d.ts +1 -1
  31. package/dist/matter/client-profile/client-profile.js +3 -1
  32. package/dist/matter/client-profile/client-profile.js.map +1 -1
  33. package/dist/matter/client-profile-form/client-profile-form.d.ts +1 -1
  34. package/dist/matter/client-profile-form/client-profile-form.js +3 -1
  35. package/dist/matter/client-profile-form/client-profile-form.js.map +1 -1
  36. package/dist/matter/delivery-options/delivery-options-accordion.d.ts +1 -1
  37. package/dist/matter/delivery-options/delivery-options-accordion.js +3 -1
  38. package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
  39. package/dist/matter/delivery-options/delivery-options-controller.d.ts +1 -1
  40. package/dist/matter/delivery-options/delivery-options-controller.js +3 -1
  41. package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
  42. package/dist/matter/delivery-options/delivery-options.d.ts +1 -1
  43. package/dist/matter/delivery-options/delivery-options.js +3 -1
  44. package/dist/matter/delivery-options/delivery-options.js.map +1 -1
  45. package/dist/matter/email-identification/email-identification.d.ts +1 -1
  46. package/dist/matter/email-identification/email-identification.js +3 -1
  47. package/dist/matter/email-identification/email-identification.js.map +1 -1
  48. package/dist/matter/identity-summary/identity-summary.d.ts +1 -1
  49. package/dist/matter/identity-summary/identity-summary.js +3 -1
  50. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  51. package/dist/matter/product-list/product-list.d.ts +1 -1
  52. package/dist/matter/product-list/product-list.js +3 -1
  53. package/dist/matter/product-list/product-list.js.map +1 -1
  54. package/dist/matter/region/region.d.ts +1 -1
  55. package/dist/matter/region/region.js +5 -2
  56. package/dist/matter/region/region.js.map +1 -1
  57. package/dist/matter/session/session.js +1 -1
  58. package/dist/matter/session/session.js.map +1 -1
  59. package/dist/matter/shipping-address/shipping-address.d.ts +1 -1
  60. package/dist/matter/shipping-address/shipping-address.js +3 -1
  61. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  62. package/dist/matter/sign-in-form/sign-in-form.d.ts +1 -1
  63. package/dist/matter/sign-in-form/sign-in-form.js +3 -1
  64. package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
  65. package/dist/matter/sign-in-redirect/sign-in-redirect.d.ts +45 -0
  66. package/dist/matter/sign-in-redirect/sign-in-redirect.js +127 -0
  67. package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -0
  68. package/dist/sdk/actions/actions-override-context.js +37 -0
  69. package/dist/sdk/actions/actions-override-context.js.map +1 -0
  70. package/dist/sdk/actions/cart-action-provider.d.ts +8 -6
  71. package/dist/sdk/actions/cart-action-provider.js +10 -8
  72. package/dist/sdk/actions/cart-action-provider.js.map +1 -1
  73. package/dist/sdk/actions/identity-action-provider.d.ts +2 -2
  74. package/dist/sdk/actions/identity-action-provider.js +4 -4
  75. package/dist/sdk/actions/identity-action-provider.js.map +1 -1
  76. package/dist/sdk/actions/inject-actions.d.ts +1 -5
  77. package/dist/sdk/actions/inject-actions.js +23 -21
  78. package/dist/sdk/actions/inject-actions.js.map +1 -1
  79. package/dist/sdk/actions/region-action-provider.d.ts +4 -3
  80. package/dist/sdk/actions/region-action-provider.js +6 -5
  81. package/dist/sdk/actions/region-action-provider.js.map +1 -1
  82. package/dist/sdk/actions/session-action-provider.d.ts +4 -3
  83. package/dist/sdk/actions/session-action-provider.js +6 -5
  84. package/dist/sdk/actions/session-action-provider.js.map +1 -1
  85. package/dist/sdk/actions/shipping-action-provider.d.ts +4 -3
  86. package/dist/sdk/actions/shipping-action-provider.js +6 -5
  87. package/dist/sdk/actions/shipping-action-provider.js.map +1 -1
  88. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  89. package/dist/sdk/client/create-client.js +24 -2
  90. package/dist/sdk/client/create-client.js.map +1 -1
  91. package/dist/sdk/content/create-content-runtime.js +1 -1
  92. package/dist/utils/safe-href.js +107 -1
  93. package/dist/utils/safe-href.js.map +1 -1
  94. package/package.json +1 -1
@@ -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":";;;;;;;;AAoDA,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;EAAwB,UAAU;CAAW;CAC9D,QAAQ;EACN,OAAO;GAAE,MAAM;GAAU,OAAO;EAAQ;EACxC,aAAa;GAAE,MAAM;GAAU,OAAO;EAAc;EACpD,qBAAqB;GAAE,MAAM;GAAU,OAAO;EAAwB;CACxE;CACA,WACE;AACJ,CAAC;;;;;;;;;;;;;AAkBD,SAAgB,2BAA2B,EACzC,OACA,aACA,qBACA,OAAO,WACP,UACA,WACA,GAAG,SAC+B;CAClC,MAAM,QAAQ,gBAAgB,SAAS;CAEvC,MAAM,EAAE,gBAAgB,WAAW;CAGnC,MAAM,WAAW,CAAC;CAElB,MAAM,aAAa,OAAO,SAAS;CACnC,MAAM,CAAC,OAAO,YAAY,SAAS,UAAU;CAC7C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,aAAa,kBAAkB,SAAwB,IAAI;CAIlE,gBAAgB;EACd,SAAS,UAAU;CACrB,GAAG,CAAC,UAAU,CAAC;CAEf,SAAS,kBAAkB,MAAc;EACvC,SAAS,IAAI;EACb,IAAI,aAAa,eAAe,IAAI;CACtC;CAEA,eAAe,aAAa;EAC1B,MAAM,UAAU,MAAM,KAAK;EAG3B,IAAI,YAAY,MAAM,eAAe,IAAI;GACvC,SAAS,UAAU;GACnB;EACF;EAEA,IAAI,CAAC,aAAa,OAAO,GAAG;EAE5B,IAAI,YAAY,YAAY;EAE5B,WAAW,IAAI;EACf,eAAe,IAAI;EACnB,IAAI;GACF,MAAM,SAAU,MAAM,UAAU,UAAU,sBAAsB,EAAE,OAAO,QAAQ,CAAC,KAAM,CAAC;GACzF,IAAI,OAAO,SAAS,GAAG,eAAe,OAAO,EAAE,EAAE,WAAW,IAAI;EAClE,UAAU;GACR,WAAW,KAAK;EAClB;CACF;CAEA,OACE,oBAAC,OAAD;EACE,GAAI;EACO;EACX,wCAAqC;EACrC,GAAK,UAAU,EAAE,wCAAwC,GAAG,IAAI,CAAC;EACjE,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"}
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;EAAwB,UAAU;CAAW;CAC9D,QAAQ;EACN,OAAO;GAAE,MAAM;GAAU,OAAO;EAAQ;EACxC,aAAa;GAAE,MAAM;GAAU,OAAO;EAAc;EACpD,qBAAqB;GAAE,MAAM;GAAU,OAAO;EAAwB;CACxE;CACA,WACE;AACJ,CAAC;;;;;;;;;;;;;AAkBD,SAAgB,2BAA2B,EACzC,OACA,aACA,qBACA,OAAO,WACP,UAAU,cACV,WACA,GAAG,SAC+B;CAClC,MAAM,QAAQ,gBAAgB,SAAS;CACvC,MAAM,WAAW,mBAAmB,YAAY;CAEhD,MAAM,EAAE,gBAAgB,WAAW;CAGnC,MAAM,WAAW,CAAC;CAElB,MAAM,aAAa,OAAO,SAAS;CACnC,MAAM,CAAC,OAAO,YAAY,SAAS,UAAU;CAC7C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,aAAa,kBAAkB,SAAwB,IAAI;CAIlE,gBAAgB;EACd,SAAS,UAAU;CACrB,GAAG,CAAC,UAAU,CAAC;CAEf,SAAS,kBAAkB,MAAc;EACvC,SAAS,IAAI;EACb,IAAI,aAAa,eAAe,IAAI;CACtC;CAEA,eAAe,aAAa;EAC1B,MAAM,UAAU,MAAM,KAAK;EAG3B,IAAI,YAAY,MAAM,eAAe,IAAI;GACvC,SAAS,UAAU;GACnB;EACF;EAEA,IAAI,CAAC,aAAa,OAAO,GAAG;EAE5B,IAAI,YAAY,YAAY;EAE5B,WAAW,IAAI;EACf,eAAe,IAAI;EACnB,IAAI;GACF,MAAM,SAAU,MAAM,UAAU,UAAU,sBAAsB,EAAE,OAAO,QAAQ,CAAC,KAAM,CAAC;GACzF,IAAI,OAAO,SAAS,GAAG,eAAe,OAAO,EAAE,EAAE,WAAW,IAAI;EAClE,UAAU;GACR,WAAW,KAAK;EAClB;CACF;CAEA,OACE,oBAAC,OAAD;EACE,GAAI;EACO;EACX,wCAAqC;EACrC,GAAK,UAAU,EAAE,wCAAwC,GAAG,IAAI,CAAC;EACjE,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;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AU,OAAO;CACtB,OACE,oBAAC,KAAD;EAAc;EAAW,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"}
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,2CAA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AAM,cAAc,YAAY,KAAA,MAAc,CAAC,MAAM,WAAW,GAAG,KAAK,MAAM,WAAW,eAAe,QAAQ;CAChH,OACE,oBAAC,KAAD;EAAc;EAAW,kCAA+B;EACrD,UAAA,eAAe,UAAU,eAAe,OAAO,OAAO,IAAI;CAC1D,CAAA;AAEP;;AAGA,SAAgB,wBAAwB,EAAE,aAAwC;CAChF,MAAM,EAAE,aAAa,0BAA0B;CAC/C,IAAI,CAAC,UAAU,OAAO;CACtB,OACE,oBAAC,KAAD;EAAc;EAAW,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"}
@@ -69,7 +69,7 @@ export declare function ProductCardPrice({ className, children, ...props }: Prod
69
69
  export declare function ProductCardListPrice({ className, children, ...props }: ProductCardListPriceProps): import("react/jsx-runtime").JSX.Element | null;
70
70
  export declare function ProductCardTaxLabel({ className, children, ...props }: ProductCardTaxLabelProps): import("react/jsx-runtime").JSX.Element | null;
71
71
  export declare function ProductCardDiscount({ className, children, format, ...props }: ProductCardDiscountProps): import("react/jsx-runtime").JSX.Element | null;
72
- export declare function ProductCardAddToCart({ className, children, onClick, $actions, ...props }: ProductCardAddToCartProps): import("react/jsx-runtime").JSX.Element;
72
+ export declare function ProductCardAddToCart({ className, children, onClick, $actions: $actionsProp, ...props }: ProductCardAddToCartProps): import("react/jsx-runtime").JSX.Element;
73
73
  export declare const ProductList: {
74
74
  Root: typeof ProductListRoot;
75
75
  Grid: typeof ProductListGrid;
@@ -2,6 +2,7 @@
2
2
  import { defineComponent } from "../../core/dist/define-component.js";
3
3
  import "../../core/dist/index.js";
4
4
  import { useStorefrontContext } from "../../sdk/context/storefront-context.js";
5
+ import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
5
6
  import { Button } from "../../particles/button/button.js";
6
7
  import { Image } from "../../particles/image/image.js";
7
8
  import { Badge } from "../../particles/badge/badge.js";
@@ -307,7 +308,8 @@ function ProductCardDiscount({ className, children, format = "percentage", ...pr
307
308
  children: children ?? label
308
309
  });
309
310
  }
310
- function ProductCardAddToCart({ className, children, onClick, $actions, ...props }) {
311
+ function ProductCardAddToCart({ className, children, onClick, $actions: $actionsProp, ...props }) {
312
+ const $actions = useActionsOverride($actionsProp);
311
313
  const item = useProductListItem();
312
314
  function handleClick(e) {
313
315
  $actions?.cart?.addItem?.({
@@ -1 +1 @@
1
- {"version":3,"file":"product-list.js","names":[],"sources":["../../../src/matter/product-list/product-list.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport { Badge } from '../../particles/badge/badge.js';\nimport { Button } from '../../particles/button/button.js';\nimport { Container } from '../../particles/container/container.js';\nimport { Image } from '../../particles/image/image.js';\nimport { Text } from '../../particles/text/text.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\n\n// ---------------------------------------------------------------------------\n// Product list config context (tax display)\n// ---------------------------------------------------------------------------\n\ntype ProductListConfig = {\n usePriceWithTaxes: boolean;\n taxesLabel: string;\n};\n\nexport const ProductListConfigContext = createContext<ProductListConfig>({\n usePriceWithTaxes: false,\n taxesLabel: 'Tax included',\n});\n\nfunction useProductListConfig(): ProductListConfig {\n return useContext(ProductListConfigContext);\n}\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Tax rate for the item: the explicit `taxPercentage` (e.g. 0.18) wins; otherwise it is derived\n// from the absolute tax amount over the price. Missing/zero-price data yields 0 (no change).\nfunction taxRate(item: ProductListItem): number {\n if (item.taxPercentage != null) {\n return item.taxPercentage;\n }\n if (item.tax != null && item.price > 0) {\n return item.tax / item.price;\n }\n return 0;\n}\n\nfunction priceWithTaxes(base: number, item: ProductListItem): number {\n return base * (1 + taxRate(item));\n}\n\n// ---------------------------------------------------------------------------\n// Product list item types\n// ---------------------------------------------------------------------------\n\nexport type ProductListItemImage = {\n src: string;\n alt: string;\n};\n\nexport type ProductListItem = {\n id: string;\n name: string;\n image: ProductListItemImage;\n price: number;\n listPrice?: number;\n variant?: string;\n slug?: string;\n // Widened for the Product Shelf (T2): fields the card parts T3–T7 read straight off the\n // per-item context. Optional so the plain-`products` ProductListRoot (PLP) stays valid.\n spotPrice?: number;\n tax?: number;\n taxPercentage?: number | null;\n availableForSale?: boolean;\n availableQuantity?: number;\n currency?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Products context (provided by Root, consumed by Grid)\n// ---------------------------------------------------------------------------\n\nconst ProductListProductsContext = createContext<ProductListItem[]>([]);\n\n// ---------------------------------------------------------------------------\n// Item context (provided by Grid per product)\n// ---------------------------------------------------------------------------\n\nexport const ProductListItemContext = createContext<ProductListItem | null>(null);\n\nfunction useProductListItem(): ProductListItem {\n const item = useContext(ProductListItemContext);\n if (!item) {\n throw new Error('ProductCard components must be used inside ProductListGrid.');\n }\n return item;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type ProductListRootProps = ComponentPropsWithRef<'div'> & {\n products?: ProductListItem[];\n /** When true, card prices render tax-inclusive (from the item's tax data). Default false. */\n usePriceWithTaxes?: boolean;\n /** Text for the tax label part when tax display is on. Default `'Tax included'`. */\n taxesLabel?: string;\n};\n\nexport type ProductListGridProps = ComponentPropsWithRef<'div'>;\n\nexport type ProductCardProps = ComponentPropsWithRef<'div'> & {\n /** Toggles the card border. Reflects onto data-fs-product-card-bordered; a swatch draws the border. Default true. */\n bordered?: boolean;\n};\n\nexport type ProductCardImageProps = ComponentPropsWithRef<'img'> & {\n objectFit?: 'contain' | 'cover' | 'fill' | 'none';\n /** CSS `aspect-ratio` (e.g. `'1/1'`, `'3/4'`, `'16/9'`); lays out the image box, orthogonal to `objectFit`. */\n aspectRatio?: string;\n};\n\nexport type ProductCardNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardListPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardTaxLabelProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardDiscountProps = ComponentPropsWithRef<'span'> & {\n format?: 'percentage' | 'absolute';\n};\n\nexport type ProductCardAddToCartProps = ComponentPropsWithRef<'button'> & {\n /** Injected by the compiler from `actions: { cart: ['addItem'] }`; the cart write surface. */\n $actions?: ComponentActions;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ProductListRootDefinition = defineComponent<ProductListRootProps>({\n name: 'ProductListRoot',\n importPath: '@vtex/faststore/components',\n component: ProductListRoot,\n editor: { label: 'Product List Root', category: 'commerce' },\n schema: {\n usePriceWithTaxes: { type: 'boolean', default: false, label: 'Use Price With Taxes' },\n taxesLabel: { type: 'string', default: 'Tax included', label: 'Taxes Label' },\n },\n guideline:\n 'Top-level wrapper for the product list; compose as ProductListRoot > ProductListGrid > ProductCard* children. Set usePriceWithTaxes to render tax-inclusive card prices and compose ProductCardTaxLabel to show the taxesLabel.',\n});\n\nexport const ProductListGridDefinition = defineComponent<ProductListGridProps>({\n name: 'ProductListGrid',\n importPath: '@vtex/faststore/components',\n component: ProductListGrid,\n editor: { label: 'Product List Grid', category: 'commerce' },\n schema: {},\n guideline:\n 'Repeating grid that renders the ProductCard* template for each product; must be a direct child of ProductListRoot.',\n});\n\nexport const ProductCardDefinition = defineComponent<ProductCardProps>({\n name: 'ProductCard',\n importPath: '@vtex/faststore/components',\n component: ProductCard,\n editor: { label: 'Product Card', category: 'commerce' },\n schema: {\n bordered: { type: 'boolean', default: true, label: 'Bordered' },\n },\n guideline:\n 'Optional card wrapper for the ProductCard* parts; always emits data-fs-product-card and data-fs-product-card-bordered (true/false, from the bordered toggle), and adds data-fs-product-card-out-of-stock when the product is unavailable (derived from availability, no prop). The border look is a swatch keyed off data-fs-product-card-bordered. Renders all children unchanged. Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardImageDefinition = defineComponent<ProductCardImageProps>({\n name: 'ProductCardImage',\n importPath: '@vtex/faststore/components',\n component: ProductCardImage,\n editor: { label: 'Product Card Image', category: 'commerce' },\n schema: {\n objectFit: { type: ['contain', 'cover', 'fill', 'none'] as const, default: 'cover', label: 'Object Fit' },\n aspectRatio: { type: 'string', label: 'Aspect Ratio' },\n },\n guideline:\n 'Renders the product image with a configurable aspectRatio (e.g. 1/1, 3/4, 16/9) and objectFit. Alt text comes from the catalog. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardNameDefinition = defineComponent<ProductCardNameProps>({\n name: 'ProductCardName',\n importPath: '@vtex/faststore/components',\n component: ProductCardName,\n editor: { label: 'Product Card Name', category: 'commerce' },\n schema: {},\n guideline: 'Renders the product name. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardPriceDefinition = defineComponent<ProductCardPriceProps>({\n name: 'ProductCardPrice',\n importPath: '@vtex/faststore/components',\n component: ProductCardPrice,\n editor: { label: 'Product Card Price', category: 'commerce' },\n schema: {},\n guideline:\n 'Displays the selling price formatted from the active storefront context; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardListPriceDefinition = defineComponent<ProductCardListPriceProps>({\n name: 'ProductCardListPrice',\n importPath: '@vtex/faststore/components',\n component: ProductCardListPrice,\n editor: { label: 'Product Card List Price', category: 'commerce' },\n schema: {},\n guideline:\n 'Displays the original (strikethrough) list price when it exceeds the selling price; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardTaxLabelDefinition = defineComponent<ProductCardTaxLabelProps>({\n name: 'ProductCardTaxLabel',\n importPath: '@vtex/faststore/components',\n component: ProductCardTaxLabel,\n editor: { label: 'Product Card Tax Label', category: 'commerce' },\n schema: {},\n guideline:\n 'Tax label (e.g. \"Tax included\") shown beside the price. Renders only when the ProductListRoot/ProductShelfRoot config usePriceWithTaxes is enabled (state-driven, no toggle); the text comes from the taxesLabel config. Compose it to place the label, omit it to hide it. Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardDiscountDefinition = defineComponent<ProductCardDiscountProps>({\n name: 'ProductCardDiscount',\n importPath: '@vtex/faststore/components',\n component: ProductCardDiscount,\n editor: { label: 'Product Card Discount', category: 'commerce' },\n schema: {\n format: { type: ['percentage', 'absolute'] as const, default: 'percentage', label: 'Discount Format' },\n },\n guideline:\n 'Discount badge for the current product; auto-computes the markdown from listPrice vs price and renders only when a discount exists. Compose it to show the badge, omit it to hide it (no toggle). Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardAddToCartDefinition = defineComponent<ProductCardAddToCartProps>({\n name: 'ProductCardAddToCart',\n importPath: '@vtex/faststore/components',\n component: ProductCardAddToCart,\n editor: { label: 'Product Card Add to Cart', category: 'commerce' },\n schema: {},\n actions: { cart: ['addItem'] },\n guideline: 'Add-to-cart button for the current product card; must be inside ProductListGrid.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ProductListRoot({\n usePriceWithTaxes = false,\n taxesLabel = 'Tax included',\n products = [],\n className,\n children,\n ...props\n}: ProductListRootProps) {\n const config = useMemo(() => ({ usePriceWithTaxes, taxesLabel }), [usePriceWithTaxes, taxesLabel]);\n\n return (\n <ProductListConfigContext value={config}>\n <ProductListProductsContext value={products}>\n <Container {...props} className={className} data-fs-product-list-root=\"\">\n {children}\n </Container>\n </ProductListProductsContext>\n </ProductListConfigContext>\n );\n}\n\nexport function ProductListGrid({ className, children, ...props }: ProductListGridProps) {\n const products = useContext(ProductListProductsContext);\n\n return (\n <Container {...props} className={className} data-fs-product-list-grid=\"\">\n {products.map((product) => (\n <ProductListItemContext key={product.id} value={product}>\n {children}\n </ProductListItemContext>\n ))}\n </Container>\n );\n}\n\nexport function ProductCard({ className, children, bordered = true, ...props }: ProductCardProps) {\n const item = useProductListItem();\n const outOfStock = item.availableForSale === false || item.availableQuantity === 0;\n\n return (\n <Container\n {...props}\n className={className}\n data-fs-product-card=\"\"\n data-fs-product-card-bordered={String(bordered)}\n data-fs-product-card-out-of-stock={outOfStock ? '' : undefined}\n >\n {children}\n </Container>\n );\n}\n\nexport function ProductCardImage({ className, objectFit = 'cover', aspectRatio, ...props }: ProductCardImageProps) {\n const item = useProductListItem();\n\n return (\n <Image\n {...props}\n src={item.image.src}\n alt={item.image.alt}\n aspectRatio={aspectRatio}\n className={className}\n style={{ objectFit, ...props.style }}\n data-fs-product-card-image=\"\"\n />\n );\n}\n\nexport function ProductCardName({ className, children, ...props }: ProductCardNameProps) {\n const item = useProductListItem();\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-name=\"\">\n {children ?? item.name}\n </Text>\n );\n}\n\nexport function ProductCardPrice({ className, children, ...props }: ProductCardPriceProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n const value = usePriceWithTaxes ? priceWithTaxes(item.price, item) : item.price;\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-price=\"\">\n {children ?? formatPrice(value, locale, item.currency ?? currency)}\n </Text>\n );\n}\n\nexport function ProductCardListPrice({ className, children, ...props }: ProductCardListPriceProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n\n if (!item.listPrice || item.listPrice <= item.price) {\n return null;\n }\n\n const value = usePriceWithTaxes ? priceWithTaxes(item.listPrice, item) : item.listPrice;\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-list-price=\"\">\n {children ?? formatPrice(value, locale, item.currency ?? currency)}\n </Text>\n );\n}\n\nexport function ProductCardTaxLabel({ className, children, ...props }: ProductCardTaxLabelProps) {\n const { usePriceWithTaxes, taxesLabel } = useProductListConfig();\n\n if (!usePriceWithTaxes) {\n return null;\n }\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-tax-label=\"\">\n {children ?? taxesLabel}\n </Text>\n );\n}\n\nexport function ProductCardDiscount({\n className,\n children,\n format = 'percentage',\n ...props\n}: ProductCardDiscountProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n\n const { listPrice, price } = item;\n if (!listPrice || listPrice <= price) {\n return null;\n }\n\n const amountOff = listPrice - price;\n const percentOff = Math.round((amountOff / listPrice) * 100);\n const tier = percentOff >= 30 ? 'high' : percentOff >= 15 ? 'medium' : 'low';\n // The percentage is tax-invariant (both prices scale by the same factor), but the absolute amount\n // must match the displayed prices, which are tax-inclusive when usePriceWithTaxes is enabled.\n const displayedAmountOff = usePriceWithTaxes ? priceWithTaxes(amountOff, item) : amountOff;\n const label =\n format === 'absolute'\n ? `-${formatPrice(displayedAmountOff, locale, item.currency ?? currency)}`\n : `-${percentOff}%`;\n\n return (\n <Badge {...props} className={className} data-fs-product-card-discount=\"\" data-fs-product-card-discount-tier={tier}>\n {children ?? label}\n </Badge>\n );\n}\n\nexport function ProductCardAddToCart({ className, children, onClick, $actions, ...props }: ProductCardAddToCartProps) {\n const item = useProductListItem();\n\n function handleClick(e: React.MouseEvent<HTMLButtonElement>) {\n void $actions?.cart?.addItem?.({ variantId: item.id, seller: '1' });\n onClick?.(e);\n }\n\n return (\n <Button {...props} className={className} onClick={handleClick} data-fs-product-card-add-to-cart=\"\">\n {children}\n </Button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ProductList = {\n Root: ProductListRoot,\n Grid: ProductListGrid,\n Card: ProductCard,\n CardImage: ProductCardImage,\n CardName: ProductCardName,\n CardPrice: ProductCardPrice,\n CardListPrice: ProductCardListPrice,\n CardTaxLabel: ProductCardTaxLabel,\n CardDiscount: ProductCardDiscount,\n CardAddToCart: ProductCardAddToCart,\n};\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,2BAA2B,cAAiC;CACvE,mBAAmB;CACnB,YAAY;AACd,CAAC;AAED,SAAS,uBAA0C;CACjD,OAAO,WAAW,wBAAwB;AAC5C;AAEA,SAAS,YAAY,OAAe,QAAgB,UAA0B;CAC5E,OAAO,IAAI,KAAK,aAAa,QAAQ;EAAE,OAAO;EAAY;CAAS,CAAC,CAAC,CAAC,OAAO,KAAK;AACpF;AAIA,SAAS,QAAQ,MAA+B;CAC9C,IAAI,KAAK,iBAAiB,MACxB,OAAO,KAAK;CAEd,IAAI,KAAK,OAAO,QAAQ,KAAK,QAAQ,GACnC,OAAO,KAAK,MAAM,KAAK;CAEzB,OAAO;AACT;AAEA,SAAS,eAAe,MAAc,MAA+B;CACnE,OAAO,QAAQ,IAAI,QAAQ,IAAI;AACjC;AAiCA,MAAM,6BAA6B,cAAiC,CAAC,CAAC;AAMtE,MAAa,yBAAyB,cAAsC,IAAI;AAEhF,SAAS,qBAAsC;CAC7C,MAAM,OAAO,WA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AoC;EAC1G,UAAA,YAAY;CACR,CAAA;AAEX;AAEA,SAAgB,qBAAqB,EAAE,WAAW,UAAU,SAAS,UAAU,GAAG,SAAoC;CACpH,MAAM,OAAO,mBAAmB;CAEhC,SAAS,YAAY,GAAwC;EAC3D,UAAe,MAAM,UAAU;GAAE,WAAW,KAAK;GAAI,QAAQ;EAAI,CAAC;EAClE,UAAU,CAAC;CACb;CAEA,OACE,oBAAC,QAAD;EAAQ,GAAI;EAAkB;EAAW,SAAS;EAAa,oCAAiC;EAC7F;CACK,CAAA;AAEZ;AAMA,MAAa,cAAc;CACzB,MAAM;CACN,MAAM;CACN,MAAM;CACN,WAAW;CACX,UAAU;CACV,WAAW;CACX,eAAe;CACf,cAAc;CACd,cAAc;CACd,eAAe;AACjB"}
1
+ {"version":3,"file":"product-list.js","names":[],"sources":["../../../src/matter/product-list/product-list.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport { Badge } from '../../particles/badge/badge.js';\nimport { Button } from '../../particles/button/button.js';\nimport { Container } from '../../particles/container/container.js';\nimport { Image } from '../../particles/image/image.js';\nimport { Text } from '../../particles/text/text.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\n\n// ---------------------------------------------------------------------------\n// Product list config context (tax display)\n// ---------------------------------------------------------------------------\n\ntype ProductListConfig = {\n usePriceWithTaxes: boolean;\n taxesLabel: string;\n};\n\nexport const ProductListConfigContext = createContext<ProductListConfig>({\n usePriceWithTaxes: false,\n taxesLabel: 'Tax included',\n});\n\nfunction useProductListConfig(): ProductListConfig {\n return useContext(ProductListConfigContext);\n}\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Tax rate for the item: the explicit `taxPercentage` (e.g. 0.18) wins; otherwise it is derived\n// from the absolute tax amount over the price. Missing/zero-price data yields 0 (no change).\nfunction taxRate(item: ProductListItem): number {\n if (item.taxPercentage != null) {\n return item.taxPercentage;\n }\n if (item.tax != null && item.price > 0) {\n return item.tax / item.price;\n }\n return 0;\n}\n\nfunction priceWithTaxes(base: number, item: ProductListItem): number {\n return base * (1 + taxRate(item));\n}\n\n// ---------------------------------------------------------------------------\n// Product list item types\n// ---------------------------------------------------------------------------\n\nexport type ProductListItemImage = {\n src: string;\n alt: string;\n};\n\nexport type ProductListItem = {\n id: string;\n name: string;\n image: ProductListItemImage;\n price: number;\n listPrice?: number;\n variant?: string;\n slug?: string;\n // Widened for the Product Shelf (T2): fields the card parts T3–T7 read straight off the\n // per-item context. Optional so the plain-`products` ProductListRoot (PLP) stays valid.\n spotPrice?: number;\n tax?: number;\n taxPercentage?: number | null;\n availableForSale?: boolean;\n availableQuantity?: number;\n currency?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Products context (provided by Root, consumed by Grid)\n// ---------------------------------------------------------------------------\n\nconst ProductListProductsContext = createContext<ProductListItem[]>([]);\n\n// ---------------------------------------------------------------------------\n// Item context (provided by Grid per product)\n// ---------------------------------------------------------------------------\n\nexport const ProductListItemContext = createContext<ProductListItem | null>(null);\n\nfunction useProductListItem(): ProductListItem {\n const item = useContext(ProductListItemContext);\n if (!item) {\n throw new Error('ProductCard components must be used inside ProductListGrid.');\n }\n return item;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type ProductListRootProps = ComponentPropsWithRef<'div'> & {\n products?: ProductListItem[];\n /** When true, card prices render tax-inclusive (from the item's tax data). Default false. */\n usePriceWithTaxes?: boolean;\n /** Text for the tax label part when tax display is on. Default `'Tax included'`. */\n taxesLabel?: string;\n};\n\nexport type ProductListGridProps = ComponentPropsWithRef<'div'>;\n\nexport type ProductCardProps = ComponentPropsWithRef<'div'> & {\n /** Toggles the card border. Reflects onto data-fs-product-card-bordered; a swatch draws the border. Default true. */\n bordered?: boolean;\n};\n\nexport type ProductCardImageProps = ComponentPropsWithRef<'img'> & {\n objectFit?: 'contain' | 'cover' | 'fill' | 'none';\n /** CSS `aspect-ratio` (e.g. `'1/1'`, `'3/4'`, `'16/9'`); lays out the image box, orthogonal to `objectFit`. */\n aspectRatio?: string;\n};\n\nexport type ProductCardNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardListPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardTaxLabelProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardDiscountProps = ComponentPropsWithRef<'span'> & {\n format?: 'percentage' | 'absolute';\n};\n\nexport type ProductCardAddToCartProps = ComponentPropsWithRef<'button'> & {\n /** Injected by the compiler from `actions: { cart: ['addItem'] }`; the cart write surface. */\n $actions?: ComponentActions;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ProductListRootDefinition = defineComponent<ProductListRootProps>({\n name: 'ProductListRoot',\n importPath: '@vtex/faststore/components',\n component: ProductListRoot,\n editor: { label: 'Product List Root', category: 'commerce' },\n schema: {\n usePriceWithTaxes: { type: 'boolean', default: false, label: 'Use Price With Taxes' },\n taxesLabel: { type: 'string', default: 'Tax included', label: 'Taxes Label' },\n },\n guideline:\n 'Top-level wrapper for the product list; compose as ProductListRoot > ProductListGrid > ProductCard* children. Set usePriceWithTaxes to render tax-inclusive card prices and compose ProductCardTaxLabel to show the taxesLabel.',\n});\n\nexport const ProductListGridDefinition = defineComponent<ProductListGridProps>({\n name: 'ProductListGrid',\n importPath: '@vtex/faststore/components',\n component: ProductListGrid,\n editor: { label: 'Product List Grid', category: 'commerce' },\n schema: {},\n guideline:\n 'Repeating grid that renders the ProductCard* template for each product; must be a direct child of ProductListRoot.',\n});\n\nexport const ProductCardDefinition = defineComponent<ProductCardProps>({\n name: 'ProductCard',\n importPath: '@vtex/faststore/components',\n component: ProductCard,\n editor: { label: 'Product Card', category: 'commerce' },\n schema: {\n bordered: { type: 'boolean', default: true, label: 'Bordered' },\n },\n guideline:\n 'Optional card wrapper for the ProductCard* parts; always emits data-fs-product-card and data-fs-product-card-bordered (true/false, from the bordered toggle), and adds data-fs-product-card-out-of-stock when the product is unavailable (derived from availability, no prop). The border look is a swatch keyed off data-fs-product-card-bordered. Renders all children unchanged. Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardImageDefinition = defineComponent<ProductCardImageProps>({\n name: 'ProductCardImage',\n importPath: '@vtex/faststore/components',\n component: ProductCardImage,\n editor: { label: 'Product Card Image', category: 'commerce' },\n schema: {\n objectFit: { type: ['contain', 'cover', 'fill', 'none'] as const, default: 'cover', label: 'Object Fit' },\n aspectRatio: { type: 'string', label: 'Aspect Ratio' },\n },\n guideline:\n 'Renders the product image with a configurable aspectRatio (e.g. 1/1, 3/4, 16/9) and objectFit. Alt text comes from the catalog. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardNameDefinition = defineComponent<ProductCardNameProps>({\n name: 'ProductCardName',\n importPath: '@vtex/faststore/components',\n component: ProductCardName,\n editor: { label: 'Product Card Name', category: 'commerce' },\n schema: {},\n guideline: 'Renders the product name. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardPriceDefinition = defineComponent<ProductCardPriceProps>({\n name: 'ProductCardPrice',\n importPath: '@vtex/faststore/components',\n component: ProductCardPrice,\n editor: { label: 'Product Card Price', category: 'commerce' },\n schema: {},\n guideline:\n 'Displays the selling price formatted from the active storefront context; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardListPriceDefinition = defineComponent<ProductCardListPriceProps>({\n name: 'ProductCardListPrice',\n importPath: '@vtex/faststore/components',\n component: ProductCardListPrice,\n editor: { label: 'Product Card List Price', category: 'commerce' },\n schema: {},\n guideline:\n 'Displays the original (strikethrough) list price when it exceeds the selling price; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardTaxLabelDefinition = defineComponent<ProductCardTaxLabelProps>({\n name: 'ProductCardTaxLabel',\n importPath: '@vtex/faststore/components',\n component: ProductCardTaxLabel,\n editor: { label: 'Product Card Tax Label', category: 'commerce' },\n schema: {},\n guideline:\n 'Tax label (e.g. \"Tax included\") shown beside the price. Renders only when the ProductListRoot/ProductShelfRoot config usePriceWithTaxes is enabled (state-driven, no toggle); the text comes from the taxesLabel config. Compose it to place the label, omit it to hide it. Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardDiscountDefinition = defineComponent<ProductCardDiscountProps>({\n name: 'ProductCardDiscount',\n importPath: '@vtex/faststore/components',\n component: ProductCardDiscount,\n editor: { label: 'Product Card Discount', category: 'commerce' },\n schema: {\n format: { type: ['percentage', 'absolute'] as const, default: 'percentage', label: 'Discount Format' },\n },\n guideline:\n 'Discount badge for the current product; auto-computes the markdown from listPrice vs price and renders only when a discount exists. Compose it to show the badge, omit it to hide it (no toggle). Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardAddToCartDefinition = defineComponent<ProductCardAddToCartProps>({\n name: 'ProductCardAddToCart',\n importPath: '@vtex/faststore/components',\n component: ProductCardAddToCart,\n editor: { label: 'Product Card Add to Cart', category: 'commerce' },\n schema: {},\n actions: { cart: ['addItem'] },\n guideline: 'Add-to-cart button for the current product card; must be inside ProductListGrid.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ProductListRoot({\n usePriceWithTaxes = false,\n taxesLabel = 'Tax included',\n products = [],\n className,\n children,\n ...props\n}: ProductListRootProps) {\n const config = useMemo(() => ({ usePriceWithTaxes, taxesLabel }), [usePriceWithTaxes, taxesLabel]);\n\n return (\n <ProductListConfigContext value={config}>\n <ProductListProductsContext value={products}>\n <Container {...props} className={className} data-fs-product-list-root=\"\">\n {children}\n </Container>\n </ProductListProductsContext>\n </ProductListConfigContext>\n );\n}\n\nexport function ProductListGrid({ className, children, ...props }: ProductListGridProps) {\n const products = useContext(ProductListProductsContext);\n\n return (\n <Container {...props} className={className} data-fs-product-list-grid=\"\">\n {products.map((product) => (\n <ProductListItemContext key={product.id} value={product}>\n {children}\n </ProductListItemContext>\n ))}\n </Container>\n );\n}\n\nexport function ProductCard({ className, children, bordered = true, ...props }: ProductCardProps) {\n const item = useProductListItem();\n const outOfStock = item.availableForSale === false || item.availableQuantity === 0;\n\n return (\n <Container\n {...props}\n className={className}\n data-fs-product-card=\"\"\n data-fs-product-card-bordered={String(bordered)}\n data-fs-product-card-out-of-stock={outOfStock ? '' : undefined}\n >\n {children}\n </Container>\n );\n}\n\nexport function ProductCardImage({ className, objectFit = 'cover', aspectRatio, ...props }: ProductCardImageProps) {\n const item = useProductListItem();\n\n return (\n <Image\n {...props}\n src={item.image.src}\n alt={item.image.alt}\n aspectRatio={aspectRatio}\n className={className}\n style={{ objectFit, ...props.style }}\n data-fs-product-card-image=\"\"\n />\n );\n}\n\nexport function ProductCardName({ className, children, ...props }: ProductCardNameProps) {\n const item = useProductListItem();\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-name=\"\">\n {children ?? item.name}\n </Text>\n );\n}\n\nexport function ProductCardPrice({ className, children, ...props }: ProductCardPriceProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n const value = usePriceWithTaxes ? priceWithTaxes(item.price, item) : item.price;\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-price=\"\">\n {children ?? formatPrice(value, locale, item.currency ?? currency)}\n </Text>\n );\n}\n\nexport function ProductCardListPrice({ className, children, ...props }: ProductCardListPriceProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n\n if (!item.listPrice || item.listPrice <= item.price) {\n return null;\n }\n\n const value = usePriceWithTaxes ? priceWithTaxes(item.listPrice, item) : item.listPrice;\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-list-price=\"\">\n {children ?? formatPrice(value, locale, item.currency ?? currency)}\n </Text>\n );\n}\n\nexport function ProductCardTaxLabel({ className, children, ...props }: ProductCardTaxLabelProps) {\n const { usePriceWithTaxes, taxesLabel } = useProductListConfig();\n\n if (!usePriceWithTaxes) {\n return null;\n }\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-tax-label=\"\">\n {children ?? taxesLabel}\n </Text>\n );\n}\n\nexport function ProductCardDiscount({\n className,\n children,\n format = 'percentage',\n ...props\n}: ProductCardDiscountProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n\n const { listPrice, price } = item;\n if (!listPrice || listPrice <= price) {\n return null;\n }\n\n const amountOff = listPrice - price;\n const percentOff = Math.round((amountOff / listPrice) * 100);\n const tier = percentOff >= 30 ? 'high' : percentOff >= 15 ? 'medium' : 'low';\n // The percentage is tax-invariant (both prices scale by the same factor), but the absolute amount\n // must match the displayed prices, which are tax-inclusive when usePriceWithTaxes is enabled.\n const displayedAmountOff = usePriceWithTaxes ? priceWithTaxes(amountOff, item) : amountOff;\n const label =\n format === 'absolute'\n ? `-${formatPrice(displayedAmountOff, locale, item.currency ?? currency)}`\n : `-${percentOff}%`;\n\n return (\n <Badge {...props} className={className} data-fs-product-card-discount=\"\" data-fs-product-card-discount-tier={tier}>\n {children ?? label}\n </Badge>\n );\n}\n\nexport function ProductCardAddToCart({\n className,\n children,\n onClick,\n $actions: $actionsProp,\n ...props\n}: ProductCardAddToCartProps) {\n const $actions = useActionsOverride($actionsProp);\n const item = useProductListItem();\n\n function handleClick(e: React.MouseEvent<HTMLButtonElement>) {\n void $actions?.cart?.addItem?.({ variantId: item.id, seller: '1' });\n onClick?.(e);\n }\n\n return (\n <Button {...props} className={className} onClick={handleClick} data-fs-product-card-add-to-cart=\"\">\n {children}\n </Button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ProductList = {\n Root: ProductListRoot,\n Grid: ProductListGrid,\n Card: ProductCard,\n CardImage: ProductCardImage,\n CardName: ProductCardName,\n CardPrice: ProductCardPrice,\n CardListPrice: ProductCardListPrice,\n CardTaxLabel: ProductCardTaxLabel,\n CardDiscount: ProductCardDiscount,\n CardAddToCart: ProductCardAddToCart,\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,2BAA2B,cAAiC;CACvE,mBAAmB;CACnB,YAAY;AACd,CAAC;AAED,SAAS,uBAA0C;CACjD,OAAO,WAAW,wBAAwB;AAC5C;AAEA,SAAS,YAAY,OAAe,QAAgB,UAA0B;CAC5E,OAAO,IAAI,KAAK,aAAa,QAAQ;EAAE,OAAO;EAAY;CAAS,CAAC,CAAC,CAAC,OAAO,KAAK;AACpF;AAIA,SAAS,QAAQ,MAA+B;CAC9C,IAAI,KAAK,iBAAiB,MACxB,OAAO,KAAK;CAEd,IAAI,KAAK,OAAO,QAAQ,KAAK,QAAQ,GACnC,OAAO,KAAK,MAAM,KAAK;CAEzB,OAAO;AACT;AAEA,SAAS,eAAe,MAAc,MAA+B;CACnE,OAAO,QAAQ,IAAI,QAAQ,IAAI;AACjC;AAiCA,MAAM,6BAA6B,cAAiC,CAAC,CAAC;AAMtE,MAAa,yBAAyB,cAAsC,IAAI;AAEhF,SAAS,qBAAsC;CAC7C,MAAM,OAAO,WAAW,sBAAsB;CAC9C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,6DAA6D;CAE/E,OAAO;AACT;AAgDA,MAAa,4BAA4B,gBAAsC;CAC7E,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAqB,UAAU;CAAW;CAC3D,QAAQ;EACN,mBAAmB;GAAE,MAAM;GAAW,SAAS;GAAO,OAAO;EAAuB;EACpF,YAAY;GAAE,MAAM;GAAU,SAAS;GAAgB,OAAO;EAAc;CAC9E;CACA,WACE;AACJ,CA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AAa,oCAAiC;EAC7F;CACK,CAAA;AAEZ;AAMA,MAAa,cAAc;CACzB,MAAM;CACN,MAAM;CACN,MAAM;CACN,WAAW;CACX,UAAU;CACV,WAAW;CACX,eAAe;CACf,cAAc;CACd,cAAc;CACd,eAAe;AACjB"}
@@ -175,7 +175,7 @@ export declare const RegionUnknownLinkDefinition: ComponentDefinition<RegionUnkn
175
175
  * into the Apollo cache (Decision 5). That is why a rejected write needs no rollback and cannot
176
176
  * leave the header showing a postal code the server refused.
177
177
  */
178
- export declare function RegionRoot({ $data: $dataProp, $actions, className, children, ...props }: RegionRootProps): import("react/jsx-runtime").JSX.Element;
178
+ export declare function RegionRoot({ $data: $dataProp, $actions: $actionsProp, className, children, ...props }: RegionRootProps): import("react/jsx-runtime").JSX.Element;
179
179
  export declare function RegionTrigger({ unsetLabel, $content, className, children, ...props }: RegionTriggerProps): import("react/jsx-runtime").JSX.Element;
180
180
  export declare function RegionValue({ className, ...props }: RegionValueProps): import("react/jsx-runtime").JSX.Element | null;
181
181
  export declare function RegionLoading({ className, children, ...props }: RegionLoadingProps): import("react/jsx-runtime").JSX.Element | null;
@@ -4,6 +4,7 @@ import { defineContentType } from "../../core/dist/define-content-type.js";
4
4
  import "../../core/dist/index.js";
5
5
  import { useIntl } from "../../sdk/i18n/client.js";
6
6
  import { graphql } from "../../sdk/generated/gql.js";
7
+ import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
7
8
  import { useDataOverride } from "../../sdk/data/data-override-context.js";
8
9
  import { resolveSafeHref } from "../../utils/safe-href.js";
9
10
  import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
@@ -291,8 +292,10 @@ const RegionUnknownLinkDefinition = defineComponent({
291
292
  * into the Apollo cache (Decision 5). That is why a rejected write needs no rollback and cannot
292
293
  * leave the header showing a postal code the server refused.
293
294
  */
294
- function RegionRoot({ $data: $dataProp, $actions, className, children, ...props }) {
295
- const region = useDataOverride($dataProp) ?? null;
295
+ function RegionRoot({ $data: $dataProp, $actions: $actionsProp, className, children, ...props }) {
296
+ const $data = useDataOverride($dataProp);
297
+ const $actions = useActionsOverride($actionsProp);
298
+ const region = $data ?? null;
296
299
  const { loading: rootLoading } = useContext(ReactiveRootContext);
297
300
  const loading = rootLoading && region == null;
298
301
  const postalCode = region?.postalCode ?? null;
@@ -1 +1 @@
1
- {"version":3,"file":"region.js","names":[],"sources":["../../../src/matter/region/region.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\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 type { DialogRootProps } from '../../particles/dialog/dialog.js';\nimport { PostalCodeField } from '../../particles/postal-code-field/postal-code-field.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport { type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { RegionEntity } from '../../sdk/region/operations.js';\nimport type { RegionUserError } from '../../sdk/region/region-operations.js';\nimport { resolveSafeHref } from '../../utils/safe-href.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — typed via @graphql-codegen client-preset\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment RegionData on Query {\n region {\n ...RegionFragment\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Content models — one per copy-bearing part (Decision 7)\n// ---------------------------------------------------------------------------\n\nexport const RegionTriggerContent = defineContentType({\n id: 'region-trigger',\n title: 'Region Trigger',\n description: 'Copy for the control that opens the region modal.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n unsetLabel: { type: 'string', title: 'Label when no region is set' },\n ariaLabel: { type: 'string', title: 'Accessible label' },\n },\n },\n});\n\nexport const RegionSubmitContent = defineContentType({\n id: 'region-submit',\n title: 'Region Submit',\n description: 'Copy for the region submit control.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label' },\n pendingLabel: { type: 'string', title: 'Pending label' },\n },\n },\n});\n\nexport const RegionUnknownLinkContent = defineContentType({\n id: 'region-unknown-link',\n title: 'Region \"I don\\'t know my postal code\" Link',\n description: 'Copy and destination for the postal-code lookup link. Absent href omits the link.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n text: { type: 'string', minLength: 1, title: 'Link text' },\n href: {\n type: 'string',\n title: 'Destination',\n format: 'uri-reference',\n // The set `resolveSafeHref` admits, so the Admin form cannot reject a destination the render\n // gate would have kept. Author-time only and lookahead-free, as in the link-bearing particles.\n pattern: '^(?:https?://.*|mailto:.+|tel:.+|/(?:[^/].*)?)$',\n },\n },\n },\n});\n\nexport const RegionErrorContent = defineContentType({\n id: 'region-error',\n title: 'Region Error',\n description: 'Fallback message shown when a write fails without a server message.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n genericMessage: { type: 'string', title: 'Generic failure message' },\n },\n },\n});\n\n// ---------------------------------------------------------------------------\n// Region context\n// ---------------------------------------------------------------------------\n\nexport type RegionContextValue = Readonly<{\n /** Persisted postal code, formatted; null until a region is set. */\n postalCode: string | null;\n /** Persisted city; null when the contract does not resolve one. */\n city: string | null;\n /** The reactive read has not resolved and no cached value is available. */\n loading: boolean;\n /** The modal's draft value, masked as the shopper typed it. */\n draft: string;\n setDraft: (value: string) => void;\n /** A write is in flight. */\n pending: boolean;\n /** Errors from the latest write; empty when there are none. */\n errors: readonly RegionUserError[];\n open: boolean;\n setOpen: (open: boolean) => void;\n /** Dispatches setPostalCode with the current draft. No-op while pending. */\n submit: () => void;\n}>;\n\nconst REGION_CONTEXT_UNSET = Symbol('RegionContextUnset');\n\nconst RegionContextInternal = createContext<RegionContextValue | typeof REGION_CONTEXT_UNSET>(REGION_CONTEXT_UNSET);\n\nexport const RegionContext = RegionContextInternal as React.Context<RegionContextValue>;\n\n/**\n * Read the active region and the modal's write state from the nearest `RegionRoot`. Throws when\n * called outside a `RegionRoot` subtree, mirroring `useSession()` and `useCart()`: a misplaced part\n * is a composition bug the author should see immediately, not a silent degrade to \"no region\". The\n * compiler catches the same mistake earlier through `requiresContext: 'region'` (ADR-0009).\n */\nexport function useRegion(): RegionContextValue {\n const ctx = useContext(RegionContextInternal);\n if (ctx === REGION_CONTEXT_UNSET) {\n throw new Error('Region components must be used inside a <RegionRoot> subtree.');\n }\n return ctx;\n}\n\n/**\n * Whether a `RegionForm` encloses the subtree. `RegionSubmit` is independently placeable, so it\n * cannot assume a form owner: with one it is a real submit button, which is what makes Enter in the\n * field submit; without one a `type=\"submit\"` button would have nothing to submit and its click\n * would do nothing. Reading this keeps the form composable rather than load-bearing.\n */\nconst RegionFormContext = createContext(false);\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type RegionRootProps = ComponentPropsWithRef<'div'> & {\n /**\n * Region entity slice forwarded by the reactive runtime (`ReactiveDataProvider`) — the value of the\n * `region` top-level field on `RegionData on Query`, not the wrapping `{ region: … }` shape.\n * Receives `null` while the entity has not resolved and when no region is set.\n */\n $data?: RegionEntity | null;\n /** Injected by the compiler from `actions: { region: ['setPostalCode'] }`; the region write surface. */\n $actions?: ComponentActions;\n children?: ReactNode;\n};\n\nexport type RegionTriggerProps = ComponentPropsWithRef<'button'> & {\n /** Shown when no region is set. */\n unsetLabel?: string;\n /** Merchant-authored copy; wins over the props when present. */\n $content?: ContentValue<typeof RegionTriggerContent>;\n};\n\n/** Children are omitted: what this renders is the resolved region, never authored content. */\nexport type RegionValueProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;\n\nexport type RegionLoadingProps = ComponentPropsWithRef<'div'>;\n\nexport type RegionModalControllerProps = {\n children?: ReactNode;\n};\n\nexport type RegionFormProps = ComponentPropsWithRef<'form'>;\n\nexport type RegionPostalCodeControlProps = {\n className?: string;\n /** Mask template forwarded to `PostalCodeField`; defaults to that particle's BR CEP mask. */\n mask?: string;\n label?: string;\n placeholder?: string;\n /** The field's own incomplete-value message. Server rejections surface through `RegionError`. */\n errorMessage?: string;\n};\n\nexport type RegionSubmitProps = ComponentPropsWithRef<'button'> & {\n label?: string;\n pendingLabel?: string;\n /** Merchant-authored copy; wins over the props when present. */\n $content?: ContentValue<typeof RegionSubmitContent>;\n};\n\n/** Children are omitted: what this renders is the write's own error, never authored content. */\nexport type RegionErrorProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & {\n /** Merchant-authored fallback copy; wins over the prop when present. */\n $content?: ContentValue<typeof RegionErrorContent>;\n};\n\nexport type RegionUnknownLinkProps = ComponentPropsWithRef<'a'> & {\n /** Merchant-authored text and destination; each wins over its prop when present. */\n $content?: ContentValue<typeof RegionUnknownLinkContent>;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const RegionRootDefinition = defineComponent<RegionRootProps>({\n name: 'RegionRoot',\n importPath: '@vtex/faststore/components',\n component: RegionRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'region',\n actions: { region: ['setPostalCode'] },\n editor: { label: 'Region Root', category: 'content' },\n schema: {},\n guideline:\n 'Provides region context and reads the active postal code and city reactively. Place it in the shared header layout and compose RegionTrigger, RegionValue, RegionLoading, and a RegionModalController inside it. Every Region* component must be a descendant. See region.md.',\n});\n\nexport const RegionTriggerDefinition = defineComponent<RegionTriggerProps>({\n name: 'RegionTrigger',\n importPath: '@vtex/faststore/components',\n component: RegionTrigger,\n content: RegionTriggerContent,\n requiresContext: 'region',\n editor: { label: 'Region Trigger', category: 'action' },\n schema: {\n unsetLabel: { type: 'string', default: 'Informe seu CEP', label: 'Label when no region is set' },\n },\n guideline:\n 'Opens the region modal. Shows its unset label while no region is set; compose RegionValue as its child so the active region reads inside the control once one is. Its accessible name carries the active region, so a screen reader announces where the shopper is shopping. Must be inside RegionRoot.',\n});\n\nexport const RegionValueDefinition = defineComponent<RegionValueProps>({\n name: 'RegionValue',\n importPath: '@vtex/faststore/components',\n component: RegionValue,\n requiresContext: 'region',\n editor: { label: 'Region Value', category: 'content' },\n schema: {},\n guideline:\n 'The active region, as city plus postal code. Renders nothing while the region is unresolved or unset, so it needs no visibility prop — place it inside RegionTrigger, or anywhere in the header that should echo the region. The city is wrapped in its own element (data-fs-region-value-city) so a store can style or hide it; when the contract resolves no city, the postal code renders alone with no separator. A plain space separates the two in the text, so the accessible name reads \"São Paulo 01310-100\"; a flex container strips it, so a gap swatch still sets the visible spacing. Must be inside RegionRoot.',\n});\n\nexport const RegionLoadingDefinition = defineComponent<RegionLoadingProps>({\n name: 'RegionLoading',\n importPath: '@vtex/faststore/components',\n component: RegionLoading,\n requiresContext: 'region',\n editor: { label: 'Region Loading', category: 'content' },\n schema: {},\n guideline:\n 'Renders its children only while the region read has not resolved. Supply a skeleton placeholder as its child, sized like the resolved display so the header does not reflow when the region arrives. RegionValue renders nothing while this branch is showing, so the two never double up. Must be inside RegionRoot.',\n});\n\nexport const RegionModalControllerDefinition = defineComponent<RegionModalControllerProps>({\n name: 'RegionModalController',\n importPath: '@vtex/faststore/components',\n component: RegionModalController,\n requiresContext: 'region',\n editor: { label: 'Region Modal Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DialogRoot child (the region modal) and makes it controlled by the region state: RegionTrigger opens it, Escape and the backdrop close it, and a successful write closes it. Do not set raw open/onOpenChange on the wrapped DialogRoot. Compose DialogPortal, DialogBackdrop, DialogViewport and DialogPopup inside it, with DialogTitle and DialogDescription naming the dialog, and place a RegionForm holding RegionPostalCodeControl and RegionSubmit in the popup, alongside RegionError and RegionUnknownLink. Same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside RegionRoot.',\n});\n\nexport const RegionFormDefinition = defineComponent<RegionFormProps>({\n name: 'RegionForm',\n importPath: '@vtex/faststore/components',\n component: RegionForm,\n requiresContext: 'region',\n editor: { label: 'Region Form', category: 'action' },\n schema: {},\n guideline:\n 'Form wrapper holding RegionPostalCodeControl and RegionSubmit inside the region modal, so pressing Enter in the field submits. Same role as ShippingSimulatorForm. Compose it whenever both parts sit together; without it the shopper must reach the button, which still works but is not what a one-field form leads them to expect. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionPostalCodeControlDefinition = defineComponent<RegionPostalCodeControlProps>({\n name: 'RegionPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: RegionPostalCodeControl,\n requiresContext: 'region',\n editor: { label: 'Region Postal Code Control', category: 'content' },\n schema: {\n mask: { type: 'string', default: '99999-999', label: 'Mask pattern' },\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n errorMessage: { type: 'string', label: 'Incomplete-value message' },\n },\n guideline:\n 'The postal-code input inside the region modal: a PostalCodeField bound to the region draft, seeded from the persisted value every time the modal opens. Set mask to the country format at build time (default 99999-999, BR CEP). Server rejections mark the field invalid and take focus back to it; their message is shown by RegionError, not repeated here, and the first keystroke after one clears it. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionSubmitDefinition = defineComponent<RegionSubmitProps>({\n name: 'RegionSubmit',\n importPath: '@vtex/faststore/components',\n component: RegionSubmit,\n content: RegionSubmitContent,\n requiresContext: 'region',\n editor: { label: 'Region Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'Aplicar', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'Aplicando...', label: 'Pending label' },\n },\n guideline:\n \"Submits the region draft. Inside a RegionForm it is the form's submit button, which is what makes Enter in the field work; on its own it dispatches directly. Inert while empty and while a write is in flight, so a double activation dispatches one mutation; the pending state is exposed as aria-busy with no built-in spinner. On success the modal closes; on a rejection it stays open and RegionError explains why. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionErrorDefinition = defineComponent<RegionErrorProps>({\n name: 'RegionError',\n importPath: '@vtex/faststore/components',\n component: RegionError,\n content: RegionErrorContent,\n requiresContext: 'region',\n editor: { label: 'Region Error', category: 'content' },\n schema: {},\n guideline:\n \"Shows why the latest region write was refused, announced as an alert when it appears. Renders nothing when there is no error, so it needs no visibility prop. The server's own message is shown verbatim; the authored generic message covers a transport failure, where there is no server message to show. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionUnknownLinkDefinition = defineComponent<RegionUnknownLinkProps>({\n name: 'RegionUnknownLink',\n importPath: '@vtex/faststore/components',\n component: RegionUnknownLink,\n content: RegionUnknownLinkContent,\n requiresContext: 'region',\n editor: { label: 'Region Unknown Postal Code Link', category: 'navigation' },\n schema: {\n href: { type: 'string', label: 'Lookup service URL' },\n target: { type: ['_self', '_blank'] as const, default: '_self', label: 'Open in' },\n },\n guideline:\n 'The \"I don\\'t know my postal code\" escape hatch, pointing at a postal-code lookup service. Renders nothing until a destination is set, so a store without a lookup service composes it and simply gets no link rather than a dead one. Its text comes from authored content or its children. Must be inside a RegionModalController dialog.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the active region reactively and publishes it, the modal's draft, and the write state as\n * `region` context.\n *\n * The resolved value is never copied into state: `RegionValue` renders only what the fragment\n * resolves, and a successful write updates the display solely by the mutation payload normalizing\n * into the Apollo cache (Decision 5). That is why a rejected write needs no rollback and cannot\n * leave the header showing a postal code the server refused.\n */\nexport function RegionRoot({ $data: $dataProp, $actions, className, children, ...props }: RegionRootProps) {\n const $data = useDataOverride($dataProp);\n const region = $data ?? null;\n const { loading: rootLoading } = useContext(ReactiveRootContext);\n // A null region is ambiguous on its own — an unresolved read and a shopper who never set one look\n // the same — so the root query's in-flight flag is what separates \"loading\" from \"unset\". Without\n // it a first-time shopper would sit under a skeleton forever instead of seeing the unset prompt.\n const loading = rootLoading && region == null;\n\n const postalCode = region?.postalCode ?? null;\n\n const [open, setOpenState] = useState(false);\n const [draft, setDraftState] = useState('');\n const [pending, setPending] = useState(false);\n const [errors, setErrors] = useState<readonly RegionUserError[]>([]);\n // State is batched, so two activations in one tick would both pass a `pending` check. The ref is\n // what makes \"exactly one mutation per activation\" hold.\n const inFlightRef = useRef(false);\n\n /**\n * Seeds the draft from the persisted value on open and clears it on close (Decision 6), so a\n * reopened modal always shows the truth rather than an abandoned edit.\n */\n const setOpen = useCallback(\n (next: boolean) => {\n setOpenState(next);\n setDraftState(next ? (postalCode ?? '') : '');\n setErrors([]);\n },\n [postalCode],\n );\n\n /**\n * Editing is the shopper's answer to a rejection, so the message and the invalid flag go with the\n * first keystroke. Left standing, they describe a value that is no longer in the field — and\n * `RegionPostalCodeControl`, which withholds its own incomplete-value copy while a rejection\n * stands, would stay silent for the whole edit. Returns the same array when there is nothing to\n * clear, so ordinary typing does not re-render the error subtree.\n */\n const setDraft = useCallback((value: string) => {\n setDraftState(value);\n setErrors((current) => (current.length === 0 ? current : []));\n }, []);\n\n const submit = useCallback(() => {\n if (inFlightRef.current) return;\n const setPostalCode = $actions?.region?.setPostalCode;\n if (!setPostalCode) return;\n\n inFlightRef.current = true;\n setPending(true);\n setErrors([]);\n\n void setPostalCode(draft)\n .then((writeErrors) => {\n if (writeErrors.length > 0) {\n // A rejection keeps the modal open so the message has somewhere to show (US-3).\n setErrors(writeErrors);\n return;\n }\n setOpenState(false);\n setDraftState('');\n })\n .finally(() => {\n inFlightRef.current = false;\n setPending(false);\n });\n }, [$actions, draft]);\n\n const value: RegionContextValue = useMemo(\n () => ({\n postalCode,\n city: region?.city ?? null,\n loading,\n draft,\n setDraft,\n pending,\n errors,\n open,\n setOpen,\n submit,\n }),\n [postalCode, region?.city, loading, draft, setDraft, pending, errors, open, setOpen, submit],\n );\n\n return (\n <RegionContextInternal value={value}>\n <div {...props} className={className} data-fs-region-root=\"\">\n {children}\n </div>\n </RegionContextInternal>\n );\n}\n\nexport function RegionTrigger({\n unsetLabel = 'Informe seu CEP',\n $content,\n className,\n children,\n ...props\n}: RegionTriggerProps) {\n const { postalCode, city, loading, setOpen } = useRegion();\n const isUnset = postalCode == null;\n\n const resolvedUnsetLabel = $content?.unsetLabel?.trim() ? $content.unsetLabel : unsetLabel;\n const authoredAriaLabel = $content?.ariaLabel?.trim() ? $content.ariaLabel : props['aria-label'];\n\n /**\n * WCAG 2.5.3 wants the accessible name to contain the visible label, so an authored label prefixes\n * the text on screen rather than replacing it: a name of \"Alterar região\" over text reading\n * \"Informe seu CEP\" leaves a voice-control user nothing to say. The region is spaced the way\n * `RegionValue` spaces it, since the name has to carry that text verbatim. Empty while the region\n * is unresolved, when the button reads nothing, and with no authored label the name falls back to\n * the text itself, which already satisfies the rule.\n */\n let visibleLabel = '';\n if (!loading) {\n visibleLabel = isUnset ? resolvedUnsetLabel : [city, postalCode].filter(Boolean).join(' ');\n }\n\n const ariaLabel = authoredAriaLabel && visibleLabel ? `${authoredAriaLabel}: ${visibleLabel}` : authoredAriaLabel;\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => setOpen(true)}\n // Not yet interactive while the region is unresolved: activating it would seed the draft from a\n // value that has not arrived.\n disabled={loading || props.disabled}\n aria-label={ariaLabel}\n className={className}\n data-fs-region-trigger=\"\"\n {...(isUnset ? { 'data-fs-region-trigger-unset': '' } : {})}\n >\n {isUnset && !loading ? resolvedUnsetLabel : null}\n {children}\n </button>\n );\n}\n\nexport function RegionValue({ className, ...props }: RegionValueProps) {\n const { postalCode, city, loading } = useRegion();\n if (loading || postalCode == null) return null;\n\n return (\n <span {...props} className={className} data-fs-region-value=\"\">\n {city ? <span data-fs-region-value-city=\"\">{city}</span> : null}\n {/* A real text node, not a styling concern: it is what separates the two values in the\n accessible name — this is the trigger's name whenever no aria-label is authored — and in any\n non-flex placement. It must stay a plain space: a flex container strips it as leading\n whitespace, so a store's `gap` still governs the visible spacing, where an &nbsp; would\n survive and widen the row. Absent with no city, so the postal code never renders padded. */}\n {city ? ' ' : null}\n {postalCode}\n </span>\n );\n}\n\nexport function RegionLoading({ className, children, ...props }: RegionLoadingProps) {\n const { loading } = useRegion();\n if (!loading) return null;\n\n return (\n <div {...props} className={className} data-fs-region-loading=\"\">\n {children}\n </div>\n );\n}\n\n/**\n * Makes the wrapped `DialogRoot` controlled by the region state. Mirrors\n * `ShippingAddressSavedAddressDrawerController`'s `cloneElement` mechanism; expects a single\n * `DialogRoot` child. Dismissal is never blocked — the Phase 1 modal is always dismissible.\n */\nexport function RegionModalController({ children }: RegionModalControllerProps) {\n const { open, setOpen } = useRegion();\n\n if (!isValidElement<Pick<DialogRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open,\n onOpenChange: (next: boolean) => setOpen(next),\n });\n}\n\n/**\n * Gives the field and the submit a form owner, so Enter in the postal code submits the way it does\n * in every other short form in the repo. Mirrors `ShippingSimulatorForm`: the form's only job is to\n * route native submission to the context's `submit()`.\n */\nexport function RegionForm({ className, children, ...props }: RegionFormProps) {\n const { submit } = useRegion();\n\n return (\n <RegionFormContext value={true}>\n <form\n {...props}\n className={className}\n data-fs-region-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n </RegionFormContext>\n );\n}\n\nexport function RegionPostalCodeControl({\n className,\n mask,\n label,\n placeholder,\n errorMessage,\n}: RegionPostalCodeControlProps) {\n const { draft, setDraft, errors, pending } = useRegion();\n const rootRef = useRef<HTMLDivElement>(null);\n const refused = errors.length > 0;\n\n /**\n * A refusal has to leave the shopper on the value they need to correct. Disabling the input while\n * the write is in flight blurs it and the browser drops focus to the document body, so a rejection\n * otherwise lands with nothing focused inside an open dialog — Enter does nothing and Tab restarts\n * from the top. Waits for `pending` to clear, because focusing a still-disabled input is a no-op:\n * the errors and the pending flag settle in separate microtasks, so there is a render in between\n * where the rejection is known and the field is not yet editable. The field is reached through the\n * root the way ClientProfileForm reaches its own fields.\n */\n useEffect(() => {\n if (!refused || pending) return;\n rootRef.current?.querySelector<HTMLInputElement>('[data-fs-postal-code-field-input]')?.focus();\n }, [refused, pending]);\n\n return (\n <PostalCodeField\n ref={rootRef}\n className={className}\n data-fs-region-postal-code-control=\"\"\n mask={mask}\n label={label}\n placeholder={placeholder}\n // The field renders this whenever it is invalid, from either source, so it is withheld while a\n // server rejection stands: that message is RegionError's, and the field's own copy describes an\n // incomplete value — wrong for a complete code the server refused, and contradictory stacked\n // under the real reason.\n errorMessage={errors.length > 0 ? undefined : errorMessage}\n value={draft}\n onValueChange={setDraft}\n // Still flagged invalid, so the refused value carries aria-invalid and the invalid styling.\n invalid={errors.length > 0}\n disabled={pending}\n />\n );\n}\n\nexport function RegionSubmit({\n label = 'Aplicar',\n pendingLabel = 'Aplicando...',\n $content,\n className,\n children,\n ...props\n}: RegionSubmitProps) {\n const { draft, pending, submit } = useRegion();\n const inForm = useContext(RegionFormContext);\n\n const resolvedLabel = $content?.label?.trim() ? $content.label : label;\n const resolvedPendingLabel = $content?.pendingLabel?.trim() ? $content.pendingLabel : pendingLabel;\n\n return (\n <button\n {...props}\n // The form routes native submission to the same submit(); alone there is no form to submit.\n type={inForm ? 'submit' : 'button'}\n onClick={inForm ? props.onClick : submit}\n disabled={pending || draft.trim() === '' || props.disabled}\n aria-busy={pending || undefined}\n className={className}\n data-fs-region-submit=\"\"\n {...(pending ? { 'data-fs-region-submit-pending': '' } : {})}\n >\n {children ?? (pending ? resolvedPendingLabel : resolvedLabel)}\n </button>\n );\n}\n\n/**\n * The catalog copy for each rejection the client can name: the server's `RegionErrorCode` values plus\n * the client-minted transport failure. The server's own `message` is English, so it is shown only for\n * a code this map does not know — a newer server than this package.\n */\nconst REGION_ERROR_MESSAGE_IDS: Readonly<Record<string, MessageId>> = {\n INVALID_POSTAL_CODE: 'fs/region.error.invalid-postal-code',\n UNSERVED_POSTAL_CODE: 'fs/region.error.unserved-postal-code',\n NETWORK_ERROR: 'fs/region.error.network',\n};\n\nexport function RegionError({ $content, className, ...props }: RegionErrorProps) {\n const { errors } = useRegion();\n const intl = useIntl();\n if (errors.length === 0) return null;\n\n const genericMessage = $content?.genericMessage?.trim() ? $content.genericMessage : null;\n\n function copyFor(error: RegionUserError): string {\n // A transport failure carries no server message worth showing a shopper, so the authored\n // generic copy wins there and only there. Every other code the catalog knows renders in the\n // store's language; a code it does not know falls back to the server's own message.\n if (error.code === 'NETWORK_ERROR' && genericMessage) return genericMessage;\n const id = error.code ? REGION_ERROR_MESSAGE_IDS[error.code] : undefined;\n return id ? intl.formatMessage({ id }) : error.message;\n }\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-region-error=\"\">\n {errors.map((error) => (\n <div key={`${error.code ?? ''}${error.message}`}>{copyFor(error)}</div>\n ))}\n </div>\n );\n}\n\nexport function RegionUnknownLink({ $content, className, children, href, rel, ...props }: RegionUnknownLinkProps) {\n // Called for its guard alone: a part placed outside a RegionRoot must fail here the way its\n // siblings do, even though this one reads nothing from the context.\n useRegion();\n\n const authoredHref = $content?.href?.trim() ? $content.href : href?.trim();\n // Absent is \"no link\", the ordinary shape for a store with no lookup service, so it never reaches\n // the allowlist or the log.\n if (!authoredHref) return null;\n\n // No read-time validator enforces the model's `format` or `pattern`, so this is the only gate on\n // the CMS value.\n const destination = resolveSafeHref(authoredHref);\n if (!destination.safe) {\n // A bounded reason and no authored value, the convention the content runtime's own log follows.\n console.warn('[RegionUnknownLink] link destination rejected', { reason: destination.reason });\n return null;\n }\n\n const text = $content?.text?.trim() ? $content.text : children;\n if (!text) return null;\n\n // A lookup service is a natural new-tab destination, so a store may pass target. The tab-nabbing\n // defense is then this component's responsibility, not the composer's — the same contract\n // NavigationLink states. Target keywords and link types are both ASCII case-insensitive per HTML,\n // so _BLANK opens a new tab and a caller-passed NOOPENER already counts.\n const relTokens = rel?.split(/\\s+/).filter(Boolean) ?? [];\n const present = new Set(relTokens.map((token) => token.toLowerCase()));\n const safeRel =\n props.target?.toLowerCase() === '_blank'\n ? [...relTokens, ...['noopener', 'noreferrer'].filter((token) => !present.has(token))].join(' ')\n : rel;\n\n return (\n <a {...props} href={destination.href} rel={safeRel} className={className} data-fs-region-unknown-link=\"\">\n {text}\n </a>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const Region = {\n Root: RegionRoot,\n Trigger: RegionTrigger,\n Value: RegionValue,\n Loading: RegionLoading,\n ModalController: RegionModalController,\n Form: RegionForm,\n PostalCodeControl: RegionPostalCodeControl,\n Submit: RegionSubmit,\n Error: RegionError,\n UnknownLink: RegionUnknownLink,\n};\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,WAAW,QAAQ;;;;;;CAMxB;AAMD,MAAa,uBAAuB,kBAAkB;CACpD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,YAAY;IAAE,MAAM;IAAU,OAAO;GAA8B;GACnE,WAAW;IAAE,MAAM;IAAU,OAAO;GAAmB;EACzD;CACF;AACF,CAAC;AAED,MAAa,sBAAsB,kBAAkB;CACnD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,OAAO;IAAE,MAAM;IAAU,OAAO;GAAe;GAC/C,cAAc;IAAE,MAAM;IAAU,OAAO;GAAgB;EACzD;CACF;AACF,CAAC;AAED,MAAa,2BAA2B,kBAAkB;CACxD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,MAAM;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAY;GACzD,MAAM;IACJ,MAAM;IACN,OAAO;IACP,QAAQ;IAGR,SAAS;GACX;EACF;CACF;AACF,CAAC;AAED,MAAa,qBAAqB,kBAAkB;CAClD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY,EACV,gBAAgB;GAAE,MAAM;GAAU,OAAO;EAA0B,EACrE;CACF;AACF,CAAC;AA0BD,MAAM,uBAAuB,OAAO,oBAAoB;AAExD,MAAM,wBAAwB,cAAgE,oBA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,IAAI,SAAS,OAAO,MAAM,KAAK;CAGzE,IAAI,CAAC,cAAc,OAAO;CAI1B,MAAM,cAAc,gBAAgB,YAAY;CAChD,IAAI,CAAC,YAAY,MAAM;EAErB,QAAQ,KAAK,iDAAiD,EAAE,QAAQ,YAAY,OAAO,CAAC;EAC5F,OAAO;CACT;CAEA,MAAM,OAAO,UAAU,MAAM,KAAK,IAAI,SAAS,OAAO;CACtD,IAAI,CAAC,MAAM,OAAO;CAMlB,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,KAAK,CAAC;CACxD,MAAM,UAAU,IAAI,IAAI,UAAU,KAAK,UAAU,MAAM,YAAY,CAAC,CAAC;CACrE,MAAM,UACJ,MAAM,QAAQ,YAAY,MAAM,WAC5B,CAAC,GAAG,WAAW,GAAG,CAAC,YAAY,YAAY,CAAC,CAAC,QAAQ,UAAU,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAC7F;CAEN,OACE,oBAAC,KAAD;EAAG,GAAI;EAAO,MAAM,YAAY;EAAM,KAAK;EAAoB;EAAW,+BAA4B;EACnG,UAAA;CACA,CAAA;AAEP;AAMA,MAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,OAAO;CACP,SAAS;CACT,iBAAiB;CACjB,MAAM;CACN,mBAAmB;CACnB,QAAQ;CACR,OAAO;CACP,aAAa;AACf"}
1
+ {"version":3,"file":"region.js","names":[],"sources":["../../../src/matter/region/region.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\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 type { DialogRootProps } from '../../particles/dialog/dialog.js';\nimport { PostalCodeField } from '../../particles/postal-code-field/postal-code-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 { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport { type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { RegionEntity } from '../../sdk/region/operations.js';\nimport type { RegionUserError } from '../../sdk/region/region-operations.js';\nimport { resolveSafeHref } from '../../utils/safe-href.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — typed via @graphql-codegen client-preset\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment RegionData on Query {\n region {\n ...RegionFragment\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Content models — one per copy-bearing part (Decision 7)\n// ---------------------------------------------------------------------------\n\nexport const RegionTriggerContent = defineContentType({\n id: 'region-trigger',\n title: 'Region Trigger',\n description: 'Copy for the control that opens the region modal.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n unsetLabel: { type: 'string', title: 'Label when no region is set' },\n ariaLabel: { type: 'string', title: 'Accessible label' },\n },\n },\n});\n\nexport const RegionSubmitContent = defineContentType({\n id: 'region-submit',\n title: 'Region Submit',\n description: 'Copy for the region submit control.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label' },\n pendingLabel: { type: 'string', title: 'Pending label' },\n },\n },\n});\n\nexport const RegionUnknownLinkContent = defineContentType({\n id: 'region-unknown-link',\n title: 'Region \"I don\\'t know my postal code\" Link',\n description: 'Copy and destination for the postal-code lookup link. Absent href omits the link.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n text: { type: 'string', minLength: 1, title: 'Link text' },\n href: {\n type: 'string',\n title: 'Destination',\n format: 'uri-reference',\n // The set `resolveSafeHref` admits, so the Admin form cannot reject a destination the render\n // gate would have kept. Author-time only and lookahead-free, as in the link-bearing particles.\n pattern: '^(?:https?://.*|mailto:.+|tel:.+|/(?:[^/].*)?)$',\n },\n },\n },\n});\n\nexport const RegionErrorContent = defineContentType({\n id: 'region-error',\n title: 'Region Error',\n description: 'Fallback message shown when a write fails without a server message.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n genericMessage: { type: 'string', title: 'Generic failure message' },\n },\n },\n});\n\n// ---------------------------------------------------------------------------\n// Region context\n// ---------------------------------------------------------------------------\n\nexport type RegionContextValue = Readonly<{\n /** Persisted postal code, formatted; null until a region is set. */\n postalCode: string | null;\n /** Persisted city; null when the contract does not resolve one. */\n city: string | null;\n /** The reactive read has not resolved and no cached value is available. */\n loading: boolean;\n /** The modal's draft value, masked as the shopper typed it. */\n draft: string;\n setDraft: (value: string) => void;\n /** A write is in flight. */\n pending: boolean;\n /** Errors from the latest write; empty when there are none. */\n errors: readonly RegionUserError[];\n open: boolean;\n setOpen: (open: boolean) => void;\n /** Dispatches setPostalCode with the current draft. No-op while pending. */\n submit: () => void;\n}>;\n\nconst REGION_CONTEXT_UNSET = Symbol('RegionContextUnset');\n\nconst RegionContextInternal = createContext<RegionContextValue | typeof REGION_CONTEXT_UNSET>(REGION_CONTEXT_UNSET);\n\nexport const RegionContext = RegionContextInternal as React.Context<RegionContextValue>;\n\n/**\n * Read the active region and the modal's write state from the nearest `RegionRoot`. Throws when\n * called outside a `RegionRoot` subtree, mirroring `useSession()` and `useCart()`: a misplaced part\n * is a composition bug the author should see immediately, not a silent degrade to \"no region\". The\n * compiler catches the same mistake earlier through `requiresContext: 'region'` (ADR-0009).\n */\nexport function useRegion(): RegionContextValue {\n const ctx = useContext(RegionContextInternal);\n if (ctx === REGION_CONTEXT_UNSET) {\n throw new Error('Region components must be used inside a <RegionRoot> subtree.');\n }\n return ctx;\n}\n\n/**\n * Whether a `RegionForm` encloses the subtree. `RegionSubmit` is independently placeable, so it\n * cannot assume a form owner: with one it is a real submit button, which is what makes Enter in the\n * field submit; without one a `type=\"submit\"` button would have nothing to submit and its click\n * would do nothing. Reading this keeps the form composable rather than load-bearing.\n */\nconst RegionFormContext = createContext(false);\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type RegionRootProps = ComponentPropsWithRef<'div'> & {\n /**\n * Region entity slice forwarded by the reactive runtime (`ReactiveDataProvider`) — the value of the\n * `region` top-level field on `RegionData on Query`, not the wrapping `{ region: … }` shape.\n * Receives `null` while the entity has not resolved and when no region is set.\n */\n $data?: RegionEntity | null;\n /** Injected by the compiler from `actions: { region: ['setPostalCode'] }`; the region write surface. */\n $actions?: ComponentActions;\n children?: ReactNode;\n};\n\nexport type RegionTriggerProps = ComponentPropsWithRef<'button'> & {\n /** Shown when no region is set. */\n unsetLabel?: string;\n /** Merchant-authored copy; wins over the props when present. */\n $content?: ContentValue<typeof RegionTriggerContent>;\n};\n\n/** Children are omitted: what this renders is the resolved region, never authored content. */\nexport type RegionValueProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;\n\nexport type RegionLoadingProps = ComponentPropsWithRef<'div'>;\n\nexport type RegionModalControllerProps = {\n children?: ReactNode;\n};\n\nexport type RegionFormProps = ComponentPropsWithRef<'form'>;\n\nexport type RegionPostalCodeControlProps = {\n className?: string;\n /** Mask template forwarded to `PostalCodeField`; defaults to that particle's BR CEP mask. */\n mask?: string;\n label?: string;\n placeholder?: string;\n /** The field's own incomplete-value message. Server rejections surface through `RegionError`. */\n errorMessage?: string;\n};\n\nexport type RegionSubmitProps = ComponentPropsWithRef<'button'> & {\n label?: string;\n pendingLabel?: string;\n /** Merchant-authored copy; wins over the props when present. */\n $content?: ContentValue<typeof RegionSubmitContent>;\n};\n\n/** Children are omitted: what this renders is the write's own error, never authored content. */\nexport type RegionErrorProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & {\n /** Merchant-authored fallback copy; wins over the prop when present. */\n $content?: ContentValue<typeof RegionErrorContent>;\n};\n\nexport type RegionUnknownLinkProps = ComponentPropsWithRef<'a'> & {\n /** Merchant-authored text and destination; each wins over its prop when present. */\n $content?: ContentValue<typeof RegionUnknownLinkContent>;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const RegionRootDefinition = defineComponent<RegionRootProps>({\n name: 'RegionRoot',\n importPath: '@vtex/faststore/components',\n component: RegionRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'region',\n actions: { region: ['setPostalCode'] },\n editor: { label: 'Region Root', category: 'content' },\n schema: {},\n guideline:\n 'Provides region context and reads the active postal code and city reactively. Place it in the shared header layout and compose RegionTrigger, RegionValue, RegionLoading, and a RegionModalController inside it. Every Region* component must be a descendant. See region.md.',\n});\n\nexport const RegionTriggerDefinition = defineComponent<RegionTriggerProps>({\n name: 'RegionTrigger',\n importPath: '@vtex/faststore/components',\n component: RegionTrigger,\n content: RegionTriggerContent,\n requiresContext: 'region',\n editor: { label: 'Region Trigger', category: 'action' },\n schema: {\n unsetLabel: { type: 'string', default: 'Informe seu CEP', label: 'Label when no region is set' },\n },\n guideline:\n 'Opens the region modal. Shows its unset label while no region is set; compose RegionValue as its child so the active region reads inside the control once one is. Its accessible name carries the active region, so a screen reader announces where the shopper is shopping. Must be inside RegionRoot.',\n});\n\nexport const RegionValueDefinition = defineComponent<RegionValueProps>({\n name: 'RegionValue',\n importPath: '@vtex/faststore/components',\n component: RegionValue,\n requiresContext: 'region',\n editor: { label: 'Region Value', category: 'content' },\n schema: {},\n guideline:\n 'The active region, as city plus postal code. Renders nothing while the region is unresolved or unset, so it needs no visibility prop — place it inside RegionTrigger, or anywhere in the header that should echo the region. The city is wrapped in its own element (data-fs-region-value-city) so a store can style or hide it; when the contract resolves no city, the postal code renders alone with no separator. A plain space separates the two in the text, so the accessible name reads \"São Paulo 01310-100\"; a flex container strips it, so a gap swatch still sets the visible spacing. Must be inside RegionRoot.',\n});\n\nexport const RegionLoadingDefinition = defineComponent<RegionLoadingProps>({\n name: 'RegionLoading',\n importPath: '@vtex/faststore/components',\n component: RegionLoading,\n requiresContext: 'region',\n editor: { label: 'Region Loading', category: 'content' },\n schema: {},\n guideline:\n 'Renders its children only while the region read has not resolved. Supply a skeleton placeholder as its child, sized like the resolved display so the header does not reflow when the region arrives. RegionValue renders nothing while this branch is showing, so the two never double up. Must be inside RegionRoot.',\n});\n\nexport const RegionModalControllerDefinition = defineComponent<RegionModalControllerProps>({\n name: 'RegionModalController',\n importPath: '@vtex/faststore/components',\n component: RegionModalController,\n requiresContext: 'region',\n editor: { label: 'Region Modal Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DialogRoot child (the region modal) and makes it controlled by the region state: RegionTrigger opens it, Escape and the backdrop close it, and a successful write closes it. Do not set raw open/onOpenChange on the wrapped DialogRoot. Compose DialogPortal, DialogBackdrop, DialogViewport and DialogPopup inside it, with DialogTitle and DialogDescription naming the dialog, and place a RegionForm holding RegionPostalCodeControl and RegionSubmit in the popup, alongside RegionError and RegionUnknownLink. Same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside RegionRoot.',\n});\n\nexport const RegionFormDefinition = defineComponent<RegionFormProps>({\n name: 'RegionForm',\n importPath: '@vtex/faststore/components',\n component: RegionForm,\n requiresContext: 'region',\n editor: { label: 'Region Form', category: 'action' },\n schema: {},\n guideline:\n 'Form wrapper holding RegionPostalCodeControl and RegionSubmit inside the region modal, so pressing Enter in the field submits. Same role as ShippingSimulatorForm. Compose it whenever both parts sit together; without it the shopper must reach the button, which still works but is not what a one-field form leads them to expect. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionPostalCodeControlDefinition = defineComponent<RegionPostalCodeControlProps>({\n name: 'RegionPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: RegionPostalCodeControl,\n requiresContext: 'region',\n editor: { label: 'Region Postal Code Control', category: 'content' },\n schema: {\n mask: { type: 'string', default: '99999-999', label: 'Mask pattern' },\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n errorMessage: { type: 'string', label: 'Incomplete-value message' },\n },\n guideline:\n 'The postal-code input inside the region modal: a PostalCodeField bound to the region draft, seeded from the persisted value every time the modal opens. Set mask to the country format at build time (default 99999-999, BR CEP). Server rejections mark the field invalid and take focus back to it; their message is shown by RegionError, not repeated here, and the first keystroke after one clears it. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionSubmitDefinition = defineComponent<RegionSubmitProps>({\n name: 'RegionSubmit',\n importPath: '@vtex/faststore/components',\n component: RegionSubmit,\n content: RegionSubmitContent,\n requiresContext: 'region',\n editor: { label: 'Region Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'Aplicar', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'Aplicando...', label: 'Pending label' },\n },\n guideline:\n \"Submits the region draft. Inside a RegionForm it is the form's submit button, which is what makes Enter in the field work; on its own it dispatches directly. Inert while empty and while a write is in flight, so a double activation dispatches one mutation; the pending state is exposed as aria-busy with no built-in spinner. On success the modal closes; on a rejection it stays open and RegionError explains why. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionErrorDefinition = defineComponent<RegionErrorProps>({\n name: 'RegionError',\n importPath: '@vtex/faststore/components',\n component: RegionError,\n content: RegionErrorContent,\n requiresContext: 'region',\n editor: { label: 'Region Error', category: 'content' },\n schema: {},\n guideline:\n \"Shows why the latest region write was refused, announced as an alert when it appears. Renders nothing when there is no error, so it needs no visibility prop. The server's own message is shown verbatim; the authored generic message covers a transport failure, where there is no server message to show. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionUnknownLinkDefinition = defineComponent<RegionUnknownLinkProps>({\n name: 'RegionUnknownLink',\n importPath: '@vtex/faststore/components',\n component: RegionUnknownLink,\n content: RegionUnknownLinkContent,\n requiresContext: 'region',\n editor: { label: 'Region Unknown Postal Code Link', category: 'navigation' },\n schema: {\n href: { type: 'string', label: 'Lookup service URL' },\n target: { type: ['_self', '_blank'] as const, default: '_self', label: 'Open in' },\n },\n guideline:\n 'The \"I don\\'t know my postal code\" escape hatch, pointing at a postal-code lookup service. Renders nothing until a destination is set, so a store without a lookup service composes it and simply gets no link rather than a dead one. Its text comes from authored content or its children. Must be inside a RegionModalController dialog.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the active region reactively and publishes it, the modal's draft, and the write state as\n * `region` context.\n *\n * The resolved value is never copied into state: `RegionValue` renders only what the fragment\n * resolves, and a successful write updates the display solely by the mutation payload normalizing\n * into the Apollo cache (Decision 5). That is why a rejected write needs no rollback and cannot\n * leave the header showing a postal code the server refused.\n */\nexport function RegionRoot({\n $data: $dataProp,\n $actions: $actionsProp,\n className,\n children,\n ...props\n}: RegionRootProps) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n const region = $data ?? null;\n const { loading: rootLoading } = useContext(ReactiveRootContext);\n // A null region is ambiguous on its own — an unresolved read and a shopper who never set one look\n // the same — so the root query's in-flight flag is what separates \"loading\" from \"unset\". Without\n // it a first-time shopper would sit under a skeleton forever instead of seeing the unset prompt.\n const loading = rootLoading && region == null;\n\n const postalCode = region?.postalCode ?? null;\n\n const [open, setOpenState] = useState(false);\n const [draft, setDraftState] = useState('');\n const [pending, setPending] = useState(false);\n const [errors, setErrors] = useState<readonly RegionUserError[]>([]);\n // State is batched, so two activations in one tick would both pass a `pending` check. The ref is\n // what makes \"exactly one mutation per activation\" hold.\n const inFlightRef = useRef(false);\n\n /**\n * Seeds the draft from the persisted value on open and clears it on close (Decision 6), so a\n * reopened modal always shows the truth rather than an abandoned edit.\n */\n const setOpen = useCallback(\n (next: boolean) => {\n setOpenState(next);\n setDraftState(next ? (postalCode ?? '') : '');\n setErrors([]);\n },\n [postalCode],\n );\n\n /**\n * Editing is the shopper's answer to a rejection, so the message and the invalid flag go with the\n * first keystroke. Left standing, they describe a value that is no longer in the field — and\n * `RegionPostalCodeControl`, which withholds its own incomplete-value copy while a rejection\n * stands, would stay silent for the whole edit. Returns the same array when there is nothing to\n * clear, so ordinary typing does not re-render the error subtree.\n */\n const setDraft = useCallback((value: string) => {\n setDraftState(value);\n setErrors((current) => (current.length === 0 ? current : []));\n }, []);\n\n const submit = useCallback(() => {\n if (inFlightRef.current) return;\n const setPostalCode = $actions?.region?.setPostalCode;\n if (!setPostalCode) return;\n\n inFlightRef.current = true;\n setPending(true);\n setErrors([]);\n\n void setPostalCode(draft)\n .then((writeErrors) => {\n if (writeErrors.length > 0) {\n // A rejection keeps the modal open so the message has somewhere to show (US-3).\n setErrors(writeErrors);\n return;\n }\n setOpenState(false);\n setDraftState('');\n })\n .finally(() => {\n inFlightRef.current = false;\n setPending(false);\n });\n }, [$actions, draft]);\n\n const value: RegionContextValue = useMemo(\n () => ({\n postalCode,\n city: region?.city ?? null,\n loading,\n draft,\n setDraft,\n pending,\n errors,\n open,\n setOpen,\n submit,\n }),\n [postalCode, region?.city, loading, draft, setDraft, pending, errors, open, setOpen, submit],\n );\n\n return (\n <RegionContextInternal value={value}>\n <div {...props} className={className} data-fs-region-root=\"\">\n {children}\n </div>\n </RegionContextInternal>\n );\n}\n\nexport function RegionTrigger({\n unsetLabel = 'Informe seu CEP',\n $content,\n className,\n children,\n ...props\n}: RegionTriggerProps) {\n const { postalCode, city, loading, setOpen } = useRegion();\n const isUnset = postalCode == null;\n\n const resolvedUnsetLabel = $content?.unsetLabel?.trim() ? $content.unsetLabel : unsetLabel;\n const authoredAriaLabel = $content?.ariaLabel?.trim() ? $content.ariaLabel : props['aria-label'];\n\n /**\n * WCAG 2.5.3 wants the accessible name to contain the visible label, so an authored label prefixes\n * the text on screen rather than replacing it: a name of \"Alterar região\" over text reading\n * \"Informe seu CEP\" leaves a voice-control user nothing to say. The region is spaced the way\n * `RegionValue` spaces it, since the name has to carry that text verbatim. Empty while the region\n * is unresolved, when the button reads nothing, and with no authored label the name falls back to\n * the text itself, which already satisfies the rule.\n */\n let visibleLabel = '';\n if (!loading) {\n visibleLabel = isUnset ? resolvedUnsetLabel : [city, postalCode].filter(Boolean).join(' ');\n }\n\n const ariaLabel = authoredAriaLabel && visibleLabel ? `${authoredAriaLabel}: ${visibleLabel}` : authoredAriaLabel;\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => setOpen(true)}\n // Not yet interactive while the region is unresolved: activating it would seed the draft from a\n // value that has not arrived.\n disabled={loading || props.disabled}\n aria-label={ariaLabel}\n className={className}\n data-fs-region-trigger=\"\"\n {...(isUnset ? { 'data-fs-region-trigger-unset': '' } : {})}\n >\n {isUnset && !loading ? resolvedUnsetLabel : null}\n {children}\n </button>\n );\n}\n\nexport function RegionValue({ className, ...props }: RegionValueProps) {\n const { postalCode, city, loading } = useRegion();\n if (loading || postalCode == null) return null;\n\n return (\n <span {...props} className={className} data-fs-region-value=\"\">\n {city ? <span data-fs-region-value-city=\"\">{city}</span> : null}\n {/* A real text node, not a styling concern: it is what separates the two values in the\n accessible name — this is the trigger's name whenever no aria-label is authored — and in any\n non-flex placement. It must stay a plain space: a flex container strips it as leading\n whitespace, so a store's `gap` still governs the visible spacing, where an &nbsp; would\n survive and widen the row. Absent with no city, so the postal code never renders padded. */}\n {city ? ' ' : null}\n {postalCode}\n </span>\n );\n}\n\nexport function RegionLoading({ className, children, ...props }: RegionLoadingProps) {\n const { loading } = useRegion();\n if (!loading) return null;\n\n return (\n <div {...props} className={className} data-fs-region-loading=\"\">\n {children}\n </div>\n );\n}\n\n/**\n * Makes the wrapped `DialogRoot` controlled by the region state. Mirrors\n * `ShippingAddressSavedAddressDrawerController`'s `cloneElement` mechanism; expects a single\n * `DialogRoot` child. Dismissal is never blocked — the Phase 1 modal is always dismissible.\n */\nexport function RegionModalController({ children }: RegionModalControllerProps) {\n const { open, setOpen } = useRegion();\n\n if (!isValidElement<Pick<DialogRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open,\n onOpenChange: (next: boolean) => setOpen(next),\n });\n}\n\n/**\n * Gives the field and the submit a form owner, so Enter in the postal code submits the way it does\n * in every other short form in the repo. Mirrors `ShippingSimulatorForm`: the form's only job is to\n * route native submission to the context's `submit()`.\n */\nexport function RegionForm({ className, children, ...props }: RegionFormProps) {\n const { submit } = useRegion();\n\n return (\n <RegionFormContext value={true}>\n <form\n {...props}\n className={className}\n data-fs-region-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n </RegionFormContext>\n );\n}\n\nexport function RegionPostalCodeControl({\n className,\n mask,\n label,\n placeholder,\n errorMessage,\n}: RegionPostalCodeControlProps) {\n const { draft, setDraft, errors, pending } = useRegion();\n const rootRef = useRef<HTMLDivElement>(null);\n const refused = errors.length > 0;\n\n /**\n * A refusal has to leave the shopper on the value they need to correct. Disabling the input while\n * the write is in flight blurs it and the browser drops focus to the document body, so a rejection\n * otherwise lands with nothing focused inside an open dialog — Enter does nothing and Tab restarts\n * from the top. Waits for `pending` to clear, because focusing a still-disabled input is a no-op:\n * the errors and the pending flag settle in separate microtasks, so there is a render in between\n * where the rejection is known and the field is not yet editable. The field is reached through the\n * root the way ClientProfileForm reaches its own fields.\n */\n useEffect(() => {\n if (!refused || pending) return;\n rootRef.current?.querySelector<HTMLInputElement>('[data-fs-postal-code-field-input]')?.focus();\n }, [refused, pending]);\n\n return (\n <PostalCodeField\n ref={rootRef}\n className={className}\n data-fs-region-postal-code-control=\"\"\n mask={mask}\n label={label}\n placeholder={placeholder}\n // The field renders this whenever it is invalid, from either source, so it is withheld while a\n // server rejection stands: that message is RegionError's, and the field's own copy describes an\n // incomplete value — wrong for a complete code the server refused, and contradictory stacked\n // under the real reason.\n errorMessage={errors.length > 0 ? undefined : errorMessage}\n value={draft}\n onValueChange={setDraft}\n // Still flagged invalid, so the refused value carries aria-invalid and the invalid styling.\n invalid={errors.length > 0}\n disabled={pending}\n />\n );\n}\n\nexport function RegionSubmit({\n label = 'Aplicar',\n pendingLabel = 'Aplicando...',\n $content,\n className,\n children,\n ...props\n}: RegionSubmitProps) {\n const { draft, pending, submit } = useRegion();\n const inForm = useContext(RegionFormContext);\n\n const resolvedLabel = $content?.label?.trim() ? $content.label : label;\n const resolvedPendingLabel = $content?.pendingLabel?.trim() ? $content.pendingLabel : pendingLabel;\n\n return (\n <button\n {...props}\n // The form routes native submission to the same submit(); alone there is no form to submit.\n type={inForm ? 'submit' : 'button'}\n onClick={inForm ? props.onClick : submit}\n disabled={pending || draft.trim() === '' || props.disabled}\n aria-busy={pending || undefined}\n className={className}\n data-fs-region-submit=\"\"\n {...(pending ? { 'data-fs-region-submit-pending': '' } : {})}\n >\n {children ?? (pending ? resolvedPendingLabel : resolvedLabel)}\n </button>\n );\n}\n\n/**\n * The catalog copy for each rejection the client can name: the server's `RegionErrorCode` values plus\n * the client-minted transport failure. The server's own `message` is English, so it is shown only for\n * a code this map does not know — a newer server than this package.\n */\nconst REGION_ERROR_MESSAGE_IDS: Readonly<Record<string, MessageId>> = {\n INVALID_POSTAL_CODE: 'fs/region.error.invalid-postal-code',\n UNSERVED_POSTAL_CODE: 'fs/region.error.unserved-postal-code',\n NETWORK_ERROR: 'fs/region.error.network',\n};\n\nexport function RegionError({ $content, className, ...props }: RegionErrorProps) {\n const { errors } = useRegion();\n const intl = useIntl();\n if (errors.length === 0) return null;\n\n const genericMessage = $content?.genericMessage?.trim() ? $content.genericMessage : null;\n\n function copyFor(error: RegionUserError): string {\n // A transport failure carries no server message worth showing a shopper, so the authored\n // generic copy wins there and only there. Every other code the catalog knows renders in the\n // store's language; a code it does not know falls back to the server's own message.\n if (error.code === 'NETWORK_ERROR' && genericMessage) return genericMessage;\n const id = error.code ? REGION_ERROR_MESSAGE_IDS[error.code] : undefined;\n return id ? intl.formatMessage({ id }) : error.message;\n }\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-region-error=\"\">\n {errors.map((error) => (\n <div key={`${error.code ?? ''}${error.message}`}>{copyFor(error)}</div>\n ))}\n </div>\n );\n}\n\nexport function RegionUnknownLink({ $content, className, children, href, rel, ...props }: RegionUnknownLinkProps) {\n // Called for its guard alone: a part placed outside a RegionRoot must fail here the way its\n // siblings do, even though this one reads nothing from the context.\n useRegion();\n\n const authoredHref = $content?.href?.trim() ? $content.href : href?.trim();\n // Absent is \"no link\", the ordinary shape for a store with no lookup service, so it never reaches\n // the allowlist or the log.\n if (!authoredHref) return null;\n\n // No read-time validator enforces the model's `format` or `pattern`, so this is the only gate on\n // the CMS value.\n const destination = resolveSafeHref(authoredHref);\n if (!destination.safe) {\n // A bounded reason and no authored value, the convention the content runtime's own log follows.\n console.warn('[RegionUnknownLink] link destination rejected', { reason: destination.reason });\n return null;\n }\n\n const text = $content?.text?.trim() ? $content.text : children;\n if (!text) return null;\n\n // A lookup service is a natural new-tab destination, so a store may pass target. The tab-nabbing\n // defense is then this component's responsibility, not the composer's — the same contract\n // NavigationLink states. Target keywords and link types are both ASCII case-insensitive per HTML,\n // so _BLANK opens a new tab and a caller-passed NOOPENER already counts.\n const relTokens = rel?.split(/\\s+/).filter(Boolean) ?? [];\n const present = new Set(relTokens.map((token) => token.toLowerCase()));\n const safeRel =\n props.target?.toLowerCase() === '_blank'\n ? [...relTokens, ...['noopener', 'noreferrer'].filter((token) => !present.has(token))].join(' ')\n : rel;\n\n return (\n <a {...props} href={destination.href} rel={safeRel} className={className} data-fs-region-unknown-link=\"\">\n {text}\n </a>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const Region = {\n Root: RegionRoot,\n Trigger: RegionTrigger,\n Value: RegionValue,\n Loading: RegionLoading,\n ModalController: RegionModalController,\n Form: RegionForm,\n PostalCodeControl: RegionPostalCodeControl,\n Submit: RegionSubmit,\n Error: RegionError,\n UnknownLink: RegionUnknownLink,\n};\n"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,WAAW,QAAQ;;;;;;CAMxB;AAMD,MAAa,uBAAuB,kBAAkB;CACpD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,YAAY;IAAE,MAAM;IAAU,OAAO;GAA8B;GACnE,WAAW;IAAE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