@atls/tinkoff-payment-widget 0.0.3 → 0.1.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.
Files changed (103) hide show
  1. package/dist/data/fields.data.d.ts +4 -4
  2. package/dist/data/fields.data.js +6 -9
  3. package/dist/data/index.d.ts +1 -1
  4. package/dist/data/index.js +1 -17
  5. package/dist/enums/button.enum.js +2 -5
  6. package/dist/enums/fields.enum.js +4 -7
  7. package/dist/enums/index.d.ts +8 -8
  8. package/dist/enums/index.js +8 -24
  9. package/dist/enums/language.enum.js +2 -5
  10. package/dist/enums/payment-method.enum.js +2 -5
  11. package/dist/enums/payment-object.enum.js +2 -5
  12. package/dist/enums/tax.enum.js +2 -5
  13. package/dist/enums/taxation.enum.js +2 -5
  14. package/dist/enums/wrapper.enum.js +2 -5
  15. package/dist/hooks/index.d.ts +6 -6
  16. package/dist/hooks/index.js +6 -28
  17. package/dist/hooks/use-custom-button.hook.d.ts +2 -2
  18. package/dist/hooks/use-custom-button.hook.js +3 -7
  19. package/dist/hooks/use-custom-fields.hook.d.ts +2 -2
  20. package/dist/hooks/use-custom-fields.hook.js +13 -17
  21. package/dist/hooks/use-fields-render.hook.d.ts +8 -8
  22. package/dist/hooks/use-fields-render.hook.js +16 -23
  23. package/dist/hooks/use-fields-state.hook.d.ts +4 -4
  24. package/dist/hooks/use-fields-state.hook.js +6 -10
  25. package/dist/hooks/use-init.hook.js +8 -10
  26. package/dist/hooks/use-validate.hook.d.ts +6 -4
  27. package/dist/hooks/use-validate.hook.js +13 -17
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +2 -24
  30. package/dist/interfaces/custom-fields.iterfaces.d.ts +5 -5
  31. package/dist/interfaces/custom-fields.iterfaces.js +1 -2
  32. package/dist/interfaces/fields.interfaces.d.ts +11 -11
  33. package/dist/interfaces/fields.interfaces.js +1 -2
  34. package/dist/interfaces/form.interfaces.d.ts +9 -9
  35. package/dist/interfaces/form.interfaces.js +1 -2
  36. package/dist/interfaces/index.d.ts +9 -9
  37. package/dist/interfaces/index.js +9 -25
  38. package/dist/interfaces/receipt.interfaces.d.ts +6 -6
  39. package/dist/interfaces/receipt.interfaces.js +1 -2
  40. package/dist/interfaces/settings.interfaces.d.ts +1 -1
  41. package/dist/interfaces/settings.interfaces.js +1 -2
  42. package/dist/interfaces/styles.interfaces.d.ts +1 -1
  43. package/dist/interfaces/styles.interfaces.js +2 -5
  44. package/dist/interfaces/theme.interfaces.d.ts +1 -1
  45. package/dist/interfaces/theme.interfaces.js +1 -2
  46. package/dist/interfaces/widget.interfaces.d.ts +6 -6
  47. package/dist/interfaces/widget.interfaces.js +1 -2
  48. package/dist/interfaces/wrappers.interfaces.d.ts +6 -6
  49. package/dist/interfaces/wrappers.interfaces.js +1 -2
  50. package/dist/ui/button/button.component.d.ts +2 -2
  51. package/dist/ui/button/button.component.js +11 -18
  52. package/dist/ui/button/button.styles.d.ts +1 -1
  53. package/dist/ui/button/button.styles.js +24 -30
  54. package/dist/ui/fields.component.d.ts +3 -3
  55. package/dist/ui/fields.component.js +21 -28
  56. package/dist/ui/form/form.component.d.ts +2 -3
  57. package/dist/ui/form/form.component.js +17 -24
  58. package/dist/ui/form/form.context.d.ts +1 -2
  59. package/dist/ui/form/form.context.js +3 -6
  60. package/dist/ui/form/form.provider.d.ts +2 -2
  61. package/dist/ui/form/form.provider.js +17 -24
  62. package/dist/ui/form/index.d.ts +3 -2
  63. package/dist/ui/form/index.js +3 -18
  64. package/dist/ui/form/use-form.hook.d.ts +1 -1
  65. package/dist/ui/form/use-form.hook.js +4 -8
  66. package/dist/ui/index.d.ts +4 -4
  67. package/dist/ui/index.js +4 -23
  68. package/dist/ui/input/input.component.d.ts +4 -3
  69. package/dist/ui/input/input.component.js +32 -39
  70. package/dist/ui/input/input.styles.d.ts +1 -1
  71. package/dist/ui/input/input.styles.js +11 -15
  72. package/dist/ui/settings.component.d.ts +1 -1
  73. package/dist/ui/settings.component.js +11 -17
  74. package/dist/ui/theme/src/index.d.ts +2 -2
  75. package/dist/ui/theme/src/index.js +3 -32
  76. package/dist/ui/theme/src/theme/colors.js +1 -4
  77. package/dist/ui/theme/src/theme/index.d.ts +1 -1
  78. package/dist/ui/theme/src/theme/index.js +1 -17
  79. package/dist/ui/theme/src/theme.provider.d.ts +2 -2
  80. package/dist/ui/theme/src/theme.provider.js +4 -34
  81. package/dist/ui/widget.component.d.ts +3 -3
  82. package/dist/ui/widget.component.js +24 -54
  83. package/dist/ui/wrapper/button-wrapper.component.d.ts +2 -2
  84. package/dist/ui/wrapper/button-wrapper.component.js +10 -16
  85. package/dist/ui/wrapper/index.d.ts +2 -2
  86. package/dist/ui/wrapper/index.js +2 -18
  87. package/dist/ui/wrapper/input-wrapper.component.d.ts +2 -2
  88. package/dist/ui/wrapper/input-wrapper.component.js +12 -18
  89. package/dist/utils/add-receipt-fields.util.d.ts +2 -2
  90. package/dist/utils/add-receipt-fields.util.js +5 -9
  91. package/dist/utils/convert-to-penny.util.d.ts +2 -12
  92. package/dist/utils/convert-to-penny.util.js +1 -5
  93. package/dist/utils/get-name-fields.util.d.ts +3 -3
  94. package/dist/utils/get-name-fields.util.js +3 -7
  95. package/dist/utils/index.d.ts +5 -5
  96. package/dist/utils/index.js +5 -21
  97. package/dist/utils/is-custom-element.util.d.ts +2 -2
  98. package/dist/utils/is-custom-element.util.js +2 -6
  99. package/dist/utils/pay.util.d.ts +3 -3
  100. package/dist/utils/pay.util.js +4 -9
  101. package/dist/utils/translate.util.d.ts +1 -1
  102. package/dist/utils/translate.util.js +1 -5
  103. package/package.json +23 -3
@@ -1,20 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InputWrapper = void 0;
7
- const condition_1 = require("@atls-ui-parts/condition");
8
- const react_1 = __importDefault(require("react"));
9
- const react_intl_1 = require("react-intl");
10
- const enums_1 = require("../../enums");
11
- const translate_util_1 = require("../../utils/translate.util");
12
- const form_1 = require("../form");
1
+ import { Condition } from '@atls-ui-parts/condition';
2
+ import { useIntl } from 'react-intl';
3
+ import React from 'react';
4
+ import { NameWrapperComponent } from '../../enums/index.js';
5
+ import { translate } from '../../utils/translate.util.js';
6
+ import { useForm } from '../form/index.js';
13
7
  const InputWrapper = ({ name, children }) => {
14
- const { fieldsState, handleChange, handleBlur, errors } = (0, form_1.useForm)();
15
- const intl = (0, react_intl_1.useIntl)();
16
- const translateError = (0, translate_util_1.translate)(intl, errors[name], errors[name]);
17
- return (react_1.default.createElement(condition_1.Condition, { match: typeof children === 'function' }, children({
8
+ const { fieldsState, handleChange, handleBlur, errors } = useForm();
9
+ const intl = useIntl();
10
+ const translateError = translate(intl, errors[name], errors[name]);
11
+ return (React.createElement(Condition, { match: typeof children === 'function' }, children({
18
12
  name,
19
13
  value: fieldsState[name],
20
14
  onChangeNative: handleChange,
@@ -22,5 +16,5 @@ const InputWrapper = ({ name, children }) => {
22
16
  errorText: translateError,
23
17
  })));
24
18
  };
25
- exports.InputWrapper = InputWrapper;
26
- InputWrapper.displayName = enums_1.NameWrapperComponent.InputWrapper;
19
+ InputWrapper.displayName = NameWrapperComponent.InputWrapper;
20
+ export { InputWrapper };
@@ -1,2 +1,2 @@
1
- import { AdditionalField } from '../interfaces';
2
- export declare const addReceiptFieldsUtil: (additionalFields: AdditionalField[]) => AdditionalField[];
1
+ import type { AdditionalField } from '../interfaces/index.js';
2
+ export declare const addReceiptFieldsUtil: (additionalFields: Array<AdditionalField>) => Array<AdditionalField>;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addReceiptFieldsUtil = void 0;
4
- const enums_1 = require("../enums");
5
- const data_1 = require("../data");
6
- const addReceiptFieldsUtil = (additionalFields) => {
7
- const missingReceiptFields = !additionalFields.some((field) => field.name === enums_1.AdditionalFieldsType.Email || field.name === enums_1.AdditionalFieldsType.Phone);
8
- return missingReceiptFields ? [...data_1.receiptFields, ...additionalFields] : additionalFields;
1
+ import { AdditionalFieldsType } from '../enums/index.js';
2
+ import { receiptFields } from '../data/index.js';
3
+ export const addReceiptFieldsUtil = (additionalFields) => {
4
+ const missingReceiptFields = !additionalFields.some((field) => field.name === AdditionalFieldsType.Email || field.name === AdditionalFieldsType.Phone);
5
+ return missingReceiptFields ? [...receiptFields, ...additionalFields] : additionalFields;
9
6
  };
10
- exports.addReceiptFieldsUtil = addReceiptFieldsUtil;
@@ -1,12 +1,2 @@
1
- import { ReceiptItem } from '../interfaces';
2
- export declare const convertToPenny: (products: ReceiptItem[]) => {
3
- Amount: number;
4
- Price: number;
5
- Name: string;
6
- Quantity: number;
7
- Tax: import("..").TaxType;
8
- PaymentMethod?: import("..").PaymentMethodType | undefined;
9
- PaymentObject?: import("..").PaymentObjectType | undefined;
10
- Ean13?: string | undefined;
11
- ShopCode?: string | undefined;
12
- }[];
1
+ import type { ReceiptItem } from '../interfaces/index.js';
2
+ export declare const convertToPenny: (products: Array<ReceiptItem>) => Array<ReceiptItem>;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToPenny = void 0;
4
- const convertToPenny = (products) => products.map((product) => ({
1
+ export const convertToPenny = (products) => products.map((product) => ({
5
2
  ...product,
6
3
  Amount: product.Amount * 100,
7
4
  Price: product.Price * 100,
8
5
  }));
9
- exports.convertToPenny = convertToPenny;
@@ -1,3 +1,3 @@
1
- import { ReactNode } from 'react';
2
- import { Field } from '../interfaces';
3
- export declare const getNameFields: (customFields: ReactNode[]) => Field[];
1
+ import type { ReactNode } from 'react';
2
+ import type { Field } from '../interfaces/index.js';
3
+ export declare const getNameFields: (customFields: Array<ReactNode>) => Array<Field>;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNameFields = void 0;
4
- const react_1 = require("react");
5
- const getNameFields = (customFields) => customFields.reduce((acc, field) => {
6
- if ((0, react_1.isValidElement)(field))
1
+ import { isValidElement } from 'react';
2
+ export const getNameFields = (customFields) => customFields.reduce((acc, field) => {
3
+ if (isValidElement(field))
7
4
  acc.push({
8
5
  name: field.props.name,
9
6
  });
10
7
  return acc;
11
8
  }, []);
12
- exports.getNameFields = getNameFields;
@@ -1,5 +1,5 @@
1
- export * from './pay.util';
2
- export * from './add-receipt-fields.util';
3
- export * from './convert-to-penny.util';
4
- export * from './is-custom-element.util';
5
- export * from './get-name-fields.util';
1
+ export * from './pay.util.js';
2
+ export * from './add-receipt-fields.util.js';
3
+ export * from './convert-to-penny.util.js';
4
+ export * from './is-custom-element.util.js';
5
+ export * from './get-name-fields.util.js';
@@ -1,21 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./pay.util"), exports);
18
- __exportStar(require("./add-receipt-fields.util"), exports);
19
- __exportStar(require("./convert-to-penny.util"), exports);
20
- __exportStar(require("./is-custom-element.util"), exports);
21
- __exportStar(require("./get-name-fields.util"), exports);
1
+ export * from "./pay.util.js";
2
+ export * from "./add-receipt-fields.util.js";
3
+ export * from "./convert-to-penny.util.js";
4
+ export * from "./is-custom-element.util.js";
5
+ export * from "./get-name-fields.util.js";
@@ -1,3 +1,3 @@
1
- import { ReactNode } from 'react';
2
- import { NameWrapperComponent } from '../enums';
1
+ import type { ReactNode } from 'react';
2
+ import type { NameWrapperComponent } from '../enums/index.js';
3
3
  export declare const isCustomElement: (nameNode: NameWrapperComponent, node: ReactNode) => boolean;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCustomElement = void 0;
4
- const react_1 = require("react");
5
- const isCustomElement = (nameNode, node) => (0, react_1.isValidElement)(node) && typeof node.type === 'function'
1
+ import { isValidElement } from 'react';
2
+ export const isCustomElement = (nameNode, node) => isValidElement(node) && typeof node.type === 'function'
6
3
  ? node.type.displayName === nameNode &&
7
4
  typeof node.props.children === 'function'
8
5
  : false;
9
- exports.isCustomElement = isCustomElement;
@@ -1,5 +1,5 @@
1
- import { FormEvent } from 'react';
2
- import { FormEventHandler } from 'react';
3
- import { ReceiptSettings } from '../interfaces';
1
+ import type { FormEventHandler } from 'react';
2
+ import type { FormEvent } from 'react';
3
+ import type { ReceiptSettings } from '../interfaces/index.js';
4
4
  export declare const makePayment: FormEventHandler<HTMLFormElement>;
5
5
  export declare const makePaymentWithCheck: (event: FormEvent<HTMLFormElement>, receiptSettings: ReceiptSettings) => void;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makePaymentWithCheck = exports.makePayment = void 0;
4
- const convert_to_penny_util_1 = require("./convert-to-penny.util");
5
- const makePayment = (event) => {
1
+ import { convertToPenny } from './convert-to-penny.util.js';
2
+ export const makePayment = (event) => {
6
3
  const { pay } = window;
7
4
  pay(event.target);
8
5
  };
9
- exports.makePayment = makePayment;
10
- const makePaymentWithCheck = (event, receiptSettings) => {
6
+ export const makePaymentWithCheck = (event, receiptSettings) => {
11
7
  const form = event.target;
12
8
  const receiptElement = form.elements.namedItem('receipt');
13
9
  const email = form.elements.namedItem('email');
@@ -15,7 +11,7 @@ const makePaymentWithCheck = (event, receiptSettings) => {
15
11
  const receipt = {
16
12
  Taxation: receiptSettings.Taxation,
17
13
  EmailCompany: receiptSettings.EmailCompany,
18
- Items: (0, convert_to_penny_util_1.convertToPenny)(receiptSettings.Items),
14
+ Items: convertToPenny(receiptSettings.Items),
19
15
  };
20
16
  if (email?.value) {
21
17
  receipt.Email = email.value;
@@ -27,4 +23,3 @@ const makePaymentWithCheck = (event, receiptSettings) => {
27
23
  const { pay } = window;
28
24
  pay(form);
29
25
  };
30
- exports.makePaymentWithCheck = makePaymentWithCheck;
@@ -1,2 +1,2 @@
1
- import { IntlShape } from 'react-intl';
1
+ import type { IntlShape } from 'react-intl';
2
2
  export declare const translate: (intl: IntlShape, messageId: string, defaultMessage: string) => string;
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.translate = void 0;
4
- const translate = (intl, messageId, defaultMessage) => intl.messages[messageId] ? intl.formatMessage({ id: messageId }) : defaultMessage;
5
- exports.translate = translate;
1
+ export const translate = (intl, messageId, defaultMessage) => intl.messages[messageId] ? intl.formatMessage({ id: messageId }) : defaultMessage;
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@atls/tinkoff-payment-widget",
3
- "version": "0.0.3",
3
+ "version": "0.1.1",
4
4
  "license": "BSD-3-Clause",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
6
15
  "files": [
7
16
  "dist"
8
17
  ],
@@ -26,11 +35,14 @@
26
35
  "@emotion/jest": "11.9.4",
27
36
  "@emotion/react": "11.9.3",
28
37
  "@emotion/styled": "11.9.3",
29
- "@testing-library/react": "14.1.0",
30
- "@types/react": "18.2.20",
38
+ "@testing-library/react": "16.1.0",
39
+ "@types/node": "22.10.1",
40
+ "@types/react": "18.3.6",
31
41
  "@types/react-dom": "18",
32
42
  "@types/styled-system": "5.1.16",
33
43
  "csstype": "3.1.2",
44
+ "global-jsdom": "25.0.0",
45
+ "jsdom": "25.0.1",
34
46
  "react": "18.2.0",
35
47
  "react-dom": "18.2.0",
36
48
  "styled-system": "5.1.5"
@@ -42,6 +54,14 @@
42
54
  },
43
55
  "publishConfig": {
44
56
  "access": "public",
57
+ "exports": {
58
+ "./package.json": "./package.json",
59
+ ".": {
60
+ "import": "./dist/index.js",
61
+ "types": "./dist/index.d.ts",
62
+ "default": "./dist/index.js"
63
+ }
64
+ },
45
65
  "main": "dist/index.js",
46
66
  "typings": "dist/index.d.ts"
47
67
  },