@atls/tinkoff-payment-widget 0.0.5 → 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 +2 -2
- 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.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 +6 -6
- package/dist/hooks/use-fields-render.hook.js +16 -23
- package/dist/hooks/use-fields-state.hook.d.ts +3 -3
- package/dist/hooks/use-fields-state.hook.js +6 -10
- package/dist/hooks/use-init.hook.js +5 -9
- package/dist/hooks/use-validate.hook.d.ts +2 -2
- package/dist/hooks/use-validate.hook.js +13 -17
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -22
- package/dist/interfaces/custom-fields.iterfaces.d.ts +1 -1
- package/dist/interfaces/custom-fields.iterfaces.js +1 -2
- package/dist/interfaces/fields.interfaces.d.ts +3 -3
- package/dist/interfaces/fields.interfaces.js +1 -2
- package/dist/interfaces/form.interfaces.d.ts +5 -5
- 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 +4 -4
- 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.js +2 -5
- package/dist/interfaces/theme.interfaces.js +1 -2
- package/dist/interfaces/widget.interfaces.d.ts +4 -4
- package/dist/interfaces/widget.interfaces.js +1 -2
- package/dist/interfaces/wrappers.interfaces.d.ts +5 -5
- package/dist/interfaces/wrappers.interfaces.js +1 -2
- package/dist/ui/button/button.component.js +11 -18
- package/dist/ui/button/button.styles.js +24 -30
- package/dist/ui/fields.component.d.ts +1 -1
- package/dist/ui/fields.component.js +21 -28
- package/dist/ui/form/form.component.d.ts +1 -2
- 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 +1 -1
- 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 +2 -1
- package/dist/ui/input/input.component.js +32 -39
- 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 +1 -1
- package/dist/ui/theme/src/theme.provider.js +4 -34
- package/dist/ui/widget.component.d.ts +1 -1
- package/dist/ui/widget.component.js +24 -54
- package/dist/ui/wrapper/button-wrapper.component.d.ts +1 -1
- 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 +1 -1
- package/dist/ui/wrapper/input-wrapper.component.js +12 -18
- package/dist/utils/add-receipt-fields.util.d.ts +1 -1
- package/dist/utils/add-receipt-fields.util.js +5 -9
- package/dist/utils/convert-to-penny.util.d.ts +1 -1
- package/dist/utils/convert-to-penny.util.js +1 -5
- package/dist/utils/get-name-fields.util.d.ts +1 -1
- 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 +1 -1
- package/dist/utils/is-custom-element.util.js +2 -6
- package/dist/utils/pay.util.d.ts +1 -1
- package/dist/utils/pay.util.js +4 -9
- package/dist/utils/translate.util.js +1 -5
- package/package.json +22 -2
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const input_styles_1 = require("./input.styles");
|
|
21
|
-
const input_styles_2 = require("./input.styles");
|
|
22
|
-
const input_styles_3 = require("./input.styles");
|
|
23
|
-
const input_styles_4 = require("./input.styles");
|
|
24
|
-
exports.InputElement = styled_1.default.div(input_styles_2.baseStyles, input_styles_3.shapeStyles, input_styles_1.appearanceStyles, input_styles_4.transitionStyles, styled_system_1.layout);
|
|
25
|
-
const Container = styled_1.default.div(({ type }) => ({
|
|
1
|
+
import { Condition } from '@atls-ui-parts/condition';
|
|
2
|
+
import { RawInput } from '@atls-ui-parts/input';
|
|
3
|
+
import { Layout } from '@atls-ui-parts/layout';
|
|
4
|
+
import { Text } from '@atls-ui-parts/text';
|
|
5
|
+
import { useChangeValue } from '@atls-ui-parts/input';
|
|
6
|
+
import styled from '@emotion/styled';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import { useRef } from 'react';
|
|
9
|
+
import { forwardRef } from 'react';
|
|
10
|
+
import { useHover } from 'react-laag';
|
|
11
|
+
import { layout } from 'styled-system';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { theme } from '../theme/src/index.js';
|
|
14
|
+
import { appearanceStyles } from './input.styles.js';
|
|
15
|
+
import { baseStyles } from './input.styles.js';
|
|
16
|
+
import { shapeStyles } from './input.styles.js';
|
|
17
|
+
import { transitionStyles } from './input.styles.js';
|
|
18
|
+
export const InputElement = styled.default.div(baseStyles, shapeStyles, appearanceStyles, transitionStyles, layout);
|
|
19
|
+
const Container = styled.default.div(({ type }) => ({
|
|
26
20
|
display: type === 'hidden' ? 'none' : 'flex',
|
|
27
21
|
width: '100%',
|
|
28
22
|
flexDirection: 'column',
|
|
29
23
|
}));
|
|
30
|
-
const InputWithoutRef = ({ value, type, required, disabled, errorText = '', onChange, onChangeNative, placeholder, ...props }, ref) => {
|
|
31
|
-
const changeValue =
|
|
32
|
-
const [, hoverProps] =
|
|
33
|
-
const [, setFocus] =
|
|
24
|
+
export const InputWithoutRef = ({ value, type, required, disabled, errorText = '', onChange, onChangeNative, placeholder, ...props }, ref) => {
|
|
25
|
+
const changeValue = useChangeValue(disabled, onChange, onChangeNative);
|
|
26
|
+
const [, hoverProps] = useHover();
|
|
27
|
+
const [, setFocus] = useState(false);
|
|
34
28
|
if (!ref) {
|
|
35
|
-
ref =
|
|
29
|
+
ref = useRef(null);
|
|
36
30
|
}
|
|
37
|
-
return (
|
|
31
|
+
return (React.createElement(Container, { type: type, onClick: () => {
|
|
38
32
|
;
|
|
39
33
|
ref.current.focus();
|
|
40
34
|
}, onBlur: () => {
|
|
@@ -46,12 +40,11 @@ const InputWithoutRef = ({ value, type, required, disabled, errorText = '', onCh
|
|
|
46
40
|
ref.current.focus();
|
|
47
41
|
setFocus(true);
|
|
48
42
|
}, ...hoverProps },
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
React.createElement(InputElement, { ...props, error: errorText !== '' },
|
|
44
|
+
React.createElement(RawInput, { ref: ref, type: type, required: required, disabled: disabled, value: value, onChange: changeValue, placeholder: required ? `${placeholder}*` : placeholder, ...props })),
|
|
45
|
+
React.createElement(Condition, { match: !!errorText },
|
|
46
|
+
React.createElement(Layout, { flexBasis: 8, flexShrink: 0 }),
|
|
47
|
+
React.createElement(Text, { color: theme.colors.input.error.default.font }, errorText))));
|
|
54
48
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.MemoizedInput = react_4.default.memo(exports.Input);
|
|
49
|
+
export const Input = forwardRef(InputWithoutRef);
|
|
50
|
+
export const MemoizedInput = React.memo(Input);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
exports.baseStyles = (0, input_1.createBaseStyles)();
|
|
8
|
-
exports.transitionStyles = { transition: '.25s' };
|
|
9
|
-
exports.shapeStyles = (0, input_2.createShapeStyles)({
|
|
1
|
+
import { createBaseStyles } from '@atls-ui-parts/input';
|
|
2
|
+
import { createShapeStyles } from '@atls-ui-parts/input';
|
|
3
|
+
import { createAppearanceStyles } from '@atls-ui-parts/input';
|
|
4
|
+
export const baseStyles = createBaseStyles();
|
|
5
|
+
export const transitionStyles = { transition: '.25s' };
|
|
6
|
+
export const shapeStyles = createShapeStyles({
|
|
10
7
|
fontWeight: 400,
|
|
11
8
|
size: 56,
|
|
12
9
|
fontSize: 16,
|
|
@@ -14,14 +11,14 @@ exports.shapeStyles = (0, input_2.createShapeStyles)({
|
|
|
14
11
|
paddingLeft: 16,
|
|
15
12
|
paddingRight: 16,
|
|
16
13
|
});
|
|
17
|
-
const appearanceStyles = ({ theme, error }) => ({
|
|
18
|
-
...
|
|
14
|
+
export const appearanceStyles = ({ theme, error }) => ({
|
|
15
|
+
...createAppearanceStyles({
|
|
19
16
|
fontColor: theme.colors.input.default.font,
|
|
20
17
|
backgroundColor: theme.colors.input.default.backgroundColor,
|
|
21
18
|
borderColor: theme.colors.input.default.border,
|
|
22
19
|
})(),
|
|
23
20
|
'&:hover': {
|
|
24
|
-
...
|
|
21
|
+
...createAppearanceStyles({
|
|
25
22
|
fontColor: theme.colors.input.hover.font,
|
|
26
23
|
backgroundColor: error
|
|
27
24
|
? theme.colors.input.error.hover.backgroundColor
|
|
@@ -30,7 +27,7 @@ const appearanceStyles = ({ theme, error }) => ({
|
|
|
30
27
|
})(),
|
|
31
28
|
},
|
|
32
29
|
'&:focus-within, &:active, &:focus': {
|
|
33
|
-
...
|
|
30
|
+
...createAppearanceStyles({
|
|
34
31
|
fontColor: theme.colors.input.focus.font,
|
|
35
32
|
backgroundColor: theme.colors.input.focus.backgroundColor,
|
|
36
33
|
borderColor: error
|
|
@@ -39,7 +36,7 @@ const appearanceStyles = ({ theme, error }) => ({
|
|
|
39
36
|
})(),
|
|
40
37
|
},
|
|
41
38
|
...(error && {
|
|
42
|
-
...
|
|
39
|
+
...createAppearanceStyles({
|
|
43
40
|
fontColor: theme.colors.input.error.default.font,
|
|
44
41
|
backgroundColor: theme.colors.input.error.default.backgroundColor,
|
|
45
42
|
borderColor: theme.colors.input.error.default.border,
|
|
@@ -50,4 +47,3 @@ const appearanceStyles = ({ theme, error }) => ({
|
|
|
50
47
|
WebkitTransitionDelay: '9999s',
|
|
51
48
|
},
|
|
52
49
|
});
|
|
53
|
-
exports.appearanceStyles = appearanceStyles;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SettingsProps } from '../interfaces';
|
|
1
|
+
import type { SettingsProps } from '../interfaces/index.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare const Settings: React.MemoExoticComponent<({ storeId, language, isNewWindow, isGenerateReceipt, }: SettingsProps) => React.JSX.Element>;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
import { Condition } from '@atls-ui-parts/condition';
|
|
2
|
+
import { HiddenInput } from '@atls-ui-parts/hidden-input';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { LanguagesType } from '../enums/index.js';
|
|
6
|
+
export const Settings = memo(({ storeId, language = LanguagesType.RUSSIAN, isNewWindow = false, isGenerateReceipt = false, }) => (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(HiddenInput, { disabled: true, readOnly: true, name: 'terminalkey', defaultValue: storeId }),
|
|
8
|
+
React.createElement(HiddenInput, { disabled: true, readOnly: true, name: 'frame', defaultValue: String(isNewWindow) }),
|
|
9
|
+
React.createElement(HiddenInput, { disabled: true, readOnly: true, name: 'language', defaultValue: language }),
|
|
10
|
+
React.createElement(Condition, { match: isGenerateReceipt },
|
|
11
|
+
React.createElement(HiddenInput, { disabled: true, readOnly: true, name: 'receipt', defaultValue: '' })))));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as theme from './theme';
|
|
2
|
-
export * from './theme.provider';
|
|
1
|
+
import * as theme from './theme/index.js';
|
|
2
|
+
export * from './theme.provider.js';
|
|
3
3
|
export { theme };
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.theme = void 0;
|
|
30
|
-
const theme = __importStar(require("./theme"));
|
|
31
|
-
exports.theme = theme;
|
|
32
|
-
__exportStar(require("./theme.provider"), exports);
|
|
1
|
+
import * as theme from './theme/index.js';
|
|
2
|
+
export * from "./theme.provider.js";
|
|
3
|
+
export { theme };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './colors';
|
|
1
|
+
export * from './colors.js';
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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("./colors"), exports);
|
|
1
|
+
export * from "./colors.js";
|
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ThemeProvider = void 0;
|
|
30
|
-
const react_1 = require("@emotion/react");
|
|
31
|
-
const react_2 = __importDefault(require("react"));
|
|
32
|
-
const theme = __importStar(require("./theme"));
|
|
33
|
-
const ThemeProvider = ({ children }) => (react_2.default.createElement(react_1.ThemeProvider, { theme: theme }, children));
|
|
34
|
-
exports.ThemeProvider = ThemeProvider;
|
|
1
|
+
import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as theme from './theme/index.js';
|
|
4
|
+
export const ThemeProvider = ({ children }) => (React.createElement(EmotionThemeProvider, { theme: theme }, children));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { WidgetProps } from '../interfaces';
|
|
2
|
+
import type { WidgetProps } from '../interfaces/index.js';
|
|
3
3
|
export declare const Widget: ({ amount, settings, receipt, additionalFields, styles, disabled, children, }: WidgetProps) => ReactNode;
|
|
@@ -1,64 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Widget = void 0;
|
|
30
|
-
const react_1 = require("react");
|
|
31
|
-
const react_intl_1 = require("react-intl");
|
|
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
|
-
const enums_1 = require("../enums");
|
|
37
|
-
const form_1 = require("./form");
|
|
38
|
-
const form_provider_1 = require("./form/form.provider");
|
|
39
|
-
const hooks_1 = require("../hooks");
|
|
40
|
-
const hooks_2 = require("../hooks");
|
|
41
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
import { IntlProvider } from 'react-intl';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import * as messagesEn from '../locales/en.json' with { type: 'json' };
|
|
6
|
+
import * as messagesRu from '../locales/ru.json' with { type: 'json' };
|
|
7
|
+
import { LanguagesType } from '../enums/index.js';
|
|
8
|
+
import { Form } from './form/index.js';
|
|
9
|
+
import { FormProvider } from './form/index.js';
|
|
10
|
+
import { useCustomButton } from '../hooks/index.js';
|
|
11
|
+
import { useCustomFields } from '../hooks/index.js';
|
|
12
|
+
import { getNameFields } from '../utils/index.js';
|
|
42
13
|
const messages = {
|
|
43
|
-
[
|
|
44
|
-
[
|
|
14
|
+
[LanguagesType.RUSSIAN]: messagesRu,
|
|
15
|
+
[LanguagesType.ENGLISH]: messagesEn,
|
|
45
16
|
};
|
|
46
|
-
const Widget = ({ amount, settings, receipt, additionalFields, styles, disabled, children, }) => {
|
|
47
|
-
const childrenArray =
|
|
48
|
-
const locale = settings.language ??
|
|
49
|
-
const customFieldsProps =
|
|
17
|
+
export const Widget = ({ amount, settings, receipt, additionalFields, styles, disabled, children, }) => {
|
|
18
|
+
const childrenArray = Children.toArray(children);
|
|
19
|
+
const locale = settings.language ?? LanguagesType.RUSSIAN;
|
|
20
|
+
const customFieldsProps = useMemo(() => ({
|
|
50
21
|
existAmount: !!amount,
|
|
51
22
|
existReceipt: !!receipt,
|
|
52
23
|
existAdditionalFields: !!additionalFields?.length,
|
|
53
24
|
nodeArray: childrenArray,
|
|
54
25
|
}), [amount, receipt, additionalFields, childrenArray]);
|
|
55
|
-
const { customFields, isGenerateReceiptField, isGenerateRequiredField } =
|
|
56
|
-
const customButton =
|
|
57
|
-
const nameFields =
|
|
58
|
-
return (
|
|
59
|
-
|
|
60
|
-
|
|
26
|
+
const { customFields, isGenerateReceiptField, isGenerateRequiredField } = useCustomFields(customFieldsProps);
|
|
27
|
+
const customButton = useCustomButton(childrenArray);
|
|
28
|
+
const nameFields = getNameFields(customFields);
|
|
29
|
+
return (React.createElement(IntlProvider, { locale: locale, messages: messages[locale], defaultLocale: LanguagesType.RUSSIAN },
|
|
30
|
+
React.createElement(FormProvider, { additionalFields: additionalFields, nameFields: nameFields, isGenerateReceipt: isGenerateReceiptField, isGenerateRequiredField: isGenerateRequiredField, disabled: !!disabled },
|
|
31
|
+
React.createElement(Form, { amount: amount, settings: settings, receipt: receipt, styles: styles, useCustomButton: !!customButton, useCustomFields: !!customFields.length },
|
|
61
32
|
customFields,
|
|
62
33
|
customButton))));
|
|
63
34
|
};
|
|
64
|
-
exports.Widget = Widget;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.ButtonWrapper = void 0;
|
|
7
|
-
const condition_1 = require("@atls-ui-parts/condition");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const enums_1 = require("../../enums");
|
|
10
|
-
const enums_2 = require("../../enums");
|
|
11
|
-
const form_1 = require("../form");
|
|
1
|
+
import { Condition } from '@atls-ui-parts/condition';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ButtonType } from '../../enums/index.js';
|
|
4
|
+
import { NameWrapperComponent } from '../../enums/index.js';
|
|
5
|
+
import { useForm } from '../form/index.js';
|
|
12
6
|
const ButtonWrapper = ({ children }) => {
|
|
13
|
-
const { disabled, isLoaded } =
|
|
14
|
-
return (
|
|
15
|
-
type:
|
|
7
|
+
const { disabled, isLoaded } = useForm();
|
|
8
|
+
return (React.createElement(Condition, { match: typeof children === 'function' }, children({
|
|
9
|
+
type: ButtonType.Submit,
|
|
16
10
|
disabled: disabled || !isLoaded,
|
|
17
11
|
})));
|
|
18
12
|
};
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
ButtonWrapper.displayName = NameWrapperComponent.ButtonWrapper;
|
|
14
|
+
export { ButtonWrapper };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './input-wrapper.component';
|
|
2
|
-
export * from './button-wrapper.component';
|
|
1
|
+
export * from './input-wrapper.component.js';
|
|
2
|
+
export * from './button-wrapper.component.js';
|
package/dist/ui/wrapper/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./input-wrapper.component"), exports);
|
|
18
|
-
__exportStar(require("./button-wrapper.component"), exports);
|
|
1
|
+
export * from "./input-wrapper.component.js";
|
|
2
|
+
export * from "./button-wrapper.component.js";
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const condition_1 = require("@atls-ui-parts/condition");
|
|
8
|
-
const react_intl_1 = require("react-intl");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
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 } =
|
|
15
|
-
const intl =
|
|
16
|
-
const translateError =
|
|
17
|
-
return (
|
|
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
|
-
|
|
26
|
-
|
|
19
|
+
InputWrapper.displayName = NameWrapperComponent.InputWrapper;
|
|
20
|
+
export { InputWrapper };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { AdditionalField } from '../interfaces';
|
|
1
|
+
import type { AdditionalField } from '../interfaces/index.js';
|
|
2
2
|
export declare const addReceiptFieldsUtil: (additionalFields: Array<AdditionalField>) => Array<AdditionalField>;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
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,2 +1,2 @@
|
|
|
1
|
-
import type { ReceiptItem } from '../interfaces';
|
|
1
|
+
import type { ReceiptItem } from '../interfaces/index.js';
|
|
2
2
|
export declare const convertToPenny: (products: Array<ReceiptItem>) => Array<ReceiptItem>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
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,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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';
|