easy-forms-core 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/dist/easy-form.d.ts +24 -0
- package/dist/easy-form.js +609 -3
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +617 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,11 +144,97 @@ const schema = {
|
|
|
144
144
|
</template>
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
+
## Templates Pre-construidos
|
|
148
|
+
|
|
149
|
+
EasyForms incluye templates pre-construidos para formularios comunes. Puedes usar el atributo `template` en lugar de `schema`. Los templates y schemas son mutuamente excluyentes.
|
|
150
|
+
|
|
151
|
+
### Uso Básico de Templates
|
|
152
|
+
|
|
153
|
+
```html
|
|
154
|
+
<!-- HTML Vanilla -->
|
|
155
|
+
<easy-form template="login"></easy-form>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
import 'easy-forms-core'
|
|
160
|
+
|
|
161
|
+
const form = document.querySelector('easy-form')
|
|
162
|
+
form.template = 'register'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
// React
|
|
167
|
+
<easy-form template="contact" />
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```vue
|
|
171
|
+
<!-- Vue -->
|
|
172
|
+
<easy-form template="login" />
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Templates Disponibles
|
|
176
|
+
|
|
177
|
+
1. **login** - Login form (email, password, remember me)
|
|
178
|
+
2. **register** - Registration form (name, email, password, confirm password)
|
|
179
|
+
3. **otp** - OTP verification (6-digit code)
|
|
180
|
+
4. **contact** - Contact form (name, email, subject, message)
|
|
181
|
+
5. **password-reset** - Password reset request (email)
|
|
182
|
+
6. **password-change** - Change password (current, new, confirm)
|
|
183
|
+
7. **profile** - User profile edit (name, email, phone, bio, avatar)
|
|
184
|
+
8. **checkout** - Checkout form (billing address, payment method, shipping)
|
|
185
|
+
9. **feedback** - Feedback form (rating, comment, email)
|
|
186
|
+
10. **subscription** - Newsletter subscription (email, preferences)
|
|
187
|
+
11. **booking** - Booking/reservation (date, time, guests, special requests)
|
|
188
|
+
12. **review** - Review/rating form (rating, title, comment)
|
|
189
|
+
|
|
190
|
+
### Extender Templates
|
|
191
|
+
|
|
192
|
+
Puedes extender un template agregando campos adicionales usando el atributo `template-extend`:
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<easy-form
|
|
196
|
+
template="contact"
|
|
197
|
+
template-extend='[{"type": "text", "name": "phone", "label": "Phone", "validations": [{"type": "required"}]}]'>
|
|
198
|
+
</easy-form>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
O programáticamente:
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
import { extendTemplate } from 'easy-forms-core'
|
|
205
|
+
|
|
206
|
+
const extendedSchema = extendTemplate('register', [
|
|
207
|
+
{
|
|
208
|
+
type: 'text',
|
|
209
|
+
name: 'company',
|
|
210
|
+
label: 'Company',
|
|
211
|
+
validations: [{ type: 'required' }]
|
|
212
|
+
}
|
|
213
|
+
])
|
|
214
|
+
|
|
215
|
+
form.schema = extendedSchema
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Mutua Exclusividad
|
|
219
|
+
|
|
220
|
+
Los atributos `template` y `schema` son mutuamente excluyentes. Si estableces uno, el otro será removido automáticamente:
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
// Si estableces template, schema será removido
|
|
224
|
+
form.template = 'login'
|
|
225
|
+
// schema ahora es null
|
|
226
|
+
|
|
227
|
+
// Si estableces schema, template será removido
|
|
228
|
+
form.schema = { fields: [...] }
|
|
229
|
+
// template ahora es null
|
|
230
|
+
```
|
|
231
|
+
|
|
147
232
|
## Características
|
|
148
233
|
|
|
149
234
|
- Web Component nativo
|
|
150
235
|
- Escrito en TypeScript
|
|
151
236
|
- JSON → Form automático
|
|
237
|
+
- **Templates pre-construidos** - 12 templates comunes listos para usar
|
|
152
238
|
- Validaciones integradas
|
|
153
239
|
- Steps / wizard forms
|
|
154
240
|
- Formularios anidados
|
package/dist/easy-form.d.ts
CHANGED
|
@@ -298,6 +298,10 @@ interface FormColors {
|
|
|
298
298
|
border?: string;
|
|
299
299
|
background?: string;
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Template names available
|
|
303
|
+
*/
|
|
304
|
+
type TemplateName = 'login' | 'register' | 'otp' | 'contact' | 'password-reset' | 'password-change' | 'profile' | 'checkout' | 'feedback' | 'subscription' | 'booking' | 'review';
|
|
301
305
|
/**
|
|
302
306
|
* Schema del formulario
|
|
303
307
|
*/
|
|
@@ -345,6 +349,22 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
345
349
|
* Establece el schema
|
|
346
350
|
*/
|
|
347
351
|
set schema(value: FormSchema | null);
|
|
352
|
+
/**
|
|
353
|
+
* Obtiene el template
|
|
354
|
+
*/
|
|
355
|
+
get template(): TemplateName | null;
|
|
356
|
+
/**
|
|
357
|
+
* Establece el template
|
|
358
|
+
*/
|
|
359
|
+
set template(value: TemplateName | null);
|
|
360
|
+
/**
|
|
361
|
+
* Obtiene los campos adicionales para extender el template
|
|
362
|
+
*/
|
|
363
|
+
get templateExtend(): Field[] | null;
|
|
364
|
+
/**
|
|
365
|
+
* Establece los campos adicionales para extender el template
|
|
366
|
+
*/
|
|
367
|
+
set templateExtend(value: Field[] | null);
|
|
348
368
|
/**
|
|
349
369
|
* Se llama cuando el componente se conecta al DOM
|
|
350
370
|
*/
|
|
@@ -357,6 +377,10 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
357
377
|
* Maneja el cambio de schema
|
|
358
378
|
*/
|
|
359
379
|
private handleSchemaChange;
|
|
380
|
+
/**
|
|
381
|
+
* Obtiene el schema desde un template
|
|
382
|
+
*/
|
|
383
|
+
private getSchemaFromTemplate;
|
|
360
384
|
/**
|
|
361
385
|
* Renderiza el formulario
|
|
362
386
|
*/
|