@payment-kit-js/vanilla 0.5.4 → 0.5.6

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * PaymentKit.js v0.5.4
2
+ * PaymentKit.js v0.5.6
3
3
  * https://paymentkit.com
4
4
  *
5
5
  * @license MIT
@@ -42,7 +42,7 @@ var PaymentKit = (() => {
42
42
  });
43
43
 
44
44
  // package.json
45
- var version = "0.5.4";
45
+ var version = "0.5.6";
46
46
 
47
47
  // src/analytics/mock-adapter.ts
48
48
  var MockAnalyticsAdapter = class {
@@ -6850,25 +6850,36 @@ var PaymentKit = (() => {
6850
6850
  return window.VGSCollect.create(vaultId, environment, () => {
6851
6851
  });
6852
6852
  }
6853
- function createVgsCardFields(form, mountPoints, css, onFocusChangeCallbacks) {
6854
- const fieldCss = css ?? {
6855
- height: "46px",
6853
+ function createVgsCardFields(form, mountPoints, css, onFocusChangeCallbacks, placeholders) {
6854
+ const sampleContainer = document.querySelector(mountPoints.pan);
6855
+ const containerPadding = sampleContainer ? getComputedStyle(sampleContainer).padding : void 0;
6856
+ const baseCss = css ?? {
6856
6857
  "font-size": "1rem",
6857
6858
  color: "#18181b",
6858
6859
  "font-family": "ui-sans-serif, system-ui, sans-serif"
6859
6860
  };
6861
+ const fieldCss = {
6862
+ ...baseCss,
6863
+ height: "100%",
6864
+ "box-sizing": "border-box",
6865
+ ...containerPadding && containerPadding !== "0px" ? { padding: containerPadding } : {}
6866
+ };
6860
6867
  const panField = form.cardNumberField(mountPoints.pan, {
6861
- placeholder: "Card number",
6868
+ placeholder: placeholders?.card_pan ?? "Card number",
6862
6869
  validations: ["required", "validCardNumber"],
6863
6870
  css: fieldCss
6864
6871
  });
6865
- const expField = form.cardExpirationDateField(mountPoints.exp, {
6866
- placeholder: "MM / YY",
6872
+ const expField = form.field(mountPoints.exp, {
6873
+ type: "card-expiration-date",
6874
+ name: "exp-date",
6875
+ placeholder: placeholders?.card_exp ?? "MM / YY",
6876
+ yearLength: 2,
6877
+ serializers: [{ name: "separate", options: { monthName: "month", yearName: "year" } }],
6867
6878
  validations: ["required", "validCardExpirationDate"],
6868
6879
  css: fieldCss
6869
6880
  });
6870
6881
  const cvcField = form.cardCVCField(mountPoints.cvc, {
6871
- placeholder: "123",
6882
+ placeholder: placeholders?.card_cvc ?? "123",
6872
6883
  validations: ["required", "validCardSecurityCode"],
6873
6884
  css: fieldCss
6874
6885
  });
@@ -6876,8 +6887,15 @@ var PaymentKit = (() => {
6876
6887
  const container = document.querySelector(selector);
6877
6888
  if (!container) continue;
6878
6889
  const styleIframe = (iframe) => {
6890
+ const containerEl = container;
6891
+ if (getComputedStyle(containerEl).position === "static") {
6892
+ containerEl.style.position = "relative";
6893
+ }
6894
+ iframe.style.position = "absolute";
6895
+ iframe.style.inset = "0";
6879
6896
  iframe.style.width = "100%";
6880
6897
  iframe.style.height = "100%";
6898
+ iframe.style.border = "none";
6881
6899
  };
6882
6900
  const existing = container.querySelector("iframe");
6883
6901
  if (existing) {
@@ -6936,7 +6954,7 @@ var PaymentKit = (() => {
6936
6954
  var defCreateElement = (states) => {
6937
6955
  const { baseUrl, apiBaseUrl, cardInputConnections, secureToken, timingTracker } = states;
6938
6956
  return (type, options) => {
6939
- const { style, onLoaded, onFocusChange } = options;
6957
+ const { style, onLoaded, onFocusChange, placeholder } = options;
6940
6958
  const mountIFrame = (parentSelector) => {
6941
6959
  let cleanupVgs;
6942
6960
  let cleanupDirect;
@@ -6954,6 +6972,10 @@ var PaymentKit = (() => {
6954
6972
  if (!states.vgsFocusCallbacks) states.vgsFocusCallbacks = {};
6955
6973
  states.vgsFocusCallbacks[type] = onFocusChange;
6956
6974
  }
6975
+ if (placeholder) {
6976
+ if (!states.vgsPlaceholders) states.vgsPlaceholders = {};
6977
+ states.vgsPlaceholders[type] = placeholder;
6978
+ }
6957
6979
  if (type === "card_pan") {
6958
6980
  const vaultId = states.vgsVaultId;
6959
6981
  const vgsEnv = states.vgsEnvironment;
@@ -6999,7 +7021,8 @@ var PaymentKit = (() => {
6999
7021
  cvc: cvcSelector
7000
7022
  },
7001
7023
  css,
7002
- states.vgsFocusCallbacks
7024
+ states.vgsFocusCallbacks,
7025
+ states.vgsPlaceholders
7003
7026
  );
7004
7027
  console.log("[PaymentKit] VGS card fields created successfully");
7005
7028
  timingTracker.trackInputReady();
@@ -7026,14 +7049,25 @@ var PaymentKit = (() => {
7026
7049
  );
7027
7050
  }
7028
7051
  const parent = $(parentSelector);
7052
+ const computed = getComputedStyle(parent);
7053
+ const containerPadding = computed.padding !== "0px" ? computed.padding : void 0;
7054
+ const enhancedStyle = {
7055
+ ...style ?? {},
7056
+ height: "100%",
7057
+ boxSizing: "border-box",
7058
+ ...containerPadding ? { padding: containerPadding } : {}
7059
+ };
7029
7060
  const params = {
7030
7061
  checkout_token: secureToken,
7031
- api_base_url: apiBaseUrl
7062
+ api_base_url: apiBaseUrl,
7063
+ style: JSON.stringify(enhancedStyle)
7032
7064
  };
7033
- if (style) {
7034
- params.style = JSON.stringify(style);
7035
- }
7036
7065
  const iframe = createCheckoutIFrame(type.replace("_", "-"), baseUrl, params);
7066
+ if (computed.position === "static") {
7067
+ parent.style.position = "relative";
7068
+ }
7069
+ iframe.style.position = "absolute";
7070
+ iframe.style.inset = "0";
7037
7071
  cleanupDirect = () => {
7038
7072
  const connection = cardInputConnections[type];
7039
7073
  connection?.destroy();