@mainmoneyapp/js-angular 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,4 +56,4 @@ export class PayComponent implements OnInit {
56
56
  - The widget runs outside the Angular zone, so its polling and debounce timers do not trigger change detection.
57
57
  - Create the `Checkout` once. Never build it in a template expression or getter.
58
58
  - On `ngOnDestroy` of the host page call `checkout.close()` to stop status polling.
59
- - The merchant backend must allow CORS for your origin, see the main README ("CORS").
59
+ - The merchant backend must allow CORS for your origin, see [docs/troubleshooting.md](../../docs/troubleshooting.md) and [docs/frameworks/angular.md](../../docs/frameworks/angular.md).
@@ -19,7 +19,8 @@ class CheckoutWizardComponent {
19
19
  constructor() {
20
20
  this.checkout = input.required(...(ngDevMode ? [{ debugName: "checkout" }] : /* istanbul ignore next */ []));
21
21
  this.logoUrl = input(undefined, ...(ngDevMode ? [{ debugName: "logoUrl" }] : /* istanbul ignore next */ []));
22
- this.colorScheme = input("auto", ...(ngDevMode ? [{ debugName: "colorScheme" }] : /* istanbul ignore next */ []));
22
+ /** Leave unset to keep the scheme given to `createCheckout` (default `auto`). */
23
+ this.colorScheme = input(undefined, ...(ngDevMode ? [{ debugName: "colorScheme" }] : /* istanbul ignore next */ []));
23
24
  this.variant = input("default", ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
24
25
  /** `form` is the single-page checkout (default for deposits); `wizard` is the step-by-step flow. */
25
26
  this.layout = input(undefined, ...(ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []));
@@ -53,7 +54,7 @@ class CheckoutWizardComponent {
53
54
  effect(() => {
54
55
  const scheme = this.colorScheme();
55
56
  const checkout = this.checkout();
56
- if (this.isBrowser) {
57
+ if (this.isBrowser && scheme !== undefined) {
57
58
  this.zone.runOutsideAngular(() => checkout.setColorScheme(scheme));
58
59
  }
59
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"mainmoneyapp-js-angular.mjs","sources":["../../src/index.ts","../../src/mainmoneyapp-js-angular.ts"],"sourcesContent":["import { isPlatformBrowser } from \"@angular/common\";\nimport { Component, ElementRef, NgZone, PLATFORM_ID, effect, inject, input, untracked, viewChild } from \"@angular/core\";\n\nimport type { Checkout, CheckoutVariant, ColorScheme, MountOptions } from \"@mainmoneyapp/js-checkout\";\nimport { mountCheckout } from \"@mainmoneyapp/js-checkout\";\n\n/**\n * Checkout wizard. Import `@mainmoneyapp/js-checkout/styles.css` once in your app\n * (`angular.json` -> `styles`, or `src/main.ts`).\n *\n * - The DOM mount only runs in the browser, so the component is safe under SSR.\n * - The widget runs **outside the Angular zone**: its debounce timers, status polling and fetch calls would\n * otherwise trigger a change-detection pass each. It renders its own DOM and never needs Angular to.\n * - Create the `Checkout` once (in `ngOnInit`, a service or a signal), not in a template expression or getter:\n * a new `Checkout` instance restarts the widget from the first step.\n * - `colorScheme` follows your theme signal: every change calls `checkout.setColorScheme`, which only flips the\n * palette (the form is not re-rendered, so a focused input keeps its focus and value).\n */\n@Component({\n selector: \"mm-checkout-wizard\",\n standalone: true,\n template: \"<div #host></div>\",\n})\nexport class CheckoutWizardComponent {\n readonly checkout = input.required<Checkout>();\n readonly logoUrl = input<string | undefined>(undefined);\n readonly colorScheme = input<ColorScheme>(\"auto\");\n readonly variant = input<CheckoutVariant>(\"default\");\n /** `form` is the single-page checkout (default for deposits); `wizard` is the step-by-step flow. */\n readonly layout = input<MountOptions[\"layout\"]>(undefined);\n /** Country preselected in the form layout. */\n readonly defaultCountry = input<string | undefined>(undefined);\n /** Footer links; only links with a URL are shown. */\n readonly links = input<MountOptions[\"links\"]>(undefined);\n private readonly host = viewChild.required<ElementRef<HTMLElement>>(\"host\");\n\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly zone = inject(NgZone);\n\n constructor() {\n effect((onCleanup) => {\n if (!this.isBrowser) {\n return;\n }\n // Track only the inputs that must restart the widget; the host element is stable.\n const checkout = this.checkout();\n const options: MountOptions = {\n logoUrl: this.logoUrl(),\n variant: this.variant(),\n layout: this.layout(),\n defaultCountry: this.defaultCountry(),\n links: this.links(),\n };\n const element = untracked(() => this.host().nativeElement);\n const unmount = this.zone.runOutsideAngular(() => mountCheckout(element, checkout, options));\n onCleanup(() => {\n unmount();\n element.replaceChildren();\n });\n });\n effect(() => {\n const scheme = this.colorScheme();\n const checkout = this.checkout();\n if (this.isBrowser) {\n this.zone.runOutsideAngular(() => checkout.setColorScheme(scheme));\n }\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAMA;;;;;;;;;;;AAWG;MAMU,uBAAuB,CAAA;AAgBlC,IAAA,WAAA,GAAA;AAfS,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,QAAQ,8EAAY;AACrC,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAqB,SAAS,8EAAC;AAC9C,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAc,MAAM,kFAAC;AACxC,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAkB,SAAS,8EAAC;;AAE3C,QAAA,IAAA,CAAA,MAAM,GAAG,KAAK,CAAyB,SAAS,6EAAC;;AAEjD,QAAA,IAAA,CAAA,cAAc,GAAG,KAAK,CAAqB,SAAS,qFAAC;;AAErD,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAwB,SAAS,4EAAC;AACvC,QAAA,IAAA,CAAA,IAAI,GAAG,SAAS,CAAC,QAAQ,CAA0B,MAAM,CAAC;QAE1D,IAAA,CAAA,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAClD,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;AAGpC,QAAA,MAAM,CAAC,CAAC,SAAS,KAAI;AACnB,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB;YACF;;AAE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,uBAAuB,olCAFxB,mBAAmB,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,CAAA;;4FAElB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBALnC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,mBAAmB;AAC9B,iBAAA;+vBAYqE,MAAM,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AClC5E;;AAEG;;;;"}
1
+ {"version":3,"file":"mainmoneyapp-js-angular.mjs","sources":["../../src/index.ts","../../src/mainmoneyapp-js-angular.ts"],"sourcesContent":["import { isPlatformBrowser } from \"@angular/common\";\nimport { Component, ElementRef, NgZone, PLATFORM_ID, effect, inject, input, untracked, viewChild } from \"@angular/core\";\n\nimport type { Checkout, CheckoutVariant, ColorScheme, MountOptions } from \"@mainmoneyapp/js-checkout\";\nimport { mountCheckout } from \"@mainmoneyapp/js-checkout\";\n\n/**\n * Checkout wizard. Import `@mainmoneyapp/js-checkout/styles.css` once in your app\n * (`angular.json` -> `styles`, or `src/main.ts`).\n *\n * - The DOM mount only runs in the browser, so the component is safe under SSR.\n * - The widget runs **outside the Angular zone**: its debounce timers, status polling and fetch calls would\n * otherwise trigger a change-detection pass each. It renders its own DOM and never needs Angular to.\n * - Create the `Checkout` once (in `ngOnInit`, a service or a signal), not in a template expression or getter:\n * a new `Checkout` instance restarts the widget from the first step.\n * - `colorScheme` follows your theme signal: every change calls `checkout.setColorScheme`, which only flips the\n * palette (the form is not re-rendered, so a focused input keeps its focus and value).\n */\n@Component({\n selector: \"mm-checkout-wizard\",\n standalone: true,\n template: \"<div #host></div>\",\n})\nexport class CheckoutWizardComponent {\n readonly checkout = input.required<Checkout>();\n readonly logoUrl = input<string | undefined>(undefined);\n /** Leave unset to keep the scheme given to `createCheckout` (default `auto`). */\n readonly colorScheme = input<ColorScheme | undefined>(undefined);\n readonly variant = input<CheckoutVariant>(\"default\");\n /** `form` is the single-page checkout (default for deposits); `wizard` is the step-by-step flow. */\n readonly layout = input<MountOptions[\"layout\"]>(undefined);\n /** Country preselected in the form layout. */\n readonly defaultCountry = input<string | undefined>(undefined);\n /** Footer links; only links with a URL are shown. */\n readonly links = input<MountOptions[\"links\"]>(undefined);\n private readonly host = viewChild.required<ElementRef<HTMLElement>>(\"host\");\n\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly zone = inject(NgZone);\n\n constructor() {\n effect((onCleanup) => {\n if (!this.isBrowser) {\n return;\n }\n // Track only the inputs that must restart the widget; the host element is stable.\n const checkout = this.checkout();\n const options: MountOptions = {\n logoUrl: this.logoUrl(),\n variant: this.variant(),\n layout: this.layout(),\n defaultCountry: this.defaultCountry(),\n links: this.links(),\n };\n const element = untracked(() => this.host().nativeElement);\n const unmount = this.zone.runOutsideAngular(() => mountCheckout(element, checkout, options));\n onCleanup(() => {\n unmount();\n element.replaceChildren();\n });\n });\n effect(() => {\n const scheme = this.colorScheme();\n const checkout = this.checkout();\n if (this.isBrowser && scheme !== undefined) {\n this.zone.runOutsideAngular(() => checkout.setColorScheme(scheme));\n }\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAMA;;;;;;;;;;;AAWG;MAMU,uBAAuB,CAAA;AAiBlC,IAAA,WAAA,GAAA;AAhBS,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,QAAQ,8EAAY;AACrC,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAqB,SAAS,8EAAC;;AAE9C,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAA0B,SAAS,kFAAC;AACvD,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAkB,SAAS,8EAAC;;AAE3C,QAAA,IAAA,CAAA,MAAM,GAAG,KAAK,CAAyB,SAAS,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AQ,GAAG,IAAI,CAAC,QAAQ,EAAE;YAChC,IAAI,IAAI,CAAC,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE;AAC1C,gBAAA,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACpE;AACF,QAAA,CAAC,CAAC;IACJ;+GA7CW,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAvB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,uBAAuB,olCAFxB,mBAAmB,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,CAAA;;4FAElB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBALnC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,mBAAmB;AAC9B,iBAAA;+vBAaqE,MAAM,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;ACnC5E;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mainmoneyapp/js-angular",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Angular checkout wizard for the MainMoney JS/TS frontend SDK",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "@angular/core": ">=17.2"
30
30
  },
31
31
  "dependencies": {
32
- "@mainmoneyapp/js-checkout": "0.2.0",
32
+ "@mainmoneyapp/js-checkout": "0.2.2",
33
33
  "tslib": "^2.8.1"
34
34
  },
35
35
  "module": "fesm2022/mainmoneyapp-js-angular.mjs",
@@ -16,7 +16,8 @@ import { Checkout, ColorScheme, CheckoutVariant } from '@mainmoneyapp/js-checkou
16
16
  declare class CheckoutWizardComponent {
17
17
  readonly checkout: _angular_core.InputSignal<Checkout>;
18
18
  readonly logoUrl: _angular_core.InputSignal<string | undefined>;
19
- readonly colorScheme: _angular_core.InputSignal<ColorScheme>;
19
+ /** Leave unset to keep the scheme given to `createCheckout` (default `auto`). */
20
+ readonly colorScheme: _angular_core.InputSignal<ColorScheme | undefined>;
20
21
  readonly variant: _angular_core.InputSignal<CheckoutVariant>;
21
22
  /** `form` is the single-page checkout (default for deposits); `wizard` is the step-by-step flow. */
22
23
  readonly layout: _angular_core.InputSignal<"form" | "wizard" | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"mainmoneyapp-js-angular.d.ts","sources":["../../src/index.ts"],"mappings":";;;AAMA;;;;;;;;;;;AAWG;AACH,cAKa,uBAAuB;uBACjB,aAAA,CAAA,WAAA,CAAA,QAAA;sBACD,aAAA,CAAA,WAAA;0BACI,aAAA,CAAA,WAAA,CAAA,WAAA;sBACJ,aAAA,CAAA,WAAA,CAAA,eAAA;;qBAED,aAAA,CAAA,WAAA;;6BAEQ,aAAA,CAAA,WAAA;;oBAET,aAAA,CAAA,WAAA,CAAA,OAAA,CAAA,MAAA;AACd;AAEA;AACA;;oDAdW,uBAAuB;sDAAvB,uBAAuB;AA6CnC;;;;","names":[]}
1
+ {"version":3,"file":"mainmoneyapp-js-angular.d.ts","sources":["../../src/index.ts"],"mappings":";;;AAMA;;;;;;;;;;;AAWG;AACH,cAKa,uBAAuB;uBACjB,aAAA,CAAA,WAAA,CAAA,QAAA;sBACD,aAAA,CAAA,WAAA;;0BAEI,aAAA,CAAA,WAAA,CAAA,WAAA;sBACJ,aAAA,CAAA,WAAA,CAAA,eAAA;;qBAED,aAAA,CAAA,WAAA;;6BAEQ,aAAA,CAAA,WAAA;;oBAET,aAAA,CAAA,WAAA,CAAA,OAAA,CAAA,MAAA;AACd;AAEA;AACA;;oDAfW,uBAAuB;sDAAvB,uBAAuB;AA8CnC;;;;","names":[]}