Skip to content

Commit e2c9d61

Browse files
committed
[form] Allow to augment InputAttributes type
1 parent 19b91f4 commit e2c9d61

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.changeset/pretty-ears-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sjsf/form": minor
3+
---
4+
5+
Allow to augment `InputAttributes` type

apps/docs/src/content/docs/api-reference/ui-schema.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ Root node of UI schema can have an additional fields:
3131
## UI options
3232

3333
```typescript
34-
type InputAttributes =
35-
| HTMLInputAttributes
36-
| HTMLTextareaAttributes
37-
| HTMLSelectAttributes
34+
interface Inputs {
35+
input: HTMLInputAttributes;
36+
textarea: HTMLTextareaAttributes;
37+
select: HTMLSelectAttributes;
38+
}
39+
40+
type InputAttributes = Inputs[keyof Inputs];
3841

3942
interface UiOptions {
4043
/**

packages/form/src/form/ui-schema.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ interface UiSchemaContent {
4747
additionalItems?: UiSchema;
4848
}
4949

50-
// TODO: Omit non serializable properties
51-
export type InputAttributes =
52-
| HTMLInputAttributes
53-
| HTMLTextareaAttributes
54-
| HTMLSelectAttributes;
50+
export interface Inputs {
51+
input: HTMLInputAttributes;
52+
textarea: HTMLTextareaAttributes;
53+
select: HTMLSelectAttributes;
54+
}
55+
56+
export type InputAttributes = Inputs[keyof Inputs];
5557

5658
export interface UiOptions {
5759
/**

0 commit comments

Comments
 (0)