@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.
- package/dist/data/fields.data.d.ts +4 -4
- package/dist/data/fields.data.js +6 -9
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +1 -17
- package/dist/enums/button.enum.js +2 -5
- package/dist/enums/fields.enum.js +4 -7
- package/dist/enums/index.d.ts +8 -8
- package/dist/enums/index.js +8 -24
- package/dist/enums/language.enum.js +2 -5
- package/dist/enums/payment-method.enum.js +2 -5
- package/dist/enums/payment-object.enum.js +2 -5
- package/dist/enums/tax.enum.js +2 -5
- package/dist/enums/taxation.enum.js +2 -5
- package/dist/enums/wrapper.enum.js +2 -5
- package/dist/hooks/index.d.ts +6 -6
- package/dist/hooks/index.js +6 -28
- package/dist/hooks/use-custom-button.hook.d.ts +2 -2
- package/dist/hooks/use-custom-button.hook.js +3 -7
- package/dist/hooks/use-custom-fields.hook.d.ts +2 -2
- package/dist/hooks/use-custom-fields.hook.js +13 -17
- package/dist/hooks/use-fields-render.hook.d.ts +8 -8
- package/dist/hooks/use-fields-render.hook.js +16 -23
- package/dist/hooks/use-fields-state.hook.d.ts +4 -4
- package/dist/hooks/use-fields-state.hook.js +6 -10
- package/dist/hooks/use-init.hook.js +8 -10
- package/dist/hooks/use-validate.hook.d.ts +6 -4
- package/dist/hooks/use-validate.hook.js +13 -17
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -24
- package/dist/interfaces/custom-fields.iterfaces.d.ts +5 -5
- package/dist/interfaces/custom-fields.iterfaces.js +1 -2
- package/dist/interfaces/fields.interfaces.d.ts +11 -11
- package/dist/interfaces/fields.interfaces.js +1 -2
- package/dist/interfaces/form.interfaces.d.ts +9 -9
- package/dist/interfaces/form.interfaces.js +1 -2
- package/dist/interfaces/index.d.ts +9 -9
- package/dist/interfaces/index.js +9 -25
- package/dist/interfaces/receipt.interfaces.d.ts +6 -6
- package/dist/interfaces/receipt.interfaces.js +1 -2
- package/dist/interfaces/settings.interfaces.d.ts +1 -1
- package/dist/interfaces/settings.interfaces.js +1 -2
- package/dist/interfaces/styles.interfaces.d.ts +1 -1
- package/dist/interfaces/styles.interfaces.js +2 -5
- package/dist/interfaces/theme.interfaces.d.ts +1 -1
- package/dist/interfaces/theme.interfaces.js +1 -2
- package/dist/interfaces/widget.interfaces.d.ts +6 -6
- package/dist/interfaces/widget.interfaces.js +1 -2
- package/dist/interfaces/wrappers.interfaces.d.ts +6 -6
- package/dist/interfaces/wrappers.interfaces.js +1 -2
- package/dist/ui/button/button.component.d.ts +2 -2
- package/dist/ui/button/button.component.js +11 -18
- package/dist/ui/button/button.styles.d.ts +1 -1
- package/dist/ui/button/button.styles.js +24 -30
- package/dist/ui/fields.component.d.ts +3 -3
- package/dist/ui/fields.component.js +21 -28
- package/dist/ui/form/form.component.d.ts +2 -3
- package/dist/ui/form/form.component.js +17 -24
- package/dist/ui/form/form.context.d.ts +1 -2
- package/dist/ui/form/form.context.js +3 -6
- package/dist/ui/form/form.provider.d.ts +2 -2
- package/dist/ui/form/form.provider.js +17 -24
- package/dist/ui/form/index.d.ts +3 -2
- package/dist/ui/form/index.js +3 -18
- package/dist/ui/form/use-form.hook.d.ts +1 -1
- package/dist/ui/form/use-form.hook.js +4 -8
- package/dist/ui/index.d.ts +4 -4
- package/dist/ui/index.js +4 -23
- package/dist/ui/input/input.component.d.ts +4 -3
- package/dist/ui/input/input.component.js +32 -39
- package/dist/ui/input/input.styles.d.ts +1 -1
- package/dist/ui/input/input.styles.js +11 -15
- package/dist/ui/settings.component.d.ts +1 -1
- package/dist/ui/settings.component.js +11 -17
- package/dist/ui/theme/src/index.d.ts +2 -2
- package/dist/ui/theme/src/index.js +3 -32
- package/dist/ui/theme/src/theme/colors.js +1 -4
- package/dist/ui/theme/src/theme/index.d.ts +1 -1
- package/dist/ui/theme/src/theme/index.js +1 -17
- package/dist/ui/theme/src/theme.provider.d.ts +2 -2
- package/dist/ui/theme/src/theme.provider.js +4 -34
- package/dist/ui/widget.component.d.ts +3 -3
- package/dist/ui/widget.component.js +24 -54
- package/dist/ui/wrapper/button-wrapper.component.d.ts +2 -2
- package/dist/ui/wrapper/button-wrapper.component.js +10 -16
- package/dist/ui/wrapper/index.d.ts +2 -2
- package/dist/ui/wrapper/index.js +2 -18
- package/dist/ui/wrapper/input-wrapper.component.d.ts +2 -2
- package/dist/ui/wrapper/input-wrapper.component.js +12 -18
- package/dist/utils/add-receipt-fields.util.d.ts +2 -2
- package/dist/utils/add-receipt-fields.util.js +5 -9
- package/dist/utils/convert-to-penny.util.d.ts +2 -12
- package/dist/utils/convert-to-penny.util.js +1 -5
- package/dist/utils/get-name-fields.util.d.ts +3 -3
- package/dist/utils/get-name-fields.util.js +3 -7
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.js +5 -21
- package/dist/utils/is-custom-element.util.d.ts +2 -2
- package/dist/utils/is-custom-element.util.js +2 -6
- package/dist/utils/pay.util.d.ts +3 -3
- package/dist/utils/pay.util.js +4 -9
- package/dist/utils/translate.util.d.ts +1 -1
- package/dist/utils/translate.util.js +1 -5
- package/package.json +23 -3
|
@@ -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/index.js';
|
|
4
|
+
import type { RequiredFieldsType } from '../enums/index.js';
|
|
5
|
+
import type { DirectionFields } from './styles.interfaces.js';
|
|
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,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -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.js';
|
|
3
|
+
import type { Field } from './fields.interfaces.js';
|
|
4
|
+
import type { FieldsState } from './fields.interfaces.js';
|
|
5
|
+
import type { FieldsValidator } from './fields.interfaces.js';
|
|
6
|
+
import type { WidgetProps } from './widget.interfaces.js';
|
|
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,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './widget.interfaces';
|
|
2
|
-
export * from './fields.interfaces';
|
|
3
|
-
export * from './settings.interfaces';
|
|
4
|
-
export * from './receipt.interfaces';
|
|
5
|
-
export * from './styles.interfaces';
|
|
6
|
-
export * from './theme.interfaces';
|
|
7
|
-
export * from './form.interfaces';
|
|
8
|
-
export * from './wrappers.interfaces';
|
|
9
|
-
export * from './custom-fields.iterfaces';
|
|
1
|
+
export * from './widget.interfaces.js';
|
|
2
|
+
export * from './fields.interfaces.js';
|
|
3
|
+
export * from './settings.interfaces.js';
|
|
4
|
+
export * from './receipt.interfaces.js';
|
|
5
|
+
export * from './styles.interfaces.js';
|
|
6
|
+
export * from './theme.interfaces.js';
|
|
7
|
+
export * from './form.interfaces.js';
|
|
8
|
+
export * from './wrappers.interfaces.js';
|
|
9
|
+
export * from './custom-fields.iterfaces.js';
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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("./widget.interfaces"), exports);
|
|
18
|
-
__exportStar(require("./fields.interfaces"), exports);
|
|
19
|
-
__exportStar(require("./settings.interfaces"), exports);
|
|
20
|
-
__exportStar(require("./receipt.interfaces"), exports);
|
|
21
|
-
__exportStar(require("./styles.interfaces"), exports);
|
|
22
|
-
__exportStar(require("./theme.interfaces"), exports);
|
|
23
|
-
__exportStar(require("./form.interfaces"), exports);
|
|
24
|
-
__exportStar(require("./wrappers.interfaces"), exports);
|
|
25
|
-
__exportStar(require("./custom-fields.iterfaces"), exports);
|
|
1
|
+
export * from "./widget.interfaces.js";
|
|
2
|
+
export * from "./fields.interfaces.js";
|
|
3
|
+
export * from "./settings.interfaces.js";
|
|
4
|
+
export * from "./receipt.interfaces.js";
|
|
5
|
+
export * from "./styles.interfaces.js";
|
|
6
|
+
export * from "./theme.interfaces.js";
|
|
7
|
+
export * from "./form.interfaces.js";
|
|
8
|
+
export * from "./wrappers.interfaces.js";
|
|
9
|
+
export * from "./custom-fields.iterfaces.js";
|
|
@@ -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/index.js';
|
|
2
|
+
import type { PaymentObjectType } from '../enums/index.js';
|
|
3
|
+
import type { TaxType } from '../enums/index.js';
|
|
4
|
+
import type { TaxationType } from '../enums/index.js';
|
|
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
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DirectionFields = void 0;
|
|
4
|
-
var DirectionFields;
|
|
1
|
+
export var DirectionFields;
|
|
5
2
|
(function (DirectionFields) {
|
|
6
3
|
DirectionFields["Row"] = "row";
|
|
7
4
|
DirectionFields["Column"] = "column";
|
|
8
|
-
})(DirectionFields
|
|
5
|
+
})(DirectionFields || (DirectionFields = {}));
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -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.js';
|
|
3
|
+
import type { ReceiptSettings } from './receipt.interfaces.js';
|
|
4
|
+
import type { Settings } from './settings.interfaces.js';
|
|
5
|
+
import type { Styles } from './styles.interfaces.js';
|
|
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,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -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/index.js';
|
|
3
|
+
import type { ButtonType } from '../enums/index.js';
|
|
4
|
+
import type { RequiredFieldsType } from '../enums/index.js';
|
|
5
|
+
import type { HandleBlurField } from './fields.interfaces.js';
|
|
6
|
+
import type { HandleChangeField } from './fields.interfaces.js';
|
|
7
7
|
interface ChildrenInputProps {
|
|
8
8
|
name: string;
|
|
9
9
|
value: string;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -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>;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { default as styled } from '@emotion/styled';
|
|
2
|
+
import { useHover } from 'react-laag';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { appearanceStyles } from './button.styles.js';
|
|
5
|
+
import { contentStyles } from './button.styles.js';
|
|
6
|
+
import { baseStyles } from './button.styles.js';
|
|
7
|
+
import { shapeStyles } from './button.styles.js';
|
|
8
|
+
const ButtonElement = styled.default('button')(baseStyles, contentStyles, appearanceStyles, shapeStyles);
|
|
9
|
+
export const Button = ({ children, ...props }) => {
|
|
10
|
+
const [hover, hoverProps] = useHover();
|
|
11
|
+
return (React.createElement(ButtonElement, { hover: hover, ...hoverProps, ...props }, children));
|
|
4
12
|
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Button = void 0;
|
|
7
|
-
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const react_laag_1 = require("react-laag");
|
|
10
|
-
const button_styles_1 = require("./button.styles");
|
|
11
|
-
const button_styles_2 = require("./button.styles");
|
|
12
|
-
const button_styles_3 = require("./button.styles");
|
|
13
|
-
const button_styles_4 = require("./button.styles");
|
|
14
|
-
const ButtonElement = (0, styled_1.default)('button')(button_styles_3.baseStyles, button_styles_2.contentStyles, button_styles_1.appearanceStyles, button_styles_4.shapeStyles);
|
|
15
|
-
const Button = ({ children, ...props }) => {
|
|
16
|
-
const [hover, hoverProps] = (0, react_laag_1.useHover)();
|
|
17
|
-
return (react_1.default.createElement(ButtonElement, { hover: hover, ...hoverProps, ...props }, children));
|
|
18
|
-
};
|
|
19
|
-
exports.Button = Button;
|
|
@@ -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,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fontColor: index_1.theme.colors.button.default.font,
|
|
13
|
-
backgroundColor: index_1.theme.colors.button.default.backgroundColor,
|
|
14
|
-
borderColor: index_1.theme.colors.button.default.border,
|
|
1
|
+
import { createAppearanceStyles } from '@atls-ui-parts/button';
|
|
2
|
+
import { createContentStyles } from '@atls-ui-parts/button';
|
|
3
|
+
import { createBaseStyles } from '@atls-ui-parts/button';
|
|
4
|
+
import { createShapeStyles } from '@atls-ui-parts/button';
|
|
5
|
+
import { ifProp } from 'styled-tools';
|
|
6
|
+
import { prop } from 'styled-tools';
|
|
7
|
+
import { theme } from '../theme/src/index.js';
|
|
8
|
+
const buttonDefaultStyles = createAppearanceStyles({
|
|
9
|
+
fontColor: theme.colors.button.default.font,
|
|
10
|
+
backgroundColor: theme.colors.button.default.backgroundColor,
|
|
11
|
+
borderColor: theme.colors.button.default.border,
|
|
15
12
|
});
|
|
16
|
-
const buttonHoverStyles =
|
|
17
|
-
fontColor:
|
|
18
|
-
backgroundColor:
|
|
19
|
-
borderColor:
|
|
13
|
+
const buttonHoverStyles = createAppearanceStyles({
|
|
14
|
+
fontColor: theme.colors.button.hover.font,
|
|
15
|
+
backgroundColor: theme.colors.button.hover.backgroundColor,
|
|
16
|
+
borderColor: theme.colors.button.hover.border,
|
|
20
17
|
});
|
|
21
|
-
const buttonDisabledStyles =
|
|
22
|
-
fontColor:
|
|
23
|
-
backgroundColor:
|
|
24
|
-
borderColor:
|
|
18
|
+
const buttonDisabledStyles = createAppearanceStyles({
|
|
19
|
+
fontColor: theme.colors.button.disabled.font,
|
|
20
|
+
backgroundColor: theme.colors.button.disabled.backgroundColor,
|
|
21
|
+
borderColor: theme.colors.button.disabled.border,
|
|
25
22
|
});
|
|
26
23
|
const createTransitionStyles = () => () => ({
|
|
27
24
|
transition: '.25s',
|
|
28
25
|
});
|
|
29
26
|
const getBaseStyles = () => {
|
|
30
|
-
const baseStyles =
|
|
27
|
+
const baseStyles = createBaseStyles();
|
|
31
28
|
const transitionStyles = createTransitionStyles();
|
|
32
29
|
return () => ({
|
|
33
30
|
...baseStyles(),
|
|
@@ -35,15 +32,12 @@ const getBaseStyles = () => {
|
|
|
35
32
|
});
|
|
36
33
|
};
|
|
37
34
|
const baseStyles = getBaseStyles();
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const appearanceStyles = (0, styled_tools_1.ifProp)((0, styled_tools_2.prop)('disabled', false), buttonDisabledStyles, (0, styled_tools_1.ifProp)((0, styled_tools_2.prop)('hover', false), buttonHoverStyles, buttonDefaultStyles));
|
|
42
|
-
exports.appearanceStyles = appearanceStyles;
|
|
43
|
-
const shapeStyles = (0, button_4.createShapeStyles)({
|
|
35
|
+
const contentStyles = createContentStyles();
|
|
36
|
+
const appearanceStyles = ifProp(prop('disabled', false), buttonDisabledStyles, ifProp(prop('hover', false), buttonHoverStyles, buttonDefaultStyles));
|
|
37
|
+
const shapeStyles = createShapeStyles({
|
|
44
38
|
size: 36,
|
|
45
39
|
rounding: 5,
|
|
46
40
|
paddingRight: 36,
|
|
47
41
|
paddingLeft: 36,
|
|
48
42
|
});
|
|
49
|
-
|
|
43
|
+
export { baseStyles, appearanceStyles, shapeStyles, contentStyles };
|
|
@@ -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/index.js';
|
|
3
|
+
export declare const Fields: ({ amount, direction, inputGaps, useCustomFields, }: FieldsProps) => ReactNode;
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const enums_1 = require("../enums");
|
|
15
|
-
const interfaces_1 = require("../interfaces");
|
|
16
|
-
const hooks_1 = require("../hooks");
|
|
17
|
-
const form_1 = require("./form");
|
|
18
|
-
const Fields = ({ amount, direction = interfaces_1.DirectionFields.Column, inputGaps = 16, useCustomFields, }) => {
|
|
19
|
-
const { fields, fieldsState, handleChange, handleBlur, errors } = (0, form_1.useForm)();
|
|
1
|
+
import { Condition } from '@atls-ui-parts/condition';
|
|
2
|
+
import { HiddenInput } from '@atls-ui-parts/hidden-input';
|
|
3
|
+
import { Box } from '@atls-ui-parts/layout';
|
|
4
|
+
import { Column } from '@atls-ui-parts/layout';
|
|
5
|
+
import { Layout } from '@atls-ui-parts/layout';
|
|
6
|
+
import { Row } from '@atls-ui-parts/layout';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { RequiredFieldsType } from '../enums/index.js';
|
|
9
|
+
import { DirectionFields } from '../interfaces/index.js';
|
|
10
|
+
import { useFieldsRenderer } from '../hooks/index.js';
|
|
11
|
+
import { useForm } from './form/index.js';
|
|
12
|
+
export const Fields = ({ amount, direction = DirectionFields.Column, inputGaps = 16, useCustomFields, }) => {
|
|
13
|
+
const { fields, fieldsState, handleChange, handleBlur, errors } = useForm();
|
|
20
14
|
const fieldsForRender = useCustomFields ? [] : fields;
|
|
21
|
-
const renderedFields =
|
|
22
|
-
const Direction = direction ===
|
|
23
|
-
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
const renderedFields = useFieldsRenderer(fieldsForRender, errors, fieldsState, handleChange, handleBlur, inputGaps);
|
|
16
|
+
const Direction = direction === DirectionFields.Column ? Column : Row;
|
|
17
|
+
return (React.createElement(Box, { flexDirection: 'column' },
|
|
18
|
+
React.createElement(Layout, { flexBasis: inputGaps, flexShrink: 0 }),
|
|
19
|
+
React.createElement(Direction, null,
|
|
20
|
+
React.createElement(Condition, { match: Boolean(amount) },
|
|
21
|
+
React.createElement(HiddenInput, { disabled: true, readOnly: true, name: RequiredFieldsType.Amount, defaultValue: amount })),
|
|
28
22
|
renderedFields),
|
|
29
|
-
|
|
23
|
+
React.createElement(Layout, { flexBasis: inputGaps, flexShrink: 0 })));
|
|
30
24
|
};
|
|
31
|
-
exports.Fields = Fields;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare const Form: ({ settings, amount, receipt, styles, useCustomButton, useCustomFields, children, }: FormProps) => React.JSX.Element;
|
|
1
|
+
import type { FormProps } from '../../interfaces/index.js';
|
|
2
|
+
export declare const Form: ({ settings, amount, receipt, styles, useCustomButton, useCustomFields, children, }: FormProps) => JSX.Element;
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const settings_component_1 = require("../settings.component");
|
|
12
|
-
const utils_1 = require("../../utils");
|
|
13
|
-
const utils_2 = require("../../utils");
|
|
14
|
-
const use_form_hook_1 = require("./use-form.hook");
|
|
15
|
-
const Form = ({ settings, amount, receipt, styles, useCustomButton, useCustomFields, children, }) => {
|
|
16
|
-
const { isValidate, disabled, isLoaded } = (0, use_form_hook_1.useForm)();
|
|
1
|
+
import { FormattedMessage } from 'react-intl';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Button } from '../button/button.component.js';
|
|
4
|
+
import { Fields } from '../fields.component.js';
|
|
5
|
+
import { Settings } from '../settings.component.js';
|
|
6
|
+
import { makePayment } from '../../utils/index.js';
|
|
7
|
+
import { makePaymentWithCheck } from '../../utils/index.js';
|
|
8
|
+
import { useForm } from './use-form.hook.js';
|
|
9
|
+
export const Form = ({ settings, amount, receipt, styles, useCustomButton, useCustomFields, children, }) => {
|
|
10
|
+
const { isValidate, disabled, isLoaded } = useForm();
|
|
17
11
|
const payHandler = (event) => {
|
|
18
12
|
event.preventDefault();
|
|
19
13
|
if (!isValidate)
|
|
20
14
|
return;
|
|
21
15
|
if (receipt) {
|
|
22
|
-
|
|
16
|
+
makePaymentWithCheck(event, receipt);
|
|
23
17
|
}
|
|
24
18
|
else {
|
|
25
|
-
|
|
19
|
+
makePayment(event);
|
|
26
20
|
}
|
|
27
21
|
};
|
|
28
|
-
return (
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
return (React.createElement("form", { name: 'payform-tinkoff', onSubmit: payHandler },
|
|
23
|
+
React.createElement(Settings, { ...settings, isGenerateReceipt: !!receipt }),
|
|
24
|
+
React.createElement(Fields, { amount: amount, direction: styles?.direction, inputGaps: styles?.inputGaps, useCustomFields: useCustomFields }),
|
|
31
25
|
children,
|
|
32
|
-
!useCustomButton && (
|
|
33
|
-
|
|
26
|
+
!useCustomButton && (React.createElement(Button, { type: 'submit', disabled: !isLoaded || disabled, ...styles?.button },
|
|
27
|
+
React.createElement(FormattedMessage, { id: 'payment_widget.pay', defaultMessage: '\u041E\u043F\u043B\u0430\u0442\u0438\u0442\u044C' })))));
|
|
34
28
|
};
|
|
35
|
-
exports.Form = Form;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { FormContext } from '../../interfaces';
|
|
1
|
+
import type { FormContext } from '../../interfaces/index.js';
|
|
3
2
|
export declare const Context: import("react").Context<FormContext | null>;
|
|
4
3
|
export declare const Provider: import("react").Provider<FormContext | null>, Consumer: import("react").Consumer<FormContext | null>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
exports.Context = (0, react_1.createContext)(null);
|
|
6
|
-
exports.Provider = exports.Context.Provider, exports.Consumer = exports.Context.Consumer;
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
export const Context = createContext(null);
|
|
3
|
+
export const { Provider, Consumer } = Context;
|
|
@@ -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/index.js';
|
|
3
3
|
export declare const FormProvider: FC<FormProviderProps>;
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const hooks_1 = require("../../hooks");
|
|
12
|
-
const hooks_2 = require("../../hooks");
|
|
13
|
-
const hooks_3 = require("../../hooks");
|
|
14
|
-
const utils_1 = require("../../utils");
|
|
15
|
-
const FormProvider = ({ additionalFields, nameFields, isGenerateReceipt, isGenerateRequiredField, disabled, children, }) => {
|
|
16
|
-
const { errors, validateField, isValidate } = (0, hooks_3.useValidate)();
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Provider } from './form.context.js';
|
|
4
|
+
import { requiredFields } from '../../data/index.js';
|
|
5
|
+
import { useFieldsState } from '../../hooks/index.js';
|
|
6
|
+
import { useInit } from '../../hooks/index.js';
|
|
7
|
+
import { useValidate } from '../../hooks/index.js';
|
|
8
|
+
import { addReceiptFieldsUtil } from '../../utils/index.js';
|
|
9
|
+
export const FormProvider = ({ additionalFields, nameFields, isGenerateReceipt, isGenerateRequiredField, disabled, children, }) => {
|
|
10
|
+
const { errors, validateField, isValidate } = useValidate();
|
|
17
11
|
const processedFields = additionalFields && isGenerateReceipt
|
|
18
|
-
?
|
|
12
|
+
? addReceiptFieldsUtil(additionalFields)
|
|
19
13
|
: nameFields;
|
|
20
|
-
const fields =
|
|
21
|
-
? [...
|
|
14
|
+
const fields = useMemo(() => additionalFields && isGenerateRequiredField
|
|
15
|
+
? [...requiredFields, ...processedFields]
|
|
22
16
|
: [...processedFields], [additionalFields, isGenerateRequiredField, processedFields]);
|
|
23
|
-
const { fieldsState, handleChange, handleBlur } =
|
|
24
|
-
const isLoaded =
|
|
25
|
-
const value =
|
|
17
|
+
const { fieldsState, handleChange, handleBlur } = useFieldsState(validateField, fields);
|
|
18
|
+
const isLoaded = useInit();
|
|
19
|
+
const value = useMemo(() => ({
|
|
26
20
|
fields,
|
|
27
21
|
fieldsState,
|
|
28
22
|
handleChange,
|
|
@@ -43,6 +37,5 @@ const FormProvider = ({ additionalFields, nameFields, isGenerateReceipt, isGener
|
|
|
43
37
|
disabled,
|
|
44
38
|
isLoaded,
|
|
45
39
|
]);
|
|
46
|
-
return
|
|
40
|
+
return React.createElement(Provider, { value: value }, children);
|
|
47
41
|
};
|
|
48
|
-
exports.FormProvider = FormProvider;
|
package/dist/ui/form/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './form.component';
|
|
2
|
-
export * from './use-form.hook';
|
|
1
|
+
export * from './form.component.js';
|
|
2
|
+
export * from './use-form.hook.js';
|
|
3
|
+
export * from './form.provider.js';
|