@@ -6,6 +6,7 @@ import type {
66} from "svelte/elements" ;
77
88import type { Nullable } from "@/lib/types.js" ;
9+ import type { Schema } from '@/core/index.js' ;
910
1011import type { Config } from "../config.js" ;
1112import { computeId } from "../id-schema.js" ;
@@ -47,6 +48,12 @@ function inputType(format: string | undefined) {
4748 }
4849}
4950
51+ function isReadonly (
52+ schema : Schema
53+ ) {
54+ return schema . readOnly || schema . const !== undefined ;
55+ }
56+
5057export function inputAttributes (
5158 ctx : FormContext ,
5259 { idSchema, required, schema, uiOptions } : Config ,
@@ -70,6 +77,7 @@ export function inputAttributes(
7077 list : Array . isArray ( schema . examples )
7178 ? computeId ( idSchema , "examples" )
7279 : undefined ,
80+ readonly : isReadonly ( schema ) ,
7381 oninput : handlers . oninput ,
7482 onchange : handlers . onchange ,
7583 onblur : handlers . onblur ,
@@ -94,6 +102,7 @@ export function textareaAttributes(
94102 required,
95103 minlength : schema . minLength ,
96104 maxlength : schema . maxLength ,
105+ readonly : isReadonly ( schema ) ,
97106 oninput : handlers . oninput ,
98107 onchange : handlers . onchange ,
99108 onblur : handlers . onblur ,
0 commit comments