easy-forms-core 1.1.13 → 1.1.15
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/dist/easy-form.d.ts +6 -0
- package/dist/easy-form.js +136 -23
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +136 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/easy-form.d.ts
CHANGED
|
@@ -273,6 +273,10 @@ interface GroupField extends BaseField {
|
|
|
273
273
|
fields: Field[];
|
|
274
274
|
/** Dirección del layout del grupo (override del formulario) */
|
|
275
275
|
direction?: 'vertical' | 'horizontal';
|
|
276
|
+
/** Si true, el grupo se puede colapsar como acordeón */
|
|
277
|
+
collapsible?: boolean;
|
|
278
|
+
/** Si collapsible, estado inicial: true = abierto, false = cerrado (default: true) */
|
|
279
|
+
defaultOpen?: boolean;
|
|
276
280
|
}
|
|
277
281
|
/**
|
|
278
282
|
* Campo row
|
|
@@ -369,6 +373,8 @@ interface FormColors {
|
|
|
369
373
|
groupBackground?: string;
|
|
370
374
|
/** Color del título .easy-form-group-label */
|
|
371
375
|
groupTitle?: string;
|
|
376
|
+
/** Color del borde .easy-form-group */
|
|
377
|
+
groupBorder?: string;
|
|
372
378
|
}
|
|
373
379
|
/**
|
|
374
380
|
* Template names available
|
package/dist/easy-form.js
CHANGED
|
@@ -240,7 +240,8 @@ var defaultColors = {
|
|
|
240
240
|
border: "#ddd",
|
|
241
241
|
background: "#ffffff",
|
|
242
242
|
groupBackground: "#f8f9fa",
|
|
243
|
-
groupTitle: "#212529"
|
|
243
|
+
groupTitle: "#212529",
|
|
244
|
+
groupBorder: "#ddd"
|
|
244
245
|
};
|
|
245
246
|
function getColors(colors) {
|
|
246
247
|
return { ...defaultColors, ...colors };
|
|
@@ -264,6 +265,7 @@ function getBaseStyles(colors) {
|
|
|
264
265
|
--easy-form-background: ${colors.background};
|
|
265
266
|
--easy-form-group-background: ${colors.groupBackground};
|
|
266
267
|
--easy-form-group-title: ${colors.groupTitle};
|
|
268
|
+
--easy-form-group-border: ${colors.groupBorder};
|
|
267
269
|
}
|
|
268
270
|
.easy-form-field {
|
|
269
271
|
margin-bottom: 1rem;
|
|
@@ -520,6 +522,8 @@ function getBaseStyles(colors) {
|
|
|
520
522
|
padding: 1rem;
|
|
521
523
|
margin-bottom: 1rem;
|
|
522
524
|
background: var(--easy-form-group-background);
|
|
525
|
+
border: 1px solid var(--easy-form-group-border);
|
|
526
|
+
border-radius: 4px;
|
|
523
527
|
}
|
|
524
528
|
.easy-form-group-label {
|
|
525
529
|
color: var(--easy-form-group-title);
|
|
@@ -528,6 +532,52 @@ function getBaseStyles(colors) {
|
|
|
528
532
|
margin-bottom: 0.75rem;
|
|
529
533
|
margin-top: 0;
|
|
530
534
|
}
|
|
535
|
+
.easy-form-group-collapsible {
|
|
536
|
+
border: 1px solid var(--easy-form-group-border);
|
|
537
|
+
border-radius: 4px;
|
|
538
|
+
overflow: hidden;
|
|
539
|
+
}
|
|
540
|
+
.easy-form-group-collapsible .easy-form-group-header {
|
|
541
|
+
display: flex;
|
|
542
|
+
align-items: center;
|
|
543
|
+
justify-content: space-between;
|
|
544
|
+
padding: 0.75rem 1rem;
|
|
545
|
+
cursor: pointer;
|
|
546
|
+
background: var(--easy-form-group-background);
|
|
547
|
+
color: var(--easy-form-group-title);
|
|
548
|
+
font-weight: 600;
|
|
549
|
+
font-size: 1rem;
|
|
550
|
+
user-select: none;
|
|
551
|
+
transition: background-color 0.2s ease;
|
|
552
|
+
width: 100%;
|
|
553
|
+
border none;
|
|
554
|
+
}
|
|
555
|
+
.easy-form-group-collapsible .easy-form-group-header:hover {
|
|
556
|
+
background: rgba(0, 0, 0, 0.03);
|
|
557
|
+
}
|
|
558
|
+
.easy-form-group-collapsible .easy-form-group-header:focus {
|
|
559
|
+
outline: none;
|
|
560
|
+
box-shadow: inset 0 0 0 2px var(--easy-form-primary);
|
|
561
|
+
}
|
|
562
|
+
.easy-form-group-collapsible .easy-form-group-chevron {
|
|
563
|
+
flex-shrink: 0;
|
|
564
|
+
margin-left: 0.5rem;
|
|
565
|
+
transition: transform 0.2s ease;
|
|
566
|
+
color: var(--easy-form-secondary);
|
|
567
|
+
}
|
|
568
|
+
.easy-form-group-collapsible.easy-form-group-collapsed .easy-form-group-chevron {
|
|
569
|
+
transform: rotate(-90deg); /* \u25BC \u2192 \u25B6 cuando colapsado */
|
|
570
|
+
}
|
|
571
|
+
.easy-form-group-collapsible .easy-form-group-content {
|
|
572
|
+
overflow: hidden;
|
|
573
|
+
transition: max-height 0.3s ease;
|
|
574
|
+
padding: 0 1rem 1rem 1rem;
|
|
575
|
+
}
|
|
576
|
+
.easy-form-group-collapsible.easy-form-group-collapsed .easy-form-group-content {
|
|
577
|
+
max-height: 0 !important;
|
|
578
|
+
padding-top: 0;
|
|
579
|
+
padding-bottom: 0;
|
|
580
|
+
}
|
|
531
581
|
.easy-form-row {
|
|
532
582
|
display: flex;
|
|
533
583
|
flex-wrap: wrap;
|
|
@@ -1097,7 +1147,7 @@ function getPlanoStyles(_colors) {
|
|
|
1097
1147
|
}
|
|
1098
1148
|
.easy-form-group {
|
|
1099
1149
|
border: none;
|
|
1100
|
-
border-bottom: 1px solid var(--easy-form-border);
|
|
1150
|
+
border-bottom: 1px solid var(--easy-form-group-border);
|
|
1101
1151
|
border-radius: 0;
|
|
1102
1152
|
background: transparent;
|
|
1103
1153
|
}
|
|
@@ -1132,7 +1182,7 @@ function getTradicionalStyles(_colors) {
|
|
|
1132
1182
|
font-weight: 500;
|
|
1133
1183
|
}
|
|
1134
1184
|
.easy-form-group {
|
|
1135
|
-
border: 2px solid var(--easy-form-border);
|
|
1185
|
+
border: 2px solid var(--easy-form-group-border);
|
|
1136
1186
|
border-radius: 4px;
|
|
1137
1187
|
background: var(--easy-form-group-background);
|
|
1138
1188
|
}
|
|
@@ -1226,7 +1276,7 @@ function getRoundedShadowStyles(_colors) {
|
|
|
1226
1276
|
transform: translateY(-2px);
|
|
1227
1277
|
}
|
|
1228
1278
|
.easy-form-group {
|
|
1229
|
-
border: 1px solid var(--easy-form-border);
|
|
1279
|
+
border: 1px solid var(--easy-form-group-border);
|
|
1230
1280
|
border-radius: 16px;
|
|
1231
1281
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
1232
1282
|
background: var(--easy-form-group-background);
|
|
@@ -1280,7 +1330,7 @@ function getLinesStyles(_colors) {
|
|
|
1280
1330
|
}
|
|
1281
1331
|
.easy-form-group {
|
|
1282
1332
|
border: none;
|
|
1283
|
-
border-bottom: 2px solid var(--easy-form-border);
|
|
1333
|
+
border-bottom: 2px solid var(--easy-form-group-border);
|
|
1284
1334
|
border-radius: 0;
|
|
1285
1335
|
padding-bottom: 1rem;
|
|
1286
1336
|
background: transparent;
|
|
@@ -1358,7 +1408,7 @@ function getShadcnStyles(_colors) {
|
|
|
1358
1408
|
box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
|
|
1359
1409
|
}
|
|
1360
1410
|
.easy-form-group {
|
|
1361
|
-
border: 1.5px solid
|
|
1411
|
+
border: 1.5px solid var(--easy-form-group-border);
|
|
1362
1412
|
border-radius: 12px;
|
|
1363
1413
|
background: var(--easy-form-group-background);
|
|
1364
1414
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
@@ -1455,7 +1505,7 @@ function getChakraStyles(_colors) {
|
|
|
1455
1505
|
transform: none;
|
|
1456
1506
|
}
|
|
1457
1507
|
.easy-form-group {
|
|
1458
|
-
border: 2px solid
|
|
1508
|
+
border: 2px solid var(--easy-form-group-border);
|
|
1459
1509
|
border-radius: 8px;
|
|
1460
1510
|
background: var(--easy-form-group-background);
|
|
1461
1511
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
@@ -1536,7 +1586,7 @@ function getMantineStyles(_colors) {
|
|
|
1536
1586
|
box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
|
1537
1587
|
}
|
|
1538
1588
|
.easy-form-group {
|
|
1539
|
-
border: 1px solid
|
|
1589
|
+
border: 1px solid var(--easy-form-group-border);
|
|
1540
1590
|
border-radius: 16px;
|
|
1541
1591
|
background: var(--easy-form-group-background);
|
|
1542
1592
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
@@ -1627,7 +1677,7 @@ function getGlassStyles(_colors) {
|
|
|
1627
1677
|
transform: translateY(-1px) scale(0.98);
|
|
1628
1678
|
}
|
|
1629
1679
|
.easy-form-group {
|
|
1630
|
-
border: 2px solid
|
|
1680
|
+
border: 2px solid var(--easy-form-group-border);
|
|
1631
1681
|
border-radius: 20px;
|
|
1632
1682
|
background: var(--easy-form-group-background);
|
|
1633
1683
|
backdrop-filter: blur(20px) saturate(180%);
|
|
@@ -1721,7 +1771,7 @@ function getBorderedStyles(_colors) {
|
|
|
1721
1771
|
box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
|
|
1722
1772
|
}
|
|
1723
1773
|
.easy-form-group {
|
|
1724
|
-
border: 4px solid
|
|
1774
|
+
border: 4px solid var(--easy-form-group-border);
|
|
1725
1775
|
border-radius: 0;
|
|
1726
1776
|
background: var(--easy-form-group-background);
|
|
1727
1777
|
box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
|
|
@@ -1833,7 +1883,7 @@ function getMinimalStyles(_colors) {
|
|
|
1833
1883
|
}
|
|
1834
1884
|
.easy-form-group {
|
|
1835
1885
|
border: none;
|
|
1836
|
-
border-bottom: 1px solid
|
|
1886
|
+
border-bottom: 1px solid var(--easy-form-group-border);
|
|
1837
1887
|
border-radius: 0;
|
|
1838
1888
|
background: transparent;
|
|
1839
1889
|
padding-bottom: 2rem;
|
|
@@ -6395,21 +6445,84 @@ var EasyForm = class extends BrowserHTMLElement {
|
|
|
6395
6445
|
* Renderiza un grupo de campos
|
|
6396
6446
|
*/
|
|
6397
6447
|
renderGroup(field) {
|
|
6398
|
-
const groupContainer = document.createElement("div");
|
|
6399
6448
|
const groupField = field;
|
|
6400
6449
|
const dir = groupField.direction ?? "vertical";
|
|
6450
|
+
const collapsible = groupField.collapsible === true;
|
|
6451
|
+
const defaultOpen = groupField.defaultOpen !== false;
|
|
6452
|
+
const groupContainer = document.createElement("div");
|
|
6401
6453
|
groupContainer.className = `easy-form-group easy-form-direction-${dir}`;
|
|
6402
|
-
if (
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6454
|
+
if (collapsible) {
|
|
6455
|
+
groupContainer.classList.add("easy-form-group-collapsible");
|
|
6456
|
+
if (!defaultOpen) {
|
|
6457
|
+
groupContainer.classList.add("easy-form-group-collapsed");
|
|
6458
|
+
}
|
|
6459
|
+
const header = document.createElement("button");
|
|
6460
|
+
header.type = "button";
|
|
6461
|
+
header.className = "easy-form-group-header";
|
|
6462
|
+
header.setAttribute("aria-expanded", String(defaultOpen));
|
|
6463
|
+
const groupContentId = `easy-form-group-${(field.name || "group").replace(/[^a-z0-9]/gi, "-")}-content`;
|
|
6464
|
+
header.setAttribute("aria-controls", groupContentId);
|
|
6465
|
+
const labelSpan = document.createElement("span");
|
|
6466
|
+
labelSpan.textContent = field.label || "Grupo";
|
|
6467
|
+
const chevron = document.createElement("span");
|
|
6468
|
+
chevron.className = "easy-form-group-chevron";
|
|
6469
|
+
chevron.setAttribute("aria-hidden", "true");
|
|
6470
|
+
chevron.textContent = "\u25BC";
|
|
6471
|
+
header.appendChild(labelSpan);
|
|
6472
|
+
header.appendChild(chevron);
|
|
6473
|
+
groupContainer.appendChild(header);
|
|
6474
|
+
const content = document.createElement("div");
|
|
6475
|
+
content.id = groupContentId;
|
|
6476
|
+
content.className = "easy-form-group-content";
|
|
6477
|
+
if ("fields" in field && field.fields) {
|
|
6478
|
+
for (const subField of field.fields) {
|
|
6479
|
+
const fieldElement = this.renderField(subField);
|
|
6480
|
+
if (fieldElement) {
|
|
6481
|
+
content.appendChild(fieldElement);
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
groupContainer.appendChild(content);
|
|
6486
|
+
const setContentHeight = (open) => {
|
|
6487
|
+
if (open) {
|
|
6488
|
+
content.style.maxHeight = content.scrollHeight + "px";
|
|
6489
|
+
} else {
|
|
6490
|
+
content.style.maxHeight = "0";
|
|
6491
|
+
}
|
|
6492
|
+
};
|
|
6493
|
+
if (defaultOpen) {
|
|
6494
|
+
requestAnimationFrame(() => setContentHeight(true));
|
|
6495
|
+
} else {
|
|
6496
|
+
content.style.maxHeight = "0";
|
|
6497
|
+
}
|
|
6498
|
+
header.addEventListener("click", () => {
|
|
6499
|
+
const isCollapsed = groupContainer.classList.contains("easy-form-group-collapsed");
|
|
6500
|
+
if (isCollapsed) {
|
|
6501
|
+
groupContainer.classList.remove("easy-form-group-collapsed");
|
|
6502
|
+
header.setAttribute("aria-expanded", "true");
|
|
6503
|
+
setContentHeight(true);
|
|
6504
|
+
} else {
|
|
6505
|
+
content.style.maxHeight = content.scrollHeight + "px";
|
|
6506
|
+
requestAnimationFrame(() => {
|
|
6507
|
+
groupContainer.classList.add("easy-form-group-collapsed");
|
|
6508
|
+
header.setAttribute("aria-expanded", "false");
|
|
6509
|
+
setContentHeight(false);
|
|
6510
|
+
});
|
|
6511
|
+
}
|
|
6512
|
+
});
|
|
6513
|
+
} else {
|
|
6514
|
+
if (field.label) {
|
|
6515
|
+
const label = document.createElement("h3");
|
|
6516
|
+
label.className = "easy-form-group-label";
|
|
6517
|
+
label.textContent = field.label;
|
|
6518
|
+
groupContainer.appendChild(label);
|
|
6519
|
+
}
|
|
6520
|
+
if ("fields" in field && field.fields) {
|
|
6521
|
+
for (const subField of field.fields) {
|
|
6522
|
+
const fieldElement = this.renderField(subField);
|
|
6523
|
+
if (fieldElement) {
|
|
6524
|
+
groupContainer.appendChild(fieldElement);
|
|
6525
|
+
}
|
|
6413
6526
|
}
|
|
6414
6527
|
}
|
|
6415
6528
|
}
|