@delopay/sdk 0.136.0 → 0.137.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/dist/internal.cjs CHANGED
@@ -20,6 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/internal.ts
21
21
  var internal_exports = {};
22
22
  __export(internal_exports, {
23
+ AIRWALLEX_AUTOFILL_TREATMENTS: () => AIRWALLEX_AUTOFILL_TREATMENTS,
24
+ AIRWALLEX_CARD_LAYOUTS: () => AIRWALLEX_CARD_LAYOUTS,
25
+ AIRWALLEX_CARD_PRESETS: () => AIRWALLEX_CARD_PRESETS,
26
+ AIRWALLEX_CARD_PRESET_FALLBACK: () => AIRWALLEX_CARD_PRESET_FALLBACK,
27
+ AIRWALLEX_FIELD_CHROMES: () => AIRWALLEX_FIELD_CHROMES,
28
+ AIRWALLEX_FIELD_FONT_SIZES: () => AIRWALLEX_FIELD_FONT_SIZES,
29
+ AIRWALLEX_FIELD_WEIGHTS: () => AIRWALLEX_FIELD_WEIGHTS,
30
+ AIRWALLEX_FOCUS_RINGS: () => AIRWALLEX_FOCUS_RINGS,
31
+ AIRWALLEX_LABEL_STYLES: () => AIRWALLEX_LABEL_STYLES,
32
+ AIRWALLEX_NETWORK_MARKS: () => AIRWALLEX_NETWORK_MARKS,
23
33
  ALL_CUSTOM_FIELD_CONDITION_SOURCES: () => ALL_CUSTOM_FIELD_CONDITION_SOURCES,
24
34
  ALL_CUSTOM_FIELD_OPERATORS: () => ALL_CUSTOM_FIELD_OPERATORS,
25
35
  ALL_CUSTOM_FIELD_TYPES: () => ALL_CUSTOM_FIELD_TYPES,
@@ -102,9 +112,15 @@ __export(internal_exports, {
102
112
  WCAG_AA_TEXT: () => WCAG_AA_TEXT,
103
113
  WCAG_AA_UI: () => WCAG_AA_UI,
104
114
  Webhooks: () => Webhooks,
115
+ airwallexCardLayout: () => airwallexCardLayout,
116
+ airwallexCardLayoutIsCoherent: () => airwallexCardLayoutIsCoherent,
117
+ airwallexCellWeight: () => airwallexCellWeight,
118
+ airwallexFieldFontPx: () => airwallexFieldFontPx,
119
+ airwallexFieldWeightValue: () => airwallexFieldWeightValue,
105
120
  allOf: () => allOf,
106
121
  anyOf: () => anyOf,
107
122
  applyBrandingVariables: () => applyBrandingVariables,
123
+ asAirwallexCardPreset: () => asAirwallexCardPreset,
108
124
  buildBrandingExport: () => buildBrandingExport,
109
125
  buttonPadValue: () => buttonPadValue,
110
126
  canonicalSectionId: () => canonicalSectionId,
@@ -168,6 +184,8 @@ __export(internal_exports, {
168
184
  programToTree: () => programToTree,
169
185
  radiusValue: () => radiusValue,
170
186
  readableInkOn: () => readableInkOn,
187
+ resolveAirwallexCardPreset: () => resolveAirwallexCardPreset,
188
+ resolveAirwallexLabelStyle: () => resolveAirwallexLabelStyle,
171
189
  ruleMatchToTree: () => ruleMatchToTree,
172
190
  sanitizeCustomCss: () => sanitizeCustomCss,
173
191
  sectionLabel: () => sectionLabel,
@@ -5499,6 +5517,120 @@ function feeProgram() {
5499
5517
  return new FeeProgramBuilder();
5500
5518
  }
5501
5519
 
5520
+ // src/airwallexCard.ts
5521
+ var AIRWALLEX_CARD_PRESETS = [
5522
+ "single_row",
5523
+ "split_fields",
5524
+ "split_fields_labelled",
5525
+ "stacked",
5526
+ "number_expiry_row",
5527
+ "compact"
5528
+ ];
5529
+ var SPLIT = ["cardNumber", "expiry", "cvc"];
5530
+ var AIRWALLEX_CARD_LAYOUTS = {
5531
+ // Airwallex's combined element. One iframe, one row, and the only preset
5532
+ // whose insides are not ours to lay out — which is why it carries no
5533
+ // captions: there is nothing to caption but the row as a whole.
5534
+ single_row: {
5535
+ elements: ["card"],
5536
+ rows: [["card"]],
5537
+ labels: false,
5538
+ density: "default"
5539
+ },
5540
+ // The trio with placeholders carrying the meaning. Shorter than the
5541
+ // labelled variant and fine on a wide surface.
5542
+ split_fields: {
5543
+ elements: SPLIT,
5544
+ rows: [["cardNumber"], ["expiry", "cvc"]],
5545
+ labels: false,
5546
+ density: "default"
5547
+ },
5548
+ // The default. The same geometry, captioned — which is what makes it
5549
+ // survive a narrow embed, where a bare field row stops being self-evident.
5550
+ split_fields_labelled: {
5551
+ elements: SPLIT,
5552
+ rows: [["cardNumber"], ["expiry", "cvc"]],
5553
+ labels: true,
5554
+ density: "default"
5555
+ },
5556
+ // Every field full width. Expiry and CVC side by side start to crowd below
5557
+ // roughly 320px, and this is the layout that does not.
5558
+ stacked: {
5559
+ elements: SPLIT,
5560
+ rows: [["cardNumber"], ["expiry"], ["cvc"]],
5561
+ labels: true,
5562
+ density: "default"
5563
+ },
5564
+ // Two rows instead of two-plus-one: shorter than the split forms without
5565
+ // the ambiguity of a single combined field.
5566
+ //
5567
+ // 3:2, not an even split. A card number is nineteen characters and an expiry
5568
+ // is five, so halving the row clipped the number's own placeholder at 460px
5569
+ // — seen in the preview before this was weighted. The proposal drew it even;
5570
+ // the merchant-facing decision was taken on the two drawn side by side and
5571
+ // the weighted one was chosen, so do not "restore" the even split to match
5572
+ // the original mock.
5573
+ number_expiry_row: {
5574
+ elements: SPLIT,
5575
+ rows: [["cardNumber", "expiry"], ["cvc"]],
5576
+ weights: { cardNumber: 3, expiry: 2 },
5577
+ labels: true,
5578
+ density: "default"
5579
+ },
5580
+ // Split geometry at reduced density and type size, for a checkout embedded
5581
+ // in a page that already has its own chrome.
5582
+ compact: {
5583
+ elements: SPLIT,
5584
+ rows: [["cardNumber"], ["expiry", "cvc"]],
5585
+ labels: false,
5586
+ density: "compact"
5587
+ }
5588
+ };
5589
+ var AIRWALLEX_CARD_PRESET_FALLBACK = "split_fields_labelled";
5590
+ function resolveAirwallexCardPreset(fromBranding, fromConnector) {
5591
+ return asPreset(fromBranding) ?? asPreset(fromConnector) ?? AIRWALLEX_CARD_PRESET_FALLBACK;
5592
+ }
5593
+ function asAirwallexCardPreset(value) {
5594
+ return asPreset(value);
5595
+ }
5596
+ function asPreset(value) {
5597
+ if (typeof value !== "string") return null;
5598
+ const trimmed = value.trim().toLowerCase();
5599
+ return AIRWALLEX_CARD_PRESETS.includes(trimmed) ? trimmed : null;
5600
+ }
5601
+ function airwallexCardLayout(preset) {
5602
+ return AIRWALLEX_CARD_LAYOUTS[preset];
5603
+ }
5604
+ function airwallexCellWeight(layout, field) {
5605
+ const weight = layout.weights?.[field];
5606
+ return typeof weight === "number" && Number.isFinite(weight) && weight > 0 ? weight : 1;
5607
+ }
5608
+ function airwallexCardLayoutIsCoherent(layout) {
5609
+ const drawn = layout.rows.flat();
5610
+ if (drawn.length !== layout.elements.length) return false;
5611
+ return layout.elements.every((field) => drawn.filter((f) => f === field).length === 1);
5612
+ }
5613
+ var AIRWALLEX_LABEL_STYLES = ["above", "inline", "floating", "none"];
5614
+ function resolveAirwallexLabelStyle(override, layout) {
5615
+ if (typeof override === "string" && AIRWALLEX_LABEL_STYLES.includes(override)) {
5616
+ return override;
5617
+ }
5618
+ return layout.labels ? "above" : "none";
5619
+ }
5620
+ var AIRWALLEX_FIELD_CHROMES = ["outlined", "filled", "underline"];
5621
+ var AIRWALLEX_FOCUS_RINGS = ["none", "subtle", "strong"];
5622
+ var AIRWALLEX_AUTOFILL_TREATMENTS = ["system", "brand", "neutral"];
5623
+ var AIRWALLEX_FIELD_FONT_SIZES = ["sm", "md", "lg"];
5624
+ var AIRWALLEX_FIELD_WEIGHTS = ["regular", "medium", "semibold"];
5625
+ function airwallexFieldFontPx(size, density) {
5626
+ const base = size === "sm" ? 14 : size === "lg" ? 18 : 16;
5627
+ return density === "compact" ? Math.max(13, base - 1) : base;
5628
+ }
5629
+ function airwallexFieldWeightValue(weight) {
5630
+ return weight === "regular" ? 400 : weight === "semibold" ? 600 : 500;
5631
+ }
5632
+ var AIRWALLEX_NETWORK_MARKS = ["visa", "mastercard", "amex", "discover"];
5633
+
5502
5634
  // src/branding.ts
5503
5635
  function surchargeShowsLabel(labelMode, style, position) {
5504
5636
  if (labelMode !== "labelled") return false;
@@ -6034,6 +6166,25 @@ var DEFAULT_BRANDING_BASE = {
6034
6166
  paymentLayout: "tabs",
6035
6167
  labelStyle: "above",
6036
6168
  showPoweredBy: true,
6169
+ // Every one of these defaults to what the Airwallex pane already did before
6170
+ // the section existed, so a merchant who never opens it sees no change:
6171
+ // empty preset (defer to the connector account), an outlined box, 16px /
6172
+ // 500 type, no focus ring, the browser's own autofill highlight, no valid
6173
+ // tint, no marks. The single deliberate change of behaviour is not here —
6174
+ // it is the fallback at the END of `resolveAirwallexCardPreset`, which
6175
+ // moves a shop that configured NOTHING from the combined row to the
6176
+ // labelled split form.
6177
+ airwallexCardPreset: "",
6178
+ // Off. With this on, no buyer can pay by card on the shop.
6179
+ airwallexHideCard: false,
6180
+ airwallexFieldChrome: "outlined",
6181
+ airwallexLabelStyle: "",
6182
+ airwallexFieldFontSize: "md",
6183
+ airwallexFieldWeight: "medium",
6184
+ airwallexFocusRing: "none",
6185
+ airwallexAutofill: "system",
6186
+ airwallexValidTint: false,
6187
+ airwallexNetworkMarks: false,
6037
6188
  customCss: ""
6038
6189
  };
6039
6190
  var DEFAULT_BRANDING = {
@@ -6143,6 +6294,10 @@ function pickEnum(value, allowed, fallback) {
6143
6294
  if (typeof value !== "string") return fallback;
6144
6295
  return allowed.includes(value) ? value : fallback;
6145
6296
  }
6297
+ function pickEnumOrEmpty(value, allowed) {
6298
+ if (typeof value !== "string") return "";
6299
+ return allowed.includes(value) ? value : "";
6300
+ }
6146
6301
  function parseBool(value, fallback) {
6147
6302
  if (typeof value === "boolean") return value;
6148
6303
  if (value === "true") return true;
@@ -6713,6 +6868,53 @@ function decodeBranding(source) {
6713
6868
  ),
6714
6869
  labelStyle,
6715
6870
  showPoweredBy: source.branding_visibility !== false,
6871
+ // The two that can be empty use `pickEnumOrEmpty`, not `pickEnum`: a
6872
+ // value this build does not know has to decode to "unset" and defer, the
6873
+ // same as a key that was never written. Sending it to a concrete default
6874
+ // instead would make an older checkout override the connector account of
6875
+ // a merchant who picked a preset a newer dashboard offers.
6876
+ airwallexCardPreset: pickEnumOrEmpty(
6877
+ extras["airwallexCardPreset"],
6878
+ AIRWALLEX_CARD_PRESETS
6879
+ ),
6880
+ airwallexHideCard: parseBool(extras["airwallexHideCard"], DEFAULT_BRANDING.airwallexHideCard),
6881
+ airwallexFieldChrome: pickEnum(
6882
+ extras["airwallexFieldChrome"],
6883
+ AIRWALLEX_FIELD_CHROMES,
6884
+ DEFAULT_BRANDING.airwallexFieldChrome
6885
+ ),
6886
+ airwallexLabelStyle: pickEnumOrEmpty(
6887
+ extras["airwallexLabelStyle"],
6888
+ AIRWALLEX_LABEL_STYLES
6889
+ ),
6890
+ airwallexFieldFontSize: pickEnum(
6891
+ extras["airwallexFieldFontSize"],
6892
+ AIRWALLEX_FIELD_FONT_SIZES,
6893
+ DEFAULT_BRANDING.airwallexFieldFontSize
6894
+ ),
6895
+ airwallexFieldWeight: pickEnum(
6896
+ extras["airwallexFieldWeight"],
6897
+ AIRWALLEX_FIELD_WEIGHTS,
6898
+ DEFAULT_BRANDING.airwallexFieldWeight
6899
+ ),
6900
+ airwallexFocusRing: pickEnum(
6901
+ extras["airwallexFocusRing"],
6902
+ AIRWALLEX_FOCUS_RINGS,
6903
+ DEFAULT_BRANDING.airwallexFocusRing
6904
+ ),
6905
+ airwallexAutofill: pickEnum(
6906
+ extras["airwallexAutofill"],
6907
+ AIRWALLEX_AUTOFILL_TREATMENTS,
6908
+ DEFAULT_BRANDING.airwallexAutofill
6909
+ ),
6910
+ airwallexValidTint: parseBool(
6911
+ extras["airwallexValidTint"],
6912
+ DEFAULT_BRANDING.airwallexValidTint
6913
+ ),
6914
+ airwallexNetworkMarks: parseBool(
6915
+ extras["airwallexNetworkMarks"],
6916
+ DEFAULT_BRANDING.airwallexNetworkMarks
6917
+ ),
6716
6918
  customCss: s(extras["customCss"])
6717
6919
  };
6718
6920
  }
@@ -6768,6 +6970,21 @@ function encodeBranding(branding, base) {
6768
6970
  logoShape: branding.logoShape,
6769
6971
  logoSize: branding.logoSize,
6770
6972
  labelStyle: branding.labelStyle,
6973
+ // Written unconditionally, empty string included. The encoder REPLACES
6974
+ // `sdk_ui_rules.branding` wholesale, so a key it skips is a key it
6975
+ // deletes — and here the empty string is a real value ("no choice made"),
6976
+ // not an absence. Omitting it would be indistinguishable from omitting it
6977
+ // by accident, which is how `summaryOrder` was lost.
6978
+ airwallexCardPreset: branding.airwallexCardPreset,
6979
+ airwallexHideCard: String(branding.airwallexHideCard),
6980
+ airwallexFieldChrome: branding.airwallexFieldChrome,
6981
+ airwallexLabelStyle: branding.airwallexLabelStyle,
6982
+ airwallexFieldFontSize: branding.airwallexFieldFontSize,
6983
+ airwallexFieldWeight: branding.airwallexFieldWeight,
6984
+ airwallexFocusRing: branding.airwallexFocusRing,
6985
+ airwallexAutofill: branding.airwallexAutofill,
6986
+ airwallexValidTint: String(branding.airwallexValidTint),
6987
+ airwallexNetworkMarks: String(branding.airwallexNetworkMarks),
6771
6988
  trustBadges: encodeBadges(branding.trustBadges),
6772
6989
  [METHOD_SECTION_ORDER_KEY]: encodeMethodSectionOrder(branding.methodSectionOrder)
6773
6990
  };
@@ -6995,6 +7212,47 @@ function parseImportedBranding(raw) {
6995
7212
  ),
6996
7213
  labelStyle,
6997
7214
  showPoweredBy: parseBool(root["showPoweredBy"], dflt.showPoweredBy),
7215
+ // An imported profile that predates this section carries none of these
7216
+ // and lands on the defaults — which is to say on "defer", so importing an
7217
+ // old export into a shop does not take that shop's connector setting
7218
+ // away. The one field that would be dangerous to import loosely is the
7219
+ // hide switch, and `parseBool` only says true for a literal `true`.
7220
+ airwallexCardPreset: pickEnumOrEmpty(
7221
+ root["airwallexCardPreset"],
7222
+ AIRWALLEX_CARD_PRESETS
7223
+ ),
7224
+ airwallexHideCard: parseBool(root["airwallexHideCard"], dflt.airwallexHideCard),
7225
+ airwallexFieldChrome: pickEnum(
7226
+ root["airwallexFieldChrome"],
7227
+ AIRWALLEX_FIELD_CHROMES,
7228
+ dflt.airwallexFieldChrome
7229
+ ),
7230
+ airwallexLabelStyle: pickEnumOrEmpty(
7231
+ root["airwallexLabelStyle"],
7232
+ AIRWALLEX_LABEL_STYLES
7233
+ ),
7234
+ airwallexFieldFontSize: pickEnum(
7235
+ root["airwallexFieldFontSize"],
7236
+ AIRWALLEX_FIELD_FONT_SIZES,
7237
+ dflt.airwallexFieldFontSize
7238
+ ),
7239
+ airwallexFieldWeight: pickEnum(
7240
+ root["airwallexFieldWeight"],
7241
+ AIRWALLEX_FIELD_WEIGHTS,
7242
+ dflt.airwallexFieldWeight
7243
+ ),
7244
+ airwallexFocusRing: pickEnum(
7245
+ root["airwallexFocusRing"],
7246
+ AIRWALLEX_FOCUS_RINGS,
7247
+ dflt.airwallexFocusRing
7248
+ ),
7249
+ airwallexAutofill: pickEnum(
7250
+ root["airwallexAutofill"],
7251
+ AIRWALLEX_AUTOFILL_TREATMENTS,
7252
+ dflt.airwallexAutofill
7253
+ ),
7254
+ airwallexValidTint: parseBool(root["airwallexValidTint"], dflt.airwallexValidTint),
7255
+ airwallexNetworkMarks: parseBool(root["airwallexNetworkMarks"], dflt.airwallexNetworkMarks),
6998
7256
  customCss: sStr(root["customCss"], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH)
6999
7257
  };
7000
7258
  }
@@ -8821,6 +9079,16 @@ var DelopayInternal = class extends Delopay {
8821
9079
  };
8822
9080
  // Annotate the CommonJS export names for ESM import in node:
8823
9081
  0 && (module.exports = {
9082
+ AIRWALLEX_AUTOFILL_TREATMENTS,
9083
+ AIRWALLEX_CARD_LAYOUTS,
9084
+ AIRWALLEX_CARD_PRESETS,
9085
+ AIRWALLEX_CARD_PRESET_FALLBACK,
9086
+ AIRWALLEX_FIELD_CHROMES,
9087
+ AIRWALLEX_FIELD_FONT_SIZES,
9088
+ AIRWALLEX_FIELD_WEIGHTS,
9089
+ AIRWALLEX_FOCUS_RINGS,
9090
+ AIRWALLEX_LABEL_STYLES,
9091
+ AIRWALLEX_NETWORK_MARKS,
8824
9092
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
8825
9093
  ALL_CUSTOM_FIELD_OPERATORS,
8826
9094
  ALL_CUSTOM_FIELD_TYPES,
@@ -8903,9 +9171,15 @@ var DelopayInternal = class extends Delopay {
8903
9171
  WCAG_AA_TEXT,
8904
9172
  WCAG_AA_UI,
8905
9173
  Webhooks,
9174
+ airwallexCardLayout,
9175
+ airwallexCardLayoutIsCoherent,
9176
+ airwallexCellWeight,
9177
+ airwallexFieldFontPx,
9178
+ airwallexFieldWeightValue,
8906
9179
  allOf,
8907
9180
  anyOf,
8908
9181
  applyBrandingVariables,
9182
+ asAirwallexCardPreset,
8909
9183
  buildBrandingExport,
8910
9184
  buttonPadValue,
8911
9185
  canonicalSectionId,
@@ -8969,6 +9243,8 @@ var DelopayInternal = class extends Delopay {
8969
9243
  programToTree,
8970
9244
  radiusValue,
8971
9245
  readableInkOn,
9246
+ resolveAirwallexCardPreset,
9247
+ resolveAirwallexLabelStyle,
8972
9248
  ruleMatchToTree,
8973
9249
  sanitizeCustomCss,
8974
9250
  sectionLabel,