@payment-kit-js/vanilla 0.5.4 → 0.5.5

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.5
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.5";
46
46
 
47
47
  // src/analytics/mock-adapter.ts
48
48
  var MockAnalyticsAdapter = class {
@@ -6850,25 +6850,32 @@ 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
6872
  const expField = form.cardExpirationDateField(mountPoints.exp, {
6866
- placeholder: "MM / YY",
6873
+ placeholder: placeholders?.card_exp ?? "MM / YY",
6867
6874
  validations: ["required", "validCardExpirationDate"],
6868
6875
  css: fieldCss
6869
6876
  });
6870
6877
  const cvcField = form.cardCVCField(mountPoints.cvc, {
6871
- placeholder: "123",
6878
+ placeholder: placeholders?.card_cvc ?? "123",
6872
6879
  validations: ["required", "validCardSecurityCode"],
6873
6880
  css: fieldCss
6874
6881
  });
@@ -6876,8 +6883,15 @@ var PaymentKit = (() => {
6876
6883
  const container = document.querySelector(selector);
6877
6884
  if (!container) continue;
6878
6885
  const styleIframe = (iframe) => {
6886
+ const containerEl = container;
6887
+ if (getComputedStyle(containerEl).position === "static") {
6888
+ containerEl.style.position = "relative";
6889
+ }
6890
+ iframe.style.position = "absolute";
6891
+ iframe.style.inset = "0";
6879
6892
  iframe.style.width = "100%";
6880
6893
  iframe.style.height = "100%";
6894
+ iframe.style.border = "none";
6881
6895
  };
6882
6896
  const existing = container.querySelector("iframe");
6883
6897
  if (existing) {
@@ -6936,7 +6950,7 @@ var PaymentKit = (() => {
6936
6950
  var defCreateElement = (states) => {
6937
6951
  const { baseUrl, apiBaseUrl, cardInputConnections, secureToken, timingTracker } = states;
6938
6952
  return (type, options) => {
6939
- const { style, onLoaded, onFocusChange } = options;
6953
+ const { style, onLoaded, onFocusChange, placeholder } = options;
6940
6954
  const mountIFrame = (parentSelector) => {
6941
6955
  let cleanupVgs;
6942
6956
  let cleanupDirect;
@@ -6954,6 +6968,10 @@ var PaymentKit = (() => {
6954
6968
  if (!states.vgsFocusCallbacks) states.vgsFocusCallbacks = {};
6955
6969
  states.vgsFocusCallbacks[type] = onFocusChange;
6956
6970
  }
6971
+ if (placeholder) {
6972
+ if (!states.vgsPlaceholders) states.vgsPlaceholders = {};
6973
+ states.vgsPlaceholders[type] = placeholder;
6974
+ }
6957
6975
  if (type === "card_pan") {
6958
6976
  const vaultId = states.vgsVaultId;
6959
6977
  const vgsEnv = states.vgsEnvironment;
@@ -6999,7 +7017,8 @@ var PaymentKit = (() => {
6999
7017
  cvc: cvcSelector
7000
7018
  },
7001
7019
  css,
7002
- states.vgsFocusCallbacks
7020
+ states.vgsFocusCallbacks,
7021
+ states.vgsPlaceholders
7003
7022
  );
7004
7023
  console.log("[PaymentKit] VGS card fields created successfully");
7005
7024
  timingTracker.trackInputReady();
@@ -7026,14 +7045,25 @@ var PaymentKit = (() => {
7026
7045
  );
7027
7046
  }
7028
7047
  const parent = $(parentSelector);
7048
+ const computed = getComputedStyle(parent);
7049
+ const containerPadding = computed.padding !== "0px" ? computed.padding : void 0;
7050
+ const enhancedStyle = {
7051
+ ...style ?? {},
7052
+ height: "100%",
7053
+ boxSizing: "border-box",
7054
+ ...containerPadding ? { padding: containerPadding } : {}
7055
+ };
7029
7056
  const params = {
7030
7057
  checkout_token: secureToken,
7031
- api_base_url: apiBaseUrl
7058
+ api_base_url: apiBaseUrl,
7059
+ style: JSON.stringify(enhancedStyle)
7032
7060
  };
7033
- if (style) {
7034
- params.style = JSON.stringify(style);
7035
- }
7036
7061
  const iframe = createCheckoutIFrame(type.replace("_", "-"), baseUrl, params);
7062
+ if (computed.position === "static") {
7063
+ parent.style.position = "relative";
7064
+ }
7065
+ iframe.style.position = "absolute";
7066
+ iframe.style.inset = "0";
7037
7067
  cleanupDirect = () => {
7038
7068
  const connection = cardInputConnections[type];
7039
7069
  connection?.destroy();