feat: добавить min/max в TextInput (ограничение диапазона дат в календаре) (0.9.0)
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tnsu/ui-kit",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "TNSU shared UI components for SPFx web parts",
|
||||
"author": "Timur Gorodetskiy",
|
||||
"license": "ISC",
|
||||
|
||||
@@ -12,6 +12,13 @@ interface ITextInputProps {
|
||||
placeholder?: string;
|
||||
/** Только чтение (режим согласующего). */
|
||||
readOnly?: boolean;
|
||||
/**
|
||||
* Границы значения — для type='date' YYYY-MM-DD (native min/max), для
|
||||
* type='number' числовая граница. Браузер сам блокирует недоступные даты в
|
||||
* календаре при type='date'.
|
||||
*/
|
||||
min?: string | number;
|
||||
max?: string | number;
|
||||
}
|
||||
|
||||
/** Однострочный ввод. type='number'|'date' — для числовых полей и дат. */
|
||||
@@ -21,7 +28,9 @@ export const TextInput: React.FC<ITextInputProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
readOnly
|
||||
readOnly,
|
||||
min,
|
||||
max
|
||||
}) => {
|
||||
const contextReadOnly = useFormReadOnly();
|
||||
const effectiveReadOnly = readOnly ?? contextReadOnly;
|
||||
@@ -33,6 +42,8 @@ export const TextInput: React.FC<ITextInputProps> = ({
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
readOnly={effectiveReadOnly}
|
||||
min={min}
|
||||
max={max}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user