File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed
core/src/main/java/dev/vml/es/acm/core/code/input Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,21 @@ public void tel() {
3636 this .display = Display .TEL ;
3737 }
3838
39+ public void numeric () {
40+ this .display = Display .NUMERIC ;
41+ }
42+
43+ public void decimal () {
44+ this .display = Display .DECIMAL ;
45+ }
46+
3947 public enum Display {
4048 TEXT ,
4149 PASSWORD ,
4250 URL ,
4351 TEL ,
52+ NUMERIC ,
53+ DECIMAL ,
4454 EMAIL ;
4555
4656 public static Display of (String name ) {
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ import { useInput } from '../hooks/form.ts';
2929import {
3030 Input ,
3131 InputValue ,
32+ stringInputDisplayToMode ,
33+ stringInputDisplayToType ,
3234 isBoolInput ,
3335 isColorInput ,
3436 isDateTimeInput ,
@@ -138,7 +140,8 @@ const CodeInput: React.FC<CodeInputProps> = ({ input }) => {
138140 } else if ( isStringInput ( input ) ) {
139141 return (
140142 < TextField
141- type = { input . display }
143+ type = { stringInputDisplayToType ( input . display ) }
144+ inputMode = { stringInputDisplayToMode ( input . display ) }
142145 { ...field }
143146 value = { field . value ?? '' }
144147 label = { label }
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export type TextInput = Input<string> & {
3535} ;
3636
3737export type StringInput = Input < string > & {
38- display : 'PLAIN ' | 'PASSWORD' ;
38+ display : 'TEXT ' | 'PASSWORD' | 'URL' | 'TEL' | 'EMAIL' | 'NUMERIC' | 'DECIMAL ';
3939} ;
4040
4141export type NumberInput = Input < number > &
@@ -140,3 +140,38 @@ export function isMapInput(input: Input<InputValue>): input is MapInput {
140140export function isKeyValueListInput ( input : Input < InputValue > ) : input is KeyValueListInput {
141141 return input . type === 'KEY_VALUE_LIST' ;
142142}
143+
144+ export function stringInputDisplayToType ( display : string ) : string {
145+ switch ( display ) {
146+ case 'PASSWORD' :
147+ return 'password' ;
148+ case 'URL' :
149+ return 'url' ;
150+ case 'TEL' :
151+ return 'tel' ;
152+ case 'EMAIL' :
153+ return 'email' ;
154+ case 'TEXT' :
155+ default :
156+ return 'text' ;
157+ }
158+ }
159+
160+ export function stringInputDisplayToMode ( display : string ) : "url" | "tel" | "email" | "text" | "numeric" | "decimal" {
161+ switch ( display ) {
162+ case 'URL' :
163+ return 'url' ;
164+ case 'TEL' :
165+ return 'tel' ;
166+ case 'EMAIL' :
167+ return 'email' ;
168+ case 'NUMERIC' :
169+ return 'numeric' ;
170+ case 'DECIMAL' :
171+ return 'decimal' ;
172+ case 'TEXT' :
173+ case 'PASSWORD' :
174+ default :
175+ return 'text' ;
176+ }
177+ }
You can’t perform that action at this time.
0 commit comments