|
1 | 1 | import styles from './page.module.css';
|
| 2 | +import {inputTypes} from '@/data/controls-metadata'; |
2 | 3 |
|
3 |
| -export default function InputPage() { |
| 4 | +let _uuid = Number.MIN_SAFE_INTEGER; |
4 | 5 |
|
5 |
| - // All HTMLInputElement types |
6 |
| - // ---- |
7 |
| - const inputTypes = [ |
8 |
| - 'button', |
9 |
| - 'checkbox', |
10 |
| - 'color', |
11 |
| - 'date', |
12 |
| - 'datetime-local', |
13 |
| - 'email', |
14 |
| - 'file', |
15 |
| - 'hidden', |
16 |
| - 'image', |
17 |
| - 'month', |
18 |
| - 'number', |
19 |
| - 'password', |
20 |
| - 'radio', |
21 |
| - 'range', |
22 |
| - 'reset', |
23 |
| - 'search', |
24 |
| - 'submit', |
25 |
| - 'tel', |
26 |
| - 'text', |
27 |
| - 'time', |
28 |
| - 'url', |
29 |
| - 'week' |
30 |
| - ], |
31 |
| - |
32 |
| - elementsConfig = inputTypes.map(type => { |
33 |
| - let options = null; |
34 |
| - |
35 |
| - switch (type) { |
36 |
| - case 'button': |
37 |
| - case 'image': |
38 |
| - case 'submit': |
39 |
| - case 'reset': |
40 |
| - return [type, {value: type[0].toUpperCase() + type.substring(1)}]; |
41 |
| - case 'hidden': |
42 |
| - break; |
43 |
| - case 'date': |
44 |
| - options = {showReadonly: true, readonly2Value: '2023-05-01'}; |
45 |
| - break; |
46 |
| - case 'datetime-local': |
47 |
| - options = {showReadonly: true, readonly2Value: '2023-05-10T11:59'}; |
48 |
| - break; |
49 |
| - case 'time': |
50 |
| - options = {showReadonly: true, readonly2Value: '11:59'}; |
51 |
| - break; |
52 |
| - case 'number': |
53 |
| - options = {showReadonly: true, readonly2Value: '1000'}; |
54 |
| - break; |
55 |
| - case 'email': |
56 |
| - options = {showReadonly: true, readonly2Value: '[email protected]'}; |
57 |
| - break; |
58 |
| - case 'file': |
59 |
| - options = {showReadonly: true}; |
60 |
| - break; |
61 |
| - default: |
62 |
| - options = {showReadonly: true, readonly2Value: 'Readonly'}; |
63 |
| - break; |
64 |
| - } |
65 |
| - |
66 |
| - return [type, options]; |
67 |
| - }); |
| 6 | +export default function InputPage() { |
| 7 | + const elementsConfig = inputTypes.map(type => { |
| 8 | + let options = null; |
| 9 | + |
| 10 | + switch (type) { |
| 11 | + case 'button': |
| 12 | + case 'image': |
| 13 | + case 'submit': |
| 14 | + case 'reset': |
| 15 | + return [type, {value: type[0].toUpperCase() + type.substring(1)}]; |
| 16 | + case 'hidden': |
| 17 | + break; |
| 18 | + case 'date': |
| 19 | + options = {showReadonly: true, readonly2Value: '2023-05-01'}; |
| 20 | + break; |
| 21 | + case 'datetime-local': |
| 22 | + options = {showReadonly: true, readonly2Value: '2023-05-10T11:59'}; |
| 23 | + break; |
| 24 | + case 'time': |
| 25 | + options = {showReadonly: true, readonly2Value: '11:59'}; |
| 26 | + break; |
| 27 | + case 'number': |
| 28 | + options = {showReadonly: true, readonly2Value: '1000'}; |
| 29 | + break; |
| 30 | + case 'email': |
| 31 | + options = {showReadonly: true, readonly2Value: '[email protected]'}; |
| 32 | + break; |
| 33 | + case 'file': |
| 34 | + options = {showReadonly: true}; |
| 35 | + break; |
| 36 | + default: |
| 37 | + options = {showReadonly: true, readonly2Value: 'Readonly'}; |
| 38 | + break; |
| 39 | + } |
| 40 | + |
| 41 | + return [type, options]; |
| 42 | + }); |
68 | 43 |
|
69 | 44 | return <section className="x-flex x-flex-row-wrap">
|
70 | 45 | <article className={styles['article']}>
|
@@ -193,5 +168,35 @@ export default function InputPage() {
|
193 | 168 | </fieldset>
|
194 | 169 | </form>
|
195 | 170 | </article>
|
| 171 | + |
| 172 | + <article> |
| 173 | + <header> |
| 174 | + <h3>Input Controls Alignment</h3> |
| 175 | + </header> |
| 176 | + |
| 177 | + <form action="#"> |
| 178 | + <fieldset className={`${styles.fieldset} x-flex x-flex-row-wrap`}> |
| 179 | + <legend>Horizontal alignment</legend> |
| 180 | + |
| 181 | + {inputTypes.map((inputType) => { |
| 182 | + const id = `example-${_uuid++}-${inputType}`; |
| 183 | + const isButton = /reset|submit|button$/i.test(inputType); |
| 184 | + |
| 185 | + if (inputType === 'hidden') return; |
| 186 | + |
| 187 | + return <> |
| 188 | + {!isButton ? <label htmlFor={id}>{inputType}:</label> : null} |
| 189 | + <input |
| 190 | + type={inputType} |
| 191 | + className={`${inputType === 'button' ? 'x-btn x-primary x-filled' : ''}`} |
| 192 | + defaultValue={isButton ? inputType[0].toUpperCase() + inputType.slice(1) : ''} |
| 193 | + name={`example-${_uuid}-${inputType}`} |
| 194 | + id={id} |
| 195 | + /> |
| 196 | + </>; |
| 197 | + })} |
| 198 | + </fieldset> |
| 199 | + </form> |
| 200 | + </article> |
196 | 201 | </section>;
|
197 | 202 | }
|
0 commit comments