@xpayeg/sdk 2.3.0 → 2.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @xpayeg/sdk
2
2
 
3
+ ## 2.4.0
4
+ ### Minor Changes
5
+
6
+
7
+
8
+ - [#474](https://github.com/xpayeg/xpay/pull/474) [`c45243c`](https://github.com/xpayeg/xpay/commit/c45243c970b71944482352baea8e8047ba746d8b) Thanks [@Elmosh](https://github.com/Elmosh)! - The Payment Element's `layout` option now works: `elements.create("payment", { layout })`, or the `options` prop on `<PaymentElement />`. `"accordion"` (default) is the vertical list; `"tabs"` is a wrapping tile grid with the selected method's form below it. With exactly one payment method the chooser chrome collapses: the accordion shows a static logo-and-name header above the content (card keeps its bare form), and tabs render the content alone with no logo or title, for pages whose own UI already shows the method's identity, such as a per-gateway row paired with `paymentMethodTypes: ["<type>"]`. Layout is updatable after creation via `element.update({ layout })`, and every method's form stays mounted across switches so typed card details survive.
9
+
3
10
  ## 2.3.0
4
11
  ### Minor Changes
5
12
 
package/dist/index.d.cts CHANGED
@@ -3751,7 +3751,23 @@ interface ElementsLoadErrorEvent {
3751
3751
  }
3752
3752
  /** Options for creating a PaymentElement */
3753
3753
  interface PaymentElementOptions {
3754
- /** Layout style for the payment method selector — `"accordion"` (default) or `"tabs"` */
3754
+ /**
3755
+ * How the element presents the payment method chooser.
3756
+ *
3757
+ * - `"accordion"` (default): a vertical list, one row per method, the
3758
+ * selected method's content expanding beneath its row. With exactly one
3759
+ * method the chooser disappears: a single non-card method shows a static
3760
+ * identity header (logo and name, no radio) above its content, while a
3761
+ * single card method renders the bare card form, since its fields
3762
+ * already identify it.
3763
+ * - `"tabs"`: a grid of tiles that fills the row and wraps when the
3764
+ * methods no longer fit, with the selected method's content below it.
3765
+ * With exactly one method the tile grid disappears and
3766
+ * only the content renders, for pages whose own UI already shows the
3767
+ * method's logo and name (e.g. a per-gateway plugin row).
3768
+ *
3769
+ * Updatable after creation via `element.update({ layout })`.
3770
+ */
3755
3771
  layout?: "accordion" | "tabs";
3756
3772
  /** Pre-select a specific payment method by type */
3757
3773
  defaultPaymentMethod?: string;
@@ -3808,12 +3824,19 @@ interface BaseElement {
3808
3824
  on(event: string, handler: (...args: unknown[]) => void): void;
3809
3825
  off(event: string, handler: (...args: unknown[]) => void): void;
3810
3826
  }
3827
+ /**
3828
+ * The subset of `PaymentElementOptions` that can be updated after creation
3829
+ * (Stripe's `StripePaymentElementUpdateOptions` pattern). Only `layout` is
3830
+ * updatable; `defaultPaymentMethod` and `paymentMethodOrder` are set at
3831
+ * creation.
3832
+ */
3833
+ type PaymentElementUpdateOptions = Pick<PaymentElementOptions, "layout">;
3811
3834
  /** PaymentElement — full payment method selector with card form */
3812
3835
  interface PaymentElement extends BaseElement {
3813
3836
  /** Collapse the payment method selector (deselect all methods) */
3814
3837
  collapse(): void;
3815
- /** Update element options at runtime */
3816
- update(options: Partial<PaymentElementOptions>): void;
3838
+ /** Update element options at runtime — see {@link PaymentElementUpdateOptions} */
3839
+ update(options: PaymentElementUpdateOptions): void;
3817
3840
  }
3818
3841
  /**
3819
3842
  * Options for `confirmPayment()` or `checkout.confirm()`.
package/dist/index.d.mts CHANGED
@@ -3751,7 +3751,23 @@ interface ElementsLoadErrorEvent {
3751
3751
  }
3752
3752
  /** Options for creating a PaymentElement */
3753
3753
  interface PaymentElementOptions {
3754
- /** Layout style for the payment method selector — `"accordion"` (default) or `"tabs"` */
3754
+ /**
3755
+ * How the element presents the payment method chooser.
3756
+ *
3757
+ * - `"accordion"` (default): a vertical list, one row per method, the
3758
+ * selected method's content expanding beneath its row. With exactly one
3759
+ * method the chooser disappears: a single non-card method shows a static
3760
+ * identity header (logo and name, no radio) above its content, while a
3761
+ * single card method renders the bare card form, since its fields
3762
+ * already identify it.
3763
+ * - `"tabs"`: a grid of tiles that fills the row and wraps when the
3764
+ * methods no longer fit, with the selected method's content below it.
3765
+ * With exactly one method the tile grid disappears and
3766
+ * only the content renders, for pages whose own UI already shows the
3767
+ * method's logo and name (e.g. a per-gateway plugin row).
3768
+ *
3769
+ * Updatable after creation via `element.update({ layout })`.
3770
+ */
3755
3771
  layout?: "accordion" | "tabs";
3756
3772
  /** Pre-select a specific payment method by type */
3757
3773
  defaultPaymentMethod?: string;
@@ -3808,12 +3824,19 @@ interface BaseElement {
3808
3824
  on(event: string, handler: (...args: unknown[]) => void): void;
3809
3825
  off(event: string, handler: (...args: unknown[]) => void): void;
3810
3826
  }
3827
+ /**
3828
+ * The subset of `PaymentElementOptions` that can be updated after creation
3829
+ * (Stripe's `StripePaymentElementUpdateOptions` pattern). Only `layout` is
3830
+ * updatable; `defaultPaymentMethod` and `paymentMethodOrder` are set at
3831
+ * creation.
3832
+ */
3833
+ type PaymentElementUpdateOptions = Pick<PaymentElementOptions, "layout">;
3811
3834
  /** PaymentElement — full payment method selector with card form */
3812
3835
  interface PaymentElement extends BaseElement {
3813
3836
  /** Collapse the payment method selector (deselect all methods) */
3814
3837
  collapse(): void;
3815
- /** Update element options at runtime */
3816
- update(options: Partial<PaymentElementOptions>): void;
3838
+ /** Update element options at runtime — see {@link PaymentElementUpdateOptions} */
3839
+ update(options: PaymentElementUpdateOptions): void;
3817
3840
  }
3818
3841
  /**
3819
3842
  * Options for `confirmPayment()` or `checkout.confirm()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpayeg/sdk",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "XPay JavaScript SDK — loader and TypeScript types for embedding XPay payments",
5
5
  "license": "MIT",
6
6
  "type": "module",