@atls/tinkoff-payment-widget 0.1.6 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,11 +1,5 @@
1
-
2
-
3
1
  ## [0.1.6](https://github.com/atls/reactjs/compare/@atls/tinkoff-payment-widget@0.1.5...@atls/tinkoff-payment-widget@0.1.6) (2025-01-22)
4
2
 
5
-
6
3
  ### Bug Fixes
7
4
 
8
-
9
- * **react:** lint and typecheck errors ([a090051](https://github.com/atls/reactjs/commit/a090051d1007e171df8066e85f15fcf8fd44c4ed))
10
-
11
-
5
+ - **react:** lint and typecheck errors ([a090051](https://github.com/atls/reactjs/commit/a090051d1007e171df8066e85f15fcf8fd44c4ed))
package/README.md CHANGED
@@ -50,12 +50,12 @@ export const Form = () => (
50
50
 
51
51
  ## Экспортируемые компоненты
52
52
 
53
- [**Widget**]() - главный компонент Виджета.
53
+ [**Widget**](<>) - главный компонент Виджета.
54
54
 
55
- [**InputWrapper**]() - компонент обёртка для полей ввода.
55
+ [**InputWrapper**](<>) - компонент обёртка для полей ввода.
56
56
 
57
- [**ButtonWrapper**]() - компонент обёртка для кнопки.
57
+ [**ButtonWrapper**](<>) - компонент обёртка для кнопки.
58
58
 
59
- [**AdditionalFieldsType**]() - интерфейс дополнительных полей.
59
+ [**AdditionalFieldsType**](<>) - интерфейс дополнительных полей.
60
60
 
61
- [**RequiredFieldsType**]() - интерфейс обязательных полей.
61
+ [**RequiredFieldsType**](<>) - интерфейс обязательных полей.
@@ -1 +1 @@
1
- export * from "./fields.data.js";
1
+ export * from './fields.data.js';
@@ -1,8 +1,8 @@
1
- export * from "./fields.enum.js";
2
- export * from "./language.enum.js";
3
- export * from "./payment-method.enum.js";
4
- export * from "./payment-object.enum.js";
5
- export * from "./tax.enum.js";
6
- export * from "./taxation.enum.js";
7
- export * from "./button.enum.js";
8
- export * from "./wrapper.enum.js";
1
+ export * from './fields.enum.js';
2
+ export * from './language.enum.js';
3
+ export * from './payment-method.enum.js';
4
+ export * from './payment-object.enum.js';
5
+ export * from './tax.enum.js';
6
+ export * from './taxation.enum.js';
7
+ export * from './button.enum.js';
8
+ export * from './wrapper.enum.js';
@@ -1,6 +1,6 @@
1
- export * from "./use-init.hook.js";
2
- export { useValidate } from "./use-validate.hook.js";
3
- export { useFieldsState } from "./use-fields-state.hook.js";
4
- export { useFieldsRenderer } from "./use-fields-render.hook.js";
5
- export { useCustomFields } from "./use-custom-fields.hook.js";
6
- export { useCustomButton } from "./use-custom-button.hook.js";
1
+ export * from './use-init.hook.js';
2
+ export { useValidate } from './use-validate.hook.js';
3
+ export { useFieldsState } from './use-fields-state.hook.js';
4
+ export { useFieldsRenderer } from './use-fields-render.hook.js';
5
+ export { useCustomFields } from './use-custom-fields.hook.js';
6
+ export { useCustomButton } from './use-custom-button.hook.js';
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import { Condition } from '@atls-ui-parts/condition';
2
3
  import { Layout } from '@atls-ui-parts/layout';
3
4
  import { useIntl } from 'react-intl';
@@ -7,15 +8,12 @@ import { ThemeProvider } from '../ui/theme/src/index.js';
7
8
  import { translate } from '../utils/translate.util.js';
8
9
  export const useFieldsRenderer = (fields, errors, fieldsState, handleChange, handleBlur, inputGaps) => {
9
10
  const intl = useIntl();
10
- return (React.createElement(ThemeProvider, null, fields.map((field, index, currentFields) => {
11
- const translatePlaceholder = 'placeholder' in field && field.placeholder
12
- ? translate(intl, field.placeholder, field.placeholder)
13
- : '';
14
- const translateError = translate(intl, errors[field.name], errors[field.name]);
15
- const isNotLastField = index !== currentFields.length - 1;
16
- return (React.createElement(React.Fragment, { key: field.name },
17
- React.createElement(MemoizedInput, { type: 'type' in field ? field.type : 'text', name: field.name, placeholder: translatePlaceholder, required: 'required' in field ? field.required : false, value: fieldsState[field.name], errorText: translateError, onChangeNative: handleChange, onBlur: handleBlur }),
18
- React.createElement(Condition, { match: isNotLastField },
19
- React.createElement(Layout, { flexBasis: inputGaps, flexShrink: 0 }))));
20
- })));
11
+ return (_jsx(ThemeProvider, { children: fields.map((field, index, currentFields) => {
12
+ const translatePlaceholder = 'placeholder' in field && field.placeholder
13
+ ? translate(intl, field.placeholder, field.placeholder)
14
+ : '';
15
+ const translateError = translate(intl, errors[field.name], errors[field.name]);
16
+ const isNotLastField = index !== currentFields.length - 1;
17
+ return (_jsxs(React.Fragment, { children: [_jsx(MemoizedInput, { type: 'type' in field ? field.type : 'text', name: field.name, placeholder: translatePlaceholder, required: 'required' in field ? field.required : false, value: fieldsState[field.name], errorText: translateError, onChangeNative: handleChange, onBlur: handleBlur }), _jsx(Condition, { match: isNotLastField, children: _jsx(Layout, { flexBasis: inputGaps, flexShrink: 0 }) })] }, field.name));
18
+ }) }));
21
19
  };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { Widget, ButtonWrapper, InputWrapper, useForm } from "./ui/index.js";
2
- export * from "./enums/index.js";
1
+ export { Widget, ButtonWrapper, InputWrapper, useForm } from './ui/index.js';
2
+ export * from './enums/index.js';
@@ -1 +1 @@
1
- export * from "./styles.enum.js";
1
+ export * from './styles.enum.js';
@@ -1,2 +1,2 @@
1
- export * from "./en.locale.js";
2
- export * from "./ru.locale.js";
1
+ export * from './en.locale.js';
2
+ export * from './ru.locale.js';
@@ -1,6 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import styled from '@emotion/styled';
2
3
  import { useHover } from 'react-laag';
3
- import React from 'react';
4
4
  import { appearanceStyles } from './button.styles.js';
5
5
  import { contentStyles } from './button.styles.js';
6
6
  import { baseStyles } from './button.styles.js';
@@ -8,5 +8,5 @@ import { shapeStyles } from './button.styles.js';
8
8
  const ButtonElement = (styled.default ?? styled)('button')(baseStyles, contentStyles, appearanceStyles, shapeStyles);
9
9
  export const Button = ({ children, ...props }) => {
10
10
  const [hover, hoverProps] = useHover();
11
- return (React.createElement(ButtonElement, { hover: hover, ...hoverProps, ...props }, children));
11
+ return (_jsx(ButtonElement, { hover: hover, ...hoverProps, ...props, children: children }));
12
12
  };
@@ -1,10 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import { Condition } from '@atls-ui-parts/condition';
2
3
  import { HiddenInput } from '@atls-ui-parts/hidden-input';
3
4
  import { Box } from '@atls-ui-parts/layout';
4
5
  import { Column } from '@atls-ui-parts/layout';
5
6
  import { Layout } from '@atls-ui-parts/layout';
6
7
  import { Row } from '@atls-ui-parts/layout';
7
- import React from 'react';
8
8
  import { RequiredFieldsType } from '../enums/index.js';
9
9
  import { DirectionFields } from '../interfaces/index.js';
10
10
  import { useFieldsRenderer } from '../hooks/index.js';
@@ -14,11 +14,5 @@ export const Fields = ({ amount, direction = DirectionFields.Column, inputGaps =
14
14
  const fieldsForRender = useCustomFields ? [] : fields;
15
15
  const renderedFields = useFieldsRenderer(fieldsForRender, errors, fieldsState, handleChange, handleBlur, inputGaps);
16
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 })),
22
- renderedFields),
23
- React.createElement(Layout, { flexBasis: inputGaps, flexShrink: 0 })));
17
+ return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(Layout, { flexBasis: inputGaps, flexShrink: 0 }), _jsxs(Direction, { children: [_jsx(Condition, { match: Boolean(amount), children: _jsx(HiddenInput, { disabled: true, readOnly: true, name: RequiredFieldsType.Amount, defaultValue: amount }) }), renderedFields] }), _jsx(Layout, { flexBasis: inputGaps, flexShrink: 0 })] }));
24
18
  };
@@ -1,5 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import { FormattedMessage } from 'react-intl';
2
- import React from 'react';
3
3
  import { Button } from '../button/button.component.js';
4
4
  import { Fields } from '../fields.component.js';
5
5
  import { Settings } from '../settings.component.js';
@@ -19,10 +19,5 @@ export const Form = ({ settings, amount, receipt, styles, useCustomButton, useCu
19
19
  makePayment(event);
20
20
  }
21
21
  };
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 }),
25
- children,
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' })))));
22
+ return (_jsxs("form", { name: 'payform-tinkoff', onSubmit: payHandler, children: [_jsx(Settings, { ...settings, isGenerateReceipt: !!receipt }), _jsx(Fields, { amount: amount, direction: styles?.direction, inputGaps: styles?.inputGaps, useCustomFields: useCustomFields }), children, !useCustomButton && (_jsx(Button, { type: 'submit', disabled: !isLoaded || disabled, ...styles?.button, children: _jsx(FormattedMessage, { id: 'payment_widget.pay', defaultMessage: '\u041E\u043F\u043B\u0430\u0442\u0438\u0442\u044C' }) }))] }));
28
23
  };
@@ -1,5 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { useMemo } from 'react';
2
- import React from 'react';
3
3
  import { Provider } from './form.context.js';
4
4
  import { requiredFields } from '../../data/index.js';
5
5
  import { useFieldsState } from '../../hooks/index.js';
@@ -37,5 +37,5 @@ export const FormProvider = ({ additionalFields, nameFields, isGenerateReceipt,
37
37
  disabled,
38
38
  isLoaded,
39
39
  ]);
40
- return React.createElement(Provider, { value: value }, children);
40
+ return _jsx(Provider, { value: value, children: children });
41
41
  };
@@ -1,3 +1,3 @@
1
- export * from "./form.component.js";
2
- export * from "./use-form.hook.js";
3
- export * from "./form.provider.js";
1
+ export * from './form.component.js';
2
+ export * from './use-form.hook.js';
3
+ export * from './form.provider.js';
package/dist/ui/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from "./widget.component.js";
2
- export * from "./wrapper/index.js";
3
- export * from "./form/index.js";
4
- export { Input } from "./input/input.component.js";
5
- export { MemoizedInput } from "./input/input.component.js";
1
+ export * from './widget.component.js';
2
+ export * from './wrapper/index.js';
3
+ export * from './form/index.js';
4
+ export { Input } from './input/input.component.js';
5
+ export { MemoizedInput } from './input/input.component.js';
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import { Condition } from '@atls-ui-parts/condition';
2
3
  import { RawInput } from '@atls-ui-parts/input';
3
4
  import { Layout } from '@atls-ui-parts/layout';
@@ -28,7 +29,7 @@ export const InputWithoutRef = ({ value, type, required, disabled, errorText = '
28
29
  if (!ref) {
29
30
  ref = useRef(null);
30
31
  }
31
- return (React.createElement(Container, { type: type, onClick: () => {
32
+ return (_jsxs(Container, { type: type, onClick: () => {
32
33
  ;
33
34
  ref.current?.focus();
34
35
  }, onBlur: () => {
@@ -39,12 +40,7 @@ export const InputWithoutRef = ({ value, type, required, disabled, errorText = '
39
40
  ;
40
41
  ref.current?.focus();
41
42
  setFocus(true);
42
- }, ...hoverProps },
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))));
43
+ }, ...hoverProps, children: [_jsx(InputElement, { ...props, error: errorText !== '', children: _jsx(RawInput, { ref: ref, type: type, required: required, disabled: disabled, value: value, onChange: changeValue, placeholder: required ? `${placeholder}*` : placeholder, ...props }) }), _jsxs(Condition, { match: !!errorText, children: [_jsx(Layout, { flexBasis: 8, flexShrink: 0 }), _jsx(Text, { color: theme.colors.input.error.default.font, children: errorText })] })] }));
48
44
  };
49
45
  export const Input = forwardRef(InputWithoutRef);
50
46
  export const MemoizedInput = React.memo(Input);
@@ -1,3 +1,3 @@
1
1
  import type { SettingsProps } from '../interfaces/index.js';
2
2
  import React from 'react';
3
- export declare const Settings: React.MemoExoticComponent<({ storeId, language, isNewWindow, isGenerateReceipt, }: SettingsProps) => React.JSX.Element>;
3
+ export declare const Settings: React.MemoExoticComponent<({ storeId, language, isNewWindow, isGenerateReceipt, }: SettingsProps) => import("react/jsx-runtime").JSX.Element>;
@@ -1,11 +1,6 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import { Condition } from '@atls-ui-parts/condition';
2
3
  import { HiddenInput } from '@atls-ui-parts/hidden-input';
3
4
  import { memo } from 'react';
4
- import React from 'react';
5
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: '' })))));
6
+ export const Settings = memo(({ storeId, language = LanguagesType.RUSSIAN, isNewWindow = false, isGenerateReceipt = false, }) => (_jsxs(_Fragment, { children: [_jsx(HiddenInput, { disabled: true, readOnly: true, name: 'terminalkey', defaultValue: storeId }), _jsx(HiddenInput, { disabled: true, readOnly: true, name: 'frame', defaultValue: String(isNewWindow) }), _jsx(HiddenInput, { disabled: true, readOnly: true, name: 'language', defaultValue: language }), _jsx(Condition, { match: isGenerateReceipt, children: _jsx(HiddenInput, { disabled: true, readOnly: true, name: 'receipt', defaultValue: '' }) })] })));
@@ -1,3 +1,3 @@
1
1
  import * as theme from './theme/index.js';
2
- export * from "./theme.provider.js";
2
+ export * from './theme.provider.js';
3
3
  export { theme };
@@ -1 +1 @@
1
- export * from "./colors.js";
1
+ export * from './colors.js';
@@ -1,4 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
2
- import React from 'react';
3
3
  import * as theme from './theme/index.js';
4
- export const ThemeProvider = ({ children }) => (React.createElement(EmotionThemeProvider, { theme: theme }, children));
4
+ export const ThemeProvider = ({ children }) => (_jsx(EmotionThemeProvider, { theme: theme, children: children }));
@@ -1,7 +1,7 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
1
2
  import { Children } from 'react';
2
3
  import { IntlProvider } from 'react-intl';
3
4
  import { useMemo } from 'react';
4
- import React from 'react';
5
5
  import { LanguagesType } from '../enums/index.js';
6
6
  import { EnLocale } from '../locales/index.js';
7
7
  import { RuLocale } from '../locales/index.js';
@@ -26,9 +26,5 @@ export const Widget = ({ amount, settings, receipt, additionalFields, styles, ch
26
26
  const { customFields, isGenerateReceiptField, isGenerateRequiredField } = useCustomFields(customFieldsProps);
27
27
  const customButton = useCustomButton(childrenArray);
28
28
  const nameFields = getNameFields(customFields);
29
- return (React.createElement(IntlProvider, { locale: locale ?? navigator.language, 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 },
32
- customFields,
33
- customButton))));
29
+ return (_jsx(IntlProvider, { locale: locale, messages: messages[locale], defaultLocale: LanguagesType.RUSSIAN, children: _jsx(FormProvider, { additionalFields: additionalFields, nameFields: nameFields, isGenerateReceipt: isGenerateReceiptField, isGenerateRequiredField: isGenerateRequiredField, disabled: !!disabled, children: _jsxs(Form, { amount: amount, settings: settings, receipt: receipt, styles: styles, useCustomButton: !!customButton, useCustomFields: !!customFields.length, children: [customFields, customButton] }) }) }));
34
30
  };
@@ -1,14 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { Condition } from '@atls-ui-parts/condition';
2
- import React from 'react';
3
3
  import { ButtonType } from '../../enums/index.js';
4
4
  import { NameWrapperComponent } from '../../enums/index.js';
5
5
  import { useForm } from '../form/index.js';
6
6
  const ButtonWrapper = ({ children }) => {
7
7
  const { disabled, isLoaded } = useForm();
8
- return (React.createElement(Condition, { match: typeof children === 'function' }, children({
9
- type: ButtonType.Submit,
10
- disabled: disabled || !isLoaded,
11
- })));
8
+ return (_jsx(Condition, { match: typeof children === 'function', children: children({
9
+ type: ButtonType.Submit,
10
+ disabled: disabled || !isLoaded,
11
+ }) }));
12
12
  };
13
13
  ButtonWrapper.displayName = NameWrapperComponent.ButtonWrapper;
14
14
  export { ButtonWrapper };
@@ -1,2 +1,2 @@
1
- export * from "./input-wrapper.component.js";
2
- export * from "./button-wrapper.component.js";
1
+ export * from './input-wrapper.component.js';
2
+ export * from './button-wrapper.component.js';
@@ -1,6 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { Condition } from '@atls-ui-parts/condition';
2
3
  import { useIntl } from 'react-intl';
3
- import React from 'react';
4
4
  import { NameWrapperComponent } from '../../enums/index.js';
5
5
  import { translate } from '../../utils/translate.util.js';
6
6
  import { useForm } from '../form/index.js';
@@ -8,13 +8,13 @@ const InputWrapper = ({ name, children }) => {
8
8
  const { fieldsState, handleChange, handleBlur, errors } = useForm();
9
9
  const intl = useIntl();
10
10
  const translateError = translate(intl, errors[name], errors[name]);
11
- return (React.createElement(Condition, { match: typeof children === 'function' }, children({
12
- name,
13
- value: fieldsState[name],
14
- onChangeNative: handleChange,
15
- onBlur: handleBlur,
16
- errorText: translateError,
17
- })));
11
+ return (_jsx(Condition, { match: typeof children === 'function', children: children({
12
+ name,
13
+ value: fieldsState[name],
14
+ onChangeNative: handleChange,
15
+ onBlur: handleBlur,
16
+ errorText: translateError,
17
+ }) }));
18
18
  };
19
19
  InputWrapper.displayName = NameWrapperComponent.InputWrapper;
20
20
  export { InputWrapper };
@@ -1,5 +1,5 @@
1
- export * from "./pay.util.js";
2
- export * from "./add-receipt-fields.util.js";
3
- export * from "./convert-to-penny.util.js";
4
- export * from "./is-custom-element.util.js";
5
- export * from "./get-name-fields.util.js";
1
+ 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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atls/tinkoff-payment-widget",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "exports": {