@forgeroute/ui 0.5.12 → 0.5.13

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.
@@ -317,6 +317,34 @@ function readSquareCardStyle(doc, element = doc.documentElement) {
317
317
  put("input::placeholder", { color: dark ? "#94a3b8" : "" });
318
318
  return style;
319
319
  }
320
+ function squareCardStyleFromTheme(tokens) {
321
+ const dark = !!tokens.dark;
322
+ const text = tokens.text || (dark ? DARK_TEXT : "");
323
+ const background = tokens.background || (dark ? DARK_BACKGROUND : "");
324
+ const border = tokens.border || (dark ? DARK_BORDER : "");
325
+ const style = {};
326
+ const put = (selector, props) => {
327
+ const filled = Object.fromEntries(Object.entries(props).filter(([, v]) => !!v));
328
+ if (Object.keys(filled).length) style[selector] = filled;
329
+ };
330
+ put(".input-container", {
331
+ borderColor: border,
332
+ borderRadius: tokens.radius
333
+ });
334
+ put(".input-container.is-focus", { borderColor: tokens.primary });
335
+ put(".input-container.is-error", { borderColor: tokens.danger });
336
+ put(".message-text", { color: text });
337
+ put(".message-icon", { color: text });
338
+ put(".message-text.is-error", { color: tokens.danger });
339
+ put("input", {
340
+ backgroundColor: background,
341
+ color: text,
342
+ fontFamily: tokens.fontFamily,
343
+ fontSize: tokens.fontSize
344
+ });
345
+ put("input::placeholder", { color: dark ? "#94a3b8" : "" });
346
+ return style;
347
+ }
320
348
  const SQUARE_A11Y_MESSAGES = {
321
349
  get loading() {
322
350
  return uiText("squarePayment.a11y.loading");
@@ -328,6 +356,11 @@ const SQUARE_A11Y_MESSAGES = {
328
356
  return uiText("squarePayment.a11y.tokenized");
329
357
  }
330
358
  };
359
+ const SQUARE_EDIT_EVENTS = [
360
+ "cardBrandChanged",
361
+ "postalCodeChanged",
362
+ "errorClassRemoved"
363
+ ];
331
364
  let nextId = 0;
332
365
  const jsonEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
333
366
  function structuralEqual(a, b, inProgress = /* @__PURE__ */ new WeakMap()) {
@@ -395,7 +428,12 @@ var SquarePaymentComponent = class SquarePaymentComponent {
395
428
  this.cardOptions = input(null, ...ngDevMode ? [{ debugName: "cardOptions" }] : /* istanbul ignore next */ []);
396
429
  this.cardStyle = input(null, ...ngDevMode ? [{ debugName: "cardStyle" }] : /* istanbul ignore next */ []);
397
430
  this.styleFromTokens = input(false, ...ngDevMode ? [{ debugName: "styleFromTokens" }] : /* istanbul ignore next */ []);
431
+ this.sdkLocale = input(null, ...ngDevMode ? [{ debugName: "sdkLocale" }] : /* istanbul ignore next */ []);
432
+ this.includeInputLabels = input(false, ...ngDevMode ? [{ debugName: "includeInputLabels" }] : /* istanbul ignore next */ []);
433
+ this.postalCode = input(null, ...ngDevMode ? [{ debugName: "postalCode" }] : /* istanbul ignore next */ []);
434
+ this.hideInlineMessages = input(false, ...ngDevMode ? [{ debugName: "hideInlineMessages" }] : /* istanbul ignore next */ []);
398
435
  this.showStatus = input(true, ...ngDevMode ? [{ debugName: "showStatus" }] : /* istanbul ignore next */ []);
436
+ this.showPaid = input(true, ...ngDevMode ? [{ debugName: "showPaid" }] : /* istanbul ignore next */ []);
399
437
  this.payableRef = input(null, ...ngDevMode ? [{ debugName: "payableRef" }] : /* istanbul ignore next */ []);
400
438
  this.attemptKey = input(null, ...ngDevMode ? [{ debugName: "attemptKey" }] : /* istanbul ignore next */ []);
401
439
  this.checkStatus = input(null, ...ngDevMode ? [{ debugName: "checkStatus" }] : /* istanbul ignore next */ []);
@@ -444,6 +482,7 @@ var SquarePaymentComponent = class SquarePaymentComponent {
444
482
  this.readinessChange = output();
445
483
  this.tokenized = output();
446
484
  this.failed = output();
485
+ this.detailsChange = output();
447
486
  this.loadError = output();
448
487
  this.loading = signal(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
449
488
  this.isReady = signal(false, ...ngDevMode ? [{ debugName: "isReady" }] : /* istanbul ignore next */ []);
@@ -497,10 +536,22 @@ var SquarePaymentComponent = class SquarePaymentComponent {
497
536
  equal: jsonEqual
498
537
  });
499
538
  this.cardConfig = computed(() => {
500
- const style = this.cardStyle();
539
+ const hidden = this.hideInlineMessages() ? {
540
+ ".message-text": { display: "none" },
541
+ ".message-icon": { display: "none" }
542
+ } : null;
543
+ const style = hidden ? {
544
+ ...this.cardStyle() ?? {},
545
+ ...hidden
546
+ } : this.cardStyle();
501
547
  const options = this.cardOptions();
502
- if (!style && !options) return null;
548
+ const own = {
549
+ ...this.includeInputLabels() ? { includeInputLabels: true } : {},
550
+ ...this.postalCode() === false ? { postalCode: false } : this.postalCode() ? { postalCode: this.postalCode() } : {}
551
+ };
552
+ if (!style && !options && !Object.keys(own).length) return null;
503
553
  return {
554
+ ...own,
504
555
  ...style ? { style } : {},
505
556
  ...options ?? {}
506
557
  };
@@ -514,6 +565,12 @@ var SquarePaymentComponent = class SquarePaymentComponent {
514
565
  this.generation = 0;
515
566
  this.destroyed = false;
516
567
  this.announced = false;
568
+ this.sdkLocaleCode = computed(() => {
569
+ const given = this.sdkLocale();
570
+ if (given === false) return null;
571
+ if (given) return given;
572
+ return (this.labels.locale() || "").toLowerCase().split("-")[0] === "es" ? "es-ES" : "en-US";
573
+ }, ...ngDevMode ? [{ debugName: "sdkLocaleCode" }] : /* istanbul ignore next */ []);
517
574
  const protection = createPaymentProtection(this, {
518
575
  amount: () => this.amount(),
519
576
  method: () => this.method(),
@@ -777,6 +834,13 @@ var SquarePaymentComponent = class SquarePaymentComponent {
777
834
  const payments = await withSquareTimeout(this.loader(connection), () => new SquareLoadError("script_failed"));
778
835
  if (generation !== this.generation) return;
779
836
  this.payments = payments;
837
+ const code = this.sdkLocaleCode();
838
+ if (code && payments.setLocale) {
839
+ try {
840
+ await withSquareTimeout(Promise.resolve(payments.setLocale(code)), () => /* @__PURE__ */ new Error("timeout"));
841
+ } catch {}
842
+ if (generation !== this.generation) return;
843
+ }
780
844
  } catch (err) {
781
845
  if (generation !== this.generation) return;
782
846
  this.loadFailed(err instanceof SquareLoadError ? err.code : "load_error", this.labels.t("squarePayment.msg.loadFailed"), messageOfThrown(err, ""));
@@ -802,6 +866,9 @@ var SquarePaymentComponent = class SquarePaymentComponent {
802
866
  return;
803
867
  }
804
868
  this.card = card;
869
+ for (const event of SQUARE_EDIT_EVENTS) card.addEventListener?.(event, () => {
870
+ if (generation === this.generation && !this.submitting()) this.edited();
871
+ });
805
872
  try {
806
873
  await withSquareTimeout(card.attach(container), () => /* @__PURE__ */ new Error("timeout"));
807
874
  } catch (err) {
@@ -844,6 +911,10 @@ var SquarePaymentComponent = class SquarePaymentComponent {
844
911
  this.loadFailed("init_failed", this.labels.t(method === "card" ? "squarePayment.msg.cardFormFailed" : "squarePayment.msg.achInitFailed"), messageOfThrown(err, ""));
845
912
  }
846
913
  }
914
+ edited() {
915
+ if (this.errorText()) this.errorText.set("");
916
+ this.detailsChange.emit();
917
+ }
847
918
  onTab(key) {
848
919
  if (this.submitting() || this.disabled() || this.attempt.locked() || key !== "card" && key !== "ach") return;
849
920
  this.method.set(key);
@@ -1000,6 +1071,34 @@ var SquarePaymentComponent = class SquarePaymentComponent {
1000
1071
  isRequired: false,
1001
1072
  transformFunction: null
1002
1073
  },
1074
+ sdkLocale: {
1075
+ classPropertyName: "sdkLocale",
1076
+ publicName: "sdkLocale",
1077
+ isSignal: true,
1078
+ isRequired: false,
1079
+ transformFunction: null
1080
+ },
1081
+ includeInputLabels: {
1082
+ classPropertyName: "includeInputLabels",
1083
+ publicName: "includeInputLabels",
1084
+ isSignal: true,
1085
+ isRequired: false,
1086
+ transformFunction: null
1087
+ },
1088
+ postalCode: {
1089
+ classPropertyName: "postalCode",
1090
+ publicName: "postalCode",
1091
+ isSignal: true,
1092
+ isRequired: false,
1093
+ transformFunction: null
1094
+ },
1095
+ hideInlineMessages: {
1096
+ classPropertyName: "hideInlineMessages",
1097
+ publicName: "hideInlineMessages",
1098
+ isSignal: true,
1099
+ isRequired: false,
1100
+ transformFunction: null
1101
+ },
1003
1102
  showStatus: {
1004
1103
  classPropertyName: "showStatus",
1005
1104
  publicName: "showStatus",
@@ -1007,6 +1106,13 @@ var SquarePaymentComponent = class SquarePaymentComponent {
1007
1106
  isRequired: false,
1008
1107
  transformFunction: null
1009
1108
  },
1109
+ showPaid: {
1110
+ classPropertyName: "showPaid",
1111
+ publicName: "showPaid",
1112
+ isSignal: true,
1113
+ isRequired: false,
1114
+ transformFunction: null
1115
+ },
1010
1116
  payableRef: {
1011
1117
  classPropertyName: "payableRef",
1012
1118
  publicName: "payableRef",
@@ -1242,6 +1348,7 @@ var SquarePaymentComponent = class SquarePaymentComponent {
1242
1348
  readinessChange: "readinessChange",
1243
1349
  tokenized: "tokenized",
1244
1350
  failed: "failed",
1351
+ detailsChange: "detailsChange",
1245
1352
  loadError: "loadError"
1246
1353
  },
1247
1354
  host: { properties: { "attr.aria-busy": "!mountOnly() && (loading() || submitting()) ? \"true\" : null" } },
@@ -1262,7 +1369,7 @@ var SquarePaymentComponent = class SquarePaymentComponent {
1262
1369
  <div class="sqp-block"><ui-pill-tabs [ariaLabel]="labels.t('squarePayment.method.group')" [tabs]="tabs()" [activeKey]="method()" (tabChange)="onTab($event)" /></div>
1263
1370
  }
1264
1371
  @if (!mountOnly() && showStatus()) {
1265
- <ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="allowStartOver()" (retryLoad)="retryLoad()" />
1372
+ <ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="allowStartOver()" [showPaid]="showPaid()" (retryLoad)="retryLoad()" />
1266
1373
  }
1267
1374
  @if (!mountOnly() && (loading() || pending())) {
1268
1375
  <div class="sqp-skeleton" data-testid="square-skeleton" aria-hidden="true">
@@ -1285,10 +1392,10 @@ var SquarePaymentComponent = class SquarePaymentComponent {
1285
1392
  <ui-text data-testid="square-ach-info" size="sm" tone="muted" [text]="labels.t('squarePayment.achInfo')" />
1286
1393
  <ui-text-input [label]="labels.t('squarePayment.holderLabel')" [placeholder]="labels.t('squarePayment.holderPlaceholder')" [inputTestId]="holderTestId()" autocomplete="name"
1287
1394
  [required]="true" [maxlength]="255" [error]="holderError()" [showErrors]="attempted()" [disabled]="locked()"
1288
- [ngModel]="holder()" (ngModelChange)="holder.set($event ?? '')" />
1395
+ [ngModel]="holder()" (ngModelChange)="holder.set($event ?? ''); edited()" />
1289
1396
  @if (requireAchConsent()) {
1290
1397
  <ui-checkbox testId="square-consent" [label]="achConsent()" [required]="true" [requiredMessage]="labels.t('squarePayment.consentRequired')" [showErrors]="attempted()"
1291
- [disabled]="locked()" [ngModel]="consent()" (ngModelChange)="consent.set(!!$event)" />
1398
+ [disabled]="locked()" [ngModel]="consent()" (ngModelChange)="consent.set(!!$event); edited()" />
1292
1399
  }
1293
1400
  </div>
1294
1401
  }
@@ -1507,6 +1614,7 @@ var SquarePaymentComponent = class SquarePaymentComponent {
1507
1614
  "readonly",
1508
1615
  "hint",
1509
1616
  "ariaDescribedBy",
1617
+ "ariaInvalid",
1510
1618
  "error",
1511
1619
  "phoneFormat",
1512
1620
  "min",
@@ -1566,7 +1674,7 @@ i0.ɵɵngDeclareClassMetadata({
1566
1674
  <div class="sqp-block"><ui-pill-tabs [ariaLabel]="labels.t('squarePayment.method.group')" [tabs]="tabs()" [activeKey]="method()" (tabChange)="onTab($event)" /></div>
1567
1675
  }
1568
1676
  @if (!mountOnly() && showStatus()) {
1569
- <ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="allowStartOver()" (retryLoad)="retryLoad()" />
1677
+ <ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="allowStartOver()" [showPaid]="showPaid()" (retryLoad)="retryLoad()" />
1570
1678
  }
1571
1679
  @if (!mountOnly() && (loading() || pending())) {
1572
1680
  <div class="sqp-skeleton" data-testid="square-skeleton" aria-hidden="true">
@@ -1589,10 +1697,10 @@ i0.ɵɵngDeclareClassMetadata({
1589
1697
  <ui-text data-testid="square-ach-info" size="sm" tone="muted" [text]="labels.t('squarePayment.achInfo')" />
1590
1698
  <ui-text-input [label]="labels.t('squarePayment.holderLabel')" [placeholder]="labels.t('squarePayment.holderPlaceholder')" [inputTestId]="holderTestId()" autocomplete="name"
1591
1699
  [required]="true" [maxlength]="255" [error]="holderError()" [showErrors]="attempted()" [disabled]="locked()"
1592
- [ngModel]="holder()" (ngModelChange)="holder.set($event ?? '')" />
1700
+ [ngModel]="holder()" (ngModelChange)="holder.set($event ?? ''); edited()" />
1593
1701
  @if (requireAchConsent()) {
1594
1702
  <ui-checkbox testId="square-consent" [label]="achConsent()" [required]="true" [requiredMessage]="labels.t('squarePayment.consentRequired')" [showErrors]="attempted()"
1595
- [disabled]="locked()" [ngModel]="consent()" (ngModelChange)="consent.set(!!$event)" />
1703
+ [disabled]="locked()" [ngModel]="consent()" (ngModelChange)="consent.set(!!$event); edited()" />
1596
1704
  }
1597
1705
  </div>
1598
1706
  }
@@ -1767,6 +1875,38 @@ i0.ɵɵngDeclareClassMetadata({
1767
1875
  required: false
1768
1876
  }]
1769
1877
  }],
1878
+ sdkLocale: [{
1879
+ type: i0.Input,
1880
+ args: [{
1881
+ isSignal: true,
1882
+ alias: "sdkLocale",
1883
+ required: false
1884
+ }]
1885
+ }],
1886
+ includeInputLabels: [{
1887
+ type: i0.Input,
1888
+ args: [{
1889
+ isSignal: true,
1890
+ alias: "includeInputLabels",
1891
+ required: false
1892
+ }]
1893
+ }],
1894
+ postalCode: [{
1895
+ type: i0.Input,
1896
+ args: [{
1897
+ isSignal: true,
1898
+ alias: "postalCode",
1899
+ required: false
1900
+ }]
1901
+ }],
1902
+ hideInlineMessages: [{
1903
+ type: i0.Input,
1904
+ args: [{
1905
+ isSignal: true,
1906
+ alias: "hideInlineMessages",
1907
+ required: false
1908
+ }]
1909
+ }],
1770
1910
  showStatus: [{
1771
1911
  type: i0.Input,
1772
1912
  args: [{
@@ -1775,6 +1915,14 @@ i0.ɵɵngDeclareClassMetadata({
1775
1915
  required: false
1776
1916
  }]
1777
1917
  }],
1918
+ showPaid: [{
1919
+ type: i0.Input,
1920
+ args: [{
1921
+ isSignal: true,
1922
+ alias: "showPaid",
1923
+ required: false
1924
+ }]
1925
+ }],
1778
1926
  payableRef: [{
1779
1927
  type: i0.Input,
1780
1928
  args: [{
@@ -2063,6 +2211,10 @@ i0.ɵɵngDeclareClassMetadata({
2063
2211
  type: i0.Output,
2064
2212
  args: ["failed"]
2065
2213
  }],
2214
+ detailsChange: [{
2215
+ type: i0.Output,
2216
+ args: ["detailsChange"]
2217
+ }],
2066
2218
  loadError: [{
2067
2219
  type: i0.Output,
2068
2220
  args: ["loadError"]
@@ -3621,7 +3773,12 @@ var PaymentSquareBodyComponent = class PaymentSquareBodyComponent {
3621
3773
  "cardOptions",
3622
3774
  "cardStyle",
3623
3775
  "styleFromTokens",
3776
+ "sdkLocale",
3777
+ "includeInputLabels",
3778
+ "postalCode",
3779
+ "hideInlineMessages",
3624
3780
  "showStatus",
3781
+ "showPaid",
3625
3782
  "payableRef",
3626
3783
  "attemptKey",
3627
3784
  "checkStatus",
@@ -3665,6 +3822,7 @@ var PaymentSquareBodyComponent = class PaymentSquareBodyComponent {
3665
3822
  "readinessChange",
3666
3823
  "tokenized",
3667
3824
  "failed",
3825
+ "detailsChange",
3668
3826
  "loadError"
3669
3827
  ]
3670
3828
  }
@@ -4337,6 +4495,6 @@ i0.ɵɵngDeclareClassMetadata({
4337
4495
  }]
4338
4496
  }
4339
4497
  });
4340
- export { SQUARE_A11Y_MESSAGES, SQUARE_FIELD_ERROR_KEYS, SQUARE_LOADER, SQUARE_METHOD_TEXTS, SQUARE_PAYMENT_DEFAULTS, SQUARE_PAYMENT_ERROR_KEYS, SQUARE_PAYMENT_METHOD_VALUES, SQUARE_SANDBOX_SDK_URL, SQUARE_SDK_URL, SQUARE_TYPE_ERROR_KEYS, SquareConnectComponent, SquareConnectFlow, SquareLoadError, SquarePaymentComponent, SquarePaymentMethodComponent, defaultSquareLoader, failureFromTokenResult, getSquareErrorMessage, getSquarePaymentErrorMessage, isSquareUrl, newIdempotencyKey, normalizeSquareDetails, provideSquarePayment, readSquareCardStyle, squareConnectNotice, squareMethodLabel, squareOutcomeOf, squareSdkUrl };
4498
+ export { SQUARE_A11Y_MESSAGES, SQUARE_FIELD_ERROR_KEYS, SQUARE_LOADER, SQUARE_METHOD_TEXTS, SQUARE_PAYMENT_DEFAULTS, SQUARE_PAYMENT_ERROR_KEYS, SQUARE_PAYMENT_METHOD_VALUES, SQUARE_SANDBOX_SDK_URL, SQUARE_SDK_URL, SQUARE_TYPE_ERROR_KEYS, SquareConnectComponent, SquareConnectFlow, SquareLoadError, SquarePaymentComponent, SquarePaymentMethodComponent, defaultSquareLoader, failureFromTokenResult, getSquareErrorMessage, getSquarePaymentErrorMessage, isSquareUrl, newIdempotencyKey, normalizeSquareDetails, provideSquarePayment, readSquareCardStyle, squareCardStyleFromTheme, squareConnectNotice, squareMethodLabel, squareOutcomeOf, squareSdkUrl };
4341
4499
 
4342
4500
  //# sourceMappingURL=forgeroute-ui-square.mjs.map