easy-forms-core 1.1.13 → 1.1.14
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 +134 -23
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +134 -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,50 @@ 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
|
+
}
|
|
553
|
+
.easy-form-group-collapsible .easy-form-group-header:hover {
|
|
554
|
+
background: rgba(0, 0, 0, 0.03);
|
|
555
|
+
}
|
|
556
|
+
.easy-form-group-collapsible .easy-form-group-header:focus {
|
|
557
|
+
outline: none;
|
|
558
|
+
box-shadow: inset 0 0 0 2px var(--easy-form-primary);
|
|
559
|
+
}
|
|
560
|
+
.easy-form-group-collapsible .easy-form-group-chevron {
|
|
561
|
+
flex-shrink: 0;
|
|
562
|
+
margin-left: 0.5rem;
|
|
563
|
+
transition: transform 0.2s ease;
|
|
564
|
+
color: var(--easy-form-secondary);
|
|
565
|
+
}
|
|
566
|
+
.easy-form-group-collapsible.easy-form-group-collapsed .easy-form-group-chevron {
|
|
567
|
+
transform: rotate(-90deg); /* \u25BC \u2192 \u25B6 cuando colapsado */
|
|
568
|
+
}
|
|
569
|
+
.easy-form-group-collapsible .easy-form-group-content {
|
|
570
|
+
overflow: hidden;
|
|
571
|
+
transition: max-height 0.3s ease;
|
|
572
|
+
padding: 0 1rem 1rem 1rem;
|
|
573
|
+
}
|
|
574
|
+
.easy-form-group-collapsible.easy-form-group-collapsed .easy-form-group-content {
|
|
575
|
+
max-height: 0 !important;
|
|
576
|
+
padding-top: 0;
|
|
577
|
+
padding-bottom: 0;
|
|
578
|
+
}
|
|
531
579
|
.easy-form-row {
|
|
532
580
|
display: flex;
|
|
533
581
|
flex-wrap: wrap;
|
|
@@ -1097,7 +1145,7 @@ function getPlanoStyles(_colors) {
|
|
|
1097
1145
|
}
|
|
1098
1146
|
.easy-form-group {
|
|
1099
1147
|
border: none;
|
|
1100
|
-
border-bottom: 1px solid var(--easy-form-border);
|
|
1148
|
+
border-bottom: 1px solid var(--easy-form-group-border);
|
|
1101
1149
|
border-radius: 0;
|
|
1102
1150
|
background: transparent;
|
|
1103
1151
|
}
|
|
@@ -1132,7 +1180,7 @@ function getTradicionalStyles(_colors) {
|
|
|
1132
1180
|
font-weight: 500;
|
|
1133
1181
|
}
|
|
1134
1182
|
.easy-form-group {
|
|
1135
|
-
border: 2px solid var(--easy-form-border);
|
|
1183
|
+
border: 2px solid var(--easy-form-group-border);
|
|
1136
1184
|
border-radius: 4px;
|
|
1137
1185
|
background: var(--easy-form-group-background);
|
|
1138
1186
|
}
|
|
@@ -1226,7 +1274,7 @@ function getRoundedShadowStyles(_colors) {
|
|
|
1226
1274
|
transform: translateY(-2px);
|
|
1227
1275
|
}
|
|
1228
1276
|
.easy-form-group {
|
|
1229
|
-
border: 1px solid var(--easy-form-border);
|
|
1277
|
+
border: 1px solid var(--easy-form-group-border);
|
|
1230
1278
|
border-radius: 16px;
|
|
1231
1279
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
1232
1280
|
background: var(--easy-form-group-background);
|
|
@@ -1280,7 +1328,7 @@ function getLinesStyles(_colors) {
|
|
|
1280
1328
|
}
|
|
1281
1329
|
.easy-form-group {
|
|
1282
1330
|
border: none;
|
|
1283
|
-
border-bottom: 2px solid var(--easy-form-border);
|
|
1331
|
+
border-bottom: 2px solid var(--easy-form-group-border);
|
|
1284
1332
|
border-radius: 0;
|
|
1285
1333
|
padding-bottom: 1rem;
|
|
1286
1334
|
background: transparent;
|
|
@@ -1358,7 +1406,7 @@ function getShadcnStyles(_colors) {
|
|
|
1358
1406
|
box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
|
|
1359
1407
|
}
|
|
1360
1408
|
.easy-form-group {
|
|
1361
|
-
border: 1.5px solid
|
|
1409
|
+
border: 1.5px solid var(--easy-form-group-border);
|
|
1362
1410
|
border-radius: 12px;
|
|
1363
1411
|
background: var(--easy-form-group-background);
|
|
1364
1412
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
@@ -1455,7 +1503,7 @@ function getChakraStyles(_colors) {
|
|
|
1455
1503
|
transform: none;
|
|
1456
1504
|
}
|
|
1457
1505
|
.easy-form-group {
|
|
1458
|
-
border: 2px solid
|
|
1506
|
+
border: 2px solid var(--easy-form-group-border);
|
|
1459
1507
|
border-radius: 8px;
|
|
1460
1508
|
background: var(--easy-form-group-background);
|
|
1461
1509
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
@@ -1536,7 +1584,7 @@ function getMantineStyles(_colors) {
|
|
|
1536
1584
|
box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
|
1537
1585
|
}
|
|
1538
1586
|
.easy-form-group {
|
|
1539
|
-
border: 1px solid
|
|
1587
|
+
border: 1px solid var(--easy-form-group-border);
|
|
1540
1588
|
border-radius: 16px;
|
|
1541
1589
|
background: var(--easy-form-group-background);
|
|
1542
1590
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
@@ -1627,7 +1675,7 @@ function getGlassStyles(_colors) {
|
|
|
1627
1675
|
transform: translateY(-1px) scale(0.98);
|
|
1628
1676
|
}
|
|
1629
1677
|
.easy-form-group {
|
|
1630
|
-
border: 2px solid
|
|
1678
|
+
border: 2px solid var(--easy-form-group-border);
|
|
1631
1679
|
border-radius: 20px;
|
|
1632
1680
|
background: var(--easy-form-group-background);
|
|
1633
1681
|
backdrop-filter: blur(20px) saturate(180%);
|
|
@@ -1721,7 +1769,7 @@ function getBorderedStyles(_colors) {
|
|
|
1721
1769
|
box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
|
|
1722
1770
|
}
|
|
1723
1771
|
.easy-form-group {
|
|
1724
|
-
border: 4px solid
|
|
1772
|
+
border: 4px solid var(--easy-form-group-border);
|
|
1725
1773
|
border-radius: 0;
|
|
1726
1774
|
background: var(--easy-form-group-background);
|
|
1727
1775
|
box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
|
|
@@ -1833,7 +1881,7 @@ function getMinimalStyles(_colors) {
|
|
|
1833
1881
|
}
|
|
1834
1882
|
.easy-form-group {
|
|
1835
1883
|
border: none;
|
|
1836
|
-
border-bottom: 1px solid
|
|
1884
|
+
border-bottom: 1px solid var(--easy-form-group-border);
|
|
1837
1885
|
border-radius: 0;
|
|
1838
1886
|
background: transparent;
|
|
1839
1887
|
padding-bottom: 2rem;
|
|
@@ -6395,21 +6443,84 @@ var EasyForm = class extends BrowserHTMLElement {
|
|
|
6395
6443
|
* Renderiza un grupo de campos
|
|
6396
6444
|
*/
|
|
6397
6445
|
renderGroup(field) {
|
|
6398
|
-
const groupContainer = document.createElement("div");
|
|
6399
6446
|
const groupField = field;
|
|
6400
6447
|
const dir = groupField.direction ?? "vertical";
|
|
6448
|
+
const collapsible = groupField.collapsible === true;
|
|
6449
|
+
const defaultOpen = groupField.defaultOpen !== false;
|
|
6450
|
+
const groupContainer = document.createElement("div");
|
|
6401
6451
|
groupContainer.className = `easy-form-group easy-form-direction-${dir}`;
|
|
6402
|
-
if (
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6452
|
+
if (collapsible) {
|
|
6453
|
+
groupContainer.classList.add("easy-form-group-collapsible");
|
|
6454
|
+
if (!defaultOpen) {
|
|
6455
|
+
groupContainer.classList.add("easy-form-group-collapsed");
|
|
6456
|
+
}
|
|
6457
|
+
const header = document.createElement("button");
|
|
6458
|
+
header.type = "button";
|
|
6459
|
+
header.className = "easy-form-group-header";
|
|
6460
|
+
header.setAttribute("aria-expanded", String(defaultOpen));
|
|
6461
|
+
const groupContentId = `easy-form-group-${(field.name || "group").replace(/[^a-z0-9]/gi, "-")}-content`;
|
|
6462
|
+
header.setAttribute("aria-controls", groupContentId);
|
|
6463
|
+
const labelSpan = document.createElement("span");
|
|
6464
|
+
labelSpan.textContent = field.label || "Grupo";
|
|
6465
|
+
const chevron = document.createElement("span");
|
|
6466
|
+
chevron.className = "easy-form-group-chevron";
|
|
6467
|
+
chevron.setAttribute("aria-hidden", "true");
|
|
6468
|
+
chevron.textContent = "\u25BC";
|
|
6469
|
+
header.appendChild(labelSpan);
|
|
6470
|
+
header.appendChild(chevron);
|
|
6471
|
+
groupContainer.appendChild(header);
|
|
6472
|
+
const content = document.createElement("div");
|
|
6473
|
+
content.id = groupContentId;
|
|
6474
|
+
content.className = "easy-form-group-content";
|
|
6475
|
+
if ("fields" in field && field.fields) {
|
|
6476
|
+
for (const subField of field.fields) {
|
|
6477
|
+
const fieldElement = this.renderField(subField);
|
|
6478
|
+
if (fieldElement) {
|
|
6479
|
+
content.appendChild(fieldElement);
|
|
6480
|
+
}
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
groupContainer.appendChild(content);
|
|
6484
|
+
const setContentHeight = (open) => {
|
|
6485
|
+
if (open) {
|
|
6486
|
+
content.style.maxHeight = content.scrollHeight + "px";
|
|
6487
|
+
} else {
|
|
6488
|
+
content.style.maxHeight = "0";
|
|
6489
|
+
}
|
|
6490
|
+
};
|
|
6491
|
+
if (defaultOpen) {
|
|
6492
|
+
requestAnimationFrame(() => setContentHeight(true));
|
|
6493
|
+
} else {
|
|
6494
|
+
content.style.maxHeight = "0";
|
|
6495
|
+
}
|
|
6496
|
+
header.addEventListener("click", () => {
|
|
6497
|
+
const isCollapsed = groupContainer.classList.contains("easy-form-group-collapsed");
|
|
6498
|
+
if (isCollapsed) {
|
|
6499
|
+
groupContainer.classList.remove("easy-form-group-collapsed");
|
|
6500
|
+
header.setAttribute("aria-expanded", "true");
|
|
6501
|
+
setContentHeight(true);
|
|
6502
|
+
} else {
|
|
6503
|
+
content.style.maxHeight = content.scrollHeight + "px";
|
|
6504
|
+
requestAnimationFrame(() => {
|
|
6505
|
+
groupContainer.classList.add("easy-form-group-collapsed");
|
|
6506
|
+
header.setAttribute("aria-expanded", "false");
|
|
6507
|
+
setContentHeight(false);
|
|
6508
|
+
});
|
|
6509
|
+
}
|
|
6510
|
+
});
|
|
6511
|
+
} else {
|
|
6512
|
+
if (field.label) {
|
|
6513
|
+
const label = document.createElement("h3");
|
|
6514
|
+
label.className = "easy-form-group-label";
|
|
6515
|
+
label.textContent = field.label;
|
|
6516
|
+
groupContainer.appendChild(label);
|
|
6517
|
+
}
|
|
6518
|
+
if ("fields" in field && field.fields) {
|
|
6519
|
+
for (const subField of field.fields) {
|
|
6520
|
+
const fieldElement = this.renderField(subField);
|
|
6521
|
+
if (fieldElement) {
|
|
6522
|
+
groupContainer.appendChild(fieldElement);
|
|
6523
|
+
}
|
|
6413
6524
|
}
|
|
6414
6525
|
}
|
|
6415
6526
|
}
|