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