feat: перенос быстрой пачки компонентов 0.1.0

This commit is contained in:
Тимур Городецкий
2026-08-13 14:53:11 +05:00
parent f5637f8b2c
commit e65805379e
42 changed files with 1911 additions and 5 deletions
+31
View File
@@ -0,0 +1,31 @@
import * as React from 'react';
import { TextInput } from '../TextInput/TextInput';
// Показ с разделителем тысяч пробелом: 350000 → «350 000».
function formatThousands(input: string): string {
const digits = input.replace(/\D/g, '');
if (!digits) {
return '';
}
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
}
interface IMoneyInputProps {
id?: string;
value: string;
onChange: (value: string) => void;
readOnly?: boolean;
}
/**
* Ввод суммы с разделителем тысяч. В модель формы кладём «сырые» цифры
* (без пробелов), поэтому запись в числовую колонку SP работает как есть.
*/
export const MoneyInput: React.FC<IMoneyInputProps> = ({ id, value, onChange, readOnly }) => (
<TextInput
id={id}
value={formatThousands(value)}
onChange={(v) => onChange(v.replace(/\D/g, ''))}
readOnly={readOnly}
/>
);