Skip to content

Commit 65cc77f

Browse files
Add error text to input component
1 parent 4d65e1d commit 65cc77f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

packages/snaps-sdk/src/ui/components/input.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('Input', () => {
1010
inputType: InputType.Text,
1111
placeholder: 'Type here...',
1212
label: 'Hello',
13+
error: 'Invalid input',
1314
}),
1415
).toStrictEqual({
1516
type: NodeType.Input,
@@ -18,6 +19,7 @@ describe('Input', () => {
1819
inputType: InputType.Text,
1920
placeholder: 'Type here...',
2021
label: 'Hello',
22+
error: 'Invalid input',
2123
});
2224

2325
expect(

packages/snaps-sdk/src/ui/components/input.ts

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const InputStruct = assign(
3232
),
3333
placeholder: optional(string()),
3434
label: optional(string()),
35+
error: optional(string()),
3536
}),
3637
);
3738

@@ -44,6 +45,7 @@ export const InputStruct = assign(
4445
* @property inputType - An optional type, either `text`, `password` or `number`.
4546
* @property placeholder - An optional input placeholder.
4647
* @property label - An optional input label.
48+
* @property error - An optional error text.
4749
*/
4850
export type Input = Infer<typeof InputStruct>;
4951

@@ -57,6 +59,7 @@ export type Input = Infer<typeof InputStruct>;
5759
* @param args.inputType - An optional type, either `text`, `password` or `number`.
5860
* @param args.placeholder - An optional input placeholder.
5961
* @param args.label - An optional input label.
62+
* @param args.error - An optional error text.
6063
* @returns The input node as an object.
6164
* @example
6265
* const node = input('myInput');

0 commit comments

Comments
 (0)