@doswiftly/storefront-sdk 21.0.0 → 22.0.0

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 (62) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +818 -527
  3. package/dist/core/auth/handlers.d.ts +10 -9
  4. package/dist/core/auth/handlers.d.ts.map +1 -1
  5. package/dist/core/auth/handlers.js +10 -9
  6. package/dist/core/auth/session-events.d.ts +2 -2
  7. package/dist/core/auth/session-events.js +2 -2
  8. package/dist/core/cart/cart-client.d.ts +23 -24
  9. package/dist/core/cart/cart-client.d.ts.map +1 -1
  10. package/dist/core/cart/cart-client.js +24 -25
  11. package/dist/core/generated/operation-types.d.ts +52 -52
  12. package/dist/core/generated/operation-types.d.ts.map +1 -1
  13. package/dist/core/index.d.ts +1 -0
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +2 -0
  16. package/dist/core/middleware/session-retry.d.ts +5 -6
  17. package/dist/core/middleware/session-retry.d.ts.map +1 -1
  18. package/dist/core/middleware/session-retry.js +7 -8
  19. package/dist/core/operations/auth.d.ts.map +1 -1
  20. package/dist/core/operations/auth.js +4 -0
  21. package/dist/core/operations/cart.d.ts +11 -10
  22. package/dist/core/operations/cart.d.ts.map +1 -1
  23. package/dist/core/operations/cart.js +14 -11
  24. package/dist/core/referral/cookie-config.d.ts +56 -0
  25. package/dist/core/referral/cookie-config.d.ts.map +1 -0
  26. package/dist/core/referral/cookie-config.js +83 -0
  27. package/dist/react/components/PaymentInstrumentSection.d.ts +24 -24
  28. package/dist/react/components/PaymentInstrumentSection.d.ts.map +1 -1
  29. package/dist/react/components/PaymentInstrumentSection.js +15 -15
  30. package/dist/react/components/PaymentInstrumentTile.d.ts +19 -20
  31. package/dist/react/components/PaymentInstrumentTile.d.ts.map +1 -1
  32. package/dist/react/components/PaymentInstrumentTile.js +15 -16
  33. package/dist/react/helpers/browser-data.d.ts +30 -33
  34. package/dist/react/helpers/browser-data.d.ts.map +1 -1
  35. package/dist/react/helpers/browser-data.js +26 -29
  36. package/dist/react/hooks/use-cart-manager.d.ts +1 -1
  37. package/dist/react/hooks/use-cart-manager.js +1 -1
  38. package/dist/react/hooks/use-cart.d.ts +2 -2
  39. package/dist/react/hooks/use-cart.js +3 -3
  40. package/dist/react/hooks/use-referral-capture.d.ts +9 -0
  41. package/dist/react/hooks/use-referral-capture.d.ts.map +1 -0
  42. package/dist/react/hooks/use-referral-capture.js +40 -0
  43. package/dist/react/hooks/use-session-expired.d.ts +6 -5
  44. package/dist/react/hooks/use-session-expired.d.ts.map +1 -1
  45. package/dist/react/hooks/use-session-expired.js +6 -5
  46. package/dist/react/index.d.ts +2 -0
  47. package/dist/react/index.d.ts.map +1 -1
  48. package/dist/react/index.js +5 -1
  49. package/dist/react/referral.d.ts +53 -0
  50. package/dist/react/referral.d.ts.map +1 -0
  51. package/dist/react/referral.js +51 -0
  52. package/dist/react/server/cookie-readers.d.ts +7 -0
  53. package/dist/react/server/cookie-readers.d.ts.map +1 -1
  54. package/dist/react/server/cookie-readers.js +10 -0
  55. package/dist/react/server/index.d.ts +1 -1
  56. package/dist/react/server/index.d.ts.map +1 -1
  57. package/dist/react/server/index.js +2 -2
  58. package/dist/react/stores/auth.store.d.ts.map +1 -1
  59. package/dist/react/stores/auth.store.js +13 -10
  60. package/dist/react/stores/cart.store.d.ts +1 -1
  61. package/dist/react/stores/cart.store.js +1 -1
  62. package/package.json +1 -1
@@ -67,6 +67,7 @@ export { AUTH_COOKIE_NAME, AUTH_COOKIE_DEFAULTS, type AuthCookieConfig, REFRESH_
67
67
  export { LANGUAGE_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_HEADER_NAME } from './language/cookie-config';
68
68
  export { CURRENCY_COOKIE_NAME, CURRENCY_COOKIE_MAX_AGE, CURRENCY_HEADER_NAME } from './currency/cookie-config';
69
69
  export { CART_COOKIE_NAME, CART_COOKIE_MAX_AGE, parseCartCookieValue, formatCartCookieValue, type CartCredentials, } from './cart/cookie-config';
70
+ export { REFERRAL_COOKIE_NAME, REFERRAL_COOKIE_MAX_AGE, REFERRAL_CODE_MAX_LENGTH, REFERRAL_CODE_PATTERN, extractReferralCodeFromUrl, } from './referral/cookie-config';
70
71
  export { matchesRoute, type RouteProtectionConfig } from './auth/routes';
71
72
  export { createSetTokenHandler, createClearTokenHandler, createWhoamiHandler, originAllowlistValidator, trustedForwardedHostValidator, } from './auth/handlers';
72
73
  export type { OriginValidator, OriginValidatorContext } from './auth/handlers';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAGxG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,8BAA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GE_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_HEADER_NAME } f
84
84
  export { CURRENCY_COOKIE_NAME, CURRENCY_COOKIE_MAX_AGE, CURRENCY_HEADER_NAME } from './currency/cookie-config';
85
85
  // Cart cookie config + composite value parser/formatter (`<cartId>.<secret>`)
86
86
  export { CART_COOKIE_NAME, CART_COOKIE_MAX_AGE, parseCartCookieValue, formatCartCookieValue, } from './cart/cookie-config';
87
+ // Referral cookie config + URL extractor (loyalty referral program capture)
88
+ export { REFERRAL_COOKIE_NAME, REFERRAL_COOKIE_MAX_AGE, REFERRAL_CODE_MAX_LENGTH, REFERRAL_CODE_PATTERN, extractReferralCodeFromUrl, } from './referral/cookie-config';
87
89
  // Auth route matching
88
90
  export { matchesRoute } from './auth/routes';
89
91
  // Auth cookie handlers (API route factories)
@@ -4,15 +4,14 @@
4
4
  * When a request fails with HTTP 401 (the access token lapsed between the
5
5
  * proactive refresh and this call):
6
6
  *
7
- * - **Read query** — refresh the session once and replay the request (R2.1).
7
+ * - **Read query** — refresh the session once and replay the request.
8
8
  * Because this middleware is the outermost one, the retry re-runs the auth
9
9
  * middleware, which re-reads the freshly-stored token. Concurrent 401s share
10
- * a single renewal because the injected `refresh` dedupes in-flight calls
11
- * (R2.2). If the refresh also fails, the session is gone — signal and bail
12
- * (R2.4).
10
+ * a single renewal because the injected `refresh` dedupes in-flight calls.
11
+ * If the refresh also fails, the session is gone — signal and bail.
13
12
  *
14
13
  * - **Mutation** — never auto-retry (mutations are sacred; client-side
15
- * idempotency is not guaranteed). Bail and signal the session loss (R2.3).
14
+ * idempotency is not guaranteed). Bail and signal the session loss.
16
15
  *
17
16
  * Auth operations (login / signup / refresh / logout) are exempt: they own
18
17
  * their own error handling, and retrying the refresh op itself would recurse.
@@ -35,7 +34,7 @@ export interface SessionRetryOptions {
35
34
  /**
36
35
  * Renew the session (refresh token → cookie sync → store update). Resolves
37
36
  * `true` on success. MUST dedupe concurrent calls so simultaneous 401s share
38
- * a single renewal (R2.2).
37
+ * a single renewal.
39
38
  */
40
39
  refresh: () => Promise<boolean>;
41
40
  /** Notify that the session is gone (a mutation 401, or a query whose refresh-retry failed). */
@@ -1 +1 @@
1
- {"version":3,"file":"session-retry.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/session-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQlE,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,+FAA+F;IAC/F,gBAAgB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAMD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,UAAU,CAgC/E"}
1
+ {"version":3,"file":"session-retry.d.ts","sourceRoot":"","sources":["../../../src/core/middleware/session-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQlE,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,+FAA+F;IAC/F,gBAAgB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAMD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,UAAU,CAgC/E"}
@@ -4,15 +4,14 @@
4
4
  * When a request fails with HTTP 401 (the access token lapsed between the
5
5
  * proactive refresh and this call):
6
6
  *
7
- * - **Read query** — refresh the session once and replay the request (R2.1).
7
+ * - **Read query** — refresh the session once and replay the request.
8
8
  * Because this middleware is the outermost one, the retry re-runs the auth
9
9
  * middleware, which re-reads the freshly-stored token. Concurrent 401s share
10
- * a single renewal because the injected `refresh` dedupes in-flight calls
11
- * (R2.2). If the refresh also fails, the session is gone — signal and bail
12
- * (R2.4).
10
+ * a single renewal because the injected `refresh` dedupes in-flight calls.
11
+ * If the refresh also fails, the session is gone — signal and bail.
13
12
  *
14
13
  * - **Mutation** — never auto-retry (mutations are sacred; client-side
15
- * idempotency is not guaranteed). Bail and signal the session loss (R2.3).
14
+ * idempotency is not guaranteed). Bail and signal the session loss.
16
15
  *
17
16
  * Auth operations (login / signup / refresh / logout) are exempt: they own
18
17
  * their own error handling, and retrying the refresh op itself would recurse.
@@ -52,14 +51,14 @@ export function sessionRetryMiddleware(options) {
52
51
  if (!isUnauthorized(err))
53
52
  throw err;
54
53
  if (request.isMutation) {
55
- // R2.3 — mutations are sacred: bail, never auto-retry.
54
+ // Mutations are sacred: bail, never auto-retry.
56
55
  onSessionExpired({ reason: 'mutation-unauthorized', cause: err });
57
56
  throw err;
58
57
  }
59
- // R2.1 / R2.2 — read query: refresh once (deduped) and replay.
58
+ // Read query: refresh once (deduped) and replay.
60
59
  const renewed = await refresh();
61
60
  if (!renewed) {
62
- // R2.4 — the refresh also failed; the session is gone.
61
+ // The refresh also failed; the session is gone.
63
62
  onSessionExpired({ reason: 'reactive-refresh-failed', cause: err });
64
63
  throw err;
65
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/operations/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsHH,eAAO,MAAM,cAAc,QASzB,CAAC;AAEH,eAAO,MAAM,eAAe,QAS1B,CAAC;AAEH,eAAO,MAAM,sBAAsB,QASjC,CAAC;AAEH,eAAO,MAAM,eAAe,QAW1B,CAAC;AAMH,eAAO,MAAM,cAAc,QAOzB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAYnC,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/operations/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA0HH,eAAO,MAAM,cAAc,QASzB,CAAC;AAEH,eAAO,MAAM,eAAe,QAS1B,CAAC;AAEH,eAAO,MAAM,sBAAsB,QASjC,CAAC;AAEH,eAAO,MAAM,eAAe,QAW1B,CAAC;AAMH,eAAO,MAAM,cAAc,QAOzB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAYnC,CAAC"}
@@ -53,6 +53,8 @@ const MAILING_ADDRESS_FRAGMENT_AUTH = `
53
53
  company
54
54
  streetLine1
55
55
  streetLine2
56
+ buildingNumber
57
+ flatNumber
56
58
  city
57
59
  state
58
60
  stateCode
@@ -90,6 +92,8 @@ const CUSTOMER_FRAGMENT = `
90
92
  id
91
93
  streetLine1
92
94
  streetLine2
95
+ buildingNumber
96
+ flatNumber
93
97
  city
94
98
  company
95
99
  country
@@ -85,7 +85,7 @@ export declare const CART_UPDATE_GIFT_CARD_RECIPIENT: string;
85
85
  * flow decisions). The cart itself is NOT returned — after completion it is
86
86
  * CONVERTED/locked, so the storefront drops its local cart and works with the
87
87
  * Order. `order` is non-null on success. `paymentUrl` is intentionally NOT in
88
- * the payload (Decision D4) — the storefront calls a separate `paymentCreate`
88
+ * the payload — the payment session is created by a separate `paymentCreate`
89
89
  * mutation after checking `order.canCreatePayment`.
90
90
  */
91
91
  export declare const CART_COMPLETE: string;
@@ -97,19 +97,20 @@ export declare const CART_COMPLETE: string;
97
97
  */
98
98
  export declare const PAYMENT_CREATE: string;
99
99
  /**
100
- * cartClearPaymentSelection Mutation (Adv-1 Phase A1-2) explicit deselect
101
- * dla storefront accordion UI ("wróć do wyboru metody"). Atomic NULL na
102
- * wszystkich 4 payment selection fields, idempotent. Cart MUSI być ACTIVE
103
- * (CONVERTED reject z `ALREADY_COMPLETED`).
100
+ * cartClearPaymentSelection Mutation explicit deselect for "back to payment
101
+ * method selection" storefront accordion UI. Atomically NULLs all 4 payment
102
+ * selection fields, idempotent. The cart MUST be ACTIVE (CONVERTED carts are
103
+ * rejected with `ALREADY_COMPLETED`).
104
104
  */
105
105
  export declare const CART_CLEAR_PAYMENT_SELECTION: string;
106
106
  /**
107
- * cartValidateDiscountCode Query — read-only preview discount applicability
108
- * (Decision D3). No cart side effects; storefront UI używa do inline feedback
109
- * gdy klient wpisuje kod (przed wywołaniem cartDiscountCodesUpdate).
107
+ * cartValidateDiscountCode Query — read-only preview of discount applicability;
108
+ * validation must not mutate cart state. No cart side effects; storefront UI
109
+ * uses it for inline feedback while the customer types a code (before calling
110
+ * cartDiscountCodesUpdate).
110
111
  *
111
- * Caching guidance: `fetchPolicy: 'network-only'` lub key zawierający
112
- * `cart.subtotal` (discount eligibility może zależeć od minimum order amount).
112
+ * Caching guidance: `fetchPolicy: 'network-only'` or a key that includes
113
+ * `cart.subtotal` (discount eligibility may depend on a minimum order amount).
113
114
  */
114
115
  export declare const CART_VALIDATE_DISCOUNT_CODE: string;
115
116
  //# sourceMappingURL=cart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsbH,eAAO,MAAM,UAAU,QAOrB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,QAehD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,QAO1C,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAO/B,CAAC;AAMH,eAAO,MAAM,WAAW,QAYtB,CAAC;AAEH,eAAO,MAAM,cAAc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QAO/B,CAAC;AAMH,eAAO,MAAM,WAAW,QAYtB,CAAC;AAEH,eAAO,MAAM,cAAc,QAWzB,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAW3B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAWjC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,QAWrB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,QAWnC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QAY/B,CAAC;AAMH,eAAO,MAAM,yBAAyB,QAWpC,CAAC;AAEH,eAAO,MAAM,wBAAwB,QAWnC,CAAC;AAEH,eAAO,MAAM,2BAA2B,QAWtC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAW/B,CAAC;AAEH,eAAO,MAAM,qBAAqB,QAWhC,CAAC;AAEH,eAAO,MAAM,+BAA+B,QAW1C,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAWxB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAWzB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAWvC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,QAoBtC,CAAC"}
@@ -162,6 +162,8 @@ const MAILING_ADDRESS_FRAGMENT = `
162
162
  company
163
163
  streetLine1
164
164
  streetLine2
165
+ buildingNumber
166
+ flatNumber
165
167
  city
166
168
  state
167
169
  stateCode
@@ -640,7 +642,7 @@ export const CART_RECOVERY_REDEEM = composeOperation(`
640
642
  ${CART_WARNING_FRAGMENT}
641
643
  `);
642
644
  // ---------------------------------------------------------------------------
643
- // Phase 3 — Cart completion lifecycle mutations
645
+ // Cart completion lifecycle mutations
644
646
  // ---------------------------------------------------------------------------
645
647
  export const CART_SET_SHIPPING_ADDRESS = composeOperation(`
646
648
  mutation CartSetShippingAddress($input: CartSetShippingAddressInput!) {
@@ -732,7 +734,7 @@ export const CART_UPDATE_GIFT_CARD_RECIPIENT = composeOperation(`
732
734
  * flow decisions). The cart itself is NOT returned — after completion it is
733
735
  * CONVERTED/locked, so the storefront drops its local cart and works with the
734
736
  * Order. `order` is non-null on success. `paymentUrl` is intentionally NOT in
735
- * the payload (Decision D4) — the storefront calls a separate `paymentCreate`
737
+ * the payload — the payment session is created by a separate `paymentCreate`
736
738
  * mutation after checking `order.canCreatePayment`.
737
739
  */
738
740
  export const CART_COMPLETE = composeOperation(`
@@ -766,10 +768,10 @@ export const PAYMENT_CREATE = composeOperation(`
766
768
  ${PAYMENT_WARNING_FRAGMENT}
767
769
  `);
768
770
  /**
769
- * cartClearPaymentSelection Mutation (Adv-1 Phase A1-2) explicit deselect
770
- * dla storefront accordion UI ("wróć do wyboru metody"). Atomic NULL na
771
- * wszystkich 4 payment selection fields, idempotent. Cart MUSI być ACTIVE
772
- * (CONVERTED reject z `ALREADY_COMPLETED`).
771
+ * cartClearPaymentSelection Mutation explicit deselect for "back to payment
772
+ * method selection" storefront accordion UI. Atomically NULLs all 4 payment
773
+ * selection fields, idempotent. The cart MUST be ACTIVE (CONVERTED carts are
774
+ * rejected with `ALREADY_COMPLETED`).
773
775
  */
774
776
  export const CART_CLEAR_PAYMENT_SELECTION = composeOperation(`
775
777
  mutation CartClearPaymentSelection($input: CartClearPaymentSelectionInput!) {
@@ -784,12 +786,13 @@ export const CART_CLEAR_PAYMENT_SELECTION = composeOperation(`
784
786
  ${CART_WARNING_FRAGMENT}
785
787
  `);
786
788
  /**
787
- * cartValidateDiscountCode Query — read-only preview discount applicability
788
- * (Decision D3). No cart side effects; storefront UI używa do inline feedback
789
- * gdy klient wpisuje kod (przed wywołaniem cartDiscountCodesUpdate).
789
+ * cartValidateDiscountCode Query — read-only preview of discount applicability;
790
+ * validation must not mutate cart state. No cart side effects; storefront UI
791
+ * uses it for inline feedback while the customer types a code (before calling
792
+ * cartDiscountCodesUpdate).
790
793
  *
791
- * Caching guidance: `fetchPolicy: 'network-only'` lub key zawierający
792
- * `cart.subtotal` (discount eligibility może zależeć od minimum order amount).
794
+ * Caching guidance: `fetchPolicy: 'network-only'` or a key that includes
795
+ * `cart.subtotal` (discount eligibility may depend on a minimum order amount).
793
796
  */
794
797
  export const CART_VALIDATE_DISCOUNT_CODE = composeOperation(`
795
798
  query CartValidateDiscountCode($cartId: ID!, $discountCode: String!) {
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Referral cookie configuration — platform contract.
3
+ *
4
+ * When a visitor lands on the storefront through a referral link
5
+ * (`https://shop.example/register?ref=REF-AB12CD34`), the code must survive
6
+ * navigation until the visitor actually signs up — possibly minutes or days
7
+ * later. The SDK persists it in a readable first-party cookie and the signup
8
+ * form passes it to `customerSignup(input: { referralCode })`.
9
+ *
10
+ * Used by:
11
+ * - `captureReferralCode` / `useReferralCapture` (client-side capture on landing)
12
+ * - `readReferralCodeCookie` (client + server readers at signup time)
13
+ */
14
+ export declare const REFERRAL_COOKIE_NAME = "referral-code";
15
+ /**
16
+ * Default cookie lifetime: 30 days.
17
+ *
18
+ * This is the "landing → signup" window only. It is intentionally NOT tied to
19
+ * the shop's referral validity setting (days the referred customer has to
20
+ * place their first order) — that window starts at signup and is validated
21
+ * exclusively by the backend. Coupling the two would be wrong: a shop giving
22
+ * referred customers 7 days to order would silently lose visitors who sign up
23
+ * 8 days after clicking the link. Override per call via
24
+ * `captureReferralCode({ maxAge })` if you need a different capture window.
25
+ */
26
+ export declare const REFERRAL_COOKIE_MAX_AGE: number;
27
+ /**
28
+ * Maximum accepted code length — longer values are ignored as garbage.
29
+ * Mirrors the `customerSignup` input contract (the API rejects longer codes).
30
+ */
31
+ export declare const REFERRAL_CODE_MAX_LENGTH = 50;
32
+ /**
33
+ * Accepted code shape: letters, digits and dashes (codes are case-insensitive —
34
+ * the API uppercases on lookup). Mirrors the platform referral-code charset;
35
+ * a non-conforming value is never persisted to the cookie, because the API
36
+ * would silently ignore it at signup anyway — storing it for 30 days would
37
+ * just carry dead weight (or someone's injection attempt) around. Widen this
38
+ * pattern only together with the `customerSignup.referralCode` API contract.
39
+ */
40
+ export declare const REFERRAL_CODE_PATTERN: RegExp;
41
+ /**
42
+ * Extract a referral code from a URL or a search string.
43
+ *
44
+ * Accepts a full or relative URL (`https://shop.example/register?ref=CODE`,
45
+ * `/register?ref=CODE`), a search string starting with `?` (`?ref=CODE`) or a
46
+ * `URL` instance. Returns the trimmed code, or `null` when the parameter is
47
+ * absent, empty, longer than {@link REFERRAL_CODE_MAX_LENGTH} or outside
48
+ * {@link REFERRAL_CODE_PATTERN} (such values would be ignored by the API
49
+ * anyway, so they are never persisted).
50
+ *
51
+ * @param input - URL, `URL` instance or `?`-prefixed search string to inspect.
52
+ * @param paramName - Query parameter carrying the code (default `'ref'` —
53
+ * matches the share links generated by the platform).
54
+ */
55
+ export declare function extractReferralCodeFromUrl(input: string | URL, paramName?: string): string | null;
56
+ //# sourceMappingURL=cookie-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie-config.d.ts","sourceRoot":"","sources":["../../../src/core/referral/cookie-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,QAAoB,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,QAAoB,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,SAAS,SAAQ,GAAG,MAAM,GAAG,IAAI,CAyBhG"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Referral cookie configuration — platform contract.
3
+ *
4
+ * When a visitor lands on the storefront through a referral link
5
+ * (`https://shop.example/register?ref=REF-AB12CD34`), the code must survive
6
+ * navigation until the visitor actually signs up — possibly minutes or days
7
+ * later. The SDK persists it in a readable first-party cookie and the signup
8
+ * form passes it to `customerSignup(input: { referralCode })`.
9
+ *
10
+ * Used by:
11
+ * - `captureReferralCode` / `useReferralCapture` (client-side capture on landing)
12
+ * - `readReferralCodeCookie` (client + server readers at signup time)
13
+ */
14
+ export const REFERRAL_COOKIE_NAME = 'referral-code';
15
+ /**
16
+ * Default cookie lifetime: 30 days.
17
+ *
18
+ * This is the "landing → signup" window only. It is intentionally NOT tied to
19
+ * the shop's referral validity setting (days the referred customer has to
20
+ * place their first order) — that window starts at signup and is validated
21
+ * exclusively by the backend. Coupling the two would be wrong: a shop giving
22
+ * referred customers 7 days to order would silently lose visitors who sign up
23
+ * 8 days after clicking the link. Override per call via
24
+ * `captureReferralCode({ maxAge })` if you need a different capture window.
25
+ */
26
+ export const REFERRAL_COOKIE_MAX_AGE = 30 * 24 * 60 * 60; // 30 days
27
+ /**
28
+ * Maximum accepted code length — longer values are ignored as garbage.
29
+ * Mirrors the `customerSignup` input contract (the API rejects longer codes).
30
+ */
31
+ export const REFERRAL_CODE_MAX_LENGTH = 50;
32
+ /**
33
+ * Accepted code shape: letters, digits and dashes (codes are case-insensitive —
34
+ * the API uppercases on lookup). Mirrors the platform referral-code charset;
35
+ * a non-conforming value is never persisted to the cookie, because the API
36
+ * would silently ignore it at signup anyway — storing it for 30 days would
37
+ * just carry dead weight (or someone's injection attempt) around. Widen this
38
+ * pattern only together with the `customerSignup.referralCode` API contract.
39
+ */
40
+ export const REFERRAL_CODE_PATTERN = /^[A-Za-z0-9-]+$/;
41
+ /**
42
+ * Extract a referral code from a URL or a search string.
43
+ *
44
+ * Accepts a full or relative URL (`https://shop.example/register?ref=CODE`,
45
+ * `/register?ref=CODE`), a search string starting with `?` (`?ref=CODE`) or a
46
+ * `URL` instance. Returns the trimmed code, or `null` when the parameter is
47
+ * absent, empty, longer than {@link REFERRAL_CODE_MAX_LENGTH} or outside
48
+ * {@link REFERRAL_CODE_PATTERN} (such values would be ignored by the API
49
+ * anyway, so they are never persisted).
50
+ *
51
+ * @param input - URL, `URL` instance or `?`-prefixed search string to inspect.
52
+ * @param paramName - Query parameter carrying the code (default `'ref'` —
53
+ * matches the share links generated by the platform).
54
+ */
55
+ export function extractReferralCodeFromUrl(input, paramName = 'ref') {
56
+ let params;
57
+ if (input instanceof URL) {
58
+ params = input.searchParams;
59
+ }
60
+ else {
61
+ const raw = input.trim();
62
+ if (!raw)
63
+ return null;
64
+ if (raw.startsWith('?')) {
65
+ // Search-string form: "?ref=CODE&utm_source=x"
66
+ params = new URLSearchParams(raw.slice(1));
67
+ }
68
+ else {
69
+ // Full or relative URL — the base argument makes relative paths
70
+ // ("/register?ref=CODE") parse too.
71
+ try {
72
+ params = new URL(raw, 'http://localhost').searchParams;
73
+ }
74
+ catch {
75
+ return null;
76
+ }
77
+ }
78
+ }
79
+ const value = params.get(paramName)?.trim() ?? '';
80
+ if (!value || value.length > REFERRAL_CODE_MAX_LENGTH || !REFERRAL_CODE_PATTERN.test(value))
81
+ return null;
82
+ return value;
83
+ }
@@ -1,17 +1,18 @@
1
1
  /**
2
- * `<PaymentInstrumentSection>` — radio-group container dla payment instruments
3
- * w obrębie jednej method (np. lista bankow + BLIK code entry w BLIK method,
4
- * lista wallets + brand cards w CARD method). Renders jeden `<PaymentInstrumentTile>`
5
- * per item z keyboard nav (Arrow Up/Down, Home/End) + ARIA `role="radiogroup"`.
2
+ * `<PaymentInstrumentSection>` — radio-group container for the payment
3
+ * instruments within a single method (e.g. a bank list + BLIK code entry in a
4
+ * BLIK method, wallets + card brands in a CARD method). Renders one
5
+ * `<PaymentInstrumentTile>` per item with keyboard nav (Arrow Up/Down,
6
+ * Home/End) + ARIA `role="radiogroup"`.
6
7
  *
7
- * Headless — section + tiles bez własnego stylingu. Pass `sectionClassName`
8
- * dla layoutu (grid/flex), `tileClassName` dla per-tile styling, optional
9
- * `iconClassName`/`labelClassName` dla wewnętrznej struktury tile.
8
+ * Headless — section + tiles ship without any styling. Pass `sectionClassName`
9
+ * for the layout (grid/flex), `tileClassName` for per-tile styling, optional
10
+ * `iconClassName`/`labelClassName` for the tile's inner structure.
10
11
  *
11
- * Auto-group **nie jest** implementowane w tym sub-sprincie backend już
12
- * zwraca instruments sorted (BLIK + wallets pierwsze → banks alpha → others)
13
- * z `availablePaymentMethods.methods[].instruments[]`. Komponent renderuje
14
- * w order'ze otrzymanym, bez własnej resort logic.
12
+ * Auto-grouping is **not** implemented the backend already returns
13
+ * instruments sorted (BLIK + wallets first → banks alphabetically → others)
14
+ * in `availablePaymentMethods.methods[].instruments[]`. The component renders
15
+ * them in the order received, with no re-sorting logic of its own.
15
16
  *
16
17
  * @example
17
18
  * ```tsx
@@ -24,32 +25,31 @@
24
25
  * tileClassName="rounded border p-3 data-[selected=true]:border-blue-500"
25
26
  * />
26
27
  * ```
27
- *
28
- * Added by payment-instrument-preselection-advanced sub-sprint Adv-2 Req 9.
29
28
  */
30
29
  import type { PaymentMethod } from '../../core/generated/operation-types';
31
30
  /**
32
- * Minimalna projekcja `PaymentMethod` używana przez section — wymaga tylko
33
- * `instruments[]`. Caller może pass pełną `PaymentMethod` z `availablePaymentMethods`
34
- * query — extra pola (id, name, providersAvailable, etc.) są ignorowane.
31
+ * Minimal projection of `PaymentMethod` used by the section — only
32
+ * `instruments[]` is required. The caller may pass a full `PaymentMethod` from
33
+ * the `availablePaymentMethods` query — extra fields (id, name,
34
+ * providersAvailable, etc.) are ignored.
35
35
  */
36
36
  export type PaymentInstrumentSectionMethod = Pick<PaymentMethod, 'instruments'>;
37
37
  export interface PaymentInstrumentSectionProps {
38
- /** Payment method z `instruments[]` listą (null/empty → komponent zwraca null). */
38
+ /** Payment method with an `instruments[]` list (null/empty → the component returns null). */
39
39
  method: PaymentInstrumentSectionMethod;
40
- /** Currently selected instrument code — controlled by parent. Undefined gdy buyer nie wybrał. */
40
+ /** Currently selected instrument code — controlled by parent. Undefined when the buyer has not picked one yet. */
41
41
  selectedInstrumentCode?: string;
42
- /** Callback gdy buyer selektuje instrument. Parent persistuje state + odpala `cartSelectPaymentMethod`. */
42
+ /** Callback fired when the buyer selects an instrument. The parent persists the state + calls `cartSelectPaymentMethod`. */
43
43
  onSelectInstrument: (instrumentCode: string) => void;
44
- /** Optional class dla outer section element — typically grid/flex layout. */
44
+ /** Optional class for the outer section element — typically grid/flex layout. */
45
45
  sectionClassName?: string;
46
- /** Optional class dla each `<PaymentInstrumentTile>` — passed jako `className`. */
46
+ /** Optional class for each `<PaymentInstrumentTile>` — passed as `className`. */
47
47
  tileClassName?: string;
48
- /** Optional class dla brand image inside tiles — passed jako `iconClassName`. */
48
+ /** Optional class for the brand image inside tiles — passed as `iconClassName`. */
49
49
  iconClassName?: string;
50
- /** Optional class dla label span inside tiles — passed jako `labelClassName`. */
50
+ /** Optional class for the label span inside tiles — passed as `labelClassName`. */
51
51
  labelClassName?: string;
52
- /** Optional ARIA label dla radiogroup. Defaults to nothing (caller's responsibility — section typically nested w wider label structure). */
52
+ /** Optional ARIA label for the radiogroup. Defaults to nothing (caller's responsibility — the section is typically nested in a wider label structure). */
53
53
  ariaLabel?: string;
54
54
  }
55
55
  export declare function PaymentInstrumentSection({ method, selectedInstrumentCode, onSelectInstrument, sectionClassName, tileClassName, iconClassName, labelClassName, ariaLabel, }: PaymentInstrumentSectionProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentInstrumentSection.d.ts","sourceRoot":"","sources":["../../../src/react/components/PaymentInstrumentSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,sCAAsC,CAAC;AAG7F;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAEhF,MAAM,WAAW,6BAA6B;IAC5C,mFAAmF;IACnF,MAAM,EAAE,8BAA8B,CAAC;IACvC,iGAAiG;IACjG,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,2GAA2G;IAC3G,kBAAkB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4IAA4I;IAC5I,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,SAAS,GACV,EAAE,6BAA6B,kDAmF/B"}
1
+ {"version":3,"file":"PaymentInstrumentSection.d.ts","sourceRoot":"","sources":["../../../src/react/components/PaymentInstrumentSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,sCAAsC,CAAC;AAG7F;;;;;GAKG;AACH,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAEhF,MAAM,WAAW,6BAA6B;IAC5C,6FAA6F;IAC7F,MAAM,EAAE,8BAA8B,CAAC;IACvC,kHAAkH;IAClH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,4HAA4H;IAC5H,kBAAkB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0JAA0J;IAC1J,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,SAAS,GACV,EAAE,6BAA6B,kDAoF/B"}
@@ -1,17 +1,18 @@
1
1
  /**
2
- * `<PaymentInstrumentSection>` — radio-group container dla payment instruments
3
- * w obrębie jednej method (np. lista bankow + BLIK code entry w BLIK method,
4
- * lista wallets + brand cards w CARD method). Renders jeden `<PaymentInstrumentTile>`
5
- * per item z keyboard nav (Arrow Up/Down, Home/End) + ARIA `role="radiogroup"`.
2
+ * `<PaymentInstrumentSection>` — radio-group container for the payment
3
+ * instruments within a single method (e.g. a bank list + BLIK code entry in a
4
+ * BLIK method, wallets + card brands in a CARD method). Renders one
5
+ * `<PaymentInstrumentTile>` per item with keyboard nav (Arrow Up/Down,
6
+ * Home/End) + ARIA `role="radiogroup"`.
6
7
  *
7
- * Headless — section + tiles bez własnego stylingu. Pass `sectionClassName`
8
- * dla layoutu (grid/flex), `tileClassName` dla per-tile styling, optional
9
- * `iconClassName`/`labelClassName` dla wewnętrznej struktury tile.
8
+ * Headless — section + tiles ship without any styling. Pass `sectionClassName`
9
+ * for the layout (grid/flex), `tileClassName` for per-tile styling, optional
10
+ * `iconClassName`/`labelClassName` for the tile's inner structure.
10
11
  *
11
- * Auto-group **nie jest** implementowane w tym sub-sprincie backend już
12
- * zwraca instruments sorted (BLIK + wallets pierwsze → banks alpha → others)
13
- * z `availablePaymentMethods.methods[].instruments[]`. Komponent renderuje
14
- * w order'ze otrzymanym, bez własnej resort logic.
12
+ * Auto-grouping is **not** implemented the backend already returns
13
+ * instruments sorted (BLIK + wallets first → banks alphabetically → others)
14
+ * in `availablePaymentMethods.methods[].instruments[]`. The component renders
15
+ * them in the order received, with no re-sorting logic of its own.
15
16
  *
16
17
  * @example
17
18
  * ```tsx
@@ -24,8 +25,6 @@
24
25
  * tileClassName="rounded border p-3 data-[selected=true]:border-blue-500"
25
26
  * />
26
27
  * ```
27
- *
28
- * Added by payment-instrument-preselection-advanced sub-sprint Adv-2 Req 9.
29
28
  */
30
29
  'use client';
31
30
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -75,8 +74,9 @@ export function PaymentInstrumentSection({ method, selectedInstrumentCode, onSel
75
74
  return null;
76
75
  }
77
76
  return (_jsx("div", { ref: sectionRef, role: "radiogroup", "aria-label": ariaLabel, onKeyDown: handleKeyDown, className: sectionClassName, children: instruments.map((instrument) => {
78
- // Cast to tile-projection shape — instruments[] z generated types ma więcej pól
79
- // niż tile potrzebuje (provider, type), tile picks subset jawnie.
77
+ // Cast to the tile-projection shape — instruments[] from the generated
78
+ // types carries more fields than the tile needs (provider, type); the
79
+ // tile picks its subset explicitly.
80
80
  const tileInstrument = {
81
81
  code: instrument.code,
82
82
  displayName: instrument.displayName,
@@ -1,21 +1,22 @@
1
1
  /**
2
2
  * `<PaymentInstrumentTile>` — single payment instrument tile (BLIK code,
3
- * bank logo, wallet button, card brand). Headless — buyer-facing button
4
- * z accessibility wbudowanym (`role="radio"`, `aria-checked`, `aria-label`,
5
- * `data-instrument-code`, `data-display-hint`). Pass className per part
6
- * (button, icon, label) żeby zintegrować z Tailwind / CSS Modules /
7
- * styled-components — komponent nie ma własnego stylingu.
3
+ * bank logo, wallet button, card brand). Headless — a buyer-facing button
4
+ * with accessibility built in (`role="radio"`, `aria-checked`, `aria-label`,
5
+ * `data-instrument-code`, `data-display-hint`). Pass a className per part
6
+ * (button, icon, label) to integrate with Tailwind / CSS Modules /
7
+ * styled-components — the component has no styling of its own.
8
8
  *
9
- * `displayHint` dispatch — backend hint jak storefront powinien renderować
10
- * instrument. Komponent emituje hint jako `data-display-hint` attribute na
11
- * `<button>` żeby caller mógł stylizować przez CSS attribute selektory:
9
+ * `displayHint` dispatch — a backend hint describing how the storefront should
10
+ * render the instrument. The component emits the hint as a `data-display-hint`
11
+ * attribute on the `<button>` so the caller can style it through CSS attribute
12
+ * selectors:
12
13
  *
13
- * - `BRANDED_TILE` — bank logo / wallet icon dominuje, label jako caption.
14
- * - `PROMINENT_BUTTON` — duże CTA (BLIK code entry), brand image pominięty.
15
- * - `RADIO_OPTION` — radio-list look, image (jeśli is) + label inline.
16
- * - `DROPDOWN_OPTION` — text-only dla dropdown integration (caller wrap).
14
+ * - `BRANDED_TILE` — bank logo / wallet icon dominates, label as a caption.
15
+ * - `PROMINENT_BUTTON` — large CTA (BLIK code entry), brand image omitted.
16
+ * - `RADIO_OPTION` — radio-list look, image (when present) + label inline.
17
+ * - `DROPDOWN_OPTION` — text-only for dropdown integration (caller wraps it).
17
18
  *
18
- * Headless = no opinion. CSS styling decyduje, komponent tylko hint'uje.
19
+ * Headless = no opinion. CSS styling decides, the component only hints.
19
20
  *
20
21
  * @example
21
22
  * ```tsx
@@ -27,21 +28,19 @@
27
28
  * labelClassName="font-semibold"
28
29
  * />
29
30
  * ```
30
- *
31
- * Added by payment-instrument-preselection-advanced sub-sprint Adv-2 Req 9.
32
31
  */
33
32
  import type { PaymentInstrument } from '../../core/generated/operation-types';
34
33
  /**
35
- * Minimalna projekcja `PaymentInstrument` używana przez tile. Caller może
36
- * pass pełny instrument z `availablePaymentMethods` query — extra pola
37
- * (provider, type) ignorowane przez komponent (UI nie branchuje na
38
- * provider — gateway-agnostic, code + displayHint wystarczą).
34
+ * Minimal projection of `PaymentInstrument` used by the tile. The caller may
35
+ * pass a full instrument from the `availablePaymentMethods` query — extra
36
+ * fields (provider, type) are ignored by the component (the UI never branches
37
+ * on the provider — gateway-agnostic, code + displayHint are enough).
39
38
  */
40
39
  export type PaymentInstrumentTileInstrument = Pick<PaymentInstrument, 'code' | 'displayName' | 'displayHint' | 'enabled'> & Partial<Pick<PaymentInstrument, 'brandImage'>>;
41
40
  export interface PaymentInstrumentTileProps {
42
41
  /** Instrument projection — gateway code, label, display hint, enabled state. */
43
42
  instrument: PaymentInstrumentTileInstrument;
44
- /** True gdy ten tile jest currently selected w parent section. Controls `aria-checked` + `data-selected`. */
43
+ /** True when this tile is currently selected in the parent section. Controls `aria-checked` + `data-selected`. */
45
44
  selected: boolean;
46
45
  /** Click handler — caller updates selected state external (controlled component). */
47
46
  onSelect: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentInstrumentTile.d.ts","sourceRoot":"","sources":["../../../src/react/components/PaymentInstrumentTile.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAChD,iBAAiB,EACjB,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CACnD,GACC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC,CAAC;AAEjD,MAAM,WAAW,0BAA0B;IACzC,gFAAgF;IAChF,UAAU,EAAE,+BAA+B,CAAC;IAC5C,6GAA6G;IAC7G,QAAQ,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,GACf,EAAE,0BAA0B,2CAuB5B"}
1
+ {"version":3,"file":"PaymentInstrumentTile.d.ts","sourceRoot":"","sources":["../../../src/react/components/PaymentInstrumentTile.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAChD,iBAAiB,EACjB,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CACnD,GACC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC,CAAC;AAEjD,MAAM,WAAW,0BAA0B;IACzC,gFAAgF;IAChF,UAAU,EAAE,+BAA+B,CAAC;IAC5C,kHAAkH;IAClH,QAAQ,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,GACf,EAAE,0BAA0B,2CAuB5B"}