@economist/web-apple-pay 0.1.1-beta.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 (55) hide show
  1. package/README.md +186 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1642 -0
  4. package/dist/src/apple-pay-button.d.ts +45 -0
  5. package/dist/src/apple-pay-button.js +1621 -0
  6. package/dist/src/apple-pay-button.stories.js +1934 -0
  7. package/dist/src/apple-pay-logo.d.ts +1 -0
  8. package/dist/src/apple-pay-logo.js +14 -0
  9. package/dist/src/apple-pay-modal.d.ts +12 -0
  10. package/dist/src/apple-pay-modal.js +442 -0
  11. package/dist/src/apple-pay-modal.stories.js +1778 -0
  12. package/dist/src/clients/payment-checkout/apple-session.d.ts +18 -0
  13. package/dist/src/clients/payment-checkout/apple-session.js +243 -0
  14. package/dist/src/clients/payment-checkout/billing-contact-details.d.ts +21 -0
  15. package/dist/src/clients/payment-checkout/billing-contact-details.js +109 -0
  16. package/dist/src/clients/payment-checkout/config.d.ts +9 -0
  17. package/dist/src/clients/payment-checkout/config.js +23 -0
  18. package/dist/src/clients/payment-checkout/contact-validation.d.ts +21 -0
  19. package/dist/src/clients/payment-checkout/contact-validation.js +50 -0
  20. package/dist/src/clients/payment-checkout/detects.d.ts +3 -0
  21. package/dist/src/clients/payment-checkout/detects.js +56 -0
  22. package/dist/src/clients/payment-checkout/index.d.ts +5 -0
  23. package/dist/src/clients/payment-checkout/index.js +83 -0
  24. package/dist/src/clients/payment-checkout/messages.d.ts +33 -0
  25. package/dist/src/clients/payment-checkout/messages.js +19 -0
  26. package/dist/src/clients/payment-checkout/payment-handler.d.ts +36 -0
  27. package/dist/src/clients/payment-checkout/payment-handler.js +389 -0
  28. package/dist/src/clients/payment-checkout/session.d.ts +2 -0
  29. package/dist/src/clients/payment-checkout/session.js +67 -0
  30. package/dist/src/clients/payment-checkout/shipping-contact-details.d.ts +10 -0
  31. package/dist/src/clients/payment-checkout/shipping-contact-details.js +83 -0
  32. package/dist/src/clients/payment-checkout/types.d.ts +118 -0
  33. package/dist/src/clients/payment-checkout/types.js +14 -0
  34. package/dist/src/index.d.ts +7 -0
  35. package/dist/src/index.js +1642 -0
  36. package/dist/src/stories/fixtures/offer.d.ts +2 -0
  37. package/dist/src/stories/fixtures/offer.js +28 -0
  38. package/dist/src/stories/utils/story-env.d.ts +11 -0
  39. package/dist/src/stories/utils/story-env.js +148 -0
  40. package/dist/src/types/html-template.d.js +0 -0
  41. package/dist/src/types/offer.types.d.ts +73 -0
  42. package/dist/src/types/offer.types.js +0 -0
  43. package/dist/src/utils/billing-countries.d.ts +19 -0
  44. package/dist/src/utils/billing-countries.js +263 -0
  45. package/dist/src/utils/define.d.ts +1 -0
  46. package/dist/src/utils/define.js +9 -0
  47. package/dist/src/utils/expressCheckoutRedirect.d.ts +55 -0
  48. package/dist/src/utils/expressCheckoutRedirect.js +46 -0
  49. package/dist/src/utils/expressCheckoutTracking.d.ts +64 -0
  50. package/dist/src/utils/expressCheckoutTracking.js +84 -0
  51. package/dist/src/utils/pricing.d.ts +1 -0
  52. package/dist/src/utils/pricing.js +60 -0
  53. package/dist/src/utils/recaptcha.d.ts +22 -0
  54. package/dist/src/utils/recaptcha.js +54 -0
  55. package/package.json +64 -0
@@ -0,0 +1,45 @@
1
+ import type { Offer, ProductVariant } from './types/offer.types';
2
+ export declare const APPLE_PAY_EXCLUDED_VARIANTS: readonly ProductVariant[];
3
+ export declare class ApplePayButton extends HTMLElement {
4
+ #private;
5
+ static readonly tag = "teg-apple-pay-button";
6
+ static define(): void;
7
+ /**
8
+ * Creates and configures an ApplePayButton if the feature flag is present.
9
+ */
10
+ static createIfEnabled(offer: Offer | undefined, country: string, entryPoint: string): ApplePayButton | null;
11
+ get offer(): Offer | null;
12
+ set offer(value: Offer | null);
13
+ get country(): string;
14
+ set country(value: string);
15
+ get entryPoint(): string;
16
+ set entryPoint(value: string);
17
+ /**
18
+ * Awaitable contract for the component's current render lifecycle.
19
+ *
20
+ * - If called **after** the element has been appended to the DOM, resolves
21
+ * once `connectedCallback` finishes — whether Apple Pay rendered
22
+ * successfully or was hidden (unavailable / suppressed by session).
23
+ * - If called **before** the element is appended (or if it has never been
24
+ * connected), resolves immediately to `undefined`. It does **not** wait
25
+ * for a future connection, so always `await whenReady()` after `appendChild`:
26
+ *
27
+ * ```ts
28
+ * container.appendChild(btn); // browser fires connectedCallback
29
+ * await btn.whenReady(); // waits for render to finish
30
+ * if (btn.style.display !== 'none') { /* available *\/ }
31
+ * ```
32
+ */
33
+ whenReady(): Promise<void>;
34
+ connectedCallback(): Promise<void>;
35
+ /**
36
+ * Resets all render state when the element is removed from the DOM.
37
+ *
38
+ * A shared library component cannot assume it won't be moved in the DOM
39
+ * (e.g. lazy panels, SPA route changes). Resetting on disconnect means
40
+ * reattach always triggers a fresh `#run()` — new session check, new payment
41
+ * options fetch, fresh event listeners — preventing stale data from persisting
42
+ * and eliminating the implicit reliance on the DOM as a render-state flag.
43
+ */
44
+ disconnectedCallback(): void;
45
+ }