Skip to content

Commit 74ddddf

Browse files
committed
Specific input mode similar to type
1 parent 338ca32 commit 74ddddf

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

packages/uui-input/lib/uui-input.element.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ export type InputType =
2424
| 'number'
2525
| 'color';
2626

27+
export type InputMode =
28+
| 'text'
29+
| 'none'
30+
| 'decimal'
31+
| 'numeric'
32+
| 'tel'
33+
| 'search'
34+
| 'email'
35+
| 'url';
36+
2737
/**
2838
* Custom element wrapping the native input element.This is a formAssociated element, meaning it can participate in a native HTMLForm. A name:value pair will be submitted.
2939
* @element uui-input
@@ -169,7 +179,7 @@ export class UUIInputElement extends UUIFormControlMixin(
169179

170180
/**
171181
* This property specifies the type of input that will be rendered.
172-
* @type {'text' | 'tel'| 'url'| 'email'| 'password'| 'date'| 'month'| 'week'| 'time'| 'datetime-local'| 'number'| 'color'}
182+
* @type {'text' | 'tel' | 'url' | 'email' | 'password' | 'date' | 'month' | 'week' | 'time' | 'datetime-local' | 'number' | 'color'}
173183
* @attr
174184
* @default text
175185
*/
@@ -182,26 +192,33 @@ export class UUIInputElement extends UUIFormControlMixin(
182192
}
183193

184194
/**
185-
* Validates the input based on the Regex pattern
186-
* @type {string}
195+
* The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard.
196+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode|MDN} for further information
197+
* @type {'text' | 'none' | 'decimal' | 'number' | 'tel' | 'search' | 'email' | 'url'}
187198
* @attr
199+
* @default text
188200
*/
189201
@property({ type: String })
190-
pattern?: string;
202+
get inputMode(): InputMode {
203+
return this._inputMode;
204+
}
205+
set inputMode(value: InputMode) {
206+
this._inputMode = value;
207+
}
191208

192209
/**
193-
* The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard.
194-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode|MDN} for further information
210+
* Validates the input based on the Regex pattern
195211
* @type {string}
196212
* @attr
197213
*/
198214
@property({ type: String })
199-
inputMode = '';
215+
pattern?: string;
200216

201217
@query('#input')
202218
_input!: HTMLInputElement;
203219

204220
private _type: InputType = 'text';
221+
private _inputMode: InputMode = 'text';
205222

206223
constructor() {
207224
super();

packages/uui-input/lib/uui-input.story.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ const meta: Meta = {
3333
'wha',
3434
],
3535
},
36+
inputMode: {
37+
options: [
38+
'text',
39+
'none',
40+
'decimal',
41+
'numeric',
42+
'tel',
43+
'search',
44+
'email',
45+
'url',
46+
],
47+
},
3648
},
3749
parameters: {
3850
readme: {

0 commit comments

Comments
 (0)