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