straumur-web-component 0.2.0 → 0.2.1

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/index.cjs CHANGED
@@ -986,7 +986,6 @@ var checkmark_default = CheckmarkIcon;
986
986
 
987
987
  // src/features/card/card-component.tsx
988
988
  function CardComponent({ configuration, paymentMethods }) {
989
- var _a, _b, _c;
990
989
  const cardElementRef = (0, import_hooks4.useRef)(null);
991
990
  const adyenCardRef = (0, import_hooks4.useRef)();
992
991
  const customCardRef = (0, import_hooks4.useRef)();
@@ -1000,7 +999,7 @@ function CardComponent({ configuration, paymentMethods }) {
1000
999
  encryptedExpiryDate: { visible: false },
1001
1000
  encryptedSecurityCode: { visible: false }
1002
1001
  });
1003
- if (!((_a = paymentMethods.paymentMethods.paymentMethods) == null ? void 0 : _a.some((x) => x.type === "scheme"))) {
1002
+ if (!paymentMethods.paymentMethods.paymentMethods?.some((x) => x.type === "scheme")) {
1004
1003
  return null;
1005
1004
  }
1006
1005
  const {
@@ -1087,7 +1086,7 @@ function CardComponent({ configuration, paymentMethods }) {
1087
1086
  const handleBoxChange = () => {
1088
1087
  setActivePaymentMethod("card");
1089
1088
  };
1090
- if (((_c = (_b = paymentMethods.paymentMethods) == null ? void 0 : _b.paymentMethods) == null ? void 0 : _c.length) === 0) {
1089
+ if (paymentMethods.paymentMethods?.paymentMethods?.length === 0) {
1091
1090
  return null;
1092
1091
  }
1093
1092
  const brands = schemeBrands.map((x) => {
@@ -1124,7 +1123,7 @@ function CardComponent({ configuration, paymentMethods }) {
1124
1123
  const { resultCode, action } = response;
1125
1124
  if (resultCode === "RedirectShopper" || resultCode === "IdentifyShopper") {
1126
1125
  setThreeDSecureActive(true);
1127
- adyenCardRef.current.createFromAction(action).mount(threeDSecureRef == null ? void 0 : threeDSecureRef.current);
1126
+ adyenCardRef.current.createFromAction(action).mount(threeDSecureRef?.current);
1128
1127
  return;
1129
1128
  }
1130
1129
  actions.resolve({ resultCode, action });
@@ -1328,7 +1327,6 @@ var googlepay_default = GooglePayIcon;
1328
1327
 
1329
1328
  // src/features/google-pay/google-pay-component.tsx
1330
1329
  function GooglePayComponent({ configuration, paymentMethods }) {
1331
- var _a;
1332
1330
  const googlePayElementRef = (0, import_hooks5.useRef)(null);
1333
1331
  const adyenCardRef = (0, import_hooks5.useRef)();
1334
1332
  const googlePayRef = (0, import_hooks5.useRef)();
@@ -1412,7 +1410,7 @@ function GooglePayComponent({ configuration, paymentMethods }) {
1412
1410
  const { resultCode, action } = response;
1413
1411
  if (resultCode === "RedirectShopper" || resultCode === "IdentifyShopper") {
1414
1412
  setThreeDSecureActive(true);
1415
- adyenCardRef.current.createFromAction(action).mount(threeDSecureRef == null ? void 0 : threeDSecureRef.current);
1413
+ adyenCardRef.current.createFromAction(action).mount(threeDSecureRef?.current);
1416
1414
  return;
1417
1415
  }
1418
1416
  actions.resolve({ resultCode, action });
@@ -1447,7 +1445,7 @@ function GooglePayComponent({ configuration, paymentMethods }) {
1447
1445
  handleError("error.paymentUnsuccessful");
1448
1446
  }
1449
1447
  }
1450
- const hasGooglePay = (_a = paymentMethods.paymentMethods.paymentMethods) == null ? void 0 : _a.some((x) => x.type === "googlepay");
1448
+ const hasGooglePay = paymentMethods.paymentMethods.paymentMethods?.some((x) => x.type === "googlepay");
1451
1449
  if (!hasGooglePay) {
1452
1450
  return null;
1453
1451
  }
@@ -1633,7 +1631,7 @@ function StoredCardComponent({
1633
1631
  const { resultCode, action } = response;
1634
1632
  if (resultCode === "RedirectShopper" || resultCode === "IdentifyShopper") {
1635
1633
  setThreeDSecureActive(true);
1636
- adyenCardRef.current.createFromAction(action).mount(threeDSecureRef == null ? void 0 : threeDSecureRef.current);
1634
+ adyenCardRef.current.createFromAction(action).mount(threeDSecureRef?.current);
1637
1635
  return;
1638
1636
  }
1639
1637
  actions.resolve({ resultCode, action });
@@ -1762,11 +1760,10 @@ function StoredCardContainerComponent({
1762
1760
  configuration,
1763
1761
  paymentMethods
1764
1762
  }) {
1765
- var _a;
1766
1763
  const [storedPaymentMethods, setStoredPaymentMethods] = (0, import_hooks7.useState)(
1767
- (_a = paymentMethods.paymentMethods.storedPaymentMethods) != null ? _a : []
1764
+ paymentMethods.paymentMethods.storedPaymentMethods ?? []
1768
1765
  );
1769
- if (!storedPaymentMethods || (storedPaymentMethods == null ? void 0 : storedPaymentMethods.length) === 0) {
1766
+ if (!storedPaymentMethods || storedPaymentMethods?.length === 0) {
1770
1767
  return null;
1771
1768
  }
1772
1769
  function handleStoredCardRemoved(storedPaymentMethodId) {
@@ -1774,7 +1771,7 @@ function StoredCardContainerComponent({
1774
1771
  (prevStoredPaymentMethods) => prevStoredPaymentMethods.filter((storedPaymentMethod) => storedPaymentMethod.id !== storedPaymentMethodId)
1775
1772
  );
1776
1773
  }
1777
- return /* @__PURE__ */ (0, import_preact22.h)(import_preact22.Fragment, null, storedPaymentMethods == null ? void 0 : storedPaymentMethods.map((storedPaymentMethod) => /* @__PURE__ */ (0, import_preact22.h)(
1774
+ return /* @__PURE__ */ (0, import_preact22.h)(import_preact22.Fragment, null, storedPaymentMethods?.map((storedPaymentMethod) => /* @__PURE__ */ (0, import_preact22.h)(
1778
1775
  stored_card_component_default,
1779
1776
  {
1780
1777
  key: storedPaymentMethod.id,
@@ -1957,9 +1954,10 @@ var straumur_checkout_container_default = StraumurCheckoutContainer2;
1957
1954
 
1958
1955
  // src/straumur-checkout.tsx
1959
1956
  var StraumurCheckout = class {
1957
+ configuration;
1958
+ paymentMethods = null;
1959
+ mountElement = null;
1960
1960
  constructor(config) {
1961
- this.paymentMethods = null;
1962
- this.mountElement = null;
1963
1961
  this.configuration = { ...config, locale: config.locale || "en-US" };
1964
1962
  }
1965
1963
  async mount(selector) {
package/dist/index.mjs CHANGED
@@ -963,7 +963,6 @@ var checkmark_default = CheckmarkIcon;
963
963
 
964
964
  // src/features/card/card-component.tsx
965
965
  function CardComponent({ configuration, paymentMethods }) {
966
- var _a, _b, _c;
967
966
  const cardElementRef = useRef3(null);
968
967
  const adyenCardRef = useRef3();
969
968
  const customCardRef = useRef3();
@@ -977,7 +976,7 @@ function CardComponent({ configuration, paymentMethods }) {
977
976
  encryptedExpiryDate: { visible: false },
978
977
  encryptedSecurityCode: { visible: false }
979
978
  });
980
- if (!((_a = paymentMethods.paymentMethods.paymentMethods) == null ? void 0 : _a.some((x) => x.type === "scheme"))) {
979
+ if (!paymentMethods.paymentMethods.paymentMethods?.some((x) => x.type === "scheme")) {
981
980
  return null;
982
981
  }
983
982
  const {
@@ -1064,7 +1063,7 @@ function CardComponent({ configuration, paymentMethods }) {
1064
1063
  const handleBoxChange = () => {
1065
1064
  setActivePaymentMethod("card");
1066
1065
  };
1067
- if (((_c = (_b = paymentMethods.paymentMethods) == null ? void 0 : _b.paymentMethods) == null ? void 0 : _c.length) === 0) {
1066
+ if (paymentMethods.paymentMethods?.paymentMethods?.length === 0) {
1068
1067
  return null;
1069
1068
  }
1070
1069
  const brands = schemeBrands.map((x) => {
@@ -1101,7 +1100,7 @@ function CardComponent({ configuration, paymentMethods }) {
1101
1100
  const { resultCode, action } = response;
1102
1101
  if (resultCode === "RedirectShopper" || resultCode === "IdentifyShopper") {
1103
1102
  setThreeDSecureActive(true);
1104
- adyenCardRef.current.createFromAction(action).mount(threeDSecureRef == null ? void 0 : threeDSecureRef.current);
1103
+ adyenCardRef.current.createFromAction(action).mount(threeDSecureRef?.current);
1105
1104
  return;
1106
1105
  }
1107
1106
  actions.resolve({ resultCode, action });
@@ -1308,7 +1307,6 @@ var googlepay_default = GooglePayIcon;
1308
1307
 
1309
1308
  // src/features/google-pay/google-pay-component.tsx
1310
1309
  function GooglePayComponent({ configuration, paymentMethods }) {
1311
- var _a;
1312
1310
  const googlePayElementRef = useRef4(null);
1313
1311
  const adyenCardRef = useRef4();
1314
1312
  const googlePayRef = useRef4();
@@ -1392,7 +1390,7 @@ function GooglePayComponent({ configuration, paymentMethods }) {
1392
1390
  const { resultCode, action } = response;
1393
1391
  if (resultCode === "RedirectShopper" || resultCode === "IdentifyShopper") {
1394
1392
  setThreeDSecureActive(true);
1395
- adyenCardRef.current.createFromAction(action).mount(threeDSecureRef == null ? void 0 : threeDSecureRef.current);
1393
+ adyenCardRef.current.createFromAction(action).mount(threeDSecureRef?.current);
1396
1394
  return;
1397
1395
  }
1398
1396
  actions.resolve({ resultCode, action });
@@ -1427,7 +1425,7 @@ function GooglePayComponent({ configuration, paymentMethods }) {
1427
1425
  handleError("error.paymentUnsuccessful");
1428
1426
  }
1429
1427
  }
1430
- const hasGooglePay = (_a = paymentMethods.paymentMethods.paymentMethods) == null ? void 0 : _a.some((x) => x.type === "googlepay");
1428
+ const hasGooglePay = paymentMethods.paymentMethods.paymentMethods?.some((x) => x.type === "googlepay");
1431
1429
  if (!hasGooglePay) {
1432
1430
  return null;
1433
1431
  }
@@ -1616,7 +1614,7 @@ function StoredCardComponent({
1616
1614
  const { resultCode, action } = response;
1617
1615
  if (resultCode === "RedirectShopper" || resultCode === "IdentifyShopper") {
1618
1616
  setThreeDSecureActive(true);
1619
- adyenCardRef.current.createFromAction(action).mount(threeDSecureRef == null ? void 0 : threeDSecureRef.current);
1617
+ adyenCardRef.current.createFromAction(action).mount(threeDSecureRef?.current);
1620
1618
  return;
1621
1619
  }
1622
1620
  actions.resolve({ resultCode, action });
@@ -1745,11 +1743,10 @@ function StoredCardContainerComponent({
1745
1743
  configuration,
1746
1744
  paymentMethods
1747
1745
  }) {
1748
- var _a;
1749
1746
  const [storedPaymentMethods, setStoredPaymentMethods] = useState6(
1750
- (_a = paymentMethods.paymentMethods.storedPaymentMethods) != null ? _a : []
1747
+ paymentMethods.paymentMethods.storedPaymentMethods ?? []
1751
1748
  );
1752
- if (!storedPaymentMethods || (storedPaymentMethods == null ? void 0 : storedPaymentMethods.length) === 0) {
1749
+ if (!storedPaymentMethods || storedPaymentMethods?.length === 0) {
1753
1750
  return null;
1754
1751
  }
1755
1752
  function handleStoredCardRemoved(storedPaymentMethodId) {
@@ -1757,7 +1754,7 @@ function StoredCardContainerComponent({
1757
1754
  (prevStoredPaymentMethods) => prevStoredPaymentMethods.filter((storedPaymentMethod) => storedPaymentMethod.id !== storedPaymentMethodId)
1758
1755
  );
1759
1756
  }
1760
- return /* @__PURE__ */ h21(Fragment4, null, storedPaymentMethods == null ? void 0 : storedPaymentMethods.map((storedPaymentMethod) => /* @__PURE__ */ h21(
1757
+ return /* @__PURE__ */ h21(Fragment4, null, storedPaymentMethods?.map((storedPaymentMethod) => /* @__PURE__ */ h21(
1761
1758
  stored_card_component_default,
1762
1759
  {
1763
1760
  key: storedPaymentMethod.id,
@@ -1940,9 +1937,10 @@ var straumur_checkout_container_default = StraumurCheckoutContainer2;
1940
1937
 
1941
1938
  // src/straumur-checkout.tsx
1942
1939
  var StraumurCheckout = class {
1940
+ configuration;
1941
+ paymentMethods = null;
1942
+ mountElement = null;
1943
1943
  constructor(config) {
1944
- this.paymentMethods = null;
1945
- this.mountElement = null;
1946
1944
  this.configuration = { ...config, locale: config.locale || "en-US" };
1947
1945
  }
1948
1946
  async mount(selector) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "straumur-web-component",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://docs.straumur.is",
6
6
  "type": "module",
@@ -8,8 +8,16 @@
8
8
  "module": "dist/index.mjs",
9
9
  "types": "dist/index.d.ts",
10
10
  "exports": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.cjs"
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.mjs"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
20
+ }
13
21
  },
14
22
  "description": "",
15
23
  "keywords": [