@atls/tinkoff-payment-widget 0.1.5 → 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.
- package/CHANGELOG.md +11 -0
- package/dist/hooks/use-fields-render.hook.js +9 -9
- package/dist/interfaces/fields.interfaces.d.ts +2 -4
- package/dist/interfaces/form.interfaces.d.ts +1 -1
- package/dist/interfaces/index.d.ts +10 -9
- package/dist/interfaces/index.js +1 -9
- package/dist/interfaces/styles.enum.d.ts +4 -0
- package/dist/interfaces/styles.enum.js +5 -0
- package/dist/interfaces/styles.interfaces.d.ts +1 -4
- package/dist/interfaces/styles.interfaces.js +1 -5
- package/dist/locales/en.locale.d.ts +1 -1
- package/dist/locales/ru.locale.d.ts +1 -1
- package/dist/ui/button/button.component.js +2 -2
- package/dist/ui/fields.component.js +2 -8
- package/dist/ui/form/form.component.d.ts +1 -0
- package/dist/ui/form/form.component.js +2 -7
- package/dist/ui/form/form.provider.js +2 -2
- package/dist/ui/input/input.component.js +7 -11
- package/dist/ui/settings.component.d.ts +1 -1
- package/dist/ui/settings.component.js +2 -7
- package/dist/ui/theme/src/theme.provider.js +2 -2
- package/dist/ui/widget.component.js +2 -6
- package/dist/ui/wrapper/button-wrapper.component.js +5 -5
- package/dist/ui/wrapper/input-wrapper.component.js +8 -8
- package/package.json +1 -1
- /package/dist/interfaces/{custom-fields.iterfaces.d.ts → custom-fields.interfaces.d.ts} +0 -0
- /package/dist/interfaces/{custom-fields.iterfaces.js → custom-fields.interfaces.js} +0 -0
- /package/dist/locales/{locale.interaces.d.ts → locale.interfaces.d.ts} +0 -0
- /package/dist/locales/{locale.interaces.js → locale.interfaces.js} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
## [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
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* **react:** lint and typecheck errors ([a090051](https://github.com/atls/reactjs/commit/a090051d1007e171df8066e85f15fcf8fd44c4ed))
|
|
10
|
+
|
|
11
|
+
|
|
@@ -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,13 +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 (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
React.
|
|
17
|
-
|
|
18
|
-
})));
|
|
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
|
+
}) }));
|
|
19
19
|
};
|
|
@@ -2,7 +2,7 @@ import type { FormEvent } from 'react';
|
|
|
2
2
|
import type { HTMLInputTypeAttribute } from 'react';
|
|
3
3
|
import type { AdditionalFieldsType } from '../enums/index.js';
|
|
4
4
|
import type { RequiredFieldsType } from '../enums/index.js';
|
|
5
|
-
import type { DirectionFields } from './styles.
|
|
5
|
+
import type { DirectionFields } from './styles.enum.js';
|
|
6
6
|
export type FieldsNames = AdditionalFieldsType | RequiredFieldsType;
|
|
7
7
|
export type FieldState = Record<FieldsNames, string>;
|
|
8
8
|
export type ValidateField = (name: FieldsNames, value: string, required?: boolean) => void;
|
|
@@ -20,9 +20,7 @@ export interface AdditionalField extends Field {
|
|
|
20
20
|
export interface RequiredField extends Field {
|
|
21
21
|
name: RequiredFieldsType;
|
|
22
22
|
}
|
|
23
|
-
export type FieldsErrors =
|
|
24
|
-
[key in FieldsNames]: string;
|
|
25
|
-
};
|
|
23
|
+
export type FieldsErrors = Record<FieldsNames, string>;
|
|
26
24
|
export interface FieldsProps {
|
|
27
25
|
amount?: number;
|
|
28
26
|
direction?: DirectionFields;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { NameField } from './custom-fields.
|
|
2
|
+
import type { NameField } from './custom-fields.interfaces.js';
|
|
3
3
|
import type { Field } from './fields.interfaces.js';
|
|
4
4
|
import type { FieldsState } from './fields.interfaces.js';
|
|
5
5
|
import type { FieldsValidator } from './fields.interfaces.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from './widget.interfaces.js';
|
|
2
|
-
export * from './fields.interfaces.js';
|
|
3
|
-
export * from './settings.interfaces.js';
|
|
4
|
-
export * from './receipt.interfaces.js';
|
|
5
|
-
export * from './styles.interfaces.js';
|
|
6
|
-
export * from './theme.interfaces.js';
|
|
7
|
-
export * from './form.interfaces.js';
|
|
8
|
-
export * from './wrappers.interfaces.js';
|
|
9
|
-
export * from './custom-fields.
|
|
1
|
+
export type * from './widget.interfaces.js';
|
|
2
|
+
export type * from './fields.interfaces.js';
|
|
3
|
+
export type * from './settings.interfaces.js';
|
|
4
|
+
export type * from './receipt.interfaces.js';
|
|
5
|
+
export type * from './styles.interfaces.js';
|
|
6
|
+
export type * from './theme.interfaces.js';
|
|
7
|
+
export type * from './form.interfaces.js';
|
|
8
|
+
export type * from './wrappers.interfaces.js';
|
|
9
|
+
export type * from './custom-fields.interfaces.js';
|
|
10
|
+
export * from './styles.enum.js';
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./fields.interfaces.js";
|
|
3
|
-
export * from "./settings.interfaces.js";
|
|
4
|
-
export * from "./receipt.interfaces.js";
|
|
5
|
-
export * from "./styles.interfaces.js";
|
|
6
|
-
export * from "./theme.interfaces.js";
|
|
7
|
-
export * from "./form.interfaces.js";
|
|
8
|
-
export * from "./wrappers.interfaces.js";
|
|
9
|
-
export * from "./custom-fields.iterfaces.js";
|
|
1
|
+
export * from "./styles.enum.js";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { ButtonProps } from '@atls-ui-parts/button';
|
|
2
|
-
|
|
3
|
-
Row = "row",
|
|
4
|
-
Column = "column"
|
|
5
|
-
}
|
|
2
|
+
import type { DirectionFields } from './styles.enum.js';
|
|
6
3
|
export interface Styles {
|
|
7
4
|
direction?: DirectionFields;
|
|
8
5
|
inputGaps?: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Locale } from './locale.
|
|
1
|
+
import type { Locale } from './locale.interfaces.js';
|
|
2
2
|
export declare const EnLocale: Locale;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Locale } from './locale.
|
|
1
|
+
import type { Locale } from './locale.interfaces.js';
|
|
2
2
|
export declare const RuLocale: Locale;
|
|
@@ -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 (
|
|
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 (
|
|
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 (
|
|
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
|
|
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';
|
|
@@ -16,7 +17,7 @@ import { baseStyles } from './input.styles.js';
|
|
|
16
17
|
import { shapeStyles } from './input.styles.js';
|
|
17
18
|
import { transitionStyles } from './input.styles.js';
|
|
18
19
|
export const InputElement = (styled.default ?? styled).div(baseStyles, shapeStyles, appearanceStyles, transitionStyles, layout);
|
|
19
|
-
const Container = (styled.default ?? styled).div(({ type }) => ({
|
|
20
|
+
const Container = (styled.default ?? styled).div(({ type, }) => ({
|
|
20
21
|
display: type === 'hidden' ? 'none' : 'flex',
|
|
21
22
|
width: '100%',
|
|
22
23
|
flexDirection: 'column',
|
|
@@ -28,23 +29,18 @@ export const InputWithoutRef = ({ value, type, required, disabled, errorText = '
|
|
|
28
29
|
if (!ref) {
|
|
29
30
|
ref = useRef(null);
|
|
30
31
|
}
|
|
31
|
-
return (
|
|
32
|
+
return (_jsxs(Container, { type: type, onClick: () => {
|
|
32
33
|
;
|
|
33
|
-
ref.current
|
|
34
|
+
ref.current?.focus();
|
|
34
35
|
}, onBlur: () => {
|
|
35
36
|
;
|
|
36
|
-
ref.current
|
|
37
|
+
ref.current?.blur();
|
|
37
38
|
setFocus(false);
|
|
38
39
|
}, onFocus: () => {
|
|
39
40
|
;
|
|
40
|
-
ref.current
|
|
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) =>
|
|
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, }) => (
|
|
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 }) => (
|
|
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 (
|
|
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 (
|
|
9
|
-
|
|
10
|
-
|
|
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 (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|