Skip to content

Commit

Permalink
feat(field): disabled field
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzwan committed Aug 3, 2023
1 parent 1171801 commit 67c61c4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/stories/create-field.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,24 @@ export const AcceptedField: ComponentStory<typeof Field> = ({
</Form>
);
};

export const InputDisabledNumber: ComponentStory<typeof Field> = ({
onSubmit,
}: any) => {
return (
<Form<T5>
onSubmit={onSubmit}
className="shadow border border-secondary rounded-3 p-3 w-75">
<FieldNumber<T5>
name="num"
label="необязательное number"
disabled
defaultValue={12}
/>

<button className="btn btn-success" type="submit">
Отправить
</button>
</Form>
);
};
9 changes: 8 additions & 1 deletion src/stories/field-typed/field-typed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {createField} from '~/create-field';
export interface IField {
label: string;
step?: number;
disabled?: boolean;
}

const FieldView = (props: FieldProps<IField>) => {
const {
disabled,
inputProps,
label,
step,
Expand All @@ -22,7 +24,12 @@ const FieldView = (props: FieldProps<IField>) => {
return (
<div className="mb-3">
<label className="form-label">{label}</label>
<input className="form-control" {...inputProps} step={step} />
<input
className="form-control"
{...inputProps}
step={step}
disabled={disabled}
/>
<span className="invalid-feedback d-block">{error}</span>
</div>
);
Expand Down

0 comments on commit 67c61c4

Please sign in to comment.