@tap-payments/os-micro-frontend-shared 0.1.138-test.1 → 0.1.138
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/build/components/index.d.ts +0 -1
- package/build/components/index.js +0 -1
- package/build/utils/number.d.ts +0 -2
- package/build/utils/number.js +0 -7
- package/package.json +3 -3
- package/build/components/AmountInput/AmountInput.d.ts +0 -14
- package/build/components/AmountInput/AmountInput.js +0 -43
- package/build/components/AmountInput/index.d.ts +0 -2
- package/build/components/AmountInput/index.js +0 -2
- package/build/components/AmountInput/style.d.ts +0 -8
- package/build/components/AmountInput/style.js +0 -30
|
@@ -114,4 +114,3 @@ export { default as ErrorToast } from './ErrorToast';
|
|
|
114
114
|
export { default as ToggleView, type ToggleViewsValues, ToggleViews } from './ToggleView';
|
|
115
115
|
export { default as LanguageDropdown } from './LanguageDropdown';
|
|
116
116
|
export { default as DisplayAmount } from './DisplayAmount';
|
|
117
|
-
export { default as AmountInput } from './AmountInput';
|
|
@@ -114,4 +114,3 @@ export { default as ErrorToast } from './ErrorToast';
|
|
|
114
114
|
export { default as ToggleView, ToggleViews } from './ToggleView';
|
|
115
115
|
export { default as LanguageDropdown } from './LanguageDropdown';
|
|
116
116
|
export { default as DisplayAmount } from './DisplayAmount';
|
|
117
|
-
export { default as AmountInput } from './AmountInput';
|
package/build/utils/number.d.ts
CHANGED
|
@@ -4,5 +4,3 @@ export declare const stringToNumber: (value: string) => number;
|
|
|
4
4
|
export declare const numberToString: (value: number, fixed?: number) => string;
|
|
5
5
|
export declare function pad(num: number, length?: number): string;
|
|
6
6
|
export declare function isNegative(num: number): boolean;
|
|
7
|
-
export declare const getRoundedAmount: (amount: number, decimals: number) => number;
|
|
8
|
-
export declare const getAmountPlaceholder: (decimals: number) => string;
|
package/build/utils/number.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import round from 'lodash/round';
|
|
2
1
|
export function formatOrdinal(num) {
|
|
3
2
|
if (!num)
|
|
4
3
|
return '';
|
|
@@ -30,9 +29,3 @@ export function pad(num, length = 2) {
|
|
|
30
29
|
export function isNegative(num) {
|
|
31
30
|
return Math.sign(num) === -1;
|
|
32
31
|
}
|
|
33
|
-
export const getRoundedAmount = (amount, decimals) => {
|
|
34
|
-
return round(amount, decimals);
|
|
35
|
-
};
|
|
36
|
-
export const getAmountPlaceholder = (decimals) => {
|
|
37
|
-
return `0.${'0'.repeat(decimals)}`;
|
|
38
|
-
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.138
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.138",
|
|
5
|
+
"testVersion": 0,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|
|
@@ -136,4 +136,4 @@
|
|
|
136
136
|
"publishConfig": {
|
|
137
137
|
"registry": "https://registry.npmjs.org/"
|
|
138
138
|
}
|
|
139
|
-
}
|
|
139
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { BoxProps } from '@mui/material/Box';
|
|
3
|
-
import { Currency } from '../../types/index.js';
|
|
4
|
-
interface AmountInputI extends BoxProps {
|
|
5
|
-
amount: number | string;
|
|
6
|
-
setAmount: (value?: number) => void;
|
|
7
|
-
maxAmount?: number;
|
|
8
|
-
isError?: boolean;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
selectedCurrency: Currency;
|
|
11
|
-
}
|
|
12
|
-
declare function AmountInput({ amount, setAmount, placeholder, maxAmount, isError, selectedCurrency, ...props }: AmountInputI): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
declare const _default: import("react").MemoExoticComponent<typeof AmountInput>;
|
|
14
|
-
export default _default;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { memo, useMemo, useState } from 'react';
|
|
14
|
-
import { isSafariBrowser, getAmountPlaceholder } from '../../utils/index.js';
|
|
15
|
-
import { DisplayAmount } from '../index.js';
|
|
16
|
-
import { Wrapper, InputStyled } from './style';
|
|
17
|
-
const isSafari = isSafariBrowser();
|
|
18
|
-
function AmountInput(_a) {
|
|
19
|
-
var { amount, setAmount, placeholder, maxAmount, isError, selectedCurrency } = _a, props = __rest(_a, ["amount", "setAmount", "placeholder", "maxAmount", "isError", "selectedCurrency"]);
|
|
20
|
-
const [editMode, setEditMode] = useState(false);
|
|
21
|
-
const [value, setValue] = useState(amount || '');
|
|
22
|
-
const currencyPlaceholder = useMemo(() => getAmountPlaceholder(selectedCurrency === null || selectedCurrency === void 0 ? void 0 : selectedCurrency.decimals), [selectedCurrency]);
|
|
23
|
-
const onChange = (e) => {
|
|
24
|
-
const newValue = Number(e.target.value) || 0;
|
|
25
|
-
if (!!maxAmount && newValue > maxAmount)
|
|
26
|
-
return false;
|
|
27
|
-
setValue(newValue);
|
|
28
|
-
setAmount(newValue);
|
|
29
|
-
};
|
|
30
|
-
const onBlur = () => {
|
|
31
|
-
setEditMode(false);
|
|
32
|
-
setAmount(Number(value));
|
|
33
|
-
};
|
|
34
|
-
const onKeyDown = (evt) => {
|
|
35
|
-
if (isSafari && isNaN(Number(evt.key)) && evt.key !== 'Backspace' && evt.key !== '.') {
|
|
36
|
-
evt.preventDefault();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
return (_jsx(Wrapper, Object.assign({ sx: props.sx }, { children: editMode ? (_jsx(InputStyled, { placeholder: currencyPlaceholder, value: value, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, isError: isError, inputProps: { step: '0.01' }, hideArrows: true, autoFocus: true })) : (_jsx(DisplayAmount, { selectedCurrency: selectedCurrency, amount: amount, onClick: () => {
|
|
40
|
-
setEditMode(true);
|
|
41
|
-
} })) })));
|
|
42
|
-
}
|
|
43
|
-
export default memo(AmountInput);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const Wrapper: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
4
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
5
|
-
export declare const InputStyled: import("@emotion/styled").StyledComponent<Omit<Readonly<import("@mui/material").InputProps & {
|
|
6
|
-
isError?: boolean | undefined;
|
|
7
|
-
hideArrows?: boolean | undefined;
|
|
8
|
-
}>, "ref"> & import("react").RefAttributes<HTMLInputElement> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
3
|
-
import { InputNumber } from '../index.js';
|
|
4
|
-
export const Wrapper = styled(Box)(({ theme }) => ({
|
|
5
|
-
color: theme.palette.text.primary,
|
|
6
|
-
border: `1px solid ${theme.palette.divider}`,
|
|
7
|
-
padding: theme.spacing(1),
|
|
8
|
-
borderRadius: '4px',
|
|
9
|
-
display: 'flex',
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
justifyContent: 'flex-end',
|
|
12
|
-
width: 93,
|
|
13
|
-
height: 32,
|
|
14
|
-
textAlign: 'right',
|
|
15
|
-
input: {
|
|
16
|
-
fontSize: '11px',
|
|
17
|
-
border: 'none',
|
|
18
|
-
color: theme.palette.text.primary,
|
|
19
|
-
height: 30,
|
|
20
|
-
padding: 0,
|
|
21
|
-
textAlign: 'right',
|
|
22
|
-
},
|
|
23
|
-
img: { cursor: 'pointer' },
|
|
24
|
-
}));
|
|
25
|
-
export const InputStyled = styled(InputNumber)(() => ({
|
|
26
|
-
padding: 0,
|
|
27
|
-
border: 'none',
|
|
28
|
-
height: 24,
|
|
29
|
-
input: { textAlign: 'right', width: '100%' },
|
|
30
|
-
}));
|