@paykka/card-checkout-ui 0.5.15 → 0.6.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.
Files changed (108) hide show
  1. package/dist/card-checkout-ui.js +22 -0
  2. package/dist/card-checkout-ui.umd.cjs +19 -5
  3. package/dist/es/api/index.js +3 -0
  4. package/dist/es/api/modules/checkout/map.js +2 -1
  5. package/dist/es/api/modules/encrypted-card/index.js +54 -0
  6. package/dist/es/api/modules/get-browser-params.js +2 -2
  7. package/dist/es/api/modules/index.js +3 -0
  8. package/dist/es/components/AccountNameField/index.js +4 -0
  9. package/dist/es/components/AddressField/index.js +4 -0
  10. package/dist/es/components/AliPay/index.js +8 -8
  11. package/dist/es/components/ApplePay/index.js +71 -14
  12. package/dist/es/components/Card/index.js +56 -40
  13. package/dist/es/components/CardExpireDateField/index.js +8 -3
  14. package/dist/es/components/CardHolderNameField/index.js +4 -0
  15. package/dist/es/components/CardIBANField/index.js +4 -0
  16. package/dist/es/components/CardNumberField/index.js +34 -17
  17. package/dist/es/components/CardSecurityCodeField/index.js +8 -3
  18. package/dist/es/components/CardSelector/index.js +3 -0
  19. package/dist/es/components/CombinedEncryptedField/index.js +75 -0
  20. package/dist/es/components/EmailField/EmailField.js +4 -0
  21. package/dist/es/components/EncryptedCard/index.js +448 -0
  22. package/dist/es/components/GooglePay/index.js +57 -19
  23. package/dist/es/components/RecurringTip/index.js +1 -1
  24. package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +70 -25
  25. package/dist/es/components/SecuredIframe/index.js +190 -22
  26. package/dist/es/components/Sepa/index.js +16 -6
  27. package/dist/es/components/WechatPay/index.js +8 -8
  28. package/dist/es/components/index.js +4 -0
  29. package/dist/es/components/internal/CheckBox/CheckBox.js +1 -1
  30. package/dist/es/components/internal/Form/FormItem.js +28 -24
  31. package/dist/es/components/internal/Form/index.js +1 -0
  32. package/dist/es/components/internal/Form/type.js +15 -1
  33. package/dist/es/components/internal/Input/Input.js +9 -11
  34. package/dist/es/components/internal/Input/index.js +1 -0
  35. package/dist/es/components/internal/Input/type.js +13 -1
  36. package/dist/es/components/internal/Select/Select.js +2 -0
  37. package/dist/es/config.js +23 -6
  38. package/dist/es/constant.js +10 -0
  39. package/dist/es/core/PayKKaCheckout.js +62 -0
  40. package/dist/es/core/Session.js +3 -0
  41. package/dist/es/core/index.js +2 -0
  42. package/dist/es/core/query.js +4 -6
  43. package/dist/es/core.js +30 -30
  44. package/dist/es/hooks/useI18n.js +2 -2
  45. package/dist/es/hooks/usePayState.js +14 -25
  46. package/dist/es/i18n/I18n.js +11 -8
  47. package/dist/es/index.js +16 -3
  48. package/dist/es/out/fraud-detection.js +99 -0
  49. package/dist/es/style.css +8 -0
  50. package/dist/es/types/{radar.js → fraud-detection.js} +1 -1
  51. package/dist/es/types/index.js +49 -1
  52. package/dist/es/utils/card-brand/brands.js +16 -42
  53. package/dist/es/utils/index.js +11 -0
  54. package/dist/es/utils/load.js +14 -0
  55. package/dist/es/utils/style.js +37 -0
  56. package/dist/style.css +1 -1
  57. package/dist/types/api/modules/checkout/map.d.ts +1 -0
  58. package/dist/types/api/modules/encrypted-card/index.d.ts +6 -0
  59. package/dist/types/api/modules/encrypted-card/type.d.ts +31 -0
  60. package/dist/types/api/modules/get-browser-params.d.ts +2 -2
  61. package/dist/types/components/AliPay/type.d.ts +0 -4
  62. package/dist/types/components/ApplePay/type.d.ts +16 -7
  63. package/dist/types/components/ApplePay/utils.d.ts +3 -0
  64. package/dist/types/components/Card/type.d.ts +15 -5
  65. package/dist/types/components/CardExpireDateField/type.d.ts +1 -0
  66. package/dist/types/components/CardNumberField/type.d.ts +3 -0
  67. package/dist/types/components/CardSecurityCodeField/type.d.ts +1 -0
  68. package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +4 -0
  69. package/dist/types/components/CombinedEncryptedField/index.d.ts +2 -0
  70. package/dist/types/components/CombinedEncryptedField/type.d.ts +15 -0
  71. package/dist/types/components/EncryptedCard/EncryptedCard.d.ts +4 -0
  72. package/dist/types/components/EncryptedCard/index.d.ts +4 -0
  73. package/dist/types/components/EncryptedCard/output.d.ts +9 -0
  74. package/dist/types/components/EncryptedCard/type.d.ts +85 -0
  75. package/dist/types/components/GooglePay/type.d.ts +17 -8
  76. package/dist/types/components/GooglePay/utils.d.ts +2 -0
  77. package/dist/types/components/SecuredFieldsProvider/type.d.ts +103 -22
  78. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +6 -2
  79. package/dist/types/components/Sepa/type.d.ts +0 -4
  80. package/dist/types/components/WechatPay/type.d.ts +0 -4
  81. package/dist/types/components/index.d.ts +2 -0
  82. package/dist/types/components/internal/Form/FormItem.d.ts +1 -1
  83. package/dist/types/components/internal/Form/type.d.ts +7 -0
  84. package/dist/types/components/internal/Input/Input.d.ts +1 -1
  85. package/dist/types/components/internal/Input/type.d.ts +6 -0
  86. package/dist/types/config.d.ts +10 -3
  87. package/dist/types/constant.d.ts +1 -0
  88. package/dist/types/core/PayKKaCheckout.d.ts +12 -0
  89. package/dist/types/core/index.d.ts +1 -0
  90. package/dist/types/core/query.d.ts +2 -2
  91. package/dist/types/hooks/useI18n.d.ts +2 -2
  92. package/dist/types/hooks/usePayState.d.ts +4 -22
  93. package/dist/types/i18n/I18n.d.ts +6 -5
  94. package/dist/types/i18n/locales/index.d.ts +1 -0
  95. package/dist/types/index.d.ts +3 -3
  96. package/dist/types/out/fraud-detection.d.ts +9 -0
  97. package/dist/types/types/{radar.d.ts → fraud-detection.d.ts} +3 -2
  98. package/dist/types/types/index.d.ts +69 -1
  99. package/dist/types/utils/card-brand/brands.d.ts +3 -10
  100. package/dist/types/utils/card-brand/index.d.ts +10 -9
  101. package/dist/types/utils/format.d.ts +2 -3
  102. package/dist/types/utils/index.d.ts +3 -0
  103. package/dist/types/utils/load.d.ts +7 -0
  104. package/dist/types/utils/style.d.ts +17 -0
  105. package/package.json +2 -2
  106. package/dist/card-checkout-ui.iife.js +0 -8
  107. package/dist/es/out/radar.js +0 -123
  108. package/dist/types/out/radar.d.ts +0 -14
@@ -1,37 +1,48 @@
1
- import { w, A, F, h, u } from "../../core.js";
1
+ import { w, A, F, h, y, u } from "../../core.js";
2
2
  import { clamp } from "../../utils/index.js";
3
3
  import { useI18n } from "../../hooks/useI18n.js";
4
4
  import "../../core/context.js";
5
+ import "../../i18n/util.js";
6
+ import "../../i18n/locales/index.js";
7
+ import "../internal/Form/type.js";
5
8
  import "../internal/Form/context.js";
6
9
  import { FormItem } from "../internal/Form/FormItem.js";
7
10
  import "../internal/Form/Form.js";
8
11
  import { IconCardNo } from "../internal/icons/IconCardNo.js";
9
12
  import { Input } from "../internal/Input/Input.js";
10
- import { FieldType } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
11
- import { getSupportedCardBrands, getSupportedCardBrandsLengths, findCardBrandInfo } from "../../utils/card-brand/index.js";
13
+ import "../internal/Input/type.js";
14
+ import { EFieldType } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
15
+ import { getSupportedCardBrands, getSupportedCardBrandsLengths, finCardBrandInfoByCode, findCardBrandInfo } from "../../utils/card-brand/index.js";
12
16
  import { trimAll, limitedToNumber } from "../../utils/format.js";
13
17
  const CardNumberField = w((props, ref) => {
14
- var _a;
15
- const { supportedCardBrands = [], className, style, security } = props;
18
+ const { supportedCardBrands = [], className, security, showLabel } = props;
16
19
  const inputRef = A(null);
17
20
  const formItemRef = A(null);
18
21
  F(ref, () => ({
19
22
  input: inputRef.current,
20
23
  focus: () => {
21
- var _a2;
22
- (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
24
+ var _a;
25
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
23
26
  },
24
27
  blur: () => {
25
- var _a2;
26
- (_a2 = inputRef.current) == null ? void 0 : _a2.blur();
28
+ var _a;
29
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
27
30
  },
28
31
  resetValidation: (status, errorTip) => {
29
- var _a2;
30
- (_a2 = formItemRef.current) == null ? void 0 : _a2.resetValidation(status, [{ message: errorTip }]);
32
+ var _a;
33
+ (_a = formItemRef.current) == null ? void 0 : _a.resetValidation(status, [{ message: errorTip }]);
31
34
  },
32
35
  binValueChanged: (binValue) => {
33
36
  setValue(binValue);
34
37
  },
38
+ brandChanged: (brand) => {
39
+ if (brand) {
40
+ const brandInfo = finCardBrandInfoByCode(brand);
41
+ setBrandIcon(() => brandInfo == null ? void 0 : brandInfo.icon);
42
+ } else {
43
+ setBrandIcon(void 0);
44
+ }
45
+ },
35
46
  getCardBrand: () => findCardBrandInfo(trimAll(value), brands) || {}
36
47
  }));
37
48
  const { i18n } = useI18n();
@@ -39,7 +50,13 @@ const CardNumberField = w((props, ref) => {
39
50
  const [validationStatus, setValidationStatus] = h("");
40
51
  const brands = getSupportedCardBrands(supportedCardBrands);
41
52
  const brandLengths = getSupportedCardBrandsLengths(brands);
42
- const cardBrandIcon = (_a = findCardBrandInfo(trimAll(value), brands)) == null ? void 0 : _a.icon;
53
+ const [brandIcon, setBrandIcon] = h(void 0);
54
+ y(() => {
55
+ setBrandIcon(value ? () => {
56
+ var _a;
57
+ return (_a = findCardBrandInfo(trimAll(value), brands)) == null ? void 0 : _a.icon;
58
+ } : void 0);
59
+ }, [value]);
43
60
  const rule = {
44
61
  trigger: ["blur", "submit"],
45
62
  validator(value2) {
@@ -63,7 +80,7 @@ const CardNumberField = w((props, ref) => {
63
80
  }
64
81
  };
65
82
  function onInput(event) {
66
- var _a2;
83
+ var _a;
67
84
  const { currentTarget, inputType } = event;
68
85
  const selectionStart = currentTarget.selectionStart;
69
86
  let val = limitedToNumber(currentTarget.value);
@@ -74,11 +91,11 @@ const CardNumberField = w((props, ref) => {
74
91
  }
75
92
  setValue(currentTarget.value = val);
76
93
  currentTarget.setSelectionRange(pos, pos);
77
- (_a2 = props.onInput) == null ? void 0 : _a2.call(props, event);
94
+ (_a = props.onInput) == null ? void 0 : _a.call(props, event);
78
95
  }
79
96
  const RightIcon = () => {
80
97
  if (validationStatus !== "error") {
81
- const Icon = cardBrandIcon ?? IconCardNo;
98
+ const Icon = brandIcon ?? IconCardNo;
82
99
  return /* @__PURE__ */ u(Icon, { size: 32 });
83
100
  }
84
101
  };
@@ -86,12 +103,12 @@ const CardNumberField = w((props, ref) => {
86
103
  FormItem,
87
104
  {
88
105
  label: i18n.get("card.cardNumber.label"),
106
+ showLabel,
89
107
  path: "number",
90
108
  ref: formItemRef,
91
109
  rule,
92
110
  onValidationStatusChange: setValidationStatus,
93
111
  className,
94
- style,
95
112
  children: /* @__PURE__ */ u(
96
113
  Input,
97
114
  {
@@ -103,7 +120,7 @@ const CardNumberField = w((props, ref) => {
103
120
  onInput,
104
121
  rightIcon: RightIcon(),
105
122
  placeholder: i18n.get("card.cardNumber.placeholder"),
106
- children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": FieldType.CARD_NUMBER })
123
+ children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": EFieldType.CARD_NUMBER })
107
124
  }
108
125
  )
109
126
  }
@@ -5,13 +5,17 @@ import "../../utils/system-info/get-browser-info.js";
5
5
  import { limitedToNumber } from "../../utils/format.js";
6
6
  import { useI18n } from "../../hooks/useI18n.js";
7
7
  import "../../core/context.js";
8
+ import "../../i18n/util.js";
9
+ import "../../i18n/locales/index.js";
10
+ import "../internal/Form/type.js";
8
11
  import "../internal/Form/context.js";
9
12
  import { FormItem } from "../internal/Form/FormItem.js";
10
13
  import "../internal/Form/Form.js";
11
14
  import { Input } from "../internal/Input/Input.js";
12
- import { FieldType } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
15
+ import "../internal/Input/type.js";
16
+ import { EFieldType } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
13
17
  const CardSecurityCodeField = w((props, ref) => {
14
- const { className, style, security } = props;
18
+ const { className, style, security, showLabel } = props;
15
19
  const inputRef = A(null);
16
20
  const formItemRef = A(null);
17
21
  F(ref, () => ({
@@ -58,6 +62,7 @@ const CardSecurityCodeField = w((props, ref) => {
58
62
  FormItem,
59
63
  {
60
64
  label: i18n.get("card.cardSecurityCode.label"),
65
+ showLabel,
61
66
  path: "securityCode",
62
67
  ref: formItemRef,
63
68
  rule,
@@ -73,7 +78,7 @@ const CardSecurityCodeField = w((props, ref) => {
73
78
  value,
74
79
  onInput,
75
80
  placeholder: i18n.get("card.cardSecurityCode.placeholder"),
76
- children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": FieldType.CVV })
81
+ children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": EFieldType.CVV })
77
82
  }
78
83
  )
79
84
  }
@@ -4,6 +4,9 @@ import { useI18n } from "../../hooks/useI18n.js";
4
4
  import "../../core/context.js";
5
5
  import { finCardBrandInfoByCode } from "../../utils/card-brand/index.js";
6
6
  import "../../utils/system-info/get-browser-info.js";
7
+ import "../../i18n/util.js";
8
+ import "../../i18n/locales/index.js";
9
+ import "../internal/Form/type.js";
7
10
  import "../internal/Form/context.js";
8
11
  import { FormItem } from "../internal/Form/FormItem.js";
9
12
  import "../internal/Form/Form.js";
@@ -0,0 +1,75 @@
1
+ import { w, A, F, h, u, b } from "../../core.js";
2
+ import "../internal/Form/type.js";
3
+ import "../internal/Form/context.js";
4
+ import { FormItem } from "../internal/Form/FormItem.js";
5
+ import "../internal/Form/Form.js";
6
+ import { Input } from "../internal/Input/Input.js";
7
+ import "../internal/Input/type.js";
8
+ import { EFieldType } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
9
+ import { getSupportedCardBrands, finCardBrandInfoByCode, findCardBrandInfo } from "../../utils/card-brand/index.js";
10
+ import "../../utils/system-info/get-browser-info.js";
11
+ import { trimAll } from "../../utils/format.js";
12
+ import { IconCardNo } from "../internal/icons/IconCardNo.js";
13
+ const CombinedEncryptedField = w((props, ref) => {
14
+ const { supportedCardBrands = [], className } = props;
15
+ const inputRef = A(null);
16
+ const formItemRef = A(null);
17
+ F(ref, () => ({
18
+ input: inputRef.current,
19
+ focus: () => {
20
+ var _a;
21
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
22
+ },
23
+ blur: () => {
24
+ var _a;
25
+ (_a = inputRef.current) == null ? void 0 : _a.blur();
26
+ },
27
+ resetValidation: (status, errorTip) => {
28
+ var _a;
29
+ (_a = formItemRef.current) == null ? void 0 : _a.resetValidation(status, [{ message: errorTip }]);
30
+ },
31
+ binValueChanged: (binValue2) => {
32
+ setBinValue(binValue2);
33
+ },
34
+ brandChanged: (brand) => {
35
+ if (brand) {
36
+ const brandInfo = finCardBrandInfoByCode(brand);
37
+ setBrandIcon(() => brandInfo == null ? void 0 : brandInfo.icon);
38
+ } else {
39
+ setBrandIcon(void 0);
40
+ }
41
+ },
42
+ getCardBrand: () => findCardBrandInfo(trimAll(binValue), brands) || {}
43
+ }));
44
+ const [binValue, setBinValue] = h("");
45
+ const brands = getSupportedCardBrands(supportedCardBrands);
46
+ const [brandIcon, setBrandIcon] = h(void 0);
47
+ const LeftIcon = () => {
48
+ const Icon = brandIcon ?? IconCardNo;
49
+ return /* @__PURE__ */ u(Icon, { size: 32 });
50
+ };
51
+ return /* @__PURE__ */ u(
52
+ FormItem,
53
+ {
54
+ showLabel: false,
55
+ ref: formItemRef,
56
+ className,
57
+ children: /* @__PURE__ */ u(
58
+ Input,
59
+ {
60
+ ref: inputRef,
61
+ leftIcon: LeftIcon(),
62
+ rightIcon: /* @__PURE__ */ u(b, {}),
63
+ children: /* @__PURE__ */ u("div", { style: "width:100%;height:100%;display:flex", children: [
64
+ /* @__PURE__ */ u("div", { style: "flex:1", "data-sf": EFieldType.CARD_NUMBER }),
65
+ /* @__PURE__ */ u("div", { style: "width:100px", "data-sf": EFieldType.EXPIRE_DATE }),
66
+ /* @__PURE__ */ u("div", { style: "width:60px", "data-sf": EFieldType.CVV })
67
+ ] })
68
+ }
69
+ )
70
+ }
71
+ );
72
+ });
73
+ export {
74
+ CombinedEncryptedField
75
+ };
@@ -10,10 +10,14 @@ import "../../utils/card-brand/brands.js";
10
10
  import "../../utils/system-info/get-browser-info.js";
11
11
  import { useI18n } from "../../hooks/useI18n.js";
12
12
  import "../../core/context.js";
13
+ import "../../i18n/util.js";
14
+ import "../../i18n/locales/index.js";
15
+ import "../internal/Form/type.js";
13
16
  import "../internal/Form/context.js";
14
17
  import { FormItem } from "../internal/Form/FormItem.js";
15
18
  import "../internal/Form/Form.js";
16
19
  import { Input } from "../internal/Input/Input.js";
20
+ import "../internal/Input/type.js";
17
21
  class EmailState {
18
22
  constructor(email) {
19
23
  __publicField(this, "_email");