|
37 | 37 | {#if multiple}
|
38 | 38 | <!-- select multiple does not work with spread props -->
|
39 | 39 | <!-- https://github.com/sveltejs/svelte/issues/4392 -->
|
40 |
| - <select |
41 |
| - name={name} |
42 |
| - multiple |
43 |
| - value={$values[name]} |
44 |
| - on:blur={handleBlur} |
45 |
| - on:input={handleInput} |
46 |
| - > |
47 |
| - <slot></slot> |
| 40 | + <select {name} multiple value={$values[name]} on:blur={handleBlur} on:input={handleInput}> |
| 41 | + <slot /> |
48 | 42 | </select>
|
49 | 43 | {:else}
|
50 |
| - <select |
51 |
| - name={name} |
52 |
| - value={$values[name]} |
53 |
| - {...$$restProps} |
54 |
| - on:blur={handleBlur} |
55 |
| - on:input={handleInput} |
56 |
| - > |
57 |
| - <slot></slot> |
| 44 | + <select {name} value={$values[name]} {...$$restProps} on:blur={handleBlur} on:input={handleInput}> |
| 45 | + <slot /> |
58 | 46 | </select>
|
59 | 47 | {/if}
|
60 | 48 | {:else if as === 'textarea'}
|
61 |
| - <textarea |
62 |
| - name={name} |
63 |
| - value={$values[name]} |
64 |
| - {...$$restProps} |
65 |
| - on:blur={handleBlur} |
66 |
| - on:input={handleInput} |
67 |
| - /> |
| 49 | + <textarea {name} value={$values[name]} {...$$restProps} on:blur={handleBlur} on:input={handleInput} /> |
68 | 50 | {:else if as === 'checkbox'}
|
69 | 51 | <input
|
70 |
| - name={name} |
| 52 | + {name} |
71 | 53 | type="checkbox"
|
72 | 54 | checked={$values[name]}
|
73 | 55 | {...$$restProps}
|
|
77 | 59 | {:else if typeof as === 'object' || typeof as === 'function'}
|
78 | 60 | <svelte:component
|
79 | 61 | this={as}
|
80 |
| - field={{ |
81 |
| - name, |
82 |
| - value: $values[name], |
83 |
| - handleBlur: contextHandleBlur, |
84 |
| - handleInput: contextHandleInput, |
85 |
| - }} |
| 62 | + field={{ name, value: $values[name], handleBlur: contextHandleBlur, handleInput: contextHandleInput }} |
86 | 63 | form={sveltikBag}
|
87 |
| - meta={{ |
88 |
| - initialError: initialErrors[name], |
89 |
| - initialTouched: initialTouched[name], |
90 |
| - initialValue: initialValues[name], |
91 |
| - initialWarning: initialWarnings[name], |
92 |
| - value: $values[name], |
93 |
| - touched: $touched[name], |
94 |
| - error: $errors[name], |
95 |
| - warning: $warnings[name], |
96 |
| - }} |
| 64 | + meta={{ initialError: initialErrors[name], initialTouched: initialTouched[name], initialValue: initialValues[name], initialWarning: initialWarnings[name], value: $values[name], touched: $touched[name], error: $errors[name], warning: $warnings[name] }} |
97 | 65 | props={$$restProps}
|
98 | 66 | />
|
99 | 67 | {:else}
|
100 | 68 | <slot
|
101 |
| - field={{ |
102 |
| - name, |
103 |
| - value: $values[name], |
104 |
| - handleBlur: contextHandleBlur, |
105 |
| - handleInput: contextHandleInput, |
106 |
| - }} |
| 69 | + field={{ name, value: $values[name], handleBlur: contextHandleBlur, handleInput: contextHandleInput }} |
107 | 70 | form={sveltikBag}
|
108 |
| - meta={{ |
109 |
| - initialError: initialErrors[name], |
110 |
| - initialTouched: initialTouched[name], |
111 |
| - initialValue: initialValues[name], |
112 |
| - initialWarning: initialWarnings[name], |
113 |
| - value: $values[name], |
114 |
| - touched: $touched[name], |
115 |
| - error: $errors[name], |
116 |
| - warning: $warnings[name], |
117 |
| - }} |
| 71 | + meta={{ initialError: initialErrors[name], initialTouched: initialTouched[name], initialValue: initialValues[name], initialWarning: initialWarnings[name], value: $values[name], touched: $touched[name], error: $errors[name], warning: $warnings[name] }} |
118 | 72 | >
|
119 | 73 | {#if type === 'number'}
|
120 | 74 | <input
|
121 |
| - name={name} |
| 75 | + {name} |
122 | 76 | type="number"
|
123 | 77 | value={$values[name]}
|
124 | 78 | {...$$restProps}
|
125 | 79 | on:blur={handleBlur}
|
126 | 80 | on:input={handleInput}
|
127 | 81 | />
|
128 | 82 | {:else}
|
129 |
| - <input |
130 |
| - name={name} |
131 |
| - value={$values[name]} |
132 |
| - type={type} |
133 |
| - {...$$restProps} |
134 |
| - on:blur={handleBlur} |
135 |
| - on:input={handleInput} |
136 |
| - /> |
| 83 | + <input {name} value={$values[name]} {type} {...$$restProps} on:blur={handleBlur} on:input={handleInput} /> |
137 | 84 | {/if}
|
138 | 85 | </slot>
|
139 | 86 | {/if}
|
0 commit comments