Skip to content

Commit f18414d

Browse files
bjarnefiOvergaard
andauthored
feat: Specific input mode similar to input type (#1021)
* Specific input mode similar to type * Simplify type and inputmode * Link to input types as well * revert back to accessor field in order not to break descendants --------- Co-authored-by: Jacob Overgaard <[email protected]>
1 parent 517788b commit f18414d

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

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

Lines changed: 20 additions & 8 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,8 @@ 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+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types|MDN} for further information
183+
* @type {'text' | 'tel' | 'url' | 'email' | 'password' | 'date' | 'month' | 'week' | 'time' | 'datetime-local' | 'number' | 'color'}
173184
* @attr
174185
* @default text
175186
*/
@@ -182,21 +193,22 @@ export class UUIInputElement extends UUIFormControlMixin(
182193
}
183194

184195
/**
185-
* Validates the input based on the Regex pattern
186-
* @type {string}
196+
* 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.
197+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode|MDN} for further information
198+
* @type {'text' | 'none' | 'decimal' | 'number' | 'tel' | 'search' | 'email' | 'url'}
187199
* @attr
200+
* @default text
188201
*/
189-
@property({ type: String })
190-
pattern?: string;
202+
@property({ attribute: 'inputmode' })
203+
inputMode: InputMode = 'text';
191204

192205
/**
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
206+
* Validates the input based on the Regex pattern
195207
* @type {string}
196208
* @attr
197209
*/
198210
@property({ type: String })
199-
inputMode = '';
211+
pattern?: string;
200212

201213
@query('#input')
202214
_input!: HTMLInputElement;

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

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

0 commit comments

Comments
 (0)