@atls/tinkoff-payment-widget 0.0.3 → 0.0.5
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/data/fields.data.d.ts +4 -4
- package/dist/enums/button.enum.js +1 -1
- package/dist/enums/fields.enum.js +2 -2
- package/dist/enums/language.enum.js +1 -1
- package/dist/enums/payment-method.enum.js +1 -1
- package/dist/enums/payment-object.enum.js +1 -1
- package/dist/enums/tax.enum.js +1 -1
- package/dist/enums/taxation.enum.js +1 -1
- package/dist/enums/wrapper.enum.js +1 -1
- package/dist/hooks/use-custom-button.hook.d.ts +2 -2
- package/dist/hooks/use-custom-fields.hook.d.ts +2 -2
- package/dist/hooks/use-fields-render.hook.d.ts +8 -8
- package/dist/hooks/use-fields-render.hook.js +1 -1
- package/dist/hooks/use-fields-state.hook.d.ts +4 -4
- package/dist/hooks/use-init.hook.js +3 -1
- package/dist/hooks/use-validate.hook.d.ts +6 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/interfaces/custom-fields.iterfaces.d.ts +5 -5
- package/dist/interfaces/fields.interfaces.d.ts +11 -11
- package/dist/interfaces/form.interfaces.d.ts +9 -9
- package/dist/interfaces/receipt.interfaces.d.ts +6 -6
- package/dist/interfaces/settings.interfaces.d.ts +1 -1
- package/dist/interfaces/styles.interfaces.d.ts +1 -1
- package/dist/interfaces/styles.interfaces.js +1 -1
- package/dist/interfaces/theme.interfaces.d.ts +1 -1
- package/dist/interfaces/widget.interfaces.d.ts +6 -6
- package/dist/interfaces/wrappers.interfaces.d.ts +6 -6
- package/dist/ui/button/button.component.d.ts +2 -2
- package/dist/ui/button/button.component.js +1 -1
- package/dist/ui/button/button.styles.d.ts +1 -1
- package/dist/ui/fields.component.d.ts +3 -3
- package/dist/ui/fields.component.js +1 -1
- package/dist/ui/form/form.component.d.ts +3 -3
- package/dist/ui/form/form.component.js +1 -1
- package/dist/ui/form/form.context.d.ts +1 -1
- package/dist/ui/form/form.provider.d.ts +2 -2
- package/dist/ui/form/form.provider.js +5 -5
- package/dist/ui/form/use-form.hook.d.ts +1 -1
- package/dist/ui/input/input.component.d.ts +2 -2
- package/dist/ui/input/input.component.js +13 -13
- package/dist/ui/input/input.styles.d.ts +1 -1
- package/dist/ui/settings.component.d.ts +1 -1
- package/dist/ui/settings.component.js +8 -8
- package/dist/ui/theme/src/theme.provider.d.ts +2 -2
- package/dist/ui/theme/src/theme.provider.js +1 -1
- package/dist/ui/widget.component.d.ts +3 -3
- package/dist/ui/widget.component.js +10 -10
- package/dist/ui/wrapper/button-wrapper.component.d.ts +2 -2
- package/dist/ui/wrapper/input-wrapper.component.d.ts +2 -2
- package/dist/ui/wrapper/input-wrapper.component.js +1 -1
- package/dist/utils/add-receipt-fields.util.d.ts +2 -2
- package/dist/utils/convert-to-penny.util.d.ts +2 -12
- package/dist/utils/get-name-fields.util.d.ts +3 -3
- package/dist/utils/is-custom-element.util.d.ts +2 -2
- package/dist/utils/pay.util.d.ts +3 -3
- package/dist/utils/translate.util.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdditionalField } from '../interfaces';
|
|
2
|
-
import { RequiredField } from '../interfaces';
|
|
3
|
-
export declare const requiredFields: RequiredField
|
|
4
|
-
export declare const receiptFields: AdditionalField
|
|
1
|
+
import type { AdditionalField } from '../interfaces';
|
|
2
|
+
import type { RequiredField } from '../interfaces';
|
|
3
|
+
export declare const requiredFields: Array<RequiredField>;
|
|
4
|
+
export declare const receiptFields: Array<AdditionalField>;
|
|
@@ -4,7 +4,7 @@ exports.AdditionalFieldsType = exports.RequiredFieldsType = void 0;
|
|
|
4
4
|
var RequiredFieldsType;
|
|
5
5
|
(function (RequiredFieldsType) {
|
|
6
6
|
RequiredFieldsType["Amount"] = "amount";
|
|
7
|
-
})(RequiredFieldsType
|
|
7
|
+
})(RequiredFieldsType || (exports.RequiredFieldsType = RequiredFieldsType = {}));
|
|
8
8
|
var AdditionalFieldsType;
|
|
9
9
|
(function (AdditionalFieldsType) {
|
|
10
10
|
AdditionalFieldsType["Name"] = "name";
|
|
@@ -12,4 +12,4 @@ var AdditionalFieldsType;
|
|
|
12
12
|
AdditionalFieldsType["Phone"] = "phone";
|
|
13
13
|
AdditionalFieldsType["Description"] = "description";
|
|
14
14
|
AdditionalFieldsType["Order"] = "order";
|
|
15
|
-
})(AdditionalFieldsType
|
|
15
|
+
})(AdditionalFieldsType || (exports.AdditionalFieldsType = AdditionalFieldsType = {}));
|
|
@@ -10,4 +10,4 @@ var PaymentMethodType;
|
|
|
10
10
|
PaymentMethodType["PartialPayment"] = "partial_payment";
|
|
11
11
|
PaymentMethodType["Credit"] = "credit";
|
|
12
12
|
PaymentMethodType["CreditPayment"] = "credit_payment";
|
|
13
|
-
})(PaymentMethodType
|
|
13
|
+
})(PaymentMethodType || (exports.PaymentMethodType = PaymentMethodType = {}));
|
|
@@ -16,4 +16,4 @@ var PaymentObjectType;
|
|
|
16
16
|
PaymentObjectType["AgentCommission"] = "agent_commission";
|
|
17
17
|
PaymentObjectType["Composite"] = "composite";
|
|
18
18
|
PaymentObjectType["Another"] = "another";
|
|
19
|
-
})(PaymentObjectType
|
|
19
|
+
})(PaymentObjectType || (exports.PaymentObjectType = PaymentObjectType = {}));
|
package/dist/enums/tax.enum.js
CHANGED
|
@@ -5,4 +5,4 @@ var NameWrapperComponent;
|
|
|
5
5
|
(function (NameWrapperComponent) {
|
|
6
6
|
NameWrapperComponent["InputWrapper"] = "InputWrapper";
|
|
7
7
|
NameWrapperComponent["ButtonWrapper"] = "ButtonWrapper";
|
|
8
|
-
})(NameWrapperComponent
|
|
8
|
+
})(NameWrapperComponent || (exports.NameWrapperComponent = NameWrapperComponent = {}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export declare const useCustomButton: (nodeArray: ReactNode
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export declare const useCustomButton: (nodeArray: Array<ReactNode>) => ReactNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CustomFields } from '../interfaces';
|
|
2
|
-
import { CustomFieldsProps } from '../interfaces';
|
|
1
|
+
import type { CustomFields } from '../interfaces';
|
|
2
|
+
import type { CustomFieldsProps } from '../interfaces';
|
|
3
3
|
export declare const useCustomFields: ({ existAmount, existReceipt, existAdditionalFields, nodeArray, }: CustomFieldsProps) => CustomFields;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Field } from '../interfaces';
|
|
3
|
-
import { NameField } from '../interfaces';
|
|
4
|
-
import { HandleBlurField } from '../interfaces';
|
|
5
|
-
import { FieldState } from '../interfaces';
|
|
6
|
-
import { HandleChangeField } from '../interfaces';
|
|
7
|
-
import { FieldsErrors } from '../interfaces';
|
|
8
|
-
export declare const useFieldsRenderer: (fields: Field
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Field } from '../interfaces';
|
|
3
|
+
import type { NameField } from '../interfaces';
|
|
4
|
+
import type { HandleBlurField } from '../interfaces';
|
|
5
|
+
import type { FieldState } from '../interfaces';
|
|
6
|
+
import type { HandleChangeField } from '../interfaces';
|
|
7
|
+
import type { FieldsErrors } from '../interfaces';
|
|
8
|
+
export declare const useFieldsRenderer: (fields: Array<Field> | Array<NameField>, errors: FieldsErrors, fieldsState: FieldState, handleChange: HandleChangeField, handleBlur: HandleBlurField, inputGaps: number) => ReactElement;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.useFieldsRenderer = void 0;
|
|
7
7
|
const condition_1 = require("@atls-ui-parts/condition");
|
|
8
8
|
const layout_1 = require("@atls-ui-parts/layout");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
9
|
const react_intl_1 = require("react-intl");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
11
|
const ui_1 = require("../ui");
|
|
12
12
|
const src_1 = require("../ui/theme/src");
|
|
13
13
|
const translate_util_1 = require("../utils/translate.util");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field } from '../interfaces';
|
|
2
|
-
import { FieldsState } from '../interfaces';
|
|
3
|
-
import { ValidateField } from '../interfaces';
|
|
4
|
-
export declare const useFieldsState: (validateField: ValidateField, fields: Field
|
|
1
|
+
import type { Field } from '../interfaces';
|
|
2
|
+
import type { FieldsState } from '../interfaces';
|
|
3
|
+
import type { ValidateField } from '../interfaces';
|
|
4
|
+
export declare const useFieldsState: (validateField: ValidateField, fields: Array<Field>) => FieldsState;
|
|
@@ -14,7 +14,9 @@ const useInit = () => {
|
|
|
14
14
|
const script = document.createElement('script');
|
|
15
15
|
script.src = TINKOFF_SCRIPT_URL;
|
|
16
16
|
script.async = true;
|
|
17
|
-
script.onload = () =>
|
|
17
|
+
script.onload = () => {
|
|
18
|
+
setIsLoaded(true);
|
|
19
|
+
};
|
|
18
20
|
script.onerror = () => {
|
|
19
21
|
console.error('Ошибка загрузки скрипта:', TINKOFF_SCRIPT_URL);
|
|
20
22
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { FieldsErrors } from '../interfaces';
|
|
2
|
-
import { ValidateField } from '../interfaces';
|
|
3
|
-
|
|
1
|
+
import type { FieldsErrors } from '../interfaces';
|
|
2
|
+
import type { ValidateField } from '../interfaces';
|
|
3
|
+
interface UseValidateReturn {
|
|
4
4
|
errors: FieldsErrors;
|
|
5
5
|
validateField: ValidateField;
|
|
6
6
|
isValidate: boolean;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
export declare const useValidate: () => UseValidateReturn;
|
|
9
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Widget, ButtonWrapper, InputWrapper } from './ui';
|
|
2
|
-
export { Settings, Styles, AdditionalField, Receipt, ReceiptItem, DirectionFields, } from './interfaces';
|
|
2
|
+
export type { Settings, Styles, AdditionalField, Receipt, ReceiptItem, DirectionFields, } from './interfaces';
|
|
3
3
|
export * from './enums';
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.InputWrapper = exports.ButtonWrapper = exports.Widget = void 0;
|
|
18
18
|
var ui_1 = require("./ui");
|
|
19
19
|
Object.defineProperty(exports, "Widget", { enumerable: true, get: function () { return ui_1.Widget; } });
|
|
20
20
|
Object.defineProperty(exports, "ButtonWrapper", { enumerable: true, get: function () { return ui_1.ButtonWrapper; } });
|
|
21
21
|
Object.defineProperty(exports, "InputWrapper", { enumerable: true, get: function () { return ui_1.InputWrapper; } });
|
|
22
|
-
var interfaces_1 = require("./interfaces");
|
|
23
|
-
Object.defineProperty(exports, "DirectionFields", { enumerable: true, get: function () { return interfaces_1.DirectionFields; } });
|
|
24
22
|
__exportStar(require("./enums"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Field } from './fields.interfaces';
|
|
3
|
-
export
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Field } from './fields.interfaces';
|
|
3
|
+
export type NameField = Pick<Field, 'name'>;
|
|
4
4
|
export interface CustomFields {
|
|
5
|
-
customFields: ReactNode
|
|
5
|
+
customFields: Array<ReactNode>;
|
|
6
6
|
isGenerateReceiptField: boolean;
|
|
7
7
|
isGenerateRequiredField: boolean;
|
|
8
8
|
}
|
|
@@ -10,5 +10,5 @@ export interface CustomFieldsProps {
|
|
|
10
10
|
existAmount: boolean;
|
|
11
11
|
existReceipt: boolean;
|
|
12
12
|
existAdditionalFields: boolean;
|
|
13
|
-
nodeArray: ReactNode
|
|
13
|
+
nodeArray: Array<ReactNode>;
|
|
14
14
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { FormEvent } from 'react';
|
|
2
|
-
import { HTMLInputTypeAttribute } from 'react';
|
|
3
|
-
import { AdditionalFieldsType } from '../enums';
|
|
4
|
-
import { RequiredFieldsType } from '../enums';
|
|
5
|
-
import { DirectionFields } from './styles.interfaces';
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
1
|
+
import type { FormEvent } from 'react';
|
|
2
|
+
import type { HTMLInputTypeAttribute } from 'react';
|
|
3
|
+
import type { AdditionalFieldsType } from '../enums';
|
|
4
|
+
import type { RequiredFieldsType } from '../enums';
|
|
5
|
+
import type { DirectionFields } from './styles.interfaces';
|
|
6
|
+
export type FieldsNames = AdditionalFieldsType | RequiredFieldsType;
|
|
7
|
+
export type FieldState = Record<FieldsNames, string>;
|
|
8
|
+
export type ValidateField = (name: FieldsNames, value: string, required?: boolean) => void;
|
|
9
|
+
export type HandleChangeField = (e: FormEvent<HTMLInputElement>) => void;
|
|
10
|
+
export type HandleBlurField = (e: FormEvent<HTMLInputElement>) => void;
|
|
11
11
|
export interface Field {
|
|
12
12
|
name: FieldsNames;
|
|
13
13
|
placeholder?: string;
|
|
@@ -20,7 +20,7 @@ export interface AdditionalField extends Field {
|
|
|
20
20
|
export interface RequiredField extends Field {
|
|
21
21
|
name: RequiredFieldsType;
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export type FieldsErrors = {
|
|
24
24
|
[key in FieldsNames]: string;
|
|
25
25
|
};
|
|
26
26
|
export interface FieldsProps {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { NameField } from './custom-fields.iterfaces';
|
|
3
|
-
import { Field } from './fields.interfaces';
|
|
4
|
-
import { FieldsState } from './fields.interfaces';
|
|
5
|
-
import { FieldsValidator } from './fields.interfaces';
|
|
6
|
-
import { WidgetProps } from './widget.interfaces';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { NameField } from './custom-fields.iterfaces';
|
|
3
|
+
import type { Field } from './fields.interfaces';
|
|
4
|
+
import type { FieldsState } from './fields.interfaces';
|
|
5
|
+
import type { FieldsValidator } from './fields.interfaces';
|
|
6
|
+
import type { WidgetProps } from './widget.interfaces';
|
|
7
7
|
export interface FormProps extends WidgetProps {
|
|
8
8
|
useCustomFields: boolean;
|
|
9
9
|
useCustomButton: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface FormProviderProps {
|
|
12
|
-
additionalFields?: Field
|
|
13
|
-
nameFields: Field
|
|
12
|
+
additionalFields?: Array<Field>;
|
|
13
|
+
nameFields: Array<Field>;
|
|
14
14
|
isGenerateReceipt: boolean;
|
|
15
15
|
isGenerateRequiredField: boolean;
|
|
16
16
|
disabled: boolean;
|
|
17
17
|
children: ReactNode;
|
|
18
18
|
}
|
|
19
19
|
export interface FormContext extends FieldsValidator, FieldsState {
|
|
20
|
-
fields: Field
|
|
20
|
+
fields: Array<Field> | Array<NameField>;
|
|
21
21
|
disabled: boolean;
|
|
22
22
|
isLoaded: boolean;
|
|
23
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PaymentMethodType } from '../enums';
|
|
2
|
-
import { PaymentObjectType } from '../enums';
|
|
3
|
-
import { TaxType } from '../enums';
|
|
4
|
-
import { TaxationType } from '../enums';
|
|
1
|
+
import type { PaymentMethodType } from '../enums';
|
|
2
|
+
import type { PaymentObjectType } from '../enums';
|
|
3
|
+
import type { TaxType } from '../enums';
|
|
4
|
+
import type { TaxationType } from '../enums';
|
|
5
5
|
export interface ReceiptItem {
|
|
6
6
|
Name: string;
|
|
7
7
|
Price: number;
|
|
@@ -18,10 +18,10 @@ export interface Receipt {
|
|
|
18
18
|
Phone?: string;
|
|
19
19
|
EmailCompany?: string;
|
|
20
20
|
Taxation: TaxationType;
|
|
21
|
-
Items: ReceiptItem
|
|
21
|
+
Items: Array<ReceiptItem>;
|
|
22
22
|
}
|
|
23
23
|
export interface ReceiptSettings {
|
|
24
24
|
Taxation: TaxationType;
|
|
25
|
-
Items: ReceiptItem
|
|
25
|
+
Items: Array<ReceiptItem>;
|
|
26
26
|
EmailCompany?: string;
|
|
27
27
|
}
|
|
@@ -5,4 +5,4 @@ var DirectionFields;
|
|
|
5
5
|
(function (DirectionFields) {
|
|
6
6
|
DirectionFields["Row"] = "row";
|
|
7
7
|
DirectionFields["Column"] = "column";
|
|
8
|
-
})(DirectionFields
|
|
8
|
+
})(DirectionFields || (exports.DirectionFields = DirectionFields = {}));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { AdditionalField } from './fields.interfaces';
|
|
3
|
-
import { ReceiptSettings } from './receipt.interfaces';
|
|
4
|
-
import { Settings } from './settings.interfaces';
|
|
5
|
-
import { Styles } from './styles.interfaces';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { AdditionalField } from './fields.interfaces';
|
|
3
|
+
import type { ReceiptSettings } from './receipt.interfaces';
|
|
4
|
+
import type { Settings } from './settings.interfaces';
|
|
5
|
+
import type { Styles } from './styles.interfaces';
|
|
6
6
|
export interface WidgetProps {
|
|
7
7
|
settings: Settings;
|
|
8
8
|
amount?: number;
|
|
9
9
|
receipt?: ReceiptSettings;
|
|
10
10
|
styles?: Styles;
|
|
11
|
-
additionalFields?: AdditionalField
|
|
11
|
+
additionalFields?: Array<AdditionalField>;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
children?: ReactNode;
|
|
14
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { AdditionalFieldsType } from '../enums';
|
|
3
|
-
import { ButtonType } from '../enums';
|
|
4
|
-
import { RequiredFieldsType } from '../enums';
|
|
5
|
-
import { HandleBlurField } from './fields.interfaces';
|
|
6
|
-
import { HandleChangeField } from './fields.interfaces';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { AdditionalFieldsType } from '../enums';
|
|
3
|
+
import type { ButtonType } from '../enums';
|
|
4
|
+
import type { RequiredFieldsType } from '../enums';
|
|
5
|
+
import type { HandleBlurField } from './fields.interfaces';
|
|
6
|
+
import type { HandleChangeField } from './fields.interfaces';
|
|
7
7
|
interface ChildrenInputProps {
|
|
8
8
|
name: string;
|
|
9
9
|
value: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ButtonProps } from '@atls-ui-parts/button';
|
|
2
|
-
import { FC } from 'react';
|
|
1
|
+
import type { ButtonProps } from '@atls-ui-parts/button';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
3
|
export declare const Button: FC<ButtonProps>;
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Button = void 0;
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
8
|
const react_laag_1 = require("react-laag");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const button_styles_1 = require("./button.styles");
|
|
11
11
|
const button_styles_2 = require("./button.styles");
|
|
12
12
|
const button_styles_3 = require("./button.styles");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const baseStyles: () =>
|
|
1
|
+
declare const baseStyles: () => Record<string, unknown>;
|
|
2
2
|
declare const contentStyles: any;
|
|
3
3
|
declare const appearanceStyles: <P = unknown>(props?: P | undefined) => any;
|
|
4
4
|
declare const shapeStyles: import("styled-system").styleFn;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FieldsProps } from '../interfaces';
|
|
3
|
-
export declare const Fields: ({ amount, direction, inputGaps, useCustomFields, }: FieldsProps) =>
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FieldsProps } from '../interfaces';
|
|
3
|
+
export declare const Fields: ({ amount, direction, inputGaps, useCustomFields, }: FieldsProps) => ReactNode;
|
|
@@ -24,7 +24,7 @@ const Fields = ({ amount, direction = interfaces_1.DirectionFields.Column, input
|
|
|
24
24
|
react_1.default.createElement(layout_3.Layout, { flexBasis: inputGaps, flexShrink: 0 }),
|
|
25
25
|
react_1.default.createElement(Direction, null,
|
|
26
26
|
react_1.default.createElement(condition_1.Condition, { match: Boolean(amount) },
|
|
27
|
-
react_1.default.createElement(hidden_input_1.HiddenInput, { name: enums_1.RequiredFieldsType.Amount, defaultValue: amount
|
|
27
|
+
react_1.default.createElement(hidden_input_1.HiddenInput, { disabled: true, readOnly: true, name: enums_1.RequiredFieldsType.Amount, defaultValue: amount })),
|
|
28
28
|
renderedFields),
|
|
29
29
|
react_1.default.createElement(layout_3.Layout, { flexBasis: inputGaps, flexShrink: 0 })));
|
|
30
30
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { FormProps } from '../../interfaces';
|
|
3
|
-
export declare const Form: ({ settings, amount, receipt, styles, useCustomButton, useCustomFields, children, }: FormProps) =>
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FormProps } from '../../interfaces';
|
|
3
|
+
export declare const Form: ({ settings, amount, receipt, styles, useCustomButton, useCustomFields, children, }: FormProps) => JSX.Element;
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Form = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
7
|
const react_intl_1 = require("react-intl");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const button_component_1 = require("../button/button.component");
|
|
10
10
|
const fields_component_1 = require("../fields.component");
|
|
11
11
|
const settings_component_1 = require("../settings.component");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FormContext } from '../../interfaces';
|
|
2
|
+
import type { FormContext } from '../../interfaces';
|
|
3
3
|
export declare const Context: import("react").Context<FormContext | null>;
|
|
4
4
|
export declare const Provider: import("react").Provider<FormContext | null>, Consumer: import("react").Consumer<FormContext | null>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { FormProviderProps } from '../../interfaces';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { FormProviderProps } from '../../interfaces';
|
|
3
3
|
export declare const FormProvider: FC<FormProviderProps>;
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FormProvider = void 0;
|
|
7
|
-
const react_1 =
|
|
8
|
-
const react_2 = require("react");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_2 = __importDefault(require("react"));
|
|
9
9
|
const form_context_1 = require("./form.context");
|
|
10
10
|
const data_1 = require("../../data");
|
|
11
11
|
const hooks_1 = require("../../hooks");
|
|
@@ -17,12 +17,12 @@ const FormProvider = ({ additionalFields, nameFields, isGenerateReceipt, isGener
|
|
|
17
17
|
const processedFields = additionalFields && isGenerateReceipt
|
|
18
18
|
? (0, utils_1.addReceiptFieldsUtil)(additionalFields)
|
|
19
19
|
: nameFields;
|
|
20
|
-
const fields = (0,
|
|
20
|
+
const fields = (0, react_1.useMemo)(() => additionalFields && isGenerateRequiredField
|
|
21
21
|
? [...data_1.requiredFields, ...processedFields]
|
|
22
22
|
: [...processedFields], [additionalFields, isGenerateRequiredField, processedFields]);
|
|
23
23
|
const { fieldsState, handleChange, handleBlur } = (0, hooks_1.useFieldsState)(validateField, fields);
|
|
24
24
|
const isLoaded = (0, hooks_2.useInit)();
|
|
25
|
-
const value = (0,
|
|
25
|
+
const value = (0, react_1.useMemo)(() => ({
|
|
26
26
|
fields,
|
|
27
27
|
fieldsState,
|
|
28
28
|
handleChange,
|
|
@@ -43,6 +43,6 @@ const FormProvider = ({ additionalFields, nameFields, isGenerateReceipt, isGener
|
|
|
43
43
|
disabled,
|
|
44
44
|
isLoaded,
|
|
45
45
|
]);
|
|
46
|
-
return
|
|
46
|
+
return react_2.default.createElement(form_context_1.Provider, { value: value }, children);
|
|
47
47
|
};
|
|
48
48
|
exports.FormProvider = FormProvider;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FormContext } from '../../interfaces';
|
|
1
|
+
import type { FormContext } from '../../interfaces';
|
|
2
2
|
export declare const useForm: () => FormContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InputProps as BaseInputProps } from '@atls-ui-parts/input';
|
|
1
|
+
import type { InputProps as BaseInputProps } from '@atls-ui-parts/input';
|
|
2
|
+
import type { ForwardRefRenderFunction } from 'react';
|
|
2
3
|
import React from 'react';
|
|
3
|
-
import { ForwardRefRenderFunction } from 'react';
|
|
4
4
|
export declare const InputElement: import("@emotion/styled").StyledComponent<any, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
5
5
|
interface InputProps extends BaseInputProps {
|
|
6
6
|
errorText?: string;
|
|
@@ -4,18 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MemoizedInput = exports.Input = exports.InputWithoutRef = exports.InputElement = void 0;
|
|
7
|
-
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
7
|
const condition_1 = require("@atls-ui-parts/condition");
|
|
9
8
|
const input_1 = require("@atls-ui-parts/input");
|
|
10
9
|
const layout_1 = require("@atls-ui-parts/layout");
|
|
11
10
|
const text_1 = require("@atls-ui-parts/text");
|
|
12
11
|
const input_2 = require("@atls-ui-parts/input");
|
|
13
|
-
const
|
|
12
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
13
|
+
const react_1 = require("react");
|
|
14
14
|
const react_2 = require("react");
|
|
15
15
|
const react_3 = require("react");
|
|
16
|
-
const react_4 = require("react");
|
|
17
16
|
const react_laag_1 = require("react-laag");
|
|
18
17
|
const styled_system_1 = require("styled-system");
|
|
18
|
+
const react_4 = __importDefault(require("react"));
|
|
19
19
|
const index_1 = require("../theme/src/index");
|
|
20
20
|
const input_styles_1 = require("./input.styles");
|
|
21
21
|
const input_styles_2 = require("./input.styles");
|
|
@@ -30,11 +30,11 @@ const Container = styled_1.default.div(({ type }) => ({
|
|
|
30
30
|
const InputWithoutRef = ({ value, type, required, disabled, errorText = '', onChange, onChangeNative, placeholder, ...props }, ref) => {
|
|
31
31
|
const changeValue = (0, input_2.useChangeValue)(disabled, onChange, onChangeNative);
|
|
32
32
|
const [, hoverProps] = (0, react_laag_1.useHover)();
|
|
33
|
-
const [, setFocus] = (0,
|
|
33
|
+
const [, setFocus] = (0, react_1.useState)(false);
|
|
34
34
|
if (!ref) {
|
|
35
|
-
ref = (0,
|
|
35
|
+
ref = (0, react_2.useRef)(null);
|
|
36
36
|
}
|
|
37
|
-
return (
|
|
37
|
+
return (react_4.default.createElement(Container, { type: type, onClick: () => {
|
|
38
38
|
;
|
|
39
39
|
ref.current.focus();
|
|
40
40
|
}, onBlur: () => {
|
|
@@ -46,12 +46,12 @@ const InputWithoutRef = ({ value, type, required, disabled, errorText = '', onCh
|
|
|
46
46
|
ref.current.focus();
|
|
47
47
|
setFocus(true);
|
|
48
48
|
}, ...hoverProps },
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
react_4.default.createElement(exports.InputElement, { ...props, error: errorText !== '' },
|
|
50
|
+
react_4.default.createElement(input_1.RawInput, { ref: ref, type: type, required: required, disabled: disabled, value: value, onChange: changeValue, placeholder: required ? `${placeholder}*` : placeholder, ...props })),
|
|
51
|
+
react_4.default.createElement(condition_1.Condition, { match: !!errorText },
|
|
52
|
+
react_4.default.createElement(layout_1.Layout, { flexBasis: 8, flexShrink: 0 }),
|
|
53
|
+
react_4.default.createElement(text_1.Text, { color: index_1.theme.colors.input.error.default.font }, errorText))));
|
|
54
54
|
};
|
|
55
55
|
exports.InputWithoutRef = InputWithoutRef;
|
|
56
|
-
exports.Input = (0,
|
|
57
|
-
exports.MemoizedInput =
|
|
56
|
+
exports.Input = (0, react_3.forwardRef)(exports.InputWithoutRef);
|
|
57
|
+
exports.MemoizedInput = react_4.default.memo(exports.Input);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import type { SettingsProps } from '../interfaces';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import { SettingsProps } from '../interfaces';
|
|
3
3
|
export declare const Settings: React.MemoExoticComponent<({ storeId, language, isNewWindow, isGenerateReceipt, }: SettingsProps) => React.JSX.Element>;
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Settings = void 0;
|
|
7
7
|
const condition_1 = require("@atls-ui-parts/condition");
|
|
8
8
|
const hidden_input_1 = require("@atls-ui-parts/hidden-input");
|
|
9
|
-
const react_1 =
|
|
10
|
-
const react_2 = require("react");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const react_2 = __importDefault(require("react"));
|
|
11
11
|
const enums_1 = require("../enums");
|
|
12
|
-
exports.Settings = (0,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
exports.Settings = (0, react_1.memo)(({ storeId, language = enums_1.LanguagesType.RUSSIAN, isNewWindow = false, isGenerateReceipt = false, }) => (react_2.default.createElement(react_2.default.Fragment, null,
|
|
13
|
+
react_2.default.createElement(hidden_input_1.HiddenInput, { disabled: true, readOnly: true, name: 'terminalkey', defaultValue: storeId }),
|
|
14
|
+
react_2.default.createElement(hidden_input_1.HiddenInput, { disabled: true, readOnly: true, name: 'frame', defaultValue: String(isNewWindow) }),
|
|
15
|
+
react_2.default.createElement(hidden_input_1.HiddenInput, { disabled: true, readOnly: true, name: 'language', defaultValue: language }),
|
|
16
|
+
react_2.default.createElement(condition_1.Condition, { match: isGenerateReceipt },
|
|
17
|
+
react_2.default.createElement(hidden_input_1.HiddenInput, { disabled: true, readOnly: true, name: 'receipt', defaultValue: '' })))));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ThemeProps } from '../../../interfaces';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ThemeProps } from '../../../interfaces';
|
|
3
3
|
export declare const ThemeProvider: FC<ThemeProps>;
|
|
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ThemeProvider = void 0;
|
|
30
|
-
const theme = __importStar(require("./theme"));
|
|
31
30
|
const react_1 = require("@emotion/react");
|
|
32
31
|
const react_2 = __importDefault(require("react"));
|
|
32
|
+
const theme = __importStar(require("./theme"));
|
|
33
33
|
const ThemeProvider = ({ children }) => (react_2.default.createElement(react_1.ThemeProvider, { theme: theme }, children));
|
|
34
34
|
exports.ThemeProvider = ThemeProvider;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { WidgetProps } from '../interfaces';
|
|
3
|
-
export declare const Widget: ({ amount, settings, receipt, additionalFields, styles, disabled, children, }: WidgetProps) =>
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { WidgetProps } from '../interfaces';
|
|
3
|
+
export declare const Widget: ({ amount, settings, receipt, additionalFields, styles, disabled, children, }: WidgetProps) => ReactNode;
|
|
@@ -27,12 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Widget = void 0;
|
|
30
|
-
const
|
|
31
|
-
const messagesEn = __importStar(require("../locales/en.json"));
|
|
32
|
-
const react_1 = __importDefault(require("react"));
|
|
33
|
-
const react_2 = require("react");
|
|
30
|
+
const react_1 = require("react");
|
|
34
31
|
const react_intl_1 = require("react-intl");
|
|
35
|
-
const
|
|
32
|
+
const react_2 = require("react");
|
|
33
|
+
const react_3 = __importDefault(require("react"));
|
|
34
|
+
const messagesEn = __importStar(require("../locales/en.json"));
|
|
35
|
+
const messagesRu = __importStar(require("../locales/ru.json"));
|
|
36
36
|
const enums_1 = require("../enums");
|
|
37
37
|
const form_1 = require("./form");
|
|
38
38
|
const form_provider_1 = require("./form/form.provider");
|
|
@@ -44,9 +44,9 @@ const messages = {
|
|
|
44
44
|
[enums_1.LanguagesType.ENGLISH]: messagesEn,
|
|
45
45
|
};
|
|
46
46
|
const Widget = ({ amount, settings, receipt, additionalFields, styles, disabled, children, }) => {
|
|
47
|
-
const childrenArray =
|
|
47
|
+
const childrenArray = react_1.Children.toArray(children);
|
|
48
48
|
const locale = settings.language ?? enums_1.LanguagesType.RUSSIAN;
|
|
49
|
-
const customFieldsProps = (0,
|
|
49
|
+
const customFieldsProps = (0, react_2.useMemo)(() => ({
|
|
50
50
|
existAmount: !!amount,
|
|
51
51
|
existReceipt: !!receipt,
|
|
52
52
|
existAdditionalFields: !!additionalFields?.length,
|
|
@@ -55,9 +55,9 @@ const Widget = ({ amount, settings, receipt, additionalFields, styles, disabled,
|
|
|
55
55
|
const { customFields, isGenerateReceiptField, isGenerateRequiredField } = (0, hooks_2.useCustomFields)(customFieldsProps);
|
|
56
56
|
const customButton = (0, hooks_1.useCustomButton)(childrenArray);
|
|
57
57
|
const nameFields = (0, utils_1.getNameFields)(customFields);
|
|
58
|
-
return (
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
return (react_3.default.createElement(react_intl_1.IntlProvider, { locale: locale, messages: messages[locale], defaultLocale: enums_1.LanguagesType.RUSSIAN },
|
|
59
|
+
react_3.default.createElement(form_provider_1.FormProvider, { additionalFields: additionalFields, nameFields: nameFields, isGenerateReceipt: isGenerateReceiptField, isGenerateRequiredField: isGenerateRequiredField, disabled: !!disabled },
|
|
60
|
+
react_3.default.createElement(form_1.Form, { amount: amount, settings: settings, receipt: receipt, styles: styles, useCustomButton: !!customButton, useCustomFields: !!customFields.length },
|
|
61
61
|
customFields,
|
|
62
62
|
customButton))));
|
|
63
63
|
};
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.InputWrapper = void 0;
|
|
7
7
|
const condition_1 = require("@atls-ui-parts/condition");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
8
|
const react_intl_1 = require("react-intl");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const enums_1 = require("../../enums");
|
|
11
11
|
const translate_util_1 = require("../../utils/translate.util");
|
|
12
12
|
const form_1 = require("../form");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AdditionalField } from '../interfaces';
|
|
2
|
-
export declare const addReceiptFieldsUtil: (additionalFields: AdditionalField
|
|
1
|
+
import type { AdditionalField } from '../interfaces';
|
|
2
|
+
export declare const addReceiptFieldsUtil: (additionalFields: Array<AdditionalField>) => Array<AdditionalField>;
|
|
@@ -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';
|
|
2
|
+
export declare const convertToPenny: (products: Array<ReceiptItem>) => Array<ReceiptItem>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Field } from '../interfaces';
|
|
3
|
-
export declare const getNameFields: (customFields: ReactNode
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Field } from '../interfaces';
|
|
3
|
+
export declare const getNameFields: (customFields: Array<ReactNode>) => Array<Field>;
|
|
@@ -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';
|
|
3
3
|
export declare const isCustomElement: (nameNode: NameWrapperComponent, node: ReactNode) => boolean;
|
package/dist/utils/pay.util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ReceiptSettings } from '../interfaces';
|
|
1
|
+
import type { FormEventHandler } from 'react';
|
|
2
|
+
import type { FormEvent } from 'react';
|
|
3
|
+
import type { ReceiptSettings } from '../interfaces';
|
|
4
4
|
export declare const makePayment: FormEventHandler<HTMLFormElement>;
|
|
5
5
|
export declare const makePaymentWithCheck: (event: FormEvent<HTMLFormElement>, receiptSettings: ReceiptSettings) => void;
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls/tinkoff-payment-widget",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@emotion/react": "11.9.3",
|
|
28
28
|
"@emotion/styled": "11.9.3",
|
|
29
29
|
"@testing-library/react": "14.1.0",
|
|
30
|
-
"@types/react": "18.
|
|
30
|
+
"@types/react": "18.3.6",
|
|
31
31
|
"@types/react-dom": "18",
|
|
32
32
|
"@types/styled-system": "5.1.16",
|
|
33
33
|
"csstype": "3.1.2",
|