@atls/tinkoff-payment-widget 0.1.6 → 0.2.0

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.
@@ -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
  };
@@ -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,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,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,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 };
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.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "exports": {