@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.
Files changed (96) hide show
  1. package/dist/data/fields.data.d.ts +2 -2
  2. package/dist/data/fields.data.js +6 -9
  3. package/dist/data/index.d.ts +1 -1
  4. package/dist/data/index.js +1 -17
  5. package/dist/enums/button.enum.js +2 -5
  6. package/dist/enums/fields.enum.js +4 -7
  7. package/dist/enums/index.d.ts +8 -8
  8. package/dist/enums/index.js +8 -24
  9. package/dist/enums/language.enum.js +2 -5
  10. package/dist/enums/payment-method.enum.js +2 -5
  11. package/dist/enums/payment-object.enum.js +2 -5
  12. package/dist/enums/tax.enum.js +2 -5
  13. package/dist/enums/taxation.enum.js +2 -5
  14. package/dist/enums/wrapper.enum.js +2 -5
  15. package/dist/hooks/index.d.ts +6 -6
  16. package/dist/hooks/index.js +6 -28
  17. package/dist/hooks/use-custom-button.hook.js +3 -7
  18. package/dist/hooks/use-custom-fields.hook.d.ts +2 -2
  19. package/dist/hooks/use-custom-fields.hook.js +13 -17
  20. package/dist/hooks/use-fields-render.hook.d.ts +6 -6
  21. package/dist/hooks/use-fields-render.hook.js +16 -23
  22. package/dist/hooks/use-fields-state.hook.d.ts +3 -3
  23. package/dist/hooks/use-fields-state.hook.js +6 -10
  24. package/dist/hooks/use-init.hook.js +5 -9
  25. package/dist/hooks/use-validate.hook.d.ts +2 -2
  26. package/dist/hooks/use-validate.hook.js +13 -17
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.js +2 -22
  29. package/dist/interfaces/custom-fields.iterfaces.d.ts +1 -1
  30. package/dist/interfaces/custom-fields.iterfaces.js +1 -2
  31. package/dist/interfaces/fields.interfaces.d.ts +3 -3
  32. package/dist/interfaces/fields.interfaces.js +1 -2
  33. package/dist/interfaces/form.interfaces.d.ts +5 -5
  34. package/dist/interfaces/form.interfaces.js +1 -2
  35. package/dist/interfaces/index.d.ts +9 -9
  36. package/dist/interfaces/index.js +9 -25
  37. package/dist/interfaces/receipt.interfaces.d.ts +4 -4
  38. package/dist/interfaces/receipt.interfaces.js +1 -2
  39. package/dist/interfaces/settings.interfaces.d.ts +1 -1
  40. package/dist/interfaces/settings.interfaces.js +1 -2
  41. package/dist/interfaces/styles.interfaces.js +2 -5
  42. package/dist/interfaces/theme.interfaces.js +1 -2
  43. package/dist/interfaces/widget.interfaces.d.ts +4 -4
  44. package/dist/interfaces/widget.interfaces.js +1 -2
  45. package/dist/interfaces/wrappers.interfaces.d.ts +5 -5
  46. package/dist/interfaces/wrappers.interfaces.js +1 -2
  47. package/dist/ui/button/button.component.js +11 -18
  48. package/dist/ui/button/button.styles.js +24 -30
  49. package/dist/ui/fields.component.d.ts +1 -1
  50. package/dist/ui/fields.component.js +21 -28
  51. package/dist/ui/form/form.component.d.ts +1 -2
  52. package/dist/ui/form/form.component.js +17 -24
  53. package/dist/ui/form/form.context.d.ts +1 -2
  54. package/dist/ui/form/form.context.js +3 -6
  55. package/dist/ui/form/form.provider.d.ts +1 -1
  56. package/dist/ui/form/form.provider.js +17 -24
  57. package/dist/ui/form/index.d.ts +3 -2
  58. package/dist/ui/form/index.js +3 -18
  59. package/dist/ui/form/use-form.hook.d.ts +1 -1
  60. package/dist/ui/form/use-form.hook.js +4 -8
  61. package/dist/ui/index.d.ts +4 -4
  62. package/dist/ui/index.js +4 -23
  63. package/dist/ui/input/input.component.d.ts +2 -1
  64. package/dist/ui/input/input.component.js +32 -39
  65. package/dist/ui/input/input.styles.js +11 -15
  66. package/dist/ui/settings.component.d.ts +1 -1
  67. package/dist/ui/settings.component.js +11 -17
  68. package/dist/ui/theme/src/index.d.ts +2 -2
  69. package/dist/ui/theme/src/index.js +3 -32
  70. package/dist/ui/theme/src/theme/colors.js +1 -4
  71. package/dist/ui/theme/src/theme/index.d.ts +1 -1
  72. package/dist/ui/theme/src/theme/index.js +1 -17
  73. package/dist/ui/theme/src/theme.provider.d.ts +1 -1
  74. package/dist/ui/theme/src/theme.provider.js +4 -34
  75. package/dist/ui/widget.component.d.ts +1 -1
  76. package/dist/ui/widget.component.js +24 -54
  77. package/dist/ui/wrapper/button-wrapper.component.d.ts +1 -1
  78. package/dist/ui/wrapper/button-wrapper.component.js +10 -16
  79. package/dist/ui/wrapper/index.d.ts +2 -2
  80. package/dist/ui/wrapper/index.js +2 -18
  81. package/dist/ui/wrapper/input-wrapper.component.d.ts +1 -1
  82. package/dist/ui/wrapper/input-wrapper.component.js +12 -18
  83. package/dist/utils/add-receipt-fields.util.d.ts +1 -1
  84. package/dist/utils/add-receipt-fields.util.js +5 -9
  85. package/dist/utils/convert-to-penny.util.d.ts +1 -1
  86. package/dist/utils/convert-to-penny.util.js +1 -5
  87. package/dist/utils/get-name-fields.util.d.ts +1 -1
  88. package/dist/utils/get-name-fields.util.js +3 -7
  89. package/dist/utils/index.d.ts +5 -5
  90. package/dist/utils/index.js +5 -21
  91. package/dist/utils/is-custom-element.util.d.ts +1 -1
  92. package/dist/utils/is-custom-element.util.js +2 -6
  93. package/dist/utils/pay.util.d.ts +1 -1
  94. package/dist/utils/pay.util.js +4 -9
  95. package/dist/utils/translate.util.js +1 -5
  96. package/package.json +22 -2
@@ -1,40 +1,34 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MemoizedInput = exports.Input = exports.InputWithoutRef = exports.InputElement = void 0;
7
- const condition_1 = require("@atls-ui-parts/condition");
8
- const input_1 = require("@atls-ui-parts/input");
9
- const layout_1 = require("@atls-ui-parts/layout");
10
- const text_1 = require("@atls-ui-parts/text");
11
- const input_2 = require("@atls-ui-parts/input");
12
- const styled_1 = __importDefault(require("@emotion/styled"));
13
- const react_1 = require("react");
14
- const react_2 = require("react");
15
- const react_3 = require("react");
16
- const react_laag_1 = require("react-laag");
17
- const styled_system_1 = require("styled-system");
18
- const react_4 = __importDefault(require("react"));
19
- const index_1 = require("../theme/src/index");
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 = (0, input_2.useChangeValue)(disabled, onChange, onChangeNative);
32
- const [, hoverProps] = (0, react_laag_1.useHover)();
33
- const [, setFocus] = (0, react_1.useState)(false);
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 = (0, react_2.useRef)(null);
29
+ ref = useRef(null);
36
30
  }
37
- return (react_4.default.createElement(Container, { type: type, onClick: () => {
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
- 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))));
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
- exports.InputWithoutRef = InputWithoutRef;
56
- exports.Input = (0, react_3.forwardRef)(exports.InputWithoutRef);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appearanceStyles = exports.shapeStyles = exports.transitionStyles = exports.baseStyles = void 0;
4
- const input_1 = require("@atls-ui-parts/input");
5
- const input_2 = require("@atls-ui-parts/input");
6
- const input_3 = require("@atls-ui-parts/input");
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
- ...(0, input_3.createAppearanceStyles)({
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
- ...(0, input_3.createAppearanceStyles)({
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
- ...(0, input_3.createAppearanceStyles)({
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
- ...(0, input_3.createAppearanceStyles)({
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
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Settings = void 0;
7
- const condition_1 = require("@atls-ui-parts/condition");
8
- const hidden_input_1 = require("@atls-ui-parts/hidden-input");
9
- const react_1 = require("react");
10
- const react_2 = __importDefault(require("react"));
11
- const enums_1 = require("../enums");
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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __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,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colors = void 0;
4
1
  const colors = {
5
2
  button: {
6
3
  default: {
@@ -54,4 +51,4 @@ const colors = {
54
51
  },
55
52
  },
56
53
  };
57
- exports.colors = colors;
54
+ export { colors };
@@ -1 +1 @@
1
- export * from './colors';
1
+ export * from './colors.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./colors"), exports);
1
+ export * from "./colors.js";
@@ -1,3 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { ThemeProps } from '../../../interfaces';
2
+ import type { ThemeProps } from '../../../interfaces/index.js';
3
3
  export declare const ThemeProvider: FC<ThemeProps>;
@@ -1,34 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __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
- [enums_1.LanguagesType.RUSSIAN]: messagesRu,
44
- [enums_1.LanguagesType.ENGLISH]: messagesEn,
14
+ [LanguagesType.RUSSIAN]: messagesRu,
15
+ [LanguagesType.ENGLISH]: messagesEn,
45
16
  };
46
- const Widget = ({ amount, settings, receipt, additionalFields, styles, disabled, children, }) => {
47
- const childrenArray = react_1.Children.toArray(children);
48
- const locale = settings.language ?? enums_1.LanguagesType.RUSSIAN;
49
- const customFieldsProps = (0, react_2.useMemo)(() => ({
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 } = (0, hooks_2.useCustomFields)(customFieldsProps);
56
- const customButton = (0, hooks_1.useCustomButton)(childrenArray);
57
- const nameFields = (0, utils_1.getNameFields)(customFields);
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 },
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,4 +1,4 @@
1
1
  import type { FC } from 'react';
2
- import type { ButtonWrapperProps } from '../../interfaces';
2
+ import type { ButtonWrapperProps } from '../../interfaces/index.js';
3
3
  declare const ButtonWrapper: FC<ButtonWrapperProps>;
4
4
  export { ButtonWrapper };
@@ -1,20 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.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 } = (0, form_1.useForm)();
14
- return (react_1.default.createElement(condition_1.Condition, { match: typeof children === 'function' }, children({
15
- type: enums_1.ButtonType.Submit,
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
- exports.ButtonWrapper = ButtonWrapper;
20
- ButtonWrapper.displayName = enums_2.NameWrapperComponent.ButtonWrapper;
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';
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./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,4 +1,4 @@
1
1
  import type { FC } from 'react';
2
- import type { InputWrapperProps } from '../../interfaces';
2
+ import type { InputWrapperProps } from '../../interfaces/index.js';
3
3
  declare const InputWrapper: FC<InputWrapperProps>;
4
4
  export { InputWrapper };
@@ -1,20 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InputWrapper = void 0;
7
- const condition_1 = require("@atls-ui-parts/condition");
8
- const react_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 } = (0, form_1.useForm)();
15
- const intl = (0, react_intl_1.useIntl)();
16
- const translateError = (0, translate_util_1.translate)(intl, errors[name], errors[name]);
17
- return (react_1.default.createElement(condition_1.Condition, { match: typeof children === 'function' }, children({
8
+ const { fieldsState, handleChange, handleBlur, errors } = useForm();
9
+ const intl = useIntl();
10
+ const translateError = translate(intl, errors[name], errors[name]);
11
+ return (React.createElement(Condition, { match: typeof children === 'function' }, children({
18
12
  name,
19
13
  value: fieldsState[name],
20
14
  onChangeNative: handleChange,
@@ -22,5 +16,5 @@ const InputWrapper = ({ name, children }) => {
22
16
  errorText: translateError,
23
17
  })));
24
18
  };
25
- exports.InputWrapper = InputWrapper;
26
- InputWrapper.displayName = enums_1.NameWrapperComponent.InputWrapper;
19
+ InputWrapper.displayName = NameWrapperComponent.InputWrapper;
20
+ export { InputWrapper };
@@ -1,2 +1,2 @@
1
- import 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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addReceiptFieldsUtil = void 0;
4
- const enums_1 = require("../enums");
5
- const data_1 = require("../data");
6
- const addReceiptFieldsUtil = (additionalFields) => {
7
- const missingReceiptFields = !additionalFields.some((field) => field.name === enums_1.AdditionalFieldsType.Email || field.name === enums_1.AdditionalFieldsType.Phone);
8
- return missingReceiptFields ? [...data_1.receiptFields, ...additionalFields] : additionalFields;
1
+ import { AdditionalFieldsType } from '../enums/index.js';
2
+ import { receiptFields } from '../data/index.js';
3
+ export const addReceiptFieldsUtil = (additionalFields) => {
4
+ const missingReceiptFields = !additionalFields.some((field) => field.name === AdditionalFieldsType.Email || field.name === AdditionalFieldsType.Phone);
5
+ return missingReceiptFields ? [...receiptFields, ...additionalFields] : additionalFields;
9
6
  };
10
- exports.addReceiptFieldsUtil = addReceiptFieldsUtil;
@@ -1,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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToPenny = void 0;
4
- const convertToPenny = (products) => products.map((product) => ({
1
+ export const convertToPenny = (products) => products.map((product) => ({
5
2
  ...product,
6
3
  Amount: product.Amount * 100,
7
4
  Price: product.Price * 100,
8
5
  }));
9
- exports.convertToPenny = convertToPenny;
@@ -1,3 +1,3 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { Field } from '../interfaces';
2
+ import type { Field } from '../interfaces/index.js';
3
3
  export declare const getNameFields: (customFields: Array<ReactNode>) => Array<Field>;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNameFields = void 0;
4
- const react_1 = require("react");
5
- const getNameFields = (customFields) => customFields.reduce((acc, field) => {
6
- if ((0, react_1.isValidElement)(field))
1
+ import { isValidElement } from 'react';
2
+ export const getNameFields = (customFields) => customFields.reduce((acc, field) => {
3
+ if (isValidElement(field))
7
4
  acc.push({
8
5
  name: field.props.name,
9
6
  });
10
7
  return acc;
11
8
  }, []);
12
- exports.getNameFields = getNameFields;
@@ -1,5 +1,5 @@
1
- export * from './pay.util';
2
- export * from './add-receipt-fields.util';
3
- export * from './convert-to-penny.util';
4
- export * from './is-custom-element.util';
5
- export * from './get-name-fields.util';
1
+ export * from './pay.util.js';
2
+ export * from './add-receipt-fields.util.js';
3
+ export * from './convert-to-penny.util.js';
4
+ export * from './is-custom-element.util.js';
5
+ export * from './get-name-fields.util.js';